diff --git a/res/values/strings.xml b/res/values/strings.xml index f1acce7a417..b2306deb380 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -10201,7 +10201,7 @@ 2-button navigation - 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. + To switch apps, swipe up on the Home button. To see all apps, swipe up again. To go back, tap the back button. Try the new Home button @@ -10210,12 +10210,12 @@ Gesture navigation - 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. + 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. 3-button navigation - Classic Android navigation mode where going Home, switching apps, and going Back are accessible via buttons. + Go back, Home, and switch apps with buttons at the bottom of your screen. system navigation, 2 button navigation, 3 button navigation, gesture navigation diff --git a/src/com/android/settings/biometrics/BiometricEnrollBase.java b/src/com/android/settings/biometrics/BiometricEnrollBase.java index 52eaa175fb0..c3f794f6905 100644 --- a/src/com/android/settings/biometrics/BiometricEnrollBase.java +++ b/src/com/android/settings/biometrics/BiometricEnrollBase.java @@ -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); } diff --git a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java index 85e4acd13d9..d5414c9664d 100644 --- a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java +++ b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java @@ -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); } diff --git a/src/com/android/settings/biometrics/BiometricStatusPreferenceController.java b/src/com/android/settings/biometrics/BiometricStatusPreferenceController.java index 156d663dfff..62dc1cf1fae 100644 --- a/src/com/android/settings/biometrics/BiometricStatusPreferenceController.java +++ b/src/com/android/settings/biometrics/BiometricStatusPreferenceController.java @@ -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; }); diff --git a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java index 12ffc6ba0ad..a2460553e26 100644 --- a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java +++ b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java @@ -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); } diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java index 02b07236ab3..5f4501580ed 100644 --- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java +++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java @@ -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); } diff --git a/src/com/android/settings/nfc/NfcAirplaneModeObserver.java b/src/com/android/settings/nfc/NfcAirplaneModeObserver.java deleted file mode 100644 index afb5616a4fa..00000000000 --- a/src/com/android/settings/nfc/NfcAirplaneModeObserver.java +++ /dev/null @@ -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); - } - } -} diff --git a/src/com/android/settings/nfc/NfcPreferenceController.java b/src/com/android/settings/nfc/NfcPreferenceController.java index 2ca3b23daea..34e7e24efd6 100644 --- a/src/com/android/settings/nfc/NfcPreferenceController.java +++ b/src/com/android/settings/nfc/NfcPreferenceController.java @@ -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(); } diff --git a/src/com/android/settings/notification/GentleDrawablePreferenceController.java b/src/com/android/settings/notification/GentleDrawablePreferenceController.java index cdadf5acd24..b4e18db27d3 100644 --- a/src/com/android/settings/notification/GentleDrawablePreferenceController.java +++ b/src/com/android/settings/notification/GentleDrawablePreferenceController.java @@ -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() { diff --git a/src/com/android/settings/notification/GentleNotificationsPreferenceController.java b/src/com/android/settings/notification/GentleNotificationsPreferenceController.java index 97e4e252d17..ea16e726846 100644 --- a/src/com/android/settings/notification/GentleNotificationsPreferenceController.java +++ b/src/com/android/settings/notification/GentleNotificationsPreferenceController.java @@ -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() { diff --git a/src/com/android/settings/notification/ImportancePreferenceController.java b/src/com/android/settings/notification/ImportancePreferenceController.java index dc592754c7d..4ef459370d5 100644 --- a/src/com/android/settings/notification/ImportancePreferenceController.java +++ b/src/com/android/settings/notification/ImportancePreferenceController.java @@ -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); } } diff --git a/src/com/android/settings/notification/ShowOnLockScreenNotificationPreferenceController.java b/src/com/android/settings/notification/ShowOnLockScreenNotificationPreferenceController.java index 5d08ac796d1..df1f4a21eb0 100644 --- a/src/com/android/settings/notification/ShowOnLockScreenNotificationPreferenceController.java +++ b/src/com/android/settings/notification/ShowOnLockScreenNotificationPreferenceController.java @@ -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; } } diff --git a/src/com/android/settings/notification/SilentLockscreenPreferenceController.java b/src/com/android/settings/notification/SilentLockscreenPreferenceController.java index 219d312b956..317f7da6e33 100644 --- a/src/com/android/settings/notification/SilentLockscreenPreferenceController.java +++ b/src/com/android/settings/notification/SilentLockscreenPreferenceController.java @@ -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 diff --git a/src/com/android/settings/wifi/WifiNoInternetDialog.java b/src/com/android/settings/wifi/WifiNoInternetDialog.java index e33cab6de29..eb42097fa16 100644 --- a/src/com/android/settings/wifi/WifiNoInternetDialog.java +++ b/src/com/android/settings/wifi/WifiNoInternetDialog.java @@ -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); diff --git a/tests/robotests/src/com/android/settings/nfc/NfcAirplaneModeObserverTest.java b/tests/robotests/src/com/android/settings/nfc/NfcAirplaneModeObserverTest.java deleted file mode 100644 index 06d9773deb7..00000000000 --- a/tests/robotests/src/com/android/settings/nfc/NfcAirplaneModeObserverTest.java +++ /dev/null @@ -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(); - } -} diff --git a/tests/robotests/src/com/android/settings/nfc/NfcPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/nfc/NfcPreferenceControllerTest.java index e3672c92dc9..b7efc22c83a 100644 --- a/tests/robotests/src/com/android/settings/nfc/NfcPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/nfc/NfcPreferenceControllerTest.java @@ -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())); diff --git a/tests/robotests/src/com/android/settings/notification/ShowOnLockscreenNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ShowOnLockscreenNotificationPreferenceControllerTest.java index 6907051ea86..a341def3ed5 100644 --- a/tests/robotests/src/com/android/settings/notification/ShowOnLockscreenNotificationPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/ShowOnLockscreenNotificationPreferenceControllerTest.java @@ -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(),