diff options
15 files changed, 557 insertions, 6 deletions
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml index 29638dd6f03..05eede3db67 100644 --- a/apps/CtsVerifier/AndroidManifest.xml +++ b/apps/CtsVerifier/AndroidManifest.xml @@ -18,7 +18,7 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.cts.verifier" android:versionCode="5" - android:versionName="6.0_r23"> + android:versionName="6.0_r24"> <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="23"/> @@ -94,6 +94,35 @@ android:value="android.software.device_admin" /> </activity> + <activity android:name=".admin.tapjacking.DeviceAdminTapjackingTestActivity" + android:label="@string/da_tapjacking_test" + android:configChanges="keyboardHidden|orientation|screenSize"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.cts.intent.category.MANUAL_TEST" /> + </intent-filter> + <meta-data android:name="test_category" android:value="@string/test_category_device_admin" /> + <meta-data android:name="test_required_features" + android:value="android.software.device_admin" /> + <meta-data android:name="test_excluded_features" + android:value="android.hardware.type.watch" /> + </activity> + + <receiver android:name=".admin.tapjacking.EmptyDeviceAdminReceiver" + android:permission="android.permission.BIND_DEVICE_ADMIN" + android:process=":TestReceiver"> + <meta-data android:name="android.app.device_admin" + android:resource="@xml/tapjacking_device_admin" /> + <intent-filter> + <action android:name="android.app.action.DEVICE_ADMIN_ENABLED"/> + </intent-filter> + </receiver> + + <activity + android:name=".admin.tapjacking.OverlayingActivity" + android:theme="@style/OverlayTheme" + android:label="Overlaying Activity"/> + <!-- A generic activity for intent based tests --> <activity android:name=".IntentDrivenTestActivity"/> diff --git a/apps/CtsVerifier/res/drawable/border.xml b/apps/CtsVerifier/res/drawable/border.xml new file mode 100644 index 00000000000..b4196189a87 --- /dev/null +++ b/apps/CtsVerifier/res/drawable/border.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Copyright (C) 2017 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" + android:shape="rectangle"> + <corners + android:radius="4dp"/> + <stroke + android:width="4dp" + android:color="@android:color/black" /> +</shape> diff --git a/apps/CtsVerifier/res/layout/da_tapjacking_overlay_activity.xml b/apps/CtsVerifier/res/layout/da_tapjacking_overlay_activity.xml new file mode 100644 index 00000000000..5583fce613d --- /dev/null +++ b/apps/CtsVerifier/res/layout/da_tapjacking_overlay_activity.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Copyright (C) 2017 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:background="@drawable/border" + android:padding="8dp" > + + <TextView android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textColor="@android:color/black" + android:text="@string/da_tapjacking_overlay_app_description" /> +</LinearLayout>
\ No newline at end of file diff --git a/apps/CtsVerifier/res/layout/da_tapjacking_test_main.xml b/apps/CtsVerifier/res/layout/da_tapjacking_test_main.xml new file mode 100644 index 00000000000..2ee9ea94d78 --- /dev/null +++ b/apps/CtsVerifier/res/layout/da_tapjacking_test_main.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2017 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. +--> +<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" + style="@style/RootLayoutPadding" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <!-- Enable device admin --> + <RelativeLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" > + + <TextView + android:id="@+id/admin_tapjacking_instructions" + style="@style/InstructionsSmallFont" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentRight="true" + android:layout_alignParentTop="true" + android:text="@string/da_tapjacking_instructions" /> + + <Button + android:id="@+id/enable_admin_overlay_button" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentRight="true" + android:layout_below="@id/admin_tapjacking_instructions" + android:layout_marginLeft="20dip" + android:layout_marginRight="20dip" + android:text="@string/da_tapjacking_button_text" /> + </RelativeLayout> + + <include layout="@layout/pass_fail_buttons" /> + </LinearLayout> + +</ScrollView> diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml index 5b2eb36a6f5..346a8aa5eb3 100755 --- a/apps/CtsVerifier/res/values/strings.xml +++ b/apps/CtsVerifier/res/values/strings.xml @@ -89,6 +89,10 @@ device and verify that all rows in the policy list are green. Red items indicate policy settings that were not loaded properly. </string> + <string name="da_tapjacking_test">Device Admin Tapjacking Test</string> + <string name="da_tapjacking_test_info">This test checks that an activity cannot tapjack the + user by obscuring the device admin details while prompting the user to activate the admin. + </string> <string name="car_dock_test">Car Dock Test</string> <string name="car_dock_test_desc">This test ensures that car mode opens the app associated with car dock when going into car mode.\n\n @@ -130,6 +134,19 @@ <string name="da_lock_success">It appears the screen was locked successfully!</string> <string name="da_lock_error">It does not look like the screen was locked...</string> + <string name="da_tapjacking_overlay_app_description">This activity attempts to tapjack the activity below.\n + Any security sensitive controls below should not respond to taps as long as this activity is visible.</string> + <string name="da_tapjacking_instructions"> + 1. Launch the device admin add screen by pressing the button below.\n + 2. Wait for an overlaying transparent activity to show up obscuring the device admin details window.\n + 3. The button to activate the admin should be disabled and should not register any taps.\n + 4. Press \'back\' to exit the overlaying transparent activity.\n + 5. Press \'back\' to exit the device admin details and return to this screen.\n + Pass the test if the device admin could not be activated while the details + window was being obscured. + </string> + <string name="da_tapjacking_button_text">Enable device admin</string> + <!-- Strings for lock bound keys test --> <string name="sec_lock_bound_key_test">Lock Bound Keys Test</string> <string name="sec_lock_bound_key_test_info"> diff --git a/apps/CtsVerifier/res/values/styles.xml b/apps/CtsVerifier/res/values/styles.xml index 16fa87f246f..64fd4fe8073 100644 --- a/apps/CtsVerifier/res/values/styles.xml +++ b/apps/CtsVerifier/res/values/styles.xml @@ -10,4 +10,12 @@ <item name="android:textSize">18sp</item> <item name="android:padding">5dp</item> </style> + <style name="RootLayoutPadding"> + <item name="android:padding">10dip</item> + </style> + <style name="OverlayTheme" parent="android:Theme.Dialog"> + <item name="android:windowNoTitle">true</item> + <item name="android:windowIsTranslucent">true</item> + <item name="android:windowBackground">@android:color/transparent</item> + </style> </resources> diff --git a/apps/CtsVerifier/res/xml/tapjacking_device_admin.xml b/apps/CtsVerifier/res/xml/tapjacking_device_admin.xml new file mode 100644 index 00000000000..d8846631ba4 --- /dev/null +++ b/apps/CtsVerifier/res/xml/tapjacking_device_admin.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2017 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. +--> + +<device-admin xmlns:android="http://schemas.android.com/apk/res/android"> + <uses-policies> + <limit-password /> + <watch-login /> + <encrypted-storage /> + <wipe-data /> + <reset-password /> + <disable-keyguard-features /> + <force-lock /> + <limit-password /> + </uses-policies> +</device-admin> diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/admin/tapjacking/DeviceAdminTapjackingTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/admin/tapjacking/DeviceAdminTapjackingTestActivity.java new file mode 100644 index 00000000000..3fd64e362b5 --- /dev/null +++ b/apps/CtsVerifier/src/com/android/cts/verifier/admin/tapjacking/DeviceAdminTapjackingTestActivity.java @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2017 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.cts.verifier.admin.tapjacking; + +import android.app.admin.DevicePolicyManager; +import android.content.ComponentName; +import android.content.Intent; +import android.os.Bundle; +import android.os.SystemClock; +import android.util.Log; +import android.view.View; +import android.widget.Button; + +import com.android.cts.verifier.PassFailButtons; +import com.android.cts.verifier.R; + +/** + * Test that checks that device admin activate button does not allow taps when another window + * is obscuring the device admin details + */ +public class DeviceAdminTapjackingTestActivity extends PassFailButtons.Activity implements + View.OnClickListener { + + private static final String TAG = DeviceAdminTapjackingTestActivity.class.getSimpleName(); + private static final String ADMIN_ACTIVATED_BUNDLE_KEY = "admin_activated"; + private static final String ACTIVITIES_FINISHED_IN_ORDER_KEY = "activities_finished_in_order"; + private static final int REQUEST_ENABLE_ADMIN = 0; + private static final int REQUEST_OVERLAY_ACTIVITY = 1; + private static final long REMOVE_ADMIN_TIMEOUT = 5000; + + private DevicePolicyManager mDevicePolicyManager; + private Button mAddDeviceAdminButton; + private boolean mAdminActivated; + private boolean mActivitiesFinishedInOrder; + private boolean mOverlayFinished; + private ComponentName mAdmin; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.da_tapjacking_test_main); + setInfoResources(R.string.da_tapjacking_test, R.string.da_tapjacking_test_info, -1); + setPassFailButtonClickListeners(); + + mAdmin = new ComponentName(this, EmptyDeviceAdminReceiver.class); + mDevicePolicyManager = (DevicePolicyManager) getSystemService(DEVICE_POLICY_SERVICE); + + if (savedInstanceState != null) { + mAdminActivated = savedInstanceState.getBoolean(ADMIN_ACTIVATED_BUNDLE_KEY, false); + mActivitiesFinishedInOrder = savedInstanceState.getBoolean( + ACTIVITIES_FINISHED_IN_ORDER_KEY, false); + } else if (isActiveAdminAfterTimeout()) { + Log.e(TAG, "Could not remove active admin. Cannot proceed with test"); + finish(); + } + mAddDeviceAdminButton = (Button) findViewById(R.id.enable_admin_overlay_button); + mAddDeviceAdminButton.setOnClickListener(this); + } + + private boolean isActiveAdminAfterTimeout() { + final long timeOut = SystemClock.uptimeMillis() + REMOVE_ADMIN_TIMEOUT; + while (mDevicePolicyManager.isAdminActive(mAdmin) + && SystemClock.uptimeMillis() < timeOut ) { + try { + Thread.sleep(1000); + } catch(InterruptedException exc) { + } + } + return mDevicePolicyManager.isAdminActive(mAdmin); + } + + @Override + public void onClick(View v) { + if (v == mAddDeviceAdminButton) { + Intent securitySettingsIntent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN); + securitySettingsIntent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mAdmin); + startActivityForResult(securitySettingsIntent, REQUEST_ENABLE_ADMIN); + try { + Thread.sleep(2000); + } catch (InterruptedException exc) { + } + startActivityForResult(new Intent(this, OverlayingActivity.class), + REQUEST_OVERLAY_ACTIVITY); + } + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + if (requestCode == REQUEST_ENABLE_ADMIN) { + mActivitiesFinishedInOrder = mOverlayFinished; + if (resultCode == RESULT_OK) { + mAdminActivated = true; + Log.e(TAG, "Admin was activated. Restart the Test"); + } + } + else if (requestCode == REQUEST_OVERLAY_ACTIVITY) { + mOverlayFinished = true; + } + } + + @Override + public void onResume() { + super.onResume(); + updateWidgets(); + } + + @Override + public void onSaveInstanceState(Bundle icicle) { + icicle.putBoolean(ADMIN_ACTIVATED_BUNDLE_KEY, mAdminActivated); + icicle.putBoolean(ACTIVITIES_FINISHED_IN_ORDER_KEY, mActivitiesFinishedInOrder); + } + + private void updateWidgets() { + mAddDeviceAdminButton.setEnabled(!mActivitiesFinishedInOrder && !mAdminActivated); + getPassButton().setEnabled(!mAdminActivated && mActivitiesFinishedInOrder); + } +} diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/admin/tapjacking/EmptyDeviceAdminReceiver.java b/apps/CtsVerifier/src/com/android/cts/verifier/admin/tapjacking/EmptyDeviceAdminReceiver.java new file mode 100644 index 00000000000..42dd9ac13b8 --- /dev/null +++ b/apps/CtsVerifier/src/com/android/cts/verifier/admin/tapjacking/EmptyDeviceAdminReceiver.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2017 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.cts.verifier.admin.tapjacking; + +import android.app.admin.DeviceAdminReceiver; +import android.app.admin.DevicePolicyManager; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; + +public class EmptyDeviceAdminReceiver extends DeviceAdminReceiver { + + @Override + public void onEnabled(Context context, Intent intent) { + DevicePolicyManager dpm = + (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE); + dpm.removeActiveAdmin(new ComponentName(context, this.getClass())); + } +} diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/admin/tapjacking/OverlayingActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/admin/tapjacking/OverlayingActivity.java new file mode 100644 index 00000000000..52c7ed5f01d --- /dev/null +++ b/apps/CtsVerifier/src/com/android/cts/verifier/admin/tapjacking/OverlayingActivity.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2017 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.cts.verifier.admin.tapjacking; + +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; +import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS; +import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; +import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; + +import android.app.Activity; +import android.os.Bundle; +import android.view.WindowManager; + +import com.android.cts.verifier.R; + + +public class OverlayingActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.da_tapjacking_overlay_activity); + WindowManager.LayoutParams params = getWindow().getAttributes(); + params.flags = FLAG_LAYOUT_NO_LIMITS | FLAG_NOT_TOUCH_MODAL | FLAG_NOT_TOUCHABLE + | FLAG_KEEP_SCREEN_ON; + } +} diff --git a/tests/tests/graphics/src/android/graphics/cts/ColorTest.java b/tests/tests/graphics/src/android/graphics/cts/ColorTest.java index 760e3f9ce92..b4514ecff7d 100644 --- a/tests/tests/graphics/src/android/graphics/cts/ColorTest.java +++ b/tests/tests/graphics/src/android/graphics/cts/ColorTest.java @@ -15,12 +15,58 @@ */ package android.graphics.cts; +import android.content.res.Resources; import android.graphics.Color; import android.test.AndroidTestCase; +import android.util.TypedValue; + +import java.util.Arrays; +import java.util.List; public class ColorTest extends AndroidTestCase { - public void testAlpha(){ + public void testResourceColor() { + int colors [][] = { + { 0xff000000, android.R.color.black }, + { 0xffaaaaaa, android.R.color.darker_gray }, + { 0xff00ddff, android.R.color.holo_blue_bright }, + { 0xff0099cc, android.R.color.holo_blue_dark }, + { 0xff33b5e5, android.R.color.holo_blue_light }, + { 0xff669900, android.R.color.holo_green_dark }, + { 0xff99cc00, android.R.color.holo_green_light }, + { 0xffff8800, android.R.color.holo_orange_dark }, + { 0xffffbb33, android.R.color.holo_orange_light }, + { 0xffaa66cc, android.R.color.holo_purple }, + { 0xffcc0000, android.R.color.holo_red_dark }, + { 0xffff4444, android.R.color.holo_red_light }, + { 0x00000000, android.R.color.transparent }, + { 0xffffffff, android.R.color.white }, + }; + + Resources resources = mContext.getResources(); + for (int[] pair : colors) { + final int resourceId = pair[1]; + final int expectedColor = pair[0]; + + // validate color from getColor + int observedColor = resources.getColor(resourceId); + assertEquals("Color = " + Integer.toHexString(observedColor) + ", " + + Integer.toHexString(expectedColor) + " expected", + expectedColor, + observedColor); + + // validate color from getValue + TypedValue value = new TypedValue(); + resources.getValue(resourceId, value, true); + assertEquals("Color should be expected value", expectedColor, value.data); + + // colors should be raw ints + assertTrue("Type should be int", value.type >= TypedValue.TYPE_FIRST_INT + && value.type <= TypedValue.TYPE_LAST_INT); + } + } + + public void testAlpha() { assertEquals(0xff, Color.alpha(Color.RED)); assertEquals(0xff, Color.alpha(Color.YELLOW)); new Color(); diff --git a/tests/tests/security/res/raw/bug_62187433.mp4 b/tests/tests/security/res/raw/bug_62187433.mp4 Binary files differnew file mode 100644 index 00000000000..058d0f4b1f8 --- /dev/null +++ b/tests/tests/security/res/raw/bug_62187433.mp4 diff --git a/tests/tests/security/src/android/security/cts/EffectBundleTest.java b/tests/tests/security/src/android/security/cts/EffectBundleTest.java index 066e305119d..ad29c17e5af 100644 --- a/tests/tests/security/src/android/security/cts/EffectBundleTest.java +++ b/tests/tests/security/src/android/security/cts/EffectBundleTest.java @@ -17,6 +17,7 @@ package android.security.cts; import android.media.audiofx.AudioEffect; +import android.media.audiofx.EnvironmentalReverb; import android.media.audiofx.Equalizer; import android.media.MediaPlayer; import android.test.InstrumentationTestCase; @@ -26,6 +27,7 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.charset.StandardCharsets; import java.util.Arrays; +import java.util.UUID; import com.android.cts.security.R; @@ -39,6 +41,11 @@ public class EffectBundleTest extends InstrumentationTestCase { private static final int MEDIA_SHORT = 0; private static final int MEDIA_LONG = 1; + // should match audio_effect.h (native) + private static final int EFFECT_CMD_SET_PARAM = 5; + + private static final int intSize = 4; + //Testing security bug: 32436341 public void testEqualizer_getParamCenterFreq() throws Exception { testGetParam(MEDIA_SHORT, Equalizer.PARAM_CENTER_FREQ, INVALID_BAND_ARRAY, mValue0, @@ -162,6 +169,40 @@ public class EffectBundleTest extends InstrumentationTestCase { eqSetParamProperties(MEDIA_LONG)); } + //Testing security bug: 63662938 + public void testDownmix_setParameter() throws Exception { + verifyZeroPVSizeRejectedForSetParameter( + EFFECT_TYPE_DOWNMIX, new int[] { DOWNMIX_PARAM_TYPE }); + } + + /** + * Definitions for the downmix effect. Taken from + * system/media/audio/include/system/audio_effects/effect_downmix.h + * This effect is normally not exposed to applications. + */ + private static final UUID EFFECT_TYPE_DOWNMIX = UUID + .fromString("381e49cc-a858-4aa2-87f6-e8388e7601b2"); + private static final int DOWNMIX_PARAM_TYPE = 0; + + //Testing security bug: 63526567 + public void testEnvironmentalReverb_setParameter() throws Exception { + verifyZeroPVSizeRejectedForSetParameter( + AudioEffect.EFFECT_TYPE_ENV_REVERB, new int[] { + EnvironmentalReverb.PARAM_ROOM_LEVEL, + EnvironmentalReverb.PARAM_ROOM_HF_LEVEL, + EnvironmentalReverb.PARAM_DECAY_TIME, + EnvironmentalReverb.PARAM_DECAY_HF_RATIO, + EnvironmentalReverb.PARAM_REFLECTIONS_LEVEL, + EnvironmentalReverb.PARAM_REFLECTIONS_DELAY, + EnvironmentalReverb.PARAM_REVERB_LEVEL, + EnvironmentalReverb.PARAM_REVERB_DELAY, + EnvironmentalReverb.PARAM_DIFFUSION, + EnvironmentalReverb.PARAM_DENSITY, + 10 // EnvironmentalReverb.PARAM_PROPERTIES + } + ); + } + private boolean eqSetParamProperties(int media) { MediaPlayer mp = null; Equalizer eq = null; @@ -170,10 +211,9 @@ public class EffectBundleTest extends InstrumentationTestCase { mp = MediaPlayer.create(getInstrumentation().getContext(), getMediaId(media)); eq = new Equalizer(0 /*priority*/, mp.getAudioSessionId()); - int intSize = 4; //bytes int shortSize = 2; //bytes - int cmdCode = 5; // EFFECT_CMD_SET_PARAM + int cmdCode = EFFECT_CMD_SET_PARAM; byte command[] = concatArrays(/*status*/ intToByteArray(0), /*psize*/ intToByteArray(1 * intSize), /*vsize*/ intToByteArray(2 * shortSize), @@ -214,7 +254,6 @@ public class EffectBundleTest extends InstrumentationTestCase { eq = new Equalizer(0 /*priority*/, mp.getAudioSessionId()); short band = 2; - int intSize = 4; //bytes //baseline int cmdCode = 8; // EFFECT_CMD_GET_PARAM @@ -364,6 +403,74 @@ public class EffectBundleTest extends InstrumentationTestCase { } } + // Verifies that for all the effects of the specified type + // an attempt to pass psize = 0 or vsize = 0 to 'set parameter' command + // is rejected by the effect. + private void verifyZeroPVSizeRejectedForSetParameter( + UUID effectType, final int paramCodes[]) throws Exception { + + boolean effectFound = false; + for (AudioEffect.Descriptor descriptor : AudioEffect.queryEffects()) { + if (descriptor.type.compareTo(effectType) != 0) continue; + + effectFound = true; + AudioEffect ae = null; + MediaPlayer mp = null; + try { + mp = MediaPlayer.create(getInstrumentation().getContext(), R.raw.good); + java.lang.reflect.Constructor ct = AudioEffect.class.getConstructor( + UUID.class, UUID.class, int.class, int.class); + try { + ae = (AudioEffect) ct.newInstance(descriptor.type, descriptor.uuid, + /*priority*/ 0, mp.getAudioSessionId()); + } catch (Exception e) { + // Not every effect can be instantiated by apps. + Log.w(TAG, "Failed to create effect " + descriptor.uuid); + continue; + } + java.lang.reflect.Method command = AudioEffect.class.getDeclaredMethod( + "command", int.class, byte[].class, byte[].class); + for (int paramCode : paramCodes) { + executeSetParameter(ae, command, intSize, 0, paramCode); + executeSetParameter(ae, command, 0, intSize, paramCode); + } + } finally { + if (ae != null) { + ae.release(); + } + if (mp != null) { + mp.release(); + } + } + } + + if (!effectFound) { + Log.w(TAG, "No effect with type " + effectType + " was found"); + } + } + + private void executeSetParameter(AudioEffect ae, java.lang.reflect.Method command, + int paramSize, int valueSize, int paramCode) throws Exception { + byte cmdBuf[] = concatArrays(/*status*/ intToByteArray(0), + /*psize*/ intToByteArray(paramSize), + /*vsize*/ intToByteArray(valueSize), + /*data[0]*/ intToByteArray(paramCode)); + byte reply[] = new byte[intSize]; + Integer ret = (Integer)command.invoke(ae, EFFECT_CMD_SET_PARAM, cmdBuf, reply); + if (ret >= 0) { + int val = byteArrayToInt(reply, 0 /*offset*/); + assertTrue("Negative reply value expected, effect " + ae.getDescriptor().uuid + + ", parameter " + paramCode + ", reply value " + val, + val < 0); + } else { + // Some effect implementations detect this condition at the command dispatch level, + // and reject command execution. That's also OK, but log a message so the test + // author can double check if 'paramCode' is correct. + Log.w(TAG, "\"Set parameter\" command rejected for effect " + ae.getDescriptor().uuid + + ", parameter " + paramCode + ", return code " + ret); + } + } + private static byte[] intToByteArray(int value) { ByteBuffer converter = ByteBuffer.allocate(4); converter.order(ByteOrder.nativeOrder()); diff --git a/tests/tests/security/src/android/security/cts/StagefrightTest.java b/tests/tests/security/src/android/security/cts/StagefrightTest.java index 965e85512a0..74422034136 100644 --- a/tests/tests/security/src/android/security/cts/StagefrightTest.java +++ b/tests/tests/security/src/android/security/cts/StagefrightTest.java @@ -69,6 +69,10 @@ public class StagefrightTest extends InstrumentationTestCase { before any existing test methods ***********************************************************/ + public void testStagefright_bug_62187433() throws Exception { + doStagefrightTest(R.raw.bug_62187433); + } + public void testStagefrightANR_bug_62673844() throws Exception { doStagefrightTestANR(R.raw.bug_62673844); } diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java index 7abbf19c4c4..0ca28974217 100644 --- a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java +++ b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java @@ -31,7 +31,7 @@ public class CtsBuildProvider implements IBuildProvider { @Option(name="cts-install-path", description="the path to the cts installation to use") private String mCtsRootDirPath = System.getProperty("CTS_ROOT"); - public static final String CTS_BUILD_VERSION = "6.0_r23"; + public static final String CTS_BUILD_VERSION = "6.0_r24"; public static final String CTS_PACKAGE = "com.android.cts.tradefed.testtype"; /** |