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

Commit 0b028b1d authored by Bookatz's avatar Bookatz
Browse files

Wean Statsd off BatteryStats: Network Power

Statsd calls were sometimes made from BatteryStats, instead of directly
from the source, as a way of getting it running quickly in P. These must
now be done properly and separately.
Note that Statsd needs to be independent of BatteryStats, in preparation
for deprecating large parts of BatteryStats.

Bug: 80308558
Test: cts-tradefed run cts-dev -m CtsStatsdHostTestCases
Change-Id: I54fa54a2dc59dfa68f0e063d7063fac423bf0bf4
parent a5ed99a7
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -579,7 +579,7 @@ message WakeupAlarmOccurred {
 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the mobile radio.
 *
 * Logged from:
 *   frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
 *   frameworks/base/services/core/java/com/android/server/NetworkManagementService.java
 */
message MobileRadioPowerStateChanged {
    repeated AttributionNode attribution_node = 1;
@@ -593,7 +593,7 @@ message MobileRadioPowerStateChanged {
 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the wifi radio.
 *
 * Logged from:
 *   frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
 *   frameworks/base/services/core/java/com/android/server/NetworkManagementService.java
 */
message WifiRadioPowerStateChanged {
    repeated AttributionNode attribution_node = 1;
+0 −4
Original line number Diff line number Diff line
@@ -5072,8 +5072,6 @@ public class BatteryStatsImpl extends BatteryStats {
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecordLocked(elapsedRealtime, uptime);
            mMobileRadioPowerState = powerState;
            StatsLog.write_non_chained(StatsLog.MOBILE_RADIO_POWER_STATE_CHANGED, uid, null,
                    powerState);
            if (active) {
                mMobileRadioActiveTimer.startRunningLocked(elapsedRealtime);
                mMobileRadioActivePerAppTimer.startRunningLocked(elapsedRealtime);
@@ -5826,8 +5824,6 @@ public class BatteryStatsImpl extends BatteryStats {
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecordLocked(elapsedRealtime, uptime);
            mWifiRadioPowerState = powerState;
            StatsLog.write_non_chained(StatsLog.WIFI_RADIO_POWER_STATE_CHANGED, uid, null,
                    powerState);
        }
    }
+5 −0
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ import android.util.Log;
import android.util.Slog;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
import android.util.StatsLog;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
@@ -512,6 +513,8 @@ public class NetworkManagementService extends INetworkManagementService.Stub
                    getBatteryStats().noteMobileRadioPowerState(powerState, tsNanos, uid);
                } catch (RemoteException e) {
                }
                StatsLog.write_non_chained(StatsLog.MOBILE_RADIO_POWER_STATE_CHANGED, uid, null,
                        powerState);
            }
        }

@@ -522,6 +525,8 @@ public class NetworkManagementService extends INetworkManagementService.Stub
                    getBatteryStats().noteWifiRadioPowerState(powerState, tsNanos, uid);
                } catch (RemoteException e) {
                }
                StatsLog.write_non_chained(StatsLog.WIFI_RADIO_POWER_STATE_CHANGED, uid, null,
                        powerState);
            }
        }