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

Commit 7bc538df authored by Atneya Nair's avatar Atneya Nair
Browse files

[audio] Keep audioserver package state on removal

Listening for package removal is incorrect when dealing with multiuser,
since what the permission provider is actually interested in is app-id
changes.

Since there are some issues with alternate intents (b/358365471), and
app-ids are not re-used during a single boot, prefer to simply leave the
uid-package association following package removal.

Test: manual app install/uninstall within profile
Bug: 338089555
Bug: 400951313
Flag: com.android.media.audio.audioserver_permissions
Change-Id: I3a35d66c319119da889aedbf23a5b044975b7ec8
parent 48012db1
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import static android.Manifest.permission.QUERY_AUDIO_STATE;
import static android.Manifest.permission.WRITE_SETTINGS;
import static android.app.BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT;
import static android.content.Intent.ACTION_PACKAGE_ADDED;
import static android.content.Intent.ACTION_PACKAGE_REMOVED;
import static android.content.Intent.EXTRA_ARCHIVAL;
import static android.content.Intent.EXTRA_REPLACING;
import static android.media.AudioDeviceInfo.TYPE_BLUETOOTH_A2DP;
@@ -12927,11 +12926,12 @@ public class AudioService extends IAudioService.Stub
                );
        audioPolicy.registerOnStartTask(() -> {
            provider.onServiceStart(audioPolicy.getPermissionController());
            sLifecycleLogger.enqueue(new EventLogger.StringEvent(
                    "Controller start task complete").printLog(ALOGI, TAG));
        });
        IntentFilter packageUpdateFilter = new IntentFilter();
        packageUpdateFilter.addAction(ACTION_PACKAGE_ADDED);
        packageUpdateFilter.addAction(ACTION_PACKAGE_REMOVED);
        packageUpdateFilter.addDataScheme("package");
        context.registerReceiverForAllUsers(new BroadcastReceiver() {
@@ -12945,9 +12945,6 @@ public class AudioService extends IAudioService.Stub
                if (ACTION_PACKAGE_ADDED.equals(action)) {
                    audioserverExecutor.execute(() ->
                            provider.onModifyPackageState(uid, pkgName, false /* isRemoved */));
                } else if (ACTION_PACKAGE_REMOVED.equals(action)) {
                    audioserverExecutor.execute(() ->
                            provider.onModifyPackageState(uid, pkgName, true /* isRemoved */));
                }
            }
        }, packageUpdateFilter, null, null); // main thread is fine, since dispatch on executor