Loading services/core/java/com/android/server/media/MediaSessionRecord.java +18 −7 Original line number Diff line number Diff line Loading @@ -234,12 +234,24 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde }; @GuardedBy("mLock") private @UserEngagementState int mUserEngagementState = USER_DISENGAGED; @IntDef({USER_PERMANENTLY_ENGAGED, USER_TEMPORARILY_ENGAGED, USER_DISENGAGED}) private @UserEngagementState int mUserEngagementState = USER_ENGAGEMENT_UNSET; @IntDef({ USER_ENGAGEMENT_UNSET, USER_PERMANENTLY_ENGAGED, USER_TEMPORARILY_ENGAGED, USER_DISENGAGED }) @Retention(RetentionPolicy.SOURCE) private @interface UserEngagementState {} /** * Indicates that the {@link UserEngagementState} is not yet set. * * @see #updateUserEngagedStateIfNeededLocked(boolean) */ private static final int USER_ENGAGEMENT_UNSET = -1; /** * Indicates that the session is {@linkplain MediaSession#isActive() active} and in one of the * {@linkplain PlaybackState#isActive() active states}. Loading Loading @@ -1054,11 +1066,10 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde } int oldUserEngagedState = mUserEngagementState; int newUserEngagedState; if (!isActive() || mPlaybackState == null) { newUserEngagedState = USER_DISENGAGED; } else if (mPlaybackState.isActive()) { if (isActive() && mPlaybackState != null && mPlaybackState.isActive()) { newUserEngagedState = USER_PERMANENTLY_ENGAGED; } else if (oldUserEngagedState == USER_PERMANENTLY_ENGAGED || oldUserEngagedState == USER_ENGAGEMENT_UNSET || (oldUserEngagedState == USER_TEMPORARILY_ENGAGED && !isTimeoutExpired)) { newUserEngagedState = USER_TEMPORARILY_ENGAGED; } else { Loading @@ -1079,7 +1090,7 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde boolean wasUserEngaged = oldUserEngagedState != USER_DISENGAGED; boolean isNowUserEngaged = newUserEngagedState != USER_DISENGAGED; if (wasUserEngaged != isNowUserEngaged) { if (oldUserEngagedState == USER_ENGAGEMENT_UNSET || wasUserEngaged != isNowUserEngaged) { mHandler.post( () -> mService.onSessionUserEngagementStateChange( Loading Loading
services/core/java/com/android/server/media/MediaSessionRecord.java +18 −7 Original line number Diff line number Diff line Loading @@ -234,12 +234,24 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde }; @GuardedBy("mLock") private @UserEngagementState int mUserEngagementState = USER_DISENGAGED; @IntDef({USER_PERMANENTLY_ENGAGED, USER_TEMPORARILY_ENGAGED, USER_DISENGAGED}) private @UserEngagementState int mUserEngagementState = USER_ENGAGEMENT_UNSET; @IntDef({ USER_ENGAGEMENT_UNSET, USER_PERMANENTLY_ENGAGED, USER_TEMPORARILY_ENGAGED, USER_DISENGAGED }) @Retention(RetentionPolicy.SOURCE) private @interface UserEngagementState {} /** * Indicates that the {@link UserEngagementState} is not yet set. * * @see #updateUserEngagedStateIfNeededLocked(boolean) */ private static final int USER_ENGAGEMENT_UNSET = -1; /** * Indicates that the session is {@linkplain MediaSession#isActive() active} and in one of the * {@linkplain PlaybackState#isActive() active states}. Loading Loading @@ -1054,11 +1066,10 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde } int oldUserEngagedState = mUserEngagementState; int newUserEngagedState; if (!isActive() || mPlaybackState == null) { newUserEngagedState = USER_DISENGAGED; } else if (mPlaybackState.isActive()) { if (isActive() && mPlaybackState != null && mPlaybackState.isActive()) { newUserEngagedState = USER_PERMANENTLY_ENGAGED; } else if (oldUserEngagedState == USER_PERMANENTLY_ENGAGED || oldUserEngagedState == USER_ENGAGEMENT_UNSET || (oldUserEngagedState == USER_TEMPORARILY_ENGAGED && !isTimeoutExpired)) { newUserEngagedState = USER_TEMPORARILY_ENGAGED; } else { Loading @@ -1079,7 +1090,7 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde boolean wasUserEngaged = oldUserEngagedState != USER_DISENGAGED; boolean isNowUserEngaged = newUserEngagedState != USER_DISENGAGED; if (wasUserEngaged != isNowUserEngaged) { if (oldUserEngagedState == USER_ENGAGEMENT_UNSET || wasUserEngaged != isNowUserEngaged) { mHandler.post( () -> mService.onSessionUserEngagementStateChange( Loading