Merge "Stop leaking wakelocks in cryptkeeper."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 35dd268..20df0d6 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -133,7 +133,6 @@
<activity android:name=".wifi.WifiSettingsForSetupWizardXL"
android:theme="@android:style/Theme.Holo.NoActionBar"
- android:windowBackground="@drawable/setups_bg_default"
android:screenOrientation="behind"
android:clearTaskOnLaunch="true"
android:windowSoftInputMode="adjustResize"
@@ -326,7 +325,6 @@
<activity android:name="DateTimeSettingsSetupWizard"
android:label="@string/date_and_time"
android:theme="@android:style/Theme.Holo.NoActionBar"
- android:windowBackground="@drawable/setups_bg_default"
android:screenOrientation="behind">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -977,7 +975,7 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.nfc.ZeroClick" />
+ android:value="com.android.settings.nfc.ShareTap" />
</activity>
<!-- Accessibility tutorial -->
diff --git a/res/drawable-hdpi/setups_bg_complete.png b/res/drawable-hdpi/setups_bg_complete.png
deleted file mode 100644
index d922859..0000000
--- a/res/drawable-hdpi/setups_bg_complete.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/setups_bg_default.png b/res/drawable-hdpi/setups_bg_default.png
deleted file mode 100644
index 5883b1d..0000000
--- a/res/drawable-hdpi/setups_bg_default.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/setups_bg_wifi.png b/res/drawable-hdpi/setups_bg_wifi.png
deleted file mode 100644
index 6b83d9b..0000000
--- a/res/drawable-hdpi/setups_bg_wifi.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/tap1.png b/res/drawable-hdpi/tap1.png
new file mode 100644
index 0000000..2395c0f
--- /dev/null
+++ b/res/drawable-hdpi/tap1.png
Binary files differ
diff --git a/res/drawable-hdpi/tap2.png b/res/drawable-hdpi/tap2.png
new file mode 100644
index 0000000..afaa243
--- /dev/null
+++ b/res/drawable-hdpi/tap2.png
Binary files differ
diff --git a/res/drawable-hdpi/tap3.png b/res/drawable-hdpi/tap3.png
new file mode 100644
index 0000000..a6b530e
--- /dev/null
+++ b/res/drawable-hdpi/tap3.png
Binary files differ
diff --git a/res/drawable-hdpi/tap4.png b/res/drawable-hdpi/tap4.png
new file mode 100644
index 0000000..b07d8a6
--- /dev/null
+++ b/res/drawable-hdpi/tap4.png
Binary files differ
diff --git a/res/drawable-hdpi/tap5.png b/res/drawable-hdpi/tap5.png
new file mode 100644
index 0000000..f1c8825
--- /dev/null
+++ b/res/drawable-hdpi/tap5.png
Binary files differ
diff --git a/res/drawable-hdpi/tap6.png b/res/drawable-hdpi/tap6.png
new file mode 100644
index 0000000..cc22a0b
--- /dev/null
+++ b/res/drawable-hdpi/tap6.png
Binary files differ
diff --git a/res/drawable-large-mdpi/setups_bg_complete.png b/res/drawable-large-mdpi/setups_bg_complete.png
deleted file mode 100644
index ac9fa28..0000000
--- a/res/drawable-large-mdpi/setups_bg_complete.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-large-mdpi/setups_bg_default.png b/res/drawable-large-mdpi/setups_bg_default.png
deleted file mode 100644
index 989d82b..0000000
--- a/res/drawable-large-mdpi/setups_bg_default.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-large-mdpi/setups_bg_wifi.png b/res/drawable-large-mdpi/setups_bg_wifi.png
deleted file mode 100644
index c4d7612..0000000
--- a/res/drawable-large-mdpi/setups_bg_wifi.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/setups_bg_complete.png b/res/drawable-mdpi/setups_bg_complete.png
deleted file mode 100644
index a0cd961..0000000
--- a/res/drawable-mdpi/setups_bg_complete.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/setups_bg_default.png b/res/drawable-mdpi/setups_bg_default.png
deleted file mode 100644
index f05bf96..0000000
--- a/res/drawable-mdpi/setups_bg_default.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/setups_bg_wifi.png b/res/drawable-mdpi/setups_bg_wifi.png
deleted file mode 100644
index 4fa1619..0000000
--- a/res/drawable-mdpi/setups_bg_wifi.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/setups_bg_complete.png b/res/drawable-xhdpi/setups_bg_complete.png
deleted file mode 100644
index bcf55ad..0000000
--- a/res/drawable-xhdpi/setups_bg_complete.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/setups_bg_default.png b/res/drawable-xhdpi/setups_bg_default.png
deleted file mode 100644
index 12d171f..0000000
--- a/res/drawable-xhdpi/setups_bg_default.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/setups_bg_wifi.png b/res/drawable-xhdpi/setups_bg_wifi.png
deleted file mode 100644
index aa086c7..0000000
--- a/res/drawable-xhdpi/setups_bg_wifi.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xlarge-mdpi/setups_bg_complete.png b/res/drawable-xlarge-mdpi/setups_bg_complete.png
deleted file mode 100644
index 4a854e3..0000000
--- a/res/drawable-xlarge-mdpi/setups_bg_complete.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xlarge-mdpi/setups_bg_default.png b/res/drawable-xlarge-mdpi/setups_bg_default.png
deleted file mode 100644
index ea0db16..0000000
--- a/res/drawable-xlarge-mdpi/setups_bg_default.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xlarge-mdpi/setups_bg_wifi.png b/res/drawable-xlarge-mdpi/setups_bg_wifi.png
deleted file mode 100644
index 9058c30..0000000
--- a/res/drawable-xlarge-mdpi/setups_bg_wifi.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/sharetap_anim.xml b/res/drawable/sharetap_anim.xml
new file mode 100644
index 0000000..6aa7d4f
--- /dev/null
+++ b/res/drawable/sharetap_anim.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2011, 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.
+*/
+-->
+<animation-list
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:oneshot="false">
+ <item android:drawable="@drawable/tap1" android:duration="200" />
+ <item android:drawable="@drawable/tap2" android:duration="200" />
+ <item android:drawable="@drawable/tap3" android:duration="200" />
+ <item android:drawable="@drawable/tap4" android:duration="200" />
+ <item android:drawable="@drawable/tap5" android:duration="200" />
+ <item android:drawable="@drawable/tap6" android:duration="600" />
+</animation-list>
diff --git a/res/layout/bluetooth_pb_access.xml b/res/layout/bluetooth_pb_access.xml
index 80f78a6..24f0df2 100644
--- a/res/layout/bluetooth_pb_access.xml
+++ b/res/layout/bluetooth_pb_access.xml
@@ -36,12 +36,12 @@
android:gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium" />
- <CheckBox android:id="@+id/bluetooth_pb_alwaysallowed"
+ <CheckBox android:id="@+id/bluetooth_pb_remember_choice"
style="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dip"
- android:text="@string/bluetooth_pb_alwaysallowed" />
+ android:text="@string/bluetooth_pb_remember_choice" />
</LinearLayout>
diff --git a/res/layout/custom_preference_list_fragment.xml b/res/layout/custom_preference_list_fragment.xml
deleted file mode 100644
index 4803639..0000000
--- a/res/layout/custom_preference_list_fragment.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?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.
--->
-
-<!-- Based on preference_list_fragment.xml in framework -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:background="@android:color/transparent">
-
- <ListView android:id="@android:id/list"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingTop="0dip"
- android:paddingBottom="@*android:dimen/preference_fragment_padding_bottom"
- android:paddingLeft="@*android:dimen/preference_fragment_padding_side"
- android:paddingRight="@*android:dimen/preference_fragment_padding_side"
- android:clipToPadding="false"
- android:drawSelectorOnTop="false"
- android:cacheColorHint="@android:color/transparent"
- android:scrollbarAlwaysDrawVerticalTrack="true" />
-
- <TextView android:id="@+id/empty"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:padding="5dip"
- android:gravity="center"
- android:visibility="gone" />
-</LinearLayout>
diff --git a/res/layout/zeroclick.xml b/res/layout/sharetap.xml
similarity index 74%
rename from res/layout/zeroclick.xml
rename to res/layout/sharetap.xml
index d039e89..bd65df2 100644
--- a/res/layout/zeroclick.xml
+++ b/res/layout/sharetap.xml
@@ -30,15 +30,24 @@
android:layout_height="wrap_content"
android:orientation="vertical">
- <TextView android:id="@+id/zeroclick_explained"
+ <TextView android:id="@+id/sharetap_explained"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dip"
android:gravity="top"
android:text="@string/zeroclick_explained"
/>
-
-
+ <ImageView android:id="@+id/sharetap_image"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ />
+ <TextView android:id="@+id/sharetap_safety"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="20dip"
+ android:gravity="top"
+ android:text="@string/zeroclick_top"
+ />
</LinearLayout>
</ScrollView>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index b777fd7..7e73bca 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -323,7 +323,7 @@
<string name="bluetooth_pb_acceptance_dialog_text">%1$s would like to access your contacts and call history. Give access to %2$s?</string>
<!-- Bluetooth phone book permission Alert Activity checkbox text [CHAR LIMIT=none] -->
- <string name="bluetooth_pb_alwaysallowed">Always allowed?</string>
+ <string name="bluetooth_pb_remember_choice">Don\'t ask again</string>
<!-- Date & time settings screen title -->
<string name="date_and_time">Date & time settings</string>
@@ -1098,15 +1098,15 @@
<!-- NFC settings -->
<!-- Used in the 1st-level settings screen to turn on NFC -->
<string name="nfc_quick_toggle_title">NFC</string>
- <!-- Used to enter the Zero-click sharing preferences screen -->
- <string name="zeroclick_settings_title">Tap to share</string>
+ <!-- Used to enter the ShareTap sharing preferences screen -->
+ <string name="zeroclick_settings_title">ShareTap</string>
<string name="zeroclick_settings_summary"></string>
<string name="zeroclick_on_summary">On</string>
<string name="zeroclick_off_summary">Off</string>
<!-- Used in the zero-click sharing preferences screen -->
- <string name="zeroclick_label">Zero-click sharing</string>
- <string name="zeroclick_explained">Tap to share allows you to share content from applications, just by tapping your NFC-enabled device to another.</string>
-
+ <string name="zeroclick_label">ShareTap</string>
+ <string name="zeroclick_explained">Share content by touching two NFC-enabled devices back to back.</string>
+ <string name="zeroclick_top">The app on the top device\'s screen sends content to the bottom device.\n\nYour data is safe: nothing is shared unless both devices are on and unlocked.\n\nYou can turn this feature off in Settings > More > ShareTap.</string>
<!-- Wi-Fi Settings --> <skip />
<!-- Used in the 1st-level settings screen to turn on Wi-Fi -->
<string name="wifi_quick_toggle_title">Wi-Fi</string>
@@ -3454,6 +3454,8 @@
<string name="data_usage_disable_4g_limit">Disable 4G data at limit</string>
<!-- Checkbox label that will disable 2G-3G network data connection when user-defined limit is reached. [CHAR LIMIT=32] -->
<string name="data_usage_disable_3g_limit">Disable 2G-3G data at limit</string>
+ <!-- Checkbox label that will disable Wi-Fi network data connection when user-defined limit is reached. [CHAR LIMIT=32] -->
+ <string name="data_usage_disable_wifi_limit">Disable Wi-Fi data at limit</string>
<!-- Tab title for showing Wi-Fi data usage. [CHAR LIMIT=10] -->
<string name="data_usage_tab_wifi">Wi-Fi</string>
@@ -3466,6 +3468,11 @@
<!-- Tab title for showing 2G and 3G data usage. [CHAR LIMIT=10] -->
<string name="data_usage_tab_3g">2G-3G</string>
+ <!-- Title shown when current operation applies to mobile networks. [CHAR LIMIT=10] -->
+ <string name="data_usage_list_mobile">mobile</string>
+ <!-- Title shown when current operation applies to no networks. [CHAR LIMIT=10] -->
+ <string name="data_usage_list_none">none</string>
+
<!-- Toggle switch title for enabling all mobile data network connections. [CHAR LIMIT=32] -->
<string name="data_usage_enable_mobile">Mobile data</string>
<!-- Toggle switch title for enabling 2G and 3G data network connections. [CHAR LIMIT=32] -->
@@ -3478,9 +3485,9 @@
<!-- Checkbox label that restricts background data usage of a specific application. [CHAR LIMIT=32] -->
<string name="data_usage_app_restrict_background">Restrict background data usage</string>
<!-- Summary message for checkbox that restricts background data usage of a specific application. [CHAR LIMIT=64] -->
- <string name="data_usage_app_restrict_background_summary">Only allow application background data when using an unlimited network</string>
+ <string name="data_usage_app_restrict_background_summary">Disable background data on networks that you\'ve chosen to limit (<xliff:g id="networks" example="Mobile, Wi-Fi">%1$s</xliff:g>).</string>
<!-- Title of dialog shown when user restricts background data usage of a specific application. [CHAR LIMIT=48] -->
- <string name="data_usage_app_restrict_dialog_title">Restricting background data</string>
+ <string name="data_usage_app_restrict_dialog_title">Restrict background data?</string>
<!-- Body of dialog shown when user restricts background data usage of a specific application. [CHAR LIMIT=NONE] -->
<string name="data_usage_app_restrict_dialog">This feature may negatively impact applications which depend on background data usage.\n\nMore appropriate data usage controls may be found within this application\'s settings.</string>
@@ -3494,16 +3501,12 @@
<!-- Title of dialog shown before user limits data usage. [CHAR LIMIT=48] -->
<string name="data_usage_limit_dialog_title">Limiting data usage</string>
<!-- Body of dialog shown before user limits mobile data usage. [CHAR LIMIT=NONE] -->
- <string name="data_usage_limit_dialog_mobile">Your mobile data connection will be disabled when the specified limit is reached.\n\nTo avoid overage charges, consider using a reduced limit, as device and carrier accounting methods may vary.</string>
- <!-- Body of dialog shown before user limits 3G data usage. [CHAR LIMIT=NONE] -->
- <string name="data_usage_limit_dialog_3g">Your 2G-3G data connection will be disabled when the specified limit is reached.\n\nTo avoid overage charges, consider using a reduced limit, as device and carrier accounting methods may vary.</string>
- <!-- Body of dialog shown before user limits 4G data usage. [CHAR LIMIT=NONE] -->
- <string name="data_usage_limit_dialog_4g">Your 4G data connection will be disabled when the specified limit is reached.\n\nTo avoid overage charges, consider using a reduced limit, as device and carrier accounting methods may vary.</string>
+ <string name="data_usage_limit_dialog">Your <xliff:g id="networks" example="mobile">%1$s</xliff:g> data connection will be disabled when the specified limit is reached.\n\nTo avoid overage charges, consider using a reduced limit, as device and carrier accounting methods may vary.</string>
<!-- Title of dialog shown before user restricts background data usage. [CHAR LIMIT=48] -->
- <string name="data_usage_restrict_background_title">Restricting background data</string>
+ <string name="data_usage_restrict_background_title">Restrict background data?</string>
<!-- Body of dialog shown before user restricts background data usage. [CHAR LIMIT=NONE] -->
- <string name="data_usage_restrict_background">This feature will disable auto-sync and may negatively impact applications which depend on background data usage.</string>
+ <string name="data_usage_restrict_background">If you restrict background data, some apps and services won\'t work on networks that you\'ve chosen to limit.\n\nCurrently limited networks: <xliff:g id="networks" example="Mobile, Wi-Fi">%1$s</xliff:g></string>
<!-- Label displaying current network data usage warning threshold. [CHAR LIMIT=18] -->
<string name="data_usage_sweep_warning"><font size="21"><xliff:g id="number" example="128">^1</xliff:g></font> <font size="9"><xliff:g id="unit" example="KB">^2</xliff:g></font>\n<font size="12">warning</font></string>
diff --git a/res/xml/wireless_settings.xml b/res/xml/wireless_settings.xml
index 1e85b9a..d908fd7 100644
--- a/res/xml/wireless_settings.xml
+++ b/res/xml/wireless_settings.xml
@@ -39,7 +39,7 @@
android:persistent="false" />
<PreferenceScreen
- android:fragment="com.android.settings.nfc.ZeroClick"
+ android:fragment="com.android.settings.nfc.ShareTap"
android:key="zeroclick_settings"
android:title="@string/zeroclick_settings_title"
android:summary="@string/zeroclick_settings_summary" >
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java
index a95ab3f..b99264f 100644
--- a/src/com/android/settings/DataUsageSummary.java
+++ b/src/com/android/settings/DataUsageSummary.java
@@ -322,9 +322,6 @@
mAppRestrict = new CheckBox(inflater.getContext());
mAppRestrict.setClickable(false);
mAppRestrictView = inflatePreference(inflater, mAppSwitches, mAppRestrict);
- setPreferenceTitle(mAppRestrictView, R.string.data_usage_app_restrict_background);
- setPreferenceSummary(
- mAppRestrictView, R.string.data_usage_app_restrict_background_summary);
mAppRestrictView.setOnClickListener(mAppRestrictListener);
mAppSwitches.addView(mAppRestrictView);
}
@@ -588,22 +585,8 @@
if (LOGD) Log.d(TAG, "updateBody() with currentTab=" + currentTab);
- if (TAB_WIFI.equals(currentTab)) {
- // wifi doesn't have any controls
- mDataEnabledView.setVisibility(View.GONE);
- mDisableAtLimitView.setVisibility(View.GONE);
- mTemplate = buildTemplateWifi();
-
- } else if (TAB_ETHERNET.equals(currentTab)) {
- // ethernet doesn't have any controls
- mDataEnabledView.setVisibility(View.GONE);
- mDisableAtLimitView.setVisibility(View.GONE);
- mTemplate = buildTemplateEthernet();
-
- } else {
- mDataEnabledView.setVisibility(View.VISIBLE);
- mDisableAtLimitView.setVisibility(View.VISIBLE);
- }
+ mDataEnabledView.setVisibility(View.VISIBLE);
+ mDisableAtLimitView.setVisibility(View.VISIBLE);
if (TAB_MOBILE.equals(currentTab)) {
setPreferenceTitle(mDataEnabledView, R.string.data_usage_enable_mobile);
@@ -622,6 +605,20 @@
setPreferenceTitle(mDisableAtLimitView, R.string.data_usage_disable_4g_limit);
// TODO: bind mDataEnabled to 4G radio state
mTemplate = buildTemplateMobile4g(getActiveSubscriberId(context));
+
+ } else if (TAB_WIFI.equals(currentTab)) {
+ mDataEnabledView.setVisibility(View.GONE);
+ setPreferenceTitle(mDisableAtLimitView, R.string.data_usage_disable_wifi_limit);
+ mTemplate = buildTemplateWifi();
+
+ } else if (TAB_ETHERNET.equals(currentTab)) {
+ // ethernet doesn't have any controls
+ mDataEnabledView.setVisibility(View.GONE);
+ mDisableAtLimitView.setVisibility(View.GONE);
+ mTemplate = buildTemplateEthernet();
+
+ } else {
+ throw new IllegalStateException("unknown tab: " + currentTab);
}
try {
@@ -731,6 +728,11 @@
if (NetworkPolicyManager.isUidValidForPolicy(context, mUid) && !getRestrictBackground()
&& isBandwidthControlEnabled()) {
+ setPreferenceTitle(mAppRestrictView, R.string.data_usage_app_restrict_background);
+ setPreferenceSummary(mAppRestrictView,
+ getString(R.string.data_usage_app_restrict_background_summary,
+ buildLimitedNetworksList()));
+
mAppRestrictView.setVisibility(View.VISIBLE);
mAppRestrict.setChecked(getAppRestrictBackground());
@@ -845,7 +847,7 @@
}
}
- final NetworkPolicy policy = mPolicyEditor.getPolicy(mTemplate);
+ final NetworkPolicy policy = mPolicyEditor.getPolicy(mTemplate, true);
if (isNetworkPolicyModifiable()) {
mDisableAtLimitView.setVisibility(View.VISIBLE);
mDisableAtLimit.setChecked(policy != null && policy.limitBytes != LIMIT_DISABLED);
@@ -1363,41 +1365,57 @@
* {@link NetworkPolicy#limitBytes}.
*/
public static class ConfirmLimitFragment extends DialogFragment {
- private static final String EXTRA_MESSAGE_ID = "messageId";
+ private static final String EXTRA_MESSAGE = "message";
private static final String EXTRA_LIMIT_BYTES = "limitBytes";
public static void show(DataUsageSummary parent) {
- final Bundle args = new Bundle();
+ final Resources res = parent.getResources();
+
+ final CharSequence message;
+ final long limitBytes;
// TODO: customize default limits based on network template
final String currentTab = parent.mCurrentTab;
if (TAB_3G.equals(currentTab)) {
- args.putInt(EXTRA_MESSAGE_ID, R.string.data_usage_limit_dialog_3g);
- args.putLong(EXTRA_LIMIT_BYTES, 5 * GB_IN_BYTES);
+ message = buildDialogMessage(res, R.string.data_usage_tab_3g);
+ limitBytes = 5 * GB_IN_BYTES;
} else if (TAB_4G.equals(currentTab)) {
- args.putInt(EXTRA_MESSAGE_ID, R.string.data_usage_limit_dialog_4g);
- args.putLong(EXTRA_LIMIT_BYTES, 5 * GB_IN_BYTES);
+ message = buildDialogMessage(res, R.string.data_usage_tab_4g);
+ limitBytes = 5 * GB_IN_BYTES;
} else if (TAB_MOBILE.equals(currentTab)) {
- args.putInt(EXTRA_MESSAGE_ID, R.string.data_usage_limit_dialog_mobile);
- args.putLong(EXTRA_LIMIT_BYTES, 5 * GB_IN_BYTES);
+ message = buildDialogMessage(res, R.string.data_usage_list_mobile);
+ limitBytes = 5 * GB_IN_BYTES;
+ } else if (TAB_WIFI.equals(currentTab)) {
+ message = buildDialogMessage(res, R.string.data_usage_tab_wifi);
+ limitBytes = 5 * GB_IN_BYTES;
+ } else {
+ throw new IllegalArgumentException("unknown current tab: " + currentTab);
}
+ final Bundle args = new Bundle();
+ args.putCharSequence(EXTRA_MESSAGE, message);
+ args.putLong(EXTRA_LIMIT_BYTES, limitBytes);
+
final ConfirmLimitFragment dialog = new ConfirmLimitFragment();
dialog.setArguments(args);
dialog.setTargetFragment(parent, 0);
dialog.show(parent.getFragmentManager(), TAG_CONFIRM_LIMIT);
}
+ private static CharSequence buildDialogMessage(Resources res, int networkResId) {
+ return res.getString(R.string.data_usage_limit_dialog, res.getString(networkResId));
+ }
+
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = getActivity();
- final int messageId = getArguments().getInt(EXTRA_MESSAGE_ID);
+ final CharSequence message = getArguments().getCharSequence(EXTRA_MESSAGE);
final long limitBytes = getArguments().getLong(EXTRA_LIMIT_BYTES);
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.data_usage_limit_dialog_title);
- builder.setMessage(messageId);
+ builder.setMessage(message);
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
@@ -1419,7 +1437,7 @@
private static final String EXTRA_CYCLE_DAY = "cycleDay";
public static void show(DataUsageSummary parent) {
- final NetworkPolicy policy = parent.mPolicyEditor.getPolicy(parent.mTemplate);
+ final NetworkPolicy policy = parent.mPolicyEditor.getPolicy(parent.mTemplate, false);
final Bundle args = new Bundle();
args.putInt(CycleEditorFragment.EXTRA_CYCLE_DAY, policy.cycleDay);
@@ -1470,8 +1488,6 @@
*/
public static class ConfirmDataRoamingFragment extends DialogFragment {
public static void show(DataUsageSummary parent) {
- final Bundle args = new Bundle();
-
final ConfirmDataRoamingFragment dialog = new ConfirmDataRoamingFragment();
dialog.setTargetFragment(parent, 0);
dialog.show(parent.getFragmentManager(), TAG_CONFIRM_ROAMING);
@@ -1505,8 +1521,6 @@
*/
public static class ConfirmRestrictFragment extends DialogFragment {
public static void show(DataUsageSummary parent) {
- final Bundle args = new Bundle();
-
final ConfirmRestrictFragment dialog = new ConfirmRestrictFragment();
dialog.setTargetFragment(parent, 0);
dialog.show(parent.getFragmentManager(), TAG_CONFIRM_RESTRICT);
@@ -1518,7 +1532,13 @@
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.data_usage_restrict_background_title);
- builder.setMessage(R.string.data_usage_restrict_background);
+
+ final DataUsageSummary target = (DataUsageSummary) getTargetFragment();
+ if (target != null) {
+ final CharSequence limitedNetworks = target.buildLimitedNetworksList();
+ builder.setMessage(
+ getString(R.string.data_usage_restrict_background, limitedNetworks));
+ }
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
@@ -1732,6 +1752,40 @@
}
/**
+ * Build string describing currently limited networks, which defines when
+ * background data is restricted.
+ */
+ private CharSequence buildLimitedNetworksList() {
+ final Context context = getActivity();
+ final String subscriberId = getActiveSubscriberId(context);
+
+ // build combined list of all limited networks
+ final ArrayList<CharSequence> limited = Lists.newArrayList();
+ if (mPolicyEditor.hasLimitedPolicy(buildTemplateMobileAll(subscriberId))) {
+ limited.add(getText(R.string.data_usage_list_mobile));
+ }
+ if (mPolicyEditor.hasLimitedPolicy(buildTemplateMobile3gLower(subscriberId))) {
+ limited.add(getText(R.string.data_usage_tab_3g));
+ }
+ if (mPolicyEditor.hasLimitedPolicy(buildTemplateMobile4g(subscriberId))) {
+ limited.add(getText(R.string.data_usage_tab_4g));
+ }
+ if (mPolicyEditor.hasLimitedPolicy(buildTemplateWifi())) {
+ limited.add(getText(R.string.data_usage_tab_wifi));
+ }
+ if (mPolicyEditor.hasLimitedPolicy(buildTemplateEthernet())) {
+ limited.add(getText(R.string.data_usage_tab_ethernet));
+ }
+
+ // handle case where no networks limited
+ if (limited.isEmpty()) {
+ limited.add(getText(R.string.data_usage_list_none));
+ }
+
+ return TextUtils.join(limited);
+ }
+
+ /**
* Set {@link android.R.id#title} for a preference view inflated with
* {@link #inflatePreference(LayoutInflater, ViewGroup, View)}.
*/
@@ -1744,9 +1798,9 @@
* Set {@link android.R.id#summary} for a preference view inflated with
* {@link #inflatePreference(LayoutInflater, ViewGroup, View)}.
*/
- private static void setPreferenceSummary(View parent, int resId) {
+ private static void setPreferenceSummary(View parent, CharSequence string) {
final TextView summary = (TextView) parent.findViewById(android.R.id.summary);
summary.setVisibility(View.VISIBLE);
- summary.setText(resId);
+ summary.setText(string);
}
}
diff --git a/src/com/android/settings/UserDictionarySettings.java b/src/com/android/settings/UserDictionarySettings.java
index fa4359c..be8f453 100644
--- a/src/com/android/settings/UserDictionarySettings.java
+++ b/src/com/android/settings/UserDictionarySettings.java
@@ -81,7 +81,6 @@
/** The word being edited in the dialog (null means the user is adding a word). */
private String mDialogEditingWord;
- private View mView;
private Cursor mCursor;
protected String mLocale;
@@ -97,13 +96,6 @@
}
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- mView = inflater.inflate(R.layout.custom_preference_list_fragment, container, false);
- return mView;
- }
-
- @Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
@@ -126,7 +118,7 @@
mLocale = locale;
mCursor = createCursor(locale);
- TextView emptyView = (TextView)mView.findViewById(R.id.empty);
+ TextView emptyView = (TextView) getView().findViewById(android.R.id.empty);
emptyView.setText(R.string.user_dict_settings_empty_text);
final ListView listView = getListView();
diff --git a/src/com/android/settings/WirelessSettings.java b/src/com/android/settings/WirelessSettings.java
index 636799d..55b395a 100644
--- a/src/com/android/settings/WirelessSettings.java
+++ b/src/com/android/settings/WirelessSettings.java
@@ -48,6 +48,8 @@
private static final String KEY_PROXY_SETTINGS = "proxy_settings";
private static final String KEY_MOBILE_NETWORK_SETTINGS = "mobile_network_settings";
+ private static final Boolean WIFI_P2P_DEBUG = false;
+
public static final String EXIT_ECM_RESULT = "exit_ecm_result";
public static final int REQUEST_CODE_EXIT_ECM = 1;
@@ -131,8 +133,7 @@
getPreferenceScreen().removePreference(findPreference(KEY_MOBILE_NETWORK_SETTINGS));
}
- WifiP2pManager wifiP2p = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
- if (!wifiP2p.isP2pSupported()) {
+ if (!WIFI_P2P_DEBUG) {
getPreferenceScreen().removePreference(findPreference(KEY_WIFI_P2P_SETTINGS));
}
diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
index 4d96140..4fd6cee 100644
--- a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
+++ b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
@@ -53,13 +53,12 @@
private TextView messageView;
private Button mOkButton;
private BluetoothDevice mDevice;
-
- private CheckBox mAlwaysAllowed;
- private boolean mAlwaysAllowedValue = true;
-
private String mReturnPackage = null;
private String mReturnClass = null;
+ private CheckBox mRememberChoice;
+ private boolean mRememberChoiceValue = false;
+
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -70,6 +69,7 @@
}
}
};
+ private boolean mReceiverRegistered = false;
private void dismissDialog() {
this.dismiss();
@@ -81,26 +81,31 @@
Intent i = getIntent();
String action = i.getAction();
+ if (!action.equals(BluetoothDevice.ACTION_CONNECTION_ACCESS_REQUEST)) {
+ Log.e(TAG, "Error: this activity may be started only with intent "
+ + "ACTION_CONNECTION_ACCESS_REQUEST");
+ finish();
+ return;
+ }
+
mDevice = i.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
mReturnPackage = i.getStringExtra(BluetoothDevice.EXTRA_PACKAGE_NAME);
mReturnClass = i.getStringExtra(BluetoothDevice.EXTRA_CLASS_NAME);
+ int requestType = i.getIntExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE,
+ BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS);
- if (action.equals(BluetoothDevice.ACTION_CONNECTION_ACCESS_REQUEST)) {
- mDevice = i.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
- if (i.getIntExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE,
- BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS) ==
- BluetoothDevice.REQUEST_TYPE_PROFILE_CONNECTION) {
- showConnectionDialog();
- } else {
- showPbapDialog();
- }
+ if (requestType == BluetoothDevice.REQUEST_TYPE_PROFILE_CONNECTION) {
+ showConnectionDialog();
+ } else if (requestType == BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS) {
+ showPhonebookDialog();
} else {
- Log.e(TAG, "Error: this activity may be started only with intent "
- + "ACTION_CONNECTION_ACCESS_REQUEST");
+ Log.e(TAG, "Error: bad request type: " + requestType);
finish();
+ return;
}
registerReceiver(mReceiver,
new IntentFilter(BluetoothDevice.ACTION_CONNECTION_ACCESS_CANCEL));
+ mReceiverRegistered = true;
}
private void showConnectionDialog() {
@@ -116,11 +121,11 @@
setupAlert();
}
- private void showPbapDialog() {
+ private void showPhonebookDialog() {
final AlertController.AlertParams p = mAlertParams;
p.mIconId = android.R.drawable.ic_dialog_info;
p.mTitle = getString(R.string.bluetooth_phonebook_request);
- p.mView = createPbapDialogView();
+ p.mView = createPhonebookDialogView();
p.mPositiveButtonText = getString(android.R.string.yes);
p.mPositiveButtonListener = this;
p.mNegativeButtonText = getString(android.R.string.no);
@@ -138,7 +143,7 @@
return mMessage1;
}
- private String createPbapDisplayText() {
+ private String createPhonebookDisplayText() {
String mRemoteName = mDevice != null ? mDevice.getAliasName() : null;
if (mRemoteName == null) mRemoteName = getString(R.string.unknown);
@@ -154,18 +159,18 @@
return mView;
}
- private View createPbapDialogView() {
+ private View createPhonebookDialogView() {
mView = getLayoutInflater().inflate(R.layout.bluetooth_pb_access, null);
messageView = (TextView)mView.findViewById(R.id.message);
- messageView.setText(createPbapDisplayText());
- mAlwaysAllowed = (CheckBox)mView.findViewById(R.id.bluetooth_pb_alwaysallowed);
- mAlwaysAllowed.setChecked(true);
- mAlwaysAllowed.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+ messageView.setText(createPhonebookDisplayText());
+ mRememberChoice = (CheckBox)mView.findViewById(R.id.bluetooth_pb_remember_choice);
+ mRememberChoice.setChecked(false);
+ mRememberChoice.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
- mAlwaysAllowedValue = true;
+ mRememberChoiceValue = true;
} else {
- mAlwaysAllowedValue = false;
+ mRememberChoiceValue = false;
}
}
});
@@ -173,14 +178,22 @@
}
private void onPositive() {
- if (DEBUG) Log.d(TAG, "onPositive mAlwaysAllowedValue: " + mAlwaysAllowedValue);
+ if (DEBUG) Log.d(TAG, "onPositive mRememberChoiceValue: " + mRememberChoiceValue);
+
+ if (mRememberChoiceValue) {
+ savePhonebookPermissionChoice(CachedBluetoothDevice.PHONEBOOK_ACCESS_ALLOWED);
+ }
sendIntentToReceiver(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY, true,
- BluetoothDevice.EXTRA_ALWAYS_ALLOWED, mAlwaysAllowedValue);
+ BluetoothDevice.EXTRA_ALWAYS_ALLOWED, mRememberChoiceValue);
finish();
}
private void onNegative() {
- if (DEBUG) Log.d(TAG, "onNegative mAlwaysAllowedValue: " + mAlwaysAllowedValue);
+ if (DEBUG) Log.d(TAG, "onNegative mRememberChoiceValue: " + mRememberChoiceValue);
+
+ if (mRememberChoiceValue) {
+ savePhonebookPermissionChoice(CachedBluetoothDevice.PHONEBOOK_ACCESS_REJECTED);
+ }
sendIntentToReceiver(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY, false,
null, false // dummy value, no effect since last param is null
);
@@ -223,10 +236,21 @@
@Override
protected void onDestroy() {
super.onDestroy();
- unregisterReceiver(mReceiver);
+ if (mReceiverRegistered) {
+ unregisterReceiver(mReceiver);
+ mReceiverRegistered = false;
+ }
}
public boolean onPreferenceChange(Preference preference, Object newValue) {
return true;
}
+
+ private void savePhonebookPermissionChoice(int permissionChoice) {
+ LocalBluetoothManager bluetoothManager = LocalBluetoothManager.getInstance(this);
+ CachedBluetoothDeviceManager cachedDeviceManager =
+ bluetoothManager.getCachedDeviceManager();
+ CachedBluetoothDevice cachedDevice = cachedDeviceManager.findDevice(mDevice);
+ cachedDevice.setPhonebookPermissionChoice(permissionChoice);
+ }
}
diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
index 51055af..e2231bb 100644
--- a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
+++ b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
@@ -38,30 +38,44 @@
private static final boolean DEBUG = Utils.V;
public static final int NOTIFICATION_ID = android.R.drawable.stat_sys_data_bluetooth;
+ Context mContext;
+ int mRequestType;
+ BluetoothDevice mDevice;
+ String mReturnPackage = null;
+ String mReturnClass = null;
+
@Override
public void onReceive(Context context, Intent intent) {
+ mContext = context;
String action = intent.getAction();
if (DEBUG) Log.d(TAG, "onReceive");
if (action.equals(BluetoothDevice.ACTION_CONNECTION_ACCESS_REQUEST)) {
// convert broadcast intent into activity intent (same action string)
- BluetoothDevice device =
- intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
- int requestType = intent.getIntExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE,
+ mDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+ mRequestType = intent.getIntExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE,
BluetoothDevice.REQUEST_TYPE_PROFILE_CONNECTION);
- String returnPackage = intent.getStringExtra(BluetoothDevice.EXTRA_PACKAGE_NAME);
- String returnClass = intent.getStringExtra(BluetoothDevice.EXTRA_CLASS_NAME);
+ mReturnPackage = intent.getStringExtra(BluetoothDevice.EXTRA_PACKAGE_NAME);
+ mReturnClass = intent.getStringExtra(BluetoothDevice.EXTRA_CLASS_NAME);
Intent connectionAccessIntent = new Intent(action);
connectionAccessIntent.setClass(context, BluetoothPermissionActivity.class);
connectionAccessIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- connectionAccessIntent.putExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE, requestType);
- connectionAccessIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
- connectionAccessIntent.putExtra(BluetoothDevice.EXTRA_PACKAGE_NAME, returnPackage);
- connectionAccessIntent.putExtra(BluetoothDevice.EXTRA_CLASS_NAME, returnClass);
+ connectionAccessIntent.putExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE,
+ mRequestType);
+ connectionAccessIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
+ connectionAccessIntent.putExtra(BluetoothDevice.EXTRA_PACKAGE_NAME, mReturnPackage);
+ connectionAccessIntent.putExtra(BluetoothDevice.EXTRA_CLASS_NAME, mReturnClass);
- String deviceAddress = device != null ? device.getAddress() : null;
+ // Check if user had made decisions on accepting or rejecting the phonebook access
+ // request. If there is, reply the request and return, no need to start permission
+ // activity dialog or notification.
+ if (checkUserChoice()) {
+ return;
+ }
+
+ String deviceAddress = mDevice != null ? mDevice.getAddress() : null;
PowerManager powerManager =
(PowerManager) context.getSystemService(Context.POWER_SERVICE);
@@ -76,14 +90,15 @@
// "Clear All Notifications" button
Intent deleteIntent = new Intent(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY);
- deleteIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
+ deleteIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
deleteIntent.putExtra(BluetoothDevice.EXTRA_CONNECTION_ACCESS_RESULT,
BluetoothDevice.CONNECTION_ACCESS_NO);
- Notification notification = new Notification(android.R.drawable.stat_sys_data_bluetooth,
+ Notification notification = new Notification(
+ android.R.drawable.stat_sys_data_bluetooth,
context.getString(R.string.bluetooth_connection_permission_request),
System.currentTimeMillis());
- String deviceName = device != null ? device.getAliasName() : null;
+ String deviceName = mDevice != null ? mDevice.getAliasName() : null;
notification.setLatestEventInfo(context,
context.getString(R.string.bluetooth_connection_permission_request),
context.getString(R.string.bluetooth_connection_notif_message, deviceName),
@@ -103,5 +118,68 @@
.getSystemService(Context.NOTIFICATION_SERVICE);
manager.cancel(NOTIFICATION_ID);
}
- }
+ }
+
+ /**
+ * @return true user had made a choice, this method replies to the request according
+ * to user's previous decision
+ * false user hadnot made any choice on this device
+ */
+ private boolean checkUserChoice() {
+ boolean processed = false;
+
+ // we only remember PHONEBOOK permission
+ if (mRequestType != BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS) {
+ return processed;
+ }
+
+ LocalBluetoothManager bluetoothManager = LocalBluetoothManager.getInstance(mContext);
+ CachedBluetoothDeviceManager cachedDeviceManager =
+ bluetoothManager.getCachedDeviceManager();
+ CachedBluetoothDevice cachedDevice = cachedDeviceManager.findDevice(mDevice);
+
+ if (cachedDevice == null) {
+ cachedDevice = cachedDeviceManager.addDevice(bluetoothManager.getBluetoothAdapter(),
+ bluetoothManager.getProfileManager(), mDevice);
+ }
+
+ int phonebookPermission = cachedDevice.getPhonebookPermissionChoice();
+
+ if (phonebookPermission == CachedBluetoothDevice.PHONEBOOK_ACCESS_UNKNOWN) {
+ return processed;
+ }
+
+ String intentName = BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY;
+ if (phonebookPermission == CachedBluetoothDevice.PHONEBOOK_ACCESS_ALLOWED) {
+ sendIntentToReceiver(intentName, true, BluetoothDevice.EXTRA_ALWAYS_ALLOWED, true);
+ processed = true;
+ } else if (phonebookPermission == CachedBluetoothDevice.PHONEBOOK_ACCESS_REJECTED) {
+ sendIntentToReceiver(intentName, false,
+ null, false // dummy value, no effect since previous param is null
+ );
+ processed = true;
+ } else {
+ Log.e(TAG, "Bad phonebookPermission: " + phonebookPermission);
+ }
+ return processed;
+ }
+
+ private void sendIntentToReceiver(final String intentName, final boolean allowed,
+ final String extraName, final boolean extraValue) {
+ Intent intent = new Intent(intentName);
+
+ if (mReturnPackage != null && mReturnClass != null) {
+ intent.setClassName(mReturnPackage, mReturnClass);
+ }
+
+ intent.putExtra(BluetoothDevice.EXTRA_CONNECTION_ACCESS_RESULT,
+ allowed ? BluetoothDevice.CONNECTION_ACCESS_YES :
+ BluetoothDevice.CONNECTION_ACCESS_NO);
+
+ if (extraName != null) {
+ intent.putExtra(extraName, extraValue);
+ }
+ intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
+ mContext.sendBroadcast(intent, android.Manifest.permission.BLUETOOTH_ADMIN);
+ }
}
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 91bcffd..4b86a74 100644
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -69,7 +69,6 @@
private PreferenceGroup mAvailableDevicesCategory;
private boolean mAvailableDevicesCategoryIsPresent;
- private View mView;
private TextView mEmptyView;
private final IntentFilter mIntentFilter;
@@ -98,17 +97,10 @@
}
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- mView = inflater.inflate(R.layout.custom_preference_list_fragment, container, false);
- return mView;
- }
-
- @Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
- mEmptyView = (TextView) mView.findViewById(R.id.empty);
+ mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
getListView().setEmptyView(mEmptyView);
}
diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
index 8082314..01fd1b2 100644
--- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
+++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
@@ -19,6 +19,8 @@
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
+import android.content.Context;
+import android.content.SharedPreferences;
import android.os.ParcelUuid;
import android.os.SystemClock;
import android.text.TextUtils;
@@ -40,6 +42,7 @@
private static final String TAG = "CachedBluetoothDevice";
private static final boolean DEBUG = Utils.V;
+ private final Context mContext;
private final LocalBluetoothAdapter mLocalAdapter;
private final LocalBluetoothProfileManager mProfileManager;
private final BluetoothDevice mDevice;
@@ -60,8 +63,20 @@
private boolean mVisible;
+ private int mPhonebookPermissionChoice;
+
private final Collection<Callback> mCallbacks = new ArrayList<Callback>();
+ // Following constants indicate the user's choices of Phone book access settings
+ // User hasn't made any choice or settings app has wiped out the memory
+ final static int PHONEBOOK_ACCESS_UNKNOWN = 0;
+ // User has accepted the connection and let Settings app remember the decision
+ final static int PHONEBOOK_ACCESS_ALLOWED = 1;
+ // User has rejected the connection and let Settings app remember the decision
+ final static int PHONEBOOK_ACCESS_REJECTED = 2;
+
+ private final static String PHONEBOOK_PREFS_NAME = "bluetooth_phonebook_permission";
+
/**
* When we connect to multiple profiles, we only want to display a single
* error even if they all fail. This tracks that state.
@@ -125,9 +140,11 @@
}
}
- CachedBluetoothDevice(LocalBluetoothAdapter adapter,
- LocalBluetoothProfileManager profileManager,
- BluetoothDevice device) {
+ CachedBluetoothDevice(Context context,
+ LocalBluetoothAdapter adapter,
+ LocalBluetoothProfileManager profileManager,
+ BluetoothDevice device) {
+ mContext = context;
mLocalAdapter = adapter;
mProfileManager = profileManager;
mDevice = device;
@@ -305,9 +322,9 @@
fetchName();
fetchBtClass();
updateProfiles();
+ fetchPhonebookPermissionChoice();
mVisible = false;
-
dispatchAttributesChanged();
}
@@ -470,6 +487,7 @@
if (bondState == BluetoothDevice.BOND_NONE) {
mProfiles.clear();
mConnectAfterPairing = false; // cancel auto-connect
+ setPhonebookPermissionChoice(PHONEBOOK_ACCESS_UNKNOWN);
}
refresh();
@@ -580,4 +598,28 @@
public interface Callback {
void onDeviceAttributesChanged();
}
+
+ int getPhonebookPermissionChoice() {
+ return mPhonebookPermissionChoice;
+ }
+
+ void setPhonebookPermissionChoice(int permissionChoice) {
+ SharedPreferences.Editor editor =
+ mContext.getSharedPreferences(PHONEBOOK_PREFS_NAME, Context.MODE_PRIVATE).edit();
+ if (permissionChoice == PHONEBOOK_ACCESS_UNKNOWN) {
+ editor.remove(mDevice.getAddress());
+ } else {
+ editor.putInt(mDevice.getAddress(), permissionChoice);
+ }
+ editor.commit();
+ mPhonebookPermissionChoice = permissionChoice;
+ }
+
+ private void fetchPhonebookPermissionChoice() {
+ SharedPreferences preference = mContext.getSharedPreferences(PHONEBOOK_PREFS_NAME,
+ Context.MODE_PRIVATE);
+ mPhonebookPermissionChoice = preference.getInt(mDevice.getAddress(),
+ PHONEBOOK_ACCESS_UNKNOWN);
+ }
+
}
diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java b/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java
index b511cb3..77f6b2c 100644
--- a/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java
+++ b/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java
@@ -17,6 +17,8 @@
package com.android.settings.bluetooth;
import android.bluetooth.BluetoothDevice;
+import android.content.Context;
+import android.util.Log;
import java.util.ArrayList;
import java.util.Collection;
@@ -26,10 +28,17 @@
* CachedBluetoothDeviceManager manages the set of remote Bluetooth devices.
*/
final class CachedBluetoothDeviceManager {
+ private static final String TAG = "CachedBluetoothDeviceManager";
+ private static final boolean DEBUG = Utils.D;
+ private Context mContext;
private final List<CachedBluetoothDevice> mCachedDevices =
new ArrayList<CachedBluetoothDevice>();
+ CachedBluetoothDeviceManager(Context context) {
+ mContext = context;
+ }
+
public synchronized Collection<CachedBluetoothDevice> getCachedDevicesCopy() {
return new ArrayList<CachedBluetoothDevice>(mCachedDevices);
}
@@ -74,8 +83,8 @@
CachedBluetoothDevice addDevice(LocalBluetoothAdapter adapter,
LocalBluetoothProfileManager profileManager,
BluetoothDevice device) {
- CachedBluetoothDevice newDevice = new CachedBluetoothDevice(adapter, profileManager,
- device);
+ CachedBluetoothDevice newDevice = new CachedBluetoothDevice(mContext, adapter,
+ profileManager, device);
mCachedDevices.add(newDevice);
return newDevice;
}
@@ -124,4 +133,10 @@
cachedDevice.onUuidChanged();
}
}
+
+ private void log(String msg) {
+ if (DEBUG) {
+ Log.d(TAG, msg);
+ }
+ }
}
diff --git a/src/com/android/settings/bluetooth/LocalBluetoothManager.java b/src/com/android/settings/bluetooth/LocalBluetoothManager.java
index 3357e59..ae8dec2 100644
--- a/src/com/android/settings/bluetooth/LocalBluetoothManager.java
+++ b/src/com/android/settings/bluetooth/LocalBluetoothManager.java
@@ -74,7 +74,7 @@
mContext = context;
mLocalAdapter = adapter;
- mCachedDeviceManager = new CachedBluetoothDeviceManager();
+ mCachedDeviceManager = new CachedBluetoothDeviceManager(context);
mEventManager = new BluetoothEventManager(mLocalAdapter,
mCachedDeviceManager, context);
mProfileManager = new LocalBluetoothProfileManager(context,
diff --git a/src/com/android/settings/net/NetworkPolicyEditor.java b/src/com/android/settings/net/NetworkPolicyEditor.java
index 81cf78e..723c5cc 100644
--- a/src/com/android/settings/net/NetworkPolicyEditor.java
+++ b/src/com/android/settings/net/NetworkPolicyEditor.java
@@ -31,6 +31,7 @@
import android.net.NetworkTemplate;
import android.os.AsyncTask;
import android.os.RemoteException;
+import android.text.format.Time;
import com.android.internal.util.Objects;
import com.google.android.collect.Lists;
@@ -91,31 +92,53 @@
}
}
- public NetworkPolicy getPolicy(NetworkTemplate template) {
+ public boolean hasLimitedPolicy(NetworkTemplate template) {
+ final NetworkPolicy policy = getPolicy(template, false);
+ return policy != null && policy.limitBytes != LIMIT_DISABLED;
+ }
+
+ public NetworkPolicy getPolicy(NetworkTemplate template, boolean createDefault) {
for (NetworkPolicy policy : mPolicies) {
if (policy.template.equals(template)) {
return policy;
}
}
- return null;
+
+ if (createDefault) {
+ final NetworkPolicy policy = buildDefaultPolicy(template);
+ mPolicies.add(policy);
+ return policy;
+ } else {
+ return null;
+ }
+ }
+
+ private static NetworkPolicy buildDefaultPolicy(NetworkTemplate template) {
+ // TODO: move this into framework to share with NetworkPolicyManagerService
+ final Time time = new Time();
+ time.setToNow();
+ final int cycleDay = time.monthDay;
+
+ return new NetworkPolicy(
+ template, cycleDay, WARNING_DISABLED, LIMIT_DISABLED, SNOOZE_NEVER);
}
public void setPolicyCycleDay(NetworkTemplate template, int cycleDay) {
- final NetworkPolicy policy = getPolicy(template);
+ final NetworkPolicy policy = getPolicy(template, true);
policy.cycleDay = cycleDay;
policy.lastSnooze = SNOOZE_NEVER;
writeAsync();
}
public void setPolicyWarningBytes(NetworkTemplate template, long warningBytes) {
- final NetworkPolicy policy = getPolicy(template);
+ final NetworkPolicy policy = getPolicy(template, true);
policy.warningBytes = warningBytes;
policy.lastSnooze = SNOOZE_NEVER;
writeAsync();
}
public void setPolicyLimitBytes(NetworkTemplate template, long limitBytes) {
- final NetworkPolicy policy = getPolicy(template);
+ final NetworkPolicy policy = getPolicy(template, true);
policy.limitBytes = limitBytes;
policy.lastSnooze = SNOOZE_NEVER;
writeAsync();
@@ -153,8 +176,8 @@
} else if (beforeSplit && !split) {
// combine, picking most restrictive policy
- final NetworkPolicy policy3g = getPolicy(template3g);
- final NetworkPolicy policy4g = getPolicy(template4g);
+ final NetworkPolicy policy3g = getPolicy(template3g, false);
+ final NetworkPolicy policy4g = getPolicy(template4g, false);
final NetworkPolicy restrictive = policy3g.compareTo(policy4g) < 0 ? policy3g
: policy4g;
@@ -167,7 +190,7 @@
} else if (!beforeSplit && split) {
// duplicate existing policy into two rules
- final NetworkPolicy policyAll = getPolicy(templateAll);
+ final NetworkPolicy policyAll = getPolicy(templateAll, false);
mPolicies.remove(policyAll);
mPolicies.add(
new NetworkPolicy(template3g, policyAll.cycleDay, policyAll.warningBytes,
@@ -179,5 +202,4 @@
}
}
-
}
diff --git a/src/com/android/settings/nfc/ZeroClick.java b/src/com/android/settings/nfc/ShareTap.java
similarity index 78%
rename from src/com/android/settings/nfc/ZeroClick.java
rename to src/com/android/settings/nfc/ShareTap.java
index 1b59b52..e434781 100644
--- a/src/com/android/settings/nfc/ZeroClick.java
+++ b/src/com/android/settings/nfc/ShareTap.java
@@ -19,20 +19,25 @@
import android.app.ActionBar;
import android.app.Activity;
import android.app.Fragment;
+import android.graphics.drawable.AnimationDrawable;
import android.nfc.NfcAdapter;
import android.os.Bundle;
+import android.os.Handler;
import android.preference.PreferenceActivity;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
+import android.widget.ImageView;
import android.widget.Switch;
import com.android.settings.R;
-public class ZeroClick extends Fragment
+public class ShareTap extends Fragment
implements CompoundButton.OnCheckedChangeListener {
private View mView;
+ private AnimationDrawable mAnimation;
+ private ImageView mImageView;
private NfcAdapter mNfcAdapter;
private Switch mActionBarSwitch;
@@ -69,25 +74,42 @@
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- mView = inflater.inflate(R.layout.zeroclick, container, false);
+ mView = inflater.inflate(R.layout.sharetap, container, false);
initView(mView);
return mView;
}
private void initView(View view) {
- mNfcAdapter = NfcAdapter.getDefaultAdapter(getActivity());
mActionBarSwitch.setOnCheckedChangeListener(this);
mActionBarSwitch.setChecked(mNfcAdapter.isZeroClickEnabled());
}
@Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ mImageView = (ImageView) getActivity().findViewById(R.id.sharetap_image);
+ mImageView.setBackgroundResource(R.drawable.sharetap_anim);
+ mAnimation = (AnimationDrawable) mImageView.getBackground();
+
+ }
+
+ @Override
public void onPause() {
super.onPause();
+ mAnimation.stop();
}
@Override
public void onResume() {
super.onResume();
+ // This is nasty: the animation can only be started once the fragment
+ // is attached to the window, and there are no callbacks for that.
+ mImageView.post(new Runnable() {
+ public void run() {
+ mAnimation.start();
+ }
+ });
}
@Override
diff --git a/src/com/android/settings/widget/ChartGridView.java b/src/com/android/settings/widget/ChartGridView.java
index c2702e4..b930c62 100644
--- a/src/com/android/settings/widget/ChartGridView.java
+++ b/src/com/android/settings/widget/ChartGridView.java
@@ -116,7 +116,7 @@
mBorder.setBounds(0, 0, width, height);
mBorder.draw(canvas);
- final int padding = mLayoutStart.getHeight() / 8;
+ final int padding = mLayoutStart != null ? mLayoutStart.getHeight() / 8 : 0;
final Layout start = mLayoutStart;
if (start != null) {
diff --git a/src/com/android/settings/widget/SettingsAppWidgetProvider.java b/src/com/android/settings/widget/SettingsAppWidgetProvider.java
index ba2b615..8df009c 100644
--- a/src/com/android/settings/widget/SettingsAppWidgetProvider.java
+++ b/src/com/android/settings/widget/SettingsAppWidgetProvider.java
@@ -26,11 +26,13 @@
import android.content.Intent;
import android.content.SyncStorageEngine;
import android.content.pm.PackageManager;
+import android.database.ContentObserver;
import android.location.LocationManager;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.net.wifi.WifiManager;
import android.os.AsyncTask;
+import android.os.Handler;
import android.os.IPowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -103,6 +105,7 @@
private static final StateTracker sBluetoothState = new BluetoothStateTracker();
private static final StateTracker sGpsState = new GpsStateTracker();
private static final StateTracker sSyncState = new SyncStateTracker();
+ private static SettingsObserver sSettingsObserver;
/**
* The state machine for a setting's toggling, tracking reality
@@ -533,8 +536,7 @@
@Override
public int getActualState(Context context) {
- boolean on = getBackgroundDataState(context) &&
- ContentResolver.getMasterSyncAutomatically();
+ boolean on = ContentResolver.getMasterSyncAutomatically();
return on ? STATE_ENABLED : STATE_DISABLED;
}
@@ -547,7 +549,6 @@
public void requestStateChange(final Context context, final boolean desiredState) {
final ConnectivityManager connManager =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
- final boolean backgroundData = getBackgroundDataState(context);
final boolean sync = ContentResolver.getMasterSyncAutomatically();
new AsyncTask<Void, Void, Boolean>() {
@@ -555,9 +556,6 @@
protected Boolean doInBackground(Void... args) {
// Turning sync on.
if (desiredState) {
- if (!backgroundData) {
- connManager.setBackgroundDataSetting(true);
- }
if (!sync) {
ContentResolver.setMasterSyncAutomatically(true);
}
@@ -600,6 +598,11 @@
new ComponentName("com.android.settings", ".widget.SettingsAppWidgetProvider"),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
+ if (sSettingsObserver == null) {
+ sSettingsObserver = new SettingsObserver(new Handler(),
+ context.getApplicationContext());
+ sSettingsObserver.startObserving();
+ }
}
@Override
@@ -610,6 +613,10 @@
new ComponentName("com.android.settings", ".widget.SettingsAppWidgetProvider"),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
+ if (sSettingsObserver != null) {
+ sSettingsObserver.stopObserving();
+ sSettingsObserver = null;
+ }
}
/**
@@ -740,18 +747,6 @@
}
/**
- * Gets the state of background data.
- *
- * @param context
- * @return true if enabled
- */
- private static boolean getBackgroundDataState(Context context) {
- ConnectivityManager connManager =
- (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
- return connManager.getBackgroundDataSetting();
- }
-
- /**
* Gets state of brightness.
*
* @param context
@@ -849,4 +844,34 @@
Log.d(TAG, "toggleBrightness: " + e);
}
}
+
+ /** Observer to watch for changes to the BRIGHTNESS setting */
+ private static class SettingsObserver extends ContentObserver {
+
+ private Context mContext;
+
+ SettingsObserver(Handler handler, Context context) {
+ super(handler);
+ mContext = context;
+ }
+
+ void startObserving() {
+ ContentResolver resolver = mContext.getContentResolver();
+ // Listen to brightness and brightness mode
+ resolver.registerContentObserver(Settings.System
+ .getUriFor(Settings.System.SCREEN_BRIGHTNESS), false, this);
+ resolver.registerContentObserver(Settings.System
+ .getUriFor(Settings.System.SCREEN_BRIGHTNESS_MODE), false, this);
+ }
+
+ void stopObserving() {
+ mContext.getContentResolver().unregisterContentObserver(this);
+ }
+
+ @Override
+ public void onChange(boolean selfChange) {
+ updateWidget(mContext);
+ }
+ }
+
}
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index dff6d2a..1b24bf7 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -114,7 +114,6 @@
private WifiDialog mDialog;
- private View mView;
private TextView mEmptyView;
/* Used in Wifi Setup context */
@@ -163,13 +162,6 @@
}
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- mView = inflater.inflate(R.layout.custom_preference_list_fragment, container, false);
- return mView;
- }
-
- @Override
public void onActivityCreated(Bundle savedInstanceState) {
// We don't call super.onActivityCreated() here, since it assumes we already set up
// Preference (probably in onCreate()), while WifiSettings exceptionally set it up in
@@ -227,7 +219,7 @@
mWifiEnabler = new WifiEnabler(activity, actionBarSwitch);
}
- mEmptyView = (TextView) mView.findViewById(R.id.empty);
+ mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
getListView().setEmptyView(mEmptyView);
registerForContextMenu(getListView());
diff --git a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
index a3f1764..4b6a081 100644
--- a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
+++ b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
@@ -135,8 +135,6 @@
*/
private DetailedState mPreviousNetworkState = DetailedState.DISCONNECTED;
- private int mBackgroundId = R.drawable.setups_bg_default;
-
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -284,7 +282,7 @@
case SCANNING: {
if (mScreenState == SCREEN_STATE_DISCONNECTED) {
if (mWifiSettings.getAccessPointsCount() == 0) {
- showScanningState();
+ showScanningState();
} else {
showDisconnectedProgressBar();
mWifiSettingsFragmentLayout.setVisibility(View.VISIBLE);
@@ -347,7 +345,6 @@
hideSoftwareKeyboard();
setPaddingVisibility(View.VISIBLE);
- trySetBackground(R.drawable.setups_bg_complete);
showConnectedTitle();
showConnectedProgressBar();
@@ -454,8 +451,6 @@
edit = true;
}
- trySetBackground(R.drawable.setups_bg_default);
-
// We don't want to keep scanning Wifi networks during users' configuring a network.
mWifiSettings.pauseWifiScan();
@@ -568,8 +563,6 @@
/* package */ void onConnectButtonPressed() {
mScreenState = SCREEN_STATE_CONNECTING;
- trySetBackground(R.drawable.setups_bg_wifi);
-
mWifiSettings.submit(mWifiConfig.getController());
// updateConnectionState() isn't called soon by the main Wifi module after the user's
@@ -597,7 +590,6 @@
}
private void onBackButtonPressed() {
- trySetBackground(R.drawable.setups_bg_default);
if (mScreenState == SCREEN_STATE_CONNECTING || mScreenState == SCREEN_STATE_CONNECTED) {
if (DEBUG) Log.d(TAG, "Back button pressed after connect action.");
@@ -717,8 +709,6 @@
mConnectButton.setVisibility(View.VISIBLE);
mConnectButton.setEnabled(true);
- trySetBackground(R.drawable.setups_bg_default);
-
if (!TextUtils.isEmpty(mEditingTitle)) {
mTitleView.setText(mEditingTitle);
} else {
@@ -785,14 +775,4 @@
// We want to both save and connect a network. connectNetwork() does both.
mWifiManager.connectNetwork(config);
}
-
- /**
- * Replace the current background with a new background whose id is resId if needed.
- */
- private void trySetBackground(int resId) {
- if (mBackgroundId != resId) {
- getWindow().setBackgroundDrawable(getResources().getDrawable(resId));
- mBackgroundId = resId;
- }
- }
}