| Joe Onorato | 4a64bde | 2009-06-25 23:53:29 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| Omari Stephens | 1f808c6 | 2009-08-03 20:23:55 -0700 | [diff] [blame] | 3 | # Copyright (C) 2009 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | |
| 18 | ADB_OPTS="$@" |
| 19 | |
| 20 | #FIXME: what was this for? |
| Joe Onorato | 4a64bde | 2009-06-25 23:53:29 -0400 | [diff] [blame] | 21 | #adb kill-server |
| 22 | |
| Omari Stephens | 1f808c6 | 2009-08-03 20:23:55 -0700 | [diff] [blame] | 23 | # run adb as root so we can poke at com.android.backuptest's data |
| 24 | root_status=$(adb $ADB_OPTS root) |
| 25 | if [ "x$root_status" != "xadbd is already running as root" ]; then |
| 26 | sleep 2 |
| 27 | adb $ADB_OPTS 'wait-for-device' |
| 28 | fi |
| 29 | |
| 30 | # show commands as we go |
| 31 | set -x |
| 32 | |
| Joe Onorato | 4a64bde | 2009-06-25 23:53:29 -0400 | [diff] [blame] | 33 | # set the transport |
| Omari Stephens | 1f808c6 | 2009-08-03 20:23:55 -0700 | [diff] [blame] | 34 | adb $ADB_OPTS shell bmgr transport com.google.android.backup/.BackupTransportService |
| Joe Onorato | 4a64bde | 2009-06-25 23:53:29 -0400 | [diff] [blame] | 35 | |
| 36 | # load up the three files |
| Omari Stephens | 1f808c6 | 2009-08-03 20:23:55 -0700 | [diff] [blame] | 37 | adb $ADB_OPTS shell \ |
| 38 | "rm /data/data/com.android.backuptest/files/* ; \ |
| 39 | mkdir /data/data/com.android.backuptest ; \ |
| 40 | mkdir /data/data/com.android.backuptest/files ; \ |
| 41 | mkdir /data/data/com.android.backuptest/shared_prefs ; \ |
| 42 | echo -n \"<map><int name=\\\"pref\\\" value=\\\"1\\\" /></map>\" > /data/data com.android.backuptest/shared_prefs/raw.xml ; \ |
| 43 | echo -n first file > /data/data/com.android.backuptest/files/file.txt ; \ |
| 44 | echo -n asdf > /data/data/com.android.backuptest/files/another_file.txt ; \ |
| 45 | echo -n 3 > /data/data/com.android.backuptest/files/3.txt ; \ |
| 46 | echo -n "" > /data/data/com.android.backuptest/files/empty.txt ; \ |
| Joe Onorato | 4a64bde | 2009-06-25 23:53:29 -0400 | [diff] [blame] | 47 | " |
| 48 | |
| 49 | # say that the data has changed |
| Omari Stephens | 1f808c6 | 2009-08-03 20:23:55 -0700 | [diff] [blame] | 50 | adb $ADB_OPTS shell bmgr backup com.android.backuptest |
| Joe Onorato | 4a64bde | 2009-06-25 23:53:29 -0400 | [diff] [blame] | 51 | |
| 52 | # run the backup |
| Omari Stephens | 1f808c6 | 2009-08-03 20:23:55 -0700 | [diff] [blame] | 53 | adb $ADB_OPTS shell bmgr run |
| Joe Onorato | dc355a9 | 2009-06-26 14:45:25 -0400 | [diff] [blame] | 54 | |