Loading packages/SystemUI/res/values/config.xml +3 −3 Original line number Diff line number Diff line Loading @@ -77,9 +77,9 @@ internet,bt,flashlight,dnd,alarm,airplane,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,custom(com.android.permissioncontroller/.permission.service.SafetyCenterQsTileService) </string> <!-- The component name of the Safety Quick Settings Tile --> <string name="safety_quick_settings_tile" translatable="false"> custom(com.android.permissioncontroller/.permission.service.SafetyCenterQsTileService) <!-- The class path of the Safety Quick Settings Tile --> <string name="safety_quick_settings_tile_class" translatable="false"> com.android.permissioncontroller.permission.service.v33.SafetyCenterQsTileService </string> <!-- The minimum number of tiles to display in QuickSettings --> Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/AutoTileManager.java +10 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.statusbar.phone; import static com.android.systemui.qs.dagger.QSFlagsModule.RBC_AVAILABLE; import android.annotation.Nullable; import android.content.ComponentName; import android.content.Context; import android.content.res.Resources; import android.hardware.display.ColorDisplayManager; Loading Loading @@ -118,13 +119,18 @@ public class AutoTileManager implements UserAwareController { mDeviceControlsController = deviceControlsController; mWalletController = walletController; mSafetyController = safetyController; String safetySpecRes; String safetySpecClass; try { safetySpecRes = context.getResources().getString(R.string.safety_quick_settings_tile); safetySpecClass = context.getResources().getString(R.string.safety_quick_settings_tile_class); if (safetySpecClass.length() == 0) { safetySpecClass = null; } } catch (Resources.NotFoundException | NullPointerException e) { safetySpecRes = null; safetySpecClass = null; } mSafetySpec = safetySpecRes; mSafetySpec = safetySpecClass != null ? CustomTile.toSpec(new ComponentName(mContext .getPackageManager().getPermissionControllerPackageName(), safetySpecClass)) : null; } /** Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/AutoTileManagerTest.java +15 −3 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import static org.mockito.Mockito.when; import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; import android.hardware.display.ColorDisplayManager; import android.hardware.display.NightDisplayListener; import android.os.Handler; Loading Loading @@ -70,7 +71,9 @@ import org.junit.runner.RunWith; import org.mockito.Answers; import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.mockito.Spy; import java.util.Collections; import java.util.List; Loading @@ -87,7 +90,10 @@ public class AutoTileManagerTest extends SysuiTestCase { private static final String TEST_SETTING_COMPONENT = "setting_component"; private static final String TEST_COMPONENT = "test_pkg/test_cls"; private static final String TEST_CUSTOM_SPEC = "custom(" + TEST_COMPONENT + ")"; private static final String TEST_CUSTOM_SAFETY_SPEC = "custom(safety_pkg/safety_cls)"; private static final String TEST_CUSTOM_SAFETY_CLASS = "safety_cls"; private static final String TEST_CUSTOM_SAFETY_PKG = "safety_pkg"; private static final String TEST_CUSTOM_SAFETY_SPEC = CustomTile.toSpec(new ComponentName( TEST_CUSTOM_SAFETY_PKG, TEST_CUSTOM_SAFETY_CLASS)); private static final String SEPARATOR = AutoTileManager.SETTING_SEPARATOR; private static final int USER = 0; Loading @@ -106,6 +112,7 @@ public class AutoTileManagerTest extends SysuiTestCase { @Mock(answer = Answers.RETURNS_SELF) private AutoAddTracker.Builder mAutoAddTrackerBuilder; @Mock private Context mUserContext; @Spy private PackageManager mPackageManager; private final boolean mIsReduceBrightColorsAvailable = true; private AutoTileManager mAutoTileManager; Loading @@ -126,13 +133,18 @@ public class AutoTileManagerTest extends SysuiTestCase { mContext.getOrCreateTestableResources().addOverride( com.android.internal.R.bool.config_nightDisplayAvailable, true); mContext.getOrCreateTestableResources().addOverride( R.string.safety_quick_settings_tile, TEST_CUSTOM_SAFETY_SPEC); R.string.safety_quick_settings_tile_class, TEST_CUSTOM_SAFETY_CLASS); when(mAutoAddTrackerBuilder.build()).thenReturn(mAutoAddTracker); when(mQsTileHost.getUserContext()).thenReturn(mUserContext); when(mUserContext.getUser()).thenReturn(UserHandle.of(USER)); mPackageManager = Mockito.spy(mContext.getPackageManager()); when(mPackageManager.getPermissionControllerPackageName()) .thenReturn(TEST_CUSTOM_SAFETY_PKG); Context context = Mockito.spy(mContext); when(context.getPackageManager()).thenReturn(mPackageManager); mAutoTileManager = createAutoTileManager(mContext); mAutoTileManager = createAutoTileManager(context); mAutoTileManager.init(); } Loading Loading
packages/SystemUI/res/values/config.xml +3 −3 Original line number Diff line number Diff line Loading @@ -77,9 +77,9 @@ internet,bt,flashlight,dnd,alarm,airplane,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,custom(com.android.permissioncontroller/.permission.service.SafetyCenterQsTileService) </string> <!-- The component name of the Safety Quick Settings Tile --> <string name="safety_quick_settings_tile" translatable="false"> custom(com.android.permissioncontroller/.permission.service.SafetyCenterQsTileService) <!-- The class path of the Safety Quick Settings Tile --> <string name="safety_quick_settings_tile_class" translatable="false"> com.android.permissioncontroller.permission.service.v33.SafetyCenterQsTileService </string> <!-- The minimum number of tiles to display in QuickSettings --> Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/AutoTileManager.java +10 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.statusbar.phone; import static com.android.systemui.qs.dagger.QSFlagsModule.RBC_AVAILABLE; import android.annotation.Nullable; import android.content.ComponentName; import android.content.Context; import android.content.res.Resources; import android.hardware.display.ColorDisplayManager; Loading Loading @@ -118,13 +119,18 @@ public class AutoTileManager implements UserAwareController { mDeviceControlsController = deviceControlsController; mWalletController = walletController; mSafetyController = safetyController; String safetySpecRes; String safetySpecClass; try { safetySpecRes = context.getResources().getString(R.string.safety_quick_settings_tile); safetySpecClass = context.getResources().getString(R.string.safety_quick_settings_tile_class); if (safetySpecClass.length() == 0) { safetySpecClass = null; } } catch (Resources.NotFoundException | NullPointerException e) { safetySpecRes = null; safetySpecClass = null; } mSafetySpec = safetySpecRes; mSafetySpec = safetySpecClass != null ? CustomTile.toSpec(new ComponentName(mContext .getPackageManager().getPermissionControllerPackageName(), safetySpecClass)) : null; } /** Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/AutoTileManagerTest.java +15 −3 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import static org.mockito.Mockito.when; import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; import android.hardware.display.ColorDisplayManager; import android.hardware.display.NightDisplayListener; import android.os.Handler; Loading Loading @@ -70,7 +71,9 @@ import org.junit.runner.RunWith; import org.mockito.Answers; import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.mockito.Spy; import java.util.Collections; import java.util.List; Loading @@ -87,7 +90,10 @@ public class AutoTileManagerTest extends SysuiTestCase { private static final String TEST_SETTING_COMPONENT = "setting_component"; private static final String TEST_COMPONENT = "test_pkg/test_cls"; private static final String TEST_CUSTOM_SPEC = "custom(" + TEST_COMPONENT + ")"; private static final String TEST_CUSTOM_SAFETY_SPEC = "custom(safety_pkg/safety_cls)"; private static final String TEST_CUSTOM_SAFETY_CLASS = "safety_cls"; private static final String TEST_CUSTOM_SAFETY_PKG = "safety_pkg"; private static final String TEST_CUSTOM_SAFETY_SPEC = CustomTile.toSpec(new ComponentName( TEST_CUSTOM_SAFETY_PKG, TEST_CUSTOM_SAFETY_CLASS)); private static final String SEPARATOR = AutoTileManager.SETTING_SEPARATOR; private static final int USER = 0; Loading @@ -106,6 +112,7 @@ public class AutoTileManagerTest extends SysuiTestCase { @Mock(answer = Answers.RETURNS_SELF) private AutoAddTracker.Builder mAutoAddTrackerBuilder; @Mock private Context mUserContext; @Spy private PackageManager mPackageManager; private final boolean mIsReduceBrightColorsAvailable = true; private AutoTileManager mAutoTileManager; Loading @@ -126,13 +133,18 @@ public class AutoTileManagerTest extends SysuiTestCase { mContext.getOrCreateTestableResources().addOverride( com.android.internal.R.bool.config_nightDisplayAvailable, true); mContext.getOrCreateTestableResources().addOverride( R.string.safety_quick_settings_tile, TEST_CUSTOM_SAFETY_SPEC); R.string.safety_quick_settings_tile_class, TEST_CUSTOM_SAFETY_CLASS); when(mAutoAddTrackerBuilder.build()).thenReturn(mAutoAddTracker); when(mQsTileHost.getUserContext()).thenReturn(mUserContext); when(mUserContext.getUser()).thenReturn(UserHandle.of(USER)); mPackageManager = Mockito.spy(mContext.getPackageManager()); when(mPackageManager.getPermissionControllerPackageName()) .thenReturn(TEST_CUSTOM_SAFETY_PKG); Context context = Mockito.spy(mContext); when(context.getPackageManager()).thenReturn(mPackageManager); mAutoTileManager = createAutoTileManager(mContext); mAutoTileManager = createAutoTileManager(context); mAutoTileManager.init(); } Loading