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.NetworkPolicy;
21 import android.net.NetworkQuotaInfo;
22 import android.net.NetworkState;
23 import android.net.NetworkTemplate;
24 import android.telephony.SubscriptionPlan;
25 
26 /**
27  * Interface that creates and modifies network policy rules.
28  *
29  * {@hide}
30  */
31 interface INetworkPolicyManager {
32 
33     /** Control UID policies. */
setUidPolicy(int uid, int policy)34     void setUidPolicy(int uid, int policy);
addUidPolicy(int uid, int policy)35     void addUidPolicy(int uid, int policy);
removeUidPolicy(int uid, int policy)36     void removeUidPolicy(int uid, int policy);
getUidPolicy(int uid)37     int getUidPolicy(int uid);
getUidsWithPolicy(int policy)38     int[] getUidsWithPolicy(int policy);
39 
registerListener(INetworkPolicyListener listener)40     void registerListener(INetworkPolicyListener listener);
unregisterListener(INetworkPolicyListener listener)41     void unregisterListener(INetworkPolicyListener listener);
42 
43     /** Control network policies atomically. */
setNetworkPolicies(in NetworkPolicy[] policies)44     void setNetworkPolicies(in NetworkPolicy[] policies);
getNetworkPolicies(String callingPackage)45     NetworkPolicy[] getNetworkPolicies(String callingPackage);
46 
47     /** Snooze limit on policy matching given template. */
snoozeLimit(in NetworkTemplate template)48     void snoozeLimit(in NetworkTemplate template);
49 
50     /** Control if background data is restricted system-wide. */
setRestrictBackground(boolean restrictBackground)51     void setRestrictBackground(boolean restrictBackground);
getRestrictBackground()52     boolean getRestrictBackground();
53 
54     /** Callback used to change internal state on tethering */
onTetheringChanged(String iface, boolean tethering)55     void onTetheringChanged(String iface, boolean tethering);
56 
57     /** Gets the restrict background status based on the caller's UID:
58         1 - disabled
59         2 - whitelisted
60         3 - enabled
61     */
getRestrictBackgroundByCaller()62     int getRestrictBackgroundByCaller();
63 
setDeviceIdleMode(boolean enabled)64     void setDeviceIdleMode(boolean enabled);
setWifiMeteredOverride(String networkId, int meteredOverride)65     void setWifiMeteredOverride(String networkId, int meteredOverride);
66 
getNetworkQuotaInfo(in NetworkState state)67     NetworkQuotaInfo getNetworkQuotaInfo(in NetworkState state);
68 
getSubscriptionPlans(int subId, String callingPackage)69     SubscriptionPlan[] getSubscriptionPlans(int subId, String callingPackage);
setSubscriptionPlans(int subId, in SubscriptionPlan[] plans, String callingPackage)70     void setSubscriptionPlans(int subId, in SubscriptionPlan[] plans, String callingPackage);
getSubscriptionPlansOwner(int subId)71     String getSubscriptionPlansOwner(int subId);
setSubscriptionOverride(int subId, int overrideMask, int overrideValue, long timeoutMillis, String callingPackage)72     void setSubscriptionOverride(int subId, int overrideMask, int overrideValue, long timeoutMillis, String callingPackage);
73 
factoryReset(String subscriber)74     void factoryReset(String subscriber);
75 
isUidNetworkingBlocked(int uid, boolean meteredNetwork)76     boolean isUidNetworkingBlocked(int uid, boolean meteredNetwork);
77 }
78