Don't crash in various ways when using backup services too early
BackupManager now no longer tries to use a null service binder if it's used early during the boot process. ActivityManagerService no longer tries to dereference null pointers if bind/unbind semantics get out of step due to things being run too early.
This commit is contained in:
@@ -68,9 +68,11 @@ public class BackupManager {
|
|||||||
* {@link android.app.BackupAgent} subclass will be scheduled when you call this method.
|
* {@link android.app.BackupAgent} subclass will be scheduled when you call this method.
|
||||||
*/
|
*/
|
||||||
public void dataChanged() {
|
public void dataChanged() {
|
||||||
try {
|
if (mService != null) {
|
||||||
mService.dataChanged(mContext.getPackageName());
|
try {
|
||||||
} catch (RemoteException e) {
|
mService.dataChanged(mContext.getPackageName());
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,9 +85,11 @@ public class BackupManager {
|
|||||||
*/
|
*/
|
||||||
public IRestoreSession beginRestoreSession(int transportID) {
|
public IRestoreSession beginRestoreSession(int transportID) {
|
||||||
IRestoreSession binder = null;
|
IRestoreSession binder = null;
|
||||||
try {
|
if (mService != null) {
|
||||||
binder = mService.beginRestoreSession(transportID);
|
try {
|
||||||
} catch (RemoteException e) {
|
binder = mService.beginRestoreSession(transportID);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return binder;
|
return binder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10472,8 +10472,17 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
|
|||||||
// done with this agent
|
// done with this agent
|
||||||
public void unbindBackupAgent(ApplicationInfo appInfo) {
|
public void unbindBackupAgent(ApplicationInfo appInfo) {
|
||||||
if (DEBUG_BACKUP) Log.v(TAG, "unbindBackupAgent: " + appInfo);
|
if (DEBUG_BACKUP) Log.v(TAG, "unbindBackupAgent: " + appInfo);
|
||||||
|
if (appInfo == null) {
|
||||||
|
Log.w(TAG, "unbind backup agent for null app");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
|
if (mBackupAppName == null) {
|
||||||
|
Log.w(TAG, "Unbinding backup agent with no active backup");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!mBackupAppName.equals(appInfo.packageName)) {
|
if (!mBackupAppName.equals(appInfo.packageName)) {
|
||||||
Log.e(TAG, "Unbind of " + appInfo + " but is not the current backup target");
|
Log.e(TAG, "Unbind of " + appInfo + " but is not the current backup target");
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user