Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set system time format via adb shell

Tags:

android

adb

I am trying to write a simple form utility to configure an attached android device. One of the actions I need to perform is to change the system timezone, time and time format.

I am setting the system timezone via:

adb shell setprop persist.sys.timezone "America/Chicago"

Changing the time via

adb shell date -s YYYYMMDD.HHmmss

Now I need to set the 12/24 hour format of the device, but I don't know how to do this. It needs to be done via adb. Any help is appreciated, thanks!

like image 664
FlyingStreudel Avatar asked Dec 14 '12 17:12

FlyingStreudel


1 Answers

IF "%time:~0,1%"==" " (
    SET mynow=%date:~-4,4%%date:~-10,2%%date:~-7,2%.0%time:~1,1%%time:~3,2%%time:~6,2%
) ELSE (
    set mynow=%date:~-4,4%%date:~-10,2%%date:~-7,2%.%time:~0,2%%time:~3,2%%time:~6,2%
)


REM sourced from:
REM http://developer.android.com/reference/android/provider/Settings.System.html

REM STILL NEED
REM font scale = 1.25  (display -> font size = extra large)
REM screen lock = none (security -> screen lock)
REM scheduled power off 10:30pm daily  (scheduled power on & off


REM allow apps from unknown sources (settings-> developer options)
adb shell settings put secure install_non_market_apps 1

REM ... (settings-> developer options)
adb shell settings put global stay_on_while_plugged_in 3

REM display off after 30 minutes (settings-> display)
adb shell settings put system screen_off_timeout 1800000

REM display Font Scale X-Large (settings-> display)
REM write setting not working, read setting works fine
REM adb shell settings put system font_scale 1.25


REM set default rotation state to horizontal
adb shell settings put system user_rotation 0

REM use 12 hour format (settings->date & time)
adb shell settings put system time_12_24 12

REM Automatic date & time = use network provided (settings->date & time)
REM adb shell settings put global auto_time 1
REM Automatic date & time = OFF (settings->date & time)
adb shell settings put global auto_time 0

REM Automatic time zone = use network provided time-zone (settings->date & time)
REM adb shell settings put global auto_time_zone 1
REM Automatic time zone = OFF (settings->date & time)
adb shell settings put global auto_time_zone 0


REM set Date & Time
adb shell su 0 date -s %mynow%
like image 67
guest1234556 Avatar answered Sep 28 '22 17:09

guest1234556