plugmate-adb-network-toggle-9.ino

TrustKernel PlugMate : Secure Miniature USB-C Computer running PlugOS · File : plugmate-adb-network-toggle-9.ino · Language : bash · Use case : Activer ou désactiver le service ADB (Android Debug Bridge) via ADB shell pour le développement local.

Host-side Bash script to enable or disable the ADB daemon on the PlugMate using Android shell commands.

This script requires an established USB-C connection with the PlugOS host client. It uses adb shell to modify global Android settings (adb_enabled). Warning: enabling ADB increases the attack surface; disable it after debugging. The adbd service must be restarted for the disable action to take effect immediately.

plugmate-adb-network-toggle-9.ino

#!/bin/bash
# Script pour basculer l'état d'ADB sur PlugMate via une connexion USB déjà établie
# Prérequis : ADB installé sur l'hôte, PlugMate connecté et autorisé (RSA fingerprint)
# Usage : ./plugmate-adb-toggle.sh [on|off]

ACTION=$1

if [ -z "$ACTION" ]; then
  echo "Usage: $0 [on|off]"
  exit 1
fi

# Vérifier la connexion
if ! adb devices | grep -q "device$"; then
  echo "Erreur : Aucun appareil PlugMate connecté ou autorisé."
  exit 1
fi

if [ "$ACTION" == "on" ]; then
  echo "Activation d'ADB..."
  adb shell settings put global adb_enabled 1
  echo "ADB activé."
elif [ "$ACTION" == "off" ]; then
  echo "Désactivation d'ADB..."
  adb shell settings put global adb_enabled 0
  # Recharger le service pour appliquer immédiatement
  adb shell setprop ctl.restart adbd
  echo "ADB désactivé."
else
  echo "Paramètre invalide. Utilisez 'on' ou 'off'."
  exit 1
fi

← Back to the board