blob: 113a26da2ad8a625d9a6b8ae9a4fc82394dbf597 [file] [log] [blame]
Joe Onorato4a64bde2009-06-25 23:53:29 -04001#!/bin/bash
2
Omari Stephens1f808c62009-08-03 20:23:55 -07003# 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 Stephens0cfeb252009-08-11 21:44:21 -070017# uncomment for debugging
18#export DRY_RUN="echo"
19source test_backup_common.sh
Omari Stephens1f808c62009-08-03 20:23:55 -070020
Omari Stephensaa6e73a2009-12-02 17:39:27 -080021# figure out what packages are participating in backup
Omari Stephens0cfeb252009-08-11 21:44:21 -070022b_pkgs=$(a shell dumpsys backup | \
Omari Stephensaa6e73a2009-12-02 17:39:27 -080023 ruby -e 'p_stanza = STDIN.read.match(/Participants:.*?(?=Ever)/m)[0]
24 puts p_stanza.scan(/^ (.+?)\s*$/).flatten.join(" ")')
Omari Stephens1f808c62009-08-03 20:23:55 -070025
Omari Stephensaa6e73a2009-12-02 17:39:27 -080026# wipe data for the package participating in backup
Omari Stephens0cfeb252009-08-11 21:44:21 -070027for pkg in $b_pkgs; do
28 a shell bmgr wipe "$pkg"
Omari Stephens864ed1a2009-08-06 15:36:34 -070029done
30
Omari Stephens864ed1a2009-08-06 15:36:34 -070031echo 'Waiting 5 seconds for things to settle...'
32sleep 5
33
Omari Stephens1f808c62009-08-03 20:23:55 -070034# run adb as root so we can poke at com.android.backuptest's data
Omari Stephens0cfeb252009-08-11 21:44:21 -070035adb_root
Omari Stephens1f808c62009-08-03 20:23:55 -070036
37# show commands as we go
38set -x
39
Joe Onorato4a64bde2009-06-25 23:53:29 -040040# set the transport
Omari Stephensaa6e73a2009-12-02 17:39:27 -080041#a shell bmgr transport com.google.android.backup/.BackupTransportService
Joe Onorato4a64bde2009-06-25 23:53:29 -040042
43# load up the three files
Omari Stephens0cfeb252009-08-11 21:44:21 -070044a shell \
Omari Stephens864ed1a2009-08-06 15:36:34 -070045 "rm /data/data/com.android.backuptest/files/file.txt ; \
46 rm /data/data/com.android.backuptest/files/another_file.txt ; \
47 rm /data/data/com.android.backuptest/files/empty.txt ; \
Omari Stephens1f808c62009-08-03 20:23:55 -070048 mkdir /data/data/com.android.backuptest ; \
49 mkdir /data/data/com.android.backuptest/files ; \
50 mkdir /data/data/com.android.backuptest/shared_prefs ; \
Omari Stephens864ed1a2009-08-06 15:36:34 -070051 echo -n \"<map><int name=\\\"pref\\\" value=\\\"1\\\" /></map>\" \
52 > /data/data/com.android.backuptest/shared_prefs/raw.xml ; \
Omari Stephens1f808c62009-08-03 20:23:55 -070053 echo -n first file > /data/data/com.android.backuptest/files/file.txt ; \
54 echo -n asdf > /data/data/com.android.backuptest/files/another_file.txt ; \
Omari Stephens1f808c62009-08-03 20:23:55 -070055 echo -n "" > /data/data/com.android.backuptest/files/empty.txt ; \
Omari Stephens864ed1a2009-08-06 15:36:34 -070056 date >> /data/data/com.android.backuptest/files/3.txt ; \
Joe Onorato4a64bde2009-06-25 23:53:29 -040057"
Omari Stephens864ed1a2009-08-06 15:36:34 -070058# echo -n 3 > /data/data/com.android.backuptest/files/3.txt ; \
Joe Onorato4a64bde2009-06-25 23:53:29 -040059
60# say that the data has changed
Omari Stephens0cfeb252009-08-11 21:44:21 -070061a shell bmgr backup com.android.backuptest
Joe Onorato4a64bde2009-06-25 23:53:29 -040062
63# run the backup
Omari Stephens0cfeb252009-08-11 21:44:21 -070064a shell bmgr run
Joe Onoratodc355a92009-06-26 14:45:25 -040065