Loading core/java/android/app/IActivityManager.aidl +0 −6 Original line number Diff line number Diff line Loading @@ -341,12 +341,6 @@ interface IActivityManager { in String message, boolean force, int exceptionTypeId); void crashApplicationWithTypeWithExtras(int uid, int initialPid, in String packageName, int userId, in String message, boolean force, int exceptionTypeId, in Bundle extras); /** @deprecated -- use getProviderMimeTypeAsync */ @UnsupportedAppUsage(maxTargetSdk = 29, publicAlternatives = "Use {@link android.content.ContentResolver#getType} public API instead.") String getProviderMimeType(in Uri uri, int userId); oneway void getProviderMimeTypeAsync(in Uri uri, int userId, in RemoteCallback resultCallback); oneway void getMimeTypeFilterAsync(in Uri uri, int userId, in RemoteCallback resultCallback); // Cause the specified process to dump the specified heap. boolean dumpHeap(in String process, int userId, boolean managed, boolean mallocInfo, Loading core/java/android/content/ContentProvider.java +2 −0 Original line number Diff line number Diff line Loading @@ -389,6 +389,8 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall @Override public void getTypeAnonymousAsync(Uri uri, RemoteCallback callback) { uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); final Bundle result = new Bundle(); try { result.putString(ContentResolver.REMOTE_CALLBACK_RESULT, getTypeAnonymous(uri)); Loading services/core/java/com/android/server/am/ActivityManagerService.java +0 −30 Original line number Diff line number Diff line Loading @@ -7014,36 +7014,6 @@ public class ActivityManagerService extends IActivityManager.Stub mCpHelper.appNotRespondingViaProvider(connection); } /** * Allows apps to retrieve the MIME type of a URI. * If an app is in the same user as the ContentProvider, or if it is allowed to interact across * users, then it does not need permission to access the ContentProvider. * Either, it needs cross-user uri grants. * * CTS tests for this functionality can be run with "runtest cts-appsecurity". * * Test cases are at cts/tests/appsecurity-tests/test-apps/UsePermissionDiffCert/ * src/com/android/cts/usespermissiondiffcertapp/AccessPermissionWithDiffSigTest.java * * @deprecated -- use getProviderMimeTypeAsync. */ @Deprecated @Override public String getProviderMimeType(Uri uri, int userId) { return mCpHelper.getProviderMimeType(uri, userId); } /** * Allows apps to retrieve the MIME type of a URI. * If an app is in the same user as the ContentProvider, or if it is allowed to interact across * users, then it does not need permission to access the ContentProvider. * Either way, it needs cross-user uri grants. */ @Override public void getProviderMimeTypeAsync(Uri uri, int userId, RemoteCallback resultCallback) { mCpHelper.getProviderMimeTypeAsync(uri, userId, resultCallback); } /** * Filters calls to getType based on permission. If the caller has required permission, * then it returns the contentProvider#getType. Loading services/core/java/com/android/server/am/ActivityManagerShellCommand.java +12 −7 Original line number Diff line number Diff line Loading @@ -146,6 +146,7 @@ import java.util.Locale; import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGLConfig; Loading Loading @@ -595,10 +596,14 @@ final class ActivityManagerShellCommand extends ShellCommand { return 1; } String mimeType = intent.getType(); if (mimeType == null && intent.getData() != null AtomicReference<String> mimeType = new AtomicReference<>(intent.getType()); if (mimeType.get() == null && intent.getData() != null && "content".equals(intent.getData().getScheme())) { mimeType = mInterface.getProviderMimeType(intent.getData(), mUserId); mInterface.getMimeTypeFilterAsync(intent.getData(), mUserId, new RemoteCallback(result -> { mimeType.set(result.getPairValue()); })); } do { Loading @@ -611,8 +616,8 @@ final class ActivityManagerShellCommand extends ShellCommand { int userIdForQuery = mInternal.mUserController.handleIncomingUser( Binder.getCallingPid(), Binder.getCallingUid(), mUserId, false, ALLOW_NON_FULL, "ActivityManagerShellCommand", null); List<ResolveInfo> activities = mPm.queryIntentActivities(intent, mimeType, 0, userIdForQuery).getList(); List<ResolveInfo> activities = mPm.queryIntentActivities(intent, mimeType.get(), 0, userIdForQuery).getList(); if (activities == null || activities.size() <= 0) { getErrPrintWriter().println("Error: Intent does not match any activities: " + intent); Loading Loading @@ -708,12 +713,12 @@ final class ActivityManagerShellCommand extends ShellCommand { } if (mWaitOption) { result = mInternal.startActivityAndWait(null, SHELL_PACKAGE_NAME, null, intent, mimeType, null, null, 0, mStartFlags, profilerInfo, mimeType.get(), null, null, 0, mStartFlags, profilerInfo, options != null ? options.toBundle() : null, mUserId); res = result.result; } else { res = mInternal.startActivityAsUserWithFeature(null, SHELL_PACKAGE_NAME, null, intent, mimeType, null, null, 0, mStartFlags, profilerInfo, intent, mimeType.get(), null, null, 0, mStartFlags, profilerInfo, options != null ? options.toBundle() : null, mUserId); } final long endTime = SystemClock.uptimeMillis(); Loading services/core/java/com/android/server/am/ContentProviderHelper.java +0 −116 Original line number Diff line number Diff line Loading @@ -968,122 +968,6 @@ public class ContentProviderHelper { } } /** * Allows apps to retrieve the MIME type of a URI. * If an app is in the same user as the ContentProvider, or if it is allowed to interact across * users, then it does not need permission to access the ContentProvider. * Either, it needs cross-user uri grants. * * CTS tests for this functionality can be run with "runtest cts-appsecurity". * * Test cases are at cts/tests/appsecurity-tests/test-apps/UsePermissionDiffCert/ * src/com/android/cts/usespermissiondiffcertapp/AccessPermissionWithDiffSigTest.java * * @deprecated -- use getProviderMimeTypeAsync. */ @Deprecated String getProviderMimeType(Uri uri, int userId) { mService.enforceNotIsolatedCaller("getProviderMimeType"); final String name = uri.getAuthority(); final int callingUid = Binder.getCallingUid(); final int callingPid = Binder.getCallingPid(); final int safeUserId = mService.mUserController.unsafeConvertIncomingUser(userId); final long ident = canClearIdentity(callingPid, callingUid, safeUserId) ? Binder.clearCallingIdentity() : 0; final ContentProviderHolder holder; try { holder = getContentProviderExternalUnchecked(name, null /* token */, callingUid, "*getmimetype*", safeUserId); } finally { if (ident != 0) { Binder.restoreCallingIdentity(ident); } } try { if (isHolderVisibleToCaller(holder, callingUid, safeUserId)) { final IBinder providerConnection = holder.connection; final ComponentName providerName = holder.info.getComponentName(); // Note: creating a new Runnable instead of using a lambda here since lambdas in // java provide no guarantee that there will be a new instance returned every call. // Hence, it's possible that a cached copy is returned and the ANR is executed on // the incorrect provider. final Runnable providerNotResponding = new Runnable() { @Override public void run() { Log.w(TAG, "Provider " + providerName + " didn't return from getType()."); appNotRespondingViaProvider(providerConnection); } }; mService.mHandler.postDelayed(providerNotResponding, 1000); try { final String type = holder.provider.getType(uri); return type; } finally { mService.mHandler.removeCallbacks(providerNotResponding); // We need to clear the identity to call removeContentProviderExternalUnchecked final long token = Binder.clearCallingIdentity(); try { removeContentProviderExternalUnchecked(name, null /* token */, safeUserId); } finally { Binder.restoreCallingIdentity(token); } } } } catch (RemoteException e) { Log.w(TAG, "Content provider dead retrieving " + uri, e); return null; } catch (Exception e) { Log.w(TAG, "Exception while determining type of " + uri, e); return null; } return null; } /** * Allows apps to retrieve the MIME type of a URI. * If an app is in the same user as the ContentProvider, or if it is allowed to interact across * users, then it does not need permission to access the ContentProvider. * Either way, it needs cross-user uri grants. */ void getProviderMimeTypeAsync(Uri uri, int userId, RemoteCallback resultCallback) { mService.enforceNotIsolatedCaller("getProviderMimeTypeAsync"); final String name = uri.getAuthority(); final int callingUid = Binder.getCallingUid(); final int callingPid = Binder.getCallingPid(); final int safeUserId = mService.mUserController.unsafeConvertIncomingUser(userId); final long ident = canClearIdentity(callingPid, callingUid, safeUserId) ? Binder.clearCallingIdentity() : 0; final ContentProviderHolder holder; try { holder = getContentProviderExternalUnchecked(name, null /* token */, callingUid, "*getmimetype*", safeUserId); } finally { if (ident != 0) { Binder.restoreCallingIdentity(ident); } } try { if (isHolderVisibleToCaller(holder, callingUid, safeUserId)) { holder.provider.getTypeAsync(uri, new RemoteCallback(result -> { final long identity = Binder.clearCallingIdentity(); try { removeContentProviderExternalUnchecked(name, null, safeUserId); } finally { Binder.restoreCallingIdentity(identity); } resultCallback.sendResult(result); })); } else { resultCallback.sendResult(Bundle.EMPTY); } } catch (RemoteException e) { Log.w(TAG, "Content provider dead retrieving " + uri, e); resultCallback.sendResult(Bundle.EMPTY); } } /** * Filters calls to getType based on permission. If the caller has required permission, * then it returns the contentProvider#getType. Loading Loading
core/java/android/app/IActivityManager.aidl +0 −6 Original line number Diff line number Diff line Loading @@ -341,12 +341,6 @@ interface IActivityManager { in String message, boolean force, int exceptionTypeId); void crashApplicationWithTypeWithExtras(int uid, int initialPid, in String packageName, int userId, in String message, boolean force, int exceptionTypeId, in Bundle extras); /** @deprecated -- use getProviderMimeTypeAsync */ @UnsupportedAppUsage(maxTargetSdk = 29, publicAlternatives = "Use {@link android.content.ContentResolver#getType} public API instead.") String getProviderMimeType(in Uri uri, int userId); oneway void getProviderMimeTypeAsync(in Uri uri, int userId, in RemoteCallback resultCallback); oneway void getMimeTypeFilterAsync(in Uri uri, int userId, in RemoteCallback resultCallback); // Cause the specified process to dump the specified heap. boolean dumpHeap(in String process, int userId, boolean managed, boolean mallocInfo, Loading
core/java/android/content/ContentProvider.java +2 −0 Original line number Diff line number Diff line Loading @@ -389,6 +389,8 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall @Override public void getTypeAnonymousAsync(Uri uri, RemoteCallback callback) { uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); final Bundle result = new Bundle(); try { result.putString(ContentResolver.REMOTE_CALLBACK_RESULT, getTypeAnonymous(uri)); Loading
services/core/java/com/android/server/am/ActivityManagerService.java +0 −30 Original line number Diff line number Diff line Loading @@ -7014,36 +7014,6 @@ public class ActivityManagerService extends IActivityManager.Stub mCpHelper.appNotRespondingViaProvider(connection); } /** * Allows apps to retrieve the MIME type of a URI. * If an app is in the same user as the ContentProvider, or if it is allowed to interact across * users, then it does not need permission to access the ContentProvider. * Either, it needs cross-user uri grants. * * CTS tests for this functionality can be run with "runtest cts-appsecurity". * * Test cases are at cts/tests/appsecurity-tests/test-apps/UsePermissionDiffCert/ * src/com/android/cts/usespermissiondiffcertapp/AccessPermissionWithDiffSigTest.java * * @deprecated -- use getProviderMimeTypeAsync. */ @Deprecated @Override public String getProviderMimeType(Uri uri, int userId) { return mCpHelper.getProviderMimeType(uri, userId); } /** * Allows apps to retrieve the MIME type of a URI. * If an app is in the same user as the ContentProvider, or if it is allowed to interact across * users, then it does not need permission to access the ContentProvider. * Either way, it needs cross-user uri grants. */ @Override public void getProviderMimeTypeAsync(Uri uri, int userId, RemoteCallback resultCallback) { mCpHelper.getProviderMimeTypeAsync(uri, userId, resultCallback); } /** * Filters calls to getType based on permission. If the caller has required permission, * then it returns the contentProvider#getType. Loading
services/core/java/com/android/server/am/ActivityManagerShellCommand.java +12 −7 Original line number Diff line number Diff line Loading @@ -146,6 +146,7 @@ import java.util.Locale; import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGLConfig; Loading Loading @@ -595,10 +596,14 @@ final class ActivityManagerShellCommand extends ShellCommand { return 1; } String mimeType = intent.getType(); if (mimeType == null && intent.getData() != null AtomicReference<String> mimeType = new AtomicReference<>(intent.getType()); if (mimeType.get() == null && intent.getData() != null && "content".equals(intent.getData().getScheme())) { mimeType = mInterface.getProviderMimeType(intent.getData(), mUserId); mInterface.getMimeTypeFilterAsync(intent.getData(), mUserId, new RemoteCallback(result -> { mimeType.set(result.getPairValue()); })); } do { Loading @@ -611,8 +616,8 @@ final class ActivityManagerShellCommand extends ShellCommand { int userIdForQuery = mInternal.mUserController.handleIncomingUser( Binder.getCallingPid(), Binder.getCallingUid(), mUserId, false, ALLOW_NON_FULL, "ActivityManagerShellCommand", null); List<ResolveInfo> activities = mPm.queryIntentActivities(intent, mimeType, 0, userIdForQuery).getList(); List<ResolveInfo> activities = mPm.queryIntentActivities(intent, mimeType.get(), 0, userIdForQuery).getList(); if (activities == null || activities.size() <= 0) { getErrPrintWriter().println("Error: Intent does not match any activities: " + intent); Loading Loading @@ -708,12 +713,12 @@ final class ActivityManagerShellCommand extends ShellCommand { } if (mWaitOption) { result = mInternal.startActivityAndWait(null, SHELL_PACKAGE_NAME, null, intent, mimeType, null, null, 0, mStartFlags, profilerInfo, mimeType.get(), null, null, 0, mStartFlags, profilerInfo, options != null ? options.toBundle() : null, mUserId); res = result.result; } else { res = mInternal.startActivityAsUserWithFeature(null, SHELL_PACKAGE_NAME, null, intent, mimeType, null, null, 0, mStartFlags, profilerInfo, intent, mimeType.get(), null, null, 0, mStartFlags, profilerInfo, options != null ? options.toBundle() : null, mUserId); } final long endTime = SystemClock.uptimeMillis(); Loading
services/core/java/com/android/server/am/ContentProviderHelper.java +0 −116 Original line number Diff line number Diff line Loading @@ -968,122 +968,6 @@ public class ContentProviderHelper { } } /** * Allows apps to retrieve the MIME type of a URI. * If an app is in the same user as the ContentProvider, or if it is allowed to interact across * users, then it does not need permission to access the ContentProvider. * Either, it needs cross-user uri grants. * * CTS tests for this functionality can be run with "runtest cts-appsecurity". * * Test cases are at cts/tests/appsecurity-tests/test-apps/UsePermissionDiffCert/ * src/com/android/cts/usespermissiondiffcertapp/AccessPermissionWithDiffSigTest.java * * @deprecated -- use getProviderMimeTypeAsync. */ @Deprecated String getProviderMimeType(Uri uri, int userId) { mService.enforceNotIsolatedCaller("getProviderMimeType"); final String name = uri.getAuthority(); final int callingUid = Binder.getCallingUid(); final int callingPid = Binder.getCallingPid(); final int safeUserId = mService.mUserController.unsafeConvertIncomingUser(userId); final long ident = canClearIdentity(callingPid, callingUid, safeUserId) ? Binder.clearCallingIdentity() : 0; final ContentProviderHolder holder; try { holder = getContentProviderExternalUnchecked(name, null /* token */, callingUid, "*getmimetype*", safeUserId); } finally { if (ident != 0) { Binder.restoreCallingIdentity(ident); } } try { if (isHolderVisibleToCaller(holder, callingUid, safeUserId)) { final IBinder providerConnection = holder.connection; final ComponentName providerName = holder.info.getComponentName(); // Note: creating a new Runnable instead of using a lambda here since lambdas in // java provide no guarantee that there will be a new instance returned every call. // Hence, it's possible that a cached copy is returned and the ANR is executed on // the incorrect provider. final Runnable providerNotResponding = new Runnable() { @Override public void run() { Log.w(TAG, "Provider " + providerName + " didn't return from getType()."); appNotRespondingViaProvider(providerConnection); } }; mService.mHandler.postDelayed(providerNotResponding, 1000); try { final String type = holder.provider.getType(uri); return type; } finally { mService.mHandler.removeCallbacks(providerNotResponding); // We need to clear the identity to call removeContentProviderExternalUnchecked final long token = Binder.clearCallingIdentity(); try { removeContentProviderExternalUnchecked(name, null /* token */, safeUserId); } finally { Binder.restoreCallingIdentity(token); } } } } catch (RemoteException e) { Log.w(TAG, "Content provider dead retrieving " + uri, e); return null; } catch (Exception e) { Log.w(TAG, "Exception while determining type of " + uri, e); return null; } return null; } /** * Allows apps to retrieve the MIME type of a URI. * If an app is in the same user as the ContentProvider, or if it is allowed to interact across * users, then it does not need permission to access the ContentProvider. * Either way, it needs cross-user uri grants. */ void getProviderMimeTypeAsync(Uri uri, int userId, RemoteCallback resultCallback) { mService.enforceNotIsolatedCaller("getProviderMimeTypeAsync"); final String name = uri.getAuthority(); final int callingUid = Binder.getCallingUid(); final int callingPid = Binder.getCallingPid(); final int safeUserId = mService.mUserController.unsafeConvertIncomingUser(userId); final long ident = canClearIdentity(callingPid, callingUid, safeUserId) ? Binder.clearCallingIdentity() : 0; final ContentProviderHolder holder; try { holder = getContentProviderExternalUnchecked(name, null /* token */, callingUid, "*getmimetype*", safeUserId); } finally { if (ident != 0) { Binder.restoreCallingIdentity(ident); } } try { if (isHolderVisibleToCaller(holder, callingUid, safeUserId)) { holder.provider.getTypeAsync(uri, new RemoteCallback(result -> { final long identity = Binder.clearCallingIdentity(); try { removeContentProviderExternalUnchecked(name, null, safeUserId); } finally { Binder.restoreCallingIdentity(identity); } resultCallback.sendResult(result); })); } else { resultCallback.sendResult(Bundle.EMPTY); } } catch (RemoteException e) { Log.w(TAG, "Content provider dead retrieving " + uri, e); resultCallback.sendResult(Bundle.EMPTY); } } /** * Filters calls to getType based on permission. If the caller has required permission, * then it returns the contentProvider#getType. Loading