Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7cafeb8b authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Convert gUnifiedServiceManager to IBinder and use in ServiceManagerProxy" into main

parents bafef272 a43009cb
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ public final class ServiceManagerNative {
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 @@ class ServiceManagerProxy implements IServiceManager {
    private IBinder mRemote;

    private IServiceManager mServiceManager;

    private native IBinder getNativeServiceManager();
}
+1 −0
Original line number Diff line number Diff line
@@ -192,6 +192,7 @@ cc_library_shared_for_libandroid_runtime {
                "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",
+2 −0
Original line number Diff line number Diff line
@@ -148,6 +148,7 @@ extern int register_android_os_HwParcel(JNIEnv *env);
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 @@ static const RegJNIRec gRegJNI[] = {
        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),
+42 −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.
 */
#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