interfaces: Add stub mtkpower service
* This keeps Camera HAL happy without MediaTek's
  PowerHAL.

Signed-off-by: bengris32 <bengris32@protonmail.ch>
diff --git a/mtkpower/1.2/default/Android.bp b/mtkpower/1.2/default/Android.bp
new file mode 100644
index 0000000..a8264e0
--- /dev/null
+++ b/mtkpower/1.2/default/Android.bp
@@ -0,0 +1,21 @@
+cc_binary {
+    name: "vendor.mediatek.hardware.mtkpower@1.2-service.stub",
+    defaults: ["hidl_defaults"],
+    init_rc: ["vendor.mediatek.hardware.mtkpower@1.2-service.stub.rc"],
+    vendor: true,
+    relative_install_path: "hw",
+    srcs: [
+        "MtkPerf.cpp",
+        "MtkPower.cpp",
+        "MtkPowerCallback.cpp",
+        "service.cpp",
+    ],
+    shared_libs: [
+        "libbase",
+        "libhidlbase",
+        "libutils",
+        "vendor.mediatek.hardware.mtkpower@1.0",
+        "vendor.mediatek.hardware.mtkpower@1.1",
+        "vendor.mediatek.hardware.mtkpower@1.2",
+    ],
+}
diff --git a/mtkpower/1.2/default/MtkPerf.cpp b/mtkpower/1.2/default/MtkPerf.cpp
new file mode 100644
index 0000000..64266fd
--- /dev/null
+++ b/mtkpower/1.2/default/MtkPerf.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2022 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.1 (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.1
+ *
+ * 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.mediatek.hardware.mtkpower@1.2-service.stub"
+
+#include <android-base/logging.h>
+
+#include "MtkPerf.h"
+
+namespace vendor::mediatek::hardware::mtkpower::implementation {
+
+// Methods from ::vendor::mediatek::hardware::mtkpower::V1_0::IMtkPerf follow.
+Return<int32_t> MtkPerf::perfLockAcquire(int32_t pl_handle, uint32_t duration, const hidl_vec<int32_t>& /* boostsList */, int32_t reserved) {
+    LOG(INFO) << "perfLockAcquire pl_handle: " << pl_handle
+              << " duration: " << duration << " reserved: "
+              << reserved;
+    return pl_handle;
+}
+
+Return<void> MtkPerf::perfLockRelease(int32_t pl_handle, int32_t reserved) {
+    LOG(INFO) << "perfLockRelease pl_handle: " << pl_handle
+              << " reserved: " << reserved;
+    return Void();
+}
+
+
+// Methods from ::vendor::mediatek::hardware::mtkpower::V1_1::IMtkPerf follow.
+Return<int32_t> MtkPerf::perfCusLockHint(int32_t hint, uint32_t duration) {
+    LOG(INFO) << "perfCusLockHint hint: " << hint
+              << " duraton: " << duration;
+    return 233;
+}
+
+
+// Methods from ::vendor::mediatek::hardware::mtkpower::V1_2::IMtkPerf follow.
+Return<int32_t> MtkPerf::perfLockReleaseSync(int32_t pl_handle, int32_t reserved) {
+    LOG(INFO) << "perfLockReleaseSync pl_handle: " << pl_handle
+              << " reserved: " << reserved;
+    return 0;
+}
+
+}  // namespace vendor::mediatek::hardware::mtkpower::implementation
diff --git a/mtkpower/1.2/default/MtkPerf.h b/mtkpower/1.2/default/MtkPerf.h
new file mode 100644
index 0000000..ea62cd4
--- /dev/null
+++ b/mtkpower/1.2/default/MtkPerf.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2022 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.1 (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.1
+ *
+ * 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/mediatek/hardware/mtkpower/1.2/IMtkPerf.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+
+namespace vendor::mediatek::hardware::mtkpower::implementation {
+
+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 MtkPerf : public V1_2::IMtkPerf {
+    // Methods from ::vendor::mediatek::hardware::mtkpower::V1_0::IMtkPerf follow.
+    Return<int32_t> perfLockAcquire(int32_t pl_handle, uint32_t duration, const hidl_vec<int32_t>& boostsList, int32_t reserved) override;
+    Return<void> perfLockRelease(int32_t pl_handle, int32_t reserved) override;
+
+    // Methods from ::vendor::mediatek::hardware::mtkpower::V1_1::IMtkPerf follow.
+    Return<int32_t> perfCusLockHint(int32_t hint, uint32_t duration) override;
+
+    // Methods from ::vendor::mediatek::hardware::mtkpower::V1_2::IMtkPerf follow.
+    Return<int32_t> perfLockReleaseSync(int32_t pl_handle, int32_t reserved) override;
+};
+
+}  // namespace vendor::mediatek::hardware::mtkpower::implementation
diff --git a/mtkpower/1.2/default/MtkPower.cpp b/mtkpower/1.2/default/MtkPower.cpp
new file mode 100644
index 0000000..acc8975
--- /dev/null
+++ b/mtkpower/1.2/default/MtkPower.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2022 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.1 (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.1
+ *
+ * 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.mediatek.hardware.mtkpower@1.2-service.stub"
+
+#include <android-base/logging.h>
+
+#include "MtkPower.h"
+
+namespace vendor::mediatek::hardware::mtkpower::implementation {
+
+// Methods from ::vendor::mediatek::hardware::mtkpower::V1_0::IMtkPower follow.
+Return<void> MtkPower::mtkCusPowerHint(int32_t hint, int32_t data) {
+    LOG(INFO) << "mtkCusPowerHint hint: " << hint
+              << " data: " << data;
+    return Void();
+}
+
+Return<void> MtkPower::mtkPowerHint(int32_t hint, int32_t data) {
+    LOG(INFO) << "mtkPowerHint hint: " << hint
+              << " data: " << data;
+    return Void();
+}
+
+Return<void> MtkPower::notifyAppState(const hidl_string& pack, const hidl_string& act, int32_t pid, int32_t state, int32_t uid) {
+    LOG(INFO) << "notifyAppState pack: " << pack
+              << " act: " << act << " pid: " << pid
+              << " state: " << state << " uid: " << uid;
+    return Void();
+}
+
+Return<int32_t> MtkPower::querySysInfo(int32_t cmd, int32_t param) {
+    LOG(INFO) << "querySysInfo cmd: " << cmd
+              << " param: " << param;
+    return 0;
+}
+
+Return<int32_t> MtkPower::setSysInfo(int32_t type, const hidl_string& data) {
+    LOG(INFO) << "setSysInfo type: " << type
+              << " data: " << data;
+    return 0;
+}
+
+Return<int32_t> MtkPower::setSysInfoAsync(int32_t type, const hidl_string& data) {
+    LOG(INFO) << "setSysInfoAsync type: " << type
+              << " data: " << data;
+    return 0;
+}
+
+
+// Methods from ::vendor::mediatek::hardware::mtkpower::V1_1::IMtkPower follow.
+Return<int32_t> MtkPower::setMtkPowerCallback(const sp<::vendor::mediatek::hardware::mtkpower::V1_1::IMtkPowerCallback>& /* callback */) {
+    LOG(WARNING) << "setMtkPowerCallback";
+    return 0;
+}
+
+
+// Methods from ::vendor::mediatek::hardware::mtkpower::V1_2::IMtkPower follow.
+Return<int32_t> MtkPower::setMtkScnUpdateCallback(int32_t /* hint */, const sp<::vendor::mediatek::hardware::mtkpower::V1_2::IMtkPowerCallback>& /* callback */) {
+    LOG(WARNING) << "setMtkScnUpdateCallback";
+    return 0;
+}
+
+}  // namespace vendor::mediatek::hardware::mtkpower::implementation
diff --git a/mtkpower/1.2/default/MtkPower.h b/mtkpower/1.2/default/MtkPower.h
new file mode 100644
index 0000000..d91da14
--- /dev/null
+++ b/mtkpower/1.2/default/MtkPower.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2022 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.1 (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.1
+ *
+ * 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/mediatek/hardware/mtkpower/1.2/IMtkPower.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+
+namespace vendor::mediatek::hardware::mtkpower::implementation {
+
+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 MtkPower : public V1_2::IMtkPower {
+    // Methods from ::vendor::mediatek::hardware::mtkpower::V1_0::IMtkPower follow.
+    Return<void> mtkCusPowerHint(int32_t hint, int32_t data) override;
+    Return<void> mtkPowerHint(int32_t hint, int32_t data) override;
+    Return<void> notifyAppState(const hidl_string& pack, const hidl_string& act, int32_t pid, int32_t state, int32_t uid) override;
+    Return<int32_t> querySysInfo(int32_t cmd, int32_t param) override;
+    Return<int32_t> setSysInfo(int32_t type, const hidl_string& data) override;
+    Return<int32_t> setSysInfoAsync(int32_t type, const hidl_string& data) override;
+
+    // Methods from ::vendor::mediatek::hardware::mtkpower::V1_1::IMtkPower follow.
+    Return<int32_t> setMtkPowerCallback(const sp<::vendor::mediatek::hardware::mtkpower::V1_1::IMtkPowerCallback>& callback) override;
+
+    // Methods from ::vendor::mediatek::hardware::mtkpower::V1_2::IMtkPower follow.
+    Return<int32_t> setMtkScnUpdateCallback(int32_t hint, const sp<::vendor::mediatek::hardware::mtkpower::V1_2::IMtkPowerCallback>& callback) override;
+};
+
+}  // namespace vendor::mediatek::hardware::mtkpower::implementation
diff --git a/mtkpower/1.2/default/MtkPowerCallback.cpp b/mtkpower/1.2/default/MtkPowerCallback.cpp
new file mode 100644
index 0000000..aaacc8b
--- /dev/null
+++ b/mtkpower/1.2/default/MtkPowerCallback.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2022 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.1 (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.1
+ *
+ * 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.mediatek.hardware.mtkpower@1.2-service.stub"
+
+#include <android-base/logging.h>
+
+#include "MtkPowerCallback.h"
+
+namespace vendor::mediatek::hardware::mtkpower::implementation {
+
+// Methods from ::vendor::mediatek::hardware::mtkpower::V1_1::IMtkPowerCallback follow.
+Return<void> MtkPowerCallback::mtkPowerHint(int32_t /* hint */, int32_t /* duration */) {
+    return Void();
+}
+
+Return<void> MtkPowerCallback::notifyAppState(const hidl_string& /* pack */, const hidl_string& /* act */, int32_t /* pid */, int32_t /* state */, int32_t /* uid */) {
+    return Void();
+}
+
+
+// Methods from ::vendor::mediatek::hardware::mtkpower::V1_2::IMtkPowerCallback follow.
+Return<void> MtkPowerCallback::notifyScnUpdate(int32_t /* hint */, int32_t /* data */) {
+    return Void();
+}
+
+}  // namespace vendor::mediatek::hardware::mtkpower::implementation
diff --git a/mtkpower/1.2/default/MtkPowerCallback.h b/mtkpower/1.2/default/MtkPowerCallback.h
new file mode 100644
index 0000000..3ffa81f
--- /dev/null
+++ b/mtkpower/1.2/default/MtkPowerCallback.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2022 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.1 (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.1
+ *
+ * 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/mediatek/hardware/mtkpower/1.2/IMtkPowerCallback.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+
+namespace vendor::mediatek::hardware::mtkpower::implementation {
+
+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 MtkPowerCallback : public V1_2::IMtkPowerCallback {
+    // Methods from ::vendor::mediatek::hardware::mtkpower::V1_1::IMtkPowerCallback follow.
+    Return<void> mtkPowerHint(int32_t hint, int32_t duration) override;
+    Return<void> notifyAppState(const hidl_string& pack, const hidl_string& act, int32_t pid, int32_t state, int32_t uid) override;
+
+    // Methods from ::vendor::mediatek::hardware::mtkpower::V1_2::IMtkPowerCallback follow.
+    Return<void> notifyScnUpdate(int32_t hint, int32_t data) override;
+};
+
+}  // namespace vendor::mediatek::hardware::mtkpower::implementation
diff --git a/mtkpower/1.2/default/service.cpp b/mtkpower/1.2/default/service.cpp
new file mode 100644
index 0000000..d411a7d
--- /dev/null
+++ b/mtkpower/1.2/default/service.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2022 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.1 (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.1
+ *
+ * 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.mediatek.hardware.mtkpower@1.2-service.stub"
+
+#include <android-base/logging.h>
+#include <hidl/HidlTransportSupport.h>
+
+#include "MtkPower.h"
+#include "MtkPerf.h"
+
+using android::OK;
+using android::sp;
+using android::status_t;
+using android::hardware::configureRpcThreadpool;
+using android::hardware::joinRpcThreadpool;
+
+using vendor::mediatek::hardware::mtkpower::V1_2::IMtkPower;
+using vendor::mediatek::hardware::mtkpower::V1_2::IMtkPerf;
+
+using vendor::mediatek::hardware::mtkpower::implementation::MtkPower;
+using vendor::mediatek::hardware::mtkpower::implementation::MtkPerf;
+
+int main() {
+    configureRpcThreadpool(1, true /*callerWillJoin*/);
+
+    sp<IMtkPower> mtkPower = new MtkPower();
+    sp<IMtkPerf> mtkPerf = new MtkPerf();
+
+    if (mtkPower->registerAsService() != android::OK) {
+        LOG(ERROR) << "Can't register MtkPower Stub HAL service";
+        return 1;
+    }
+
+    if (mtkPerf->registerAsService() != android::OK) {
+        LOG(ERROR) << "Can't register MtkPerf Stub HAL service";
+        return 1;
+    }
+
+    joinRpcThreadpool();
+
+    return 0;  // should never get here
+}
diff --git a/mtkpower/1.2/default/vendor.mediatek.hardware.mtkpower@1.2-service.stub.rc b/mtkpower/1.2/default/vendor.mediatek.hardware.mtkpower@1.2-service.stub.rc
new file mode 100644
index 0000000..5aae40c
--- /dev/null
+++ b/mtkpower/1.2/default/vendor.mediatek.hardware.mtkpower@1.2-service.stub.rc
@@ -0,0 +1,4 @@
+service power-hal-1-2 /vendor/bin/hw/vendor.mediatek.hardware.mtkpower@1.2-service.stub
+    class hal
+    user system
+    group system