Throttling framework addins
Add ThrottleManager in getSystemService Add API for URL fetch Bug: 2576057 Change-Id: Icd25c8b91ea4beea15c74e8ad7292ab48c962253
This commit is contained in:
@@ -67,6 +67,8 @@ import android.location.LocationManager;
|
|||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.IConnectivityManager;
|
import android.net.IConnectivityManager;
|
||||||
|
import android.net.ThrottleManager;
|
||||||
|
import android.net.IThrottleManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.net.wifi.IWifiManager;
|
import android.net.wifi.IWifiManager;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
@@ -164,6 +166,7 @@ class ContextImpl extends Context {
|
|||||||
private static AlarmManager sAlarmManager;
|
private static AlarmManager sAlarmManager;
|
||||||
private static PowerManager sPowerManager;
|
private static PowerManager sPowerManager;
|
||||||
private static ConnectivityManager sConnectivityManager;
|
private static ConnectivityManager sConnectivityManager;
|
||||||
|
private static ThrottleManager sThrottleManager;
|
||||||
private static WifiManager sWifiManager;
|
private static WifiManager sWifiManager;
|
||||||
private static LocationManager sLocationManager;
|
private static LocationManager sLocationManager;
|
||||||
private static final HashMap<File, SharedPreferencesImpl> sSharedPrefs =
|
private static final HashMap<File, SharedPreferencesImpl> sSharedPrefs =
|
||||||
@@ -929,6 +932,8 @@ class ContextImpl extends Context {
|
|||||||
return getPowerManager();
|
return getPowerManager();
|
||||||
} else if (CONNECTIVITY_SERVICE.equals(name)) {
|
} else if (CONNECTIVITY_SERVICE.equals(name)) {
|
||||||
return getConnectivityManager();
|
return getConnectivityManager();
|
||||||
|
} else if (THROTTLE_SERVICE.equals(name)) {
|
||||||
|
return getThrottleManager();
|
||||||
} else if (WIFI_SERVICE.equals(name)) {
|
} else if (WIFI_SERVICE.equals(name)) {
|
||||||
return getWifiManager();
|
return getWifiManager();
|
||||||
} else if (NOTIFICATION_SERVICE.equals(name)) {
|
} else if (NOTIFICATION_SERVICE.equals(name)) {
|
||||||
@@ -1028,6 +1033,18 @@ class ContextImpl extends Context {
|
|||||||
return sConnectivityManager;
|
return sConnectivityManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ThrottleManager getThrottleManager()
|
||||||
|
{
|
||||||
|
synchronized (sSync) {
|
||||||
|
if (sThrottleManager == null) {
|
||||||
|
IBinder b = ServiceManager.getService(THROTTLE_SERVICE);
|
||||||
|
IThrottleManager service = IThrottleManager.Stub.asInterface(b);
|
||||||
|
sThrottleManager = new ThrottleManager(service);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sThrottleManager;
|
||||||
|
}
|
||||||
|
|
||||||
private WifiManager getWifiManager()
|
private WifiManager getWifiManager()
|
||||||
{
|
{
|
||||||
synchronized (sSync) {
|
synchronized (sSync) {
|
||||||
|
|||||||
@@ -35,4 +35,6 @@ interface IThrottleManager
|
|||||||
long getCliffThreshold(String iface, int cliff);
|
long getCliffThreshold(String iface, int cliff);
|
||||||
|
|
||||||
int getCliffLevel(String iface, int cliff);
|
int getCliffLevel(String iface, int cliff);
|
||||||
|
|
||||||
|
String getHelpUri();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,6 +171,19 @@ public class ThrottleManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the help URI for throttling
|
||||||
|
* {@hide}
|
||||||
|
*/
|
||||||
|
public String getHelpUri() {
|
||||||
|
try {
|
||||||
|
return mService.getHelpUri();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private IThrottleManager mService;
|
private IThrottleManager mService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3332,6 +3332,13 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public static final String THROTTLE_IFACE = "throttle_iface";
|
public static final String THROTTLE_IFACE = "throttle_iface";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Help URI for data throttling policy
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final String THROTTLE_HELP_URI = "throttle_help_uri";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -157,6 +157,12 @@ public class ThrottleService extends IThrottleManager.Stub {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getHelpUri() {
|
||||||
|
enforceAccessPermission();
|
||||||
|
return Settings.Secure.getString(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.THROTTLE_HELP_URI);
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized long getByteCount(String iface, int dir, int period, int ago) {
|
public synchronized long getByteCount(String iface, int dir, int period, int ago) {
|
||||||
enforceAccessPermission();
|
enforceAccessPermission();
|
||||||
if (iface.equals(mPolicyIface) &&
|
if (iface.equals(mPolicyIface) &&
|
||||||
|
|||||||
Reference in New Issue
Block a user