Merge branch 'master' into honeycomb-release
This commit is contained in:
@@ -7,3 +7,6 @@
|
|||||||
-keep class com.android.settings.bluetooth.*
|
-keep class com.android.settings.bluetooth.*
|
||||||
-keep class com.android.settings.applications.*
|
-keep class com.android.settings.applications.*
|
||||||
-keep class com.android.settings.inputmethod.*
|
-keep class com.android.settings.inputmethod.*
|
||||||
|
-keep class com.android.settings.MasterClear
|
||||||
|
-keep class com.android.settings.MasterClearConfirm
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/wifi_setup_title"
|
android:id="@+id/wifi_setup_title"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
@@ -39,13 +39,13 @@
|
|||||||
android:id="@+id/scanning_progress_bar"
|
android:id="@+id/scanning_progress_bar"
|
||||||
android:layout_width="100dip"
|
android:layout_width="100dip"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_above="@+id/scanning_progress_text"
|
android:layout_above="@+id/scanning_progress_text"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
style="?android:attr/progressBarStyleHorizontal" />
|
style="?android:attr/progressBarStyleHorizontal" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/scanning_progress_text"
|
android:id="@+id/scanning_progress_text"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_above="@+id/top_divider"
|
android:layout_above="@+id/top_divider"
|
||||||
@@ -85,27 +85,23 @@
|
|||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/right_buttons"
|
android:id="@+id/right_buttons"
|
||||||
android:layout_width="300dip"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_alignParentBottom="true">
|
android:layout_alignParentBottom="true">
|
||||||
|
|
||||||
<Button android:id="@+id/wifi_setup_connect"
|
<Button android:id="@+id/wifi_setup_connect"
|
||||||
android:layout_width="260dip"
|
android:layout_width="260dip"
|
||||||
android:layout_height="60dip"
|
android:layout_height="60dip"
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:textSize="24dip"
|
android:textSize="24dip"
|
||||||
android:text="@string/wifi_connect"
|
android:text="@string/wifi_connect"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
<Button android:id="@+id/wifi_setup_forget"
|
<Button android:id="@+id/wifi_setup_forget"
|
||||||
android:layout_width="260dip"
|
android:layout_width="260dip"
|
||||||
android:layout_height="60dip"
|
android:layout_height="60dip"
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:textSize="24dip"
|
android:textSize="24dip"
|
||||||
android:text="@string/wifi_forget"
|
android:text="@string/wifi_forget"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
@@ -113,8 +109,6 @@
|
|||||||
<Button android:id="@+id/wifi_setup_add_network"
|
<Button android:id="@+id/wifi_setup_add_network"
|
||||||
android:layout_width="260dip"
|
android:layout_width="260dip"
|
||||||
android:layout_height="60dip"
|
android:layout_height="60dip"
|
||||||
android:layout_above="@+id/wifi_setup_refresh_list"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:textSize="24dip"
|
android:textSize="24dip"
|
||||||
android:text="@string/wifi_setup_add_network"
|
android:text="@string/wifi_setup_add_network"
|
||||||
android:enabled="false" />
|
android:enabled="false" />
|
||||||
@@ -122,8 +116,6 @@
|
|||||||
<Button android:id="@+id/wifi_setup_refresh_list"
|
<Button android:id="@+id/wifi_setup_refresh_list"
|
||||||
android:layout_width="260dip"
|
android:layout_width="260dip"
|
||||||
android:layout_height="60dip"
|
android:layout_height="60dip"
|
||||||
android:layout_above="@+id/wifi_setup_skip_or_next"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:textSize="24dip"
|
android:textSize="24dip"
|
||||||
android:text="@string/wifi_setup_refresh_list"
|
android:text="@string/wifi_setup_refresh_list"
|
||||||
android:enabled="false" />
|
android:enabled="false" />
|
||||||
@@ -132,12 +124,10 @@
|
|||||||
android:layout_width="260dip"
|
android:layout_width="260dip"
|
||||||
android:layout_height="60dip"
|
android:layout_height="60dip"
|
||||||
android:layout_marginTop="30dip"
|
android:layout_marginTop="30dip"
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:textSize="24dip"
|
android:textSize="24dip"
|
||||||
android:text="@string/wifi_setup_skip"
|
android:text="@string/wifi_setup_skip"
|
||||||
android:enabled="false" />
|
android:enabled="false" />
|
||||||
</RelativeLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<Button android:id="@+id/wifi_setup_detail"
|
<Button android:id="@+id/wifi_setup_detail"
|
||||||
android:layout_width="260dip"
|
android:layout_width="260dip"
|
||||||
|
|||||||
@@ -1,29 +1,31 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!-- Copyright (C) 2010 The Android Open Source Project
|
||||||
/*
|
|
||||||
**
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
** Copyright (C) 2008 The Android Open Source Project
|
you may not use this file except in compliance with the License.
|
||||||
**
|
You may obtain a copy of the License at
|
||||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
** you may not use this file except in compliance with the License.
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
** You may obtain a copy of the License at
|
|
||||||
**
|
Unless required by applicable law or agreed to in writing, software
|
||||||
** http://www.apache.org/licenses/LICENSE-2.0
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
**
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
** Unless required by applicable law or agreed to in writing, software
|
See the License for the specific language governing permissions and
|
||||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
limitations under the License.
|
||||||
** 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"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
style="@style/info_layout">
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dip"
|
android:layout_height="0dip"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:layout_marginRight="12dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
<LinearLayout android:layout_width="match_parent"
|
<LinearLayout android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -42,13 +44,14 @@
|
|||||||
<CheckBox android:id="@+id/erase_external"
|
<CheckBox android:id="@+id/erase_external"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="top"
|
android:layout_gravity="center_vertical"
|
||||||
android:paddingRight="8dp"
|
android:paddingRight="8dp"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:duplicateParentState="true" />
|
android:duplicateParentState="true" />
|
||||||
<LinearLayout android:layout_width="match_parent"
|
<LinearLayout android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -70,7 +73,8 @@
|
|||||||
android:id="@+id/initiate_master_clear"
|
android:id="@+id/initiate_master_clear"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:layout_marginTop="20dip"
|
android:layout_marginTop="20dip"
|
||||||
android:layout_width="150dip"
|
android:layout_marginBottom="12dip"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/master_clear_button_text"
|
android:text="@string/master_clear_button_text"
|
||||||
android:gravity="center" />
|
android:gravity="center" />
|
||||||
39
res/layout/master_clear_confirm.xml
Normal file
39
res/layout/master_clear_confirm.xml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2010 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="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:layout_marginRight="12dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:text="@string/master_clear_final_desc" />
|
||||||
|
|
||||||
|
<Button android:id="@+id/execute_master_clear"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_marginTop="40dip"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/master_clear_final_button_text"
|
||||||
|
android:gravity="center" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
/*
|
|
||||||
** Copyright (C) 2008 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"
|
|
||||||
style="@style/info_layout">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="20sp"
|
|
||||||
android:text="@string/master_clear_final_desc" />
|
|
||||||
|
|
||||||
<Button android:id="@+id/execute_master_clear"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:layout_marginTop="40dip"
|
|
||||||
android:layout_width="150dip"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/master_clear_final_button_text"
|
|
||||||
android:gravity="center" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
@@ -837,6 +837,17 @@
|
|||||||
<!-- Bluetooth settings. The summary string when a device is connected to the PAN profile. [CHAR LIMIT=35]-->
|
<!-- Bluetooth settings. The summary string when a device is connected to the PAN profile. [CHAR LIMIT=35]-->
|
||||||
<string name="bluetooth_summary_connected_to_pan">Tethered</string>
|
<string name="bluetooth_summary_connected_to_pan">Tethered</string>
|
||||||
|
|
||||||
|
<!-- Bluetooth settings. Message for disconnecting from the A2DP profile. -->
|
||||||
|
<string name="bluetooth_disconnect_a2dp_profile"><xliff:g id="device_name">%1$s</xliff:g> will be disconnected from media audio.</string>
|
||||||
|
<!-- Bluetooth settings. Message for disconnecting from the headset profile. -->
|
||||||
|
<string name="bluetooth_disconnect_headset_profile" product="tablet"><xliff:g id="device_name">%1$s</xliff:g> will be disconnected from tablet audio.</string>
|
||||||
|
<!-- Bluetooth settings. Message for disconnecting from the headset profile. -->
|
||||||
|
<string name="bluetooth_disconnect_headset_profile" product="default"><xliff:g id="device_name">%1$s</xliff:g> will be disconnected from phone audio.</string>
|
||||||
|
<!-- Bluetooth settings. Message for disconnecting from the HID profile. -->
|
||||||
|
<string name="bluetooth_disconnect_hid_profile"><xliff:g id="device_name">%1$s</xliff:g> will be disconnected from input device.</string>
|
||||||
|
<!-- Bluetooth settings. Message for disconnecting from the PAN profile. -->
|
||||||
|
<string name="bluetooth_disconnect_pan_profile"><xliff:g id="device_name">%1$s</xliff:g> will be disconnected from tethering.</string>
|
||||||
|
|
||||||
<!-- Bluetooth settings. Connection options screen. The title of the screen. -->
|
<!-- Bluetooth settings. Connection options screen. The title of the screen. -->
|
||||||
<string name="bluetooth_device_advanced_title"><xliff:g id="device_name">%1$s</xliff:g> options</string>
|
<string name="bluetooth_device_advanced_title"><xliff:g id="device_name">%1$s</xliff:g> options</string>
|
||||||
<!-- Bluetooth settings. Connection options screen. Title of device actions section. [CHAR LIMIT=30] -->
|
<!-- Bluetooth settings. Connection options screen. Title of device actions section. [CHAR LIMIT=30] -->
|
||||||
@@ -1608,6 +1619,8 @@
|
|||||||
<string name="master_clear_gesture_explanation">You must draw your unlock pattern to confirm a factory data reset.</string>
|
<string name="master_clear_gesture_explanation">You must draw your unlock pattern to confirm a factory data reset.</string>
|
||||||
<!-- Master clear failed message -->
|
<!-- Master clear failed message -->
|
||||||
<string name="master_clear_failed">No reset was performed because the System Clear service is not available.</string>
|
<string name="master_clear_failed">No reset was performed because the System Clear service is not available.</string>
|
||||||
|
<!-- Master clear confirmation screen title [CHAR LIMIT=30] -->
|
||||||
|
<string name="master_clear_confirm_title">Confirm reset</string>
|
||||||
|
|
||||||
<!-- Media Format -->
|
<!-- Media Format -->
|
||||||
<!-- SD card & phone storage settings screen, setting option name under Internal phone storage heading [CHAR LIMIT=25] -->
|
<!-- SD card & phone storage settings screen, setting option name under Internal phone storage heading [CHAR LIMIT=25] -->
|
||||||
|
|||||||
@@ -33,15 +33,11 @@
|
|||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/personal_data_section_title">
|
android:title="@string/personal_data_section_title"/>
|
||||||
<!-- Factory reset -->
|
<!-- Factory reset -->
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:title="@string/master_clear_title"
|
android:title="@string/master_clear_title"
|
||||||
android:summary="@string/master_clear_summary">
|
android:summary="@string/master_clear_summary"
|
||||||
<intent android:action="android.intent.action.MAIN"
|
android:fragment="com.android.settings.MasterClear" />
|
||||||
android:targetPackage="com.android.settings"
|
|
||||||
android:targetClass="com.android.settings.MasterClear" />
|
|
||||||
</PreferenceScreen>
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|||||||
@@ -16,21 +16,28 @@
|
|||||||
|
|
||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.Fragment;
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
|
||||||
|
|
||||||
public class ChooseLockSettingsHelper {
|
public class ChooseLockSettingsHelper {
|
||||||
private LockPatternUtils mLockPatternUtils;
|
private LockPatternUtils mLockPatternUtils;
|
||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
|
private Fragment mFragment;
|
||||||
|
|
||||||
public ChooseLockSettingsHelper(Activity activity) {
|
public ChooseLockSettingsHelper(Activity activity) {
|
||||||
mActivity = activity;
|
mActivity = activity;
|
||||||
mLockPatternUtils = new LockPatternUtils(activity);
|
mLockPatternUtils = new LockPatternUtils(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ChooseLockSettingsHelper(Activity activity, Fragment fragment) {
|
||||||
|
this(activity);
|
||||||
|
mFragment = fragment;
|
||||||
|
}
|
||||||
|
|
||||||
public LockPatternUtils utils() {
|
public LockPatternUtils utils() {
|
||||||
return mLockPatternUtils;
|
return mLockPatternUtils;
|
||||||
}
|
}
|
||||||
@@ -76,7 +83,11 @@ public class ChooseLockSettingsHelper {
|
|||||||
intent.putExtra(ConfirmLockPattern.HEADER_TEXT, message);
|
intent.putExtra(ConfirmLockPattern.HEADER_TEXT, message);
|
||||||
intent.putExtra(ConfirmLockPattern.FOOTER_TEXT, details);
|
intent.putExtra(ConfirmLockPattern.FOOTER_TEXT, details);
|
||||||
intent.setClassName("com.android.settings", "com.android.settings.ConfirmLockPattern");
|
intent.setClassName("com.android.settings", "com.android.settings.ConfirmLockPattern");
|
||||||
mActivity.startActivityForResult(intent, request);
|
if (mFragment != null) {
|
||||||
|
mFragment.startActivityForResult(intent, request);
|
||||||
|
} else {
|
||||||
|
mActivity.startActivityForResult(intent, request);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +100,11 @@ public class ChooseLockSettingsHelper {
|
|||||||
if (!mLockPatternUtils.isLockPasswordEnabled()) return false;
|
if (!mLockPatternUtils.isLockPasswordEnabled()) return false;
|
||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
intent.setClassName("com.android.settings", "com.android.settings.ConfirmLockPassword");
|
intent.setClassName("com.android.settings", "com.android.settings.ConfirmLockPassword");
|
||||||
mActivity.startActivityForResult(intent, request);
|
if (mFragment != null) {
|
||||||
|
mFragment.startActivityForResult(intent, request);
|
||||||
|
} else {
|
||||||
|
mActivity.startActivityForResult(intent, request);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,14 +16,18 @@
|
|||||||
|
|
||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
import com.android.internal.os.storage.ExternalStorageFormatter;
|
import com.android.settings.R;
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.Fragment;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.Preference;
|
||||||
|
import android.preference.PreferenceActivity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
|
||||||
@@ -34,44 +38,20 @@ import android.widget.CheckBox;
|
|||||||
* has defined one, followed by a final strongly-worded "THIS WILL ERASE EVERYTHING
|
* has defined one, followed by a final strongly-worded "THIS WILL ERASE EVERYTHING
|
||||||
* ON THE PHONE" prompt. If at any time the phone is allowed to go to sleep, is
|
* ON THE PHONE" prompt. If at any time the phone is allowed to go to sleep, is
|
||||||
* locked, et cetera, then the confirmation sequence is abandoned.
|
* locked, et cetera, then the confirmation sequence is abandoned.
|
||||||
|
*
|
||||||
|
* This is the initial screen.
|
||||||
*/
|
*/
|
||||||
public class MasterClear extends Activity {
|
public class MasterClear extends Fragment {
|
||||||
|
|
||||||
private static final int KEYGUARD_REQUEST = 55;
|
private static final int KEYGUARD_REQUEST = 55;
|
||||||
|
|
||||||
private LayoutInflater mInflater;
|
static final String ERASE_EXTERNAL_EXTRA = "erase_sd";
|
||||||
private LockPatternUtils mLockUtils;
|
|
||||||
|
|
||||||
private View mInitialView;
|
private View mContentView;
|
||||||
private Button mInitiateButton;
|
private Button mInitiateButton;
|
||||||
private View mExternalStorageContainer;
|
private View mExternalStorageContainer;
|
||||||
private CheckBox mExternalStorage;
|
private CheckBox mExternalStorage;
|
||||||
|
|
||||||
private View mFinalView;
|
|
||||||
private Button mFinalButton;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The user has gone through the multiple confirmation, so now we go ahead
|
|
||||||
* and invoke the Checkin Service to reset the device to its factory-default
|
|
||||||
* state (rebooting in the process).
|
|
||||||
*/
|
|
||||||
private Button.OnClickListener mFinalClickListener = new Button.OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (Utils.isMonkeyRunning()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mExternalStorage.isChecked()) {
|
|
||||||
Intent intent = new Intent(ExternalStorageFormatter.FORMAT_AND_FACTORY_RESET);
|
|
||||||
intent.setComponent(ExternalStorageFormatter.COMPONENT_NAME);
|
|
||||||
startService(intent);
|
|
||||||
} else {
|
|
||||||
sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR"));
|
|
||||||
// Intent handling is asynchronous -- assume it will happen soon.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keyguard validation is run using the standard {@link ConfirmLockPattern}
|
* Keyguard validation is run using the standard {@link ConfirmLockPattern}
|
||||||
* component as a subactivity
|
* component as a subactivity
|
||||||
@@ -79,14 +59,15 @@ public class MasterClear extends Activity {
|
|||||||
* @return true if confirmation launched
|
* @return true if confirmation launched
|
||||||
*/
|
*/
|
||||||
private boolean runKeyguardConfirmation(int request) {
|
private boolean runKeyguardConfirmation(int request) {
|
||||||
return new ChooseLockSettingsHelper(this)
|
Resources res = getActivity().getResources();
|
||||||
|
return new ChooseLockSettingsHelper(getActivity(), this)
|
||||||
.launchConfirmationActivity(request,
|
.launchConfirmationActivity(request,
|
||||||
getText(R.string.master_clear_gesture_prompt),
|
res.getText(R.string.master_clear_gesture_prompt),
|
||||||
getText(R.string.master_clear_gesture_explanation));
|
res.getText(R.string.master_clear_gesture_explanation));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
|
||||||
if (requestCode != KEYGUARD_REQUEST) {
|
if (requestCode != KEYGUARD_REQUEST) {
|
||||||
@@ -96,40 +77,33 @@ public class MasterClear extends Activity {
|
|||||||
// If the user entered a valid keyguard trace, present the final
|
// If the user entered a valid keyguard trace, present the final
|
||||||
// confirmation prompt; otherwise, go back to the initial state.
|
// confirmation prompt; otherwise, go back to the initial state.
|
||||||
if (resultCode == Activity.RESULT_OK) {
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
establishFinalConfirmationState();
|
showFinalConfirmation();
|
||||||
} else if (resultCode == Activity.RESULT_CANCELED) {
|
|
||||||
finish();
|
|
||||||
} else {
|
} else {
|
||||||
establishInitialState();
|
establishInitialState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showFinalConfirmation() {
|
||||||
|
Preference preference = new Preference(getActivity());
|
||||||
|
preference.setFragment(MasterClearConfirm.class.getName());
|
||||||
|
preference.setTitle(R.string.master_clear_confirm_title);
|
||||||
|
preference.getExtras().putBoolean(ERASE_EXTERNAL_EXTRA, mExternalStorage.isChecked());
|
||||||
|
((PreferenceActivity) getActivity()).onPreferenceStartFragment(null, preference);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the user clicks to begin the reset sequence, we next require a
|
* If the user clicks to begin the reset sequence, we next require a
|
||||||
* keyguard confirmation if the user has currently enabled one. If there
|
* keyguard confirmation if the user has currently enabled one. If there
|
||||||
* is no keyguard available, we simply go to the final confirmation prompt.
|
* is no keyguard available, we simply go to the final confirmation prompt.
|
||||||
*/
|
*/
|
||||||
private Button.OnClickListener mInitiateListener = new Button.OnClickListener() {
|
private Button.OnClickListener mInitiateListener = new Button.OnClickListener() {
|
||||||
public void onClick(View v) {
|
|
||||||
if (!runKeyguardConfirmation(KEYGUARD_REQUEST)) {
|
public void onClick(View v) {
|
||||||
establishFinalConfirmationState();
|
if (!runKeyguardConfirmation(KEYGUARD_REQUEST)) {
|
||||||
}
|
showFinalConfirmation();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure the UI for the final confirmation interaction
|
|
||||||
*/
|
|
||||||
private void establishFinalConfirmationState() {
|
|
||||||
if (mFinalView == null) {
|
|
||||||
mFinalView = mInflater.inflate(R.layout.master_clear_final, null);
|
|
||||||
mFinalButton =
|
|
||||||
(Button) mFinalView.findViewById(R.id.execute_master_clear);
|
|
||||||
mFinalButton.setOnClickListener(mFinalClickListener);
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
setContentView(mFinalView);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In its initial state, the activity presents a button for the user to
|
* In its initial state, the activity presents a button for the user to
|
||||||
@@ -144,48 +118,25 @@ public class MasterClear extends Activity {
|
|||||||
* to change contents.
|
* to change contents.
|
||||||
*/
|
*/
|
||||||
private void establishInitialState() {
|
private void establishInitialState() {
|
||||||
if (mInitialView == null) {
|
mInitiateButton = (Button) mContentView.findViewById(R.id.initiate_master_clear);
|
||||||
mInitialView = mInflater.inflate(R.layout.master_clear_primary, null);
|
mInitiateButton.setOnClickListener(mInitiateListener);
|
||||||
mInitiateButton =
|
mExternalStorageContainer = mContentView.findViewById(R.id.erase_external_container);
|
||||||
(Button) mInitialView.findViewById(R.id.initiate_master_clear);
|
mExternalStorage = (CheckBox) mContentView.findViewById(R.id.erase_external);
|
||||||
mInitiateButton.setOnClickListener(mInitiateListener);
|
|
||||||
mExternalStorageContainer =
|
|
||||||
mInitialView.findViewById(R.id.erase_external_container);
|
|
||||||
mExternalStorage =
|
|
||||||
(CheckBox) mInitialView.findViewById(R.id.erase_external);
|
|
||||||
mExternalStorageContainer.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
mExternalStorage.toggle();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
setContentView(mInitialView);
|
mExternalStorageContainer.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
mExternalStorage.toggle();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
super.onCreate(savedState);
|
Bundle savedInstanceState) {
|
||||||
|
mContentView = inflater.inflate(R.layout.master_clear, null);
|
||||||
mInitialView = null;
|
|
||||||
mFinalView = null;
|
|
||||||
mInflater = LayoutInflater.from(this);
|
|
||||||
mLockUtils = new LockPatternUtils(this);
|
|
||||||
|
|
||||||
establishInitialState();
|
establishInitialState();
|
||||||
}
|
return mContentView;
|
||||||
|
|
||||||
/** Abandon all progress through the confirmation sequence by returning
|
|
||||||
* to the initial view any time the activity is interrupted (e.g. by
|
|
||||||
* idle timeout).
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
|
|
||||||
if (!isFinishing()) {
|
|
||||||
establishInitialState();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
95
src/com/android/settings/MasterClearConfirm.java
Normal file
95
src/com/android/settings/MasterClearConfirm.java
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 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;
|
||||||
|
|
||||||
|
import com.android.internal.os.storage.ExternalStorageFormatter;
|
||||||
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.Fragment;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Confirm and execute a reset of the device to a clean "just out of the box"
|
||||||
|
* state. Multiple confirmations are required: first, a general "are you sure
|
||||||
|
* you want to do this?" prompt, followed by a keyguard pattern trace if the user
|
||||||
|
* has defined one, followed by a final strongly-worded "THIS WILL ERASE EVERYTHING
|
||||||
|
* ON THE PHONE" prompt. If at any time the phone is allowed to go to sleep, is
|
||||||
|
* locked, et cetera, then the confirmation sequence is abandoned.
|
||||||
|
*
|
||||||
|
* This is the confirmation screen.
|
||||||
|
*/
|
||||||
|
public class MasterClearConfirm extends Fragment {
|
||||||
|
|
||||||
|
private View mContentView;
|
||||||
|
private boolean mEraseSdCard;
|
||||||
|
private Button mFinalButton;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The user has gone through the multiple confirmation, so now we go ahead
|
||||||
|
* and invoke the Checkin Service to reset the device to its factory-default
|
||||||
|
* state (rebooting in the process).
|
||||||
|
*/
|
||||||
|
private Button.OnClickListener mFinalClickListener = new Button.OnClickListener() {
|
||||||
|
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (Utils.isMonkeyRunning()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mEraseSdCard) {
|
||||||
|
Intent intent = new Intent(ExternalStorageFormatter.FORMAT_AND_FACTORY_RESET);
|
||||||
|
intent.setComponent(ExternalStorageFormatter.COMPONENT_NAME);
|
||||||
|
getActivity().startService(intent);
|
||||||
|
} else {
|
||||||
|
getActivity().sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR"));
|
||||||
|
// Intent handling is asynchronous -- assume it will happen soon.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure the UI for the final confirmation interaction
|
||||||
|
*/
|
||||||
|
private void establishFinalConfirmationState() {
|
||||||
|
mFinalButton = (Button) mContentView.findViewById(R.id.execute_master_clear);
|
||||||
|
mFinalButton.setOnClickListener(mFinalClickListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
mContentView = inflater.inflate(R.layout.master_clear_confirm, null);
|
||||||
|
establishFinalConfirmationState();
|
||||||
|
return mContentView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
Bundle args = getArguments();
|
||||||
|
mEraseSdCard = args != null ? args.getBoolean(MasterClear.ERASE_EXTERNAL_EXTRA) : false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -98,7 +98,7 @@ public class PrivacySettings extends SettingsPreferenceFragment implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showEraseBackupDialog() {
|
private void showEraseBackupDialog() {
|
||||||
|
|||||||
@@ -155,7 +155,6 @@ public class SettingsPreferenceFragment extends PreferenceFragment
|
|||||||
mDialogFragment.show(getActivity().getFragmentManager(), Integer.toString(dialogId));
|
mDialogFragment.show(getActivity().getFragmentManager(), Integer.toString(dialogId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dialog onCreateDialog(int dialogId) {
|
public Dialog onCreateDialog(int dialogId) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ public class BluetoothPairingDialog extends AlertActivity implements DialogInter
|
|||||||
TextWatcher {
|
TextWatcher {
|
||||||
private static final String TAG = "BluetoothPairingDialog";
|
private static final String TAG = "BluetoothPairingDialog";
|
||||||
|
|
||||||
private final int BLUETOOTH_PIN_MAX_LENGTH = 16;
|
private static final int BLUETOOTH_PIN_MAX_LENGTH = 16;
|
||||||
private final int BLUETOOTH_PASSKEY_MAX_LENGTH = 6;
|
private static final int BLUETOOTH_PASSKEY_MAX_LENGTH = 6;
|
||||||
private LocalBluetoothManager mLocalManager;
|
private LocalBluetoothManager mLocalManager;
|
||||||
private BluetoothDevice mDevice;
|
private BluetoothDevice mDevice;
|
||||||
private int mType;
|
private int mType;
|
||||||
|
|||||||
@@ -251,7 +251,6 @@ public class BluetoothSettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUserLeaveHint() {
|
public void onUserLeaveHint() {
|
||||||
mLocalManager.stopScanning();
|
mLocalManager.stopScanning();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,9 +104,9 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
|||||||
* @param profile Profile to describe
|
* @param profile Profile to describe
|
||||||
* @return Description of the device and profile
|
* @return Description of the device and profile
|
||||||
*/
|
*/
|
||||||
private String describe(CachedBluetoothDevice cachedDevice, Profile profile) {
|
private String describe(Profile profile) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Address:").append(cachedDevice.mDevice);
|
sb.append("Address:").append(mDevice);
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
sb.append(" Profile:").append(profile.name());
|
sb.append(" Profile:").append(profile.name());
|
||||||
}
|
}
|
||||||
@@ -114,10 +114,6 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String describe(Profile profile) {
|
|
||||||
return describe(this, profile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onProfileStateChanged(Profile profile, int newProfileState) {
|
public void onProfileStateChanged(Profile profile, int newProfileState) {
|
||||||
if (D) {
|
if (D) {
|
||||||
Log.d(TAG, "onProfileStateChanged: profile " + profile.toString() +
|
Log.d(TAG, "onProfileStateChanged: profile " + profile.toString() +
|
||||||
@@ -166,20 +162,13 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect(Profile profile) {
|
public void disconnect(Profile profile) {
|
||||||
disconnectInt(this, profile);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean disconnectInt(CachedBluetoothDevice cachedDevice, Profile profile) {
|
|
||||||
LocalBluetoothProfileManager profileManager =
|
LocalBluetoothProfileManager profileManager =
|
||||||
LocalBluetoothProfileManager.getProfileManager(mLocalManager, profile);
|
LocalBluetoothProfileManager.getProfileManager(mLocalManager, profile);
|
||||||
int status = profileManager.getConnectionStatus(cachedDevice.mDevice);
|
if (profileManager.disconnect(mDevice)) {
|
||||||
if (profileManager.disconnect(cachedDevice.mDevice)) {
|
|
||||||
if (D) {
|
if (D) {
|
||||||
Log.d(TAG, "Command sent successfully:DISCONNECT " + describe(profile));
|
Log.d(TAG, "Command sent successfully:DISCONNECT " + describe(profile));
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void askDisconnect() {
|
public void askDisconnect() {
|
||||||
@@ -204,6 +193,57 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
showDisconnectDialog(context, disconnectListener, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void askDisconnect(final Profile profile) {
|
||||||
|
Context context = mLocalManager.getForegroundActivity();
|
||||||
|
if (context == null) {
|
||||||
|
// Cannot ask, since we need an activity context
|
||||||
|
disconnect(profile);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Resources res = context.getResources();
|
||||||
|
|
||||||
|
String name = getName();
|
||||||
|
if (TextUtils.isEmpty(name)) {
|
||||||
|
name = res.getString(R.string.bluetooth_device);
|
||||||
|
}
|
||||||
|
int disconnectMessage;
|
||||||
|
switch (profile) {
|
||||||
|
case A2DP:
|
||||||
|
disconnectMessage = R.string.bluetooth_disconnect_a2dp_profile;
|
||||||
|
break;
|
||||||
|
case HEADSET:
|
||||||
|
disconnectMessage = R.string.bluetooth_disconnect_headset_profile;
|
||||||
|
break;
|
||||||
|
case HID:
|
||||||
|
disconnectMessage = R.string.bluetooth_disconnect_hid_profile;
|
||||||
|
break;
|
||||||
|
case PAN:
|
||||||
|
disconnectMessage = R.string.bluetooth_disconnect_pan_profile;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Log.w(TAG, "askDisconnect: unexpected profile " + profile);
|
||||||
|
disconnectMessage = R.string.bluetooth_disconnect_blank;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
String message = res.getString(disconnectMessage, name);
|
||||||
|
|
||||||
|
DialogInterface.OnClickListener disconnectListener =
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
disconnect(profile);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
showDisconnectDialog(context, disconnectListener, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showDisconnectDialog(Context context,
|
||||||
|
DialogInterface.OnClickListener disconnectListener,
|
||||||
|
String message) {
|
||||||
if (mDialog == null) {
|
if (mDialog == null) {
|
||||||
mDialog = new AlertDialog.Builder(context)
|
mDialog = new AlertDialog.Builder(context)
|
||||||
.setPositiveButton(android.R.string.ok, disconnectListener)
|
.setPositiveButton(android.R.string.ok, disconnectListener)
|
||||||
@@ -213,6 +253,10 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
|||||||
if (mDialog.isShowing()) {
|
if (mDialog.isShowing()) {
|
||||||
mDialog.dismiss();
|
mDialog.dismiss();
|
||||||
}
|
}
|
||||||
|
// use disconnectListener for the correct profile(s)
|
||||||
|
CharSequence okText = context.getText(android.R.string.ok);
|
||||||
|
mDialog.setButton(DialogInterface.BUTTON_POSITIVE,
|
||||||
|
okText, disconnectListener);
|
||||||
}
|
}
|
||||||
mDialog.setTitle(getName());
|
mDialog.setTitle(getName());
|
||||||
mDialog.setMessage(message);
|
mDialog.setMessage(message);
|
||||||
@@ -311,7 +355,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
|||||||
CachedBluetoothDevice cachedDevice = cachedDeviceManager.findDevice(btDevice);
|
CachedBluetoothDevice cachedDevice = cachedDeviceManager.findDevice(btDevice);
|
||||||
|
|
||||||
if (cachedDevice != null && !cachedDevice.equals(device)) {
|
if (cachedDevice != null && !cachedDevice.equals(device)) {
|
||||||
disconnectInt(cachedDevice, profile);
|
cachedDevice.disconnect(profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -321,7 +365,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
|||||||
|
|
||||||
LocalBluetoothProfileManager profileManager =
|
LocalBluetoothProfileManager profileManager =
|
||||||
LocalBluetoothProfileManager.getProfileManager(mLocalManager, profile);
|
LocalBluetoothProfileManager.getProfileManager(mLocalManager, profile);
|
||||||
int status = profileManager.getConnectionStatus(cachedDevice.mDevice);
|
|
||||||
if (profileManager.connect(cachedDevice.mDevice)) {
|
if (profileManager.connect(cachedDevice.mDevice)) {
|
||||||
if (D) {
|
if (D) {
|
||||||
Log.d(TAG, "Command sent successfully:CONNECT " + describe(profile));
|
Log.d(TAG, "Command sent successfully:CONNECT " + describe(profile));
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import com.android.settings.SettingsPreferenceFragment;
|
|||||||
import com.android.settings.bluetooth.LocalBluetoothProfileManager.Profile;
|
import com.android.settings.bluetooth.LocalBluetoothProfileManager.Profile;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.EditTextPreference;
|
import android.preference.EditTextPreference;
|
||||||
@@ -35,8 +34,8 @@ import android.view.View;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ConnectSpecificProfilesActivity presents the user with all of the profiles
|
* This preference fragment presents the user with all of the profiles
|
||||||
* for a particular device, and allows him to choose which should be connected
|
* for a particular device, and allows them to be individually connected
|
||||||
* (or disconnected).
|
* (or disconnected).
|
||||||
*/
|
*/
|
||||||
public class DeviceProfilesSettings extends SettingsPreferenceFragment
|
public class DeviceProfilesSettings extends SettingsPreferenceFragment
|
||||||
@@ -155,9 +154,6 @@ public class DeviceProfilesSettings extends SettingsPreferenceFragment
|
|||||||
pref.setOrder(getProfilePreferenceIndex(profile));
|
pref.setOrder(getProfilePreferenceIndex(profile));
|
||||||
pref.setOnExpandClickListener(this);
|
pref.setOnExpandClickListener(this);
|
||||||
|
|
||||||
LocalBluetoothProfileManager profileManager = LocalBluetoothProfileManager
|
|
||||||
.getProfileManager(mManager, profile);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gray out profile while connecting and disconnecting
|
* Gray out profile while connecting and disconnecting
|
||||||
*/
|
*/
|
||||||
@@ -172,7 +168,7 @@ public class DeviceProfilesSettings extends SettingsPreferenceFragment
|
|||||||
public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) {
|
public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) {
|
||||||
String key = preference.getKey();
|
String key = preference.getKey();
|
||||||
if (preference instanceof BluetoothProfilePreference) {
|
if (preference instanceof BluetoothProfilePreference) {
|
||||||
onProfileClicked(preference, Profile.valueOf(key));
|
onProfileClicked(Profile.valueOf(key));
|
||||||
return true;
|
return true;
|
||||||
} else if (key.equals(KEY_UNPAIR)) {
|
} else if (key.equals(KEY_UNPAIR)) {
|
||||||
unpairDevice();
|
unpairDevice();
|
||||||
@@ -196,18 +192,24 @@ public class DeviceProfilesSettings extends SettingsPreferenceFragment
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onProfileClicked(Preference preference, Profile profile) {
|
private void onProfileClicked(Profile profile) {
|
||||||
|
BluetoothDevice device = mCachedDevice.getDevice();
|
||||||
LocalBluetoothProfileManager profileManager = LocalBluetoothProfileManager
|
LocalBluetoothProfileManager profileManager = LocalBluetoothProfileManager
|
||||||
.getProfileManager(mManager, profile);
|
.getProfileManager(mManager, profile);
|
||||||
// TODO: Get the current state and flip it, updating the summary for the preference
|
|
||||||
|
|
||||||
// profileManager.setPreferred(mCachedDevice.getDevice(), checked);
|
int status = profileManager.getConnectionStatus(device);
|
||||||
//
|
boolean isConnected =
|
||||||
// if (checked) {
|
SettingsBtStatus.isConnectionStatusConnected(status);
|
||||||
// mCachedDevice.connect(profile);
|
|
||||||
// } else {
|
// TODO: only change the preference on disconnect if user confirms
|
||||||
// mCachedDevice.disconnect(profile);
|
// TODO: add method to change priority of individual profiles
|
||||||
// }
|
// profileManager.setPreferred(device, !isConnected);
|
||||||
|
|
||||||
|
if (isConnected) {
|
||||||
|
mCachedDevice.askDisconnect(profile);
|
||||||
|
} else {
|
||||||
|
mCachedDevice.connect(profile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDeviceAttributesChanged(CachedBluetoothDevice cachedDevice) {
|
public void onDeviceAttributesChanged(CachedBluetoothDevice cachedDevice) {
|
||||||
|
|||||||
@@ -496,7 +496,7 @@ public class DockService extends Service implements AlertDialog.OnMultiChoiceCli
|
|||||||
private CharSequence[] initBtSettings(DockService service, BluetoothDevice device, int state,
|
private CharSequence[] initBtSettings(DockService service, BluetoothDevice device, int state,
|
||||||
boolean firstTime) {
|
boolean firstTime) {
|
||||||
// TODO Avoid hardcoding dock and profiles. Read from system properties
|
// TODO Avoid hardcoding dock and profiles. Read from system properties
|
||||||
int numOfProfiles = 0;
|
int numOfProfiles;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case Intent.EXTRA_DOCK_STATE_DESK:
|
case Intent.EXTRA_DOCK_STATE_DESK:
|
||||||
numOfProfiles = 1;
|
numOfProfiles = 1;
|
||||||
@@ -729,7 +729,7 @@ public class DockService extends Service implements AlertDialog.OnMultiChoiceCli
|
|||||||
profileManager.setPreferred(device, mCheckedItems[i]);
|
profileManager.setPreferred(device, mCheckedItems[i]);
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
if (mCheckedItems[i] != profileManager.isPreferred(device)) {
|
if (mCheckedItems[i] != profileManager.isPreferred(device)) {
|
||||||
Log.e(TAG, "Can't save prefered value");
|
Log.e(TAG, "Can't save preferred value");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class LocalBluetoothManager {
|
|||||||
// If a device was picked from the device picker or was in discoverable mode
|
// If a device was picked from the device picker or was in discoverable mode
|
||||||
// in the last 60 seconds, show the pairing dialogs in foreground instead
|
// in the last 60 seconds, show the pairing dialogs in foreground instead
|
||||||
// of raising notifications
|
// of raising notifications
|
||||||
private static long GRACE_PERIOD_TO_SHOW_DIALOGS_IN_FOREGROUND = 60 * 1000;
|
private static final int GRACE_PERIOD_TO_SHOW_DIALOGS_IN_FOREGROUND = 60 * 1000;
|
||||||
|
|
||||||
public static final String SHARED_PREFERENCES_KEY_DISCOVERING_TIMESTAMP =
|
public static final String SHARED_PREFERENCES_KEY_DISCOVERING_TIMESTAMP =
|
||||||
"last_discovering_time";
|
"last_discovering_time";
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ public abstract class LocalBluetoothProfileManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: int instead of enum
|
// TODO: int instead of enum
|
||||||
public enum Profile {
|
public static enum Profile {
|
||||||
HEADSET(R.string.bluetooth_profile_headset),
|
HEADSET(R.string.bluetooth_profile_headset),
|
||||||
A2DP(R.string.bluetooth_profile_a2dp),
|
A2DP(R.string.bluetooth_profile_a2dp),
|
||||||
OPP(R.string.bluetooth_profile_opp),
|
OPP(R.string.bluetooth_profile_opp),
|
||||||
@@ -433,7 +433,7 @@ public abstract class LocalBluetoothProfileManager {
|
|||||||
public boolean disconnect(BluetoothDevice device) {
|
public boolean disconnect(BluetoothDevice device) {
|
||||||
List<BluetoothDevice> deviceList = getConnectedDevices();
|
List<BluetoothDevice> deviceList = getConnectedDevices();
|
||||||
if (deviceList.size() != 0 && deviceList.get(0).equals(device)) {
|
if (deviceList.size() != 0 && deviceList.get(0).equals(device)) {
|
||||||
// Downgrade prority as user is disconnecting the headset.
|
// Downgrade priority as user is disconnecting the headset.
|
||||||
if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON) {
|
if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON) {
|
||||||
mService.setPriority(device, BluetoothProfile.PRIORITY_ON);
|
mService.setPriority(device, BluetoothProfile.PRIORITY_ON);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,15 +48,19 @@ public class InputMethodAndSubtypeUtil {
|
|||||||
private static final TextUtils.SimpleStringSplitter sStringInputMethodSubtypeSplitter
|
private static final TextUtils.SimpleStringSplitter sStringInputMethodSubtypeSplitter
|
||||||
= new TextUtils.SimpleStringSplitter(INPUT_METHOD_SUBTYPE_SEPARATER);
|
= new TextUtils.SimpleStringSplitter(INPUT_METHOD_SUBTYPE_SEPARATER);
|
||||||
|
|
||||||
private static boolean isInputMethodSubtypeSelected(ContentResolver resolver) {
|
private static int getInputMethodSubtypeSelected(ContentResolver resolver) {
|
||||||
try {
|
try {
|
||||||
return Settings.Secure.getInt(resolver,
|
return Settings.Secure.getInt(resolver,
|
||||||
Settings.Secure.SELECTED_INPUT_METHOD_SUBTYPE) != NOT_A_SUBTYPE_ID;
|
Settings.Secure.SELECTED_INPUT_METHOD_SUBTYPE);
|
||||||
} catch (SettingNotFoundException e) {
|
} catch (SettingNotFoundException e) {
|
||||||
return false;
|
return NOT_A_SUBTYPE_ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isInputMethodSubtypeSelected(ContentResolver resolver) {
|
||||||
|
return getInputMethodSubtypeSelected(resolver) != NOT_A_SUBTYPE_ID;
|
||||||
|
}
|
||||||
|
|
||||||
private static void putSelectedInputMethodSubtype(ContentResolver resolver, int hashCode) {
|
private static void putSelectedInputMethodSubtype(ContentResolver resolver, int hashCode) {
|
||||||
Settings.Secure.putInt(resolver, Settings.Secure.SELECTED_INPUT_METHOD_SUBTYPE, hashCode);
|
Settings.Secure.putInt(resolver, Settings.Secure.SELECTED_INPUT_METHOD_SUBTYPE, hashCode);
|
||||||
}
|
}
|
||||||
@@ -98,6 +102,7 @@ public class InputMethodAndSubtypeUtil {
|
|||||||
boolean hasHardKeyboard, String lastTickedInputMethodId) {
|
boolean hasHardKeyboard, String lastTickedInputMethodId) {
|
||||||
String currentInputMethodId = Settings.Secure.getString(resolver,
|
String currentInputMethodId = Settings.Secure.getString(resolver,
|
||||||
Settings.Secure.DEFAULT_INPUT_METHOD);
|
Settings.Secure.DEFAULT_INPUT_METHOD);
|
||||||
|
final int selectedInputMethodSubtype = getInputMethodSubtypeSelected(resolver);
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
StringBuilder disabledSysImes = new StringBuilder();
|
StringBuilder disabledSysImes = new StringBuilder();
|
||||||
@@ -105,6 +110,7 @@ public class InputMethodAndSubtypeUtil {
|
|||||||
int firstSubtypeHashCode = NOT_A_SUBTYPE_ID;
|
int firstSubtypeHashCode = NOT_A_SUBTYPE_ID;
|
||||||
|
|
||||||
final boolean onlyOneIME = inputMethodProperties.size() == 1;
|
final boolean onlyOneIME = inputMethodProperties.size() == 1;
|
||||||
|
boolean existsSelectedIME = false;
|
||||||
for (InputMethodInfo property : inputMethodProperties) {
|
for (InputMethodInfo property : inputMethodProperties) {
|
||||||
final String id = property.getId();
|
final String id = property.getId();
|
||||||
CheckBoxPreference pref = (CheckBoxPreference) context.findPreference(id);
|
CheckBoxPreference pref = (CheckBoxPreference) context.findPreference(id);
|
||||||
@@ -123,8 +129,12 @@ public class InputMethodAndSubtypeUtil {
|
|||||||
id + subtype.hashCode());
|
id + subtype.hashCode());
|
||||||
if (subtypePref != null && subtypePref.isChecked()) {
|
if (subtypePref != null && subtypePref.isChecked()) {
|
||||||
builder.append(INPUT_METHOD_SUBTYPE_SEPARATER).append(subtype.hashCode());
|
builder.append(INPUT_METHOD_SUBTYPE_SEPARATER).append(subtype.hashCode());
|
||||||
if (firstSubtypeHashCode == NOT_A_SUBTYPE_ID) {
|
if (isCurrentInputMethod) {
|
||||||
firstSubtypeHashCode = subtype.hashCode();
|
if (selectedInputMethodSubtype == subtype.hashCode()) {
|
||||||
|
existsSelectedIME = true;
|
||||||
|
} else if (firstSubtypeHashCode == NOT_A_SUBTYPE_ID) {
|
||||||
|
firstSubtypeHashCode = subtype.hashCode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,9 +168,10 @@ public class InputMethodAndSubtypeUtil {
|
|||||||
Log.d(TAG, "--- Save default inputmethod settings. :" + currentInputMethodId);
|
Log.d(TAG, "--- Save default inputmethod settings. :" + currentInputMethodId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// redefines SelectedSubtype when all subtypes are unchecked or there is no subtype
|
// Redefines SelectedSubtype when all subtypes are unchecked or there is no subtype
|
||||||
// selected.
|
// selected. And if the selected subtype of the current input method was disabled,
|
||||||
if (firstSubtypeHashCode == NOT_A_SUBTYPE_ID || !isInputMethodSubtypeSelected(resolver)) {
|
// We should reset the selected input method's subtype.
|
||||||
|
if (!existsSelectedIME || !isInputMethodSubtypeSelected(resolver)) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "--- Set inputmethod subtype because it's not defined."
|
Log.d(TAG, "--- Set inputmethod subtype because it's not defined."
|
||||||
+ firstSubtypeHashCode);
|
+ firstSubtypeHashCode);
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
|
|||||||
// This is a tweak for letting users not confused with WiFi state during a first first steps.
|
// This is a tweak for letting users not confused with WiFi state during a first first steps.
|
||||||
private int mIgnoringWifiNotificationCount = 5;
|
private int mIgnoringWifiNotificationCount = 5;
|
||||||
|
|
||||||
|
private boolean mShowingConnectingMessageManually = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -127,6 +129,14 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
|
|||||||
break;
|
break;
|
||||||
case R.id.wifi_setup_connect:
|
case R.id.wifi_setup_connect:
|
||||||
mWifiSettings.submit();
|
mWifiSettings.submit();
|
||||||
|
|
||||||
|
// updateConnectionState() isn't called soon after the user's "connect" action,
|
||||||
|
// and the user still sees "not connected" message for a while, which looks strange.
|
||||||
|
// We instead manually show "connecting" message before the system gets actual
|
||||||
|
// "connecting" message from Wi-Fi module.
|
||||||
|
showConnectingStatus();
|
||||||
|
mShowingConnectingMessageManually = true;
|
||||||
|
mIgnoringWifiNotificationCount = 2;
|
||||||
break;
|
break;
|
||||||
case R.id.wifi_setup_forget:
|
case R.id.wifi_setup_forget:
|
||||||
mWifiSettings.forget();
|
mWifiSettings.forget();
|
||||||
@@ -167,10 +177,8 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CONNECTING: {
|
case CONNECTING: {
|
||||||
mProgressBar.setIndeterminate(false);
|
mShowingConnectingMessageManually = false;
|
||||||
mProgressBar.setProgress(1);
|
showConnectingStatus();
|
||||||
mStatusText.setText(R.string.wifi_setup_status_connecting);
|
|
||||||
mProgressText.setText(Summary.get(this, state));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CONNECTED: {
|
case CONNECTED: {
|
||||||
@@ -200,12 +208,15 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: // Not connected.
|
default: // Not connected.
|
||||||
if (mWifiSettings.getAccessPointsCount() == 0 &&
|
if (mWifiSettings.getAccessPointsCount() == 0 && mIgnoringWifiNotificationCount > 0) {
|
||||||
mIgnoringWifiNotificationCount > 0) {
|
|
||||||
mIgnoringWifiNotificationCount--;
|
mIgnoringWifiNotificationCount--;
|
||||||
mProgressBar.setIndeterminate(true);
|
mProgressBar.setIndeterminate(true);
|
||||||
mProgressText.setText(Summary.get(this, DetailedState.SCANNING));
|
mProgressText.setText(Summary.get(this, DetailedState.SCANNING));
|
||||||
|
} else if (mShowingConnectingMessageManually && mIgnoringWifiNotificationCount > 0) {
|
||||||
|
mIgnoringWifiNotificationCount--;
|
||||||
|
showConnectingStatus();
|
||||||
} else {
|
} else {
|
||||||
|
mShowingConnectingMessageManually = false;
|
||||||
mProgressBar.setIndeterminate(false);
|
mProgressBar.setIndeterminate(false);
|
||||||
mProgressBar.setProgress(0);
|
mProgressBar.setProgress(0);
|
||||||
mStatusText.setText(R.string.wifi_setup_status_select_network);
|
mStatusText.setText(R.string.wifi_setup_status_select_network);
|
||||||
@@ -217,6 +228,13 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showConnectingStatus() {
|
||||||
|
mProgressBar.setIndeterminate(false);
|
||||||
|
mProgressBar.setProgress(1);
|
||||||
|
mStatusText.setText(R.string.wifi_setup_status_connecting);
|
||||||
|
mProgressText.setText(Summary.get(this, DetailedState.CONNECTING));
|
||||||
|
}
|
||||||
|
|
||||||
private void enableButtons() {
|
private void enableButtons() {
|
||||||
((Button)findViewById(R.id.wifi_setup_refresh_list)).setEnabled(true);
|
((Button)findViewById(R.id.wifi_setup_refresh_list)).setEnabled(true);
|
||||||
((Button)findViewById(R.id.wifi_setup_add_network)).setEnabled(true);
|
((Button)findViewById(R.id.wifi_setup_add_network)).setEnabled(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user