Snap for 7325276 from c51cefb2b9 to sc-release
Change-Id: I1e8deb0cdeb5567bdb77e85ff364c6073955cf45
This commit is contained in:
26
res/drawable/ic_accessibility_visibility.xml
Normal file
26
res/drawable/ic_accessibility_visibility.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2021 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.
|
||||
-->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M12,7c-2.48,0 -4.5,2.02 -4.5,4.5S9.52,16 12,16s4.5,-2.02 4.5,-4.5S14.48,7 12,7zM12,14.2c-1.49,0 -2.7,-1.21 -2.7,-2.7 0,-1.49 1.21,-2.7 2.7,-2.7s2.7,1.21 2.7,2.7c0,1.49 -1.21,2.7 -2.7,2.7zM12,4C7,4 2.73,7.11 1,11.5 2.73,15.89 7,19 12,19s9.27,-3.11 11,-7.5C21.27,7.11 17,4 12,4zM12,17c-3.79,0 -7.17,-2.13 -8.82,-5.5C4.83,8.13 8.21,6 12,6s7.17,2.13 8.82,5.5C19.17,14.87 15.79,17 12,17z"
|
||||
android:fillColor="?android:attr/colorPrimary"/>
|
||||
</vector>
|
||||
@@ -3768,6 +3768,8 @@
|
||||
<string name="apn_edit">Edit access point</string>
|
||||
<!-- Edit access point label summary text when no value has been set -->
|
||||
<string name="apn_not_set">Not set</string>
|
||||
<!-- Edit access point label summary text when no value has been set for mvno value. [CHAR LIMIT=NONE]-->
|
||||
<string name="apn_not_set_for_mvno">Not set</string>
|
||||
<!-- Edit access point labels: A label the user can give to the APN to allow him to differentiate it from the others -->
|
||||
<string name="apn_name">Name</string>
|
||||
<!-- Edit access point labels: The actual access point name-->
|
||||
@@ -6322,9 +6324,9 @@
|
||||
<string name ="battery_detail_manage_title">Manage battery usage</string>
|
||||
|
||||
<!-- Description for battery total and background usage time for an app, i.e. 1 hr 15 min total • 39 min background for past 24 hr. Note: ^1 and ^2 should be used in all translations [CHAR LIMIT=120] -->
|
||||
<string name="battery_total_and_background_usage"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total • <xliff:g id="time" example="39 min">^2</xliff:g> background for past 24 hr</string>
|
||||
<string name="battery_total_and_bg_usage"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total • <xliff:g id="time" example="39 min">^2</xliff:g> background for past 24 hr</string>
|
||||
<!-- Description for battery total and background usage time in a time period for an app, i.e. 1 hr 15 min total • 39 min background for 12 am-2 am. Note: ^1, ^2 and ^3 should be used in all translations [CHAR LIMIT=120] -->
|
||||
<string name="battery_total_and_background_usage_with_period"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total • <xliff:g id="time" example="39 min">^2</xliff:g> background for <xliff:g id="time_period" example="12 am-2 am">^3</xliff:g></string>
|
||||
<string name="battery_total_and_bg_usage_with_period"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total • <xliff:g id="time" example="39 min">^2</xliff:g> background for <xliff:g id="time_period" example="12 am-2 am">^3</xliff:g></string>
|
||||
|
||||
<!-- Description for battery total usage time is less than a minute for an app [CHAR LIMIT=120] -->
|
||||
<string name="battery_total_usage_less_minute">Total less than a minute for past 24 hr</string>
|
||||
@@ -6332,9 +6334,9 @@
|
||||
<string name="battery_total_usage_less_minute_with_period">Total less than a minute for <xliff:g id="time_period" example="12 am-2 am">^1</xliff:g></string>
|
||||
|
||||
<!-- Description for battery background usage time is less than a minute for an app [CHAR LIMIT=120] -->
|
||||
<string name="battery_background_usage_less_minute">Background less than a minute for past 24 hr</string>
|
||||
<string name="battery_bg_usage_less_minute">Background less than a minute for past 24 hr</string>
|
||||
<!-- Description for battery background usage time is less than a minute in a time period for an app, i.e. Background less than a minute for 12 am-2 am. Note: ^1 should be used in all translations[CHAR LIMIT=120] -->
|
||||
<string name="battery_background_usage_less_minute_with_period">Background less than a minute for <xliff:g id="time_period" example="12 am-2 am">^1</xliff:g></string>
|
||||
<string name="battery_bg_usage_less_minute_with_period">Background less than a minute for <xliff:g id="time_period" example="12 am-2 am">^1</xliff:g></string>
|
||||
|
||||
<!-- Description for battery total usage time for an app, i.e. 1 hr 15 min total for past 24 hr. Note: ^1 should be used in all translations [CHAR LIMIT=120] -->
|
||||
<string name="battery_total_usage"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total for past 24 hr</string>
|
||||
@@ -6342,14 +6344,14 @@
|
||||
<string name="battery_total_usage_with_period"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total for <xliff:g id="time_period" example="12 am-2 am">^2</xliff:g></string>
|
||||
|
||||
<!-- Description for battery background usage time for an app, i.e. 1 hr 15 min background for past 24 hr. Note: ^1 should be used in all translations [CHAR LIMIT=120] -->
|
||||
<string name="battery_background_usage"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> background for past 24 hr</string>
|
||||
<string name="battery_bg_usage"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> background for past 24 hr</string>
|
||||
<!-- Description for battery background usage time in a time period for an app, i.e. 1 hr 15 min background for 12 am-2 am. Note: ^1 and ^2 should be used in all translations [CHAR LIMIT=120] -->
|
||||
<string name="battery_background_usage_with_period"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> background for <xliff:g id="time_period" example="12 am-2 am">^2</xliff:g></string>
|
||||
<string name="battery_bg_usage_with_period"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> background for <xliff:g id="time_period" example="12 am-2 am">^2</xliff:g></string>
|
||||
|
||||
<!-- Description for battery total usage with background usage time less than a minute for an app, i.e. 1 hr 15 min total • background less than a minute for past 24 hr. Note: ^1 should be used in all translations [CHAR LIMIT=120] -->
|
||||
<string name="battery_total_usage_and_background_less_minute_usage"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total • background less than a minute for past 24 hr</string>
|
||||
<string name="battery_total_usage_and_bg_less_minute_usage"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total • background less than a minute for past 24 hr</string>
|
||||
<!-- Description for battery total usage with background usage time less than a minute in a time period for an app, i.e. 1 hr 15 min total • background less than a minute for 12 am-2 am. Note: ^1 and ^2 should be used in all translations [CHAR LIMIT=120] -->
|
||||
<string name="battery_total_usage_and_background_less_minute_usage_with_period"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total • background less than a minute for <xliff:g id="time_period" example="12 am-2 am">^2</xliff:g></string>
|
||||
<string name="battery_total_usage_and_bg_less_minute_usage_with_period"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total • background less than a minute for <xliff:g id="time_period" example="12 am-2 am">^2</xliff:g></string>
|
||||
|
||||
<!-- Description for no any battery usage for past 24 hr [CHAR LIMIT=120] -->
|
||||
<string name="battery_not_usage">No usage for past 24 hr</string>
|
||||
|
||||
@@ -14,46 +14,44 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:persistent="true"
|
||||
android:title="@string/vision_settings_title">
|
||||
|
||||
<com.android.settings.accessibility.DividerAllowedBelowPreference
|
||||
android:key="vision_settings_summary"
|
||||
android:layout="@layout/preference_multiline_title"
|
||||
android:selectable="false"
|
||||
android:title="@string/vision_settings_description" />
|
||||
|
||||
<Preference
|
||||
settings:controller="com.android.settings.accessibility.MagnificationPreferenceController"
|
||||
android:fragment="com.android.settings.accessibility.MagnificationPreferenceFragment"
|
||||
android:key="screen_magnification_preference"
|
||||
android:summary="@string/accessibility_preference_magnification_summary"
|
||||
android:title="@string/accessibility_screen_magnification_title" />
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.display.FontSizePreferenceFragmentForSetupWizard"
|
||||
android:key="font_size_preference"
|
||||
android:icon="@drawable/ic_font_size"
|
||||
android:summary="@string/short_summary_font_size"
|
||||
android:title="@string/title_font_size" />
|
||||
android:title="@string/title_font_size"/>
|
||||
|
||||
<com.android.settings.display.ScreenZoomPreference
|
||||
android:fragment="com.android.settings.display.ScreenZoomPreferenceFragmentForSetupWizard"
|
||||
android:key="force_density_preference"
|
||||
android:icon="@drawable/ic_screen_zoom"
|
||||
android:summary="@string/screen_zoom_short_summary"
|
||||
android:title="@string/screen_zoom_title" />
|
||||
android:title="@string/screen_zoom_title"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.accessibility.MagnificationPreferenceFragment"
|
||||
android:key="screen_magnification_preference"
|
||||
android:icon="@drawable/ic_accessibility_magnification"
|
||||
android:summary="@string/accessibility_preference_magnification_summary"
|
||||
android:title="@string/accessibility_screen_magnification_title"
|
||||
settings:controller="com.android.settings.accessibility.MagnificationPreferenceController"/>
|
||||
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:fragment="com.android.settings.accessibility.ToggleSelectToSpeakPreferenceFragmentForSetupWizard"
|
||||
android:key="select_to_speak_preference"
|
||||
android:persistent="true"
|
||||
android:summary="@string/select_to_speak_summary" />
|
||||
android:summary="@string/select_to_speak_summary"/>
|
||||
|
||||
<Preference
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:fragment="com.android.settings.accessibility.ToggleScreenReaderPreferenceFragmentForSetupWizard"
|
||||
android:key="screen_reader_preference"
|
||||
android:persistent="true"
|
||||
android:summary="@string/talkback_summary" />
|
||||
android:summary="@string/talkback_summary"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
@@ -48,6 +48,12 @@
|
||||
settings:allowDividerAbove="true"
|
||||
settings:userRestriction="no_config_date_time"/>
|
||||
|
||||
<!-- This preference gets removed if location-based time zone detection is not supported -->
|
||||
<SwitchPreference
|
||||
android:key="location_time_zone_detection"
|
||||
android:title="@string/location_time_zone_detection_toggle_title"
|
||||
settings:controller="com.android.settings.datetime.LocationTimeZoneDetectionPreferenceController"/>
|
||||
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="timezone"
|
||||
android:title="@string/date_time_set_timezone_title"
|
||||
@@ -56,12 +62,6 @@
|
||||
settings:userRestriction="no_config_date_time"
|
||||
settings:keywords="@string/keywords_time_zone"/>
|
||||
|
||||
<!-- This preference gets removed if location-based time zone detection is not supported -->
|
||||
<SwitchPreference
|
||||
android:key="location_time_zone_detection"
|
||||
android:title="@string/location_time_zone_detection_toggle_title"
|
||||
settings:controller="com.android.settings.datetime.LocationTimeZoneDetectionPreferenceController"
|
||||
/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
|
||||
@@ -54,7 +54,6 @@
|
||||
<Preference
|
||||
android:key="app_level_permissions"
|
||||
android:title="@string/location_app_level_permissions"
|
||||
android:icon="@drawable/ic_chevron_right_24dp"
|
||||
settings:controller="com.android.settings.location.AppLocationPermissionPreferenceController">
|
||||
<intent android:action="android.intent.action.MANAGE_PERMISSION_APPS">
|
||||
<extra android:name="android.intent.extra.PERMISSION_NAME"
|
||||
@@ -65,7 +64,6 @@
|
||||
<Preference
|
||||
android:fragment="com.android.settings.location.LocationServices"
|
||||
android:key="location_services"
|
||||
android:icon="@drawable/ic_chevron_right_24dp"
|
||||
android:title="@string/location_services_preference_title"
|
||||
settings:controller="com.android.settings.location.LocationServicesPreferenceController"/>
|
||||
|
||||
|
||||
@@ -16,24 +16,32 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.settings.Utils.getAdaptiveIcon;
|
||||
import static com.android.settings.accessibility.AccessibilityUtil.AccessibilityServiceFragmentType.VOLUME_SHORTCUT_TOGGLE;
|
||||
import static com.android.settingslib.widget.TwoTargetPreference.ICON_SIZE_MEDIUM;
|
||||
|
||||
import android.accessibilityservice.AccessibilityServiceInfo;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
|
||||
import com.google.android.setupdesign.GlifPreferenceLayout;
|
||||
|
||||
@@ -61,8 +69,8 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
||||
|
||||
// Preference controls.
|
||||
private Preference mDisplayMagnificationPreference;
|
||||
private Preference mScreenReaderPreference;
|
||||
private Preference mSelectToSpeakPreference;
|
||||
private RestrictedPreference mScreenReaderPreference;
|
||||
private RestrictedPreference mSelectToSpeakPreference;
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
@@ -73,16 +81,24 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
GlifPreferenceLayout layout = (GlifPreferenceLayout) view;
|
||||
final GlifPreferenceLayout layout = (GlifPreferenceLayout) view;
|
||||
layout.setDividerInsets(Integer.MAX_VALUE, 0);
|
||||
|
||||
layout.setDescriptionText(R.string.vision_settings_description);
|
||||
layout.setHeaderText(R.string.vision_settings_title);
|
||||
layout.setIcon(getResources().getDrawable(R.drawable.ic_accessibility_visibility));
|
||||
|
||||
final ImageView iconView = layout.findManagedViewById(R.id.sud_layout_icon);
|
||||
final FrameLayout.LayoutParams params =
|
||||
(FrameLayout.LayoutParams) iconView.getLayoutParams();
|
||||
params.gravity = Gravity.START;
|
||||
layout.getHeaderTextView().setGravity(Gravity.START);
|
||||
layout.getDescriptionTextView().setGravity(Gravity.START);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent,
|
||||
Bundle savedInstanceState) {
|
||||
GlifPreferenceLayout layout = (GlifPreferenceLayout) parent;
|
||||
final GlifPreferenceLayout layout = (GlifPreferenceLayout) parent;
|
||||
return layout.onCreateRecyclerView(inflater, parent, savedInstanceState);
|
||||
}
|
||||
|
||||
@@ -145,7 +161,7 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
||||
return null;
|
||||
}
|
||||
|
||||
private void updateAccessibilityServicePreference(Preference preference,
|
||||
private void updateAccessibilityServicePreference(RestrictedPreference preference,
|
||||
String packageName, String serviceName, String targetFragment) {
|
||||
final AccessibilityServiceInfo info = findService(packageName, serviceName);
|
||||
if (info == null) {
|
||||
@@ -153,24 +169,28 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
||||
return;
|
||||
}
|
||||
|
||||
ServiceInfo serviceInfo = info.getResolveInfo().serviceInfo;
|
||||
String title = info.getResolveInfo().loadLabel(getPackageManager()).toString();
|
||||
final ServiceInfo serviceInfo = info.getResolveInfo().serviceInfo;
|
||||
final Drawable icon = info.getResolveInfo().loadIcon(getPackageManager());
|
||||
preference.setIcon(getAdaptiveIcon(getContext(), icon, Color.WHITE));
|
||||
preference.setIconSize(ICON_SIZE_MEDIUM);
|
||||
final String title = info.getResolveInfo().loadLabel(getPackageManager()).toString();
|
||||
preference.setTitle(title);
|
||||
ComponentName componentName = new ComponentName(serviceInfo.packageName, serviceInfo.name);
|
||||
final ComponentName componentName =
|
||||
new ComponentName(serviceInfo.packageName, serviceInfo.name);
|
||||
preference.setKey(componentName.flattenToString());
|
||||
if (AccessibilityUtil.getAccessibilityServiceFragmentType(info) == VOLUME_SHORTCUT_TOGGLE) {
|
||||
preference.setFragment(targetFragment);
|
||||
}
|
||||
|
||||
// Update the extras.
|
||||
Bundle extras = preference.getExtras();
|
||||
final Bundle extras = preference.getExtras();
|
||||
extras.putParcelable(AccessibilitySettings.EXTRA_COMPONENT_NAME, componentName);
|
||||
|
||||
extras.putString(AccessibilitySettings.EXTRA_PREFERENCE_KEY,
|
||||
preference.getKey());
|
||||
extras.putString(AccessibilitySettings.EXTRA_TITLE, title);
|
||||
|
||||
String description = info.loadDescription(getPackageManager());
|
||||
final String description = info.loadDescription(getPackageManager());
|
||||
extras.putString(AccessibilitySettings.EXTRA_SUMMARY, description);
|
||||
|
||||
extras.putInt(AccessibilitySettings.EXTRA_ANIMATED_IMAGE_RES, info.getAnimatedImageRes());
|
||||
|
||||
@@ -48,16 +48,15 @@ public abstract class BiometricsSettingsBase extends DashboardFragment {
|
||||
private static final int CHOOSE_LOCK_REQUEST = 2002;
|
||||
|
||||
private static final String SAVE_STATE_CONFIRM_CREDETIAL = "confirm_credential";
|
||||
private static final String DO_NOT_FINISH_ACTIVITY = "do_not_finish_activity";
|
||||
|
||||
protected int mUserId;
|
||||
protected long mFaceChallenge;
|
||||
protected long mFingerprintChallenge;
|
||||
protected int mFaceSensorId;
|
||||
protected int mFingerprintSensorId;
|
||||
protected long mGkPwHandle;
|
||||
private boolean mConfirmCredential;
|
||||
@Nullable private FaceManager mFaceManager;
|
||||
@Nullable private FingerprintManager mFingerprintManager;
|
||||
// Do not finish() if choosing/confirming credential, or showing fp/face settings
|
||||
private boolean mDoNotFinishActivity;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
@@ -78,6 +77,7 @@ public abstract class BiometricsSettingsBase extends DashboardFragment {
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
mConfirmCredential = savedInstanceState.getBoolean(SAVE_STATE_CONFIRM_CREDETIAL);
|
||||
mDoNotFinishActivity = savedInstanceState.getBoolean(DO_NOT_FINISH_ACTIVITY);
|
||||
if (savedInstanceState.containsKey(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_REQUEST_GK_PW_HANDLE)) {
|
||||
mGkPwHandle = savedInstanceState.getLong(
|
||||
@@ -92,31 +92,47 @@ public abstract class BiometricsSettingsBase extends DashboardFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (getActivity().isFinishing()) {
|
||||
mFaceManager.revokeChallenge(mFaceSensorId, mUserId, mFaceChallenge);
|
||||
mFingerprintManager.revokeChallenge(mUserId, mFingerprintChallenge);
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (!mConfirmCredential) {
|
||||
mDoNotFinishActivity = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
if (!getActivity().isChangingConfigurations() && !mDoNotFinishActivity) {
|
||||
BiometricUtils.removeGatekeeperPasswordHandle(getActivity(), mGkPwHandle);
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(Preference preference) {
|
||||
final String key = preference.getKey();
|
||||
|
||||
// Generate challenge (and request LSS to create a HAT) each time the preference is clicked,
|
||||
// since FingerprintSettings and FaceSettings revoke the challenge when finishing.
|
||||
if (getFacePreferenceKey().equals(key)) {
|
||||
final byte[] token = BiometricUtils.requestGatekeeperHat(getActivity(), mGkPwHandle,
|
||||
mUserId, mFaceChallenge);
|
||||
final Bundle extras = preference.getExtras();
|
||||
extras.putByteArray(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
|
||||
extras.putInt(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, mFaceSensorId);
|
||||
extras.putLong(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, mFaceChallenge);
|
||||
mDoNotFinishActivity = true;
|
||||
mFaceManager.generateChallenge((sensorId, challenge) -> {
|
||||
final byte[] token = BiometricUtils.requestGatekeeperHat(getActivity(), mGkPwHandle,
|
||||
mUserId, challenge);
|
||||
final Bundle extras = preference.getExtras();
|
||||
extras.putByteArray(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
|
||||
extras.putInt(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, sensorId);
|
||||
extras.putLong(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, challenge);
|
||||
});
|
||||
} else if (getFingerprintPreferenceKey().equals(key)) {
|
||||
final byte[] token = BiometricUtils.requestGatekeeperHat(getActivity(), mGkPwHandle,
|
||||
mUserId, mFingerprintChallenge);
|
||||
final Bundle extras = preference.getExtras();
|
||||
extras.putByteArray(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
|
||||
extras.putLong(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, mFingerprintChallenge);
|
||||
mDoNotFinishActivity = true;
|
||||
mFingerprintManager.generateChallenge(mUserId, (sensorId, challenge) -> {
|
||||
final byte[] token = BiometricUtils.requestGatekeeperHat(getActivity(), mGkPwHandle,
|
||||
mUserId, challenge);
|
||||
final Bundle extras = preference.getExtras();
|
||||
extras.putByteArray(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
|
||||
extras.putLong(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, challenge);
|
||||
});
|
||||
}
|
||||
return super.onPreferenceTreeClick(preference);
|
||||
}
|
||||
@@ -125,6 +141,7 @@ public abstract class BiometricsSettingsBase extends DashboardFragment {
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(SAVE_STATE_CONFIRM_CREDETIAL, mConfirmCredential);
|
||||
outState.putBoolean(DO_NOT_FINISH_ACTIVITY, mDoNotFinishActivity);
|
||||
if (mGkPwHandle != 0L) {
|
||||
outState.putLong(ChooseLockSettingsHelper.EXTRA_KEY_REQUEST_GK_PW_HANDLE, mGkPwHandle);
|
||||
}
|
||||
@@ -135,17 +152,10 @@ public abstract class BiometricsSettingsBase extends DashboardFragment {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == CONFIRM_REQUEST || requestCode == CHOOSE_LOCK_REQUEST) {
|
||||
mConfirmCredential = false;
|
||||
mDoNotFinishActivity = false;
|
||||
if (resultCode == RESULT_FINISHED || resultCode == RESULT_OK) {
|
||||
if (data != null && BiometricUtils.containsGatekeeperPasswordHandle(data)) {
|
||||
if (BiometricUtils.containsGatekeeperPasswordHandle(data)) {
|
||||
mGkPwHandle = BiometricUtils.getGatekeeperPasswordHandle(data);
|
||||
mFaceManager.generateChallenge((sensorId, challenge) -> {
|
||||
mFaceSensorId = sensorId;
|
||||
mFaceChallenge = challenge;
|
||||
});
|
||||
mFingerprintManager.generateChallenge(mUserId, (sensorId, challenge) -> {
|
||||
mFingerprintSensorId = sensorId;
|
||||
mFingerprintChallenge = challenge;
|
||||
});
|
||||
} else {
|
||||
Log.d(getLogTag(), "Data null or GK PW missing.");
|
||||
finish();
|
||||
@@ -178,6 +188,7 @@ public abstract class BiometricsSettingsBase extends DashboardFragment {
|
||||
if (mUserId != UserHandle.USER_NULL) {
|
||||
builder.setUserId(mUserId);
|
||||
}
|
||||
mDoNotFinishActivity = true;
|
||||
final boolean launched = builder.show();
|
||||
|
||||
if (!launched) {
|
||||
|
||||
@@ -37,26 +37,18 @@ public class AdaptiveSleepPermissionPreferenceController {
|
||||
@VisibleForTesting
|
||||
BannerMessagePreference mPreference;
|
||||
private final PackageManager mPackageManager;
|
||||
private final Context mContext;
|
||||
|
||||
public AdaptiveSleepPermissionPreferenceController(Context context) {
|
||||
final String packageName = context.getPackageManager().getAttentionServicePackageName();
|
||||
mPackageManager = context.getPackageManager();
|
||||
final Intent intent = new Intent(
|
||||
android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
intent.setData(Uri.parse("package:" + packageName));
|
||||
mPreference = new BannerMessagePreference(context);
|
||||
mPreference.setTitle(R.string.adaptive_sleep_title_no_permission);
|
||||
mPreference.setSummary(R.string.adaptive_sleep_summary_no_permission);
|
||||
mPreference.setPositiveButtonText(R.string.adaptive_sleep_manage_permission_button);
|
||||
mPreference.setPositiveButtonOnClickListener(p -> {
|
||||
context.startActivity(intent);
|
||||
});
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the controlled preference to the provided preference screen.
|
||||
*/
|
||||
public void addToScreen(PreferenceScreen screen) {
|
||||
initializePreference();
|
||||
if (!hasSufficientPermission(mPackageManager)) {
|
||||
screen.addPreference(mPreference);
|
||||
}
|
||||
@@ -68,4 +60,19 @@ public class AdaptiveSleepPermissionPreferenceController {
|
||||
public void updateVisibility() {
|
||||
mPreference.setVisible(!hasSufficientPermission(mPackageManager));
|
||||
}
|
||||
|
||||
private void initializePreference() {
|
||||
final String packageName = mContext.getPackageManager().getAttentionServicePackageName();
|
||||
final Intent intent = new Intent(
|
||||
android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
intent.setData(Uri.parse("package:" + packageName));
|
||||
mPreference = new BannerMessagePreference(mContext);
|
||||
mPreference.setTitle(R.string.adaptive_sleep_title_no_permission);
|
||||
mPreference.setSummary(R.string.adaptive_sleep_summary_no_permission);
|
||||
mPreference.setPositiveButtonText(R.string.adaptive_sleep_manage_permission_button);
|
||||
mPreference.setPositiveButtonOnClickListener(p -> {
|
||||
mContext.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,10 +49,10 @@ public class AdaptiveSleepPreferenceController {
|
||||
public static final String PREFERENCE_KEY = "adaptive_sleep";
|
||||
private static final int DEFAULT_VALUE = 0;
|
||||
private final SensorPrivacyManager mPrivacyManager;
|
||||
private RestrictionUtils mRestrictionUtils;
|
||||
private PackageManager mPackageManager;
|
||||
private Context mContext;
|
||||
private MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
private final RestrictionUtils mRestrictionUtils;
|
||||
private final PackageManager mPackageManager;
|
||||
private final Context mContext;
|
||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
|
||||
@VisibleForTesting
|
||||
RestrictedSwitchPreference mPreference;
|
||||
@@ -62,19 +62,6 @@ public class AdaptiveSleepPreferenceController {
|
||||
mRestrictionUtils = restrictionUtils;
|
||||
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
|
||||
mPrivacyManager = SensorPrivacyManager.getInstance(context);
|
||||
mPreference = new RestrictedSwitchPreference(context);
|
||||
mPreference.setTitle(R.string.adaptive_sleep_title);
|
||||
mPreference.setSummary(R.string.adaptive_sleep_description);
|
||||
mPreference.setChecked(isChecked());
|
||||
mPreference.setKey(PREFERENCE_KEY);
|
||||
mPreference.setOnPreferenceClickListener(preference -> {
|
||||
final boolean isChecked = ((RestrictedSwitchPreference) preference).isChecked();
|
||||
mMetricsFeatureProvider.action(context, SettingsEnums.ACTION_SCREEN_ATTENTION_CHANGED,
|
||||
isChecked);
|
||||
Settings.Secure.putInt(context.getContentResolver(),
|
||||
Settings.Secure.ADAPTIVE_SLEEP, isChecked ? 1 : DEFAULT_VALUE);
|
||||
return true;
|
||||
});
|
||||
mPackageManager = context.getPackageManager();
|
||||
}
|
||||
|
||||
@@ -86,6 +73,7 @@ public class AdaptiveSleepPreferenceController {
|
||||
* Adds the controlled preference to the provided preference screen.
|
||||
*/
|
||||
public void addToScreen(PreferenceScreen screen) {
|
||||
initializePreference();
|
||||
updatePreference();
|
||||
screen.addPreference(mPreference);
|
||||
}
|
||||
@@ -103,6 +91,23 @@ public class AdaptiveSleepPreferenceController {
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void initializePreference() {
|
||||
mPreference = new RestrictedSwitchPreference(mContext);
|
||||
mPreference.setTitle(R.string.adaptive_sleep_title);
|
||||
mPreference.setSummary(R.string.adaptive_sleep_description);
|
||||
mPreference.setChecked(isChecked());
|
||||
mPreference.setKey(PREFERENCE_KEY);
|
||||
mPreference.setOnPreferenceChangeListener((preference, value) -> {
|
||||
final boolean isChecked = (Boolean) value;
|
||||
mMetricsFeatureProvider.action(mContext, SettingsEnums.ACTION_SCREEN_ATTENTION_CHANGED,
|
||||
isChecked);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.ADAPTIVE_SLEEP, isChecked ? 1 : DEFAULT_VALUE);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean isChecked() {
|
||||
return hasSufficientPermission(mContext.getPackageManager()) && !isCameraLocked()
|
||||
|
||||
@@ -71,11 +71,15 @@ public class ScreenTimeoutSettings extends RadioButtonPickerFragment implements
|
||||
private CharSequence[] mInitialEntries;
|
||||
private CharSequence[] mInitialValues;
|
||||
private FooterPreference mPrivacyPreference;
|
||||
private MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
private SensorPrivacyManager mPrivacyManager;
|
||||
|
||||
@VisibleForTesting
|
||||
Context mContext;
|
||||
|
||||
@VisibleForTesting
|
||||
RestrictedLockUtils.EnforcedAdmin mAdmin;
|
||||
|
||||
@VisibleForTesting
|
||||
Preference mDisableOptionsPreference;
|
||||
|
||||
@@ -97,6 +101,7 @@ public class ScreenTimeoutSettings extends RadioButtonPickerFragment implements
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
mContext = context;
|
||||
mInitialEntries = getResources().getStringArray(R.array.screen_timeout_entries);
|
||||
mInitialValues = getResources().getStringArray(R.array.screen_timeout_values);
|
||||
mAdaptiveSleepController = new AdaptiveSleepPreferenceController(context);
|
||||
@@ -104,11 +109,6 @@ public class ScreenTimeoutSettings extends RadioButtonPickerFragment implements
|
||||
context);
|
||||
mAdaptiveSleepCameraStatePreferenceController =
|
||||
new AdaptiveSleepCameraStatePreferenceController(context);
|
||||
mPrivacyPreference = new FooterPreference(context);
|
||||
mPrivacyPreference.setIcon(R.drawable.ic_privacy_shield_24dp);
|
||||
mPrivacyPreference.setTitle(R.string.adaptive_sleep_privacy);
|
||||
mPrivacyPreference.setSelectable(false);
|
||||
mPrivacyPreference.setLayoutResource(R.layout.preference_footer);
|
||||
mPrivacyManager = SensorPrivacyManager.getInstance(context);
|
||||
mPrivacyManager.addSensorPrivacyListener(CAMERA,
|
||||
(sensor, enabled) -> mAdaptiveSleepController.updatePreference());
|
||||
@@ -167,6 +167,12 @@ public class ScreenTimeoutSettings extends RadioButtonPickerFragment implements
|
||||
preferenceWithLargestTimeout.setChecked(true);
|
||||
}
|
||||
|
||||
mPrivacyPreference = new FooterPreference(mContext);
|
||||
mPrivacyPreference.setIcon(R.drawable.ic_privacy_shield_24dp);
|
||||
mPrivacyPreference.setTitle(R.string.adaptive_sleep_privacy);
|
||||
mPrivacyPreference.setSelectable(false);
|
||||
mPrivacyPreference.setLayoutResource(R.layout.preference_footer);
|
||||
|
||||
if (isScreenAttentionAvailable(getContext())) {
|
||||
mAdaptiveSleepPermissionController.addToScreen(screen);
|
||||
mAdaptiveSleepCameraStatePreferenceController.addToScreen(screen);
|
||||
|
||||
@@ -70,6 +70,7 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
public static final String EXTRA_PACKAGE_NAME = "extra_package_name";
|
||||
public static final String EXTRA_FOREGROUND_TIME = "extra_foreground_time";
|
||||
public static final String EXTRA_BACKGROUND_TIME = "extra_background_time";
|
||||
public static final String EXTRA_SLOT_TIME = "extra_slot_time";
|
||||
public static final String EXTRA_LABEL = "extra_label";
|
||||
public static final String EXTRA_ICON_ID = "extra_icon_id";
|
||||
public static final String EXTRA_POWER_USAGE_PERCENT = "extra_power_usage_percent";
|
||||
@@ -184,6 +185,7 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
args.putInt(EXTRA_UID, launchArgs.mUid);
|
||||
args.putLong(EXTRA_BACKGROUND_TIME, launchArgs.mBackgroundTimeMs);
|
||||
args.putLong(EXTRA_FOREGROUND_TIME, launchArgs.mForegroundTimeMs);
|
||||
args.putString(EXTRA_SLOT_TIME, launchArgs.mSlotInformation);
|
||||
args.putString(EXTRA_POWER_USAGE_PERCENT, launchArgs.mUsagePercent);
|
||||
args.putInt(EXTRA_POWER_USAGE_AMOUNT, launchArgs.mConsumedPower);
|
||||
final int userId = launchArgs.mIsUserEntry ? ActivityManager.getCurrentUser()
|
||||
@@ -294,8 +296,9 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
if (enableTriState) {
|
||||
final long foregroundTimeMs = bundle.getLong(EXTRA_FOREGROUND_TIME);
|
||||
final long backgroundTimeMs = bundle.getLong(EXTRA_BACKGROUND_TIME);
|
||||
final String slotTime = bundle.getString(EXTRA_SLOT_TIME, null);
|
||||
//TODO(b/178197718) Update layout to support multiple lines
|
||||
controller.setSummary(getAppActiveTime(foregroundTimeMs, backgroundTimeMs));
|
||||
controller.setSummary(getAppActiveTime(foregroundTimeMs, backgroundTimeMs, slotTime));
|
||||
}
|
||||
|
||||
controller.done(context, true /* rebindActions */);
|
||||
@@ -430,32 +433,46 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
getContext(), getArguments().getInt(EXTRA_UID), packageName);
|
||||
}
|
||||
|
||||
//TODO(b/178197718) Update method to support time period
|
||||
private CharSequence getAppActiveTime(long foregroundTimeMs, long backgroundTimeMs) {
|
||||
private CharSequence getAppActiveTime(
|
||||
long foregroundTimeMs, long backgroundTimeMs, String slotTime) {
|
||||
final long totalTimeMs = foregroundTimeMs + backgroundTimeMs;
|
||||
final CharSequence usageTimeSummary;
|
||||
|
||||
if (totalTimeMs == 0) {
|
||||
usageTimeSummary = getText(R.string.battery_not_usage);
|
||||
} else if (slotTime == null) {
|
||||
// Shows summary text with past 24 hr if slot time is null.
|
||||
usageTimeSummary =
|
||||
getAppPast24HrActiveSummary(foregroundTimeMs, backgroundTimeMs, totalTimeMs);
|
||||
} else {
|
||||
// Shows summary text with slot time.
|
||||
usageTimeSummary = getAppActiveSummaryWithSlotTime(
|
||||
foregroundTimeMs, backgroundTimeMs, totalTimeMs, slotTime);
|
||||
}
|
||||
return usageTimeSummary;
|
||||
}
|
||||
|
||||
private CharSequence getAppPast24HrActiveSummary(
|
||||
long foregroundTimeMs, long backgroundTimeMs, long totalTimeMs) {
|
||||
// Shows background summary only if we don't have foreground usage time.
|
||||
} else if (foregroundTimeMs == 0 && backgroundTimeMs != 0) {
|
||||
usageTimeSummary = backgroundTimeMs < DateUtils.MINUTE_IN_MILLIS ?
|
||||
getText(R.string.battery_background_usage_less_minute) :
|
||||
TextUtils.expandTemplate(getText(R.string.battery_background_usage),
|
||||
StringUtil.formatElapsedTime(
|
||||
getContext(),
|
||||
backgroundTimeMs,
|
||||
/* withSeconds */ false,
|
||||
/* collapseTimeUnit */ false));
|
||||
if (foregroundTimeMs == 0 && backgroundTimeMs != 0) {
|
||||
return backgroundTimeMs < DateUtils.MINUTE_IN_MILLIS ?
|
||||
getText(R.string.battery_bg_usage_less_minute) :
|
||||
TextUtils.expandTemplate(getText(R.string.battery_bg_usage),
|
||||
StringUtil.formatElapsedTime(
|
||||
getContext(),
|
||||
backgroundTimeMs,
|
||||
/* withSeconds */ false,
|
||||
/* collapseTimeUnit */ false));
|
||||
// Shows total usage summary only if total usage time is small.
|
||||
} else if (totalTimeMs < DateUtils.MINUTE_IN_MILLIS) {
|
||||
usageTimeSummary = getText(R.string.battery_total_usage_less_minute);
|
||||
return getText(R.string.battery_total_usage_less_minute);
|
||||
// Shows different total usage summary when background usage time is small.
|
||||
} else if (backgroundTimeMs < DateUtils.MINUTE_IN_MILLIS) {
|
||||
usageTimeSummary = TextUtils.expandTemplate(
|
||||
return TextUtils.expandTemplate(
|
||||
getText(backgroundTimeMs == 0 ?
|
||||
R.string.battery_total_usage :
|
||||
R.string.battery_total_usage_and_background_less_minute_usage),
|
||||
R.string.battery_total_usage_and_bg_less_minute_usage),
|
||||
StringUtil.formatElapsedTime(
|
||||
getContext(),
|
||||
totalTimeMs,
|
||||
@@ -463,8 +480,8 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
/* collapseTimeUnit */ false));
|
||||
// Shows default summary.
|
||||
} else {
|
||||
usageTimeSummary = TextUtils.expandTemplate(
|
||||
getText(R.string.battery_total_and_background_usage),
|
||||
return TextUtils.expandTemplate(
|
||||
getText(R.string.battery_total_and_bg_usage),
|
||||
StringUtil.formatElapsedTime(
|
||||
getContext(),
|
||||
totalTimeMs,
|
||||
@@ -476,6 +493,51 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
/* withSeconds */ false,
|
||||
/* collapseTimeUnit */ false));
|
||||
}
|
||||
return usageTimeSummary;
|
||||
}
|
||||
|
||||
private CharSequence getAppActiveSummaryWithSlotTime(
|
||||
long foregroundTimeMs, long backgroundTimeMs, long totalTimeMs, String slotTime) {
|
||||
// Shows background summary only if we don't have foreground usage time.
|
||||
if (foregroundTimeMs == 0 && backgroundTimeMs != 0) {
|
||||
return backgroundTimeMs < DateUtils.MINUTE_IN_MILLIS ?
|
||||
TextUtils.expandTemplate(
|
||||
getText(R.string.battery_bg_usage_less_minute_with_period),
|
||||
slotTime) :
|
||||
TextUtils.expandTemplate(getText(R.string.battery_bg_usage_with_period),
|
||||
StringUtil.formatElapsedTime(
|
||||
getContext(),
|
||||
backgroundTimeMs,
|
||||
/* withSeconds */ false,
|
||||
/* collapseTimeUnit */ false), slotTime);
|
||||
// Shows total usage summary only if total usage time is small.
|
||||
} else if (totalTimeMs < DateUtils.MINUTE_IN_MILLIS) {
|
||||
return TextUtils.expandTemplate(
|
||||
getText(R.string.battery_total_usage_less_minute_with_period), slotTime);
|
||||
// Shows different total usage summary when background usage time is small.
|
||||
} else if (backgroundTimeMs < DateUtils.MINUTE_IN_MILLIS) {
|
||||
return TextUtils.expandTemplate(
|
||||
getText(backgroundTimeMs == 0 ?
|
||||
R.string.battery_total_usage_with_period :
|
||||
R.string.battery_total_usage_and_bg_less_minute_usage_with_period),
|
||||
StringUtil.formatElapsedTime(
|
||||
getContext(),
|
||||
totalTimeMs,
|
||||
/* withSeconds */ false,
|
||||
/* collapseTimeUnit */ false), slotTime);
|
||||
// Shows default summary.
|
||||
} else {
|
||||
return TextUtils.expandTemplate(
|
||||
getText(R.string.battery_total_and_bg_usage_with_period),
|
||||
StringUtil.formatElapsedTime(
|
||||
getContext(),
|
||||
totalTimeMs,
|
||||
/* withSeconds */ false,
|
||||
/* collapseTimeUnit */ false),
|
||||
StringUtil.formatElapsedTime(
|
||||
getContext(),
|
||||
backgroundTimeMs,
|
||||
/* withSeconds */ false,
|
||||
/* collapseTimeUnit */ false), slotTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -632,7 +632,7 @@ public class ApnEditor extends SettingsPreferenceFragment
|
||||
checkNull(bearerMultiDescription(mBearerMulti.getValues())));
|
||||
mMvnoType.setSummary(
|
||||
checkNull(mvnoDescription(mMvnoType.getValue())));
|
||||
mMvnoMatchData.setSummary(checkNull(mMvnoMatchData.getText()));
|
||||
mMvnoMatchData.setSummary(checkNullforMvnoValue(mMvnoMatchData.getText()));
|
||||
// allow user to edit carrier_enabled for some APN
|
||||
final boolean ceEditable = getResources().getBoolean(
|
||||
R.bool.config_allow_edit_carrier_enabled);
|
||||
@@ -791,7 +791,7 @@ public class ApnEditor extends SettingsPreferenceFragment
|
||||
}
|
||||
mMvnoType.setValue((String) newValue);
|
||||
mMvnoType.setSummary(mvno);
|
||||
mMvnoMatchData.setSummary(checkNull(mMvnoMatchData.getText()));
|
||||
mMvnoMatchData.setSummary(checkNullforMvnoValue(mMvnoMatchData.getText()));
|
||||
} else if (KEY_PASSWORD.equals(key)) {
|
||||
mPassword.setSummary(starify(newValue != null ? String.valueOf(newValue) : ""));
|
||||
} else if (KEY_CARRIER_ENABLED.equals(key)) {
|
||||
@@ -1216,6 +1216,14 @@ public class ApnEditor extends SettingsPreferenceFragment
|
||||
return TextUtils.isEmpty(value) ? sNotSet : value;
|
||||
}
|
||||
|
||||
/**
|
||||
* To make traslation be diversity, use another string id for MVNO value.
|
||||
*/
|
||||
private String checkNullforMvnoValue(String value) {
|
||||
String notSetForMvnoValue = getResources().getString(R.string.apn_not_set_for_mvno);
|
||||
return TextUtils.isEmpty(value) ? notSetForMvnoValue : value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns null if the given string {@code value} equals to {@link #sNotSet}. This method
|
||||
* should be used when convert a string value from preference to database.
|
||||
|
||||
@@ -156,7 +156,7 @@ public class BackupCallingPreferenceController extends TelephonyTogglePreference
|
||||
}
|
||||
// TODO: remove log after fixing b/182326102
|
||||
Log.d(LOG_TAG, "config " + CarrierConfigManager.KEY_CARRIER_CROSS_SIM_IMS_AVAILABLE_BOOL
|
||||
+ "=" + featureEnableStatus + " for subId=" + mSubId);
|
||||
+ "=" + featureEnableStatus + " for subId=" + subscriptionId);
|
||||
return (featureEnableStatus != null) && featureEnableStatus.booleanValue();
|
||||
}
|
||||
|
||||
|
||||
@@ -359,21 +359,22 @@ public final class ChooseLockSettingsHelper {
|
||||
requestGatekeeperPasswordHandle);
|
||||
|
||||
intent.setClassName(SETTINGS_PACKAGE_NAME, activityClass.getName());
|
||||
|
||||
Intent inIntent = mFragment != null ? mFragment.getActivity().getIntent() :
|
||||
mActivity.getIntent();
|
||||
copyInternalExtras(inIntent, intent);
|
||||
if (external) {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
||||
copyOptionalExtras(inIntent, intent);
|
||||
if (mFragment != null) {
|
||||
copyOptionalExtras(mFragment.getActivity().getIntent(), intent);
|
||||
mFragment.startActivity(intent);
|
||||
} else {
|
||||
copyOptionalExtras(mActivity.getIntent(), intent);
|
||||
mActivity.startActivity(intent);
|
||||
}
|
||||
} else {
|
||||
if (mFragment != null) {
|
||||
copyInternalExtras(mFragment.getActivity().getIntent(), intent);
|
||||
mFragment.startActivityForResult(intent, request);
|
||||
} else {
|
||||
copyInternalExtras(mActivity.getIntent(), intent);
|
||||
mActivity.startActivityForResult(intent, request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.SetupWizardUtils;
|
||||
import com.android.settings.Utils;
|
||||
|
||||
import com.google.android.setupdesign.util.ThemeHelper;
|
||||
|
||||
public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivity {
|
||||
|
||||
private static final String STATE_IS_KEYGUARD_LOCKED = "STATE_IS_KEYGUARD_LOCKED";
|
||||
@@ -74,6 +76,7 @@ public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivi
|
||||
setTheme(SetupWizardUtils.getTheme(this, getIntent()));
|
||||
mConfirmCredentialTheme = ConfirmCredentialTheme.NORMAL;
|
||||
}
|
||||
ThemeHelper.trySetDynamicColor(this);
|
||||
super.onCreate(savedState);
|
||||
|
||||
if (mConfirmCredentialTheme == ConfirmCredentialTheme.NORMAL) {
|
||||
|
||||
@@ -35,6 +35,6 @@ public final class PrivacyHubPreferenceController extends BasePreferenceControll
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
|
||||
PROPERTY_PRIVACY_HUB_ENABLED, false) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
PROPERTY_PRIVACY_HUB_ENABLED, true) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ public class AdaptiveSleepPreferenceControllerTest {
|
||||
eq(UserManager.DISALLOW_CONFIG_SCREEN_TIMEOUT))).thenReturn(null);
|
||||
|
||||
mController = new AdaptiveSleepPreferenceController(mContext, mRestrictionUtils);
|
||||
mController.initializePreference();
|
||||
when(mController.isCameraLocked()).thenReturn(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,8 +60,6 @@ public class ScreenTimeoutSettingsTest {
|
||||
private ScreenTimeoutSettings mSettings;
|
||||
private Context mContext;
|
||||
private ContentResolver mContentResolver;
|
||||
|
||||
@Mock
|
||||
private Resources mResources;
|
||||
|
||||
@Mock
|
||||
@@ -85,7 +83,9 @@ public class ScreenTimeoutSettingsTest {
|
||||
FakeFeatureFactory.setupForTest();
|
||||
mContext = spy(getApplicationContext());
|
||||
mSettings = spy(new ScreenTimeoutSettings());
|
||||
mSettings.mContext = mContext;
|
||||
mContentResolver = mContext.getContentResolver();
|
||||
mResources = spy(mContext.getResources());
|
||||
|
||||
doReturn(TIMEOUT_ENTRIES).when(mResources).getStringArray(R.array.screen_timeout_entries);
|
||||
doReturn(TIMEOUT_VALUES).when(mResources).getStringArray(R.array.screen_timeout_entries);
|
||||
|
||||
@@ -81,6 +81,7 @@ public class AdvancedPowerUsageDetailTest {
|
||||
private static final String SUMMARY = "summary";
|
||||
private static final String[] PACKAGE_NAME = {"com.android.app"};
|
||||
private static final String USAGE_PERCENT = "16%";
|
||||
private static final String SLOT_TIME = "12 am-2 am";
|
||||
private static final int ICON_ID = 123;
|
||||
private static final int UID = 1;
|
||||
private static final int POWER_MAH = 150;
|
||||
@@ -284,7 +285,7 @@ public class AdvancedPowerUsageDetailTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitHeader_backgroundTwoMinutesForegroundZero_hasCorrectSummary() {
|
||||
public void testInitHeader_backgroundTwoMinForegroundZero_hasCorrectSummary() {
|
||||
final long backgroundTimeTwoMinutes = 120000;
|
||||
final long foregroundTimeZero = 0;
|
||||
Bundle bundle = new Bundle(2);
|
||||
@@ -301,7 +302,7 @@ public class AdvancedPowerUsageDetailTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitHeader_backgroundLessThanAMinutesForegroundZero_hasCorrectSummary() {
|
||||
public void testInitHeader_backgroundLessThanAMinForegroundZero_hasCorrectSummary() {
|
||||
final long backgroundTimeLessThanAMinute = 59999;
|
||||
final long foregroundTimeZero = 0;
|
||||
Bundle bundle = new Bundle(2);
|
||||
@@ -319,7 +320,7 @@ public class AdvancedPowerUsageDetailTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitHeader_totalUsageLessThanAMinutes_hasCorrectSummary() {
|
||||
public void testInitHeader_totalUsageLessThanAMin_hasCorrectSummary() {
|
||||
final long backgroundTimeLessThanHalfMinute = 20000;
|
||||
final long foregroundTimeLessThanHalfMinute = 20000;
|
||||
Bundle bundle = new Bundle(2);
|
||||
@@ -338,7 +339,7 @@ public class AdvancedPowerUsageDetailTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitHeader_TotalAMinutesBackgroundLessThanAMinutes_hasCorrectSummary() {
|
||||
public void testInitHeader_TotalAMinutesBackgroundLessThanAMin_hasCorrectSummary() {
|
||||
final long backgroundTimeZero = 59999;
|
||||
final long foregroundTimeTwoMinutes = 1;
|
||||
Bundle bundle = new Bundle(2);
|
||||
@@ -355,7 +356,7 @@ public class AdvancedPowerUsageDetailTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitHeader_TotalAMinutesBackgroundZero_hasCorrectSummary() {
|
||||
public void testInitHeader_TotalAMinBackgroundZero_hasCorrectSummary() {
|
||||
final long backgroundTimeZero = 0;
|
||||
final long foregroundTimeAMinutes = 60000;
|
||||
Bundle bundle = new Bundle(2);
|
||||
@@ -372,7 +373,7 @@ public class AdvancedPowerUsageDetailTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitHeader_foregroundTwoMinutesBackgroundFourMinutes_hasCorrectSummary() {
|
||||
public void testInitHeader_foregroundTwoMinBackgroundFourMin_hasCorrectSummary() {
|
||||
final long backgroundTimeFourMinute = 240000;
|
||||
final long foregroundTimeTwoMinutes = 120000;
|
||||
Bundle bundle = new Bundle(2);
|
||||
@@ -387,6 +388,79 @@ public class AdvancedPowerUsageDetailTest {
|
||||
.isEqualTo("6 min total • 4 min background for past 24 hr");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitHeader_totalUsageLessThanAMinWithSlotTime_hasCorrectSummary() {
|
||||
final long backgroundTimeLessThanHalfMinute = 20000;
|
||||
final long foregroundTimeLessThanHalfMinute = 20000;
|
||||
Bundle bundle = new Bundle(2);
|
||||
bundle.putLong(
|
||||
AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeLessThanHalfMinute);
|
||||
bundle.putLong(
|
||||
AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeLessThanHalfMinute);
|
||||
bundle.putString(AdvancedPowerUsageDetail.EXTRA_SLOT_TIME, SLOT_TIME);
|
||||
when(mFragment.getArguments()).thenReturn(bundle);
|
||||
|
||||
mFragment.initHeader();
|
||||
|
||||
ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
|
||||
verify(mEntityHeaderController).setSummary(captor.capture());
|
||||
assertThat(captor.getValue().toString())
|
||||
.isEqualTo("Total less than a minute for 12 am-2 am");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitHeader_TotalAMinBackgroundLessThanAMinWithSlotTime_hasCorrectSummary() {
|
||||
final long backgroundTimeZero = 59999;
|
||||
final long foregroundTimeTwoMinutes = 1;
|
||||
Bundle bundle = new Bundle(2);
|
||||
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeZero);
|
||||
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeTwoMinutes);
|
||||
bundle.putString(AdvancedPowerUsageDetail.EXTRA_SLOT_TIME, SLOT_TIME);
|
||||
when(mFragment.getArguments()).thenReturn(bundle);
|
||||
|
||||
mFragment.initHeader();
|
||||
|
||||
ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
|
||||
verify(mEntityHeaderController).setSummary(captor.capture());
|
||||
assertThat(captor.getValue().toString())
|
||||
.isEqualTo("1 min total • background less than a minute for 12 am-2 am");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitHeader_TotalAMinBackgroundZeroWithSlotTime_hasCorrectSummary() {
|
||||
final long backgroundTimeZero = 0;
|
||||
final long foregroundTimeAMinutes = 60000;
|
||||
Bundle bundle = new Bundle(2);
|
||||
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeZero);
|
||||
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeAMinutes);
|
||||
bundle.putString(AdvancedPowerUsageDetail.EXTRA_SLOT_TIME, SLOT_TIME);
|
||||
when(mFragment.getArguments()).thenReturn(bundle);
|
||||
|
||||
mFragment.initHeader();
|
||||
|
||||
ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
|
||||
verify(mEntityHeaderController).setSummary(captor.capture());
|
||||
assertThat(captor.getValue().toString())
|
||||
.isEqualTo("1 min total for 12 am-2 am");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitHeader_foregroundTwoMinBackgroundFourMinWithSlotTime_hasCorrectSummary() {
|
||||
final long backgroundTimeFourMinute = 240000;
|
||||
final long foregroundTimeTwoMinutes = 120000;
|
||||
Bundle bundle = new Bundle(2);
|
||||
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeFourMinute);
|
||||
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeTwoMinutes);
|
||||
bundle.putString(AdvancedPowerUsageDetail.EXTRA_SLOT_TIME, SLOT_TIME);
|
||||
when(mFragment.getArguments()).thenReturn(bundle);
|
||||
mFragment.initHeader();
|
||||
|
||||
ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
|
||||
verify(mEntityHeaderController).setSummary(captor.capture());
|
||||
assertThat(captor.getValue().toString())
|
||||
.isEqualTo("6 min total • 4 min background for 12 am-2 am");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartBatteryDetailPage_hasBasicData() {
|
||||
AdvancedPowerUsageDetail.startBatteryDetailPage(mActivity, mFragment,
|
||||
|
||||
Reference in New Issue
Block a user