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

Commit 85ad1b94 authored by Eric Rahm's avatar Eric Rahm
Browse files

Add INTERACT_ACROSS_USERS to soundpicker



Adds the `INTERACT_ACROSS_USERS` permission to
`android.com.soundpicker`.

`SoundPicker` provides a `RingtonePickerActivity` which allows the user
to choose a ringtone from all of the available ringtones. To support
this is uses a `RingtoneManager` to retrieve a list of all available
rintgtones including those of the parent profile. RingtoneManager
optionally supports managing ringtones from the parent profile, this is
controlled by a boolean flag that `RingtonePickerActivity` sets to true
when creating its `RingtoneManager`.

When enumerating ringtones one calls `RingtoneManager::getCursor` which
builds a set of ringtones that includes “internal ringtones,” “media
ringtones,” and optionally parent ringtones if the `RingtoneManager` was
configured to included them when created. In this case it is configured
to do so and will call `RingtoneManager::getParentRingtones`.  This
function retrieves the parent profile by calling
`UserManager::getProfileParent` and gates following logic on whether or
not a `UserInfo` is returned.

`UserManager::getProfileParent` requires the caller to have either the
`MANAGER_USERS` or `INTERACT_ACROSS_USERS` permission. Without the
permission a security exception is thrown similar to the following:

```
02-01 16:22:29.979 16869 16869 E AndroidRuntime: Caused by:
java.lang.SecurityException: You need MANAGE_USERS permission to: get
the profile parent
02-01 16:22:29.979 16869 16869 E AndroidRuntime: 	at
android.os.Parcel.createExceptionOrNull(Parcel.java:2373)
02-01 16:22:29.979 16869 16869 E AndroidRuntime: 	at
android.os.Parcel.createException(Parcel.java:2357)
02-01 16:22:29.979 16869 16869 E AndroidRuntime: 	at
android.os.Parcel.readException(Parcel.java:2340)
02-01 16:22:29.979 16869 16869 E AndroidRuntime: 	at
android.os.Parcel.readException(Parcel.java:2282)
02-01 16:22:29.979 16869 16869 E AndroidRuntime: 	at
android.os.IUserManager$Stub$Proxy.getProfileParent(IUserManager.java:2083)
02-01 16:22:29.979 16869 16869 E AndroidRuntime: 	at
android.os.UserManager.getProfileParent(UserManager.java:3564)
02-01 16:22:29.979 16869 16869 E AndroidRuntime: 	at
android.media.RingtoneManager.getParentProfileRingtones(RingtoneManager.java:455)
02-01 16:22:29.979 16869 16869 E AndroidRuntime: 	at
android.media.RingtoneManager.getCursor(RingtoneManager.java:443)
02-01 16:22:29.979 16869 16869 E AndroidRuntime: 	at
com.android.soundpicker.RingtonePickerActivity.initRingtoneManager(RingtonePickerActivity.java:470)
02-01 16:22:29.979 16869 16869 E AndroidRuntime: 	at
com.android.soundpicker.RingtonePickerActivity.onCreate(RingtonePickerActivity.java:188)
02-01 16:22:29.979 16869 16869 E AndroidRuntime: 	at
android.app.Activity.performCreate(Activity.java:7994)
02-01 16:22:29.979 16869 16869 E AndroidRuntime: 	at
android.app.Activity.performCreate(Activity.java:7978)
02-01 16:22:29.979 16869 16869 E AndroidRuntime: 	at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
02-01 16:22:29.979 16869 16869 E AndroidRuntime: 	at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
```

To ameliorate this we add the `INTERACT_ACROSS_USERS` permission to
`SoundPicker` to indicate its intent to query the parent profile which
matches the intent of `RingtonePickerActivity`.

Bug: 178990696
Bug: 246352264

Test: INTERACT_ACROSS_USERS permssion SecurityException is when go to Settings->Watch Ringtone.

Co-Authored-by: default avatarhaiping <haiping@google.com>
Change-Id: I448a104cf71c5cb1dbda09091c5db8b558fecdeb
(cherry picked from commit 66d2f2afb4cfc531142230cad1af568d1904a7a2)
(cherry picked from commit 82dc1c8e464adf01d14ea0e7b1c9064595ad3293)
parent f86c1914
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment