Snap for 7202128 from 0936026260 to sc-v2-release
Change-Id: If15e4834d599db800f2e4379376c52e6b1eeb5c9
This commit is contained in:
@@ -3751,6 +3751,25 @@
|
||||
android:launchMode="singleTask">
|
||||
</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. -->
|
||||
</application>
|
||||
</manifest>
|
||||
|
||||
28
res/drawable/ic_battery_low.xml
Normal file
28
res/drawable/ic_battery_low.xml
Normal 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>
|
||||
@@ -48,7 +48,7 @@
|
||||
android:id="@android:id/empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:gravity="bottom|center_horizontal"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/no_applications"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
|
||||
@@ -170,6 +170,7 @@
|
||||
<declare-styleable name="LabeledSeekBarPreference">
|
||||
<attr name="textStart" format="reference" />
|
||||
<attr name="textEnd" format="reference" />
|
||||
<attr name="tickMark" format="reference" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="TintDrawable">
|
||||
|
||||
@@ -2836,7 +2836,9 @@
|
||||
<!-- 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>
|
||||
<!-- 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]-->
|
||||
<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]-->
|
||||
@@ -4059,18 +4061,8 @@
|
||||
<!-- [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>
|
||||
|
||||
<!-- [CHAR LIMIT=60] Location settings screen, screen title -->
|
||||
<string name="location_time_zone_detection_screen_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=60] Date&Time settings screen, toggle button title -->
|
||||
<string name="location_time_zone_detection_toggle_title">Use location to set time zone</string>
|
||||
<!-- [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
|
||||
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>
|
||||
|
||||
<!-- 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] -->
|
||||
<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] -->
|
||||
<string name="keywords_system_update_settings">upgrade, android</string>
|
||||
|
||||
@@ -53,12 +53,12 @@
|
||||
settings:keywords="@string/keywords_time_zone"/>
|
||||
|
||||
<!-- 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:title="@string/location_time_zone_detection_screen_title"
|
||||
android:title="@string/location_time_zone_detection_toggle_title"
|
||||
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
|
||||
android:key="time_format_preference_category"
|
||||
|
||||
@@ -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>
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.settings;
|
||||
|
||||
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
@@ -72,6 +74,8 @@ public class ActivityPicker extends AlertActivity implements
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
getWindow().addPrivateFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||
|
||||
final Intent intent = getIntent();
|
||||
|
||||
// Read base intent from extras, otherwise assume default
|
||||
|
||||
@@ -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_REQUIRE_VISION = "accessibility_vision";
|
||||
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
|
||||
@@ -90,12 +92,16 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
|
||||
protected boolean mLaunchedConfirmLock;
|
||||
protected byte[] mToken;
|
||||
protected int mUserId;
|
||||
protected int mSensorId;
|
||||
protected long mChallenge;
|
||||
protected boolean mFromSettingsSummary;
|
||||
protected FooterBarMixin mFooterBarMixin;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle 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
|
||||
// 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)
|
||||
@@ -110,6 +116,8 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
|
||||
mFromSettingsSummary =
|
||||
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());
|
||||
}
|
||||
@@ -127,6 +135,8 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
|
||||
outState.putBoolean(EXTRA_KEY_LAUNCHED_CONFIRM, mLaunchedConfirmLock);
|
||||
outState.putByteArray(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
|
||||
outState.putBoolean(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
|
||||
outState.putLong(EXTRA_KEY_CHALLENGE, mChallenge);
|
||||
outState.putInt(EXTRA_KEY_SENSOR_ID, mSensorId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -173,10 +183,18 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
|
||||
setHeaderText(resId, false /* force */);
|
||||
}
|
||||
|
||||
protected void setHeaderText(CharSequence title) {
|
||||
getLayout().setHeaderText(title);
|
||||
}
|
||||
|
||||
protected void setDescriptionText(int resId) {
|
||||
getLayout().setDescriptionText(resId);
|
||||
}
|
||||
|
||||
protected void setDescriptionText(CharSequence descriptionText) {
|
||||
getLayout().setDescriptionText(descriptionText);
|
||||
}
|
||||
|
||||
protected FooterButton getNextButton() {
|
||||
if (mFooterBarMixin != null) {
|
||||
return mFooterBarMixin.getPrimaryButton();
|
||||
@@ -192,6 +210,8 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
|
||||
intent.setClassName(SETTINGS_PACKAGE_NAME, FingerprintEnrollEnrolling.class.getName());
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
|
||||
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) {
|
||||
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
|
||||
}
|
||||
|
||||
@@ -243,6 +243,8 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
|
||||
}
|
||||
BiometricUtils.copyMultiBiometricExtras(getIntent(), intent);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -262,6 +264,8 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
|
||||
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
|
||||
getNextButton().setEnabled(false);
|
||||
getChallenge(((sensorId, challenge) -> {
|
||||
mSensorId = sensorId;
|
||||
mChallenge = challenge;
|
||||
mToken = BiometricUtils.requestGatekeeperHat(this, data, mUserId, challenge);
|
||||
BiometricUtils.removeGatekeeperPasswordHandle(this, data);
|
||||
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);
|
||||
getNextButton().setEnabled(false);
|
||||
getChallenge(((sensorId, challenge) -> {
|
||||
mSensorId = sensorId;
|
||||
mChallenge = challenge;
|
||||
mToken = BiometricUtils.requestGatekeeperHat(this, data, mUserId, challenge);
|
||||
BiometricUtils.removeGatekeeperPasswordHandle(this, data);
|
||||
getNextButton().setEnabled(true);
|
||||
|
||||
@@ -121,6 +121,8 @@ public abstract class BiometricsEnrollEnrolling extends BiometricEnrollBase
|
||||
| Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
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);
|
||||
if (mUserId != UserHandle.USER_NULL) {
|
||||
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
|
||||
|
||||
@@ -72,6 +72,8 @@ public class MultiBiometricEnrollHelper {
|
||||
mGkPwHandle, mUserId, challenge);
|
||||
final Intent faceIntent = BiometricUtils.getFaceIntroIntent(mActivity,
|
||||
mActivity.getIntent());
|
||||
faceIntent.putExtra(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, sensorId);
|
||||
faceIntent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, challenge);
|
||||
|
||||
if (mRequestEnrollFingerprint) {
|
||||
// Give FaceEnroll a pendingIntent pointing to fingerprint enrollment, so that it
|
||||
@@ -97,6 +99,8 @@ public class MultiBiometricEnrollHelper {
|
||||
mGkPwHandle, mUserId, challenge);
|
||||
final Intent intent = BiometricUtils.getFingerprintIntroIntent(mActivity,
|
||||
mActivity.getIntent());
|
||||
intent.putExtra(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, sensorId);
|
||||
intent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, challenge);
|
||||
BiometricUtils.launchEnrollForResult(mActivity, intent, REQUEST_FINGERPRINT_ENROLL,
|
||||
hardwareAuthToken, mGkPwHandle, mUserId);
|
||||
}));
|
||||
|
||||
@@ -183,6 +183,8 @@ public class FaceEnrollEducation extends BiometricEnrollBase {
|
||||
if (mUserId != UserHandle.USER_NULL) {
|
||||
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);
|
||||
BiometricUtils.copyMultiBiometricExtras(getIntent(), intent);
|
||||
final String flattenedString = getString(R.string.config_face_enroll);
|
||||
|
||||
@@ -112,6 +112,8 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
|
||||
// the challenge is ready. Let's just do this for now.
|
||||
mFaceManager.generateChallenge((sensorId, challenge) -> {
|
||||
mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge);
|
||||
mSensorId = sensorId;
|
||||
mChallenge = challenge;
|
||||
if (BiometricUtils.isMultiBiometricEnrollmentFlow(this)) {
|
||||
BiometricUtils.removeGatekeeperPasswordHandle(this, getIntent());
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import androidx.preference.Preference;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.biometrics.BiometricEnrollBase;
|
||||
import com.android.settings.biometrics.BiometricUtils;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
@@ -67,6 +68,8 @@ public class FaceSettings extends DashboardFragment {
|
||||
private UserManager mUserManager;
|
||||
private FaceManager mFaceManager;
|
||||
private int mUserId;
|
||||
private int mSensorId;
|
||||
private long mChallenge;
|
||||
private byte[] mToken;
|
||||
private FaceSettingsAttentionPreferenceController mAttentionController;
|
||||
private FaceSettingsRemoveButtonPreferenceController mRemoveController;
|
||||
@@ -147,6 +150,8 @@ public class FaceSettings extends DashboardFragment {
|
||||
mUserManager = context.getSystemService(UserManager.class);
|
||||
mFaceManager = context.getSystemService(FaceManager.class);
|
||||
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(
|
||||
Intent.EXTRA_USER_ID, UserHandle.myUserId());
|
||||
@@ -247,6 +252,8 @@ public class FaceSettings extends DashboardFragment {
|
||||
mFaceManager.generateChallenge((sensorId, challenge) -> {
|
||||
mToken = BiometricUtils.requestGatekeeperHat(getPrefContext(), data, mUserId,
|
||||
challenge);
|
||||
mSensorId = sensorId;
|
||||
mChallenge = challenge;
|
||||
BiometricUtils.removeGatekeeperPasswordHandle(getPrefContext(), data);
|
||||
mAttentionController.setToken(mToken);
|
||||
mEnrollController.setToken(mToken);
|
||||
@@ -269,7 +276,7 @@ public class FaceSettings extends DashboardFragment {
|
||||
&& !mConfirmingPassword) {
|
||||
// Revoke challenge and finish
|
||||
if (mToken != null) {
|
||||
mFaceManager.revokeChallenge();
|
||||
mFaceManager.revokeChallenge(mSensorId, mUserId, mChallenge);
|
||||
mToken = null;
|
||||
}
|
||||
finish();
|
||||
|
||||
@@ -324,7 +324,9 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
||||
@Override
|
||||
public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) {
|
||||
if (!TextUtils.isEmpty(helpString)) {
|
||||
if (!mCanAssumeUdfps) {
|
||||
mErrorText.removeCallbacks(mTouchAgainRunnable);
|
||||
}
|
||||
showError(helpString);
|
||||
}
|
||||
}
|
||||
@@ -345,8 +347,10 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
||||
}
|
||||
showErrorDialog(getText(msgId), errMsgId);
|
||||
stopIconAnimation();
|
||||
if (!mCanAssumeUdfps) {
|
||||
mErrorText.removeCallbacks(mTouchAgainRunnable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnrollmentProgressChange(int steps, int remaining) {
|
||||
@@ -354,9 +358,11 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
||||
updateTitleAndDescription();
|
||||
clearError();
|
||||
animateFlash();
|
||||
if (!mCanAssumeUdfps) {
|
||||
mErrorText.removeCallbacks(mTouchAgainRunnable);
|
||||
mErrorText.postDelayed(mTouchAgainRunnable, HINT_TIMEOUT_DURATION);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateProgress(boolean animate) {
|
||||
if (mSidecar == null || !mSidecar.isEnrolling()) {
|
||||
@@ -397,6 +403,11 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
||||
}
|
||||
|
||||
private void showError(CharSequence error) {
|
||||
if (mCanAssumeUdfps) {
|
||||
setHeaderText(error);
|
||||
// Show nothing for subtitle when getting an error message.
|
||||
setDescriptionText("");
|
||||
} else {
|
||||
mErrorText.setText(error);
|
||||
if (mErrorText.getVisibility() == View.INVISIBLE) {
|
||||
mErrorText.setVisibility(View.VISIBLE);
|
||||
@@ -414,13 +425,14 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
||||
mErrorText.setAlpha(1f);
|
||||
mErrorText.setTranslationY(0f);
|
||||
}
|
||||
}
|
||||
if (isResumed()) {
|
||||
mVibrator.vibrate(VIBRATE_EFFECT_ERROR, FINGERPRINT_ENROLLING_SONFICATION_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
|
||||
private void clearError() {
|
||||
if (mErrorText.getVisibility() == View.VISIBLE) {
|
||||
if (!mCanAssumeUdfps && mErrorText.getVisibility() == View.VISIBLE) {
|
||||
mErrorText.animate()
|
||||
.alpha(0f)
|
||||
.translationY(getResources().getDimensionPixelSize(
|
||||
|
||||
@@ -81,6 +81,8 @@ public class FingerprintEnrollFindSensor extends BiometricEnrollBase {
|
||||
if (mToken == null && BiometricUtils.containsGatekeeperPasswordHandle(getIntent())) {
|
||||
final FingerprintManager fpm = getSystemService(FingerprintManager.class);
|
||||
fpm.generateChallenge(mUserId, (sensorId, challenge) -> {
|
||||
mChallenge = challenge;
|
||||
mSensorId = sensorId;
|
||||
mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge);
|
||||
BiometricUtils.removeGatekeeperPasswordHandle(this, getIntent());
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ public class FingerprintEnrollFinish extends BiometricEnrollBase {
|
||||
private void postEnroll() {
|
||||
final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(this);
|
||||
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.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
|
||||
intent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, mChallenge);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
@@ -138,6 +138,8 @@ public class FingerprintSettings extends SubSettings {
|
||||
private CharSequence mFooterTitle;
|
||||
private boolean mEnrollClicked;
|
||||
|
||||
private long mChallenge;
|
||||
|
||||
private static final String TAG_AUTHENTICATE_SIDECAR = "authenticate_sidecar";
|
||||
private static final String TAG_REMOVAL_SIDECAR = "removal_sidecar";
|
||||
private FingerprintAuthenticateSidecar mAuthenticateSidecar;
|
||||
@@ -287,6 +289,8 @@ public class FingerprintSettings extends SubSettings {
|
||||
|
||||
mToken = getIntent().getByteArrayExtra(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
|
||||
mChallenge = activity.getIntent()
|
||||
.getLongExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, -1L);
|
||||
|
||||
mAuthenticateSidecar = (FingerprintAuthenticateSidecar)
|
||||
getFragmentManager().findFragmentByTag(TAG_AUTHENTICATE_SIDECAR);
|
||||
@@ -577,6 +581,7 @@ public class FingerprintSettings extends SubSettings {
|
||||
mFingerprintManager.generateChallenge(mUserId, (sensorId, challenge) -> {
|
||||
mToken = BiometricUtils.requestGatekeeperHat(getActivity(), data,
|
||||
mUserId, challenge);
|
||||
mChallenge = challenge;
|
||||
BiometricUtils.removeGatekeeperPasswordHandle(getActivity(), data);
|
||||
updateAddPreference();
|
||||
});
|
||||
@@ -602,7 +607,7 @@ public class FingerprintSettings extends SubSettings {
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (getActivity().isFinishing()) {
|
||||
mFingerprintManager.revokeChallenge(mUserId);
|
||||
mFingerprintManager.revokeChallenge(mUserId, mChallenge);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,8 @@ public class SetupFingerprintEnrollFindSensor extends FingerprintEnrollFindSenso
|
||||
protected Intent getFingerprintEnrollingIntent() {
|
||||
Intent intent = new Intent(this, SetupFingerprintEnrollEnrolling.class);
|
||||
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) {
|
||||
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
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.events.OnStart;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||
@@ -43,7 +43,7 @@ import java.util.concurrent.Executor;
|
||||
* screen.
|
||||
*/
|
||||
public class LocationTimeZoneDetectionPreferenceController
|
||||
extends BasePreferenceController
|
||||
extends TogglePreferenceController
|
||||
implements LifecycleObserver, OnStart, OnStop, TimeManager.TimeZoneDetectorListener {
|
||||
|
||||
private final TimeManager mTimeManager;
|
||||
@@ -57,6 +57,22 @@ public class LocationTimeZoneDetectionPreferenceController
|
||||
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
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
@@ -126,10 +142,10 @@ public class LocationTimeZoneDetectionPreferenceController
|
||||
summaryResId = R.string.location_time_zone_detection_not_applicable;
|
||||
}
|
||||
} else if (configureGeoDetectionEnabledCapability == CAPABILITY_POSSESSED) {
|
||||
boolean isGeoDetectionEnabled = configuration.isGeoDetectionEnabled();
|
||||
summaryResId = isGeoDetectionEnabled
|
||||
? R.string.location_time_zone_detection_on
|
||||
: R.string.location_time_zone_detection_off;
|
||||
// If capability is possessed, toggle status already tells all the information needed.
|
||||
// Returning null will make previous text stick on toggling.
|
||||
// See AbstractPreferenceController#refreshSummary.
|
||||
return "";
|
||||
} else {
|
||||
// This is unexpected: getAvailabilityStatus() should ensure that the UI element isn't
|
||||
// even shown for known cases, or the capability is unknown.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -23,11 +23,11 @@ import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.widget.BannerMessagePreference;
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
@VisibleForTesting
|
||||
Preference mPreference;
|
||||
private PackageManager mPackageManager;
|
||||
BannerMessagePreference mPreference;
|
||||
private final PackageManager mPackageManager;
|
||||
|
||||
public AdaptiveSleepPermissionPreferenceController(Context context) {
|
||||
final String packageName = context.getPackageManager().getAttentionServicePackageName();
|
||||
@@ -44,13 +44,12 @@ public class AdaptiveSleepPermissionPreferenceController {
|
||||
final Intent intent = new Intent(
|
||||
android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
intent.setData(Uri.parse("package:" + packageName));
|
||||
mPreference = new Preference(context);
|
||||
mPreference = new BannerMessagePreference(context);
|
||||
mPreference.setTitle(R.string.adaptive_sleep_title_no_permission);
|
||||
mPreference.setSummary(R.string.adaptive_sleep_summary_no_permission);
|
||||
mPreference.setIcon(R.drawable.ic_info_outline_24);
|
||||
mPreference.setOnPreferenceClickListener(p -> {
|
||||
mPreference.setPositiveButtonText(R.string.adaptive_sleep_manage_permission_button);
|
||||
mPreference.setPositiveButtonOnClickListener(p -> {
|
||||
context.startActivity(intent);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.text.SpannableString;
|
||||
@@ -39,8 +38,6 @@ import androidx.preference.PreferenceScreen;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
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.widget.RadioButtonPickerFragment;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
@@ -91,13 +88,6 @@ public class ScreenTimeoutSettings extends RadioButtonPickerFragment implements
|
||||
.getMetricsFeatureProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
SearchMenuController.init(this /* host */);
|
||||
HelpMenuController.init(this /* host */);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
|
||||
@@ -21,10 +21,12 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.icu.text.NumberFormat;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.PowerManager;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
@@ -60,6 +62,7 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
|
||||
private Activity mActivity;
|
||||
private PreferenceFragmentCompat mHost;
|
||||
private Lifecycle mLifecycle;
|
||||
private ColorFilter mAccentColorFilter;
|
||||
private final PowerManager mPowerManager;
|
||||
|
||||
public BatteryHeaderPreferenceController(Context context, String key) {
|
||||
@@ -85,6 +88,9 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
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)) {
|
||||
quickUpdateHeaderPreference();
|
||||
@@ -116,13 +122,12 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
|
||||
}
|
||||
|
||||
public void updateHeaderPreference(BatteryInfo info) {
|
||||
|
||||
//TODO(b/179237746): Make progress bar widget support battery state icon
|
||||
|
||||
mBatteryUsageProgressBarPref.setUsageSummary(
|
||||
formatBatteryPercentageText(info.batteryLevel));
|
||||
mBatteryUsageProgressBarPref.setTotalSummary(generateLabel(info));
|
||||
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 =
|
||||
batteryBroadcast.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) == 0;
|
||||
|
||||
//TODO(b/179237746): Make progress bar widget support battery state icon
|
||||
|
||||
mBatteryUsageProgressBarPref.setUsageSummary(formatBatteryPercentageText(batteryLevel));
|
||||
mBatteryUsageProgressBarPref.setPercent(batteryLevel, BATTERY_MAX_LEVEL);
|
||||
mBatteryUsageProgressBarPref.setCustomContent(getBatteryIcon(!discharging, batteryLevel));
|
||||
}
|
||||
|
||||
private CharSequence formatBatteryPercentageText(int batteryLevel) {
|
||||
return TextUtils.expandTemplate(mContext.getText(R.string.battery_header_title_alternate),
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# Default reviewers for this and subdirectories.
|
||||
yukawa@google.com
|
||||
michaelwr@google.com
|
||||
# Bug component: 34867
|
||||
include platform/frameworks/base:/services/core/java/com/android/server/inputmethod/OWNERS
|
||||
|
||||
# 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
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.settings.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
@@ -32,6 +33,7 @@ public class LabeledSeekBarPreference extends SeekBarPreference {
|
||||
|
||||
private final int mTextStartId;
|
||||
private final int mTextEndId;
|
||||
private final int mTickMarkId;
|
||||
private OnPreferenceChangeListener mStopListener;
|
||||
|
||||
public LabeledSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
|
||||
@@ -48,6 +50,8 @@ public class LabeledSeekBarPreference extends SeekBarPreference {
|
||||
mTextEndId = styledAttrs.getResourceId(
|
||||
R.styleable.LabeledSeekBarPreference_textEnd,
|
||||
R.string.summary_placeholder);
|
||||
mTickMarkId = styledAttrs.getResourceId(
|
||||
R.styleable.LabeledSeekBarPreference_tickMark, /* defValue= */ 0);
|
||||
styledAttrs.recycle();
|
||||
}
|
||||
|
||||
@@ -65,6 +69,13 @@ public class LabeledSeekBarPreference extends SeekBarPreference {
|
||||
final TextView endText = (TextView) holder.findViewById(android.R.id.text2);
|
||||
startText.setText(mTextStartId);
|
||||
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) {
|
||||
|
||||
@@ -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");
|
||||
* 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 org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.time.TimeManager;
|
||||
@@ -61,10 +62,34 @@ public class LocationTimeZoneDetectionPreferenceControllerTest {
|
||||
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
|
||||
public void testLocationTimeZoneDetection_supported_shouldBeShown() {
|
||||
TimeZoneCapabilities capabilities =
|
||||
createTimeZoneCapabilities(/* geoDetectionSupported= */ true);
|
||||
createTimeZoneCapabilities(CAPABILITY_POSSESSED);
|
||||
TimeZoneConfiguration configuration = createTimeZoneConfig(/* geoDetectionEnabled= */ true);
|
||||
TimeZoneCapabilitiesAndConfig capabilitiesAndConfig =
|
||||
new TimeZoneCapabilitiesAndConfig(capabilities, configuration);
|
||||
@@ -76,7 +101,7 @@ public class LocationTimeZoneDetectionPreferenceControllerTest {
|
||||
@Test
|
||||
public void testLocationTimeZoneDetection_unsupported_shouldNotBeShown() {
|
||||
TimeZoneCapabilities capabilities =
|
||||
createTimeZoneCapabilities(/* geoDetectionSupported= */ false);
|
||||
createTimeZoneCapabilities(CAPABILITY_NOT_SUPPORTED);
|
||||
TimeZoneConfiguration configuration = createTimeZoneConfig(/* geoDetectionEnabled= */ true);
|
||||
TimeZoneCapabilitiesAndConfig capabilitiesAndConfig =
|
||||
new TimeZoneCapabilitiesAndConfig(capabilities, configuration);
|
||||
@@ -91,20 +116,34 @@ public class LocationTimeZoneDetectionPreferenceControllerTest {
|
||||
@Test
|
||||
public void testLocationTimeZoneDetection_summary_geoDetectionEnabled() {
|
||||
TimeZoneCapabilities capabilities =
|
||||
createTimeZoneCapabilities(/* geoDetectionSupported= */ true);
|
||||
createTimeZoneCapabilities(CAPABILITY_POSSESSED);
|
||||
TimeZoneConfiguration configuration = createTimeZoneConfig(/* geoDetectionEnabled= */ true);
|
||||
TimeZoneCapabilitiesAndConfig capabilitiesAndConfig =
|
||||
new TimeZoneCapabilitiesAndConfig(capabilities, configuration);
|
||||
|
||||
when(mTimeManager.getTimeZoneCapabilitiesAndConfig()).thenReturn(capabilitiesAndConfig);
|
||||
assertThat(mController.getSummary()).isEqualTo(
|
||||
mContext.getString(R.string.location_time_zone_detection_on));
|
||||
assertThat(mController.getSummary().toString()).isEmpty();
|
||||
}
|
||||
|
||||
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);
|
||||
int geoDetectionCapability =
|
||||
geoDetectionSupported ? CAPABILITY_POSSESSED : CAPABILITY_NOT_SUPPORTED;
|
||||
return new TimeZoneCapabilities.Builder(arbitraryUserHandle)
|
||||
.setConfigureAutoDetectionEnabledCapability(CAPABILITY_POSSESSED)
|
||||
.setConfigureGeoDetectionEnabledCapability(geoDetectionCapability)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user