Merge "Update Safety Tile config value" into tm-dev
This commit is contained in:
@@ -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 -->
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user