Add infra for battery tip

This cl adds the basic structure for battery tip:
1. BaseBatteryTip: Model class to represent the tip and build
preference and dialog
2. SummaryTip: Display a general battery summary(i.e. your battery
is good..)
3. BatteryTipLoader: AsyncLoader to load the battery tips.
4. BatteryTipPreferenceController: preference controller for
preference group to display battery tips

This cl also:
1. Remove the anomaly code in PowerUsageSummary and we will add it
to app restriction in future.
2. Add preference_category_no_title.xml to avoid the extra 32dp
blank at the top.

Bug: 70570352
Test: RunSettingsRoboTests
Change-Id: If91a553888e2eb91d55fb1d0d7bbea69652f144c
This commit is contained in:
jackqdyulei
2017-12-12 12:52:35 -08:00
parent 444989ad35
commit fde63fc351
13 changed files with 700 additions and 65 deletions

View File

@@ -0,0 +1,58 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.fuelgauge.batterytip;
import android.content.Context;
import com.android.internal.os.BatteryStatsHelper;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.SummaryTip;
import com.android.settingslib.utils.AsyncLoader;
import java.util.ArrayList;
import java.util.List;
/**
* Loader to compute and return a battery tip list. It will always return a full length list even
* though some tips may have state {@code BaseBatteryTip.StateType.INVISIBLE}.
*/
public class BatteryTipLoader extends AsyncLoader<List<BatteryTip>> {
private static final String TAG = "BatteryTipLoader";
private static final boolean USE_FAKE_DATA = false;
private BatteryStatsHelper mBatteryStatsHelper;
public BatteryTipLoader(Context context, BatteryStatsHelper batteryStatsHelper) {
super(context);
mBatteryStatsHelper = batteryStatsHelper;
}
@Override
public List<BatteryTip> loadInBackground() {
List<BatteryTip> tips = new ArrayList<>();
//TODO(b/70570352): add battery tip detectors
tips.add(new SummaryTip(BatteryTip.StateType.NEW));
return tips;
}
@Override
protected void onDiscardResult(List<BatteryTip> result) {
}
}