Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e88491d6 authored by Sunny Goyal's avatar Sunny Goyal Committed by Android Git Automerger
Browse files

am d468ee90: Merge "Reloading launcher whenever there is an external update to...

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

* commit 'd468ee90':
  Reloading launcher whenever there is an external update to contentprovider, irrespective of the uri
parents 4e7a1018 d468ee90
Loading
Loading
Loading
Loading
+16 −13
Original line number Diff line number Diff line
@@ -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;
    }