Avoid starting home that targeted before Q on secondary display
Some launchers don't explicitly request for single instance. Since these launchers could be launched on secondary displays and having multiple instances at the same time, the applications may not work properly if they were implemented based on a single display/instance assumption. Bug: 111363427 Test: atest ActivityStackSupervisorTests Test: atest ActivityManagerMultiDisplayTests Change-Id: Ib1de00c6bca89c0e588dd2a5883bceb8887b3f76
This commit is contained in:
@@ -145,6 +145,7 @@ import android.hardware.display.DisplayManager.DisplayListener;
|
||||
import android.hardware.display.DisplayManagerInternal;
|
||||
import android.hardware.power.V1_0.PowerHint;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Debug;
|
||||
import android.os.FactoryTest;
|
||||
@@ -825,9 +826,13 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
|
||||
}
|
||||
|
||||
final boolean supportMultipleInstance = homeInfo.launchMode != LAUNCH_SINGLE_TASK
|
||||
&& homeInfo.launchMode != LAUNCH_SINGLE_INSTANCE;
|
||||
&& homeInfo.launchMode != LAUNCH_SINGLE_INSTANCE
|
||||
&& homeInfo.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.Q;
|
||||
if (!supportMultipleInstance) {
|
||||
// Can't launch home on other displays if it requested to be single instance.
|
||||
// Can't launch home on other displays if it requested to be single instance. Also we
|
||||
// don't allow home applications that target before Q to have multiple home activity
|
||||
// instances because they may not be expected to have multiple home scenario and
|
||||
// haven't explicitly request for single instance.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN_OR_SPLIT
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
|
||||
import static android.content.pm.ActivityInfo.FLAG_ALWAYS_FOCUSABLE;
|
||||
import static android.content.pm.ActivityInfo.LAUNCH_MULTIPLE;
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
|
||||
import static com.android.server.wm.ActivityDisplay.POSITION_TOP;
|
||||
@@ -57,6 +58,7 @@ import android.app.WaitResult;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
|
||||
import androidx.test.filters.MediumTest;
|
||||
@@ -433,6 +435,26 @@ public class ActivityStackSupervisorTests extends ActivityTestsBase {
|
||||
eq(activity), eq(null /* targetOptions */));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests home activities that targeted sdk before Q cannot start on secondary display.
|
||||
*/
|
||||
@Test
|
||||
public void testStartHomeTargetSdkBeforeQ() throws Exception {
|
||||
final TestActivityDisplay secondDisplay = spy(createNewActivityDisplay());
|
||||
mSupervisor.addChild(secondDisplay, POSITION_TOP);
|
||||
doReturn(true).when(secondDisplay).supportsSystemDecorations();
|
||||
|
||||
final ActivityInfo info = new ActivityInfo();
|
||||
info.launchMode = LAUNCH_MULTIPLE;
|
||||
info.applicationInfo = new ApplicationInfo();
|
||||
info.applicationInfo.targetSdkVersion = Build.VERSION_CODES.Q;
|
||||
assertTrue(mSupervisor.canStartHomeOnDisplay(info, secondDisplay.mDisplayId,
|
||||
false /* allowInstrumenting */));
|
||||
|
||||
info.applicationInfo.targetSdkVersion = Build.VERSION_CODES.P;
|
||||
assertFalse(mSupervisor.canStartHomeOnDisplay(info, secondDisplay.mDisplayId,
|
||||
false /* allowInstrumenting */));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that home activities can be started on the displays that supports system decorations.
|
||||
|
||||
Reference in New Issue
Block a user