Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suspend Actions [2/3] #1

Open
wants to merge 2 commits into
base: NineDotZero
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions res/drawable/ic_4g.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:tint="?android:attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#000" android:pathData="M22,16.5V10.5H17.5V13.5H19V16.5H16V7.5H22V4.5H16A3,3 0 0,0
13,7.5V16.5A3,3 0 0,0 16,19.5H19A3,3 0 0,0 22,16.5M8,19.5H11V4.5H8V10.5H5V4.5H2V13.5H8V19.5Z" />
</vector>
14 changes: 14 additions & 0 deletions res/drawable/ic_apn.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:tint="?android:attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#000" android:pathData="M4.93,4.93C3.12,6.74 2,9.24 2,12C2,14.76 3.12,17.26
4.93,19.07L6.34,17.66C4.89,16.22 4,14.22 4,12C4,9.79 4.89,7.78 6.34,6.34L4.93,4.93M19.07,4.93L17.66,6.34C19.11,7.78 20,9.79
20,12C20,14.22 19.11,16.22 17.66,17.66L19.07,19.07C20.88,17.26 22,14.76 22,12C22,9.24 20.88,6.74
19.07,4.93M7.76,7.76C6.67,8.85 6,10.35 6,12C6,13.65 6.67,15.15 7.76,16.24L9.17,14.83C8.45,14.11 8,13.11 8,12C8,10.89
8.45,9.89 9.17,9.17L7.76,7.76M16.24,7.76L14.83,9.17C15.55,9.89 16,10.89 16,12C16,13.11 15.55,14.11
14.83,14.83L16.24,16.24C17.33,15.15 18,13.65 18,12C18,10.35 17.33,8.85 16.24,7.76M12,10A2,2 0 0,0 10,12A2,2 0 0,0 12,14A2,2 0
0,0 14,12A2,2 0 0,0 12,10Z" />
</vector>
10 changes: 10 additions & 0 deletions res/drawable/ic_app_data_usage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:tint="?android:attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#000" android:pathData="M13,2.05V5.08C16.39,5.57 19,8.47 19,12C19,12.9 18.82,13.75
18.5,14.54L21.12,16.07C21.68,14.83 22,13.45 22,12C22,6.82 18.05,2.55 13,2.05M12,19A7,7 0 0,1 5,12C5,8.47 7.61,5.57
11,5.08V2.05C5.94,2.55 2,6.81 2,12A10,10 0 0,0 12,22C15.3,22 18.23,20.39 20.05,17.91L17.45,16.38C16.17,18 14.21,19 12,19Z" />
</vector>
11 changes: 11 additions & 0 deletions res/drawable/ic_auto_select.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:tint="?android:attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#000" android:pathData="M12,5H9L13,1L17,5H14V9.43C13.25,9.89 12.58,10.46
12,11.12V5M10.4,15H8.5L7.8,13H4.6L3.9,15H2L5.2,6H7.2L10.4,15M7.35,11.65L6.2,8L5.05,11.65H7.35M23,11L19,7V10C15.39,9.85
12.31,12.57 12,16.17C10.44,16.72 9.62,18.44 10.17,20C10.72,21.56 12.44,22.38 14,21.83C15.56,21.27 16.38,19.56
15.83,18C15.53,17.14 14.85,16.47 14,16.17C14.47,12.17 18.47,11.97 18.95,11.97V14.97L23,11Z" />
</vector>
10 changes: 10 additions & 0 deletions res/drawable/ic_enable_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:tint="?android:attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#000" android:pathData="M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1
12,2M12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12A8,8 0 0,0
12,4M11,16.5L6.5,12L7.91,10.59L11,13.67L16.59,8.09L18,9.5L11,16.5Z" />
</vector>
8 changes: 8 additions & 0 deletions res/drawable/ic_network.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:tint="?android:attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#000" android:pathData="M1,21H21V1" />
</vector>
11 changes: 11 additions & 0 deletions res/drawable/ic_pref_network.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:tint="?android:attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#000"
android:pathData="M8.58,17.25L9.5,13.36L6.5,10.78L10.45,10.41L12,6.8L13.55,10.45L17.5,10.78L14.5,13.36L15.42,17.25L12,15.19L8.58,17.25M12,2A10,10
0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12A8,8 0 0,0
12,4Z" />
</vector>
10 changes: 10 additions & 0 deletions res/drawable/ic_roaming.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:tint="?android:attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#000" android:pathData="M9,7H13A2,2 0 0,1 15,9V11C15,11.84 14.5,12.55
13.76,12.85L15,17H13L11.8,13H11V17H9V7M11,9V11H13V9H11M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1
12,2M12,4A8,8 0 0,0 4,12C4,16.41 7.58,20 12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4Z" />
</vector>
8 changes: 8 additions & 0 deletions res/drawable/ic_signal.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:tint="?android:attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#000" android:pathData="M1,21H21V1" />
</vector>
9 changes: 9 additions & 0 deletions res/drawable/ic_video_calling.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:tint="?android:attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#000" android:pathData="M17,10.5V7A1,1 0 0,0 16,6H4A1,1 0 0,0 3,7V17A1,1 0 0,0 4,18H16A1,1 0 0,0
17,17V13.5L21,17.5V6.5L17,10.5M14,13H11V16H9V13H6V11H9V8H11V11H14V13Z" />
</vector>
1 change: 1 addition & 0 deletions res/xml/cdma_options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<!-- The launching Intent will be defined thru code as we need to pass some Extra -->
<com.android.phone.RestrictedPreference
android:key="button_cdma_apn_key"
android:icon="@drawable/ic_apn"
android:title="@string/apn_settings"
android:persistent="false"/>
</PreferenceCategory>
Expand Down
2 changes: 2 additions & 0 deletions res/xml/gsm_umts_options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

<SwitchPreference
android:key="button_auto_select_key"
android:icon="@drawable/ic_auto_select"
android:title="@string/select_automatically"
android:persistent="false"/>

Expand All @@ -46,6 +47,7 @@

<com.android.phone.RestrictedPreference
android:key="button_gsm_apn_key"
android:icon="@drawable/ic_apn"
android:title="@string/apn_settings"
android:persistent="false" />
</PreferenceCategory>
Expand Down
7 changes: 7 additions & 0 deletions res/xml/network_setting_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,36 @@

<com.android.phone.MobileDataPreference
android:key="mobile_data_enable"
android:icon="@drawable/ic_enable_data"
android:title="@string/mobile_data_settings_title"
android:summary="@string/mobile_data_settings_summary"/>

<com.android.phone.RestrictedSwitchPreference
android:key="button_roaming_key"
android:icon="@drawable/ic_roaming"
android:title="@string/roaming"
android:persistent="false"
android:summaryOn="@string/roaming_enable"
android:summaryOff="@string/roaming_disable"/>

<com.android.phone.DataUsagePreference
android:key="data_usage_summary"
android:icon="@drawable/ic_app_data_usage"
android:title="@string/data_usage_title" />

<com.android.phone.AdvancedOptionsPreference
android:key="advanced_options"/>

<SwitchPreference
android:key="enhanced_4g_lte"
android:icon="@drawable/ic_4g"
android:title="@string/enhanced_4g_lte_mode_title"
android:persistent="false"
android:summary="@string/enhanced_4g_lte_mode_summary"/>

<ListPreference
android:key="preferred_network_mode_key"
android:icon="@drawable/ic_pref_network"
android:title="@string/preferred_network_mode_title"
android:summary="@string/preferred_network_mode_summary"
android:entries="@array/preferred_network_mode_choices"
Expand All @@ -55,6 +60,7 @@

<ListPreference
android:key="enabled_networks_key"
android:icon="@drawable/ic_pref_network"
android:title="@string/preferred_network_mode_title"
android:summary="@string/preferred_network_mode_summary"
android:entries="@array/enabled_networks_choices"
Expand Down Expand Up @@ -83,6 +89,7 @@

<SwitchPreference
android:key="video_calling_key"
android:icon="@drawable/ic_video_calling"
android:title="@string/video_calling_settings_title"
android:persistent="true"/>

Expand Down
1 change: 1 addition & 0 deletions src/com/android/phone/MobileNetworkSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,7 @@ public boolean onPreferenceChange(Preference preference, Object objValue) {
switch (buttonNetworkMode) {
case Phone.NT_MODE_WCDMA_PREF:
case Phone.NT_MODE_GSM_ONLY:
case Phone.NT_MODE_WCDMA_ONLY:
case Phone.NT_MODE_LTE_GSM_WCDMA:
case Phone.NT_MODE_LTE_CDMA_EVDO_GSM_WCDMA:
case Phone.NT_MODE_CDMA:
Expand Down
31 changes: 31 additions & 0 deletions src/com/android/phone/PhoneInterfaceManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ public class PhoneInterfaceManager extends ITelephony.Stub {
private static final int EVENT_GET_FORBIDDEN_PLMNS_DONE = 49;
private static final int CMD_SWITCH_SLOTS = 50;
private static final int EVENT_SWITCH_SLOTS_DONE = 51;
private static final int CMD_TOGGLE_2G = 998;

// Parameters of select command.
private static final int SELECT_COMMAND = 0xA4;
Expand All @@ -216,6 +217,7 @@ public class PhoneInterfaceManager extends ITelephony.Stub {
private MainThreadHandler mMainThreadHandler;
private SubscriptionController mSubscriptionController;
private SharedPreferences mTelephonySharedPreferences;
private int pNetwork;

private static final String PREF_CARRIERS_ALPHATAG_PREFIX = "carrier_alphtag_";
private static final String PREF_CARRIERS_NUMBER_PREFIX = "carrier_number_";
Expand Down Expand Up @@ -1158,6 +1160,35 @@ public void dialForSubscriber(int subId, String number) {
}
}

public void toggle2G(boolean on) {
int network = -1;
final int phoneSubId = mSubscriptionController.getDefaultDataSubId();
Phone aphone = getPhone(phoneSubId);
if (on) {
if(phoneSubId != 0) {
pNetwork = android.provider.Settings.Global.getInt(mApp.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + phoneSubId, 0);
} else {
pNetwork = android.provider.Settings.Global.getInt(mApp.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE, 0);
}
network = Phone.NT_MODE_GSM_ONLY;
} else {
network = pNetwork;
}
aphone.setPreferredNetworkType(network,
mMainThreadHandler.obtainMessage(CMD_TOGGLE_2G));
if(phoneSubId != 0) {
android.provider.Settings.Global.putInt(mApp.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + phoneSubId, network);
} else {
android.provider.Settings.Global.putInt(mApp.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE, network);
}
log("DefaultSubId: " + phoneSubId);
log("NetworkType: " + network);
}

public void call(String callingPackage, String number) {
callForSubscriber(getPreferredVoiceSubscription(), callingPackage, number);
}
Expand Down