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