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

Commit 47407209 authored by Himanshu Gupta's avatar Himanshu Gupta Committed by Android (Google) Code Review
Browse files

Merge "Clearing obsolete cloneUserId from CloneBackend." into udc-dev

parents 03e8dbca d9f60d9a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -58,6 +58,11 @@ public class AppStateClonedAppsBridge extends AppStateBaseBridge{
            mCloneProfileApps = mContext.getPackageManager()
                    .getInstalledPackagesAsUser(GET_ACTIVITIES,
                            mCloneUserId).stream().map(x -> x.packageName).toList();
        } else if (!mCloneProfileApps.isEmpty()) {
            // In case we remove clone profile (mCloneUserId becomes -1), the bridge state should
            // reflect the same by setting cloneProfileApps as empty, without building the entire
            // page.
            mCloneProfileApps = new ArrayList<>();
        }

        final List<ApplicationsState.AppEntry> allApps = mAppSession.getAllApps();
+9 −0
Original line number Diff line number Diff line
@@ -165,4 +165,13 @@ public class CloneBackend {
    public int getCloneUserId() {
        return mCloneUserId;
    }

    /**
     * Resets {@link #mCloneUserId} to -1.
     * Typically called after the cloneUser is removed, so that the obsolete clonedUserId present
     * with the CloneBackend instance can be cleared.
     */
    public void resetCloneUserId() {
        mCloneUserId = -1;
    }
}
+7 −2
Original line number Diff line number Diff line
@@ -923,10 +923,15 @@ public class ManageApplications extends InstrumentedFragment
            }
            IUserManager um = IUserManager.Stub.asInterface(
                    ServiceManager.getService(Context.USER_SERVICE));
            CloneBackend cloneBackend = CloneBackend.getInstance(getContext());
            try {
                // Warning: This removes all the data, media & images present in cloned user.
                um.removeUser(clonedUserId);
                if (um.removeUser(clonedUserId)) {
                    cloneBackend.resetCloneUserId();
                    mApplications.rebuild();
                } else if (ManageApplications.DEBUG) {
                    Log.e(TAG, "Failed to remove cloned user");
                }
            } catch (RemoteException e) {
                Log.e(TAG, "Failed to remove cloned apps", e);
                Toast.makeText(getContext(),