Loading services/core/java/com/android/server/BinderCallsStatsService.java +17 −16 Original line number Diff line number Diff line Loading @@ -288,6 +288,7 @@ public class BinderCallsStatsService extends Binder { CachedDeviceState.Readonly.class); mBinderCallsStats.setDeviceState(deviceState); if (!com.android.server.power.optimization.Flags.disableSystemServicePowerAttr()) { BatteryStatsInternal batteryStatsInternal = getLocalService( BatteryStatsInternal.class); mBinderCallsStats.setCallStatsObserver(new BinderInternal.CallStatsObserver() { Loading @@ -303,7 +304,7 @@ public class BinderCallsStatsService extends Binder { batteryStatsInternal.noteBinderThreadNativeIds(binderThreadNativeTids); } }); } // It needs to be called before mService.systemReady to make sure the observer is // initialized before installing it. mWorkSourceProvider.systemReady(getContext()); Loading services/core/java/com/android/server/am/BatteryStatsService.java +3 −1 Original line number Diff line number Diff line Loading @@ -422,7 +422,9 @@ public final class BatteryStatsService extends IBatteryStats.Stub mStats.setExternalStatsSyncLocked(mWorker); mStats.setRadioScanningTimeoutLocked(mContext.getResources().getInteger( com.android.internal.R.integer.config_radioScanningTimeout) * 1000L); if (!Flags.disableSystemServicePowerAttr()) { mStats.startTrackingSystemServerCpuTime(); } mAggregatedPowerStatsConfig = createAggregatedPowerStatsConfig(); mPowerStatsStore = new PowerStatsStore(systemDir, mHandler, mAggregatedPowerStatsConfig); Loading services/core/java/com/android/server/power/stats/BatteryStatsImpl.java +40 −24 Original line number Diff line number Diff line Loading @@ -138,6 +138,7 @@ import com.android.internal.util.XmlUtils; import com.android.modules.utils.TypedXmlPullParser; import com.android.modules.utils.TypedXmlSerializer; import com.android.net.module.util.NetworkCapabilitiesUtils; import com.android.server.power.optimization.Flags; import com.android.server.power.stats.SystemServerCpuThreadReader.SystemServiceCpuThreadTimes; import libcore.util.EmptyArray; Loading Loading @@ -185,7 +186,8 @@ public class BatteryStatsImpl extends BatteryStats { // TODO: remove "tcp" from network methods, since we measure total stats. // Current on-disk Parcel version. Must be updated when the format of the parcelable changes public static final int VERSION = 214; public static final int VERSION = !Flags.disableSystemServicePowerAttr() ? 214 : 215; // The maximum number of names wakelocks we will keep track of // per uid; once the limit is reached, we batch the remaining wakelocks Loading Loading @@ -1753,7 +1755,9 @@ public class BatteryStatsImpl extends BatteryStats { mCpuUidActiveTimeReader = new KernelCpuUidActiveTimeReader(true, mClock); mCpuUidClusterTimeReader = new KernelCpuUidClusterTimeReader(true, mClock); mKernelWakelockReader = new KernelWakelockReader(); if (!Flags.disableSystemServicePowerAttr()) { mSystemServerCpuThreadReader = SystemServerCpuThreadReader.create(); } mKernelMemoryBandwidthStats = new KernelMemoryBandwidthStats(); mTmpRailStats = new RailStats(); } Loading Loading @@ -11702,7 +11706,9 @@ public class BatteryStatsImpl extends BatteryStats { EnergyConsumerStats.resetIfNotNull(mGlobalEnergyConsumerStats); if (!Flags.disableSystemServicePowerAttr()) { resetIfNotNull(mBinderThreadCpuTimesUs, false, elapsedRealtimeUs); } mNumAllUidCpuTimeReads = 0; mNumUidsRemoved = 0; Loading Loading @@ -13676,7 +13682,9 @@ public class BatteryStatsImpl extends BatteryStats { mKernelCpuSpeedReaders[i].readDelta(); } } if (!Flags.disableSystemServicePowerAttr()) { mSystemServerCpuThreadReader.readDelta(); } return; } Loading Loading @@ -15696,6 +15704,7 @@ public class BatteryStatsImpl extends BatteryStats { } } if (!Flags.disableSystemServicePowerAttr()) { updateSystemServiceCallStats(); if (mBinderThreadCpuTimesUs != null) { pw.println("Per UID System server binder time in ms:"); Loading @@ -15716,6 +15725,7 @@ public class BatteryStatsImpl extends BatteryStats { } } } } /** * Dump EnergyConsumer stats Loading Loading @@ -16428,9 +16438,11 @@ public class BatteryStatsImpl extends BatteryStats { } } if (!Flags.disableSystemServicePowerAttr()) { mBinderThreadCpuTimesUs = LongSamplingCounterArray.readSummaryFromParcelLocked(in, mOnBatteryTimeBase); } } /** * Writes a summary of the statistics to a Parcel, in a format suitable to be written to Loading Loading @@ -16973,8 +16985,10 @@ public class BatteryStatsImpl extends BatteryStats { } } if (!Flags.disableSystemServicePowerAttr()) { LongSamplingCounterArray.writeSummaryToParcelLocked(out, mBinderThreadCpuTimesUs); } } @GuardedBy("this") public void prepareForDumpLocked() { Loading @@ -16985,8 +16999,10 @@ public class BatteryStatsImpl extends BatteryStats { // if we had originally pulled a time before the RTC was set. getStartClockTime(); if (!Flags.disableSystemServicePowerAttr()) { updateSystemServiceCallStats(); } } @GuardedBy("this") public void dump(Context context, PrintWriter pw, int flags, int reqUid, long histStart, services/core/java/com/android/server/power/stats/BatteryUsageStatsProvider.java +7 −5 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ public class BatteryUsageStatsProvider { mPowerCalculators.add(new CustomEnergyConsumerPowerCalculator(mPowerProfile)); mPowerCalculators.add(new UserPowerCalculator()); if (!com.android.server.power.optimization.Flags.disableSystemServicePowerAttr()) { // It is important that SystemServicePowerCalculator be applied last, // because it re-attributes some of the power estimated by the other // calculators. Loading @@ -103,6 +104,7 @@ public class BatteryUsageStatsProvider { new SystemServicePowerCalculator(mCpuScalingPolicies, mPowerProfile)); } } } return mPowerCalculators; } Loading services/core/java/com/android/server/power/stats/flags.aconfig +8 −0 Original line number Diff line number Diff line Loading @@ -13,3 +13,11 @@ flag { description: "Feature flag for streamlined battery stats" bug: "285646152" } flag { name: "disable_system_service_power_attr" namespace: "backstage_power" description: "Deprecation of system service power re-attribution" bug: "311793616" is_fixed_read_only: true } Loading
services/core/java/com/android/server/BinderCallsStatsService.java +17 −16 Original line number Diff line number Diff line Loading @@ -288,6 +288,7 @@ public class BinderCallsStatsService extends Binder { CachedDeviceState.Readonly.class); mBinderCallsStats.setDeviceState(deviceState); if (!com.android.server.power.optimization.Flags.disableSystemServicePowerAttr()) { BatteryStatsInternal batteryStatsInternal = getLocalService( BatteryStatsInternal.class); mBinderCallsStats.setCallStatsObserver(new BinderInternal.CallStatsObserver() { Loading @@ -303,7 +304,7 @@ public class BinderCallsStatsService extends Binder { batteryStatsInternal.noteBinderThreadNativeIds(binderThreadNativeTids); } }); } // It needs to be called before mService.systemReady to make sure the observer is // initialized before installing it. mWorkSourceProvider.systemReady(getContext()); Loading
services/core/java/com/android/server/am/BatteryStatsService.java +3 −1 Original line number Diff line number Diff line Loading @@ -422,7 +422,9 @@ public final class BatteryStatsService extends IBatteryStats.Stub mStats.setExternalStatsSyncLocked(mWorker); mStats.setRadioScanningTimeoutLocked(mContext.getResources().getInteger( com.android.internal.R.integer.config_radioScanningTimeout) * 1000L); if (!Flags.disableSystemServicePowerAttr()) { mStats.startTrackingSystemServerCpuTime(); } mAggregatedPowerStatsConfig = createAggregatedPowerStatsConfig(); mPowerStatsStore = new PowerStatsStore(systemDir, mHandler, mAggregatedPowerStatsConfig); Loading
services/core/java/com/android/server/power/stats/BatteryStatsImpl.java +40 −24 Original line number Diff line number Diff line Loading @@ -138,6 +138,7 @@ import com.android.internal.util.XmlUtils; import com.android.modules.utils.TypedXmlPullParser; import com.android.modules.utils.TypedXmlSerializer; import com.android.net.module.util.NetworkCapabilitiesUtils; import com.android.server.power.optimization.Flags; import com.android.server.power.stats.SystemServerCpuThreadReader.SystemServiceCpuThreadTimes; import libcore.util.EmptyArray; Loading Loading @@ -185,7 +186,8 @@ public class BatteryStatsImpl extends BatteryStats { // TODO: remove "tcp" from network methods, since we measure total stats. // Current on-disk Parcel version. Must be updated when the format of the parcelable changes public static final int VERSION = 214; public static final int VERSION = !Flags.disableSystemServicePowerAttr() ? 214 : 215; // The maximum number of names wakelocks we will keep track of // per uid; once the limit is reached, we batch the remaining wakelocks Loading Loading @@ -1753,7 +1755,9 @@ public class BatteryStatsImpl extends BatteryStats { mCpuUidActiveTimeReader = new KernelCpuUidActiveTimeReader(true, mClock); mCpuUidClusterTimeReader = new KernelCpuUidClusterTimeReader(true, mClock); mKernelWakelockReader = new KernelWakelockReader(); if (!Flags.disableSystemServicePowerAttr()) { mSystemServerCpuThreadReader = SystemServerCpuThreadReader.create(); } mKernelMemoryBandwidthStats = new KernelMemoryBandwidthStats(); mTmpRailStats = new RailStats(); } Loading Loading @@ -11702,7 +11706,9 @@ public class BatteryStatsImpl extends BatteryStats { EnergyConsumerStats.resetIfNotNull(mGlobalEnergyConsumerStats); if (!Flags.disableSystemServicePowerAttr()) { resetIfNotNull(mBinderThreadCpuTimesUs, false, elapsedRealtimeUs); } mNumAllUidCpuTimeReads = 0; mNumUidsRemoved = 0; Loading Loading @@ -13676,7 +13682,9 @@ public class BatteryStatsImpl extends BatteryStats { mKernelCpuSpeedReaders[i].readDelta(); } } if (!Flags.disableSystemServicePowerAttr()) { mSystemServerCpuThreadReader.readDelta(); } return; } Loading Loading @@ -15696,6 +15704,7 @@ public class BatteryStatsImpl extends BatteryStats { } } if (!Flags.disableSystemServicePowerAttr()) { updateSystemServiceCallStats(); if (mBinderThreadCpuTimesUs != null) { pw.println("Per UID System server binder time in ms:"); Loading @@ -15716,6 +15725,7 @@ public class BatteryStatsImpl extends BatteryStats { } } } } /** * Dump EnergyConsumer stats Loading Loading @@ -16428,9 +16438,11 @@ public class BatteryStatsImpl extends BatteryStats { } } if (!Flags.disableSystemServicePowerAttr()) { mBinderThreadCpuTimesUs = LongSamplingCounterArray.readSummaryFromParcelLocked(in, mOnBatteryTimeBase); } } /** * Writes a summary of the statistics to a Parcel, in a format suitable to be written to Loading Loading @@ -16973,8 +16985,10 @@ public class BatteryStatsImpl extends BatteryStats { } } if (!Flags.disableSystemServicePowerAttr()) { LongSamplingCounterArray.writeSummaryToParcelLocked(out, mBinderThreadCpuTimesUs); } } @GuardedBy("this") public void prepareForDumpLocked() { Loading @@ -16985,8 +16999,10 @@ public class BatteryStatsImpl extends BatteryStats { // if we had originally pulled a time before the RTC was set. getStartClockTime(); if (!Flags.disableSystemServicePowerAttr()) { updateSystemServiceCallStats(); } } @GuardedBy("this") public void dump(Context context, PrintWriter pw, int flags, int reqUid, long histStart,
services/core/java/com/android/server/power/stats/BatteryUsageStatsProvider.java +7 −5 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ public class BatteryUsageStatsProvider { mPowerCalculators.add(new CustomEnergyConsumerPowerCalculator(mPowerProfile)); mPowerCalculators.add(new UserPowerCalculator()); if (!com.android.server.power.optimization.Flags.disableSystemServicePowerAttr()) { // It is important that SystemServicePowerCalculator be applied last, // because it re-attributes some of the power estimated by the other // calculators. Loading @@ -103,6 +104,7 @@ public class BatteryUsageStatsProvider { new SystemServicePowerCalculator(mCpuScalingPolicies, mPowerProfile)); } } } return mPowerCalculators; } Loading
services/core/java/com/android/server/power/stats/flags.aconfig +8 −0 Original line number Diff line number Diff line Loading @@ -13,3 +13,11 @@ flag { description: "Feature flag for streamlined battery stats" bug: "285646152" } flag { name: "disable_system_service_power_attr" namespace: "backstage_power" description: "Deprecation of system service power re-attribution" bug: "311793616" is_fixed_read_only: true }