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

Commit 562ed84f authored by Steven Moreland's avatar Steven Moreland Committed by Gerrit Code Review
Browse files

Merge "Use hwservicemanager getTransport."

parents b2c75d06 f7019c2e
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -276,7 +276,8 @@ static jobject JHwBinder_native_getService(
        jstring ifaceNameObj,
        jstring serviceNameObj) {

    using ::android::vintf::operator<<;
    using ::android::hidl::base::V1_0::IBase;
    using ::android::hidl::manager::V1_0::IServiceManager;

    if (ifaceNameObj == NULL) {
        jniThrowException(env, "java/lang/NullPointerException", NULL);
@@ -318,13 +319,20 @@ static jobject JHwBinder_native_getService(
              << "/"
              << serviceName;

    ::android::vintf::Transport transport =
            ::android::hardware::getTransport(ifaceName, serviceName);
    if (   transport != ::android::vintf::Transport::EMPTY
        && transport != ::android::vintf::Transport::HWBINDER) {
    Return<IServiceManager::Transport> transportRet =
            manager->getTransport(ifaceNameHStr, serviceNameHStr);

    if (!transportRet.isOk()) {
        signalExceptionForError(env, UNKNOWN_ERROR, true /* canThrowRemoteException */);
        return NULL;
    }

    IServiceManager::Transport transport = transportRet;

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