From 99882e67586590e0e111059d9a9d2afd73c3c5b7 Mon Sep 17 00:00:00 2001 From: Eran Messeri Date: Wed, 8 May 2019 15:35:53 +0100 Subject: Fix sharing into a locked work profile Change ActivityStartInterceptor.interceptWithConfirmCredentialsIfNeeded to create the intent for the original sender under the original caller uid, not the binder calling uid (which may be the system). This fixes the issue which happens when: * There's a work profile on the device. * The work profile has a separate challenge. * The work profile is locked using that challenge. * The user shares a resource into the work profile. Under those circumstances, the user is asked to unlock the work profile, but as a part of that process the grant to the resource is lost, so that when the user chooses the app in the work profile, that app no longer has a grant to the resource. When the activity is started from the right uid then the grant is accessible. Bug: 123017711 Test: Manual, set up a work profile with TestDPC, ensure it has a separate lock challenge and share a picture file from the personal profile to the (locked) work profile. Change-Id: I7a55e4bdc4709caec2c5ef4466b720ca786ebfe3 Merged-In: I7a55e4bdc4709caec2c5ef4466b720ca786ebfe3 (cherry picked from commit c6be50986332a2af32a416b3638c9ca5c17b137b) --- services/core/java/com/android/server/wm/ActivityStartInterceptor.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityStartInterceptor.java b/services/core/java/com/android/server/wm/ActivityStartInterceptor.java index b8442a887dac..1cdb49d25dfd 100644 --- a/services/core/java/com/android/server/wm/ActivityStartInterceptor.java +++ b/services/core/java/com/android/server/wm/ActivityStartInterceptor.java @@ -46,7 +46,6 @@ import android.content.pm.PackageManagerInternal; import android.content.pm.ResolveInfo; import android.content.pm.SuspendDialogInfo; import android.content.pm.UserInfo; -import android.os.Binder; import android.os.Bundle; import android.os.RemoteException; import android.os.UserHandle; @@ -304,7 +303,7 @@ class ActivityStartInterceptor { return null; } // TODO(b/28935539): should allow certain activities to bypass work challenge - final IntentSender target = createIntentSenderForOriginalIntent(Binder.getCallingUid(), + final IntentSender target = createIntentSenderForOriginalIntent(mCallingUid, FLAG_CANCEL_CURRENT | FLAG_ONE_SHOT | FLAG_IMMUTABLE); final KeyguardManager km = (KeyguardManager) mServiceContext .getSystemService(KEYGUARD_SERVICE); -- cgit v1.2.3-59-g8ed1b