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

Unverified Commit 4469fc32 authored by Jorge Ruesga's avatar Jorge Ruesga Committed by Michael Bestas
Browse files

AppOps: Do not prune apps that are not present



Do not prune apps that are not currently present in the device (like
USB memory ones). While booting, they are not available but must not
be purged from AppOps, because they are still present in the Android
app database.

Issue-Id: CYAN-2811
Change-Id: I6680cbdf0022812b45d966dffee754399e92accb
Signed-off-by: default avatarJorge Ruesga <jorge@ruesga.com>
parent aeba21fe
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -330,12 +330,19 @@ public class AppOpsService extends IAppOpsService.Stub {
                    } catch (RemoteException ignored) {
                    }
                    if (curUid != ops.uidState.uid) {
                        // Do not prune apps that are not currently present in the device
                        // (like SDcard ones). While booting, SDcards are not available but
                        // must not be purged from AppOps, because they are still present
                        // in the Android app database.
                        String pkgName = mContext.getPackageManager().getNameForUid(ops.uidState.uid);
                        if (curUid != -1 || pkgName == null || !pkgName.equals(ops.packageName)) {
                            Slog.i(TAG, "Pruning old package " + ops.packageName
                                    + "/" + ops.uidState + ": new uid=" + curUid);
                            it.remove();
                            changed = true;
                        }
                    }
                }

                if (uidState.isDefault()) {
                    mUidStates.removeAt(i);