RM6785: Set correct default device name

 * also switch to PascalCase for init_RM6785_vendor

Change-Id: Ie0d2abd91618cdbb6e84ae551ea1c00ae5d62897
diff --git a/device.mk b/device.mk
index fc42e00..3bf15c1 100644
--- a/device.mk
+++ b/device.mk
@@ -175,7 +175,14 @@
 PRODUCT_PACKAGES += \
     FrameworksOverlayRMX2151 \
     FrameworksOverlayRMX2161 \
-    SettingsOverlayRM6785
+    SettingsOverlayRM6785 \
+    SettingsProviderOverlay6 \
+    SettingsProviderOverlay6i \
+    SettingsProviderOverlay6s \
+    SettingsProviderOverlay7 \
+    SettingsProviderOverlayNarzo \
+    SettingsProviderOverlayNarzo20Pro \
+    SettingsProviderOverlayNarzo30
 
 # RRO (Runtime Resource Overlay)
 PRODUCT_ENFORCE_RRO_TARGETS += *
diff --git a/init/init_RM6785_vendor.cpp b/init/init_RM6785_vendor.cpp
index 85733d7..af6574d 100644
--- a/init/init_RM6785_vendor.cpp
+++ b/init/init_RM6785_vendor.cpp
@@ -12,39 +12,55 @@
 constexpr const char* kProcOperatorPath = "/proc/oppoVersion/operatorName";
 constexpr const char* kPropPowerProfile = "ro.vendor.power_profile.device";
 constexpr const char* kPropNfcDevice = "ro.vendor.nfc_device";
+constexpr const char* kPropVendorDevice = "ro.vendor.device";
 
-void set_property(const std::string& prop, const std::string& value) {
+void SetProperty(const std::string& prop, const std::string& value) {
     LOG(INFO) << "Setting property: " << prop << " to " << value;
     if (!android::base::SetProperty(prop, value)) {
         LOG(ERROR) << "Unable to set: " << prop << " to " << value;
     }
 }
 
-void detect_nfc() {
-    std::string nfc_chipset;
-    if (!android::base::ReadFileToString(kProcNfcPath, &nfc_chipset)) {
+void DetectNfc() {
+    std::string nfcChipset;
+    if (!android::base::ReadFileToString(kProcNfcPath, &nfcChipset)) {
         LOG(ERROR) << "Failed to read file: " << kProcNfcPath;
         return;
     }
 
-    if (nfc_chipset != "NULL") {
-        set_property(kPropNfcDevice, "1");
+    if (nfcChipset != "NULL") {
+        SetProperty(kPropNfcDevice, "1");
     }
 }
 
-void set_power_profile() {
-    std::string device_name, operator_content;
+void SetDevice() {
+    std::string device, model, powerProfileDevice, operatorContent;
     if (!android::base::ReadFileToString(kProcOperatorPath,
-                                         &operator_content)) {
+                                         &operatorContent)) {
         LOG(ERROR) << "Failed to read file: " << kProcOperatorPath;
         return;
     }
 
-    int operator_code = stoi(operator_content);
+    int operatorCode = stoi(operatorContent);
 
-    switch (operator_code) {
-        case 90:
-        case 92:
+    switch (operatorCode) {
+        case 101:
+        case 102:
+        case 104:
+        case 105:
+        case 106:
+        case 113:
+            device = "realme 6";
+            break;
+        case 111:
+            device = "realme 6i";
+            break;
+        case 112:
+            device = "realme Narzo";
+            break;
+        case 114:
+            device = "realme 6s";
+            break;
         case 94:
         case 140:
         case 141:
@@ -52,25 +68,36 @@
         case 146:
         case 148:
         case 149:
-            device_name = "RMX2151";
+            device = "realme 7";
+            powerProfileDevice = "RMX2151";
+            break;
+        case 90:
+        case 92:
+            device = "realme Narzo 30";
+            powerProfileDevice = "RMX2151";
             break;
         case 143:
         case 145:
         case 147:
-            device_name = "RMX2161";
+            device = "realme Narzo 20 Pro";
+            powerProfileDevice = "RMX2161";
             break;
         default:
-            LOG(ERROR) << "Unknown operator found: " << operator_code;
+            LOG(ERROR) << "Unknown operator found: " << operatorCode;
     }
 
-    if (!device_name.empty()) {
-        set_property(kPropPowerProfile, device_name);
+    if (!device.empty()) {
+        SetProperty(kPropVendorDevice, device);
+    }
+
+    if (!powerProfileDevice.empty()) {
+        SetProperty(kPropPowerProfile, powerProfileDevice);
     }
 }
 
 int main() {
-    detect_nfc();
-    set_power_profile();
+    DetectNfc();
+    SetDevice();
 
     return 0;
 }
diff --git a/rootdir/etc/init.RM6785.rc b/rootdir/etc/init.RM6785.rc
index 1aad63f..e2c2021 100644
--- a/rootdir/etc/init.RM6785.rc
+++ b/rootdir/etc/init.RM6785.rc
@@ -60,3 +60,6 @@
     class hal
     user nfc
     group nfc
+
+on property:ro.vendor.device=*
+    setprop bluetooth.device.default_name ${ro.vendor.device}
diff --git a/rro_overlays/SettingsProviderOverlay6/Android.bp b/rro_overlays/SettingsProviderOverlay6/Android.bp
new file mode 100644
index 0000000..9cc605c
--- /dev/null
+++ b/rro_overlays/SettingsProviderOverlay6/Android.bp
@@ -0,0 +1,9 @@
+//
+// Copyright (C) 2023 The LineageOS Project
+//
+// SPDX-License-Identifier: Apache-2.0
+
+runtime_resource_overlay {
+    name: "SettingsProviderOverlay6",
+    vendor: true
+}
diff --git a/rro_overlays/SettingsProviderOverlay6/AndroidManifest.xml b/rro_overlays/SettingsProviderOverlay6/AndroidManifest.xml
new file mode 100644
index 0000000..9362d68
--- /dev/null
+++ b/rro_overlays/SettingsProviderOverlay6/AndroidManifest.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2023 The LineageOS Project
+
+     SPDX-License-Identifier: Apache-2.0
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.android.providers.settings.overlay.r6">
+
+    <overlay
+      android:targetPackage="com.android.providers.settings"
+      android:requiredSystemPropertyName="ro.vendor.device"
+      android:requiredSystemPropertyValue="realme 6"
+      android:isStatic="true"
+      android:priority="100"/>
+</manifest>
diff --git a/rro_overlays/SettingsProviderOverlay6/res/values/config.xml b/rro_overlays/SettingsProviderOverlay6/res/values/config.xml
new file mode 100644
index 0000000..b58fd4c
--- /dev/null
+++ b/rro_overlays/SettingsProviderOverlay6/res/values/config.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/**
+ * Copyright (c) 2016, The Android Open Source Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+-->
+<resources>
+    <!-- Default for Settings.Global.DEVICE_NAME $1=MODEL-->
+    <string name="def_device_name_simple">realme 6</string>
+</resources>
diff --git a/rro_overlays/SettingsProviderOverlay6i/Android.bp b/rro_overlays/SettingsProviderOverlay6i/Android.bp
new file mode 100644
index 0000000..7d4b87d
--- /dev/null
+++ b/rro_overlays/SettingsProviderOverlay6i/Android.bp
@@ -0,0 +1,9 @@
+//
+// Copyright (C) 2023 The LineageOS Project
+//
+// SPDX-License-Identifier: Apache-2.0
+
+runtime_resource_overlay {
+    name: "SettingsProviderOverlay6i",
+    vendor: true
+}
diff --git a/rro_overlays/SettingsProviderOverlay6i/AndroidManifest.xml b/rro_overlays/SettingsProviderOverlay6i/AndroidManifest.xml
new file mode 100644
index 0000000..edb648e
--- /dev/null
+++ b/rro_overlays/SettingsProviderOverlay6i/AndroidManifest.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2023 The LineageOS Project
+
+     SPDX-License-Identifier: Apache-2.0
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.android.providers.settings.overlay.r6i">
+
+    <overlay
+      android:targetPackage="com.android.providers.settings"
+      android:requiredSystemPropertyName="ro.vendor.device"
+      android:requiredSystemPropertyValue="realme 6i"
+      android:isStatic="true"
+      android:priority="100"/>
+</manifest>
diff --git a/rro_overlays/SettingsProviderOverlay6i/res/values/config.xml b/rro_overlays/SettingsProviderOverlay6i/res/values/config.xml
new file mode 100644
index 0000000..c690f02
--- /dev/null
+++ b/rro_overlays/SettingsProviderOverlay6i/res/values/config.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/**
+ * Copyright (c) 2016, The Android Open Source Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+-->
+<resources>
+    <!-- Default for Settings.Global.DEVICE_NAME $1=MODEL-->
+    <string name="def_device_name_simple">realme 6i</string>
+</resources>
diff --git a/rro_overlays/SettingsProviderOverlay6s/Android.bp b/rro_overlays/SettingsProviderOverlay6s/Android.bp
new file mode 100644
index 0000000..062662d
--- /dev/null
+++ b/rro_overlays/SettingsProviderOverlay6s/Android.bp
@@ -0,0 +1,9 @@
+//
+// Copyright (C) 2023 The LineageOS Project
+//
+// SPDX-License-Identifier: Apache-2.0
+
+runtime_resource_overlay {
+    name: "SettingsProviderOverlay6s",
+    vendor: true
+}
diff --git a/rro_overlays/SettingsProviderOverlay6s/AndroidManifest.xml b/rro_overlays/SettingsProviderOverlay6s/AndroidManifest.xml
new file mode 100644
index 0000000..326ffa7
--- /dev/null
+++ b/rro_overlays/SettingsProviderOverlay6s/AndroidManifest.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2023 The LineageOS Project
+
+     SPDX-License-Identifier: Apache-2.0
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.android.providers.settings.overlay.r6s">
+
+    <overlay
+      android:targetPackage="com.android.providers.settings"
+      android:requiredSystemPropertyName="ro.vendor.device"
+      android:requiredSystemPropertyValue="realme 6s"
+      android:isStatic="true"
+      android:priority="100"/>
+</manifest>
diff --git a/rro_overlays/SettingsProviderOverlay6s/res/values/config.xml b/rro_overlays/SettingsProviderOverlay6s/res/values/config.xml
new file mode 100644
index 0000000..d0c69ca
--- /dev/null
+++ b/rro_overlays/SettingsProviderOverlay6s/res/values/config.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/**
+ * Copyright (c) 2016, The Android Open Source Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+-->
+<resources>
+    <!-- Default for Settings.Global.DEVICE_NAME $1=MODEL-->
+    <string name="def_device_name_simple">realme 6s</string>
+</resources>
diff --git a/rro_overlays/SettingsProviderOverlay7/Android.bp b/rro_overlays/SettingsProviderOverlay7/Android.bp
new file mode 100644
index 0000000..9c31807
--- /dev/null
+++ b/rro_overlays/SettingsProviderOverlay7/Android.bp
@@ -0,0 +1,9 @@
+//
+// Copyright (C) 2023 The LineageOS Project
+//
+// SPDX-License-Identifier: Apache-2.0
+
+runtime_resource_overlay {
+    name: "SettingsProviderOverlay7",
+    vendor: true
+}
diff --git a/rro_overlays/SettingsProviderOverlay7/AndroidManifest.xml b/rro_overlays/SettingsProviderOverlay7/AndroidManifest.xml
new file mode 100644
index 0000000..7d9ea43
--- /dev/null
+++ b/rro_overlays/SettingsProviderOverlay7/AndroidManifest.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2023 The LineageOS Project
+
+     SPDX-License-Identifier: Apache-2.0
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.android.providers.settings.overlay.r7">
+
+    <overlay
+      android:targetPackage="com.android.providers.settings"
+      android:requiredSystemPropertyName="ro.vendor.device"
+      android:requiredSystemPropertyValue="realme 7"
+      android:isStatic="true"
+      android:priority="100"/>
+</manifest>
diff --git a/rro_overlays/SettingsProviderOverlay7/res/values/config.xml b/rro_overlays/SettingsProviderOverlay7/res/values/config.xml
new file mode 100644
index 0000000..47fb5ad
--- /dev/null
+++ b/rro_overlays/SettingsProviderOverlay7/res/values/config.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/**
+ * Copyright (c) 2016, The Android Open Source Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+-->
+<resources>
+    <!-- Default for Settings.Global.DEVICE_NAME $1=MODEL-->
+    <string name="def_device_name_simple">realme 7</string>
+</resources>
diff --git a/rro_overlays/SettingsProviderOverlayNarzo/Android.bp b/rro_overlays/SettingsProviderOverlayNarzo/Android.bp
new file mode 100644
index 0000000..77ff970
--- /dev/null
+++ b/rro_overlays/SettingsProviderOverlayNarzo/Android.bp
@@ -0,0 +1,9 @@
+//
+// Copyright (C) 2023 The LineageOS Project
+//
+// SPDX-License-Identifier: Apache-2.0
+
+runtime_resource_overlay {
+    name: "SettingsProviderOverlayNarzo",
+    vendor: true
+}
diff --git a/rro_overlays/SettingsProviderOverlayNarzo/AndroidManifest.xml b/rro_overlays/SettingsProviderOverlayNarzo/AndroidManifest.xml
new file mode 100644
index 0000000..0b29773
--- /dev/null
+++ b/rro_overlays/SettingsProviderOverlayNarzo/AndroidManifest.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2023 The LineageOS Project
+
+     SPDX-License-Identifier: Apache-2.0
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.android.providers.settings.overlay.narzo">
+
+    <overlay
+      android:targetPackage="com.android.providers.settings"
+      android:requiredSystemPropertyName="ro.vendor.device"
+      android:requiredSystemPropertyValue="realme Narzo"
+      android:isStatic="true"
+      android:priority="100"/>
+</manifest>
diff --git a/rro_overlays/SettingsProviderOverlayNarzo/res/values/config.xml b/rro_overlays/SettingsProviderOverlayNarzo/res/values/config.xml
new file mode 100644
index 0000000..6774f3a
--- /dev/null
+++ b/rro_overlays/SettingsProviderOverlayNarzo/res/values/config.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/**
+ * Copyright (c) 2016, The Android Open Source Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+-->
+<resources>
+    <!-- Default for Settings.Global.DEVICE_NAME $1=MODEL-->
+    <string name="def_device_name_simple">realme Narzo</string>
+</resources>
diff --git a/rro_overlays/SettingsProviderOverlayNarzo20Pro/Android.bp b/rro_overlays/SettingsProviderOverlayNarzo20Pro/Android.bp
new file mode 100644
index 0000000..5cf33df
--- /dev/null
+++ b/rro_overlays/SettingsProviderOverlayNarzo20Pro/Android.bp
@@ -0,0 +1,9 @@
+//
+// Copyright (C) 2023 The LineageOS Project
+//
+// SPDX-License-Identifier: Apache-2.0
+
+runtime_resource_overlay {
+    name: "SettingsProviderOverlayNarzo20Pro",
+    vendor: true
+}
diff --git a/rro_overlays/SettingsProviderOverlayNarzo20Pro/AndroidManifest.xml b/rro_overlays/SettingsProviderOverlayNarzo20Pro/AndroidManifest.xml
new file mode 100644
index 0000000..1ea143b
--- /dev/null
+++ b/rro_overlays/SettingsProviderOverlayNarzo20Pro/AndroidManifest.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2023 The LineageOS Project
+
+     SPDX-License-Identifier: Apache-2.0
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.android.providers.settings.overlay.narzo20pro">
+
+    <overlay
+      android:targetPackage="com.android.providers.settings"
+      android:requiredSystemPropertyName="ro.vendor.device"
+      android:requiredSystemPropertyValue="realme Narzo 20 Pro"
+      android:isStatic="true"
+      android:priority="100"/>
+</manifest>
diff --git a/rro_overlays/SettingsProviderOverlayNarzo20Pro/res/values/config.xml b/rro_overlays/SettingsProviderOverlayNarzo20Pro/res/values/config.xml
new file mode 100644
index 0000000..3566aba
--- /dev/null
+++ b/rro_overlays/SettingsProviderOverlayNarzo20Pro/res/values/config.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/**
+ * Copyright (c) 2016, The Android Open Source Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+-->
+<resources>
+    <!-- Default for Settings.Global.DEVICE_NAME $1=MODEL-->
+    <string name="def_device_name_simple">realme Narzo 20 Pro</string>
+</resources>
diff --git a/rro_overlays/SettingsProviderOverlayNarzo30/Android.bp b/rro_overlays/SettingsProviderOverlayNarzo30/Android.bp
new file mode 100644
index 0000000..c1ce212
--- /dev/null
+++ b/rro_overlays/SettingsProviderOverlayNarzo30/Android.bp
@@ -0,0 +1,9 @@
+//
+// Copyright (C) 2023 The LineageOS Project
+//
+// SPDX-License-Identifier: Apache-2.0
+
+runtime_resource_overlay {
+    name: "SettingsProviderOverlayNarzo30",
+    vendor: true
+}
diff --git a/rro_overlays/SettingsProviderOverlayNarzo30/AndroidManifest.xml b/rro_overlays/SettingsProviderOverlayNarzo30/AndroidManifest.xml
new file mode 100644
index 0000000..61ff3b1
--- /dev/null
+++ b/rro_overlays/SettingsProviderOverlayNarzo30/AndroidManifest.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2023 The LineageOS Project
+
+     SPDX-License-Identifier: Apache-2.0
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.android.providers.settings.overlay.narzo30">
+
+    <overlay
+      android:targetPackage="com.android.providers.settings"
+      android:requiredSystemPropertyName="ro.vendor.device"
+      android:requiredSystemPropertyValue="realme Narzo 30"
+      android:isStatic="true"
+      android:priority="100"/>
+</manifest>
diff --git a/rro_overlays/SettingsProviderOverlayNarzo30/res/values/config.xml b/rro_overlays/SettingsProviderOverlayNarzo30/res/values/config.xml
new file mode 100644
index 0000000..e2c2f9a
--- /dev/null
+++ b/rro_overlays/SettingsProviderOverlayNarzo30/res/values/config.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/**
+ * Copyright (c) 2016, The Android Open Source Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+-->
+<resources>
+    <!-- Default for Settings.Global.DEVICE_NAME $1=MODEL-->
+    <string name="def_device_name_simple">realme Narzo 30</string>
+</resources>
diff --git a/sepolicy/vendor/init_RM6785.te b/sepolicy/vendor/init_RM6785.te
index ce37c1d..1c1dd52 100644
--- a/sepolicy/vendor/init_RM6785.te
+++ b/sepolicy/vendor/init_RM6785.te
@@ -3,8 +3,7 @@
 
 init_daemon_domain(init_RM6785)
 
-set_prop(init_RM6785, vendor_nfc_prop)
-set_prop(init_RM6785, vendor_power_profile_prop)
+set_prop(init_RM6785, vendor_device_prop)
 
 allow init_RM6785 proc_nfc_chipset:file r_file_perms;
 allow init_RM6785 proc_oppo_operator:file r_file_perms;
diff --git a/sepolicy/vendor/property.te b/sepolicy/vendor/property.te
index e046584..e01d79f 100644
--- a/sepolicy/vendor/property.te
+++ b/sepolicy/vendor/property.te
@@ -1,4 +1,3 @@
 vendor_internal_prop(vendor_audio_tunning_prop)
 vendor_internal_prop(vendor_fingerprint_prop)
-vendor_internal_prop(vendor_nfc_prop)
-vendor_public_prop(vendor_power_profile_prop)
+vendor_public_prop(vendor_device_prop)
diff --git a/sepolicy/vendor/property_contexts b/sepolicy/vendor/property_contexts
index 54eec61..3548c26 100644
--- a/sepolicy/vendor/property_contexts
+++ b/sepolicy/vendor/property_contexts
@@ -11,8 +11,7 @@
 ro.vendor.mtk_crossmount                    u:object_r:vendor_mtk_crossmount_prop:s0
 ro.vendor.mtk_deinterlace                   u:object_r:vendor_mtk_deinterlace_prop:s0
 
-# NFC device
-ro.vendor.nfc_device                        u:object_r:vendor_nfc_prop:s0
-
-# Power profile
-ro.vendor.power_profile.device              u:object_r:vendor_power_profile_prop:s0
+# Vendor device
+ro.vendor.device                            u:object_r:vendor_device_prop:s0
+ro.vendor.nfc_device                        u:object_r:vendor_device_prop:s0
+ro.vendor.power_profile.device              u:object_r:vendor_device_prop:s0
diff --git a/sepolicy/vendor/system_server.te b/sepolicy/vendor/system_server.te
index 91e0e21..387a5ef 100644
--- a/sepolicy/vendor/system_server.te
+++ b/sepolicy/vendor/system_server.te
@@ -1 +1 @@
-get_prop(system_server, vendor_power_profile_prop)
+get_prop(system_server, vendor_device_prop)
diff --git a/sepolicy/vendor/vendor_init.te b/sepolicy/vendor/vendor_init.te
index c8ae150..503c115 100644
--- a/sepolicy/vendor/vendor_init.te
+++ b/sepolicy/vendor/vendor_init.te
@@ -3,3 +3,5 @@
 allow vendor_init proc_dirty:file rw_file_perms;
 allow vendor_init proc_sched:file rw_file_perms;
 allow vendor_init sysfs_otg_switch:file rw_file_perms;
+
+get_prop(vendor_init, vendor_device_prop)
diff --git a/sepolicy/vendor/zygote.te b/sepolicy/vendor/zygote.te
index 132f643..9f395cc 100644
--- a/sepolicy/vendor/zygote.te
+++ b/sepolicy/vendor/zygote.te
@@ -1 +1 @@
-get_prop(zygote, vendor_power_profile_prop)
+get_prop(zygote, vendor_device_prop)