Merge "add getPreferredDataSubId to SubscriptionManager and rename setPreferredData -> serPreferredDataSubId"

am: 396e01a168

Change-Id: I0fb8572c7a7c12aad124609dc62283061879afcf
This commit is contained in:
Nazanin Bakhshi
2019-01-15 09:39:03 -08:00
committed by android-build-merger
5 changed files with 50 additions and 12 deletions

View File

@@ -296,7 +296,7 @@ public class PhoneStateListener {
/**
* Listen for changes to preferred data subId.
* See {@link SubscriptionManager#setPreferredData(int)}
* See {@link SubscriptionManager#setPreferredDataSubId(int)}
* for more details.
*
* @see #onPreferredDataSubIdChanged

View File

@@ -2439,10 +2439,39 @@ public class SubscriptionManager {
*
*/
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public void setPreferredData(int subId) {
if (VDBG) logd("[setPreferredData]+ subId:" + subId);
setSubscriptionPropertyHelper(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID,
"setPreferredData", (iSub)-> iSub.setPreferredData(subId));
public void setPreferredDataSubscriptionId(int subId) {
if (VDBG) logd("[setPreferredDataSubscriptionId]+ subId:" + subId);
setSubscriptionPropertyHelper(DEFAULT_SUBSCRIPTION_ID, "setPreferredDataSubscriptionId",
(iSub)-> iSub.setPreferredDataSubscriptionId(subId));
}
/**
* Get which subscription is preferred for cellular data.
* It's also usually the subscription we set up internet connection on.
*
* PreferredData overwrites user setting of default data subscription. And it's used
* by AlternativeNetworkService or carrier apps to switch primary and CBRS
* subscription dynamically in multi-SIM devices.
*
* @return preferred subscription id for cellular data. {@link DEFAULT_SUBSCRIPTION_ID} if
* there's no prefered subscription.
*
* @hide
*
*/
@RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
public int getPreferredDataSubscriptionId() {
int preferredSubId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;
try {
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
if (iSub != null) {
preferredSubId = iSub.getPreferredDataSubscriptionId();
}
} catch (RemoteException ex) {
// ignore it
}
return preferredSubId;
}
/**

View File

@@ -9738,10 +9738,11 @@ public class TelephonyManager {
try {
IOns iOpportunisticNetworkService = getIOns();
if (iOpportunisticNetworkService != null) {
return iOpportunisticNetworkService.setPreferredData(subId, pkgForDebug);
return iOpportunisticNetworkService
.setPreferredDataSubscriptionId(subId, pkgForDebug);
}
} catch (RemoteException ex) {
Rlog.e(TAG, "setPreferredData RemoteException", ex);
Rlog.e(TAG, "setPreferredDataSubscriptionId RemoteException", ex);
}
return false;
}
@@ -9762,10 +9763,10 @@ public class TelephonyManager {
try {
IOns iOpportunisticNetworkService = getIOns();
if (iOpportunisticNetworkService != null) {
subId = iOpportunisticNetworkService.getPreferredData(pkgForDebug);
subId = iOpportunisticNetworkService.getPreferredDataSubscriptionId(pkgForDebug);
}
} catch (RemoteException ex) {
Rlog.e(TAG, "getPreferredData RemoteException", ex);
Rlog.e(TAG, "getPreferredDataSubscriptionId RemoteException", ex);
}
return subId;
}

View File

@@ -66,7 +66,7 @@ interface IOns {
* @return true if request is accepted, else false.
*
*/
boolean setPreferredData(int subId, String callingPackage);
boolean setPreferredDataSubscriptionId(int subId, String callingPackage);
/**
* Get preferred opportunistic data subscription Id
@@ -78,7 +78,7 @@ interface IOns {
* subscription id
*
*/
int getPreferredData(String callingPackage);
int getPreferredDataSubscriptionId(String callingPackage);
/**
* Update availability of a list of networks in the current location.

View File

@@ -200,7 +200,15 @@ interface ISub {
* @hide
*
*/
int setPreferredData(int subId);
int setPreferredDataSubscriptionId(int subId);
/**
* Get which subscription is preferred for cellular data.
*
* @hide
*
*/
int getPreferredDataSubscriptionId();
/**
* Get User downloaded Profiles.