Cherish: Add force background freezer

Change-Id: Ic0c119282c295db9b7d4dc03c037828b02c5a9e4

Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
LibXZR
2022-07-04 21:34:43 +02:00
committed by Hưng Phan
parent 326c047131
commit 51e39f9475
3 changed files with 59 additions and 0 deletions

View File

@@ -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;
}
}