Loading core/java/com/android/internal/os/BatteryStatsHelper.java +17 −12 Original line number Original line Diff line number Diff line Loading @@ -126,6 +126,9 @@ public final class BatteryStatsHelper { PowerCalculator mCameraPowerCalculator; PowerCalculator mCameraPowerCalculator; PowerCalculator mFlashlightPowerCalculator; PowerCalculator mFlashlightPowerCalculator; boolean mHasWifiPowerReporting = false; boolean mHasBluetoothPowerReporting = false; public static boolean checkWifiOnly(Context context) { public static boolean checkWifiOnly(Context context) { ConnectivityManager cm = (ConnectivityManager)context.getSystemService( ConnectivityManager cm = (ConnectivityManager)context.getSystemService( Context.CONNECTIVITY_SERVICE); Context.CONNECTIVITY_SERVICE); Loading Loading @@ -349,21 +352,23 @@ public final class BatteryStatsHelper { } } mMobileRadioPowerCalculator.reset(mStats); mMobileRadioPowerCalculator.reset(mStats); if (mWifiPowerCalculator == null) { // checkHasWifiPowerReporting can change if we get energy data at a later point, so if (checkHasWifiPowerReporting(mStats, mPowerProfile)) { // always check this field. mWifiPowerCalculator = new WifiPowerCalculator(mPowerProfile); final boolean hasWifiPowerReporting = checkHasWifiPowerReporting(mStats, mPowerProfile); } else { if (mWifiPowerCalculator == null || hasWifiPowerReporting != mHasWifiPowerReporting) { mWifiPowerCalculator = new WifiPowerEstimator(mPowerProfile); mWifiPowerCalculator = hasWifiPowerReporting ? } new WifiPowerCalculator(mPowerProfile) : new WifiPowerEstimator(mPowerProfile); mHasWifiPowerReporting = hasWifiPowerReporting; } } mWifiPowerCalculator.reset(); mWifiPowerCalculator.reset(); if (mBluetoothPowerCalculator == null) { final boolean hasBluetoothPowerReporting = checkHasBluetoothPowerReporting(mStats, if (checkHasBluetoothPowerReporting(mStats, mPowerProfile)) { mPowerProfile); if (mBluetoothPowerCalculator == null || hasBluetoothPowerReporting != mHasBluetoothPowerReporting) { mBluetoothPowerCalculator = new BluetoothPowerCalculator(mPowerProfile); mBluetoothPowerCalculator = new BluetoothPowerCalculator(mPowerProfile); } else { mHasBluetoothPowerReporting = hasBluetoothPowerReporting; mBluetoothPowerCalculator = new BluetoothPowerCalculator(mPowerProfile); } } } mBluetoothPowerCalculator.reset(); mBluetoothPowerCalculator.reset(); Loading Loading
core/java/com/android/internal/os/BatteryStatsHelper.java +17 −12 Original line number Original line Diff line number Diff line Loading @@ -126,6 +126,9 @@ public final class BatteryStatsHelper { PowerCalculator mCameraPowerCalculator; PowerCalculator mCameraPowerCalculator; PowerCalculator mFlashlightPowerCalculator; PowerCalculator mFlashlightPowerCalculator; boolean mHasWifiPowerReporting = false; boolean mHasBluetoothPowerReporting = false; public static boolean checkWifiOnly(Context context) { public static boolean checkWifiOnly(Context context) { ConnectivityManager cm = (ConnectivityManager)context.getSystemService( ConnectivityManager cm = (ConnectivityManager)context.getSystemService( Context.CONNECTIVITY_SERVICE); Context.CONNECTIVITY_SERVICE); Loading Loading @@ -349,21 +352,23 @@ public final class BatteryStatsHelper { } } mMobileRadioPowerCalculator.reset(mStats); mMobileRadioPowerCalculator.reset(mStats); if (mWifiPowerCalculator == null) { // checkHasWifiPowerReporting can change if we get energy data at a later point, so if (checkHasWifiPowerReporting(mStats, mPowerProfile)) { // always check this field. mWifiPowerCalculator = new WifiPowerCalculator(mPowerProfile); final boolean hasWifiPowerReporting = checkHasWifiPowerReporting(mStats, mPowerProfile); } else { if (mWifiPowerCalculator == null || hasWifiPowerReporting != mHasWifiPowerReporting) { mWifiPowerCalculator = new WifiPowerEstimator(mPowerProfile); mWifiPowerCalculator = hasWifiPowerReporting ? } new WifiPowerCalculator(mPowerProfile) : new WifiPowerEstimator(mPowerProfile); mHasWifiPowerReporting = hasWifiPowerReporting; } } mWifiPowerCalculator.reset(); mWifiPowerCalculator.reset(); if (mBluetoothPowerCalculator == null) { final boolean hasBluetoothPowerReporting = checkHasBluetoothPowerReporting(mStats, if (checkHasBluetoothPowerReporting(mStats, mPowerProfile)) { mPowerProfile); if (mBluetoothPowerCalculator == null || hasBluetoothPowerReporting != mHasBluetoothPowerReporting) { mBluetoothPowerCalculator = new BluetoothPowerCalculator(mPowerProfile); mBluetoothPowerCalculator = new BluetoothPowerCalculator(mPowerProfile); } else { mHasBluetoothPowerReporting = hasBluetoothPowerReporting; mBluetoothPowerCalculator = new BluetoothPowerCalculator(mPowerProfile); } } } mBluetoothPowerCalculator.reset(); mBluetoothPowerCalculator.reset(); Loading