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

Commit 5013f984 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "libbinder: Add libbinder_ndk_on_trusty_mock" into main am: 9ecd5a25 am: b8a2ec0f

parents ac3d26f0 b8a2ec0f
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ cc_library {
        "-DBINDER_WITH_KERNEL_IPC",
        "-Wall",
        "-Wextra",
        "-Wextra-semi",
        "-Werror",
    ],

@@ -146,6 +147,46 @@ cc_library {
    afdo: true,
}

cc_library {
    name: "libbinder_ndk_on_trusty_mock",
    defaults: [
        "trusty_mock_defaults",
    ],

    export_include_dirs: [
        "include_cpp",
        "include_ndk",
        "include_platform",
    ],

    srcs: [
        "ibinder.cpp",
        "libbinder.cpp",
        "parcel.cpp",
        "stability.cpp",
        "status.cpp",
    ],

    shared_libs: [
        "libbinder_on_trusty_mock",
    ],

    header_libs: [
        "libbinder_trusty_ndk_headers",
    ],
    export_header_lib_headers: [
        "libbinder_trusty_ndk_headers",
    ],

    cflags: [
        "-Wall",
        "-Wextra",
        "-Werror",
    ],

    visibility: ["//frameworks/native/libs/binder:__subpackages__"],
}

cc_library_headers {
    name: "libbinder_headers_platform_shared",
    export_include_dirs: ["include_cpp"],
+8 −2
Original line number Diff line number Diff line
@@ -45,7 +45,9 @@ namespace ABBinderTag {

static const void* kId = "ABBinder";
static void* kValue = static_cast<void*>(new bool{true});
void clean(const void* /*id*/, void* /*obj*/, void* /*cookie*/){/* do nothing */};
void clean(const void* /*id*/, void* /*obj*/, void* /*cookie*/) {
    /* do nothing */
}

static void attach(const sp<IBinder>& binder) {
    auto alreadyAttached = binder->attachObject(kId, kValue, nullptr /*cookie*/, clean);
@@ -70,7 +72,7 @@ void clean(const void* id, void* obj, void* cookie) {
    LOG_ALWAYS_FATAL_IF(id != kId, "%p %p %p", id, obj, cookie);

    delete static_cast<Value*>(obj);
};
}

}  // namespace ABpBinderTag

@@ -609,6 +611,7 @@ binder_status_t AIBinder_unlinkToDeath(AIBinder* binder, AIBinder_DeathRecipient
    return recipient->unlinkToDeath(binder->getBinder(), cookie);
}

#ifdef BINDER_WITH_KERNEL_IPC
uid_t AIBinder_getCallingUid() {
    return ::android::IPCThreadState::self()->getCallingUid();
}
@@ -620,6 +623,7 @@ pid_t AIBinder_getCallingPid() {
bool AIBinder_isHandlingTransaction() {
    return ::android::IPCThreadState::self()->getServingStackPointer() != nullptr;
}
#endif

void AIBinder_incStrong(AIBinder* binder) {
    if (binder == nullptr) {
@@ -837,9 +841,11 @@ void AIBinder_setRequestingSid(AIBinder* binder, bool requestingSid) {
    localBinder->setRequestingSid(requestingSid);
}

#ifdef BINDER_WITH_KERNEL_IPC
const char* AIBinder_getCallingSid() {
    return ::android::IPCThreadState::self()->getCallingSid();
}
#endif

void AIBinder_setMinSchedulerPolicy(AIBinder* binder, int policy, int priority) {
    binder->asABBinder()->setMinSchedulerPolicy(policy, priority);
+1 −0
Original line number Diff line number Diff line
@@ -435,6 +435,7 @@ cc_test {
    // Add the Trusty mock library as a fake dependency so it gets built
    required: [
        "libbinder_on_trusty_mock",
        "libbinder_ndk_on_trusty_mock",
        "binderRpcTestService_on_trusty_mock",
        "binderRpcTest_on_trusty_mock",
    ],
+31 −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.
 */

package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "frameworks_native_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["frameworks_native_license"],
}

cc_library_headers {
    name: "libbinder_trusty_ndk_headers",
    export_include_dirs: ["include"],
    host_supported: true,
    vendor_available: true,
}
+5 −0
Original line number Diff line number Diff line
@@ -15,11 +15,16 @@
 */
#pragma once

#if __has_include(<lk/compiler.h>)
#include <lk/compiler.h>

/* Alias the bionic macros to the ones from lk/compiler.h */
#define __BEGIN_DECLS __BEGIN_CDECLS
#define __END_DECLS __END_CDECLS

#else // __has_include(<lk/compiler.h>)
#include_next <sys/cdefs.h>
#endif

#define __INTRODUCED_IN(x) /* nothing on Trusty */
#define __INTRODUCED_IN_LLNDK(x) /* nothing on Trusty */