Merge "Fix a race condition in acquiring content provider" into sc-dev
This commit is contained in:
@@ -501,37 +501,38 @@ public class ContentProviderHelper {
|
|||||||
|
|
||||||
mService.grantImplicitAccess(userId, null, callingUid,
|
mService.grantImplicitAccess(userId, null, callingUid,
|
||||||
UserHandle.getAppId(cpi.applicationInfo.uid));
|
UserHandle.getAppId(cpi.applicationInfo.uid));
|
||||||
}
|
|
||||||
|
|
||||||
if (caller != null) {
|
if (caller != null) {
|
||||||
// The client will be waiting, and we'll notify it when the provider is ready.
|
// The client will be waiting, and we'll notify it when the provider is ready.
|
||||||
synchronized (cpr) {
|
synchronized (cpr) {
|
||||||
if (cpr.provider == null) {
|
if (cpr.provider == null) {
|
||||||
if (cpr.launchingApp == null) {
|
if (cpr.launchingApp == null) {
|
||||||
Slog.w(TAG, "Unable to launch app "
|
Slog.w(TAG, "Unable to launch app "
|
||||||
+ cpi.applicationInfo.packageName + "/"
|
+ cpi.applicationInfo.packageName + "/"
|
||||||
+ cpi.applicationInfo.uid + " for provider "
|
+ cpi.applicationInfo.uid + " for provider "
|
||||||
+ name + ": launching app became null");
|
+ name + ": launching app became null");
|
||||||
EventLogTags.writeAmProviderLostProcess(
|
EventLogTags.writeAmProviderLostProcess(
|
||||||
UserHandle.getUserId(cpi.applicationInfo.uid),
|
UserHandle.getUserId(cpi.applicationInfo.uid),
|
||||||
cpi.applicationInfo.packageName,
|
cpi.applicationInfo.packageName,
|
||||||
cpi.applicationInfo.uid, name);
|
cpi.applicationInfo.uid, name);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn != null) {
|
if (conn != null) {
|
||||||
conn.waiting = true;
|
conn.waiting = true;
|
||||||
|
}
|
||||||
|
Message msg = mService.mHandler.obtainMessage(
|
||||||
|
ActivityManagerService.WAIT_FOR_CONTENT_PROVIDER_TIMEOUT_MSG);
|
||||||
|
msg.obj = cpr;
|
||||||
|
mService.mHandler.sendMessageDelayed(msg,
|
||||||
|
ContentResolver.CONTENT_PROVIDER_READY_TIMEOUT_MILLIS);
|
||||||
}
|
}
|
||||||
Message msg = mService.mHandler.obtainMessage(
|
|
||||||
ActivityManagerService.WAIT_FOR_CONTENT_PROVIDER_TIMEOUT_MSG);
|
|
||||||
msg.obj = cpr;
|
|
||||||
mService.mHandler.sendMessageDelayed(msg,
|
|
||||||
ContentResolver.CONTENT_PROVIDER_READY_TIMEOUT_MILLIS);
|
|
||||||
}
|
}
|
||||||
|
// Return a holder instance even if we are waiting for the publishing of the
|
||||||
|
// provider, client will check for the holder.provider to see if it needs to wait
|
||||||
|
// for it.
|
||||||
|
return cpr.newHolder(conn, false);
|
||||||
}
|
}
|
||||||
// Return a holder instance even if we are waiting for the publishing of the provider,
|
|
||||||
// client will check for the holder.provider to see if it needs to wait for it.
|
|
||||||
return cpr.newHolder(conn, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Because of the provider's external client (i.e., SHELL), we'll have to wait right here.
|
// Because of the provider's external client (i.e., SHELL), we'll have to wait right here.
|
||||||
|
|||||||
Reference in New Issue
Block a user