Jeff Sharkey | d5cdd59 | 2011-05-03 20:27:17 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.net; |
| 18 | |
Jeff Sharkey | 4414cea | 2011-06-24 17:05:24 -0700 | [diff] [blame] | 19 | import static android.content.pm.PackageManager.GET_SIGNATURES; |
Jeff Sharkey | cd2ca40 | 2011-06-10 15:14:07 -0700 | [diff] [blame] | 20 | |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 21 | import android.annotation.IntDef; |
| 22 | import android.annotation.NonNull; |
Aaron Huang | 9204f46 | 2019-12-25 00:26:47 +0800 | [diff] [blame] | 23 | import android.annotation.RequiresPermission; |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 24 | import android.annotation.SystemApi; |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 25 | import android.annotation.SystemService; |
Sudheer Shanka | e359c3d | 2017-02-22 18:41:29 -0800 | [diff] [blame] | 26 | import android.app.ActivityManager; |
Artur Satayev | 2695800 | 2019-12-10 17:47:52 +0000 | [diff] [blame] | 27 | import android.compat.annotation.UnsupportedAppUsage; |
Jeff Sharkey | eedcb95 | 2011-05-17 14:55:15 -0700 | [diff] [blame] | 28 | import android.content.Context; |
Jeff Sharkey | 14711eb5 | 2011-06-15 10:29:17 -0700 | [diff] [blame] | 29 | import android.content.Intent; |
Jeff Sharkey | 4414cea | 2011-06-24 17:05:24 -0700 | [diff] [blame] | 30 | import android.content.pm.PackageManager; |
| 31 | import android.content.pm.PackageManager.NameNotFoundException; |
| 32 | import android.content.pm.Signature; |
Jeff Sharkey | 43d2a17 | 2017-07-12 10:50:42 -0600 | [diff] [blame] | 33 | import android.net.wifi.WifiConfiguration; |
| 34 | import android.net.wifi.WifiInfo; |
Mathew Inwood | 31755f9 | 2018-12-20 13:53:36 +0000 | [diff] [blame] | 35 | import android.os.Build; |
Jeff Sharkey | d5cdd59 | 2011-05-03 20:27:17 -0700 | [diff] [blame] | 36 | import android.os.RemoteException; |
Jeff Sharkey | d0c6ccb | 2012-09-14 16:26:37 -0700 | [diff] [blame] | 37 | import android.os.UserHandle; |
Sarah Chin | 7af1fd0 | 2019-09-26 11:37:13 -0700 | [diff] [blame] | 38 | import android.telephony.SubscriptionPlan; |
Felipe Leme | 46c4fc3 | 2016-05-04 09:21:43 -0700 | [diff] [blame] | 39 | import android.util.DebugUtils; |
Jeff Sharkey | 53313d7 | 2017-07-13 16:47:32 -0600 | [diff] [blame] | 40 | import android.util.Pair; |
Jeff Sharkey | 0fc6d03 | 2018-03-30 16:25:11 -0600 | [diff] [blame] | 41 | import android.util.Range; |
Jeff Sharkey | d5cdd59 | 2011-05-03 20:27:17 -0700 | [diff] [blame] | 42 | |
Jeff Sharkey | 4414cea | 2011-06-24 17:05:24 -0700 | [diff] [blame] | 43 | import com.google.android.collect.Sets; |
| 44 | |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 45 | import java.lang.annotation.Retention; |
| 46 | import java.lang.annotation.RetentionPolicy; |
Jeff Sharkey | 53313d7 | 2017-07-13 16:47:32 -0600 | [diff] [blame] | 47 | import java.time.ZonedDateTime; |
Jeff Sharkey | 4414cea | 2011-06-24 17:05:24 -0700 | [diff] [blame] | 48 | import java.util.HashSet; |
Jeff Sharkey | 53313d7 | 2017-07-13 16:47:32 -0600 | [diff] [blame] | 49 | import java.util.Iterator; |
Aaron Huang | 9204f46 | 2019-12-25 00:26:47 +0800 | [diff] [blame] | 50 | import java.util.Map; |
| 51 | import java.util.concurrent.ConcurrentHashMap; |
Jeff Sharkey | 1b86127 | 2011-05-22 00:34:52 -0700 | [diff] [blame] | 52 | |
Jeff Sharkey | d5cdd59 | 2011-05-03 20:27:17 -0700 | [diff] [blame] | 53 | /** |
| 54 | * Manager for creating and modifying network policy rules. |
| 55 | * |
Aaron Huang | 9204f46 | 2019-12-25 00:26:47 +0800 | [diff] [blame] | 56 | * @hide |
Jeff Sharkey | d5cdd59 | 2011-05-03 20:27:17 -0700 | [diff] [blame] | 57 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 58 | @SystemService(Context.NETWORK_POLICY_SERVICE) |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 59 | @SystemApi |
Jeff Sharkey | d5cdd59 | 2011-05-03 20:27:17 -0700 | [diff] [blame] | 60 | public class NetworkPolicyManager { |
| 61 | |
Felipe Leme | 46b451f | 2016-08-19 08:46:17 -0700 | [diff] [blame] | 62 | /* POLICY_* are masks and can be ORed, although currently they are not.*/ |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 63 | /** |
| 64 | * No specific network policy, use system default. |
| 65 | * @hide |
| 66 | */ |
Jeff Sharkey | d5cdd59 | 2011-05-03 20:27:17 -0700 | [diff] [blame] | 67 | public static final int POLICY_NONE = 0x0; |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 68 | /** |
| 69 | * Reject network usage on metered networks when application in background. |
| 70 | * @hide |
| 71 | */ |
Jeff Sharkey | fdfef57 | 2011-06-16 15:07:48 -0700 | [diff] [blame] | 72 | public static final int POLICY_REJECT_METERED_BACKGROUND = 0x1; |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 73 | /** |
| 74 | * Allow metered network use in the background even when in data usage save mode. |
| 75 | * @hide |
| 76 | */ |
Felipe Leme | 46b451f | 2016-08-19 08:46:17 -0700 | [diff] [blame] | 77 | public static final int POLICY_ALLOW_METERED_BACKGROUND = 0x4; |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 78 | |
Felipe Leme | 46c4fc3 | 2016-05-04 09:21:43 -0700 | [diff] [blame] | 79 | /* |
| 80 | * Rules defining whether an uid has access to a network given its type (metered / non-metered). |
| 81 | * |
| 82 | * These rules are bits and can be used in bitmask operations; in particular: |
| 83 | * - rule & RULE_MASK_METERED: returns the metered-networks status. |
| 84 | * - rule & RULE_MASK_ALL: returns the all-networks status. |
| 85 | * |
| 86 | * The RULE_xxx_ALL rules applies to all networks (metered or non-metered), but on |
| 87 | * metered networks, the RULE_xxx_METERED rules should be checked first. For example, |
| 88 | * if the device is on Battery Saver Mode and Data Saver Mode simulatenously, and a uid |
| 89 | * is whitelisted for the former but not the latter, its status would be |
| 90 | * RULE_REJECT_METERED | RULE_ALLOW_ALL, meaning it could have access to non-metered |
| 91 | * networks but not to metered networks. |
| 92 | * |
| 93 | * See network-policy-restrictions.md for more info. |
| 94 | */ |
Aaron Huang | 9204f46 | 2019-12-25 00:26:47 +0800 | [diff] [blame] | 95 | |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 96 | /** |
| 97 | * No specific rule was set |
| 98 | * @hide |
| 99 | */ |
Felipe Leme | 46c4fc3 | 2016-05-04 09:21:43 -0700 | [diff] [blame] | 100 | public static final int RULE_NONE = 0; |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 101 | /** |
| 102 | * Allow traffic on metered networks. |
| 103 | * @hide |
| 104 | */ |
Felipe Leme | 46c4fc3 | 2016-05-04 09:21:43 -0700 | [diff] [blame] | 105 | public static final int RULE_ALLOW_METERED = 1 << 0; |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 106 | /** |
| 107 | * Temporarily allow traffic on metered networks because app is on foreground. |
| 108 | * @hide |
| 109 | */ |
Felipe Leme | 46c4fc3 | 2016-05-04 09:21:43 -0700 | [diff] [blame] | 110 | public static final int RULE_TEMPORARY_ALLOW_METERED = 1 << 1; |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 111 | /** |
| 112 | * Reject traffic on metered networks. |
| 113 | * @hide |
| 114 | */ |
Felipe Leme | 46c4fc3 | 2016-05-04 09:21:43 -0700 | [diff] [blame] | 115 | public static final int RULE_REJECT_METERED = 1 << 2; |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 116 | /** |
| 117 | * Network traffic should be allowed on all networks (metered or non-metered), although |
| 118 | * metered-network restrictions could still apply. |
| 119 | * @hide |
| 120 | */ |
Felipe Leme | 46c4fc3 | 2016-05-04 09:21:43 -0700 | [diff] [blame] | 121 | public static final int RULE_ALLOW_ALL = 1 << 5; |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 122 | /** |
| 123 | * Reject traffic on all networks. |
| 124 | * @hide |
| 125 | */ |
Felipe Leme | 46c4fc3 | 2016-05-04 09:21:43 -0700 | [diff] [blame] | 126 | public static final int RULE_REJECT_ALL = 1 << 6; |
Aaron Huang | 9204f46 | 2019-12-25 00:26:47 +0800 | [diff] [blame] | 127 | |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 128 | /** |
| 129 | * Mask used to get the {@code RULE_xxx_METERED} rules |
| 130 | * @hide |
| 131 | */ |
Felipe Leme | 46c4fc3 | 2016-05-04 09:21:43 -0700 | [diff] [blame] | 132 | public static final int MASK_METERED_NETWORKS = 0b00001111; |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 133 | /** |
| 134 | * Mask used to get the {@code RULE_xxx_ALL} rules |
| 135 | * @hide |
| 136 | */ |
Felipe Leme | 46c4fc3 | 2016-05-04 09:21:43 -0700 | [diff] [blame] | 137 | public static final int MASK_ALL_NETWORKS = 0b11110000; |
Amith Yamasani | 15e47235 | 2015-04-24 19:06:07 -0700 | [diff] [blame] | 138 | |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 139 | /** @hide */ |
Amith Yamasani | 15e47235 | 2015-04-24 19:06:07 -0700 | [diff] [blame] | 140 | public static final int FIREWALL_RULE_DEFAULT = 0; |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 141 | /** @hide */ |
Xiaohui Chen | b41c9f7 | 2015-06-17 15:55:37 -0700 | [diff] [blame] | 142 | public static final String FIREWALL_CHAIN_NAME_NONE = "none"; |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 143 | /** @hide */ |
Xiaohui Chen | b41c9f7 | 2015-06-17 15:55:37 -0700 | [diff] [blame] | 144 | public static final String FIREWALL_CHAIN_NAME_DOZABLE = "dozable"; |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 145 | /** @hide */ |
Xiaohui Chen | b41c9f7 | 2015-06-17 15:55:37 -0700 | [diff] [blame] | 146 | public static final String FIREWALL_CHAIN_NAME_STANDBY = "standby"; |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 147 | /** @hide */ |
Felipe Leme | 011b98f | 2016-02-10 17:28:31 -0800 | [diff] [blame] | 148 | public static final String FIREWALL_CHAIN_NAME_POWERSAVE = "powersave"; |
Xiaohui Chen | b41c9f7 | 2015-06-17 15:55:37 -0700 | [diff] [blame] | 149 | |
Jeff Sharkey | b3f19ca | 2011-06-29 23:54:13 -0700 | [diff] [blame] | 150 | private static final boolean ALLOW_PLATFORM_APP_POLICY = true; |
| 151 | |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 152 | /** @hide */ |
Sudheer Shanka | d993dcf | 2018-02-11 12:22:16 -0800 | [diff] [blame] | 153 | public static final int FOREGROUND_THRESHOLD_STATE = |
| 154 | ActivityManager.PROCESS_STATE_BOUND_FOREGROUND_SERVICE; |
| 155 | |
Jeff Sharkey | 14711eb5 | 2011-06-15 10:29:17 -0700 | [diff] [blame] | 156 | /** |
Jeff Sharkey | 41ff7ec | 2011-07-25 15:21:22 -0700 | [diff] [blame] | 157 | * {@link Intent} extra that indicates which {@link NetworkTemplate} rule it |
| 158 | * applies to. |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 159 | * @hide |
Jeff Sharkey | 14711eb5 | 2011-06-15 10:29:17 -0700 | [diff] [blame] | 160 | */ |
Jeff Sharkey | 41ff7ec | 2011-07-25 15:21:22 -0700 | [diff] [blame] | 161 | public static final String EXTRA_NETWORK_TEMPLATE = "android.net.NETWORK_TEMPLATE"; |
Jeff Sharkey | 14711eb5 | 2011-06-15 10:29:17 -0700 | [diff] [blame] | 162 | |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 163 | /** |
| 164 | * Mask used to check if an override value is marked as unmetered. |
| 165 | */ |
| 166 | public static final int SUBSCRIPTION_OVERRIDE_UNMETERED = 1 << 0; |
| 167 | |
| 168 | /** |
| 169 | * Mask used to check if an override value is marked as congested. |
| 170 | */ |
| 171 | public static final int SUBSCRIPTION_OVERRIDE_CONGESTED = 1 << 1; |
| 172 | |
| 173 | /** |
| 174 | * @hide |
| 175 | */ |
| 176 | @Retention(RetentionPolicy.SOURCE) |
| 177 | @IntDef(flag = true, prefix = { "SUBSCRIPTION_OVERRIDE_" }, value = { |
| 178 | SUBSCRIPTION_OVERRIDE_UNMETERED, |
| 179 | SUBSCRIPTION_OVERRIDE_CONGESTED |
| 180 | }) |
| 181 | public @interface SubscriptionOverrideMask {} |
Jeff Sharkey | 75d3189 | 2018-01-18 22:01:59 +0900 | [diff] [blame] | 182 | |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 183 | private final Context mContext; |
Mathew Inwood | fa3a746 | 2018-08-08 14:52:47 +0100 | [diff] [blame] | 184 | @UnsupportedAppUsage |
Jeff Sharkey | d5cdd59 | 2011-05-03 20:27:17 -0700 | [diff] [blame] | 185 | private INetworkPolicyManager mService; |
| 186 | |
Aaron Huang | 9204f46 | 2019-12-25 00:26:47 +0800 | [diff] [blame] | 187 | private final Map<SubscriptionCallback, SubscriptionCallbackProxy> |
| 188 | mCallbackMap = new ConcurrentHashMap<>(); |
| 189 | |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 190 | /** @hide */ |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 191 | public NetworkPolicyManager(Context context, INetworkPolicyManager service) { |
Jeff Sharkey | d5cdd59 | 2011-05-03 20:27:17 -0700 | [diff] [blame] | 192 | if (service == null) { |
| 193 | throw new IllegalArgumentException("missing INetworkPolicyManager"); |
| 194 | } |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 195 | mContext = context; |
Jeff Sharkey | d5cdd59 | 2011-05-03 20:27:17 -0700 | [diff] [blame] | 196 | mService = service; |
| 197 | } |
| 198 | |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 199 | /** @hide */ |
Mathew Inwood | fa3a746 | 2018-08-08 14:52:47 +0100 | [diff] [blame] | 200 | @UnsupportedAppUsage |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame] | 201 | public static NetworkPolicyManager from(Context context) { |
Jeff Sharkey | eedcb95 | 2011-05-17 14:55:15 -0700 | [diff] [blame] | 202 | return (NetworkPolicyManager) context.getSystemService(Context.NETWORK_POLICY_SERVICE); |
| 203 | } |
| 204 | |
Jeff Sharkey | d5cdd59 | 2011-05-03 20:27:17 -0700 | [diff] [blame] | 205 | /** |
Jeff Sharkey | d0c6ccb | 2012-09-14 16:26:37 -0700 | [diff] [blame] | 206 | * Set policy flags for specific UID. |
Jeff Sharkey | d5cdd59 | 2011-05-03 20:27:17 -0700 | [diff] [blame] | 207 | * |
Felipe Leme | 8546a44 | 2016-08-23 09:38:20 -0700 | [diff] [blame] | 208 | * @param policy should be {@link #POLICY_NONE} or any combination of {@code POLICY_} flags, |
| 209 | * although it is not validated. |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 210 | * @hide |
Jeff Sharkey | d5cdd59 | 2011-05-03 20:27:17 -0700 | [diff] [blame] | 211 | */ |
Mathew Inwood | fa3a746 | 2018-08-08 14:52:47 +0100 | [diff] [blame] | 212 | @UnsupportedAppUsage |
Jeff Sharkey | d0c6ccb | 2012-09-14 16:26:37 -0700 | [diff] [blame] | 213 | public void setUidPolicy(int uid, int policy) { |
Jeff Sharkey | d5cdd59 | 2011-05-03 20:27:17 -0700 | [diff] [blame] | 214 | try { |
Jeff Sharkey | d0c6ccb | 2012-09-14 16:26:37 -0700 | [diff] [blame] | 215 | mService.setUidPolicy(uid, policy); |
Jeff Sharkey | d5cdd59 | 2011-05-03 20:27:17 -0700 | [diff] [blame] | 216 | } catch (RemoteException e) { |
Jeff Sharkey | f888056 | 2016-02-26 13:03:01 -0700 | [diff] [blame] | 217 | throw e.rethrowFromSystemServer(); |
Jeff Sharkey | d5cdd59 | 2011-05-03 20:27:17 -0700 | [diff] [blame] | 218 | } |
| 219 | } |
| 220 | |
Dianne Hackborn | be7c50e | 2014-06-30 14:43:28 -0700 | [diff] [blame] | 221 | /** |
Felipe Leme | 8546a44 | 2016-08-23 09:38:20 -0700 | [diff] [blame] | 222 | * Add policy flags for specific UID. |
| 223 | * |
| 224 | * <p>The given policy bits will be set for the uid. |
| 225 | * |
| 226 | * @param policy should be {@link #POLICY_NONE} or any combination of {@code POLICY_} flags, |
| 227 | * although it is not validated. |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 228 | * @hide |
Dianne Hackborn | be7c50e | 2014-06-30 14:43:28 -0700 | [diff] [blame] | 229 | */ |
| 230 | public void addUidPolicy(int uid, int policy) { |
| 231 | try { |
| 232 | mService.addUidPolicy(uid, policy); |
| 233 | } catch (RemoteException e) { |
Jeff Sharkey | f888056 | 2016-02-26 13:03:01 -0700 | [diff] [blame] | 234 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | be7c50e | 2014-06-30 14:43:28 -0700 | [diff] [blame] | 235 | } |
| 236 | } |
| 237 | |
| 238 | /** |
Felipe Leme | 8546a44 | 2016-08-23 09:38:20 -0700 | [diff] [blame] | 239 | * Clear/remove policy flags for specific UID. |
| 240 | * |
| 241 | * <p>The given policy bits will be set for the uid. |
| 242 | * |
| 243 | * @param policy should be {@link #POLICY_NONE} or any combination of {@code POLICY_} flags, |
| 244 | * although it is not validated. |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 245 | * @hide |
Dianne Hackborn | be7c50e | 2014-06-30 14:43:28 -0700 | [diff] [blame] | 246 | */ |
| 247 | public void removeUidPolicy(int uid, int policy) { |
| 248 | try { |
| 249 | mService.removeUidPolicy(uid, policy); |
| 250 | } catch (RemoteException e) { |
Jeff Sharkey | f888056 | 2016-02-26 13:03:01 -0700 | [diff] [blame] | 251 | throw e.rethrowFromSystemServer(); |
Dianne Hackborn | be7c50e | 2014-06-30 14:43:28 -0700 | [diff] [blame] | 252 | } |
| 253 | } |
| 254 | |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 255 | /** @hide */ |
Mathew Inwood | fa3a746 | 2018-08-08 14:52:47 +0100 | [diff] [blame] | 256 | @UnsupportedAppUsage |
Jeff Sharkey | d0c6ccb | 2012-09-14 16:26:37 -0700 | [diff] [blame] | 257 | public int getUidPolicy(int uid) { |
Jeff Sharkey | d5cdd59 | 2011-05-03 20:27:17 -0700 | [diff] [blame] | 258 | try { |
Jeff Sharkey | d0c6ccb | 2012-09-14 16:26:37 -0700 | [diff] [blame] | 259 | return mService.getUidPolicy(uid); |
Jeff Sharkey | d5cdd59 | 2011-05-03 20:27:17 -0700 | [diff] [blame] | 260 | } catch (RemoteException e) { |
Jeff Sharkey | f888056 | 2016-02-26 13:03:01 -0700 | [diff] [blame] | 261 | throw e.rethrowFromSystemServer(); |
Jeff Sharkey | d5cdd59 | 2011-05-03 20:27:17 -0700 | [diff] [blame] | 262 | } |
| 263 | } |
Jeff Sharkey | cd2ca40 | 2011-06-10 15:14:07 -0700 | [diff] [blame] | 264 | |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 265 | /** @hide */ |
Mathew Inwood | fa3a746 | 2018-08-08 14:52:47 +0100 | [diff] [blame] | 266 | @UnsupportedAppUsage |
Jeff Sharkey | d0c6ccb | 2012-09-14 16:26:37 -0700 | [diff] [blame] | 267 | public int[] getUidsWithPolicy(int policy) { |
Jeff Sharkey | 854b2b1 | 2012-04-13 16:03:40 -0700 | [diff] [blame] | 268 | try { |
Jeff Sharkey | d0c6ccb | 2012-09-14 16:26:37 -0700 | [diff] [blame] | 269 | return mService.getUidsWithPolicy(policy); |
Jeff Sharkey | 854b2b1 | 2012-04-13 16:03:40 -0700 | [diff] [blame] | 270 | } catch (RemoteException e) { |
Jeff Sharkey | f888056 | 2016-02-26 13:03:01 -0700 | [diff] [blame] | 271 | throw e.rethrowFromSystemServer(); |
Jeff Sharkey | 854b2b1 | 2012-04-13 16:03:40 -0700 | [diff] [blame] | 272 | } |
| 273 | } |
| 274 | |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 275 | /** @hide */ |
Mathew Inwood | 31755f9 | 2018-12-20 13:53:36 +0000 | [diff] [blame] | 276 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Jeff Sharkey | 1a30395 | 2011-06-16 13:04:20 -0700 | [diff] [blame] | 277 | public void registerListener(INetworkPolicyListener listener) { |
| 278 | try { |
| 279 | mService.registerListener(listener); |
| 280 | } catch (RemoteException e) { |
Jeff Sharkey | f888056 | 2016-02-26 13:03:01 -0700 | [diff] [blame] | 281 | throw e.rethrowFromSystemServer(); |
Jeff Sharkey | 1a30395 | 2011-06-16 13:04:20 -0700 | [diff] [blame] | 282 | } |
| 283 | } |
| 284 | |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 285 | /** @hide */ |
Mathew Inwood | 31755f9 | 2018-12-20 13:53:36 +0000 | [diff] [blame] | 286 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Jeff Sharkey | 1a30395 | 2011-06-16 13:04:20 -0700 | [diff] [blame] | 287 | public void unregisterListener(INetworkPolicyListener listener) { |
| 288 | try { |
| 289 | mService.unregisterListener(listener); |
| 290 | } catch (RemoteException e) { |
Jeff Sharkey | f888056 | 2016-02-26 13:03:01 -0700 | [diff] [blame] | 291 | throw e.rethrowFromSystemServer(); |
Jeff Sharkey | 1a30395 | 2011-06-16 13:04:20 -0700 | [diff] [blame] | 292 | } |
| 293 | } |
| 294 | |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 295 | /** @hide */ |
Aaron Huang | 9204f46 | 2019-12-25 00:26:47 +0800 | [diff] [blame] | 296 | @RequiresPermission(android.Manifest.permission.OBSERVE_NETWORK_POLICY) |
| 297 | @SystemApi |
| 298 | public void registerSubscriptionCallback(@NonNull SubscriptionCallback callback) { |
| 299 | if (callback == null) { |
| 300 | throw new NullPointerException("Callback cannot be null."); |
| 301 | } |
| 302 | |
| 303 | final SubscriptionCallbackProxy callbackProxy = new SubscriptionCallbackProxy(callback); |
| 304 | if (null != mCallbackMap.putIfAbsent(callback, callbackProxy)) { |
| 305 | throw new IllegalArgumentException("Callback is already registered."); |
| 306 | } |
| 307 | registerListener(callbackProxy); |
| 308 | } |
| 309 | |
| 310 | /** @hide */ |
| 311 | @RequiresPermission(android.Manifest.permission.OBSERVE_NETWORK_POLICY) |
| 312 | @SystemApi |
| 313 | public void unregisterSubscriptionCallback(@NonNull SubscriptionCallback callback) { |
| 314 | if (callback == null) { |
| 315 | throw new NullPointerException("Callback cannot be null."); |
| 316 | } |
| 317 | |
| 318 | final SubscriptionCallbackProxy callbackProxy = mCallbackMap.remove(callback); |
| 319 | if (callbackProxy == null) return; |
| 320 | |
| 321 | unregisterListener(callbackProxy); |
| 322 | } |
| 323 | |
| 324 | /** @hide */ |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame] | 325 | public void setNetworkPolicies(NetworkPolicy[] policies) { |
| 326 | try { |
| 327 | mService.setNetworkPolicies(policies); |
| 328 | } catch (RemoteException e) { |
Jeff Sharkey | f888056 | 2016-02-26 13:03:01 -0700 | [diff] [blame] | 329 | throw e.rethrowFromSystemServer(); |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame] | 330 | } |
| 331 | } |
| 332 | |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 333 | /** @hide */ |
Mathew Inwood | fa3a746 | 2018-08-08 14:52:47 +0100 | [diff] [blame] | 334 | @UnsupportedAppUsage |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame] | 335 | public NetworkPolicy[] getNetworkPolicies() { |
| 336 | try { |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 337 | return mService.getNetworkPolicies(mContext.getOpPackageName()); |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame] | 338 | } catch (RemoteException e) { |
Jeff Sharkey | f888056 | 2016-02-26 13:03:01 -0700 | [diff] [blame] | 339 | throw e.rethrowFromSystemServer(); |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame] | 340 | } |
| 341 | } |
| 342 | |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 343 | /** @hide */ |
Mathew Inwood | fa3a746 | 2018-08-08 14:52:47 +0100 | [diff] [blame] | 344 | @UnsupportedAppUsage |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame] | 345 | public void setRestrictBackground(boolean restrictBackground) { |
| 346 | try { |
| 347 | mService.setRestrictBackground(restrictBackground); |
| 348 | } catch (RemoteException e) { |
Jeff Sharkey | f888056 | 2016-02-26 13:03:01 -0700 | [diff] [blame] | 349 | throw e.rethrowFromSystemServer(); |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame] | 350 | } |
| 351 | } |
| 352 | |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 353 | /** @hide */ |
Mathew Inwood | fa3a746 | 2018-08-08 14:52:47 +0100 | [diff] [blame] | 354 | @UnsupportedAppUsage |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame] | 355 | public boolean getRestrictBackground() { |
| 356 | try { |
| 357 | return mService.getRestrictBackground(); |
| 358 | } catch (RemoteException e) { |
Jeff Sharkey | f888056 | 2016-02-26 13:03:01 -0700 | [diff] [blame] | 359 | throw e.rethrowFromSystemServer(); |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame] | 360 | } |
| 361 | } |
| 362 | |
Jeff Sharkey | cd2ca40 | 2011-06-10 15:14:07 -0700 | [diff] [blame] | 363 | /** |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 364 | * Override connections to be temporarily marked as either unmetered or congested, |
| 365 | * along with automatic timeouts if desired. |
| 366 | * |
| 367 | * @param subId the subscriber ID this override applies to. |
| 368 | * @param overrideMask the bitmask that specifies which of the overrides is being |
| 369 | * set or cleared. |
| 370 | * @param overrideValue the override values to set or clear. |
| 371 | * @param timeoutMillis the timeout after which the requested override will |
| 372 | * be automatically cleared, or {@code 0} to leave in the |
| 373 | * requested state until explicitly cleared, or the next reboot, |
| 374 | * whichever happens first |
| 375 | * @param callingPackage the name of the package making the call. |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 376 | */ |
| 377 | public void setSubscriptionOverride(int subId, @SubscriptionOverrideMask int overrideMask, |
| 378 | @SubscriptionOverrideMask int overrideValue, long timeoutMillis, |
| 379 | @NonNull String callingPackage) { |
| 380 | try { |
| 381 | mService.setSubscriptionOverride(subId, overrideMask, overrideValue, timeoutMillis, |
| 382 | callingPackage); |
| 383 | } catch (RemoteException e) { |
| 384 | throw e.rethrowFromSystemServer(); |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | /** |
Aaron Huang | 58d9559 | 2020-01-16 21:53:55 +0800 | [diff] [blame] | 389 | * Set the subscription plans for a specific subscriber. |
| 390 | * |
| 391 | * @param subId the subscriber this relationship applies to. |
| 392 | * @param plans the list of plans. |
| 393 | * @param callingPackage the name of the package making the call |
| 394 | */ |
| 395 | public void setSubscriptionPlans(int subId, @NonNull SubscriptionPlan[] plans, |
| 396 | @NonNull String callingPackage) { |
| 397 | try { |
| 398 | mService.setSubscriptionPlans(subId, plans, callingPackage); |
| 399 | } catch (RemoteException e) { |
| 400 | throw e.rethrowFromSystemServer(); |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | /** |
| 405 | * Get subscription plans for the given subscription id. |
| 406 | * |
| 407 | * @param subId the subscriber to get the subscription plans for. |
| 408 | * @param callingPackage the name of the package making the call. |
| 409 | */ |
| 410 | @NonNull |
| 411 | public SubscriptionPlan[] getSubscriptionPlans(int subId, @NonNull String callingPackage) { |
| 412 | try { |
| 413 | return mService.getSubscriptionPlans(subId, callingPackage); |
| 414 | } catch (RemoteException e) { |
| 415 | throw e.rethrowFromSystemServer(); |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | /** |
Stuart Scott | 984dc85 | 2015-03-30 13:17:11 -0700 | [diff] [blame] | 420 | * Resets network policy settings back to factory defaults. |
| 421 | * |
| 422 | * @hide |
| 423 | */ |
| 424 | public void factoryReset(String subscriber) { |
Stuart Scott | f1fb397 | 2015-04-02 18:00:02 -0700 | [diff] [blame] | 425 | try { |
| 426 | mService.factoryReset(subscriber); |
| 427 | } catch (RemoteException e) { |
Jeff Sharkey | f888056 | 2016-02-26 13:03:01 -0700 | [diff] [blame] | 428 | throw e.rethrowFromSystemServer(); |
Stuart Scott | 984dc85 | 2015-03-30 13:17:11 -0700 | [diff] [blame] | 429 | } |
| 430 | } |
| 431 | |
Jeff Sharkey | cd2ca40 | 2011-06-10 15:14:07 -0700 | [diff] [blame] | 432 | /** {@hide} */ |
Jeff Sharkey | 0fc6d03 | 2018-03-30 16:25:11 -0600 | [diff] [blame] | 433 | @Deprecated |
Jeff Sharkey | 53313d7 | 2017-07-13 16:47:32 -0600 | [diff] [blame] | 434 | public static Iterator<Pair<ZonedDateTime, ZonedDateTime>> cycleIterator(NetworkPolicy policy) { |
Jeff Sharkey | 0fc6d03 | 2018-03-30 16:25:11 -0600 | [diff] [blame] | 435 | final Iterator<Range<ZonedDateTime>> it = policy.cycleIterator(); |
| 436 | return new Iterator<Pair<ZonedDateTime, ZonedDateTime>>() { |
| 437 | @Override |
| 438 | public boolean hasNext() { |
| 439 | return it.hasNext(); |
| 440 | } |
| 441 | |
| 442 | @Override |
| 443 | public Pair<ZonedDateTime, ZonedDateTime> next() { |
Jeff Sharkey | e67463d | 2018-04-13 14:38:01 -0600 | [diff] [blame] | 444 | if (hasNext()) { |
| 445 | final Range<ZonedDateTime> r = it.next(); |
| 446 | return Pair.create(r.getLower(), r.getUpper()); |
| 447 | } else { |
| 448 | return Pair.create(null, null); |
| 449 | } |
Jeff Sharkey | 0fc6d03 | 2018-03-30 16:25:11 -0600 | [diff] [blame] | 450 | } |
| 451 | }; |
Jeff Sharkey | cd2ca40 | 2011-06-10 15:14:07 -0700 | [diff] [blame] | 452 | } |
| 453 | |
Jeff Sharkey | 497e443 | 2011-06-14 17:27:29 -0700 | [diff] [blame] | 454 | /** |
| 455 | * Check if given UID can have a {@link #setUidPolicy(int, int)} defined, |
| 456 | * usually to protect critical system services. |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 457 | * @hide |
Jeff Sharkey | 497e443 | 2011-06-14 17:27:29 -0700 | [diff] [blame] | 458 | */ |
Jeff Sharkey | 8a8b581 | 2012-03-21 18:13:36 -0700 | [diff] [blame] | 459 | @Deprecated |
Jeff Sharkey | 497e443 | 2011-06-14 17:27:29 -0700 | [diff] [blame] | 460 | public static boolean isUidValidForPolicy(Context context, int uid) { |
Jeff Sharkey | 4414cea | 2011-06-24 17:05:24 -0700 | [diff] [blame] | 461 | // first, quick-reject non-applications |
Jeff Sharkey | d0c6ccb | 2012-09-14 16:26:37 -0700 | [diff] [blame] | 462 | if (!UserHandle.isApp(uid)) { |
Jeff Sharkey | 4414cea | 2011-06-24 17:05:24 -0700 | [diff] [blame] | 463 | return false; |
| 464 | } |
| 465 | |
Jeff Sharkey | b3f19ca | 2011-06-29 23:54:13 -0700 | [diff] [blame] | 466 | if (!ALLOW_PLATFORM_APP_POLICY) { |
| 467 | final PackageManager pm = context.getPackageManager(); |
| 468 | final HashSet<Signature> systemSignature; |
| 469 | try { |
| 470 | systemSignature = Sets.newHashSet( |
| 471 | pm.getPackageInfo("android", GET_SIGNATURES).signatures); |
| 472 | } catch (NameNotFoundException e) { |
| 473 | throw new RuntimeException("problem finding system signature", e); |
Jeff Sharkey | 4414cea | 2011-06-24 17:05:24 -0700 | [diff] [blame] | 474 | } |
Jeff Sharkey | b3f19ca | 2011-06-29 23:54:13 -0700 | [diff] [blame] | 475 | |
| 476 | try { |
| 477 | // reject apps signed with platform cert |
| 478 | for (String packageName : pm.getPackagesForUid(uid)) { |
| 479 | final HashSet<Signature> packageSignature = Sets.newHashSet( |
| 480 | pm.getPackageInfo(packageName, GET_SIGNATURES).signatures); |
| 481 | if (packageSignature.containsAll(systemSignature)) { |
| 482 | return false; |
| 483 | } |
| 484 | } |
| 485 | } catch (NameNotFoundException e) { |
| 486 | } |
Jeff Sharkey | 4414cea | 2011-06-24 17:05:24 -0700 | [diff] [blame] | 487 | } |
| 488 | |
| 489 | // nothing found above; we can apply policy to UID |
| 490 | return true; |
Jeff Sharkey | 497e443 | 2011-06-14 17:27:29 -0700 | [diff] [blame] | 491 | } |
Felipe Leme | 46c4fc3 | 2016-05-04 09:21:43 -0700 | [diff] [blame] | 492 | |
Felipe Leme | b146f76 | 2016-08-19 09:52:16 -0700 | [diff] [blame] | 493 | /** |
Felipe Leme | 46c4fc3 | 2016-05-04 09:21:43 -0700 | [diff] [blame] | 494 | * @hide |
| 495 | */ |
| 496 | public static String uidRulesToString(int uidRules) { |
| 497 | final StringBuilder string = new StringBuilder().append(uidRules).append(" ("); |
| 498 | if (uidRules == RULE_NONE) { |
| 499 | string.append("NONE"); |
| 500 | } else { |
| 501 | string.append(DebugUtils.flagsToString(NetworkPolicyManager.class, "RULE_", uidRules)); |
| 502 | } |
| 503 | string.append(")"); |
| 504 | return string.toString(); |
| 505 | } |
Felipe Leme | b146f76 | 2016-08-19 09:52:16 -0700 | [diff] [blame] | 506 | |
| 507 | /** |
| 508 | * @hide |
| 509 | */ |
| 510 | public static String uidPoliciesToString(int uidPolicies) { |
| 511 | final StringBuilder string = new StringBuilder().append(uidPolicies).append(" ("); |
| 512 | if (uidPolicies == POLICY_NONE) { |
| 513 | string.append("NONE"); |
| 514 | } else { |
| 515 | string.append(DebugUtils.flagsToString(NetworkPolicyManager.class, |
| 516 | "POLICY_", uidPolicies)); |
| 517 | } |
| 518 | string.append(")"); |
| 519 | return string.toString(); |
| 520 | } |
Sudheer Shanka | e359c3d | 2017-02-22 18:41:29 -0800 | [diff] [blame] | 521 | |
| 522 | /** |
| 523 | * Returns true if {@param procState} is considered foreground and as such will be allowed |
| 524 | * to access network when the device is idle or in battery saver mode. Otherwise, false. |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 525 | * @hide |
Sudheer Shanka | e359c3d | 2017-02-22 18:41:29 -0800 | [diff] [blame] | 526 | */ |
| 527 | public static boolean isProcStateAllowedWhileIdleOrPowerSaveMode(int procState) { |
Sudheer Shanka | d993dcf | 2018-02-11 12:22:16 -0800 | [diff] [blame] | 528 | return procState <= FOREGROUND_THRESHOLD_STATE; |
Sudheer Shanka | e359c3d | 2017-02-22 18:41:29 -0800 | [diff] [blame] | 529 | } |
| 530 | |
| 531 | /** |
| 532 | * Returns true if {@param procState} is considered foreground and as such will be allowed |
| 533 | * to access network when the device is in data saver mode. Otherwise, false. |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 534 | * @hide |
Sudheer Shanka | e359c3d | 2017-02-22 18:41:29 -0800 | [diff] [blame] | 535 | */ |
| 536 | public static boolean isProcStateAllowedWhileOnRestrictBackground(int procState) { |
Sudheer Shanka | d993dcf | 2018-02-11 12:22:16 -0800 | [diff] [blame] | 537 | return procState <= FOREGROUND_THRESHOLD_STATE; |
Sudheer Shanka | e359c3d | 2017-02-22 18:41:29 -0800 | [diff] [blame] | 538 | } |
Jeff Sharkey | 43d2a17 | 2017-07-12 10:50:42 -0600 | [diff] [blame] | 539 | |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 540 | /** @hide */ |
Jeff Sharkey | 43d2a17 | 2017-07-12 10:50:42 -0600 | [diff] [blame] | 541 | public static String resolveNetworkId(WifiConfiguration config) { |
David Su | b4d222a | 2020-01-27 13:27:50 -0800 | [diff] [blame] | 542 | return WifiInfo.sanitizeSsid(config.isPasspoint() |
Jeff Sharkey | 43d2a17 | 2017-07-12 10:50:42 -0600 | [diff] [blame] | 543 | ? config.providerFriendlyName : config.SSID); |
| 544 | } |
| 545 | |
Aaron Huang | 2d471ca | 2019-12-30 20:11:36 +0800 | [diff] [blame] | 546 | /** @hide */ |
Jeff Sharkey | 43d2a17 | 2017-07-12 10:50:42 -0600 | [diff] [blame] | 547 | public static String resolveNetworkId(String ssid) { |
David Su | b4d222a | 2020-01-27 13:27:50 -0800 | [diff] [blame] | 548 | return WifiInfo.sanitizeSsid(ssid); |
Jeff Sharkey | 43d2a17 | 2017-07-12 10:50:42 -0600 | [diff] [blame] | 549 | } |
Jeff Sharkey | 75d3189 | 2018-01-18 22:01:59 +0900 | [diff] [blame] | 550 | |
Aaron Huang | 9204f46 | 2019-12-25 00:26:47 +0800 | [diff] [blame] | 551 | /** @hide */ |
| 552 | @SystemApi |
| 553 | public static class SubscriptionCallback { |
| 554 | /** |
| 555 | * Notify clients of a new override about a given subscription. |
| 556 | * |
| 557 | * @param subId the subscriber this override applies to. |
| 558 | * @param overrideMask a bitmask that specifies which of the overrides is set. |
| 559 | * @param overrideValue a bitmask that specifies the override values. |
| 560 | */ |
| 561 | public void onSubscriptionOverride(int subId, @SubscriptionOverrideMask int overrideMask, |
| 562 | @SubscriptionOverrideMask int overrideValue) {} |
| 563 | |
| 564 | /** |
| 565 | * Notify of subscription plans change about a given subscription. |
| 566 | * |
| 567 | * @param subId the subscriber id that got subscription plans change. |
| 568 | * @param plans the list of subscription plans. |
| 569 | */ |
| 570 | public void onSubscriptionPlansChanged(int subId, @NonNull SubscriptionPlan[] plans) {} |
| 571 | } |
| 572 | |
| 573 | /** |
| 574 | * SubscriptionCallback proxy for SubscriptionCallback object. |
| 575 | * @hide |
| 576 | */ |
| 577 | public class SubscriptionCallbackProxy extends Listener { |
| 578 | private final SubscriptionCallback mCallback; |
| 579 | |
| 580 | SubscriptionCallbackProxy(SubscriptionCallback callback) { |
| 581 | mCallback = callback; |
| 582 | } |
| 583 | |
| 584 | @Override |
| 585 | public void onSubscriptionOverride(int subId, @SubscriptionOverrideMask int overrideMask, |
| 586 | @SubscriptionOverrideMask int overrideValue) { |
| 587 | mCallback.onSubscriptionOverride(subId, overrideMask, overrideValue); |
| 588 | } |
| 589 | |
| 590 | @Override |
| 591 | public void onSubscriptionPlansChanged(int subId, SubscriptionPlan[] plans) { |
| 592 | mCallback.onSubscriptionPlansChanged(subId, plans); |
| 593 | } |
| 594 | } |
| 595 | |
Jeff Sharkey | 75d3189 | 2018-01-18 22:01:59 +0900 | [diff] [blame] | 596 | /** {@hide} */ |
| 597 | public static class Listener extends INetworkPolicyListener.Stub { |
| 598 | @Override public void onUidRulesChanged(int uid, int uidRules) { } |
| 599 | @Override public void onMeteredIfacesChanged(String[] meteredIfaces) { } |
| 600 | @Override public void onRestrictBackgroundChanged(boolean restrictBackground) { } |
| 601 | @Override public void onUidPoliciesChanged(int uid, int uidPolicies) { } |
Sarah Chin | 7af1fd0 | 2019-09-26 11:37:13 -0700 | [diff] [blame] | 602 | @Override public void onSubscriptionOverride(int subId, int overrideMask, |
| 603 | int overrideValue) { } |
| 604 | @Override public void onSubscriptionPlansChanged(int subId, SubscriptionPlan[] plans) { } |
Jeff Sharkey | 75d3189 | 2018-01-18 22:01:59 +0900 | [diff] [blame] | 605 | } |
Jeff Sharkey | d5cdd59 | 2011-05-03 20:27:17 -0700 | [diff] [blame] | 606 | } |