Merge "Merge "Merge "DO NOT MERGE: Fix android.widget.cts.ToolbarWithMarginsTest" into nougat-mr1-cts-dev am: e675dec575 -s ours" into oreo-cts-dev am: 2f2b80d045 -s ours" into oreo-mr1-cts-dev am: b6a04716a2 -s ours
am: cef4f4483b
Change-Id: I748a620b7f1c6e95660b95a067b48f16602de651
diff --git a/CtsCoverage.mk b/CtsCoverage.mk
index 895af4d..b3c66f5 100644
--- a/CtsCoverage.mk
+++ b/CtsCoverage.mk
@@ -95,12 +95,10 @@
cts-combined-xml-coverage : $(cts-combined-xml-coverage-report)
# Put the test coverage report in the dist dir if "cts" is among the build goals.
-ifneq ($(filter cts, $(MAKECMDGOALS)),)
- $(call dist-for-goals, cts, $(cts-test-coverage-report):cts-test-coverage-report.html)
- $(call dist-for-goals, cts, $(cts-verifier-coverage-report):cts-verifier-coverage-report.html)
- $(call dist-for-goals, cts, $(cts-combined-coverage-report):cts-combined-coverage-report.html)
- $(call dist-for-goals, cts, $(cts-combined-xml-coverage-report):cts-combined-coverage-report.xml)
-endif
+$(call dist-for-goals, cts, $(cts-test-coverage-report):cts-test-coverage-report.html)
+$(call dist-for-goals, cts, $(cts-verifier-coverage-report):cts-verifier-coverage-report.html)
+$(call dist-for-goals, cts, $(cts-combined-coverage-report):cts-combined-coverage-report.html)
+$(call dist-for-goals, cts, $(cts-combined-xml-coverage-report):cts-combined-coverage-report.xml)
# Arguments;
# 1 - Name of the report printed out on the screen
diff --git a/apps/CtsVerifier/Android.mk b/apps/CtsVerifier/Android.mk
index ba9155c..9fcbdb1 100644
--- a/apps/CtsVerifier/Android.mk
+++ b/apps/CtsVerifier/Android.mk
@@ -155,8 +155,6 @@
$(hide) $(ACP) -fpr $(HOST_OUT)/CameraITS $(verifier-dir)
$(hide) cd $(cts-dir) && zip -rq $(verifier-dir-name) $(verifier-dir-name)
-ifneq ($(filter cts, $(MAKECMDGOALS)),)
- $(call dist-for-goals, cts, $(verifier-zip):$(verifier-zip-name))
-endif
+$(call dist-for-goals, cts, $(verifier-zip):$(verifier-zip-name))
include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/apps/CtsVerifier/jni/verifier/Android.mk b/apps/CtsVerifier/jni/verifier/Android.mk
index 42e2d26..66f3fd0 100644
--- a/apps/CtsVerifier/jni/verifier/Android.mk
+++ b/apps/CtsVerifier/jni/verifier/Android.mk
@@ -32,7 +32,10 @@
LOCAL_SHARED_LIBRARIES := liblog \
libnativehelper_compat_libc++
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := \
+ -Wall -Werror \
+ -Wno-unused-parameter \
+ -Wno-unused-variable \
include $(BUILD_SHARED_LIBRARY)
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 9cec751..db4ff1d 100755
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -271,9 +271,9 @@
<string name="ble_write_descriptor_name">Bluetooth LE Write Descriptor</string>
<string name="ble_read_rssi_name">Bluetooth LE Read RSSI</string>
<string name="ble_client_disconnect_name">Bluetooth LE Client Disconnect</string>
- <string name="ble_client_test_info">
+ <string name="ble_insecure_client_test_info">
The Bluetooth LE test must be done simultaneously on two devices. This device is the client.
- All tests listed here must be done with out pairing.
+ All tests listed here must be done without pairing.
</string>
<string name="ble_client_send_connect_info">Type in the Bluetooth address of the remote device to connect to, and verify that the devices are connected.</string>
<string name="ble_discover_service_info">Verify that the service is discovered when you press the "Discover Service" button.</string>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientService.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientService.java
index e61cefe..28d08cd 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientService.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientService.java
@@ -148,8 +148,8 @@
"com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_CLIENT_CONNECT";
public static final String BLE_CLIENT_ACTION_CLIENT_CONNECT_SECURE =
"com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_CLIENT_CONNECT_SECURE";
- public static final String BLE_CLIENT_ACTION_BLE_DISVOCER_SERVICE =
- "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_BLE_DISVOCER_SERVICE";
+ public static final String BLE_CLIENT_ACTION_BLE_DISCOVER_SERVICE =
+ "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_BLE_DISCOVER_SERVICE";
public static final String BLE_CLIENT_ACTION_REQUEST_MTU_23 =
"com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_REQUEST_MTU_23";
public static final String BLE_CLIENT_ACTION_REQUEST_MTU_512 =
@@ -353,7 +353,7 @@
mExecReliableWrite = ReliableWriteState.RELIABLE_WRITE_NONE;
startScan();
break;
- case BLE_CLIENT_ACTION_BLE_DISVOCER_SERVICE:
+ case BLE_CLIENT_ACTION_BLE_DISCOVER_SERVICE:
if (mBluetoothGatt != null && mBleState == BluetoothProfile.STATE_CONNECTED) {
mBluetoothGatt.discoverServices();
} else {
@@ -770,13 +770,13 @@
}
private void notifyReliableWriteCompleted() {
- showMessage("Reliable write compelte");
+ showMessage("Reliable write complete");
Intent intent = new Intent(BLE_RELIABLE_WRITE_COMPLETED);
sendBroadcast(intent);
}
private void notifyReliableWriteBadRespCompleted(String err) {
- showMessage("Reliable write(bad response) compelte");
+ showMessage("Reliable write(bad response) complete");
Intent intent = new Intent(BLE_RELIABLE_WRITE_BAD_RESP_COMPLETED);
if (err != null) {
intent.putExtra(EXTRA_ERROR_MESSAGE, err);
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientTestBaseActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientTestBaseActivity.java
index df9a368..b5220f8 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientTestBaseActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientTestBaseActivity.java
@@ -35,6 +35,7 @@
import java.util.ArrayList;
import java.util.List;
+import android.util.Log;
public class BleClientTestBaseActivity extends PassFailButtons.Activity {
public static final String TAG = "BleClientTestBase";
@@ -62,7 +63,7 @@
private static final int PASS_FLAG_ALL = 0x3FFFF;
private final int BLE_CLIENT_CONNECT = 0;
- private final int BLE_BLE_DISVOCER_SERVICE = 1;
+ private final int BLE_BLE_DISCOVER_SERVICE = 1;
private final int BLE_READ_CHARACTERISTIC = 2;
private final int BLE_WRITE_CHARACTERISTIC = 3;
private final int BLE_REQUEST_MTU_23BYTES = 4;
@@ -90,8 +91,6 @@
super.onCreate(savedInstanceState);
setContentView(R.layout.ble_server_start);
setPassFailButtonClickListeners();
- setInfoResources(R.string.ble_client_test_name,
- R.string.ble_client_test_info, -1);
getPassButton().setEnabled(false);
mTestAdapter = new TestAdapter(this, setupTestList());
@@ -212,7 +211,11 @@
String action = intent.getAction();
String newAction = null;
String actionName = null;
+ long previousPassed = mPassed;
final Intent startIntent = new Intent(BleClientTestBaseActivity.this, BleClientService.class);
+ if (action != null) {
+ Log.d(TAG, "Processing " + action);
+ }
switch (action) {
case BleClientService.BLE_BLUETOOTH_DISABLED:
showErrorDialog(R.string.ble_bluetooth_disable_title, R.string.ble_bluetooth_disable_message, true);
@@ -222,11 +225,11 @@
mTestAdapter.setTestPass(BLE_CLIENT_CONNECT);
mPassed |= PASS_FLAG_CONNECT;
// execute service discovery test
- newAction = BleClientService.BLE_CLIENT_ACTION_BLE_DISVOCER_SERVICE;
+ newAction = BleClientService.BLE_CLIENT_ACTION_BLE_DISCOVER_SERVICE;
break;
case BleClientService.BLE_SERVICES_DISCOVERED:
actionName = getString(R.string.ble_discover_service_name);
- mTestAdapter.setTestPass(BLE_BLE_DISVOCER_SERVICE);
+ mTestAdapter.setTestPass(BLE_BLE_DISCOVER_SERVICE);
mPassed |= PASS_FLAG_DISCOVER;
// execute MTU requesting test (23bytes)
newAction = BleClientService.BLE_CLIENT_ACTION_READ_CHARACTERISTIC;
@@ -283,6 +286,7 @@
// skip Reliable write (bad response) test
mPassed |= PASS_FLAG_RELIABLE_WRITE_BAD_RESP;
+ Log.d(TAG, "Skip PASS_FLAG_RELIABLE_WRITE_BAD_RESP.");
newAction = BleClientService.BLE_CLIENT_ACTION_NOTIFY_CHARACTERISTIC;
showProgressDialog = true;
break;
@@ -342,6 +346,7 @@
// newAction = BleClientService.BLE_CLIENT_ACTION_READ_RSSI;
// execute disconnection test
mPassed |= PASS_FLAG_READ_RSSI;
+ Log.d(TAG, "Skip PASS_FLAG_READ_RSSI.");
newAction = BleClientService.BLE_CLIENT_ACTION_CLIENT_DISCONNECT;
break;
case BleClientService.BLE_READ_REMOTE_RSSI:
@@ -365,9 +370,16 @@
break;
}
+ if (previousPassed != mPassed) {
+ String logMessage = String.format("Passed Flags has changed from 0x%08X to 0x%08X. Delta=0x%08X",
+ previousPassed, mPassed, mPassed ^ previousPassed);
+ Log.d(TAG, logMessage);
+ }
+
mTestAdapter.notifyDataSetChanged();
if (newAction != null) {
+ Log.d(TAG, "Starting " + newAction);
startIntent.setAction(newAction);
if (STEP_EXECUTION) {
closeDialog();
@@ -399,6 +411,7 @@
}
if (mPassed == PASS_FLAG_ALL) {
+ Log.d(TAG, "All Tests Passed.");
if (shouldRebootBluetoothAfterTest()) {
mBtPowerSwitcher.executeSwitching();
} else {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureClientStartActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureClientStartActivity.java
index 03256fb..d0a6e80 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureClientStartActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureClientStartActivity.java
@@ -18,6 +18,7 @@
import android.content.Intent;
import android.os.Bundle;
+import com.android.cts.verifier.R;
public class BleInsecureClientStartActivity extends BleClientTestBaseActivity {
private Intent mIntent;
@@ -25,6 +26,10 @@
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+
+ setInfoResources(R.string.ble_client_test_name,
+ R.string.ble_insecure_client_test_info, -1);
+
mIntent = new Intent(this, BleClientService.class);
mIntent.setAction(BleClientService.BLE_CLIENT_ACTION_CLIENT_CONNECT);
diff --git a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/DeviceInfo.java b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/DeviceInfo.java
index 750e45f..c48d16f 100644
--- a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/DeviceInfo.java
+++ b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/DeviceInfo.java
@@ -64,15 +64,23 @@
Set<String> mActivityList = new HashSet<String>();
+ static File makeResultDir() {
+ final File dir = new File(Environment.getExternalStorageDirectory(), "device-info-files");
+ if (!dir.mkdirs() && !dir.isDirectory()) {
+ return null;
+ }
+ return dir;
+ }
+
public void testCollectDeviceInfo() throws Exception {
if (!mActivityList.contains(getClass().getName())) {
return;
}
- final File dir = new File(Environment.getExternalStorageDirectory(), "device-info-files");
+ final File dir;
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
failed("External storage is not mounted");
- } else if (!dir.mkdirs() && !dir.isDirectory()) {
+ } else if ((dir = makeResultDir()) == null) {
failed("Cannot create directory for device info files");
} else {
try {
diff --git a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/VintfDeviceInfo.java b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/VintfDeviceInfo.java
index c9a6265..468bcc1 100644
--- a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/VintfDeviceInfo.java
+++ b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/VintfDeviceInfo.java
@@ -45,7 +45,6 @@
store.addResult("os_version", VintfRuntimeInfo.getOsVersion());
store.addResult("hardware_id", VintfRuntimeInfo.getHardwareId());
store.addResult("kernel_version", VintfRuntimeInfo.getKernelVersion());
- store.addResult("kernel_sepolicy_version", VintfRuntimeInfo.getKernelSepolicyVersion());
store.addResult("sepolicy_version", VintfObject.getSepolicyVersion());
String[] hals = VintfObject.getHalNamesAndVersions();
diff --git a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/VintfFilesCollector.java b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/VintfFilesCollector.java
new file mode 100644
index 0000000..89997f0
--- /dev/null
+++ b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/VintfFilesCollector.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.compatibility.common.deviceinfo;
+
+import android.test.InstrumentationTestCase;
+import android.os.Environment;
+import android.os.Build;
+import android.os.VintfObject;
+import com.google.common.collect.ImmutableMap;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.StringReader;
+import java.io.Writer;
+import java.util.Map;
+import java.util.function.Supplier;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlPullParserFactory;
+
+/**
+ * Device-side VINTF files collector. Uses {@link android.os.VintfObject} to collect VINTF manifests
+ * and compatibility matrices.
+ */
+public final class VintfFilesCollector extends InstrumentationTestCase {
+
+ private static final String FRAMEWORK_MANIFEST_NAME = "framework_manifest.xml";
+ private static final String FRAMEWORK_MATRIX_NAME = "framework_compatibility_matrix.xml";
+ private static final String DEVICE_MANIFEST_NAME = "device_manifest.xml";
+ private static final String DEVICE_MATRIX_NAME = "device_compatibility_matrix.xml";
+
+ public void testCollectVintfFiles() throws Exception {
+
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
+ // No VINTF before O.
+ return;
+ }
+
+ assertTrue("External storage is not mounted",
+ Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED));
+ File dir = DeviceInfo.makeResultDir();
+ assertNotNull("Cannot create directory for device info files", dir);
+ collect(dir);
+ }
+
+
+ // report() doesn't distinguish the four XML Strings, so we have to guess.
+ private static void collect(File dir) throws Exception {
+ for (String content : VintfObject.report()) {
+ String fileName = guessFileName(content);
+ if (fileName != null) {
+ writeStringToFile(content, new File(dir, fileName));
+ }
+ }
+ }
+
+ private static void writeStringToFile(String content, File file) throws Exception {
+ if (content == null || content.isEmpty()) {
+ return;
+ }
+ try (Writer os = new FileWriter(file)) {
+ os.write(content);
+ }
+ }
+
+ // Guess a suitable file name for the given XML string. Return null if
+ // it is not an XML string, or no suitable names can be provided.
+ private static String guessFileName(String content) throws Exception {
+ try {
+ XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
+ parser.setInput(new StringReader(content));
+
+ for (int eventType = parser.getEventType(); eventType != XmlPullParser.END_DOCUMENT;
+ eventType = parser.next()) {
+
+ if (eventType == XmlPullParser.START_TAG) {
+ String tag = parser.getName();
+ if (parser.getDepth() != 1) {
+ continue; // only parse top level tags
+ }
+
+ String type = parser.getAttributeValue(null, "type");
+ if ("manifest".equals(tag)) {
+ if ("framework".equals(type)) {
+ return FRAMEWORK_MANIFEST_NAME;
+ }
+ if ("device".equals(type)) {
+ return DEVICE_MANIFEST_NAME;
+ }
+ }
+ if ("compatibility-matrix".equals(tag)) {
+ if ("framework".equals(type)) {
+ return FRAMEWORK_MATRIX_NAME;
+ }
+ if ("device".equals(type)) {
+ return DEVICE_MATRIX_NAME;
+ }
+ }
+ }
+ }
+ } catch (XmlPullParserException ex) {
+ return null;
+ }
+ return null;
+ }
+}
diff --git a/common/device-side/util/jni/Android.mk b/common/device-side/util/jni/Android.mk
index 8627d24..39b395e 100644
--- a/common/device-side/util/jni/Android.mk
+++ b/common/device-side/util/jni/Android.mk
@@ -32,6 +32,6 @@
LOCAL_STATIC_LIBRARIES := cpufeatures
LOCAL_SDK_VERSION := 19
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
include $(BUILD_SHARED_LIBRARY)
diff --git a/common/device-side/util/src/com/android/compatibility/common/util/CtsMouseUtil.java b/common/device-side/util/src/com/android/compatibility/common/util/CtsMouseUtil.java
index c89afa3..99228fe 100644
--- a/common/device-side/util/src/com/android/compatibility/common/util/CtsMouseUtil.java
+++ b/common/device-side/util/src/com/android/compatibility/common/util/CtsMouseUtil.java
@@ -27,8 +27,8 @@
import android.view.MotionEvent;
import android.view.View;
+import org.mockito.ArgumentMatcher;
import org.mockito.InOrder;
-import org.mockito.compat.ArgumentMatcher;
public final class CtsMouseUtil {
@@ -63,7 +63,7 @@
return event;
}
- public static class ActionMatcher extends ArgumentMatcher<MotionEvent> {
+ public static class ActionMatcher implements ArgumentMatcher<MotionEvent> {
private final int mAction;
public ActionMatcher(int action) {
@@ -71,8 +71,8 @@
}
@Override
- public boolean matchesObject(Object actual) {
- return (actual instanceof MotionEvent) && ((MotionEvent) actual).getAction() == mAction;
+ public boolean matches(MotionEvent actual) {
+ return actual.getAction() == mAction;
}
@Override
@@ -92,10 +92,10 @@
}
@Override
- public boolean matchesObject(Object actual) {
- return super.matchesObject(actual)
- && ((int) ((MotionEvent) actual).getX()) == mX
- && ((int) ((MotionEvent) actual).getY()) == mY;
+ public boolean matches(MotionEvent actual) {
+ return super.matches(actual)
+ && ((int) actual.getX()) == mX
+ && ((int) actual.getY()) == mY;
}
@Override
diff --git a/common/util/src/com/android/compatibility/common/util/ResultHandler.java b/common/util/src/com/android/compatibility/common/util/ResultHandler.java
index 4aa6e05..4308947 100644
--- a/common/util/src/com/android/compatibility/common/util/ResultHandler.java
+++ b/common/util/src/com/android/compatibility/common/util/ResultHandler.java
@@ -41,6 +41,7 @@
import java.util.Collections;
import java.util.Date;
import java.util.List;
+import java.util.Locale;
import java.util.Map.Entry;
import java.util.Set;
import javax.xml.transform.Transformer;
@@ -563,7 +564,8 @@
* @param time the epoch time in ms since midnight Jan 1, 1970
*/
static String toReadableDateString(long time) {
- SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
+ SimpleDateFormat dateFormat =
+ new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH);
return dateFormat.format(new Date(time));
}
diff --git a/hostsidetests/abioverride/app/jni/Android.mk b/hostsidetests/abioverride/app/jni/Android.mk
index c500100..d806a2c 100644
--- a/hostsidetests/abioverride/app/jni/Android.mk
+++ b/hostsidetests/abioverride/app/jni/Android.mk
@@ -26,7 +26,7 @@
LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
# Ignore unused parameters.
-LOCAL_CFLAGS += -Wno-unused-parameter
+LOCAL_CFLAGS += -Wall -Werror -Wno-unused-parameter
LOCAL_SHARED_LIBRARIES := libnativehelper_compat_libc++ liblog libdl
LOCAL_CXX_STL := none
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/EphemeralTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/EphemeralTest.java
index fdd2f06..914f4ef 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/EphemeralTest.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/EphemeralTest.java
@@ -219,6 +219,13 @@
runDeviceTests(EPHEMERAL_1_PKG, TEST_CLASS, "testInstallPermissionGranted");
}
+ public void testStartForegrondService() throws Exception {
+ // Make sure the test package does not have INSTANT_APP_FOREGROUND_SERVICE
+ getDevice().executeShellCommand("cmd package revoke " + EPHEMERAL_1_PKG
+ + " android.permission.INSTANT_APP_FOREGROUND_SERVICE");
+ runDeviceTests(EPHEMERAL_1_PKG, TEST_CLASS, "testStartForegroundService");
+ }
+
private static final HashMap<String, String> makeArgs(
String action, String category, String mimeType) {
if (action == null || action.length() == 0) {
diff --git a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp1/AndroidManifest.xml b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp1/AndroidManifest.xml
index ed3c3cf..6028ae5 100644
--- a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp1/AndroidManifest.xml
+++ b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp1/AndroidManifest.xml
@@ -22,6 +22,8 @@
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
<uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.INSTANT_APP_FOREGROUND_SERVICE" />
+
<application
android:label="@string/app_name">
<uses-library android:name="android.test.runner" />
@@ -88,6 +90,7 @@
<action android:name="com.android.cts.ephemeraltest.QUERY" />
</intent-filter>
</provider>
+ <service android:name=".SomeService"/>
</application>
<instrumentation
diff --git a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp1/src/com/android/cts/ephemeralapp1/ClientTest.java b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp1/src/com/android/cts/ephemeralapp1/ClientTest.java
index 8ecd860..656be27 100644
--- a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp1/src/com/android/cts/ephemeralapp1/ClientTest.java
+++ b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp1/src/com/android/cts/ephemeralapp1/ClientTest.java
@@ -19,11 +19,16 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import android.Manifest;
import android.annotation.Nullable;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
@@ -40,14 +45,10 @@
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
-import android.os.ServiceManager.ServiceNotFoundException;
-import android.provider.CalendarContract;
-import android.provider.ContactsContract;
-import android.provider.MediaStore;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
-import android.test.InstrumentationTestCase;
+import com.android.compatibility.common.util.SystemUtil;
import com.android.cts.util.TestResult;
import org.junit.After;
@@ -55,10 +56,9 @@
import org.junit.Test;
import org.junit.runner.RunWith;
-import java.util.ArrayList;
-import java.util.Arrays;
+import java.io.IOException;
import java.util.List;
-import java.util.ServiceConfigurationError;
+import java.util.concurrent.CountDownLatch;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.TimeUnit;
@@ -958,6 +958,42 @@
}
}
+ @Test
+ public void testStartForegroundService() throws Exception {
+ final Context context = InstrumentationRegistry.getContext();
+ final Intent intent = new Intent(context, SomeService.class);
+
+ // Create a notification channel for the foreground notification
+ final NotificationChannel channel = new NotificationChannel("foo", "foo",
+ NotificationManager.IMPORTANCE_DEFAULT);
+ final NotificationManager notificationManager = context.getSystemService(
+ NotificationManager.class);
+ notificationManager.createNotificationChannel(channel);
+
+ // Shouldn't be able to start without a permission
+ final CountDownLatch latch1 = new CountDownLatch(1);
+ SomeService.setOnStartCommandCallback((int result) -> {
+ assertSame("Shouldn't be able to start without "
+ + " INSTANT_APP_FOREGROUND_SERVICE permission", 0, result);
+ latch1.countDown();
+ });
+ context.startForegroundService(intent);
+ latch1.await(5, TimeUnit.SECONDS);
+
+ // Now grant ourselves INSTANT_APP_FOREGROUND_SERVICE
+ grantInstantAppForegroundServicePermission();
+
+ // Should be able to start with a permission
+ final CountDownLatch latch2 = new CountDownLatch(1);
+ SomeService.setOnStartCommandCallback((int result) -> {
+ assertSame("Should be able to start with "
+ + " INSTANT_APP_FOREGROUND_SERVICE permission", 1, result);
+ latch2.countDown();
+ });
+ context.startForegroundService(intent);
+ latch2.await(5, TimeUnit.SECONDS);
+ }
+
private TestResult getResult() {
final TestResult result;
try {
@@ -971,6 +1007,12 @@
return result;
}
+ private static void grantInstantAppForegroundServicePermission() throws IOException {
+ SystemUtil.runShellCommand(InstrumentationRegistry.getInstrumentation(),
+ "pm grant " + InstrumentationRegistry.getContext().getPackageName()
+ + " " + Manifest.permission.INSTANT_APP_FOREGROUND_SERVICE);
+ }
+
private static Intent makeIntent(String action, String category, String mimeType) {
Intent intent = new Intent(action);
if (category != null) {
diff --git a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp1/src/com/android/cts/ephemeralapp1/SomeService.java b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp1/src/com/android/cts/ephemeralapp1/SomeService.java
new file mode 100644
index 0000000..116067a
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp1/src/com/android/cts/ephemeralapp1/SomeService.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.cts.ephemeralapp1;
+
+import android.app.Notification;
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+
+import java.util.function.IntConsumer;
+
+public class SomeService extends Service {
+ private static IntConsumer sCallback;
+
+ public static void setOnStartCommandCallback(IntConsumer callback) {
+ sCallback = callback;
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return null;
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ final Notification.Builder builder = new Notification.Builder(this, "foo")
+ .setSmallIcon(android.R.drawable.sym_def_app_icon)
+ .setContentTitle("foo")
+ .setWhen(System.currentTimeMillis())
+ .setOngoing(true);
+ try {
+ startForeground(1, builder.build());
+ stopSelf(startId);
+ } catch (Exception e) {
+ sCallback.accept(0);
+ return START_NOT_STICKY;
+ }
+ sCallback.accept(1);
+ return START_NOT_STICKY;
+ }
+}
diff --git a/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/src/com/android/cts/writeexternalstorageapp/WriteMultiViewTest.java b/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/src/com/android/cts/writeexternalstorageapp/WriteMultiViewTest.java
index db1c721..e48c319 100644
--- a/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/src/com/android/cts/writeexternalstorageapp/WriteMultiViewTest.java
+++ b/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/src/com/android/cts/writeexternalstorageapp/WriteMultiViewTest.java
@@ -21,10 +21,11 @@
import static com.android.cts.externalstorageapp.CommonExternalStorageTest.PACKAGE_READ;
import static com.android.cts.externalstorageapp.CommonExternalStorageTest.assertFileReadWriteAccess;
+import android.os.SystemClock;
import android.system.Os;
import android.test.AndroidTestCase;
-
+import android.text.format.DateUtils;
import android.util.Log;
@@ -65,6 +66,9 @@
Os.rename(ourTestDir.getAbsolutePath(), otherTestDir.getAbsolutePath());
+ // Sit around long enough for VFS cache to expire
+ SystemClock.sleep(15 * DateUtils.SECOND_IN_MILLIS);
+
assertNotEqual(Os.getuid(), Os.stat(otherCache.getAbsolutePath()).st_uid);
assertNotEqual(Os.getuid(), Os.stat(otherTestDir.getAbsolutePath()).st_uid);
assertNotEqual(Os.getuid(), Os.stat(afterFile.getAbsolutePath()).st_uid);
diff --git a/hostsidetests/bootstats/Android.mk b/hostsidetests/bootstats/Android.mk
index 58fcfe2..87bff19 100644
--- a/hostsidetests/bootstats/Android.mk
+++ b/hostsidetests/bootstats/Android.mk
@@ -20,8 +20,8 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_MODULE := CtsBootStatsTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := host-framework-protos
-LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed compatibility-host-util host-libprotobuf-java-full
+LOCAL_STATIC_JAVA_LIBRARIES := framework-protos
+LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed compatibility-host-util libprotobuf-java-full
LOCAL_CTS_TEST_PACKAGE := android.bootstats
diff --git a/hostsidetests/content/test-apps/CtsSyncAccountAccessOtherCertTests/src/com/android/cts/content/CtsSyncAccountAccessOtherCertTestCases.java b/hostsidetests/content/test-apps/CtsSyncAccountAccessOtherCertTests/src/com/android/cts/content/CtsSyncAccountAccessOtherCertTestCases.java
index 9ef4587..c2557ef 100644
--- a/hostsidetests/content/test-apps/CtsSyncAccountAccessOtherCertTests/src/com/android/cts/content/CtsSyncAccountAccessOtherCertTestCases.java
+++ b/hostsidetests/content/test-apps/CtsSyncAccountAccessOtherCertTests/src/com/android/cts/content/CtsSyncAccountAccessOtherCertTestCases.java
@@ -39,6 +39,7 @@
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.Until;
+import android.util.Log;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -63,6 +64,7 @@
private static final long SYNC_TIMEOUT_MILLIS = 20000; // 20 sec
private static final long UI_TIMEOUT_MILLIS = 5000; // 5 sec
+ private static final String PERMISSION_REQUESTED = "Permission Requested";
public static final String TOKEN_TYPE_REMOVE_ACCOUNTS = "TOKEN_TYPE_REMOVE_ACCOUNTS";
@Rule
@@ -125,10 +127,10 @@
notification.click();
} else {
uiDevice.openNotification();
- uiDevice.wait(Until.hasObject(By.text("Permission requested")),
+ uiDevice.wait(Until.hasObject(By.text(PERMISSION_REQUESTED)),
UI_TIMEOUT_MILLIS);
- uiDevice.findObject(By.text("Permission requested")).click();
+ uiDevice.findObject(By.text(PERMISSION_REQUESTED)).click();
}
uiDevice.wait(Until.hasObject(By.text("ALLOW")),
@@ -150,16 +152,16 @@
private UiObject2 findPermissionNotificationInStream(UiDevice uiDevice) {
uiDevice.pressHome();
swipeUp(uiDevice);
- if (uiDevice.hasObject(By.text("Permission requested"))) {
- return uiDevice.findObject(By.text("Permission requested"));
+ if (uiDevice.hasObject(By.text(PERMISSION_REQUESTED))) {
+ return uiDevice.findObject(By.text(PERMISSION_REQUESTED));
}
for (int i = 0; i < 100; i++) {
if (!swipeUp(uiDevice)) {
// We have reached the end of the stream and not found the target.
break;
}
- if (uiDevice.hasObject(By.text("Permission requested"))) {
- return uiDevice.findObject(By.text("Permission requested"));
+ if (uiDevice.hasObject(By.text(PERMISSION_REQUESTED))) {
+ return uiDevice.findObject(By.text(PERMISSION_REQUESTED));
}
}
return null;
diff --git a/hostsidetests/incident/Android.mk b/hostsidetests/incident/Android.mk
index b89bafe..8900b76 100644
--- a/hostsidetests/incident/Android.mk
+++ b/hostsidetests/incident/Android.mk
@@ -26,7 +26,7 @@
LOCAL_PROTOC_OPTIMIZE_TYPE := full
LOCAL_STATIC_JAVA_LIBRARIES := platformprotos
-LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed compatibility-host-util host-libprotobuf-java-full
+LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed compatibility-host-util
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/incident/apps/errorsapp/jni/Android.mk b/hostsidetests/incident/apps/errorsapp/jni/Android.mk
index 5101bf3..75d1d09 100644
--- a/hostsidetests/incident/apps/errorsapp/jni/Android.mk
+++ b/hostsidetests/incident/apps/errorsapp/jni/Android.mk
@@ -25,6 +25,8 @@
LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
+LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
+
LOCAL_SDK_VERSION := current
include $(BUILD_SHARED_LIBRARY)
diff --git a/hostsidetests/incident/src/com/android/server/cts/BatteryIncidentTest.java b/hostsidetests/incident/src/com/android/server/cts/BatteryIncidentTest.java
index b04b2f3..4b83b0a 100644
--- a/hostsidetests/incident/src/com/android/server/cts/BatteryIncidentTest.java
+++ b/hostsidetests/incident/src/com/android/server/cts/BatteryIncidentTest.java
@@ -40,6 +40,7 @@
assertTrue(
dump.getPlugged()
!= BatteryServiceDumpProto.BatteryPlugged.BATTERY_PLUGGED_WIRELESS);
+ assertTrue(dump.getChargeCounter() > 0);
assertTrue(
dump.getStatus() != BatteryServiceDumpProto.BatteryStatus.BATTERY_STATUS_INVALID);
assertTrue(
diff --git a/hostsidetests/jvmti/allocation-tracking/Android.mk b/hostsidetests/jvmti/allocation-tracking/Android.mk
index 634b0f6..15c3e50 100644
--- a/hostsidetests/jvmti/allocation-tracking/Android.mk
+++ b/hostsidetests/jvmti/allocation-tracking/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiTrackingHostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../host_side.mk
diff --git a/hostsidetests/jvmti/attaching/host/src/android/jvmti/cts/JvmtiAttachingHostTest.java b/hostsidetests/jvmti/attaching/host/src/android/jvmti/cts/JvmtiAttachingHostTest.java
index 2438f32..52be162 100644
--- a/hostsidetests/jvmti/attaching/host/src/android/jvmti/cts/JvmtiAttachingHostTest.java
+++ b/hostsidetests/jvmti/attaching/host/src/android/jvmti/cts/JvmtiAttachingHostTest.java
@@ -93,8 +93,28 @@
return AbiUtils.getBaseArchForAbi(abi);
}
+ private void runAttachTestCmd(ITestDevice device, String pkg, String agentParams)
+ throws Exception {
+ String attachCmd = "cmd activity start -S -W " + agentParams + " -n " + pkg
+ + "/android.jvmti.JvmtiActivity";
+
+ String attachReply = device.executeShellCommand(attachCmd);
+ // Don't try to parse the output. The test will time out anyways if this didn't
+ // work.
+ if (attachReply != null && !attachReply.trim().isEmpty()) {
+ CLog.e(attachReply);
+ }
+ }
+
+ private final static String AGENT = "libctsjvmtiattachagent.so";
+
private void runAttachTest(ITestDevice device, String pkg, String apk) {
try {
+ runAttachTestCmd(device, pkg, "--attach-agent-bind " + AGENT);
+ } catch (Exception e) {
+ throw new RuntimeException("Failed bind-time attaching", e);
+ }
+ try {
String pwd = device.executeShellCommand("run-as " + pkg + " pwd");
if (pwd == null) {
throw new RuntimeException("pwd failed");
@@ -104,30 +124,24 @@
throw new RuntimeException("pwd failed");
}
+ // Give it a different name, so we do not have "contamination" from
+ // the test APK.
+ String libInDataData = AGENT.substring(0, AGENT.length() - ".so".length()) + "2.so";
String agentInDataData =
- installLibToDataData(device, pkg, apk, pwd, "libctsjvmtiattachagent.so");
-
- String attachCmd = "cmd activity start -S -W --attach-agent " + agentInDataData + " -n "
- + pkg + "/android.jvmti.JvmtiActivity";
-
- String attachReply = device.executeShellCommand(attachCmd);
- // Don't try to parse the output. The test will time out anyways if this didn't
- // work.
- if (attachReply != null && !attachReply.trim().isEmpty()) {
- CLog.e(attachReply);
- }
+ installLibToDataData(device, pkg, apk, pwd, AGENT, libInDataData);
+ runAttachTestCmd(device, pkg, "--attach-agent " + agentInDataData);
} catch (Exception e) {
- throw new RuntimeException("Failed attaching", e);
+ throw new RuntimeException("Failed pre-bind attaching", e);
}
}
String installLibToDataData(ITestDevice device, String pkg, String apk, String dataData,
- String library) throws Exception {
+ String library, String newLibName) throws Exception {
ZipFile zf = null;
File tmpFile = null;
String libInTmp = null;
try {
- String libInDataData = dataData + "/" + library;
+ String libInDataData = dataData + "/" + newLibName;
File apkFile = mBuildHelper.getTestFile(apk);
zf = new ZipFile(apkFile);
diff --git a/hostsidetests/jvmti/base/jni/cts_agent.cpp b/hostsidetests/jvmti/base/jni/cts_agent.cpp
index bb1e620..665a47e 100644
--- a/hostsidetests/jvmti/base/jni/cts_agent.cpp
+++ b/hostsidetests/jvmti/base/jni/cts_agent.cpp
@@ -49,7 +49,7 @@
LOG(FATAL) << "Could not get shared jvmtiEnv";
}
- SetAllCapabilities(jvmti_env);
+ SetStandardCapabilities(jvmti_env);
return 0;
}
@@ -64,7 +64,7 @@
LOG(FATAL) << "Could not get shared jvmtiEnv";
}
- SetAllCapabilities(jvmti_env);
+ SetStandardCapabilities(jvmti_env);
InformMainAttach(jvmti_env, env, kMainClass, kMainClassStartup);
return 0;
}
diff --git a/hostsidetests/jvmti/host_side.mk b/hostsidetests/jvmti/host_side.mk
new file mode 100644
index 0000000..708d170
--- /dev/null
+++ b/hostsidetests/jvmti/host_side.mk
@@ -0,0 +1,45 @@
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This file is meant to be included for every host-side test case to
+# have common build system code.
+#
+# For example:
+#
+# LOCAL_PATH := $(call my-dir)
+#
+# include $(CLEAR_VARS)
+#
+# LOCAL_MODULE := CtsJvmtiRunTest902HostTestCases
+#
+# include $(LOCAL_PATH)/../host_side.mk
+#
+
+
+ifndef LOCAL_PATH
+ $(error LOCAL_PATH not defined)
+endif
+ifndef LOCAL_MODULE
+ $(error LOCAL_MODULE not defined)
+endif
+
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
+
diff --git a/hostsidetests/jvmti/redefining/Android.mk b/hostsidetests/jvmti/redefining/Android.mk
index 327aa69..a5c0f07 100644
--- a/hostsidetests/jvmti/redefining/Android.mk
+++ b/hostsidetests/jvmti/redefining/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRedefineClassesHostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/Android.mk b/hostsidetests/jvmti/run-tests/Android.mk
index ca07cab..66ec37d 100644
--- a/hostsidetests/jvmti/run-tests/Android.mk
+++ b/hostsidetests/jvmti/run-tests/Android.mk
@@ -148,16 +148,19 @@
GEN_INPUT := $(wildcard $(LOCAL_PATH)/src/$(1)*/expected.txt)
ifeq (true,$(ANDROID_COMPILE_WITH_JACK))
-GEN_JACK := $(wildcard $(LOCAL_PATH)/src/$(1)*/expected_jack.diff)
+GEN_EXTRA_DIFF := $(wildcard $(LOCAL_PATH)/src/$(1)*/expected_jack.diff)
+else ifeq (true,$(USE_D8))
+GEN_EXTRA_DIFF := $(wildcard $(LOCAL_PATH)/src/$(1)*/expected_d8.diff)
else
-GEN_JACK :=
+GEN_EXTRA_DIFF :=
endif
+
GEN_OUTPUT := $(GENERATED_SRC_DIR)/results.$(1).expected.txt
-$$(GEN_OUTPUT): PRIVATE_GEN_JACK := $$(GEN_JACK)
-$$(GEN_OUTPUT): $$(GEN_INPUT) $$(GEN_JACK)
+$$(GEN_OUTPUT): PRIVATE_GEN_EXTRA_DIFF := $$(GEN_EXTRA_DIFF)
+$$(GEN_OUTPUT): $$(GEN_INPUT) $$(GEN_EXTRA_DIFF)
cp $$< $$@
-ifneq (,$$(GEN_JACK))
- (cd $$(dir $$@) && patch $$(notdir $$@)) < $$(PRIVATE_GEN_JACK)
+ifneq (,$$(GEN_EXTRA_DIFF))
+ (cd $$(dir $$@) && patch $$(notdir $$@)) < $$(PRIVATE_GEN_EXTRA_DIFF)
endif
GEN_INPUT :=
diff --git a/hostsidetests/jvmti/run-tests/test-902/Android.mk b/hostsidetests/jvmti/run-tests/test-902/Android.mk
index e47ab62..4467924 100644
--- a/hostsidetests/jvmti/run-tests/test-902/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-902/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest902HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-903/Android.mk b/hostsidetests/jvmti/run-tests/test-903/Android.mk
index 7ba63d8..74208d0 100644
--- a/hostsidetests/jvmti/run-tests/test-903/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-903/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest903HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-904/Android.mk b/hostsidetests/jvmti/run-tests/test-904/Android.mk
index fa9a94e..bfbbfa2 100644
--- a/hostsidetests/jvmti/run-tests/test-904/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-904/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest904HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-905/Android.mk b/hostsidetests/jvmti/run-tests/test-905/Android.mk
index 97678be..cd9234a 100644
--- a/hostsidetests/jvmti/run-tests/test-905/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-905/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest905HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-906/Android.mk b/hostsidetests/jvmti/run-tests/test-906/Android.mk
index 7b6e063..d9105ca 100644
--- a/hostsidetests/jvmti/run-tests/test-906/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-906/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest906HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-907/Android.mk b/hostsidetests/jvmti/run-tests/test-907/Android.mk
index a64d940..12c66f2 100644
--- a/hostsidetests/jvmti/run-tests/test-907/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-907/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest907HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-908/Android.mk b/hostsidetests/jvmti/run-tests/test-908/Android.mk
index a4a3716..2879daf 100644
--- a/hostsidetests/jvmti/run-tests/test-908/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-908/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest908HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-910/Android.mk b/hostsidetests/jvmti/run-tests/test-910/Android.mk
index dc913dd..85334b3 100644
--- a/hostsidetests/jvmti/run-tests/test-910/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-910/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest910HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-911/Android.mk b/hostsidetests/jvmti/run-tests/test-911/Android.mk
index 10d15fd..445fab0 100644
--- a/hostsidetests/jvmti/run-tests/test-911/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-911/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest911HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-912/Android.mk b/hostsidetests/jvmti/run-tests/test-912/Android.mk
index 6ec22d7..aa69a75 100644
--- a/hostsidetests/jvmti/run-tests/test-912/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-912/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest912HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-913/Android.mk b/hostsidetests/jvmti/run-tests/test-913/Android.mk
index d54985d..3c87a22 100644
--- a/hostsidetests/jvmti/run-tests/test-913/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-913/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest913HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-914/Android.mk b/hostsidetests/jvmti/run-tests/test-914/Android.mk
index 51b1022..7732cb1 100644
--- a/hostsidetests/jvmti/run-tests/test-914/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-914/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest914HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-915/Android.mk b/hostsidetests/jvmti/run-tests/test-915/Android.mk
index 961c4cc..384884a 100644
--- a/hostsidetests/jvmti/run-tests/test-915/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-915/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest915HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-917/Android.mk b/hostsidetests/jvmti/run-tests/test-917/Android.mk
index 8cf73fc..ebf60f5 100644
--- a/hostsidetests/jvmti/run-tests/test-917/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-917/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest917HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-918/Android.mk b/hostsidetests/jvmti/run-tests/test-918/Android.mk
index 497f86c..f6ba563 100644
--- a/hostsidetests/jvmti/run-tests/test-918/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-918/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest918HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-919/Android.mk b/hostsidetests/jvmti/run-tests/test-919/Android.mk
index 640f3d6..b14ab91 100644
--- a/hostsidetests/jvmti/run-tests/test-919/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-919/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest919HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-920/Android.mk b/hostsidetests/jvmti/run-tests/test-920/Android.mk
index 3029742..80ddaa8 100644
--- a/hostsidetests/jvmti/run-tests/test-920/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-920/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest920HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-922/Android.mk b/hostsidetests/jvmti/run-tests/test-922/Android.mk
index bf10341..d84b832 100644
--- a/hostsidetests/jvmti/run-tests/test-922/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-922/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest922HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-923/Android.mk b/hostsidetests/jvmti/run-tests/test-923/Android.mk
index fd2d6f8..d7f9f09 100644
--- a/hostsidetests/jvmti/run-tests/test-923/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-923/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest923HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-924/Android.mk b/hostsidetests/jvmti/run-tests/test-924/Android.mk
index 4b917d8..7e71607 100644
--- a/hostsidetests/jvmti/run-tests/test-924/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-924/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest924HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-926/Android.mk b/hostsidetests/jvmti/run-tests/test-926/Android.mk
index 9e0ffe1..d11f3f3 100644
--- a/hostsidetests/jvmti/run-tests/test-926/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-926/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest926HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-927/Android.mk b/hostsidetests/jvmti/run-tests/test-927/Android.mk
index 3371896..839ab86 100644
--- a/hostsidetests/jvmti/run-tests/test-927/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-927/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest927HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-928/Android.mk b/hostsidetests/jvmti/run-tests/test-928/Android.mk
index 3b0e60c..30ec7b5 100644
--- a/hostsidetests/jvmti/run-tests/test-928/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-928/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest928HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-930/Android.mk b/hostsidetests/jvmti/run-tests/test-930/Android.mk
index 3b7ddf7..73e6ba5d 100644
--- a/hostsidetests/jvmti/run-tests/test-930/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-930/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest930HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-931/Android.mk b/hostsidetests/jvmti/run-tests/test-931/Android.mk
index 8f2cec9..3c2175d 100644
--- a/hostsidetests/jvmti/run-tests/test-931/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-931/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest931HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-932/Android.mk b/hostsidetests/jvmti/run-tests/test-932/Android.mk
index 4e655f5..3773279 100644
--- a/hostsidetests/jvmti/run-tests/test-932/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-932/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest932HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-940/Android.mk b/hostsidetests/jvmti/run-tests/test-940/Android.mk
index 99fc6ae..372ee0d 100644
--- a/hostsidetests/jvmti/run-tests/test-940/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-940/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest940HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-942/Android.mk b/hostsidetests/jvmti/run-tests/test-942/Android.mk
index 68d839b..9a9407a 100644
--- a/hostsidetests/jvmti/run-tests/test-942/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-942/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest942HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-944/Android.mk b/hostsidetests/jvmti/run-tests/test-944/Android.mk
index bcc2046..c60d2e2 100644
--- a/hostsidetests/jvmti/run-tests/test-944/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-944/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest944HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-945/Android.mk b/hostsidetests/jvmti/run-tests/test-945/Android.mk
index b06d1f9..433d9ac6 100644
--- a/hostsidetests/jvmti/run-tests/test-945/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-945/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest945HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-947/Android.mk b/hostsidetests/jvmti/run-tests/test-947/Android.mk
index 2258a4b..0201816 100644
--- a/hostsidetests/jvmti/run-tests/test-947/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-947/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest947HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-951/Android.mk b/hostsidetests/jvmti/run-tests/test-951/Android.mk
index 5677f8b..e198f70 100644
--- a/hostsidetests/jvmti/run-tests/test-951/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-951/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest951HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-982/Android.mk b/hostsidetests/jvmti/run-tests/test-982/Android.mk
index b766614..e245e1d 100644
--- a/hostsidetests/jvmti/run-tests/test-982/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-982/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest982HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-984/Android.mk b/hostsidetests/jvmti/run-tests/test-984/Android.mk
index 2d71278..b0a919a 100644
--- a/hostsidetests/jvmti/run-tests/test-984/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-984/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest984HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-985/Android.mk b/hostsidetests/jvmti/run-tests/test-985/Android.mk
index 06e4454..0a55fac 100644
--- a/hostsidetests/jvmti/run-tests/test-985/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-985/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest985HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/run-tests/test-986/Android.mk b/hostsidetests/jvmti/run-tests/test-986/Android.mk
index e198471..6be45f2 100644
--- a/hostsidetests/jvmti/run-tests/test-986/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-986/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiRunTest986HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../../host_side.mk
diff --git a/hostsidetests/jvmti/tagging/Android.mk b/hostsidetests/jvmti/tagging/Android.mk
index 3d3e9e4..1ee7bee 100644
--- a/hostsidetests/jvmti/tagging/Android.mk
+++ b/hostsidetests/jvmti/tagging/Android.mk
@@ -17,11 +17,5 @@
include $(CLEAR_VARS)
LOCAL_MODULE := CtsJvmtiTaggingHostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(LOCAL_PATH)/../host_side.mk
diff --git a/hostsidetests/security/Android.mk b/hostsidetests/security/Android.mk
index 2745506..00c5742 100644
--- a/hostsidetests/security/Android.mk
+++ b/hostsidetests/security/Android.mk
@@ -23,7 +23,7 @@
LOCAL_MODULE_TAGS := optional
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# Must match the package name in CtsTestCaseList.mk
LOCAL_MODULE := CtsSecurityHostTestCases
@@ -34,6 +34,12 @@
LOCAL_CTS_TEST_PACKAGE := android.host.security
+ifeq ($(HOST_OS),darwin)
+SHAREDLIB_EXT=dylib
+else
+SHAREDLIB_EXT=so
+endif
+
selinux_plat_seapp_contexts := $(call intermediates-dir-for,ETC,plat_seapp_contexts)/plat_seapp_contexts
selinux_plat_seapp_neverallows := $(call intermediates-dir-for,ETC,plat_seapp_neverallows)/plat_seapp_neverallows
@@ -47,6 +53,11 @@
LOCAL_JAVA_RESOURCE_FILES := \
$(HOST_OUT_EXECUTABLES)/checkseapp \
$(HOST_OUT_EXECUTABLES)/checkfc \
+ $(HOST_OUT_EXECUTABLES)/property_info_checker \
+ $(HOST_OUT_EXECUTABLES)/sepolicy_tests \
+ $(HOST_OUT_EXECUTABLES)/treble_sepolicy_tests \
+ $(HOST_OUT)/lib64/libsepolwrap.$(SHAREDLIB_EXT) \
+ $(HOST_OUT)/lib64/libc++.$(SHAREDLIB_EXT) \
$(selinux_plat_seapp_contexts) \
$(selinux_plat_seapp_neverallows) \
$(selinux_plat_file_contexts) \
diff --git a/hostsidetests/security/AndroidTest.xml b/hostsidetests/security/AndroidTest.xml
index 052e976..5beebde 100644
--- a/hostsidetests/security/AndroidTest.xml
+++ b/hostsidetests/security/AndroidTest.xml
@@ -18,7 +18,10 @@
<target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
<option name="cleanup" value="true" />
<option name="push" value="CVE-2016-8460->/data/local/tmp/CVE-2016-8460" />
+ <option name="push" value="CVE-2017-0403->/data/local/tmp/CVE-2017-0403" />
+ <option name="push" value="CVE-2017-0404->/data/local/tmp/CVE-2017-0404" />
<option name="push" value="CVE-2016-8482->/data/local/tmp/CVE-2016-8482" />
+ <option name="push" value="CVE-2017-0429->/data/local/tmp/CVE-2017-0429" />
<option name="push" value="CVE-2016-6730->/data/local/tmp/CVE-2016-6730" />
<option name="push" value="CVE-2016-6731->/data/local/tmp/CVE-2016-6731" />
<option name="push" value="CVE-2016-6732->/data/local/tmp/CVE-2016-6732" />
@@ -36,6 +39,8 @@
<option name="push" value="CVE-2016-8431->/data/local/tmp/CVE-2016-8431" />
<option name="push" value="CVE-2016-8432->/data/local/tmp/CVE-2016-8432" />
<option name="push" value="CVE-2016-8434->/data/local/tmp/CVE-2016-8434" />
+ <option name="push" value="CVE-2016-8435->/data/local/tmp/CVE-2016-8435" />
+ <option name="push" value="CVE-2016-9120->/data/local/tmp/CVE-2016-9120" />
<option name="push" value="Bug-34328139->/data/local/tmp/Bug-34328139" />
<option name="push" value="Bug-33452365->/data/local/tmp/Bug-33452365" />
<option name="push" value="CVE-2017-0451->/data/local/tmp/CVE-2017-0451" />
@@ -50,11 +55,14 @@
<option name="push" value="CVE-2017-0586->/data/local/tmp/CVE-2017-0586" />
<option name="push" value="CVE-2017-0705->/data/local/tmp/CVE-2017-0705" />
<option name="push" value="CVE-2017-8263->/data/local/tmp/CVE-2017-8263" />
-
<!--__________________-->
<!-- Bulletin 2017-01 -->
<!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+ <option name="push" value="CVE-2016-8457->/data/local/tmp/CVE-2016-8457" />
+ <option name="push" value="CVE-2016-8456->/data/local/tmp/CVE-2016-8456" />
+ <option name="push" value="CVE-2016-8455->/data/local/tmp/CVE-2016-8455" />
+
<!--__________________-->
<!-- Bulletin 2017-02 -->
<!-- Please add tests solely from this bulletin below to avoid merge conflict -->
diff --git a/hostsidetests/security/securityPatch/Bug-32551280/poc.c b/hostsidetests/security/securityPatch/Bug-32551280/poc.c
index 5d852c7..2bbc512 100644
--- a/hostsidetests/security/securityPatch/Bug-32551280/poc.c
+++ b/hostsidetests/security/securityPatch/Bug-32551280/poc.c
@@ -32,7 +32,6 @@
static int subsystem_get(void) {
int fd, ret;
- unsigned long buf;
char *cmd[3] = {"get", "put", "restart"};
fd = open("/sys/kernel/debug/msm_subsys/adsp", O_RDWR);
@@ -49,7 +48,6 @@
static int subsystem_put(void) {
int fd, ret;
- unsigned long buf;
char *cmd[3] = {"get", "put", "restart"};
fd = open("/sys/kernel/debug/msm_subsys/adsp", O_RDWR);
diff --git a/hostsidetests/security/securityPatch/Bug-33039685/Android.mk b/hostsidetests/security/securityPatch/Bug-33039685/Android.mk
index 17af326..50d3b53 100644
--- a/hostsidetests/security/securityPatch/Bug-33039685/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-33039685/Android.mk
@@ -26,10 +26,12 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral
+LOCAL_CFLAGS += -Wno-incompatible-pointer-types-discards-qualifiers
+LOCAL_CFLAGS += -Wno-unused-parameter
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-33299365/Android.mk b/hostsidetests/security/securityPatch/Bug-33299365/Android.mk
index 6ba7ed9..9718680 100644
--- a/hostsidetests/security/securityPatch/Bug-33299365/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-33299365/Android.mk
@@ -26,10 +26,11 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+LOCAL_CFLAGS += -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-33452365/Android.mk b/hostsidetests/security/securityPatch/Bug-33452365/Android.mk
index 9c61dc0..1eba7d1 100644
--- a/hostsidetests/security/securityPatch/Bug-33452365/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-33452365/Android.mk
@@ -26,10 +26,10 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-33863407/Android.mk b/hostsidetests/security/securityPatch/Bug-33863407/Android.mk
index f708aaf..ccd9dc6 100644
--- a/hostsidetests/security/securityPatch/Bug-33863407/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-33863407/Android.mk
@@ -26,10 +26,11 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wno-unused-variable
+LOCAL_CFLAGS += -Wno-literal-conversion -Wno-incompatible-pointer-types-discards-qualifiers
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-34173755/Android.mk b/hostsidetests/security/securityPatch/Bug-34173755/Android.mk
index a64a37c..7daf578 100644
--- a/hostsidetests/security/securityPatch/Bug-34173755/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-34173755/Android.mk
@@ -26,10 +26,11 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+LOCAL_CFLAGS += -Wno-macro-redefined -Wno-unused-parameter -Wno-unused-variable -Wno-sign-compare
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-34328139/Android.mk b/hostsidetests/security/securityPatch/Bug-34328139/Android.mk
index bbdeb63..946f778 100644
--- a/hostsidetests/security/securityPatch/Bug-34328139/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-34328139/Android.mk
@@ -26,10 +26,10 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-34624155/Android.mk b/hostsidetests/security/securityPatch/Bug-34624155/Android.mk
index 95e8c24..9f9d1dd 100644
--- a/hostsidetests/security/securityPatch/Bug-34624155/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-34624155/Android.mk
@@ -26,10 +26,12 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-sign-compare
+LOCAL_CFLAGS += -Wno-incompatible-pointer-types-discards-qualifiers -Wno-unused-const-variable
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-35047217/Android.mk b/hostsidetests/security/securityPatch/Bug-35047217/Android.mk
index f59c682..6bb9d7b 100644
--- a/hostsidetests/security/securityPatch/Bug-35047217/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35047217/Android.mk
@@ -26,10 +26,11 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+LOCAL_CFLAGS += -Wno-macro-redefined -Wno-unused-variable
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-35047780/Android.mk b/hostsidetests/security/securityPatch/Bug-35047780/Android.mk
index c9a8935..697f535 100644
--- a/hostsidetests/security/securityPatch/Bug-35047780/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35047780/Android.mk
@@ -26,10 +26,11 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+LOCAL_CFLAGS += -Wno-macro-redefined -Wno-unused-variable
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-35048450/Android.mk b/hostsidetests/security/securityPatch/Bug-35048450/Android.mk
index a009f80..3cd09a8 100644
--- a/hostsidetests/security/securityPatch/Bug-35048450/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35048450/Android.mk
@@ -26,10 +26,11 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+LOCAL_CFLAGS += -Wno-macro-redefined -Wno-unused-variable
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-35139833/Android.mk b/hostsidetests/security/securityPatch/Bug-35139833/Android.mk
index bc49a79..5f00d4f 100644
--- a/hostsidetests/security/securityPatch/Bug-35139833/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35139833/Android.mk
@@ -26,10 +26,10 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+LOCAL_CFLAGS += -Iinclude -fPIE -Wno-packed
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-35216793/poc.c b/hostsidetests/security/securityPatch/Bug-35216793/poc.c
index 314228d..7cb2335 100644
--- a/hostsidetests/security/securityPatch/Bug-35216793/poc.c
+++ b/hostsidetests/security/securityPatch/Bug-35216793/poc.c
@@ -31,10 +31,8 @@
#include <sys/types.h>
#include "local_poc.h"
-int main(int argc, char **argv) {
+int main(int argc __unused, char **argv __unused) {
int fd, ret, i, count;
- pthread_t tid[2];
- char buf[256];
char subdev[32] = {0};
struct msm_ois_cfg_data data;
@@ -85,7 +83,7 @@
close(fd);
}
- sleep(0.5);
+ sleep(1);
printf("[pid:%d] try %d again!\n", getpid(), ++count);
goto retry;
return 0;
diff --git a/hostsidetests/security/securityPatch/Bug-35468048/Android.mk b/hostsidetests/security/securityPatch/Bug-35468048/Android.mk
index 88166b8..eedec6f 100644
--- a/hostsidetests/security/securityPatch/Bug-35468048/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35468048/Android.mk
@@ -26,10 +26,11 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-variable
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-35644510/Android.mk b/hostsidetests/security/securityPatch/Bug-35644510/Android.mk
index 3a8edf6..0afc492 100644
--- a/hostsidetests/security/securityPatch/Bug-35644510/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35644510/Android.mk
@@ -26,10 +26,14 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes
+LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-incompatible-pointer-types
+LOCAL_CFLAGS += -Wno-unused-parameter -Wno-pointer-sign -Wno-sign-compare
+LOCAL_CFLAGS += -Wno-format -Wno-parentheses -Wno-unused-function
+LOCAL_CFLAGS += -Wno-pointer-arith -Wno-shadow -Wno-unused-label -Wno-unused-variable
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-35644812/poc.c b/hostsidetests/security/securityPatch/Bug-35644812/poc.c
index c0ca91f..6bc5fff 100644
--- a/hostsidetests/security/securityPatch/Bug-35644812/poc.c
+++ b/hostsidetests/security/securityPatch/Bug-35644812/poc.c
@@ -53,7 +53,6 @@
void in_cpu() {
int num_processors = sysconf(_SC_NPROCESSORS_CONF);
cpu_set_t get;
- int i = 0;
CPU_ZERO(&get);
sched_getaffinity(0, sizeof(cpu_set_t), &get);
for (int i = 0; i < num_processors; i++) {
@@ -62,20 +61,11 @@
}
}
}
-static void bind_child_to_cpu() {
- in_cpu();
- cpu_set_t set;
- CPU_ZERO(&set);
- CPU_SET(1, &set);
- sched_setaffinity(0, sizeof(set), &set);
- in_cpu();
-}
#define BLKTRACETEARDOWN _IO(0x12, 118)
#define SG_SET_RESERVED_SIZE 0x2275
#define SG_GET_RESERVED_SIZE 0x2272
static void* overwrite(void* param) {
- int ret;
for (int i = 0; i < 100000; i++) {
int size = 0x100;
int n = ioctl(fd, SG_SET_RESERVED_SIZE, &size);
@@ -103,4 +93,4 @@
return 0;
}
-int main(int argc, char** argv, char** env) { return functionOne(); }
+int main(int argc __unused, char** argv __unused, char** env __unused) { return functionOne(); }
diff --git a/hostsidetests/security/securityPatch/Bug-35644815/Android.mk b/hostsidetests/security/securityPatch/Bug-35644815/Android.mk
index 57660e2..04fee18 100644
--- a/hostsidetests/security/securityPatch/Bug-35644815/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35644815/Android.mk
@@ -26,10 +26,12 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+LOCAL_CFLAGS += -Wno-missing-braces -Wno-missing-field-initializers -Wno-parentheses
+LOCAL_CFLAGS += -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-35676417/Android.mk b/hostsidetests/security/securityPatch/Bug-35676417/Android.mk
index 06ab345..feb24bc 100644
--- a/hostsidetests/security/securityPatch/Bug-35676417/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35676417/Android.mk
@@ -26,10 +26,11 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes
+LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-variable -Wno-packed
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-35764875/Android.mk b/hostsidetests/security/securityPatch/Bug-35764875/Android.mk
index 4d6f4fc..ae0b53f 100644
--- a/hostsidetests/security/securityPatch/Bug-35764875/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35764875/Android.mk
@@ -28,10 +28,12 @@
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes
+LOCAL_CFLAGS += -Wno-unused-variable -Wno-sign-compare
+LOCAL_CFLAGS += -Wno-format -Wno-format-extra-args -Wno-unused-parameter -Wno-user-defined-warnings
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-35950388/Android.mk b/hostsidetests/security/securityPatch/Bug-35950388/Android.mk
index 8289311..79d4023 100644
--- a/hostsidetests/security/securityPatch/Bug-35950388/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35950388/Android.mk
@@ -26,10 +26,11 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_C_INCLUDES += include
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-variable -Wno-macro-redefined
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-35950805/Android.mk b/hostsidetests/security/securityPatch/Bug-35950805/Android.mk
index b3dec07..bef51d2 100644
--- a/hostsidetests/security/securityPatch/Bug-35950805/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35950805/Android.mk
@@ -26,10 +26,11 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-variable
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-36266767/Android.mk b/hostsidetests/security/securityPatch/Bug-36266767/Android.mk
index be220a5..a8dd5b2 100644
--- a/hostsidetests/security/securityPatch/Bug-36266767/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-36266767/Android.mk
@@ -26,10 +26,11 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes
+LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-variable
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-36492827/Android.mk b/hostsidetests/security/securityPatch/Bug-36492827/Android.mk
index d2a91be..44182bf 100644
--- a/hostsidetests/security/securityPatch/Bug-36492827/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-36492827/Android.mk
@@ -26,10 +26,9 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror
+LOCAL_CFLAGS += -Wno-missing-prototypes -Wno-shadow
+LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-variable
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-36591162/Android.mk b/hostsidetests/security/securityPatch/Bug-36591162/Android.mk
index e70c2aa..e8ce0cd 100644
--- a/hostsidetests/security/securityPatch/Bug-36591162/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-36591162/Android.mk
@@ -26,10 +26,11 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+LOCAL_CFLAGS += -Wno-main-return-type -Wno-pointer-sign
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-36730104/Android.mk b/hostsidetests/security/securityPatch/Bug-36730104/Android.mk
index 4c27a41..6d7fb55 100644
--- a/hostsidetests/security/securityPatch/Bug-36730104/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-36730104/Android.mk
@@ -26,10 +26,10 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror
+LOCAL_CFLAGS += -Wno-missing-prototypes -Wno-shadow
+LOCAL_CFLAGS += -Wno-pointer-arith -Wno-incompatible-pointer-types
+LOCAL_CFLAGS += -Wno-unused-variable -Wno-unused-parameter
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-36730104/poc.c b/hostsidetests/security/securityPatch/Bug-36730104/poc.c
index b4a4de3..a331bb8 100644
--- a/hostsidetests/security/securityPatch/Bug-36730104/poc.c
+++ b/hostsidetests/security/securityPatch/Bug-36730104/poc.c
@@ -394,7 +394,7 @@
#define GENL_ID_VFS_DQUOT (NLMSG_MIN_TYPE + 1)
#define GENL_ID_PMCRAID (NLMSG_MIN_TYPE + 2)
-#define GENLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
+#define GENLMSG_DATA(glh) ((void *)((char *)(NLMSG_DATA(glh)) + GENL_HDRLEN))
#define NLA_DATA(na) ((void *)((char *)(na) + NLA_HDRLEN))
#define QCA_NL80211_VENDOR_ID 0x001374
@@ -462,7 +462,7 @@
printf("send_cmd %s %d\n", nla_data, nla_len);
struct nlattr *na;
struct sockaddr_nl nladdr;
- int r, buflen;
+ int buflen;
char *buf;
struct msgtemplate msg;
@@ -523,9 +523,8 @@
int start_p2p(int id, int fd) {
struct nlattr *na;
- struct nlattr *na_data;
struct sockaddr_nl nladdr;
- int r, buflen, ret;
+ int buflen, ret;
char *buf;
struct msgtemplate msg, ans;
@@ -579,9 +578,8 @@
int get_wiphy_idx(int id, int fd, int *ifindex, int *wiphyid, char *ifname) {
struct nlattr *na;
- struct nlattr *na_data;
struct sockaddr_nl nladdr;
- int r, buflen, ret;
+ int buflen, ret;
char *buf;
struct msgtemplate msg, ans;
@@ -624,7 +622,7 @@
return ret;
}
-int main(int argc, const char *argv[]) {
+int main(int argc __unused, const char *argv[] __unused) {
int ret;
int fd;
@@ -651,7 +649,7 @@
struct nlattr *na;
struct nlattr *na_data;
struct sockaddr_nl nladdr;
- int r, buflen;
+ int buflen;
char *buf;
struct msgtemplate msg;
@@ -683,7 +681,7 @@
char data[1024] = {0};
int data_size = 0;
- na_data = data;
+ na_data = (struct nlattr *)data;
na_data = (struct nlattr *)((char *)na_data + NLMSG_ALIGN(na_data->nla_len));
na_data->nla_type = PARAM_REQUEST_ID;
@@ -729,7 +727,7 @@
char apTh[256] = {0};
int apTh_size = 0;
- struct nlattr *na_apTh = apTh;
+ struct nlattr *na_apTh = (struct nlattr *)apTh;
na_apTh = (struct nlattr *)((char *)na_apTh + NLMSG_ALIGN(na_apTh->nla_len));
na_apTh->nla_type = QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND;
@@ -745,7 +743,7 @@
char middlebuf[256] = {0};
int middlebuf_size = 0;
- struct nlattr *na_middle = middlebuf;
+ struct nlattr *na_middle = (struct nlattr *)middlebuf;
na_middle =
(struct nlattr *)((char *)na_middle + NLMSG_ALIGN(na_middle->nla_len));
@@ -779,7 +777,6 @@
ret = recv(fd, &ans, sizeof(ans), 0);
na = (struct nlattr *)GENLMSG_DATA(&ans);
- char *temp = na;
return ret;
}
diff --git a/hostsidetests/security/securityPatch/Bug-36817053/Android.mk b/hostsidetests/security/securityPatch/Bug-36817053/Android.mk
index 2d3d8eb..7e10720 100644
--- a/hostsidetests/security/securityPatch/Bug-36817053/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-36817053/Android.mk
@@ -26,10 +26,9 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror
+LOCAL_CFLAGS += -Wno-pointer-arith -Wno-incompatible-pointer-types
+LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-variable
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-36817053/poc.c b/hostsidetests/security/securityPatch/Bug-36817053/poc.c
index 4e7ae0c..5304fa5 100644
--- a/hostsidetests/security/securityPatch/Bug-36817053/poc.c
+++ b/hostsidetests/security/securityPatch/Bug-36817053/poc.c
@@ -743,7 +743,7 @@
#define GENL_ID_VFS_DQUOT (NLMSG_MIN_TYPE + 1)
#define GENL_ID_PMCRAID (NLMSG_MIN_TYPE + 2)
-#define GENLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
+#define GENLMSG_DATA(glh) ((void *)((char *)(NLMSG_DATA(glh)) + GENL_HDRLEN))
#define NLA_DATA(na) ((void *)((char *)(na) + NLA_HDRLEN))
#define QCA_NL80211_VENDOR_ID 0x001374
@@ -810,7 +810,7 @@
__u16 nla_type, void *nla_data, int nla_len) {
struct nlattr *na;
struct sockaddr_nl nladdr;
- int r, buflen;
+ int buflen;
char *buf;
struct msgtemplate msg;
@@ -872,9 +872,8 @@
int start_p2p(int id, int fd) {
struct nlattr *na;
- struct nlattr *na_data;
struct sockaddr_nl nladdr;
- int r, buflen, ret;
+ int buflen, ret;
char *buf;
struct msgtemplate msg, ans;
@@ -929,9 +928,8 @@
int get_wiphy_idx(int id, int fd, int *ifindex, int *wiphyid, char *ifname) {
struct nlattr *na;
- struct nlattr *na_data;
struct sockaddr_nl nladdr;
- int r, buflen, ret;
+ int buflen, ret;
char *buf;
struct msgtemplate msg, ans;
@@ -974,7 +972,7 @@
return ret;
}
-int main(int argc, const char *argv[]) {
+int main(int argc __unused, const char *argv[] __unused) {
int ret;
int fd;
@@ -1000,7 +998,7 @@
struct nlattr *na;
struct nlattr *na_data;
struct sockaddr_nl nladdr;
- int r, buflen;
+ int buflen;
char *buf;
struct msgtemplate msg;
@@ -1032,7 +1030,7 @@
char data[1024] = {0};
int data_size = 0;
- na_data = data;
+ na_data = (struct nlattr *)data;
na_data = (struct nlattr *)((char *)na_data + NLMSG_ALIGN(na_data->nla_len));
na_data->nla_type =
@@ -1066,7 +1064,6 @@
ret = recv(fd, &ans, sizeof(ans), 0);
na = (struct nlattr *)GENLMSG_DATA(&ans);
- char *temp = na;
struct nlattr *nla;
int rem;
diff --git a/hostsidetests/security/securityPatch/Bug-36818198/Android.mk b/hostsidetests/security/securityPatch/Bug-36818198/Android.mk
index b34f64e..875c8c8 100644
--- a/hostsidetests/security/securityPatch/Bug-36818198/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-36818198/Android.mk
@@ -26,10 +26,10 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror
+LOCAL_CFLAGS += -Wno-missing-prototypes
+LOCAL_CFLAGS += -Wno-pointer-arith -Wno-incompatible-pointer-types
+LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-variable
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-36818198/poc.c b/hostsidetests/security/securityPatch/Bug-36818198/poc.c
index 82838d8..c45a52c 100644
--- a/hostsidetests/security/securityPatch/Bug-36818198/poc.c
+++ b/hostsidetests/security/securityPatch/Bug-36818198/poc.c
@@ -741,7 +741,7 @@
#define GENL_ID_VFS_DQUOT (NLMSG_MIN_TYPE + 1)
#define GENL_ID_PMCRAID (NLMSG_MIN_TYPE + 2)
-#define GENLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
+#define GENLMSG_DATA(glh) ((void *)((char *)(NLMSG_DATA(glh)) + GENL_HDRLEN))
#define NLA_DATA(na) ((void *)((char *)(na) + NLA_HDRLEN))
#define QCA_NL80211_VENDOR_ID 0x001374
@@ -808,7 +808,7 @@
__u16 nla_type, void *nla_data, int nla_len) {
struct nlattr *na;
struct sockaddr_nl nladdr;
- int r, buflen;
+ int buflen;
char *buf;
struct msgtemplate msg;
@@ -871,9 +871,8 @@
int start_p2p(int id, int fd) {
struct nlattr *na;
- struct nlattr *na_data;
struct sockaddr_nl nladdr;
- int r, buflen, ret;
+ int buflen, ret;
char *buf;
struct msgtemplate msg, ans;
@@ -928,9 +927,8 @@
int get_wiphy_idx(int id, int fd, int *ifindex, int *wiphyid, char *ifname) {
struct nlattr *na;
- struct nlattr *na_data;
struct sockaddr_nl nladdr;
- int r, buflen, ret;
+ int buflen, ret;
char *buf;
struct msgtemplate msg, ans;
@@ -973,7 +971,7 @@
return ret;
}
-int main(int argc, const char *argv[]) {
+int main(int argc __unused, const char *argv[] __unused) {
int ret;
int fd;
@@ -1000,7 +998,7 @@
struct nlattr *na;
struct nlattr *na_data;
struct sockaddr_nl nladdr;
- int r, buflen;
+ int buflen;
char *buf;
struct msgtemplate msg;
@@ -1032,7 +1030,7 @@
char data[1024] = {0};
int data_size = 0;
- na_data = data;
+ na_data = (struct nlattr *)data;
na_data = (struct nlattr *)((char *)na_data + NLMSG_ALIGN(na_data->nla_len));
na_data->nla_type =
@@ -1049,7 +1047,7 @@
char apTh[256] = {0};
int apTh_size = 0;
- struct nlattr *na_apTh = apTh;
+ struct nlattr *na_apTh = (struct nlattr *)apTh;
na_apTh = (struct nlattr *)((char *)na_apTh + NLMSG_ALIGN(na_apTh->nla_len));
na_apTh->nla_type = QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW;
@@ -1065,7 +1063,7 @@
char middlebuf[256] = {0};
int middlebuf_size = 0;
- struct nlattr *na_middle = middlebuf;
+ struct nlattr *na_middle = (struct nlattr *)middlebuf;
na_middle =
(struct nlattr *)((char *)na_middle + NLMSG_ALIGN(na_middle->nla_len));
@@ -1105,7 +1103,6 @@
ret = recv(fd, &ans, sizeof(ans), 0);
na = (struct nlattr *)GENLMSG_DATA(&ans);
- char *temp = na;
struct nlattr *nla;
int rem;
diff --git a/hostsidetests/security/securityPatch/Bug-37093119/Android.mk b/hostsidetests/security/securityPatch/Bug-37093119/Android.mk
index 00f77fd..c621936 100644
--- a/hostsidetests/security/securityPatch/Bug-37093119/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-37093119/Android.mk
@@ -26,10 +26,8 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror
+LOCAL_CFLAGS += -Wno-unused-parameter
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-37093119/poc.c b/hostsidetests/security/securityPatch/Bug-37093119/poc.c
index 781fed7..6d93e87 100644
--- a/hostsidetests/security/securityPatch/Bug-37093119/poc.c
+++ b/hostsidetests/security/securityPatch/Bug-37093119/poc.c
@@ -31,7 +31,7 @@
#include <sys/types.h>
#include "local_poc.h"
-int main(int argc, char **argv) {
+int main(int argc __unused, char **argv __unused) {
int ret, count;
int j = 0;
int fd;
diff --git a/hostsidetests/security/securityPatch/Bug-62058746/Android.mk b/hostsidetests/security/securityPatch/Bug-62058746/Android.mk
index 1a36be9..c7c958d 100644
--- a/hostsidetests/security/securityPatch/Bug-62058746/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-62058746/Android.mk
@@ -26,10 +26,8 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror
+LOCAL_CFLAGS += -Wno-missing-prototypes
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-10231/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-10231/Android.mk
index 34c2f5c..e8ad0bb 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-10231/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-10231/Android.mk
@@ -26,10 +26,10 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6730/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6730/Android.mk
index 5fae570..824dce4 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-6730/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-6730/Android.mk
@@ -22,10 +22,11 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
+LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-unused-label
LOCAL_LDFLAGS += -fPIE -pie
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6731/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6731/Android.mk
index c6a406a..eb1e3c1 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-6731/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-6731/Android.mk
@@ -22,10 +22,11 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
+LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-unused-label
LOCAL_LDFLAGS += -fPIE -pie
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6732/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6732/Android.mk
index 74a634a..fd9af02 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-6732/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-6732/Android.mk
@@ -22,10 +22,11 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
+LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-unused-label
LOCAL_LDFLAGS += -fPIE -pie
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6733/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6733/Android.mk
index 8feabb7..a07c8f6 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-6733/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-6733/Android.mk
@@ -22,10 +22,11 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
+LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-unused-label
LOCAL_LDFLAGS += -fPIE -pie
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6734/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6734/Android.mk
index a53613a..e141a4f 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-6734/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-6734/Android.mk
@@ -22,10 +22,11 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
+LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-unused-label
LOCAL_LDFLAGS += -fPIE -pie
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6735/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6735/Android.mk
index 50b93aa..543537e 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-6735/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-6735/Android.mk
@@ -22,10 +22,11 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
+LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-unused-label
LOCAL_LDFLAGS += -fPIE -pie
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6736/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6736/Android.mk
index f63bfad..075d8c9 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-6736/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-6736/Android.mk
@@ -22,10 +22,11 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
+LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-unused-label
LOCAL_LDFLAGS += -fPIE -pie
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8424/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8424/Android.mk
index aa12137..dcf0339 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8424/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-8424/Android.mk
@@ -22,10 +22,11 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
+LOCAL_CFLAGS += -Wno-incompatible-pointer-types -Wno-unused-variable
LOCAL_LDFLAGS += -fPIE -pie
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8425/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8425/Android.mk
index 1289fe3..6e85bac 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8425/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-8425/Android.mk
@@ -22,10 +22,11 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
+LOCAL_CFLAGS += -Wno-unused-variable -Wno-unused-function
LOCAL_LDFLAGS += -fPIE -pie
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8426/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8426/Android.mk
index fa9104f..29dbda7 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8426/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-8426/Android.mk
@@ -22,10 +22,11 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
+LOCAL_CFLAGS += -Wno-unused-variable -Wno-unused-function
LOCAL_LDFLAGS += -fPIE -pie
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8427/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8427/Android.mk
index 2b115a8..51e2175 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8427/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-8427/Android.mk
@@ -22,10 +22,11 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
+LOCAL_CFLAGS += -Wno-constant-conversion -Wno-user-defined-warnings
LOCAL_LDFLAGS += -fPIE -pie
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8428/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8428/Android.mk
index 888539e..84fc531 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8428/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-8428/Android.mk
@@ -22,10 +22,12 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
+LOCAL_CFLAGS += -Wno-incompatible-pointer-types -Wno-missing-field-initializers
+LOCAL_CFLAGS += -Wno-unused-variable
LOCAL_LDFLAGS += -fPIE -pie
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8429/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8429/Android.mk
index 5e4e7ce..9b3f8ec 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8429/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-8429/Android.mk
@@ -22,10 +22,11 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
+LOCAL_CFLAGS += -Wno-incompatible-pointer-types -Wno-missing-field-initializers
LOCAL_LDFLAGS += -fPIE -pie
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8430/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8430/Android.mk
index 141b86d..9ac496a 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8430/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-8430/Android.mk
@@ -22,10 +22,11 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
+LOCAL_CFLAGS += -Wno-incompatible-pointer-types -Wno-missing-field-initializers
LOCAL_LDFLAGS += -fPIE -pie
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8431/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8431/Android.mk
index 0eb3c0d..7f2f80e 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8431/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-8431/Android.mk
@@ -22,9 +22,10 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wall -Werror
LOCAL_LDFLAGS += -fPIE -pie
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8432/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8432/Android.mk
index 681b8ef..020dbf4 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8432/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-8432/Android.mk
@@ -22,10 +22,10 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
LOCAL_LDFLAGS += -fPIE -pie
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8434/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8434/Android.mk
index 72754be..3da9cd8 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8434/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-8434/Android.mk
@@ -22,10 +22,10 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
LOCAL_LDFLAGS += -fPIE -pie
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8460/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8460/Android.mk
index 30506f3..97d900a 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8460/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-8460/Android.mk
@@ -22,10 +22,11 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
+LOCAL_CFLAGS += -Wno-missing-braces -Wno-missing-field-initializers -Wno-pointer-arith -Wno-pointer-sign -Wno-unused-variable
LOCAL_LDFLAGS += -fPIE -pie
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8479/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8479/Android.mk
index 744144c..f5fbd1a 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8479/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-8479/Android.mk
@@ -23,7 +23,7 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
+LOCAL_COMPATIBILITY_SUITE := cts vts
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8482/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8482/Android.mk
index ee9620a..4444a2d 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8482/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-8482/Android.mk
@@ -22,10 +22,11 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
+LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-unused-variable
LOCAL_LDFLAGS += -fPIE -pie
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0333/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0333/Android.mk
index ae9fad5..5e19036 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0333/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0333/Android.mk
@@ -23,7 +23,7 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
+LOCAL_COMPATIBILITY_SUITE := cts vts
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0451/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0451/Android.mk
index 445754c..6d031f8 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0451/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0451/Android.mk
@@ -27,10 +27,11 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+LOCAL_CFLAGS += -Wno-incompatible-pointer-types-discards-qualifiers
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0462/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0462/Android.mk
index 35531b4..9c3bd78 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0462/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0462/Android.mk
@@ -26,10 +26,11 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes
+LOCAL_CFLAGS += -Wno-packed -Wno-unused-parameter -Wno-unused-variable
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0508/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0508/Android.mk
index e51e98b..194cd9f 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0508/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0508/Android.mk
@@ -23,7 +23,7 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
+LOCAL_COMPATIBILITY_SUITE := cts vts
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0564/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0564/Android.mk
index 0a02b5e..48d8d4b 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0564/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0564/Android.mk
@@ -27,10 +27,10 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wno-shadow
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0564/kernel-headers/linux/ion.h b/hostsidetests/security/securityPatch/CVE-2017-0564/kernel-headers/linux/ion.h
new file mode 100644
index 0000000..7b5b031
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0564/kernel-headers/linux/ion.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** This header was automatically generated from a Linux kernel header
+ *** of the same name, to make information necessary for userspace to
+ *** call into the kernel available to libc. It contains only constants,
+ *** structures, and macros generated from the original header, and thus,
+ *** contains no copyrightable information.
+ ***
+ *** To edit the content of this header, modify the corresponding
+ *** source file (e.g. under external/kernel-headers/original/) then
+ *** run bionic/libc/kernel/tools/update_all.py
+ ***
+ *** Any manual change here will be lost the next time this script will
+ *** be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _UAPI_LINUX_ION_H
+#define _UAPI_LINUX_ION_H
+#include <linux/ioctl.h>
+#include <linux/types.h>
+typedef int ion_user_handle_t;
+enum ion_heap_type {
+ ION_HEAP_TYPE_SYSTEM,
+ ION_HEAP_TYPE_SYSTEM_CONTIG,
+ ION_HEAP_TYPE_CARVEOUT,
+ ION_HEAP_TYPE_CHUNK,
+ ION_HEAP_TYPE_DMA,
+ ION_HEAP_TYPE_CUSTOM,
+};
+#define ION_NUM_HEAP_IDS (sizeof(unsigned int) * 8)
+#define ION_FLAG_CACHED 1
+#define ION_FLAG_CACHED_NEEDS_SYNC 2
+struct ion_allocation_data {
+ size_t len;
+ size_t align;
+ unsigned int heap_id_mask;
+ unsigned int flags;
+ ion_user_handle_t handle;
+};
+struct ion_fd_data {
+ ion_user_handle_t handle;
+ int fd;
+};
+struct ion_handle_data {
+ ion_user_handle_t handle;
+};
+struct ion_custom_data {
+ unsigned int cmd;
+ unsigned long arg;
+};
+#define MAX_HEAP_NAME 32
+struct ion_heap_data {
+ char name[MAX_HEAP_NAME];
+ __u32 type;
+ __u32 heap_id;
+ __u32 reserved0;
+ __u32 reserved1;
+ __u32 reserved2;
+};
+struct ion_heap_query {
+ __u32 cnt;
+ __u32 reserved0;
+ __u64 heaps;
+ __u32 reserved1;
+ __u32 reserved2;
+};
+#define ION_IOC_MAGIC 'I'
+#define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, struct ion_allocation_data)
+#define ION_IOC_FREE _IOWR(ION_IOC_MAGIC, 1, struct ion_handle_data)
+#define ION_IOC_MAP _IOWR(ION_IOC_MAGIC, 2, struct ion_fd_data)
+#define ION_IOC_SHARE _IOWR(ION_IOC_MAGIC, 4, struct ion_fd_data)
+#define ION_IOC_IMPORT _IOWR(ION_IOC_MAGIC, 5, struct ion_fd_data)
+#define ION_IOC_SYNC _IOWR(ION_IOC_MAGIC, 7, struct ion_fd_data)
+#define ION_IOC_CUSTOM _IOWR(ION_IOC_MAGIC, 6, struct ion_custom_data)
+#define ION_IOC_HEAP_QUERY _IOWR(ION_IOC_MAGIC, 8, struct ion_heap_query)
+#endif
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0564/original-kernel-headers/linux/ion.h b/hostsidetests/security/securityPatch/CVE-2017-0564/original-kernel-headers/linux/ion.h
new file mode 100644
index 0000000..14cd873
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0564/original-kernel-headers/linux/ion.h
@@ -0,0 +1,236 @@
+/*
+ * drivers/staging/android/uapi/ion.h
+ *
+ * Copyright (C) 2011 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef _UAPI_LINUX_ION_H
+#define _UAPI_LINUX_ION_H
+
+#include <linux/ioctl.h>
+#include <linux/types.h>
+
+typedef int ion_user_handle_t;
+
+/**
+ * enum ion_heap_types - list of all possible types of heaps
+ * @ION_HEAP_TYPE_SYSTEM: memory allocated via vmalloc
+ * @ION_HEAP_TYPE_SYSTEM_CONTIG: memory allocated via kmalloc
+ * @ION_HEAP_TYPE_CARVEOUT: memory allocated from a prereserved
+ * carveout heap, allocations are physically
+ * contiguous
+ * @ION_HEAP_TYPE_DMA: memory allocated via DMA API
+ * @ION_NUM_HEAPS: helper for iterating over heaps, a bit mask
+ * is used to identify the heaps, so only 32
+ * total heap types are supported
+ */
+enum ion_heap_type {
+ ION_HEAP_TYPE_SYSTEM,
+ ION_HEAP_TYPE_SYSTEM_CONTIG,
+ ION_HEAP_TYPE_CARVEOUT,
+ ION_HEAP_TYPE_CHUNK,
+ ION_HEAP_TYPE_DMA,
+ ION_HEAP_TYPE_CUSTOM, /*
+ * must be last so device specific heaps always
+ * are at the end of this enum
+ */
+};
+
+#define ION_NUM_HEAP_IDS (sizeof(unsigned int) * 8)
+
+/**
+ * allocation flags - the lower 16 bits are used by core ion, the upper 16
+ * bits are reserved for use by the heaps themselves.
+ */
+
+/*
+ * mappings of this buffer should be cached, ion will do cache maintenance
+ * when the buffer is mapped for dma
+ */
+#define ION_FLAG_CACHED 1
+
+/*
+ * mappings of this buffer will created at mmap time, if this is set
+ * caches must be managed manually
+ */
+#define ION_FLAG_CACHED_NEEDS_SYNC 2
+
+/**
+ * DOC: Ion Userspace API
+ *
+ * create a client by opening /dev/ion
+ * most operations handled via following ioctls
+ *
+ */
+
+/**
+ * struct ion_allocation_data - metadata passed from userspace for allocations
+ * @len: size of the allocation
+ * @align: required alignment of the allocation
+ * @heap_id_mask: mask of heap ids to allocate from
+ * @flags: flags passed to heap
+ * @handle: pointer that will be populated with a cookie to use to
+ * refer to this allocation
+ *
+ * Provided by userspace as an argument to the ioctl
+ */
+struct ion_allocation_data {
+ size_t len;
+ size_t align;
+ unsigned int heap_id_mask;
+ unsigned int flags;
+ ion_user_handle_t handle;
+};
+
+/**
+ * struct ion_fd_data - metadata passed to/from userspace for a handle/fd pair
+ * @handle: a handle
+ * @fd: a file descriptor representing that handle
+ *
+ * For ION_IOC_SHARE or ION_IOC_MAP userspace populates the handle field with
+ * the handle returned from ion alloc, and the kernel returns the file
+ * descriptor to share or map in the fd field. For ION_IOC_IMPORT, userspace
+ * provides the file descriptor and the kernel returns the handle.
+ */
+struct ion_fd_data {
+ ion_user_handle_t handle;
+ int fd;
+};
+
+/**
+ * struct ion_handle_data - a handle passed to/from the kernel
+ * @handle: a handle
+ */
+struct ion_handle_data {
+ ion_user_handle_t handle;
+};
+
+/**
+ * struct ion_custom_data - metadata passed to/from userspace for a custom ioctl
+ * @cmd: the custom ioctl function to call
+ * @arg: additional data to pass to the custom ioctl, typically a user
+ * pointer to a predefined structure
+ *
+ * This works just like the regular cmd and arg fields of an ioctl.
+ */
+struct ion_custom_data {
+ unsigned int cmd;
+ unsigned long arg;
+};
+
+#define MAX_HEAP_NAME 32
+
+/**
+ * struct ion_heap_data - data about a heap
+ * @name - first 32 characters of the heap name
+ * @type - heap type
+ * @heap_id - heap id for the heap
+ */
+struct ion_heap_data {
+ char name[MAX_HEAP_NAME];
+ __u32 type;
+ __u32 heap_id;
+ __u32 reserved0;
+ __u32 reserved1;
+ __u32 reserved2;
+};
+
+/**
+ * struct ion_heap_query - collection of data about all heaps
+ * @cnt - total number of heaps to be copied
+ * @heaps - buffer to copy heap data
+ */
+struct ion_heap_query {
+ __u32 cnt; /* Total number of heaps to be copied */
+ __u32 reserved0; /* align to 64bits */
+ __u64 heaps; /* buffer to be populated */
+ __u32 reserved1;
+ __u32 reserved2;
+};
+
+#define ION_IOC_MAGIC 'I'
+
+/**
+ * DOC: ION_IOC_ALLOC - allocate memory
+ *
+ * Takes an ion_allocation_data struct and returns it with the handle field
+ * populated with the opaque handle for the allocation.
+ */
+#define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \
+ struct ion_allocation_data)
+
+/**
+ * DOC: ION_IOC_FREE - free memory
+ *
+ * Takes an ion_handle_data struct and frees the handle.
+ */
+#define ION_IOC_FREE _IOWR(ION_IOC_MAGIC, 1, struct ion_handle_data)
+
+/**
+ * DOC: ION_IOC_MAP - get a file descriptor to mmap
+ *
+ * Takes an ion_fd_data struct with the handle field populated with a valid
+ * opaque handle. Returns the struct with the fd field set to a file
+ * descriptor open in the current address space. This file descriptor
+ * can then be used as an argument to mmap.
+ */
+#define ION_IOC_MAP _IOWR(ION_IOC_MAGIC, 2, struct ion_fd_data)
+
+/**
+ * DOC: ION_IOC_SHARE - creates a file descriptor to use to share an allocation
+ *
+ * Takes an ion_fd_data struct with the handle field populated with a valid
+ * opaque handle. Returns the struct with the fd field set to a file
+ * descriptor open in the current address space. This file descriptor
+ * can then be passed to another process. The corresponding opaque handle can
+ * be retrieved via ION_IOC_IMPORT.
+ */
+#define ION_IOC_SHARE _IOWR(ION_IOC_MAGIC, 4, struct ion_fd_data)
+
+/**
+ * DOC: ION_IOC_IMPORT - imports a shared file descriptor
+ *
+ * Takes an ion_fd_data struct with the fd field populated with a valid file
+ * descriptor obtained from ION_IOC_SHARE and returns the struct with the handle
+ * filed set to the corresponding opaque handle.
+ */
+#define ION_IOC_IMPORT _IOWR(ION_IOC_MAGIC, 5, struct ion_fd_data)
+
+/**
+ * DOC: ION_IOC_SYNC - syncs a shared file descriptors to memory
+ *
+ * Deprecated in favor of using the dma_buf api's correctly (syncing
+ * will happen automatically when the buffer is mapped to a device).
+ * If necessary should be used after touching a cached buffer from the cpu,
+ * this will make the buffer in memory coherent.
+ */
+#define ION_IOC_SYNC _IOWR(ION_IOC_MAGIC, 7, struct ion_fd_data)
+
+/**
+ * DOC: ION_IOC_CUSTOM - call architecture specific ion ioctl
+ *
+ * Takes the argument of the architecture specific ioctl to call and
+ * passes appropriate userdata for that ioctl
+ */
+#define ION_IOC_CUSTOM _IOWR(ION_IOC_MAGIC, 6, struct ion_custom_data)
+
+/**
+ * DOC: ION_IOC_HEAP_QUERY - information about available heaps
+ *
+ * Takes an ion_heap_query structure and populates information about
+ * available Ion heaps.
+ */
+#define ION_IOC_HEAP_QUERY _IOWR(ION_IOC_MAGIC, 8, \
+ struct ion_heap_query)
+
+#endif /* _UAPI_LINUX_ION_H */
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0564/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0564/poc.c
index 7734d4c..ae5ad40 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0564/poc.c
+++ b/hostsidetests/security/securityPatch/CVE-2017-0564/poc.c
@@ -29,7 +29,11 @@
#include <string.h>
#include <fcntl.h>
#include <errno.h>
-#include <linux/ion.h>
+
+// Include a fixed version of the ion.h file because it changes per kernel.
+// This test is going to be extremely brittle due to it's dependency on
+// a structure that is going to change with different kernels.
+#include "kernel-headers/linux/ion.h"
#define ION_HEAP(bit) (1 << (bit))
@@ -73,7 +77,7 @@
#ifdef NEW_ION
.heap_id_mask = ion_type,
//.flags = ION_SECURE | ION_FORCE_CONTIGUOUS,
- .flags = (1 << 0),
+ //.flags = (1 << 0),
.flags = 0x0,
#else
.flags = ION_SECURE | ION_FORCE_CONTIGUOUS | ION_HEAP(ION_CP_MM_HEAP_ID),
@@ -165,7 +169,7 @@
int main()
{
- int ret, i, count;
+ int ret, count;
pthread_t tid_free[2];
count = 0;
@@ -178,6 +182,7 @@
return -1;
}
+ size_t i;
for (i=0; i < sizeof(ion_type)/sizeof(ion_type[0]); i++) {
ret = ion_alloc(ion_fd, 0x1000, &ion_handle, ion_type[i]);
if (ret == 0) {
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0576/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0576/Android.mk
index 28e49a5..559505a 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0576/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0576/Android.mk
@@ -26,10 +26,10 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0577/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0577/Android.mk
index 521bf98..7e02d8b 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0577/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0577/Android.mk
@@ -26,10 +26,11 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes
+LOCAL_CFLAGS += -Wno-incompatible-pointer-types-discards-qualifiers
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0579/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0579/poc.c
index 5bf4329..6caab6c 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0579/poc.c
+++ b/hostsidetests/security/securityPatch/CVE-2017-0579/poc.c
@@ -77,7 +77,7 @@
int main()
{
- int file_desc, ret_val;
+ int file_desc;
const char* DEVICE_FILE_NAME = "/dev/graphics/fb0";
file_desc = open(DEVICE_FILE_NAME, 0);
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0580/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0580/Android.mk
index ec3a6f6..c2d67a3 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0580/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0580/Android.mk
@@ -26,10 +26,11 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes
+LOCAL_CFLAGS += -Wno-incompatible-pointer-types-discards-qualifiers
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0586/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0586/Android.mk
index 1dc269d9..c7805c0 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0586/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0586/Android.mk
@@ -26,10 +26,11 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+LOCAL_CFLAGS += -Wno-unused-variable
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0705/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0705/Android.mk
index dd11e97..b5d29aa 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0705/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0705/Android.mk
@@ -27,10 +27,11 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-variable
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0705/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0705/poc.c
index 8d48434..4b8a446 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0705/poc.c
+++ b/hostsidetests/security/securityPatch/CVE-2017-0705/poc.c
@@ -188,7 +188,7 @@
#define ETHER_ADDR_LEN 6
-struct __attribute__ ((packed)) _ether_addr {
+struct _ether_addr {
uint8_t octet[ETHER_ADDR_LEN];
};
diff --git a/hostsidetests/security/securityPatch/CVE-2017-7369/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-7369/Android.mk
index ee76324..47f097a 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-7369/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-7369/Android.mk
@@ -26,10 +26,12 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+LOCAL_CFLAGS += -Wno-incompatible-pointer-types-discards-qualifiers
+LOCAL_CFLAGS += -Wno-missing-prototypes -Wno-unused-variable
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
diff --git a/hostsidetests/security/securityPatch/CVE-2017-8263/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-8263/Android.mk
index 6cf70f2..ce43700 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-8263/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-8263/Android.mk
@@ -26,10 +26,11 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+LOCAL_CFLAGS += -Wno-visibility
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2017-8263/poc.c b/hostsidetests/security/securityPatch/CVE-2017-8263/poc.c
index 687bbc5..558544d 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-8263/poc.c
+++ b/hostsidetests/security/securityPatch/CVE-2017-8263/poc.c
@@ -39,7 +39,7 @@
mmap_ret = (uint64_t) mmap((void *) 0x7f0000000 /*addr*/, 0x1000 /*length*/, 0x0 /*prot*/,
0x12 /*flags=MAP_FIXED|MAP_PRIVATE*/, fd, 0x0 /*offset*/);
- if (mmap_ret == MAP_FAILED) {
+ if (mmap_ret == (uint64_t) MAP_FAILED) {
return -1;
}
diff --git a/hostsidetests/security/securityPatch/CVE-2017-9678/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-9678/Android.mk
index f4f2c57..b070264 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-9678/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-9678/Android.mk
@@ -26,10 +26,10 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2017-9680/poc.c b/hostsidetests/security/securityPatch/CVE-2017-9680/poc.c
index 3d2835a..2a7e600 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-9680/poc.c
+++ b/hostsidetests/security/securityPatch/CVE-2017-9680/poc.c
@@ -124,7 +124,7 @@
unsigned char reserved;
};
-struct qbt1000_app app = {0};
+struct qbt1000_app app = {0, {0}, 0, 0};
static int get_fd(const char *dev_node) {
int fd;
@@ -137,45 +137,13 @@
return fd;
}
-static void leak_heap_ptr(int fd) {
- void *addr = NULL;
- app.app_handle = (void *)&addr;
- app.size = 32;
- ioctl(fd, QBT1000_LOAD_APP, &app);
-}
-
-static void arb_kernel_write_load_app(int fd) {
- struct qbt1000_app app = {0};
-
- app.app_handle = (void *)0xABADACCE55013337;
- ioctl(fd, QBT1000_LOAD_APP, &app);
-}
-
-static void arb_kernel_write_send_tzcmd(int fd) {
- struct qseecom_handle hdl = {0};
- struct qbt1000_send_tz_cmd cmd = {0};
- int x = 0;
-
- hdl.sbuf = (void *)0xffffffc0017b1b84;
- cmd.app_handle = &hdl;
- cmd.req_buf = &x;
- cmd.rsp_buf = NULL;
- cmd.req_buf_len = cmd.rsp_buf_len = 4;
-
- ioctl(fd, QBT1000_SEND_TZCMD, &cmd);
-}
-
-static void print_msg(char *msg) {
- int i;
- for (i = 0; i < 4096; i++) printf("%hx ", msg[i]);
- printf("\n");
-}
-
static void recv_msgs(int fd) {
- struct msghdr msg = {0};
- struct iovec io = {0};
- struct sockaddr_msm_ipc addr = {0};
- struct msm_ipc_addr address = {0};
+ struct msghdr msg;
+ memset(&msg, 0, sizeof(msg));
+ struct iovec io;
+ memset(&io, 0, sizeof(io));
+ struct sockaddr_msm_ipc addr;
+ memset(&addr, 0, sizeof(addr));
uint8_t *ptr;
struct qmi_header *hdr;
int count = 1;
@@ -199,7 +167,7 @@
hdr->msg_id = SNS_QFP_OPEN_RESP_V01;
hdr->msg_len = 3;
- ptr = io.iov_base + sizeof(*hdr);
+ ptr = (uint8_t*)((char*)io.iov_base + sizeof(*hdr));
*ptr = OPTIONAL_TLV_TYPE_START;
ptr++;
@@ -213,7 +181,8 @@
#define BUILD_INSTANCE_ID(vers, ins) (((vers)&0xFF) | (((ins)&0xFF) << 8))
static void setup_ipc_server(void) {
int fd;
- struct sockaddr_msm_ipc addr = {0};
+ struct sockaddr_msm_ipc addr;
+ memset(&addr, 0, sizeof(addr));
fd = socket(AF_MSM_IPC, SOCK_DGRAM, 0);
if (fd < 0) {
@@ -231,20 +200,7 @@
recv_msgs(fd);
}
-static void *leak_ptr(void *ignore) {
- void *save;
- while (cont) {
- if (app.app_handle != NULL) {
- save = *app.app_handle;
- if (save != NULL) {
- break;
- }
- }
- }
- return (void *)NULL;
-}
-
-static void *do_ipc_crap(void *ignore) {
+static void *do_ipc_crap(void *ignore __unused) {
setup_ipc_server();
return (void *)NULL;
}
@@ -253,14 +209,13 @@
int fd;
pthread_t race_car;
- pthread_t race_car1;
pthread_create(&race_car, NULL, do_ipc_crap, NULL);
usleep(50000);
fd = get_fd(dev);
for (;;) {
- int err = ioctl(fd, 0, (unsigned long)-4095);
+ ioctl(fd, 0, (unsigned long)-4095);
usleep(5000);
}
diff --git a/hostsidetests/security/securityPatch/CVE-2017-9692/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-9692/Android.mk
index c6a7471..c69db88 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-9692/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-9692/Android.mk
@@ -26,10 +26,10 @@
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Iinclude -fPIE
+LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+LOCAL_CFLAGS += -Iinclude -fPIE
LOCAL_LDFLAGS += -fPIE -pie
LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/src/android/security/cts/Poc16_12.java b/hostsidetests/security/src/android/security/cts/Poc16_12.java
index 1592182..7e24e8f 100644
--- a/hostsidetests/security/src/android/security/cts/Poc16_12.java
+++ b/hostsidetests/security/src/android/security/cts/Poc16_12.java
@@ -139,6 +139,73 @@
}
/**
+ * b/32700935
+ */
+ @SecurityTest
+ public void testPocCVE_2016_8435() throws Exception {
+ enableAdbRoot(getDevice());
+ if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
+ AdbUtils.runPoc("CVE-2016-8435", getDevice(), 60);
+ }
+ }
+
+ /**
+ * b/31568617
+ */
+ @SecurityTest
+ public void testPocCVE_2016_9120() throws Exception {
+ enableAdbRoot(getDevice());
+ if(containsDriver(getDevice(), "/dev/ion")) {
+ AdbUtils.runPoc("CVE-2016-9120", getDevice(), 60);
+ }
+ }
+
+ //Highs
+ /**
+ * b/31225246
+ */
+ @SecurityTest
+ public void testPocCVE_2016_8412() throws Exception {
+ enableAdbRoot(getDevice());
+ if(containsDriver(getDevice(), "/dev/v4l-subdev7")) {
+ AdbUtils.runPoc("CVE-2016-8412", getDevice(), 60);
+ }
+ }
+
+ /**
+ * b/31243641
+ */
+ @SecurityTest
+ public void testPocCVE_2016_8444() throws Exception {
+ enableAdbRoot(getDevice());
+ if(containsDriver(getDevice(), "/dev/v4l-subdev17")) {
+ AdbUtils.runPoc("CVE-2016-8444", getDevice(), 60);
+ }
+ }
+
+ /**
+ * b/31791148
+ */
+ @SecurityTest
+ public void testPocCVE_2016_8448() throws Exception {
+ enableAdbRoot(getDevice());
+ if(containsDriver(getDevice(), "/dev/graphics/fb0")) {
+ AdbUtils.runPoc("CVE-2016-8448", getDevice(), 60);
+ }
+ }
+
+ /**
+ * b/31798848
+ */
+ @SecurityTest
+ public void testPocCVE_2016_8449() throws Exception {
+ enableAdbRoot(getDevice());
+ if(containsDriver(getDevice(), "/dev/tegra_avpchannel")) {
+ AdbUtils.runPoc("CVE-2016-8449", getDevice(), 60);
+ }
+ }
+
+ /**
* b/31668540
*/
@SecurityTest
@@ -150,6 +217,37 @@
}
/**
+ * b/32402548
+ */
+ @SecurityTest
+ public void testPocCVE_2017_0403() throws Exception {
+ enableAdbRoot(getDevice());
+ AdbUtils.runPoc("CVE-2017-0403", getDevice(), 60);
+ }
+
+ /**
+ * b/32510733
+ */
+ @SecurityTest
+ public void testPocCVE_2017_0404() throws Exception {
+ enableAdbRoot(getDevice());
+ if(containsDriver(getDevice(), "/proc/asound/version")) {
+ AdbUtils.runPoc("CVE-2017-0404", getDevice(), 60);
+ }
+ }
+
+ /**
+ * b/32178033
+ */
+ @SecurityTest
+ public void testPocCVE_2016_8451() throws Exception {
+ enableAdbRoot(getDevice());
+ String command =
+ "echo AAAAAAAAA > /sys/devices/f9924000.i2c/i2c-2/2-0070/power_control";
+ AdbUtils.runCommandLine(command, getDevice());
+ }
+
+ /**
* b/32659848
*/
@SecurityTest
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_01.java b/hostsidetests/security/src/android/security/cts/Poc17_01.java
index 4fd98b7..ff32086 100644
--- a/hostsidetests/security/src/android/security/cts/Poc17_01.java
+++ b/hostsidetests/security/src/android/security/cts/Poc17_01.java
@@ -30,4 +30,5 @@
AdbUtils.runPoc("CVE-2016-8482", getDevice(), 60);
}
}
+
}
diff --git a/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java b/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java
index fb09788..45b30c6 100644
--- a/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java
+++ b/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java
@@ -62,6 +62,8 @@
public class SELinuxHostTest extends DeviceTestCase implements IBuildReceiver, IDeviceTest {
private static final Map<ITestDevice, File> cachedDevicePolicyFiles = new HashMap<>(1);
+ private static final Map<ITestDevice, File> cachedDevicePlatFcFiles = new HashMap<>(1);
+ private static final Map<ITestDevice, File> cachedDeviceNonplatFcFiles = new HashMap<>(1);
private File sepolicyAnalyze;
private File checkSeapp;
@@ -78,6 +80,9 @@
private File devicePcFile;
private File deviceSvcFile;
private File seappNeverAllowFile;
+ private File libsepolwrap;
+ private File libcpp;
+ private File sepolicyTests;
private IBuildInfo mBuild;
@@ -107,9 +112,11 @@
InputStream is = this.getClass().getResourceAsStream(resName);
File tempFile = File.createTempFile("SELinuxHostTest", ".tmp");
FileOutputStream os = new FileOutputStream(tempFile);
- int rByte = 0;
- while ((rByte = is.read()) != -1) {
- os.write(rByte);
+ byte[] buf = new byte[1024];
+ int len;
+
+ while ((len = is.read(buf)) != -1) {
+ os.write(buf, 0, len);
}
os.flush();
os.close();
@@ -137,6 +144,43 @@
sepolicyAnalyze.setExecutable(true);
devicePolicyFile = getDevicePolicyFile(mDevice);
+ if (mDevice.doesFileExist("/system/etc/selinux/plat_file_contexts")) {
+ devicePlatFcFile = getDeviceFile(mDevice, cachedDevicePlatFcFiles,
+ "/system/etc/selinux/plat_file_contexts", "plat_file_contexts");
+ deviceNonplatFcFile = getDeviceFile(mDevice, cachedDeviceNonplatFcFiles,
+ "/vendor/etc/selinux/nonplat_file_contexts", "nonplat_file_contexts");
+ } else {
+ devicePlatFcFile = getDeviceFile(mDevice, cachedDevicePlatFcFiles,
+ "/plat_file_contexts", "plat_file_contexts");
+ deviceNonplatFcFile = getDeviceFile(mDevice, cachedDeviceNonplatFcFiles,
+ "/nonplat_file_contexts", "nonplat_file_contexts");
+ }
+ }
+
+ /*
+ * IMPLEMENTATION DETAILS: We cache some host-side policy files on per-device basis (in case
+ * CTS supports running against multiple devices at the same time). HashMap is used instead
+ * of WeakHashMap because in the grand scheme of things, keeping ITestDevice and
+ * corresponding File objects from being garbage-collected is not a big deal in CTS. If this
+ * becomes a big deal, this can be switched to WeakHashMap.
+ */
+ private static File getDeviceFile(ITestDevice device,
+ Map<ITestDevice, File> cache, String deviceFilePath,
+ String tmpFileName) throws Exception {
+ File file;
+ synchronized (cache) {
+ file = cache.get(device);
+ }
+ if (file != null) {
+ return file;
+ }
+ file = File.createTempFile(tmpFileName, ".tmp");
+ file.deleteOnExit();
+ device.pullFile(deviceFilePath, file);
+ synchronized (cache) {
+ cache.put(device, file);
+ }
+ return file;
}
// NOTE: cts/tools/selinux depends on this method. Rename/change with caution.
@@ -144,25 +188,7 @@
* Returns the host-side file containing the SELinux policy of the device under test.
*/
public static File getDevicePolicyFile(ITestDevice device) throws Exception {
- // IMPLEMENTATION DETAILS: We cache the host-side policy file on per-device basis (in case
- // CTS supports running against multiple devices at the same time). HashMap is used instead
- // of WeakHashMap because in the grand scheme of things, keeping ITestDevice and
- // corresponding File objects from being garbage-collected is not a big deal in CTS. If this
- // becomes a big deal, this can be switched to WeakHashMap.
- File file;
- synchronized (cachedDevicePolicyFiles) {
- file = cachedDevicePolicyFiles.get(device);
- }
- if (file != null) {
- return file;
- }
- file = File.createTempFile("sepolicy", ".tmp");
- file.deleteOnExit();
- device.pullFile("/sys/fs/selinux/policy", file);
- synchronized (cachedDevicePolicyFiles) {
- cachedDevicePolicyFiles.put(device, file);
- }
- return file;
+ return getDeviceFile(device, cachedDevicePolicyFiles, "/sys/fs/selinux/policy", "sepolicy");
}
/**
@@ -455,13 +481,6 @@
checkFc = copyResourceToTempFile("/checkfc");
checkFc.setExecutable(true);
- /* obtain file_contexts file(s) from running device */
- devicePlatFcFile = File.createTempFile("file_contexts", ".tmp");
- devicePlatFcFile.deleteOnExit();
- if (!mDevice.pullFile("/system/etc/selinux/plat_file_contexts", devicePlatFcFile)) {
- mDevice.pullFile("/plat_file_contexts", devicePlatFcFile);
- }
-
/* retrieve the AOSP file_contexts file from jar */
aospFcFile = copyResourceToTempFile("/plat_file_contexts");
@@ -539,24 +558,16 @@
checkFc = copyResourceToTempFile("/checkfc");
checkFc.setExecutable(true);
- /* obtain file_contexts file(s) from running device */
- devicePlatFcFile = File.createTempFile("plat_file_contexts", ".tmp");
- devicePlatFcFile.deleteOnExit();
- deviceNonplatFcFile = File.createTempFile("nonplat_file_contexts", ".tmp");
- deviceNonplatFcFile.deleteOnExit();
- if (mDevice.pullFile("/system/etc/selinux/plat_file_contexts", devicePlatFcFile)) {
- mDevice.pullFile("/vendor/etc/selinux/nonplat_file_contexts", deviceNonplatFcFile);
- } else {
- mDevice.pullFile("/plat_file_contexts", devicePlatFcFile);
- mDevice.pullFile("/nonplat_file_contexts", deviceNonplatFcFile);
- }
- appendTo(devicePlatFcFile.getAbsolutePath(),
- deviceNonplatFcFile.getAbsolutePath());
+ /* combine plat and nonplat policies for testing */
+ File combinedFcFile = File.createTempFile("combined_file_context", ".tmp");
+ combinedFcFile.deleteOnExit();
+ appendTo(combinedFcFile.getAbsolutePath(), devicePlatFcFile.getAbsolutePath());
+ appendTo(combinedFcFile.getAbsolutePath(), deviceNonplatFcFile.getAbsolutePath());
/* run checkfc sepolicy file_contexts */
ProcessBuilder pb = new ProcessBuilder(checkFc.getAbsolutePath(),
devicePolicyFile.getAbsolutePath(),
- devicePlatFcFile.getAbsolutePath());
+ combinedFcFile.getAbsolutePath());
pb.redirectOutput(ProcessBuilder.Redirect.PIPE);
pb.redirectErrorStream(true);
Process p = pb.start();
@@ -581,17 +592,19 @@
public void testValidPropertyContexts() throws Exception {
/* retrieve the checkfc executable from jar */
- checkFc = copyResourceToTempFile("/checkfc");
- checkFc.setExecutable(true);
+ File propertyInfoChecker = copyResourceToTempFile("/property_info_checker");
+ propertyInfoChecker.setExecutable(true);
/* obtain property_contexts file from running device */
devicePcFile = File.createTempFile("property_contexts", ".tmp");
devicePcFile.deleteOnExit();
- mDevice.pullFile("/property_contexts", devicePcFile);
+ // plat_property_contexts may be either in /system/etc/sepolicy or in /
+ if (!mDevice.pullFile("/system/etc/selinux/plat_property_contexts", devicePcFile)) {
+ mDevice.pullFile("/plat_property_contexts", devicePcFile);
+ }
- /* run checkfc -p on property_contexts */
- ProcessBuilder pb = new ProcessBuilder(checkFc.getAbsolutePath(),
- "-p", devicePolicyFile.getAbsolutePath(),
+ /* run property_info_checker on property_contexts */
+ ProcessBuilder pb = new ProcessBuilder(propertyInfoChecker.getAbsolutePath(),
devicePcFile.getAbsolutePath());
pb.redirectOutput(ProcessBuilder.Redirect.PIPE);
pb.redirectErrorStream(true);
@@ -644,6 +657,87 @@
+ errorString, errorString.length() == 0);
}
+ private boolean isMac() {
+ String os = System.getProperty("os.name").toLowerCase();
+ return (os.startsWith("mac") || os.startsWith("darwin"));
+ }
+
+ private void setupLibraries() throws Exception {
+ // The host side binary tests are host OS specific. Use Linux
+ // libraries on Linux and Mac libraries on Mac.
+ if (isMac()) {
+ libsepolwrap = copyResourceToTempFile("/libsepolwrap.dylib");
+ libcpp = copyResourceToTempFile("/libc++.dylib");
+ libcpp.renameTo(new File(System.getProperty("java.io.tmpdir") + "/libc++.dylib"));
+ } else {
+ libsepolwrap = copyResourceToTempFile("/libsepolwrap.so");
+ libcpp = copyResourceToTempFile("/libc++.so");
+ libcpp.renameTo(new File(System.getProperty("java.io.tmpdir") + "/libc++.so"));
+ }
+ libsepolwrap.deleteOnExit();
+ libcpp.deleteOnExit();
+ }
+
+ private void assertSepolicyTests(String test, String testExecutable) throws Exception {
+ setupLibraries();
+ sepolicyTests = copyResourceToTempFile(testExecutable);
+ sepolicyTests.setExecutable(true);
+ ProcessBuilder pb = new ProcessBuilder(
+ sepolicyTests.getAbsolutePath(),
+ "-l", libsepolwrap.getAbsolutePath(),
+ "-f", devicePlatFcFile.getAbsolutePath(),
+ "-f", deviceNonplatFcFile.getAbsolutePath(),
+ "-p", devicePolicyFile.getAbsolutePath(),
+ "--test", test);
+ Map<String, String> env = pb.environment();
+ if (isMac()) {
+ env.put("DYLD_LIBRARY_PATH", System.getProperty("java.io.tmpdir"));
+ } else {
+ env.put("LD_LIBRARY_PATH", System.getProperty("java.io.tmpdir"));
+ }
+ pb.redirectOutput(ProcessBuilder.Redirect.PIPE);
+ pb.redirectErrorStream(true);
+ Process p = pb.start();
+ p.waitFor();
+ BufferedReader result = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ String line;
+ StringBuilder errorString = new StringBuilder();
+ while ((line = result.readLine()) != null) {
+ errorString.append(line);
+ errorString.append("\n");
+ }
+ assertTrue(errorString.toString(), errorString.length() == 0);
+ }
+
+ /**
+ * Tests that all types on /data have the data_file_type attribute.
+ *
+ * @throws Exception
+ */
+ public void testDataTypeViolators() throws Exception {
+ assertSepolicyTests("TestDataTypeViolations", "/sepolicy_tests");
+ }
+
+ /**
+ * Tests that all types on /vendor have the vendor_file_type attribute.
+ *
+ * @throws Exception
+ */
+ public void testVendorTypeViolators() throws Exception {
+ assertSepolicyTests("TestVendorTypeViolations", "/sepolicy_tests");
+ }
+
+ /**
+ * Tests that all domains with entrypoints on /system have the coredomain
+ * attribute, and that all domains with entrypoints on /vendor do not have the
+ * coredomain attribute.
+ *
+ * @throws Exception
+ */
+ public void testCoredomainViolators() throws Exception {
+ assertSepolicyTests("CoredomainViolations", "/treble_sepolicy_tests");
+ }
+
/**
* Tests that the policy defines no booleans (runtime conditional policy).
*
@@ -811,24 +905,37 @@
assertTrue(msg, execList.contains(p.procTitle));
}
}
+ }
- for (String exe : executables) {
- List<ProcessDetails> exeProcs = ProcessDetails.getExeMap(mDevice).get(exe);
+ /**
+ * Asserts that an executable exists and is only running in the listed domains.
+ *
+ * @param executable
+ * The path of the executable to check.
+ * @param domains
+ * The list of allowed domains.
+ */
+ private void assertExecutableHasDomain(String executable, String... domains)
+ throws DeviceNotAvailableException {
+ List<ProcessDetails> exeProcs = ProcessDetails.getExeMap(mDevice).get(executable);
+ Set<String> domainList = new HashSet<String>(Arrays.asList(domains));
- if (exeProcs != null) {
- for (ProcessDetails p : exeProcs) {
- String msg = "Expected executable \"" + exe + "\" in SELinux domain \""
- + domain + "\"" + " Found: \"" + p + "\"";
- assertEquals(msg, domain, p.label);
- }
- }
+ String msg = "Expected 1 or more processes for executable \"" + executable + "\".";
+ assertNotNull(msg, exeProcs);
+
+ for (ProcessDetails p : exeProcs) {
+ msg = "Expected one of \"" + domainList + "\" for executable \"" + executable
+ + "\"" + " Found: \"" + p.label + "\"";
+ assertTrue(msg, domainList.contains(p.label));
}
}
/* Init is always there */
@CddTest(requirement="9.7")
public void testInitDomain() throws DeviceNotAvailableException {
- assertDomainOne("u:r:init:s0", "/init");
+ assertDomainHasExecutable("u:r:init:s0", "/init");
+ assertDomainHasExecutable("u:r:vendor_init:s0", "/init");
+ assertExecutableHasDomain("/init", "u:r:init:s0", "u:r:vendor_init:s0");
}
/* Ueventd is always there */
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/AndroidTest.xml b/hostsidetests/services/activityandwindowmanager/activitymanager/AndroidTest.xml
index 52b8d55..5ecde6b 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/AndroidTest.xml
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/AndroidTest.xml
@@ -24,6 +24,7 @@
<option name="test-file-name" value="CtsDeviceDisplaySizeApp.apk" />
<option name="test-file-name" value="CtsDisplayServiceApp.apk" />
<option name="test-file-name" value="CtsDeviceTranslucentTestApp.apk" />
+ <option name="test-file-name" value="CtsDeviceTranslucentTestApp26.apk" />
</target_preparer>
<test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
<option name="jar" value="CtsServicesHostTestCases.jar" />
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java
index fc90f91..025f9b8 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java
@@ -42,7 +42,9 @@
private static final String NIGHT_MODE_ACTIVITY = "NightModeActivity";
private static final String DIALOG_WHEN_LARGE_ACTIVITY = "DialogWhenLargeActivity";
- private static final String TRANSLUCENT_ACTIVITY = "TranslucentLandscapeActivity";
+ private static final String TRANSLUCENT_ACTIVITY =
+ "android.server.translucentapp.TranslucentLandscapeActivity";
+ private static final String TRANSLUCENT_SDK_26_PACKAGE = "android.server.translucentapp26";
private static final String TRANSLUCENT_CURRENT_PACKAGE = "android.server.translucentapp";
private static final String EXTRA_LAUNCH_NEW_TASK = "launch_new_task";
@@ -333,9 +335,9 @@
1 /* portrait */, initialReportedSizes.orientation);
logSeparator = clearLogcat();
- launchActivityInComponent(TRANSLUCENT_CURRENT_PACKAGE, TRANSLUCENT_ACTIVITY);
+ launchActivityInComponent(TRANSLUCENT_SDK_26_PACKAGE, TRANSLUCENT_ACTIVITY);
- assertEquals("non-fullscreen activity requested landscape orientation",
+ assertEquals("Legacy non-fullscreen activity requested landscape orientation",
0 /* landscape */, mAmWmState.getWmState().getLastOrientation());
// TODO(b/36897968): uncomment once we can suppress unsupported configurations
@@ -437,11 +439,6 @@
*/
private void requestOrientationInSplitScreen(int orientation, String activity)
throws Exception {
- if (!supportsSplitScreenMultiWindow()) {
- CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no multi-window support");
- return;
- }
-
// Set initial orientation.
setDeviceRotation(orientation);
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDisplayTests.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDisplayTests.java
index aaa5593..72a477f 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDisplayTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDisplayTests.java
@@ -1692,8 +1692,6 @@
* on an external secondary display.
*/
public void testExternalDisplayActivityTurnPrimaryOff() throws Exception {
- if (!supportsMultiDisplay()) { return; }
-
// Launch something on the primary display so we know there is a resumed activity there
launchActivity(RESIZEABLE_ACTIVITY_NAME);
waitAndAssertActivityResumed(RESIZEABLE_ACTIVITY_NAME, DEFAULT_DISPLAY_ID,
@@ -1725,8 +1723,6 @@
* display is off.
*/
public void testLaunchExternalDisplayActivityWhilePrimaryOff() throws Exception {
- if (!supportsMultiDisplay()) { return; }
-
// Launch something on the primary display so we know there is a resumed activity there
launchActivity(RESIZEABLE_ACTIVITY_NAME);
waitAndAssertActivityResumed(RESIZEABLE_ACTIVITY_NAME, DEFAULT_DISPLAY_ID,
@@ -1754,8 +1750,6 @@
* Tests that turning the secondary display off stops activities running on that display.
*/
public void testExternalDisplayToggleState() throws Exception {
- if (!supportsMultiDisplay()) { return; }
-
final DisplayState newDisplay = createExternalVirtualDisplay(
false /* showContentWhenLocked */);
@@ -1783,8 +1777,6 @@
* activity on the primary display.
*/
public void testStackFocusSwitchOnTouchEventAfterKeyguard() throws Exception {
- if (!supportsMultiDisplay()) { return; }
-
// Launch something on the primary display so we know there is a resumed activity there
launchActivity(RESIZEABLE_ACTIVITY_NAME);
waitAndAssertActivityResumed(RESIZEABLE_ACTIVITY_NAME, DEFAULT_DISPLAY_ID,
@@ -1868,8 +1860,6 @@
* Tests that showWhenLocked works on a secondary display.
*/
public void testSecondaryDisplayShowWhenLocked() throws Exception {
- if (!supportsMultiDisplay()) { return; }
-
try {
setLockCredential();
diff --git a/tests/signature/api-check/legacy-test-26-api/Android.mk b/hostsidetests/services/activityandwindowmanager/activitymanager/translucentappsdk26/Android.mk
similarity index 61%
copy from tests/signature/api-check/legacy-test-26-api/Android.mk
copy to hostsidetests/services/activityandwindowmanager/activitymanager/translucentappsdk26/Android.mk
index 699bd0c..dbb0b2b 100644
--- a/tests/signature/api-check/legacy-test-26-api/Android.mk
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/translucentappsdk26/Android.mk
@@ -12,13 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-LOCAL_PATH := $(call my-dir)
+LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := CtsLegacyTest26ApiSignatureTestCases
+# Don't include this package in any target.
+LOCAL_MODULE_TAGS := tests
-LOCAL_SIGNATURE_API_FILES := \
- legacy-test-current.api \
+LOCAL_SRC_FILES := \
+ $(call all-java-files-under, ../translucentapp/src) \
-include $(LOCAL_PATH)/../build_signature_apk.mk
+LOCAL_SDK_VERSION := 26
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_PACKAGE_NAME := CtsDeviceTranslucentTestApp26
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/translucentappsdk26/AndroidManifest.xml b/hostsidetests/services/activityandwindowmanager/activitymanager/translucentappsdk26/AndroidManifest.xml
new file mode 100755
index 0000000..43c85f5
--- /dev/null
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/translucentappsdk26/AndroidManifest.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2017 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
+ package="android.server.translucentapp26">
+ <application android:label="CtsTranslucentApp26">
+ <activity android:name="android.server.translucentapp.TranslucentLandscapeActivity"
+ android:theme="@android:style/Theme.Translucent.NoTitleBar"
+ android:exported="true"
+ android:screenOrientation="landscape">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
+
diff --git a/hostsidetests/sustainedperf/dhrystone/Android.mk b/hostsidetests/sustainedperf/dhrystone/Android.mk
index abcbe669..8645318 100644
--- a/hostsidetests/sustainedperf/dhrystone/Android.mk
+++ b/hostsidetests/sustainedperf/dhrystone/Android.mk
@@ -9,6 +9,7 @@
LOCAL_MODULE := dhry
LOCAL_SRC_FILES := dhry_1.c dhry_2.c
LOCAL_CFLAGS := -O3 -fno-inline-functions -DMSC_CLOCK -DCLK_TCK=1000000
+LOCAL_CFLAGS += -Wall -Werror -Wno-incompatible-library-redeclaration
LOCAL_CFLAGS += -Wno-return-type -Wno-implicit-function-declaration -Wno-implicit-int
# Include both the 32 and 64 bit versions
LOCAL_MULTILIB := both
diff --git a/hostsidetests/sustainedperf/dhrystone/dhry_1.c b/hostsidetests/sustainedperf/dhrystone/dhry_1.c
index c1198d1..3682052 100644
--- a/hostsidetests/sustainedperf/dhrystone/dhry_1.c
+++ b/hostsidetests/sustainedperf/dhrystone/dhry_1.c
@@ -28,7 +28,6 @@
int Arr_1_Glob [50];
int Arr_2_Glob [50] [50];
-extern char *malloc ();
Enumeration Func_1 ();
/* forward declaration necessary since Enumeration may not simply be int */
diff --git a/hostsidetests/sustainedperf/shadertoy_android/jni/Android.mk b/hostsidetests/sustainedperf/shadertoy_android/jni/Android.mk
index 2859b30..79ab5fe 100644
--- a/hostsidetests/sustainedperf/shadertoy_android/jni/Android.mk
+++ b/hostsidetests/sustainedperf/shadertoy_android/jni/Android.mk
@@ -25,6 +25,8 @@
hooks_android.cpp \
utils.cpp
+LOCAL_CFLAGS := -Wall -Werror -Wno-unused-variable
+
LOCAL_SDK_VERSION := 21
LOCAL_NDK_STL_VARIANT := c++_static
diff --git a/hostsidetests/theme/assets/P b/hostsidetests/theme/assets/P
new file mode 120000
index 0000000..a5c750f
--- /dev/null
+++ b/hostsidetests/theme/assets/P
@@ -0,0 +1 @@
+27
\ No newline at end of file
diff --git a/hostsidetests/tzdata/Android.mk b/hostsidetests/tzdata/Android.mk
index 50c22ab..e6e31fb 100644
--- a/hostsidetests/tzdata/Android.mk
+++ b/hostsidetests/tzdata/Android.mk
@@ -23,7 +23,7 @@
LOCAL_JAVA_LIBRARIES := tradefed
-LOCAL_STATIC_JAVA_LIBRARIES := tzdata-testing-host time_zone_distro-host time_zone_distro_tools-host
+LOCAL_STATIC_JAVA_LIBRARIES := tzdata-testing time_zone_distro time_zone_distro_tools
LOCAL_CTS_TEST_PACKAGE := android.host.tzdata
diff --git a/suite/audio_quality/Android.mk b/suite/audio_quality/Android.mk
index c3404d2..9cf5dc8 100644
--- a/suite/audio_quality/Android.mk
+++ b/suite/audio_quality/Android.mk
@@ -50,8 +50,6 @@
cts: $(CTS_AUDIO_QUALITY_ZIP)
-ifneq ($(filter cts, $(MAKECMDGOALS)),)
$(call dist-for-goals, cts, $(CTS_AUDIO_QUALITY_ZIP))
-endif # cts
endif # linux
diff --git a/suite/audio_quality/executable/Android.bp b/suite/audio_quality/executable/Android.bp
new file mode 100644
index 0000000..78ecd00
--- /dev/null
+++ b/suite/audio_quality/executable/Android.bp
@@ -0,0 +1,44 @@
+//
+// Copyright (C) 2012 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.
+//
+
+cc_binary_host {
+ name: "cts_audio_quality",
+ srcs: ["src/main.cpp"],
+ static_libs: [
+ "libutils",
+ "liblog",
+ "libcutils",
+ "libtinyalsa",
+ "libtinyxml2",
+ ],
+ whole_static_libs: ["libcts_audio_quality"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-g",
+ "-fno-exceptions",
+ ],
+ ldflags: [
+ "-g",
+ "-fno-exceptions",
+ ],
+ stl: "libc++_static",
+ target: {
+ darwin: {
+ enabled: false,
+ },
+ },
+}
diff --git a/suite/audio_quality/executable/Android.mk b/suite/audio_quality/executable/Android.mk
deleted file mode 100644
index b22d542..0000000
--- a/suite/audio_quality/executable/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Copyright (C) 2012 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.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := $(call all-subdir-cpp-files)
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/../lib/include $(LOCAL_PATH)/../lib/src
-LOCAL_STATIC_LIBRARIES += libutils liblog libcutils libtinyalsa libtinyxml2
-LOCAL_WHOLE_STATIC_LIBRARIES := libcts_audio_quality
-LOCAL_CFLAGS:= -g -fno-exceptions
-LOCAL_LDFLAGS:= -g -lrt -ldl -lm -fno-exceptions -lpthread
-LOCAL_CXX_STL := libc++_static
-LOCAL_MODULE_HOST_OS := linux
-LOCAL_MODULE:= cts_audio_quality
-include $(BUILD_HOST_EXECUTABLE)
diff --git a/suite/audio_quality/lib/Android.bp b/suite/audio_quality/lib/Android.bp
new file mode 100644
index 0000000..4900227
--- /dev/null
+++ b/suite/audio_quality/lib/Android.bp
@@ -0,0 +1,48 @@
+//
+// Copyright (C) 2012 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.
+//
+
+cc_library_host_static {
+ name: "libcts_audio_quality",
+ srcs: ["**/*.cpp"],
+ export_include_dirs: [
+ "include",
+ "src",
+ ],
+ static_libs: [
+ "libutils",
+ "liblog",
+ "libtinyalsa",
+ "libcutils",
+ "libtinyxml2",
+ ],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-g",
+ "-fno-exceptions",
+ "-Wno-unused-parameter",
+ "-Wno-unused-variable",
+ "-Wno-format",
+ ],
+ ldflags: [
+ "-fno-exceptions",
+ ],
+ target: {
+ darwin: {
+ enabled: false,
+ },
+ },
+}
diff --git a/suite/audio_quality/lib/Android.mk b/suite/audio_quality/lib/Android.mk
deleted file mode 100644
index 2b3c22a..0000000
--- a/suite/audio_quality/lib/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Copyright (C) 2012 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.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := $(call all-subdir-cpp-files)
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/include $(LOCAL_PATH)/src
-LOCAL_STATIC_LIBRARIES += libutils liblog libtinyalsa libcutils libtinyxml2
-LOCAL_CFLAGS:= -g -fno-exceptions -Wno-unused-parameter
-LOCAL_LDFLAGS:= -g -lrt -ldl -lm -fno-exceptions
-LOCAL_MODULE_HOST_OS := linux
-LOCAL_MODULE:= libcts_audio_quality
-include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/suite/audio_quality/lib/src/task/ModelBuilder.cpp b/suite/audio_quality/lib/src/task/ModelBuilder.cpp
index 78e5138..f1a506b 100644
--- a/suite/audio_quality/lib/src/task/ModelBuilder.cpp
+++ b/suite/audio_quality/lib/src/task/ModelBuilder.cpp
@@ -87,7 +87,7 @@
{
XMLDocument doc;
int error = doc.LoadFile(xmlFileName.string());
- if (error != XML_NO_ERROR) {
+ if (error != XML_SUCCESS) {
LOGE("ModelBuilder::parseTestDescriptionXml cannot load file %s: %d", xmlFileName.string(), error);
return NULL;
}
diff --git a/suite/audio_quality/lib/src/task/TaskSave.cpp b/suite/audio_quality/lib/src/task/TaskSave.cpp
index 18dfb5e..64a1928 100644
--- a/suite/audio_quality/lib/src/task/TaskSave.cpp
+++ b/suite/audio_quality/lib/src/task/TaskSave.cpp
@@ -14,6 +14,7 @@
* the License.
*/
+#include <inttypes.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
@@ -127,7 +128,8 @@
if (it->second.getType() == TaskCase::Value::ETypeDouble) {
details.appendFormat(" %s: %f\n", it->first.string(), it->second.getDouble());
} else { //64bit int
- details.appendFormat(" %s: %lld\n", it->first.string(), it->second.getInt64());
+ details.appendFormat(" %s: %" PRId64 "\n", it->first.string(),
+ it->second.getInt64());
}
}
MSG("%s", details.string());
diff --git a/suite/audio_quality/test/Android.bp b/suite/audio_quality/test/Android.bp
new file mode 100644
index 0000000..79e6ead
--- /dev/null
+++ b/suite/audio_quality/test/Android.bp
@@ -0,0 +1,52 @@
+//
+// Copyright (C) 2012 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.
+//
+
+cc_test_host {
+ name: "cts_audio_quality_test",
+ srcs: ["*.cpp"],
+
+ static_libs: [
+ "libutils",
+ "liblog",
+ "libcutils",
+ "libtinyalsa",
+ "libtinyxml2",
+ ],
+
+ // need to keep everything in libcts_.. Otherwise, linker will drop some
+ // functions and linker error happens
+ whole_static_libs: ["libcts_audio_quality"],
+
+ cflags: [
+ "-g",
+ "-fno-exceptions",
+ "-Wall",
+ "-Werror",
+ "-Wno-unused-parameter",
+ "-Wno-unused-variable",
+ ],
+ ldflags: [
+ "-g",
+ "-fno-exceptions",
+ ],
+ stl: "libc++_static",
+ target: {
+ darwin: {
+ enabled: false,
+ },
+ },
+ compile_multilib: "first",
+}
diff --git a/suite/audio_quality/test/Android.mk b/suite/audio_quality/test/Android.mk
deleted file mode 100644
index f8fe13c..0000000
--- a/suite/audio_quality/test/Android.mk
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# Copyright (C) 2012 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.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := $(call all-subdir-cpp-files)
-
-#$(info $(LOCAL_SRC_FILES))
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/../lib/include \
- $(LOCAL_PATH)/../lib/src \
-
-LOCAL_STATIC_LIBRARIES := \
- libutils \
- liblog \
- libcutils \
- libtinyalsa \
- libtinyxml2 \
-
-# need to keep everything in libcts_.. Otherwise, linker will drop some
-# functions and linker error happens
-LOCAL_WHOLE_STATIC_LIBRARIES := libcts_audio_quality
-LOCAL_CFLAGS:= -g -fno-exceptions -Wno-unused-parameter
-LOCAL_LDFLAGS:= -g -lrt -ldl -lm -fno-exceptions -lpthread
-LOCAL_CXX_STL := libc++_static
-LOCAL_MODULE_HOST_OS := linux
-LOCAL_MODULE := cts_audio_quality_test
-LOCAL_MULTILIB := first
-include $(BUILD_HOST_NATIVE_TEST)
diff --git a/tests/admin/src/android/admin/cts/DeviceAdminReceiverTest.java b/tests/admin/src/android/admin/cts/DeviceAdminReceiverTest.java
index cbc8811..4888476 100644
--- a/tests/admin/src/android/admin/cts/DeviceAdminReceiverTest.java
+++ b/tests/admin/src/android/admin/cts/DeviceAdminReceiverTest.java
@@ -36,9 +36,9 @@
import android.test.AndroidTestCase;
import android.util.Log;
+import org.mockito.ArgumentMatcher;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
-import org.mockito.compat.ArgumentMatcher;
public class DeviceAdminReceiverTest extends AndroidTestCase {
@@ -209,13 +209,7 @@
eq(NETWORK_LOGS_TOKEN), eq(NETWORK_LOGS_COUNT));
}
- // TODO: replace with inline argThat(x → e.equals(x.getAction())) when mockito is updated.
private Intent actionEq(final String expected) {
- return argThat(new ArgumentMatcher<Intent>() {
- @Override
- public boolean matchesObject(Object argument) {
- return expected.equals(((Intent) argument).getAction());
- }
- });
+ return argThat(x -> expected.equals(x.getAction()));
}
}
diff --git a/tests/aslr/Android.mk b/tests/aslr/Android.mk
index 2abe2a8..f0a4008 100644
--- a/tests/aslr/Android.mk
+++ b/tests/aslr/Android.mk
@@ -24,6 +24,8 @@
LOCAL_SRC_FILES := \
src/AslrMallocTest.cpp
+LOCAL_CFLAGS := -Wall -Werror
+
LOCAL_SHARED_LIBRARIES := \
libbase \
libutils \
diff --git a/tests/autofillservice/res/layout/webview_activity.xml b/tests/autofillservice/res/layout/webview_activity.xml
index 84ead4f..a975186 100644
--- a/tests/autofillservice/res/layout/webview_activity.xml
+++ b/tests/autofillservice/res/layout/webview_activity.xml
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
-->
-<android.autofillservice.cts.MyWebView xmlns:android="http://schemas.android.com/apk/res/android"
+<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
diff --git a/tests/autofillservice/src/android/autofillservice/cts/MyWebView.java b/tests/autofillservice/src/android/autofillservice/cts/MyWebView.java
deleted file mode 100644
index fa233dd..0000000
--- a/tests/autofillservice/src/android/autofillservice/cts/MyWebView.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package android.autofillservice.cts;
-
-import static android.autofillservice.cts.Helper.FILL_TIMEOUT_MS;
-
-import static com.google.common.truth.Truth.assertWithMessage;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.util.SparseArray;
-import android.view.autofill.AutofillValue;
-import android.webkit.WebView;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Custom {@link WebView} used to assert contents were autofilled.
- */
-public class MyWebView extends WebView {
-
- private FillExpectation mExpectation;
-
- public MyWebView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public void expectAutofill(String username, String password) {
- mExpectation = new FillExpectation(username, password);
- }
-
- public void assertAutofilled() throws Exception {
- assertWithMessage("expectAutofill() not called").that(mExpectation).isNotNull();
- final boolean set = mExpectation.mLatch.await(FILL_TIMEOUT_MS, TimeUnit.MILLISECONDS);
- if (mExpectation.mException != null) {
- throw mExpectation.mException;
- }
- assertWithMessage("Timeout (%s ms) expecting autofill()", FILL_TIMEOUT_MS)
- .that(set).isTrue();
- assertWithMessage("Wrong value for username").that(mExpectation.mActualUsername)
- .isEqualTo(mExpectation.mExpectedUsername);
- assertWithMessage("Wrong value for password").that(mExpectation.mActualPassword)
- .isEqualTo(mExpectation.mExpectedPassword);
- }
-
- @Override
- public void autofill(SparseArray<AutofillValue> values) {
- super.autofill(values);
-
- if (mExpectation == null) return;
-
- try {
- if (values == null || values.size() != 2) {
- mExpectation.mException =
- new IllegalArgumentException("Invalid values on autofill(): " + values);
- } else {
- try {
- mExpectation.mActualUsername = values.valueAt(0).getTextValue().toString();
- mExpectation.mActualPassword = values.valueAt(1).getTextValue().toString();
- } catch (Exception e) {
- mExpectation.mException = e;
- }
- }
- } finally {
- mExpectation.mLatch.countDown();
- }
- }
-
- private class FillExpectation {
- private final CountDownLatch mLatch = new CountDownLatch(1);
- private final String mExpectedUsername;
- private final String mExpectedPassword;
- private String mActualUsername;
- private String mActualPassword;
- private Exception mException;
-
- FillExpectation(String username, String password) {
- this.mExpectedUsername = username;
- this.mExpectedPassword = password;
- }
- }
-}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/WebViewActivity.java b/tests/autofillservice/src/android/autofillservice/cts/WebViewActivity.java
index 2ef5141..9bc3df0 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/WebViewActivity.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/WebViewActivity.java
@@ -33,7 +33,7 @@
private static final String FAKE_URL = "https://" + FAKE_DOMAIN + ":666/login.html";
static final String ID_WEBVIEW = "webview";
- MyWebView mWebView;
+ WebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -75,6 +75,7 @@
return getLabel(uiBot, "Password: ");
}
+
public UiObject2 getUsernameInput(UiBot uiBot) {
return getInput(uiBot, "Username: ");
}
@@ -84,15 +85,12 @@
}
public UiObject2 getLoginButton(UiBot uiBot) {
- return getLabel(uiBot, "Login");
+ return uiBot.assertShownByContentDescription("Login");
}
- private UiObject2 getLabel(UiBot uiBot, String label) {
- try {
- return uiBot.assertShownByContentDescription(label);
- } catch (Throwable t) {
- return uiBot.assertShownByText(label);
- }
+ private UiObject2 getLabel(UiBot uiBot, String contentDescription) {
+ final UiObject2 label = uiBot.assertShownByContentDescription(contentDescription);
+ return label;
}
private UiObject2 getInput(UiBot uiBot, String contentDescription) {
diff --git a/tests/autofillservice/src/android/autofillservice/cts/WebViewActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/WebViewActivityTest.java
index d3b2d82..7eb73d2 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/WebViewActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/WebViewActivityTest.java
@@ -82,7 +82,6 @@
enableService();
// Set expectations.
- mActivity.mWebView.expectAutofill("dude", "sweet");
final MyAutofillCallback callback = mActivity.registerCallback();
sReplier.addResponse(new CannedDataset.Builder()
.setField("username", "dude")
@@ -106,7 +105,6 @@
// Now Autofill it.
sUiBot.selectDataset(datasetPicker, "The Dude");
- mActivity.mWebView.assertAutofilled();
sUiBot.assertNoDatasets();
callback.assertUiHiddenEvent(mActivity.mWebView, passwordChildId);
@@ -210,7 +208,6 @@
// Set expectations.
final MyAutofillCallback callback = mActivity.registerCallback();
- mActivity.mWebView.expectAutofill("dude", "sweet");
sReplier.addResponse(new CannedFillResponse.Builder()
.setRequiredSavableIds(SAVE_DATA_TYPE_PASSWORD, "username", "password")
.addDataset(new CannedDataset.Builder()
@@ -238,7 +235,6 @@
// Autofill it.
sUiBot.selectDataset("The Dude");
- mActivity.mWebView.assertAutofilled();
callback.assertUiHiddenEvent(mActivity.mWebView, usernameChildId);
// Make sure screen was autofilled.
diff --git a/tests/camera/libctscamera2jni/Android.mk b/tests/camera/libctscamera2jni/Android.mk
index e6a078f..649908d 100644
--- a/tests/camera/libctscamera2jni/Android.mk
+++ b/tests/camera/libctscamera2jni/Android.mk
@@ -32,7 +32,8 @@
LOCAL_CFLAGS := -DUNIX_ENV=1 -DqDNGBigEndian=0 -DqDNGThreadSafe=1 -DqDNGUseLibJPEG=1 -DqDNGUseXMP=0 -DqDNGValidate=1 -DqDNGValidateTarget=1 -DqAndroid=1 -fexceptions -Wsign-compare -Wno-reorder -Wframe-larger-than=20000
# Flags to avoid warnings from DNG SDK
-LOCAL_CFLAGS += -Wno-unused-parameter
+LOCAL_CFLAGS += -Wall -Werror -Wno-unused-parameter
+LOCAL_CFLAGS += -Wno-unused-value -Wno-unused-variable
LOCAL_STATIC_LIBRARIES := libdng_sdk_validate libjpeg_static_ndk
LOCAL_SHARED_LIBRARIES := libandroid \
diff --git a/tests/camera/src/android/hardware/camera2/cts/CameraDeviceTest.java b/tests/camera/src/android/hardware/camera2/cts/CameraDeviceTest.java
index b51e338..3d9c683 100644
--- a/tests/camera/src/android/hardware/camera2/cts/CameraDeviceTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/CameraDeviceTest.java
@@ -49,8 +49,6 @@
import com.android.ex.camera2.blocking.BlockingStateCallback;
import com.android.ex.camera2.utils.StateWaiter;
-import org.mockito.compat.ArgumentMatcher;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.concurrent.locks.Condition;
@@ -62,6 +60,9 @@
import java.util.HashMap;
import java.util.Set;
import android.util.Size;
+
+import org.mockito.ArgumentMatcher;
+
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
@@ -1151,14 +1152,13 @@
}
private class IsCaptureResultNotEmpty
- extends ArgumentMatcher<TotalCaptureResult> {
+ implements ArgumentMatcher<TotalCaptureResult> {
@Override
- public boolean matchesObject(Object obj) {
+ public boolean matches(TotalCaptureResult result) {
/**
* Do the simple verification here. Only verify the timestamp for now.
* TODO: verify more required capture result metadata fields.
*/
- TotalCaptureResult result = (TotalCaptureResult) obj;
Long timeStamp = result.get(CaptureResult.SENSOR_TIMESTAMP);
if (timeStamp != null && timeStamp.longValue() > 0L) {
return true;
diff --git a/tests/camera/src/android/hardware/camera2/cts/SurfaceViewPreviewTest.java b/tests/camera/src/android/hardware/camera2/cts/SurfaceViewPreviewTest.java
index 34d29e5..89b1926 100644
--- a/tests/camera/src/android/hardware/camera2/cts/SurfaceViewPreviewTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/SurfaceViewPreviewTest.java
@@ -42,7 +42,7 @@
import android.view.SurfaceHolder;
import org.mockito.ArgumentCaptor;
-import org.mockito.compat.ArgumentMatcher;
+import org.mockito.ArgumentMatcher;
import static org.mockito.Mockito.*;
@@ -871,10 +871,10 @@
}
}
- private class IsCaptureResultValid extends ArgumentMatcher<TotalCaptureResult> {
+ private class IsCaptureResultValid implements ArgumentMatcher<TotalCaptureResult> {
@Override
- public boolean matchesObject(Object obj) {
- TotalCaptureResult result = (TotalCaptureResult)obj;
+ public boolean matches(TotalCaptureResult obj) {
+ TotalCaptureResult result = obj;
Long timeStamp = result.get(CaptureResult.SENSOR_TIMESTAMP);
if (timeStamp != null && timeStamp.longValue() > 0L) {
return true;
diff --git a/tests/dram/Android.mk b/tests/dram/Android.mk
deleted file mode 100644
index 1d21cdc..0000000
--- a/tests/dram/Android.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright (C) 2012 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.
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# don't include this package in any target
-LOCAL_MODULE_TAGS := tests
-
-# Include both the 32 and 64 bit versions
-LOCAL_MULTILIB := both
-
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner
-
-LOCAL_JNI_SHARED_LIBRARIES := libctsdram_jni
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := CtsDramTestCases
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-
-LOCAL_SDK_VERSION := 16
-
-include $(BUILD_CTS_PACKAGE)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/dram/AndroidManifest.xml b/tests/dram/AndroidManifest.xml
deleted file mode 100644
index d43fe79..0000000
--- a/tests/dram/AndroidManifest.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.dram.cts">
-
- <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
-
- <application>
- <uses-library android:name="android.test.runner" />
- </application>
- <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
- android:targetPackage="android.dram.cts"
- android:label="DRAM bandwidth measurement" />
-</manifest>
diff --git a/tests/dram/jni/Android.mk b/tests/dram/jni/Android.mk
deleted file mode 100644
index 1021aaa..0000000
--- a/tests/dram/jni/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright (C) 2012 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.
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libctsdram_jni
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := MemoryNativeJni.cpp
-
-LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
-
-LOCAL_SDK_VERSION := 14
-
-LOCAL_CFLAGS := -Wno-unused-parameter
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/dram/jni/MemoryNativeJni.cpp b/tests/dram/jni/MemoryNativeJni.cpp
deleted file mode 100644
index cbf145c..0000000
--- a/tests/dram/jni/MemoryNativeJni.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include <jni.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/time.h>
-
-double currentTimeMillis()
-{
- struct timeval tv;
- gettimeofday(&tv, (struct timezone *) NULL);
- return tv.tv_sec * 1000.0 + tv.tv_usec / 1000.0;
-}
-
-extern "C" JNIEXPORT jdouble JNICALL Java_android_dram_cts_MemoryNative_runMemcpy(JNIEnv* env,
- jclass clazz, jint bufferSize, jint repetition)
-{
- char* src = new char[bufferSize];
- char* dst = new char[bufferSize];
- if ((src == NULL) || (dst == NULL)) {
- delete[] src;
- delete[] dst;
- env->ThrowNew(env->FindClass("java/lang/OutOfMemoryError"), "No memory");
- return -1;
- }
- memset(src, 0, bufferSize);
- memset(dst, 0, bufferSize);
- double start = currentTimeMillis();
- for (int i = 0; i < repetition; i++) {
- memcpy(dst, src, bufferSize);
- src[bufferSize - 1] = i & 0xff;
- }
- double end = currentTimeMillis();
- delete[] src;
- delete[] dst;
- return end - start;
-}
-
-extern "C" JNIEXPORT jdouble JNICALL Java_android_dram_cts_MemoryNative_runMemset(JNIEnv* env,
- jclass clazz, jint bufferSize, jint repetition, jint c)
-{
- char* dst = new char[bufferSize];
- if (dst == NULL) {
- delete[] dst;
- env->ThrowNew(env->FindClass("java/lang/OutOfMemoryError"), "No memory");
- return -1;
- }
- memset(dst, 0, bufferSize);
- double start = currentTimeMillis();
- for (int i = 0; i < repetition; i++) {
- memset(dst, (c + i) & 0xff, bufferSize);
- }
- double end = currentTimeMillis();
- delete[] dst;
- return end - start;
-}
-
diff --git a/tests/dram/src/android/dram/cts/BandwidthTest.java b/tests/dram/src/android/dram/cts/BandwidthTest.java
deleted file mode 100644
index 8b54d90..0000000
--- a/tests/dram/src/android/dram/cts/BandwidthTest.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright (C) 2012 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.dram.cts;
-
-import android.content.Context;
-import android.graphics.Point;
-import android.util.Log;
-import android.view.WindowManager;
-
-import com.android.compatibility.common.util.CtsAndroidTestCase;
-import com.android.compatibility.common.util.DeviceReportLog;
-import com.android.compatibility.common.util.ResultType;
-import com.android.compatibility.common.util.ResultUnit;
-import com.android.compatibility.common.util.Stat;
-
-/**
- * check how many screens the memcpy function can copy in a sec.
- * Note that this does not represent the total memory bandwidth available in the system
- * as typically CPU cannot use the whole bandwidth.
- * Smaller buffers can fit into L1 or L2 cache, which can show big boost.
- */
-public class BandwidthTest extends CtsAndroidTestCase {
- private static final String TAG = BandwidthTest.class.getSimpleName();
- private static final String REPORT_LOG_NAME = "CtsDramTestCases";
- // data length is odd to prevent rare cases that all data are rejected.
- private static final int MEMCPY_REPETITION = 11;
- private static final int MEMSET_REPETITION = 31;
- private static final int REPEAT_IN_EACH_CALL = 100;
- private static final int KB = 1024;
- private static final int MB = 1024 * 1024;
- private static final int MEMSET_CHAR = 0xa5;
- // reject data outside +/- this value * median
- private static final double OUTLIER_THRESHOLD = 0.1;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- // warm-up
- MemoryNative.runMemcpy(2 * MB, 100);
- }
-
- public void testMemcpyK004() {
- doRunMemcpy(4 * KB);
- }
-
- public void testMemcpyK008() {
- doRunMemcpy(8 * KB);
- }
-
- public void testMemcpyK016() {
- doRunMemcpy(16 * KB);
- }
-
- public void testMemcpyK032() {
- doRunMemcpy(32 * KB);
- }
-
- public void testMemcpyK064() {
- doRunMemcpy(64 * KB);
- }
-
- public void testMemcpyK128() {
- doRunMemcpy(128 * KB);
- }
-
- public void testMemcpyK256() {
- doRunMemcpy(256 * KB);
- }
-
- public void testMemcpyK512() {
- doRunMemcpy(512 * KB);
- }
-
- public void testMemcpyM001() {
- doRunMemcpy(1 * MB);
- }
-
- public void testMemcpyM002() {
- doRunMemcpy(2 * MB);
- }
-
- public void testMemcpyM004() {
- doRunMemcpy(4 * MB);
- }
-
- public void testMemcpyM008() {
- doRunMemcpy(8 * MB);
- }
-
- public void testMemcpyM016() {
- doRunMemcpy(16 * MB);
- }
-
- public void testMemsetK004() {
- doRunMemset(4 * KB);
- }
-
- public void testMemsetK008() {
- doRunMemset(8 * KB);
- }
-
- public void testMemsetK016() {
- doRunMemset(16 * KB);
- }
-
- public void testMemsetK032() {
- doRunMemset(32 * KB);
- }
-
- public void testMemsetK064() {
- doRunMemset(64 * KB);
- }
-
- public void testMemsetK128() {
- doRunMemset(128 * KB);
- }
-
- public void testMemsetK256() {
- doRunMemset(256 * KB);
- }
-
- public void testMemsetK512() {
- doRunMemset(512 * KB);
- }
-
- public void testMemsetM001() {
- doRunMemset(1 * MB);
- }
-
- public void testMemsetM002() {
- doRunMemset(2 * MB);
- }
-
- public void testMemsetM004() {
- doRunMemset(4 * MB);
- }
-
- public void testMemsetM008() {
- doRunMemset(8 * MB);
- }
-
- public void testMemsetM016() {
- doRunMemset(16 * MB);
- }
-
- private void doRunMemcpy(int bufferSize) {
- double[] result = new double[MEMCPY_REPETITION];
- int repeatInEachCall = REPEAT_IN_EACH_CALL;
- if (bufferSize < (1 * MB)) {
- // too small buffer size finishes too early to give accurate result.
- repeatInEachCall *= (1 * MB / bufferSize);
- }
- for (int i = 0; i < MEMCPY_REPETITION; i++) {
- result[i] = MemoryNative.runMemcpy(bufferSize, repeatInEachCall);
- }
- String streamName = "run_memcpy";
- DeviceReportLog report = new DeviceReportLog(REPORT_LOG_NAME, streamName);
- report.addValue("buffer_size", bufferSize, ResultType.NEUTRAL, ResultUnit.NONE);
- report.addValues("memcpy_time", result, ResultType.LOWER_BETTER, ResultUnit.MS);
- double[] mbps = Stat.calcRatePerSecArray(
- (double)bufferSize * repeatInEachCall / 1024.0 / 1024.0, result);
- report.addValues("memcpy_throughput", mbps, ResultType.HIGHER_BETTER, ResultUnit.MBPS);
- Stat.StatResult stat = Stat.getStatWithOutlierRejection(mbps, OUTLIER_THRESHOLD);
- if (stat.mDataCount != result.length) {
- Log.w(TAG, "rejecting " + (result.length - stat.mDataCount) + " outliers");
- }
- WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
- Point size = new Point();
- wm.getDefaultDisplay().getSize(size);
- Log.i(TAG, " x " + size.x + " y " + size.y);
- double pixels = size.x * size.y;
- // now this represents how many times the whole screen can be copied in a sec.
- double screensPerSecAverage = stat.mAverage / pixels * 1024.0 * 1024.0 / 4.0;
- report.addValue("memcpy_in_fps", screensPerSecAverage, ResultType.HIGHER_BETTER,
- ResultUnit.FPS);
- report.setSummary("memcpy_throughput_average", stat.mAverage, ResultType.HIGHER_BETTER,
- ResultUnit.MBPS);
- report.submit(getInstrumentation());
- }
-
- private void doRunMemset(int bufferSize) {
- double[] result = new double[MEMSET_REPETITION];
- int repeatInEachCall = REPEAT_IN_EACH_CALL;
- if (bufferSize < (1 * MB)) {
- // too small buffer size finishes too early to give accurate result.
- repeatInEachCall *= (1 * MB / bufferSize);
- }
- for (int i = 0; i < MEMSET_REPETITION; i++) {
- result[i] = MemoryNative.runMemset(bufferSize, repeatInEachCall, MEMSET_CHAR);
- }
- String streamName = "run_memset";
- DeviceReportLog report = new DeviceReportLog(REPORT_LOG_NAME, streamName);
- report.addValue("buffer_size", bufferSize, ResultType.NEUTRAL, ResultUnit.NONE);
- report.addValues("memset_time", result, ResultType.LOWER_BETTER, ResultUnit.MS);
- double[] mbps = Stat.calcRatePerSecArray(
- (double)bufferSize * repeatInEachCall / 1024.0 / 1024.0, result);
- report.addValues("memset_throughput", mbps, ResultType.HIGHER_BETTER, ResultUnit.MBPS);
- Stat.StatResult stat = Stat.getStatWithOutlierRejection(mbps, OUTLIER_THRESHOLD);
- if (stat.mDataCount != result.length) {
- Log.w(TAG, "rejecting " + (result.length - stat.mDataCount) + " outliers");
- }
- WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
- Point size = new Point();
- wm.getDefaultDisplay().getSize(size);
- Log.i(TAG, " x " + size.x + " y " + size.y);
- double pixels = size.x * size.y;
- // now this represents how many times the whole screen can be copied in a sec.
- double screensPerSecAverage = stat.mAverage / pixels * 1024.0 * 1024.0 / 4.0;
- report.addValue("memset_in_fps", screensPerSecAverage, ResultType.HIGHER_BETTER,
- ResultUnit.FPS);
- report.setSummary("memset_throughput_average", stat.mAverage, ResultType.HIGHER_BETTER,
- ResultUnit.MBPS);
- report.submit(getInstrumentation());
- }
-}
diff --git a/tests/dram/src/android/dram/cts/MemoryNative.java b/tests/dram/src/android/dram/cts/MemoryNative.java
deleted file mode 100644
index 7fa4c46..0000000
--- a/tests/dram/src/android/dram/cts/MemoryNative.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2012 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.dram.cts;
-
-public class MemoryNative {
- static {
- System.loadLibrary("ctsdram_jni");
- }
- /**
- * run memcpy for given number of repetition from a source to a destination buffers
- * with each having the size of bufferSize.
- * @param bufferSize
- * @param repetition
- * @return time spent in copying in ms.
- */
- public static native double runMemcpy(int bufferSize, int repetition);
-
- /**
- * run memset for given number of repetition from a source to a destination buffers
- * with each having the size of bufferSize.
- * @param bufferSize
- * @param repetition
- * @param c char to set. Only LSBs will be used to get char value.
- * @return time spent in memset in ms.
- */
- public static native double runMemset(int bufferSize, int repetition, int c);
-}
diff --git a/tests/libcore/ojluni/Android.mk b/tests/libcore/ojluni/Android.mk
index be709be..079638e 100644
--- a/tests/libcore/ojluni/Android.mk
+++ b/tests/libcore/ojluni/Android.mk
@@ -21,6 +21,10 @@
LOCAL_STATIC_JAVA_LIBRARIES := \
core-ojtests-public
+LOCAL_JAVA_LIBRARIES := testng
+
+LOCAL_DX_FLAGS := --core-library
+
# Don't include this package in any target
LOCAL_MODULE_TAGS := tests
diff --git a/tests/mocking/Android.mk b/tests/mocking/Android.mk
new file mode 100644
index 0000000..c3fabef
--- /dev/null
+++ b/tests/mocking/Android.mk
@@ -0,0 +1,38 @@
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := \
+ tests
+LOCAL_JAVA_LIBRARIES := \
+ android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES = \
+ mockito-target \
+ android-support-test \
+ ctstestrunner
+LOCAL_SRC_FILES := \
+ $(call all-java-files-under, \
+ ../../../external/dexmaker/dexmaker-mockito-tests/src/androidTest/java)
+LOCAL_COMPATIBILITY_SUITE := \
+ cts vts general-tests
+LOCAL_PACKAGE_NAME := \
+ CtsMockingTestCases
+LOCAL_SDK_VERSION := \
+ current
+include $(BUILD_CTS_PACKAGE)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/mocking/AndroidManifest.xml b/tests/mocking/AndroidManifest.xml
new file mode 100644
index 0000000..e6520f9
--- /dev/null
+++ b/tests/mocking/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright 2017 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.mocking.cts">
+
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <application android:debuggable="true">
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.mocking.cts"
+ android:label="CTS tests for mockito mocking">
+ <meta-data android:name="listener"
+ android:value="com.android.cts.runner.CtsTestRunListener" />
+ </instrumentation>
+
+</manifest>
+
diff --git a/tests/mocking/AndroidTest.xml b/tests/mocking/AndroidTest.xml
new file mode 100644
index 0000000..2741eba
--- /dev/null
+++ b/tests/mocking/AndroidTest.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright 2017 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<configuration description="Config for Mockito mocking test cases">
+ <option name="config-descriptor:metadata" key="component" value="framework" />
+
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="cleanup-apks" value="true" />
+ <option name="test-file-name" value="CtsMockingTestCases.apk" />
+ </target_preparer>
+
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="android.mocking.cts" />
+ <option name="runtime-hint" value="5s" />
+ </test>
+</configuration>
diff --git a/tests/mocking/inline/Android.mk b/tests/mocking/inline/Android.mk
new file mode 100644
index 0000000..1bc133b
--- /dev/null
+++ b/tests/mocking/inline/Android.mk
@@ -0,0 +1,42 @@
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := \
+ tests
+LOCAL_JAVA_LIBRARIES := \
+ android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES = \
+ mockito-target-inline \
+ android-support-test \
+ ctstestrunner
+LOCAL_MULTILIB := \
+ both
+LOCAL_JNI_SHARED_LIBRARIES := \
+ libdexmakerjvmtiagent \
+ libmultiplejvmtiagentsinterferenceagent
+LOCAL_SRC_FILES := \
+ $(call all-java-files-under, \
+ ../../../../external/dexmaker/dexmaker-mockito-inline-tests/src/androidTest/java)
+LOCAL_COMPATIBILITY_SUITE := \
+ cts vts general-tests
+LOCAL_PACKAGE_NAME := \
+ CtsInlineMockingTestCases
+LOCAL_SDK_VERSION := \
+ current
+include $(BUILD_CTS_PACKAGE)
+
diff --git a/tests/mocking/inline/AndroidManifest.xml b/tests/mocking/inline/AndroidManifest.xml
new file mode 100644
index 0000000..9d97a38
--- /dev/null
+++ b/tests/mocking/inline/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright 2017 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.inline.mocking.cts">
+
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <application android:debuggable="true">
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.inline.mocking.cts"
+ android:label="CTS tests for mockito inline mocking">
+ <meta-data android:name="listener"
+ android:value="com.android.cts.runner.CtsTestRunListener" />
+ </instrumentation>
+
+</manifest>
+
diff --git a/tests/mocking/inline/AndroidTest.xml b/tests/mocking/inline/AndroidTest.xml
new file mode 100644
index 0000000..e642329
--- /dev/null
+++ b/tests/mocking/inline/AndroidTest.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright 2017 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<configuration description="Config for Mockito inline mocking test cases">
+ <option name="config-descriptor:metadata" key="component" value="framework" />
+
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="cleanup-apks" value="true" />
+ <option name="test-file-name" value="CtsInlineMockingTestCases.apk" />
+ </target_preparer>
+
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="android.inline.mocking.cts" />
+ <option name="runtime-hint" value="30s" />
+ </test>
+</configuration>
diff --git a/tests/openglperf2/jni/Android.mk b/tests/openglperf2/jni/Android.mk
index 174375d..b1981ec 100644
--- a/tests/openglperf2/jni/Android.mk
+++ b/tests/openglperf2/jni/Android.mk
@@ -21,7 +21,7 @@
# Needed in order to use fences for synchronization
LOCAL_CFLAGS += -DEGL_EGLEXT_PROTOTYPES -funsigned-char
-LOCAL_CFLAGS += -Wno-unused-parameter
+LOCAL_CFLAGS += -Wall -Werror -Wno-unused-parameter
# Get all cpp files but not hidden files
LOCAL_SRC_FILES := $(call all-subdir-cpp-files)
diff --git a/tests/openglperf2/test/Android.mk b/tests/openglperf2/test/Android.mk
index a9ec558..0103e3f 100644
--- a/tests/openglperf2/test/Android.mk
+++ b/tests/openglperf2/test/Android.mk
@@ -18,6 +18,7 @@
LOCAL_SRC_FILES := $(call all-subdir-cpp-files)
LOCAL_SRC_FILES += ../jni/graphics/Matrix.cpp
+LOCAL_CFLAGS := -Wall -Werror
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../jni/graphics/
LOCAL_STATIC_LIBRARIES := liblog
LOCAL_LDFLAGS:= -g -lpthread
diff --git a/tests/perfetto/AndroidTest.xml b/tests/perfetto/AndroidTest.xml
new file mode 100644
index 0000000..6fada38
--- /dev/null
+++ b/tests/perfetto/AndroidTest.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!-- The Android.mk file that defines these target lives in /external/perfetto/cts -->
+<configuration description="Config for CTS Perfetto test cases">
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="cleanup-apks" value="true" />
+ <option name="test-file-name" value="CtsPerfettoProducerApp.apk" />
+ </target_preparer>
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+ <option name="cleanup" value="true" />
+ <option name="push" value="CtsPerfettoTestCases->/data/local/tmp/CtsPerfettoTestCases" />
+ </target_preparer>
+ <test class="com.android.tradefed.testtype.GTest" >
+ <option name="native-test-device-path" value="/data/local/tmp" />
+ <option name="module-name" value="CtsPerfettoTestCases" />
+ <option name="runtime-hint" value="0m5s" />
+ <!-- test-timeout unit is ms, value = 10 seconds -->
+ <option name="native-test-timeout" value="10000" />
+ </test>
+</configuration>
\ No newline at end of file
diff --git a/tests/sensor/src/android/hardware/cts/helpers/TestSensorEnvironment.java b/tests/sensor/src/android/hardware/cts/helpers/TestSensorEnvironment.java
index 6ef7938..261d327 100644
--- a/tests/sensor/src/android/hardware/cts/helpers/TestSensorEnvironment.java
+++ b/tests/sensor/src/android/hardware/cts/helpers/TestSensorEnvironment.java
@@ -228,7 +228,7 @@
boolean isDeviceSuspendTest) {
this(context, sensor, sensorMightHaveMoreListeners,
samplingPeriodUs, maxReportLatencyUs,
- false /* isDeviceSuspendTest */,
+ isDeviceSuspendTest,
false /* isIntegrationTest */);
}
diff --git a/tests/signature/api-check/Android.mk b/tests/signature/api-check/Android.mk
index 013cc4d..15fa178 100644
--- a/tests/signature/api-check/Android.mk
+++ b/tests/signature/api-check/Android.mk
@@ -30,8 +30,9 @@
LOCAL_STATIC_JAVA_LIBRARIES := \
cts-signature-common \
- repackaged-legacy-test \
+ repackaged.android.test.base \
repackaged.android.test.runner \
+ repackaged.android.test.mock \
include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/tests/signature/api-check/legacy-test-26-api/Android.mk b/tests/signature/api-check/android-test-base-27-api/Android.mk
similarity index 87%
rename from tests/signature/api-check/legacy-test-26-api/Android.mk
rename to tests/signature/api-check/android-test-base-27-api/Android.mk
index 699bd0c..1adcb12c 100644
--- a/tests/signature/api-check/legacy-test-26-api/Android.mk
+++ b/tests/signature/api-check/android-test-base-27-api/Android.mk
@@ -16,9 +16,9 @@
include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := CtsLegacyTest26ApiSignatureTestCases
+LOCAL_PACKAGE_NAME := CtsAndroidTestBase27ApiSignatureTestCases
LOCAL_SIGNATURE_API_FILES := \
- legacy-test-current.api \
+ android-test-base-current.api \
include $(LOCAL_PATH)/../build_signature_apk.mk
diff --git a/tests/signature/api-check/legacy-test-26-api/AndroidManifest.xml b/tests/signature/api-check/android-test-base-27-api/AndroidManifest.xml
similarity index 85%
rename from tests/signature/api-check/legacy-test-26-api/AndroidManifest.xml
rename to tests/signature/api-check/android-test-base-27-api/AndroidManifest.xml
index 636dfd3..c65bfdf 100644
--- a/tests/signature/api-check/legacy-test-26-api/AndroidManifest.xml
+++ b/tests/signature/api-check/android-test-base-27-api/AndroidManifest.xml
@@ -16,16 +16,16 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.signature.cts.api.legacy_test_26">
+ package="android.signature.cts.api.android_test_base_26">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
- <uses-sdk android:minSdkVersion="25" android:targetSdkVersion="26"/>
+ <uses-sdk android:minSdkVersion="25" android:targetSdkVersion="27"/>
<application/>
<instrumentation android:name="repackaged.android.test.InstrumentationTestRunner"
- android:targetPackage="android.signature.cts.api.legacy_test_26"
- android:label="Legacy Test 26 API Signature Test"/>
+ android:targetPackage="android.signature.cts.api.android_test_base_27"
+ android:label="Android Test Base 27 API Signature Test"/>
</manifest>
diff --git a/tests/signature/api-check/legacy-test-26-api/AndroidTest.xml b/tests/signature/api-check/android-test-base-27-api/AndroidTest.xml
similarity index 81%
rename from tests/signature/api-check/legacy-test-26-api/AndroidTest.xml
rename to tests/signature/api-check/android-test-base-27-api/AndroidTest.xml
index ecb3299..c9cbd9a 100644
--- a/tests/signature/api-check/legacy-test-26-api/AndroidTest.xml
+++ b/tests/signature/api-check/android-test-base-27-api/AndroidTest.xml
@@ -13,23 +13,23 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<configuration description="Config for CTS Legacy Test 26 API Signature test cases">
+<configuration description="Config for CTS Android Test Base 27 API Signature test cases">
<option name="config-descriptor:metadata" key="component" value="systems" />
<target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
<option name="run-command" value="mkdir -p /data/local/tmp/signature-test" />
<option name="teardown-command" value="rm -rf /data/local/tmp/signature-test" />
</target_preparer>
<target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
- <option name="push" value="legacy-test-current.api->/data/local/tmp/signature-test/legacy-test-current.api" />
+ <option name="push" value="android-test-base-current.api->/data/local/tmp/signature-test/android-test-base-current.api" />
</target_preparer>
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
- <option name="test-file-name" value="CtsLegacyTest26ApiSignatureTestCases.apk" />
+ <option name="test-file-name" value="CtsAndroidTestBase27ApiSignatureTestCases.apk" />
</target_preparer>
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
- <option name="package" value="android.signature.cts.api.legacy_test_26" />
+ <option name="package" value="android.signature.cts.api.android_test_base_27" />
<option name="runner" value="repackaged.android.test.InstrumentationTestRunner" />
- <option name="instrumentation-arg" key="expected-api-files" value="legacy-test-current.api" />
+ <option name="instrumentation-arg" key="expected-api-files" value="android-test-base-current.api" />
<option name="runtime-hint" value="5s" />
</test>
</configuration>
diff --git a/tests/signature/api/Android.mk b/tests/signature/api/Android.mk
index 71e33ae..f84ca36 100644
--- a/tests/signature/api/Android.mk
+++ b/tests/signature/api/Android.mk
@@ -48,12 +48,12 @@
include $(LOCAL_PATH)/build_xml_api_file.mk
-# current legacy-test api, in XML format.
+# current android-test-base api, in XML format.
# ============================================================
include $(CLEAR_VARS)
-LOCAL_MODULE := cts-legacy-test-current-api
-LOCAL_MODULE_STEM := legacy-test-current.api
-LOCAL_SRC_FILES := frameworks/base/legacy-test/api/legacy-test-current.txt
+LOCAL_MODULE := cts-android-test-base-current-api
+LOCAL_MODULE_STEM := android-test-base-current.api
+LOCAL_SRC_FILES := frameworks/base/test-base/api/android-test-base-current.txt
include $(LOCAL_PATH)/build_xml_api_file.mk
@@ -62,7 +62,7 @@
include $(CLEAR_VARS)
LOCAL_MODULE := cts-android-test-mock-current-api
LOCAL_MODULE_STEM := android-test-mock-current.api
-LOCAL_SRC_FILES := frameworks/base/test-runner/api/android-test-mock-current.txt
+LOCAL_SRC_FILES := frameworks/base/test-mock/api/android-test-mock-current.txt
include $(LOCAL_PATH)/build_xml_api_file.mk
diff --git a/tests/signature/runSignatureTests.sh b/tests/signature/runSignatureTests.sh
index 623973d..e23d4fa 100755
--- a/tests/signature/runSignatureTests.sh
+++ b/tests/signature/runSignatureTests.sh
@@ -15,7 +15,7 @@
CtsSystemCurrentApiSignatureTestCases
CtsAndroidTestMockCurrentApiSignatureTestCases
CtsAndroidTestRunnerCurrentApiSignatureTestCases
-CtsLegacyTest26ApiSignatureTestCases
+CtsAndroidTestBase27ApiSignatureTestCases
CtsApacheHttpLegacyCurrentApiSignatureTestCases
"
else
diff --git a/tests/simplecpu/jni/Android.mk b/tests/simplecpu/jni/Android.mk
index c5f072e..73a6fcf 100644
--- a/tests/simplecpu/jni/Android.mk
+++ b/tests/simplecpu/jni/Android.mk
@@ -26,6 +26,6 @@
LOCAL_SDK_VERSION := 14
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/app.usage/src/android/app/usage/cts/NetworkUsageStatsTest.java b/tests/tests/app.usage/src/android/app/usage/cts/NetworkUsageStatsTest.java
index b475cea..636a6b8 100644
--- a/tests/tests/app.usage/src/android/app/usage/cts/NetworkUsageStatsTest.java
+++ b/tests/tests/app.usage/src/android/app/usage/cts/NetworkUsageStatsTest.java
@@ -62,20 +62,36 @@
private static final int NETWORK_TAG = 0xf00d;
private static final long THRESHOLD_BYTES = 2 * 1024 * 1024; // 2 MB
- private interface NetworkInterfaceToTest {
- int getNetworkType();
- int getTransportType();
- boolean getMetered();
- void setMetered(boolean metered);
- String getSystemFeature();
- String getErrorMessage();
+ private abstract class NetworkInterfaceToTest {
+ private boolean mMetered;
+ private boolean mIsDefault;
+
+ abstract int getNetworkType();
+ abstract int getTransportType();
+
+ public boolean getMetered() {
+ return mMetered;
+ }
+
+ public void setMetered(boolean metered) {
+ this.mMetered = metered;
+ }
+
+ public boolean getIsDefault() {
+ return mIsDefault;
+ }
+
+ public void setIsDefault(boolean isDefault) {
+ mIsDefault = isDefault;
+ }
+
+ abstract String getSystemFeature();
+ abstract String getErrorMessage();
}
- private static final NetworkInterfaceToTest[] sNetworkInterfacesToTest =
+ private final NetworkInterfaceToTest[] mNetworkInterfacesToTest =
new NetworkInterfaceToTest[] {
new NetworkInterfaceToTest() {
- private boolean metered = false;
-
@Override
public int getNetworkType() {
return ConnectivityManager.TYPE_WIFI;
@@ -87,16 +103,6 @@
}
@Override
- public boolean getMetered() {
- return metered;
- }
-
- @Override
- public void setMetered(boolean metered) {
- this.metered = metered;
- }
-
- @Override
public String getSystemFeature() {
return PackageManager.FEATURE_WIFI;
}
@@ -107,7 +113,6 @@
}
},
new NetworkInterfaceToTest() {
- private boolean metered = false;
@Override
public int getNetworkType() {
return ConnectivityManager.TYPE_MOBILE;
@@ -119,15 +124,6 @@
}
@Override
- public boolean getMetered() {
- return metered;
- }
-
- @Override
- public void setMetered(boolean metered) {
- this.metered = metered;
- }
- @Override
public String getSystemFeature() {
return PackageManager.FEATURE_TELEPHONY;
}
@@ -266,18 +262,21 @@
private URL mUrl;
public boolean success;
public boolean metered;
+ public boolean isDefault;
NetworkCallback(long tolerance, URL url) {
mTolerance = tolerance;
mUrl = url;
success = false;
metered = false;
+ isDefault = false;
}
@Override
public void onAvailable(Network network) {
try {
mStartTime = System.currentTimeMillis() - mTolerance;
+ isDefault = network.equals(mCm.getActiveNetwork());
exerciseRemoteHost(network, mUrl);
mEndTime = System.currentTimeMillis() + mTolerance;
success = true;
@@ -296,13 +295,13 @@
private boolean shouldTestThisNetworkType(int networkTypeIndex, final long tolerance)
throws Exception {
boolean hasFeature = mPm.hasSystemFeature(
- sNetworkInterfacesToTest[networkTypeIndex].getSystemFeature());
+ mNetworkInterfacesToTest[networkTypeIndex].getSystemFeature());
if (!hasFeature) {
return false;
}
NetworkCallback callback = new NetworkCallback(tolerance, new URL(CHECK_CONNECTIVITY_URL));
mCm.requestNetwork(new NetworkRequest.Builder()
- .addTransportType(sNetworkInterfacesToTest[networkTypeIndex].getTransportType())
+ .addTransportType(mNetworkInterfacesToTest[networkTypeIndex].getTransportType())
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
.build(), callback);
synchronized(this) {
@@ -312,21 +311,22 @@
}
}
if (callback.success) {
- sNetworkInterfacesToTest[networkTypeIndex].setMetered(callback.metered);
+ mNetworkInterfacesToTest[networkTypeIndex].setMetered(callback.metered);
+ mNetworkInterfacesToTest[networkTypeIndex].setIsDefault(callback.isDefault);
return true;
}
// This will always fail at this point as we know 'hasFeature' is true.
- assertFalse (sNetworkInterfacesToTest[networkTypeIndex].getSystemFeature() +
+ assertFalse (mNetworkInterfacesToTest[networkTypeIndex].getSystemFeature() +
" is a reported system feature, " +
"however no corresponding connected network interface was found or the attempt " +
"to connect has timed out (timeout = " + TIMEOUT_MILLIS + "ms)." +
- sNetworkInterfacesToTest[networkTypeIndex].getErrorMessage(), hasFeature);
+ mNetworkInterfacesToTest[networkTypeIndex].getErrorMessage(), hasFeature);
return false;
}
private String getSubscriberId(int networkIndex) {
- int networkType = sNetworkInterfacesToTest[networkIndex].getNetworkType();
+ int networkType = mNetworkInterfacesToTest[networkIndex].getNetworkType();
if (ConnectivityManager.TYPE_MOBILE == networkType) {
TelephonyManager tm = (TelephonyManager) getInstrumentation().getContext()
.getSystemService(Context.TELEPHONY_SERVICE);
@@ -336,7 +336,7 @@
}
public void testDeviceSummary() throws Exception {
- for (int i = 0; i < sNetworkInterfacesToTest.length; ++i) {
+ for (int i = 0; i < mNetworkInterfacesToTest.length; ++i) {
if (!shouldTestThisNetworkType(i, MINUTE/2)) {
continue;
}
@@ -344,7 +344,7 @@
NetworkStats.Bucket bucket = null;
try {
bucket = mNsm.querySummaryForDevice(
- sNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
+ mNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
mStartTime, mEndTime);
} catch (RemoteException | SecurityException e) {
fail("testDeviceSummary fails with exception: " + e.toString());
@@ -354,10 +354,11 @@
assertEquals(bucket.getState(), NetworkStats.Bucket.STATE_ALL);
assertEquals(bucket.getUid(), NetworkStats.Bucket.UID_ALL);
assertEquals(bucket.getMetered(), NetworkStats.Bucket.METERED_ALL);
+ assertEquals(bucket.getDefaultNetwork(), NetworkStats.Bucket.DEFAULT_NETWORK_ALL);
setAppOpsMode(AppOpsManager.OPSTR_GET_USAGE_STATS, "deny");
try {
bucket = mNsm.querySummaryForDevice(
- sNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
+ mNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
mStartTime, mEndTime);
fail("negative testDeviceSummary fails: no exception thrown.");
} catch (RemoteException e) {
@@ -369,7 +370,7 @@
}
public void testUserSummary() throws Exception {
- for (int i = 0; i < sNetworkInterfacesToTest.length; ++i) {
+ for (int i = 0; i < mNetworkInterfacesToTest.length; ++i) {
if (!shouldTestThisNetworkType(i, MINUTE/2)) {
continue;
}
@@ -377,7 +378,7 @@
NetworkStats.Bucket bucket = null;
try {
bucket = mNsm.querySummaryForUser(
- sNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
+ mNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
mStartTime, mEndTime);
} catch (RemoteException | SecurityException e) {
fail("testUserSummary fails with exception: " + e.toString());
@@ -387,10 +388,11 @@
assertEquals(bucket.getState(), NetworkStats.Bucket.STATE_ALL);
assertEquals(bucket.getUid(), NetworkStats.Bucket.UID_ALL);
assertEquals(bucket.getMetered(), NetworkStats.Bucket.METERED_ALL);
+ assertEquals(bucket.getDefaultNetwork(), NetworkStats.Bucket.DEFAULT_NETWORK_ALL);
setAppOpsMode(AppOpsManager.OPSTR_GET_USAGE_STATS, "deny");
try {
bucket = mNsm.querySummaryForUser(
- sNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
+ mNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
mStartTime, mEndTime);
fail("negative testUserSummary fails: no exception thrown.");
} catch (RemoteException e) {
@@ -402,7 +404,7 @@
}
public void testAppSummary() throws Exception {
- for (int i = 0; i < sNetworkInterfacesToTest.length; ++i) {
+ for (int i = 0; i < mNetworkInterfacesToTest.length; ++i) {
if (!shouldTestThisNetworkType(i, MINUTE/2)) {
continue;
}
@@ -410,7 +412,7 @@
NetworkStats result = null;
try {
result = mNsm.querySummary(
- sNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
+ mNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
mStartTime, mEndTime);
assertTrue(result != null);
NetworkStats.Bucket bucket = new NetworkStats.Bucket();
@@ -419,8 +421,12 @@
long totalTxBytes = 0;
long totalRxBytes = 0;
boolean hasCorrectMetering = false;
- int expectedMetering = sNetworkInterfacesToTest[i].getMetered() ?
+ boolean hasCorrectIsDefault = false;
+ int expectedMetering = mNetworkInterfacesToTest[i].getMetered() ?
NetworkStats.Bucket.METERED_YES : NetworkStats.Bucket.METERED_NO;
+ int expectedIsDefault = mNetworkInterfacesToTest[i].getIsDefault() ?
+ NetworkStats.Bucket.DEFAULT_NETWORK_YES :
+ NetworkStats.Bucket.DEFAULT_NETWORK_NO;
while (result.hasNextBucket()) {
assertTrue(result.getNextBucket(bucket));
assertTimestamps(bucket);
@@ -430,11 +436,14 @@
totalRxPackets += bucket.getRxPackets();
totalTxBytes += bucket.getTxBytes();
totalRxBytes += bucket.getRxBytes();
+ hasCorrectIsDefault |= bucket.getDefaultNetwork() == expectedIsDefault;
}
}
assertFalse(result.getNextBucket(bucket));
assertTrue("Incorrect metering for NetworkType: " +
- sNetworkInterfacesToTest[i].getNetworkType(), hasCorrectMetering);
+ mNetworkInterfacesToTest[i].getNetworkType(), hasCorrectMetering);
+ assertTrue("Incorrect isDefault for NetworkType: " +
+ mNetworkInterfacesToTest[i].getNetworkType(), hasCorrectIsDefault);
assertTrue("No Rx bytes usage for uid " + Process.myUid(), totalRxBytes > 0);
assertTrue("No Rx packets usage for uid " + Process.myUid(), totalRxPackets > 0);
assertTrue("No Tx bytes usage for uid " + Process.myUid(), totalTxBytes > 0);
@@ -449,7 +458,7 @@
setAppOpsMode(AppOpsManager.OPSTR_GET_USAGE_STATS, "deny");
try {
result = mNsm.querySummary(
- sNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
+ mNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
mStartTime, mEndTime);
fail("negative testAppSummary fails: no exception thrown.");
} catch (RemoteException e) {
@@ -461,7 +470,7 @@
}
public void testAppDetails() throws Exception {
- for (int i = 0; i < sNetworkInterfacesToTest.length; ++i) {
+ for (int i = 0; i < mNetworkInterfacesToTest.length; ++i) {
// Relatively large tolerance to accommodate for history bucket size.
if (!shouldTestThisNetworkType(i, MINUTE * 120)) {
continue;
@@ -470,7 +479,7 @@
NetworkStats result = null;
try {
result = mNsm.queryDetails(
- sNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
+ mNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
mStartTime, mEndTime);
assertTrue(result != null);
NetworkStats.Bucket bucket = new NetworkStats.Bucket();
@@ -483,6 +492,8 @@
assertTimestamps(bucket);
assertEquals(bucket.getState(), NetworkStats.Bucket.STATE_ALL);
assertEquals(bucket.getMetered(), NetworkStats.Bucket.METERED_ALL);
+ assertEquals(bucket.getDefaultNetwork(),
+ NetworkStats.Bucket.DEFAULT_NETWORK_ALL);
if (bucket.getUid() == Process.myUid()) {
totalTxPackets += bucket.getTxPackets();
totalRxPackets += bucket.getRxPackets();
@@ -505,7 +516,7 @@
setAppOpsMode(AppOpsManager.OPSTR_GET_USAGE_STATS, "deny");
try {
result = mNsm.queryDetails(
- sNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
+ mNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
mStartTime, mEndTime);
fail("negative testAppDetails fails: no exception thrown.");
} catch (RemoteException e) {
@@ -517,7 +528,7 @@
}
public void testUidDetails() throws Exception {
- for (int i = 0; i < sNetworkInterfacesToTest.length; ++i) {
+ for (int i = 0; i < mNetworkInterfacesToTest.length; ++i) {
// Relatively large tolerance to accommodate for history bucket size.
if (!shouldTestThisNetworkType(i, MINUTE * 120)) {
continue;
@@ -526,7 +537,7 @@
NetworkStats result = null;
try {
result = mNsm.queryDetailsForUid(
- sNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
+ mNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
mStartTime, mEndTime, Process.myUid());
assertTrue(result != null);
NetworkStats.Bucket bucket = new NetworkStats.Bucket();
@@ -539,6 +550,8 @@
assertTimestamps(bucket);
assertEquals(bucket.getState(), NetworkStats.Bucket.STATE_ALL);
assertEquals(bucket.getMetered(), NetworkStats.Bucket.METERED_ALL);
+ assertEquals(bucket.getDefaultNetwork(),
+ NetworkStats.Bucket.DEFAULT_NETWORK_ALL);
assertEquals(bucket.getUid(), Process.myUid());
totalTxPackets += bucket.getTxPackets();
totalRxPackets += bucket.getRxPackets();
@@ -560,7 +573,7 @@
setAppOpsMode(AppOpsManager.OPSTR_GET_USAGE_STATS, "deny");
try {
result = mNsm.queryDetailsForUid(
- sNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
+ mNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
mStartTime, mEndTime, Process.myUid());
fail("negative testUidDetails fails: no exception thrown.");
} catch (RemoteException e) {
@@ -572,7 +585,7 @@
}
public void testTagDetails() throws Exception {
- for (int i = 0; i < sNetworkInterfacesToTest.length; ++i) {
+ for (int i = 0; i < mNetworkInterfacesToTest.length; ++i) {
// Relatively large tolerance to accommodate for history bucket size.
if (!shouldTestThisNetworkType(i, MINUTE * 120)) {
continue;
@@ -581,7 +594,7 @@
NetworkStats result = null;
try {
result = mNsm.queryDetailsForUidTag(
- sNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
+ mNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
mStartTime, mEndTime, Process.myUid(), NETWORK_TAG);
assertTrue(result != null);
NetworkStats.Bucket bucket = new NetworkStats.Bucket();
@@ -594,6 +607,8 @@
assertTimestamps(bucket);
assertEquals(bucket.getState(), NetworkStats.Bucket.STATE_ALL);
assertEquals(bucket.getMetered(), NetworkStats.Bucket.METERED_ALL);
+ assertEquals(bucket.getDefaultNetwork(),
+ NetworkStats.Bucket.DEFAULT_NETWORK_ALL);
assertEquals(bucket.getUid(), Process.myUid());
if (bucket.getTag() == NETWORK_TAG) {
totalTxPackets += bucket.getTxPackets();
@@ -620,7 +635,7 @@
setAppOpsMode(AppOpsManager.OPSTR_GET_USAGE_STATS, "deny");
try {
result = mNsm.queryDetailsForUidTag(
- sNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
+ mNetworkInterfacesToTest[i].getNetworkType(), getSubscriberId(i),
mStartTime, mEndTime, Process.myUid(), NETWORK_TAG);
fail("negative testUidDetails fails: no exception thrown.");
} catch (SecurityException e) {
@@ -630,7 +645,7 @@
}
public void testCallback() throws Exception {
- for (int i = 0; i < sNetworkInterfacesToTest.length; ++i) {
+ for (int i = 0; i < mNetworkInterfacesToTest.length; ++i) {
// Relatively large tolerance to accommodate for history bucket size.
if (!shouldTestThisNetworkType(i, MINUTE/2)) {
continue;
@@ -641,7 +656,7 @@
HandlerThread thread = new HandlerThread("callback-thread");
thread.start();
Handler handler = new Handler(thread.getLooper());
- mNsm.registerUsageCallback(sNetworkInterfacesToTest[i].getNetworkType(),
+ mNsm.registerUsageCallback(mNetworkInterfacesToTest[i].getNetworkType(),
getSubscriberId(i), THRESHOLD_BYTES, usageCallback, handler);
// TODO: Force traffic and check whether the callback is invoked.
diff --git a/tests/tests/bionic/Android.build.copy.libs.mk b/tests/tests/bionic/Android.build.copy.libs.mk
index 5016e33..2944911 100644
--- a/tests/tests/bionic/Android.build.copy.libs.mk
+++ b/tests/tests/bionic/Android.build.copy.libs.mk
@@ -16,109 +16,117 @@
dt_runpath_b_c_x/libtest_dt_runpath_b.so \
dt_runpath_b_c_x/libtest_dt_runpath_c.so \
dt_runpath_b_c_x/libtest_dt_runpath_x.so \
+ inaccessible_libs/libtestshared.so \
+ inaccessible_libs/libtestshared.so \
+ ld_config_test_helper/ld_config_test_helper \
+ ld_config_test_helper_lib3.so \
+ ld_preload_test_helper/ld_preload_test_helper \
+ ld_preload_test_helper_lib1.so \
+ ld_preload_test_helper_lib2.so \
libatest_simple_zip/libatest_simple_zip.so \
- libcfi-test.so \
libcfi-test-bad.so \
+ libcfi-test.so \
+ libdl_preempt_test_1.so \
+ libdl_preempt_test_2.so \
+ libdl_test_df_1_global.so \
+ libdlext_test.so \
libdlext_test_different_soname.so \
libdlext_test_fd/libdlext_test_fd.so \
libdlext_test_norelro.so \
libdlext_test_runpath_zip/libdlext_test_runpath_zip_zipaligned.zip \
- libdlext_test.so \
libdlext_test_zip/libdlext_test_zip.so \
libdlext_test_zip/libdlext_test_zip_zipaligned.zip \
- libdl_preempt_test_1.so \
- libdl_preempt_test_2.so \
- libdl_test_df_1_global.so \
libsysv-hash-table-library.so \
libtest_atexit.so \
+ libtest_check_order_dlsym.so \
libtest_check_order_dlsym_1_left.so \
libtest_check_order_dlsym_2_right.so \
libtest_check_order_dlsym_3_c.so \
libtest_check_order_dlsym_a.so \
libtest_check_order_dlsym_b.so \
libtest_check_order_dlsym_d.so \
- libtest_check_order_dlsym.so \
+ libtest_check_order_reloc_root.so \
libtest_check_order_reloc_root_1.so \
libtest_check_order_reloc_root_2.so \
- libtest_check_order_reloc_root.so \
+ libtest_check_order_reloc_siblings.so \
libtest_check_order_reloc_siblings_1.so \
libtest_check_order_reloc_siblings_2.so \
libtest_check_order_reloc_siblings_3.so \
libtest_check_order_reloc_siblings_a.so \
libtest_check_order_reloc_siblings_b.so \
+ libtest_check_order_reloc_siblings_c.so \
libtest_check_order_reloc_siblings_c_1.so \
libtest_check_order_reloc_siblings_c_2.so \
- libtest_check_order_reloc_siblings_c.so \
libtest_check_order_reloc_siblings_d.so \
libtest_check_order_reloc_siblings_e.so \
libtest_check_order_reloc_siblings_f.so \
- libtest_check_order_reloc_siblings.so \
libtest_check_rtld_next_from_library.so \
- libtest_dlopen_from_ctor_main.so \
+ libtest_dlopen_df_1_global.so \
libtest_dlopen_from_ctor.so \
+ libtest_dlopen_from_ctor_main.so \
libtest_dlopen_weak_undefined_func.so \
libtest_dlsym_df_1_global.so \
+ libtest_dlsym_from_this.so \
libtest_dlsym_from_this_child.so \
libtest_dlsym_from_this_grandchild.so \
- libtest_dlsym_from_this.so \
libtest_dlsym_weak_func.so \
libtest_dt_runpath_d.so \
libtest_empty.so \
libtest_init_fini_order_child.so \
libtest_init_fini_order_grand_child.so \
- libtest_init_fini_order_root2.so \
libtest_init_fini_order_root.so \
+ libtest_init_fini_order_root2.so \
libtest_nodelete_1.so \
libtest_nodelete_2.so \
libtest_nodelete_dt_flags_1.so \
libtest_pthread_atfork.so \
+ libtest_relo_check_dt_needed_order.so \
libtest_relo_check_dt_needed_order_1.so \
libtest_relo_check_dt_needed_order_2.so \
- libtest_relo_check_dt_needed_order.so \
libtest_simple.so \
+ libtest_thread_local_dtor.so \
libtest_two_parents_child.so \
libtest_two_parents_parent1.so \
libtest_two_parents_parent2.so \
libtest_versioned_lib.so \
libtest_versioned_libv1.so \
libtest_versioned_libv2.so \
- libtest_versioned_otherlib_empty.so \
libtest_versioned_otherlib.so \
+ libtest_versioned_otherlib_empty.so \
libtest_versioned_uselibv1.so \
- libtest_versioned_uselibv2_other.so \
libtest_versioned_uselibv2.so \
+ libtest_versioned_uselibv2_other.so \
libtest_versioned_uselibv3_other.so \
+ libtest_with_dependency.so \
+ libtest_with_dependency_loop.so \
libtest_with_dependency_loop_a.so \
libtest_with_dependency_loop_b.so \
libtest_with_dependency_loop_b_tmp.so \
libtest_with_dependency_loop_c.so \
- libtest_with_dependency_loop.so \
- libtest_with_dependency.so \
+ ns2/ld_config_test_helper_lib1.so \
+ ns2/ld_config_test_helper_lib2.so \
prebuilt-elf-files/libtest_invalid-empty_shdr_table.so \
prebuilt-elf-files/libtest_invalid-rw_load_segment.so \
+ prebuilt-elf-files/libtest_invalid-textrels.so \
+ prebuilt-elf-files/libtest_invalid-textrels2.so \
prebuilt-elf-files/libtest_invalid-unaligned_shdr_offset.so \
prebuilt-elf-files/libtest_invalid-zero_shdr_table_content.so \
prebuilt-elf-files/libtest_invalid-zero_shdr_table_offset.so \
prebuilt-elf-files/libtest_invalid-zero_shentsize.so \
prebuilt-elf-files/libtest_invalid-zero_shstrndx.so \
- prebuilt-elf-files/libtest_invalid-textrels.so \
- prebuilt-elf-files/libtest_invalid-textrels2.so \
preinit_getauxval_test_helper/preinit_getauxval_test_helper \
preinit_syscall_test_helper/preinit_syscall_test_helper \
- private_namespace_libs_external/libnstest_private_external.so \
private_namespace_libs/libnstest_dlopened.so \
private_namespace_libs/libnstest_private.so \
- private_namespace_libs/libnstest_root_not_isolated.so \
private_namespace_libs/libnstest_root.so \
+ private_namespace_libs/libnstest_root_not_isolated.so \
+ private_namespace_libs/libtest_missing_symbol_child_private.so \
+ private_namespace_libs/libtest_missing_symbol_root.so \
+ private_namespace_libs_external/libnstest_private_external.so \
public_namespace_libs/libnstest_public.so \
public_namespace_libs/libnstest_public_internal.so \
- ld_preload_test_helper/ld_preload_test_helper \
- ld_preload_test_helper_lib1.so \
- ld_preload_test_helper_lib2.so \
- ld_config_test_helper/ld_config_test_helper \
- ns2/ld_config_test_helper_lib1.so \
- ns2/ld_config_test_helper_lib2.so \
- ld_config_test_helper_lib3.so \
+ public_namespace_libs/libtest_missing_symbol.so \
+ public_namespace_libs/libtest_missing_symbol_child_public.so \
# These libraries are not built for mips.
my_bionic_testlib_files_non_mips := \
diff --git a/tests/tests/bionic/Android.mk b/tests/tests/bionic/Android.mk
index 00448f3..83172e4 100644
--- a/tests/tests/bionic/Android.mk
+++ b/tests/tests/bionic/Android.mk
@@ -7,6 +7,8 @@
LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+LOCAL_CFLAGS := -Wall -Werror
+
LOCAL_LDFLAGS := -Wl,--rpath,\$${ORIGIN}/lib/bionic-loader-test-libs -Wl,--enable-new-dtags -Wl,--export-dynamic
LOCAL_SHARED_LIBRARIES += \
diff --git a/tests/tests/carrierapi/AndroidManifest.xml b/tests/tests/carrierapi/AndroidManifest.xml
index 0338d99..95f55f4 100644
--- a/tests/tests/carrierapi/AndroidManifest.xml
+++ b/tests/tests/carrierapi/AndroidManifest.xml
@@ -17,6 +17,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.carrierapi.cts">
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
diff --git a/tests/tests/carrierapi/src/android/carrierapi/cts/ApnDatabaseTest.java b/tests/tests/carrierapi/src/android/carrierapi/cts/ApnDatabaseTest.java
new file mode 100644
index 0000000..372f22c
--- /dev/null
+++ b/tests/tests/carrierapi/src/android/carrierapi/cts/ApnDatabaseTest.java
@@ -0,0 +1,382 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.carrierapi.cts;
+
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteException;
+import android.net.Uri;
+import android.provider.Telephony.Carriers;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+import android.test.InstrumentationTestCase;
+import android.util.Log;
+
+import com.android.internal.telephony.uicc.IccUtils;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import static junit.framework.TestCase.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+/**
+ * Build, install and run the tests by running the commands below:
+ * make cts -j64
+ * cts-tradefed run cts -m CtsCarrierApiTestCases --test android.carrierapi.cts.ApnDatabaseTest
+ */
+@RunWith(AndroidJUnit4.class)
+public class ApnDatabaseTest {
+ private static final String TAG = "ApnDatabaseTest";
+
+ private ContentResolver mContentResolver;
+
+ private static final String NAME = "carrierName";
+ private static final String APN = "apn";
+ private static final String PROXY = "proxy";
+ private static final String PORT = "port";
+ private static final String MMSC = "mmsc";
+ private static final String MMSPROXY = "mmsproxy";
+ private static final String MMSPORT = "mmsport";
+ private static final String NUMERIC = "numeric";
+ private static final String USER = "user";
+ private static final String PASSWORD = "password";
+ private static final String AUTH_TYPE = "auth_type";
+ private static final String TYPE = "type";
+ private static final String PROTOCOL = "protocol";
+ private static final String ROAMING_PROTOCOL = "roaming_protocol";
+ private static final String CARRIER_ENABLED = "true";
+ private static final String NETWORK_TYPE_BITMASK = "0";
+ private static final String BEARER = "0";
+
+ private static final Map<String, String> APN_MAP = new HashMap<String,String>() {{
+ put(Carriers.NAME, NAME);
+ put(Carriers.APN, APN);
+ put(Carriers.PROXY, PROXY);
+ put(Carriers.PORT, PORT);
+ put(Carriers.MMSC, MMSC);
+ put(Carriers.MMSPROXY, MMSPROXY);
+ put(Carriers.MMSPORT, MMSPORT);
+ put(Carriers.NUMERIC, NUMERIC);
+ put(Carriers.USER, USER);
+ put(Carriers.PASSWORD, PASSWORD);
+ put(Carriers.AUTH_TYPE, AUTH_TYPE);
+ put(Carriers.TYPE, TYPE);
+ put(Carriers.PROTOCOL, PROTOCOL);
+ put(Carriers.ROAMING_PROTOCOL, ROAMING_PROTOCOL);
+ put(Carriers.CARRIER_ENABLED, CARRIER_ENABLED);
+ put(Carriers.NETWORK_TYPE_BITMASK, NETWORK_TYPE_BITMASK);
+ put(Carriers.BEARER, BEARER);
+ }};
+
+ // Faked network type bitmask and its compatible bearer bitmask.
+ private static final int NETWORK_TYPE_BITMASK_NUMBER = 1 << (13 - 1);
+ private static final int RIL_RADIO_TECHNOLOGY_BITMASK_NUMBER = 1 << (14 - 1);
+
+ @Before
+ public void setUp() throws Exception {
+ mContentResolver = InstrumentationRegistry.getContext().getContentResolver();
+ }
+
+ private void failMessage() {
+ fail("This test requires a SIM card with carrier privilege rule on it.\n" +
+ "Visit https://source.android.com/devices/tech/config/uicc.html");
+ }
+
+ /**
+ * Test inserting, querying, updating and deleting values in carriers table.
+ * Verify that the inserted values match the result of the query and are deleted.
+ */
+ @Test
+ public void testValidCase() {
+ Uri uri = Carriers.CONTENT_URI;
+ // CONTENT_URI = Uri.parse("content://telephony/carriers");
+ // Create A set of column_name/value pairs to add to the database.
+ ContentValues contentValues = makeDefaultContentValues();
+
+ try {
+ // Insert the value into database.
+ Log.d(TAG, "testInsertCarriers Inserting contentValues: " + contentValues.toString());
+ Uri newUri = mContentResolver.insert(uri, contentValues);
+ assertNotNull("Failed to insert to table", newUri);
+
+ // Get the values in table.
+ final String selection = Carriers.NUMERIC + "=?";
+ String[] selectionArgs = { NUMERIC };
+ String[] apnProjection = APN_MAP.keySet().toArray(new String[APN_MAP.size()]);
+ Log.d(TAG, "testInsertCarriers query projection: " + Arrays.toString(apnProjection)
+ + "\ntestInsertCarriers selection: " + selection
+ + "\ntestInsertCarriers selectionArgs: " + Arrays.toString(selectionArgs));
+ Cursor cursor = mContentResolver.query(
+ uri, apnProjection, selection, selectionArgs, null);
+
+ // Verify that the inserted value match the results of the query
+ assertNotNull("Failed to query the table", cursor);
+ assertEquals("Unexpected number of APNs returned by cursor",
+ 1, cursor.getCount());
+ cursor.moveToFirst();
+ for (Map.Entry<String, String> entry: APN_MAP.entrySet()) {
+ assertEquals(
+ "Unexpected value returned by cursor",
+ cursor.getString(cursor.getColumnIndex(entry.getKey())), entry.getValue());
+ }
+
+ // update the apn
+ final String newApn = "newapn";
+ Log.d(TAG, "Update the APN field to: " + newApn);
+ contentValues.put(Carriers.APN, newApn);
+ final int updateCount = mContentResolver.update(uri, contentValues, selection,
+ selectionArgs);
+ assertEquals("Unexpected number of rows updated", 1, updateCount);
+
+ // Verify the updated value
+ cursor = mContentResolver.query(uri, apnProjection, selection, selectionArgs, null);
+ assertNotNull("Failed to query the table", cursor);
+ assertEquals("Unexpected number of APNs returned by cursor", 1, cursor.getCount());
+ cursor.moveToFirst();
+ assertEquals("Unexpected value returned by cursor",
+ cursor.getString(cursor.getColumnIndex(Carriers.APN)), newApn);
+
+ // delete test content
+ final String selectionToDelete = Carriers.NUMERIC + "=?";
+ String[] selectionArgsToDelete = { NUMERIC };
+ Log.d(TAG, "testInsertCarriers deleting selection: " + selectionToDelete
+ + "testInsertCarriers selectionArgs: " + Arrays.toString(selectionArgs));
+ int numRowsDeleted = mContentResolver.delete(
+ uri, selectionToDelete, selectionArgsToDelete);
+ assertEquals("Unexpected number of rows deleted",1, numRowsDeleted);
+
+ // verify that deleted values are gone
+ cursor = mContentResolver.query(uri, apnProjection, selection, selectionArgs, null);
+ assertEquals("Unexpected number of rows deleted", 0, cursor.getCount());
+ } catch (SecurityException e) {
+ failMessage();
+ }
+ }
+
+ @Test
+ public void testQueryConflictCase() {
+ String invalidColumn = "random";
+ Uri uri = Carriers.CONTENT_URI;
+ // CONTENT_URI = Uri.parse("content://telephony/carriers");
+ // Create A set of column_name/value pairs to add to the database.
+ ContentValues contentValues = new ContentValues();
+ contentValues.put(Carriers.NAME, NAME);
+ contentValues.put(Carriers.APN, APN);
+ contentValues.put(Carriers.PORT, PORT);
+ contentValues.put(Carriers.PROTOCOL, PROTOCOL);
+ contentValues.put(Carriers.NUMERIC, NUMERIC);
+
+ try {
+ // Insert the value into database.
+ Log.d(TAG, "testInsertCarriers Inserting contentValues: " + contentValues.toString());
+ Uri newUri = mContentResolver.insert(uri, contentValues);
+ assertNotNull("Failed to insert to table", newUri);
+
+ // Try to get the value with invalid selection
+ final String[] testProjection =
+ {
+ Carriers.NAME,
+ Carriers.APN,
+ Carriers.PORT,
+ Carriers.PROTOCOL,
+ Carriers.NUMERIC,
+ };
+ final String selection = invalidColumn + "=?";
+ String[] selectionArgs = { invalidColumn };
+ Log.d(TAG, "testInsertCarriers query projection: " + Arrays.toString(testProjection)
+ + "\ntestInsertCarriers selection: " + selection
+ + "\ntestInsertCarriers selectionArgs: " + Arrays.toString(selectionArgs));
+ Cursor cursor = mContentResolver.query(
+ uri, testProjection, selection, selectionArgs, null);
+ assertNull("Failed to query the table",cursor);
+
+ // delete test content
+ final String selectionToDelete = Carriers.NAME + "=?";
+ String[] selectionArgsToDelete = { NAME };
+ Log.d(TAG, "testInsertCarriers deleting selection: " + selectionToDelete
+ + "testInsertCarriers selectionArgs: " + Arrays.toString(selectionArgs));
+ int numRowsDeleted = mContentResolver.delete(
+ uri, selectionToDelete, selectionArgsToDelete);
+ assertEquals("Unexpected number of rows deleted", 1, numRowsDeleted);
+
+ // verify that deleted values are gone
+ cursor = mContentResolver.query(
+ uri, testProjection, selectionToDelete, selectionArgsToDelete, null);
+ assertEquals("Unexpected number of rows deleted", 0, cursor.getCount());
+ } catch (SecurityException e) {
+ failMessage();
+ }
+ }
+
+ @Test
+ public void testUpdateConflictCase() {
+ Uri uri = Carriers.CONTENT_URI;
+ // CONTENT_URI = Uri.parse("content://telephony/carriers");
+ // Create A set of column_name/value pairs to add to the database.
+ ContentValues contentValues = new ContentValues();
+ contentValues.put(Carriers.NAME, NAME);
+ contentValues.put(Carriers.APN, APN);
+ contentValues.put(Carriers.PORT, PORT);
+ contentValues.put(Carriers.PROTOCOL, PROTOCOL);
+ contentValues.put(Carriers.NUMERIC, NUMERIC);
+
+ try {
+ // Insert the value into database.
+ Log.d(TAG, "testInsertCarriers Inserting contentValues: " + contentValues.toString());
+ Uri newUri = mContentResolver.insert(uri, contentValues);
+ assertNotNull("Failed to insert to table", newUri);
+
+ // Try to get the value with invalid selection
+ final String[] testProjection =
+ {
+ Carriers.NAME,
+ Carriers.APN,
+ Carriers.PORT,
+ Carriers.PROTOCOL,
+ Carriers.NUMERIC,
+ };
+ String selection = Carriers.NAME + "=?";
+ String[] selectionArgs = { NAME };
+ Log.d(TAG, "testInsertCarriers query projection: " + Arrays.toString(testProjection)
+ + "\ntestInsertCarriers selection: " + selection
+ + "\ntestInsertCarriers selectionArgs: " + Arrays.toString(selectionArgs));
+ Cursor cursor = mContentResolver.query(
+ uri, testProjection, selection, selectionArgs, null);
+ assertEquals("Unexpected number of APNs returned by cursor",
+ 1, cursor.getCount());
+
+ // Update the table with invalid column
+ String invalidColumn = "random";
+ contentValues.put(invalidColumn, invalidColumn);
+ try {
+ mContentResolver.update(uri, contentValues, selection, selectionArgs);
+ fail();
+ } catch (SQLiteException e) {
+ // Expected: If there's no such a column, an exception will be thrown and the
+ // Activity Manager will kill this process shortly.
+ }
+
+ // delete test content
+ final String selectionToDelete = Carriers.NAME + "=?";
+ String[] selectionArgsToDelete = { NAME };
+ Log.d(TAG, "testInsertCarriers deleting selection: " + selectionToDelete
+ + "testInsertCarriers selectionArgs: " + Arrays.toString(selectionArgs));
+ int numRowsDeleted = mContentResolver.delete(
+ uri, selectionToDelete, selectionArgsToDelete);
+ assertEquals("Unexpected number of rows deleted", 1, numRowsDeleted);
+
+ // verify that deleted values are gone
+ cursor = mContentResolver.query(
+ uri, testProjection, selectionToDelete, selectionArgsToDelete, null);
+ assertEquals("Unexpected number of rows deleted", 0, cursor.getCount());
+ } catch (SecurityException e) {
+ failMessage();
+ }
+ }
+
+ @Test
+ public void testDeleteConflictCase() {
+ String invalidColumn = "random";
+ Uri uri = Carriers.CONTENT_URI;
+ // CONTENT_URI = Uri.parse("content://telephony/carriers");
+ // Create A set of column_name/value pairs to add to the database.
+ ContentValues contentValues = new ContentValues();
+ contentValues.put(Carriers.NAME, NAME);
+ contentValues.put(Carriers.APN, APN);
+ contentValues.put(Carriers.PORT, PORT);
+ contentValues.put(Carriers.PROTOCOL, PROTOCOL);
+ contentValues.put(Carriers.NUMERIC, NUMERIC);
+
+ try {
+ // Insert the value into database.
+ Log.d(TAG, "testInsertCarriers Inserting contentValues: " + contentValues.toString());
+ Uri newUri = mContentResolver.insert(uri, contentValues);
+ assertNotNull("Failed to insert to table", newUri);
+
+ // Get the values in table.
+ final String[] testProjection =
+ {
+ Carriers.NAME,
+ Carriers.APN,
+ Carriers.PORT,
+ Carriers.PROTOCOL,
+ Carriers.NUMERIC,
+ };
+ String selection = Carriers.NAME + "=?";
+ String[] selectionArgs = { NAME };
+ Log.d(TAG, "testInsertCarriers query projection: " + Arrays.toString(testProjection)
+ + "\ntestInsertCarriers selection: " + selection
+ + "\ntestInsertCarriers selectionArgs: " + Arrays.toString(selectionArgs));
+ Cursor cursor = mContentResolver.query(
+ uri, testProjection, selection, selectionArgs, null);
+ assertEquals("Unexpected number of APNs returned by cursor", 1, cursor.getCount());
+
+ // try to delete with invalid selection
+ String selectionToDelete = invalidColumn + "=?";
+ String[] selectionArgsToDelete = { invalidColumn };
+ Log.d(TAG, "testInsertCarriers deleting selection: " + selectionToDelete
+ + "testInsertCarriers selectionArgs: " + Arrays.toString(selectionArgs));
+
+ try {
+ mContentResolver.delete(uri, selectionToDelete, selectionArgsToDelete);
+ fail();
+ } catch (SQLiteException e) {
+ // Expected: If there's no such a column, an exception will be thrown and the
+ // Activity Manager will kill this process shortly.
+ }
+
+ // verify that deleted value is still there
+ selection = Carriers.NAME + "=?";
+ selectionArgs[0] = NAME;
+ cursor = mContentResolver.query(uri, testProjection, selection, selectionArgs, null);
+ assertEquals("Unexpected number of APNs returned by cursor", 1, cursor.getCount());
+
+ // delete test content
+ selectionToDelete = Carriers.NAME + "=?";
+ selectionArgsToDelete[0] = NAME;
+ Log.d(TAG, "testInsertCarriers deleting selection: " + selectionToDelete
+ + "testInsertCarriers selectionArgs: " + Arrays.toString(selectionArgs));
+ int numRowsDeleted = mContentResolver.delete(
+ uri, selectionToDelete, selectionArgsToDelete);
+ assertEquals("Unexpected number of rows deleted", 1, numRowsDeleted);
+
+ // verify that deleted values are gone
+ cursor = mContentResolver.query(uri, testProjection, selection, selectionArgs, null);
+ assertEquals("Unexpected number of rows deleted", 0, cursor.getCount());
+ } catch (SecurityException e) {
+ failMessage();
+ }
+ }
+
+ private ContentValues makeDefaultContentValues() {
+ ContentValues contentValues = new ContentValues();
+ for (Map.Entry<String, String> entry: APN_MAP.entrySet()) {
+ contentValues.put(entry.getKey(), entry.getValue());
+ }
+ return contentValues;
+ }
+}
\ No newline at end of file
diff --git a/tests/tests/carrierapi/src/android/carrierapi/cts/NetworkScanApiTest.java b/tests/tests/carrierapi/src/android/carrierapi/cts/NetworkScanApiTest.java
new file mode 100644
index 0000000..63f8347
--- /dev/null
+++ b/tests/tests/carrierapi/src/android/carrierapi/cts/NetworkScanApiTest.java
@@ -0,0 +1,258 @@
+/*
+ * Copyright (C) 2018 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.carrierapi.cts;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Message;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+import android.telephony.CellInfo;
+import android.telephony.CellInfoGsm;
+import android.telephony.CellInfoLte;
+import android.telephony.CellInfoWcdma;
+import android.telephony.NetworkScan;
+import android.telephony.NetworkScanRequest;
+import android.telephony.RadioAccessSpecifier;
+import android.telephony.AccessNetworkConstants;
+import android.telephony.TelephonyManager;
+import android.telephony.TelephonyScanManager;
+import android.util.Log;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * Build, install and run the tests by running the commands below:
+ * make cts -j64
+ * cts-tradefed run cts -m CtsCarrierApiTestCases --test android.carrierapi.cts.NetworkScanApiTest
+ */
+@RunWith(AndroidJUnit4.class)
+public class NetworkScanApiTest {
+ private TelephonyManager mTelephonyManager;
+ private static final String TAG = "NetworkScanApiTest";
+ private int mNetworkScanStatus;
+ private static final int EVENT_NETWORK_SCAN_START = 100;
+ private static final int EVENT_NETWORK_SCAN_RESULTS = 200;
+ private static final int EVENT_NETWORK_SCAN_ERROR = 300;
+ private static final int EVENT_NETWORK_SCAN_COMPLETED = 400;
+ private List<CellInfo> mScanResults = null;
+ private NetworkScanHandlerThread mTestHandlerThread;
+ private Handler mHandler;
+ private NetworkScanRequest mNetworkScanRequest;
+ private NetworkScanCallbackImpl mNetworkScanCallback;
+ private static final int MAX_INIT_WAIT_MS = 60000; // 60 seconds
+ private Object mLock = new Object();
+ private boolean mReady;
+ private int mErrorCode;
+
+ @Before
+ public void setUp() throws Exception {
+ mTelephonyManager = (TelephonyManager)
+ InstrumentationRegistry.getContext().getSystemService(Context.TELEPHONY_SERVICE);
+ mTestHandlerThread = new NetworkScanHandlerThread(TAG);
+ mTestHandlerThread.start();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ mTestHandlerThread.quit();
+ }
+
+ private void waitUntilReady() {
+ synchronized (mLock) {
+ try {
+ mLock.wait(MAX_INIT_WAIT_MS);
+ } catch (InterruptedException ie) {
+ }
+
+ if (!mReady) {
+ fail("NetworkScanApiTest failed to initialize");
+ }
+ }
+ }
+
+ private void setReady(boolean ready) {
+ synchronized (mLock) {
+ mReady = ready;
+ mLock.notifyAll();
+ }
+ }
+
+ private class NetworkScanHandlerThread extends HandlerThread {
+
+ public NetworkScanHandlerThread(String name) {
+ super(name);
+ }
+
+ @Override
+ public void onLooperPrepared() {
+ /* create a custom handler for the Handler Thread */
+ mHandler = new Handler(mTestHandlerThread.getLooper()) {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case EVENT_NETWORK_SCAN_START:
+ Log.d(TAG, "request network scan");
+ mTelephonyManager.requestNetworkScan(
+ mNetworkScanRequest, mNetworkScanCallback);
+ break;
+ default:
+ Log.d(TAG, "Unknown Event " + msg.what);
+ }
+ }
+ };
+ }
+ }
+
+ private class NetworkScanCallbackImpl extends TelephonyScanManager.NetworkScanCallback {
+ @Override
+ public void onResults(List<CellInfo> results) {
+ Log.d(TAG, "onResults: " + results.toString());
+ mNetworkScanStatus = EVENT_NETWORK_SCAN_RESULTS;
+ mScanResults = results;
+ }
+
+ @Override
+ public void onComplete() {
+ Log.d(TAG, "onComplete");
+ mNetworkScanStatus = EVENT_NETWORK_SCAN_COMPLETED;
+ setReady(true);
+ }
+
+ @Override
+ public void onError(int error) {
+ Log.d(TAG, "onError: " + String.valueOf(error));
+ mNetworkScanStatus = EVENT_NETWORK_SCAN_ERROR;
+ mErrorCode = error;
+ setReady(true);
+ }
+ }
+
+ private RadioAccessSpecifier getRadioAccessSpecifier(CellInfo cellInfo) {
+ RadioAccessSpecifier ras;
+ if (cellInfo instanceof CellInfoLte) {
+ int ranLte = AccessNetworkConstants.AccessNetworkType.EUTRAN;
+ int[] lteChannels = {((CellInfoLte) cellInfo).getCellIdentity().getEarfcn()};
+ ras = new RadioAccessSpecifier(ranLte, null /* bands */, lteChannels);
+ Log.d(TAG, "CellInfoLte channel: " + lteChannels[0]);
+ } else if (cellInfo instanceof CellInfoWcdma) {
+ int ranLte = AccessNetworkConstants.AccessNetworkType.UTRAN;
+ int[] wcdmaChannels = {((CellInfoWcdma) cellInfo).getCellIdentity().getUarfcn()};
+ ras = new RadioAccessSpecifier(ranLte, null /* bands */, wcdmaChannels);
+ Log.d(TAG, "CellInfoWcdma channel: " + wcdmaChannels[0]);
+ } else if (cellInfo instanceof CellInfoGsm) {
+ int ranGsm = AccessNetworkConstants.AccessNetworkType.GERAN;
+ int[] gsmChannels = {((CellInfoGsm) cellInfo).getCellIdentity().getArfcn()};
+ ras = new RadioAccessSpecifier(ranGsm, null /* bands */, gsmChannels);
+ Log.d(TAG, "CellInfoGsm channel: " + gsmChannels[0]);
+ } else {
+ ras = null;
+ }
+ return ras;
+ }
+
+ /**
+ * Tests that the device properly requests a network scan.
+ */
+ @Test
+ public void testRequestNetworkScan() throws InterruptedException {
+ if (!mTelephonyManager.hasCarrierPrivileges()) {
+ fail("This test requires a SIM card with carrier privilege rule on it.");
+ }
+
+ // Make sure that there should be at least one entry.
+ List<CellInfo> allCellInfo = mTelephonyManager.getAllCellInfo();
+ Log.d(TAG, "allCellInfo: " + allCellInfo.toString());
+ if (allCellInfo == null) {
+ fail("TelephonyManager.getAllCellInfo() returned NULL!");
+ }
+ if (allCellInfo.size() == 0) {
+ fail("TelephonyManager.getAllCellInfo() returned zero-length list!");
+ }
+
+ // Construct a NetworkScanRequest
+ List<RadioAccessSpecifier> radioAccessSpecifier = new ArrayList<>();
+ for (int i = 0; i < allCellInfo.size(); i++) {
+ RadioAccessSpecifier ras = getRadioAccessSpecifier(allCellInfo.get(i));
+ if (ras != null) {
+ radioAccessSpecifier.add(ras);
+ }
+ }
+ if (radioAccessSpecifier.size() == 0) {
+ RadioAccessSpecifier gsm = new RadioAccessSpecifier(
+ AccessNetworkConstants.AccessNetworkType.GERAN,
+ null /* bands */,
+ null /* channels */);
+ RadioAccessSpecifier lte = new RadioAccessSpecifier(
+ AccessNetworkConstants.AccessNetworkType.EUTRAN,
+ null /* bands */,
+ null /* channels */);
+ RadioAccessSpecifier wcdma = new RadioAccessSpecifier(
+ AccessNetworkConstants.AccessNetworkType.UTRAN,
+ null /* bands */,
+ null /* channels */);
+ radioAccessSpecifier.add(gsm);
+ radioAccessSpecifier.add(lte);
+ radioAccessSpecifier.add(wcdma);
+ }
+ RadioAccessSpecifier[] radioAccessSpecifierArray =
+ new RadioAccessSpecifier[radioAccessSpecifier.size()];
+ mNetworkScanRequest = new NetworkScanRequest(
+ NetworkScanRequest.SCAN_TYPE_ONE_SHOT /* scan type */,
+ radioAccessSpecifier.toArray(radioAccessSpecifierArray),
+ 5 /* search periodicity */,
+ 60 /* max search time */,
+ true /*enable incremental results*/,
+ 5 /* incremental results periodicity */,
+ null /* List of PLMN ids (MCC-MNC) */);
+
+ mNetworkScanCallback = new NetworkScanCallbackImpl();
+ Message startNetworkScan = mHandler.obtainMessage(EVENT_NETWORK_SCAN_START);
+ setReady(false);
+ startNetworkScan.sendToTarget();
+ waitUntilReady();
+
+ Log.d(TAG, "mNetworkScanStatus: " + mNetworkScanStatus);
+ assertTrue("The final scan status is not ScanCompleted or ScanError with an error "
+ + "code ERROR_MODEM_UNAVAILABLE or ERROR_UNSUPPORTED",
+ isScanStatusValid());
+ }
+
+ private boolean isScanStatusValid() {
+ // TODO(b/72162885): test the size of ScanResults is not zero after the blocking bug fixed.
+ if ((mNetworkScanStatus == EVENT_NETWORK_SCAN_COMPLETED) && (mScanResults != null)) {
+ // Scan complete.
+ return true;
+ }
+ if ((mNetworkScanStatus == EVENT_NETWORK_SCAN_ERROR)
+ && ((mErrorCode == NetworkScan.ERROR_MODEM_UNAVAILABLE)
+ || (mErrorCode == NetworkScan.ERROR_UNSUPPORTED))) {
+ // Scan error but the error type is allowed.
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/tests/tests/content/jni/Android.mk b/tests/tests/content/jni/Android.mk
index 4737b35..3b14b6f 100644
--- a/tests/tests/content/jni/Android.mk
+++ b/tests/tests/content/jni/Android.mk
@@ -25,6 +25,8 @@
LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
+LOCAL_CFLAGS := -Wall -Werror -Wno-pointer-arith -Wno-unused-parameter
+
LOCAL_SHARED_LIBRARIES := libnativehelper_compat_libc++ liblog
LOCAL_CXX_STL := libc++_static
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/content/src/android/content/cts/IntentTest.java b/tests/tests/content/src/android/content/cts/IntentTest.java
index dbbbe15..af53e56 100644
--- a/tests/tests/content/src/android/content/cts/IntentTest.java
+++ b/tests/tests/content/src/android/content/cts/IntentTest.java
@@ -1148,6 +1148,11 @@
.putExtra("int", 1000).putExtra("long", (long) 1000)
.putExtra("boolean", true).putExtra("float", 10.4f)
.setPackage("com.myapp"));
+ checkIntentUri(
+ "intent://example.org/db?123#Intent;scheme=z39.50r;end",
+ null,
+ new Intent().setAction(Intent.ACTION_VIEW)
+ .setData(Uri.parse("z39.50r://example.org/db?123")));
}
private boolean compareIntents(Intent expected, Intent actual) {
diff --git a/tests/tests/debug/libdebugtest/Android.mk b/tests/tests/debug/libdebugtest/Android.mk
index 65c9756..80eb256 100644
--- a/tests/tests/debug/libdebugtest/Android.mk
+++ b/tests/tests/debug/libdebugtest/Android.mk
@@ -22,6 +22,8 @@
LOCAL_MODULE := libdebugtest
+LOCAL_CFLAGS := -Wall -Werror
+
# Don't include this package in any configuration by default.
LOCAL_MODULE_TAGS := optional
diff --git a/tests/tests/debug/libdebugtest/android_debug_cts.cpp b/tests/tests/debug/libdebugtest/android_debug_cts.cpp
index 2c7c967..fb87a28 100644
--- a/tests/tests/debug/libdebugtest/android_debug_cts.cpp
+++ b/tests/tests/debug/libdebugtest/android_debug_cts.cpp
@@ -17,6 +17,7 @@
#include <jni.h>
#include <android/log.h>
+#include <errno.h>
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/uio.h>
diff --git a/tests/tests/drm/jni/Android.mk b/tests/tests/drm/jni/Android.mk
index fe9a041..113bef8 100644
--- a/tests/tests/drm/jni/Android.mk
+++ b/tests/tests/drm/jni/Android.mk
@@ -30,6 +30,6 @@
LOCAL_SHARED_LIBRARIES := liblog libdl
LOCAL_SDK_VERSION := 23
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/graphics/jni/android_graphics_cts_SyncTest.cpp b/tests/tests/graphics/jni/android_graphics_cts_SyncTest.cpp
index aeea02c..1379e48 100644
--- a/tests/tests/graphics/jni/android_graphics_cts_SyncTest.cpp
+++ b/tests/tests/graphics/jni/android_graphics_cts_SyncTest.cpp
@@ -17,6 +17,7 @@
#define LOG_TAG "SyncTest"
+#include <errno.h>
#include <poll.h>
#include <unistd.h>
diff --git a/tests/tests/jni/Android.mk b/tests/tests/jni/Android.mk
index 1f332b9..f0ebe63 100644
--- a/tests/tests/jni/Android.mk
+++ b/tests/tests/jni/Android.mk
@@ -33,6 +33,7 @@
LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner android-support-test
LOCAL_JNI_SHARED_LIBRARIES := \
+ libjni_test_dlclose \
libjninamespacea1 \
libjninamespacea2 \
libjninamespaceb \
@@ -43,6 +44,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
+LOCAL_NDK_STL_VARIANT := c++_shared
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/jni/libjnicommon/Android.mk b/tests/tests/jni/libjnicommon/Android.mk
index 0f8044e..14406f3 100644
--- a/tests/tests/jni/libjnicommon/Android.mk
+++ b/tests/tests/jni/libjnicommon/Android.mk
@@ -27,11 +27,13 @@
LOCAL_SRC_FILES := common.cpp
+LOCAL_CFLAGS := -Wall -Werror
+
LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
LOCAL_SHARED_LIBRARIES := libdl liblog libnativehelper_compat_libc++
LOCAL_SDK_VERSION := 23
-LOCAL_NDK_STL_VARIANT := c++_static
+LOCAL_NDK_STL_VARIANT := c++_shared
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/jni/libjninamespacea1/Android.mk b/tests/tests/jni/libjninamespacea1/Android.mk
index 8016c50..419db82 100644
--- a/tests/tests/jni/libjninamespacea1/Android.mk
+++ b/tests/tests/jni/libjninamespacea1/Android.mk
@@ -27,12 +27,14 @@
LOCAL_SRC_FILES := namespacea1.cpp
+LOCAL_CFLAGS := -Wall -Werror
+
LOCAL_C_INCLUDES := $(JNI_H_INCLUDE) $(LOCAL_PATH)/../libjnicommon/
LOCAL_LDLIBS += -llog
LOCAL_SHARED_LIBRARIES := libdl liblog libnativehelper_compat_libc++ libjnicommon
LOCAL_SDK_VERSION := 23
-LOCAL_NDK_STL_VARIANT := c++_static
+LOCAL_NDK_STL_VARIANT := c++_shared
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/jni/libjninamespacea1/namespacea1.cpp b/tests/tests/jni/libjninamespacea1/namespacea1.cpp
index decb4f1..8a79c3c 100644
--- a/tests/tests/jni/libjninamespacea1/namespacea1.cpp
+++ b/tests/tests/jni/libjninamespacea1/namespacea1.cpp
@@ -18,7 +18,7 @@
#include <android/log.h>
#include <jni.h>
-#include <JNIHelp.h>
+#include <nativehelper/JNIHelp.h>
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,"namespacea1",__VA_ARGS__)
diff --git a/tests/tests/jni/libjninamespacea2/Android.mk b/tests/tests/jni/libjninamespacea2/Android.mk
index 9b515c9..2781a81 100644
--- a/tests/tests/jni/libjninamespacea2/Android.mk
+++ b/tests/tests/jni/libjninamespacea2/Android.mk
@@ -27,12 +27,14 @@
LOCAL_SRC_FILES := namespacea2.cpp
+LOCAL_CFLAGS := -Wall -Werror
+
LOCAL_C_INCLUDES := $(JNI_H_INCLUDE) $(LOCAL_PATH)/../libjnicommon/
LOCAL_LDLIBS += -llog
LOCAL_SHARED_LIBRARIES := libdl liblog libnativehelper_compat_libc++ libjnicommon
LOCAL_SDK_VERSION := 23
-LOCAL_NDK_STL_VARIANT := c++_static
+LOCAL_NDK_STL_VARIANT := c++_shared
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/jni/libjninamespacea2/namespacea2.cpp b/tests/tests/jni/libjninamespacea2/namespacea2.cpp
index 809266e..49f055e 100644
--- a/tests/tests/jni/libjninamespacea2/namespacea2.cpp
+++ b/tests/tests/jni/libjninamespacea2/namespacea2.cpp
@@ -18,7 +18,7 @@
#include <android/log.h>
#include <jni.h>
-#include <JNIHelp.h>
+#include <nativehelper/JNIHelp.h>
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,"namespacea2",__VA_ARGS__)
diff --git a/tests/tests/jni/libjninamespaceb/Android.mk b/tests/tests/jni/libjninamespaceb/Android.mk
index 4d3e158..e91ba59 100644
--- a/tests/tests/jni/libjninamespaceb/Android.mk
+++ b/tests/tests/jni/libjninamespaceb/Android.mk
@@ -27,12 +27,14 @@
LOCAL_SRC_FILES := namespaceb.cpp
+LOCAL_CFLAGS := -Wall -Werror
+
LOCAL_C_INCLUDES := $(JNI_H_INCLUDE) $(LOCAL_PATH)/../libjnicommon/
LOCAL_LDLIBS += -llog
LOCAL_SHARED_LIBRARIES := libdl liblog libnativehelper_compat_libc++ libjnicommon
LOCAL_SDK_VERSION := 23
-LOCAL_NDK_STL_VARIANT := c++_static
+LOCAL_NDK_STL_VARIANT := c++_shared
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/jni/libjninamespaceb/namespaceb.cpp b/tests/tests/jni/libjninamespaceb/namespaceb.cpp
index b3bedcb..4c48627 100644
--- a/tests/tests/jni/libjninamespaceb/namespaceb.cpp
+++ b/tests/tests/jni/libjninamespaceb/namespaceb.cpp
@@ -18,7 +18,7 @@
#include <android/log.h>
#include <jni.h>
-#include <JNIHelp.h>
+#include <nativehelper/JNIHelp.h>
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,"namespaceb",__VA_ARGS__)
diff --git a/tests/tests/jni/libjnitest/Android.mk b/tests/tests/jni/libjnitest/Android.mk
index 0703722..b94f07b 100644
--- a/tests/tests/jni/libjnitest/Android.mk
+++ b/tests/tests/jni/libjnitest/Android.mk
@@ -26,6 +26,7 @@
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := \
+ android_jni_cts_BasicLoaderTest.cpp \
android_jni_cts_InstanceNonce.c \
android_jni_cts_JniCTest.c \
android_jni_cts_JniCppTest.cpp \
@@ -42,6 +43,21 @@
LOCAL_SDK_VERSION := 23
LOCAL_NDK_STL_VARIANT := c++_static
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
+LOCAL_CFLAGS += -Wno-format -Wno-gnu-designator
+
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libjni_test_dlclose
+
+LOCAL_SRC_FILES := taxicab_number.cpp
+
+LOCAL_CFLAGS += -Wall -Werror
+
+LOCAL_SDK_VERSION := 23
+
+LOCAL_NDK_STL_VARIANT := c++_static
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/jni/libjnitest/android_jni_cts_BasicLoaderTest.cpp b/tests/tests/jni/libjnitest/android_jni_cts_BasicLoaderTest.cpp
new file mode 100644
index 0000000..704cd4f
--- /dev/null
+++ b/tests/tests/jni/libjnitest/android_jni_cts_BasicLoaderTest.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Tests accessibility of platform native libraries
+ */
+
+#include <dlfcn.h>
+#include <jni.h>
+#include <libgen.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include <string>
+
+#include "nativehelper/JNIHelp.h"
+#include "nativehelper/ScopedLocalRef.h"
+#include "nativehelper/ScopedUtfChars.h"
+
+static constexpr const char* kTestLibName = "libjni_test_dlclose.so";
+
+static bool run_test(std::string* error_msg) {
+ void* handle = dlopen(kTestLibName, RTLD_NOW);
+ if (handle == nullptr) {
+ *error_msg = dlerror();
+ return false;
+ }
+
+ void* taxicab_number = dlsym(handle, "dlopen_testlib_taxicab_number");
+ if (taxicab_number == nullptr) {
+ *error_msg = dlerror();
+ return false;
+ }
+
+ dlclose(handle);
+
+ uintptr_t page_start = reinterpret_cast<uintptr_t>(taxicab_number) & ~(PAGE_SIZE - 1);
+ if (mprotect(reinterpret_cast<void*>(page_start), PAGE_SIZE, PROT_NONE) == 0) {
+ *error_msg = std::string("The library \"") +
+ kTestLibName +
+ "\" has not been unloaded on dlclose()";
+ return false;
+ }
+
+ if (errno != ENOMEM) {
+ *error_msg = std::string("Unexpected error on mprotect: ") + strerror(errno);
+ return false;
+ }
+
+ return true;
+}
+
+extern "C" JNIEXPORT jstring JNICALL Java_android_jni_cts_BasicLoaderTestHelper_nativeRunTests(
+ JNIEnv* env) {
+ std::string error_str;
+
+ if (!run_test(&error_str)) {
+ return env->NewStringUTF(error_str.c_str());
+ }
+
+ return nullptr;
+}
+
diff --git a/tests/tests/jni/libjnitest/android_jni_cts_InstanceNonce.c b/tests/tests/jni/libjnitest/android_jni_cts_InstanceNonce.c
index 3fda82a..cb44b42 100644
--- a/tests/tests/jni/libjnitest/android_jni_cts_InstanceNonce.c
+++ b/tests/tests/jni/libjnitest/android_jni_cts_InstanceNonce.c
@@ -20,7 +20,7 @@
*/
#include <jni.h>
-#include <JNIHelp.h>
+#include <nativehelper/JNIHelp.h>
#include <stdbool.h>
#include <string.h>
diff --git a/tests/tests/jni/libjnitest/android_jni_cts_JniCTest.c b/tests/tests/jni/libjnitest/android_jni_cts_JniCTest.c
index 23278dc..cca5383 100644
--- a/tests/tests/jni/libjnitest/android_jni_cts_JniCTest.c
+++ b/tests/tests/jni/libjnitest/android_jni_cts_JniCTest.c
@@ -19,7 +19,7 @@
*/
#include <jni.h>
-#include <JNIHelp.h>
+#include <nativehelper/JNIHelp.h>
/*
diff --git a/tests/tests/jni/libjnitest/android_jni_cts_JniCppTest.cpp b/tests/tests/jni/libjnitest/android_jni_cts_JniCppTest.cpp
index 38829a0..b0937f4 100644
--- a/tests/tests/jni/libjnitest/android_jni_cts_JniCppTest.cpp
+++ b/tests/tests/jni/libjnitest/android_jni_cts_JniCppTest.cpp
@@ -19,7 +19,7 @@
*/
#include <jni.h>
-#include <JNIHelp.h>
+#include <nativehelper/JNIHelp.h>
/*
diff --git a/tests/tests/jni/libjnitest/android_jni_cts_JniStaticTest.cpp b/tests/tests/jni/libjnitest/android_jni_cts_JniStaticTest.cpp
index 5e8bea0..aa5651f 100644
--- a/tests/tests/jni/libjnitest/android_jni_cts_JniStaticTest.cpp
+++ b/tests/tests/jni/libjnitest/android_jni_cts_JniStaticTest.cpp
@@ -19,7 +19,7 @@
*/
#include <jni.h>
-#include <JNIHelp.h>
+#include <nativehelper/JNIHelp.h>
extern "C" JNIEXPORT jint JNICALL Java_android_jni_cts_ClassLoaderHelper_nativeGetHashCode(
JNIEnv* env,
diff --git a/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp b/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp
index c983ee2..77ac34b 100644
--- a/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp
+++ b/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp
@@ -22,7 +22,6 @@
#include <dlfcn.h>
#include <fcntl.h>
#include <jni.h>
-#include <JNIHelp.h>
#include <libgen.h>
#include <stdlib.h>
#include <sys/types.h>
@@ -34,8 +33,9 @@
#include <unordered_set>
#include <vector>
-#include "ScopedLocalRef.h"
-#include "ScopedUtfChars.h"
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/ScopedLocalRef.h>
+#include <nativehelper/ScopedUtfChars.h>
#if defined(__LP64__)
static const std::string kSystemLibraryPath = "/system/lib64";
@@ -77,9 +77,7 @@
static bool not_accessible(const std::string& library, const std::string& err) {
return err.find("dlopen failed: library \"" + library + "\"") == 0 &&
- (err.find("is not accessible for the namespace \"classloader-namespace\"") != std::string::npos ||
- err.find("is not accessible for the namespace \"sphal\"") != std::string::npos ||
- err.find("is not accessible for the namespace \"(default)\"") != std::string::npos);
+ err.find("is not accessible for the namespace \"classloader-namespace\"") != std::string::npos;
}
static bool not_found(const std::string& library, const std::string& err) {
diff --git a/tests/tests/jni/libjnitest/android_jni_cts_StaticNonce.c b/tests/tests/jni/libjnitest/android_jni_cts_StaticNonce.c
index ada2bf8..4e330e5 100644
--- a/tests/tests/jni/libjnitest/android_jni_cts_StaticNonce.c
+++ b/tests/tests/jni/libjnitest/android_jni_cts_StaticNonce.c
@@ -20,7 +20,7 @@
*/
#include <jni.h>
-#include <JNIHelp.h>
+#include <nativehelper/JNIHelp.h>
#include <stdbool.h>
#include <string.h>
diff --git a/tests/tests/jni/libjnitest/macroized_tests.c b/tests/tests/jni/libjnitest/macroized_tests.c
index 130b378..795c682 100644
--- a/tests/tests/jni/libjnitest/macroized_tests.c
+++ b/tests/tests/jni/libjnitest/macroized_tests.c
@@ -29,6 +29,7 @@
#endif
#include "helper.h"
+#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
@@ -182,13 +183,13 @@
// TODO: Missing functions:
// AllocObject
-static char *help_CallBooleanMethod(JNIEnv *env, callType ct, ...) {
+static char *help_CallBooleanMethod(JNIEnv *env, int ct, ...) {
va_list args;
va_start(args, ct);
char *msg;
jobject o = getStandardInstance(env);
- jmethodID method = findAppropriateMethod(env, &msg, ct,
+ jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
"returnBoolean", "()Z");
if (method == NULL) {
@@ -287,13 +288,13 @@
return help_CallBooleanMethod(env, STATIC_VA);
}
-static char *help_CallByteMethod(JNIEnv *env, callType ct, ...) {
+static char *help_CallByteMethod(JNIEnv *env, int ct, ...) {
va_list args;
va_start(args, ct);
char *msg;
jobject o = getStandardInstance(env);
- jmethodID method = findAppropriateMethod(env, &msg, ct,
+ jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
"returnByte", "()B");
if (method == NULL) {
@@ -392,13 +393,13 @@
return help_CallByteMethod(env, STATIC_VA);
}
-static char *help_CallShortMethod(JNIEnv *env, callType ct, ...) {
+static char *help_CallShortMethod(JNIEnv *env, int ct, ...) {
va_list args;
va_start(args, ct);
char *msg;
jobject o = getStandardInstance(env);
- jmethodID method = findAppropriateMethod(env, &msg, ct,
+ jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
"returnShort", "()S");
if (method == NULL) {
@@ -497,13 +498,13 @@
return help_CallShortMethod(env, STATIC_VA);
}
-static char *help_CallCharMethod(JNIEnv *env, callType ct, ...) {
+static char *help_CallCharMethod(JNIEnv *env, int ct, ...) {
va_list args;
va_start(args, ct);
char *msg;
jobject o = getStandardInstance(env);
- jmethodID method = findAppropriateMethod(env, &msg, ct,
+ jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
"returnChar", "()C");
if (method == NULL) {
@@ -602,13 +603,13 @@
return help_CallCharMethod(env, STATIC_VA);
}
-static char *help_CallIntMethod(JNIEnv *env, callType ct, ...) {
+static char *help_CallIntMethod(JNIEnv *env, int ct, ...) {
va_list args;
va_start(args, ct);
char *msg;
jobject o = getStandardInstance(env);
- jmethodID method = findAppropriateMethod(env, &msg, ct,
+ jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
"returnInt", "()I");
if (method == NULL) {
@@ -707,13 +708,13 @@
return help_CallIntMethod(env, STATIC_VA);
}
-static char *help_CallLongMethod(JNIEnv *env, callType ct, ...) {
+static char *help_CallLongMethod(JNIEnv *env, int ct, ...) {
va_list args;
va_start(args, ct);
char *msg;
jobject o = getStandardInstance(env);
- jmethodID method = findAppropriateMethod(env, &msg, ct,
+ jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
"returnLong", "()J");
if (method == NULL) {
@@ -773,7 +774,7 @@
va_end(args);
- return FAIL_IF_UNEQUAL("%lld", -80080080087LL, result);
+ return FAIL_IF_UNEQUAL("%" PRId64, -80080080087LL, result);
}
TEST_DECLARATION(CallLongMethod) {
@@ -812,13 +813,13 @@
return help_CallLongMethod(env, STATIC_VA);
}
-static char *help_CallFloatMethod(JNIEnv *env, callType ct, ...) {
+static char *help_CallFloatMethod(JNIEnv *env, int ct, ...) {
va_list args;
va_start(args, ct);
char *msg;
jobject o = getStandardInstance(env);
- jmethodID method = findAppropriateMethod(env, &msg, ct,
+ jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
"returnFloat", "()F");
if (method == NULL) {
@@ -917,13 +918,13 @@
return help_CallFloatMethod(env, STATIC_VA);
}
-static char *help_CallDoubleMethod(JNIEnv *env, callType ct, ...) {
+static char *help_CallDoubleMethod(JNIEnv *env, int ct, ...) {
va_list args;
va_start(args, ct);
char *msg;
jobject o = getStandardInstance(env);
- jmethodID method = findAppropriateMethod(env, &msg, ct,
+ jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
"returnDouble", "()D");
if (method == NULL) {
@@ -1022,13 +1023,13 @@
return help_CallDoubleMethod(env, STATIC_VA);
}
-static char *help_CallVoidMethod(JNIEnv *env, callType ct, ...) {
+static char *help_CallVoidMethod(JNIEnv *env, int ct, ...) {
va_list args;
va_start(args, ct);
char *msg;
jobject o = getStandardInstance(env);
- jmethodID method = findAppropriateMethod(env, &msg, ct,
+ jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
"nop", "()V");
if (method == NULL) {
@@ -1127,13 +1128,13 @@
return help_CallVoidMethod(env, STATIC_VA);
}
-static char *help_CallObjectMethod(JNIEnv *env, callType ct, ...) {
+static char *help_CallObjectMethod(JNIEnv *env, int ct, ...) {
va_list args;
va_start(args, ct);
char *msg;
jobject o = getStandardInstance(env);
- jmethodID method = findAppropriateMethod(env, &msg, ct,
+ jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
"returnString", "()Ljava/lang/String;");
if (method == NULL) {
@@ -1250,13 +1251,13 @@
return help_CallObjectMethod(env, STATIC_VA);
}
-static char *help_TakeOneOfEach(JNIEnv *env, callType ct, ...) {
+static char *help_TakeOneOfEach(JNIEnv *env, int ct, ...) {
va_list args;
va_start(args, ct);
char *msg;
jobject o = getStandardInstance(env);
- jmethodID method = findAppropriateMethod(env, &msg, ct,
+ jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
"takeOneOfEach", "(DFJICSBZLjava/lang/String;)Z");
if (method == NULL) {
@@ -1265,8 +1266,8 @@
}
jvalue jargs[] = {
- {d: 0.0}, {f: 1.0f}, {j: 2LL}, {i: 3}, {c: 4}, {s: 5}, {b: 6},
- {z: true}, {l: biscuits}
+ {.d = 0.0}, {.f = 1.0f}, {.j = 2LL}, {.i = 3}, {.c = 4}, {.s = 5},
+ {.b = 6}, {.z = true}, {.l = biscuits}
};
jboolean result;
@@ -1372,13 +1373,13 @@
(jboolean) true, biscuits);
}
-static char *help_TakeCoolHandLuke(JNIEnv *env, callType ct, ...) {
+static char *help_TakeCoolHandLuke(JNIEnv *env, int ct, ...) {
va_list args;
va_start(args, ct);
char *msg;
jobject o = getStandardInstance(env);
- jmethodID method = findAppropriateMethod(env, &msg, ct,
+ jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
"takeCoolHandLuke",
"(IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII)Z");
@@ -1388,17 +1389,17 @@
}
jvalue jargs[] = {
- {i: 1}, {i: 2}, {i: 3}, {i: 4},
- {i: 5}, {i: 6}, {i: 7}, {i: 8}, {i: 9},
- {i: 10}, {i: 11}, {i: 12}, {i: 13}, {i: 14},
- {i: 15}, {i: 16}, {i: 17}, {i: 18}, {i: 19},
- {i: 20}, {i: 21}, {i: 22}, {i: 23}, {i: 24},
- {i: 25}, {i: 26}, {i: 27}, {i: 28}, {i: 29},
- {i: 30}, {i: 31}, {i: 32}, {i: 33}, {i: 34},
- {i: 35}, {i: 36}, {i: 37}, {i: 38}, {i: 39},
- {i: 40}, {i: 41}, {i: 42}, {i: 43}, {i: 44},
- {i: 45}, {i: 46}, {i: 47}, {i: 48}, {i: 49},
- {i: 50}
+ {.i = 1}, {.i = 2}, {.i = 3}, {.i = 4},
+ {.i = 5}, {.i = 6}, {.i = 7}, {.i = 8}, {.i = 9},
+ {.i = 10}, {.i = 11}, {.i = 12}, {.i = 13}, {.i = 14},
+ {.i = 15}, {.i = 16}, {.i = 17}, {.i = 18}, {.i = 19},
+ {.i = 20}, {.i = 21}, {.i = 22}, {.i = 23}, {.i = 24},
+ {.i = 25}, {.i = 26}, {.i = 27}, {.i = 28}, {.i = 29},
+ {.i = 30}, {.i = 31}, {.i = 32}, {.i = 33}, {.i = 34},
+ {.i = 35}, {.i = 36}, {.i = 37}, {.i = 38}, {.i = 39},
+ {.i = 40}, {.i = 41}, {.i = 42}, {.i = 43}, {.i = 44},
+ {.i = 45}, {.i = 46}, {.i = 47}, {.i = 48}, {.i = 49},
+ {.i = 50}
};
jboolean result;
diff --git a/tests/tests/jni/libjnitest/taxicab_number.cpp b/tests/tests/jni/libjnitest/taxicab_number.cpp
new file mode 100644
index 0000000..3226955
--- /dev/null
+++ b/tests/tests/jni/libjnitest/taxicab_number.cpp
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+
+uint32_t dlopen_testlib_taxicab_number = 1729;
+
+extern "C" bool dlopen_testlib_simple_func() {
+ return true;
+}
diff --git a/tests/tests/jni/src/android/jni/cts/BasicLoaderTestHelper.java b/tests/tests/jni/src/android/jni/cts/BasicLoaderTestHelper.java
new file mode 100644
index 0000000..389dc16
--- /dev/null
+++ b/tests/tests/jni/src/android/jni/cts/BasicLoaderTestHelper.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.jni.cts;
+
+class BasicLoaderTestHelper {
+ static {
+ System.loadLibrary("jnitest");
+ }
+
+ static native String nativeRunTests();
+}
diff --git a/tests/tests/jni/src/android/jni/cts/JniStaticTest.java b/tests/tests/jni/src/android/jni/cts/JniStaticTest.java
index d2e90c6..b122457 100644
--- a/tests/tests/jni/src/android/jni/cts/JniStaticTest.java
+++ b/tests/tests/jni/src/android/jni/cts/JniStaticTest.java
@@ -49,6 +49,13 @@
}
}
+ public void test_loader_basic() throws Exception {
+ String error = BasicLoaderTestHelper.nativeRunTests();
+ if (error != null) {
+ fail(error);
+ }
+ }
+
/**
* Test that accessing classes true JNI works as expected. b/19382130
*/
diff --git a/tests/tests/jni/src/android/jni/cts/LinkerNamespacesHelper.java b/tests/tests/jni/src/android/jni/cts/LinkerNamespacesHelper.java
index f63e76a..72acf64 100644
--- a/tests/tests/jni/src/android/jni/cts/LinkerNamespacesHelper.java
+++ b/tests/tests/jni/src/android/jni/cts/LinkerNamespacesHelper.java
@@ -16,22 +16,29 @@
package android.jni.cts;
-import android.content.Context;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.support.test.InstrumentationRegistry;
import dalvik.system.PathClassLoader;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.File;
-import java.io.FileReader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
class LinkerNamespacesHelper {
+ private final static String PUBLIC_CONFIG_DIR = "/system/etc/";
+ private final static String SYSTEM_CONFIG_FILE = PUBLIC_CONFIG_DIR + "public.libraries.txt";
+ private final static String OEM_CONFIG_FILE_PATTERN = "public\\.libraries-([A-Za-z0-9-_]+)\\.txt";
private final static String VENDOR_CONFIG_FILE = "/vendor/etc/public.libraries.txt";
private final static String[] PUBLIC_SYSTEM_LIBRARIES = {
"libaaudio.so",
@@ -59,12 +66,29 @@
"libvulkan.so",
"libz.so"
};
+ // The grey-list.
+ private final static String[] PRIVATE_SYSTEM_LIBRARIES = {
+ "libandroid_runtime.so",
+ "libbinder.so",
+ "libcrypto.so",
+ "libcutils.so",
+ "libexpat.so",
+ "libgui.so",
+ "libmedia.so",
+ "libnativehelper.so",
+ "libskia.so",
+ "libssl.so",
+ "libstagefright.so",
+ "libsqlite.so",
+ "libui.so",
+ "libutils.so",
+ "libvorbisidec.so",
+ };
private final static String WEBVIEW_PLAT_SUPPORT_LIB = "libwebviewchromium_plat_support.so";
- public static String runAccessibilityTest() throws IOException {
- List<String> vendorLibs = new ArrayList<>();
- File file = new File(VENDOR_CONFIG_FILE);
+ private static List<String> readPublicLibrariesFile(File file) throws IOException {
+ List<String> libs = new ArrayList<>();
if (file.exists()) {
try (BufferedReader br = new BufferedReader(new FileReader(file))) {
String line;
@@ -73,12 +97,16 @@
if (line.isEmpty() || line.startsWith("#")) {
continue;
}
- vendorLibs.add(line);
+ libs.add(line);
}
}
}
+ return libs;
+ }
+ public static String runAccessibilityTest() throws IOException {
List<String> systemLibs = new ArrayList<>();
+
Collections.addAll(systemLibs, PUBLIC_SYSTEM_LIBRARIES);
if (InstrumentationRegistry.getContext().getPackageManager().
@@ -86,6 +114,63 @@
systemLibs.add(WEBVIEW_PLAT_SUPPORT_LIB);
}
+ // Check if public.libraries.txt contains libs other than the
+ // public system libs (NDK libs).
+ for (String lib : readPublicLibrariesFile(new File(SYSTEM_CONFIG_FILE))) {
+ if (!systemLibs.contains(lib)) {
+ return "Library \"" + lib + "\" in " + SYSTEM_CONFIG_FILE
+ + " is not an allowed system lib.";
+ }
+ }
+
+ Pattern oemConfigFilePattern = Pattern.compile(OEM_CONFIG_FILE_PATTERN);
+ File[] oemConfigFiles = new File(PUBLIC_CONFIG_DIR).listFiles(
+ new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return oemConfigFilePattern.matcher(name).matches();
+ }
+ });
+
+ List<String> oemLibs = new ArrayList<>();
+ for (File configFile : oemConfigFiles) {
+ String fileName = configFile.toPath().getFileName().toString();
+ Matcher matcher = oemConfigFilePattern.matcher(fileName);
+ if (matcher.matches()) {
+ String oemName = matcher.group(1);
+ // a lib in /system/etc/public.libraries-acme.txt should be
+ // libFoo.acme.so
+ Pattern libNamePattern = Pattern.compile("lib.+\\." + oemName + "\\.so");
+ List<String> libs = readPublicLibrariesFile(configFile);
+ for (String lib : libs) {
+ if (libNamePattern.matcher(lib).matches()) {
+ oemLibs.add(lib);
+ } else {
+ return "OEM library \"" + lib + "\" in " + configFile.toString()
+ + " must have company name " + oemName + " as suffix.";
+ }
+ }
+ }
+ }
+ // OEM libs that passed above tests are available to Android app via JNI
+ systemLibs.addAll(oemLibs);
+
+ List<String> vendorLibs = readPublicLibrariesFile(new File(VENDOR_CONFIG_FILE));
+
+ // Make sure that the libs in grey-list are not exposed to apps. In fact, it
+ // would be better for us to run this check against all system libraries which
+ // are not NDK libs, but grey-list libs are enough for now since they have been
+ // the most popular violators.
+ Set<String> greyListLibs = new HashSet<>();
+ Collections.addAll(greyListLibs, PRIVATE_SYSTEM_LIBRARIES);
+ // Note: check for systemLibs isn't needed since we already checked
+ // /system/etc/public.libraries.txt against NDK and
+ // /system/etc/public.libraries-<company>.txt against lib<name>.<company>.so.
+ for (String lib : vendorLibs) {
+ if (greyListLibs.contains(lib)) {
+ return "Internal library \"" + lib + "\" must not be available to apps.";
+ }
+ }
+
return runAccessibilityTestImpl(systemLibs.toArray(new String[systemLibs.size()]),
vendorLibs.toArray(new String[vendorLibs.size()]));
}
diff --git a/tests/tests/jni_vendor/libvendorjnitest/Android.mk b/tests/tests/jni_vendor/libvendorjnitest/Android.mk
index ca59ee8..c9e9205 100644
--- a/tests/tests/jni_vendor/libvendorjnitest/Android.mk
+++ b/tests/tests/jni_vendor/libvendorjnitest/Android.mk
@@ -36,4 +36,6 @@
LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_VENDOR_MODULE := true
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/signature/api-check/legacy-test-26-api/Android.mk b/tests/tests/jvmti/Android.mk
similarity index 76%
copy from tests/signature/api-check/legacy-test-26-api/Android.mk
copy to tests/tests/jvmti/Android.mk
index 699bd0c..8facc9f 100644
--- a/tests/signature/api-check/legacy-test-26-api/Android.mk
+++ b/tests/tests/jvmti/Android.mk
@@ -14,11 +14,5 @@
LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_PACKAGE_NAME := CtsLegacyTest26ApiSignatureTestCases
-
-LOCAL_SIGNATURE_API_FILES := \
- legacy-test-current.api \
-
-include $(LOCAL_PATH)/../build_signature_apk.mk
+# Include the associated library's makefile.
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/jvmti/attaching/Android.mk b/tests/tests/jvmti/attaching/Android.mk
new file mode 100644
index 0000000..56169d4
--- /dev/null
+++ b/tests/tests/jvmti/attaching/Android.mk
@@ -0,0 +1,39 @@
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_PACKAGE_NAME := CtsJvmtiAttachingTestCases
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner android-support-test
+
+LOCAL_MULTILIB := both
+LOCAL_JNI_SHARED_LIBRARIES := libjvmtiattachingtestagent1 \
+ libjvmtiattachingtestagent2 \
+ libjvmtiattachingtestagent3 \
+ libjvmtiattachingtestagent4 \
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_CTS_PACKAGE)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/jvmti/attaching/AndroidManifest.xml b/tests/tests/jvmti/attaching/AndroidManifest.xml
new file mode 100644
index 0000000..16acb14
--- /dev/null
+++ b/tests/tests/jvmti/attaching/AndroidManifest.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2017 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.jmvti.attaching.cts">
+
+ <application android:debuggable="true">
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.jmvti.attaching.cts"
+ android:label="CTS tests for attaching jvmti agents from inside the app">
+ <meta-data android:name="listener"
+ android:value="com.android.cts.runner.CtsTestRunListener" />
+ </instrumentation>
+</manifest>
+
diff --git a/tests/tests/jvmti/attaching/AndroidTest.xml b/tests/tests/jvmti/attaching/AndroidTest.xml
new file mode 100644
index 0000000..1b4ed05
--- /dev/null
+++ b/tests/tests/jvmti/attaching/AndroidTest.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ ~ Copyright (C) 2017 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<configuration description="Config for CTS jvmti attaching test cases">
+ <option name="config-descriptor:metadata" key="component" value="art" />
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="cleanup-apks" value="true" />
+ <option name="test-file-name" value="CtsJvmtiAttachingTestCases.apk" />
+ </target_preparer>
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="android.jmvti.attaching.cts" />
+ <option name="runtime-hint" value="18s" />
+ </test>
+</configuration>
diff --git a/tests/tests/jvmti/attaching/jni/Android.mk b/tests/tests/jvmti/attaching/jni/Android.mk
new file mode 100644
index 0000000..b0d8376
--- /dev/null
+++ b/tests/tests/jvmti/attaching/jni/Android.mk
@@ -0,0 +1,44 @@
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# This is the shared library included by the JNI test app.
+#
+
+LOCAL_PATH:= $(call my-dir)
+
+define jvmti-attaching-test-agent
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libjvmtiattachingtestagent$1
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := agent.c
+
+LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
+
+LOCAL_SDK_VERSION := current
+
+LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
+
+LOCAL_CFLAGS += -DAGENT_NR=$1
+
+include $(BUILD_SHARED_LIBRARY)
+endef
+
+$(eval $(call jvmti-attaching-test-agent,1))
+$(eval $(call jvmti-attaching-test-agent,2))
+$(eval $(call jvmti-attaching-test-agent,3))
+$(eval $(call jvmti-attaching-test-agent,4))
diff --git a/tests/tests/jvmti/attaching/jni/agent.c b/tests/tests/jvmti/attaching/jni/agent.c
new file mode 100644
index 0000000..3ebca31
--- /dev/null
+++ b/tests/tests/jvmti/attaching/jni/agent.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <jni.h>
+
+#include <string.h>
+#include <stdbool.h>
+
+static bool sIsAttached = false;
+
+jint
+Agent_OnAttach(JavaVM* vm, char* options, void* reserved) {
+ if (options != NULL && options[0] == 'a') {
+ sIsAttached = true;
+ return JNI_OK;
+ } else {
+ return JNI_ERR;
+ }
+}
+
+#ifndef AGENT_NR
+#error "Missing AGENT_NR"
+#endif
+#define CONCAT(A,B) A ## B
+#define EVAL(A,B) CONCAT(A,B)
+#define NAME(BASE) EVAL(BASE,AGENT_NR)
+
+JNIEXPORT jboolean JNICALL NAME(Java_android_jvmti_attaching_cts_AttachingTest_isAttached) (
+ JNIEnv* env, jclass klass) {
+ if (sIsAttached) {
+ return JNI_TRUE;
+ } else {
+ return JNI_FALSE;
+ }
+}
diff --git a/tests/tests/jvmti/attaching/src/android.jvmti.attaching.cts/AttachingTest.java b/tests/tests/jvmti/attaching/src/android.jvmti.attaching.cts/AttachingTest.java
new file mode 100644
index 0000000..994681f
--- /dev/null
+++ b/tests/tests/jvmti/attaching/src/android.jvmti.attaching.cts/AttachingTest.java
@@ -0,0 +1,223 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.jvmti.attaching.cts;
+
+import static org.junit.Assert.assertTrue;
+
+import android.os.Debug;
+import android.support.test.runner.AndroidJUnit4;
+
+import dalvik.system.BaseDexClassLoader;
+
+import org.junit.AfterClass;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.junit.runner.RunWith;
+import org.junit.runners.MethodSorters;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.concurrent.Callable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+@RunWith(Parameterized.class)
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class AttachingTest {
+ // Some static stored state, for final cleanup.
+ private static Set<File> createdFiles = new HashSet<>();
+
+ // Parameters for a test instance.
+
+ // The string to pass as the agent parameter.
+ private String agentString;
+ // The classloader to pass.
+ private ClassLoader classLoader;
+ // The attach-success function for the last test.
+ private Callable<Boolean> isAttachedFn;
+
+ public AttachingTest(String agentString, ClassLoader classLoader,
+ Callable<Boolean> isAttachedFn) {
+ this.agentString = agentString;
+ this.classLoader = classLoader;
+ this.isAttachedFn = isAttachedFn;
+ }
+
+ @Parameters
+ public static Collection<Object[]> data() {
+ Collection<Object[]> params = new ArrayList<>();
+
+ try {
+ // Test that an absolute path works w/o given classloader.
+ File agentExtracted = copyAgentToFile("jvmtiattachingtestagent1");
+ Callable<Boolean> success = AttachingTest::isAttached1;
+ params.add(new Object[] {
+ agentExtracted.getAbsolutePath(),
+ null,
+ success,
+ });
+ createdFiles.add(agentExtracted);
+ } catch (Exception exc) {
+ throw new RuntimeException(exc);
+ }
+
+ try {
+ // Test that an absolute path works w/ given classloader.
+ File agentExtracted = copyAgentToFile("jvmtiattachingtestagent2");
+ Callable<Boolean> success = AttachingTest::isAttached2;
+ params.add(new Object[] {
+ agentExtracted.getAbsolutePath(),
+ AttachingTest.class.getClassLoader(),
+ success,
+ });
+ createdFiles.add(agentExtracted);
+ } catch (Exception exc) {
+ throw new RuntimeException(exc);
+ }
+
+ {
+ // Test that a relative path works w/ given classloader.
+ Callable<Boolean> success = AttachingTest::isAttached3;
+ params.add(new Object[] {
+ "libjvmtiattachingtestagent3.so",
+ AttachingTest.class.getClassLoader(),
+ success,
+ });
+ }
+
+ try {
+ // The name part of an extracted lib should not work.
+ File agentExtracted = copyAgentToFile("jvmtiattachingtestagent4");
+ String name = agentExtracted.getName();
+ Callable<Boolean> success = () -> {
+ try {
+ isAttached4();
+ // Any result is a failure.
+ return false;
+ } catch (UnsatisfiedLinkError e) {
+ return true;
+ }
+ };
+ params.add(new Object[] {
+ name,
+ AttachingTest.class.getClassLoader(),
+ success,
+ });
+ createdFiles.add(agentExtracted);
+ } catch (Exception exc) {
+ throw new RuntimeException(exc);
+ }
+
+ return params;
+ }
+
+ private static File copyAgentToFile(String lib) throws Exception {
+ ClassLoader cl = AttachingTest.class.getClassLoader();
+ assertTrue(cl instanceof BaseDexClassLoader);
+
+ File copiedAgent = File.createTempFile("agent", ".so");
+ try (InputStream is = new FileInputStream(
+ ((BaseDexClassLoader) cl).findLibrary(lib))) {
+ try (OutputStream os = new FileOutputStream(copiedAgent)) {
+ byte[] buffer = new byte[64 * 1024];
+
+ while (true) {
+ int numRead = is.read(buffer);
+ if (numRead == -1) {
+ break;
+ }
+ os.write(buffer, 0, numRead);
+ }
+ }
+ }
+
+ return copiedAgent;
+ }
+
+ @AfterClass
+ public static void cleanupExtractedAgents() throws Exception {
+ for (File f : createdFiles) {
+ f.delete();
+ }
+ createdFiles.clear();
+ }
+
+ // Tests.
+
+ // This will be repeated unnecessarily, but that's OK.
+ @Test(expected = IOException.class)
+ public void a_attachInvalidAgent() throws Exception {
+ File tmpFile = File.createTempFile("badAgent", ".so");
+ createdFiles.add(tmpFile);
+ Debug.attachJvmtiAgent(tmpFile.getAbsolutePath(), null, classLoader);
+ }
+
+ @Test(expected = IOException.class)
+ public void a_attachInvalidPath() throws Exception {
+ Debug.attachJvmtiAgent(agentString + ".invalid", null, classLoader);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void a_attachNullAgent() throws Exception {
+ Debug.attachJvmtiAgent(null, null, classLoader);
+ }
+
+ // This will be repeated unnecessarily, but that's OK.
+ @Test(expected = IllegalArgumentException.class)
+ public void a_attachWithEquals() throws Exception {
+ File tmpFile = File.createTempFile("=", ".so");
+ createdFiles.add(tmpFile);
+ Debug.attachJvmtiAgent(tmpFile.getAbsolutePath(), null, classLoader);
+ }
+
+ @Test(expected = IOException.class)
+ public void a_attachWithNullOptions() throws Exception {
+ Debug.attachJvmtiAgent(agentString, null, classLoader);
+ }
+
+ @Test(expected = IOException.class)
+ public void a_attachWithBadOptions() throws Exception {
+ Debug.attachJvmtiAgent(agentString, "b", classLoader);
+ }
+
+ @Test
+ public void b_attach() throws Exception {
+ try {
+ Debug.attachJvmtiAgent(agentString, "a", classLoader);
+ } catch (Throwable t) {
+ // Ignored.
+ }
+
+ assertTrue(isAttachedFn.call());
+ }
+
+ // Functions the agents can bind to.
+
+ native static boolean isAttached1();
+ native static boolean isAttached2();
+ native static boolean isAttached3();
+ native static boolean isAttached4();
+}
diff --git a/tests/tests/media/libmediandkjni/codec-utils-jni.cpp b/tests/tests/media/libmediandkjni/codec-utils-jni.cpp
index cb4363e..d7bd74e 100644
--- a/tests/tests/media/libmediandkjni/codec-utils-jni.cpp
+++ b/tests/tests/media/libmediandkjni/codec-utils-jni.cpp
@@ -24,8 +24,8 @@
#include <sys/types.h>
#include <jni.h>
-#include <ScopedLocalRef.h>
-#include <JNIHelp.h>
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/ScopedLocalRef.h>
#include <math.h>
diff --git a/tests/tests/media/libmediandkjni/native-mediadrm-jni.cpp b/tests/tests/media/libmediandkjni/native-mediadrm-jni.cpp
index a94bbb0..cff5c18 100644
--- a/tests/tests/media/libmediandkjni/native-mediadrm-jni.cpp
+++ b/tests/tests/media/libmediandkjni/native-mediadrm-jni.cpp
@@ -24,7 +24,7 @@
#include <assert.h>
#include <jni.h>
-#include <JNIHelp.h>
+#include <nativehelper/JNIHelp.h>
#include <android/native_window_jni.h>
diff --git a/tests/tests/media/res/raw/video_1280x720_mkv_h265_500kbps_25fps_aac_stereo_128kbps_44100hz.mkv b/tests/tests/media/res/raw/video_1280x720_mkv_h265_500kbps_25fps_aac_stereo_128kbps_44100hz.mkv
new file mode 100644
index 0000000..dd6d3ab
--- /dev/null
+++ b/tests/tests/media/res/raw/video_1280x720_mkv_h265_500kbps_25fps_aac_stereo_128kbps_44100hz.mkv
Binary files differ
diff --git a/tests/tests/media/src/android/media/cts/MediaPlayerTest.java b/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
index ebeba4e..c2d2991 100644
--- a/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
@@ -1351,6 +1351,11 @@
mMediaPlayer.stop();
}
+ public void testLocalVideo_MKV_H265_1280x720_500kbps_25fps_AAC_Stereo_128kbps_44100Hz()
+ throws Exception {
+ playVideoTest(
+ R.raw.video_1280x720_mkv_h265_500kbps_25fps_aac_stereo_128kbps_44100hz, 1280, 720);
+ }
public void testLocalVideo_MP4_H264_480x360_500kbps_25fps_AAC_Stereo_128kbps_44110Hz()
throws Exception {
playVideoTest(
diff --git a/tests/tests/mediastress/jni/Android.mk b/tests/tests/mediastress/jni/Android.mk
index 6756bc3..139aa00 100644
--- a/tests/tests/mediastress/jni/Android.mk
+++ b/tests/tests/mediastress/jni/Android.mk
@@ -29,6 +29,6 @@
LOCAL_SHARED_LIBRARIES := libandroid libnativehelper_compat_libc++ liblog libOpenMAXAL
LOCAL_CXX_STL := libc++_static
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter -Wno-unused-variable
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/mediastress/jni/native-media-jni.cpp b/tests/tests/mediastress/jni/native-media-jni.cpp
index 4a105e1..42fac20 100644
--- a/tests/tests/mediastress/jni/native-media-jni.cpp
+++ b/tests/tests/mediastress/jni/native-media-jni.cpp
@@ -106,7 +106,7 @@
return JNI_FALSE;
}
assert(1 <= nbRead && nbRead <= NB_BUFFERS);
- ALOGV("Initially queueing %u buffers of %u bytes each", nbRead, BUFFER_SIZE);
+ ALOGV("Initially queueing %zu buffers of %u bytes each", nbRead, BUFFER_SIZE);
/* Enqueue the content of our cache before starting to play,
we don't want to starve the player */
diff --git a/tests/tests/nativemedia/xa/Android.mk b/tests/tests/nativemedia/xa/Android.mk
index c11c10e..5f8830d 100644
--- a/tests/tests/nativemedia/xa/Android.mk
+++ b/tests/tests/nativemedia/xa/Android.mk
@@ -38,6 +38,8 @@
LOCAL_STATIC_LIBRARIES := \
libgtest \
+LOCAL_CFLAGS := -Wall -Werror
+
LOCAL_CTS_TEST_PACKAGE := android.nativemedia.xa
# Tag this module as a cts test artifact
diff --git a/tests/tests/net/jni/Android.mk b/tests/tests/net/jni/Android.mk
index 887e95e..727a44d 100644
--- a/tests/tests/net/jni/Android.mk
+++ b/tests/tests/net/jni/Android.mk
@@ -28,7 +28,7 @@
LOCAL_SHARED_LIBRARIES := libnativehelper_compat_libc++ liblog
LOCAL_CXX_STL := libc++_static
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
include $(BUILD_SHARED_LIBRARY)
@@ -37,6 +37,7 @@
# Don't include this package in any configuration by default.
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := NativeMultinetworkJni.c
+LOCAL_CFLAGS := -Wall -Werror -Wno-format
LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
LOCAL_SHARED_LIBRARIES := libandroid libnativehelper_compat_libc++ liblog
LOCAL_CXX_STL := libc++_static
diff --git a/tests/tests/net/jni/NativeMultinetworkJni.c b/tests/tests/net/jni/NativeMultinetworkJni.c
index 9156504..2fa5291 100644
--- a/tests/tests/net/jni/NativeMultinetworkJni.c
+++ b/tests/tests/net/jni/NativeMultinetworkJni.c
@@ -47,7 +47,7 @@
const int saved_errno = errno;
freeaddrinfo(res);
- ALOGD("android_getaddrinfofornetwork(%llu, %s) returned rval=%d errno=%d",
+ ALOGD("android_getaddrinfofornetwork(%" PRIu64 ", %s) returned rval=%d errno=%d",
handle, kHostname, rval, saved_errno);
return rval == 0 ? 0 : -saved_errno;
}
@@ -61,7 +61,7 @@
errno = 0;
int rval = android_setprocnetwork(handle);
const int saved_errno = errno;
- ALOGD("android_setprocnetwork(%llu) returned rval=%d errno=%d",
+ ALOGD("android_setprocnetwork(%" PRIu64 ") returned rval=%d errno=%d",
handle, rval, saved_errno);
return rval == 0 ? 0 : -saved_errno;
}
@@ -82,7 +82,7 @@
errno = 0;
int rval = android_setsocknetwork(handle, fd);
const int saved_errno = errno;
- ALOGD("android_setprocnetwork(%llu, %d) returned rval=%d errno=%d",
+ ALOGD("android_setprocnetwork(%" PRIu64 ", %d) returned rval=%d errno=%d",
handle, fd, rval, saved_errno);
close(fd);
return rval == 0 ? 0 : -saved_errno;
diff --git a/tests/tests/net/native/qtaguid/src/NativeQtaguidTest.cpp b/tests/tests/net/native/qtaguid/src/NativeQtaguidTest.cpp
index 9009c24..7f790fb 100644
--- a/tests/tests/net/native/qtaguid/src/NativeQtaguidTest.cpp
+++ b/tests/tests/net/native/qtaguid/src/NativeQtaguidTest.cpp
@@ -15,14 +15,39 @@
*/
#include <arpa/inet.h>
+#include <error.h>
#include <errno.h>
#include <inttypes.h>
#include <string.h>
#include <sys/socket.h>
+#include <sys/utsname.h>
#include <gtest/gtest.h>
#include <cutils/qtaguid.h>
+int hasQtaguidKernelSupport() {
+ struct utsname buf;
+ int kernel_version_major;
+ int kernel_version_minor;
+
+ int ret = uname(&buf);
+ if (ret) {
+ ret = -errno;
+ return ret;
+ }
+ char dummy;
+ ret = sscanf(buf.release, "%d.%d%c", &kernel_version_major, &kernel_version_minor, &dummy);
+ if (ret < 3)
+ return -EINVAL;
+
+ if ((kernel_version_major == 4 && kernel_version_minor < 9) ||
+ (kernel_version_major < 4)) {
+ return 1;
+ } else {
+ return access("/proc/net/xt_qtaguid/ctrl", F_OK) != -1;
+ }
+}
+
int getCtrlSkInfo(int tag, uid_t uid, uint64_t* sk_addr, int* ref_cnt) {
FILE *fp;
fp = fopen("/proc/net/xt_qtaguid/ctrl", "r");
@@ -70,6 +95,12 @@
}
TEST (NativeQtaguidTest, close_socket_without_untag) {
+ int res = hasQtaguidKernelSupport();
+ ASSERT_LE(0, res);
+ if (!res) {
+ GTEST_LOG_(INFO) << "This test is skipped since kernel may not have the module\n";
+ return;
+ }
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
uid_t uid = getuid();
int tag = arc4random();
@@ -83,6 +114,12 @@
}
TEST (NativeQtaguidTest, close_socket_without_untag_ipv6) {
+ int res = hasQtaguidKernelSupport();
+ ASSERT_LE(0, res);
+ if (!res) {
+ GTEST_LOG_(INFO) << "This test is skipped since kernel may not have the module\n";
+ return;
+ }
int sockfd = socket(AF_INET6, SOCK_STREAM, 0);
uid_t uid = getuid();
int tag = arc4random();
@@ -96,12 +133,17 @@
}
TEST (NativeQtaguidTest, no_socket_addr_leak) {
+ int res = hasQtaguidKernelSupport();
+ ASSERT_LE(0, res);
+ if (!res) {
+ GTEST_LOG_(INFO) << "This test is skipped since kernel may not have the module\n";
+ return;
+ }
checkNoSocketPointerLeaks(AF_INET);
checkNoSocketPointerLeaks(AF_INET6);
}
int main(int argc, char **argv) {
testing::InitGoogleTest(&argc, argv);
-
return RUN_ALL_TESTS();
}
diff --git a/tests/tests/net/src/android/net/cts/IpSecManagerTest.java b/tests/tests/net/src/android/net/cts/IpSecManagerTest.java
new file mode 100644
index 0000000..0ef3792
--- /dev/null
+++ b/tests/tests/net/src/android/net/cts/IpSecManagerTest.java
@@ -0,0 +1,1083 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.cts;
+
+import static android.system.OsConstants.IPPROTO_TCP;
+import static android.system.OsConstants.IPPROTO_UDP;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertTrue;
+
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.IpSecAlgorithm;
+import android.net.IpSecManager;
+import android.net.IpSecTransform;
+import android.net.TrafficStats;
+import android.os.ParcelFileDescriptor;
+import android.system.ErrnoException;
+import android.system.Os;
+import android.system.OsConstants;
+import android.test.AndroidTestCase;
+
+import java.io.FileDescriptor;
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.Inet4Address;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.util.Arrays;
+
+public class IpSecManagerTest extends AndroidTestCase {
+
+ private static final String TAG = IpSecManagerTest.class.getSimpleName();
+
+ private IpSecManager mISM;
+
+ private ConnectivityManager mCM;
+
+ private static InetAddress IpAddress(String addrString) {
+ try {
+ return InetAddress.getByName(addrString);
+ } catch (UnknownHostException e) {
+ throw new IllegalArgumentException("Invalid IP address: " + e);
+ }
+ }
+
+ private static final InetAddress GOOGLE_DNS_4 = IpAddress("8.8.8.8");
+ private static final InetAddress GOOGLE_DNS_6 = IpAddress("2001:4860:4860::8888");
+
+ private static final InetAddress[] GOOGLE_DNS_LIST =
+ new InetAddress[] {GOOGLE_DNS_4, GOOGLE_DNS_6};
+
+ private static final int DROID_SPI = 0xD1201D;
+ private static final int MAX_PORT_BIND_ATTEMPTS = 10;
+
+ private static final byte[] CRYPT_KEY = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F
+ };
+ private static final byte[] AUTH_KEY = {
+ 0x7A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F,
+ 0x7A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F
+ };
+
+ private static final String IPV4_LOOPBACK = "127.0.0.1";
+ private static final String IPV6_LOOPBACK = "::1";
+ private static final int TCP_HDRLEN_WITH_OPTIONS = 32;
+ private static final int UDP_HDRLEN = 8;
+ private static final int IP4_HDRLEN = 20;
+ private static final int IP6_HDRLEN = 40;
+
+ private static final byte[] TEST_DATA = "Best test data ever!".getBytes();
+
+ // Encryption parameters
+ private static final int AES_CBC_IV_LEN = 16;
+ private static final int AES_CBC_BLK_SIZE = 16;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ mCM = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
+ mISM = (IpSecManager) getContext().getSystemService(Context.IPSEC_SERVICE);
+ }
+
+ /*
+ * Allocate a random SPI
+ * Allocate a specific SPI using previous randomly created SPI value
+ * Realloc the same SPI that was specifically created (expect SpiUnavailable)
+ * Close SPIs
+ */
+ public void testAllocSpi() throws Exception {
+ for (InetAddress addr : GOOGLE_DNS_LIST) {
+ IpSecManager.SecurityParameterIndex randomSpi = null, droidSpi = null;
+ randomSpi = mISM.allocateSecurityParameterIndex(addr);
+ assertTrue(
+ "Failed to receive a valid SPI",
+ randomSpi.getSpi() != IpSecManager.INVALID_SECURITY_PARAMETER_INDEX);
+
+ droidSpi = mISM.allocateSecurityParameterIndex(addr, DROID_SPI);
+ assertTrue("Failed to allocate specified SPI, " + DROID_SPI,
+ droidSpi.getSpi() == DROID_SPI);
+
+ try {
+ mISM.allocateSecurityParameterIndex(addr, DROID_SPI);
+ fail("Duplicate SPI was allowed to be created");
+ } catch (IpSecManager.SpiUnavailableException expected) {
+ // This is a success case because we expect a dupe SPI to throw
+ }
+
+ randomSpi.close();
+ droidSpi.close();
+ }
+ }
+
+ private byte[] getAuthKey(int bitLength) {
+ return Arrays.copyOf(AUTH_KEY, bitLength / 8);
+ }
+
+ private static int getDomain(InetAddress address) {
+ int domain;
+ if (address instanceof Inet6Address)
+ domain = OsConstants.AF_INET6;
+ else
+ domain = OsConstants.AF_INET;
+ return domain;
+ }
+
+ /** This function finds an available port */
+ private static int findUnusedPort() throws Exception {
+ // Get an available port.
+ DatagramSocket s = new DatagramSocket();
+ int port = s.getLocalPort();
+ s.close();
+ return port;
+ }
+
+ private static FileDescriptor getBoundUdpSocket(InetAddress address) throws Exception {
+ FileDescriptor sock =
+ Os.socket(getDomain(address), OsConstants.SOCK_DGRAM, OsConstants.IPPROTO_UDP);
+
+ for (int i = 0; i < MAX_PORT_BIND_ATTEMPTS; i++) {
+ try {
+ int port = findUnusedPort();
+ Os.bind(sock, address, port);
+ break;
+ } catch (ErrnoException e) {
+ // Someone claimed the port since we called findUnusedPort.
+ if (e.errno == OsConstants.EADDRINUSE) {
+ if (i == MAX_PORT_BIND_ATTEMPTS - 1) {
+
+ fail("Failed " + MAX_PORT_BIND_ATTEMPTS + " attempts to bind to a port");
+ }
+ continue;
+ }
+ throw e.rethrowAsIOException();
+ }
+ }
+ return sock;
+ }
+
+ private void checkUnconnectedUdp(IpSecTransform transform, InetAddress local, int sendCount,
+ boolean useJavaSockets) throws Exception {
+ FileDescriptor udpSocket = null;
+ int localPort;
+
+ if (useJavaSockets) {
+ DatagramSocket localSocket = new DatagramSocket(0, local);
+ localSocket.setSoTimeout(500);
+ ParcelFileDescriptor pfd = ParcelFileDescriptor.fromDatagramSocket(localSocket);
+
+ localPort = localSocket.getLocalPort();
+ udpSocket = pfd.getFileDescriptor();
+ } else {
+ udpSocket = getBoundUdpSocket(local);
+ localPort = getPort(udpSocket);
+ }
+
+ mISM.applyTransportModeTransform(udpSocket, IpSecManager.DIRECTION_IN, transform);
+ mISM.applyTransportModeTransform(udpSocket, IpSecManager.DIRECTION_OUT, transform);
+
+ for (int i = 0; i < sendCount; i++) {
+ byte[] in = new byte[TEST_DATA.length];
+ Os.sendto(udpSocket, TEST_DATA, 0, TEST_DATA.length, 0, local, localPort);
+ Os.read(udpSocket, in, 0, in.length);
+ assertArrayEquals("Encapsulated data did not match.", TEST_DATA, in);
+ }
+
+ mISM.removeTransportModeTransforms(udpSocket);
+ Os.close(udpSocket);
+ }
+
+ private void checkTcp(IpSecTransform transform, InetAddress local, int sendCount,
+ boolean useJavaSockets) throws Exception {
+
+ FileDescriptor server = null, client = null;
+
+ if (useJavaSockets) {
+ Socket serverSocket = new Socket();
+ serverSocket.setSoTimeout(500);
+ ParcelFileDescriptor serverPfd = ParcelFileDescriptor.fromSocket(serverSocket);
+ server = serverPfd.getFileDescriptor();
+
+ Socket clientSocket = new Socket();
+ clientSocket.setSoTimeout(500);
+ ParcelFileDescriptor clientPfd = ParcelFileDescriptor.fromSocket(clientSocket);
+ client = clientPfd.getFileDescriptor();
+ } else {
+ final int domain = getDomain(local);
+ server =
+ Os.socket(domain, OsConstants.SOCK_STREAM, IPPROTO_TCP);
+ client =
+ Os.socket(domain, OsConstants.SOCK_STREAM, IPPROTO_TCP);
+ }
+
+ Os.bind(server, local, 0);
+ int port = ((InetSocketAddress) Os.getsockname(server)).getPort();
+
+ mISM.applyTransportModeTransform(client, IpSecManager.DIRECTION_IN, transform);
+ mISM.applyTransportModeTransform(client, IpSecManager.DIRECTION_OUT, transform);
+ mISM.applyTransportModeTransform(server, IpSecManager.DIRECTION_IN, transform);
+ mISM.applyTransportModeTransform(server, IpSecManager.DIRECTION_OUT, transform);
+
+ Os.listen(server, 10);
+ Os.connect(client, local, port);
+ FileDescriptor accepted = Os.accept(server, null);
+
+ mISM.applyTransportModeTransform(accepted, IpSecManager.DIRECTION_IN, transform);
+ mISM.applyTransportModeTransform(accepted, IpSecManager.DIRECTION_OUT, transform);
+
+ // Wait for TCP handshake packets to be counted
+ StatsChecker.waitForNumPackets(3); // (SYN, SYN+ACK, ACK)
+
+ // Reset StatsChecker, to ignore negotiation overhead.
+ StatsChecker.initStatsChecker();
+ for (int i = 0; i < sendCount; i++) {
+ byte[] in = new byte[TEST_DATA.length];
+
+ Os.write(client, TEST_DATA, 0, TEST_DATA.length);
+ Os.read(accepted, in, 0, in.length);
+ assertArrayEquals("Client-to-server encrypted data did not match.", TEST_DATA, in);
+
+ // Allow for newest data + ack packets to be returned before sending next packet
+ // Also add the number of expected packets in each of the previous runs (4 per run)
+ StatsChecker.waitForNumPackets(2 + (4 * i));
+ in = new byte[TEST_DATA.length];
+
+ Os.write(accepted, TEST_DATA, 0, TEST_DATA.length);
+ Os.read(client, in, 0, in.length);
+ assertArrayEquals("Server-to-client encrypted data did not match.", TEST_DATA, in);
+
+ // Allow for all data + ack packets to be returned before sending next packet
+ // Also add the number of expected packets in each of the previous runs (4 per run)
+ StatsChecker.waitForNumPackets(4 * (i + 1));
+ }
+
+ mISM.removeTransportModeTransforms(server);
+ mISM.removeTransportModeTransforms(client);
+ mISM.removeTransportModeTransforms(accepted);
+
+ Os.close(server);
+ Os.close(client);
+ Os.close(accepted);
+ }
+
+ /*
+ * Alloc outbound SPI
+ * Alloc inbound SPI
+ * Create transport mode transform
+ * open socket
+ * apply transform to socket
+ * send data on socket
+ * release transform
+ * send data (expect exception)
+ */
+ public void testCreateTransform() throws Exception {
+ InetAddress localAddr = InetAddress.getByName(IPV4_LOOPBACK);
+ IpSecManager.SecurityParameterIndex spi =
+ mISM.allocateSecurityParameterIndex(localAddr);
+
+ IpSecTransform transform =
+ new IpSecTransform.Builder(mContext)
+ .setEncryption(
+ new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY))
+ .setAuthentication(
+ new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_SHA256,
+ AUTH_KEY,
+ AUTH_KEY.length * 8))
+ .buildTransportModeTransform(localAddr, spi);
+
+ final boolean [][] applyInApplyOut = {
+ {false, false}, {false, true}, {true, false}, {true,true}};
+ final byte[] data = new String("Best test data ever!").getBytes("UTF-8");
+ final DatagramPacket outPacket = new DatagramPacket(data, 0, data.length, localAddr, 0);
+
+ byte[] in = new byte[data.length];
+ DatagramPacket inPacket = new DatagramPacket(in, in.length);
+ DatagramSocket localSocket;
+ int localPort;
+
+ for(boolean[] io : applyInApplyOut) {
+ boolean applyIn = io[0];
+ boolean applyOut = io[1];
+ // Bind localSocket to a random available port.
+ localSocket = new DatagramSocket(0);
+ localPort = localSocket.getLocalPort();
+ localSocket.setSoTimeout(200);
+ outPacket.setPort(localPort);
+ if (applyIn) {
+ mISM.applyTransportModeTransform(
+ localSocket, IpSecManager.DIRECTION_IN, transform);
+ }
+ if (applyOut) {
+ mISM.applyTransportModeTransform(
+ localSocket, IpSecManager.DIRECTION_OUT, transform);
+ }
+ if (applyIn == applyOut) {
+ localSocket.send(outPacket);
+ localSocket.receive(inPacket);
+ assertTrue("Encapsulated data did not match.",
+ Arrays.equals(outPacket.getData(), inPacket.getData()));
+ mISM.removeTransportModeTransforms(localSocket);
+ localSocket.close();
+ } else {
+ try {
+ localSocket.send(outPacket);
+ localSocket.receive(inPacket);
+ } catch (IOException e) {
+ continue;
+ } finally {
+ mISM.removeTransportModeTransforms(localSocket);
+ localSocket.close();
+ }
+ // FIXME: This check is disabled because sockets currently receive data
+ // if there is a valid SA for decryption, even when the input policy is
+ // not applied to a socket.
+ // fail("Data IO should fail on asymmetrical transforms! + Input="
+ // + applyIn + " Output=" + applyOut);
+ }
+ }
+ transform.close();
+ }
+
+ /** Snapshot of TrafficStats as of initStatsChecker call for later comparisons */
+ private static class StatsChecker {
+ private static final String LOOPBACK_INTERFACE = "lo";
+ private static final double ERROR_MARGIN_BYTES = 1.05;
+ private static final double ERROR_MARGIN_PKTS = 1.05;
+ private static final int MAX_WAIT_TIME_MILLIS = 1000;
+
+ private static long uidTxBytes;
+ private static long uidRxBytes;
+ private static long uidTxPackets;
+ private static long uidRxPackets;
+
+ private static long ifaceTxBytes;
+ private static long ifaceRxBytes;
+ private static long ifaceTxPackets;
+ private static long ifaceRxPackets;
+
+ /**
+ * This method counts the number of incoming packets, polling intermittently up to
+ * MAX_WAIT_TIME_MILLIS.
+ */
+ private static void waitForNumPackets(int numPackets) throws Exception {
+ long uidTxDelta = 0;
+ long uidRxDelta = 0;
+ for (int i = 0; i < 100; i++) {
+ uidTxDelta = TrafficStats.getUidTxPackets(Os.getuid()) - uidTxPackets;
+ uidRxDelta = TrafficStats.getUidRxPackets(Os.getuid()) - uidRxPackets;
+
+ // TODO: Check Rx packets as well once kernel security policy bug is fixed.
+ // (b/70635417)
+ if (uidTxDelta >= numPackets) {
+ return;
+ }
+ Thread.sleep(MAX_WAIT_TIME_MILLIS / 100);
+ }
+ fail(
+ "Not enough traffic was recorded to satisfy the provided conditions: wanted "
+ + numPackets
+ + ", got "
+ + uidTxDelta
+ + " tx and "
+ + uidRxDelta
+ + " rx packets");
+ }
+
+ private static void assertUidStatsDelta(
+ int expectedTxByteDelta,
+ int expectedTxPacketDelta,
+ int expectedRxByteDelta,
+ int expectedRxPacketDelta) {
+ long newUidTxBytes = TrafficStats.getUidTxBytes(Os.getuid());
+ long newUidRxBytes = TrafficStats.getUidRxBytes(Os.getuid());
+ long newUidTxPackets = TrafficStats.getUidTxPackets(Os.getuid());
+ long newUidRxPackets = TrafficStats.getUidRxPackets(Os.getuid());
+
+ assertEquals(expectedTxByteDelta, newUidTxBytes - uidTxBytes);
+ assertEquals(expectedRxByteDelta, newUidRxBytes - uidRxBytes);
+ assertEquals(expectedTxPacketDelta, newUidTxPackets - uidTxPackets);
+ assertEquals(expectedRxPacketDelta, newUidRxPackets - uidRxPackets);
+ }
+
+ private static void assertIfaceStatsDelta(
+ int expectedTxByteDelta,
+ int expectedTxPacketDelta,
+ int expectedRxByteDelta,
+ int expectedRxPacketDelta)
+ throws IOException {
+ long newIfaceTxBytes = TrafficStats.getLoopbackTxBytes();
+ long newIfaceRxBytes = TrafficStats.getLoopbackRxBytes();
+ long newIfaceTxPackets = TrafficStats.getLoopbackTxPackets();
+ long newIfaceRxPackets = TrafficStats.getLoopbackRxPackets();
+
+ // Check that iface stats are within an acceptable range; data might be sent
+ // on the local interface by other apps.
+ assertApproxEquals(
+ ifaceTxBytes, newIfaceTxBytes, expectedTxByteDelta, ERROR_MARGIN_BYTES);
+ assertApproxEquals(
+ ifaceRxBytes, newIfaceRxBytes, expectedRxByteDelta, ERROR_MARGIN_BYTES);
+ assertApproxEquals(
+ ifaceTxPackets, newIfaceTxPackets, expectedTxPacketDelta, ERROR_MARGIN_PKTS);
+ assertApproxEquals(
+ ifaceRxPackets, newIfaceRxPackets, expectedRxPacketDelta, ERROR_MARGIN_PKTS);
+ }
+
+ private static void assertApproxEquals(
+ long oldStats, long newStats, int expectedDelta, double errorMargin) {
+ assertTrue(expectedDelta <= newStats - oldStats);
+ assertTrue((expectedDelta * errorMargin) > newStats - oldStats);
+ }
+
+ private static void initStatsChecker() throws IOException {
+ uidTxBytes = TrafficStats.getUidTxBytes(Os.getuid());
+ uidRxBytes = TrafficStats.getUidRxBytes(Os.getuid());
+ uidTxPackets = TrafficStats.getUidTxPackets(Os.getuid());
+ uidRxPackets = TrafficStats.getUidRxPackets(Os.getuid());
+
+ ifaceTxBytes = TrafficStats.getLoopbackTxBytes();
+ ifaceRxBytes = TrafficStats.getLoopbackRxBytes();
+ ifaceTxPackets = TrafficStats.getLoopbackTxPackets();
+ ifaceRxPackets = TrafficStats.getLoopbackRxPackets();
+ }
+ }
+
+ /** Helper function to calculate expected ESP packet size. */
+ private int calculateEspPacketSize(
+ int payloadLen, int cryptIvLength, int cryptBlockSize, int authTruncLen) {
+ final int ESP_HDRLEN = 4 + 4; // SPI + Seq#
+ final int ICV_LEN = authTruncLen / 8; // Auth trailer; based on truncation length
+ payloadLen += cryptIvLength; // Initialization Vector
+ payloadLen += 2; // ESP trailer
+
+ // Align to block size of encryption algorithm
+ payloadLen += (cryptBlockSize - (payloadLen % cryptBlockSize)) % cryptBlockSize;
+ return payloadLen + ESP_HDRLEN + ICV_LEN;
+ }
+
+ /** Helper function to calculate expected ESP packet size using AES-CBC encryption. */
+ private int calculateAesCbcEspPacketSizeWithAuth(int payloadLen, int authTruncLen) {
+ return calculateEspPacketSize(payloadLen, AES_CBC_IV_LEN, AES_CBC_BLK_SIZE, authTruncLen);
+ }
+
+ public void checkTransform(
+ int protocol,
+ String localAddress,
+ IpSecAlgorithm crypt,
+ IpSecAlgorithm auth,
+ boolean doUdpEncap,
+ int sendCount,
+ boolean useJavaSockets)
+ throws Exception {
+ StatsChecker.initStatsChecker();
+ InetAddress local = InetAddress.getByName(localAddress);
+
+ try (IpSecManager.UdpEncapsulationSocket encapSocket = mISM.openUdpEncapsulationSocket();
+ IpSecManager.SecurityParameterIndex spi =
+ mISM.allocateSecurityParameterIndex(local)) {
+
+ IpSecTransform.Builder transformBuilder =
+ new IpSecTransform.Builder(mContext)
+ .setEncryption(crypt)
+ .setAuthentication(auth);
+
+ if (doUdpEncap) {
+ transformBuilder =
+ transformBuilder.setIpv4Encapsulation(encapSocket, encapSocket.getPort());
+ }
+
+ int ipHdrLen = local instanceof Inet6Address ? IP6_HDRLEN : IP4_HDRLEN;
+ int transportHdrLen = 0;
+ int udpEncapLen = doUdpEncap ? UDP_HDRLEN : 0;
+
+ try (IpSecTransform transform =
+ transformBuilder.buildTransportModeTransform(local, spi)) {
+ if (protocol == IPPROTO_TCP) {
+ transportHdrLen = TCP_HDRLEN_WITH_OPTIONS;
+ checkTcp(transform, local, sendCount, useJavaSockets);
+ } else if (protocol == IPPROTO_UDP) {
+ transportHdrLen = UDP_HDRLEN;
+
+ // TODO: Also check connected udp.
+ checkUnconnectedUdp(transform, local, sendCount, useJavaSockets);
+ } else {
+ throw new IllegalArgumentException("Invalid protocol");
+ }
+ }
+
+ checkStatsChecker(
+ protocol,
+ ipHdrLen,
+ transportHdrLen,
+ udpEncapLen,
+ sendCount,
+ auth.getTruncationLengthBits());
+ }
+ }
+
+ private void checkStatsChecker(
+ int protocol,
+ int ipHdrLen,
+ int transportHdrLen,
+ int udpEncapLen,
+ int sendCount,
+ int truncLenBits)
+ throws Exception {
+
+ int innerPacketSize = TEST_DATA.length + transportHdrLen + ipHdrLen;
+ int outerPacketSize =
+ calculateAesCbcEspPacketSizeWithAuth(
+ TEST_DATA.length + transportHdrLen, truncLenBits)
+ + udpEncapLen
+ + ipHdrLen;
+
+ int expectedOuterBytes = outerPacketSize * sendCount;
+ int expectedInnerBytes = innerPacketSize * sendCount;
+ int expectedPackets = sendCount;
+
+ // Add TCP ACKs for data packets
+ if (protocol == IPPROTO_TCP) {
+ int encryptedTcpPktSize =
+ calculateAesCbcEspPacketSizeWithAuth(TCP_HDRLEN_WITH_OPTIONS, truncLenBits);
+
+ // Each run sends two packets, one in each direction.
+ sendCount *= 2;
+ expectedOuterBytes *= 2;
+ expectedInnerBytes *= 2;
+ expectedPackets *= 2;
+
+ // Add data packet ACKs
+ expectedOuterBytes += (encryptedTcpPktSize + udpEncapLen + ipHdrLen) * (sendCount);
+ expectedInnerBytes += (TCP_HDRLEN_WITH_OPTIONS + ipHdrLen) * (sendCount);
+ expectedPackets += sendCount;
+ }
+
+ StatsChecker.waitForNumPackets(expectedPackets);
+
+ if (udpEncapLen != 0) {
+ StatsChecker.assertUidStatsDelta(
+ expectedOuterBytes, expectedPackets, expectedOuterBytes, expectedPackets);
+ } else {
+ StatsChecker.assertUidStatsDelta(
+ expectedOuterBytes, expectedPackets, expectedInnerBytes, expectedPackets);
+ }
+
+ // Unreliable at low numbers due to potential interference from other processes.
+ if (sendCount >= 1000) {
+ StatsChecker.assertIfaceStatsDelta(
+ expectedOuterBytes, expectedPackets, expectedOuterBytes, expectedPackets);
+ }
+ }
+
+ public void testIkeOverUdpEncapSocket() throws Exception {
+ // IPv6 not supported for UDP-encap-ESP
+ InetAddress local = InetAddress.getByName(IPV4_LOOPBACK);
+ StatsChecker.initStatsChecker();
+
+ try (IpSecManager.UdpEncapsulationSocket encapSocket = mISM.openUdpEncapsulationSocket()) {
+ int localPort = getPort(encapSocket.getSocket());
+
+ // Append ESP header - 4 bytes of SPI, 4 bytes of seq number
+ byte[] dataWithEspHeader = new byte[TEST_DATA.length + 8];
+ System.arraycopy(TEST_DATA, 0, dataWithEspHeader, 8, TEST_DATA.length);
+
+ byte[] in = new byte[dataWithEspHeader.length];
+ Os.sendto(
+ encapSocket.getSocket(),
+ dataWithEspHeader,
+ 0,
+ dataWithEspHeader.length,
+ 0,
+ local,
+ localPort);
+ Os.read(encapSocket.getSocket(), in, 0, in.length);
+ assertArrayEquals("Encapsulated data did not match.", dataWithEspHeader, in);
+
+ int ipHdrLen = local instanceof Inet6Address ? IP6_HDRLEN : IP4_HDRLEN;
+ int expectedPacketSize = dataWithEspHeader.length + UDP_HDRLEN + ipHdrLen;
+ StatsChecker.assertUidStatsDelta(expectedPacketSize, 1, expectedPacketSize, 1);
+ StatsChecker.assertIfaceStatsDelta(expectedPacketSize, 1, expectedPacketSize, 1);
+ }
+ }
+
+ // TODO: Check IKE over ESP sockets (IPv4, IPv6) - does this need SOCK_RAW?
+
+ /* TODO: Re-enable these when policy matcher works for reflected packets
+ *
+ * The issue here is that A sends to B, and everything is new; therefore PREROUTING counts
+ * correctly. But it appears that the security path is not cleared afterwards, thus when A
+ * sends an ACK back to B, the policy matcher flags it as a "IPSec" packet. See b/70635417
+ */
+
+ // public void testInterfaceCountersTcp4() throws Exception {
+ // IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ // IpSecAlgorithm auth = new IpSecAlgorithm(
+ // IpSecAlgorithm.AUTH_HMAC_MD5, getAuthKey(128), 96);
+ // checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, false, 1000);
+ // }
+
+ // public void testInterfaceCountersTcp6() throws Exception {
+ // IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ // IpSecAlgorithm auth = new IpSecAlgorithm(
+ // IpSecAlgorithm.AUTH_HMAC_MD5, getAuthKey(128), 96);
+ // checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, crypt, auth, false, 1000);
+ // }
+
+ // public void testInterfaceCountersTcp4UdpEncap() throws Exception {
+ // IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ // IpSecAlgorithm auth =
+ // new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_MD5, getAuthKey(128), 96);
+ // checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, true, 1000);
+ // }
+
+ public void testInterfaceCountersUdp4() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_MD5, getAuthKey(128), 96);
+ checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, false, 1000, false);
+ }
+
+ public void testInterfaceCountersUdp6() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_MD5, getAuthKey(128), 96);
+ checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, crypt, auth, false, 1000, false);
+ }
+
+ public void testInterfaceCountersUdp4UdpEncap() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_MD5, getAuthKey(128), 96);
+ checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, true, 1000, false);
+ }
+
+ public void testAesCbcHmacMd5Tcp4() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_MD5, getAuthKey(128), 96);
+ checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, false, 1, false);
+ checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, false, 1, true);
+ }
+
+ public void testAesCbcHmacMd5Tcp6() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_MD5, getAuthKey(128), 96);
+ checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, crypt, auth, false, 1, false);
+ checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, crypt, auth, false, 1, true);
+ }
+
+ public void testAesCbcHmacMd5Udp4() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_MD5, getAuthKey(128), 96);
+ checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, false, 1, false);
+ checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, false, 1, true);
+ }
+
+ public void testAesCbcHmacMd5Udp6() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_MD5, getAuthKey(128), 96);
+ checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, crypt, auth, false, 1, false);
+ checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, crypt, auth, false, 1, true);
+ }
+
+ public void testAesCbcHmacSha1Tcp4() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_SHA1, getAuthKey(160), 96);
+ checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, false, 1, false);
+ checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, false, 1, true);
+ }
+
+ public void testAesCbcHmacSha1Tcp6() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_SHA1, getAuthKey(160), 96);
+ checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, crypt, auth, false, 1, false);
+ checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, crypt, auth, false, 1, true);
+ }
+
+ public void testAesCbcHmacSha1Udp4() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_SHA1, getAuthKey(160), 96);
+ checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, false, 1, false);
+ checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, false, 1, true);
+ }
+
+ public void testAesCbcHmacSha1Udp6() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_SHA1, getAuthKey(160), 96);
+ checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, crypt, auth, false, 1, false);
+ checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, crypt, auth, false, 1, true);
+ }
+
+ public void testAesCbcHmacSha256Tcp4() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_SHA256, getAuthKey(256), 128);
+ checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, false, 1, false);
+ checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, false, 1, true);
+ }
+
+ public void testAesCbcHmacSha256Tcp6() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_SHA256, getAuthKey(256), 128);
+ checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, crypt, auth, false, 1, false);
+ checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, crypt, auth, false, 1, true);
+ }
+
+ public void testAesCbcHmacSha256Udp4() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_SHA256, getAuthKey(256), 128);
+ checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, false, 1, false);
+ checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, false, 1, true);
+ }
+
+ public void testAesCbcHmacSha256Udp6() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_SHA256, getAuthKey(256), 128);
+ checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, crypt, auth, false, 1, false);
+ checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, crypt, auth, false, 1, true);
+ }
+
+ public void testAesCbcHmacSha384Tcp4() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_SHA384, getAuthKey(384), 192);
+ checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, false, 1, false);
+ checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, false, 1, true);
+ }
+
+ public void testAesCbcHmacSha384Tcp6() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_SHA384, getAuthKey(384), 192);
+ checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, crypt, auth, false, 1, false);
+ checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, crypt, auth, false, 1, true);
+ }
+
+ public void testAesCbcHmacSha384Udp4() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_SHA384, getAuthKey(384), 192);
+ checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, false, 1, false);
+ checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, false, 1, true);
+ }
+
+ public void testAesCbcHmacSha384Udp6() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_SHA384, getAuthKey(384), 192);
+ checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, crypt, auth, false, 1, false);
+ checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, crypt, auth, false, 1, true);
+ }
+
+ public void testAesCbcHmacSha512Tcp4() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_SHA512, getAuthKey(512), 256);
+ checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, false, 1, false);
+ checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, false, 1, true);
+ }
+
+ public void testAesCbcHmacSha512Tcp6() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_SHA512, getAuthKey(512), 256);
+ checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, crypt, auth, false, 1, false);
+ checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, crypt, auth, false, 1, true);
+ }
+
+ public void testAesCbcHmacSha512Udp4() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_SHA512, getAuthKey(512), 256);
+ checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, false, 1, false);
+ checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, false, 1, true);
+ }
+
+ public void testAesCbcHmacSha512Udp6() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_SHA512, getAuthKey(512), 256);
+ checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, crypt, auth, false, 1, false);
+ checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, crypt, auth, false, 1, true);
+ }
+
+ public void testAesCbcHmacMd5Tcp4UdpEncap() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_MD5, getAuthKey(128), 96);
+ checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, true, 1, false);
+ }
+
+ public void testAesCbcHmacMd5Udp4UdpEncap() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_MD5, getAuthKey(128), 96);
+ checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, true, 1, false);
+ }
+
+ public void testAesCbcHmacSha1Tcp4UdpEncap() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth =
+ new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA1, getAuthKey(160), 96);
+ checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, true, 1, false);
+ }
+
+ public void testAesCbcHmacSha1Udp4UdpEncap() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth =
+ new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA1, getAuthKey(160), 96);
+ checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, true, 1, false);
+ }
+
+ public void testAesCbcHmacSha256Tcp4UdpEncap() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth =
+ new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA256, getAuthKey(256), 128);
+ checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, true, 1, false);
+ }
+
+ public void testAesCbcHmacSha256Udp4UdpEncap() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth =
+ new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA256, getAuthKey(256), 128);
+ checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, true, 1, false);
+ }
+
+ public void testAesCbcHmacSha384Tcp4UdpEncap() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth =
+ new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA384, getAuthKey(384), 192);
+ checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, true, 1, false);
+ }
+
+ public void testAesCbcHmacSha384Udp4UdpEncap() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth =
+ new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA384, getAuthKey(384), 192);
+ checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, true, 1, false);
+ }
+
+ public void testAesCbcHmacSha512Tcp4UdpEncap() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth =
+ new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA512, getAuthKey(512), 256);
+ checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, true, 1, false);
+ }
+
+ public void testAesCbcHmacSha512Udp4UdpEncap() throws Exception {
+ IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
+ IpSecAlgorithm auth =
+ new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA512, getAuthKey(512), 256);
+ checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, true, 1, false);
+ }
+
+ public void testOpenUdpEncapSocketSpecificPort() throws Exception {
+ IpSecManager.UdpEncapsulationSocket encapSocket = null;
+ int port = -1;
+ for (int i = 0; i < MAX_PORT_BIND_ATTEMPTS; i++) {
+ try {
+ port = findUnusedPort();
+ encapSocket = mISM.openUdpEncapsulationSocket(port);
+ break;
+ } catch (ErrnoException e) {
+ if (e.errno == OsConstants.EADDRINUSE) {
+ // Someone claimed the port since we called findUnusedPort.
+ continue;
+ }
+ throw e;
+ } finally {
+ if (encapSocket != null) {
+ encapSocket.close();
+ }
+ }
+ }
+
+ if (encapSocket == null) {
+ fail("Failed " + MAX_PORT_BIND_ATTEMPTS + " attempts to bind to a port");
+ }
+
+ assertTrue("Returned invalid port", encapSocket.getPort() == port);
+ }
+
+ public void testOpenUdpEncapSocketRandomPort() throws Exception {
+ try (IpSecManager.UdpEncapsulationSocket encapSocket = mISM.openUdpEncapsulationSocket()) {
+ assertTrue("Returned invalid port", encapSocket.getPort() != 0);
+ }
+ }
+
+ public void testUdpEncapsulation() throws Exception {
+ InetAddress local = InetAddress.getByName(IPV4_LOOPBACK);
+
+ // TODO: Refactor to make this more representative of a normal application use case. (use
+ // separate sockets for inbound and outbound)
+ // Create SPIs, UDP encap socket
+ try (IpSecManager.UdpEncapsulationSocket encapSocket = mISM.openUdpEncapsulationSocket();
+ IpSecManager.SecurityParameterIndex spi =
+ mISM.allocateSecurityParameterIndex(local);
+ IpSecTransform transform =
+ buildIpSecTransform(mContext, spi, encapSocket, local)) {
+
+ // Create user socket, apply transform to it
+ FileDescriptor udpSocket = null;
+ try {
+ udpSocket = getBoundUdpSocket(local);
+ int port = getPort(udpSocket);
+
+ mISM.applyTransportModeTransform(
+ udpSocket, IpSecManager.DIRECTION_IN, transform);
+ mISM.applyTransportModeTransform(
+ udpSocket, IpSecManager.DIRECTION_OUT, transform);
+
+ // Send an ESP packet from this socket to itself. Since the inbound and
+ // outbound transforms match, we should receive the data we sent.
+ byte[] data = new String("IPSec UDP-encap-ESP test data").getBytes("UTF-8");
+ Os.sendto(udpSocket, data, 0, data.length, 0, local, port);
+ byte[] in = new byte[data.length];
+ Os.read(udpSocket, in, 0, in.length);
+ assertTrue("Encapsulated data did not match.", Arrays.equals(data, in));
+
+ // Send an IKE packet from this socket to itself. IKE packets (SPI of 0)
+ // are not transformed in any way, and should be sent in the clear
+ // We expect this to work too (no inbound transforms)
+ final byte[] header = new byte[] {0, 0, 0, 0};
+ final String message = "Sample IKE Packet";
+ data = (new String(header) + message).getBytes("UTF-8");
+ Os.sendto(
+ encapSocket.getSocket(),
+ data,
+ 0,
+ data.length,
+ 0,
+ local,
+ encapSocket.getPort());
+ in = new byte[data.length];
+ Os.read(encapSocket.getSocket(), in, 0, in.length);
+ assertTrue(
+ "Encap socket was unable to send/receive IKE data",
+ Arrays.equals(data, in));
+
+ mISM.removeTransportModeTransforms(udpSocket);
+ } finally {
+ if (udpSocket != null) {
+ Os.close(udpSocket);
+ }
+ }
+ }
+ }
+
+ public void testIke() throws Exception {
+ InetAddress localAddr = InetAddress.getByName(IPV4_LOOPBACK);
+
+ // TODO: Refactor to make this more representative of a normal application use case. (use
+ // separate sockets for inbound and outbound)
+ try (IpSecManager.UdpEncapsulationSocket encapSocket = mISM.openUdpEncapsulationSocket();
+ IpSecManager.SecurityParameterIndex spi =
+ mISM.allocateSecurityParameterIndex(localAddr);
+ IpSecTransform transform =
+ buildIpSecTransform(mContext, spi, encapSocket, localAddr)) {
+
+ // Create user socket, apply transform to it
+ FileDescriptor sock = null;
+
+ try {
+ sock = getBoundUdpSocket(localAddr);
+ int port = getPort(sock);
+
+ mISM.applyTransportModeTransform(sock, IpSecManager.DIRECTION_IN, transform);
+ mISM.applyTransportModeTransform(sock, IpSecManager.DIRECTION_OUT, transform);
+
+ // TODO: Find a way to set a timeout on the socket, and assert the ESP packet
+ // doesn't make it through. Setting sockopts currently throws EPERM (possibly
+ // because it is owned by a different UID).
+
+ // Send ESP packet from our socket to the encap socket. The SPIs do not
+ // match, and we should expect this packet to be dropped.
+ byte[] header = new byte[] {1, 1, 1, 1};
+ String message = "Sample ESP Packet";
+ byte[] data = (new String(header) + message).getBytes("UTF-8");
+ Os.sendto(sock, data, 0, data.length, 0, localAddr, encapSocket.getPort());
+
+ // Send IKE packet from the encap socket to itself. Since IKE is not
+ // transformed in any way, this should succeed.
+ header = new byte[] {0, 0, 0, 0};
+ message = "Sample IKE Packet";
+ data = (new String(header) + message).getBytes("UTF-8");
+ Os.sendto(
+ encapSocket.getSocket(),
+ data,
+ 0,
+ data.length,
+ 0,
+ localAddr,
+ encapSocket.getPort());
+
+ // ESP data should be dropped, due to different input SPI (as opposed to being
+ // readable from the encapSocket)
+ // Thus, only IKE data should be received from the socket.
+ // If the first four bytes are zero, assume non-ESP (IKE) traffic.
+ // Expect an nulled out SPI just as we sent out, without being modified.
+ byte[] in = new byte[4];
+ in[0] = 1; // Make sure the array has to be overwritten to pass
+ Os.read(encapSocket.getSocket(), in, 0, in.length);
+ assertTrue(
+ "Encap socket received UDP-encap-ESP data despite invalid SPIs",
+ Arrays.equals(header, in));
+
+ mISM.removeTransportModeTransforms(sock);
+ } finally {
+ if (sock != null) {
+ Os.close(sock);
+ }
+ }
+ }
+ }
+
+ private static IpSecTransform buildIpSecTransform(
+ Context mContext,
+ IpSecManager.SecurityParameterIndex spi,
+ IpSecManager.UdpEncapsulationSocket encapSocket,
+ InetAddress remoteAddr)
+ throws Exception {
+ String localAddr = (remoteAddr instanceof Inet4Address)
+ ? IPV4_LOOPBACK : IPV6_LOOPBACK;
+ return new IpSecTransform.Builder(mContext)
+ .setEncryption(
+ new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY))
+ .setAuthentication(
+ new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_SHA256, AUTH_KEY, AUTH_KEY.length * 4))
+ .setIpv4Encapsulation(encapSocket, encapSocket.getPort())
+ .buildTransportModeTransform(InetAddress.getByName(localAddr), spi);
+ }
+
+ private static int getPort(FileDescriptor sock) throws Exception {
+ return ((InetSocketAddress) Os.getsockname(sock)).getPort();
+ }
+}
diff --git a/tests/tests/opengl/libopengltest/Android.mk b/tests/tests/opengl/libopengltest/Android.mk
index f05fd8c..8c45c38 100755
--- a/tests/tests/opengl/libopengltest/Android.mk
+++ b/tests/tests/opengl/libopengltest/Android.mk
@@ -40,7 +40,8 @@
LOCAL_SHARED_LIBRARIES := libGLESv2 liblog
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
+LOCAL_CFLAGS += -Wno-sign-compare -Wno-unused-function -Wno-unused-variable
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/opengl/libopengltest/color_one.cpp b/tests/tests/opengl/libopengltest/color_one.cpp
index 27d400c..c56a937 100755
--- a/tests/tests/opengl/libopengltest/color_one.cpp
+++ b/tests/tests/opengl/libopengltest/color_one.cpp
@@ -111,7 +111,7 @@
glReadPixels(width/2, height/2, 1,1, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)&data);
- for(int i = 0; i < sizeof(data); i++){
+ for(size_t i = 0; i < sizeof(data); i++){
dataFloat[i] = data[i];
}
diff --git a/tests/tests/openglperf/jni/Android.mk b/tests/tests/openglperf/jni/Android.mk
index 3fe448a..fef30a1 100644
--- a/tests/tests/openglperf/jni/Android.mk
+++ b/tests/tests/openglperf/jni/Android.mk
@@ -28,6 +28,6 @@
LOCAL_SDK_VERSION := 14
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/os/assets/platform_versions.txt b/tests/tests/os/assets/platform_versions.txt
index 8104cab..52c184f 100644
--- a/tests/tests/os/assets/platform_versions.txt
+++ b/tests/tests/os/assets/platform_versions.txt
@@ -1 +1 @@
-8.1.0
+P
diff --git a/tests/tests/os/jni/Android.mk b/tests/tests/os/jni/Android.mk
index 68f839c..4e8e0c4 100644
--- a/tests/tests/os/jni/Android.mk
+++ b/tests/tests/os/jni/Android.mk
@@ -56,7 +56,16 @@
LOCAL_CFLAGS += -DARCH_SUPPORTS_SECCOMP
endif
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
+LOCAL_CFLAGS += -Wno-inline-asm -Wno-unused-const-variable
+
+# Let's overwrite -mcpu in case it's set to some ARMv8 core by
+# TARGET_2ND_CPU_VARIANT and causes clang to ignore the -march below.
LOCAL_CPPFLAGS_arm := -mcpu=generic
+# The ARM version of this library must be built using ARMv7 ISA (even if it
+# can be run on armv8 cores) since one of the tested instruction, swp, is
+# only supported in ARMv7 (and older) cores, and obsolete in ARMv8.
+LOCAL_CPPFLAGS_arm += -march=armv7-a
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/os/jni/android_os_cts_TaggedPointer.cpp b/tests/tests/os/jni/android_os_cts_TaggedPointer.cpp
index f656f50..dca6ae2 100644
--- a/tests/tests/os/jni/android_os_cts_TaggedPointer.cpp
+++ b/tests/tests/os/jni/android_os_cts_TaggedPointer.cpp
@@ -18,7 +18,6 @@
#include <inttypes.h>
#include <setjmp.h>
#include <signal.h>
-#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
diff --git a/tests/tests/os/src/android/os/cts/TokenWatcherTest.java b/tests/tests/os/src/android/os/cts/TokenWatcherTest.java
index 70e839a..312ea81 100644
--- a/tests/tests/os/src/android/os/cts/TokenWatcherTest.java
+++ b/tests/tests/os/src/android/os/cts/TokenWatcherTest.java
@@ -23,7 +23,6 @@
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
-import android.os.Message;
import android.os.RemoteException;
import android.os.TokenWatcher;
import android.test.AndroidTestCase;
@@ -159,6 +158,36 @@
assertTrue(waitUntilReleased());
}
+ public void testRepeatedAcquire() throws RemoteException, InterruptedException {
+ IBinder token = mEmptyService.getToken();
+ mMockTokenWatcher = new MockTokenWatcher(mHandler, TAG);
+ assertFalse(mMockTokenWatcher.isAcquired());
+ assertFalse(mMockTokenWatcher.isAcquiredCalled);
+ assertFalse(mMockTokenWatcher.isReleasedCalled);
+
+ // First time
+ mMockTokenWatcher.acquire(token, TAG);
+ assertTrue(mMockTokenWatcher.isAcquired());
+ assertTrue(waitUntilAcquired());
+
+ // Reset
+ mMockTokenWatcher.isAcquiredCalled = false;
+ mMockTokenWatcher.isReleasedCalled = false;
+
+ // Second time -- should be a no-op
+ mMockTokenWatcher.acquire(token, TAG);
+ assertTrue(mMockTokenWatcher.isAcquired());
+ assertFalse(waitUntilAcquired());
+ assertFalse(waitUntilReleased());
+
+ // Release
+ synchronized (mMockTokenWatcher) {
+ mMockTokenWatcher.release(token);
+ assertFalse(mMockTokenWatcher.isAcquired());
+ }
+ assertTrue(waitUntilReleased());
+ }
+
private boolean waitUntilAcquired() throws InterruptedException {
long time = System.currentTimeMillis();
while (System.currentTimeMillis() - time < OVERTIME) {
diff --git a/tests/tests/permission/jni/Android.mk b/tests/tests/permission/jni/Android.mk
index 2e64d47..1d4d77d 100644
--- a/tests/tests/permission/jni/Android.mk
+++ b/tests/tests/permission/jni/Android.mk
@@ -30,7 +30,8 @@
LOCAL_SHARED_LIBRARIES := libnativehelper_compat_libc++ liblog
LOCAL_SDK_VERSION := 23
LOCAL_CPPFLAGS := -std=gnu++11
+LOCAL_NDK_STL_VARIANT := c++_static
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/permission/jni/android_permission_cts_FileUtils.cpp b/tests/tests/permission/jni/android_permission_cts_FileUtils.cpp
index 0547be4..68c3c76 100644
--- a/tests/tests/permission/jni/android_permission_cts_FileUtils.cpp
+++ b/tests/tests/permission/jni/android_permission_cts_FileUtils.cpp
@@ -25,9 +25,9 @@
#include <grp.h>
#include <pwd.h>
#include <string.h>
-#include <ScopedLocalRef.h>
-#include <ScopedPrimitiveArray.h>
-#include <ScopedUtfChars.h>
+#include <nativehelper/ScopedLocalRef.h>
+#include <nativehelper/ScopedPrimitiveArray.h>
+#include <nativehelper/ScopedUtfChars.h>
static jfieldID gFileStatusDevFieldID;
static jfieldID gFileStatusInoFieldID;
@@ -106,7 +106,7 @@
{
__android_log_print(ANDROID_LOG_DEBUG, NULL,
"isPermittedCapBitSet(): getxattr(\"%s\") call failed: "
- "return %d (error: %s (%d))\n",
+ "return %zd (error: %s (%d))\n",
cPath.c_str(), result, strerror(errno), errno);
return false;
}
@@ -173,7 +173,7 @@
struct vfs_cap_data expectedCapData;
memset(&expectedCapData, 0, sizeof(expectedCapData));
- expectedCapData.magic_etc = VFS_CAP_REVISION | VFS_CAP_FLAGS_EFFECTIVE;
+ expectedCapData.magic_etc = VFS_CAP_REVISION_2 | VFS_CAP_FLAGS_EFFECTIVE;
if (!fillPermittedCaps(&expectedCapData, env, capIds))
{
// exception thrown
@@ -190,7 +190,7 @@
{
__android_log_print(ANDROID_LOG_DEBUG, NULL,
"fileHasOnly(): getxattr(\"%s\") call failed: "
- "return %d (error: %s (%d))\n",
+ "return %zd (error: %s (%d))\n",
cPath.c_str(), result, strerror(errno), errno);
return false;
}
diff --git a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
index a2b1b36..ae6123e 100644
--- a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
@@ -56,6 +56,7 @@
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Scanner;
import java.util.Set;
/**
@@ -65,6 +66,21 @@
*/
public class FileSystemPermissionTest extends AndroidTestCase {
+ private int dumpable;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ dumpable = Os.prctl(OsConstants.PR_GET_DUMPABLE, 0, 0, 0, 0);
+ Os.prctl(OsConstants.PR_SET_DUMPABLE, 1, 0, 0, 0);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ Os.prctl(OsConstants.PR_SET_DUMPABLE, dumpable, 0, 0, 0);
+ super.tearDown();
+ }
+
@MediumTest
public void testCreateFileHasSanePermissions() throws Exception {
File myFile = new File(getContext().getFilesDir(), "hello");
@@ -271,18 +287,58 @@
assertFileOwnedByGroup(f, "net_bw_stats");
}
- @MediumTest
- public void testProcSelfOomAdjSane() {
- File f = new File("/proc/self/oom_adj");
- assertFalse(f.canWrite());
- assertFalse(f.canExecute());
+ private static int readInt(File f) throws FileNotFoundException {
+ try (Scanner s = new Scanner(f)) {
+ return s.nextInt();
+ }
+ }
+
+ private static boolean writeInt(File f, int value) throws IOException {
+ try (FileOutputStream os = new FileOutputStream(f)) {
+ try {
+ os.write(Integer.toString(value).getBytes());
+ return true;
+ } catch (IOException e) {
+ return false;
+ }
+ }
}
@MediumTest
- public void testProcSelfOomScoreAdjSane() {
- File f = new File("/proc/self/oom_score_adj");
- assertFalse(f.canWrite());
+ public void testProcSelfOomAdjSane() throws IOException {
+ final int OOM_DISABLE = -17;
+
+ File f = new File("/proc/self/oom_adj");
+ assertTrue(f.canRead());
assertFalse(f.canExecute());
+
+ int oom_adj = readInt(f);
+ assertNotSame("unprivileged processes should not be unkillable", OOM_DISABLE, oom_adj);
+ if (f.canWrite())
+ assertFalse("unprivileged processes should not be able to reduce their oom_adj value",
+ writeInt(f, oom_adj - 1));
+ }
+
+ @MediumTest
+ public void testProcSelfOomScoreAdjSane() throws IOException {
+ final int OOM_SCORE_ADJ_MIN = -1000;
+
+ File f = new File("/proc/self/oom_score_adj");
+ assertTrue(f.canRead());
+ assertFalse(f.canExecute());
+
+ int oom_score_adj = readInt(f);
+ assertNotSame("unprivileged processes should not be unkillable", OOM_SCORE_ADJ_MIN, oom_score_adj);
+ if (f.canWrite()) {
+ assertFalse(
+ "unprivileged processes should not be able to reduce their oom_score_adj value",
+ writeInt(f, oom_score_adj - 1));
+ assertTrue(
+ "unprivileged processes should be able to increase their oom_score_adj value",
+ writeInt(f, oom_score_adj + 1));
+ assertTrue("unprivileged processes should be able to restore their oom_score_adj value",
+ writeInt(f, oom_score_adj));
+ }
}
private static List<Pair<Long, Long>> mappedPageRanges() throws IOException {
@@ -326,7 +382,14 @@
byte bytes[] = new byte[SIZEOF_U64];
ByteBuffer buf = ByteBuffer.wrap(bytes).order(ByteOrder.nativeOrder());
int read = Os.read(pagemap, buf);
- if (read != bytes.length)
+
+ if (read == 0)
+ // /proc/[pid]/maps may contain entries that are outside the process's VM space,
+ // like the [vectors] page on 32-bit ARM devices. In this case, seek() succeeds but
+ // read() returns 0. The kernel is telling us that there are no more pagemap
+ // entries to read, so we can stop here.
+ break;
+ else if (read != bytes.length)
throw new IOException("read(" + bytes.length + ") returned " + read);
buf.position(0);
@@ -341,9 +404,6 @@
@MediumTest
public void testProcSelfPagemapSane() throws ErrnoException, IOException {
FileDescriptor pagemap = null;
- int dumpable = Os.prctl(OsConstants.PR_GET_DUMPABLE, 0, 0, 0, 0);
- Os.prctl(OsConstants.PR_SET_DUMPABLE, 1, 0, 0, 0);
-
try {
pagemap = Os.open("/proc/self/pagemap", OsConstants.O_RDONLY, 0);
@@ -360,7 +420,6 @@
} finally {
if (pagemap != null)
Os.close(pagemap);
- Os.prctl(OsConstants.PR_SET_DUMPABLE, dumpable, 0, 0, 0);
}
}
@@ -868,6 +927,21 @@
assertTrue("rootfs is not mounted read-only", (vfs.f_flag & OsConstants.ST_RDONLY) != 0);
}
+ public void testVendorMountedRO() throws Exception {
+ StructStatVfs vfs = Os.statvfs("/vendor");
+ assertTrue("/vendor is not mounted read-only", (vfs.f_flag & OsConstants.ST_RDONLY) != 0);
+ }
+
+ public void testOdmMountedRO() throws Exception {
+ StructStatVfs vfs = Os.statvfs("/odm");
+ assertTrue("/odm is not mounted read-only", (vfs.f_flag & OsConstants.ST_RDONLY) != 0);
+ }
+
+ public void testOemMountedRO() throws Exception {
+ StructStatVfs vfs = Os.statvfs("/oem");
+ assertTrue("/oem is not mounted read-only", (vfs.f_flag & OsConstants.ST_RDONLY) != 0);
+ }
+
public void testDataMountedNoSuidNoDev() throws Exception {
StructStatVfs vfs = Os.statvfs(getContext().getFilesDir().getAbsolutePath());
assertTrue("/data is not mounted NOSUID", (vfs.f_flag & OsConstants.ST_NOSUID) != 0);
diff --git a/tests/tests/permission2/res/raw/android_manifest.xml b/tests/tests/permission2/res/raw/android_manifest.xml
index b23c6ab..a4dad83 100644
--- a/tests/tests/permission2/res/raw/android_manifest.xml
+++ b/tests/tests/permission2/res/raw/android_manifest.xml
@@ -204,8 +204,8 @@
android:name="com.android.bluetooth.BluetoothMapContentObserver.action.MESSAGE_DELIVERY" />
<protected-broadcast
android:name="android.bluetooth.pan.profile.action.CONNECTION_STATE_CHANGED" />
- <protected-broadcast android:name="android.bluetooth.pbap.intent.action.PBAP_STATE_CHANGED" />
<protected-broadcast android:name="android.bluetooth.pbap.profile.action.CONNECTION_STATE_CHANGED" />
+ <protected-broadcast android:name="android.bluetooth.pbapclient.profile.action.CONNECTION_STATE_CHANGED" />
<protected-broadcast android:name="android.bluetooth.sap.profile.action.CONNECTION_STATE_CHANGED" />
<protected-broadcast android:name="android.btopp.intent.action.INCOMING_FILE_NOTIFICATION" />
<protected-broadcast android:name="android.btopp.intent.action.USER_CONFIRMATION_TIMEOUT" />
diff --git a/tests/tests/renderscript/libcoremathtestcpp/Android.mk b/tests/tests/renderscript/libcoremathtestcpp/Android.mk
index ad528571..c6ebfe3 100644
--- a/tests/tests/renderscript/libcoremathtestcpp/Android.mk
+++ b/tests/tests/renderscript/libcoremathtestcpp/Android.mk
@@ -22,10 +22,10 @@
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := CoreMathTestJni.cpp
-LOCAL_CFLAGS := -std=c++11
+LOCAL_CFLAGS := -std=c++11 -Wall -Werror
LOCAL_SDK_VERSION := 21
-LOCAL_NDK_STL_VARIANT := stlport_static
+LOCAL_NDK_STL_VARIANT := c++_static
LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
LOCAL_C_INCLUDES += frameworks/rs/cpp
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/CoreMathVerifier.java b/tests/tests/renderscript/src/android/renderscript/cts/CoreMathVerifier.java
index bc13144..cf535e8 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/CoreMathVerifier.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/CoreMathVerifier.java
@@ -3045,9 +3045,9 @@
RemquoResult expected = remquo(args.inNumerator, args.inDenominator);
// If the expected remainder is NaN, we don't validate the quotient. It's because of
// a division by zero.
- if (expected.remainder != expected.remainder) {
+ if (Float.isNaN(expected.remainder)) {
// Check that the value we got is NaN too.
- if (args.out == args.out) {
+ if (!Float.isNaN(args.out)) {
return "Expected a remainder of NaN but got " + Float.toString(args.out);
}
} else {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/Target.java b/tests/tests/renderscript/src/android/renderscript/cts/Target.java
index 55d3712..3ac4ff8 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/Target.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/Target.java
@@ -341,7 +341,7 @@
mHasRange = false;
mValue = values[0];
for (double f: values) {
- if (f != f) {
+ if (Double.isNaN(f)) {
mCanBeNan = true;
continue;
}
@@ -573,7 +573,7 @@
public boolean couldBe(double a, double extraAllowedError) {
//Log.w("Floaty.couldBe", "Can " + Double.toString(a) + " be " + toString() + "? ");
// Handle the input being a NaN.
- if (a != a) {
+ if (Double.isNaN(a)) {
//Log.w("couldBe", "true because is Naan");
return mCanBeNan;
}
diff --git a/tests/tests/rsblas/libbnnmdata/Android.mk b/tests/tests/rsblas/libbnnmdata/Android.mk
index bbfd289..6a5e542 100644
--- a/tests/tests/rsblas/libbnnmdata/Android.mk
+++ b/tests/tests/rsblas/libbnnmdata/Android.mk
@@ -14,7 +14,6 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
-LOCAL_CLANG := true
LOCAL_MODULE := libbnnmdata_jni
LOCAL_MODULE_TAGS := optional
@@ -22,6 +21,7 @@
LOCAL_SDK_VERSION := 23
LOCAL_NDK_STL_VARIANT := c++_static
+LOCAL_CFLAGS := -Wall -Werror -Wno-unused-const-variable
LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/rscpp/librscpptest/Android.mk b/tests/tests/rscpp/librscpptest/Android.mk
index 5621c02..633ee23 100644
--- a/tests/tests/rscpp/librscpptest/Android.mk
+++ b/tests/tests/rscpp/librscpptest/Android.mk
@@ -18,7 +18,6 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_CLANG := true
LOCAL_MODULE := librscpptest_jni
LOCAL_MODULE_TAGS := optional
@@ -46,14 +45,14 @@
LOCAL_C_INCLUDES += frameworks/rs
LOCAL_CPPFLAGS := -std=c++11
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
LOCAL_SHARED_LIBRARIES := libdl liblog
LOCAL_STATIC_LIBRARIES := libRScpp_static
LOCAL_SDK_VERSION := 21
-LOCAL_NDK_STL_VARIANT := stlport_static
+LOCAL_NDK_STL_VARIANT := c++_static
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/security/Android.mk b/tests/tests/security/Android.mk
index 56bc908..b22f6c7 100644
--- a/tests/tests/security/Android.mk
+++ b/tests/tests/security/Android.mk
@@ -51,7 +51,7 @@
#LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/security/jni/Android.mk b/tests/tests/security/jni/Android.mk
index dd069fe..fe4f779 100644
--- a/tests/tests/security/jni/Android.mk
+++ b/tests/tests/security/jni/Android.mk
@@ -46,6 +46,7 @@
LOCAL_C_INCLUDES += ndk/sources/cpufeatures
LOCAL_STATIC_LIBRARIES := cpufeatures
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
+LOCAL_CFLAGS += -Wno-sign-compare -Wno-unused-label -Wno-unused-variable
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/security/jni/android_security_cts_EncryptionTest.cpp b/tests/tests/security/jni/android_security_cts_EncryptionTest.cpp
index 136b52b..47f760a 100644
--- a/tests/tests/security/jni/android_security_cts_EncryptionTest.cpp
+++ b/tests/tests/security/jni/android_security_cts_EncryptionTest.cpp
@@ -18,7 +18,7 @@
#include <cutils/log.h>
#include <cutils/properties.h>
#include <jni.h>
-#include <JNIHelp.h>
+#include <nativehelper/JNIHelp.h>
#include <openssl/aes.h>
#include <openssl/cpu.h>
#include <openssl/evp.h>
diff --git a/tests/tests/security/jni/android_security_cts_SELinuxTest.cpp b/tests/tests/security/jni/android_security_cts_SELinuxTest.cpp
index 1cfde0a..c7975ec 100644
--- a/tests/tests/security/jni/android_security_cts_SELinuxTest.cpp
+++ b/tests/tests/security/jni/android_security_cts_SELinuxTest.cpp
@@ -15,10 +15,10 @@
*/
#include <jni.h>
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/ScopedLocalRef.h>
+#include <nativehelper/ScopedUtfChars.h>
#include <selinux/selinux.h>
-#include <JNIHelp.h>
-#include <ScopedLocalRef.h>
-#include <ScopedUtfChars.h>
#include <memory>
diff --git a/tests/tests/security/res/raw/b38116746_new.ico b/tests/tests/security/res/raw/b38116746_new.ico
deleted file mode 100644
index 35ee5b5..0000000
--- a/tests/tests/security/res/raw/b38116746_new.ico
+++ /dev/null
Binary files differ
diff --git a/tests/tests/security/src/android/security/cts/BitmapFactorySecurityTests.java b/tests/tests/security/src/android/security/cts/BitmapFactorySecurityTests.java
index 203db12..c8bfbb1 100644
--- a/tests/tests/security/src/android/security/cts/BitmapFactorySecurityTests.java
+++ b/tests/tests/security/src/android/security/cts/BitmapFactorySecurityTests.java
@@ -17,56 +17,30 @@
package android.security.cts;
import android.graphics.BitmapFactory;
-import android.os.ParcelFileDescriptor;
import android.platform.test.annotations.SecurityTest;
import android.test.AndroidTestCase;
-import java.io.File;
-import java.io.FileDescriptor;
-import java.io.FileOutputStream;
import java.io.InputStream;
-import java.lang.Exception;
-
import android.security.cts.R;
@SecurityTest
public class BitmapFactorySecurityTests extends AndroidTestCase {
- private FileDescriptor getResource(int resId) {
- try {
- InputStream is = mContext.getResources().openRawResource(resId);
- assertNotNull(is);
- File file = File.createTempFile("BitmapFactorySecurityFile" + resId, "img");
- file.deleteOnExit();
- FileOutputStream output = new FileOutputStream(file);
- byte[] buffer = new byte[1024];
- int readLength;
- while ((readLength = is.read(buffer)) != -1) {
- output.write(buffer, 0, readLength);
- }
- is.close();
- output.close();
- ParcelFileDescriptor pfd = ParcelFileDescriptor.open(file,
- ParcelFileDescriptor.MODE_READ_ONLY);
- return pfd.getFileDescriptor();
- } catch (Exception e) {
- fail("Could not get resource " + resId + "! " + e);
- return null;
- }
+ private InputStream getResource(int resId) {
+ InputStream resource = mContext.getResources().openRawResource(R.raw.bug_38116746);
+ assertNotNull(resource);
+ return resource;
}
/**
- * Verifies that decoding a corrupt ICO does crash.
+ * Verifies that decoding a corrupt ICO does not run out of memory.
*/
public void test_android_bug_38116746() {
- FileDescriptor exploitImage = getResource(R.raw.bug_38116746);
+ InputStream exploitImage = getResource(R.raw.bug_38116746);
try {
- BitmapFactory.decodeFileDescriptor(exploitImage);
+ BitmapFactory.decodeStream(exploitImage);
} catch (OutOfMemoryError e) {
fail("OOM attempting to decode ICO");
}
-
- // This previously crashed in fread. No need to check the output.
- BitmapFactory.decodeFileDescriptor(getResource(R.raw.b38116746_new));
}
}
diff --git a/tests/tests/security/src/android/security/cts/CryptoProviderWorkaroundTest.java b/tests/tests/security/src/android/security/cts/CryptoProviderWorkaroundTest.java
deleted file mode 100644
index 861c443..0000000
--- a/tests/tests/security/src/android/security/cts/CryptoProviderWorkaroundTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2016 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.security.cts;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-import dalvik.system.VMRuntime;
-import java.security.NoSuchProviderException;
-import java.security.SecureRandom;
-import java.security.Security;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-/**
- * http://b/28550092 : Removal of "Crypto" provider in N caused application compatibility
- * issues for callers of SecureRandom. To improve compatibility the provider is not registered
- * as a JCA Provider obtainable via Security.getProvider() but is made available for
- * SecureRandom.getInstance() iff the application targets API <= 23.
- */
-@RunWith(JUnit4.class)
-public class CryptoProviderWorkaroundTest {
- @Test
- public void cryptoProvider_withWorkaround_Success() throws Exception {
- // Assert that SecureRandom is still using the default value. Sanity check.
- assertEquals(SecureRandom.DEFAULT_SDK_TARGET_FOR_CRYPTO_PROVIDER_WORKAROUND,
- SecureRandom.getSdkTargetForCryptoProviderWorkaround());
-
- try {
- // Modify the maximum target SDK to apply the workaround, thereby enabling the
- // workaround for the current SDK and enabling it to be tested.
- SecureRandom.setSdkTargetForCryptoProviderWorkaround(
- VMRuntime.getRuntime().getTargetSdkVersion());
-
- // Assert that the crypto provider is not installed...
- assertNull(Security.getProvider("Crypto"));
- SecureRandom sr = SecureRandom.getInstance("SHA1PRNG", "Crypto");
- assertNotNull(sr);
- // ...but we can get a SecureRandom from it...
- assertEquals("org.apache.harmony.security.provider.crypto.CryptoProvider",
- sr.getProvider().getClass().getName());
- // ...yet it's not installed. So the workaround worked.
- assertNull(Security.getProvider("Crypto"));
- } finally {
- // Reset the target SDK for the workaround to the default / real value.
- SecureRandom.setSdkTargetForCryptoProviderWorkaround(
- SecureRandom.DEFAULT_SDK_TARGET_FOR_CRYPTO_PROVIDER_WORKAROUND);
- }
- }
-
- @Test
- public void cryptoProvider_withoutWorkaround_Failure() throws Exception {
- // Assert that SecureRandom is still using the default value. Sanity check.
- assertEquals(SecureRandom.DEFAULT_SDK_TARGET_FOR_CRYPTO_PROVIDER_WORKAROUND,
- SecureRandom.getSdkTargetForCryptoProviderWorkaround());
-
- try {
- // We set the limit SDK for the workaround at the previous one, indicating that the
- // workaround shouldn't be in place.
- SecureRandom.setSdkTargetForCryptoProviderWorkaround(
- VMRuntime.getRuntime().getTargetSdkVersion() - 1);
-
- SecureRandom sr = SecureRandom.getInstance("SHA1PRNG", "Crypto");
- fail("Should throw " + NoSuchProviderException.class.getName());
- } catch(NoSuchProviderException expected) {
- // The workaround doesn't work. As expected.
- } finally {
- // Reset the target SDK for the workaround to the default / real value.
- SecureRandom.setSdkTargetForCryptoProviderWorkaround(
- SecureRandom.DEFAULT_SDK_TARGET_FOR_CRYPTO_PROVIDER_WORKAROUND);
- }
- }
-}
diff --git a/tests/tests/security/testeffect/Android.mk b/tests/tests/security/testeffect/Android.mk
index 7e4ab93..0784b5d 100644
--- a/tests/tests/security/testeffect/Android.mk
+++ b/tests/tests/security/testeffect/Android.mk
@@ -28,6 +28,6 @@
LOCAL_C_INCLUDES := \
$(call include-path-for, audio-effects)
-LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter -Wno-gnu-designator
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/simpleperf/Android.mk b/tests/tests/simpleperf/Android.mk
index eaec920..ddbb26a 100644
--- a/tests/tests/simpleperf/Android.mk
+++ b/tests/tests/simpleperf/Android.mk
@@ -19,6 +19,7 @@
libbacktrace_offline \
libbacktrace \
libunwind \
+ libunwindstack \
libziparchive \
libz \
libgtest \
diff --git a/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java b/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
index 93e4c65..ea29552 100644
--- a/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
+++ b/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
@@ -15,18 +15,21 @@
*/
package android.telecom.cts;
+
import static android.telecom.cts.TestUtils.PACKAGE;
import static android.telecom.cts.TestUtils.TAG;
import static android.telecom.cts.TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS;
-import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerThread;
import android.telecom.Call;
import android.telecom.CallAudioState;
import android.telecom.Conference;
@@ -37,13 +40,18 @@
import android.telecom.TelecomManager;
import android.telecom.VideoProfile;
import android.telecom.cts.MockInCallService.InCallServiceCallbacks;
+import android.telephony.PhoneStateListener;
+import android.telephony.TelephonyManager;
import android.test.InstrumentationTestCase;
import android.text.TextUtils;
import android.util.Log;
+import android.util.Pair;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
/**
@@ -59,6 +67,7 @@
Context mContext;
TelecomManager mTelecomManager;
+ TelephonyManager mTelephonyManager;
TestUtils.InvokeCounter mOnBringToForegroundCounter;
TestUtils.InvokeCounter mOnCallAudioStateChangedCounter;
@@ -79,33 +88,86 @@
String mPreviousDefaultDialer = null;
MockConnectionService connectionService = null;
+ HandlerThread mPhoneStateListenerThread;
+ Handler mPhoneStateListenerHandler;
+ TestPhoneStateListener mPhoneStateListener;
+
+ static class TestPhoneStateListener extends PhoneStateListener {
+ /** Semaphore released for every callback invocation. */
+ public Semaphore mCallbackSemaphore = new Semaphore(0);
+
+ List<Pair<Integer, String>> mCallStates = new ArrayList<>();
+
+ @Override
+ public void onCallStateChanged(int state, String number) {
+ mCallStates.add(Pair.create(state, number));
+ mCallbackSemaphore.release();
+ }
+ }
+
boolean mShouldTestTelecom = true;
@Override
protected void setUp() throws Exception {
super.setUp();
mContext = getInstrumentation().getContext();
- mTelecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
mShouldTestTelecom = TestUtils.shouldTestTelecom(mContext);
- if (mShouldTestTelecom) {
- mPreviousDefaultDialer = TestUtils.getDefaultDialer(getInstrumentation());
- TestUtils.setDefaultDialer(getInstrumentation(), PACKAGE);
- setupCallbacks();
+ if (!mShouldTestTelecom) {
+ return;
}
+
+ mTelecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
+ mTelephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+
+ mPreviousDefaultDialer = TestUtils.getDefaultDialer(getInstrumentation());
+ TestUtils.setDefaultDialer(getInstrumentation(), PACKAGE);
+ setupCallbacks();
+
+ // PhoneStateListener's public API registers the listener on the calling thread, which must
+ // be a looper thread. So we need to create and register the listener in a custom looper
+ // thread.
+ mPhoneStateListenerThread = new HandlerThread("PhoneStateListenerThread");
+ mPhoneStateListenerThread.start();
+ mPhoneStateListenerHandler = new Handler(mPhoneStateListenerThread.getLooper());
+ final CountDownLatch registeredLatch = new CountDownLatch(1);
+ mPhoneStateListenerHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mPhoneStateListener = new TestPhoneStateListener();
+ mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
+ registeredLatch.countDown();
+ }
+ });
+ registeredLatch.await(
+ TestUtils.WAIT_FOR_PHONE_STATE_LISTENER_REGISTERED_TIMEOUT_S, TimeUnit.SECONDS);
}
@Override
protected void tearDown() throws Exception {
- if (mShouldTestTelecom) {
- cleanupCalls();
- if (!TextUtils.isEmpty(mPreviousDefaultDialer)) {
- TestUtils.setDefaultDialer(getInstrumentation(), mPreviousDefaultDialer);
- }
- tearDownConnectionService(TestUtils.TEST_PHONE_ACCOUNT_HANDLE);
- assertMockInCallServiceUnbound();
- }
super.tearDown();
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
+ final CountDownLatch unregisteredLatch = new CountDownLatch(1);
+ mPhoneStateListenerHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
+ unregisteredLatch.countDown();
+ }
+ });
+ unregisteredLatch.await(
+ TestUtils.WAIT_FOR_PHONE_STATE_LISTENER_REGISTERED_TIMEOUT_S, TimeUnit.SECONDS);
+ mPhoneStateListenerThread.quit();
+
+ cleanupCalls();
+ if (!TextUtils.isEmpty(mPreviousDefaultDialer)) {
+ TestUtils.setDefaultDialer(getInstrumentation(), mPreviousDefaultDialer);
+ }
+ tearDownConnectionService(TestUtils.TEST_PHONE_ACCOUNT_HANDLE);
+ assertMockInCallServiceUnbound();
}
protected PhoneAccount setupConnectionService(MockConnectionService connectionService,
@@ -506,6 +568,14 @@
assertConferenceState(conference, Connection.STATE_ACTIVE);
}
+ void verifyPhoneStateListenerCallbacksForCall(int expectedCallState) throws Exception {
+ assertTrue(mPhoneStateListener.mCallbackSemaphore.tryAcquire(
+ TestUtils.WAIT_FOR_PHONE_STATE_LISTENER_CALLBACK_TIMEOUT_S, TimeUnit.SECONDS));
+ Pair<Integer, String> callState = mPhoneStateListener.mCallStates.get(0);
+ assertEquals(expectedCallState, (int) callState.first);
+ assertEquals(getTestNumber().getSchemeSpecificPart(), callState.second);
+ }
+
/**
* Disconnect the created test call and verify that Telecom has cleared all calls.
*/
diff --git a/tests/tests/telecom/src/android/telecom/cts/CtsSelfManagedConnectionService.java b/tests/tests/telecom/src/android/telecom/cts/CtsSelfManagedConnectionService.java
index fada275..16e7b27 100644
--- a/tests/tests/telecom/src/android/telecom/cts/CtsSelfManagedConnectionService.java
+++ b/tests/tests/telecom/src/android/telecom/cts/CtsSelfManagedConnectionService.java
@@ -133,6 +133,9 @@
connection.putExtras(moreExtras);
connection.setVideoState(request.getVideoState());
+ if (!isIncoming) {
+ connection.setInitializing();
+ }
synchronized(mLock) {
mConnections.add(connection);
}
diff --git a/tests/tests/telecom/src/android/telecom/cts/IncomingCallTest.java b/tests/tests/telecom/src/android/telecom/cts/IncomingCallTest.java
index f3ffeaa..472b03b 100644
--- a/tests/tests/telecom/src/android/telecom/cts/IncomingCallTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/IncomingCallTest.java
@@ -16,17 +16,18 @@
package android.telecom.cts;
+import static android.telecom.cts.TestUtils.COMPONENT;
+import static android.telecom.cts.TestUtils.PACKAGE;
+
import android.content.ComponentName;
import android.os.Bundle;
import android.telecom.Connection;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
+import android.telephony.TelephonyManager;
import java.util.Collection;
-import static android.telecom.cts.TestUtils.COMPONENT;
-import static android.telecom.cts.TestUtils.PACKAGE;
-
/**
* Tests valid/invalid incoming calls that are received from the ConnectionService
* and registered through TelecomManager
@@ -36,12 +37,6 @@
private static final PhoneAccountHandle TEST_INVALID_HANDLE = new PhoneAccountHandle(
new ComponentName(PACKAGE, COMPONENT), "WRONG_ID");
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mContext = getInstrumentation().getContext();
- }
-
public void testAddNewIncomingCall_CorrectPhoneAccountHandle() throws Exception {
if (!mShouldTestTelecom) {
return;
@@ -54,6 +49,16 @@
assertTrue(connections.contains(connection3));
}
+ public void testPhoneStateListenerInvokedOnIncomingCall() throws Exception {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+ setupConnectionService(null, FLAG_REGISTER | FLAG_ENABLE);
+ addAndVerifyNewIncomingCall(createTestNumber(), null);
+ verifyConnectionForIncomingCall();
+ verifyPhoneStateListenerCallbacksForCall(TelephonyManager.CALL_STATE_RINGING);
+ }
+
/**
* Tests to be sure that new incoming calls can only be added using a valid PhoneAccountHandle
* (b/26864502). If a PhoneAccount has not been registered for the PhoneAccountHandle, then
diff --git a/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java b/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java
index 38a6709..6df32f8 100644
--- a/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java
@@ -16,13 +16,12 @@
package android.telecom.cts;
-import static android.telecom.cts.TestUtils.shouldTestTelecom;
-
import android.content.Context;
import android.media.AudioManager;
import android.os.Bundle;
import android.telecom.CallAudioState;
import android.telecom.TelecomManager;
+import android.telephony.TelephonyManager;
/**
* Verifies the behavior of Telecom during various outgoing call flows.
@@ -94,4 +93,14 @@
}
assertNotAudioRoute(mInCallCallbacks.getService(), CallAudioState.ROUTE_SPEAKER);
}
+
+ public void testPhoneStateListenerInvokedOnOutgoingCall() throws Exception {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
+ placeAndVerifyCall();
+ verifyConnectionForOutgoingCall();
+ verifyPhoneStateListenerCallbacksForCall(TelephonyManager.CALL_STATE_OFFHOOK);
+ }
}
diff --git a/tests/tests/telecom/src/android/telecom/cts/TestUtils.java b/tests/tests/telecom/src/android/telecom/cts/TestUtils.java
index 5c67190..ac717d7 100644
--- a/tests/tests/telecom/src/android/telecom/cts/TestUtils.java
+++ b/tests/tests/telecom/src/android/telecom/cts/TestUtils.java
@@ -15,8 +15,6 @@
*/
package android.telecom.cts;
-import com.android.compatibility.common.util.ApiLevelUtil;
-
import android.app.Instrumentation;
import android.content.ComponentName;
import android.content.Context;
@@ -28,7 +26,6 @@
import android.os.Handler;
import android.os.Looper;
import android.os.ParcelFileDescriptor;
-import android.os.Process;
import android.os.SystemClock;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
@@ -53,6 +50,8 @@
static final long WAIT_FOR_STATE_CHANGE_TIMEOUT_MS = 10000;
static final long WAIT_FOR_CALL_ADDED_TIMEOUT_S = 15;
static final long WAIT_FOR_STATE_CHANGE_TIMEOUT_CALLBACK = 50;
+ static final long WAIT_FOR_PHONE_STATE_LISTENER_REGISTERED_TIMEOUT_S = 15;
+ static final long WAIT_FOR_PHONE_STATE_LISTENER_CALLBACK_TIMEOUT_S = 15;
// Non-final to allow modification by tests not in this package (e.g. permission-related
// tests in the Telecom2 test package.
diff --git a/tests/tests/telephony/Android.mk b/tests/tests/telephony/Android.mk
index 1368573..7bd88fe 100644
--- a/tests/tests/telephony/Android.mk
+++ b/tests/tests/telephony/Android.mk
@@ -31,7 +31,11 @@
LOCAL_HOST_SHARED_LIBRARIES := compatibility-device-telephony-preconditions
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_SRC_FILES := $(call all-java-files-under, src) \
+ $(call all-java-files-under, EmbmsMiddlewareTestApp) \
+ $(call all-Iaidl-files-under, EmbmsMiddlewareTestApp)
+
+LOCAL_AIDL_INCLUDES := EmbmsMiddlewareTestApp/aidl/
LOCAL_PACKAGE_NAME := CtsTelephonyTestCases
diff --git a/tests/tests/telephony/AndroidManifest.xml b/tests/tests/telephony/AndroidManifest.xml
index 38d20c6..a50329a 100644
--- a/tests/tests/telephony/AndroidManifest.xml
+++ b/tests/tests/telephony/AndroidManifest.xml
@@ -30,7 +30,10 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
+ <uses-permission android:name="android.telephony.embms.cts.permission.TEST_BROADCAST"/>
+ <permission android:name="android.telephony.embms.cts.permission.TEST_BROADCAST"
+ android:protectionLevel="signature"/>
<application>
<provider android:name="android.telephony.cts.MmsPduProvider"
android:authorities="telephonyctstest"
@@ -127,6 +130,30 @@
</activity>
<uses-library android:name="android.test.runner" />
+
+
+ <!-- This is the receiver defined by the MBMS api. -->
+ <receiver
+ android:name="android.telephony.mbms.MbmsDownloadReceiver"
+ android:permission="android.telephony.cts.embmstestapp.CTS_DOWNLOAD_PERMISSION"
+ android:enabled="true"
+ android:exported="true">
+ </receiver>
+
+ <provider
+ android:name="android.telephony.mbms.MbmsTempFileProvider"
+ android:authorities="android.telephony.mbms.cts"
+ android:exported="false"
+ android:grantUriPermissions="true">
+ </provider>
+
+ <meta-data android:name="mbms-streaming-service-override"
+ android:value="android.telephony.cts.embmstestapp/.CtsStreamingService"/>
+ <meta-data android:name="mbms-download-service-override"
+ android:value="android.telephony.cts.embmstestapp/.CtsDownloadService"/>
+ <meta-data
+ android:name="mbms-file-provider-authority"
+ android:value="android.telephony.mbms.cts"/>
</application>
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
diff --git a/tests/tests/telephony/AndroidTest.xml b/tests/tests/telephony/AndroidTest.xml
index 41cf7ce..1e48ebf 100644
--- a/tests/tests/telephony/AndroidTest.xml
+++ b/tests/tests/telephony/AndroidTest.xml
@@ -25,6 +25,7 @@
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsTelephonyTestCases.apk" />
+ <option name="test-file-name" value="EmbmsMiddlewareCtsTestApp.apk"/>
</target_preparer>
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="android.telephony.cts" />
diff --git a/tests/tests/telephony/EmbmsMiddlewareTestApp/Android.mk b/tests/tests/telephony/EmbmsMiddlewareTestApp/Android.mk
new file mode 100644
index 0000000..cbd18b2
--- /dev/null
+++ b/tests/tests/telephony/EmbmsMiddlewareTestApp/Android.mk
@@ -0,0 +1,21 @@
+LOCAL_PATH:= $(call my-dir)
+
+# Build the Sample Embms Services
+include $(CLEAR_VARS)
+
+src_dirs := src
+
+LOCAL_SRC_FILES := $(call all-java-files-under, $(src_dirs)) \
+ $(call all-Iaidl-files-under, aidl)
+
+LOCAL_AIDL_INCLUDES := aidl/
+
+LOCAL_PACKAGE_NAME := EmbmsMiddlewareCtsTestApp
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_SDK_VERSION := test_current
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_PROGUARD_ENABLED := disabled
+include $(BUILD_PACKAGE)
diff --git a/tests/tests/telephony/EmbmsMiddlewareTestApp/AndroidManifest.xml b/tests/tests/telephony/EmbmsMiddlewareTestApp/AndroidManifest.xml
new file mode 100644
index 0000000..0ea1be2
--- /dev/null
+++ b/tests/tests/telephony/EmbmsMiddlewareTestApp/AndroidManifest.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.telephony.cts.embmstestapp">
+ <permission android:name="android.telephony.cts.embmstestapp.CTS_DOWNLOAD_PERMISSION"
+ android.protectionLevel="signature"/>
+
+ <uses-permission android:name="android.telephony.cts.embms.permission.SEND_EMBMS_INTENTS"/>
+ <uses-permission android:name="android.telephony.cts.embmstestapp.CTS_DOWNLOAD_PERMISSION"/>
+
+ <application android:label="EmbmsCtsMiddleware">
+ <service android:name="android.telephony.cts.embmstestapp.CtsStreamingService"
+ android:launchMode="singleInstance">
+ <intent-filter>
+ <action android:name="android.telephony.action.EmbmsStreaming" />
+ <action android:name="android.telephony.cts.embmstestapp.ACTION_CONTROL_MIDDLEWARE" />
+ </intent-filter>
+ </service>
+ <service android:name="android.telephony.cts.embmstestapp.CtsDownloadService"
+ android:launchMode="singleInstance">
+ <intent-filter>
+ <action android:name="android.telephony.action.EmbmsDownload" />
+ <action android:name="android.telephony.cts.embmstestapp.ACTION_CONTROL_MIDDLEWARE" />
+ </intent-filter>
+ </service>
+ </application>
+</manifest>
+
diff --git a/tests/tests/telephony/EmbmsMiddlewareTestApp/aidl/android/telephony/cts/embmstestapp/ICtsDownloadMiddlewareControl.aidl b/tests/tests/telephony/EmbmsMiddlewareTestApp/aidl/android/telephony/cts/embmstestapp/ICtsDownloadMiddlewareControl.aidl
new file mode 100644
index 0000000..833ac74
--- /dev/null
+++ b/tests/tests/telephony/EmbmsMiddlewareTestApp/aidl/android/telephony/cts/embmstestapp/ICtsDownloadMiddlewareControl.aidl
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package android.telephony.cts.embmstestapp;
+
+import android.os.Bundle;
+import android.telephony.mbms.DownloadRequest;
+import android.telephony.mbms.FileInfo;
+
+interface ICtsDownloadMiddlewareControl {
+ // Resets the state of the CTS middleware
+ void reset();
+ // Get a list of calls made to the middleware binder.
+ // Looks like List<List<Object>>, where the first Object is always a String corresponding to
+ // the method name.
+ List<Bundle> getDownloadSessionCalls();
+ // Force all methods that can return an error to return this error.
+ void forceErrorCode(int error);
+ // Fire the error callback on the download session
+ void fireErrorOnSession(int errorCode, String message);
+ // Fire the download state callback methods
+ void fireOnProgressUpdated(in DownloadRequest request, in FileInfo fileInfo,
+ int currentDownloadSize, int fullDownloadSize,
+ int currentDecodedSize, int fullDecodedSize);
+ void fireOnStateUpdated(in DownloadRequest request, in FileInfo fileInfo, int state);
+
+ // calling download() does nothing, this is to actually start the file-download flow.
+ void actuallyStartDownloadFlow();
+}
\ No newline at end of file
diff --git a/tests/tests/telephony/EmbmsMiddlewareTestApp/aidl/android/telephony/cts/embmstestapp/ICtsStreamingMiddlewareControl.aidl b/tests/tests/telephony/EmbmsMiddlewareTestApp/aidl/android/telephony/cts/embmstestapp/ICtsStreamingMiddlewareControl.aidl
new file mode 100644
index 0000000..b882e23
--- /dev/null
+++ b/tests/tests/telephony/EmbmsMiddlewareTestApp/aidl/android/telephony/cts/embmstestapp/ICtsStreamingMiddlewareControl.aidl
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package android.telephony.cts.embmstestapp;
+
+import android.os.Parcel;
+
+interface ICtsStreamingMiddlewareControl {
+ // Resets the state of the CTS middleware
+ void reset();
+ // Get a list of calls made to the middleware binder.
+ // Looks like List<List<Object>>, where the first Object is always a String corresponding to
+ // the method name.
+ List getStreamingSessionCalls();
+ // Force all methods that can return an error to return this error.
+ void forceErrorCode(int error);
+ // Fire the error callback on the current active stream
+ void fireErrorOnStream(int errorCode, String message);
+ // Fire the error callback on the streaming session
+ void fireErrorOnSession(int errorCode, String message);
+ // The following fire callbacks on the active stream, using the provided arguments
+ void fireOnMediaDescriptionUpdated();
+ void fireOnBroadcastSignalStrengthUpdated(int signalStrength);
+ void fireOnStreamMethodUpdated(int methodType);
+}
\ No newline at end of file
diff --git a/tests/tests/telephony/EmbmsMiddlewareTestApp/src/android/telephony/cts/embmstestapp/CtsDownloadService.java b/tests/tests/telephony/EmbmsMiddlewareTestApp/src/android/telephony/cts/embmstestapp/CtsDownloadService.java
new file mode 100644
index 0000000..01777c6
--- /dev/null
+++ b/tests/tests/telephony/EmbmsMiddlewareTestApp/src/android/telephony/cts/embmstestapp/CtsDownloadService.java
@@ -0,0 +1,419 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package android.telephony.cts.embmstestapp;
+
+import android.app.Activity;
+import android.app.Service;
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Binder;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.IBinder;
+import android.os.ParcelFileDescriptor;
+import android.os.RemoteException;
+import android.telephony.MbmsDownloadSession;
+import android.telephony.mbms.DownloadRequest;
+import android.telephony.mbms.DownloadStateCallback;
+import android.telephony.mbms.FileInfo;
+import android.telephony.mbms.FileServiceInfo;
+import android.telephony.mbms.MbmsDownloadSessionCallback;
+import android.telephony.mbms.MbmsErrors;
+import android.telephony.mbms.UriPathPair;
+import android.telephony.mbms.vendor.MbmsDownloadServiceBase;
+import android.telephony.mbms.vendor.VendorUtils;
+import android.util.Log;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+public class CtsDownloadService extends Service {
+ private static final Set<String> ALLOWED_PACKAGES = new HashSet<String>() {{
+ add("android.telephony.cts");
+ }};
+ private static final String TAG = "EmbmsTestDownload";
+
+ public static final String METHOD_NAME = "method_name";
+ public static final String METHOD_INITIALIZE = "initialize";
+ public static final String METHOD_REQUEST_UPDATE_FILE_SERVICES =
+ "requestUpdateFileServices";
+ public static final String METHOD_SET_TEMP_FILE_ROOT = "setTempFileRootDirectory";
+ public static final String METHOD_RESET_DOWNLOAD_KNOWLEDGE = "resetDownloadKnowledge";
+ public static final String METHOD_GET_DOWNLOAD_STATUS = "getDownloadStatus";
+ public static final String METHOD_CANCEL_DOWNLOAD = "cancelDownload";
+ public static final String METHOD_CLOSE = "close";
+ // Not a method call, but it's a form of communication to the middleware so it's included
+ // here for convenience.
+ public static final String METHOD_DOWNLOAD_RESULT_ACK = "downloadResultAck";
+
+ public static final String ARGUMENT_SUBSCRIPTION_ID = "subscriptionId";
+ public static final String ARGUMENT_SERVICE_CLASSES = "serviceClasses";
+ public static final String ARGUMENT_ROOT_DIRECTORY_PATH = "rootDirectoryPath";
+ public static final String ARGUMENT_DOWNLOAD_REQUEST = "downloadRequest";
+ public static final String ARGUMENT_FILE_INFO = "fileInfo";
+ public static final String ARGUMENT_RESULT_CODE = "resultCode";
+
+ public static final String CONTROL_INTERFACE_ACTION =
+ "android.telephony.cts.embmstestapp.ACTION_CONTROL_MIDDLEWARE";
+ public static final ComponentName CONTROL_INTERFACE_COMPONENT =
+ ComponentName.unflattenFromString(
+ "android.telephony.cts.embmstestapp/.CtsDownloadService");
+ public static final ComponentName CTS_TEST_RECEIVER_COMPONENT =
+ ComponentName.unflattenFromString(
+ "android.telephony.cts/android.telephony.mbms.MbmsDownloadReceiver");
+
+ public static final Uri DOWNLOAD_SOURCE_URI = Uri.parse("http://www.example.com/file_download");
+ public static final FileServiceInfo FILE_SERVICE_INFO;
+ public static final FileInfo FILE_INFO = new FileInfo(
+ DOWNLOAD_SOURCE_URI.buildUpon().appendPath("file1.txt").build(),
+ "text/plain");
+ public static final byte[] SAMPLE_FILE_DATA = "this is some sample file data".getBytes();
+
+ static {
+ String id = "FileServiceId";
+ Map<Locale, String> localeDict = new HashMap<Locale, String>() {{
+ put(Locale.US, "Entertainment Source 1");
+ put(Locale.CANADA, "Entertainment Source 1, eh?");
+ }};
+ List<Locale> locales = new ArrayList<Locale>() {{
+ add(Locale.CANADA);
+ add(Locale.US);
+ }};
+ FILE_SERVICE_INFO = new FileServiceInfo(localeDict, "class1", locales,
+ id, new Date(2017, 8, 21, 18, 20, 29),
+ new Date(2017, 8, 21, 18, 23, 9), Collections.singletonList(FILE_INFO));
+ }
+
+ private MbmsDownloadSessionCallback mAppCallback;
+ private DownloadStateCallback mDownloadStateCallback;
+
+ private HandlerThread mHandlerThread;
+ private Handler mHandler;
+ private List<Bundle> mReceivedCalls = new LinkedList<>();
+ private int mErrorCodeOverride = MbmsErrors.SUCCESS;
+ private List<DownloadRequest> mReceivedRequests = new LinkedList<>();
+ private String mTempFileRootDirPath = null;
+
+ private final MbmsDownloadServiceBase mDownloadServiceImpl = new MbmsDownloadServiceBase() {
+ @Override
+ public int initialize(int subscriptionId, MbmsDownloadSessionCallback callback) {
+ Bundle b = new Bundle();
+ b.putString(METHOD_NAME, METHOD_INITIALIZE);
+ b.putInt(ARGUMENT_SUBSCRIPTION_ID, subscriptionId);
+ mReceivedCalls.add(b);
+
+ if (mErrorCodeOverride != MbmsErrors.SUCCESS) {
+ return mErrorCodeOverride;
+ }
+
+ int packageUid = Binder.getCallingUid();
+ String[] packageNames = getPackageManager().getPackagesForUid(packageUid);
+ if (packageNames == null) {
+ return MbmsErrors.InitializationErrors.ERROR_APP_PERMISSIONS_NOT_GRANTED;
+ }
+ boolean isUidAllowed = Arrays.stream(packageNames).anyMatch(ALLOWED_PACKAGES::contains);
+ if (!isUidAllowed) {
+ return MbmsErrors.InitializationErrors.ERROR_APP_PERMISSIONS_NOT_GRANTED;
+ }
+
+ mHandler.post(() -> {
+ if (mAppCallback == null) {
+ mAppCallback = callback;
+ } else {
+ callback.onError(
+ MbmsErrors.InitializationErrors.ERROR_DUPLICATE_INITIALIZE, "");
+ return;
+ }
+ callback.onMiddlewareReady();
+ });
+ return MbmsErrors.SUCCESS;
+ }
+
+ @Override
+ public int requestUpdateFileServices(int subscriptionId, List<String> serviceClasses) {
+ Bundle b = new Bundle();
+ b.putString(METHOD_NAME, METHOD_REQUEST_UPDATE_FILE_SERVICES);
+ b.putInt(ARGUMENT_SUBSCRIPTION_ID, subscriptionId);
+ b.putStringArrayList(ARGUMENT_SERVICE_CLASSES, new ArrayList<>(serviceClasses));
+ mReceivedCalls.add(b);
+
+ if (mErrorCodeOverride != MbmsErrors.SUCCESS) {
+ return mErrorCodeOverride;
+ }
+
+ List<FileServiceInfo> serviceInfos = Collections.singletonList(FILE_SERVICE_INFO);
+
+ mHandler.post(() -> {
+ if (mAppCallback!= null) {
+ mAppCallback.onFileServicesUpdated(serviceInfos);
+ }
+ });
+
+ return MbmsErrors.SUCCESS;
+ }
+
+ @Override
+ public int download(DownloadRequest downloadRequest) {
+ mReceivedRequests.add(downloadRequest);
+ return MbmsErrors.SUCCESS;
+ }
+
+ @Override
+ public int setTempFileRootDirectory(int subscriptionId, String rootDirectoryPath) {
+ Bundle b = new Bundle();
+ b.putString(METHOD_NAME, METHOD_SET_TEMP_FILE_ROOT);
+ b.putInt(ARGUMENT_SUBSCRIPTION_ID, subscriptionId);
+ b.putString(ARGUMENT_ROOT_DIRECTORY_PATH, rootDirectoryPath);
+ mReceivedCalls.add(b);
+ mTempFileRootDirPath = rootDirectoryPath;
+ return 0;
+ }
+
+ @Override
+ public int registerStateCallback(DownloadRequest downloadRequest,
+ DownloadStateCallback listener) throws RemoteException {
+ mDownloadStateCallback = listener;
+ return MbmsErrors.SUCCESS;
+ }
+
+ @Override
+ public void dispose(int subscriptionId) {
+ Bundle b = new Bundle();
+ b.putString(METHOD_NAME, METHOD_CLOSE);
+ b.putInt(ARGUMENT_SUBSCRIPTION_ID, subscriptionId);
+ mReceivedCalls.add(b);
+ }
+
+ @Override
+ public int getDownloadStatus(DownloadRequest downloadRequest, FileInfo fileInfo) {
+ Bundle b = new Bundle();
+ b.putString(METHOD_NAME, METHOD_GET_DOWNLOAD_STATUS);
+ b.putParcelable(ARGUMENT_DOWNLOAD_REQUEST, downloadRequest);
+ b.putParcelable(ARGUMENT_FILE_INFO, fileInfo);
+ mReceivedCalls.add(b);
+ return MbmsDownloadSession.STATUS_ACTIVELY_DOWNLOADING;
+ }
+
+ @Override
+ public int cancelDownload(DownloadRequest request) {
+ Bundle b = new Bundle();
+ b.putString(METHOD_NAME, METHOD_CANCEL_DOWNLOAD);
+ b.putParcelable(ARGUMENT_DOWNLOAD_REQUEST, request);
+ mReceivedCalls.add(b);
+ mReceivedRequests.remove(request);
+ return MbmsErrors.SUCCESS;
+ }
+
+ @Override
+ public List<DownloadRequest> listPendingDownloads(int subscriptionId) {
+ return mReceivedRequests;
+ }
+
+ @Override
+ public int unregisterStateCallback(DownloadRequest downloadRequest,
+ DownloadStateCallback callback) {
+ mDownloadStateCallback = null;
+ return MbmsErrors.SUCCESS;
+ }
+
+ @Override
+ public int resetDownloadKnowledge(DownloadRequest downloadRequest) {
+ Bundle b = new Bundle();
+ b.putString(METHOD_NAME, METHOD_RESET_DOWNLOAD_KNOWLEDGE);
+ b.putParcelable(ARGUMENT_DOWNLOAD_REQUEST, downloadRequest);
+ mReceivedCalls.add(b);
+ return MbmsErrors.SUCCESS;
+ }
+
+ @Override
+ public void onAppCallbackDied(int uid, int subscriptionId) {
+ mAppCallback = null;
+ }
+ };
+
+ private final IBinder mControlInterface = new ICtsDownloadMiddlewareControl.Stub() {
+ @Override
+ public void reset() {
+ mReceivedCalls.clear();
+ mHandler.removeCallbacksAndMessages(null);
+ mAppCallback = null;
+ mErrorCodeOverride = MbmsErrors.SUCCESS;
+ mReceivedRequests.clear();
+ mDownloadStateCallback = null;
+ mTempFileRootDirPath = null;
+ }
+
+ @Override
+ public List<Bundle> getDownloadSessionCalls() {
+ return mReceivedCalls;
+ }
+
+ @Override
+ public void forceErrorCode(int error) {
+ mErrorCodeOverride = error;
+ }
+
+ @Override
+ public void fireErrorOnSession(int errorCode, String message) {
+ mHandler.post(() -> mAppCallback.onError(errorCode, message));
+ }
+
+ @Override
+ public void fireOnProgressUpdated(DownloadRequest request, FileInfo fileInfo,
+ int currentDownloadSize, int fullDownloadSize,
+ int currentDecodedSize, int fullDecodedSize) {
+ if (mDownloadStateCallback == null) {
+ return;
+ }
+ mHandler.post(() -> mDownloadStateCallback.onProgressUpdated(request, fileInfo,
+ currentDownloadSize, fullDownloadSize, currentDecodedSize, fullDecodedSize));
+ }
+
+ @Override
+ public void fireOnStateUpdated(DownloadRequest request, FileInfo fileInfo, int state) {
+ if (mDownloadStateCallback == null) {
+ return;
+ }
+ mHandler.post(() -> mDownloadStateCallback.onStateUpdated(request, fileInfo, state));
+ }
+
+ @Override
+ public void actuallyStartDownloadFlow() {
+ DownloadRequest request = mReceivedRequests.get(0);
+ // Compose the FILE_DESCRIPTOR_REQUEST_INTENT to get some FDs to write to
+ Intent requestIntent = new Intent(VendorUtils.ACTION_FILE_DESCRIPTOR_REQUEST);
+ requestIntent.putExtra(VendorUtils.EXTRA_SERVICE_ID, request.getFileServiceId());
+ requestIntent.putExtra(VendorUtils.EXTRA_FD_COUNT, 1);
+ requestIntent.putExtra(VendorUtils.EXTRA_TEMP_FILE_ROOT, mTempFileRootDirPath);
+ requestIntent.setComponent(CTS_TEST_RECEIVER_COMPONENT);
+
+ // Send as an ordered broadcast, using a BroadcastReceiver to capture the result
+ // containing UriPathPairs.
+ logd("Sending fd-request broadcast");
+ sendOrderedBroadcast(requestIntent,
+ null, // receiverPermission
+ new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ logd("Got file-descriptors");
+ Bundle extras = getResultExtras(false);
+ UriPathPair tempFile = (UriPathPair) extras.getParcelableArrayList(
+ VendorUtils.EXTRA_FREE_URI_LIST).get(0);
+ int result = MbmsDownloadSession.RESULT_SUCCESSFUL;
+ try {
+ ParcelFileDescriptor tempFileFd =
+ getContentResolver().openFileDescriptor(
+ tempFile.getContentUri(), "rw");
+ OutputStream destinationStream =
+ new ParcelFileDescriptor.AutoCloseOutputStream(tempFileFd);
+
+ destinationStream.write(SAMPLE_FILE_DATA);
+ destinationStream.flush();
+ } catch (IOException e) {
+ result = MbmsDownloadSession.RESULT_CANCELLED;
+ }
+
+ Intent downloadResultIntent =
+ new Intent(VendorUtils.ACTION_DOWNLOAD_RESULT_INTERNAL);
+ downloadResultIntent.putExtra(
+ MbmsDownloadSession.EXTRA_MBMS_DOWNLOAD_REQUEST, request);
+ downloadResultIntent.putExtra(VendorUtils.EXTRA_FINAL_URI,
+ tempFile.getFilePathUri());
+ downloadResultIntent.putExtra(MbmsDownloadSession.EXTRA_MBMS_FILE_INFO,
+ FILE_INFO);
+ downloadResultIntent.putExtra(VendorUtils.EXTRA_TEMP_FILE_ROOT,
+ mTempFileRootDirPath);
+ downloadResultIntent.putExtra(
+ MbmsDownloadSession.EXTRA_MBMS_DOWNLOAD_RESULT, result);
+ downloadResultIntent.setComponent(CTS_TEST_RECEIVER_COMPONENT);
+
+ logd("Sending broadcast to app: " + downloadResultIntent.toString());
+ sendOrderedBroadcast(downloadResultIntent,
+ null, // receiverPermission
+ new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Bundle b = new Bundle();
+ b.putString(METHOD_NAME, METHOD_DOWNLOAD_RESULT_ACK);
+ b.putInt(ARGUMENT_RESULT_CODE, getResultCode());
+ mReceivedCalls.add(b);
+ }
+ },
+ null, // scheduler
+ Activity.RESULT_OK,
+ null, // initialData
+ null /* initialExtras */);
+ }
+ },
+ mHandler, // scheduler
+ Activity.RESULT_OK,
+ null, // initialData
+ null /* initialExtras */);
+
+ }
+ };
+
+ @Override
+ public void onDestroy() {
+ super.onCreate();
+ mHandlerThread.quitSafely();
+ logd("CtsDownloadService onDestroy");
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ if (CONTROL_INTERFACE_ACTION.equals(intent.getAction())) {
+ logd("CtsDownloadService control interface bind");
+ return mControlInterface;
+ }
+
+ logd("CtsDownloadService onBind");
+ if (mHandlerThread != null && mHandlerThread.isAlive()) {
+ return mDownloadServiceImpl;
+ }
+
+ mHandlerThread = new HandlerThread("CtsDownloadServiceWorker");
+ mHandlerThread.start();
+ mHandler = new Handler(mHandlerThread.getLooper());
+ return mDownloadServiceImpl;
+ }
+
+ private static void logd(String s) {
+ Log.d(TAG, s);
+ }
+
+ private void checkInitialized() {
+ if (mAppCallback == null) {
+ throw new IllegalStateException("Not yet initialized");
+ }
+ }
+}
diff --git a/tests/tests/telephony/EmbmsMiddlewareTestApp/src/android/telephony/cts/embmstestapp/CtsStreamingService.java b/tests/tests/telephony/EmbmsMiddlewareTestApp/src/android/telephony/cts/embmstestapp/CtsStreamingService.java
new file mode 100644
index 0000000..9e95a0d
--- /dev/null
+++ b/tests/tests/telephony/EmbmsMiddlewareTestApp/src/android/telephony/cts/embmstestapp/CtsStreamingService.java
@@ -0,0 +1,271 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package android.telephony.cts.embmstestapp;
+
+import android.app.Service;
+import android.content.ComponentName;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Binder;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.telephony.mbms.MbmsErrors;
+import android.telephony.mbms.MbmsStreamingSessionCallback;
+import android.telephony.mbms.StreamingService;
+import android.telephony.mbms.StreamingServiceCallback;
+import android.telephony.mbms.StreamingServiceInfo;
+import android.telephony.mbms.vendor.MbmsStreamingServiceBase;
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+public class CtsStreamingService extends Service {
+ private static final Set<String> ALLOWED_PACKAGES = new HashSet<String>() {{
+ add("android.telephony.cts");
+ }};
+ private static final String TAG = "EmbmsTestStreaming";
+
+ public static final String METHOD_INITIALIZE = "initialize";
+ public static final String METHOD_REQUEST_UPDATE_STREAMING_SERVICES =
+ "requestUpdateStreamingServices";
+ public static final String METHOD_START_STREAMING = "startStreaming";
+ public static final String METHOD_GET_PLAYBACK_URI = "getPlaybackUri";
+ public static final String METHOD_STOP_STREAMING = "stopStreaming";
+ public static final String METHOD_CLOSE = "close";
+
+ public static final String CONTROL_INTERFACE_ACTION =
+ "android.telephony.cts.embmstestapp.ACTION_CONTROL_MIDDLEWARE";
+ public static final ComponentName CONTROL_INTERFACE_COMPONENT =
+ ComponentName.unflattenFromString(
+ "android.telephony.cts.embmstestapp/.CtsStreamingService");
+ public static final Uri STREAMING_URI = Uri.parse("http://www.example.com/stream1");
+
+ public static final StreamingServiceInfo STREAMING_SERVICE_INFO;
+ static {
+ String id = "StreamingServiceId";
+ Map<Locale, String> localeDict = new HashMap<Locale, String>() {{
+ put(Locale.US, "Entertainment Source 1");
+ put(Locale.CANADA, "Entertainment Source 1, eh?");
+ }};
+ List<Locale> locales = new ArrayList<Locale>() {{
+ add(Locale.CANADA);
+ add(Locale.US);
+ }};
+ STREAMING_SERVICE_INFO = new StreamingServiceInfo(localeDict, "class1", locales,
+ id, new Date(2017, 8, 21, 18, 20, 29),
+ new Date(2017, 8, 21, 18, 23, 9));
+ }
+
+ private static final int SEND_STREAMING_SERVICES_LIST = 1;
+
+ private MbmsStreamingSessionCallback mAppCallback;
+ private StreamingServiceCallback mStreamCallback;
+
+ private HandlerThread mHandlerThread;
+ private Handler mHandler;
+ private Handler.Callback mWorkerCallback = (msg) -> {
+ switch (msg.what) {
+ case SEND_STREAMING_SERVICES_LIST:
+ List<StreamingServiceInfo> services = (List<StreamingServiceInfo>) msg.obj;
+ if (mAppCallback!= null) {
+ mAppCallback.onStreamingServicesUpdated(services);
+ }
+ break;
+ }
+ return true;
+ };
+ private List<List> mReceivedCalls = new LinkedList<>();
+ private int mErrorCodeOverride = MbmsErrors.SUCCESS;
+
+ private final MbmsStreamingServiceBase mStreamingServiceImpl = new MbmsStreamingServiceBase() {
+ @Override
+ public int initialize(MbmsStreamingSessionCallback callback, int subId) {
+ mReceivedCalls.add(Arrays.asList(METHOD_INITIALIZE, subId));
+ if (mErrorCodeOverride != MbmsErrors.SUCCESS) {
+ return mErrorCodeOverride;
+ }
+
+
+ int packageUid = Binder.getCallingUid();
+ String[] packageNames = getPackageManager().getPackagesForUid(packageUid);
+ if (packageNames == null) {
+ return MbmsErrors.InitializationErrors.ERROR_APP_PERMISSIONS_NOT_GRANTED;
+ }
+ boolean isUidAllowed = Arrays.stream(packageNames).anyMatch(ALLOWED_PACKAGES::contains);
+ if (!isUidAllowed) {
+ return MbmsErrors.InitializationErrors.ERROR_APP_PERMISSIONS_NOT_GRANTED;
+ }
+
+ mHandler.post(() -> {
+ if (mAppCallback == null) {
+ mAppCallback = callback;
+ } else {
+ callback.onError(
+ MbmsErrors.InitializationErrors.ERROR_DUPLICATE_INITIALIZE, "");
+ return;
+ }
+ callback.onMiddlewareReady();
+ });
+ return MbmsErrors.SUCCESS;
+ }
+
+ @Override
+ public int requestUpdateStreamingServices(int subscriptionId, List<String> serviceClasses) {
+ mReceivedCalls.add(Arrays.asList(METHOD_REQUEST_UPDATE_STREAMING_SERVICES,
+ subscriptionId, serviceClasses));
+ if (mErrorCodeOverride != MbmsErrors.SUCCESS) {
+ return mErrorCodeOverride;
+ }
+
+ List<StreamingServiceInfo> serviceInfos =
+ Collections.singletonList(STREAMING_SERVICE_INFO);
+
+ mHandler.removeMessages(SEND_STREAMING_SERVICES_LIST);
+ mHandler.sendMessage(
+ mHandler.obtainMessage(SEND_STREAMING_SERVICES_LIST, serviceInfos));
+ return MbmsErrors.SUCCESS;
+ }
+
+ @Override
+ public int startStreaming(int subscriptionId, String serviceId,
+ StreamingServiceCallback callback) {
+ mReceivedCalls.add(Arrays.asList(METHOD_START_STREAMING, subscriptionId, serviceId));
+ if (mErrorCodeOverride != MbmsErrors.SUCCESS) {
+ return mErrorCodeOverride;
+ }
+
+ mStreamCallback = callback;
+ mHandler.post(() -> callback.onStreamStateUpdated(StreamingService.STATE_STARTED,
+ StreamingService.REASON_BY_USER_REQUEST));
+ return MbmsErrors.SUCCESS;
+ }
+
+ @Override
+ public Uri getPlaybackUri(int subscriptionId, String serviceId) {
+ mReceivedCalls.add(Arrays.asList(METHOD_GET_PLAYBACK_URI, subscriptionId, serviceId));
+ return STREAMING_URI;
+ }
+
+ @Override
+ public void stopStreaming(int subscriptionId, String serviceId) {
+ mReceivedCalls.add(Arrays.asList(METHOD_STOP_STREAMING, subscriptionId, serviceId));
+ }
+
+ @Override
+ public void dispose(int subscriptionId) {
+ mReceivedCalls.add(Arrays.asList(METHOD_CLOSE, subscriptionId));
+ // TODO
+ }
+
+ @Override
+ public void onAppCallbackDied(int uid, int subscriptionId) {
+ mAppCallback = null;
+ }
+ };
+
+ private final IBinder mControlInterface = new ICtsStreamingMiddlewareControl.Stub() {
+ @Override
+ public void reset() {
+ mReceivedCalls.clear();
+ mHandler.removeCallbacksAndMessages(null);
+ mAppCallback = null;
+ mErrorCodeOverride = MbmsErrors.SUCCESS;
+ }
+
+ @Override
+ public List getStreamingSessionCalls() {
+ return mReceivedCalls;
+ }
+
+ @Override
+ public void forceErrorCode(int error) {
+ mErrorCodeOverride = error;
+ }
+
+ @Override
+ public void fireErrorOnStream(int errorCode, String message) {
+ mHandler.post(() -> mStreamCallback.onError(errorCode, message));
+ }
+
+ @Override
+ public void fireErrorOnSession(int errorCode, String message) {
+ mHandler.post(() -> mAppCallback.onError(errorCode, message));
+ }
+
+ @Override
+ public void fireOnMediaDescriptionUpdated() {
+ mHandler.post(() -> mStreamCallback.onMediaDescriptionUpdated());
+ }
+
+ @Override
+ public void fireOnBroadcastSignalStrengthUpdated(int signalStrength) {
+ mHandler.post(() -> mStreamCallback.onBroadcastSignalStrengthUpdated(signalStrength));
+ }
+
+ @Override
+ public void fireOnStreamMethodUpdated(int methodType){
+ mHandler.post(() -> mStreamCallback.onStreamMethodUpdated(methodType));
+ }
+ };
+
+ @Override
+ public void onDestroy() {
+ super.onCreate();
+ mHandlerThread.quitSafely();
+ logd("CtsStreamingService onDestroy");
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ if (CONTROL_INTERFACE_ACTION.equals(intent.getAction())) {
+ logd("CtsStreamingService control interface bind");
+ return mControlInterface;
+ }
+
+ logd("CtsStreamingService onBind");
+ if (mHandlerThread != null && mHandlerThread.isAlive()) {
+ return mStreamingServiceImpl;
+ }
+
+ mHandlerThread = new HandlerThread("CtsStreamingServiceWorker");
+ mHandlerThread.start();
+ mHandler = new Handler(mHandlerThread.getLooper(), mWorkerCallback);
+ return mStreamingServiceImpl;
+ }
+
+ private static void logd(String s) {
+ Log.d(TAG, s);
+ }
+
+ private void checkInitialized() {
+ if (mAppCallback == null) {
+ throw new IllegalStateException("Not yet initialized");
+ }
+ }
+}
diff --git a/tests/tests/telephony/src/android/telephony/cts/CellInfoTest.java b/tests/tests/telephony/src/android/telephony/cts/CellInfoTest.java
index a1423af..a074783 100644
--- a/tests/tests/telephony/src/android/telephony/cts/CellInfoTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/CellInfoTest.java
@@ -110,6 +110,11 @@
}
private void verifyCdmaInfo(CellInfoCdma cdma) {
+ String alphaLong = (String) cdma.getCellIdentity().getOperatorAlphaLong();
+ assertNotNull("getOperatorAlphaLong() returns NULL!", alphaLong);
+ String alphaShort = (String) cdma.getCellIdentity().getOperatorAlphaShort();
+ assertNotNull("getOperatorAlphaShort() returns NULL!", alphaShort);
+
int level = cdma.getCellSignalStrength().getLevel();
assertTrue("getLevel() out of range [0,4], level=" + level, level >=0 && level <= 4);
}
@@ -123,6 +128,29 @@
// Physical cell id should be within [0, 503].
assertTrue("getPci() out of range [0, 503], pci=" + pci, pci >= 0 && pci <= 503);
+ String alphaLong = (String) lte.getCellIdentity().getOperatorAlphaLong();
+ assertNotNull("getOperatorAlphaLong() returns NULL!", alphaLong);
+ String alphaShort = (String) lte.getCellIdentity().getOperatorAlphaShort();
+ assertNotNull("getOperatorAlphaShort() returns NULL!", alphaShort);
+
+ String mccStr = lte.getCellIdentity().getMccStr();
+ // mccStr is set as NULL if empty, unknown or invalid.
+ assertTrue("getMccStr() out of range [0, 999], mcc=" + mccStr,
+ mccStr == null || mccStr.matches("^[0-9]{3}$"));
+ String mncStr = lte.getCellIdentity().getMncStr();
+ // mncStr is set as NULL if empty, unknown or invalid.
+ assertTrue("getMncStr() out of range [0, 999], mnc=" + mncStr,
+ mncStr == null || mncStr.matches("^[0-9]{2,3}$"));
+
+ int mcc = lte.getCellIdentity().getMcc();
+ // getMcc() returns Integer.MAX_VALUE if mccStr is null.
+ assertTrue("getMcc() out of range [0, 999], mcc=" + mcc,
+ (mcc >= 0 && mcc <= 999) || mcc == Integer.MAX_VALUE);
+ int mnc = lte.getCellIdentity().getMnc();
+ // getMnc() returns Integer.MAX_VALUE if mccStr is null.
+ assertTrue("getMnc() out of range [0, 999], mnc=" + mnc,
+ (mnc >= 0 && mnc <= 999) || mnc == Integer.MAX_VALUE);
+
int earfcn = lte.getCellIdentity().getEarfcn();
// Reference 3GPP 36.101 Table 5.7.3-1
assertTrue("getEarfcn() out of range [0,47000], earfcn=" + earfcn,
@@ -162,6 +190,29 @@
assertTrue("getUarfcn() out of range [400,11000], uarfcn=" + uarfcn,
uarfcn >= 400 && uarfcn <= 11000);
+ String alphaLong = (String) wcdma.getCellIdentity().getOperatorAlphaLong();
+ assertNotNull("getOperatorAlphaLong() returns NULL!", alphaLong);
+ String alphaShort = (String) wcdma.getCellIdentity().getOperatorAlphaShort();
+ assertNotNull("getOperatorAlphaShort() returns NULL!", alphaShort);
+
+ String mccStr = wcdma.getCellIdentity().getMccStr();
+ // mccStr is set as NULL if empty, unknown or invalid.
+ assertTrue("getMccStr() out of range [0, 999], mcc=" + mccStr,
+ mccStr == null || mccStr.matches("^[0-9]{3}$"));
+ String mncStr = wcdma.getCellIdentity().getMncStr();
+ // mncStr is set as NULL if empty, unknown or invalid.
+ assertTrue("getMncStr() out of range [0, 999], mnc=" + mncStr,
+ mncStr == null || mncStr.matches("^[0-9]{2,3}$"));
+
+ int mcc = wcdma.getCellIdentity().getMcc();
+ // getMcc() returns Integer.MAX_VALUE if mccStr is null.
+ assertTrue("getMcc() out of range [0, 999], mcc=" + mcc,
+ (mcc >= 0 && mcc <= 999) || mcc == Integer.MAX_VALUE);
+ int mnc = wcdma.getCellIdentity().getMnc();
+ // getMnc() returns Integer.MAX_VALUE if mccStr is null.
+ assertTrue("getMnc() out of range [0, 999], mnc=" + mnc,
+ (mnc >= 0 && mnc <= 999) || mnc == Integer.MAX_VALUE);
+
int level = wcdma.getCellSignalStrength().getLevel();
assertTrue("getLevel() out of range [0,4], level=" + level, level >=0 && level <= 4);
}
@@ -183,6 +234,29 @@
assertTrue("getArfcn() out of range [0,1024], arfcn=" + arfcn,
arfcn >= 0 && arfcn <= 1024);
+ String alphaLong = (String) gsm.getCellIdentity().getOperatorAlphaLong();
+ assertNotNull("getOperatorAlphaLong() returns NULL!", alphaLong);
+ String alphaShort = (String) gsm.getCellIdentity().getOperatorAlphaShort();
+ assertNotNull("getOperatorAlphaShort() returns NULL!", alphaShort);
+
+ String mccStr = gsm.getCellIdentity().getMccStr();
+ // mccStr is set as NULL if empty, unknown or invalid.
+ assertTrue("getMccStr() out of range [0, 999], mcc=" + mccStr,
+ mccStr == null || mccStr.matches("^[0-9]{3}$"));
+ String mncStr = gsm.getCellIdentity().getMncStr();
+ // mncStr is set as NULL if empty, unknown or invalid.
+ assertTrue("getMncStr() out of range [0, 999], mnc=" + mncStr,
+ mncStr == null || mncStr.matches("^[0-9]{2,3}$"));
+
+ int mcc = gsm.getCellIdentity().getMcc();
+ // getMcc() returns Integer.MAX_VALUE if mccStr is null.
+ assertTrue("getMcc() out of range [0, 999], mcc=" + mcc,
+ (mcc >= 0 && mcc <= 999) || mcc == Integer.MAX_VALUE);
+ int mnc = gsm.getCellIdentity().getMnc();
+ // getMnc() returns Integer.MAX_VALUE if mccStr is null.
+ assertTrue("getMnc() out of range [0, 999], mnc=" + mnc,
+ (mnc >= 0 && mnc <= 999) || mnc == Integer.MAX_VALUE);
+
int level = gsm.getCellSignalStrength().getLevel();
assertTrue("getLevel() out of range [0,4], level=" + level, level >=0 && level <= 4);
diff --git a/tests/tests/telephony/src/android/telephony/cts/PhoneStateListenerTest.java b/tests/tests/telephony/src/android/telephony/cts/PhoneStateListenerTest.java
index d18a9f5..8a13349 100644
--- a/tests/tests/telephony/src/android/telephony/cts/PhoneStateListenerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/PhoneStateListenerTest.java
@@ -23,11 +23,9 @@
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;
import android.net.ConnectivityManager;
-import android.test.InstrumentationTestCase;
import android.test.AndroidTestCase;
import android.util.Log;
-import com.android.compatibility.common.util.ReadElf;
import com.android.compatibility.common.util.TestThread;
public class PhoneStateListenerTest extends AndroidTestCase{
@@ -37,6 +35,7 @@
private boolean mOnCallForwardingIndicatorChangedCalled;
private boolean mOnCallStateChangedCalled;
private boolean mOnCellLocationChangedCalled;
+ private boolean mOnUserMobileDataStateChanged;
private boolean mOnDataActivityCalled;
private boolean mOnDataConnectionStateChangedCalled;
private boolean mOnMessageWaitingIndicatorChangedCalled;
@@ -428,4 +427,42 @@
t.checkException();
assertTrue(mOnDataActivityCalled);
}
+
+ public void testOnUserMobileDataStateChanged() throws Throwable {
+ if (mCm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE) == null) {
+ Log.d(TAG, "Skipping test that requires ConnectivityManager.TYPE_MOBILE");
+ return;
+ }
+
+ TestThread t = new TestThread(new Runnable() {
+ public void run() {
+ Looper.prepare();
+
+ mListener = new PhoneStateListener() {
+ @Override
+ public void onUserMobileDataStateChanged(boolean state) {
+ synchronized(mLock) {
+ mOnUserMobileDataStateChanged = true;
+ mLock.notify();
+ }
+ }
+ };
+ mTelephonyManager.listen(
+ mListener, PhoneStateListener.LISTEN_USER_MOBILE_DATA_STATE);
+
+ Looper.loop();
+ }
+ });
+
+ assertFalse(mOnUserMobileDataStateChanged);
+ t.start();
+
+ synchronized (mLock) {
+ while(!mOnUserMobileDataStateChanged){
+ mLock.wait();
+ }
+ }
+ t.checkException();
+ assertTrue(mOnUserMobileDataStateChanged);
+ }
}
diff --git a/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java
index 79097e0..9803a45 100644
--- a/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java
@@ -51,8 +51,14 @@
import org.junit.Test;
import org.junit.runner.RunWith;
+import java.util.List;
import java.util.regex.Pattern;
+/**
+ * Build, install and run the tests by running the commands below:
+ * make cts -j64
+ * cts-tradefed run cts -m CtsTelephonyTestCases --test android.telephony.cts.TelephonyManagerTest
+ */
@RunWith(AndroidJUnit4.class)
public class TelephonyManagerTest {
private TelephonyManager mTelephonyManager;
@@ -602,4 +608,32 @@
private static Context getContext() {
return InstrumentationRegistry.getContext();
}
+
+ /**
+ * Tests that the device properly sets the network selection mode to automatic.
+ * Expects a security exception since the caller does not have carrier privileges.
+ */
+ @Test
+ public void testSetNetworkSelectionModeAutomatic() {
+ try {
+ mTelephonyManager.setNetworkSelectionModeAutomatic();
+ fail("Expected SecurityException. App does not have carrier privileges.");
+ } catch (SecurityException expected) {
+ }
+ }
+
+ /**
+ * Tests that the device properly asks the radio to connect to the input network and change
+ * selection mode to manual.
+ * Expects a security exception since the caller does not have carrier privileges.
+ */
+ @Test
+ public void testSetNetworkSelectionModeManual() {
+ try {
+ mTelephonyManager.setNetworkSelectionModeManual(
+ "" /* operatorNumeric */, false /* persistSelection */);
+ fail("Expected SecurityException. App does not have carrier privileges.");
+ } catch (SecurityException expected) {
+ }
+ }
}
diff --git a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadFlowTest.java b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadFlowTest.java
new file mode 100644
index 0000000..5089381
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadFlowTest.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package android.telephony.embms.cts;
+
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.telephony.MbmsDownloadSession;
+import android.telephony.cts.embmstestapp.CtsDownloadService;
+import android.telephony.mbms.MbmsDownloadReceiver;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.List;
+
+public class MbmsDownloadFlowTest extends MbmsDownloadTestBase {
+ private File tempFileRootDir;
+ private String tempFileRootDirPath;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ tempFileRootDir = new File(mContext.getFilesDir(), "CtsTestDir");
+ tempFileRootDir.mkdir();
+ tempFileRootDirPath = tempFileRootDir.getCanonicalPath();
+ mDownloadSession.setTempFileRootDirectory(tempFileRootDir);
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ recursiveDelete(tempFileRootDir);
+ tempFileRootDir = null;
+ super.tearDown();
+ }
+
+ public void testFileDownloadFlow() throws Exception {
+ MbmsDownloadReceiverTest.AppIntentCapture captor =
+ new MbmsDownloadReceiverTest.AppIntentCapture(mContext, mCallbackHandler);
+ mDownloadSession.download(MbmsDownloadReceiverTest.TEST_DOWNLOAD_REQUEST);
+ mMiddlewareControl.actuallyStartDownloadFlow();
+ Intent downloadDoneIntent = captor.getIntent();
+
+ assertEquals(MbmsDownloadReceiverTest.APP_INTENT_ACTION, downloadDoneIntent.getAction());
+ assertEquals(MbmsDownloadSession.RESULT_SUCCESSFUL,
+ downloadDoneIntent.getIntExtra(MbmsDownloadSession.EXTRA_MBMS_DOWNLOAD_RESULT, -1));
+ assertEquals(MbmsDownloadReceiverTest.TEST_DOWNLOAD_REQUEST,
+ downloadDoneIntent.getParcelableExtra(
+ MbmsDownloadSession.EXTRA_MBMS_DOWNLOAD_REQUEST));
+ assertEquals(CtsDownloadService.FILE_INFO,
+ downloadDoneIntent.getParcelableExtra(MbmsDownloadSession.EXTRA_MBMS_FILE_INFO));
+ Uri fileUri = downloadDoneIntent.getParcelableExtra(
+ MbmsDownloadSession.EXTRA_MBMS_COMPLETED_FILE_URI);
+ InputStream is = mContext.getContentResolver().openInputStream(fileUri);
+ byte[] contents = new byte[CtsDownloadService.SAMPLE_FILE_DATA.length];
+ is.read(contents);
+ for (int i = 0; i < contents.length; i++) {
+ assertEquals(contents[i], CtsDownloadService.SAMPLE_FILE_DATA[i]);
+ }
+
+ List<Bundle> downloadResultAck =
+ getMiddlewareCalls(CtsDownloadService.METHOD_DOWNLOAD_RESULT_ACK);
+ assertEquals(1, downloadResultAck.size());
+ assertEquals(MbmsDownloadReceiver.RESULT_OK,
+ downloadResultAck.get(0).getInt(CtsDownloadService.ARGUMENT_RESULT_CODE, -1));
+ }
+}
diff --git a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadReceiverTest.java b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadReceiverTest.java
new file mode 100644
index 0000000..0d88f13
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadReceiverTest.java
@@ -0,0 +1,272 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package android.telephony.embms.cts;
+
+import android.content.BroadcastReceiver;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Handler;
+import android.telephony.MbmsDownloadSession;
+import android.telephony.cts.embmstestapp.CtsDownloadService;
+import android.telephony.mbms.DownloadRequest;
+import android.telephony.mbms.MbmsDownloadReceiver;
+import android.telephony.mbms.UriPathPair;
+import android.telephony.mbms.vendor.VendorUtils;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+public class MbmsDownloadReceiverTest extends MbmsDownloadTestBase {
+ private static final String CTS_BROADCAST_PERMISSION =
+ "android.telephony.embms.cts.permission.TEST_BROADCAST";
+ private static final String TEST_SERVICE_ID = "service_id";
+
+ public static final String APP_INTENT_ACTION =
+ "android.telephony.embms.cts.ACTION_TEST_DOWNLOAD_COMPLETE";
+ public static final DownloadRequest TEST_DOWNLOAD_REQUEST = DOWNLOAD_REQUEST_TEMPLATE
+ .setAppIntent(new Intent(APP_INTENT_ACTION))
+ .build();
+
+ public static class AppIntentCapture {
+ private final BlockingQueue<Intent> mReceivedIntent = new LinkedBlockingQueue<>();
+ private final BroadcastReceiver mAppIntentReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mReceivedIntent.add(intent);
+ }
+ };
+ private Context mContext;
+
+ public AppIntentCapture(Context context, Handler handler) {
+ mContext = context;
+ IntentFilter filter = new IntentFilter(APP_INTENT_ACTION);
+ mContext.registerReceiver(mAppIntentReceiver, filter, null, handler);
+ }
+
+ public Intent getIntent() {
+ try {
+ Intent result = mReceivedIntent.poll(ASYNC_TIMEOUT, TimeUnit.MILLISECONDS);
+ mContext.unregisterReceiver(mAppIntentReceiver);
+ return result;
+ } catch (InterruptedException e) {
+ fail("test was interrupted");
+ return null;
+ }
+ }
+ }
+
+ private MbmsDownloadReceiver mReceiver;
+ private File tempFileRootDir;
+ private String tempFileRootDirPath;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ mReceiver = new MbmsDownloadReceiver();
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(VendorUtils.ACTION_DOWNLOAD_RESULT_INTERNAL);
+ filter.addAction(VendorUtils.ACTION_CLEANUP);
+ filter.addAction(VendorUtils.ACTION_FILE_DESCRIPTOR_REQUEST);
+ mContext.registerReceiver(mReceiver, filter);
+ tempFileRootDir = new File(mContext.getFilesDir(), "CtsTestDir");
+ tempFileRootDir.mkdir();
+ tempFileRootDirPath = tempFileRootDir.getCanonicalPath();
+ try {
+ mDownloadSession.setTempFileRootDirectory(tempFileRootDir);
+ } catch (IllegalStateException e) {
+ tearDown();
+ throw e;
+ }
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ recursiveDelete(tempFileRootDir);
+ tempFileRootDir = null;
+ super.tearDown();
+ }
+
+ public void testMalformedIntents() throws Exception {
+ Intent downloadCompleteIntent = new Intent(VendorUtils.ACTION_DOWNLOAD_RESULT_INTERNAL);
+ sendBroadcastAndValidate(downloadCompleteIntent,
+ MbmsDownloadReceiver.RESULT_MALFORMED_INTENT);
+
+ Intent fdRequestIntent = new Intent(VendorUtils.ACTION_FILE_DESCRIPTOR_REQUEST);
+ sendBroadcastAndValidate(fdRequestIntent,
+ MbmsDownloadReceiver.RESULT_MALFORMED_INTENT);
+
+ Intent cleanupIntent = new Intent(VendorUtils.ACTION_CLEANUP);
+ sendBroadcastAndValidate(cleanupIntent,
+ MbmsDownloadReceiver.RESULT_MALFORMED_INTENT);
+ }
+
+ public void testBadTempFileDirectory() throws Exception {
+ Intent cleanupIntent = new Intent(VendorUtils.ACTION_CLEANUP);
+ populateIntentWithCommonFields(cleanupIntent);
+ cleanupIntent.putParcelableArrayListExtra(VendorUtils.EXTRA_TEMP_FILES_IN_USE,
+ new ArrayList<>(0));
+ cleanupIntent.putExtra(VendorUtils.EXTRA_TEMP_FILE_ROOT, "this is not a directory path");
+ sendBroadcastAndValidate(cleanupIntent,
+ MbmsDownloadReceiver.RESULT_BAD_TEMP_FILE_ROOT);
+ }
+
+ public void testDownloadFailureIntent() throws Exception {
+ Intent intentForReceiverTest = new Intent(VendorUtils.ACTION_DOWNLOAD_RESULT_INTERNAL);
+ populateIntentWithCommonFields(intentForReceiverTest);
+ intentForReceiverTest.putExtra(MbmsDownloadSession.EXTRA_MBMS_DOWNLOAD_RESULT,
+ MbmsDownloadSession.RESULT_CANCELLED);
+ intentForReceiverTest.putExtra(MbmsDownloadSession.EXTRA_MBMS_DOWNLOAD_REQUEST,
+ TEST_DOWNLOAD_REQUEST);
+
+ AppIntentCapture intentCaptor = new AppIntentCapture(mContext, mCallbackHandler);
+
+ sendBroadcastAndValidate(intentForReceiverTest, MbmsDownloadReceiver.RESULT_OK);
+ Intent receivedIntent = intentCaptor.getIntent();
+
+ assertEquals(MbmsDownloadSession.RESULT_CANCELLED,
+ receivedIntent.getIntExtra(MbmsDownloadSession.EXTRA_MBMS_DOWNLOAD_RESULT, -1));
+
+ assertEquals(TEST_DOWNLOAD_REQUEST,
+ receivedIntent.getParcelableExtra(MbmsDownloadSession.EXTRA_MBMS_DOWNLOAD_REQUEST));
+ }
+
+ public void testBadDownloadToken() {
+ // Set up a perfectly valid download completion intent, and expect it to fail because the
+ // download token hasn't been written.
+ Intent intentForReceiverTest = new Intent(VendorUtils.ACTION_DOWNLOAD_RESULT_INTERNAL);
+ populateIntentWithCommonFields(intentForReceiverTest);
+ intentForReceiverTest.putExtra(MbmsDownloadSession.EXTRA_MBMS_DOWNLOAD_RESULT,
+ MbmsDownloadSession.RESULT_SUCCESSFUL);
+ intentForReceiverTest.putExtra(MbmsDownloadSession.EXTRA_MBMS_DOWNLOAD_REQUEST,
+ TEST_DOWNLOAD_REQUEST);
+ intentForReceiverTest.putExtra(MbmsDownloadSession.EXTRA_MBMS_FILE_INFO,
+ CtsDownloadService.FILE_INFO);
+ intentForReceiverTest.putExtra(VendorUtils.EXTRA_FINAL_URI,
+ Uri.fromFile(new File(new File(tempFileRootDir, TEST_SERVICE_ID), "file1")));
+
+ sendBroadcastAndValidate(intentForReceiverTest,
+ MbmsDownloadReceiver.RESULT_MALFORMED_INTENT);
+ }
+
+ public void testRequestNoFileDescriptors() throws Exception {
+ Intent fdRequestIntent = new Intent(VendorUtils.ACTION_FILE_DESCRIPTOR_REQUEST);
+ populateIntentWithCommonFields(fdRequestIntent);
+
+ Bundle b = sendBroadcastAndValidate(fdRequestIntent, MbmsDownloadReceiver.RESULT_OK);
+ assertTrue(b == null || b.isEmpty());
+ }
+
+ public void testRequestNewFileDescriptors() throws Exception {
+ Intent fdRequestIntent = new Intent(VendorUtils.ACTION_FILE_DESCRIPTOR_REQUEST);
+ populateIntentWithCommonFields(fdRequestIntent);
+ fdRequestIntent.putExtra(VendorUtils.EXTRA_FD_COUNT, 5);
+
+ Bundle result = sendBroadcastAndValidate(fdRequestIntent, MbmsDownloadReceiver.RESULT_OK);
+ List<UriPathPair> freeUris = result.getParcelableArrayList(VendorUtils.EXTRA_FREE_URI_LIST);
+ assertNotNull(freeUris);
+ assertEquals(5, freeUris.size());
+ for (UriPathPair pathPair : freeUris) {
+ assertEquals(ContentResolver.SCHEME_CONTENT, pathPair.getContentUri().getScheme());
+ assertEquals(ContentResolver.SCHEME_FILE, pathPair.getFilePathUri().getScheme());
+ }
+ }
+
+ public void testRequestRefreshedFileDescriptors() throws Exception {
+ // Set up a few temp files that we can request again
+ Intent fdRequestIntent = new Intent(VendorUtils.ACTION_FILE_DESCRIPTOR_REQUEST);
+ populateIntentWithCommonFields(fdRequestIntent);
+ fdRequestIntent.putExtra(VendorUtils.EXTRA_FD_COUNT, 2);
+
+ Bundle result = sendBroadcastAndValidate(fdRequestIntent, MbmsDownloadReceiver.RESULT_OK);
+ List<UriPathPair> freeUris = result.getParcelableArrayList(VendorUtils.EXTRA_FREE_URI_LIST);
+
+ Intent fdRefreshIntent = new Intent(VendorUtils.ACTION_FILE_DESCRIPTOR_REQUEST);
+ populateIntentWithCommonFields(fdRefreshIntent);
+ fdRefreshIntent.putParcelableArrayListExtra(VendorUtils.EXTRA_PAUSED_LIST,
+ new ArrayList<>(freeUris.stream().map(UriPathPair::getFilePathUri)
+ .collect(Collectors.toList())));
+ Bundle result2 = sendBroadcastAndValidate(fdRefreshIntent, MbmsDownloadReceiver.RESULT_OK);
+ List<UriPathPair> refreshUris =
+ result2.getParcelableArrayList(VendorUtils.EXTRA_PAUSED_URI_LIST);
+ assertEquals(freeUris.size(), refreshUris.size());
+ for (UriPathPair pathPair : refreshUris) {
+ assertTrue(freeUris.stream()
+ .anyMatch((originalPair) ->
+ originalPair.getFilePathUri().equals(pathPair.getFilePathUri())));
+ }
+ }
+
+ private Bundle sendBroadcastAndValidate(Intent intent, int expectedCode) {
+ BlockingQueue<Bundle> receivedExtras = new LinkedBlockingQueue<>();
+ BlockingQueue<Integer> receivedCode = new LinkedBlockingQueue<>();
+ mContext.sendOrderedBroadcast(intent, CTS_BROADCAST_PERMISSION,
+ new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ receivedExtras.add(getResultExtras(true));
+ receivedCode.add(getResultCode());
+ }
+ }, mCallbackHandler, -1, null, null);
+
+ try {
+ assertEquals(expectedCode,
+ (int) receivedCode.poll(ASYNC_TIMEOUT, TimeUnit.MILLISECONDS));
+ return receivedExtras.poll(ASYNC_TIMEOUT, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ fail("Test interrupted");
+ return null;
+ }
+ }
+
+ private boolean bundleEquals(Bundle a, Bundle b) {
+ if (a == null && b == null) {
+ return true;
+ }
+ if (a == null || b == null) {
+ return false;
+ }
+ for (String aKey : a.keySet()) {
+ if (!Objects.equals(a.get(aKey), b.get(aKey))) {
+ return false;
+ }
+ }
+
+ for (String bKey : b.keySet()) {
+ if (!Objects.equals(b.get(bKey), a.get(bKey))) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private void populateIntentWithCommonFields(Intent intent) {
+ intent.putExtra(VendorUtils.EXTRA_SERVICE_ID, TEST_SERVICE_ID);
+ intent.putExtra(VendorUtils.EXTRA_TEMP_FILE_ROOT, tempFileRootDirPath);
+ }
+
+}
diff --git a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadSessionTest.java b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadSessionTest.java
new file mode 100644
index 0000000..6bd35c3
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadSessionTest.java
@@ -0,0 +1,204 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package android.telephony.embms.cts;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.telephony.MbmsDownloadSession;
+import android.telephony.cts.embmstestapp.CtsDownloadService;
+import android.telephony.cts.embmstestapp.CtsStreamingService;
+import android.telephony.mbms.DownloadRequest;
+import android.telephony.mbms.FileServiceInfo;
+import android.telephony.mbms.MbmsErrors;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+public class MbmsDownloadSessionTest extends MbmsDownloadTestBase {
+ public void testDuplicateSession() throws Exception {
+ try {
+ MbmsDownloadSession failure = MbmsDownloadSession.create(
+ mContext, mCallback, mCallbackHandler);
+ fail("Duplicate create should've thrown an exception");
+ } catch (IllegalStateException e) {
+ // Succeed
+ }
+ }
+
+ public void testRequestUpdateDownloadServices() throws Exception {
+ List<String> testClasses = Arrays.asList("class1", "class2");
+ mDownloadSession.requestUpdateFileServices(testClasses);
+
+ // Make sure we got the streaming services
+ List<FileServiceInfo> serviceInfos =
+ (List<FileServiceInfo>) mCallback.waitOnFileServicesUpdated().arg1;
+ assertEquals(CtsDownloadService.FILE_SERVICE_INFO, serviceInfos.get(0));
+ assertEquals(0, mCallback.getNumErrorCalls());
+
+ // Make sure the middleware got the call with the right args
+ List<Bundle> requestDownloadServicesCalls =
+ getMiddlewareCalls(CtsDownloadService.METHOD_REQUEST_UPDATE_FILE_SERVICES);
+ assertEquals(1, requestDownloadServicesCalls.size());
+ List<String> middlewareReceivedServiceClasses =
+ requestDownloadServicesCalls.get(0)
+ .getStringArrayList(CtsDownloadService.ARGUMENT_SERVICE_CLASSES);
+ assertEquals(testClasses.size(), middlewareReceivedServiceClasses.size());
+ for (int i = 0; i < testClasses.size(); i++) {
+ assertEquals(testClasses.get(i), middlewareReceivedServiceClasses.get(i));
+ }
+ }
+
+ public void testClose() throws Exception {
+ mDownloadSession.close();
+
+ // Make sure we can't use it anymore
+ try {
+ mDownloadSession.requestUpdateFileServices(Collections.emptyList());
+ fail("Download session should not be usable after close");
+ } catch (IllegalStateException e) {
+ // Succeed
+ }
+
+ // Make sure that the middleware got the call to close
+ List<Bundle> closeCalls = getMiddlewareCalls(CtsDownloadService.METHOD_CLOSE);
+ assertEquals(1, closeCalls.size());
+ }
+
+ public void testSetTempFileDirectory() throws Exception {
+ String tempFileDirName = "CTSTestDir";
+ File tempFileRootDirectory = new File(mContext.getFilesDir(), tempFileDirName);
+ tempFileRootDirectory.mkdirs();
+
+ mDownloadSession.setTempFileRootDirectory(tempFileRootDirectory);
+ List<Bundle> setTempRootCalls =
+ getMiddlewareCalls(CtsDownloadService.METHOD_SET_TEMP_FILE_ROOT);
+ assertEquals(1, setTempRootCalls.size());
+ assertEquals(tempFileRootDirectory.getCanonicalPath(),
+ setTempRootCalls.get(0).getString(CtsDownloadService.ARGUMENT_ROOT_DIRECTORY_PATH));
+ tempFileRootDirectory.delete();
+ }
+
+ public void testSetInvalidTempFileRoot() throws Exception {
+ File tempFileRootDirectory = new File(mContext.getFilesDir(), "NNN-DoesNotExist");
+ tempFileRootDirectory.delete();
+
+ try {
+ mDownloadSession.setTempFileRootDirectory(tempFileRootDirectory);
+ fail("Should not be able to set temp file root to non-existent directory");
+ } catch (IllegalArgumentException e) {
+ // success
+ }
+
+ tempFileRootDirectory = new File(mContext.getFilesDir(), "this-is-a-file.dat");
+ tempFileRootDirectory.createNewFile();
+
+ try {
+ mDownloadSession.setTempFileRootDirectory(tempFileRootDirectory);
+ fail("Should not be able to set temp file root to a file");
+ } catch (IllegalArgumentException e) {
+ // success
+ }
+
+ try {
+ mDownloadSession.setTempFileRootDirectory(mContext.getFilesDir());
+ fail("Should not be able to set temp file root to the files dir");
+ } catch (IllegalArgumentException e) {
+ // success
+ }
+
+ try {
+ mDownloadSession.setTempFileRootDirectory(mContext.getCacheDir());
+ fail("Should not be able to set temp file root to the cache dir");
+ } catch (IllegalArgumentException e) {
+ // success
+ }
+
+ try {
+ mDownloadSession.setTempFileRootDirectory(mContext.getDataDir());
+ fail("Should not be able to set temp file root to the data dir");
+ } catch (IllegalArgumentException e) {
+ // success
+ }
+
+ tempFileRootDirectory.delete();
+ }
+
+ public void testResetDownloadKnowledge() throws Exception {
+ DownloadRequest request = DOWNLOAD_REQUEST_TEMPLATE.build();
+ mDownloadSession.resetDownloadKnowledge(request);
+
+ List<Bundle> resetDownloadKnowledgeCalls =
+ getMiddlewareCalls(CtsDownloadService.METHOD_RESET_DOWNLOAD_KNOWLEDGE);
+ assertEquals(1, resetDownloadKnowledgeCalls.size());
+ assertEquals(request, resetDownloadKnowledgeCalls.get(0).getParcelable(
+ CtsDownloadService.ARGUMENT_DOWNLOAD_REQUEST));
+ }
+
+ public void testGetDownloadStatus() throws Exception {
+ DownloadRequest request = DOWNLOAD_REQUEST_TEMPLATE.build();
+ mDownloadSession.getDownloadStatus(request, CtsDownloadService.FILE_INFO);
+
+ List<Bundle> getDownloadStatusCalls =
+ getMiddlewareCalls(CtsDownloadService.METHOD_GET_DOWNLOAD_STATUS);
+ assertEquals(1, getDownloadStatusCalls.size());
+ assertEquals(request, getDownloadStatusCalls.get(0).getParcelable(
+ CtsDownloadService.ARGUMENT_DOWNLOAD_REQUEST));
+ assertEquals(CtsDownloadService.FILE_INFO, getDownloadStatusCalls.get(0).getParcelable(
+ CtsDownloadService.ARGUMENT_FILE_INFO));
+ }
+
+ public void testCancelDownload() throws Exception {
+ DownloadRequest request = DOWNLOAD_REQUEST_TEMPLATE.build();
+ mDownloadSession.cancelDownload(request);
+
+ List<Bundle> cancelDownloadCalls =
+ getMiddlewareCalls(CtsDownloadService.METHOD_CANCEL_DOWNLOAD);
+ assertEquals(1, cancelDownloadCalls.size());
+ assertEquals(request, cancelDownloadCalls.get(0).getParcelable(
+ CtsDownloadService.ARGUMENT_DOWNLOAD_REQUEST));
+ }
+
+ public void testListPendingDownloads() throws Exception {
+ DownloadRequest request = DOWNLOAD_REQUEST_TEMPLATE.setAppIntent(new Intent()).build();
+ mDownloadSession.download(request);
+
+ List<DownloadRequest> downloads = mDownloadSession.listPendingDownloads();
+ assertEquals(1, downloads.size());
+ assertEquals(request, downloads.get(0));
+ }
+
+ public void testDownloadRequestOpacity() throws Exception {
+ Intent intent = new Intent("sample_intent_action");
+ DownloadRequest request = DOWNLOAD_REQUEST_TEMPLATE.setAppIntent(intent).build();
+ DownloadRequest newRequest = new DownloadRequest.Builder(request.getSourceUri())
+ .setServiceId(request.getFileServiceId())
+ .setSubscriptionId(request.getSubscriptionId())
+ .setOpaqueData(request.getOpaqueData())
+ .build();
+ assertEquals(request, newRequest);
+ }
+
+ public void testErrorDelivery() throws Exception {
+ mMiddlewareControl.forceErrorCode(
+ MbmsErrors.GeneralErrors.ERROR_MIDDLEWARE_TEMPORARILY_UNAVAILABLE);
+ mDownloadSession.requestUpdateFileServices(Collections.emptyList());
+ assertEquals(MbmsErrors.GeneralErrors.ERROR_MIDDLEWARE_TEMPORARILY_UNAVAILABLE,
+ mCallback.waitOnError().arg1);
+ }
+}
diff --git a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadStateCallbackTest.java b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadStateCallbackTest.java
new file mode 100644
index 0000000..a5cc2d0
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadStateCallbackTest.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package android.telephony.embms.cts;
+
+import android.telephony.MbmsDownloadSession;
+import android.telephony.cts.embmstestapp.CtsDownloadService;
+import android.telephony.mbms.DownloadRequest;
+import android.telephony.mbms.DownloadStateCallback;
+import android.telephony.mbms.FileInfo;
+
+import com.android.internal.os.SomeArgs;
+
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+public class MbmsDownloadStateCallbackTest extends MbmsDownloadTestBase {
+ private static final long SHORT_TIMEOUT = 500;
+
+ private class TestDSCallback extends DownloadStateCallback {
+ private final BlockingQueue<SomeArgs> mProgressUpdatedCalls = new LinkedBlockingQueue<>();
+ private final BlockingQueue<SomeArgs> mStateUpdatedCalls = new LinkedBlockingQueue<>();
+
+ public TestDSCallback(int filterFlags) {
+ super(filterFlags);
+ }
+
+ @Override
+ public void onProgressUpdated(DownloadRequest request, FileInfo fileInfo, int
+ currentDownloadSize, int fullDownloadSize, int currentDecodedSize, int
+ fullDecodedSize) {
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = request;
+ args.arg2 = fileInfo;
+ args.arg3 = currentDownloadSize;
+ args.arg4 = fullDownloadSize;
+ args.arg5 = currentDecodedSize;
+ args.arg6 = fullDecodedSize;
+ mProgressUpdatedCalls.add(args);
+ }
+
+ @Override
+ public void onStateUpdated(DownloadRequest request, FileInfo fileInfo,
+ @MbmsDownloadSession.DownloadStatus int state) {
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = request;
+ args.arg2 = fileInfo;
+ args.arg3 = state;
+ mStateUpdatedCalls.add(args);
+ }
+
+ public SomeArgs waitOnProgressUpdated(long timeout) {
+ try {
+ return mProgressUpdatedCalls.poll(timeout, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ return null;
+ }
+ }
+
+ public SomeArgs waitOnStateUpdated(long timeout) {
+ try {
+ return mStateUpdatedCalls.poll(timeout, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ return null;
+ }
+ }
+ }
+
+ public void testFullCallback() throws Exception {
+ int sampleInt = 10;
+ TestDSCallback callback = new TestDSCallback(DownloadStateCallback.ALL_UPDATES);
+ DownloadRequest request = DOWNLOAD_REQUEST_TEMPLATE.build();
+ mDownloadSession.registerStateCallback(request, callback, mCallbackHandler);
+ mMiddlewareControl.fireOnProgressUpdated(request, CtsDownloadService.FILE_INFO,
+ sampleInt, sampleInt, sampleInt, sampleInt);
+ SomeArgs progressArgs = callback.waitOnProgressUpdated(ASYNC_TIMEOUT);
+ assertEquals(request, progressArgs.arg1);
+ assertEquals(CtsDownloadService.FILE_INFO, progressArgs.arg2);
+ assertEquals(sampleInt, progressArgs.arg3);
+ assertEquals(sampleInt, progressArgs.arg4);
+ assertEquals(sampleInt, progressArgs.arg5);
+ assertEquals(sampleInt, progressArgs.arg6);
+
+ mMiddlewareControl.fireOnStateUpdated(request, CtsDownloadService.FILE_INFO, sampleInt);
+ SomeArgs stateArgs = callback.waitOnStateUpdated(ASYNC_TIMEOUT);
+ assertEquals(request, stateArgs.arg1);
+ assertEquals(CtsDownloadService.FILE_INFO, stateArgs.arg2);
+ assertEquals(sampleInt, stateArgs.arg3);
+ }
+
+ public void testDeregistration() throws Exception {
+ TestDSCallback callback = new TestDSCallback(DownloadStateCallback.ALL_UPDATES);
+ DownloadRequest request = DOWNLOAD_REQUEST_TEMPLATE.build();
+ mDownloadSession.registerStateCallback(request, callback, mCallbackHandler);
+ mDownloadSession.unregisterStateCallback(request, callback);
+
+ mMiddlewareControl.fireOnStateUpdated(null, null, 0);
+ assertNull(callback.waitOnStateUpdated(SHORT_TIMEOUT));
+ mMiddlewareControl.fireOnProgressUpdated(null, null, 0, 0, 0, 0);
+ assertNull(callback.waitOnProgressUpdated(SHORT_TIMEOUT));
+ }
+
+ public void testCallbackFiltering1() throws Exception {
+ TestDSCallback callback = new TestDSCallback(DownloadStateCallback.PROGRESS_UPDATES);
+ DownloadRequest request = DOWNLOAD_REQUEST_TEMPLATE.build();
+ mDownloadSession.registerStateCallback(request, callback, mCallbackHandler);
+
+ mMiddlewareControl.fireOnStateUpdated(null, null, 0);
+ assertNull(callback.waitOnStateUpdated(SHORT_TIMEOUT));
+ mMiddlewareControl.fireOnProgressUpdated(null, null, 0, 0, 0, 0);
+ assertNotNull(callback.waitOnProgressUpdated(SHORT_TIMEOUT));
+ }
+
+ public void testCallbackFiltering2() throws Exception {
+ TestDSCallback callback = new TestDSCallback(DownloadStateCallback.STATE_UPDATES);
+ DownloadRequest request = DOWNLOAD_REQUEST_TEMPLATE.build();
+ mDownloadSession.registerStateCallback(request, callback, mCallbackHandler);
+
+ mMiddlewareControl.fireOnStateUpdated(null, null, 0);
+ assertNotNull(callback.waitOnStateUpdated(SHORT_TIMEOUT));
+ mMiddlewareControl.fireOnProgressUpdated(null, null, 0, 0, 0, 0);
+ assertNull(callback.waitOnProgressUpdated(SHORT_TIMEOUT));
+ }
+}
diff --git a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadTestBase.java b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadTestBase.java
new file mode 100644
index 0000000..9da5f04
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsDownloadTestBase.java
@@ -0,0 +1,187 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package android.telephony.embms.cts;
+
+import android.annotation.Nullable;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.telephony.MbmsDownloadSession;
+import android.telephony.cts.embmstestapp.CtsDownloadService;
+import android.telephony.cts.embmstestapp.ICtsDownloadMiddlewareControl;
+import android.telephony.mbms.DownloadRequest;
+import android.telephony.mbms.FileServiceInfo;
+import android.telephony.mbms.MbmsDownloadSessionCallback;
+import android.test.InstrumentationTestCase;
+import android.util.Log;
+
+import com.android.internal.os.SomeArgs;
+
+import java.io.File;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+public class MbmsDownloadTestBase extends InstrumentationTestCase {
+ protected static final int ASYNC_TIMEOUT = 10000;
+
+ protected static class TestCallback extends MbmsDownloadSessionCallback {
+ private final BlockingQueue<SomeArgs> mErrorCalls = new LinkedBlockingQueue<>();
+ private final BlockingQueue<SomeArgs> mFileServicesUpdatedCalls =
+ new LinkedBlockingQueue<>();
+ private final BlockingQueue<SomeArgs> mMiddlewareReadyCalls = new LinkedBlockingQueue<>();
+ private int mNumErrorCalls = 0;
+
+ @Override
+ public void onError(int errorCode, @Nullable String message) {
+ mNumErrorCalls += 1;
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = errorCode;
+ args.arg2 = message;
+ mErrorCalls.add(args);
+ Log.i(MbmsDownloadTestBase.class.getSimpleName(),
+ "Got error: " + errorCode + ": " + message);
+ }
+
+ @Override
+ public void onFileServicesUpdated(List<FileServiceInfo> services) {
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = services;
+ mFileServicesUpdatedCalls.add(args);
+ }
+
+ @Override
+ public void onMiddlewareReady() {
+ mMiddlewareReadyCalls.add(SomeArgs.obtain());
+ }
+
+ public SomeArgs waitOnError() {
+ try {
+ return mErrorCalls.poll(ASYNC_TIMEOUT, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ return null;
+ }
+ }
+
+ public boolean waitOnMiddlewareReady() {
+ try {
+ return mMiddlewareReadyCalls.poll(ASYNC_TIMEOUT, TimeUnit.MILLISECONDS) != null;
+ } catch (InterruptedException e) {
+ return false;
+ }
+ }
+
+ public SomeArgs waitOnFileServicesUpdated() {
+ try {
+ return mFileServicesUpdatedCalls.poll(ASYNC_TIMEOUT, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ return null;
+ }
+ }
+
+ public int getNumErrorCalls() {
+ return mNumErrorCalls;
+ }
+ }
+
+ static final DownloadRequest.Builder DOWNLOAD_REQUEST_TEMPLATE =
+ new DownloadRequest.Builder(CtsDownloadService.DOWNLOAD_SOURCE_URI)
+ .setServiceInfo(CtsDownloadService.FILE_SERVICE_INFO);
+
+ Context mContext;
+ HandlerThread mHandlerThread;
+ Handler mCallbackHandler;
+ ICtsDownloadMiddlewareControl mMiddlewareControl;
+ MbmsDownloadSession mDownloadSession;
+ TestCallback mCallback = new TestCallback();
+
+ @Override
+ public void setUp() throws Exception {
+ mContext = getInstrumentation().getContext();
+ mHandlerThread = new HandlerThread("EmbmsCtsTestWorker");
+ mHandlerThread.start();
+ mCallbackHandler = new Handler(mHandlerThread.getLooper());
+ mCallback = new TestCallback();
+ getControlBinder();
+ setupDownloadSession();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ mHandlerThread.quit();
+ mDownloadSession.close();
+ mMiddlewareControl.reset();
+ }
+
+ private void setupDownloadSession() throws Exception {
+ mDownloadSession = MbmsDownloadSession.create(
+ mContext, mCallback, mCallbackHandler);
+ assertNotNull(mDownloadSession);
+ assertTrue(mCallback.waitOnMiddlewareReady());
+ assertEquals(0, mCallback.getNumErrorCalls());
+ Bundle initializeCall = mMiddlewareControl.getDownloadSessionCalls().get(0);
+ assertEquals(CtsDownloadService.METHOD_INITIALIZE,
+ initializeCall.getString(CtsDownloadService.METHOD_NAME));
+ }
+
+ private void getControlBinder() throws InterruptedException {
+ Intent bindIntent = new Intent(CtsDownloadService.CONTROL_INTERFACE_ACTION);
+ bindIntent.setComponent(CtsDownloadService.CONTROL_INTERFACE_COMPONENT);
+ final CountDownLatch bindLatch = new CountDownLatch(1);
+
+ boolean success = mContext.bindService(bindIntent, new ServiceConnection() {
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ mMiddlewareControl = ICtsDownloadMiddlewareControl.Stub.asInterface(service);
+ bindLatch.countDown();
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ mMiddlewareControl = null;
+ }
+ }, Context.BIND_AUTO_CREATE);
+ if (!success) {
+ fail("Failed to get control interface -- bind error");
+ }
+ bindLatch.await(ASYNC_TIMEOUT, TimeUnit.MILLISECONDS);
+ }
+
+ protected List<Bundle> getMiddlewareCalls(String methodName) throws RemoteException {
+ return (mMiddlewareControl.getDownloadSessionCalls()).stream()
+ .filter((elem) -> elem.getString(CtsDownloadService.METHOD_NAME).equals(methodName))
+ .collect(Collectors.toList());
+ }
+
+ protected static void recursiveDelete(File f) {
+ if (f.isDirectory()) {
+ for (File f1 : f.listFiles()) {
+ recursiveDelete(f1);
+ }
+ }
+ f.delete();
+ }
+}
\ No newline at end of file
diff --git a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsStreamingServiceTest.java b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsStreamingServiceTest.java
new file mode 100644
index 0000000..42e5618
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsStreamingServiceTest.java
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package android.telephony.embms.cts;
+
+import android.annotation.Nullable;
+import android.telephony.cts.embmstestapp.CtsStreamingService;
+import android.telephony.mbms.MbmsErrors;
+import android.telephony.mbms.StreamingService;
+import android.telephony.mbms.StreamingServiceCallback;
+
+import com.android.internal.os.SomeArgs;
+
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+public class MbmsStreamingServiceTest extends MbmsStreamingTestBase {
+ private class TestStreamingServiceCallback extends StreamingServiceCallback {
+ private final BlockingQueue<SomeArgs> mErrorCalls = new LinkedBlockingQueue<>();
+ private final BlockingQueue<SomeArgs> mStreamStateUpdatedCalls =
+ new LinkedBlockingQueue<>();
+ private final BlockingQueue<SomeArgs> mMediaDescriptionUpdatedCalls =
+ new LinkedBlockingQueue<>();
+ private final BlockingQueue<SomeArgs> mBroadcastSignalStrengthUpdatedCalls =
+ new LinkedBlockingQueue<>();
+ private final BlockingQueue<SomeArgs> mStreamMethodUpdatedCalls =
+ new LinkedBlockingQueue<>();
+
+ @Override
+ public void onError(int errorCode, @Nullable String message) {
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = errorCode;
+ args.arg2 = message;
+ mErrorCalls.add(args);
+ }
+
+ @Override
+ public void onStreamStateUpdated(@StreamingService.StreamingState int state,
+ @StreamingService.StreamingStateChangeReason int reason) {
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = state;
+ args.arg2 = reason;
+ mStreamStateUpdatedCalls.add(args);
+ }
+
+ @Override
+ public void onMediaDescriptionUpdated() {
+ SomeArgs args = SomeArgs.obtain();
+ mMediaDescriptionUpdatedCalls.add(args);
+ }
+
+ @Override
+ public void onBroadcastSignalStrengthUpdated(int signalStrength) {
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = signalStrength;
+ mBroadcastSignalStrengthUpdatedCalls.add(args);
+ }
+
+ @Override
+ public void onStreamMethodUpdated(int methodType) {
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = methodType;
+ mStreamMethodUpdatedCalls.add(args);
+ }
+
+ public SomeArgs waitOnError() {
+ try {
+ return mErrorCalls.poll(ASYNC_TIMEOUT, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ return null;
+ }
+ }
+
+ public SomeArgs waitOnStreamStateUpdated() {
+ try {
+ return mStreamStateUpdatedCalls.poll(ASYNC_TIMEOUT, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ return null;
+ }
+ }
+
+ public SomeArgs waitOnMediaDescriptionUpdated() {
+ try {
+ return mMediaDescriptionUpdatedCalls.poll(ASYNC_TIMEOUT, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ return null;
+ }
+ }
+
+ public SomeArgs waitOnBroadcastSignalStrengthUpdated() {
+ try {
+ return mBroadcastSignalStrengthUpdatedCalls.poll(
+ ASYNC_TIMEOUT, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ return null;
+ }
+ }
+
+ public SomeArgs waitOnStreamMethodUpdated() {
+ try {
+ return mStreamMethodUpdatedCalls.poll(ASYNC_TIMEOUT, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ return null;
+ }
+ }
+
+ }
+
+ private TestStreamingServiceCallback mStreamingServiceCallback =
+ new TestStreamingServiceCallback();
+
+ public void testStartStreaming() throws Exception {
+ StreamingService streamingService = mStreamingSession.startStreaming(
+ CtsStreamingService .STREAMING_SERVICE_INFO,
+ mStreamingServiceCallback, mCallbackHandler);
+ assertNotNull(streamingService);
+ assertEquals(CtsStreamingService.STREAMING_SERVICE_INFO, streamingService.getInfo());
+
+ SomeArgs args = mStreamingServiceCallback.waitOnStreamStateUpdated();
+ assertEquals(StreamingService.STATE_STARTED, args.arg1);
+ assertEquals(StreamingService.REASON_BY_USER_REQUEST, args.arg2);
+
+ List<List<Object>> startStreamingCalls =
+ getMiddlewareCalls(CtsStreamingService.METHOD_START_STREAMING);
+ assertEquals(1, startStreamingCalls.size());
+ assertEquals(CtsStreamingService.STREAMING_SERVICE_INFO.getServiceId(),
+ startStreamingCalls.get(0).get(2));
+ }
+
+ public void testGetPlaybackUri() throws Exception {
+ StreamingService streamingService = mStreamingSession.startStreaming(
+ CtsStreamingService .STREAMING_SERVICE_INFO,
+ mStreamingServiceCallback, mCallbackHandler);
+ assertEquals(CtsStreamingService.STREAMING_URI, streamingService.getPlaybackUri());
+
+ List<List<Object>> getPlaybackUriCalls =
+ getMiddlewareCalls(CtsStreamingService.METHOD_GET_PLAYBACK_URI);
+ assertEquals(1, getPlaybackUriCalls.size());
+ assertEquals(CtsStreamingService.STREAMING_SERVICE_INFO.getServiceId(),
+ getPlaybackUriCalls.get(0).get(2));
+ }
+
+ public void testStopStreaming() throws Exception {
+ StreamingService streamingService = mStreamingSession.startStreaming(
+ CtsStreamingService .STREAMING_SERVICE_INFO,
+ mStreamingServiceCallback, mCallbackHandler);
+ streamingService.stopStreaming();
+ List<List<Object>> stopStreamingCalls =
+ getMiddlewareCalls(CtsStreamingService.METHOD_STOP_STREAMING);
+ assertEquals(1, stopStreamingCalls.size());
+ assertEquals(CtsStreamingService.STREAMING_SERVICE_INFO.getServiceId(),
+ stopStreamingCalls.get(0).get(2));
+ }
+
+ public void testStreamingCallbacks() throws Exception {
+ mStreamingSession.startStreaming(
+ CtsStreamingService .STREAMING_SERVICE_INFO,
+ mStreamingServiceCallback, mCallbackHandler);
+
+ mMiddlewareControl.fireErrorOnStream(
+ MbmsErrors.StreamingErrors.ERROR_UNABLE_TO_START_SERVICE, "");
+ assertEquals(MbmsErrors.StreamingErrors.ERROR_UNABLE_TO_START_SERVICE,
+ mStreamingServiceCallback.waitOnError().arg1);
+
+ mMiddlewareControl.fireOnMediaDescriptionUpdated();
+ assertNotNull(mStreamingServiceCallback.waitOnMediaDescriptionUpdated());
+
+ int broadcastSignalStrength = 3;
+ mMiddlewareControl.fireOnBroadcastSignalStrengthUpdated(broadcastSignalStrength);
+ assertEquals(broadcastSignalStrength,
+ mStreamingServiceCallback.waitOnBroadcastSignalStrengthUpdated().arg1);
+
+ mMiddlewareControl.fireOnStreamMethodUpdated(StreamingService.BROADCAST_METHOD);
+ assertEquals(StreamingService.BROADCAST_METHOD,
+ mStreamingServiceCallback.waitOnStreamMethodUpdated().arg1);
+ }
+
+ public void testStartStreamingFailure() throws Exception {
+ mMiddlewareControl.forceErrorCode(
+ MbmsErrors.GeneralErrors.ERROR_MIDDLEWARE_TEMPORARILY_UNAVAILABLE);
+ mStreamingSession.startStreaming(CtsStreamingService.STREAMING_SERVICE_INFO,
+ mStreamingServiceCallback, mCallbackHandler);
+ assertEquals(MbmsErrors.GeneralErrors.ERROR_MIDDLEWARE_TEMPORARILY_UNAVAILABLE,
+ mCallback.waitOnError().arg1);
+ }
+}
diff --git a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsStreamingSessionTest.java b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsStreamingSessionTest.java
new file mode 100644
index 0000000..92b3fc9
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsStreamingSessionTest.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package android.telephony.embms.cts;
+
+import android.telephony.MbmsStreamingSession;
+import android.telephony.cts.embmstestapp.CtsStreamingService;
+import android.telephony.mbms.MbmsErrors;
+import android.telephony.mbms.StreamingServiceInfo;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+public class MbmsStreamingSessionTest extends MbmsStreamingTestBase {
+ public void testDuplicateSession() throws Exception {
+ try {
+ MbmsStreamingSession failure = MbmsStreamingSession.create(
+ mContext, mCallback, mCallbackHandler);
+ fail("Duplicate create should've thrown an exception");
+ } catch (IllegalStateException e) {
+ // Succeed
+ }
+ }
+
+ public void testRequestUpdateStreamingServices() throws Exception {
+ List<String> testClasses = Arrays.asList("class1", "class2");
+ mStreamingSession.requestUpdateStreamingServices(testClasses);
+
+ // Make sure we got the streaming services
+ List<StreamingServiceInfo> serviceInfos =
+ (List<StreamingServiceInfo>) mCallback.waitOnStreamingServicesUpdated().arg1;
+ assertEquals(CtsStreamingService.STREAMING_SERVICE_INFO, serviceInfos.get(0));
+ assertEquals(0, mCallback.getNumErrorCalls());
+
+ // Make sure the middleware got the call with the right args
+ List<List<Object>> requestStreamingServicesCalls =
+ getMiddlewareCalls(CtsStreamingService.METHOD_REQUEST_UPDATE_STREAMING_SERVICES);
+ assertEquals(1, requestStreamingServicesCalls.size());
+ assertEquals(3, requestStreamingServicesCalls.get(0).size());
+ List<String> middlewareReceivedServiceClasses =
+ (List<String>) requestStreamingServicesCalls.get(0).get(2);
+ assertEquals(testClasses.size(), middlewareReceivedServiceClasses.size());
+ for (int i = 0; i < testClasses.size(); i++) {
+ assertEquals(testClasses.get(i), middlewareReceivedServiceClasses.get(i));
+ }
+ }
+
+ public void testClose() throws Exception {
+ mStreamingSession.close();
+
+ // Make sure we can't use it anymore
+ try {
+ mStreamingSession.requestUpdateStreamingServices(Collections.emptyList());
+ fail("Streaming session should not be usable after close");
+ } catch (IllegalStateException e) {
+ // Succeed
+ }
+
+ // Make sure that the middleware got the call to close
+ List<List<Object>> closeCalls = getMiddlewareCalls(CtsStreamingService.METHOD_CLOSE);
+ assertEquals(1, closeCalls.size());
+ }
+
+ public void testErrorDelivery() throws Exception {
+ mMiddlewareControl.forceErrorCode(
+ MbmsErrors.GeneralErrors.ERROR_MIDDLEWARE_TEMPORARILY_UNAVAILABLE);
+ mStreamingSession.requestUpdateStreamingServices(Collections.emptyList());
+ assertEquals(MbmsErrors.GeneralErrors.ERROR_MIDDLEWARE_TEMPORARILY_UNAVAILABLE,
+ mCallback.waitOnError().arg1);
+ }
+}
diff --git a/tests/tests/telephony/src/android/telephony/embms/cts/MbmsStreamingTestBase.java b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsStreamingTestBase.java
new file mode 100644
index 0000000..e170998
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/embms/cts/MbmsStreamingTestBase.java
@@ -0,0 +1,151 @@
+package android.telephony.embms.cts;
+
+import android.annotation.Nullable;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.telephony.MbmsStreamingSession;
+import android.telephony.cts.embmstestapp.CtsStreamingService;
+import android.telephony.cts.embmstestapp.ICtsStreamingMiddlewareControl;
+import android.telephony.mbms.MbmsStreamingSessionCallback;
+import android.telephony.mbms.StreamingServiceInfo;
+import android.test.InstrumentationTestCase;
+
+import com.android.internal.os.SomeArgs;
+
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+public class MbmsStreamingTestBase extends InstrumentationTestCase {
+ protected static final int ASYNC_TIMEOUT = 10000;
+
+ protected static class TestCallback extends MbmsStreamingSessionCallback {
+ private final BlockingQueue<SomeArgs> mErrorCalls = new LinkedBlockingQueue<>();
+ private final BlockingQueue<SomeArgs> mStreamingServicesUpdatedCalls =
+ new LinkedBlockingQueue<>();
+ private final BlockingQueue<SomeArgs> mMiddlewareReadyCalls = new LinkedBlockingQueue<>();
+ private int mNumErrorCalls = 0;
+
+ @Override
+ public void onError(int errorCode, @Nullable String message) {
+ mNumErrorCalls += 1;
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = errorCode;
+ args.arg2 = message;
+ mErrorCalls.add(args);
+ }
+
+ @Override
+ public void onStreamingServicesUpdated(List<StreamingServiceInfo> services) {
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = services;
+ mStreamingServicesUpdatedCalls.add(args);
+ }
+
+ @Override
+ public void onMiddlewareReady() {
+ mMiddlewareReadyCalls.add(SomeArgs.obtain());
+ }
+
+ public SomeArgs waitOnError() {
+ try {
+ return mErrorCalls.poll(ASYNC_TIMEOUT, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ return null;
+ }
+ }
+
+ public SomeArgs waitOnStreamingServicesUpdated() {
+ try {
+ return mStreamingServicesUpdatedCalls.poll(ASYNC_TIMEOUT, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ return null;
+ }
+ }
+
+ public boolean waitOnMiddlewareReady() {
+ try {
+ return mMiddlewareReadyCalls.poll(ASYNC_TIMEOUT, TimeUnit.MILLISECONDS) != null;
+ } catch (InterruptedException e) {
+ return false;
+ }
+ }
+
+ public int getNumErrorCalls() {
+ return mNumErrorCalls;
+ }
+ }
+
+ Context mContext;
+ HandlerThread mHandlerThread;
+ Handler mCallbackHandler;
+ ICtsStreamingMiddlewareControl mMiddlewareControl;
+ MbmsStreamingSession mStreamingSession;
+ TestCallback mCallback = new TestCallback();
+
+ @Override
+ public void setUp() throws Exception {
+ mContext = getInstrumentation().getContext();
+ mHandlerThread = new HandlerThread("EmbmsCtsTestWorker");
+ mHandlerThread.start();
+ mCallbackHandler = new Handler(mHandlerThread.getLooper());
+ mCallback = new TestCallback();
+ getControlBinder();
+ setupStreamingSession();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ mHandlerThread.quit();
+ mStreamingSession.close();
+ mMiddlewareControl.reset();
+ }
+
+ private void setupStreamingSession() throws Exception {
+ mStreamingSession = MbmsStreamingSession.create(
+ mContext, mCallback, mCallbackHandler);
+ assertNotNull(mStreamingSession);
+ assertTrue(mCallback.waitOnMiddlewareReady());
+ assertEquals(0, mCallback.getNumErrorCalls());
+ List initializeCall = (List) mMiddlewareControl.getStreamingSessionCalls().get(0);
+ assertEquals(CtsStreamingService.METHOD_INITIALIZE, initializeCall.get(0));
+ }
+
+ private void getControlBinder() throws InterruptedException {
+ Intent bindIntent = new Intent(CtsStreamingService.CONTROL_INTERFACE_ACTION);
+ bindIntent.setComponent(CtsStreamingService.CONTROL_INTERFACE_COMPONENT);
+ final CountDownLatch bindLatch = new CountDownLatch(1);
+
+ boolean success = mContext.bindService(bindIntent, new ServiceConnection() {
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ mMiddlewareControl = ICtsStreamingMiddlewareControl.Stub.asInterface(service);
+ bindLatch.countDown();
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ mMiddlewareControl = null;
+ }
+ }, Context.BIND_AUTO_CREATE);
+ if (!success) {
+ fail("Failed to get control interface -- bind error");
+ }
+ bindLatch.await(ASYNC_TIMEOUT, TimeUnit.MILLISECONDS);
+ }
+
+ protected List<List<Object>> getMiddlewareCalls(String methodName) throws RemoteException {
+ return ((List<List<Object>>) mMiddlewareControl.getStreamingSessionCalls()).stream()
+ .filter((elem) -> elem.get(0).equals(methodName))
+ .collect(Collectors.toList());
+ }
+}
\ No newline at end of file
diff --git a/tests/tests/text/src/android/text/cts/TextUtilsTest.java b/tests/tests/text/src/android/text/cts/TextUtilsTest.java
index d549cfa..2fd4e59 100644
--- a/tests/tests/text/src/android/text/cts/TextUtilsTest.java
+++ b/tests/tests/text/src/android/text/cts/TextUtilsTest.java
@@ -1563,7 +1563,7 @@
assertFalse(TextUtils.isGraphic('\u0085'));
// UNASSIGNED
- assertFalse(TextUtils.isGraphic('\u0D00'));
+ assertFalse(TextUtils.isGraphic('\uFFFF'));
// SURROGATE
assertFalse(TextUtils.isGraphic('\uD800'));
@@ -1581,9 +1581,9 @@
public void testIsGraphicCharSequence() {
assertTrue(TextUtils.isGraphic("printable characters"));
- assertFalse(TextUtils.isGraphic("\u2028\u2029\u0085\u0D00\uD800\u0020"));
+ assertFalse(TextUtils.isGraphic("\u2028\u2029\u0085\uFFFF\uD800\u0020"));
- assertTrue(TextUtils.isGraphic("a\u2028\u2029\u0085\u0D00\uD800\u0020"));
+ assertTrue(TextUtils.isGraphic("a\u2028\u2029\u0085\uFFFF\uD800\u0020"));
assertTrue(TextUtils.isGraphic("\uD83D\uDC0C")); // U+1F40C SNAIL
assertFalse(TextUtils.isGraphic("\uDB40\uDC01")); // U+E0000 (unassigned)
diff --git a/tests/tests/uidisolation/AndroidManifest.xml b/tests/tests/uidisolation/AndroidManifest.xml
index 0d27e37..822eeea 100644
--- a/tests/tests/uidisolation/AndroidManifest.xml
+++ b/tests/tests/uidisolation/AndroidManifest.xml
@@ -18,8 +18,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.uidisolation.cts">
- <uses-library android:name="org.apache.http.legacy" android:required="false" />
-
<application android:label="UidIsolationTest">
<activity android:name="android.uidisolation.cts.ServiceRunnerActivity"
android:label="UidIsolationTest"/>
@@ -29,6 +27,7 @@
android:process=":remote"
android:isolatedProcess="true"/>
<uses-library android:name="android.test.runner" />
+ <uses-library android:name="org.apache.http.legacy" android:required="false" />
</application>
<uses-permission android:name="android.permission.INTERNET"/>
diff --git a/tests/tests/view/jni/Android.mk b/tests/tests/view/jni/Android.mk
index 288e250..f1aad68 100644
--- a/tests/tests/view/jni/Android.mk
+++ b/tests/tests/view/jni/Android.mk
@@ -32,6 +32,4 @@
LOCAL_CXX_STL := libc++_static
-LOCAL_CLANG := true
-
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/widget/src/android/widget/cts/ListPopupWindowTest.java b/tests/tests/widget/src/android/widget/cts/ListPopupWindowTest.java
index 70f9661..88f3450 100644
--- a/tests/tests/widget/src/android/widget/cts/ListPopupWindowTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ListPopupWindowTest.java
@@ -528,15 +528,19 @@
assertTrue(promptView.isShown());
assertEquals(ListPopupWindow.POSITION_PROMPT_ABOVE, mPopupWindow.getPromptPosition());
- final int[] promptViewOnScreenXY = new int[2];
- promptView.getLocationOnScreen(promptViewOnScreenXY);
-
final ListView listView = mPopupWindow.getListView();
WidgetTestUtils.runOnMainAndDrawSync(mActivityRule, listView, null);
- final View firstListChild = listView.getChildAt(0);
+ final int[] promptViewOnScreenXY = new int[2];
final int[] firstChildOnScreenXY = new int[2];
- firstListChild.getLocationOnScreen(firstChildOnScreenXY);
+
+ mActivityRule.runOnUiThread(()-> {
+ promptView.getLocationOnScreen(promptViewOnScreenXY);
+
+ final View firstListChild = listView.getChildAt(0);
+ firstListChild.getLocationOnScreen(firstChildOnScreenXY);
+ });
+ mInstrumentation.waitForIdleSync();
assertTrue(promptViewOnScreenXY[1] + promptView.getHeight() <= firstChildOnScreenXY[1]);
}
@@ -560,11 +564,15 @@
WidgetTestUtils.runOnMainAndDrawSync(mActivityRule, listView, null);
final int[] promptViewOnScreenXY = new int[2];
- promptView.getLocationOnScreen(promptViewOnScreenXY);
-
- final View lastListChild = listView.getChildAt(listView.getChildCount() - 1);
final int[] lastChildOnScreenXY = new int[2];
- lastListChild.getLocationOnScreen(lastChildOnScreenXY);
+
+ mActivityRule.runOnUiThread(()-> {
+ promptView.getLocationOnScreen(promptViewOnScreenXY);
+
+ final View lastListChild = listView.getChildAt(listView.getChildCount() - 1);
+ lastListChild.getLocationOnScreen(lastChildOnScreenXY);
+ });
+ mInstrumentation.waitForIdleSync();
// The child is above the prompt. They may overlap, as in the case
// when the list items do not all fit on screen, but this is still
diff --git a/tests/tests/wrap/nowrap/Android.mk b/tests/tests/wrap/nowrap/Android.mk
index 8f70c2a..35c0448 100644
--- a/tests/tests/wrap/nowrap/Android.mk
+++ b/tests/tests/wrap/nowrap/Android.mk
@@ -32,4 +32,7 @@
LOCAL_PACKAGE_NAME := CtsWrapNoWrapTestCases
LOCAL_MANIFEST_FILE := AndroidManifest.xml
+# Jarjar to make WrapTest unique.
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
+
include $(BUILD_PACKAGE)
diff --git a/tests/tests/wrap/nowrap/jarjar-rules.txt b/tests/tests/wrap/nowrap/jarjar-rules.txt
new file mode 100644
index 0000000..91e7454
--- /dev/null
+++ b/tests/tests/wrap/nowrap/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.wrap.cts.WrapTest** android.wrap.cts.WrapTestNoWrap@1
diff --git a/tests/tests/wrap/wrap_debug/Android.mk b/tests/tests/wrap/wrap_debug/Android.mk
index 7299f02..77b6d27 100644
--- a/tests/tests/wrap/wrap_debug/Android.mk
+++ b/tests/tests/wrap/wrap_debug/Android.mk
@@ -39,6 +39,9 @@
LOCAL_PACKAGE_NAME := CtsWrapWrapDebugTestCases
LOCAL_MANIFEST_FILE := AndroidManifest.xml
+# Jarjar to make WrapTest unique.
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
+
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
diff --git a/tests/tests/wrap/wrap_debug/jarjar-rules.txt b/tests/tests/wrap/wrap_debug/jarjar-rules.txt
new file mode 100644
index 0000000..3020934
--- /dev/null
+++ b/tests/tests/wrap/wrap_debug/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.wrap.cts.WrapTest** android.wrap.cts.WrapTestWrapDebug@1
diff --git a/tests/tests/wrap/wrap_debug_malloc_debug/Android.mk b/tests/tests/wrap/wrap_debug_malloc_debug/Android.mk
new file mode 100644
index 0000000..bc6240d
--- /dev/null
+++ b/tests/tests/wrap/wrap_debug_malloc_debug/Android.mk
@@ -0,0 +1,47 @@
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MULTILIB := both
+LOCAL_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ compatibility-device-util \
+ android-support-test \
+ legacy-android-test
+LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_SDK_VERSION := current
+
+LOCAL_PREBUILT_JNI_LIBS_arm := wrap.sh
+LOCAL_PREBUILT_JNI_LIBS_arm64 := wrap.sh
+LOCAL_PREBUILT_JNI_LIBS_mips := wrap.sh
+LOCAL_PREBUILT_JNI_LIBS_mips64 := wrap.sh
+LOCAL_PREBUILT_JNI_LIBS_x86 := wrap.sh
+LOCAL_PREBUILT_JNI_LIBS_x86_64 := wrap.sh
+
+LOCAL_PACKAGE_NAME := CtsWrapWrapDebugMallocDebugTestCases
+LOCAL_MANIFEST_FILE := AndroidManifest.xml
+
+# Jarjar to make WrapTest unique.
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
+
+include $(BUILD_PACKAGE)
+
+include $(CLEAR_VARS)
diff --git a/tests/tests/wrap/wrap_debug_malloc_debug/AndroidManifest.xml b/tests/tests/wrap/wrap_debug_malloc_debug/AndroidManifest.xml
new file mode 100644
index 0000000..a359f17
--- /dev/null
+++ b/tests/tests/wrap/wrap_debug_malloc_debug/AndroidManifest.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.wrap.wrap_debug_malloc_debug.cts">
+
+ <application android:debuggable="true">
+ <uses-library android:name="android.test.runner" />
+ <meta-data android:name="android.wrap.cts.expext_env" android:value="true" />
+ <activity android:name="android.wrap.WrapActivity" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+ <!-- self-instrumenting test package. -->
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:label="CTS tests for wrap.sh"
+ android:targetPackage="android.wrap.wrap_debug_malloc_debug.cts" >
+ </instrumentation>
+</manifest>
+
diff --git a/tests/dram/AndroidTest.xml b/tests/tests/wrap/wrap_debug_malloc_debug/AndroidTest.xml
similarity index 74%
rename from tests/dram/AndroidTest.xml
rename to tests/tests/wrap/wrap_debug_malloc_debug/AndroidTest.xml
index 636c8c1..0c740e4 100644
--- a/tests/dram/AndroidTest.xml
+++ b/tests/tests/wrap/wrap_debug_malloc_debug/AndroidTest.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
+<!-- Copyright (C) 2017 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -13,14 +13,13 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<configuration description="Config for CTS Dram test cases">
- <option name="config-descriptor:metadata" key="component" value="systems" />
+<configuration description="Config for CTS Debug Wrap (Malloc Debug) test cases">
+ <option name="config-descriptor:metadata" key="component" value="art" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
- <option name="test-file-name" value="CtsDramTestCases.apk" />
+ <option name="test-file-name" value="CtsWrapWrapDebugMallocDebugTestCases.apk" />
</target_preparer>
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
- <option name="package" value="android.dram.cts" />
- <option name="runtime-hint" value="8m" />
+ <option name="package" value="android.wrap.wrap_debug_malloc_debug.cts" />
</test>
</configuration>
diff --git a/tests/tests/wrap/wrap_debug_malloc_debug/jarjar-rules.txt b/tests/tests/wrap/wrap_debug_malloc_debug/jarjar-rules.txt
new file mode 100644
index 0000000..286029b
--- /dev/null
+++ b/tests/tests/wrap/wrap_debug_malloc_debug/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.wrap.cts.WrapTest** android.wrap.cts.WrapTestDebugMalloc@1
diff --git a/tests/signature/api-check/legacy-test-26-api/Android.mk b/tests/tests/wrap/wrap_debug_malloc_debug/wrap.sh
old mode 100644
new mode 100755
similarity index 72%
copy from tests/signature/api-check/legacy-test-26-api/Android.mk
copy to tests/tests/wrap/wrap_debug_malloc_debug/wrap.sh
index 699bd0c..f00a554
--- a/tests/signature/api-check/legacy-test-26-api/Android.mk
+++ b/tests/tests/wrap/wrap_debug_malloc_debug/wrap.sh
@@ -1,3 +1,4 @@
+#!/system/bin/sh
# Copyright (C) 2017 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -11,14 +12,4 @@
# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_PACKAGE_NAME := CtsLegacyTest26ApiSignatureTestCases
-
-LOCAL_SIGNATURE_API_FILES := \
- legacy-test-current.api \
-
-include $(LOCAL_PATH)/../build_signature_apk.mk
+LIBC_DEBUG_MALLOC_OPTIONS=backtrace=1 WRAP_PROPERTY=test $@
diff --git a/tests/tests/wrap/wrap_nodebug/Android.mk b/tests/tests/wrap/wrap_nodebug/Android.mk
index e4a8c51..1d6e9c0 100644
--- a/tests/tests/wrap/wrap_nodebug/Android.mk
+++ b/tests/tests/wrap/wrap_nodebug/Android.mk
@@ -39,6 +39,9 @@
LOCAL_PACKAGE_NAME := CtsWrapWrapNoDebugTestCases
LOCAL_MANIFEST_FILE := AndroidManifest.xml
+# Jarjar to make WrapTest unique.
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
+
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
diff --git a/tests/tests/wrap/wrap_nodebug/jarjar-rules.txt b/tests/tests/wrap/wrap_nodebug/jarjar-rules.txt
new file mode 100644
index 0000000..11a43f1
--- /dev/null
+++ b/tests/tests/wrap/wrap_nodebug/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.wrap.cts.WrapTest** android.wrap.cts.WrapTestWrapNoDebug@1
diff --git a/tools/cts-api-coverage/src/Android.mk b/tools/cts-api-coverage/src/Android.mk
index 4f3b558..fcf7ad4 100644
--- a/tools/cts-api-coverage/src/Android.mk
+++ b/tools/cts-api-coverage/src/Android.mk
@@ -20,6 +20,7 @@
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-subdir-java-files)
+LOCAL_PROTOC_OPTIMIZE_TYPE := full
LOCAL_JAVA_RESOURCE_DIRS := res
LOCAL_JAR_MANIFEST := MANIFEST.mf
@@ -28,13 +29,11 @@
dexlib2
LOCAL_MODULE := cts-api-coverage
-LOCAL_MODULE_TAGS := optional
# This tool is not checking any dependencies or metadata, so all of the
# dependencies of all of the tests must be on its classpath. This is
# super fragile.
LOCAL_STATIC_JAVA_LIBRARIES += \
- host-libprotobuf-java-full \
platformprotos
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/tools/cts-device-info/jni/Android.mk b/tools/cts-device-info/jni/Android.mk
index 30bde53..9e514f0 100644
--- a/tools/cts-device-info/jni/Android.mk
+++ b/tools/cts-device-info/jni/Android.mk
@@ -28,6 +28,8 @@
LOCAL_SHARED_LIBRARIES := libvulkan liblog libdl
LOCAL_NDK_STL_VARIANT := c++_static
+LOCAL_CFLAGS := -Wall -Werror
+
# Would be "current" if that was supported for native code.
LOCAL_SDK_VERSION := 24
diff --git a/tools/cts-tradefed/etc/cts-tradefed b/tools/cts-tradefed/etc/cts-tradefed
index 7560b62..f20f190 100755
--- a/tools/cts-tradefed/etc/cts-tradefed
+++ b/tools/cts-tradefed/etc/cts-tradefed
@@ -36,18 +36,10 @@
checkPath java
# check java version
-if [ "${EXPERIMENTAL_USE_OPENJDK9}" == "" ]; then
- JAVA_VERSION=$(java -version 2>&1 | head -n 2 | grep '[ "]1\.[678][\. "$$]')
- if [ "${JAVA_VERSION}" == "" ]; then
- echo "Wrong java version. 1.6, 1.7 or 1.8 is required."
- exit
- fi
-else
- JAVA_VERSION=$(java -version 2>&1 | head -n 2 | grep '^java .* "9.*')
- if [ "${JAVA_VERSION}" == "" ]; then
- echo "Wrong java version. Version 9 is required."
- exit
- fi
+JAVA_VERSION=$(java -version 2>&1 | head -n 1 | grep 'version [ "]\(1\.8\|9\).*[ "]')
+if [ "${JAVA_VERSION}" == "" ]; then
+ echo "Wrong java version. 1.8 or 9 is required."
+ exit
fi
# check debug flag and set up remote debugging
@@ -102,6 +94,7 @@
checkFile ${JAR_DIR}/${JAR}.jar
JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}.jar
done
+JAR_PATH=${JAR_PATH:1} # Strip off leading ':'
OPTIONAL_JARS="
google-tradefed
diff --git a/tools/cts-tradefed/res/config/cts-device-files.xml b/tools/cts-tradefed/res/config/cts-device-files.xml
index 92a3e28..6acf7bb 100644
--- a/tools/cts-tradefed/res/config/cts-device-files.xml
+++ b/tools/cts-tradefed/res/config/cts-device-files.xml
@@ -23,30 +23,6 @@
</target_preparer>
<target_preparer class="com.android.compatibility.common.tradefed.targetprep.DeviceFileCollector">
- <option name="src-file" value="/system/manifest.xml" />
- <option name="dest-file" value="vintf-files/framework_manifest.xml"/>
- <option name="property" key="ro.treble.enabled" value="true"/>
- </target_preparer>
-
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.DeviceFileCollector">
- <option name="src-file" value="/system/compatibility_matrix.xml" />
- <option name="dest-file" value="vintf-files/framework_compatibility_matrix.xml"/>
- <option name="property" key="ro.treble.enabled" value="true"/>
- </target_preparer>
-
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.DeviceFileCollector">
- <option name="src-file" value="/vendor/manifest.xml" />
- <option name="dest-file" value="vintf-files/device_manifest.xml"/>
- <option name="property" key="ro.treble.enabled" value="true"/>
- </target_preparer>
-
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.DeviceFileCollector">
- <option name="src-file" value="/vendor/compatibility_matrix.xml" />
- <option name="dest-file" value="vintf-files/device_compatibility_matrix.xml"/>
- <option name="property" key="ro.treble.enabled" value="true"/>
- </target_preparer>
-
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.DeviceFileCollector">
<option name="src-file" value="/proc/config.gz" />
<option name="dest-file" value="vintf-files/proc_config.gz"/>
<option name="property" key="ro.treble.enabled" value="true"/>
diff --git a/tools/cts-tradefed/res/config/cts-jvmti.xml b/tools/cts-tradefed/res/config/cts-jvmti.xml
new file mode 100644
index 0000000..b02529a
--- /dev/null
+++ b/tools/cts-tradefed/res/config/cts-jvmti.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 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.
+-->
+<configuration description="Runs JVMTI Tests from a pre-existing CTS installation">
+
+ <!-- Using cts-dev to avoid system checkers. -->
+ <include name="cts-dev" />
+
+ <option name="plan" value="cts-jvmti" />
+
+ <!-- Include all JVMTI test cases -->
+ <option name="compatibility:include-filter" value="CtsJvmtiAttachingHostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRedefineClassesHostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest902HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest903HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest904HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest905HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest906HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest907HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest908HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest910HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest911HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest912HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest913HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest914HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest915HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest917HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest918HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest919HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest920HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest922HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest923HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest924HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest926HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest927HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest928HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest930HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest931HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest932HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest940HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest942HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest944HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest945HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest947HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest951HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest982HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest984HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest985HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiRunTest986HostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiTaggingHostTestCases" />
+ <option name="compatibility:include-filter" value="CtsJvmtiTrackingHostTestCases" />
+
+</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-known-failures.xml b/tools/cts-tradefed/res/config/cts-known-failures.xml
index 0d52a1f..9f0256c 100644
--- a/tools/cts-tradefed/res/config/cts-known-failures.xml
+++ b/tools/cts-tradefed/res/config/cts-known-failures.xml
@@ -93,6 +93,9 @@
<option name="compatibility:exclude-filter" value="CtsSecurityTestCases android.security.cts.MediaCryptoTest#testMediaCryptoClearKey" />
<option name="compatibility:exclude-filter" value="CtsSecurityTestCases android.security.cts.MediaCryptoTest#testMediaCryptoWidevine" />
+ <!-- b/63916274 -->
+ <option name="compatibility:exclude-filter" value="CtsTelecomTestCases android.telecom.cts.WiredHeadsetTest" />
+
<!-- b/62302163 -->
<option name="compatibility:exclude-filter" value="CtsSecurityHostTestCases android.security.cts.Poc17_04#testPocCVE_2017_0564" />
diff --git a/tools/utils/CollectAllTests.java b/tools/utils/CollectAllTests.java
index cd85e0c..1c6fa99 100644
--- a/tools/utils/CollectAllTests.java
+++ b/tools/utils/CollectAllTests.java
@@ -510,7 +510,7 @@
* @return true if it is valid, false otherwise
*/
private static boolean isValidJavaPackage(String javaPackageName) {
- String[] strSections = javaPackageName.split(".");
+ String[] strSections = javaPackageName.split("\\.");
for (String strSection : strSections) {
if (!isValidJavaIdentifier(strSection)) {
return false;
diff --git a/tools/vm-tests-tf/Android.mk b/tools/vm-tests-tf/Android.mk
index c7d61e4..70c74e1 100644
--- a/tools/vm-tests-tf/Android.mk
+++ b/tools/vm-tests-tf/Android.mk
@@ -28,7 +28,7 @@
-include cts/error_prone_rules_tests.mk
include $(BUILD_JAVA_LIBRARY)
-cts-tf-dalvik-lib.jack := $(full_classes_jack)
+cts-tf-dalvik-lib.jar := $(full_classes_jar)
# buildutil java library
# ============================================================
@@ -44,7 +44,7 @@
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_MODULE_TAGS := optional
-LOCAL_JAVA_LIBRARIES := dx dasm cfassembler junit-host jsr305lib
+LOCAL_JAVA_LIBRARIES := dx dasm cfassembler junit-host jsr305lib d8
LOCAL_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
@@ -55,8 +55,6 @@
#
include $(CLEAR_VARS)
-include $(BUILD_SYSTEM)/configure_local_jack.mk
-
LOCAL_MODULE := vm-tests-tf
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_MODULE_SUFFIX := $(COMMON_JAVA_PACKAGE_SUFFIX)
@@ -74,13 +72,8 @@
vmteststf_dep_jars := \
$(HOST_JDK_TOOLS_JAR) \
- $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/, cts-tf-dalvik-buildutil.jar dasm.jar dx.jar cfassembler.jar junit-host.jar)
-
-$(LOCAL_BUILT_MODULE): PRIVATE_JACK_EXTRA_ARGS := $(LOCAL_JACK_EXTRA_ARGS)
-
-ifdef LOCAL_JACK_ENABLED
- vmteststf_dep_jars += $(cts-tf-dalvik-lib.jack)
-endif
+ $(cts-tf-dalvik-lib.jar) \
+ $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/, cts-tf-dalvik-buildutil.jar dasm.jar dx.jar cfassembler.jar junit-host.jar d8.jar)
$(LOCAL_BUILT_MODULE): PRIVATE_SRC_FOLDER := $(LOCAL_PATH)/src
$(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES_CLASSES := $(call intermediates-dir-for,JAVA_LIBRARIES,cts-tf-dalvik-buildutil,HOST)/classes
@@ -89,50 +82,34 @@
$(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES_MAIN_FILES := $(intermediates)/main_files
$(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES := $(intermediates)/hostjunit_files
$(LOCAL_BUILT_MODULE): PRIVATE_CLASS_PATH := $(call normalize-path-list, $(vmteststf_dep_jars))
-$(LOCAL_BUILT_MODULE): PRIVATE_JACK_VERSION := $(LOCAL_JACK_VERSION)
-ifndef LOCAL_JACK_ENABLED
-$(LOCAL_BUILT_MODULE) : $(vmteststf_dep_jars) $(HOST_OUT_JAVA_LIBRARIES)/tradefed.jar
+oj_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,core-oj,,COMMON)/classes.jar
+libart_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,core-libart,,COMMON)/classes.jar
+$(LOCAL_BUILT_MODULE): PRIVATE_DALVIK_SUITE_CLASSPATH := $(oj_jar):$(libart_jar):$(cts-tf-dalvik-lib.jar):$(HOST_OUT_JAVA_LIBRARIES)/tradefed.jar:
+$(LOCAL_BUILT_MODULE) : $(vmteststf_dep_jars) $(HOST_OUT_JAVA_LIBRARIES)/tradefed.jar $(DX)
$(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
$(hide) mkdir -p $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/dot/junit $(dir $(PRIVATE_INTERMEDIATES_DEXCORE_JAR))
# generated and compile the host side junit tests
@echo "Write generated Main_*.java files to $(PRIVATE_INTERMEDIATES_MAIN_FILES)"
$(hide) $(JAVA) \
- $(if $(EXPERIMENTAL_USE_OPENJDK9),--add-exports jdk.jartool/sun.tools.jar=ALL-UNNAMED) \
-cp $(PRIVATE_CLASS_PATH) util.build.BuildDalvikSuite $(PRIVATE_SRC_FOLDER) $(PRIVATE_INTERMEDIATES) \
- $(HOST_OUT_JAVA_LIBRARIES)/cts-tf-dalvik-buildutil.jar:$(HOST_OUT_JAVA_LIBRARIES)/tradefed.jar \
- $(PRIVATE_INTERMEDIATES_MAIN_FILES) $(PRIVATE_INTERMEDIATES_CLASSES) $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES) $$RUN_VM_TESTS_RTO
- @echo "Generate $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)"
- $(hide) $(JAR) -cf $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jar \
- $(addprefix -C $(PRIVATE_INTERMEDIATES_CLASSES) , dot/junit/DxUtil.class dot/junit/DxAbstractMain.class)
- $(hide) $(DX) -JXms16M -JXmx768M --dex --output=$(PRIVATE_INTERMEDIATES_DEXCORE_JAR) \
- $(if $(NO_OPTIMIZE_DX), --no-optimize) $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jar && rm -f $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jar
- $(hide) cd $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/classes && zip -q -r ../../$(notdir $@).jar .
- $(hide) cd $(dir $@) && zip -q -r $(notdir $@) tests
-else # LOCAL_JACK_ENABLED
-oj_jack := $(call intermediates-dir-for,JAVA_LIBRARIES,core-oj,,COMMON)/classes.jack
-libart_jack := $(call intermediates-dir-for,JAVA_LIBRARIES,core-libart,,COMMON)/classes.jack
-$(LOCAL_BUILT_MODULE): PRIVATE_DALVIK_SUITE_CLASSPATH := $(oj_jack):$(libart_jack):$(cts-tf-dalvik-lib.jack):$(HOST_OUT_JAVA_LIBRARIES)/tradefed.jar
-$(LOCAL_BUILT_MODULE) : $(vmteststf_dep_jars) $(JACK) $(oj_jack) $(libart_jack) $(HOST_OUT_JAVA_LIBRARIES)/tradefed.jar | setup-jack-server
- $(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
- $(hide) mkdir -p $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/dot/junit $(dir $(PRIVATE_INTERMEDIATES_DEXCORE_JAR))
- # generated and compile the host side junit tests
- @echo "Write generated Main_*.java files to $(PRIVATE_INTERMEDIATES_MAIN_FILES)"
- $(hide) JACK_VERSION=$(PRIVATE_JACK_VERSION) $(JAVA) -cp $(PRIVATE_CLASS_PATH) util.build.JackBuildDalvikSuite $(JACK) $(PRIVATE_SRC_FOLDER) $(PRIVATE_INTERMEDIATES) \
$(PRIVATE_DALVIK_SUITE_CLASSPATH) \
$(PRIVATE_INTERMEDIATES_MAIN_FILES) $(PRIVATE_INTERMEDIATES_CLASSES) $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES) $$RUN_VM_TESTS_RTO
@echo "Generate $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)"
$(hide) $(JAR) -cf $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)-class.jar \
- $(addprefix -C $(PRIVATE_INTERMEDIATES_CLASSES) , dot/junit/DxUtil.class dot/junit/DxAbstractMain.class)
- $(hide) $(call call-jack) --import $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)-class.jar --output-jack $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jack
+ $(addprefix -C $(PRIVATE_INTERMEDIATES_CLASSES) , dot/junit/DxUtil.class dot/junit/DxAbstractMain.class dot/junit/AssertionFailedException.class)
$(hide) mkdir -p $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp
- $(hide) $(call call-jack,$(PRIVATE_JACK_EXTRA_ARGS)) --output-dex $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp \
- $(if $(NO_OPTIMIZE_DX), -D jack.dex.optimize "false") --import $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jack && rm -f $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jack
+ifneq ($(USE_D8_DESUGAR),true)
+ $(hide) $(DX_COMMAND) --dex --output=$(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp \
+ $(if $(NO_OPTIMIZE_DX), --no-optimize) $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)-class.jar && rm -f $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jar
+else
+ $(hide) $(DX_COMMAND) --output $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp \
+ $(if $(NO_OPTIMIZE_DX), --debug) $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)-class.jar && rm -f $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jar
+endif
$(hide) cd $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp && zip -q -r $(abspath $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)) .
$(hide) cd $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/classes && zip -q -r ../../$(notdir $@) .
$(hide) cd $(dir $@) && zip -q -r $(notdir $@) tests
-oj_jack :=
-libart_jack :=
-endif # LOCAL_JACK_ENABLED
+oj_jar :=
+libart_jar :=
# Clean up temp vars
intermediates :=
diff --git a/tools/vm-tests-tf/etc/starthosttests b/tools/vm-tests-tf/etc/starthosttests
new file mode 100755
index 0000000..c1144f0
--- /dev/null
+++ b/tools/vm-tests-tf/etc/starthosttests
@@ -0,0 +1,249 @@
+#!/bin/bash
+#
+# Copyright (C) 2008 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.
+
+# Set up prog to be the path of this script, including following symlinks,
+# and set up progdir to be the fully-qualified pathname of its directory.
+
+prog="$0"
+while [ -h "${prog}" ]; do
+ newProg=`/bin/ls -ld "${prog}"`
+ newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
+ if expr "x${newProg}" : 'x/' >/dev/null; then
+ prog="${newProg}"
+ else
+ progdir=`dirname "${prog}"`
+ prog="${progdir}/${newProg}"
+ fi
+done
+oldwd=`pwd`
+progdir=`dirname "${prog}"`
+cd "${progdir}"
+progdir=`pwd`
+prog="${progdir}"/`basename "${prog}"`
+cd "${oldwd}"
+
+javaOpts=""
+while expr "x$1" : 'x-J' >/dev/null; do
+ opt=`expr "$1" : '-J\(.*\)'`
+ javaOpts="${javaOpts} -${opt}"
+ shift
+done
+
+
+#######################################################################
+# Original content of invocation script follows. Uses values cleverly
+# deduced by the above code.
+#######################################################################
+
+selection=$1
+interpreter="fast"
+if [ "$selection" = "--portable" ]; then
+ selection=$2;
+ interpreter="portable"
+fi
+
+dalviktest=$ANDROID_BUILD_TOP/out/host/common/obj/JAVA_LIBRARIES/vm-tests-tf_intermediates
+dalviktestdir=$dalviktest/tests
+dexcore=$dalviktest/tests/dot/junit/dexcore.jar
+scriptdata=$dalviktestdir/data/scriptdata
+report=$dalviktest/report.html
+curdate=`date`
+datadir=/tmp/${USER}
+export ANDROID_PRINTF_LOG=tag
+export ANDROID_LOG_TAGS='*:s' # was: jdwp:i dalvikvm:i dalvikvmi:i'
+export ANDROID_DATA=$datadir
+export ANDROID_ROOT=$ANDROID_HOST_OUT
+# export LD_LIBRARY_PATH=$base/system/lib
+# export DYLD_LIBRARY_PATH=$base/system/lib
+debug_opts="-Xcheck:jni -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"
+vmtpath=$ANDROID_HOST_OUT/../common/obj/JAVA_LIBRARIES/vm-tests-tf_intermediates/tests
+
+echo "--------------------------------------------------"
+echo "Dalvik VM Test Suite"
+echo "Version 1.0"
+echo "Copyright (c) 2008 The Android Open Source Project"
+echo ""
+
+if [ "$selection" = "--help" ]; then
+ echo "Usage: vm-tests [--help|--portable] [<mnemonic>]"
+ echo ""
+ echo " --help prints this help message"
+ echo ""
+ echo " <mnemonic> specifies the instruction to test;"
+ echo " default is to run all tests"
+ echo ""
+ exit 1;
+fi
+
+rm -rf --preserve-root $datadir/dalvik-cache
+mkdir -p $datadir
+mkdir -p $datadir/dalvik-cache
+
+echo ""
+
+pre_report="<html><head><style>
+table tr.ok { background:#a0ffa0; }
+table tr.nok { background:#ffa0a0; }
+table tr.wok { background:#ffffa0; }
+table tr.lok { background:#aaaaff; }
+</style></head>
+<body>
+<h1>Dalvik VM test suite results</h1>
+Generated $curdate (using the emulator)
+<p>
+<table width='100%'>
+<tr><td>Status</td><td>Target</td><td>Category</td><td>Details</td></tr>"
+post_report="</body></html>"
+
+rm -f $report
+echo $pre_report > $report
+
+# ----------- running each opcode test ------------
+
+export jpassedcnt=0
+export jfailedcnt=0
+export jvfefailedcnt=0
+export jwarningcnt=0
+export jallcnt=0
+export jcolumns=0
+
+function classnameToJar()
+{
+ echo $1 | sed -e 's#\.#/#g;s#$#.jar#'
+}
+
+while read -u 3 myline;
+do
+ # dot.junit.opcodes.add_double.Main_testB1;dot.junit.opcodes.add_double.d.T_add_double_1 ;opcode add_double;test B #1 (border edge case)
+ # ->
+ # mainclass: dot.junit.opcodes.add_double.Main_testB1
+ # testcasedir: opcodes/add_double
+ # testname: testB1 ->
+ # dir dot/junit/opcodes/add_double/testB1
+
+ # e.g dot.junit.opcodes.add_double.Main_testB1
+ mainclass=`echo $myline | cut -d";" -f1`
+ # e.g dot.junit.opcodes.add_double.d.T_add_double_1, space sep. >=1 entries
+ deps=`echo $myline | cut -d";" -f2`
+
+ jtitle=`echo $myline | cut -d";" -f3`
+ jcomment=`echo $myline | cut -d";" -f4`
+ details=`echo $myline | cut -d";" -f5`
+
+ if [ "$selection" == "" ] || [ "$jtitle" == "$selection" ]; then
+
+ (( jallcnt += 1 ))
+
+ cd $dalviktestdir
+ rm -f $datadir/dalvikout
+ # write dalvik output to file
+ echo -n "mk_b:" > $datadir/dalvikout
+
+ classpath="${vmtpath}/dot/junit/dexcore.jar:${vmtpath}/mains.jar"
+ deps=${deps}" "${mainclass}
+ for dep in ${deps}; do
+ depJar=`classnameToJar ${dep}`
+ classpath=${classpath}:${vmtpath}/${depJar}
+ done
+
+ art -Djava.io.tmpdir=/tmp/${USER} \
+ -classpath $classpath $mainclass >> $datadir/dalvikout 2>&1 && \
+ echo -n dvmpassed: >> $datadir/dalvikout 2>&1
+
+ echo -n "mk_s:" >> $datadir/dalvikout
+ # Verify tmpout only contains mkdxc_start;mkdxc_stop -> no system.out/err
+ # because of exception. If ok -> green report line else red report with info
+ # between mkdxc_start and stop
+ vmresult=`cat $datadir/dalvikout`
+
+ if [[ ("$vmresult" == "mk_b:mk_s:") || ("$vmresult" == "mk_b:dvmpassed:mk_s:") ]]; then
+ (( jpassedcnt += 1 ))
+ echo -n "<tr class=\"ok\"><td>Success</td><td>$jtitle</td>" >> $report
+ echo "<td>$jcomment</td><td>$details</td></tr>" >> $report
+ echo -n "."
+ else
+ vmres=`cat $datadir/dalvikout | sed -e 's/mk_b://;s/mk_s://'`
+ vmres="$details<br><pre>$vmres</pre>"
+
+ stacktraces=`echo $vmresult | grep "java\.lang\." | grep -c "at dot\.junit\."`
+ if [[ $stacktraces > 0 ]]; then
+ jtype=`echo "$mainclass" | sed -e 's/.*_test\([^0-9]*\)[0-9].*/\1/' `
+ if [ "$jtype" == "VFE" ]; then
+ (( jvfefailedcnt += 1 ))
+ echo -n "V"
+ else
+ (( jfailedcnt += 1 ))
+ echo -n "F"
+ fi
+
+ echo "<tr class=\"nok\"><td>Failure</td><td>$jtitle</td><td>" >> $report
+ echo "$jcomment</td><td>$vmres</td></tr>" >> $report
+ else
+ (( jwarningcnt += 1 ))
+ echo "<tr class=\"wok\"><td>Failure</td><td>$jtitle</td><td>" >> $report
+ echo "$jcomment</td><td>(No stacktrace, but errors on console)" >> $report
+ echo "<br>$vmres</td></tr>" >> $report
+ echo -n "C"
+ fi
+ fi
+
+ (( jcolumns += 1 ))
+ if [ ${jcolumns} -eq 40 ]; then
+ echo ""
+ (( jcolumns = 0 ))
+ fi
+
+ fi
+# Use fd nr 3 to avoid subshelling via cat since this looses all
+# variables(and thus also the counters we are interested in).
+done 3<$scriptdata
+
+echo "</table>" >> $report
+let jallcalccnt=$jpassedcnt+$jfailedcnt+$jvfefailedcnt+$jwarningcnt
+if [ $jallcalccnt -ne $jallcnt ]; then
+ echo "<br>error: green & red != total , $jallcalccnt -ne $jallcnt" >> $report
+ exit 1;
+fi
+
+echo $post_report >> $report
+
+echo "<br>Tests run: ${jallcnt}" >> $report
+echo "<br>Functional failures: ${jfailedcnt}" >> $report
+echo "<br>Verifier failures: ${jvfefailedcnt}" >> $report
+echo "<br>Console errors: ${jwarningcnt}" >> $report
+
+echo $post_report >> $report
+
+if [[ jcolumns -ne 0 ]]; then
+ echo ""
+fi
+
+echo ""
+
+if [[ jallcnt -eq jpassedcnt ]]; then
+ echo "OK (${jpassedcnt} tests)"
+else
+ echo "FAILURES!!!"
+ echo ""
+ echo "Tests run : ${jallcnt}"
+ echo "Functional failures: ${jfailedcnt}"
+ echo "Verifier failures : ${jvfefailedcnt}"
+ echo "Console errors : ${jwarningcnt}"
+fi
+
+echo ""
+echo "Please see complete report in ${report}"
+echo "--------------------------------------------------"
diff --git a/tools/vm-tests-tf/src/dot/junit/AssertionFailedException.java b/tools/vm-tests-tf/src/dot/junit/AssertionFailedException.java
new file mode 100644
index 0000000..44b686d
--- /dev/null
+++ b/tools/vm-tests-tf/src/dot/junit/AssertionFailedException.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package dot.junit;
+
+class AssertionFailedException extends RuntimeException {
+
+ public AssertionFailedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public AssertionFailedException(String message) {
+ super(message);
+ }
+}
\ No newline at end of file
diff --git a/tools/vm-tests-tf/src/dot/junit/DxAbstractMain.java b/tools/vm-tests-tf/src/dot/junit/DxAbstractMain.java
index dac6dcf..6223507 100644
--- a/tools/vm-tests-tf/src/dot/junit/DxAbstractMain.java
+++ b/tools/vm-tests-tf/src/dot/junit/DxAbstractMain.java
@@ -25,20 +25,19 @@
private static void checkError(Class<?> expectedErrorClass, Throwable thrown,
boolean in_invocation_exc) {
if (expectedErrorClass != null && thrown == null) {
- fail("Expected error of type " + expectedErrorClass);
+ fail("Expected error of type " + expectedErrorClass, null);
} else if (expectedErrorClass == null && thrown != null) {
- fail("Unexpected error " + thrown);
+ fail("Unexpected error " + thrown, thrown);
} else if (expectedErrorClass != null && thrown != null) {
if (in_invocation_exc) {
if (!(thrown instanceof java.lang.reflect.InvocationTargetException)) {
- fail("Expected invocation target exception, but got " + thrown);
+ fail("Expected invocation target exception, but got " + thrown, thrown);
}
thrown = thrown.getCause();
}
if (!expectedErrorClass.equals(thrown.getClass())) {
- thrown.printStackTrace(System.err);
fail("Expected error of type " + expectedErrorClass + ", but got " +
- thrown.getClass());
+ thrown.getClass(), thrown);
}
}
}
@@ -47,19 +46,19 @@
* Try to load the class with the given name, and check for the expected error.
*/
public static Class<?> load(String className, Class<?> expectedErrorClass) {
+ Class<?> c;
try {
- Class<?> c = Class.forName(className);
- checkError(expectedErrorClass, null, false);
- return c;
+ c = Class.forName(className);
} catch (Throwable t) {
if (expectedErrorClass != null) {
checkError(expectedErrorClass, t, false);
} else {
- t.printStackTrace(System.err);
- fail("Could not load class " + className + ": " + t);
+ fail("Could not load class " + className, t);
}
return null;
}
+ checkError(expectedErrorClass, null, false);
+ return c;
}
/**
@@ -80,7 +79,7 @@
}
}
if (method == null) {
- fail("Could not find method 'run'");
+ fail("Could not find method 'run'", null);
}
Object receiver = null;
@@ -88,16 +87,17 @@
try {
receiver = c.newInstance();
} catch (Exception exc) {
- fail("Could not instantiate " + className + ": " + exc.getMessage());
+ fail("Could not instantiate " + className, exc);
}
}
try {
method.invoke(receiver, args);
- checkError(expectedErrorClass, null, false);
} catch (Throwable t) {
checkError(expectedErrorClass, t, wrapped);
+ return;
}
+ checkError(expectedErrorClass, null, false);
}
public static void loadAndRun(String className, Class<?> expectedErrorClass) {
@@ -109,19 +109,26 @@
}
static public void assertEquals(int expected, int actual) {
- if (expected != actual) throw new RuntimeException("AssertionFailedError: not equals. Expected " + expected + " actual " + actual);
+ if (expected != actual)
+ throw new AssertionFailedException(
+ "not equals. Expected " + expected + " actual " + actual);
}
static public void assertEquals(String message, int expected, int actual) {
- if (expected != actual) throw new RuntimeException("AssertionFailedError: not equals: " + message + " Expected " + expected + " actual " + actual);
+ if (expected != actual)
+ throw new AssertionFailedException(
+ "not equals: " + message + " Expected " + expected + " actual " + actual);
}
static public void assertEquals(long expected, long actual) {
- if (expected != actual) throw new RuntimeException("AssertionFailedError: not equals. Expected " + expected + " actual " + actual);
+ if (expected != actual)
+ throw new AssertionFailedException(
+ "not equals. Expected " + expected + " actual " + actual);
}
static public void assertEquals(double expected, double actual, double delta) {
- if(!(Math.abs(expected-actual) <= delta)) throw new RuntimeException("AssertionFailedError: not within delta");
+ if (!(Math.abs(expected - actual) <= delta))
+ throw new AssertionFailedException("not within delta");
}
static public void assertEquals(Object expected, Object actual) {
@@ -129,26 +136,34 @@
return;
if (expected != null && expected.equals(actual))
return;
- throw new RuntimeException("AssertionFailedError: not the same");
+ throw new AssertionFailedException("not the same: " + expected + " vs " + actual);
}
static public void assertTrue(boolean condition) {
- if (!condition) throw new RuntimeException("AssertionFailedError: condition was false");
+ if (!condition)
+ throw new AssertionFailedException("condition was false");
}
static public void assertFalse(boolean condition) {
- if (condition) throw new RuntimeException("AssertionFailedError: condition was true");
+ if (condition)
+ throw new AssertionFailedException("condition was true");
}
static public void assertNotNull(Object object) {
- if (object == null) throw new RuntimeException("AssertionFailedError: object was null");
+ if (object == null)
+ throw new AssertionFailedException("object was null");
}
static public void assertNull(Object object) {
- if (object != null) throw new RuntimeException("AssertionFailedError: object was not null");
+ if (object != null)
+ throw new AssertionFailedException("object was not null");
}
static public void fail(String message) {
- throw new RuntimeException("AssertionFailedError msg:"+message);
+ fail(message, null);
+ }
+
+ static public void fail(String message, Throwable cause) {
+ throw new AssertionFailedException(message, cause);
}
}
diff --git a/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java b/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java
index 187858c..e9e1996 100644
--- a/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java
+++ b/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java
@@ -82,7 +82,6 @@
private int testClassCnt = 0;
private int testMethodsCnt = 0;
- private boolean useJack;
/*
* using a linked hashmap to keep the insertion order for iterators.
@@ -112,7 +111,7 @@
}
long start = System.currentTimeMillis();
- BuildDalvikSuite cat = new BuildDalvikSuite(false);
+ BuildDalvikSuite cat = new BuildDalvikSuite();
cat.compose();
long end = System.currentTimeMillis();
@@ -149,10 +148,6 @@
"[restrict-to-opcode]");
}
- public BuildDalvikSuite(boolean useJack) {
- this.useJack = useJack;
- }
-
public void compose() throws IOException {
System.out.println("Collecting all junit tests...");
new TestRunner() {
@@ -296,12 +291,7 @@
HOSTJUNIT_CLASSES_OUTPUT_FOLDER, CLASS_PATH);
String mainsJar = OUTPUT_FOLDER + File.separator + TARGET_MAIN_FILE;
- if (useJack) {
- srcBuildStep = new JackBuildStep(mainsJar,
- CLASS_PATH);
- } else {
- srcBuildStep = new JavacBuildStep(CLASSES_OUTPUT_FOLDER, CLASS_PATH);
- }
+ srcBuildStep = new JavacBuildStep(CLASSES_OUTPUT_FOLDER, CLASS_PATH);
for (Entry<String, List<String>> entry : map.entrySet()) {
@@ -455,14 +445,12 @@
}
- if (!useJack) {
- DxBuildStep dexBuildStep = new DxBuildStep(
- new BuildStep.BuildFile(new File(CLASSES_OUTPUT_FOLDER)),
- new BuildStep.BuildFile(new File(mainsJar)),
- false);
+ D8BuildStep dexBuildStep = new D8BuildStep(
+ new BuildStep.BuildFile(new File(CLASSES_OUTPUT_FOLDER)),
+ new BuildStep.BuildFile(new File(mainsJar)),
+ false);
- targets.add(dexBuildStep);
- }
+ targets.add(dexBuildStep);
// write latest HOSTJUNIT generated file.
flushHostJunitFile();
@@ -546,36 +534,16 @@
File srcFile = new File(sourceFolder, fileName + ".java");
if (srcFile.exists()) {
BuildStep dexBuildStep;
- if (useJack) {
- JackBuildStep jackBuildStep = new JackBuildStep(
- OUTPUT_FOLDER + File.separator + fileName + ".jar",
- CLASS_PATH);
- jackBuildStep.addSourceFile(srcFile.getAbsolutePath());
- dexBuildStep = jackBuildStep;
- } else {
- dexBuildStep = generateDexBuildStep(
- COMPILED_CLASSES_FOLDER, fileName, null);
- }
+ dexBuildStep = generateDexBuildStep(
+ COMPILED_CLASSES_FOLDER, fileName);
targets.add(dexBuildStep);
return;
}
try {
if (Class.forName(dependentTestClassName) != null) {
- JillBuildStep jillBuildStep = null;
- if (useJack) {
- BuildStep.BuildFile classFile = new BuildStep.BuildFile(
- COMPILED_CLASSES_FOLDER, fileName + ".class");
-
- BuildStep.BuildFile jackFile = new BuildStep.BuildFile(
- COMPILED_CLASSES_FOLDER,
- fileName + ".jack");
-
- jillBuildStep = new JillBuildStep(classFile,
- jackFile);
- }
BuildStep dexBuildStep = generateDexBuildStep(
- COMPILED_CLASSES_FOLDER, fileName, jillBuildStep);
+ COMPILED_CLASSES_FOLDER, fileName);
targets.add(dexBuildStep);
return;
}
@@ -588,51 +556,27 @@
}
private BuildStep generateDexBuildStep(String classFileFolder,
- String classFileName, BuildStep dependency) {
- if (!useJack) {
- BuildStep.BuildFile classFile = new BuildStep.BuildFile(
- classFileFolder, classFileName + ".class");
+ String classFileName) {
+ BuildStep.BuildFile classFile = new BuildStep.BuildFile(
+ classFileFolder, classFileName + ".class");
- BuildStep.BuildFile tmpJarFile = new BuildStep.BuildFile(
- OUTPUT_FOLDER,
- classFileName + "_tmp.jar");
+ BuildStep.BuildFile tmpJarFile = new BuildStep.BuildFile(
+ OUTPUT_FOLDER,
+ classFileName + "_tmp.jar");
- JarBuildStep jarBuildStep = new JarBuildStep(classFile,
- classFileName + ".class", tmpJarFile, false);
+ JarBuildStep jarBuildStep = new JarBuildStep(classFile,
+ classFileName + ".class", tmpJarFile, false);
- if (dependency != null) {
- jarBuildStep.addChild(dependency);
- }
+ BuildStep.BuildFile outputFile = new BuildStep.BuildFile(
+ OUTPUT_FOLDER,
+ classFileName + ".jar");
- BuildStep.BuildFile outputFile = new BuildStep.BuildFile(
- OUTPUT_FOLDER,
- classFileName + ".jar");
+ D8BuildStep dexBuildStep = new D8BuildStep(tmpJarFile,
+ outputFile,
+ true);
- DxBuildStep dexBuildStep = new DxBuildStep(tmpJarFile,
- outputFile,
- true);
-
- dexBuildStep.addChild(jarBuildStep);
- return dexBuildStep;
- } else {
- BuildStep.BuildFile jackFile = new BuildStep.BuildFile(
- classFileFolder, classFileName + ".jack");
-
- BuildStep.BuildFile outputFile = new BuildStep.BuildFile(
- OUTPUT_FOLDER,
- classFileName + ".jar");
-
- JackDexBuildStep dexBuildStep = new JackDexBuildStep(jackFile,
- outputFile,
- true);
-
- if (dependency != null) {
- dexBuildStep.addChild(dependency);
- }
- return dexBuildStep;
-
- }
-
+ dexBuildStep.addChild(jarBuildStep);
+ return dexBuildStep;
}
/**
diff --git a/tools/vm-tests-tf/src/util/build/BytesStreamSucker.java b/tools/vm-tests-tf/src/util/build/BytesStreamSucker.java
deleted file mode 100644
index f243c17..0000000
--- a/tools/vm-tests-tf/src/util/build/BytesStreamSucker.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2012 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 util.build;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import javax.annotation.Nonnull;
-
-/**
- * Class that continuously read an {@link InputStream} and optionally could write the input in a
- * {@link OutputStream}.
- */
-public class BytesStreamSucker {
-
- private static final int BUFFER_SIZE = 4096;
-
- @Nonnull
- private final byte[] buffer = new byte[BUFFER_SIZE];
-
- @Nonnull
- private final InputStream is;
-
- @Nonnull
- private final OutputStream os;
-
- private final boolean toBeClose;
-
- public BytesStreamSucker(
- @Nonnull InputStream is, @Nonnull OutputStream os, boolean toBeClose) {
- this.is = is;
- this.os = os;
- this.toBeClose = toBeClose;
- }
-
- public BytesStreamSucker(@Nonnull InputStream is, @Nonnull OutputStream os) {
- this(is, os, false);
- }
-
- public void suck() throws IOException {
- try {
- int bytesRead;
- while ((bytesRead = is.read(buffer)) >= 0) {
- os.write(buffer, 0, bytesRead);
- os.flush();
- }
- } finally {
- if (toBeClose) {
- os.close();
- }
- }
- }
-}
\ No newline at end of file
diff --git a/tools/vm-tests-tf/src/util/build/CharactersStreamSucker.java b/tools/vm-tests-tf/src/util/build/CharactersStreamSucker.java
deleted file mode 100644
index ce4dfb1..0000000
--- a/tools/vm-tests-tf/src/util/build/CharactersStreamSucker.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2012 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 util.build;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-
-import javax.annotation.Nonnull;
-
-/**
- * Class that continuously read an {@link InputStream} and optionally could print the input in a
- * {@link PrintStream}.
- */
-public class CharactersStreamSucker {
-
- @Nonnull
- private final BufferedReader ir;
-
- @Nonnull
- private final PrintStream os;
-
- private final boolean toBeClose;
-
- public CharactersStreamSucker(
- @Nonnull InputStream is, @Nonnull PrintStream os, boolean toBeClose) {
- this.ir = new BufferedReader(new InputStreamReader(is));
- this.os = os;
- this.toBeClose = toBeClose;
- }
-
- public CharactersStreamSucker(@Nonnull InputStream is, @Nonnull PrintStream os) {
- this(is, os, false);
- }
-
- public void suck() throws IOException {
- String line;
-
- try {
- while ((line = ir.readLine()) != null) {
- os.println(line);
- }
- } finally {
- if (toBeClose) {
- os.close();
- }
- }
- }
-}
\ No newline at end of file
diff --git a/tools/vm-tests-tf/src/util/build/D8BuildStep.java b/tools/vm-tests-tf/src/util/build/D8BuildStep.java
new file mode 100644
index 0000000..1e2c281
--- /dev/null
+++ b/tools/vm-tests-tf/src/util/build/D8BuildStep.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package util.build;
+
+import com.android.tools.r8.CompilationMode;
+import com.android.tools.r8.D8;
+import com.android.tools.r8.D8Command;
+import com.android.tools.r8.OutputMode;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.attribute.BasicFileAttributes;
+
+public class D8BuildStep extends BuildStep {
+
+ private final boolean deleteInputFileAfterBuild;
+ private final D8Command.Builder builder;
+
+ D8BuildStep(BuildFile inputFile, BuildFile outputFile, boolean deleteInputFileAfterBuild) {
+ super(inputFile, outputFile);
+ this.deleteInputFileAfterBuild = deleteInputFileAfterBuild;
+ this.builder =
+ D8Command.builder()
+ .setMode(CompilationMode.DEBUG)
+ .setMinApiLevel(1000)
+ .setEnableDesugaring(false);
+ }
+
+ @Override
+ boolean build() {
+
+ if (super.build()) {
+ try {
+ builder.setOutput(Paths.get(outputFile.fileName.getAbsolutePath()), OutputMode.DexIndexed);
+ Files.find(
+ Paths.get(inputFile.fileName.getAbsolutePath()),
+ 1000,
+ D8BuildStep::isJarOrClassFile)
+ .forEach(
+ p -> {
+ try {
+ builder.addProgramFiles(p);
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ });
+ D8.run(builder.build());
+ } catch (Throwable e) {
+ e.printStackTrace();
+ return false;
+ }
+ if (deleteInputFileAfterBuild) {
+ inputFile.fileName.delete();
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return inputFile.hashCode() ^ outputFile.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (super.equals(obj)) {
+ D8BuildStep other = (D8BuildStep) obj;
+
+ return inputFile.equals(other.inputFile) && outputFile.equals(other.outputFile);
+ }
+ return false;
+ }
+
+ private static boolean isJarOrClassFile(Path file, BasicFileAttributes attrs) {
+ if (!attrs.isRegularFile()) {
+ return false;
+ }
+ String name = file.getFileName().toString().toLowerCase();
+ return name.endsWith(".jar") || name.endsWith(".class");
+ }
+}
diff --git a/tools/vm-tests-tf/src/util/build/DxBuildStep.java b/tools/vm-tests-tf/src/util/build/DxBuildStep.java
deleted file mode 100644
index 6e347b2..0000000
--- a/tools/vm-tests-tf/src/util/build/DxBuildStep.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2008 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 util.build;
-
-import com.android.dx.command.dexer.Main;
-import java.io.IOException;
-
-public class DxBuildStep extends BuildStep {
-
- private final boolean deleteInputFileAfterBuild;
-
- DxBuildStep(BuildFile inputFile, BuildFile outputFile,
- boolean deleteInputFileAfterBuild) {
- super(inputFile, outputFile);
- this.deleteInputFileAfterBuild = deleteInputFileAfterBuild;
- }
-
- @Override
- boolean build() {
-
- if (super.build()) {
- Main.Arguments args = new Main.Arguments();
-
- args.jarOutput = true;
- args.fileNames = new String[] {inputFile.fileName.getAbsolutePath()};
-
- args.outName = outputFile.fileName.getAbsolutePath();
-
- int result = 0;
- try {
- result = Main.run(args);
- } catch (IOException e) {
- e.printStackTrace();
- return false;
- }
-
- if (result == 0) {
- if (deleteInputFileAfterBuild) {
- inputFile.fileName.delete();
- }
- return true;
- } else {
- System.err.println("exception while dexing "
- + inputFile.fileName.getAbsolutePath() + " to "
- + args.outName);
- return false;
- }
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return inputFile.hashCode() ^ outputFile.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (super.equals(obj)) {
- DxBuildStep other = (DxBuildStep) obj;
-
- return inputFile.equals(other.inputFile)
- && outputFile.equals(other.outputFile);
- }
- return false;
- }
-
-
-}
diff --git a/tools/vm-tests-tf/src/util/build/ExecuteFile.java b/tools/vm-tests-tf/src/util/build/ExecuteFile.java
deleted file mode 100644
index 128e477..0000000
--- a/tools/vm-tests-tf/src/util/build/ExecuteFile.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * Copyright (C) 2012 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 util.build;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.io.StreamTokenizer;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
-
-/**
- * Class to handle the execution of an external process
- */
-public class ExecuteFile {
- @Nonnull
- private final String[] cmdLine;
-
- @CheckForNull
- private File workDir;
-
- @CheckForNull
- private InputStream inStream;
- private boolean inToBeClose;
-
- @CheckForNull
- private OutputStream outStream;
- private boolean outToBeClose;
-
- @CheckForNull
- private OutputStream errStream;
- private boolean errToBeClose;
- private boolean verbose;
-
- @Nonnull
- private final Logger logger = Logger.getLogger(this.getClass().getName());
-
- public void setErr(@Nonnull File file) throws FileNotFoundException {
- errStream = new FileOutputStream(file);
- errToBeClose = true;
- }
-
- public void setOut(@Nonnull File file) throws FileNotFoundException {
- outStream = new FileOutputStream(file);
- outToBeClose = true;
- }
-
- public void setIn(@Nonnull File file) throws FileNotFoundException {
- inStream = new FileInputStream(file);
- inToBeClose = true;
- }
-
- public void setErr(@Nonnull OutputStream stream) {
- errStream = stream;
- }
-
- public void setOut(@Nonnull OutputStream stream) {
- outStream = stream;
- }
-
- public void setIn(@Nonnull InputStream stream) {
- inStream = stream;
- }
-
- public void setWorkingDir(@Nonnull File dir, boolean create) throws IOException {
- if (!dir.isDirectory()) {
- if (create && !dir.exists()) {
- if (!dir.mkdirs()) {
- throw new IOException("Directory creation failed");
- }
- } else {
- throw new FileNotFoundException(dir.getPath() + " is not a directory");
- }
- }
-
- workDir = dir;
- }
-
- public void setVerbose(boolean verbose) {
- this.verbose = verbose;
- }
-
- public ExecuteFile(@Nonnull File exec, @Nonnull String[] args) {
- cmdLine = new String[args.length + 1];
- System.arraycopy(args, 0, cmdLine, 1, args.length);
-
- cmdLine[0] = exec.getAbsolutePath();
- }
-
- public ExecuteFile(@Nonnull String exec, @Nonnull String[] args) {
- cmdLine = new String[args.length + 1];
- System.arraycopy(args, 0, cmdLine, 1, args.length);
-
- cmdLine[0] = exec;
- }
-
- public ExecuteFile(@Nonnull File exec) {
- cmdLine = new String[1];
- cmdLine[0] = exec.getAbsolutePath();
- }
-
- public ExecuteFile(@Nonnull String[] cmdLine) {
- this.cmdLine = cmdLine.clone();
- }
-
- public ExecuteFile(@Nonnull String cmdLine) throws IOException {
- StringReader reader = new StringReader(cmdLine);
- StreamTokenizer tokenizer = new StreamTokenizer(reader);
- tokenizer.resetSyntax();
- // Only standard spaces are recognized as whitespace chars
- tokenizer.whitespaceChars(' ', ' ');
- // Matches alphanumerical and common special symbols like '(' and ')'
- tokenizer.wordChars('!', 'z');
- // Quote chars will be ignored when parsing strings
- tokenizer.quoteChar('\'');
- tokenizer.quoteChar('\"');
- ArrayList<String> tokens = new ArrayList<String>();
- while (tokenizer.nextToken() != StreamTokenizer.TT_EOF) {
- String token = tokenizer.sval;
- if (token != null) {
- tokens.add(token);
- }
- }
- this.cmdLine = tokens.toArray(new String[0]);
- }
-
- public boolean run() {
- int ret;
- Process proc = null;
- Thread suckOut = null;
- Thread suckErr = null;
- Thread suckIn = null;
-
- try {
- StringBuilder cmdLineBuilder = new StringBuilder();
- for (String arg : cmdLine) {
- cmdLineBuilder.append(arg).append(' ');
- }
- if (verbose) {
- PrintStream printStream;
- if (outStream instanceof PrintStream) {
- printStream = (PrintStream) outStream;
- } else {
- printStream = System.out;
- }
-
- if (printStream != null) {
- printStream.println(cmdLineBuilder);
- }
- } else {
- logger.log(Level.FINE, "Execute: {0}", cmdLineBuilder);
- }
-
- proc = Runtime.getRuntime().exec(cmdLine, null, workDir);
-
- InputStream localInStream = inStream;
- if (localInStream != null) {
- suckIn = new Thread(
- new ThreadBytesStreamSucker(localInStream, proc.getOutputStream(), inToBeClose));
- } else {
- proc.getOutputStream().close();
- }
-
- OutputStream localOutStream = outStream;
- if (localOutStream != null) {
- if (localOutStream instanceof PrintStream) {
- suckOut = new Thread(new ThreadCharactersStreamSucker(proc.getInputStream(),
- (PrintStream) localOutStream, outToBeClose));
- } else {
- suckOut = new Thread(
- new ThreadBytesStreamSucker(proc.getInputStream(), localOutStream, outToBeClose));
- }
- }
-
- OutputStream localErrStream = errStream;
- if (localErrStream != null) {
- if (localErrStream instanceof PrintStream) {
- suckErr = new Thread(new ThreadCharactersStreamSucker(proc.getErrorStream(),
- (PrintStream) localErrStream, errToBeClose));
- } else {
- suckErr = new Thread(
- new ThreadBytesStreamSucker(proc.getErrorStream(), localErrStream, errToBeClose));
- }
- }
-
- if (suckIn != null) {
- suckIn.start();
- }
- if (suckOut != null) {
- suckOut.start();
- }
- if (suckErr != null) {
- suckErr.start();
- }
-
- proc.waitFor();
- if (suckIn != null) {
- suckIn.join();
- }
- if (suckOut != null) {
- suckOut.join();
- }
- if (suckErr != null) {
- suckErr.join();
- }
-
- ret = proc.exitValue();
- proc.destroy();
-
- return ret == 0;
- } catch (Throwable e) {
- e.printStackTrace();
- return false;
- }
- }
-
- private static class ThreadBytesStreamSucker extends BytesStreamSucker implements Runnable {
-
- public ThreadBytesStreamSucker(@Nonnull InputStream is, @Nonnull OutputStream os,
- boolean toBeClose) {
- super(is, os, toBeClose);
- }
-
- @Override
- public void run() {
- try {
- suck();
- } catch (IOException e) {
- // Best effort
- }
- }
- }
-
- private static class ThreadCharactersStreamSucker extends CharactersStreamSucker implements
- Runnable {
-
- public ThreadCharactersStreamSucker(@Nonnull InputStream is, @Nonnull PrintStream ps,
- boolean toBeClose) {
- super(is, ps, toBeClose);
- }
-
- @Override
- public void run() {
- try {
- suck();
- } catch (IOException e) {
- // Best effort
- }
- }
- }
-}
\ No newline at end of file
diff --git a/tools/vm-tests-tf/src/util/build/JackBuildDalvikSuite.java b/tools/vm-tests-tf/src/util/build/JackBuildDalvikSuite.java
deleted file mode 100644
index 2b45f9c..0000000
--- a/tools/vm-tests-tf/src/util/build/JackBuildDalvikSuite.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package util.build;
-
-import java.io.IOException;
-
-public class JackBuildDalvikSuite {
-
- public static String JACK;
-
- public static void main(String[] args) throws IOException {
-
- String[] remainingArgs;
- if (args.length > 0) {
- JACK = args[0];
- remainingArgs = new String[args.length - 1];
- System.arraycopy(args, 1, remainingArgs, 0, remainingArgs.length);
- } else {
- remainingArgs = args;
- }
-
- if (!BuildDalvikSuite.parseArgs(remainingArgs)) {
- printUsage();
- System.exit(-1);
- }
-
- long start = System.currentTimeMillis();
- BuildDalvikSuite cat = new BuildDalvikSuite(true);
- cat.compose();
- long end = System.currentTimeMillis();
-
- System.out.println("elapsed seconds: " + (end - start) / 1000);
- }
-
-
- private static void printUsage() {
- System.out.println("usage: java-src-folder output-folder classpath " +
- "generated-main-files compiled_output generated-main-files " +
- "[restrict-to-opcode]");
- }
-}
diff --git a/tools/vm-tests-tf/src/util/build/JackBuildStep.java b/tools/vm-tests-tf/src/util/build/JackBuildStep.java
deleted file mode 100644
index ed46582..0000000
--- a/tools/vm-tests-tf/src/util/build/JackBuildStep.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package util.build;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-public class JackBuildStep extends SourceBuildStep {
-
- private final String destPath;
- private final String classPath;
- private final Set<String> sourceFiles = new HashSet<String>();
-
- public JackBuildStep(String destPath, String classPath) {
- super(new File(destPath));
- this.destPath = destPath;
- this.classPath = classPath;
- }
-
- @Override
- public void addSourceFile(String sourceFile) {
- sourceFiles.add(sourceFile);
- }
-
- @Override
- boolean build() {
- if (super.build()) {
- if (sourceFiles.isEmpty()) {
- return true;
- }
-
- File outDir = new File(destPath).getParentFile();
- if (!outDir.exists() && !outDir.mkdirs()) {
- System.err.println("failed to create output dir: "
- + outDir.getAbsolutePath());
- return false;
- }
-
- File tmpOutDir = new File(outDir, outputFile.fileName.getName() + ".dexTmp");
- if (!tmpOutDir.exists() && !tmpOutDir.mkdirs()) {
- System.err.println("failed to create temp dir: "
- + tmpOutDir.getAbsolutePath());
- return false;
- }
- File tmpDex = new File(tmpOutDir, "classes.dex");
-
- File tmpArgs = new File(outDir, outputFile.fileName.getName() + ".args");
-
- Writer argsOut = null;
- try {
- argsOut = new FileWriter(tmpArgs);
- for (String source : sourceFiles) {
- argsOut.append(source);
- argsOut.append('\n');
- }
- argsOut.close();
- argsOut = null;
-
- List<String> commandLine = new ArrayList<String>(6 + sourceFiles.size());
- commandLine.add("--verbose");
- commandLine.add("error");
- commandLine.add("--classpath");
- commandLine.add(classPath);
- commandLine.add("--output-dex");
- commandLine.add(tmpOutDir.getAbsolutePath());
- commandLine.add("@" + tmpArgs.getPath());
-
- ExecuteFile exec = new ExecuteFile(JackBuildDalvikSuite.JACK,
- commandLine.toArray(new String[commandLine.size()]));
- exec.setErr(System.err);
- exec.setOut(System.out);
- if (!exec.run()) {
- return false;
- }
-
- JarBuildStep jarStep = new JarBuildStep(
- new BuildFile(tmpDex),
- "classes.dex",
- outputFile,
- /* deleteInputFileAfterBuild = */ true);
- if (!jarStep.build()) {
- throw new IOException("Failed to make jar: " + outputFile.getPath());
- }
- return true;
- } catch (Throwable ex) {
- ex.printStackTrace();
- return false;
- } finally {
- tmpDex.delete();
- tmpArgs.delete();
- tmpOutDir.delete();
- if (argsOut != null) {
- try {
- argsOut.close();
- } catch (IOException io) {
- // Ignore, don't override already thrown exception
- }
- }
- }
- }
- return false;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (super.equals(obj)) {
- JackBuildStep other = (JackBuildStep) obj;
- return destPath.equals(other.destPath) && classPath.equals(other.classPath)
- && sourceFiles.equals(other.sourceFiles);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return destPath.hashCode() ^ classPath.hashCode() ^ sourceFiles.hashCode();
- }
-}
diff --git a/tools/vm-tests-tf/src/util/build/JackDexBuildStep.java b/tools/vm-tests-tf/src/util/build/JackDexBuildStep.java
deleted file mode 100644
index cbd5a3b..0000000
--- a/tools/vm-tests-tf/src/util/build/JackDexBuildStep.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2008 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 util.build;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-public class JackDexBuildStep extends BuildStep {
-
- private final boolean deleteInputFileAfterBuild;
-
- JackDexBuildStep(BuildFile inputFile, BuildFile outputFile,
- boolean deleteInputFileAfterBuild) {
- super(inputFile, outputFile);
- this.deleteInputFileAfterBuild = deleteInputFileAfterBuild;
- }
-
- @Override
- boolean build() {
-
- if (super.build()) {
- String outputFilePath = outputFile.fileName.getAbsolutePath();
- if (outputFilePath.endsWith(".dex")) {
- throw new AssertionError(
- "JackDexBuildStep does not support dex output outside of an archive");
- }
-
- File outDir = outputFile.fileName.getParentFile();
- if (!outDir.exists() && !outDir.mkdirs()) {
- System.err.println("failed to create output dir: "
- + outDir.getAbsolutePath());
- return false;
- }
-
- File tmpOutDir = new File(outDir, outputFile.fileName.getName() + ".dexTmp");
- if (!tmpOutDir.exists() && !tmpOutDir.mkdirs()) {
- System.err.println("failed to create temp dir: "
- + tmpOutDir.getAbsolutePath());
- return false;
- }
- File tmpDex = new File(tmpOutDir, "classes.dex");
-
- try {
- List<String> commandLine = new ArrayList<String>(4);
- commandLine.add("--verbose");
- commandLine.add("error");
- commandLine.add("--output-dex");
- commandLine.add(tmpOutDir.getAbsolutePath());
- commandLine.add("--import");
- commandLine.add(inputFile.fileName.getAbsolutePath());
-
- ExecuteFile exec = new ExecuteFile(JackBuildDalvikSuite.JACK,
- commandLine.toArray(new String[commandLine.size()]));
- exec.setErr(System.err);
- exec.setOut(System.out);
- if (!exec.run()) {
- return false;
- }
-
- JarBuildStep jarStep = new JarBuildStep(
- new BuildFile(tmpDex),
- "classes.dex",
- outputFile,
- /* deleteInputFileAfterBuild = */ true);
- if (!jarStep.build()) {
- throw new IOException("Failed to make jar: " + outputFile.getPath());
- }
- if (deleteInputFileAfterBuild) {
- inputFile.fileName.delete();
- }
- return true;
- } catch (Throwable ex) {
- System.err.println("exception while dexing "
- + inputFile.fileName.getAbsolutePath() + " to "
- + outputFile.fileName.getAbsolutePath());
- ex.printStackTrace();
- } finally {
- tmpDex.delete();
- tmpOutDir.delete();
- }
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return inputFile.hashCode() ^ outputFile.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (super.equals(obj)) {
- JackDexBuildStep other = (JackDexBuildStep) obj;
-
- return inputFile.equals(other.inputFile)
- && outputFile.equals(other.outputFile);
- }
- return false;
- }
-
-
-}
diff --git a/tools/vm-tests-tf/src/util/build/JavacBuildStep.java b/tools/vm-tests-tf/src/util/build/JavacBuildStep.java
index a1cde1f..e551989 100644
--- a/tools/vm-tests-tf/src/util/build/JavacBuildStep.java
+++ b/tools/vm-tests-tf/src/util/build/JavacBuildStep.java
@@ -16,12 +16,18 @@
package util.build;
-import com.sun.tools.javac.Main;
-
import java.io.File;
-import java.io.PrintWriter;
+import java.lang.Iterable;
+import java.util.stream.Collectors;
+import java.util.Arrays;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
public class JavacBuildStep extends SourceBuildStep {
@@ -55,23 +61,37 @@
System.err.println("failed to create destination dir");
return false;
}
- int args = 8;
- String[] commandLine = new String[sourceFiles.size()+args];
- commandLine[0] = "-classpath";
- commandLine[1] = classPath;
- commandLine[2] = "-d";
- commandLine[3] = destPath;
- commandLine[4] = "-source";
- commandLine[5] = "1.7";
- commandLine[6] = "-target";
- commandLine[7] = "1.7";
- String[] files = new String[sourceFiles.size()];
- sourceFiles.toArray(files);
+ Iterable<File> classPathFiles = Arrays.asList(classPath.split(":"))
+ .stream()
+ .map(File::new)
+ .collect(Collectors.toList());
- System.arraycopy(files, 0, commandLine, args, files.length);
+ JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+ try (StandardJavaFileManager fileManager = compiler.getStandardFileManager(
+ null, // diagnosticListener: we don't care about the details.
+ null, // locale: use default locale.
+ null)) { // charset: use platform default.
+ fileManager.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(
+ new File(destPath)));
+ fileManager.setLocation(StandardLocation.CLASS_PATH, classPathFiles);
- return Main.compile(commandLine, new PrintWriter(System.err)) == 0;
+ Iterable<? extends JavaFileObject> compilationUnits =
+ fileManager.getJavaFileObjectsFromStrings(sourceFiles);
+
+ List<String> options = Arrays.asList("-source", "1.7", "-target", "1.7");
+
+ return compiler.getTask(
+ null, // out: write errors to System.err.
+ fileManager,
+ null, // diagnosticListener: we don't care about the details.
+ options,
+ null, // classes: classes for annotation processing = none.
+ compilationUnits).call();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
}
return false;
}
diff --git a/tools/vm-tests-tf/src/util/build/JillBuildStep.java b/tools/vm-tests-tf/src/util/build/JillBuildStep.java
deleted file mode 100644
index 80cd49c..0000000
--- a/tools/vm-tests-tf/src/util/build/JillBuildStep.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package util.build;
-
-import java.io.File;
-import java.io.IOException;
-
-public class JillBuildStep extends BuildStep {
-
- JillBuildStep(BuildFile inputFile, BuildFile outputFile) {
- super(inputFile, outputFile);
- }
-
- @Override
- boolean build() {
- if (super.build()) {
- File tmpInputJar = new File(inputFile.fileName.getPath() + ".jar");
- try {
-
- File outDir = outputFile.fileName.getParentFile();
- if (!outDir.exists() && !outDir.mkdirs()) {
- System.err.println("failed to create output dir: "
- + outDir.getAbsolutePath());
- return false;
- }
-
- // input file is a class file but jack supports only jar
- JarBuildStep jarStep = new JarBuildStep(
- inputFile,
- inputFile.fileName.getName(),
- new BuildFile(tmpInputJar),
- /* deleteInputFileAfterBuild = */ false);
- if (!jarStep.build()) {
- throw new IOException("Failed to make jar: " + outputFile.getPath());
- }
-
-
- String[] commandLine = new String[] {
- "--verbose",
- "error",
- "--import",
- tmpInputJar.getAbsolutePath(),
- "--output-jack",
- outputFile.fileName.getAbsolutePath(),
- };
-
- ExecuteFile exec = new ExecuteFile(JackBuildDalvikSuite.JACK, commandLine);
- exec.setErr(System.err);
- exec.setOut(System.out);
- if (!exec.run()) {
- return false;
- }
-
- return true;
- } catch (Throwable ex) {
- System.err.println("exception while transforming jack file from jar "
- + inputFile.fileName.getAbsolutePath() + " to "
- + outputFile.fileName.getAbsolutePath());
- ex.printStackTrace();
- } finally {
- tmpInputJar.delete();
- }
- }
- return false;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (super.equals(obj)) {
- JillBuildStep other = (JillBuildStep) obj;
-
- return inputFile.equals(other.inputFile) && outputFile.equals(other.outputFile);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return inputFile.hashCode() ^ outputFile.hashCode();
- }
-}