Loading src/java/com/android/internal/telephony/PhoneSwitcher.java +5 −5 Original line number Diff line number Diff line Loading @@ -274,7 +274,7 @@ public class PhoneSwitcher extends Handler { break; } case EVENT_PREFERRED_SUBSCRIPTION_CHANGED: { onEvaluate(REQUESTS_UNCHANGED, "preferredDataSubIdChanged"); onEvaluate(REQUESTS_UNCHANGED, "preferredDataSubscriptionIdChanged"); break; } case EVENT_RADIO_AVAILABLE: { Loading Loading @@ -477,7 +477,7 @@ public class PhoneSwitcher extends Handler { /** * Used when the modem may have been rebooted and we * want to resend setDataAllowed or setPreferredData * want to resend setDataAllowed or setPreferredDataSubscriptionId */ public void onRadioCapChanged(int phoneId) { validatePhoneId(phoneId); Loading Loading @@ -625,11 +625,11 @@ public class PhoneSwitcher extends Handler { /** * Set a subscription as preferred data subscription. * See {@link SubscriptionManager#setPreferredData(int)} for more details. * See {@link SubscriptionManager#setPreferredDataSubscriptionId(int)} for more details. */ public void setPreferredData(int subId) { public void setPreferredDataSubscriptionId(int subId) { if (mPreferredDataSubId != subId) { log("setPreferredData subId changed to " + subId); log("setPreferredDataSubscriptionId subId changed to " + subId); mPreferredDataSubId = subId; Message msg = PhoneSwitcher.this.obtainMessage(EVENT_PREFERRED_SUBSCRIPTION_CHANGED); msg.sendToTarget(); Loading src/java/com/android/internal/telephony/SubscriptionController.java +15 −4 Original line number Diff line number Diff line Loading @@ -173,7 +173,7 @@ public class SubscriptionController extends ISub.Stub { private int[] colorArr; private long mLastISubServiceRegTime; private int mPreferredDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; private int mPreferredDataSubId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID; public static SubscriptionController init(Phone phone) { synchronized (SubscriptionController.class) { Loading Loading @@ -247,6 +247,11 @@ public class SubscriptionController extends ISub.Stub { android.Manifest.permission.MODIFY_PHONE_STATE, message); } private void enforceReadPrivilegedPhoneState(String message) { mContext.enforceCallingOrSelfPermission( Manifest.permission.READ_PRIVILEGED_PHONE_STATE, message); } /** * Broadcast when SubscriptionInfo has changed * FIXME: Hopefully removed if the API council accepts SubscriptionInfoListener Loading Loading @@ -2318,14 +2323,14 @@ public class SubscriptionController extends ISub.Stub { } @Override public int setPreferredData(int subId) { enforceModifyPhoneState("setPreferredData"); public int setPreferredDataSubscriptionId(int subId) { enforceModifyPhoneState("setPreferredDataSubscriptionId"); final long token = Binder.clearCallingIdentity(); try { if (mPreferredDataSubId != subId) { mPreferredDataSubId = subId; PhoneSwitcher.getInstance().setPreferredData(subId); PhoneSwitcher.getInstance().setPreferredDataSubscriptionId(subId); notifyPreferredDataSubIdChanged(); } Loading @@ -2335,6 +2340,12 @@ public class SubscriptionController extends ISub.Stub { } } @Override public int getPreferredDataSubscriptionId() { enforceReadPrivilegedPhoneState("getPreferredDataSubscriptionId"); return mPreferredDataSubId; } private void notifyPreferredDataSubIdChanged() { ITelephonyRegistry tr = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService( "telephony.registry")); Loading tests/telephonytests/src/com/android/internal/telephony/PhoneSwitcherTest.java +4 −4 Original line number Diff line number Diff line Loading @@ -378,13 +378,13 @@ public class PhoneSwitcherTest extends TelephonyTest { assertTrue(mDataAllowed[0]); // Set sub 2 as preferred sub should make phone 1 activated and phone 0 deactivated. mPhoneSwitcher.setPreferredData(2); mPhoneSwitcher.setPreferredDataSubscriptionId(2); waitABit(); assertFalse(mDataAllowed[0]); assertTrue(mDataAllowed[1]); // Unset preferred sub should make default data sub (phone 0 / sub 1) activated again. mPhoneSwitcher.setPreferredData(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID); mPhoneSwitcher.setPreferredDataSubscriptionId(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID); waitABit(); assertTrue(mDataAllowed[0]); assertFalse(mDataAllowed[1]); Loading Loading @@ -433,7 +433,7 @@ public class PhoneSwitcherTest extends TelephonyTest { assertTrue(mPhoneSwitcher.shouldApplyNetworkRequest(mmsRequest, 1)); // Set sub 2 as preferred sub should make phone 1 preferredDataModem mPhoneSwitcher.setPreferredData(2); mPhoneSwitcher.setPreferredDataSubscriptionId(2); waitABit(); verify(mMockRadioConfig).setPreferredDataModem(eq(1), any()); verify(mActivePhoneSwitchHandler, times(2)).sendMessageAtTime(any(), anyLong()); Loading @@ -446,7 +446,7 @@ public class PhoneSwitcherTest extends TelephonyTest { clearInvocations(mActivePhoneSwitchHandler); // Unset preferred sub should make phone0 preferredDataModem again. mPhoneSwitcher.setPreferredData(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID); mPhoneSwitcher.setPreferredDataSubscriptionId(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID); waitABit(); verify(mMockRadioConfig).setPreferredDataModem(eq(0), any()); verify(mActivePhoneSwitchHandler, times(2)).sendMessageAtTime(any(), anyLong()); Loading Loading
src/java/com/android/internal/telephony/PhoneSwitcher.java +5 −5 Original line number Diff line number Diff line Loading @@ -274,7 +274,7 @@ public class PhoneSwitcher extends Handler { break; } case EVENT_PREFERRED_SUBSCRIPTION_CHANGED: { onEvaluate(REQUESTS_UNCHANGED, "preferredDataSubIdChanged"); onEvaluate(REQUESTS_UNCHANGED, "preferredDataSubscriptionIdChanged"); break; } case EVENT_RADIO_AVAILABLE: { Loading Loading @@ -477,7 +477,7 @@ public class PhoneSwitcher extends Handler { /** * Used when the modem may have been rebooted and we * want to resend setDataAllowed or setPreferredData * want to resend setDataAllowed or setPreferredDataSubscriptionId */ public void onRadioCapChanged(int phoneId) { validatePhoneId(phoneId); Loading Loading @@ -625,11 +625,11 @@ public class PhoneSwitcher extends Handler { /** * Set a subscription as preferred data subscription. * See {@link SubscriptionManager#setPreferredData(int)} for more details. * See {@link SubscriptionManager#setPreferredDataSubscriptionId(int)} for more details. */ public void setPreferredData(int subId) { public void setPreferredDataSubscriptionId(int subId) { if (mPreferredDataSubId != subId) { log("setPreferredData subId changed to " + subId); log("setPreferredDataSubscriptionId subId changed to " + subId); mPreferredDataSubId = subId; Message msg = PhoneSwitcher.this.obtainMessage(EVENT_PREFERRED_SUBSCRIPTION_CHANGED); msg.sendToTarget(); Loading
src/java/com/android/internal/telephony/SubscriptionController.java +15 −4 Original line number Diff line number Diff line Loading @@ -173,7 +173,7 @@ public class SubscriptionController extends ISub.Stub { private int[] colorArr; private long mLastISubServiceRegTime; private int mPreferredDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; private int mPreferredDataSubId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID; public static SubscriptionController init(Phone phone) { synchronized (SubscriptionController.class) { Loading Loading @@ -247,6 +247,11 @@ public class SubscriptionController extends ISub.Stub { android.Manifest.permission.MODIFY_PHONE_STATE, message); } private void enforceReadPrivilegedPhoneState(String message) { mContext.enforceCallingOrSelfPermission( Manifest.permission.READ_PRIVILEGED_PHONE_STATE, message); } /** * Broadcast when SubscriptionInfo has changed * FIXME: Hopefully removed if the API council accepts SubscriptionInfoListener Loading Loading @@ -2318,14 +2323,14 @@ public class SubscriptionController extends ISub.Stub { } @Override public int setPreferredData(int subId) { enforceModifyPhoneState("setPreferredData"); public int setPreferredDataSubscriptionId(int subId) { enforceModifyPhoneState("setPreferredDataSubscriptionId"); final long token = Binder.clearCallingIdentity(); try { if (mPreferredDataSubId != subId) { mPreferredDataSubId = subId; PhoneSwitcher.getInstance().setPreferredData(subId); PhoneSwitcher.getInstance().setPreferredDataSubscriptionId(subId); notifyPreferredDataSubIdChanged(); } Loading @@ -2335,6 +2340,12 @@ public class SubscriptionController extends ISub.Stub { } } @Override public int getPreferredDataSubscriptionId() { enforceReadPrivilegedPhoneState("getPreferredDataSubscriptionId"); return mPreferredDataSubId; } private void notifyPreferredDataSubIdChanged() { ITelephonyRegistry tr = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService( "telephony.registry")); Loading
tests/telephonytests/src/com/android/internal/telephony/PhoneSwitcherTest.java +4 −4 Original line number Diff line number Diff line Loading @@ -378,13 +378,13 @@ public class PhoneSwitcherTest extends TelephonyTest { assertTrue(mDataAllowed[0]); // Set sub 2 as preferred sub should make phone 1 activated and phone 0 deactivated. mPhoneSwitcher.setPreferredData(2); mPhoneSwitcher.setPreferredDataSubscriptionId(2); waitABit(); assertFalse(mDataAllowed[0]); assertTrue(mDataAllowed[1]); // Unset preferred sub should make default data sub (phone 0 / sub 1) activated again. mPhoneSwitcher.setPreferredData(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID); mPhoneSwitcher.setPreferredDataSubscriptionId(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID); waitABit(); assertTrue(mDataAllowed[0]); assertFalse(mDataAllowed[1]); Loading Loading @@ -433,7 +433,7 @@ public class PhoneSwitcherTest extends TelephonyTest { assertTrue(mPhoneSwitcher.shouldApplyNetworkRequest(mmsRequest, 1)); // Set sub 2 as preferred sub should make phone 1 preferredDataModem mPhoneSwitcher.setPreferredData(2); mPhoneSwitcher.setPreferredDataSubscriptionId(2); waitABit(); verify(mMockRadioConfig).setPreferredDataModem(eq(1), any()); verify(mActivePhoneSwitchHandler, times(2)).sendMessageAtTime(any(), anyLong()); Loading @@ -446,7 +446,7 @@ public class PhoneSwitcherTest extends TelephonyTest { clearInvocations(mActivePhoneSwitchHandler); // Unset preferred sub should make phone0 preferredDataModem again. mPhoneSwitcher.setPreferredData(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID); mPhoneSwitcher.setPreferredDataSubscriptionId(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID); waitABit(); verify(mMockRadioConfig).setPreferredDataModem(eq(0), any()); verify(mActivePhoneSwitchHandler, times(2)).sendMessageAtTime(any(), anyLong()); Loading