#!/bin/bash
LOCATION=$(dirname "$0")
source "$LOCATION"/../common_tools
android_choose_device

prompt(){
  tput setaf 1
  yes_or_no "💣 Wipe all data on $SELECTED_DEVICE_MODEL - $SELECTED_DEVICE?"
  tput sgr0
  if [[ "$RESPONSE" == "y" ||  "$RESPONSE" == "Y" ]]; then
    wipe_apps
    wipe_data
  fi
}

wipe_data(){
  android_device_info "$SELECTED_DEVICE"
  android_get_storage_location_per_SDK "$SDK"

  echo "🔥 Deleting everything in mnt/sdcard..."
  adb -s "$SELECTED_DEVICE" shell rm -rf "$DEVICE_FILE_PATH/*" &>/dev/null
}

wipe_apps(){
  echo "🔥 Deleting all third-party apps..."
  "$LOCATION"/auninstall "-w" "$SELECTED_DEVICE"
}

prompt
echo "✅ Done"
