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

Commit 132afa2b authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Transition more PowerStats tests to Ravenwood" into main

parents db76d3b4 77d4ceea
Loading
Loading
Loading
Loading
+38 −7
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.location.GnssSignalQuality;
import android.net.NetworkCapabilities;
import android.os.BatteryStatsManager.WifiState;
import android.os.BatteryStatsManager.WifiSupplState;
import android.server.ServerProtoEnums;
@@ -59,6 +60,7 @@ import com.android.internal.os.BatteryStatsHistoryIterator;
import com.android.internal.os.CpuScalingPolicies;
import com.android.internal.os.MonotonicClock;
import com.android.internal.os.PowerStats;
import com.android.net.module.util.NetworkCapabilitiesUtils;

import com.google.android.collect.Lists;

@@ -2734,26 +2736,28 @@ public abstract class BatteryStats {
        "emngcy", "other"
    };

    public static final int NUM_ALL_NETWORK_TYPES = getAllNetworkTypesCount();
    public static final int DATA_CONNECTION_OUT_OF_SERVICE = 0;
    public static final int DATA_CONNECTION_EMERGENCY_SERVICE = getEmergencyNetworkConnectionType();
    public static final int DATA_CONNECTION_OTHER = DATA_CONNECTION_EMERGENCY_SERVICE + 1;
    public static final int DATA_CONNECTION_EMERGENCY_SERVICE = NUM_ALL_NETWORK_TYPES + 1;
    public static final int DATA_CONNECTION_OTHER = NUM_ALL_NETWORK_TYPES + 2;

    @UnsupportedAppUsage
    public static final int NUM_DATA_CONNECTION_TYPES = DATA_CONNECTION_OTHER + 1;
    public static final int NUM_DATA_CONNECTION_TYPES = NUM_ALL_NETWORK_TYPES + 3;


    @android.ravenwood.annotation.RavenwoodReplace
    private static int getEmergencyNetworkConnectionType() {
    public static int getAllNetworkTypesCount() {
        int count = TelephonyManager.getAllNetworkTypes().length;
        if (DATA_CONNECTION_NAMES.length != count + 3) {        // oos, emngcy, other
            throw new IllegalStateException(
                    "DATA_CONNECTION_NAMES length does not match network type count. "
                    + "Expected: " + (count + 3) + ", actual:" + DATA_CONNECTION_NAMES.length);
        }
        return count + 1;
        return count;
    }

    private static int getEmergencyNetworkConnectionType$ravenwood() {
        return DATA_CONNECTION_NAMES.length - 2;
    public static int getAllNetworkTypesCount$ravenwood() {
        return DATA_CONNECTION_NAMES.length - 3;  // oos, emngcy, other
    }

    /**
@@ -9071,4 +9075,31 @@ public abstract class BatteryStats {
    protected static boolean isKernelStatsAvailable$ravenwood() {
        return false;
    }

    @android.ravenwood.annotation.RavenwoodReplace
    protected static int getDisplayTransport(int[] transports) {
        return NetworkCapabilitiesUtils.getDisplayTransport(transports);
    }

    // See NetworkCapabilitiesUtils
    private static final int[] DISPLAY_TRANSPORT_PRIORITIES = new int[] {
            NetworkCapabilities.TRANSPORT_VPN,
            NetworkCapabilities.TRANSPORT_CELLULAR,
            NetworkCapabilities.TRANSPORT_WIFI_AWARE,
            NetworkCapabilities.TRANSPORT_BLUETOOTH,
            NetworkCapabilities.TRANSPORT_WIFI,
            NetworkCapabilities.TRANSPORT_ETHERNET,
            NetworkCapabilities.TRANSPORT_USB
    };

    protected static int getDisplayTransport$ravenwood(int[] transports) {
        for (int transport : DISPLAY_TRANSPORT_PRIORITIES) {
            for (int t : transports) {
                if (t == transport) {
                    return transport;
                }
            }
        }
        return transports[0];
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import java.util.List;
 *
 * @hide
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class BluetoothBatteryStats implements Parcelable {

    /** @hide */
+1 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import java.util.List;
 *
 * {@hide}
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class UserBatteryConsumer extends BatteryConsumer {
    static final int CONSUMER_TYPE_USER = 2;

+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import java.util.List;
 * Snapshot of wake lock stats.
 *  @hide
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public final class WakeLockStats implements Parcelable {

    /** @hide */
+6 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ import java.util.function.Consumer;
 * that are currently attached and whether mirroring has been enabled.
 * </p>
 */
@android.ravenwood.annotation.RavenwoodKeepPartialClass
public final class Display {
    private static final String TAG = "Display";
    private static final boolean DEBUG = false;
@@ -1998,6 +1999,7 @@ public final class Display {
     * display power state. In SUSPEND states, updates are absolutely forbidden.
     * @hide
     */
    @android.ravenwood.annotation.RavenwoodKeep
    public static boolean isSuspendedState(int state) {
        return state == STATE_OFF || state == STATE_DOZE_SUSPEND || state == STATE_ON_SUSPEND;
    }
@@ -2007,6 +2009,7 @@ public final class Display {
     * specified display power state.
     * @hide
     */
    @android.ravenwood.annotation.RavenwoodKeep
    public static boolean isDozeState(int state) {
        return state == STATE_DOZE || state == STATE_DOZE_SUSPEND;
    }
@@ -2016,6 +2019,7 @@ public final class Display {
     * or {@link #STATE_VR}.
     * @hide
     */
    @android.ravenwood.annotation.RavenwoodKeep
    public static boolean isActiveState(int state) {
        return state == STATE_ON || state == STATE_VR;
    }
@@ -2024,6 +2028,7 @@ public final class Display {
     * Returns true if the display is in an off state such as {@link #STATE_OFF}.
     * @hide
     */
    @android.ravenwood.annotation.RavenwoodKeep
    public static boolean isOffState(int state) {
        return state == STATE_OFF;
    }
@@ -2033,6 +2038,7 @@ public final class Display {
     * or {@link #STATE_VR} or {@link #STATE_ON_SUSPEND}.
     * @hide
     */
    @android.ravenwood.annotation.RavenwoodKeep
    public static boolean isOnState(int state) {
        return state == STATE_ON || state == STATE_VR || state == STATE_ON_SUSPEND;
    }
Loading