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 19 import android.net.INetworkPolicyListener; 20 import android.net.Network; 21 import android.net.NetworkPolicy; 22 import android.net.NetworkTemplate; 23 import android.telephony.SubscriptionPlan; 24 25 /** 26 * Interface that creates and modifies network policy rules. 27 * 28 * {@hide} 29 */ 30 interface INetworkPolicyManager { 31 32 /** Control UID policies. */ 33 @EnforcePermission("MANAGE_NETWORK_POLICY") 34 @UnsupportedAppUsage setUidPolicy(int uid, int policy)35 void setUidPolicy(int uid, int policy); 36 @EnforcePermission("MANAGE_NETWORK_POLICY") addUidPolicy(int uid, int policy)37 void addUidPolicy(int uid, int policy); 38 @EnforcePermission("MANAGE_NETWORK_POLICY") removeUidPolicy(int uid, int policy)39 void removeUidPolicy(int uid, int policy); 40 @EnforcePermission("MANAGE_NETWORK_POLICY") 41 @UnsupportedAppUsage getUidPolicy(int uid)42 int getUidPolicy(int uid); 43 @EnforcePermission("MANAGE_NETWORK_POLICY") getUidsWithPolicy(int policy)44 int[] getUidsWithPolicy(int policy); 45 registerListener(INetworkPolicyListener listener)46 void registerListener(INetworkPolicyListener listener); unregisterListener(INetworkPolicyListener listener)47 void unregisterListener(INetworkPolicyListener listener); 48 49 /** Control network policies atomically. */ 50 @EnforcePermission("MANAGE_NETWORK_POLICY") 51 @UnsupportedAppUsage setNetworkPolicies(in NetworkPolicy[] policies)52 void setNetworkPolicies(in NetworkPolicy[] policies); 53 @EnforcePermission("MANAGE_NETWORK_POLICY") getNetworkPolicies(String callingPackage)54 NetworkPolicy[] getNetworkPolicies(String callingPackage); 55 56 /** Snooze limit on policy matching given template. */ 57 @EnforcePermission("MANAGE_NETWORK_POLICY") 58 @UnsupportedAppUsage snoozeLimit(in NetworkTemplate template)59 void snoozeLimit(in NetworkTemplate template); 60 61 /** Control if background data is restricted system-wide. */ 62 @UnsupportedAppUsage setRestrictBackground(boolean restrictBackground)63 void setRestrictBackground(boolean restrictBackground); 64 @EnforcePermission("MANAGE_NETWORK_POLICY") 65 @UnsupportedAppUsage getRestrictBackground()66 boolean getRestrictBackground(); 67 68 /** Gets the restrict background status based on the caller's UID: 69 1 - disabled 70 2 - whitelisted 71 3 - enabled 72 */ 73 @EnforcePermission("ACCESS_NETWORK_STATE") getRestrictBackgroundByCaller()74 int getRestrictBackgroundByCaller(); getRestrictBackgroundStatus(int uid)75 int getRestrictBackgroundStatus(int uid); 76 77 @EnforcePermission("MANAGE_NETWORK_POLICY") setDeviceIdleMode(boolean enabled)78 void setDeviceIdleMode(boolean enabled); 79 @EnforcePermission("MANAGE_NETWORK_POLICY") setWifiMeteredOverride(String networkId, int meteredOverride)80 void setWifiMeteredOverride(String networkId, int meteredOverride); 81 getMultipathPreference(in Network network)82 int getMultipathPreference(in Network network); 83 getSubscriptionPlan(in NetworkTemplate template)84 SubscriptionPlan getSubscriptionPlan(in NetworkTemplate template); notifyStatsProviderWarningOrLimitReached()85 void notifyStatsProviderWarningOrLimitReached(); getSubscriptionPlans(int subId, String callingPackage)86 SubscriptionPlan[] getSubscriptionPlans(int subId, String callingPackage); setSubscriptionPlans(int subId, in SubscriptionPlan[] plans, long expirationDurationMillis, String callingPackage)87 void setSubscriptionPlans(int subId, in SubscriptionPlan[] plans, long expirationDurationMillis, String callingPackage); getSubscriptionPlansOwner(int subId)88 String getSubscriptionPlansOwner(int subId); setSubscriptionOverride(int subId, int overrideMask, int overrideValue, in int[] networkTypes, long expirationDurationMillis, String callingPackage)89 void setSubscriptionOverride(int subId, int overrideMask, int overrideValue, in int[] networkTypes, long expirationDurationMillis, String callingPackage); 90 91 @EnforcePermission("NETWORK_SETTINGS") factoryReset(String subscriber)92 void factoryReset(String subscriber); 93 isUidNetworkingBlocked(int uid, boolean meteredNetwork)94 boolean isUidNetworkingBlocked(int uid, boolean meteredNetwork); 95 @EnforcePermission("OBSERVE_NETWORK_POLICY") isUidRestrictedOnMeteredNetworks(int uid)96 boolean isUidRestrictedOnMeteredNetworks(int uid); 97 } 98