Snap for 5645193 from 090cd1d05e to qt-qpr1-release
Change-Id: I82e6259d3b8796794cd4dc82cf1803025b37b1ff
This commit is contained in:
@@ -3037,4 +3037,36 @@
|
||||
column="5"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="HardCodedColor"
|
||||
severity="Error"
|
||||
message="Avoid using hardcoded color"
|
||||
category="Correctness"
|
||||
priority="4"
|
||||
summary="Using hardcoded color"
|
||||
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
|
||||
errorLine1=" <color name="face_intro_outline">#ffdadce0</color> </color>"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/values/colors.xml"
|
||||
line="150"
|
||||
column="40"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="HardCodedColor"
|
||||
severity="Error"
|
||||
message="Avoid using hardcoded color"
|
||||
category="Correctness"
|
||||
priority="4"
|
||||
summary="Using hardcoded color"
|
||||
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
|
||||
errorLine1=" android:fillColor="@color/face_intro_outline""
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/drawable/face_enroll_introduction.xml"
|
||||
line="25"
|
||||
column="40"/>
|
||||
</issue>
|
||||
|
||||
</issues>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
android:viewportHeight="300">
|
||||
|
||||
<path
|
||||
android:fillColor="#DADCE0"
|
||||
android:fillColor="@color/face_intro_outline"
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M150,0C67.16,0,0,67.16,0,150s67.16,150,150,150 s150-67.16,150-150S232.84,0,150,0 M150,4c39,0,75.66,15.19,103.24,42.76C280.81,74.34,296,111,296,150s-15.19,75.66-42.76,103.24 C225.66,280.81,189,296,150,296s-75.66-15.19-103.24-42.76C19.19,225.66,4,189,4,150S19.19,74.34,46.76,46.76 C74.34,19.19,111,4,150,4" />
|
||||
<path
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:fillColor="#12B5CB"
|
||||
android:pathData="M10.67,21H7v-1h3.13c-0.27-0.63-0.46-1.3-0.56-2H7V6h10v3.5c0.69,0,1.36,0.1,2,0.28V3 c0-1.1-0.9-1.99-2-1.99L7,1C5.9,1,5,1.9,5,3v18c0,1.1,0.9,2,2,2h5.52C11.79,22.45,11.16,21.77,10.67,21z M7,3h10v1H7V3z" />
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:fillColor="#FA903E"
|
||||
android:pathData="M17,12.5c2.48,0,4.5,2.02,4.5,4.5s-2.02,4.5-4.5,4.5s-4.5-2.02-4.5-4.5S14.52,12.5,17,12.5 M17,11 c-3.31,0-6,2.69-6,6s2.69,6,6,6c3.31,0,6-2.69,6-6S20.31,11,17,11L17,11z" />
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:fillColor="#FA903E"
|
||||
android:pathData="M17,14v3l-2.12,2.12C15.42,19.66,16.17,20,17,20c1.66,0,3-1.34,3-3S18.66,14,17,14z" />
|
||||
</vector>
|
||||
@@ -27,5 +27,6 @@
|
||||
<color name="notification_importance_selection_bg">@*android:color/material_grey_800</color>
|
||||
<color name="notification_importance_button_selected">#AECBFA</color> <!-- material blue 200 -->
|
||||
<color name="notification_importance_button_unselected">#5F6368</color>
|
||||
<color name="face_intro_outline">?android:attr/colorAccent</color>
|
||||
</resources>
|
||||
|
||||
|
||||
@@ -147,4 +147,5 @@
|
||||
<!-- Dialog background color -->
|
||||
<color name="dialog_background">@*android:color/background_device_default_light</color>
|
||||
|
||||
<color name="face_intro_outline">#ffdadce0</color>
|
||||
</resources>
|
||||
@@ -10207,7 +10207,7 @@
|
||||
<!-- Title text for swipe up to switch apps [CHAR LIMIT=60] -->
|
||||
<string name="swipe_up_to_switch_apps_title">2-button navigation</string>
|
||||
<!-- Summary text for swipe up to switch apps [CHAR LIMIT=250] -->
|
||||
<string name="swipe_up_to_switch_apps_summary">To switch apps, swipe up on the Home button. Swipe up again to see all apps. Works from any screen. You’ll no longer have an Overview button on the bottom right of your screen.</string>
|
||||
<string name="swipe_up_to_switch_apps_summary">To switch apps, swipe up on the Home button. To see all apps, swipe up again. To go back, tap the back button.</string>
|
||||
<!-- Title for settings suggestion for swipe up to switch apps [CHAR LIMIT=60] -->
|
||||
<string name="swipe_up_to_switch_apps_suggestion_title">Try the new Home button</string>
|
||||
<!-- Summary for settings suggestion for swipe up to switch apps [CHAR LIMIT=60] -->
|
||||
@@ -10216,12 +10216,12 @@
|
||||
<!-- Title text for edge to edge navigation [CHAR LIMIT=60] -->
|
||||
<string name="edge_to_edge_navigation_title">Gesture navigation</string>
|
||||
<!-- Summary text for edge to edge navigation [CHAR LIMIT=NONE] -->
|
||||
<string name="edge_to_edge_navigation_summary">To go Home, swipe up from the bottom of the screen. To go Back, swipe from either the left or right edge of the screen. To switch apps, start swiping up from the bottom of the screen and hold before releasing.</string>
|
||||
<string name="edge_to_edge_navigation_summary">To go Home, swipe up from the bottom of the screen. To switch apps, swipe up from the bottom, hold, then release. To go back, swipe from either the left or right edge.</string>
|
||||
|
||||
<!-- Title text for 3-button navigation [CHAR LIMIT=60] -->
|
||||
<string name="legacy_navigation_title">3-button navigation</string>
|
||||
<!-- Summary text for 3-button navigation [CHAR LIMIT=NONE] -->
|
||||
<string name="legacy_navigation_summary">Classic Android navigation mode where going Home, switching apps, and going Back are accessible via buttons.</string>
|
||||
<string name="legacy_navigation_summary">Go back, Home, and switch apps with buttons at the bottom of your screen.</string>
|
||||
|
||||
<!-- Search keywords for System Navigation settings. [CHAR_LIMIT=NONE]-->
|
||||
<string name="keywords_system_navigation">system navigation, 2 button navigation, 3 button navigation, gesture navigation</string>
|
||||
@@ -10991,6 +10991,20 @@
|
||||
<!-- Label for the off position of a switch on the mobile network details page which allows
|
||||
disabling/enabling a SIM. The SIM is disabled in this state. [CHAR LIMIT=40] -->
|
||||
<string name="mobile_network_use_sim_off">Off</string>
|
||||
<!-- Text shown in an information footer on the SIM details page for a physical SIM notifying
|
||||
the user that the way to disable this SIM is to physically remove it. This is in contrast
|
||||
to eSIM's, which can disabled using an on/off toggle switch. [CHAR LIMIT=NONE] -->
|
||||
<string name="mobile_network_disable_sim_explanation">
|
||||
To disable this SIM, remove the SIM card
|
||||
</string>
|
||||
|
||||
<!--Summary used when a physical SIM is disabled, indicating that tapping on the preference will
|
||||
enable the SIM. This may be used as the summary of the 'Mobile network' item on the
|
||||
Network & internet page (if there are no other SIMs), or on the mobile network list page.
|
||||
[CHAR LIMIT=50] -->
|
||||
<string name="mobile_network_tap_to_activate">
|
||||
Tap to activate <xliff:g id="carrier" example="T-mobile">%1$s</xliff:g>
|
||||
</string>
|
||||
|
||||
<!-- Title for a confirmation dialog when the user is enabling an eSIM subscription and there
|
||||
is already another active eSIM subscription which will need to be disabled if they proceed.
|
||||
|
||||
@@ -21,7 +21,6 @@ import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.Resources.Theme;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
@@ -44,6 +43,7 @@ import com.google.android.setupdesign.GlifLayout;
|
||||
*/
|
||||
public abstract class BiometricEnrollBase extends InstrumentedActivity {
|
||||
|
||||
public static final String EXTRA_FROM_SETTINGS_SUMMARY = "from_settings_summary";
|
||||
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";
|
||||
@@ -81,16 +81,20 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
|
||||
protected boolean mLaunchedConfirmLock;
|
||||
protected byte[] mToken;
|
||||
protected int mUserId;
|
||||
protected boolean mFromSettingsSummary;
|
||||
protected FooterBarMixin mFooterBarMixin;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mToken = getIntent().getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
|
||||
mFromSettingsSummary = getIntent().getBooleanExtra(EXTRA_FROM_SETTINGS_SUMMARY, false);
|
||||
if (savedInstanceState != null && mToken == null) {
|
||||
mLaunchedConfirmLock = savedInstanceState.getBoolean(EXTRA_KEY_LAUNCHED_CONFIRM);
|
||||
mToken = savedInstanceState.getByteArray(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
|
||||
mFromSettingsSummary =
|
||||
savedInstanceState.getBoolean(EXTRA_FROM_SETTINGS_SUMMARY, false);
|
||||
}
|
||||
mUserId = getIntent().getIntExtra(Intent.EXTRA_USER_ID, UserHandle.myUserId());
|
||||
}
|
||||
@@ -107,6 +111,7 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(EXTRA_KEY_LAUNCHED_CONFIRM, mLaunchedConfirmLock);
|
||||
outState.putByteArray(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
|
||||
outState.putBoolean(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,6 +159,7 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
|
||||
Intent intent = new Intent();
|
||||
intent.setClassName(SETTINGS_PACKAGE_NAME, FingerprintEnrollEnrolling.class.getName());
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
|
||||
intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
|
||||
if (mUserId != UserHandle.USER_NULL) {
|
||||
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
|
||||
}
|
||||
|
||||
@@ -214,6 +214,7 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
|
||||
if (mUserId != UserHandle.USER_NULL) {
|
||||
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
|
||||
}
|
||||
intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
|
||||
startActivityForResult(intent, BIOMETRIC_FIND_SENSOR_REQUEST);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.settings.biometrics;
|
||||
|
||||
import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
|
||||
import static com.android.settings.biometrics.BiometricEnrollBase.EXTRA_FROM_SETTINGS_SUMMARY;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -118,6 +119,7 @@ public abstract class BiometricStatusPreferenceController extends BasePreference
|
||||
Intent intent = new Intent();
|
||||
intent.setClassName(SETTINGS_PACKAGE_NAME, clazz);
|
||||
intent.putExtra(Intent.EXTRA_USER_ID, userId);
|
||||
intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, true);
|
||||
context.startActivity(intent);
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -107,6 +107,7 @@ 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(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
|
||||
if (mUserId != UserHandle.USER_NULL) {
|
||||
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
|
||||
}
|
||||
|
||||
@@ -169,6 +169,15 @@ public class FaceEnrollEducation extends BiometricEnrollBase {
|
||||
super.onResume();
|
||||
mSwitchDiversityListener.onCheckedChanged(mSwitchDiversity.getSwitch(),
|
||||
mSwitchDiversity.isChecked());
|
||||
|
||||
// If the user goes back after enrollment, we should send them back to the intro page
|
||||
// if they've met the max limit.
|
||||
final int max = getResources().getInteger(
|
||||
com.android.internal.R.integer.config_faceMaxTemplatesPerUser);
|
||||
final int numEnrolledFaces = mFaceManager.getEnrolledFaces(mUserId).size();
|
||||
if (numEnrolledFaces >= max) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -110,7 +110,8 @@ public class FingerprintEnrollFinish extends BiometricEnrollBase {
|
||||
setResult(RESULT_FINISHED);
|
||||
if (WizardManagerHelper.isAnySetupWizard(getIntent())) {
|
||||
postEnroll();
|
||||
} else {
|
||||
} else if (mFromSettingsSummary) {
|
||||
// Only launch fingerprint settings if enrollment was triggered through settings summary
|
||||
launchFingerprintSettings();
|
||||
}
|
||||
finish();
|
||||
@@ -150,7 +151,7 @@ public class FingerprintEnrollFinish extends BiometricEnrollBase {
|
||||
final Intent intent = new Intent(ACTION_FINGERPRINT_SETTINGS);
|
||||
intent.setPackage(Utils.SETTINGS_PACKAGE_NAME);
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.settings.homepage.contextualcards.slices;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
|
||||
import static com.android.settings.display.AdaptiveSleepPreferenceController.PREF_NAME;
|
||||
import static com.android.settings.display.AdaptiveSleepPreferenceController.isControllerAvailable;
|
||||
import static com.android.settings.slices.CustomSliceRegistry.CONTEXTUAL_ADAPTIVE_SLEEP_URI;
|
||||
@@ -90,6 +90,7 @@ public class ContextualAdaptiveSleepSlice implements CustomSliceable {
|
||||
final ListBuilder listBuilder = new ListBuilder(mContext,
|
||||
CONTEXTUAL_ADAPTIVE_SLEEP_URI,
|
||||
ListBuilder.INFINITY)
|
||||
.setAccentColor(COLOR_NOT_TINTED)
|
||||
.addRow(new ListBuilder.RowBuilder()
|
||||
.setTitleItem(icon, ListBuilder.ICON_IMAGE)
|
||||
.setTitle(title)
|
||||
@@ -150,6 +151,6 @@ public class ContextualAdaptiveSleepSlice implements CustomSliceable {
|
||||
*/
|
||||
@VisibleForTesting
|
||||
boolean isSettingsAvailable() {
|
||||
return isControllerAvailable(mContext) == AVAILABLE;
|
||||
return isControllerAvailable(mContext) == AVAILABLE_UNSEARCHABLE;
|
||||
}
|
||||
}
|
||||
@@ -61,12 +61,13 @@ public class RoamingDialogFragment extends InstrumentedDialogFragment implements
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
int title = R.string.roaming_alert_title;
|
||||
int message = R.string.roaming_warning;
|
||||
PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
|
||||
if (carrierConfig != null && carrierConfig.getBoolean(
|
||||
CarrierConfigManager.KEY_CHECK_PRICING_WITH_CARRIER_FOR_DATA_ROAMING_BOOL)) {
|
||||
title = R.string.roaming_check_price_warning;
|
||||
message = R.string.roaming_check_price_warning;
|
||||
}
|
||||
builder.setMessage(getResources().getString(R.string.roaming_warning))
|
||||
builder.setMessage(getResources().getString(message))
|
||||
.setTitle(title)
|
||||
.setIconAttribute(android.R.attr.alertDialogIcon)
|
||||
.setPositiveButton(android.R.string.yes, this)
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.settings.nfc;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.ContentObserver;
|
||||
import android.net.Uri;
|
||||
import android.nfc.NfcAdapter;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
/**
|
||||
* NfcAirplaneModeObserver is a helper to manage the Nfc on/off when airplane mode status
|
||||
* is changed.
|
||||
*/
|
||||
public class NfcAirplaneModeObserver extends ContentObserver {
|
||||
|
||||
private final Context mContext;
|
||||
private final NfcAdapter mNfcAdapter;
|
||||
private final Preference mPreference;
|
||||
private int mAirplaneMode;
|
||||
|
||||
@VisibleForTesting
|
||||
final static Uri AIRPLANE_MODE_URI =
|
||||
Settings.Global.getUriFor(Settings.Global.AIRPLANE_MODE_ON);
|
||||
|
||||
public NfcAirplaneModeObserver(Context context, NfcAdapter nfcAdapter, Preference preference) {
|
||||
super(new Handler(Looper.getMainLooper()));
|
||||
mContext = context;
|
||||
mNfcAdapter = nfcAdapter;
|
||||
mPreference = preference;
|
||||
updateNfcPreference();
|
||||
}
|
||||
|
||||
public void register() {
|
||||
mContext.getContentResolver().registerContentObserver(AIRPLANE_MODE_URI, false, this);
|
||||
}
|
||||
|
||||
public void unregister() {
|
||||
mContext.getContentResolver().unregisterContentObserver(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
super.onChange(selfChange, uri);
|
||||
updateNfcPreference();
|
||||
}
|
||||
|
||||
private void updateNfcPreference() {
|
||||
final int airplaneMode = Settings.Global.getInt(
|
||||
mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, mAirplaneMode);
|
||||
if (airplaneMode == mAirplaneMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
mAirplaneMode = airplaneMode;
|
||||
if (mAirplaneMode == 1) {
|
||||
// airplane mode is on, need to turn off NFC, and check if user can toggle it
|
||||
mNfcAdapter.disable();
|
||||
mPreference.setEnabled(NfcPreferenceController.isToggleableInAirplaneMode(mContext));
|
||||
} else {
|
||||
// airplane mode is off, no restriction
|
||||
mPreference.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,8 +41,6 @@ public class NfcPreferenceController extends TogglePreferenceController
|
||||
public static final String KEY_TOGGLE_NFC = "toggle_nfc";
|
||||
private final NfcAdapter mNfcAdapter;
|
||||
private NfcEnabler mNfcEnabler;
|
||||
@VisibleForTesting
|
||||
NfcAirplaneModeObserver mAirplaneModeObserver;
|
||||
|
||||
public NfcPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
@@ -61,11 +59,6 @@ public class NfcPreferenceController extends TogglePreferenceController
|
||||
|
||||
mNfcEnabler = new NfcEnabler(mContext, switchPreference);
|
||||
|
||||
// Listen to airplane mode updates if NFC should be turned off when airplane mode is on
|
||||
if (shouldTurnOffNFCInAirplaneMode(mContext) || isToggleableInAirplaneMode(mContext)) {
|
||||
mAirplaneModeObserver =
|
||||
new NfcAirplaneModeObserver(mContext, mNfcAdapter, switchPreference);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,9 +101,6 @@ public class NfcPreferenceController extends TogglePreferenceController
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
if (mAirplaneModeObserver != null) {
|
||||
mAirplaneModeObserver.register();
|
||||
}
|
||||
if (mNfcEnabler != null) {
|
||||
mNfcEnabler.resume();
|
||||
}
|
||||
@@ -118,9 +108,6 @@ public class NfcPreferenceController extends TogglePreferenceController
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
if (mAirplaneModeObserver != null) {
|
||||
mAirplaneModeObserver.unregister();
|
||||
}
|
||||
if (mNfcEnabler != null) {
|
||||
mNfcEnabler.pause();
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class GentleDrawablePreferenceController extends BasePreferenceController
|
||||
|
||||
private boolean showOnLockscreen() {
|
||||
return Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0) == ON;
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, ON) == ON;
|
||||
}
|
||||
|
||||
private boolean showOnStatusBar() {
|
||||
|
||||
@@ -69,7 +69,7 @@ public class GentleNotificationsPreferenceController extends BasePreferenceContr
|
||||
|
||||
private boolean showOnLockscreen() {
|
||||
return Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0) == ON;
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, ON) == ON;
|
||||
}
|
||||
|
||||
private boolean showOnStatusBar() {
|
||||
|
||||
@@ -66,7 +66,7 @@ public class ImportancePreferenceController extends NotificationPreferenceContro
|
||||
pref.setImportance(mChannel.getImportance());
|
||||
pref.setDisplayInStatusBar(mBackend.showSilentInStatusBar(mContext.getPackageName()));
|
||||
pref.setDisplayOnLockscreen(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0) == 1);
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1) == 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,11 +150,11 @@ public class ShowOnLockScreenNotificationPreferenceController extends AbstractPr
|
||||
|
||||
private boolean getLockscreenNotificationsEnabled() {
|
||||
return Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1) != 0;
|
||||
}
|
||||
|
||||
private boolean getLockscreenSilentNotificationsEnabled() {
|
||||
return Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0) != 0;
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class SilentLockscreenPreferenceController extends TogglePreferenceContro
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0) == 1;
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1) == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -52,6 +52,7 @@ public final class WifiNoInternetDialog extends AlertActivity implements
|
||||
private ConnectivityManager.NetworkCallback mNetworkCallback;
|
||||
private CheckBox mAlwaysAllow;
|
||||
private String mAction;
|
||||
private boolean mButtonClicked;
|
||||
|
||||
private boolean isKnownAction(Intent intent) {
|
||||
return intent.getAction().equals(ACTION_PROMPT_UNVALIDATED)
|
||||
@@ -169,14 +170,31 @@ public final class WifiNoInternetDialog extends AlertActivity implements
|
||||
mCM.unregisterNetworkCallback(mNetworkCallback);
|
||||
mNetworkCallback = null;
|
||||
}
|
||||
|
||||
// If the user exits the no Internet or partial connectivity dialog without taking any
|
||||
// action, disconnect the network, because once the dialog has been dismissed there is no
|
||||
// way to use the network.
|
||||
//
|
||||
// Unfortunately, AlertDialog does not seem to offer any good way to get an onCancel or
|
||||
// onDismiss callback. So we implement this ourselves.
|
||||
if (isFinishing() && !mButtonClicked) {
|
||||
if (ACTION_PROMPT_PARTIAL_CONNECTIVITY.equals(mAction)) {
|
||||
mCM.setAcceptPartialConnectivity(mNetwork, false /* accept */, false /* always */);
|
||||
} else if (ACTION_PROMPT_UNVALIDATED.equals(mAction)) {
|
||||
mCM.setAcceptUnvalidated(mNetwork, false /* accept */, false /* always */);
|
||||
}
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which != BUTTON_NEGATIVE && which != BUTTON_POSITIVE) return;
|
||||
final boolean always = mAlwaysAllow.isChecked();
|
||||
final String what, action;
|
||||
|
||||
mButtonClicked = true;
|
||||
|
||||
if (ACTION_PROMPT_UNVALIDATED.equals(mAction)) {
|
||||
what = "NO_INTERNET";
|
||||
final boolean accept = (which == BUTTON_POSITIVE);
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.nfc;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.nfc.NfcAdapter;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.Global;
|
||||
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.testutils.shadow.ShadowNfcAdapter;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = {ShadowNfcAdapter.class})
|
||||
public class NfcAirplaneModeObserverTest {
|
||||
|
||||
private Context mContext;
|
||||
private NfcAdapter mNfcAdapter;
|
||||
private SwitchPreference mNfcPreference;
|
||||
private NfcAirplaneModeObserver mNfcAirplaneModeObserver;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mNfcAdapter = NfcAdapter.getDefaultAdapter(mContext);
|
||||
|
||||
mNfcPreference = new SwitchPreference(mContext);
|
||||
|
||||
mNfcAirplaneModeObserver =
|
||||
new NfcAirplaneModeObserver(mContext, mNfcAdapter, mNfcPreference);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void NfcAirplaneModeObserver_airplaneOn_shouldDisableNfc() {
|
||||
ReflectionHelpers.setField(mNfcAirplaneModeObserver,
|
||||
"mAirplaneMode", 0);
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.AIRPLANE_MODE_ON, 1);
|
||||
|
||||
mNfcAirplaneModeObserver.onChange(false,
|
||||
NfcAirplaneModeObserver.AIRPLANE_MODE_URI);
|
||||
|
||||
assertThat(mNfcAdapter.isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void NfcAirplaneModeObserver_airplaneModeOnNfcToggleable_shouldEnablePreference() {
|
||||
ReflectionHelpers.setField(mNfcAirplaneModeObserver, "mAirplaneMode", 0);
|
||||
final ContentResolver contentResolver = mContext.getContentResolver();
|
||||
Settings.Global.putInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 1);
|
||||
Settings.Global.putString(contentResolver,
|
||||
Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS, Settings.Global.RADIO_NFC);
|
||||
|
||||
mNfcAirplaneModeObserver.onChange(false, NfcAirplaneModeObserver.AIRPLANE_MODE_URI);
|
||||
|
||||
assertThat(mNfcPreference.isEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void NfcAirplaneModeObserver_airplaneModeOnNfcNotToggleable_shouldDisablePreference() {
|
||||
ReflectionHelpers.setField(mNfcAirplaneModeObserver, "mAirplaneMode", 0);
|
||||
final ContentResolver contentResolver = mContext.getContentResolver();
|
||||
Settings.Global.putInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 1);
|
||||
Settings.Global.putString(contentResolver,
|
||||
Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS, Global.RADIO_WIFI);
|
||||
|
||||
mNfcAirplaneModeObserver.onChange(false, NfcAirplaneModeObserver.AIRPLANE_MODE_URI);
|
||||
|
||||
assertThat(mNfcPreference.isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void NfcAirplaneModeObserver_airplaneModeOff_shouldEnablePreference() {
|
||||
ReflectionHelpers.setField(mNfcAirplaneModeObserver, "mAirplaneMode", 1);
|
||||
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0);
|
||||
|
||||
mNfcAirplaneModeObserver.onChange(false, NfcAirplaneModeObserver.AIRPLANE_MODE_URI);
|
||||
|
||||
assertThat(mNfcPreference.isEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void NfcAirplaneModeObserver_airplaneModeOff_shouldNotEnableNfcAutomatically() {
|
||||
ReflectionHelpers.setField(mNfcAirplaneModeObserver, "mAirplaneMode", 1);
|
||||
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0);
|
||||
|
||||
mNfcAirplaneModeObserver.onChange(false, NfcAirplaneModeObserver.AIRPLANE_MODE_URI);
|
||||
|
||||
assertThat(mNfcAdapter.isEnabled()).isFalse();
|
||||
}
|
||||
}
|
||||
@@ -222,38 +222,6 @@ public class NfcPreferenceControllerTest {
|
||||
assertThat(NfcPreferenceController.shouldTurnOffNFCInAirplaneMode(mContext)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void displayPreference_airplaneModeRadiosContainsNfc_shouldCreateAirplaneModeObserver() {
|
||||
Settings.Global.putString(mContext.getContentResolver(),
|
||||
Settings.Global.AIRPLANE_MODE_RADIOS, Settings.Global.RADIO_NFC);
|
||||
|
||||
mNfcController.displayPreference(mScreen);
|
||||
|
||||
assertThat(mNfcController.mAirplaneModeObserver).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void displayPreference_nfcToggleableInAirplaneMode_shouldCreateAirplaneModeObserver() {
|
||||
Settings.Global.putString(mContext.getContentResolver(),
|
||||
Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS, Settings.Global.RADIO_NFC);
|
||||
|
||||
mNfcController.displayPreference(mScreen);
|
||||
|
||||
assertThat(mNfcController.mAirplaneModeObserver).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void displayPreference_nfcNotAffectByAirplaneMode_shouldNotCreateAirplaneModeObserver() {
|
||||
Settings.Global.putString(mContext.getContentResolver(),
|
||||
Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS, "");
|
||||
Settings.Global.putString(mContext.getContentResolver(),
|
||||
Settings.Global.AIRPLANE_MODE_RADIOS, "");
|
||||
|
||||
mNfcController.displayPreference(mScreen);
|
||||
|
||||
assertThat(mNfcController.mAirplaneModeObserver).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ncfSliceWorker_nfcBroadcast_noExtra_sliceDoesntUpdate() {
|
||||
final NfcSliceWorker worker = spy(new NfcSliceWorker(mContext, getDummyUri()));
|
||||
|
||||
@@ -132,6 +132,18 @@ public class ShowOnLockscreenNotificationPreferenceControllerTest {
|
||||
.isEqualTo(mContext.getString(R.string.lock_screen_notifs_show_all));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_allNotifsOnLockscreen_isDefault() {
|
||||
// settings don't exist
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.getValue()).isEqualTo(
|
||||
String.valueOf(R.string.lock_screen_notifs_show_all));
|
||||
assertThat(mPreference.getSummary())
|
||||
.isEqualTo(mContext.getString(R.string.lock_screen_notifs_show_all));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_dpmSaysNo() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
|
||||
Reference in New Issue
Block a user