From bfbaa0bbcaba41c5415d54691b85890305b6036f Mon Sep 17 00:00:00 2001 From: Aaron Huang Date: Thu, 16 Jan 2020 21:53:55 +0800 Subject: [PATCH] Add setSubscriptionPlans() and getSubscriptionPlans() @SystemApi Add two interfaces to communicate with NetworkPolicyManagerService and make them @SystemApi for mainline support. Bug: 138306002 Test: atest FrameworksNetTests atest FrameworksTelephonyTests Change-Id: I9f1168bbc70dce9b2b107e1f946737b1d85599c7 Merged-In: I9f1168bbc70dce9b2b107e1f946737b1d85599c7 --- api/system-current.txt | 2 ++ .../android/net/NetworkPolicyManager.java | 32 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/api/system-current.txt b/api/system-current.txt index 1ec7bef945c9b..de1072a258703 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -4602,7 +4602,9 @@ package android.net { } public class NetworkPolicyManager { + method @NonNull public android.telephony.SubscriptionPlan[] getSubscriptionPlans(int, @NonNull String); method public void setSubscriptionOverride(int, int, int, long, @NonNull String); + method public void setSubscriptionPlans(int, @NonNull android.telephony.SubscriptionPlan[], @NonNull String); field public static final int SUBSCRIPTION_OVERRIDE_CONGESTED = 2; // 0x2 field public static final int SUBSCRIPTION_OVERRIDE_UNMETERED = 1; // 0x1 } diff --git a/core/java/android/net/NetworkPolicyManager.java b/core/java/android/net/NetworkPolicyManager.java index 32e6a6d13e288..0f66c794ea500 100644 --- a/core/java/android/net/NetworkPolicyManager.java +++ b/core/java/android/net/NetworkPolicyManager.java @@ -337,7 +337,6 @@ public class NetworkPolicyManager { * requested state until explicitly cleared, or the next reboot, * whichever happens first * @param callingPackage the name of the package making the call. - * */ public void setSubscriptionOverride(int subId, @SubscriptionOverrideMask int overrideMask, @SubscriptionOverrideMask int overrideValue, long timeoutMillis, @@ -350,6 +349,37 @@ public class NetworkPolicyManager { } } + /** + * Set the subscription plans for a specific subscriber. + * + * @param subId the subscriber this relationship applies to. + * @param plans the list of plans. + * @param callingPackage the name of the package making the call + */ + public void setSubscriptionPlans(int subId, @NonNull SubscriptionPlan[] plans, + @NonNull String callingPackage) { + try { + mService.setSubscriptionPlans(subId, plans, callingPackage); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * Get subscription plans for the given subscription id. + * + * @param subId the subscriber to get the subscription plans for. + * @param callingPackage the name of the package making the call. + */ + @NonNull + public SubscriptionPlan[] getSubscriptionPlans(int subId, @NonNull String callingPackage) { + try { + return mService.getSubscriptionPlans(subId, callingPackage); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + /** * Resets network policy settings back to factory defaults. *