Merge "Reloading launcher whenever there is an external update to contentprovider, irrespective of the uri" into ub-launcher3-burnaby

This commit is contained in:
Sunny Goyal
2015-08-13 23:48:04 +00:00
committed by Android (Google) Code Review
+16 -13
View File
@@ -77,8 +77,6 @@ public class LauncherProvider extends ContentProvider {
static final String TABLE_WORKSPACE_SCREENS = LauncherSettings.WorkspaceScreens.TABLE_NAME;
static final String EMPTY_DATABASE_CREATED = "EMPTY_DATABASE_CREATED";
private static final String URI_PARAM_IS_EXTERNAL_ADD = "isExternalAdd";
private static final String RESTRICTION_PACKAGE_NAME = "workspace.configuration.package.name";
@Thunk LauncherProviderChangeListener mListener;
@@ -140,14 +138,21 @@ public class LauncherProvider extends ContentProvider {
return db.insert(table, nullColumnHack, values);
}
private void reloadLauncherIfExternal() {
if (Binder.getCallingPid() != Process.myPid()) {
LauncherAppState app = LauncherAppState.getInstanceNoCreate();
if (app != null) {
app.reloadWorkspace();
}
}
}
@Override
public Uri insert(Uri uri, ContentValues initialValues) {
SqlArguments args = new SqlArguments(uri);
// In very limited cases, we support system|signature permission apps to add to the db
String externalAdd = uri.getQueryParameter(URI_PARAM_IS_EXTERNAL_ADD);
final boolean isExternalAll = externalAdd != null && "true".equals(externalAdd);
if (isExternalAll) {
// In very limited cases, we support system|signature permission apps to modify the db.
if (Binder.getCallingPid() != Process.myPid()) {
if (!mOpenHelper.initializeExternalAdd(initialValues)) {
return null;
}
@@ -161,13 +166,7 @@ public class LauncherProvider extends ContentProvider {
uri = ContentUris.withAppendedId(uri, rowId);
notifyListeners();
if (isExternalAll) {
LauncherAppState app = LauncherAppState.getInstanceNoCreate();
if (app != null) {
app.reloadWorkspace();
}
}
reloadLauncherIfExternal();
return uri;
}
@@ -192,6 +191,7 @@ public class LauncherProvider extends ContentProvider {
}
notifyListeners();
reloadLauncherIfExternal();
return values.length;
}
@@ -203,6 +203,7 @@ public class LauncherProvider extends ContentProvider {
try {
ContentProviderResult[] result = super.applyBatch(operations);
db.setTransactionSuccessful();
reloadLauncherIfExternal();
return result;
} finally {
db.endTransaction();
@@ -217,6 +218,7 @@ public class LauncherProvider extends ContentProvider {
int count = db.delete(args.table, args.where, args.args);
if (count > 0) notifyListeners();
reloadLauncherIfExternal();
return count;
}
@@ -229,6 +231,7 @@ public class LauncherProvider extends ContentProvider {
int count = db.update(args.table, values, args.where, args.args);
if (count > 0) notifyListeners();
reloadLauncherIfExternal();
return count;
}