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

Commit 8c341488 authored by Robert Horvath's avatar Robert Horvath Committed by Automerger Merge Worker
Browse files

Merge "Support generic profile types" into sc-dev am: 23141294

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14621138

Change-Id: I8fc10bb55dfbb7323372ff64daccc42bcfdb531c
parents 0adba8aa 23141294
Loading
Loading
Loading
Loading
+14 −14
Original line number Diff line number Diff line
@@ -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);