Skip to content

Instantly share code, notes, and snippets.

@dodyirawan85
Created January 16, 2026 00:41
Show Gist options
  • Select an option

  • Save dodyirawan85/ff1fc8405c682aeb07a1ebdf741c605b to your computer and use it in GitHub Desktop.

Select an option

Save dodyirawan85/ff1fc8405c682aeb07a1ebdf741c605b to your computer and use it in GitHub Desktop.
#!/bin/bash
if [[ -z "$1" ]]; then
echo "Usage: $0 <rom_root_directory>"
exit 1
fi
ROM_DIR="$(cd "$1" 2>/dev/null && pwd)"
if [[ -z "$ROM_DIR" ]]; then
echo "Error: invalid directory: $1"
exit 1
fi
ODM_PROP="${ROM_DIR}/odm/etc/build.prop"
SYSTEM_PROP_PRIMARY="${ROM_DIR}/system/build.prop"
SYSTEM_PROP_FALLBACK="${ROM_DIR}/system/system/build.prop"
missing=0
# helper: read property value from build.prop
getprop_from_file() {
local key="$1"
local file="$2"
[[ -f "$file" ]] || return
grep -m1 "^${key}=" "$file" | cut -d= -f2-
}
# helper: try system primary, then fallback
get_system_prop() {
local key="$1"
local val
val=$(getprop_from_file "$key" "$SYSTEM_PROP_PRIMARY")
[[ -n "$val" ]] && echo "$val" && return
getprop_from_file "$key" "$SYSTEM_PROP_FALLBACK"
}
check_prop() {
local value="$1"
local key="$2"
local file="$3"
if [[ -z "$value" ]]; then
echo "Missing property: ${key} (from ${file})"
missing=1
fi
}
# ---- ODM properties ----
ODM_BRAND=$(getprop_from_file ro.product.odm.brand "$ODM_PROP")
ODM_NAME=$(getprop_from_file ro.product.odm.name "$ODM_PROP")
ODM_DEVICE=$(getprop_from_file ro.product.odm.device "$ODM_PROP")
check_prop "$ODM_BRAND" "ro.product.odm.brand" "$ODM_PROP"
check_prop "$ODM_NAME" "ro.product.odm.name" "$ODM_PROP"
check_prop "$ODM_DEVICE" "ro.product.odm.device" "$ODM_PROP"
# ---- SYSTEM properties (with fallback) ----
ANDROID_RELEASE=$(get_system_prop ro.system.build.version.release)
BUILD_ID=$(get_system_prop ro.system.build.id)
INCREMENTAL=$(get_system_prop ro.system.build.version.incremental)
BUILD_TYPE=$(get_system_prop ro.build.type)
BUILD_TAGS=$(get_system_prop ro.build.tags)
check_prop "$ANDROID_RELEASE" "ro.system.build.version.release" \
"${SYSTEM_PROP_PRIMARY} or ${SYSTEM_PROP_FALLBACK}"
check_prop "$BUILD_ID" "ro.system.build.id" \
"${SYSTEM_PROP_PRIMARY} or ${SYSTEM_PROP_FALLBACK}"
check_prop "$INCREMENTAL" "ro.system.build.version.incremental" \
"${SYSTEM_PROP_PRIMARY} or ${SYSTEM_PROP_FALLBACK}"
check_prop "$BUILD_TYPE" "ro.build.type" \
"${SYSTEM_PROP_PRIMARY} or ${SYSTEM_PROP_FALLBACK}"
check_prop "$BUILD_TAGS" "ro.build.tags" \
"${SYSTEM_PROP_PRIMARY} or ${SYSTEM_PROP_FALLBACK}"
# stop if anything missing
if [[ $missing -eq 1 ]]; then
echo "Aborting: one or more required properties are missing."
exit 1
fi
# assemble fingerprint
FINGERPRINT="${ODM_BRAND}/${ODM_NAME}/${ODM_DEVICE}:${ANDROID_RELEASE}/${BUILD_ID}/${INCREMENTAL}:${BUILD_TYPE}/${BUILD_TAGS}"
echo "$FINGERPRINT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment