diff options
| author | 2018-11-30 00:33:19 -0800 | |
|---|---|---|
| committer | 2018-11-30 00:33:19 -0800 | |
| commit | ab64d282542d2ac54008acc8e208de1a08e8f8a8 (patch) | |
| tree | a6d3f8fd992edc5a5bfd180d99aa0d53b08cc13b | |
| parent | 520a94aa479909654c854a3f802806d3a9b9ed0c (diff) | |
| parent | 5d128c3e26addbb229614ec29aa77f513394a428 (diff) | |
Merge "API to switch preferred data" am: 98b78236d0
am: 5d128c3e26
Change-Id: Ie419367d7bbbde1ff69e6c28aa500ae8b8f2a198
| -rwxr-xr-x | api/current.txt | 2 | ||||
| -rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 51 | ||||
| -rwxr-xr-x | telephony/java/com/android/internal/telephony/IAns.aidl | 29 |
3 files changed, 82 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt index 299700b2dde5..caa14d4f6713 100755 --- a/api/current.txt +++ b/api/current.txt @@ -42945,6 +42945,7 @@ package android.telephony { method public int getNetworkType(); method public int getPhoneCount(); method public int getPhoneType(); + method public int getPreferredOpportunisticDataSubscription(); method public android.telephony.ServiceState getServiceState(); method public android.telephony.SignalStrength getSignalStrength(); method public int getSimCarrierId(); @@ -42995,6 +42996,7 @@ package android.telephony { method public boolean setNetworkSelectionModeManual(java.lang.String, boolean); method public boolean setOperatorBrandOverride(java.lang.String); method public boolean setPreferredNetworkTypeToGlobal(); + method public boolean setPreferredOpportunisticDataSubscription(int); method public void setVisualVoicemailSmsFilterSettings(android.telephony.VisualVoicemailSmsFilterSettings); method public boolean setVoiceMailNumber(java.lang.String, java.lang.String); method public deprecated void setVoicemailRingtoneUri(android.telecom.PhoneAccountHandle, android.net.Uri); diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 6d1de07e1fb3..a0bfcc36992f 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -9251,4 +9251,55 @@ public class TelephonyManager { } return false; } + + /** + * Set preferred opportunistic data subscription id. + * + * <p>Requires that the calling app has carrier privileges on both primary and + * secondary subscriptions (see + * {@link #hasCarrierPrivileges}), or has permission + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}. + * + * @param subId which opportunistic subscription + * {@link SubscriptionManager#getOpportunisticSubscriptions} is preferred for cellular data. + * Pass {@link SubscriptionManager#DEFAULT_SUBSCRIPTION_ID} to unset the preference + * @return true if request is accepted, else false. + * + */ + public boolean setPreferredOpportunisticDataSubscription(int subId) { + String pkgForDebug = mContext != null ? mContext.getOpPackageName() : "<unknown>"; + try { + IAns iAlternativeNetworkService = getIAns(); + if (iAlternativeNetworkService != null) { + return iAlternativeNetworkService.setPreferredData(subId, pkgForDebug); + } + } catch (RemoteException ex) { + Rlog.e(TAG, "setPreferredData RemoteException", ex); + } + return false; + } + + /** + * Get preferred opportunistic data subscription Id + * + * <p>Requires that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}), + * or has permission {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}. + * @return subId preferred opportunistic subscription id or + * {@link SubscriptionManager#DEFAULT_SUBSCRIPTION_ID} if there are no preferred + * subscription id + * + */ + public int getPreferredOpportunisticDataSubscription() { + String pkgForDebug = mContext != null ? mContext.getOpPackageName() : "<unknown>"; + int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; + try { + IAns iAlternativeNetworkService = getIAns(); + if (iAlternativeNetworkService != null) { + subId = iAlternativeNetworkService.getPreferredData(pkgForDebug); + } + } catch (RemoteException ex) { + Rlog.e(TAG, "getPreferredData RemoteException", ex); + } + return subId; + } } diff --git a/telephony/java/com/android/internal/telephony/IAns.aidl b/telephony/java/com/android/internal/telephony/IAns.aidl index 6eb8d666cb1e..e9a46491522e 100755 --- a/telephony/java/com/android/internal/telephony/IAns.aidl +++ b/telephony/java/com/android/internal/telephony/IAns.aidl @@ -49,4 +49,33 @@ interface IAns { * @param callingPackage caller's package name */ boolean isEnabled(String callingPackage); + + /** + * Set preferred opportunistic data subscription id. + * + * <p>Requires that the calling app has carrier privileges on both primary and + * secondary subscriptions (see + * {@link #hasCarrierPrivileges}), or has permission + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}. + * + * @param subId which opportunistic subscription + * {@link SubscriptionManager#getOpportunisticSubscriptions} is preferred for cellular data. + * Pass {@link SubscriptionManager#DEFAULT_SUBSCRIPTION_ID} to unset the preference + * @param callingPackage caller's package name + * @return true if request is accepted, else false. + * + */ + boolean setPreferredData(int subId, String callingPackage); + + /** + * Get preferred opportunistic data subscription Id + * + * <p>Requires that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}), + * or has permission {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}. + * @return subId preferred opportunistic subscription id or + * {@link SubscriptionManager#DEFAULT_SUBSCRIPTION_ID} if there are no preferred + * subscription id + * + */ + int getPreferredData(String callingPackage); } |