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

Commit bed03a5d authored by Steven Moreland's avatar Steven Moreland Committed by Automerger Merge Worker
Browse files

Merge "libbinder_ndk: way to convert AParcel to libbinder" am: ec6c073a

parents 9246c23c ec6c073a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ cc_library {
    srcs: [
        "ibinder.cpp",
        "ibinder_jni.cpp",
        "libbinder.cpp",
        "parcel.cpp",
        "parcel_jni.cpp",
        "process.cpp",
+5 −18
Original line number Diff line number Diff line
@@ -14,21 +14,19 @@
 * limitations under the License.
 */

#include <android-base/logging.h>
#include <android/binder_ibinder.h>
#include <android/binder_ibinder_platform.h>
#include <android/binder_libbinder.h>
#include "ibinder_internal.h"

#include <android/binder_stability.h>
#include <android/binder_status.h>
#include "parcel_internal.h"
#include "status_internal.h"

#include <android-base/logging.h>
#include <binder/IPCThreadState.h>
#include <binder/IResultReceiver.h>
#include <private/android_filesystem_config.h>

#include "ibinder_internal.h"
#include "parcel_internal.h"
#include "status_internal.h"

using DeathRecipient = ::android::IBinder::DeathRecipient;

using ::android::IBinder;
@@ -782,17 +780,6 @@ const char* AIBinder_getCallingSid() {
    return ::android::IPCThreadState::self()->getCallingSid();
}

android::sp<android::IBinder> AIBinder_toPlatformBinder(AIBinder* binder) {
    if (binder == nullptr) return nullptr;
    return binder->getBinder();
}

AIBinder* AIBinder_fromPlatformBinder(const android::sp<android::IBinder>& binder) {
    sp<AIBinder> ndkBinder = ABpBinder::lookupOrCreateFromBinder(binder);
    AIBinder_incStrong(ndkBinder.get());
    return ndkBinder.get();
}

void AIBinder_setMinSchedulerPolicy(AIBinder* binder, int policy, int priority) {
    binder->asABBinder()->setMinSchedulerPolicy(policy, priority);
}
+24 −0
Original line number Diff line number Diff line
@@ -19,7 +19,9 @@
#if !defined(__ANDROID_APEX__) && !defined(__ANDROID_VNDK__)

#include <android/binder_ibinder.h>
#include <android/binder_parcel.h>
#include <binder/IBinder.h>
#include <binder/Parcel.h>

/**
 * Get libbinder version of binder from AIBinder.
@@ -47,4 +49,26 @@ android::sp<android::IBinder> AIBinder_toPlatformBinder(AIBinder* binder);
 */
AIBinder* AIBinder_fromPlatformBinder(const android::sp<android::IBinder>& binder);

/**
 * View libbinder version of parcel from AParcel (mutable).
 *
 * The lifetime of the returned parcel is the lifetime of the input AParcel.
 * Do not ues this reference after dropping the AParcel.
 *
 * \param parcel non-null parcel with ownership retained by client
 * \return platform parcel object
 */
android::Parcel* AParcel_viewPlatformParcel(AParcel* parcel);

/**
 * View libbinder version of parcel from AParcel (const version).
 *
 * The lifetime of the returned parcel is the lifetime of the input AParcel.
 * Do not ues this reference after dropping the AParcel.
 *
 * \param parcel non-null parcel with ownership retained by client
 * \return platform parcel object
 */
const android::Parcel* AParcel_viewPlatformParcel(const AParcel* parcel);

#endif
+43 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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 <android/binder_libbinder.h>

#include "ibinder_internal.h"
#include "parcel_internal.h"

using ::android::IBinder;
using ::android::Parcel;
using ::android::sp;

sp<IBinder> AIBinder_toPlatformBinder(AIBinder* binder) {
    if (binder == nullptr) return nullptr;
    return binder->getBinder();
}

AIBinder* AIBinder_fromPlatformBinder(const sp<IBinder>& binder) {
    sp<AIBinder> ndkBinder = ABpBinder::lookupOrCreateFromBinder(binder);
    AIBinder_incStrong(ndkBinder.get());
    return ndkBinder.get();
}

Parcel* AParcel_viewPlatformParcel(AParcel* parcel) {
    return parcel->get();
}

const Parcel* AParcel_viewPlatformParcel(const AParcel* parcel) {
    return parcel->get();
}
+1 −0
Original line number Diff line number Diff line
@@ -158,6 +158,7 @@ LIBBINDER_NDK_PLATFORM {
    extern "C++" {
        AIBinder_fromPlatformBinder*;
        AIBinder_toPlatformBinder*;
        AParcel_viewPlatformParcel*;
    };
  local:
    *;
Loading