Loading res/values/strings.xml +5 −0 Original line number Diff line number Diff line Loading @@ -4914,6 +4914,11 @@ <item quantity="other">%1$d apps</item> </plurals> <!-- Title for auto restriction toggle --> <string name="battery_auto_restriction_title">Restrict apps automatically</string> <!-- Summary for auto restriction toggle --> <string name="battery_auto_restriction_summary">Prevent apps from using extra battery in the background</string> <!-- Title for force stop dialog [CHAR LIMIT=30] --> <string name="dialog_stop_title">Stop app?</string> <!-- Message body for force stop dialog [CHAR LIMIT=NONE] --> Loading res/xml/smart_battery_detail.xml +9 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,9 @@ limitations under the License. --> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:settings="http://schemas.android.com/apk/res-auto" android:key="smart_battery_detail" android:title="@string/smart_battery_manager_title"> Loading @@ -32,6 +34,12 @@ android:title="@string/smart_battery_title" android:summary="@string/smart_battery_summary"/> <SwitchPreference android:key="auto_restriction" android:title="@string/battery_auto_restriction_title" android:summary="@string/battery_auto_restriction_summary" settings:controller="com.android.settings.fuelgauge.AutoRestrictionPreferenceController"/> <Preference android:key="restricted_app" android:title="@string/restricted_app_title"/> Loading src/com/android/settings/fuelgauge/AutoRestrictionPreferenceController.java 0 → 100644 +65 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 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; import android.content.Context; import android.provider.Settings; import android.support.v14.preference.SwitchPreference; import android.support.v7.preference.Preference; import com.android.settings.core.BasePreferenceController; import com.android.settings.overlay.FeatureFactory; /** * Controller to change and update the auto restriction toggle */ public class AutoRestrictionPreferenceController extends BasePreferenceController implements Preference.OnPreferenceChangeListener { private static final String KEY_SMART_BATTERY = "auto_restriction"; private static final int ON = 1; private static final int OFF = 0; private PowerUsageFeatureProvider mPowerUsageFeatureProvider; public AutoRestrictionPreferenceController(Context context) { super(context, KEY_SMART_BATTERY); mPowerUsageFeatureProvider = FeatureFactory.getFactory( context).getPowerUsageFeatureProvider(context); } @Override public int getAvailabilityStatus() { return mPowerUsageFeatureProvider.isSmartBatterySupported() ? DISABLED_UNSUPPORTED : AVAILABLE; } @Override public void updateState(Preference preference) { super.updateState(preference); final boolean smartBatteryOn = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.APP_AUTO_RESTRICTION_ENABLED, ON) == ON; ((SwitchPreference) preference).setChecked(smartBatteryOn); } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { final boolean smartBatteryOn = (Boolean) newValue; Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.APP_AUTO_RESTRICTION_ENABLED, smartBatteryOn ? ON : OFF); return true; } } src/com/android/settings/fuelgauge/PowerUsageFeatureProvider.java +5 −0 Original line number Diff line number Diff line Loading @@ -118,4 +118,9 @@ public interface PowerUsageFeatureProvider { * the caller */ boolean getEarlyWarningSignal(Context context, String id); /** * Checks whether smart battery feature is supported in this device */ boolean isSmartBatterySupported(); } src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImpl.java +5 −0 Original line number Diff line number Diff line Loading @@ -136,4 +136,9 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider public boolean getEarlyWarningSignal(Context context, String id) { return false; } @Override public boolean isSmartBatterySupported() { return false; } } Loading
res/values/strings.xml +5 −0 Original line number Diff line number Diff line Loading @@ -4914,6 +4914,11 @@ <item quantity="other">%1$d apps</item> </plurals> <!-- Title for auto restriction toggle --> <string name="battery_auto_restriction_title">Restrict apps automatically</string> <!-- Summary for auto restriction toggle --> <string name="battery_auto_restriction_summary">Prevent apps from using extra battery in the background</string> <!-- Title for force stop dialog [CHAR LIMIT=30] --> <string name="dialog_stop_title">Stop app?</string> <!-- Message body for force stop dialog [CHAR LIMIT=NONE] --> Loading
res/xml/smart_battery_detail.xml +9 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,9 @@ limitations under the License. --> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:settings="http://schemas.android.com/apk/res-auto" android:key="smart_battery_detail" android:title="@string/smart_battery_manager_title"> Loading @@ -32,6 +34,12 @@ android:title="@string/smart_battery_title" android:summary="@string/smart_battery_summary"/> <SwitchPreference android:key="auto_restriction" android:title="@string/battery_auto_restriction_title" android:summary="@string/battery_auto_restriction_summary" settings:controller="com.android.settings.fuelgauge.AutoRestrictionPreferenceController"/> <Preference android:key="restricted_app" android:title="@string/restricted_app_title"/> Loading
src/com/android/settings/fuelgauge/AutoRestrictionPreferenceController.java 0 → 100644 +65 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 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; import android.content.Context; import android.provider.Settings; import android.support.v14.preference.SwitchPreference; import android.support.v7.preference.Preference; import com.android.settings.core.BasePreferenceController; import com.android.settings.overlay.FeatureFactory; /** * Controller to change and update the auto restriction toggle */ public class AutoRestrictionPreferenceController extends BasePreferenceController implements Preference.OnPreferenceChangeListener { private static final String KEY_SMART_BATTERY = "auto_restriction"; private static final int ON = 1; private static final int OFF = 0; private PowerUsageFeatureProvider mPowerUsageFeatureProvider; public AutoRestrictionPreferenceController(Context context) { super(context, KEY_SMART_BATTERY); mPowerUsageFeatureProvider = FeatureFactory.getFactory( context).getPowerUsageFeatureProvider(context); } @Override public int getAvailabilityStatus() { return mPowerUsageFeatureProvider.isSmartBatterySupported() ? DISABLED_UNSUPPORTED : AVAILABLE; } @Override public void updateState(Preference preference) { super.updateState(preference); final boolean smartBatteryOn = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.APP_AUTO_RESTRICTION_ENABLED, ON) == ON; ((SwitchPreference) preference).setChecked(smartBatteryOn); } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { final boolean smartBatteryOn = (Boolean) newValue; Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.APP_AUTO_RESTRICTION_ENABLED, smartBatteryOn ? ON : OFF); return true; } }
src/com/android/settings/fuelgauge/PowerUsageFeatureProvider.java +5 −0 Original line number Diff line number Diff line Loading @@ -118,4 +118,9 @@ public interface PowerUsageFeatureProvider { * the caller */ boolean getEarlyWarningSignal(Context context, String id); /** * Checks whether smart battery feature is supported in this device */ boolean isSmartBatterySupported(); }
src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImpl.java +5 −0 Original line number Diff line number Diff line Loading @@ -136,4 +136,9 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider public boolean getEarlyWarningSignal(Context context, String id) { return false; } @Override public boolean isSmartBatterySupported() { return false; } }