Skip to content

Commit

Permalink
Fix DisplayControl classpath
Browse files Browse the repository at this point in the history
Use the full system server classpath to load DisplayControl, so that
turning the screen off on Android 14+ does not crash on certain devices.

Refs #4544 comment <#4544 (comment)>
Fixes #4544 <#4544>
Fixes #5274 <#5274>

Signed-off-by: Romain Vimont <[email protected]>
  • Loading branch information
yume-chan authored and rom1v committed Dec 9, 2024
1 parent a9aadc9 commit a507b4f
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.os.IBinder;
import android.system.Os;

import java.lang.reflect.Method;

Expand All @@ -21,7 +22,9 @@ public final class DisplayControl {
Class<?> classLoaderFactoryClass = Class.forName("com.android.internal.os.ClassLoaderFactory");
Method createClassLoaderMethod = classLoaderFactoryClass.getDeclaredMethod("createClassLoader", String.class, String.class, String.class,
ClassLoader.class, int.class, boolean.class, String.class);
ClassLoader classLoader = (ClassLoader) createClassLoaderMethod.invoke(null, "/system/framework/services.jar", null, null,

String systemServerClasspath = Os.getenv("SYSTEMSERVERCLASSPATH");
ClassLoader classLoader = (ClassLoader) createClassLoaderMethod.invoke(null, systemServerClasspath, null, null,
ClassLoader.getSystemClassLoader(), 0, true, null);

displayControlClass = classLoader.loadClass("com.android.server.display.DisplayControl");
Expand Down

0 comments on commit a507b4f

Please sign in to comment.