Support generic profile types

TV uses custom profiles on S instead of managed profiles.

Bug: 170249807
Test: m
Test: Create and start custom profile
Change-Id: I704fff09ec7bc66d90251080843009c2ada873e2
This commit is contained in:
Robert Horvath
2021-05-18 14:26:21 +02:00
parent bd5c79d216
commit 997a221ca8

View File

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