diff options
author | Christopher Tate <ctate@google.com> | 2011-04-01 14:43:32 -0700 |
---|---|---|
committer | Christopher Tate <ctate@google.com> | 2011-05-10 17:52:51 -0700 |
commit | 4a627c71ff53a4fca1f961f4b1dcc0461df18a06 (patch) | |
tree | 270190b1e030424210b6375ca886c45db10c4fb6 /packages | |
parent | 2bb51bb203c117649db10ad8bd497f199ca797b0 (diff) | |
download | frameworks_base-4a627c71ff53a4fca1f961f4b1dcc0461df18a06.zip frameworks_base-4a627c71ff53a4fca1f961f4b1dcc0461df18a06.tar.gz frameworks_base-4a627c71ff53a4fca1f961f4b1dcc0461df18a06.tar.bz2 |
Full local backup infrastructure
This is the basic infrastructure for pulling a full(*) backup of the
device's data over an adb(**) connection to the local device. The
basic process consists of these interacting pieces:
1. The framework's BackupManagerService, which coordinates the
collection of app data and routing to the destination.
2. A new framework-provided BackupAgent implementation called
FullBackupAgent, which is instantiated in the target applications'
processes in turn, and knows how to emit a datastream that contains
all of the app's saved data files.
3. A new shell-level program called "bu" that is used to bridge from
adb to the framework's Backup Manager.
4. adb itself, which now knows how to use 'bu' to kick off a backup
operation and pull the resulting data stream to the desktop host.
5. A system-provided application that verifies with the user that
an attempted backup/restore operation is in fact expected and to
be allowed.
The full agent implementation is not used during normal operation of
the delta-based app-customized remote backup process. Instead it's
used during user-confirmed *full* backup of applications and all their
data to a local destination, e.g. via the adb connection.
The output format is 'tar'. This makes it very easy for the end
user to examine the resulting dataset, e.g. for purpose of extracting
files for debug purposes; as well as making it easy to contemplate
adding things like a direct gzip stage to the data pipeline during
backup/restore. It also makes it convenient to construct and maintain
synthetic backup datasets for testing purposes.
Within the tar format, certain artificial conventions are used.
All files are stored within top-level directories according to
their semantic origin:
apps/pkgname/a/ : Application .apk file itself
apps/pkgname/obb/: The application's associated .obb containers
apps/pkgname/f/ : The subtree rooted at the getFilesDir() location
apps/pkgname/db/ : The subtree rooted at the getDatabasePath() parent
apps/pkgname/sp/ : The subtree rooted at the getSharedPrefsFile() parent
apps/pkgname/r/ : Files stored relative to the root of the app's file tree
apps/pkgname/c/ : Reserved for the app's getCacheDir() tree; not stored.
For each package, the first entry in the tar stream is a file called
"_manifest", nominally rooted at apps/pkgname. This file contains some
metadata about the package whose data is stored in the archive.
The contents of shared storage can optionally be included in the tar
stream. It is placed in the synthetic location:
shared/...
uid/gid are ignored; app uids are assigned at install time, and the
app's data is handled from within its own execution environment, so
will automatically have the app's correct uid.
Forward-locked .apk files are never backed up. System-partition
.apk files are not backed up unless they have been overridden by a
post-factory upgrade, in which case the current .apk *is* backed up --
i.e. the .apk that matches the on-disk data. The manifest preceding
each application's portion of the tar stream provides version numbers
and signature blocks for version checking, as well as an indication
of whether the restore logic should expect to install the .apk before
extracting the data.
System packages can designate their own full backup agents. This is
to manage things like the settings provider which (a) cannot be shut
down on the fly in order to do a clean snapshot of their file trees,
and (b) manage data that is not only irrelevant but actively hostile
to non-identical devices -- CDMA telephony settings would seriously
mess up a GSM device if emplaced there blind, for example.
When a full backup or restore is initiated from adb, the system will
present a confirmation UI that the user must explicitly respond to
within a short [~ 30 seconds] timeout. This is to avoid the
possibility of malicious desktop-side software secretly grabbing a copy
of all the user's data for nefarious purposes.
(*) The backup is not strictly a full mirror. In particular, the
settings database is not cloned; it is handled the same way that
it is in cloud backup/restore. This is because some settings
are actively destructive if cloned onto a different (or
especially a different-model) device: telephony settings and
AndroidID are good examples of this.
(**) On the framework side it doesn't care that it's adb; it just
sends the tar stream to a file descriptor. This can easily be
retargeted around whatever transport we might decide to use
in the future.
KNOWN ISSUES:
* the security UI is desperately ugly; no proper designs have yet
been done for it
* restore is not yet implemented
* shared storage backup is not yet implemented
* symlinks aren't yet handled, though some infrastructure for
dealing with them has been put in place.
Change-Id: Ia8347611e23b398af36ea22c36dff0a276b1ce91
Diffstat (limited to 'packages')
8 files changed, 485 insertions, 10 deletions
diff --git a/packages/BackupRestoreConfirmation/Android.mk b/packages/BackupRestoreConfirmation/Android.mk new file mode 100644 index 0000000..e775b44 --- /dev/null +++ b/packages/BackupRestoreConfirmation/Android.mk @@ -0,0 +1,31 @@ +# +# Copyright (C) 2011 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional + +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_PACKAGE_NAME := BackupRestoreConfirmation +LOCAL_CERTIFICATE := platform + +include $(BUILD_PACKAGE) + +######################## +include $(call all-makefiles-under,$(LOCAL_PATH)) + diff --git a/packages/BackupRestoreConfirmation/AndroidManifest.xml b/packages/BackupRestoreConfirmation/AndroidManifest.xml new file mode 100644 index 0000000..ed9a519 --- /dev/null +++ b/packages/BackupRestoreConfirmation/AndroidManifest.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +** Copyright 2011, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +--> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.backupconfirm" > + + <uses-permission android:name="android.permission.BACKUP" /> + + <application android:allowClearUserData="false" + android:killAfterRestore="false" + android:permission="android.permission.CONFIRM_FULL_BACKUP" > + + <activity android:name=".BackupRestoreConfirmation" + android:windowSoftInputMode="stateAlwaysHidden" + android:excludeFromRecents="true" + android:exported="true" > + </activity> + </application> +</manifest> diff --git a/packages/BackupRestoreConfirmation/res/layout/confirm_backup.xml b/packages/BackupRestoreConfirmation/res/layout/confirm_backup.xml new file mode 100644 index 0000000..109cfff --- /dev/null +++ b/packages/BackupRestoreConfirmation/res/layout/confirm_backup.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="utf-8"?> + +<!-- +/* + * Copyright (C) 2011, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +--> + +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:padding="10dp" > + + <TextView android:id="@+id/confirm_text" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="30dp" + android:text="@string/backup_confirm_text" /> + + <TextView android:id="@+id/package_name" + android:layout_width="match_parent" + android:layout_height="20dp" + android:layout_marginLeft="30dp" + android:layout_below="@id/confirm_text" + android:layout_marginBottom="30dp" /> + + <Button android:id="@+id/button_allow" + android:text="@string/allow_backup_button_label" + android:layout_below="@id/package_name" + android:layout_height="wrap_content" + android:layout_width="wrap_content" /> + + <Button android:id="@+id/button_deny" + android:text="@string/deny_backup_button_label" + android:layout_below="@id/package_name" + android:layout_toRightOf="@id/button_allow" + android:layout_alignTop="@id/button_allow" + android:layout_height="wrap_content" + android:layout_width="wrap_content" /> + +</RelativeLayout> diff --git a/packages/BackupRestoreConfirmation/res/layout/confirm_restore.xml b/packages/BackupRestoreConfirmation/res/layout/confirm_restore.xml new file mode 100644 index 0000000..a1f9a4a --- /dev/null +++ b/packages/BackupRestoreConfirmation/res/layout/confirm_restore.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="utf-8"?> + +<!-- +/* + * Copyright (C) 2011, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +--> + +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:padding="10dp" > + + <TextView android:id="@+id/confirm_text" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="30dp" + android:text="@string/restore_confirm_text" /> + + <TextView android:id="@+id/package_name" + android:layout_width="match_parent" + android:layout_height="20dp" + android:layout_marginLeft="30dp" + android:layout_below="@id/confirm_text" + android:layout_marginBottom="30dp" /> + + <Button android:id="@+id/button_allow" + android:text="@string/allow_restore_button_label" + android:layout_below="@id/package_name" + android:layout_height="wrap_content" + android:layout_width="wrap_content" /> + + <Button android:id="@+id/button_deny" + android:text="@string/deny_restore_button_label" + android:layout_below="@id/package_name" + android:layout_toRightOf="@id/button_allow" + android:layout_alignTop="@id/button_allow" + android:layout_height="wrap_content" + android:layout_width="wrap_content" /> + +</RelativeLayout> diff --git a/packages/BackupRestoreConfirmation/res/values/strings.xml b/packages/BackupRestoreConfirmation/res/values/strings.xml new file mode 100644 index 0000000..3d85e86 --- /dev/null +++ b/packages/BackupRestoreConfirmation/res/values/strings.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + + <!-- Text for message to user that a full backup has been requested, and must be confirmed. --> + <string name="backup_confirm_text">A full backup of all data to a connected desktop computer has been requested. Do you want to allow this to happen\?\n\nIf you did not request the backup yourself, do not allow the operation to proceed.</string> + <!-- Button to allow a requested full backup to occur --> + <string name="allow_backup_button_label">Back up my data</string> + <!-- Button to refuse to allow the requested full backup --> + <string name="deny_backup_button_label">Do not back up</string> + + <!-- Text for message to user that a full restore has been requested, and must be confirmed. --> + <string name="restore_confirm_text">A full restore of all data from a connected desktop computer has been requested. Do you want to allow this to happen\?\n\nIf you did not request the restore yourself, do not allow the operation to proceed. This will replace any data currently on the device!</string> + <!-- Button to allow a requested full restore to occur --> + <string name="allow_restore_button_label">Restore my data</string> + <!-- Button to refuse to allow the requested full restore --> + <string name="deny_restore_button_label">Do not restore</string> + +</resources> diff --git a/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java b/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java new file mode 100644 index 0000000..805b905 --- /dev/null +++ b/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java @@ -0,0 +1,237 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.backupconfirm; + +import android.app.Activity; +import android.app.backup.FullBackup; +import android.app.backup.IBackupManager; +import android.app.backup.IFullBackupRestoreObserver; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import android.os.RemoteException; +import android.os.ServiceManager; +import android.util.Slog; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; +import android.widget.Toast; + +/** + * Confirm with the user that a requested full backup/restore operation is legitimate. + * Any attempt to perform a full backup/restore will launch this UI and wait for a + * designated timeout interval (nominally 30 seconds) for the user to confirm. If the + * user fails to respond within the timeout period, or explicitly refuses the operation + * within the UI presented here, no data will be transferred off the device. + * + * Note that the fully scoped name of this class is baked into the backup manager service. + * + * @hide + */ +public class BackupRestoreConfirmation extends Activity { + static final String TAG = "BackupRestoreConfirmation"; + static final boolean DEBUG = true; + + static final int MSG_START_BACKUP = 1; + static final int MSG_BACKUP_PACKAGE = 2; + static final int MSG_END_BACKUP = 3; + static final int MSG_START_RESTORE = 11; + static final int MSG_RESTORE_PACKAGE = 12; + static final int MSG_END_RESTORE = 13; + static final int MSG_TIMEOUT = 100; + + Handler mHandler; + IBackupManager mBackupManager; + FullObserver mObserver; + int mToken; + + TextView mStatusView; + Button mAllowButton; + Button mDenyButton; + + // Handler for dealing with observer callbacks on the main thread + class ObserverHandler extends Handler { + Context mContext; + ObserverHandler(Context context) { + mContext = context; + } + + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case MSG_START_BACKUP: { + Toast.makeText(mContext, "!!! Backup starting !!!", Toast.LENGTH_LONG); + } + break; + + case MSG_BACKUP_PACKAGE: { + String name = (String) msg.obj; + mStatusView.setText(name); + } + break; + + case MSG_END_BACKUP: { + Toast.makeText(mContext, "!!! Backup ended !!!", Toast.LENGTH_SHORT); + } + break; + + case MSG_START_RESTORE: { + Toast.makeText(mContext, "!!! Restore starting !!!", Toast.LENGTH_LONG); + } + break; + + case MSG_RESTORE_PACKAGE: { + } + break; + + case MSG_END_RESTORE: { + Toast.makeText(mContext, "!!! Restore ended !!!", Toast.LENGTH_SHORT); + } + break; + + case MSG_TIMEOUT: { + } + break; + } + } + } + + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + + final Intent intent = getIntent(); + final String action = intent.getAction(); + + int layoutId; + if (action.equals(FullBackup.FULL_BACKUP_INTENT_ACTION)) { + layoutId = R.layout.confirm_backup; + } else if (action.equals(FullBackup.FULL_RESTORE_INTENT_ACTION)) { + layoutId = R.layout.confirm_restore; + } else { + Slog.w(TAG, "Backup/restore confirmation activity launched with invalid action!"); + finish(); + return; + } + + mToken = intent.getIntExtra(FullBackup.CONF_TOKEN_INTENT_EXTRA, -1); + if (mToken < 0) { + Slog.e(TAG, "Backup/restore confirmation requested but no token passed!"); + finish(); + return; + } + + mBackupManager = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE)); + + mHandler = new ObserverHandler(getApplicationContext()); + mObserver = new FullObserver(); + + setContentView(layoutId); + + // Same resource IDs for each layout variant (backup / restore) + mStatusView = (TextView) findViewById(R.id.package_name); + mAllowButton = (Button) findViewById(R.id.button_allow); + mDenyButton = (Button) findViewById(R.id.button_deny); + + mAllowButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + try { + mBackupManager.acknowledgeFullBackupOrRestore(mToken, true, mObserver); + } catch (RemoteException e) { + // TODO: bail gracefully if we can't contact the backup manager + } + mAllowButton.setEnabled(false); + mDenyButton.setEnabled(false); + } + }); + + mDenyButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + try { + mBackupManager.acknowledgeFullBackupOrRestore(mToken, false, mObserver); + } catch (RemoteException e) { + // TODO: bail gracefully if we can't contact the backup manager + } + mAllowButton.setEnabled(false); + mDenyButton.setEnabled(false); + } + }); + } + + @Override + public void onStop() { + super.onStop(); + + // We explicitly equate departure from the UI with refusal. This includes the + // implicit configuration-changed stop/restart cycle. + try { + mBackupManager.acknowledgeFullBackupOrRestore(mToken, false, null); + } catch (RemoteException e) { + // if this fails we'll still time out with no acknowledgment + } + finish(); + } + + /** + * The observer binder for showing backup/restore progress. This binder just bounces + * the notifications onto the main thread. + */ + class FullObserver extends IFullBackupRestoreObserver.Stub { + // + // IFullBackupRestoreObserver implementation + // + @Override + public void onStartBackup() throws RemoteException { + mHandler.sendEmptyMessage(MSG_START_BACKUP); + } + + @Override + public void onBackupPackage(String name) throws RemoteException { + mHandler.sendMessage(mHandler.obtainMessage(MSG_BACKUP_PACKAGE, name)); + } + + @Override + public void onEndBackup() throws RemoteException { + mHandler.sendEmptyMessage(MSG_END_BACKUP); + } + + @Override + public void onStartRestore() throws RemoteException { + mHandler.sendEmptyMessage(MSG_START_RESTORE); + } + + @Override + public void onRestorePackage(String name) throws RemoteException { + mHandler.sendMessage(mHandler.obtainMessage(MSG_RESTORE_PACKAGE, name)); + } + + @Override + public void onEndRestore() throws RemoteException { + mHandler.sendEmptyMessage(MSG_END_RESTORE); + } + + @Override + public void onTimeout() throws RemoteException { + mHandler.sendEmptyMessage(MSG_TIMEOUT); + } + } +} diff --git a/packages/SettingsProvider/AndroidManifest.xml b/packages/SettingsProvider/AndroidManifest.xml index dd0d064..e5f52e2 100644 --- a/packages/SettingsProvider/AndroidManifest.xml +++ b/packages/SettingsProvider/AndroidManifest.xml @@ -6,6 +6,7 @@ android:label="@string/app_label" android:process="system" android:backupAgent="SettingsBackupAgent" + android:fullBackupAgent="SettingsBackupAgent" android:killAfterRestore="false" android:icon="@drawable/ic_launcher_settings"> diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java index 744798e..45bb2b6 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java @@ -36,6 +36,7 @@ import java.util.zip.CRC32; import android.app.backup.BackupDataInput; import android.app.backup.BackupDataOutput; import android.app.backup.BackupAgentHelper; +import android.app.backup.FullBackup; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; @@ -99,6 +100,10 @@ public class SettingsBackupAgent extends BackupAgentHelper { private static final String KEY_WIFI_SUPPLICANT = "\uffedWIFI"; private static final String KEY_WIFI_CONFIG = "\uffedCONFIG_WIFI"; + // Name of the temporary file we use during full backup/restore. This is + // stored in the full-backup tarfile as well, so should not be changed. + private static final String STAGE_FILE = "flattened-data"; + private SettingsHelper mSettingsHelper; private WifiManager mWfm; private static String mWifiConfigFile; @@ -121,22 +126,52 @@ public class SettingsBackupAgent extends BackupAgentHelper { byte[] wifiSupplicantData = getWifiSupplicant(FILE_WIFI_SUPPLICANT); byte[] wifiConfigData = getFileData(mWifiConfigFile); - long[] stateChecksums = readOldChecksums(oldState); + // This same agent class is used for both full and incremental backups. A full + // backup is flagged by a 'null' oldState argument. In the case of a full backup, + // the output is structured as tarfile contents. + if (oldState != null) { + long[] stateChecksums = readOldChecksums(oldState); - stateChecksums[STATE_SYSTEM] = + stateChecksums[STATE_SYSTEM] = writeIfChanged(stateChecksums[STATE_SYSTEM], KEY_SYSTEM, systemSettingsData, data); - stateChecksums[STATE_SECURE] = + stateChecksums[STATE_SECURE] = writeIfChanged(stateChecksums[STATE_SECURE], KEY_SECURE, secureSettingsData, data); - stateChecksums[STATE_LOCALE] = + stateChecksums[STATE_LOCALE] = writeIfChanged(stateChecksums[STATE_LOCALE], KEY_LOCALE, locale, data); - stateChecksums[STATE_WIFI_SUPPLICANT] = + stateChecksums[STATE_WIFI_SUPPLICANT] = writeIfChanged(stateChecksums[STATE_WIFI_SUPPLICANT], KEY_WIFI_SUPPLICANT, - wifiSupplicantData, data); - stateChecksums[STATE_WIFI_CONFIG] = + wifiSupplicantData, data); + stateChecksums[STATE_WIFI_CONFIG] = writeIfChanged(stateChecksums[STATE_WIFI_CONFIG], KEY_WIFI_CONFIG, wifiConfigData, - data); - - writeNewChecksums(stateChecksums, newState); + data); + + writeNewChecksums(stateChecksums, newState); + } else { + // Write the data to the staging file, then emit that as our tarfile + // representation of the backed-up settings. + String root = getFilesDir().getAbsolutePath(); + File stage = new File(root, STAGE_FILE); + FileOutputStream filestream = new FileOutputStream(stage); + BufferedOutputStream bufstream = new BufferedOutputStream(filestream); + DataOutputStream out = new DataOutputStream(bufstream); + + out.writeInt(systemSettingsData.length); + out.write(systemSettingsData); + out.writeInt(secureSettingsData.length); + out.write(secureSettingsData); + out.writeInt(locale.length); + out.write(locale); + out.writeInt(wifiSupplicantData.length); + out.write(wifiSupplicantData); + out.writeInt(wifiConfigData.length); + out.write(wifiConfigData); + + out.flush(); // also flushes downstream + + // now we're set to emit the tar stream + FullBackup.backupToTar(getPackageName(), FullBackup.DATA_TREE_TOKEN, null, + root, stage.getAbsolutePath(), data); + } } @Override |