Introduce wvmkiller

This lets us disable WVM L1 on boot up for devices where it's not
provisioned properly.

Change-Id: I6074a9fad4235ac7896851f3cd4e9ea8bf288994
This commit is contained in:
LuK1337
2024-08-08 23:47:52 +02:00
parent b460039fa2
commit 4c37ab7678
8 changed files with 91 additions and 0 deletions

1
wvmkiller/.clang-format Symbolic link
View File

@@ -0,0 +1 @@
../../../build/soong/scripts/system-clang-format

13
wvmkiller/Android.bp Normal file
View File

@@ -0,0 +1,13 @@
cc_binary {
name: "wvmkiller",
defaults: ["hidl_defaults"],
init_rc: ["wvmkiller.rc"],
vendor: true,
srcs: ["main.cpp"],
shared_libs: [
"android.hardware.drm@1.0",
"libbase",
"libhidlbase",
"libutils",
],
}

52
wvmkiller/main.cpp Normal file
View File

@@ -0,0 +1,52 @@
/*
* Copyright (C) 2024 The LineageOS 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.
*/
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android/hardware/drm/1.0/IDrmFactory.h>
using android::sp;
using android::base::SetProperty;
using android::hardware::hidl_array;
using android::hardware::hidl_string;
using android::hardware::drm::V1_0::IDrmFactory;
using android::hardware::drm::V1_0::IDrmPlugin;
using android::hardware::drm::V1_0::Status;
int main() {
const uint8_t WIDEVINE_UUID[] = {0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE,
0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED};
const auto callback = [](Status status, const sp<IDrmPlugin>& drmPlugin) {
CHECK(status == Status::OK);
drmPlugin->getPropertyString("systemId", [](Status status, const hidl_string& value) {
CHECK(status == Status::OK);
if (value.size() > 5) {
SetProperty("vendor.wvm.disable_l1", "1");
}
});
};
const auto drmFactory = IDrmFactory::getService("widevine");
CHECK(drmFactory.get() != nullptr);
drmFactory->createPlugin(hidl_array<uint8_t, 16>(WIDEVINE_UUID), "org.lineageos.wvmkiller",
callback);
return 0;
}

9
wvmkiller/wvmkiller.rc Normal file
View File

@@ -0,0 +1,9 @@
on property:vendor.wvm.disable_l1=1
export FORCE_LEVEL3_OEMCRYPTO yes
restart vendor.drm-widevine-hal-1-3
service vendor.wvmkiller /vendor/bin/wvmkiller
class late_start
user system
group system
oneshot