Merge "Avoid starting home that targeted before Q on secondary display"

This commit is contained in:
TreeHugger Robot
2018-11-15 02:47:57 +00:00
committed by Android (Google) Code Review
2 changed files with 29 additions and 2 deletions

View File

@@ -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;
@@ -835,9 +836,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;
}

View File

@@ -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.