summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Assist/Android.mk10
-rw-r--r--tests/Assist/AndroidManifest.xml39
-rw-r--r--tests/Assist/res/drawable/assistant.xml27
-rw-r--r--tests/Assist/res/drawable/navbar_scrim.xml25
-rw-r--r--tests/Assist/res/drawable/round_rect.xml26
-rw-r--r--tests/Assist/res/layout/assist.xml71
-rw-r--r--tests/Assist/res/values/strings.xml28
-rw-r--r--tests/Assist/res/xml/interaction_service.xml21
-rw-r--r--tests/Assist/res/xml/recognition_service.xml18
-rw-r--r--tests/Assist/src/com/android/test/assist/AssistInteractionService.java23
-rw-r--r--tests/Assist/src/com/android/test/assist/AssistInteractionSession.java181
-rw-r--r--tests/Assist/src/com/android/test/assist/AssistInteractionSessionService.java28
-rw-r--r--tests/Assist/src/com/android/test/assist/AssistRecognitionService.java38
-rw-r--r--tests/Assist/src/com/android/test/assist/ScrimView.java42
-rw-r--r--tests/CoreTests/android/Android.mk2
-rw-r--r--tests/CoreTests/android/AndroidManifest.xml1
-rw-r--r--tests/HwAccelerationTest/res/layout/projection_clipping.xml6
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/CirclePropActivity.java6
-rw-r--r--tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/MainActivity.java6
-rw-r--r--tests/LegacyAssistant/Android.mk (renamed from tests/Assistant/Android.mk)2
-rw-r--r--tests/LegacyAssistant/AndroidManifest.xml (renamed from tests/Assistant/AndroidManifest.xml)2
-rw-r--r--tests/LegacyAssistant/res/drawable-hdpi/ic_action_assist_activated.png (renamed from tests/Assistant/res/drawable-hdpi/ic_action_assist_activated.png)bin13757 -> 13757 bytes
-rw-r--r--tests/LegacyAssistant/res/drawable-hdpi/ic_action_assist_normal.png (renamed from tests/Assistant/res/drawable-hdpi/ic_action_assist_normal.png)bin5732 -> 5732 bytes
-rw-r--r--tests/LegacyAssistant/res/drawable-mdpi/ic_action_assist_activated.png (renamed from tests/Assistant/res/drawable-mdpi/ic_action_assist_activated.png)bin8786 -> 8786 bytes
-rw-r--r--tests/LegacyAssistant/res/drawable-mdpi/ic_action_assist_normal.png (renamed from tests/Assistant/res/drawable-mdpi/ic_action_assist_normal.png)bin4480 -> 4480 bytes
-rw-r--r--tests/LegacyAssistant/res/drawable-xhdpi/ic_action_assist_activated.png (renamed from tests/Assistant/res/drawable-xhdpi/ic_action_assist_activated.png)bin19647 -> 19647 bytes
-rw-r--r--tests/LegacyAssistant/res/drawable-xhdpi/ic_action_assist_normal.png (renamed from tests/Assistant/res/drawable-xhdpi/ic_action_assist_normal.png)bin7327 -> 7327 bytes
-rw-r--r--tests/LegacyAssistant/res/drawable/ic_action_assist.xml (renamed from tests/Assistant/res/drawable/ic_action_assist.xml)0
-rw-r--r--tests/LegacyAssistant/res/layout/assist_intent_activity.xml (renamed from tests/Assistant/res/layout/assist_intent_activity.xml)0
-rw-r--r--tests/LegacyAssistant/res/values/strings.xml (renamed from tests/Assistant/res/values/strings.xml)0
-rw-r--r--tests/LegacyAssistant/src/com/google/android/test/legacyassistant/AssistActivity.java (renamed from tests/Assistant/src/com/google/android/test/assistant/AssistActivity.java)4
-rw-r--r--tests/OneMedia/Android.mk5
-rw-r--r--tests/OneMedia/AndroidManifest.xml11
-rw-r--r--tests/OneMedia/src/com/android/onemedia/PlayerSession.java83
-rw-r--r--tests/OneMedia/src/com/android/onemedia/playback/OneMRPRenderer.java47
-rw-r--r--tests/OneMedia/src/com/android/onemedia/provider/OneMediaRouteProvider.java270
-rw-r--r--tests/Split/res/values-b+fr+Latn+CA/strings.xml4
-rw-r--r--tests/Split/res/values-fr-rCA/strings.xml4
-rw-r--r--tests/TtsTests/src/com/android/speech/tts/MockableTextToSpeechService.java2
-rw-r--r--tests/TtsTests/src/com/android/speech/tts/TextToSpeechTests.java29
-rw-r--r--tests/UsageStatsTest/src/com/android/tests/usagestats/UsageLogActivity.java3
-rw-r--r--tests/VectorDrawableTest/res/drawable/vector_drawable03.xml40
-rw-r--r--tests/VectorDrawableTest/res/drawable/vector_drawable_scale0.xml57
-rw-r--r--tests/VectorDrawableTest/res/drawable/vector_drawable_scale1.xml52
-rw-r--r--tests/VectorDrawableTest/res/drawable/vector_drawable_scale2.xml48
-rw-r--r--tests/VectorDrawableTest/res/drawable/vector_drawable_scale3.xml62
-rw-r--r--tests/VectorDrawableTest/src/com/android/test/dynamic/AnimatedVectorDrawableTest.java23
-rw-r--r--tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawablePerformance.java4
-rw-r--r--tests/VoiceInteraction/AndroidManifest.xml17
-rw-r--r--tests/VoiceInteraction/res/layout/main.xml8
-rw-r--r--tests/VoiceInteraction/res/layout/test_interaction.xml15
-rw-r--r--tests/VoiceInteraction/res/layout/voice_interaction_session.xml46
-rw-r--r--tests/VoiceInteraction/res/values/strings.xml4
-rw-r--r--tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistProxyActivity.java33
-rw-r--r--tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java104
-rw-r--r--tests/VoiceInteraction/src/com/android/test/voiceinteraction/AsyncStructure.java58
-rw-r--r--tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java12
-rw-r--r--tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java186
-rw-r--r--tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java74
-rw-r--r--tests/permission/src/com/android/framework/permission/tests/ActivityManagerPermissionTests.java12
-rw-r--r--tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java2
61 files changed, 1825 insertions, 96 deletions
diff --git a/tests/Assist/Android.mk b/tests/Assist/Android.mk
new file mode 100644
index 0000000..f31c4dd
--- /dev/null
+++ b/tests/Assist/Android.mk
@@ -0,0 +1,10 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_PACKAGE_NAME := Assist
+
+include $(BUILD_PACKAGE)
diff --git a/tests/Assist/AndroidManifest.xml b/tests/Assist/AndroidManifest.xml
new file mode 100644
index 0000000..4eceed9
--- /dev/null
+++ b/tests/Assist/AndroidManifest.xml
@@ -0,0 +1,39 @@
+<!--
+ ~ Copyright (C) 2015 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.test.assist">
+
+ <application>
+ <service android:name="AssistInteractionService"
+ android:label="Test Assist Interaction Service"
+ android:permission="android.permission.BIND_VOICE_INTERACTION"
+ android:process=":interactor">
+ <meta-data android:name="android.voice_interaction"
+ android:resource="@xml/interaction_service" />
+ <intent-filter>
+ <action android:name="android.service.voice.VoiceInteractionService" />
+ </intent-filter>
+ <meta-data
+ android:name="com.android.systemui.action_assist_icon"
+ android:resource="@drawable/assistant" />
+ </service>
+ <service android:name="AssistInteractionSessionService"
+ android:permission="android.permission.BIND_VOICE_INTERACTION"
+ android:process=":session">
+ </service>
+ </application>
+</manifest>
diff --git a/tests/Assist/res/drawable/assistant.xml b/tests/Assist/res/drawable/assistant.xml
new file mode 100644
index 0000000..2a89dda
--- /dev/null
+++ b/tests/Assist/res/drawable/assistant.xml
@@ -0,0 +1,27 @@
+<!--
+Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="48.0dp"
+ android:height="48.0dp"
+ android:viewportWidth="48.0"
+ android:viewportHeight="48.0">
+ <path
+ android:pathData="M0 0h48v48H0z"
+ android:fillColor="#00000000"/>
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M38.0,4.0L10.0,4.0C7.79,4.0 6.0,5.79 6.0,8.0l0.0,28.0c0.0,2.21 1.79,4.0 4.0,4.0l8.0,0.0l6.0,6.0 6.0,-6.0l8.0,0.0c2.21,0.0 4.0,-1.79 4.0,-4.0L36.0,8.0c0.0,-2.21 -1.79,-4.0 -4.0,-4.0zM27.75,25.75L24.0,34.0l-3.75,-8.25L12.0,22.0l8.25,-3.75L24.0,10.0l3.75,8.25L36.0,22.0l-8.25,3.75z"/>
+</vector>
diff --git a/tests/Assist/res/drawable/navbar_scrim.xml b/tests/Assist/res/drawable/navbar_scrim.xml
new file mode 100644
index 0000000..52ed76d
--- /dev/null
+++ b/tests/Assist/res/drawable/navbar_scrim.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ ~ Copyright (C) 2014 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
+ -->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+ <gradient
+ android:type="linear"
+ android:angle="90"
+ android:startColor="#33000000"
+ android:endColor="#00000000" />
+</shape> \ No newline at end of file
diff --git a/tests/Assist/res/drawable/round_rect.xml b/tests/Assist/res/drawable/round_rect.xml
new file mode 100644
index 0000000..55937a0
--- /dev/null
+++ b/tests/Assist/res/drawable/round_rect.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2014 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
+ -->
+
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="#e0e0e0">
+ <item>
+ <shape>
+ <solid android:color="#ffffff" />
+ <corners android:radius="2dp" />
+ </shape>
+ </item>
+</ripple> \ No newline at end of file
diff --git a/tests/Assist/res/layout/assist.xml b/tests/Assist/res/layout/assist.xml
new file mode 100644
index 0000000..8c4be2d
--- /dev/null
+++ b/tests/Assist/res/layout/assist.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2015 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
+ -->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <com.android.test.assist.ScrimView
+ android:id="@+id/scrim"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#60000000"/>
+
+ <View
+ android:id="@+id/background"
+ android:layout_width="match_parent"
+ android:layout_height="350dp"
+ android:layout_gravity="bottom"
+ android:background="#e0e0e0"/>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="350dp"
+ android:orientation="vertical"
+ android:layout_gravity="bottom">
+
+ <FrameLayout
+ android:id="@+id/card1"
+ android:layout_width="match_parent"
+ android:layout_height="150dp"
+ android:layout_marginStart="8dp"
+ android:layout_marginEnd="8dp"
+ android:layout_marginTop="16dp"
+ android:elevation="3dp"
+ android:background="@drawable/round_rect">
+ </FrameLayout>
+
+ <View
+ android:id="@+id/card2"
+ android:layout_width="match_parent"
+ android:layout_height="200dp"
+ android:layout_marginStart="8dp"
+ android:layout_marginEnd="8dp"
+ android:layout_marginTop="16dp"
+ android:elevation="3dp"
+ android:background="@drawable/round_rect"/>
+
+ </LinearLayout>
+
+ <com.android.test.assist.ScrimView
+ android:id="@+id/navbar_scrim"
+ android:layout_width="match_parent"
+ android:layout_height="150dp"
+ android:layout_gravity="bottom"
+ android:background="@drawable/navbar_scrim"/>
+</FrameLayout> \ No newline at end of file
diff --git a/tests/Assist/res/values/strings.xml b/tests/Assist/res/values/strings.xml
new file mode 100644
index 0000000..5331457
--- /dev/null
+++ b/tests/Assist/res/values/strings.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+
+ <string name="start">Start</string>
+ <string name="confirm">Confirm</string>
+ <string name="abort">Abort</string>
+ <string name="complete">Complete</string>
+ <string name="abortVoice">Abort Voice</string>
+ <string name="completeVoice">Complete Voice</string>
+ <string name="pickVoice">Pick Voice</string>
+ <string name="cancelVoice">Cancel</string>
+
+</resources>
diff --git a/tests/Assist/res/xml/interaction_service.xml b/tests/Assist/res/xml/interaction_service.xml
new file mode 100644
index 0000000..2fd50aa
--- /dev/null
+++ b/tests/Assist/res/xml/interaction_service.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2015 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
+ -->
+
+<voice-interaction-service xmlns:android="http://schemas.android.com/apk/res/android"
+ android:sessionService="com.android.test.assist.AssistInteractionSessionService"
+ android:recognitionService="com.android.test.assist.AssistRecognitionService"
+ android:supportsAssistGesture="true"/>
diff --git a/tests/Assist/res/xml/recognition_service.xml b/tests/Assist/res/xml/recognition_service.xml
new file mode 100644
index 0000000..5b52c3c
--- /dev/null
+++ b/tests/Assist/res/xml/recognition_service.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2015 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
+ -->
+
+<recognition-service/>
diff --git a/tests/Assist/src/com/android/test/assist/AssistInteractionService.java b/tests/Assist/src/com/android/test/assist/AssistInteractionService.java
new file mode 100644
index 0000000..e6a6713
--- /dev/null
+++ b/tests/Assist/src/com/android/test/assist/AssistInteractionService.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2015 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.test.assist;
+
+import android.service.voice.VoiceInteractionService;
+
+public class AssistInteractionService extends VoiceInteractionService {
+
+}
diff --git a/tests/Assist/src/com/android/test/assist/AssistInteractionSession.java b/tests/Assist/src/com/android/test/assist/AssistInteractionSession.java
new file mode 100644
index 0000000..0b522c0
--- /dev/null
+++ b/tests/Assist/src/com/android/test/assist/AssistInteractionSession.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2015 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.test.assist;
+
+import android.animation.Animator;
+import android.animation.RevealAnimator;
+import android.animation.ValueAnimator;
+import android.app.VoiceInteractor;
+import android.content.Context;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.os.Handler;
+import android.service.voice.VoiceInteractionService;
+import android.service.voice.VoiceInteractionSession;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewAnimationUtils;
+import android.view.ViewTreeObserver;
+import android.view.animation.AnimationUtils;
+import android.view.animation.Interpolator;
+
+/**
+ * Sample session to show test assist transition.
+ */
+public class AssistInteractionSession extends VoiceInteractionSession {
+
+ private View mScrim;
+ private View mBackground;
+ private View mNavbarScrim;
+ private View mCard1;
+ private View mCard2;
+
+ private float mDensity;
+
+ public AssistInteractionSession(Context context) {
+ super(context);
+ }
+
+ public AssistInteractionSession(Context context, Handler handler) {
+ super(context, handler);
+ }
+
+ @Override
+ public void onConfirm(Caller caller,
+ Request request, CharSequence prompt, Bundle extras) {
+
+ }
+
+ @Override
+ public void onPickOption(Caller caller,
+ Request request, CharSequence prompt,
+ VoiceInteractor.PickOptionRequest.Option[] options, Bundle extras) {
+
+ }
+
+ @Override
+ public void onCommand(Caller caller,
+ Request request, String command, Bundle extras) {
+
+ }
+
+ @Override
+ public void onCreate(Bundle args) {
+ super.onCreate(args);
+
+ // Simulate slowness of Assist app
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onCancel(Request request) {
+
+ }
+
+ @Override
+ public View onCreateContentView() {
+ View v = getLayoutInflater().inflate(R.layout.assist, null);
+ mScrim = v.findViewById(R.id.scrim);
+ mBackground = v.findViewById(R.id.background);
+ mDensity = mScrim.getResources().getDisplayMetrics().density;
+ mCard1 = v.findViewById(R.id.card1);
+ mCard2 = v.findViewById(R.id.card2);
+ mNavbarScrim = v.findViewById(R.id.navbar_scrim);
+ return v;
+ }
+
+ @Override
+ public void onShow(Bundle args, int showFlags) {
+ super.onShow(args, showFlags);
+ if ((showFlags & VoiceInteractionService.START_SOURCE_ASSIST_GESTURE) != 0) {
+ mBackground.getViewTreeObserver().addOnPreDrawListener(
+ new ViewTreeObserver.OnPreDrawListener() {
+ @Override
+ public boolean onPreDraw() {
+ mBackground.getViewTreeObserver().removeOnPreDrawListener(this);
+ playAssistAnimation();
+ return true;
+ }
+ });
+ }
+ }
+
+ private void playAssistAnimation() {
+ Interpolator linearOutSlowIn = AnimationUtils.loadInterpolator(mBackground.getContext(),
+ android.R.interpolator.linear_out_slow_in);
+ Interpolator fastOutSlowIn = AnimationUtils.loadInterpolator(mBackground.getContext(),
+ android.R.interpolator.fast_out_slow_in);
+ mScrim.setAlpha(0f);
+ mScrim.animate()
+ .alpha(1f)
+ .setStartDelay(100)
+ .setDuration(500);
+ mBackground.setTranslationY(50 * mDensity);
+ mBackground.animate()
+ .translationY(0)
+ .setDuration(300)
+ .setInterpolator(linearOutSlowIn);
+ int centerX = mBackground.getWidth()/2;
+ int centerY = (int) (mBackground.getHeight()/5*3.8f);
+ int radius = (int) Math.sqrt(centerX*centerX + centerY*centerY) + 1;
+ Animator animator = ViewAnimationUtils.createCircularReveal(mBackground, centerX, centerY,
+ 0, radius);
+ animator.setDuration(300);
+ animator.setInterpolator(fastOutSlowIn);
+ animator.start();
+
+ ValueAnimator colorAnim = ValueAnimator.ofArgb(Color.WHITE, 0xffe0e0e0);
+ colorAnim.setDuration(300);
+ colorAnim.setInterpolator(fastOutSlowIn);
+ colorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(ValueAnimator animation) {
+ mBackground.setBackgroundColor((Integer) animation.getAnimatedValue());
+ }
+ });
+ colorAnim.start();
+
+
+ mCard1.setY(mBackground.getHeight());
+ mCard2.setTranslationY(mCard1.getTranslationY());
+ mCard1.animate()
+ .translationY(0)
+ .setDuration(500)
+ .setInterpolator(linearOutSlowIn)
+ .setStartDelay(100);
+ mCard2.animate()
+ .translationY(0)
+ .setInterpolator(linearOutSlowIn)
+ .setStartDelay(150)
+ .setDuration(500);
+
+ mNavbarScrim.setAlpha(0f);
+ mNavbarScrim.animate()
+ .alpha(1f)
+ .setDuration(500)
+ .setStartDelay(100);
+ }
+
+ @Override
+ public void onHide() {
+ super.onHide();
+ }
+}
diff --git a/tests/Assist/src/com/android/test/assist/AssistInteractionSessionService.java b/tests/Assist/src/com/android/test/assist/AssistInteractionSessionService.java
new file mode 100644
index 0000000..3c483d6
--- /dev/null
+++ b/tests/Assist/src/com/android/test/assist/AssistInteractionSessionService.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2015 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.test.assist;
+
+import android.os.Bundle;
+import android.service.voice.VoiceInteractionSession;
+import android.service.voice.VoiceInteractionSessionService;
+
+public class AssistInteractionSessionService extends VoiceInteractionSessionService {
+ @Override
+ public VoiceInteractionSession onNewSession(Bundle args) {
+ return new AssistInteractionSession(this);
+ }
+}
diff --git a/tests/Assist/src/com/android/test/assist/AssistRecognitionService.java b/tests/Assist/src/com/android/test/assist/AssistRecognitionService.java
new file mode 100644
index 0000000..6e5faa1
--- /dev/null
+++ b/tests/Assist/src/com/android/test/assist/AssistRecognitionService.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2015 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.test.assist;
+
+import android.content.Intent;
+import android.speech.RecognitionService;
+
+/**
+ * Stub recognition service needed to be a complete voice interactor.
+ */
+public class AssistRecognitionService extends RecognitionService {
+
+ @Override
+ protected void onStartListening(Intent recognizerIntent, Callback listener) {
+ }
+
+ @Override
+ protected void onCancel(Callback listener) {
+ }
+
+ @Override
+ protected void onStopListening(Callback listener) {
+ }
+}
diff --git a/tests/Assist/src/com/android/test/assist/ScrimView.java b/tests/Assist/src/com/android/test/assist/ScrimView.java
new file mode 100644
index 0000000..1b7387b
--- /dev/null
+++ b/tests/Assist/src/com/android/test/assist/ScrimView.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2015 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.test.assist;
+
+import android.annotation.Nullable;
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+
+public class ScrimView extends View {
+
+ public ScrimView(Context context) {
+ super(context);
+ }
+
+ public ScrimView(Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public ScrimView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ @Override
+ public boolean hasOverlappingRendering() {
+ return false;
+ }
+}
diff --git a/tests/CoreTests/android/Android.mk b/tests/CoreTests/android/Android.mk
index bc0e4e4..5f3d0d9 100644
--- a/tests/CoreTests/android/Android.mk
+++ b/tests/CoreTests/android/Android.mk
@@ -6,7 +6,7 @@ LOCAL_MODULE_TAGS := tests
LOCAL_SRC_FILES := \
$(call all-subdir-java-files)
-LOCAL_JAVA_LIBRARIES := android.test.runner bouncycastle conscrypt
+LOCAL_JAVA_LIBRARIES := android.test.runner bouncycastle conscrypt org.apache.http.legacy
LOCAL_PACKAGE_NAME := CoreTests
diff --git a/tests/CoreTests/android/AndroidManifest.xml b/tests/CoreTests/android/AndroidManifest.xml
index 8331f0c..bf46d15 100644
--- a/tests/CoreTests/android/AndroidManifest.xml
+++ b/tests/CoreTests/android/AndroidManifest.xml
@@ -35,6 +35,7 @@
<application>
<uses-library android:name="android.test.runner" />
+ <uses-library android:name="org.apache.http.legacy" android:required="false" />
</application>
<instrumentation
diff --git a/tests/HwAccelerationTest/res/layout/projection_clipping.xml b/tests/HwAccelerationTest/res/layout/projection_clipping.xml
index 7177fc8f..1f2b939 100644
--- a/tests/HwAccelerationTest/res/layout/projection_clipping.xml
+++ b/tests/HwAccelerationTest/res/layout/projection_clipping.xml
@@ -14,13 +14,13 @@
android:id="@+id/clickable1"
android:layout_width="100dp"
android:layout_height="100dp"
- android:background="?android:attr/selectableItemBackground"/>
+ android:background="?android:attr/selectableItemBackgroundBorderless"/>
<View
android:id="@+id/clickable2"
android:translationX="50dp"
android:translationY="10dp"
android:layout_width="150dp"
android:layout_height="100dp"
- android:background="?android:attr/selectableItemBackground"/>
+ android:background="?android:attr/selectableItemBackgroundBorderless"/>
</FrameLayout>
-</LinearLayout> \ No newline at end of file
+</LinearLayout>
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/CirclePropActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/CirclePropActivity.java
index afd6a8d..5bc8934 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/CirclePropActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/CirclePropActivity.java
@@ -24,7 +24,7 @@ import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.os.Bundle;
import android.os.Trace;
-import android.view.HardwareCanvas;
+import android.view.DisplayListCanvas;
import android.view.RenderNodeAnimator;
import android.view.View;
import android.widget.LinearLayout;
@@ -88,8 +88,8 @@ public class CirclePropActivity extends Activity {
super.onDraw(canvas);
if (canvas.isHardwareAccelerated()) {
- HardwareCanvas hwcanvas = (HardwareCanvas) canvas;
- hwcanvas.drawCircle(mX, mY, mRadius, mPaint);
+ DisplayListCanvas displayListCanvas = (DisplayListCanvas) canvas;
+ displayListCanvas.drawCircle(mX, mY, mRadius, mPaint);
}
}
diff --git a/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/MainActivity.java b/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/MainActivity.java
index b9a2a7e..dfbbd7e 100644
--- a/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/MainActivity.java
+++ b/tests/JobSchedulerTestApp/src/com/android/demo/jobSchedulerApp/MainActivity.java
@@ -51,9 +51,9 @@ public class MainActivity extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Resources res = getResources();
- defaultColor = res.getColor(R.color.none_received);
- startJobColor = res.getColor(R.color.start_received);
- stopJobColor = res.getColor(R.color.stop_received);
+ defaultColor = getColor(R.color.none_received);
+ startJobColor = getColor(R.color.start_received);
+ stopJobColor = getColor(R.color.stop_received);
// Set up UI.
mShowStartView = (TextView) findViewById(R.id.onstart_textview);
diff --git a/tests/Assistant/Android.mk b/tests/LegacyAssistant/Android.mk
index bf8cc29..0ad48d1 100644
--- a/tests/Assistant/Android.mk
+++ b/tests/LegacyAssistant/Android.mk
@@ -3,7 +3,7 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-subdir-java-files)
-LOCAL_PACKAGE_NAME := Assistant
+LOCAL_PACKAGE_NAME := LegacyAssistant
LOCAL_MODULE_TAGS := tests
LOCAL_CERTIFICATE := platform
diff --git a/tests/Assistant/AndroidManifest.xml b/tests/LegacyAssistant/AndroidManifest.xml
index b5d4d51..7ae5103 100644
--- a/tests/Assistant/AndroidManifest.xml
+++ b/tests/LegacyAssistant/AndroidManifest.xml
@@ -15,7 +15,7 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.google.android.test.assistant">
+ package="com.google.android.test.legacyassistant">
<application android:label="@string/activity_title">
diff --git a/tests/Assistant/res/drawable-hdpi/ic_action_assist_activated.png b/tests/LegacyAssistant/res/drawable-hdpi/ic_action_assist_activated.png
index cea8ac4..cea8ac4 100644
--- a/tests/Assistant/res/drawable-hdpi/ic_action_assist_activated.png
+++ b/tests/LegacyAssistant/res/drawable-hdpi/ic_action_assist_activated.png
Binary files differ
diff --git a/tests/Assistant/res/drawable-hdpi/ic_action_assist_normal.png b/tests/LegacyAssistant/res/drawable-hdpi/ic_action_assist_normal.png
index bb7702d..bb7702d 100644
--- a/tests/Assistant/res/drawable-hdpi/ic_action_assist_normal.png
+++ b/tests/LegacyAssistant/res/drawable-hdpi/ic_action_assist_normal.png
Binary files differ
diff --git a/tests/Assistant/res/drawable-mdpi/ic_action_assist_activated.png b/tests/LegacyAssistant/res/drawable-mdpi/ic_action_assist_activated.png
index 5841d82..5841d82 100644
--- a/tests/Assistant/res/drawable-mdpi/ic_action_assist_activated.png
+++ b/tests/LegacyAssistant/res/drawable-mdpi/ic_action_assist_activated.png
Binary files differ
diff --git a/tests/Assistant/res/drawable-mdpi/ic_action_assist_normal.png b/tests/LegacyAssistant/res/drawable-mdpi/ic_action_assist_normal.png
index 3851f03..3851f03 100644
--- a/tests/Assistant/res/drawable-mdpi/ic_action_assist_normal.png
+++ b/tests/LegacyAssistant/res/drawable-mdpi/ic_action_assist_normal.png
Binary files differ
diff --git a/tests/Assistant/res/drawable-xhdpi/ic_action_assist_activated.png b/tests/LegacyAssistant/res/drawable-xhdpi/ic_action_assist_activated.png
index 778db19..778db19 100644
--- a/tests/Assistant/res/drawable-xhdpi/ic_action_assist_activated.png
+++ b/tests/LegacyAssistant/res/drawable-xhdpi/ic_action_assist_activated.png
Binary files differ
diff --git a/tests/Assistant/res/drawable-xhdpi/ic_action_assist_normal.png b/tests/LegacyAssistant/res/drawable-xhdpi/ic_action_assist_normal.png
index ad49125..ad49125 100644
--- a/tests/Assistant/res/drawable-xhdpi/ic_action_assist_normal.png
+++ b/tests/LegacyAssistant/res/drawable-xhdpi/ic_action_assist_normal.png
Binary files differ
diff --git a/tests/Assistant/res/drawable/ic_action_assist.xml b/tests/LegacyAssistant/res/drawable/ic_action_assist.xml
index 05c4bf5..05c4bf5 100644
--- a/tests/Assistant/res/drawable/ic_action_assist.xml
+++ b/tests/LegacyAssistant/res/drawable/ic_action_assist.xml
diff --git a/tests/Assistant/res/layout/assist_intent_activity.xml b/tests/LegacyAssistant/res/layout/assist_intent_activity.xml
index 49785bc..49785bc 100644
--- a/tests/Assistant/res/layout/assist_intent_activity.xml
+++ b/tests/LegacyAssistant/res/layout/assist_intent_activity.xml
diff --git a/tests/Assistant/res/values/strings.xml b/tests/LegacyAssistant/res/values/strings.xml
index a59c1ef..a59c1ef 100644
--- a/tests/Assistant/res/values/strings.xml
+++ b/tests/LegacyAssistant/res/values/strings.xml
diff --git a/tests/Assistant/src/com/google/android/test/assistant/AssistActivity.java b/tests/LegacyAssistant/src/com/google/android/test/legacyassistant/AssistActivity.java
index 51894a1..b3dbb15 100644
--- a/tests/Assistant/src/com/google/android/test/assistant/AssistActivity.java
+++ b/tests/LegacyAssistant/src/com/google/android/test/legacyassistant/AssistActivity.java
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-package com.google.android.test.assistant;
+package com.google.android.test.legacyassistant;
import android.app.Activity;
import android.os.Bundle;
-import com.google.android.test.assistant.R;
+import com.google.android.test.legacyassistant.R;
public class AssistActivity extends Activity {
diff --git a/tests/OneMedia/Android.mk b/tests/OneMedia/Android.mk
index 4d39728..b7d7f98 100644
--- a/tests/OneMedia/Android.mk
+++ b/tests/OneMedia/Android.mk
@@ -9,6 +9,11 @@ LOCAL_SRC_FILES := $(call all-subdir-java-files) \
LOCAL_PACKAGE_NAME := OneMedia
LOCAL_CERTIFICATE := platform
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android-support-media-protocols
+
+LOCAL_JAVA_LIBRARIES += org.apache.http.legacy
+
LOCAL_PROGUARD_ENABLED := disabled
include $(BUILD_PACKAGE)
diff --git a/tests/OneMedia/AndroidManifest.xml b/tests/OneMedia/AndroidManifest.xml
index beafeb4..ef3fad5 100644
--- a/tests/OneMedia/AndroidManifest.xml
+++ b/tests/OneMedia/AndroidManifest.xml
@@ -13,6 +13,8 @@
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
+
+ <uses-library android:name="org.apache.http.legacy" android:required="false" />
<activity
android:name="com.android.onemedia.OnePlayerActivity"
android:label="@string/app_name" >
@@ -25,6 +27,15 @@
android:name="com.android.onemedia.OnePlayerService"
android:exported="true"
android:process="com.android.onemedia.service" />
+ <service
+ android:name=".provider.OneMediaRouteProvider"
+ android:permission="android.permission.BIND_MEDIA_ROUTE_SERVICE"
+ android:exported="true"
+ android:process="com.android.onemedia.provider">
+ <intent-filter>
+ <action android:name="android.media.routing.MediaRouteService" />
+ </intent-filter>
+ </service>
</application>
</manifest>
diff --git a/tests/OneMedia/src/com/android/onemedia/PlayerSession.java b/tests/OneMedia/src/com/android/onemedia/PlayerSession.java
index 2455c9c..141a209 100644
--- a/tests/OneMedia/src/com/android/onemedia/PlayerSession.java
+++ b/tests/OneMedia/src/com/android/onemedia/PlayerSession.java
@@ -19,17 +19,25 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.media.MediaMetadata;
+import android.media.routing.MediaRouteSelector;
+import android.media.routing.MediaRouter;
+import android.media.routing.MediaRouter.ConnectionRequest;
+import android.media.routing.MediaRouter.DestinationInfo;
+import android.media.routing.MediaRouter.RouteInfo;
import android.media.session.MediaSession;
import android.media.session.MediaSession.QueueItem;
import android.media.session.MediaSessionManager;
import android.media.session.PlaybackState;
import android.os.Bundle;
+import android.support.media.protocols.MediaPlayerProtocol;
+import android.support.media.protocols.MediaPlayerProtocol.MediaStatus;
import android.os.RemoteException;
import android.os.SystemClock;
import android.util.Log;
import android.view.KeyEvent;
import com.android.onemedia.playback.LocalRenderer;
+import com.android.onemedia.playback.OneMRPRenderer;
import com.android.onemedia.playback.Renderer;
import com.android.onemedia.playback.RequestUtils;
@@ -40,6 +48,7 @@ public class PlayerSession {
private static final String TAG = "PlayerSession";
protected MediaSession mSession;
+ protected MediaRouter mRouter;
protected Context mContext;
protected Renderer mRenderer;
protected MediaSession.Callback mCallback;
@@ -75,11 +84,22 @@ public class PlayerSession {
.getSystemService(Context.MEDIA_SESSION_SERVICE);
Log.d(TAG, "Creating session for package " + mContext.getBasePackageName());
+ mRouter = new MediaRouter(mContext);
+ mRouter.addSelector(new MediaRouteSelector.Builder()
+ .addRequiredProtocol(MediaPlayerProtocol.class)
+ .build());
+ mRouter.addSelector(new MediaRouteSelector.Builder()
+ .setRequiredFeatures(MediaRouter.ROUTE_FEATURE_LIVE_AUDIO)
+ .setOptionalFeatures(MediaRouter.ROUTE_FEATURE_LIVE_VIDEO)
+ .build());
+ mRouter.setRoutingCallback(new RoutingCallback(), null);
+
mSession = new MediaSession(mContext, "OneMedia");
mSession.setCallback(mCallback);
mSession.setPlaybackState(mPlaybackState);
mSession.setFlags(MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS
| MediaSession.FLAG_HANDLES_MEDIA_BUTTONS);
+ mSession.setMediaRouter(mRouter);
mSession.setActive(true);
updateMetadata();
}
@@ -97,6 +117,10 @@ public class PlayerSession {
mSession.release();
mSession = null;
}
+ if (mRouter != null) {
+ mRouter.release();
+ mRouter = null;
+ }
}
public void setListener(Listener listener) {
@@ -254,4 +278,63 @@ public class PlayerSession {
mRenderer.onPause();
}
}
+
+ private class RoutingCallback extends MediaRouter.RoutingCallback {
+ @Override
+ public void onConnectionStateChanged(int state) {
+ if (state == MediaRouter.CONNECTION_STATE_CONNECTING) {
+ if (mRenderer != null) {
+ mRenderer.onStop();
+ }
+ mRenderer = null;
+ updateState(PlaybackState.STATE_CONNECTING);
+ return;
+ }
+
+ MediaRouter.ConnectionInfo connection = mRouter.getConnection();
+ if (connection != null) {
+ MediaPlayerProtocol protocol =
+ connection.getProtocolObject(MediaPlayerProtocol.class);
+ if (protocol != null) {
+ Log.d(TAG, "Connected to route using media player protocol");
+
+ protocol.setCallback(new PlayerCallback(), null);
+ mRenderer = new OneMRPRenderer(protocol);
+ updateState(PlaybackState.STATE_NONE);
+ return;
+ }
+ }
+
+ // Use local route
+ mRenderer = new LocalRenderer(mContext, null);
+ mRenderer.registerListener(mRenderListener);
+ updateState(PlaybackState.STATE_NONE);
+ }
+ }
+
+ private class PlayerCallback extends MediaPlayerProtocol.Callback {
+ @Override
+ public void onStatusUpdated(MediaStatus status, Bundle extras) {
+ if (status != null) {
+ Log.d(TAG, "Received status update: " + status.toBundle());
+ switch (status.getPlayerState()) {
+ case MediaStatus.PLAYER_STATE_BUFFERING:
+ updateState(PlaybackState.STATE_BUFFERING);
+ break;
+ case MediaStatus.PLAYER_STATE_IDLE:
+ updateState(PlaybackState.STATE_STOPPED);
+ break;
+ case MediaStatus.PLAYER_STATE_PAUSED:
+ updateState(PlaybackState.STATE_PAUSED);
+ break;
+ case MediaStatus.PLAYER_STATE_PLAYING:
+ updateState(PlaybackState.STATE_PLAYING);
+ break;
+ case MediaStatus.PLAYER_STATE_UNKNOWN:
+ updateState(PlaybackState.STATE_NONE);
+ break;
+ }
+ }
+ }
+ }
}
diff --git a/tests/OneMedia/src/com/android/onemedia/playback/OneMRPRenderer.java b/tests/OneMedia/src/com/android/onemedia/playback/OneMRPRenderer.java
new file mode 100644
index 0000000..55eb92c
--- /dev/null
+++ b/tests/OneMedia/src/com/android/onemedia/playback/OneMRPRenderer.java
@@ -0,0 +1,47 @@
+package com.android.onemedia.playback;
+
+import android.os.Bundle;
+import android.support.media.protocols.MediaPlayerProtocol;
+import android.support.media.protocols.MediaPlayerProtocol.MediaInfo;
+
+/**
+ * Renderer for communicating with the OneMRP route
+ */
+public class OneMRPRenderer extends Renderer {
+ private final MediaPlayerProtocol mProtocol;
+
+ public OneMRPRenderer(MediaPlayerProtocol protocol) {
+ super(null, null);
+ mProtocol = protocol;
+ }
+
+ @Override
+ public void setContent(Bundle request) {
+ MediaInfo mediaInfo = new MediaInfo(request.getString(RequestUtils.EXTRA_KEY_SOURCE),
+ MediaInfo.STREAM_TYPE_BUFFERED, "audio/mp3");
+ mProtocol.load(mediaInfo, true, 0, null);
+ }
+
+ @Override
+ public boolean onStop() {
+ mProtocol.stop(null);
+ return true;
+ }
+
+ @Override
+ public boolean onPlay() {
+ mProtocol.play(null);
+ return true;
+ }
+
+ @Override
+ public boolean onPause() {
+ mProtocol.pause(null);
+ return true;
+ }
+
+ @Override
+ public long getSeekPosition() {
+ return -1;
+ }
+}
diff --git a/tests/OneMedia/src/com/android/onemedia/provider/OneMediaRouteProvider.java b/tests/OneMedia/src/com/android/onemedia/provider/OneMediaRouteProvider.java
new file mode 100644
index 0000000..5845e48
--- /dev/null
+++ b/tests/OneMedia/src/com/android/onemedia/provider/OneMediaRouteProvider.java
@@ -0,0 +1,270 @@
+/*
+ * Copyright (C) 2014 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.onemedia.provider;
+
+import android.media.routing.MediaRouteSelector;
+import android.media.routing.MediaRouteService;
+import android.media.routing.MediaRouter.ConnectionInfo;
+import android.media.routing.MediaRouter.ConnectionRequest;
+import android.media.routing.MediaRouter.DestinationInfo;
+import android.media.routing.MediaRouter.DiscoveryRequest;
+import android.media.routing.MediaRouter.RouteInfo;
+import android.media.session.PlaybackState;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Process;
+import android.support.media.protocols.MediaPlayerProtocol;
+import android.support.media.protocols.MediaPlayerProtocol.MediaInfo;
+import android.support.media.protocols.MediaPlayerProtocol.MediaStatus;
+import android.os.Looper;
+import android.os.ResultReceiver;
+import android.os.SystemClock;
+import android.util.Log;
+
+import com.android.onemedia.playback.LocalRenderer;
+import com.android.onemedia.playback.Renderer;
+import com.android.onemedia.playback.RequestUtils;
+
+import java.util.ArrayList;
+
+/**
+ * Test of MediaRouteProvider. Show a dummy provider with a simple interface for
+ * playing music.
+ */
+public class OneMediaRouteProvider extends MediaRouteService {
+ private static final String TAG = "OneMRP";
+ private static final boolean DEBUG = true;
+
+ private static final String TEST_DESTINATION_ID = "testDestination";
+ private static final String TEST_ROUTE_ID = "testRoute";
+
+ private Renderer mRenderer;
+ private RenderListener mRenderListener;
+ private PlaybackState mPlaybackState;
+ private Handler mHandler;
+
+ private OneStub mStub;
+
+ @Override
+ public void onCreate() {
+ mHandler = new Handler();
+ mRenderer = new LocalRenderer(this, null);
+ mRenderListener = new RenderListener();
+ PlaybackState.Builder bob = new PlaybackState.Builder();
+ bob.setActions(PlaybackState.ACTION_PAUSE | PlaybackState.ACTION_PLAY);
+ mPlaybackState = bob.build();
+
+ mRenderer.registerListener(mRenderListener);
+ }
+
+ @Override
+ public ClientSession onCreateClientSession(ClientInfo client) {
+ if (client.getUid() != Process.myUid()) {
+ // for testing purposes, only allow connections from this application
+ // since this provider is not fully featured
+ return null;
+ }
+ return new OneSession(client);
+ }
+
+ private final class OneSession extends ClientSession {
+ private final ClientInfo mClient;
+
+ public OneSession(ClientInfo client) {
+ mClient = client;
+ }
+
+ @Override
+ public boolean onStartDiscovery(DiscoveryRequest req, DiscoveryCallback callback) {
+ for (MediaRouteSelector selector : req.getSelectors()) {
+ if (isMatch(selector)) {
+ DestinationInfo destination = new DestinationInfo.Builder(
+ TEST_DESTINATION_ID, getServiceMetadata(), "OneMedia")
+ .setDescription("Test route from OneMedia app.")
+ .build();
+ ArrayList<RouteInfo> routes = new ArrayList<RouteInfo>();
+ routes.add(new RouteInfo.Builder(
+ TEST_ROUTE_ID, destination, selector).build());
+ callback.onDestinationFound(destination, routes);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void onStopDiscovery() {
+ }
+
+ @Override
+ public boolean onConnect(ConnectionRequest req, ConnectionCallback callback) {
+ if (req.getRoute().getId().equals(TEST_ROUTE_ID)) {
+ mStub = new OneStub();
+ ConnectionInfo connection = new ConnectionInfo.Builder(req.getRoute())
+ .setProtocolStub(MediaPlayerProtocol.class, mStub)
+ .build();
+ callback.onConnected(connection);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void onDisconnect() {
+ mStub = null;
+ }
+
+ private boolean isMatch(MediaRouteSelector selector) {
+ if (!selector.containsProtocol(MediaPlayerProtocol.class)) {
+ return false;
+ }
+ for (String protocol : selector.getRequiredProtocols()) {
+ if (!protocol.equals(MediaPlayerProtocol.class.getName())) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+
+ private final class OneStub extends MediaPlayerProtocol.Stub {
+ MediaInfo mMediaInfo;
+
+ public OneStub() {
+ super(mHandler);
+ }
+
+ @Override
+ public void onLoad(MediaInfo mediaInfo, boolean autoplay, long playPosition,
+ Bundle extras) {
+ if (DEBUG) {
+ Log.d(TAG, "Attempting to play " + mediaInfo.getContentId());
+ }
+ // look up the route and send a play command to it
+ mMediaInfo = mediaInfo;
+ Bundle bundle = new Bundle();
+ bundle.putString(RequestUtils.EXTRA_KEY_SOURCE, mediaInfo.getContentId());
+ mRenderer.setContent(bundle);
+ }
+
+ @Override
+ public void onPlay(Bundle extras) {
+ mRenderer.onPlay();
+ }
+
+ @Override
+ public void onPause(Bundle extras) {
+ mRenderer.onPause();
+ }
+ }
+
+ private class RenderListener implements Renderer.Listener {
+
+ @Override
+ public void onError(int type, int extra, Bundle extras, Throwable error) {
+ Log.d(TAG, "Sending onError with type " + type + " and extra " + extra);
+ sendStatusUpdate(PlaybackState.STATE_ERROR);
+ }
+
+ @Override
+ public void onStateChanged(int newState) {
+ long position = -1;
+ if (mRenderer != null) {
+ position = mRenderer.getSeekPosition();
+ }
+ int pbState;
+ float rate = 0;
+ String errorMsg = null;
+ switch (newState) {
+ case Renderer.STATE_ENDED:
+ case Renderer.STATE_STOPPED:
+ pbState = PlaybackState.STATE_STOPPED;
+ break;
+ case Renderer.STATE_INIT:
+ case Renderer.STATE_PREPARING:
+ pbState = PlaybackState.STATE_BUFFERING;
+ break;
+ case Renderer.STATE_ERROR:
+ pbState = PlaybackState.STATE_ERROR;
+ break;
+ case Renderer.STATE_PAUSED:
+ pbState = PlaybackState.STATE_PAUSED;
+ break;
+ case Renderer.STATE_PLAYING:
+ pbState = PlaybackState.STATE_PLAYING;
+ rate = 1;
+ break;
+ default:
+ pbState = PlaybackState.STATE_ERROR;
+ errorMsg = "unknown state";
+ break;
+ }
+ PlaybackState.Builder bob = new PlaybackState.Builder(mPlaybackState);
+ bob.setState(pbState, position, rate, SystemClock.elapsedRealtime());
+ bob.setErrorMessage(errorMsg);
+ mPlaybackState = bob.build();
+
+ sendStatusUpdate(mPlaybackState.getState());
+ }
+
+ @Override
+ public void onBufferingUpdate(int percent) {
+ }
+
+ @Override
+ public void onFocusLost() {
+ Log.d(TAG, "Focus lost, pausing");
+ // Don't update state here, we'll get a separate call to
+ // onStateChanged when it pauses
+ mRenderer.onPause();
+ }
+
+ @Override
+ public void onNextStarted() {
+ }
+
+ private void sendStatusUpdate(int state) {
+ if (mStub != null) {
+ MediaStatus status = new MediaStatus(1, mStub.mMediaInfo);
+ switch (state) {
+ case PlaybackState.STATE_BUFFERING:
+ case PlaybackState.STATE_FAST_FORWARDING:
+ case PlaybackState.STATE_REWINDING:
+ case PlaybackState.STATE_SKIPPING_TO_NEXT:
+ case PlaybackState.STATE_SKIPPING_TO_PREVIOUS:
+ status.setPlayerState(MediaStatus.PLAYER_STATE_BUFFERING);
+ break;
+ case PlaybackState.STATE_CONNECTING:
+ case PlaybackState.STATE_STOPPED:
+ status.setPlayerState(MediaStatus.PLAYER_STATE_IDLE);
+ break;
+ case PlaybackState.STATE_PAUSED:
+ status.setPlayerState(MediaStatus.PLAYER_STATE_PAUSED);
+ break;
+ case PlaybackState.STATE_PLAYING:
+ status.setPlayerState(MediaStatus.PLAYER_STATE_PLAYING);
+ break;
+ case PlaybackState.STATE_NONE:
+ case PlaybackState.STATE_ERROR:
+ default:
+ status.setPlayerState(MediaStatus.PLAYER_STATE_UNKNOWN);
+ break;
+ }
+ mStub.sendStatusUpdatedEvent(status, null);
+ }
+ }
+ }
+}
diff --git a/tests/Split/res/values-b+fr+Latn+CA/strings.xml b/tests/Split/res/values-b+fr+Latn+CA/strings.xml
new file mode 100644
index 0000000..108a135
--- /dev/null
+++ b/tests/Split/res/values-b+fr+Latn+CA/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="test">Bonsoir!</string>
+</resources>
diff --git a/tests/Split/res/values-fr-rCA/strings.xml b/tests/Split/res/values-fr-rCA/strings.xml
new file mode 100644
index 0000000..0837a68
--- /dev/null
+++ b/tests/Split/res/values-fr-rCA/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="test">Bonjour</string>
+</resources>
diff --git a/tests/TtsTests/src/com/android/speech/tts/MockableTextToSpeechService.java b/tests/TtsTests/src/com/android/speech/tts/MockableTextToSpeechService.java
index 20648a4..06fbcdc 100644
--- a/tests/TtsTests/src/com/android/speech/tts/MockableTextToSpeechService.java
+++ b/tests/TtsTests/src/com/android/speech/tts/MockableTextToSpeechService.java
@@ -19,8 +19,10 @@ package com.android.speech.tts;
import android.speech.tts.SynthesisCallback;
import android.speech.tts.SynthesisRequest;
import android.speech.tts.TextToSpeechService;
+import android.util.Log;
import java.util.ArrayList;
+import java.util.logging.Logger;
public class MockableTextToSpeechService extends TextToSpeechService {
diff --git a/tests/TtsTests/src/com/android/speech/tts/TextToSpeechTests.java b/tests/TtsTests/src/com/android/speech/tts/TextToSpeechTests.java
index 78d4f96..faf6827 100644
--- a/tests/TtsTests/src/com/android/speech/tts/TextToSpeechTests.java
+++ b/tests/TtsTests/src/com/android/speech/tts/TextToSpeechTests.java
@@ -43,11 +43,18 @@ public class TextToSpeechTests extends InstrumentationTestCase {
IDelegate passThrough = LittleMock.mock(IDelegate.class);
MockableTextToSpeechService.setMocker(passThrough);
+ // For the default voice selection
+ LittleMock.doReturn(TextToSpeech.LANG_COUNTRY_AVAILABLE).when(passThrough)
+ .onIsLanguageAvailable(
+ LittleMock.anyString(), LittleMock.anyString(), LittleMock.anyString());
+ LittleMock.doReturn(TextToSpeech.LANG_COUNTRY_AVAILABLE).when(passThrough)
+ .onLoadLanguage(
+ LittleMock.anyString(), LittleMock.anyString(), LittleMock.anyString());
+
blockingInitAndVerify(MOCK_ENGINE, TextToSpeech.SUCCESS);
assertEquals(MOCK_ENGINE, mTts.getCurrentEngine());
}
-
@Override
public void tearDown() {
if (mTts != null) {
@@ -77,7 +84,7 @@ public class TextToSpeechTests extends InstrumentationTestCase {
assertEquals(TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE, mTts.setLanguage(new Locale("eng", "USA", "variant")));
LittleMock.verify(delegate, LittleMock.anyTimes()).onIsLanguageAvailable(
"eng", "USA", "variant");
- LittleMock.verify(delegate, LittleMock.times(1)).onLoadLanguage(
+ LittleMock.verify(delegate, LittleMock.anyTimes()).onLoadLanguage(
"eng", "USA", "variant");
}
@@ -147,26 +154,34 @@ public class TextToSpeechTests extends InstrumentationTestCase {
public void testDefaultLanguage_setsVoiceName() throws Exception {
IDelegate delegate = LittleMock.mock(IDelegate.class);
MockableTextToSpeechService.setMocker(delegate);
+ Locale defaultLocale = Locale.getDefault();
// ---------------------------------------------------------
// Test that default language also sets the default voice
// name
- LittleMock.doReturn(TextToSpeech.LANG_COUNTRY_AVAILABLE).when(delegate).onIsLanguageAvailable(
- LittleMock.anyString(), LittleMock.anyString(), LittleMock.anyString());
- LittleMock.doReturn(TextToSpeech.LANG_COUNTRY_AVAILABLE).when(delegate).onLoadLanguage(
- LittleMock.anyString(), LittleMock.anyString(), LittleMock.anyString());
+ LittleMock.doReturn(TextToSpeech.LANG_COUNTRY_AVAILABLE).
+ when(delegate).onIsLanguageAvailable(
+ defaultLocale.getISO3Language(),
+ defaultLocale.getISO3Country().toUpperCase(),
+ defaultLocale.getVariant());
+ LittleMock.doReturn(TextToSpeech.LANG_COUNTRY_AVAILABLE).
+ when(delegate).onLoadLanguage(
+ defaultLocale.getISO3Language(),
+ defaultLocale.getISO3Country(),
+ defaultLocale.getVariant());
+
blockingCallSpeak("foo bar", delegate);
ArgumentCaptor<SynthesisRequest> req = LittleMock.createCaptor();
LittleMock.verify(delegate, LittleMock.times(1)).onSynthesizeText(req.capture(),
LittleMock.<SynthesisCallback>anyObject());
- Locale defaultLocale = Locale.getDefault();
assertEquals(defaultLocale.getISO3Language(), req.getValue().getLanguage());
assertEquals(defaultLocale.getISO3Country(), req.getValue().getCountry());
assertEquals("", req.getValue().getVariant());
assertEquals(defaultLocale.toLanguageTag(), req.getValue().getVoiceName());
}
+
private void blockingCallSpeak(String speech, IDelegate mock) throws
InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
diff --git a/tests/UsageStatsTest/src/com/android/tests/usagestats/UsageLogActivity.java b/tests/UsageStatsTest/src/com/android/tests/usagestats/UsageLogActivity.java
index d9a3b61..8e6daea 100644
--- a/tests/UsageStatsTest/src/com/android/tests/usagestats/UsageLogActivity.java
+++ b/tests/UsageStatsTest/src/com/android/tests/usagestats/UsageLogActivity.java
@@ -166,6 +166,9 @@ public class UsageLogActivity extends ListActivity implements Runnable {
case UsageEvents.Event.CONFIGURATION_CHANGE:
return "Config change";
+ case UsageEvents.Event.INTERACTION:
+ return "Interaction";
+
default:
return "Unknown: " + eventType;
}
diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable03.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable03.xml
index a0b0e00..7cddda1 100644
--- a/tests/VectorDrawableTest/res/drawable/vector_drawable03.xml
+++ b/tests/VectorDrawableTest/res/drawable/vector_drawable03.xml
@@ -14,10 +14,10 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:height="64dp"
- android:width="64dp"
- android:viewportHeight="12.25"
- android:viewportWidth="7.30625" >
+ android:height="64dp"
+ android:viewportHeight="12.25"
+ android:viewportWidth="7.30625"
+ android:width="64dp" >
<group
android:pivotX="3.65"
@@ -31,14 +31,18 @@
l 0, 12.25
l-7.3, 0
z" />
- </group>
- <group>
- <path
- android:name="one"
- android:fillColor="#ff88ff"
- android:pathData="M 1.215625,9.5l 1.9375,0.0 0.0-6.671875-2.109375,0.421875 0.0-1.078125
+
+ <group
+ android:pivotX="3.65"
+ android:pivotY="6.125"
+ android:rotation="30" >
+ <path
+ android:name="one"
+ android:fillColor="#ff88ff"
+ android:pathData="M 1.215625,9.5l 1.9375,0.0 0.0-6.671875-2.109375,0.421875 0.0-1.078125
l 2.09375-0.421875 1.1874998,0.0 0.0,7.75 1.9375,0.0 0.0,1.0
l-5.046875,0.0 0.0-1.0Z" />
+ </group>
</group>
<group
android:pivotX="3.65"
@@ -52,12 +56,15 @@
l 0, 6.125
l-7.3, 0
z" />
- </group>
- <group>
- <path
- android:name="two"
- android:fillColor="#ff88ff"
- android:pathData="M 2.534375,9.6875l 4.140625,0.0 0.0,1.0-5.5625,0.0 0.0-1.0q 0.671875-0.6875 1.828125-1.859375
+
+ <group
+ android:pivotX="3.65"
+ android:pivotY="6.125"
+ android:rotation="30" >
+ <path
+ android:name="two"
+ android:fillColor="#ff88ff"
+ android:pathData="M 2.534375,9.6875l 4.140625,0.0 0.0,1.0-5.5625,0.0 0.0-1.0q 0.671875-0.6875 1.828125-1.859375
q 1.1718752-1.1875 1.4687502-1.53125 0.578125-0.625 0.796875-1.0625
q 0.234375-0.453125 0.234375-0.875 0.0-0.703125-0.5-1.140625
q-0.484375-0.4375-1.2656252-0.4375-0.5625,0.0-1.1875,0.1875
@@ -66,6 +73,7 @@
q 0.8125,0.671875 0.8125,1.8125 0.0,0.53125-0.203125,1.015625
q-0.203125,0.484375-0.734375,1.140625-0.15625,0.171875-0.9375,0.984375
q-0.78125024,0.8125-2.2187502,2.265625Z" />
+ </group>
</group>
</vector> \ No newline at end of file
diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable_scale0.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable_scale0.xml
new file mode 100644
index 0000000..88bf777
--- /dev/null
+++ b/tests/VectorDrawableTest/res/drawable/vector_drawable_scale0.xml
@@ -0,0 +1,57 @@
+<!--
+ Copyright (C) 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="64dp"
+ android:viewportHeight="200"
+ android:viewportWidth="200"
+ android:width="64dp" >
+
+ <group>
+ <path
+ android:name="background1"
+ android:fillColor="#FF000000"
+ android:pathData="M 0,0 l 100,0 l 0, 100 l -100, 0 z" />
+ <path
+ android:name="background2"
+ android:fillColor="#FF000000"
+ android:pathData="M 100,100 l 100,0 l 0, 100 l -100, 0 z" />
+ </group>
+ <group
+ android:pivotX="0"
+ android:pivotY="0"
+ android:rotation="90" >
+ <group
+ android:scaleX="1.5"
+ android:scaleY="1" >
+ <group
+ android:pivotX="0"
+ android:pivotY="0"
+ android:rotation="-90" >
+ <group
+ android:scaleX="1.5"
+ android:scaleY="1" >
+ <path
+ android:name="twoLines"
+ android:fillColor="#FFFF0000"
+ android:pathData="M 100, 0 l 0, 100, -100, 0 z"
+ android:strokeColor="#FF00FF00"
+ android:strokeWidth="10" />
+ </group>
+ </group>
+ </group>
+ </group>
+
+</vector> \ No newline at end of file
diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable_scale1.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable_scale1.xml
new file mode 100644
index 0000000..530c73b
--- /dev/null
+++ b/tests/VectorDrawableTest/res/drawable/vector_drawable_scale1.xml
@@ -0,0 +1,52 @@
+<!--
+ Copyright (C) 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="64dp"
+ android:viewportHeight="200"
+ android:viewportWidth="200"
+ android:width="64dp" >
+
+ <group>
+ <path
+ android:name="background1"
+ android:fillColor="#FF000000"
+ android:pathData="M 0,0 l 100,0 l 0, 100 l -100, 0 z" />
+ <path
+ android:name="background2"
+ android:fillColor="#FF000000"
+ android:pathData="M 100,100 l 100,0 l 0, 100 l -100, 0 z" />
+ </group>
+ <group
+ android:scaleX="-1"
+ android:scaleY="-1" >
+ <group
+ android:scaleX="-1"
+ android:scaleY="-1" >
+ <group
+ android:pivotX="100"
+ android:pivotY="100"
+ android:rotation="45" >
+ <path
+ android:name="twoLines"
+ android:fillColor="#FFFF0000"
+ android:pathData="M 100, 0 l 0, 100, -100, 0 z"
+ android:strokeColor="#FF00FF00"
+ android:strokeWidth="10" />
+ </group>
+ </group>
+ </group>
+
+</vector> \ No newline at end of file
diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable_scale2.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable_scale2.xml
new file mode 100644
index 0000000..200eb61
--- /dev/null
+++ b/tests/VectorDrawableTest/res/drawable/vector_drawable_scale2.xml
@@ -0,0 +1,48 @@
+<!--
+ Copyright (C) 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="64dp"
+ android:viewportHeight="200"
+ android:viewportWidth="200"
+ android:width="64dp" >
+
+ <group>
+ <path
+ android:name="background1"
+ android:fillColor="#FF000000"
+ android:pathData="M 0,0 l 100,0 l 0, 100 l -100, 0 z" />
+ <path
+ android:name="background2"
+ android:fillColor="#FF000000"
+ android:pathData="M 100,100 l 100,0 l 0, 100 l -100, 0 z" />
+ </group>
+ <group
+ android:scaleX="2"
+ android:scaleY="0.5" >
+ <group
+ android:pivotX="100"
+ android:pivotY="100"
+ android:rotation="45" >
+ <path
+ android:name="twoLines"
+ android:fillColor="#FFFF0000"
+ android:pathData="M 100, 0 l 0, 100, -100, 0 z"
+ android:strokeColor="#FF00FF00"
+ android:strokeWidth="10" />
+ </group>
+ </group>
+
+</vector> \ No newline at end of file
diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable_scale3.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable_scale3.xml
new file mode 100644
index 0000000..a40fc9c
--- /dev/null
+++ b/tests/VectorDrawableTest/res/drawable/vector_drawable_scale3.xml
@@ -0,0 +1,62 @@
+<!--
+ Copyright (C) 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="64dp"
+ android:viewportHeight="200"
+ android:viewportWidth="200"
+ android:width="64dp" >
+
+ <group>
+ <path
+ android:name="background1"
+ android:fillColor="#FF000000"
+ android:pathData="M 0,0 l 100,0 l 0, 100 l -100, 0 z" />
+ <path
+ android:name="background2"
+ android:fillColor="#FF000000"
+ android:pathData="M 100,100 l 100,0 l 0, 100 l -100, 0 z" />
+ </group>
+ <group
+ android:pivotX="0"
+ android:pivotY="0"
+ android:rotation="45" >
+ <group
+ android:pivotX="0"
+ android:pivotY="0"
+ android:rotation="90" >
+ <group
+ android:scaleX="1.5"
+ android:scaleY="1" >
+ <group
+ android:pivotX="0"
+ android:pivotY="0"
+ android:rotation="-90" >
+ <group
+ android:scaleX="1.5"
+ android:scaleY="1" >
+ <path
+ android:name="twoLines"
+ android:fillColor="#FFFF0000"
+ android:pathData="M 100, 0 l 0, 100, -100, 0 z"
+ android:strokeColor="#FF00FF00"
+ android:strokeWidth="10" />
+ </group>
+ </group>
+ </group>
+ </group>
+ </group>
+
+</vector> \ No newline at end of file
diff --git a/tests/VectorDrawableTest/src/com/android/test/dynamic/AnimatedVectorDrawableTest.java b/tests/VectorDrawableTest/src/com/android/test/dynamic/AnimatedVectorDrawableTest.java
index ecc7782..56c8119 100644
--- a/tests/VectorDrawableTest/src/com/android/test/dynamic/AnimatedVectorDrawableTest.java
+++ b/tests/VectorDrawableTest/src/com/android/test/dynamic/AnimatedVectorDrawableTest.java
@@ -14,9 +14,12 @@
package com.android.test.dynamic;
+import android.animation.Animator;
+import android.animation.Animator.AnimatorListener;
import android.app.Activity;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.os.Bundle;
+import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.GridLayout;
@@ -52,6 +55,26 @@ public class AnimatedVectorDrawableTest extends Activity implements View.OnClick
button.setWidth(400);
button.setHeight(400);
button.setBackgroundResource(icon[i]);
+ AnimatedVectorDrawable d = (AnimatedVectorDrawable) button.getBackground();
+ d.addListener(new AnimatorListener() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ Log.v(LOGCAT, "Animator start");
+ }
+ @Override
+ public void onAnimationRepeat(Animator animation) {
+ Log.v(LOGCAT, "Animator repeat");
+ }
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ Log.v(LOGCAT, "Animator end");
+ }
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ Log.v(LOGCAT, "Animator cancel");
+ }
+ });
+
container.addView(button);
button.setOnClickListener(this);
}
diff --git a/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawablePerformance.java b/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawablePerformance.java
index d029050..b4a93f6 100644
--- a/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawablePerformance.java
+++ b/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawablePerformance.java
@@ -65,6 +65,10 @@ public class VectorDrawablePerformance extends Activity {
R.drawable.vector_drawable28,
R.drawable.vector_drawable29,
R.drawable.vector_drawable30,
+ R.drawable.vector_drawable_scale0,
+ R.drawable.vector_drawable_scale1,
+ R.drawable.vector_drawable_scale2,
+ R.drawable.vector_drawable_scale3,
};
public static VectorDrawable create(Resources resources, int rid) {
diff --git a/tests/VoiceInteraction/AndroidManifest.xml b/tests/VoiceInteraction/AndroidManifest.xml
index 06d31a4..36d5d98 100644
--- a/tests/VoiceInteraction/AndroidManifest.xml
+++ b/tests/VoiceInteraction/AndroidManifest.xml
@@ -12,10 +12,19 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
- <activity android:name="SettingsActivity"
- android:label="Voice Interaction Settings"
+ <activity android:name="AssistProxyActivity"
+ android:label="Test Assist Proxy"
+ android:theme="@android:style/Theme.NoDisplay"
android:excludeFromRecents="true"
- android:noHistory="true">
+ android:noHistory="true"
+ android:taskAffinity="">
+ <intent-filter>
+ <action android:name="android.intent.action.ASSIST" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+ <activity android:name="SettingsActivity"
+ android:label="Voice Interaction Settings">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
@@ -44,7 +53,7 @@
<meta-data android:name="android.speech" android:resource="@xml/recognition_service" />
</service>
<activity android:name="TestInteractionActivity" android:label="Voice Interaction Target"
- android:theme="@android:style/Theme.Material.Light.Voice">
+ android:theme="@android:style/Theme.Material.Light">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
diff --git a/tests/VoiceInteraction/res/layout/main.xml b/tests/VoiceInteraction/res/layout/main.xml
index 3d7a418..092d37d 100644
--- a/tests/VoiceInteraction/res/layout/main.xml
+++ b/tests/VoiceInteraction/res/layout/main.xml
@@ -26,6 +26,14 @@
android:text="@string/start"
/>
+ <com.android.test.voiceinteraction.AsyncStructure
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingTop="64dp"
+ android:paddingBottom="64dp"
+ android:text="@string/asyncStructure"
+ />
+
</LinearLayout>
diff --git a/tests/VoiceInteraction/res/layout/test_interaction.xml b/tests/VoiceInteraction/res/layout/test_interaction.xml
index d55736f..8c8151d 100644
--- a/tests/VoiceInteraction/res/layout/test_interaction.xml
+++ b/tests/VoiceInteraction/res/layout/test_interaction.xml
@@ -32,7 +32,6 @@
android:layout_weight="1"
android:layout_marginTop="16dp"
android:textAppearance="?android:attr/textAppearanceMedium"
- android:textColor="#ffffffff"
/>
<Button android:id="@+id/complete"
@@ -42,6 +41,13 @@
android:text="@string/completeVoice"
/>
+ <Button android:id="@+id/pick"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="16dp"
+ android:text="@string/pickVoice"
+ />
+
<Button android:id="@+id/abort"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -49,4 +55,11 @@
android:text="@string/abortVoice"
/>
+ <Button android:id="@+id/cancel"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="16dp"
+ android:text="@string/cancelVoice"
+ />
+
</LinearLayout>
diff --git a/tests/VoiceInteraction/res/layout/voice_interaction_session.xml b/tests/VoiceInteraction/res/layout/voice_interaction_session.xml
index 002f350..d44afb0 100644
--- a/tests/VoiceInteraction/res/layout/voice_interaction_session.xml
+++ b/tests/VoiceInteraction/res/layout/voice_interaction_session.xml
@@ -15,24 +15,47 @@
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="match_parent"
- android:fitsSystemWindows="true">
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
- <FrameLayout android:layout_width="fill_parent"
+ <com.android.test.voiceinteraction.AssistVisualizer android:id="@+id/assist_visualizer"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+ <FrameLayout android:layout_width="match_parent"
android:layout_height="match_parent"
- android:padding="8dp">
+ android:fitsSystemWindows="true">
+
+ <LinearLayout android:id="@+id/top_content"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top"
+ android:orientation="vertical"
+ android:background="#ffffffff"
+ android:elevation="8dp"
+ >
+ <Button android:id="@+id/start"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top|right"
+ android:text="@string/start"
+ />
+ <ImageView android:id="@+id/screenshot"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
+ </LinearLayout>
- <LinearLayout android:id="@+id/content"
- android:layout_width="fill_parent"
- android:layout_height="match_parent"
+ <LinearLayout android:id="@+id/bottom_content"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom"
android:orientation="vertical"
android:background="#ffffffff"
android:elevation="8dp"
>
<TextView android:id="@+id/text"
- android:layout_width="fill_parent"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:textAppearance="?android:attr/textAppearanceMedium"
@@ -40,11 +63,6 @@
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="horizontal">
- <Button android:id="@+id/start"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/start"
- />
<Button android:id="@+id/confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/tests/VoiceInteraction/res/values/strings.xml b/tests/VoiceInteraction/res/values/strings.xml
index 7eec90c..942c931 100644
--- a/tests/VoiceInteraction/res/values/strings.xml
+++ b/tests/VoiceInteraction/res/values/strings.xml
@@ -17,11 +17,13 @@
<resources>
<string name="start">Start</string>
+ <string name="asyncStructure">(Async structure goes here)</string>
<string name="confirm">Confirm</string>
<string name="abort">Abort</string>
<string name="complete">Complete</string>
<string name="abortVoice">Abort Voice</string>
<string name="completeVoice">Complete Voice</string>
+ <string name="pickVoice">Pick Voice</string>
+ <string name="cancelVoice">Cancel</string>
</resources>
-
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistProxyActivity.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistProxyActivity.java
new file mode 100644
index 0000000..d0c5e36
--- /dev/null
+++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistProxyActivity.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2015 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.test.voiceinteraction;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+
+public class AssistProxyActivity extends Activity {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ finish();
+ Intent intent = new Intent(this, MainInteractionService.class);
+ intent.setAction(Intent.ACTION_ASSIST);
+ startService(intent);
+ }
+}
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java
new file mode 100644
index 0000000..8a72341
--- /dev/null
+++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2015 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.test.voiceinteraction;
+
+import android.annotation.Nullable;
+import android.app.AssistStructure;
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.View;
+
+import java.util.ArrayList;
+
+public class AssistVisualizer extends View {
+ static final String TAG = "AssistVisualizer";
+
+ AssistStructure mAssistStructure;
+ final Paint mFramePaint = new Paint();
+ final ArrayList<Rect> mTextRects = new ArrayList<>();
+ final int[] mTmpLocation = new int[2];
+
+ public AssistVisualizer(Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ setWillNotDraw(false);
+ mFramePaint.setColor(0xffff0000);
+ mFramePaint.setStyle(Paint.Style.STROKE);
+ mFramePaint.setStrokeWidth(0);
+ }
+
+ public void setAssistStructure(AssistStructure as) {
+ mAssistStructure = as;
+ mAssistStructure.dump();
+ mTextRects.clear();
+ final int N = as.getWindowNodeCount();
+ if (N > 0) {
+ for (int i=0; i<N; i++) {
+ AssistStructure.WindowNode windowNode = as.getWindowNodeAt(i);
+ buildTextRects(windowNode.getRootViewNode(), windowNode.getLeft(),
+ windowNode.getTop());
+ }
+ }
+ Log.d(TAG, "Building text rects in " + this + ": found " + mTextRects.size());
+ invalidate();
+ }
+
+ public void clearAssistData() {
+ mAssistStructure = null;
+ mTextRects.clear();
+ }
+
+ void buildTextRects(AssistStructure.ViewNode root, int parentLeft, int parentTop) {
+ if (root.getVisibility() != View.VISIBLE) {
+ return;
+ }
+ int left = parentLeft+root.getLeft();
+ int top = parentTop+root.getTop();
+ if (root.getText() != null || root.getContentDescription() != null) {
+ Rect r = new Rect(left, top, left+root.getWidth(), top+root.getHeight());
+ Log.d(TAG, "View " + root.getClassName() + " " + left + "," + top + " tr "
+ + r.toShortString() + ": "
+ + (root.getText() != null ? root.getText() : root.getContentDescription()));
+ mTextRects.add(r);
+ }
+ final int N = root.getChildCount();
+ if (N > 0) {
+ left -= root.getScrollX();
+ top -= root.getScrollY();
+ for (int i=0; i<N; i++) {
+ AssistStructure.ViewNode child = root.getChildAt(i);
+ buildTextRects(child, left, top);
+ }
+ }
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ getLocationOnScreen(mTmpLocation);
+ final int N = mTextRects.size();
+ Log.d(TAG, "Drawing text rects in " + this + ": found " + mTextRects.size());
+ for (int i=0; i<N; i++) {
+ Rect r = mTextRects.get(i);
+ canvas.drawRect(r.left-mTmpLocation[0], r.top-mTmpLocation[1],
+ r.right-mTmpLocation[0], r.bottom-mTmpLocation[1], mFramePaint);
+ }
+ }
+}
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AsyncStructure.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AsyncStructure.java
new file mode 100644
index 0000000..73e04e5
--- /dev/null
+++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AsyncStructure.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2015 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.test.voiceinteraction;
+
+import android.annotation.Nullable;
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewAssistStructure;
+import android.widget.TextView;
+
+/**
+ * Test for asynchronously creating additional assist structure.
+ */
+public class AsyncStructure extends TextView {
+ public AsyncStructure(Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ public void onProvideVirtualAssistStructure(ViewAssistStructure structure) {
+ structure.setChildCount(1);
+ final ViewAssistStructure child = structure.asyncNewChild(0);
+ final int width = getWidth();
+ final int height = getHeight();
+ (new Thread() {
+ @Override
+ public void run() {
+ // Simulate taking a long time to build this.
+ try {
+ sleep(2000);
+ } catch (InterruptedException e) {
+ }
+ child.setClassName(AsyncStructure.class.getName());
+ child.setVisibility(View.VISIBLE);
+ child.setDimens(width / 4, height / 4, 0, 0, width / 2, height / 2);
+ child.setEnabled(true);
+ child.setContentDescription("This is some async content");
+ child.setText("We could have lots and lots of async text!");
+ child.asyncCommit();
+ }
+ }).start();
+ }
+}
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java
index 4639114..15196b4 100644
--- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java
+++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java
@@ -16,6 +16,7 @@
package com.android.test.voiceinteraction;
+import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.service.voice.AlwaysOnHotwordDetector;
@@ -74,9 +75,14 @@ public class MainInteractionService extends VoiceInteractionService {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
- Bundle args = new Bundle();
- args.putParcelable("intent", new Intent(this, TestInteractionActivity.class));
- startSession(args);
+ if (isActiveService(this, new ComponentName(this, getClass()))) {
+ Bundle args = new Bundle();
+ args.putParcelable("intent", new Intent(this, TestInteractionActivity.class));
+ args.putBundle("assist", intent.getExtras());
+ startSession(args, START_WITH_ASSIST|START_WITH_SCREENSHOT);
+ } else {
+ Log.w(TAG, "Not starting -- not current voice interaction service");
+ }
stopSelf(startId);
return START_NOT_STICKY;
}
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java
index d20906e..ec727c4 100644
--- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java
+++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java
@@ -16,13 +16,18 @@
package com.android.test.voiceinteraction;
+import android.app.AssistContent;
+import android.app.AssistStructure;
+import android.app.VoiceInteractor;
import android.content.Context;
import android.content.Intent;
+import android.graphics.Bitmap;
import android.os.Bundle;
import android.service.voice.VoiceInteractionSession;
import android.util.Log;
import android.view.View;
import android.widget.Button;
+import android.widget.ImageView;
import android.widget.TextView;
public class MainInteractionSession extends VoiceInteractionSession
@@ -31,20 +36,30 @@ public class MainInteractionSession extends VoiceInteractionSession
Intent mStartIntent;
View mContentView;
+ AssistVisualizer mAssistVisualizer;
+ View mTopContent;
+ View mBottomContent;
TextView mText;
Button mStartButton;
+ ImageView mScreenshot;
Button mConfirmButton;
Button mCompleteButton;
Button mAbortButton;
+ AssistStructure mAssistStructure;
+
static final int STATE_IDLE = 0;
static final int STATE_LAUNCHING = 1;
static final int STATE_CONFIRM = 2;
- static final int STATE_COMMAND = 3;
- static final int STATE_ABORT_VOICE = 4;
- static final int STATE_COMPLETE_VOICE = 5;
+ static final int STATE_PICK_OPTION = 3;
+ static final int STATE_COMMAND = 4;
+ static final int STATE_ABORT_VOICE = 5;
+ static final int STATE_COMPLETE_VOICE = 6;
+ static final int STATE_DONE=7;
int mState = STATE_IDLE;
+ VoiceInteractor.PickOptionRequest.Option[] mPendingOptions;
+ CharSequence mPendingPrompt;
Request mPendingRequest;
MainInteractionSession(Context context) {
@@ -52,31 +67,115 @@ public class MainInteractionSession extends VoiceInteractionSession
}
@Override
- public void onCreate(Bundle args) {
+ public void onCreate(Bundle args, int startFlags) {
super.onCreate(args);
- showWindow();
+ }
+
+ @Override
+ public void onShow(Bundle args, int showFlags) {
+ super.onShow(args, showFlags);
+ mState = STATE_IDLE;
mStartIntent = args.getParcelable("intent");
+ if (mAssistVisualizer != null) {
+ mAssistVisualizer.clearAssistData();
+ }
+ onHandleScreenshot(null);
+ updateState();
+ }
+
+ @Override
+ public void onHide() {
+ super.onHide();
+ if (mAssistVisualizer != null) {
+ mAssistVisualizer.clearAssistData();
+ }
+ mState = STATE_DONE;
+ updateState();
}
@Override
public View onCreateContentView() {
mContentView = getLayoutInflater().inflate(R.layout.voice_interaction_session, null);
+ mAssistVisualizer = (AssistVisualizer)mContentView.findViewById(R.id.assist_visualizer);
+ if (mAssistStructure != null) {
+ mAssistVisualizer.setAssistStructure(mAssistStructure);
+ }
+ mTopContent = mContentView.findViewById(R.id.top_content);
+ mBottomContent = mContentView.findViewById(R.id.bottom_content);
mText = (TextView)mContentView.findViewById(R.id.text);
mStartButton = (Button)mContentView.findViewById(R.id.start);
mStartButton.setOnClickListener(this);
+ mScreenshot = (ImageView)mContentView.findViewById(R.id.screenshot);
mConfirmButton = (Button)mContentView.findViewById(R.id.confirm);
mConfirmButton.setOnClickListener(this);
mCompleteButton = (Button)mContentView.findViewById(R.id.complete);
mCompleteButton.setOnClickListener(this);
mAbortButton = (Button)mContentView.findViewById(R.id.abort);
mAbortButton.setOnClickListener(this);
- updateState();
return mContentView;
}
+ @Override
+ public void onHandleAssist(Bundle assistBundle) {
+ if (assistBundle != null) {
+ parseAssistData(assistBundle);
+ } else {
+ Log.i(TAG, "onHandleAssist: NO ASSIST BUNDLE");
+ }
+ }
+
+ @Override
+ public void onHandleScreenshot(Bitmap screenshot) {
+ if (screenshot != null) {
+ mScreenshot.setImageBitmap(screenshot);
+ mScreenshot.setAdjustViewBounds(true);
+ mScreenshot.setMaxWidth(screenshot.getWidth()/3);
+ mScreenshot.setMaxHeight(screenshot.getHeight()/3);
+ } else {
+ mScreenshot.setImageDrawable(null);
+ }
+ }
+
+ void parseAssistData(Bundle assistBundle) {
+ if (assistBundle != null) {
+ Bundle assistContext = assistBundle.getBundle(Intent.EXTRA_ASSIST_CONTEXT);
+ if (assistContext != null) {
+ mAssistStructure = AssistStructure.getAssistStructure(assistContext);
+ if (mAssistStructure != null) {
+ if (mAssistVisualizer != null) {
+ mAssistVisualizer.setAssistStructure(mAssistStructure);
+ }
+ }
+ AssistContent content = AssistContent.getAssistContent(assistContext);
+ if (content != null) {
+ Log.i(TAG, "Assist intent: " + content.getIntent());
+ Log.i(TAG, "Assist clipdata: " + content.getClipData());
+ }
+ return;
+ }
+ }
+ if (mAssistVisualizer != null) {
+ mAssistVisualizer.clearAssistData();
+ }
+ }
+
void updateState() {
+ if (mState == STATE_IDLE) {
+ mTopContent.setVisibility(View.VISIBLE);
+ mBottomContent.setVisibility(View.GONE);
+ mAssistVisualizer.setVisibility(View.VISIBLE);
+ } else if (mState == STATE_DONE) {
+ mTopContent.setVisibility(View.GONE);
+ mBottomContent.setVisibility(View.GONE);
+ mAssistVisualizer.setVisibility(View.GONE);
+ } else {
+ mTopContent.setVisibility(View.GONE);
+ mBottomContent.setVisibility(View.VISIBLE);
+ mAssistVisualizer.setVisibility(View.GONE);
+ }
mStartButton.setEnabled(mState == STATE_IDLE);
- mConfirmButton.setEnabled(mState == STATE_CONFIRM || mState == STATE_COMMAND);
+ mConfirmButton.setEnabled(mState == STATE_CONFIRM || mState == STATE_PICK_OPTION
+ || mState == STATE_COMMAND);
mAbortButton.setEnabled(mState == STATE_ABORT_VOICE);
mCompleteButton.setEnabled(mState == STATE_COMPLETE_VOICE);
}
@@ -89,22 +188,48 @@ public class MainInteractionSession extends VoiceInteractionSession
} else if (v == mConfirmButton) {
if (mState == STATE_CONFIRM) {
mPendingRequest.sendConfirmResult(true, null);
- } else {
+ mPendingRequest = null;
+ mState = STATE_LAUNCHING;
+ } else if (mState == STATE_PICK_OPTION) {
+ int numReturn = mPendingOptions.length/2;
+ if (numReturn <= 0) {
+ numReturn = 1;
+ }
+ VoiceInteractor.PickOptionRequest.Option[] picked
+ = new VoiceInteractor.PickOptionRequest.Option[numReturn];
+ for (int i=0; i<picked.length; i++) {
+ picked[i] = mPendingOptions[i*2];
+ }
+ mPendingOptions = picked;
+ if (picked.length <= 1) {
+ mPendingRequest.sendPickOptionResult(true, picked, null);
+ mPendingRequest = null;
+ mState = STATE_LAUNCHING;
+ } else {
+ mPendingRequest.sendPickOptionResult(false, picked, null);
+ updatePickText();
+ }
+ } else if (mPendingRequest != null) {
mPendingRequest.sendCommandResult(true, null);
+ mPendingRequest = null;
+ mState = STATE_LAUNCHING;
}
- mPendingRequest = null;
- mState = STATE_IDLE;
- updateState();
} else if (v == mAbortButton) {
mPendingRequest.sendAbortVoiceResult(null);
mPendingRequest = null;
- mState = STATE_IDLE;
- updateState();
} else if (v== mCompleteButton) {
mPendingRequest.sendCompleteVoiceResult(null);
mPendingRequest = null;
- mState = STATE_IDLE;
- updateState();
+ }
+ updateState();
+ }
+
+ @Override
+ public void onComputeInsets(Insets outInsets) {
+ super.onComputeInsets(outInsets);
+ if (mState != STATE_IDLE) {
+ outInsets.contentInsets.top = mBottomContent.getTop();
+ outInsets.touchableInsets = Insets.TOUCHABLE_INSETS_CONTENT;
}
}
@@ -117,13 +242,40 @@ public class MainInteractionSession extends VoiceInteractionSession
public void onConfirm(Caller caller, Request request, CharSequence prompt, Bundle extras) {
Log.i(TAG, "onConfirm: prompt=" + prompt + " extras=" + extras);
mText.setText(prompt);
- mStartButton.setText("Confirm");
+ mConfirmButton.setText("Confirm");
mPendingRequest = request;
+ mPendingPrompt = prompt;
mState = STATE_CONFIRM;
updateState();
}
@Override
+ public void onPickOption(Caller caller, Request request, CharSequence prompt,
+ VoiceInteractor.PickOptionRequest.Option[] options, Bundle extras) {
+ Log.i(TAG, "onPickOption: prompt=" + prompt + " options=" + options + " extras=" + extras);
+ mConfirmButton.setText("Pick Option");
+ mPendingRequest = request;
+ mPendingPrompt = prompt;
+ mPendingOptions = options;
+ mState = STATE_PICK_OPTION;
+ updatePickText();
+ updateState();
+ }
+
+ void updatePickText() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(mPendingPrompt);
+ sb.append(": ");
+ for (int i=0; i<mPendingOptions.length; i++) {
+ if (i > 0) {
+ sb.append(", ");
+ }
+ sb.append(mPendingOptions[i].getLabel());
+ }
+ mText.setText(sb.toString());
+ }
+
+ @Override
public void onCompleteVoice(Caller caller, Request request, CharSequence message, Bundle extras) {
Log.i(TAG, "onCompleteVoice: message=" + message + " extras=" + extras);
mText.setText(message);
@@ -145,7 +297,7 @@ public class MainInteractionSession extends VoiceInteractionSession
public void onCommand(Caller caller, Request request, String command, Bundle extras) {
Log.i(TAG, "onCommand: command=" + command + " extras=" + extras);
mText.setText("Command: " + command);
- mStartButton.setText("Finish Command");
+ mConfirmButton.setText("Finish Command");
mPendingRequest = request;
mState = STATE_COMMAND;
updateState();
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java
index d64eefa..e195c30 100644
--- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java
+++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java
@@ -18,19 +18,26 @@ package com.android.test.voiceinteraction;
import android.app.Activity;
import android.app.VoiceInteractor;
+import android.content.ComponentName;
import android.os.Bundle;
+import android.service.voice.VoiceInteractionService;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
+import android.widget.TextView;
public class TestInteractionActivity extends Activity implements View.OnClickListener {
static final String TAG = "TestInteractionActivity";
VoiceInteractor mInteractor;
+ VoiceInteractor.Request mCurrentRequest = null;
+ TextView mLog;
Button mAbortButton;
Button mCompleteButton;
+ Button mPickButton;
+ Button mCancelButton;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -42,19 +49,26 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis
return;
}
+ if (!VoiceInteractionService.isActiveService(this,
+ new ComponentName(this, MainInteractionService.class))) {
+ Log.w(TAG, "Not current voice interactor!");
+ finish();
+ return;
+ }
+
setContentView(R.layout.test_interaction);
+ mLog = (TextView)findViewById(R.id.log);
mAbortButton = (Button)findViewById(R.id.abort);
mAbortButton.setOnClickListener(this);
mCompleteButton = (Button)findViewById(R.id.complete);
mCompleteButton.setOnClickListener(this);
-
- // Framework should take care of these.
- getWindow().setGravity(Gravity.TOP);
- getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.WRAP_CONTENT);
+ mPickButton = (Button)findViewById(R.id.pick);
+ mPickButton.setOnClickListener(this);
+ mCancelButton = (Button)findViewById(R.id.cancel);
+ mCancelButton.setOnClickListener(this);
mInteractor = getVoiceInteractor();
- VoiceInteractor.ConfirmationRequest req = new VoiceInteractor.ConfirmationRequest(
+ mCurrentRequest = new VoiceInteractor.ConfirmationRequest(
"This is a confirmation", null) {
@Override
public void onCancel() {
@@ -68,7 +82,7 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis
getActivity().finish();
}
};
- mInteractor.submitRequest(req);
+ mInteractor.submitRequest(mCurrentRequest);
}
@Override
@@ -84,11 +98,13 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis
@Override
public void onCancel() {
Log.i(TAG, "Canceled!");
+ mLog.append("Canceled abort\n");
}
@Override
public void onAbortResult(Bundle result) {
Log.i(TAG, "Abort result: result=" + result);
+ mLog.append("Abort: result=" + result + "\n");
getActivity().finish();
}
};
@@ -99,15 +115,59 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis
@Override
public void onCancel() {
Log.i(TAG, "Canceled!");
+ mLog.append("Canceled complete\n");
}
@Override
public void onCompleteResult(Bundle result) {
Log.i(TAG, "Complete result: result=" + result);
+ mLog.append("Complete: result=" + result + "\n");
getActivity().finish();
}
};
mInteractor.submitRequest(req);
+ } else if (v == mPickButton) {
+ VoiceInteractor.PickOptionRequest.Option[] options =
+ new VoiceInteractor.PickOptionRequest.Option[5];
+ options[0] = new VoiceInteractor.PickOptionRequest.Option("One");
+ options[1] = new VoiceInteractor.PickOptionRequest.Option("Two");
+ options[2] = new VoiceInteractor.PickOptionRequest.Option("Three");
+ options[3] = new VoiceInteractor.PickOptionRequest.Option("Four");
+ options[4] = new VoiceInteractor.PickOptionRequest.Option("Five");
+ VoiceInteractor.PickOptionRequest req = new VoiceInteractor.PickOptionRequest(
+ "Need to pick something", options, null) {
+ @Override
+ public void onCancel() {
+ Log.i(TAG, "Canceled!");
+ mLog.append("Canceled pick\n");
+ }
+
+ @Override
+ public void onPickOptionResult(boolean finished, Option[] selections, Bundle result) {
+ Log.i(TAG, "Pick result: finished=" + finished + " selections=" + selections
+ + " result=" + result);
+ StringBuilder sb = new StringBuilder();
+ if (finished) {
+ sb.append("Pick final result: ");
+ } else {
+ sb.append("Pick intermediate result: ");
+ }
+ for (int i=0; i<selections.length; i++) {
+ if (i >= 1) {
+ sb.append(", ");
+ }
+ sb.append(selections[i].getLabel());
+ }
+ mLog.append(sb.toString());
+ if (finished) {
+ getActivity().finish();
+ }
+ }
+ };
+ mInteractor.submitRequest(req);
+ } else if (v == mCancelButton && mCurrentRequest != null) {
+ Log.i(TAG, "Cancel request");
+ mCurrentRequest.cancel();
}
}
diff --git a/tests/permission/src/com/android/framework/permission/tests/ActivityManagerPermissionTests.java b/tests/permission/src/com/android/framework/permission/tests/ActivityManagerPermissionTests.java
index 3bd35a7..3791d02 100644
--- a/tests/permission/src/com/android/framework/permission/tests/ActivityManagerPermissionTests.java
+++ b/tests/permission/src/com/android/framework/permission/tests/ActivityManagerPermissionTests.java
@@ -47,17 +47,7 @@ public class ActivityManagerPermissionTests extends TestCase {
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
-
- try {
- mAm.moveTaskToBack(-1);
- fail("IActivityManager.moveTaskToBack did not throw SecurityException as"
- + " expected");
- } catch (SecurityException e) {
- // expected
- } catch (RemoteException e) {
- fail("Unexpected remote exception");
- }
-
+
try {
mAm.moveTaskBackwards(-1);
fail("IActivityManager.moveTaskToFront did not throw SecurityException as"
diff --git a/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java b/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java
index 62c92a1..e44969d 100644
--- a/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java
+++ b/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java
@@ -103,7 +103,7 @@ public class WindowManagerPermissionTests extends TestCase {
}
try {
- mWm.setAppGroupId(null, 0);
+ mWm.setAppTask(null, 0);
fail("IWindowManager.setAppGroupId did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {