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

Commit d3e6416c authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

No special case for location permission

The location permissions are not special anymore. In a further change a
new special behavior for the location permission will be added at a
different place.

Test: atest SplitPermissionTest
Change-Id: I770f23804bc1e97b7c1ffa99cecdaf28c8fdf902
parent dddadd76
Loading
Loading
Loading
Loading
+19 −42
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.server.pm.permission;

import static android.Manifest.permission.ACCESS_BACKGROUND_LOCATION;
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
import static android.app.AppOpsManager.MODE_ALLOWED;
@@ -1364,8 +1363,6 @@ public class PermissionManagerService {
            @NonNull PermissionsState origPs,
            @NonNull PermissionsState ps, @NonNull PackageParser.Package pkg,
            @NonNull int[] updatedUserIds) {
        AppOpsManager appOpsManager = mContext.getSystemService(AppOpsManager.class);

        String pkgName = pkg.packageName;
        ArraySet<String> newImplicitPermissions = new ArraySet<>();

@@ -1428,24 +1425,6 @@ public class PermissionManagerService {
                                FLAG_PERMISSION_REVOKE_WHEN_REQUESTED);
                        updatedUserIds = ArrayUtils.appendInt(updatedUserIds, userId);

                        // SPECIAL BEHAVIOR for background location. Foreground only by default.
                        if (newPerm.equals(ACCESS_BACKGROUND_LOCATION)) {
                            int numSourcePerms = sourcePerms.size();
                            for (int sourcePermNum = 0; sourcePermNum < numSourcePerms;
                                    sourcePermNum++) {
                                String sourcePerm = sourcePerms.valueAt(sourcePermNum);

                                if (ps.hasRuntimePermission(sourcePerm, userId)
                                        && ps.getRuntimePermissionState(sourcePerm, userId)
                                        .isGranted()
                                        && appOpsManager.unsafeCheckOpNoThrow(
                                                permissionToOp(sourcePerm), getUid(userId,
                                                getAppId(pkg.applicationInfo.uid)), pkgName)
                                        == MODE_ALLOWED) {
                                    setAppOpMode(sourcePerm, pkg, userId, MODE_FOREGROUND);
                                }
                            }
                        } else {
                        boolean inheritsFromInstallPerm = false;
                        for (int sourcePermNum = 0; sourcePermNum < sourcePerms.size();
                                sourcePermNum++) {
@@ -1460,8 +1439,7 @@ public class PermissionManagerService {
                            // Both permissions are new so nothing to inherit.
                            if (DEBUG_PERMISSIONS) {
                                Slog.i(TAG, newPerm + " does not inherit from " + sourcePerms
                                            + " for " + pkgName
                                            + " as split permission is also new");
                                        + " for " + pkgName + " as split permission is also new");
                            }

                            break;
@@ -1474,7 +1452,6 @@ public class PermissionManagerService {
                }
            }
        }
        }

        return updatedUserIds;
    }