Snap for 8877244 from 5d68dd58aa to tm-qpr1-release

Change-Id: If90c475d849b3ccf03f0efcd81f8cda0f0f1d268
This commit is contained in:
Android Build Coastguard Worker
2022-07-27 23:30:16 +00:00
9 changed files with 149 additions and 45 deletions

View File

@@ -4397,22 +4397,6 @@
column="9"/>
</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;string name=&quot;sync_plug&quot; msgid=&quot;7956982719077985381&quot;>&quot;&quot;&lt;font fgcolor=&quot;#ffffffff&quot;>&quot;Welcome to Google sync!&quot;&lt;/font>&quot; \nA Google approach to syncing data to allow access to your contacts, appointments, and more from wherever you are.&quot;&lt;/string>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rXC/strings.xml"
line="3152"
column="170"/>
</issue>
<issue
id="HardCodedColor"
severity="Error"
@@ -4425,7 +4409,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rAU/strings.xml"
line="3157"
line="3173"
column="64"/>
</issue>
@@ -4441,7 +4425,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rCA/strings.xml"
line="3157"
line="3173"
column="64"/>
</issue>
@@ -4457,7 +4441,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rGB/strings.xml"
line="3157"
line="3173"
column="64"/>
</issue>
@@ -4473,10 +4457,26 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rIN/strings.xml"
line="3157"
line="3173"
column="64"/>
</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;string name=&quot;sync_plug&quot; msgid=&quot;7956982719077985381&quot;>&quot;&quot;&lt;font fgcolor=&quot;#ffffffff&quot;>&quot;Welcome to Google sync!&quot;&lt;/font>&quot; \nA Google approach to syncing data to allow access to your contacts, appointments, and more from wherever you are.&quot;&lt;/string>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rXC/strings.xml"
line="3173"
column="170"/>
</issue>
<issue
id="HardCodedColor"
severity="Error"
@@ -4489,7 +4489,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/strings.xml"
line="7160"
line="7204"
column="36"/>
</issue>
@@ -4749,6 +4749,38 @@
column="40"/>
</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;wifi_signal_color&quot;>@color/setup_wizard_wifi_color_dark&lt;/item>"
errorLine2=" ^">
<location
file="res/values/themes_suw.xml"
line="145"
column="40"/>
</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;wifi_signal_color&quot;>@color/setup_wizard_wifi_color_light&lt;/item>"
errorLine2=" ^">
<location
file="res/values/themes_suw.xml"
line="164"
column="40"/>
</issue>
<issue
id="HardCodedColor"
severity="Error"
@@ -4761,7 +4793,7 @@
errorLine2=" ^">
<location
file="res/values/themes_suw.xml"
line="196"
line="233"
column="43"/>
</issue>
@@ -4777,7 +4809,7 @@
errorLine2=" ^">
<location
file="res/values/themes_suw.xml"
line="197"
line="234"
column="42"/>
</issue>
@@ -4793,7 +4825,7 @@
errorLine2=" ^">
<location
file="res/values/themes_suw.xml"
line="198"
line="235"
column="45"/>
</issue>

23
res/values/bools.xml Normal file
View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 2022, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<resources>
<!-- Referenced outside of Settings to confirm bug fixed - bug involved multiple
pending intents with difference only in intent extras, which doesn't work. -->
<bool name="config_isSafetyCenterLockScreenPendingIntentFixed">true</bool>
</resources>

View File

@@ -49,6 +49,10 @@
<string name="config_wallpaper_picker_class" translatable="false">com.android.settings.Settings$WallpaperSettingsActivity</string>
<!-- Fully-qualified class name for the styles & wallpaper picker activity. -->
<string name="config_styles_and_wallpaper_picker_class" translatable="false"></string>
<!-- Action name for the wallpaper picker activity. -->
<string name="config_wallpaper_picker_action" translatable="false"></string>
<!-- Action name for the styles & wallpaper picker activity. -->
<string name="config_styles_and_wallpaper_picker_action" translatable="false"></string>
<!-- Intent extra for wallpaper picker activity. -->
<string name="config_wallpaper_picker_launch_extra" translatable="false">com.android.wallpaper.LAUNCH_SOURCE</string>

View File

@@ -38,10 +38,6 @@ public class NotificationChannelWarningsPreferenceController extends
final static int SETTING_VALUE_ON = 1;
@VisibleForTesting
final static int SETTING_VALUE_OFF = 0;
@VisibleForTesting
final static int DEBUGGING_ENABLED = 1;
@VisibleForTesting
final static int DEBUGGING_DISABLED = 0;
public NotificationChannelWarningsPreferenceController(Context context) {
super(context);
@@ -64,9 +60,8 @@ public class NotificationChannelWarningsPreferenceController extends
@Override
public void updateState(Preference preference) {
final int defaultWarningEnabled = isDebuggable() ? DEBUGGING_ENABLED : DEBUGGING_DISABLED;
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.SHOW_NOTIFICATION_CHANNEL_WARNINGS, defaultWarningEnabled);
Settings.Global.SHOW_NOTIFICATION_CHANNEL_WARNINGS, 0);
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}

View File

@@ -41,6 +41,8 @@ public class WallpaperPreferenceController extends BasePreferenceController {
private final String mWallpaperPackage;
private final String mWallpaperClass;
private final String mStylesAndWallpaperClass;
private final String mWallpaperActionName;
private final String mStylesAndWallpaperActionName;
private final String mWallpaperLaunchExtra;
public WallpaperPreferenceController(Context context, String key) {
@@ -49,6 +51,9 @@ public class WallpaperPreferenceController extends BasePreferenceController {
mWallpaperClass = mContext.getString(R.string.config_wallpaper_picker_class);
mStylesAndWallpaperClass =
mContext.getString(R.string.config_styles_and_wallpaper_picker_class);
mWallpaperActionName = mContext.getString(R.string.config_wallpaper_picker_action);
mStylesAndWallpaperActionName =
mContext.getString(R.string.config_styles_and_wallpaper_picker_action);
mWallpaperLaunchExtra = mContext.getString(R.string.config_wallpaper_picker_launch_extra);
}
@@ -72,6 +77,10 @@ public class WallpaperPreferenceController extends BasePreferenceController {
return areStylesAvailable() ? mStylesAndWallpaperClass : mWallpaperClass;
}
public String getComponentActionName() {
return areStylesAvailable() ? mStylesAndWallpaperActionName : mWallpaperActionName;
}
public String getKeywords() {
StringBuilder sb = new StringBuilder(mContext.getString(R.string.keywords_wallpaper));
if (areStylesAvailable()) {

View File

@@ -84,7 +84,7 @@ public class WallpaperSuggestionActivity extends StyleSuggestionActivityBase imp
ComponentName component = controller.getComponentName();
data.intentTargetPackage = component.getPackageName();
data.intentTargetClass = component.getClassName();
data.intentAction = Intent.ACTION_MAIN;
data.intentAction = controller.getComponentActionName();
data.key = SUPPORT_SEARCH_INDEX_KEY;
data.keywords = controller.getKeywords();
result.add(data);

View File

@@ -18,11 +18,15 @@ package com.android.settings.wifi;
import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.UserManager;
import android.text.TextUtils;
import android.util.EventLog;
import android.util.Log;
import android.view.WindowManager;
import androidx.annotation.VisibleForTesting;
@@ -39,6 +43,7 @@ import com.android.settingslib.wifi.WifiPermissionChecker;
* This activity requests users permission to allow scanning even when Wi-Fi is turned off
*/
public class WifiScanModeActivity extends FragmentActivity {
private static final String TAG = "WifiScanModeActivity";
private DialogFragment mDialog;
@VisibleForTesting
String mApp;
@@ -78,7 +83,15 @@ public class WifiScanModeActivity extends FragmentActivity {
mApp = Utils.getApplicationLabel(getApplicationContext(), packageName).toString();
}
private void createDialog() {
@VisibleForTesting
void createDialog() {
if (isGuestUser(getApplicationContext())) {
Log.e(TAG, "Guest user is not allowed to configure Wi-Fi Scan Mode!");
EventLog.writeEvent(0x534e4554, "235601169", -1 /* UID */, "User is a guest");
finish();
return;
}
if (mDialog == null) {
mDialog = AlertDialogFragment.newInstance(mApp);
mDialog.show(getSupportFragmentManager(), "dialog");
@@ -169,4 +182,11 @@ public class WifiScanModeActivity extends FragmentActivity {
((WifiScanModeActivity) getActivity()).doNegativeClick();
}
}
private static boolean isGuestUser(Context context) {
if (context == null) return false;
final UserManager userManager = context.getSystemService(UserManager.class);
if (userManager == null) return false;
return userManager.isGuestUser();
}
}

View File

@@ -102,7 +102,7 @@ public class NotificationChannelWarningsPreferenceControllerTest {
}
@Test
public void updateState_settingUndefinedDebuggingEnabled_preferenceShouldBeChecked() {
public void updateState_settingUndefinedDebuggingEnabled_preferenceShouldNotBeChecked() {
mController = spy(mController);
doReturn(true).when(mController).isDebuggable();
Settings.Global.putString(mContext.getContentResolver(),
@@ -110,18 +110,6 @@ public class NotificationChannelWarningsPreferenceControllerTest {
mController.updateState(mPreference);
verify(mPreference).setChecked(true);
}
@Test
public void updateState_settingUndefinedDebuggingDisabled_preferenceShouldNotBeChecked() {
mController = spy(mController);
doReturn(false).when(mController).isDebuggable();
Settings.Global.putString(mContext.getContentResolver(),
Settings.Global.SHOW_NOTIFICATION_CHANNEL_WARNINGS, "NotAnInteger");
mController.updateState(mPreference);
verify(mPreference).setChecked(false);
}

View File

@@ -18,11 +18,17 @@ package com.android.settings.wifi;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.os.UserManager;
import android.text.TextUtils;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.testutils.shadow.ShadowUtils;
import com.android.settingslib.wifi.WifiPermissionChecker;
@@ -32,6 +38,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.Robolectric;
@@ -47,6 +54,10 @@ public class WifiScanModeActivityTest {
@Rule
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
@Spy
Context mContext = ApplicationProvider.getApplicationContext();
@Mock
UserManager mUserManager;
@Mock
WifiPermissionChecker mWifiPermissionChecker;
@@ -54,7 +65,11 @@ public class WifiScanModeActivityTest {
@Before
public void setUp() {
when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
when(mUserManager.isGuestUser()).thenReturn(false);
mActivity = spy(Robolectric.setupActivity(WifiScanModeActivity.class));
when(mActivity.getApplicationContext()).thenReturn(mContext);
mActivity.mWifiPermissionChecker = mWifiPermissionChecker;
}
@@ -87,4 +102,22 @@ public class WifiScanModeActivityTest {
assertThat(mActivity.mApp).isEqualTo(APP_LABEL);
}
@Test
public void createDialog_isNotGuestUser_shouldNotFinishDialog() {
when(mUserManager.isGuestUser()).thenReturn(false);
mActivity.createDialog();
verify(mActivity, never()).finish();
}
@Test
public void createDialog_isGuestUser_shouldFinishDialog() {
when(mUserManager.isGuestUser()).thenReturn(true);
mActivity.createDialog();
verify(mActivity).finish();
}
}