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

Commit 1dadaf45 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5409551 from 605ee5e4 to qt-release

Change-Id: I01a672f5112150d9b080979da8477a295a41dcc0
parents d3e2efbb 605ee5e4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -171,7 +171,7 @@ binder::Status checkArgumentUuidTestOrNull(const std::unique_ptr<std::string>& u
}

binder::Status checkArgumentPackageName(const std::string& packageName) {
    if (is_valid_package_name(packageName.c_str())) {
    if (is_valid_package_name(packageName)) {
        return ok();
    } else {
        return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
+4 −4
Original line number Diff line number Diff line
@@ -1564,7 +1564,7 @@ class RunDexoptAnalyzer : public ExecVHelper {
        if (vdex_fd >= 0) {
            AddArg(vdex_fd_arg);
        }
        AddArg(zip_fd_arg.c_str());
        AddArg(zip_fd_arg);
        if (profile_was_updated) {
            AddArg(assume_profile_changed);
        }
@@ -1572,9 +1572,9 @@ class RunDexoptAnalyzer : public ExecVHelper {
            AddArg(downgrade_flag);
        }
        if (class_loader_context != nullptr) {
            AddArg(class_loader_context_arg.c_str());
            AddArg(class_loader_context_arg);
            if (!class_loader_context_fds.empty()) {
                AddArg(class_loader_context_fds_arg.c_str());
                AddArg(class_loader_context_fds_arg);
            }
        }

@@ -2259,7 +2259,7 @@ bool reconcile_secondary_dex_file(const std::string& dex_path,
        drop_capabilities(uid);

        const char* volume_uuid_cstr = volume_uuid == nullptr ? nullptr : volume_uuid->c_str();
        if (!validate_secondary_dex_path(pkgname.c_str(), dex_path.c_str(), volume_uuid_cstr,
        if (!validate_secondary_dex_path(pkgname, dex_path, volume_uuid_cstr,
                uid, storage_flag)) {
            LOG(ERROR) << "Could not validate secondary dex path " << dex_path;
            _exit(kReconcileSecondaryDexValidationError);
+5 −12
Original line number Diff line number Diff line
@@ -50,19 +50,19 @@ struct InputApplicationInfo {
class InputApplicationHandle : public RefBase {
public:
    inline const InputApplicationInfo* getInfo() const {
        return mInfo;
        return &mInfo;
    }

    inline std::string getName() const {
        return mInfo ? mInfo->name : "<invalid>";
        return !mInfo.name.empty() ? mInfo.name : "<invalid>";
    }

    inline nsecs_t getDispatchingTimeout(nsecs_t defaultValue) const {
        return mInfo ? mInfo->dispatchingTimeout : defaultValue;
        return mInfo.token ? mInfo.dispatchingTimeout : defaultValue;
    }

    inline sp<IBinder> getApplicationToken() const {
        return mInfo ? mInfo->token : nullptr;
        return mInfo.token;
    }

    /**
@@ -75,18 +75,11 @@ public:
     * Returns true on success, or false if the handle is no longer valid.
     */
    virtual bool updateInfo() = 0;

    /**
     * Releases the storage used by the associated information when it is
     * no longer needed.
     */
    void releaseInfo();

protected:
    InputApplicationHandle();
    virtual ~InputApplicationHandle();

    InputApplicationInfo* mInfo;
    InputApplicationInfo mInfo;
};

} // namespace android
+65 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.
 */

// libandroid_runtime_lazy is a shim library.
// This provides very limited small set of APIs from libandroid_runtime.
//
// By depending on this instead of libandroid_runtime,
// a library can be loaded without paying the cost of libandroid_runtime
// which is quite huge. The cost will be paid when libandroid_runtime is actually used.
//
// For Partial-source PDK build, there is a constraint that
// frameworks/native modules should not depend on frameworks/base.
// This library can be used to cut down the dependency between them.
// (e.g. libbinder_ndk)
//
// Some libraries which serve as LL-NDK and NDK as well may depend on this
// instead of libandroid_runtime. When they are used by a vendor process,
// depending on libandroid_runtime is meaningless. In this case,
// they can depend on libandroid_runtime_lazy.
cc_library {
    name: "libandroid_runtime_lazy",
    vendor_available: true,

    cflags: [
        "-Wall",
        "-Werror",
        "-Wunused",
        "-Wunreachable-code",
    ],

    srcs: [
        "android_runtime_lazy.cpp",
    ],

    shared_libs: [
        "liblog",
        "libutils",
    ],

    required: [
        "libandroid_runtime",
    ],

    export_include_dirs: [
        "include",
    ],

    header_libs: [
        "jni_headers",
        "libbinder_headers",
    ],
}
+98 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.
 */
#define LOG_TAG "ANDROID_RUNTIME_LAZY"
#include "android_runtime/AndroidRuntime.h"
#include "android_util_Binder.h"

#include <dlfcn.h>
#include <mutex>

#include <log/log.h>

namespace android {
namespace {

std::once_flag loadFlag;

typedef JNIEnv* (*getJNIEnv_t)();
typedef sp<IBinder> (*ibinderForJavaObject_t)(JNIEnv* env, jobject obj);
typedef jobject (*javaObjectForIBinder_t)(JNIEnv* env, const sp<IBinder>& val);

getJNIEnv_t _getJNIEnv;
ibinderForJavaObject_t _ibinderForJavaObject;
javaObjectForIBinder_t _javaObjectForIBinder;

void load() {
    std::call_once(loadFlag, []() {
        void* handle = dlopen("libandroid_runtime.so", RTLD_LAZY);
        if (handle == nullptr) {
            ALOGE("Could not open libandroid_runtime.");
            return;
        }

        _getJNIEnv = reinterpret_cast<getJNIEnv_t>(
                dlsym(handle, "_ZN7android14AndroidRuntime9getJNIEnvEv"));
        if (_getJNIEnv == nullptr) {
            ALOGW("Could not find getJNIEnv.");
            // no return
        }

        _ibinderForJavaObject = reinterpret_cast<ibinderForJavaObject_t>(
                dlsym(handle, "_ZN7android20ibinderForJavaObjectEP7_JNIEnvP8_jobject"));
        if (_ibinderForJavaObject == nullptr) {
            ALOGW("Could not find ibinderForJavaObject.");
            // no return
        }

        _javaObjectForIBinder = reinterpret_cast<javaObjectForIBinder_t>(
                dlsym(handle,
                      "_ZN7android20javaObjectForIBinderEP7_JNIEnvRKNS_2spINS_7IBinderEEE"));
        if (_javaObjectForIBinder == nullptr) {
            ALOGW("Could not find javaObjectForIBinder.");
            // no return
        }
    });
}

} // namespace

// exports delegate functions

JNIEnv* AndroidRuntime::getJNIEnv() {
    load();
    if (_getJNIEnv == nullptr) {
        return nullptr;
    }
    return _getJNIEnv();
}

sp<IBinder> ibinderForJavaObject(JNIEnv* env, jobject obj) {
    load();
    if (_ibinderForJavaObject == nullptr) {
        return nullptr;
    }
    return _ibinderForJavaObject(env, obj);
}

jobject javaObjectForIBinder(JNIEnv* env, const sp<IBinder>& val) {
    load();
    if (_javaObjectForIBinder == nullptr) {
        return nullptr;
    }
    return _javaObjectForIBinder(env, val);
}

} // namespace android
Loading