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 | |
Omari Stephens | 0cfeb25 | 2009-08-11 21:44:21 -0700 | [diff] [blame] | 17 | # uncomment for debugging |
| 18 | #export DRY_RUN="echo" |
| 19 | source test_backup_common.sh |
Omari Stephens | 1f808c6 | 2009-08-03 20:23:55 -0700 | [diff] [blame] | 20 | |
Omari Stephens | 0cfeb25 | 2009-08-11 21:44:21 -0700 | [diff] [blame] | 21 | # wipe prior backup data for packages |
| 22 | b_pkgs=$(a shell dumpsys backup | \ |
| 23 | ruby -ne 'print($1+" ") if $_ =~ /^\s*ApplicationInfo\S+ (.+?)\}/') |
Omari Stephens | 1f808c6 | 2009-08-03 20:23:55 -0700 | [diff] [blame] | 24 | |
Omari Stephens | 0cfeb25 | 2009-08-11 21:44:21 -0700 | [diff] [blame] | 25 | for pkg in $b_pkgs; do |
| 26 | a shell bmgr wipe "$pkg" |
Omari Stephens | 864ed1a | 2009-08-06 15:36:34 -0700 | [diff] [blame] | 27 | done |
| 28 | |
Omari Stephens | 864ed1a | 2009-08-06 15:36:34 -0700 | [diff] [blame] | 29 | echo 'Waiting 5 seconds for things to settle...' |
| 30 | sleep 5 |
| 31 | |
Omari Stephens | 1f808c6 | 2009-08-03 20:23:55 -0700 | [diff] [blame] | 32 | # run adb as root so we can poke at com.android.backuptest's data |
Omari Stephens | 0cfeb25 | 2009-08-11 21:44:21 -0700 | [diff] [blame] | 33 | adb_root |
Omari Stephens | 1f808c6 | 2009-08-03 20:23:55 -0700 | [diff] [blame] | 34 | |
| 35 | # show commands as we go |
| 36 | set -x |
| 37 | |
Joe Onorato | 4a64bde | 2009-06-25 23:53:29 -0400 | [diff] [blame] | 38 | # set the transport |
Omari Stephens | 0cfeb25 | 2009-08-11 21:44:21 -0700 | [diff] [blame] | 39 | a shell bmgr transport com.google.android.backup/.BackupTransportService |
Joe Onorato | 4a64bde | 2009-06-25 23:53:29 -0400 | [diff] [blame] | 40 | |
| 41 | # load up the three files |
Omari Stephens | 0cfeb25 | 2009-08-11 21:44:21 -0700 | [diff] [blame] | 42 | a shell \ |
Omari Stephens | 864ed1a | 2009-08-06 15:36:34 -0700 | [diff] [blame] | 43 | "rm /data/data/com.android.backuptest/files/file.txt ; \ |
| 44 | rm /data/data/com.android.backuptest/files/another_file.txt ; \ |
| 45 | rm /data/data/com.android.backuptest/files/empty.txt ; \ |
Omari Stephens | 1f808c6 | 2009-08-03 20:23:55 -0700 | [diff] [blame] | 46 | mkdir /data/data/com.android.backuptest ; \ |
| 47 | mkdir /data/data/com.android.backuptest/files ; \ |
| 48 | mkdir /data/data/com.android.backuptest/shared_prefs ; \ |
Omari Stephens | 864ed1a | 2009-08-06 15:36:34 -0700 | [diff] [blame] | 49 | echo -n \"<map><int name=\\\"pref\\\" value=\\\"1\\\" /></map>\" \ |
| 50 | > /data/data/com.android.backuptest/shared_prefs/raw.xml ; \ |
Omari Stephens | 1f808c6 | 2009-08-03 20:23:55 -0700 | [diff] [blame] | 51 | echo -n first file > /data/data/com.android.backuptest/files/file.txt ; \ |
| 52 | echo -n asdf > /data/data/com.android.backuptest/files/another_file.txt ; \ |
Omari Stephens | 1f808c6 | 2009-08-03 20:23:55 -0700 | [diff] [blame] | 53 | echo -n "" > /data/data/com.android.backuptest/files/empty.txt ; \ |
Omari Stephens | 864ed1a | 2009-08-06 15:36:34 -0700 | [diff] [blame] | 54 | date >> /data/data/com.android.backuptest/files/3.txt ; \ |
Joe Onorato | 4a64bde | 2009-06-25 23:53:29 -0400 | [diff] [blame] | 55 | " |
Omari Stephens | 864ed1a | 2009-08-06 15:36:34 -0700 | [diff] [blame] | 56 | # echo -n 3 > /data/data/com.android.backuptest/files/3.txt ; \ |
Joe Onorato | 4a64bde | 2009-06-25 23:53:29 -0400 | [diff] [blame] | 57 | |
| 58 | # say that the data has changed |
Omari Stephens | 0cfeb25 | 2009-08-11 21:44:21 -0700 | [diff] [blame] | 59 | a shell bmgr backup com.android.backuptest |
Joe Onorato | 4a64bde | 2009-06-25 23:53:29 -0400 | [diff] [blame] | 60 | |
| 61 | # run the backup |
Omari Stephens | 0cfeb25 | 2009-08-11 21:44:21 -0700 | [diff] [blame] | 62 | a shell bmgr run |
Joe Onorato | dc355a9 | 2009-06-26 14:45:25 -0400 | [diff] [blame] | 63 | |