Fix Maps PIP issue: DeviceConfig permission denial

Problem:
Exception thrown when maps was in PIP mode.

Solution:
Use Binder to give permission to Settings reading device config
SEPARATE_VOLUME_NOTIFICATION.

Bug: 261809910
Test: Manual. (from bug report) Launch Maps and navigate to a place.
Minimize maps app. Open Settings. Should open normally and not crash.

Change-Id: I38735ebc7d555ead54e3aa77b50e4a7077fe452b
This commit is contained in:
Behnam Heydarshahi
2022-12-22 22:11:33 +00:00
parent 988e1712a3
commit acea45544e
3 changed files with 16 additions and 10 deletions

View File

@@ -23,6 +23,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.AudioManager;
import android.os.Binder;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -85,8 +86,9 @@ public class RingVolumePreferenceController extends
super.onResume();
mReceiver.register(true);
readSeparateNotificationVolumeConfig();
DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI,
ActivityThread.currentApplication().getMainExecutor(), this::onDeviceConfigChange);
Binder.withCleanCallingIdentity(()
-> DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI,
ActivityThread.currentApplication().getMainExecutor(), this::onDeviceConfigChange));
updateEffectsSuppressor();
selectPreferenceIconState();
@@ -100,7 +102,8 @@ public class RingVolumePreferenceController extends
public void onPause() {
super.onPause();
mReceiver.register(false);
DeviceConfig.removeOnPropertiesChangedListener(this::onDeviceConfigChange);
Binder.withCleanCallingIdentity(() ->
DeviceConfig.removeOnPropertiesChangedListener(this::onDeviceConfigChange));
}
@Override
@@ -124,7 +127,6 @@ public class RingVolumePreferenceController extends
@Override
protected boolean hintsMatch(int hints) {
boolean notificationSeparated = isSeparateNotificationConfigEnabled();
return (hints & NotificationListenerService.HINT_HOST_DISABLE_CALL_EFFECTS) != 0
|| (hints & NotificationListenerService.HINT_HOST_DISABLE_EFFECTS) != 0
|| ((hints & NotificationListenerService.HINT_HOST_DISABLE_NOTIFICATION_EFFECTS)