use of com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction in project android_packages_apps_Trebuchet by LineageOS.
the class LauncherProvider method bulkInsert.
@Override
public int bulkInsert(Uri uri, ContentValues[] values) {
createDbIfNotExists();
SqlArguments args = new SqlArguments(uri);
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
try (SQLiteTransaction t = new SQLiteTransaction(db)) {
int numValues = values.length;
for (int i = 0; i < numValues; i++) {
addModifiedTime(values[i]);
if (dbInsertAndCheck(mOpenHelper, db, args.table, null, values[i]) < 0) {
return 0;
}
}
onAddOrDeleteOp(db);
t.commit();
}
reloadLauncherIfExternal();
return values.length;
}
use of com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction in project android_packages_apps_Trebuchet by LineageOS.
the class RestoreDbTask method performRestore.
public static boolean performRestore(Context context, DatabaseHelper helper, BackupManager backupManager) {
SQLiteDatabase db = helper.getWritableDatabase();
try (SQLiteTransaction t = new SQLiteTransaction(db)) {
RestoreDbTask task = new RestoreDbTask();
task.backupWorkspace(context, db);
task.sanitizeDB(helper, db, backupManager);
task.restoreAppWidgetIdsIfExists(context);
t.commit();
return true;
} catch (Exception e) {
FileLog.e(TAG, "Failed to verify db", e);
return false;
}
}
use of com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction in project Neo-Launcher by NeoApplications.
the class HomeWidgetMigrationTask method migrateIfNeeded.
@SuppressLint("ApplySharedPref")
public static void migrateIfNeeded(Context context) {
SharedPreferences prefs = Utilities.getPrefs(context);
boolean needsMigration = !prefs.getBoolean(PREF_MIGRATION_STATUS, false) && prefs.getBoolean(SMARTSPACE_PREF, false);
if (!needsMigration)
return;
// Save the pref so we only run migration once
prefs.edit().putBoolean(PREF_MIGRATION_STATUS, true).commit();
HashSet<String> validPackages = getValidPackages(context);
InvariantDeviceProfile idp = LauncherAppState.getIDP(context);
Point size = new Point(idp.numColumns, idp.numRows);
long migrationStartTime = System.currentTimeMillis();
try (SQLiteTransaction transaction = (SQLiteTransaction) Settings.call(context.getContentResolver(), Settings.METHOD_NEW_TRANSACTION).getBinder(Settings.EXTRA_VALUE)) {
if (!new HomeWidgetMigrationTask(context, transaction.getDb(), validPackages, size).migrateWorkspace()) {
throw new RuntimeException("Failed to migrate Smartspace");
}
} catch (Exception e) {
Log.e(TAG, "Error during grid migration", e);
} finally {
Log.v(TAG, "Home widget migration completed in " + (System.currentTimeMillis() - migrationStartTime));
}
}
use of com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction in project Neo-Launcher by NeoApplications.
the class RestoreDbTask method performRestore.
public static boolean performRestore(Context context, DatabaseHelper helper, BackupManager backupManager) {
SQLiteDatabase db = helper.getWritableDatabase();
try (SQLiteTransaction t = new SQLiteTransaction(db)) {
RestoreDbTask task = new RestoreDbTask();
task.sanitizeDB(helper, db, backupManager);
task.restoreAppWidgetIdsIfExists(context);
t.commit();
return true;
} catch (Exception e) {
FileLog.e(TAG, "Failed to verify db", e);
return false;
}
}
use of com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction in project Neo-Launcher by NeoApplications.
the class GridSizeMigrationTask method removeBrokenHotseatItems.
/**
* Removes any broken item from the hotseat.
*
* @return a map with occupied hotseat position set to non-null value.
*/
public static IntSparseArrayMap<Object> removeBrokenHotseatItems(Context context) throws Exception {
try (SQLiteTransaction transaction = (SQLiteTransaction) Settings.call(context.getContentResolver(), Settings.METHOD_NEW_TRANSACTION).getBinder(Settings.EXTRA_VALUE)) {
GridSizeMigrationTask task = new GridSizeMigrationTask(context, transaction.getDb(), getValidPackages(context), Integer.MAX_VALUE, Integer.MAX_VALUE);
// Load all the valid entries
ArrayList<DbEntry> items = task.loadHotseatEntries();
// Delete any entry marked for deletion by above load.
task.applyOperations();
IntSparseArrayMap<Object> positions = new IntSparseArrayMap<>();
for (DbEntry item : items) {
positions.put(item.screenId, item);
}
transaction.commit();
return positions;
}
}
Aggregations