Merge "Using add/replace instead of update when updating an entry." into ub-launcher3-calgary-polish

This commit is contained in:
Sunny Goyal
2016-10-07 18:04:15 +00:00
committed by Android (Google) Code Review
2 changed files with 9 additions and 23 deletions
+9 -7
View File
@@ -772,13 +772,15 @@ public class IconCache {
public void run() { public void run() {
if (!mAppsToUpdate.isEmpty()) { if (!mAppsToUpdate.isEmpty()) {
LauncherActivityInfoCompat app = mAppsToUpdate.pop(); LauncherActivityInfoCompat app = mAppsToUpdate.pop();
String cn = app.getComponentName().flattenToString(); String pkg = app.getComponentName().getPackageName();
ContentValues values = updateCacheAndGetContentValues(app, true); PackageInfo info = mPkgInfoMap.get(pkg);
mIconDb.update(values, if (info != null) {
IconDB.COLUMN_COMPONENT + " = ? AND " + IconDB.COLUMN_USER + " = ?", synchronized (IconCache.this) {
new String[]{cn, Long.toString(mUserSerial)}); ContentValues values = updateCacheAndGetContentValues(app, true);
mUpdatedPackages.add(app.getComponentName().getPackageName()); addIconToDB(values, app.getComponentName(), info, mUserSerial);
}
mUpdatedPackages.add(pkg);
}
if (mAppsToUpdate.isEmpty() && !mUpdatedPackages.isEmpty()) { if (mAppsToUpdate.isEmpty() && !mUpdatedPackages.isEmpty()) {
// No more app to update. Notify model. // No more app to update. Notify model.
LauncherAppState.getInstance().getModel().onPackageIconsUpdated( LauncherAppState.getInstance().getModel().onPackageIconsUpdated(
@@ -28,22 +28,6 @@ public abstract class SQLiteCacheHelper {
mIgnoreWrites = false; mIgnoreWrites = false;
} }
/**
* @see SQLiteDatabase#update(String, ContentValues, String, String[])
*/
public void update(ContentValues values, String whereClause, String[] whereArgs) {
if (mIgnoreWrites) {
return;
}
try {
mOpenHelper.getWritableDatabase().update(mTableName, values, whereClause, whereArgs);
} catch (SQLiteFullException e) {
onDiskFull(e);
} catch (SQLiteException e) {
Log.d(TAG, "Ignoring sqlite exception", e);
}
}
/** /**
* @see SQLiteDatabase#delete(String, String, String[]) * @see SQLiteDatabase#delete(String, String, String[])
*/ */