Revert "Add adaptive charging to the top level settings menu"

Revert submission 12989357-fix_ac_menu

Reason for revert: Bug: 176473169
Reverted Changes:
I6fc50a5ae:Add adaptive charging to the top level settings me...
I8f600287c:Add adaptive charging to the top level settings me...

Change-Id: I2928a96112bb8d2beeb071f231af6595edead4fa
This commit is contained in:
Daniel Chapin
2020-12-29 17:55:13 +00:00
parent 8fee0917f8
commit 2f51836ca1
6 changed files with 23 additions and 87 deletions

View File

@@ -26,21 +26,18 @@ import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.FeatureFlags;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
public class TopLevelBatteryPreferenceController extends BasePreferenceController implements
LifecycleObserver, OnStart, OnStop, BatteryPreferenceController {
LifecycleObserver, OnStart, OnStop {
@VisibleForTesting
protected boolean mIsBatteryPresent = true;
boolean mIsBatteryPresent = true;
private final BatteryBroadcastReceiver mBatteryBroadcastReceiver;
private Preference mPreference;
private BatteryInfo mBatteryInfo;
private BatteryStatusFeatureProvider mBatteryStatusFeatureProvider;
private String mBatteryStatusLabel;
public TopLevelBatteryPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
@@ -54,9 +51,6 @@ public class TopLevelBatteryPreferenceController extends BasePreferenceControlle
updateState(mPreference);
}, true /* shortString */);
});
mBatteryStatusFeatureProvider = FeatureFactory.getFactory(context)
.getBatteryStatusFeatureProvider(context);
}
@Override
@@ -94,42 +88,20 @@ public class TopLevelBatteryPreferenceController extends BasePreferenceControlle
return getDashboardLabel(mContext, mBatteryInfo);
}
protected CharSequence getDashboardLabel(Context context, BatteryInfo info) {
static CharSequence getDashboardLabel(Context context, BatteryInfo info) {
if (info == null || context == null) {
return null;
}
CharSequence label;
if (!mBatteryStatusFeatureProvider.triggerBatteryStatusUpdate(this, info)
|| mBatteryStatusLabel == null) {
label = generateLabel(info);
} else {
label = mBatteryStatusLabel;
}
return label;
}
private CharSequence generateLabel(BatteryInfo info) {
if (!info.discharging && info.chargeLabel != null) {
return info.chargeLabel;
label = info.chargeLabel;
} else if (info.remainingLabel == null) {
return info.batteryPercentString;
label = info.batteryPercentString;
} else {
return mContext.getString(R.string.power_remaining_settings_home_page,
label = context.getString(R.string.power_remaining_settings_home_page,
info.batteryPercentString,
info.remainingLabel);
}
}
/**
* Callback which receives text for the label.
*/
public void updateBatteryStatus(String label, BatteryInfo info) {
mBatteryStatusLabel = (label != null) ? label : generateLabel(info).toString();
if (mPreference != null) {
updateState(mPreference);
}
return label;
}
}