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

Commit a83cc37d authored by Devin Moore's avatar Devin Moore Committed by Android (Google) Code Review
Browse files

Merge "Remove android.frameworks.schedulerservice" into main

parents 81acc44a 25a53ad1
Loading
Loading
Loading
Loading
+0 −32
Original line number Diff line number Diff line
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_shared {
    name: "libschedulerservicehidl",
    srcs: [
        "SchedulingPolicyService.cpp",
    ],
    cflags: ["-Wall", "-Werror"],
    shared_libs: [
        "libhidlbase",
        "libmediautils",
        "liblog",
        "libutils",
        "android.frameworks.schedulerservice@1.0",
    ],
    header_libs: [
        "libcutils_headers",
    ],
    export_include_dirs: [
        "include/"
    ],
    local_include_dirs: [
        "include/schedulerservice/",
    ],
}
+0 −67
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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 "schedulerservicehidl"

#include "SchedulingPolicyService.h"

#include <private/android_filesystem_config.h> // for AID_CAMERASERVER

#include <log/log.h>
#include <hwbinder/IPCThreadState.h>
#include <mediautils/SchedulingPolicyService.h>

namespace android {
namespace frameworks {
namespace schedulerservice {
namespace V1_0 {
namespace implementation {

bool SchedulingPolicyService::isAllowed() {
    using ::android::hardware::IPCThreadState;

    return IPCThreadState::self()->getCallingUid() == AID_CAMERASERVER;
}

Return<bool> SchedulingPolicyService::requestPriority(int32_t pid, int32_t tid, int32_t priority) {
    if (priority < static_cast<int32_t>(Priority::MIN) ||
            priority > static_cast<int32_t>(Priority::MAX)) {
        return false;
    }

    if (!isAllowed()) {
        return false;
    }

    // TODO(b/37226359): decouple from and remove AIDL service
    // this should always be allowed since we are in system_server.
    int value = ::android::requestPriority(pid, tid, priority, false /* isForApp */);
    return value == 0 /* success */;
}

Return<int32_t> SchedulingPolicyService::getMaxAllowedPriority() {
    if (!isAllowed()) {
        return 0;
    }

    // TODO(b/37226359): decouple from and remove AIDL service
    return 3;
}

}  // namespace implementation
}  // namespace V1_0
}  // namespace schedulerservice
}  // namespace frameworks
}  // namespace android
+0 −50
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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.
 */
#pragma once

#include <android/frameworks/schedulerservice/1.0/ISchedulingPolicyService.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>

namespace android {
namespace frameworks {
namespace schedulerservice {
namespace V1_0 {
namespace implementation {

using ::android::frameworks::schedulerservice::V1_0::ISchedulingPolicyService;
using ::android::hidl::base::V1_0::DebugInfo;
using ::android::hidl::base::V1_0::IBase;
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;

struct SchedulingPolicyService : public ISchedulingPolicyService {
    Return<bool> requestPriority(int32_t pid, int32_t tid, int32_t priority) override;
    Return<int32_t> getMaxAllowedPriority() override;
private:
    bool isAllowed();
};

}  // namespace implementation
}  // namespace V1_0
}  // namespace schedulerservice
}  // namespace frameworks
}  // namespace android