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

Commit 8ddfeb06 authored by Devin Moore's avatar Devin Moore Committed by Automerger Merge Worker
Browse files

Merge changes from topic...

Merge changes from topic "revert-2870060-revert-2866127-HwNoService-EIABNUAXKH-SMYTAJDJZM" into main am: 3d64cfe6

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2871713



Change-Id: I2e0ccf169d0c11c699c515894bcdb86b5c80c5aa
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents dee14e8b 3d64cfe6
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -218,6 +218,13 @@ public class HidlSupport {
    @SystemApi
    @SystemApi
    public static native int getPidIfSharable();
    public static native int getPidIfSharable();


    /**
     * Return true if HIDL is supported on this device and false if not.
     *
     * @hide
     */
    public static native boolean isHidlSupported();

    /** @hide */
    /** @hide */
    public HidlSupport() {}
    public HidlSupport() {}
}
}
+12 −0
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package android.os;


import android.annotation.SystemApi;
import android.annotation.SystemApi;
import android.compat.annotation.UnsupportedAppUsage;
import android.compat.annotation.UnsupportedAppUsage;
import android.util.Log;


import libcore.util.NativeAllocationRegistry;
import libcore.util.NativeAllocationRegistry;


@@ -78,6 +79,17 @@ public abstract class HwBinder implements IHwBinder {
            String iface,
            String iface,
            String serviceName)
            String serviceName)
        throws RemoteException, NoSuchElementException {
        throws RemoteException, NoSuchElementException {
        if (!HidlSupport.isHidlSupported()
                && (iface.equals("android.hidl.manager@1.0::IServiceManager")
                        || iface.equals("android.hidl.manager@1.1::IServiceManager")
                        || iface.equals("android.hidl.manager@1.2::IServiceManager"))) {
            Log.i(
                    TAG,
                    "Replacing Java hwservicemanager with a fake HwNoService"
                            + " because HIDL is not supported on this device.");
            return new HwNoService();
        }

        return getService(iface, serviceName, false /* retry */);
        return getService(iface, serviceName, false /* retry */);
    }
    }
    /**
    /**
+52 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2023 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 android.os;

/**
 * A fake hwservicemanager that is used locally when HIDL isn't supported on the device.
 *
 * @hide
 */
final class HwNoService implements IHwBinder, IHwInterface {
    /** @hide */
    @Override
    public void transact(int code, HwParcel request, HwParcel reply, int flags) {}

    /** @hide */
    @Override
    public IHwInterface queryLocalInterface(String descriptor) {
        return new HwNoService();
    }

    /** @hide */
    @Override
    public boolean linkToDeath(DeathRecipient recipient, long cookie) {
        return true;
    }

    /** @hide */
    @Override
    public boolean unlinkToDeath(DeathRecipient recipient) {
        return true;
    }

    /** @hide */
    @Override
    public IHwBinder asBinder() {
        return this;
    }
}
+7 −1
Original line number Original line Diff line number Diff line
@@ -15,6 +15,7 @@
 */
 */


#include <hidl/HidlTransportSupport.h>
#include <hidl/HidlTransportSupport.h>
#include <hidl/ServiceManagement.h>
#include <nativehelper/JNIHelp.h>
#include <nativehelper/JNIHelp.h>


#include "core_jni_helpers.h"
#include "core_jni_helpers.h"
@@ -24,8 +25,13 @@ static jint android_os_HidlSupport_getPidIfSharable(JNIEnv*, jclass) {
    return android::hardware::details::getPidIfSharable();
    return android::hardware::details::getPidIfSharable();
}
}


static jboolean android_os_HidlSupport_isHidlSupported(JNIEnv*, jclass) {
    return android::hardware::isHidlSupported();
}

static const JNINativeMethod gHidlSupportMethods[] = {
static const JNINativeMethod gHidlSupportMethods[] = {
        {"getPidIfSharable", "()I", (void*)android_os_HidlSupport_getPidIfSharable},
        {"getPidIfSharable", "()I", (void*)android_os_HidlSupport_getPidIfSharable},
        {"isHidlSupported", "()Z", (void*)android_os_HidlSupport_isHidlSupported},
};
};


const char* const kHidlSupportPathName = "android/os/HidlSupport";
const char* const kHidlSupportPathName = "android/os/HidlSupport";