packages/apps/Settings
Revisão | e7a578e95ca12834659bda07a0109c4de132b6ec (tree) |
---|---|
Hora | 2016-09-29 21:37:59 |
Autor | Steve Kondik <steve@cyng...> |
Commiter | Steve Kondik |
Merge branch 'android_ui.lnx.2.1.r5-rel' of git://codeaurora.org/platform/packages/apps/Settings into cm-14.0
Change-Id: I26bb722ee150b0f5e9e20df736acb4f4cc794efd
@@ -492,7 +492,6 @@ | ||
492 | 492 | <action android:name="android.intent.action.MAIN" /> |
493 | 493 | <category android:name="android.intent.category.DEFAULT" /> |
494 | 494 | <category android:name="android.intent.category.VOICE_LAUNCH" /> |
495 | - <category android:name="com.android.settings.SHORTCUT" /> | |
496 | 495 | </intent-filter> |
497 | 496 | <intent-filter android:priority="1"> |
498 | 497 | <action android:name="com.android.settings.action.SETTINGS" /> |
@@ -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> |
@@ -1061,5 +1061,25 @@ | ||
1061 | 1061 | <item>com.qualcomm.qti.RIDL</item> |
1062 | 1062 | <item>com.android.localphone</item> |
1063 | 1063 | <item>com.android.sim</item> |
1064 | + <item>com.android.alice</item> | |
1065 | + <item>com.android.yahoo</item> | |
1066 | + <item>com.android.outlook</item> | |
1067 | + <item>com.android.gmail</item> | |
1068 | + <item>com.android.aol</item> | |
1069 | + <item>com.android.free</item> | |
1070 | + <item>com.android.laposte</item> | |
1071 | + <item>com.android.sfr</item> | |
1072 | + <item>com.android.orange</item> | |
1073 | + <item>com.android.noos</item> | |
1074 | + </string-array> | |
1075 | + | |
1076 | + <string-array name="plmn_list_for_apn_disable"> | |
1077 | + <item>20404</item> | |
1078 | + <item>45403</item> | |
1079 | + <item>45404</item> | |
1080 | + <item>45502</item> | |
1081 | + <item>45507</item> | |
1082 | + <item>46003</item> | |
1083 | + <item>46011</item> | |
1064 | 1084 | </string-array> |
1065 | 1085 | </resources> |
@@ -39,6 +39,9 @@ | ||
39 | 39 | <!-- Whether to show a preference item for mobile plan --> |
40 | 40 | <bool name="config_show_mobile_plan">true</bool> |
41 | 41 | |
42 | + <!-- Whether to add AGPS parameter settings --> | |
43 | + <bool name="config_agps_enabled">false</bool> | |
44 | + | |
42 | 45 | <!-- Whether none security option is hide or not (country specific). --> |
43 | 46 | <bool name="config_hide_none_security_option">false</bool> |
44 | 47 |
@@ -98,4 +101,6 @@ | ||
98 | 101 | <bool name="config_hidesupl_enable">false</bool> |
99 | 102 | <!-- Whether to hide mms apn--> |
100 | 103 | <bool name="config_hide_mms_enable">false</bool> |
104 | + <!-- show pop up notification for turn off wifi begin --> | |
105 | + <bool name="hotspot_show_turn_off_wifi_dialog">false</bool> | |
101 | 106 | </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> |
@@ -2286,6 +2286,8 @@ | ||
2286 | 2286 | <!-- About phone screen, setting option name [CHAR LIMIT=40] --> |
2287 | 2287 | <string name="build_number">Build number</string> |
2288 | 2288 | <!-- About phone screen, setting option name [CHAR LIMIT=40] --> |
2289 | + <string name="qgp_version">QGP Version</string> | |
2290 | + <!-- About phone screen, setting option name [CHAR LIMIT=40] --> | |
2289 | 2291 | <string name="selinux_status">SELinux status</string> |
2290 | 2292 | |
2291 | 2293 | <!-- About phone screen, show when a value of some status item is unavailable. --> |
@@ -7588,4 +7590,11 @@ | ||
7588 | 7590 | <string name="protected_apps">Protected apps</string> |
7589 | 7591 | <string name="saving_protected_components">Saving component state</string> |
7590 | 7592 | |
7593 | + <string name="lte_data_and_voice_calling_enabled">LTE data and Voice Calling (IMS/VoLTE) service enabled </string> | |
7594 | + <string name="lte_data_service_enabled">LTE data service enabled </string> | |
7595 | + <string name="turn_off_wifi_dialog_title">Turn off Wi-Fi</string> | |
7596 | + <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> | |
7597 | + <string name="show_battery_percentage">Show battery percentage</string> | |
7598 | + <string name="show_battery_percentage_summary">Show battery level percentage inside the status bar</string> | |
7599 | + | |
7591 | 7600 | </resources> |
@@ -158,6 +158,12 @@ | ||
158 | 158 | android:title="@string/build_number" |
159 | 159 | android:summary="@string/device_info_default"/> |
160 | 160 | |
161 | + <!-- Device QGP version --> | |
162 | + <Preference android:key="qgp_version" | |
163 | + style="?android:preferenceInformationStyle" | |
164 | + android:title="@string/qgp_version" | |
165 | + android:summary="@string/device_info_default"/> | |
166 | + | |
161 | 167 | <!-- SELinux status information --> |
162 | 168 | <Preference android:key="selinux_status" |
163 | 169 | android:enabled="false" |
@@ -38,6 +38,12 @@ | ||
38 | 38 | android:key="location_services" |
39 | 39 | android:title="@string/location_category_location_services" /> |
40 | 40 | |
41 | + <CheckBoxPreference | |
42 | + android:key="assisted_gps" | |
43 | + android:title="@string/assisted_gps" | |
44 | + android:summaryOn="@string/assisted_gps_enabled" | |
45 | + android:summaryOff="@string/assisted_gps_disabled"/> | |
46 | + | |
41 | 47 | <com.android.settings.DividedCategory |
42 | 48 | android:key="recent_location_requests" |
43 | 49 | android:title="@string/location_category_recent_location_requests" /> |
@@ -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 | } |
@@ -76,6 +76,8 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In | ||
76 | 76 | private static final String KEY_MOD_VERSION = "mod_version"; |
77 | 77 | private static final String KEY_MOD_BUILD_DATE = "build_date"; |
78 | 78 | private static final String KEY_MOD_API_LEVEL = "mod_api_level"; |
79 | + private static final String KEY_QGP_VERSION = "qgp_version"; | |
80 | + private static final String PROPERTY_QGP_VERSION = "persist.qgp.version"; | |
79 | 81 | |
80 | 82 | static final int TAPS_TO_BE_A_DEVELOPER = 7; |
81 | 83 |
@@ -123,6 +125,10 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In | ||
123 | 125 | setStringSummary(KEY_DEVICE_MODEL, Build.MODEL); |
124 | 126 | setStringSummary(KEY_BUILD_NUMBER, Build.DISPLAY); |
125 | 127 | findPreference(KEY_BUILD_NUMBER).setEnabled(true); |
128 | + setValueSummary(KEY_QGP_VERSION, PROPERTY_QGP_VERSION); | |
129 | + // Remove QGP Version if property is not present | |
130 | + removePreferenceIfPropertyMissing(getPreferenceScreen(), KEY_QGP_VERSION, | |
131 | + PROPERTY_QGP_VERSION); | |
126 | 132 | findPreference(KEY_KERNEL_VERSION).setSummary(DeviceInfoUtils.customizeFormatKernelVersion( |
127 | 133 | getResources().getBoolean(R.bool.def_hide_kernel_version_name))); |
128 | 134 | setValueSummary(KEY_MBN_VERSION, PROPERTY_MBN_VERSION); |
@@ -32,6 +32,7 @@ import android.content.SharedPreferences; | ||
32 | 32 | import android.content.SharedPreferences.Editor; |
33 | 33 | import android.hardware.usb.UsbManager; |
34 | 34 | import android.net.ConnectivityManager; |
35 | +import android.net.NetworkInfo; | |
35 | 36 | import android.net.wifi.WifiConfiguration; |
36 | 37 | import android.net.wifi.WifiManager; |
37 | 38 | import android.net.wifi.WifiConfiguration.AuthAlgorithm; |
@@ -64,6 +65,10 @@ import static android.net.ConnectivityManager.TETHERING_BLUETOOTH; | ||
64 | 65 | import static android.net.ConnectivityManager.TETHERING_USB; |
65 | 66 | import static android.net.ConnectivityManager.TETHERING_WIFI; |
66 | 67 | |
68 | +import android.view.LayoutInflater; | |
69 | +import android.view.View; | |
70 | +import android.widget.CheckBox; | |
71 | + | |
67 | 72 | /* |
68 | 73 | * Displays preferences for Tethering. |
69 | 74 | */ |
@@ -83,6 +88,7 @@ public class TetherSettings extends RestrictedSettingsFragment | ||
83 | 88 | private static final String SHAREPREFERENCE_DEFAULT_WIFI = "def_wifiap_set"; |
84 | 89 | private static final String SHAREPREFERENCE_FIFE_NAME = "MY_PERFS"; |
85 | 90 | private static final String KEY_FIRST_LAUNCH_HOTSPOT = "FirstLaunchHotspotTethering"; |
91 | + private static final String KEY_TURN_OFF_WIFI_SHOW_AGAIN = "TurnOffWifiShowAgain"; | |
86 | 92 | private static final String ACTION_HOTSPOT_PRE_CONFIGURE = "Hotspot_PreConfigure"; |
87 | 93 | private static final String ACTION_HOTSPOT_POST_CONFIGURE = "Hotspot_PostConfigure"; |
88 | 94 | private static final String CONFIGURE_RESULT = "PreConfigure_result"; |
@@ -144,6 +150,10 @@ public class TetherSettings extends RestrictedSettingsFragment | ||
144 | 150 | private DataSaverBackend mDataSaverBackend; |
145 | 151 | private boolean mDataSaverEnabled; |
146 | 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; | |
147 | 157 | |
148 | 158 | @Override |
149 | 159 | protected int getMetricsCategory() { |
@@ -262,6 +272,9 @@ public class TetherSettings extends RestrictedSettingsFragment | ||
262 | 272 | } |
263 | 273 | // Set initial state based on Data Saver mode. |
264 | 274 | onDataSaverChanged(mDataSaverBackend.isDataSaverEnabled()); |
275 | + mUsbEnable = getResources().getBoolean(R.bool.config_usb_line_enable); | |
276 | + mWifiStatusManager= (WifiManager) getActivity().getSystemService( | |
277 | + Context.WIFI_SERVICE); | |
265 | 278 | } |
266 | 279 | |
267 | 280 | @Override |
@@ -358,6 +371,12 @@ public class TetherSettings extends RestrictedSettingsFragment | ||
358 | 371 | updateState(); |
359 | 372 | } else if (action.equals(UsbManager.ACTION_USB_STATE)) { |
360 | 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 | + } | |
361 | 380 | updateState(); |
362 | 381 | } else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { |
363 | 382 | if (mBluetoothEnableForTether) { |
@@ -601,6 +620,9 @@ public class TetherSettings extends RestrictedSettingsFragment | ||
601 | 620 | getPrefContext().startActivity(intent); |
602 | 621 | ((HotspotPreference)preference).setChecked(false); |
603 | 622 | return false; |
623 | + } else if(checkWifiConnectivityState(getActivity())) { | |
624 | + showTurnOffWifiDialog(getActivity()); | |
625 | + startTethering(TETHERING_WIFI); | |
604 | 626 | } else { |
605 | 627 | startTethering(TETHERING_WIFI); |
606 | 628 | } |
@@ -610,6 +632,45 @@ public class TetherSettings extends RestrictedSettingsFragment | ||
610 | 632 | return false; |
611 | 633 | } |
612 | 634 | |
635 | + private boolean checkWifiConnectivityState(Context ctx) { | |
636 | + if(mCm == null) { | |
637 | + ConnectivityManager mCm = (ConnectivityManager) ctx. | |
638 | + getSystemService(Context.CONNECTIVITY_SERVICE); | |
639 | + } | |
640 | + NetworkInfo info = mCm == null ? null : mCm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); | |
641 | + return (info != null && info.isConnected()); | |
642 | + } | |
643 | + | |
644 | + private void showTurnOffWifiDialog(final Context ctx) { | |
645 | + LayoutInflater inflater = (LayoutInflater)ctx.getSystemService( | |
646 | + Context.LAYOUT_INFLATER_SERVICE); | |
647 | + View showAgainView = inflater.inflate(R.layout.not_show_again, null); | |
648 | + CheckBox notShowAgainCheckbox = (CheckBox)showAgainView.findViewById(R.id.check); | |
649 | + final SharedPreferences sharedpreferences = ctx.getSharedPreferences( | |
650 | + SHAREPREFERENCE_FIFE_NAME, Context.MODE_PRIVATE); | |
651 | + boolean showAgain = sharedpreferences.getBoolean(KEY_TURN_OFF_WIFI_SHOW_AGAIN, true); | |
652 | + if (!showAgain) { | |
653 | + return; | |
654 | + } else { | |
655 | + AlertDialog.Builder alert = new AlertDialog.Builder(ctx) | |
656 | + .setTitle(ctx.getResources().getString(R.string.turn_off_wifi_dialog_title)) | |
657 | + .setMessage(ctx.getResources().getString(R.string.turn_off_wifi_dialog_text)) | |
658 | + .setView(showAgainView) | |
659 | + .setPositiveButton(ctx.getResources(). | |
660 | + getString(R.string.okay), new DialogInterface.OnClickListener() { | |
661 | + @Override | |
662 | + public void onClick(DialogInterface dialog, int which) { | |
663 | + Editor editor = sharedpreferences.edit(); | |
664 | + editor.putBoolean(KEY_TURN_OFF_WIFI_SHOW_AGAIN, | |
665 | + !notShowAgainCheckbox.isChecked()); | |
666 | + editor.commit(); | |
667 | + } | |
668 | + }); | |
669 | + alert.setCancelable(false); | |
670 | + alert.show(); | |
671 | + } | |
672 | + } | |
673 | + | |
613 | 674 | public static boolean isProvisioningNeededButUnavailable(Context context) { |
614 | 675 | return (TetherUtil.isProvisioningNeeded(context) |
615 | 676 | && !isIntentAvailable(context)); |
@@ -639,16 +700,29 @@ public class TetherSettings extends RestrictedSettingsFragment | ||
639 | 700 | } |
640 | 701 | } |
641 | 702 | |
703 | + if (choice == TETHERING_USB) { | |
704 | + if(mUsbTether.isChecked()) { | |
705 | + mWifiManager.setWifiEnabled(false); | |
706 | + } | |
707 | + } | |
642 | 708 | mCm.startTethering(choice, true, mStartTetheringCallback, mHandler); |
643 | 709 | } |
644 | 710 | |
645 | 711 | @Override |
646 | 712 | public boolean onPreferenceTreeClick(Preference preference) { |
647 | 713 | if (preference == mUsbTether) { |
648 | - 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); | |
649 | 720 | startTethering(TETHERING_USB); |
650 | 721 | } else { |
651 | 722 | mCm.stopTethering(TETHERING_USB); |
723 | + if (mIsWifiEnabled) { | |
724 | + mWifiManager.setWifiEnabled(true); | |
725 | + } | |
652 | 726 | } |
653 | 727 | } else if (preference == mBluetoothTether) { |
654 | 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); |
@@ -251,6 +236,9 @@ public class AppDataUsage extends DataUsageBase implements Preference.OnPreferen | ||
251 | 236 | |
252 | 237 | @Override |
253 | 238 | public boolean onPreferenceChange(Preference preference, Object newValue) { |
239 | + if (com.android.settings.Utils.isMonkeyRunning()) { | |
240 | + return false; | |
241 | + } | |
254 | 242 | if (preference == mRestrictBackground) { |
255 | 243 | mDataSaverBackend.setIsBlacklisted(mAppItem.key, mPackageName, !(Boolean) newValue); |
256 | 244 | return true; |
@@ -134,6 +134,10 @@ public class DataUsageSummary extends DataUsageBase implements Indexable { | ||
134 | 134 | public void onPrepareOptionsMenu(Menu menu) { |
135 | 135 | final Context context = getActivity(); |
136 | 136 | final MenuItem networkaccess = menu.findItem(R.id.data_usage_menu_app_network_access); |
137 | + if (networkaccess == null) { | |
138 | + return; | |
139 | + } | |
140 | + | |
137 | 141 | if (context.getResources().getBoolean(R.bool.config_app_network_access_enabled)) { |
138 | 142 | networkaccess.setVisible(true); |
139 | 143 | } else { |
@@ -250,7 +250,7 @@ public class UnrestrictedDataAccess extends SettingsPreferenceFragment | ||
250 | 250 | |
251 | 251 | @Override |
252 | 252 | protected void onClick() { |
253 | - if (mState.isDataSaverBlacklisted) { | |
253 | + if (mState != null && mState.isDataSaverBlacklisted) { | |
254 | 254 | // app is blacklisted, launch App Data Usage screen |
255 | 255 | InstalledAppDetails.startAppInfoFragment(AppDataUsage.class, |
256 | 256 | getContext().getString(R.string.app_data_usage), |
@@ -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; |
@@ -286,6 +287,20 @@ public class SimStatus extends SettingsPreferenceFragment { | ||
286 | 287 | if (networktype != null && networktype.equals("LTE") && show4GForLTE) { |
287 | 288 | networktype = "4G"; |
288 | 289 | } |
290 | + | |
291 | + String property = SystemProperties.get("persist.radio.atel.carrier"); | |
292 | + boolean isCarrierOneSupported = "405854".equals(property); | |
293 | + if (isCarrierOneSupported) { | |
294 | + if (TelephonyManager.NETWORK_TYPE_LTE == actualDataNetworkType || | |
295 | + TelephonyManager.NETWORK_TYPE_LTE == actualVoiceNetworkType) { | |
296 | + if (mTelephonyManager.isImsRegistered()) { | |
297 | + networktype = getResources(). | |
298 | + getString(R.string.lte_data_and_voice_calling_enabled); | |
299 | + } else { | |
300 | + networktype = getResources().getString(R.string.lte_data_service_enabled); | |
301 | + } | |
302 | + } | |
303 | + } | |
289 | 304 | setSummaryText(KEY_NETWORK_TYPE, networktype); |
290 | 305 | } |
291 | 306 |
@@ -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 | } |
@@ -20,6 +20,7 @@ import android.app.Activity; | ||
20 | 20 | import android.app.admin.DevicePolicyManager; |
21 | 21 | import android.content.BroadcastReceiver; |
22 | 22 | import android.content.ComponentName; |
23 | +import android.content.ContentResolver; | |
23 | 24 | import android.content.Context; |
24 | 25 | import android.content.Intent; |
25 | 26 | import android.content.IntentFilter; |
@@ -32,6 +33,7 @@ import android.support.v7.preference.Preference; | ||
32 | 33 | import android.support.v7.preference.PreferenceCategory; |
33 | 34 | import android.support.v7.preference.PreferenceGroup; |
34 | 35 | import android.support.v7.preference.PreferenceScreen; |
36 | +import android.support.v7.preference.CheckBoxPreference; | |
35 | 37 | import android.util.Log; |
36 | 38 | import android.view.Menu; |
37 | 39 | import android.view.MenuInflater; |
@@ -50,9 +52,13 @@ import com.android.settingslib.RestrictedSwitchPreference; | ||
50 | 52 | import com.android.settingslib.location.RecentLocationApps; |
51 | 53 | |
52 | 54 | import java.util.ArrayList; |
55 | +import java.io.File; | |
56 | +import java.io.FileInputStream; | |
57 | +import java.io.IOException; | |
53 | 58 | import java.util.Collections; |
54 | 59 | import java.util.Comparator; |
55 | 60 | import java.util.List; |
61 | +import java.util.Properties; | |
56 | 62 | |
57 | 63 | import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; |
58 | 64 |
@@ -91,17 +97,28 @@ public class LocationSettings extends LocationSettingsBase | ||
91 | 97 | * if there is a managed profile. |
92 | 98 | */ |
93 | 99 | private static final String KEY_MANAGED_PROFILE_SWITCH = "managed_profile_location_switch"; |
100 | + | |
101 | + // CMCC assisted gps SUPL(Secure User Plane Location) server address | |
102 | + private static final String ASSISTED_GPS_SUPL_HOST = "assisted_gps_supl_host"; | |
103 | + | |
104 | + // CMCC agps SUPL port address | |
105 | + private static final String ASSISTED_GPS_SUPL_PORT = "assisted_gps_supl_port"; | |
106 | + private static final String KEY_ASSISTED_GPS = "assisted_gps"; | |
107 | + | |
94 | 108 | /** Key for preference screen "Mode" */ |
95 | 109 | private static final String KEY_LOCATION_MODE = "location_mode"; |
96 | 110 | /** Key for preference category "Recent location requests" */ |
97 | 111 | private static final String KEY_RECENT_LOCATION_REQUESTS = "recent_location_requests"; |
98 | 112 | /** Key for preference category "Location services" */ |
99 | 113 | private static final String KEY_LOCATION_SERVICES = "location_services"; |
114 | + private static final String PROPERTIES_FILE = "/etc/gps.conf"; | |
100 | 115 | |
101 | 116 | private static final int MENU_SCANNING = Menu.FIRST; |
102 | 117 | |
118 | + private CheckBoxPreference mAssistedGps; | |
103 | 119 | private SwitchBar mSwitchBar; |
104 | 120 | private Switch mSwitch; |
121 | + private boolean mAgpsEnabled; | |
105 | 122 | private boolean mValidListener = false; |
106 | 123 | private UserHandle mManagedProfile; |
107 | 124 | private RestrictedSwitchPreference mManagedProfileSwitch; |
@@ -199,6 +216,18 @@ public class LocationSettings extends LocationSettingsBase | ||
199 | 216 | } |
200 | 217 | }); |
201 | 218 | |
219 | + mAgpsEnabled = getActivity().getResources().getBoolean( | |
220 | + R.bool.config_agps_enabled); | |
221 | + mAssistedGps = (CheckBoxPreference) root.findPreference(KEY_ASSISTED_GPS); | |
222 | + if (!mAgpsEnabled) { | |
223 | + root.removePreference(mAssistedGps); | |
224 | + } | |
225 | + | |
226 | + if (mAssistedGps != null) { | |
227 | + mAssistedGps.setChecked(Settings.Global.getInt( | |
228 | + getContentResolver(), Settings.Global.ASSISTED_GPS_ENABLED, 0) == 1); | |
229 | + } | |
230 | + | |
202 | 231 | mCategoryRecentLocationRequests = |
203 | 232 | (PreferenceCategory) root.findPreference(KEY_RECENT_LOCATION_REQUESTS); |
204 | 233 | RecentLocationApps recentApps = new RecentLocationApps(activity); |
@@ -244,6 +273,47 @@ public class LocationSettings extends LocationSettingsBase | ||
244 | 273 | return root; |
245 | 274 | } |
246 | 275 | |
276 | + @Override | |
277 | + public boolean onPreferenceTreeClick(Preference preference) { | |
278 | + final ContentResolver cr = getContentResolver(); | |
279 | + if (preference == mAssistedGps) { | |
280 | + if (mAssistedGps.isChecked()) { | |
281 | + if (Settings.Global.getString(cr, ASSISTED_GPS_SUPL_HOST) == null | |
282 | + || Settings.Global | |
283 | + .getString(cr, ASSISTED_GPS_SUPL_PORT) == null) { | |
284 | + FileInputStream stream = null; | |
285 | + try { | |
286 | + Properties properties = new Properties(); | |
287 | + File file = new File(PROPERTIES_FILE); | |
288 | + stream = new FileInputStream(file); | |
289 | + properties.load(stream); | |
290 | + Settings.Global.putString(cr, ASSISTED_GPS_SUPL_HOST, | |
291 | + properties.getProperty("SUPL_HOST", null)); | |
292 | + Settings.Global.putString(cr, ASSISTED_GPS_SUPL_PORT, | |
293 | + properties.getProperty("SUPL_PORT", null)); | |
294 | + } catch (IOException e) { | |
295 | + Log.e("LocationSettings", | |
296 | + "Could not open GPS configuration file " | |
297 | + + PROPERTIES_FILE + ", e=" + e); | |
298 | + } finally { | |
299 | + if (stream != null) { | |
300 | + try { | |
301 | + stream.close(); | |
302 | + } catch (Exception e) { | |
303 | + } | |
304 | + } | |
305 | + } | |
306 | + } | |
307 | + } | |
308 | + Settings.Global.putInt(cr, Settings.Global.ASSISTED_GPS_ENABLED, | |
309 | + mAssistedGps.isChecked() ? 1 : 0); | |
310 | + } else { | |
311 | + // If we didn't handle it, let preferences handle it. | |
312 | + return super.onPreferenceTreeClick(preference); | |
313 | + } | |
314 | + | |
315 | + return true; | |
316 | + } | |
247 | 317 | private void setupManagedProfileCategory(PreferenceScreen root) { |
248 | 318 | // Looking for a managed profile. If there are no managed profiles then we are removing the |
249 | 319 | // managed profile category. |
@@ -153,7 +153,9 @@ public class AdvancedWifiSettings extends RestrictedSettingsFragment | ||
153 | 153 | enableHs2.setChecked(Settings.Global.getInt(getContentResolver(), |
154 | 154 | Settings.Global.WIFI_HOTSPOT2_ENABLED, WIFI_HS2_DISABLED) == WIFI_HS2_ENABLED); |
155 | 155 | } else { |
156 | - getPreferenceScreen().removePreference(enableHs2); | |
156 | + if(enableHs2 != null){ | |
157 | + getPreferenceScreen().removePreference(enableHs2); | |
158 | + } | |
157 | 159 | } |
158 | 160 | |
159 | 161 | Intent wifiDirectIntent = new Intent(context, |
@@ -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 |