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

Commit 6aaf75ca authored by Ikjoon Jang's avatar Ikjoon Jang
Browse files

Revert "Fix IllegalStateException in getSupportedPowerMonitors API"

This reverts commit 6fed387e.

Reason for revert: DroidMonitor: Potential culprit for Bug b/310083260 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Bug: 310083260
Change-Id: I2e66b682eb07641c9de169266dbbb9db4abcf3cc
parent 6fed387e
Loading
Loading
Loading
Loading
+30 −41
Original line number Diff line number Diff line
@@ -603,37 +603,9 @@ public class PowerStatsService extends SystemService {
    @NonNull
    private String getEnergyConsumerName(EnergyConsumer consumer,
            EnergyConsumer[] energyConsumers) {
        if (consumer.type != EnergyConsumerType.OTHER) {
            StringBuilder sb = new StringBuilder();
        switch (consumer.type) {
            case EnergyConsumerType.BLUETOOTH:
                sb.append("BLUETOOTH");
                break;
            case EnergyConsumerType.CPU_CLUSTER:
                sb.append("CPU");
                break;
            case EnergyConsumerType.DISPLAY:
                sb.append("DISPLAY");
                break;
            case EnergyConsumerType.GNSS:
                sb.append("GNSS");
                break;
            case EnergyConsumerType.MOBILE_RADIO:
                sb.append("MOBILE_RADIO");
                break;
            case EnergyConsumerType.WIFI:
                sb.append("WIFI");
                break;
            case EnergyConsumerType.CAMERA:
                sb.append("CAMERA");
                break;
            default:
                if (consumer.name != null && !consumer.name.isBlank()) {
                    sb.append(consumer.name.toUpperCase(Locale.ENGLISH));
                } else {
                    sb.append("CONSUMER_").append(consumer.type);
                }
                break;
        }
            sb.append(energyConsumerTypeToString(consumer.type));
            boolean hasOrdinal = consumer.ordinal != 0;
            if (!hasOrdinal) {
                // See if any other EnergyConsumer of the same type has an ordinal
@@ -648,6 +620,23 @@ public class PowerStatsService extends SystemService {
                sb.append('/').append(consumer.ordinal);
            }
            return sb.toString();
        } else {
            return consumer.name;
        }
    }

    private static String energyConsumerTypeToString(int type) {
        switch(type) {
            case EnergyConsumerType.BLUETOOTH: return "BLUETOOTH";
            case EnergyConsumerType.CPU_CLUSTER: return "CPU";
            case EnergyConsumerType.DISPLAY: return "DISPLAY";
            case EnergyConsumerType.GNSS: return "GNSS";
            case EnergyConsumerType.MOBILE_RADIO: return "MOBILE_RADIO";
            case EnergyConsumerType.WIFI: return "WIFI";
            case EnergyConsumerType.OTHER: return "";
            default:
                throw new IllegalStateException("Unrecognized EnergyConsumerType: " + type);
        }
    }

    /**