mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-22 04:05:31 -04:00
universal7885: SamsungParts: add gpu, selinux and update related sepolicy
This commit is contained in:
parent
1bcf57f719
commit
c1a9d9f071
36 changed files with 632 additions and 170 deletions
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
package vendor.eureka.hardware.flashlight@1.0;
|
||||
|
||||
interface IFlashLight {
|
||||
interface IFlashlight {
|
||||
setFlashlightWritable(Number value) generates (int32_t result);
|
||||
setFlashlightEnable(Enable enable) generates (int32_t result);
|
||||
readFlashlightstats(Device device) generates (int32_t value);
|
||||
|
|
|
|||
|
|
@ -19,18 +19,18 @@
|
|||
namespace vendor::eureka::hardware::flashlight::V1_0 {
|
||||
|
||||
// Methods from ::android::hardware::flashlight::V1_0::IFlashlight follow.
|
||||
Return<int32_t> Flashlight::getFlashlightStats(flashlight::V1_0::Enable enable) {
|
||||
Return<int32_t> Flashlight::setFlashlightEnable(flashlight::V1_0::Enable enable) {
|
||||
std::ofstream file;
|
||||
std::string writevalue;
|
||||
switch (enable){
|
||||
case Number::ENABLE:
|
||||
case Enable::ENABLE:
|
||||
writevalue = "1";
|
||||
break;
|
||||
case Number::DISABLE:
|
||||
case Enable::DISABLE:
|
||||
writevalue = "0";
|
||||
break;
|
||||
default:
|
||||
filename = "";
|
||||
writevalue = "";
|
||||
break;
|
||||
}
|
||||
file.open("/sys/class/camera/flash/torch_brightness_lvl_enable");
|
||||
|
|
@ -74,7 +74,7 @@ Return<int32_t> Flashlight::setFlashlightWritable(flashlight::V1_0::Number value
|
|||
writevalue = "10";
|
||||
break;
|
||||
default:
|
||||
filename = "";
|
||||
writevalue = "";
|
||||
break;
|
||||
}
|
||||
file.open("/sys/class/camera/flash/torch_brightness_lvl");
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@ using ::android::sp;
|
|||
|
||||
struct Flashlight : public IFlashlight {
|
||||
// Methods from ::vendor::eureka::hardware::flashlight::V1_0::IFlashlight follow.
|
||||
Return<int32_t> Flashlight::getFlashlightStats(flashlight::V1_0::Enable enable);
|
||||
Return<int32_t> Flashlight::setFlashlightWritable(flashlight::V1_0::Number value);
|
||||
Return<int32_t> Flashlight::readFlashlightstats(flashlight::V1_0::Device device);
|
||||
Return<int32_t> setFlashlightEnable(Enable enable);
|
||||
Return<int32_t> setFlashlightWritable(Number value);
|
||||
Return<int32_t> readFlashlightstats(Device device);
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
static IFlashlight* getInstance(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -35,4 +35,4 @@ enum Number : int32_t {
|
|||
enum Enable : int32_t {
|
||||
ENABLE,
|
||||
DISABLE,
|
||||
}
|
||||
};
|
||||
|
|
|
|||
10
universal7885-common/interfaces/hardware/gpu/1.0/Android.bp
Normal file
10
universal7885-common/interfaces/hardware/gpu/1.0/Android.bp
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
hidl_interface {
|
||||
name: "vendor.eureka.hardware.gpu@1.0",
|
||||
root: "vendor.eureka",
|
||||
srcs: [
|
||||
"types.hal",
|
||||
"IGpu.hal",
|
||||
],
|
||||
interfaces: [ "android.hidl.base@1.0" ],
|
||||
gen_java: true,
|
||||
}
|
||||
20
universal7885-common/interfaces/hardware/gpu/1.0/IGpu.hal
Normal file
20
universal7885-common/interfaces/hardware/gpu/1.0/IGpu.hal
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (C) 2021 Eureka Team
|
||||
//
|
||||
// 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 vendor.eureka.hardware.gpu@1.0;
|
||||
|
||||
interface IGpu {
|
||||
setGpuWritable(Enable enable) generates (int32_t result);
|
||||
readGpustats() generates (int32_t value);
|
||||
};
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// FIXME: your file license if you have one
|
||||
|
||||
cc_binary {
|
||||
name: "vendor.eureka.hardware.gpu@1.0-service",
|
||||
relative_install_path: "hw",
|
||||
proprietary: true,
|
||||
srcs: [
|
||||
"Gpu.cpp",
|
||||
"service.cpp",
|
||||
],
|
||||
shared_libs: [
|
||||
"libhidlbase",
|
||||
"libutils",
|
||||
"liblog",
|
||||
"vendor.eureka.hardware.gpu@1.0",
|
||||
],
|
||||
init_rc: [ "vendor.eureka.hardware.gpu@1.0-service.rc" ],
|
||||
vintf_fragments: [ "vendor.eureka.hardware.gpu@1.0.xml" ],
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
// Copyright (C) 2021 Eureka Team
|
||||
//
|
||||
// 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.
|
||||
|
||||
#include "Gpu.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
namespace vendor::eureka::hardware::gpu::V1_0 {
|
||||
|
||||
Return<int32_t> Gpu::setGpuWritable(gpu::V1_0::Enable enable) {
|
||||
std::ofstream file;
|
||||
std::string writevalue;
|
||||
if (enable == Enable::ENABLE){
|
||||
writevalue = "1";
|
||||
}else{
|
||||
writevalue = "0";
|
||||
}
|
||||
file.open("/sys/devices/platform/11500000.mali/tmu");
|
||||
file << writevalue;
|
||||
file.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Return<int32_t> Gpu::readGpustats(void) {
|
||||
std::ifstream file;
|
||||
std::string value;
|
||||
int32_t intvalue;
|
||||
file.open("/sys/devices/platform/11500000.mali/tmu");
|
||||
if (file.is_open()) {
|
||||
getline(file, value);
|
||||
file.close();
|
||||
std::stringstream val(value);
|
||||
val >> intvalue;
|
||||
return intvalue;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
IGpu *Gpu::getInstance(void){
|
||||
return new Gpu();
|
||||
}
|
||||
} // namespace android::hardware::gpu::implementation
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright (C) 2021 Eureka Team
|
||||
//
|
||||
// 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 <vendor/eureka/hardware/gpu/1.0/IGpu.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
namespace vendor::eureka::hardware::gpu::V1_0 {
|
||||
|
||||
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 Gpu : public IGpu {
|
||||
// Methods from ::vendor::eureka::hardware::gpu::V1_0::IGpu follow.
|
||||
Return<int32_t> setGpuWritable(Enable enable);
|
||||
Return<int32_t> readGpustats(void);
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
static IGpu* getInstance(void);
|
||||
|
||||
};
|
||||
} // namespace android::hardware::gpu::implementation
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
// Copyright (C) 2021 Eureka Team
|
||||
//
|
||||
// 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 "vendor.eureka.hardware.gpu@1.0-service"
|
||||
|
||||
#include <vendor/eureka/hardware/gpu/1.0/IGpu.h>
|
||||
|
||||
#include <hidl/LegacySupport.h>
|
||||
|
||||
#include "Gpu.h"
|
||||
|
||||
using vendor::eureka::hardware::gpu::V1_0::IGpu;
|
||||
using vendor::eureka::hardware::gpu::V1_0::Gpu;
|
||||
using android::hardware::configureRpcThreadpool;
|
||||
using android::hardware::joinRpcThreadpool;
|
||||
using android::sp;
|
||||
|
||||
int main() {
|
||||
int ret;
|
||||
android::sp<IGpu> service = Gpu::getInstance();
|
||||
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
||||
|
||||
if (service != nullptr) {
|
||||
ret = service->registerAsService();
|
||||
if(ret != 0) {
|
||||
ALOGE("Can't register instance of Gpu HAL, nullptr");
|
||||
}else{
|
||||
ALOGI("registered Gpu HAL");
|
||||
}
|
||||
} else {
|
||||
ALOGE("Can't create instance of Gpu HAL, nullptr");
|
||||
}
|
||||
|
||||
joinRpcThreadpool();
|
||||
|
||||
return -1; // should never get here
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
service vendor.gpu-hal /vendor/bin/hw/vendor.eureka.hardware.gpu@1.0-service
|
||||
interface vendor.eureka.hardware.gpu@1.0::IGpu default
|
||||
class hal
|
||||
user root
|
||||
group root
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<manifest version="1.0" type="device" target-level="3">
|
||||
<hal format="hidl">
|
||||
<name>vendor.eureka.hardware.gpu</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>1.0</version>
|
||||
<interface>
|
||||
<name>IGpu</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</manifest>
|
||||
20
universal7885-common/interfaces/hardware/gpu/1.0/types.hal
Normal file
20
universal7885-common/interfaces/hardware/gpu/1.0/types.hal
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (C) 2021 Eureka Team
|
||||
//
|
||||
// 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 vendor.eureka.hardware.gpu@1.0;
|
||||
|
||||
enum Enable : int32_t {
|
||||
ENABLE,
|
||||
DISABLE,
|
||||
};
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
hidl_interface {
|
||||
name: "vendor.eureka.security.selinux@1.0",
|
||||
root: "vendor.eureka",
|
||||
srcs: [
|
||||
"types.hal",
|
||||
"ISELinux.hal",
|
||||
],
|
||||
interfaces: [ "android.hidl.base@1.0" ],
|
||||
gen_java: true,
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (C) 2021 Eureka Team
|
||||
//
|
||||
// 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 vendor.eureka.security.selinux@1.0;
|
||||
|
||||
interface ISELinux {
|
||||
setSELinuxWritable(Enable enable) generates (int32_t result);
|
||||
readSELinuxstats() generates (int32_t value);
|
||||
};
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// FIXME: your file license if you have one
|
||||
|
||||
cc_binary {
|
||||
name: "vendor.eureka.security.selinux@1.0-service",
|
||||
relative_install_path: "hw",
|
||||
proprietary: true,
|
||||
srcs: [
|
||||
"SELinux.cpp",
|
||||
"service.cpp",
|
||||
],
|
||||
shared_libs: [
|
||||
"libhidlbase",
|
||||
"libutils",
|
||||
"liblog",
|
||||
"vendor.eureka.security.selinux@1.0",
|
||||
],
|
||||
init_rc: [ "vendor.eureka.security.selinux@1.0-service.rc" ],
|
||||
vintf_fragments: [ "vendor.eureka.security.selinux@1.0.xml" ],
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
// Copyright (C) 2021 Eureka Team
|
||||
//
|
||||
// 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.
|
||||
|
||||
#include "SELinux.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
namespace vendor::eureka::security::selinux::V1_0 {
|
||||
|
||||
Return<int32_t> SELinux::setSELinuxWritable(selinux::V1_0::Enable enable) {
|
||||
std::ofstream file;
|
||||
std::string writevalue;
|
||||
if (enable == Enable::ENABLE){
|
||||
writevalue = "1";
|
||||
}else{
|
||||
writevalue = "0";
|
||||
}
|
||||
file.open("/sys/fs/selinux/enforce");
|
||||
file << writevalue;
|
||||
file.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Return<int32_t> SELinux::readSELinuxstats(void) {
|
||||
std::ifstream file;
|
||||
std::string value;
|
||||
int32_t intvalue;
|
||||
file.open("/sys/fs/selinux/enforce");
|
||||
if (file.is_open()) {
|
||||
getline(file, value);
|
||||
file.close();
|
||||
std::stringstream val(value);
|
||||
val >> intvalue;
|
||||
return intvalue;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
ISELinux *SELinux::getInstance(void){
|
||||
return new SELinux();
|
||||
}
|
||||
} // namespace android::security::selinux::implementation
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright (C) 2021 Eureka Team
|
||||
//
|
||||
// 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 <vendor/eureka/security/selinux/1.0/ISELinux.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
namespace vendor::eureka::security::selinux::V1_0 {
|
||||
|
||||
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 SELinux : public ISELinux {
|
||||
// Methods from ::vendor::eureka::security::selinux::V1_0::ISELinux follow.
|
||||
Return<int32_t> setSELinuxWritable(Enable enable);
|
||||
Return<int32_t> readSELinuxstats(void);
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
static ISELinux* getInstance(void);
|
||||
|
||||
};
|
||||
} // namespace android::security::selinux::implementation
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
// Copyright (C) 2021 Eureka Team
|
||||
//
|
||||
// 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 "vendor.eureka.security.selinux@1.0-service"
|
||||
|
||||
#include <vendor/eureka/security/selinux/1.0/ISELinux.h>
|
||||
|
||||
#include <hidl/LegacySupport.h>
|
||||
|
||||
#include "SELinux.h"
|
||||
|
||||
using vendor::eureka::security::selinux::V1_0::ISELinux;
|
||||
using vendor::eureka::security::selinux::V1_0::SELinux;
|
||||
using android::hardware::configureRpcThreadpool;
|
||||
using android::hardware::joinRpcThreadpool;
|
||||
using android::sp;
|
||||
|
||||
int main() {
|
||||
int ret;
|
||||
android::sp<ISELinux> service = SELinux::getInstance();
|
||||
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
||||
|
||||
if (service != nullptr) {
|
||||
ret = service->registerAsService();
|
||||
if(ret != 0) {
|
||||
ALOGE("Can't register instance of SELinux HAL, nullptr");
|
||||
}else{
|
||||
ALOGI("registered SELinux HAL");
|
||||
}
|
||||
} else {
|
||||
ALOGE("Can't create instance of SELinux HAL, nullptr");
|
||||
}
|
||||
|
||||
joinRpcThreadpool();
|
||||
|
||||
return -1; // should never get here
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
service vendor.selinux-hal /vendor/bin/hw/vendor.eureka.security.selinux@1.0-service
|
||||
interface vendor.eureka.security.selinux@1.0::ISELinux default
|
||||
class hal
|
||||
user root
|
||||
group root
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<manifest version="1.0" type="device" target-level="3">
|
||||
<hal format="hidl">
|
||||
<name>vendor.eureka.security.selinux</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>1.0</version>
|
||||
<interface>
|
||||
<name>ISELinux</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</manifest>
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (C) 2021 Eureka Team
|
||||
//
|
||||
// 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 vendor.eureka.security.selinux@1.0;
|
||||
|
||||
enum Enable : int32_t {
|
||||
ENABLE,
|
||||
DISABLE,
|
||||
};
|
||||
Loading…
Reference in a new issue