packages/apps/Settings
リビジョン | d7316682503194cdd12d29059d99a9de12732192 (tree) |
---|---|
日時 | 2016-09-22 21:20:08 |
作者 | Linux Build Service Account <lnxbuild@loca...> |
コミッター | Linux Build Service Account |
Merge 0958a78753c47944d1e9f3b401d247361347ddc7 on remote branch
Change-Id: I08214a16cc1aba6885faeebeca39313b0d94407c
@@ -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 |
@@ -224,6 +224,7 @@ | ||
224 | 224 | <item msgid="6062567900587138000">"SPN"</item> |
225 | 225 | <item msgid="2454085083342423481">"IMSI"</item> |
226 | 226 | <item msgid="2681427309183221543">"GID"</item> |
227 | + <item>"ICCID"</item> | |
227 | 228 | </string-array> |
228 | 229 | <string-array name="app_install_location_entries"> |
229 | 230 | <item msgid="8151497958991952759">"内部存储设备"</item> |
@@ -3143,4 +3143,6 @@ | ||
3143 | 3143 | <string name="profiles_settings_title">情景模式</string> |
3144 | 3144 | |
3145 | 3145 | <string name="mbn_version">MBN 版本</string> |
3146 | + <string name="show_battery_percentage">显示电池电量百分比</string> | |
3147 | + <string name="show_battery_percentage_summary">在状态栏中显示电池电量百分比</string> | |
3146 | 3148 | </resources> |
@@ -224,6 +224,7 @@ | ||
224 | 224 | <item msgid="6062567900587138000">"SPN"</item> |
225 | 225 | <item msgid="2454085083342423481">"IMSI"</item> |
226 | 226 | <item msgid="2681427309183221543">"GID"</item> |
227 | + <item>"ICCID"</item> | |
227 | 228 | </string-array> |
228 | 229 | <string-array name="app_install_location_entries"> |
229 | 230 | <item msgid="8151497958991952759">"內部裝置儲存空間"</item> |
@@ -224,6 +224,7 @@ | ||
224 | 224 | <item msgid="6062567900587138000">"SPN"</item> |
225 | 225 | <item msgid="2454085083342423481">"IMSI"</item> |
226 | 226 | <item msgid="2681427309183221543">"GID"</item> |
227 | + <item>"ICCID"</item> | |
227 | 228 | </string-array> |
228 | 229 | <string-array name="app_install_location_entries"> |
229 | 230 | <item msgid="8151497958991952759">"內部裝置儲存空間"</item> |
@@ -1100,4 +1100,14 @@ | ||
1100 | 1100 | <item>com.android.orange</item> |
1101 | 1101 | <item>com.android.noos</item> |
1102 | 1102 | </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> | |
1103 | 1113 | </resources> |
@@ -56,6 +56,10 @@ | ||
56 | 56 | <!-- show tethering help begin --> |
57 | 57 | <bool name="tethering_show_help_for_first_using">false</bool> |
58 | 58 | <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 | + | |
59 | 63 | <!-- show tethering help end --> |
60 | 64 | <!-- Config voice over lte in wireless settings begin --> |
61 | 65 | <bool name="config_voice_over_lte_enabled">false</bool> |
@@ -33,4 +33,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | 33 | |
34 | 34 | <!-- Whether to show_kernel version name --> |
35 | 35 | <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> | |
36 | 39 | </resources> |
@@ -7590,4 +7590,6 @@ | ||
7590 | 7590 | <string name="lte_data_service_enabled">LTE data service enabled </string> |
7591 | 7591 | <string name="turn_off_wifi_dialog_title">Turn off Wi-Fi</string> |
7592 | 7592 | <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> | |
7593 | 7595 | </resources> |
@@ -23,6 +23,12 @@ | ||
23 | 23 | android:title="@string/battery_saver" |
24 | 24 | android:fragment="com.android.settings.fuelgauge.BatterySaverSettings" /> |
25 | 25 | |
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 | + | |
26 | 32 | <com.android.settings.fuelgauge.BatteryHistoryPreference |
27 | 33 | android:key="battery_history" /> |
28 | 34 |
@@ -1,4 +1,6 @@ | ||
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | +<!-- Copyright (c) 2016, The Linux Foundation. All rights reserved.--> | |
3 | + | |
2 | 4 | <!-- Copyright (C) 2008 The Android Open Source Project |
3 | 5 | |
4 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -34,17 +36,12 @@ | ||
34 | 36 | settings:keywords="@string/keywords_wifi_calling" |
35 | 37 | android:fragment="com.android.settings.WifiCallingSettings" /> |
36 | 38 | |
37 | - <PreferenceScreen | |
39 | + <com.android.settings.WFCPreference | |
38 | 40 | android:key="wifi_calling_enhanced_settings" |
39 | - android:title="@string/wifi_calling_settings_title" | |
40 | 41 | android:summaryOff="@null" |
41 | 42 | 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" /> | |
48 | 45 | |
49 | 46 | <com.android.settingslib.RestrictedPreference |
50 | 47 | android:fragment="com.android.settings.nfc.AndroidBeam" |
@@ -100,6 +100,7 @@ public class ApnEditor extends SettingsPreferenceFragment | ||
100 | 100 | private Cursor mCursor; |
101 | 101 | private boolean mNewApn; |
102 | 102 | private boolean mFirstTime; |
103 | + private boolean mApnDisable = false; | |
103 | 104 | private int mSubId; |
104 | 105 | private Resources mRes; |
105 | 106 | private TelephonyManager mTelephonyManager; |
@@ -206,10 +207,6 @@ public class ApnEditor extends SettingsPreferenceFragment | ||
206 | 207 | mSubId = intent.getIntExtra(ApnSettings.SUB_ID, |
207 | 208 | SubscriptionManager.INVALID_SUBSCRIPTION_ID); |
208 | 209 | mDisableEditor = intent.getBooleanExtra("DISABLE_EDITOR", false); |
209 | - if (mDisableEditor) { | |
210 | - getPreferenceScreen().setEnabled(false); | |
211 | - Log.d(TAG, "ApnEditor form is disabled."); | |
212 | - } | |
213 | 210 | |
214 | 211 | mFirstTime = icicle == null; |
215 | 212 |
@@ -404,6 +401,24 @@ public class ApnEditor extends SettingsPreferenceFragment | ||
404 | 401 | } else { |
405 | 402 | mCarrierEnabled.setEnabled(false); |
406 | 403 | } |
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 | + } | |
407 | 422 | } |
408 | 423 | |
409 | 424 | /** |
@@ -550,12 +565,12 @@ public class ApnEditor extends SettingsPreferenceFragment | ||
550 | 565 | @Override |
551 | 566 | public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { |
552 | 567 | super.onCreateOptionsMenu(menu, inflater); |
553 | - if (mDisableEditor) { | |
568 | + if (mDisableEditor && !mApnDisable) { | |
554 | 569 | Log.d(TAG, "Form is disabled. Do not create the options menu."); |
555 | 570 | return; |
556 | 571 | } |
557 | 572 | // If it's a new APN, then cancel will delete the new entry in onPause |
558 | - if (!mNewApn) { | |
573 | + if (!mNewApn && !mDisableEditor) { | |
559 | 574 | menu.add(0, MENU_DELETE, 0, R.string.menu_delete) |
560 | 575 | .setIcon(R.drawable.ic_menu_delete); |
561 | 576 | } |
@@ -43,6 +43,7 @@ import android.support.v7.preference.Preference; | ||
43 | 43 | import android.support.v7.preference.PreferenceGroup; |
44 | 44 | import android.support.v7.preference.PreferenceScreen; |
45 | 45 | import android.telephony.CarrierConfigManager; |
46 | +import android.telephony.ServiceState; | |
46 | 47 | import android.telephony.SubscriptionInfo; |
47 | 48 | import android.telephony.SubscriptionManager; |
48 | 49 | import android.telephony.TelephonyManager; |
@@ -64,6 +65,8 @@ import com.android.internal.telephony.uicc.UiccController; | ||
64 | 65 | import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; |
65 | 66 | |
66 | 67 | import java.util.ArrayList; |
68 | +import java.util.HashSet; | |
69 | +import java.util.Iterator; | |
67 | 70 | |
68 | 71 | public class ApnSettings extends RestrictedSettingsFragment implements |
69 | 72 | Preference.OnPreferenceChangeListener { |
@@ -89,6 +92,8 @@ public class ApnSettings extends RestrictedSettingsFragment implements | ||
89 | 92 | private static final int MVNO_TYPE_INDEX = 4; |
90 | 93 | private static final int MVNO_MATCH_DATA_INDEX = 5; |
91 | 94 | private static final int RO_INDEX = 6; |
95 | + private static final int BEARER_INDEX = 7; | |
96 | + private static final int BEARER_BITMASK_INDEX = 8; | |
92 | 97 | |
93 | 98 | private static final int MENU_NEW = Menu.FIRST; |
94 | 99 | private static final int MENU_RESTORE = Menu.FIRST + 1; |
@@ -126,6 +131,8 @@ public class ApnSettings extends RestrictedSettingsFragment implements | ||
126 | 131 | super(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS); |
127 | 132 | } |
128 | 133 | |
134 | + private HashSet mIccidSet; | |
135 | + | |
129 | 136 | private final BroadcastReceiver mMobileStateReceiver = new BroadcastReceiver() { |
130 | 137 | @Override |
131 | 138 | public void onReceive(Context context, Intent intent) { |
@@ -136,8 +143,6 @@ public class ApnSettings extends RestrictedSettingsFragment implements | ||
136 | 143 | case CONNECTED: |
137 | 144 | if (!mRestoreDefaultApnMode) { |
138 | 145 | fillList(); |
139 | - } else { | |
140 | - showDialog(DIALOG_RESTORE_DEFAULTAPN); | |
141 | 146 | } |
142 | 147 | break; |
143 | 148 | } |
@@ -165,6 +170,9 @@ public class ApnSettings extends RestrictedSettingsFragment implements | ||
165 | 170 | final Activity activity = getActivity(); |
166 | 171 | final int subId = activity.getIntent().getIntExtra(SUB_ID, |
167 | 172 | SubscriptionManager.INVALID_SUBSCRIPTION_ID); |
173 | + fillOperatorIccidset(); | |
174 | + Log.d(TAG, "onCreate: subId = " + subId); | |
175 | + | |
168 | 176 | |
169 | 177 | mMobileStateFilter = new IntentFilter( |
170 | 178 | TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED); |
@@ -251,6 +259,23 @@ public class ApnSettings extends RestrictedSettingsFragment implements | ||
251 | 259 | return null; |
252 | 260 | } |
253 | 261 | |
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 | + | |
254 | 279 | private void fillList() { |
255 | 280 | final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); |
256 | 281 | final String mccmnc = mSubscriptionInfo == null ? "" |
@@ -305,11 +330,15 @@ public class ApnSettings extends RestrictedSettingsFragment implements | ||
305 | 330 | where.append(" AND NOT (type='ims')"); |
306 | 331 | } |
307 | 332 | |
333 | + if (isOperatorIccId()) { | |
334 | + where.append(" AND type <>\"" + PhoneConstants.APN_TYPE_EMERGENCY + "\""); | |
335 | + where.append(" AND type <>\"" + PhoneConstants.APN_TYPE_IMS + "\""); | |
336 | + } | |
308 | 337 | Log.d(TAG, "where---" + where); |
309 | 338 | |
310 | 339 | 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); | |
313 | 342 | |
314 | 343 | if (cursor != null) { |
315 | 344 | IccRecords r = null; |
@@ -339,7 +368,22 @@ public class ApnSettings extends RestrictedSettingsFragment implements | ||
339 | 368 | if (!TextUtils.isEmpty(localizedName)) { |
340 | 369 | name = localizedName; |
341 | 370 | } |
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 | + } | |
343 | 387 | ApnPreference pref = new ApnPreference(getPrefContext()); |
344 | 388 | |
345 | 389 | pref.setApnReadOnly(readOnly); |
@@ -379,6 +423,61 @@ public class ApnSettings extends RestrictedSettingsFragment implements | ||
379 | 423 | } |
380 | 424 | } |
381 | 425 | |
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 | + | |
382 | 481 | public static String getLocalizedName(Context context, Cursor cursor, int index) { |
383 | 482 | // If can find a localized name, replace the APN name with it |
384 | 483 | String resName = cursor.getString(index); |
@@ -483,13 +582,13 @@ public class ApnSettings extends RestrictedSettingsFragment implements | ||
483 | 582 | |
484 | 583 | ContentValues values = new ContentValues(); |
485 | 584 | values.put(APN_ID, mSelectedKey); |
486 | - resolver.update(PREFERAPN_URI, values, null, null); | |
585 | + resolver.update(getUri(PREFERAPN_URI), values, null, null); | |
487 | 586 | } |
488 | 587 | |
489 | 588 | private String getSelectedApnKey() { |
490 | 589 | String key = null; |
491 | 590 | |
492 | - Cursor cursor = getContentResolver().query(PREFERAPN_URI, new String[] {"_id"}, | |
591 | + Cursor cursor = getContentResolver().query(getUri(PREFERAPN_URI), new String[] {"_id"}, | |
493 | 592 | null, null, Telephony.Carriers.DEFAULT_SORT_ORDER); |
494 | 593 | if (cursor.getCount() > 0) { |
495 | 594 | cursor.moveToFirst(); |
@@ -560,7 +659,7 @@ public class ApnSettings extends RestrictedSettingsFragment implements | ||
560 | 659 | switch (msg.what) { |
561 | 660 | case EVENT_RESTORE_DEFAULTAPN_START: |
562 | 661 | ContentResolver resolver = getContentResolver(); |
563 | - resolver.delete(DEFAULTAPN_URI, null, null); | |
662 | + resolver.delete(getUri(DEFAULTAPN_URI), null, null); | |
564 | 663 | mRestoreApnUiHandler |
565 | 664 | .sendEmptyMessage(EVENT_RESTORE_DEFAULTAPN_COMPLETE); |
566 | 665 | break; |
@@ -582,4 +681,13 @@ public class ApnSettings extends RestrictedSettingsFragment implements | ||
582 | 681 | } |
583 | 682 | return null; |
584 | 683 | } |
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 | + } | |
585 | 693 | } |
@@ -52,6 +52,8 @@ import java.util.List; | ||
52 | 52 | public class AppListPreference extends CustomListPreference { |
53 | 53 | |
54 | 54 | public static final String ITEM_NONE_VALUE = ""; |
55 | + public static final int TYPE_PACKAGE = 0; | |
56 | + public static final int TYPE_COMPONENT = 1; | |
55 | 57 | |
56 | 58 | protected final boolean mForWork; |
57 | 59 | protected final int mUserId; |
@@ -60,6 +62,7 @@ public class AppListPreference extends CustomListPreference { | ||
60 | 62 | private boolean mShowItemNone = false; |
61 | 63 | private CharSequence[] mSummaries; |
62 | 64 | private int mSystemAppIndex = -1; |
65 | + private int mType = TYPE_PACKAGE; | |
63 | 66 | |
64 | 67 | public class AppArrayAdapter extends ArrayAdapter<CharSequence> { |
65 | 68 | private Drawable[] mImageDrawables = null; |
@@ -189,6 +192,8 @@ public class AppListPreference extends CustomListPreference { | ||
189 | 192 | public void setComponentNames(ComponentName[] componentNames, ComponentName defaultCN, |
190 | 193 | CharSequence[] summaries) { |
191 | 194 | mSummaries = summaries; |
195 | + mType = TYPE_COMPONENT; | |
196 | + | |
192 | 197 | // Look up all package names in PackageManager. Skip ones we can't find. |
193 | 198 | PackageManager pm = getContext().getPackageManager(); |
194 | 199 | final int entryCount = componentNames.length + (mShowItemNone ? 1 : 0); |
@@ -257,7 +262,18 @@ public class AppListPreference extends CustomListPreference { | ||
257 | 262 | if (state instanceof SavedState) { |
258 | 263 | SavedState savedState = (SavedState) state; |
259 | 264 | 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 | + } | |
261 | 277 | mSummaries = savedState.summaries; |
262 | 278 | super.onRestoreInstanceState(savedState.superState); |
263 | 279 | } else { |
@@ -100,6 +100,8 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity { | ||
100 | 100 | |
101 | 101 | private AppearAnimationUtils mAppearAnimationUtils; |
102 | 102 | private DisappearAnimationUtils mDisappearAnimationUtils; |
103 | + private boolean mIsScale = false; | |
104 | + private final float mScale = 0.65f; | |
103 | 105 | |
104 | 106 | // required constructor for fragments |
105 | 107 | public ConfirmLockPatternFragment() { |
@@ -122,6 +124,8 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity { | ||
122 | 124 | mLeftSpacerLandscape = view.findViewById(R.id.leftSpacer); |
123 | 125 | mRightSpacerLandscape = view.findViewById(R.id.rightSpacer); |
124 | 126 | |
127 | + resizePattern(); | |
128 | + | |
125 | 129 | // make it so unhandled touch events within the unlock screen go to the |
126 | 130 | // lock pattern view. |
127 | 131 | final LinearLayoutWithDefaultTouchRecepient topLayout |
@@ -215,6 +219,27 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity { | ||
215 | 219 | mCredentialCheckResultTracker.setListener(this); |
216 | 220 | } |
217 | 221 | |
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 | + | |
218 | 243 | @Override |
219 | 244 | protected void onShowError() { |
220 | 245 | } |
@@ -150,6 +150,10 @@ public class TetherSettings extends RestrictedSettingsFragment | ||
150 | 150 | private DataSaverBackend mDataSaverBackend; |
151 | 151 | private boolean mDataSaverEnabled; |
152 | 152 | 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; | |
153 | 157 | |
154 | 158 | @Override |
155 | 159 | protected int getMetricsCategory() { |
@@ -268,6 +272,9 @@ public class TetherSettings extends RestrictedSettingsFragment | ||
268 | 272 | } |
269 | 273 | // Set initial state based on Data Saver mode. |
270 | 274 | onDataSaverChanged(mDataSaverBackend.isDataSaverEnabled()); |
275 | + mUsbEnable = getResources().getBoolean(R.bool.config_usb_line_enable); | |
276 | + mWifiStatusManager= (WifiManager) getActivity().getSystemService( | |
277 | + Context.WIFI_SERVICE); | |
271 | 278 | } |
272 | 279 | |
273 | 280 | @Override |
@@ -364,6 +371,12 @@ public class TetherSettings extends RestrictedSettingsFragment | ||
364 | 371 | updateState(); |
365 | 372 | } else if (action.equals(UsbManager.ACTION_USB_STATE)) { |
366 | 373 | 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 | + } | |
367 | 380 | updateState(); |
368 | 381 | } else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { |
369 | 382 | if (mBluetoothEnableForTether) { |
@@ -687,16 +700,29 @@ public class TetherSettings extends RestrictedSettingsFragment | ||
687 | 700 | } |
688 | 701 | } |
689 | 702 | |
703 | + if (choice == TETHERING_USB) { | |
704 | + if(mUsbTether.isChecked()) { | |
705 | + mWifiManager.setWifiEnabled(false); | |
706 | + } | |
707 | + } | |
690 | 708 | mCm.startTethering(choice, true, mStartTetheringCallback, mHandler); |
691 | 709 | } |
692 | 710 | |
693 | 711 | @Override |
694 | 712 | public boolean onPreferenceTreeClick(Preference preference) { |
695 | 713 | 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); | |
697 | 720 | startTethering(TETHERING_USB); |
698 | 721 | } else { |
699 | 722 | mCm.stopTethering(TETHERING_USB); |
723 | + if (mIsWifiEnabled) { | |
724 | + mWifiManager.setWifiEnabled(true); | |
725 | + } | |
700 | 726 | } |
701 | 727 | } else if (preference == mBluetoothTether) { |
702 | 728 | if (mBluetoothTether.isChecked()) { |
@@ -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 | +} |
@@ -29,6 +29,8 @@ import android.support.v7.preference.Preference; | ||
29 | 29 | import android.support.v7.preference.PreferenceScreen; |
30 | 30 | import android.telephony.CarrierConfigManager; |
31 | 31 | import android.telephony.PhoneStateListener; |
32 | +import android.telephony.SubscriptionInfo; | |
33 | +import android.telephony.SubscriptionManager; | |
32 | 34 | import android.telephony.TelephonyManager; |
33 | 35 | import android.util.Log; |
34 | 36 | import android.widget.Switch; |
@@ -60,35 +62,50 @@ public class WifiCallingSettings extends SettingsPreferenceFragment | ||
60 | 62 | private ListPreference mButtonWfcMode; |
61 | 63 | private TextView mEmptyView; |
62 | 64 | |
65 | + private int[] mCallState = null; | |
66 | + private PhoneStateListener[] mPhoneStateListener = null; | |
67 | + private int mPhoneCount; | |
63 | 68 | private boolean mValidListener = false; |
64 | 69 | private boolean mEditableWfcMode = true; |
65 | 70 | |
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; | |
67 | 83 | /* |
68 | 84 | * Enable/disable controls when in/out of a call and depending on |
69 | 85 | * TTY mode and TTY support over VoLTE. |
70 | 86 | * @see android.telephony.PhoneStateListener#onCallStateChanged(int, |
71 | 87 | * java.lang.String) |
72 | 88 | */ |
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 | + } | |
89 | 106 | } |
90 | - } | |
91 | - }; | |
107 | + }; | |
108 | + } | |
92 | 109 | |
93 | 110 | @Override |
94 | 111 | public void onActivityCreated(Bundle savedInstanceState) { |
@@ -182,6 +199,10 @@ public class WifiCallingSettings extends SettingsPreferenceFragment | ||
182 | 199 | mButtonWfcMode.setEntries(R.array.wifi_calling_mode_choices_without_wifi_only); |
183 | 200 | mButtonWfcMode.setEntryValues(R.array.wifi_calling_mode_values_without_wifi_only); |
184 | 201 | } |
202 | + | |
203 | + mPhoneCount = TelephonyManager.getDefault().getPhoneCount(); | |
204 | + mPhoneStateListener = new PhoneStateListener[mPhoneCount]; | |
205 | + mCallState = new int[mPhoneCount]; | |
185 | 206 | } |
186 | 207 | |
187 | 208 | @Override |
@@ -191,8 +212,7 @@ public class WifiCallingSettings extends SettingsPreferenceFragment | ||
191 | 212 | final Context context = getActivity(); |
192 | 213 | |
193 | 214 | if (ImsManager.isWfcEnabledByPlatform(context)) { |
194 | - TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); | |
195 | - tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE); | |
215 | + registerPhoneStateListeners(context); | |
196 | 216 | |
197 | 217 | mSwitchBar.addOnSwitchChangeListener(this); |
198 | 218 |
@@ -224,8 +244,7 @@ public class WifiCallingSettings extends SettingsPreferenceFragment | ||
224 | 244 | if (mValidListener) { |
225 | 245 | mValidListener = false; |
226 | 246 | |
227 | - TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); | |
228 | - tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); | |
247 | + unRegisterPhoneStateListeners(context); | |
229 | 248 | |
230 | 249 | mSwitchBar.removeOnSwitchChangeListener(this); |
231 | 250 | } |
@@ -233,6 +252,30 @@ public class WifiCallingSettings extends SettingsPreferenceFragment | ||
233 | 252 | context.unregisterReceiver(mIntentReceiver); |
234 | 253 | } |
235 | 254 | |
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 | + | |
236 | 279 | /** |
237 | 280 | * Listens to the state change of the switch. |
238 | 281 | */ |
@@ -299,4 +342,15 @@ public class WifiCallingSettings extends SettingsPreferenceFragment | ||
299 | 342 | } |
300 | 343 | return resId; |
301 | 344 | } |
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 | + } | |
302 | 356 | } |
@@ -1,3 +1,5 @@ | ||
1 | +/* Copyright (c) 2016, The Linux Foundation. All rights reserved.*/ | |
2 | + | |
1 | 3 | /* |
2 | 4 | * Copyright (C) 2009 The Android Open Source Project |
3 | 5 | * |
@@ -84,6 +86,10 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde | ||
84 | 86 | private static final String KEY_WFC_SETTINGS = "wifi_calling_settings"; |
85 | 87 | private static final String KEY_WFC_ENHANCED_SETTINGS = "wifi_calling_enhanced_settings"; |
86 | 88 | |
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 | + | |
87 | 93 | public static final String EXIT_ECM_RESULT = "exit_ecm_result"; |
88 | 94 | public static final int REQUEST_CODE_EXIT_ECM = 1; |
89 | 95 |
@@ -102,10 +108,11 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde | ||
102 | 108 | private static final int MANAGE_MOBILE_PLAN_DIALOG_ID = 1; |
103 | 109 | private static final String SAVED_MANAGE_MOBILE_PLAN_MSG = "mManageMobilePlanMessage"; |
104 | 110 | |
105 | - private PreferenceScreen mButtonWfc; | |
111 | + private Preference mButtonWfc; | |
106 | 112 | private boolean mEnhancedWFCSettingsEnabled = false; |
107 | 113 | |
108 | 114 | private IWFCService mWFCService; |
115 | + | |
109 | 116 | private ServiceConnection mConnection = new ServiceConnection() { |
110 | 117 | |
111 | 118 | public void onServiceConnected(ComponentName className, IBinder service) { |
@@ -124,15 +131,25 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde | ||
124 | 131 | }; |
125 | 132 | |
126 | 133 | 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)) { | |
129 | 136 | if(DEBUG) Log.e(TAG, "updateWFCMessage fail."); |
130 | 137 | return ; |
131 | 138 | } |
132 | 139 | getActivity().runOnUiThread(new Runnable() { |
133 | 140 | 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 | + } | |
136 | 153 | } |
137 | 154 | }); |
138 | 155 |
@@ -303,6 +320,14 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde | ||
303 | 320 | return MetricsEvent.WIRELESS; |
304 | 321 | } |
305 | 322 | |
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 | + | |
306 | 331 | @Override |
307 | 332 | public void onCreate(Bundle savedInstanceState) { |
308 | 333 | super.onCreate(savedInstanceState); |
@@ -332,21 +357,52 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde | ||
332 | 357 | mEnhancedWFCSettingsEnabled = getActivity().getResources().getBoolean( |
333 | 358 | R.bool.wifi_call_enhanced_setting); |
334 | 359 | if (mEnhancedWFCSettingsEnabled) { |
335 | - mButtonWfc = (PreferenceScreen) findPreference(KEY_WFC_ENHANCED_SETTINGS); | |
360 | + mButtonWfc = (WFCPreference) findPreference(KEY_WFC_ENHANCED_SETTINGS); | |
336 | 361 | 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 | + }); | |
337 | 401 | } else { |
338 | 402 | mButtonWfc = (PreferenceScreen) findPreference(KEY_WFC_SETTINGS); |
339 | 403 | removePreference(KEY_WFC_ENHANCED_SETTINGS); |
340 | 404 | } |
341 | 405 | |
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 | - | |
350 | 406 | String toggleable = Settings.Global.getString(activity.getContentResolver(), |
351 | 407 | Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS); |
352 | 408 |
@@ -475,6 +531,14 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde | ||
475 | 531 | public void onResume() { |
476 | 532 | super.onResume(); |
477 | 533 | |
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 | + | |
478 | 542 | mAirplaneModeEnabler.resume(); |
479 | 543 | if (mNfcEnabler != null) { |
480 | 544 | mNfcEnabler.resume(); |
@@ -486,12 +550,15 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde | ||
486 | 550 | getPreferenceScreen().addPreference(mButtonWfc); |
487 | 551 | if (!mEnhancedWFCSettingsEnabled) { |
488 | 552 | mButtonWfc.setSummary(WifiCallingSettings.getWfcModeSummary( |
489 | - context, ImsManager.getWfcMode(context))); | |
553 | + context, ImsManager.getWfcMode(context))); | |
490 | 554 | } else { |
491 | 555 | if (!ImsManager.isWfcEnabledByUser(context)) { |
492 | - mButtonWfc.setSummary(R.string.disabled); | |
556 | + ((WFCPreference) mButtonWfc).setChecked(false); | |
557 | + ((WFCPreference) mButtonWfc).setSummary(R.string.disabled); | |
493 | 558 | } 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")); | |
495 | 562 | } |
496 | 563 | } |
497 | 564 | } else { |
@@ -66,6 +66,7 @@ public final class DeviceProfilesSettings extends DialogFragment implements | ||
66 | 66 | private ViewGroup mProfileContainer; |
67 | 67 | private TextView mProfileLabel; |
68 | 68 | private EditTextPreference mDeviceNamePref; |
69 | + private static final int OK_BUTTON = -1; | |
69 | 70 | |
70 | 71 | private final HashMap<LocalBluetoothProfile, CheckBoxPreference> mAutoConnectPrefs |
71 | 72 | = new HashMap<LocalBluetoothProfile, CheckBoxPreference>(); |
@@ -173,11 +174,16 @@ public final class DeviceProfilesSettings extends DialogFragment implements | ||
173 | 174 | private void addPreferencesForProfiles() { |
174 | 175 | mProfileContainer.removeAllViews(); |
175 | 176 | 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 | + } | |
178 | 183 | } |
179 | 184 | |
180 | 185 | final int pbapPermission = mCachedDevice.getPhonebookPermissionChoice(); |
186 | + Log.d(TAG, "addPreferencesForProfiles: pbapPermission = " + pbapPermission); | |
181 | 187 | // Only provide PBAP cabability if the client device has requested PBAP. |
182 | 188 | if (pbapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN) { |
183 | 189 | final PbapServerProfile psp = mManager.getProfileManager().getPbapProfile(); |
@@ -187,6 +193,7 @@ public final class DeviceProfilesSettings extends DialogFragment implements | ||
187 | 193 | |
188 | 194 | final MapProfile mapProfile = mManager.getProfileManager().getMapProfile(); |
189 | 195 | final int mapPermission = mCachedDevice.getMessagePermissionChoice(); |
196 | + Log.d(TAG, "addPreferencesForProfiles: mapPermission = " + mapPermission); | |
190 | 197 | if (mapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN) { |
191 | 198 | CheckBox mapPreference = createProfilePreference(mapProfile); |
192 | 199 | mProfileContainer.addView(mapPreference); |
@@ -241,15 +248,6 @@ public final class DeviceProfilesSettings extends DialogFragment implements | ||
241 | 248 | private void onProfileClicked(LocalBluetoothProfile profile, CheckBox profilePref) { |
242 | 249 | BluetoothDevice device = mCachedDevice.getDevice(); |
243 | 250 | |
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 | - | |
253 | 251 | if (!profilePref.isChecked()) { |
254 | 252 | // Recheck it, until the dialog is done. |
255 | 253 | profilePref.setChecked(true); |
@@ -258,6 +256,11 @@ public final class DeviceProfilesSettings extends DialogFragment implements | ||
258 | 256 | if (profile instanceof MapProfile) { |
259 | 257 | mCachedDevice.setMessagePermissionChoice(BluetoothDevice.ACCESS_ALLOWED); |
260 | 258 | } |
259 | + if (profile instanceof PbapServerProfile) { | |
260 | + mCachedDevice.setPhonebookPermissionChoice(BluetoothDevice.ACCESS_ALLOWED); | |
261 | + refreshProfilePreference(profilePref, profile); | |
262 | + return; | |
263 | + } | |
261 | 264 | if (profile.isPreferred(device)) { |
262 | 265 | // profile is preferred but not connected: disable auto-connect |
263 | 266 | if (profile instanceof PanProfile) { |
@@ -291,10 +294,18 @@ public final class DeviceProfilesSettings extends DialogFragment implements | ||
291 | 294 | DialogInterface.OnClickListener disconnectListener = |
292 | 295 | new DialogInterface.OnClickListener() { |
293 | 296 | 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 | + | |
298 | 309 | } |
299 | 310 | refreshProfilePreference(findProfile(profile.toString()), profile); |
300 | 311 | } |
@@ -331,6 +342,19 @@ public final class DeviceProfilesSettings extends DialogFragment implements | ||
331 | 342 | for (LocalBluetoothProfile profile : mCachedDevice.getRemovedProfiles()) { |
332 | 343 | CheckBox profilePref = findProfile(profile.toString()); |
333 | 344 | 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 | + } | |
334 | 358 | Log.d(TAG, "Removing " + profile.toString() + " from profile list"); |
335 | 359 | mProfileContainer.removeView(profilePref); |
336 | 360 | } |
@@ -51,7 +51,6 @@ import com.android.settingslib.net.ChartDataLoader; | ||
51 | 51 | import com.android.settingslib.net.UidDetailProvider; |
52 | 52 | |
53 | 53 | import static android.net.NetworkPolicyManager.POLICY_REJECT_METERED_BACKGROUND; |
54 | -import static android.net.TrafficStats.UID_TETHERING; | |
55 | 54 | |
56 | 55 | public class AppDataUsage extends DataUsageBase implements Preference.OnPreferenceChangeListener, |
57 | 56 | DataSaverBackend.Listener { |
@@ -202,20 +201,6 @@ public class AppDataUsage extends DataUsageBase implements Preference.OnPreferen | ||
202 | 201 | mLabel = Utils.getUserLabel(getActivity(), info); |
203 | 202 | mPackageName = getActivity().getPackageName(); |
204 | 203 | } |
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(); | |
219 | 204 | removePreference(KEY_UNRESTRICTED_DATA); |
220 | 205 | removePreference(KEY_APP_SETTINGS); |
221 | 206 | removePreference(KEY_RESTRICT_BACKGROUND); |
@@ -27,6 +27,7 @@ import android.content.pm.PackageManager.NameNotFoundException; | ||
27 | 27 | import android.content.res.Resources; |
28 | 28 | import android.os.Bundle; |
29 | 29 | import android.os.PersistableBundle; |
30 | +import android.os.SystemProperties; | |
30 | 31 | import android.os.UserHandle; |
31 | 32 | import android.os.UserManager; |
32 | 33 | import android.support.v7.preference.Preference; |
@@ -287,9 +288,9 @@ public class SimStatus extends SettingsPreferenceFragment { | ||
287 | 288 | networktype = "4G"; |
288 | 289 | } |
289 | 290 | |
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) { | |
293 | 294 | if (TelephonyManager.NETWORK_TYPE_LTE == actualDataNetworkType || |
294 | 295 | TelephonyManager.NETWORK_TYPE_LTE == actualVoiceNetworkType) { |
295 | 296 | if (mTelephonyManager.isImsRegistered()) { |
@@ -28,6 +28,8 @@ import android.os.Process; | ||
28 | 28 | import android.os.UserHandle; |
29 | 29 | import android.support.v7.preference.Preference; |
30 | 30 | import android.support.v7.preference.PreferenceGroup; |
31 | +import android.support.v14.preference.SwitchPreference; | |
32 | +import android.provider.Settings; | |
31 | 33 | import android.text.TextUtils; |
32 | 34 | import android.util.SparseArray; |
33 | 35 | import android.util.TypedValue; |
@@ -56,6 +58,7 @@ import java.util.List; | ||
56 | 58 | */ |
57 | 59 | public class PowerUsageSummary extends PowerUsageBase { |
58 | 60 | |
61 | + public static final String SHOW_PERCENT_SETTING = "status_bar_show_battery_percent"; | |
59 | 62 | private static final boolean DEBUG = false; |
60 | 63 | |
61 | 64 | private static final boolean USE_FAKE_DATA = false; |
@@ -64,6 +67,7 @@ public class PowerUsageSummary extends PowerUsageBase { | ||
64 | 67 | |
65 | 68 | private static final String KEY_APP_LIST = "app_list"; |
66 | 69 | private static final String KEY_BATTERY_HISTORY = "battery_history"; |
70 | + private static final String KEY_BATTERY_PCT = "battery_pct"; | |
67 | 71 | |
68 | 72 | private static final int MENU_STATS_TYPE = Menu.FIRST; |
69 | 73 | private static final int MENU_HIGH_POWER_APPS = Menu.FIRST + 3; |
@@ -71,8 +75,10 @@ public class PowerUsageSummary extends PowerUsageBase { | ||
71 | 75 | |
72 | 76 | private BatteryHistoryPreference mHistPref; |
73 | 77 | private PreferenceGroup mAppListGroup; |
78 | + private SwitchPreference mBatteryPct; | |
74 | 79 | |
75 | 80 | private int mStatsType = BatteryStats.STATS_SINCE_CHARGED; |
81 | + private boolean isShowBatteryPct; | |
76 | 82 | |
77 | 83 | private static final int MIN_POWER_THRESHOLD_MILLI_AMP = 5; |
78 | 84 | private static final int MAX_ITEMS_TO_LIST = USE_FAKE_DATA ? 30 : 10; |
@@ -87,6 +93,11 @@ public class PowerUsageSummary extends PowerUsageBase { | ||
87 | 93 | addPreferencesFromResource(R.xml.power_usage_summary); |
88 | 94 | mHistPref = (BatteryHistoryPreference) findPreference(KEY_BATTERY_HISTORY); |
89 | 95 | 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 | + } | |
90 | 101 | } |
91 | 102 | |
92 | 103 | @Override |
@@ -97,6 +108,9 @@ public class PowerUsageSummary extends PowerUsageBase { | ||
97 | 108 | @Override |
98 | 109 | public void onResume() { |
99 | 110 | super.onResume(); |
111 | + if (isShowBatteryPct) { | |
112 | + updateBatteryPct(); | |
113 | + } | |
100 | 114 | refreshStats(); |
101 | 115 | } |
102 | 116 |
@@ -479,4 +493,24 @@ public class PowerUsageSummary extends PowerUsageBase { | ||
479 | 493 | return new SummaryProvider(activity, summaryLoader); |
480 | 494 | } |
481 | 495 | }; |
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 | + }; | |
482 | 516 | } |
@@ -44,6 +44,7 @@ import android.support.v7.preference.Preference; | ||
44 | 44 | import android.support.v7.preference.Preference.OnPreferenceClickListener; |
45 | 45 | import android.support.v7.preference.PreferenceGroup; |
46 | 46 | import android.support.v7.preference.PreferenceScreen; |
47 | +import android.provider.Settings.Global; | |
47 | 48 | import android.util.Log; |
48 | 49 | import android.util.SparseArray; |
49 | 50 | import android.view.Menu; |
@@ -241,6 +242,11 @@ public class UserSettings extends SettingsPreferenceFragment | ||
241 | 242 | loadProfile(); |
242 | 243 | updateUserList(); |
243 | 244 | mShouldUpdateUserList = false; |
245 | + | |
246 | + if (Global.getInt(getContext().getContentResolver(), Global.DEVICE_PROVISIONED, 0) == 0) { | |
247 | + getActivity().finish(); | |
248 | + return; | |
249 | + } | |
244 | 250 | } |
245 | 251 | |
246 | 252 | @Override |
@@ -35,5 +35,8 @@ import org.codeaurora.wfcservice.IWFCServiceCB; | ||
35 | 35 | interface IWFCService { |
36 | 36 | void registerCallback(IWFCServiceCB cb); |
37 | 37 | void unregisterCallback(IWFCServiceCB cb); |
38 | + void setWifiCalling(boolean state, int preference); | |
39 | + boolean getWifiCallingStatus(); | |
40 | + int getWifiCallingPreference(); | |
38 | 41 | } |
39 | 42 |