Snap for 5386257 from f669a3bd70 to qt-release
Change-Id: Iac67aae2ecdfec9dd960da49624cd10cea351b9e
This commit is contained in:
@@ -49,6 +49,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
|
|||||||
settings-contextual-card-protos-lite \
|
settings-contextual-card-protos-lite \
|
||||||
contextualcards \
|
contextualcards \
|
||||||
settings-logtags \
|
settings-logtags \
|
||||||
|
statsdprotolite \
|
||||||
zxing-core-1.7
|
zxing-core-1.7
|
||||||
|
|
||||||
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
|
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -29,7 +29,6 @@
|
|||||||
android:id="@+id/collapse_button"
|
android:id="@+id/collapse_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:src="@drawable/ic_expand_less"
|
android:src="@drawable/ic_expand_less"/>
|
||||||
android:tint="?android:attr/colorAccent"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -45,8 +45,8 @@
|
|||||||
android:paddingTop="@dimen/homepage_condition_header_indicator_padding_top"
|
android:paddingTop="@dimen/homepage_condition_header_indicator_padding_top"
|
||||||
android:paddingStart="@dimen/homepage_condition_header_indicator_padding_start"
|
android:paddingStart="@dimen/homepage_condition_header_indicator_padding_start"
|
||||||
android:paddingEnd="@dimen/homepage_condition_header_indicator_padding_end"
|
android:paddingEnd="@dimen/homepage_condition_header_indicator_padding_end"
|
||||||
android:src="@*android:drawable/ic_expand_more"
|
android:src="@drawable/ic_expand_more_inverse"
|
||||||
android:tint="?android:attr/colorAccent"/>
|
android:tint="?android:attr/colorControlNormal"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:animateLayoutChanges="true"
|
android:animateLayoutChanges="true"
|
||||||
|
android:importantForAccessibility="no"
|
||||||
style="@style/SliceViewStyle"/>
|
style="@style/SliceViewStyle"/>
|
||||||
|
|
||||||
<!--dismissal view-->
|
<!--dismissal view-->
|
||||||
|
|||||||
@@ -127,12 +127,9 @@
|
|||||||
android:text="@string/erase_external_storage_description"/>
|
android:text="@string/erase_external_storage_description"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<include
|
|
||||||
layout="@layout/reset_esim_checkbox"
|
<include layout="@layout/reset_esim_checkbox"/>
|
||||||
android:layout_marginTop="40dp"
|
|
||||||
android:id="@+id/erase_esim_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</com.google.android.setupdesign.GlifLayout>
|
</com.google.android.setupdesign.GlifLayout>
|
||||||
|
|||||||
@@ -15,7 +15,9 @@
|
|||||||
-->
|
-->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/erase_esim_container"
|
||||||
style="@style/SudDescription"
|
style="@style/SudDescription"
|
||||||
|
android:layout_marginTop="40dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
@@ -41,10 +43,10 @@
|
|||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/erase_esim_title"
|
|
||||||
style="@style/TextAppearance.SudGlifItemTitle"
|
style="@style/TextAppearance.SudGlifItemTitle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/reset_esim_title"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
style="@style/TextAppearance.SudGlifItemSummary"
|
style="@style/TextAppearance.SudGlifItemSummary"
|
||||||
|
|||||||
@@ -40,10 +40,7 @@
|
|||||||
android:textDirection="locale"
|
android:textDirection="locale"
|
||||||
android:text="@string/reset_network_desc" />
|
android:text="@string/reset_network_desc" />
|
||||||
|
|
||||||
<include layout="@layout/reset_esim_checkbox"
|
<include layout="@layout/reset_esim_checkbox"/>
|
||||||
android:id="@+id/erase_esim_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
android:id="@+id/main_content_scrollable_container"
|
android:id="@+id/main_content_scrollable_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:importantForAccessibility="no"
|
||||||
app:layout_behavior="com.android.settings.widget.FloatingAppBarScrollingViewBehavior">
|
app:layout_behavior="com.android.settings.widget.FloatingAppBarScrollingViewBehavior">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|||||||
@@ -3581,10 +3581,10 @@
|
|||||||
<string name="reset_network_title">Reset Wi-Fi, mobile & Bluetooth</string>
|
<string name="reset_network_title">Reset Wi-Fi, mobile & Bluetooth</string>
|
||||||
<!-- SD card & phone storage settings screen, message on screen after user selects Reset network settings [CHAR LIMIT=NONE] -->
|
<!-- SD card & phone storage settings screen, message on screen after user selects Reset network settings [CHAR LIMIT=NONE] -->
|
||||||
<string name="reset_network_desc">This will reset all network settings, including:\n\n<li>Wi\u2011Fi</li>\n<li>Mobile data</li>\n<li>Bluetooth</li>"</string>
|
<string name="reset_network_desc">This will reset all network settings, including:\n\n<li>Wi\u2011Fi</li>\n<li>Mobile data</li>\n<li>Bluetooth</li>"</string>
|
||||||
<!-- SD card & phone storage settings screen, title for the checkbox to let user decide whether erase eSIM data together [CHAR LIMIT=NONE] -->
|
<!-- SD card & phone storage settings screen, title for the checkbox to let user decide whether erase eSIM data together [CHAR LIMIT=30] -->
|
||||||
<string name="reset_esim_title">Also reset eSIM</string>
|
<string name="reset_esim_title">Erase eSIMs</string>
|
||||||
<!-- SD card & phone storage settings screen, message for the checkbox to let user decide whether erase eSIM data together [CHAR LIMIT=NONE] -->
|
<!-- SD card & phone storage settings screen, message for the checkbox to let user decide whether erase eSIM data together [CHAR LIMIT=NONE] -->
|
||||||
<string name="reset_esim_desc">Erase all eSIMs on the phone. You\u2019ll have to contact your carrier to redownload your eSIMs. This will not cancel your mobile service plan.</string>
|
<string name="reset_esim_desc">You\u2019ll have to contact your carrier to download replacement eSIMs. This won\u2019t cancel any mobile service plans.</string>
|
||||||
<!-- SD card & phone storage settings screen, button on screen after user selects Reset network settings -->
|
<!-- SD card & phone storage settings screen, button on screen after user selects Reset network settings -->
|
||||||
<string name="reset_network_button_text">Reset settings</string>
|
<string name="reset_network_button_text">Reset settings</string>
|
||||||
<!-- SD card & phone storage settings screen, message on screen after user selects Reset settings button -->
|
<!-- SD card & phone storage settings screen, message on screen after user selects Reset settings button -->
|
||||||
@@ -3633,12 +3633,6 @@
|
|||||||
<string name="erase_external_storage_description" product="nosdcard">Erase all the data on the internal USB storage, such as music or photos</string>
|
<string name="erase_external_storage_description" product="nosdcard">Erase all the data on the internal USB storage, such as music or photos</string>
|
||||||
<!-- SD card & phone storage settings screen, description for check box to erase USB storage [CHAR LIMIT=NONE] -->
|
<!-- SD card & phone storage settings screen, description for check box to erase USB storage [CHAR LIMIT=NONE] -->
|
||||||
<string name="erase_external_storage_description" product="default">Erase all the data on the SD card, such as music or photos</string>
|
<string name="erase_external_storage_description" product="default">Erase all the data on the SD card, such as music or photos</string>
|
||||||
<!-- SD card & phone storage settings screen, label for check box to erase all the carriers information on the embedded SIM card [CHAR LIMIT=30] -->
|
|
||||||
<string name="erase_esim_storage">Erase eSIM</string>
|
|
||||||
<!-- SD card & phone storage settings screen, description for check box to erase eSIMs for default devices [CHAR LIMIT=NONE] -->
|
|
||||||
<string name="erase_esim_storage_description" product="default">Erase all eSIMs on the phone. This will not cancel your mobile service plan.</string>
|
|
||||||
<!-- SD card & phone storage settings screen, description for check box to erase eSIMs for tablets [CHAR LIMIT=NONE] -->
|
|
||||||
<string name="erase_esim_storage_description" product="tablet">Erase all eSIMs on the tablet. This will not cancel your mobile service plan.</string>
|
|
||||||
<!-- SD card & phone storage settings screen, button on screen after user selects Factory data reset -->
|
<!-- SD card & phone storage settings screen, button on screen after user selects Factory data reset -->
|
||||||
<string name="master_clear_button_text" product="tablet">Erase all data</string>
|
<string name="master_clear_button_text" product="tablet">Erase all data</string>
|
||||||
<!-- SD card & phone storage settings screen, button on screen after user selects Factory data reset -->
|
<!-- SD card & phone storage settings screen, button on screen after user selects Factory data reset -->
|
||||||
@@ -9892,8 +9886,6 @@
|
|||||||
|
|
||||||
<!-- Preference and settings suggestion title text for display wake-up gesture [CHAR LIMIT=60]-->
|
<!-- Preference and settings suggestion title text for display wake-up gesture [CHAR LIMIT=60]-->
|
||||||
<string name="ambient_display_wake_screen_title">Wake up display</string>
|
<string name="ambient_display_wake_screen_title">Wake up display</string>
|
||||||
<!-- Summary text for ambient display wake-up gesture [CHAR LIMIT=NONE]-->
|
|
||||||
<string name="ambient_display_wake_screen_summary"></string>
|
|
||||||
|
|
||||||
<!-- Summary text for ambient display (phone) [CHAR LIMIT=NONE]-->
|
<!-- Summary text for ambient display (phone) [CHAR LIMIT=NONE]-->
|
||||||
<string name="ambient_display_pickup_summary" product="default">To check time, notifications, and other info, pick up your phone.</string>
|
<string name="ambient_display_pickup_summary" product="default">To check time, notifications, and other info, pick up your phone.</string>
|
||||||
|
|||||||
@@ -59,12 +59,6 @@
|
|||||||
android:summary="@string/doze_always_on_summary"
|
android:summary="@string/doze_always_on_summary"
|
||||||
settings:controller="com.android.settings.display.AmbientDisplayAlwaysOnPreferenceController" />
|
settings:controller="com.android.settings.display.AmbientDisplayAlwaysOnPreferenceController" />
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="ambient_display_wake_screen"
|
|
||||||
android:title="@string/ambient_display_wake_screen_title"
|
|
||||||
android:fragment="com.android.settings.gestures.WakeScreenGestureSettings"
|
|
||||||
settings:controller="com.android.settings.gestures.WakeScreenGesturePreferenceController" />
|
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="ambient_display_tap"
|
android:key="ambient_display_tap"
|
||||||
android:title="@string/ambient_display_tap_screen_title"
|
android:title="@string/ambient_display_tap_screen_title"
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
android:key="zen_access"
|
android:key="zen_access"
|
||||||
android:title="@string/manage_zen_access_title"
|
android:title="@string/manage_zen_access_title"
|
||||||
android:fragment="com.android.settings.notification.ZenAccessSettings"
|
android:fragment="com.android.settings.notification.ZenAccessSettings"
|
||||||
settings:controller="com.android.settings.applications.specialaccess.ZenAccessController" />
|
settings:controller="com.android.settings.applications.specialaccess.zenaccess.ZenAccessController" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="write_settings_apps"
|
android:key="write_settings_apps"
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
Copyright (C) 2018 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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:key="gesture_wake_screen_screen"
|
|
||||||
android:title="@string/ambient_display_wake_screen_title">
|
|
||||||
|
|
||||||
<com.android.settings.widget.VideoPreference
|
|
||||||
android:key="gesture_wake_screen_video"
|
|
||||||
app:animation="@raw/gesture_ambient_wake_screen"
|
|
||||||
app:preview="@drawable/gesture_ambient_wake_screen" />
|
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="gesture_wake_screen"
|
|
||||||
android:title="@string/ambient_display_wake_screen_title"
|
|
||||||
android:summary="@string/ambient_display_wake_screen_summary"
|
|
||||||
app:keywords="@string/keywords_gesture"
|
|
||||||
app:controller="com.android.settings.gestures.WakeScreenGesturePreferenceController"
|
|
||||||
app:allowDividerAbove="true" />
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
|
||||||
@@ -326,8 +326,6 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
|
|||||||
|
|
||||||
if (showWipeEuicc()) {
|
if (showWipeEuicc()) {
|
||||||
if (showWipeEuiccCheckbox()) {
|
if (showWipeEuiccCheckbox()) {
|
||||||
TextView title = mContentView.findViewById(R.id.erase_esim_title);
|
|
||||||
title.setText(R.string.erase_esim_storage);
|
|
||||||
mEsimStorageContainer.setVisibility(View.VISIBLE);
|
mEsimStorageContainer.setVisibility(View.VISIBLE);
|
||||||
mEsimStorageContainer.setOnClickListener(new View.OnClickListener() {
|
mEsimStorageContainer.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -213,8 +213,6 @@ public class ResetNetwork extends InstrumentedFragment {
|
|||||||
mInitiateButton.setOnClickListener(mInitiateListener);
|
mInitiateButton.setOnClickListener(mInitiateListener);
|
||||||
if (showEuiccSettings(getContext())) {
|
if (showEuiccSettings(getContext())) {
|
||||||
mEsimContainer.setVisibility(View.VISIBLE);
|
mEsimContainer.setVisibility(View.VISIBLE);
|
||||||
TextView title = mContentView.findViewById(R.id.erase_esim_title);
|
|
||||||
title.setText(R.string.reset_esim_title);
|
|
||||||
mEsimContainer.setOnClickListener(new OnClickListener() {
|
mEsimContainer.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|||||||
@@ -154,11 +154,15 @@ public class UserCredentialsSettings extends SettingsPreferenceFragment
|
|||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (item.isSystem()) {
|
// TODO: b/127865361
|
||||||
// TODO: a safe means of clearing wifi certificates. Configs refer to aliases
|
// a safe means of clearing wifi certificates. Configs refer to aliases
|
||||||
// directly so deleting certs will break dependent access points.
|
// directly so deleting certs will break dependent access points.
|
||||||
builder.setNegativeButton(R.string.trusted_credentials_remove_label, listener);
|
// However, Wi-Fi used to remove this certificate from storage if the network
|
||||||
}
|
// was removed, regardless if it is used in more than one network.
|
||||||
|
// It has been decided to allow removing certificates from this menu, as we
|
||||||
|
// assume that the user who manually adds certificates must have a way to
|
||||||
|
// manually remove them.
|
||||||
|
builder.setNegativeButton(R.string.trusted_credentials_remove_label, listener);
|
||||||
}
|
}
|
||||||
return builder.create();
|
return builder.create();
|
||||||
}
|
}
|
||||||
@@ -172,7 +176,8 @@ public class UserCredentialsSettings extends SettingsPreferenceFragment
|
|||||||
* Deletes all certificates and keys under a given alias.
|
* Deletes all certificates and keys under a given alias.
|
||||||
*
|
*
|
||||||
* If the {@link Credential} is for a system alias, all active grants to the alias will be
|
* If the {@link Credential} is for a system alias, all active grants to the alias will be
|
||||||
* removed using {@link KeyChain}.
|
* removed using {@link KeyChain}. If the {@link Credential} is for Wi-Fi alias, all
|
||||||
|
* credentials and keys will be removed using {@link KeyStore}.
|
||||||
*/
|
*/
|
||||||
private class RemoveCredentialsTask extends AsyncTask<Credential, Void, Credential[]> {
|
private class RemoveCredentialsTask extends AsyncTask<Credential, Void, Credential[]> {
|
||||||
private Context context;
|
private Context context;
|
||||||
@@ -188,14 +193,32 @@ public class UserCredentialsSettings extends SettingsPreferenceFragment
|
|||||||
for (final Credential credential : credentials) {
|
for (final Credential credential : credentials) {
|
||||||
if (credential.isSystem()) {
|
if (credential.isSystem()) {
|
||||||
removeGrantsAndDelete(credential);
|
removeGrantsAndDelete(credential);
|
||||||
continue;
|
} else {
|
||||||
|
deleteWifiCredential(credential);
|
||||||
}
|
}
|
||||||
throw new UnsupportedOperationException(
|
|
||||||
"Not implemented for wifi certificates. This should not be reachable.");
|
|
||||||
}
|
}
|
||||||
return credentials;
|
return credentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void deleteWifiCredential(final Credential credential) {
|
||||||
|
final KeyStore keyStore = KeyStore.getInstance();
|
||||||
|
final EnumSet<Credential.Type> storedTypes = credential.getStoredTypes();
|
||||||
|
|
||||||
|
// Remove all Wi-Fi credentials
|
||||||
|
if (storedTypes.contains(Credential.Type.USER_KEY)) {
|
||||||
|
keyStore.delete(Credentials.USER_PRIVATE_KEY + credential.getAlias(),
|
||||||
|
Process.WIFI_UID);
|
||||||
|
}
|
||||||
|
if (storedTypes.contains(Credential.Type.USER_CERTIFICATE)) {
|
||||||
|
keyStore.delete(Credentials.USER_CERTIFICATE + credential.getAlias(),
|
||||||
|
Process.WIFI_UID);
|
||||||
|
}
|
||||||
|
if (storedTypes.contains(Credential.Type.CA_CERTIFICATE)) {
|
||||||
|
keyStore.delete(Credentials.CA_CERTIFICATE + credential.getAlias(),
|
||||||
|
Process.WIFI_UID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void removeGrantsAndDelete(final Credential credential) {
|
private void removeGrantsAndDelete(final Credential credential) {
|
||||||
final KeyChainConnection conn;
|
final KeyChainConnection conn;
|
||||||
try {
|
try {
|
||||||
@@ -488,5 +511,11 @@ public class UserCredentialsSettings extends SettingsPreferenceFragment
|
|||||||
public boolean isSystem() {
|
public boolean isSystem() {
|
||||||
return UserHandle.getAppId(uid) == Process.SYSTEM_UID;
|
return UserHandle.getAppId(uid) == Process.SYSTEM_UID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAlias() { return alias; }
|
||||||
|
|
||||||
|
public EnumSet<Type> getStoredTypes() {
|
||||||
|
return storedTypes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import android.app.usage.UsageStatsManager;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.icu.text.RelativeDateTimeFormatter;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
@@ -224,7 +225,8 @@ public class RecentAppsPreferenceController extends BasePreferenceController
|
|||||||
.setIcon(mIconDrawableFactory.getBadgedIcon(appEntry.info))
|
.setIcon(mIconDrawableFactory.getBadgedIcon(appEntry.info))
|
||||||
.setTitle(appEntry.label)
|
.setTitle(appEntry.label)
|
||||||
.setSummary(StringUtil.formatRelativeTime(mContext,
|
.setSummary(StringUtil.formatRelativeTime(mContext,
|
||||||
System.currentTimeMillis() - stat.getLastTimeUsed(), false))
|
System.currentTimeMillis() - stat.getLastTimeUsed(), false,
|
||||||
|
RelativeDateTimeFormatter.Style.SHORT))
|
||||||
.setOnClickListener(v ->
|
.setOnClickListener(v ->
|
||||||
AppInfoBase.startAppInfoFragment(AppInfoDashboardFragment.class,
|
AppInfoBase.startAppInfoFragment(AppInfoDashboardFragment.class,
|
||||||
R.string.application_info_label, pkgName, appEntry.info.uid,
|
R.string.application_info_label, pkgName, appEntry.info.uid,
|
||||||
|
|||||||
@@ -15,22 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.settings.applications.appinfo;
|
package com.android.settings.applications.appinfo;
|
||||||
|
|
||||||
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
|
||||||
|
|
||||||
import android.app.ActivityManager;
|
|
||||||
import android.app.AppOpsManager;
|
import android.app.AppOpsManager;
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.content.pm.ResolveInfo;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
@@ -55,16 +46,11 @@ public class DrawOverlayDetails extends AppInfoWithHeader implements OnPreferenc
|
|||||||
private static final String KEY_APP_OPS_SETTINGS_SWITCH = "app_ops_settings_switch";
|
private static final String KEY_APP_OPS_SETTINGS_SWITCH = "app_ops_settings_switch";
|
||||||
private static final String LOG_TAG = "DrawOverlayDetails";
|
private static final String LOG_TAG = "DrawOverlayDetails";
|
||||||
|
|
||||||
private static final int[] APP_OPS_OP_CODE = {
|
|
||||||
AppOpsManager.OP_SYSTEM_ALERT_WINDOW
|
|
||||||
};
|
|
||||||
|
|
||||||
// Use a bridge to get the overlay details but don't initialize it to connect with all state.
|
// Use a bridge to get the overlay details but don't initialize it to connect with all state.
|
||||||
// TODO: Break out this functionality into its own class.
|
// TODO: Break out this functionality into its own class.
|
||||||
private AppStateOverlayBridge mOverlayBridge;
|
private AppStateOverlayBridge mOverlayBridge;
|
||||||
private AppOpsManager mAppOpsManager;
|
private AppOpsManager mAppOpsManager;
|
||||||
private SwitchPreference mSwitchPref;
|
private SwitchPreference mSwitchPref;
|
||||||
private Intent mSettingsIntent;
|
|
||||||
private OverlayState mOverlayState;
|
private OverlayState mOverlayState;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -82,18 +68,15 @@ public class DrawOverlayDetails extends AppInfoWithHeader implements OnPreferenc
|
|||||||
|
|
||||||
// find preferences
|
// find preferences
|
||||||
addPreferencesFromResource(R.xml.draw_overlay_permissions_details);
|
addPreferencesFromResource(R.xml.draw_overlay_permissions_details);
|
||||||
mSwitchPref = (SwitchPreference) findPreference(KEY_APP_OPS_SETTINGS_SWITCH);
|
mSwitchPref = findPreference(KEY_APP_OPS_SETTINGS_SWITCH);
|
||||||
|
|
||||||
// install event listeners
|
// install event listeners
|
||||||
mSwitchPref.setOnPreferenceChangeListener(this);
|
mSwitchPref.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
mSettingsIntent = new Intent(Intent.ACTION_MAIN)
|
|
||||||
.setAction(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Override here so we don't have an empty screen
|
// Override here so we don't have an empty screen
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView (LayoutInflater inflater,
|
public View onCreateView(LayoutInflater inflater,
|
||||||
ViewGroup container,
|
ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
// if we don't have a package info, show a page saying this is unsupported
|
// if we don't have a package info, show a page saying this is unsupported
|
||||||
@@ -103,21 +86,6 @@ public class DrawOverlayDetails extends AppInfoWithHeader implements OnPreferenc
|
|||||||
return super.onCreateView(inflater, container, savedInstanceState);
|
return super.onCreateView(inflater, container, savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
getActivity().getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
Window window = getActivity().getWindow();
|
|
||||||
WindowManager.LayoutParams attrs = window.getAttributes();
|
|
||||||
attrs.privateFlags &= ~SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
|
||||||
window.setAttributes(attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
@@ -164,7 +132,9 @@ public class DrawOverlayDetails extends AppInfoWithHeader implements OnPreferenc
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean refreshUi() {
|
protected boolean refreshUi() {
|
||||||
if (mPackageInfo == null) return true;
|
if (mPackageInfo == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
mOverlayState = mOverlayBridge.getOverlayInfo(mPackageName,
|
mOverlayState = mOverlayBridge.getOverlayInfo(mPackageName,
|
||||||
mPackageInfo.applicationInfo.uid);
|
mPackageInfo.applicationInfo.uid);
|
||||||
@@ -174,9 +144,6 @@ public class DrawOverlayDetails extends AppInfoWithHeader implements OnPreferenc
|
|||||||
// you cannot ask a user to grant you a permission you did not have!
|
// you cannot ask a user to grant you a permission you did not have!
|
||||||
mSwitchPref.setEnabled(mOverlayState.permissionDeclared && mOverlayState.controlEnabled);
|
mSwitchPref.setEnabled(mOverlayState.permissionDeclared && mOverlayState.controlEnabled);
|
||||||
|
|
||||||
ResolveInfo resolveInfo = mPm.resolveActivityAsUser(mSettingsIntent,
|
|
||||||
PackageManager.GET_META_DATA, mUserId);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
beverlyt@google.com
|
||||||
|
juliacr@google.com
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.settings.applications.specialaccess;
|
package com.android.settings.applications.specialaccess.zenaccess;
|
||||||
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
64
src/com/android/settings/core/HideNonSystemOverlayMixin.java
Normal file
64
src/com/android/settings/core/HideNonSystemOverlayMixin.java
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.core;
|
||||||
|
|
||||||
|
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||||
|
|
||||||
|
import static androidx.lifecycle.Lifecycle.Event.ON_START;
|
||||||
|
import static androidx.lifecycle.Lifecycle.Event.ON_STOP;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
|
||||||
|
import androidx.lifecycle.LifecycleObserver;
|
||||||
|
import androidx.lifecycle.OnLifecycleEvent;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A mixin that adds window flag to prevent non-system overlays showing on top of Settings
|
||||||
|
* activities.
|
||||||
|
*/
|
||||||
|
public class HideNonSystemOverlayMixin implements LifecycleObserver {
|
||||||
|
|
||||||
|
private final Activity mActivity;
|
||||||
|
|
||||||
|
public HideNonSystemOverlayMixin(Activity activity) {
|
||||||
|
mActivity = activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnLifecycleEvent(ON_START)
|
||||||
|
public void onStart() {
|
||||||
|
if (mActivity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mActivity.getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||||
|
android.util.EventLog.writeEvent(0x534e4554, "120484087", -1, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OnLifecycleEvent(ON_STOP)
|
||||||
|
public void onStop() {
|
||||||
|
if (mActivity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Window window = mActivity.getWindow();
|
||||||
|
final WindowManager.LayoutParams attrs = window.getAttributes();
|
||||||
|
attrs.privateFlags &= ~SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||||
|
window.setAttributes(attrs);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,7 +32,6 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager.LayoutParams;
|
|
||||||
import android.widget.Toolbar;
|
import android.widget.Toolbar;
|
||||||
|
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
@@ -59,8 +58,8 @@ public class SettingsBaseActivity extends FragmentActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
final long startTime = System.currentTimeMillis();
|
final long startTime = System.currentTimeMillis();
|
||||||
|
getLifecycle().addObserver(new HideNonSystemOverlayMixin(this));
|
||||||
|
|
||||||
final TypedArray theme = getTheme().obtainStyledAttributes(android.R.styleable.Theme);
|
final TypedArray theme = getTheme().obtainStyledAttributes(android.R.styleable.Theme);
|
||||||
if (!theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
|
if (!theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
|
||||||
|
|||||||
@@ -51,13 +51,15 @@ public abstract class SystemNavigationPreferenceController extends GesturePrefer
|
|||||||
private static final String ENABLE_ASSISTANT_GESTURE = "ENABLE_ASSISTANT_GESTURE";
|
private static final String ENABLE_ASSISTANT_GESTURE = "ENABLE_ASSISTANT_GESTURE";
|
||||||
private static final String PROTOTYPE_ENABLED = "prototype_enabled";
|
private static final String PROTOTYPE_ENABLED = "prototype_enabled";
|
||||||
|
|
||||||
private static final int EDGE_SENSITIVITY_WIDTH = 32;
|
private static final int EDGE_SENSITIVITY_WIDTH = 48;
|
||||||
private static final String EDGE_SENSITIVITY_KEY = "quickstepcontroller_edge_width_sensitivity";
|
private static final String EDGE_SENSITIVITY_KEY = "quickstepcontroller_edge_width_sensitivity";
|
||||||
|
|
||||||
private static final String GESTURES_MATCH_MAP_OFF = "000000";
|
private static final String GESTURES_MATCH_MAP_OFF = "000000";
|
||||||
private static final String GESTURES_MATCH_MAP_ON = "071133";
|
private static final String GESTURES_MATCH_MAP_ON = "071133";
|
||||||
private static final String GESTURES_MATCH_MAP_KEY = "quickstepcontroller_gesture_match_map";
|
private static final String GESTURES_MATCH_MAP_KEY = "quickstepcontroller_gesture_match_map";
|
||||||
|
|
||||||
|
private static final String OVERLAY_NAVBAR_KEY =
|
||||||
|
"com.android.internal.experiment.navbar.default";
|
||||||
private static final String OVERLAY_NAVBAR_TYPE_INSET =
|
private static final String OVERLAY_NAVBAR_TYPE_INSET =
|
||||||
"com.android.internal.experiment.navbar.type.inset";
|
"com.android.internal.experiment.navbar.type.inset";
|
||||||
private static final String OVERLAY_NAVBAR_TYPE_FLOATING =
|
private static final String OVERLAY_NAVBAR_TYPE_FLOATING =
|
||||||
@@ -174,6 +176,7 @@ public abstract class SystemNavigationPreferenceController extends GesturePrefer
|
|||||||
.asInterface(ServiceManager.getService(Context.OVERLAY_SERVICE));
|
.asInterface(ServiceManager.getService(Context.OVERLAY_SERVICE));
|
||||||
if (overlayManager != null) {
|
if (overlayManager != null) {
|
||||||
try {
|
try {
|
||||||
|
overlayManager.setEnabled(OVERLAY_NAVBAR_KEY, true, USER_SYSTEM);
|
||||||
overlayManager.setEnabled(OVERLAY_NAVBAR_TYPE_FLOATING, false, USER_SYSTEM);
|
overlayManager.setEnabled(OVERLAY_NAVBAR_TYPE_FLOATING, false, USER_SYSTEM);
|
||||||
overlayManager.setEnabled(OVERLAY_NAVBAR_TYPE_INSET, enable, USER_SYSTEM);
|
overlayManager.setEnabled(OVERLAY_NAVBAR_TYPE_INSET, enable, USER_SYSTEM);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2018 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.settings.gestures;
|
|
||||||
|
|
||||||
import android.app.settings.SettingsEnums;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.provider.SearchIndexableResource;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
|
||||||
import com.android.settingslib.search.SearchIndexable;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@SearchIndexable
|
|
||||||
public class WakeScreenGestureSettings extends DashboardFragment {
|
|
||||||
|
|
||||||
private static final String TAG = "WakeScreenGestureSettings";
|
|
||||||
|
|
||||||
public static final String PREF_KEY_SUGGESTION_COMPLETE =
|
|
||||||
"pref_wake_screen_gesture_suggestion_complete";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetricsCategory() {
|
|
||||||
return SettingsEnums.SETTINGS_GESTURE_WAKE_SCREEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getLogTag() {
|
|
||||||
return TAG;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getPreferenceScreenResId() {
|
|
||||||
return R.xml.wake_screen_gesture_settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
|
||||||
new BaseSearchIndexProvider() {
|
|
||||||
@Override
|
|
||||||
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
|
||||||
Context context, boolean enabled) {
|
|
||||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
|
||||||
sir.xmlResId = R.xml.wake_screen_gesture_settings;
|
|
||||||
return Arrays.asList(sir);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -139,7 +139,7 @@ public class ContextualCardFeatureProviderImpl implements ContextualCardFeatureP
|
|||||||
final String action = mContext.getString(R.string.config_settingsintelligence_log_action);
|
final String action = mContext.getString(R.string.config_settingsintelligence_log_action);
|
||||||
if (!TextUtils.isEmpty(action)) {
|
if (!TextUtils.isEmpty(action)) {
|
||||||
intent.setAction(action);
|
intent.setAction(action);
|
||||||
mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
|
mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,11 @@ public class MediaOutputSlice implements CustomSliceable {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getWorker() == null) {
|
||||||
|
Log.d(TAG, "getSlice() Can not get worker through uri!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
final List<MediaDevice> devices = getMediaDevices();
|
final List<MediaDevice> devices = getMediaDevices();
|
||||||
@ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
|
@ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
|
||||||
|
|
||||||
@@ -115,13 +120,15 @@ public class MediaOutputSlice implements CustomSliceable {
|
|||||||
private MediaDeviceUpdateWorker getWorker() {
|
private MediaDeviceUpdateWorker getWorker() {
|
||||||
if (mWorker == null) {
|
if (mWorker == null) {
|
||||||
mWorker = (MediaDeviceUpdateWorker) SliceBackgroundWorker.getInstance(getUri());
|
mWorker = (MediaDeviceUpdateWorker) SliceBackgroundWorker.getInstance(getUri());
|
||||||
mWorker.setPackageName(mPackageName);
|
if (mWorker != null) {
|
||||||
|
mWorker.setPackageName(mPackageName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return mWorker;
|
return mWorker;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<MediaDevice> getMediaDevices() {
|
private List<MediaDevice> getMediaDevices() {
|
||||||
List<MediaDevice> devices = getWorker().getMediaDevices();
|
final List<MediaDevice> devices = getWorker().getMediaDevices();
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import android.telephony.AccessNetworkConstants;
|
|||||||
import android.telephony.CarrierConfigManager;
|
import android.telephony.CarrierConfigManager;
|
||||||
import android.telephony.CellIdentity;
|
import android.telephony.CellIdentity;
|
||||||
import android.telephony.CellInfo;
|
import android.telephony.CellInfo;
|
||||||
import android.telephony.NetworkRegistrationState;
|
import android.telephony.NetworkRegistrationInfo;
|
||||||
import android.telephony.ServiceState;
|
import android.telephony.ServiceState;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
@@ -304,7 +304,7 @@ public class NetworkSelectSettings extends DashboardFragment {
|
|||||||
* Config the connected network operator preference when the page was created. When user get
|
* Config the connected network operator preference when the page was created. When user get
|
||||||
* into this page, the device might or might not have data connection.
|
* into this page, the device might or might not have data connection.
|
||||||
* - If the device has data:
|
* - If the device has data:
|
||||||
* 1. use {@code ServiceState#getNetworkRegistrationStates()} to get the currently
|
* 1. use {@code ServiceState#getNetworkRegistrationInfoList()} to get the currently
|
||||||
* registered cellIdentity, wrap it into a CellInfo;
|
* registered cellIdentity, wrap it into a CellInfo;
|
||||||
* 2. set the signal strength level as strong;
|
* 2. set the signal strength level as strong;
|
||||||
* 3. use {@link TelephonyManager#getNetworkOperatorName()} to get the title of the
|
* 3. use {@link TelephonyManager#getNetworkOperatorName()} to get the title of the
|
||||||
@@ -317,8 +317,8 @@ public class NetworkSelectSettings extends DashboardFragment {
|
|||||||
if (mTelephonyManager.getDataState() == mTelephonyManager.DATA_CONNECTED) {
|
if (mTelephonyManager.getDataState() == mTelephonyManager.DATA_CONNECTED) {
|
||||||
// Try to get the network registration states
|
// Try to get the network registration states
|
||||||
ServiceState ss = mTelephonyManager.getServiceState();
|
ServiceState ss = mTelephonyManager.getServiceState();
|
||||||
List<NetworkRegistrationState> networkList =
|
List<NetworkRegistrationInfo> networkList =
|
||||||
ss.getNetworkRegistrationStatesForTransportType(
|
ss.getNetworkRegistrationInfoListForTransportType(
|
||||||
AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
|
AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
|
||||||
if (networkList == null || networkList.size() == 0) {
|
if (networkList == null || networkList.size() == 0) {
|
||||||
// Remove the connected network operators category
|
// Remove the connected network operators category
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings.notification;
|
package com.android.settings.notification;
|
||||||
|
|
||||||
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
|
||||||
|
|
||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationChannelGroup;
|
import android.app.NotificationChannelGroup;
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
@@ -26,8 +24,6 @@ import android.os.AsyncTask;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceCategory;
|
import androidx.preference.PreferenceCategory;
|
||||||
@@ -88,8 +84,6 @@ public class AppNotificationSettings extends NotificationSettingsBase {
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
getActivity().getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
|
||||||
|
|
||||||
if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null) {
|
if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null) {
|
||||||
Log.w(TAG, "Missing package or uid or packageinfo");
|
Log.w(TAG, "Missing package or uid or packageinfo");
|
||||||
finish();
|
finish();
|
||||||
@@ -123,15 +117,6 @@ public class AppNotificationSettings extends NotificationSettingsBase {
|
|||||||
updatePreferenceStates();
|
updatePreferenceStates();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
final Window window = getActivity().getWindow();
|
|
||||||
final WindowManager.LayoutParams attrs = window.getAttributes();
|
|
||||||
attrs.privateFlags &= ~SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
|
||||||
window.setAttributes(attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getLogTag() {
|
protected String getLogTag() {
|
||||||
return TAG;
|
return TAG;
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
|
|||||||
} else if (isManagedProfile && isInternalActivity()
|
} else if (isManagedProfile && isInternalActivity()
|
||||||
&& !lockPatternUtils.isSeparateProfileChallengeEnabled(mUserId)) {
|
&& !lockPatternUtils.isSeparateProfileChallengeEnabled(mUserId)) {
|
||||||
mCredentialMode = CREDENTIAL_MANAGED;
|
mCredentialMode = CREDENTIAL_MANAGED;
|
||||||
if (isBiometricAllowed(effectiveUserId)) {
|
if (isBiometricAllowed(effectiveUserId, mUserId)) {
|
||||||
showBiometricPrompt(bpBundle);
|
showBiometricPrompt(bpBundle);
|
||||||
launchedBiometric = true;
|
launchedBiometric = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -207,7 +207,7 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mCredentialMode = CREDENTIAL_NORMAL;
|
mCredentialMode = CREDENTIAL_NORMAL;
|
||||||
if (isBiometricAllowed(effectiveUserId)) {
|
if (isBiometricAllowed(effectiveUserId, mUserId)) {
|
||||||
// Don't need to check if biometrics / pin/pattern/pass are enrolled. It will go to
|
// Don't need to check if biometrics / pin/pattern/pass are enrolled. It will go to
|
||||||
// onAuthenticationError and do the right thing automatically.
|
// onAuthenticationError and do the right thing automatically.
|
||||||
showBiometricPrompt(bpBundle);
|
showBiometricPrompt(bpBundle);
|
||||||
@@ -273,9 +273,10 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
|
|||||||
return (disabledFeatures & DevicePolicyManager.KEYGUARD_DISABLE_BIOMETRICS) != 0;
|
return (disabledFeatures & DevicePolicyManager.KEYGUARD_DISABLE_BIOMETRICS) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isBiometricAllowed(int effectiveUserId) {
|
private boolean isBiometricAllowed(int effectiveUserId, int realUserId) {
|
||||||
return !isStrongAuthRequired(effectiveUserId)
|
return !isStrongAuthRequired(effectiveUserId)
|
||||||
&& !isBiometricDisabledByAdmin(effectiveUserId);
|
&& !isBiometricDisabledByAdmin(effectiveUserId)
|
||||||
|
&& !mLockPatternUtils.hasPendingEscrowToken(realUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showBiometricPrompt(Bundle bundle) {
|
private void showBiometricPrompt(Bundle bundle) {
|
||||||
@@ -304,9 +305,18 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
|
|||||||
private void showConfirmCredentials() {
|
private void showConfirmCredentials() {
|
||||||
mCCLaunched = true;
|
mCCLaunched = true;
|
||||||
boolean launched = false;
|
boolean launched = false;
|
||||||
|
// The only difference between CREDENTIAL_MANAGED and CREDENTIAL_NORMAL is that for
|
||||||
|
// CREDENTIAL_MANAGED, we launch the real confirm credential activity with an explicit
|
||||||
|
// but dummy challenge value (0L). This will result in ConfirmLockPassword calling
|
||||||
|
// verifyTiedProfileChallenge() (if it's a profile with unified challenge), due to the
|
||||||
|
// difference between ConfirmLockPassword.startVerifyPassword() and
|
||||||
|
// ConfirmLockPassword.startCheckPassword(). Calling verifyTiedProfileChallenge() here is
|
||||||
|
// necessary when this is part of the turning on work profile flow, because it forces
|
||||||
|
// unlocking the work profile even before the profile is running.
|
||||||
|
// TODO: Remove the duplication of checkPassword and verifyPassword in ConfirmLockPassword,
|
||||||
|
// LockPatternChecker and LockPatternUtils. verifyPassword should be the only API to use,
|
||||||
|
// which optionally accepts a challenge.
|
||||||
if (mCredentialMode == CREDENTIAL_MANAGED) {
|
if (mCredentialMode == CREDENTIAL_MANAGED) {
|
||||||
// We set the challenge as 0L, so it will force to unlock managed profile when it
|
|
||||||
// unlocks primary profile screen lock, by calling verifyTiedProfileChallenge()
|
|
||||||
launched = mChooseLockSettingsHelper
|
launched = mChooseLockSettingsHelper
|
||||||
.launchConfirmationActivityWithExternalAndChallenge(
|
.launchConfirmationActivityWithExternalAndChallenge(
|
||||||
0 /* request code */, null /* title */, mTitle, mDetails,
|
0 /* request code */, null /* title */, mTitle, mDetails,
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import com.android.settingslib.search.SearchIndexableResources;
|
|||||||
*/
|
*/
|
||||||
public interface SearchFeatureProvider {
|
public interface SearchFeatureProvider {
|
||||||
|
|
||||||
int REQUEST_CODE = 0;
|
int REQUEST_CODE = 501;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures the caller has necessary privilege to launch search result page.
|
* Ensures the caller has necessary privilege to launch search result page.
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import com.android.settings.Utils;
|
|||||||
import com.android.settings.core.InstrumentedFragment;
|
import com.android.settings.core.InstrumentedFragment;
|
||||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
|
import com.android.settings.search.SearchFeatureProvider;
|
||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnCreateOptionsMenu;
|
import com.android.settingslib.core.lifecycle.events.OnCreateOptionsMenu;
|
||||||
|
|
||||||
@@ -93,7 +94,7 @@ public class SearchMenuController implements LifecycleObserver, OnCreateOptionsM
|
|||||||
|
|
||||||
FeatureFactory.getFactory(context).getMetricsFeatureProvider()
|
FeatureFactory.getFactory(context).getMetricsFeatureProvider()
|
||||||
.action(context, SettingsEnums.ACTION_SEARCH_RESULTS);
|
.action(context, SettingsEnums.ACTION_SEARCH_RESULTS);
|
||||||
mHost.startActivityForResult(intent, 0 /* requestCode */);
|
mHost.startActivityForResult(intent, SearchFeatureProvider.REQUEST_CODE);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public abstract class SliceBackgroundWorker<E> implements Closeable {
|
|||||||
needNotify = true;
|
needNotify = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
needNotify = !results.equals(mCachedResults);
|
needNotify = !areListsTheSame(results, mCachedResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needNotify) {
|
if (needNotify) {
|
||||||
@@ -155,6 +155,10 @@ public abstract class SliceBackgroundWorker<E> implements Closeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean areListsTheSame(List<E> a, List<E> b) {
|
||||||
|
return a.equals(b);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify that data was updated and attempt to sync changes to the Slice.
|
* Notify that data was updated and attempt to sync changes to the Slice.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ class SlicesIndexer implements Runnable {
|
|||||||
} finally {
|
} finally {
|
||||||
database.endTransaction();
|
database.endTransaction();
|
||||||
}
|
}
|
||||||
database.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import android.graphics.PorterDuffColorFilter;
|
|||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
|
import android.net.NetworkInfo.State;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.net.wifi.WifiInfo;
|
import android.net.wifi.WifiInfo;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
@@ -355,7 +356,6 @@ public class WifiSlice implements CustomSliceable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnectedChanged() {
|
public void onConnectedChanged() {
|
||||||
notifySliceChange();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -370,10 +370,43 @@ public class WifiSlice implements CustomSliceable {
|
|||||||
final List<AccessPoint> resultList = new ArrayList<>();
|
final List<AccessPoint> resultList = new ArrayList<>();
|
||||||
for (AccessPoint ap : accessPoints) {
|
for (AccessPoint ap : accessPoints) {
|
||||||
if (ap.isReachable()) {
|
if (ap.isReachable()) {
|
||||||
resultList.add(ap);
|
resultList.add(clone(ap));
|
||||||
|
if (resultList.size() >= DEFAULT_EXPANDED_ROW_COUNT) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateResults(resultList);
|
updateResults(resultList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private AccessPoint clone(AccessPoint accessPoint) {
|
||||||
|
final Bundle savedState = new Bundle();
|
||||||
|
accessPoint.saveWifiState(savedState);
|
||||||
|
return new AccessPoint(mContext, savedState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean areListsTheSame(List<AccessPoint> a, List<AccessPoint> b) {
|
||||||
|
if (!a.equals(b)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// compare access point states one by one
|
||||||
|
final int listSize = a.size();
|
||||||
|
for (int i = 0; i < listSize; i++) {
|
||||||
|
if (getState(a.get(i)) != getState(b.get(i))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private State getState(AccessPoint accessPoint) {
|
||||||
|
final NetworkInfo networkInfo = accessPoint.getNetworkInfo();
|
||||||
|
if (networkInfo != null) {
|
||||||
|
return networkInfo.getState();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.settings.applications.specialaccess;
|
package com.android.settings.applications.specialaccess.zenaccess;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.core;
|
||||||
|
|
||||||
|
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.Robolectric;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.android.controller.ActivityController;
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
public class HideNonSystemOverlayMixinTest {
|
||||||
|
|
||||||
|
private ActivityController<TestActivity> mActivityController;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
RuntimeEnvironment.application.setTheme(R.style.Theme_AppCompat);
|
||||||
|
mActivityController = Robolectric.buildActivity(TestActivity.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void startActivity_shouldHideNonSystemOverlay() {
|
||||||
|
mActivityController.setup();
|
||||||
|
TestActivity activity = mActivityController.get();
|
||||||
|
|
||||||
|
// Activity start: HIDE_NON_SYSTEM_OVERLAY should be set.
|
||||||
|
final WindowManager.LayoutParams attrs = activity.getWindow().getAttributes();
|
||||||
|
assertThat(attrs.privateFlags & SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS)
|
||||||
|
.isNotEqualTo(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void stopActivity_shouldUnhideNonSystemOverlay() {
|
||||||
|
mActivityController.setup().stop();
|
||||||
|
TestActivity activity = mActivityController.get();
|
||||||
|
|
||||||
|
final WindowManager.LayoutParams attrs = activity.getWindow().getAttributes();
|
||||||
|
assertThat(attrs.privateFlags & SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS)
|
||||||
|
.isEqualTo(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class TestActivity extends AppCompatActivity {
|
||||||
|
@Override
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
getLifecycle().addObserver(new HideNonSystemOverlayMixin(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2018 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.settings.gestures;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
import android.provider.SearchIndexableResource;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.robolectric.RobolectricTestRunner;
|
|
||||||
import org.robolectric.RuntimeEnvironment;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
|
||||||
public class WakeScreenGestureSettingsTest {
|
|
||||||
|
|
||||||
private WakeScreenGestureSettings mSettings;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
mSettings = new WakeScreenGestureSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSearchIndexProvider_shouldIndexResource() {
|
|
||||||
final List<SearchIndexableResource> indexRes =
|
|
||||||
WakeScreenGestureSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
|
|
||||||
RuntimeEnvironment.application, true /* enabled */);
|
|
||||||
|
|
||||||
assertThat(indexRes).isNotNull();
|
|
||||||
assertThat(indexRes.get(0).xmlResId).isEqualTo(mSettings.getPreferenceScreenResId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -57,7 +57,7 @@ public class ContextualCardFeatureProviderImplTest {
|
|||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
mImpl.sendBroadcast(intent);
|
mImpl.sendBroadcast(intent);
|
||||||
|
|
||||||
verify(mContext, never()).sendBroadcastAsUser(intent, UserHandle.ALL);
|
verify(mContext, never()).sendBroadcastAsUser(intent, UserHandle.CURRENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -66,7 +66,7 @@ public class ContextualCardFeatureProviderImplTest {
|
|||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
mImpl.sendBroadcast(intent);
|
mImpl.sendBroadcast(intent);
|
||||||
|
|
||||||
verify(mContext).sendBroadcastAsUser(intent, UserHandle.ALL);
|
verify(mContext).sendBroadcastAsUser(intent, UserHandle.CURRENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -93,6 +93,13 @@ public class MediaOutputSliceTest {
|
|||||||
mMediaOutputSlice.init(TEST_PACKAGE_NAME, mMediaDeviceUpdateWorker);
|
mMediaOutputSlice.init(TEST_PACKAGE_NAME, mMediaDeviceUpdateWorker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSlice_workerIsNull_shouldNotCrash() {
|
||||||
|
mMediaOutputSlice.init(TEST_PACKAGE_NAME, null);
|
||||||
|
|
||||||
|
mMediaOutputSlice.getSlice();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSlice_shouldHaveActiveDeviceName() {
|
public void getSlice_shouldHaveActiveDeviceName() {
|
||||||
mDevices.clear();
|
mDevices.clear();
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import static org.mockito.Mockito.verify;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.media.session.ControllerLink;
|
import android.media.session.ISessionController;
|
||||||
import android.media.session.MediaController;
|
import android.media.session.MediaController;
|
||||||
import android.media.session.MediaSession;
|
import android.media.session.MediaSession;
|
||||||
import android.media.session.MediaSessionManager;
|
import android.media.session.MediaSessionManager;
|
||||||
@@ -51,9 +51,9 @@ public class RemoteVolumePreferenceControllerTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private MediaController mMediaController;
|
private MediaController mMediaController;
|
||||||
@Mock
|
@Mock
|
||||||
private ControllerLink.ControllerStub mStub;
|
private ISessionController mStub;
|
||||||
@Mock
|
@Mock
|
||||||
private ControllerLink.ControllerStub mStub2;
|
private ISessionController mStub2;
|
||||||
private MediaSession.Token mToken;
|
private MediaSession.Token mToken;
|
||||||
private MediaSession.Token mToken2;
|
private MediaSession.Token mToken2;
|
||||||
private RemoteVolumePreferenceController mController;
|
private RemoteVolumePreferenceController mController;
|
||||||
@@ -71,8 +71,8 @@ public class RemoteVolumePreferenceControllerTest {
|
|||||||
mActiveSessions.add(mMediaController);
|
mActiveSessions.add(mMediaController);
|
||||||
when(mMediaSessionManager.getActiveSessions(null)).thenReturn(
|
when(mMediaSessionManager.getActiveSessions(null)).thenReturn(
|
||||||
mActiveSessions);
|
mActiveSessions);
|
||||||
mToken = new MediaSession.Token(new ControllerLink(mStub));
|
mToken = new MediaSession.Token(mStub);
|
||||||
mToken2 = new MediaSession.Token(new ControllerLink(mStub2));
|
mToken2 = new MediaSession.Token(mStub2);
|
||||||
|
|
||||||
mController = new RemoteVolumePreferenceController(mContext);
|
mController = new RemoteVolumePreferenceController(mContext);
|
||||||
mPlaybackInfo = new MediaController.PlaybackInfo(
|
mPlaybackInfo = new MediaController.PlaybackInfo(
|
||||||
|
|||||||
@@ -34,8 +34,10 @@ import android.content.ContentResolver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
|
import android.net.NetworkInfo.State;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.core.graphics.drawable.IconCompat;
|
import androidx.core.graphics.drawable.IconCompat;
|
||||||
import androidx.slice.Slice;
|
import androidx.slice.Slice;
|
||||||
@@ -61,6 +63,7 @@ import org.robolectric.annotation.Implementation;
|
|||||||
import org.robolectric.annotation.Implements;
|
import org.robolectric.annotation.Implements;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@@ -253,11 +256,42 @@ public class WifiSliceTest {
|
|||||||
verify(mResolver).notifyChange(WIFI_SLICE_URI, null);
|
verify(mResolver).notifyChange(WIFI_SLICE_URI, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
private AccessPoint createAccessPoint(String name, State state) {
|
||||||
public void onConnectedChanged_shouldNotifyChange() {
|
final NetworkInfo info = mock(NetworkInfo.class);
|
||||||
mWifiScanWorker.onConnectedChanged();
|
doReturn(state).when(info).getState();
|
||||||
|
|
||||||
verify(mResolver).notifyChange(WIFI_SLICE_URI, null);
|
final Bundle savedState = new Bundle();
|
||||||
|
savedState.putString("key_ssid", name);
|
||||||
|
savedState.putParcelable("key_networkinfo", info);
|
||||||
|
return new AccessPoint(mContext, savedState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void SliceAccessPoint_sameState_shouldBeTheSame() {
|
||||||
|
final AccessPoint ap1 = createAccessPoint(AP1_NAME, State.CONNECTED);
|
||||||
|
final AccessPoint ap2 = createAccessPoint(AP1_NAME, State.CONNECTED);
|
||||||
|
|
||||||
|
assertThat(mWifiScanWorker.areListsTheSame(Arrays.asList(ap1), Arrays.asList(ap2)))
|
||||||
|
.isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void SliceAccessPoint_differentState_shouldBeDifferent() {
|
||||||
|
final AccessPoint ap1 = createAccessPoint(AP1_NAME, State.CONNECTING);
|
||||||
|
final AccessPoint ap2 = createAccessPoint(AP1_NAME, State.CONNECTED);
|
||||||
|
|
||||||
|
assertThat(mWifiScanWorker.areListsTheSame(Arrays.asList(ap1), Arrays.asList(ap2)))
|
||||||
|
.isFalse();
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void SliceAccessPoint_differentLength_shouldBeDifferent() {
|
||||||
|
final AccessPoint ap1 = createAccessPoint(AP1_NAME, State.CONNECTED);
|
||||||
|
final AccessPoint ap2 = createAccessPoint(AP1_NAME, State.CONNECTED);
|
||||||
|
final List<AccessPoint> list = new ArrayList<>();
|
||||||
|
list.add(ap1);
|
||||||
|
list.add(ap2);
|
||||||
|
|
||||||
|
assertThat(mWifiScanWorker.areListsTheSame(list, Arrays.asList(ap1))).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Implements(SliceBackgroundWorker.class)
|
@Implements(SliceBackgroundWorker.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user