<commit_before>#!/bin/bash

start() {
  shell am start -a android.intent.action.VIEW $1
}

setDate() {
  su date -s $1
}

getIp() {
#  run "adb shell ip a"
  shell netcfg
}

getSdk() {
  shell getprop ro.build.version.sdk
}

wifiConnect() {
#  echo "Use one of following:"
#  echo " wifiConnect_service"
#  echo " wifiConnect_file"
#  #wifiConnect_service
  wifiConnect_file
}

wifiConnect_service() {
  shell am startservice \
    -n com.google.wifisetup/.WifiSetupService \
    -a WifiSetupService.Connect \
    -e ssid $1 \
    -e passphrase $2
}

wifiConnect_file() {
  echo "Wanted ssid"
  read -e ssid
  echo "Password:"
  read -es pass
  echo "Password manager <WPA-PSK>"
  read -e mgmt
  if [ -z "$mgmt" ]; then
    mgmt="WPA-PSK"
  fi

  { # try
    pull /data/misc/wifi/wpa_supplicant.conf .wifi 
  } || {
    cat >.wifi<<TEXT
ctrl_interface=tiwlan0
update_config=1
device_type=0-00000000-0
TEXT
  }
  cat >>.wifi<<TEXT
network={
  ssid="$ssid"
  psk="$pass"
  key_mgmt=$mgmt
  priority=1
}
TEXT
  push .wifi /data/misc/wifi/wpa_supplicant.conf
  run adb shell chown system.wifi /data/misc/wifi/wpa_supplicant.conf
  run adb shell chmod 660 /data/misc/wifi/wpa_supplicant.conf
  run adb shell am start -a android.intent.action.MAIN -n com.android.settings/.Settings
}

open() {
  home() {
    shell am start -a android.intent.action.MAIN -c android.intent.category.HOME
  }
  settings() {
    shell am start -a android.intent.action.MAIN -n com.android.settings/.Settings
  }
  date() {
    shell am start -a android.provider.Settings.ACTION_DATE_SETTINGS
    shell am start -n com.android.settings/.DateTimeSettings
  }
  $1
}

su() {
  shell su -c \"$@\" 0
}

shell() {
  run adb shell $@
}

pull() {
  run adb pull $@
}

push() {
  run adb push $@
}

run() {
  echo \>$@
  $@
}

help() {
  cat <<TEXT
Droid Commands
 setDate <date format>
  - change device date using format yyyyMMdd.HHmmss

 getIp
  - Print all IPs for device

 wifiConnect <ssid> <pasword><commit_msg>Add help for start command<commit_after>#!/bin/bash

start() {
  shell am start -a android.intent.action.VIEW $1
}

setDate() {
  su date -s $1
}

getIp() {
#  run "adb shell ip a"
  shell netcfg
}

getSdk() {
  shell getprop ro.build.version.sdk
}

wifiConnect() {
#  echo "Use one of following:"
#  echo " wifiConnect_service"
#  echo " wifiConnect_file"
#  #wifiConnect_service
  wifiConnect_file
}

wifiConnect_service() {
  shell am startservice \
    -n com.google.wifisetup/.WifiSetupService \
    -a WifiSetupService.Connect \
    -e ssid $1 \
    -e passphrase $2
}

wifiConnect_file() {
  echo "Wanted ssid"
  read -e ssid
  echo "Password:"
  read -es pass
  echo "Password manager <WPA-PSK>"
  read -e mgmt
  if [ -z "$mgmt" ]; then
    mgmt="WPA-PSK"
  fi

  { # try
    pull /data/misc/wifi/wpa_supplicant.conf .wifi 
  } || {
    cat >.wifi<<TEXT
ctrl_interface=tiwlan0
update_config=1
device_type=0-00000000-0
TEXT
  }
  cat >>.wifi<<TEXT
network={
  ssid="$ssid"
  psk="$pass"
  key_mgmt=$mgmt
  priority=1
}
TEXT
  push .wifi /data/misc/wifi/wpa_supplicant.conf
  run adb shell chown system.wifi /data/misc/wifi/wpa_supplicant.conf
  run adb shell chmod 660 /data/misc/wifi/wpa_supplicant.conf
  run adb shell am start -a android.intent.action.MAIN -n com.android.settings/.Settings
}

open() {
  home() {
    shell am start -a android.intent.action.MAIN -c android.intent.category.HOME
  }
  settings() {
    shell am start -a android.intent.action.MAIN -n com.android.settings/.Settings
  }
  date() {
    shell am start -a android.provider.Settings.ACTION_DATE_SETTINGS
    shell am start -n com.android.settings/.DateTimeSettings
  }
  $1
}

su() {
  shell su -c \"$@\" 0
}

shell() {
  run adb shell $@
}

pull() {
  run adb pull $@
}

push() {
  run adb push $@
}

run() {
  echo \>$@
  $@
}

help() {
  cat <<TEXT
Droid Commands

 start <uri>
  - start default app that may resolve the requested uri
 
 setDate <date format>
  - change device date using format yyyyMMdd.HHmmss

 getIp
  - Print all IPs for device

 wifiConnect <ssid> <pasword>
{'fraction_non_alphanumeric': 0.13005923000987166, 'fraction_numerical': 0.01085883514313919, 'mean_word_length': 2.9502923976608186, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6210505', 'n_tokens_mistral': 1624, 'n_tokens_neox': 1566, 'n_words': 392}