summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-08-13 19:08:30 (GMT)
committerSunny Goyal <sunnygoyal@google.com>2015-08-13 21:09:43 (GMT)
commitd106418dee16b041f30682540fbd3ca3d841b7af (patch)
treefe9bcfe58af17e2e68c909a4ef4c49e3650f1365
parentf29471c751b173b91989709b9ce9ca811bf20244 (diff)
downloadandroid_packages_apps_Trebuchet-d106418dee16b041f30682540fbd3ca3d841b7af.zip
android_packages_apps_Trebuchet-d106418dee16b041f30682540fbd3ca3d841b7af.tar.gz
android_packages_apps_Trebuchet-d106418dee16b041f30682540fbd3ca3d841b7af.tar.bz2
Reloading launcher whenever there is an external update to contentprovider, irrespective of the uri
Change-Id: If1a06da57171be30adb74f09ac256a8b03ab8549
-rw-r--r--src/com/android/launcher3/LauncherProvider.java29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index 6cbb267..0599714 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -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;
}