@@ -174,44 +174,6 @@ private void setUpDisplaySizeWithApp(int dw, int dh) {
174174 setUpApp (builder .build ());
175175 }
176176
177- @ Test
178- public void testActivityInHistoryAndNotVisibleIsNotUsedAsOpaqueForTranslucentActivities () {
179- mWm .mLetterboxConfiguration .setTranslucentLetterboxingOverrideEnabled (true );
180- setUpDisplaySizeWithApp (2000 , 1000 );
181- prepareUnresizable (mActivity , SCREEN_ORIENTATION_PORTRAIT );
182- mActivity .mDisplayContent .setIgnoreOrientationRequest (true /* ignoreOrientationRequest */ );
183- mActivity .nowVisible = false ;
184- // Translucent Activity
185- final ActivityRecord translucentActivity = new ActivityBuilder (mAtm )
186- .setLaunchedFromUid (mActivity .getUid ())
187- .setScreenOrientation (SCREEN_ORIENTATION_PORTRAIT )
188- .build ();
189- doReturn (false ).when (translucentActivity ).fillsParent ();
190-
191- mTask .addChild (translucentActivity );
192-
193- assertFalse (translucentActivity .mLetterboxUiController .hasInheritedLetterboxBehavior ());
194- }
195-
196- @ Test
197- public void testActivityInHistoryAndVisibleIsUsedAsOpaqueForTranslucentActivities () {
198- mWm .mLetterboxConfiguration .setTranslucentLetterboxingOverrideEnabled (true );
199- setUpDisplaySizeWithApp (2000 , 1000 );
200- prepareUnresizable (mActivity , SCREEN_ORIENTATION_PORTRAIT );
201- mActivity .mDisplayContent .setIgnoreOrientationRequest (true /* ignoreOrientationRequest */ );
202- mActivity .nowVisible = true ;
203- // Translucent Activity
204- final ActivityRecord translucentActivity = new ActivityBuilder (mAtm )
205- .setLaunchedFromUid (mActivity .getUid ())
206- .setScreenOrientation (SCREEN_ORIENTATION_PORTRAIT )
207- .build ();
208- doReturn (false ).when (translucentActivity ).fillsParent ();
209-
210- mTask .addChild (translucentActivity );
211-
212- assertTrue (translucentActivity .mLetterboxUiController .hasInheritedLetterboxBehavior ());
213- }
214-
215177 @ Test
216178 public void testCleanLetterboxConfigListenerWhenTranslucentIsDestroyed () {
217179 mWm .mLetterboxConfiguration .setTranslucentLetterboxingOverrideEnabled (true );
@@ -236,7 +198,6 @@ public void testCleanLetterboxConfigListenerWhenTranslucentIsDestroyed() {
236198 public void testHorizontalReachabilityEnabledForTranslucentActivities () {
237199 setUpDisplaySizeWithApp (2500 , 1000 );
238200 mActivity .mDisplayContent .setIgnoreOrientationRequest (true /* ignoreOrientationRequest */ );
239- mActivity .nowVisible = true ;
240201 final LetterboxConfiguration config = mWm .mLetterboxConfiguration ;
241202 config .setTranslucentLetterboxingOverrideEnabled (true );
242203 config .setLetterboxHorizontalPositionMultiplier (0.5f );
@@ -312,7 +273,6 @@ public void testHorizontalReachabilityEnabledForTranslucentActivities() {
312273 public void testVerticalReachabilityEnabledForTranslucentActivities () {
313274 setUpDisplaySizeWithApp (1000 , 2500 );
314275 mActivity .mDisplayContent .setIgnoreOrientationRequest (true /* ignoreOrientationRequest */ );
315- mActivity .nowVisible = true ;
316276 final LetterboxConfiguration config = mWm .mLetterboxConfiguration ;
317277 config .setTranslucentLetterboxingOverrideEnabled (true );
318278 config .setLetterboxVerticalPositionMultiplier (0.5f );
@@ -384,14 +344,111 @@ public void testVerticalReachabilityEnabledForTranslucentActivities() {
384344 checkIsCentered .run ();
385345 }
386346
347+ @ Test
348+ public void testApplyStrategyAgainWhenOpaqueIsDestroyed () {
349+ mWm .mLetterboxConfiguration .setTranslucentLetterboxingOverrideEnabled (true );
350+ setUpDisplaySizeWithApp (2000 , 1000 );
351+ prepareUnresizable (mActivity , SCREEN_ORIENTATION_PORTRAIT );
352+ mActivity .mDisplayContent .setIgnoreOrientationRequest (true /* ignoreOrientationRequest */ );
353+ // Launch another opaque activity
354+ final ActivityRecord opaqueActivity = new ActivityBuilder (mAtm )
355+ .setLaunchedFromUid (mActivity .getUid ())
356+ .setScreenOrientation (SCREEN_ORIENTATION_PORTRAIT )
357+ .build ();
358+ mTask .addChild (opaqueActivity );
359+ // Transparent activity strategy not applied
360+ assertFalse (opaqueActivity .mLetterboxUiController .hasInheritedLetterboxBehavior ());
361+
362+ // Launch translucent Activity
363+ final ActivityRecord translucentActivity = new ActivityBuilder (mAtm )
364+ .setLaunchedFromUid (mActivity .getUid ())
365+ .setScreenOrientation (SCREEN_ORIENTATION_PORTRAIT )
366+ .build ();
367+ doReturn (false ).when (translucentActivity ).fillsParent ();
368+ mTask .addChild (translucentActivity );
369+ // Transparent strategy applied
370+ assertTrue (translucentActivity .mLetterboxUiController .hasInheritedLetterboxBehavior ());
371+
372+ spyOn (translucentActivity .mLetterboxUiController );
373+ clearInvocations (translucentActivity .mLetterboxUiController );
374+
375+ // We destroy the first opaque activity
376+ opaqueActivity .setState (DESTROYED , "testing" );
377+ opaqueActivity .removeImmediately ();
378+
379+ // Check that updateInheritedLetterbox() is invoked again
380+ verify (translucentActivity .mLetterboxUiController ).updateInheritedLetterbox ();
381+ }
382+
383+ @ Test
384+ public void testResetOpaqueReferenceWhenOpaqueIsDestroyed () {
385+ mWm .mLetterboxConfiguration .setTranslucentLetterboxingOverrideEnabled (true );
386+ setUpDisplaySizeWithApp (2000 , 1000 );
387+ prepareUnresizable (mActivity , SCREEN_ORIENTATION_PORTRAIT );
388+ mActivity .mDisplayContent .setIgnoreOrientationRequest (true /* ignoreOrientationRequest */ );
389+
390+ // Launch translucent Activity
391+ final ActivityRecord translucentActivity = new ActivityBuilder (mAtm )
392+ .setLaunchedFromUid (mActivity .getUid ())
393+ .setScreenOrientation (SCREEN_ORIENTATION_PORTRAIT )
394+ .build ();
395+ doReturn (false ).when (translucentActivity ).fillsParent ();
396+ mTask .addChild (translucentActivity );
397+ // Transparent strategy applied
398+ assertTrue (translucentActivity .mLetterboxUiController .hasInheritedLetterboxBehavior ());
399+ assertNotNull (translucentActivity .mLetterboxUiController .mFirstOpaqueActivityBeneath );
400+
401+ spyOn (translucentActivity .mLetterboxUiController );
402+ clearInvocations (translucentActivity .mLetterboxUiController );
403+
404+ // We destroy the first opaque activity
405+ mActivity .setState (DESTROYED , "testing" );
406+ mActivity .removeImmediately ();
407+
408+ // Check that updateInheritedLetterbox() is invoked again
409+ verify (translucentActivity .mLetterboxUiController ).updateInheritedLetterbox ();
410+ assertNull (translucentActivity .mLetterboxUiController .mFirstOpaqueActivityBeneath );
411+ }
412+
413+ @ Test
414+ public void testNotApplyStrategyAgainWhenOpaqueIsNotDestroyed () {
415+ mWm .mLetterboxConfiguration .setTranslucentLetterboxingOverrideEnabled (true );
416+ setUpDisplaySizeWithApp (2000 , 1000 );
417+ prepareUnresizable (mActivity , SCREEN_ORIENTATION_PORTRAIT );
418+ mActivity .mDisplayContent .setIgnoreOrientationRequest (true /* ignoreOrientationRequest */ );
419+ // Launch another opaque activity
420+ final ActivityRecord opaqueActivity = new ActivityBuilder (mAtm )
421+ .setLaunchedFromUid (mActivity .getUid ())
422+ .setScreenOrientation (SCREEN_ORIENTATION_PORTRAIT )
423+ .build ();
424+ mTask .addChild (opaqueActivity );
425+ // Transparent activity strategy not applied
426+ assertFalse (opaqueActivity .mLetterboxUiController .hasInheritedLetterboxBehavior ());
427+
428+ // Launch translucent Activity
429+ final ActivityRecord translucentActivity = new ActivityBuilder (mAtm )
430+ .setLaunchedFromUid (mActivity .getUid ())
431+ .setScreenOrientation (SCREEN_ORIENTATION_PORTRAIT )
432+ .build ();
433+ doReturn (false ).when (translucentActivity ).fillsParent ();
434+ mTask .addChild (translucentActivity );
435+ // Transparent strategy applied
436+ assertTrue (translucentActivity .mLetterboxUiController .hasInheritedLetterboxBehavior ());
437+
438+ spyOn (translucentActivity .mLetterboxUiController );
439+ clearInvocations (translucentActivity .mLetterboxUiController );
440+
441+ // Check that updateInheritedLetterbox() is invoked again
442+ verify (translucentActivity .mLetterboxUiController , never ()).updateInheritedLetterbox ();
443+ }
444+
387445 @ Test
388446 public void testApplyStrategyToTranslucentActivities () {
389447 mWm .mLetterboxConfiguration .setTranslucentLetterboxingOverrideEnabled (true );
390448 setUpDisplaySizeWithApp (2000 , 1000 );
391449 prepareUnresizable (mActivity , 1.5f /* maxAspect */ , SCREEN_ORIENTATION_PORTRAIT );
392450 mActivity .info .setMinAspectRatio (1.2f );
393451 mActivity .mDisplayContent .setIgnoreOrientationRequest (true /* ignoreOrientationRequest */ );
394- mActivity .nowVisible = true ;
395452 // Translucent Activity
396453 final ActivityRecord translucentActivity = new ActivityBuilder (mAtm )
397454 .setLaunchedFromUid (mActivity .getUid ())
@@ -448,7 +505,6 @@ public void testApplyStrategyToMultipleTranslucentActivities() {
448505 prepareUnresizable (mActivity , 1.5f /* maxAspect */ , SCREEN_ORIENTATION_PORTRAIT );
449506 mActivity .info .setMinAspectRatio (1.2f );
450507 mActivity .mDisplayContent .setIgnoreOrientationRequest (true /* ignoreOrientationRequest */ );
451- mActivity .nowVisible = true ;
452508 // Translucent Activity
453509 final ActivityRecord translucentActivity = new ActivityBuilder (mAtm )
454510 .setLaunchedFromUid (mActivity .getUid ())
@@ -542,7 +598,6 @@ public void testTranslucentActivitiesWhenUnfolding() {
542598 true /* ignoreOrientationRequest */ );
543599 mActivity .mWmService .mLetterboxConfiguration .setLetterboxHorizontalPositionMultiplier (
544600 1.0f /*letterboxVerticalPositionMultiplier*/ );
545- mActivity .nowVisible = true ;
546601 prepareUnresizable (mActivity , SCREEN_ORIENTATION_PORTRAIT );
547602 // We launch a transparent activity
548603 final ActivityRecord translucentActivity = new ActivityBuilder (mAtm )
@@ -575,7 +630,6 @@ public void testTranslucentActivity_clearSizeCompatMode_inheritedCompatDisplayIn
575630 mWm .mLetterboxConfiguration .setTranslucentLetterboxingOverrideEnabled (true );
576631 setUpDisplaySizeWithApp (2800 , 1400 );
577632 mActivity .mDisplayContent .setIgnoreOrientationRequest (true /* ignoreOrientationRequest */ );
578- mActivity .nowVisible = true ;
579633 prepareUnresizable (mActivity , -1f /* maxAspect */ , SCREEN_ORIENTATION_PORTRAIT );
580634 // Rotate to put activity in size compat mode.
581635 rotateDisplay (mActivity .mDisplayContent , ROTATION_90 );
0 commit comments