diff options
| author | 2017-04-08 02:26:56 +0000 | |
|---|---|---|
| committer | 2017-04-08 02:27:07 +0000 | |
| commit | 873da45918a80d59323e13b94b878dd593374025 (patch) | |
| tree | 0797a5ac9f807fd870db9947ce386234546fc4e5 | |
| parent | f49152330a161c3144f01d4d780ba70cd169781d (diff) | |
| parent | 236461444e6a29de42ab3d49e3308fd75306cd9d (diff) | |
Merge "Add HIDL Scheduler Service implementation." into oc-dev
3 files changed, 125 insertions, 0 deletions
diff --git a/services/schedulerservice/Android.bp b/services/schedulerservice/Android.bp new file mode 100644 index 0000000000..1f1340ca47 --- /dev/null +++ b/services/schedulerservice/Android.bp @@ -0,0 +1,25 @@ +cc_library_shared { + name: "libschedulerservicehidl", + srcs: [ + "SchedulingPolicyService.cpp", + ], + shared_libs: [ + "libhidlbase", + "libhidltransport", + "libhwbinder", + "libmediautils", + "liblog", + "libutils", + "android.hidl.base@1.0", + "android.frameworks.schedulerservice@1.0", + ], + header_libs: [ + "libcutils_headers", + ], + export_include_dirs: [ + "include/" + ], + local_include_dirs: [ + "include/schedulerservice/", + ], +} diff --git a/services/schedulerservice/SchedulingPolicyService.cpp b/services/schedulerservice/SchedulingPolicyService.cpp new file mode 100644 index 0000000000..522a8c0950 --- /dev/null +++ b/services/schedulerservice/SchedulingPolicyService.cpp @@ -0,0 +1,53 @@ +/* + * 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 { + +Return<bool> SchedulingPolicyService::requestPriority(int32_t pid, int32_t tid, int32_t priority) { + using ::android::hardware::IPCThreadState; + + if (priority < static_cast<int32_t>(Priority::MIN) || + priority > static_cast<int32_t>(Priority::MAX)) { + return false; + } + + if (IPCThreadState::self()->getCallingUid() != AID_CAMERASERVER) { + return false; + } + + // this should always be allowed since we are in system_server. + int value = ::android::requestPriority(pid, tid, priority, false /* isForApp */); + return value == 0 /* success */; +} + +} // namespace implementation +} // namespace V1_0 +} // namespace schedulerservice +} // namespace frameworks +} // namespace android diff --git a/services/schedulerservice/include/schedulerservice/SchedulingPolicyService.h b/services/schedulerservice/include/schedulerservice/SchedulingPolicyService.h new file mode 100644 index 0000000000..eb5a4aee9d --- /dev/null +++ b/services/schedulerservice/include/schedulerservice/SchedulingPolicyService.h @@ -0,0 +1,47 @@ +/* + * 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; +}; + +} // namespace implementation +} // namespace V1_0 +} // namespace schedulerservice +} // namespace frameworks +} // namespace android |