Merge "Support generic profile types" into sc-dev

This commit is contained in:
Robert Horvath
2021-05-19 07:47:08 +00:00
committed by Android (Google) Code Review

View File

@@ -143,9 +143,9 @@ public final class TvInputManagerService extends SystemService {
// ID of the current user. // ID of the current user.
@GuardedBy("mLock") @GuardedBy("mLock")
private int mCurrentUserId = UserHandle.USER_SYSTEM; private int mCurrentUserId = UserHandle.USER_SYSTEM;
// IDs of the running managed profiles. Their parent user ID should be mCurrentUserId. // IDs of the running profiles. Their parent user ID should be mCurrentUserId.
@GuardedBy("mLock") @GuardedBy("mLock")
private final Set<Integer> mRunningManagedProfile = new HashSet<>(); private final Set<Integer> mRunningProfiles = new HashSet<>();
// A map from user id to UserState. // A map from user id to UserState.
@GuardedBy("mLock") @GuardedBy("mLock")
@@ -440,13 +440,13 @@ public final class TvInputManagerService extends SystemService {
private void startUser(int userId) { private void startUser(int userId) {
synchronized (mLock) { synchronized (mLock) {
if (userId == mCurrentUserId || mRunningManagedProfile.contains(userId)) { if (userId == mCurrentUserId || mRunningProfiles.contains(userId)) {
// user already started // user already started
return; return;
} }
UserInfo userInfo = mUserManager.getUserInfo(userId); UserInfo userInfo = mUserManager.getUserInfo(userId);
UserInfo parentInfo = mUserManager.getProfileParent(userId); UserInfo parentInfo = mUserManager.getProfileParent(userId);
if (userInfo.isManagedProfile() if (userInfo.isProfile()
&& parentInfo != null && parentInfo != null
&& parentInfo.id == mCurrentUserId) { && parentInfo.id == mCurrentUserId) {
// only the children of the current user can be started in background // only the children of the current user can be started in background
@@ -463,13 +463,13 @@ public final class TvInputManagerService extends SystemService {
releaseSessionOfUserLocked(userId); releaseSessionOfUserLocked(userId);
unbindServiceOfUserLocked(userId); unbindServiceOfUserLocked(userId);
mRunningManagedProfile.remove(userId); mRunningProfiles.remove(userId);
} }
private void startProfileLocked(int userId) { private void startProfileLocked(int userId) {
buildTvInputListLocked(userId, null); buildTvInputListLocked(userId, null);
buildTvContentRatingSystemListLocked(userId); buildTvContentRatingSystemListLocked(userId);
mRunningManagedProfile.add(userId); mRunningProfiles.add(userId);
} }
private void switchUser(int userId) { private void switchUser(int userId) {
@@ -478,16 +478,16 @@ public final class TvInputManagerService extends SystemService {
return; return;
} }
UserInfo userInfo = mUserManager.getUserInfo(userId); UserInfo userInfo = mUserManager.getUserInfo(userId);
if (userInfo.isManagedProfile()) { if (userInfo.isProfile()) {
Slog.w(TAG, "cannot switch to a managed profile!"); Slog.w(TAG, "cannot switch to a profile!");
return; return;
} }
for (int runningId : mRunningManagedProfile) { for (int runningId : mRunningProfiles) {
releaseSessionOfUserLocked(runningId); releaseSessionOfUserLocked(runningId);
unbindServiceOfUserLocked(runningId); unbindServiceOfUserLocked(runningId);
} }
mRunningManagedProfile.clear(); mRunningProfiles.clear();
releaseSessionOfUserLocked(mCurrentUserId); releaseSessionOfUserLocked(mCurrentUserId);
unbindServiceOfUserLocked(mCurrentUserId); unbindServiceOfUserLocked(mCurrentUserId);
@@ -630,7 +630,7 @@ public final class TvInputManagerService extends SystemService {
userState.mCallbacks.kill(); userState.mCallbacks.kill();
userState.mainSessionToken = null; userState.mainSessionToken = null;
mRunningManagedProfile.remove(userId); mRunningProfiles.remove(userId);
mUserStates.remove(userId); mUserStates.remove(userId);
if (userId == mCurrentUserId) { if (userId == mCurrentUserId) {
@@ -729,7 +729,7 @@ public final class TvInputManagerService extends SystemService {
} }
boolean shouldBind; boolean shouldBind;
if (userId == mCurrentUserId || mRunningManagedProfile.contains(userId)) { if (userId == mCurrentUserId || mRunningProfiles.contains(userId)) {
shouldBind = !serviceState.sessionTokens.isEmpty() || serviceState.isHardware; shouldBind = !serviceState.sessionTokens.isEmpty() || serviceState.isHardware;
} else { } else {
// For a non-current user, // For a non-current user,
@@ -1400,9 +1400,9 @@ public final class TvInputManagerService extends SystemService {
String uniqueSessionId = UUID.randomUUID().toString(); String uniqueSessionId = UUID.randomUUID().toString();
try { try {
synchronized (mLock) { synchronized (mLock) {
if (userId != mCurrentUserId && !mRunningManagedProfile.contains(userId) if (userId != mCurrentUserId && !mRunningProfiles.contains(userId)
&& !isRecordingSession) { && !isRecordingSession) {
// Only current user and its running managed profiles can create // Only current user and its running profiles can create
// non-recording sessions. // non-recording sessions.
// Let the client get onConnectionFailed callback for this case. // Let the client get onConnectionFailed callback for this case.
sendSessionTokenToClientLocked(client, inputId, null, null, seq); sendSessionTokenToClientLocked(client, inputId, null, null, seq);