Cherish: Add force background freezer
Change-Id: Ic0c119282c295db9b7d4dc03c037828b02c5a9e4 Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
@@ -864,4 +864,8 @@
|
||||
<!-- Strict standby -->
|
||||
<string name="strict_standby_policy_title">Strict standby policy</string>
|
||||
<string name="strict_standby_policy_summary">When dismissing from recents, this will force stop apps with restricted battery usage and impose stronger restrictions to them. Also, all app standby restrictions will be imposed even when device is charging.</string>
|
||||
|
||||
<!-- Force background freezer -->
|
||||
<string name="force_background_freezer_title">Background tasks freezer</string>
|
||||
<string name="force_background_freezer_summary">Freeze tasks with restricted battery usage when moving them to background and unfreeze them when moving to foreground. This could save battery slightly but may lead to crashes and background ANR.</string>
|
||||
</resources>
|
||||
|
||||
@@ -40,6 +40,13 @@
|
||||
android:key="strict_standby_policy"
|
||||
android:title="@string/strict_standby_policy_title"
|
||||
android:summary="@string/strict_standby_policy_summary"
|
||||
android:defaultValue="false"/>
|
||||
|
||||
<com.cherish.settings.preferences.GlobalSettingSwitchPreference
|
||||
android:key="force_background_freezer"
|
||||
android:title="@string/force_background_freezer_title"
|
||||
android:summary="@string/force_background_freezer_summary"
|
||||
settings:controller="com.cherish.settings.preferences.ForceBackgroundFreezePreferenceController"
|
||||
android:defaultValue="false"/>
|
||||
|
||||
<!-- Gaming mode -->
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Project Kaleidoscope
|
||||
*
|
||||
* 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.cherish.settings.preferences;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.R;
|
||||
|
||||
public class ForceBackgroundFreezePreferenceController extends BasePreferenceController {
|
||||
private static final String TAG = "ForceBackgroundFreezePreferenceController";
|
||||
|
||||
public ForceBackgroundFreezePreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
@AvailabilityStatus
|
||||
public int getAvailabilityStatus() {
|
||||
int ret = UNSUPPORTED_ON_DEVICE;
|
||||
|
||||
try {
|
||||
if (ActivityManager.getService().isAppFreezerEnabled())
|
||||
ret = AVAILABLE;
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Unable to obtain freezer enabling status from ActivityManager");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user