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

Commit 2905e604 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 0abadb1a
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -322,12 +322,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);