Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 750f3211 authored by Irfan Sheriff's avatar Irfan Sheriff Committed by Android Git Automerger
Browse files

am c9b6851a: Throttling framework addins

Merge commit 'c9b6851a' into froyo-plus-aosp

* commit 'c9b6851a':
  Throttling framework addins
parents b00771aa c9b6851a
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -67,6 +67,8 @@ import android.location.LocationManager;
import android.media.AudioManager;
import android.net.ConnectivityManager;
import android.net.IConnectivityManager;
import android.net.ThrottleManager;
import android.net.IThrottleManager;
import android.net.Uri;
import android.net.wifi.IWifiManager;
import android.net.wifi.WifiManager;
@@ -164,6 +166,7 @@ class ContextImpl extends Context {
    private static AlarmManager sAlarmManager;
    private static PowerManager sPowerManager;
    private static ConnectivityManager sConnectivityManager;
    private static ThrottleManager sThrottleManager;
    private static WifiManager sWifiManager;
    private static LocationManager sLocationManager;
    private static final HashMap<File, SharedPreferencesImpl> sSharedPrefs =
@@ -929,6 +932,8 @@ class ContextImpl extends Context {
            return getPowerManager();
        } else if (CONNECTIVITY_SERVICE.equals(name)) {
            return getConnectivityManager();
        } else if (THROTTLE_SERVICE.equals(name)) {
            return getThrottleManager();
        } else if (WIFI_SERVICE.equals(name)) {
            return getWifiManager();
        } else if (NOTIFICATION_SERVICE.equals(name)) {
@@ -1028,6 +1033,18 @@ class ContextImpl extends Context {
        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()
    {
        synchronized (sSync) {
+2 −0
Original line number Diff line number Diff line
@@ -35,4 +35,6 @@ interface IThrottleManager
    long getCliffThreshold(String iface, int cliff);

    int getCliffLevel(String iface, int cliff);

    String getHelpUri();
}
+13 −0
Original line number Diff line number Diff line
@@ -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;

    /**
+7 −0
Original line number Diff line number Diff line
@@ -3332,6 +3332,13 @@ public final class Settings {
         */
        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
         */
+6 −0
Original line number Diff line number Diff line
@@ -157,6 +157,12 @@ public class ThrottleService extends IThrottleManager.Stub {
        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) {
        enforceAccessPermission();
        if (iface.equals(mPolicyIface) &&