Merge "Ensure layout occurs before testing divider height" into mnc-dev
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 43afa87..750d8db 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -1727,6 +1727,40 @@
<string name="activity_not_found">No activity found to handle intent: %s</string>
<string name="open_settings_button_label">Open Application Settings</string>
<string name="finish_button_label">Finish</string>
+ <string name="device_owner_device_admin_visible">Device administrator settings</string>
+ <string name="device_owner_device_admin_visible_info">
+ Please press the Go button to open the Security page in Settings.
+ Navigate to Device administrators and confirm that:\n
+ \n
+ - \"CTS Verifier - AfW Admin\" exists and is activated.\n
+ - \"CTS Verifier - AfW Admin\" cannot be disabled.\n
+ \n
+ Use the Back button to return to this page.
+ </string>
+ <string name="device_owner_disallow_config_bt">Disallow configuring Bluetooth</string>
+ <string name="device_owner_disallow_config_bt_info">
+ Please press the Set restriction button to set the user restriction.
+ Then press Go to open the Bluetooth page in Settings.
+ Confirm that:\n
+ \n
+ - You cannot view Bluetooth devices in range.\n
+ - You cannot edit, add or remove any already paired devices.\n
+ \n
+ Use the Back button to return to this page.
+ </string>
+ <string name="device_owner_disallow_config_wifi">Disallow configuring WiFi</string>
+ <string name="device_owner_disallow_config_wifi_info">
+ Please press the Set restriction button to set the user restriction.
+ Then press Go to open the WiFi page in Settings.
+ Confirm that:\n
+ \n
+ - You cannot view WiFi networks in range.\n
+ - You cannot edit, add or remove any existing WiFi configs.\n
+ \n
+ Use the Back button to return to this page.
+ </string>
+ <string name="device_owner_user_restriction_set">Set restriction</string>
+ <string name="device_owner_settings_go">Go</string>
<!-- Strings for JobScheduler Tests -->
<string name="js_test_description">This test is mostly automated, but requires some user interaction. You can pass this test once the list items below are checked.</string>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java
index e6bbdee..a6a5e5a 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java
@@ -25,6 +25,7 @@
import android.content.pm.PackageManager;
import android.database.DataSetObserver;
import android.os.Bundle;
+import android.os.UserManager;
import android.provider.Settings;
import android.util.Log;
import android.view.View;
@@ -66,11 +67,14 @@
static final String EXTRA_SETTING = "extra-setting";
private static final String CHECK_DEVICE_OWNER_TEST_ID = "CHECK_DEVICE_OWNER";
+ private static final String DEVICE_ADMIN_SETTINGS_ID = "DEVICE_ADMIN_SETTINGS";
private static final String WIFI_LOCKDOWN_TEST_ID = WifiLockdownTestActivity.class.getName();
private static final String DISABLE_STATUS_BAR_TEST_ID = "DISABLE_STATUS_BAR";
private static final String DISABLE_KEYGUARD_TEST_ID = "DISABLE_KEYGUARD";
private static final String CHECK_PERMISSION_LOCKDOWN_TEST_ID =
PermissionLockdownTestActivity.class.getName();
+ private static final String DISALLOW_CONFIG_BT_ID = "DISALLOW_CONFIG_BT";
+ private static final String DISALLOW_CONFIG_WIFI_ID = "DISALLOW_CONFIG_WIFI";
private static final String REMOVE_DEVICE_OWNER_TEST_ID = "REMOVE_DEVICE_OWNER";
@Override
@@ -132,11 +136,49 @@
new Intent(this, CommandReceiver.class)
.putExtra(EXTRA_COMMAND, COMMAND_CHECK_DEVICE_OWNER)
));
+
+ // device admin settings
+ adapter.add(createInteractiveTestItem(this, DEVICE_ADMIN_SETTINGS_ID,
+ R.string.device_owner_device_admin_visible,
+ R.string.device_owner_device_admin_visible_info,
+ new ButtonInfo(
+ R.string.device_owner_settings_go,
+ new Intent(Settings.ACTION_SECURITY_SETTINGS))));
+
PackageManager packageManager = getPackageManager();
if (packageManager.hasSystemFeature(PackageManager.FEATURE_WIFI)) {
+ // WiFi Lock down tests
adapter.add(createTestItem(this, WIFI_LOCKDOWN_TEST_ID,
R.string.device_owner_wifi_lockdown_test,
new Intent(this, WifiLockdownTestActivity.class)));
+
+ // DISALLOW_CONFIG_WIFI
+ adapter.add(createInteractiveTestItem(this, DISALLOW_CONFIG_WIFI_ID,
+ R.string.device_owner_disallow_config_wifi,
+ R.string.device_owner_disallow_config_wifi_info,
+ new ButtonInfo[] {
+ new ButtonInfo(
+ R.string.device_owner_user_restriction_set,
+ createSetUserRestrictionIntent(
+ UserManager.DISALLOW_CONFIG_WIFI)),
+ new ButtonInfo(
+ R.string.device_owner_settings_go,
+ new Intent(Settings.ACTION_WIFI_SETTINGS))}));
+ }
+
+ // DISALLOW_CONFIG_BLUETOOTH
+ if (packageManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
+ adapter.add(createInteractiveTestItem(this, DISALLOW_CONFIG_BT_ID,
+ R.string.device_owner_disallow_config_bt,
+ R.string.device_owner_disallow_config_bt_info,
+ new ButtonInfo[] {
+ new ButtonInfo(
+ R.string.device_owner_user_restriction_set,
+ createSetUserRestrictionIntent(
+ UserManager.DISALLOW_CONFIG_BLUETOOTH)),
+ new ButtonInfo(
+ R.string.device_owner_settings_go,
+ new Intent(Settings.ACTION_BLUETOOTH_SETTINGS))}));
}
// setStatusBarDisabled
@@ -215,6 +257,12 @@
.putExtra(EXTRA_PARAMETER_1, value);
}
+ private Intent createSetUserRestrictionIntent(String restriction) {
+ return new Intent(this, CommandReceiver.class)
+ .putExtra(EXTRA_COMMAND, COMMAND_ADD_USER_RESTRICTION)
+ .putExtra(EXTRA_RESTRICTION, restriction);
+ }
+
public static class CommandReceiver extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -276,6 +324,8 @@
dpm.setStatusBarDisabled(admin, false);
dpm.setKeyguardDisabled(admin, false);
+ dpm.clearUserRestriction(admin, UserManager.DISALLOW_CONFIG_BLUETOOTH);
+ dpm.clearUserRestriction(admin, UserManager.DISALLOW_CONFIG_WIFI);
dpm.clearDeviceOwnerApp(getPackageName());
}
}
diff --git a/hostsidetests/appsecurity/src/com/android/cts/appsecurity/ExternalStorageHostTest.java b/hostsidetests/appsecurity/src/com/android/cts/appsecurity/ExternalStorageHostTest.java
index d74ec52..cb67c63 100644
--- a/hostsidetests/appsecurity/src/com/android/cts/appsecurity/ExternalStorageHostTest.java
+++ b/hostsidetests/appsecurity/src/com/android/cts/appsecurity/ExternalStorageHostTest.java
@@ -215,6 +215,10 @@
// Verify they both have isolated view of storage
runDeviceTests(MULTIUSER_PKG, MULTIUSER_CLASS, "testReadIsolatedStorage", owner);
runDeviceTests(MULTIUSER_PKG, MULTIUSER_CLASS, "testReadIsolatedStorage", secondary);
+
+ // Verify they can't poke at each other
+ runDeviceTests(MULTIUSER_PKG, MULTIUSER_CLASS, "testUserIsolation", owner);
+ runDeviceTests(MULTIUSER_PKG, MULTIUSER_CLASS, "testUserIsolation", secondary);
} finally {
getDevice().uninstallPackage(MULTIUSER_PKG);
removeUsersForTest(users);
diff --git a/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/src/com/android/cts/multiuserstorageapp/MultiUserStorageTest.java b/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/src/com/android/cts/multiuserstorageapp/MultiUserStorageTest.java
index ed84a66..d9f00d2 100644
--- a/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/src/com/android/cts/multiuserstorageapp/MultiUserStorageTest.java
+++ b/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/src/com/android/cts/multiuserstorageapp/MultiUserStorageTest.java
@@ -16,6 +16,7 @@
package com.android.cts.multiuserstorageapp;
+import static com.android.cts.externalstorageapp.CommonExternalStorageTest.assertDirNoAccess;
import static com.android.cts.externalstorageapp.CommonExternalStorageTest.getAllPackageSpecificPathsExceptObb;
import static com.android.cts.externalstorageapp.CommonExternalStorageTest.readInt;
import static com.android.cts.externalstorageapp.CommonExternalStorageTest.writeInt;
@@ -119,6 +120,24 @@
readInt(buildRawObbPath(FILE_OBB_SINGLETON)));
}
+ /**
+ * Verify that we can't poke at storage of other users.
+ */
+ public void testUserIsolation() throws Exception {
+ final File myPath = Environment.getExternalStorageDirectory();
+ final int myId = android.os.Process.myUid() / 100000;
+ assertEquals(String.valueOf(myId), myPath.getName());
+
+ Log.d(TAG, "My path is " + myPath);
+ final File basePath = myPath.getParentFile();
+ for (int i = 0; i < 128; i++) {
+ if (i == myId) continue;
+
+ final File otherPath = new File(basePath, String.valueOf(i));
+ assertDirNoAccess(otherPath);
+ }
+ }
+
private File buildApiObbPath(String file) {
return new File(getContext().getObbDir(), file);
}
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/AndroidManifest.xml b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/AndroidManifest.xml
index 07b6953..ed920e9 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/AndroidManifest.xml
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/AndroidManifest.xml
@@ -18,6 +18,9 @@
package="com.android.cts.deviceandprofileowner">
<uses-sdk android:minSdkVersion="23"/>
+ <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
+ <uses-permission android:name="android.permission.GET_ACCOUNTS" />
+ <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<application>
<uses-library android:name="android.test.runner" />
@@ -50,6 +53,15 @@
</intent-filter>
</activity>
+ <service android:name=".MockAccountService" android:exported="true">
+ <intent-filter>
+ <action android:name="android.accounts.AccountAuthenticator" />
+ </intent-filter>
+
+ <meta-data android:name="android.accounts.AccountAuthenticator"
+ android:resource="@xml/authenticator" />
+ </service>
+
</application>
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/res/values/strings.xml b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/res/values/strings.xml
new file mode 100644
index 0000000..4aca824
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/res/values/strings.xml
@@ -0,0 +1,20 @@
+<?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 xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- Label for this package -->
+ <string name="authenticator_label">Android CTS - Device and Profile Owner</string>
+</resources>
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/res/xml/authenticator.xml b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/res/xml/authenticator.xml
new file mode 100644
index 0000000..0d8ecd8
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/res/xml/authenticator.xml
@@ -0,0 +1,22 @@
+<!-- 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.
+-->
+
+<!-- The attributes in this XML file provide configuration information -->
+<!-- for the Account Manager. -->
+
+<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
+ android:accountType="com.android.cts.deviceandprofileowner.account.type"
+ android:label="@string/authenticator_label"
+/>
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AccountManagementTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AccountManagementTest.java
new file mode 100644
index 0000000..c40539b
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AccountManagementTest.java
@@ -0,0 +1,179 @@
+/*
+ * 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.cts.deviceandprofileowner;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.accounts.AccountManagerFuture;
+import android.accounts.AuthenticatorException;
+import android.accounts.OperationCanceledException;
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
+import android.os.Bundle;
+
+import java.io.IOException;
+
+/**
+ * Functionality tests for {@link DevicePolicyManager#setAccountManagementDisabled}
+ *
+ * Fire up a remote unprivileged service and attempt to add/remove/list
+ * accounts from it to verify the enforcement is in place.
+ *
+ * This test depend on MockAccountService, which provides authenticator of type
+ * {@code com.android.cts.deviceandprofileowner.account.type}
+ */
+public class AccountManagementTest extends BaseDeviceAdminTest {
+
+ // Account type for MockAccountAuthenticator
+ private final static String ACCOUNT_TYPE_1 =
+ "com.android.cts.deviceandprofileowner.account.type";
+ private final static String ACCOUNT_TYPE_2 = "com.dummy.account";
+ private final static Account ACCOUNT_0 = new Account("user0", ACCOUNT_TYPE_1);
+ private final static Account ACCOUNT_1 = new Account("user1", ACCOUNT_TYPE_1);
+
+ private AccountManager mAccountManager;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mAccountManager = (AccountManager) mContext.getSystemService(Context.ACCOUNT_SERVICE);
+ clearAllAccountManagementDisabled();
+ removeAllAccounts();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ clearAllAccountManagementDisabled();
+ removeAllAccounts();
+ super.tearDown();
+ }
+
+ public void testAccountManagementDisabled_setterAndGetter() {
+ // Some local tests: adding and removing disabled accounts and make sure
+ // DevicePolicyManager keeps track of the disabled set correctly
+ assertEquals(0, mDevicePolicyManager.getAccountTypesWithManagementDisabled().length);
+
+ mDevicePolicyManager.setAccountManagementDisabled(ADMIN_RECEIVER_COMPONENT, ACCOUNT_TYPE_1,
+ true);
+ assertEquals(1, mDevicePolicyManager.getAccountTypesWithManagementDisabled().length);
+ assertEquals(ACCOUNT_TYPE_1,
+ mDevicePolicyManager.getAccountTypesWithManagementDisabled()[0]);
+
+ mDevicePolicyManager.setAccountManagementDisabled(ADMIN_RECEIVER_COMPONENT, ACCOUNT_TYPE_1,
+ false);
+ assertEquals(0, mDevicePolicyManager.getAccountTypesWithManagementDisabled().length);
+ }
+
+ public void testAccountManagementDisabled_addAccount() throws AuthenticatorException,
+ IOException, OperationCanceledException {
+ // Test for restriction on addAccount()
+ mDevicePolicyManager.setAccountManagementDisabled(ADMIN_RECEIVER_COMPONENT, ACCOUNT_TYPE_1,
+ true);
+ // Test if disabling ACCOUNT_TYPE_2 affects ACCOUNT_TYPE_1
+ mDevicePolicyManager.setAccountManagementDisabled(ADMIN_RECEIVER_COMPONENT, ACCOUNT_TYPE_2,
+ false);
+ assertEquals(1, mDevicePolicyManager.getAccountTypesWithManagementDisabled().length);
+
+ assertEquals(0, mAccountManager.getAccountsByType(ACCOUNT_TYPE_1).length);
+ // Management is disabled, adding account should fail.
+ try {
+ mAccountManager.addAccount(ACCOUNT_TYPE_1, null, null, null, null, null, null)
+ .getResult();
+ fail("Expected OperationCanceledException is not thrown.");
+ } catch (OperationCanceledException e) {
+ // Expected
+ }
+ assertEquals(0, mAccountManager.getAccountsByType(ACCOUNT_TYPE_1).length);
+
+ // Management is re-enabled, adding account should succeed.
+ mDevicePolicyManager.setAccountManagementDisabled(ADMIN_RECEIVER_COMPONENT, ACCOUNT_TYPE_1,
+ false);
+ assertEquals(0, mDevicePolicyManager.getAccountTypesWithManagementDisabled().length);
+ Bundle result = mAccountManager.addAccount(ACCOUNT_TYPE_1,
+ null, null, null, null, null, null).getResult();
+
+ // Normally the expected result of addAccount() is AccountManager returning
+ // an intent to start the authenticator activity for adding new accounts.
+ // But MockAccountAuthenticator returns a new account straightway.
+ assertEquals(ACCOUNT_TYPE_1, result.getString(AccountManager.KEY_ACCOUNT_TYPE));
+ }
+
+ public void testAccountManagementDisabled_removeAccount() throws AuthenticatorException,
+ IOException, OperationCanceledException {
+ // Test for restriction on removeAccount()
+ mDevicePolicyManager.setAccountManagementDisabled(ADMIN_RECEIVER_COMPONENT, ACCOUNT_TYPE_1,
+ true);
+ mDevicePolicyManager.setAccountManagementDisabled(ADMIN_RECEIVER_COMPONENT, ACCOUNT_TYPE_2,
+ false);
+ assertEquals(1, mDevicePolicyManager.getAccountTypesWithManagementDisabled().length);
+
+ assertEquals(0, mAccountManager.getAccountsByType(ACCOUNT_TYPE_1).length);
+ // First prepare some accounts by manually adding them,
+ // setAccountManagementDisabled(true) should not stop addAccountExplicitly().
+ assertTrue(mAccountManager.addAccountExplicitly(ACCOUNT_0, "password", null));
+ assertTrue(mAccountManager.addAccountExplicitly(ACCOUNT_1, "password", null));
+ assertEquals(2, mAccountManager.getAccountsByType(ACCOUNT_TYPE_1).length);
+
+ // Removing account should fail, as we just disabled it.
+ try {
+ mAccountManager.removeAccount(ACCOUNT_0, null, null).getResult();
+ fail("Expected OperationCanceledException is not thrown.");
+ } catch (OperationCanceledException e) {
+ // Expected
+ }
+ assertEquals(2, mAccountManager.getAccountsByType(ACCOUNT_TYPE_1).length);
+
+ // Re-enable management, so we can successfully remove account this time.
+ mDevicePolicyManager.setAccountManagementDisabled(ADMIN_RECEIVER_COMPONENT, ACCOUNT_TYPE_1,
+ false);
+ assertEquals(0, mDevicePolicyManager.getAccountTypesWithManagementDisabled().length);
+ assertTrue(mAccountManager.removeAccount(ACCOUNT_0, null, null).getResult());
+
+ // Make sure the removal actually succeeds.
+ Account[] accounts = mAccountManager.getAccountsByType(ACCOUNT_TYPE_1);
+ assertEquals(1, accounts.length);
+ assertEquals(ACCOUNT_1, accounts[0]);
+
+ // Disable account type 2, we should still be able to remove from type 1.
+ mDevicePolicyManager.setAccountManagementDisabled(ADMIN_RECEIVER_COMPONENT, ACCOUNT_TYPE_2,
+ true);
+ assertEquals(1, mDevicePolicyManager.getAccountTypesWithManagementDisabled().length);
+ assertTrue(mAccountManager.removeAccount(ACCOUNT_1, null, null).getResult());
+
+ // Make sure the removal actually succeeds.
+ assertEquals(0, mAccountManager.getAccountsByType(ACCOUNT_TYPE_1).length);
+ }
+
+ private void clearAllAccountManagementDisabled() {
+ for (String accountType : mDevicePolicyManager.getAccountTypesWithManagementDisabled()) {
+ mDevicePolicyManager.setAccountManagementDisabled(ADMIN_RECEIVER_COMPONENT, accountType,
+ false);
+ }
+ assertEquals(0, mDevicePolicyManager.getAccountTypesWithManagementDisabled().length);
+ }
+
+ private void removeAllAccounts() throws OperationCanceledException, AuthenticatorException,
+ IOException {
+ for (Account account : mAccountManager.getAccountsByType(ACCOUNT_TYPE_1)) {
+ AccountManagerFuture<Boolean> result = mAccountManager.removeAccount(account, null,
+ null);
+ assertTrue(result.getResult());
+ }
+ assertEquals(0, mAccountManager.getAccountsByType(ACCOUNT_TYPE_1).length);
+ }
+
+}
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/MockAccountAuthenticator.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/MockAccountAuthenticator.java
new file mode 100644
index 0000000..161410f
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/MockAccountAuthenticator.java
@@ -0,0 +1,100 @@
+/*
+ * 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.cts.deviceandprofileowner;
+
+import android.accounts.AbstractAccountAuthenticator;
+import android.accounts.Account;
+import android.accounts.AccountAuthenticatorResponse;
+import android.accounts.AccountManager;
+import android.accounts.NetworkErrorException;
+import android.content.Context;
+import android.os.Bundle;
+
+/* package */ class MockAccountAuthenticator extends AbstractAccountAuthenticator {
+ private static MockAccountAuthenticator sMockAuthenticator = null;
+ private static final String ACCOUNT_NAME = "com.android.cts.deviceandprofileowner.account.name";
+ private static final String ACCOUNT_TYPE = "com.android.cts.deviceandprofileowner.account.type";
+ private static final String AUTH_TOKEN = "mockAuthToken";
+ private static final String AUTH_TOKEN_LABEL = "mockAuthTokenLabel";
+
+ private MockAccountAuthenticator(Context context) {
+ super(context);
+ }
+
+ private Bundle createResultBundle() {
+ Bundle result = new Bundle();
+ result.putString(AccountManager.KEY_ACCOUNT_NAME, ACCOUNT_NAME);
+ result.putString(AccountManager.KEY_ACCOUNT_TYPE, ACCOUNT_TYPE);
+ result.putString(AccountManager.KEY_AUTHTOKEN, AUTH_TOKEN);
+
+ return result;
+ }
+
+ @Override
+ public Bundle addAccount(AccountAuthenticatorResponse response, String accountType,
+ String authTokenType, String[] requiredFeatures, Bundle options)
+ throws NetworkErrorException {
+ return createResultBundle();
+ }
+
+ @Override
+ public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) {
+ return createResultBundle();
+ }
+
+ @Override
+ public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account,
+ String authTokenType, Bundle options) throws NetworkErrorException {
+ return createResultBundle();
+ }
+
+ @Override
+ public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account,
+ Bundle options) throws NetworkErrorException {
+
+ Bundle result = new Bundle();
+ result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, true);
+ return result;
+ }
+
+ @Override
+ public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account,
+ String authTokenType, Bundle options) throws NetworkErrorException {
+ return createResultBundle();
+ }
+
+ @Override
+ public String getAuthTokenLabel(String authTokenType) {
+ return AUTH_TOKEN_LABEL;
+ }
+
+ @Override
+ public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account,
+ String[] features) throws NetworkErrorException {
+
+ Bundle result = new Bundle();
+ result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, true);
+ return result;
+ }
+
+ public static synchronized MockAccountAuthenticator getMockAuthenticator(Context context) {
+ if (null == sMockAuthenticator) {
+ sMockAuthenticator = new MockAccountAuthenticator(context);
+ }
+ return sMockAuthenticator;
+ }
+}
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/MockAccountService.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/MockAccountService.java
new file mode 100644
index 0000000..dfedccb
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/MockAccountService.java
@@ -0,0 +1,32 @@
+/*
+ * 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.cts.deviceandprofileowner;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+
+/**
+ * a basic Mock Service for wrapping the MockAccountAuthenticator
+ */
+public class MockAccountService extends Service {
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return MockAccountAuthenticator.getMockAuthenticator(this).getIBinder();
+ }
+}
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CustomDeviceOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CustomDeviceOwnerTest.java
index adf81a3..e6351c5 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CustomDeviceOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CustomDeviceOwnerTest.java
@@ -37,6 +37,24 @@
private static final String ADMIN_RECEIVER_TEST_CLASS =
DEVICE_OWNER_PKG + ".BaseDeviceOwnerTest$BasicAdminReceiver";
+ private static final String ADMIN_RECEIVER_COMPONENT =
+ DEVICE_OWNER_PKG + "/" + ADMIN_RECEIVER_TEST_CLASS;
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ if (mHasFeature) {
+ installApp(DEVICE_OWNER_APK);
+ }
+ }
+
+ public void tearDown() throws Exception {
+ if (mHasFeature) {
+ getDevice().uninstallPackage(DEVICE_OWNER_PKG);
+ }
+
+ super.tearDown();
+ }
public void testOwnerChangedBroadcast() throws Exception {
if (!mHasFeature) {
@@ -44,7 +62,6 @@
}
try {
installApp(INTENT_RECEIVER_APK);
- installApp(DEVICE_OWNER_APK);
String testClass = INTENT_RECEIVER_PKG + ".OwnerChangedBroadcastTest";
@@ -54,15 +71,27 @@
"testOwnerChangedBroadcastNotReceived", 0));
// Setting the device owner should send the owner changed broadcast.
- setDeviceOwner(DEVICE_OWNER_PKG + "/" + ADMIN_RECEIVER_TEST_CLASS);
+ assertTrue(setDeviceOwner(ADMIN_RECEIVER_COMPONENT));
assertTrue(runDeviceTests(INTENT_RECEIVER_PKG, testClass,
"testOwnerChangedBroadcastReceived", 0));
} finally {
+ getDevice().uninstallPackage(INTENT_RECEIVER_PKG);
assertTrue("Failed to remove device owner.",
runDeviceTests(DEVICE_OWNER_PKG, CLEAR_DEVICE_OWNER_TEST_CLASS));
- getDevice().uninstallPackage(DEVICE_OWNER_PKG);
- getDevice().uninstallPackage(INTENT_RECEIVER_PKG);
+ }
+ }
+
+ public void testCannotSetDeviceOwnerWhenSecondaryUserPresent() throws Exception {
+ if (!mHasFeature) {
+ return;
+ }
+ int userId = -1;
+ try {
+ userId = createUser();
+ assertFalse(setDeviceOwner(ADMIN_RECEIVER_COMPONENT));
+ } finally {
+ removeUser(userId);
}
}
}
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
index 45f3618..36dab2c 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
@@ -16,12 +16,6 @@
package com.android.cts.devicepolicy;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.log.LogUtil.CLog;
-
-import junit.framework.AssertionFailedError;
-
/**
* Set of tests for usecases that apply to profile and device owner.
* This class is the base class of MixedProfileOwnerTest and MixedDeviceOwnerTest and is abstract
@@ -46,6 +40,7 @@
// is the user id of the created profile.
protected int mUserId;
+ @Override
protected void tearDown() throws Exception {
if (mHasFeature) {
getDevice().uninstallPackage(DEVICE_ADMIN_PKG);
@@ -164,6 +159,15 @@
executeDeviceTestClass(".ApplicationHiddenTest");
}
+ // TODO: Remove AccountManagementTest from XTS after GTS is released for MNC.
+ public void testAccountManagement() throws Exception {
+ if (!mHasFeature) {
+ return;
+ }
+
+ executeDeviceTestClass(".AccountManagementTest");
+ }
+
protected void executeDeviceTestClass(String className) throws Exception {
assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, className, mUserId));
}
diff --git a/libs/deviceutil/src/android/cts/util/MediaUtils.java b/libs/deviceutil/src/android/cts/util/MediaUtils.java
index c04a2cf..c595e10 100644
--- a/libs/deviceutil/src/android/cts/util/MediaUtils.java
+++ b/libs/deviceutil/src/android/cts/util/MediaUtils.java
@@ -459,12 +459,13 @@
return avgs;
}
- public static void logResults(ReportLog log, String prefix,
+ public static String logResults(ReportLog log, String prefix,
double min, double max, double avg, double stdev) {
String msg = prefix;
msg += " min=" + Math.round(min / 1000) + " max=" + Math.round(max / 1000) +
" avg=" + Math.round(avg / 1000) + " stdev=" + Math.round(stdev / 1000);
log.printValue(msg, 1000000000 / min, ResultType.HIGHER_BETTER, ResultUnit.FPS);
+ return msg;
}
public static VideoCapabilities getVideoCapabilities(String codecName, String mime) {
@@ -512,4 +513,17 @@
return (measured >= lowerBoundary1 && measured <= upperBoundary1 &&
measured >= lowerBoundary2 && measured <= upperBoundary2);
}
+
+ public static String getErrorMessage(
+ Range<Double> reportedRange, double[] measuredFps, String[] rawData) {
+ String msg = "";
+ if (reportedRange == null) {
+ msg += "Failed to get achievable frame rate.\n";
+ } else {
+ msg += "Expected achievable frame rate range: " + reportedRange + ".\n";
+ }
+ msg += "Measured frame rate: " + Arrays.toString(measuredFps) + ".\n";
+ msg += "Raw data: " + Arrays.toString(rawData) + ".\n";
+ return msg;
+ }
}
diff --git a/suite/cts/deviceTests/videoperf/src/com/android/cts/videoperf/VideoEncoderDecoderTest.java b/suite/cts/deviceTests/videoperf/src/com/android/cts/videoperf/VideoEncoderDecoderTest.java
index 8fc5a44..62f37c5 100644
--- a/suite/cts/deviceTests/videoperf/src/com/android/cts/videoperf/VideoEncoderDecoderTest.java
+++ b/suite/cts/deviceTests/videoperf/src/com/android/cts/videoperf/VideoEncoderDecoderTest.java
@@ -516,6 +516,8 @@
boolean encTestPassed = false;
boolean decTestPassed = false;
+ double[] measuredFps = new double[mTestConfig.mNumberOfRepeat];
+ String[] resultRawData = new String[mTestConfig.mNumberOfRepeat];
for (int i = 0; i < mTestConfig.mNumberOfRepeat; i++) {
// make sure that rms error is not too big.
if (decoderRmsErrorResults[i] >= mRmsErrorMargain) {
@@ -542,8 +544,11 @@
String prefix = "codec=" + encoderName + " round=" + i +
" EncInputFormat=" + mEncInputFormat +
" EncOutputFormat=" + mEncOutputFormat;
- MediaUtils.logResults(mReportLog, prefix, encMin, encMax, encAvg, encStdev);
+ String result =
+ MediaUtils.logResults(mReportLog, prefix, encMin, encMax, encAvg, encStdev);
double measuredEncFps = 1000000000 / encMin;
+ resultRawData[i] = result;
+ measuredFps[i] = measuredEncFps;
if (!encTestPassed) {
encTestPassed = MediaUtils.verifyResults(
encoderName, mimeType, w, h, measuredEncFps);
@@ -565,10 +570,14 @@
}
}
}
+
if (mTestConfig.mTestResult) {
if (!encTestPassed) {
- fail("Measured fps for " + encoderName +
- " doesn't match with reported achievable frame rates.");
+ Range<Double> reportedRange =
+ MediaUtils.getAchievableFrameRatesFor(encoderName, mimeType, w, h);
+ String failMessage =
+ MediaUtils.getErrorMessage(reportedRange, measuredFps, resultRawData);
+ fail(failMessage);
}
// Decoder result will be verified in VideoDecoderPerfTest
// if (!decTestPassed) {
@@ -576,6 +585,8 @@
// " doesn't match with reported achievable frame rates.");
// }
}
+ measuredFps = null;
+ resultRawData = null;
}
/**
diff --git a/tests/tests/assist/AndroidManifest.xml b/tests/tests/assist/AndroidManifest.xml
index c5772ad..b6cd684 100644
--- a/tests/tests/assist/AndroidManifest.xml
+++ b/tests/tests/assist/AndroidManifest.xml
@@ -28,6 +28,7 @@
<intent-filter>
<action android:name="android.intent.action.TEST_START_ACTIVITY_ASSIST_STRUCTURE" />
<action android:name="android.intent.action.TEST_START_ACTIVITY_DISABLE_CONTEXT" />
+ <action android:name="android.intent.action.TEST_START_ACTIVITY_FLAG_SECURE" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
diff --git a/tests/tests/assist/common/src/android/assist/common/Utils.java b/tests/tests/assist/common/src/android/assist/common/Utils.java
index 1831182..bf051c0 100644
--- a/tests/tests/assist/common/src/android/assist/common/Utils.java
+++ b/tests/tests/assist/common/src/android/assist/common/Utils.java
@@ -15,18 +15,11 @@
*/
package android.assist.common;
-import android.app.VoiceInteractor;
-import android.app.VoiceInteractor.PickOptionRequest.Option;
-import android.content.BroadcastReceiver;
+import android.R;
import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
import android.os.Bundle;
-import android.util.Log;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.concurrent.CountDownLatch;
public class Utils {
public static final String TESTCASE_TYPE = "testcase_type";
@@ -42,8 +35,10 @@
public static final int TIMEOUT_MS = 2 * 1000; // TODO(awlee): what is the timeout
+ /** Test name suffixes */
public static final String ASSIST_STRUCTURE = "ASSIST_STRUCTURE";
public static final String DISABLE_CONTEXT = "DISABLE_CONTEXT";
+ public static final String FLAG_SECURE = "FLAG_SECURE";
/**
* The shim activity that starts the service associated with each test.
@@ -51,6 +46,7 @@
public static final String getTestActivity(String testCaseType) {
switch (testCaseType) {
case ASSIST_STRUCTURE:
+ case FLAG_SECURE:
return "service.AssistStructureActivity";
case DISABLE_CONTEXT:
return "service.DisableContextActivity";
@@ -65,8 +61,12 @@
public static final ComponentName getTestAppComponent(String testCaseType) {
switch (testCaseType) {
case ASSIST_STRUCTURE:
+ case DISABLE_CONTEXT:
return new ComponentName(
"android.assist.testapp", "android.assist.testapp.TestApp");
+ case FLAG_SECURE:
+ return new ComponentName(
+ "android.assist.testapp", "android.assist.testapp.SecureActivity");
default:
return new ComponentName("","");
}
@@ -90,19 +90,6 @@
return buf.toString();
}
- public static final String toOptionsString(Option[] options) {
- StringBuilder sb = new StringBuilder();
- sb.append("{");
- for (int i = 0; i < options.length; i++) {
- if (i >= 1) {
- sb.append(", ");
- }
- sb.append(options[i].getLabel());
- }
- sb.append("}");
- return sb.toString();
- }
-
public static final void addErrorResult(final Bundle testinfo, final String msg) {
testinfo.getStringArrayList(testinfo.getString(Utils.TESTCASE_TYPE))
.add(TEST_ERROR + " " + msg);
diff --git a/tests/tests/assist/service/AndroidManifest.xml b/tests/tests/assist/service/AndroidManifest.xml
index 543568d..2c5206a 100644
--- a/tests/tests/assist/service/AndroidManifest.xml
+++ b/tests/tests/assist/service/AndroidManifest.xml
@@ -34,6 +34,7 @@
<activity android:name=".AssistStructureActivity" >
<intent-filter>
<action android:name="android.intent.action.START_TEST_ASSIST_STRUCTURE" />
+ <action android:name="android.intent.action.START_TEST_FLAG_SECURE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
diff --git a/tests/tests/assist/service/src/android/voiceinteraction/service/DisableContextActivity.java b/tests/tests/assist/service/src/android/voiceinteraction/service/DisableContextActivity.java
index 0db7ec1..52ba7ac 100644
--- a/tests/tests/assist/service/src/android/voiceinteraction/service/DisableContextActivity.java
+++ b/tests/tests/assist/service/src/android/voiceinteraction/service/DisableContextActivity.java
@@ -38,6 +38,7 @@
super.onStart();
Intent intent = new Intent();
intent.setComponent(new ComponentName(this, MainInteractionService.class));
+ finish();
ComponentName serviceName = startService(intent);
Log.i(TAG, "Started service: " + serviceName);
}
diff --git a/tests/tests/assist/service/src/android/voiceinteraction/service/MainInteractionService.java b/tests/tests/assist/service/src/android/voiceinteraction/service/MainInteractionService.java
index 684c817..85bd6ea 100644
--- a/tests/tests/assist/service/src/android/voiceinteraction/service/MainInteractionService.java
+++ b/tests/tests/assist/service/src/android/voiceinteraction/service/MainInteractionService.java
@@ -17,7 +17,6 @@
package android.assist.service;
import android.content.ComponentName;
-import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.service.voice.VoiceInteractionService;
diff --git a/tests/tests/assist/service/src/android/voiceinteraction/service/MainInteractionSession.java b/tests/tests/assist/service/src/android/voiceinteraction/service/MainInteractionSession.java
index 7b77ea0..9a835c2 100644
--- a/tests/tests/assist/service/src/android/voiceinteraction/service/MainInteractionSession.java
+++ b/tests/tests/assist/service/src/android/voiceinteraction/service/MainInteractionSession.java
@@ -16,27 +16,19 @@
package android.assist.service;
-import android.app.VoiceInteractor;
-import android.app.VoiceInteractor.Prompt;
import android.app.assist.AssistContent;
import android.app.assist.AssistStructure;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.service.voice.VoiceInteractionSession;
-import android.service.voice.VoiceInteractionSession.ConfirmationRequest;
-import android.service.voice.VoiceInteractionSession.PickOptionRequest;
import android.util.Log;
import java.io.ByteArrayOutputStream;
-import java.util.ArrayList;
-import java.util.List;
import android.assist.common.Utils;
-import android.webkit.URLUtil;
public class MainInteractionSession extends VoiceInteractionSession {
static final String TAG = "MainInteractionSession";
@@ -93,7 +85,7 @@
@Override
public void onHandleScreenshot(/*@Nullable*/ Bitmap screenshot) {
- Log.i(TAG, "onHandleScreenshot");
+ Log.i(TAG, String.format("onHandleScreenshot - Screenshot: %s", screenshot));
super.onHandleScreenshot(screenshot);
ByteArrayOutputStream bs = new ByteArrayOutputStream();
if (screenshot != null) {
diff --git a/tests/tests/assist/src/android/assist/TestStartActivity.java b/tests/tests/assist/src/android/assist/TestStartActivity.java
index c0549c6..df9b534 100644
--- a/tests/tests/assist/src/android/assist/TestStartActivity.java
+++ b/tests/tests/assist/src/android/assist/TestStartActivity.java
@@ -21,12 +21,9 @@
import android.app.Activity;
import android.content.Intent;
import android.content.ComponentName;
-import android.content.Context;
import android.os.Bundle;
import android.util.Log;
-import android.assist.common.Utils;
-
public class TestStartActivity extends Activity {
static final String TAG = "TestStartActivity";
@@ -42,22 +39,21 @@
Log.i(TAG, " in onResume");
}
- public void startTest(String testCaseType) {
- Log.i(TAG, "Starting test activity for TestCaseType = " + testCaseType);
+ public void startTest(String testCaseName) {
+ Log.i(TAG, "Starting test activity for TestCaseType = " + testCaseName);
Intent intent = new Intent();
- intent.putExtra(Utils.TESTCASE_TYPE, testCaseType);
- intent.setAction("android.intent.action.START_TEST_" + testCaseType);
+ intent.putExtra(Utils.TESTCASE_TYPE, testCaseName);
+ intent.setAction("android.intent.action.START_TEST_" + testCaseName);
intent.setComponent(new ComponentName("android.assist.service",
- "android.assist." + Utils.getTestActivity(testCaseType)));
+ "android.assist." + Utils.getTestActivity(testCaseName)));
startActivity(intent);
}
- public void start3pApp() {
+ public void start3pApp(String testCaseName) {
Intent intent = new Intent();
- intent.setComponent(new ComponentName("android.assist.testapp",
- "android.assist.testapp.TestApp"));
+ intent.setAction("android.intent.action.TEST_APP_" + testCaseName);
+ intent.setComponent(Utils.getTestAppComponent(testCaseName));
startActivity(intent);
-
}
@Override protected void onPause() {
diff --git a/tests/tests/assist/src/android/assist/cts/AssistStructureTest.java b/tests/tests/assist/src/android/assist/cts/AssistStructureTest.java
index d113774..97ab290 100644
--- a/tests/tests/assist/src/android/assist/cts/AssistStructureTest.java
+++ b/tests/tests/assist/src/android/assist/cts/AssistStructureTest.java
@@ -16,25 +16,10 @@
package android.assist.cts;
-import android.assist.TestStartActivity;
import android.assist.common.Utils;
-import android.app.assist.AssistContent;
-import android.app.assist.AssistStructure;
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.cts.util.SystemUtil;
-import android.os.Bundle;
-import android.test.ActivityInstrumentationTestCase2;
-import android.util.Log;
+import android.provider.Settings;
-import java.lang.Exception;
-import java.lang.Override;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
/**
* Test that the AssistStructure returned is properly formatted.
@@ -57,22 +42,11 @@
}
public void testAssistStructure() throws Exception {
- // TODO(awlee): verify that the context/screenshot setting is on if appropriate
- if (mAssistContent == null) {
- fail("Received null assistBundle or assistContent.");
- return;
- }
- if (mAssistBundle == null) {
- fail("Received null assistBundle.");
- return;
- }
+ assertEquals("1", Settings.Secure.getString(
+ mContext.getContentResolver(), "assist_structure_enabled"));
- if (mAssistStructure == null) {
- fail("Received null assistStructure");
- return;
- } else {
- verifyAssistStructure(Utils.getTestAppComponent(TEST_CASE_TYPE),
+ verifyAssistDataNullness(false, false, false, false);
+ verifyAssistStructure(Utils.getTestAppComponent(TEST_CASE_TYPE),
false /*FLAG_SECURE set*/);
- }
}
}
\ No newline at end of file
diff --git a/tests/tests/assist/src/android/assist/cts/AssistTestBase.java b/tests/tests/assist/src/android/assist/cts/AssistTestBase.java
index b2ec739..e6d08cf 100644
--- a/tests/tests/assist/src/android/assist/cts/AssistTestBase.java
+++ b/tests/tests/assist/src/android/assist/cts/AssistTestBase.java
@@ -19,7 +19,6 @@
import android.assist.TestStartActivity;
import android.assist.common.Utils;
-import android.app.Activity;
import android.app.assist.AssistContent;
import android.app.assist.AssistStructure;
import android.content.BroadcastReceiver;
@@ -27,9 +26,11 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.res.XmlResourceParser;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
+import android.provider.Settings;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
@@ -57,6 +58,11 @@
protected void setUp() throws Exception {
super.setUp();
mContext = getInstrumentation().getTargetContext();
+ assertEquals("1", Settings.Secure.getString(
+ mContext.getContentResolver(), "assist_structure_enabled"));
+ assertEquals("1", Settings.Secure.getString(
+ mContext.getContentResolver(), "assist_screenshot_enabled"));
+ logContextAndScreenshotSetting();
}
@Override
@@ -71,7 +77,7 @@
mTestName = testName;
intent.setAction("android.intent.action.TEST_START_ACTIVITY_" + testName);
intent.setComponent(new ComponentName(getInstrumentation().getContext(),
- TestStartActivity.class));
+ TestStartActivity.class));
setActivityIntent(intent);
mTestActivity = getActivity();
}
@@ -86,9 +92,9 @@
}
mReceiver = new TestResultsReceiver();
mContext.registerReceiver(mReceiver,
- new IntentFilter(Utils.BROADCAST_ASSIST_DATA_INTENT));
+ new IntentFilter(Utils.BROADCAST_ASSIST_DATA_INTENT));
- mTestActivity.start3pApp();
+ mTestActivity.start3pApp(mTestName);
mTestActivity.startTest(mTestName);
if (!mLatch.await(Utils.TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
fail("Failed to receive broadcast in " + Utils.TIMEOUT_MS + "msec");
@@ -97,6 +103,43 @@
return true;
}
+ /**
+ * Checks that the nullness of values are what we expect.
+ * @param isBundleNull True if assistBundle should be null.
+ * @param isStructureNull True if assistStructure should be null.
+ * @param isContentNull True if assistContent should be null.
+ * @param isScreenshotNull True if screenshot should be null.
+ */
+ protected void verifyAssistDataNullness(boolean isBundleNull, boolean isStructureNull,
+ boolean isContentNull, boolean isScreenshotNull) {
+
+ if ((mAssistContent == null) != isContentNull) {
+ fail(String.format("Should %s have been null - AssistContent: %s",
+ isContentNull? "":"not", mAssistContent));
+ }
+
+ if ((mAssistStructure == null) != isStructureNull) {
+ fail(String.format("Should %s have been null - AssistStructure: %s",
+ isStructureNull ? "" : "not", mAssistStructure));
+ }
+
+ if ((mAssistBundle == null) != isBundleNull) {
+ fail(String.format("Should %s have been null - AssistBundle: %s",
+ isBundleNull? "":"not", mAssistBundle));
+ }
+
+ if ((mScreenshot == null) != isScreenshotNull) {
+ fail(String.format("Should %s have been null - Screenshot: %s",
+ isScreenshotNull? "":"not", mScreenshot));
+ }
+ }
+
+ /**
+ * Traverses and compares the view heirarchy of the backgroundApp and the view we expect.
+ *
+ * @param backgroundApp ComponentName of app the assistant is invoked upon
+ * @param isSecureWindow Denotes whether the activity has FLAG_SECURE set
+ */
protected void verifyAssistStructure(ComponentName backgroundApp, boolean isSecureWindow) {
// Check component name matches
assertEquals(backgroundApp.flattenToString(),
@@ -106,10 +149,18 @@
assertEquals(1, numWindows);
for (int i = 0; i < numWindows; i++) {
AssistStructure.ViewNode node = mAssistStructure.getWindowNodeAt(i).getRootViewNode();
- // TODO: traverse view heirarchy and verify it matches what we expect
+ // TODO: Actually traverse the view heirarchy and verify it matches what we expect
+ // If isSecureWindow, will not have any children.
}
}
+ protected void logContextAndScreenshotSetting() {
+ Log.i(TAG, "Context is: " + Settings.Secure.getString(
+ mContext.getContentResolver(), "assist_structure_enabled"));
+ Log.i(TAG, "Screenshot is: " + Settings.Secure.getString(
+ mContext.getContentResolver(), "assist_screenshot_enabled"));
+ }
+
class TestResultsReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
diff --git a/tests/tests/assist/src/android/assist/cts/DisableContextTest.java b/tests/tests/assist/src/android/assist/cts/DisableContextTest.java
index 6801737..9407ec5 100644
--- a/tests/tests/assist/src/android/assist/cts/DisableContextTest.java
+++ b/tests/tests/assist/src/android/assist/cts/DisableContextTest.java
@@ -53,8 +53,8 @@
SystemUtil.runShellCommand(getInstrumentation(),
"settings put secure assist_structure_enabled 0");
SystemUtil.runShellCommand(getInstrumentation(),
- "settings put secure assist_screenshot_enabled 0");
-
+ "settings put secure assist_screenshot_enabled 0");
+ logContextAndScreenshotSetting();
startTestActivity(TEST_CASE_TYPE);
waitForBroadcast();
}
@@ -64,20 +64,14 @@
SystemUtil.runShellCommand(getInstrumentation(),
"settings put secure assist_structure_enabled 1");
SystemUtil.runShellCommand(getInstrumentation(),
- "settings put secure assist_screenshot_enabled 1");
+ "settings put secure assist_screenshot_enabled 1");
+ logContextAndScreenshotSetting();
super.tearDown();
}
public void testContextAndScreenshotOff() throws Exception {
// Both settings off
- if (mAssistContent != null || mAssistBundle != null || mAssistStructure != null) {
- fail(String.format("Should have all been null - Bundle: %s, Structure: %s, Content: %s",
- mAssistBundle, mAssistStructure, mAssistContent));
- }
-
- if (mScreenshot != null) {
- fail(String.format("Should have been null - Screenshot: %s", mScreenshot));
- }
+ verifyAssistDataNullness(true, true, true, true);
// Screenshot off, context on
SystemUtil.runShellCommand(getInstrumentation(),
@@ -86,29 +80,19 @@
"settings put secure assist_screenshot_enabled 0");
waitForBroadcast();
- if (mScreenshot != null) {
- fail(String.format("Should have been null - Screenshot: %s", mScreenshot));
- }
+ logContextAndScreenshotSetting();
- if (mAssistContent == null || mAssistBundle == null) {
- fail(String.format("Should not have been null - Bundle: %s, Content: %s",
- mAssistBundle, mAssistContent));
- }
+ verifyAssistDataNullness(false, false, false, true);
// Context off, screenshot on
SystemUtil.runShellCommand(getInstrumentation(),
- "settings put secure assist_screenshot_enabled 1");
- SystemUtil.runShellCommand(getInstrumentation(),
"settings put secure assist_structure_enabled 0");
+ SystemUtil.runShellCommand(getInstrumentation(),
+ "settings put secure assist_screenshot_enabled 1");
waitForBroadcast();
- if (mScreenshot == null) {
- fail(String.format("Should not have been null - Screenshot: %s", mScreenshot));
- }
+ logContextAndScreenshotSetting();
- if (mAssistContent != null || mAssistBundle != null || mAssistStructure != null) {
- fail(String.format("Should have all been null - Bundle: %s, Structure: %s, Content: %s",
- mAssistBundle, mAssistStructure, mAssistContent));
- }
+ verifyAssistDataNullness(true, true, true, false);
}
}
\ No newline at end of file
diff --git a/tests/tests/assist/src/android/assist/cts/FlagSecureTest.java b/tests/tests/assist/src/android/assist/cts/FlagSecureTest.java
new file mode 100644
index 0000000..0e79d9d
--- /dev/null
+++ b/tests/tests/assist/src/android/assist/cts/FlagSecureTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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 android.assist.cts;
+
+import android.assist.common.Utils;
+
+import java.util.concurrent.CountDownLatch;
+
+/**
+ * Test we receive proper assist data (root assistStructure with no children) when the assistant is
+ * invoked on an app with FLAG_SECURE set.
+ */
+public class FlagSecureTest extends AssistTestBase {
+
+ static final String TAG = "DisableContextTest";
+
+ private static final String TEST_CASE_TYPE = Utils.FLAG_SECURE;
+
+ public FlagSecureTest() {
+ super();
+ }
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ startTestActivity(TEST_CASE_TYPE);
+ waitForBroadcast();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testSecureActivity() throws Exception {
+ verifyAssistDataNullness(false, false, false, true);
+
+ // verify that we have only the root window and not its children.
+ verifyAssistStructure(Utils.getTestAppComponent(TEST_CASE_TYPE), true);
+ }
+}
\ No newline at end of file
diff --git a/tests/tests/assist/testapp/AndroidManifest.xml b/tests/tests/assist/testapp/AndroidManifest.xml
index 5b16ed7..371ae7b 100644
--- a/tests/tests/assist/testapp/AndroidManifest.xml
+++ b/tests/tests/assist/testapp/AndroidManifest.xml
@@ -19,16 +19,25 @@
package="android.assist.testapp">
<application>
- <uses-library android:name="android.test.runner" />
+ <uses-library android:name="android.test.runner" />
- <activity android:name="TestApp"
+ <activity android:name="TestApp"
android:label="Assist Test App"
android:theme="@android:style/Theme.Material.Light">
<intent-filter>
- <action android:name="android.intent.action.TEST_APP" />
+ <action android:name="android.intent.action.TEST_APP_ASSIST_STRUCTURE" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.VOICE" />
</intent-filter>
- </activity>
+ </activity>
+ <activity android:name="SecureActivity"
+ android:label="Secure Test App"
+ android:theme="@android:style/Theme.Material.Light">
+ <intent-filter>
+ <action android:name="android.intent.action.TEST_APP_FLAG_SECURE" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.VOICE" />
+ </intent-filter>
+ </activity>
</application>
</manifest>
diff --git a/tests/tests/assist/testapp/res/layout/voice_interaction_main.xml b/tests/tests/assist/testapp/res/layout/secure_app.xml
similarity index 100%
rename from tests/tests/assist/testapp/res/layout/voice_interaction_main.xml
rename to tests/tests/assist/testapp/res/layout/secure_app.xml
diff --git a/tests/tests/assist/testapp/res/layout/voice_interaction_main.xml b/tests/tests/assist/testapp/res/layout/test_app.xml
similarity index 100%
copy from tests/tests/assist/testapp/res/layout/voice_interaction_main.xml
copy to tests/tests/assist/testapp/res/layout/test_app.xml
diff --git a/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/SecureActivity.java b/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/SecureActivity.java
new file mode 100644
index 0000000..83f7549
--- /dev/null
+++ b/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/SecureActivity.java
@@ -0,0 +1,36 @@
+/*
+ * 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 android.assist.testapp;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.util.Log;
+
+import android.view.WindowManager;
+
+public class SecureActivity extends Activity {
+ static final String TAG = "SecureActivity";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Log.i(TAG, "SecureActivity created");
+ setContentView(R.layout.secure_app);
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
+ WindowManager.LayoutParams.FLAG_SECURE);
+ }
+}
\ No newline at end of file
diff --git a/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/TestApp.java b/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/TestApp.java
index 7fa9653..85a9342 100644
--- a/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/TestApp.java
+++ b/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/TestApp.java
@@ -17,17 +17,9 @@
package android.assist.testapp;
import android.app.Activity;
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
-import java.util.ArrayList;
-
-import android.assist.common.Utils;
-
public class TestApp extends Activity {
static final String TAG = "TestApp";
@@ -38,7 +30,7 @@
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i(TAG, "TestApp created");
- getLayoutInflater().inflate(R.layout.voice_interaction_main, null);
+ getLayoutInflater().inflate(R.layout.test_app, null);
}
@Override
diff --git a/tests/tests/hardware/Android.mk b/tests/tests/hardware/Android.mk
index 9523d87..9c26d8a 100644
--- a/tests/tests/hardware/Android.mk
+++ b/tests/tests/hardware/Android.mk
@@ -34,7 +34,7 @@
src/android/hardware/cts/SensorIntegrationTests.java \
src/android/hardware/cts/SensorBatchingTests.java \
src/android/hardware/cts/SensorTest.java \
- src/android/hardware/cts/SensorManagerStaticTest.java \
+ src/android/hardware/cts/SensorManagerStaticTest.java
LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil
@@ -57,4 +57,4 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
-include $(BUILD_CTS_PACKAGE)
\ No newline at end of file
+include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/hardware/src/android/hardware/cts/SensorParameterRangeTest.java b/tests/tests/hardware/src/android/hardware/cts/SensorParameterRangeTest.java
new file mode 100644
index 0000000..4750b09
--- /dev/null
+++ b/tests/tests/hardware/src/android/hardware/cts/SensorParameterRangeTest.java
@@ -0,0 +1,115 @@
+/*
+ * 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 android.hardware.cts;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.hardware.Sensor;
+import android.hardware.SensorManager;
+import android.hardware.cts.helpers.SensorCtsHelper;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Test min-max frequency, max range parameters for sensors.
+ *
+ * <p>To execute these test cases, the following command can be used:</p>
+ * <pre>
+ * adb shell am instrument -e class android.hardware.cts.SensorParameterRangeTest \
+ * -w com.android.cts.hardware/android.test.AndroidJUnitRunner
+ * </pre>
+ */
+public class SensorParameterRangeTest extends SensorTestCase {
+
+ private static final double ACCELEROMETER_MAX_RANGE = 8 * 9.81; // 8G
+ private static final int ACCELEROMETER_MIN_FREQUENCY = 5;
+ private static final int ACCELEROMETER_MAX_FREQUENCY = 200;
+
+ private static final double GYRO_MAX_RANGE = 1000/57.295; // 1000 degrees per sec.
+ private static final int GYRO_MIN_FREQUENCY = 5;
+ private static final int GYRO_MAX_FREQUENCY = 200;
+
+ private static final int MAGNETOMETER_MAX_RANGE = 900; // micro telsa
+ private static final int MAGNETOMETER_MIN_FREQUENCY = 5;
+ private static final int MAGNETOMETER_MAX_FREQUENCY = 50;
+
+ private static final int PRESSURE_MAX_RANGE = 1100; // hecto-pascal
+ private static final int PRESSURE_MIN_FREQUENCY = 1;
+ private static final int PRESSURE_MAX_FREQUENCY = 10;
+
+ private boolean mHasHifiSensors;
+ private SensorManager mSensorManager;
+
+ @Override
+ public void setUp() {
+ mSensorManager = (SensorManager) getContext().getSystemService(Context.SENSOR_SERVICE);
+ mHasHifiSensors = getContext().getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_HIFI_SENSORS);
+ }
+
+ public void testAccelerometerRange() {
+ checkSensorRangeAndFrequency(
+ mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
+ ACCELEROMETER_MAX_RANGE,
+ ACCELEROMETER_MIN_FREQUENCY,
+ ACCELEROMETER_MAX_FREQUENCY);
+ }
+
+ public void testGyroscopeRange() {
+ checkSensorRangeAndFrequency(
+ mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE),
+ GYRO_MAX_RANGE,
+ GYRO_MIN_FREQUENCY,
+ GYRO_MAX_FREQUENCY);
+ }
+
+ public void testMagnetometerRange() {
+ checkSensorRangeAndFrequency(
+ mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD),
+ MAGNETOMETER_MAX_RANGE,
+ MAGNETOMETER_MIN_FREQUENCY,
+ MAGNETOMETER_MAX_FREQUENCY);
+ }
+
+ public void testPressureRange() {
+ checkSensorRangeAndFrequency(
+ mSensorManager.getDefaultSensor(Sensor.TYPE_PRESSURE),
+ PRESSURE_MAX_RANGE,
+ PRESSURE_MIN_FREQUENCY,
+ PRESSURE_MAX_FREQUENCY);
+ }
+
+ private void checkSensorRangeAndFrequency(
+ Sensor sensor, double maxRange, int minFrequency, int maxFrequency) {
+ if (!mHasHifiSensors) return;
+ assertTrue(String.format("%s Range actual=%.2f expected=%.2f %s",
+ sensor.getName(), sensor.getMaximumRange(), maxRange,
+ SensorCtsHelper.getUnitsForSensor(sensor)),
+ sensor.getMaximumRange() >= maxRange);
+ double actualMinFrequency = SensorCtsHelper.getFrequency(sensor.getMaxDelay(),
+ TimeUnit.MICROSECONDS);
+ assertTrue(String.format("%s Min Frequency actual=%.2f expected=%dHz",
+ sensor.getName(), actualMinFrequency, minFrequency), actualMinFrequency <=
+ minFrequency);
+
+ double actualMaxFrequency = SensorCtsHelper.getFrequency(sensor.getMinDelay(),
+ TimeUnit.MICROSECONDS);
+ assertTrue(String.format("%s Max Frequency actual=%.2f expected=%dHz",
+ sensor.getName(), actualMaxFrequency, maxFrequency), actualMaxFrequency >=
+ maxFrequency);
+ }
+}
diff --git a/tests/tests/hardware/src/android/hardware/cts/SensorSupportTest.java b/tests/tests/hardware/src/android/hardware/cts/SensorSupportTest.java
new file mode 100644
index 0000000..2f25c8d
--- /dev/null
+++ b/tests/tests/hardware/src/android/hardware/cts/SensorSupportTest.java
@@ -0,0 +1,101 @@
+/*
+ * 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 android.hardware.cts;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.hardware.Sensor;
+import android.hardware.SensorManager;
+import android.test.AndroidTestCase;
+
+/**
+ * Checks if Hifi sensors are supported. When supported, checks individual support for
+ * Accelerometer, Gyroscope, Gyroscope_uncal, GeoMagneticField, MagneticField_uncal
+ * Pressure, RotationVector, SignificantMotion, StepDetector, StepCounter, TiltDetector.
+ *
+ * <p>To execute these test cases, the following command can be used:</p>
+ * <pre>
+ * adb shell am instrument -e class android.hardware.cts.SensorSupportTest \
+ * -w com.android.cts.hardware/android.test.AndroidJUnitRunner
+ * </pre>
+ */
+public class SensorSupportTest extends AndroidTestCase {
+ private SensorManager mSensorManager;
+ private boolean mAreHifiSensorsSupported;
+
+ @Override
+ public void setUp() {
+ // Tests will only run if HIFI_SENSORS are supported.
+ mAreHifiSensorsSupported = getContext().getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_HIFI_SENSORS);
+ if (mAreHifiSensorsSupported) {
+ mSensorManager =
+ (SensorManager) getContext().getSystemService(Context.SENSOR_SERVICE);
+ }
+ }
+
+ public void testSupportsAccelerometer() {
+ checkSupportsSensor(Sensor.TYPE_ACCELEROMETER);
+ }
+
+ public void testSupportsGyroscope() {
+ checkSupportsSensor(Sensor.TYPE_GYROSCOPE);
+ }
+
+ public void testSupportsGyroscopeUncalibrated() {
+ checkSupportsSensor(Sensor.TYPE_GYROSCOPE_UNCALIBRATED);
+ }
+
+ public void testSupportsGeoMagneticField() {
+ checkSupportsSensor(Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR);
+ }
+
+ public void testSupportsMagneticFieldUncalibrated() {
+ checkSupportsSensor(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED);
+ }
+
+ public void testSupportsPressure() {
+ checkSupportsSensor(Sensor.TYPE_PRESSURE);
+ }
+
+ public void testSupportsRotationVector() {
+ checkSupportsSensor(Sensor.TYPE_ROTATION_VECTOR);
+ }
+
+ public void testSupportsSignificantMotion() {
+ checkSupportsSensor(Sensor.TYPE_SIGNIFICANT_MOTION);
+ }
+
+ public void testSupportsStepDetector() {
+ checkSupportsSensor(Sensor.TYPE_STEP_DETECTOR);
+ }
+
+ public void testSupportsStepCounter() {
+ checkSupportsSensor(Sensor.TYPE_STEP_COUNTER);
+ }
+
+ public void testSupportsTiltDetector() {
+ final int TYPE_TILT_DETECTOR = 22;
+ checkSupportsSensor(TYPE_TILT_DETECTOR);
+ }
+
+ private void checkSupportsSensor(int sensorType) {
+ if (mAreHifiSensorsSupported) {
+ assertTrue(mSensorManager.getDefaultSensor(sensorType) != null);
+ }
+ }
+}
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/SensorCtsHelper.java b/tests/tests/hardware/src/android/hardware/cts/helpers/SensorCtsHelper.java
index 490e965..55465ac 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/SensorCtsHelper.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/SensorCtsHelper.java
@@ -15,6 +15,7 @@
*/
package android.hardware.cts.helpers;
+import android.hardware.Sensor;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -259,4 +260,20 @@
throw new IllegalStateException("Collection cannot be null or empty");
}
}
+
+ public static String getUnitsForSensor(Sensor sensor) {
+ switch(sensor.getType()) {
+ case Sensor.TYPE_ACCELEROMETER:
+ return "m/s^2";
+ case Sensor.TYPE_MAGNETIC_FIELD:
+ case Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED:
+ return "uT";
+ case Sensor.TYPE_GYROSCOPE:
+ case Sensor.TYPE_GYROSCOPE_UNCALIBRATED:
+ return "radians/sec";
+ case Sensor.TYPE_PRESSURE:
+ return "hPa";
+ };
+ return "";
+ }
}
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/JitterVerification.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/JitterVerification.java
index 6633903..e5a5053 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/JitterVerification.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/JitterVerification.java
@@ -18,6 +18,10 @@
import junit.framework.Assert;
+import android.content.Context;
+import android.content.pm.PackageManager;
+
+import android.util.Log;
import android.hardware.Sensor;
import android.hardware.cts.helpers.SensorCtsHelper;
import android.hardware.cts.helpers.SensorStats;
@@ -39,6 +43,8 @@
// sensorType: threshold (% of expected period)
private static final SparseIntArray DEFAULTS = new SparseIntArray(12);
+ // Max allowed jitter (in percentage).
+ private static final int THRESHOLD_PERCENT_FOR_HIFI_SENSORS = 1;
static {
// Use a method so that the @deprecation warning can be set for that method only
setDefaults();
@@ -68,6 +74,11 @@
if (threshold == -1) {
return null;
}
+ boolean hasHifiSensors = environment.getContext().getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_HIFI_SENSORS);
+ if (hasHifiSensors) {
+ threshold = THRESHOLD_PERCENT_FOR_HIFI_SENSORS;
+ }
return new JitterVerification(threshold);
}
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/StandardDeviationVerification.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/StandardDeviationVerification.java
index f7c2c53..20dd2d2 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/StandardDeviationVerification.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/StandardDeviationVerification.java
@@ -18,10 +18,13 @@
import junit.framework.Assert;
+import android.content.Context;
+import android.content.pm.PackageManager;
import android.hardware.Sensor;
import android.hardware.cts.helpers.SensorStats;
import android.hardware.cts.helpers.TestSensorEnvironment;
import android.hardware.cts.helpers.TestSensorEvent;
+import android.util.Log;
import java.util.HashMap;
import java.util.Map;
@@ -66,7 +69,21 @@
if (!DEFAULTS.containsKey(sensorType)) {
return null;
}
+ boolean hasHifiSensors = environment.getContext().getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_HIFI_SENSORS);
+ if (hasHifiSensors) {
+ // Max accelerometer deviation: 400uG/√Hz
+ DEFAULTS.put(Sensor.TYPE_ACCELEROMETER, new float[]{0.004f, 0.004f, 0.004f});
+ // Max gyro deviation: 0.014°/s/√Hz
+ float deviationInRadians = (float) (0.014f * (Math.PI / 180));
+ DEFAULTS.put(Sensor.TYPE_GYROSCOPE,
+ new float[]{deviationInRadians,deviationInRadians, deviationInRadians});
+ // Max magnetometer deviation: 0.1uT/√Hz
+ DEFAULTS.put(Sensor.TYPE_MAGNETIC_FIELD, new float[]{0.1f, 0.1f, 0.1f});
+ // Max pressure deviation: 2Pa/√Hz
+ DEFAULTS.put(Sensor.TYPE_PRESSURE, new float[]{2.0f, 2.0f, 2.0f});
+ }
return new StandardDeviationVerification(DEFAULTS.get(sensorType));
}
@@ -107,9 +124,9 @@
if (stdDevs[i] > mThreshold[i]) {
failed = true;
}
- stddevSb.append(String.format("%.2f", stdDevs[i]));
+ stddevSb.append(String.format("%.3f", stdDevs[i]));
if (i != stdDevs.length - 1) stddevSb.append(", ");
- expectedSb.append(String.format("<%.2f", mThreshold[i]));
+ expectedSb.append(String.format("<%.3f", mThreshold[i]));
if (i != stdDevs.length - 1) expectedSb.append(", ");
}
if (stdDevs.length > 1) {
diff --git a/tests/tests/media/src/android/media/cts/AudioManagerTest.java b/tests/tests/media/src/android/media/cts/AudioManagerTest.java
index ded0539..a0163e5 100644
--- a/tests/tests/media/src/android/media/cts/AudioManagerTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioManagerTest.java
@@ -45,23 +45,27 @@
import android.os.Vibrator;
import android.provider.Settings;
import android.provider.Settings.System;
-import android.test.AndroidTestCase;
+import android.test.InstrumentationTestCase;
import android.view.SoundEffectConstants;
import java.util.TreeMap;
-public class AudioManagerTest extends AndroidTestCase {
+public class AudioManagerTest extends InstrumentationTestCase {
private final static int MP3_TO_PLAY = R.raw.testmp3;
private final static long TIME_TO_PLAY = 2000;
+ private final static String APPOPS_OP_STR = "android:write_settings";
private AudioManager mAudioManager;
private boolean mHasVibrator;
private boolean mUseFixedVolume;
private boolean mIsTelevision;
+ private Context mContext;
@Override
protected void setUp() throws Exception {
super.setUp();
+ mContext = getInstrumentation().getContext();
+ Utils.enableAppOps(mContext.getPackageName(), APPOPS_OP_STR, getInstrumentation());
mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
mHasVibrator = (vibrator != null) && vibrator.hasVibrator();
diff --git a/tests/tests/media/src/android/media/cts/MidiSoloTest.java b/tests/tests/media/src/android/media/cts/MidiSoloTest.java
index 4c1a5e8..d198ee8 100644
--- a/tests/tests/media/src/android/media/cts/MidiSoloTest.java
+++ b/tests/tests/media/src/android/media/cts/MidiSoloTest.java
@@ -97,9 +97,7 @@
MidiManager.DeviceCallback callback = new MidiManager.DeviceCallback();
// These should not crash.
- midiManager.unregisterDeviceCallback(null);
midiManager.unregisterDeviceCallback(callback);
- midiManager.registerDeviceCallback(null, null);
midiManager.registerDeviceCallback(callback, null);
midiManager.unregisterDeviceCallback(callback);
midiManager.registerDeviceCallback(callback, new Handler(Looper.getMainLooper()));
@@ -107,9 +105,6 @@
midiManager.unregisterDeviceCallback(callback);
midiManager.unregisterDeviceCallback(callback);
midiManager.unregisterDeviceCallback(callback);
- midiManager.registerDeviceCallback(null, new Handler(Looper.getMainLooper()));
- midiManager.unregisterDeviceCallback(callback);
- midiManager.unregisterDeviceCallback(null);
}
public void testMidiReceiver() throws Exception {
diff --git a/tests/tests/media/src/android/media/cts/RingtoneManagerTest.java b/tests/tests/media/src/android/media/cts/RingtoneManagerTest.java
index bf47a27..4693036 100644
--- a/tests/tests/media/src/android/media/cts/RingtoneManagerTest.java
+++ b/tests/tests/media/src/android/media/cts/RingtoneManagerTest.java
@@ -55,6 +55,7 @@
mActivity = getActivity();
mInstrumentation = getInstrumentation();
mContext = mInstrumentation.getContext();
+ Utils.enableAppOps(mContext.getPackageName(), "android:write_settings", mInstrumentation);
mRingtoneManager = new RingtoneManager(mActivity);
mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
// backup ringer settings
@@ -74,6 +75,7 @@
}
RingtoneManager.setActualDefaultRingtoneUri(mContext, RingtoneManager.TYPE_RINGTONE,
mDefaultUri);
+ Utils.disableAppOps(mContext.getPackageName(), "android:write_settings", mInstrumentation);
super.tearDown();
}
diff --git a/tests/tests/media/src/android/media/cts/Utils.java b/tests/tests/media/src/android/media/cts/Utils.java
new file mode 100644
index 0000000..bb9cf78
--- /dev/null
+++ b/tests/tests/media/src/android/media/cts/Utils.java
@@ -0,0 +1,70 @@
+/*
+ * 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 android.media.cts;
+
+import android.app.Instrumentation;
+import android.app.UiAutomation;
+import android.os.ParcelFileDescriptor;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Scanner;
+
+public class Utils {
+ public static void enableAppOps(String packageName, String operation,
+ Instrumentation instrumentation) {
+ setAppOps(packageName, operation, instrumentation, true);
+ }
+
+ public static void disableAppOps(String packageName, String operation,
+ Instrumentation instrumentation) {
+ setAppOps(packageName, operation, instrumentation, false);
+ }
+
+ public static String convertStreamToString(InputStream is) {
+ try (Scanner scanner = new Scanner(is).useDelimiter("\\A")) {
+ return scanner.hasNext() ? scanner.next() : "";
+ }
+ }
+
+ private static void setAppOps(String packageName, String operation,
+ Instrumentation instrumentation, boolean enable) {
+ StringBuilder cmd = new StringBuilder();
+ cmd.append("appops set ");
+ cmd.append(packageName);
+ cmd.append(" ");
+ cmd.append(operation);
+ cmd.append(enable ? " allow" : " deny");
+ instrumentation.getUiAutomation().executeShellCommand(cmd.toString());
+
+ StringBuilder query = new StringBuilder();
+ query.append("appops get ");
+ query.append(packageName);
+ query.append(" ");
+ query.append(operation);
+ String queryStr = query.toString();
+
+ String expectedResult = enable ? "allow" : "deny";
+ String result = "";
+ while(!result.contains(expectedResult)) {
+ ParcelFileDescriptor pfd = instrumentation.getUiAutomation().executeShellCommand(
+ queryStr);
+ InputStream inputStream = new FileInputStream(pfd.getFileDescriptor());
+ result = convertStreamToString(inputStream);
+ }
+ }
+}
diff --git a/tests/tests/media/src/android/media/cts/VideoDecoderPerfTest.java b/tests/tests/media/src/android/media/cts/VideoDecoderPerfTest.java
index ede5040..f5680f6 100644
--- a/tests/tests/media/src/android/media/cts/VideoDecoderPerfTest.java
+++ b/tests/tests/media/src/android/media/cts/VideoDecoderPerfTest.java
@@ -31,6 +31,7 @@
import android.media.MediaExtractor;
import android.media.MediaFormat;
import android.util.Log;
+import android.util.Range;
import android.view.Surface;
import com.android.cts.util.ResultType;
@@ -58,6 +59,8 @@
LinkedList<ByteBuffer> mSamplesInMemory = new LinkedList<ByteBuffer>();
private static final int MOVING_AVERAGE_NUM = 10;
private MediaFormat mDecOutputFormat;
+ private double[] mMeasuredFps;
+ private String[] mResultRawData;
private Resources mResources;
private DeviceReportLog mReportLog;
@@ -104,6 +107,8 @@
}
boolean pass = false;
+ mMeasuredFps = new double[NUMBER_OF_REPEAT];
+ mResultRawData = new String[NUMBER_OF_REPEAT];
Log.d(TAG, "testing " + name);
for (int i = 0; i < NUMBER_OF_REPEAT; ++i) {
// Decode to Surface.
@@ -118,7 +123,16 @@
Log.d(TAG, "round #" + i + " decode to buffer");
doDecode(name, video, width, height, null, i);
}
- assertTrue("Measured fps doesn't match with reported achievable frame rates.", pass);
+
+ if (!pass) {
+ Range<Double> reportedRange =
+ MediaUtils.getAchievableFrameRatesFor(name, mime, width, height);
+ String failMessage =
+ MediaUtils.getErrorMessage(reportedRange, mMeasuredFps, mResultRawData);
+ fail(failMessage);
+ }
+ mMeasuredFps = null;
+ mResultRawData = null;
}
// use 0 for summary line, detail for each test config is in the report.
mReportLog.printSummary("average fps", 0, ResultType.HIGHER_BETTER, ResultUnit.FPS);
@@ -276,9 +290,15 @@
double decMax = Stat.getMax(avgs);
double decAvg = Stat.getAverage(avgs);
double decStdev = MediaUtils.getStdev(avgs);
- MediaUtils.logResults(mReportLog, testConfig, decMin, decMax, decAvg, decStdev);
+ String result =
+ MediaUtils.logResults(mReportLog, testConfig, decMin, decMax, decAvg, decStdev);
+ fps = 1000000000 / decMin;
+ if (surface != null) {
+ mMeasuredFps[round] = fps;
+ mResultRawData[round] = result;
+ }
- return MediaUtils.verifyResults(name, mime, w, h, 1000000000 / decMin);
+ return MediaUtils.verifyResults(name, mime, w, h, fps);
}
public void testH2640320x0240Other() throws Exception {
diff --git a/tests/tests/permission2/src/android/permission2/cts/PermissionPolicyTest.java b/tests/tests/permission2/src/android/permission2/cts/PermissionPolicyTest.java
new file mode 100644
index 0000000..a4d68cb
--- /dev/null
+++ b/tests/tests/permission2/src/android/permission2/cts/PermissionPolicyTest.java
@@ -0,0 +1,64 @@
+/*
+* 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 android.permission2.cts;
+
+import android.Manifest;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PermissionInfo;
+import android.test.AndroidTestCase;
+import android.text.TextUtils;
+import android.util.ArraySet;
+
+import java.util.Set;
+
+/**
+ * Tests for permission policy on the platform.
+ */
+public class PermissionPolicyTest extends AndroidTestCase {
+ private static final String PLATFORM_PACKAGE_NAME = "android";
+
+ private static final Set<String> PERMISSION_GROUPS = new ArraySet<>();
+ static {
+ PERMISSION_GROUPS.add(Manifest.permission_group.CALENDAR);
+ PERMISSION_GROUPS.add(Manifest.permission_group.CAMERA);
+ PERMISSION_GROUPS.add(Manifest.permission_group.CONTACTS);
+ PERMISSION_GROUPS.add(Manifest.permission_group.LOCATION);
+ PERMISSION_GROUPS.add(Manifest.permission_group.MICROPHONE);
+ PERMISSION_GROUPS.add(Manifest.permission_group.PHONE);
+ PERMISSION_GROUPS.add(Manifest.permission_group.SENSORS);
+ PERMISSION_GROUPS.add(Manifest.permission_group.SMS);
+ PERMISSION_GROUPS.add(Manifest.permission_group.STORAGE);
+ }
+
+ public void testPlatformDefinedRuntimePermissionValid() throws Exception {
+ PackageManager packageManager = getContext().getPackageManager();
+ PackageInfo packageInfo = packageManager.getPackageInfo(PLATFORM_PACKAGE_NAME,
+ PackageManager.GET_PERMISSIONS);
+ for (PermissionInfo permission : packageInfo.permissions) {
+ if ((permission.protectionLevel & PermissionInfo.PROTECTION_DANGEROUS) == 0) {
+ continue;
+ }
+ assertTrue(permission.name + " must be in one of these groups: " + PERMISSION_GROUPS,
+ PERMISSION_GROUPS.contains(permission.group));
+ assertFalse(permission.name + " must have non-empty label",
+ TextUtils.isEmpty(permission.loadLabel(packageManager)));
+ assertFalse(permission.name + " must have non-empty description",
+ TextUtils.isEmpty(permission.loadDescription(packageManager)));
+ }
+ }
+}
diff --git a/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java b/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
index 323190c..bf063f7 100644
--- a/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
+++ b/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
@@ -86,13 +86,16 @@
String mPreviousDefaultDialer = null;
MockConnectionService connectionService = null;
+ boolean mShouldTestTelecom = true;
+
@Override
protected void setUp() throws Exception {
super.setUp();
mContext = getInstrumentation().getContext();
mTelecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
- if (shouldTestTelecom(mContext)) {
+ mShouldTestTelecom = shouldTestTelecom(mContext);
+ if (mShouldTestTelecom) {
mPreviousDefaultDialer = TestUtils.getDefaultDialer(getInstrumentation());
TestUtils.setDefaultDialer(getInstrumentation(), PACKAGE);
setupCallbacks();
@@ -101,7 +104,7 @@
@Override
protected void tearDown() throws Exception {
- if (shouldTestTelecom(mContext)) {
+ if (mShouldTestTelecom) {
cleanupCalls();
if (!TextUtils.isEmpty(mPreviousDefaultDialer)) {
TestUtils.setDefaultDialer(getInstrumentation(), mPreviousDefaultDialer);
diff --git a/tests/tests/telecom/src/android/telecom/cts/CallDetailsTest.java b/tests/tests/telecom/src/android/telecom/cts/CallDetailsTest.java
index dd93573..879c995 100644
--- a/tests/tests/telecom/src/android/telecom/cts/CallDetailsTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/CallDetailsTest.java
@@ -65,7 +65,7 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- if (TestUtils.shouldTestTelecom(mContext)) {
+ if (mShouldTestTelecom) {
PhoneAccount account = setupConnectionService(
new MockConnectionService() {
@Override
@@ -93,23 +93,27 @@
}
}, FLAG_REGISTER | FLAG_ENABLE);
+ /** Place a call as a part of the setup before we test the various
+ * Call details.
+ */
+ placeAndVerifyCall();
+ verifyConnectionForOutgoingCall();
+
+ mInCallService = mInCallCallbacks.getService();
+ mCall = mInCallService.getLastCall();
+
+ assertCallState(mCall, Call.STATE_DIALING);
}
- /** Place a call as a part of the setup before we test the various
- * Call details.
- */
- placeAndVerifyCall();
- verifyConnectionForOutgoingCall();
-
- mInCallService = mInCallCallbacks.getService();
- mCall = mInCallService.getLastCall();
-
- assertCallState(mCall, Call.STATE_DIALING);
}
/**
* Tests whether the getAccountHandle() getter returns the correct object.
*/
public void testAccountHandle() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
assertThat(mCall.getDetails().getAccountHandle(), is(PhoneAccountHandle.class));
assertEquals(TEST_PHONE_ACCOUNT_HANDLE, mCall.getDetails().getAccountHandle());
}
@@ -118,6 +122,10 @@
* Tests whether the getCallCapabilities() getter returns the correct object.
*/
public void testCallCapabilities() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
assertThat(mCall.getDetails().getCallCapabilities(), is(Integer.class));
assertEquals(CALL_CAPABILITIES, mCall.getDetails().getCallCapabilities());
assertTrue(mCall.getDetails().can(Call.Details.CAPABILITY_HOLD));
@@ -130,6 +138,10 @@
* Tests whether the getCallerDisplayName() getter returns the correct object.
*/
public void testCallerDisplayName() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
assertThat(mCall.getDetails().getCallerDisplayName(), is(String.class));
assertEquals(CALLER_DISPLAY_NAME, mCall.getDetails().getCallerDisplayName());
}
@@ -138,6 +150,10 @@
* Tests whether the getCallerDisplayNamePresentation() getter returns the correct object.
*/
public void testCallerDisplayNamePresentation() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
assertThat(mCall.getDetails().getCallerDisplayNamePresentation(), is(Integer.class));
assertEquals(CALLER_DISPLAY_NAME_PRESENTATION, mCall.getDetails().getCallerDisplayNamePresentation());
}
@@ -146,6 +162,10 @@
* Tests whether the getCallProperties() getter returns the correct object.
*/
public void testCallProperties() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
assertThat(mCall.getDetails().getCallProperties(), is(Integer.class));
assertEquals(CALL_PROPERTIES, mCall.getDetails().getCallProperties());
}
@@ -154,6 +174,10 @@
* Tests whether the getConnectTimeMillis() getter returns the correct object.
*/
public void testConnectTimeMillis() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
assertThat(mCall.getDetails().getConnectTimeMillis(), is(Long.class));
}
@@ -161,6 +185,10 @@
* Tests whether the getDisconnectCause() getter returns the correct object.
*/
public void testDisconnectCause() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
assertThat(mCall.getDetails().getDisconnectCause(), is(DisconnectCause.class));
}
@@ -168,6 +196,10 @@
* Tests whether the getExtras() getter returns the correct object.
*/
public void testExtras() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
if (mCall.getDetails().getExtras() != null) {
assertThat(mCall.getDetails().getExtras(), is(Bundle.class));
}
@@ -177,6 +209,10 @@
* Tests whether the getIntentExtras() getter returns the correct object.
*/
public void testIntentExtras() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
assertThat(mCall.getDetails().getIntentExtras(), is(Bundle.class));
}
@@ -184,6 +220,10 @@
* Tests whether the getGatewayInfo() getter returns the correct object.
*/
public void testGatewayInfo() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
if (mCall.getDetails().getGatewayInfo() != null) {
assertThat(mCall.getDetails().getGatewayInfo(), is(GatewayInfo.class));
}
@@ -193,6 +233,10 @@
* Tests whether the getHandle() getter returns the correct object.
*/
public void testHandle() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
assertThat(mCall.getDetails().getHandle(), is(Uri.class));
assertEquals(getTestNumber(), mCall.getDetails().getHandle());
}
@@ -201,6 +245,10 @@
* Tests whether the getHandlePresentation() getter returns the correct object.
*/
public void testHandlePresentation() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
assertThat(mCall.getDetails().getHandlePresentation(), is(Integer.class));
assertEquals(MockConnectionService.CONNECTION_PRESENTATION, mCall.getDetails().getHandlePresentation());
}
@@ -209,6 +257,10 @@
* Tests whether the getStatusHints() getter returns the correct object.
*/
public void testStatusHints() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
assertThat(mCall.getDetails().getStatusHints(), is(StatusHints.class));
assertEquals(mStatusHints.getLabel(), mCall.getDetails().getStatusHints().getLabel());
assertEquals(
@@ -221,6 +273,10 @@
* Tests whether the getVideoState() getter returns the correct object.
*/
public void testVideoState() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
assertThat(mCall.getDetails().getVideoState(), is(Integer.class));
}
}
diff --git a/tests/tests/telecom/src/android/telecom/cts/ConferenceTest.java b/tests/tests/telecom/src/android/telecom/cts/ConferenceTest.java
index 989045c..121d559 100644
--- a/tests/tests/telecom/src/android/telecom/cts/ConferenceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/ConferenceTest.java
@@ -51,17 +51,17 @@
protected void setUp() throws Exception {
super.setUp();
mContext = getInstrumentation().getContext();
- if (shouldTestTelecom(mContext)) {
+ if (mShouldTestTelecom) {
addOutgoingCalls();
addConferenceCall(mCall1, mCall2);
// Use vanilla conference object so that the CTS coverage tool detects the useage.
- mConferenceObject = (Conference)verifyConferenceForOutgoingCall();
+ mConferenceObject = verifyConferenceForOutgoingCall();
verifyConferenceObject(mConferenceObject, mConnection1, mConnection2);
}
}
public void testConferenceCreate() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
final Call conf = mInCallService.getLastConferenceCall();
@@ -81,7 +81,7 @@
}
public void testConferenceSplit() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
final Call conf = mInCallService.getLastConferenceCall();
@@ -101,7 +101,7 @@
}
public void testConferenceHoldAndUnhold() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
final Call conf = mInCallService.getLastConferenceCall();
@@ -119,7 +119,7 @@
}
public void testConferenceMergeAndSwap() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
final Call conf = mInCallService.getLastConferenceCall();
@@ -144,7 +144,7 @@
}
public void testConferenceSetters() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
final Call conf = mInCallService.getLastConferenceCall();
@@ -215,7 +215,7 @@
}
public void testConferenceAddAndRemoveConnection() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
final Call conf = mInCallService.getLastConferenceCall();
@@ -240,7 +240,7 @@
}
public void testConferenceDTMFTone() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
final Call conf = mInCallService.getLastConferenceCall();
diff --git a/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java b/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java
index b56db06..216ba97 100644
--- a/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java
@@ -36,13 +36,13 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- if (TestUtils.shouldTestTelecom(mContext)) {
+ if (mShouldTestTelecom) {
setupConnectionService(null, FLAG_REGISTER | FLAG_ENABLE);
}
}
public void testAddNewOutgoingCallAndThenDisconnect() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -56,7 +56,7 @@
}
public void testMuteAndUnmutePhone() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -83,7 +83,7 @@
}
public void testSwitchAudioRoutes() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -122,7 +122,7 @@
* @see {@link Call#stopDtmfTone()}
*/
public void testPlayAndStopDtmfTones() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -155,7 +155,7 @@
}
public void testHoldAndUnholdCall() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -182,6 +182,10 @@
}
public void testAnswerIncomingCallAudioOnly() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
addAndVerifyNewIncomingCall(getTestNumber(), null);
final MockConnection connection = verifyConnectionForIncomingCall();
@@ -199,6 +203,10 @@
}
public void testAnswerIncomingCallAsVideo_SendsCorrectVideoState() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
addAndVerifyNewIncomingCall(getTestNumber(), null);
final MockConnection connection = verifyConnectionForIncomingCall();
@@ -218,6 +226,10 @@
}
public void testRejectIncomingCall() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
addAndVerifyNewIncomingCall(getTestNumber(), null);
final MockConnection connection = verifyConnectionForIncomingCall();
@@ -235,7 +247,7 @@
}
public void testCanAddCall_CannotAddForExistingDialingCall() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -252,7 +264,7 @@
}
public void testCanAddCall_CanAddForExistingActiveCall() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -273,7 +285,7 @@
}
public void testCanAddCall_CannotAddIfTooManyCalls() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -308,7 +320,7 @@
}
public void testOnBringToForeground() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -340,7 +352,7 @@
}
public void testOnPostDialWaitAndContinue() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -372,7 +384,7 @@
}
public void testOnCannedTextResponsesLoaded() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
diff --git a/tests/tests/telecom/src/android/telecom/cts/NumberDialingTest.java b/tests/tests/telecom/src/android/telecom/cts/NumberDialingTest.java
index 8d6d114..8ffcf48 100644
--- a/tests/tests/telecom/src/android/telecom/cts/NumberDialingTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/NumberDialingTest.java
@@ -35,7 +35,7 @@
private static final int CS_WAIT_MILLIS = 2000;
public void testEndInPound() throws Exception {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
diff --git a/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java b/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java
index b1c77fd..f2422c9 100644
--- a/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java
@@ -30,7 +30,7 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- if (TestUtils.shouldTestTelecom(mContext)) {
+ if (mShouldTestTelecom) {
setupConnectionService(null, FLAG_REGISTER | FLAG_ENABLE);
}
}
@@ -52,6 +52,10 @@
* @see {@link TelecomManager#EXTRA_START_CALL_WITH_SPEAKERPHONE}
*/
public void testStartCallWithSpeakerphoneTrue_SpeakerphoneOnInCall() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
final Bundle extras = new Bundle();
extras.putBoolean(TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, true);
placeAndVerifyCall(extras);
@@ -60,6 +64,10 @@
}
public void testStartCallWithSpeakerphoneFalse_SpeakerphoneOffInCall() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
final Bundle extras = new Bundle();
extras.putBoolean(TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, false);
placeAndVerifyCall(extras);
@@ -68,6 +76,10 @@
}
public void testStartCallWithSpeakerphoneNotProvided_SpeakerphoneOffByDefault() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
placeAndVerifyCall();
verifyConnectionForOutgoingCall();
assertAudioRoute(mInCallCallbacks.getService(), CallAudioState.ROUTE_EARPIECE);
diff --git a/tests/tests/telecom/src/android/telecom/cts/PhoneAccountOperationsTest.java b/tests/tests/telecom/src/android/telecom/cts/PhoneAccountOperationsTest.java
index 27c8cf4..cfa8e9f 100644
--- a/tests/tests/telecom/src/android/telecom/cts/PhoneAccountOperationsTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/PhoneAccountOperationsTest.java
@@ -74,6 +74,9 @@
@Override
protected void tearDown() throws Exception {
+ if (!TestUtils.shouldTestTelecom(mContext)) {
+ return;
+ }
mTelecomManager.unregisterPhoneAccount(TEST_PHONE_ACCOUNT_HANDLE);
PhoneAccount retrievedPhoneAccount = mTelecomManager.getPhoneAccount(
TEST_PHONE_ACCOUNT_HANDLE);
diff --git a/tests/tests/telecom/src/android/telecom/cts/RemoteConferenceTest.java b/tests/tests/telecom/src/android/telecom/cts/RemoteConferenceTest.java
index d14372e..3fc65ea 100644
--- a/tests/tests/telecom/src/android/telecom/cts/RemoteConferenceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/RemoteConferenceTest.java
@@ -62,14 +62,14 @@
protected void setUp() throws Exception {
super.setUp();
mContext = getInstrumentation().getContext();
- if (shouldTestTelecom(mContext)) {
+ if (mShouldTestTelecom) {
addRemoteConferenceCall();
verifyRemoteConferenceObject(mRemoteConferenceObject, mRemoteConference, mConference);
}
}
public void testRemoteConferenceCreate() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
final Call confCall = mInCallCallbacks.getService().getLastConferenceCall();
@@ -92,7 +92,7 @@
}
public void testRemoteConferenceSplit() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
final Call confCall = mInCallCallbacks.getService().getLastConferenceCall();
@@ -114,7 +114,7 @@
}
public void testRemoteConferenceHoldAndUnhold() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
final Call confCall = mInCallCallbacks.getService().getLastConferenceCall();
@@ -146,7 +146,7 @@
}
public void testRemoteConferenceMergeAndSwap() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
final Call confCall = mInCallCallbacks.getService().getLastConferenceCall();
@@ -178,7 +178,7 @@
}
public void testRemoteConferenceDTMFTone() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
final Call confCall = mInCallCallbacks.getService().getLastConferenceCall();
@@ -201,7 +201,7 @@
}
public void testRemoteConferenceCallbacks_StateChange() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
Handler handler = setupRemoteConferenceCallbacksTest();
@@ -227,7 +227,7 @@
}
public void testRemoteConferenceCallbacks_Disconnect() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
Handler handler = setupRemoteConferenceCallbacksTest();
@@ -254,7 +254,7 @@
}
public void testRemoteConferenceCallbacks_ConnectionAdd() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
Handler handler = setupRemoteConferenceCallbacksTest();
@@ -285,7 +285,7 @@
}
public void testRemoteConferenceCallbacks_ConnectionRemove() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
Handler handler = setupRemoteConferenceCallbacksTest();
@@ -317,7 +317,7 @@
}
public void testRemoteConferenceCallbacks_ConnectionCapabilities() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
Handler handler = setupRemoteConferenceCallbacksTest();
@@ -345,7 +345,7 @@
}
public void testRemoteConferenceCallbacks_ConferenceableConnections() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
Handler handler = setupRemoteConferenceCallbacksTest();
@@ -380,7 +380,7 @@
}
public void testRemoteConferenceCallbacks_Destroy() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
Handler handler = setupRemoteConferenceCallbacksTest();
@@ -404,7 +404,7 @@
}
public void testRemoteConferenceCallbacks_Extras() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
Handler handler = setupRemoteConferenceCallbacksTest();
diff --git a/tests/tests/telecom/src/android/telecom/cts/RemoteConnectionTest.java b/tests/tests/telecom/src/android/telecom/cts/RemoteConnectionTest.java
index b4237ab..79fb592 100644
--- a/tests/tests/telecom/src/android/telecom/cts/RemoteConnectionTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/RemoteConnectionTest.java
@@ -55,7 +55,7 @@
RemoteConnection mRemoteConnectionObject;
public void testRemoteConnectionOutgoingCall() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
addRemoteConnectionOutgoingCall();
@@ -92,7 +92,7 @@
}
public void testRemoteConnectionIncomingCallAccept() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
addRemoteConnectionIncomingCall();
@@ -113,7 +113,7 @@
}
public void testRemoteConnectionIncomingCallReject() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
addRemoteConnectionIncomingCall();
@@ -134,7 +134,7 @@
}
public void testRemoteConnectionDTMFTone() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
addRemoteConnectionIncomingCall();
@@ -160,7 +160,7 @@
}
public void testRemoteConnectionCallbacks_StateChange() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -186,7 +186,7 @@
}
public void testRemoteConnectionCallbacks_RingbackRequest() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -212,7 +212,7 @@
}
public void testRemoteConnectionCallbacks_ConnectionCapabilities() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -242,7 +242,7 @@
}
public void testRemoteConnectionCallbacks_PostDialWait() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -270,7 +270,7 @@
}
public void testRemoteConnectionCallbacks_PostDialChar() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -297,7 +297,7 @@
}
public void testRemoteConnectionCallbacks_VoipAudio() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -323,7 +323,7 @@
}
public void testRemoteConnectionCallbacks_StatusHints() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -350,7 +350,7 @@
}
public void testRemoteConnectionCallbacks_AddressChange() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -379,7 +379,7 @@
}
public void testRemoteConnectionCallbacks_CallerDisplayName() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -408,7 +408,7 @@
}
public void testRemoteConnectionCallbacks_VideoState() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -434,7 +434,7 @@
}
public void testRemoteConnectionCallbacks_ConferenceableConnections() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -474,7 +474,7 @@
}
public void testRemoteConnectionCallbacks_VideoProvider() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -502,7 +502,7 @@
}
public void testRemoteConnectionCallbacks_Extras() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -531,7 +531,7 @@
}
public void testRemoteConnectionCallbacks_Disconnect() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -560,7 +560,7 @@
}
public void testRemoteConnectionCallbacks_Destroy() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -585,7 +585,7 @@
}
public void testRemoteConnectionVideoCallbacks_SessionModify() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -627,7 +627,7 @@
}
public void testRemoteConnectionVideoCallbacks_SessionEvent() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -655,7 +655,7 @@
}
public void testRemoteConnectionVideoCallbacks_PeerDimensions() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -686,7 +686,7 @@
}
public void testRemoteConnectionVideoCallbacks_CallDataUsage() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -715,7 +715,7 @@
}
public void testRemoteConnectionVideoCallbacks_CameraCapabilities() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -746,7 +746,7 @@
}
public void testRemoteConnectionVideoCallbacks_VideoQuality() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -775,7 +775,7 @@
}
public void testRemoteConnectionVideo_RequestCallDataUsage() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -810,7 +810,7 @@
}
public void testRemoteConnectionVideo_RequestCameraCapabilities() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -848,7 +848,7 @@
}
public void testRemoteConnectionVideo_SendSessionModifyRequest() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -889,7 +889,7 @@
}
public void testRemoteConnectionVideo_SendSessionModifyResponse() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -935,7 +935,7 @@
}
public void testRemoteConnectionVideo_SetCamera() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -975,7 +975,7 @@
}
public void testRemoteConnectionVideo_SetDeviceOrientation() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -998,7 +998,7 @@
}
public void testRemoteConnectionVideo_SetDisplaySurface() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -1021,7 +1021,7 @@
}
public void testRemoteConnectionVideo_SetPauseImage() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -1044,7 +1044,7 @@
}
public void testRemoteConnectionVideo_SetPreviewSurface() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
@@ -1067,7 +1067,7 @@
}
public void testRemoteConnectionVideo_SetZoom() {
- if (!shouldTestTelecom(mContext)) {
+ if (!mShouldTestTelecom) {
return;
}
diff --git a/tests/tests/telecom/src/android/telecom/cts/VideoCallTest.java b/tests/tests/telecom/src/android/telecom/cts/VideoCallTest.java
index e3ba6ef..fbfa998 100644
--- a/tests/tests/telecom/src/android/telecom/cts/VideoCallTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/VideoCallTest.java
@@ -47,7 +47,7 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- if (TestUtils.shouldTestTelecom(mContext)) {
+ if (mShouldTestTelecom) {
setupConnectionService(null, FLAG_REGISTER | FLAG_ENABLE);
}
}
@@ -56,6 +56,9 @@
* Tests ability to start a 2-way video call and retrieve its video state.
*/
public void testMakeTwoWayVideoCall() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
final MockConnection connection = verifyConnectionForOutgoingCall();
@@ -75,6 +78,10 @@
* Tests ability to start a 1-way video call and retrieve its video state.
*/
public void testMakeOneWayVideoCall() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
placeAndVerifyCall(VideoProfile.STATE_TX_ENABLED);
verifyConnectionForOutgoingCall();
@@ -89,6 +96,10 @@
* Tests ability to upgrade an audio-only call to a video call.
*/
public void testUpgradeToVideo() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
placeAndVerifyCall(VideoProfile.STATE_AUDIO_ONLY);
verifyConnectionForOutgoingCall();
@@ -109,6 +120,10 @@
* Tests ability to receive a session modification request.
*/
public void testReceiveSessionModifyRequest() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
placeAndVerifyCall(VideoProfile.STATE_AUDIO_ONLY);
final MockConnection connection = verifyConnectionForOutgoingCall();
@@ -134,6 +149,10 @@
* Tests ability to send a session modification response.
*/
public void testSendSessionModifyResponse() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
placeAndVerifyCall(VideoProfile.STATE_AUDIO_ONLY);
final MockConnection connection = verifyConnectionForOutgoingCall();
@@ -156,6 +175,10 @@
* the call.
*/
public void testVideoCallDelayProvider() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
// Don't create video provider when call is created initially; we will do this later.
try {
connectionService.setCreateVideoProvider(false);
@@ -187,6 +210,10 @@
* back in response.
*/
public void testChangeCamera() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
verifyConnectionForOutgoingCall();
@@ -208,6 +235,10 @@
* Tests ability to request the camera capabilities from the video provider.
*/
public void testRequestCameraCapabilities() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
verifyConnectionForOutgoingCall();
@@ -232,6 +263,10 @@
* Tests ability to request data usage from the video provider.
*/
public void testRequestDataUsage() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
verifyConnectionForOutgoingCall();
@@ -249,6 +284,10 @@
* Tests ability to receive changes to the video quality from the video provider.
*/
public void testReceiveVideoQuality() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
final MockConnection connection = verifyConnectionForOutgoingCall();
@@ -281,6 +320,10 @@
* Tests ability to receive call session events from the video provider.
*/
public void testReceiveCallSessionEvent() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
final MockConnection connection = verifyConnectionForOutgoingCall();
@@ -303,6 +346,10 @@
* Tests ability to receive changes to the peer dimensions from the video provider.
*/
public void testReceivePeerDimensionChange() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
final MockConnection connection = verifyConnectionForOutgoingCall();
@@ -324,6 +371,10 @@
* Tests ability to set the device orientation via the provider.
*/
public void testSetDeviceOrientation() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
final MockConnection connection = verifyConnectionForOutgoingCall();
@@ -342,6 +393,10 @@
* Tests ability to set the preview surface via the provider.
*/
public void testSetPreviewSurface() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
final MockConnection connection = verifyConnectionForOutgoingCall();
@@ -365,6 +420,10 @@
* Tests ability to set the display surface via the provider.
*/
public void testSetDisplaySurface() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
final MockConnection connection = verifyConnectionForOutgoingCall();
@@ -388,6 +447,10 @@
* Tests ability to set the camera zoom via the provider.
*/
public void testSetZoom() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
final MockConnection connection = verifyConnectionForOutgoingCall();
diff --git a/tests/tests/telecom/src/android/telecom/cts/WiredHeadsetTest.java b/tests/tests/telecom/src/android/telecom/cts/WiredHeadsetTest.java
index 697b191..466a90b 100644
--- a/tests/tests/telecom/src/android/telecom/cts/WiredHeadsetTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/WiredHeadsetTest.java
@@ -30,7 +30,7 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- if (TestUtils.shouldTestTelecom(mContext)) {
+ if (mShouldTestTelecom) {
setupConnectionService(null, FLAG_REGISTER | FLAG_ENABLE);
}
}
@@ -45,6 +45,10 @@
}
public void testIncomingCallShortPress_acceptsCall() throws Exception {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
addAndVerifyNewIncomingCall(getTestNumber(), null);
final MockConnection connection = verifyConnectionForIncomingCall();
@@ -58,6 +62,10 @@
}
public void testIncomingCallLongPress_rejectsCall() throws Exception {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
addAndVerifyNewIncomingCall(getTestNumber(), null);
final MockConnection connection = verifyConnectionForIncomingCall();
@@ -71,6 +79,10 @@
}
public void testInCallShortPress_togglesMute() throws Exception {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
placeAndVerifyCall();
final MockConnection connection = verifyConnectionForOutgoingCall();
final MockInCallService incallService = mInCallCallbacks.getService();
@@ -89,6 +101,10 @@
}
public void testInCallLongPress_hangupCall() throws Exception {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
placeAndVerifyCall();
final MockConnection connection = verifyConnectionForOutgoingCall();
@@ -104,6 +120,10 @@
}
public void testStartCallWithSpeakerphoneNotProvided_SpeakerphoneOffByDefault() {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
placeAndVerifyCall();
verifyConnectionForOutgoingCall();
assertAudioRoute(mInCallCallbacks.getService(), CallAudioState.ROUTE_EARPIECE);
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java b/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
index e6b656f..592e308 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
@@ -95,7 +95,7 @@
* brackets are optional):
* <p/>
* Mozilla/5.0 (Linux;[ U;] Android <version>;[ <language>-<country>;]
- * [<devicemodel>;] Build/<buildID>[; wv]) AppleWebKit/<major>.<minor> (KHTML, like Gecko)
+ * [<devicemodel>;] Build/<buildID>; wv) AppleWebKit/<major>.<minor> (KHTML, like Gecko)
* Version/<major>.<minor> Chrome/<major>.<minor>.<branch>.<build>[ Mobile]
* Safari/<major>.<minor>
*/
@@ -107,7 +107,7 @@
Log.i(LOG_TAG, String.format("Checking user agent string %s", actualUserAgentString));
final String patternString =
"Mozilla/5\\.0 \\(Linux;( U;)? Android ([^;]+);( (\\w+)-(\\w+);)?" +
- "\\s?(.*)\\sBuild/(.+?)(; wv)?\\) AppleWebKit/(\\d+)\\.(\\d+) " +
+ "\\s?(.*)\\sBuild/(.+); wv\\) AppleWebKit/(\\d+)\\.(\\d+) " +
"\\(KHTML, like Gecko\\) " +
"Version/\\d+\\.\\d+ Chrome/\\d+\\.\\d+\\.\\d+\\.\\d+( Mobile)? " +
"Safari/(\\d+)\\.(\\d+)";
@@ -119,12 +119,11 @@
// 5 - language
// 6 - device model (optional)
// 7 - build ID
- // 8 - WebView identifier "; wv" (optional)
- // 9 - AppleWebKit major version number
- // 10 - AppleWebKit minor version number
- // 11 - " Mobile" string (optional)
- // 12 - Safari major version number
- // 13 - Safari minor version number
+ // 8 - AppleWebKit major version number
+ // 9 - AppleWebKit minor version number
+ // 10 - " Mobile" string (optional)
+ // 11 - Safari major version number
+ // 12 - Safari minor version number
Log.i(LOG_TAG, String.format("Trying to match pattern %s", patternString));
final Pattern userAgentExpr = Pattern.compile(patternString);
Matcher patternMatcher = userAgentExpr.matcher(actualUserAgentString);
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
index 01f148a..d74cce5 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
@@ -289,9 +289,8 @@
@Override
public void testFailed(TestIdentifier test, String trace) {
super.testFailed(test, trace);
- // sleep a small amount of time to ensure test failure stack trace makes it into logcat
- // capture
- RunUtil.getDefault().sleep(10);
+ // sleep 2s to ensure test failure stack trace makes it into logcat capture
+ RunUtil.getDefault().sleep(2 * 1000);
InputStreamSource logSource = mDevice.getLogcat(mNumLogcatBytes);
super.testLog(String.format("logcat-%s_%s", test.getClassName(), test.getTestName()),
LogDataType.TEXT, logSource);
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java
index f276f1d..12c3ddd 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java
@@ -308,9 +308,6 @@
instrTest.setRunName(mAppPackageName);
instrTest.setPackageName(mAppNameSpace);
instrTest.setRunnerName(mRunner);
- instrTest.setTestPackageName(mTestPackageName);
- instrTest.setClassName(mClassName);
- instrTest.setMethodName(mMethodName);
instrTest.setAbi(mAbi);
instrTest.setTestsToRun(mTests, false
/* force batch mode off to always run using testFile */);