Loading services/core/java/com/android/server/ConsumerIrService.java +6 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.util.Slog; import com.android.server.utils.LazyJniRegistrar; public class ConsumerIrService extends IConsumerIrService.Stub { private static final String TAG = "ConsumerIrService"; Loading @@ -39,6 +41,10 @@ public class ConsumerIrService extends IConsumerIrService.Stub { private static native int halTransmit(int carrierFrequency, int[] pattern); private static native int[] halGetCarrierFrequencies(); static { LazyJniRegistrar.registerConsumerIrService(); } private final Context mContext; private final PowerManager.WakeLock mWakeLock; private final boolean mHasNativeHal; Loading services/core/java/com/android/server/utils/LazyJniRegistrar.java 0 → 100644 +47 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * 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.android.server.utils; import com.android.tools.r8.keepanno.annotations.KeepItemKind; import com.android.tools.r8.keepanno.annotations.MethodAccessFlags; import com.android.tools.r8.keepanno.annotations.UsedByNative; /** * Utility class for lazily registering native methods for a given class. * * <p><strong>Note: </strong>Most native methods are registered eagerly via the * native {@code JNI_OnLoad} hook when system server loads its primary native * lib. However, some classes within system server may be stripped if unused. * This class offers a way to selectively register their native methods. Such * register calls should typically be done from that class's {@code static {}} * init block. */ @UsedByNative( description = "Referenced from JNI in jni/com_android_server_utils_LazyJniRegistrar.cpp", kind = KeepItemKind.CLASS_AND_MEMBERS, methodAccess = {MethodAccessFlags.NATIVE}) public final class LazyJniRegistrar { // Note: {@link SystemServer#run} loads the native "android_servers" lib, so no need to do so // explicitly here. Classes that use this registration must not be initialized before this. /** Registers native methods for ConsumerIrService. */ public static native void registerConsumerIrService(); /** Registers native methods for VrManagerService. */ public static native void registerVrManagerService(); } services/core/java/com/android/server/utils/OWNERS +1 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ per-file Watcher.java = file:/services/core/java/com/android/server/pm/OWNERS per-file Watcher.java = shombert@google.com per-file EventLogger.java = file:/platform/frameworks/av:/media/janitors/media_solutions_OWNERS per-file EventLogger.java = jmtrivi@google.com per-file LazyJniRegistrar.java = file:/PERFORMANCE_OWNERS # Bug component : 158088 = per-file AnrTimer*.java per-file AnrTimer*.java = file:/PERFORMANCE_OWNERS Loading services/core/java/com/android/server/vr/VrManagerService.java +5 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ import com.android.server.FgThread; import com.android.server.LocalServices; import com.android.server.SystemConfig; import com.android.server.SystemService; import com.android.server.utils.LazyJniRegistrar; import com.android.server.utils.ManagedApplicationService; import com.android.server.utils.ManagedApplicationService.BinderChecker; import com.android.server.utils.ManagedApplicationService.LogEvent; Loading Loading @@ -131,6 +132,10 @@ public class VrManagerService extends SystemService private static native void initializeNative(); private static native void setVrModeNative(boolean enabled); static { LazyJniRegistrar.registerVrManagerService(); } private final Object mLock = new Object(); private final IBinder mOverlayToken = new Binder(); Loading services/core/jni/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ cc_library_static { "com_android_server_am_LowMemDetector.cpp", "com_android_server_pm_PackageManagerShellCommandDataLoader.cpp", "com_android_server_sensor_SensorService.cpp", "com_android_server_utils_LazyJniRegistrar.cpp", "com_android_server_wm_TaskFpsCallbackController.cpp", "onload.cpp", ":lib_cachedAppOptimizer_native", Loading Loading
services/core/java/com/android/server/ConsumerIrService.java +6 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.util.Slog; import com.android.server.utils.LazyJniRegistrar; public class ConsumerIrService extends IConsumerIrService.Stub { private static final String TAG = "ConsumerIrService"; Loading @@ -39,6 +41,10 @@ public class ConsumerIrService extends IConsumerIrService.Stub { private static native int halTransmit(int carrierFrequency, int[] pattern); private static native int[] halGetCarrierFrequencies(); static { LazyJniRegistrar.registerConsumerIrService(); } private final Context mContext; private final PowerManager.WakeLock mWakeLock; private final boolean mHasNativeHal; Loading
services/core/java/com/android/server/utils/LazyJniRegistrar.java 0 → 100644 +47 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * 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.android.server.utils; import com.android.tools.r8.keepanno.annotations.KeepItemKind; import com.android.tools.r8.keepanno.annotations.MethodAccessFlags; import com.android.tools.r8.keepanno.annotations.UsedByNative; /** * Utility class for lazily registering native methods for a given class. * * <p><strong>Note: </strong>Most native methods are registered eagerly via the * native {@code JNI_OnLoad} hook when system server loads its primary native * lib. However, some classes within system server may be stripped if unused. * This class offers a way to selectively register their native methods. Such * register calls should typically be done from that class's {@code static {}} * init block. */ @UsedByNative( description = "Referenced from JNI in jni/com_android_server_utils_LazyJniRegistrar.cpp", kind = KeepItemKind.CLASS_AND_MEMBERS, methodAccess = {MethodAccessFlags.NATIVE}) public final class LazyJniRegistrar { // Note: {@link SystemServer#run} loads the native "android_servers" lib, so no need to do so // explicitly here. Classes that use this registration must not be initialized before this. /** Registers native methods for ConsumerIrService. */ public static native void registerConsumerIrService(); /** Registers native methods for VrManagerService. */ public static native void registerVrManagerService(); }
services/core/java/com/android/server/utils/OWNERS +1 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ per-file Watcher.java = file:/services/core/java/com/android/server/pm/OWNERS per-file Watcher.java = shombert@google.com per-file EventLogger.java = file:/platform/frameworks/av:/media/janitors/media_solutions_OWNERS per-file EventLogger.java = jmtrivi@google.com per-file LazyJniRegistrar.java = file:/PERFORMANCE_OWNERS # Bug component : 158088 = per-file AnrTimer*.java per-file AnrTimer*.java = file:/PERFORMANCE_OWNERS Loading
services/core/java/com/android/server/vr/VrManagerService.java +5 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ import com.android.server.FgThread; import com.android.server.LocalServices; import com.android.server.SystemConfig; import com.android.server.SystemService; import com.android.server.utils.LazyJniRegistrar; import com.android.server.utils.ManagedApplicationService; import com.android.server.utils.ManagedApplicationService.BinderChecker; import com.android.server.utils.ManagedApplicationService.LogEvent; Loading Loading @@ -131,6 +132,10 @@ public class VrManagerService extends SystemService private static native void initializeNative(); private static native void setVrModeNative(boolean enabled); static { LazyJniRegistrar.registerVrManagerService(); } private final Object mLock = new Object(); private final IBinder mOverlayToken = new Binder(); Loading
services/core/jni/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ cc_library_static { "com_android_server_am_LowMemDetector.cpp", "com_android_server_pm_PackageManagerShellCommandDataLoader.cpp", "com_android_server_sensor_SensorService.cpp", "com_android_server_utils_LazyJniRegistrar.cpp", "com_android_server_wm_TaskFpsCallbackController.cpp", "onload.cpp", ":lib_cachedAppOptimizer_native", Loading