diff options
author | sivachandra@chromium.org <sivachandra@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-29 06:21:13 +0000 |
---|---|---|
committer | sivachandra@chromium.org <sivachandra@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-29 06:21:13 +0000 |
commit | 12f36c8e13e5b35d29a170986d35eef8b1fa402c (patch) | |
tree | d34fc701051497c8cb4c367bebf927e581537e04 /tools/android | |
parent | 24fb6ab45e597cca488652883595a48630b3bfcb (diff) | |
download | chromium_src-12f36c8e13e5b35d29a170986d35eef8b1fa402c.zip chromium_src-12f36c8e13e5b35d29a170986d35eef8b1fa402c.tar.gz chromium_src-12f36c8e13e5b35d29a170986d35eef8b1fa402c.tar.bz2 |
Provision Android devices after the 'device_status_check' step.
BUG=169338
Review URL: https://chromiumcodereview.appspot.com/12733012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191315 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/android')
-rw-r--r-- | tools/android/adb_reboot/adb_reboot.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tools/android/adb_reboot/adb_reboot.c b/tools/android/adb_reboot/adb_reboot.c index 1cc7533..a8115fc 100644 --- a/tools/android/adb_reboot/adb_reboot.c +++ b/tools/android/adb_reboot/adb_reboot.c @@ -2,12 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <sys/types.h> +#include <sys/stat.h> #include <stdio.h> #include <stdlib.h> +#include <time.h> #include <unistd.h> int main(int argc, char ** argv) { int i = fork(); + struct stat ft; + time_t ct; + if (i < 0) { printf("fork error"); return 1; @@ -23,13 +29,15 @@ int main(int argc, char ** argv) { setsid(); /* obtain a new process group */ while (1) { - system("touch /sdcard/host_heartbeat"); sleep(120); - if (fopen("/sdcard/host_heartbeat", "r") != NULL) { - // File exists, was not removed from host. - system("stop adbd"); + + stat("/sdcard/host_heartbeat", &ft); + time(&ct); + if (ct - ft.st_mtime > 120) { + /* File was not touched for some time. */ + system("su -c stop adbd"); system("sleep 2"); - system("start adbd"); + system("su -c start adbd"); } } |