4/ Delete flicker test apps from WMShell package

Test: atest FlickerLibTest && atest FlickerTests
Change-Id: I4a71fedb8190c82abd5649b3d99c9c6cf0cb934e
This commit is contained in:
Nataniel Borges
2022-09-20 15:48:15 +00:00
parent 816c9464ec
commit ec667f9fc4
28 changed files with 0 additions and 1716 deletions

View File

@@ -1,35 +0,0 @@
// Copyright (C) 2020 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package {
// See: http://go/android-license-faq
// A large-scale-change added 'default_applicable_licenses' to import
// all of the 'license_kinds' from "frameworks_base_license"
// to get the below license kinds:
// SPDX-license-identifier-Apache-2.0
default_applicable_licenses: ["frameworks_base_license"],
}
android_test {
name: "WMShellFlickerTestApp",
srcs: ["**/*.java"],
sdk_version: "current",
test_suites: ["device-tests"],
}
java_library {
name: "wmshell-flicker-test-components",
srcs: ["src/**/Components.java"],
sdk_version: "test_current",
}

View File

@@ -1,147 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2020 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.wm.shell.flicker.testapp">
<uses-sdk android:minSdkVersion="29"
android:targetSdkVersion="29"/>
<application android:allowBackup="false"
android:supportsRtl="true">
<activity android:name=".FixedActivity"
android:resizeableActivity="true"
android:supportsPictureInPicture="true"
android:launchMode="singleTop"
android:theme="@style/CutoutShortEdges"
android:label="FixedApp"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".PipActivity"
android:resizeableActivity="true"
android:supportsPictureInPicture="true"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:taskAffinity="com.android.wm.shell.flicker.testapp.PipActivity"
android:theme="@style/CutoutShortEdges"
android:launchMode="singleTop"
android:label="PipApp"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".ImeActivity"
android:taskAffinity="com.android.wm.shell.flicker.testapp.ImeActivity"
android:theme="@style/CutoutShortEdges"
android:label="ImeApp"
android:launchMode="singleTop"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".SplitScreenActivity"
android:resizeableActivity="true"
android:taskAffinity="com.android.wm.shell.flicker.testapp.SplitScreenActivity"
android:theme="@style/CutoutShortEdges"
android:label="SplitScreenPrimaryApp"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".SplitScreenSecondaryActivity"
android:resizeableActivity="true"
android:taskAffinity="com.android.wm.shell.flicker.testapp.SplitScreenSecondaryActivity"
android:theme="@style/CutoutShortEdges"
android:label="SplitScreenSecondaryApp"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".SendNotificationActivity"
android:taskAffinity="com.android.wm.shell.flicker.testapp.SendNotificationActivity"
android:theme="@style/CutoutShortEdges"
android:label="SendNotificationApp"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".NonResizeableActivity"
android:resizeableActivity="false"
android:taskAffinity="com.android.wm.shell.flicker.testapp.NonResizeableActivity"
android:theme="@style/CutoutShortEdges"
android:label="NonResizeableApp"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".SimpleActivity"
android:taskAffinity="com.android.wm.shell.flicker.testapp.SimpleActivity"
android:theme="@style/CutoutShortEdges"
android:label="SimpleApp"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".LaunchBubbleActivity"
android:label="LaunchBubbleApp"
android:exported="true"
android:theme="@style/CutoutShortEdges"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".BubbleActivity"
android:label="BubbleApp"
android:exported="false"
android:theme="@style/CutoutShortEdges"
android:resizeableActivity="true" />
</application>
</manifest>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M7.2,14.4m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0"/>
<path
android:fillColor="#FF000000"
android:pathData="M14.8,18m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0"/>
<path
android:fillColor="#FF000000"
android:pathData="M15.2,8.8m-4.8,0a4.8,4.8 0,1 1,9.6 0a4.8,4.8 0,1 1,-9.6 0"/>
</vector>

View File

@@ -1,26 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M12,4c-4.97,0 -9,3.58 -9,8c0,1.53 0.49,2.97 1.33,4.18c0.12,0.18 0.2,0.46 0.1,0.66c-0.33,0.68 -0.79,1.52 -1.38,2.39c-0.12,0.17 0.01,0.41 0.21,0.39c0.63,-0.05 1.86,-0.26 3.38,-0.91c0.17,-0.07 0.36,-0.06 0.52,0.03C8.55,19.54 10.21,20 12,20c4.97,0 9,-3.58 9,-8S16.97,4 12,4zM16.94,11.63l-3.29,3.29c-0.13,0.13 -0.34,0.04 -0.34,-0.14v-1.57c0,-0.11 -0.1,-0.21 -0.21,-0.2c-2.19,0.06 -3.65,0.65 -5.14,1.95c-0.15,0.13 -0.38,0 -0.33,-0.19c0.7,-2.57 2.9,-4.57 5.5,-4.75c0.1,-0.01 0.18,-0.09 0.18,-0.19V8.2c0,-0.18 0.22,-0.27 0.34,-0.14l3.29,3.29C17.02,11.43 17.02,11.55 16.94,11.63z"
android:fillColor="#000000"
android:fillType="evenOdd"/>
</vector>

View File

@@ -1,48 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button_finish"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_marginStart="8dp"
android:text="Finish" />
<Button
android:id="@+id/button_new_task"
android:layout_width="wrap_content"
android:layout_height="46dp"
android:layout_marginStart="8dp"
android:text="New Task" />
<Button
android:id="@+id/button_new_bubble"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:text="New Bubble" />
<Button
android:id="@+id/button_activity_for_result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:text="Activity For Result" />
</LinearLayout>

View File

@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true"
android:background="@android:color/holo_green_light">
<EditText android:id="@+id/plain_text_input"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:inputType="text"/>
</LinearLayout>

View File

@@ -1,48 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@android:color/black">
<Button
android:id="@+id/button_create"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Add Bubble" />
<Button
android:id="@+id/button_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button_create"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="Cancel Bubble" />
<Button
android:id="@+id/button_cancel_all"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button_cancel"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="Cancel All Bubble" />
</RelativeLayout>

View File

@@ -1,32 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2020 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@android:color/holo_orange_light">
<TextView
android:id="@+id/NonResizeableTest"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:text="NonResizeableActivity"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</LinearLayout>

View File

@@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@android:color/black">
<Button
android:id="@+id/button_send_notification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Send Notification" />
</RelativeLayout>

View File

@@ -1,141 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2020 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@android:color/holo_blue_bright">
<!-- All the buttons (and other clickable elements) should be arranged in a way so that it is
possible to "cycle" over all them by clicking on the D-Pad DOWN button. The way we do it
here is by arranging them this vertical LL and by relying on the nextFocusDown attribute
where things are arranged differently and to circle back up to the top once we reach the
bottom. -->
<Button
android:id="@+id/enter_pip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter PIP"
android:onClick="enterPip"/>
<CheckBox
android:id="@+id/with_custom_actions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="With custom actions"/>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:checkedButton="@id/enter_pip_on_leave_disabled">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter PiP on home press"/>
<RadioButton
android:id="@+id/enter_pip_on_leave_disabled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Disabled"
android:onClick="onAutoPipSelected"/>
<RadioButton
android:id="@+id/enter_pip_on_leave_manual"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Via code behind"
android:onClick="onAutoPipSelected"/>
<RadioButton
android:id="@+id/enter_pip_on_leave_autoenter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Auto-enter PiP"
android:onClick="onAutoPipSelected"/>
</RadioGroup>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:checkedButton="@id/ratio_default">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ratio"/>
<RadioButton
android:id="@+id/ratio_default"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Default"
android:onClick="onRatioSelected"/>
<RadioButton
android:id="@+id/ratio_square"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Square [1:1]"
android:onClick="onRatioSelected"/>
<RadioButton
android:id="@+id/ratio_wide"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Wide [2:1]"
android:onClick="onRatioSelected"/>
<RadioButton
android:id="@+id/ratio_tall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tall [1:2]"
android:onClick="onRatioSelected"/>
</RadioGroup>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Media Session"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/media_session_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:nextFocusDown="@id/media_session_stop"
android:text="Start"/>
<Button
android:id="@+id/media_session_stop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:nextFocusDown="@id/enter_pip"
android:text="Stop"/>
</LinearLayout>
</LinearLayout>

View File

@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_orange_light">
</LinearLayout>

View File

@@ -1,33 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2020 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@android:color/holo_green_light">
<TextView
android:id="@+id/SplitScreenTest"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:textIsSelectable="true"
android:text="PrimaryActivity"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</LinearLayout>

View File

@@ -1,32 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2020 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@android:color/holo_blue_light">
<TextView
android:id="@+id/SplitScreenTest"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:text="SecondaryActivity"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</LinearLayout>

View File

@@ -1,34 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<resources>
<style name="DefaultTheme" parent="@android:style/Theme.DeviceDefault">
<item name="android:windowBackground">@android:color/darker_gray</item>
</style>
<style name="CutoutDefault" parent="@style/DefaultTheme">
<item name="android:windowLayoutInDisplayCutoutMode">default</item>
</style>
<style name="CutoutShortEdges" parent="@style/DefaultTheme">
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style>
<style name="CutoutNever" parent="@style/DefaultTheme">
<item name="android:windowLayoutInDisplayCutoutMode">never</item>
</style>
</resources>

View File

@@ -1,77 +0,0 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.wm.shell.flicker.testapp;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
public class BubbleActivity extends Activity {
private int mNotifId = 0;
public BubbleActivity() {
super();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
if (intent != null) {
mNotifId = intent.getIntExtra(BubbleHelper.EXTRA_BUBBLE_NOTIF_ID, -1);
} else {
mNotifId = -1;
}
setContentView(R.layout.activity_bubble);
}
@Override
protected void onStart() {
super.onStart();
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onPause() {
super.onPause();
}
@Override
protected void onStop() {
super.onStop();
}
@Override
protected void onDestroy() {
super.onDestroy();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
String result = resultCode == Activity.RESULT_OK ? "OK" : "CANCELLED";
Toast.makeText(this, "Activity result: " + result, Toast.LENGTH_SHORT).show();
}
}

View File

@@ -1,173 +0,0 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.wm.shell.flicker.testapp;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Person;
import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
import android.graphics.drawable.Icon;
import android.os.SystemClock;
import android.service.notification.StatusBarNotification;
import android.view.WindowManager;
import java.util.HashMap;
public class BubbleHelper {
static final String EXTRA_BUBBLE_NOTIF_ID = "EXTRA_BUBBLE_NOTIF_ID";
static final String CHANNEL_ID = "bubbles";
static final String CHANNEL_NAME = "Bubbles";
static final int DEFAULT_HEIGHT_DP = 300;
private static BubbleHelper sInstance;
private final Context mContext;
private NotificationManager mNotificationManager;
private float mDisplayHeight;
private HashMap<Integer, BubbleInfo> mBubbleMap = new HashMap<>();
private int mNextNotifyId = 0;
private int mColourIndex = 0;
public static class BubbleInfo {
public int id;
public int height;
public Icon icon;
public BubbleInfo(int id, int height, Icon icon) {
this.id = id;
this.height = height;
this.icon = icon;
}
}
public static BubbleHelper getInstance(Context context) {
if (sInstance == null) {
sInstance = new BubbleHelper(context);
}
return sInstance;
}
private BubbleHelper(Context context) {
mContext = context;
mNotificationManager = context.getSystemService(NotificationManager.class);
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME,
NotificationManager.IMPORTANCE_DEFAULT);
channel.setDescription("Channel that posts bubbles");
channel.setAllowBubbles(true);
mNotificationManager.createNotificationChannel(channel);
Point p = new Point();
WindowManager wm = context.getSystemService(WindowManager.class);
wm.getDefaultDisplay().getRealSize(p);
mDisplayHeight = p.y;
}
private int getNextNotifyId() {
int id = mNextNotifyId;
mNextNotifyId++;
return id;
}
private Icon getIcon() {
return Icon.createWithResource(mContext, R.drawable.bg);
}
public int addNewBubble(boolean autoExpand, boolean suppressNotif) {
int id = getNextNotifyId();
BubbleInfo info = new BubbleInfo(id, DEFAULT_HEIGHT_DP, getIcon());
mBubbleMap.put(info.id, info);
Notification.BubbleMetadata data = getBubbleBuilder(info)
.setSuppressNotification(suppressNotif)
.setAutoExpandBubble(false)
.build();
Notification notification = getNotificationBuilder(info.id)
.setBubbleMetadata(data).build();
mNotificationManager.notify(info.id, notification);
return info.id;
}
private Notification.Builder getNotificationBuilder(int id) {
Person chatBot = new Person.Builder()
.setBot(true)
.setName("BubbleChat")
.setImportant(true)
.build();
String shortcutId = "BubbleChat";
return new Notification.Builder(mContext, CHANNEL_ID)
.setChannelId(CHANNEL_ID)
.setShortcutId(shortcutId)
.setContentTitle("BubbleChat")
.setContentIntent(PendingIntent.getActivity(mContext, 0,
new Intent(mContext, LaunchBubbleActivity.class),
PendingIntent.FLAG_UPDATE_CURRENT))
.setStyle(new Notification.MessagingStyle(chatBot)
.setConversationTitle("BubbleChat")
.addMessage("BubbleChat",
SystemClock.currentThreadTimeMillis() - 300000, chatBot)
.addMessage("Is it me, " + id + ", you're looking for?",
SystemClock.currentThreadTimeMillis(), chatBot)
)
.setSmallIcon(R.drawable.ic_bubble);
}
private Notification.BubbleMetadata.Builder getBubbleBuilder(BubbleInfo info) {
Intent target = new Intent(mContext, BubbleActivity.class);
target.putExtra(EXTRA_BUBBLE_NOTIF_ID, info.id);
PendingIntent bubbleIntent = PendingIntent.getActivity(mContext, info.id, target,
PendingIntent.FLAG_UPDATE_CURRENT);
return new Notification.BubbleMetadata.Builder()
.setIntent(bubbleIntent)
.setIcon(info.icon)
.setDesiredHeight(info.height);
}
public void cancel(int id) {
mNotificationManager.cancel(id);
}
public void cancelAll() {
mNotificationManager.cancelAll();
}
public void cancelLast() {
StatusBarNotification[] activeNotifications = mNotificationManager.getActiveNotifications();
if (activeNotifications.length > 0) {
mNotificationManager.cancel(
activeNotifications[activeNotifications.length - 1].getId());
}
}
public void cancelFirst() {
StatusBarNotification[] activeNotifications = mNotificationManager.getActiveNotifications();
if (activeNotifications.length > 0) {
mNotificationManager.cancel(activeNotifications[0].getId());
}
}
}

View File

@@ -1,108 +0,0 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.wm.shell.flicker.testapp;
import android.content.ComponentName;
public class Components {
public static final String PACKAGE_NAME = "com.android.wm.shell.flicker.testapp";
public static class SimpleActivity {
public static final String LABEL = "SimpleApp";
public static final ComponentName COMPONENT = new ComponentName(PACKAGE_NAME,
PACKAGE_NAME + ".SimpleActivity");
}
public static class FixedActivity {
public static final String EXTRA_FIXED_ORIENTATION = "fixed_orientation";
public static final String LABEL = "FixedApp";
public static final ComponentName COMPONENT = new ComponentName(PACKAGE_NAME,
PACKAGE_NAME + ".FixedActivity");
}
public static class NonResizeableActivity {
public static final String LABEL = "NonResizeableApp";
public static final ComponentName COMPONENT = new ComponentName(PACKAGE_NAME,
PACKAGE_NAME + ".NonResizeableActivity");
}
public static class PipActivity {
// Test App > Pip Activity
public static final String LABEL = "PipApp";
public static final String MENU_ACTION_NO_OP = "No-Op";
public static final String MENU_ACTION_ON = "On";
public static final String MENU_ACTION_OFF = "Off";
public static final String MENU_ACTION_CLEAR = "Clear";
// Intent action that this activity dynamically registers to enter picture-in-picture
public static final String ACTION_ENTER_PIP = PACKAGE_NAME + ".PipActivity.ENTER_PIP";
// Intent action that this activity dynamically registers to set requested orientation.
// Will apply the oriention to the value set in the EXTRA_FIXED_ORIENTATION extra.
public static final String ACTION_SET_REQUESTED_ORIENTATION =
PACKAGE_NAME + ".PipActivity.SET_REQUESTED_ORIENTATION";
// Calls enterPictureInPicture() on creation
public static final String EXTRA_ENTER_PIP = "enter_pip";
// Sets the fixed orientation (can be one of {@link ActivityInfo.ScreenOrientation}
public static final String EXTRA_PIP_ORIENTATION = "fixed_orientation";
// Adds a click listener to finish this activity when it is clicked
public static final String EXTRA_TAP_TO_FINISH = "tap_to_finish";
public static final ComponentName COMPONENT = new ComponentName(PACKAGE_NAME,
PACKAGE_NAME + ".PipActivity");
}
public static class ImeActivity {
public static final String LABEL = "ImeApp";
public static final String ACTION_CLOSE_IME =
PACKAGE_NAME + ".action.CLOSE_IME";
public static final String ACTION_OPEN_IME =
PACKAGE_NAME + ".action.OPEN_IME";
public static final ComponentName COMPONENT = new ComponentName(PACKAGE_NAME,
PACKAGE_NAME + ".ImeActivity");
}
public static class SplitScreenActivity {
public static final String LABEL = "SplitScreenPrimaryApp";
public static final ComponentName COMPONENT = new ComponentName(PACKAGE_NAME,
PACKAGE_NAME + ".SplitScreenActivity");
}
public static class SplitScreenSecondaryActivity {
public static final String LABEL = "SplitScreenSecondaryApp";
public static final ComponentName COMPONENT = new ComponentName(PACKAGE_NAME,
PACKAGE_NAME + ".SplitScreenSecondaryActivity");
}
public static class SendNotificationActivity {
public static final String LABEL = "SendNotificationApp";
public static final ComponentName COMPONENT = new ComponentName(PACKAGE_NAME,
PACKAGE_NAME + ".SendNotificationActivity");
}
public static class LaunchBubbleActivity {
public static final String LABEL = "LaunchBubbleApp";
public static final ComponentName COMPONENT = new ComponentName(PACKAGE_NAME,
PACKAGE_NAME + ".LaunchBubbleActivity");
}
public static class BubbleActivity {
public static final String LABEL = "BubbleApp";
public static final ComponentName COMPONENT = new ComponentName(PACKAGE_NAME,
PACKAGE_NAME + ".BubbleActivity");
}
}

View File

@@ -1,35 +0,0 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.wm.shell.flicker.testapp;
import static com.android.wm.shell.flicker.testapp.Components.FixedActivity.EXTRA_FIXED_ORIENTATION;
import android.os.Bundle;
public class FixedActivity extends SimpleActivity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
// Set the fixed orientation if requested
if (getIntent().hasExtra(EXTRA_FIXED_ORIENTATION)) {
final int ori = Integer.parseInt(getIntent().getStringExtra(EXTRA_FIXED_ORIENTATION));
setRequestedOrientation(ori);
}
}
}

View File

@@ -1,66 +0,0 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.wm.shell.flicker.testapp;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
public class ImeActivity extends Activity {
private static final String ACTION_OPEN_IME =
"com.android.wm.shell.flicker.testapp.action.OPEN_IME";
private static final String ACTION_CLOSE_IME =
"com.android.wm.shell.flicker.testapp.action.CLOSE_IME";
private InputMethodManager mImm;
private View mEditText;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WindowManager.LayoutParams p = getWindow().getAttributes();
p.layoutInDisplayCutoutMode = WindowManager.LayoutParams
.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
getWindow().setAttributes(p);
setContentView(R.layout.activity_ime);
mEditText = findViewById(R.id.plain_text_input);
mImm = getSystemService(InputMethodManager.class);
handleIntent(getIntent());
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
handleIntent(intent);
}
private void handleIntent(Intent intent) {
final String action = intent.getAction();
if (ACTION_OPEN_IME.equals(action)) {
mEditText.requestFocus();
mImm.showSoftInput(mEditText, InputMethodManager.SHOW_FORCED);
} else if (ACTION_CLOSE_IME.equals(action)) {
mImm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
mEditText.clearFocus();
}
}
}

View File

@@ -1,82 +0,0 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.wm.shell.flicker.testapp;
import android.app.Activity;
import android.app.Person;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager;
import android.graphics.drawable.Icon;
import android.os.Bundle;
import android.view.View;
import java.util.Arrays;
public class LaunchBubbleActivity extends Activity {
private BubbleHelper mBubbleHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addInboxShortcut(getApplicationContext());
mBubbleHelper = BubbleHelper.getInstance(this);
setContentView(R.layout.activity_main);
findViewById(R.id.button_create).setOnClickListener(this::add);
findViewById(R.id.button_cancel).setOnClickListener(this::cancel);
findViewById(R.id.button_cancel_all).setOnClickListener(this::cancelAll);
}
private void add(View v) {
mBubbleHelper.addNewBubble(false /* autoExpand */, false /* suppressNotif */);
}
private void cancel(View v) {
mBubbleHelper.cancelLast();
}
private void cancelAll(View v) {
mBubbleHelper.cancelAll();
}
private void addInboxShortcut(Context context) {
Icon icon = Icon.createWithResource(this, R.drawable.bg);
Person[] persons = new Person[4];
for (int i = 0; i < persons.length; i++) {
persons[i] = new Person.Builder()
.setBot(false)
.setIcon(icon)
.setName("google" + i)
.setImportant(true)
.build();
}
ShortcutInfo shortcut = new ShortcutInfo.Builder(context, "BubbleChat")
.setShortLabel("BubbleChat")
.setLongLived(true)
.setIntent(new Intent(Intent.ACTION_VIEW))
.setIcon(Icon.createWithResource(context, R.drawable.ic_message))
.setPersons(persons)
.build();
ShortcutManager scmanager = context.getSystemService(ShortcutManager.class);
scmanager.addDynamicShortcuts(Arrays.asList(shortcut));
}
}

View File

@@ -1,29 +0,0 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.wm.shell.flicker.testapp;
import android.app.Activity;
import android.os.Bundle;
public class NonResizeableActivity extends Activity {
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_non_resizeable);
}
}

View File

@@ -1,308 +0,0 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.wm.shell.flicker.testapp;
import static android.media.MediaMetadata.METADATA_KEY_TITLE;
import static android.media.session.PlaybackState.ACTION_PAUSE;
import static android.media.session.PlaybackState.ACTION_PLAY;
import static android.media.session.PlaybackState.ACTION_STOP;
import static android.media.session.PlaybackState.STATE_PAUSED;
import static android.media.session.PlaybackState.STATE_PLAYING;
import static android.media.session.PlaybackState.STATE_STOPPED;
import static com.android.wm.shell.flicker.testapp.Components.PipActivity.ACTION_ENTER_PIP;
import static com.android.wm.shell.flicker.testapp.Components.PipActivity.ACTION_SET_REQUESTED_ORIENTATION;
import static com.android.wm.shell.flicker.testapp.Components.PipActivity.EXTRA_ENTER_PIP;
import static com.android.wm.shell.flicker.testapp.Components.PipActivity.EXTRA_PIP_ORIENTATION;
import android.app.Activity;
import android.app.PendingIntent;
import android.app.PictureInPictureParams;
import android.app.RemoteAction;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.drawable.Icon;
import android.media.MediaMetadata;
import android.media.session.MediaSession;
import android.media.session.PlaybackState;
import android.os.Bundle;
import android.util.Log;
import android.util.Rational;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.RadioButton;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class PipActivity extends Activity {
private static final String TAG = PipActivity.class.getSimpleName();
/**
* A media session title for when the session is in {@link STATE_PLAYING}.
* TvPipNotificationTests check whether the actual notification title matches this string.
*/
private static final String TITLE_STATE_PLAYING = "TestApp media is playing";
/**
* A media session title for when the session is in {@link STATE_PAUSED}.
* TvPipNotificationTests check whether the actual notification title matches this string.
*/
private static final String TITLE_STATE_PAUSED = "TestApp media is paused";
private static final Rational RATIO_DEFAULT = null;
private static final Rational RATIO_SQUARE = new Rational(1, 1);
private static final Rational RATIO_WIDE = new Rational(2, 1);
private static final Rational RATIO_TALL = new Rational(1, 2);
private static final String PIP_ACTION_NO_OP = "No-Op";
private static final String PIP_ACTION_OFF = "Off";
private static final String PIP_ACTION_ON = "On";
private static final String PIP_ACTION_CLEAR = "Clear";
private static final String ACTION_NO_OP = "com.android.wm.shell.flicker.testapp.NO_OP";
private static final String ACTION_SWITCH_OFF =
"com.android.wm.shell.flicker.testapp.SWITCH_OFF";
private static final String ACTION_SWITCH_ON = "com.android.wm.shell.flicker.testapp.SWITCH_ON";
private static final String ACTION_CLEAR = "com.android.wm.shell.flicker.testapp.CLEAR";
private final PictureInPictureParams.Builder mPipParamsBuilder =
new PictureInPictureParams.Builder()
.setAspectRatio(RATIO_DEFAULT);
private MediaSession mMediaSession;
private final PlaybackState.Builder mPlaybackStateBuilder = new PlaybackState.Builder()
.setActions(ACTION_PLAY | ACTION_PAUSE | ACTION_STOP)
.setState(STATE_STOPPED, 0, 1f);
private PlaybackState mPlaybackState = mPlaybackStateBuilder.build();
private final MediaMetadata.Builder mMediaMetadataBuilder = new MediaMetadata.Builder();
private final List<RemoteAction> mSwitchOffActions = new ArrayList<>();
private final List<RemoteAction> mSwitchOnActions = new ArrayList<>();
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (isInPictureInPictureMode()) {
switch (intent.getAction()) {
case ACTION_SWITCH_ON:
mPipParamsBuilder.setActions(mSwitchOnActions);
break;
case ACTION_SWITCH_OFF:
mPipParamsBuilder.setActions(mSwitchOffActions);
break;
case ACTION_CLEAR:
mPipParamsBuilder.setActions(Collections.emptyList());
break;
case ACTION_NO_OP:
return;
default:
Log.w(TAG, "Unhandled action=" + intent.getAction());
return;
}
setPictureInPictureParams(mPipParamsBuilder.build());
} else {
switch (intent.getAction()) {
case ACTION_ENTER_PIP:
enterPip(null);
break;
case ACTION_SET_REQUESTED_ORIENTATION:
setRequestedOrientation(Integer.parseInt(intent.getStringExtra(
EXTRA_PIP_ORIENTATION)));
break;
default:
Log.w(TAG, "Unhandled action=" + intent.getAction());
return;
}
}
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Window window = getWindow();
final WindowManager.LayoutParams layoutParams = window.getAttributes();
layoutParams.layoutInDisplayCutoutMode = WindowManager.LayoutParams
.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
window.setAttributes(layoutParams);
setContentView(R.layout.activity_pip);
findViewById(R.id.media_session_start)
.setOnClickListener(v -> updateMediaSessionState(STATE_PLAYING));
findViewById(R.id.media_session_stop)
.setOnClickListener(v -> updateMediaSessionState(STATE_STOPPED));
mMediaSession = new MediaSession(this, "WMShell_TestApp");
mMediaSession.setPlaybackState(mPlaybackStateBuilder.build());
mMediaSession.setCallback(new MediaSession.Callback() {
@Override
public void onPlay() {
updateMediaSessionState(STATE_PLAYING);
}
@Override
public void onPause() {
updateMediaSessionState(STATE_PAUSED);
}
@Override
public void onStop() {
updateMediaSessionState(STATE_STOPPED);
}
});
// Build two sets of the custom actions. We'll replace one with the other when 'On'/'Off'
// action is invoked.
// The first set consists of 3 actions: 1) Off; 2) No-Op; 3) Clear.
// The second set consists of 2 actions: 1) On; 2) Clear.
// Upon invocation 'Clear' action clear-off all the custom actions, including itself.
final Icon icon = Icon.createWithResource(this, android.R.drawable.ic_menu_help);
final RemoteAction noOpAction = buildRemoteAction(icon, PIP_ACTION_NO_OP, ACTION_NO_OP);
final RemoteAction switchOnAction =
buildRemoteAction(icon, PIP_ACTION_ON, ACTION_SWITCH_ON);
final RemoteAction switchOffAction =
buildRemoteAction(icon, PIP_ACTION_OFF, ACTION_SWITCH_OFF);
final RemoteAction clearAllAction = buildRemoteAction(icon, PIP_ACTION_CLEAR, ACTION_CLEAR);
mSwitchOffActions.addAll(Arrays.asList(switchOnAction, clearAllAction));
mSwitchOnActions.addAll(Arrays.asList(noOpAction, switchOffAction, clearAllAction));
final IntentFilter filter = new IntentFilter();
filter.addAction(ACTION_NO_OP);
filter.addAction(ACTION_SWITCH_ON);
filter.addAction(ACTION_SWITCH_OFF);
filter.addAction(ACTION_CLEAR);
filter.addAction(ACTION_SET_REQUESTED_ORIENTATION);
filter.addAction(ACTION_ENTER_PIP);
registerReceiver(mBroadcastReceiver, filter);
handleIntentExtra(getIntent());
}
@Override
protected void onDestroy() {
unregisterReceiver(mBroadcastReceiver);
super.onDestroy();
}
@Override
protected void onUserLeaveHint() {
// Only used when auto PiP is disabled. This is to simulate the behavior that an app
// supports regular PiP but not auto PiP.
final boolean manuallyEnterPip =
((RadioButton) findViewById(R.id.enter_pip_on_leave_manual)).isChecked();
if (manuallyEnterPip) {
enterPictureInPictureMode();
}
}
private RemoteAction buildRemoteAction(Icon icon, String label, String action) {
final Intent intent = new Intent(action);
final PendingIntent pendingIntent =
PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
return new RemoteAction(icon, label, label, pendingIntent);
}
public void enterPip(View v) {
final boolean withCustomActions =
((CheckBox) findViewById(R.id.with_custom_actions)).isChecked();
mPipParamsBuilder.setActions(
withCustomActions ? mSwitchOnActions : Collections.emptyList());
enterPictureInPictureMode(mPipParamsBuilder.build());
}
public void onAutoPipSelected(View v) {
switch (v.getId()) {
case R.id.enter_pip_on_leave_manual:
// disable auto enter PiP
case R.id.enter_pip_on_leave_disabled:
mPipParamsBuilder.setAutoEnterEnabled(false);
setPictureInPictureParams(mPipParamsBuilder.build());
break;
case R.id.enter_pip_on_leave_autoenter:
mPipParamsBuilder.setAutoEnterEnabled(true);
setPictureInPictureParams(mPipParamsBuilder.build());
break;
}
}
public void onRatioSelected(View v) {
switch (v.getId()) {
case R.id.ratio_default:
mPipParamsBuilder.setAspectRatio(RATIO_DEFAULT);
break;
case R.id.ratio_square:
mPipParamsBuilder.setAspectRatio(RATIO_SQUARE);
break;
case R.id.ratio_wide:
mPipParamsBuilder.setAspectRatio(RATIO_WIDE);
break;
case R.id.ratio_tall:
mPipParamsBuilder.setAspectRatio(RATIO_TALL);
break;
}
}
private void updateMediaSessionState(int newState) {
if (mPlaybackState.getState() == newState) {
return;
}
final String title;
switch (newState) {
case STATE_PLAYING:
title = TITLE_STATE_PLAYING;
break;
case STATE_PAUSED:
title = TITLE_STATE_PAUSED;
break;
case STATE_STOPPED:
title = "";
break;
default:
throw new IllegalArgumentException("Unknown state " + newState);
}
mPlaybackStateBuilder.setState(newState, 0, 1f);
mPlaybackState = mPlaybackStateBuilder.build();
mMediaMetadataBuilder.putText(METADATA_KEY_TITLE, title);
mMediaSession.setPlaybackState(mPlaybackState);
mMediaSession.setMetadata(mMediaMetadataBuilder.build());
mMediaSession.setActive(newState != STATE_STOPPED);
}
private void handleIntentExtra(Intent intent) {
// Set the fixed orientation if requested
if (intent.hasExtra(EXTRA_PIP_ORIENTATION)) {
final int ori = Integer.parseInt(getIntent().getStringExtra(EXTRA_PIP_ORIENTATION));
setRequestedOrientation(ori);
}
// Enter picture in picture with the given aspect ratio if provided
if (intent.hasExtra(EXTRA_ENTER_PIP)) {
mPipParamsBuilder.setActions(mSwitchOnActions);
enterPip(null);
}
}
}

View File

@@ -1,61 +0,0 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.wm.shell.flicker.testapp;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
public class SendNotificationActivity extends Activity {
private NotificationManager mNotificationManager;
private String mChannelId = "Channel id";
private String mChannelName = "Channel name";
private NotificationChannel mChannel;
private int mNotifyId = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notification);
findViewById(R.id.button_send_notification).setOnClickListener(this::sendNotification);
mChannel = new NotificationChannel(mChannelId, mChannelName,
NotificationManager.IMPORTANCE_DEFAULT);
mNotificationManager = getSystemService(NotificationManager.class);
mNotificationManager.createNotificationChannel(mChannel);
}
private void sendNotification(View v) {
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
new Intent(this, SendNotificationActivity.class),
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
Notification notification = new Notification.Builder(this, mChannelId)
.setContentTitle("Notification App")
.setContentText("Notification content")
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.drawable.ic_message)
.setContentIntent(pendingIntent)
.build();
mNotificationManager.notify(mNotifyId, notification);
}
}

View File

@@ -1,33 +0,0 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.wm.shell.flicker.testapp;
import android.app.Activity;
import android.os.Bundle;
import android.view.WindowManager;
public class SimpleActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WindowManager.LayoutParams p = getWindow().getAttributes();
p.layoutInDisplayCutoutMode = WindowManager.LayoutParams
.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
getWindow().setAttributes(p);
setContentView(R.layout.activity_simple);
}
}

View File

@@ -1,29 +0,0 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.wm.shell.flicker.testapp;
import android.app.Activity;
import android.os.Bundle;
public class SplitScreenActivity extends Activity {
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_splitscreen);
}
}

View File

@@ -1,28 +0,0 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.wm.shell.flicker.testapp;
import android.app.Activity;
import android.os.Bundle;
public class SplitScreenSecondaryActivity extends Activity {
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_splitscreen_secondary);
}
}