#!/bin/bash

#adb kill-server
export ADB_VENDOR_KEYS="./adbkey"
echo ADB=$ADB_VENDOR_KEYS

ip=$1
adb connect $ip:5555 && adb root && adb connect $ip:5555 
adb remount 
mac=`adb shell getprop ro.boot.mac`
echo "DEVICEID:" 
adb shell "getprop ro.boot.mac | tr -d ':' | tr '[:lower:]' '[:upper:]'"
echo "---------------------------------"

adb shell rm -rf /data/data/com.arkha.alto.* 
adb shell rm -rf /data/app/com.arkha.alto.* 
adb push build/apks/Launcher /vendor/app 
adb push build/apks/Service /vendor/app
adb push build/apks/Browser /system/app 
adb push build/apks/Iptv /vendor/app 
adb push build/apks/VLC /system/app 



# Set the time zone to CDT and configure NTP server on the Android device
adb -s "$device_id" shell "setprop persist.sys.timezone America/Chicago"
adb -s "$device_id" shell "settings put global ntp_server pool.ntp.org"

# Get the current date and time in CDT
current_date_cdt=$(TZ="America/Chicago" date +'%m%d%H%M%Y.%S')

# Send the date to the Android device
adb -s "$device_id" shell "date \"$current_date_cdt\""

# Verify that the date, time, and NTP server have been set on the device
adb -s "$device_id" shell date
adb -s "$device_id" shell "settings get global ntp_server"

adb reboot
adb disconnect
