1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.backup; 18 19 import android.app.BackupAgent; 20 import android.backup.BackupHelper; 21 import android.backup.BackupHelperDispatcher; 22 import android.backup.BackupDataInput; 23 import android.backup.BackupDataOutput; 24 import android.os.ParcelFileDescriptor; 25 import android.util.Log; 26 27 import java.io.IOException; 28 29 /** @hide */ 30 public class BackupHelperAgent extends BackupAgent { 31 static final String TAG = "BackupHelperAgent"; 32 33 BackupHelperDispatcher mDispatcher = new BackupHelperDispatcher(); 34 35 @Override onBackup(ParcelFileDescriptor oldState, BackupDataOutput data, ParcelFileDescriptor newState)36 public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data, 37 ParcelFileDescriptor newState) throws IOException { 38 mDispatcher.performBackup(oldState, data, newState); 39 } 40 41 @Override onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState)42 public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) 43 throws IOException { 44 mDispatcher.performRestore(data, appVersionCode, newState); 45 } 46 getDispatcher()47 public BackupHelperDispatcher getDispatcher() { 48 return mDispatcher; 49 } 50 addHelper(String keyPrefix, BackupHelper helper)51 public void addHelper(String keyPrefix, BackupHelper helper) { 52 mDispatcher.addHelper(keyPrefix, helper); 53 } 54 } 55 56 57