ActivityManager API to check availability of app freezer

A method to verify the availability of the app freezer is required for
configuration code running in places like the Settings app

Bug: 155465196
Change-Id: I5779d263536091689a099eec0815f207dfbbf6ad
Test: verified its workings through the developer options CL
This commit is contained in:
Marco Ballesio
2020-05-01 05:13:51 -07:00
parent 06028798b9
commit 240bea3f47
3 changed files with 17 additions and 1 deletions

View File

@@ -673,4 +673,9 @@ interface IActivityManager {
* @param state The customized state data
*/
void setProcessStateSummary(in byte[] state);
/**
* Return whether the app freezer is supported (true) or not (false) by this system.
*/
boolean isAppFreezerSupported();
}

View File

@@ -20171,4 +20171,15 @@ public class ActivityManagerService extends IActivityManager.Stub
mUsageStatsService.reportLocusUpdate(activity, userId, locusId, appToken);
}
}
@Override
public boolean isAppFreezerSupported() {
final long token = Binder.clearCallingIdentity();
try {
return mOomAdjuster.mCachedAppOptimizer.isFreezerSupported();
} finally {
Binder.restoreCallingIdentity(token);
}
}
}

View File

@@ -407,7 +407,7 @@ public final class CachedAppOptimizer {
/**
* Determines whether the freezer is correctly supported by this system
*/
public boolean isFreezerSupported() {
public static boolean isFreezerSupported() {
boolean supported = false;
FileReader fr = null;