CachedAppOptimizer: don't hardcode freezer path
Test: verified that the freezer is correctly detected Bug: 168058155 Change-Id: Ia594282f62ce934d124fa5f89da75cd58fd6ed78
This commit is contained in:
@@ -537,6 +537,12 @@ public final class CachedAppOptimizer {
|
||||
*/
|
||||
private static native int getBinderFreezeInfo(int pid);
|
||||
|
||||
/**
|
||||
* Returns the path to be checked to verify whether the freezer is supported by this system.
|
||||
* @return absolute path to the file
|
||||
*/
|
||||
private static native String getFreezerCheckPath();
|
||||
|
||||
/**
|
||||
* Determines whether the freezer is supported by this system
|
||||
*/
|
||||
@@ -545,7 +551,7 @@ public final class CachedAppOptimizer {
|
||||
FileReader fr = null;
|
||||
|
||||
try {
|
||||
fr = new FileReader("/sys/fs/cgroup/uid_0/cgroup.freeze");
|
||||
fr = new FileReader(getFreezerCheckPath());
|
||||
char state = (char) fr.read();
|
||||
|
||||
if (state == '1' || state == '0') {
|
||||
|
||||
@@ -278,6 +278,11 @@ static jint com_android_server_am_CachedAppOptimizer_getBinderFreezeInfo(JNIEnv
|
||||
return retVal;
|
||||
}
|
||||
|
||||
static jstring com_android_server_am_CachedAppOptimizer_getFreezerCheckPath(JNIEnv* env,
|
||||
jobject clazz) {
|
||||
return env->NewStringUTF(CGROUP_FREEZE_PATH);
|
||||
}
|
||||
|
||||
static const JNINativeMethod sMethods[] = {
|
||||
/* name, signature, funcPtr */
|
||||
{"compactSystem", "()V", (void*)com_android_server_am_CachedAppOptimizer_compactSystem},
|
||||
@@ -286,7 +291,9 @@ static const JNINativeMethod sMethods[] = {
|
||||
(void*)com_android_server_am_CachedAppOptimizer_enableFreezerInternal},
|
||||
{"freezeBinder", "(IZ)V", (void*)com_android_server_am_CachedAppOptimizer_freezeBinder},
|
||||
{"getBinderFreezeInfo", "(I)I",
|
||||
(void*)com_android_server_am_CachedAppOptimizer_getBinderFreezeInfo}};
|
||||
(void*)com_android_server_am_CachedAppOptimizer_getBinderFreezeInfo},
|
||||
{"getFreezerCheckPath", "()Ljava/lang/String;",
|
||||
(void*)com_android_server_am_CachedAppOptimizer_getFreezerCheckPath}};
|
||||
|
||||
int register_android_server_am_CachedAppOptimizer(JNIEnv* env)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user