Merge "Enforce Treble-only neverallows" into oc-dev
diff --git a/apps/CameraITS/tools/run_all_tests.py b/apps/CameraITS/tools/run_all_tests.py
index b1c8177..9e98b79 100644
--- a/apps/CameraITS/tools/run_all_tests.py
+++ b/apps/CameraITS/tools/run_all_tests.py
@@ -19,11 +19,26 @@
import subprocess
import time
import sys
-import textwrap
+
+import its.caps
import its.device
from its.device import ItsSession
CHART_DELAY = 1 # seconds
+FACING_EXTERNAL = 2
+SKIP_RET_CODE = 101 # note this must be same as tests/scene*/test_*
+
+
+def skip_sensor_fusion():
+ """Determine if sensor fusion test is skipped for this camera."""
+
+ skip_code = SKIP_RET_CODE
+ with ItsSession() as cam:
+ props = cam.get_camera_properties()
+ if (its.caps.sensor_fusion(props) and its.caps.manual_sensor(props) and
+ props['android.lens.facing'] is not FACING_EXTERNAL):
+ skip_code = None
+ return skip_code
def main():
@@ -45,61 +60,58 @@
all android devices.
"""
- SKIP_RET_CODE = 101
-
# Not yet mandated tests
NOT_YET_MANDATED = {
- "scene0":[
+ "scene0": [
"test_jitter"
- ],
- "scene1":[
+ ],
+ "scene1": [
"test_ae_af",
"test_ae_precapture_trigger",
"test_crop_region_raw",
"test_ev_compensation_advanced",
"test_ev_compensation_basic",
"test_yuv_plus_jpeg"
- ],
- "scene2":[],
- "scene3":[
+ ],
+ "scene2": [],
+ "scene3": [
"test_lens_movement_reporting",
"test_lens_position"
- ],
- "scene4":[],
- "scene5":[],
- "sensor_fusion":[]
+ ],
+ "scene4": [],
+ "scene5": [],
+ "sensor_fusion": []
}
- all_scenes = ["scene0", "scene1", "scene2", "scene3", "scene4", "scene5"]
+ all_scenes = ["scene0", "scene1", "scene2", "scene3", "scene4", "scene5",
+ "sensor_fusion"]
auto_scenes = ["scene0", "scene1", "scene2", "scene3", "scene4"]
scene_req = {
- "scene0" : None,
- "scene1" : "A grey card covering at least the middle 30% of the scene",
- "scene2" : "A picture containing human faces",
- "scene3" : "The ISO 12233 chart",
- "scene4" : "A specific test page of a circle covering at least the "
- "middle 50% of the scene. See CameraITS.pdf section 2.3.4 "
- "for more details",
- "scene5" : "Capture images with a diffuser attached to the camera. See "
- "CameraITS.pdf section 2.3.4 for more details",
- "sensor_fusion" : "Rotating checkboard pattern. See "
- "sensor_fusion/SensorFusion.pdf for detailed "
- "instructions. Note that this test will be skipped "
- "on devices not supporting REALTIME camera timestamp."
- "If that is the case, no scene setup is required and "
- "you can just answer Y when being asked if the scene "
- "is okay"
+ "scene0": None,
+ "scene1": "A grey card covering at least the middle 30% of the scene",
+ "scene2": "A picture containing human faces",
+ "scene3": "The ISO 12233 chart",
+ "scene4": "A specific test page of a circle covering at least the "
+ "middle 50% of the scene. See CameraITS.pdf section 2.3.4 "
+ "for more details",
+ "scene5": "Capture images with a diffuser attached to the camera. See "
+ "CameraITS.pdf section 2.3.4 for more details",
+ "sensor_fusion": "Rotating checkboard pattern. See "
+ "sensor_fusion/SensorFusion.pdf for detailed "
+ "instructions.\nNote that this test will be skipped "
+ "on devices not supporting REALTIME camera timestamp."
}
scene_extra_args = {
- "scene5" : ["doAF=False"]
+ "scene5": ["doAF=False"]
}
camera_ids = []
scenes = []
chart_host_id = None
result_device_id = None
+ rot_rig_id = None
for s in sys.argv[1:]:
if s[:7] == "camera=" and len(s) > 7:
@@ -110,6 +122,9 @@
chart_host_id = s[6:]
elif s[:7] == 'result=' and len(s) > 7:
result_device_id = s[7:]
+ 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'
auto_scene_switch = chart_host_id is not None
merge_result_switch = result_device_id is not None
@@ -128,7 +143,6 @@
else:
try:
# Try replace "X" to "sceneX"
- scene_num = int(s)
scene_str = "scene" + s
if scene_str not in possible_scenes:
valid_scenes = False
@@ -140,7 +154,7 @@
if not valid_scenes:
print "Unknown scene specifiied:", s
- assert(False)
+ assert False
scenes = temp_scenes
# Initialize test results
@@ -157,7 +171,7 @@
device_id_arg = "device=" + device_id
print "Testing device " + device_id
- #Sanity Check for devices
+ # Sanity Check for devices
device_bfp = its.device.get_device_fingerprint(device_id)
assert device_bfp is not None
@@ -167,19 +181,19 @@
if merge_result_switch:
result_device_bfp = its.device.get_device_fingerprint(result_device_id)
- assert device_bfp == result_device_bfp, \
- "Can not merge result to a different build, from %s to %s" \
- % (device_bfp, result_device_bfp)
+ assert_err_msg = ('Cannot merge result to a different build, from '
+ '%s to %s' % (device_bfp, result_device_bfp))
+ assert device_bfp == result_device_bfp, assert_err_msg
# user doesn't specify camera id, run through all cameras
if not camera_ids:
camera_ids_path = os.path.join(topdir, "camera_ids.txt")
out_arg = "out=" + camera_ids_path
cmd = ['python',
- os.path.join(os.getcwd(),"tools/get_camera_ids.py"), out_arg,
+ os.path.join(os.getcwd(), "tools/get_camera_ids.py"), out_arg,
device_id_arg]
- retcode = subprocess.call(cmd,cwd=topdir)
- assert(retcode == 0)
+ cam_code = subprocess.call(cmd, cwd=topdir)
+ assert cam_code == 0
with open(camera_ids_path, "r") as f:
for line in f:
camera_ids.append(line.replace('\n', ''))
@@ -196,8 +210,8 @@
screen_id_arg = ('screen=%s' % chart_host_id)
cmd = ['python', os.path.join(os.environ['CAMERA_ITS_TOP'], 'tools',
'wake_up_screen.py'), screen_id_arg]
- retcode = subprocess.call(cmd)
- assert retcode == 0
+ wake_code = subprocess.call(cmd)
+ assert wake_code == 0
for camera_id in camera_ids:
# Loop capturing images until user confirm test scene is correct
@@ -209,8 +223,9 @@
os.mkdir(os.path.join(topdir, camera_id, d))
for scene in scenes:
- tests = [(s[:-3],os.path.join("tests", scene, s))
- for s in os.listdir(os.path.join("tests",scene))
+ skip_code = None
+ tests = [(s[:-3], os.path.join("tests", scene, s))
+ for s in os.listdir(os.path.join("tests", scene))
if s[-3:] == ".py" and s[:4] == "test"]
tests.sort()
@@ -219,36 +234,42 @@
numskip = 0
num_not_mandated_fail = 0
numfail = 0
- if scene_req[scene] != None:
+ validate_switch = True
+ if scene_req[scene] is not None:
out_path = os.path.join(topdir, camera_id, scene+".jpg")
out_arg = "out=" + out_path
+ if scene == 'sensor_fusion':
+ skip_code = skip_sensor_fusion()
+ if rot_rig_id or skip_code == SKIP_RET_CODE:
+ validate_switch = False
+ if scene == 'scene5':
+ validate_switch = False
cmd = None
if auto_scene_switch:
- if not merge_result_switch or \
- (merge_result_switch and camera_ids[0] == '0'):
- scene_arg = "scene=" + scene
+ if (not merge_result_switch or
+ (merge_result_switch and camera_ids[0] == '0')):
+ scene_arg = 'scene=' + scene
cmd = ['python',
os.path.join(os.getcwd(), 'tools/load_scene.py'),
scene_arg, screen_id_arg]
else:
time.sleep(CHART_DELAY)
else:
- # Skip scene validation for scene 5 running in parallel
- if not merge_result_switch or scene != 'scene5':
- scene_arg = "scene=" + scene_req[scene]
+ # Skip scene validation under certain conditions
+ if validate_switch and not merge_result_switch:
+ scene_arg = 'scene=' + scene_req[scene]
extra_args = scene_extra_args.get(scene, [])
cmd = ['python',
- os.path.join(os.getcwd(),"tools/validate_scene.py"),
- camera_id_arg, out_arg,
- scene_arg, device_id_arg] + extra_args
-
+ os.path.join(os.getcwd(),
+ 'tools/validate_scene.py'),
+ camera_id_arg, out_arg,
+ scene_arg, device_id_arg] + extra_args
if cmd is not None:
- retcode = subprocess.call(cmd,cwd=topdir)
- assert(retcode == 0)
+ valid_scene_code = subprocess.call(cmd, cwd=topdir)
+ assert valid_scene_code == 0
print "Start running ITS on camera %s, %s" % (camera_id, scene)
-
# Run each test, capturing stdout and stderr.
- for (testname,testpath) in tests:
+ for (testname, testpath) in tests:
if auto_scene_switch:
if merge_result_switch and camera_ids[0] == '0':
# Send an input event to keep the screen not dimmed.
@@ -260,25 +281,37 @@
cmd = ('adb -s %s shell input keyevent FOCUS'
% chart_host_id)
subprocess.call(cmd.split())
- cmd = ['python', os.path.join(os.getcwd(),testpath)] + \
- sys.argv[1:] + [camera_id_arg]
- outdir = os.path.join(topdir,camera_id,scene)
- outpath = os.path.join(outdir,testname+"_stdout.txt")
- errpath = os.path.join(outdir,testname+"_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)
+ 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:
+ 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)
t1 = time.time()
test_failed = False
- if retcode == 0:
+ if test_code == 0:
retstr = "PASS "
numpass += 1
- elif retcode == SKIP_RET_CODE:
+ elif test_code == SKIP_RET_CODE:
retstr = "SKIP "
numskip += 1
- elif retcode != 0 and testname in NOT_YET_MANDATED[scene]:
+ elif test_code != 0 and testname in NOT_YET_MANDATED[scene]:
retstr = "FAIL*"
num_not_mandated_fail += 1
else:
@@ -294,16 +327,15 @@
if numskip > 0:
skipstr = ", %d test%s skipped" % (
- numskip, "s" if numskip > 1 else "")
+ numskip, "s" if numskip > 1 else "")
else:
skipstr = ""
test_result = "\n%d / %d tests passed (%.1f%%)%s" % (
- numpass + num_not_mandated_fail, len(tests) - numskip,
- 100.0 * float(numpass + num_not_mandated_fail) /
- (len(tests) - numskip)
- if len(tests) != numskip else 100.0,
- skipstr)
+ numpass + num_not_mandated_fail, len(tests) - numskip,
+ 100.0 * float(numpass + num_not_mandated_fail) /
+ (len(tests) - numskip)
+ if len(tests) != numskip else 100.0, skipstr)
print test_result
if num_not_mandated_fail > 0:
@@ -316,7 +348,7 @@
passed = numfail == 0
results[scene][result_key] = (ItsSession.RESULT_PASS if passed
- else ItsSession.RESULT_FAIL)
+ else ItsSession.RESULT_FAIL)
results[scene][ItsSession.SUMMARY_KEY] = summary_path
print "Reporting ITS result to CtsVerifier"
@@ -335,15 +367,15 @@
screen_id_arg = ('screen=%s' % chart_host_id)
cmd = ['python', os.path.join(os.environ['CAMERA_ITS_TOP'], 'tools',
'turn_off_screen.py'), screen_id_arg]
- retcode = subprocess.call(cmd)
- assert retcode == 0
+ screen_off_code = subprocess.call(cmd)
+ assert screen_off_code == 0
print 'Shutting down DUT screen: ', device_id
screen_id_arg = ('screen=%s' % device_id)
cmd = ['python', os.path.join(os.environ['CAMERA_ITS_TOP'], 'tools',
- 'turn_off_screen.py'), screen_id_arg]
- retcode = subprocess.call(cmd)
- assert retcode == 0
+ 'turn_off_screen.py'), screen_id_arg]
+ screen_off_code = subprocess.call(cmd)
+ assert screen_off_code == 0
print "ITS tests finished. Please go back to CtsVerifier and proceed"
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 996a056..6794059 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
@@ -67,6 +67,7 @@
import java.util.NoSuchElementException;
import java.util.Random;
import java.util.Set;
+import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
public class UsbDeviceTestActivity extends PassFailButtons.Activity {
@@ -842,14 +843,12 @@
runAndAssertException(() -> connection.requestWait(-1), IllegalArgumentException.class);
long startTime = now();
- UsbRequest req = connection.requestWait(100);
- assertNull(req);
+ runAndAssertException(() -> connection.requestWait(100), TimeoutException.class);
assertTrue(now() - startTime >= 100);
assertTrue(now() - startTime < 400);
startTime = now();
- req = connection.requestWait(0);
- assertNull(req);
+ runAndAssertException(() -> connection.requestWait(0), TimeoutException.class);
assertTrue(now() - startTime < 400);
}
@@ -860,7 +859,7 @@
* @param in The endpoint to receive requests from
*/
private void receiveAfterTimeout(@NonNull UsbDeviceConnection connection,
- @NonNull UsbEndpoint in, int timeout) throws InterruptedException {
+ @NonNull UsbEndpoint in, long timeout) throws InterruptedException, TimeoutException {
UsbRequest reqQueued = new UsbRequest();
ByteBuffer buffer = ByteBuffer.allocate(1);
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 7ecdc30..a73f964 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
@@ -285,12 +285,11 @@
// 6. request network
ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(
Context.CONNECTIVITY_SERVICE);
- String networkSpecifier = mIsSecurityOpen ? discoverySession.createNetworkSpecifierOpen(
- peerHandle) : discoverySession.createNetworkSpecifierPassphrase(peerHandle,
- PASSPHRASE);
NetworkRequest nr = new NetworkRequest.Builder().addTransportType(
NetworkCapabilities.TRANSPORT_WIFI_AWARE).setNetworkSpecifier(
- networkSpecifier).build();
+ mIsSecurityOpen ? discoverySession.createNetworkSpecifierOpen(peerHandle)
+ : discoverySession.createNetworkSpecifierPassphrase(peerHandle,
+ PASSPHRASE)).build();
CallbackUtils.NetworkCb networkCb = new CallbackUtils.NetworkCb();
cm.requestNetwork(nr, CALLBACK_TIMEOUT_SEC * 1000, networkCb);
mListener.onTestMsgReceived(mContext.getString(R.string.aware_status_network_requested));
@@ -374,12 +373,11 @@
// 4. Request network
ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(
Context.CONNECTIVITY_SERVICE);
- String networkSpecifier = mIsSecurityOpen ? discoverySession.createNetworkSpecifierOpen(
- peerHandle) : discoverySession.createNetworkSpecifierPassphrase(peerHandle,
- PASSPHRASE);
NetworkRequest nr = new NetworkRequest.Builder().addTransportType(
NetworkCapabilities.TRANSPORT_WIFI_AWARE).setNetworkSpecifier(
- networkSpecifier).build();
+ mIsSecurityOpen ? discoverySession.createNetworkSpecifierOpen(peerHandle)
+ : discoverySession.createNetworkSpecifierPassphrase(peerHandle,
+ PASSPHRASE)).build();
CallbackUtils.NetworkCb networkCb = new CallbackUtils.NetworkCb();
cm.requestNetwork(nr, CALLBACK_TIMEOUT_SEC * 1000, networkCb);
mListener.onTestMsgReceived(mContext.getString(R.string.aware_status_network_requested));
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 a2e0de5..3dc31e1 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
@@ -265,13 +265,13 @@
// 6. Request network (as Responder) and wait for network
ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(
Context.CONNECTIVITY_SERVICE);
- String networkSpecifier = mIsSecurityOpen ? mWifiAwareSession.createNetworkSpecifierOpen(
- WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER, peerMac)
- : mWifiAwareSession.createNetworkSpecifierPassphrase(
- WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER, peerMac, PASSPHRASE);
NetworkRequest nr = new NetworkRequest.Builder().addTransportType(
NetworkCapabilities.TRANSPORT_WIFI_AWARE).setNetworkSpecifier(
- networkSpecifier).build();
+ mIsSecurityOpen ? mWifiAwareSession.createNetworkSpecifierOpen(
+ WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER, peerMac)
+ : mWifiAwareSession.createNetworkSpecifierPassphrase(
+ WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER, peerMac,
+ PASSPHRASE)).build();
CallbackUtils.NetworkCb networkCb = new CallbackUtils.NetworkCb();
cm.requestNetwork(nr, CALLBACK_TIMEOUT_SEC * 1000, networkCb);
mListener.onTestMsgReceived(mContext.getString(R.string.aware_status_network_requested));
@@ -397,13 +397,13 @@
// 8. Request network (as Initiator) and wait for network
ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(
Context.CONNECTIVITY_SERVICE);
- String networkSpecifier = mIsSecurityOpen ? mWifiAwareSession.createNetworkSpecifierOpen(
- WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR, peerMac)
- : mWifiAwareSession.createNetworkSpecifierPassphrase(
- WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR, peerMac, PASSPHRASE);
NetworkRequest nr = new NetworkRequest.Builder().addTransportType(
NetworkCapabilities.TRANSPORT_WIFI_AWARE).setNetworkSpecifier(
- networkSpecifier).build();
+ mIsSecurityOpen ? mWifiAwareSession.createNetworkSpecifierOpen(
+ WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR, peerMac)
+ : mWifiAwareSession.createNetworkSpecifierPassphrase(
+ WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR, peerMac,
+ PASSPHRASE)).build();
CallbackUtils.NetworkCb networkCb = new CallbackUtils.NetworkCb();
cm.requestNetwork(nr, CALLBACK_TIMEOUT_SEC * 1000, networkCb);
mListener.onTestMsgReceived(mContext.getString(R.string.aware_status_network_requested));
diff --git a/apps/CtsVerifierUSBCompanion/src/com/android/cts/verifierusbcompanion/DeviceTestCompanion.java b/apps/CtsVerifierUSBCompanion/src/com/android/cts/verifierusbcompanion/DeviceTestCompanion.java
index 001b18a..7cbeccf 100644
--- a/apps/CtsVerifierUSBCompanion/src/com/android/cts/verifierusbcompanion/DeviceTestCompanion.java
+++ b/apps/CtsVerifierUSBCompanion/src/com/android/cts/verifierusbcompanion/DeviceTestCompanion.java
@@ -76,7 +76,8 @@
assertEquals(42, sizeBuffer[0]);
assertEquals(1, numRead);
- return Charset.forName("UTF-8").decode(ByteBuffer.wrap(nextTestNameBytes)).toString();
+ return Charset.forName("UTF-8").decode(
+ ByteBuffer.wrap(nextTestNameBytes)).toString().trim();
}
/**
diff --git a/hostsidetests/incident/src/com/android/server/cts/NotificationTest.java b/hostsidetests/incident/src/com/android/server/cts/NotificationTest.java
index 0e27a66..10a1b77 100644
--- a/hostsidetests/incident/src/com/android/server/cts/NotificationTest.java
+++ b/hostsidetests/incident/src/com/android/server/cts/NotificationTest.java
@@ -43,7 +43,6 @@
found = true;
assertEquals(State.POSTED, record.getState());
assertTrue(record.getImportance() > 0 /* NotificationManager.IMPORTANCE_NONE */);
- assertEquals(record.getKey(), record.getGroupKey());
// Ensure these fields exist, at least
record.getFlags();
diff --git a/tests/autofillservice/src/android/autofillservice/cts/LoginActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/LoginActivityTest.java
index f6ddb13..3f68b50 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/LoginActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/LoginActivityTest.java
@@ -57,7 +57,6 @@
import android.content.IntentFilter;
import android.content.IntentSender;
import android.os.Bundle;
-import android.os.SystemClock;
import android.support.test.rule.ActivityTestRule;
import android.support.test.uiautomator.UiObject2;
import android.view.View;
@@ -85,7 +84,7 @@
*
* Save
* - test cases where only non-savable-ids are changed
- * - test case where 'no thanks' is tapped (similar to testSaveSnackBarGoesAway())
+ * - test case where 'no thanks' or 'x' is tapped (similar to former testSaveSnackBarGoesAway())
*
* Other assertions
* - illegal state thrown on callback calls
@@ -810,53 +809,6 @@
assertNoDanglingSessions();
}
- private void setSnackBarLifetimeMs(long timeout) {
- runShellCommand("cmd autofill set save_timeout %s", timeout);
- }
-
- @Test
- public void testSaveSnackBarGoesAway() throws Exception {
- enableService();
- final int timeout = 1000;
- setSnackBarLifetimeMs(timeout);
-
- try {
- // Set expectations.
- sReplier.addResponse(new CannedFillResponse.Builder()
- .setRequiredSavableIds(SAVE_DATA_TYPE_PASSWORD, ID_USERNAME, ID_PASSWORD)
- .build());
-
- // Trigger auto-fill.
- mActivity.onUsername(View::requestFocus);
-
- // Wait for onFill() before proceeding, otherwise the fields might be changed before
- // the session started
- sReplier.getNextFillRequest();
-
- // Sanity check.
- sUiBot.assertNoDatasets();
-
- // Set credentials...
- mActivity.onUsername((v) -> v.setText("malkovich"));
- mActivity.onPassword((v) -> v.setText("malkovich"));
-
- // ...and login
- final String expectedMessage = getWelcomeMessage("malkovich");
- final String actualMessage = mActivity.tapLogin();
- assertWithMessage("Wrong welcome msg").that(actualMessage).isEqualTo(expectedMessage);
-
- // Assert the snack bar is shown.
- sUiBot.assertSaveShowing(SAVE_DATA_TYPE_PASSWORD);
- SystemClock.sleep(timeout);
- sUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_PASSWORD);
-
- // Sanity check: once timed out, session should be finsihed.
- assertNoDanglingSessions();
- } finally {
- setSnackBarLifetimeMs(5000);
- }
- }
-
@Test
public void testGenericSave() throws Exception {
customizedSaveTest(SAVE_DATA_TYPE_GENERIC);
diff --git a/tests/signature/src/android/signature/cts/JDiffClassDescription.java b/tests/signature/src/android/signature/cts/JDiffClassDescription.java
index 2779ea7..2d13ed2 100644
--- a/tests/signature/src/android/signature/cts/JDiffClassDescription.java
+++ b/tests/signature/src/android/signature/cts/JDiffClassDescription.java
@@ -58,6 +58,8 @@
// 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()");
diff --git a/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java b/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java
index b69a8c5..096eef9 100644
--- a/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java
+++ b/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java
@@ -276,6 +276,9 @@
}
public void testAlarmClockShowTimers() {
+ if (mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK_ONLY)) {
+ return;
+ }
Intent intent = new Intent(AlarmClock.ACTION_SHOW_TIMERS);
assertCanBeHandled(intent);
}
diff --git a/tests/tests/graphics/res/drawable-nodpi/alpha_mask.png b/tests/tests/graphics/res/drawable-nodpi/alpha_mask.png
new file mode 100644
index 0000000..1d6177f
--- /dev/null
+++ b/tests/tests/graphics/res/drawable-nodpi/alpha_mask.png
Binary files differ
diff --git a/tests/tests/graphics/src/android/graphics/cts/BitmapColorSpaceTest.java b/tests/tests/graphics/src/android/graphics/cts/BitmapColorSpaceTest.java
index 194f36c..5012e1c 100644
--- a/tests/tests/graphics/src/android/graphics/cts/BitmapColorSpaceTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/BitmapColorSpaceTest.java
@@ -26,6 +26,7 @@
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
+import android.util.Log;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -40,11 +41,14 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@SmallTest
@RunWith(AndroidJUnit4.class)
public class BitmapColorSpaceTest {
+ private static final String LOG_TAG = "BitmapColorSpaceTest";
+
private Resources mResources;
@Before
@@ -52,12 +56,92 @@
mResources = InstrumentationRegistry.getTargetContext().getResources();
}
+ @SuppressWarnings("deprecation")
+ @Test
+ public void createWithColorSpace() {
+ Bitmap b;
+ ColorSpace cs;
+
+ // We don't test HARDWARE configs because they are not compatible with mutable bitmaps
+
+ b = Bitmap.createBitmap(32, 32, Bitmap.Config.ARGB_8888, true, null);
+ cs = b.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.SRGB), cs);
+
+ b = Bitmap.createBitmap(32, 32, Bitmap.Config.ARGB_8888, true,
+ ColorSpace.get(ColorSpace.Named.ADOBE_RGB));
+ cs = b.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.ADOBE_RGB), cs);
+
+ b = Bitmap.createBitmap(32, 32, Bitmap.Config.RGBA_F16, true, null);
+ cs = b.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.LINEAR_EXTENDED_SRGB), cs);
+
+ b = Bitmap.createBitmap(32, 32, Bitmap.Config.RGBA_F16, true,
+ ColorSpace.get(ColorSpace.Named.ADOBE_RGB));
+ cs = b.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.LINEAR_EXTENDED_SRGB), cs);
+
+ b = Bitmap.createBitmap(32, 32, Bitmap.Config.RGB_565, true, null);
+ cs = b.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.SRGB), cs);
+
+ b = Bitmap.createBitmap(32, 32, Bitmap.Config.RGB_565, true,
+ ColorSpace.get(ColorSpace.Named.ADOBE_RGB));
+ cs = b.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.SRGB), cs);
+
+ b = Bitmap.createBitmap(32, 32, Bitmap.Config.ALPHA_8, true, null);
+ cs = b.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.SRGB), cs);
+
+ b = Bitmap.createBitmap(32, 32, Bitmap.Config.ALPHA_8, true,
+ ColorSpace.get(ColorSpace.Named.ADOBE_RGB));
+ cs = b.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.SRGB), cs);
+
+ b = Bitmap.createBitmap(32, 32, Bitmap.Config.ARGB_4444, true, null);
+ cs = b.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.SRGB), cs);
+
+ b = Bitmap.createBitmap(32, 32, Bitmap.Config.ARGB_4444, true,
+ ColorSpace.get(ColorSpace.Named.ADOBE_RGB));
+ cs = b.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.SRGB), cs);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void createWithNonRgbColorSpace() {
+ Bitmap.createBitmap(32, 32, Bitmap.Config.ARGB_8888, true,
+ ColorSpace.get(ColorSpace.Named.CIE_LAB));
+ }
+
@Test
public void sRGB() {
Bitmap b = BitmapFactory.decodeResource(mResources, R.drawable.robot);
ColorSpace cs = b.getColorSpace();
assertNotNull(cs);
assertSame(ColorSpace.get(ColorSpace.Named.SRGB), cs);
+
+ b = Bitmap.createBitmap(b, 0, 0, b.getWidth() / 2, b.getHeight() / 2);
+ cs = b.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.SRGB), cs);
+
+ b = Bitmap.createScaledBitmap(b, b.getWidth() / 2, b.getHeight() / 2, true);
+ cs = b.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.SRGB), cs);
}
@Test
@@ -67,6 +151,16 @@
ColorSpace cs = b.getColorSpace();
assertNotNull(cs);
assertSame(ColorSpace.get(ColorSpace.Named.DISPLAY_P3), cs);
+
+ b = Bitmap.createBitmap(b, 0, 0, b.getWidth() / 2, b.getHeight() / 2);
+ cs = b.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.DISPLAY_P3), cs);
+
+ b = Bitmap.createScaledBitmap(b, b.getWidth() / 2, b.getHeight() / 2, true);
+ cs = b.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.DISPLAY_P3), cs);
} catch (IOException e) {
fail();
}
@@ -79,6 +173,16 @@
ColorSpace cs = b.getColorSpace();
assertNotNull(cs);
assertSame(ColorSpace.get(ColorSpace.Named.LINEAR_EXTENDED_SRGB), cs);
+
+ b = Bitmap.createBitmap(b, 0, 0, b.getWidth() / 2, b.getHeight() / 2);
+ cs = b.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.LINEAR_EXTENDED_SRGB), cs);
+
+ b = Bitmap.createScaledBitmap(b, b.getWidth() / 2, b.getHeight() / 2, true);
+ cs = b.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.LINEAR_EXTENDED_SRGB), cs);
} catch (IOException e) {
fail();
}
@@ -139,7 +243,7 @@
@Test
public void getPixel() {
- verifyGetPixel("green-p3.png", 0x75fb4cff, 0xff03ff00);
+ verifyGetPixel("green-p3.png", 0x75fb4cff, 0xff00ff00);
verifyGetPixel("translucent-green-p3.png", 0x3a7d267f, 0x7f00ff00); // 50% translucent
}
@@ -151,22 +255,34 @@
assertNotNull(cs);
assertSame(ColorSpace.get(ColorSpace.Named.DISPLAY_P3), cs);
- ByteBuffer dst = ByteBuffer.allocate(b.getByteCount());
- b.copyPixelsToBuffer(dst);
- dst.rewind();
- // Stored as RGBA
- assertEquals(rawColor, dst.asIntBuffer().get());
+ verifyGetPixel(b, rawColor, srgbColor);
- int srgb = b.getPixel(31, 31);
- assertEquals(srgbColor, srgb);
+ b = Bitmap.createBitmap(b, 0, 0, b.getWidth() / 2, b.getHeight() / 2);
+ verifyGetPixel(b, rawColor, srgbColor);
+
+ b = Bitmap.createScaledBitmap(b, b.getWidth() / 2, b.getHeight() / 2, true);
+ verifyGetPixel(b, rawColor, srgbColor);
} catch (IOException e) {
fail();
}
}
+ private static void verifyGetPixel(@NonNull Bitmap b,
+ @ColorInt int rawColor, @ColorInt int srgbColor) {
+ ByteBuffer dst = ByteBuffer.allocate(b.getByteCount());
+ b.copyPixelsToBuffer(dst);
+ dst.rewind();
+
+ // Stored as RGBA
+ assertEquals(rawColor, dst.asIntBuffer().get());
+
+ int srgb = b.getPixel(15, 15);
+ almostEqual(srgbColor, srgb, 3, 15 * b.getWidth() + 15);
+ }
+
@Test
public void getPixels() {
- verifyGetPixels("green-p3.png", 0xff03ff00);
+ verifyGetPixels("green-p3.png", 0xff00ff00);
verifyGetPixels("translucent-green-p3.png", 0x7f00ff00); // 50% translucent
}
@@ -177,16 +293,28 @@
assertNotNull(cs);
assertSame(ColorSpace.get(ColorSpace.Named.DISPLAY_P3), cs);
- int[] pixels = new int[b.getWidth() * b.getHeight()];
- b.getPixels(pixels, 0, b.getWidth(), 0, 0, b.getWidth(), b.getHeight());
- for (int pixel : pixels) {
- assertEquals(expected, pixel);
- }
+ verifyGetPixels(b, expected);
+
+ b = Bitmap.createBitmap(b, 0, 0, b.getWidth() / 2, b.getHeight() / 2);
+ verifyGetPixels(b, expected);
+
+ b = Bitmap.createScaledBitmap(b, b.getWidth() / 2, b.getHeight() / 2, true);
+ verifyGetPixels(b, expected);
} catch (IOException e) {
fail();
}
}
+ private static void verifyGetPixels(@NonNull Bitmap b, @ColorInt int expected) {
+ int[] pixels = new int[b.getWidth() * b.getHeight()];
+ b.getPixels(pixels, 0, b.getWidth(), 0, 0, b.getWidth(), b.getHeight());
+
+ for (int i = 0; i < pixels.length; i++) {
+ int pixel = pixels[i];
+ almostEqual(expected, pixel, 3, i);
+ }
+ }
+
@Test
public void setPixel() {
verifySetPixel("green-p3.png", 0xffff0000, 0xea3323ff);
@@ -204,18 +332,29 @@
assertNotNull(cs);
assertSame(ColorSpace.get(ColorSpace.Named.DISPLAY_P3), cs);
- b.setPixel(0, 0, newColor);
+ verifySetPixel(b, newColor, expectedColor);
- ByteBuffer dst = ByteBuffer.allocate(b.getByteCount());
- b.copyPixelsToBuffer(dst);
- dst.rewind();
- // Stored as RGBA
- assertEquals(expectedColor, dst.asIntBuffer().get());
+ b = Bitmap.createBitmap(b, 0, 0, b.getWidth() / 2, b.getHeight() / 2);
+ verifySetPixel(b, newColor, expectedColor);
+
+ b = Bitmap.createScaledBitmap(b, b.getWidth() / 2, b.getHeight() / 2, true);
+ verifySetPixel(b, newColor, expectedColor);
} catch (IOException e) {
fail();
}
}
+ private static void verifySetPixel(@NonNull Bitmap b,
+ @ColorInt int newColor, @ColorInt int expectedColor) {
+ b.setPixel(0, 0, newColor);
+
+ ByteBuffer dst = ByteBuffer.allocate(b.getByteCount());
+ b.copyPixelsToBuffer(dst);
+ dst.rewind();
+ // Stored as RGBA
+ assertEquals(expectedColor, dst.asIntBuffer().get());
+ }
+
@Test
public void setPixels() {
verifySetPixels("green-p3.png", 0xffff0000, 0xea3323ff);
@@ -233,25 +372,36 @@
assertNotNull(cs);
assertSame(ColorSpace.get(ColorSpace.Named.DISPLAY_P3), cs);
- int[] pixels = new int[b.getWidth() * b.getHeight()];
- Arrays.fill(pixels, newColor);
- b.setPixels(pixels, 0, b.getWidth(), 0, 0, b.getWidth(), b.getHeight());
+ verifySetPixels(b, newColor, expectedColor);
- ByteBuffer dst = ByteBuffer.allocate(b.getByteCount());
- b.copyPixelsToBuffer(dst);
- dst.rewind();
+ b = Bitmap.createBitmap(b, 0, 0, b.getWidth() / 2, b.getHeight() / 2);
+ verifySetPixels(b, newColor, expectedColor);
- IntBuffer buffer = dst.asIntBuffer();
- //noinspection ForLoopReplaceableByForEach
- for (int i = 0; i < pixels.length; i++) {
- // Stored as RGBA
- assertEquals(expectedColor, buffer.get());
- }
+ b = Bitmap.createScaledBitmap(b, b.getWidth() / 2, b.getHeight() / 2, true);
+ verifySetPixels(b, newColor, expectedColor);
} catch (IOException e) {
fail();
}
}
+ private static void verifySetPixels(@NonNull Bitmap b,
+ @ColorInt int newColor, @ColorInt int expectedColor) {
+ int[] pixels = new int[b.getWidth() * b.getHeight()];
+ Arrays.fill(pixels, newColor);
+ b.setPixels(pixels, 0, b.getWidth(), 0, 0, b.getWidth(), b.getHeight());
+
+ ByteBuffer dst = ByteBuffer.allocate(b.getByteCount());
+ b.copyPixelsToBuffer(dst);
+ dst.rewind();
+
+ IntBuffer buffer = dst.asIntBuffer();
+ //noinspection ForLoopReplaceableByForEach
+ for (int i = 0; i < pixels.length; i++) {
+ // Stored as RGBA
+ assertEquals(expectedColor, buffer.get());
+ }
+ }
+
@Test
public void writeColorSpace() {
verifyColorSpaceMarshalling("green-srgb.png", ColorSpace.get(ColorSpace.Named.SRGB));
@@ -400,4 +550,65 @@
fail();
}
}
+
+ @Test
+ public void copy() {
+ Bitmap b = BitmapFactory.decodeResource(mResources, R.drawable.robot);
+ Bitmap c = b.copy(Bitmap.Config.ARGB_8888, false);
+ ColorSpace cs = c.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.SRGB), cs);
+
+ c = b.copy(Bitmap.Config.ARGB_8888, true);
+ cs = c.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.SRGB), cs);
+
+ try (InputStream in = mResources.getAssets().open("green-p3.png")) {
+ b = BitmapFactory.decodeStream(in);
+ c = b.copy(Bitmap.Config.ARGB_8888, false);
+ cs = c.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.DISPLAY_P3), cs);
+
+ c = b.copy(Bitmap.Config.ARGB_8888, true);
+ cs = c.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.DISPLAY_P3), cs);
+ } catch (IOException e) {
+ fail();
+ }
+
+ try (InputStream in = mResources.getAssets().open("prophoto-rgba16f.png")) {
+ b = BitmapFactory.decodeStream(in);
+ c = b.copy(Bitmap.Config.RGBA_F16, false);
+ cs = c.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.LINEAR_EXTENDED_SRGB), cs);
+
+ c = b.copy(Bitmap.Config.RGBA_F16, true);
+ cs = c.getColorSpace();
+ assertNotNull(cs);
+ assertSame(ColorSpace.get(ColorSpace.Named.LINEAR_EXTENDED_SRGB), cs);
+ } catch (IOException e) {
+ fail();
+ }
+ }
+
+ @SuppressWarnings("SameParameterValue")
+ private static void almostEqual(@ColorInt int expected,
+ @ColorInt int pixel, int threshold, int index) {
+ int diffA = Math.abs(expected >>> 24 - pixel >>> 24);
+ int diffR = Math.abs((expected >> 16) & 0xff - (pixel >> 16) & 0xff);
+ int diffG = Math.abs((expected >> 8) & 0xff - (pixel >> 8) & 0xff);
+ int diffB = Math.abs((expected ) & 0xff - (pixel ) & 0xff);
+
+ boolean pass = diffA + diffR + diffG + diffB < threshold;
+ if (!pass) {
+ Log.d(LOG_TAG, "Expected 0x" + Integer.toHexString(expected) +
+ " but was 0x" + Integer.toHexString(pixel) + " with index " + index);
+ }
+
+ assertTrue(pass);
+ }
}
diff --git a/tests/tests/graphics/src/android/graphics/cts/BitmapRGBAF16Test.java b/tests/tests/graphics/src/android/graphics/cts/BitmapRGBAF16Test.java
index 114a385..02c9425 100644
--- a/tests/tests/graphics/src/android/graphics/cts/BitmapRGBAF16Test.java
+++ b/tests/tests/graphics/src/android/graphics/cts/BitmapRGBAF16Test.java
@@ -15,38 +15,41 @@
*/
package android.graphics.cts;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.Bitmap.Config;
-import android.graphics.BitmapFactory;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
-import org.junit.Before;
-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.assertNotNull;
import static org.junit.Assert.assertTrue;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.Bitmap.Config;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
@SmallTest
@RunWith(AndroidJUnit4.class)
public class BitmapRGBAF16Test {
private Bitmap mOpaqueBitmap;
private Bitmap mTransparentBitmap;
+ private Resources mResources;
@Before
public void setup() {
- Resources resources = InstrumentationRegistry.getTargetContext().getResources();
+ mResources = InstrumentationRegistry.getTargetContext().getResources();
BitmapFactory.Options options = new BitmapFactory.Options();
options.inMutable = true;
// The bitmaps are in raw-nodpi/ to guarantee aapt and framework leave them untouched
- mOpaqueBitmap = BitmapFactory.decodeResource(resources, R.raw.p3_opaque, options);
- mTransparentBitmap = BitmapFactory.decodeResource(resources, R.raw.p3_transparent, options);
+ mOpaqueBitmap = BitmapFactory.decodeResource(mResources, R.raw.p3_opaque, options);
+ mTransparentBitmap = BitmapFactory.decodeResource(mResources, R.raw.p3_transparent, options);
}
@Test
@@ -133,4 +136,16 @@
assertTrue(before != after);
assertEquals(0x7f102030, after);
}
+
+ @Test
+ public void testCopyFromA8() {
+ Bitmap res = BitmapFactory.decodeResource(mResources, R.drawable.alpha_mask);
+ Bitmap mask = Bitmap.createBitmap(res.getWidth(), res.getHeight(),
+ Bitmap.Config.ALPHA_8);
+ Canvas c = new Canvas(mask);
+ c.drawBitmap(res, 0, 0, null);
+
+ Bitmap b = mask.copy(Config.RGBA_F16, false);
+ assertNotNull(b);
+ }
}
diff --git a/tests/tests/permission/src/android/permission/cts/TelephonyManagerPermissionTest.java b/tests/tests/permission/src/android/permission/cts/TelephonyManagerPermissionTest.java
index 54c2371..0197f5d 100644
--- a/tests/tests/permission/src/android/permission/cts/TelephonyManagerPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/TelephonyManagerPermissionTest.java
@@ -242,7 +242,11 @@
getContext().sendBroadcast(intent);
fail("SecurityException expected!");
} catch (SecurityException e) {}
-
+ try {
+ Intent intent = new Intent("android.provider.Telephony.SECRET_CODE");
+ getContext().sendBroadcast(intent);
+ fail("SecurityException expected!");
+ } catch (SecurityException e) {}
}
/**
diff --git a/tests/tests/text/src/android/text/method/cts/DateKeyListenerTest.java b/tests/tests/text/src/android/text/method/cts/DateKeyListenerTest.java
index d8342ca..16f632c 100644
--- a/tests/tests/text/src/android/text/method/cts/DateKeyListenerTest.java
+++ b/tests/tests/text/src/android/text/method/cts/DateKeyListenerTest.java
@@ -111,16 +111,26 @@
@Test
public void testGetInputType() {
- final int expected = InputType.TYPE_CLASS_DATETIME | InputType.TYPE_DATETIME_VARIATION_DATE;
+ // The "normal" input type that has been used consistently until Android O.
+ final int dateTimeType = InputType.TYPE_CLASS_DATETIME
+ | InputType.TYPE_DATETIME_VARIATION_DATE;
+ // Fallback for locales that need more characters.
+ final int textType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL;
+ // Deprecated constructor that needs to preserve pre-existing behavior.
DateKeyListener dateKeyListener = new DateKeyListener();
- assertEquals(expected, dateKeyListener.getInputType());
+ assertEquals(dateTimeType, dateKeyListener.getInputType());
+ // TYPE_CLASS_DATETIME is fine for English locales.
dateKeyListener = new DateKeyListener(Locale.US);
- assertEquals(expected, dateKeyListener.getInputType());
+ assertEquals(dateTimeType, dateKeyListener.getInputType());
+ dateKeyListener = new DateKeyListener(Locale.UK);
+ assertEquals(dateTimeType, dateKeyListener.getInputType());
+ // Persian needs more characters then typically provided by datetime inputs, so it falls
+ // back on normal text.
dateKeyListener = new DateKeyListener(Locale.forLanguageTag("fa-IR"));
- assertEquals(expected, dateKeyListener.getInputType());
+ assertEquals(textType, dateKeyListener.getInputType());
}
/*
diff --git a/tests/tests/text/src/android/text/method/cts/DateTimeKeyListenerTest.java b/tests/tests/text/src/android/text/method/cts/DateTimeKeyListenerTest.java
index 06bb68c..decd451 100644
--- a/tests/tests/text/src/android/text/method/cts/DateTimeKeyListenerTest.java
+++ b/tests/tests/text/src/android/text/method/cts/DateTimeKeyListenerTest.java
@@ -114,17 +114,26 @@
@Test
public void testGetInputType() {
- final int expected = InputType.TYPE_CLASS_DATETIME
+ // The "normal" input type that has been used consistently until Android O.
+ final int dateTimeType = InputType.TYPE_CLASS_DATETIME
| InputType.TYPE_DATETIME_VARIATION_NORMAL;
+ // Fallback for locales that need more characters.
+ final int textType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL;
+ // Deprecated constructor that needs to preserve pre-existing behavior.
DateTimeKeyListener listener = DateTimeKeyListener.getInstance();
- assertEquals(expected, listener.getInputType());
+ assertEquals(dateTimeType, listener.getInputType());
+ // TYPE_CLASS_DATETIME is fine for English locales.
listener = DateTimeKeyListener.getInstance(Locale.US);
- assertEquals(expected, listener.getInputType());
+ assertEquals(dateTimeType, listener.getInputType());
+ listener = DateTimeKeyListener.getInstance(Locale.UK);
+ assertEquals(dateTimeType, listener.getInputType());
+ // Persian needs more characters then typically provided by datetime inputs, so it falls
+ // back on normal text.
listener = DateTimeKeyListener.getInstance(Locale.forLanguageTag("fa-IR"));
- assertEquals(expected, listener.getInputType());
+ assertEquals(textType, listener.getInputType());
}
/*
diff --git a/tests/tests/text/src/android/text/method/cts/DigitsKeyListenerTest.java b/tests/tests/text/src/android/text/method/cts/DigitsKeyListenerTest.java
index 510d329..7854268 100644
--- a/tests/tests/text/src/android/text/method/cts/DigitsKeyListenerTest.java
+++ b/tests/tests/text/src/android/text/method/cts/DigitsKeyListenerTest.java
@@ -899,8 +899,9 @@
assertEquals(-1, acceptedChars.indexOf(usDecimalSeparator));
}
+ // Deprecated constructors that need to preserve pre-existing behavior.
@Test
- public void testGetInputType1() {
+ public void testGetInputType_deprecatedConstructors() {
DigitsKeyListener digitsKeyListener = DigitsKeyListener.getInstance(false, false);
int expected = InputType.TYPE_CLASS_NUMBER;
assertEquals(expected, digitsKeyListener.getInputType());
@@ -922,27 +923,57 @@
assertEquals(expected, digitsKeyListener.getInputType());
}
+ // Deprecated constructors that need to preserve pre-existing behavior.
@Test
- public void testGetInputType2() {
- final Locale irLocale = Locale.forLanguageTag("fa-IR");
- DigitsKeyListener digitsKeyListener = DigitsKeyListener.getInstance(irLocale, false, false);
+ public void testGetInputType_English() {
int expected = InputType.TYPE_CLASS_NUMBER;
+ DigitsKeyListener digitsKeyListener = DigitsKeyListener.getInstance(
+ Locale.US, false, false);
+ assertEquals(expected, digitsKeyListener.getInputType());
+ digitsKeyListener = DigitsKeyListener.getInstance(
+ Locale.UK, false, false);
assertEquals(expected, digitsKeyListener.getInputType());
- digitsKeyListener = DigitsKeyListener.getInstance(irLocale, true, false);
expected = InputType.TYPE_CLASS_NUMBER
| InputType.TYPE_NUMBER_FLAG_SIGNED;
+ digitsKeyListener = DigitsKeyListener.getInstance(Locale.US, true, false);
+ assertEquals(expected, digitsKeyListener.getInputType());
+ digitsKeyListener = DigitsKeyListener.getInstance(Locale.UK, true, false);
assertEquals(expected, digitsKeyListener.getInputType());
- digitsKeyListener = DigitsKeyListener.getInstance(irLocale, false, true);
expected = InputType.TYPE_CLASS_NUMBER
| InputType.TYPE_NUMBER_FLAG_DECIMAL;
+ digitsKeyListener = DigitsKeyListener.getInstance(Locale.US, false, true);
+ assertEquals(expected, digitsKeyListener.getInputType());
+ digitsKeyListener = DigitsKeyListener.getInstance(Locale.UK, false, true);
assertEquals(expected, digitsKeyListener.getInputType());
- digitsKeyListener = DigitsKeyListener.getInstance(irLocale, true, true);
expected = InputType.TYPE_CLASS_NUMBER
| InputType.TYPE_NUMBER_FLAG_SIGNED
| InputType.TYPE_NUMBER_FLAG_DECIMAL;
+ digitsKeyListener = DigitsKeyListener.getInstance(Locale.US, true, true);
+ assertEquals(expected, digitsKeyListener.getInputType());
+ digitsKeyListener = DigitsKeyListener.getInstance(Locale.UK, true, true);
+ assertEquals(expected, digitsKeyListener.getInputType());
+ }
+
+ // Persian needs more characters then typically provided by datetime inputs, so it falls
+ // back on normal text.
+ @Test
+ public void testGetInputType_Persian() {
+ final Locale irLocale = Locale.forLanguageTag("fa-IR");
+ final int expected = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL;
+
+ DigitsKeyListener digitsKeyListener = DigitsKeyListener.getInstance(irLocale, false, false);
+ assertEquals(expected, digitsKeyListener.getInputType());
+
+ digitsKeyListener = DigitsKeyListener.getInstance(irLocale, true, false);
+ assertEquals(expected, digitsKeyListener.getInputType());
+
+ digitsKeyListener = DigitsKeyListener.getInstance(irLocale, false, true);
+ assertEquals(expected, digitsKeyListener.getInputType());
+
+ digitsKeyListener = DigitsKeyListener.getInstance(irLocale, true, true);
assertEquals(expected, digitsKeyListener.getInputType());
}
diff --git a/tests/tests/text/src/android/text/method/cts/TimeKeyListenerTest.java b/tests/tests/text/src/android/text/method/cts/TimeKeyListenerTest.java
index 68d410d..a887a19 100644
--- a/tests/tests/text/src/android/text/method/cts/TimeKeyListenerTest.java
+++ b/tests/tests/text/src/android/text/method/cts/TimeKeyListenerTest.java
@@ -110,17 +110,26 @@
@Test
public void testGetInputType() {
- final int expected = InputType.TYPE_CLASS_DATETIME
+ // The "normal" input type that has been used consistently until Android O.
+ final int dateTimeType = InputType.TYPE_CLASS_DATETIME
| InputType.TYPE_DATETIME_VARIATION_TIME;
+ // Fallback for locales that need more characters.
+ final int textType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL;
+ // Deprecated constructor that needs to preserve pre-existing behavior.
TimeKeyListener listener = TimeKeyListener.getInstance();
- assertEquals(expected, listener.getInputType());
+ assertEquals(dateTimeType, listener.getInputType());
+ // TYPE_CLASS_DATETIME is fine for English locales.
listener = TimeKeyListener.getInstance(Locale.US);
- assertEquals(expected, listener.getInputType());
+ assertEquals(dateTimeType, listener.getInputType());
+ listener = TimeKeyListener.getInstance(Locale.UK);
+ assertEquals(dateTimeType, listener.getInputType());
+ // Persian needs more characters then typically provided by datetime inputs, so it falls
+ // back on normal text.
listener = TimeKeyListener.getInstance(Locale.forLanguageTag("fa-IR"));
- assertEquals(expected, listener.getInputType());
+ assertEquals(textType, listener.getInputType());
}
/*
diff --git a/tests/tests/widget/src/android/widget/cts/ListPopupWindowTest.java b/tests/tests/widget/src/android/widget/cts/ListPopupWindowTest.java
index 334a1f6..70f9661 100644
--- a/tests/tests/widget/src/android/widget/cts/ListPopupWindowTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ListPopupWindowTest.java
@@ -504,7 +504,7 @@
mInstrumentation.waitForIdleSync();
verify(mPopupWindowBuilder.mOnItemClickListener, times(1)).onItemClick(
- any(AdapterView.class), any(View.class), eq(1), eq(1L));
+ any(AdapterView.class), any(), eq(1), eq(1L));
// Also verify that the popup window has been dismissed
assertFalse(mPopupWindow.isShowing());
verify(mPopupWindowBuilder.mOnDismissListener, times(2)).onDismiss();
diff --git a/tests/tests/widget/src/android/widget/cts/TextViewTest.java b/tests/tests/widget/src/android/widget/cts/TextViewTest.java
index 86f9877..968b6e3 100644
--- a/tests/tests/widget/src/android/widget/cts/TextViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TextViewTest.java
@@ -114,7 +114,6 @@
import android.util.TypedValue;
import android.view.ActionMode;
import android.view.ContextMenu;
-import android.view.ContextMenu.ContextMenuInfo;
import android.view.Gravity;
import android.view.InputDevice;
import android.view.KeyEvent;
@@ -3038,7 +3037,7 @@
((ContextMenu) invocation.getArguments() [0]).add("menu item");
return null;
}).when(mockOnCreateContextMenuListener).onCreateContextMenu(
- any(ContextMenu.class), any(View.class), any(ContextMenuInfo.class));
+ any(ContextMenu.class), any(View.class), any());
mTextView.setOnLongClickListener(mockOnLongClickListener);
mTextView.setOnCreateContextMenuListener(mockOnCreateContextMenuListener);
@@ -3051,16 +3050,16 @@
assertTrue(mTextView.performLongClick());
verify(mockOnLongClickListener, times(1)).onLongClick(mTextView);
verify(mockOnCreateContextMenuListener, times(1)).onCreateContextMenu(
- any(ContextMenu.class), eq(mTextView), any(ContextMenuInfo.class));
+ any(ContextMenu.class), eq(mTextView), any());
reset(mockOnCreateContextMenuListener);
mTextView.setOnLongClickListener(null);
doNothing().when(mockOnCreateContextMenuListener).onCreateContextMenu(
- any(ContextMenu.class), any(View.class), any(ContextMenuInfo.class));
+ any(ContextMenu.class), any(View.class), any());
assertFalse(mTextView.performLongClick());
verifyNoMoreInteractions(mockOnLongClickListener);
verify(mockOnCreateContextMenuListener, times(1)).onCreateContextMenu(
- any(ContextMenu.class), eq(mTextView), any(ContextMenuInfo.class));
+ any(ContextMenu.class), eq(mTextView), any());
}
@UiThreadTest
diff --git a/tools/selinux/SELinuxNeverallowTestGen.py b/tools/selinux/SELinuxNeverallowTestGen.py
index ec29e45..e74ba78 100755
--- a/tools/selinux/SELinuxNeverallowTestGen.py
+++ b/tools/selinux/SELinuxNeverallowTestGen.py
@@ -79,7 +79,7 @@
# check usage
if len(sys.argv) != 3:
print usage
- exit()
+ exit(1)
input_file = sys.argv[1]
output_file = sys.argv[2]