diff options
author | Roman Birg <roman@cyngn.com> | 2016-02-10 18:59:16 -0800 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-03-15 16:08:46 -0700 |
commit | c46e0ffb69dc8c223ccef5d16c9a15dc2d10c1d3 (patch) | |
tree | f38957233cd6b4e3404ef097ffa1e25177c82599 /src/java/cyanogenmod/profiles | |
parent | 80f56517fd4c09d25e12b5164ac31966dd4f827a (diff) | |
download | vendor_cmsdk-c46e0ffb69dc8c223ccef5d16c9a15dc2d10c1d3.zip vendor_cmsdk-c46e0ffb69dc8c223ccef5d16c9a15dc2d10c1d3.tar.gz vendor_cmsdk-c46e0ffb69dc8c223ccef5d16c9a15dc2d10c1d3.tar.bz2 |
cmsdk: send connection value when changing network modes
Ref: CYNGNOS-1463
Change-Id: I2ef1feb0d1f135f360dc553e3426bdd7610087bd
Signed-off-by: Roman Birg <roman@cyngn.com>
Diffstat (limited to 'src/java/cyanogenmod/profiles')
-rw-r--r-- | src/java/cyanogenmod/profiles/ConnectionSettings.java | 90 |
1 files changed, 68 insertions, 22 deletions
diff --git a/src/java/cyanogenmod/profiles/ConnectionSettings.java b/src/java/cyanogenmod/profiles/ConnectionSettings.java index f8f745d..0370062 100644 --- a/src/java/cyanogenmod/profiles/ConnectionSettings.java +++ b/src/java/cyanogenmod/profiles/ConnectionSettings.java @@ -59,6 +59,11 @@ public final class ConnectionSettings implements Parcelable { private boolean mDirty; /** + * For use with {@link #PROFILE_CONNECTION_2G3G4G} to determine what subscription to control. + */ + private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; + + /** * The {@link #PROFILE_CONNECTION_MOBILEDATA} allows for enabling and disabling the mobile * data connection. Boolean connection settings {@link BooleanState} */ @@ -116,6 +121,7 @@ public final class ConnectionSettings implements Parcelable { private static final String ACTION_MODIFY_NETWORK_MODE = "com.android.internal.telephony.MODIFY_NETWORK_MODE"; private static final String EXTRA_NETWORK_MODE = "networkMode"; + private static final String EXTRA_SUB_ID = "subId"; /** * BooleanStates for specific {@link ConnectionSettings} @@ -210,6 +216,11 @@ public final class ConnectionSettings implements Parcelable { mDirty = true; } + public void setSubId(int subId) { + mSubId = subId; + mDirty = true; + } + /** * Check whether or not the {@link ConnectionSettings} overrides user settings. * @return true if override @@ -218,6 +229,14 @@ public final class ConnectionSettings implements Parcelable { return mOverride; } + /** + * Get the subscription id which this {@link ConnectionSettings} should apply to. + * @return + */ + public int getSubId() { + return mSubId; + } + /** @hide */ public boolean isDirty() { return mDirty; @@ -254,28 +273,35 @@ public final class ConnectionSettings implements Parcelable { } break; case PROFILE_CONNECTION_2G3G4G: - Intent intent = new Intent(ACTION_MODIFY_NETWORK_MODE); - switch(getValue()) { - case CM_MODE_2G: - intent.putExtra(EXTRA_NETWORK_MODE, RILConstants.NETWORK_MODE_GSM_ONLY); - break; - case CM_MODE_3G: - intent.putExtra(EXTRA_NETWORK_MODE, RILConstants.NETWORK_MODE_WCDMA_ONLY); - break; - case CM_MODE_4G: - intent.putExtra(EXTRA_NETWORK_MODE, RILConstants.NETWORK_MODE_LTE_ONLY); - break; - case CM_MODE_2G3G: - intent.putExtra(EXTRA_NETWORK_MODE, RILConstants.NETWORK_MODE_WCDMA_PREF); - break; - case CM_MODE_ALL: - intent.putExtra(EXTRA_NETWORK_MODE, - RILConstants.NETWORK_MODE_LTE_GSM_WCDMA); - break; - default: - return; + if (Build.CM_VERSION.SDK_INT >= Build.CM_VERSION_CODES.ELDERBERRY) { + Intent intent = new Intent(ACTION_MODIFY_NETWORK_MODE); + intent.putExtra(EXTRA_NETWORK_MODE, getValue()); + intent.putExtra(EXTRA_SUB_ID, getSubId()); + context.sendBroadcast(intent, "com.android.phone.CHANGE_NETWORK_MODE"); + } else { + Intent intent = new Intent(ACTION_MODIFY_NETWORK_MODE); + switch(getValue()) { + case CM_MODE_2G: + intent.putExtra(EXTRA_NETWORK_MODE, RILConstants.NETWORK_MODE_GSM_ONLY); + break; + case CM_MODE_3G: + intent.putExtra(EXTRA_NETWORK_MODE, RILConstants.NETWORK_MODE_WCDMA_ONLY); + break; + case CM_MODE_4G: + intent.putExtra(EXTRA_NETWORK_MODE, RILConstants.NETWORK_MODE_LTE_ONLY); + break; + case CM_MODE_2G3G: + intent.putExtra(EXTRA_NETWORK_MODE, RILConstants.NETWORK_MODE_WCDMA_PREF); + break; + case CM_MODE_ALL: + intent.putExtra(EXTRA_NETWORK_MODE, + RILConstants.NETWORK_MODE_LTE_GSM_WCDMA); + break; + default: + return; + } + context.sendBroadcast(intent); } - context.sendBroadcast(intent); break; case PROFILE_CONNECTION_BLUETOOTH: int btstate = bta.getState(); @@ -363,6 +389,8 @@ public final class ConnectionSettings implements Parcelable { connectionDescriptor.mValue = Integer.parseInt(xpp.nextText()); } else if (name.equals("override")) { connectionDescriptor.mOverride = Boolean.parseBoolean(xpp.nextText()); + } else if (name.equals("subId")) { + connectionDescriptor.mSubId = Integer.parseInt(xpp.nextText()); } } else if (event == XmlPullParser.END_DOCUMENT) { throw new IOException("Premature end of file while parsing connection settings"); @@ -380,7 +408,14 @@ public final class ConnectionSettings implements Parcelable { builder.append(mValue); builder.append("</value>\n<override>"); builder.append(mOverride); - builder.append("</override>\n</connectionDescriptor>\n"); + builder.append("</override>\n"); + if (Build.CM_VERSION.SDK_INT >= Build.CM_VERSION_CODES.ELDERBERRY) { + if (mConnectionId == PROFILE_CONNECTION_2G3G4G + && mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) { + builder.append("<subId>").append(mSubId).append("</subId>\n"); + } + } + builder.append("</connectionDescriptor>\n"); } @Override @@ -407,6 +442,11 @@ public final class ConnectionSettings implements Parcelable { dest.writeInt(mValue); dest.writeInt(mDirty ? 1 : 0); + // === ELDERBERRY === + if (mConnectionId == PROFILE_CONNECTION_2G3G4G) { + dest.writeInt(mSubId); + } + // Go back and write size int parcelableSize = dest.dataPosition() - startPosition; dest.setDataPosition(sizePosition); @@ -432,6 +472,12 @@ public final class ConnectionSettings implements Parcelable { mDirty = in.readInt() != 0; } + if (parcelableVersion >= Build.CM_VERSION_CODES.ELDERBERRY) { + if (mConnectionId == PROFILE_CONNECTION_2G3G4G) { + mSubId = in.readInt(); + } + } + in.setDataPosition(startPosition + parcelableSize); } } |