Merge "Add Overview team to SystemUI OWNERS" into main
diff --git a/core/java/android/os/ServiceManagerNative.java b/core/java/android/os/ServiceManagerNative.java
index f2143f6..7b91dd5 100644
--- a/core/java/android/os/ServiceManagerNative.java
+++ b/core/java/android/os/ServiceManagerNative.java
@@ -50,7 +50,7 @@
class ServiceManagerProxy implements IServiceManager {
public ServiceManagerProxy(IBinder remote) {
mRemote = remote;
- mServiceManager = IServiceManager.Stub.asInterface(remote);
+ mServiceManager = IServiceManager.Stub.asInterface(this.getNativeServiceManager());
}
public IBinder asBinder() {
@@ -128,4 +128,6 @@
private IBinder mRemote;
private IServiceManager mServiceManager;
+
+ private native IBinder getNativeServiceManager();
}
diff --git a/core/jni/Android.bp b/core/jni/Android.bp
index 8a230de..ce19965 100644
--- a/core/jni/Android.bp
+++ b/core/jni/Android.bp
@@ -192,6 +192,7 @@
"android_os_PerformanceHintManager.cpp",
"android_os_SELinux.cpp",
"android_os_ServiceManager.cpp",
+ "android_os_ServiceManagerNative.cpp",
"android_os_SharedMemory.cpp",
"android_os_storage_StorageManager.cpp",
"android_os_UEventObserver.cpp",
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index aa63f4f..9111129 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -148,6 +148,7 @@
extern int register_android_os_HwRemoteBinder(JNIEnv *env);
extern int register_android_os_NativeHandle(JNIEnv *env);
extern int register_android_os_ServiceManager(JNIEnv *env);
+extern int register_android_os_ServiceManagerNative(JNIEnv* env);
extern int register_android_os_MessageQueue(JNIEnv* env);
extern int register_android_os_Parcel(JNIEnv* env);
extern int register_android_os_PerformanceHintManager(JNIEnv* env);
@@ -1542,6 +1543,7 @@
REG_JNI(register_android_os_HwRemoteBinder),
REG_JNI(register_android_os_NativeHandle),
REG_JNI(register_android_os_ServiceManager),
+ REG_JNI(register_android_os_ServiceManagerNative),
REG_JNI(register_android_os_storage_StorageManager),
REG_JNI(register_android_service_DataLoaderService),
REG_JNI(register_android_view_DisplayEventReceiver),
diff --git a/core/jni/android_os_ServiceManagerNative.cpp b/core/jni/android_os_ServiceManagerNative.cpp
new file mode 100644
index 0000000..39a3013
--- /dev/null
+++ b/core/jni/android_os_ServiceManagerNative.cpp
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+#include <binder/IServiceManagerFFI.h>
+#include <jni.h>
+#include <nativehelper/JNIHelp.h>
+
+#include "android_util_Binder.h"
+namespace android {
+
+jobject JNICALL Java_android_os_ServiceManagerProxy_getNativeServiceManager(JNIEnv *env,
+ jobject obj) {
+ sp<IBinder> service = IInterface::asBinder(
+ impl::getJavaServicemanagerImplPrivateDoNotUseExceptInTheOnePlaceItIsUsed());
+ return javaObjectForIBinder(env, service);
+}
+
+// ----------------------------------------------------------------------------
+
+static const JNINativeMethod serviceManagerNativeMethods[] = {
+ /* name, signature, funcPtr */
+ {"getNativeServiceManager", "()Landroid/os/IBinder;",
+ (void *)Java_android_os_ServiceManagerProxy_getNativeServiceManager}};
+
+int register_android_os_ServiceManagerNative(JNIEnv *env) {
+ return jniRegisterNativeMethods(env, "android/os/ServiceManagerProxy",
+ serviceManagerNativeMethods,
+ NELEM(serviceManagerNativeMethods));
+}
+} // namespace android
\ No newline at end of file