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