summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-05-22 03:14:42 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-05-22 03:14:42 +0000
commit6ccf12d250602af5032e7879bef7dd784e1e6648 (patch)
treeff05bba625c7a5655ff0514d6e99f5b1a336a536
parentb1d6a89b0f29db8459ef6f5ef35c907a19a3b5e6 (diff)
parentb1fd0964932ec9e0aeb0809d3777110371c3bf98 (diff)
downloadplatform_packages_services_AlternativeNetworkAccess-android10-s2-release.tar.gz
platform_packages_services_AlternativeNetworkAccess-android10-s2-release.tar.bz2
platform_packages_services_AlternativeNetworkAccess-android10-s2-release.zip
Change-Id: Ibf58b0c7cf9bfb7c86c43320af41cfcb314cc9df
-rw-r--r--src/com/android/ons/ONSProfileSelector.java22
-rw-r--r--src/com/android/ons/OpportunisticNetworkService.java24
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);