diff options
Diffstat (limited to 'tests')
47 files changed, 1146 insertions, 28 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/CameraPrewarmTest/Android.mk b/tests/CameraPrewarmTest/Android.mk new file mode 100644 index 0000000..b6316f0 --- /dev/null +++ b/tests/CameraPrewarmTest/Android.mk @@ -0,0 +1,11 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(call all-subdir-java-files) + +LOCAL_PACKAGE_NAME := CameraPrewarmTest + +LOCAL_MODULE_TAGS := tests +LOCAL_CERTIFICATE := platform + +include $(BUILD_PACKAGE) diff --git a/tests/CameraPrewarmTest/AndroidManifest.xml b/tests/CameraPrewarmTest/AndroidManifest.xml new file mode 100644 index 0000000..eb40200 --- /dev/null +++ b/tests/CameraPrewarmTest/AndroidManifest.xml @@ -0,0 +1,52 @@ +<?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 + --> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.google.android.test.cameraprewarm"> + <application android:label="@string/activity_title"> + + <activity android:name=".CameraActivity" + android:theme="@android:style/Theme.NoTitleBar"> + <intent-filter> + <action android:name="android.media.action.STILL_IMAGE_CAMERA_SECURE" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + <intent-filter> + <action android:name="android.media.action.STILL_IMAGE_CAMERA" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + </activity> + + <activity android:name=".SecureCameraActivity" + android:theme="@android:style/Theme.NoTitleBar"> + <intent-filter> + <action android:name="android.media.action.STILL_IMAGE_CAMERA_SECURE" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + </activity> + + <receiver android:name=".PrewarmReceiver" > + <intent-filter> + <action android:name="android.media.action.STILL_IMAGE_CAMERA_PREWARM" /> + </intent-filter> + <intent-filter> + <action android:name="android.media.action.STILL_IMAGE_CAMERA_COOLDOWN" /> + </intent-filter> + </receiver> + + </application> +</manifest> diff --git a/tests/CameraPrewarmTest/res/layout/camera_activity.xml b/tests/CameraPrewarmTest/res/layout/camera_activity.xml new file mode 100644 index 0000000..64437bc --- /dev/null +++ b/tests/CameraPrewarmTest/res/layout/camera_activity.xml @@ -0,0 +1,25 @@ +<?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 + --> + +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center"> +</LinearLayout> + diff --git a/tests/CameraPrewarmTest/res/values/strings.xml b/tests/CameraPrewarmTest/res/values/strings.xml new file mode 100644 index 0000000..11f7ac7 --- /dev/null +++ b/tests/CameraPrewarmTest/res/values/strings.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 + --> + +<resources> + <string name="activity_title">Assistant</string> + <string name="search_label">Orilla Search Engine</string> +</resources> diff --git a/tests/CameraPrewarmTest/src/com/google/android/test/cameraprewarm/CameraActivity.java b/tests/CameraPrewarmTest/src/com/google/android/test/cameraprewarm/CameraActivity.java new file mode 100644 index 0000000..4d22234 --- /dev/null +++ b/tests/CameraPrewarmTest/src/com/google/android/test/cameraprewarm/CameraActivity.java @@ -0,0 +1,37 @@ +/* + * 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.google.android.test.cameraprewarm; + +import android.app.Activity; +import android.os.Bundle; +import android.util.Log; +import android.view.WindowManager; + +import com.google.android.test.cameraprewarm.R; + +public class CameraActivity extends Activity { + + public final static String TAG = "PrewarmTest"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.camera_activity); + getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); + Log.i(TAG, "Activity created"); + } +} diff --git a/tests/CameraPrewarmTest/src/com/google/android/test/cameraprewarm/PrewarmReceiver.java b/tests/CameraPrewarmTest/src/com/google/android/test/cameraprewarm/PrewarmReceiver.java new file mode 100644 index 0000000..d49f96d --- /dev/null +++ b/tests/CameraPrewarmTest/src/com/google/android/test/cameraprewarm/PrewarmReceiver.java @@ -0,0 +1,35 @@ +/* + * 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.google.android.test.cameraprewarm; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.provider.MediaStore; +import android.util.Log; + +public class PrewarmReceiver extends BroadcastReceiver { + + @Override + public void onReceive(Context context, Intent intent) { + if (intent.getAction().equals(MediaStore.ACTION_STILL_IMAGE_CAMERA_PREWARM)) { + Log.i(CameraActivity.TAG, "Prewarm received"); + } else if (intent.getAction().equals(MediaStore.ACTION_STILL_IMAGE_CAMERA_COOLDOWN)){ + Log.i(CameraActivity.TAG, "Cooldown received"); + } + } +} diff --git a/tests/CameraPrewarmTest/src/com/google/android/test/cameraprewarm/SecureCameraActivity.java b/tests/CameraPrewarmTest/src/com/google/android/test/cameraprewarm/SecureCameraActivity.java new file mode 100644 index 0000000..530fe00 --- /dev/null +++ b/tests/CameraPrewarmTest/src/com/google/android/test/cameraprewarm/SecureCameraActivity.java @@ -0,0 +1,35 @@ +/* + * 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.google.android.test.cameraprewarm; + +import android.app.Activity; +import android.os.Bundle; +import android.util.Log; +import android.view.WindowManager; + +import com.google.android.test.cameraprewarm.R; + +public class SecureCameraActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.camera_activity); + getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); + Log.i(CameraActivity.TAG, "Activity created"); + } +} diff --git a/tests/Compatibility/Android.mk b/tests/Compatibility/Android.mk index 0ec4d9d..c2f89dd 100644 --- a/tests/Compatibility/Android.mk +++ b/tests/Compatibility/Android.mk @@ -25,7 +25,7 @@ LOCAL_SRC_FILES := \ LOCAL_PACKAGE_NAME := AppCompatibilityTest - +LOCAL_CERTIFICATE := platform include $(BUILD_PACKAGE) include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/tests/Compatibility/AndroidManifest.xml b/tests/Compatibility/AndroidManifest.xml index 2884532..8ae5bc5 100644 --- a/tests/Compatibility/AndroidManifest.xml +++ b/tests/Compatibility/AndroidManifest.xml @@ -19,7 +19,7 @@ <application > <uses-library android:name="android.test.runner" /> </application> - + <uses-permission android:name="android.permission.REAL_GET_TASKS" /> <instrumentation android:name=".AppCompatibilityRunner" android:targetPackage="com.android.compatibilitytest" 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 Binary files differindex 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 diff --git a/tests/Assistant/res/drawable-hdpi/ic_action_assist_normal.png b/tests/LegacyAssistant/res/drawable-hdpi/ic_action_assist_normal.png Binary files differindex 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 diff --git a/tests/Assistant/res/drawable-mdpi/ic_action_assist_activated.png b/tests/LegacyAssistant/res/drawable-mdpi/ic_action_assist_activated.png Binary files differindex 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 diff --git a/tests/Assistant/res/drawable-mdpi/ic_action_assist_normal.png b/tests/LegacyAssistant/res/drawable-mdpi/ic_action_assist_normal.png Binary files differindex 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 diff --git a/tests/Assistant/res/drawable-xhdpi/ic_action_assist_activated.png b/tests/LegacyAssistant/res/drawable-xhdpi/ic_action_assist_activated.png Binary files differindex 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 diff --git a/tests/Assistant/res/drawable-xhdpi/ic_action_assist_normal.png b/tests/LegacyAssistant/res/drawable-xhdpi/ic_action_assist_normal.png Binary files differindex 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 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/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/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/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 8c8151d..6209bd0 100644 --- a/tests/VoiceInteraction/res/layout/test_interaction.xml +++ b/tests/VoiceInteraction/res/layout/test_interaction.xml @@ -34,32 +34,49 @@ android:textAppearance="?android:attr/textAppearanceMedium" /> - <Button android:id="@+id/complete" - android:layout_width="wrap_content" + <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="16dp" - android:text="@string/completeVoice" - /> + android:orientation="horizontal"> + + <Button android:id="@+id/complete" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/completeVoice" + /> + + <Button android:id="@+id/abort" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/abortVoice" + /> + + <Button android:id="@+id/pick" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/pickVoice" + /> + + </LinearLayout> - <Button android:id="@+id/pick" - android:layout_width="wrap_content" + <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="16dp" - android:text="@string/pickVoice" + android:layout_marginBottom="16dp" + android:orientation="horizontal"> + + <Button android:id="@+id/cancel" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/cancelVoice" /> - <Button android:id="@+id/abort" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="16dp" - android:text="@string/abortVoice" + <Button android:id="@+id/jump" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/jumpOut" /> - <Button android:id="@+id/cancel" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="16dp" - android:text="@string/cancelVoice" - /> + </LinearLayout> </LinearLayout> diff --git a/tests/VoiceInteraction/res/values/strings.xml b/tests/VoiceInteraction/res/values/strings.xml index 5331457..6289929 100644 --- a/tests/VoiceInteraction/res/values/strings.xml +++ b/tests/VoiceInteraction/res/values/strings.xml @@ -17,6 +17,7 @@ <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> @@ -24,5 +25,6 @@ <string name="completeVoice">Complete Voice</string> <string name="pickVoice">Pick Voice</string> <string name="cancelVoice">Cancel</string> + <string name="jumpOut">Jump out</string> </resources> diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java index bdc1276..8a72341 100644 --- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java +++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java @@ -46,6 +46,7 @@ public class AssistVisualizer extends View { public void setAssistStructure(AssistStructure as) { mAssistStructure = as; + mAssistStructure.dump(); mTextRects.clear(); final int N = as.getWindowNodeCount(); if (N > 0) { @@ -55,6 +56,7 @@ public class AssistVisualizer extends View { windowNode.getTop()); } } + Log.d(TAG, "Building text rects in " + this + ": found " + mTextRects.size()); invalidate(); } @@ -69,10 +71,11 @@ public class AssistVisualizer extends View { } int left = parentLeft+root.getLeft(); int top = parentTop+root.getTop(); - Log.d(TAG, "View " + root.getClassName() + ": " + left + ", " + top); - if (root.getText() != null) { + if (root.getText() != null || root.getContentDescription() != null) { Rect r = new Rect(left, top, left+root.getWidth(), top+root.getHeight()); - Log.d(TAG, "Text Rect " + r.toShortString() + ": " + root.getText()); + 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(); @@ -91,6 +94,7 @@ public class AssistVisualizer extends View { 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], 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/MainInteractionSession.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java index bc18ca9..3c5c201 100644 --- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java +++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java @@ -16,6 +16,7 @@ package com.android.test.voiceinteraction; +import android.app.ActivityManager; import android.app.AssistContent; import android.app.AssistStructure; import android.app.VoiceInteractor; @@ -69,6 +70,8 @@ public class MainInteractionSession extends VoiceInteractionSession @Override public void onCreate(Bundle args, int startFlags) { super.onCreate(args); + ActivityManager am = getContext().getSystemService(ActivityManager.class); + am.setWatchHeapLimit(40*1024*1024); } @Override @@ -142,7 +145,6 @@ public class MainInteractionSession extends VoiceInteractionSession if (assistContext != null) { mAssistStructure = AssistStructure.getAssistStructure(assistContext); if (mAssistStructure != null) { - mAssistStructure.dump(); if (mAssistVisualizer != null) { mAssistVisualizer.setAssistStructure(mAssistStructure); } diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java index e195c30..9d24c59 100644 --- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java +++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java @@ -19,6 +19,7 @@ package com.android.test.voiceinteraction; import android.app.Activity; import android.app.VoiceInteractor; import android.content.ComponentName; +import android.content.Intent; import android.os.Bundle; import android.service.voice.VoiceInteractionService; import android.util.Log; @@ -37,6 +38,7 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis Button mAbortButton; Button mCompleteButton; Button mPickButton; + Button mJumpOutButton; Button mCancelButton; @Override @@ -64,6 +66,8 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis mCompleteButton.setOnClickListener(this); mPickButton = (Button)findViewById(R.id.pick); mPickButton.setOnClickListener(this); + mJumpOutButton = (Button)findViewById(R.id.jump); + mJumpOutButton.setOnClickListener(this); mCancelButton = (Button)findViewById(R.id.cancel); mCancelButton.setOnClickListener(this); @@ -165,6 +169,13 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis } }; mInteractor.submitRequest(req); + } else if (v == mJumpOutButton) { + Log.i(TAG, "Jump out"); + Intent intent = new Intent(Intent.ACTION_MAIN); + intent.addCategory(Intent.CATEGORY_LAUNCHER); + intent.setComponent(new ComponentName(this, VoiceInteractionMain.class)); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); } else if (v == mCancelButton && mCurrentRequest != null) { Log.i(TAG, "Cancel request"); mCurrentRequest.cancel(); |
