OSDN Git Service

Fix a deadlock I ran into.
authorDianne Hackborn <hackbod@google.com>
Thu, 23 Sep 2010 05:46:21 +0000 (22:46 -0700)
committerDianne Hackborn <hackbod@google.com>
Thu, 23 Sep 2010 05:46:21 +0000 (22:46 -0700)
Activity manager was calling into the backup service (and other
things) with its lock held.

Change-Id: Id55093e09cc5fe81b73b85968184816d956e0ae8

services/java/com/android/server/am/ActivityManagerService.java

index 4f0d2d5..3edf196 100644 (file)
@@ -9621,20 +9621,20 @@ public final class ActivityManagerService extends ActivityManagerNative
                 Slog.e(TAG, "Backup agent created for " + agentPackageName + " but not requested!");
                 return;
             }
+        }
 
-            long oldIdent = Binder.clearCallingIdentity();
-            try {
-                IBackupManager bm = IBackupManager.Stub.asInterface(
-                        ServiceManager.getService(Context.BACKUP_SERVICE));
-                bm.agentConnected(agentPackageName, agent);
-            } catch (RemoteException e) {
-                // can't happen; the backup manager service is local
-            } catch (Exception e) {
-                Slog.w(TAG, "Exception trying to deliver BackupAgent binding: ");
-                e.printStackTrace();
-            } finally {
-                Binder.restoreCallingIdentity(oldIdent);
-            }
+        long oldIdent = Binder.clearCallingIdentity();
+        try {
+            IBackupManager bm = IBackupManager.Stub.asInterface(
+                    ServiceManager.getService(Context.BACKUP_SERVICE));
+            bm.agentConnected(agentPackageName, agent);
+        } catch (RemoteException e) {
+            // can't happen; the backup manager service is local
+        } catch (Exception e) {
+            Slog.w(TAG, "Exception trying to deliver BackupAgent binding: ");
+            e.printStackTrace();
+        } finally {
+            Binder.restoreCallingIdentity(oldIdent);
         }
     }