#!/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: $(echo "$mac" | tr -d ':' | tr '[:lower:]' '[:upper:]')"
echo "---------------------------------"

adb shell rm -rf /system/priv-app/AirScreen /system/app/iptv /system/app/player /system/app/browser /system/priv-app/Velvet /system/app/LiveWallpapersPicker /system/priv-app/WallpaperCropper /system/priv-app/Phonesky /system/app/Aging /system/app/BasicDreams /system/app/Browser2 /system/app/Chrome /system/app/Music /system/app/PhotoTable /system/app/WallpaperBackup /system/priv-app/MusicFX /vendor/app/Browser /system/priv-app/Launcher /vendor/priv-app/Spotify.apk 
adb shell rm -rf /system/priv-app/AirScreen 
adb shell rm -rf /system/app/iptv 
adb shell rm -rf /system/app/player 
adb shell rm -rf /system/app/browser 
adb shell rm -rf /system/priv-app/Phonesky 
adb shell rm -rf /system/app/Music 
adb shell rm -rf /system/priv-app/MusicFX 
adb shell rm -rf /vendor/app/Browser 
adb shell rm -rf /system/app/Aging 
adb shell rm -rf /system/app/AirScreen 
adb shell rm -rf /system/app/BasicDreams 
adb shell rm -rf /System/app/Browser2 
adb shell rm -rf /System/app/Chrome 
adb shell rm -rf /System/app/DeskClock 
adb shell rm -rf /System/app/LiveWallpapersPicker 
adb shell rm -rf /System/app/PhotoTable 
adb shell rm -rf /System/app/WallpaperBackup 
adb shell rm -rf /system/priv-app/Velvet 
adb shell rm -rf /system/priv-app/WallpaperCropper 
adb shell rm -rf /system/priv-app/AirScreen 
adb shell rm -rf /vendor/app/Launcher 
adb shell rm -rf /vendor/app/Service 
adb shell rm -rf /system/app/Browser 
adb shell rm -rf /system/app/Iptv 
adb shell rm -rf /system/app/VLC 
adb shell rm -rf /system/priv-app/VNC 
adb shell rm -rf /vendor/preinstall/Hulu.apk
adb shell rm -rf /vendor/preinstall/Netflix.apk
adb shell rm -rf /vendor/preinstall/PrimeVideo.apk
adb shell rm -rf /vendor/preinstall/Spotify.apk
adb shell rm -rf /data/data/com.arkha.alto.* 
adb shell rm -rf /data/app/com.arkha.alto.* 
adb shell rm -rf /data/app/com.spotify.* 
adb shell rm -rf /data/app/com.netflix.* 
adb shell rm -rf /data/app/com.amazon.* 
adb shell rm -rf /data/app/com.hulu.* 
adb shell cp -rf /storage/1583-D885/apks/Launcher /vendor/app 
adb shell cp -rf /storage/1583-D885/apks/Service /vendor/app
adb shell cp -rf /storage/1583-D885/apks/Browser /system/app 
adb shell cp -rf /storage/1583-D885/apks/Iptv /system/app 
adb shell cp -rf /storage/1583-D885/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
