Snap for 5645017 from 2bcfecdb21 to qt-release

Change-Id: I87b7cdd74db6c108706bae3448421444779cecea
This commit is contained in:
android-build-team Robot
2019-06-08 23:13:33 +00:00
17 changed files with 53 additions and 257 deletions

View File

@@ -10201,7 +10201,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. Youll 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] -->
@@ -10210,12 +10210,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>

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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;
});

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}
}
}

View File

@@ -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();
}

View File

@@ -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() {

View File

@@ -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() {

View File

@@ -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);
}
}

View File

@@ -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;
}
}

View File

@@ -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

View File

@@ -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);

View File

@@ -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();
}
}

View File

@@ -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()));

View File

@@ -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(),