From dfa47b56e1c10c001adcb9dd6c32613b4ce50ff7 Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Tue, 22 Dec 2009 16:01:32 -0800 Subject: [PATCH] Don't crash the system process when a backup transport unregisters Bug: 2342503 --- .../com/android/server/BackupManagerService.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java index ad0fb0c579a51..2e4551268a08d 100644 --- a/services/java/com/android/server/BackupManagerService.java +++ b/services/java/com/android/server/BackupManagerService.java @@ -497,11 +497,21 @@ class BackupManagerService extends IBackupManager.Stub { } } - // Add a transport to our set of available backends + // Add a transport to our set of available backends. If 'transport' is null, this + // is an unregistration, and the transport's entry is removed from our bookkeeping. private void registerTransport(String name, IBackupTransport transport) { synchronized (mTransports) { if (DEBUG) Log.v(TAG, "Registering transport " + name + " = " + transport); - mTransports.put(name, transport); + if (transport != null) { + mTransports.put(name, transport); + } else { + mTransports.remove(name); + if (mCurrentTransport.equals(name)) { + mCurrentTransport = null; + } + // Nothing further to do in the unregistration case + return; + } } // If the init sentinel file exists, we need to be sure to perform the init