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

Commit 3913bb35 authored by Aaron Huang's avatar Aaron Huang Committed by Automerger Merge Worker
Browse files

Add a new API in BatteryStatsManager for connectivity service am: 3ae5bdab am: 584e64df

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1475899

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ic4f99588f81a9545e91593311d6d4e8e6c64659e
parents d4e1a709 584e64df
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -56,6 +56,10 @@ package android.net {

package android.os {

  public final class BatteryStatsManager {
    method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK}) public void reportNetworkInterfaceForTransports(@NonNull String, @NonNull int[]) throws java.lang.RuntimeException;
  }

  public class Binder implements android.os.IBinder {
    method public final void markVintfStability();
  }
+24 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.content.Context;
import android.net.NetworkStack;
import android.os.connectivity.CellularBatteryStats;
import android.os.connectivity.WifiBatteryStats;
import android.telephony.DataConnectionRealTimeInfo;
@@ -416,10 +417,31 @@ public final class BatteryStatsManager {
        }
    }

    /**
     * Notifies the battery stats of a new interface, and the transport types of the network that
     * includes that interface.
     *
     * @param iface The interface of the network.
     * @param transportTypes The transport type of the network {@link Transport}.
     * @hide
     */
    @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
    @RequiresPermission(anyOf = {
            NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK,
            android.Manifest.permission.NETWORK_STACK})
    public void reportNetworkInterfaceForTransports(@NonNull String iface,
            @NonNull int[] transportTypes) throws RuntimeException {
        try {
            mBatteryStats.noteNetworkInterfaceForTransports(iface, transportTypes);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
    }

    private static int getDataConnectionPowerState(boolean isActive) {
        // TODO: DataConnectionRealTimeInfo is under telephony package but the constants are used
        // for both Wifi and mobile. It would make more sense to separate the constants to a generic
        // class or move it to generic package.
        // for both Wifi and mobile. It would make more sense to separate the constants to a
        // generic class or move it to generic package.
        return isActive ? DataConnectionRealTimeInfo.DC_POWER_STATE_HIGH
                : DataConnectionRealTimeInfo.DC_POWER_STATE_LOW;
    }
+2 −1
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ import com.android.internal.util.DumpUtils;
import com.android.internal.util.FrameworkStatsLog;
import com.android.internal.util.ParseUtils;
import com.android.net.module.util.NetworkCapabilitiesUtils;
import com.android.net.module.util.PermissionUtils;
import com.android.server.LocalServices;
import com.android.server.net.BaseNetworkObserver;

@@ -1102,7 +1103,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub

    @Override
    public void noteNetworkInterfaceForTransports(final String iface, int[] transportTypes) {
        enforceCallingPermission();
        PermissionUtils.enforceNetworkStackPermission(mContext);
        mStats.noteNetworkInterfaceForTransports(iface, transportTypes);
    }