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

Commit 55d18c6f authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge "Merge "Update Safety Tile config value" into tm-dev am: 32cc80fe am:...

Merge "Merge "Update Safety Tile config value" into tm-dev am: 32cc80fe am: f12e01d1" into tm-d1-dev-plus-aosp
parents 36319f51 288472c4
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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 -->
+10 −4
Original line number Diff line number Diff line
@@ -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;
    }

    /**
+15 −3
Original line number Diff line number Diff line
@@ -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();
    }