Merge "Change the location mode before applying restrictions" into lmp-dev
diff --git a/res/layout/bluetooth_device_settings.xml b/res/layout/bluetooth_device_settings.xml
new file mode 100644
index 0000000..cc2cc09
--- /dev/null
+++ b/res/layout/bluetooth_device_settings.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:gravity="center">
+
+ <LinearLayout android:id="@+id/dialog_layout"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:paddingBottom="@dimen/bluetooth_dialog_padding"
+ style="@style/bt_item" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/bluetooth_preference_paired_dialog_name_label"
+ android:textDirection="locale"
+ android:textColor="?android:attr/colorAccent"
+ style="@style/bt_item_label" />
+
+ <EditText android:id="@+id/name"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textNoSuggestions"
+ android:maxLength="@integer/bluetooth_name_length"
+ android:singleLine="true"
+ style="@style/bt_item_edit_content" />
+
+ <fragment android:id="@+id/bluetooth_fragment_settings"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ class="com.android.settings.bluetooth.DeviceProfilesSettings" />
+
+ </LinearLayout>
+
+</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d75824e..96f57cb 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5918,4 +5918,15 @@
<!-- Summary Title for saying that the preference is experimental and will evolve over time due to User feedback. [CHAR LIMIT=NONE] -->
<string name="experimental_preference">(Experimental)</string>
+ <!-- [CHAR LIMIT=45] Auto-rotate setting title -->
+ <string name="display_auto_rotate_title">When device is rotated</string>
+ <!-- [CHAR LIMIT=70] Rotate when screen is turned option -->
+ <string name="display_auto_rotate_rotate">Rotate the contents of the screen</string>
+ <!-- [CHAR LIMIT=70] Keep the screen in portrait when rotated -->
+ <string name="display_auto_rotate_stay_in_portrait">Stay in portrait view</string>
+ <!-- [CHAR LIMIT=70] Keep the screen in landscape when rotated -->
+ <string name="display_auto_rotate_stay_in_landscape">Stay in landscape view</string>
+ <!-- [CHAR LIMIT=70] Don't rotate when screen is turned option -->
+ <string name="display_auto_rotate_stay_in_current">Stay in current orientation</string>
+
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index c3d2564..03a9fde 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -196,6 +196,29 @@
<item name="android:textColor">?android:attr/colorAccent</item>
</style>
+ <style name="bt_item">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:layout_marginTop">8dip</item>
+ <item name="android:layout_marginStart">16dip</item>
+ <item name="android:layout_marginEnd">16dip</item>
+ <item name="android:orientation">vertical</item>
+ <item name="android:gravity">start</item>
+ </style>
+
+ <style name="bt_item_label">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:textSize">14sp</item>
+ <item name="android:textAlignment">viewStart</item>
+ </style>
+
+ <style name="bt_item_edit_content">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:textSize">18sp</item>
+ </style>
+
<style name="wifi_item">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index cb6bab0..6cfad2d 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -72,6 +72,10 @@
android:entryValues="@array/entryvalues_font_size"
android:dialogTitle="@string/dialog_title_font_size" />
+ <com.android.settings.notification.DropDownPreference
+ android:key="auto_rotate"
+ android:title="@string/display_auto_rotate_title" />
+
<PreferenceScreen
android:key="wifi_display"
android:title="@string/wifi_display_settings_title"
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java
index 9a09647..7e92cc6 100644
--- a/src/com/android/settings/CryptKeeper.java
+++ b/src/com/android/settings/CryptKeeper.java
@@ -117,6 +117,8 @@
private boolean mValidationRequested;
/** A flag to indicate that the volume is in a bad state (e.g. partially encrypted). */
private boolean mEncryptionGoneBad;
+ /** If gone bad, should we show encryption failed (false) or corrupt (true)*/
+ private boolean mCorrupt;
/** A flag to indicate when the back event should be ignored */
private boolean mIgnoreBack = false;
private int mCooldown;
@@ -224,12 +226,14 @@
}
private class ValidationTask extends AsyncTask<Void, Void, Boolean> {
+ int state;
+
@Override
protected Boolean doInBackground(Void... params) {
final IMountService service = getMountService();
try {
Log.d(TAG, "Validating encryption state.");
- int state = service.getEncryptionState();
+ state = service.getEncryptionState();
if (state == IMountService.ENCRYPTION_STATE_NONE) {
Log.w(TAG, "Unexpectedly in CryptKeeper even though there is no encryption.");
return true; // Unexpected, but fine, I guess...
@@ -247,6 +251,7 @@
if (Boolean.FALSE.equals(result)) {
Log.w(TAG, "Incomplete, or corrupted encryption detected. Prompting user to wipe.");
mEncryptionGoneBad = true;
+ mCorrupt = state == IMountService.ENCRYPTION_STATE_ERROR_CORRUPT;
} else {
Log.d(TAG, "Encryption state validated. Proceeding to configure UI");
}
@@ -403,7 +408,7 @@
private void setupUi() {
if (mEncryptionGoneBad || isDebugView(FORCE_VIEW_ERROR)) {
setContentView(R.layout.crypt_keeper_progress);
- showFactoryReset(false);
+ showFactoryReset(mCorrupt);
return;
}
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index f85b74e..ddd6728 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -16,6 +16,9 @@
package com.android.settings;
+import com.android.internal.view.RotationPolicy;
+import com.android.settings.notification.DropDownPreference;
+import com.android.settings.notification.DropDownPreference.Callback;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
@@ -26,6 +29,7 @@
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
+import android.app.Activity;
import android.app.ActivityManagerNative;
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
@@ -65,6 +69,7 @@
private static final String KEY_LIFT_TO_WAKE = "lift_to_wake";
private static final String KEY_DOZE = "doze";
private static final String KEY_AUTO_BRIGHTNESS = "auto_brightness";
+ private static final String KEY_AUTO_ROTATE = "auto_rotate";
private static final int DLG_GLOBAL_CHANGE_WARNING = 1;
@@ -81,7 +86,8 @@
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- final ContentResolver resolver = getActivity().getContentResolver();
+ final Activity activity = getActivity();
+ final ContentResolver resolver = activity.getContentResolver();
addPreferencesFromResource(R.xml.display_settings);
@@ -111,19 +117,59 @@
removePreference(KEY_AUTO_BRIGHTNESS);
}
- if (isLiftToWakeAvailable(getActivity())) {
+ if (isLiftToWakeAvailable(activity)) {
mLiftToWakePreference = (SwitchPreference) findPreference(KEY_LIFT_TO_WAKE);
mLiftToWakePreference.setOnPreferenceChangeListener(this);
} else {
removePreference(KEY_LIFT_TO_WAKE);
}
- if (isDozeAvailable(getActivity())) {
+ if (isDozeAvailable(activity)) {
mDozePreference = (SwitchPreference) findPreference(KEY_DOZE);
mDozePreference.setOnPreferenceChangeListener(this);
} else {
removePreference(KEY_DOZE);
}
+
+ if (RotationPolicy.isRotationLockToggleVisible(activity)) {
+ DropDownPreference rotatePreference =
+ (DropDownPreference) findPreference(KEY_AUTO_ROTATE);
+ rotatePreference.addItem(activity.getString(R.string.display_auto_rotate_rotate),
+ false);
+ int rotateLockedResourceId;
+ // The following block sets the string used when rotation is locked.
+ // If the device locks specifically to portrait or landscape (rather than current
+ // rotation), then we use a different string to include this information.
+ if (allowAllRotations(activity)) {
+ rotateLockedResourceId = R.string.display_auto_rotate_stay_in_current;
+ } else {
+ if (RotationPolicy.getRotationLockOrientation(activity)
+ == Configuration.ORIENTATION_PORTRAIT) {
+ rotateLockedResourceId =
+ R.string.display_auto_rotate_stay_in_portrait;
+ } else {
+ rotateLockedResourceId =
+ R.string.display_auto_rotate_stay_in_landscape;
+ }
+ }
+ rotatePreference.addItem(activity.getString(rotateLockedResourceId), true);
+ rotatePreference.setSelectedItem(RotationPolicy.isRotationLocked(activity) ?
+ 1 : 0);
+ rotatePreference.setCallback(new Callback() {
+ @Override
+ public boolean onItemSelected(int pos, Object value) {
+ RotationPolicy.setRotationLock(activity, (Boolean) value);
+ return true;
+ }
+ });
+ } else {
+ removePreference(KEY_AUTO_ROTATE);
+ }
+ }
+
+ private static boolean allowAllRotations(Context context) {
+ return Resources.getSystem().getBoolean(
+ com.android.internal.R.bool.config_allowAllRotations);
}
private static boolean isLiftToWakeAvailable(Context context) {
@@ -382,6 +428,9 @@
if (!isDozeAvailable(context)) {
result.add(KEY_DOZE);
}
+ if (!RotationPolicy.isRotationLockToggleVisible(context)) {
+ result.add(KEY_AUTO_ROTATE);
+ }
return result;
}
};
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 054995b..ec288f3 100755
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -393,7 +393,7 @@
}
if (profileFrag == null) {
LayoutInflater inflater = getActivity().getLayoutInflater();
- mSettingsDialogView = inflater.inflate(R.layout.bluetooth_device_picker, null);
+ mSettingsDialogView = inflater.inflate(R.layout.bluetooth_device_settings, null);
profileFrag = (DeviceProfilesSettings)activity.getFragmentManager()
.findFragmentById(R.id.bluetooth_fragment_settings);
}