Skip to content

Commit

Permalink
Suspend Actions [2/3]
Browse files Browse the repository at this point in the history
Change-Id: I20e4d0332e8902c8092afcb4454203de703ae565
  • Loading branch information
maxwen authored and Dil3mm4 committed Nov 17, 2018
1 parent 42ae80d commit 66657d3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
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 @@ -1200,6 +1202,35 @@ public void callForSubscriber(int subId, String callingPackage, String number) {
mApp.startActivity(intent);
}

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);
}

/**
* End a call based on call state
* @return true is a call was ended
Expand Down

0 comments on commit 66657d3

Please sign in to comment.