Merge "Index TTS-Settings and dedupe TTS-engine in search result."
diff --git a/res/drawable-nodpi/fingerprint_enroll_introduction.png b/res/drawable-nodpi/fingerprint_enroll_introduction.png
new file mode 100644
index 0000000..268ca43
--- /dev/null
+++ b/res/drawable-nodpi/fingerprint_enroll_introduction.png
Binary files differ
diff --git a/res/layout/choose_lock_password.xml b/res/layout/choose_lock_password.xml
index 7ce3034..f1b631e 100644
--- a/res/layout/choose_lock_password.xml
+++ b/res/layout/choose_lock_password.xml
@@ -21,7 +21,7 @@
android:layout_height="match_parent"
android:icon="@drawable/ic_lock"
settings:suwFooter="@layout/choose_lock_password_footer"
- settings:suwHeaderText="@string/lockpassword_choose_your_password_header">
+ settings:suwHeaderText="@string/lockpassword_choose_your_screen_lock_header">
<LinearLayout
style="@style/SuwContentFrame"
@@ -33,11 +33,11 @@
android:orientation="vertical">
<TextView
- android:id="@+id/fingerprint_backup_message"
+ android:id="@+id/message"
style="@style/SuwDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:visibility="gone" />
+ android:minLines="2"/>
<LinearLayout
android:id="@+id/password_container"
diff --git a/res/layout/fingerprint_enroll_introduction.xml b/res/layout/fingerprint_enroll_introduction.xml
index 4f73395..4228f42 100644
--- a/res/layout/fingerprint_enroll_introduction.xml
+++ b/res/layout/fingerprint_enroll_introduction.xml
@@ -45,6 +45,20 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />
+ <com.android.setupwizardlib.view.FillContentLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1">
+
+ <ImageView
+ style="@style/SuwContentIllustration"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:contentDescription="@null"
+ android:src="@drawable/fingerprint_enroll_introduction" />
+
+ </com.android.setupwizardlib.view.FillContentLayout>
+
</LinearLayout>
</com.android.setupwizardlib.GlifLayout>
diff --git a/res/layout/setup_choose_lock_generic_fingerprint_header.xml b/res/layout/setup_choose_lock_generic_fingerprint_header.xml
index 4c696f3..ec5d750 100644
--- a/res/layout/setup_choose_lock_generic_fingerprint_header.xml
+++ b/res/layout/setup_choose_lock_generic_fingerprint_header.xml
@@ -23,4 +23,4 @@
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingTop="@dimen/suw_description_glif_margin_top"
android:paddingBottom="@dimen/suw_description_glif_margin_bottom_lists"
- android:text="@string/setup_lock_settings_picker_fingerprint_message" />
+ android:text="@string/lock_settings_picker_fingerprint_added_security_message" />
diff --git a/res/layout/video_preference.xml b/res/layout/video_preference.xml
index 8b0e619..9ab52ae 100644
--- a/res/layout/video_preference.xml
+++ b/res/layout/video_preference.xml
@@ -28,7 +28,7 @@
<com.android.settings.widget.AspectRatioFrameLayout
android:layout_width="240dp"
- android:layout_height="wrap_content"
+ android:layout_height="240dp"
android:padding="@dimen/gesture_animation_padding">
<TextureView
diff --git a/res/values/strings.xml b/res/values/strings.xml
index aacb8a1..4022423 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1109,8 +1109,8 @@
<!-- Title for security picker in setup wizard to choose the unlock method: None/Pattern/PIN/Password (phone) [CHAR LIMIT=22] -->
<string name="setup_lock_settings_picker_title" product="default">Protect your phone</string>
- <!-- Title for screen in setup wizard, prompting user to choose the their backup screen lock method [CHAR LIMIT=NONE] -->
- <string name="setup_lock_settings_picker_fingerprint_message">For added security, set up a backup screen lock.</string>
+ <!-- Message shown when setting up screen lock, prompting user to choose the their backup screen lock method [CHAR LIMIT=NONE] -->
+ <string name="lock_settings_picker_fingerprint_added_security_message">For added security, set up a backup screen lock.</string>
<!-- Description text for screen in setup wizard asking user to set up screen lock, explaining to the user how setting up a screen lock protect them from losing data. (tablet) [CHAR LIMIT=NONE] -->
<string name="setup_lock_settings_picker_message" product="tablet">Prevent others from using this tablet without your permission by activating device protection features. Choose the screen lock you want to use.</string>
@@ -3432,23 +3432,25 @@
<!-- Lock Pattern settings -->
<!-- Header on first screen of choose password/PIN flow [CHAR LIMIT=40] -->
- <string name="lockpassword_choose_your_password_header">Choose your password</string>
+ <string name="lockpassword_choose_your_screen_lock_header">Set a screen lock</string>
+ <!-- Message on first screen of choose password flow [CHAR LIMIT=NONE] -->
+ <string name="lockpassword_choose_your_password_message">For security, set a password</string>
<!-- Header on first screen of choose password/PIN as backup for fingerprint flow. If this string cannot be translated in under 40 characters, please translate "Set fingerprint backup" [CHAR LIMIT=40] -->
<string name="lockpassword_choose_your_password_header_for_fingerprint">To use fingerprint, set password</string>
<!-- Header on first screen of choose pattern flow [CHAR LIMIT=40] -->
<string name="lockpassword_choose_your_pattern_header">Choose your pattern</string>
<!-- Header on first screen of choose pattern as backup for fingerprint flow. If this string cannot be translated in under 40 characters, please translate "Set fingerprint backup" [CHAR LIMIT=40] -->
<string name="lockpassword_choose_your_pattern_header_for_fingerprint">To use fingerprint, set pattern</string>
- <!-- Header on first screen of choose password/PIN flow [CHAR LIMIT=40] -->
- <string name="lockpassword_choose_your_pin_header">Choose your PIN</string>
+ <!-- Message on first screen of choose PIN flow [CHAR LIMIT=NONE] -->
+ <string name="lockpassword_choose_your_pin_message">For security, set a PIN</string>
<!-- Header on first screen of choose password/PIN as backup for fingerprint flow. If this string cannot be translated in under 40 characters, please translate "Set fingerprint backup" [CHAR LIMIT=40] -->
<string name="lockpassword_choose_your_pin_header_for_fingerprint">To use fingerprint, set PIN</string>
- <!-- Header on password confirm screen [CHAR LIMIT=30] -->
- <string name="lockpassword_confirm_your_password_header">Confirm your password</string>
+ <!-- Header on password confirm screen [CHAR LIMIT=40] -->
+ <string name="lockpassword_confirm_your_password_header">Re-enter your password</string>
<!-- Header on pattern confirm screen [CHAR LIMIT=30] -->
<string name="lockpassword_confirm_your_pattern_header">Confirm your pattern</string>
- <!-- Header on password confirm screen [CHAR LIMIT=30] -->
- <string name="lockpassword_confirm_your_pin_header">Confirm your PIN</string>
+ <!-- Header on password confirm screen [CHAR LIMIT=40] -->
+ <string name="lockpassword_confirm_your_pin_header">Re-enter your PIN</string>
<!-- Header on password confirm screen if second password doesn't match the first. [CHAR LIMIT=30] -->
<string name="lockpassword_confirm_passwords_dont_match">Passwords don\u2019t match</string>
<!-- Header on pin confirm screen if second pin doesn't match the first. [CHAR LIMIT=30]-->
@@ -4274,6 +4276,8 @@
<string name="user_installed_services_category_title">Downloaded services</string>
<!-- Title for the accessibility preference category of settings considered to be experimental, meaning they might be changed or removed in the future. [CHAR LIMIT=50] -->
<string name="experimental_category_title">Experimental</string>
+ <!-- Title for feature flags dashboard DO NOT TRANSLATE -->
+ <string name="feature_flags_dashboard_title" translatable="false">Feature flags</string>
<!-- Title for the Talkback Accessibility Service. Displayed on the Accessibility Settings screen in Setup Wizard. [CHAR_LIMIT=25] -->
<string name="talkback_title">Talkback</string>
<!-- Summary for the Talkback Accessibility Service. Lets the user know that Talkback is a screenreader and that it is usually most helpful to blind and low vision users and whether the service is on. [CHAR_LIMIT=none] -->
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 1a8f3de..2610e08 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -25,7 +25,6 @@
<style name="GlifTheme" parent="SuwThemeGlif">
<!-- For all Alert Dialogs -->
<item name="android:alertDialogTheme">@style/ThemeOverlay.AlertDialog</item>
- <item name="android:colorPrimary">@color/suw_color_accent_dark</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
<item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
<item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
@@ -46,7 +45,6 @@
<style name="GlifTheme.Light" parent="SuwThemeGlif.Light">
<!-- For all Alert Dialogs -->
<item name="android:alertDialogTheme">@style/ThemeOverlay.AlertDialog</item>
- <item name="android:colorPrimary">@color/suw_color_accent_light</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
<item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
<item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
@@ -66,7 +64,6 @@
<style name="GlifV2Theme" parent="SuwThemeGlifV2">
<!-- For all Alert Dialogs -->
<item name="android:alertDialogTheme">@style/ThemeOverlay.AlertDialog</item>
- <item name="android:colorPrimary">@color/suw_color_accent_dark</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
<item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
<item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
@@ -87,7 +84,6 @@
<style name="GlifV2Theme.Light" parent="SuwThemeGlifV2.Light">
<!-- For all Alert Dialogs -->
<item name="android:alertDialogTheme">@style/ThemeOverlay.AlertDialog</item>
- <item name="android:colorPrimary">@color/suw_color_accent_light</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
<item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
<item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml
index 8992446..92205e4 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -167,6 +167,11 @@
android:key="camera_hal_hdrplus_switch"
android:title="@string/camera_hal_hdrplus_switch" />
+ <Preference
+ android:key="feature_flags_dashboard"
+ android:title="@string/feature_flags_dashboard_title"
+ android:fragment="com.android.settings.development.featureflags.FeatureFlagsDashboard"/>
+
</PreferenceCategory>
<PreferenceCategory android:key="debug_networking_category"
diff --git a/res/xml/security_settings_password_sub.xml b/res/xml/security_settings_password_sub.xml
index 46c4999..c0287c0 100644
--- a/res/xml/security_settings_password_sub.xml
+++ b/res/xml/security_settings_password_sub.xml
@@ -22,7 +22,7 @@
<com.android.settings.TimeoutListPreference
android:key="lock_after_timeout"
android:title="@string/lock_after_timeout"
- android:summary="@string/lock_after_timeout_summary"
+ android:summary="@string/summary_placeholder"
android:entries="@array/lock_after_timeout_entries"
android:entryValues="@array/lock_after_timeout_values" />
@@ -32,7 +32,6 @@
<com.android.settingslib.RestrictedPreference
android:key="owner_info_settings"
- android:title="@string/owner_info_settings_title"
- android:summary="@string/owner_info_settings_summary" />
+ android:title="@string/owner_info_settings_title" />
</PreferenceScreen>
diff --git a/res/xml/security_settings_pin_sub.xml b/res/xml/security_settings_pin_sub.xml
index 46c4999..c0287c0 100644
--- a/res/xml/security_settings_pin_sub.xml
+++ b/res/xml/security_settings_pin_sub.xml
@@ -22,7 +22,7 @@
<com.android.settings.TimeoutListPreference
android:key="lock_after_timeout"
android:title="@string/lock_after_timeout"
- android:summary="@string/lock_after_timeout_summary"
+ android:summary="@string/summary_placeholder"
android:entries="@array/lock_after_timeout_entries"
android:entryValues="@array/lock_after_timeout_values" />
@@ -32,7 +32,6 @@
<com.android.settingslib.RestrictedPreference
android:key="owner_info_settings"
- android:title="@string/owner_info_settings_title"
- android:summary="@string/owner_info_settings_summary" />
+ android:title="@string/owner_info_settings_title" />
</PreferenceScreen>
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java b/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java
index f95ce46..1aac0ff 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java
@@ -25,6 +25,7 @@
import android.text.InputFilter;
import android.text.InputFilter.LengthFilter;
import android.text.InputType;
+import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
@@ -34,6 +35,7 @@
import android.widget.EditText;
import android.widget.TextView;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
@@ -186,6 +188,19 @@
}
/**
+ * Helper method to return the text of the pin entry field - this exists primarily to help us
+ * simulate having existing text when the dialog is recreated, for example after a screen
+ * rotation.
+ */
+ @VisibleForTesting
+ CharSequence getPairingViewText() {
+ if (mPairingView != null) {
+ return mPairingView.getText();
+ }
+ return null;
+ }
+
+ /**
* Returns a dialog with UI elements that allow a user to provide input.
*/
private AlertDialog createUserEntryDialog() {
@@ -196,7 +211,9 @@
mBuilder.setNegativeButton(getString(android.R.string.cancel), this);
AlertDialog dialog = mBuilder.create();
dialog.setOnShowListener(d -> {
- mDialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(false);
+ if (TextUtils.isEmpty(getPairingViewText())) {
+ mDialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(false);
+ }
if (mPairingView != null && mPairingView.requestFocus()) {
InputMethodManager imm = (InputMethodManager)
getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
diff --git a/src/com/android/settings/development/featureflags/FeatureFlagsDashboard.java b/src/com/android/settings/development/featureflags/FeatureFlagsDashboard.java
new file mode 100644
index 0000000..ee2258d
--- /dev/null
+++ b/src/com/android/settings/development/featureflags/FeatureFlagsDashboard.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development.featureflags;
+
+import android.content.Context;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settingslib.core.AbstractPreferenceController;
+
+import java.util.List;
+
+public class FeatureFlagsDashboard extends DashboardFragment {
+
+ private static final String TAG = "FeatureFlagsDashboard";
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsProto.MetricsEvent.SETTINGS_FEATURE_FLAGS_DASHBOARD;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.placeholder_prefs;
+ }
+
+ @Override
+ protected int getHelpResource() {
+ return 0;
+ }
+
+ @Override
+ protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
+ return null;
+ }
+}
diff --git a/src/com/android/settings/nfc/NfcPaymentPreference.java b/src/com/android/settings/nfc/NfcPaymentPreference.java
index 239377d..a3f7466 100644
--- a/src/com/android/settings/nfc/NfcPaymentPreference.java
+++ b/src/com/android/settings/nfc/NfcPaymentPreference.java
@@ -18,6 +18,7 @@
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
+import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.preference.PreferenceViewHolder;
@@ -209,7 +210,9 @@
if (!appInfo.isDefault) {
mPaymentBackend.setDefaultPaymentApp(appInfo.componentName);
}
- getDialog().dismiss();
+ Dialog dialog = getDialog();
+ if (dialog != null)
+ dialog.dismiss();
}
}
}
diff --git a/src/com/android/settings/notification/ConfigureNotificationSettings.java b/src/com/android/settings/notification/ConfigureNotificationSettings.java
index 2b1ecc4..2533466 100644
--- a/src/com/android/settings/notification/ConfigureNotificationSettings.java
+++ b/src/com/android/settings/notification/ConfigureNotificationSettings.java
@@ -22,8 +22,8 @@
import android.os.Bundle;
import android.os.UserHandle;
import android.provider.SearchIndexableResource;
+import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
-import android.util.Log;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
@@ -44,7 +44,16 @@
public class ConfigureNotificationSettings extends DashboardFragment {
private static final String TAG = "ConfigNotiSettings";
- private static final String KEY_SWIPE_DOWN = "gesture_swipe_down_fingerprint_notifications";
+ @VisibleForTesting
+ static final String KEY_LOCKSCREEN = "lock_screen_notifications";
+ @VisibleForTesting
+ static final String KEY_LOCKSCREEN_WORK_PROFILE_HEADER =
+ "lock_screen_notifications_profile_header";
+ @VisibleForTesting
+ static final String KEY_LOCKSCREEN_WORK_PROFILE = "lock_screen_notifications_profile";
+ @VisibleForTesting
+ static final String KEY_SWIPE_DOWN = "gesture_swipe_down_fingerprint_notifications";
+
private static final String KEY_NOTI_DEFAULT_RINGTONE = "notification_default_ringtone";
private RingtonePreference mRequestPreference;
@@ -80,9 +89,9 @@
new PulseNotificationPreferenceController(context);
final LockScreenNotificationPreferenceController lockScreenNotificationController =
new LockScreenNotificationPreferenceController(context,
- "lock_screen_notifications",
- "lock_screen_notifications_profile_header",
- "lock_screen_notifications_profile");
+ KEY_LOCKSCREEN,
+ KEY_LOCKSCREEN_WORK_PROFILE_HEADER,
+ KEY_LOCKSCREEN_WORK_PROFILE);
if (lifecycle != null) {
lifecycle.addObserver(pulseController);
lifecycle.addObserver(lockScreenNotificationController);
@@ -156,9 +165,19 @@
}
@Override
- public List<AbstractPreferenceController> getPreferenceControllers(Context context) {
+ public List<AbstractPreferenceController> getPreferenceControllers(
+ Context context) {
return buildPreferenceControllers(context, null);
}
+ @Override
+ public List<String> getNonIndexableKeys(Context context) {
+ final List<String> keys = super.getNonIndexableKeys(context);
+ keys.add(KEY_SWIPE_DOWN);
+ keys.add(KEY_LOCKSCREEN);
+ keys.add(KEY_LOCKSCREEN_WORK_PROFILE);
+ keys.add(KEY_LOCKSCREEN_WORK_PROFILE_HEADER);
+ return keys;
+ }
};
}
diff --git a/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java b/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
index db46ef1..272d504 100644
--- a/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
+++ b/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
@@ -16,6 +16,9 @@
package com.android.settings.notification;
+import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS;
+import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS;
+
import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
@@ -41,9 +44,6 @@
import java.util.ArrayList;
-import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS;
-import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS;
-
public class LockScreenNotificationPreferenceController extends AbstractPreferenceController
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener,
LifecycleObserver, OnResume, OnPause {
@@ -79,11 +79,10 @@
mProfileChallengeUserId = Utils.getManagedProfileId(
UserManager.get(context), UserHandle.myUserId());
final LockPatternUtils utils = new LockPatternUtils(context);
- final boolean isUnified =
- !utils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId);
mSecure = utils.isSecure(UserHandle.myUserId());
mSecureProfile = (mProfileChallengeUserId != UserHandle.USER_NULL)
- && (utils.isSecure(mProfileChallengeUserId) || (isUnified && mSecure));
+ && (utils.isSecure(mProfileChallengeUserId)
+ || (!utils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId) && mSecure));
}
@Override
diff --git a/src/com/android/settings/password/ChooseLockGeneric.java b/src/com/android/settings/password/ChooseLockGeneric.java
index 4d20bcf..5126727 100644
--- a/src/com/android/settings/password/ChooseLockGeneric.java
+++ b/src/com/android/settings/password/ChooseLockGeneric.java
@@ -219,7 +219,7 @@
mManagedPasswordProvider = ManagedLockPasswordProvider.get(getActivity(), mUserId);
if (mPasswordConfirmed) {
- updatePreferencesOrFinish();
+ updatePreferencesOrFinish(savedInstanceState != null);
if (mForChangeCredRequiredForBoot) {
maybeEnableEncryption(mLockPatternUtils.getKeyguardStoredPasswordQuality(
mUserId), false);
@@ -234,7 +234,7 @@
|| !helper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST,
getString(R.string.unlock_set_unlock_launch_picker_title), true, mUserId)) {
mPasswordConfirmed = true; // no password set, so no need to confirm
- updatePreferencesOrFinish();
+ updatePreferencesOrFinish(savedInstanceState != null);
} else {
mWaitingForConfirmation = true;
}
@@ -332,7 +332,7 @@
if (requestCode == CONFIRM_EXISTING_REQUEST && resultCode == Activity.RESULT_OK) {
mPasswordConfirmed = true;
mUserPassword = data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
- updatePreferencesOrFinish();
+ updatePreferencesOrFinish(false /* isRecreatingActivity */);
if (mForChangeCredRequiredForBoot) {
if (!TextUtils.isEmpty(mUserPassword)) {
maybeEnableEncryption(
@@ -395,7 +395,7 @@
outState.putBoolean(ENCRYPT_REQUESTED_DISABLED, mEncryptionRequestDisabled);
}
- private void updatePreferencesOrFinish() {
+ private void updatePreferencesOrFinish(boolean isRecreatingActivity) {
Intent intent = getActivity().getIntent();
int quality = intent.getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, -1);
if (quality == -1) {
@@ -413,7 +413,8 @@
updatePreferenceText();
updateCurrentPreference();
updatePreferenceSummaryIfNeeded();
- } else {
+ } else if (!isRecreatingActivity) {
+ // Don't start the activity again if we are recreated for configuration change
updateUnlockMethodAndFinish(quality, false, true /* chooseLockSkipped */);
}
}
diff --git a/src/com/android/settings/password/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java
index e013b8b..d890956 100644
--- a/src/com/android/settings/password/ChooseLockPassword.java
+++ b/src/com/android/settings/password/ChooseLockPassword.java
@@ -162,7 +162,7 @@
.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, false);
CharSequence msg = getText(forFingerprint
? R.string.lockpassword_choose_your_password_header_for_fingerprint
- : R.string.lockpassword_choose_your_password_header);
+ : R.string.lockpassword_choose_your_screen_lock_header);
setTitle(msg);
LinearLayout layout = (LinearLayout) findViewById(R.id.content_parent);
layout.setFitsSystemWindows(false);
@@ -213,6 +213,7 @@
protected Button mCancelButton;
private Button mClearButton;
private Button mNextButton;
+ private TextView mMessage;
private TextChangedHandler mTextChangedHandler;
@@ -247,10 +248,14 @@
protected enum Stage {
Introduction(
- R.string.lockpassword_choose_your_password_header,
+ R.string.lockpassword_choose_your_screen_lock_header,
R.string.lockpassword_choose_your_password_header_for_fingerprint,
- R.string.lockpassword_choose_your_pin_header,
+ R.string.lockpassword_choose_your_screen_lock_header,
R.string.lockpassword_choose_your_pin_header_for_fingerprint,
+ R.string.lockpassword_choose_your_password_message,
+ R.string.lock_settings_picker_fingerprint_added_security_message,
+ R.string.lockpassword_choose_your_pin_message,
+ R.string.lock_settings_picker_fingerprint_added_security_message,
R.string.next_label),
NeedToConfirm(
@@ -258,6 +263,10 @@
R.string.lockpassword_confirm_your_password_header,
R.string.lockpassword_confirm_your_pin_header,
R.string.lockpassword_confirm_your_pin_header,
+ 0,
+ 0,
+ 0,
+ 0,
R.string.lockpassword_ok_label),
ConfirmWrong(
@@ -265,14 +274,25 @@
R.string.lockpassword_confirm_passwords_dont_match,
R.string.lockpassword_confirm_pins_dont_match,
R.string.lockpassword_confirm_pins_dont_match,
+ 0,
+ 0,
+ 0,
+ 0,
R.string.next_label);
Stage(int hintInAlpha, int hintInAlphaForFingerprint,
- int hintInNumeric, int hintInNumericForFingerprint, int nextButtonText) {
+ int hintInNumeric, int hintInNumericForFingerprint,
+ int messageInAlpha, int messageInAlphaForFingerprint,
+ int messageInNumeric, int messageInNumericForFingerprint,
+ int nextButtonText) {
this.alphaHint = hintInAlpha;
this.alphaHintForFingerprint = hintInAlphaForFingerprint;
this.numericHint = hintInNumeric;
this.numericHintForFingerprint = hintInNumericForFingerprint;
+ this.alphaMessage = messageInAlpha;
+ this.alphaMessageForFingerprint = messageInAlphaForFingerprint;
+ this.numericMessage = messageInNumeric;
+ this.numericMessageForFingerprint = messageInNumericForFingerprint;
this.buttonText = nextButtonText;
}
@@ -280,6 +300,10 @@
public final int alphaHintForFingerprint;
public final int numericHint;
public final int numericHintForFingerprint;
+ public final int alphaMessage;
+ public final int alphaMessageForFingerprint;
+ public final int numericMessage;
+ public final int numericMessageForFingerprint;
public final int buttonText;
public @StringRes int getHint(boolean isAlpha, boolean isFingerprint) {
@@ -289,6 +313,14 @@
return isFingerprint ? numericHintForFingerprint : numericHint;
}
}
+
+ public @StringRes int getMessage(boolean isAlpha, boolean isFingerprint) {
+ if (isAlpha) {
+ return isFingerprint ? alphaMessageForFingerprint : alphaMessage;
+ } else {
+ return isFingerprint ? numericMessageForFingerprint : numericMessage;
+ }
+ }
}
// required constructor for fragments
@@ -351,14 +383,9 @@
mClearButton = view.findViewById(R.id.clear_button);
mClearButton.setOnClickListener(this);
+
+ mMessage = view.findViewById(R.id.message);
if (mForFingerprint) {
- TextView fingerprintBackupMessage =
- view.findViewById(R.id.fingerprint_backup_message);
- if (fingerprintBackupMessage != null) {
- fingerprintBackupMessage.setVisibility(View.VISIBLE);
- fingerprintBackupMessage
- .setText(R.string.setup_lock_settings_picker_fingerprint_message);
- }
mLayout.setIcon(getActivity().getDrawable(R.drawable.ic_fingerprint_header));
}
@@ -848,6 +875,13 @@
setNextEnabled(canInput && length > 0);
mClearButton.setEnabled(canInput && length > 0);
}
+ int message = mUiStage.getMessage(mIsAlphaMode, mForFingerprint);
+ if (message != 0) {
+ mMessage.setVisibility(View.VISIBLE);
+ mMessage.setText(message);
+ } else {
+ mMessage.setVisibility(View.INVISIBLE);
+ }
mClearButton.setVisibility(toVisibility(mUiStage != Stage.Introduction));
mCancelButton.setVisibility(toVisibility(mUiStage == Stage.Introduction));
diff --git a/src/com/android/settings/widget/AspectRatioFrameLayout.java b/src/com/android/settings/widget/AspectRatioFrameLayout.java
index 14d7921..bb4c28b 100644
--- a/src/com/android/settings/widget/AspectRatioFrameLayout.java
+++ b/src/com/android/settings/widget/AspectRatioFrameLayout.java
@@ -22,12 +22,14 @@
import com.android.settings.R;
/**
- * A {@link FrameLayout} with customizable aspect ration.
+ * A {@link FrameLayout} with customizable aspect ratio.
* This is used to avoid dynamically calculating the height for the frame. Default aspect
* ratio will be 1 if none is set in layout attribute.
*/
public final class AspectRatioFrameLayout extends FrameLayout {
+ private static final float ASPECT_RATIO_CHANGE_THREASHOLD = 0.01f;
+
private float mAspectRatio = 1.0f;
public AspectRatioFrameLayout(Context context) {
@@ -51,7 +53,25 @@
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, (int) (widthMeasureSpec / mAspectRatio));
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ int width = getMeasuredWidth();
+ int height = getMeasuredHeight();
+ if (width == 0 || height == 0) {
+ return;
+ }
+ final float viewAspectRatio = (float) width / height;
+ final float aspectRatioDiff = mAspectRatio - viewAspectRatio;
+ if (Math.abs(aspectRatioDiff) <= ASPECT_RATIO_CHANGE_THREASHOLD) {
+ // Close enough, skip.
+ return;
+ }
+ if (aspectRatioDiff > 0) {
+ width = (int) (height * mAspectRatio);
+ } else {
+ height = (int) (width / mAspectRatio);
+ }
+ super.onMeasure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
+ MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
}
}
diff --git a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java b/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
index 33fdf2d..5c8e42b 100644
--- a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
+++ b/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
@@ -18,13 +18,9 @@
import android.app.Dialog;
import android.content.Context;
-import android.content.res.Resources;
import android.icu.text.Collator;
-import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
-import android.net.wifi.hotspot2.PasspointConfiguration;
import android.os.Bundle;
-import android.provider.SearchIndexableResource;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.util.Log;
@@ -33,15 +29,11 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
-import com.android.settings.search.SearchIndexableRaw;
import com.android.settingslib.wifi.AccessPoint;
import com.android.settingslib.wifi.AccessPointPreference;
import com.android.settingslib.wifi.WifiSavedConfigUtils;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -51,7 +43,7 @@
*/
public class SavedAccessPointsWifiSettings extends SettingsPreferenceFragment
implements Indexable, WifiDialog.WifiDialogListener {
- private static final String TAG = "SavedAccessPointsWifiSettings";
+ private static final String TAG = "SavedAccessPoints";
private static final Comparator<AccessPoint> SAVED_NETWORK_COMPARATOR =
new Comparator<AccessPoint>() {
final Collator mCollator = Collator.getInstance();
@@ -239,47 +231,4 @@
return super.onPreferenceTreeClick(preference);
}
}
-
- /**
- * For search.
- */
- public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
- @Override
- public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
- boolean enabled) {
- SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = R.xml.wifi_display_saved_access_points;
- return Arrays.asList(sir);
- }
-
- @Override
- public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
- final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();
- final Resources res = context.getResources();
- final String title = res.getString(R.string.wifi_saved_access_points_titlebar);
-
- // Add fragment title
- SearchIndexableRaw data = new SearchIndexableRaw(context);
- data.title = title;
- data.screenTitle = title;
- data.enabled = enabled;
- result.add(data);
-
- // Add available Wi-Fi access points
- final List<AccessPoint> accessPoints = WifiSavedConfigUtils.getAllConfigs(
- context, context.getSystemService(WifiManager.class));
-
- final int accessPointsSize = accessPoints.size();
- for (int i = 0; i < accessPointsSize; ++i){
- data = new SearchIndexableRaw(context);
- data.title = accessPoints.get(i).getSsidStr();
- data.screenTitle = title;
- data.enabled = enabled;
- result.add(data);
- }
-
- return result;
- }
- };
}
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index 90c17c3..72fc981 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -30,7 +30,6 @@
import android.net.LinkAddress;
import android.net.LinkProperties;
import android.net.Network;
-import android.net.NetworkBadging;
import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
import android.net.NetworkRequest;
@@ -46,8 +45,6 @@
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;
import android.util.Log;
-import android.view.View;
-import android.widget.Button;
import android.widget.ImageView;
import com.android.internal.annotations.VisibleForTesting;
@@ -120,7 +117,7 @@
private Network mNetwork;
private NetworkInfo mNetworkInfo;
private NetworkCapabilities mNetworkCapabilities;
- private int mRssi;
+ private int mRssiSignalLevel = -1;
private String[] mSignalStr;
private final WifiConfiguration mWifiConfig;
private WifiInfo mWifiInfo;
@@ -142,6 +139,7 @@
private PreferenceCategory mIpv6Category;
private Preference mIpv6AddressPref;
+ private final IconInjector mIconInjector;
private final IntentFilter mFilter;
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
@@ -198,7 +196,7 @@
}
};
- public WifiDetailPreferenceController(
+ public static WifiDetailPreferenceController newInstance(
AccessPoint accessPoint,
ConnectivityManagerWrapper connectivityManagerWrapper,
Context context,
@@ -207,6 +205,22 @@
Lifecycle lifecycle,
WifiManager wifiManager,
MetricsFeatureProvider metricsFeatureProvider) {
+ return new WifiDetailPreferenceController(
+ accessPoint, connectivityManagerWrapper, context, fragment, handler, lifecycle,
+ wifiManager, metricsFeatureProvider, new IconInjector(context));
+ }
+
+ @VisibleForTesting
+ /* package */ WifiDetailPreferenceController(
+ AccessPoint accessPoint,
+ ConnectivityManagerWrapper connectivityManagerWrapper,
+ Context context,
+ Fragment fragment,
+ Handler handler,
+ Lifecycle lifecycle,
+ WifiManager wifiManager,
+ MetricsFeatureProvider metricsFeatureProvider,
+ IconInjector injector) {
super(context);
mAccessPoint = accessPoint;
@@ -218,11 +232,11 @@
mWifiConfig = accessPoint.getConfig();
mWifiManager = wifiManager;
mMetricsFeatureProvider = metricsFeatureProvider;
+ mIconInjector = injector;
mFilter = new IntentFilter();
mFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
mFilter.addAction(WifiManager.RSSI_CHANGED_ACTION);
-
lifecycle.addObserver(this);
}
@@ -324,7 +338,6 @@
refreshNetworkState();
// Update Connection Header icon and Signal Strength Preference
- mRssi = mWifiInfo.getRssi();
refreshRssiViews();
// MAC Address Pref
@@ -367,10 +380,13 @@
}
private void refreshRssiViews() {
- int iconSignalLevel = WifiManager.calculateSignalLevel(
- mRssi, WifiManager.RSSI_LEVELS);
- Drawable wifiIcon = NetworkBadging.getWifiIcon(
- iconSignalLevel, NetworkBadging.BADGING_NONE, mContext.getTheme()).mutate();
+ int signalLevel = mAccessPoint.getLevel();
+
+ if (mRssiSignalLevel == signalLevel) {
+ return;
+ }
+ mRssiSignalLevel = signalLevel;
+ Drawable wifiIcon = mIconInjector.getIcon(mRssiSignalLevel);
wifiIcon.setTint(Utils.getColorAccent(mContext));
mEntityHeaderController.setIcon(wifiIcon).done(mFragment.getActivity(), true /* rebind */);
@@ -380,8 +396,7 @@
R.color.wifi_details_icon_color, mContext.getTheme()));
mSignalStrengthPref.setIcon(wifiIconDark);
- int summarySignalLevel = mAccessPoint.getLevel();
- mSignalStrengthPref.setDetailText(mSignalStr[summarySignalLevel]);
+ mSignalStrengthPref.setDetailText(mSignalStr[mRssiSignalLevel]);
}
private void updatePreference(WifiDetailPreference pref, String detailText) {
@@ -501,4 +516,20 @@
mFragment.getActivity(), MetricsProto.MetricsEvent.ACTION_WIFI_SIGNIN);
mConnectivityManagerWrapper.startCaptivePortalApp(mNetwork);
}
+
+ /**
+ * Wrapper for testing compatibility.
+ */
+ @VisibleForTesting
+ static class IconInjector {
+ private final Context mContext;
+
+ public IconInjector(Context context) {
+ mContext = context;
+ }
+
+ public Drawable getIcon(int level) {
+ return mContext.getDrawable(Utils.getWifiIconResource(level)).mutate();
+ }
+ }
}
diff --git a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
index 8145d77..4918889 100644
--- a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
+++ b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
@@ -25,6 +25,7 @@
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.vpn2.ConnectivityManagerWrapperImpl;
+import com.android.settings.wifi.WifiDetailPreference;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.wifi.AccessPoint;
import java.util.ArrayList;
@@ -72,7 +73,7 @@
@Override
protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
ConnectivityManager cm = context.getSystemService(ConnectivityManager.class);
- mWifiDetailPreferenceController = new WifiDetailPreferenceController(
+ mWifiDetailPreferenceController = WifiDetailPreferenceController.newInstance(
mAccessPoint,
new ConnectivityManagerWrapperImpl(cm),
context,
diff --git a/tests/robotests/assets/grandfather_not_implementing_index_provider b/tests/robotests/assets/grandfather_not_implementing_index_provider
index 4623889..9b86ced 100644
--- a/tests/robotests/assets/grandfather_not_implementing_index_provider
+++ b/tests/robotests/assets/grandfather_not_implementing_index_provider
@@ -4,6 +4,7 @@
com.android.settings.accounts.AccountDetailDashboardFragment
com.android.settings.fuelgauge.PowerUsageAnomalyDetails
com.android.settings.fuelgauge.AdvancedPowerUsageDetail
+com.android.settings.development.featureflags.FeatureFlagsDashboard
com.android.settings.deviceinfo.StorageProfileFragment
com.android.settings.wifi.details.WifiNetworkDetailsFragment
com.android.settings.wifi.p2p.WifiP2pSettings
@@ -13,3 +14,4 @@
com.android.settings.enterprise.ApplicationListFragment$EnterpriseInstalledPackages
com.android.settings.enterprise.EnterpriseSetDefaultAppsListFragment
com.android.settings.wifi.tether.WifiTetherSettings
+com.android.settings.wifi.SavedAccessPointsWifiSettings
diff --git a/tests/robotests/src/android/net/NetworkBadging.java b/tests/robotests/src/android/net/NetworkBadging.java
deleted file mode 100644
index f2af08b..0000000
--- a/tests/robotests/src/android/net/NetworkBadging.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package android.net;
-
-import android.annotation.IntDef;
-import android.annotation.Nullable;
-import android.content.res.Resources;
-import android.graphics.Color;
-import android.graphics.drawable.ColorDrawable;
-import android.graphics.drawable.Drawable;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Implementation for {@link android.net.NetworkBadging}.
- *
- * <p>Can be removed once Robolectric supports Android O.
- */
-public class NetworkBadging {
- @IntDef({BADGING_NONE, BADGING_SD, BADGING_HD, BADGING_4K})
- @Retention(RetentionPolicy.SOURCE)
- public @interface Badging {}
-
- public static final int BADGING_NONE = 0;
- public static final int BADGING_SD = 10;
- public static final int BADGING_HD = 20;
- public static final int BADGING_4K = 30;
-
- private static Drawable drawable;
-
- public static Drawable getWifiIcon(
- int signalLevel, @NetworkBadging.Badging int badging, @Nullable Resources.Theme theme) {
- return new ColorDrawable(Color.GREEN);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java
index 7a6ae79..fba11de 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java
@@ -28,6 +28,7 @@
import static org.mockito.Mockito.when;
import android.app.AlertDialog;
+import android.app.Dialog;
import android.content.Context;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
@@ -47,6 +48,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowAlertDialog;
import org.robolectric.shadows.ShadowApplication;
import org.robolectric.util.FragmentTestUtil;
@@ -412,6 +414,39 @@
verify(dialogActivity, times(1)).dismiss();
}
+ @Test
+ public void rotateDialog_nullPinText_okButtonEnabled() {
+ userEntryDialogExistingTextTest(null);
+ }
+
+ @Test
+ public void rotateDialog_emptyPinText_okButtonEnabled() {
+ userEntryDialogExistingTextTest("");
+ }
+
+ @Test
+ public void rotateDialog_nonEmptyPinText_okButtonEnabled() {
+ userEntryDialogExistingTextTest("test");
+ }
+
+ // Runs a test simulating the user entry dialog type in a situation like device rotation, where
+ // the dialog fragment gets created and we already have some existing text entered into the
+ // pin field.
+ private void userEntryDialogExistingTextTest(CharSequence existingText) {
+ when(controller.getDialogType()).thenReturn(BluetoothPairingController.USER_ENTRY_DIALOG);
+ when(controller.getDeviceVariantMessageHintId())
+ .thenReturn(BluetoothPairingController.INVALID_DIALOG_TYPE);
+ when(controller.getDeviceVariantMessageId())
+ .thenReturn(BluetoothPairingController.INVALID_DIALOG_TYPE);
+
+ BluetoothPairingDialogFragment fragment = spy(new BluetoothPairingDialogFragment());
+ when(fragment.getPairingViewText()).thenReturn(existingText);
+ setupFragment(fragment);
+ AlertDialog dialog = ShadowAlertDialog.getLatestAlertDialog();
+ boolean expected = !TextUtils.isEmpty(existingText);
+ assertThat(dialog.getButton(Dialog.BUTTON_POSITIVE).isEnabled()).isEqualTo(expected);
+ }
+
private void setupFragment(BluetoothPairingDialogFragment frag) {
assertThat(frag.isPairingControllerSet()).isFalse();
frag.setPairingController(controller);
diff --git a/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagsDashboardTest.java b/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagsDashboardTest.java
new file mode 100644
index 0000000..92e92fc
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagsDashboardTest.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development.featureflags;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class FeatureFlagsDashboardTest {
+
+ private FeatureFlagsDashboard mDashboard;
+
+ @Before
+ public void setUp() {
+ mDashboard = new FeatureFlagsDashboard();
+ }
+
+ @Test
+ public void shouldNotHaveHelpResource() {
+ assertThat(mDashboard.getHelpResource()).isEqualTo(0);
+ }
+
+ @Test
+ public void shouldLogAsFeatureFlagPage() {
+ assertThat(mDashboard.getMetricsCategory())
+ .isEqualTo(MetricsProto.MetricsEvent.SETTINGS_FEATURE_FLAGS_DASHBOARD);
+ }
+
+ @Test
+ public void shouldUsePlaceholderPreferenceLayout() {
+ assertThat(mDashboard.getPreferenceScreenResId())
+ .isEqualTo(R.xml.placeholder_prefs);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/ConfigureNotificationSettingsTest.java b/tests/robotests/src/com/android/settings/notification/ConfigureNotificationSettingsTest.java
new file mode 100644
index 0000000..8cf8f83
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/ConfigureNotificationSettingsTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification;
+
+import static com.android.settings.notification.ConfigureNotificationSettings.KEY_LOCKSCREEN;
+import static com.android.settings.notification.ConfigureNotificationSettings
+ .KEY_LOCKSCREEN_WORK_PROFILE;
+import static com.android.settings.notification.ConfigureNotificationSettings
+ .KEY_LOCKSCREEN_WORK_PROFILE_HEADER;
+import static com.android.settings.notification.ConfigureNotificationSettings.KEY_SWIPE_DOWN;
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.ShadowLockPatternUtils;
+import com.android.settings.testutils.shadow.ShadowUtils;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import java.util.List;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class ConfigureNotificationSettingsTest {
+
+ private Context mContext;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ }
+
+ @Test
+ @Config(shadows = {
+ ShadowUtils.class,
+ ShadowLockPatternUtils.class
+ })
+ public void getNonIndexableKeys_shouldContainLockScreenPrefs() {
+ final List<String> keys = ConfigureNotificationSettings.SEARCH_INDEX_DATA_PROVIDER
+ .getNonIndexableKeys(mContext);
+
+ assertThat(keys).containsAllOf(
+ KEY_SWIPE_DOWN, KEY_LOCKSCREEN, KEY_LOCKSCREEN_WORK_PROFILE,
+ KEY_LOCKSCREEN_WORK_PROFILE_HEADER);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java
index f85a874..271ffa8 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java
@@ -18,6 +18,8 @@
import android.content.ComponentName;
import android.content.Context;
+import android.os.UserHandle;
+import android.os.UserManager;
import com.android.settings.Utils;
import com.android.settings.password.IFingerprintManager;
@@ -87,4 +89,9 @@
public static ComponentName getDeviceOwnerComponent(Context context) {
return sDeviceOwnerComponentName;
}
+
+ @Implementation
+ public static int getManagedProfileId(UserManager um, int parentUserId) {
+ return UserHandle.USER_NULL;
+ }
}
diff --git a/tests/robotests/src/com/android/settings/widget/AspectRatioFrameLayoutTest.java b/tests/robotests/src/com/android/settings/widget/AspectRatioFrameLayoutTest.java
new file mode 100644
index 0000000..dd6138c
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/widget/AspectRatioFrameLayoutTest.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.widget;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.view.View;
+
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class AspectRatioFrameLayoutTest {
+
+ private Context mContext;
+ private AspectRatioFrameLayout mLayout;
+
+ @Before
+ public void setup() {
+ mContext = RuntimeEnvironment.application;
+ }
+
+ @Test
+ public void measure_squareAspectRatio_stretchHeight() {
+ mLayout = new AspectRatioFrameLayout(mContext);
+
+ int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.EXACTLY);
+ int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(50, View.MeasureSpec.EXACTLY);
+
+ mLayout.measure(widthMeasureSpec, heightMeasureSpec);
+
+ assertThat(mLayout.getMeasuredWidth()).isEqualTo(100);
+ assertThat(mLayout.getMeasuredHeight()).isEqualTo(100);
+ }
+
+ @Test
+ public void measure_squareAspectRatio_stretchWidth() {
+ mLayout = new AspectRatioFrameLayout(mContext);
+
+ int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(50, View.MeasureSpec.EXACTLY);
+ int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.EXACTLY);
+
+ mLayout.measure(widthMeasureSpec, heightMeasureSpec);
+
+ assertThat(mLayout.getMeasuredWidth()).isEqualTo(100);
+ assertThat(mLayout.getMeasuredHeight()).isEqualTo(100);
+ }
+
+ @Test
+ public void measure_squareAspectRatio_doNotStretch() {
+ mLayout = new AspectRatioFrameLayout(mContext);
+
+ int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.EXACTLY);
+ int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.EXACTLY);
+
+ mLayout.measure(widthMeasureSpec, heightMeasureSpec);
+
+ assertThat(mLayout.getMeasuredWidth()).isEqualTo(100);
+ assertThat(mLayout.getMeasuredHeight()).isEqualTo(100);
+ }
+
+ @Test
+ public void measure_rectangleAspectRatio_stretch() {
+ mLayout = new AspectRatioFrameLayout(mContext);
+ // Set aspect ratio to 2:1.
+ ReflectionHelpers.setField(mLayout, "mAspectRatio", 2f);
+
+ int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.EXACTLY);
+ int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.EXACTLY);
+
+ mLayout.measure(widthMeasureSpec, heightMeasureSpec);
+
+ // Should stretch width/height to 2:1 ratio
+ assertThat(mLayout.getMeasuredWidth()).isEqualTo(200);
+ assertThat(mLayout.getMeasuredHeight()).isEqualTo(100);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
index 793c07f..2a7f0cc 100644
--- a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
@@ -16,6 +16,7 @@
package com.android.settings.wifi.details;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.any;
@@ -30,6 +31,7 @@
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
+import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.ConnectivityManager.NetworkCallback;
@@ -37,7 +39,6 @@
import android.net.LinkAddress;
import android.net.LinkProperties;
import android.net.Network;
-import android.net.NetworkBadging;
import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
import android.net.NetworkRequest;
@@ -112,6 +113,7 @@
@Mock private WifiNetworkDetailsFragment mockFragment;
@Mock private WifiManager mockWifiManager;
@Mock private MetricsFeatureProvider mockMetricsFeatureProvider;
+ @Mock private WifiDetailPreferenceController.IconInjector mockIconInjector;
@Mock (answer = Answers.RETURNS_DEEP_STUBS)
private EntityHeaderController mockHeaderController;
@@ -229,6 +231,7 @@
when(mockHeaderController.setRecyclerView(mockFragment.getListView(), mLifecycle))
.thenReturn(mockHeaderController);
when(mockHeaderController.setSummary(anyString())).thenReturn(mockHeaderController);
+ when(mockIconInjector.getIcon(anyInt())).thenReturn(new ColorDrawable());
setupMockedPreferenceScreen();
mController = newWifiDetailPreferenceController();
@@ -243,7 +246,8 @@
null, // Handler
mLifecycle,
mockWifiManager,
- mockMetricsFeatureProvider);
+ mockMetricsFeatureProvider,
+ mockIconInjector);
}
private void setupMockedPreferenceScreen() {
@@ -332,8 +336,7 @@
@Test
public void entityHeader_shouldHaveIconSet() {
- Drawable expectedIcon =
- NetworkBadging.getWifiIcon(LEVEL, NetworkBadging.BADGING_NONE, mContext.getTheme());
+ Drawable expectedIcon = mockIconInjector.getIcon(LEVEL);
displayAndResume();
@@ -742,4 +745,24 @@
verify(mockMetricsFeatureProvider)
.action(mockActivity, MetricsProto.MetricsEvent.ACTION_WIFI_SIGNIN);
}
+
+ @Test
+ public void testRefreshRssiViews_shouldNotUpdateIfLevelIsSame() {
+ displayAndResume();
+
+ mContext.sendBroadcast(new Intent(WifiManager.RSSI_CHANGED_ACTION));
+
+ verify(mockAccessPoint, times(2)).getLevel();
+ verify(mockIconInjector, times(1)).getIcon(anyInt());
+ }
+ @Test
+ public void testRefreshRssiViews_shouldUpdateOnLevelChange() {
+ displayAndResume();
+
+ when(mockAccessPoint.getLevel()).thenReturn(0);
+ mContext.sendBroadcast(new Intent(WifiManager.RSSI_CHANGED_ACTION));
+
+ verify(mockAccessPoint, times(2)).getLevel();
+ verify(mockIconInjector, times(2)).getIcon(anyInt());
+ }
}