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

Commit 98bfab5f authored by Josep del Río's avatar Josep del Río Committed by Android (Google) Code Review
Browse files

Merge "NEW Use Mockito 4.6.1 API" into tm-qpr-dev

parents 3959e27e a962b4b7
Loading
Loading
Loading
Loading
+224 −0
Original line number Diff line number Diff line
@@ -525,6 +525,86 @@
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;sfps_enrollment_fp_captured_color&quot;>#ffffffff&lt;/color>"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values-night/colors.xml"
            line="54"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;sfps_enrollment_fp_error_color&quot;>#ffffffff&lt;/color>"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values-night/colors.xml"
            line="55"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;sfps_enrollment_progress_bar_bg_color&quot;>#ffffffff&lt;/color>"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values-night/colors.xml"
            line="56"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;sfps_enrollment_progress_bar_fill_color&quot;>#ffffffff&lt;/color>"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values-night/colors.xml"
            line="57"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;sfps_enrollment_progress_bar_error_color&quot;>#ffffffff&lt;/color>"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values-night/colors.xml"
            line="58"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
@@ -589,6 +669,86 @@
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;sfps_enrollment_fp_captured_color&quot;>#ffffffff&lt;/color>"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values/colors.xml"
            line="205"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;sfps_enrollment_fp_error_color&quot;>#ffffffff&lt;/color>"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values/colors.xml"
            line="206"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;sfps_enrollment_progress_bar_bg_color&quot;>#ffffffff&lt;/color>"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values/colors.xml"
            line="207"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;sfps_enrollment_progress_bar_fill_color&quot;>#ffffffff&lt;/color>"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values/colors.xml"
            line="208"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="    &lt;color name=&quot;sfps_enrollment_progress_bar_error_color&quot;>#ffffffff&lt;/color>"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/values/colors.xml"
            line="209"
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
@@ -4829,6 +4989,38 @@
            column="45"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="        &lt;item name=&quot;android:colorPrimary&quot;>@color/material_grey_100&lt;/item>"
        errorLine2="                                          ^">
        <location
            file="res/values/themes_suw.xml"
            line="233"
            column="45"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="        &lt;item name=&quot;android:titleTextColor&quot;>@color/material_blue_700&lt;/item>"
        errorLine2="                                            ^">
        <location
            file="res/values/themes_suw.xml"
            line="235"
            column="45"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
@@ -4845,4 +5037,36 @@
            column="5"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="                    android:progressBackgroundTint=&quot;@color/sfps_enrollment_progress_bar_bg_color&quot;"
        errorLine2="                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/layout/sfps_enroll_enrolling.xml"
            line="71"
            column="20"/>
    </issue>

    <issue
        id="HardCodedColor"
        severity="Error"
        message="Avoid using hardcoded color"
        category="Correctness"
        priority="4"
        summary="Using hardcoded color"
        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
        errorLine1="                    android:progressBackgroundTint=&quot;@color/sfps_enrollment_progress_bar_bg_color&quot;"
        errorLine2="                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="res/layout/sfps_enroll_enrolling.xml"
            line="71"
            column="20"/>
    </issue>

</issues>
+14 −14
Original line number Diff line number Diff line
@@ -20,10 +20,10 @@ import static com.android.settings.testutils.ApplicationTestUtils.buildInfo;

import static com.google.common.truth.Truth.assertThat;

import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
@@ -39,7 +39,6 @@ import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;

import java.util.Collections;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -49,6 +48,7 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.shadows.ShadowApplication;

import java.util.Arrays;
import java.util.Collections;

@RunWith(RobolectricTestRunner.class)
public final class AppWithAdminGrantedPermissionsCounterTest {
@@ -129,7 +129,7 @@ public final class AppWithAdminGrantedPermissionsCounterTest {
        verify(mPackageManager).getInstalledApplicationsAsUser(anyInt(), eq(MAIN_USER_ID));
        verify(mPackageManager).getInstalledApplicationsAsUser(anyInt(),
                eq(MANAGED_PROFILE_ID));
        verify(mPackageManager, atLeast(0)).getInstallReason(anyObject(), anyObject());
        verify(mPackageManager, atLeast(0)).getInstallReason(any(), any());
        verifyNoMoreInteractions(mPackageManager);
    }

@@ -166,9 +166,9 @@ public final class AppWithAdminGrantedPermissionsCounterTest {
    }

    private void configureInstallTimePermissions() throws RemoteException {
        when(mPackageManagerService.checkUidPermission(anyObject(), eq(APP_1_UID)))
        when(mPackageManagerService.checkUidPermission(any(), eq(APP_1_UID)))
                .thenReturn(PackageManager.PERMISSION_DENIED);
        when(mPackageManagerService.checkUidPermission(anyObject(), eq(APP_2_UID)))
        when(mPackageManagerService.checkUidPermission(any(), eq(APP_2_UID)))
                .thenReturn(PackageManager.PERMISSION_DENIED);
        when(mPackageManagerService.checkUidPermission(PERMISSION_1, APP_3_UID))
                .thenReturn(PackageManager.PERMISSION_DENIED);
@@ -178,9 +178,9 @@ public final class AppWithAdminGrantedPermissionsCounterTest {
                .thenReturn(PackageManager.PERMISSION_DENIED);
        when(mPackageManagerService.checkUidPermission(PERMISSION_2, APP_4_UID))
                .thenReturn(PackageManager.PERMISSION_GRANTED);
        when(mPackageManagerService.checkUidPermission(anyObject(), eq(APP_5_UID)))
        when(mPackageManagerService.checkUidPermission(any(), eq(APP_5_UID)))
                .thenReturn(PackageManager.PERMISSION_DENIED);
        when(mPackageManagerService.checkUidPermission(anyObject(), eq(APP_6_UID)))
        when(mPackageManagerService.checkUidPermission(any(), eq(APP_6_UID)))
                .thenReturn(PackageManager.PERMISSION_DENIED);
    }

@@ -189,15 +189,15 @@ public final class AppWithAdminGrantedPermissionsCounterTest {
                .thenReturn(DevicePolicyManager.PERMISSION_GRANT_STATE_GRANTED);
        when(mDevicePolicyManager.getPermissionGrantState(null, APP_1, PERMISSION_2))
                .thenReturn(DevicePolicyManager.PERMISSION_GRANT_STATE_DENIED);
        when(mDevicePolicyManager.getPermissionGrantState(eq(null), eq(APP_2), anyObject()))
        when(mDevicePolicyManager.getPermissionGrantState(eq(null), eq(APP_2), any()))
                .thenReturn(DevicePolicyManager.PERMISSION_GRANT_STATE_DENIED);
        when(mDevicePolicyManager.getPermissionGrantState(eq(null), eq(APP_3), anyObject()))
        when(mDevicePolicyManager.getPermissionGrantState(eq(null), eq(APP_3), any()))
                .thenReturn(DevicePolicyManager.PERMISSION_GRANT_STATE_DENIED);
        when(mDevicePolicyManager.getPermissionGrantState(eq(null), eq(APP_4), anyObject()))
        when(mDevicePolicyManager.getPermissionGrantState(eq(null), eq(APP_4), any()))
                .thenReturn(DevicePolicyManager.PERMISSION_GRANT_STATE_DENIED);
        when(mDevicePolicyManager.getPermissionGrantState(eq(null), eq(APP_5), anyObject()))
        when(mDevicePolicyManager.getPermissionGrantState(eq(null), eq(APP_5), any()))
                .thenReturn(DevicePolicyManager.PERMISSION_GRANT_STATE_DENIED);
        when(mDevicePolicyManager.getPermissionGrantState(eq(null), eq(APP_6), anyObject()))
        when(mDevicePolicyManager.getPermissionGrantState(eq(null), eq(APP_6), any()))
                .thenReturn(DevicePolicyManager.PERMISSION_GRANT_STATE_GRANTED);
    }

+13 −13
Original line number Diff line number Diff line
@@ -20,10 +20,10 @@ import static com.android.settings.testutils.ApplicationTestUtils.buildInfo;

import static com.google.common.truth.Truth.assertThat;

import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
@@ -122,19 +122,19 @@ public final class AppWithAdminGrantedPermissionsListerTest {
                .thenReturn(DevicePolicyManager.PERMISSION_GRANT_STATE_GRANTED);
        when(mDevicePolicyManager.getPermissionGrantState(null, APP_1, PERMISSION_2))
                .thenReturn(DevicePolicyManager.PERMISSION_GRANT_STATE_DENIED);
        when(mDevicePolicyManager.getPermissionGrantState(eq(null), eq(APP_2), anyObject()))
        when(mDevicePolicyManager.getPermissionGrantState(eq(null), eq(APP_2), any()))
                .thenReturn(DevicePolicyManager.PERMISSION_GRANT_STATE_DENIED);
        when(mDevicePolicyManager.getPermissionGrantState(eq(null), eq(APP_3), anyObject()))
        when(mDevicePolicyManager.getPermissionGrantState(eq(null), eq(APP_3), any()))
                .thenReturn(DevicePolicyManager.PERMISSION_GRANT_STATE_DENIED);
        when(mDevicePolicyManager.getPermissionGrantState(eq(null), eq(APP_4), anyObject()))
        when(mDevicePolicyManager.getPermissionGrantState(eq(null), eq(APP_4), any()))
                .thenReturn(DevicePolicyManager.PERMISSION_GRANT_STATE_DENIED);
        when(mDevicePolicyManager.getPermissionGrantState(eq(null), eq(APP_5), anyObject()))
        when(mDevicePolicyManager.getPermissionGrantState(eq(null), eq(APP_5), any()))
                .thenReturn(DevicePolicyManager.PERMISSION_GRANT_STATE_DENIED);

        // Grant install-time permissions as appropriate.
        when(mPackageManagerService.checkUidPermission(anyObject(), eq(APP_1_UID)))
        when(mPackageManagerService.checkUidPermission(any(), eq(APP_1_UID)))
                .thenReturn(PackageManager.PERMISSION_DENIED);
        when(mPackageManagerService.checkUidPermission(anyObject(), eq(APP_2_UID)))
        when(mPackageManagerService.checkUidPermission(any(), eq(APP_2_UID)))
                .thenReturn(PackageManager.PERMISSION_DENIED);
        when(mPackageManagerService.checkUidPermission(PERMISSION_1, APP_3_UID))
                .thenReturn(PackageManager.PERMISSION_DENIED);
@@ -144,7 +144,7 @@ public final class AppWithAdminGrantedPermissionsListerTest {
                .thenReturn(PackageManager.PERMISSION_DENIED);
        when(mPackageManagerService.checkUidPermission(PERMISSION_2, APP_4_UID))
                .thenReturn(PackageManager.PERMISSION_GRANTED);
        when(mPackageManagerService.checkUidPermission(anyObject(), eq(APP_5_UID)))
        when(mPackageManagerService.checkUidPermission(any(), eq(APP_5_UID)))
                .thenReturn(PackageManager.PERMISSION_DENIED);

        // app3 and app5 were installed by enterprise policy.
@@ -168,11 +168,11 @@ public final class AppWithAdminGrantedPermissionsListerTest {
                buildInfo(APP_6_UID, APP_6, 0 /* flags */, Build.VERSION_CODES.M)));

        // Grant run-time permissions as appropriate.
        when(mDevicePolicyManager.getPermissionGrantState(eq(null), eq(APP_6), anyObject()))
        when(mDevicePolicyManager.getPermissionGrantState(eq(null), eq(APP_6), any()))
                .thenReturn(DevicePolicyManager.PERMISSION_GRANT_STATE_GRANTED);

        // Grant install-time permissions as appropriate.
        when(mPackageManagerService.checkUidPermission(anyObject(), eq(APP_6_UID)))
        when(mPackageManagerService.checkUidPermission(any(), eq(APP_6_UID)))
                .thenReturn(PackageManager.PERMISSION_DENIED);

        // app6 was not installed by enterprise policy.
@@ -202,7 +202,7 @@ public final class AppWithAdminGrantedPermissionsListerTest {
        verify(mPackageManager).getInstalledApplicationsAsUser(anyInt(), eq(MAIN_USER_ID));
        verify(mPackageManager).getInstalledApplicationsAsUser(anyInt(),
                eq(MANAGED_PROFILE_ID));
        verify(mPackageManager, atLeast(0)).getInstallReason(anyObject(), anyObject());
        verify(mPackageManager, atLeast(0)).getInstallReason(any(), any());
        verifyNoMoreInteractions(mPackageManager);
    }

+5 −5
Original line number Diff line number Diff line
@@ -20,11 +20,11 @@ import static com.android.settings.testutils.ApplicationTestUtils.buildInfo;

import static com.google.common.truth.Truth.assertThat;

import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.argThat;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@@ -170,7 +170,7 @@ public final class InstalledAppListerTest {
        verify(mPackageManager).getInstalledApplicationsAsUser(anyInt(), eq(MAIN_USER_ID));
        verify(mPackageManager).getInstalledApplicationsAsUser(anyInt(), eq(MANAGED_PROFILE_ID));
        verify(mPackageManager, atLeast(0))
            .queryIntentActivitiesAsUser(anyObject(), anyInt(), anyInt());
            .queryIntentActivitiesAsUser(any(), anyInt(), anyInt());
    }

    public static boolean checkAppFound(List<UserAppInfo> mInstalledAppList, String appId,
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ import static com.android.settings.core.BasePreferenceController.AVAILABLE;

import static com.google.common.truth.Truth.assertThat;

import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
Loading