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

Commit d4e36b69 authored by Martijn Coenen's avatar Martijn Coenen
Browse files

Remove calls to remountUid().

These are no-ops with FUSE enabled, so avoid doing needless work.

Bug: 141394269
Test: N/A
Change-Id: Id9f56ff3235cc2746195b4dd6f8f13e0f7cd0f67
parent e7741e18
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -69,13 +69,6 @@ public abstract class StorageManagerInternal {
     */
    public abstract void addExternalStoragePolicy(ExternalStorageMountPolicy policy);

    /**
     * Notify the mount service that the mount policy for a UID changed.
     * @param uid The UID for which policy changed.
     * @param packageName The package in the UID for making the call.
     */
    public abstract void onExternalStoragePolicyChanged(int uid, String packageName);

    /**
     * Gets the mount mode to use for a given UID as determined by consultin all
     * policies.
+0 −48
Original line number Diff line number Diff line
@@ -19,11 +19,9 @@ package com.android.server;
import static android.Manifest.permission.ACCESS_MTP;
import static android.Manifest.permission.INSTALL_PACKAGES;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
import static android.app.ActivityManager.PROCESS_STATE_NONEXISTENT;
import static android.app.AppOpsManager.MODE_ALLOWED;
import static android.app.AppOpsManager.OP_LEGACY_STORAGE;
import static android.app.AppOpsManager.OP_MANAGE_EXTERNAL_STORAGE;
import static android.app.AppOpsManager.OP_READ_EXTERNAL_STORAGE;
import static android.app.AppOpsManager.OP_REQUEST_INSTALL_PACKAGES;
import static android.app.AppOpsManager.OP_WRITE_EXTERNAL_STORAGE;
import static android.content.pm.PackageManager.MATCH_ANY_USER;
@@ -135,7 +133,6 @@ import android.util.TimeUtils;
import android.util.Xml;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.app.IAppOpsCallback;
import com.android.internal.app.IAppOpsService;
import com.android.internal.content.PackageMonitor;
import com.android.internal.os.AppFuseMount;
@@ -151,7 +148,6 @@ import com.android.internal.util.HexDump;
import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.Preconditions;
import com.android.internal.widget.LockPatternUtils;
import com.android.server.SystemService.TargetUser;
import com.android.server.pm.Installer;
import com.android.server.storage.AppFuseBridge;
import com.android.server.storage.StorageSessionController;
@@ -2521,19 +2517,6 @@ class StorageManagerService extends IStorageManager.Stub
        abortIdleMaint(null);
    }

    private void remountUidExternalStorage(int uid, int mode) {
        if (uid == Process.SYSTEM_UID) {
            // No need to remount uid for system because it has all access anyways
            return;
        }

        try {
            mVold.remountUid(uid, mode);
        } catch (Exception e) {
            Slog.wtf(TAG, e);
        }
    }

    @Override
    public void setDebugFlags(int flags, int mask) {
        enforcePermission(android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS);
@@ -3845,21 +3828,6 @@ class StorageManagerService extends IStorageManager.Stub
        }
    }

    private IAppOpsCallback.Stub mAppOpsCallback = new IAppOpsCallback.Stub() {
        @Override
        public void opChanged(int op, int uid, String packageName) throws RemoteException {
            if (!ENABLE_ISOLATED_STORAGE) return;

            int mountMode = getMountMode(uid, packageName);
            boolean isUidActive = LocalServices.getService(ActivityManagerInternal.class)
                    .getUidProcessState(uid) != PROCESS_STATE_NONEXISTENT;

            if (isUidActive) {
                remountUidExternalStorage(uid, mountMode);
            }
        }
    };

    private void addObbStateLocked(ObbState obbState) throws RemoteException {
        final IBinder binder = obbState.getBinder();
        List<ObbState> obbStates = mObbMounts.get(binder);
@@ -4545,12 +4513,6 @@ class StorageManagerService extends IStorageManager.Stub
            return true;
        }

        @Override
        public void onExternalStoragePolicyChanged(int uid, String packageName) {
            final int mountMode = getExternalStorageMountMode(uid, packageName);
            remountUidExternalStorage(uid, mountMode);
        }

        @Override
        public int getExternalStorageMountMode(int uid, String packageName) {
            if (ENABLE_ISOLATED_STORAGE) {
@@ -4696,16 +4658,6 @@ class StorageManagerService extends IStorageManager.Stub
                        updateLegacyStorageApps(packageName, uid, mode == MODE_ALLOWED);
                        return;
                }

                if (mode == MODE_ALLOWED && (code == OP_READ_EXTERNAL_STORAGE
                                || code == OP_WRITE_EXTERNAL_STORAGE
                                || code == OP_REQUEST_INSTALL_PACKAGES)) {
                    final UserManagerInternal userManagerInternal =
                            LocalServices.getService(UserManagerInternal.class);
                    if (userManagerInternal.isUserInitialized(UserHandle.getUserId(uid))) {
                        onExternalStoragePolicyChanged(uid, packageName);
                    }
                }
            } finally {
                Binder.restoreCallingIdentity(token);
            }
+0 −19
Original line number Diff line number Diff line
@@ -104,7 +104,6 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.os.UserManagerInternal;
import android.os.storage.StorageManager;
import android.os.storage.StorageManagerInternal;
import android.permission.IOnPermissionsChangeListener;
import android.permission.IPermissionManager;
import android.permission.PermissionControllerManager;
@@ -1554,24 +1553,6 @@ public class PermissionManagerService extends IPermissionManager.Stub {
        if (bp.isRuntime()) {
            notifyRuntimePermissionStateChanged(packageName, userId);
        }

        // Only need to do this if user is initialized. Otherwise it's a new user
        // and there are no processes running as the user yet and there's no need
        // to make an expensive call to remount processes for the changed permissions.
        if (READ_EXTERNAL_STORAGE.equals(permName)
                || WRITE_EXTERNAL_STORAGE.equals(permName)) {
            final long token = Binder.clearCallingIdentity();
            try {
                if (mUserManagerInt.isUserInitialized(userId)) {
                    StorageManagerInternal storageManagerInternal = LocalServices.getService(
                            StorageManagerInternal.class);
                    storageManagerInternal.onExternalStoragePolicyChanged(uid, packageName);
                }
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        }

    }

    @Override