Merge "Allow System ChooserActivity to start home activity" into qt-r1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
32cc706519
@@ -921,8 +921,9 @@ final class ActivityRecord extends ConfigurationContainer {
|
||||
return ResolverActivity.class.getName().equals(className);
|
||||
}
|
||||
|
||||
boolean isResolverActivity() {
|
||||
return isResolverActivity(mActivityComponent.getClassName());
|
||||
boolean isResolverOrDelegateActivity() {
|
||||
return isResolverActivity(mActivityComponent.getClassName()) || Objects.equals(
|
||||
mActivityComponent, mAtmService.mStackSupervisor.getSystemChooserActivity());
|
||||
}
|
||||
|
||||
boolean isResolverOrChildActivity() {
|
||||
@@ -1251,7 +1252,8 @@ final class ActivityRecord extends ConfigurationContainer {
|
||||
&& intent.getType() == null;
|
||||
}
|
||||
|
||||
private boolean canLaunchHomeActivity(int uid, ActivityRecord sourceRecord) {
|
||||
@VisibleForTesting
|
||||
boolean canLaunchHomeActivity(int uid, ActivityRecord sourceRecord) {
|
||||
if (uid == Process.myUid() || uid == 0) {
|
||||
// System process can launch home activity.
|
||||
return true;
|
||||
@@ -1261,8 +1263,8 @@ final class ActivityRecord extends ConfigurationContainer {
|
||||
if (recentTasks != null && recentTasks.isCallerRecents(uid)) {
|
||||
return true;
|
||||
}
|
||||
// Resolver activity can launch home activity.
|
||||
return sourceRecord != null && sourceRecord.isResolverActivity();
|
||||
// Resolver or system chooser activity can launch home activity.
|
||||
return sourceRecord != null && sourceRecord.isResolverOrDelegateActivity();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1281,7 +1283,7 @@ final class ActivityRecord extends ConfigurationContainer {
|
||||
ActivityOptions options, ActivityRecord sourceRecord) {
|
||||
int activityType = ACTIVITY_TYPE_UNDEFINED;
|
||||
if ((!componentSpecified || canLaunchHomeActivity(launchedFromUid, sourceRecord))
|
||||
&& isHomeIntent(intent) && !isResolverActivity()) {
|
||||
&& isHomeIntent(intent) && !isResolverOrDelegateActivity()) {
|
||||
// This sure looks like a home activity!
|
||||
activityType = ACTIVITY_TYPE_HOME;
|
||||
|
||||
|
||||
@@ -130,6 +130,7 @@ import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.content.ReferrerIntent;
|
||||
@@ -322,6 +323,12 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
|
||||
* is being brought in front of us. */
|
||||
boolean mUserLeaving = false;
|
||||
|
||||
/**
|
||||
* The system chooser activity which worked as a delegate of
|
||||
* {@link com.android.internal.app.ResolverActivity}.
|
||||
*/
|
||||
private ComponentName mSystemChooserActivity;
|
||||
|
||||
/**
|
||||
* We don't want to allow the device to go to sleep while in the process
|
||||
* of launching an activity. This is primarily to allow alarm intent
|
||||
@@ -469,6 +476,14 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
|
||||
return mKeyguardController;
|
||||
}
|
||||
|
||||
ComponentName getSystemChooserActivity() {
|
||||
if (mSystemChooserActivity == null) {
|
||||
mSystemChooserActivity = ComponentName.unflattenFromString(
|
||||
mService.mContext.getResources().getString(R.string.config_chooserActivity));
|
||||
}
|
||||
return mSystemChooserActivity;
|
||||
}
|
||||
|
||||
void setRecentTasks(RecentTasks recentTasks) {
|
||||
mRecentTasks = recentTasks;
|
||||
mRecentTasks.registerCallback(this);
|
||||
|
||||
@@ -1979,8 +1979,8 @@ class ActivityStarter {
|
||||
// Also put noDisplay activities in the source task. These by itself can be placed
|
||||
// in any task/stack, however it could launch other activities like ResolverActivity,
|
||||
// and we want those to stay in the original task.
|
||||
if ((mStartActivity.isResolverActivity() || mStartActivity.noDisplay) && mSourceRecord != null
|
||||
&& mSourceRecord.inFreeformWindowingMode()) {
|
||||
if ((mStartActivity.isResolverOrDelegateActivity() || mStartActivity.noDisplay)
|
||||
&& mSourceRecord != null && mSourceRecord.inFreeformWindowingMode()) {
|
||||
mAddingToTask = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.server.wm;
|
||||
|
||||
import static android.os.Process.NOBODY_UID;
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
import static android.view.Surface.ROTATION_0;
|
||||
import static android.view.Surface.ROTATION_90;
|
||||
@@ -40,6 +41,8 @@ import static com.android.server.wm.ActivityStack.STACK_VISIBILITY_INVISIBLE;
|
||||
import static com.android.server.wm.ActivityStack.STACK_VISIBILITY_VISIBLE;
|
||||
import static com.android.server.wm.ActivityStack.STACK_VISIBILITY_VISIBLE_BEHIND_TRANSLUCENT;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
@@ -54,8 +57,10 @@ import android.app.ActivityOptions;
|
||||
import android.app.servertransaction.ActivityConfigurationChangeItem;
|
||||
import android.app.servertransaction.ClientTransaction;
|
||||
import android.app.servertransaction.PauseActivityItem;
|
||||
import android.content.ComponentName;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Rect;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
import android.util.MergedConfiguration;
|
||||
@@ -67,6 +72,7 @@ import android.view.RemoteAnimationTarget;
|
||||
|
||||
import androidx.test.filters.MediumTest;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.server.wm.utils.WmDisplayCutout;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -605,6 +611,15 @@ public class ActivityRecordTests extends ActivityTestsBase {
|
||||
assertNull(mActivity.pendingOptions);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCanLaunchHomeActivityFromChooser() {
|
||||
ComponentName chooserComponent = ComponentName.unflattenFromString(
|
||||
Resources.getSystem().getString(R.string.config_chooserActivity));
|
||||
ActivityRecord chooserActivity = new ActivityBuilder(mService).setComponent(
|
||||
chooserComponent).build();
|
||||
assertThat(mActivity.canLaunchHomeActivity(NOBODY_UID, chooserActivity)).isTrue();
|
||||
}
|
||||
|
||||
/** Setup {@link #mActivity} as a size-compat-mode-able activity without fixed orientation. */
|
||||
private void prepareFixedAspectRatioUnresizableActivity() {
|
||||
setupDisplayContentForCompatDisplayInsets();
|
||||
|
||||
Reference in New Issue
Block a user