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

Commit 77d4ceea authored by Dmitri Plotnikov's avatar Dmitri Plotnikov
Browse files

Transition more PowerStats tests to Ravenwood

Bug: 314797745
Test: atest PowerStatsTestsRavenwood PowerStatsTests FrameworksCoreTests
Change-Id: I24bfe2e5c587e9547411ce5165d2fdd4c47b0e2b
parent 8e3ca63b
Loading
Loading
Loading
Loading
+38 −7
Original line number Original line Diff line number Diff line
@@ -31,6 +31,7 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.content.res.Resources;
import android.location.GnssSignalQuality;
import android.location.GnssSignalQuality;
import android.net.NetworkCapabilities;
import android.os.BatteryStatsManager.WifiState;
import android.os.BatteryStatsManager.WifiState;
import android.os.BatteryStatsManager.WifiSupplState;
import android.os.BatteryStatsManager.WifiSupplState;
import android.server.ServerProtoEnums;
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.CpuScalingPolicies;
import com.android.internal.os.MonotonicClock;
import com.android.internal.os.MonotonicClock;
import com.android.internal.os.PowerStats;
import com.android.internal.os.PowerStats;
import com.android.net.module.util.NetworkCapabilitiesUtils;


import com.google.android.collect.Lists;
import com.google.android.collect.Lists;


@@ -2734,26 +2736,28 @@ public abstract class BatteryStats {
        "emngcy", "other"
        "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_OUT_OF_SERVICE = 0;
    public static final int DATA_CONNECTION_EMERGENCY_SERVICE = getEmergencyNetworkConnectionType();
    public static final int DATA_CONNECTION_EMERGENCY_SERVICE = NUM_ALL_NETWORK_TYPES + 1;
    public static final int DATA_CONNECTION_OTHER = DATA_CONNECTION_EMERGENCY_SERVICE + 1;
    public static final int DATA_CONNECTION_OTHER = NUM_ALL_NETWORK_TYPES + 2;


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


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


    /**
    /**
@@ -9071,4 +9075,31 @@ public abstract class BatteryStats {
    protected static boolean isKernelStatsAvailable$ravenwood() {
    protected static boolean isKernelStatsAvailable$ravenwood() {
        return false;
        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 Original line Diff line number Diff line
@@ -26,6 +26,7 @@ import java.util.List;
 *
 *
 * @hide
 * @hide
 */
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class BluetoothBatteryStats implements Parcelable {
public class BluetoothBatteryStats implements Parcelable {


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


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


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