use of com.android.launcher3.util.LauncherModelHelper in project android_packages_apps_Launcher3 by ArrowOS.
the class CacheDataUpdatedTaskTest method setup.
@Before
public void setup() throws Exception {
mModelHelper = new LauncherModelHelper();
mModelHelper.initializeData("cache_data_updated_task_data");
// Add placeholder entries in the cache to simulate update
Context context = mModelHelper.sandboxContext;
IconCache iconCache = LauncherAppState.getInstance(context).getIconCache();
CachingLogic<ItemInfo> placeholderLogic = new CachingLogic<ItemInfo>() {
@Override
public ComponentName getComponent(ItemInfo info) {
return info.getTargetComponent();
}
@Override
public UserHandle getUser(ItemInfo info) {
return info.user;
}
@Override
public CharSequence getLabel(ItemInfo info) {
return NEW_LABEL_PREFIX + info.id;
}
@NonNull
@Override
public BitmapInfo loadIcon(Context context, ItemInfo info) {
return BitmapInfo.of(Bitmap.createBitmap(1, 1, Config.ARGB_8888), Color.RED);
}
};
UserManager um = context.getSystemService(UserManager.class);
for (ItemInfo info : mModelHelper.getBgDataModel().itemsIdMap) {
iconCache.addIconToDBAndMemCache(info, placeholderLogic, new PackageInfo(), um.getSerialNumberForUser(info.user), true);
}
}
use of com.android.launcher3.util.LauncherModelHelper in project android_packages_apps_Launcher3 by ArrowOS.
the class BackupRestoreTest method setUp.
@Before
public void setUp() {
mModelHelper = new LauncherModelHelper();
mCurrentMyProfileId = mModelHelper.defaultProfileId;
mOldMyProfileId = mCurrentMyProfileId + 1;
mCurrentWorkProfileId = mOldMyProfileId + 1;
mOldWorkProfileId = mCurrentWorkProfileId + 1;
mWorkUserHandle = UserHandle.getUserHandleForUid(PER_USER_RANGE);
mUserChangeListener = UserCache.INSTANCE.get(mModelHelper.sandboxContext).addUserChangeListener(() -> {
});
setupUserManager();
setupBackupManager();
RestoreDbTask.setPending(mModelHelper.sandboxContext);
mDb = mModelHelper.provider.getDb();
mIdp = InvariantDeviceProfile.INSTANCE.get(mModelHelper.sandboxContext);
}
use of com.android.launcher3.util.LauncherModelHelper in project android_packages_apps_Launcher3 by ArrowOS.
the class LauncherModelHelper method setupDefaultLayoutProvider.
/**
* Sets up a mock provider to load the provided layout by default, next time the layout loads
*/
public LauncherModelHelper setupDefaultLayoutProvider(LauncherLayoutBuilder builder) throws Exception {
InvariantDeviceProfile idp = InvariantDeviceProfile.INSTANCE.get(sandboxContext);
idp.numRows = idp.numColumns = idp.numDatabaseHotseatIcons = DEFAULT_GRID_SIZE;
idp.iconBitmapSize = DEFAULT_BITMAP_SIZE;
UiDevice.getInstance(getInstrumentation()).executeShellCommand("settings put secure launcher3.layout.provider " + TEST_PROVIDER_AUTHORITY);
ContentProvider cp = new TestInformationProvider() {
@Override
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
try {
ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
AutoCloseOutputStream outputStream = new AutoCloseOutputStream(pipe[1]);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
builder.build(new OutputStreamWriter(bos));
outputStream.write(bos.toByteArray());
outputStream.flush();
outputStream.close();
return pipe[0];
} catch (Exception e) {
throw new FileNotFoundException(e.getMessage());
}
}
};
setupProvider(TEST_PROVIDER_AUTHORITY, cp);
return this;
}
use of com.android.launcher3.util.LauncherModelHelper in project android_packages_apps_Launcher3 by AOSPA.
the class BackupRestoreTest method setUp.
@Before
public void setUp() {
mModelHelper = new LauncherModelHelper();
mCurrentMyProfileId = mModelHelper.defaultProfileId;
mOldMyProfileId = mCurrentMyProfileId + 1;
mCurrentWorkProfileId = mOldMyProfileId + 1;
mOldWorkProfileId = mCurrentWorkProfileId + 1;
mWorkUserHandle = UserHandle.getUserHandleForUid(PER_USER_RANGE);
mUserChangeListener = UserCache.INSTANCE.get(mModelHelper.sandboxContext).addUserChangeListener(() -> {
});
setupUserManager();
setupBackupManager();
RestoreDbTask.setPending(mModelHelper.sandboxContext);
mDb = mModelHelper.provider.getDb();
mIdp = InvariantDeviceProfile.INSTANCE.get(mModelHelper.sandboxContext);
}
use of com.android.launcher3.util.LauncherModelHelper in project android_packages_apps_Launcher3 by AOSPA.
the class GridSizeMigrationTaskV2Test method setUp.
@Before
public void setUp() {
mModelHelper = new LauncherModelHelper();
mContext = mModelHelper.sandboxContext;
mDb = mModelHelper.provider.getDb();
mValidPackages = new HashSet<>();
mValidPackages.add(TEST_PACKAGE);
mValidPackages.add(testPackage1);
mValidPackages.add(testPackage2);
mValidPackages.add(testPackage3);
mValidPackages.add(testPackage4);
mValidPackages.add(testPackage5);
mValidPackages.add(testPackage6);
mValidPackages.add(testPackage7);
mValidPackages.add(testPackage8);
mValidPackages.add(testPackage9);
mValidPackages.add(testPackage10);
mIdp = InvariantDeviceProfile.INSTANCE.get(mContext);
long userSerial = UserCache.INSTANCE.get(mContext).getSerialNumberForUser(Process.myUserHandle());
dropTable(mDb, LauncherSettings.Favorites.TMP_TABLE);
LauncherSettings.Favorites.addTableToDb(mDb, userSerial, false, LauncherSettings.Favorites.TMP_TABLE);
}
Aggregations