blob: e92302a939d8a386353ee94d53e3b55abd013fef [file] [log] [blame]
Jeff Sharkeyd5cdd592011-05-03 20:27:17 -07001/*
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
17package android.net;
18
Jeff Sharkeyc006f1a2011-05-19 17:12:49 -070019import android.net.INetworkPolicyListener;
Jeff Sharkey21c9c452011-06-07 12:26:43 -070020import android.net.NetworkPolicy;
Jeff Sharkeyf0ceede2011-08-02 17:22:34 -070021import android.net.NetworkQuotaInfo;
22import android.net.NetworkState;
Jeff Sharkey41ff7ec2011-07-25 15:21:22 -070023import android.net.NetworkTemplate;
Jeff Sharkey53313d72017-07-13 16:47:32 -060024import android.telephony.SubscriptionPlan;
Jeff Sharkeyc006f1a2011-05-19 17:12:49 -070025
Jeff Sharkeyd5cdd592011-05-03 20:27:17 -070026/**
27 * Interface that creates and modifies network policy rules.
28 *
29 * {@hide}
30 */
31interface INetworkPolicyManager {
32
Jeff Sharkeyf0ceede2011-08-02 17:22:34 -070033 /** Control UID policies. */
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -070034 void setUidPolicy(int uid, int policy);
Dianne Hackbornbe7c50e2014-06-30 14:43:28 -070035 void addUidPolicy(int uid, int policy);
36 void removeUidPolicy(int uid, int policy);
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -070037 int getUidPolicy(int uid);
38 int[] getUidsWithPolicy(int policy);
Jeff Sharkeyd5cdd592011-05-03 20:27:17 -070039
Jeff Sharkeyc006f1a2011-05-19 17:12:49 -070040 void registerListener(INetworkPolicyListener listener);
41 void unregisterListener(INetworkPolicyListener listener);
42
Jeff Sharkeyf0ceede2011-08-02 17:22:34 -070043 /** Control network policies atomically. */
Jeff Sharkey22c055e2011-06-12 21:13:51 -070044 void setNetworkPolicies(in NetworkPolicy[] policies);
Svet Ganov16a16892015-04-16 10:32:04 -070045 NetworkPolicy[] getNetworkPolicies(String callingPackage);
Jeff Sharkeyd5cdd592011-05-03 20:27:17 -070046
Jeff Sharkeyf0ceede2011-08-02 17:22:34 -070047 /** Snooze limit on policy matching given template. */
Jeff Sharkey0e2e5f82012-02-02 16:02:51 -080048 void snoozeLimit(in NetworkTemplate template);
Jeff Sharkey41ff7ec2011-07-25 15:21:22 -070049
Jeff Sharkeyf0ceede2011-08-02 17:22:34 -070050 /** Control if background data is restricted system-wide. */
Jeff Sharkey46645002011-07-27 21:11:21 -070051 void setRestrictBackground(boolean restrictBackground);
52 boolean getRestrictBackground();
53
Felipe Leme70c8b9b2016-04-25 14:41:31 -070054 /** Callback used to change internal state on tethering */
55 void onTetheringChanged(String iface, boolean tethering);
56
Felipe Leme1b103232016-01-22 09:44:57 -080057 /** Gets the restrict background status based on the caller's UID:
58 1 - disabled
59 2 - whitelisted
60 3 - enabled
61 */
62 int getRestrictBackgroundByCaller();
Felipe Lemeb85a6372016-01-14 16:16:16 -080063
Dianne Hackborn8ad2af72015-03-17 17:00:24 -070064 void setDeviceIdleMode(boolean enabled);
Jeff Sharkey43d2a172017-07-12 10:50:42 -060065 void setWifiMeteredOverride(String networkId, int meteredOverride);
Dianne Hackborn8ad2af72015-03-17 17:00:24 -070066
Jeff Sharkeyf0ceede2011-08-02 17:22:34 -070067 NetworkQuotaInfo getNetworkQuotaInfo(in NetworkState state);
Stuart Scottf1fb3972015-04-02 18:00:02 -070068
Jeff Sharkey53313d72017-07-13 16:47:32 -060069 SubscriptionPlan[] getSubscriptionPlans(int subId, String callingPackage);
70 void setSubscriptionPlans(int subId, in SubscriptionPlan[] plans, String callingPackage);
Jeff Sharkey717f52f2018-01-04 16:04:11 -070071 String getSubscriptionPlansOwner(int subId);
Jeff Sharkey9252b342018-01-19 07:58:35 +090072 void setSubscriptionOverride(int subId, int overrideMask, int overrideValue, long timeoutMillis, String callingPackage);
Jeff Sharkey53313d72017-07-13 16:47:32 -060073
Stuart Scottf1fb3972015-04-02 18:00:02 -070074 void factoryReset(String subscriber);
Sudheer Shankab8f23162017-08-04 13:30:10 -070075
76 boolean isUidNetworkingBlocked(int uid, boolean meteredNetwork);
Jeff Sharkeyd5cdd592011-05-03 20:27:17 -070077}