Update related UI if battery is not present
This change is to update the related UI in the battery page if the battery is not present. This includes the following updates: 1. Update the summary of battery tile in the Settings homepage 2. Replace the battery level with "Unknown" 3. Replace the summary with help message in the battery page 4. Remove the battery meter icon Bug: 171368508 Test: verify on an issue device Change-Id: I892e0d137143160a0bce0c11ce9265120ebb8fd4
This commit is contained in:
@@ -56,8 +56,8 @@ import com.android.settingslib.widget.LayoutPreference;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Displays a list of apps and subsystems that consume power, ordered by how much power was
|
||||
* consumed since the last time it was unplugged.
|
||||
* Displays a list of apps and subsystems that consume power, ordered by how much power was consumed
|
||||
* since the last time it was unplugged.
|
||||
*/
|
||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||
public class PowerUsageSummary extends PowerUsageBase implements OnLongClickListener,
|
||||
@@ -220,7 +220,9 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
|
||||
KEY_TIME_SINCE_LAST_FULL_CHARGE);
|
||||
mBatteryUtils = BatteryUtils.getInstance(getContext());
|
||||
|
||||
restartBatteryInfoLoader();
|
||||
if (Utils.isBatteryPresent(getContext())) {
|
||||
restartBatteryInfoLoader();
|
||||
}
|
||||
mBatteryTipPreferenceController.restoreInstanceState(icicle);
|
||||
updateBatteryTipFlag(icicle);
|
||||
}
|
||||
@@ -287,6 +289,10 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
// Skip refreshing UI if battery is not present.
|
||||
if (!mIsBatteryPresent) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip BatteryTipLoader if device is rotated or only battery level change
|
||||
if (mNeedUpdateBatteryTip
|
||||
@@ -295,7 +301,6 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
|
||||
} else {
|
||||
mNeedUpdateBatteryTip = true;
|
||||
}
|
||||
|
||||
// reload BatteryInfo and updateUI
|
||||
restartBatteryInfoLoader();
|
||||
updateLastFullChargePreference();
|
||||
@@ -354,6 +359,10 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
|
||||
if (getContext() == null) {
|
||||
return;
|
||||
}
|
||||
// Skip restartBatteryInfoLoader if battery is not present.
|
||||
if (!mIsBatteryPresent) {
|
||||
return;
|
||||
}
|
||||
getLoaderManager().restartLoader(BATTERY_INFO_LOADER, Bundle.EMPTY,
|
||||
mBatteryInfoLoaderCallbacks);
|
||||
if (mPowerFeatureProvider.isEstimateDebugEnabled()) {
|
||||
@@ -378,7 +387,10 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
|
||||
@Override
|
||||
protected void restartBatteryStatsLoader(@BatteryUpdateType int refreshType) {
|
||||
super.restartBatteryStatsLoader(refreshType);
|
||||
mBatteryHeaderPreferenceController.quickUpdateHeaderPreference();
|
||||
// Update battery header if battery is present.
|
||||
if (mIsBatteryPresent) {
|
||||
mBatteryHeaderPreferenceController.quickUpdateHeaderPreference();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -392,7 +404,6 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
|
||||
restartBatteryTipLoader();
|
||||
}
|
||||
|
||||
|
||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider(R.xml.power_usage_summary);
|
||||
}
|
||||
|
Reference in New Issue
Block a user