blob: 385cb1d68b57fc7ab579426407eadb43d654e0b9 [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. */
Andrei Onea9a8b6bf2019-02-25 13:25:32 +000034 @UnsupportedAppUsage
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -070035 void setUidPolicy(int uid, int policy);
Dianne Hackbornbe7c50e2014-06-30 14:43:28 -070036 void addUidPolicy(int uid, int policy);
37 void removeUidPolicy(int uid, int policy);
Andrei Onea9a8b6bf2019-02-25 13:25:32 +000038 @UnsupportedAppUsage
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -070039 int getUidPolicy(int uid);
40 int[] getUidsWithPolicy(int policy);
Jeff Sharkeyd5cdd592011-05-03 20:27:17 -070041
Jeff Sharkeyc006f1a2011-05-19 17:12:49 -070042 void registerListener(INetworkPolicyListener listener);
43 void unregisterListener(INetworkPolicyListener listener);
44
Jeff Sharkeyf0ceede2011-08-02 17:22:34 -070045 /** Control network policies atomically. */
Andrei Onea9a8b6bf2019-02-25 13:25:32 +000046 @UnsupportedAppUsage
Jeff Sharkey22c055e2011-06-12 21:13:51 -070047 void setNetworkPolicies(in NetworkPolicy[] policies);
Svet Ganov16a16892015-04-16 10:32:04 -070048 NetworkPolicy[] getNetworkPolicies(String callingPackage);
Jeff Sharkeyd5cdd592011-05-03 20:27:17 -070049
Jeff Sharkeyf0ceede2011-08-02 17:22:34 -070050 /** Snooze limit on policy matching given template. */
Andrei Onea9a8b6bf2019-02-25 13:25:32 +000051 @UnsupportedAppUsage
Jeff Sharkey0e2e5f82012-02-02 16:02:51 -080052 void snoozeLimit(in NetworkTemplate template);
Jeff Sharkey41ff7ec2011-07-25 15:21:22 -070053
Jeff Sharkeyf0ceede2011-08-02 17:22:34 -070054 /** Control if background data is restricted system-wide. */
Andrei Onea9a8b6bf2019-02-25 13:25:32 +000055 @UnsupportedAppUsage
Jeff Sharkey46645002011-07-27 21:11:21 -070056 void setRestrictBackground(boolean restrictBackground);
Andrei Onea9a8b6bf2019-02-25 13:25:32 +000057 @UnsupportedAppUsage
Jeff Sharkey46645002011-07-27 21:11:21 -070058 boolean getRestrictBackground();
59
Felipe Leme70c8b9b2016-04-25 14:41:31 -070060 /** Callback used to change internal state on tethering */
61 void onTetheringChanged(String iface, boolean tethering);
62
Felipe Leme1b103232016-01-22 09:44:57 -080063 /** Gets the restrict background status based on the caller's UID:
64 1 - disabled
65 2 - whitelisted
66 3 - enabled
67 */
68 int getRestrictBackgroundByCaller();
Felipe Lemeb85a6372016-01-14 16:16:16 -080069
Dianne Hackborn8ad2af72015-03-17 17:00:24 -070070 void setDeviceIdleMode(boolean enabled);
Jeff Sharkey43d2a172017-07-12 10:50:42 -060071 void setWifiMeteredOverride(String networkId, int meteredOverride);
Dianne Hackborn8ad2af72015-03-17 17:00:24 -070072
Andrei Onea9a8b6bf2019-02-25 13:25:32 +000073 @UnsupportedAppUsage
Jeff Sharkeyf0ceede2011-08-02 17:22:34 -070074 NetworkQuotaInfo getNetworkQuotaInfo(in NetworkState state);
Stuart Scottf1fb3972015-04-02 18:00:02 -070075
Jeff Sharkey53313d72017-07-13 16:47:32 -060076 SubscriptionPlan[] getSubscriptionPlans(int subId, String callingPackage);
77 void setSubscriptionPlans(int subId, in SubscriptionPlan[] plans, String callingPackage);
Jeff Sharkey717f52f2018-01-04 16:04:11 -070078 String getSubscriptionPlansOwner(int subId);
Jeff Sharkey9252b342018-01-19 07:58:35 +090079 void setSubscriptionOverride(int subId, int overrideMask, int overrideValue, long timeoutMillis, String callingPackage);
Jeff Sharkey53313d72017-07-13 16:47:32 -060080
Stuart Scottf1fb3972015-04-02 18:00:02 -070081 void factoryReset(String subscriber);
Sudheer Shankab8f23162017-08-04 13:30:10 -070082
83 boolean isUidNetworkingBlocked(int uid, boolean meteredNetwork);
Jeff Sharkeyd5cdd592011-05-03 20:27:17 -070084}