Snap for 7202128 from 0936026260 to sc-v2-release

Change-Id: If15e4834d599db800f2e4379376c52e6b1eeb5c9
This commit is contained in:
android-build-team Robot
2021-03-12 02:08:04 +00:00
31 changed files with 271 additions and 395 deletions

View File

@@ -3751,6 +3751,25 @@
android:launchMode="singleTask"> android:launchMode="singleTask">
</activity> </activity>
<activity android:name="Settings$FactoryResetActivity"
android:permission="android.permission.BACKUP"
android:label="@string/main_clear_title"
android:exported="true"
android:theme="@style/SudThemeGlif.Light">
<intent-filter>
<action android:name="com.android.settings.action.FACTORY_RESET"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.MainClear"/>
</activity>
<activity android:name="Settings$FactoryResetConfirmActivity"
android:label="@string/main_clear_confirm_title"
android:exported="false"
android:theme="@style/SudThemeGlif.Light">
</activity>
<!-- This is the longest AndroidManifest.xml ever. --> <!-- This is the longest AndroidManifest.xml ever. -->
</application> </application>
</manifest> </manifest>

View File

@@ -0,0 +1,28 @@
<!--
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:fillColor="?android:attr/colorAccent"
android:pathData="M12,19m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0"/>
<path
android:fillColor="?android:attr/colorAccent"
android:pathData="M10,3h4v12h-4z"/>
</vector>

View File

@@ -48,7 +48,7 @@
android:id="@android:id/empty" android:id="@android:id/empty"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center" android:gravity="bottom|center_horizontal"
android:layout_gravity="center" android:layout_gravity="center"
android:text="@string/no_applications" android:text="@string/no_applications"
android:textAppearance="?android:attr/textAppearanceLarge" android:textAppearance="?android:attr/textAppearanceLarge"

View File

@@ -170,6 +170,7 @@
<declare-styleable name="LabeledSeekBarPreference"> <declare-styleable name="LabeledSeekBarPreference">
<attr name="textStart" format="reference" /> <attr name="textStart" format="reference" />
<attr name="textEnd" format="reference" /> <attr name="textEnd" format="reference" />
<attr name="tickMark" format="reference" />
</declare-styleable> </declare-styleable>
<declare-styleable name="TintDrawable"> <declare-styleable name="TintDrawable">

View File

@@ -2836,7 +2836,9 @@
<!-- adaptive_sleep settings screen, title about the required permission is missing [CHAR LIMIT=NONE]--> <!-- adaptive_sleep settings screen, title about the required permission is missing [CHAR LIMIT=NONE]-->
<string name="adaptive_sleep_title_no_permission">Camera access needed</string> <string name="adaptive_sleep_title_no_permission">Camera access needed</string>
<!-- adaptive_sleep settings screen, subtitle when permission is missing [CHAR LIMIT=NONE]--> <!-- adaptive_sleep settings screen, subtitle when permission is missing [CHAR LIMIT=NONE]-->
<string name="adaptive_sleep_summary_no_permission">Tap to manage permissions for Device Personalization Services</string> <string name="adaptive_sleep_summary_no_permission">Camera access is required for screen attention. Tap to manage permissions for Device Personalization Services</string>
<!-- adaptive_sleep settings screen, text for the camera permission button [CHAR LIMIT=NONE]-->
<string name="adaptive_sleep_manage_permission_button">Manage permissions</string>
<!-- Description about the feature adaptive sleep [CHAR LIMIT=NONE]--> <!-- Description about the feature adaptive sleep [CHAR LIMIT=NONE]-->
<string name="adaptive_sleep_description">Prevents your screen from turning off if you\u2019re looking at it</string> <string name="adaptive_sleep_description">Prevents your screen from turning off if you\u2019re looking at it</string>
<!-- Description feature's privacy sensitive details to make sure users understand what feature users, what it saves/sends etc [CHAR LIMIT=NONE]--> <!-- Description feature's privacy sensitive details to make sure users understand what feature users, what it saves/sends etc [CHAR LIMIT=NONE]-->
@@ -4059,18 +4061,8 @@
<!-- [CHAR LIMIT=50] Location settings screen, sub category for location services for managed profile --> <!-- [CHAR LIMIT=50] Location settings screen, sub category for location services for managed profile -->
<string name="managed_profile_location_services">Location services for work</string> <string name="managed_profile_location_services">Location services for work</string>
<!-- [CHAR LIMIT=60] Location settings screen, screen title --> <!-- [CHAR LIMIT=60] Date&Time settings screen, toggle button title -->
<string name="location_time_zone_detection_screen_title">Use location to set time zone</string> <string name="location_time_zone_detection_toggle_title">Use location to set time zone</string>
<!-- [CHAR LIMIT=50] Location settings screen, title for the setting that control whether the
device can use its location for time zone detection. -->
<string name="location_time_zone_detection_enabled_title">Location time zone detection</string>
<!-- [CHAR LIMIT=NONE] Preference description text for location time zone detection -->
<string name="location_time_zone_detection_enabled_description">Allows the device\u2019s location to be used to detect the current time zone. Other location settings such as Wi\u2011Fi scanning can affect the accuracy of time zone detection.</string>
<!-- [CHAR LIMIT=NONE] Location settings screen, summary when location time zone detection is on -->
<string name="location_time_zone_detection_on">On</string>
<!-- [CHAR LIMIT=NONE] Location settings screen, summary when location time zone detection is off -->
<string name="location_time_zone_detection_off">Off</string>
<!-- [CHAR LIMIT=NONE] Location settings screen, summary when location time zone detection is not <!-- [CHAR LIMIT=NONE] Location settings screen, summary when location time zone detection is not
applicable due to other settings like the "automatic time zone detection enabled" setting applicable due to other settings like the "automatic time zone detection enabled" setting
being set to "off". --> being set to "off". -->
@@ -7841,10 +7833,10 @@
<string name="keywords_display_auto_brightness">dim screen, touchscreen, battery, smart brightness, dynamic brightness, Auto brightness</string> <string name="keywords_display_auto_brightness">dim screen, touchscreen, battery, smart brightness, dynamic brightness, Auto brightness</string>
<!-- Search keywords for adaptive sleep setting [CHAR LIMIT=NONE]--> <!-- Search keywords for adaptive sleep setting [CHAR LIMIT=NONE]-->
<string name="keywords_display_adaptive_sleep">dim screen, sleep, battery, timeout, attention, display, screen, inactivity</string> <string name="keywords_display_adaptive_sleep">smart, dim screen, sleep, battery, timeout, attention, display, screen, inactivity</string>
<!-- List of synonyms for the auto rotate (rotate the virtual display when the device rotates) setting, used to match in settings search [CHAR LIMIT=NONE] --> <!-- List of synonyms for the auto rotate (rotate the virtual display when the device rotates) setting, used to match in settings search [CHAR LIMIT=NONE] -->
<string name="keywords_auto_rotate">rotate, flip, rotation, portrait, landscape, orientation, vertical, horizontal</string> <string name="keywords_auto_rotate">camera, smart, auto rotate, auto-rotate, rotate, flip, rotation, portrait, landscape, orientation, vertical, horizontal</string>
<!-- List of synonyms for the System Update (update the operating system) setting, used to match in settings search [CHAR LIMIT=NONE] --> <!-- List of synonyms for the System Update (update the operating system) setting, used to match in settings search [CHAR LIMIT=NONE] -->
<string name="keywords_system_update_settings">upgrade, android</string> <string name="keywords_system_update_settings">upgrade, android</string>

View File

@@ -53,12 +53,12 @@
settings:keywords="@string/keywords_time_zone"/> settings:keywords="@string/keywords_time_zone"/>
<!-- This preference gets removed if location-based time zone detection is not supported --> <!-- This preference gets removed if location-based time zone detection is not supported -->
<com.android.settingslib.RestrictedPreference <com.android.settingslib.RestrictedSwitchPreference
android:key="location_time_zone_detection" android:key="location_time_zone_detection"
android:title="@string/location_time_zone_detection_screen_title" android:title="@string/location_time_zone_detection_toggle_title"
settings:controller="com.android.settings.datetime.LocationTimeZoneDetectionPreferenceController" settings:controller="com.android.settings.datetime.LocationTimeZoneDetectionPreferenceController"
android:fragment="com.android.settings.datetime.locationtimezone.TimeZoneDetectionSettings" settings:userRestriction="no_config_date_time"
settings:userRestriction="no_config_date_time"/> />
<PreferenceCategory <PreferenceCategory
android:key="time_format_preference_category" android:key="time_format_preference_category"

View File

@@ -1,28 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2020 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:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/location_time_zone_detection_screen_title">
<SwitchPreference
android:title="@string/location_time_zone_detection_enabled_title"
android:summary="@string/location_time_zone_detection_enabled_description"
settings:controller="com.android.settings.datetime.locationtimezone.TimeZoneDetectionTogglePreferenceController"
android:key="location_time_zone_detection_enabled" />
</PreferenceScreen>

View File

@@ -16,6 +16,8 @@
package com.android.settings; package com.android.settings;
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
@@ -72,6 +74,8 @@ public class ActivityPicker extends AlertActivity implements
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getWindow().addPrivateFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
final Intent intent = getIntent(); final Intent intent = getIntent();
// Read base intent from extras, otherwise assume default // Read base intent from extras, otherwise assume default

View File

@@ -48,6 +48,8 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
public static final String EXTRA_KEY_LAUNCHED_CONFIRM = "launched_confirm_lock"; public static final String EXTRA_KEY_LAUNCHED_CONFIRM = "launched_confirm_lock";
public static final String EXTRA_KEY_REQUIRE_VISION = "accessibility_vision"; public static final String EXTRA_KEY_REQUIRE_VISION = "accessibility_vision";
public static final String EXTRA_KEY_REQUIRE_DIVERSITY = "accessibility_diversity"; public static final String EXTRA_KEY_REQUIRE_DIVERSITY = "accessibility_diversity";
public static final String EXTRA_KEY_SENSOR_ID = "sensor_id";
public static final String EXTRA_KEY_CHALLENGE = "challenge";
/** /**
* Used by the choose fingerprint wizard to indicate the wizard is * Used by the choose fingerprint wizard to indicate the wizard is
@@ -90,12 +92,16 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
protected boolean mLaunchedConfirmLock; protected boolean mLaunchedConfirmLock;
protected byte[] mToken; protected byte[] mToken;
protected int mUserId; protected int mUserId;
protected int mSensorId;
protected long mChallenge;
protected boolean mFromSettingsSummary; protected boolean mFromSettingsSummary;
protected FooterBarMixin mFooterBarMixin; protected FooterBarMixin mFooterBarMixin;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mChallenge = getIntent().getLongExtra(EXTRA_KEY_CHALLENGE, -1L);
mSensorId = getIntent().getIntExtra(EXTRA_KEY_SENSOR_ID, -1);
// Don't need to retrieve the HAT if it already exists. In some cases, the extras do not // Don't need to retrieve the HAT if it already exists. In some cases, the extras do not
// contain EXTRA_KEY_CHALLENGE_TOKEN but contain EXTRA_KEY_GK_PW, in which case enrollment // contain EXTRA_KEY_CHALLENGE_TOKEN but contain EXTRA_KEY_GK_PW, in which case enrollment
// classes may request a HAT to be created (as opposed to being passed in) // classes may request a HAT to be created (as opposed to being passed in)
@@ -110,6 +116,8 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN); ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
mFromSettingsSummary = mFromSettingsSummary =
savedInstanceState.getBoolean(EXTRA_FROM_SETTINGS_SUMMARY, false); savedInstanceState.getBoolean(EXTRA_FROM_SETTINGS_SUMMARY, false);
mChallenge = savedInstanceState.getLong(EXTRA_KEY_CHALLENGE);
mSensorId = savedInstanceState.getInt(EXTRA_KEY_SENSOR_ID);
} }
mUserId = getIntent().getIntExtra(Intent.EXTRA_USER_ID, UserHandle.myUserId()); mUserId = getIntent().getIntExtra(Intent.EXTRA_USER_ID, UserHandle.myUserId());
} }
@@ -127,6 +135,8 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
outState.putBoolean(EXTRA_KEY_LAUNCHED_CONFIRM, mLaunchedConfirmLock); outState.putBoolean(EXTRA_KEY_LAUNCHED_CONFIRM, mLaunchedConfirmLock);
outState.putByteArray(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken); outState.putByteArray(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
outState.putBoolean(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary); outState.putBoolean(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
outState.putLong(EXTRA_KEY_CHALLENGE, mChallenge);
outState.putInt(EXTRA_KEY_SENSOR_ID, mSensorId);
} }
@Override @Override
@@ -173,10 +183,18 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
setHeaderText(resId, false /* force */); setHeaderText(resId, false /* force */);
} }
protected void setHeaderText(CharSequence title) {
getLayout().setHeaderText(title);
}
protected void setDescriptionText(int resId) { protected void setDescriptionText(int resId) {
getLayout().setDescriptionText(resId); getLayout().setDescriptionText(resId);
} }
protected void setDescriptionText(CharSequence descriptionText) {
getLayout().setDescriptionText(descriptionText);
}
protected FooterButton getNextButton() { protected FooterButton getNextButton() {
if (mFooterBarMixin != null) { if (mFooterBarMixin != null) {
return mFooterBarMixin.getPrimaryButton(); return mFooterBarMixin.getPrimaryButton();
@@ -192,6 +210,8 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
intent.setClassName(SETTINGS_PACKAGE_NAME, FingerprintEnrollEnrolling.class.getName()); intent.setClassName(SETTINGS_PACKAGE_NAME, FingerprintEnrollEnrolling.class.getName());
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken); intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary); intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
intent.putExtra(EXTRA_KEY_CHALLENGE, mChallenge);
intent.putExtra(EXTRA_KEY_SENSOR_ID, mSensorId);
if (mUserId != UserHandle.USER_NULL) { if (mUserId != UserHandle.USER_NULL) {
intent.putExtra(Intent.EXTRA_USER_ID, mUserId); intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
} }

View File

@@ -243,6 +243,8 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
} }
BiometricUtils.copyMultiBiometricExtras(getIntent(), intent); BiometricUtils.copyMultiBiometricExtras(getIntent(), intent);
intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary); intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
intent.putExtra(EXTRA_KEY_CHALLENGE, mChallenge);
intent.putExtra(EXTRA_KEY_SENSOR_ID, mSensorId);
startActivityForResult(intent, BIOMETRIC_FIND_SENSOR_REQUEST); startActivityForResult(intent, BIOMETRIC_FIND_SENSOR_REQUEST);
} }
@@ -262,6 +264,8 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out); overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
getNextButton().setEnabled(false); getNextButton().setEnabled(false);
getChallenge(((sensorId, challenge) -> { getChallenge(((sensorId, challenge) -> {
mSensorId = sensorId;
mChallenge = challenge;
mToken = BiometricUtils.requestGatekeeperHat(this, data, mUserId, challenge); mToken = BiometricUtils.requestGatekeeperHat(this, data, mUserId, challenge);
BiometricUtils.removeGatekeeperPasswordHandle(this, data); BiometricUtils.removeGatekeeperPasswordHandle(this, data);
getNextButton().setEnabled(true); getNextButton().setEnabled(true);
@@ -276,6 +280,8 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out); overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
getNextButton().setEnabled(false); getNextButton().setEnabled(false);
getChallenge(((sensorId, challenge) -> { getChallenge(((sensorId, challenge) -> {
mSensorId = sensorId;
mChallenge = challenge;
mToken = BiometricUtils.requestGatekeeperHat(this, data, mUserId, challenge); mToken = BiometricUtils.requestGatekeeperHat(this, data, mUserId, challenge);
BiometricUtils.removeGatekeeperPasswordHandle(this, data); BiometricUtils.removeGatekeeperPasswordHandle(this, data);
getNextButton().setEnabled(true); getNextButton().setEnabled(true);

View File

@@ -121,6 +121,8 @@ public abstract class BiometricsEnrollEnrolling extends BiometricEnrollBase
| Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP); | Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token); intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
intent.putExtra(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, mSensorId);
intent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, mChallenge);
intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary); intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
if (mUserId != UserHandle.USER_NULL) { if (mUserId != UserHandle.USER_NULL) {
intent.putExtra(Intent.EXTRA_USER_ID, mUserId); intent.putExtra(Intent.EXTRA_USER_ID, mUserId);

View File

@@ -72,6 +72,8 @@ public class MultiBiometricEnrollHelper {
mGkPwHandle, mUserId, challenge); mGkPwHandle, mUserId, challenge);
final Intent faceIntent = BiometricUtils.getFaceIntroIntent(mActivity, final Intent faceIntent = BiometricUtils.getFaceIntroIntent(mActivity,
mActivity.getIntent()); mActivity.getIntent());
faceIntent.putExtra(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, sensorId);
faceIntent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, challenge);
if (mRequestEnrollFingerprint) { if (mRequestEnrollFingerprint) {
// Give FaceEnroll a pendingIntent pointing to fingerprint enrollment, so that it // Give FaceEnroll a pendingIntent pointing to fingerprint enrollment, so that it
@@ -97,6 +99,8 @@ public class MultiBiometricEnrollHelper {
mGkPwHandle, mUserId, challenge); mGkPwHandle, mUserId, challenge);
final Intent intent = BiometricUtils.getFingerprintIntroIntent(mActivity, final Intent intent = BiometricUtils.getFingerprintIntroIntent(mActivity,
mActivity.getIntent()); mActivity.getIntent());
intent.putExtra(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, sensorId);
intent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, challenge);
BiometricUtils.launchEnrollForResult(mActivity, intent, REQUEST_FINGERPRINT_ENROLL, BiometricUtils.launchEnrollForResult(mActivity, intent, REQUEST_FINGERPRINT_ENROLL,
hardwareAuthToken, mGkPwHandle, mUserId); hardwareAuthToken, mGkPwHandle, mUserId);
})); }));

View File

@@ -183,6 +183,8 @@ public class FaceEnrollEducation extends BiometricEnrollBase {
if (mUserId != UserHandle.USER_NULL) { if (mUserId != UserHandle.USER_NULL) {
intent.putExtra(Intent.EXTRA_USER_ID, mUserId); intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
} }
intent.putExtra(EXTRA_KEY_CHALLENGE, mChallenge);
intent.putExtra(EXTRA_KEY_SENSOR_ID, mSensorId);
intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary); intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
BiometricUtils.copyMultiBiometricExtras(getIntent(), intent); BiometricUtils.copyMultiBiometricExtras(getIntent(), intent);
final String flattenedString = getString(R.string.config_face_enroll); final String flattenedString = getString(R.string.config_face_enroll);

View File

@@ -112,6 +112,8 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
// the challenge is ready. Let's just do this for now. // the challenge is ready. Let's just do this for now.
mFaceManager.generateChallenge((sensorId, challenge) -> { mFaceManager.generateChallenge((sensorId, challenge) -> {
mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge); mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge);
mSensorId = sensorId;
mChallenge = challenge;
if (BiometricUtils.isMultiBiometricEnrollmentFlow(this)) { if (BiometricUtils.isMultiBiometricEnrollmentFlow(this)) {
BiometricUtils.removeGatekeeperPasswordHandle(this, getIntent()); BiometricUtils.removeGatekeeperPasswordHandle(this, getIntent());
} }

View File

@@ -37,6 +37,7 @@ import androidx.preference.Preference;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.SettingsActivity; import com.android.settings.SettingsActivity;
import com.android.settings.Utils; import com.android.settings.Utils;
import com.android.settings.biometrics.BiometricEnrollBase;
import com.android.settings.biometrics.BiometricUtils; import com.android.settings.biometrics.BiometricUtils;
import com.android.settings.dashboard.DashboardFragment; import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory; import com.android.settings.overlay.FeatureFactory;
@@ -67,6 +68,8 @@ public class FaceSettings extends DashboardFragment {
private UserManager mUserManager; private UserManager mUserManager;
private FaceManager mFaceManager; private FaceManager mFaceManager;
private int mUserId; private int mUserId;
private int mSensorId;
private long mChallenge;
private byte[] mToken; private byte[] mToken;
private FaceSettingsAttentionPreferenceController mAttentionController; private FaceSettingsAttentionPreferenceController mAttentionController;
private FaceSettingsRemoveButtonPreferenceController mRemoveController; private FaceSettingsRemoveButtonPreferenceController mRemoveController;
@@ -147,6 +150,8 @@ public class FaceSettings extends DashboardFragment {
mUserManager = context.getSystemService(UserManager.class); mUserManager = context.getSystemService(UserManager.class);
mFaceManager = context.getSystemService(FaceManager.class); mFaceManager = context.getSystemService(FaceManager.class);
mToken = getIntent().getByteArrayExtra(KEY_TOKEN); mToken = getIntent().getByteArrayExtra(KEY_TOKEN);
mSensorId = getIntent().getIntExtra(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, -1);
mChallenge = getIntent().getLongExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, 0L);
mUserId = getActivity().getIntent().getIntExtra( mUserId = getActivity().getIntent().getIntExtra(
Intent.EXTRA_USER_ID, UserHandle.myUserId()); Intent.EXTRA_USER_ID, UserHandle.myUserId());
@@ -247,6 +252,8 @@ public class FaceSettings extends DashboardFragment {
mFaceManager.generateChallenge((sensorId, challenge) -> { mFaceManager.generateChallenge((sensorId, challenge) -> {
mToken = BiometricUtils.requestGatekeeperHat(getPrefContext(), data, mUserId, mToken = BiometricUtils.requestGatekeeperHat(getPrefContext(), data, mUserId,
challenge); challenge);
mSensorId = sensorId;
mChallenge = challenge;
BiometricUtils.removeGatekeeperPasswordHandle(getPrefContext(), data); BiometricUtils.removeGatekeeperPasswordHandle(getPrefContext(), data);
mAttentionController.setToken(mToken); mAttentionController.setToken(mToken);
mEnrollController.setToken(mToken); mEnrollController.setToken(mToken);
@@ -269,7 +276,7 @@ public class FaceSettings extends DashboardFragment {
&& !mConfirmingPassword) { && !mConfirmingPassword) {
// Revoke challenge and finish // Revoke challenge and finish
if (mToken != null) { if (mToken != null) {
mFaceManager.revokeChallenge(); mFaceManager.revokeChallenge(mSensorId, mUserId, mChallenge);
mToken = null; mToken = null;
} }
finish(); finish();

View File

@@ -324,7 +324,9 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
@Override @Override
public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) { public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) {
if (!TextUtils.isEmpty(helpString)) { if (!TextUtils.isEmpty(helpString)) {
mErrorText.removeCallbacks(mTouchAgainRunnable); if (!mCanAssumeUdfps) {
mErrorText.removeCallbacks(mTouchAgainRunnable);
}
showError(helpString); showError(helpString);
} }
} }
@@ -345,7 +347,9 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
} }
showErrorDialog(getText(msgId), errMsgId); showErrorDialog(getText(msgId), errMsgId);
stopIconAnimation(); stopIconAnimation();
mErrorText.removeCallbacks(mTouchAgainRunnable); if (!mCanAssumeUdfps) {
mErrorText.removeCallbacks(mTouchAgainRunnable);
}
} }
@Override @Override
@@ -354,8 +358,10 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
updateTitleAndDescription(); updateTitleAndDescription();
clearError(); clearError();
animateFlash(); animateFlash();
mErrorText.removeCallbacks(mTouchAgainRunnable); if (!mCanAssumeUdfps) {
mErrorText.postDelayed(mTouchAgainRunnable, HINT_TIMEOUT_DURATION); mErrorText.removeCallbacks(mTouchAgainRunnable);
mErrorText.postDelayed(mTouchAgainRunnable, HINT_TIMEOUT_DURATION);
}
} }
private void updateProgress(boolean animate) { private void updateProgress(boolean animate) {
@@ -397,22 +403,28 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
} }
private void showError(CharSequence error) { private void showError(CharSequence error) {
mErrorText.setText(error); if (mCanAssumeUdfps) {
if (mErrorText.getVisibility() == View.INVISIBLE) { setHeaderText(error);
mErrorText.setVisibility(View.VISIBLE); // Show nothing for subtitle when getting an error message.
mErrorText.setTranslationY(getResources().getDimensionPixelSize( setDescriptionText("");
R.dimen.fingerprint_error_text_appear_distance));
mErrorText.setAlpha(0f);
mErrorText.animate()
.alpha(1f)
.translationY(0f)
.setDuration(200)
.setInterpolator(mLinearOutSlowInInterpolator)
.start();
} else { } else {
mErrorText.animate().cancel(); mErrorText.setText(error);
mErrorText.setAlpha(1f); if (mErrorText.getVisibility() == View.INVISIBLE) {
mErrorText.setTranslationY(0f); mErrorText.setVisibility(View.VISIBLE);
mErrorText.setTranslationY(getResources().getDimensionPixelSize(
R.dimen.fingerprint_error_text_appear_distance));
mErrorText.setAlpha(0f);
mErrorText.animate()
.alpha(1f)
.translationY(0f)
.setDuration(200)
.setInterpolator(mLinearOutSlowInInterpolator)
.start();
} else {
mErrorText.animate().cancel();
mErrorText.setAlpha(1f);
mErrorText.setTranslationY(0f);
}
} }
if (isResumed()) { if (isResumed()) {
mVibrator.vibrate(VIBRATE_EFFECT_ERROR, FINGERPRINT_ENROLLING_SONFICATION_ATTRIBUTES); mVibrator.vibrate(VIBRATE_EFFECT_ERROR, FINGERPRINT_ENROLLING_SONFICATION_ATTRIBUTES);
@@ -420,7 +432,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
} }
private void clearError() { private void clearError() {
if (mErrorText.getVisibility() == View.VISIBLE) { if (!mCanAssumeUdfps && mErrorText.getVisibility() == View.VISIBLE) {
mErrorText.animate() mErrorText.animate()
.alpha(0f) .alpha(0f)
.translationY(getResources().getDimensionPixelSize( .translationY(getResources().getDimensionPixelSize(

View File

@@ -81,6 +81,8 @@ public class FingerprintEnrollFindSensor extends BiometricEnrollBase {
if (mToken == null && BiometricUtils.containsGatekeeperPasswordHandle(getIntent())) { if (mToken == null && BiometricUtils.containsGatekeeperPasswordHandle(getIntent())) {
final FingerprintManager fpm = getSystemService(FingerprintManager.class); final FingerprintManager fpm = getSystemService(FingerprintManager.class);
fpm.generateChallenge(mUserId, (sensorId, challenge) -> { fpm.generateChallenge(mUserId, (sensorId, challenge) -> {
mChallenge = challenge;
mSensorId = sensorId;
mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge); mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge);
BiometricUtils.removeGatekeeperPasswordHandle(this, getIntent()); BiometricUtils.removeGatekeeperPasswordHandle(this, getIntent());

View File

@@ -141,7 +141,7 @@ public class FingerprintEnrollFinish extends BiometricEnrollBase {
private void postEnroll() { private void postEnroll() {
final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(this); final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(this);
if (fpm != null) { if (fpm != null) {
fpm.revokeChallenge(mUserId); fpm.revokeChallenge(mUserId, mChallenge);
} }
} }
@@ -151,6 +151,7 @@ public class FingerprintEnrollFinish extends BiometricEnrollBase {
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken); intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra(Intent.EXTRA_USER_ID, mUserId); intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
intent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, mChallenge);
startActivity(intent); startActivity(intent);
} }

View File

@@ -138,6 +138,8 @@ public class FingerprintSettings extends SubSettings {
private CharSequence mFooterTitle; private CharSequence mFooterTitle;
private boolean mEnrollClicked; private boolean mEnrollClicked;
private long mChallenge;
private static final String TAG_AUTHENTICATE_SIDECAR = "authenticate_sidecar"; private static final String TAG_AUTHENTICATE_SIDECAR = "authenticate_sidecar";
private static final String TAG_REMOVAL_SIDECAR = "removal_sidecar"; private static final String TAG_REMOVAL_SIDECAR = "removal_sidecar";
private FingerprintAuthenticateSidecar mAuthenticateSidecar; private FingerprintAuthenticateSidecar mAuthenticateSidecar;
@@ -287,6 +289,8 @@ public class FingerprintSettings extends SubSettings {
mToken = getIntent().getByteArrayExtra( mToken = getIntent().getByteArrayExtra(
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN); ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
mChallenge = activity.getIntent()
.getLongExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, -1L);
mAuthenticateSidecar = (FingerprintAuthenticateSidecar) mAuthenticateSidecar = (FingerprintAuthenticateSidecar)
getFragmentManager().findFragmentByTag(TAG_AUTHENTICATE_SIDECAR); getFragmentManager().findFragmentByTag(TAG_AUTHENTICATE_SIDECAR);
@@ -577,6 +581,7 @@ public class FingerprintSettings extends SubSettings {
mFingerprintManager.generateChallenge(mUserId, (sensorId, challenge) -> { mFingerprintManager.generateChallenge(mUserId, (sensorId, challenge) -> {
mToken = BiometricUtils.requestGatekeeperHat(getActivity(), data, mToken = BiometricUtils.requestGatekeeperHat(getActivity(), data,
mUserId, challenge); mUserId, challenge);
mChallenge = challenge;
BiometricUtils.removeGatekeeperPasswordHandle(getActivity(), data); BiometricUtils.removeGatekeeperPasswordHandle(getActivity(), data);
updateAddPreference(); updateAddPreference();
}); });
@@ -602,7 +607,7 @@ public class FingerprintSettings extends SubSettings {
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
if (getActivity().isFinishing()) { if (getActivity().isFinishing()) {
mFingerprintManager.revokeChallenge(mUserId); mFingerprintManager.revokeChallenge(mUserId, mChallenge);
} }
} }

View File

@@ -40,6 +40,8 @@ public class SetupFingerprintEnrollFindSensor extends FingerprintEnrollFindSenso
protected Intent getFingerprintEnrollingIntent() { protected Intent getFingerprintEnrollingIntent() {
Intent intent = new Intent(this, SetupFingerprintEnrollEnrolling.class); Intent intent = new Intent(this, SetupFingerprintEnrollEnrolling.class);
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken); intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
intent.putExtra(EXTRA_KEY_CHALLENGE, mChallenge);
intent.putExtra(EXTRA_KEY_SENSOR_ID, mSensorId);
if (mUserId != UserHandle.USER_NULL) { if (mUserId != UserHandle.USER_NULL) {
intent.putExtra(Intent.EXTRA_USER_ID, mUserId); intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
} }

View File

@@ -31,7 +31,7 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.core.BasePreferenceController; import com.android.settings.core.TogglePreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver; import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart; import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop; import com.android.settingslib.core.lifecycle.events.OnStop;
@@ -43,7 +43,7 @@ import java.util.concurrent.Executor;
* screen. * screen.
*/ */
public class LocationTimeZoneDetectionPreferenceController public class LocationTimeZoneDetectionPreferenceController
extends BasePreferenceController extends TogglePreferenceController
implements LifecycleObserver, OnStart, OnStop, TimeManager.TimeZoneDetectorListener { implements LifecycleObserver, OnStart, OnStop, TimeManager.TimeZoneDetectorListener {
private final TimeManager mTimeManager; private final TimeManager mTimeManager;
@@ -57,6 +57,22 @@ public class LocationTimeZoneDetectionPreferenceController
mLocationManager = context.getSystemService(LocationManager.class); mLocationManager = context.getSystemService(LocationManager.class);
} }
@Override
public boolean isChecked() {
TimeZoneCapabilitiesAndConfig capabilitiesAndConfig =
mTimeManager.getTimeZoneCapabilitiesAndConfig();
TimeZoneConfiguration configuration = capabilitiesAndConfig.getConfiguration();
return configuration.isGeoDetectionEnabled();
}
@Override
public boolean setChecked(boolean isChecked) {
TimeZoneConfiguration configuration = new TimeZoneConfiguration.Builder()
.setGeoDetectionEnabled(isChecked)
.build();
return mTimeManager.updateTimeZoneConfiguration(configuration);
}
@Override @Override
public void displayPreference(PreferenceScreen screen) { public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen); super.displayPreference(screen);
@@ -126,10 +142,10 @@ public class LocationTimeZoneDetectionPreferenceController
summaryResId = R.string.location_time_zone_detection_not_applicable; summaryResId = R.string.location_time_zone_detection_not_applicable;
} }
} else if (configureGeoDetectionEnabledCapability == CAPABILITY_POSSESSED) { } else if (configureGeoDetectionEnabledCapability == CAPABILITY_POSSESSED) {
boolean isGeoDetectionEnabled = configuration.isGeoDetectionEnabled(); // If capability is possessed, toggle status already tells all the information needed.
summaryResId = isGeoDetectionEnabled // Returning null will make previous text stick on toggling.
? R.string.location_time_zone_detection_on // See AbstractPreferenceController#refreshSummary.
: R.string.location_time_zone_detection_off; return "";
} else { } else {
// This is unexpected: getAvailabilityStatus() should ensure that the UI element isn't // This is unexpected: getAvailabilityStatus() should ensure that the UI element isn't
// even shown for known cases, or the capability is unknown. // even shown for known cases, or the capability is unknown.

View File

@@ -1,52 +0,0 @@
/*
* Copyright (C) 2020 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.datetime.locationtimezone;
import android.app.settings.SettingsEnums;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.SearchIndexable;
/**
* The controller for the "location time zone detection" screen.
*/
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class TimeZoneDetectionSettings extends DashboardFragment {
private static final String TAG = "LTZDetectionSettings";
@Override
public int getMetricsCategory() {
return SettingsEnums.LOCATION_TIME_ZONE_DETECTION;
}
@Override
protected int getPreferenceScreenResId() {
return R.xml.location_time_zone_detection;
}
@Override
protected String getLogTag() {
return TAG;
}
/**
* For Search.
*/
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.location_time_zone_detection);
}

View File

@@ -1,59 +0,0 @@
/*
* Copyright (C) 2020 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.datetime.locationtimezone;
import android.app.time.TimeManager;
import android.app.time.TimeZoneCapabilitiesAndConfig;
import android.app.time.TimeZoneConfiguration;
import android.content.Context;
import com.android.settings.core.TogglePreferenceController;
/**
* The controller for the "location time zone detection" switch on the location time zone detection
* screen.
*/
public class TimeZoneDetectionTogglePreferenceController extends TogglePreferenceController {
private final TimeManager mTimeManager;
public TimeZoneDetectionTogglePreferenceController(Context context, String key) {
super(context, key);
mTimeManager = context.getSystemService(TimeManager.class);
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
@Override
public boolean isChecked() {
TimeZoneCapabilitiesAndConfig capabilitiesAndConfig =
mTimeManager.getTimeZoneCapabilitiesAndConfig();
TimeZoneConfiguration configuration = capabilitiesAndConfig.getConfiguration();
return configuration.isGeoDetectionEnabled();
}
@Override
public boolean setChecked(boolean isChecked) {
TimeZoneConfiguration configuration = new TimeZoneConfiguration.Builder()
.setGeoDetectionEnabled(isChecked)
.build();
return mTimeManager.updateTimeZoneConfiguration(configuration);
}
}

View File

@@ -23,11 +23,11 @@ import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R; import com.android.settings.R;
import com.android.settingslib.widget.BannerMessagePreference;
/** /**
* The controller of Screen attention's permission warning preference. The preference appears when * The controller of Screen attention's permission warning preference. The preference appears when
@@ -35,8 +35,8 @@ import com.android.settings.R;
*/ */
public class AdaptiveSleepPermissionPreferenceController { public class AdaptiveSleepPermissionPreferenceController {
@VisibleForTesting @VisibleForTesting
Preference mPreference; BannerMessagePreference mPreference;
private PackageManager mPackageManager; private final PackageManager mPackageManager;
public AdaptiveSleepPermissionPreferenceController(Context context) { public AdaptiveSleepPermissionPreferenceController(Context context) {
final String packageName = context.getPackageManager().getAttentionServicePackageName(); final String packageName = context.getPackageManager().getAttentionServicePackageName();
@@ -44,13 +44,12 @@ public class AdaptiveSleepPermissionPreferenceController {
final Intent intent = new Intent( final Intent intent = new Intent(
android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.parse("package:" + packageName)); intent.setData(Uri.parse("package:" + packageName));
mPreference = new Preference(context); mPreference = new BannerMessagePreference(context);
mPreference.setTitle(R.string.adaptive_sleep_title_no_permission); mPreference.setTitle(R.string.adaptive_sleep_title_no_permission);
mPreference.setSummary(R.string.adaptive_sleep_summary_no_permission); mPreference.setSummary(R.string.adaptive_sleep_summary_no_permission);
mPreference.setIcon(R.drawable.ic_info_outline_24); mPreference.setPositiveButtonText(R.string.adaptive_sleep_manage_permission_button);
mPreference.setOnPreferenceClickListener(p -> { mPreference.setPositiveButtonOnClickListener(p -> {
context.startActivity(intent); context.startActivity(intent);
return true;
}); });
} }

View File

@@ -23,7 +23,6 @@ import android.app.settings.SettingsEnums;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.UserHandle; import android.os.UserHandle;
import android.provider.Settings; import android.provider.Settings;
import android.text.SpannableString; import android.text.SpannableString;
@@ -39,8 +38,6 @@ import androidx.preference.PreferenceScreen;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory; import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.actionbar.SearchMenuController;
import com.android.settings.support.actionbar.HelpMenuController;
import com.android.settings.support.actionbar.HelpResourceProvider; import com.android.settings.support.actionbar.HelpResourceProvider;
import com.android.settings.widget.RadioButtonPickerFragment; import com.android.settings.widget.RadioButtonPickerFragment;
import com.android.settingslib.RestrictedLockUtils; import com.android.settingslib.RestrictedLockUtils;
@@ -91,13 +88,6 @@ public class ScreenTimeoutSettings extends RadioButtonPickerFragment implements
.getMetricsFeatureProvider(); .getMetricsFeatureProvider();
} }
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
SearchMenuController.init(this /* host */);
HelpMenuController.init(this /* host */);
}
@Override @Override
public void onAttach(Context context) { public void onAttach(Context context) {
super.onAttach(context); super.onAttach(context);

View File

@@ -21,10 +21,12 @@ import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.graphics.ColorFilter;
import android.icu.text.NumberFormat; import android.icu.text.NumberFormat;
import android.os.BatteryManager; import android.os.BatteryManager;
import android.os.PowerManager; import android.os.PowerManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.widget.ImageView;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceFragmentCompat;
@@ -60,6 +62,7 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
private Activity mActivity; private Activity mActivity;
private PreferenceFragmentCompat mHost; private PreferenceFragmentCompat mHost;
private Lifecycle mLifecycle; private Lifecycle mLifecycle;
private ColorFilter mAccentColorFilter;
private final PowerManager mPowerManager; private final PowerManager mPowerManager;
public BatteryHeaderPreferenceController(Context context, String key) { public BatteryHeaderPreferenceController(Context context, String key) {
@@ -85,6 +88,9 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
public void displayPreference(PreferenceScreen screen) { public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen); super.displayPreference(screen);
mBatteryUsageProgressBarPref = screen.findPreference(getPreferenceKey()); mBatteryUsageProgressBarPref = screen.findPreference(getPreferenceKey());
mAccentColorFilter = com.android.settings.Utils.getAlphaInvariantColorFilterForColor(
com.android.settings.Utils.getColorAttrDefaultColor(
mContext, android.R.attr.colorAccent));
if (com.android.settings.Utils.isBatteryPresent(mContext)) { if (com.android.settings.Utils.isBatteryPresent(mContext)) {
quickUpdateHeaderPreference(); quickUpdateHeaderPreference();
@@ -116,13 +122,12 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
} }
public void updateHeaderPreference(BatteryInfo info) { public void updateHeaderPreference(BatteryInfo info) {
//TODO(b/179237746): Make progress bar widget support battery state icon
mBatteryUsageProgressBarPref.setUsageSummary( mBatteryUsageProgressBarPref.setUsageSummary(
formatBatteryPercentageText(info.batteryLevel)); formatBatteryPercentageText(info.batteryLevel));
mBatteryUsageProgressBarPref.setTotalSummary(generateLabel(info)); mBatteryUsageProgressBarPref.setTotalSummary(generateLabel(info));
mBatteryUsageProgressBarPref.setPercent(info.batteryLevel, BATTERY_MAX_LEVEL); mBatteryUsageProgressBarPref.setPercent(info.batteryLevel, BATTERY_MAX_LEVEL);
mBatteryUsageProgressBarPref.setCustomContent(
getBatteryIcon(!info.discharging, info.batteryLevel));
} }
/** /**
@@ -139,14 +144,30 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
final boolean discharging = final boolean discharging =
batteryBroadcast.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) == 0; batteryBroadcast.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) == 0;
//TODO(b/179237746): Make progress bar widget support battery state icon
mBatteryUsageProgressBarPref.setUsageSummary(formatBatteryPercentageText(batteryLevel)); mBatteryUsageProgressBarPref.setUsageSummary(formatBatteryPercentageText(batteryLevel));
mBatteryUsageProgressBarPref.setPercent(batteryLevel, BATTERY_MAX_LEVEL); mBatteryUsageProgressBarPref.setPercent(batteryLevel, BATTERY_MAX_LEVEL);
mBatteryUsageProgressBarPref.setCustomContent(getBatteryIcon(!discharging, batteryLevel));
} }
private CharSequence formatBatteryPercentageText(int batteryLevel) { private CharSequence formatBatteryPercentageText(int batteryLevel) {
return TextUtils.expandTemplate(mContext.getText(R.string.battery_header_title_alternate), return TextUtils.expandTemplate(mContext.getText(R.string.battery_header_title_alternate),
NumberFormat.getIntegerInstance().format(batteryLevel)); NumberFormat.getIntegerInstance().format(batteryLevel));
} }
//TODO(b/179237746): Update the battery icon after receiving final asset
private ImageView getBatteryIcon(boolean isCharging, int batteryLevel) {
ImageView batteryIcon = new ImageView(mContext);
if (batteryLevel <= (mContext.getResources().getInteger(
com.android.internal.R.integer.config_lowBatteryWarningLevel))) {
batteryIcon.setImageResource(R.drawable.ic_battery_low);
} else if (isCharging) {
batteryIcon.setColorFilter(mAccentColorFilter);
batteryIcon.setImageResource(R.drawable.ic_battery_charging_full);
} else {
batteryIcon = null;
}
return batteryIcon;
}
} }

View File

@@ -1,5 +1,7 @@
# Default reviewers for this and subdirectories. # Bug component: 34867
yukawa@google.com include platform/frameworks/base:/services/core/java/com/android/server/inputmethod/OWNERS
michaelwr@google.com
# Emergency approvers in case the above are not available # Settings for physical keyboard and game pad are better to be reviewed by the input team
per-file GameControllerPreferenceController.java = file: platform/frameworks/base:/services/core/java/com/android/server/input/OWNERS
per-file KeyboardLayoutPicker*.java = file: platform/frameworks/base:/services/core/java/com/android/server/input/OWNERS
per-file PhysicalKeyboard*.java = file: platform/frameworks/base:/services/core/java/com/android/server/input/OWNERS

View File

@@ -18,6 +18,7 @@ package com.android.settings.widget;
import android.content.Context; import android.content.Context;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.widget.SeekBar; import android.widget.SeekBar;
import android.widget.TextView; import android.widget.TextView;
@@ -32,6 +33,7 @@ public class LabeledSeekBarPreference extends SeekBarPreference {
private final int mTextStartId; private final int mTextStartId;
private final int mTextEndId; private final int mTextEndId;
private final int mTickMarkId;
private OnPreferenceChangeListener mStopListener; private OnPreferenceChangeListener mStopListener;
public LabeledSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr, public LabeledSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
@@ -48,6 +50,8 @@ public class LabeledSeekBarPreference extends SeekBarPreference {
mTextEndId = styledAttrs.getResourceId( mTextEndId = styledAttrs.getResourceId(
R.styleable.LabeledSeekBarPreference_textEnd, R.styleable.LabeledSeekBarPreference_textEnd,
R.string.summary_placeholder); R.string.summary_placeholder);
mTickMarkId = styledAttrs.getResourceId(
R.styleable.LabeledSeekBarPreference_tickMark, /* defValue= */ 0);
styledAttrs.recycle(); styledAttrs.recycle();
} }
@@ -65,6 +69,13 @@ public class LabeledSeekBarPreference extends SeekBarPreference {
final TextView endText = (TextView) holder.findViewById(android.R.id.text2); final TextView endText = (TextView) holder.findViewById(android.R.id.text2);
startText.setText(mTextStartId); startText.setText(mTextStartId);
endText.setText(mTextEndId); endText.setText(mTextEndId);
if (mTickMarkId != 0) {
final Drawable tickMark = getContext().getDrawable(mTickMarkId);
final SeekBar seekBar = (SeekBar) holder.findViewById(
com.android.internal.R.id.seekbar);
seekBar.setTickMark(tickMark);
}
} }
public void setOnPreferenceChangeStopListener(OnPreferenceChangeListener listener) { public void setOnPreferenceChangeStopListener(OnPreferenceChangeListener listener) {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018 The Android Open Source Project * Copyright (C) 2020 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ import static android.app.time.TimeZoneCapabilities.CAPABILITY_POSSESSED;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import android.app.time.TimeManager; import android.app.time.TimeManager;
@@ -61,10 +62,34 @@ public class LocationTimeZoneDetectionPreferenceControllerTest {
mController = new LocationTimeZoneDetectionPreferenceController(mContext, "key"); mController = new LocationTimeZoneDetectionPreferenceController(mContext, "key");
} }
@Test
public void setChecked_withTrue_shouldUpdateSetting() {
// Simulate the UI being clicked.
mController.setChecked(true);
// Verify the TimeManager was updated with the UI value.
TimeZoneConfiguration expectedConfiguration = new TimeZoneConfiguration.Builder()
.setGeoDetectionEnabled(true)
.build();
verify(mTimeManager).updateTimeZoneConfiguration(expectedConfiguration);
}
@Test
public void setChecked_withFalse_shouldUpdateSetting() {
// Simulate the UI being clicked.
mController.setChecked(false);
// Verify the TimeManager was updated with the UI value.
TimeZoneConfiguration expectedConfiguration = new TimeZoneConfiguration.Builder()
.setGeoDetectionEnabled(false)
.build();
verify(mTimeManager).updateTimeZoneConfiguration(expectedConfiguration);
}
@Test @Test
public void testLocationTimeZoneDetection_supported_shouldBeShown() { public void testLocationTimeZoneDetection_supported_shouldBeShown() {
TimeZoneCapabilities capabilities = TimeZoneCapabilities capabilities =
createTimeZoneCapabilities(/* geoDetectionSupported= */ true); createTimeZoneCapabilities(CAPABILITY_POSSESSED);
TimeZoneConfiguration configuration = createTimeZoneConfig(/* geoDetectionEnabled= */ true); TimeZoneConfiguration configuration = createTimeZoneConfig(/* geoDetectionEnabled= */ true);
TimeZoneCapabilitiesAndConfig capabilitiesAndConfig = TimeZoneCapabilitiesAndConfig capabilitiesAndConfig =
new TimeZoneCapabilitiesAndConfig(capabilities, configuration); new TimeZoneCapabilitiesAndConfig(capabilities, configuration);
@@ -76,7 +101,7 @@ public class LocationTimeZoneDetectionPreferenceControllerTest {
@Test @Test
public void testLocationTimeZoneDetection_unsupported_shouldNotBeShown() { public void testLocationTimeZoneDetection_unsupported_shouldNotBeShown() {
TimeZoneCapabilities capabilities = TimeZoneCapabilities capabilities =
createTimeZoneCapabilities(/* geoDetectionSupported= */ false); createTimeZoneCapabilities(CAPABILITY_NOT_SUPPORTED);
TimeZoneConfiguration configuration = createTimeZoneConfig(/* geoDetectionEnabled= */ true); TimeZoneConfiguration configuration = createTimeZoneConfig(/* geoDetectionEnabled= */ true);
TimeZoneCapabilitiesAndConfig capabilitiesAndConfig = TimeZoneCapabilitiesAndConfig capabilitiesAndConfig =
new TimeZoneCapabilitiesAndConfig(capabilities, configuration); new TimeZoneCapabilitiesAndConfig(capabilities, configuration);
@@ -91,20 +116,34 @@ public class LocationTimeZoneDetectionPreferenceControllerTest {
@Test @Test
public void testLocationTimeZoneDetection_summary_geoDetectionEnabled() { public void testLocationTimeZoneDetection_summary_geoDetectionEnabled() {
TimeZoneCapabilities capabilities = TimeZoneCapabilities capabilities =
createTimeZoneCapabilities(/* geoDetectionSupported= */ true); createTimeZoneCapabilities(CAPABILITY_POSSESSED);
TimeZoneConfiguration configuration = createTimeZoneConfig(/* geoDetectionEnabled= */ true); TimeZoneConfiguration configuration = createTimeZoneConfig(/* geoDetectionEnabled= */ true);
TimeZoneCapabilitiesAndConfig capabilitiesAndConfig = TimeZoneCapabilitiesAndConfig capabilitiesAndConfig =
new TimeZoneCapabilitiesAndConfig(capabilities, configuration); new TimeZoneCapabilitiesAndConfig(capabilities, configuration);
when(mTimeManager.getTimeZoneCapabilitiesAndConfig()).thenReturn(capabilitiesAndConfig); when(mTimeManager.getTimeZoneCapabilitiesAndConfig()).thenReturn(capabilitiesAndConfig);
assertThat(mController.getSummary()).isEqualTo( assertThat(mController.getSummary().toString()).isEmpty();
mContext.getString(R.string.location_time_zone_detection_on));
} }
private static TimeZoneCapabilities createTimeZoneCapabilities(boolean geoDetectionSupported) { @Test
public void testLocationTimeZoneDetection_toggleIsOn_whenGeoDetectionEnabledAnsMlsIsOff() {
TimeZoneCapabilities capabilities =
createTimeZoneCapabilities(CAPABILITY_NOT_APPLICABLE);
TimeZoneConfiguration configuration = createTimeZoneConfig(/* geoDetectionEnabled= */ true);
TimeZoneCapabilitiesAndConfig capabilitiesAndConfig =
new TimeZoneCapabilitiesAndConfig(capabilities, configuration);
when(mTimeManager.getTimeZoneCapabilitiesAndConfig()).thenReturn(capabilitiesAndConfig);
when(mLocationManager.isLocationEnabled()).thenReturn(false);
assertThat(mController.isChecked()).isTrue();
assertThat(mController.getSummary()).isEqualTo(
mContext.getString(R.string.location_app_permission_summary_location_off));
}
private static TimeZoneCapabilities createTimeZoneCapabilities(
@TimeZoneCapabilities.CapabilityState int geoDetectionCapability) {
UserHandle arbitraryUserHandle = UserHandle.of(123); UserHandle arbitraryUserHandle = UserHandle.of(123);
int geoDetectionCapability =
geoDetectionSupported ? CAPABILITY_POSSESSED : CAPABILITY_NOT_SUPPORTED;
return new TimeZoneCapabilities.Builder(arbitraryUserHandle) return new TimeZoneCapabilities.Builder(arbitraryUserHandle)
.setConfigureAutoDetectionEnabledCapability(CAPABILITY_POSSESSED) .setConfigureAutoDetectionEnabledCapability(CAPABILITY_POSSESSED)
.setConfigureGeoDetectionEnabledCapability(geoDetectionCapability) .setConfigureGeoDetectionEnabledCapability(geoDetectionCapability)

View File

@@ -1,53 +0,0 @@
/*
* Copyright (C) 2017 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.datetime.locationtimezone;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.provider.SearchIndexableResource;
import com.android.settings.R;
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 TimeZoneDetectionSettingsTest {
private Context mContext;
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
}
@Test
public void searchProvider_shouldIndexDefaultXml() {
final List<SearchIndexableResource> sir =
TimeZoneDetectionSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
mContext, /* enabled= */ true);
assertThat(sir).hasSize(1);
assertThat(sir.get(0).xmlResId).isEqualTo(R.xml.location_time_zone_detection);
}
}

View File

@@ -1,119 +0,0 @@
/*
* Copyright (C) 2017 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.datetime.locationtimezone;
import static android.app.time.TimeZoneCapabilities.CAPABILITY_NOT_APPLICABLE;
import static android.app.time.TimeZoneCapabilities.CAPABILITY_POSSESSED;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.time.TimeManager;
import android.app.time.TimeZoneCapabilities;
import android.app.time.TimeZoneCapabilitiesAndConfig;
import android.app.time.TimeZoneConfiguration;
import android.content.Context;
import android.os.UserHandle;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
@RunWith(RobolectricTestRunner.class)
public class TimeZoneDetectionTogglePreferenceControllerTest {
private static final String PREF_KEY = "test_key";
@Mock
private Context mContext;
@Mock
private TimeManager mTimeManager;
private TimeZoneDetectionTogglePreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
when(mContext.getSystemService(TimeManager.class)).thenReturn(mTimeManager);
mController = new TimeZoneDetectionTogglePreferenceController(mContext, PREF_KEY);
}
@Test
public void isAvailable_shouldReturnTrue() {
assertThat(mController.isAvailable()).isTrue();
}
@Test
public void isChecked_whenEnabled_shouldReturnTrue() {
when(mTimeManager.getTimeZoneCapabilitiesAndConfig())
.thenReturn(createTimeZoneCapabilitiesAndConfig(true));
assertThat(mController.isChecked()).isTrue();
}
@Test
public void isChecked_whenDisabled_shouldReturnFalse() {
when(mTimeManager.getTimeZoneCapabilitiesAndConfig())
.thenReturn(createTimeZoneCapabilitiesAndConfig(false));
assertThat(mController.isChecked()).isFalse();
}
@Test
public void setChecked_withTrue_shouldUpdateSetting() {
// Simulate the UI being clicked.
mController.setChecked(true);
// Verify the TimeManager was updated with the UI value.
TimeZoneConfiguration expectedConfiguration = new TimeZoneConfiguration.Builder()
.setGeoDetectionEnabled(true)
.build();
verify(mTimeManager).updateTimeZoneConfiguration(expectedConfiguration);
}
@Test
public void setChecked_withFalse_shouldUpdateSetting() {
// Simulate the UI being clicked.
mController.setChecked(false);
// Verify the TimeManager was updated with the UI value.
TimeZoneConfiguration expectedConfiguration = new TimeZoneConfiguration.Builder()
.setGeoDetectionEnabled(false)
.build();
verify(mTimeManager).updateTimeZoneConfiguration(expectedConfiguration);
}
private static TimeZoneCapabilitiesAndConfig createTimeZoneCapabilitiesAndConfig(
boolean geoDetectionEnabled) {
UserHandle arbitraryUserHandle = UserHandle.of(123);
TimeZoneCapabilities capabilities = new TimeZoneCapabilities.Builder(arbitraryUserHandle)
.setConfigureAutoDetectionEnabledCapability(CAPABILITY_POSSESSED)
.setConfigureGeoDetectionEnabledCapability(CAPABILITY_POSSESSED)
.setSuggestManualTimeZoneCapability(CAPABILITY_NOT_APPLICABLE)
.build();
TimeZoneConfiguration configuration = new TimeZoneConfiguration.Builder()
.setAutoDetectionEnabled(true)
.setGeoDetectionEnabled(geoDetectionEnabled)
.build();
return new TimeZoneCapabilitiesAndConfig(capabilities, configuration);
}
}