#!/system/bin/sh # Initialize IntelliRAT state and register its Quick Settings tile. MODDIR=${0%/*} STATE_DIR=/data/local/tmp/intellirat APK="$MODDIR/payload/IntelliRAT.apk" INSTALL_APK=/data/local/tmp/intellirat-install.apk package_ready=1 if ! pm path com.axp.intellirat >/dev/null 2>&1 && [ -f "$APK" ]; then if cp "$APK" "$INSTALL_APK" 2>/dev/null; then chmod 0644 "$INSTALL_APK" install_result=$(pm install -r --user 0 "$INSTALL_APK" 2>&1 || true) printf '%s install_result=%s\n' "$(date -u '+%Y-%m-%dT%H:%M:%SZ')" "$install_result" \ >> /data/local/tmp/intellirat-install.log rm -f "$INSTALL_APK" else printf '%s install_error=copy_failed source=%s\n' \ "$(date -u '+%Y-%m-%dT%H:%M:%SZ')" "$APK" >> /data/local/tmp/intellirat-install.log fi elif [ "$package_ready" = 1 ] && ! pm path com.axp.intellirat >/dev/null 2>&1; then printf '%s install_error=payload_missing path=%s\n' \ "$(date -u '+%Y-%m-%dT%H:%M:%SZ')" "$APK" >> /data/local/tmp/intellirat-install.log fi for user in $(cmd user list 2>/dev/null | awk -F '[{}:]' '/UserInfo/ {print $2}'); do if [ "$user" != 0 ]; then pm uninstall --user "$user" com.axp.intellirat >/dev/null 2>&1 || true fi done mkdir -p "$STATE_DIR" chown 0 2000 "$STATE_DIR" chmod 0770 "$STATE_DIR" if [ ! -f "$STATE_DIR/config.conf" ]; then cp "$MODDIR/config/default.conf" "$STATE_DIR/config.conf" chown 0 2000 "$STATE_DIR/config.conf" chmod 0600 "$STATE_DIR/config.conf" fi printf '%s\n' "$(date -u '+%Y-%m-%dT%H:%M:%SZ') module_loaded version=0.1.0" \ >> "$STATE_DIR/events.log" chown 0 2000 "$STATE_DIR/events.log" chmod 0600 "$STATE_DIR/events.log" TILE='custom(com.axp.intellirat/.IntelliRatTileService)' tiles=$(settings get secure sysui_qs_tiles 2>/dev/null || true) case ",$tiles," in *",$TILE,"*) ;; *) settings put secure sysui_qs_tiles "$tiles,$TILE" ;; esac