Modify device name according to vendor on first boot.
diff --git a/base.mk b/base.mk
index 34c6071..53e501e 100644
--- a/base.mk
+++ b/base.mk
@@ -71,3 +71,8 @@
device/phh/treble/twrp/twrp.rc:system/etc/init/twrp.rc \
device/phh/treble/twrp/twrp.sh:system/bin/twrp.sh \
device/phh/treble/twrp/busybox-armv7l:system/bin/busybox_phh
+
+PRODUCT_COPY_FILES += \
+ device/phh/treble/device.rc:system/etc/init/device.rc \
+ device/phh/treble/change-device-name.sh:system/bin/change-device-name.sh
+
\ No newline at end of file
diff --git a/change-device-name.sh b/change-device-name.sh
new file mode 100644
index 0000000..9fea294
--- /dev/null
+++ b/change-device-name.sh
@@ -0,0 +1,46 @@
+#!/system/bin/sh
+
+if [ -n "$(grep phh.device.namechanged /system/build.prop)" ]; then
+ exit 0
+fi
+
+if [ ! -f /vendor/build.prop ]; then
+ exit 0
+fi
+
+VENDOR_FINGERPRINT="$(grep ro.vendor.build.fingerprint /vendor/build.prop | cut -d'=' -f 2)"
+echo "Vendor fingerprint: $VENDOR_FINGERPRINT"
+
+modify_on_match() {
+ match_result=`echo $VENDOR_FINGERPRINT | grep $1`
+ brand=$2
+ model=$3
+ name=$4
+ device=$5
+
+ if [ -n "$match_result" ]; then
+ sed -i "s/ro\.product\.brand=.*/ro.product.brand=${brand}/" /system/build.prop
+ sed -i "s/ro\.product\.model=.*/ro.product.model=${model}/" /system/build.prop
+ sed -i "s/ro\.product\.name=.*/ro.product.name=${name}/" /system/build.prop
+ sed -i "s/ro\.product\.device=.*/ro.product.device=${device}/" /system/build.prop
+ sed -i "s/ro\.lineage\.device=.*/ro.lineage.device=${device}/" /system/build.prop
+
+ echo "Device name changed! Match: $2 $3 $4 $5"
+ fi
+}
+
+mount -o remount,rw /system
+
+# Add devices here, e.g.
+# modify_on_match <pattern> <brand> <model> <name> <device>
+
+modify_on_match "Xiaomi/polaris/polaris.*" "Xiaomi" "MIX 2S" "polaris" "polaris"
+modify_on_match "Xiaomi/clover/clover.*" "Xiaomi" "MI PAD 4" "clover" "clover"
+
+# End of devices
+
+if [ -z "$(grep phh.device.namechanged /system/build.prop)" ]; then
+ echo -e "\nphh.device.namechanged=true\n" >> /system/build.prop
+fi
+
+mount -o remount,ro /system
diff --git a/device.rc b/device.rc
new file mode 100644
index 0000000..3d0fc52
--- /dev/null
+++ b/device.rc
@@ -0,0 +1,2 @@
+on post-fs
+ exec u:r:phhsu_daemon:s0 root -- /system/bin/change-device-name.sh