Snap for 7349343 from d8d5335096 to sc-release
Change-Id: I43c66bc843a38666239070440ff7416a8c35b92b
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="165dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:visibility="invisible"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
settings:textColor="?android:attr/textColorSecondary" />
|
||||
<TextView
|
||||
|
||||
@@ -25,8 +25,7 @@
|
||||
android:key="battery_graph"/>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="app_list"
|
||||
android:title="@string/power_usage_list_summary"/>
|
||||
android:key="app_list"/>
|
||||
|
||||
<com.android.settingslib.widget.FooterPreference
|
||||
android:title="@string/battery_usage_screen_footer"
|
||||
|
||||
@@ -167,6 +167,7 @@ public class BatteryAppListPreferenceController extends AbstractPreferenceContro
|
||||
super.displayPreference(screen);
|
||||
mPrefContext = screen.getContext();
|
||||
mAppListGroup = screen.findPreference(mPreferenceKey);
|
||||
mAppListGroup.setTitle(mPrefContext.getString(R.string.power_usage_list_summary));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,6 +33,7 @@ import android.widget.TextView;
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.Utils;
|
||||
|
||||
import java.util.Locale;
|
||||
@@ -59,6 +60,8 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
||||
private int mSelectedIndex;
|
||||
private float mTrapezoidVOffset;
|
||||
private float mTrapezoidHOffset;
|
||||
private boolean mIsSlotsClickable;
|
||||
|
||||
// Colors for drawing the trapezoid shape and dividers.
|
||||
private int mTrapezoidColor;
|
||||
private int mTrapezoidSolidColor;
|
||||
@@ -73,7 +76,6 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
||||
private final Rect[] mTimestampsBounds =
|
||||
new Rect[] {new Rect(), new Rect(), new Rect(), new Rect()};
|
||||
|
||||
|
||||
private int[] mLevels;
|
||||
private Paint mTextPaint;
|
||||
private Paint mDividerPaint;
|
||||
@@ -92,9 +94,9 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
||||
initializeColors(context);
|
||||
// Registers the click event listener.
|
||||
setOnClickListener(this);
|
||||
setClickable(false);
|
||||
setSelectedIndex(SELECTED_INDEX_ALL);
|
||||
setTrapezoidCount(DEFAULT_TRAPEZOID_COUNT);
|
||||
setClickable(false);
|
||||
}
|
||||
|
||||
/** Sets the total trapezoid count for drawing. */
|
||||
@@ -157,6 +159,7 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
||||
} else {
|
||||
mTextPaint = null;
|
||||
}
|
||||
setVisibility(View.VISIBLE);
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
@@ -240,6 +243,23 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
||||
view.performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
final Context context = mContext;
|
||||
mIsSlotsClickable =
|
||||
FeatureFactory.getFactory(context)
|
||||
.getPowerUsageFeatureProvider(context)
|
||||
.isChartGraphSlotsEnabled(context);
|
||||
Log.d(TAG, "isChartGraphSlotsEnabled:" + mIsSlotsClickable);
|
||||
setClickable(isClickable());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClickable(boolean clickable) {
|
||||
super.setClickable(mIsSlotsClickable && clickable);
|
||||
}
|
||||
|
||||
private void initializeColors(Context context) {
|
||||
setBackgroundColor(Color.TRANSPARENT);
|
||||
mTrapezoidSolidColor = Utils.getColorAccentDefaultColor(context);
|
||||
|
||||
@@ -214,13 +214,11 @@ public final class ConvertUtils {
|
||||
currentEntry.mBackgroundUsageTimeInMs,
|
||||
nextEntry.mBackgroundUsageTimeInMs,
|
||||
nextTwoEntry.mBackgroundUsageTimeInMs);
|
||||
final double consumePower =
|
||||
double consumePower =
|
||||
getDiffValue(
|
||||
currentEntry.mConsumePower,
|
||||
nextEntry.mConsumePower,
|
||||
nextTwoEntry.mConsumePower);
|
||||
totalConsumePower += consumePower;
|
||||
|
||||
// Excludes entry since we don't have enough data to calculate.
|
||||
if (foregroundUsageTimeInMs == 0
|
||||
&& backgroundUsageTimeInMs == 0
|
||||
@@ -246,7 +244,9 @@ public final class ConvertUtils {
|
||||
Math.round(foregroundUsageTimeInMs * ratio);
|
||||
backgroundUsageTimeInMs =
|
||||
Math.round(backgroundUsageTimeInMs * ratio);
|
||||
consumePower = consumePower * ratio;
|
||||
}
|
||||
totalConsumePower += consumePower;
|
||||
batteryDiffEntryList.add(
|
||||
new BatteryDiffEntry(
|
||||
context,
|
||||
@@ -260,10 +260,10 @@ public final class ConvertUtils {
|
||||
diffEntry.setTotalConsumePower(totalConsumePower);
|
||||
}
|
||||
}
|
||||
insert24HoursData(BatteryChartView.SELECTED_INDEX_ALL, resultMap);
|
||||
if (purgeLowPercentageAndFakeData) {
|
||||
purgeLowPercentageAndFakeData(resultMap);
|
||||
}
|
||||
insert24HoursData(BatteryChartView.SELECTED_INDEX_ALL, resultMap);
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
|
||||
@@ -132,6 +132,11 @@ public interface PowerUsageFeatureProvider {
|
||||
*/
|
||||
boolean isChartGraphEnabled(Context context);
|
||||
|
||||
/**
|
||||
* Checks whether we should show usage information by slots or not.
|
||||
*/
|
||||
boolean isChartGraphSlotsEnabled(Context context);
|
||||
|
||||
/**
|
||||
* Returns battery history data with corresponding timestamp key.
|
||||
*/
|
||||
|
||||
@@ -158,6 +158,11 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChartGraphSlotsEnabled(Context context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, Map<String, BatteryHistEntry>> getBatteryHistory(Context context) {
|
||||
return null;
|
||||
|
||||
@@ -246,12 +246,10 @@ public final class ConvertUtilsTest {
|
||||
assertBatteryDiffEntry(entryList.get(0), 75, 40L, 50L);
|
||||
// Verifies the last 24 hours aggregate result.
|
||||
entryList = purgedResultMap.get(Integer.valueOf(-1));
|
||||
assertThat(entryList).hasSize(2);
|
||||
assertThat(entryList).hasSize(1);
|
||||
// Verifies the fake data is cleared out.
|
||||
assertThat(entryList.get(0).getPackageName())
|
||||
.isNotEqualTo(ConvertUtils.FAKE_PACKAGE_NAME);
|
||||
assertThat(entryList.get(1).getPackageName())
|
||||
.isNotEqualTo(ConvertUtils.FAKE_PACKAGE_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -286,9 +284,14 @@ public final class ConvertUtilsTest {
|
||||
final List<BatteryDiffEntry> entryList = purgedResultMap.get(0);
|
||||
assertThat(entryList).hasSize(1);
|
||||
// Verifies the clipped usage time.
|
||||
final float ratio = (float) (7200) / (float) (3600 + 7200);
|
||||
final BatteryDiffEntry resultEntry = entryList.get(0);
|
||||
assertThat(resultEntry.mForegroundUsageTimeInMs).isEqualTo(2400000);
|
||||
assertThat(resultEntry.mBackgroundUsageTimeInMs).isEqualTo(4800000);
|
||||
assertThat(resultEntry.mForegroundUsageTimeInMs)
|
||||
.isEqualTo(Math.round(entry.mForegroundUsageTimeInMs * ratio));
|
||||
assertThat(resultEntry.mBackgroundUsageTimeInMs)
|
||||
.isEqualTo(Math.round(entry.mBackgroundUsageTimeInMs * ratio));
|
||||
assertThat(resultEntry.mConsumePower)
|
||||
.isEqualTo(entry.mConsumePower * ratio);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user