Loading core/java/android/app/ActivityThread.java +42 −24 Original line number Original line Diff line number Diff line Loading @@ -261,6 +261,8 @@ public final class ActivityThread { IActivityManager.ContentProviderHolder holder; IActivityManager.ContentProviderHolder holder; boolean acquiring = true; boolean acquiring = true; int requests = 1; int requests = 1; // Set if there was a runtime exception when trying to acquire the provider. RuntimeException runtimeException = null; } } // The lock of mProviderMap protects the following variables. // The lock of mProviderMap protects the following variables. Loading Loading @@ -4667,6 +4669,7 @@ public final class ActivityThread { } } IActivityManager.ContentProviderHolder holder = null; IActivityManager.ContentProviderHolder holder = null; try { if (first) { if (first) { // Multiple threads may try to acquire the same provider at the same time. // Multiple threads may try to acquire the same provider at the same time. // When this happens, we only let the first one really gets provider. // When this happens, we only let the first one really gets provider. Loading @@ -4674,16 +4677,8 @@ public final class ActivityThread { // Note that we cannot hold the lock while acquiring and installing the // Note that we cannot hold the lock while acquiring and installing the // provider since it might take a long time to run and it could also potentially // provider since it might take a long time to run and it could also potentially // be re-entrant in the case where the provider is in the same process. // be re-entrant in the case where the provider is in the same process. try { holder = ActivityManagerNative.getDefault().getContentProvider( holder = ActivityManagerNative.getDefault().getContentProvider( getApplicationThread(), auth, userId, stable); getApplicationThread(), auth, userId, stable); } catch (RemoteException ex) { } synchronized (r) { r.holder = holder; r.acquiring = false; r.notifyAll(); } } else { } else { synchronized (r) { synchronized (r) { while (r.acquiring) { while (r.acquiring) { Loading @@ -4695,11 +4690,34 @@ public final class ActivityThread { holder = r.holder; holder = r.holder; } } } } } catch (RemoteException ex) { } catch (RuntimeException e) { synchronized (r) { r.runtimeException = e; } } finally { if (first) { synchronized (r) { r.holder = holder; r.acquiring = false; r.notifyAll(); } } synchronized (mAcquiringProviderMap) { synchronized (mAcquiringProviderMap) { if (--r.requests == 0) { if (--r.requests == 0) { mAcquiringProviderMap.remove(key); mAcquiringProviderMap.remove(key); } } } } if (r.runtimeException != null) { // Was set when the first thread tried to acquire the provider, // but we should make sure it is thrown for all threads trying to // acquire the provider. throw r.runtimeException; } } if (holder == null) { if (holder == null) { Slog.e(TAG, "Failed to find provider info for " + auth); Slog.e(TAG, "Failed to find provider info for " + auth); return null; return null; Loading Loading
core/java/android/app/ActivityThread.java +42 −24 Original line number Original line Diff line number Diff line Loading @@ -261,6 +261,8 @@ public final class ActivityThread { IActivityManager.ContentProviderHolder holder; IActivityManager.ContentProviderHolder holder; boolean acquiring = true; boolean acquiring = true; int requests = 1; int requests = 1; // Set if there was a runtime exception when trying to acquire the provider. RuntimeException runtimeException = null; } } // The lock of mProviderMap protects the following variables. // The lock of mProviderMap protects the following variables. Loading Loading @@ -4667,6 +4669,7 @@ public final class ActivityThread { } } IActivityManager.ContentProviderHolder holder = null; IActivityManager.ContentProviderHolder holder = null; try { if (first) { if (first) { // Multiple threads may try to acquire the same provider at the same time. // Multiple threads may try to acquire the same provider at the same time. // When this happens, we only let the first one really gets provider. // When this happens, we only let the first one really gets provider. Loading @@ -4674,16 +4677,8 @@ public final class ActivityThread { // Note that we cannot hold the lock while acquiring and installing the // Note that we cannot hold the lock while acquiring and installing the // provider since it might take a long time to run and it could also potentially // provider since it might take a long time to run and it could also potentially // be re-entrant in the case where the provider is in the same process. // be re-entrant in the case where the provider is in the same process. try { holder = ActivityManagerNative.getDefault().getContentProvider( holder = ActivityManagerNative.getDefault().getContentProvider( getApplicationThread(), auth, userId, stable); getApplicationThread(), auth, userId, stable); } catch (RemoteException ex) { } synchronized (r) { r.holder = holder; r.acquiring = false; r.notifyAll(); } } else { } else { synchronized (r) { synchronized (r) { while (r.acquiring) { while (r.acquiring) { Loading @@ -4695,11 +4690,34 @@ public final class ActivityThread { holder = r.holder; holder = r.holder; } } } } } catch (RemoteException ex) { } catch (RuntimeException e) { synchronized (r) { r.runtimeException = e; } } finally { if (first) { synchronized (r) { r.holder = holder; r.acquiring = false; r.notifyAll(); } } synchronized (mAcquiringProviderMap) { synchronized (mAcquiringProviderMap) { if (--r.requests == 0) { if (--r.requests == 0) { mAcquiringProviderMap.remove(key); mAcquiringProviderMap.remove(key); } } } } if (r.runtimeException != null) { // Was set when the first thread tried to acquire the provider, // but we should make sure it is thrown for all threads trying to // acquire the provider. throw r.runtimeException; } } if (holder == null) { if (holder == null) { Slog.e(TAG, "Failed to find provider info for " + auth); Slog.e(TAG, "Failed to find provider info for " + auth); return null; return null; Loading