blob: dd3907cbde91fd5ea262a4f24c88faf22e3281cf [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
17
18ADB_OPTS="$@"
19
20#FIXME: what was this for?
Joe Onorato4a64bde2009-06-25 23:53:29 -040021#adb kill-server
22
Omari Stephens1f808c62009-08-03 20:23:55 -070023# run adb as root so we can poke at com.android.backuptest's data
24root_status=$(adb $ADB_OPTS root)
25if [ "x$root_status" != "xadbd is already running as root" ]; then
26 sleep 2
27 adb $ADB_OPTS 'wait-for-device'
28fi
29
30# show commands as we go
31set -x
32
Joe Onorato4a64bde2009-06-25 23:53:29 -040033# set the transport
Omari Stephens1f808c62009-08-03 20:23:55 -070034adb $ADB_OPTS shell bmgr transport com.google.android.backup/.BackupTransportService
Joe Onorato4a64bde2009-06-25 23:53:29 -040035
36# load up the three files
Omari Stephens1f808c62009-08-03 20:23:55 -070037adb $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 Onorato4a64bde2009-06-25 23:53:29 -040047"
48
49# say that the data has changed
Omari Stephens1f808c62009-08-03 20:23:55 -070050adb $ADB_OPTS shell bmgr backup com.android.backuptest
Joe Onorato4a64bde2009-06-25 23:53:29 -040051
52# run the backup
Omari Stephens1f808c62009-08-03 20:23:55 -070053adb $ADB_OPTS shell bmgr run
Joe Onoratodc355a92009-06-26 14:45:25 -040054