Merge "Import translations. DO NOT MERGE" into qt-dev
diff --git a/src/com/android/settings/biometrics/BiometricEnrollBase.java b/src/com/android/settings/biometrics/BiometricEnrollBase.java
index 52eaa17..c3f794f 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollBase.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollBase.java
@@ -21,7 +21,6 @@
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 @@
*/
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 @@
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 @@
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 @@
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 85e4acd..d5414c9 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
@@ -214,6 +214,7 @@
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 156d663..62dc1cf 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 @@
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 12ffc6b..a246055 100644
--- a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
@@ -107,6 +107,7 @@
| 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 02b0723..5f45015 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
@@ -110,7 +110,8 @@
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 @@
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 afb5616..0000000
--- 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 2ca3b23..34e7e24 100644
--- a/src/com/android/settings/nfc/NfcPreferenceController.java
+++ b/src/com/android/settings/nfc/NfcPreferenceController.java
@@ -41,8 +41,6 @@
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 @@
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 @@
@Override
public void onResume() {
- if (mAirplaneModeObserver != null) {
- mAirplaneModeObserver.register();
- }
if (mNfcEnabler != null) {
mNfcEnabler.resume();
}
@@ -118,9 +108,6 @@
@Override
public void onPause() {
- if (mAirplaneModeObserver != null) {
- mAirplaneModeObserver.unregister();
- }
if (mNfcEnabler != null) {
mNfcEnabler.pause();
}
diff --git a/src/com/android/settings/wifi/WifiNoInternetDialog.java b/src/com/android/settings/wifi/WifiNoInternetDialog.java
index e33cab6..eb42097 100644
--- a/src/com/android/settings/wifi/WifiNoInternetDialog.java
+++ b/src/com/android/settings/wifi/WifiNoInternetDialog.java
@@ -52,6 +52,7 @@
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 @@
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 06d9773..0000000
--- 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 e3672c9..b7efc22 100644
--- a/tests/robotests/src/com/android/settings/nfc/NfcPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/nfc/NfcPreferenceControllerTest.java
@@ -223,38 +223,6 @@
}
@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()));
final NfcUpdateReceiver receiver = worker.new NfcUpdateReceiver(worker);