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

Commit 2cf5a3f4 authored by Steven Moreland's avatar Steven Moreland
Browse files

HIDL: C++ Java parity

Add same restrictions to Java that we have in C++ HIDL
code for C++ services.

Test: hidl_test_java, multiple internal devices work
Bug: 38415912
Merged-In: I48571a5cd94b0ba6b1f722d032e45aac6e9527ed
Change-Id: I48571a5cd94b0ba6b1f722d032e45aac6e9527ed
parent 9eb635c4
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -318,6 +318,13 @@ LOCAL_CFLAGS += -Wall -Werror -Wno-error=deprecated-declarations -Wunused -Wunre
#                        is not being compiled with that level. Remove once this has changed.
#                        is not being compiled with that level. Remove once this has changed.
LOCAL_CLANG_CFLAGS += -Wno-c++11-extensions
LOCAL_CLANG_CFLAGS += -Wno-c++11-extensions


ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
LOCAL_CFLAGS += -D__ANDROID_DEBUGGABLE__
endif
ifneq (,$(filter true, $(PRODUCT_FULL_TREBLE)))
LOCAL_CFLAGS += -D__ANDROID_TREBLE__
endif

include $(BUILD_SHARED_LIBRARY)
include $(BUILD_SHARED_LIBRARY)


include $(call all-makefiles-under,$(LOCAL_PATH))
include $(call all-makefiles-under,$(LOCAL_PATH))
+15 −2
Original line number Original line Diff line number Diff line
@@ -23,6 +23,8 @@
#include "android_os_HwParcel.h"
#include "android_os_HwParcel.h"
#include "android_os_HwRemoteBinder.h"
#include "android_os_HwRemoteBinder.h"


#include <cstring>

#include <JNIHelp.h>
#include <JNIHelp.h>
#include <android/hidl/manager/1.0/IServiceManager.h>
#include <android/hidl/manager/1.0/IServiceManager.h>
#include <android/hidl/base/1.0/IBase.h>
#include <android/hidl/base/1.0/IBase.h>
@@ -331,8 +333,19 @@ static jobject JHwBinder_native_getService(


    IServiceManager::Transport transport = transportRet;
    IServiceManager::Transport transport = transportRet;


    if (   transport != IServiceManager::Transport::EMPTY
#ifdef __ANDROID_TREBLE__
        && transport != IServiceManager::Transport::HWBINDER) {
#ifdef __ANDROID_DEBUGGABLE__
    const char* testingOverride = std::getenv("TREBLE_TESTING_OVERRIDE");
    const bool vintfLegacy = (transport == IServiceManager::Transport::EMPTY)
            && testingOverride && !strcmp(testingOverride, "true");
#else // __ANDROID_TREBLE__ but not __ANDROID_DEBUGGABLE__
    const bool vintfLegacy = false;
#endif // __ANDROID_DEBUGGABLE__
#else // not __ANDROID_TREBLE__
    const bool vintfLegacy = (transport == IServiceManager::Transport::EMPTY);
#endif // __ANDROID_TREBLE__";

    if (transport != IServiceManager::Transport::HWBINDER && !vintfLegacy) {
        LOG(ERROR) << "service " << ifaceName << " declares transport method "
        LOG(ERROR) << "service " << ifaceName << " declares transport method "
                   << toString(transport) << " but framework expects hwbinder.";
                   << toString(transport) << " but framework expects hwbinder.";
        signalExceptionForError(env, UNKNOWN_ERROR, true /* canThrowRemoteException */);
        signalExceptionForError(env, UNKNOWN_ERROR, true /* canThrowRemoteException */);