• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

packages/apps/Settings


Commit MetaInfo

Revisiond7316682503194cdd12d29059d99a9de12732192 (tree)
Time2016-09-22 21:20:08
AuthorLinux Build Service Account <lnxbuild@loca...>
CommiterLinux Build Service Account

Log Message

Merge 0958a78753c47944d1e9f3b401d247361347ddc7 on remote branch

Change-Id: I08214a16cc1aba6885faeebeca39313b0d94407c

Change Summary

Incremental Difference

--- /dev/null
+++ b/res/layout/wfc_checkbox.xml
@@ -0,0 +1,77 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<!--
3+Copyright (c) 2016, The Linux Foundation. All rights reserved.
4+
5+Redistribution and use in source and binary forms, with or without
6+modification, are permitted provided that the following conditions are
7+met:
8+ * Redistributions of source code must retain the above copyright
9+ notice, this list of conditions and the following disclaimer.
10+ * Redistributions in binary form must reproduce the above
11+ copyright notice, this list of conditions and the following
12+ disclaimer in the documentation and/or other materials provided
13+ with the distribution.
14+ * Neither the name of The Linux Foundation nor the names of its
15+ contributors may be used to endorse or promote products derived
16+ from this software without specific prior written permission.
17+
18+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
19+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
21+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
25+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
28+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+-->
30+
31+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
32+ android:layout_width="match_parent"
33+ android:layout_height="wrap_content"
34+ android:background="?android:attr/activatedBackgroundIndicator"
35+ android:gravity="center_vertical"
36+ android:minHeight="48dp"
37+ android:paddingEnd="?android:attr/scrollbarSize" >
38+
39+ <RelativeLayout
40+ android:layout_width="0dip"
41+ android:layout_height="wrap_content"
42+ android:layout_marginStart="15dip"
43+ android:layout_marginEnd="6dip"
44+ android:layout_marginTop="6dip"
45+ android:layout_marginBottom="6dip"
46+ android:layout_weight="1">
47+
48+ <TextView android:id="@+id/subtitle"
49+ android:layout_width="wrap_content"
50+ android:layout_height="wrap_content"
51+ android:singleLine="true"
52+ android:text="@string/wifi_calling_settings_title"
53+ android:textAppearance="?android:attr/textAppearanceListItem"
54+ android:ellipsize="marquee"
55+ android:fadingEdge="horizontal" />
56+
57+ <TextView android:id="@+id/subsummary"
58+ android:layout_width="wrap_content"
59+ android:layout_height="wrap_content"
60+ android:layout_below="@+id/subtitle"
61+ android:layout_alignStart="@+id/subtitle"
62+ android:textAppearance="?android:attr/textAppearanceSmall"
63+ android:textColor="?android:attr/textColorSecondary"
64+ android:maxLines="4" />
65+
66+ </RelativeLayout>
67+
68+ <Switch
69+ android:id="@+id/switchWidget"
70+ android:layout_width="wrap_content"
71+ android:layout_height="wrap_content"
72+ android:layout_gravity="center"
73+ android:clickable="true"
74+ android:focusable="false"
75+ android:padding="8dip" />
76+
77+</LinearLayout>
\ No newline at end of file
--- a/res/values-zh-rCN/arrays.xml
+++ b/res/values-zh-rCN/arrays.xml
@@ -224,6 +224,7 @@
224224 <item msgid="6062567900587138000">"SPN"</item>
225225 <item msgid="2454085083342423481">"IMSI"</item>
226226 <item msgid="2681427309183221543">"GID"</item>
227+ <item>"ICCID"</item>
227228 </string-array>
228229 <string-array name="app_install_location_entries">
229230 <item msgid="8151497958991952759">"内部存储设备"</item>
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -3143,4 +3143,6 @@
31433143 <string name="profiles_settings_title">情景模式</string>
31443144
31453145 <string name="mbn_version">MBN 版本</string>
3146+ <string name="show_battery_percentage">显示电池电量百分比</string>
3147+ <string name="show_battery_percentage_summary">在状态栏中显示电池电量百分比</string>
31463148 </resources>
--- a/res/values-zh-rHK/arrays.xml
+++ b/res/values-zh-rHK/arrays.xml
@@ -224,6 +224,7 @@
224224 <item msgid="6062567900587138000">"SPN"</item>
225225 <item msgid="2454085083342423481">"IMSI"</item>
226226 <item msgid="2681427309183221543">"GID"</item>
227+ <item>"ICCID"</item>
227228 </string-array>
228229 <string-array name="app_install_location_entries">
229230 <item msgid="8151497958991952759">"內部裝置儲存空間"</item>
--- a/res/values-zh-rTW/arrays.xml
+++ b/res/values-zh-rTW/arrays.xml
@@ -224,6 +224,7 @@
224224 <item msgid="6062567900587138000">"SPN"</item>
225225 <item msgid="2454085083342423481">"IMSI"</item>
226226 <item msgid="2681427309183221543">"GID"</item>
227+ <item>"ICCID"</item>
227228 </string-array>
228229 <string-array name="app_install_location_entries">
229230 <item msgid="8151497958991952759">"內部裝置儲存空間"</item>
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1100,4 +1100,14 @@
11001100 <item>com.android.orange</item>
11011101 <item>com.android.noos</item>
11021102 </string-array>
1103+
1104+ <string-array name="plmn_list_for_apn_disable">
1105+ <item>20404</item>
1106+ <item>45403</item>
1107+ <item>45404</item>
1108+ <item>45502</item>
1109+ <item>45507</item>
1110+ <item>46003</item>
1111+ <item>46011</item>
1112+ </string-array>
11031113 </resources>
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -56,6 +56,10 @@
5656 <!-- show tethering help begin -->
5757 <bool name="tethering_show_help_for_first_using">false</bool>
5858 <bool name="tethering_show_help_menu">false</bool>
59+
60+ <!-- Config to enable/disable the USB line-->
61+ <bool name="config_usb_line_enable">false</bool>
62+
5963 <!-- show tethering help end -->
6064 <!-- Config voice over lte in wireless settings begin -->
6165 <bool name="config_voice_over_lte_enabled">false</bool>
--- a/res/values/customize.xml
+++ b/res/values/customize.xml
@@ -33,4 +33,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333
3434 <!-- Whether to show_kernel version name -->
3535 <bool name="def_hide_kernel_version_name">false</bool>
36+ <!-- Whether to show a preference item for battery percentage
37+ in ("Battery") for India RJIL -->
38+ <bool name="config_show_battery_percentage">false</bool>
3639 </resources>
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7590,4 +7590,6 @@
75907590 <string name="lte_data_service_enabled">LTE data service enabled </string>
75917591 <string name="turn_off_wifi_dialog_title">Turn off Wi-Fi</string>
75927592 <string name="turn_off_wifi_dialog_text">Wi-Fi is turned off when Mobile HotSpot is active. To turn on Wi-Fi, please turn off Mobile HotSpot.</string>
7593+ <string name="show_battery_percentage">Show battery percentage</string>
7594+ <string name="show_battery_percentage_summary">Show battery level percentage inside the status bar</string>
75937595 </resources>
--- a/res/xml/power_usage_summary.xml
+++ b/res/xml/power_usage_summary.xml
@@ -23,6 +23,12 @@
2323 android:title="@string/battery_saver"
2424 android:fragment="com.android.settings.fuelgauge.BatterySaverSettings" />
2525
26+ <SwitchPreference
27+ android:key="battery_pct"
28+ android:title="@string/show_battery_percentage"
29+ android:summary="@string/show_battery_percentage_summary"
30+ android:persistent="false" />
31+
2632 <com.android.settings.fuelgauge.BatteryHistoryPreference
2733 android:key="battery_history" />
2834
--- a/res/xml/wireless_settings.xml
+++ b/res/xml/wireless_settings.xml
@@ -1,4 +1,6 @@
11 <?xml version="1.0" encoding="utf-8"?>
2+<!-- Copyright (c) 2016, The Linux Foundation. All rights reserved.-->
3+
24 <!-- Copyright (C) 2008 The Android Open Source Project
35
46 Licensed under the Apache License, Version 2.0 (the "License");
@@ -34,17 +36,12 @@
3436 settings:keywords="@string/keywords_wifi_calling"
3537 android:fragment="com.android.settings.WifiCallingSettings" />
3638
37- <PreferenceScreen
39+ <com.android.settings.WFCPreference
3840 android:key="wifi_calling_enhanced_settings"
39- android:title="@string/wifi_calling_settings_title"
4041 android:summaryOff="@null"
4142 android:summaryOn="@null"
42- android:persistent="false">
43- <intent
44- android:action="android.intent.action.MAIN"
45- android:targetPackage="com.qualcomm.qti.wfcservice"
46- android:targetClass="com.qualcomm.qti.wfcservice.WifiCallingEnhancedSettings" />
47- </PreferenceScreen>
43+ android:persistent="false"
44+ android:layout="@layout/wfc_checkbox" />
4845
4946 <com.android.settingslib.RestrictedPreference
5047 android:fragment="com.android.settings.nfc.AndroidBeam"
--- a/src/com/android/settings/ApnEditor.java
+++ b/src/com/android/settings/ApnEditor.java
@@ -100,6 +100,7 @@ public class ApnEditor extends SettingsPreferenceFragment
100100 private Cursor mCursor;
101101 private boolean mNewApn;
102102 private boolean mFirstTime;
103+ private boolean mApnDisable = false;
103104 private int mSubId;
104105 private Resources mRes;
105106 private TelephonyManager mTelephonyManager;
@@ -206,10 +207,6 @@ public class ApnEditor extends SettingsPreferenceFragment
206207 mSubId = intent.getIntExtra(ApnSettings.SUB_ID,
207208 SubscriptionManager.INVALID_SUBSCRIPTION_ID);
208209 mDisableEditor = intent.getBooleanExtra("DISABLE_EDITOR", false);
209- if (mDisableEditor) {
210- getPreferenceScreen().setEnabled(false);
211- Log.d(TAG, "ApnEditor form is disabled.");
212- }
213210
214211 mFirstTime = icicle == null;
215212
@@ -404,6 +401,24 @@ public class ApnEditor extends SettingsPreferenceFragment
404401 } else {
405402 mCarrierEnabled.setEnabled(false);
406403 }
404+
405+ String mccMnc = mMcc.getText() + mMnc.getText();
406+ for (String plmn : getResources().getStringArray(R.array.plmn_list_for_apn_disable)) {
407+ if (plmn.equals(mccMnc) && !mNewApn) {
408+ mApnDisable = true;
409+ Log.d(TAG, "APN is China Telecom's.");
410+ break;
411+ }
412+ }
413+ if (mDisableEditor) {
414+ if (mApnDisable) {
415+ mApn.setEnabled(false);
416+ Log.d(TAG, "Apn Name can't be edited.");
417+ } else {
418+ getPreferenceScreen().setEnabled(false);
419+ Log.d(TAG, "ApnEditor form is disabled.");
420+ }
421+ }
407422 }
408423
409424 /**
@@ -550,12 +565,12 @@ public class ApnEditor extends SettingsPreferenceFragment
550565 @Override
551566 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
552567 super.onCreateOptionsMenu(menu, inflater);
553- if (mDisableEditor) {
568+ if (mDisableEditor && !mApnDisable) {
554569 Log.d(TAG, "Form is disabled. Do not create the options menu.");
555570 return;
556571 }
557572 // If it's a new APN, then cancel will delete the new entry in onPause
558- if (!mNewApn) {
573+ if (!mNewApn && !mDisableEditor) {
559574 menu.add(0, MENU_DELETE, 0, R.string.menu_delete)
560575 .setIcon(R.drawable.ic_menu_delete);
561576 }
--- a/src/com/android/settings/ApnSettings.java
+++ b/src/com/android/settings/ApnSettings.java
@@ -43,6 +43,7 @@ import android.support.v7.preference.Preference;
4343 import android.support.v7.preference.PreferenceGroup;
4444 import android.support.v7.preference.PreferenceScreen;
4545 import android.telephony.CarrierConfigManager;
46+import android.telephony.ServiceState;
4647 import android.telephony.SubscriptionInfo;
4748 import android.telephony.SubscriptionManager;
4849 import android.telephony.TelephonyManager;
@@ -64,6 +65,8 @@ import com.android.internal.telephony.uicc.UiccController;
6465 import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
6566
6667 import java.util.ArrayList;
68+import java.util.HashSet;
69+import java.util.Iterator;
6770
6871 public class ApnSettings extends RestrictedSettingsFragment implements
6972 Preference.OnPreferenceChangeListener {
@@ -89,6 +92,8 @@ public class ApnSettings extends RestrictedSettingsFragment implements
8992 private static final int MVNO_TYPE_INDEX = 4;
9093 private static final int MVNO_MATCH_DATA_INDEX = 5;
9194 private static final int RO_INDEX = 6;
95+ private static final int BEARER_INDEX = 7;
96+ private static final int BEARER_BITMASK_INDEX = 8;
9297
9398 private static final int MENU_NEW = Menu.FIRST;
9499 private static final int MENU_RESTORE = Menu.FIRST + 1;
@@ -126,6 +131,8 @@ public class ApnSettings extends RestrictedSettingsFragment implements
126131 super(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS);
127132 }
128133
134+ private HashSet mIccidSet;
135+
129136 private final BroadcastReceiver mMobileStateReceiver = new BroadcastReceiver() {
130137 @Override
131138 public void onReceive(Context context, Intent intent) {
@@ -136,8 +143,6 @@ public class ApnSettings extends RestrictedSettingsFragment implements
136143 case CONNECTED:
137144 if (!mRestoreDefaultApnMode) {
138145 fillList();
139- } else {
140- showDialog(DIALOG_RESTORE_DEFAULTAPN);
141146 }
142147 break;
143148 }
@@ -165,6 +170,9 @@ public class ApnSettings extends RestrictedSettingsFragment implements
165170 final Activity activity = getActivity();
166171 final int subId = activity.getIntent().getIntExtra(SUB_ID,
167172 SubscriptionManager.INVALID_SUBSCRIPTION_ID);
173+ fillOperatorIccidset();
174+ Log.d(TAG, "onCreate: subId = " + subId);
175+
168176
169177 mMobileStateFilter = new IntentFilter(
170178 TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
@@ -251,6 +259,23 @@ public class ApnSettings extends RestrictedSettingsFragment implements
251259 return null;
252260 }
253261
262+ private void fillOperatorIccidset(){
263+ mIccidSet = new HashSet<String>();
264+ mIccidSet.add("8991840");
265+ mIccidSet.add("8991854");
266+ mIccidSet.add("8991855");
267+ mIccidSet.add("8991856");
268+ mIccidSet.add("8991857");
269+ mIccidSet.add("8991858");
270+ mIccidSet.add("8991859");
271+ mIccidSet.add("899186");
272+ mIccidSet.add("8991870");
273+ mIccidSet.add("8991871");
274+ mIccidSet.add("8991872");
275+ mIccidSet.add("8991873");
276+ mIccidSet.add("8991874");
277+ }
278+
254279 private void fillList() {
255280 final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
256281 final String mccmnc = mSubscriptionInfo == null ? ""
@@ -305,11 +330,15 @@ public class ApnSettings extends RestrictedSettingsFragment implements
305330 where.append(" AND NOT (type='ims')");
306331 }
307332
333+ if (isOperatorIccId()) {
334+ where.append(" AND type <>\"" + PhoneConstants.APN_TYPE_EMERGENCY + "\"");
335+ where.append(" AND type <>\"" + PhoneConstants.APN_TYPE_IMS + "\"");
336+ }
308337 Log.d(TAG, "where---" + where);
309338
310339 Cursor cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI, new String[] {
311- "_id", "name", "apn", "type", "mvno_type", "mvno_match_data", "read_only"},
312- where.toString(), null, Telephony.Carriers.DEFAULT_SORT_ORDER);
340+ "_id", "name", "apn", "type", "mvno_type", "mvno_match_data", "read_only", "bearer",
341+ "bearer_bitmask"}, where.toString(), null, Telephony.Carriers.DEFAULT_SORT_ORDER);
313342
314343 if (cursor != null) {
315344 IccRecords r = null;
@@ -339,7 +368,22 @@ public class ApnSettings extends RestrictedSettingsFragment implements
339368 if (!TextUtils.isEmpty(localizedName)) {
340369 name = localizedName;
341370 }
342-
371+ int bearer = cursor.getInt(BEARER_INDEX);
372+ int bearerBitMask = cursor.getInt(BEARER_BITMASK_INDEX);
373+ int fullBearer = bearer | bearerBitMask;
374+ int subId = mSubscriptionInfo != null ? mSubscriptionInfo.getSubscriptionId()
375+ : SubscriptionManager.INVALID_SUBSCRIPTION_ID;
376+ int radioTech = networkTypeToRilRidioTechnology(TelephonyManager.getDefault()
377+ .getDataNetworkType(subId));
378+ if (!ServiceState.bitmaskHasTech(fullBearer, radioTech)
379+ && (bearer != 0 || bearerBitMask != 0)) {
380+ // In OOS, show APN with bearer as default
381+ if ((radioTech != ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN) || (bearer == 0
382+ && radioTech == ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN)) {
383+ cursor.moveToNext();
384+ continue;
385+ }
386+ }
343387 ApnPreference pref = new ApnPreference(getPrefContext());
344388
345389 pref.setApnReadOnly(readOnly);
@@ -379,6 +423,61 @@ public class ApnSettings extends RestrictedSettingsFragment implements
379423 }
380424 }
381425
426+ private boolean isOperatorIccId(){
427+ final String iccid = mSubscriptionInfo == null ? ""
428+ : mSubscriptionInfo.getIccId();
429+ Iterator<String> itr = mIccidSet.iterator();
430+ while (itr.hasNext()) {
431+ if (iccid.contains(itr.next())) {
432+ return true;
433+ }
434+ }
435+ return false;
436+ }
437+
438+ private int networkTypeToRilRidioTechnology(int nt) {
439+ switch(nt) {
440+ case TelephonyManager.NETWORK_TYPE_GPRS:
441+ return ServiceState.RIL_RADIO_TECHNOLOGY_GPRS;
442+ case TelephonyManager.NETWORK_TYPE_EDGE:
443+ return ServiceState.RIL_RADIO_TECHNOLOGY_EDGE;
444+ case TelephonyManager.NETWORK_TYPE_UMTS:
445+ return ServiceState.RIL_RADIO_TECHNOLOGY_UMTS;
446+ case TelephonyManager.NETWORK_TYPE_HSDPA:
447+ return ServiceState.RIL_RADIO_TECHNOLOGY_HSDPA;
448+ case TelephonyManager.NETWORK_TYPE_HSUPA:
449+ return ServiceState.RIL_RADIO_TECHNOLOGY_HSUPA;
450+ case TelephonyManager.NETWORK_TYPE_HSPA:
451+ return ServiceState.RIL_RADIO_TECHNOLOGY_HSPA;
452+ case TelephonyManager.NETWORK_TYPE_CDMA:
453+ return ServiceState.RIL_RADIO_TECHNOLOGY_IS95B;
454+ case TelephonyManager.NETWORK_TYPE_1xRTT:
455+ return ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT;
456+ case TelephonyManager.NETWORK_TYPE_EVDO_0:
457+ return ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_0;
458+ case TelephonyManager.NETWORK_TYPE_EVDO_A:
459+ return ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A;
460+ case TelephonyManager.NETWORK_TYPE_EVDO_B:
461+ return ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_B;
462+ case TelephonyManager.NETWORK_TYPE_EHRPD:
463+ return ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD;
464+ case TelephonyManager.NETWORK_TYPE_LTE:
465+ return ServiceState.RIL_RADIO_TECHNOLOGY_LTE;
466+ case TelephonyManager.NETWORK_TYPE_HSPAP:
467+ return ServiceState.RIL_RADIO_TECHNOLOGY_HSPAP;
468+ case TelephonyManager.NETWORK_TYPE_GSM:
469+ return ServiceState.RIL_RADIO_TECHNOLOGY_GSM;
470+ case TelephonyManager.NETWORK_TYPE_TD_SCDMA:
471+ return ServiceState.RIL_RADIO_TECHNOLOGY_TD_SCDMA;
472+ case TelephonyManager.NETWORK_TYPE_IWLAN:
473+ return ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN;
474+ case TelephonyManager.NETWORK_TYPE_LTE_CA:
475+ return ServiceState.RIL_RADIO_TECHNOLOGY_LTE_CA;
476+ default:
477+ return ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN;
478+ }
479+ }
480+
382481 public static String getLocalizedName(Context context, Cursor cursor, int index) {
383482 // If can find a localized name, replace the APN name with it
384483 String resName = cursor.getString(index);
@@ -483,13 +582,13 @@ public class ApnSettings extends RestrictedSettingsFragment implements
483582
484583 ContentValues values = new ContentValues();
485584 values.put(APN_ID, mSelectedKey);
486- resolver.update(PREFERAPN_URI, values, null, null);
585+ resolver.update(getUri(PREFERAPN_URI), values, null, null);
487586 }
488587
489588 private String getSelectedApnKey() {
490589 String key = null;
491590
492- Cursor cursor = getContentResolver().query(PREFERAPN_URI, new String[] {"_id"},
591+ Cursor cursor = getContentResolver().query(getUri(PREFERAPN_URI), new String[] {"_id"},
493592 null, null, Telephony.Carriers.DEFAULT_SORT_ORDER);
494593 if (cursor.getCount() > 0) {
495594 cursor.moveToFirst();
@@ -560,7 +659,7 @@ public class ApnSettings extends RestrictedSettingsFragment implements
560659 switch (msg.what) {
561660 case EVENT_RESTORE_DEFAULTAPN_START:
562661 ContentResolver resolver = getContentResolver();
563- resolver.delete(DEFAULTAPN_URI, null, null);
662+ resolver.delete(getUri(DEFAULTAPN_URI), null, null);
564663 mRestoreApnUiHandler
565664 .sendEmptyMessage(EVENT_RESTORE_DEFAULTAPN_COMPLETE);
566665 break;
@@ -582,4 +681,13 @@ public class ApnSettings extends RestrictedSettingsFragment implements
582681 }
583682 return null;
584683 }
684+
685+ private Uri getUri(Uri uri) {
686+ int subId = SubscriptionManager.getDefaultDataSubscriptionId();
687+ if (mSubscriptionInfo != null && SubscriptionManager.isValidSubscriptionId(
688+ mSubscriptionInfo.getSubscriptionId())) {
689+ subId = mSubscriptionInfo.getSubscriptionId();
690+ }
691+ return Uri.withAppendedPath(uri, "/subId/" + subId);
692+ }
585693 }
--- a/src/com/android/settings/AppListPreference.java
+++ b/src/com/android/settings/AppListPreference.java
@@ -52,6 +52,8 @@ import java.util.List;
5252 public class AppListPreference extends CustomListPreference {
5353
5454 public static final String ITEM_NONE_VALUE = "";
55+ public static final int TYPE_PACKAGE = 0;
56+ public static final int TYPE_COMPONENT = 1;
5557
5658 protected final boolean mForWork;
5759 protected final int mUserId;
@@ -60,6 +62,7 @@ public class AppListPreference extends CustomListPreference {
6062 private boolean mShowItemNone = false;
6163 private CharSequence[] mSummaries;
6264 private int mSystemAppIndex = -1;
65+ private int mType = TYPE_PACKAGE;
6366
6467 public class AppArrayAdapter extends ArrayAdapter<CharSequence> {
6568 private Drawable[] mImageDrawables = null;
@@ -189,6 +192,8 @@ public class AppListPreference extends CustomListPreference {
189192 public void setComponentNames(ComponentName[] componentNames, ComponentName defaultCN,
190193 CharSequence[] summaries) {
191194 mSummaries = summaries;
195+ mType = TYPE_COMPONENT;
196+
192197 // Look up all package names in PackageManager. Skip ones we can't find.
193198 PackageManager pm = getContext().getPackageManager();
194199 final int entryCount = componentNames.length + (mShowItemNone ? 1 : 0);
@@ -257,7 +262,18 @@ public class AppListPreference extends CustomListPreference {
257262 if (state instanceof SavedState) {
258263 SavedState savedState = (SavedState) state;
259264 mShowItemNone = savedState.showItemNone;
260- setPackageNames(savedState.entryValues, savedState.value);
265+ if (mType == TYPE_PACKAGE) {
266+ setPackageNames(savedState.entryValues, savedState.value);
267+ } else if (mType == TYPE_COMPONENT) {
268+ int len = savedState.entryValues.length;
269+ ComponentName[] entryValues = new ComponentName[len];
270+ for(int i = 0; i < len; i++) {
271+ entryValues[i] = ComponentName.unflattenFromString(
272+ savedState.entryValues[i]+"");
273+ }
274+ setComponentNames(entryValues,
275+ ComponentName.unflattenFromString(savedState.value+""));
276+ }
261277 mSummaries = savedState.summaries;
262278 super.onRestoreInstanceState(savedState.superState);
263279 } else {
--- a/src/com/android/settings/ConfirmLockPattern.java
+++ b/src/com/android/settings/ConfirmLockPattern.java
@@ -100,6 +100,8 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
100100
101101 private AppearAnimationUtils mAppearAnimationUtils;
102102 private DisappearAnimationUtils mDisappearAnimationUtils;
103+ private boolean mIsScale = false;
104+ private final float mScale = 0.65f;
103105
104106 // required constructor for fragments
105107 public ConfirmLockPatternFragment() {
@@ -122,6 +124,8 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
122124 mLeftSpacerLandscape = view.findViewById(R.id.leftSpacer);
123125 mRightSpacerLandscape = view.findViewById(R.id.rightSpacer);
124126
127+ resizePattern();
128+
125129 // make it so unhandled touch events within the unlock screen go to the
126130 // lock pattern view.
127131 final LinearLayoutWithDefaultTouchRecepient topLayout
@@ -215,6 +219,27 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
215219 mCredentialCheckResultTracker.setListener(this);
216220 }
217221
222+ private void resizePattern() {
223+ if ((getActivity() != null) && getActivity().isInMultiWindowMode()) {
224+ mIsScale = true;
225+ ViewGroup.LayoutParams lp = mLockPatternView.getLayoutParams();
226+ lp.width *= mScale;
227+ lp.height *= mScale;
228+ mLockPatternView.setLayoutParams(lp);
229+ }
230+ }
231+
232+ @Override
233+ public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
234+ super.onMultiWindowModeChanged(isInMultiWindowMode);
235+ if (!isInMultiWindowMode && mIsScale) {
236+ ViewGroup.LayoutParams lp = mLockPatternView.getLayoutParams();
237+ lp.width /= mScale;
238+ lp.height /= mScale;
239+ mLockPatternView.setLayoutParams(lp);
240+ }
241+ }
242+
218243 @Override
219244 protected void onShowError() {
220245 }
--- a/src/com/android/settings/TetherSettings.java
+++ b/src/com/android/settings/TetherSettings.java
@@ -150,6 +150,10 @@ public class TetherSettings extends RestrictedSettingsFragment
150150 private DataSaverBackend mDataSaverBackend;
151151 private boolean mDataSaverEnabled;
152152 private Preference mDataSaverFooter;
153+ /* Record the wifi status before usb tether is on */
154+ private boolean mUsbEnable = false;
155+ private WifiManager mWifiStatusManager;
156+ private boolean mIsWifiEnabled = false;
153157
154158 @Override
155159 protected int getMetricsCategory() {
@@ -268,6 +272,9 @@ public class TetherSettings extends RestrictedSettingsFragment
268272 }
269273 // Set initial state based on Data Saver mode.
270274 onDataSaverChanged(mDataSaverBackend.isDataSaverEnabled());
275+ mUsbEnable = getResources().getBoolean(R.bool.config_usb_line_enable);
276+ mWifiStatusManager= (WifiManager) getActivity().getSystemService(
277+ Context.WIFI_SERVICE);
271278 }
272279
273280 @Override
@@ -364,6 +371,12 @@ public class TetherSettings extends RestrictedSettingsFragment
364371 updateState();
365372 } else if (action.equals(UsbManager.ACTION_USB_STATE)) {
366373 mUsbConnected = intent.getBooleanExtra(UsbManager.USB_CONNECTED, false);
374+ mMassStorageActive = Environment.MEDIA_SHARED.equals(
375+ Environment.getExternalStorageState());
376+ boolean usbAvailable = mUsbConnected && !mMassStorageActive;
377+ if(!usbAvailable && mIsWifiEnabled && mUsbEnable){
378+ mWifiManager.setWifiEnabled(true);
379+ }
367380 updateState();
368381 } else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
369382 if (mBluetoothEnableForTether) {
@@ -687,16 +700,29 @@ public class TetherSettings extends RestrictedSettingsFragment
687700 }
688701 }
689702
703+ if (choice == TETHERING_USB) {
704+ if(mUsbTether.isChecked()) {
705+ mWifiManager.setWifiEnabled(false);
706+ }
707+ }
690708 mCm.startTethering(choice, true, mStartTetheringCallback, mHandler);
691709 }
692710
693711 @Override
694712 public boolean onPreferenceTreeClick(Preference preference) {
695713 if (preference == mUsbTether) {
696- if (mUsbTether.isChecked()) {
714+ if (mUsbTether.isChecked() && mUsbEnable) {
715+ //get the wifi status
716+ mIsWifiEnabled = mWifiStatusManager.isWifiEnabled();
717+ IntentFilter filter = new IntentFilter();
718+ filter.addAction(UsbManager.ACTION_USB_STATE);
719+ getActivity().registerReceiver(mTetherChangeReceiver, filter);
697720 startTethering(TETHERING_USB);
698721 } else {
699722 mCm.stopTethering(TETHERING_USB);
723+ if (mIsWifiEnabled) {
724+ mWifiManager.setWifiEnabled(true);
725+ }
700726 }
701727 } else if (preference == mBluetoothTether) {
702728 if (mBluetoothTether.isChecked()) {
--- /dev/null
+++ b/src/com/android/settings/WFCPreference.java
@@ -0,0 +1,98 @@
1+/*
2+Copyright (c) 2016, The Linux Foundation. All rights reserved.
3+
4+Redistribution and use in source and binary forms, with or without
5+modification, are permitted provided that the following conditions are
6+met:
7+ * Redistributions of source code must retain the above copyright
8+ notice, this list of conditions and the following disclaimer.
9+ * Redistributions in binary form must reproduce the above
10+ copyright notice, this list of conditions and the following
11+ disclaimer in the documentation and/or other materials provided
12+ with the distribution.
13+ * Neither the name of The Linux Foundation nor the names of its
14+ contributors may be used to endorse or promote products derived
15+ from this software without specific prior written permission.
16+
17+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+*/
29+
30+package com.android.settings;
31+
32+import android.content.Context;
33+import android.support.v7.preference.Preference;
34+import android.support.v7.preference.PreferenceViewHolder;
35+import android.util.AttributeSet;
36+import android.view.View;
37+import android.view.ViewGroup;
38+import android.widget.CompoundButton;
39+import android.widget.CompoundButton.OnCheckedChangeListener;
40+import android.widget.Switch;
41+import android.widget.TextView;
42+
43+public class WFCPreference extends Preference implements OnCheckedChangeListener {
44+
45+ private Switch mSwitch;
46+ private TextView mSubSummary;
47+ private Context mContext;
48+ private boolean mSwitchEnabled;
49+ private CharSequence remainSummary;
50+
51+ public WFCPreference(Context context, AttributeSet attrs, int defStyle) {
52+ super(context, attrs, defStyle);
53+ mContext = context;
54+ }
55+
56+ public WFCPreference(Context context, AttributeSet attrs) {
57+ this(context, attrs, com.android.internal.R.attr.switchPreferenceStyle);
58+ mContext = context;
59+ }
60+
61+ public WFCPreference(Context context) {
62+ this(context, null);
63+ mContext = context;
64+ }
65+
66+ @Override
67+ public void onBindViewHolder(PreferenceViewHolder view) {
68+ super.onBindViewHolder(view);
69+ mSubSummary = (TextView) view.findViewById(R.id.subsummary);
70+ mSubSummary.setText(remainSummary);
71+ mSwitch = (Switch) view.findViewById(R.id.switchWidget);
72+ mSwitch.setOnCheckedChangeListener(this);
73+ setChecked(mSwitchEnabled);
74+ }
75+
76+ @Override
77+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
78+ callChangeListener(isChecked);
79+ mSwitchEnabled = isChecked;
80+ }
81+
82+ public void setSummary(CharSequence summary) {
83+ if (mSubSummary == null) {
84+ remainSummary = summary;
85+ return;
86+ }
87+ mSubSummary.setText(summary);
88+ }
89+
90+ public void setChecked(boolean state) {
91+ if (mSwitch != null) {
92+ mSwitch.setOnCheckedChangeListener(null);
93+ mSwitch.setChecked(state);
94+ mSwitch.setOnCheckedChangeListener(this);
95+ }
96+ mSwitchEnabled=state;
97+ }
98+}
--- a/src/com/android/settings/WifiCallingSettings.java
+++ b/src/com/android/settings/WifiCallingSettings.java
@@ -29,6 +29,8 @@ import android.support.v7.preference.Preference;
2929 import android.support.v7.preference.PreferenceScreen;
3030 import android.telephony.CarrierConfigManager;
3131 import android.telephony.PhoneStateListener;
32+import android.telephony.SubscriptionInfo;
33+import android.telephony.SubscriptionManager;
3234 import android.telephony.TelephonyManager;
3335 import android.util.Log;
3436 import android.widget.Switch;
@@ -60,35 +62,50 @@ public class WifiCallingSettings extends SettingsPreferenceFragment
6062 private ListPreference mButtonWfcMode;
6163 private TextView mEmptyView;
6264
65+ private int[] mCallState = null;
66+ private PhoneStateListener[] mPhoneStateListener = null;
67+ private int mPhoneCount;
6368 private boolean mValidListener = false;
6469 private boolean mEditableWfcMode = true;
6570
66- private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
71+ private void initPhoneStateListeners(int phoneId) {
72+ SubscriptionManager subMgr = SubscriptionManager.from(getActivity());
73+ final SubscriptionInfo subInfo = subMgr.getActiveSubscriptionInfoForSimSlotIndex(phoneId);
74+
75+ if (subInfo == null) {
76+ Log.e(TAG, "initPhoneStateListeners subInfo : " + subInfo +
77+ " for phone Id: " + phoneId);
78+ return;
79+ }
80+
81+ int subId = subInfo.getSubscriptionId();
82+ final int i = phoneId;
6783 /*
6884 * Enable/disable controls when in/out of a call and depending on
6985 * TTY mode and TTY support over VoLTE.
7086 * @see android.telephony.PhoneStateListener#onCallStateChanged(int,
7187 * java.lang.String)
7288 */
73- @Override
74- public void onCallStateChanged(int state, String incomingNumber) {
75- final SettingsActivity activity = (SettingsActivity) getActivity();
76- boolean isNonTtyOrTtyOnVolteEnabled = ImsManager
77- .isNonTtyOrTtyOnVolteEnabled(activity);
78- final SwitchBar switchBar = activity.getSwitchBar();
79- boolean isWfcEnabled = switchBar.getSwitch().isChecked()
80- && isNonTtyOrTtyOnVolteEnabled;
81-
82- switchBar.setEnabled((state == TelephonyManager.CALL_STATE_IDLE)
83- && isNonTtyOrTtyOnVolteEnabled);
84-
85- Preference pref = getPreferenceScreen().findPreference(BUTTON_WFC_MODE);
86- if (pref != null) {
87- pref.setEnabled(isWfcEnabled
88- && (state == TelephonyManager.CALL_STATE_IDLE));
89+ mPhoneStateListener[phoneId] = new PhoneStateListener(subId) {
90+ @Override
91+ public void onCallStateChanged(int state, String incomingNumber) {
92+ final SettingsActivity activity = (SettingsActivity) getActivity();
93+ boolean isNonTtyOrTtyOnVolteEnabled = ImsManager
94+ .isNonTtyOrTtyOnVolteEnabled(activity);
95+ final SwitchBar switchBar = activity.getSwitchBar();
96+ boolean isWfcEnabled = switchBar.getSwitch().isChecked()
97+ && isNonTtyOrTtyOnVolteEnabled;
98+
99+ mCallState[i] = state;
100+ switchBar.setEnabled(isCallStateIdle() && isNonTtyOrTtyOnVolteEnabled);
101+
102+ Preference pref = getPreferenceScreen().findPreference(BUTTON_WFC_MODE);
103+ if (pref != null) {
104+ pref.setEnabled(isWfcEnabled && isCallStateIdle());
105+ }
89106 }
90- }
91- };
107+ };
108+ }
92109
93110 @Override
94111 public void onActivityCreated(Bundle savedInstanceState) {
@@ -182,6 +199,10 @@ public class WifiCallingSettings extends SettingsPreferenceFragment
182199 mButtonWfcMode.setEntries(R.array.wifi_calling_mode_choices_without_wifi_only);
183200 mButtonWfcMode.setEntryValues(R.array.wifi_calling_mode_values_without_wifi_only);
184201 }
202+
203+ mPhoneCount = TelephonyManager.getDefault().getPhoneCount();
204+ mPhoneStateListener = new PhoneStateListener[mPhoneCount];
205+ mCallState = new int[mPhoneCount];
185206 }
186207
187208 @Override
@@ -191,8 +212,7 @@ public class WifiCallingSettings extends SettingsPreferenceFragment
191212 final Context context = getActivity();
192213
193214 if (ImsManager.isWfcEnabledByPlatform(context)) {
194- TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
195- tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
215+ registerPhoneStateListeners(context);
196216
197217 mSwitchBar.addOnSwitchChangeListener(this);
198218
@@ -224,8 +244,7 @@ public class WifiCallingSettings extends SettingsPreferenceFragment
224244 if (mValidListener) {
225245 mValidListener = false;
226246
227- TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
228- tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
247+ unRegisterPhoneStateListeners(context);
229248
230249 mSwitchBar.removeOnSwitchChangeListener(this);
231250 }
@@ -233,6 +252,30 @@ public class WifiCallingSettings extends SettingsPreferenceFragment
233252 context.unregisterReceiver(mIntentReceiver);
234253 }
235254
255+ private void registerPhoneStateListeners(Context context) {
256+ TelephonyManager tm =
257+ (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
258+ for (int i = 0; i < mPhoneCount; i++) {
259+ initPhoneStateListeners(i);
260+ if (mPhoneStateListener[i] != null) {
261+ Log.d(TAG, "Register for call state change for phone Id: " + i);
262+ tm.listen(mPhoneStateListener[i], PhoneStateListener.LISTEN_CALL_STATE);
263+ }
264+ }
265+ }
266+
267+ private void unRegisterPhoneStateListeners(Context context) {
268+ TelephonyManager tm =
269+ (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
270+ for (int i = 0; i < mPhoneCount; i++) {
271+ if (mPhoneStateListener[i] != null) {
272+ Log.d(TAG, "unRegister for call state change for phone Id: " + i);
273+ tm.listen(mPhoneStateListener[i], PhoneStateListener.LISTEN_NONE);
274+ mPhoneStateListener[i] = null;
275+ }
276+ }
277+ }
278+
236279 /**
237280 * Listens to the state change of the switch.
238281 */
@@ -299,4 +342,15 @@ public class WifiCallingSettings extends SettingsPreferenceFragment
299342 }
300343 return resId;
301344 }
345+
346+ private boolean isCallStateIdle() {
347+ boolean callStateIdle = true;
348+ for (int i = 0; i < mCallState.length; i++) {
349+ if (TelephonyManager.CALL_STATE_IDLE != mCallState[i]) {
350+ callStateIdle = false;
351+ }
352+ }
353+ Log.d(TAG, "isCallStateIdle " + callStateIdle);
354+ return callStateIdle;
355+ }
302356 }
--- a/src/com/android/settings/WirelessSettings.java
+++ b/src/com/android/settings/WirelessSettings.java
@@ -1,3 +1,5 @@
1+/* Copyright (c) 2016, The Linux Foundation. All rights reserved.*/
2+
13 /*
24 * Copyright (C) 2009 The Android Open Source Project
35 *
@@ -84,6 +86,10 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
8486 private static final String KEY_WFC_SETTINGS = "wifi_calling_settings";
8587 private static final String KEY_WFC_ENHANCED_SETTINGS = "wifi_calling_enhanced_settings";
8688
89+ private static final String ACTION_WIFI_CALL_ON = "com.android.wificall.TURNON";
90+ private static final String ACTION_WIFI_CALL_OFF = "com.android.wificall.TURNOFF";
91+ private static final String WIFI_CALLING_PREFERRED = "preference";
92+
8793 public static final String EXIT_ECM_RESULT = "exit_ecm_result";
8894 public static final int REQUEST_CODE_EXIT_ECM = 1;
8995
@@ -102,10 +108,11 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
102108 private static final int MANAGE_MOBILE_PLAN_DIALOG_ID = 1;
103109 private static final String SAVED_MANAGE_MOBILE_PLAN_MSG = "mManageMobilePlanMessage";
104110
105- private PreferenceScreen mButtonWfc;
111+ private Preference mButtonWfc;
106112 private boolean mEnhancedWFCSettingsEnabled = false;
107113
108114 private IWFCService mWFCService;
115+
109116 private ServiceConnection mConnection = new ServiceConnection() {
110117
111118 public void onServiceConnected(ComponentName className, IBinder service) {
@@ -124,15 +131,25 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
124131 };
125132
126133 private IWFCServiceCB mCallback = new IWFCServiceCB.Stub() {
127- public void updateWFCMessage(String s) {
128- if (!mEnhancedWFCSettingsEnabled || (s == null)) {
134+ public void updateWFCMessage(String errorCode) {
135+ if (!mEnhancedWFCSettingsEnabled || (errorCode == null)) {
129136 if(DEBUG) Log.e(TAG, "updateWFCMessage fail.");
130137 return ;
131138 }
132139 getActivity().runOnUiThread(new Runnable() {
133140 public void run() {
134- if(DEBUG) Log.d (TAG, "new UI thread.");
135- mButtonWfc.setSummary(s);
141+ if (DEBUG) Log.d(TAG, "new UI thread.");
142+ try {
143+ if (mWFCService.getWifiCallingStatus()) {
144+ if (mButtonWfc instanceof WFCPreference) {
145+ ((WFCPreference) mButtonWfc).setSummary(errorCode);
146+ } else {
147+ mButtonWfc.setSummary(errorCode);
148+ }
149+ }
150+ } catch (RemoteException r) {
151+ Log.e(TAG, "getWifiCallingStatus RemoteException");
152+ }
136153 }
137154 });
138155
@@ -303,6 +320,14 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
303320 return MetricsEvent.WIRELESS;
304321 }
305322
323+ private void broadcastWifiCallingStatus(Context ctx, boolean isTurnOn, int preference) {
324+ if(DEBUG) Log.d(TAG, "broadcastWifiCallingStatus:");
325+ Intent intent = new Intent(isTurnOn ? ACTION_WIFI_CALL_ON
326+ : ACTION_WIFI_CALL_OFF);
327+ intent.putExtra(WIFI_CALLING_PREFERRED, preference);
328+ ctx.sendBroadcast(intent);
329+ }
330+
306331 @Override
307332 public void onCreate(Bundle savedInstanceState) {
308333 super.onCreate(savedInstanceState);
@@ -332,21 +357,52 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
332357 mEnhancedWFCSettingsEnabled = getActivity().getResources().getBoolean(
333358 R.bool.wifi_call_enhanced_setting);
334359 if (mEnhancedWFCSettingsEnabled) {
335- mButtonWfc = (PreferenceScreen) findPreference(KEY_WFC_ENHANCED_SETTINGS);
360+ mButtonWfc = (WFCPreference) findPreference(KEY_WFC_ENHANCED_SETTINGS);
336361 removePreference(KEY_WFC_SETTINGS);
362+ mButtonWfc.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
363+ public boolean onPreferenceClick(Preference preference) {
364+ Intent intent = new Intent();
365+ intent.setAction("android.intent.action.MAIN");
366+ intent.setPackage("com.qualcomm.qti.wfcservice");
367+ intent.setClassName("com.qualcomm.qti.wfcservice",
368+ "com.qualcomm.qti.wfcservice.WifiCallingEnhancedSettings");
369+ mButtonWfc.setIntent(intent);
370+ return false;
371+ }
372+ });
373+
374+ mButtonWfc.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
375+ @Override
376+ public boolean onPreferenceChange(Preference preference, Object value) {
377+ int wfcPreference = -1;
378+ try {
379+ wfcPreference = mWFCService.getWifiCallingPreference();
380+ } catch (RemoteException re) {
381+ Log.e(TAG, "getWifiCallingPreference RemoteException");
382+ return false;
383+ }
384+
385+ boolean isChecked = (Boolean) value;
386+
387+ try {
388+ mWFCService.setWifiCalling(isChecked, wfcPreference);
389+ } catch (RemoteException r) {
390+ Log.e(TAG, "setWifiCalling RemoteException");
391+ }
392+
393+ if (!isChecked) {
394+ ((WFCPreference) preference).setSummary(R.string.disabled);
395+ }
396+
397+ broadcastWifiCallingStatus(getActivity(), isChecked, wfcPreference);
398+ return false;
399+ }
400+ });
337401 } else {
338402 mButtonWfc = (PreferenceScreen) findPreference(KEY_WFC_SETTINGS);
339403 removePreference(KEY_WFC_ENHANCED_SETTINGS);
340404 }
341405
342- if (mEnhancedWFCSettingsEnabled) {
343- //bind WFC service
344- final Intent intentWfc = new Intent();
345- intentWfc.setAction("com.qualcomm.qti.wfcservice.IWFCService");
346- intentWfc.setPackage("com.qualcomm.qti.wfcservice");
347- activity.bindService(intentWfc, mConnection, Context.BIND_AUTO_CREATE);
348- }
349-
350406 String toggleable = Settings.Global.getString(activity.getContentResolver(),
351407 Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
352408
@@ -475,6 +531,14 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
475531 public void onResume() {
476532 super.onResume();
477533
534+ if (mEnhancedWFCSettingsEnabled && mWFCService == null) {
535+ //bind WFC service
536+ final Intent intentWfc = new Intent();
537+ intentWfc.setAction("com.qualcomm.qti.wfcservice.IWFCService");
538+ intentWfc.setPackage("com.qualcomm.qti.wfcservice");
539+ getActivity().bindService(intentWfc, mConnection, Context.BIND_AUTO_CREATE);
540+ }
541+
478542 mAirplaneModeEnabler.resume();
479543 if (mNfcEnabler != null) {
480544 mNfcEnabler.resume();
@@ -486,12 +550,15 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
486550 getPreferenceScreen().addPreference(mButtonWfc);
487551 if (!mEnhancedWFCSettingsEnabled) {
488552 mButtonWfc.setSummary(WifiCallingSettings.getWfcModeSummary(
489- context, ImsManager.getWfcMode(context)));
553+ context, ImsManager.getWfcMode(context)));
490554 } else {
491555 if (!ImsManager.isWfcEnabledByUser(context)) {
492- mButtonWfc.setSummary(R.string.disabled);
556+ ((WFCPreference) mButtonWfc).setChecked(false);
557+ ((WFCPreference) mButtonWfc).setSummary(R.string.disabled);
493558 } else {
494- mButtonWfc.setSummary(SystemProperties.get("sys.wificall.status.msg"));
559+ ((WFCPreference) mButtonWfc).setChecked(true);
560+ ((WFCPreference) mButtonWfc).setSummary(
561+ SystemProperties.get("sys.wificall.status.msg"));
495562 }
496563 }
497564 } else {
--- a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
+++ b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
@@ -66,6 +66,7 @@ public final class DeviceProfilesSettings extends DialogFragment implements
6666 private ViewGroup mProfileContainer;
6767 private TextView mProfileLabel;
6868 private EditTextPreference mDeviceNamePref;
69+ private static final int OK_BUTTON = -1;
6970
7071 private final HashMap<LocalBluetoothProfile, CheckBoxPreference> mAutoConnectPrefs
7172 = new HashMap<LocalBluetoothProfile, CheckBoxPreference>();
@@ -173,11 +174,16 @@ public final class DeviceProfilesSettings extends DialogFragment implements
173174 private void addPreferencesForProfiles() {
174175 mProfileContainer.removeAllViews();
175176 for (LocalBluetoothProfile profile : mCachedDevice.getConnectableProfiles()) {
176- CheckBox pref = createProfilePreference(profile);
177- mProfileContainer.addView(pref);
177+ // MAP and PBAP profiles would be added based on permission access
178+ if (!((profile instanceof PbapServerProfile) ||
179+ (profile instanceof MapProfile))) {
180+ CheckBox pref = createProfilePreference(profile);
181+ mProfileContainer.addView(pref);
182+ }
178183 }
179184
180185 final int pbapPermission = mCachedDevice.getPhonebookPermissionChoice();
186+ Log.d(TAG, "addPreferencesForProfiles: pbapPermission = " + pbapPermission);
181187 // Only provide PBAP cabability if the client device has requested PBAP.
182188 if (pbapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN) {
183189 final PbapServerProfile psp = mManager.getProfileManager().getPbapProfile();
@@ -187,6 +193,7 @@ public final class DeviceProfilesSettings extends DialogFragment implements
187193
188194 final MapProfile mapProfile = mManager.getProfileManager().getMapProfile();
189195 final int mapPermission = mCachedDevice.getMessagePermissionChoice();
196+ Log.d(TAG, "addPreferencesForProfiles: mapPermission = " + mapPermission);
190197 if (mapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN) {
191198 CheckBox mapPreference = createProfilePreference(mapProfile);
192199 mProfileContainer.addView(mapPreference);
@@ -241,15 +248,6 @@ public final class DeviceProfilesSettings extends DialogFragment implements
241248 private void onProfileClicked(LocalBluetoothProfile profile, CheckBox profilePref) {
242249 BluetoothDevice device = mCachedDevice.getDevice();
243250
244- if (KEY_PBAP_SERVER.equals(profilePref.getTag())) {
245- final int newPermission = mCachedDevice.getPhonebookPermissionChoice()
246- == CachedBluetoothDevice.ACCESS_ALLOWED ? CachedBluetoothDevice.ACCESS_REJECTED
247- : CachedBluetoothDevice.ACCESS_ALLOWED;
248- mCachedDevice.setPhonebookPermissionChoice(newPermission);
249- profilePref.setChecked(newPermission == CachedBluetoothDevice.ACCESS_ALLOWED);
250- return;
251- }
252-
253251 if (!profilePref.isChecked()) {
254252 // Recheck it, until the dialog is done.
255253 profilePref.setChecked(true);
@@ -258,6 +256,11 @@ public final class DeviceProfilesSettings extends DialogFragment implements
258256 if (profile instanceof MapProfile) {
259257 mCachedDevice.setMessagePermissionChoice(BluetoothDevice.ACCESS_ALLOWED);
260258 }
259+ if (profile instanceof PbapServerProfile) {
260+ mCachedDevice.setPhonebookPermissionChoice(BluetoothDevice.ACCESS_ALLOWED);
261+ refreshProfilePreference(profilePref, profile);
262+ return;
263+ }
261264 if (profile.isPreferred(device)) {
262265 // profile is preferred but not connected: disable auto-connect
263266 if (profile instanceof PanProfile) {
@@ -291,10 +294,18 @@ public final class DeviceProfilesSettings extends DialogFragment implements
291294 DialogInterface.OnClickListener disconnectListener =
292295 new DialogInterface.OnClickListener() {
293296 public void onClick(DialogInterface dialog, int which) {
294- device.disconnect(profile);
295- profile.setPreferred(device.getDevice(), false);
296- if (profile instanceof MapProfile) {
297- device.setMessagePermissionChoice(BluetoothDevice.ACCESS_REJECTED);
297+
298+ // Disconnect only when user has selected OK
299+ if (which == OK_BUTTON) {
300+ device.disconnect(profile);
301+ profile.setPreferred(device.getDevice(), false);
302+ if (profile instanceof MapProfile) {
303+ device.setMessagePermissionChoice(BluetoothDevice.ACCESS_REJECTED);
304+ }
305+ if (profile instanceof PbapServerProfile) {
306+ device.setPhonebookPermissionChoice(BluetoothDevice.ACCESS_REJECTED);
307+ }
308+
298309 }
299310 refreshProfilePreference(findProfile(profile.toString()), profile);
300311 }
@@ -331,6 +342,19 @@ public final class DeviceProfilesSettings extends DialogFragment implements
331342 for (LocalBluetoothProfile profile : mCachedDevice.getRemovedProfiles()) {
332343 CheckBox profilePref = findProfile(profile.toString());
333344 if (profilePref != null) {
345+
346+ if (profile instanceof PbapServerProfile) {
347+ final int pbapPermission = mCachedDevice.getPhonebookPermissionChoice();
348+ Log.d(TAG, "refreshProfiles: pbapPermission = " + pbapPermission);
349+ if (pbapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN)
350+ continue;
351+ }
352+ if (profile instanceof MapProfile) {
353+ final int mapPermission = mCachedDevice.getMessagePermissionChoice();
354+ Log.d(TAG, "refreshProfiles: mapPermission = " + mapPermission);
355+ if (mapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN)
356+ continue;
357+ }
334358 Log.d(TAG, "Removing " + profile.toString() + " from profile list");
335359 mProfileContainer.removeView(profilePref);
336360 }
--- a/src/com/android/settings/datausage/AppDataUsage.java
+++ b/src/com/android/settings/datausage/AppDataUsage.java
@@ -51,7 +51,6 @@ import com.android.settingslib.net.ChartDataLoader;
5151 import com.android.settingslib.net.UidDetailProvider;
5252
5353 import static android.net.NetworkPolicyManager.POLICY_REJECT_METERED_BACKGROUND;
54-import static android.net.TrafficStats.UID_TETHERING;
5554
5655 public class AppDataUsage extends DataUsageBase implements Preference.OnPreferenceChangeListener,
5756 DataSaverBackend.Listener {
@@ -202,20 +201,6 @@ public class AppDataUsage extends DataUsageBase implements Preference.OnPreferen
202201 mLabel = Utils.getUserLabel(getActivity(), info);
203202 mPackageName = getActivity().getPackageName();
204203 }
205- int userId = 0;
206- //UID_TETHERING will return wrong userId from UidDetailProvider, user UserHandle instead
207- if (mAppItem.key == UID_TETHERING) {
208- userId = UserHandle.getUserId(mAppItem.key);
209- } else {
210- userId = UidDetailProvider.getUserIdForKey(mAppItem.key);
211- }
212-
213- final UserManager um = UserManager.get(getActivity());
214- final UserInfo info = um.getUserInfo(userId);
215- final PackageManager pm = getPackageManager();
216- mIcon = Utils.getUserIcon(getActivity(), um, info);
217- mLabel = Utils.getUserLabel(getActivity(), info);
218- mPackageName = getActivity().getPackageName();
219204 removePreference(KEY_UNRESTRICTED_DATA);
220205 removePreference(KEY_APP_SETTINGS);
221206 removePreference(KEY_RESTRICT_BACKGROUND);
--- a/src/com/android/settings/deviceinfo/SimStatus.java
+++ b/src/com/android/settings/deviceinfo/SimStatus.java
@@ -27,6 +27,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
2727 import android.content.res.Resources;
2828 import android.os.Bundle;
2929 import android.os.PersistableBundle;
30+import android.os.SystemProperties;
3031 import android.os.UserHandle;
3132 import android.os.UserManager;
3233 import android.support.v7.preference.Preference;
@@ -287,9 +288,9 @@ public class SimStatus extends SettingsPreferenceFragment {
287288 networktype = "4G";
288289 }
289290
290- PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
291- if (carrierConfig != null && carrierConfig.getBoolean(
292- "config_carrier_specific_network_type_display", false)) {
291+ String property = SystemProperties.get("persist.radio.atel.carrier");
292+ boolean isCarrierOneSupported = "405854".equals(property);
293+ if (isCarrierOneSupported) {
293294 if (TelephonyManager.NETWORK_TYPE_LTE == actualDataNetworkType ||
294295 TelephonyManager.NETWORK_TYPE_LTE == actualVoiceNetworkType) {
295296 if (mTelephonyManager.isImsRegistered()) {
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -28,6 +28,8 @@ import android.os.Process;
2828 import android.os.UserHandle;
2929 import android.support.v7.preference.Preference;
3030 import android.support.v7.preference.PreferenceGroup;
31+import android.support.v14.preference.SwitchPreference;
32+import android.provider.Settings;
3133 import android.text.TextUtils;
3234 import android.util.SparseArray;
3335 import android.util.TypedValue;
@@ -56,6 +58,7 @@ import java.util.List;
5658 */
5759 public class PowerUsageSummary extends PowerUsageBase {
5860
61+ public static final String SHOW_PERCENT_SETTING = "status_bar_show_battery_percent";
5962 private static final boolean DEBUG = false;
6063
6164 private static final boolean USE_FAKE_DATA = false;
@@ -64,6 +67,7 @@ public class PowerUsageSummary extends PowerUsageBase {
6467
6568 private static final String KEY_APP_LIST = "app_list";
6669 private static final String KEY_BATTERY_HISTORY = "battery_history";
70+ private static final String KEY_BATTERY_PCT = "battery_pct";
6771
6872 private static final int MENU_STATS_TYPE = Menu.FIRST;
6973 private static final int MENU_HIGH_POWER_APPS = Menu.FIRST + 3;
@@ -71,8 +75,10 @@ public class PowerUsageSummary extends PowerUsageBase {
7175
7276 private BatteryHistoryPreference mHistPref;
7377 private PreferenceGroup mAppListGroup;
78+ private SwitchPreference mBatteryPct;
7479
7580 private int mStatsType = BatteryStats.STATS_SINCE_CHARGED;
81+ private boolean isShowBatteryPct;
7682
7783 private static final int MIN_POWER_THRESHOLD_MILLI_AMP = 5;
7884 private static final int MAX_ITEMS_TO_LIST = USE_FAKE_DATA ? 30 : 10;
@@ -87,6 +93,11 @@ public class PowerUsageSummary extends PowerUsageBase {
8793 addPreferencesFromResource(R.xml.power_usage_summary);
8894 mHistPref = (BatteryHistoryPreference) findPreference(KEY_BATTERY_HISTORY);
8995 mAppListGroup = (PreferenceGroup) findPreference(KEY_APP_LIST);
96+ mBatteryPct = (SwitchPreference) findPreference(KEY_BATTERY_PCT);
97+ isShowBatteryPct = getResources().getBoolean(R.bool.config_show_battery_percentage);
98+ if (!isShowBatteryPct) {
99+ getPreferenceScreen().removePreference(mBatteryPct);
100+ }
90101 }
91102
92103 @Override
@@ -97,6 +108,9 @@ public class PowerUsageSummary extends PowerUsageBase {
97108 @Override
98109 public void onResume() {
99110 super.onResume();
111+ if (isShowBatteryPct) {
112+ updateBatteryPct();
113+ }
100114 refreshStats();
101115 }
102116
@@ -479,4 +493,24 @@ public class PowerUsageSummary extends PowerUsageBase {
479493 return new SummaryProvider(activity, summaryLoader);
480494 }
481495 };
496+
497+ private void updateBatteryPct() {
498+ if (mBatteryPct != null) {
499+ mBatteryPct.setChecked(
500+ Settings.System.getInt(getContext().getContentResolver(),
501+ SHOW_PERCENT_SETTING, 0) != 0);
502+ mBatteryPct.setOnPreferenceChangeListener(mBatteryPctChange);
503+ }
504+ }
505+
506+ private final Preference.OnPreferenceChangeListener mBatteryPctChange =
507+ new Preference.OnPreferenceChangeListener() {
508+ @Override
509+ public boolean onPreferenceChange(Preference preference, Object newValue) {
510+ final boolean v = (Boolean) newValue;
511+ Settings.System.putInt(getContext().getContentResolver(),
512+ SHOW_PERCENT_SETTING, v ? 1 : 0);
513+ return true;
514+ }
515+ };
482516 }
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -44,6 +44,7 @@ import android.support.v7.preference.Preference;
4444 import android.support.v7.preference.Preference.OnPreferenceClickListener;
4545 import android.support.v7.preference.PreferenceGroup;
4646 import android.support.v7.preference.PreferenceScreen;
47+import android.provider.Settings.Global;
4748 import android.util.Log;
4849 import android.util.SparseArray;
4950 import android.view.Menu;
@@ -241,6 +242,11 @@ public class UserSettings extends SettingsPreferenceFragment
241242 loadProfile();
242243 updateUserList();
243244 mShouldUpdateUserList = false;
245+
246+ if (Global.getInt(getContext().getContentResolver(), Global.DEVICE_PROVISIONED, 0) == 0) {
247+ getActivity().finish();
248+ return;
249+ }
244250 }
245251
246252 @Override
--- a/src/org/codeaurora/wfcservice/IWFCService.aidl
+++ b/src/org/codeaurora/wfcservice/IWFCService.aidl
@@ -35,5 +35,8 @@ import org.codeaurora.wfcservice.IWFCServiceCB;
3535 interface IWFCService {
3636 void registerCallback(IWFCServiceCB cb);
3737 void unregisterCallback(IWFCServiceCB cb);
38+ void setWifiCalling(boolean state, int preference);
39+ boolean getWifiCallingStatus();
40+ int getWifiCallingPreference();
3841 }
3942