diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2019-05-22 03:14:42 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2019-05-22 03:14:42 +0000 |
commit | 6ccf12d250602af5032e7879bef7dd784e1e6648 (patch) | |
tree | ff05bba625c7a5655ff0514d6e99f5b1a336a536 | |
parent | b1d6a89b0f29db8459ef6f5ef35c907a19a3b5e6 (diff) | |
parent | b1fd0964932ec9e0aeb0809d3777110371c3bf98 (diff) | |
download | AlternativeNetworkAccess-android10-s2-release.tar.gz |
Snap for 5591509 from b1fd0964932ec9e0aeb0809d3777110371c3bf98 to qt-releaseandroid-vts-10.0_r9android-vts-10.0_r8android-vts-10.0_r7android-vts-10.0_r6android-vts-10.0_r5android-vts-10.0_r4android-vts-10.0_r3android-vts-10.0_r2android-vts-10.0_r16android-vts-10.0_r15android-vts-10.0_r14android-vts-10.0_r13android-vts-10.0_r12android-vts-10.0_r11android-vts-10.0_r10android-vts-10.0_r1android-security-10.0.0_r75android-security-10.0.0_r74android-security-10.0.0_r73android-security-10.0.0_r72android-security-10.0.0_r71android-security-10.0.0_r70android-security-10.0.0_r69android-security-10.0.0_r68android-security-10.0.0_r67android-security-10.0.0_r66android-security-10.0.0_r65android-security-10.0.0_r64android-security-10.0.0_r63android-security-10.0.0_r62android-security-10.0.0_r61android-security-10.0.0_r60android-security-10.0.0_r59android-security-10.0.0_r58android-security-10.0.0_r57android-security-10.0.0_r56android-security-10.0.0_r55android-security-10.0.0_r54android-security-10.0.0_r53android-security-10.0.0_r52android-security-10.0.0_r51android-security-10.0.0_r50android-security-10.0.0_r49android-security-10.0.0_r48android-cts-10.0_r9android-cts-10.0_r8android-cts-10.0_r7android-cts-10.0_r6android-cts-10.0_r5android-cts-10.0_r4android-cts-10.0_r3android-cts-10.0_r2android-cts-10.0_r16android-cts-10.0_r15android-cts-10.0_r14android-cts-10.0_r13android-cts-10.0_r12android-cts-10.0_r11android-cts-10.0_r10android-cts-10.0_r1android-10.0.0_r6android-10.0.0_r5android-10.0.0_r47android-10.0.0_r46android-10.0.0_r4android-10.0.0_r3android-10.0.0_r2android-10.0.0_r17android-10.0.0_r11android-10.0.0_r10android-10.0.0_r1android10-tests-releaseandroid10-security-releaseandroid10-s3-releaseandroid10-s2-releaseandroid10-s1-releaseandroid10-release
Change-Id: Ibf58b0c7cf9bfb7c86c43320af41cfcb314cc9df
-rw-r--r-- | src/com/android/ons/ONSProfileSelector.java | 22 | ||||
-rw-r--r-- | src/com/android/ons/OpportunisticNetworkService.java | 24 |
2 files changed, 29 insertions, 17 deletions
diff --git a/src/com/android/ons/ONSProfileSelector.java b/src/com/android/ons/ONSProfileSelector.java index 0d600a7..04fd3dd 100644 --- a/src/com/android/ons/ONSProfileSelector.java +++ b/src/com/android/ons/ONSProfileSelector.java @@ -92,6 +92,7 @@ public class ONSProfileSelector { protected List<SubscriptionInfo> mOppSubscriptionInfos; private ONSProfileSelectionCallback mProfileSelectionCallback; private int mSequenceId; + private int mSubId; private int mCurrentDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; private ArrayList<AvailableNetworkInfo> mAvailableNetworkInfos; private IUpdateAvailableNetworksCallback mNetworkScanCallback; @@ -310,7 +311,7 @@ public class ONSProfileSelector { updateToken(); callbackIntent.putExtra("sequenceId", mSequenceId); callbackIntent.putExtra("subId", subId); - + mSubId = subId; PendingIntent replyIntent = PendingIntent.getService(mContext, 1, callbackIntent, Intent.FILL_IN_ACTION); @@ -322,16 +323,19 @@ public class ONSProfileSelector { int subId = intent.getIntExtra("subId", SubscriptionManager.INVALID_SUBSCRIPTION_ID); logDebug("ACTION_SUB_SWITCH sequenceId: " + sequenceId - + " mSequenceId: " + mSequenceId); - if (sequenceId != mSequenceId) { - return; - } - + + " mSequenceId: " + mSequenceId + + " mSubId: " + mSubId + + " subId: " + subId); Message message = Message.obtain(mHandler, MSG_SUB_SWITCH_COMPLETE, subId); message.sendToTarget(); } private void onSubSwitchComplete(int subId) { + /* Ignore if this is callback for an older request */ + if (mSubId != subId) { + return; + } + if (enableModem(subId, true)) { sendUpdateNetworksCallbackHelper(mNetworkScanCallback, TelephonyManager.UPDATE_AVAILABLE_NETWORKS_SUCCESS); @@ -471,10 +475,10 @@ public class ONSProfileSelector { switchToSubscription(filteredAvailableNetworks.get(0).getSubId()); } else { if (enableModem(filteredAvailableNetworks.get(0).getSubId(), true)) { - sendUpdateNetworksCallbackHelper(mNetworkScanCallback, + sendUpdateNetworksCallbackHelper(callbackStub, TelephonyManager.UPDATE_AVAILABLE_NETWORKS_SUCCESS); } else { - sendUpdateNetworksCallbackHelper(mNetworkScanCallback, + sendUpdateNetworksCallbackHelper(callbackStub, TelephonyManager.UPDATE_AVAILABLE_NETWORKS_ABORTED); } mProfileSelectionCallback.onProfileSelectionDone(); @@ -588,6 +592,7 @@ public class ONSProfileSelector { int phoneId = SubscriptionManager.getPhoneId(subId); if (mSubscriptionBoundTelephonyManager.isModemEnabledForSlot(phoneId) == enable) { + logDebug("modem is already enabled "); return true; } @@ -723,6 +728,7 @@ public class ONSProfileSelector { protected void init(Context c, ONSProfileSelectionCallback profileSelectionCallback) { mContext = c; mSequenceId = START_SEQUENCE_ID; + mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; mProfileSelectionCallback = profileSelectionCallback; mTelephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); diff --git a/src/com/android/ons/OpportunisticNetworkService.java b/src/com/android/ons/OpportunisticNetworkService.java index f23b488..91a17b2 100644 --- a/src/com/android/ons/OpportunisticNetworkService.java +++ b/src/com/android/ons/OpportunisticNetworkService.java @@ -383,17 +383,23 @@ public class OpportunisticNetworkService extends Service { TelephonyManager.UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS); return; } - TelephonyPermissions.enforceCallingOrSelfCarrierPrivilege( - availableNetworks.get(0).getSubId(), "updateAvailableNetworks"); - /* check if the app has opportunistic carrier permission */ - if (!hasOpportunisticSubPrivilege(callingPackage, - availableNetworks.get(0).getSubId())) { - log("No carrier privelege for opportunistic subscription"); - sendUpdateNetworksCallbackHelper(callbackStub, - TelephonyManager.UPDATE_AVAILABLE_NETWORKS_NO_CARRIER_PRIVILEGE); - return; + for (AvailableNetworkInfo availableNetworkInfo : availableNetworks) { + if (mSubscriptionManager.isActiveSubId(availableNetworkInfo.getSubId())) { + TelephonyPermissions.enforceCallingOrSelfCarrierPrivilege( + availableNetworkInfo.getSubId(), "updateAvailableNetworks"); + } else { + /* check if the app has opportunistic carrier permission */ + if (!hasOpportunisticSubPrivilege(callingPackage, + availableNetworkInfo.getSubId())) { + log("No carrier privilege for opportunistic subscription"); + sendUpdateNetworksCallbackHelper(callbackStub, + TelephonyManager.UPDATE_AVAILABLE_NETWORKS_NO_CARRIER_PRIVILEGE); + return; + } + } } + final long identity = Binder.clearCallingIdentity(); try { ONSConfigInput onsConfigInput = new ONSConfigInput(availableNetworks, callbackStub); |