summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ApiDocs.bp2
-rw-r--r--apct-tests/perftests/multiuser/Android.bp1
-rw-r--r--apct-tests/perftests/multiuser/AndroidManifest.xml3
-rw-r--r--apct-tests/perftests/multiuser/AndroidTest.xml34
-rw-r--r--apct-tests/perftests/textclassifier/Android.bp2
-rw-r--r--apct-tests/perftests/textclassifier/AndroidTest.xml32
-rw-r--r--apct-tests/perftests/textclassifier/src/android/view/textclassifier/TextClassifierPerfTest.java88
-rw-r--r--api/current.txt2
-rwxr-xr-xapi/system-current.txt8
-rw-r--r--cmds/screencap/screencap.cpp31
-rw-r--r--cmds/uiautomator/library/Android.bp2
-rw-r--r--core/java/android/animation/AnimatorSet.java18
-rw-r--r--core/java/android/app/ActivityManagerInternal.java13
-rw-r--r--core/java/android/companion/BluetoothDeviceFilter.java10
-rw-r--r--core/java/android/telephony/TelephonyRegistryManager.java29
-rw-r--r--core/java/android/view/SurfaceControl.java83
-rw-r--r--core/java/android/view/accessibility/AccessibilityNodeInfo.java4
-rw-r--r--core/java/android/widget/inline/InlineContentView.java2
-rw-r--r--core/java/com/android/internal/telephony/ITelephonyRegistry.aidl6
-rw-r--r--core/jni/android_view_SurfaceControl.cpp179
-rw-r--r--data/keyboards/Generic.kl1
-rw-r--r--location/java/android/location/GnssAntennaInfo.java107
-rwxr-xr-xmedia/java/android/media/AudioManager.java83
-rw-r--r--media/jni/android_media_tv_Tuner.cpp5
-rw-r--r--media/jni/android_media_tv_Tuner.h5
-rw-r--r--media/jni/audioeffect/Visualizer.cpp33
-rw-r--r--media/jni/audioeffect/Visualizer.h34
-rw-r--r--media/jni/audioeffect/android_media_AudioEffect.cpp21
-rw-r--r--media/jni/audioeffect/android_media_Visualizer.cpp10
-rw-r--r--non-updatable-api/current.txt2
-rw-r--r--non-updatable-api/system-current.txt8
-rw-r--r--packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java9
-rw-r--r--packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java21
-rw-r--r--packages/FakeOemFeatures/src/com/android/fakeoemfeatures/FakeView.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java9
-rw-r--r--packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java22
-rw-r--r--packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java79
-rw-r--r--packages/SystemUI/src/com/android/systemui/bubbles/BubbleViewInfoTask.java11
-rw-r--r--packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java73
-rw-r--r--packages/SystemUI/src/com/android/systemui/controls/CustomIconCache.kt76
-rw-r--r--packages/SystemUI/src/com/android/systemui/controls/management/ControlsEditingActivity.kt6
-rw-r--r--packages/SystemUI/src/com/android/systemui/controls/management/ControlsModel.kt19
-rw-r--r--packages/SystemUI/src/com/android/systemui/controls/management/FavoritesModel.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt5
-rw-r--r--packages/SystemUI/src/com/android/systemui/dagger/SystemUIRootComponent.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/PipAnimationController.java12
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java17
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipAccessibilityInteractionConnection.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java10
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java29
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java10
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuIconsAlgorithm.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java16
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/dagger/PipMenuActivityClass.java30
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/BatterySaverTile.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotNotificationsController.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/settings/CurrentUserContentResolverProvider.kt24
-rw-r--r--packages/SystemUI/src/com/android/systemui/settings/CurrentUserContextTracker.kt8
-rw-r--r--packages/SystemUI/src/com/android/systemui/settings/dagger/SettingsModule.java9
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java10
-rw-r--r--packages/SystemUI/src/com/android/systemui/util/leak/LeakReporter.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/util/sensors/ProximitySensor.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/wmshell/WindowManagerShellModule.java10
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/controls/CustomIconCacheTest.kt101
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/controls/management/FavoritesModelTest.kt15
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/pip/PipAnimationControllerTest.java6
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/util/sensors/ProximityCheckTest.java6
-rw-r--r--services/Android.bp2
-rw-r--r--services/accessibility/java/com/android/server/accessibility/magnification/FullScreenMagnificationController.java123
-rw-r--r--services/core/java/com/android/server/TelephonyRegistry.java175
-rw-r--r--services/core/java/com/android/server/am/ActiveServices.java6
-rw-r--r--services/core/java/com/android/server/am/UserController.java22
-rw-r--r--services/core/java/com/android/server/appop/AppOpsService.java74
-rw-r--r--services/core/java/com/android/server/appop/TEST_MAPPING3
-rwxr-xr-xservices/core/java/com/android/server/audio/AudioService.java24
-rw-r--r--services/core/java/com/android/server/pm/OWNERS20
-rw-r--r--services/core/java/com/android/server/pm/PackageInstallerService.java8
-rw-r--r--services/core/java/com/android/server/pm/ShortcutService.java72
-rw-r--r--services/core/java/com/android/server/pm/permission/PermissionManagerService.java86
-rw-r--r--services/core/java/com/android/server/pm/permission/TEST_MAPPING17
-rw-r--r--services/core/java/com/android/server/wm/RootWindowContainer.java1
-rw-r--r--services/java/com/android/server/SystemServer.java17
-rw-r--r--services/profcollect/Android.bp35
-rw-r--r--services/profcollect/OWNERS3
-rw-r--r--services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java196
-rw-r--r--services/tests/mockingservicestests/src/com/android/server/appop/AppOpsServiceTest.java10
-rw-r--r--services/tests/servicestests/src/com/android/server/accessibility/magnification/FullScreenMagnificationControllerTest.java100
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityDisplayTests.java24
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityMetricsLaunchObserverTests.java14
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java79
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityStackSupervisorTests.java20
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityStackTests.java101
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityStartControllerTests.java22
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java108
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java32
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityTestsBase.java607
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java4
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java22
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/LaunchParamsControllerTests.java30
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/LaunchParamsPersisterTests.java6
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java84
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java2
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/RecentsAnimationTest.java60
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/RootActivityContainerTests.java93
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java12
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/RunningTasksTest.java10
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java32
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskDisplayAreaTests.java5
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java16
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskPositionerTests.java2
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java82
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java2
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java2
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java12
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerMapTests.java14
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerTests.java28
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/WindowTestUtils.java6
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java574
-rw-r--r--services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java38
-rw-r--r--startop/OWNERS2
-rw-r--r--telephony/api/system-current.txt1
-rw-r--r--telephony/java/android/telephony/PreciseDataConnectionState.java129
-rw-r--r--telephony/java/android/telephony/data/ApnSetting.java14
-rw-r--r--test-runner/src/android/test/AndroidTestRunner.java2
-rw-r--r--tools/stats_log_api_gen/main.cpp2
129 files changed, 2870 insertions, 1968 deletions
diff --git a/ApiDocs.bp b/ApiDocs.bp
index 029699efe3b9..ca921ff97c35 100644
--- a/ApiDocs.bp
+++ b/ApiDocs.bp
@@ -150,12 +150,10 @@ doc_defaults {
":current-support-api",
":current-androidx-api",
],
- create_stubs: false,
}
doc_defaults {
name: "framework-dokka-docs-default",
- create_stubs: false,
}
droiddoc {
diff --git a/apct-tests/perftests/multiuser/Android.bp b/apct-tests/perftests/multiuser/Android.bp
index 04432f25e337..fc45d4adcc15 100644
--- a/apct-tests/perftests/multiuser/Android.bp
+++ b/apct-tests/perftests/multiuser/Android.bp
@@ -22,5 +22,6 @@ android_test {
],
platform_apis: true,
test_suites: ["device-tests"],
+ data: [":perfetto_artifacts"],
certificate: "platform",
}
diff --git a/apct-tests/perftests/multiuser/AndroidManifest.xml b/apct-tests/perftests/multiuser/AndroidManifest.xml
index e4196dd6cf12..cb05651a3eec 100644
--- a/apct-tests/perftests/multiuser/AndroidManifest.xml
+++ b/apct-tests/perftests/multiuser/AndroidManifest.xml
@@ -17,7 +17,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.perftests.multiuser">
- <uses-sdk android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.CONTROL_KEYGUARD" />
<uses-permission android:name="android.permission.MANAGE_USERS" />
@@ -25,8 +24,6 @@
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-permission android:name="android.permission.REAL_GET_TASKS" />
<application>
<uses-library android:name="android.test.runner" />
diff --git a/apct-tests/perftests/multiuser/AndroidTest.xml b/apct-tests/perftests/multiuser/AndroidTest.xml
index 9117561fe1e5..c7929af6077f 100644
--- a/apct-tests/perftests/multiuser/AndroidTest.xml
+++ b/apct-tests/perftests/multiuser/AndroidTest.xml
@@ -16,14 +16,48 @@
<configuration description="Runs MultiUserPerfTests metric instrumentation.">
<option name="test-suite-tag" value="apct" />
<option name="test-suite-tag" value="apct-metric-instrumentation" />
+
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="MultiUserPerfTests.apk" />
<option name="test-file-name" value="MultiUserPerfDummyApp.apk" />
</target_preparer>
+ <!-- Needed for pushing the trace config file -->
+ <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/>
+ <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
+ <option name="push-file" key="trace_config_detailed.textproto" value="/data/misc/perfetto-traces/trace_config.textproto" />
+ </target_preparer>
+
+ <!-- Needed for pulling the collected trace config on to the host -->
+ <metrics_collector class="com.android.tradefed.device.metric.FilePullerLogCollector">
+ <option name="pull-pattern-keys" value="perfetto_file_path" />
+ </metrics_collector>
+
+ <!-- Needed for storing the perfetto trace files in the sdcard/test_results-->
+ <option name="isolated-storage" value="false" />
+
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="com.android.perftests.multiuser" />
<option name="hidden-api-checks" value="false"/>
+
+ <!-- Listener related args for collecting the traces and waiting for the device to stabilize. -->
+ <option name="device-listeners" value="android.device.collectors.ProcLoadListener,android.device.collectors.PerfettoListener" />
+ <!-- Guarantee that user defined RunListeners will be running before any of the default listeners defined in this runner. -->
+ <option name="instrumentation-arg" key="newRunListenerMode" value="true" />
+
+ <!-- ProcLoadListener related arguments -->
+ <!-- Wait for device last minute threshold to reach 3 with 2 minute timeout before starting the test run -->
+ <option name="instrumentation-arg" key="procload-collector:per_run" value="true" />
+ <option name="instrumentation-arg" key="proc-loadavg-threshold" value="3" />
+ <option name="instrumentation-arg" key="proc-loadavg-timeout" value="120000" />
+ <option name="instrumentation-arg" key="proc-loadavg-interval" value="10000" />
+
+ <!-- PerfettoListener related arguments -->
+ <option name="instrumentation-arg" key="perfetto_config_text_proto" value="true" />
+ <option name="instrumentation-arg" key="perfetto_config_file" value="trace_config.textproto" />
+
+ <option name="instrumentation-arg" key="newRunListenerMode" value="true" />
+
</test>
</configuration>
diff --git a/apct-tests/perftests/textclassifier/Android.bp b/apct-tests/perftests/textclassifier/Android.bp
index 49952dc1d009..9f795a7ed54a 100644
--- a/apct-tests/perftests/textclassifier/Android.bp
+++ b/apct-tests/perftests/textclassifier/Android.bp
@@ -19,7 +19,9 @@ android_test {
"androidx.test.rules",
"androidx.annotation_annotation",
"apct-perftests-utils",
+ "collector-device-lib-platform",
],
+ data: [":perfetto_artifacts"],
platform_apis: true,
test_suites: ["device-tests"],
}
diff --git a/apct-tests/perftests/textclassifier/AndroidTest.xml b/apct-tests/perftests/textclassifier/AndroidTest.xml
index 3df51b8ae67a..3fac462448f0 100644
--- a/apct-tests/perftests/textclassifier/AndroidTest.xml
+++ b/apct-tests/perftests/textclassifier/AndroidTest.xml
@@ -21,8 +21,40 @@
<option name="test-file-name" value="TextClassifierPerfTests.apk" />
</target_preparer>
+ <!-- Needed for pushing the trace config file -->
+ <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/>
+ <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
+ <option name="push-file" key="trace_config_detailed.textproto" value="/data/misc/perfetto-traces/trace_config.textproto" />
+ </target_preparer>
+
+ <!-- Needed for pulling the collected trace config on to the host -->
+ <metrics_collector class="com.android.tradefed.device.metric.FilePullerLogCollector">
+ <option name="pull-pattern-keys" value="perfetto_file_path" />
+ </metrics_collector>
+
+ <!-- Needed for storing the perfetto trace files in the sdcard/test_results-->
+ <option name="isolated-storage" value="false" />
+
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="com.android.perftests.textclassifier" />
<option name="hidden-api-checks" value="false"/>
+
+ <!-- Listener related args for collecting the traces and waiting for the device to stabilize. -->
+ <option name="device-listeners" value="android.device.collectors.ProcLoadListener,android.device.collectors.PerfettoListener" />
+ <!-- Guarantee that user defined RunListeners will be running before any of the default listeners defined in this runner. -->
+ <option name="instrumentation-arg" key="newRunListenerMode" value="true" />
+
+ <!-- ProcLoadListener related arguments -->
+ <!-- Wait for device last minute threshold to reach 3 with 2 minute timeout before starting the test run -->
+ <option name="instrumentation-arg" key="procload-collector:per_run" value="true" />
+ <option name="instrumentation-arg" key="proc-loadavg-threshold" value="3" />
+ <option name="instrumentation-arg" key="proc-loadavg-timeout" value="120000" />
+ <option name="instrumentation-arg" key="proc-loadavg-interval" value="10000" />
+
+ <!-- PerfettoListener related arguments -->
+ <option name="instrumentation-arg" key="perfetto_config_text_proto" value="true" />
+ <option name="instrumentation-arg" key="perfetto_config_file" value="trace_config.textproto" />
+
+ <option name="instrumentation-arg" key="newRunListenerMode" value="true" />
</test>
</configuration>
diff --git a/apct-tests/perftests/textclassifier/src/android/view/textclassifier/TextClassifierPerfTest.java b/apct-tests/perftests/textclassifier/src/android/view/textclassifier/TextClassifierPerfTest.java
index 14a121d60c2e..324def83785f 100644
--- a/apct-tests/perftests/textclassifier/src/android/view/textclassifier/TextClassifierPerfTest.java
+++ b/apct-tests/perftests/textclassifier/src/android/view/textclassifier/TextClassifierPerfTest.java
@@ -18,6 +18,7 @@ package android.view.textclassifier;
import android.content.Context;
import android.perftests.utils.BenchmarkState;
import android.perftests.utils.PerfStatusReporter;
+import android.service.textclassifier.TextClassifierService;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest;
@@ -25,86 +26,85 @@ import androidx.test.filters.LargeTest;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
-import java.util.Random;
-@RunWith(Parameterized.class)
@LargeTest
public class TextClassifierPerfTest {
- /** Request contains meaning text, rather than garbled text. */
- private static final int ACTUAL_REQUEST = 0;
- private static final String RANDOM_CHAR_SET = "abcdefghijklmnopqrstuvwxyz0123456789";
+ private static final String TEXT = " Oh hi Mark, the number is (323) 654-6192.\n"
+ + "Anyway, I'll meet you at 1600 Pennsylvania Avenue NW.\n"
+ + "My flight is LX 38 and I'll arrive at 8:00pm.\n"
+ + "Also, check out www.google.com.\n";
@Rule
public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
- @Parameterized.Parameters(name = "size{0}")
- public static Collection<Object[]> data() {
- return Arrays.asList(new Object[][]{{ACTUAL_REQUEST}, {10}, {100}, {1000}});
- }
-
private TextClassifier mTextClassifier;
- private final int mSize;
-
- public TextClassifierPerfTest(int size) {
- mSize = size;
- }
@Before
public void setUp() {
Context context = InstrumentationRegistry.getTargetContext();
- TextClassificationManager textClassificationManager =
- context.getSystemService(TextClassificationManager.class);
- mTextClassifier = textClassificationManager.getTextClassifier(TextClassifier.LOCAL);
+ mTextClassifier = TextClassifierService.getDefaultTextClassifierImplementation(context);
}
@Test
- public void testSuggestConversationActions() {
- String text = mSize == ACTUAL_REQUEST ? "Where are you?" : generateRandomString(mSize);
- ConversationActions.Request request = createConversationActionsRequest(text);
+ public void testClassifyText() {
+ TextClassification.Request request =
+ new TextClassification.Request.Builder(TEXT, 0, TEXT.length()).build();
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
while (state.keepRunning()) {
- mTextClassifier.suggestConversationActions(request);
+ mTextClassifier.classifyText(request);
}
}
@Test
- public void testDetectLanguage() {
- String text = mSize == ACTUAL_REQUEST
- ? "これは日本語のテキストです" : generateRandomString(mSize);
- TextLanguage.Request request = createTextLanguageRequest(text);
+ public void testSuggestSelection() {
+ // Trying to select the phone number.
+ TextSelection.Request request =
+ new TextSelection.Request.Builder(
+ TEXT,
+ /* startIndex= */ 28,
+ /* endIndex= */29)
+ .build();
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
while (state.keepRunning()) {
- mTextClassifier.detectLanguage(request);
+ mTextClassifier.suggestSelection(request);
}
}
- private static ConversationActions.Request createConversationActionsRequest(CharSequence text) {
+ @Test
+ public void testGenerateLinks() {
+ TextLinks.Request request =
+ new TextLinks.Request.Builder(TEXT).build();
+ BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ while (state.keepRunning()) {
+ mTextClassifier.generateLinks(request);
+ }
+ }
+
+ @Test
+ public void testSuggestConversationActions() {
ConversationActions.Message message =
new ConversationActions.Message.Builder(
ConversationActions.Message.PERSON_USER_OTHERS)
- .setText(text)
+ .setText(TEXT)
.build();
- return new ConversationActions.Request.Builder(Collections.singletonList(message))
+ ConversationActions.Request request = new ConversationActions.Request.Builder(
+ Collections.singletonList(message))
.build();
- }
- private static TextLanguage.Request createTextLanguageRequest(CharSequence text) {
- return new TextLanguage.Request.Builder(text).build();
+ BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ while (state.keepRunning()) {
+ mTextClassifier.suggestConversationActions(request);
+ }
}
- private static String generateRandomString(int length) {
- Random random = new Random();
- StringBuilder stringBuilder = new StringBuilder(length);
- for (int i = 0; i < length; i++) {
- int index = random.nextInt(RANDOM_CHAR_SET.length());
- stringBuilder.append(RANDOM_CHAR_SET.charAt(index));
+ @Test
+ public void testDetectLanguage() {
+ TextLanguage.Request request = new TextLanguage.Request.Builder(TEXT).build();
+ BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ while (state.keepRunning()) {
+ mTextClassifier.detectLanguage(request);
}
- return stringBuilder.toString();
}
}
diff --git a/api/current.txt b/api/current.txt
index a59c7b85e608..09de005c008c 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -24207,6 +24207,7 @@ package android.media {
method @NonNull public java.util.List<android.media.AudioPlaybackConfiguration> getActivePlaybackConfigurations();
method @NonNull public java.util.List<android.media.AudioRecordingConfiguration> getActiveRecordingConfigurations();
method public int getAllowedCapturePolicy();
+ method public int getAudioHwSyncForSession(int);
method public android.media.AudioDeviceInfo[] getDevices(int);
method public java.util.List<android.media.MicrophoneInfo> getMicrophones() throws java.io.IOException;
method public int getMode();
@@ -47864,6 +47865,7 @@ package android.telephony {
method @Nullable public android.net.LinkProperties getLinkProperties();
method public int getNetworkType();
method public int getState();
+ method public int getTransportType();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.PreciseDataConnectionState> CREATOR;
}
diff --git a/api/system-current.txt b/api/system-current.txt
index 11db781dd42f..56059dd9d864 100755
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -4201,6 +4201,7 @@ package android.media {
method @IntRange(from=0) public long getAdditionalOutputDeviceDelay(@NonNull android.media.AudioDeviceInfo);
method @NonNull @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public static java.util.List<android.media.audiopolicy.AudioProductStrategy> getAudioProductStrategies();
method @NonNull @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public static java.util.List<android.media.audiopolicy.AudioVolumeGroup> getAudioVolumeGroups();
+ method @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public int getDeviceVolumeBehavior(@NonNull android.media.AudioDeviceAttributes);
method @NonNull @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public java.util.List<android.media.AudioDeviceAttributes> getDevicesForAttributes(@NonNull android.media.AudioAttributes);
method @IntRange(from=0) public long getMaxAdditionalOutputDeviceDelay(@NonNull android.media.AudioDeviceInfo);
method @IntRange(from=0) @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public int getMaxVolumeIndexForAttributes(@NonNull android.media.AudioAttributes);
@@ -4219,6 +4220,7 @@ package android.media {
method @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public int requestAudioFocus(@NonNull android.media.AudioFocusRequest, @Nullable android.media.audiopolicy.AudioPolicy);
method @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public boolean setAdditionalOutputDeviceDelay(@NonNull android.media.AudioDeviceInfo, @IntRange(from=0) long);
method public void setAudioServerStateCallback(@NonNull java.util.concurrent.Executor, @NonNull android.media.AudioManager.AudioServerStateCallback);
+ method @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public void setDeviceVolumeBehavior(@NonNull android.media.AudioDeviceAttributes, int);
method @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public void setFocusRequestResult(@NonNull android.media.AudioFocusInfo, int, @NonNull android.media.audiopolicy.AudioPolicy);
method @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public boolean setPreferredDeviceForStrategy(@NonNull android.media.audiopolicy.AudioProductStrategy, @NonNull android.media.AudioDeviceAttributes);
method @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public void setSupportedSystemUsages(@NonNull int[]);
@@ -4229,6 +4231,11 @@ package android.media {
field public static final int AUDIOFOCUS_FLAG_DELAY_OK = 1; // 0x1
field public static final int AUDIOFOCUS_FLAG_LOCK = 4; // 0x4
field public static final int AUDIOFOCUS_FLAG_PAUSES_ON_DUCKABLE_LOSS = 2; // 0x2
+ field public static final int DEVICE_VOLUME_BEHAVIOR_ABSOLUTE = 3; // 0x3
+ field public static final int DEVICE_VOLUME_BEHAVIOR_ABSOLUTE_MULTI_MODE = 4; // 0x4
+ field public static final int DEVICE_VOLUME_BEHAVIOR_FIXED = 2; // 0x2
+ field public static final int DEVICE_VOLUME_BEHAVIOR_FULL = 1; // 0x1
+ field public static final int DEVICE_VOLUME_BEHAVIOR_VARIABLE = 0; // 0x0
field @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public static final int STREAM_ASSISTANT = 11; // 0xb
field public static final int SUCCESS = 0; // 0x0
}
@@ -10838,6 +10845,7 @@ package android.telephony {
method @Deprecated public int getDataConnectionApnTypeBitMask();
method @Deprecated public int getDataConnectionFailCause();
method @Deprecated public int getDataConnectionState();
+ method public int getId();
}
public final class PreciseDisconnectCause {
diff --git a/cmds/screencap/screencap.cpp b/cmds/screencap/screencap.cpp
index c1d8399d91a5..a46a54cc2063 100644
--- a/cmds/screencap/screencap.cpp
+++ b/cmds/screencap/screencap.cpp
@@ -182,16 +182,17 @@ int main(int argc, char** argv)
ProcessState::self()->setThreadPoolMaxThreadCount(0);
ProcessState::self()->startThreadPool();
- ui::Dataspace outDataspace;
- sp<GraphicBuffer> outBuffer;
-
- status_t result = ScreenshotClient::capture(*displayId, &outDataspace, &outBuffer);
+ ScreenCaptureResults captureResults;
+ status_t result = ScreenshotClient::captureDisplay(*displayId, captureResults);
if (result != NO_ERROR) {
close(fd);
return 1;
}
- result = outBuffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN, &base);
+ ui::Dataspace dataspace = captureResults.capturedDataspace;
+ sp<GraphicBuffer> buffer = captureResults.buffer;
+
+ result = buffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN, &base);
if (base == nullptr || result != NO_ERROR) {
String8 reason;
@@ -207,13 +208,13 @@ int main(int argc, char** argv)
if (png) {
AndroidBitmapInfo info;
- info.format = flinger2bitmapFormat(outBuffer->getPixelFormat());
+ info.format = flinger2bitmapFormat(buffer->getPixelFormat());
info.flags = ANDROID_BITMAP_FLAGS_ALPHA_PREMUL;
- info.width = outBuffer->getWidth();
- info.height = outBuffer->getHeight();
- info.stride = outBuffer->getStride() * bytesPerPixel(outBuffer->getPixelFormat());
+ info.width = buffer->getWidth();
+ info.height = buffer->getHeight();
+ info.stride = buffer->getStride() * bytesPerPixel(buffer->getPixelFormat());
- int result = AndroidBitmap_compress(&info, static_cast<int32_t>(outDataspace), base,
+ int result = AndroidBitmap_compress(&info, static_cast<int32_t>(dataspace), base,
ANDROID_BITMAP_COMPRESS_FORMAT_PNG, 100, &fd,
[](void* fdPtr, const void* data, size_t size) -> bool {
int bytesWritten = write(*static_cast<int*>(fdPtr),
@@ -229,11 +230,11 @@ int main(int argc, char** argv)
notifyMediaScanner(fn);
}
} else {
- uint32_t w = outBuffer->getWidth();
- uint32_t h = outBuffer->getHeight();
- uint32_t s = outBuffer->getStride();
- uint32_t f = outBuffer->getPixelFormat();
- uint32_t c = dataSpaceToInt(outDataspace);
+ uint32_t w = buffer->getWidth();
+ uint32_t h = buffer->getHeight();
+ uint32_t s = buffer->getStride();
+ uint32_t f = buffer->getPixelFormat();
+ uint32_t c = dataSpaceToInt(dataspace);
write(fd, &w, 4);
write(fd, &h, 4);
diff --git a/cmds/uiautomator/library/Android.bp b/cmds/uiautomator/library/Android.bp
index 04b00cb837b2..14b74da0c616 100644
--- a/cmds/uiautomator/library/Android.bp
+++ b/cmds/uiautomator/library/Android.bp
@@ -54,7 +54,6 @@ droiddoc {
],
installable: false,
custom_template: "droiddoc-templates-sdk",
- create_stubs: false,
}
java_library_static {
@@ -66,6 +65,7 @@ java_library_static {
"android.test.runner",
"junit",
],
+ java_version: "1.8",
}
java_library_static {
diff --git a/core/java/android/animation/AnimatorSet.java b/core/java/android/animation/AnimatorSet.java
index a9239b48bb3f..bc8db029e06d 100644
--- a/core/java/android/animation/AnimatorSet.java
+++ b/core/java/android/animation/AnimatorSet.java
@@ -183,7 +183,7 @@ public final class AnimatorSet extends Animator implements AnimationHandler.Anim
// This is to work around a bug in b/34736819. This needs to be removed once app team
// fixes their side.
- private AnimatorListenerAdapter mAnimationEndingListener = new AnimatorListenerAdapter() {
+ private AnimatorListenerAdapter mAnimationEndListener = new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (mNodeMap.get(animation) == null) {
@@ -1186,7 +1186,7 @@ public final class AnimatorSet extends Animator implements AnimationHandler.Anim
}
private void startAnimation() {
- addAnimationEndingListener();
+ addAnimationEndListener();
// Register animation callback
addAnimationCallback(0);
@@ -1243,15 +1243,15 @@ public final class AnimatorSet extends Animator implements AnimationHandler.Anim
// This is to work around the issue in b/34736819, as the old behavior in AnimatorSet had
// masked a real bug in play movies. TODO: remove this and below once the root cause is fixed.
- private void addAnimationEndingListener() {
+ private void addAnimationEndListener() {
for (int i = 1; i < mNodes.size(); i++) {
- mNodes.get(i).mAnimation.addListener(mAnimationEndingListener);
+ mNodes.get(i).mAnimation.addListener(mAnimationEndListener);
}
}
- private void removeAnimationEndingListener() {
+ private void removeAnimationEndListener() {
for (int i = 1; i < mNodes.size(); i++) {
- mNodes.get(i).mAnimation.removeListener(mAnimationEndingListener);
+ mNodes.get(i).mAnimation.removeListener(mAnimationEndListener);
}
}
@@ -1301,7 +1301,7 @@ public final class AnimatorSet extends Animator implements AnimationHandler.Anim
tmpListeners.get(i).onAnimationEnd(this, mReversing);
}
}
- removeAnimationEndingListener();
+ removeAnimationEndListener();
mSelfPulse = true;
mReversing = false;
}
@@ -1346,7 +1346,7 @@ public final class AnimatorSet extends Animator implements AnimationHandler.Anim
anim.mNodeMap = new ArrayMap<Animator, Node>();
anim.mNodes = new ArrayList<Node>(nodeCount);
anim.mEvents = new ArrayList<AnimationEvent>();
- anim.mAnimationEndingListener = new AnimatorListenerAdapter() {
+ anim.mAnimationEndListener = new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (anim.mNodeMap.get(animation) == null) {
@@ -1369,7 +1369,7 @@ public final class AnimatorSet extends Animator implements AnimationHandler.Anim
final Node node = mNodes.get(n);
Node nodeClone = node.clone();
// Remove the old internal listener from the cloned child
- nodeClone.mAnimation.removeListener(mAnimationEndingListener);
+ nodeClone.mAnimation.removeListener(mAnimationEndListener);
clonesMap.put(node, nodeClone);
anim.mNodes.add(nodeClone);
anim.mNodeMap.put(nodeClone.mAnimation, nodeClone);
diff --git a/core/java/android/app/ActivityManagerInternal.java b/core/java/android/app/ActivityManagerInternal.java
index 7fe567b5ce27..9cf0d2a3a36a 100644
--- a/core/java/android/app/ActivityManagerInternal.java
+++ b/core/java/android/app/ActivityManagerInternal.java
@@ -52,23 +52,14 @@ public abstract class ActivityManagerInternal {
* if in the same profile group.
* Otherwise, {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL} is required.
*/
- public static final int ALLOW_NON_FULL_IN_PROFILE_OR_FULL = 1;
+ public static final int ALLOW_NON_FULL_IN_PROFILE = 1;
public static final int ALLOW_FULL_ONLY = 2;
/**
* Allows access to a caller with {@link android.Manifest.permission#INTERACT_ACROSS_PROFILES}
* or {@link android.Manifest.permission#INTERACT_ACROSS_USERS} if in the same profile group.
* Otherwise, {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL} is required.
*/
- public static final int ALLOW_ACROSS_PROFILES_IN_PROFILE_OR_FULL = 3;
- /**
- * Requires {@link android.Manifest.permission#INTERACT_ACROSS_PROFILES},
- * {@link android.Manifest.permission#INTERACT_ACROSS_USERS}, or
- * {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL} if in same profile group,
- * otherwise {@link android.Manifest.permission#INTERACT_ACROSS_USERS} or
- * {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL}. (so this is an extension
- * to {@link #ALLOW_NON_FULL})
- */
- public static final int ALLOW_ACROSS_PROFILES_IN_PROFILE_OR_NON_FULL = 4;
+ public static final int ALLOW_ALL_PROFILE_PERMISSIONS_IN_PROFILE = 3;
/**
* Verify that calling app has access to the given provider.
diff --git a/core/java/android/companion/BluetoothDeviceFilter.java b/core/java/android/companion/BluetoothDeviceFilter.java
index 2649fbee4246..cf9eeca0d739 100644
--- a/core/java/android/companion/BluetoothDeviceFilter.java
+++ b/core/java/android/companion/BluetoothDeviceFilter.java
@@ -142,6 +142,16 @@ public final class BluetoothDeviceFilter implements DeviceFilter<BluetoothDevice
}
@Override
+ public String toString() {
+ return "BluetoothDeviceFilter{"
+ + "mNamePattern=" + mNamePattern
+ + ", mAddress='" + mAddress + '\''
+ + ", mServiceUuids=" + mServiceUuids
+ + ", mServiceUuidMasks=" + mServiceUuidMasks
+ + '}';
+ }
+
+ @Override
public int describeContents() {
return 0;
}
diff --git a/core/java/android/telephony/TelephonyRegistryManager.java b/core/java/android/telephony/TelephonyRegistryManager.java
index 0a47032354f5..a720601d81ff 100644
--- a/core/java/android/telephony/TelephonyRegistryManager.java
+++ b/core/java/android/telephony/TelephonyRegistryManager.java
@@ -26,10 +26,8 @@ import android.os.Binder;
import android.os.Build;
import android.os.RemoteException;
import android.os.ServiceManager;
-import android.telephony.Annotation.ApnType;
import android.telephony.Annotation.CallState;
import android.telephony.Annotation.DataActivityType;
-import android.telephony.Annotation.DataFailureCause;
import android.telephony.Annotation.DisconnectCauses;
import android.telephony.Annotation.NetworkType;
import android.telephony.Annotation.PreciseCallStates;
@@ -37,7 +35,6 @@ import android.telephony.Annotation.PreciseDisconnectCauses;
import android.telephony.Annotation.RadioPowerState;
import android.telephony.Annotation.SimActivationState;
import android.telephony.Annotation.SrvccState;
-import android.telephony.data.ApnSetting;
import android.telephony.emergency.EmergencyNumber;
import android.telephony.ims.ImsReasonInfo;
import android.util.Log;
@@ -402,17 +399,16 @@ public class TelephonyRegistryManager {
* @param subId for which data connection state changed.
* @param slotIndex for which data connections state changed. Can be derived from subId except
* when subId is invalid.
- * @param apnType the apn type bitmask, defined with {@code ApnSetting#TYPE_*} flags.
* @param preciseState the PreciseDataConnectionState
*
- * @see android.telephony.PreciseDataConnection
+ * @see PreciseDataConnectionState
* @see TelephonyManager#DATA_DISCONNECTED
*/
public void notifyDataConnectionForSubscriber(int slotIndex, int subId,
- @ApnType int apnType, @Nullable PreciseDataConnectionState preciseState) {
+ @NonNull PreciseDataConnectionState preciseState) {
try {
sRegistry.notifyDataConnectionForSubscriber(
- slotIndex, subId, apnType, preciseState);
+ slotIndex, subId, preciseState);
} catch (RemoteException ex) {
// system process is dead
}
@@ -612,25 +608,6 @@ public class TelephonyRegistryManager {
}
/**
- * Notify precise data connection failed cause on certain subscription.
- *
- * @param subId for which data connection failed.
- * @param slotIndex for which data conenction failed. Can be derived from subId except when
- * subId is invalid.
- * @param apnType the apn type bitmask, defined with {@code ApnSetting#TYPE_*} flags.
- * @param apn the APN {@link ApnSetting#getApnName()} of this data connection.
- * @param failCause data fail cause.
- */
- public void notifyPreciseDataConnectionFailed(int subId, int slotIndex, @ApnType int apnType,
- @Nullable String apn, @DataFailureCause int failCause) {
- try {
- sRegistry.notifyPreciseDataConnectionFailed(slotIndex, subId, apnType, apn, failCause);
- } catch (RemoteException ex) {
- // system process is dead
- }
- }
-
- /**
* Notify single Radio Voice Call Continuity (SRVCC) state change for the currently active call
* on certain subscription.
*
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java
index eaa7eafc23cc..50ed00cd0aa7 100644
--- a/core/java/android/view/SurfaceControl.java
+++ b/core/java/android/view/SurfaceControl.java
@@ -89,13 +89,10 @@ public final class SurfaceControl implements Parcelable {
private static native void nativeWriteToParcel(long nativeObject, Parcel out);
private static native void nativeRelease(long nativeObject);
private static native void nativeDisconnect(long nativeObject);
-
- private static native ScreenshotHardwareBuffer nativeScreenshot(IBinder displayToken,
- Rect sourceCrop, int width, int height, boolean useIdentityTransform, int rotation,
- boolean captureSecureLayers);
- private static native ScreenshotHardwareBuffer nativeCaptureLayers(IBinder displayToken,
- long layerObject, Rect sourceCrop, float frameScale, long[] excludeLayerObjects,
- int format);
+ private static native ScreenshotHardwareBuffer nativeCaptureDisplay(
+ DisplayCaptureArgs captureArgs);
+ private static native ScreenshotHardwareBuffer nativeCaptureLayers(
+ LayerCaptureArgs captureArgs);
private static native long nativeMirrorSurface(long mirrorOfObject);
private static native long nativeCreateTransaction();
private static native long nativeGetNativeTransactionFinalizer();
@@ -572,7 +569,8 @@ public final class SurfaceControl implements Parcelable {
* Create ScreenshotHardwareBuffer from an existing HardwareBuffer object.
* @param hardwareBuffer The existing HardwareBuffer object
* @param namedColorSpace Integer value of a named color space {@link ColorSpace.Named}
- * @param containsSecureLayer Indicates whether this graphic buffer contains captured contents
+ * @param containsSecureLayers Indicates whether this graphic buffer contains captured
+ * contents
* of secure layers, in which case the screenshot should not be persisted.
*/
private static ScreenshotHardwareBuffer createFromNative(HardwareBuffer hardwareBuffer,
@@ -662,14 +660,14 @@ public final class SurfaceControl implements Parcelable {
/**
* Each sub class should return itself to allow the builder to chain properly
*/
- public abstract T getThis();
+ abstract T getThis();
}
}
/**
* The arguments class used to make display capture requests.
*
- * @see #nativeScreenshot(IBinder, Rect, int, int, boolean, int, boolean)
+ * @see #nativeCaptureDisplay(DisplayCaptureArgs)
* @hide
*/
public static class DisplayCaptureArgs extends CaptureArgs {
@@ -759,7 +757,7 @@ public final class SurfaceControl implements Parcelable {
}
@Override
- public Builder getThis() {
+ Builder getThis() {
return this;
}
}
@@ -768,7 +766,7 @@ public final class SurfaceControl implements Parcelable {
/**
* The arguments class used to make layer capture requests.
*
- * @see #nativeCaptureLayers(IBinder, long, Rect, float, long[], int)
+ * @see #nativeCaptureLayers(LayerCaptureArgs)
* @hide
*/
public static class LayerCaptureArgs extends CaptureArgs {
@@ -780,9 +778,13 @@ public final class SurfaceControl implements Parcelable {
super(builder);
mChildrenOnly = builder.mChildrenOnly;
mNativeLayer = builder.mLayer.mNativeObject;
- mNativeExcludeLayers = new long[builder.mExcludeLayers.length];
- for (int i = 0; i < builder.mExcludeLayers.length; i++) {
- mNativeExcludeLayers[i] = builder.mExcludeLayers[i].mNativeObject;
+ if (builder.mExcludeLayers != null) {
+ mNativeExcludeLayers = new long[builder.mExcludeLayers.length];
+ for (int i = 0; i < builder.mExcludeLayers.length; i++) {
+ mNativeExcludeLayers[i] = builder.mExcludeLayers[i].mNativeObject;
+ }
+ } else {
+ mNativeExcludeLayers = null;
}
}
@@ -837,7 +839,7 @@ public final class SurfaceControl implements Parcelable {
}
@Override
- public Builder getThis() {
+ Builder getThis() {
return this;
}
@@ -2293,8 +2295,14 @@ public final class SurfaceControl implements Parcelable {
throw new IllegalArgumentException("displayToken must not be null");
}
- return nativeScreenshot(display, sourceCrop, width, height, useIdentityTransform, rotation,
- false /* captureSecureLayers */);
+ DisplayCaptureArgs captureArgs = new DisplayCaptureArgs.Builder(display)
+ .setSourceCrop(sourceCrop)
+ .setSize(width, height)
+ .setUseIdentityTransform(useIdentityTransform)
+ .setRotation(rotation)
+ .build();
+
+ return nativeCaptureDisplay(captureArgs);
}
/**
@@ -2314,8 +2322,15 @@ public final class SurfaceControl implements Parcelable {
throw new IllegalArgumentException("displayToken must not be null");
}
- return nativeScreenshot(display, sourceCrop, width, height, useIdentityTransform, rotation,
- true /* captureSecureLayers */);
+ DisplayCaptureArgs captureArgs = new DisplayCaptureArgs.Builder(display)
+ .setSourceCrop(sourceCrop)
+ .setSize(width, height)
+ .setUseIdentityTransform(useIdentityTransform)
+ .setRotation(rotation)
+ .setCaptureSecureLayers(true)
+ .build();
+
+ return nativeCaptureDisplay(captureArgs);
}
private static void rotateCropForSF(Rect crop, int rot) {
@@ -2365,24 +2380,30 @@ public final class SurfaceControl implements Parcelable {
*/
public static ScreenshotHardwareBuffer captureLayers(SurfaceControl layer, Rect sourceCrop,
float frameScale, int format) {
- final IBinder displayToken = SurfaceControl.getInternalDisplayToken();
- return nativeCaptureLayers(displayToken, layer.mNativeObject, sourceCrop, frameScale, null,
- format);
+ LayerCaptureArgs captureArgs = new LayerCaptureArgs.Builder(layer)
+ .setSourceCrop(sourceCrop)
+ .setFrameScale(frameScale)
+ .setPixelFormat(format)
+ .build();
+
+ return nativeCaptureLayers(captureArgs);
}
/**
- * Like {@link captureLayers} but with an array of layer handles to exclude.
+ * Like {@link #captureLayers(SurfaceControl, Rect, float, int)} but with an array of layer
+ * handles to exclude.
* @hide
*/
public static ScreenshotHardwareBuffer captureLayersExcluding(SurfaceControl layer,
Rect sourceCrop, float frameScale, int format, SurfaceControl[] exclude) {
- final IBinder displayToken = SurfaceControl.getInternalDisplayToken();
- long[] nativeExcludeObjects = new long[exclude.length];
- for (int i = 0; i < exclude.length; i++) {
- nativeExcludeObjects[i] = exclude[i].mNativeObject;
- }
- return nativeCaptureLayers(displayToken, layer.mNativeObject, sourceCrop, frameScale,
- nativeExcludeObjects, PixelFormat.RGBA_8888);
+ LayerCaptureArgs captureArgs = new LayerCaptureArgs.Builder(layer)
+ .setSourceCrop(sourceCrop)
+ .setFrameScale(frameScale)
+ .setPixelFormat(format)
+ .setExcludeLayers(exclude)
+ .build();
+
+ return nativeCaptureLayers(captureArgs);
}
/**
diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
index 708e27771ef2..2d0f05e3dc02 100644
--- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java
+++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
@@ -1768,7 +1768,7 @@ public class AccessibilityNodeInfo implements Parcelable {
* <strong>Note:</strong> The primary usage of this API is for UI test automation
* and in order to report the fully qualified view id if an {@link AccessibilityNodeInfo}
* the client has to set the {@link AccessibilityServiceInfo#FLAG_REPORT_VIEW_IDS}
- * flag when configuring their {@link android.accessibilityservice.AccessibilityService}.
+ * flag when configuring the {@link android.accessibilityservice.AccessibilityService}.
* </p>
* <p>
* <strong>Note:</strong> If this view hierarchy has a {@link SurfaceView} embedding another
@@ -3206,7 +3206,7 @@ public class AccessibilityNodeInfo implements Parcelable {
* <strong>Note:</strong> The primary usage of this API is for UI test automation
* and in order to report the source view id of an {@link AccessibilityNodeInfo} the
* client has to set the {@link AccessibilityServiceInfo#FLAG_REPORT_VIEW_IDS}
- * flag when configuring their {@link android.accessibilityservice.AccessibilityService}.
+ * flag when configuring the {@link android.accessibilityservice.AccessibilityService}.
* </p>
* @return The id resource name.
diff --git a/core/java/android/widget/inline/InlineContentView.java b/core/java/android/widget/inline/InlineContentView.java
index 699a7735bbee..9712311aab7c 100644
--- a/core/java/android/widget/inline/InlineContentView.java
+++ b/core/java/android/widget/inline/InlineContentView.java
@@ -59,7 +59,7 @@ import java.util.function.Consumer;
*/
public class InlineContentView extends ViewGroup {
- private static final String TAG = "InlineContentView_test2";
+ private static final String TAG = "InlineContentView";
private static final boolean DEBUG = false;
diff --git a/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl b/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl
index 5a04992a35b4..ea09fc8cd34a 100644
--- a/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl
+++ b/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl
@@ -65,9 +65,7 @@ interface ITelephonyRegistry {
void notifyDataActivity(int state);
void notifyDataActivityForSubscriber(in int subId, int state);
void notifyDataConnectionForSubscriber(
- int phoneId, int subId, int apnType, in PreciseDataConnectionState preciseState);
- @UnsupportedAppUsage
- void notifyDataConnectionFailed(String apnType);
+ int phoneId, int subId, in PreciseDataConnectionState preciseState);
// Uses CellIdentity which is Parcelable here; will convert to CellLocation in client.
void notifyCellLocation(in CellIdentity cellLocation);
void notifyCellLocationForSubscriber(in int subId, in CellIdentity cellLocation);
@@ -77,8 +75,6 @@ interface ITelephonyRegistry {
int foregroundCallState, int backgroundCallState);
void notifyDisconnectCause(int phoneId, int subId, int disconnectCause,
int preciseDisconnectCause);
- void notifyPreciseDataConnectionFailed(int phoneId, int subId, int apnType, String apn,
- int failCause);
void notifyCellInfoForSubscriber(in int subId, in List<CellInfo> cellInfo);
void notifySrvccStateChanged(in int subId, in int lteState);
void notifySimActivationStateChangedForPhoneId(in int phoneId, in int subId,
diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp
index a965ab310205..814a07e7f2df 100644
--- a/core/jni/android_view_SurfaceControl.cpp
+++ b/core/jni/android_view_SurfaceControl.cpp
@@ -104,6 +104,27 @@ static struct {
jfieldID top;
} gRectClassInfo;
+static struct {
+ jfieldID pixelFormat;
+ jfieldID sourceCrop;
+ jfieldID frameScale;
+ jfieldID captureSecureLayers;
+} gCaptureArgsClassInfo;
+
+static struct {
+ jfieldID displayToken;
+ jfieldID width;
+ jfieldID height;
+ jfieldID useIdentityTransform;
+ jfieldID rotation;
+} gDisplayCaptureArgsClassInfo;
+
+static struct {
+ jfieldID layer;
+ jfieldID excludeLayers;
+ jfieldID childrenOnly;
+} gLayerCaptureArgsClassInfo;
+
// Implements SkMallocPixelRef::ReleaseProc, to delete the screenshot on unref.
void DeleteScreenshot(void* addr, void* context) {
delete ((ScreenshotClient*) context);
@@ -276,55 +297,79 @@ static Rect rectFromObj(JNIEnv* env, jobject rectObj) {
return Rect(left, top, right, bottom);
}
-static jobject nativeScreenshot(JNIEnv* env, jclass clazz,
- jobject displayTokenObj, jobject sourceCropObj, jint width, jint height,
- bool useIdentityTransform, int rotation, bool captureSecureLayers) {
- sp<IBinder> displayToken = ibinderForJavaObject(env, displayTokenObj);
- if (displayToken == NULL) {
+static void getCaptureArgs(JNIEnv* env, jobject captureArgsObject, CaptureArgs& captureArgs) {
+ captureArgs.pixelFormat = static_cast<ui::PixelFormat>(
+ env->GetIntField(captureArgsObject, gCaptureArgsClassInfo.pixelFormat));
+ captureArgs.sourceCrop =
+ rectFromObj(env,
+ env->GetObjectField(captureArgsObject, gCaptureArgsClassInfo.sourceCrop));
+ captureArgs.frameScale =
+ env->GetFloatField(captureArgsObject, gCaptureArgsClassInfo.frameScale);
+ captureArgs.captureSecureLayers =
+ env->GetBooleanField(captureArgsObject, gCaptureArgsClassInfo.captureSecureLayers);
+}
+
+static DisplayCaptureArgs displayCaptureArgsFromObject(JNIEnv* env,
+ jobject displayCaptureArgsObject) {
+ DisplayCaptureArgs captureArgs;
+ getCaptureArgs(env, displayCaptureArgsObject, captureArgs);
+
+ captureArgs.displayToken =
+ ibinderForJavaObject(env,
+ env->GetObjectField(displayCaptureArgsObject,
+ gDisplayCaptureArgsClassInfo.displayToken));
+ captureArgs.width =
+ env->GetIntField(displayCaptureArgsObject, gDisplayCaptureArgsClassInfo.width);
+ captureArgs.height =
+ env->GetIntField(displayCaptureArgsObject, gDisplayCaptureArgsClassInfo.height);
+ captureArgs.useIdentityTransform =
+ env->GetBooleanField(displayCaptureArgsObject,
+ gDisplayCaptureArgsClassInfo.useIdentityTransform);
+ captureArgs.rotation = ui::toRotation(
+ env->GetIntField(displayCaptureArgsObject, gDisplayCaptureArgsClassInfo.rotation));
+ return captureArgs;
+}
+
+static jobject nativeCaptureDisplay(JNIEnv* env, jclass clazz, jobject displayCaptureArgsObject) {
+ const DisplayCaptureArgs captureArgs =
+ displayCaptureArgsFromObject(env, displayCaptureArgsObject);
+
+ if (captureArgs.displayToken == NULL) {
return NULL;
}
- const ui::ColorMode colorMode = SurfaceComposerClient::getActiveColorMode(displayToken);
- const ui::Dataspace dataspace = pickDataspaceFromColorMode(colorMode);
-
- Rect sourceCrop = rectFromObj(env, sourceCropObj);
- sp<GraphicBuffer> buffer;
- bool capturedSecureLayers = false;
- status_t res = ScreenshotClient::capture(displayToken, dataspace,
- ui::PixelFormat::RGBA_8888,
- sourceCrop, width, height,
- useIdentityTransform, ui::toRotation(rotation),
- captureSecureLayers, &buffer, capturedSecureLayers);
+
+ ScreenCaptureResults captureResults;
+ status_t res = ScreenshotClient::captureDisplay(captureArgs, captureResults);
if (res != NO_ERROR) {
return NULL;
}
- jobject jhardwareBuffer =
- android_hardware_HardwareBuffer_createFromAHardwareBuffer(env,
- buffer->toAHardwareBuffer());
- const jint namedColorSpace = fromDataspaceToNamedColorSpaceValue(dataspace);
+ jobject jhardwareBuffer = android_hardware_HardwareBuffer_createFromAHardwareBuffer(
+ env, captureResults.buffer->toAHardwareBuffer());
+ const jint namedColorSpace =
+ fromDataspaceToNamedColorSpaceValue(captureResults.capturedDataspace);
return env->CallStaticObjectMethod(gScreenshotHardwareBufferClassInfo.clazz,
gScreenshotHardwareBufferClassInfo.builder, jhardwareBuffer,
- namedColorSpace, capturedSecureLayers);
+ namedColorSpace, captureResults.capturedSecureLayers);
}
-static jobject nativeCaptureLayers(JNIEnv* env, jclass clazz, jobject displayTokenObj,
- jlong layerObject, jobject sourceCropObj, jfloat frameScale,
- jlongArray excludeObjectArray, jint format) {
-
- auto layer = reinterpret_cast<SurfaceControl *>(layerObject);
- if (layer == NULL) {
- return NULL;
- }
-
- Rect sourceCrop;
- if (sourceCropObj != NULL) {
- sourceCrop = rectFromObj(env, sourceCropObj);
+static jobject nativeCaptureLayers(JNIEnv* env, jclass clazz, jobject layerCaptureArgsObject) {
+ LayerCaptureArgs captureArgs;
+ getCaptureArgs(env, layerCaptureArgsObject, captureArgs);
+ SurfaceControl* layer = reinterpret_cast<SurfaceControl*>(
+ env->GetLongField(layerCaptureArgsObject, gLayerCaptureArgsClassInfo.layer));
+ if (layer == nullptr) {
+ return nullptr;
}
- std::unordered_set<sp<IBinder>,ISurfaceComposer::SpHash<IBinder>> excludeHandles;
+ captureArgs.layerHandle = layer->getHandle();
+ captureArgs.childrenOnly =
+ env->GetBooleanField(layerCaptureArgsObject, gLayerCaptureArgsClassInfo.childrenOnly);
+ jlongArray excludeObjectArray = reinterpret_cast<jlongArray>(
+ env->GetObjectField(layerCaptureArgsObject, gLayerCaptureArgsClassInfo.excludeLayers));
if (excludeObjectArray != NULL) {
const jsize len = env->GetArrayLength(excludeObjectArray);
- excludeHandles.reserve(len);
+ captureArgs.excludeHandles.reserve(len);
const jlong* objects = env->GetLongArrayElements(excludeObjectArray, nullptr);
for (jsize i = 0; i < len; i++) {
@@ -333,33 +378,24 @@ static jobject nativeCaptureLayers(JNIEnv* env, jclass clazz, jobject displayTok
jniThrowNullPointerException(env, "Exclude layer is null");
return NULL;
}
- excludeHandles.emplace(excludeObject->getHandle());
+ captureArgs.excludeHandles.emplace(excludeObject->getHandle());
}
env->ReleaseLongArrayElements(excludeObjectArray, const_cast<jlong*>(objects), JNI_ABORT);
}
- sp<GraphicBuffer> buffer;
- ui::Dataspace dataspace = ui::Dataspace::V0_SRGB;
- sp<IBinder> displayToken = ibinderForJavaObject(env, displayTokenObj);
- if (displayToken != nullptr) {
- const ui::ColorMode colorMode = SurfaceComposerClient::getActiveColorMode(displayToken);
- dataspace = pickDataspaceFromColorMode(colorMode);
- }
- status_t res = ScreenshotClient::captureChildLayers(layer->getHandle(), dataspace,
- static_cast<ui::PixelFormat>(format),
- sourceCrop, excludeHandles, frameScale,
- &buffer);
+ ScreenCaptureResults captureResults;
+ status_t res = ScreenshotClient::captureLayers(captureArgs, captureResults);
if (res != NO_ERROR) {
return NULL;
}
- jobject jhardwareBuffer =
- android_hardware_HardwareBuffer_createFromAHardwareBuffer(env,
- buffer->toAHardwareBuffer());
- const jint namedColorSpace = fromDataspaceToNamedColorSpaceValue(dataspace);
+ jobject jhardwareBuffer = android_hardware_HardwareBuffer_createFromAHardwareBuffer(
+ env, captureResults.buffer->toAHardwareBuffer());
+ const jint namedColorSpace =
+ fromDataspaceToNamedColorSpaceValue(captureResults.capturedDataspace);
return env->CallStaticObjectMethod(gScreenshotHardwareBufferClassInfo.clazz,
gScreenshotHardwareBufferClassInfo.builder, jhardwareBuffer,
- namedColorSpace, false /* capturedSecureLayers */);
+ namedColorSpace, captureResults.capturedSecureLayers);
}
static void nativeApplyTransaction(JNIEnv* env, jclass clazz, jlong transactionObj, jboolean sync) {
@@ -1614,13 +1650,12 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
(void*)nativeSeverChildren } ,
{"nativeSetOverrideScalingMode", "(JJI)V",
(void*)nativeSetOverrideScalingMode },
- {"nativeScreenshot",
- "(Landroid/os/IBinder;Landroid/graphics/Rect;IIZIZ)"
+ {"nativeCaptureDisplay",
+ "(Landroid/view/SurfaceControl$DisplayCaptureArgs;)"
"Landroid/view/SurfaceControl$ScreenshotHardwareBuffer;",
- (void*)nativeScreenshot },
+ (void*)nativeCaptureDisplay },
{"nativeCaptureLayers",
- "(Landroid/os/IBinder;JLandroid/graphics/Rect;"
- "F[JI)"
+ "(Landroid/view/SurfaceControl$LayerCaptureArgs;)"
"Landroid/view/SurfaceControl$ScreenshotHardwareBuffer;",
(void*)nativeCaptureLayers },
{"nativeSetInputWindowInfo", "(JJLandroid/view/InputWindowHandle;)V",
@@ -1795,6 +1830,36 @@ int register_android_view_SurfaceControl(JNIEnv* env)
gDesiredDisplayConfigSpecsClassInfo.appRequestRefreshRateMax =
GetFieldIDOrDie(env, desiredDisplayConfigSpecsClazz, "appRequestRefreshRateMax", "F");
+ jclass captureArgsClazz = FindClassOrDie(env, "android/view/SurfaceControl$CaptureArgs");
+ gCaptureArgsClassInfo.pixelFormat = GetFieldIDOrDie(env, captureArgsClazz, "mPixelFormat", "I");
+ gCaptureArgsClassInfo.sourceCrop =
+ GetFieldIDOrDie(env, captureArgsClazz, "mSourceCrop", "Landroid/graphics/Rect;");
+ gCaptureArgsClassInfo.frameScale = GetFieldIDOrDie(env, captureArgsClazz, "mFrameScale", "F");
+ gCaptureArgsClassInfo.captureSecureLayers =
+ GetFieldIDOrDie(env, captureArgsClazz, "mCaptureSecureLayers", "Z");
+
+ jclass displayCaptureArgsClazz =
+ FindClassOrDie(env, "android/view/SurfaceControl$DisplayCaptureArgs");
+ gDisplayCaptureArgsClassInfo.displayToken =
+ GetFieldIDOrDie(env, displayCaptureArgsClazz, "mDisplayToken", "Landroid/os/IBinder;");
+ gDisplayCaptureArgsClassInfo.width =
+ GetFieldIDOrDie(env, displayCaptureArgsClazz, "mWidth", "I");
+ gDisplayCaptureArgsClassInfo.height =
+ GetFieldIDOrDie(env, displayCaptureArgsClazz, "mHeight", "I");
+ gDisplayCaptureArgsClassInfo.useIdentityTransform =
+ GetFieldIDOrDie(env, displayCaptureArgsClazz, "mUseIdentityTransform", "Z");
+ gDisplayCaptureArgsClassInfo.rotation =
+ GetFieldIDOrDie(env, displayCaptureArgsClazz, "mRotation", "I");
+
+ jclass layerCaptureArgsClazz =
+ FindClassOrDie(env, "android/view/SurfaceControl$LayerCaptureArgs");
+ gLayerCaptureArgsClassInfo.layer =
+ GetFieldIDOrDie(env, layerCaptureArgsClazz, "mNativeLayer", "J");
+ gLayerCaptureArgsClassInfo.excludeLayers =
+ GetFieldIDOrDie(env, layerCaptureArgsClazz, "mNativeExcludeLayers", "[J");
+ gLayerCaptureArgsClassInfo.childrenOnly =
+ GetFieldIDOrDie(env, layerCaptureArgsClazz, "mChildrenOnly", "Z");
+
return err;
}
diff --git a/data/keyboards/Generic.kl b/data/keyboards/Generic.kl
index 4cdfbb8ce27f..5711f98e3b75 100644
--- a/data/keyboards/Generic.kl
+++ b/data/keyboards/Generic.kl
@@ -415,6 +415,7 @@ key 583 ASSIST
key usage 0x0c0067 WINDOW
key usage 0x0c006F BRIGHTNESS_UP
key usage 0x0c0070 BRIGHTNESS_DOWN
+key usage 0x0c0173 MEDIA_AUDIO_TRACK
# Joystick and game controller axes.
# Axes that are not mapped will be assigned generic axis numbers by the input subsystem.
diff --git a/location/java/android/location/GnssAntennaInfo.java b/location/java/android/location/GnssAntennaInfo.java
index b2f9a0f41b7e..23977f18f749 100644
--- a/location/java/android/location/GnssAntennaInfo.java
+++ b/location/java/android/location/GnssAntennaInfo.java
@@ -53,7 +53,7 @@ public final class GnssAntennaInfo implements Parcelable {
* Class containing information about the antenna phase center offset (PCO). PCO is defined with
* respect to the origin of the Android sensor coordinate system, e.g., center of primary screen
* for mobiles - see sensor or form factor documents for details. Uncertainties are reported
- * to 1-sigma.
+ * to 1-sigma.
*/
public static final class PhaseCenterOffset implements Parcelable {
private final double mOffsetXMm;
@@ -95,31 +95,55 @@ public final class GnssAntennaInfo implements Parcelable {
}
};
+ /**
+ * Returns the x-axis offset of the phase center from the origin of the Android sensor
+ * coordinate system, in millimeters.
+ */
@FloatRange()
public double getXOffsetMm() {
return mOffsetXMm;
}
+ /**
+ * Returns the 1-sigma uncertainty of the x-axis offset of the phase center from the origin
+ * of the Android sensor coordinate system, in millimeters.
+ */
@FloatRange()
public double getXOffsetUncertaintyMm() {
return mOffsetXUncertaintyMm;
}
+ /**
+ * Returns the y-axis offset of the phase center from the origin of the Android sensor
+ * coordinate system, in millimeters.
+ */
@FloatRange()
public double getYOffsetMm() {
return mOffsetYMm;
}
+ /**
+ * Returns the 1-sigma uncertainty of the y-axis offset of the phase center from the origin
+ * of the Android sensor coordinate system, in millimeters.
+ */
@FloatRange()
public double getYOffsetUncertaintyMm() {
return mOffsetYUncertaintyMm;
}
+ /**
+ * Returns the z-axis offset of the phase center from the origin of the Android sensor
+ * coordinate system, in millimeters.
+ */
@FloatRange()
public double getZOffsetMm() {
return mOffsetZMm;
}
+ /**
+ * Returns the 1-sigma uncertainty of the z-axis offset of the phase center from the origin
+ * of the Android sensor coordinate system, in millimeters.
+ */
@FloatRange()
public double getZOffsetUncertaintyMm() {
return mOffsetZUncertaintyMm;
@@ -165,7 +189,7 @@ public final class GnssAntennaInfo implements Parcelable {
* at 180 degrees. They are separated by deltaPhi, the regular spacing between zenith angles,
* i.e., deltaPhi = 180 / (number of columns - 1).
*/
- public static final class SphericalCorrections implements Parcelable{
+ public static final class SphericalCorrections implements Parcelable {
private final double[][] mCorrections;
private final double[][] mCorrectionUncertainties;
private final double mDeltaTheta;
@@ -296,10 +320,10 @@ public final class GnssAntennaInfo implements Parcelable {
public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeInt(mNumRows);
dest.writeInt(mNumColumns);
- for (double[] row: mCorrections) {
+ for (double[] row : mCorrections) {
dest.writeDoubleArray(row);
}
- for (double[] row: mCorrectionUncertainties) {
+ for (double[] row : mCorrectionUncertainties) {
dest.writeDoubleArray(row);
}
}
@@ -340,6 +364,7 @@ public final class GnssAntennaInfo implements Parcelable {
/**
* Set antenna carrier frequency (MHz).
+ *
* @param carrierFrequencyMHz antenna carrier frequency (MHz)
* @return Builder builder object
*/
@@ -351,6 +376,7 @@ public final class GnssAntennaInfo implements Parcelable {
/**
* Set antenna phase center offset.
+ *
* @param phaseCenterOffset phase center offset object
* @return Builder builder object
*/
@@ -362,6 +388,7 @@ public final class GnssAntennaInfo implements Parcelable {
/**
* Set phase center variation corrections.
+ *
* @param phaseCenterVariationCorrections phase center variation corrections object
* @return Builder builder object
*/
@@ -374,6 +401,7 @@ public final class GnssAntennaInfo implements Parcelable {
/**
* Set signal gain corrections.
+ *
* @param signalGainCorrections signal gain corrections object
* @return Builder builder object
*/
@@ -386,6 +414,7 @@ public final class GnssAntennaInfo implements Parcelable {
/**
* Build GnssAntennaInfo object.
+ *
* @return instance of GnssAntennaInfo
*/
@NonNull
@@ -400,47 +429,65 @@ public final class GnssAntennaInfo implements Parcelable {
return mCarrierFrequencyMHz;
}
+ /**
+ * Returns a {@link PhaseCenterOffset} object encapsulating the phase center offset and
+ * corresponding uncertainties in millimeters.
+ *
+ * @return {@link PhaseCenterOffset}
+ */
@NonNull
public PhaseCenterOffset getPhaseCenterOffset() {
return mPhaseCenterOffset;
}
+ /**
+ * Returns a {@link SphericalCorrections} object encapsulating the phase center variation
+ * corrections and corresponding uncertainties in millimeters.
+ *
+ * @return phase center variation corrections as {@link SphericalCorrections}
+ */
@Nullable
public SphericalCorrections getPhaseCenterVariationCorrections() {
return mPhaseCenterVariationCorrections;
}
+ /**
+ * Returns a {@link SphericalCorrections} object encapsulating the signal gain
+ * corrections and corresponding uncertainties in dBi.
+ *
+ * @return signal gain corrections as {@link SphericalCorrections}
+ */
@Nullable
public SphericalCorrections getSignalGainCorrections() {
return mSignalGainCorrections;
}
- public static final @android.annotation.NonNull
- Creator<GnssAntennaInfo> CREATOR = new Creator<GnssAntennaInfo>() {
- @Override
- public GnssAntennaInfo createFromParcel(Parcel in) {
- double carrierFrequencyMHz = in.readDouble();
-
- ClassLoader classLoader = getClass().getClassLoader();
- PhaseCenterOffset phaseCenterOffset =
- in.readParcelable(classLoader);
- SphericalCorrections phaseCenterVariationCorrections =
- in.readParcelable(classLoader);
- SphericalCorrections signalGainCorrections =
- in.readParcelable(classLoader);
-
- return new GnssAntennaInfo(
- carrierFrequencyMHz,
- phaseCenterOffset,
- phaseCenterVariationCorrections,
- signalGainCorrections);
- }
-
- @Override
- public GnssAntennaInfo[] newArray(int size) {
- return new GnssAntennaInfo[size];
- }
- };
+ public static final @android.annotation.NonNull Creator<GnssAntennaInfo> CREATOR =
+ new Creator<GnssAntennaInfo>() {
+ @Override
+ public GnssAntennaInfo createFromParcel(Parcel in) {
+ double carrierFrequencyMHz = in.readDouble();
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ PhaseCenterOffset phaseCenterOffset =
+ in.readParcelable(classLoader);
+ SphericalCorrections phaseCenterVariationCorrections =
+ in.readParcelable(classLoader);
+ SphericalCorrections signalGainCorrections =
+ in.readParcelable(classLoader);
+
+ return new GnssAntennaInfo(
+ carrierFrequencyMHz,
+ phaseCenterOffset,
+ phaseCenterVariationCorrections,
+ signalGainCorrections);
+ }
+
+ @Override
+ public GnssAntennaInfo[] newArray(int size) {
+ return new GnssAntennaInfo[size];
+ }
+ };
@Override
public int describeContents() {
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index 4c03fd10f248..408f34be6b65 100755
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -4601,36 +4601,41 @@ public class AudioManager {
/**
* @hide
* Volume behavior for an audio device that has no particular volume behavior set. Invalid as
- * an argument to {@link #setDeviceVolumeBehavior(int, String, int)}.
+ * an argument to {@link #setDeviceVolumeBehavior(AudioDeviceAttributes, int)} and should not
+ * be returned by {@link #getDeviceVolumeBehavior(AudioDeviceAttributes)}.
*/
public static final int DEVICE_VOLUME_BEHAVIOR_UNSET = -1;
/**
* @hide
* Volume behavior for an audio device where a software attenuation is applied
- * @see #setDeviceVolumeBehavior(int, String, int)
+ * @see #setDeviceVolumeBehavior(AudioDeviceAttributes, int)
*/
+ @SystemApi
public static final int DEVICE_VOLUME_BEHAVIOR_VARIABLE = 0;
/**
* @hide
* Volume behavior for an audio device where the volume is always set to provide no attenuation
* nor gain (e.g. unit gain).
- * @see #setDeviceVolumeBehavior(int, String, int)
+ * @see #setDeviceVolumeBehavior(AudioDeviceAttributes, int)
*/
+ @SystemApi
public static final int DEVICE_VOLUME_BEHAVIOR_FULL = 1;
/**
* @hide
* Volume behavior for an audio device where the volume is either set to muted, or to provide
* no attenuation nor gain (e.g. unit gain).
- * @see #setDeviceVolumeBehavior(int, String, int)
+ * @see #setDeviceVolumeBehavior(AudioDeviceAttributes, int)
*/
+ @SystemApi
public static final int DEVICE_VOLUME_BEHAVIOR_FIXED = 2;
/**
* @hide
* Volume behavior for an audio device where no software attenuation is applied, and
* the volume is kept synchronized between the host and the device itself through a
* device-specific protocol such as BT AVRCP.
- * @see #setDeviceVolumeBehavior(int, String, int)
+ * @see #setDeviceVolumeBehavior(AudioDeviceAttributes, int)
*/
+ @SystemApi
public static final int DEVICE_VOLUME_BEHAVIOR_ABSOLUTE = 3;
/**
* @hide
@@ -4639,8 +4644,9 @@ public class AudioManager {
* device-specific protocol (such as for hearing aids), based on the audio mode (e.g.
* normal vs in phone call).
* @see #setMode(int)
- * @see #setDeviceVolumeBehavior(int, String, int)
+ * @see #setDeviceVolumeBehavior(AudioDeviceAttributes, int)
*/
+ @SystemApi
public static final int DEVICE_VOLUME_BEHAVIOR_ABSOLUTE_MULTI_MODE = 4;
/** @hide */
@@ -4687,27 +4693,15 @@ public class AudioManager {
/**
* @hide
* Sets the volume behavior for an audio output device.
- * @param deviceType the type of audio device to be affected. Currently only supports
- * {@link AudioDeviceInfo#TYPE_HDMI}, {@link AudioDeviceInfo#TYPE_HDMI_ARC},
- * {@link AudioDeviceInfo#TYPE_LINE_DIGITAL} and {@link AudioDeviceInfo#TYPE_AUX_LINE}
- * @param deviceAddress the address of the device, if any
- * @param deviceVolumeBehavior one of the device behaviors
- */
- @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING)
- public void setDeviceVolumeBehavior(int deviceType, @Nullable String deviceAddress,
- @DeviceVolumeBehavior int deviceVolumeBehavior) {
- setDeviceVolumeBehavior(new AudioDeviceAttributes(AudioDeviceAttributes.ROLE_OUTPUT,
- deviceType, deviceAddress), deviceVolumeBehavior);
- }
-
- /**
- * @hide
- * Sets the volume behavior for an audio output device.
- * @param device the device to be affected. Currently only supports devices of type
- * {@link AudioDeviceInfo#TYPE_HDMI}, {@link AudioDeviceInfo#TYPE_HDMI_ARC},
- * {@link AudioDeviceInfo#TYPE_LINE_DIGITAL} and {@link AudioDeviceInfo#TYPE_AUX_LINE}
+ * @see #DEVICE_VOLUME_BEHAVIOR_VARIABLE
+ * @see #DEVICE_VOLUME_BEHAVIOR_FULL
+ * @see #DEVICE_VOLUME_BEHAVIOR_FIXED
+ * @see #DEVICE_VOLUME_BEHAVIOR_ABSOLUTE
+ * @see #DEVICE_VOLUME_BEHAVIOR_ABSOLUTE_MULTI_MODE
+ * @param device the device to be affected
* @param deviceVolumeBehavior one of the device behaviors
*/
+ @SystemApi
@RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING)
public void setDeviceVolumeBehavior(@NonNull AudioDeviceAttributes device,
@DeviceVolumeBehavior int deviceVolumeBehavior) {
@@ -4726,29 +4720,14 @@ public class AudioManager {
/**
* @hide
- * Returns the volume device behavior for the given device type and address
- * @param deviceType an audio output device type, as defined in {@link AudioDeviceInfo}
- * @param deviceAddress the address of the audio device, if any.
- * @return the volume behavior for the device
- */
- @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING)
- public @DeviceVolumeBehaviorState int getDeviceVolumeBehavior(int deviceType,
- @Nullable String deviceAddress) {
- // verify arguments
- AudioDeviceInfo.enforceValidAudioDeviceTypeOut(deviceType);
- return getDeviceVolumeBehavior(new AudioDeviceAttributes(AudioDeviceAttributes.ROLE_OUTPUT,
- deviceType, deviceAddress));
- }
-
- /**
- * @hide
* Returns the volume device behavior for the given audio device
* @param device the audio device
* @return the volume behavior for the device
*/
+ @SystemApi
@RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING)
- public @DeviceVolumeBehaviorState int getDeviceVolumeBehavior(
- @NonNull AudioDeviceAttributes device) {
+ public @DeviceVolumeBehavior
+ int getDeviceVolumeBehavior(@NonNull AudioDeviceAttributes device) {
// verify arguments (validity of device type is enforced in server)
Objects.requireNonNull(device);
// communicate with service
@@ -6201,6 +6180,24 @@ public class AudioManager {
}
}
+
+ /**
+ * Retrieves the Hardware A/V synchronization ID corresponding to the given audio session ID.
+ * For more details on Hardware A/V synchronization please refer to
+ * <a href="https://source.android.com/devices/tv/multimedia-tunneling/">
+ * media tunneling documentation</a>.
+ * @param sessionId the audio session ID for which the HW A/V sync ID is retrieved.
+ * @return the HW A/V sync ID for this audio session (an integer different from 0).
+ * @throws UnsupportedOperationException if HW A/V synchronization is not supported.
+ */
+ public int getAudioHwSyncForSession(int sessionId) {
+ int hwSyncId = AudioSystem.getAudioHwSyncForSession(sessionId);
+ if (hwSyncId == AudioSystem.AUDIO_HW_SYNC_INVALID) {
+ throw new UnsupportedOperationException("HW A/V synchronization is not supported.");
+ }
+ return hwSyncId;
+ }
+
//---------------------------------------------------------
// Inner classes
//--------------------
diff --git a/media/jni/android_media_tv_Tuner.cpp b/media/jni/android_media_tv_Tuner.cpp
index 3cd40818ae2a..5770c6797404 100644
--- a/media/jni/android_media_tv_Tuner.cpp
+++ b/media/jni/android_media_tv_Tuner.cpp
@@ -291,8 +291,9 @@ MQ& Dvr::getDvrMQ() {
C2DataIdInfo::C2DataIdInfo(uint32_t index, uint64_t value) : C2Param(kParamSize, index) {
CHECK(isGlobal());
CHECK_EQ(C2Param::INFO, kind());
- DummyInfo info{value};
- memcpy(this + 1, static_cast<C2Param *>(&info) + 1, kParamSize - sizeof(C2Param));
+ mInfo = StubInfo(value);
+ memcpy(static_cast<C2Param *>(this) + 1, static_cast<C2Param *>(&mInfo) + 1,
+ kParamSize - sizeof(C2Param));
}
/////////////// MediaEvent ///////////////////////
diff --git a/media/jni/android_media_tv_Tuner.h b/media/jni/android_media_tv_Tuner.h
index 83e9db796363..fd2995917475 100644
--- a/media/jni/android_media_tv_Tuner.h
+++ b/media/jni/android_media_tv_Tuner.h
@@ -250,8 +250,9 @@ class C2DataIdInfo : public C2Param {
public:
C2DataIdInfo(uint32_t index, uint64_t value);
private:
- typedef C2GlobalParam<C2Info, C2Int64Value, 0> DummyInfo;
- static const size_t kParamSize = sizeof(DummyInfo);
+ typedef C2GlobalParam<C2Info, C2Int64Value, 0> StubInfo;
+ StubInfo mInfo;
+ static const size_t kParamSize = sizeof(StubInfo);
};
} // namespace android
diff --git a/media/jni/audioeffect/Visualizer.cpp b/media/jni/audioeffect/Visualizer.cpp
index f4d65d0a397f..a74ae5307a36 100644
--- a/media/jni/audioeffect/Visualizer.cpp
+++ b/media/jni/audioeffect/Visualizer.cpp
@@ -34,21 +34,9 @@ namespace android {
// ---------------------------------------------------------------------------
-Visualizer::Visualizer (const String16& opPackageName,
- int32_t priority,
- effect_callback_t cbf,
- void* user,
- audio_session_t sessionId)
- : AudioEffect(SL_IID_VISUALIZATION, opPackageName, NULL, priority, cbf, user, sessionId),
- mCaptureRate(CAPTURE_RATE_DEF),
- mCaptureSize(CAPTURE_SIZE_DEF),
- mSampleRate(44100000),
- mScalingMode(VISUALIZER_SCALING_MODE_NORMALIZED),
- mMeasurementMode(MEASUREMENT_MODE_NONE),
- mCaptureCallBack(NULL),
- mCaptureCbkUser(NULL)
+Visualizer::Visualizer (const String16& opPackageName)
+ : AudioEffect(opPackageName)
{
- initCaptureSize();
}
Visualizer::~Visualizer()
@@ -58,6 +46,23 @@ Visualizer::~Visualizer()
setCaptureCallBack(NULL, NULL, 0, 0);
}
+status_t Visualizer::set(int32_t priority,
+ effect_callback_t cbf,
+ void* user,
+ audio_session_t sessionId,
+ audio_io_handle_t io,
+ const AudioDeviceTypeAddr& device,
+ bool probe)
+{
+ status_t status = AudioEffect::set(
+ SL_IID_VISUALIZATION, nullptr, priority, cbf, user, sessionId, io, device, probe);
+ if (status == NO_ERROR || status == ALREADY_EXISTS) {
+ initCaptureSize();
+ }
+ return status;
+}
+
+
void Visualizer::release()
{
ALOGV("Visualizer::release()");
diff --git a/media/jni/audioeffect/Visualizer.h b/media/jni/audioeffect/Visualizer.h
index d4672a95c6d8..8b6a62f25638 100644
--- a/media/jni/audioeffect/Visualizer.h
+++ b/media/jni/audioeffect/Visualizer.h
@@ -65,14 +65,22 @@ public:
/* Constructor.
* See AudioEffect constructor for details on parameters.
*/
- Visualizer(const String16& opPackageName,
- int32_t priority = 0,
- effect_callback_t cbf = NULL,
- void* user = NULL,
- audio_session_t sessionId = AUDIO_SESSION_OUTPUT_MIX);
+ explicit Visualizer(const String16& opPackageName);
~Visualizer();
+ /**
+ * Initialize an uninitialized Visualizer.
+ * See AudioEffect 'set' function for details on parameters.
+ */
+ status_t set(int32_t priority = 0,
+ effect_callback_t cbf = NULL,
+ void* user = NULL,
+ audio_session_t sessionId = AUDIO_SESSION_OUTPUT_MIX,
+ audio_io_handle_t io = AUDIO_IO_HANDLE_NONE,
+ const AudioDeviceTypeAddr& device = {},
+ bool probe = false);
+
// Declared 'final' because we call this in ~Visualizer().
status_t setEnabled(bool enabled) final;
@@ -163,15 +171,15 @@ private:
uint32_t initCaptureSize();
Mutex mCaptureLock;
- uint32_t mCaptureRate;
- uint32_t mCaptureSize;
- uint32_t mSampleRate;
- uint32_t mScalingMode;
- uint32_t mMeasurementMode;
- capture_cbk_t mCaptureCallBack;
- void *mCaptureCbkUser;
+ uint32_t mCaptureRate = CAPTURE_RATE_DEF;
+ uint32_t mCaptureSize = CAPTURE_SIZE_DEF;
+ uint32_t mSampleRate = 44100000;
+ uint32_t mScalingMode = VISUALIZER_SCALING_MODE_NORMALIZED;
+ uint32_t mMeasurementMode = MEASUREMENT_MODE_NONE;
+ capture_cbk_t mCaptureCallBack = nullptr;
+ void *mCaptureCbkUser = nullptr;
sp<CaptureThread> mCaptureThread;
- uint32_t mCaptureFlags;
+ uint32_t mCaptureFlags = 0;
};
diff --git a/media/jni/audioeffect/android_media_AudioEffect.cpp b/media/jni/audioeffect/android_media_AudioEffect.cpp
index dbe7b4b619c9..96961ac21a2d 100644
--- a/media/jni/audioeffect/android_media_AudioEffect.cpp
+++ b/media/jni/audioeffect/android_media_AudioEffect.cpp
@@ -337,22 +337,21 @@ android_media_AudioEffect_native_setup(JNIEnv *env, jobject thiz, jobject weak_t
}
// create the native AudioEffect object
- lpAudioEffect = new AudioEffect(typeStr,
- String16(opPackageNameStr.c_str()),
- uuidStr,
- priority,
- effectCallback,
- &lpJniStorage->mCallbackData,
- (audio_session_t) sessionId,
- AUDIO_IO_HANDLE_NONE,
- device,
- probe);
+ lpAudioEffect = new AudioEffect(String16(opPackageNameStr.c_str()));
if (lpAudioEffect == 0) {
ALOGE("Error creating AudioEffect");
goto setup_failure;
}
-
+ lpAudioEffect->set(typeStr,
+ uuidStr,
+ priority,
+ effectCallback,
+ &lpJniStorage->mCallbackData,
+ (audio_session_t) sessionId,
+ AUDIO_IO_HANDLE_NONE,
+ device,
+ probe);
lStatus = AudioEffectJni::translateNativeErrorToJava(lpAudioEffect->initCheck());
if (lStatus != AUDIOEFFECT_SUCCESS && lStatus != AUDIOEFFECT_ERROR_ALREADY_EXISTS) {
ALOGE("AudioEffect initCheck failed %d", lStatus);
diff --git a/media/jni/audioeffect/android_media_Visualizer.cpp b/media/jni/audioeffect/android_media_Visualizer.cpp
index f9a77f474c50..4c5970a30a05 100644
--- a/media/jni/audioeffect/android_media_Visualizer.cpp
+++ b/media/jni/audioeffect/android_media_Visualizer.cpp
@@ -382,15 +382,15 @@ android_media_visualizer_native_setup(JNIEnv *env, jobject thiz, jobject weak_th
}
// create the native Visualizer object
- lpVisualizer = new Visualizer(String16(opPackageNameStr.c_str()),
- 0,
- android_media_visualizer_effect_callback,
- lpJniStorage,
- (audio_session_t) sessionId);
+ lpVisualizer = new Visualizer(String16(opPackageNameStr.c_str()));
if (lpVisualizer == 0) {
ALOGE("Error creating Visualizer");
goto setup_failure;
}
+ lpVisualizer->set(0,
+ android_media_visualizer_effect_callback,
+ lpJniStorage,
+ (audio_session_t) sessionId);
lStatus = translateError(lpVisualizer->initCheck());
if (lStatus != VISUALIZER_SUCCESS && lStatus != VISUALIZER_ERROR_ALREADY_EXISTS) {
diff --git a/non-updatable-api/current.txt b/non-updatable-api/current.txt
index 5aaca435e71e..54618a5da3a3 100644
--- a/non-updatable-api/current.txt
+++ b/non-updatable-api/current.txt
@@ -24189,6 +24189,7 @@ package android.media {
method @NonNull public java.util.List<android.media.AudioPlaybackConfiguration> getActivePlaybackConfigurations();
method @NonNull public java.util.List<android.media.AudioRecordingConfiguration> getActiveRecordingConfigurations();
method public int getAllowedCapturePolicy();
+ method public int getAudioHwSyncForSession(int);
method public android.media.AudioDeviceInfo[] getDevices(int);
method public java.util.List<android.media.MicrophoneInfo> getMicrophones() throws java.io.IOException;
method public int getMode();
@@ -46014,6 +46015,7 @@ package android.telephony {
method @Nullable public android.net.LinkProperties getLinkProperties();
method public int getNetworkType();
method public int getState();
+ method public int getTransportType();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.PreciseDataConnectionState> CREATOR;
}
diff --git a/non-updatable-api/system-current.txt b/non-updatable-api/system-current.txt
index 222e563d4f96..844e929774a1 100644
--- a/non-updatable-api/system-current.txt
+++ b/non-updatable-api/system-current.txt
@@ -4141,6 +4141,7 @@ package android.media {
method @IntRange(from=0) public long getAdditionalOutputDeviceDelay(@NonNull android.media.AudioDeviceInfo);
method @NonNull @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public static java.util.List<android.media.audiopolicy.AudioProductStrategy> getAudioProductStrategies();
method @NonNull @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public static java.util.List<android.media.audiopolicy.AudioVolumeGroup> getAudioVolumeGroups();
+ method @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public int getDeviceVolumeBehavior(@NonNull android.media.AudioDeviceAttributes);
method @NonNull @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public java.util.List<android.media.AudioDeviceAttributes> getDevicesForAttributes(@NonNull android.media.AudioAttributes);
method @IntRange(from=0) public long getMaxAdditionalOutputDeviceDelay(@NonNull android.media.AudioDeviceInfo);
method @IntRange(from=0) @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public int getMaxVolumeIndexForAttributes(@NonNull android.media.AudioAttributes);
@@ -4159,6 +4160,7 @@ package android.media {
method @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public int requestAudioFocus(@NonNull android.media.AudioFocusRequest, @Nullable android.media.audiopolicy.AudioPolicy);
method @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public boolean setAdditionalOutputDeviceDelay(@NonNull android.media.AudioDeviceInfo, @IntRange(from=0) long);
method public void setAudioServerStateCallback(@NonNull java.util.concurrent.Executor, @NonNull android.media.AudioManager.AudioServerStateCallback);
+ method @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public void setDeviceVolumeBehavior(@NonNull android.media.AudioDeviceAttributes, int);
method @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public void setFocusRequestResult(@NonNull android.media.AudioFocusInfo, int, @NonNull android.media.audiopolicy.AudioPolicy);
method @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public boolean setPreferredDeviceForStrategy(@NonNull android.media.audiopolicy.AudioProductStrategy, @NonNull android.media.AudioDeviceAttributes);
method @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public void setSupportedSystemUsages(@NonNull int[]);
@@ -4169,6 +4171,11 @@ package android.media {
field public static final int AUDIOFOCUS_FLAG_DELAY_OK = 1; // 0x1
field public static final int AUDIOFOCUS_FLAG_LOCK = 4; // 0x4
field public static final int AUDIOFOCUS_FLAG_PAUSES_ON_DUCKABLE_LOSS = 2; // 0x2
+ field public static final int DEVICE_VOLUME_BEHAVIOR_ABSOLUTE = 3; // 0x3
+ field public static final int DEVICE_VOLUME_BEHAVIOR_ABSOLUTE_MULTI_MODE = 4; // 0x4
+ field public static final int DEVICE_VOLUME_BEHAVIOR_FIXED = 2; // 0x2
+ field public static final int DEVICE_VOLUME_BEHAVIOR_FULL = 1; // 0x1
+ field public static final int DEVICE_VOLUME_BEHAVIOR_VARIABLE = 0; // 0x0
field @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public static final int STREAM_ASSISTANT = 11; // 0xb
field public static final int SUCCESS = 0; // 0x0
}
@@ -9706,6 +9713,7 @@ package android.telephony {
method @Deprecated public int getDataConnectionApnTypeBitMask();
method @Deprecated public int getDataConnectionFailCause();
method @Deprecated public int getDataConnectionState();
+ method public int getId();
}
public final class PreciseDisconnectCause {
diff --git a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java
index 995a3ecde6c1..f4e704ea373e 100644
--- a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java
+++ b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java
@@ -38,6 +38,8 @@ import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dock.DockManager;
import com.android.systemui.dock.DockManagerImpl;
import com.android.systemui.doze.DozeHost;
+import com.android.systemui.pip.phone.PipMenuActivity;
+import com.android.systemui.pip.phone.dagger.PipMenuActivityClass;
import com.android.systemui.plugins.qs.QSFactory;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.power.EnhancedEstimates;
@@ -142,6 +144,13 @@ public abstract class CarSystemUIModule {
mainHandler, transactionPool).build();
}
+ @Singleton
+ @PipMenuActivityClass
+ @Provides
+ static Class<?> providePipMenuActivityClass() {
+ return PipMenuActivity.class;
+ }
+
@Binds
abstract HeadsUpManager bindHeadsUpManagerPhone(HeadsUpManagerPhone headsUpManagerPhone);
diff --git a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java
index bcaee367b03c..f108e06951ef 100644
--- a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java
+++ b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java
@@ -259,18 +259,19 @@ public class DeviceDiscoveryService extends Service {
private void onDeviceFound(@Nullable DeviceFilterPair device) {
if (device == null) return;
- if (mDevicesFound.contains(device)) {
- return;
- }
-
- if (DEBUG) Log.i(LOG_TAG, "Found device " + device);
-
Handler.getMain().sendMessage(obtainMessage(
DeviceDiscoveryService::onDeviceFoundMainThread, this, device));
}
@MainThread
void onDeviceFoundMainThread(@NonNull DeviceFilterPair device) {
+ if (mDevicesFound.contains(device)) {
+ Log.i(LOG_TAG, "Skipping device " + device + " - already among found devices");
+ return;
+ }
+
+ Log.i(LOG_TAG, "Found device " + device);
+
if (mDevicesFound.isEmpty()) {
onReadyToShowUI();
}
@@ -428,10 +429,10 @@ public class DeviceDiscoveryService extends Service {
@Override
public String toString() {
- return "DeviceFilterPair{" +
- "device=" + device +
- ", filter=" + filter +
- '}';
+ return "DeviceFilterPair{"
+ + "device=" + device + " " + getDisplayName()
+ + ", filter=" + filter
+ + '}';
}
}
diff --git a/packages/FakeOemFeatures/src/com/android/fakeoemfeatures/FakeView.java b/packages/FakeOemFeatures/src/com/android/fakeoemfeatures/FakeView.java
index 276d55ee9a5e..9fe7ab655e46 100644
--- a/packages/FakeOemFeatures/src/com/android/fakeoemfeatures/FakeView.java
+++ b/packages/FakeOemFeatures/src/com/android/fakeoemfeatures/FakeView.java
@@ -26,7 +26,7 @@ import android.os.Message;
import android.view.View;
/**
- * Dummy view to emulate stuff an OEM may want to do.
+ * Fake view to emulate stuff an OEM may want to do.
*/
public class FakeView extends View {
static final long TICK_DELAY = 30*1000; // 30 seconds
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
index 87489262a420..27863ba6c857 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
@@ -697,6 +697,9 @@ class Bubble implements BubbleViewProvider {
pw.print(" desiredHeight: "); pw.println(getDesiredHeightString());
pw.print(" suppressNotif: "); pw.println(shouldSuppressNotification());
pw.print(" autoExpand: "); pw.println(shouldAutoExpand());
+ if (mExpandedView != null) {
+ mExpandedView.dump(fd, pw, args);
+ }
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index bb572191fe3c..c5639ea6fcde 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -84,6 +84,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.Dumpable;
+import com.android.systemui.bubbles.animation.StackAnimationController;
import com.android.systemui.bubbles.dagger.BubbleModule;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.model.SysUiState;
@@ -173,6 +174,12 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
@Nullable private BubbleStackView mStackView;
private BubbleIconFactory mBubbleIconFactory;
+ /**
+ * The relative position of the stack when we removed it and nulled it out. If the stack is
+ * re-created, it will re-appear at this position.
+ */
+ @Nullable private BubbleStackView.RelativeStackPosition mPositionFromRemovedStack;
+
// Tracks the id of the current (foreground) user.
private int mCurrentUserId;
// Saves notification keys of active bubbles when users are switched.
@@ -736,6 +743,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
mContext, mBubbleData, mSurfaceSynchronizer, mFloatingContentCoordinator,
mSysUiState, this::onAllBubblesAnimatedOut, this::onImeVisibilityChanged,
this::hideCurrentInputMethod);
+ mStackView.setStackStartPosition(mPositionFromRemovedStack);
mStackView.addView(mBubbleScrim);
if (mExpandListener != null) {
mStackView.setExpandListener(mExpandListener);
@@ -806,6 +814,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
try {
mAddedToWindowManager = false;
if (mStackView != null) {
+ mPositionFromRemovedStack = mStackView.getRelativeStackPosition();
mWindowManager.removeView(mStackView);
mStackView.removeView(mBubbleScrim);
mStackView = null;
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
index 318a98799013..d0f61817d1cc 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
@@ -34,6 +34,7 @@ import static com.android.systemui.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_EXPAND
import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_BUBBLES;
import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
+import android.annotation.NonNull;
import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.ActivityOptions;
@@ -77,6 +78,9 @@ import com.android.systemui.R;
import com.android.systemui.recents.TriangleShape;
import com.android.systemui.statusbar.AlphaOptimizedButton;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
/**
* Container for the expanded bubble view, handles rendering the caret and settings icon.
*/
@@ -593,14 +597,17 @@ public class BubbleExpandedView extends LinearLayout {
*/
void update(Bubble bubble) {
if (DEBUG_BUBBLE_EXPANDED_VIEW) {
- Log.d(TAG, "update: bubble=" + (bubble != null ? bubble.getKey() : "null"));
+ Log.d(TAG, "update: bubble=" + bubble);
+ }
+ if (mStackView == null) {
+ Log.w(TAG, "Stack is null for bubble: " + bubble);
+ return;
}
boolean isNew = mBubble == null || didBackingContentChange(bubble);
if (isNew || bubble != null && bubble.getKey().equals(mBubble.getKey())) {
mBubble = bubble;
mSettingsIcon.setContentDescription(getResources().getString(
R.string.bubbles_settings_button_description, bubble.getAppName()));
-
mSettingsIcon.setAccessibilityDelegate(
new AccessibilityDelegate() {
@Override
@@ -808,4 +815,15 @@ public class BubbleExpandedView extends LinearLayout {
}
return null;
}
+
+ /**
+ * Description of current expanded view state.
+ */
+ public void dump(
+ @NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) {
+ pw.print("BubbleExpandedView");
+ pw.print(" taskId: "); pw.println(mTaskId);
+ pw.print(" activityViewStatus: "); pw.println(mActivityViewStatus);
+ pw.print(" stackView: "); pw.println(mStackView);
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
index b3fbfd6a0f30..ec9644af7013 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
@@ -253,13 +253,8 @@ public class BubbleStackView extends FrameLayout
/** Layout change listener that moves the stack to the nearest valid position on rotation. */
private OnLayoutChangeListener mOrientationChangedListener;
- /** Whether the stack was on the left side of the screen prior to rotation. */
- private boolean mWasOnLeftBeforeRotation = false;
- /**
- * How far down the screen the stack was before rotation, in terms of percentage of the way down
- * the allowable region. Defaults to -1 if not set.
- */
- private float mVerticalPosPercentBeforeRotation = -1;
+
+ @Nullable private RelativeStackPosition mRelativeStackPositionBeforeRotation;
private int mMaxBubbles;
private int mBubbleSize;
@@ -940,9 +935,10 @@ public class BubbleStackView extends FrameLayout
mExpandedViewContainer.setTranslationY(getExpandedViewY());
mExpandedViewContainer.setAlpha(1f);
}
- if (mVerticalPosPercentBeforeRotation >= 0) {
- mStackAnimationController.moveStackToSimilarPositionAfterRotation(
- mWasOnLeftBeforeRotation, mVerticalPosPercentBeforeRotation);
+ if (mRelativeStackPositionBeforeRotation != null) {
+ mStackAnimationController.setStackPosition(
+ mRelativeStackPositionBeforeRotation);
+ mRelativeStackPositionBeforeRotation = null;
}
removeOnLayoutChangeListener(mOrientationChangedListener);
};
@@ -1189,13 +1185,7 @@ public class BubbleStackView extends FrameLayout
com.android.internal.R.dimen.status_bar_height);
mBubblePaddingTop = res.getDimensionPixelSize(R.dimen.bubble_padding_top);
- final RectF allowablePos = mStackAnimationController.getAllowableStackPositionRegion();
- mWasOnLeftBeforeRotation = mStackAnimationController.isStackOnLeftSide();
- mVerticalPosPercentBeforeRotation =
- (mStackAnimationController.getStackPosition().y - allowablePos.top)
- / (allowablePos.bottom - allowablePos.top);
- mVerticalPosPercentBeforeRotation =
- Math.max(0f, Math.min(1f, mVerticalPosPercentBeforeRotation));
+ mRelativeStackPositionBeforeRotation = mStackAnimationController.getRelativeStackPosition();
addOnLayoutChangeListener(mOrientationChangedListener);
hideFlyoutImmediate();
@@ -1459,7 +1449,7 @@ public class BubbleStackView extends FrameLayout
if (getBubbleCount() == 0 && mShouldShowUserEducation) {
// Override the default stack position if we're showing user education.
mStackAnimationController.setStackPosition(
- mStackAnimationController.getDefaultStartPosition());
+ mStackAnimationController.getStartPosition());
}
if (getBubbleCount() == 0) {
@@ -1674,7 +1664,7 @@ public class BubbleStackView extends FrameLayout
// Post so we have height of mUserEducationView
mUserEducationView.post(() -> {
final int viewHeight = mUserEducationView.getHeight();
- PointF stackPosition = mStackAnimationController.getDefaultStartPosition();
+ PointF stackPosition = mStackAnimationController.getStartPosition();
final float translationY = stackPosition.y + (mBubbleSize / 2) - (viewHeight / 2);
mUserEducationView.setTranslationY(translationY);
mUserEducationView.animate()
@@ -2740,10 +2730,18 @@ public class BubbleStackView extends FrameLayout
.floatValue();
}
+ public void setStackStartPosition(RelativeStackPosition position) {
+ mStackAnimationController.setStackStartPosition(position);
+ }
+
public PointF getStackPosition() {
return mStackAnimationController.getStackPosition();
}
+ public RelativeStackPosition getRelativeStackPosition() {
+ return mStackAnimationController.getRelativeStackPosition();
+ }
+
/**
* Logs the bubble UI event.
*
@@ -2797,4 +2795,47 @@ public class BubbleStackView extends FrameLayout
}
return bubbles;
}
+
+ /**
+ * Representation of stack position that uses relative properties rather than absolute
+ * coordinates. This is used to maintain similar stack positions across configuration changes.
+ */
+ public static class RelativeStackPosition {
+ /** Whether to place the stack at the leftmost allowed position. */
+ private boolean mOnLeft;
+
+ /**
+ * How far down the vertically allowed region to place the stack. For example, if the stack
+ * allowed region is between y = 100 and y = 1100 and this is 0.2f, we'll place the stack at
+ * 100 + (0.2f * 1000) = 300.
+ */
+ private float mVerticalOffsetPercent;
+
+ public RelativeStackPosition(boolean onLeft, float verticalOffsetPercent) {
+ mOnLeft = onLeft;
+ mVerticalOffsetPercent = clampVerticalOffsetPercent(verticalOffsetPercent);
+ }
+
+ /** Constructs a relative position given a region and a point in that region. */
+ public RelativeStackPosition(PointF position, RectF region) {
+ mOnLeft = position.x < region.width() / 2;
+ mVerticalOffsetPercent =
+ clampVerticalOffsetPercent((position.y - region.top) / region.height());
+ }
+
+ /** Ensures that the offset percent is between 0f and 1f. */
+ private float clampVerticalOffsetPercent(float offsetPercent) {
+ return Math.max(0f, Math.min(1f, offsetPercent));
+ }
+
+ /**
+ * Given an allowable stack position region, returns the point within that region
+ * represented by this relative position.
+ */
+ public PointF getAbsolutePositionInRegion(RectF region) {
+ return new PointF(
+ mOnLeft ? region.left : region.right,
+ region.top + mVerticalOffsetPercent * region.height());
+ }
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleViewInfoTask.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleViewInfoTask.java
index 1929fc4e9dbf..5749169b881a 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleViewInfoTask.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleViewInfoTask.java
@@ -103,11 +103,12 @@ public class BubbleViewInfoTask extends AsyncTask<Void, Void, BubbleViewInfoTask
@Override
protected void onPostExecute(BubbleViewInfo viewInfo) {
- if (viewInfo != null) {
- mBubble.setViewInfo(viewInfo);
- if (mCallback != null && !isCancelled()) {
- mCallback.onBubbleViewsReady(mBubble);
- }
+ if (isCancelled() || viewInfo == null) {
+ return;
+ }
+ mBubble.setViewInfo(viewInfo);
+ if (mCallback != null) {
+ mCallback.onBubbleViewsReady(mBubble);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java b/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java
index b378469c4c98..e835ea206e59 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java
@@ -35,6 +35,7 @@ import androidx.dynamicanimation.animation.SpringAnimation;
import androidx.dynamicanimation.animation.SpringForce;
import com.android.systemui.R;
+import com.android.systemui.bubbles.BubbleStackView;
import com.android.systemui.util.FloatingContentCoordinator;
import com.android.systemui.util.animation.PhysicsAnimator;
import com.android.systemui.util.magnetictarget.MagnetizedObject;
@@ -125,6 +126,9 @@ public class StackAnimationController extends
*/
private Rect mAnimatingToBounds = new Rect();
+ /** Initial starting location for the stack. */
+ @Nullable private BubbleStackView.RelativeStackPosition mStackStartPosition;
+
/** Whether or not the stack's start position has been set. */
private boolean mStackMovedToStartPosition = false;
@@ -431,21 +435,6 @@ public class StackAnimationController extends
return stackPos;
}
- /**
- * Moves the stack in response to rotation. We keep it in the most similar position by keeping
- * it on the same side, and positioning it the same percentage of the way down the screen
- * (taking status bar/nav bar into account by using the allowable region's height).
- */
- public void moveStackToSimilarPositionAfterRotation(boolean wasOnLeft, float verticalPercent) {
- final RectF allowablePos = getAllowableStackPositionRegion();
- final float allowableRegionHeight = allowablePos.bottom - allowablePos.top;
-
- final float x = wasOnLeft ? allowablePos.left : allowablePos.right;
- final float y = (allowableRegionHeight * verticalPercent) + allowablePos.top;
-
- setStackPosition(new PointF(x, y));
- }
-
/** Description of current animation controller state. */
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
pw.println("StackAnimationController state:");
@@ -815,7 +804,7 @@ public class StackAnimationController extends
} else {
// When all children are removed ensure stack position is sane
setStackPosition(mRestingStackPosition == null
- ? getDefaultStartPosition()
+ ? getStartPosition()
: mRestingStackPosition);
// Remove the stack from the coordinator since we don't have any bubbles and aren't
@@ -868,7 +857,7 @@ public class StackAnimationController extends
mLayout.setVisibility(View.INVISIBLE);
mLayout.post(() -> {
setStackPosition(mRestingStackPosition == null
- ? getDefaultStartPosition()
+ ? getStartPosition()
: mRestingStackPosition);
mStackMovedToStartPosition = true;
mLayout.setVisibility(View.VISIBLE);
@@ -938,15 +927,47 @@ public class StackAnimationController extends
}
}
- /** Returns the default stack position, which is on the top left. */
- public PointF getDefaultStartPosition() {
- boolean isRtl = mLayout != null
- && mLayout.getResources().getConfiguration().getLayoutDirection()
- == View.LAYOUT_DIRECTION_RTL;
- return new PointF(isRtl
- ? getAllowableStackPositionRegion().right
- : getAllowableStackPositionRegion().left,
- getAllowableStackPositionRegion().top + mStackStartingVerticalOffset);
+ public void setStackPosition(BubbleStackView.RelativeStackPosition position) {
+ setStackPosition(position.getAbsolutePositionInRegion(getAllowableStackPositionRegion()));
+ }
+
+ public BubbleStackView.RelativeStackPosition getRelativeStackPosition() {
+ return new BubbleStackView.RelativeStackPosition(
+ mStackPosition, getAllowableStackPositionRegion());
+ }
+
+ /**
+ * Sets the starting position for the stack, where it will be located when the first bubble is
+ * added.
+ */
+ public void setStackStartPosition(BubbleStackView.RelativeStackPosition position) {
+ mStackStartPosition = position;
+ }
+
+ /**
+ * Returns the starting stack position. If {@link #setStackStartPosition} was called, this will
+ * return that position - otherwise, a reasonable default will be returned.
+ */
+ @Nullable public PointF getStartPosition() {
+ if (mLayout == null) {
+ return null;
+ }
+
+ if (mStackStartPosition == null) {
+ // Start on the left if we're in LTR, right otherwise.
+ final boolean startOnLeft =
+ mLayout.getResources().getConfiguration().getLayoutDirection()
+ != View.LAYOUT_DIRECTION_RTL;
+
+ final float startingVerticalOffset = mLayout.getResources().getDimensionPixelOffset(
+ R.dimen.bubble_stack_starting_offset_y);
+
+ mStackStartPosition = new BubbleStackView.RelativeStackPosition(
+ startOnLeft,
+ startingVerticalOffset / getAllowableStackPositionRegion().height());
+ }
+
+ return mStackStartPosition.getAbsolutePositionInRegion(getAllowableStackPositionRegion());
}
private boolean isStackPositionSet() {
diff --git a/packages/SystemUI/src/com/android/systemui/controls/CustomIconCache.kt b/packages/SystemUI/src/com/android/systemui/controls/CustomIconCache.kt
new file mode 100644
index 000000000000..cca0f1653757
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/controls/CustomIconCache.kt
@@ -0,0 +1,76 @@
+/*
+ * 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.systemui.controls
+
+import android.content.ComponentName
+import android.graphics.drawable.Icon
+import androidx.annotation.GuardedBy
+import javax.inject.Inject
+import javax.inject.Singleton
+
+/**
+ * Icon cache for custom icons sent with controls.
+ *
+ * It assumes that only one component can be current at the time, to minimize the number of icons
+ * stored at a given time.
+ */
+@Singleton
+class CustomIconCache @Inject constructor() {
+
+ private var currentComponent: ComponentName? = null
+ @GuardedBy("cache")
+ private val cache: MutableMap<String, Icon> = LinkedHashMap()
+
+ /**
+ * Store an icon in the cache.
+ *
+ * If the icons currently stored do not correspond to the component to be stored, the cache is
+ * cleared first.
+ */
+ fun store(component: ComponentName, controlId: String, icon: Icon?) {
+ if (component != currentComponent) {
+ clear()
+ currentComponent = component
+ }
+ synchronized(cache) {
+ if (icon != null) {
+ cache.put(controlId, icon)
+ } else {
+ cache.remove(controlId)
+ }
+ }
+ }
+
+ /**
+ * Retrieves a custom icon stored in the cache.
+ *
+ * It will return null if the component requested is not the one whose icons are stored, or if
+ * there is no icon cached for that id.
+ */
+ fun retrieve(component: ComponentName, controlId: String): Icon? {
+ if (component != currentComponent) return null
+ return synchronized(cache) {
+ cache.get(controlId)
+ }
+ }
+
+ private fun clear() {
+ synchronized(cache) {
+ cache.clear()
+ }
+ }
+} \ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsEditingActivity.kt b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsEditingActivity.kt
index ff40a8a883ae..f68388d5db3f 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsEditingActivity.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsEditingActivity.kt
@@ -29,6 +29,7 @@ import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.RecyclerView
import com.android.systemui.R
import com.android.systemui.broadcast.BroadcastDispatcher
+import com.android.systemui.controls.CustomIconCache
import com.android.systemui.controls.controller.ControlsControllerImpl
import com.android.systemui.controls.controller.StructureInfo
import com.android.systemui.globalactions.GlobalActionsComponent
@@ -42,7 +43,8 @@ import javax.inject.Inject
class ControlsEditingActivity @Inject constructor(
private val controller: ControlsControllerImpl,
broadcastDispatcher: BroadcastDispatcher,
- private val globalActionsComponent: GlobalActionsComponent
+ private val globalActionsComponent: GlobalActionsComponent,
+ private val customIconCache: CustomIconCache
) : LifecycleActivity() {
companion object {
@@ -170,7 +172,7 @@ class ControlsEditingActivity @Inject constructor(
private fun setUpList() {
val controls = controller.getFavoritesForStructure(component, structure)
- model = FavoritesModel(component, controls, favoritesModelCallback)
+ model = FavoritesModel(customIconCache, component, controls, favoritesModelCallback)
val elevation = resources.getFloat(R.dimen.control_card_elevation)
val recyclerView = requireViewById<RecyclerView>(R.id.list)
recyclerView.alpha = 0.0f
diff --git a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsModel.kt b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsModel.kt
index 4ef64a5cddbf..ad0e7a541f98 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsModel.kt
@@ -114,11 +114,27 @@ data class ControlStatusWrapper(
val controlStatus: ControlStatus
) : ElementWrapper(), ControlInterface by controlStatus
+private fun nullIconGetter(_a: ComponentName, _b: String): Icon? = null
+
data class ControlInfoWrapper(
override val component: ComponentName,
val controlInfo: ControlInfo,
override var favorite: Boolean
) : ElementWrapper(), ControlInterface {
+
+ var customIconGetter: (ComponentName, String) -> Icon? = ::nullIconGetter
+ private set
+
+ // Separate constructor so the getter is not used in auto-generated methods
+ constructor(
+ component: ComponentName,
+ controlInfo: ControlInfo,
+ favorite: Boolean,
+ customIconGetter: (ComponentName, String) -> Icon?
+ ): this(component, controlInfo, favorite) {
+ this.customIconGetter = customIconGetter
+ }
+
override val controlId: String
get() = controlInfo.controlId
override val title: CharSequence
@@ -128,8 +144,7 @@ data class ControlInfoWrapper(
override val deviceType: Int
get() = controlInfo.deviceType
override val customIcon: Icon?
- // Will need to address to support for edit activity
- get() = null
+ get() = customIconGetter(component, controlId)
}
data class DividerWrapper(
diff --git a/packages/SystemUI/src/com/android/systemui/controls/management/FavoritesModel.kt b/packages/SystemUI/src/com/android/systemui/controls/management/FavoritesModel.kt
index 524250134e9b..f9ce6362f4f8 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/management/FavoritesModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/management/FavoritesModel.kt
@@ -21,6 +21,7 @@ import android.util.Log
import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.RecyclerView
import com.android.systemui.controls.ControlInterface
+import com.android.systemui.controls.CustomIconCache
import com.android.systemui.controls.controller.ControlInfo
import java.util.Collections
@@ -35,6 +36,7 @@ import java.util.Collections
* @property favoritesModelCallback callback to notify on first change and empty favorites
*/
class FavoritesModel(
+ private val customIconCache: CustomIconCache,
private val componentName: ComponentName,
favorites: List<ControlInfo>,
private val favoritesModelCallback: FavoritesModelCallback
@@ -83,7 +85,7 @@ class FavoritesModel(
}
override val elements: List<ElementWrapper> = favorites.map {
- ControlInfoWrapper(componentName, it, true)
+ ControlInfoWrapper(componentName, it, true, customIconCache::retrieve)
} + DividerWrapper()
/**
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt
index 22d6b6bb75c3..e15380b42a78 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt
@@ -92,7 +92,7 @@ class ControlActionCoordinatorImpl @Inject constructor(
override fun setValue(cvh: ControlViewHolder, templateId: String, newValue: Float) {
bouncerOrRun(Action(cvh.cws.ci.controlId, {
cvh.action(FloatAction(templateId, newValue))
- }, true /* blockable */))
+ }, false /* blockable */))
}
override fun longPress(cvh: ControlViewHolder) {
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt
index 1eb7e2168a6a..5f75c96be128 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt
@@ -44,6 +44,7 @@ import android.widget.Space
import android.widget.TextView
import com.android.systemui.R
import com.android.systemui.controls.ControlsServiceInfo
+import com.android.systemui.controls.CustomIconCache
import com.android.systemui.controls.controller.ControlInfo
import com.android.systemui.controls.controller.ControlsController
import com.android.systemui.controls.controller.StructureInfo
@@ -75,7 +76,8 @@ class ControlsUiControllerImpl @Inject constructor (
@Main val sharedPreferences: SharedPreferences,
val controlActionCoordinator: ControlActionCoordinator,
private val activityStarter: ActivityStarter,
- private val shadeController: ShadeController
+ private val shadeController: ShadeController,
+ private val iconCache: CustomIconCache
) : ControlsUiController {
companion object {
@@ -502,6 +504,7 @@ class ControlsUiControllerImpl @Inject constructor (
controls.forEach { c ->
controlsById.get(ControlKey(componentName, c.getControlId()))?.let {
Log.d(ControlsUiController.TAG, "onRefreshState() for id: " + c.getControlId())
+ iconCache.store(componentName, c.controlId, c.customIcon)
val cws = ControlWithState(componentName, it.ci, c)
val key = ControlKey(componentName, c.getControlId())
controlsById.put(key, cws)
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIRootComponent.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIRootComponent.java
index 900c11f0830e..9fdbb6daca51 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIRootComponent.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIRootComponent.java
@@ -29,7 +29,6 @@ import com.android.systemui.dump.DumpManager;
import com.android.systemui.fragments.FragmentService;
import com.android.systemui.keyguard.KeyguardSliceProvider;
import com.android.systemui.onehanded.dagger.OneHandedModule;
-import com.android.systemui.pip.phone.PipMenuActivity;
import com.android.systemui.pip.phone.dagger.PipModule;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.util.InjectionInflationController;
@@ -133,9 +132,4 @@ public interface SystemUIRootComponent {
* Member injection into the supplied argument.
*/
void inject(KeyguardSliceProvider keyguardSliceProvider);
-
- /**
- * Member injection into the supplied argument.
- */
- void inject(PipMenuActivity pipMenuActivity);
}
diff --git a/packages/SystemUI/src/com/android/systemui/pip/PipAnimationController.java b/packages/SystemUI/src/com/android/systemui/pip/PipAnimationController.java
index 72019315139b..4931388fe362 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/PipAnimationController.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/PipAnimationController.java
@@ -53,16 +53,16 @@ public class PipAnimationController {
public static final int TRANSITION_DIRECTION_NONE = 0;
public static final int TRANSITION_DIRECTION_SAME = 1;
public static final int TRANSITION_DIRECTION_TO_PIP = 2;
- public static final int TRANSITION_DIRECTION_TO_FULLSCREEN = 3;
- public static final int TRANSITION_DIRECTION_TO_SPLIT_SCREEN = 4;
+ public static final int TRANSITION_DIRECTION_LEAVE_PIP = 3;
+ public static final int TRANSITION_DIRECTION_LEAVE_PIP_TO_SPLIT_SCREEN = 4;
public static final int TRANSITION_DIRECTION_REMOVE_STACK = 5;
@IntDef(prefix = { "TRANSITION_DIRECTION_" }, value = {
TRANSITION_DIRECTION_NONE,
TRANSITION_DIRECTION_SAME,
TRANSITION_DIRECTION_TO_PIP,
- TRANSITION_DIRECTION_TO_FULLSCREEN,
- TRANSITION_DIRECTION_TO_SPLIT_SCREEN,
+ TRANSITION_DIRECTION_LEAVE_PIP,
+ TRANSITION_DIRECTION_LEAVE_PIP_TO_SPLIT_SCREEN,
TRANSITION_DIRECTION_REMOVE_STACK
})
@Retention(RetentionPolicy.SOURCE)
@@ -73,8 +73,8 @@ public class PipAnimationController {
}
public static boolean isOutPipDirection(@TransitionDirection int direction) {
- return direction == TRANSITION_DIRECTION_TO_FULLSCREEN
- || direction == TRANSITION_DIRECTION_TO_SPLIT_SCREEN;
+ return direction == TRANSITION_DIRECTION_LEAVE_PIP
+ || direction == TRANSITION_DIRECTION_LEAVE_PIP_TO_SPLIT_SCREEN;
}
private final PipSurfaceTransactionHelper mSurfaceTransactionHelper;
diff --git a/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java b/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java
index 312d6d62128f..7c3743bd8bcf 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java
@@ -23,12 +23,12 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static com.android.systemui.pip.PipAnimationController.ANIM_TYPE_ALPHA;
import static com.android.systemui.pip.PipAnimationController.ANIM_TYPE_BOUNDS;
+import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_LEAVE_PIP;
+import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_LEAVE_PIP_TO_SPLIT_SCREEN;
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_NONE;
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_REMOVE_STACK;
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_SAME;
-import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_TO_FULLSCREEN;
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_TO_PIP;
-import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_TO_SPLIT_SCREEN;
import static com.android.systemui.pip.PipAnimationController.isInPipDirection;
import static com.android.systemui.pip.PipAnimationController.isOutPipDirection;
@@ -285,8 +285,8 @@ public class PipTaskOrganizer extends TaskOrganizer implements
final WindowContainerTransaction wct = new WindowContainerTransaction();
final Rect destinationBounds = initialConfig.windowConfiguration.getBounds();
final int direction = syncWithSplitScreenBounds(destinationBounds)
- ? TRANSITION_DIRECTION_TO_SPLIT_SCREEN
- : TRANSITION_DIRECTION_TO_FULLSCREEN;
+ ? TRANSITION_DIRECTION_LEAVE_PIP_TO_SPLIT_SCREEN
+ : TRANSITION_DIRECTION_LEAVE_PIP;
if (orientationDiffers) {
// Send started callback though animation is ignored.
sendOnPipTransitionStarted(direction);
@@ -303,7 +303,10 @@ public class PipTaskOrganizer extends TaskOrganizer implements
mSurfaceTransactionHelper.scale(tx, mLeash, destinationBounds,
mLastReportedBounds);
tx.setWindowCrop(mLeash, destinationBounds.width(), destinationBounds.height());
- wct.setActivityWindowingMode(mToken, direction == TRANSITION_DIRECTION_TO_SPLIT_SCREEN
+ // We set to fullscreen here for now, but later it will be set to UNDEFINED for
+ // the proper windowing mode to take place. See #applyWindowingModeChangeOnExit.
+ wct.setActivityWindowingMode(mToken,
+ direction == TRANSITION_DIRECTION_LEAVE_PIP_TO_SPLIT_SCREEN
? WINDOWING_MODE_SPLIT_SCREEN_SECONDARY
: WINDOWING_MODE_FULLSCREEN);
wct.setBounds(mToken, destinationBounds);
@@ -327,7 +330,7 @@ public class PipTaskOrganizer extends TaskOrganizer implements
wct.setWindowingMode(mToken, getOutPipWindowingMode());
// Simply reset the activity mode set prior to the animation running.
wct.setActivityWindowingMode(mToken, WINDOWING_MODE_UNDEFINED);
- if (mSplitDivider != null && direction == TRANSITION_DIRECTION_TO_SPLIT_SCREEN) {
+ if (mSplitDivider != null && direction == TRANSITION_DIRECTION_LEAVE_PIP_TO_SPLIT_SCREEN) {
wct.reparent(mToken, mSplitDivider.getSecondaryRoot(), true /* onTop */);
}
}
@@ -842,7 +845,7 @@ public class PipTaskOrganizer extends TaskOrganizer implements
} else if (isOutPipDirection(direction)) {
// If we are animating to fullscreen, then we need to reset the override bounds
// on the task to ensure that the task "matches" the parent's bounds.
- taskBounds = (direction == TRANSITION_DIRECTION_TO_FULLSCREEN)
+ taskBounds = (direction == TRANSITION_DIRECTION_LEAVE_PIP)
? null : destinationBounds;
applyWindowingModeChangeOnExit(wct, direction);
} else {
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipAccessibilityInteractionConnection.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipAccessibilityInteractionConnection.java
index c715398d52da..a13318990f40 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipAccessibilityInteractionConnection.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipAccessibilityInteractionConnection.java
@@ -131,7 +131,7 @@ public class PipAccessibilityInteractionConnection
result = true;
break;
case AccessibilityNodeInfo.ACTION_EXPAND:
- mMotionHelper.expandPipToFullscreen();
+ mMotionHelper.expandLeavePip();
result = true;
break;
default:
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
index 582cd046f9e0..6e75253d8604 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
@@ -47,6 +47,7 @@ import com.android.systemui.pip.BasePipManager;
import com.android.systemui.pip.PipBoundsHandler;
import com.android.systemui.pip.PipSnapAlgorithm;
import com.android.systemui.pip.PipTaskOrganizer;
+import com.android.systemui.pip.phone.dagger.PipMenuActivityClass;
import com.android.systemui.shared.recents.IPinnedStackAnimationListener;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.InputConsumerController;
@@ -181,7 +182,7 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
!= WINDOWING_MODE_PINNED) {
return;
}
- mTouchHandler.getMotionHelper().expandPipToFullscreen(clearedTask /* skipAnimation */);
+ mTouchHandler.getMotionHelper().expandLeavePip(clearedTask /* skipAnimation */);
}
};
@@ -250,6 +251,7 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
@Inject
public PipManager(Context context, BroadcastDispatcher broadcastDispatcher,
+ @PipMenuActivityClass Class<?> pipMenuActivityClass,
DisplayController displayController,
FloatingContentCoordinator floatingContentCoordinator,
DeviceConfigProxy deviceConfig,
@@ -274,8 +276,8 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
mPipTaskOrganizer.registerPipTransitionCallback(this);
mInputConsumerController = InputConsumerController.getPipInputConsumer();
mMediaController = new PipMediaController(context, mActivityManager, broadcastDispatcher);
- mMenuController = new PipMenuActivityController(context, mMediaController,
- mInputConsumerController);
+ mMenuController = new PipMenuActivityController(context, pipMenuActivityClass,
+ mMediaController, mInputConsumerController);
mTouchHandler = new PipTouchHandler(context, mActivityManager,
mMenuController, mInputConsumerController, mPipBoundsHandler, mPipTaskOrganizer,
floatingContentCoordinator, deviceConfig, pipSnapAlgorithm, sysUiState);
@@ -318,7 +320,7 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
*/
@Override
public void expandPip() {
- mTouchHandler.getMotionHelper().expandPipToFullscreen(false /* skipAnimation */);
+ mTouchHandler.getMotionHelper().expandLeavePip(false /* skipAnimation */);
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
index d6f3e163ad70..1b1b2de05883 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
@@ -76,17 +76,15 @@ import android.widget.ImageButton;
import android.widget.LinearLayout;
import com.android.systemui.Interpolators;
-import com.android.systemui.SystemUIFactory;
import com.android.wm.shell.R;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import javax.inject.Inject;
-
/**
* Translucent activity that gets started on top of a task in PIP to allow the user to control it.
+ * TODO(b/150319024): PipMenuActivity will move to a Window
*/
public class PipMenuActivity extends Activity {
@@ -126,19 +124,11 @@ public class PipMenuActivity extends Activity {
private final List<RemoteAction> mActions = new ArrayList<>();
private AccessibilityManager mAccessibilityManager;
- private View mViewRoot;
private Drawable mBackgroundDrawable;
private View mMenuContainer;
private LinearLayout mActionsGroup;
- private View mSettingsButton;
- private View mDismissButton;
- private View mResizeHandle;
- private View mTopEndContainer;
private int mBetweenActionPaddingLand;
- @Inject
- PipMenuIconsAlgorithm mPipMenuIconsAlgorithm;
-
private AnimatorSet mMenuContainerAnimator;
private ValueAnimator.AnimatorUpdateListener mMenuBgUpdateListener =
@@ -193,6 +183,9 @@ public class PipMenuActivity extends Activity {
break;
}
case MESSAGE_MENU_EXPANDED : {
+ if (mMenuContainerAnimator == null) {
+ return;
+ }
mMenuContainerAnimator.setStartDelay(MENU_SHOW_ON_EXPAND_START_DELAY);
mMenuContainerAnimator.start();
break;
@@ -202,6 +195,9 @@ public class PipMenuActivity extends Activity {
break;
}
case MESSAGE_UPDATE_MENU_LAYOUT: {
+ if (mPipMenuIconsAlgorithm == null) {
+ return;
+ }
final Rect bounds = (Rect) msg.obj;
mPipMenuIconsAlgorithm.onBoundsChanged(bounds);
break;
@@ -214,6 +210,13 @@ public class PipMenuActivity extends Activity {
private final Runnable mFinishRunnable = this::hideMenu;
+ protected View mViewRoot;
+ protected View mSettingsButton;
+ protected View mDismissButton;
+ protected View mResizeHandle;
+ protected View mTopEndContainer;
+ protected PipMenuIconsAlgorithm mPipMenuIconsAlgorithm;
+
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
// Set the flags to allow us to watch for outside touches and also hide the menu and start
@@ -222,8 +225,6 @@ public class PipMenuActivity extends Activity {
super.onCreate(savedInstanceState);
- SystemUIFactory.getInstance().getRootComponent().inject(this);
-
setContentView(R.layout.pip_menu_activity);
mAccessibilityManager = getSystemService(AccessibilityManager.class);
@@ -254,7 +255,7 @@ public class PipMenuActivity extends Activity {
mActionsGroup = findViewById(R.id.actions_group);
mBetweenActionPaddingLand = getResources().getDimensionPixelSize(
R.dimen.pip_between_action_padding_land);
-
+ mPipMenuIconsAlgorithm = new PipMenuIconsAlgorithm(this.getApplicationContext());
mPipMenuIconsAlgorithm.bindViews((ViewGroup) mViewRoot, (ViewGroup) mTopEndContainer,
mResizeHandle, mSettingsButton, mDismissButton);
updateFromIntent(getIntent());
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java
index 267c5eacd139..383f6b3bf79d 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java
@@ -110,6 +110,8 @@ public class PipMenuActivityController {
void onPipShowMenu();
}
+ /** TODO(b/150319024): PipMenuActivity will move to a Window */
+ private Class<?> mPipMenuActivityClass;
private Context mContext;
private PipMediaController mMediaController;
private InputConsumerController mInputConsumerController;
@@ -185,11 +187,13 @@ public class PipMenuActivityController {
}
};
- public PipMenuActivityController(Context context,
- PipMediaController mediaController, InputConsumerController inputConsumerController) {
+ public PipMenuActivityController(Context context, Class<?> pipMenuActivityClass,
+ PipMediaController mediaController, InputConsumerController inputConsumerController
+ ) {
mContext = context;
mMediaController = mediaController;
mInputConsumerController = inputConsumerController;
+ mPipMenuActivityClass = pipMenuActivityClass;
}
public boolean isMenuActivityVisible() {
@@ -454,7 +458,7 @@ public class PipMenuActivityController {
WINDOWING_MODE_PINNED, ACTIVITY_TYPE_UNDEFINED);
if (pinnedStackInfo != null && pinnedStackInfo.taskIds != null &&
pinnedStackInfo.taskIds.length > 0) {
- Intent intent = new Intent(mContext, PipMenuActivity.class);
+ Intent intent = new Intent(mContext, mPipMenuActivityClass);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(EXTRA_CONTROLLER_MESSENGER, mMessenger);
intent.putExtra(EXTRA_ACTIONS, resolveMenuActions());
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuIconsAlgorithm.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuIconsAlgorithm.java
index 69a04d8d3e22..6cfed070198b 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuIconsAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuIconsAlgorithm.java
@@ -24,8 +24,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
-import javax.inject.Inject;
-
/**
* Helper class to calculate and place the menu icons on the PIP Menu.
*/
@@ -40,8 +38,7 @@ public class PipMenuIconsAlgorithm {
protected View mSettingsButton;
protected View mDismissButton;
- @Inject
- public PipMenuIconsAlgorithm(Context context) {
+ protected PipMenuIconsAlgorithm(Context context) {
}
/**
@@ -56,7 +53,6 @@ public class PipMenuIconsAlgorithm {
mDismissButton = dismissButton;
}
-
/**
* Updates the position of the drag handle based on where the PIP window is on the screen.
*/
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java
index ca3ef2465498..ee8f295e0c30 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java
@@ -54,7 +54,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
private static final int SHRINK_STACK_FROM_MENU_DURATION = 250;
private static final int EXPAND_STACK_TO_MENU_DURATION = 250;
- private static final int EXPAND_STACK_TO_FULLSCREEN_DURATION = 300;
+ private static final int LEAVE_PIP_DURATION = 300;
private static final int SHIFT_DURATION = 300;
/** Friction to use for PIP when it moves via physics fling animations. */
@@ -304,16 +304,18 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
}
/**
- * Resizes the pinned stack back to fullscreen.
+ * Resizes the pinned stack back to unknown windowing mode, which could be freeform or
+ * * fullscreen depending on the display area's windowing mode.
*/
- void expandPipToFullscreen() {
- expandPipToFullscreen(false /* skipAnimation */);
+ void expandLeavePip() {
+ expandLeavePip(false /* skipAnimation */);
}
/**
- * Resizes the pinned stack back to fullscreen.
+ * Resizes the pinned stack back to unknown windowing mode, which could be freeform or
+ * fullscreen depending on the display area's windowing mode.
*/
- void expandPipToFullscreen(boolean skipAnimation) {
+ void expandLeavePip(boolean skipAnimation) {
if (DEBUG) {
Log.d(TAG, "exitPip: skipAnimation=" + skipAnimation
+ " callers=\n" + Debug.getCallers(5, " "));
@@ -323,7 +325,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
mPipTaskOrganizer.getUpdateHandler().post(() -> {
mPipTaskOrganizer.exitPip(skipAnimation
? 0
- : EXPAND_STACK_TO_FULLSCREEN_DURATION);
+ : LEAVE_PIP_DURATION);
});
}
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
index 5434b62e19b8..7fc2823fc248 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
@@ -193,7 +193,7 @@ public class PipTouchHandler {
@Override
public void onPipExpand() {
- mMotionHelper.expandPipToFullscreen();
+ mMotionHelper.expandLeavePip();
}
@Override
@@ -991,7 +991,7 @@ public class PipTouchHandler {
// Expand to fullscreen if this is a double tap
// the PiP should be frozen until the transition ends
setTouchEnabled(false);
- mMotionHelper.expandPipToFullscreen();
+ mMotionHelper.expandLeavePip();
} else if (mMenuState != MENU_STATE_FULL) {
if (!mTouchState.isWaitingForDoubleTap()) {
// User has stalled long enough for this not to be a drag or a double tap, just
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/dagger/PipMenuActivityClass.java b/packages/SystemUI/src/com/android/systemui/pip/phone/dagger/PipMenuActivityClass.java
new file mode 100644
index 000000000000..114c30e625aa
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/dagger/PipMenuActivityClass.java
@@ -0,0 +1,30 @@
+/*
+ * 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.systemui.pip.phone.dagger;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Documented
+@Retention(RUNTIME)
+public @interface PipMenuActivityClass {
+}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
index 560998b5d1d8..22c735d5fa11 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
@@ -185,7 +185,9 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
fakeDragBy(getScrollX() - mScroller.getCurrX());
} else if (isFakeDragging()) {
endFakeDrag();
- mBounceAnimatorSet.start();
+ if (mBounceAnimatorSet != null) {
+ mBounceAnimatorSet.start();
+ }
setOffscreenPageLimit(1);
}
super.computeScroll();
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BatterySaverTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BatterySaverTile.java
index eb794a8b4378..c64fc50b8237 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BatterySaverTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BatterySaverTile.java
@@ -130,6 +130,7 @@ public class BatterySaverTile extends QSTileImpl<BooleanState> implements
: mPowerSave ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
state.icon = mIcon;
state.label = mContext.getString(R.string.battery_detail_switch_title);
+ state.secondaryLabel = "";
state.contentDescription = state.label;
state.value = mPowerSave;
state.expandedAccessibilityClassName = Switch.class.getName();
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotNotificationsController.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotNotificationsController.java
index 6f5ceabcc9a5..6d1299ba98ac 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotNotificationsController.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotNotificationsController.java
@@ -205,7 +205,8 @@ public class ScreenshotNotificationsController {
mPublicNotificationBuilder
.setContentTitle(mResources.getString(R.string.screenshot_saved_title))
.setContentText(mResources.getString(R.string.screenshot_saved_text))
- .setContentIntent(PendingIntent.getActivity(mContext, 0, launchIntent, 0))
+ .setContentIntent(PendingIntent
+ .getActivity(mContext, 0, launchIntent, PendingIntent.FLAG_IMMUTABLE))
.setWhen(now)
.setAutoCancel(true)
.setColor(mContext.getColor(
@@ -213,7 +214,8 @@ public class ScreenshotNotificationsController {
mNotificationBuilder
.setContentTitle(mResources.getString(R.string.screenshot_saved_title))
.setContentText(mResources.getString(R.string.screenshot_saved_text))
- .setContentIntent(PendingIntent.getActivity(mContext, 0, launchIntent, 0))
+ .setContentIntent(PendingIntent
+ .getActivity(mContext, 0, launchIntent, PendingIntent.FLAG_IMMUTABLE))
.setWhen(now)
.setAutoCancel(true)
.setColor(mContext.getColor(
diff --git a/packages/SystemUI/src/com/android/systemui/settings/CurrentUserContentResolverProvider.kt b/packages/SystemUI/src/com/android/systemui/settings/CurrentUserContentResolverProvider.kt
new file mode 100644
index 000000000000..9d05843b42bf
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/settings/CurrentUserContentResolverProvider.kt
@@ -0,0 +1,24 @@
+/*
+ * 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.systemui.settings
+
+import android.content.ContentResolver
+
+interface CurrentUserContentResolverProvider {
+
+ val currentUserContentResolver: ContentResolver
+} \ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/settings/CurrentUserContextTracker.kt b/packages/SystemUI/src/com/android/systemui/settings/CurrentUserContextTracker.kt
index 825a7f3dbadb..d7c4caaa4f9d 100644
--- a/packages/SystemUI/src/com/android/systemui/settings/CurrentUserContextTracker.kt
+++ b/packages/SystemUI/src/com/android/systemui/settings/CurrentUserContextTracker.kt
@@ -16,6 +16,7 @@
package com.android.systemui.settings
+import android.content.ContentResolver
import android.content.Context
import android.os.UserHandle
import androidx.annotation.VisibleForTesting
@@ -31,7 +32,7 @@ import java.lang.IllegalStateException
class CurrentUserContextTracker internal constructor(
private val sysuiContext: Context,
broadcastDispatcher: BroadcastDispatcher
-) {
+) : CurrentUserContentResolverProvider {
private val userTracker: CurrentUserTracker
private var initialized = false
@@ -44,6 +45,9 @@ class CurrentUserContextTracker internal constructor(
return _curUserContext!!
}
+ override val currentUserContentResolver: ContentResolver
+ get() = currentUserContext.contentResolver
+
init {
userTracker = object : CurrentUserTracker(broadcastDispatcher) {
override fun onUserSwitched(newUserId: Int) {
@@ -54,8 +58,8 @@ class CurrentUserContextTracker internal constructor(
fun initialize() {
initialized = true
- _curUserContext = makeUserContext(userTracker.currentUserId)
userTracker.startTracking()
+ _curUserContext = makeUserContext(userTracker.currentUserId)
}
@VisibleForTesting
diff --git a/packages/SystemUI/src/com/android/systemui/settings/dagger/SettingsModule.java b/packages/SystemUI/src/com/android/systemui/settings/dagger/SettingsModule.java
index 2c5c3ceb6e66..eb5bd5c01a78 100644
--- a/packages/SystemUI/src/com/android/systemui/settings/dagger/SettingsModule.java
+++ b/packages/SystemUI/src/com/android/systemui/settings/dagger/SettingsModule.java
@@ -19,10 +19,12 @@ package com.android.systemui.settings.dagger;
import android.content.Context;
import com.android.systemui.broadcast.BroadcastDispatcher;
+import com.android.systemui.settings.CurrentUserContentResolverProvider;
import com.android.systemui.settings.CurrentUserContextTracker;
import javax.inject.Singleton;
+import dagger.Binds;
import dagger.Module;
import dagger.Provides;
@@ -30,7 +32,7 @@ import dagger.Provides;
* Dagger Module for classes found within the com.android.systemui.settings package.
*/
@Module
-public interface SettingsModule {
+public abstract class SettingsModule {
/**
* Provides and initializes a CurrentUserContextTracker
@@ -45,4 +47,9 @@ public interface SettingsModule {
tracker.initialize();
return tracker;
}
+
+ @Binds
+ @Singleton
+ abstract CurrentUserContentResolverProvider bindCurrentUserContentResolverTracker(
+ CurrentUserContextTracker tracker);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java
index 673549ab589f..e5a46797d035 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java
@@ -79,6 +79,13 @@ public interface BatteryController extends DemoMode, Dumpable,
default void setReverseState(boolean isReverse) {}
/**
+ * Returns {@code true} if extreme battery saver is on.
+ */
+ default boolean isExtremeSaverOn() {
+ return false;
+ }
+
+ /**
* A listener that will be notified whenever a change in battery level or power save mode has
* occurred.
*/
@@ -92,6 +99,9 @@ public interface BatteryController extends DemoMode, Dumpable,
default void onReverseChanged(boolean isReverse, int level, String name) {
}
+
+ default void onExtremeBatterySaverChanged(boolean isExtreme) {
+ }
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/util/leak/LeakReporter.java b/packages/SystemUI/src/com/android/systemui/util/leak/LeakReporter.java
index b25df5f9c07f..5e7280840bb9 100644
--- a/packages/SystemUI/src/com/android/systemui/util/leak/LeakReporter.java
+++ b/packages/SystemUI/src/com/android/systemui/util/leak/LeakReporter.java
@@ -104,9 +104,13 @@ public class LeakReporter {
.setContentText(String.format(
"SystemUI has detected %d leaked objects. Tap to send", garbageCount))
.setSmallIcon(com.android.internal.R.drawable.stat_sys_adb)
- .setContentIntent(PendingIntent.getActivityAsUser(mContext, 0,
+ .setContentIntent(PendingIntent.getActivityAsUser(
+ mContext,
+ 0,
getIntent(hprofFile, dumpFile),
- PendingIntent.FLAG_UPDATE_CURRENT, null, UserHandle.CURRENT));
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE,
+ null,
+ UserHandle.CURRENT));
notiMan.notify(TAG, 0, builder.build());
} catch (IOException e) {
Log.e(TAG, "Couldn't dump heap for leak", e);
diff --git a/packages/SystemUI/src/com/android/systemui/util/sensors/ProximitySensor.java b/packages/SystemUI/src/com/android/systemui/util/sensors/ProximitySensor.java
index 9fa03df4229a..06806d0e6ab6 100644
--- a/packages/SystemUI/src/com/android/systemui/util/sensors/ProximitySensor.java
+++ b/packages/SystemUI/src/com/android/systemui/util/sensors/ProximitySensor.java
@@ -338,7 +338,7 @@ public class ProximitySensor implements ThresholdSensor {
@Override
public void run() {
unregister();
- mSensor.alertListeners();
+ onProximityEvent(null);
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/wmshell/WindowManagerShellModule.java b/packages/SystemUI/src/com/android/systemui/wmshell/WindowManagerShellModule.java
index 5b2c39db2eae..d2c61cc996dd 100644
--- a/packages/SystemUI/src/com/android/systemui/wmshell/WindowManagerShellModule.java
+++ b/packages/SystemUI/src/com/android/systemui/wmshell/WindowManagerShellModule.java
@@ -21,6 +21,8 @@ import android.os.Handler;
import android.view.IWindowManager;
import com.android.systemui.dagger.qualifiers.Main;
+import com.android.systemui.pip.phone.PipMenuActivity;
+import com.android.systemui.pip.phone.dagger.PipMenuActivityClass;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayImeController;
import com.android.wm.shell.common.SystemWindows;
@@ -65,4 +67,12 @@ public class WindowManagerShellModule {
return new DisplayImeController.Builder(wmService, displayController, mainHandler,
transactionPool).build();
}
+
+ /** TODO(b/150319024): PipMenuActivity will move to a Window */
+ @Singleton
+ @PipMenuActivityClass
+ @Provides
+ static Class<?> providePipMenuActivityClass() {
+ return PipMenuActivity.class;
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/controls/CustomIconCacheTest.kt b/packages/SystemUI/tests/src/com/android/systemui/controls/CustomIconCacheTest.kt
new file mode 100644
index 000000000000..4d0f2ed47495
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/controls/CustomIconCacheTest.kt
@@ -0,0 +1,101 @@
+/*
+ * 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.systemui.controls
+
+import android.content.ComponentName
+import android.graphics.drawable.Icon
+import android.testing.AndroidTestingRunner
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import org.junit.Assert.assertNull
+import org.junit.Assert.assertTrue
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.Mock
+import org.mockito.MockitoAnnotations
+
+@SmallTest
+@RunWith(AndroidTestingRunner::class)
+class CustomIconCacheTest : SysuiTestCase() {
+
+ companion object {
+ private val TEST_COMPONENT1 = ComponentName.unflattenFromString("pkg/.cls1")!!
+ private val TEST_COMPONENT2 = ComponentName.unflattenFromString("pkg/.cls2")!!
+ private const val CONTROL_ID_1 = "TEST_CONTROL_1"
+ private const val CONTROL_ID_2 = "TEST_CONTROL_2"
+ }
+
+ @Mock(stubOnly = true)
+ private lateinit var icon1: Icon
+ @Mock(stubOnly = true)
+ private lateinit var icon2: Icon
+ private lateinit var customIconCache: CustomIconCache
+
+ @Before
+ fun setUp() {
+ MockitoAnnotations.initMocks(this)
+
+ customIconCache = CustomIconCache()
+ }
+
+ @Test
+ fun testIconStoredCorrectly() {
+ customIconCache.store(TEST_COMPONENT1, CONTROL_ID_1, icon1)
+
+ assertTrue(icon1 === customIconCache.retrieve(TEST_COMPONENT1, CONTROL_ID_1))
+ }
+
+ @Test
+ fun testIconNotStoredReturnsNull() {
+ customIconCache.store(TEST_COMPONENT1, CONTROL_ID_1, icon1)
+
+ assertNull(customIconCache.retrieve(TEST_COMPONENT1, CONTROL_ID_2))
+ }
+
+ @Test
+ fun testWrongComponentReturnsNull() {
+ customIconCache.store(TEST_COMPONENT1, CONTROL_ID_1, icon1)
+
+ assertNull(customIconCache.retrieve(TEST_COMPONENT2, CONTROL_ID_1))
+ }
+
+ @Test
+ fun testChangeComponentOldComponentIsRemoved() {
+ customIconCache.store(TEST_COMPONENT1, CONTROL_ID_1, icon1)
+ customIconCache.store(TEST_COMPONENT2, CONTROL_ID_2, icon2)
+
+ assertNull(customIconCache.retrieve(TEST_COMPONENT1, CONTROL_ID_1))
+ assertNull(customIconCache.retrieve(TEST_COMPONENT1, CONTROL_ID_2))
+ }
+
+ @Test
+ fun testChangeComponentCorrectIconRetrieved() {
+ customIconCache.store(TEST_COMPONENT1, CONTROL_ID_1, icon1)
+ customIconCache.store(TEST_COMPONENT2, CONTROL_ID_1, icon2)
+
+ assertTrue(icon2 === customIconCache.retrieve(TEST_COMPONENT2, CONTROL_ID_1))
+ }
+
+ @Test
+ fun testStoreNull() {
+ customIconCache.store(TEST_COMPONENT1, CONTROL_ID_1, icon1)
+ customIconCache.store(TEST_COMPONENT1, CONTROL_ID_1, null)
+
+ assertNull(customIconCache.retrieve(TEST_COMPONENT1, CONTROL_ID_1))
+ }
+} \ No newline at end of file
diff --git a/packages/SystemUI/tests/src/com/android/systemui/controls/management/FavoritesModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/controls/management/FavoritesModelTest.kt
index ce33a8d49fac..f0003ed603ab 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/controls/management/FavoritesModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/controls/management/FavoritesModelTest.kt
@@ -22,6 +22,7 @@ import androidx.recyclerview.widget.RecyclerView
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.controls.ControlInterface
+import com.android.systemui.controls.CustomIconCache
import com.android.systemui.controls.controller.ControlInfo
import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.eq
@@ -57,6 +58,8 @@ class FavoritesModelTest : SysuiTestCase() {
private lateinit var callback: FavoritesModel.FavoritesModelCallback
@Mock
private lateinit var adapter: RecyclerView.Adapter<*>
+ @Mock
+ private lateinit var customIconCache: CustomIconCache
private lateinit var model: FavoritesModel
private lateinit var dividerWrapper: DividerWrapper
@@ -64,7 +67,7 @@ class FavoritesModelTest : SysuiTestCase() {
fun setUp() {
MockitoAnnotations.initMocks(this)
- model = FavoritesModel(TEST_COMPONENT, INITIAL_FAVORITES, callback)
+ model = FavoritesModel(customIconCache, TEST_COMPONENT, INITIAL_FAVORITES, callback)
model.attachAdapter(adapter)
dividerWrapper = model.elements.first { it is DividerWrapper } as DividerWrapper
}
@@ -89,7 +92,7 @@ class FavoritesModelTest : SysuiTestCase() {
@Test
fun testInitialElements() {
val expected = INITIAL_FAVORITES.map {
- ControlInfoWrapper(TEST_COMPONENT, it, true)
+ ControlInfoWrapper(TEST_COMPONENT, it, true, customIconCache::retrieve)
} + DividerWrapper()
assertEquals(expected, model.elements)
}
@@ -287,5 +290,13 @@ class FavoritesModelTest : SysuiTestCase() {
verify(callback).onFirstChange()
}
+ @Test
+ fun testCacheCalledWhenGettingCustomIcon() {
+ val wrapper = model.elements[0] as ControlInfoWrapper
+ wrapper.customIcon
+
+ verify(customIconCache).retrieve(TEST_COMPONENT, wrapper.controlId)
+ }
+
private fun getDividerPosition(): Int = model.elements.indexOf(dividerWrapper)
} \ No newline at end of file
diff --git a/packages/SystemUI/tests/src/com/android/systemui/pip/PipAnimationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/pip/PipAnimationControllerTest.java
index c9c111198f4c..f0066ba4f66a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/pip/PipAnimationControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/pip/PipAnimationControllerTest.java
@@ -16,7 +16,7 @@
package com.android.systemui.pip;
-import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_TO_FULLSCREEN;
+import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_LEAVE_PIP;
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_TO_PIP;
import static org.junit.Assert.assertEquals;
@@ -116,9 +116,9 @@ public class PipAnimationControllerTest extends SysuiTestCase {
animator = mPipAnimationController
.getAnimator(mLeash, new Rect(), 0f, 1f)
- .setTransitionDirection(TRANSITION_DIRECTION_TO_FULLSCREEN);
+ .setTransitionDirection(TRANSITION_DIRECTION_LEAVE_PIP);
assertEquals("Transition to fullscreen mode",
- animator.getTransitionDirection(), TRANSITION_DIRECTION_TO_FULLSCREEN);
+ animator.getTransitionDirection(), TRANSITION_DIRECTION_LEAVE_PIP);
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/util/sensors/ProximityCheckTest.java b/packages/SystemUI/tests/src/com/android/systemui/util/sensors/ProximityCheckTest.java
index 8ba11dae2b5c..c5a197eef2d4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/util/sensors/ProximityCheckTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/util/sensors/ProximityCheckTest.java
@@ -16,6 +16,7 @@
package com.android.systemui.util.sensors;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -80,6 +81,8 @@ public class ProximityCheckTest extends SysuiTestCase {
mFakeExecutor.runAllReady();
assertFalse(mFakeProximitySensor.isRegistered());
+ assertEquals(1, mTestableCallback.mNumCalls);
+ assertNull(mTestableCallback.mLastResult);
}
@Test
@@ -110,9 +113,12 @@ public class ProximityCheckTest extends SysuiTestCase {
private static class TestableCallback implements Consumer<Boolean> {
Boolean mLastResult;
+ int mNumCalls = 0;
+
@Override
public void accept(Boolean result) {
mLastResult = result;
+ mNumCalls++;
}
}
}
diff --git a/services/Android.bp b/services/Android.bp
index f0144ac1c695..ef52c2aff002 100644
--- a/services/Android.bp
+++ b/services/Android.bp
@@ -30,6 +30,7 @@ filegroup {
":services.midi-sources",
":services.net-sources",
":services.print-sources",
+ ":services.profcollect-sources",
":services.restrictions-sources",
":services.startop.iorap-sources",
":services.systemcaptions-sources",
@@ -73,6 +74,7 @@ java_library {
"services.net",
"services.people",
"services.print",
+ "services.profcollect",
"services.restrictions",
"services.startop",
"services.systemcaptions",
diff --git a/services/accessibility/java/com/android/server/accessibility/magnification/FullScreenMagnificationController.java b/services/accessibility/java/com/android/server/accessibility/magnification/FullScreenMagnificationController.java
index 44c4bf4836a0..b6f2a47dd5e2 100644
--- a/services/accessibility/java/com/android/server/accessibility/magnification/FullScreenMagnificationController.java
+++ b/services/accessibility/java/com/android/server/accessibility/magnification/FullScreenMagnificationController.java
@@ -16,8 +16,10 @@
package com.android.server.accessibility.magnification;
+import android.animation.Animator;
import android.animation.ValueAnimator;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -61,6 +63,8 @@ public class FullScreenMagnificationController {
private static final boolean DEBUG = false;
private static final String LOG_TAG = "FullScreenMagnificationController";
+ private static final Runnable STUB_RUNNABLE = () -> {
+ };
public static final float MIN_SCALE = 1.0f;
public static final float MAX_SCALE = 8.0f;
@@ -292,7 +296,7 @@ public class FullScreenMagnificationController {
// Adjust the current spec's offsets if necessary.
if (updateCurrentSpecWithOffsetsLocked(
mCurrentMagnificationSpec.offsetX, mCurrentMagnificationSpec.offsetY)) {
- sendSpecToAnimation(mCurrentMagnificationSpec, false);
+ sendSpecToAnimation(mCurrentMagnificationSpec, null);
}
onMagnificationChangedLocked();
}
@@ -300,17 +304,18 @@ public class FullScreenMagnificationController {
}
}
- void sendSpecToAnimation(MagnificationSpec spec, boolean animate) {
+ void sendSpecToAnimation(MagnificationSpec spec, Runnable endCallback) {
if (DEBUG) {
Slog.i(LOG_TAG,
- "sendSpecToAnimation(spec = " + spec + ", animate = " + animate + ")");
+ "sendSpecToAnimation(spec = " + spec + ", endCallback = " + endCallback
+ + ")");
}
if (Thread.currentThread().getId() == mMainThreadId) {
- mSpecAnimationBridge.updateSentSpecMainThread(spec, animate);
+ mSpecAnimationBridge.updateSentSpecMainThread(spec, endCallback);
} else {
final Message m = PooledLambda.obtainMessage(
SpecAnimationBridge::updateSentSpecMainThread,
- mSpecAnimationBridge, spec, animate);
+ mSpecAnimationBridge, spec, endCallback);
mControllerCtx.getHandler().sendMessage(m);
}
}
@@ -410,6 +415,11 @@ public class FullScreenMagnificationController {
@GuardedBy("mLock")
boolean reset(boolean animate) {
+ return reset(transformToStubRunnable(animate));
+ }
+
+ @GuardedBy("mLock")
+ boolean reset(Runnable endCallback) {
if (!mRegistered) {
return false;
}
@@ -420,7 +430,7 @@ public class FullScreenMagnificationController {
onMagnificationChangedLocked();
}
mIdOfLastServiceToMagnify = INVALID_ID;
- sendSpecToAnimation(spec, animate);
+ sendSpecToAnimation(spec, endCallback);
return changed;
}
@@ -448,24 +458,24 @@ public class FullScreenMagnificationController {
final float centerX = normPivotX + offsetX;
final float centerY = normPivotY + offsetY;
mIdOfLastServiceToMagnify = id;
- return setScaleAndCenter(scale, centerX, centerY, animate, id);
+ return setScaleAndCenter(scale, centerX, centerY, transformToStubRunnable(animate), id);
}
@GuardedBy("mLock")
boolean setScaleAndCenter(float scale, float centerX, float centerY,
- boolean animate, int id) {
+ Runnable endCallback, int id) {
if (!mRegistered) {
return false;
}
if (DEBUG) {
Slog.i(LOG_TAG,
"setScaleAndCenterLocked(scale = " + scale + ", centerX = " + centerX
- + ", centerY = " + centerY + ", animate = " + animate
+ + ", centerY = " + centerY + ", endCallback = " + endCallback
+ ", id = " + id
+ ")");
}
final boolean changed = updateMagnificationSpecLocked(scale, centerX, centerY);
- sendSpecToAnimation(mCurrentMagnificationSpec, animate);
+ sendSpecToAnimation(mCurrentMagnificationSpec, endCallback);
if (isMagnifying() && (id != INVALID_ID)) {
mIdOfLastServiceToMagnify = id;
}
@@ -531,7 +541,7 @@ public class FullScreenMagnificationController {
if (id != INVALID_ID) {
mIdOfLastServiceToMagnify = id;
}
- sendSpecToAnimation(mCurrentMagnificationSpec, false);
+ sendSpecToAnimation(mCurrentMagnificationSpec, null);
}
boolean updateCurrentSpecWithOffsetsLocked(float nonNormOffsetX, float nonNormOffsetY) {
@@ -865,12 +875,26 @@ public class FullScreenMagnificationController {
* the spec did not change
*/
public boolean reset(int displayId, boolean animate) {
+ return reset(displayId, animate ? STUB_RUNNABLE : null);
+ }
+
+ /**
+ * Resets the magnification scale and center, optionally animating the
+ * transition.
+ *
+ * @param displayId The logical display id.
+ * @param endCallback Called when the animation is ended or the spec did not change.
+ * {@code null} to transition immediately
+ * @return {@code true} if the magnification spec changed, {@code false} if
+ * the spec did not change
+ */
+ public boolean reset(int displayId, Runnable endCallback) {
synchronized (mLock) {
final DisplayMagnification display = mDisplays.get(displayId);
if (display == null) {
return false;
}
- return display.reset(animate);
+ return display.reset(endCallback);
}
}
@@ -921,7 +945,8 @@ public class FullScreenMagnificationController {
if (display == null) {
return false;
}
- return display.setScaleAndCenter(Float.NaN, centerX, centerY, animate, id);
+ return display.setScaleAndCenter(Float.NaN, centerX, centerY,
+ animate ? STUB_RUNNABLE : null, id);
}
}
@@ -944,12 +969,35 @@ public class FullScreenMagnificationController {
*/
public boolean setScaleAndCenter(int displayId, float scale, float centerX, float centerY,
boolean animate, int id) {
+ return setScaleAndCenter(displayId, scale, centerX, centerY,
+ transformToStubRunnable(animate), id);
+ }
+
+ /**
+ * Sets the scale and center of the magnified region, optionally
+ * animating the transition. If animation is disabled, the transition
+ * is immediate.
+ *
+ * @param displayId The logical display id.
+ * @param scale the target scale, or {@link Float#NaN} to leave unchanged
+ * @param centerX the screen-relative X coordinate around which to
+ * center and scale, or {@link Float#NaN} to leave unchanged
+ * @param centerY the screen-relative Y coordinate around which to
+ * center and scale, or {@link Float#NaN} to leave unchanged
+ * @param endCallback called when the transition is finished successfully or the spec did not
+ * change. {@code null} to transition immediately.
+ * @param id the ID of the service requesting the change
+ * @return {@code true} if the magnification spec changed, {@code false} if
+ * the spec did not change
+ */
+ public boolean setScaleAndCenter(int displayId, float scale, float centerX, float centerY,
+ Runnable endCallback, int id) {
synchronized (mLock) {
final DisplayMagnification display = mDisplays.get(displayId);
if (display == null) {
return false;
}
- return display.setScaleAndCenter(scale, centerX, centerY, animate, id);
+ return display.setScaleAndCenter(scale, centerX, centerY, endCallback, id);
}
}
@@ -1160,7 +1208,8 @@ public class FullScreenMagnificationController {
* Class responsible for animating spec on the main thread and sending spec
* updates to the window manager.
*/
- private static class SpecAnimationBridge implements ValueAnimator.AnimatorUpdateListener {
+ private static class SpecAnimationBridge implements ValueAnimator.AnimatorUpdateListener,
+ Animator.AnimatorListener {
private final ControllerContext mControllerCtx;
/**
@@ -1180,6 +1229,8 @@ public class FullScreenMagnificationController {
*/
private final ValueAnimator mValueAnimator;
+ // Called when the callee wants animating and the sent spec matches the target spec.
+ private Runnable mEndCallback;
private final Object mLock;
private final int mDisplayId;
@@ -1197,6 +1248,7 @@ public class FullScreenMagnificationController {
mValueAnimator.setInterpolator(new DecelerateInterpolator(2.5f));
mValueAnimator.setFloatValues(0.0f, 1.0f);
mValueAnimator.addUpdateListener(this);
+ mValueAnimator.addListener(this);
}
/**
@@ -1216,24 +1268,36 @@ public class FullScreenMagnificationController {
}
}
- public void updateSentSpecMainThread(MagnificationSpec spec, boolean animate) {
+ void updateSentSpecMainThread(MagnificationSpec spec, Runnable endCallback) {
if (mValueAnimator.isRunning()) {
+ // Avoid AnimationEnd Callback.
+ mEndCallback = null;
mValueAnimator.cancel();
}
+ mEndCallback = endCallback;
// If the current and sent specs don't match, update the sent spec.
synchronized (mLock) {
final boolean changed = !mSentMagnificationSpec.equals(spec);
if (changed) {
- if (animate) {
+ if (mEndCallback != null) {
animateMagnificationSpecLocked(spec);
} else {
setMagnificationSpecLocked(spec);
}
+ } else {
+ sendEndCallbackMainThread();
}
}
}
+ private void sendEndCallbackMainThread() {
+ if (mEndCallback != null) {
+ mEndCallback.run();
+ mEndCallback = null;
+ }
+ }
+
@GuardedBy("mLock")
private void setMagnificationSpecLocked(MagnificationSpec spec) {
if (mEnabled) {
@@ -1270,6 +1334,26 @@ public class FullScreenMagnificationController {
}
}
}
+
+ @Override
+ public void onAnimationStart(Animator animation) {
+
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ sendEndCallbackMainThread();
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator animation) {
+
+ }
}
private static class ScreenStateObserver extends BroadcastReceiver {
@@ -1395,4 +1479,9 @@ public class FullScreenMagnificationController {
return mAnimationDuration;
}
}
+
+ @Nullable
+ private static Runnable transformToStubRunnable(boolean animate) {
+ return animate ? STUB_RUNNABLE : null;
+ }
}
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index 7381da1676f5..6d71c8e68f77 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -34,7 +34,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
-import android.net.LinkProperties;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
@@ -46,8 +45,6 @@ import android.os.RemoteException;
import android.os.UserHandle;
import android.provider.DeviceConfig;
import android.telephony.Annotation;
-import android.telephony.Annotation.ApnType;
-import android.telephony.Annotation.DataFailureCause;
import android.telephony.Annotation.RadioPowerState;
import android.telephony.Annotation.SrvccState;
import android.telephony.BarringInfo;
@@ -80,7 +77,9 @@ import android.telephony.TelephonyManager;
import android.telephony.data.ApnSetting;
import android.telephony.emergency.EmergencyNumber;
import android.telephony.ims.ImsReasonInfo;
+import android.util.ArrayMap;
import android.util.LocalLog;
+import android.util.Pair;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.IBatteryStats;
@@ -103,6 +102,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
+import java.util.Objects;
/**
* Since phone process can be restarted, this class provides a centralized place
@@ -302,13 +302,18 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
@RadioPowerState
private int mRadioPowerState = TelephonyManager.RADIO_POWER_UNAVAILABLE;
- private final LocalLog mLocalLog = new LocalLog(100);
+ private final LocalLog mLocalLog = new LocalLog(200);
- private final LocalLog mListenLog = new LocalLog(100);
+ private final LocalLog mListenLog = new LocalLog(00);
- // Per-phoneMap of APN Type to DataConnectionState
- private List<Map<Integer, PreciseDataConnectionState>> mPreciseDataConnectionStates =
- new ArrayList<Map<Integer, PreciseDataConnectionState>>();
+ /**
+ * Per-phone map of precise data connection state. The key of the map is the pair of transport
+ * type and APN setting. This is the cache to prevent redundant callbacks to the listeners.
+ * A precise data connection with state {@link TelephonyManager#DATA_DISCONNECTED} removes
+ * its entry from the map.
+ */
+ private List<Map<Pair<Integer, ApnSetting>, PreciseDataConnectionState>>
+ mPreciseDataConnectionStates;
static final int ENFORCE_COARSE_LOCATION_PERMISSION_MASK =
PhoneStateListener.LISTEN_REGISTRATION_FAILURE
@@ -521,7 +526,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
mRingingCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
mForegroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
- mPreciseDataConnectionStates.add(new HashMap<Integer, PreciseDataConnectionState>());
+ mPreciseDataConnectionStates.add(new ArrayMap<>());
mBarringInfo.add(i, new BarringInfo());
mTelephonyDisplayInfos[i] = null;
}
@@ -610,7 +615,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
mRingingCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
mForegroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
- mPreciseDataConnectionStates.add(new HashMap<Integer, PreciseDataConnectionState>());
+ mPreciseDataConnectionStates.add(new ArrayMap<>());
mBarringInfo.add(i, new BarringInfo());
mTelephonyDisplayInfos[i] = null;
}
@@ -1687,38 +1692,25 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
*
* @param phoneId the phoneId carrying the data connection
* @param subId the subscriptionId for the data connection
- * @param apnType the apn type bitmask, defined with {@code ApnSetting#TYPE_*} flags.
* @param preciseState a PreciseDataConnectionState that has info about the data connection
*/
@Override
- public void notifyDataConnectionForSubscriber(
- int phoneId, int subId, @ApnType int apnType, PreciseDataConnectionState preciseState) {
+ public void notifyDataConnectionForSubscriber(int phoneId, int subId,
+ @NonNull PreciseDataConnectionState preciseState) {
if (!checkNotifyPermission("notifyDataConnection()" )) {
return;
}
- String apn = "";
- int state = TelephonyManager.DATA_UNKNOWN;
- int networkType = TelephonyManager.NETWORK_TYPE_UNKNOWN;
- LinkProperties linkProps = null;
+ ApnSetting apnSetting = preciseState.getApnSetting();
- if (preciseState != null) {
- apn = preciseState.getDataConnectionApn();
- state = preciseState.getState();
- networkType = preciseState.getNetworkType();
- linkProps = preciseState.getLinkProperties();
- }
- if (VDBG) {
- log("notifyDataConnectionForSubscriber: subId=" + subId
- + " state=" + state + "' apn='" + apn
- + "' apnType=" + apnType + " networkType=" + networkType
- + "' preciseState=" + preciseState);
- }
+ int apnTypes = apnSetting.getApnTypeBitmask();
+ int state = preciseState.getState();
+ int networkType = preciseState.getNetworkType();
synchronized (mRecords) {
if (validatePhoneId(phoneId)) {
// We only call the callback when the change is for default APN type.
- if ((ApnSetting.TYPE_DEFAULT & apnType) != 0
+ if ((ApnSetting.TYPE_DEFAULT & apnTypes) != 0
&& (mDataConnectionState[phoneId] != state
|| mDataConnectionNetworkType[phoneId] != networkType)) {
String str = "onDataConnectionStateChanged("
@@ -1747,19 +1739,11 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
mDataConnectionNetworkType[phoneId] = networkType;
}
- boolean needsNotify = false;
- // State has been cleared for this APN Type
- if (preciseState == null) {
- // We try clear the state and check if the state was previously not cleared
- needsNotify = mPreciseDataConnectionStates.get(phoneId).remove(apnType) != null;
- } else {
- // We need to check to see if the state actually changed
- PreciseDataConnectionState oldPreciseState =
- mPreciseDataConnectionStates.get(phoneId).put(apnType, preciseState);
- needsNotify = !preciseState.equals(oldPreciseState);
- }
-
- if (needsNotify) {
+ Pair<Integer, ApnSetting> key = Pair.create(preciseState.getTransportType(),
+ preciseState.getApnSetting());
+ PreciseDataConnectionState oldState = mPreciseDataConnectionStates.get(phoneId)
+ .remove(key);
+ if (!Objects.equals(oldState, preciseState)) {
for (Record r : mRecords) {
if (r.matchPhoneStateListenerEvent(
PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)
@@ -1771,54 +1755,22 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
}
}
}
- }
- }
- handleRemoveListLocked();
- }
+ handleRemoveListLocked();
- broadcastDataConnectionStateChanged(state, apn, apnType, subId);
- }
+ broadcastDataConnectionStateChanged(phoneId, subId, preciseState);
- /**
- * Stub to satisfy the ITelephonyRegistry aidl interface; do not use this function.
- * @see #notifyDataConnectionFailedForSubscriber
- */
- public void notifyDataConnectionFailed(String apnType) {
- loge("This function should not be invoked");
- }
+ String str = "notifyDataConnectionForSubscriber: phoneId=" + phoneId + " subId="
+ + subId + " " + preciseState;
+ log(str);
+ mLocalLog.log(str);
+ }
- private void notifyDataConnectionFailedForSubscriber(int phoneId, int subId, int apnType) {
- if (!checkNotifyPermission("notifyDataConnectionFailed()")) {
- return;
- }
- if (VDBG) {
- log("notifyDataConnectionFailedForSubscriber: subId=" + subId
- + " apnType=" + apnType);
- }
- synchronized (mRecords) {
- if (validatePhoneId(phoneId)) {
- mPreciseDataConnectionStates.get(phoneId).put(
- apnType,
- new PreciseDataConnectionState.Builder()
- .setApnSetting(new ApnSetting.Builder()
- .setApnTypeBitmask(apnType)
- .build())
- .build());
- for (Record r : mRecords) {
- if (r.matchPhoneStateListenerEvent(
- PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)
- && idMatch(r.subId, subId, phoneId)) {
- try {
- r.callback.onPreciseDataConnectionStateChanged(
- mPreciseDataConnectionStates.get(phoneId).get(apnType));
- } catch (RemoteException ex) {
- mRemoveList.add(r.binder);
- }
- }
+ // If the state is disconnected, it would be the end of life cycle of a data
+ // connection, so remove it from the cache.
+ if (preciseState.getState() != TelephonyManager.DATA_DISCONNECTED) {
+ mPreciseDataConnectionStates.get(phoneId).put(key, preciseState);
}
}
-
- handleRemoveListLocked();
}
}
@@ -1972,43 +1924,6 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
}
@Override
- public void notifyPreciseDataConnectionFailed(int phoneId, int subId, @ApnType int apnType,
- String apn, @DataFailureCause int failCause) {
- if (!checkNotifyPermission("notifyPreciseDataConnectionFailed()")) {
- return;
- }
-
- // precise notify invokes imprecise notify
- notifyDataConnectionFailedForSubscriber(phoneId, subId, apnType);
-
- synchronized (mRecords) {
- if (validatePhoneId(phoneId)) {
- mPreciseDataConnectionStates.get(phoneId).put(
- apnType,
- new PreciseDataConnectionState.Builder()
- .setApnSetting(new ApnSetting.Builder()
- .setApnTypeBitmask(apnType)
- .build())
- .setFailCause(failCause)
- .build());
- for (Record r : mRecords) {
- if (r.matchPhoneStateListenerEvent(
- PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)
- && idMatch(r.subId, subId, phoneId)) {
- try {
- r.callback.onPreciseDataConnectionStateChanged(
- mPreciseDataConnectionStates.get(phoneId).get(apnType));
- } catch (RemoteException ex) {
- mRemoveList.add(r.binder);
- }
- }
- }
- }
- handleRemoveListLocked();
- }
- }
-
- @Override
public void notifySrvccStateChanged(int subId, @SrvccState int state) {
if (!checkNotifyPermission("notifySrvccStateChanged()")) {
return;
@@ -2578,16 +2493,18 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
}
}
- private void broadcastDataConnectionStateChanged(int state, String apn,
- int apnType, int subId) {
+ private void broadcastDataConnectionStateChanged(int slotIndex, int subId,
+ @NonNull PreciseDataConnectionState pdcs) {
// Note: not reporting to the battery stats service here, because the
// status bar takes care of that after taking into account all of the
// required info.
Intent intent = new Intent(ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
- intent.putExtra(PHONE_CONSTANTS_STATE_KEY, TelephonyUtils.dataStateToString(state));
- intent.putExtra(PHONE_CONSTANTS_DATA_APN_KEY, apn);
+ intent.putExtra(PHONE_CONSTANTS_STATE_KEY,
+ TelephonyUtils.dataStateToString(pdcs.getState()));
+ intent.putExtra(PHONE_CONSTANTS_DATA_APN_KEY, pdcs.getApnSetting().getApnName());
intent.putExtra(PHONE_CONSTANTS_DATA_APN_TYPE_KEY,
- ApnSetting.getApnTypesStringFromBitmask(apnType));
+ ApnSetting.getApnTypesStringFromBitmask(pdcs.getApnSetting().getApnTypeBitmask()));
+ intent.putExtra(PHONE_CONSTANTS_SLOT_KEY, slotIndex);
intent.putExtra(PHONE_CONSTANTS_SUBSCRIPTION_KEY, subId);
mContext.sendBroadcastAsUser(intent, UserHandle.ALL, Manifest.permission.READ_PHONE_STATE);
}
@@ -2973,7 +2890,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
/**
* Returns a string representation of the radio technology (network type)
* currently in use on the device.
- * @param subId for which network type is returned
+ * @param type for which network type is returned
* @return the name of the radio technology
*
*/
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java
index 1680963e26d1..33a92e6ad0ac 100644
--- a/services/core/java/com/android/server/am/ActiveServices.java
+++ b/services/core/java/com/android/server/am/ActiveServices.java
@@ -2559,12 +2559,12 @@ public final class ActiveServices {
private int getAllowMode(Intent service, @Nullable String callingPackage) {
if (callingPackage == null || service.getComponent() == null) {
- return ActivityManagerInternal.ALLOW_NON_FULL_IN_PROFILE_OR_FULL;
+ return ActivityManagerInternal.ALLOW_NON_FULL_IN_PROFILE;
}
if (callingPackage.equals(service.getComponent().getPackageName())) {
- return ActivityManagerInternal.ALLOW_ACROSS_PROFILES_IN_PROFILE_OR_FULL;
+ return ActivityManagerInternal.ALLOW_ALL_PROFILE_PERMISSIONS_IN_PROFILE;
} else {
- return ActivityManagerInternal.ALLOW_NON_FULL_IN_PROFILE_OR_FULL;
+ return ActivityManagerInternal.ALLOW_NON_FULL_IN_PROFILE;
}
}
diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java
index 19b671e46b71..0658e8139cc2 100644
--- a/services/core/java/com/android/server/am/UserController.java
+++ b/services/core/java/com/android/server/am/UserController.java
@@ -23,11 +23,10 @@ import static android.app.ActivityManager.USER_OP_ERROR_IS_SYSTEM;
import static android.app.ActivityManager.USER_OP_ERROR_RELATED_USERS_CANNOT_STOP;
import static android.app.ActivityManager.USER_OP_IS_CURRENT;
import static android.app.ActivityManager.USER_OP_SUCCESS;
-import static android.app.ActivityManagerInternal.ALLOW_ACROSS_PROFILES_IN_PROFILE_OR_NON_FULL;
-import static android.app.ActivityManagerInternal.ALLOW_ACROSS_PROFILES_IN_PROFILE_OR_FULL;
+import static android.app.ActivityManagerInternal.ALLOW_ALL_PROFILE_PERMISSIONS_IN_PROFILE;
import static android.app.ActivityManagerInternal.ALLOW_FULL_ONLY;
import static android.app.ActivityManagerInternal.ALLOW_NON_FULL;
-import static android.app.ActivityManagerInternal.ALLOW_NON_FULL_IN_PROFILE_OR_FULL;
+import static android.app.ActivityManagerInternal.ALLOW_NON_FULL_IN_PROFILE;
import static android.os.Process.SHELL_UID;
import static android.os.Process.SYSTEM_UID;
@@ -1910,12 +1909,11 @@ class UserController implements Handler.Callback {
callingUid, -1, true) != PackageManager.PERMISSION_GRANTED) {
// If the caller does not have either permission, they are always doomed.
allow = false;
- } else if (allowMode == ALLOW_NON_FULL
- || allowMode == ALLOW_ACROSS_PROFILES_IN_PROFILE_OR_NON_FULL) {
+ } else if (allowMode == ALLOW_NON_FULL) {
// We are blanket allowing non-full access, you lucky caller!
allow = true;
- } else if (allowMode == ALLOW_NON_FULL_IN_PROFILE_OR_FULL
- || allowMode == ALLOW_ACROSS_PROFILES_IN_PROFILE_OR_FULL) {
+ } else if (allowMode == ALLOW_NON_FULL_IN_PROFILE
+ || allowMode == ALLOW_ALL_PROFILE_PERMISSIONS_IN_PROFILE) {
// We may or may not allow this depending on whether the two users are
// in the same profile.
allow = isSameProfileGroup;
@@ -1942,15 +1940,12 @@ class UserController implements Handler.Callback {
builder.append("; this requires ");
builder.append(INTERACT_ACROSS_USERS_FULL);
if (allowMode != ALLOW_FULL_ONLY) {
- if (allowMode == ALLOW_NON_FULL
- || allowMode == ALLOW_ACROSS_PROFILES_IN_PROFILE_OR_NON_FULL
- || isSameProfileGroup) {
+ if (allowMode == ALLOW_NON_FULL || isSameProfileGroup) {
builder.append(" or ");
builder.append(INTERACT_ACROSS_USERS);
}
if (isSameProfileGroup
- && (allowMode == ALLOW_ACROSS_PROFILES_IN_PROFILE_OR_FULL
- || allowMode == ALLOW_ACROSS_PROFILES_IN_PROFILE_OR_NON_FULL)) {
+ && allowMode == ALLOW_ALL_PROFILE_PERMISSIONS_IN_PROFILE) {
builder.append(" or ");
builder.append(INTERACT_ACROSS_PROFILES);
}
@@ -1977,8 +1972,7 @@ class UserController implements Handler.Callback {
private boolean canInteractWithAcrossProfilesPermission(
int allowMode, boolean isSameProfileGroup, int callingPid, int callingUid,
String callingPackage) {
- if (allowMode != ALLOW_ACROSS_PROFILES_IN_PROFILE_OR_FULL
- && allowMode != ALLOW_ACROSS_PROFILES_IN_PROFILE_OR_NON_FULL) {
+ if (allowMode != ALLOW_ALL_PROFILE_PERMISSIONS_IN_PROFILE) {
return false;
}
if (!isSameProfileGroup) {
diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java
index 74f3daf50079..ee441bf06d04 100644
--- a/services/core/java/com/android/server/appop/AppOpsService.java
+++ b/services/core/java/com/android/server/appop/AppOpsService.java
@@ -19,7 +19,6 @@ package com.android.server.appop;
import static android.app.ActivityManager.PROCESS_CAPABILITY_FOREGROUND_CAMERA;
import static android.app.ActivityManager.PROCESS_CAPABILITY_FOREGROUND_LOCATION;
import static android.app.ActivityManager.PROCESS_CAPABILITY_FOREGROUND_MICROPHONE;
-import static android.app.ActivityManagerInternal.ALLOW_ACROSS_PROFILES_IN_PROFILE_OR_NON_FULL;
import static android.app.AppOpsManager.CALL_BACK_ON_SWITCHED_OP;
import static android.app.AppOpsManager.FILTER_BY_ATTRIBUTION_TAG;
import static android.app.AppOpsManager.FILTER_BY_OP_NAMES;
@@ -129,7 +128,6 @@ import android.provider.Settings;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.AtomicFile;
-import android.util.EventLog;
import android.util.KeyValueListParser;
import android.util.LongSparseArray;
import android.util.Pair;
@@ -163,7 +161,6 @@ import com.android.server.LocalServices;
import com.android.server.LockGuard;
import com.android.server.SystemServerInitThreadPool;
import com.android.server.SystemServiceManager;
-import com.android.server.am.ActivityManagerService;
import com.android.server.pm.PackageList;
import com.android.server.pm.parsing.pkg.AndroidPackage;
@@ -1892,6 +1889,7 @@ public class AppOpsService extends IAppOpsService.Stub {
synchronized (this) {
if (mWriteScheduled) {
mWriteScheduled = false;
+ mHandler.removeCallbacks(mWriteRunner);
doWrite = true;
}
}
@@ -2200,11 +2198,8 @@ public class AppOpsService extends IAppOpsService.Stub {
+ " by uid " + Binder.getCallingUid());
}
- int userId = UserHandle.getUserId(uid);
-
enforceManageAppOpsModes(Binder.getCallingPid(), Binder.getCallingUid(), uid);
verifyIncomingOp(code);
- verifyIncomingUser(userId);
code = AppOpsManager.opToSwitch(code);
if (permissionPolicyCallback == null) {
@@ -2449,12 +2444,8 @@ public class AppOpsService extends IAppOpsService.Stub {
private void setMode(int code, int uid, @NonNull String packageName, int mode,
@Nullable IAppOpsCallback permissionPolicyCallback) {
enforceManageAppOpsModes(Binder.getCallingPid(), Binder.getCallingUid(), uid);
-
- int userId = UserHandle.getUserId(uid);
-
verifyIncomingOp(code);
- verifyIncomingUser(userId);
- verifyIncomingPackage(packageName, userId);
+ verifyIncomingPackage(packageName, UserHandle.getUserId(uid));
ArraySet<ModeCallback> repCbs = null;
code = AppOpsManager.opToSwitch(code);
@@ -2867,11 +2858,8 @@ public class AppOpsService extends IAppOpsService.Stub {
private int checkOperationImpl(int code, int uid, String packageName,
boolean raw) {
- int userId = UserHandle.getUserId(uid);
-
verifyIncomingOp(code);
- verifyIncomingUser(userId);
- verifyIncomingPackage(packageName, userId);
+ verifyIncomingPackage(packageName, UserHandle.getUserId(uid));
String resolvedPackageName = resolvePackageName(uid, packageName);
if (resolvedPackageName == null) {
@@ -2990,15 +2978,10 @@ public class AppOpsService extends IAppOpsService.Stub {
String proxiedAttributionTag, int proxyUid, String proxyPackageName,
String proxyAttributionTag, boolean shouldCollectAsyncNotedOp, String message,
boolean shouldCollectMessage) {
- int proxiedUserId = UserHandle.getUserId(proxiedUid);
- int proxyUserId = UserHandle.getUserId(proxyUid);
-
verifyIncomingUid(proxyUid);
verifyIncomingOp(code);
- verifyIncomingUser(proxiedUserId);
- verifyIncomingUser(proxyUserId);
- verifyIncomingPackage(proxiedPackageName, proxiedUserId);
- verifyIncomingPackage(proxyPackageName, proxyUserId);
+ verifyIncomingPackage(proxiedPackageName, UserHandle.getUserId(proxiedUid));
+ verifyIncomingPackage(proxyPackageName, UserHandle.getUserId(proxyUid));
String resolveProxyPackageName = resolvePackageName(proxyUid, proxyPackageName);
if (resolveProxyPackageName == null) {
@@ -3048,12 +3031,9 @@ public class AppOpsService extends IAppOpsService.Stub {
private int noteOperationImpl(int code, int uid, @Nullable String packageName,
@Nullable String attributionTag, boolean shouldCollectAsyncNotedOp,
@Nullable String message, boolean shouldCollectMessage) {
- int userId = UserHandle.getUserId(uid);
-
verifyIncomingUid(uid);
verifyIncomingOp(code);
- verifyIncomingUser(userId);
- verifyIncomingPackage(packageName, userId);
+ verifyIncomingPackage(packageName, UserHandle.getUserId(uid));
String resolvedPackageName = resolvePackageName(uid, packageName);
if (resolvedPackageName == null) {
@@ -3430,12 +3410,9 @@ public class AppOpsService extends IAppOpsService.Stub {
public int startOperation(IBinder clientId, int code, int uid, String packageName,
String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp,
String message, boolean shouldCollectMessage) {
- int userId = UserHandle.getUserId(uid);
-
verifyIncomingUid(uid);
verifyIncomingOp(code);
- verifyIncomingUser(userId);
- verifyIncomingPackage(packageName, userId);
+ verifyIncomingPackage(packageName, UserHandle.getUserId(uid));
String resolvedPackageName = resolvePackageName(uid, packageName);
if (resolvedPackageName == null) {
@@ -3515,12 +3492,9 @@ public class AppOpsService extends IAppOpsService.Stub {
@Override
public void finishOperation(IBinder clientId, int code, int uid, String packageName,
String attributionTag) {
- int userId = UserHandle.getUserId(uid);
-
verifyIncomingUid(uid);
verifyIncomingOp(code);
- verifyIncomingUser(userId);
- verifyIncomingPackage(packageName, userId);
+ verifyIncomingPackage(packageName, UserHandle.getUserId(uid));
String resolvedPackageName = resolvePackageName(uid, packageName);
if (resolvedPackageName == null) {
@@ -3749,33 +3723,6 @@ public class AppOpsService extends IAppOpsService.Stub {
}
}
- private void verifyIncomingUser(@UserIdInt int userId) {
- int callingUid = Binder.getCallingUid();
- int callingUserId = UserHandle.getUserId(callingUid);
- int callingPid = Binder.getCallingPid();
-
- if (callingUserId != userId) {
- // Prevent endless loop between when checking appops inside of handleIncomingUser
- if (Binder.getCallingPid() == ActivityManagerService.MY_PID) {
- return;
- }
- long token = Binder.clearCallingIdentity();
- try {
- try {
- LocalServices.getService(ActivityManagerInternal.class).handleIncomingUser(
- callingPid, callingUid, userId, /* allowAll */ false,
- ALLOW_ACROSS_PROFILES_IN_PROFILE_OR_NON_FULL, "appop operation", null);
- } catch (Exception e) {
- EventLog.writeEvent(0x534e4554, "153996875", "appop", userId);
-
- throw e;
- }
- } finally {
- Binder.restoreCallingIdentity(token);
- }
- }
- }
-
private @Nullable UidState getUidStateLocked(int uid, boolean edit) {
UidState uidState = mUidStates.get(uid);
if (uidState == null) {
@@ -5855,11 +5802,8 @@ public class AppOpsService extends IAppOpsService.Stub {
return false;
}
}
- int userId = UserHandle.getUserId(uid);
-
verifyIncomingOp(code);
- verifyIncomingUser(userId);
- verifyIncomingPackage(packageName, userId);
+ verifyIncomingPackage(packageName, UserHandle.getUserId(uid));
final String resolvedPackageName = resolvePackageName(uid, packageName);
if (resolvedPackageName == null) {
diff --git a/services/core/java/com/android/server/appop/TEST_MAPPING b/services/core/java/com/android/server/appop/TEST_MAPPING
index a3e1b7a7e5c5..84de25c06ebf 100644
--- a/services/core/java/com/android/server/appop/TEST_MAPPING
+++ b/services/core/java/com/android/server/appop/TEST_MAPPING
@@ -7,9 +7,6 @@
"name": "CtsAppOps2TestCases"
},
{
- "name": "CtsAppOpHostTestCases"
- },
- {
"name": "FrameworksServicesTests",
"options": [
{
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 32be03fb4ef8..366f30318cd5 100755
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -414,13 +414,6 @@ public class AudioService extends IAudioService.Stub
AppOpsManager.OP_AUDIO_MEDIA_VOLUME // STREAM_ASSISTANT
};
- private static Set<Integer> sDeviceVolumeBehaviorSupportedDeviceOutSet = new HashSet<>(
- Arrays.asList(
- AudioSystem.DEVICE_OUT_HDMI,
- AudioSystem.DEVICE_OUT_HDMI_ARC,
- AudioSystem.DEVICE_OUT_SPDIF,
- AudioSystem.DEVICE_OUT_LINE));
-
private final boolean mUseFixedVolume;
// If absolute volume is supported in AVRCP device
@@ -4952,11 +4945,6 @@ public class AudioService extends IAudioService.Stub
private void setDeviceVolumeBehaviorInternal(int audioSystemDeviceOut,
@AudioManager.DeviceVolumeBehavior int deviceVolumeBehavior, @NonNull String caller) {
- if (!sDeviceVolumeBehaviorSupportedDeviceOutSet.contains(audioSystemDeviceOut)) {
- // unsupported for now
- throw new IllegalArgumentException("Unsupported device type " + audioSystemDeviceOut);
- }
-
// update device masks based on volume behavior
switch (deviceVolumeBehavior) {
case AudioManager.DEVICE_VOLUME_BEHAVIOR_VARIABLE:
@@ -4990,20 +4978,14 @@ public class AudioService extends IAudioService.Stub
* @param device the audio output device type
* @return the volume behavior for the device
*/
- public @AudioManager.DeviceVolumeBehaviorState int getDeviceVolumeBehavior(
- @NonNull AudioDeviceAttributes device) {
+ public @AudioManager.DeviceVolumeBehavior
+ int getDeviceVolumeBehavior(@NonNull AudioDeviceAttributes device) {
// verify permissions
enforceModifyAudioRoutingPermission();
// translate Java device type to native device type (for the devices masks for full / fixed)
final int audioSystemDeviceOut = AudioDeviceInfo.convertDeviceTypeToInternalDevice(
device.getType());
- if (!sDeviceVolumeBehaviorSupportedDeviceOutSet.contains(audioSystemDeviceOut)
- && audioSystemDeviceOut != AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP
- && audioSystemDeviceOut != AudioSystem.DEVICE_OUT_HEARING_AID) {
- throw new IllegalArgumentException("Unsupported volume behavior "
- + audioSystemDeviceOut);
- }
int setDeviceVolumeBehavior = retrieveStoredDeviceVolumeBehavior(audioSystemDeviceOut);
if (setDeviceVolumeBehavior != AudioManager.DEVICE_VOLUME_BEHAVIOR_UNSET) {
@@ -9081,7 +9063,7 @@ public class AudioService extends IAudioService.Stub
}
private void restoreDeviceVolumeBehavior() {
- for (int deviceType : sDeviceVolumeBehaviorSupportedDeviceOutSet) {
+ for (int deviceType : AudioSystem.DEVICE_OUT_ALL_SET) {
if (DEBUG_VOL) {
Log.d(TAG, "Retrieving Volume Behavior for DeviceType: " + deviceType);
}
diff --git a/services/core/java/com/android/server/pm/OWNERS b/services/core/java/com/android/server/pm/OWNERS
index fe6aad70c31e..e48862e2e5e0 100644
--- a/services/core/java/com/android/server/pm/OWNERS
+++ b/services/core/java/com/android/server/pm/OWNERS
@@ -14,16 +14,16 @@ per-file ApexManager.java = dariofreni@google.com, ioffe@google.com, olilan@goog
per-file StagingManager.java = dariofreni@google.com, ioffe@google.com, olilan@google.com
# dex
-per-file AbstractStatsBase.java = agampe@google.com, calin@google.com, ngeoffray@google.com
-per-file BackgroundDexOptService.java = agampe@google.com, calin@google.com, ngeoffray@google.com
-per-file CompilerStats.java = agampe@google.com, calin@google.com, ngeoffray@google.com
-per-file DynamicCodeLoggingService.java = alanstokes@google.com, agampe@google.com, calin@google.com, ngeoffray@google.com
-per-file InstructionSets.java = agampe@google.com, calin@google.com, ngeoffray@google.com
-per-file OtaDexoptService.java = agampe@google.com, calin@google.com, ngeoffray@google.com
-per-file OtaDexoptShellCommand.java = agampe@google.com, calin@google.com, ngeoffray@google.com
-per-file PackageDexOptimizer.java = agampe@google.com, calin@google.com, ngeoffray@google.com
-per-file PackageManagerServiceCompilerMapping.java = agampe@google.com, calin@google.com, ngeoffray@google.com
-per-file PackageUsage.java = agampe@google.com, calin@google.com, ngeoffray@google.com
+per-file AbstractStatsBase.java = calin@google.com, ngeoffray@google.com
+per-file BackgroundDexOptService.java = calin@google.com, ngeoffray@google.com
+per-file CompilerStats.java = calin@google.com, ngeoffray@google.com
+per-file DynamicCodeLoggingService.java = alanstokes@google.com, calin@google.com, ngeoffray@google.com
+per-file InstructionSets.java = calin@google.com, ngeoffray@google.com
+per-file OtaDexoptService.java = calin@google.com, ngeoffray@google.com
+per-file OtaDexoptShellCommand.java = calin@google.com, ngeoffray@google.com
+per-file PackageDexOptimizer.java = calin@google.com, ngeoffray@google.com
+per-file PackageManagerServiceCompilerMapping.java = calin@google.com, ngeoffray@google.com
+per-file PackageUsage.java = calin@google.com, ngeoffray@google.com
# multi user / cross profile
per-file CrossProfileAppsServiceImpl.java = omakoto@google.com, yamasani@google.com
diff --git a/services/core/java/com/android/server/pm/PackageInstallerService.java b/services/core/java/com/android/server/pm/PackageInstallerService.java
index 312dcddd577d..55e7ca8ca838 100644
--- a/services/core/java/com/android/server/pm/PackageInstallerService.java
+++ b/services/core/java/com/android/server/pm/PackageInstallerService.java
@@ -1284,10 +1284,16 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
int N = mSessions.size();
for (int i = 0; i < N; i++) {
final PackageInstallerSession session = mSessions.valueAt(i);
- if (session.isStagedAndInTerminalState()) {
+
+ // Do not print finalized staged session as active install sessions
+ final PackageInstallerSession rootSession = session.hasParentSessionId()
+ ? getSession(session.getParentSessionId())
+ : session;
+ if (rootSession.isStagedAndInTerminalState()) {
finalizedSessions.add(session);
continue;
}
+
session.dump(pw);
pw.println();
}
diff --git a/services/core/java/com/android/server/pm/ShortcutService.java b/services/core/java/com/android/server/pm/ShortcutService.java
index 89ed3c755783..700f7be83e15 100644
--- a/services/core/java/com/android/server/pm/ShortcutService.java
+++ b/services/core/java/com/android/server/pm/ShortcutService.java
@@ -260,7 +260,8 @@ public class ShortcutService extends IShortcutService.Stub {
private static final int PACKAGE_MATCH_FLAGS =
PackageManager.MATCH_DIRECT_BOOT_AWARE
| PackageManager.MATCH_DIRECT_BOOT_UNAWARE
- | PackageManager.MATCH_UNINSTALLED_PACKAGES;
+ | PackageManager.MATCH_UNINSTALLED_PACKAGES
+ | PackageManager.MATCH_DISABLED_COMPONENTS;
private static final int SYSTEM_APP_MASK =
ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP;
@@ -278,12 +279,6 @@ public class ShortcutService extends IShortcutService.Stub {
}
};
- private static Predicate<ResolveInfo> ACTIVITY_NOT_SYSTEM_NOR_ENABLED = (ri) -> {
- final ApplicationInfo ai = ri.activityInfo.applicationInfo;
- final boolean isSystemApp = ai != null && (ai.flags & SYSTEM_APP_MASK) != 0;
- return !isSystemApp && !ri.activityInfo.enabled;
- };
-
private static Predicate<ResolveInfo> ACTIVITY_NOT_INSTALLED = (ri) ->
!isInstalled(ri.activityInfo);
@@ -3685,10 +3680,8 @@ public class ShortcutService extends IShortcutService.Stub {
final long start = getStatStartTime();
final long token = injectClearCallingIdentity();
try {
- return mIPackageManager.getPackageInfo(
- packageName, PACKAGE_MATCH_FLAGS | PackageManager.MATCH_DISABLED_COMPONENTS
- | (getSignatures ? PackageManager.GET_SIGNING_CERTIFICATES : 0),
- userId);
+ return mIPackageManager.getPackageInfo(packageName, PACKAGE_MATCH_FLAGS
+ | (getSignatures ? PackageManager.GET_SIGNING_CERTIFICATES : 0), userId);
} catch (RemoteException e) {
// Shouldn't happen.
Slog.wtf(TAG, "RemoteException", e);
@@ -3721,8 +3714,7 @@ public class ShortcutService extends IShortcutService.Stub {
final long start = getStatStartTime();
final long token = injectClearCallingIdentity();
try {
- return mIPackageManager.getApplicationInfo(packageName,
- PACKAGE_MATCH_FLAGS | PackageManager.MATCH_DISABLED_COMPONENTS, userId);
+ return mIPackageManager.getApplicationInfo(packageName, PACKAGE_MATCH_FLAGS, userId);
} catch (RemoteException e) {
// Shouldn't happen.
Slog.wtf(TAG, "RemoteException", e);
@@ -3753,9 +3745,8 @@ public class ShortcutService extends IShortcutService.Stub {
final long start = getStatStartTime();
final long token = injectClearCallingIdentity();
try {
- return mIPackageManager.getActivityInfo(activity, (PACKAGE_MATCH_FLAGS
- | PackageManager.MATCH_DISABLED_COMPONENTS | PackageManager.GET_META_DATA),
- userId);
+ return mIPackageManager.getActivityInfo(activity,
+ PACKAGE_MATCH_FLAGS | PackageManager.GET_META_DATA, userId);
} catch (RemoteException e) {
// Shouldn't happen.
Slog.wtf(TAG, "RemoteException", e);
@@ -3800,8 +3791,7 @@ public class ShortcutService extends IShortcutService.Stub {
List<PackageInfo> injectGetPackagesWithUninstalled(@UserIdInt int userId)
throws RemoteException {
final ParceledListSlice<PackageInfo> parceledList =
- mIPackageManager.getInstalledPackages(
- PACKAGE_MATCH_FLAGS | PackageManager.MATCH_DISABLED_COMPONENTS, userId);
+ mIPackageManager.getInstalledPackages(PACKAGE_MATCH_FLAGS, userId);
if (parceledList == null) {
return Collections.emptyList();
}
@@ -3836,6 +3826,41 @@ public class ShortcutService extends IShortcutService.Stub {
return (ai != null) && ((ai.flags & flags) == flags);
}
+ // Due to b/38267327, ActivityInfo.enabled may not reflect the current state of the component
+ // and we need to check the enabled state via PackageManager.getComponentEnabledSetting.
+ private boolean isEnabled(@Nullable ActivityInfo ai, int userId) {
+ if (ai == null) {
+ return false;
+ }
+
+ int enabledFlag;
+ final long token = injectClearCallingIdentity();
+ try {
+ enabledFlag = mIPackageManager.getComponentEnabledSetting(
+ ai.getComponentName(), userId);
+ } catch (RemoteException e) {
+ // Shouldn't happen.
+ Slog.wtf(TAG, "RemoteException", e);
+ return false;
+ } finally {
+ injectRestoreCallingIdentity(token);
+ }
+
+ if ((enabledFlag == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT && ai.enabled)
+ || enabledFlag == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
+ return true;
+ }
+ return false;
+ }
+
+ private static boolean isSystem(@Nullable ActivityInfo ai) {
+ return (ai != null) && isSystem(ai.applicationInfo);
+ }
+
+ private static boolean isSystem(@Nullable ApplicationInfo ai) {
+ return (ai != null) && (ai.flags & SYSTEM_APP_MASK) != 0;
+ }
+
private static boolean isInstalled(@Nullable ApplicationInfo ai) {
return (ai != null) && ai.enabled && (ai.flags & ApplicationInfo.FLAG_INSTALLED) != 0;
}
@@ -3900,12 +3925,6 @@ public class ShortcutService extends IShortcutService.Stub {
return intent;
}
- private static boolean isSystemApp(@Nullable final ApplicationInfo ai) {
- final int systemAppMask =
- ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP;
- return ai != null && ((ai.flags & systemAppMask) != 0);
- }
-
/**
* Same as queryIntentActivitiesAsUser, except it makes sure the package is installed,
* and only returns exported activities.
@@ -3938,7 +3957,10 @@ public class ShortcutService extends IShortcutService.Stub {
}
// Make sure the package is installed.
resolved.removeIf(ACTIVITY_NOT_INSTALLED);
- resolved.removeIf(ACTIVITY_NOT_SYSTEM_NOR_ENABLED);
+ resolved.removeIf((ri) -> {
+ final ActivityInfo ai = ri.activityInfo;
+ return !isSystem(ai) && !isEnabled(ai, userId);
+ });
if (exportedOnly) {
resolved.removeIf(ACTIVITY_NOT_EXPORTED);
}
diff --git a/services/core/java/com/android/server/pm/permission/PermissionManagerService.java b/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
index 6e0efb09aff3..be93b8f95b79 100644
--- a/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
+++ b/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
@@ -137,7 +137,6 @@ import com.android.server.LocalServices;
import com.android.server.ServiceThread;
import com.android.server.SystemConfig;
import com.android.server.Watchdog;
-import com.android.server.am.ActivityManagerService;
import com.android.server.pm.ApexManager;
import com.android.server.pm.PackageManagerServiceUtils;
import com.android.server.pm.PackageSetting;
@@ -922,16 +921,6 @@ public class PermissionManagerService extends IPermissionManager.Stub {
}
final int uid = UserHandle.getUid(userId, pkg.getUid());
-
- try {
- enforceCrossUserOrProfilePermission(Binder.getCallingUid(), UserHandle.getUserId(uid),
- false, false, "checkPermissionInternal");
- } catch (Exception e) {
- EventLog.writeEvent(0x534e4554, "153996875", "checkPermission", uid);
-
- throw e;
- }
-
final PackageSetting ps = (PackageSetting) mPackageManagerInt.getPackageSetting(
pkg.getPackageName());
if (ps == null) {
@@ -4399,7 +4388,7 @@ public class PermissionManagerService extends IPermissionManager.Stub {
}
final int callingUserId = UserHandle.getUserId(callingUid);
if (hasCrossUserPermission(
- Binder.getCallingPid(), callingUid, callingUserId, userId, requireFullPermission,
+ callingUid, callingUserId, userId, requireFullPermission,
requirePermissionWhenSameUser)) {
return;
}
@@ -4426,54 +4415,37 @@ public class PermissionManagerService extends IPermissionManager.Stub {
private void enforceCrossUserOrProfilePermission(int callingUid, int userId,
boolean requireFullPermission, boolean checkShell,
String message) {
- int callingPid = Binder.getCallingPid();
- final int callingUserId = UserHandle.getUserId(callingUid);
-
if (userId < 0) {
throw new IllegalArgumentException("Invalid userId " + userId);
}
-
- if (callingUserId == userId) {
- return;
+ if (checkShell) {
+ PackageManagerServiceUtils.enforceShellRestriction(mUserManagerInt,
+ UserManager.DISALLOW_DEBUGGING_FEATURES, callingUid, userId);
}
-
- // Prevent endless loop between when checking permission while checking a permission
- if (callingPid == ActivityManagerService.MY_PID) {
+ final int callingUserId = UserHandle.getUserId(callingUid);
+ if (hasCrossUserPermission(callingUid, callingUserId, userId, requireFullPermission,
+ /*requirePermissionWhenSameUser= */ false)) {
return;
}
-
- long token = Binder.clearCallingIdentity();
- try {
- if (checkShell) {
- PackageManagerServiceUtils.enforceShellRestriction(mUserManagerInt,
- UserManager.DISALLOW_DEBUGGING_FEATURES, callingUid, userId);
- }
- if (hasCrossUserPermission(callingPid, callingUid, callingUserId, userId,
- requireFullPermission, /*requirePermissionWhenSameUser= */ false)) {
- return;
- }
- final boolean isSameProfileGroup = isSameProfileGroup(callingUserId, userId);
- if (isSameProfileGroup && PermissionChecker.checkPermissionForPreflight(
- mContext,
- android.Manifest.permission.INTERACT_ACROSS_PROFILES,
- PermissionChecker.PID_UNKNOWN,
- callingUid,
- mPackageManagerInt.getPackage(callingUid).getPackageName())
- == PermissionChecker.PERMISSION_GRANTED) {
- return;
- }
-
- String errorMessage = buildInvalidCrossUserOrProfilePermissionMessage(
- message, requireFullPermission, isSameProfileGroup);
- Slog.w(TAG, errorMessage);
- throw new SecurityException(errorMessage);
- } finally {
- Binder.restoreCallingIdentity(token);
+ final boolean isSameProfileGroup = isSameProfileGroup(callingUserId, userId);
+ if (isSameProfileGroup && PermissionChecker.checkPermissionForPreflight(
+ mContext,
+ android.Manifest.permission.INTERACT_ACROSS_PROFILES,
+ PermissionChecker.PID_UNKNOWN,
+ callingUid,
+ mPackageManagerInt.getPackage(callingUid).getPackageName())
+ == PermissionChecker.PERMISSION_GRANTED) {
+ return;
}
+ String errorMessage = buildInvalidCrossUserOrProfilePermissionMessage(
+ message, requireFullPermission, isSameProfileGroup);
+ Slog.w(TAG, errorMessage);
+ throw new SecurityException(errorMessage);
}
- private boolean hasCrossUserPermission(int callingPid, int callingUid, int callingUserId,
- int userId, boolean requireFullPermission, boolean requirePermissionWhenSameUser) {
+ private boolean hasCrossUserPermission(
+ int callingUid, int callingUserId, int userId, boolean requireFullPermission,
+ boolean requirePermissionWhenSameUser) {
if (!requirePermissionWhenSameUser && userId == callingUserId) {
return true;
}
@@ -4481,11 +4453,15 @@ public class PermissionManagerService extends IPermissionManager.Stub {
return true;
}
if (requireFullPermission) {
- return mContext.checkPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL,
- callingPid, callingUid) == PackageManager.PERMISSION_GRANTED;
+ return hasPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL);
}
- return mContext.checkPermission(android.Manifest.permission.INTERACT_ACROSS_USERS,
- callingPid, callingUid) == PackageManager.PERMISSION_GRANTED;
+ return hasPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
+ || hasPermission(Manifest.permission.INTERACT_ACROSS_USERS);
+ }
+
+ private boolean hasPermission(String permission) {
+ return mContext.checkCallingOrSelfPermission(permission)
+ == PackageManager.PERMISSION_GRANTED;
}
private boolean isSameProfileGroup(@UserIdInt int callerUserId, @UserIdInt int userId) {
diff --git a/services/core/java/com/android/server/pm/permission/TEST_MAPPING b/services/core/java/com/android/server/pm/permission/TEST_MAPPING
index 65dc320eadc2..c0d71ac26853 100644
--- a/services/core/java/com/android/server/pm/permission/TEST_MAPPING
+++ b/services/core/java/com/android/server/pm/permission/TEST_MAPPING
@@ -18,24 +18,21 @@
]
},
{
- "name": "CtsPermission2TestCases",
+ "name": "CtsAppSecurityHostTestCases",
"options": [
{
- "include-filter": "android.permission2.cts.RestrictedPermissionsTest"
- },
- {
- "include-filter": "android.permission.cts.PermissionMaxSdkVersionTest"
+ "include-filter": "android.appsecurity.cts.AppSecurityTests#rebootWithDuplicatePermission"
}
]
},
{
- "name": "CtsPermissionHostTestCases"
- },
- {
- "name": "CtsAppSecurityHostTestCases",
+ "name": "CtsPermission2TestCases",
"options": [
{
- "include-filter": "android.appsecurity.cts.AppSecurityTests#rebootWithDuplicatePermission"
+ "include-filter": "android.permission2.cts.RestrictedPermissionsTest"
+ },
+ {
+ "include-filter": "android.permission.cts.PermissionMaxSdkVersionTest"
}
]
},
diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java
index 526ec08930ea..ac96d144c4d0 100644
--- a/services/core/java/com/android/server/wm/RootWindowContainer.java
+++ b/services/core/java/com/android/server/wm/RootWindowContainer.java
@@ -2155,6 +2155,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
// non-fullscreen bounds. Then when this new PIP task exits PIP, it can restore
// to its previous freeform bounds.
stack.setLastNonFullscreenBounds(task.mLastNonFullscreenBounds);
+ stack.setBounds(task.getBounds());
// There are multiple activities in the task and moving the top activity should
// reveal/leave the other activities in their original task.
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index ae6ccda71558..97ae505b4fcf 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -121,9 +121,7 @@ import com.android.server.inputmethod.MultiClientInputMethodManagerService;
import com.android.server.integrity.AppIntegrityManagerService;
import com.android.server.lights.LightsService;
import com.android.server.location.LocationManagerService;
-import com.android.server.media.MediaResourceMonitorService;
import com.android.server.media.MediaRouterService;
-import com.android.server.media.MediaSessionService;
import com.android.server.media.projection.MediaProjectionManagerService;
import com.android.server.net.NetworkPolicyManagerService;
import com.android.server.net.NetworkStatsService;
@@ -152,6 +150,7 @@ import com.android.server.policy.role.LegacyRoleResolutionPolicy;
import com.android.server.power.PowerManagerService;
import com.android.server.power.ShutdownThread;
import com.android.server.power.ThermalManagerService;
+import com.android.server.profcollect.ProfcollectForwardingService;
import com.android.server.recoverysystem.RecoverySystemService;
import com.android.server.restrictions.RestrictionsManagerService;
import com.android.server.role.RoleManagerService;
@@ -311,6 +310,10 @@ public final class SystemServer {
"com.android.server.rollback.RollbackManagerService";
private static final String ALARM_MANAGER_SERVICE_CLASS =
"com.android.server.alarm.AlarmManagerService";
+ private static final String MEDIA_SESSION_SERVICE_CLASS =
+ "com.android.server.media.MediaSessionService";
+ private static final String MEDIA_RESOURCE_MONITOR_SERVICE_CLASS =
+ "com.android.server.media.MediaResourceMonitorService";
private static final String TETHERING_CONNECTOR_CLASS = "android.net.ITetheringConnector";
@@ -1229,6 +1232,12 @@ public final class SystemServer {
mSystemServiceManager.startService(IorapForwardingService.class);
t.traceEnd();
+ if (Build.IS_DEBUGGABLE) {
+ t.traceBegin("ProfcollectForwardingService");
+ mSystemServiceManager.startService(ProfcollectForwardingService.class);
+ t.traceEnd();
+ }
+
t.traceBegin("SignedConfigService");
SignedConfigService.registerUpdateReceiver(mSystemContext);
t.traceEnd();
@@ -1886,7 +1895,7 @@ public final class SystemServer {
t.traceEnd();
t.traceBegin("StartMediaSessionService");
- mSystemServiceManager.startService(MediaSessionService.class);
+ mSystemServiceManager.startService(MEDIA_SESSION_SERVICE_CLASS);
t.traceEnd();
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_HDMI_CEC)) {
@@ -1910,7 +1919,7 @@ public final class SystemServer {
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)) {
t.traceBegin("StartMediaResourceMonitor");
- mSystemServiceManager.startService(MediaResourceMonitorService.class);
+ mSystemServiceManager.startService(MEDIA_RESOURCE_MONITOR_SERVICE_CLASS);
t.traceEnd();
}
diff --git a/services/profcollect/Android.bp b/services/profcollect/Android.bp
new file mode 100644
index 000000000000..68fba5508b58
--- /dev/null
+++ b/services/profcollect/Android.bp
@@ -0,0 +1,35 @@
+// 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.
+
+filegroup {
+ name: "services.profcollect-javasources",
+ srcs: ["src/**/*.java"],
+ path: "src",
+ visibility: ["//frameworks/base/services"],
+}
+
+filegroup {
+ name: "services.profcollect-sources",
+ srcs: [
+ ":services.profcollect-javasources",
+ ":profcollectd_aidl",
+ ],
+ visibility: ["//frameworks/base/services:__subpackages__"],
+}
+
+java_library_static {
+ name: "services.profcollect",
+ srcs: [":services.profcollect-sources"],
+ libs: ["services.core"],
+}
diff --git a/services/profcollect/OWNERS b/services/profcollect/OWNERS
new file mode 100644
index 000000000000..b380e39529e3
--- /dev/null
+++ b/services/profcollect/OWNERS
@@ -0,0 +1,3 @@
+srhines@google.com
+yabinc@google.com
+yikong@google.com
diff --git a/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java
new file mode 100644
index 000000000000..bc75dcd91813
--- /dev/null
+++ b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java
@@ -0,0 +1,196 @@
+/**
+ * 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.server.profcollect;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Handler;
+import android.os.IBinder.DeathRecipient;
+import android.os.Looper;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.os.SystemProperties;
+import android.util.Log;
+
+import com.android.server.IoThread;
+import com.android.server.LocalServices;
+import com.android.server.SystemService;
+import com.android.server.wm.ActivityMetricsLaunchObserver;
+import com.android.server.wm.ActivityMetricsLaunchObserverRegistry;
+import com.android.server.wm.ActivityTaskManagerInternal;
+
+import java.util.concurrent.ThreadLocalRandom;
+
+/**
+ * System-server-local proxy into the {@code IProfcollectd} native service.
+ */
+public final class ProfcollectForwardingService extends SystemService {
+ public static final String LOG_TAG = "ProfcollectForwardingService";
+
+ private IProfCollectd mIProfcollect;
+ private ProfcollectForwardingService mSelfService;
+ private final Handler mHandler = new ProfcollectdHandler(IoThread.getHandler().getLooper());
+
+ public ProfcollectForwardingService(Context context) {
+ super(context);
+
+ if (mSelfService != null) {
+ throw new AssertionError("only one service instance allowed");
+ }
+ mSelfService = this;
+ }
+
+ @Override
+ public void onStart() {
+ Log.i(LOG_TAG, "Profcollect forwarding service start");
+ connectNativeService();
+ if (mIProfcollect == null) {
+ return;
+ }
+ if (serviceHasSupportedTraceProvider()) {
+ registerObservers();
+ }
+ }
+
+ private boolean serviceHasSupportedTraceProvider() {
+ if (mIProfcollect == null) {
+ return false;
+ }
+ try {
+ return !mIProfcollect.GetSupportedProvider().isEmpty();
+ } catch (RemoteException e) {
+ Log.e(LOG_TAG, e.getMessage());
+ return false;
+ }
+ }
+
+ private boolean tryConnectNativeService() {
+ if (connectNativeService()) {
+ return true;
+ }
+ // Cannot connect to the native service at this time, retry after a short delay.
+ mHandler.sendEmptyMessageDelayed(ProfcollectdHandler.MESSAGE_BINDER_CONNECT, 5000);
+ return false;
+ }
+
+ private boolean connectNativeService() {
+ try {
+ IProfCollectd profcollectd =
+ IProfCollectd.Stub.asInterface(
+ ServiceManager.getServiceOrThrow("profcollectd"));
+ profcollectd.asBinder().linkToDeath(new ProfcollectdDeathRecipient(), /*flags*/0);
+ mIProfcollect = profcollectd;
+ return true;
+ } catch (ServiceManager.ServiceNotFoundException | RemoteException e) {
+ Log.w(LOG_TAG, "Failed to connect profcollectd binder service.");
+ return false;
+ }
+ }
+
+ private class ProfcollectdHandler extends Handler {
+ public ProfcollectdHandler(Looper looper) {
+ super(looper);
+ }
+
+ public static final int MESSAGE_BINDER_CONNECT = 0;
+
+ @Override
+ public void handleMessage(android.os.Message message) {
+ switch (message.what) {
+ case MESSAGE_BINDER_CONNECT:
+ connectNativeService();
+ break;
+ default:
+ throw new AssertionError("Unknown message: " + message.toString());
+ }
+ }
+ }
+
+ private class ProfcollectdDeathRecipient implements DeathRecipient {
+ @Override
+ public void binderDied() {
+ Log.w(LOG_TAG, "profcollectd has died");
+
+ mIProfcollect = null;
+ tryConnectNativeService();
+ }
+ }
+
+ // Event observers
+ private void registerObservers() {
+ registerAppLaunchObserver();
+ }
+
+ private final AppLaunchObserver mAppLaunchObserver = new AppLaunchObserver();
+ private void registerAppLaunchObserver() {
+ ActivityTaskManagerInternal atmInternal =
+ LocalServices.getService(ActivityTaskManagerInternal.class);
+ ActivityMetricsLaunchObserverRegistry launchObserverRegistry =
+ atmInternal.getLaunchObserverRegistry();
+ launchObserverRegistry.registerLaunchObserver(mAppLaunchObserver);
+ }
+
+ private void traceOnAppStart(String packageName) {
+ if (mIProfcollect == null) {
+ return;
+ }
+
+ // Sample for a fraction of app launches.
+ int traceFrequency = SystemProperties.getInt("profcollectd.applaunch_trace_freq", 2);
+ int randomNum = ThreadLocalRandom.current().nextInt(100);
+ if (randomNum < traceFrequency) {
+ try {
+ Log.i(LOG_TAG, "Tracing on app launch event: " + packageName);
+ mIProfcollect.TraceOnce("applaunch");
+ } catch (RemoteException e) {
+ Log.e(LOG_TAG, e.getMessage());
+ }
+ }
+ }
+
+ private class AppLaunchObserver implements ActivityMetricsLaunchObserver {
+ @Override
+ public void onIntentStarted(Intent intent, long timestampNanos) {
+ traceOnAppStart(intent.getPackage());
+ }
+
+ @Override
+ public void onIntentFailed() {
+ // Ignored
+ }
+
+ @Override
+ public void onActivityLaunched(byte[] activity, int temperature) {
+ // Ignored
+ }
+
+ @Override
+ public void onActivityLaunchCancelled(byte[] abortingActivity) {
+ // Ignored
+ }
+
+ @Override
+ public void onActivityLaunchFinished(byte[] finalActivity, long timestampNanos) {
+ // Ignored
+ }
+
+ @Override
+ public void onReportFullyDrawn(byte[] activity, long timestampNanos) {
+ // Ignored
+ }
+ }
+}
diff --git a/services/tests/mockingservicestests/src/com/android/server/appop/AppOpsServiceTest.java b/services/tests/mockingservicestests/src/com/android/server/appop/AppOpsServiceTest.java
index 0a61c443e0bd..7a3a9504a0b3 100644
--- a/services/tests/mockingservicestests/src/com/android/server/appop/AppOpsServiceTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/appop/AppOpsServiceTest.java
@@ -130,7 +130,9 @@ public class AppOpsServiceTest {
}
@After
- public void resetStaticMocks() {
+ public void tearDown() {
+ mAppOpsService.shutdown();
+
mMockingSession.finishMocking();
}
@@ -216,9 +218,8 @@ public class AppOpsServiceTest {
false);
mAppOpsService.writeState();
- // Create a new app ops service, and initialize its state from XML.
+ // Create a new app ops service which will initialize its state from XML.
setupAppOpsService();
- mAppOpsService.readState();
// Query the state of the 2nd service.
List<PackageOps> loggedOps = getLoggedOps();
@@ -233,9 +234,8 @@ public class AppOpsServiceTest {
mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null, false);
mAppOpsService.shutdown();
- // Create a new app ops service, and initialize its state from XML.
+ // Create a new app ops service which will initialize its state from XML.
setupAppOpsService();
- mAppOpsService.readState();
// Query the state of the 2nd service.
List<PackageOps> loggedOps = getLoggedOps();
diff --git a/services/tests/servicestests/src/com/android/server/accessibility/magnification/FullScreenMagnificationControllerTest.java b/services/tests/servicestests/src/com/android/server/accessibility/magnification/FullScreenMagnificationControllerTest.java
index a9f2e4a50ded..57bfbf33d680 100644
--- a/services/tests/servicestests/src/com/android/server/accessibility/magnification/FullScreenMagnificationControllerTest.java
+++ b/services/tests/servicestests/src/com/android/server/accessibility/magnification/FullScreenMagnificationControllerTest.java
@@ -27,6 +27,7 @@ import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -95,12 +96,15 @@ public class FullScreenMagnificationControllerTest {
ValueAnimator mMockValueAnimator;
ValueAnimator.AnimatorUpdateListener mTargetAnimationListener;
+ ValueAnimator.AnimatorListener mStateListener;
FullScreenMagnificationController mFullScreenMagnificationController;
+ Runnable mEndCallback;
@Before
public void setUp() {
Looper looper = InstrumentationRegistry.getContext().getMainLooper();
+ mEndCallback = Mockito.mock(Runnable.class);
// Pretending ID of the Thread associated with looper as main thread ID in controller
when(mMockContext.getMainLooper()).thenReturn(looper);
when(mMockControllerCtx.getContext()).thenReturn(mMockContext);
@@ -319,6 +323,7 @@ public class FullScreenMagnificationControllerTest {
for (int i = 0; i < DISPLAY_COUNT; i++) {
setScaleAndCenter_animated_stateChangesAndAnimationHappens(i);
resetMockWindowManager();
+ Mockito.reset(mEndCallback);
}
}
@@ -331,7 +336,7 @@ public class FullScreenMagnificationControllerTest {
MagnificationSpec endSpec = getMagnificationSpec(scale, offsets);
assertTrue(mFullScreenMagnificationController.setScaleAndCenter(displayId, scale,
- newCenter.x, newCenter.y, true, SERVICE_ID_1));
+ newCenter.x, newCenter.y, mEndCallback, SERVICE_ID_1));
mMessageCapturingHandler.sendAllMessages();
assertEquals(newCenter.x, mFullScreenMagnificationController.getCenterX(displayId), 0.5);
@@ -358,7 +363,33 @@ public class FullScreenMagnificationControllerTest {
Mockito.reset(mMockWindowManager);
when(mMockValueAnimator.getAnimatedFraction()).thenReturn(1.0f);
mTargetAnimationListener.onAnimationUpdate(mMockValueAnimator);
+ mStateListener.onAnimationEnd(mMockValueAnimator);
verify(mMockWindowManager).setMagnificationSpec(eq(displayId), argThat(closeTo(endSpec)));
+ verify(mEndCallback).run();
+ }
+
+ @Test
+ public void testSetScaleAndCenterWithAnimation_sameSpec_noAnimationButInvokeEndCallback() {
+ for (int i = 0; i < DISPLAY_COUNT; i++) {
+ setScaleAndCenter_sameSpec_noAnimationButInvokeEndCallback(i);
+ Mockito.reset(mEndCallback);
+ }
+ }
+
+ private void setScaleAndCenter_sameSpec_noAnimationButInvokeEndCallback(int displayId) {
+ register(displayId);
+ final PointF center = INITIAL_BOUNDS_LOWER_RIGHT_2X_CENTER;
+ final float targetScale = 2.0f;
+ assertTrue(mFullScreenMagnificationController.setScaleAndCenter(displayId,
+ targetScale, center.x, center.y, false, SERVICE_ID_1));
+ mMessageCapturingHandler.sendAllMessages();
+
+ assertFalse(mFullScreenMagnificationController.setScaleAndCenter(displayId,
+ targetScale, center.x, center.y, mEndCallback, SERVICE_ID_1));
+ mMessageCapturingHandler.sendAllMessages();
+
+ verify(mMockValueAnimator, never()).start();
+ verify(mEndCallback).run();
}
@Test
@@ -639,6 +670,69 @@ public class FullScreenMagnificationControllerTest {
}
@Test
+ public void testReset_notMagnifying_noStateChangeButInvokeCallback() {
+ for (int i = 0; i < DISPLAY_COUNT; i++) {
+ reset_notMagnifying_noStateChangeButInvokeCallback(i);
+ Mockito.reset(mEndCallback);
+ }
+ }
+
+ private void reset_notMagnifying_noStateChangeButInvokeCallback(int displayId) {
+ register(displayId);
+
+ assertFalse(mFullScreenMagnificationController.reset(displayId, mEndCallback));
+ mMessageCapturingHandler.sendAllMessages();
+
+ verify(mMockAms, never()).notifyMagnificationChanged(eq(displayId),
+ any(Region.class), anyFloat(), anyFloat(), anyFloat());
+ verify(mEndCallback).run();
+ }
+
+ @Test
+ public void testReset_Magnifying_resetsMagnificationAndInvokeLastEndCallback() {
+ for (int i = 0; i < DISPLAY_COUNT; i++) {
+ reset_Magnifying_resetsMagnificationAndInvokeLastEndCallback(i);
+ }
+ }
+
+ private void reset_Magnifying_resetsMagnificationAndInvokeLastEndCallback(int displayId) {
+ register(displayId);
+ float scale = 2.5f;
+ PointF firstCenter = INITIAL_BOUNDS_LOWER_RIGHT_2X_CENTER;
+ assertTrue(mFullScreenMagnificationController.setScaleAndCenter(displayId,
+ scale, firstCenter.x, firstCenter.y, mEndCallback, SERVICE_ID_1));
+ mMessageCapturingHandler.sendAllMessages();
+ Mockito.reset(mMockValueAnimator);
+ // Stubs the logic after the animation is started.
+ doAnswer(invocation -> {
+ mStateListener.onAnimationEnd(mMockValueAnimator);
+ return null;
+ }).when(mMockValueAnimator).cancel();
+ when(mMockValueAnimator.isRunning()).thenReturn(true);
+ // Intermediate point
+ float fraction = 0.33f;
+ when(mMockValueAnimator.getAnimatedFraction()).thenReturn(fraction);
+ mTargetAnimationListener.onAnimationUpdate(mMockValueAnimator);
+ Runnable lastEndCallback = Mockito.mock(Runnable.class);
+
+ assertTrue(mFullScreenMagnificationController.reset(displayId, lastEndCallback));
+ mMessageCapturingHandler.sendAllMessages();
+
+ // Verify expected actions.
+ verify(mEndCallback, never()).run();
+ verify(mMockValueAnimator).start();
+ verify(mMockValueAnimator).cancel();
+
+ // Fast-forward the animation to the end.
+ when(mMockValueAnimator.getAnimatedFraction()).thenReturn(1.0f);
+ mTargetAnimationListener.onAnimationUpdate(mMockValueAnimator);
+ mStateListener.onAnimationEnd(mMockValueAnimator);
+
+ assertFalse(mFullScreenMagnificationController.isMagnifying(DISPLAY_0));
+ verify(lastEndCallback).run();
+ }
+
+ @Test
public void testTurnScreenOff_resetsMagnification() {
register(DISPLAY_0);
register(DISPLAY_1);
@@ -1043,6 +1137,10 @@ public class FullScreenMagnificationControllerTest {
ArgumentCaptor.forClass(ValueAnimator.AnimatorUpdateListener.class);
verify(mMockValueAnimator).addUpdateListener(listenerArgumentCaptor.capture());
mTargetAnimationListener = listenerArgumentCaptor.getValue();
+ ArgumentCaptor<ValueAnimator.AnimatorListener> animatorListenerArgumentCaptor =
+ ArgumentCaptor.forClass(ValueAnimator.AnimatorListener.class);
+ verify(mMockValueAnimator).addListener(animatorListenerArgumentCaptor.capture());
+ mStateListener = animatorListenerArgumentCaptor.getValue();
Mockito.reset(mMockValueAnimator); // Ignore other initialization
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityDisplayTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityDisplayTests.java
index f69d7c332382..1eb45d587d33 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityDisplayTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityDisplayTests.java
@@ -59,7 +59,7 @@ import org.junit.runner.RunWith;
@Presubmit
@RunWith(WindowTestRunner.class)
// TODO(b/144248496): Merge to DisplayContentTests
-public class ActivityDisplayTests extends ActivityTestsBase {
+public class ActivityDisplayTests extends WindowTestsBase {
@Test
public void testLastFocusedStackIsUpdatedWhenMovingStack() {
@@ -89,9 +89,9 @@ public class ActivityDisplayTests extends ActivityTestsBase {
// Create a pinned stack and move to front.
final Task pinnedStack = mRootWindowContainer.getDefaultTaskDisplayArea()
.createStack(WINDOWING_MODE_PINNED, ACTIVITY_TYPE_STANDARD, ON_TOP);
- final Task pinnedTask = new TaskBuilder(mService.mStackSupervisor)
+ final Task pinnedTask = new TaskBuilder(mAtm.mStackSupervisor)
.setStack(pinnedStack).build();
- new ActivityBuilder(mService).setActivityFlags(FLAG_ALWAYS_FOCUSABLE)
+ new ActivityBuilder(mAtm).setActivityFlags(FLAG_ALWAYS_FOCUSABLE)
.setTask(pinnedTask).build();
pinnedStack.moveToFront("movePinnedStackToFront");
@@ -140,7 +140,7 @@ public class ActivityDisplayTests extends ActivityTestsBase {
// Create a display which supports system decoration and allows reparenting stacks to
// another display when the display is removed.
final DisplayContent display = new TestDisplayContent.Builder(
- mService, 1000, 1500).setSystemDecorations(true).build();
+ mAtm, 1000, 1500).setSystemDecorations(true).build();
doReturn(false).when(display).shouldDestroyContentOnRemove();
// Put home stack on the display.
@@ -162,9 +162,9 @@ public class ActivityDisplayTests extends ActivityTestsBase {
private Task createFullscreenStackWithSimpleActivityAt(DisplayContent display) {
final Task fullscreenStack = display.getDefaultTaskDisplayArea().createStack(
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, ON_TOP);
- final Task fullscreenTask = new TaskBuilder(mService.mStackSupervisor)
+ final Task fullscreenTask = new TaskBuilder(mAtm.mStackSupervisor)
.setStack(fullscreenStack).build();
- new ActivityBuilder(mService).setTask(fullscreenTask).build();
+ new ActivityBuilder(mAtm).setTask(fullscreenTask).build();
return fullscreenStack;
}
@@ -197,7 +197,7 @@ public class ActivityDisplayTests extends ActivityTestsBase {
assertNull(display.topRunningActivity(true /* considerKeyguardState */));
// Add activity that should be shown on the keyguard.
- final ActivityRecord showWhenLockedActivity = new ActivityBuilder(mService)
+ final ActivityRecord showWhenLockedActivity = new ActivityBuilder(mAtm)
.setCreateTask(true)
.setStack(stack)
.setActivityFlags(FLAG_SHOW_WHEN_LOCKED)
@@ -226,7 +226,7 @@ public class ActivityDisplayTests extends ActivityTestsBase {
final TaskDisplayArea taskDisplayArea = mRootWindowContainer.getDefaultTaskDisplayArea();
final Task alwaysOnTopStack = taskDisplayArea.createStack(WINDOWING_MODE_FREEFORM,
ACTIVITY_TYPE_STANDARD, true /* onTop */);
- final ActivityRecord activity = new ActivityBuilder(mService).setCreateTask(true)
+ final ActivityRecord activity = new ActivityBuilder(mAtm).setCreateTask(true)
.setStack(alwaysOnTopStack).build();
alwaysOnTopStack.setAlwaysOnTop(true);
taskDisplayArea.positionChildAt(POSITION_TOP, alwaysOnTopStack,
@@ -322,10 +322,10 @@ public class ActivityDisplayTests extends ActivityTestsBase {
ACTIVITY_TYPE_STANDARD, ON_TOP);
final Task stack4 = taskDisplayArea.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, ON_TOP);
- final Task task1 = new TaskBuilder(mService.mStackSupervisor).setStack(stack1).build();
- final Task task2 = new TaskBuilder(mService.mStackSupervisor).setStack(stack2).build();
- final Task task3 = new TaskBuilder(mService.mStackSupervisor).setStack(stack3).build();
- final Task task4 = new TaskBuilder(mService.mStackSupervisor).setStack(stack4).build();
+ final Task task1 = new TaskBuilder(mAtm.mStackSupervisor).setStack(stack1).build();
+ final Task task2 = new TaskBuilder(mAtm.mStackSupervisor).setStack(stack2).build();
+ final Task task3 = new TaskBuilder(mAtm.mStackSupervisor).setStack(stack3).build();
+ final Task task4 = new TaskBuilder(mAtm.mStackSupervisor).setStack(stack4).build();
// Reordering stacks while removing stacks.
doAnswer(invocation -> {
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityMetricsLaunchObserverTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityMetricsLaunchObserverTests.java
index feac6dbe1051..46c3e22da38c 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityMetricsLaunchObserverTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityMetricsLaunchObserverTests.java
@@ -59,7 +59,7 @@ import java.util.concurrent.TimeUnit;
@SmallTest
@Presubmit
@RunWith(WindowTestRunner.class)
-public class ActivityMetricsLaunchObserverTests extends ActivityTestsBase {
+public class ActivityMetricsLaunchObserverTests extends WindowTestsBase {
private ActivityMetricsLogger mActivityMetricsLogger;
private ActivityMetricsLogger.LaunchingState mLaunchingState;
private ActivityMetricsLaunchObserver mLaunchObserver;
@@ -81,11 +81,11 @@ public class ActivityMetricsLaunchObserverTests extends ActivityTestsBase {
// Sometimes we need an ActivityRecord for ActivityMetricsLogger to do anything useful.
// This seems to be the easiest way to create an ActivityRecord.
- mTrampolineActivity = new ActivityBuilder(mService)
+ mTrampolineActivity = new ActivityBuilder(mAtm)
.setCreateTask(true)
.setComponent(createRelative(DEFAULT_COMPONENT_PACKAGE_NAME, "TrampolineActivity"))
.build();
- mTopActivity = new ActivityBuilder(mService)
+ mTopActivity = new ActivityBuilder(mAtm)
.setTask(mTrampolineActivity.getTask())
.setComponent(createRelative(DEFAULT_COMPONENT_PACKAGE_NAME, "TopActivity"))
.build();
@@ -121,7 +121,7 @@ public class ActivityMetricsLaunchObserverTests extends ActivityTestsBase {
private <T> T verifyAsync(T mock) {
// With WindowTestRunner, all test methods are inside WM lock, so we have to unblock any
// messages that are waiting for the lock.
- waitHandlerIdle(mService.mH);
+ waitHandlerIdle(mAtm.mH);
// AMLO callbacks happen on a separate thread than AML calls, so we need to use a timeout.
return verify(mock, timeout(TimeUnit.SECONDS.toMillis(5)));
}
@@ -192,7 +192,7 @@ public class ActivityMetricsLaunchObserverTests extends ActivityTestsBase {
// Suppress resume when creating the record because we want to notify logger manually.
mSupervisor.beginDeferResume();
// Create an activity with different process that meets process switch.
- final ActivityRecord noDrawnActivity = new ActivityBuilder(mService)
+ final ActivityRecord noDrawnActivity = new ActivityBuilder(mAtm)
.setTask(mTopActivity.getTask())
.setProcessName("other")
.build();
@@ -321,7 +321,7 @@ public class ActivityMetricsLaunchObserverTests extends ActivityTestsBase {
onActivityLaunched(mTopActivity);
final ActivityMetricsLogger.LaunchingState previousState = mLaunchingState;
- final ActivityRecord otherActivity = new ActivityBuilder(mService)
+ final ActivityRecord otherActivity = new ActivityBuilder(mAtm)
.setComponent(createRelative(DEFAULT_COMPONENT_PACKAGE_NAME, "OtherActivity"))
.setCreateTask(true)
.build();
@@ -345,7 +345,7 @@ public class ActivityMetricsLaunchObserverTests extends ActivityTestsBase {
.setDisplay(addNewDisplayContentAt(DisplayContent.POSITION_BOTTOM))
.setCreateActivity(false)
.build();
- final ActivityRecord activityOnNewDisplay = new ActivityBuilder(mService)
+ final ActivityRecord activityOnNewDisplay = new ActivityBuilder(mAtm)
.setStack(stack)
.setCreateTask(true)
.setProcessName("new")
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
index 2f020736d059..e3830f686a42 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
@@ -67,7 +67,6 @@ import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
@@ -122,7 +121,7 @@ import org.mockito.invocation.InvocationOnMock;
@MediumTest
@Presubmit
@RunWith(WindowTestRunner.class)
-public class ActivityRecordTests extends ActivityTestsBase {
+public class ActivityRecordTests extends WindowTestsBase {
private Task mStack;
private Task mTask;
private ActivityRecord mActivity;
@@ -133,7 +132,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
mTask = mStack.getBottomMostTask();
mActivity = mTask.getTopNonFinishingActivity();
- setBooted(mService);
+ setBooted(mAtm);
}
@Test
@@ -152,16 +151,16 @@ public class ActivityRecordTests extends ActivityTestsBase {
public void testStackCleanupOnTaskRemoval() {
mStack.removeChild(mTask, null /*reason*/);
// Stack should be gone on task removal.
- assertNull(mService.mRootWindowContainer.getStack(mStack.mTaskId));
+ assertNull(mAtm.mRootWindowContainer.getStack(mStack.mTaskId));
}
@Test
public void testRemoveChildWithOverlayActivity() {
final ActivityRecord overlayActivity =
- new ActivityBuilder(mService).setTask(mTask).build();
+ new ActivityBuilder(mAtm).setTask(mTask).build();
overlayActivity.setTaskOverlay(true);
final ActivityRecord overlayActivity2 =
- new ActivityBuilder(mService).setTask(mTask).build();
+ new ActivityBuilder(mAtm).setTask(mTask).build();
overlayActivity2.setTaskOverlay(true);
mTask.removeChild(overlayActivity2, "test");
@@ -170,7 +169,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
@Test
public void testNoCleanupMovingActivityInSameStack() {
- final Task newTask = new TaskBuilder(mService.mStackSupervisor).setStack(mStack).build();
+ final Task newTask = new TaskBuilder(mAtm.mStackSupervisor).setStack(mStack).build();
mActivity.reparent(newTask, 0, null /*reason*/);
verify(mStack, times(0)).cleanUpActivityReferences(any());
}
@@ -213,7 +212,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
// Make sure the state does not change if we are not the current top activity.
mActivity.setState(STOPPED, "testPausingWhenVisibleFromStopped behind");
- final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord topActivity = new ActivityBuilder(mAtm).setTask(mTask).build();
mStack.mTranslucentActivityWaiting = topActivity;
mActivity.makeVisibleIfNeeded(null /* starting */, true /* reportToClient */);
assertTrue(mActivity.isState(STARTED));
@@ -231,8 +230,8 @@ public class ActivityRecordTests extends ActivityTestsBase {
@Test
public void testCanBeLaunchedOnDisplay() {
- mService.mSupportsMultiWindow = true;
- final ActivityRecord activity = new ActivityBuilder(mService).build();
+ mAtm.mSupportsMultiWindow = true;
+ final ActivityRecord activity = new ActivityBuilder(mAtm).build();
// An activity can be launched on default display.
assertTrue(activity.canBeLaunchedOnDisplay(DEFAULT_DISPLAY));
@@ -251,7 +250,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
// Set options for two ActivityRecords in same Task. Apply one ActivityRecord options.
// Pending options should be cleared for both ActivityRecords
- ActivityRecord activity2 = new ActivityBuilder(mService).setTask(mTask).build();
+ ActivityRecord activity2 = new ActivityBuilder(mAtm).setTask(mTask).build();
activity2.updateOptionsLocked(activityOptions);
mActivity.updateOptionsLocked(activityOptions);
mActivity.applyOptionsLocked();
@@ -260,8 +259,8 @@ public class ActivityRecordTests extends ActivityTestsBase {
// Set options for two ActivityRecords in separate Tasks. Apply one ActivityRecord options.
// Pending options should be cleared for only ActivityRecord that was applied
- Task task2 = new TaskBuilder(mService.mStackSupervisor).setStack(mStack).build();
- activity2 = new ActivityBuilder(mService).setTask(task2).build();
+ Task task2 = new TaskBuilder(mAtm.mStackSupervisor).setStack(mStack).build();
+ activity2 = new ActivityBuilder(mAtm).setTask(task2).build();
activity2.updateOptionsLocked(activityOptions);
mActivity.updateOptionsLocked(activityOptions);
mActivity.applyOptionsLocked();
@@ -362,7 +361,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
@Test
public void testSetRequestedOrientationUpdatesConfiguration() throws Exception {
- mActivity = new ActivityBuilder(mService)
+ mActivity = new ActivityBuilder(mAtm)
.setTask(mTask)
.setConfigChanges(CONFIG_ORIENTATION | CONFIG_SCREEN_LAYOUT)
.build();
@@ -405,7 +404,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
final ActivityConfigurationChangeItem expected =
ActivityConfigurationChangeItem.obtain(newConfig);
- verify(mService.getLifecycleManager()).scheduleTransaction(eq(mActivity.app.getThread()),
+ verify(mAtm.getLifecycleManager()).scheduleTransaction(eq(mActivity.app.getThread()),
eq(mActivity.appToken), eq(expected));
}
@@ -500,9 +499,9 @@ public class ActivityRecordTests extends ActivityTestsBase {
@Test
public void testShouldMakeActive_nonTopVisible() {
- ActivityRecord finishingActivity = new ActivityBuilder(mService).setTask(mTask).build();
+ ActivityRecord finishingActivity = new ActivityBuilder(mAtm).setTask(mTask).build();
finishingActivity.finishing = true;
- ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build();
+ ActivityRecord topActivity = new ActivityBuilder(mAtm).setTask(mTask).build();
mActivity.setState(Task.ActivityState.STOPPED, "Testing");
assertEquals(false, mActivity.shouldMakeActive(null /* activeActivity */));
@@ -528,7 +527,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
mActivity.setState(Task.ActivityState.STOPPED, "Testing");
spyOn(mStack);
- ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build();
+ ActivityRecord topActivity = new ActivityBuilder(mAtm).setTask(mTask).build();
mActivity.addResultLocked(topActivity, "resultWho", 0, 0, new Intent());
topActivity.finishing = true;
@@ -539,7 +538,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
@Test
public void testPushConfigurationWhenLaunchTaskBehind() throws Exception {
- mActivity = new ActivityBuilder(mService)
+ mActivity = new ActivityBuilder(mAtm)
.setTask(mTask)
.setLaunchTaskBehind(true)
.setConfigChanges(CONFIG_ORIENTATION)
@@ -574,7 +573,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
final ActivityConfigurationChangeItem expected =
ActivityConfigurationChangeItem.obtain(newConfig);
- verify(mService.getLifecycleManager()).scheduleTransaction(
+ verify(mAtm.getLifecycleManager()).scheduleTransaction(
eq(mActivity.app.getThread()), eq(mActivity.appToken), eq(expected));
} finally {
stack.getDisplayArea().removeChild(stack);
@@ -583,7 +582,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
@Test
public void testShouldStartWhenMakeClientActive() {
- ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build();
+ ActivityRecord topActivity = new ActivityBuilder(mAtm).setTask(mTask).build();
topActivity.setOccludesParent(false);
mActivity.setState(Task.ActivityState.STOPPED, "Testing");
mActivity.setVisibility(true);
@@ -621,7 +620,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
public void testCanLaunchHomeActivityFromChooser() {
ComponentName chooserComponent = ComponentName.unflattenFromString(
Resources.getSystem().getString(R.string.config_chooserActivity));
- ActivityRecord chooserActivity = new ActivityBuilder(mService).setComponent(
+ ActivityRecord chooserActivity = new ActivityBuilder(mAtm).setComponent(
chooserComponent).build();
assertThat(mActivity.canLaunchHomeActivity(NOBODY_UID, chooserActivity)).isTrue();
}
@@ -736,7 +735,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
// Put a visible activity on top, so the finishing activity doesn't have to wait until the
// next activity reports idle to destroy it.
- final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord topActivity = new ActivityBuilder(mAtm).setTask(mTask).build();
topActivity.mVisibleRequested = true;
topActivity.nowVisible = true;
topActivity.setState(RESUMED, "test");
@@ -914,7 +913,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
public void testFinishActivityIfPossible_nonVisibleNoAppTransition() {
// Put an activity on top of test activity to make it invisible and prevent us from
// accidentally resuming the topmost one again.
- new ActivityBuilder(mService).build();
+ new ActivityBuilder(mAtm).build();
mActivity.mVisibleRequested = false;
mActivity.setState(STOPPED, "test");
@@ -992,7 +991,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
*/
@Test
public void testCompleteFinishing_waitForNextVisible() {
- final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord topActivity = new ActivityBuilder(mAtm).setTask(mTask).build();
topActivity.mVisibleRequested = true;
topActivity.nowVisible = true;
topActivity.finishing = true;
@@ -1017,7 +1016,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
*/
@Test
public void testCompleteFinishing_noWaitForNextVisible_alreadyInvisible() {
- final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord topActivity = new ActivityBuilder(mAtm).setTask(mTask).build();
topActivity.mVisibleRequested = false;
topActivity.nowVisible = false;
topActivity.finishing = true;
@@ -1039,7 +1038,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
*/
@Test
public void testCompleteFinishing_waitForIdle() {
- final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord topActivity = new ActivityBuilder(mAtm).setTask(mTask).build();
topActivity.mVisibleRequested = true;
topActivity.nowVisible = true;
topActivity.finishing = true;
@@ -1060,7 +1059,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
*/
@Test
public void testCompleteFinishing_noWaitForNextVisible_stopped() {
- final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord topActivity = new ActivityBuilder(mAtm).setTask(mTask).build();
topActivity.mVisibleRequested = false;
topActivity.nowVisible = false;
topActivity.finishing = true;
@@ -1081,7 +1080,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
*/
@Test
public void testCompleteFinishing_noWaitForNextVisible_nonFocusedStack() {
- final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord topActivity = new ActivityBuilder(mAtm).setTask(mTask).build();
topActivity.mVisibleRequested = true;
topActivity.nowVisible = true;
topActivity.finishing = true;
@@ -1114,7 +1113,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
// Make keyguard locked and set the top activity show-when-locked.
KeyguardController keyguardController = mActivity.mStackSupervisor.getKeyguardController();
doReturn(true).when(keyguardController).isKeyguardLocked();
- final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord topActivity = new ActivityBuilder(mAtm).setTask(mTask).build();
topActivity.mVisibleRequested = true;
topActivity.nowVisible = true;
topActivity.setState(RESUMED, "true");
@@ -1143,18 +1142,18 @@ public class ActivityRecordTests extends ActivityTestsBase {
*/
@Test
public void testCompleteFinishing_ensureActivitiesVisible() {
- final ActivityRecord firstActivity = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord firstActivity = new ActivityBuilder(mAtm).setTask(mTask).build();
firstActivity.mVisibleRequested = false;
firstActivity.nowVisible = false;
firstActivity.setState(STOPPED, "true");
- final ActivityRecord secondActivity = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord secondActivity = new ActivityBuilder(mAtm).setTask(mTask).build();
secondActivity.mVisibleRequested = true;
secondActivity.nowVisible = true;
secondActivity.setState(PAUSED, "true");
final ActivityRecord translucentActivity =
- new ActivityBuilder(mService).setTask(mTask).build();
+ new ActivityBuilder(mAtm).setTask(mTask).build();
translucentActivity.mVisibleRequested = true;
translucentActivity.nowVisible = true;
translucentActivity.setState(RESUMED, "true");
@@ -1396,7 +1395,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
final Task firstTaskRecord = mActivity.getTask();
final ActivityRecord secondActivityRecord =
- new ActivityBuilder(mService).setTask(firstTaskRecord).setUseProcess(wpc).build();
+ new ActivityBuilder(mAtm).setTask(firstTaskRecord).setUseProcess(wpc).build();
assertTrue(wpc.registeredForActivityConfigChanges());
assertEquals(0, secondActivityRecord.getMergedOverrideConfiguration()
@@ -1409,7 +1408,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
assertTrue(wpc.registeredForActivityConfigChanges());
final ActivityRecord secondActivityRecord =
- new ActivityBuilder(mService).setTask(mTask).setUseProcess(wpc).build();
+ new ActivityBuilder(mAtm).setTask(mTask).setUseProcess(wpc).build();
assertTrue(wpc.registeredForActivityConfigChanges());
assertEquals(0, secondActivityRecord.getMergedOverrideConfiguration()
@@ -1505,7 +1504,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
WindowManager.LayoutParams.TYPE_APPLICATION_STARTING);
params.width = params.height = WindowManager.LayoutParams.MATCH_PARENT;
final WindowTestUtils.TestWindowState w = new WindowTestUtils.TestWindowState(
- mService.mWindowManager, mock(Session.class), new TestIWindow(), params, mActivity);
+ mAtm.mWindowManager, mock(Session.class), new TestIWindow(), params, mActivity);
mActivity.addWindow(w);
// Assume the activity is launching in different rotation, and there was an available
@@ -1526,7 +1525,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
any() /* outContentInsets */, any() /* outStableInsets */,
any() /* outDisplayCutout */, any() /* outInputChannel */,
any() /* outInsetsState */, any() /* outActiveControls */);
- TaskSnapshotSurface.create(mService.mWindowManager, mActivity, snapshot);
+ TaskSnapshotSurface.create(mAtm.mWindowManager, mActivity, snapshot);
} catch (RemoteException ignored) {
} finally {
reset(session);
@@ -1602,7 +1601,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
final Configuration initialConf =
new Configuration(mActivity.getMergedOverrideConfiguration());
final Task initialTask = mActivity.getTask();
- final ActivityRecord secondActivity = new ActivityBuilder(mService).setTask(initialTask)
+ final ActivityRecord secondActivity = new ActivityBuilder(mAtm).setTask(initialTask)
.setUseProcess(wpc).build();
assertTrue(wpc.registeredForActivityConfigChanges());
@@ -1696,12 +1695,12 @@ public class ActivityRecordTests extends ActivityTestsBase {
if (defaultDisplay) {
display = mRootWindowContainer.getDefaultDisplay();
} else {
- display = new TestDisplayContent.Builder(mService, 2000, 1000).setDensityDpi(300)
+ display = new TestDisplayContent.Builder(mAtm, 2000, 1000).setDensityDpi(300)
.setPosition(DisplayContent.POSITION_TOP).build();
}
final Task stack = display.getDefaultTaskDisplayArea()
.createStack(WINDOWING_MODE_UNDEFINED, ACTIVITY_TYPE_STANDARD, true /* onTop */);
final Task task = new TaskBuilder(mSupervisor).setStack(stack).build();
- return new ActivityBuilder(mService).setTask(task).setUseProcess(process).build();
+ return new ActivityBuilder(mAtm).setTask(task).setUseProcess(process).build();
}
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStackSupervisorTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStackSupervisorTests.java
index 197c89a2d479..addf1ffe40c2 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityStackSupervisorTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStackSupervisorTests.java
@@ -55,7 +55,7 @@ import org.junit.runner.RunWith;
@MediumTest
@Presubmit
@RunWith(WindowTestRunner.class)
-public class ActivityStackSupervisorTests extends ActivityTestsBase {
+public class ActivityStackSupervisorTests extends WindowTestsBase {
private Task mFullscreenStack;
@Before
@@ -69,7 +69,7 @@ public class ActivityStackSupervisorTests extends ActivityTestsBase {
*/
@Test
public void testStoppingActivityRemovedWhenResumed() {
- final ActivityRecord firstActivity = new ActivityBuilder(mService).setCreateTask(true)
+ final ActivityRecord firstActivity = new ActivityBuilder(mAtm).setCreateTask(true)
.setStack(mFullscreenStack).build();
mSupervisor.mStoppingActivities.add(firstActivity);
@@ -83,7 +83,7 @@ public class ActivityStackSupervisorTests extends ActivityTestsBase {
*/
@Test
public void testReportWaitingActivityLaunchedIfNeeded() {
- final ActivityRecord firstActivity = new ActivityBuilder(mService).setCreateTask(true)
+ final ActivityRecord firstActivity = new ActivityBuilder(mAtm).setCreateTask(true)
.setStack(mFullscreenStack).build();
final WaitResult taskToFrontWait = new WaitResult();
@@ -121,7 +121,7 @@ public class ActivityStackSupervisorTests extends ActivityTestsBase {
task.setResizeMode(unresizableActivity.info.resizeMode);
final TaskChangeNotificationController taskChangeNotifier =
- mService.getTaskChangeNotificationController();
+ mAtm.getTaskChangeNotificationController();
spyOn(taskChangeNotifier);
mSupervisor.handleNonResizableTaskIfNeeded(task, newDisplay.getWindowingMode(),
@@ -133,7 +133,7 @@ public class ActivityStackSupervisorTests extends ActivityTestsBase {
reset(taskChangeNotifier);
// Put a resizable activity on top of the unresizable task.
- final ActivityRecord resizableActivity = new ActivityBuilder(mService)
+ final ActivityRecord resizableActivity = new ActivityBuilder(mAtm)
.setTask(task).build();
resizableActivity.info.resizeMode = ActivityInfo.RESIZE_MODE_RESIZEABLE;
@@ -150,24 +150,24 @@ public class ActivityStackSupervisorTests extends ActivityTestsBase {
*/
@Test
public void testNotifyTaskFocusChanged() {
- final ActivityRecord fullScreenActivityA = new ActivityBuilder(mService).setCreateTask(true)
+ final ActivityRecord fullScreenActivityA = new ActivityBuilder(mAtm).setCreateTask(true)
.setStack(mFullscreenStack).build();
final Task taskA = fullScreenActivityA.getTask();
final TaskChangeNotificationController taskChangeNotifier =
- mService.getTaskChangeNotificationController();
+ mAtm.getTaskChangeNotificationController();
spyOn(taskChangeNotifier);
- mService.setResumedActivityUncheckLocked(fullScreenActivityA, "resumeA");
+ mAtm.setResumedActivityUncheckLocked(fullScreenActivityA, "resumeA");
verify(taskChangeNotifier).notifyTaskFocusChanged(eq(taskA.mTaskId) /* taskId */,
eq(true) /* focused */);
reset(taskChangeNotifier);
- final ActivityRecord fullScreenActivityB = new ActivityBuilder(mService).setCreateTask(true)
+ final ActivityRecord fullScreenActivityB = new ActivityBuilder(mAtm).setCreateTask(true)
.setStack(mFullscreenStack).build();
final Task taskB = fullScreenActivityB.getTask();
- mService.setResumedActivityUncheckLocked(fullScreenActivityB, "resumeB");
+ mAtm.setResumedActivityUncheckLocked(fullScreenActivityB, "resumeB");
verify(taskChangeNotifier).notifyTaskFocusChanged(eq(taskA.mTaskId) /* taskId */,
eq(false) /* focused */);
verify(taskChangeNotifier).notifyTaskFocusChanged(eq(taskB.mTaskId) /* taskId */,
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStackTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStackTests.java
index dfdf686e5502..e2948a724acd 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityStackTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStackTests.java
@@ -89,7 +89,7 @@ import java.util.function.Consumer;
@SmallTest
@Presubmit
@RunWith(WindowTestRunner.class)
-public class ActivityStackTests extends ActivityTestsBase {
+public class ActivityStackTests extends WindowTestsBase {
private TaskDisplayArea mDefaultTaskDisplayArea;
private Task mStack;
private Task mTask;
@@ -105,7 +105,7 @@ public class ActivityStackTests extends ActivityTestsBase {
@Test
public void testResumedActivity() {
- final ActivityRecord r = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord r = new ActivityBuilder(mAtm).setTask(mTask).build();
assertNull(mStack.getResumedActivity());
r.setState(RESUMED, "testResumedActivity");
assertEquals(r, mStack.getResumedActivity());
@@ -115,7 +115,7 @@ public class ActivityStackTests extends ActivityTestsBase {
@Test
public void testResumedActivityFromTaskReparenting() {
- final ActivityRecord r = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord r = new ActivityBuilder(mAtm).setTask(mTask).build();
// Ensure moving task between two stacks updates resumed activity
r.setState(RESUMED, "testResumedActivityFromTaskReparenting");
assertEquals(r, mStack.getResumedActivity());
@@ -133,7 +133,7 @@ public class ActivityStackTests extends ActivityTestsBase {
@Test
public void testResumedActivityFromActivityReparenting() {
- final ActivityRecord r = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord r = new ActivityBuilder(mAtm).setTask(mTask).build();
// Ensure moving task between two stacks updates resumed activity
r.setState(RESUMED, "testResumedActivityFromActivityReparenting");
assertEquals(r, mStack.getResumedActivity());
@@ -149,7 +149,7 @@ public class ActivityStackTests extends ActivityTestsBase {
@Test
public void testPrimarySplitScreenMoveToBack() {
- TestSplitOrganizer organizer = new TestSplitOrganizer(mService);
+ TestSplitOrganizer organizer = new TestSplitOrganizer(mAtm);
// We're testing an edge case here where we have primary + fullscreen rather than secondary.
organizer.setMoveToSecondaryOnEnter(false);
@@ -177,7 +177,7 @@ public class ActivityStackTests extends ActivityTestsBase {
@Test
public void testMoveToPrimarySplitScreenThenMoveToBack() {
- TestSplitOrganizer organizer = new TestSplitOrganizer(mService);
+ TestSplitOrganizer organizer = new TestSplitOrganizer(mAtm);
// This time, start with a fullscreen activitystack
final Task primarySplitScreen = mDefaultTaskDisplayArea.createStack(
WINDOWING_MODE_UNDEFINED, ACTIVITY_TYPE_STANDARD, true /* onTop */);
@@ -202,7 +202,7 @@ public class ActivityStackTests extends ActivityTestsBase {
@Test
public void testSplitScreenMoveToBack() {
- TestSplitOrganizer organizer = new TestSplitOrganizer(mService);
+ TestSplitOrganizer organizer = new TestSplitOrganizer(mAtm);
// Set up split-screen with primary on top and secondary containing the home task below
// another stack.
final Task primaryTask = mDefaultTaskDisplayArea.createStack(
@@ -241,12 +241,12 @@ public class ActivityStackTests extends ActivityTestsBase {
@Test
public void testRemoveOrganizedTask_UpdateStackReference() {
final Task rootHomeTask = mDefaultTaskDisplayArea.getRootHomeTask();
- final ActivityRecord homeActivity = new ActivityBuilder(mService)
+ final ActivityRecord homeActivity = new ActivityBuilder(mAtm)
.setStack(rootHomeTask)
.setCreateTask(true)
.build();
final Task secondaryStack = (Task) WindowContainer.fromBinder(
- mService.mTaskOrganizerController.createRootTask(rootHomeTask.getDisplayId(),
+ mAtm.mTaskOrganizerController.createRootTask(rootHomeTask.getDisplayId(),
WINDOWING_MODE_SPLIT_SCREEN_SECONDARY).token.asBinder());
rootHomeTask.reparent(secondaryStack, POSITION_TOP);
@@ -292,7 +292,7 @@ public class ActivityStackTests extends ActivityTestsBase {
@Test
public void testStopActivityWhenActivityDestroyed() {
- final ActivityRecord r = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord r = new ActivityBuilder(mAtm).setTask(mTask).build();
r.info.flags |= ActivityInfo.FLAG_NO_HISTORY;
mStack.moveToFront("testStopActivityWithDestroy");
r.stopIfPossible();
@@ -302,14 +302,14 @@ public class ActivityStackTests extends ActivityTestsBase {
@Test
public void testFindTaskWithOverlay() {
- final ActivityRecord r = new ActivityBuilder(mService)
+ final ActivityRecord r = new ActivityBuilder(mAtm)
.setCreateTask(true)
.setStack(mStack)
.setUid(0)
.build();
final Task task = r.getTask();
// Overlay must be for a different user to prevent recognizing a matching top activity
- final ActivityRecord taskOverlay = new ActivityBuilder(mService).setTask(task)
+ final ActivityRecord taskOverlay = new ActivityBuilder(mAtm).setTask(task)
.setUid(UserHandle.PER_USER_RANGE * 2).build();
taskOverlay.setTaskOverlay(true);
@@ -330,21 +330,21 @@ public class ActivityStackTests extends ActivityTestsBase {
targetActivity);
final ComponentName alias = new ComponentName(DEFAULT_COMPONENT_PACKAGE_NAME,
aliasActivity);
- final Task task = new TaskBuilder(mService.mStackSupervisor).setStack(mStack).build();
+ final Task task = new TaskBuilder(mAtm.mStackSupervisor).setStack(mStack).build();
task.origActivity = alias;
task.realActivity = target;
- new ActivityBuilder(mService).setComponent(target).setTask(task).setTargetActivity(
+ new ActivityBuilder(mAtm).setComponent(target).setTask(task).setTargetActivity(
targetActivity).build();
// Using target activity to find task.
- final ActivityRecord r1 = new ActivityBuilder(mService).setComponent(
+ final ActivityRecord r1 = new ActivityBuilder(mAtm).setComponent(
target).setTargetActivity(targetActivity).build();
RootWindowContainer.FindTaskResult result = new RootWindowContainer.FindTaskResult();
result.process(r1, mStack);
assertThat(result.mRecord).isNotNull();
// Using alias activity to find task.
- final ActivityRecord r2 = new ActivityBuilder(mService).setComponent(
+ final ActivityRecord r2 = new ActivityBuilder(mAtm).setComponent(
alias).setTargetActivity(targetActivity).build();
result = new RootWindowContainer.FindTaskResult();
result.process(r2, mStack);
@@ -377,7 +377,7 @@ public class ActivityStackTests extends ActivityTestsBase {
final Task pinnedStack = createStackForShouldBeVisibleTest(mDefaultTaskDisplayArea,
WINDOWING_MODE_PINNED, ACTIVITY_TYPE_STANDARD, true /* onTop */);
// Add an activity to the pinned stack so it isn't considered empty for visibility check.
- final ActivityRecord pinnedActivity = new ActivityBuilder(mService)
+ final ActivityRecord pinnedActivity = new ActivityBuilder(mAtm)
.setCreateTask(true)
.setStack(pinnedStack)
.build();
@@ -676,7 +676,7 @@ public class ActivityStackTests extends ActivityTestsBase {
assertEquals(STACK_VISIBILITY_VISIBLE,
translucentStack.getVisibility(null /* starting */));
// Add an activity to the pinned stack so it isn't considered empty for visibility check.
- final ActivityRecord pinnedActivity = new ActivityBuilder(mService)
+ final ActivityRecord pinnedActivity = new ActivityBuilder(mAtm)
.setCreateTask(true)
.setStack(pinnedStack)
.build();
@@ -689,7 +689,7 @@ public class ActivityStackTests extends ActivityTestsBase {
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME, true /* onTop */);
ActivityRecord topRunningHomeActivity = homeStack.topRunningActivity();
if (topRunningHomeActivity == null) {
- topRunningHomeActivity = new ActivityBuilder(mService)
+ topRunningHomeActivity = new ActivityBuilder(mAtm)
.setStack(homeStack)
.setCreateTask(true)
.build();
@@ -721,12 +721,12 @@ public class ActivityStackTests extends ActivityTestsBase {
final Task homeStack = createStackForShouldBeVisibleTest(mDefaultTaskDisplayArea,
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME, true /* onTop */);
- final ActivityRecord firstActivity = new ActivityBuilder(mService)
+ final ActivityRecord firstActivity = new ActivityBuilder(mAtm)
.setStack(homeStack)
.setCreateTask(true)
.build();
final Task task = firstActivity.getTask();
- final ActivityRecord secondActivity = new ActivityBuilder(mService)
+ final ActivityRecord secondActivity = new ActivityBuilder(mAtm)
.setTask(task)
.build();
@@ -991,7 +991,6 @@ public class ActivityStackTests extends ActivityTestsBase {
TaskDisplayArea taskDisplayArea, int windowingMode, int activityType, boolean onTop) {
final Task task;
if (activityType == ACTIVITY_TYPE_HOME) {
- // Home stack and activity are created in ActivityTestsBase#setupActivityManagerService
task = mDefaultTaskDisplayArea.getStack(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME);
mDefaultTaskDisplayArea.positionChildAt(onTop ? POSITION_TOP : POSITION_BOTTOM, task,
false /* includingParents */);
@@ -1009,8 +1008,8 @@ public class ActivityStackTests extends ActivityTestsBase {
@Test
public void testFinishDisabledPackageActivities_FinishAliveActivities() {
- final ActivityRecord firstActivity = new ActivityBuilder(mService).setTask(mTask).build();
- final ActivityRecord secondActivity = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord firstActivity = new ActivityBuilder(mAtm).setTask(mTask).build();
+ final ActivityRecord secondActivity = new ActivityBuilder(mAtm).setTask(mTask).build();
firstActivity.setState(STOPPED, "testFinishDisabledPackageActivities");
secondActivity.setState(RESUMED, "testFinishDisabledPackageActivities");
mStack.mResumedActivity = secondActivity;
@@ -1029,10 +1028,10 @@ public class ActivityStackTests extends ActivityTestsBase {
@Test
public void testFinishDisabledPackageActivities_RemoveNonAliveActivities() {
- final ActivityRecord activity = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord activity = new ActivityBuilder(mAtm).setTask(mTask).build();
// The overlay activity is not in the disabled package but it is in the same task.
- final ActivityRecord overlayActivity = new ActivityBuilder(mService).setTask(mTask)
+ final ActivityRecord overlayActivity = new ActivityBuilder(mAtm).setTask(mTask)
.setComponent(new ComponentName("package.overlay", ".OverlayActivity")).build();
// If the task only remains overlay activity, the task should also be removed.
// See {@link ActivityStack#removeFromHistory}.
@@ -1058,8 +1057,8 @@ public class ActivityStackTests extends ActivityTestsBase {
@Test
public void testHandleAppDied() {
- final ActivityRecord firstActivity = new ActivityBuilder(mService).setTask(mTask).build();
- final ActivityRecord secondActivity = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord firstActivity = new ActivityBuilder(mAtm).setTask(mTask).build();
+ final ActivityRecord secondActivity = new ActivityBuilder(mAtm).setTask(mTask).build();
// Making the first activity a task overlay means it will be removed from the task's
// activities as well once second activity is removed as handleAppDied processes the
@@ -1080,7 +1079,7 @@ public class ActivityStackTests extends ActivityTestsBase {
@Test
public void testHandleAppDied_RelaunchesAfterCrashDuringWindowingModeResize() {
- final ActivityRecord activity = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord activity = new ActivityBuilder(mAtm).setTask(mTask).build();
activity.mRelaunchReason = RELAUNCH_REASON_WINDOWING_MODE_RESIZE;
activity.launchCount = 1;
@@ -1094,7 +1093,7 @@ public class ActivityStackTests extends ActivityTestsBase {
@Test
public void testHandleAppDied_NotRelaunchAfterThreeCrashesDuringWindowingModeResize() {
- final ActivityRecord activity = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord activity = new ActivityBuilder(mAtm).setTask(mTask).build();
activity.mRelaunchReason = RELAUNCH_REASON_WINDOWING_MODE_RESIZE;
activity.launchCount = 3;
@@ -1108,7 +1107,7 @@ public class ActivityStackTests extends ActivityTestsBase {
@Test
public void testHandleAppDied_RelaunchesAfterCrashDuringFreeResize() {
- final ActivityRecord activity = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord activity = new ActivityBuilder(mAtm).setTask(mTask).build();
activity.mRelaunchReason = RELAUNCH_REASON_FREE_RESIZE;
activity.launchCount = 1;
@@ -1122,7 +1121,7 @@ public class ActivityStackTests extends ActivityTestsBase {
@Test
public void testHandleAppDied_NotRelaunchAfterThreeCrashesDuringFreeResize() {
- final ActivityRecord activity = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord activity = new ActivityBuilder(mAtm).setTask(mTask).build();
activity.mRelaunchReason = RELAUNCH_REASON_FREE_RESIZE;
activity.launchCount = 3;
@@ -1136,11 +1135,11 @@ public class ActivityStackTests extends ActivityTestsBase {
@Test
public void testCompletePauseOnResumeWhilePausingActivity() {
- final ActivityRecord bottomActivity = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord bottomActivity = new ActivityBuilder(mAtm).setTask(mTask).build();
doReturn(true).when(bottomActivity).attachedToProcess();
mStack.mPausingActivity = null;
mStack.mResumedActivity = bottomActivity;
- final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord topActivity = new ActivityBuilder(mAtm).setTask(mTask).build();
topActivity.info.flags |= FLAG_RESUME_WHILE_PAUSING;
mStack.startPausingLocked(false /* userLeaving */, false /* uiSleeping */, topActivity);
@@ -1154,7 +1153,7 @@ public class ActivityStackTests extends ActivityTestsBase {
ActivityRecord activity = homeStack.topRunningActivity();
if (activity == null) {
- activity = new ActivityBuilder(mService)
+ activity = new ActivityBuilder(mAtm)
.setStack(homeStack)
.setCreateTask(true)
.build();
@@ -1265,13 +1264,13 @@ public class ActivityStackTests extends ActivityTestsBase {
public void testNavigateUpTo() {
final ActivityStartController controller = mock(ActivityStartController.class);
final ActivityStarter starter = new ActivityStarter(controller,
- mService, mService.mStackSupervisor, mock(ActivityStartInterceptor.class));
- doReturn(controller).when(mService).getActivityStartController();
+ mAtm, mAtm.mStackSupervisor, mock(ActivityStartInterceptor.class));
+ doReturn(controller).when(mAtm).getActivityStartController();
spyOn(starter);
doReturn(ActivityManager.START_SUCCESS).when(starter).execute();
- final ActivityRecord firstActivity = new ActivityBuilder(mService).setTask(mTask).build();
- final ActivityRecord secondActivity = new ActivityBuilder(mService).setTask(mTask)
+ final ActivityRecord firstActivity = new ActivityBuilder(mAtm).setTask(mTask).build();
+ final ActivityRecord secondActivity = new ActivityBuilder(mAtm).setTask(mTask)
.setUid(firstActivity.getUid() + 1).build();
doReturn(starter).when(controller).obtainStarter(eq(firstActivity.intent), anyString());
@@ -1297,7 +1296,7 @@ public class ActivityStackTests extends ActivityTestsBase {
@Test
public void testShouldUpRecreateTaskLockedWithCorrectAffinityFormat() {
final String affinity = "affinity";
- final ActivityRecord activity = new ActivityBuilder(mService).setAffinity(affinity)
+ final ActivityRecord activity = new ActivityBuilder(mAtm).setAffinity(affinity)
.setUid(Binder.getCallingUid()).setCreateTask(true).build();
activity.getTask().affinity = activity.taskAffinity;
@@ -1307,7 +1306,7 @@ public class ActivityStackTests extends ActivityTestsBase {
@Test
public void testShouldUpRecreateTaskLockedWithWrongAffinityFormat() {
final String affinity = "affinity";
- final ActivityRecord activity = new ActivityBuilder(mService).setAffinity(affinity)
+ final ActivityRecord activity = new ActivityBuilder(mAtm).setAffinity(affinity)
.setUid(Binder.getCallingUid()).setCreateTask(true).build();
activity.getTask().affinity = activity.taskAffinity;
final String fakeAffinity = activity.getUid() + activity.taskAffinity;
@@ -1318,12 +1317,12 @@ public class ActivityStackTests extends ActivityTestsBase {
@Test
public void testResetTaskWithFinishingActivities() {
final ActivityRecord taskTop =
- new ActivityBuilder(mService).setStack(mStack).setCreateTask(true).build();
+ new ActivityBuilder(mAtm).setStack(mStack).setCreateTask(true).build();
// Make all activities in the task are finishing to simulate Task#getTopActivity
// returns null.
taskTop.finishing = true;
- final ActivityRecord newR = new ActivityBuilder(mService).build();
+ final ActivityRecord newR = new ActivityBuilder(mAtm).build();
final ActivityRecord result = mStack.resetTaskIfNeeded(taskTop, newR);
assertThat(result).isEqualTo(taskTop);
}
@@ -1333,9 +1332,9 @@ public class ActivityStackTests extends ActivityTestsBase {
final ArrayList<ActivityRecord> occludedActivities = new ArrayList<>();
final Consumer<ActivityRecord> handleOccludedActivity = occludedActivities::add;
final ActivityRecord bottomActivity =
- new ActivityBuilder(mService).setStack(mStack).setTask(mTask).build();
+ new ActivityBuilder(mAtm).setStack(mStack).setTask(mTask).build();
final ActivityRecord topActivity =
- new ActivityBuilder(mService).setStack(mStack).setTask(mTask).build();
+ new ActivityBuilder(mAtm).setStack(mStack).setTask(mTask).build();
// Top activity occludes bottom activity.
doReturn(true).when(mStack).shouldBeVisible(any());
assertTrue(topActivity.shouldBeVisible());
@@ -1354,7 +1353,7 @@ public class ActivityStackTests extends ActivityTestsBase {
// A finishing activity should not occlude other activities behind.
final ActivityRecord finishingActivity =
- new ActivityBuilder(mService).setStack(mStack).setTask(mTask).build();
+ new ActivityBuilder(mAtm).setStack(mStack).setTask(mTask).build();
finishingActivity.finishing = true;
doCallRealMethod().when(finishingActivity).occludesParent();
assertTrue(topActivity.shouldBeVisible());
@@ -1376,9 +1375,9 @@ public class ActivityStackTests extends ActivityTestsBase {
final ActivityRecord[] activities = new ActivityRecord[2];
mSupervisor.beginDeferResume();
for (int i = 0; i < activities.length; i++) {
- final ActivityRecord r = new ActivityBuilder(mService).setTask(mTask).build();
+ final ActivityRecord r = new ActivityBuilder(mAtm).setTask(mTask).build();
activities[i] = r;
- doReturn(null).when(mService).getProcessController(
+ doReturn(null).when(mAtm).getProcessController(
eq(r.processName), eq(r.info.applicationInfo.uid));
r.setState(Task.ActivityState.INITIALIZING, "test");
// Ensure precondition that the activity is opaque.
@@ -1388,7 +1387,7 @@ public class ActivityStackTests extends ActivityTestsBase {
}
mSupervisor.endDeferResume();
- setBooted(mService);
+ setBooted(mAtm);
// 2 activities are started while keyguard is locked, so they are waiting to be resolved.
assertFalse(unknownAppVisibilityController.allResolved());
@@ -1405,8 +1404,8 @@ public class ActivityStackTests extends ActivityTestsBase {
@Test
public void testNonTopVisibleActivityNotResume() {
final ActivityRecord nonTopVisibleActivity =
- new ActivityBuilder(mService).setTask(mTask).build();
- new ActivityBuilder(mService).setTask(mTask).build();
+ new ActivityBuilder(mAtm).setTask(mTask).build();
+ new ActivityBuilder(mAtm).setTask(mTask).build();
doReturn(false).when(nonTopVisibleActivity).attachedToProcess();
doReturn(true).when(nonTopVisibleActivity).shouldBeVisible(anyBoolean(), anyBoolean());
doNothing().when(mSupervisor).startSpecificActivity(any(), anyBoolean(),
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStartControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStartControllerTests.java
index c9a927901a37..55afc70f5213 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityStartControllerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStartControllerTests.java
@@ -51,7 +51,7 @@ import java.util.Random;
@SmallTest
@Presubmit
@RunWith(WindowTestRunner.class)
-public class ActivityStartControllerTests extends ActivityTestsBase {
+public class ActivityStartControllerTests extends WindowTestsBase {
private ActivityStartController mController;
private Factory mFactory;
private ActivityStarter mStarter;
@@ -59,9 +59,9 @@ public class ActivityStartControllerTests extends ActivityTestsBase {
@Before
public void setUp() throws Exception {
mFactory = mock(Factory.class);
- mController = new ActivityStartController(mService, mService.mStackSupervisor, mFactory);
- mStarter = spy(new ActivityStarter(mController, mService,
- mService.mStackSupervisor, mock(ActivityStartInterceptor.class)));
+ mController = new ActivityStartController(mAtm, mAtm.mStackSupervisor, mFactory);
+ mStarter = spy(new ActivityStarter(mController, mAtm,
+ mAtm.mStackSupervisor, mock(ActivityStartInterceptor.class)));
doReturn(mStarter).when(mFactory).obtain();
}
@@ -72,15 +72,15 @@ public class ActivityStartControllerTests extends ActivityTestsBase {
public void testPendingActivityLaunches() {
final Random random = new Random();
- final ActivityRecord activity = new ActivityBuilder(mService).build();
- final ActivityRecord source = new ActivityBuilder(mService)
+ final ActivityRecord activity = new ActivityBuilder(mAtm).build();
+ final ActivityRecord source = new ActivityBuilder(mAtm)
.setCreateTask(true)
.build();
final int startFlags = random.nextInt();
- final Task stack = mService.mRootWindowContainer.getDefaultTaskDisplayArea()
+ final Task stack = mAtm.mRootWindowContainer.getDefaultTaskDisplayArea()
.createStack(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
- final WindowProcessController wpc = new WindowProcessController(mService,
- mService.mContext.getApplicationInfo(), "name", 12345,
+ final WindowProcessController wpc = new WindowProcessController(mAtm,
+ mAtm.mContext.getApplicationInfo(), "name", 12345,
UserHandle.getUserId(12345), mock(Object.class),
mock(WindowProcessListener.class));
wpc.setThread(mock(IApplicationThread.class));
@@ -101,8 +101,8 @@ public class ActivityStartControllerTests extends ActivityTestsBase {
@Test
public void testRecycling() {
final Intent intent = new Intent();
- final ActivityStarter optionStarter = new ActivityStarter(mController, mService,
- mService.mStackSupervisor, mock(ActivityStartInterceptor.class));
+ final ActivityStarter optionStarter = new ActivityStarter(mController, mAtm,
+ mAtm.mStackSupervisor, mock(ActivityStartInterceptor.class));
optionStarter
.setIntent(intent)
.setReason("Test")
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
index d07000f30046..e5c9ecc7676d 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
@@ -100,7 +100,7 @@ import org.junit.runner.RunWith;
@SmallTest
@Presubmit
@RunWith(WindowTestRunner.class)
-public class ActivityStarterTests extends ActivityTestsBase {
+public class ActivityStarterTests extends WindowTestsBase {
private ActivityStartController mController;
private ActivityMetricsLogger mActivityMetricsLogger;
private PackageManagerInternal mMockPackageManager;
@@ -187,7 +187,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
*/
private void verifyStartActivityPreconditionsUntracked(int preconditions, int launchFlags,
int expectedResult) {
- final ActivityTaskManagerService service = mService;
+ final ActivityTaskManagerService service = mAtm;
final IPackageManager packageManager = mock(IPackageManager.class);
final ActivityStartController controller = mock(ActivityStartController.class);
@@ -283,8 +283,8 @@ public class ActivityStarterTests extends ActivityTestsBase {
// Ensure that {@link ActivityOptions} are aborted with unsuccessful result.
if (expectedResult != START_SUCCESS) {
- final ActivityStarter optionStarter = new ActivityStarter(mController, mService,
- mService.mStackSupervisor, mock(ActivityStartInterceptor.class));
+ final ActivityStarter optionStarter = new ActivityStarter(mController, mAtm,
+ mAtm.mStackSupervisor, mock(ActivityStartInterceptor.class));
final ActivityOptions options = spy(ActivityOptions.makeBasic());
final int optionResult = optionStarter.setCaller(caller)
@@ -338,7 +338,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
invocation -> {
throw new RuntimeException("Not stubbed");
});
- doReturn(mMockPackageManager).when(mService).getPackageManagerInternalLocked();
+ doReturn(mMockPackageManager).when(mAtm).getPackageManagerInternalLocked();
doReturn(false).when(mMockPackageManager).isInstantAppInstallerComponent(any());
doReturn(null).when(mMockPackageManager).resolveIntent(any(), any(), anyInt(), anyInt(),
anyInt(), anyBoolean(), anyInt());
@@ -359,8 +359,8 @@ public class ActivityStarterTests extends ActivityTestsBase {
info.applicationInfo = new ApplicationInfo();
info.applicationInfo.packageName = ActivityBuilder.getDefaultComponent().getPackageName();
- return new ActivityStarter(mController, mService,
- mService.mStackSupervisor, mock(ActivityStartInterceptor.class))
+ return new ActivityStarter(mController, mAtm,
+ mAtm.mStackSupervisor, mock(ActivityStartInterceptor.class))
.setIntent(intent)
.setActivityInfo(info);
}
@@ -373,7 +373,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
public void testCreateTaskLayout() {
// modifier for validating passed values.
final LaunchParamsModifier modifier = mock(LaunchParamsModifier.class);
- mService.mStackSupervisor.getLaunchParamsController().registerModifier(modifier);
+ mAtm.mStackSupervisor.getLaunchParamsController().registerModifier(modifier);
// add custom values to activity info to make unique.
final ActivityInfo info = new ActivityInfo();
@@ -414,9 +414,9 @@ public class ActivityStarterTests extends ActivityTestsBase {
final ActivityStarter starter = prepareStarter(
FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | FLAG_ACTIVITY_SINGLE_TOP, false);
final ActivityRecord splitPrimaryFocusActivity =
- new ActivityBuilder(mService).setCreateTask(true).build();
+ new ActivityBuilder(mAtm).setCreateTask(true).build();
final ActivityRecord splitSecondReusableActivity =
- new ActivityBuilder(mService).setCreateTask(true).build();
+ new ActivityBuilder(mAtm).setCreateTask(true).build();
splitPrimaryFocusActivity.getRootTask()
.setWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
splitSecondReusableActivity.getRootTask()
@@ -443,11 +443,11 @@ public class ActivityStarterTests extends ActivityTestsBase {
final ActivityStarter starter = prepareStarter(
FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | FLAG_ACTIVITY_SINGLE_TOP, false);
final ActivityRecord splitSecondReusableActivity =
- new ActivityBuilder(mService).setCreateTask(true).build();
+ new ActivityBuilder(mAtm).setCreateTask(true).build();
final ActivityRecord splitSecondTopActivity =
- new ActivityBuilder(mService).setCreateTask(true).build();
+ new ActivityBuilder(mAtm).setCreateTask(true).build();
final ActivityRecord splitPrimaryFocusActivity =
- new ActivityBuilder(mService).setCreateTask(true).build();
+ new ActivityBuilder(mAtm).setCreateTask(true).build();
splitPrimaryFocusActivity.getRootTask()
.setWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
splitSecondReusableActivity.getRootTask()
@@ -475,13 +475,13 @@ public class ActivityStarterTests extends ActivityTestsBase {
*/
@Test
public void testTaskModeViolation() {
- final DisplayContent display = mService.mRootWindowContainer.getDefaultDisplay();
+ final DisplayContent display = mAtm.mRootWindowContainer.getDefaultDisplay();
display.removeAllTasks();
assertNoTasks(display);
final ActivityStarter starter = prepareStarter(0);
- final LockTaskController lockTaskController = mService.getLockTaskController();
+ final LockTaskController lockTaskController = mAtm.getLockTaskController();
doReturn(true).when(lockTaskController).isLockTaskModeViolation(any());
final int result = starter.setReason("testTaskModeViolation").execute();
@@ -504,8 +504,8 @@ public class ActivityStarterTests extends ActivityTestsBase {
*/
@Test
public void testActivityStartsLogging_noLoggingWhenDisabled() {
- doReturn(false).when(mService).isActivityStartsLoggingEnabled();
- doReturn(mActivityMetricsLogger).when(mService.mStackSupervisor).getActivityMetricsLogger();
+ doReturn(false).when(mAtm).isActivityStartsLoggingEnabled();
+ doReturn(mActivityMetricsLogger).when(mAtm.mStackSupervisor).getActivityMetricsLogger();
ActivityStarter starter = prepareStarter(FLAG_ACTIVITY_NEW_TASK);
starter.setReason("testActivityStartsLogging_noLoggingWhenDisabled").execute();
@@ -521,8 +521,8 @@ public class ActivityStarterTests extends ActivityTestsBase {
@Test
public void testActivityStartsLogging_logsWhenEnabled() {
// note: conveniently this package doesn't have any activity visible
- doReturn(true).when(mService).isActivityStartsLoggingEnabled();
- doReturn(mActivityMetricsLogger).when(mService.mStackSupervisor).getActivityMetricsLogger();
+ doReturn(true).when(mAtm).isActivityStartsLoggingEnabled();
+ doReturn(mActivityMetricsLogger).when(mAtm.mStackSupervisor).getActivityMetricsLogger();
ActivityStarter starter = prepareStarter(FLAG_ACTIVITY_NEW_TASK)
.setCallingUid(FAKE_CALLING_UID)
@@ -544,7 +544,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
*/
@Test
public void testBackgroundActivityStartsAllowed_noStartsAborted() {
- doReturn(true).when(mService).isBackgroundActivityStartsEnabled();
+ doReturn(true).when(mAtm).isBackgroundActivityStartsEnabled();
runAndVerifyBackgroundActivityStartsSubtest("allowed_noStartsAborted", false,
UNIMPORTANT_UID, false, PROCESS_STATE_TOP + 1,
@@ -558,7 +558,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
*/
@Test
public void testBackgroundActivityStartsDisallowed_unsupportedStartsAborted() {
- doReturn(false).when(mService).isBackgroundActivityStartsEnabled();
+ doReturn(false).when(mAtm).isBackgroundActivityStartsEnabled();
runAndVerifyBackgroundActivityStartsSubtest(
"disallowed_unsupportedUsecase_aborted", true,
@@ -589,7 +589,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
*/
@Test
public void testBackgroundActivityStartsDisallowed_supportedStartsNotAborted() {
- doReturn(false).when(mService).isBackgroundActivityStartsEnabled();
+ doReturn(false).when(mAtm).isBackgroundActivityStartsEnabled();
runAndVerifyBackgroundActivityStartsSubtest("disallowed_rootUid_notAborted", false,
Process.ROOT_UID, false, PROCESS_STATE_TOP + 1,
@@ -644,13 +644,13 @@ public class ActivityStarterTests extends ActivityTestsBase {
boolean callerIsInstrumentingWithBackgroundActivityStartPrivileges,
boolean isCallingUidDeviceOwner) {
// window visibility
- doReturn(callingUidHasVisibleWindow).when(mService.mWindowManager.mRoot)
+ doReturn(callingUidHasVisibleWindow).when(mAtm.mWindowManager.mRoot)
.isAnyNonToastWindowVisibleForUid(callingUid);
- doReturn(realCallingUidHasVisibleWindow).when(mService.mWindowManager.mRoot)
+ doReturn(realCallingUidHasVisibleWindow).when(mAtm.mWindowManager.mRoot)
.isAnyNonToastWindowVisibleForUid(realCallingUid);
// process importance
- doReturn(callingUidProcState).when(mService).getUidState(callingUid);
- doReturn(realCallingUidProcState).when(mService).getUidState(realCallingUid);
+ doReturn(callingUidProcState).when(mAtm).getUidState(callingUid);
+ doReturn(realCallingUidProcState).when(mAtm).getUidState(realCallingUid);
// foreground activities
final IApplicationThread caller = mock(IApplicationThread.class);
final WindowProcessListener listener = mock(WindowProcessListener.class);
@@ -658,12 +658,12 @@ public class ActivityStarterTests extends ActivityTestsBase {
ai.uid = callingUid;
ai.packageName = "com.android.test.package";
final WindowProcessController callerApp =
- new WindowProcessController(mService, ai, null, callingUid, -1, null, listener);
+ new WindowProcessController(mAtm, ai, null, callingUid, -1, null, listener);
callerApp.setHasForegroundActivities(hasForegroundActivities);
- doReturn(callerApp).when(mService).getProcessController(caller);
+ doReturn(callerApp).when(mAtm).getProcessController(caller);
// caller is recents
RecentTasks recentTasks = mock(RecentTasks.class);
- mService.mStackSupervisor.setRecentTasks(recentTasks);
+ mAtm.mStackSupervisor.setRecentTasks(recentTasks);
doReturn(callerIsRecents).when(recentTasks).isCallerRecents(callingUid);
// caller is temp allowed
if (callerIsTempAllowed) {
@@ -673,7 +673,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
callerApp.setInstrumenting(callerIsInstrumentingWithBackgroundActivityStartPrivileges,
callerIsInstrumentingWithBackgroundActivityStartPrivileges);
// callingUid is the device owner
- doReturn(isCallingUidDeviceOwner).when(mService).isDeviceOwner(callingUid);
+ doReturn(isCallingUidDeviceOwner).when(mAtm).isDeviceOwner(callingUid);
final ActivityOptions options = spy(ActivityOptions.makeBasic());
ActivityRecord[] outActivity = new ActivityRecord[1];
@@ -706,14 +706,14 @@ public class ActivityStarterTests extends ActivityTestsBase {
@Test
public void testBringTaskToFrontWhenFocusedStackIsFinising() {
// Put 2 tasks in the same stack (simulate the behavior of home stack).
- final ActivityRecord activity = new ActivityBuilder(mService)
+ final ActivityRecord activity = new ActivityBuilder(mAtm)
.setCreateTask(true).build();
- new ActivityBuilder(mService)
+ new ActivityBuilder(mAtm)
.setStack(activity.getRootTask())
.setCreateTask(true).build();
// Create a top finishing activity.
- final ActivityRecord finishingTopActivity = new ActivityBuilder(mService)
+ final ActivityRecord finishingTopActivity = new ActivityBuilder(mAtm)
.setCreateTask(true).build();
finishingTopActivity.getRootTask().moveToFront("finishingTopActivity");
@@ -741,7 +741,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
// Create a secondary display at bottom.
final TestDisplayContent secondaryDisplay =
- new TestDisplayContent.Builder(mService, 1000, 1500)
+ new TestDisplayContent.Builder(mAtm, 1000, 1500)
.setPosition(POSITION_BOTTOM).build();
final TaskDisplayArea secondaryTaskContainer = secondaryDisplay.getDefaultTaskDisplayArea();
final Task stack = secondaryTaskContainer.createStack(
@@ -751,7 +751,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
final ActivityRecord topActivityOnSecondaryDisplay = createSingleTaskActivityOn(stack);
// Put an activity on default display as the top focused activity.
- new ActivityBuilder(mService).setCreateTask(true).build();
+ new ActivityBuilder(mAtm).setCreateTask(true).build();
// Start activity with the same intent as {@code topActivityOnSecondaryDisplay}
// on secondary display.
@@ -781,7 +781,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
// Create a secondary display with an activity.
final TestDisplayContent secondaryDisplay =
- new TestDisplayContent.Builder(mService, 1000, 1500).build();
+ new TestDisplayContent.Builder(mAtm, 1000, 1500).build();
mRootWindowContainer.positionChildAt(POSITION_TOP, secondaryDisplay,
false /* includingParents */);
final TaskDisplayArea secondaryTaskContainer = secondaryDisplay.getDefaultTaskDisplayArea();
@@ -793,7 +793,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
final Task topStack = secondaryTaskContainer.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, true /* onTop */);
final Task topTask = new TaskBuilder(mSupervisor).setStack(topStack).build();
- new ActivityBuilder(mService).setTask(topTask).build();
+ new ActivityBuilder(mAtm).setTask(topTask).build();
// Start activity with the same intent as {@code singleTaskActivity} on secondary display.
final ActivityOptions options = ActivityOptions.makeBasic()
@@ -815,16 +815,16 @@ public class ActivityStarterTests extends ActivityTestsBase {
final ActivityStarter starter = prepareStarter(
FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | FLAG_ACTIVITY_SINGLE_TOP, false);
final ActivityRecord reusableActivity =
- new ActivityBuilder(mService).setCreateTask(true).build();
+ new ActivityBuilder(mAtm).setCreateTask(true).build();
final ActivityRecord topActivity =
- new ActivityBuilder(mService).setCreateTask(true).build();
+ new ActivityBuilder(mAtm).setCreateTask(true).build();
// Make sure topActivity is on top
topActivity.getRootTask().moveToFront("testWasVisibleInRestartAttempt");
reusableActivity.setVisible(false);
final TaskChangeNotificationController taskChangeNotifier =
- mService.getTaskChangeNotificationController();
+ mAtm.getTaskChangeNotificationController();
spyOn(taskChangeNotifier);
Task task = topActivity.getTask();
@@ -853,7 +853,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
.setComponent(componentName)
.setStack(stack)
.build();
- return new ActivityBuilder(mService)
+ return new ActivityBuilder(mAtm)
.setComponent(componentName)
.setLaunchMode(LAUNCH_SINGLE_TASK)
.setTask(task)
@@ -876,7 +876,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
true /* onTop */);
// Put an activity on default display as the top focused activity.
- final ActivityRecord topActivity = new ActivityBuilder(mService)
+ final ActivityRecord topActivity = new ActivityBuilder(mAtm)
.setCreateTask(true)
.setLaunchMode(LAUNCH_SINGLE_TASK)
.build();
@@ -900,7 +900,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
@Test
public void testFreezeTaskListActivityOption() {
RecentTasks recentTasks = mock(RecentTasks.class);
- mService.mStackSupervisor.setRecentTasks(recentTasks);
+ mAtm.mStackSupervisor.setRecentTasks(recentTasks);
doReturn(true).when(recentTasks).isCallerRecents(anyInt());
final ActivityStarter starter = prepareStarter(0 /* flags */);
@@ -922,7 +922,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
@Test
public void testFreezeTaskListActivityOptionFailedStart_expectResetFreezeTaskList() {
RecentTasks recentTasks = mock(RecentTasks.class);
- mService.mStackSupervisor.setRecentTasks(recentTasks);
+ mAtm.mStackSupervisor.setRecentTasks(recentTasks);
doReturn(true).when(recentTasks).isCallerRecents(anyInt());
final ActivityStarter starter = prepareStarter(0 /* flags */);
@@ -959,7 +959,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
intent.setComponent(ActivityBuilder.getDefaultComponent());
doReturn(true).when(mMockPackageManager).isInstantAppInstallerComponent(any());
- starter.setIntent(intent).mRequest.resolveActivity(mService.mStackSupervisor);
+ starter.setIntent(intent).mRequest.resolveActivity(mAtm.mStackSupervisor);
// Make sure the client intent won't be modified.
assertThat(intent.getComponent()).isNotNull();
@@ -985,9 +985,9 @@ public class ActivityStarterTests extends ActivityTestsBase {
@Test
public void testRecycleTaskFromAnotherUser() {
final ActivityStarter starter = prepareStarter(0 /* flags */);
- starter.mStartActivity = new ActivityBuilder(mService).build();
- final Task task = new TaskBuilder(mService.mStackSupervisor)
- .setStack(mService.mRootWindowContainer.getDefaultTaskDisplayArea().createStack(
+ starter.mStartActivity = new ActivityBuilder(mAtm).build();
+ final Task task = new TaskBuilder(mAtm.mStackSupervisor)
+ .setStack(mAtm.mRootWindowContainer.getDefaultTaskDisplayArea().createStack(
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */))
.setUserId(10)
.build();
@@ -1001,7 +1001,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
public void testTargetStackInSplitScreen() {
final ActivityStarter starter =
prepareStarter(FLAG_ACTIVITY_LAUNCH_ADJACENT, false /* mockGetLaunchStack */);
- final ActivityRecord top = new ActivityBuilder(mService).setCreateTask(true).build();
+ final ActivityRecord top = new ActivityBuilder(mAtm).setCreateTask(true).build();
final ActivityOptions options = ActivityOptions.makeBasic();
final ActivityRecord[] outActivity = new ActivityRecord[1];
@@ -1012,7 +1012,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
assertThat(outActivity[0].inSplitScreenWindowingMode()).isFalse();
// Move activity to split-screen-primary stack and make sure it has the focus.
- TestSplitOrganizer splitOrg = new TestSplitOrganizer(mService, top.getDisplayId());
+ TestSplitOrganizer splitOrg = new TestSplitOrganizer(mAtm, top.getDisplayId());
top.getRootTask().reparent(splitOrg.mPrimary, POSITION_BOTTOM);
top.getRootTask().moveToFront("testWindowingModeOptionsLaunchAdjacent");
@@ -1026,7 +1026,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
@Test
public void testActivityStart_expectAddedToRecentTask() {
RecentTasks recentTasks = mock(RecentTasks.class);
- mService.mStackSupervisor.setRecentTasks(recentTasks);
+ mAtm.mStackSupervisor.setRecentTasks(recentTasks);
doReturn(true).when(recentTasks).isCallerRecents(anyInt());
final ActivityStarter starter = prepareStarter(0 /* flags */);
@@ -1044,10 +1044,10 @@ public class ActivityStarterTests extends ActivityTestsBase {
starter.setReason("testAllSplitScreenPrimaryActivitiesAreResumed");
- final ActivityRecord targetRecord = new ActivityBuilder(mService).build();
+ final ActivityRecord targetRecord = new ActivityBuilder(mAtm).build();
targetRecord.setFocusable(false);
targetRecord.setVisibility(false);
- final ActivityRecord sourceRecord = new ActivityBuilder(mService).build();
+ final ActivityRecord sourceRecord = new ActivityBuilder(mAtm).build();
final Task stack = spy(
mRootWindowContainer.getDefaultTaskDisplayArea()
@@ -1059,7 +1059,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
doReturn(stack).when(mRootWindowContainer)
.getLaunchStack(any(), any(), any(), anyBoolean(), any(), anyInt(), anyInt());
- starter.mStartActivity = new ActivityBuilder(mService).build();
+ starter.mStartActivity = new ActivityBuilder(mAtm).build();
// When
starter.startActivityInner(
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java
index f8faae66c704..2e988af29638 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java
@@ -60,14 +60,14 @@ import java.util.ArrayList;
@Presubmit
@MediumTest
@RunWith(WindowTestRunner.class)
-public class ActivityTaskManagerServiceTests extends ActivityTestsBase {
+public class ActivityTaskManagerServiceTests extends WindowTestsBase {
private final ArgumentCaptor<ClientTransaction> mClientTransactionCaptor =
ArgumentCaptor.forClass(ClientTransaction.class);
@Before
public void setUp() throws Exception {
- setBooted(mService);
+ setBooted(mAtm);
}
/** Verify that activity is finished correctly upon request. */
@@ -75,13 +75,13 @@ public class ActivityTaskManagerServiceTests extends ActivityTestsBase {
public void testActivityFinish() {
final Task stack = new StackBuilder(mRootWindowContainer).build();
final ActivityRecord activity = stack.getBottomMostTask().getTopNonFinishingActivity();
- assertTrue("Activity must be finished", mService.finishActivity(activity.appToken,
+ assertTrue("Activity must be finished", mAtm.finishActivity(activity.appToken,
0 /* resultCode */, null /* resultData */,
Activity.DONT_FINISH_TASK_WITH_ACTIVITY));
assertTrue(activity.finishing);
assertTrue("Duplicate activity finish request must also return 'true'",
- mService.finishActivity(activity.appToken, 0 /* resultCode */,
+ mAtm.finishActivity(activity.appToken, 0 /* resultCode */,
null /* resultData */, Activity.DONT_FINISH_TASK_WITH_ACTIVITY));
}
@@ -90,10 +90,10 @@ public class ActivityTaskManagerServiceTests extends ActivityTestsBase {
final Task stack = new StackBuilder(mRootWindowContainer).build();
final ActivityRecord activity = stack.getBottomMostTask().getTopNonFinishingActivity();
final ClientLifecycleManager mockLifecycleManager = mock(ClientLifecycleManager.class);
- doReturn(mockLifecycleManager).when(mService).getLifecycleManager();
+ doReturn(mockLifecycleManager).when(mAtm).getLifecycleManager();
doReturn(true).when(activity).checkEnterPictureInPictureState(anyString(), anyBoolean());
- mService.requestPictureInPictureMode(activity.token);
+ mAtm.requestPictureInPictureMode(activity.token);
verify(mockLifecycleManager).scheduleTransaction(mClientTransactionCaptor.capture());
final ClientTransaction transaction = mClientTransactionCaptor.getValue();
@@ -108,11 +108,11 @@ public class ActivityTaskManagerServiceTests extends ActivityTestsBase {
public void testOnPictureInPictureRequested_cannotEnterPip() throws RemoteException {
final Task stack = new StackBuilder(mRootWindowContainer).build();
final ActivityRecord activity = stack.getBottomMostTask().getTopNonFinishingActivity();
- ClientLifecycleManager lifecycleManager = mService.getLifecycleManager();
+ ClientLifecycleManager lifecycleManager = mAtm.getLifecycleManager();
doReturn(false).when(activity).inPinnedWindowingMode();
doReturn(false).when(activity).checkEnterPictureInPictureState(anyString(), anyBoolean());
- mService.requestPictureInPictureMode(activity.token);
+ mAtm.requestPictureInPictureMode(activity.token);
// Check enter no transactions with enter pip requests are made.
verify(lifecycleManager, times(0)).scheduleTransaction(any());
@@ -122,10 +122,10 @@ public class ActivityTaskManagerServiceTests extends ActivityTestsBase {
public void testOnPictureInPictureRequested_alreadyInPIPMode() throws RemoteException {
final Task stack = new StackBuilder(mRootWindowContainer).build();
final ActivityRecord activity = stack.getBottomMostTask().getTopNonFinishingActivity();
- ClientLifecycleManager lifecycleManager = mService.getLifecycleManager();
+ ClientLifecycleManager lifecycleManager = mAtm.getLifecycleManager();
doReturn(true).when(activity).inPinnedWindowingMode();
- mService.requestPictureInPictureMode(activity.token);
+ mAtm.requestPictureInPictureMode(activity.token);
// Check that no transactions with enter pip requests are made.
verify(lifecycleManager, times(0)).scheduleTransaction(any());
@@ -158,14 +158,14 @@ public class ActivityTaskManagerServiceTests extends ActivityTestsBase {
@Override
public void onFixedRotationFinished(int displayId) {}
};
- mService.mWindowManager.registerDisplayWindowListener(listener);
+ mAtm.mWindowManager.registerDisplayWindowListener(listener);
// Check that existing displays call added
assertEquals(1, added.size());
assertEquals(0, changed.size());
assertEquals(0, removed.size());
added.clear();
// Check adding a display
- DisplayContent newDisp1 = new TestDisplayContent.Builder(mService, 600, 800).build();
+ DisplayContent newDisp1 = new TestDisplayContent.Builder(mAtm, 600, 800).build();
assertEquals(1, added.size());
assertEquals(0, changed.size());
assertEquals(0, removed.size());
@@ -174,7 +174,7 @@ public class ActivityTaskManagerServiceTests extends ActivityTestsBase {
Configuration c = new Configuration(newDisp1.getRequestedOverrideConfiguration());
c.windowConfiguration.setBounds(new Rect(0, 0, 1000, 1300));
newDisp1.onRequestedOverrideConfigurationChanged(c);
- mService.mRootWindowContainer.ensureVisibilityAndConfig(null /* starting */,
+ mAtm.mRootWindowContainer.ensureVisibilityAndConfig(null /* starting */,
newDisp1.mDisplayId, false /* markFrozenIfConfigChanged */,
false /* deferResume */);
assertEquals(0, added.size());
@@ -214,13 +214,13 @@ public class ActivityTaskManagerServiceTests extends ActivityTestsBase {
//mock other operations
doReturn(true).when(record)
.checkEnterPictureInPictureState("enterPictureInPictureMode", false);
- doReturn(false).when(mService).isInPictureInPictureMode(any());
- doReturn(false).when(mService).isKeyguardLocked();
+ doReturn(false).when(mAtm).isInPictureInPictureMode(any());
+ doReturn(false).when(mAtm).isKeyguardLocked();
//to simulate NPE
doReturn(null).when(record).getParent();
- mService.enterPictureInPictureMode(token, params);
+ mAtm.enterPictureInPictureMode(token, params);
//if record's null parent is not handled gracefully, test will fail with NPE
mockSession.finishMocking();
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityTestsBase.java b/services/tests/wmtests/src/com/android/server/wm/ActivityTestsBase.java
deleted file mode 100644
index 5be2f0453bf4..000000000000
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityTestsBase.java
+++ /dev/null
@@ -1,607 +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.server.wm;
-
-import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
-import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
-import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
-import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
-import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
-import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
-import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE;
-import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
-
-import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
-
-import static com.android.dx.mockito.inline.extended.ExtendedMockito.any;
-import static com.android.dx.mockito.inline.extended.ExtendedMockito.anyBoolean;
-import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing;
-import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
-import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock;
-import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
-import static com.android.server.wm.WindowContainer.POSITION_BOTTOM;
-
-import android.app.ActivityManager;
-import android.app.ActivityOptions;
-import android.app.IApplicationThread;
-import android.app.WindowConfiguration;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ActivityInfo;
-import android.content.pm.ApplicationInfo;
-import android.content.res.Configuration;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.UserHandle;
-import android.service.voice.IVoiceInteractionSession;
-import android.view.SurfaceControl;
-import android.window.ITaskOrganizer;
-import android.window.WindowContainerToken;
-
-import com.android.server.AttributeCache;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-
-/**
- * A base class to handle common operations in activity related unit tests.
- */
-class ActivityTestsBase extends SystemServiceTestsBase {
- final Context mContext = getInstrumentation().getTargetContext();
-
- ActivityTaskManagerService mService;
- RootWindowContainer mRootWindowContainer;
- ActivityStackSupervisor mSupervisor;
-
- // Default package name
- static final String DEFAULT_COMPONENT_PACKAGE_NAME = "com.foo";
-
- // Default base activity name
- private static final String DEFAULT_COMPONENT_CLASS_NAME = ".BarActivity";
-
- @BeforeClass
- public static void setUpOnceBase() {
- AttributeCache.init(getInstrumentation().getTargetContext());
- }
-
- @Before
- public void setUpBase() {
- mService = mSystemServicesTestRule.getActivityTaskManagerService();
- mSupervisor = mService.mStackSupervisor;
- mRootWindowContainer = mService.mRootWindowContainer;
- }
-
- /** Creates and adds a {@link TestDisplayContent} to supervisor at the given position. */
- TestDisplayContent addNewDisplayContentAt(int position) {
- return new TestDisplayContent.Builder(mService, 1000, 1500).setPosition(position).build();
- }
-
- /** Sets the default minimum task size to 1 so that tests can use small task sizes */
- public void removeGlobalMinSizeRestriction() {
- mService.mRootWindowContainer.mDefaultMinSizeOfResizeableTaskDp = 1;
- }
-
- /**
- * Builder for creating new activities.
- */
- protected static class ActivityBuilder {
- // An id appended to the end of the component name to make it unique
- private static int sCurrentActivityId = 0;
-
- private final ActivityTaskManagerService mService;
-
- private ComponentName mComponent;
- private String mTargetActivity;
- private Task mTask;
- private String mProcessName = "name";
- private String mAffinity;
- private int mUid = 12345;
- private boolean mCreateTask;
- private Task mStack;
- private int mActivityFlags;
- private int mLaunchMode;
- private int mResizeMode = RESIZE_MODE_RESIZEABLE;
- private float mMaxAspectRatio;
- private int mScreenOrientation = SCREEN_ORIENTATION_UNSPECIFIED;
- private boolean mLaunchTaskBehind;
- private int mConfigChanges;
- private int mLaunchedFromPid;
- private int mLaunchedFromUid;
- private WindowProcessController mWpc;
- private Bundle mIntentExtras;
-
- ActivityBuilder(ActivityTaskManagerService service) {
- mService = service;
- }
-
- ActivityBuilder setComponent(ComponentName component) {
- mComponent = component;
- return this;
- }
-
- ActivityBuilder setTargetActivity(String targetActivity) {
- mTargetActivity = targetActivity;
- return this;
- }
-
- ActivityBuilder setIntentExtras(Bundle extras) {
- mIntentExtras = extras;
- return this;
- }
-
- static ComponentName getDefaultComponent() {
- return ComponentName.createRelative(DEFAULT_COMPONENT_PACKAGE_NAME,
- DEFAULT_COMPONENT_PACKAGE_NAME);
- }
-
- ActivityBuilder setTask(Task task) {
- mTask = task;
- return this;
- }
-
- ActivityBuilder setActivityFlags(int flags) {
- mActivityFlags = flags;
- return this;
- }
-
- ActivityBuilder setLaunchMode(int launchMode) {
- mLaunchMode = launchMode;
- return this;
- }
-
- ActivityBuilder setStack(Task stack) {
- mStack = stack;
- return this;
- }
-
- ActivityBuilder setCreateTask(boolean createTask) {
- mCreateTask = createTask;
- return this;
- }
-
- ActivityBuilder setProcessName(String name) {
- mProcessName = name;
- return this;
- }
-
- ActivityBuilder setUid(int uid) {
- mUid = uid;
- return this;
- }
-
- ActivityBuilder setResizeMode(int resizeMode) {
- mResizeMode = resizeMode;
- return this;
- }
-
- ActivityBuilder setMaxAspectRatio(float maxAspectRatio) {
- mMaxAspectRatio = maxAspectRatio;
- return this;
- }
-
- ActivityBuilder setScreenOrientation(int screenOrientation) {
- mScreenOrientation = screenOrientation;
- return this;
- }
-
- ActivityBuilder setLaunchTaskBehind(boolean launchTaskBehind) {
- mLaunchTaskBehind = launchTaskBehind;
- return this;
- }
-
- ActivityBuilder setConfigChanges(int configChanges) {
- mConfigChanges = configChanges;
- return this;
- }
-
- ActivityBuilder setLaunchedFromPid(int pid) {
- mLaunchedFromPid = pid;
- return this;
- }
-
- ActivityBuilder setLaunchedFromUid(int uid) {
- mLaunchedFromUid = uid;
- return this;
- }
-
- ActivityBuilder setUseProcess(WindowProcessController wpc) {
- mWpc = wpc;
- return this;
- }
-
- ActivityBuilder setAffinity(String affinity) {
- mAffinity = affinity;
- return this;
- }
-
- ActivityRecord build() {
- SystemServicesTestRule.checkHoldsLock(mService.mGlobalLock);
- try {
- mService.deferWindowLayout();
- return buildInner();
- } finally {
- mService.continueWindowLayout();
- }
- }
-
- ActivityRecord buildInner() {
- if (mComponent == null) {
- final int id = sCurrentActivityId++;
- mComponent = ComponentName.createRelative(DEFAULT_COMPONENT_PACKAGE_NAME,
- DEFAULT_COMPONENT_CLASS_NAME + id);
- }
-
- if (mCreateTask) {
- mTask = new TaskBuilder(mService.mStackSupervisor)
- .setComponent(mComponent)
- .setStack(mStack).build();
- } else if (mTask == null && mStack != null && DisplayContent.alwaysCreateStack(
- mStack.getWindowingMode(), mStack.getActivityType())) {
- // The stack can be the task root.
- mTask = mStack;
- }
-
- Intent intent = new Intent();
- intent.setComponent(mComponent);
- if (mIntentExtras != null) {
- intent.putExtras(mIntentExtras);
- }
- final ActivityInfo aInfo = new ActivityInfo();
- aInfo.applicationInfo = new ApplicationInfo();
- aInfo.applicationInfo.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT;
- aInfo.applicationInfo.packageName = mComponent.getPackageName();
- aInfo.applicationInfo.uid = mUid;
- aInfo.processName = mProcessName;
- aInfo.packageName = mComponent.getPackageName();
- aInfo.name = mComponent.getClassName();
- if (mTargetActivity != null) {
- aInfo.targetActivity = mTargetActivity;
- }
- aInfo.flags |= mActivityFlags;
- aInfo.launchMode = mLaunchMode;
- aInfo.resizeMode = mResizeMode;
- aInfo.maxAspectRatio = mMaxAspectRatio;
- aInfo.screenOrientation = mScreenOrientation;
- aInfo.configChanges |= mConfigChanges;
- aInfo.taskAffinity = mAffinity;
-
- ActivityOptions options = null;
- if (mLaunchTaskBehind) {
- options = ActivityOptions.makeTaskLaunchBehind();
- }
-
- final ActivityRecord activity = new ActivityRecord(mService, null /* caller */,
- mLaunchedFromPid /* launchedFromPid */, mLaunchedFromUid /* launchedFromUid */,
- null, null, intent, null, aInfo /*aInfo*/, new Configuration(),
- null /* resultTo */, null /* resultWho */, 0 /* reqCode */,
- false /*componentSpecified*/, false /* rootVoiceInteraction */,
- mService.mStackSupervisor, options, null /* sourceRecord */);
- spyOn(activity);
- if (mTask != null) {
- // fullscreen value is normally read from resources in ctor, so for testing we need
- // to set it somewhere else since we can't mock resources.
- doReturn(true).when(activity).occludesParent();
- doReturn(true).when(activity).fillsParent();
- mTask.addChild(activity);
- // Make visible by default...
- activity.setVisible(true);
- }
-
- final WindowProcessController wpc;
- if (mWpc != null) {
- wpc = mWpc;
- } else {
- wpc = new WindowProcessController(mService,
- aInfo.applicationInfo, mProcessName, mUid,
- UserHandle.getUserId(12345), mock(Object.class),
- mock(WindowProcessListener.class));
- wpc.setThread(mock(IApplicationThread.class));
- }
- wpc.setThread(mock(IApplicationThread.class));
- activity.setProcess(wpc);
- doReturn(wpc).when(mService).getProcessController(
- activity.processName, activity.info.applicationInfo.uid);
-
- // Resume top activities to make sure all other signals in the system are connected.
- mService.mRootWindowContainer.resumeFocusedStacksTopActivities();
- return activity;
- }
- }
-
- /**
- * Builder for creating new tasks.
- */
- protected static class TaskBuilder {
- private final ActivityStackSupervisor mSupervisor;
-
- private ComponentName mComponent;
- private String mPackage;
- private int mFlags = 0;
- // Task id 0 is reserved in ARC for the home app.
- private int mTaskId = SystemServicesTestRule.sNextTaskId++;
- private int mUserId = 0;
- private IVoiceInteractionSession mVoiceSession;
- private boolean mCreateStack = true;
-
- private Task mStack;
- private TaskDisplayArea mTaskDisplayArea;
-
- TaskBuilder(ActivityStackSupervisor supervisor) {
- mSupervisor = supervisor;
- }
-
- TaskBuilder setComponent(ComponentName component) {
- mComponent = component;
- return this;
- }
-
- TaskBuilder setPackage(String packageName) {
- mPackage = packageName;
- return this;
- }
-
- /**
- * Set to {@code true} by default, set to {@code false} to prevent the task from
- * automatically creating a parent stack.
- */
- TaskBuilder setCreateStack(boolean createStack) {
- mCreateStack = createStack;
- return this;
- }
-
- TaskBuilder setVoiceSession(IVoiceInteractionSession session) {
- mVoiceSession = session;
- return this;
- }
-
- TaskBuilder setFlags(int flags) {
- mFlags = flags;
- return this;
- }
-
- TaskBuilder setTaskId(int taskId) {
- mTaskId = taskId;
- return this;
- }
-
- TaskBuilder setUserId(int userId) {
- mUserId = userId;
- return this;
- }
-
- TaskBuilder setStack(Task stack) {
- mStack = stack;
- return this;
- }
-
- TaskBuilder setDisplay(DisplayContent display) {
- mTaskDisplayArea = display.getDefaultTaskDisplayArea();
- return this;
- }
-
- Task build() {
- SystemServicesTestRule.checkHoldsLock(mSupervisor.mService.mGlobalLock);
-
- if (mStack == null && mCreateStack) {
- TaskDisplayArea displayArea = mTaskDisplayArea != null ? mTaskDisplayArea
- : mSupervisor.mRootWindowContainer.getDefaultTaskDisplayArea();
- mStack = displayArea.createStack(
- WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
- spyOn(mStack);
- }
-
- final ActivityInfo aInfo = new ActivityInfo();
- aInfo.applicationInfo = new ApplicationInfo();
- aInfo.applicationInfo.packageName = mPackage;
-
- Intent intent = new Intent();
- if (mComponent == null) {
- mComponent = ComponentName.createRelative(DEFAULT_COMPONENT_PACKAGE_NAME,
- DEFAULT_COMPONENT_CLASS_NAME);
- }
-
- intent.setComponent(mComponent);
- intent.setFlags(mFlags);
-
- final Task task = new Task(mSupervisor.mService, mTaskId, aInfo,
- intent /*intent*/, mVoiceSession, null /*_voiceInteractor*/,
- null /*taskDescription*/, mStack);
- spyOn(task);
- task.mUserId = mUserId;
-
- if (mStack != null) {
- mStack.moveToFront("test");
- mStack.addChild(task, true, true);
- }
-
- return task;
- }
- }
-
- static class StackBuilder {
- private final RootWindowContainer mRootWindowContainer;
- private DisplayContent mDisplay;
- private TaskDisplayArea mTaskDisplayArea;
- private int mStackId = -1;
- private int mWindowingMode = WINDOWING_MODE_UNDEFINED;
- private int mActivityType = ACTIVITY_TYPE_STANDARD;
- private boolean mOnTop = true;
- private boolean mCreateActivity = true;
- private ActivityInfo mInfo;
- private Intent mIntent;
-
- StackBuilder(RootWindowContainer root) {
- mRootWindowContainer = root;
- mDisplay = mRootWindowContainer.getDefaultDisplay();
- mTaskDisplayArea = mDisplay.getDefaultTaskDisplayArea();
- }
-
- StackBuilder setWindowingMode(int windowingMode) {
- mWindowingMode = windowingMode;
- return this;
- }
-
- StackBuilder setActivityType(int activityType) {
- mActivityType = activityType;
- return this;
- }
-
- StackBuilder setStackId(int stackId) {
- mStackId = stackId;
- return this;
- }
-
- /**
- * Set the parent {@link DisplayContent} and use the default task display area. Overrides
- * the task display area, if was set before.
- */
- StackBuilder setDisplay(DisplayContent display) {
- mDisplay = display;
- mTaskDisplayArea = mDisplay.getDefaultTaskDisplayArea();
- return this;
- }
-
- /** Set the parent {@link TaskDisplayArea}. Overrides the display, if was set before. */
- StackBuilder setTaskDisplayArea(TaskDisplayArea taskDisplayArea) {
- mTaskDisplayArea = taskDisplayArea;
- mDisplay = mTaskDisplayArea.mDisplayContent;
- return this;
- }
-
- StackBuilder setOnTop(boolean onTop) {
- mOnTop = onTop;
- return this;
- }
-
- StackBuilder setCreateActivity(boolean createActivity) {
- mCreateActivity = createActivity;
- return this;
- }
-
- StackBuilder setActivityInfo(ActivityInfo info) {
- mInfo = info;
- return this;
- }
-
- StackBuilder setIntent(Intent intent) {
- mIntent = intent;
- return this;
- }
-
- Task build() {
- SystemServicesTestRule.checkHoldsLock(mRootWindowContainer.mWmService.mGlobalLock);
-
- final int stackId = mStackId >= 0 ? mStackId : mTaskDisplayArea.getNextStackId();
- final Task stack = mTaskDisplayArea.createStackUnchecked(
- mWindowingMode, mActivityType, stackId, mOnTop, mInfo, mIntent,
- false /* createdByOrganizer */);
- final ActivityStackSupervisor supervisor = mRootWindowContainer.mStackSupervisor;
-
- if (mCreateActivity) {
- new ActivityBuilder(supervisor.mService)
- .setCreateTask(true)
- .setStack(stack)
- .build();
- if (mOnTop) {
- // We move the task to front again in order to regain focus after activity
- // added to the stack. Or {@link DisplayContent#mPreferredTopFocusableStack}
- // could be other stacks (e.g. home stack).
- stack.moveToFront("createActivityStack");
- } else {
- stack.moveToBack("createActivityStack", null);
- }
- }
- spyOn(stack);
-
- doNothing().when(stack).startActivityLocked(
- any(), any(), anyBoolean(), anyBoolean(), any());
-
- return stack;
- }
-
- }
-
- static class TestSplitOrganizer extends ITaskOrganizer.Stub {
- final ActivityTaskManagerService mService;
- Task mPrimary;
- Task mSecondary;
- boolean mInSplit = false;
- // moves everything to secondary. Most tests expect this since sysui usually does it.
- boolean mMoveToSecondaryOnEnter = true;
- int mDisplayId;
- TestSplitOrganizer(ActivityTaskManagerService service, int displayId) {
- mService = service;
- mDisplayId = displayId;
- mService.mTaskOrganizerController.registerTaskOrganizer(this,
- WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
- mService.mTaskOrganizerController.registerTaskOrganizer(this,
- WINDOWING_MODE_SPLIT_SCREEN_SECONDARY);
- WindowContainerToken primary = mService.mTaskOrganizerController.createRootTask(
- displayId, WINDOWING_MODE_SPLIT_SCREEN_PRIMARY).token;
- mPrimary = WindowContainer.fromBinder(primary.asBinder()).asTask();
- WindowContainerToken secondary = mService.mTaskOrganizerController.createRootTask(
- displayId, WINDOWING_MODE_SPLIT_SCREEN_SECONDARY).token;
- mSecondary = WindowContainer.fromBinder(secondary.asBinder()).asTask();
- }
- TestSplitOrganizer(ActivityTaskManagerService service) {
- this(service,
- service.mStackSupervisor.mRootWindowContainer.getDefaultDisplay().mDisplayId);
- }
- public void setMoveToSecondaryOnEnter(boolean move) {
- mMoveToSecondaryOnEnter = move;
- }
- @Override
- public void onTaskAppeared(ActivityManager.RunningTaskInfo info, SurfaceControl leash) {
- }
- @Override
- public void onTaskVanished(ActivityManager.RunningTaskInfo info) {
- }
- @Override
- public void onTaskInfoChanged(ActivityManager.RunningTaskInfo info) {
- if (mInSplit) {
- return;
- }
- if (info.topActivityType == ACTIVITY_TYPE_UNDEFINED) {
- // Not populated
- return;
- }
- if (info.configuration.windowConfiguration.getWindowingMode()
- != WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) {
- return;
- }
- mInSplit = true;
- if (!mMoveToSecondaryOnEnter) {
- return;
- }
- mService.mTaskOrganizerController.setLaunchRoot(mDisplayId,
- mSecondary.mRemoteToken.toWindowContainerToken());
- DisplayContent dc = mService.mRootWindowContainer.getDisplayContent(mDisplayId);
- dc.forAllTaskDisplayAreas(taskDisplayArea -> {
- for (int sNdx = taskDisplayArea.getStackCount() - 1; sNdx >= 0; --sNdx) {
- final Task stack = taskDisplayArea.getStackAt(sNdx);
- if (!WindowConfiguration.isSplitScreenWindowingMode(stack.getWindowingMode())) {
- stack.reparent(mSecondary, POSITION_BOTTOM);
- }
- }
- });
- }
- @Override
- public void onBackPressedOnTaskRoot(ActivityManager.RunningTaskInfo taskInfo) {
- }
- };
-}
diff --git a/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java b/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java
index 97a2ebe98abb..888935ef9747 100644
--- a/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java
@@ -431,7 +431,7 @@ public class AppWindowTokenTests extends WindowTestsBase {
doCallRealMethod().when(mStack).startActivityLocked(
any(), any(), anyBoolean(), anyBoolean(), any());
// Make mVisibleSetFromTransferredStartingWindow true.
- final ActivityRecord middle = new ActivityTestsBase.ActivityBuilder(mWm.mAtmService)
+ final ActivityRecord middle = new ActivityBuilder(mWm.mAtmService)
.setTask(mTask).build();
mStack.startActivityLocked(middle, null /* focusedTopActivity */,
false /* newTask */, false /* keepCurTransition */, null /* options */);
@@ -440,7 +440,7 @@ public class AppWindowTokenTests extends WindowTestsBase {
assertNull(mActivity.startingWindow);
assertHasStartingWindow(middle);
- final ActivityRecord top = new ActivityTestsBase.ActivityBuilder(mWm.mAtmService)
+ final ActivityRecord top = new ActivityBuilder(mWm.mAtmService)
.setTask(mTask).build();
// Expect the visibility should be updated to true when transferring starting window from
// a visible activity.
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
index edf15361e445..0cc61599c2ac 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
@@ -850,13 +850,13 @@ public class DisplayContentTests extends WindowTestsBase {
IWindowManager.FIXED_TO_USER_ROTATION_DISABLED);
final Task stack =
- new ActivityTestsBase.StackBuilder(mWm.mAtmService.mRootWindowContainer)
+ new StackBuilder(mWm.mAtmService.mRootWindowContainer)
.setDisplay(dc)
.build();
doReturn(true).when(stack).isVisible();
final Task freeformStack =
- new ActivityTestsBase.StackBuilder(mWm.mAtmService.mRootWindowContainer)
+ new StackBuilder(mWm.mAtmService.mRootWindowContainer)
.setDisplay(dc)
.setWindowingMode(WINDOWING_MODE_FREEFORM)
.build();
@@ -881,9 +881,8 @@ public class DisplayContentTests extends WindowTestsBase {
IWindowManager.FIXED_TO_USER_ROTATION_DISABLED);
final int newOrientation = getRotatedOrientation(dc);
- final Task stack =
- new ActivityTestsBase.StackBuilder(mWm.mAtmService.mRootWindowContainer)
- .setDisplay(dc).build();
+ final Task stack = new StackBuilder(mWm.mAtmService.mRootWindowContainer)
+ .setDisplay(dc).build();
final ActivityRecord activity = stack.getTopMostTask().getTopNonFinishingActivity();
activity.setRequestedOrientation(newOrientation);
@@ -901,9 +900,8 @@ public class DisplayContentTests extends WindowTestsBase {
IWindowManager.FIXED_TO_USER_ROTATION_ENABLED);
final int newOrientation = getRotatedOrientation(dc);
- final Task stack =
- new ActivityTestsBase.StackBuilder(mWm.mAtmService.mRootWindowContainer)
- .setDisplay(dc).build();
+ final Task stack = new StackBuilder(mWm.mAtmService.mRootWindowContainer)
+ .setDisplay(dc).build();
final ActivityRecord activity = stack.getTopMostTask().getTopNonFinishingActivity();
activity.setRequestedOrientation(newOrientation);
@@ -1213,7 +1211,7 @@ public class DisplayContentTests extends WindowTestsBase {
verify(t, never()).setPosition(any(), eq(0), eq(0));
// Launch another activity before the transition is finished.
- final ActivityRecord app2 = new ActivityTestsBase.StackBuilder(mWm.mRoot)
+ final ActivityRecord app2 = new StackBuilder(mWm.mRoot)
.setDisplay(mDisplayContent).build().getTopMostActivity();
app2.setVisible(false);
mDisplayContent.mOpeningApps.add(app2);
@@ -1247,8 +1245,7 @@ public class DisplayContentTests extends WindowTestsBase {
final ActivityRecord app = createActivityRecord(mDisplayContent, WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD);
final Task task = app.getTask();
- final ActivityRecord app2 = new ActivityTestsBase.ActivityBuilder(mWm.mAtmService)
- .setTask(task).build();
+ final ActivityRecord app2 = new ActivityBuilder(mWm.mAtmService).setTask(task).build();
mDisplayContent.setFixedRotationLaunchingApp(app2, (mDisplayContent.getRotation() + 1) % 4);
doReturn(true).when(task).isAppTransitioning();
// If the task is animating transition, this should be no-op.
@@ -1513,8 +1510,7 @@ public class DisplayContentTests extends WindowTestsBase {
@Test
public void testSetWindowingModeAtomicallyUpdatesWindoingModeAndDisplayWindowingMode() {
final DisplayContent dc = createNewDisplay();
- final Task stack =
- new ActivityTestsBase.StackBuilder(mWm.mAtmService.mRootWindowContainer)
+ final Task stack = new StackBuilder(mWm.mAtmService.mRootWindowContainer)
.setDisplay(dc)
.build();
doAnswer(invocation -> {
diff --git a/services/tests/wmtests/src/com/android/server/wm/LaunchParamsControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/LaunchParamsControllerTests.java
index a7a8505e336d..820eca4a49a8 100644
--- a/services/tests/wmtests/src/com/android/server/wm/LaunchParamsControllerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/LaunchParamsControllerTests.java
@@ -68,14 +68,14 @@ import java.util.Map;
@MediumTest
@Presubmit
@RunWith(WindowTestRunner.class)
-public class LaunchParamsControllerTests extends ActivityTestsBase {
+public class LaunchParamsControllerTests extends WindowTestsBase {
private LaunchParamsController mController;
private TestLaunchParamsPersister mPersister;
@Before
public void setUp() throws Exception {
mPersister = new TestLaunchParamsPersister();
- mController = new LaunchParamsController(mService, mPersister);
+ mController = new LaunchParamsController(mAtm, mPersister);
}
/**
@@ -87,8 +87,8 @@ public class LaunchParamsControllerTests extends ActivityTestsBase {
positioner = mock(LaunchParamsModifier.class);
mController.registerModifier(positioner);
- final ActivityRecord record = new ActivityBuilder(mService).build();
- final ActivityRecord source = new ActivityBuilder(mService).build();
+ final ActivityRecord record = new ActivityBuilder(mAtm).build();
+ final ActivityRecord source = new ActivityBuilder(mAtm).build();
final WindowLayout layout = new WindowLayout(0, 0, 0, 0, 0, 0, 0);
final ActivityOptions options = mock(ActivityOptions.class);
@@ -108,7 +108,7 @@ public class LaunchParamsControllerTests extends ActivityTestsBase {
final ComponentName name = new ComponentName("com.android.foo", ".BarActivity");
final int userId = 0;
- final ActivityRecord activity = new ActivityBuilder(mService).setComponent(name)
+ final ActivityRecord activity = new ActivityBuilder(mAtm).setComponent(name)
.setUid(userId).build();
final LaunchParams expected = new LaunchParams();
expected.mPreferredTaskDisplayArea = mock(TaskDisplayArea.class);
@@ -228,10 +228,10 @@ public class LaunchParamsControllerTests extends ActivityTestsBase {
@Test
public void testVrPreferredDisplay() {
final TestDisplayContent vrDisplay = createNewDisplayContent();
- mService.mVr2dDisplayId = vrDisplay.mDisplayId;
+ mAtm.mVr2dDisplayId = vrDisplay.mDisplayId;
final LaunchParams result = new LaunchParams();
- final ActivityRecord vrActivity = new ActivityBuilder(mService).build();
+ final ActivityRecord vrActivity = new ActivityBuilder(mAtm).build();
vrActivity.requestedVrComponent = vrActivity.mActivityComponent;
// VR activities should always land on default display.
@@ -241,7 +241,7 @@ public class LaunchParamsControllerTests extends ActivityTestsBase {
result.mPreferredTaskDisplayArea);
// Otherwise, always lands on VR 2D display.
- final ActivityRecord vr2dActivity = new ActivityBuilder(mService).build();
+ final ActivityRecord vr2dActivity = new ActivityBuilder(mAtm).build();
mController.calculate(null /*task*/, null /*layout*/, vr2dActivity /*activity*/,
null /*source*/, null /*options*/, PHASE_BOUNDS, result);
assertEquals(vrDisplay.getDefaultTaskDisplayArea(), result.mPreferredTaskDisplayArea);
@@ -249,7 +249,7 @@ public class LaunchParamsControllerTests extends ActivityTestsBase {
null /*options*/, PHASE_BOUNDS, result);
assertEquals(vrDisplay.getDefaultTaskDisplayArea(), result.mPreferredTaskDisplayArea);
- mService.mVr2dDisplayId = INVALID_DISPLAY;
+ mAtm.mVr2dDisplayId = INVALID_DISPLAY;
}
@@ -262,8 +262,8 @@ public class LaunchParamsControllerTests extends ActivityTestsBase {
final LaunchParamsModifier positioner = mock(LaunchParamsModifier.class);
mController.registerModifier(positioner);
- final ActivityRecord record = new ActivityBuilder(mService).build();
- final ActivityRecord source = new ActivityBuilder(mService).build();
+ final ActivityRecord record = new ActivityBuilder(mAtm).build();
+ final ActivityRecord source = new ActivityBuilder(mAtm).build();
final WindowLayout layout = new WindowLayout(0, 0, 0, 0, 0, 0, 0);
final ActivityOptions options = mock(ActivityOptions.class);
@@ -284,7 +284,7 @@ public class LaunchParamsControllerTests extends ActivityTestsBase {
final TaskDisplayArea preferredTaskDisplayArea = display.getDefaultTaskDisplayArea();
params.mPreferredTaskDisplayArea = preferredTaskDisplayArea;
final InstrumentedPositioner positioner = new InstrumentedPositioner(RESULT_DONE, params);
- final Task task = new TaskBuilder(mService.mStackSupervisor).build();
+ final Task task = new TaskBuilder(mAtm.mStackSupervisor).build();
mController.registerModifier(positioner);
@@ -305,7 +305,7 @@ public class LaunchParamsControllerTests extends ActivityTestsBase {
final int windowingMode = WINDOWING_MODE_FREEFORM;
params.mWindowingMode = windowingMode;
final InstrumentedPositioner positioner = new InstrumentedPositioner(RESULT_DONE, params);
- final Task task = new TaskBuilder(mService.mStackSupervisor).build();
+ final Task task = new TaskBuilder(mAtm.mStackSupervisor).build();
mController.registerModifier(positioner);
@@ -330,7 +330,7 @@ public class LaunchParamsControllerTests extends ActivityTestsBase {
params.mWindowingMode = WINDOWING_MODE_FREEFORM;
params.mBounds.set(expected);
final InstrumentedPositioner positioner = new InstrumentedPositioner(RESULT_DONE, params);
- final Task task = new TaskBuilder(mService.mStackSupervisor).build();
+ final Task task = new TaskBuilder(mAtm.mStackSupervisor).build();
mController.registerModifier(positioner);
@@ -355,7 +355,7 @@ public class LaunchParamsControllerTests extends ActivityTestsBase {
params.mWindowingMode = WINDOWING_MODE_FULLSCREEN;
params.mBounds.set(expected);
final InstrumentedPositioner positioner = new InstrumentedPositioner(RESULT_DONE, params);
- final Task task = new TaskBuilder(mService.mStackSupervisor).build();
+ final Task task = new TaskBuilder(mAtm.mStackSupervisor).build();
mController.registerModifier(positioner);
diff --git a/services/tests/wmtests/src/com/android/server/wm/LaunchParamsPersisterTests.java b/services/tests/wmtests/src/com/android/server/wm/LaunchParamsPersisterTests.java
index e389a538f25d..18a2d1337d4b 100644
--- a/services/tests/wmtests/src/com/android/server/wm/LaunchParamsPersisterTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/LaunchParamsPersisterTests.java
@@ -65,7 +65,7 @@ import java.util.function.Predicate;
@MediumTest
@Presubmit
@RunWith(WindowTestRunner.class)
-public class LaunchParamsPersisterTests extends ActivityTestsBase {
+public class LaunchParamsPersisterTests extends WindowTestsBase {
private static final int TEST_USER_ID = 3;
private static final int ALTERNATIVE_USER_ID = 0;
private static final ComponentName TEST_COMPONENT =
@@ -109,7 +109,7 @@ public class LaunchParamsPersisterTests extends ActivityTestsBase {
deleteRecursively(mFolder);
mDisplayUniqueId = "test:" + sNextUniqueId++;
- mTestDisplay = new TestDisplayContent.Builder(mService, 1000, 1500)
+ mTestDisplay = new TestDisplayContent.Builder(mAtm, 1000, 1500)
.setUniqueId(mDisplayUniqueId).build();
when(mRootWindowContainer.getDisplayContent(eq(mDisplayUniqueId)))
.thenReturn(mTestDisplay);
@@ -172,7 +172,7 @@ public class LaunchParamsPersisterTests extends ActivityTestsBase {
public void testFetchesSameResultWithActivity() {
mTarget.saveTask(mTestTask);
- final ActivityRecord activity = new ActivityBuilder(mService).setComponent(TEST_COMPONENT)
+ final ActivityRecord activity = new ActivityBuilder(mAtm).setComponent(TEST_COMPONENT)
.setUid(TEST_USER_ID * UserHandle.PER_USER_RANGE).build();
mTarget.getLaunchParams(null, activity, mResult);
diff --git a/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java b/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java
index 1724303633d9..54c7f271e81b 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java
@@ -94,7 +94,7 @@ import java.util.function.Function;
@MediumTest
@Presubmit
@RunWith(WindowTestRunner.class)
-public class RecentTasksTest extends ActivityTestsBase {
+public class RecentTasksTest extends WindowTestsBase {
private static final int TEST_USER_0_ID = 0;
private static final int TEST_USER_1_ID = 10;
private static final int TEST_QUIET_USER_ID = 20;
@@ -122,14 +122,14 @@ public class RecentTasksTest extends ActivityTestsBase {
mTaskContainer = mRootWindowContainer.getDefaultTaskDisplayArea();
// Set the recent tasks we should use for testing in this class.
- mRecentTasks = new TestRecentTasks(mService, mTaskPersister);
+ mRecentTasks = new TestRecentTasks(mAtm, mTaskPersister);
spyOn(mRecentTasks);
- mService.setRecentTasks(mRecentTasks);
+ mAtm.setRecentTasks(mRecentTasks);
mRecentTasks.loadParametersFromResources(mContext.getResources());
// Set the running tasks we should use for testing in this class.
mRunningTasks = new TestRunningTasks();
- mService.mStackSupervisor.setRunningTasks(mRunningTasks);
+ mAtm.mStackSupervisor.setRunningTasks(mRunningTasks);
mStack = mTaskContainer.createStack(
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
@@ -455,7 +455,7 @@ public class RecentTasksTest extends ActivityTestsBase {
final Function<Boolean, Task> taskBuilder = visible -> {
final Task task = createTaskBuilder(className).build();
// Make the task non-empty.
- final ActivityRecord r = new ActivityBuilder(mService).setTask(task).build();
+ final ActivityRecord r = new ActivityBuilder(mAtm).setTask(task).build();
r.setVisibility(visible);
return task;
};
@@ -831,7 +831,7 @@ public class RecentTasksTest extends ActivityTestsBase {
Task stack = mTasks.get(2).getRootTask();
stack.moveToFront("", mTasks.get(2));
- doReturn(stack).when(mService.mRootWindowContainer).getTopDisplayFocusedStack();
+ doReturn(stack).when(mAtm.mRootWindowContainer).getTopDisplayFocusedStack();
// Simulate the reset from the timeout
mRecentTasks.resetFreezeTaskListReorderingOnTimeout();
@@ -994,16 +994,16 @@ public class RecentTasksTest extends ActivityTestsBase {
mStack.removeIfPossible();
// The following APIs should not restore task from recents to the active list.
- assertNotRestoreTask(() -> mService.setFocusedTask(taskId));
- assertNotRestoreTask(() -> mService.startSystemLockTaskMode(taskId));
- assertNotRestoreTask(() -> mService.cancelTaskWindowTransition(taskId));
+ assertNotRestoreTask(() -> mAtm.setFocusedTask(taskId));
+ assertNotRestoreTask(() -> mAtm.startSystemLockTaskMode(taskId));
+ assertNotRestoreTask(() -> mAtm.cancelTaskWindowTransition(taskId));
assertNotRestoreTask(
- () -> mService.resizeTask(taskId, null /* bounds */, 0 /* resizeMode */));
+ () -> mAtm.resizeTask(taskId, null /* bounds */, 0 /* resizeMode */));
assertNotRestoreTask(
- () -> mService.setTaskWindowingMode(taskId, WINDOWING_MODE_FULLSCREEN,
+ () -> mAtm.setTaskWindowingMode(taskId, WINDOWING_MODE_FULLSCREEN,
false/* toTop */));
assertNotRestoreTask(
- () -> mService.setTaskWindowingModeSplitScreenPrimary(taskId, false /* toTop */));
+ () -> mAtm.setTaskWindowingModeSplitScreenPrimary(taskId, false /* toTop */));
}
@Test
@@ -1014,7 +1014,7 @@ public class RecentTasksTest extends ActivityTestsBase {
mRecentTasks.remove(task);
TaskChangeNotificationController controller =
- mService.getTaskChangeNotificationController();
+ mAtm.getTaskChangeNotificationController();
verify(controller, times(2)).notifyTaskListUpdated();
}
@@ -1027,7 +1027,7 @@ public class RecentTasksTest extends ActivityTestsBase {
// 2 calls - Once for add and once for remove
TaskChangeNotificationController controller =
- mService.getTaskChangeNotificationController();
+ mAtm.getTaskChangeNotificationController();
verify(controller, times(2)).notifyTaskListUpdated();
}
@@ -1042,7 +1042,7 @@ public class RecentTasksTest extends ActivityTestsBase {
// 4 calls - Twice for add and twice for remove
TaskChangeNotificationController controller =
- mService.getTaskChangeNotificationController();
+ mAtm.getTaskChangeNotificationController();
verify(controller, times(4)).notifyTaskListUpdated();
}
@@ -1054,7 +1054,7 @@ public class RecentTasksTest extends ActivityTestsBase {
final Bundle data = new Bundle();
data.putInt("key", 100);
final Task task1 = createTaskBuilder(".Task").build();
- final ActivityRecord r1 = new ActivityBuilder(mService)
+ final ActivityRecord r1 = new ActivityBuilder(mAtm)
.setTask(task1)
.setIntentExtras(data)
.build();
@@ -1106,7 +1106,7 @@ public class RecentTasksTest extends ActivityTestsBase {
@Test
public void testNotRecentsComponent_denyApiAccess() throws Exception {
- doReturn(PackageManager.PERMISSION_DENIED).when(mService)
+ doReturn(PackageManager.PERMISSION_DENIED).when(mAtm)
.checkGetTasksPermission(anyString(), anyInt(), anyInt());
// Expect the following methods to fail due to recents component not being set
mRecentTasks.setIsCallerRecentsOverride(TestRecentTasks.DENY_THROW_SECURITY_EXCEPTION);
@@ -1118,7 +1118,7 @@ public class RecentTasksTest extends ActivityTestsBase {
@Test
public void testRecentsComponent_allowApiAccessWithoutPermissions() {
- doReturn(PackageManager.PERMISSION_DENIED).when(mService)
+ doReturn(PackageManager.PERMISSION_DENIED).when(mAtm)
.checkGetTasksPermission(anyString(), anyInt(), anyInt());
// Set the recents component and ensure that the following calls do not fail
mRecentTasks.setIsCallerRecentsOverride(TestRecentTasks.GRANT);
@@ -1127,50 +1127,50 @@ public class RecentTasksTest extends ActivityTestsBase {
}
private void doTestRecentTasksApis(boolean expectCallable) {
- assertSecurityException(expectCallable, () -> mService.removeStack(INVALID_STACK_ID));
+ assertSecurityException(expectCallable, () -> mAtm.removeStack(INVALID_STACK_ID));
assertSecurityException(expectCallable,
- () -> mService.removeStacksInWindowingModes(
+ () -> mAtm.removeStacksInWindowingModes(
new int[]{WINDOWING_MODE_UNDEFINED}));
assertSecurityException(expectCallable,
- () -> mService.removeStacksWithActivityTypes(
+ () -> mAtm.removeStacksWithActivityTypes(
new int[]{ACTIVITY_TYPE_UNDEFINED}));
- assertSecurityException(expectCallable, () -> mService.removeTask(0));
+ assertSecurityException(expectCallable, () -> mAtm.removeTask(0));
assertSecurityException(expectCallable,
- () -> mService.setTaskWindowingMode(0, WINDOWING_MODE_UNDEFINED, true));
+ () -> mAtm.setTaskWindowingMode(0, WINDOWING_MODE_UNDEFINED, true));
assertSecurityException(expectCallable,
- () -> mService.moveTaskToStack(0, INVALID_STACK_ID, true));
+ () -> mAtm.moveTaskToStack(0, INVALID_STACK_ID, true));
assertSecurityException(expectCallable,
- () -> mService.setTaskWindowingModeSplitScreenPrimary(0, true));
+ () -> mAtm.setTaskWindowingModeSplitScreenPrimary(0, true));
assertSecurityException(expectCallable,
- () -> mService.moveTopActivityToPinnedStack(INVALID_STACK_ID, new Rect()));
- assertSecurityException(expectCallable, () -> mService.getAllStackInfos());
+ () -> mAtm.moveTopActivityToPinnedStack(INVALID_STACK_ID, new Rect()));
+ assertSecurityException(expectCallable, () -> mAtm.getAllStackInfos());
assertSecurityException(expectCallable,
- () -> mService.getStackInfo(WINDOWING_MODE_UNDEFINED, ACTIVITY_TYPE_UNDEFINED));
+ () -> mAtm.getStackInfo(WINDOWING_MODE_UNDEFINED, ACTIVITY_TYPE_UNDEFINED));
assertSecurityException(expectCallable, () -> {
try {
- mService.getFocusedStackInfo();
+ mAtm.getFocusedStackInfo();
} catch (RemoteException e) {
// Ignore
}
});
assertSecurityException(expectCallable,
- () -> mService.startActivityFromRecents(0, new Bundle()));
- assertSecurityException(expectCallable, () -> mService.getTaskSnapshot(0, true));
- assertSecurityException(expectCallable, () -> mService.registerTaskStackListener(null));
+ () -> mAtm.startActivityFromRecents(0, new Bundle()));
+ assertSecurityException(expectCallable, () -> mAtm.getTaskSnapshot(0, true));
+ assertSecurityException(expectCallable, () -> mAtm.registerTaskStackListener(null));
assertSecurityException(expectCallable,
- () -> mService.unregisterTaskStackListener(null));
- assertSecurityException(expectCallable, () -> mService.getTaskDescription(0));
- assertSecurityException(expectCallable, () -> mService.cancelTaskWindowTransition(0));
- assertSecurityException(expectCallable, () -> mService.startRecentsActivity(null, null,
+ () -> mAtm.unregisterTaskStackListener(null));
+ assertSecurityException(expectCallable, () -> mAtm.getTaskDescription(0));
+ assertSecurityException(expectCallable, () -> mAtm.cancelTaskWindowTransition(0));
+ assertSecurityException(expectCallable, () -> mAtm.startRecentsActivity(null, null,
null));
- assertSecurityException(expectCallable, () -> mService.cancelRecentsAnimation(true));
- assertSecurityException(expectCallable, () -> mService.stopAppSwitches());
- assertSecurityException(expectCallable, () -> mService.resumeAppSwitches());
+ assertSecurityException(expectCallable, () -> mAtm.cancelRecentsAnimation(true));
+ assertSecurityException(expectCallable, () -> mAtm.stopAppSwitches());
+ assertSecurityException(expectCallable, () -> mAtm.resumeAppSwitches());
}
private void testGetTasksApis(boolean expectCallable) {
- mService.getRecentTasks(MAX_VALUE, 0, TEST_USER_0_ID);
- mService.getTasks(MAX_VALUE);
+ mAtm.getRecentTasks(MAX_VALUE, 0, TEST_USER_0_ID);
+ mAtm.getTasks(MAX_VALUE);
if (expectCallable) {
assertTrue(mRecentTasks.mLastAllowed);
assertTrue(mRunningTasks.mLastAllowed);
@@ -1185,7 +1185,7 @@ public class RecentTasksTest extends ActivityTestsBase {
}
private TaskBuilder createTaskBuilder(String packageName, String className) {
- return new TaskBuilder(mService.mStackSupervisor)
+ return new TaskBuilder(mAtm.mStackSupervisor)
.setComponent(new ComponentName(packageName, className))
.setStack(mStack)
.setUserId(TEST_USER_0_ID);
diff --git a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java
index 8bc8c0b1169f..7fb7d40f0bd2 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java
@@ -477,7 +477,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase {
}
private ActivityRecord createHomeActivity() {
- final ActivityRecord homeActivity = new ActivityTestsBase.ActivityBuilder(mWm.mAtmService)
+ final ActivityRecord homeActivity = new ActivityBuilder(mWm.mAtmService)
.setStack(mRootHomeTask)
.setCreateTask(true)
.build();
diff --git a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationTest.java b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationTest.java
index e5d1e465d8ff..d821d38ea297 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationTest.java
@@ -66,7 +66,7 @@ import org.junit.runner.RunWith;
@MediumTest
@Presubmit
@RunWith(WindowTestRunner.class)
-public class RecentsAnimationTest extends ActivityTestsBase {
+public class RecentsAnimationTest extends WindowTestsBase {
private static final int TEST_USER_ID = 100;
@@ -77,11 +77,11 @@ public class RecentsAnimationTest extends ActivityTestsBase {
@Before
public void setUp() throws Exception {
mRecentsAnimationController = mock(RecentsAnimationController.class);
- mService.mWindowManager.setRecentsAnimationController(mRecentsAnimationController);
- doNothing().when(mService.mWindowManager).initializeRecentsAnimation(
+ mAtm.mWindowManager.setRecentsAnimationController(mRecentsAnimationController);
+ doNothing().when(mAtm.mWindowManager).initializeRecentsAnimation(
anyInt(), any(), any(), anyInt(), any(), any());
- final RecentTasks recentTasks = mService.getRecentTasks();
+ final RecentTasks recentTasks = mAtm.getRecentTasks();
spyOn(recentTasks);
doReturn(mRecentsComponent).when(recentTasks).getRecentsComponent();
}
@@ -91,12 +91,12 @@ public class RecentsAnimationTest extends ActivityTestsBase {
TaskDisplayArea taskDisplayArea = mRootWindowContainer.getDefaultTaskDisplayArea();
Task recentsStack = taskDisplayArea.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_RECENTS, true /* onTop */);
- ActivityRecord recentActivity = new ActivityBuilder(mService)
+ ActivityRecord recentActivity = new ActivityBuilder(mAtm)
.setComponent(mRecentsComponent)
.setCreateTask(true)
.setStack(recentsStack)
.build();
- ActivityRecord topActivity = new ActivityBuilder(mService).setCreateTask(true).build();
+ ActivityRecord topActivity = new ActivityBuilder(mAtm).setCreateTask(true).build();
topActivity.getRootTask().moveToFront("testRecentsActivityVisiblility");
doCallRealMethod().when(mRootWindowContainer).ensureActivitiesVisible(
@@ -123,7 +123,7 @@ public class RecentsAnimationTest extends ActivityTestsBase {
false /* includingParents */);
ActivityRecord topRunningHomeActivity = homeStack.topRunningActivity();
if (topRunningHomeActivity == null) {
- topRunningHomeActivity = new ActivityBuilder(mService)
+ topRunningHomeActivity = new ActivityBuilder(mAtm)
.setStack(homeStack)
.setCreateTask(true)
.build();
@@ -139,15 +139,15 @@ public class RecentsAnimationTest extends ActivityTestsBase {
anyInt() /* startFlags */, any() /* profilerInfo */);
// Assume its process is alive because the caller should be the recents service.
- WindowProcessController wpc = new WindowProcessController(mService, aInfo.applicationInfo,
+ WindowProcessController wpc = new WindowProcessController(mAtm, aInfo.applicationInfo,
aInfo.processName, aInfo.applicationInfo.uid, 0 /* userId */,
mock(Object.class) /* owner */, mock(WindowProcessListener.class));
wpc.setThread(mock(IApplicationThread.class));
- doReturn(wpc).when(mService).getProcessController(eq(wpc.mName), eq(wpc.mUid));
+ doReturn(wpc).when(mAtm).getProcessController(eq(wpc.mName), eq(wpc.mUid));
Intent recentsIntent = new Intent().setComponent(mRecentsComponent);
// Null animation indicates to preload.
- mService.startRecentsActivity(recentsIntent, null /* assistDataReceiver */,
+ mAtm.startRecentsActivity(recentsIntent, null /* assistDataReceiver */,
null /* recentsAnimationRunner */);
Task recentsStack = defaultTaskDisplayArea.getStack(WINDOWING_MODE_FULLSCREEN,
@@ -167,7 +167,7 @@ public class RecentsAnimationTest extends ActivityTestsBase {
spyOn(recentsActivity);
// Start when the recents activity exists. It should ensure the configuration.
- mService.startRecentsActivity(recentsIntent, null /* assistDataReceiver */,
+ mAtm.startRecentsActivity(recentsIntent, null /* assistDataReceiver */,
null /* recentsAnimationRunner */);
verify(recentsActivity).ensureActivityConfiguration(anyInt() /* globalChanges */,
@@ -181,20 +181,20 @@ public class RecentsAnimationTest extends ActivityTestsBase {
TaskDisplayArea defaultTaskDisplayArea = mRootWindowContainer.getDefaultTaskDisplayArea();
Task recentsStack = defaultTaskDisplayArea.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_RECENTS, true /* onTop */);
- ActivityRecord recentActivity = new ActivityBuilder(mService).setComponent(
+ ActivityRecord recentActivity = new ActivityBuilder(mAtm).setComponent(
mRecentsComponent).setCreateTask(true).setStack(recentsStack).build();
WindowProcessController app = recentActivity.app;
recentActivity.app = null;
// Start an activity on top.
- new ActivityBuilder(mService).setCreateTask(true).build().getRootTask().moveToFront(
+ new ActivityBuilder(mAtm).setCreateTask(true).build().getRootTask().moveToFront(
"testRestartRecentsActivity");
doCallRealMethod().when(mRootWindowContainer).ensureActivitiesVisible(
any() /* starting */, anyInt() /* configChanges */,
anyBoolean() /* preserveWindows */, anyBoolean() /* notifyClients */);
- doReturn(app).when(mService).getProcessController(eq(recentActivity.processName), anyInt());
- ClientLifecycleManager lifecycleManager = mService.getLifecycleManager();
+ doReturn(app).when(mAtm).getProcessController(eq(recentActivity.processName), anyInt());
+ ClientLifecycleManager lifecycleManager = mAtm.getLifecycleManager();
doNothing().when(lifecycleManager).scheduleTransaction(any());
startRecentsActivity();
@@ -212,20 +212,20 @@ public class RecentsAnimationTest extends ActivityTestsBase {
// Assume the home activity support recents.
ActivityRecord targetActivity = homeStack.getTopNonFinishingActivity();
if (targetActivity == null) {
- targetActivity = new ActivityBuilder(mService)
+ targetActivity = new ActivityBuilder(mAtm)
.setCreateTask(true)
.setStack(homeStack)
.build();
}
// Put another home activity in home stack.
- ActivityRecord anotherHomeActivity = new ActivityBuilder(mService)
+ ActivityRecord anotherHomeActivity = new ActivityBuilder(mAtm)
.setComponent(new ComponentName(mContext.getPackageName(), "Home2"))
.setCreateTask(true)
.setStack(homeStack)
.build();
// Start an activity on top so the recents activity can be started.
- new ActivityBuilder(mService)
+ new ActivityBuilder(mAtm)
.setCreateTask(true)
.build()
.getRootTask()
@@ -252,21 +252,21 @@ public class RecentsAnimationTest extends ActivityTestsBase {
TaskDisplayArea taskDisplayArea = mRootWindowContainer.getDefaultTaskDisplayArea();
Task fullscreenStack = taskDisplayArea.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, true /* onTop */);
- new ActivityBuilder(mService)
+ new ActivityBuilder(mAtm)
.setComponent(new ComponentName(mContext.getPackageName(), "App1"))
.setCreateTask(true)
.setStack(fullscreenStack)
.build();
Task recentsStack = taskDisplayArea.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_RECENTS, true /* onTop */);
- new ActivityBuilder(mService)
+ new ActivityBuilder(mAtm)
.setComponent(mRecentsComponent)
.setCreateTask(true)
.setStack(recentsStack)
.build();
Task fullscreenStack2 = taskDisplayArea.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, true /* onTop */);
- new ActivityBuilder(mService)
+ new ActivityBuilder(mAtm)
.setComponent(new ComponentName(mContext.getPackageName(), "App2"))
.setCreateTask(true)
.setStack(fullscreenStack2)
@@ -293,21 +293,21 @@ public class RecentsAnimationTest extends ActivityTestsBase {
TaskDisplayArea taskDisplayArea = mRootWindowContainer.getDefaultTaskDisplayArea();
Task fullscreenStack = taskDisplayArea.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, true /* onTop */);
- new ActivityBuilder(mService)
+ new ActivityBuilder(mAtm)
.setComponent(new ComponentName(mContext.getPackageName(), "App1"))
.setCreateTask(true)
.setStack(fullscreenStack)
.build();
Task recentsStack = taskDisplayArea.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_RECENTS, true /* onTop */);
- new ActivityBuilder(mService)
+ new ActivityBuilder(mAtm)
.setComponent(mRecentsComponent)
.setCreateTask(true)
.setStack(recentsStack)
.build();
Task fullscreenStack2 = taskDisplayArea.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, true /* onTop */);
- new ActivityBuilder(mService)
+ new ActivityBuilder(mAtm)
.setComponent(new ComponentName(mContext.getPackageName(), "App2"))
.setCreateTask(true)
.setStack(fullscreenStack2)
@@ -319,7 +319,7 @@ public class RecentsAnimationTest extends ActivityTestsBase {
fullscreenStack.removeIfPossible();
// Ensure that the recents animation was NOT canceled
- verify(mService.mWindowManager, times(0)).cancelRecentsAnimation(
+ verify(mAtm.mWindowManager, times(0)).cancelRecentsAnimation(
eq(REORDER_KEEP_IN_PLACE), any());
verify(mRecentsAnimationController, times(0)).setCancelOnNextTransitionStart();
}
@@ -330,7 +330,7 @@ public class RecentsAnimationTest extends ActivityTestsBase {
.getDefaultTaskDisplayArea();
Task homeStack = taskDisplayArea.getStack(WINDOWING_MODE_UNDEFINED,
ACTIVITY_TYPE_HOME);
- ActivityRecord otherUserHomeActivity = new ActivityBuilder(mService)
+ ActivityRecord otherUserHomeActivity = new ActivityBuilder(mAtm)
.setStack(homeStack)
.setCreateTask(true)
.setComponent(new ComponentName(mContext.getPackageName(), "Home2"))
@@ -339,13 +339,13 @@ public class RecentsAnimationTest extends ActivityTestsBase {
Task fullscreenStack = taskDisplayArea.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, true /* onTop */);
- new ActivityBuilder(mService)
+ new ActivityBuilder(mAtm)
.setComponent(new ComponentName(mContext.getPackageName(), "App1"))
.setCreateTask(true)
.setStack(fullscreenStack)
.build();
- doReturn(TEST_USER_ID).when(mService).getCurrentUserId();
+ doReturn(TEST_USER_ID).when(mAtm).getCurrentUserId();
doCallRealMethod().when(mRootWindowContainer).ensureActivitiesVisible(
any() /* starting */, anyInt() /* configChanges */,
anyBoolean() /* preserveWindows */, anyBoolean() /* notifyClients */);
@@ -373,7 +373,7 @@ public class RecentsAnimationTest extends ActivityTestsBase {
// The callback is actually RecentsAnimation.
recentsAnimation[0] = invocation.getArgument(2);
return null;
- }).when(mService.mWindowManager).initializeRecentsAnimation(
+ }).when(mAtm.mWindowManager).initializeRecentsAnimation(
anyInt() /* targetActivityType */, any() /* recentsAnimationRunner */,
any() /* callbacks */, anyInt() /* displayId */, any() /* recentTaskIds */,
any() /* targetActivity */);
@@ -381,7 +381,7 @@ public class RecentsAnimationTest extends ActivityTestsBase {
Intent recentsIntent = new Intent();
recentsIntent.setComponent(recentsComponent);
- mService.startRecentsActivity(recentsIntent, null /* assistDataReceiver */,
+ mAtm.startRecentsActivity(recentsIntent, null /* assistDataReceiver */,
mock(IRecentsAnimationRunner.class));
return recentsAnimation[0];
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/RootActivityContainerTests.java b/services/tests/wmtests/src/com/android/server/wm/RootActivityContainerTests.java
index 74be2c979668..1ec9bd24ad59 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RootActivityContainerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RootActivityContainerTests.java
@@ -89,14 +89,14 @@ import java.util.function.Consumer;
@MediumTest
@Presubmit
@RunWith(WindowTestRunner.class)
-public class RootActivityContainerTests extends ActivityTestsBase {
+public class RootActivityContainerTests extends WindowTestsBase {
private Task mFullscreenStack;
@Before
public void setUp() throws Exception {
mFullscreenStack = mRootWindowContainer.getDefaultTaskDisplayArea().createStack(
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
- doNothing().when(mService).updateSleepIfNeededLocked();
+ doNothing().when(mAtm).updateSleepIfNeededLocked();
}
/**
@@ -117,11 +117,11 @@ public class RootActivityContainerTests extends ActivityTestsBase {
*/
@Test
public void testReplacingTaskInPinnedStack() {
- final ActivityRecord firstActivity = new ActivityBuilder(mService).setCreateTask(true)
+ final ActivityRecord firstActivity = new ActivityBuilder(mAtm).setCreateTask(true)
.setStack(mFullscreenStack).build();
final Task task = firstActivity.getTask();
- final ActivityRecord secondActivity = new ActivityBuilder(mService).setTask(task)
+ final ActivityRecord secondActivity = new ActivityBuilder(mAtm).setTask(task)
.setStack(mFullscreenStack).build();
mFullscreenStack.moveToFront("testReplacingTaskInPinnedStack");
@@ -152,11 +152,11 @@ public class RootActivityContainerTests extends ActivityTestsBase {
@Test
public void testMovingBottomMostStackActivityToPinnedStack() {
- final ActivityRecord firstActivity = new ActivityBuilder(mService).setCreateTask(true)
+ final ActivityRecord firstActivity = new ActivityBuilder(mAtm).setCreateTask(true)
.setStack(mFullscreenStack).build();
final Task task = firstActivity.getTask();
- final ActivityRecord secondActivity = new ActivityBuilder(mService).setTask(task)
+ final ActivityRecord secondActivity = new ActivityBuilder(mAtm).setTask(task)
.setStack(mFullscreenStack).build();
mFullscreenStack.moveTaskToBack(task);
@@ -252,7 +252,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
@Test
public void testAwakeFromSleepingWithAppConfiguration() {
final DisplayContent display = mRootWindowContainer.getDefaultDisplay();
- final ActivityRecord activity = new ActivityBuilder(mService).setCreateTask(true).build();
+ final ActivityRecord activity = new ActivityBuilder(mAtm).setCreateTask(true).build();
activity.moveFocusableActivityToTop("test");
assertTrue(activity.getStack().isFocusedStackOnDisplay());
ActivityRecordTests.setRotatedScreenOrientationSilently(activity);
@@ -264,13 +264,13 @@ public class RootActivityContainerTests extends ActivityTestsBase {
// Assume the activity was shown in different orientation. For example, the top activity is
// landscape and the portrait lockscreen is shown.
activity.setLastReportedConfiguration(
- new MergedConfiguration(mService.getGlobalConfiguration(), rotatedConfig));
+ new MergedConfiguration(mAtm.getGlobalConfiguration(), rotatedConfig));
activity.setState(ActivityState.STOPPED, "sleep");
display.setIsSleeping(true);
doReturn(false).when(display).shouldSleep();
// Allow to resume when awaking.
- setBooted(mService);
+ setBooted(mAtm);
mRootWindowContainer.applySleepTokens(true);
// The display orientation should be changed by the activity so there is no relaunch.
@@ -288,7 +288,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
final int originalStackCount = defaultTaskDisplayArea.getStackCount();
final Task stack = defaultTaskDisplayArea.createStack(
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, false /* onTop */);
- final ActivityRecord firstActivity = new ActivityBuilder(mService).setCreateTask(true)
+ final ActivityRecord firstActivity = new ActivityBuilder(mAtm).setCreateTask(true)
.setStack(stack).build();
assertEquals(originalStackCount + 1, defaultTaskDisplayArea.getStackCount());
@@ -312,16 +312,16 @@ public class RootActivityContainerTests extends ActivityTestsBase {
final int originalStackCount = defaultTaskDisplayArea.getStackCount();
final Task stack = defaultTaskDisplayArea.createStack(
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, false /* onTop */);
- final ActivityRecord firstActivity = new ActivityBuilder(mService).setCreateTask(true)
+ final ActivityRecord firstActivity = new ActivityBuilder(mAtm).setCreateTask(true)
.setStack(stack).build();
assertEquals(originalStackCount + 1, defaultTaskDisplayArea.getStackCount());
final DisplayContent dc = defaultTaskDisplayArea.getDisplayContent();
- final TaskDisplayArea secondTaskDisplayArea = WindowTestsBase.createTaskDisplayArea(dc,
- mRootWindowContainer.mWmService, "TestTaskDisplayArea", FEATURE_VENDOR_FIRST);
+ final TaskDisplayArea secondTaskDisplayArea = WindowTestsBase.createTaskDisplayArea(
+ dc, mRootWindowContainer.mWmService, "TestTaskDisplayArea", FEATURE_VENDOR_FIRST);
final Task secondStack = secondTaskDisplayArea.createStack(
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, false /* onTop */);
- new ActivityBuilder(mService).setCreateTask(true).setStack(secondStack)
+ new ActivityBuilder(mAtm).setCreateTask(true).setStack(secondStack)
.setUseProcess(firstActivity.app).build();
assertEquals(1, secondTaskDisplayArea.getStackCount());
@@ -340,7 +340,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
.getDefaultTaskDisplayArea();
final Task stack = defaultTaskDisplayArea.createStack(
WINDOWING_MODE_SPLIT_SCREEN_PRIMARY, ACTIVITY_TYPE_STANDARD, true /* onTop */);
- final ActivityRecord activity = new ActivityBuilder(mService).setCreateTask(true)
+ final ActivityRecord activity = new ActivityBuilder(mAtm).setCreateTask(true)
.setStack(stack).build();
// Created stacks are focusable by default.
@@ -354,7 +354,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
final Task pinnedStack = defaultTaskDisplayArea.createStack(
WINDOWING_MODE_PINNED, ACTIVITY_TYPE_STANDARD, true /* onTop */);
- final ActivityRecord pinnedActivity = new ActivityBuilder(mService).setCreateTask(true)
+ final ActivityRecord pinnedActivity = new ActivityBuilder(mAtm).setCreateTask(true)
.setStack(pinnedStack).build();
// We should not be focusable when in pinned mode
@@ -385,7 +385,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
.createStack(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY, ACTIVITY_TYPE_STANDARD,
true /* onTop */);
final Task task = new TaskBuilder(mSupervisor).setStack(primaryStack).build();
- final ActivityRecord r = new ActivityBuilder(mService).setTask(task).build();
+ final ActivityRecord r = new ActivityBuilder(mAtm).setTask(task).build();
// Find a launch stack for the top activity in split-screen primary, while requesting
// split-screen secondary.
@@ -439,7 +439,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
final Task stack = secondDisplay.getDefaultTaskDisplayArea()
.createStack(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_RECENTS, true /* onTop */);
final Task task = new TaskBuilder(mSupervisor).setStack(stack).build();
- new ActivityBuilder(mService).setTask(task).build();
+ new ActivityBuilder(mAtm).setTask(task).build();
final String reason = "findTaskToMoveToFront";
mSupervisor.findTaskToMoveToFront(targetTask, 0, ActivityOptions.makeBasic(), reason,
@@ -459,7 +459,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
final Task targetStack = spy(taskDisplayArea.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, false /* onTop */));
final Task task = new TaskBuilder(mSupervisor).setStack(targetStack).build();
- final ActivityRecord activity = new ActivityBuilder(mService).setTask(task).build();
+ final ActivityRecord activity = new ActivityBuilder(mAtm).setTask(task).build();
taskDisplayArea.positionChildAt(POSITION_BOTTOM, targetStack, false /*includingParents*/);
// Assume the stack is not at the topmost position (e.g. behind always-on-top stacks) but it
@@ -489,7 +489,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
doReturn(true).when(mRootWindowContainer).resumeHomeActivity(any(), any(), any());
- mService.setBooted(true);
+ mAtm.setBooted(true);
// Trigger resume on all displays
mRootWindowContainer.resumeFocusedStacksTopActivities();
@@ -515,11 +515,11 @@ public class RootActivityContainerTests extends ActivityTestsBase {
final Task stack = secondDisplay.getDefaultTaskDisplayArea()
.createStack(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
final Task task = new TaskBuilder(mSupervisor).setStack(stack).build();
- new ActivityBuilder(mService).setTask(task).build();
+ new ActivityBuilder(mAtm).setTask(task).build();
doReturn(true).when(mRootWindowContainer).resumeHomeActivity(any(), any(), any());
- mService.setBooted(true);
+ mAtm.setBooted(true);
// Trigger resume on all displays
mRootWindowContainer.resumeFocusedStacksTopActivities();
@@ -539,7 +539,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
final Task targetStack = spy(taskDisplayArea.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, false /* onTop */));
final Task task = new TaskBuilder(mSupervisor).setStack(targetStack).build();
- final ActivityRecord activity = new ActivityBuilder(mService).setTask(task).build();
+ final ActivityRecord activity = new ActivityBuilder(mAtm).setTask(task).build();
activity.setState(ActivityState.RESUMED, "test");
// Assume the stack is at the topmost position
@@ -559,7 +559,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
final Task targetStack = spy(taskDisplayArea.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, false /* onTop */));
final Task task = new TaskBuilder(mSupervisor).setStack(targetStack).build();
- final ActivityRecord activity = new ActivityBuilder(mService).setTask(task).build();
+ final ActivityRecord activity = new ActivityBuilder(mAtm).setTask(task).build();
activity.setState(ActivityState.RESUMED, "test");
taskDisplayArea.positionChildAt(POSITION_BOTTOM, targetStack, false /*includingParents*/);
@@ -584,7 +584,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
// Create secondary displays.
final TestDisplayContent secondDisplay =
- new TestDisplayContent.Builder(mService, 1000, 1500)
+ new TestDisplayContent.Builder(mAtm, 1000, 1500)
.setSystemDecorations(true).build();
doReturn(true).when(mRootWindowContainer)
@@ -605,16 +605,16 @@ public class RootActivityContainerTests extends ActivityTestsBase {
@Test
public void testNotStartHomeBeforeBoot() {
final int displayId = 1;
- final boolean isBooting = mService.mAmInternal.isBooting();
- final boolean isBooted = mService.mAmInternal.isBooted();
+ final boolean isBooting = mAtm.mAmInternal.isBooting();
+ final boolean isBooted = mAtm.mAmInternal.isBooted();
try {
- mService.mAmInternal.setBooting(false);
- mService.mAmInternal.setBooted(false);
+ mAtm.mAmInternal.setBooting(false);
+ mAtm.mAmInternal.setBooted(false);
mRootWindowContainer.onDisplayAdded(displayId);
verify(mRootWindowContainer, never()).startHomeOnDisplay(anyInt(), any(), anyInt());
} finally {
- mService.mAmInternal.setBooting(isBooting);
- mService.mAmInternal.setBooted(isBooted);
+ mAtm.mAmInternal.setBooting(isBooting);
+ mAtm.mAmInternal.setBooted(isBooted);
}
}
@@ -626,7 +626,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
final ActivityInfo info = new ActivityInfo();
info.applicationInfo = new ApplicationInfo();
final WindowProcessController app = mock(WindowProcessController.class);
- doReturn(app).when(mService).getProcessController(any(), anyInt());
+ doReturn(app).when(mAtm).getProcessController(any(), anyInt());
// Can not start home if we don't want to start home while home is being instrumented.
doReturn(true).when(app).isInstrumenting();
@@ -653,7 +653,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
public void testStartSecondaryHomeOnDisplayWithUserKeyLocked() {
// Create secondary displays.
final TestDisplayContent secondDisplay =
- new TestDisplayContent.Builder(mService, 1000, 1500)
+ new TestDisplayContent.Builder(mAtm, 1000, 1500)
.setSystemDecorations(true).build();
// Use invalid user id to let StorageManager.isUserKeyUnlocked() return false.
@@ -678,7 +678,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
public void testStartSecondaryHomeOnDisplayWithoutSysDecorations() {
// Create secondary displays.
final TestDisplayContent secondDisplay =
- new TestDisplayContent.Builder(mService, 1000, 1500)
+ new TestDisplayContent.Builder(mAtm, 1000, 1500)
.setSystemDecorations(false).build();
mRootWindowContainer.startHomeOnDisplay(0 /* userId */, "testStartSecondaryHome",
@@ -712,7 +712,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
@Test
public void testResolveSecondaryHomeActivityWhenPrimaryHomeNotSet() {
// Setup: primary home not set.
- final Intent primaryHomeIntent = mService.getHomeIntent();
+ final Intent primaryHomeIntent = mAtm.getHomeIntent();
final ActivityInfo aInfoPrimary = new ActivityInfo();
aInfoPrimary.name = ResolverActivity.class.getName();
doReturn(aInfoPrimary).when(mRootWindowContainer).resolveHomeActivity(anyInt(),
@@ -740,7 +740,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
// SetUp: set secondary home and force it.
mockResolveHomeActivity(false /* primaryHome */, true /* forceSystemProvided */);
final Intent secondaryHomeIntent =
- mService.getSecondaryHomeIntent(null /* preferredPackage */);
+ mAtm.getSecondaryHomeIntent(null /* preferredPackage */);
final List<ResolveInfo> resolutions = new ArrayList<>();
final ResolveInfo resolveInfo = new ResolveInfo();
final ActivityInfo aInfoSecondary = getFakeHomeActivityInfo(false /* primaryHome*/);
@@ -855,11 +855,11 @@ public class RootActivityContainerTests extends ActivityTestsBase {
public void testGetLaunchStackWithRealCallerId() {
// Create a non-system owned virtual display.
final TestDisplayContent secondaryDisplay =
- new TestDisplayContent.Builder(mService, 1000, 1500)
+ new TestDisplayContent.Builder(mAtm, 1000, 1500)
.setType(TYPE_VIRTUAL).setOwnerUid(100).build();
// Create an activity with specify the original launch pid / uid.
- final ActivityRecord r = new ActivityBuilder(mService).setLaunchedFromPid(200)
+ final ActivityRecord r = new ActivityBuilder(mAtm).setLaunchedFromPid(200)
.setLaunchedFromUid(200).build();
// Simulate ActivityStarter to find a launch stack for requesting the activity to launch
@@ -882,12 +882,11 @@ public class RootActivityContainerTests extends ActivityTestsBase {
@Test
public void testGetValidLaunchStackOnDisplayWithCandidateRootTask() {
// Create a root task with an activity on secondary display.
- final TestDisplayContent secondaryDisplay = new TestDisplayContent.Builder(mService, 300,
+ final TestDisplayContent secondaryDisplay = new TestDisplayContent.Builder(mAtm, 300,
600).build();
- final Task task = new ActivityTestsBase.StackBuilder(mRootWindowContainer).setDisplay(
- secondaryDisplay).build();
- final ActivityRecord activity = new ActivityTestsBase.ActivityBuilder(mService)
- .setTask(task).build();
+ final Task task = new StackBuilder(mRootWindowContainer)
+ .setDisplay(secondaryDisplay).build();
+ final ActivityRecord activity = new ActivityBuilder(mAtm).setTask(task).build();
// Make sure the root task is valid and can be reused on default display.
final Task stack = mRootWindowContainer.getValidLaunchStackInTaskDisplayArea(
@@ -923,7 +922,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
DisplayContent.POSITION_TOP);
final Task stack = secondDisplay.getDefaultTaskDisplayArea()
.createStack(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
- final ActivityRecord activity = new ActivityBuilder(mService).setStack(stack).build();
+ final ActivityRecord activity = new ActivityBuilder(mAtm).setStack(stack).build();
spyOn(activity);
spyOn(stack);
@@ -946,7 +945,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
ActivityInfo targetActivityInfo = getFakeHomeActivityInfo(primaryHome);
Intent targetIntent;
if (primaryHome) {
- targetIntent = mService.getHomeIntent();
+ targetIntent = mAtm.getHomeIntent();
} else {
Resources resources = mContext.getResources();
spyOn(resources);
@@ -954,7 +953,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
com.android.internal.R.string.config_secondaryHomePackage);
doReturn(forceSystemProvided).when(resources).getBoolean(
com.android.internal.R.bool.config_useSystemProvidedLauncherForSecondary);
- targetIntent = mService.getSecondaryHomeIntent(null /* preferredPackage */);
+ targetIntent = mAtm.getSecondaryHomeIntent(null /* preferredPackage */);
}
doReturn(targetActivityInfo).when(mRootWindowContainer).resolveHomeActivity(anyInt(),
refEq(targetIntent));
@@ -965,7 +964,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
* activity info for test cases.
*/
private void mockResolveSecondaryHomeActivity() {
- final Intent secondaryHomeIntent = mService
+ final Intent secondaryHomeIntent = mAtm
.getSecondaryHomeIntent(null /* preferredPackage */);
final ActivityInfo aInfoSecondary = getFakeHomeActivityInfo(false);
doReturn(Pair.create(aInfoSecondary, secondaryHomeIntent)).when(mRootWindowContainer)
diff --git a/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java b/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java
index d9d07d9beb2b..72899e726b6e 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java
@@ -133,10 +133,10 @@ public class RootWindowContainerTests extends WindowTestsBase {
@Test
public void testFindActivityByTargetComponent() {
final ComponentName aliasComponent = ComponentName.createRelative(
- ActivityTestsBase.DEFAULT_COMPONENT_PACKAGE_NAME, ".AliasActivity");
+ DEFAULT_COMPONENT_PACKAGE_NAME, ".AliasActivity");
final ComponentName targetComponent = ComponentName.createRelative(
aliasComponent.getPackageName(), ".TargetActivity");
- final ActivityRecord activity = new ActivityTestsBase.ActivityBuilder(mWm.mAtmService)
+ final ActivityRecord activity = new ActivityBuilder(mWm.mAtmService)
.setComponent(aliasComponent)
.setTargetActivity(targetComponent.getClassName())
.setLaunchMode(ActivityInfo.LAUNCH_SINGLE_INSTANCE)
@@ -174,15 +174,13 @@ public class RootWindowContainerTests extends WindowTestsBase {
@Test
public void testForceStopPackage() {
- final Task task = new ActivityTestsBase.StackBuilder(mWm.mRoot).build();
+ final Task task = new StackBuilder(mWm.mRoot).build();
final ActivityRecord activity = task.getTopMostActivity();
final WindowProcessController wpc = activity.app;
final ActivityRecord[] activities = {
activity,
- new ActivityTestsBase.ActivityBuilder(mWm.mAtmService)
- .setStack(task).setUseProcess(wpc).build(),
- new ActivityTestsBase.ActivityBuilder(mWm.mAtmService)
- .setStack(task).setUseProcess(wpc).build()
+ new ActivityBuilder(mWm.mAtmService).setStack(task).setUseProcess(wpc).build(),
+ new ActivityBuilder(mWm.mAtmService).setStack(task).setUseProcess(wpc).build()
};
activities[0].detachFromProcess();
activities[1].finishing = true;
diff --git a/services/tests/wmtests/src/com/android/server/wm/RunningTasksTest.java b/services/tests/wmtests/src/com/android/server/wm/RunningTasksTest.java
index e51a133d5cce..341509310e26 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RunningTasksTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RunningTasksTest.java
@@ -42,7 +42,7 @@ import java.util.ArrayList;
@MediumTest
@Presubmit
@RunWith(WindowTestRunner.class)
-public class RunningTasksTest extends ActivityTestsBase {
+public class RunningTasksTest extends WindowTestsBase {
private static final ArraySet<Integer> PROFILE_IDS = new ArraySet<>();
@@ -57,7 +57,7 @@ public class RunningTasksTest extends ActivityTestsBase {
public void testCollectTasksByLastActiveTime() {
// Create a number of stacks with tasks (of incrementing active time)
final ArrayList<DisplayContent> displays = new ArrayList<>();
- final DisplayContent display = new TestDisplayContent.Builder(mService, 1000, 2500).build();
+ final DisplayContent display = new TestDisplayContent.Builder(mAtm, 1000, 2500).build();
displays.add(display);
final int numStacks = 2;
@@ -101,7 +101,7 @@ public class RunningTasksTest extends ActivityTestsBase {
@Test
public void testTaskInfo_expectNoExtras() {
- final DisplayContent display = new TestDisplayContent.Builder(mService, 1000, 2500).build();
+ final DisplayContent display = new TestDisplayContent.Builder(mAtm, 1000, 2500).build();
final int numTasks = 10;
for (int i = 0; i < numTasks; i++) {
final Task stack = new StackBuilder(mRootWindowContainer)
@@ -132,13 +132,13 @@ public class RunningTasksTest extends ActivityTestsBase {
*/
private Task createTask(Task stack, String className, int taskId,
int lastActiveTime, Bundle extras) {
- final Task task = new TaskBuilder(mService.mStackSupervisor)
+ final Task task = new TaskBuilder(mAtm.mStackSupervisor)
.setComponent(new ComponentName(mContext.getPackageName(), className))
.setTaskId(taskId)
.setStack(stack)
.build();
task.lastActiveTime = lastActiveTime;
- final ActivityRecord activity = new ActivityBuilder(mService)
+ final ActivityRecord activity = new ActivityBuilder(mAtm)
.setTask(task)
.setComponent(new ComponentName(mContext.getPackageName(), ".TaskActivity"))
.setIntentExtras(extras)
diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
index 250cf09e8547..0e1d4dc4aa0d 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
@@ -64,7 +64,7 @@ import java.util.ArrayList;
@MediumTest
@Presubmit
@RunWith(WindowTestRunner.class)
-public class SizeCompatTests extends ActivityTestsBase {
+public class SizeCompatTests extends WindowTestsBase {
private Task mStack;
private Task mTask;
private ActivityRecord mActivity;
@@ -76,7 +76,7 @@ public class SizeCompatTests extends ActivityTestsBase {
}
private void setUpDisplaySizeWithApp(int dw, int dh) {
- final TestDisplayContent.Builder builder = new TestDisplayContent.Builder(mService, dw, dh);
+ final TestDisplayContent.Builder builder = new TestDisplayContent.Builder(mAtm, dw, dh);
setUpApp(builder.build());
}
@@ -92,7 +92,7 @@ public class SizeCompatTests extends ActivityTestsBase {
final Rect originalOverrideBounds = new Rect(mActivity.getBounds());
resizeDisplay(mStack.getDisplay(), 600, 1200);
// The visible activity should recompute configuration according to the last parent bounds.
- mService.restartActivityProcessIfVisible(mActivity.appToken);
+ mAtm.restartActivityProcessIfVisible(mActivity.appToken);
assertEquals(Task.ActivityState.RESTARTING_PROCESS, mActivity.getState());
assertNotEquals(originalOverrideBounds, mActivity.getBounds());
@@ -102,7 +102,7 @@ public class SizeCompatTests extends ActivityTestsBase {
public void testKeepBoundsWhenChangingFromFreeformToFullscreen() {
removeGlobalMinSizeRestriction();
// create freeform display and a freeform app
- DisplayContent display = new TestDisplayContent.Builder(mService, 2000, 1000)
+ DisplayContent display = new TestDisplayContent.Builder(mAtm, 2000, 1000)
.setCanRotate(false)
.setWindowingMode(WindowConfiguration.WINDOWING_MODE_FREEFORM).build();
setUpApp(display);
@@ -135,7 +135,7 @@ public class SizeCompatTests extends ActivityTestsBase {
@Test
public void testFixedAspectRatioBoundsWithDecorInSquareDisplay() {
final int notchHeight = 100;
- setUpApp(new TestDisplayContent.Builder(mService, 600, 800).setNotch(notchHeight).build());
+ setUpApp(new TestDisplayContent.Builder(mAtm, 600, 800).setNotch(notchHeight).build());
// Rotation is ignored so because the display size is close to square (700/600<1.333).
assertTrue(mActivity.mDisplayContent.ignoreRotationForApps());
@@ -186,10 +186,10 @@ public class SizeCompatTests extends ActivityTestsBase {
// Make a new less-tall display with lower density
final DisplayContent newDisplay =
- new TestDisplayContent.Builder(mService, 1000, 2000)
+ new TestDisplayContent.Builder(mAtm, 1000, 2000)
.setDensityDpi(200).build();
- mActivity = new ActivityBuilder(mService)
+ mActivity = new ActivityBuilder(mAtm)
.setTask(mTask)
.setResizeMode(RESIZE_MODE_UNRESIZEABLE)
.setMaxAspectRatio(1.5f)
@@ -262,7 +262,7 @@ public class SizeCompatTests extends ActivityTestsBase {
@Test
public void testAspectRatioMatchParentBoundsAndImeAttachable() {
- setUpApp(new TestDisplayContent.Builder(mService, 1000, 2000)
+ setUpApp(new TestDisplayContent.Builder(mAtm, 1000, 2000)
.setSystemDecorations(true).build());
prepareUnresizable(2f /* maxAspect */, SCREEN_ORIENTATION_UNSPECIFIED);
assertFitted();
@@ -293,7 +293,7 @@ public class SizeCompatTests extends ActivityTestsBase {
final int origHeight = configBounds.height();
final int notchHeight = 100;
- final DisplayContent newDisplay = new TestDisplayContent.Builder(mService, 2000, 1000)
+ final DisplayContent newDisplay = new TestDisplayContent.Builder(mAtm, 2000, 1000)
.setCanRotate(false).setNotch(notchHeight).build();
// Move the non-resizable activity to the new display.
@@ -327,7 +327,7 @@ public class SizeCompatTests extends ActivityTestsBase {
public void testFixedOrientRotateCutoutDisplay() {
// Create a display with a notch/cutout
final int notchHeight = 60;
- setUpApp(new TestDisplayContent.Builder(mService, 1000, 2500)
+ setUpApp(new TestDisplayContent.Builder(mAtm, 1000, 2500)
.setNotch(notchHeight).build());
// Bounds=[0, 0 - 1000, 1460], AppBounds=[0, 60 - 1000, 1460].
prepareUnresizable(1.4f /* maxAspect */, SCREEN_ORIENTATION_PORTRAIT);
@@ -430,14 +430,14 @@ public class SizeCompatTests extends ActivityTestsBase {
// Change display density
display.mBaseDisplayDensity = (int) (0.7f * display.mBaseDisplayDensity);
display.computeScreenConfiguration(rotatedConfig);
- mService.mAmInternal = mock(ActivityManagerInternal.class);
+ mAtm.mAmInternal = mock(ActivityManagerInternal.class);
display.onRequestedOverrideConfigurationChanged(rotatedConfig);
// The override configuration should be reset and the activity's process will be killed.
assertFitted();
verify(mActivity).restartProcessIfVisible();
- waitHandlerIdle(mService.mH);
- verify(mService.mAmInternal).killProcess(
+ waitHandlerIdle(mAtm.mH);
+ verify(mAtm.mAmInternal).killProcess(
eq(mActivity.app.mName), eq(mActivity.app.mUid), anyString());
}
@@ -454,7 +454,7 @@ public class SizeCompatTests extends ActivityTestsBase {
assertFitted();
final ArrayList<IBinder> compatTokens = new ArrayList<>();
- mService.getTaskChangeNotificationController().registerTaskStackListener(
+ mAtm.getTaskChangeNotificationController().registerTaskStackListener(
new TaskStackListener() {
@Override
public void onSizeCompatModeActivityChanged(int displayId,
@@ -492,7 +492,7 @@ public class SizeCompatTests extends ActivityTestsBase {
mActivity.info.resizeMode = ActivityInfo.RESIZE_MODE_RESIZEABLE;
// Create a size compat activity on the same task.
- final ActivityRecord activity = new ActivityBuilder(mService)
+ final ActivityRecord activity = new ActivityBuilder(mAtm)
.setTask(mTask)
.setResizeMode(ActivityInfo.RESIZE_MODE_UNRESIZEABLE)
.setScreenOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
@@ -516,7 +516,7 @@ public class SizeCompatTests extends ActivityTestsBase {
final int dw = 1000;
final int dh = 2500;
final int notchHeight = 200;
- setUpApp(new TestDisplayContent.Builder(mService, dw, dh).setNotch(notchHeight).build());
+ setUpApp(new TestDisplayContent.Builder(mAtm, dw, dh).setNotch(notchHeight).build());
addStatusBar(mActivity.mDisplayContent);
mActivity.setVisible(false);
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskDisplayAreaTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskDisplayAreaTests.java
index 27a8fc3c5943..3492556b3682 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskDisplayAreaTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskDisplayAreaTests.java
@@ -219,8 +219,7 @@ public class TaskDisplayAreaTests extends WindowTestsBase {
final Task rootHomeTask = defaultTaskDisplayArea.getRootHomeTask();
rootHomeTask.mResizeMode = RESIZE_MODE_UNRESIZEABLE;
- final Task primarySplitTask =
- new ActivityTestsBase.StackBuilder(rootWindowContainer)
+ final Task primarySplitTask = new StackBuilder(rootWindowContainer)
.setTaskDisplayArea(defaultTaskDisplayArea)
.setWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY)
.setActivityType(ACTIVITY_TYPE_STANDARD)
@@ -234,7 +233,7 @@ public class TaskDisplayAreaTests extends WindowTestsBase {
ActivityRecord homeActivity = rootHomeTask.getTopNonFinishingActivity();
if (homeActivity == null) {
- homeActivity = new ActivityTestsBase.ActivityBuilder(mWm.mAtmService)
+ homeActivity = new ActivityBuilder(mWm.mAtmService)
.setStack(rootHomeTask).setCreateTask(true).build();
}
homeActivity.setVisible(false);
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java
index a048526bb068..42de5e6b429d 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java
@@ -67,7 +67,7 @@ import java.util.Locale;
@SmallTest
@Presubmit
@RunWith(WindowTestRunner.class)
-public class TaskLaunchParamsModifierTests extends ActivityTestsBase {
+public class TaskLaunchParamsModifierTests extends WindowTestsBase {
private static final Rect DISPLAY_BOUNDS = new Rect(/* left */ 0, /* top */ 0,
/* right */ 1920, /* bottom */ 1080);
private static final Rect DISPLAY_STABLE_BOUNDS = new Rect(/* left */ 100,
@@ -82,7 +82,7 @@ public class TaskLaunchParamsModifierTests extends ActivityTestsBase {
@Before
public void setUp() throws Exception {
- mActivity = new ActivityBuilder(mService).build();
+ mActivity = new ActivityBuilder(mAtm).build();
mActivity.info.applicationInfo.targetSdkVersion = Build.VERSION_CODES.N_MR1;
mActivity.info.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES;
@@ -449,7 +449,7 @@ public class TaskLaunchParamsModifierTests extends ActivityTestsBase {
@Test
public void testForceMaximizesUnresizeableApp() {
- mService.mSizeCompatFreeform = false;
+ mAtm.mSizeCompatFreeform = false;
final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
@@ -472,7 +472,7 @@ public class TaskLaunchParamsModifierTests extends ActivityTestsBase {
@Test
public void testLaunchesAppInWindowOnFreeformDisplay() {
- mService.mSizeCompatFreeform = true;
+ mAtm.mSizeCompatFreeform = true;
final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
@@ -1318,18 +1318,18 @@ public class TaskLaunchParamsModifierTests extends ActivityTestsBase {
@Test
public void testNoMultiDisplaySupports() {
- final boolean orgValue = mService.mSupportsMultiDisplay;
+ final boolean orgValue = mAtm.mSupportsMultiDisplay;
final TestDisplayContent display = createNewDisplayContent(WINDOWING_MODE_FULLSCREEN);
mCurrent.mPreferredTaskDisplayArea = display.getDefaultTaskDisplayArea();
try {
- mService.mSupportsMultiDisplay = false;
+ mAtm.mSupportsMultiDisplay = false;
assertEquals(RESULT_CONTINUE, mTarget.onCalculate(/* task */ null, /* layout */ null,
mActivity, /* source */ null, /* options */ null, mCurrent, mResult));
assertEquals(mRootWindowContainer.getDefaultTaskDisplayArea(),
mResult.mPreferredTaskDisplayArea);
} finally {
- mService.mSupportsMultiDisplay = orgValue;
+ mAtm.mSupportsMultiDisplay = orgValue;
}
}
@@ -1351,7 +1351,7 @@ public class TaskLaunchParamsModifierTests extends ActivityTestsBase {
private ActivityRecord createSourceActivity(TestDisplayContent display) {
final Task stack = display.getDefaultTaskDisplayArea()
.createStack(display.getWindowingMode(), ACTIVITY_TYPE_STANDARD, true);
- return new ActivityBuilder(mService).setStack(stack).setCreateTask(true).build();
+ return new ActivityBuilder(mAtm).setStack(stack).setCreateTask(true).build();
}
private void addFreeformTaskTo(TestDisplayContent display, Rect bounds) {
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskPositionerTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskPositionerTests.java
index 0db3f94d1fc3..27cae2fc1a4c 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskPositionerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskPositionerTests.java
@@ -77,7 +77,7 @@ public class TaskPositionerTests extends WindowTestsBase {
removeGlobalMinSizeRestriction();
final Task stack = createTaskStackOnDisplay(mDisplayContent);
- final ActivityRecord activity = new ActivityTestsBase.ActivityBuilder(stack.mAtmService)
+ final ActivityRecord activity = new ActivityBuilder(stack.mAtmService)
.setStack(stack)
// In real case, there is no additional level for freeform mode.
.setCreateTask(false)
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java
index bf76c8ee5f0a..fc54e1de888f 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java
@@ -95,7 +95,7 @@ import java.io.Reader;
@MediumTest
@Presubmit
@RunWith(WindowTestRunner.class)
-public class TaskRecordTests extends ActivityTestsBase {
+public class TaskRecordTests extends WindowTestsBase {
private static final String TASK_TAG = "task";
@@ -172,7 +172,7 @@ public class TaskRecordTests extends ActivityTestsBase {
@Test
public void testFitWithinBounds() {
final Rect parentBounds = new Rect(10, 10, 200, 200);
- TaskDisplayArea taskDisplayArea = mService.mRootWindowContainer.getDefaultTaskDisplayArea();
+ TaskDisplayArea taskDisplayArea = mAtm.mRootWindowContainer.getDefaultTaskDisplayArea();
Task stack = taskDisplayArea.createStack(WINDOWING_MODE_FREEFORM,
ACTIVITY_TYPE_STANDARD, true /* onTop */);
Task task = new TaskBuilder(mSupervisor).setStack(stack).build();
@@ -210,7 +210,7 @@ public class TaskRecordTests extends ActivityTestsBase {
/** Tests that the task bounds adjust properly to changes between FULLSCREEN and FREEFORM */
@Test
public void testBoundsOnModeChangeFreeformToFullscreen() {
- DisplayContent display = mService.mRootWindowContainer.getDefaultDisplay();
+ DisplayContent display = mAtm.mRootWindowContainer.getDefaultDisplay();
Task stack = new StackBuilder(mRootWindowContainer).setDisplay(display)
.setWindowingMode(WINDOWING_MODE_FREEFORM).build();
Task task = stack.getBottomMostTask();
@@ -243,7 +243,7 @@ public class TaskRecordTests extends ActivityTestsBase {
public void testFullscreenBoundsForcedOrientation() {
final Rect fullScreenBounds = new Rect(0, 0, 1920, 1080);
final Rect fullScreenBoundsPort = new Rect(0, 0, 1080, 1920);
- final DisplayContent display = new TestDisplayContent.Builder(mService,
+ final DisplayContent display = new TestDisplayContent.Builder(mAtm,
fullScreenBounds.width(), fullScreenBounds.height()).setCanRotate(false).build();
assertTrue(mRootWindowContainer.getDisplayContent(display.mDisplayId) != null);
// Fix the display orientation to landscape which is the natural rotation (0) for the test
@@ -267,7 +267,7 @@ public class TaskRecordTests extends ActivityTestsBase {
assertEquals(fullScreenBounds.height(), task.getBounds().height());
// Top activity gets used
- ActivityRecord top = new ActivityBuilder(mService).setTask(task).setStack(stack).build();
+ ActivityRecord top = new ActivityBuilder(mAtm).setTask(task).setStack(stack).build();
assertEquals(top, task.getTopNonFinishingActivity());
top.setRequestedOrientation(SCREEN_ORIENTATION_LANDSCAPE);
assertThat(task.getBounds().width()).isGreaterThan(task.getBounds().height());
@@ -307,7 +307,7 @@ public class TaskRecordTests extends ActivityTestsBase {
public void testIgnoresForcedOrientationWhenParentHandles() {
final Rect fullScreenBounds = new Rect(0, 0, 1920, 1080);
DisplayContent display = new TestDisplayContent.Builder(
- mService, fullScreenBounds.width(), fullScreenBounds.height()).build();
+ mAtm, fullScreenBounds.width(), fullScreenBounds.height()).build();
display.getRequestedOverrideConfiguration().orientation =
Configuration.ORIENTATION_LANDSCAPE;
@@ -339,7 +339,7 @@ public class TaskRecordTests extends ActivityTestsBase {
public void testComputeConfigResourceOverrides() {
final Rect fullScreenBounds = new Rect(0, 0, 1080, 1920);
TestDisplayContent display = new TestDisplayContent.Builder(
- mService, fullScreenBounds.width(), fullScreenBounds.height()).build();
+ mAtm, fullScreenBounds.width(), fullScreenBounds.height()).build();
final Task task = new TaskBuilder(mSupervisor).setDisplay(display).build();
final Configuration inOutConfig = new Configuration();
final Configuration parentConfig = new Configuration();
@@ -438,11 +438,11 @@ public class TaskRecordTests extends ActivityTestsBase {
@Test
public void testInsetDisregardedWhenFreeformOverlapsNavBar() {
- TaskDisplayArea taskDisplayArea = mService.mRootWindowContainer.getDefaultTaskDisplayArea();
+ TaskDisplayArea taskDisplayArea = mAtm.mRootWindowContainer.getDefaultTaskDisplayArea();
Task stack = taskDisplayArea.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, true /* onTop */);
DisplayInfo displayInfo = new DisplayInfo();
- mService.mContext.getDisplay().getDisplayInfo(displayInfo);
+ mAtm.mContext.getDisplay().getDisplayInfo(displayInfo);
final int displayHeight = displayInfo.logicalHeight;
final Task task = new TaskBuilder(mSupervisor).setStack(stack).build();
final Configuration inOutConfig = new Configuration();
@@ -514,23 +514,23 @@ public class TaskRecordTests extends ActivityTestsBase {
info.packageName = DEFAULT_COMPONENT_PACKAGE_NAME;
info.targetActivity = targetClassName;
- final Task task = new Task(mService, 1 /* taskId */, info, intent,
+ final Task task = new Task(mAtm, 1 /* taskId */, info, intent,
null /* voiceSession */, null /* voiceInteractor */, null /* taskDescriptor */,
null /*stack*/);
assertEquals("The alias activity component should be saved in task intent.", aliasClassName,
task.intent.getComponent().getClassName());
- ActivityRecord aliasActivity = new ActivityBuilder(mService).setComponent(
+ ActivityRecord aliasActivity = new ActivityBuilder(mAtm).setComponent(
aliasComponent).setTargetActivity(targetClassName).build();
assertEquals("Should be the same intent filter.", true,
task.isSameIntentFilter(aliasActivity));
- ActivityRecord targetActivity = new ActivityBuilder(mService).setComponent(
+ ActivityRecord targetActivity = new ActivityBuilder(mAtm).setComponent(
targetComponent).build();
assertEquals("Should be the same intent filter.", true,
task.isSameIntentFilter(targetActivity));
- ActivityRecord defaultActivity = new ActivityBuilder(mService).build();
+ ActivityRecord defaultActivity = new ActivityBuilder(mAtm).build();
assertEquals("Should not be the same intent filter.", false,
task.isSameIntentFilter(defaultActivity));
}
@@ -540,7 +540,7 @@ public class TaskRecordTests extends ActivityTestsBase {
public void testFindRootIndex() {
final Task task = getTestTask();
// Add an extra activity on top of the root one
- new ActivityBuilder(mService).setTask(task).build();
+ new ActivityBuilder(mAtm).setTask(task).build();
assertEquals("The root activity in the task must be reported.", task.getChildAt(0),
task.getRootActivity(
@@ -557,9 +557,9 @@ public class TaskRecordTests extends ActivityTestsBase {
// Add extra two activities and mark the two on the bottom as finishing.
final ActivityRecord activity0 = task.getBottomMostActivity();
activity0.finishing = true;
- final ActivityRecord activity1 = new ActivityBuilder(mService).setTask(task).build();
+ final ActivityRecord activity1 = new ActivityBuilder(mAtm).setTask(task).build();
activity1.finishing = true;
- new ActivityBuilder(mService).setTask(task).build();
+ new ActivityBuilder(mAtm).setTask(task).build();
assertEquals("The first non-finishing activity in the task must be reported.",
task.getChildAt(2), task.getRootActivity(
@@ -574,7 +574,7 @@ public class TaskRecordTests extends ActivityTestsBase {
public void testFindRootIndex_effectiveRoot() {
final Task task = getTestTask();
// Add an extra activity on top of the root one
- new ActivityBuilder(mService).setTask(task).build();
+ new ActivityBuilder(mAtm).setTask(task).build();
assertEquals("The root activity in the task must be reported.",
task.getChildAt(0), task.getRootActivity(
@@ -592,9 +592,9 @@ public class TaskRecordTests extends ActivityTestsBase {
// one above as finishing.
final ActivityRecord activity0 = task.getBottomMostActivity();
activity0.info.flags |= FLAG_RELINQUISH_TASK_IDENTITY;
- final ActivityRecord activity1 = new ActivityBuilder(mService).setTask(task).build();
+ final ActivityRecord activity1 = new ActivityBuilder(mAtm).setTask(task).build();
activity1.finishing = true;
- new ActivityBuilder(mService).setTask(task).build();
+ new ActivityBuilder(mAtm).setTask(task).build();
assertEquals("The first non-finishing activity and non-relinquishing task identity "
+ "must be reported.", task.getChildAt(2), task.getRootActivity(
@@ -626,7 +626,7 @@ public class TaskRecordTests extends ActivityTestsBase {
// Set relinquishTaskIdentity for all activities in the task
final ActivityRecord activity0 = task.getBottomMostActivity();
activity0.info.flags |= FLAG_RELINQUISH_TASK_IDENTITY;
- final ActivityRecord activity1 = new ActivityBuilder(mService).setTask(task).build();
+ final ActivityRecord activity1 = new ActivityBuilder(mAtm).setTask(task).build();
activity1.info.flags |= FLAG_RELINQUISH_TASK_IDENTITY;
assertEquals("The topmost activity in the task must be reported.",
@@ -639,7 +639,7 @@ public class TaskRecordTests extends ActivityTestsBase {
public void testGetRootActivity() {
final Task task = getTestTask();
// Add an extra activity on top of the root one
- new ActivityBuilder(mService).setTask(task).build();
+ new ActivityBuilder(mAtm).setTask(task).build();
assertEquals("The root activity in the task must be reported.",
task.getBottomMostActivity(), task.getRootActivity());
@@ -652,7 +652,7 @@ public class TaskRecordTests extends ActivityTestsBase {
public void testGetRootActivity_finishing() {
final Task task = getTestTask();
// Add an extra activity on top of the root one
- new ActivityBuilder(mService).setTask(task).build();
+ new ActivityBuilder(mAtm).setTask(task).build();
// Mark the root as finishing
task.getBottomMostActivity().finishing = true;
@@ -670,7 +670,7 @@ public class TaskRecordTests extends ActivityTestsBase {
final ActivityRecord activity0 = task.getBottomMostActivity();
activity0.info.flags |= FLAG_RELINQUISH_TASK_IDENTITY;
// Add an extra activity on top of the root one.
- new ActivityBuilder(mService).setTask(task).build();
+ new ActivityBuilder(mAtm).setTask(task).build();
assertEquals("The root activity in the task must be reported.",
task.getBottomMostActivity(), task.getRootActivity());
@@ -687,7 +687,7 @@ public class TaskRecordTests extends ActivityTestsBase {
final ActivityRecord activity0 = task.getBottomMostActivity();
activity0.finishing = true;
// Add an extra activity on top of the root one and mark it as finishing
- final ActivityRecord activity1 = new ActivityBuilder(mService).setTask(task).build();
+ final ActivityRecord activity1 = new ActivityBuilder(mAtm).setTask(task).build();
activity1.finishing = true;
assertNull("No activity must be reported if all are finishing", task.getRootActivity());
@@ -703,7 +703,7 @@ public class TaskRecordTests extends ActivityTestsBase {
final ActivityRecord activity0 = task.getBottomMostActivity();
activity0.finishing = true;
// Add an extra activity on top of the root one.
- final ActivityRecord activity1 = new ActivityBuilder(mService).setTask(task).build();
+ final ActivityRecord activity1 = new ActivityBuilder(mAtm).setTask(task).build();
assertFalse("Finishing activity must not be the root of task", activity0.isRootOfTask());
assertTrue("Non-finishing activity must be the root of task", activity1.isRootOfTask());
@@ -720,7 +720,7 @@ public class TaskRecordTests extends ActivityTestsBase {
final ActivityRecord activity0 = task.getBottomMostActivity();
activity0.finishing = true;
// Add an extra activity on top of the root one and mark it as finishing
- final ActivityRecord activity1 = new ActivityBuilder(mService).setTask(task).build();
+ final ActivityRecord activity1 = new ActivityBuilder(mAtm).setTask(task).build();
activity1.finishing = true;
assertTrue("Bottom activity must be the root of task", activity0.isRootOfTask());
@@ -756,9 +756,9 @@ public class TaskRecordTests extends ActivityTestsBase {
final ActivityRecord activity0 = task.getBottomMostActivity();
activity0.finishing = true;
// Add an extra activity on top - this will be the new root
- final ActivityRecord activity1 = new ActivityBuilder(mService).setTask(task).build();
+ final ActivityRecord activity1 = new ActivityBuilder(mAtm).setTask(task).build();
// Add one more on top
- final ActivityRecord activity2 = new ActivityBuilder(mService).setTask(task).build();
+ final ActivityRecord activity2 = new ActivityBuilder(mAtm).setTask(task).build();
assertEquals(task.mTaskId,
ActivityRecord.getTaskForActivityLocked(activity0.appToken, true /* onlyRoot */));
@@ -779,9 +779,9 @@ public class TaskRecordTests extends ActivityTestsBase {
final ActivityRecord activity0 = task.getBottomMostActivity();
activity0.info.flags |= FLAG_RELINQUISH_TASK_IDENTITY;
// Add an extra activity on top - this will be the new root
- final ActivityRecord activity1 = new ActivityBuilder(mService).setTask(task).build();
+ final ActivityRecord activity1 = new ActivityBuilder(mAtm).setTask(task).build();
// Add one more on top
- final ActivityRecord activity2 = new ActivityBuilder(mService).setTask(task).build();
+ final ActivityRecord activity2 = new ActivityBuilder(mAtm).setTask(task).build();
assertEquals(task.mTaskId,
ActivityRecord.getTaskForActivityLocked(activity0.appToken, true /* onlyRoot */));
@@ -803,11 +803,11 @@ public class TaskRecordTests extends ActivityTestsBase {
activity0.finishing = true;
// Add an extra activity on top of the root one and make it relinquish task identity
- final ActivityRecord activity1 = new ActivityBuilder(mService).setTask(task).build();
+ final ActivityRecord activity1 = new ActivityBuilder(mAtm).setTask(task).build();
activity1.info.flags |= FLAG_RELINQUISH_TASK_IDENTITY;
// Add one more activity on top
- final ActivityRecord activity2 = new ActivityBuilder(mService).setTask(task).build();
+ final ActivityRecord activity2 = new ActivityBuilder(mAtm).setTask(task).build();
assertEquals(task.mTaskId,
ActivityRecord.getTaskForActivityLocked(activity0.appToken, false /* onlyRoot */));
@@ -843,7 +843,7 @@ public class TaskRecordTests extends ActivityTestsBase {
// Mark the bottom-most activity as finishing.
activity0.finishing = true;
// Add an extra activity on top of the root one
- final ActivityRecord activity1 = new ActivityBuilder(mService).setTask(task).build();
+ final ActivityRecord activity1 = new ActivityBuilder(mAtm).setTask(task).build();
spyOn(task);
task.updateEffectiveIntent();
@@ -863,7 +863,7 @@ public class TaskRecordTests extends ActivityTestsBase {
// Mark the bottom-most activity as finishing.
activity0.finishing = true;
// Add an extra activity on top of the root one and make it relinquish task identity
- final ActivityRecord activity1 = new ActivityBuilder(mService).setTask(task).build();
+ final ActivityRecord activity1 = new ActivityBuilder(mAtm).setTask(task).build();
activity1.finishing = true;
// Task must still update the intent using the root activity (preserving legacy behavior).
@@ -874,7 +874,7 @@ public class TaskRecordTests extends ActivityTestsBase {
@Test
public void testSaveLaunchingStateWhenConfigurationChanged() {
- LaunchParamsPersister persister = mService.mStackSupervisor.mLaunchParamsPersister;
+ LaunchParamsPersister persister = mAtm.mStackSupervisor.mLaunchParamsPersister;
spyOn(persister);
final Task task = getTestTask();
@@ -890,7 +890,7 @@ public class TaskRecordTests extends ActivityTestsBase {
@Test
public void testSaveLaunchingStateWhenClearingParent() {
- LaunchParamsPersister persister = mService.mStackSupervisor.mLaunchParamsPersister;
+ LaunchParamsPersister persister = mAtm.mStackSupervisor.mLaunchParamsPersister;
spyOn(persister);
final Task task = getTestTask();
@@ -915,7 +915,7 @@ public class TaskRecordTests extends ActivityTestsBase {
@Test
public void testNotSaveLaunchingStateNonFreeformDisplay() {
- LaunchParamsPersister persister = mService.mStackSupervisor.mLaunchParamsPersister;
+ LaunchParamsPersister persister = mAtm.mStackSupervisor.mLaunchParamsPersister;
spyOn(persister);
final Task task = getTestTask();
@@ -930,7 +930,7 @@ public class TaskRecordTests extends ActivityTestsBase {
@Test
public void testNotSaveLaunchingStateWhenNotFullscreenOrFreeformWindow() {
- LaunchParamsPersister persister = mService.mStackSupervisor.mLaunchParamsPersister;
+ LaunchParamsPersister persister = mAtm.mStackSupervisor.mLaunchParamsPersister;
spyOn(persister);
final Task task = getTestTask();
@@ -983,7 +983,7 @@ public class TaskRecordTests extends ActivityTestsBase {
private void testStackBoundsConfiguration(int windowingMode, Rect parentBounds, Rect bounds,
Rect expectedConfigBounds) {
- TaskDisplayArea taskDisplayArea = mService.mRootWindowContainer.getDefaultTaskDisplayArea();
+ TaskDisplayArea taskDisplayArea = mAtm.mRootWindowContainer.getDefaultTaskDisplayArea();
Task stack = taskDisplayArea.createStack(windowingMode, ACTIVITY_TYPE_STANDARD,
true /* onTop */);
Task task = new TaskBuilder(mSupervisor).setStack(stack).build();
@@ -1019,12 +1019,12 @@ public class TaskRecordTests extends ActivityTestsBase {
parser.setInput(reader);
assertEquals(XmlPullParser.START_TAG, parser.next());
assertEquals(TASK_TAG, parser.getName());
- return Task.restoreFromXml(parser, mService.mStackSupervisor);
+ return Task.restoreFromXml(parser, mAtm.mStackSupervisor);
}
}
private Task createTask(int taskId) {
- return new Task(mService, taskId, new Intent(), null, null, null,
+ return new Task(mAtm, taskId, new Intent(), null, null, null,
ActivityBuilder.getDefaultComponent(), null, false, false, false, 0, 10050, null,
0, false, null, 0, 0, 0, 0, null, null, 0, false, false, false, 0,
0, null /*ActivityInfo*/, null /*_voiceSession*/, null /*_voiceInteractor*/,
diff --git a/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java
index 573e37a2d6b3..ed9e2707ae39 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java
@@ -295,7 +295,7 @@ public class WallpaperControllerTests extends WindowTestsBase {
}
private WindowState createWallpaperTargetWindow(DisplayContent dc) {
- final ActivityRecord homeActivity = new ActivityTestsBase.ActivityBuilder(mWm.mAtmService)
+ final ActivityRecord homeActivity = new ActivityBuilder(mWm.mAtmService)
.setStack(dc.getDefaultTaskDisplayArea().getRootHomeTask())
.setCreateTask(true)
.build();
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java
index 3ebc28886377..8ac44f2afcfd 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java
@@ -830,7 +830,7 @@ public class WindowContainerTests extends WindowTestsBase {
final DisplayContent displayContent = createNewDisplay();
// Do not reparent activity to default display when removing the display.
doReturn(true).when(displayContent).shouldDestroyContentOnRemove();
- final ActivityRecord r = new ActivityTestsBase.StackBuilder(mWm.mRoot)
+ final ActivityRecord r = new StackBuilder(mWm.mRoot)
.setDisplay(displayContent).build().getTopMostActivity();
// Add a window and make the activity animating so the removal of activity is deferred.
createWindow(null, TYPE_BASE_APPLICATION, r, "win");
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java
index 800a5d42ce09..8cfa4f00c8b6 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java
@@ -321,7 +321,7 @@ public class WindowOrganizerTests extends WindowTestsBase {
@Test
public void testTaskTransaction() {
removeGlobalMinSizeRestriction();
- final Task stack = new ActivityTestsBase.StackBuilder(mWm.mRoot)
+ final Task stack = new StackBuilder(mWm.mRoot)
.setWindowingMode(WINDOWING_MODE_FREEFORM).build();
final Task task = stack.getTopMostTask();
testTransaction(task);
@@ -330,7 +330,7 @@ public class WindowOrganizerTests extends WindowTestsBase {
@Test
public void testStackTransaction() {
removeGlobalMinSizeRestriction();
- final Task stack = new ActivityTestsBase.StackBuilder(mWm.mRoot)
+ final Task stack = new StackBuilder(mWm.mRoot)
.setWindowingMode(WINDOWING_MODE_FREEFORM).build();
StackInfo info =
mWm.mAtmService.getStackInfo(WINDOWING_MODE_FREEFORM, ACTIVITY_TYPE_STANDARD);
@@ -355,7 +355,7 @@ public class WindowOrganizerTests extends WindowTestsBase {
@Test
public void testSetWindowingMode() {
- final Task stack = new ActivityTestsBase.StackBuilder(mWm.mRoot)
+ final Task stack = new StackBuilder(mWm.mRoot)
.setWindowingMode(WINDOWING_MODE_FREEFORM).build();
testSetWindowingMode(stack);
@@ -389,7 +389,7 @@ public class WindowOrganizerTests extends WindowTestsBase {
@Test
public void testContainerFocusableChanges() {
removeGlobalMinSizeRestriction();
- final Task stack = new ActivityTestsBase.StackBuilder(mWm.mRoot)
+ final Task stack = new StackBuilder(mWm.mRoot)
.setWindowingMode(WINDOWING_MODE_FREEFORM).build();
final Task task = stack.getTopMostTask();
WindowContainerTransaction t = new WindowContainerTransaction();
@@ -405,7 +405,7 @@ public class WindowOrganizerTests extends WindowTestsBase {
@Test
public void testContainerHiddenChanges() {
removeGlobalMinSizeRestriction();
- final Task stack = new ActivityTestsBase.StackBuilder(mWm.mRoot)
+ final Task stack = new StackBuilder(mWm.mRoot)
.setWindowingMode(WINDOWING_MODE_FREEFORM).build();
WindowContainerTransaction t = new WindowContainerTransaction();
assertTrue(stack.shouldBeVisible(null));
@@ -420,7 +420,7 @@ public class WindowOrganizerTests extends WindowTestsBase {
@Test
public void testOverrideConfigSize() {
removeGlobalMinSizeRestriction();
- final Task stack = new ActivityTestsBase.StackBuilder(mWm.mRoot)
+ final Task stack = new StackBuilder(mWm.mRoot)
.setWindowingMode(WINDOWING_MODE_FREEFORM).build();
final Task task = stack.getTopMostTask();
WindowContainerTransaction t = new WindowContainerTransaction();
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerMapTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerMapTests.java
index cb7bff3a4f15..c2ee0798fd07 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerMapTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerMapTests.java
@@ -31,6 +31,7 @@ import androidx.test.filters.SmallTest;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
/**
* Tests for the {@link WindowProcessControllerMap} class.
@@ -40,7 +41,8 @@ import org.junit.Test;
*/
@SmallTest
@Presubmit
-public class WindowProcessControllerMapTests extends ActivityTestsBase {
+@RunWith(WindowTestRunner.class)
+public class WindowProcessControllerMapTests extends WindowTestsBase {
private static final int FAKE_UID1 = 666;
private static final int FAKE_UID2 = 667;
@@ -60,23 +62,23 @@ public class WindowProcessControllerMapTests extends ActivityTestsBase {
public void setUp() throws Exception {
mProcessMap = new WindowProcessControllerMap();
pid1uid1 = new WindowProcessController(
- mService, mService.mContext.getApplicationInfo(), "fakepid1fakeuid1", FAKE_UID1,
+ mAtm, mAtm.mContext.getApplicationInfo(), "fakepid1fakeuid1", FAKE_UID1,
UserHandle.getUserId(12345), mock(Object.class), mock(WindowProcessListener.class));
pid1uid1.setPid(FAKE_PID1);
pid1uid2 = new WindowProcessController(
- mService, mService.mContext.getApplicationInfo(), "fakepid1fakeuid2", FAKE_UID2,
+ mAtm, mAtm.mContext.getApplicationInfo(), "fakepid1fakeuid2", FAKE_UID2,
UserHandle.getUserId(12345), mock(Object.class), mock(WindowProcessListener.class));
pid1uid2.setPid(FAKE_PID1);
pid2uid1 = new WindowProcessController(
- mService, mService.mContext.getApplicationInfo(), "fakepid2fakeuid1", FAKE_UID1,
+ mAtm, mAtm.mContext.getApplicationInfo(), "fakepid2fakeuid1", FAKE_UID1,
UserHandle.getUserId(12345), mock(Object.class), mock(WindowProcessListener.class));
pid2uid1.setPid(FAKE_PID2);
pid3uid1 = new WindowProcessController(
- mService, mService.mContext.getApplicationInfo(), "fakepid3fakeuid1", FAKE_UID1,
+ mAtm, mAtm.mContext.getApplicationInfo(), "fakepid3fakeuid1", FAKE_UID1,
UserHandle.getUserId(12345), mock(Object.class), mock(WindowProcessListener.class));
pid3uid1.setPid(FAKE_PID3);
pid4uid2 = new WindowProcessController(
- mService, mService.mContext.getApplicationInfo(), "fakepid4fakeuid2", FAKE_UID2,
+ mAtm, mAtm.mContext.getApplicationInfo(), "fakepid4fakeuid2", FAKE_UID2,
UserHandle.getUserId(12345), mock(Object.class), mock(WindowProcessListener.class));
pid4uid2.setPid(FAKE_PID4);
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerTests.java
index cdf8eb4faf1d..2f736555ae1b 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerTests.java
@@ -50,7 +50,7 @@ import org.mockito.Mockito;
*/
@Presubmit
@RunWith(WindowTestRunner.class)
-public class WindowProcessControllerTests extends ActivityTestsBase {
+public class WindowProcessControllerTests extends WindowTestsBase {
WindowProcessController mWpc;
WindowProcessListener mMockListener;
@@ -62,7 +62,7 @@ public class WindowProcessControllerTests extends ActivityTestsBase {
ApplicationInfo info = mock(ApplicationInfo.class);
info.packageName = "test.package.name";
mWpc = new WindowProcessController(
- mService, info, null, 0, -1, null, mMockListener);
+ mAtm, info, null, 0, -1, null, mMockListener);
mWpc.setThread(mock(IApplicationThread.class));
}
@@ -108,7 +108,7 @@ public class WindowProcessControllerTests extends ActivityTestsBase {
public void testSetRunningRecentsAnimation() {
mWpc.setRunningRecentsAnimation(true);
mWpc.setRunningRecentsAnimation(false);
- waitHandlerIdle(mService.mH);
+ waitHandlerIdle(mAtm.mH);
InOrder orderVerifier = Mockito.inOrder(mMockListener);
orderVerifier.verify(mMockListener).setRunningRemoteAnimation(eq(true));
@@ -119,7 +119,7 @@ public class WindowProcessControllerTests extends ActivityTestsBase {
public void testSetRunningRemoteAnimation() {
mWpc.setRunningRemoteAnimation(true);
mWpc.setRunningRemoteAnimation(false);
- waitHandlerIdle(mService.mH);
+ waitHandlerIdle(mAtm.mH);
InOrder orderVerifier = Mockito.inOrder(mMockListener);
orderVerifier.verify(mMockListener).setRunningRemoteAnimation(eq(true));
@@ -133,7 +133,7 @@ public class WindowProcessControllerTests extends ActivityTestsBase {
mWpc.setRunningRecentsAnimation(false);
mWpc.setRunningRemoteAnimation(false);
- waitHandlerIdle(mService.mH);
+ waitHandlerIdle(mAtm.mH);
InOrder orderVerifier = Mockito.inOrder(mMockListener);
orderVerifier.verify(mMockListener, times(3)).setRunningRemoteAnimation(eq(true));
@@ -147,12 +147,12 @@ public class WindowProcessControllerTests extends ActivityTestsBase {
assertEquals(INVALID_DISPLAY, mWpc.getDisplayId());
// Register to a new display as a listener.
- final DisplayContent display = new TestDisplayContent.Builder(mService, 2000, 1000)
+ final DisplayContent display = new TestDisplayContent.Builder(mAtm, 2000, 1000)
.setDensityDpi(300).setPosition(DisplayContent.POSITION_TOP).build();
mWpc.registerDisplayConfigurationListener(display);
assertEquals(display.mDisplayId, mWpc.getDisplayId());
- final Configuration expectedConfig = mService.mRootWindowContainer.getConfiguration();
+ final Configuration expectedConfig = mAtm.mRootWindowContainer.getConfiguration();
expectedConfig.updateFrom(display.getConfiguration());
assertEquals(expectedConfig, mWpc.getConfiguration());
}
@@ -184,15 +184,15 @@ public class WindowProcessControllerTests extends ActivityTestsBase {
@Test
public void testActivityNotOverridingSystemUiProcessConfig() {
- final ComponentName systemUiServiceComponent = mService.getSysUiServiceComponentLocked();
+ final ComponentName systemUiServiceComponent = mAtm.getSysUiServiceComponentLocked();
ApplicationInfo applicationInfo = mock(ApplicationInfo.class);
applicationInfo.packageName = systemUiServiceComponent.getPackageName();
WindowProcessController wpc = new WindowProcessController(
- mService, applicationInfo, null, 0, -1, null, mMockListener);
+ mAtm, applicationInfo, null, 0, -1, null, mMockListener);
wpc.setThread(mock(IApplicationThread.class));
- final ActivityRecord activity = new ActivityBuilder(mService)
+ final ActivityRecord activity = new ActivityBuilder(mAtm)
.setCreateTask(true)
.setUseProcess(wpc)
.build();
@@ -209,7 +209,7 @@ public class WindowProcessControllerTests extends ActivityTestsBase {
// Notify WPC that this process has started an IME service.
mWpc.onServiceStarted(serviceInfo);
- final ActivityRecord activity = new ActivityBuilder(mService)
+ final ActivityRecord activity = new ActivityBuilder(mAtm)
.setCreateTask(true)
.setUseProcess(mWpc)
.build();
@@ -226,7 +226,7 @@ public class WindowProcessControllerTests extends ActivityTestsBase {
// Notify WPC that this process has started an ally service.
mWpc.onServiceStarted(serviceInfo);
- final ActivityRecord activity = new ActivityBuilder(mService)
+ final ActivityRecord activity = new ActivityBuilder(mAtm)
.setCreateTask(true)
.setUseProcess(mWpc)
.build();
@@ -243,7 +243,7 @@ public class WindowProcessControllerTests extends ActivityTestsBase {
// Notify WPC that this process has started an voice interaction service.
mWpc.onServiceStarted(serviceInfo);
- final ActivityRecord activity = new ActivityBuilder(mService)
+ final ActivityRecord activity = new ActivityBuilder(mAtm)
.setCreateTask(true)
.setUseProcess(mWpc)
.build();
@@ -254,7 +254,7 @@ public class WindowProcessControllerTests extends ActivityTestsBase {
}
private TestDisplayContent createTestDisplayContentInContainer() {
- return new TestDisplayContent.Builder(mService, 1000, 1500).build();
+ return new TestDisplayContent.Builder(mAtm, 1000, 1500).build();
}
private static void invertOrientation(Configuration config) {
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTestUtils.java b/services/tests/wmtests/src/com/android/server/wm/WindowTestUtils.java
index 2502932c5421..0180d87290a1 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowTestUtils.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowTestUtils.java
@@ -25,7 +25,7 @@ import android.os.IBinder;
import android.view.IWindow;
import android.view.WindowManager;
-import com.android.server.wm.ActivityTestsBase.ActivityBuilder;
+import com.android.server.wm.WindowTestsBase.ActivityBuilder;
/**
* A collection of static functions that provide access to WindowManager related test functionality.
@@ -34,7 +34,7 @@ class WindowTestUtils {
/** Creates a {@link Task} and adds it to the specified {@link Task}. */
static Task createTaskInStack(WindowManagerService service, Task stack, int userId) {
- final Task task = new ActivityTestsBase.TaskBuilder(stack.mStackSupervisor)
+ final Task task = new WindowTestsBase.TaskBuilder(stack.mStackSupervisor)
.setUserId(userId)
.setStack(stack)
.build();
@@ -49,7 +49,7 @@ class WindowTestUtils {
}
static ActivityRecord createTestActivityRecord(Task stack) {
- final ActivityRecord activity = new ActivityTestsBase.ActivityBuilder(stack.mAtmService)
+ final ActivityRecord activity = new ActivityBuilder(stack.mAtmService)
.setStack(stack)
.setCreateTask(true)
.build();
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java
index dc388833f338..ec19a58b17c4 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java
@@ -18,7 +18,13 @@ package com.android.server.wm;
import static android.app.AppOpsManager.OP_NONE;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
+import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
+import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
+import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
+import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
+import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE;
+import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
import static android.os.Process.SYSTEM_UID;
import static android.view.View.VISIBLE;
import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
@@ -37,22 +43,44 @@ import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
+import static com.android.server.wm.WindowContainer.POSITION_BOTTOM;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.mock;
import android.annotation.IntDef;
+import android.app.ActivityManager;
+import android.app.ActivityOptions;
+import android.app.IApplicationThread;
+import android.app.WindowConfiguration;
+import android.content.ComponentName;
+import android.content.Context;
import android.content.Intent;
+import android.content.pm.ActivityInfo;
+import android.content.pm.ApplicationInfo;
+import android.content.res.Configuration;
import android.hardware.display.DisplayManager;
+import android.os.Build;
+import android.os.Bundle;
import android.os.RemoteException;
import android.os.UserHandle;
+import android.service.voice.IVoiceInteractionSession;
import android.view.Display;
import android.view.DisplayInfo;
import android.view.IDisplayWindowInsetsController;
import android.view.IWindow;
import android.view.InsetsSourceControl;
import android.view.InsetsState;
+import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;
import android.view.View;
import android.view.WindowManager;
+import android.window.ITaskOrganizer;
+import android.window.WindowContainerToken;
import com.android.internal.util.ArrayUtils;
import com.android.server.AttributeCache;
@@ -68,11 +96,20 @@ import java.lang.annotation.Target;
/** Common base class for window manager unit test classes. */
class WindowTestsBase extends SystemServiceTestsBase {
+ final Context mContext = getInstrumentation().getTargetContext();
+
+ // Default package name
+ static final String DEFAULT_COMPONENT_PACKAGE_NAME = "com.foo";
+
+ // Default base activity name
+ private static final String DEFAULT_COMPONENT_CLASS_NAME = ".BarActivity";
+ ActivityTaskManagerService mAtm;
+ RootWindowContainer mRootWindowContainer;
+ ActivityStackSupervisor mSupervisor;
WindowManagerService mWm;
private final IWindow mIWindow = new TestIWindow();
private Session mMockSession;
- static int sNextStackId = 1000;
DisplayInfo mDisplayInfo = new DisplayInfo();
DisplayContent mDefaultDisplay;
@@ -107,6 +144,9 @@ class WindowTestsBase extends SystemServiceTestsBase {
@Before
public void setUpBase() {
+ mAtm = mSystemServicesTestRule.getActivityTaskManagerService();
+ mSupervisor = mAtm.mStackSupervisor;
+ mRootWindowContainer = mAtm.mRootWindowContainer;
mWm = mSystemServicesTestRule.getWindowManagerService();
SystemServicesTestRule.checkHoldsLock(mWm.mGlobalLock);
@@ -114,7 +154,7 @@ class WindowTestsBase extends SystemServiceTestsBase {
mTransaction = mSystemServicesTestRule.mTransaction;
mMockSession = mock(Session.class);
- getInstrumentation().getTargetContext().getSystemService(DisplayManager.class)
+ mContext.getSystemService(DisplayManager.class)
.getDisplay(Display.DEFAULT_DISPLAY).getDisplayInfo(mDisplayInfo);
// Only create an additional test display for annotated test class/method because it may
@@ -328,7 +368,7 @@ class WindowTestsBase extends SystemServiceTestsBase {
}
Task createTaskStackOnDisplay(int windowingMode, int activityType, DisplayContent dc) {
- return new ActivityTestsBase.StackBuilder(dc.mWmService.mRoot)
+ return new StackBuilder(dc.mWmService.mRoot)
.setDisplay(dc)
.setWindowingMode(windowingMode)
.setActivityType(activityType)
@@ -339,7 +379,7 @@ class WindowTestsBase extends SystemServiceTestsBase {
Task createTaskStackOnTaskDisplayArea(int windowingMode, int activityType,
TaskDisplayArea tda) {
- return new ActivityTestsBase.StackBuilder(tda.mWmService.mRoot)
+ return new StackBuilder(tda.mWmService.mRoot)
.setTaskDisplayArea(tda)
.setWindowingMode(windowingMode)
.setActivityType(activityType)
@@ -371,7 +411,7 @@ class WindowTestsBase extends SystemServiceTestsBase {
/** Creates a {@link DisplayContent} and adds it to the system. */
private DisplayContent createNewDisplay(DisplayInfo info, boolean supportIme) {
final DisplayContent display =
- new TestDisplayContent.Builder(mWm.mAtmService, info).build();
+ new TestDisplayContent.Builder(mAtm, info).build();
final DisplayContent dc = display.mDisplayContent;
// this display can show IME.
dc.mWmService.mDisplayWindowSettings.setShouldShowImeLocked(dc, supportIme);
@@ -435,11 +475,6 @@ class WindowTestsBase extends SystemServiceTestsBase {
};
}
- /** Sets the default minimum task size to 1 so that tests can use small task sizes */
- void removeGlobalMinSizeRestriction() {
- mWm.mAtmService.mRootWindowContainer.mDefaultMinSizeOfResizeableTaskDp = 1;
- }
-
/**
* Avoids rotating screen disturbed by some conditions. It is usually used for the default
* display that is not the instance of {@link TestDisplayContent} (it bypasses the conditions).
@@ -501,4 +536,523 @@ class WindowTestsBase extends SystemServiceTestsBase {
boolean addAllCommonWindows() default false;
@CommonTypes int[] addWindows() default {};
}
+
+ /** Creates and adds a {@link TestDisplayContent} to supervisor at the given position. */
+ TestDisplayContent addNewDisplayContentAt(int position) {
+ return new TestDisplayContent.Builder(mAtm, 1000, 1500).setPosition(position).build();
+ }
+
+ /** Sets the default minimum task size to 1 so that tests can use small task sizes */
+ public void removeGlobalMinSizeRestriction() {
+ mAtm.mRootWindowContainer.mDefaultMinSizeOfResizeableTaskDp = 1;
+ }
+
+ /**
+ * Builder for creating new activities.
+ */
+ protected static class ActivityBuilder {
+ // An id appended to the end of the component name to make it unique
+ private static int sCurrentActivityId = 0;
+
+ private final ActivityTaskManagerService mService;
+
+ private ComponentName mComponent;
+ private String mTargetActivity;
+ private Task mTask;
+ private String mProcessName = "name";
+ private String mAffinity;
+ private int mUid = 12345;
+ private boolean mCreateTask;
+ private Task mStack;
+ private int mActivityFlags;
+ private int mLaunchMode;
+ private int mResizeMode = RESIZE_MODE_RESIZEABLE;
+ private float mMaxAspectRatio;
+ private int mScreenOrientation = SCREEN_ORIENTATION_UNSPECIFIED;
+ private boolean mLaunchTaskBehind;
+ private int mConfigChanges;
+ private int mLaunchedFromPid;
+ private int mLaunchedFromUid;
+ private WindowProcessController mWpc;
+ private Bundle mIntentExtras;
+
+ ActivityBuilder(ActivityTaskManagerService service) {
+ mService = service;
+ }
+
+ ActivityBuilder setComponent(ComponentName component) {
+ mComponent = component;
+ return this;
+ }
+
+ ActivityBuilder setTargetActivity(String targetActivity) {
+ mTargetActivity = targetActivity;
+ return this;
+ }
+
+ ActivityBuilder setIntentExtras(Bundle extras) {
+ mIntentExtras = extras;
+ return this;
+ }
+
+ static ComponentName getDefaultComponent() {
+ return ComponentName.createRelative(DEFAULT_COMPONENT_PACKAGE_NAME,
+ DEFAULT_COMPONENT_PACKAGE_NAME);
+ }
+
+ ActivityBuilder setTask(Task task) {
+ mTask = task;
+ return this;
+ }
+
+ ActivityBuilder setActivityFlags(int flags) {
+ mActivityFlags = flags;
+ return this;
+ }
+
+ ActivityBuilder setLaunchMode(int launchMode) {
+ mLaunchMode = launchMode;
+ return this;
+ }
+
+ ActivityBuilder setStack(Task stack) {
+ mStack = stack;
+ return this;
+ }
+
+ ActivityBuilder setCreateTask(boolean createTask) {
+ mCreateTask = createTask;
+ return this;
+ }
+
+ ActivityBuilder setProcessName(String name) {
+ mProcessName = name;
+ return this;
+ }
+
+ ActivityBuilder setUid(int uid) {
+ mUid = uid;
+ return this;
+ }
+
+ ActivityBuilder setResizeMode(int resizeMode) {
+ mResizeMode = resizeMode;
+ return this;
+ }
+
+ ActivityBuilder setMaxAspectRatio(float maxAspectRatio) {
+ mMaxAspectRatio = maxAspectRatio;
+ return this;
+ }
+
+ ActivityBuilder setScreenOrientation(int screenOrientation) {
+ mScreenOrientation = screenOrientation;
+ return this;
+ }
+
+ ActivityBuilder setLaunchTaskBehind(boolean launchTaskBehind) {
+ mLaunchTaskBehind = launchTaskBehind;
+ return this;
+ }
+
+ ActivityBuilder setConfigChanges(int configChanges) {
+ mConfigChanges = configChanges;
+ return this;
+ }
+
+ ActivityBuilder setLaunchedFromPid(int pid) {
+ mLaunchedFromPid = pid;
+ return this;
+ }
+
+ ActivityBuilder setLaunchedFromUid(int uid) {
+ mLaunchedFromUid = uid;
+ return this;
+ }
+
+ ActivityBuilder setUseProcess(WindowProcessController wpc) {
+ mWpc = wpc;
+ return this;
+ }
+
+ ActivityBuilder setAffinity(String affinity) {
+ mAffinity = affinity;
+ return this;
+ }
+
+ ActivityRecord build() {
+ SystemServicesTestRule.checkHoldsLock(mService.mGlobalLock);
+ try {
+ mService.deferWindowLayout();
+ return buildInner();
+ } finally {
+ mService.continueWindowLayout();
+ }
+ }
+
+ ActivityRecord buildInner() {
+ if (mComponent == null) {
+ final int id = sCurrentActivityId++;
+ mComponent = ComponentName.createRelative(DEFAULT_COMPONENT_PACKAGE_NAME,
+ DEFAULT_COMPONENT_CLASS_NAME + id);
+ }
+
+ if (mCreateTask) {
+ mTask = new TaskBuilder(mService.mStackSupervisor)
+ .setComponent(mComponent)
+ .setStack(mStack).build();
+ } else if (mTask == null && mStack != null && DisplayContent.alwaysCreateStack(
+ mStack.getWindowingMode(), mStack.getActivityType())) {
+ // The stack can be the task root.
+ mTask = mStack;
+ }
+
+ Intent intent = new Intent();
+ intent.setComponent(mComponent);
+ if (mIntentExtras != null) {
+ intent.putExtras(mIntentExtras);
+ }
+ final ActivityInfo aInfo = new ActivityInfo();
+ aInfo.applicationInfo = new ApplicationInfo();
+ aInfo.applicationInfo.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT;
+ aInfo.applicationInfo.packageName = mComponent.getPackageName();
+ aInfo.applicationInfo.uid = mUid;
+ aInfo.processName = mProcessName;
+ aInfo.packageName = mComponent.getPackageName();
+ aInfo.name = mComponent.getClassName();
+ if (mTargetActivity != null) {
+ aInfo.targetActivity = mTargetActivity;
+ }
+ aInfo.flags |= mActivityFlags;
+ aInfo.launchMode = mLaunchMode;
+ aInfo.resizeMode = mResizeMode;
+ aInfo.maxAspectRatio = mMaxAspectRatio;
+ aInfo.screenOrientation = mScreenOrientation;
+ aInfo.configChanges |= mConfigChanges;
+ aInfo.taskAffinity = mAffinity;
+
+ ActivityOptions options = null;
+ if (mLaunchTaskBehind) {
+ options = ActivityOptions.makeTaskLaunchBehind();
+ }
+
+ final ActivityRecord activity = new ActivityRecord(mService, null /* caller */,
+ mLaunchedFromPid /* launchedFromPid */, mLaunchedFromUid /* launchedFromUid */,
+ null, null, intent, null, aInfo /*aInfo*/, new Configuration(),
+ null /* resultTo */, null /* resultWho */, 0 /* reqCode */,
+ false /*componentSpecified*/, false /* rootVoiceInteraction */,
+ mService.mStackSupervisor, options, null /* sourceRecord */);
+ spyOn(activity);
+ if (mTask != null) {
+ // fullscreen value is normally read from resources in ctor, so for testing we need
+ // to set it somewhere else since we can't mock resources.
+ doReturn(true).when(activity).occludesParent();
+ doReturn(true).when(activity).fillsParent();
+ mTask.addChild(activity);
+ // Make visible by default...
+ activity.setVisible(true);
+ }
+
+ final WindowProcessController wpc;
+ if (mWpc != null) {
+ wpc = mWpc;
+ } else {
+ wpc = new WindowProcessController(mService,
+ aInfo.applicationInfo, mProcessName, mUid,
+ UserHandle.getUserId(12345), mock(Object.class),
+ mock(WindowProcessListener.class));
+ wpc.setThread(mock(IApplicationThread.class));
+ }
+ wpc.setThread(mock(IApplicationThread.class));
+ activity.setProcess(wpc);
+ doReturn(wpc).when(mService).getProcessController(
+ activity.processName, activity.info.applicationInfo.uid);
+
+ // Resume top activities to make sure all other signals in the system are connected.
+ mService.mRootWindowContainer.resumeFocusedStacksTopActivities();
+ return activity;
+ }
+ }
+
+ /**
+ * Builder for creating new tasks.
+ */
+ protected static class TaskBuilder {
+ private final ActivityStackSupervisor mSupervisor;
+
+ private ComponentName mComponent;
+ private String mPackage;
+ private int mFlags = 0;
+ // Task id 0 is reserved in ARC for the home app.
+ private int mTaskId = SystemServicesTestRule.sNextTaskId++;
+ private int mUserId = 0;
+ private IVoiceInteractionSession mVoiceSession;
+ private boolean mCreateStack = true;
+
+ private Task mStack;
+ private TaskDisplayArea mTaskDisplayArea;
+
+ TaskBuilder(ActivityStackSupervisor supervisor) {
+ mSupervisor = supervisor;
+ }
+
+ TaskBuilder setComponent(ComponentName component) {
+ mComponent = component;
+ return this;
+ }
+
+ TaskBuilder setPackage(String packageName) {
+ mPackage = packageName;
+ return this;
+ }
+
+ /**
+ * Set to {@code true} by default, set to {@code false} to prevent the task from
+ * automatically creating a parent stack.
+ */
+ TaskBuilder setCreateStack(boolean createStack) {
+ mCreateStack = createStack;
+ return this;
+ }
+
+ TaskBuilder setVoiceSession(IVoiceInteractionSession session) {
+ mVoiceSession = session;
+ return this;
+ }
+
+ TaskBuilder setFlags(int flags) {
+ mFlags = flags;
+ return this;
+ }
+
+ TaskBuilder setTaskId(int taskId) {
+ mTaskId = taskId;
+ return this;
+ }
+
+ TaskBuilder setUserId(int userId) {
+ mUserId = userId;
+ return this;
+ }
+
+ TaskBuilder setStack(Task stack) {
+ mStack = stack;
+ return this;
+ }
+
+ TaskBuilder setDisplay(DisplayContent display) {
+ mTaskDisplayArea = display.getDefaultTaskDisplayArea();
+ return this;
+ }
+
+ Task build() {
+ SystemServicesTestRule.checkHoldsLock(mSupervisor.mService.mGlobalLock);
+
+ if (mStack == null && mCreateStack) {
+ TaskDisplayArea displayArea = mTaskDisplayArea != null ? mTaskDisplayArea
+ : mSupervisor.mRootWindowContainer.getDefaultTaskDisplayArea();
+ mStack = displayArea.createStack(
+ WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
+ spyOn(mStack);
+ }
+
+ final ActivityInfo aInfo = new ActivityInfo();
+ aInfo.applicationInfo = new ApplicationInfo();
+ aInfo.applicationInfo.packageName = mPackage;
+
+ Intent intent = new Intent();
+ if (mComponent == null) {
+ mComponent = ComponentName.createRelative(DEFAULT_COMPONENT_PACKAGE_NAME,
+ DEFAULT_COMPONENT_CLASS_NAME);
+ }
+
+ intent.setComponent(mComponent);
+ intent.setFlags(mFlags);
+
+ final Task task = new Task(mSupervisor.mService, mTaskId, aInfo,
+ intent /*intent*/, mVoiceSession, null /*_voiceInteractor*/,
+ null /*taskDescription*/, mStack);
+ spyOn(task);
+ task.mUserId = mUserId;
+
+ if (mStack != null) {
+ mStack.moveToFront("test");
+ mStack.addChild(task, true, true);
+ }
+
+ return task;
+ }
+ }
+
+ static class StackBuilder {
+ private final RootWindowContainer mRootWindowContainer;
+ private DisplayContent mDisplay;
+ private TaskDisplayArea mTaskDisplayArea;
+ private int mStackId = -1;
+ private int mWindowingMode = WINDOWING_MODE_UNDEFINED;
+ private int mActivityType = ACTIVITY_TYPE_STANDARD;
+ private boolean mOnTop = true;
+ private boolean mCreateActivity = true;
+ private ActivityInfo mInfo;
+ private Intent mIntent;
+
+ StackBuilder(RootWindowContainer root) {
+ mRootWindowContainer = root;
+ mDisplay = mRootWindowContainer.getDefaultDisplay();
+ mTaskDisplayArea = mDisplay.getDefaultTaskDisplayArea();
+ }
+
+ StackBuilder setWindowingMode(int windowingMode) {
+ mWindowingMode = windowingMode;
+ return this;
+ }
+
+ StackBuilder setActivityType(int activityType) {
+ mActivityType = activityType;
+ return this;
+ }
+
+ StackBuilder setStackId(int stackId) {
+ mStackId = stackId;
+ return this;
+ }
+
+ /**
+ * Set the parent {@link DisplayContent} and use the default task display area. Overrides
+ * the task display area, if was set before.
+ */
+ StackBuilder setDisplay(DisplayContent display) {
+ mDisplay = display;
+ mTaskDisplayArea = mDisplay.getDefaultTaskDisplayArea();
+ return this;
+ }
+
+ /** Set the parent {@link TaskDisplayArea}. Overrides the display, if was set before. */
+ StackBuilder setTaskDisplayArea(TaskDisplayArea taskDisplayArea) {
+ mTaskDisplayArea = taskDisplayArea;
+ mDisplay = mTaskDisplayArea.mDisplayContent;
+ return this;
+ }
+
+ StackBuilder setOnTop(boolean onTop) {
+ mOnTop = onTop;
+ return this;
+ }
+
+ StackBuilder setCreateActivity(boolean createActivity) {
+ mCreateActivity = createActivity;
+ return this;
+ }
+
+ StackBuilder setActivityInfo(ActivityInfo info) {
+ mInfo = info;
+ return this;
+ }
+
+ StackBuilder setIntent(Intent intent) {
+ mIntent = intent;
+ return this;
+ }
+
+ Task build() {
+ SystemServicesTestRule.checkHoldsLock(mRootWindowContainer.mWmService.mGlobalLock);
+
+ final int stackId = mStackId >= 0 ? mStackId : mTaskDisplayArea.getNextStackId();
+ final Task stack = mTaskDisplayArea.createStackUnchecked(
+ mWindowingMode, mActivityType, stackId, mOnTop, mInfo, mIntent,
+ false /* createdByOrganizer */);
+ final ActivityStackSupervisor supervisor = mRootWindowContainer.mStackSupervisor;
+
+ if (mCreateActivity) {
+ new ActivityBuilder(supervisor.mService)
+ .setCreateTask(true)
+ .setStack(stack)
+ .build();
+ if (mOnTop) {
+ // We move the task to front again in order to regain focus after activity
+ // added to the stack. Or {@link DisplayContent#mPreferredTopFocusableStack}
+ // could be other stacks (e.g. home stack).
+ stack.moveToFront("createActivityStack");
+ } else {
+ stack.moveToBack("createActivityStack", null);
+ }
+ }
+ spyOn(stack);
+
+ doNothing().when(stack).startActivityLocked(
+ any(), any(), anyBoolean(), anyBoolean(), any());
+
+ return stack;
+ }
+
+ }
+
+ static class TestSplitOrganizer extends ITaskOrganizer.Stub {
+ final ActivityTaskManagerService mService;
+ Task mPrimary;
+ Task mSecondary;
+ boolean mInSplit = false;
+ // moves everything to secondary. Most tests expect this since sysui usually does it.
+ boolean mMoveToSecondaryOnEnter = true;
+ int mDisplayId;
+ TestSplitOrganizer(ActivityTaskManagerService service, int displayId) {
+ mService = service;
+ mDisplayId = displayId;
+ mService.mTaskOrganizerController.registerTaskOrganizer(this,
+ WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
+ mService.mTaskOrganizerController.registerTaskOrganizer(this,
+ WINDOWING_MODE_SPLIT_SCREEN_SECONDARY);
+ WindowContainerToken primary = mService.mTaskOrganizerController.createRootTask(
+ displayId, WINDOWING_MODE_SPLIT_SCREEN_PRIMARY).token;
+ mPrimary = WindowContainer.fromBinder(primary.asBinder()).asTask();
+ WindowContainerToken secondary = mService.mTaskOrganizerController.createRootTask(
+ displayId, WINDOWING_MODE_SPLIT_SCREEN_SECONDARY).token;
+ mSecondary = WindowContainer.fromBinder(secondary.asBinder()).asTask();
+ }
+ TestSplitOrganizer(ActivityTaskManagerService service) {
+ this(service,
+ service.mStackSupervisor.mRootWindowContainer.getDefaultDisplay().mDisplayId);
+ }
+ public void setMoveToSecondaryOnEnter(boolean move) {
+ mMoveToSecondaryOnEnter = move;
+ }
+ @Override
+ public void onTaskAppeared(ActivityManager.RunningTaskInfo info, SurfaceControl leash) {
+ }
+ @Override
+ public void onTaskVanished(ActivityManager.RunningTaskInfo info) {
+ }
+ @Override
+ public void onTaskInfoChanged(ActivityManager.RunningTaskInfo info) {
+ if (mInSplit) {
+ return;
+ }
+ if (info.topActivityType == ACTIVITY_TYPE_UNDEFINED) {
+ // Not populated
+ return;
+ }
+ if (info.configuration.windowConfiguration.getWindowingMode()
+ != WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) {
+ return;
+ }
+ mInSplit = true;
+ if (!mMoveToSecondaryOnEnter) {
+ return;
+ }
+ mService.mTaskOrganizerController.setLaunchRoot(mDisplayId,
+ mSecondary.mRemoteToken.toWindowContainerToken());
+ DisplayContent dc = mService.mRootWindowContainer.getDisplayContent(mDisplayId);
+ dc.forAllTaskDisplayAreas(taskDisplayArea -> {
+ for (int sNdx = taskDisplayArea.getStackCount() - 1; sNdx >= 0; --sNdx) {
+ final Task stack = taskDisplayArea.getStackAt(sNdx);
+ if (!WindowConfiguration.isSplitScreenWindowingMode(stack.getWindowingMode())) {
+ stack.reparent(mSecondary, POSITION_BOTTOM);
+ }
+ }
+ });
+ }
+ @Override
+ public void onBackPressedOnTaskRoot(ActivityManager.RunningTaskInfo taskInfo) {
+ }
+ }
}
diff --git a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java
index ee564a93e022..0ea84da54b60 100644
--- a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java
+++ b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java
@@ -1281,27 +1281,25 @@ public class SoundTriggerService extends SystemService {
attributesBuilder.setInternalCapturePreset(MediaRecorder.AudioSource.HOTWORD);
AudioAttributes attributes = attributesBuilder.build();
- // Use same AudioFormat processing as in RecognitionEvent.fromParcel
AudioFormat originalFormat = event.getCaptureFormat();
- AudioFormat captureFormat = (new AudioFormat.Builder())
- .setChannelMask(originalFormat.getChannelMask())
- .setEncoding(originalFormat.getEncoding())
- .setSampleRate(originalFormat.getSampleRate())
- .build();
-
- int bufferSize = AudioRecord.getMinBufferSize(
- captureFormat.getSampleRate() == AudioFormat.SAMPLE_RATE_UNSPECIFIED
- ? AudioFormat.SAMPLE_RATE_HZ_MAX
- : captureFormat.getSampleRate(),
- captureFormat.getChannelCount() == 2
- ? AudioFormat.CHANNEL_IN_STEREO
- : AudioFormat.CHANNEL_IN_MONO,
- captureFormat.getEncoding());
sEventLogger.log(new SoundTriggerLogger.StringEvent("createAudioRecordForEvent"));
- return new AudioRecord(attributes, captureFormat, bufferSize,
- event.getCaptureSession());
+ try {
+ return (new AudioRecord.Builder())
+ .setAudioAttributes(attributes)
+ .setAudioFormat((new AudioFormat.Builder())
+ .setChannelMask(originalFormat.getChannelMask())
+ .setEncoding(originalFormat.getEncoding())
+ .setSampleRate(originalFormat.getSampleRate())
+ .build())
+ .setSessionId(event.getCaptureSession())
+ .build();
+ } catch (IllegalArgumentException | UnsupportedOperationException e) {
+ Slog.w(TAG, mPuuid + ": createAudioRecordForEvent(" + event
+ + "), failed to create AudioRecord");
+ return null;
+ }
}
@Override
@@ -1331,8 +1329,10 @@ public class SoundTriggerService extends SystemService {
// Currently we need to start and release the audio record to reset
// the DSP even if we don't want to process the event
- capturedData.startRecording();
- capturedData.release();
+ if (capturedData != null) {
+ capturedData.startRecording();
+ capturedData.release();
+ }
}
}));
}
diff --git a/startop/OWNERS b/startop/OWNERS
index 3394be9779e3..2d1eb38952ed 100644
--- a/startop/OWNERS
+++ b/startop/OWNERS
@@ -1,7 +1,7 @@
# mailing list: startop-eng@google.com
+calin@google.com
chriswailes@google.com
eholk@google.com
iam@google.com
mathieuc@google.com
-sehr@google.com
yawanng@google.com
diff --git a/telephony/api/system-current.txt b/telephony/api/system-current.txt
index ef94c7677a17..09c16595e2c7 100644
--- a/telephony/api/system-current.txt
+++ b/telephony/api/system-current.txt
@@ -316,6 +316,7 @@ package android.telephony {
method @Deprecated public int getDataConnectionApnTypeBitMask();
method @Deprecated public int getDataConnectionFailCause();
method @Deprecated public int getDataConnectionState();
+ method public int getId();
}
public final class PreciseDisconnectCause {
diff --git a/telephony/java/android/telephony/PreciseDataConnectionState.java b/telephony/java/android/telephony/PreciseDataConnectionState.java
index aee861768209..fd9f46011c7e 100644
--- a/telephony/java/android/telephony/PreciseDataConnectionState.java
+++ b/telephony/java/android/telephony/PreciseDataConnectionState.java
@@ -28,11 +28,15 @@ import android.net.LinkProperties;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
+import android.telephony.AccessNetworkConstants.TransportType;
import android.telephony.Annotation.ApnType;
import android.telephony.Annotation.DataFailureCause;
import android.telephony.Annotation.DataState;
import android.telephony.Annotation.NetworkType;
import android.telephony.data.ApnSetting;
+import android.telephony.data.DataCallResponse;
+
+import com.android.internal.telephony.util.TelephonyUtils;
import java.util.Objects;
@@ -53,6 +57,8 @@ import java.util.Objects;
*
*/
public final class PreciseDataConnectionState implements Parcelable {
+ private final @TransportType int mTransportType;
+ private final int mId;
private final @DataState int mState;
private final @NetworkType int mNetworkType;
private final @DataFailureCause int mFailCause;
@@ -74,16 +80,20 @@ public final class PreciseDataConnectionState implements Parcelable {
@ApnType int apnTypes, @NonNull String apn,
@Nullable LinkProperties linkProperties,
@DataFailureCause int failCause) {
- this(state, networkType, linkProperties, failCause, new ApnSetting.Builder()
- .setApnTypeBitmask(apnTypes)
- .setApnName(apn)
- .build());
+ this(AccessNetworkConstants.TRANSPORT_TYPE_INVALID, -1, state, networkType,
+ linkProperties, failCause, new ApnSetting.Builder()
+ .setApnTypeBitmask(apnTypes)
+ .setApnName(apn)
+ .setEntryName(apn)
+ .build());
}
/**
* Constructor of PreciseDataConnectionState
*
+ * @param transportType The transport of the data connection
+ * @param id The id of the data connection
* @param state The state of the data connection
* @param networkType The access network that is/would carry this data connection
* @param linkProperties If the data connection is connected, the properties of the connection
@@ -92,11 +102,12 @@ public final class PreciseDataConnectionState implements Parcelable {
* @param apnSetting If there is a valid APN for this Data Connection, then the APN Settings;
* if there is no valid APN setting for the specific type, then this will be null
*/
- private PreciseDataConnectionState(@DataState int state,
- @NetworkType int networkType,
- @Nullable LinkProperties linkProperties,
- @DataFailureCause int failCause,
- @Nullable ApnSetting apnSetting) {
+ private PreciseDataConnectionState(@TransportType int transportType, int id,
+ @DataState int state, @NetworkType int networkType,
+ @Nullable LinkProperties linkProperties, @DataFailureCause int failCause,
+ @Nullable ApnSetting apnSetting) {
+ mTransportType = transportType;
+ mId = id;
mState = state;
mNetworkType = networkType;
mLinkProperties = linkProperties;
@@ -110,6 +121,8 @@ public final class PreciseDataConnectionState implements Parcelable {
* @hide
*/
private PreciseDataConnectionState(Parcel in) {
+ mTransportType = in.readInt();
+ mId = in.readInt();
mState = in.readInt();
mNetworkType = in.readInt();
mLinkProperties = in.readParcelable(LinkProperties.class.getClassLoader());
@@ -144,7 +157,29 @@ public final class PreciseDataConnectionState implements Parcelable {
}
/**
- * Returns the high-level state of this data connection.
+ * @return The transport type of this data connection.
+ */
+ public @TransportType int getTransportType() {
+ return mTransportType;
+ }
+
+ /**
+ * @return The unique id of the data connection
+ *
+ * Note this is the id assigned in {@link DataCallResponse}.
+ * The id remains the same for data connection handover between
+ * {@link AccessNetworkConstants#TRANSPORT_TYPE_WLAN} and
+ * {@link AccessNetworkConstants#TRANSPORT_TYPE_WWAN}
+ *
+ * @hide
+ */
+ @SystemApi
+ public int getId() {
+ return mId;
+ }
+
+ /**
+ * @return The high-level state of this data connection.
*/
public @DataState int getState() {
return mState;
@@ -222,7 +257,9 @@ public final class PreciseDataConnectionState implements Parcelable {
/**
* Return the APN Settings for this data connection.
*
- * @return the ApnSetting that was used to configure this data connection.
+ * @return the ApnSetting that was used to configure this data connection. Note that a data
+ * connection cannot be established without a valid {@link ApnSetting}. The return value would
+ * never be {@code null} even though it has {@link Nullable} annotation.
*/
public @Nullable ApnSetting getApnSetting() {
return mApnSetting;
@@ -235,6 +272,8 @@ public final class PreciseDataConnectionState implements Parcelable {
@Override
public void writeToParcel(@NonNull Parcel out, int flags) {
+ out.writeInt(mTransportType);
+ out.writeInt(mId);
out.writeInt(mState);
out.writeInt(mNetworkType);
out.writeParcelable(mLinkProperties, flags);
@@ -256,7 +295,8 @@ public final class PreciseDataConnectionState implements Parcelable {
@Override
public int hashCode() {
- return Objects.hash(mState, mNetworkType, mFailCause, mLinkProperties, mApnSetting);
+ return Objects.hash(mTransportType, mId, mState, mNetworkType, mFailCause,
+ mLinkProperties, mApnSetting);
}
@@ -265,7 +305,9 @@ public final class PreciseDataConnectionState implements Parcelable {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PreciseDataConnectionState that = (PreciseDataConnectionState) o;
- return mState == that.mState
+ return mTransportType == that.mTransportType
+ && mId == that.mId
+ && mState == that.mState
&& mNetworkType == that.mNetworkType
&& mFailCause == that.mFailCause
&& Objects.equals(mLinkProperties, that.mLinkProperties)
@@ -277,14 +319,14 @@ public final class PreciseDataConnectionState implements Parcelable {
public String toString() {
StringBuilder sb = new StringBuilder();
- sb.append("Data Connection state: " + mState);
- sb.append(", Network type: " + mNetworkType);
- sb.append(", APN types: " + ApnSetting.getApnTypesStringFromBitmask(
- getDataConnectionApnTypeBitMask()));
- sb.append(", APN: " + getDataConnectionApn());
- sb.append(", Link properties: " + mLinkProperties);
- sb.append(", Fail cause: " + DataFailCause.toString(mFailCause));
- sb.append(", Apn Setting: " + mApnSetting);
+ sb.append(" state: " + TelephonyUtils.dataStateToString(mState));
+ sb.append(", transport: "
+ + AccessNetworkConstants.transportTypeToString(mTransportType));
+ sb.append(", id: " + mId);
+ sb.append(", network type: " + TelephonyManager.getNetworkTypeName(mNetworkType));
+ sb.append(", APN Setting: " + mApnSetting);
+ sb.append(", link properties: " + mLinkProperties);
+ sb.append(", fail cause: " + DataFailCause.toString(mFailCause));
return sb.toString();
}
@@ -295,6 +337,15 @@ public final class PreciseDataConnectionState implements Parcelable {
* @hide
*/
public static final class Builder {
+ /** The transport type of the data connection */
+ private @TransportType int mTransportType = AccessNetworkConstants.TRANSPORT_TYPE_INVALID;
+
+ /**
+ * The unique ID of the data connection. This is the id assigned in
+ * {@link DataCallResponse)}.
+ */
+ private int mId = -1;
+
/** The state of the data connection */
private @DataState int mState = TelephonyManager.DATA_UNKNOWN;
@@ -314,12 +365,34 @@ public final class PreciseDataConnectionState implements Parcelable {
private @Nullable ApnSetting mApnSetting = null;
/**
+ * Set the transport type of the data connection.
+ *
+ * @param transportType The transport type of the data connection
+ * @return The builder
+ */
+ public @NonNull Builder setTransportType(@TransportType int transportType) {
+ mTransportType = transportType;
+ return this;
+ }
+
+ /**
+ * Set the id of the data connection.
+ *
+ * @param id The id of the data connection
+ * @return The builder
+ */
+ public @NonNull Builder setId(int id) {
+ mId = id;
+ return this;
+ }
+
+ /**
* Set the state of the data connection.
*
* @param state The state of the data connection
* @return The builder
*/
- public Builder setState(@DataState int state) {
+ public @NonNull Builder setState(@DataState int state) {
mState = state;
return this;
}
@@ -330,7 +403,7 @@ public final class PreciseDataConnectionState implements Parcelable {
* @param networkType The network type
* @return The builder
*/
- public Builder setNetworkType(@NetworkType int networkType) {
+ public @NonNull Builder setNetworkType(@NetworkType int networkType) {
mNetworkType = networkType;
return this;
}
@@ -341,7 +414,7 @@ public final class PreciseDataConnectionState implements Parcelable {
* @param linkProperties Link properties
* @return The builder
*/
- public Builder setLinkProperties(@NonNull LinkProperties linkProperties) {
+ public @NonNull Builder setLinkProperties(LinkProperties linkProperties) {
mLinkProperties = linkProperties;
return this;
}
@@ -353,7 +426,7 @@ public final class PreciseDataConnectionState implements Parcelable {
* error code indicating the cause of the failure.
* @return The builder
*/
- public Builder setFailCause(@DataFailureCause int failCause) {
+ public @NonNull Builder setFailCause(@DataFailureCause int failCause) {
mFailCause = failCause;
return this;
}
@@ -364,7 +437,7 @@ public final class PreciseDataConnectionState implements Parcelable {
* @param apnSetting APN setting
* @return This builder
*/
- public Builder setApnSetting(@NonNull ApnSetting apnSetting) {
+ public @NonNull Builder setApnSetting(@NonNull ApnSetting apnSetting) {
mApnSetting = apnSetting;
return this;
}
@@ -375,8 +448,8 @@ public final class PreciseDataConnectionState implements Parcelable {
* @return The {@link PreciseDataConnectionState} instance
*/
public PreciseDataConnectionState build() {
- return new PreciseDataConnectionState(mState, mNetworkType, mLinkProperties, mFailCause,
- mApnSetting);
+ return new PreciseDataConnectionState(mTransportType, mId, mState, mNetworkType,
+ mLinkProperties, mFailCause, mApnSetting);
}
}
}
diff --git a/telephony/java/android/telephony/data/ApnSetting.java b/telephony/java/android/telephony/data/ApnSetting.java
index e60ae896f9f8..ff9329ef9742 100644
--- a/telephony/java/android/telephony/data/ApnSetting.java
+++ b/telephony/java/android/telephony/data/ApnSetting.java
@@ -1214,12 +1214,16 @@ public class ApnSetting implements Parcelable {
return false;
}
- // TODO - if we have this function we should also have hashCode.
- // Also should handle changes in type order and perhaps case-insensitivity.
+ @Override
+ public int hashCode() {
+ return Objects.hash(mApnName, mProxyAddress, mProxyPort, mMmsc, mMmsProxyAddress,
+ mMmsProxyPort, mUser, mPassword, mAuthType, mApnTypeBitmask, mId, mOperatorNumeric,
+ mProtocol, mRoamingProtocol, mMtu, mCarrierEnabled, mNetworkTypeBitmask, mProfileId,
+ mPersistent, mMaxConns, mWaitTime, mMaxConnsTime, mMvnoType, mMvnoMatchData,
+ mApnSetId, mCarrierId, mSkip464Xlat);
+ }
- /**
- * @hide
- */
+ @Override
public boolean equals(Object o) {
if (o instanceof ApnSetting == false) {
return false;
diff --git a/test-runner/src/android/test/AndroidTestRunner.java b/test-runner/src/android/test/AndroidTestRunner.java
index f898516a001b..b2fdc5084834 100644
--- a/test-runner/src/android/test/AndroidTestRunner.java
+++ b/test-runner/src/android/test/AndroidTestRunner.java
@@ -125,7 +125,7 @@ public class AndroidTestRunner extends BaseTestRunner {
} catch (IllegalArgumentException e) {
runFailed("Illegal argument passed to constructor. Class: " + testClass.getName());
} catch (InvocationTargetException e) {
- runFailed("Constructor thew an exception. Class: " + testClass.getName());
+ runFailed("Constructor threw an exception. Class: " + testClass.getName());
}
return null;
}
diff --git a/tools/stats_log_api_gen/main.cpp b/tools/stats_log_api_gen/main.cpp
index d21018463868..28302493a8e1 100644
--- a/tools/stats_log_api_gen/main.cpp
+++ b/tools/stats_log_api_gen/main.cpp
@@ -15,8 +15,6 @@
#include "native_writer.h"
#include "utils.h"
-using namespace google::protobuf;
-
namespace android {
namespace stats_log_api_gen {