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

Commit a9262a0b authored by shafik's avatar shafik
Browse files

Always kill app when M_E_S is denied

StorageManagerService gets notified that MANAGE_EXTERNAL_STORAGE was
denied from AppOpsService#setUidMode, which means that we can't get the
package name. However, SMS only kills the app if it has the package
name.
This is unnecessary since we use ActivityManager#killUid.

This change removes the conditions that package name should be provided
in order for SMS to kill the app.

Test: manual - check bug
Fix: 160253075
Change-Id: I0a411cf5224714c09744ffd3ade14267024efb67
parent 16868fbe
Loading
Loading
Loading
Loading
+3 −8
Original line number Original line Diff line number Diff line
@@ -4736,7 +4736,7 @@ class StorageManagerService extends IStorageManager.Stub
            return true;
            return true;
        }
        }


        private void killAppForOpChange(int code, int uid, String packageName) {
        private void killAppForOpChange(int code, int uid) {
            final IActivityManager am = ActivityManager.getService();
            final IActivityManager am = ActivityManager.getService();
            try {
            try {
                am.killUid(UserHandle.getAppId(uid), UserHandle.USER_ALL,
                am.killUid(UserHandle.getAppId(uid), UserHandle.USER_ALL,
@@ -4753,7 +4753,7 @@ class StorageManagerService extends IStorageManager.Stub
                    switch(code) {
                    switch(code) {
                        case OP_REQUEST_INSTALL_PACKAGES:
                        case OP_REQUEST_INSTALL_PACKAGES:
                            // Always kill regardless of op change, to remount apps /storage
                            // Always kill regardless of op change, to remount apps /storage
                            killAppForOpChange(code, uid, packageName);
                            killAppForOpChange(code, uid);
                            return;
                            return;
                        case OP_MANAGE_EXTERNAL_STORAGE:
                        case OP_MANAGE_EXTERNAL_STORAGE:
                            if (mode != MODE_ALLOWED) {
                            if (mode != MODE_ALLOWED) {
@@ -4762,12 +4762,7 @@ class StorageManagerService extends IStorageManager.Stub
                                // results in a bad UX, especially since the gid only gives access
                                // results in a bad UX, especially since the gid only gives access
                                // to unreliable volumes, USB OTGs that are rarely mounted. The app
                                // to unreliable volumes, USB OTGs that are rarely mounted. The app
                                // will get the external_storage gid on next organic restart.
                                // will get the external_storage gid on next organic restart.
                                if (packageName != null) {
                                killAppForOpChange(code, uid);
                                    killAppForOpChange(code, uid, packageName);
                                } else {
                                    // TODO(b/158283222) this can happen, figure out if we need
                                    // to kill in this case as well.
                                }
                            }
                            }
                            return;
                            return;
                        case OP_LEGACY_STORAGE:
                        case OP_LEGACY_STORAGE: