180202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate/* 280202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * Copyright (C) 2010 The Android Open Source Project 380202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * 480202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * Licensed under the Apache License, Version 2.0 (the "License"); 580202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * you may not use this file except in compliance with the License. 680202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * You may obtain a copy of the License at 780202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * 880202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * http://www.apache.org/licenses/LICENSE-2.0 980202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * 1080202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * Unless required by applicable law or agreed to in writing, software 1180202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * distributed under the License is distributed on an "AS IS" BASIS, 1280202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1380202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * See the License for the specific language governing permissions and 1480202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * limitations under the License. 1580202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate */ 1680202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate 174528186e0d65fc68ef0dd1941aa2ac8aefcd55a3Christopher Tatepackage android.app.backup; 1880202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate 19d5cf722ae62d06d1fb6a9505c6f4c403a5d14a37Christopher Tateimport android.annotation.SystemApi; 204528186e0d65fc68ef0dd1941aa2ac8aefcd55a3Christopher Tateimport android.app.backup.RestoreObserver; 214528186e0d65fc68ef0dd1941aa2ac8aefcd55a3Christopher Tateimport android.app.backup.RestoreSet; 224528186e0d65fc68ef0dd1941aa2ac8aefcd55a3Christopher Tateimport android.app.backup.IRestoreObserver; 234528186e0d65fc68ef0dd1941aa2ac8aefcd55a3Christopher Tateimport android.app.backup.IRestoreSession; 2480202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tateimport android.content.Context; 2580202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tateimport android.os.Handler; 26d3cd359122348ebc72fcf699de871ad084908622Christopher Tateimport android.os.Message; 2780202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tateimport android.os.RemoteException; 2880202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tateimport android.util.Log; 2980202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate 3080202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate/** 319c3cee9824026764275e4d84ba9b5d9fdc5da690Christopher Tate * Interface for managing a restore session. 329c3cee9824026764275e4d84ba9b5d9fdc5da690Christopher Tate * @hide 3380202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate */ 34d5cf722ae62d06d1fb6a9505c6f4c403a5d14a37Christopher Tate@SystemApi 3580202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tatepublic class RestoreSession { 3680202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate static final String TAG = "RestoreSession"; 3780202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate 3880202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate final Context mContext; 3980202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate IRestoreSession mBinder; 4080202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate RestoreObserverWrapper mObserver = null; 4180202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate 4280202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate /** 4380202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * Ask the current transport what the available restore sets are. 4480202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * 452d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate * @param observer a RestoreObserver object whose restoreSetsAvailable() method will 462d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate * be called on the application's main thread in order to supply the results of 472d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate * the restore set lookup by the backup transport. This parameter must not be 482d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate * null. 492d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate * @return Zero on success, nonzero on error. The observer's restoreSetsAvailable() 502d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate * method will only be called if this method returned zero. 5180202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate */ 522d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate public int getAvailableRestoreSets(RestoreObserver observer) { 532d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate int err = -1; 542d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate RestoreObserverWrapper obsWrapper = new RestoreObserverWrapper(mContext, observer); 5580202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate try { 562d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate err = mBinder.getAvailableRestoreSets(obsWrapper); 5780202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate } catch (RemoteException e) { 5880202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate Log.d(TAG, "Can't contact server to get available sets"); 5980202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate } 602d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate return err; 6180202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate } 6280202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate 6380202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate /** 6480202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * Restore the given set onto the device, replacing the current data of any app 6580202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * contained in the restore set with the data previously backed up. 6680202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * 678472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate * <p>Callers must hold the android.permission.BACKUP permission to use this method. 688472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate * 6980202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * @return Zero on success; nonzero on error. The observer will only receive 7080202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * progress callbacks if this method returned zero. 717951eaa92a962e39ebba0366fdcafc4a0a78cc98Kenny Root * @param token The token from {@link #getAvailableRestoreSets()} corresponding to 7280202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * the restore set that should be used. 738472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate * @param observer If non-null, this binder points to an object that will receive 748472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate * progress callbacks during the restore operation. 758472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate */ 768472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate public int restoreAll(long token, RestoreObserver observer) { 778472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate int err = -1; 788472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate if (mObserver != null) { 798472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate Log.d(TAG, "restoreAll() called during active restore"); 808472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate return -1; 818472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate } 828472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate mObserver = new RestoreObserverWrapper(mContext, observer); 838472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate try { 848472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate err = mBinder.restoreAll(token, mObserver); 858472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate } catch (RemoteException e) { 868472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate Log.d(TAG, "Can't contact server to restore"); 878472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate } 888472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate return err; 898472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate } 908472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate 918472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate /** 92284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate * Restore select packages from the given set onto the device, replacing the 93284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate * current data of any app contained in the set with the data previously 94284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate * backed up. 95284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate * 96284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate * <p>Callers must hold the android.permission.BACKUP permission to use this method. 97284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate * 98284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate * @return Zero on success, nonzero on error. The observer will only receive 99284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate * progress callbacks if this method returned zero. 100284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate * @param token The token from {@link getAvailableRestoreSets()} corresponding to 101284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate * the restore set that should be used. 102284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate * @param observer If non-null, this binder points to an object that will receive 103284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate * progress callbacks during the restore operation. 104284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate * @param packages The set of packages for which to attempt a restore. Regardless of 105284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate * the contents of the actual back-end dataset named by {@code token}, only 106284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate * applications mentioned in this list will have their data restored. 107284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate * 108284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate * @hide 109284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate */ 110284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate public int restoreSome(long token, RestoreObserver observer, String[] packages) { 111284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate int err = -1; 112284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate if (mObserver != null) { 113284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate Log.d(TAG, "restoreAll() called during active restore"); 114284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate return -1; 115284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate } 116284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate mObserver = new RestoreObserverWrapper(mContext, observer); 117284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate try { 118284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate err = mBinder.restoreSome(token, mObserver, packages); 119284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate } catch (RemoteException e) { 120284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate Log.d(TAG, "Can't contact server to restore packages"); 121284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate } 122284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate return err; 123284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate } 124284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate 125284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate /** 1268472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate * Restore a single application from backup. The data will be restored from the 1278472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate * current backup dataset if the given package has stored data there, or from 1288472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate * the dataset used during the last full device setup operation if the current 1298472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate * backup dataset has no matching data. If no backup data exists for this package 1308472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate * in either source, a nonzero value will be returned. 1318472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate * 1328472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate * @return Zero on success; nonzero on error. The observer will only receive 1338472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate * progress callbacks if this method returned zero. 1348472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate * @param packageName The name of the package whose data to restore. If this is 1358472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate * not the name of the caller's own package, then the android.permission.BACKUP 1368472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate * permission must be held. 1378472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate * @param observer If non-null, this binder points to an object that will receive 1388472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate * progress callbacks during the restore operation. 13980202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate */ 1408472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate public int restorePackage(String packageName, RestoreObserver observer) { 14180202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate int err = -1; 14280202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate if (mObserver != null) { 1438472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate Log.d(TAG, "restorePackage() called during active restore"); 14480202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate return -1; 14580202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate } 14680202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate mObserver = new RestoreObserverWrapper(mContext, observer); 14780202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate try { 1488472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate err = mBinder.restorePackage(packageName, mObserver); 14980202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate } catch (RemoteException e) { 1508472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate Log.d(TAG, "Can't contact server to restore package"); 15180202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate } 15280202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate return err; 15380202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate } 15480202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate 15580202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate /** 15680202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * End this restore session. After this method is called, the RestoreSession 15780202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * object is no longer valid. 15880202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * 15980202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * <p><b>Note:</b> The caller <i>must</i> invoke this method to end the restore session, 1607951eaa92a962e39ebba0366fdcafc4a0a78cc98Kenny Root * even if {@link #restorePackage(String, RestoreObserver)} failed. 16180202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate */ 16280202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate public void endRestoreSession() { 16380202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate try { 16480202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate mBinder.endRestoreSession(); 16580202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate } catch (RemoteException e) { 16680202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate Log.d(TAG, "Can't contact server to get available sets"); 16780202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate } finally { 16880202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate mBinder = null; 16980202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate } 17080202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate } 17180202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate 17280202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate /* 17380202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * Nonpublic implementation here 17480202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate */ 17580202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate 17680202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate RestoreSession(Context context, IRestoreSession binder) { 17780202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate mContext = context; 17880202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate mBinder = binder; 17980202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate } 18080202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate 18180202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate /* 18280202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * We wrap incoming binder calls with a private class implementation that 18344a2790374bf27116cbd91060d4f096ca5999709Christopher Tate * redirects them into main-thread actions. This serializes the restore 18480202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate * progress callbacks nicely within the usual main-thread lifecycle pattern. 18580202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate */ 18680202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate private class RestoreObserverWrapper extends IRestoreObserver.Stub { 18780202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate final Handler mHandler; 18880202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate final RestoreObserver mAppObserver; 18980202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate 190d3cd359122348ebc72fcf699de871ad084908622Christopher Tate static final int MSG_RESTORE_STARTING = 1; 191d3cd359122348ebc72fcf699de871ad084908622Christopher Tate static final int MSG_UPDATE = 2; 192d3cd359122348ebc72fcf699de871ad084908622Christopher Tate static final int MSG_RESTORE_FINISHED = 3; 1932d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate static final int MSG_RESTORE_SETS_AVAILABLE = 4; 194d3cd359122348ebc72fcf699de871ad084908622Christopher Tate 19580202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate RestoreObserverWrapper(Context context, RestoreObserver appObserver) { 196d3cd359122348ebc72fcf699de871ad084908622Christopher Tate mHandler = new Handler(context.getMainLooper()) { 197d3cd359122348ebc72fcf699de871ad084908622Christopher Tate @Override 198d3cd359122348ebc72fcf699de871ad084908622Christopher Tate public void handleMessage(Message msg) { 199d3cd359122348ebc72fcf699de871ad084908622Christopher Tate switch (msg.what) { 200d3cd359122348ebc72fcf699de871ad084908622Christopher Tate case MSG_RESTORE_STARTING: 201d3cd359122348ebc72fcf699de871ad084908622Christopher Tate mAppObserver.restoreStarting(msg.arg1); 202d3cd359122348ebc72fcf699de871ad084908622Christopher Tate break; 203d3cd359122348ebc72fcf699de871ad084908622Christopher Tate case MSG_UPDATE: 2049c3cee9824026764275e4d84ba9b5d9fdc5da690Christopher Tate mAppObserver.onUpdate(msg.arg1, (String)msg.obj); 205d3cd359122348ebc72fcf699de871ad084908622Christopher Tate break; 206d3cd359122348ebc72fcf699de871ad084908622Christopher Tate case MSG_RESTORE_FINISHED: 207d3cd359122348ebc72fcf699de871ad084908622Christopher Tate mAppObserver.restoreFinished(msg.arg1); 208d3cd359122348ebc72fcf699de871ad084908622Christopher Tate break; 2092d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate case MSG_RESTORE_SETS_AVAILABLE: 2102d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate mAppObserver.restoreSetsAvailable((RestoreSet[])msg.obj); 2112d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate break; 212d3cd359122348ebc72fcf699de871ad084908622Christopher Tate } 213d3cd359122348ebc72fcf699de871ad084908622Christopher Tate } 214d3cd359122348ebc72fcf699de871ad084908622Christopher Tate }; 21580202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate mAppObserver = appObserver; 21680202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate } 21780202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate 218d3cd359122348ebc72fcf699de871ad084908622Christopher Tate // Binder calls into this object just enqueue on the main-thread handler 2192d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate public void restoreSetsAvailable(RestoreSet[] result) { 2202d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate mHandler.sendMessage( 2212d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate mHandler.obtainMessage(MSG_RESTORE_SETS_AVAILABLE, result)); 2222d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate } 2232d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate 22480202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate public void restoreStarting(int numPackages) { 225d3cd359122348ebc72fcf699de871ad084908622Christopher Tate mHandler.sendMessage( 226d3cd359122348ebc72fcf699de871ad084908622Christopher Tate mHandler.obtainMessage(MSG_RESTORE_STARTING, numPackages, 0)); 22780202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate } 22880202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate 2299c3cee9824026764275e4d84ba9b5d9fdc5da690Christopher Tate public void onUpdate(int nowBeingRestored, String currentPackage) { 230d3cd359122348ebc72fcf699de871ad084908622Christopher Tate mHandler.sendMessage( 2319c3cee9824026764275e4d84ba9b5d9fdc5da690Christopher Tate mHandler.obtainMessage(MSG_UPDATE, nowBeingRestored, 0, currentPackage)); 23280202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate } 23380202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate 23480202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate public void restoreFinished(int error) { 235d3cd359122348ebc72fcf699de871ad084908622Christopher Tate mHandler.sendMessage( 236d3cd359122348ebc72fcf699de871ad084908622Christopher Tate mHandler.obtainMessage(MSG_RESTORE_FINISHED, error, 0)); 23780202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate } 23880202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate } 23980202c8cb8c8e4ab507079e79b864c61a8eeeee9Christopher Tate} 240