diff options
Diffstat (limited to 'tests')
36 files changed, 929 insertions, 30 deletions
diff --git a/tests/AccessoryDisplay/sink/src/com/android/accessorydisplay/sink/DisplaySinkService.java b/tests/AccessoryDisplay/sink/src/com/android/accessorydisplay/sink/DisplaySinkService.java index daec845..8189fa9 100644 --- a/tests/AccessoryDisplay/sink/src/com/android/accessorydisplay/sink/DisplaySinkService.java +++ b/tests/AccessoryDisplay/sink/src/com/android/accessorydisplay/sink/DisplaySinkService.java @@ -30,6 +30,7 @@ import android.view.Surface; import android.view.SurfaceHolder; import android.view.SurfaceView; +import java.io.IOException; import java.nio.ByteBuffer; public class DisplaySinkService extends Service implements SurfaceHolder.Callback { @@ -150,7 +151,12 @@ public class DisplaySinkService extends Service implements SurfaceHolder.Callbac if (mSurface != null) { MediaFormat format = MediaFormat.createVideoFormat( "video/avc", mSurfaceWidth, mSurfaceHeight); - mCodec = MediaCodec.createDecoderByType("video/avc"); + try { + mCodec = MediaCodec.createDecoderByType("video/avc"); + } catch (IOException e) { + throw new RuntimeException( + "failed to create video/avc decoder", e); + } mCodec.configure(format, mSurface, null, 0); mCodec.start(); mCodecBufferInfo = new BufferInfo(); diff --git a/tests/AccessoryDisplay/source/src/com/android/accessorydisplay/source/DisplaySourceService.java b/tests/AccessoryDisplay/source/src/com/android/accessorydisplay/source/DisplaySourceService.java index 256f900..a4faca5 100644 --- a/tests/AccessoryDisplay/source/src/com/android/accessorydisplay/source/DisplaySourceService.java +++ b/tests/AccessoryDisplay/source/src/com/android/accessorydisplay/source/DisplaySourceService.java @@ -32,6 +32,7 @@ import android.os.Message; import android.view.Display; import android.view.Surface; +import java.io.IOException; import java.nio.ByteBuffer; public class DisplaySourceService extends Service { @@ -191,8 +192,13 @@ public class DisplaySourceService extends Service { format.setInteger(MediaFormat.KEY_BIT_RATE, BIT_RATE); format.setInteger(MediaFormat.KEY_FRAME_RATE, FRAME_RATE); format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, I_FRAME_INTERVAL); - - MediaCodec codec = MediaCodec.createEncoderByType("video/avc"); + MediaCodec codec; + try { + codec = MediaCodec.createEncoderByType("video/avc"); + } catch (IOException e) { + throw new RuntimeException( + "failed to create video/avc encoder", e); + } codec.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE); Surface surface = codec.createInputSurface(); codec.start(); diff --git a/tests/BiDiTests/src/com/android/bidi/BiDiTestGridLayoutCodeLtr.java b/tests/BiDiTests/src/com/android/bidi/BiDiTestGridLayoutCodeLtr.java index 2b5e674..ea08a6a 100644 --- a/tests/BiDiTests/src/com/android/bidi/BiDiTestGridLayoutCodeLtr.java +++ b/tests/BiDiTests/src/com/android/bidi/BiDiTestGridLayoutCodeLtr.java @@ -22,11 +22,25 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; +import android.widget.FrameLayout; import android.widget.GridLayout; -import android.widget.*; +import android.widget.Space; +import android.widget.TextView; -import static android.text.InputType.*; -import static android.widget.GridLayout.*; +import static android.text.InputType.TYPE_CLASS_TEXT; +import static android.text.InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; +import static android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD; +import static android.widget.GridLayout.ALIGN_BOUNDS; +import static android.widget.GridLayout.BASELINE; +import static android.widget.GridLayout.CENTER; +import static android.widget.GridLayout.FILL; +import static android.widget.GridLayout.LEFT; +import static android.widget.GridLayout.RIGHT; +import static android.widget.GridLayout.START; +import static android.widget.GridLayout.Spec; +import static android.widget.GridLayout.spec; public class BiDiTestGridLayoutCodeLtr extends Fragment { diff --git a/tests/BiDiTests/src/com/android/bidi/BiDiTestGridLayoutCodeRtl.java b/tests/BiDiTests/src/com/android/bidi/BiDiTestGridLayoutCodeRtl.java index 3a03c6c..fc3a92c 100644 --- a/tests/BiDiTests/src/com/android/bidi/BiDiTestGridLayoutCodeRtl.java +++ b/tests/BiDiTests/src/com/android/bidi/BiDiTestGridLayoutCodeRtl.java @@ -22,11 +22,25 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; +import android.widget.FrameLayout; import android.widget.GridLayout; -import android.widget.*; +import android.widget.Space; +import android.widget.TextView; -import static android.text.InputType.*; -import static android.widget.GridLayout.*; +import static android.text.InputType.TYPE_CLASS_TEXT; +import static android.text.InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; +import static android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD; +import static android.widget.GridLayout.ALIGN_BOUNDS; +import static android.widget.GridLayout.BASELINE; +import static android.widget.GridLayout.CENTER; +import static android.widget.GridLayout.FILL; +import static android.widget.GridLayout.LEFT; +import static android.widget.GridLayout.RIGHT; +import static android.widget.GridLayout.START; +import static android.widget.GridLayout.Spec; +import static android.widget.GridLayout.spec; public class BiDiTestGridLayoutCodeRtl extends Fragment { diff --git a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/AudioTrackDecoder.java b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/AudioTrackDecoder.java index 0219fd7..3b3de9f 100644 --- a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/AudioTrackDecoder.java +++ b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/AudioTrackDecoder.java @@ -59,8 +59,15 @@ public class AudioTrackDecoder extends TrackDecoder { @Override protected MediaCodec initMediaCodec(MediaFormat format) { - MediaCodec mediaCodec = MediaCodec.createDecoderByType( - format.getString(MediaFormat.KEY_MIME)); + MediaCodec mediaCodec; + try { + mediaCodec = MediaCodec.createDecoderByType( + format.getString(MediaFormat.KEY_MIME)); + } catch (IOException e) { + throw new RuntimeException( + "failed to create decoder for " + + format.getString(MediaFormat.KEY_MIME), e); + } mediaCodec.configure(format, null, null, 0); return mediaCodec; } diff --git a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/CpuVideoTrackDecoder.java b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/CpuVideoTrackDecoder.java index 96f3059..a624010 100644 --- a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/CpuVideoTrackDecoder.java +++ b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/CpuVideoTrackDecoder.java @@ -29,6 +29,7 @@ import androidx.media.filterfw.Frame; import androidx.media.filterfw.FrameImage2D; import androidx.media.filterfw.PixelUtils; +import java.io.IOException; import java.nio.ByteBuffer; import java.util.Arrays; import java.util.HashSet; @@ -214,7 +215,13 @@ public class CpuVideoTrackDecoder extends VideoTrackDecoder { return null; } else { String bestCodec = candidateCodecs.firstEntry().getValue(); - return MediaCodec.createByCodecName(bestCodec); + try { + return MediaCodec.createByCodecName(bestCodec); + } catch (IOException e) { + throw new RuntimeException( + "failed to create codec for " + + bestCodec, e); + } } } diff --git a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/GpuVideoTrackDecoder.java b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/GpuVideoTrackDecoder.java index bbba9d8..f5eb513 100644 --- a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/GpuVideoTrackDecoder.java +++ b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/GpuVideoTrackDecoder.java @@ -28,6 +28,7 @@ import androidx.media.filterfw.FrameImage2D; import androidx.media.filterfw.ImageShader; import androidx.media.filterfw.TextureSource; +import java.io.IOException; import java.nio.ByteBuffer; /** @@ -86,9 +87,16 @@ public class GpuVideoTrackDecoder extends VideoTrackDecoder { @Override protected MediaCodec initMediaCodec(MediaFormat format) { + MediaCodec mediaCodec; + try { + mediaCodec = MediaCodec.createDecoderByType( + format.getString(MediaFormat.KEY_MIME)); + } catch (IOException e) { + throw new RuntimeException( + "failed to create decoder for " + + format.getString(MediaFormat.KEY_MIME), e); + } Surface surface = new Surface(mSurfaceTexture); - MediaCodec mediaCodec = MediaCodec.createDecoderByType( - format.getString(MediaFormat.KEY_MIME)); mediaCodec.configure(format, surface, null, 0); surface.release(); return mediaCodec; diff --git a/tests/GridLayoutTest/src/com/android/test/layout/AbstractLayoutTest.java b/tests/GridLayoutTest/src/com/android/test/layout/AbstractLayoutTest.java index 4d3a843..196a5c1 100644 --- a/tests/GridLayoutTest/src/com/android/test/layout/AbstractLayoutTest.java +++ b/tests/GridLayoutTest/src/com/android/test/layout/AbstractLayoutTest.java @@ -24,7 +24,13 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; -import static android.view.Gravity.*; +import static android.view.Gravity.BOTTOM; +import static android.view.Gravity.CENTER; +import static android.view.Gravity.FILL; +import static android.view.Gravity.LEFT; +import static android.view.Gravity.NO_GRAVITY; +import static android.view.Gravity.RIGHT; +import static android.view.Gravity.TOP; public abstract class AbstractLayoutTest extends Activity { diff --git a/tests/GridLayoutTest/src/com/android/test/layout/AlignmentTest.java b/tests/GridLayoutTest/src/com/android/test/layout/AlignmentTest.java index b1c4486..5559707 100644 --- a/tests/GridLayoutTest/src/com/android/test/layout/AlignmentTest.java +++ b/tests/GridLayoutTest/src/com/android/test/layout/AlignmentTest.java @@ -20,15 +20,25 @@ import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.view.View; +import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import android.widget.GridLayout; +import android.widget.GridLayout.Alignment; +import android.widget.GridLayout.LayoutParams; import android.widget.TextView; -import static android.widget.GridLayout.*; +import static android.widget.GridLayout.BASELINE; +import static android.widget.GridLayout.BOTTOM; +import static android.widget.GridLayout.CENTER; +import static android.widget.GridLayout.FILL; +import static android.widget.GridLayout.LEFT; +import static android.widget.GridLayout.RIGHT; +import static android.widget.GridLayout.TOP; +import static android.widget.GridLayout.spec; -public class AlignmentTest extends Activity { +public class AlignmentTest extends Activity { public static final String[] HORIZONTAL_NAMES = {"LEFT", "center", "east", "fill"}; public static final Alignment[] HORIZONTAL_ALIGNMENTS = {LEFT, CENTER, RIGHT, FILL}; diff --git a/tests/GridLayoutTest/src/com/android/test/layout/GridLayoutTest.java b/tests/GridLayoutTest/src/com/android/test/layout/GridLayoutTest.java index 4ce449a..8047c5f 100644 --- a/tests/GridLayoutTest/src/com/android/test/layout/GridLayoutTest.java +++ b/tests/GridLayoutTest/src/com/android/test/layout/GridLayoutTest.java @@ -21,7 +21,10 @@ import android.view.View; import android.view.ViewGroup; import android.widget.GridLayout; -import static android.widget.GridLayout.*; +import static android.widget.GridLayout.Spec; +import static android.widget.GridLayout.UNDEFINED; +import static android.widget.GridLayout.VERTICAL; +import static android.widget.GridLayout.spec; public class GridLayoutTest extends AbstractLayoutTest { public ViewGroup create(Context context) { diff --git a/tests/GridLayoutTest/src/com/android/test/layout/LinearLayoutTest.java b/tests/GridLayoutTest/src/com/android/test/layout/LinearLayoutTest.java index c7f4665..dc5b12c 100644 --- a/tests/GridLayoutTest/src/com/android/test/layout/LinearLayoutTest.java +++ b/tests/GridLayoutTest/src/com/android/test/layout/LinearLayoutTest.java @@ -20,9 +20,9 @@ import android.content.Context; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; +import android.widget.LinearLayout.LayoutParams; -import static android.widget.LinearLayout.*; -import static android.widget.LinearLayout.LayoutParams.*; +import static android.widget.LinearLayout.LayoutParams.WRAP_CONTENT; public class LinearLayoutTest extends AbstractLayoutTest { public ViewGroup create(Context context) { diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml index 1bb0db0..c8eefe0 100644 --- a/tests/HwAccelerationTest/AndroidManifest.xml +++ b/tests/HwAccelerationTest/AndroidManifest.xml @@ -706,6 +706,15 @@ </activity> <activity + android:name="ColorFiltersMutateActivity" + android:label="ColorFilters/Mutate Filters"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="com.android.test.hwui.TEST" /> + </intent-filter> + </activity> + + <activity android:name="LinesActivity" android:label="Draw/Lines"> <intent-filter> @@ -849,5 +858,23 @@ </intent-filter> </activity> + <activity + android:name="ProjectionActivity" + android:label="Reordering/Projection"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="com.android.test.hwui.TEST" /> + </intent-filter> + </activity> + + <activity + android:name="IsolationVolumeActivity" + android:label="Reordering/IsolationVolume"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="com.android.test.hwui.TEST" /> + </intent-filter> + </activity> + </application> </manifest> diff --git a/tests/HwAccelerationTest/res/layout/isolation.xml b/tests/HwAccelerationTest/res/layout/isolation.xml new file mode 100644 index 0000000..802ac7f --- /dev/null +++ b/tests/HwAccelerationTest/res/layout/isolation.xml @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="#f55"> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + <LinearLayout + android:layout_width="0dp" + android:layout_height="150dp" + android:layout_weight="1" + android:isolatedZVolume="false" + android:orientation="vertical"> + <TextView style="@style/TopLeftReorderTextView"/> + <TextView style="@style/BottomLeftReorderTextView"/> + </LinearLayout> + <LinearLayout + android:layout_width="0dp" + android:layout_height="150dp" + android:layout_weight="1" + android:isolatedZVolume="false" + android:orientation="vertical"> + <TextView style="@style/TopRightReorderTextView"/> + <TextView style="@style/BottomRightReorderTextView"/> + </LinearLayout> + </LinearLayout> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + <LinearLayout + android:layout_width="0dp" + android:layout_height="150dp" + android:layout_weight="1" + android:orientation="vertical"> + <TextView style="@style/TopLeftReorderTextView"/> + <TextView style="@style/BottomLeftReorderTextView"/> + </LinearLayout> + <LinearLayout + android:layout_width="0dp" + android:layout_height="150dp" + android:layout_weight="1" + android:orientation="vertical"> + <TextView style="@style/TopRightReorderTextView"/> + <TextView style="@style/BottomRightReorderTextView"/> + </LinearLayout> + </LinearLayout> +</LinearLayout>
\ No newline at end of file diff --git a/tests/HwAccelerationTest/res/layout/projection.xml b/tests/HwAccelerationTest/res/layout/projection.xml new file mode 100644 index 0000000..564201a --- /dev/null +++ b/tests/HwAccelerationTest/res/layout/projection.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<view class="com.android.test.hwui.ProjectionActivity$ProjecteeLayout" + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/container" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + tools:context="com.example.projection.ProjectionActivity" + tools:ignore="MergeRootFrame"> + <TextView + android:layout_width="match_parent" + android:layout_height="100dp" + android:textSize="50sp" + android:text="TextView"/> + <FrameLayout + android:layout_width="match_parent" + android:layout_height="100dp" + android:clipChildren="false"> + <view class="com.android.test.hwui.ProjectionActivity$ProjectedView" + android:id="@+id/projection" + android:layout_width="match_parent" + android:layout_height="match_parent"/> + <TextView + android:layout_width="match_parent" + android:layout_height="match_parent" + android:textSize="50sp" + android:text="TextView"/> + </FrameLayout> + + <TextView + android:layout_width="match_parent" + android:layout_height="100dp" + android:textSize="50sp" + android:text="TextView"/> +</view>
\ No newline at end of file diff --git a/tests/HwAccelerationTest/res/values/styles.xml b/tests/HwAccelerationTest/res/values/styles.xml new file mode 100644 index 0000000..0ffd3d7 --- /dev/null +++ b/tests/HwAccelerationTest/res/values/styles.xml @@ -0,0 +1,34 @@ +<resources> + <style name="ReorderTextView" parent="@android:style/TextAppearance.Medium"> + <item name="android:layout_width">match_parent</item> + <item name="android:layout_height">75dp</item> + <item name="android:gravity">center</item> + </style> + <style name="LeftReorderTextView" parent="@style/ReorderTextView"> + <item name="android:translationX">50dp</item> + </style> + <style name="RightReorderTextView" parent="@style/ReorderTextView"> + <item name="android:translationX">-50dp</item> + </style> + + <style name="TopLeftReorderTextView" parent="@style/LeftReorderTextView"> + <item name="android:background">#666</item> + <item name="android:text">100</item> + <item name="android:translationZ">100dp</item> + </style> + <style name="BottomLeftReorderTextView" parent="@style/LeftReorderTextView"> + <item name="android:background">#bbb</item> + <item name="android:text">300</item> + <item name="android:translationZ">300dp</item> + </style> + <style name="TopRightReorderTextView" parent="@style/RightReorderTextView"> + <item name="android:background">#888</item> + <item name="android:text">200</item> + <item name="android:translationZ">200dp</item> + </style> + <style name="BottomRightReorderTextView" parent="@style/RightReorderTextView"> + <item name="android:background">#ccc</item> + <item name="android:text">400</item> + <item name="android:translationZ">400dp</item> + </style> +</resources> diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ColorFiltersMutateActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ColorFiltersMutateActivity.java new file mode 100644 index 0000000..808b5d3 --- /dev/null +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ColorFiltersMutateActivity.java @@ -0,0 +1,180 @@ +/* + * Copyright (C) 2010 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.hwui; + +import android.animation.ArgbEvaluator; +import android.animation.ObjectAnimator; +import android.app.Activity; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.ColorMatrix; +import android.graphics.ColorMatrixColorFilter; +import android.graphics.LightingColorFilter; +import android.graphics.Paint; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; +import android.os.Bundle; +import android.view.View; + +@SuppressWarnings({"UnusedDeclaration"}) +public class ColorFiltersMutateActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + final BitmapsView view = new BitmapsView(this); + setContentView(view); + } + + static class BitmapsView extends View { + private final Bitmap mBitmap1; + private final Bitmap mBitmap2; + private final Paint mColorMatrixPaint; + private final Paint mLightingPaint; + private final Paint mBlendPaint; + + private float mSaturation = 0.0f; + private int mLightAdd = 0; + private int mLightMul = 0; + private int mPorterDuffColor = 0; + + BitmapsView(Context c) { + super(c); + + mBitmap1 = BitmapFactory.decodeResource(c.getResources(), R.drawable.sunset1); + mBitmap2 = BitmapFactory.decodeResource(c.getResources(), R.drawable.sunset2); + + mColorMatrixPaint = new Paint(); + final ColorMatrix colorMatrix = new ColorMatrix(); + colorMatrix.setSaturation(0); + mColorMatrixPaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix)); + + mLightingPaint = new Paint(); + mLightingPaint.setColorFilter(new LightingColorFilter(0, 0)); + + mBlendPaint = new Paint(); + mBlendPaint.setColorFilter(new PorterDuffColorFilter(0, PorterDuff.Mode.SRC_OVER)); + + ObjectAnimator sat = ObjectAnimator.ofFloat(this, "saturation", 1.0f); + sat.setDuration(1000); + sat.setRepeatCount(ObjectAnimator.INFINITE); + sat.setRepeatMode(ObjectAnimator.REVERSE); + sat.start(); + + ObjectAnimator light = ObjectAnimator.ofInt(this, "lightAdd", 0x00101030); + light.setEvaluator(new ArgbEvaluator()); + light.setDuration(1000); + light.setRepeatCount(ObjectAnimator.INFINITE); + light.setRepeatMode(ObjectAnimator.REVERSE); + light.start(); + + ObjectAnimator mult = ObjectAnimator.ofInt(this, "lightMul", 0x0060ffff); + mult.setEvaluator(new ArgbEvaluator()); + mult.setDuration(1000); + mult.setRepeatCount(ObjectAnimator.INFINITE); + mult.setRepeatMode(ObjectAnimator.REVERSE); + mult.start(); + + ObjectAnimator color = ObjectAnimator.ofInt(this, "porterDuffColor", 0x7f990040); + color.setEvaluator(new ArgbEvaluator()); + color.setDuration(1000); + color.setRepeatCount(ObjectAnimator.INFINITE); + color.setRepeatMode(ObjectAnimator.REVERSE); + color.start(); + } + + public int getPorterDuffColor() { + return mPorterDuffColor; + } + + public void setPorterDuffColor(int porterDuffColor) { + mPorterDuffColor = porterDuffColor; + final PorterDuffColorFilter filter = + (PorterDuffColorFilter) mBlendPaint.getColorFilter(); + filter.setColor(mPorterDuffColor); + invalidate(); + } + + public int getLightAdd() { + return mLightAdd; + } + + public void setLightAdd(int lightAdd) { + mLightAdd = lightAdd; + final LightingColorFilter filter = + (LightingColorFilter) mLightingPaint.getColorFilter(); + filter.setColorAdd(lightAdd); + invalidate(); + } + + public int getLightMul() { + return mLightAdd; + } + + public void setLightMul(int lightMul) { + mLightMul = lightMul; + final LightingColorFilter filter = + (LightingColorFilter) mLightingPaint.getColorFilter(); + filter.setColorMultiply(lightMul); + invalidate(); + } + + public void setSaturation(float saturation) { + mSaturation = saturation; + final ColorMatrixColorFilter filter = + (ColorMatrixColorFilter) mColorMatrixPaint.getColorFilter(); + final ColorMatrix m = filter.getColorMatrix(); + m.setSaturation(saturation); + filter.setColorMatrix(m); + invalidate(); + } + + public float getSaturation() { + return mSaturation; + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + + canvas.drawARGB(255, 255, 255, 255); + + canvas.save(); + canvas.translate(120.0f, 50.0f); + canvas.drawBitmap(mBitmap1, 0.0f, 0.0f, mColorMatrixPaint); + + canvas.translate(0.0f, 50.0f + mBitmap1.getHeight()); + canvas.drawBitmap(mBitmap1, 0.0f, 0.0f, mLightingPaint); + + canvas.translate(0.0f, 50.0f + mBitmap1.getHeight()); + canvas.drawBitmap(mBitmap1, 0.0f, 0.0f, mBlendPaint); + canvas.restore(); + + canvas.save(); + canvas.translate(120.0f + mBitmap1.getWidth() + 120.0f, 50.0f); + canvas.drawBitmap(mBitmap2, 0.0f, 0.0f, mColorMatrixPaint); + + canvas.translate(0.0f, 50.0f + mBitmap2.getHeight()); + canvas.drawBitmap(mBitmap2, 0.0f, 0.0f, mLightingPaint); + + canvas.translate(0.0f, 50.0f + mBitmap2.getHeight()); + canvas.drawBitmap(mBitmap2, 0.0f, 0.0f, mBlendPaint); + canvas.restore(); + } + } +} diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/IsolationVolumeActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/IsolationVolumeActivity.java new file mode 100644 index 0000000..d5c93f2 --- /dev/null +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/IsolationVolumeActivity.java @@ -0,0 +1,12 @@ +package com.android.test.hwui; + +import android.os.Bundle; +import android.app.Activity; + +public class IsolationVolumeActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.isolation); + } +} diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ProjectionActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ProjectionActivity.java new file mode 100644 index 0000000..f27652d --- /dev/null +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ProjectionActivity.java @@ -0,0 +1,110 @@ +package com.android.test.hwui; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.RectF; +import android.os.Bundle; + +import android.app.Activity; +import android.util.AttributeSet; +import android.view.DisplayList; +import android.view.View; +import android.widget.LinearLayout; + +public class ProjectionActivity extends Activity { + /** + * The content from this view should be projected in between the background of the + * ProjecteeLayout and its children, unclipped. + * + * This view doesn't clip to its bounds (because its parent has clipChildren=false) so that + * when it is projected onto the ProjecteeLayout, it draws outside its view bounds. + */ + public static class ProjectedView extends View { + private final Paint mPaint = new Paint(); + private final RectF mRectF = new RectF(); + + public ProjectedView(Context context) { + this(context, null); + } + + public ProjectedView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public ProjectedView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + + setOnClickListener(new OnClickListener() { + boolean toggle = false; + @Override + public void onClick(View v) { + toggle = !toggle; + setProject(toggle); + } + }); + } + + private void setProject(boolean value) { + DisplayList displayList = getDisplayList(); + if (displayList != null) { + displayList.setProjectBackwards(value); + } + // NOTE: we can't invalidate ProjectedView for the redraw because: + // 1) the view won't preserve displayList properties that it doesn't know about + // 2) the damage rect won't be big enough + + // instead, twiddle properties on the container, so that enough area of the screen is + // redrawn without rerecording any DisplayLists. + container.setTranslationX(100f); + container.setTranslationX(0.0f); + } + + @Override + protected void onDraw(Canvas canvas) { + // TODO: set projection flag + final int w = getWidth(); + final int h = getHeight(); + mRectF.set(0, -h, w, 2 * h); + mPaint.setAntiAlias(true); + mPaint.setColor(0x5f00ff00); + canvas.drawOval(mRectF, mPaint); + } + } + + public static class ProjecteeLayout extends LinearLayout { + private final Paint mPaint = new Paint(); + private final RectF mRectF = new RectF(); + + public ProjecteeLayout(Context context) { + this(context, null); + } + + public ProjecteeLayout(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public ProjecteeLayout(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + @Override + protected void dispatchDraw(Canvas canvas) { + canvas.save(0x20); // secret save flag + mRectF.set(0, 0, getWidth(), getHeight()); + mPaint.setColor(0x5f000000); + canvas.drawOval(mRectF, mPaint); + canvas.restore(); + super.dispatchDraw(canvas); + } + } + + static View container; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.projection); + container = findViewById(R.id.container); + } +} diff --git a/tests/LegacyRestoreTest/README b/tests/LegacyRestoreTest/README new file mode 100644 index 0000000..cdd157e --- /dev/null +++ b/tests/LegacyRestoreTest/README @@ -0,0 +1,18 @@ +The file "jbmr2-encrypted-settings-abcd.ab" in this directory is an encrypted +"adb backup" archive of the settings provider package. It was generated on a +Nexus 4 running Android 4.3 (API 18), and so predates the Android 4.4 changes +to the PBKDF2 implementation. The archive's encryption password, entered on-screen, +is "abcd" (with no quotation marks). + +'adb restore' decrypts and applies the restored archive successfully on a device +running Android 4.3, but fails to restore correctly on a device running Android 4.4, +reporting an invalid password in logcat. This is the situation reported in bug +<https://code.google.com/p/android/issues/detail?id=63880>. + +The file "kk-fixed-encrypted-settings-abcd.ab" is a similar encrypted "adb backup" +archive, using the same key, generated on a Nexus 4 running Android 4.4 with a fix +to this bug in place. This archive should be successfully restorable on any +version of Android which incorporates the fix. + +These archives can be used as an ongoing test to verify that historical encrypted +archives from various points in Android's history can be successfully restored. diff --git a/tests/LegacyRestoreTest/jbmr2-encrypted-settings-abcd.ab b/tests/LegacyRestoreTest/jbmr2-encrypted-settings-abcd.ab Binary files differnew file mode 100644 index 0000000..192dcf5 --- /dev/null +++ b/tests/LegacyRestoreTest/jbmr2-encrypted-settings-abcd.ab diff --git a/tests/LegacyRestoreTest/kk-fixed-encrypted-settings-abcd.ab b/tests/LegacyRestoreTest/kk-fixed-encrypted-settings-abcd.ab Binary files differnew file mode 100644 index 0000000..bf2b558 --- /dev/null +++ b/tests/LegacyRestoreTest/kk-fixed-encrypted-settings-abcd.ab diff --git a/tests/RenderThreadTest/Android.mk b/tests/RenderThreadTest/Android.mk new file mode 100644 index 0000000..bdcba2e --- /dev/null +++ b/tests/RenderThreadTest/Android.mk @@ -0,0 +1,18 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional + +# Only compile source java files in this apk. +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_PACKAGE_NAME := RenderThreadTest + +LOCAL_STATIC_JAVA_LIBRARIES += android-common + +LOCAL_PROGUARD_ENABLED := disabled + +include $(BUILD_PACKAGE) + +# Use the following include to make our test apk. +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/tests/RenderThreadTest/AndroidManifest.xml b/tests/RenderThreadTest/AndroidManifest.xml new file mode 100644 index 0000000..c76cfce --- /dev/null +++ b/tests/RenderThreadTest/AndroidManifest.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.example.renderthread" + android:versionCode="1" + android:versionName="1.0" > + + <uses-sdk + android:minSdkVersion="18" + android:targetSdkVersion="18" /> + + <application + android:allowBackup="true" + android:icon="@drawable/ic_launcher" + android:label="@string/app_name" + android:theme="@style/AppTheme" > + <activity + android:name=".MainActivity" + android:label="@string/app_name" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + <activity android:name=".SubActivity" + android:theme="@style/AppTheme.Transparent" /> + </application> + +</manifest> diff --git a/tests/RenderThreadTest/res/drawable-hdpi/ic_launcher.png b/tests/RenderThreadTest/res/drawable-hdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..96a442e --- /dev/null +++ b/tests/RenderThreadTest/res/drawable-hdpi/ic_launcher.png diff --git a/tests/RenderThreadTest/res/drawable-mdpi/ic_launcher.png b/tests/RenderThreadTest/res/drawable-mdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..359047d --- /dev/null +++ b/tests/RenderThreadTest/res/drawable-mdpi/ic_launcher.png diff --git a/tests/RenderThreadTest/res/drawable-xhdpi/ic_launcher.png b/tests/RenderThreadTest/res/drawable-xhdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..71c6d76 --- /dev/null +++ b/tests/RenderThreadTest/res/drawable-xhdpi/ic_launcher.png diff --git a/tests/RenderThreadTest/res/drawable-xhdpi/starry_night_bg.jpg b/tests/RenderThreadTest/res/drawable-xhdpi/starry_night_bg.jpg Binary files differnew file mode 100644 index 0000000..755232d --- /dev/null +++ b/tests/RenderThreadTest/res/drawable-xhdpi/starry_night_bg.jpg diff --git a/tests/RenderThreadTest/res/layout/activity_main.xml b/tests/RenderThreadTest/res/layout/activity_main.xml new file mode 100644 index 0000000..1fd5459 --- /dev/null +++ b/tests/RenderThreadTest/res/layout/activity_main.xml @@ -0,0 +1,12 @@ +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".MainActivity" > + + <ListView android:id="@android:id/list" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:divider="@null" /> + +</FrameLayout> diff --git a/tests/RenderThreadTest/res/layout/activity_sub.xml b/tests/RenderThreadTest/res/layout/activity_sub.xml new file mode 100644 index 0000000..713cee4 --- /dev/null +++ b/tests/RenderThreadTest/res/layout/activity_sub.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" > + + <View + android:id="@+id/bg_container" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@drawable/starry_night_bg" /> + + <LinearLayout + android:id="@+id/my_container" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <View + android:id="@+id/from_left" + android:layout_width="match_parent" + android:layout_height="48dip" + android:background="#7000FF00" /> + + <View + android:id="@+id/from_right" + android:layout_width="match_parent" + android:layout_height="0dip" + android:layout_margin="80dip" + android:layout_weight="1" + android:background="#90FF0000" /> + + <View + android:id="@+id/from_left" + android:layout_width="match_parent" + android:layout_height="48dip" + android:background="#7000FF00" /> + </LinearLayout> + +</FrameLayout>
\ No newline at end of file diff --git a/tests/RenderThreadTest/res/layout/item_layout.xml b/tests/RenderThreadTest/res/layout/item_layout.xml new file mode 100644 index 0000000..5bdb1ac --- /dev/null +++ b/tests/RenderThreadTest/res/layout/item_layout.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<TextView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@android:id/text1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceListItemSmall" + android:gravity="center_vertical" + android:paddingStart="?android:attr/listPreferredItemPaddingStart" + android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" + android:minHeight="?android:attr/listPreferredItemHeightSmall" + android:background="#33b5e5" +/>
\ No newline at end of file diff --git a/tests/RenderThreadTest/res/values/strings.xml b/tests/RenderThreadTest/res/values/strings.xml new file mode 100644 index 0000000..f782e98 --- /dev/null +++ b/tests/RenderThreadTest/res/values/strings.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <string name="app_name">Render Thread</string> + <string name="action_settings">Settings</string> + <string name="hello_world">Hello world!</string> + +</resources> diff --git a/tests/RenderThreadTest/res/values/styles.xml b/tests/RenderThreadTest/res/values/styles.xml new file mode 100644 index 0000000..f6b5d6a --- /dev/null +++ b/tests/RenderThreadTest/res/values/styles.xml @@ -0,0 +1,11 @@ +<resources> + <!-- Application theme. --> + <style name="AppTheme" parent="android:Theme.Holo.Light"> + </style> + + <style name="AppTheme.Transparent"> + <item name="android:windowIsTranslucent">true</item> + <item name="android:windowBackground">@android:color/transparent</item> + </style> + +</resources> diff --git a/tests/RenderThreadTest/src/com/example/renderthread/MainActivity.java b/tests/RenderThreadTest/src/com/example/renderthread/MainActivity.java new file mode 100644 index 0000000..a39aba8 --- /dev/null +++ b/tests/RenderThreadTest/src/com/example/renderthread/MainActivity.java @@ -0,0 +1,158 @@ + +package com.example.renderthread; + +import android.animation.TimeInterpolator; +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.os.Handler; +import android.os.SystemClock; +import android.view.DisplayList; +import android.view.HardwareRenderer; +import android.view.ThreadedRenderer; +import android.view.View; +import android.view.animation.AccelerateDecelerateInterpolator; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.ListView; +import android.widget.SimpleAdapter; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +public class MainActivity extends Activity implements OnItemClickListener { + + static final int DURATION = 400; + + static final String KEY_NAME = "name"; + static final String KEY_CLASS = "clazz"; + + static Map<String,?> make(String name) { + Map<String,Object> ret = new HashMap<String,Object>(); + ret.put(KEY_NAME, name); + return ret; + } + + @SuppressWarnings("serial") + static final ArrayList<Map<String,?>> SAMPLES = new ArrayList<Map<String,?>>() {{ + for (int i = 1; i < 25; i++) { + add(make("List Item: " + i)); + } + }}; + + Handler mHandler = new Handler(); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + HardwareRenderer.sUseRenderThread = true; + setContentView(R.layout.activity_main); + ListView lv = (ListView) findViewById(android.R.id.list); + lv.setDrawSelectorOnTop(true); + lv.setAdapter(new SimpleAdapter(this, SAMPLES, + R.layout.item_layout, new String[] { KEY_NAME }, + new int[] { android.R.id.text1 })); + lv.setOnItemClickListener(this); + getActionBar().setTitle("MainActivity"); + } + + @Override + protected void onResume() { + super.onResume(); + ListView lv = (ListView) findViewById(android.R.id.list); + for (int i = 0; i < lv.getChildCount(); i++) { + lv.getChildAt(i).animate().translationY(0).setDuration(DURATION); + } + } + + private static class DisplayListAnimator { + private static final TimeInterpolator sDefaultInterpolator = + new AccelerateDecelerateInterpolator(); + + DisplayList mDisplayList; + float mFromValue; + float mDelta; + long mDuration = DURATION * 2; + long mStartTime; + + DisplayListAnimator(View view, float translateXBy) { + mDelta = translateXBy; + mFromValue = view.getTranslationY(); + mDisplayList = view.getDisplayList(); + } + + boolean animate(long currentTime) { + if (mStartTime == 0) mStartTime = currentTime; + + float fraction = (float)(currentTime - mStartTime) / mDuration; + if (fraction > 1) { + return false; + } + fraction = sDefaultInterpolator.getInterpolation(fraction); + float translation = mFromValue + (mDelta * fraction); + mDisplayList.setTranslationY(translation); + return fraction < 1f; + } + } + + private static class AnimationExecutor implements Runnable { + DisplayListAnimator[] mAnimations; + ThreadedRenderer mRenderer; + + AnimationExecutor(ThreadedRenderer renderer, DisplayListAnimator[] animations) { + mRenderer = renderer; + mAnimations = animations; + ThreadedRenderer.postToRenderThread(this); + } + + @Override + public void run() { + boolean hasMore = false; + long now = SystemClock.uptimeMillis(); + for (DisplayListAnimator animator : mAnimations) { + hasMore |= animator.animate(now); + } + mRenderer.repeatLastDraw(); + if (hasMore) { + ThreadedRenderer.postToRenderThread(this); + } + } + + } + + @Override + public void onItemClick(final AdapterView<?> adapterView, View clickedView, + int clickedPosition, long clickedId) { + int topPosition = adapterView.getFirstVisiblePosition(); + int dy = adapterView.getHeight(); + final DisplayListAnimator[] animators = new DisplayListAnimator[adapterView.getChildCount()]; + for (int i = 0; i < adapterView.getChildCount(); i++) { + int pos = topPosition + i; + View child = adapterView.getChildAt(i); + float delta = (pos - clickedPosition) * 1.1f; + if (delta == 0) delta = -1; + animators[i] = new DisplayListAnimator(child, dy * delta); + } + adapterView.invalidate(); + adapterView.post(new Runnable() { + + @Override + public void run() { + new AnimationExecutor((ThreadedRenderer) adapterView.getHardwareRenderer(), animators); + } + }); + //mHandler.postDelayed(mLaunchActivity, (long) (DURATION * .4)); + mLaunchActivity.run(); + } + + private Runnable mLaunchActivity = new Runnable() { + + @Override + public void run() { + startActivity(new Intent(MainActivity.this, SubActivity.class)); + overridePendingTransition(0, 0); + } + }; + +} diff --git a/tests/RenderThreadTest/src/com/example/renderthread/SubActivity.java b/tests/RenderThreadTest/src/com/example/renderthread/SubActivity.java new file mode 100644 index 0000000..892cbae --- /dev/null +++ b/tests/RenderThreadTest/src/com/example/renderthread/SubActivity.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2013 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.example.renderthread; + +import android.app.Activity; +import android.os.Bundle; +import android.os.Process; +import android.os.SystemClock; +import android.view.View; +import android.view.ViewGroup; + +public class SubActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + long before = SystemClock.currentThreadTimeMillis(); + setContentView(R.layout.activity_sub); + getActionBar().setTitle("SubActivity"); + // Simulate being a real app! + while (SystemClock.currentThreadTimeMillis() - before < 100) { + View v = new View(this, null); + } + } + + @Override + protected void onResume() { + super.onResume(); + ViewGroup container = (ViewGroup) findViewById(R.id.my_container); + int dx = getWindowManager().getDefaultDisplay().getWidth(); + for (int i = 0; i < container.getChildCount(); i++) { + View child = container.getChildAt(i); + int dir = child.getId() == R.id.from_left ? 1 : -1; + child.setTranslationX(dx * dir); + child.animate().translationX(0).setDuration(MainActivity.DURATION); + } + View bg = findViewById(R.id.bg_container); + bg.setAlpha(0f); + bg.animate().alpha(1f).setDuration(MainActivity.DURATION); + } + + @Override + public void onBackPressed() { + super.onBackPressed(); + overridePendingTransition(0, 0); + } +} diff --git a/tests/SmokeTest/tests/AndroidManifest.xml b/tests/SmokeTest/tests/AndroidManifest.xml index cad37c5..f1a0a4c 100644 --- a/tests/SmokeTest/tests/AndroidManifest.xml +++ b/tests/SmokeTest/tests/AndroidManifest.xml @@ -27,15 +27,6 @@ </application> <!-- - This declares that this app uses the instrumentation test runner targeting the package of - com.android.smoketest. To run the tests use the command: - `adb shell am instrument -w com.android.smoketest.tests/android.test.InstrumentationTestRunner` - --> - <instrumentation android:name="android.test.InstrumentationTestRunner" - android:targetPackage="com.android.smoketest" - android:label="System Smoke Tests"/> - - <!-- This declares a method to run the instrumentation with a special runner, which will run each app as a separate testcase. To do so, use the command: `adb shell am instrument -w com.android.smoketest.tests/com.android.smoketest.SmokeTestRunner` diff --git a/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java b/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java index 03c2923..946299b 100644 --- a/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java +++ b/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java @@ -154,6 +154,11 @@ public class ProcessErrorsTest extends AndroidTestCase { // launch app, and wait 7 seconds for it to start/settle final Intent intent = intentForActivity(app); + if (intent == null) { + Log.i(TAG, String.format("Activity %s/%s is disabled, skipping", + app.activityInfo.packageName, app.activityInfo.name)); + return Collections.EMPTY_LIST; + } getContext().startActivity(intent); try { Thread.sleep(appLaunchWait); @@ -238,10 +243,16 @@ public class ProcessErrorsTest extends AndroidTestCase { /** * A helper function to create an {@link Intent} to run, given a {@link ResolveInfo} specifying * an activity to be launched. + * + * @return the {@link Intent} or <code>null</code> if given app is disabled */ - static Intent intentForActivity(ResolveInfo app) { + Intent intentForActivity(ResolveInfo app) { final ComponentName component = new ComponentName(app.activityInfo.packageName, app.activityInfo.name); + if (getContext().getPackageManager().getComponentEnabledSetting(component) == + PackageManager.COMPONENT_ENABLED_STATE_DISABLED) { + return null; + } final Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(component); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |