Merge "Provide referrer package with respect to package visibility" into sc-qpr1-dev
This commit is contained in:
@@ -4148,7 +4148,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
// The activity now gets access to the data associated with this Intent.
|
// The activity now gets access to the data associated with this Intent.
|
||||||
mAtmService.mUgmInternal.grantUriPermissionUncheckedFromIntent(intentGrants,
|
mAtmService.mUgmInternal.grantUriPermissionUncheckedFromIntent(intentGrants,
|
||||||
getUriPermissionsLocked());
|
getUriPermissionsLocked());
|
||||||
final ReferrerIntent rintent = new ReferrerIntent(intent, referrer);
|
final ReferrerIntent rintent = new ReferrerIntent(intent, getFilteredReferrer(referrer));
|
||||||
boolean unsent = true;
|
boolean unsent = true;
|
||||||
final boolean isTopActivityWhileSleeping = isTopRunningActivity() && isSleeping();
|
final boolean isTopActivityWhileSleeping = isTopRunningActivity() && isSleeping();
|
||||||
|
|
||||||
@@ -8504,6 +8504,19 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
return launchedFromUid;
|
return launchedFromUid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the referrer package name with respect to package visibility. This method returns null
|
||||||
|
* if the given package is not visible to this activity.
|
||||||
|
*/
|
||||||
|
String getFilteredReferrer(String referrerPackage) {
|
||||||
|
if (referrerPackage == null || (!referrerPackage.equals(packageName)
|
||||||
|
&& mWmService.mPmInternal.filterAppAccess(
|
||||||
|
referrerPackage, info.applicationInfo.uid, mUserId))) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return referrerPackage;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether this ActivityRecord can turn the screen on. It checks whether the flag
|
* Determines whether this ActivityRecord can turn the screen on. It checks whether the flag
|
||||||
* {@link ActivityRecord#getTurnScreenOnFlag} is set and checks whether the ActivityRecord
|
* {@link ActivityRecord#getTurnScreenOnFlag} is set and checks whether the ActivityRecord
|
||||||
|
|||||||
@@ -848,9 +848,9 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
|
|||||||
// and override configs.
|
// and override configs.
|
||||||
mergedConfiguration.getGlobalConfiguration(),
|
mergedConfiguration.getGlobalConfiguration(),
|
||||||
mergedConfiguration.getOverrideConfiguration(), r.compat,
|
mergedConfiguration.getOverrideConfiguration(), r.compat,
|
||||||
r.launchedFromPackage, task.voiceInteractor, proc.getReportedProcState(),
|
r.getFilteredReferrer(r.launchedFromPackage), task.voiceInteractor,
|
||||||
r.getSavedState(), r.getPersistentSavedState(), results, newIntents,
|
proc.getReportedProcState(), r.getSavedState(), r.getPersistentSavedState(),
|
||||||
r.takeOptions(), isTransitionForward,
|
results, newIntents, r.takeOptions(), isTransitionForward,
|
||||||
proc.createProfilerInfoIfNeeded(), r.assistToken, activityClientController,
|
proc.createProfilerInfoIfNeeded(), r.assistToken, activityClientController,
|
||||||
r.createFixedRotationAdjustmentsIfNeeded(), r.shareableActivityToken,
|
r.createFixedRotationAdjustmentsIfNeeded(), r.shareableActivityToken,
|
||||||
r.getLaunchedFromBubble()));
|
r.getLaunchedFromBubble()));
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
@@ -40,8 +41,10 @@ import static org.mockito.Mockito.timeout;
|
|||||||
|
|
||||||
import android.app.WaitResult;
|
import android.app.WaitResult;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.os.ConditionVariable;
|
import android.os.ConditionVariable;
|
||||||
|
import android.os.RemoteException;
|
||||||
import android.platform.test.annotations.Presubmit;
|
import android.platform.test.annotations.Presubmit;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
|
|
||||||
@@ -187,6 +190,24 @@ public class ActivityTaskSupervisorTests extends WindowTestsBase {
|
|||||||
verify(taskChangeNotifier, never()).notifyActivityDismissingDockedRootTask();
|
verify(taskChangeNotifier, never()).notifyActivityDismissingDockedRootTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Ensures that the calling package name passed to client complies with package visibility. */
|
||||||
|
@Test
|
||||||
|
public void testFilteredReferred() {
|
||||||
|
final ActivityRecord activity = new ActivityBuilder(mAtm)
|
||||||
|
.setLaunchedFromPackage("other.package").setCreateTask(true).build();
|
||||||
|
assertNotNull(activity.launchedFromPackage);
|
||||||
|
try {
|
||||||
|
mSupervisor.realStartActivityLocked(activity, activity.app, false /* andResume */,
|
||||||
|
false /* checkConfig */);
|
||||||
|
} catch (RemoteException ignored) {
|
||||||
|
}
|
||||||
|
verify(activity).getFilteredReferrer(eq(activity.launchedFromPackage));
|
||||||
|
|
||||||
|
activity.deliverNewIntentLocked(ActivityBuilder.DEFAULT_FAKE_UID,
|
||||||
|
new Intent(), null /* intentGrants */, "other.package2");
|
||||||
|
verify(activity).getFilteredReferrer(eq("other.package2"));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures that notify focus task changes.
|
* Ensures that notify focus task changes.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -801,6 +801,7 @@ class WindowTestsBase extends SystemServiceTestsBase {
|
|||||||
private int mConfigChanges;
|
private int mConfigChanges;
|
||||||
private int mLaunchedFromPid;
|
private int mLaunchedFromPid;
|
||||||
private int mLaunchedFromUid;
|
private int mLaunchedFromUid;
|
||||||
|
private String mLaunchedFromPackage;
|
||||||
private WindowProcessController mWpc;
|
private WindowProcessController mWpc;
|
||||||
private Bundle mIntentExtras;
|
private Bundle mIntentExtras;
|
||||||
private boolean mOnTop = false;
|
private boolean mOnTop = false;
|
||||||
@@ -911,6 +912,11 @@ class WindowTestsBase extends SystemServiceTestsBase {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ActivityBuilder setLaunchedFromPackage(String packageName) {
|
||||||
|
mLaunchedFromPackage = packageName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
ActivityBuilder setUseProcess(WindowProcessController wpc) {
|
ActivityBuilder setUseProcess(WindowProcessController wpc) {
|
||||||
mWpc = wpc;
|
mWpc = wpc;
|
||||||
return this;
|
return this;
|
||||||
@@ -1000,6 +1006,7 @@ class WindowTestsBase extends SystemServiceTestsBase {
|
|||||||
final ActivityRecord activity = new ActivityRecord.Builder(mService)
|
final ActivityRecord activity = new ActivityRecord.Builder(mService)
|
||||||
.setLaunchedFromPid(mLaunchedFromPid)
|
.setLaunchedFromPid(mLaunchedFromPid)
|
||||||
.setLaunchedFromUid(mLaunchedFromUid)
|
.setLaunchedFromUid(mLaunchedFromUid)
|
||||||
|
.setLaunchedFromPackage(mLaunchedFromPackage)
|
||||||
.setIntent(intent)
|
.setIntent(intent)
|
||||||
.setActivityInfo(aInfo)
|
.setActivityInfo(aInfo)
|
||||||
.setActivityOptions(options)
|
.setActivityOptions(options)
|
||||||
|
|||||||
Reference in New Issue
Block a user