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

Commit 3233380a authored by Dmitri Plotnikov's avatar Dmitri Plotnikov
Browse files

Migrate PowerStatsExporter test to Ravenwood

Bug: 314797745
Test: atest PowerStatsTestsRavenwood
Test: atest PowerStatsTests

Change-Id: Ib16b999ea1d21d6f887e6b4aba6ae8dcbc7c0451
parent 182ae92f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import java.io.PrintWriter;
 *
 * {@hide}
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public final class AggregateBatteryConsumer extends BatteryConsumer {
    static final int CONSUMER_TYPE_AGGREGATE = 0;

+62 −6
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.server.ServerProtoEnums;
import android.service.batterystats.BatteryStatsServiceDumpHistoryProto;
import android.service.batterystats.BatteryStatsServiceDumpProto;
import android.telephony.CellSignalStrength;
import android.telephony.ModemActivityInfo;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.text.format.DateFormat;
@@ -83,6 +84,7 @@ import java.util.Map;
 * except where indicated otherwise.
 * @hide
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public abstract class BatteryStats {

    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
@@ -463,6 +465,7 @@ public abstract class BatteryStats {
    /**
     * State for keeping track of long counting information.
     */
    @android.ravenwood.annotation.RavenwoodKeepWholeClass
    public static abstract class LongCounter {

        /**
@@ -2724,12 +2727,6 @@ public abstract class BatteryStats {
     */
    public abstract int getMobileRadioActiveUnknownCount(int which);

    public static final int DATA_CONNECTION_OUT_OF_SERVICE = 0;
    public static final int DATA_CONNECTION_EMERGENCY_SERVICE =
            TelephonyManager.getAllNetworkTypes().length + 1;
    public static final int DATA_CONNECTION_OTHER = DATA_CONNECTION_EMERGENCY_SERVICE + 1;


    static final String[] DATA_CONNECTION_NAMES = {
        "oos", "gprs", "edge", "umts", "cdma", "evdo_0", "evdo_A",
        "1xrtt", "hsdpa", "hsupa", "hspa", "iden", "evdo_b", "lte",
@@ -2737,9 +2734,28 @@ public abstract class BatteryStats {
        "emngcy", "other"
    };

    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;

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

    @android.ravenwood.annotation.RavenwoodReplace
    private static int getEmergencyNetworkConnectionType() {
        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;
    }

    private static int getEmergencyNetworkConnectionType$ravenwood() {
        return DATA_CONNECTION_NAMES.length - 2;
    }

    /**
     * Returns the time in microseconds that the phone has been running with
     * the given data connection.
@@ -9015,4 +9031,44 @@ public abstract class BatteryStats {
                (lhs, rhs) -> Double.compare(rhs.millisecondsPerPacket, lhs.millisecondsPerPacket));
        return uidMobileRadioStats;
    }

    @android.ravenwood.annotation.RavenwoodReplace
    @VisibleForTesting
    protected static boolean isLowRamDevice() {
        return ActivityManager.isLowRamDeviceStatic();
    }

    protected static boolean isLowRamDevice$ravenwood() {
        return false;
    }

    @android.ravenwood.annotation.RavenwoodReplace
    @VisibleForTesting
    protected static int getCellSignalStrengthLevelCount() {
        return CellSignalStrength.getNumSignalStrengthLevels();
    }

    protected static int getCellSignalStrengthLevelCount$ravenwood() {
        return 5;
    }

    @android.ravenwood.annotation.RavenwoodReplace
    @VisibleForTesting
    protected static int getModemTxPowerLevelCount() {
        return ModemActivityInfo.getNumTxPowerLevels();
    }

    protected static int getModemTxPowerLevelCount$ravenwood() {
        return 5;
    }

    @android.ravenwood.annotation.RavenwoodReplace
    @VisibleForTesting
    protected static boolean isKernelStatsAvailable() {
        return true;
    }

    protected static boolean isKernelStatsAvailable$ravenwood() {
        return false;
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import java.util.List;
 *
 * @hide
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public final class BatteryUsageStats implements Parcelable, Closeable {

    /**
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import java.lang.annotation.RetentionPolicy;
 *
 * @hide
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public final class BatteryUsageStatsQuery implements Parcelable {

    @NonNull
+1 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import java.io.PrintWriter;
 *
 * @hide
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
class PowerComponents {
    private final BatteryConsumer.BatteryConsumerData mData;

Loading