Loading core/java/android/service/quicksettings/TileService.java +1 −1 Original line number Diff line number Diff line Loading @@ -506,7 +506,7 @@ public class TileService extends Service { * the calling package or if the calling user cannot act on behalf of the user from the * {@code context}.</li> * <li> {@link IllegalArgumentException} if the user of the {@code context} is not the * current user.</li> * current user. Only thrown for apps targeting {@link Build.VERSION_CODES#TIRAMISU}</li> * </ul> */ public static final void requestListeningState(Context context, ComponentName component) { Loading packages/SystemUI/src/com/android/systemui/qs/external/CustomTile.java +1 −1 Original line number Diff line number Diff line Loading @@ -328,7 +328,7 @@ public class CustomTile extends QSTileImpl<State> implements TileChangeListener if (listening) { updateDefaultTileAndIcon(); refreshState(); if (!mServiceManager.isActiveTile()) { if (!mServiceManager.isActiveTile() || !isTileReady()) { mServiceManager.setBindRequested(true); mService.onStartListening(); } Loading packages/SystemUI/tests/src/com/android/systemui/qs/external/CustomTileTest.kt +41 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ import org.mockito.ArgumentMatchers.anyInt import org.mockito.ArgumentMatchers.anyString import org.mockito.Mock import org.mockito.Mockito.`when` import org.mockito.Mockito.clearInvocations import org.mockito.Mockito.mock import org.mockito.Mockito.never import org.mockito.Mockito.reset Loading Loading @@ -351,4 +352,44 @@ class CustomTileTest : SysuiTestCase() { .startPendingIntentDismissingKeyguard( eq(pi), nullable(), nullable<ActivityLaunchAnimator.Controller>()) } @Test fun testActiveTileListensOnceAfterCreated() { `when`(tileServiceManager.isActiveTile).thenReturn(true) val tile = CustomTile.create(customTileBuilder, TILE_SPEC, mContext) tile.initialize() tile.postStale() testableLooper.processAllMessages() verify(tileServiceManager).setBindRequested(true) verify(tileService).onStartListening() } @Test fun testActiveTileDoesntListenAfterFirstTime() { `when`(tileServiceManager.isActiveTile).thenReturn(true) val tile = CustomTile.create(customTileBuilder, TILE_SPEC, mContext) tile.initialize() // Make sure we have an icon in the tile because we don't have a default icon // This should not be overridden by the retrieved tile that has null icon. tile.qsTile.icon = mock(Icon::class.java) `when`(tile.qsTile.icon.loadDrawable(any(Context::class.java))) .thenReturn(mock(Drawable::class.java)) tile.postStale() testableLooper.processAllMessages() // postStale will set it to not listening after it's done verify(tileService).onStopListening() clearInvocations(tileServiceManager, tileService) tile.setListening(Any(), true) testableLooper.processAllMessages() verify(tileServiceManager, never()).setBindRequested(true) verify(tileService, never()).onStartListening() } } No newline at end of file services/core/java/com/android/server/statusbar/StatusBarManagerService.java +13 −1 Original line number Diff line number Diff line Loading @@ -152,6 +152,13 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.S_V2) static final long REQUEST_LISTENING_MUST_MATCH_PACKAGE = 172251878L; /** * @hide */ @ChangeId @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.TIRAMISU) static final long REQUEST_LISTENING_OTHER_USER_NOOP = 242194868L; private final Context mContext; private final Handler mHandler = new Handler(); Loading Loading @@ -1859,7 +1866,12 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D // Check current user if (userId != currentUser) { throw new IllegalArgumentException("User " + userId + " is not the current user."); if (CompatChanges.isChangeEnabled(REQUEST_LISTENING_OTHER_USER_NOOP, callingUid)) { return; } else { throw new IllegalArgumentException( "User " + userId + " is not the current user."); } } } if (mBar != null) { Loading Loading
core/java/android/service/quicksettings/TileService.java +1 −1 Original line number Diff line number Diff line Loading @@ -506,7 +506,7 @@ public class TileService extends Service { * the calling package or if the calling user cannot act on behalf of the user from the * {@code context}.</li> * <li> {@link IllegalArgumentException} if the user of the {@code context} is not the * current user.</li> * current user. Only thrown for apps targeting {@link Build.VERSION_CODES#TIRAMISU}</li> * </ul> */ public static final void requestListeningState(Context context, ComponentName component) { Loading
packages/SystemUI/src/com/android/systemui/qs/external/CustomTile.java +1 −1 Original line number Diff line number Diff line Loading @@ -328,7 +328,7 @@ public class CustomTile extends QSTileImpl<State> implements TileChangeListener if (listening) { updateDefaultTileAndIcon(); refreshState(); if (!mServiceManager.isActiveTile()) { if (!mServiceManager.isActiveTile() || !isTileReady()) { mServiceManager.setBindRequested(true); mService.onStartListening(); } Loading
packages/SystemUI/tests/src/com/android/systemui/qs/external/CustomTileTest.kt +41 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ import org.mockito.ArgumentMatchers.anyInt import org.mockito.ArgumentMatchers.anyString import org.mockito.Mock import org.mockito.Mockito.`when` import org.mockito.Mockito.clearInvocations import org.mockito.Mockito.mock import org.mockito.Mockito.never import org.mockito.Mockito.reset Loading Loading @@ -351,4 +352,44 @@ class CustomTileTest : SysuiTestCase() { .startPendingIntentDismissingKeyguard( eq(pi), nullable(), nullable<ActivityLaunchAnimator.Controller>()) } @Test fun testActiveTileListensOnceAfterCreated() { `when`(tileServiceManager.isActiveTile).thenReturn(true) val tile = CustomTile.create(customTileBuilder, TILE_SPEC, mContext) tile.initialize() tile.postStale() testableLooper.processAllMessages() verify(tileServiceManager).setBindRequested(true) verify(tileService).onStartListening() } @Test fun testActiveTileDoesntListenAfterFirstTime() { `when`(tileServiceManager.isActiveTile).thenReturn(true) val tile = CustomTile.create(customTileBuilder, TILE_SPEC, mContext) tile.initialize() // Make sure we have an icon in the tile because we don't have a default icon // This should not be overridden by the retrieved tile that has null icon. tile.qsTile.icon = mock(Icon::class.java) `when`(tile.qsTile.icon.loadDrawable(any(Context::class.java))) .thenReturn(mock(Drawable::class.java)) tile.postStale() testableLooper.processAllMessages() // postStale will set it to not listening after it's done verify(tileService).onStopListening() clearInvocations(tileServiceManager, tileService) tile.setListening(Any(), true) testableLooper.processAllMessages() verify(tileServiceManager, never()).setBindRequested(true) verify(tileService, never()).onStartListening() } } No newline at end of file
services/core/java/com/android/server/statusbar/StatusBarManagerService.java +13 −1 Original line number Diff line number Diff line Loading @@ -152,6 +152,13 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.S_V2) static final long REQUEST_LISTENING_MUST_MATCH_PACKAGE = 172251878L; /** * @hide */ @ChangeId @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.TIRAMISU) static final long REQUEST_LISTENING_OTHER_USER_NOOP = 242194868L; private final Context mContext; private final Handler mHandler = new Handler(); Loading Loading @@ -1859,7 +1866,12 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D // Check current user if (userId != currentUser) { throw new IllegalArgumentException("User " + userId + " is not the current user."); if (CompatChanges.isChangeEnabled(REQUEST_LISTENING_OTHER_USER_NOOP, callingUid)) { return; } else { throw new IllegalArgumentException( "User " + userId + " is not the current user."); } } } if (mBar != null) { Loading