Merge "Only register conditions receiver when needed." into oc-dev
diff --git a/res/layout-land/confirm_lock_password.xml b/res/layout-land/confirm_lock_password.xml
index dff4e4d..e9b2b0f 100644
--- a/res/layout-land/confirm_lock_password.xml
+++ b/res/layout-land/confirm_lock_password.xml
@@ -74,7 +74,7 @@
android:layout_gravity="center_horizontal|bottom"
android:layout_marginBottom="26dp"
android:inputType="textPassword"
- android:imeOptions="actionNext|flagNoFullscreen"
+ android:imeOptions="actionNext|flagNoFullscreen|flagForceAscii"
android:gravity="center"
android:textSize="16sp"
style="@style/TextAppearance.PasswordEntry"/>
diff --git a/res/layout/choose_lock_generic_fingerprint_header.xml b/res/layout/choose_lock_generic_fingerprint_header.xml
index a92b68f..6a107bf 100644
--- a/res/layout/choose_lock_generic_fingerprint_header.xml
+++ b/res/layout/choose_lock_generic_fingerprint_header.xml
@@ -18,9 +18,9 @@
android:id="@+id/fingerprint_header_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:minHeight="56dp"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
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/lock_settings_picker_fingerprint_message"
- style="@style/SuwDescription.Glif" />
+ style="@style/FingerprintHeaderStyle" />
diff --git a/res/layout/choose_lock_password.xml b/res/layout/choose_lock_password.xml
index 15fb7db..260db7f 100644
--- a/res/layout/choose_lock_password.xml
+++ b/res/layout/choose_lock_password.xml
@@ -48,7 +48,7 @@
android:layout_gravity="center"
android:gravity="center"
android:inputType="textPassword"
- android:imeOptions="actionNext|flagNoExtractUi"
+ android:imeOptions="actionNext|flagNoExtractUi|flagForceAscii"
android:textSize="24sp"
style="@style/TextAppearance.PasswordEntry"/>
diff --git a/res/layout/confirm_lock_password_base.xml b/res/layout/confirm_lock_password_base.xml
index 8e9a87b..22726be 100644
--- a/res/layout/confirm_lock_password_base.xml
+++ b/res/layout/confirm_lock_password_base.xml
@@ -70,7 +70,7 @@
android:layout_gravity="center_horizontal"
android:layout_marginTop="-40dp"
android:inputType="textPassword"
- android:imeOptions="actionNext|flagNoFullscreen"
+ android:imeOptions="actionNext|flagNoFullscreen|flagForceAscii"
android:gravity="center"
android:textSize="16sp"
style="@style/TextAppearance.PasswordEntry"/>
diff --git a/res/layout/confirm_lock_password_internal.xml b/res/layout/confirm_lock_password_internal.xml
index e22d764..4f22cfb 100644
--- a/res/layout/confirm_lock_password_internal.xml
+++ b/res/layout/confirm_lock_password_internal.xml
@@ -67,7 +67,7 @@
android:layout_gravity="center_horizontal"
android:layout_marginTop="-40dp"
android:inputType="textPassword"
- android:imeOptions="actionNext|flagNoFullscreen"
+ android:imeOptions="actionNext|flagNoFullscreen|flagForceAscii"
android:gravity="center"
android:textSize="16sp"
style="@style/TextAppearance.PasswordEntry"/>
diff --git a/res/layout/crypt_keeper_password_field.xml b/res/layout/crypt_keeper_password_field.xml
index bf286c0..9a06fd3 100644
--- a/res/layout/crypt_keeper_password_field.xml
+++ b/res/layout/crypt_keeper_password_field.xml
@@ -27,6 +27,7 @@
android:layout_width="0dip"
android:layout_weight="1"
android:inputType="textPassword"
+ android:imeOptions="flagForceAscii"
android:textSize="16sp"
android:padding="10sp"
android:maxLength="500"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 475c60e..21a23ae 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3088,23 +3088,23 @@
<!-- Bluetooth Tethering settings-->
<!-- Label for bluetooth tether checkbox [CHAR LIMIT=25]-->
<string name="bluetooth_tether_checkbox_text">Bluetooth tethering</string>
- <!-- Bluetooth available subtext - shown when Bluetooth tethering is turned on but it is not currently tethered to any devices [CHAR LIMIT=50]-->
+ <!-- Bluetooth available subtext - shown when Bluetooth tethering is turned on but it is not currently tethered to any devices [CHAR LIMIT=70]-->
<string name="bluetooth_tethering_available_subtext" product="tablet">Sharing this tablet\u2019s Internet connection via Bluetooth</string>
- <!-- Bluetooth available subtext - shown when Bluetooth tethering is turned on but it is not currently tethered to any devices [CHAR LIMIT=50]-->
+ <!-- Bluetooth available subtext - shown when Bluetooth tethering is turned on but it is not currently tethered to any devices [CHAR LIMIT=70]-->
<string name="bluetooth_tethering_available_subtext" product="default">Sharing this phone\u2019s Internet connection via Bluetooth</string>
- <!-- Bluetooth connected subtext - shown when a device is tethered over Bluetooth [CHAR LIMIT=60]-->
+ <!-- Bluetooth connected subtext - shown when a device is tethered over Bluetooth [CHAR LIMIT=90]-->
<string name="bluetooth_tethering_device_connected_subtext" product="tablet">Sharing this tablet\u2019s Internet connection to 1 device via Bluetooth</string>
- <!-- Bluetooth connected subtext - shown when a device is tethered over Bluetooth [CHAR LIMIT=60]-->
+ <!-- Bluetooth connected subtext - shown when a device is tethered over Bluetooth [CHAR LIMIT=90]-->
<string name="bluetooth_tethering_device_connected_subtext" product="default">Sharing this phone\u2019s Internet connection to 1 device via Bluetooth</string>
- <!-- Bluetooth connected subtext - shown when multiple devices are tethered over Bluetooth [CHAR LIMIT=60]-->
+ <!-- Bluetooth connected subtext - shown when multiple devices are tethered over Bluetooth [CHAR LIMIT=90]-->
<string name="bluetooth_tethering_devices_connected_subtext" product="tablet">Sharing this tablet\u2019s Internet connection to <xliff:g id="connectedDeviceCount">%1$d</xliff:g> devices via Bluetooth</string>
- <!-- Bluetooth connected subtext - shown when multiple devices are tethered over Bluetooth [CHAR LIMIT=60]-->
+ <!-- Bluetooth connected subtext - shown when multiple devices are tethered over Bluetooth [CHAR LIMIT=90]-->
<string name="bluetooth_tethering_devices_connected_subtext" product="default">Sharing this phone\u2019s Internet connection to <xliff:g id="connectedDeviceCount">%1$d</xliff:g> devices via Bluetooth</string>
- <!-- Bluetooth tethering off subtext - shown when Bluetooth Tethering is turned off [CHAR LIMIT=50]-->
+ <!-- Bluetooth tethering off subtext - shown when Bluetooth Tethering is turned off [CHAR LIMIT=80]-->
<string name="bluetooth_tethering_off_subtext_config">Sharing this <xliff:g id="device_name">%1$d</xliff:g>\u2019s Internet connection via Bluetooth</string>
- <!-- Bluetooth tethering off subtext - shown when Bluetooth Tethering is turned off [CHAR LIMIT=50]-->
+ <!-- Bluetooth tethering off subtext - shown when Bluetooth Tethering is turned off [CHAR LIMIT=80]-->
<string name="bluetooth_tethering_off_subtext" product="tablet">Not sharing this tablet\u2019s Internet connection via Bluetooth</string>
- <!-- Bluetooth tethering off subtext - shown when Bluetooth Tethering is turned off [CHAR LIMIT=50]-->
+ <!-- Bluetooth tethering off subtext - shown when Bluetooth Tethering is turned off [CHAR LIMIT=80]-->
<string name="bluetooth_tethering_off_subtext" product="default">Not sharing this phone\u2019s Internet connection via Bluetooth</string>
<!-- Bluetooth errored subtext - shown when Bluetooth is broken for some reason [CHAR LIMIT=50]-->
<string name="bluetooth_tethering_errored_subtext">Not tethered</string>
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index fec489a..c38b89d 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -102,6 +102,9 @@
@Override
protected void onPostExecute(Void unused) {
+ if (getHost() == null) {
+ return;
+ }
populateChannelList();
}
}.execute();
diff --git a/src/com/android/settings/wifi/WifiEnabler.java b/src/com/android/settings/wifi/WifiEnabler.java
index 87e4120..e0e6a1a 100644
--- a/src/com/android/settings/wifi/WifiEnabler.java
+++ b/src/com/android/settings/wifi/WifiEnabler.java
@@ -134,14 +134,12 @@
switch (state) {
case WifiManager.WIFI_STATE_ENABLING:
- mSwitchWidget.setEnabled(false);
break;
case WifiManager.WIFI_STATE_ENABLED:
setSwitchBarChecked(true);
mSwitchWidget.setEnabled(true);
break;
case WifiManager.WIFI_STATE_DISABLING:
- mSwitchWidget.setEnabled(false);
break;
case WifiManager.WIFI_STATE_DISABLED:
setSwitchBarChecked(false);
diff --git a/tests/app/src/com/android/settings/ChooseLockGenericTest.java b/tests/app/src/com/android/settings/ChooseLockGenericTest.java
index dee6697..924e716 100644
--- a/tests/app/src/com/android/settings/ChooseLockGenericTest.java
+++ b/tests/app/src/com/android/settings/ChooseLockGenericTest.java
@@ -16,11 +16,20 @@
package com.android.settings;
+import static android.support.test.InstrumentationRegistry.getInstrumentation;
+import static android.support.test.InstrumentationRegistry.getTargetContext;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.junit.Assert.assertTrue;
+
import android.app.Activity;
+import android.app.ActivityManager;
+import android.app.ActivityManager.AppTask;
+import android.app.KeyguardManager;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.PackageManager;
import android.support.test.filters.MediumTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
@@ -29,24 +38,17 @@
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject;
import android.support.test.uiautomator.UiSelector;
-
import android.text.format.DateUtils;
-import android.view.KeyEvent;
-import com.android.settings.R;
+import com.android.internal.widget.LockPatternUtils;
-import java.util.Collection;
-
-import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static android.support.test.InstrumentationRegistry.getInstrumentation;
-import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertTrue;
+import java.util.Collection;
+import java.util.List;
/**
* Tests for {@link ChooseLockGenericTest}
@@ -68,7 +70,7 @@
private UiDevice mDevice;
private Context mTargetContext;
private String mSettingPackage;
- private PackageManager mPackageManager;
+
@Rule
public ActivityTestRule<ChooseLockGeneric> mChooseLockGenericActivityRule =
new ActivityTestRule<>(
@@ -81,108 +83,105 @@
mDevice = UiDevice.getInstance(getInstrumentation());
mTargetContext = getInstrumentation().getTargetContext();
mSettingPackage = mTargetContext.getPackageName();
- mPackageManager = mTargetContext.getPackageManager();
+ }
+ @Test
+ public void testConfirmLockPasswordShown_deviceWithPassword() throws Throwable {
setPassword();
- }
-
- @After
- public void tearDown() throws Exception {
- clearPassword();
+ try {
+ // GIVEN a PIN password is set on this device at set up.
+ // WHEN ChooseLockGeneric is launched with no extras.
+ mChooseLockGenericActivityRule.launchActivity(null /* No extras */);
+ // THEN ConfirmLockPassword.InternalActivity is shown.
+ assertThat(getCurrentActivity())
+ .isInstanceOf(ConfirmLockPassword.InternalActivity.class);
+ } finally {
+ finishAllAppTasks();
+ mDevice.waitForIdle();
+ clearPassword();
+ }
}
@Test
- public void testConfirmLockPasswordShown_deviceWithPassword() throws Exception, Throwable {
- // GIVEN a PIN password is set on this device at set up.
- // WHEN ChooseLockGeneric is launched with no extras.
- mChooseLockGenericActivityRule.launchActivity(null /* No extras */);
- // THEN ConfirmLockPassword.InternalActivity is shown.
- assertThat(getCurrentActivity()).isInstanceOf(ConfirmLockPassword.InternalActivity.class);
+ public void testConfirmLockPasswordShown_deviceWithPassword_phishingAttack() throws Throwable {
+ setPassword();
+ try {
+ // GIVEN a PIN password is set on this device at set up.
+ // WHEN ChooseLockGeneric is launched with extras to by-pass lock password confirmation.
+ mChooseLockGenericActivityRule.launchActivity(PHISHING_ATTACK_INTENT);
+ // THEN ConfirmLockPassword.InternalActivity is still shown.
+ assertThat(getCurrentActivity())
+ .isInstanceOf(ConfirmLockPassword.InternalActivity.class);
+ } finally {
+ finishAllAppTasks();
+ mDevice.waitForIdle();
+ clearPassword();
+ }
}
@Test
- public void testConfirmLockPasswordShown_deviceWithPassword_phishingAttack()
- throws Exception, Throwable {
- // GIVEN a PIN password is set on this device at set up.
- // WHEN ChooseLockGeneric is launched with extras to by-pass lock password confirmation.
- mChooseLockGenericActivityRule.launchActivity(PHISHING_ATTACK_INTENT);
- // THEN ConfirmLockPassword.InternalActivity is still shown.
- assertThat(getCurrentActivity()).isInstanceOf(ConfirmLockPassword.InternalActivity.class);
+ public void testForFingerprint_inflateLayout() {
+ mChooseLockGenericActivityRule.launchActivity(new Intent()
+ .putExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, true));
+
+ assertThat(mChooseLockGenericActivityRule.getActivity().isResumed()).isTrue();
}
private Activity getCurrentActivity() throws Throwable {
getInstrumentation().waitForIdleSync();
final Activity[] activity = new Activity[1];
- getInstrumentation().runOnMainSync(new Runnable() {
- @Override
- public void run() {
- Collection<Activity> activities = ActivityLifecycleMonitorRegistry.getInstance()
- .getActivitiesInStage(Stage.RESUMED);
- activity[0] = activities.iterator().next();
- }
+ getInstrumentation().runOnMainSync(() -> {
+ Collection<Activity> activities = ActivityLifecycleMonitorRegistry.getInstance()
+ .getActivitiesInStage(Stage.RESUMED);
+ activity[0] = activities.iterator().next();
});
return activity[0];
}
- private void launchNewPassword() throws Exception {
- Intent newPasswordIntent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD)
- .setPackage(mSettingPackage)
+ /** Sets a PIN password, 12345, for testing. */
+ private void setPassword() throws Exception {
+ Intent newPasswordIntent = new Intent(getTargetContext(), ChooseLockGeneric.class)
+ .putExtra(LockPatternUtils.PASSWORD_TYPE_KEY,
+ DevicePolicyManager.PASSWORD_QUALITY_NUMERIC)
+ .putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
+ "12345")
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getInstrumentation().getContext().startActivity(newPasswordIntent);
mDevice.waitForIdle();
- }
- /** Sets a PIN password, 12345, for testing. */
- private void setPassword() throws Exception {
- launchNewPassword();
-
- if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
- // Set "lock_none", but it actually means we don't want to enroll a fingerprint.
- UiObject view = new UiObject(
- new UiSelector().resourceId(mSettingPackage + ":id/lock_none"));
- assertTrue("lock_none", view.waitForExists(TIMEOUT));
- view.click();
- mDevice.waitForIdle();
- }
-
- // Pick PIN from the option list
- UiObject view = new UiObject(new UiSelector()
- .resourceId(mSettingPackage + ":id/lock_pin"));
- assertTrue("lock_pin", view.waitForExists(TIMEOUT));
- view.click();
- mDevice.waitForIdle();
// Ignore any interstitial options
- view = new UiObject(new UiSelector()
+ UiObject view = new UiObject(new UiSelector()
.resourceId(mSettingPackage + ":id/encrypt_dont_require_password"));
if (view.waitForExists(TIMEOUT)) {
view.click();
mDevice.waitForIdle();
}
- // Yes, we really want to
- view = new UiObject(new UiSelector()
- .resourceId(mSettingPackage + ":id/next_button"));
- if (view.waitForExists(TIMEOUT)) {
- view.click();
- mDevice.waitForIdle();
- }
-
// Set our PIN
view = new UiObject(new UiSelector()
.resourceId(mSettingPackage + ":id/password_entry"));
assertTrue("password_entry", view.waitForExists(TIMEOUT));
// Enter it twice to confirm
- enterTestPin();
- enterTestPin();
+ enterTestPin(view);
+ enterTestPin(view);
mDevice.pressBack();
+
+ assertThat(getTargetContext().getSystemService(KeyguardManager.class).isDeviceSecure())
+ .isTrue();
}
/** Clears the previous set PIN password. */
private void clearPassword() throws Exception {
- launchNewPassword();
+ Intent newPasswordIntent = new Intent(getTargetContext(), ChooseLockGeneric.class)
+ .putExtra(LockPatternUtils.PASSWORD_TYPE_KEY,
+ DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED)
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ getInstrumentation().getContext().startActivity(newPasswordIntent);
+ mDevice.waitForIdle();
// Enter current PIN
UiObject view = new UiObject(
@@ -195,40 +194,26 @@
assertTrue("password_entry", view.waitForExists(TIMEOUT));
}
- enterTestPin();
-
- // Set back to "none"
- view = new UiObject(new UiSelector().resourceId(mSettingPackage + ":id/lock_none"));
- assertTrue("lock_none", view.waitForExists(TIMEOUT));
- view.click();
- mDevice.waitForIdle();
-
- // Yes, we really want "none" if prompted again
- view = new UiObject(new UiSelector().resourceId(mSettingPackage + ":id/lock_none"));
- if (view.waitForExists(TIMEOUT)) {
- view.click();
- mDevice.waitForIdle();
- }
-
- // Yes, we really want to
- view = new UiObject(new UiSelector()
- .resourceId("android:id/button1"));
- if (view.waitForExists(TIMEOUT)) {
- view.click();
- mDevice.waitForIdle();
- }
+ enterTestPin(view);
mDevice.pressBack();
+
+ assertThat(getTargetContext().getSystemService(KeyguardManager.class).isDeviceSecure())
+ .isFalse();
}
- private void enterTestPin() throws Exception {
+ private void finishAllAppTasks() {
+ final ActivityManager activityManager =
+ getTargetContext().getSystemService(ActivityManager.class);
+ final List<AppTask> appTasks = activityManager.getAppTasks();
+ for (ActivityManager.AppTask task : appTasks) {
+ task.finishAndRemoveTask();
+ }
+ }
+
+ private void enterTestPin(UiObject view) throws Exception {
mDevice.waitForIdle();
- mDevice.pressKeyCode(KeyEvent.KEYCODE_1);
- mDevice.pressKeyCode(KeyEvent.KEYCODE_2);
- mDevice.pressKeyCode(KeyEvent.KEYCODE_3);
- mDevice.pressKeyCode(KeyEvent.KEYCODE_4);
- mDevice.pressKeyCode(KeyEvent.KEYCODE_5);
- mDevice.waitForIdle();
+ view.setText("12345");
mDevice.pressEnter();
mDevice.waitForIdle();
}