1 /*
2  * Copyright (C) 2008 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 com.android.providers.downloads;
18 
19 import android.content.Context;
20 import android.content.Intent;
21 import android.content.pm.PackageManager.NameNotFoundException;
22 import android.net.Network;
23 import android.net.NetworkInfo;
24 
25 import java.security.GeneralSecurityException;
26 import javax.net.ssl.SSLContext;
27 
28 interface SystemFacade {
29     /**
30      * @see System#currentTimeMillis()
31      */
currentTimeMillis()32     public long currentTimeMillis();
33 
getActiveNetwork(int uid, boolean ignoreBlocked)34     public Network getActiveNetwork(int uid, boolean ignoreBlocked);
35 
getNetworkInfo(Network network, int uid, boolean ignoreBlocked)36     public NetworkInfo getNetworkInfo(Network network, int uid, boolean ignoreBlocked);
37 
38     /**
39      * @return maximum size, in bytes, of downloads that may go over a mobile connection; or null if
40      * there's no limit
41      */
getMaxBytesOverMobile()42     public long getMaxBytesOverMobile();
43 
44     /**
45      * @return recommended maximum size, in bytes, of downloads that may go over a mobile
46      * connection; or null if there's no recommended limit.  The user will have the option to bypass
47      * this limit.
48      */
getRecommendedMaxBytesOverMobile()49     public long getRecommendedMaxBytesOverMobile();
50 
51     /**
52      * Send a broadcast intent.
53      */
sendBroadcast(Intent intent)54     public void sendBroadcast(Intent intent);
55 
56     /**
57      * Returns true if the specified UID owns the specified package name.
58      */
userOwnsPackage(int uid, String pckg)59     public boolean userOwnsPackage(int uid, String pckg) throws NameNotFoundException;
60 
61     /**
62      * Returns true if cleartext network traffic is permitted for the specified UID.
63      */
isCleartextTrafficPermitted(int uid)64     public boolean isCleartextTrafficPermitted(int uid);
65 
66     /**
67      * Return a {@link SSLContext} configured using the specified package's configuration.
68      */
getSSLContextForPackage(Context context, String pckg)69     public SSLContext getSSLContextForPackage(Context context, String pckg)
70             throws GeneralSecurityException;
71 }
72