Snap for 8055626 from 7eeb727614 to tm-release

Change-Id: I2db81e6a5f484711172ec95b7035991a7038c044
This commit is contained in:
Android Build Coastguard Worker
2022-01-08 04:09:25 +00:00
10 changed files with 161 additions and 9 deletions

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 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.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<com.android.settingslib.widget.AdaptiveIconShapeDrawable
android:width="@dimen/accessibility_icon_size"
android:height="@dimen/accessibility_icon_size"
android:color="@color/accessibility_feature_background"/>
</item>
<item android:gravity="center">
<vector
android:width="@dimen/accessibility_icon_foreground_size"
android:height="@dimen/accessibility_icon_foreground_size"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M6.4,18h2.1l1.1,-3.05h4.8L15.5,18h2.1L13.05,6h-2.1zM10.2,13.2l1.75,-4.95h0.1l1.75,4.95zM4,22q-0.825,0 -1.413,-0.587Q2,20.825 2,20L2,4q0,-0.825 0.587,-1.413Q3.175,2 4,2h16q0.825,0 1.413,0.587Q22,3.175 22,4v16q0,0.825 -0.587,1.413Q20.825,22 20,22zM4,20h16L20,4L4,4v16zM4,4v16L4,4z"/>
</vector>
</item>
</layer-list>

View File

@@ -21,13 +21,17 @@
android:clipToPadding="true"
android:clipChildren="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/captioning_preview_height"
android:contentDescription="@null"
android:scaleType="centerCrop"
android:clipToOutline="true"
android:background="@drawable/protection_background"
android:src="@drawable/caption_background"/>
<FrameLayout

View File

@@ -5326,6 +5326,8 @@
<string name="accessibility_screen_magnification_state_navbar_gesture">Magnify with shortcut &amp; triple-tap</string>
<!-- Title for the footer text to explain what accessibility service does. [CHAR LIMIT=35] -->
<string name="accessibility_introduction_title">About <xliff:g id="service" example="Select to Speak">%1$s</xliff:g></string>
<!-- Title for the accessibility preference to adjust the display size, font size, bold text, and high contrast text features. [CHAR LIMIT=NONE] -->
<string name="accessibility_text_reading_options_title">Text and reading options</string>
<!-- Title for the footer text to explain what option accessibility service does. [CHAR LIMIT=35] -->
<string name="accessibility_screen_option">Options</string>
<!-- Summary for the accessibility preference to enable screen magnification. [CHAR LIMIT=25] -->

View File

@@ -36,6 +36,14 @@
android:persistent="false"
android:title="@string/display_category_title">
<!-- After completely finishing the Text and reading options feature, it will be visible. -->
<Preference
android:icon="@drawable/ic_adaptive_font_download"
android:key="text_reading_options"
android:persistent="false"
android:title="@strings/accessibility_text_reading_options_title"
settings:isPreferenceVisible="false"/>
<Preference
android:fragment="com.android.settings.accessibility.TextAndDisplayFragment"
android:key="text_and_display_preference_screen"

View File

@@ -566,7 +566,9 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
}
if (mSelectedWifiEntry.canDisconnect()) {
menu.add(Menu.NONE, MENU_ID_SHARE, 0 /* order */, R.string.share);
if (mSelectedWifiEntry.canShare()) {
menu.add(Menu.NONE, MENU_ID_SHARE, 0 /* order */, R.string.share);
}
menu.add(Menu.NONE, MENU_ID_DISCONNECT, 1 /* order */,
R.string.wifi_disconnect_button_text);
}

View File

@@ -18,6 +18,7 @@ package com.android.settings.users;
import android.app.Activity;
import android.app.settings.SettingsEnums;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -37,6 +38,7 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.EventLog;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
@@ -641,7 +643,15 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
} else if (restrictionsIntent != null) {
preference.setRestrictions(restrictions);
if (invokeIfCustom && AppRestrictionsFragment.this.isResumed()) {
assertSafeToStartCustomActivity(restrictionsIntent);
try {
assertSafeToStartCustomActivity(restrictionsIntent);
} catch (ActivityNotFoundException | SecurityException e) {
// return without startActivity
Log.e(TAG, "Cannot start restrictionsIntent " + e);
EventLog.writeEvent(0x534e4554, "200688991", -1 /* UID */, "");
return;
}
int requestCode = generateCustomActivityRequestCode(
RestrictionsResultReceiver.this.preference);
AppRestrictionsFragment.this.startActivityForResult(
@@ -655,14 +665,14 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
if (intent.getPackage() != null && intent.getPackage().equals(packageName)) {
return;
}
// Activity can be started if intent resolves to multiple activities
List<ResolveInfo> resolveInfos = AppRestrictionsFragment.this.mPackageManager
.queryIntentActivities(intent, 0 /* no flags */);
if (resolveInfos.size() != 1) {
return;
ResolveInfo resolveInfo = mPackageManager.resolveActivity(
intent, PackageManager.MATCH_DEFAULT_ONLY);
if (resolveInfo == null) {
throw new ActivityNotFoundException("No result for resolving " + intent);
}
// Prevent potential privilege escalation
ActivityInfo activityInfo = resolveInfos.get(0).activityInfo;
ActivityInfo activityInfo = resolveInfo.activityInfo;
if (!packageName.equals(activityInfo.packageName)) {
throw new SecurityException("Application " + packageName
+ " is not allowed to start activity " + intent);

View File

@@ -1251,7 +1251,10 @@ public class UserSettings extends SettingsPreferenceFragment
}
return true;
} else if (pref == mAddSupervisedUser) {
mMetricsFeatureProvider.action(getActivity(), SettingsEnums.ACTION_USER_SUPERVISED_ADD);
Trace.beginSection("UserSettings.addSupervisedUser");
onAddSupervisedUserClicked();
Trace.endSection();
return true;
} else if (pref == mAddGuest) {
mAddGuest.setEnabled(false); // prevent multiple tap issue

View File

@@ -328,6 +328,55 @@ public class NetworkProviderSettingsTest {
anyInt());
}
@Test
public void onCreateContextMenu_canShare_shouldHaveShareMenuForConnectedWifiEntry() {
final FragmentActivity activity = mock(FragmentActivity.class);
when(activity.getApplicationContext()).thenReturn(mContext);
when(mNetworkProviderSettings.getActivity()).thenReturn(activity);
final WifiEntry wifiEntry = mock(WifiEntry.class);
when(wifiEntry.canDisconnect()).thenReturn(true);
when(wifiEntry.canShare()).thenReturn(true);
when(wifiEntry.canForget()).thenReturn(true);
when(wifiEntry.isSaved()).thenReturn(true);
when(wifiEntry.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_CONNECTED);
final LongPressWifiEntryPreference connectedWifiEntryPreference =
mNetworkProviderSettings.createLongPressWifiEntryPreference(wifiEntry);
final View view = mock(View.class);
when(view.getTag()).thenReturn(connectedWifiEntryPreference);
final ContextMenu menu = mock(ContextMenu.class);
mNetworkProviderSettings.onCreateContextMenu(menu, view, null /* info */);
verify(menu).add(anyInt(), eq(NetworkProviderSettings.MENU_ID_SHARE), anyInt(), anyInt());
}
@Test
public void onCreateContextMenu_canNotShare_shouldDisappearShareMenuForConnectedWifiEntry() {
final FragmentActivity activity = mock(FragmentActivity.class);
when(activity.getApplicationContext()).thenReturn(mContext);
when(mNetworkProviderSettings.getActivity()).thenReturn(activity);
final WifiEntry wifiEntry = mock(WifiEntry.class);
when(wifiEntry.canDisconnect()).thenReturn(true);
when(wifiEntry.canShare()).thenReturn(false);
when(wifiEntry.canForget()).thenReturn(true);
when(wifiEntry.isSaved()).thenReturn(true);
when(wifiEntry.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_CONNECTED);
final LongPressWifiEntryPreference connectedWifiEntryPreference =
mNetworkProviderSettings.createLongPressWifiEntryPreference(wifiEntry);
final View view = mock(View.class);
when(view.getTag()).thenReturn(connectedWifiEntryPreference);
final ContextMenu menu = mock(ContextMenu.class);
mNetworkProviderSettings.onCreateContextMenu(menu, view, null /* info */);
verify(menu, never())
.add(anyInt(), eq(NetworkProviderSettings.MENU_ID_SHARE), anyInt(), anyInt());
}
@Test
public void onWifiEntriesChanged_shouldChangeNextButtonState() {
mNetworkProviderSettings.onWifiEntriesChanged();

View File

@@ -27,6 +27,7 @@ import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.notNull;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -40,6 +41,8 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
@@ -122,6 +125,8 @@ public class UserSettingsTest {
@Mock
private UserManager mUserManager;
@Mock
private PackageManager mPackageManager;
@Mock
private MetricsFeatureProvider mMetricsFeatureProvider;
private FragmentActivity mActivity;
@@ -149,11 +154,13 @@ public class UserSettingsTest {
ReflectionHelpers.setField(mFragment, "mMetricsFeatureProvider", mMetricsFeatureProvider);
doReturn(mUserManager).when(mActivity).getSystemService(UserManager.class);
doReturn(mPackageManager).when(mActivity).getPackageManager();
doReturn(mActivity).when(mFragment).getActivity();
doReturn(mContext).when(mFragment).getContext();
doReturn(mMockPreferenceManager).when(mFragment).getPreferenceManager();
doReturn(mUserManager).when(mContext).getSystemService(UserManager.class);
doReturn(mPackageManager).when(mContext).getPackageManager();
mProvisionedBackupValue = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.DEVICE_PROVISIONED, 0);
@@ -653,6 +660,29 @@ public class UserSettingsTest {
verify(mMetricsFeatureProvider).action(any(), eq(SettingsEnums.ACTION_USER_GUEST_ADD));
}
@Test
public void onPreferenceClick_addSupervisedUserClicked_startIntentWithAction() {
final String intentPackage = "testPackage";
final String intentAction = UserManager.ACTION_CREATE_SUPERVISED_USER;
final int metricsAction = SettingsEnums.ACTION_USER_SUPERVISED_ADD;
try {
setConfigSupervisedUserCreationPackage(intentPackage);
doReturn(new ResolveInfo()).when(mPackageManager).resolveActivity(any(), anyInt());
doNothing().when(mFragment).startActivity(any());
mFragment.onPreferenceClick(mAddSupervisedUserPreference);
final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
verify(mFragment).startActivity(captor.capture());
assertThat(captor.getValue().getPackage()).isEqualTo(intentPackage);
assertThat(captor.getValue().getAction()).isEqualTo(intentAction);
verify(mMetricsFeatureProvider).action(any(), eq(metricsAction));
} finally {
SettingsShadowResources.reset();
}
}
@Test
public void getRealUsersCount_onlyAdmin_shouldCount() {
givenUsers(getAdminUser(true));

View File

@@ -15,6 +15,7 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.android.settings.tests.unit">
<uses-permission android:name="android.permission.BLUETOOTH" />
@@ -69,6 +70,13 @@
android:resource="@xml/authenticator" />
</service>
<!-- Disable startup provider due to resource loading issue. -->
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
tools:node="remove"
tools:replace="android:authorities"/>
</application>
<instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"