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

Commit 9a5d6908 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 7314842 from 3dec083f to sc-release

Change-Id: I181b529ea47ec35f7ca83235b39695ef1387348f
parents 7132116d 3dec083f
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -48,16 +48,20 @@ sp<RpcConnection> RpcServer::addClientConnection() {

    auto connection = RpcConnection::make();
    connection->setForServer(sp<RpcServer>::fromExisting(this));
    {
        std::lock_guard<std::mutex> _l(mLock);
        mConnections.push_back(connection);
    }
    return connection;
}

void RpcServer::setRootObject(const sp<IBinder>& binder) {
    LOG_ALWAYS_FATAL_IF(mRootObject != nullptr, "There can only be one root object");
    std::lock_guard<std::mutex> _l(mLock);
    mRootObject = binder;
}

sp<IBinder> RpcServer::getRootObject() {
    std::lock_guard<std::mutex> _l(mLock);
    return mRootObject;
}

+4 −13
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@
#include <utils/Errors.h>
#include <utils/RefBase.h>

#include <mutex>

// WARNING: This is a feature which is still in development, and it is subject
// to radical change. Any production use of this may subject your code to any
// number of problems.
@@ -30,9 +32,6 @@ namespace android {
/**
 * This represents a server of an interface, which may be connected to by any
 * number of clients over sockets.
 *
 * This object is not (currently) thread safe. All calls to it are expected to
 * happen at process startup.
 */
class RpcServer final : public virtual RefBase {
public:
@@ -50,17 +49,9 @@ public:
     */
    sp<RpcConnection> addClientConnection();

    /**
     * Allowing a server to explicitly drop clients would be easy to add here,
     * but it is not currently implemented, since users of this functionality
     * could not use similar functionality if they are running under real
     * binder.
     */
    // void drop(const sp<RpcConnection>& connection);

    /**
     * The root object can be retrieved by any client, without any
     * authentication.
     * authentication. TODO(b/183988761)
     */
    void setRootObject(const sp<IBinder>& binder);

@@ -77,8 +68,8 @@ private:

    bool mAgreedExperimental = false;

    std::mutex mLock;
    sp<IBinder> mRootObject;

    std::vector<sp<RpcConnection>> mConnections; // per-client
};

+26 −1
Original line number Diff line number Diff line
@@ -7,17 +7,42 @@ package {
    default_applicable_licenses: ["frameworks_native_license"],
}

aidl_interface {
    name: "framework-permission-aidl",
    unstable: true,
    local_include_dir: "aidl",
    backend: {
        ndk: {
            enabled: false
        }
    },
    srcs: [
        "aidl/android/content/AttributionSourceState.aidl",
        "aidl/android/permission/IPermissionChecker.aidl",
    ],
}

cc_library_shared {
    name: "libpermission",
    cflags: [
        "-Wall",
        "-Wextra",
        "-Werror",
    ],
    srcs: [
        "AppOpsManager.cpp",
        "IAppOpsCallback.cpp",
        "IAppOpsService.cpp",
        "android/permission/PermissionChecker.cpp",
    ],
    export_include_dirs: ["include"],
    shared_libs: [
        "libutils",
        "libbinder",
        "libcutils",
        "liblog",
        "libutils",
    ],
    static_libs: [
        "framework-permission-aidl-cpp",
    ],
}
+40 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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 android.content;

/**
 * Payload for the {@link AttributionSource} class needed to interoperate
 * with different languages.
 *
 * {@hide}
 */
parcelable AttributionSourceState {
    /** The UID that is accessing the permission protected data. */
    int uid;
    /** The package that is accessing the permission protected data. */
    @nullable @utf8InCpp String packageName;
    /** The attribution tag of the app accessing the permission protected data. */
    @nullable @utf8InCpp String attributionTag;
    /** Unique token for that source. */
    @nullable IBinder token;
    /** Permissions that should be considered revoked regardless if granted. */
    @nullable @utf8InCpp String[] renouncedPermissions;
    /** The next app to receive the permission protected data. */
    // TODO: We use an array as a workaround - the C++ backend doesn't
    // support referring to the parcelable as it expects ctor/dtor
    @nullable AttributionSourceState[] next;
}
+37 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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 android.permission;

import android.content.AttributionSourceState;

/**
 * Interface to communicate directly with the permission checker service.
 */
interface IPermissionChecker {
    const int PERMISSION_GRANTED = 0;
    const int PERMISSION_SOFT_DENIED = 1;
    const int PERMISSION_HARD_DENIED = 2;

    int checkPermission(String permission, in AttributionSourceState attributionSource,
            @nullable String message, boolean forDataDelivery, boolean startDataDelivery,
            boolean fromDatasource);

    void finishDataDelivery(String op, in AttributionSourceState attributionSource);

    int checkOp(int op, in AttributionSourceState attributionSource,
            String message, boolean forDataDelivery, boolean startDataDelivery);
}
Loading