Loading core/java/android/content/ContentProvider.java +22 −16 Original line number Original line Diff line number Diff line Loading @@ -265,7 +265,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall // Return an empty cursor for all columns. // Return an empty cursor for all columns. return new MatrixCursor(cursor.getColumnNames(), 0); return new MatrixCursor(cursor.getColumnNames(), 0); } } Trace.traceBegin(TRACE_TAG_DATABASE, "query"); traceBegin(TRACE_TAG_DATABASE, "query: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading @@ -285,7 +285,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall // getCallingPackage() isn't available in getType(), as the javadoc states. // getCallingPackage() isn't available in getType(), as the javadoc states. uri = validateIncomingUri(uri); uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); uri = maybeGetUriWithoutUserId(uri); Trace.traceBegin(TRACE_TAG_DATABASE, "getType"); traceBegin(TRACE_TAG_DATABASE, "getType: ", uri.getAuthority()); try { try { return mInterface.getType(uri); return mInterface.getType(uri); } catch (RemoteException e) { } catch (RemoteException e) { Loading Loading @@ -323,7 +323,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall setCallingAttributionSource(original); setCallingAttributionSource(original); } } } } Trace.traceBegin(TRACE_TAG_DATABASE, "insert"); traceBegin(TRACE_TAG_DATABASE, "insert: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading @@ -345,7 +345,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall != PermissionChecker.PERMISSION_GRANTED) { != PermissionChecker.PERMISSION_GRANTED) { return 0; return 0; } } Trace.traceBegin(TRACE_TAG_DATABASE, "bulkInsert"); traceBegin(TRACE_TAG_DATABASE, "bulkInsert: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading Loading @@ -391,7 +391,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } } } } } } Trace.traceBegin(TRACE_TAG_DATABASE, "applyBatch"); traceBegin(TRACE_TAG_DATABASE, "applyBatch: ", authority); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading Loading @@ -423,7 +423,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall != PermissionChecker.PERMISSION_GRANTED) { != PermissionChecker.PERMISSION_GRANTED) { return 0; return 0; } } Trace.traceBegin(TRACE_TAG_DATABASE, "delete"); traceBegin(TRACE_TAG_DATABASE, "delete: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading @@ -445,7 +445,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall != PermissionChecker.PERMISSION_GRANTED) { != PermissionChecker.PERMISSION_GRANTED) { return 0; return 0; } } Trace.traceBegin(TRACE_TAG_DATABASE, "update"); traceBegin(TRACE_TAG_DATABASE, "update: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading @@ -465,7 +465,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall uri = validateIncomingUri(uri); uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); uri = maybeGetUriWithoutUserId(uri); enforceFilePermission(attributionSource, uri, mode); enforceFilePermission(attributionSource, uri, mode); Trace.traceBegin(TRACE_TAG_DATABASE, "openFile"); traceBegin(TRACE_TAG_DATABASE, "openFile: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading @@ -486,7 +486,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall uri = validateIncomingUri(uri); uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); uri = maybeGetUriWithoutUserId(uri); enforceFilePermission(attributionSource, uri, mode); enforceFilePermission(attributionSource, uri, mode); Trace.traceBegin(TRACE_TAG_DATABASE, "openAssetFile"); traceBegin(TRACE_TAG_DATABASE, "openAssetFile: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading @@ -505,7 +505,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall String method, @Nullable String arg, @Nullable Bundle extras) { String method, @Nullable String arg, @Nullable Bundle extras) { validateIncomingAuthority(authority); validateIncomingAuthority(authority); Bundle.setDefusable(extras, true); Bundle.setDefusable(extras, true); Trace.traceBegin(TRACE_TAG_DATABASE, "call"); traceBegin(TRACE_TAG_DATABASE, "call: ", authority); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading @@ -523,7 +523,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall // getCallingPackage() isn't available in getType(), as the javadoc states. // getCallingPackage() isn't available in getType(), as the javadoc states. uri = validateIncomingUri(uri); uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); uri = maybeGetUriWithoutUserId(uri); Trace.traceBegin(TRACE_TAG_DATABASE, "getStreamTypes"); traceBegin(TRACE_TAG_DATABASE, "getStreamTypes: ", uri.getAuthority()); try { try { return mInterface.getStreamTypes(uri, mimeTypeFilter); return mInterface.getStreamTypes(uri, mimeTypeFilter); } catch (RemoteException e) { } catch (RemoteException e) { Loading @@ -541,7 +541,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall uri = validateIncomingUri(uri); uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); uri = maybeGetUriWithoutUserId(uri); enforceFilePermission(attributionSource, uri, "r"); enforceFilePermission(attributionSource, uri, "r"); Trace.traceBegin(TRACE_TAG_DATABASE, "openTypedAssetFile"); traceBegin(TRACE_TAG_DATABASE, "openTypedAssetFile: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading Loading @@ -569,7 +569,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall != PermissionChecker.PERMISSION_GRANTED) { != PermissionChecker.PERMISSION_GRANTED) { return null; return null; } } Trace.traceBegin(TRACE_TAG_DATABASE, "canonicalize"); traceBegin(TRACE_TAG_DATABASE, "canonicalize: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading Loading @@ -605,7 +605,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall != PermissionChecker.PERMISSION_GRANTED) { != PermissionChecker.PERMISSION_GRANTED) { return null; return null; } } Trace.traceBegin(TRACE_TAG_DATABASE, "uncanonicalize"); traceBegin(TRACE_TAG_DATABASE, "uncanonicalize: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading Loading @@ -641,7 +641,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall != PermissionChecker.PERMISSION_GRANTED) { != PermissionChecker.PERMISSION_GRANTED) { return false; return false; } } Trace.traceBegin(TRACE_TAG_DATABASE, "refresh"); traceBegin(TRACE_TAG_DATABASE, "refresh: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading @@ -658,7 +658,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall int uid, int modeFlags) { int uid, int modeFlags) { uri = validateIncomingUri(uri); uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); uri = maybeGetUriWithoutUserId(uri); Trace.traceBegin(TRACE_TAG_DATABASE, "checkUriPermission"); traceBegin(TRACE_TAG_DATABASE, "checkUriPermission: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading Loading @@ -2683,4 +2683,10 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } } return uri; return uri; } } private static void traceBegin(long traceTag, String methodName, String subInfo) { if (Trace.isTagEnabled(traceTag)) { Trace.traceBegin(traceTag, methodName + subInfo); } } } } services/core/java/com/android/server/am/ActivityManagerService.java +60 −5 Original line number Original line Diff line number Diff line Loading @@ -5996,13 +5996,23 @@ public class ActivityManagerService extends IActivityManager.Stub public final ContentProviderHolder getContentProvider( public final ContentProviderHolder getContentProvider( IApplicationThread caller, String callingPackage, String name, int userId, IApplicationThread caller, String callingPackage, String name, int userId, boolean stable) { boolean stable) { traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "getContentProvider: ", name); try { return mCpHelper.getContentProvider(caller, callingPackage, name, userId, stable); return mCpHelper.getContentProvider(caller, callingPackage, name, userId, stable); } finally { Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } } } @Override @Override public ContentProviderHolder getContentProviderExternal( public ContentProviderHolder getContentProviderExternal( String name, int userId, IBinder token, String tag) { String name, int userId, IBinder token, String tag) { traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "getContentProviderExternal: ", name); try { return mCpHelper.getContentProviderExternal(name, userId, token, tag); return mCpHelper.getContentProviderExternal(name, userId, token, tag); } finally { Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } } } /** /** Loading @@ -6017,18 +6027,57 @@ public class ActivityManagerService extends IActivityManager.Stub @Deprecated @Deprecated @Override @Override public void removeContentProviderExternal(String name, IBinder token) { public void removeContentProviderExternal(String name, IBinder token) { traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "removeContentProviderExternal: ", name); try { removeContentProviderExternalAsUser(name, token, UserHandle.getCallingUserId()); removeContentProviderExternalAsUser(name, token, UserHandle.getCallingUserId()); } finally { Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } } } @Override @Override public void removeContentProviderExternalAsUser(String name, IBinder token, int userId) { public void removeContentProviderExternalAsUser(String name, IBinder token, int userId) { traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "removeContentProviderExternalAsUser: ", name); try { mCpHelper.removeContentProviderExternalAsUser(name, token, userId); mCpHelper.removeContentProviderExternalAsUser(name, token, userId); } finally { Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } } } @Override @Override public final void publishContentProviders(IApplicationThread caller, public final void publishContentProviders(IApplicationThread caller, List<ContentProviderHolder> providers) { List<ContentProviderHolder> providers) { if (Trace.isTagEnabled(Trace.TRACE_TAG_ACTIVITY_MANAGER)) { final int maxLength = 256; final StringBuilder sb = new StringBuilder(maxLength); sb.append("publishContentProviders: "); if (providers != null) { boolean first = true; for (int i = 0, size = providers.size(); i < size; i++) { final ContentProviderHolder holder = providers.get(i); if (holder != null && holder.info != null && holder.info.authority != null) { final int len = holder.info.authority.length(); if (sb.length() + len > maxLength) { sb.append("[[TRUNCATED]]"); break; } if (!first) { sb.append(';'); } else { first = false; } sb.append(holder.info.authority); } } } Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, sb.toString()); } try { mCpHelper.publishContentProviders(caller, providers); mCpHelper.publishContentProviders(caller, providers); } finally { Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } } } @Override @Override Loading Loading @@ -17108,4 +17157,10 @@ public class ActivityManagerService extends IActivityManager.Stub SystemClock.sleep(durationMs); SystemClock.sleep(durationMs); } } } } static void traceBegin(long traceTag, String methodName, String subInfo) { if (Trace.isTagEnabled(traceTag)) { Trace.traceBegin(traceTag, methodName + subInfo); } } } } services/core/java/com/android/server/am/ContentProviderHelper.java +89 −55 Original line number Original line Diff line number Diff line Loading @@ -58,6 +58,7 @@ import android.os.Process; import android.os.RemoteCallback; import android.os.RemoteCallback; import android.os.RemoteException; import android.os.RemoteException; import android.os.SystemClock; import android.os.SystemClock; import android.os.Trace; import android.os.UserHandle; import android.os.UserHandle; import android.provider.Settings; import android.provider.Settings; import android.text.TextUtils; import android.text.TextUtils; Loading Loading @@ -707,7 +708,6 @@ public class ContentProviderHelper { mService.enforceNotIsolatedCaller("removeContentProvider"); mService.enforceNotIsolatedCaller("removeContentProvider"); final long ident = Binder.clearCallingIdentity(); final long ident = Binder.clearCallingIdentity(); try { try { synchronized (mService) { ContentProviderConnection conn; ContentProviderConnection conn; try { try { conn = (ContentProviderConnection) connection; conn = (ContentProviderConnection) connection; Loading @@ -720,8 +720,17 @@ public class ContentProviderHelper { if (conn == null) { if (conn == null) { throw new NullPointerException("connection is null"); throw new NullPointerException("connection is null"); } } ActivityManagerService.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "removeContentProvider: ", (conn.provider != null && conn.provider.info != null ? conn.provider.info.authority : "")); try { synchronized (mService) { decProviderCountLocked(conn, null, null, stable, true, true); decProviderCountLocked(conn, null, null, stable, true, true); } } } finally { Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } } finally { } finally { Binder.restoreCallingIdentity(ident); Binder.restoreCallingIdentity(ident); } } Loading Loading @@ -781,8 +790,15 @@ public class ContentProviderHelper { throw new NullPointerException("connection is null"); throw new NullPointerException("connection is null"); } } ActivityManagerService.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "refContentProvider: ", (conn.provider != null && conn.provider.info != null ? conn.provider.info.authority : "")); try { conn.adjustCounts(stable, unstable); conn.adjustCounts(stable, unstable); return !conn.dead; return !conn.dead; } finally { Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } } } void unstableProviderDied(IBinder connection) { void unstableProviderDied(IBinder connection) { Loading @@ -798,6 +814,12 @@ public class ContentProviderHelper { throw new NullPointerException("connection is null"); throw new NullPointerException("connection is null"); } } ActivityManagerService.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "unstableProviderDied: ", (conn.provider != null && conn.provider.info != null ? conn.provider.info.authority : "")); try { // Safely retrieve the content provider associated with the connection. // Safely retrieve the content provider associated with the connection. IContentProvider provider; IContentProvider provider; synchronized (mService) { synchronized (mService) { Loading Loading @@ -835,7 +857,8 @@ public class ContentProviderHelper { // As far as we're concerned, this is just like receiving a // As far as we're concerned, this is just like receiving a // death notification... just a bit prematurely. // death notification... just a bit prematurely. mService.reportUidInfoMessageLocked(TAG, "Process " + proc.processName mService.reportUidInfoMessageLocked(TAG, "Process " + proc.processName + " (pid " + proc.getPid() + ") early provider death", proc.info.uid); + " (pid " + proc.getPid() + ") early provider death", proc.info.uid); final long token = Binder.clearCallingIdentity(); final long token = Binder.clearCallingIdentity(); try { try { mService.appDiedLocked(proc, "unstable content provider"); mService.appDiedLocked(proc, "unstable content provider"); Loading @@ -843,6 +866,9 @@ public class ContentProviderHelper { Binder.restoreCallingIdentity(token); Binder.restoreCallingIdentity(token); } } } } } finally { Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } } } void appNotRespondingViaProvider(IBinder connection) { void appNotRespondingViaProvider(IBinder connection) { Loading @@ -855,6 +881,11 @@ public class ContentProviderHelper { return; return; } } ActivityManagerService.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "appNotRespondingViaProvider: ", (conn.provider != null && conn.provider.info != null ? conn.provider.info.authority : "")); try { final ProcessRecord host = conn.provider.proc; final ProcessRecord host = conn.provider.proc; if (host == null) { if (host == null) { Slog.w(TAG, "Failed to find hosting ProcessRecord"); Slog.w(TAG, "Failed to find hosting ProcessRecord"); Loading @@ -862,6 +893,9 @@ public class ContentProviderHelper { } } mService.mAnrHelper.appNotResponding(host, "ContentProvider not responding"); mService.mAnrHelper.appNotResponding(host, "ContentProvider not responding"); } finally { Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } } } /** /** Loading Loading
core/java/android/content/ContentProvider.java +22 −16 Original line number Original line Diff line number Diff line Loading @@ -265,7 +265,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall // Return an empty cursor for all columns. // Return an empty cursor for all columns. return new MatrixCursor(cursor.getColumnNames(), 0); return new MatrixCursor(cursor.getColumnNames(), 0); } } Trace.traceBegin(TRACE_TAG_DATABASE, "query"); traceBegin(TRACE_TAG_DATABASE, "query: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading @@ -285,7 +285,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall // getCallingPackage() isn't available in getType(), as the javadoc states. // getCallingPackage() isn't available in getType(), as the javadoc states. uri = validateIncomingUri(uri); uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); uri = maybeGetUriWithoutUserId(uri); Trace.traceBegin(TRACE_TAG_DATABASE, "getType"); traceBegin(TRACE_TAG_DATABASE, "getType: ", uri.getAuthority()); try { try { return mInterface.getType(uri); return mInterface.getType(uri); } catch (RemoteException e) { } catch (RemoteException e) { Loading Loading @@ -323,7 +323,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall setCallingAttributionSource(original); setCallingAttributionSource(original); } } } } Trace.traceBegin(TRACE_TAG_DATABASE, "insert"); traceBegin(TRACE_TAG_DATABASE, "insert: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading @@ -345,7 +345,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall != PermissionChecker.PERMISSION_GRANTED) { != PermissionChecker.PERMISSION_GRANTED) { return 0; return 0; } } Trace.traceBegin(TRACE_TAG_DATABASE, "bulkInsert"); traceBegin(TRACE_TAG_DATABASE, "bulkInsert: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading Loading @@ -391,7 +391,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } } } } } } Trace.traceBegin(TRACE_TAG_DATABASE, "applyBatch"); traceBegin(TRACE_TAG_DATABASE, "applyBatch: ", authority); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading Loading @@ -423,7 +423,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall != PermissionChecker.PERMISSION_GRANTED) { != PermissionChecker.PERMISSION_GRANTED) { return 0; return 0; } } Trace.traceBegin(TRACE_TAG_DATABASE, "delete"); traceBegin(TRACE_TAG_DATABASE, "delete: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading @@ -445,7 +445,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall != PermissionChecker.PERMISSION_GRANTED) { != PermissionChecker.PERMISSION_GRANTED) { return 0; return 0; } } Trace.traceBegin(TRACE_TAG_DATABASE, "update"); traceBegin(TRACE_TAG_DATABASE, "update: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading @@ -465,7 +465,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall uri = validateIncomingUri(uri); uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); uri = maybeGetUriWithoutUserId(uri); enforceFilePermission(attributionSource, uri, mode); enforceFilePermission(attributionSource, uri, mode); Trace.traceBegin(TRACE_TAG_DATABASE, "openFile"); traceBegin(TRACE_TAG_DATABASE, "openFile: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading @@ -486,7 +486,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall uri = validateIncomingUri(uri); uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); uri = maybeGetUriWithoutUserId(uri); enforceFilePermission(attributionSource, uri, mode); enforceFilePermission(attributionSource, uri, mode); Trace.traceBegin(TRACE_TAG_DATABASE, "openAssetFile"); traceBegin(TRACE_TAG_DATABASE, "openAssetFile: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading @@ -505,7 +505,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall String method, @Nullable String arg, @Nullable Bundle extras) { String method, @Nullable String arg, @Nullable Bundle extras) { validateIncomingAuthority(authority); validateIncomingAuthority(authority); Bundle.setDefusable(extras, true); Bundle.setDefusable(extras, true); Trace.traceBegin(TRACE_TAG_DATABASE, "call"); traceBegin(TRACE_TAG_DATABASE, "call: ", authority); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading @@ -523,7 +523,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall // getCallingPackage() isn't available in getType(), as the javadoc states. // getCallingPackage() isn't available in getType(), as the javadoc states. uri = validateIncomingUri(uri); uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); uri = maybeGetUriWithoutUserId(uri); Trace.traceBegin(TRACE_TAG_DATABASE, "getStreamTypes"); traceBegin(TRACE_TAG_DATABASE, "getStreamTypes: ", uri.getAuthority()); try { try { return mInterface.getStreamTypes(uri, mimeTypeFilter); return mInterface.getStreamTypes(uri, mimeTypeFilter); } catch (RemoteException e) { } catch (RemoteException e) { Loading @@ -541,7 +541,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall uri = validateIncomingUri(uri); uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); uri = maybeGetUriWithoutUserId(uri); enforceFilePermission(attributionSource, uri, "r"); enforceFilePermission(attributionSource, uri, "r"); Trace.traceBegin(TRACE_TAG_DATABASE, "openTypedAssetFile"); traceBegin(TRACE_TAG_DATABASE, "openTypedAssetFile: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading Loading @@ -569,7 +569,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall != PermissionChecker.PERMISSION_GRANTED) { != PermissionChecker.PERMISSION_GRANTED) { return null; return null; } } Trace.traceBegin(TRACE_TAG_DATABASE, "canonicalize"); traceBegin(TRACE_TAG_DATABASE, "canonicalize: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading Loading @@ -605,7 +605,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall != PermissionChecker.PERMISSION_GRANTED) { != PermissionChecker.PERMISSION_GRANTED) { return null; return null; } } Trace.traceBegin(TRACE_TAG_DATABASE, "uncanonicalize"); traceBegin(TRACE_TAG_DATABASE, "uncanonicalize: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading Loading @@ -641,7 +641,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall != PermissionChecker.PERMISSION_GRANTED) { != PermissionChecker.PERMISSION_GRANTED) { return false; return false; } } Trace.traceBegin(TRACE_TAG_DATABASE, "refresh"); traceBegin(TRACE_TAG_DATABASE, "refresh: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading @@ -658,7 +658,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall int uid, int modeFlags) { int uid, int modeFlags) { uri = validateIncomingUri(uri); uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); uri = maybeGetUriWithoutUserId(uri); Trace.traceBegin(TRACE_TAG_DATABASE, "checkUriPermission"); traceBegin(TRACE_TAG_DATABASE, "checkUriPermission: ", uri.getAuthority()); final AttributionSource original = setCallingAttributionSource( final AttributionSource original = setCallingAttributionSource( attributionSource); attributionSource); try { try { Loading Loading @@ -2683,4 +2683,10 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } } return uri; return uri; } } private static void traceBegin(long traceTag, String methodName, String subInfo) { if (Trace.isTagEnabled(traceTag)) { Trace.traceBegin(traceTag, methodName + subInfo); } } } }
services/core/java/com/android/server/am/ActivityManagerService.java +60 −5 Original line number Original line Diff line number Diff line Loading @@ -5996,13 +5996,23 @@ public class ActivityManagerService extends IActivityManager.Stub public final ContentProviderHolder getContentProvider( public final ContentProviderHolder getContentProvider( IApplicationThread caller, String callingPackage, String name, int userId, IApplicationThread caller, String callingPackage, String name, int userId, boolean stable) { boolean stable) { traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "getContentProvider: ", name); try { return mCpHelper.getContentProvider(caller, callingPackage, name, userId, stable); return mCpHelper.getContentProvider(caller, callingPackage, name, userId, stable); } finally { Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } } } @Override @Override public ContentProviderHolder getContentProviderExternal( public ContentProviderHolder getContentProviderExternal( String name, int userId, IBinder token, String tag) { String name, int userId, IBinder token, String tag) { traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "getContentProviderExternal: ", name); try { return mCpHelper.getContentProviderExternal(name, userId, token, tag); return mCpHelper.getContentProviderExternal(name, userId, token, tag); } finally { Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } } } /** /** Loading @@ -6017,18 +6027,57 @@ public class ActivityManagerService extends IActivityManager.Stub @Deprecated @Deprecated @Override @Override public void removeContentProviderExternal(String name, IBinder token) { public void removeContentProviderExternal(String name, IBinder token) { traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "removeContentProviderExternal: ", name); try { removeContentProviderExternalAsUser(name, token, UserHandle.getCallingUserId()); removeContentProviderExternalAsUser(name, token, UserHandle.getCallingUserId()); } finally { Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } } } @Override @Override public void removeContentProviderExternalAsUser(String name, IBinder token, int userId) { public void removeContentProviderExternalAsUser(String name, IBinder token, int userId) { traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "removeContentProviderExternalAsUser: ", name); try { mCpHelper.removeContentProviderExternalAsUser(name, token, userId); mCpHelper.removeContentProviderExternalAsUser(name, token, userId); } finally { Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } } } @Override @Override public final void publishContentProviders(IApplicationThread caller, public final void publishContentProviders(IApplicationThread caller, List<ContentProviderHolder> providers) { List<ContentProviderHolder> providers) { if (Trace.isTagEnabled(Trace.TRACE_TAG_ACTIVITY_MANAGER)) { final int maxLength = 256; final StringBuilder sb = new StringBuilder(maxLength); sb.append("publishContentProviders: "); if (providers != null) { boolean first = true; for (int i = 0, size = providers.size(); i < size; i++) { final ContentProviderHolder holder = providers.get(i); if (holder != null && holder.info != null && holder.info.authority != null) { final int len = holder.info.authority.length(); if (sb.length() + len > maxLength) { sb.append("[[TRUNCATED]]"); break; } if (!first) { sb.append(';'); } else { first = false; } sb.append(holder.info.authority); } } } Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, sb.toString()); } try { mCpHelper.publishContentProviders(caller, providers); mCpHelper.publishContentProviders(caller, providers); } finally { Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } } } @Override @Override Loading Loading @@ -17108,4 +17157,10 @@ public class ActivityManagerService extends IActivityManager.Stub SystemClock.sleep(durationMs); SystemClock.sleep(durationMs); } } } } static void traceBegin(long traceTag, String methodName, String subInfo) { if (Trace.isTagEnabled(traceTag)) { Trace.traceBegin(traceTag, methodName + subInfo); } } } }
services/core/java/com/android/server/am/ContentProviderHelper.java +89 −55 Original line number Original line Diff line number Diff line Loading @@ -58,6 +58,7 @@ import android.os.Process; import android.os.RemoteCallback; import android.os.RemoteCallback; import android.os.RemoteException; import android.os.RemoteException; import android.os.SystemClock; import android.os.SystemClock; import android.os.Trace; import android.os.UserHandle; import android.os.UserHandle; import android.provider.Settings; import android.provider.Settings; import android.text.TextUtils; import android.text.TextUtils; Loading Loading @@ -707,7 +708,6 @@ public class ContentProviderHelper { mService.enforceNotIsolatedCaller("removeContentProvider"); mService.enforceNotIsolatedCaller("removeContentProvider"); final long ident = Binder.clearCallingIdentity(); final long ident = Binder.clearCallingIdentity(); try { try { synchronized (mService) { ContentProviderConnection conn; ContentProviderConnection conn; try { try { conn = (ContentProviderConnection) connection; conn = (ContentProviderConnection) connection; Loading @@ -720,8 +720,17 @@ public class ContentProviderHelper { if (conn == null) { if (conn == null) { throw new NullPointerException("connection is null"); throw new NullPointerException("connection is null"); } } ActivityManagerService.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "removeContentProvider: ", (conn.provider != null && conn.provider.info != null ? conn.provider.info.authority : "")); try { synchronized (mService) { decProviderCountLocked(conn, null, null, stable, true, true); decProviderCountLocked(conn, null, null, stable, true, true); } } } finally { Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } } finally { } finally { Binder.restoreCallingIdentity(ident); Binder.restoreCallingIdentity(ident); } } Loading Loading @@ -781,8 +790,15 @@ public class ContentProviderHelper { throw new NullPointerException("connection is null"); throw new NullPointerException("connection is null"); } } ActivityManagerService.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "refContentProvider: ", (conn.provider != null && conn.provider.info != null ? conn.provider.info.authority : "")); try { conn.adjustCounts(stable, unstable); conn.adjustCounts(stable, unstable); return !conn.dead; return !conn.dead; } finally { Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } } } void unstableProviderDied(IBinder connection) { void unstableProviderDied(IBinder connection) { Loading @@ -798,6 +814,12 @@ public class ContentProviderHelper { throw new NullPointerException("connection is null"); throw new NullPointerException("connection is null"); } } ActivityManagerService.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "unstableProviderDied: ", (conn.provider != null && conn.provider.info != null ? conn.provider.info.authority : "")); try { // Safely retrieve the content provider associated with the connection. // Safely retrieve the content provider associated with the connection. IContentProvider provider; IContentProvider provider; synchronized (mService) { synchronized (mService) { Loading Loading @@ -835,7 +857,8 @@ public class ContentProviderHelper { // As far as we're concerned, this is just like receiving a // As far as we're concerned, this is just like receiving a // death notification... just a bit prematurely. // death notification... just a bit prematurely. mService.reportUidInfoMessageLocked(TAG, "Process " + proc.processName mService.reportUidInfoMessageLocked(TAG, "Process " + proc.processName + " (pid " + proc.getPid() + ") early provider death", proc.info.uid); + " (pid " + proc.getPid() + ") early provider death", proc.info.uid); final long token = Binder.clearCallingIdentity(); final long token = Binder.clearCallingIdentity(); try { try { mService.appDiedLocked(proc, "unstable content provider"); mService.appDiedLocked(proc, "unstable content provider"); Loading @@ -843,6 +866,9 @@ public class ContentProviderHelper { Binder.restoreCallingIdentity(token); Binder.restoreCallingIdentity(token); } } } } } finally { Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } } } void appNotRespondingViaProvider(IBinder connection) { void appNotRespondingViaProvider(IBinder connection) { Loading @@ -855,6 +881,11 @@ public class ContentProviderHelper { return; return; } } ActivityManagerService.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "appNotRespondingViaProvider: ", (conn.provider != null && conn.provider.info != null ? conn.provider.info.authority : "")); try { final ProcessRecord host = conn.provider.proc; final ProcessRecord host = conn.provider.proc; if (host == null) { if (host == null) { Slog.w(TAG, "Failed to find hosting ProcessRecord"); Slog.w(TAG, "Failed to find hosting ProcessRecord"); Loading @@ -862,6 +893,9 @@ public class ContentProviderHelper { } } mService.mAnrHelper.appNotResponding(host, "ContentProvider not responding"); mService.mAnrHelper.appNotResponding(host, "ContentProvider not responding"); } finally { Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } } } /** /** Loading