[Media ML] Replace user-related hidden APIs
MediaSessionService keeps track of users being added and removed from the system. It also considers "managed" users (work profiles) to be part of the "manager" user, since they will always be running simultaneously and therefore should share a common logic for session management (e.g. dispatching a media key event to the most recently active session). Thus, MediaSessionService needs to know what users are "managed" and who their "manager" user is. This CL replaces the existing hidden API usage with existing public/system APIs. Bug: 175216227 Test: Manually test adding managed/non-managed users Change-Id: I0ce807e5bdcccee7ae99e29c0a0a52b6dadc8b57
This commit is contained in:
@@ -40,7 +40,6 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ParceledListSlice;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.media.AudioManager;
|
||||
import android.media.AudioPlaybackConfiguration;
|
||||
import android.media.IRemoteVolumeControllerCallback;
|
||||
@@ -393,15 +392,17 @@ public class MediaSessionService extends SystemService implements Monitor {
|
||||
synchronized (mLock) {
|
||||
UserManager manager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
|
||||
mFullUserIds.clear();
|
||||
List<UserInfo> allUsers = manager.getUsers();
|
||||
List<UserHandle> allUsers = manager.getUserHandles(/*excludeDying=*/false);
|
||||
if (allUsers != null) {
|
||||
for (UserInfo userInfo : allUsers) {
|
||||
if (userInfo.isManagedProfile()) {
|
||||
mFullUserIds.put(userInfo.id, userInfo.profileGroupId);
|
||||
for (UserHandle user : allUsers) {
|
||||
UserHandle parent = manager.getProfileParent(user);
|
||||
if (parent != null) {
|
||||
mFullUserIds.put(user.getIdentifier(), parent.getIdentifier());
|
||||
} else {
|
||||
mFullUserIds.put(userInfo.id, userInfo.id);
|
||||
if (mUserRecords.get(userInfo.id) == null) {
|
||||
mUserRecords.put(userInfo.id, new FullUserRecord(userInfo.id));
|
||||
mFullUserIds.put(user.getIdentifier(), user.getIdentifier());
|
||||
if (mUserRecords.get(user.getIdentifier()) == null) {
|
||||
mUserRecords.put(user.getIdentifier(),
|
||||
new FullUserRecord(user.getIdentifier()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user