From ff17024e583b170312d82089fd358d278ce16c9a Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Wed, 19 Nov 2014 10:59:01 -0800 Subject: Fix issue with call backs from media process. All but a few lines of this is for issue #16013164, which allowed apps to do some operations as the media uid by having it call back to them to open a file. The problem here is with the tempory identity stuff in the activity manager, allowing us to make the open call as the original caller... ideally we should figure out a way to just get rid of all of that, but the solution here is actually easier (even though it doesn't look it) -- we now hand a token over to the openFile() call that it can use when doing permission checks to say "yes I would like the check to be against whoever is responsible for the open". This allows us to do the uid remapping for only this one specific set of permission checks, and nothing else. Also fix issue #17487348: Isolated services can access system services they shouldn't be able to. Don't send any system service IBinder objects down for the first initialization of an isolated process. Change-Id: I3c70e16e0899d7eef0bae458e83958b41ed2b75e --- test-runner/src/android/test/mock/MockContentProvider.java | 4 ++-- test-runner/src/android/test/mock/MockContext.java | 13 +++++++++++++ test-runner/src/android/test/mock/MockIContentProvider.java | 3 ++- 3 files changed, 17 insertions(+), 3 deletions(-) (limited to 'test-runner') diff --git a/test-runner/src/android/test/mock/MockContentProvider.java b/test-runner/src/android/test/mock/MockContentProvider.java index 28d52b0..5ef71df 100644 --- a/test-runner/src/android/test/mock/MockContentProvider.java +++ b/test-runner/src/android/test/mock/MockContentProvider.java @@ -91,8 +91,8 @@ public class MockContentProvider extends ContentProvider { @Override public ParcelFileDescriptor openFile( - String callingPackage, Uri url, String mode, ICancellationSignal signal) - throws RemoteException, FileNotFoundException { + String callingPackage, Uri url, String mode, ICancellationSignal signal, + IBinder callerToken) throws RemoteException, FileNotFoundException { return MockContentProvider.this.openFile(url, mode); } diff --git a/test-runner/src/android/test/mock/MockContext.java b/test-runner/src/android/test/mock/MockContext.java index 46c81b6..3378872 100644 --- a/test-runner/src/android/test/mock/MockContext.java +++ b/test-runner/src/android/test/mock/MockContext.java @@ -37,6 +37,7 @@ import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; import android.os.Handler; +import android.os.IBinder; import android.os.Looper; import android.os.UserHandle; import android.view.DisplayAdjustments; @@ -483,6 +484,12 @@ public class MockContext extends Context { throw new UnsupportedOperationException(); } + /** @hide */ + @Override + public int checkPermission(String permission, int pid, int uid, IBinder callerToken) { + return checkPermission(permission, pid, uid); + } + @Override public int checkCallingPermission(String permission) { throw new UnsupportedOperationException(); @@ -524,6 +531,12 @@ public class MockContext extends Context { throw new UnsupportedOperationException(); } + /** @hide */ + @Override + public int checkUriPermission(Uri uri, int pid, int uid, int modeFlags, IBinder callerToken) { + return checkUriPermission(uri, pid, uid, modeFlags); + } + @Override public int checkCallingUriPermission(Uri uri, int modeFlags) { throw new UnsupportedOperationException(); diff --git a/test-runner/src/android/test/mock/MockIContentProvider.java b/test-runner/src/android/test/mock/MockIContentProvider.java index c0dc7c3..ee8c376 100644 --- a/test-runner/src/android/test/mock/MockIContentProvider.java +++ b/test-runner/src/android/test/mock/MockIContentProvider.java @@ -62,7 +62,8 @@ public class MockIContentProvider implements IContentProvider { } public ParcelFileDescriptor openFile( - String callingPackage, Uri url, String mode, ICancellationSignal signal) { + String callingPackage, Uri url, String mode, ICancellationSignal signal, + IBinder callerToken) { throw new UnsupportedOperationException("unimplemented mock method"); } -- cgit v1.1