Merge "Do not turn on NFC automatically when airplane mode is off."
diff --git a/res/layout/usage_view.xml b/res/layout/usage_view.xml
index 16b4916..c24f289 100644
--- a/res/layout/usage_view.xml
+++ b/res/layout/usage_view.xml
@@ -80,8 +80,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:orientation="horizontal"
- android:layoutDirection="ltr">
+ android:orientation="horizontal">
<include android:id="@+id/label_start"
layout="@layout/usage_side_label" />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 51ec590..f0394c9 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -289,7 +289,7 @@
<string name="bluetooth_notif_message">Tap to pair with <xliff:g id="device_name">%1$s</xliff:g>.</string>
<!-- Item in bluetooth settings screen, used to show the list of received files [CHAR LIMIT=30] -->
<string name="bluetooth_show_received_files">Received files</string>
- <!-- Item in bluetooth settings screen, used to show the list of Files received via Bluetooth [CHAR LIMIT=30] -->
+ <!-- Item in bluetooth settings screen, used to show the list of Files received via Bluetooth [CHAR LIMIT=NONE] -->
<string name="bluetooth_show_files_received_via_bluetooth">Files received via Bluetooth</string>
<!-- Strings for BluetoothDevicePicker [CHAR LIMIT=40]-->
@@ -6999,6 +6999,9 @@
<string name="keywords_model_and_hardware">serial number, hardware version</string>
<string name="keywords_android_version">android security patch level, baseband version, kernel version</string>
+ <!-- Search keyword for Device Theme Settings [CHAR LIMIT=NONE] -->
+ <string name="keywords_systemui_theme">dark theme</string>
+
<!-- Search keyword for Send Device Feedback Setting [CHAR LIMIT=NONE] -->
<string name="keywords_device_feedback">bug</string>
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index 683abd3..87d422f 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -141,7 +141,8 @@
android:title="@string/device_theme"
android:entries="@array/systemui_theme_entries"
android:entryValues="@array/systemui_theme_values"
- settings:controller="com.android.settings.display.SystemUiThemePreferenceController" />
+ settings:controller="com.android.settings.display.SystemUiThemePreferenceController"
+ settings:keywords="@string/keywords_systemui_theme" />
<Preference
android:key="vr_display_pref"
diff --git a/src/com/android/settings/datetime/timezone/BaseTimeZoneAdapter.java b/src/com/android/settings/datetime/timezone/BaseTimeZoneAdapter.java
index 1a868b8..253bd2f 100644
--- a/src/com/android/settings/datetime/timezone/BaseTimeZoneAdapter.java
+++ b/src/com/android/settings/datetime/timezone/BaseTimeZoneAdapter.java
@@ -78,7 +78,7 @@
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
switch(viewType) {
case TYPE_HEADER: {
- final View view = inflater.inflate(R.layout.preference_category_material_settings,
+ final View view = inflater.inflate(R.layout.preference_category_material,
parent, false);
return new HeaderViewHolder(view);
}
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index 9604f74..0272b5c 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -402,10 +402,14 @@
try {
final int userId = intent.getIntExtra(Intent.EXTRA_USER_ID, -1);
+ // b/33117269: Note that launchIntent may launch activity in different task which set
+ // different launchMode (e.g. Files), using startActivityForesult to set task as
+ // source task, and set requestCode as 0 means don't care about returnCode currently.
if (userId == -1) {
- mFragment.startActivity(intent);
+ mFragment.startActivityForResult(intent, 0 /* requestCode not used */);
} else {
- mFragment.getActivity().startActivityAsUser(intent, new UserHandle(userId));
+ mFragment.getActivity().startActivityForResultAsUser(intent,
+ 0 /* requestCode not used */, new UserHandle(userId));
}
} catch (ActivityNotFoundException e) {
Log.w(TAG, "No activity found for " + intent);
diff --git a/src/com/android/settings/password/ChooseLockGeneric.java b/src/com/android/settings/password/ChooseLockGeneric.java
index a2d4a3a..39380ea 100644
--- a/src/com/android/settings/password/ChooseLockGeneric.java
+++ b/src/com/android/settings/password/ChooseLockGeneric.java
@@ -39,6 +39,7 @@
import android.os.UserManager;
import android.os.storage.StorageManager;
import androidx.annotation.StringRes;
+import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import android.text.TextUtils;
@@ -124,7 +125,8 @@
*/
public static final String EXTRA_CHOOSE_LOCK_GENERIC_EXTRAS = "choose_lock_generic_extras";
- private static final int CONFIRM_EXISTING_REQUEST = 100;
+ @VisibleForTesting
+ static final int CONFIRM_EXISTING_REQUEST = 100;
private static final int ENABLE_ENCRYPTION_REQUEST = 101;
private static final int CHOOSE_LOCK_REQUEST = 102;
private static final int CHOOSE_LOCK_BEFORE_FINGERPRINT_REQUEST = 103;
@@ -329,7 +331,9 @@
mWaitingForConfirmation = false;
if (requestCode == CONFIRM_EXISTING_REQUEST && resultCode == Activity.RESULT_OK) {
mPasswordConfirmed = true;
- mUserPassword = data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
+ mUserPassword = data != null
+ ? data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD)
+ : null;
updatePreferencesOrFinish(false /* isRecreatingActivity */);
if (mForChangeCredRequiredForBoot) {
if (!TextUtils.isEmpty(mUserPassword)) {
@@ -394,7 +398,8 @@
}
}
- private void updatePreferencesOrFinish(boolean isRecreatingActivity) {
+ @VisibleForTesting
+ void updatePreferencesOrFinish(boolean isRecreatingActivity) {
Intent intent = getActivity().getIntent();
int quality = intent.getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, -1);
if (quality == -1) {
diff --git a/src/com/android/settings/widget/UsageGraph.java b/src/com/android/settings/widget/UsageGraph.java
index da61607..7238e5d 100644
--- a/src/com/android/settings/widget/UsageGraph.java
+++ b/src/com/android/settings/widget/UsageGraph.java
@@ -255,9 +255,15 @@
return;
}
+ canvas.save();
+ if (getLayoutDirection() == LAYOUT_DIRECTION_RTL) {
+ // Flip the canvas along the y-axis of the center of itself before drawing paths.
+ canvas.scale(-1, 1, canvas.getWidth() * 0.5f, 0);
+ }
drawLinePath(canvas, mLocalProjectedPaths, mDottedPaint);
drawFilledPath(canvas, mLocalPaths, mFillPaint);
drawLinePath(canvas, mLocalPaths, mLinePaint);
+ canvas.restore();
BatteryUtils.logRuntime(LOG_TAG, "onDraw", startTime);
}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
index a4107f5..c8ed42e 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
@@ -19,6 +19,7 @@
import static com.android.settings.applications.manageapplications.ManageApplications.EXTRA_WORK_ONLY;
import static com.android.settings.utils.FileSizeFormatter.MEGABYTE_IN_BYTES;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
@@ -123,7 +124,8 @@
mController.handlePreferenceTreeClick(mPreference);
final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
- verify(mActivity).startActivityAsUser(argumentCaptor.capture(), nullable(UserHandle.class));
+ verify(mActivity).startActivityForResultAsUser(argumentCaptor.capture(), anyInt(),
+ nullable(UserHandle.class));
final Intent intent = argumentCaptor.getValue();
assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MAIN);
@@ -140,8 +142,8 @@
mController.handlePreferenceTreeClick(mPreference);
final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
- verify(mFragment.getActivity())
- .startActivityAsUser(argumentCaptor.capture(), nullable(UserHandle.class));
+ verify(mFragment.getActivity()).startActivityForResultAsUser(argumentCaptor.capture(),
+ anyInt(), nullable(UserHandle.class));
final Intent intent = argumentCaptor.getValue();
assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MAIN);
@@ -167,8 +169,8 @@
mController.handlePreferenceTreeClick(mPreference);
final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
- verify(mFragment.getActivity()).startActivityAsUser(argumentCaptor.capture(),
- nullable(UserHandle.class));
+ verify(mFragment.getActivity()).startActivityForResultAsUser(argumentCaptor.capture(),
+ anyInt(), nullable(UserHandle.class));
final Intent intent = argumentCaptor.getValue();
assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MAIN);
@@ -186,8 +188,8 @@
mController.handlePreferenceTreeClick(mPreference);
final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
- verify(mFragment.getActivity())
- .startActivityAsUser(argumentCaptor.capture(), nullable(UserHandle.class));
+ verify(mFragment.getActivity()).startActivityForResultAsUser(argumentCaptor.capture(),
+ anyInt(), nullable(UserHandle.class));
Intent intent = argumentCaptor.getValue();
assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MAIN);
@@ -223,8 +225,8 @@
.isTrue();
final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
- verify(mFragment.getActivity()).startActivityAsUser(argumentCaptor.capture(),
- nullable(UserHandle.class));
+ verify(mFragment.getActivity()).startActivityForResultAsUser(argumentCaptor.capture(),
+ anyInt(), nullable(UserHandle.class));
Intent intent = argumentCaptor.getValue();
Intent browseIntent = mVolume.buildBrowseIntent();
@@ -240,8 +242,8 @@
mController.handlePreferenceTreeClick(mPreference);
final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
- verify(mFragment.getActivity()).startActivityAsUser(argumentCaptor.capture(),
- nullable(UserHandle.class));
+ verify(mFragment.getActivity()).startActivityForResultAsUser(argumentCaptor.capture(),
+ anyInt(), nullable(UserHandle.class));
Intent intent = argumentCaptor.getValue();
assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MAIN);
@@ -258,8 +260,8 @@
mController.handlePreferenceTreeClick(mPreference);
final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
- verify(mFragment.getActivity()).startActivityAsUser(argumentCaptor.capture(),
- nullable(UserHandle.class));
+ verify(mFragment.getActivity()).startActivityForResultAsUser(argumentCaptor.capture(),
+ anyInt(), nullable(UserHandle.class));
Intent intent = argumentCaptor.getValue();
assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MAIN);
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockGenericTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockGenericTest.java
new file mode 100644
index 0000000..c66373b
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockGenericTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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.password;
+
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.spy;
+
+import android.app.Activity;
+import com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class ChooseLockGenericTest {
+
+ @Test
+ public void onActivityResult_nullIntentData_shouldNotCrash() {
+ ChooseLockGenericFragment fragment = spy(new ChooseLockGenericFragment());
+ doNothing().when(fragment).updatePreferencesOrFinish(anyBoolean());
+
+ fragment.onActivityResult(
+ fragment.CONFIRM_EXISTING_REQUEST, Activity.RESULT_OK, null /* data */);
+ // no crash
+ }
+
+}