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

Commit ff971bc3 authored by Sudheer Shanka's avatar Sudheer Shanka
Browse files

Update process mount points when appop gets updated.

When an app is started, it's mountmode is dependent on
OP_REQUEST_INSTALL_PACKAGES. If user changes the appop grant of an app,
we need to update the mounts of any processes running in that app.

Bug: 121099965
Test: atest android.appsecurity.cts.ExternalStorageHostTest#testExternalStorageObbGifts
Change-Id: I606c4d9b338800637acb45b263c4673f210b1de8
parent 159c83c5
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -128,6 +128,7 @@ 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.os.AppFuseMount;
import com.android.internal.os.BackgroundThread;
@@ -1666,6 +1667,10 @@ class StorageManagerService extends IStorageManager.Stub
                ServiceManager.getService("package"));
        mIAppOpsService = IAppOpsService.Stub.asInterface(
                ServiceManager.getService(Context.APP_OPS_SERVICE));
        try {
            mIAppOpsService.startWatchingMode(OP_REQUEST_INSTALL_PACKAGES, null, mAppOpsCallback);
        } catch (RemoteException e) {
        }
        mHandler.obtainMessage(H_SYSTEM_READY).sendToTarget();
    }

@@ -3193,6 +3198,15 @@ 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;

            remountUidExternalStorage(uid, getMountMode(uid, packageName));
        }
    };

    private static final Pattern PATTERN_TRANSLATE = Pattern.compile(
            "(?i)^(/storage/[^/]+/(?:[0-9]+/)?)(.*)");