Merge "Test onHandleScreenshot for approximate pixel equality to expected view." into mnc-dev
diff --git a/CtsTestCaseList.mk b/CtsTestCaseList.mk
index cf7da2f..41f9dc3 100644
--- a/CtsTestCaseList.mk
+++ b/CtsTestCaseList.mk
@@ -100,6 +100,7 @@
CtsManagedProfileApp \
CtsMonkeyApp \
CtsMonkeyApp2 \
+ CtsPackageInstallerApp \
CtsPermissionApp \
CtsSimpleApp \
CtsSimplePreMApp \
diff --git a/apps/CameraITS/tests/scene1/test_raw_burst_sensitivity.py b/apps/CameraITS/tests/scene1/test_raw_burst_sensitivity.py
index 6c2b5c1..e176312 100644
--- a/apps/CameraITS/tests/scene1/test_raw_burst_sensitivity.py
+++ b/apps/CameraITS/tests/scene1/test_raw_burst_sensitivity.py
@@ -44,6 +44,8 @@
# Expose for the scene with min sensitivity
sens_min, sens_max = props['android.sensor.info.sensitivityRange']
+ # Digital gains might not be visible on RAW data
+ sens_max = props['android.sensor.maxAnalogSensitivity']
sens_step = (sens_max - sens_min) / NUM_STEPS
s_ae,e_ae,_,_,_ = cam.do_3a(get_results=True)
s_e_prod = s_ae * e_ae
diff --git a/apps/CameraITS/tests/scene1/test_raw_sensitivity.py b/apps/CameraITS/tests/scene1/test_raw_sensitivity.py
index 14c5eb0..cc0ce14 100644
--- a/apps/CameraITS/tests/scene1/test_raw_sensitivity.py
+++ b/apps/CameraITS/tests/scene1/test_raw_sensitivity.py
@@ -42,6 +42,8 @@
# Expose for the scene with min sensitivity
sens_min, sens_max = props['android.sensor.info.sensitivityRange']
+ # Digital gains might not be visible on RAW data
+ sens_max = props['android.sensor.maxAnalogSensitivity']
sens_step = (sens_max - sens_min) / NUM_STEPS
s_ae,e_ae,_,_,_ = cam.do_3a(get_results=True)
s_e_prod = s_ae * e_ae
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 5c188b7..d0d5ff0 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -363,6 +363,7 @@
<meta-data android:name="test_category" android:value="@string/test_category_security" />
<meta-data android:name="test_excluded_features"
android:value="android.hardware.type.television:android.software.leanback:android.hardware.type.watch" />
+ <meta-data android:name="test_required_features" android:value="android.hardware.fingerprint" />
</activity>
<activity android:name=".security.ScreenLockBoundKeysTest"
android:label="@string/sec_lock_bound_key_test"
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RVCVCameraPreview.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RVCVCameraPreview.java
index a5b58f6..fa89b71 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RVCVCameraPreview.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RVCVCameraPreview.java
@@ -23,9 +23,9 @@
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
+import android.view.ViewGroup;
import java.io.IOException;
-import java.util.List;
/** Camera preview class */
public class RVCVCameraPreview extends SurfaceView implements SurfaceHolder.Callback {
@@ -34,15 +34,16 @@
private SurfaceHolder mHolder;
private Camera mCamera;
+ private float mAspect;
+ private int mRotation;
/**
* Constructor
* @param context Activity context
- * @param camera Camera object to be previewed
*/
- public RVCVCameraPreview(Context context, Camera camera) {
+ public RVCVCameraPreview(Context context) {
super(context);
- mCamera = camera;
+ mCamera = null;
initSurface();
}
@@ -55,8 +56,10 @@
super(context, attrs);
}
- public void init(Camera camera) {
+ public void init(Camera camera, float aspectRatio, int rotation) {
this.mCamera = camera;
+ mAspect = aspectRatio;
+ mRotation = rotation;
initSurface();
}
@@ -86,6 +89,20 @@
try {
mCamera.setPreviewDisplay(holder);
mCamera.startPreview();
+ int v_height = getHeight();
+ int v_width = getWidth();
+ ViewGroup.LayoutParams layout = getLayoutParams();
+ if ( (float)v_height/v_width >
+ mAspect) {
+ layout.height = (int)(v_width * mAspect);
+ layout.width = v_width;
+ }else {
+ layout.width = (int)(v_height / mAspect);
+ layout.height = v_height;
+ }
+ Log.d(TAG, String.format("Layout (%d, %d) -> (%d, %d)", v_width, v_height,
+ layout.width, layout.height));
+ setLayoutParams(layout);
} catch (IOException e) {
if (LOCAL_LOGD) Log.d(TAG, "Error when starting camera preview: " + e.getMessage());
}
@@ -111,8 +128,7 @@
// stop preview before making changes
mCamera.stopPreview();
- // the activity using this view is locked to this orientation, so hard code is fine
- mCamera.setDisplayOrientation(90);
+ mCamera.setDisplayOrientation(mRotation);
//do the same as if it is created again
surfaceCreated(holder);
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RVCVRecordActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RVCVRecordActivity.java
index f90b27c..be5ec52 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RVCVRecordActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RVCVRecordActivity.java
@@ -46,6 +46,7 @@
import java.io.OutputStreamWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.List;
// ----------------------------------------------------------------------
@@ -67,7 +68,7 @@
private VideoRecorder mVideoRecorder;
private RVSensorLogger mRVSensorLogger;
private CoverageManager mCoverManager;
- private CameraPreviewer mPreviewer;
+ private CameraContext mCameraContext;
public static final int AXIS_NONE = 0;
public static final int AXIS_ALL = SensorManager.AXIS_X +
@@ -99,7 +100,7 @@
super.onPause();
mController.quit();
- mPreviewer.end();
+ mCameraContext.end();
endSoundPool();
}
@@ -128,8 +129,8 @@
*
*/
private void init() {
- mPreviewer = new CameraPreviewer();
- mPreviewer.init();
+ mCameraContext = new CameraContext();
+ mCameraContext.init();
mCoverManager = new CoverageManager();
mIndicatorView.setDataProvider(
@@ -140,7 +141,7 @@
initSoundPool();
mRVSensorLogger = new RVSensorLogger(this);
- mVideoRecorder = new VideoRecorder(mPreviewer.getCamera());
+ mVideoRecorder = new VideoRecorder(mCameraContext.getCamera(), mCameraContext.getProfile());
if (LOG_RAW_SENSORS) {
mRawSensorLogger = new RawSensorLogger(mRecordDir);
@@ -173,7 +174,8 @@
// X and Y
final String axisName = "YXZ";
- message("Manipulate the device in " + axisName.charAt(axis-1) + " axis (as illustrated) about the pattern.");
+ message("Manipulate the device in " + axisName.charAt(axis - 1) +
+ " axis (as illustrated) about the pattern.");
}
/**
@@ -250,20 +252,28 @@
* Start the sensor recording
*/
public void startRecordSensor() {
- mRVSensorLogger.init();
- if (LOG_RAW_SENSORS) {
- mRawSensorLogger.init();
- }
+ runOnUiThread(new Runnable() {
+ public void run() {
+ mRVSensorLogger.init();
+ if (LOG_RAW_SENSORS) {
+ mRawSensorLogger.init();
+ }
+ }
+ });
}
/**
* Stop the sensor recording
*/
public void stopRecordSensor() {
- mRVSensorLogger.end();
- if (LOG_RAW_SENSORS) {
- mRawSensorLogger.end();
- }
+ runOnUiThread(new Runnable() {
+ public void run() {
+ mRVSensorLogger.end();
+ if (LOG_RAW_SENSORS) {
+ mRawSensorLogger.end();
+ }
+ }
+ });
}
/**
@@ -365,20 +375,93 @@
/**
* Camera preview control class
*/
- class CameraPreviewer {
+ class CameraContext {
private Camera mCamera;
+ private CamcorderProfile mProfile;
+ private Camera.CameraInfo mCameraInfo;
- CameraPreviewer() {
+ private int [] mPreferredProfiles = {
+ CamcorderProfile.QUALITY_480P, // smaller -> faster
+ CamcorderProfile.QUALITY_720P,
+ CamcorderProfile.QUALITY_1080P,
+ CamcorderProfile.QUALITY_HIGH // existence guaranteed
+ };
+
+ CameraContext() {
try {
- mCamera = Camera.open(); // attempt to get a default Camera instance
+ mCamera = Camera.open(); // attempt to get a default Camera instance (0)
+ mProfile = null;
+ if (mCamera != null) {
+ mCameraInfo = new Camera.CameraInfo();
+ Camera.getCameraInfo(0, mCameraInfo);
+ setupCamera();
+ }
}
- catch (Exception e) {
+ catch (Exception e){
// Camera is not available (in use or does not exist)
Log.e(TAG, "Cannot obtain Camera!");
}
}
/**
+ * Find a preferred camera profile and set preview and picture size property accordingly.
+ */
+ void setupCamera() {
+ CamcorderProfile profile = null;
+ Camera.Parameters param = mCamera.getParameters();
+ List<Camera.Size> pre_sz = param.getSupportedPreviewSizes();
+ List<Camera.Size> pic_sz = param.getSupportedPictureSizes();
+
+ for (int i : mPreferredProfiles) {
+ if (CamcorderProfile.hasProfile(i)) {
+ profile = CamcorderProfile.get(i);
+
+ int valid = 0;
+ for (Camera.Size j : pre_sz) {
+ if (j.width == profile.videoFrameWidth &&
+ j.height == profile.videoFrameHeight) {
+ ++valid;
+ break;
+ }
+ }
+ for (Camera.Size j : pic_sz) {
+ if (j.width == profile.videoFrameWidth &&
+ j.height == profile.videoFrameHeight) {
+ ++valid;
+ break;
+ }
+ }
+ if (valid == 2) {
+ param.setPreviewSize(profile.videoFrameWidth, profile.videoFrameHeight);
+ param.setPictureSize(profile.videoFrameWidth, profile.videoFrameHeight);
+ mCamera.setParameters(param);
+ break;
+ } else {
+ profile = null;
+ }
+ }
+ }
+ if (profile != null) {
+ float fovW = param.getHorizontalViewAngle();
+ float fovH = param.getVerticalViewAngle();
+ writeVideoMetaInfo(profile.videoFrameWidth, profile.videoFrameHeight,
+ profile.videoFrameRate, fovW, fovH);
+ } else {
+ Log.e(TAG, "Cannot find a proper video profile");
+ }
+ mProfile = profile;
+
+ }
+
+
+ /**
+ * Get sensor information of the camera being used
+ */
+ public Camera.CameraInfo getCameraInfo() {
+ return mCameraInfo;
+ }
+
+ /**
* Get the camera to be previewed
* @return Reference to Camera used
*/
@@ -387,12 +470,20 @@
}
/**
+ * Get the camera profile to be used
+ * @return Reference to Camera profile
+ */
+ public CamcorderProfile getProfile() {
+ return mProfile;
+ }
+
+ /**
* Setup the camera
*/
public void init() {
if (mCamera != null) {
double alpha = mCamera.getParameters().getHorizontalViewAngle()*Math.PI/180.0;
- int width = 1920;
+ int width = mProfile.videoFrameWidth;
double fx = width/2/Math.tan(alpha/2.0);
if (LOCAL_LOGV) Log.v(TAG, "View angle="
@@ -400,7 +491,9 @@
RVCVCameraPreview cameraPreview =
(RVCVCameraPreview) findViewById(R.id.cam_preview);
- cameraPreview.init(mCamera);
+ cameraPreview.init(mCamera,
+ (float)mProfile.videoFrameWidth/mProfile.videoFrameHeight,
+ mCameraInfo.orientation);
} else {
message("Cannot open camera!");
finish();
@@ -466,26 +559,22 @@
class VideoRecorder
{
private MediaRecorder mRecorder;
+ private CamcorderProfile mProfile;
private Camera mCamera;
private boolean mRunning = false;
- private int [] mPreferredProfiles = { CamcorderProfile.QUALITY_480P, // smaller -> faster
- CamcorderProfile.QUALITY_720P,
- CamcorderProfile.QUALITY_1080P,
- CamcorderProfile.QUALITY_HIGH // existence guaranteed
- };
-
-
- VideoRecorder(Camera camera) {
+ VideoRecorder(Camera camera, CamcorderProfile profile){
mCamera = camera;
+ mProfile = profile;
}
/**
* Initialize and start recording
*/
public void init() {
- float fovW = mCamera.getParameters().getHorizontalViewAngle();
- float fovH = mCamera.getParameters().getVerticalViewAngle();
+ if (mCamera == null || mProfile ==null){
+ return;
+ }
mRecorder = new MediaRecorder();
mCamera.unlock();
@@ -494,17 +583,7 @@
mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
- CamcorderProfile profile = null;
- for (int i: mPreferredProfiles) {
- if (CamcorderProfile.hasProfile(i)) {
- profile = CamcorderProfile.get(i);
- mRecorder.setProfile(profile);
- break;
- }
- }
-
- writeVideoMetaInfo(profile.videoFrameWidth, profile.videoFrameHeight,
- profile.videoFrameRate, fovW, fovH);
+ mRecorder.setProfile(mProfile);
try {
mRecorder.setOutputFile(getVideoRecFilePath());
@@ -689,8 +768,20 @@
*/
public void init() {
mSensorManager = (SensorManager)getSystemService(SENSOR_SERVICE);
+ if (mSensorManager == null) {
+ Log.e(TAG,"SensorManager is null!");
+ }
mRVSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR);
- mSensorManager.registerListener(this, mRVSensor, SENSOR_RATE);
+ if (mRVSensor != null) {
+ if (LOCAL_LOGV) Log.v(TAG, "Got RV Sensor");
+ }else {
+ Log.e(TAG, "Did not get RV sensor");
+ }
+ if(mSensorManager.registerListener(this, mRVSensor, SENSOR_RATE)) {
+ if (LOCAL_LOGV) Log.v(TAG,"Register listener successfull");
+ } else {
+ Log.e(TAG,"Register listener failed");
+ }
try {
mLogWriter= new OutputStreamWriter(
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RVCVXCheckAnalyzer.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RVCVXCheckAnalyzer.java
index 9afd1a9..3dc7270 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RVCVXCheckAnalyzer.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RVCVXCheckAnalyzer.java
@@ -15,12 +15,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
import android.media.MediaCodec;
import android.media.MediaExtractor;
import android.media.MediaFormat;
import android.os.Debug;
import android.os.Environment;
+import android.os.PowerManager;
import android.util.JsonWriter;
import android.util.Log;
@@ -777,14 +777,16 @@
VideoMetaInfo meta = new VideoMetaInfo(new File(mPath, "videometa.json"));
int decimation = 1;
+ boolean use_timestamp = true;
+ // roughly determine if decimation is necessary
if (meta.fps > DECIMATION_FPS_TARGET) {
decimation = (int)(meta.fps / DECIMATION_FPS_TARGET);
meta.fps /=decimation;
}
VideoDecoderForOpenCV videoDecoder = new VideoDecoderForOpenCV(
- new File(mPath, "video.mp4"), decimation); // every 3 frame process 1 frame
+ new File(mPath, "video.mp4"), decimation);
Mat frame;
@@ -820,12 +822,17 @@
}
long startTime = System.nanoTime();
+ long [] ts = new long[1];
- while ((frame = videoDecoder.getFrame()) !=null) {
+ while ((frame = videoDecoder.getFrame(ts)) !=null) {
if (LOCAL_LOGV) {
Log.v(TAG, "got a frame " + i);
}
+ if (use_timestamp && ts[0] == -1) {
+ use_timestamp = false;
+ }
+
// has to be in front, as there are cases where execution
// will skip the later part of this while
i++;
@@ -873,8 +880,16 @@
// if error is reasonable, add it into the results
if (error < REPROJECTION_THREASHOLD) {
double [] rv = new double[3];
+ double timestamp;
+
rvec.get(0,0, rv);
- recs.add(new AttitudeRec((double) i / meta.fps, rodr2rpy(rv)));
+ if (use_timestamp) {
+ timestamp = (double)ts[0] / 1e6;
+ } else {
+ timestamp = (double) i / meta.fps;
+ }
+ if (LOCAL_LOGV) Log.v(TAG, String.format("Added frame %d ts = %f", i, timestamp));
+ recs.add(new AttitudeRec(timestamp, rodr2rpy(rv)));
}
if (OUTPUT_DEBUG_IMAGE) {
@@ -906,6 +921,8 @@
* One issue right now is that the glReadPixels is quite slow .. around 6.5ms for a 720p frame
*/
private class VideoDecoderForOpenCV implements Runnable {
+ static final String TAG = "VideoDecoderForOpenCV";
+
private MediaExtractor extractor=null;
private MediaCodec decoder=null;
private CtsMediaOutputSurface surface=null;
@@ -1031,7 +1048,7 @@
}
if (decoder == null) {
- Log.e("VideoDecoderForOpenCV", "Can't find video info!");
+ Log.e(TAG, "Can't find video info!");
return;
}
valid = true;
@@ -1060,6 +1077,7 @@
long timeoutUs = 10000;
int iframe = 0;
+ long frameTimestamp = 0;
while (!Thread.interrupted()) {
if (!isEOS) {
@@ -1076,8 +1094,12 @@
MediaCodec.BUFFER_FLAG_END_OF_STREAM);
isEOS = true;
} else {
- decoder.queueInputBuffer(inIndex, 0, sampleSize,
- extractor.getSampleTime(), 0);
+ frameTimestamp = extractor.getSampleTime();
+ decoder.queueInputBuffer(inIndex, 0, sampleSize, frameTimestamp, 0);
+ if (LOCAL_LOGD) {
+ Log.d(TAG, String.format("Frame %d sample time %f s",
+ iframe, (double)frameTimestamp/1e6));
+ }
extractor.advance();
}
}
@@ -1088,19 +1110,19 @@
switch (outIndex) {
case MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED:
if (LOCAL_LOGD) {
- Log.d("VideoDecoderForOpenCV", "INFO_OUTPUT_BUFFERS_CHANGED");
+ Log.d(TAG, "INFO_OUTPUT_BUFFERS_CHANGED");
}
outputBuffers = decoder.getOutputBuffers();
break;
case MediaCodec.INFO_OUTPUT_FORMAT_CHANGED:
outFormat = decoder.getOutputFormat();
if (LOCAL_LOGD) {
- Log.d("VideoDecoderForOpenCV", "New format " + outFormat);
+ Log.d(TAG, "New format " + outFormat);
}
break;
case MediaCodec.INFO_TRY_AGAIN_LATER:
if (LOCAL_LOGD) {
- Log.d("VideoDecoderForOpenCV", "dequeueOutputBuffer timed out!");
+ Log.d(TAG, "dequeueOutputBuffer timed out!");
}
break;
default:
@@ -1118,12 +1140,12 @@
if (doRender) {
surface.awaitNewImage();
surface.drawImage();
- if (LOCAL_LOGD) {
- Log.d("VideoDecoderForOpenCV", "Finish drawing a frame!");
+ if (LOCAL_LOGV) {
+ Log.v(TAG, "Finish drawing a frame!");
}
if ((iframe++ % mDecimation) == 0) {
//Send the frame for processing
- mMatBuffer.put();
+ mMatBuffer.put(frameTimestamp);
}
}
break;
@@ -1149,8 +1171,8 @@
* Get next valid frame
* @return Frame in OpenCV mat
*/
- public Mat getFrame() {
- return mMatBuffer.get();
+ public Mat getFrame(long ts[]) {
+ return mMatBuffer.get(ts);
}
/**
@@ -1168,6 +1190,7 @@
private Mat mat;
private byte[] bytes;
private ByteBuffer buf;
+ private long timestamp;
private boolean full;
private int mWidth, mHeight;
@@ -1180,6 +1203,7 @@
mat = new Mat(height, width, CvType.CV_8UC4); //RGBA
buf = ByteBuffer.allocateDirect(width*height*4);
bytes = new byte[width*height*4];
+ timestamp = -1;
mValid = true;
full = false;
@@ -1190,7 +1214,7 @@
notifyAll();
}
- public synchronized Mat get() {
+ public synchronized Mat get(long ts[]) {
if (!mValid) return null;
while (full == false) {
@@ -1204,9 +1228,11 @@
mat.put(0,0, bytes);
full = false;
notifyAll();
+ ts[0] = timestamp;
return mat;
}
- public synchronized void put() {
+
+ public synchronized void put(long ts) {
while (full) {
try {
wait();
@@ -1219,6 +1245,7 @@
buf.get(bytes);
buf.rewind();
+ timestamp = ts;
full = true;
notifyAll();
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RVCVXCheckTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RVCVXCheckTestActivity.java
index 9a74a0e..35c4d56 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RVCVXCheckTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RVCVXCheckTestActivity.java
@@ -16,9 +16,10 @@
package com.android.cts.verifier.sensors;
-
+import android.content.Context;
import android.hardware.cts.helpers.SensorTestStateNotSupportedException;
import android.os.Bundle;
+import android.os.PowerManager;
import com.android.cts.verifier.sensors.base.SensorCtsVerifierTestActivity;
import com.android.cts.verifier.sensors.helpers.OpenCVLibrary;
@@ -82,7 +83,7 @@
while(retry-->0) {
try {
- Thread.sleep(100);
+ Thread.sleep(250);
} catch (InterruptedException e) {
//
}
@@ -146,7 +147,15 @@
// Analysis of recorded video and sensor data using RVCXAnalyzer
RVCVXCheckAnalyzer analyzer = new RVCVXCheckAnalyzer(mRecPath);
+
+ // acquire a partial wake lock just in case CPU fall asleep
+ PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
+ PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
+ "RVCVXCheckAnalyzer");
+
+ wl.acquire();
mReport = analyzer.processDataSet();
+ wl.release();
playSound();
vibrate(500);
diff --git a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/DeviceInfoInstrument.java b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/DeviceInfoInstrument.java
index f3af0bc..2f80911 100644
--- a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/DeviceInfoInstrument.java
+++ b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/DeviceInfoInstrument.java
@@ -25,19 +25,37 @@
import android.text.TextUtils;
import android.util.Log;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
/**
* An instrumentation that runs all activities that extends DeviceInfoActivity.
*/
public class DeviceInfoInstrument extends Instrumentation {
private static final String LOG_TAG = "ExtendedDeviceInfo";
- private static final int DEVICE_INFO_ACTIVITY_REQUEST = 1;
+ private static final String COLLECTOR = "collector";
+ // List of collectors to run. If null or empty, all collectors will run.
+ private Set<String> mCollectorSet = new HashSet<String>();
+
+ // Results sent to the caller when this istrumentation completes.
private Bundle mBundle = new Bundle();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ if (savedInstanceState != null) {
+ String collectorList = savedInstanceState.getString(COLLECTOR);
+ if (!TextUtils.isEmpty(collectorList)) {
+ for (String collector : TextUtils.split(collectorList, ",")) {
+ if (!TextUtils.isEmpty(collector)) {
+ mCollectorSet.add(collector);
+ }
+ }
+ }
+ }
start();
}
@@ -47,13 +65,8 @@
Context context = getContext();
ActivityInfo[] activities = context.getPackageManager().getPackageInfo(
context.getPackageName(), PackageManager.GET_ACTIVITIES).activities;
-
for (ActivityInfo activityInfo : activities) {
- Class cls = Class.forName(activityInfo.name);
- if (cls != DeviceInfoActivity.class &&
- DeviceInfoActivity.class.isAssignableFrom(cls)) {
- runActivity(activityInfo.name);
- }
+ runActivity(activityInfo.name);
}
} catch (Exception e) {
Log.e(LOG_TAG, "Exception occurred while running activities.", e);
@@ -65,9 +78,40 @@
}
/**
+ * Returns true if the activity meets the criteria to run; otherwise, false.
+ */
+ private boolean isActivityRunnable(Class activityClass) {
+ // Don't run the base DeviceInfoActivity class.
+ if (DeviceInfoActivity.class == activityClass) {
+ return false;
+ }
+ // Don't run anything that doesn't extends DeviceInfoActivity.
+ if (!DeviceInfoActivity.class.isAssignableFrom(activityClass)) {
+ return false;
+ }
+ // Only run activity if mCollectorSet is empty or contains it.
+ if (mCollectorSet != null && mCollectorSet.size() > 0) {
+ return mCollectorSet.contains(activityClass.getName());
+ }
+ // Run anything that makes it here.
+ return true;
+ }
+
+ /**
* Runs a device info activity and return the file path where the results are written to.
*/
private void runActivity(String activityName) throws Exception {
+ Class activityClass = null;
+ try {
+ activityClass = Class.forName(activityName);
+ } catch (ClassNotFoundException e) {
+ return;
+ }
+
+ if (activityClass == null || !isActivityRunnable(activityClass)) {
+ return;
+ }
+
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClassName(this.getContext(), activityName);
@@ -76,7 +120,7 @@
waitForIdleSync();
activity.waitForActivityToFinish();
- String className = Class.forName(activityName).getSimpleName();
+ String className = activityClass.getSimpleName();
String errorMessage = activity.getErrorMessage();
if (TextUtils.isEmpty(errorMessage)) {
mBundle.putString(className, activity.getResultFilePath());
diff --git a/hostsidetests/atrace/src/android/atrace/cts/AtraceHostTest.java b/hostsidetests/atrace/src/android/atrace/cts/AtraceHostTest.java
index c8a2d8e..760723e 100644
--- a/hostsidetests/atrace/src/android/atrace/cts/AtraceHostTest.java
+++ b/hostsidetests/atrace/src/android/atrace/cts/AtraceHostTest.java
@@ -209,7 +209,7 @@
// capture a launch of the app with async tracing
// content traced by 'view' tag tested below, 'sched' used to ensure tgid printed
- String atraceArgs = "-a " + TEST_PKG + " -c -b 16000 view sched"; // TODO: zipping
+ String atraceArgs = "-a " + TEST_PKG + " -c -b 16000 view"; // TODO: zipping
getDevice().executeShellCommand("atrace --async_stop " + atraceArgs);
getDevice().executeShellCommand("atrace --async_start " + atraceArgs);
getDevice().executeShellCommand("am start " + TEST_PKG);
@@ -228,13 +228,15 @@
String traceData = atraceOutput.substring(dataStart + MARKER.length());
FtraceEntryCallback callback = new FtraceEntryCallback() {
- private int matches = 0;
- private int nextSectionIndex = 0;
- private int appPid = -1;
+ private int userSpaceMatches = 0;
+ private int beginMatches = 0;
+ private int nextSectionIndex = -1;
+ private int appTid = -1;
- // list of tags expected to be seen on app launch, in order.
+
+ private final String initialSection = "traceable-app-test-section";
+ // list of tags expected to be seen on app launch, in order, after the initial.
private final String[] requiredSectionList = {
- "traceable-app-test-section",
"inflate",
"Choreographer#doFrame",
"traversal",
@@ -252,34 +254,41 @@
return;
}
- matches++;
assertNotNull(truncatedThreadName);
assertTrue(tid > 0);
- if (TEST_PKG.endsWith(truncatedThreadName)) {
- matches++;
+ userSpaceMatches++;
- if (pid >= 0) {
- // verify pid, if present
- if (appPid == -1) {
- appPid = pid;
- } else {
- assertEquals(appPid, pid);
- }
- }
+ if (details == null || !details.startsWith("B|")) {
+ // not a begin event
+ return;
+ }
+ beginMatches++;
- if (nextSectionIndex < requiredSectionList.length
- && details != null
- && details.startsWith("B|")
- && details.endsWith("|" + requiredSectionList[nextSectionIndex])) {
- nextSectionIndex++;
- }
+ if (details.endsWith("|" + initialSection)) {
+ // initial section observed, start looking for others in order
+ assertEquals(nextSectionIndex, -1);
+ nextSectionIndex = 0;
+ appTid = tid;
+ return;
+ }
+
+ if (nextSectionIndex >= 0
+ && tid == appTid
+ && nextSectionIndex < requiredSectionList.length
+ && details.endsWith("|" + requiredSectionList[nextSectionIndex])) {
+ // found next required section in sequence
+ nextSectionIndex++;
}
}
@Override
public void onFinished() {
assertTrue("Unable to parse any userspace sections from atrace output",
- matches != 0);
+ userSpaceMatches != 0);
+ assertTrue("Unable to parse any section begin events from atrace output",
+ beginMatches != 0);
+ assertTrue("Unable to parse initial userspace sections from test app",
+ nextSectionIndex >= 0);
assertEquals("Didn't see required list of traced sections, in order",
requiredSectionList.length, nextSectionIndex);
}
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/AndroidManifest.xml b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/AndroidManifest.xml
index 6e520c3..fe07bcb 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/AndroidManifest.xml
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/AndroidManifest.xml
@@ -71,6 +71,13 @@
android:resource="@xml/authenticator" />
</service>
+ <activity android:name=".UserRestrictionActivity" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.DEFAULT"/>
+ </intent-filter>
+ </activity>
+
</application>
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/UserRestrictionActivity.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/UserRestrictionActivity.java
new file mode 100644
index 0000000..fed1a79
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/UserRestrictionActivity.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.cts.deviceandprofileowner;
+
+import android.app.Activity;
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Process;
+import android.util.Log;
+
+/**
+ * Simple activity that adds or clears a user restriction depending on the value of the extras.
+ */
+public class UserRestrictionActivity extends Activity {
+
+ private static final String TAG = UserRestrictionActivity.class.getName();
+
+ private static final String EXTRA_RESTRICTION_KEY = "extra-restriction-key";
+ private static final String EXTRA_COMMAND = "extra-command";
+
+ private static final String ADD_COMMAND = "add-restriction";
+ private static final String CLEAR_COMMAND = "clear-restriction";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ handleIntent(getIntent());
+ }
+
+ // Overriding this method in case another intent is sent to this activity before finish()
+ @Override
+ public void onNewIntent(Intent intent) {
+ super.onNewIntent(intent);
+ handleIntent(intent);
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ // Calling finish() here because doing it in onCreate(), onStart() or onResume() makes
+ // "adb shell am start" timeout if using the -W option.
+ finish();
+ }
+
+ private void handleIntent(Intent intent) {
+ DevicePolicyManager dpm = (DevicePolicyManager)
+ getSystemService(Context.DEVICE_POLICY_SERVICE);
+ String restrictionKey = intent.getStringExtra(EXTRA_RESTRICTION_KEY);
+ String command = intent.getStringExtra(EXTRA_COMMAND);
+ Log.i(TAG, "Command: \"" + command + "\". Restriction: \"" + restrictionKey + "\"");
+
+ if (ADD_COMMAND.equals(command)) {
+ dpm.addUserRestriction(BaseDeviceAdminTest.ADMIN_RECEIVER_COMPONENT, restrictionKey);
+ Log.i(TAG, "Added user restriction " + restrictionKey
+ + " for user " + Process.myUserHandle());
+ } else if (CLEAR_COMMAND.equals(command)) {
+ dpm.clearUserRestriction(
+ BaseDeviceAdminTest.ADMIN_RECEIVER_COMPONENT, restrictionKey);
+ Log.i(TAG, "Cleared user restriction " + restrictionKey
+ + " for user " + Process.myUserHandle());
+ } else {
+ Log.e(TAG, "Invalid command: " + command);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/hostsidetests/devicepolicy/app/PackageInstaller/Android.mk b/hostsidetests/devicepolicy/app/PackageInstaller/Android.mk
new file mode 100644
index 0000000..e68c884
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/PackageInstaller/Android.mk
@@ -0,0 +1,33 @@
+# 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.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_PACKAGE_NAME := CtsPackageInstallerApp
+
+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_STATIC_JAVA_LIBRARIES := android-support-v4 ctstestrunner ub-uiautomator
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/PackageInstaller/AndroidManifest.xml b/hostsidetests/devicepolicy/app/PackageInstaller/AndroidManifest.xml
new file mode 100644
index 0000000..aaa88f2
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/PackageInstaller/AndroidManifest.xml
@@ -0,0 +1,41 @@
+<?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"
+ package="com.android.cts.packageinstaller">
+
+ <uses-sdk android:minSdkVersion="21"/>
+
+ <application>
+ <uses-library android:name="android.test.runner" />
+
+ <receiver
+ android:name=".ClearDeviceOwnerTest$BasicAdminReceiver"
+ 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>
+ </application>
+
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.cts.packageinstaller"
+ android:label="Package Installer CTS Tests" />
+
+</manifest>
diff --git a/hostsidetests/devicepolicy/app/PackageInstaller/res/xml/device_admin.xml b/hostsidetests/devicepolicy/app/PackageInstaller/res/xml/device_admin.xml
new file mode 100644
index 0000000..de4a9e1
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/PackageInstaller/res/xml/device_admin.xml
@@ -0,0 +1,3 @@
+<device-admin xmlns:android="http://schemas.android.com/apk/res/android" android:visible="false">
+ <uses-policies />
+</device-admin>
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/PackageInstallTest.java b/hostsidetests/devicepolicy/app/PackageInstaller/src/com/android/cts/packageinstaller/BasePackageInstallTest.java
similarity index 70%
rename from hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/PackageInstallTest.java
rename to hostsidetests/devicepolicy/app/PackageInstaller/src/com/android/cts/packageinstaller/BasePackageInstallTest.java
index 0eddbee..f994e9e 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/PackageInstallTest.java
+++ b/hostsidetests/devicepolicy/app/PackageInstaller/src/com/android/cts/packageinstaller/BasePackageInstallTest.java
@@ -13,17 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.cts.deviceowner;
+package com.android.cts.packageinstaller;
import android.app.PendingIntent;
+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.content.IntentSender;
-import android.content.pm.PackageManager;
import android.content.pm.PackageInfo;
import android.content.pm.PackageInstaller;
+import android.content.pm.PackageManager;
+import android.support.test.uiautomator.UiDevice;
+import android.test.InstrumentationTestCase;
+
+import com.android.cts.packageinstaller.ClearDeviceOwnerTest.BasicAdminReceiver;
import java.io.File;
import java.io.FileInputStream;
@@ -31,34 +37,41 @@
import java.io.OutputStream;
/**
- * This class tests silent package install and uninstall by a device owner.
+ * Base test case for testing PackageInstaller.
*/
-public class PackageInstallTest extends BaseDeviceOwnerTest {
- private static final String TEST_APP_LOCATION = "/data/local/tmp/CtsSimpleApp.apk";
- private static final String TEST_APP_PKG = "com.android.cts.launcherapps.simpleapp";
- private static final int PACKAGE_INSTALLER_TIMEOUT_MS = 60000; // 60 seconds
+public class BasePackageInstallTest extends InstrumentationTestCase {
+ protected static final String TEST_APP_LOCATION = "/data/local/tmp/CtsSimpleApp.apk";
+ protected static final String TEST_APP_PKG = "com.android.cts.launcherapps.simpleapp";
+ protected static final int PACKAGE_INSTALLER_TIMEOUT_MS = 60000; // 60 seconds
private static final String ACTION_INSTALL_COMMIT =
"com.android.cts.deviceowner.INTENT_PACKAGE_INSTALL_COMMIT";
- private static final int PACKAGE_INSTALLER_STATUS_UNDEFINED = -1000;
+ protected static final int PACKAGE_INSTALLER_STATUS_UNDEFINED = -1000;
+ public static final String PACKAGE_NAME = SilentPackageInstallTest.class.getPackage().getName();
+ protected Context mContext;
+ protected UiDevice mDevice;
+ protected DevicePolicyManager mDevicePolicyManager;
private PackageManager mPackageManager;
private PackageInstaller mPackageInstaller;
private PackageInstaller.Session mSession;
- private boolean mCallbackReceived;
- private int mCallbackStatus;
+ protected boolean mCallbackReceived;
+ protected int mCallbackStatus;
+ protected Intent mCallbackIntent;
- private final Object mPackageInstallerTimeoutLock = new Object();
+ protected final Object mPackageInstallerTimeoutLock = new Object();
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- mContext.unregisterReceiver(this);
synchronized (mPackageInstallerTimeoutLock) {
mCallbackStatus = intent.getIntExtra(PackageInstaller.EXTRA_STATUS,
PACKAGE_INSTALLER_STATUS_UNDEFINED);
if (mCallbackStatus == PackageInstaller.STATUS_SUCCESS) {
+ mContext.unregisterReceiver(this);
assertEquals(TEST_APP_PKG, intent.getStringExtra(
PackageInstaller.EXTRA_PACKAGE_NAME));
+ } else if (mCallbackStatus == PackageInstaller.STATUS_PENDING_USER_ACTION) {
+ mCallbackIntent = (Intent) intent.getExtras().get(Intent.EXTRA_INTENT);
}
mCallbackReceived = true;
mPackageInstallerTimeoutLock.notify();
@@ -69,6 +82,10 @@
@Override
protected void setUp() throws Exception {
super.setUp();
+ mContext = getInstrumentation().getContext();
+ mDevice = UiDevice.getInstance(getInstrumentation());
+ mDevicePolicyManager = (DevicePolicyManager)
+ mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
mPackageManager = mContext.getPackageManager();
mPackageInstaller = mPackageManager.getPackageInstaller();
assertNotNull(mPackageInstaller);
@@ -79,7 +96,10 @@
@Override
protected void tearDown() throws Exception {
- mDevicePolicyManager.setUninstallBlocked(getWho(), TEST_APP_PKG, false);
+ if (mDevicePolicyManager.isDeviceOwnerApp(PACKAGE_NAME) ||
+ mDevicePolicyManager.isProfileOwnerApp(PACKAGE_NAME)) {
+ mDevicePolicyManager.setUninstallBlocked(getWho(), TEST_APP_PKG, false);
+ }
try {
mContext.unregisterReceiver(mBroadcastReceiver);
} catch (IllegalArgumentException e) {
@@ -91,33 +111,12 @@
super.tearDown();
}
- public void testSilentInstallUninstall() throws Exception {
- // install the app
- assertInstallPackage();
-
- // uninstall the app again
- assertTrue(tryUninstallPackage());
- assertFalse(isPackageInstalled(TEST_APP_PKG));
+ protected static ComponentName getWho() {
+ return new ComponentName(PACKAGE_NAME, BasicAdminReceiver.class.getName());
}
- public void testUninstallBlocked() throws Exception {
- // install the app
- assertInstallPackage();
-
- mDevicePolicyManager.setUninstallBlocked(getWho(), TEST_APP_PKG, true);
- assertTrue(mDevicePolicyManager.isUninstallBlocked(getWho(), TEST_APP_PKG));
- assertTrue(mDevicePolicyManager.isUninstallBlocked(null, TEST_APP_PKG));
- assertFalse(tryUninstallPackage());
- assertTrue(isPackageInstalled(TEST_APP_PKG));
-
- mDevicePolicyManager.setUninstallBlocked(getWho(), TEST_APP_PKG, false);
- assertFalse(mDevicePolicyManager.isUninstallBlocked(getWho(), TEST_APP_PKG));
- assertFalse(mDevicePolicyManager.isUninstallBlocked(null, TEST_APP_PKG));
- assertTrue(tryUninstallPackage());
+ protected void assertInstallPackage() throws Exception {
assertFalse(isPackageInstalled(TEST_APP_PKG));
- }
-
- private void assertInstallPackage() throws Exception {
synchronized (mPackageInstallerTimeoutLock) {
mCallbackReceived = false;
mCallbackStatus = PACKAGE_INSTALLER_STATUS_UNDEFINED;
@@ -134,7 +133,7 @@
assertTrue(isPackageInstalled(TEST_APP_PKG));
}
- private boolean tryUninstallPackage() throws Exception {
+ protected boolean tryUninstallPackage() throws Exception {
assertTrue(isPackageInstalled(TEST_APP_PKG));
synchronized (mPackageInstallerTimeoutLock) {
mCallbackReceived = false;
@@ -151,7 +150,7 @@
}
}
- private void installPackage(String packageLocation) throws Exception {
+ protected void installPackage(String packageLocation) throws Exception {
PackageInstaller.SessionParams params = new PackageInstaller.SessionParams(
PackageInstaller.SessionParams.MODE_FULL_INSTALL);
int sessionId = mPackageInstaller.createSession(params);
@@ -184,11 +183,11 @@
mContext,
sessionId,
broadcastIntent,
- PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent.FLAG_UPDATE_CURRENT);
return pendingIntent.getIntentSender();
}
- private boolean isPackageInstalled(String packageName) {
+ protected boolean isPackageInstalled(String packageName) {
try {
PackageInfo pi = mPackageManager.getPackageInfo(packageName, 0);
return pi != null;
diff --git a/hostsidetests/devicepolicy/app/PackageInstaller/src/com/android/cts/packageinstaller/ClearDeviceOwnerTest.java b/hostsidetests/devicepolicy/app/PackageInstaller/src/com/android/cts/packageinstaller/ClearDeviceOwnerTest.java
new file mode 100644
index 0000000..a06271b
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/PackageInstaller/src/com/android/cts/packageinstaller/ClearDeviceOwnerTest.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.cts.packageinstaller;
+
+import android.app.admin.DeviceAdminReceiver;
+import android.app.admin.DevicePolicyManager;
+import android.content.ComponentName;
+import android.content.Context;
+import android.test.InstrumentationTestCase;
+
+/**
+ * Base class for profile and device based tests.
+ *
+ * This class handles making sure that the test is the profile or device owner and that it has an
+ * active admin registered, so that all tests may assume these are done.
+ */
+public class ClearDeviceOwnerTest extends InstrumentationTestCase {
+
+ public static class BasicAdminReceiver extends DeviceAdminReceiver {
+ }
+
+ public static final String PACKAGE_NAME = BasicAdminReceiver.class.getPackage().getName();
+ public static final ComponentName ADMIN_RECEIVER_COMPONENT = new ComponentName(
+ PACKAGE_NAME, BasicAdminReceiver.class.getName());
+
+ private DevicePolicyManager mDevicePolicyManager;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ mDevicePolicyManager = (DevicePolicyManager)
+ getInstrumentation().getContext().getSystemService(Context.DEVICE_POLICY_SERVICE);
+ assertNotNull(mDevicePolicyManager);
+
+ assertTrue(mDevicePolicyManager.isAdminActive(ADMIN_RECEIVER_COMPONENT));
+ assertTrue("App is not device owner", mDevicePolicyManager.isDeviceOwnerApp(PACKAGE_NAME));
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ removeActiveAdmin(ADMIN_RECEIVER_COMPONENT);
+ mDevicePolicyManager.clearDeviceOwnerApp(PACKAGE_NAME);
+ assertFalse(mDevicePolicyManager.isAdminActive(ADMIN_RECEIVER_COMPONENT));
+ assertFalse(mDevicePolicyManager.isDeviceOwnerApp(PACKAGE_NAME));
+
+ super.tearDown();
+ }
+
+ // This test clears the device owner and active admin on tearDown(). To be called from the host
+ // side test once a test case is finished.
+ public void testClearDeviceOwner() {
+ }
+
+ private void removeActiveAdmin(ComponentName cn) throws InterruptedException {
+ if (mDevicePolicyManager.isAdminActive(cn)) {
+ mDevicePolicyManager.removeActiveAdmin(cn);
+ for (int i = 0; i < 1000 && mDevicePolicyManager.isAdminActive(cn); i++) {
+ Thread.sleep(100);
+ }
+ }
+ }
+}
diff --git a/hostsidetests/devicepolicy/app/PackageInstaller/src/com/android/cts/packageinstaller/ManualPackageInstallTest.java b/hostsidetests/devicepolicy/app/PackageInstaller/src/com/android/cts/packageinstaller/ManualPackageInstallTest.java
new file mode 100644
index 0000000..96affae
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/PackageInstaller/src/com/android/cts/packageinstaller/ManualPackageInstallTest.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.cts.packageinstaller;
+
+import android.content.Intent;
+import android.content.pm.PackageInstaller;
+import android.support.test.uiautomator.By;
+import android.support.test.uiautomator.BySelector;
+import android.support.test.uiautomator.UiObject2;
+import android.support.test.uiautomator.Until;
+
+/**
+ * This class tests manual package install and uninstall by a device owner.
+ */
+public class ManualPackageInstallTest extends BasePackageInstallTest {
+ private static final int AUTOMATOR_WAIT_TIMEOUT = 5000;
+ private static final int INSTALL_WAIT_TIME = 5000;
+
+ private static final BySelector POPUP_BUTTON_SELECTOR = By
+ .clazz(android.widget.Button.class.getName())
+ .res("android:id/button1")
+ .pkg("com.google.android.packageinstaller");
+ private static final BySelector POPUP_TEXT_SELECTOR = By
+ .clazz(android.widget.TextView.class.getName())
+ .res("android:id/alertTitle")
+ .pkg("com.google.android.packageinstaller");
+ private static final BySelector INSTALL_BUTTON_SELECTOR = By
+ .clazz(android.widget.Button.class.getName())
+ .res("com.android.packageinstaller:id/ok_button")
+ .pkg("com.google.android.packageinstaller");
+
+ public void testManualInstallSucceeded() throws Exception {
+ assertInstallPackage();
+ }
+
+ public void testManualInstallBlocked() throws Exception {
+ synchronized (mPackageInstallerTimeoutLock) {
+ mCallbackReceived = false;
+ mCallbackStatus = PACKAGE_INSTALLER_STATUS_UNDEFINED;
+ }
+ // Calls the original installPackage which does not click through the install button.
+ super.installPackage(TEST_APP_LOCATION);
+ synchronized (mPackageInstallerTimeoutLock) {
+ try {
+ mPackageInstallerTimeoutLock.wait(PACKAGE_INSTALLER_TIMEOUT_MS);
+ } catch (InterruptedException e) {
+ }
+ assertTrue(mCallbackReceived);
+ assertEquals(PackageInstaller.STATUS_PENDING_USER_ACTION, mCallbackStatus);
+ }
+
+ mCallbackIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ mContext.startActivity(mCallbackIntent);
+
+ automateDismissInstallBlockedDialog();
+
+ // Assuming installation is not synchronous, we should wait a while before checking.
+ Thread.sleep(INSTALL_WAIT_TIME);
+ assertFalse(isPackageInstalled(TEST_APP_PKG));
+ }
+
+ @Override
+ protected void installPackage(String packageLocation) throws Exception {
+ super.installPackage(packageLocation);
+
+ synchronized (mPackageInstallerTimeoutLock) {
+ try {
+ mPackageInstallerTimeoutLock.wait(PACKAGE_INSTALLER_TIMEOUT_MS);
+ } catch (InterruptedException e) {
+ }
+ assertTrue(mCallbackReceived);
+ assertEquals(PackageInstaller.STATUS_PENDING_USER_ACTION, mCallbackStatus);
+ }
+
+ // Use a receiver to listen for package install.
+ synchronized (mPackageInstallerTimeoutLock) {
+ mCallbackReceived = false;
+ mCallbackStatus = PACKAGE_INSTALLER_STATUS_UNDEFINED;
+ }
+
+ mCallbackIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ mContext.startActivity(mCallbackIntent);
+
+ automateInstallClick();
+ }
+
+ private void automateInstallClick() {
+ mDevice.wait(Until.hasObject(INSTALL_BUTTON_SELECTOR), AUTOMATOR_WAIT_TIMEOUT);
+ UiObject2 button = mDevice.findObject(INSTALL_BUTTON_SELECTOR);
+ assertNotNull("Install button not found", button);
+ button.click();
+ }
+
+ private void automateDismissInstallBlockedDialog() {
+ mDevice.wait(Until.hasObject(POPUP_TEXT_SELECTOR), AUTOMATOR_WAIT_TIMEOUT);
+ UiObject2 text = mDevice.findObject(POPUP_TEXT_SELECTOR);
+ assertNotNull("Alert dialog not found", text);
+ // "OK" button only present in the dialog if it is blocked by policy.
+ UiObject2 button = mDevice.findObject(POPUP_BUTTON_SELECTOR);
+ assertNotNull("OK button not found", button);
+ button.click();
+ }
+}
diff --git a/hostsidetests/devicepolicy/app/PackageInstaller/src/com/android/cts/packageinstaller/SilentPackageInstallTest.java b/hostsidetests/devicepolicy/app/PackageInstaller/src/com/android/cts/packageinstaller/SilentPackageInstallTest.java
new file mode 100644
index 0000000..f1a80b9
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/PackageInstaller/src/com/android/cts/packageinstaller/SilentPackageInstallTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.cts.packageinstaller;
+
+/**
+ * This class tests silent package install and uninstall by a device owner.
+ */
+public class SilentPackageInstallTest extends BasePackageInstallTest {
+ public void testSilentInstallUninstall() throws Exception {
+ // install the app
+ assertInstallPackage();
+
+ // uninstall the app again
+ assertTrue(tryUninstallPackage());
+ assertFalse(isPackageInstalled(TEST_APP_PKG));
+ }
+
+ public void testUninstallBlocked() throws Exception {
+ // install the app
+ assertInstallPackage();
+
+ mDevicePolicyManager.setUninstallBlocked(getWho(), TEST_APP_PKG, true);
+ assertTrue(mDevicePolicyManager.isUninstallBlocked(getWho(), TEST_APP_PKG));
+ assertTrue(mDevicePolicyManager.isUninstallBlocked(null, TEST_APP_PKG));
+ assertFalse(tryUninstallPackage());
+ assertTrue(isPackageInstalled(TEST_APP_PKG));
+
+ mDevicePolicyManager.setUninstallBlocked(getWho(), TEST_APP_PKG, false);
+ assertFalse(mDevicePolicyManager.isUninstallBlocked(getWho(), TEST_APP_PKG));
+ assertFalse(mDevicePolicyManager.isUninstallBlocked(null, TEST_APP_PKG));
+ assertTrue(tryUninstallPackage());
+ assertFalse(isPackageInstalled(TEST_APP_PKG));
+ }
+}
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java
index 650e963..4fc14e4 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java
@@ -17,7 +17,6 @@
package com.android.cts.devicepolicy;
import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.util.AbiUtils;
import com.android.ddmlib.Log.LogLevel;
import com.android.ddmlib.testrunner.InstrumentationResultParser;
import com.android.ddmlib.testrunner.RemoteAndroidTestRunner;
@@ -363,4 +362,20 @@
CLog.logAndDisplay(LogLevel.INFO, "Output for command " + command + ": " + commandOutput);
return commandOutput.startsWith("Success:");
}
+
+ protected String getSettings(String namespace, String name, int userId)
+ throws DeviceNotAvailableException {
+ String command = "settings --user " + userId + " get " + namespace + " " + name;
+ String commandOutput = getDevice().executeShellCommand(command);
+ CLog.logAndDisplay(LogLevel.INFO, "Output for command " + command + ": " + commandOutput);
+ return commandOutput.replace("\n", "").replace("\r", "");
+ }
+
+ protected void putSettings(String namespace, String name, String value, int userId)
+ throws DeviceNotAvailableException {
+ String command = "settings --user " + userId + " put " + namespace + " " + name
+ + " " + value;
+ String commandOutput = getDevice().executeShellCommand(command);
+ CLog.logAndDisplay(LogLevel.INFO, "Output for command " + command + ": " + commandOutput);
+ }
}
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CustomDeviceOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CustomDeviceOwnerTest.java
index 7cb8f3b..8d22638 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CustomDeviceOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CustomDeviceOwnerTest.java
@@ -16,9 +16,7 @@
package com.android.cts.devicepolicy;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.tradefed.log.LogUtil.CLog;
-
+import java.io.File;
import java.lang.Exception;
/**
@@ -49,6 +47,18 @@
private static final String INTENT_RECEIVER_PKG = "com.android.cts.intent.receiver";
private static final String INTENT_RECEIVER_APK = "CtsIntentReceiverApp.apk";
+ private static final String TEST_APP_APK = "CtsSimpleApp.apk";
+ private static final String TEST_APP_PKG = "com.android.cts.launcherapps.simpleapp";
+ private static final String TEST_APP_LOCATION = "/data/local/tmp/";
+
+ private static final String PACKAGE_INSTALLER_PKG = "com.android.cts.packageinstaller";
+ private static final String PACKAGE_INSTALLER_APK = "CtsPackageInstallerApp.apk";
+ private static final String PACKAGE_INSTALLER_ADMIN_COMPONENT =
+ PACKAGE_INSTALLER_PKG + "/" + ".ClearDeviceOwnerTest$BasicAdminReceiver";
+ private static final String PACKAGE_INSTALLER_CLEAR_DEVICE_OWNER_TEST_CLASS =
+ PACKAGE_INSTALLER_PKG + ".ClearDeviceOwnerTest";
+
+ @Override
public void tearDown() throws Exception {
if (mHasFeature) {
getDevice().uninstallPackage(DEVICE_OWNER_PKG);
@@ -117,4 +127,28 @@
"testRemoveAccounts", 0));
}
}
+
+ public void testSilentPackageInstall() throws Exception {
+ if (!mHasFeature) {
+ return;
+ }
+ final File apk = mCtsBuild.getTestApp(TEST_APP_APK);
+ try {
+ // Install the test and prepare the test apk.
+ installApp(PACKAGE_INSTALLER_APK);
+ assertTrue(setDeviceOwner(PACKAGE_INSTALLER_ADMIN_COMPONENT));
+
+ getDevice().uninstallPackage(TEST_APP_PKG);
+ assertTrue(getDevice().pushFile(apk, TEST_APP_LOCATION + apk.getName()));
+ assertTrue(runDeviceTests(PACKAGE_INSTALLER_PKG,
+ PACKAGE_INSTALLER_PKG + ".SilentPackageInstallTest"));
+ } finally {
+ assertTrue("Failed to remove device owner.", runDeviceTests(PACKAGE_INSTALLER_PKG,
+ PACKAGE_INSTALLER_CLEAR_DEVICE_OWNER_TEST_CLASS));
+ String command = "rm " + TEST_APP_LOCATION + apk.getName();
+ String commandOutput = getDevice().executeShellCommand(command);
+ getDevice().uninstallPackage(TEST_APP_PKG);
+ getDevice().uninstallPackage(PACKAGE_INSTALLER_PKG);
+ }
+ }
}
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
index 439c85f..43e6730 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
@@ -20,6 +20,8 @@
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.log.LogUtil.CLog;
+import java.io.File;
+
/**
* Set of tests for usecases that apply to profile and device owner.
* This class is the base class of MixedProfileOwnerTest and MixedDeviceOwnerTest and is abstract
@@ -41,8 +43,18 @@
private static final String CERT_INSTALLER_PKG = "com.android.cts.certinstaller";
private static final String CERT_INSTALLER_APK = "CtsCertInstallerApp.apk";
+ private static final String TEST_APP_APK = "CtsSimpleApp.apk";
+ private static final String TEST_APP_PKG = "com.android.cts.launcherapps.simpleapp";
+ private static final String TEST_APP_LOCATION = "/data/local/tmp/";
+
+ private static final String PACKAGE_INSTALLER_PKG = "com.android.cts.packageinstaller";
+ private static final String PACKAGE_INSTALLER_APK = "CtsPackageInstallerApp.apk";
+
protected static final int USER_OWNER = 0;
+ private static final String ADD_RESTRICTION_COMMAND = "add-restriction";
+ private static final String CLEAR_RESTRICTION_COMMAND = "clear-restriction";
+
// ID of the user all tests are run as. For device owner this will be 0, for profile owner it
// is the user id of the created profile.
protected int mUserId;
@@ -167,7 +179,6 @@
executeDeviceTestClass(".ApplicationHiddenTest");
}
- // TODO: Remove AccountManagementTest from XTS after GTS is released for MNC.
public void testAccountManagement() throws Exception {
if (!mHasFeature) {
return;
@@ -206,6 +217,49 @@
}
}
+ public void testPackageInstallUserRestrictions() throws Exception {
+ // UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES
+ final String DISALLOW_INSTALL_UNKNOWN_SOURCES = "no_install_unknown_sources";
+ final String UNKNOWN_SOURCES_SETTING = "install_non_market_apps";
+ final String SECURE_SETTING_CATEGORY = "secure";
+ final File apk = mCtsBuild.getTestApp(TEST_APP_APK);
+ String unknownSourceSetting = null;
+ try {
+ // Install the test and prepare the test apk.
+ installApp(PACKAGE_INSTALLER_APK);
+ assertTrue(getDevice().pushFile(apk, TEST_APP_LOCATION + apk.getName()));
+
+ // Add restrictions and test if we can install the apk.
+ getDevice().uninstallPackage(TEST_APP_PKG);
+ changeUserRestrictionForUser(DISALLOW_INSTALL_UNKNOWN_SOURCES,
+ ADD_RESTRICTION_COMMAND, mUserId);
+ assertTrue(runDeviceTestsAsUser(PACKAGE_INSTALLER_PKG, ".ManualPackageInstallTest",
+ "testManualInstallBlocked", mUserId));
+
+ // Clear restrictions and test if we can install the apk.
+ changeUserRestrictionForUser(DISALLOW_INSTALL_UNKNOWN_SOURCES,
+ CLEAR_RESTRICTION_COMMAND, mUserId);
+
+ // Enable Unknown sources in Settings.
+ unknownSourceSetting =
+ getSettings(SECURE_SETTING_CATEGORY, UNKNOWN_SOURCES_SETTING, mUserId);
+ putSettings(SECURE_SETTING_CATEGORY, UNKNOWN_SOURCES_SETTING, "1", mUserId);
+ assertEquals("1",
+ getSettings(SECURE_SETTING_CATEGORY, UNKNOWN_SOURCES_SETTING, mUserId));
+ assertTrue(runDeviceTestsAsUser(PACKAGE_INSTALLER_PKG, ".ManualPackageInstallTest",
+ "testManualInstallSucceeded", mUserId));
+ } finally {
+ String command = "rm " + TEST_APP_LOCATION + apk.getName();
+ getDevice().executeShellCommand(command);
+ getDevice().uninstallPackage(TEST_APP_PKG);
+ getDevice().uninstallPackage(PACKAGE_INSTALLER_APK);
+ if (unknownSourceSetting != null) {
+ putSettings(SECURE_SETTING_CATEGORY, UNKNOWN_SOURCES_SETTING, unknownSourceSetting,
+ mUserId);
+ }
+ }
+ }
+
protected void executeDeviceTestClass(String className) throws Exception {
assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, className, mUserId));
}
@@ -213,4 +267,18 @@
protected void executeDeviceTestMethod(String className, String testName) throws Exception {
assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, className, testName, mUserId));
}
+
+ private void changeUserRestrictionForUser(String key, String command, int userId)
+ throws DeviceNotAvailableException {
+ String adbCommand = "am start -W --user " + userId
+ + " -c android.intent.category.DEFAULT "
+ + " --es extra-command " + command
+ + " --es extra-restriction-key " + key
+ + " " + DEVICE_ADMIN_PKG + "/.UserRestrictionActivity";
+ String commandOutput = getDevice().executeShellCommand(adbCommand);
+ CLog.logAndDisplay(LogLevel.INFO,
+ "Output for command " + adbCommand + ": " + commandOutput);
+ assertTrue("Command was expected to succeed " + commandOutput,
+ commandOutput.contains("Status: ok"));
+ }
}
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
index 4f267d1..96ca469 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
@@ -16,12 +16,6 @@
package com.android.cts.devicepolicy;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.log.LogUtil.CLog;
-
-import java.io.File;
-
/**
* Set of tests for Device Owner use cases.
*/
@@ -35,10 +29,6 @@
private static final String MANAGED_PROFILE_ADMIN =
MANAGED_PROFILE_PKG + ".BaseManagedProfileTest$BasicAdminReceiver";
- private static final String TEST_APP_APK = "CtsSimpleApp.apk";
- private static final String TEST_APP_PKG = "com.android.cts.launcherapps.simpleapp";
- private static final String TEST_APP_LOCATION = "/data/local/tmp/";
-
private static final String INTENT_RECEIVER_PKG = "com.android.cts.intent.receiver";
private static final String INTENT_RECEIVER_APK = "CtsIntentReceiverApp.apk";
@@ -93,19 +83,6 @@
}
}
- public void testPackageInstall() throws Exception {
- final File apk = mCtsBuild.getTestApp(TEST_APP_APK);
- try {
- getDevice().uninstallPackage(TEST_APP_PKG);
- assertTrue(getDevice().pushFile(apk, TEST_APP_LOCATION + apk.getName()));
- executeDeviceOwnerTest("PackageInstallTest");
- } finally {
- String command = "rm " + TEST_APP_LOCATION + apk.getName();
- String commandOutput = getDevice().executeShellCommand(command);
- getDevice().uninstallPackage(TEST_APP_PKG);
- }
- }
-
public void testSystemUpdatePolicy() throws Exception {
executeDeviceOwnerTest("SystemUpdatePolicyTest");
}
diff --git a/hostsidetests/dumpsys/FramestatsTestApp/Android.mk b/hostsidetests/dumpsys/FramestatsTestApp/Android.mk
new file mode 100644
index 0000000..1104523
--- /dev/null
+++ b/hostsidetests/dumpsys/FramestatsTestApp/Android.mk
@@ -0,0 +1,28 @@
+# 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.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+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_PACKAGE_NAME := CtsFramestatsTestApp
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/dumpsys/FramestatsTestApp/AndroidManifest.xml b/hostsidetests/dumpsys/FramestatsTestApp/AndroidManifest.xml
new file mode 100644
index 0000000..3a9f902
--- /dev/null
+++ b/hostsidetests/dumpsys/FramestatsTestApp/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?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"
+ package="com.android.cts.framestatstestapp">
+ <!--
+ A simple app that draws at least one frame. Used by framestats
+ test.
+ -->
+ <application>
+ <activity android:name=".FramestatsTestAppActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
diff --git a/hostsidetests/dumpsys/FramestatsTestApp/src/com/android/cts/framestatstestapp/FramestatsTestAppActivity.java b/hostsidetests/dumpsys/FramestatsTestApp/src/com/android/cts/framestatstestapp/FramestatsTestAppActivity.java
new file mode 100644
index 0000000..7370508
--- /dev/null
+++ b/hostsidetests/dumpsys/FramestatsTestApp/src/com/android/cts/framestatstestapp/FramestatsTestAppActivity.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.cts.framestatstestapp;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.os.Trace;
+import android.view.View;
+
+public class FramestatsTestAppActivity extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ View v = new View(this);
+ v.setBackgroundColor(0xFF00FF00);
+ setContentView(v);
+ }
+}
diff --git a/hostsidetests/dumpsys/src/android/dumpsys/cts/DumpsysHostTest.java b/hostsidetests/dumpsys/src/android/dumpsys/cts/DumpsysHostTest.java
index a787cdd..0daae03 100644
--- a/hostsidetests/dumpsys/src/android/dumpsys/cts/DumpsysHostTest.java
+++ b/hostsidetests/dumpsys/src/android/dumpsys/cts/DumpsysHostTest.java
@@ -16,11 +16,15 @@
package android.dumpsys.cts;
-import com.android.ddmlib.Log;
+import com.android.cts.tradefed.build.CtsBuildHelper;
+import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.testtype.DeviceTestCase;
+import com.android.tradefed.testtype.IBuildReceiver;
import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
import java.io.StringReader;
import java.util.HashSet;
import java.util.Set;
@@ -28,8 +32,10 @@
/**
* Test to check the format of the dumps of various services (currently only procstats is tested).
*/
-public class DumpsysHostTest extends DeviceTestCase {
+public class DumpsysHostTest extends DeviceTestCase implements IBuildReceiver {
private static final String TAG = "DumpsysHostTest";
+ private static final String TEST_APK = "CtsFramestatsTestApp.apk";
+ private static final String TEST_PKG = "com.android.cts.framestatstestapp";
/**
* A reference to the device under test.
@@ -815,17 +821,38 @@
*/
public void testGfxinfoFramestats() throws Exception {
final String MARKER = "---PROFILEDATA---";
- final int TIMESTAMP_COUNT = 14;
- String frameinfo = mDevice.executeShellCommand("dumpsys gfxinfo com.android.systemui framestats");
- assertNotNull(frameinfo);
- assertTrue(frameinfo.length() > 0);
- int profileStart = frameinfo.indexOf(MARKER);
- int profileEnd = frameinfo.indexOf(MARKER, profileStart + 1);
- assertTrue(profileStart >= 0);
- assertTrue(profileEnd > profileStart);
- String profileData = frameinfo.substring(profileStart + MARKER.length(), profileEnd);
- assertTrue(profileData.length() > 0);
+ try {
+ // cleanup test apps that might be installed from previous partial test run
+ getDevice().uninstallPackage(TEST_PKG);
+
+ // install the test app
+ File testAppFile = mCtsBuild.getTestApp(TEST_APK);
+ String installResult = getDevice().installPackage(testAppFile, false);
+ assertNull(
+ String.format("failed to install atrace test app. Reason: %s", installResult),
+ installResult);
+
+ getDevice().executeShellCommand("am start -W " + TEST_PKG);
+
+ String frameinfo = mDevice.executeShellCommand("dumpsys gfxinfo " +
+ TEST_PKG + " framestats");
+ assertNotNull(frameinfo);
+ assertTrue(frameinfo.length() > 0);
+ int profileStart = frameinfo.indexOf(MARKER);
+ int profileEnd = frameinfo.indexOf(MARKER, profileStart + 1);
+ assertTrue(profileStart >= 0);
+ assertTrue(profileEnd > profileStart);
+ String profileData = frameinfo.substring(profileStart + MARKER.length(), profileEnd);
+ assertTrue(profileData.length() > 0);
+ validateProfileData(profileData);
+ } finally {
+ getDevice().uninstallPackage(TEST_PKG);
+ }
+ }
+
+ private void validateProfileData(String profileData) throws IOException {
+ final int TIMESTAMP_COUNT = 14;
boolean foundAtLeastOneRow = false;
try (BufferedReader reader = new BufferedReader(
new StringReader(profileData))) {
@@ -872,6 +899,16 @@
assertTrue(foundAtLeastOneRow);
}
+ private CtsBuildHelper mCtsBuild;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setBuild(IBuildInfo buildInfo) {
+ mCtsBuild = CtsBuildHelper.createBuildHelper(buildInfo);
+ }
+
private static long assertInteger(String input) {
try {
return Long.parseLong(input);
diff --git a/suite/cts/deviceTests/opengl/jni/graphics/Renderer.cpp b/suite/cts/deviceTests/opengl/jni/graphics/Renderer.cpp
index b8e2acf..16504fd 100644
--- a/suite/cts/deviceTests/opengl/jni/graphics/Renderer.cpp
+++ b/suite/cts/deviceTests/opengl/jni/graphics/Renderer.cpp
@@ -22,6 +22,14 @@
// Used to center the grid on the screen.
#define CENTER_GRID(x) ((((x) * 2.0 + 1) - OFFSCREEN_GRID_SIZE) / OFFSCREEN_GRID_SIZE)
+// Leave a good error message if something fails.
+#define EGL_RESULT_CHECK(X) do { \
+ EGLint error = eglGetError(); \
+ if (!(X) || error != EGL_SUCCESS) { \
+ ALOGE("EGL error '%d' at %s:%d", error, __FILE__, __LINE__);\
+ return false; \
+ } \
+ } while (0)
static const int FBO_NUM_VERTICES = 6;
@@ -66,7 +74,7 @@
EGL_NONE };
static const EGLint configAttribs[] = {
- EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
@@ -78,53 +86,60 @@
static const int FBO_SIZE = 128;
-Renderer::Renderer(ANativeWindow* window, bool offscreen, int workload) :
- mOffscreen(offscreen), mWindow(window), mEglDisplay(EGL_NO_DISPLAY),
- mEglSurface(EGL_NO_SURFACE), mEglContext(EGL_NO_CONTEXT), mWorkload(workload) {
+Renderer::Renderer(EGLNativeWindowType window, bool offscreen) :
+ mOffscreen(offscreen), mEglDisplay(EGL_NO_DISPLAY), mEglSurface(EGL_NO_SURFACE),
+ mEglContext(EGL_NO_CONTEXT), mWindow(window) {
}
-bool Renderer::setUp() {
+bool Renderer::eglSetUp() {
SCOPED_TRACE();
mEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
- if (EGL_NO_DISPLAY == mEglDisplay || EGL_SUCCESS != eglGetError()) {
- return false;
- }
+ EGL_RESULT_CHECK(mEglDisplay != EGL_NO_DISPLAY);
EGLint major;
EGLint minor;
- if (!eglInitialize(mEglDisplay, &major, &minor) || EGL_SUCCESS != eglGetError()) {
- return false;
- }
+ EGL_RESULT_CHECK(eglInitialize(mEglDisplay, &major, &minor));
EGLint numConfigs = 0;
- if (!eglChooseConfig(mEglDisplay, configAttribs, &mGlConfig, 1, &numConfigs)
- || EGL_SUCCESS != eglGetError()) {
- return false;
- }
+ EGL_RESULT_CHECK(eglChooseConfig(mEglDisplay, configAttribs, &mGlConfig, 1, &numConfigs)
+ && (numConfigs > 0));
mEglSurface = eglCreateWindowSurface(mEglDisplay, mGlConfig, mWindow, NULL);
- if (EGL_NO_SURFACE == mEglSurface || EGL_SUCCESS != eglGetError()) {
- return false;
- }
+ EGL_RESULT_CHECK(mEglSurface != EGL_NO_SURFACE);
mEglContext = eglCreateContext(mEglDisplay, mGlConfig, EGL_NO_CONTEXT, contextAttribs);
- if (EGL_NO_CONTEXT == mEglContext || EGL_SUCCESS != eglGetError()) {
- return false;
+ EGL_RESULT_CHECK(mEglContext != EGL_NO_CONTEXT);
+
+ EGL_RESULT_CHECK(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext));
+ EGL_RESULT_CHECK(eglQuerySurface(mEglDisplay, mEglSurface, EGL_WIDTH, &mWidth));
+ EGL_RESULT_CHECK(eglQuerySurface(mEglDisplay, mEglSurface, EGL_HEIGHT, &mHeight));
+
+ return true;
+}
+
+void Renderer::eglTearDown() {
+ SCOPED_TRACE();
+ eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+
+ if (mEglContext != EGL_NO_CONTEXT) {
+ eglDestroyContext(mEglDisplay, mEglContext);
+ mEglContext = EGL_NO_CONTEXT;
}
- if (!eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext)
- || EGL_SUCCESS != eglGetError()) {
- return false;
+ if (mEglSurface != EGL_NO_SURFACE) {
+ mEglSurface = EGL_NO_SURFACE;
}
- if (!eglQuerySurface(mEglDisplay, mEglSurface, EGL_WIDTH, &mWidth)
- || EGL_SUCCESS != eglGetError()) {
- return false;
+ if (mEglDisplay != EGL_NO_DISPLAY) {
+ eglTerminate(mEglDisplay);
+ mEglDisplay = EGL_NO_DISPLAY;
}
- if (!eglQuerySurface(mEglDisplay, mEglSurface, EGL_HEIGHT, &mHeight)
- || EGL_SUCCESS != eglGetError()) {
- return false;
- }
+}
+
+bool Renderer::setUp(int /*workload*/) {
+ SCOPED_TRACE();
+
+ EGL_RESULT_CHECK(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext));
if (mOffscreen) {
mFboWidth = FBO_SIZE;
@@ -178,6 +193,7 @@
ALOGE("GLError %d in setUp", err);
return false;
}
+
return true;
}
@@ -202,29 +218,14 @@
ALOGE("GLError %d in tearDown", err);
return false;
}
- if (mEglContext != EGL_NO_CONTEXT) {
- eglDestroyContext(mEglDisplay, mEglContext);
- mEglContext = EGL_NO_CONTEXT;
- }
- if (mEglSurface != EGL_NO_SURFACE) {
- eglDestroySurface(mEglDisplay, mEglSurface);
- mEglSurface = EGL_NO_SURFACE;
- }
- if (mEglDisplay != EGL_NO_DISPLAY) {
- eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- eglTerminate(mEglDisplay);
- mEglDisplay = EGL_NO_DISPLAY;
- }
- return EGL_SUCCESS == eglGetError();
+ return true;
}
bool Renderer::draw() {
SCOPED_TRACE();
- if (!eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext)
- || EGL_SUCCESS != eglGetError()) {
- return false;
- }
+
+ EGL_RESULT_CHECK(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext));
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(0, 0, mWidth, mHeight);
@@ -287,5 +288,6 @@
return false;
}
- return eglSwapBuffers(mEglDisplay, mEglSurface);
+ EGL_RESULT_CHECK(eglSwapBuffers(mEglDisplay, mEglSurface));
+ return true;
}
diff --git a/suite/cts/deviceTests/opengl/jni/graphics/Renderer.h b/suite/cts/deviceTests/opengl/jni/graphics/Renderer.h
index caa1634..3c62a26 100644
--- a/suite/cts/deviceTests/opengl/jni/graphics/Renderer.h
+++ b/suite/cts/deviceTests/opengl/jni/graphics/Renderer.h
@@ -14,17 +14,18 @@
#ifndef RENDERER_H
#define RENDERER_H
-#include <android/native_window.h>
-
#include <EGL/egl.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
class Renderer {
public:
- Renderer(ANativeWindow* window, bool offscreen, int workload);
- virtual bool setUp();
+ Renderer(EGLNativeWindowType window, bool offscreen);
+ virtual bool setUp(int workload);
virtual bool tearDown();
+ bool eglSetUp();
+ void eglTearDown();
+
bool draw();
virtual void drawWorkload() = 0;
virtual ~Renderer() {};
@@ -32,7 +33,6 @@
static const int OFFSCREEN_GRID_SIZE = 10;
bool mOffscreen;
protected:
- ANativeWindow* mWindow;
EGLDisplay mEglDisplay;
EGLSurface mEglSurface;
EGLContext mEglContext;
@@ -40,7 +40,6 @@
GLuint mProgramId;
EGLint mWidth;
EGLint mHeight;
- int mWorkload;
int mFboWidth;// Frame buffer width
int mFboHeight;// Frame buffer height
GLuint mFboId;// Frame buffer id
@@ -52,5 +51,7 @@
GLuint mFboYOffsetUniformHandle;// Frame buffer y offset uniform handle
GLuint mFboPositionHandle;// Frame buffer position handle
GLuint mFboTexCoordHandle;// Frame buffer texture coordinate handle
+private:
+ EGLNativeWindowType mWindow;
};
#endif
diff --git a/suite/cts/deviceTests/opengl/jni/primitive/GLPrimitive.cpp b/suite/cts/deviceTests/opengl/jni/primitive/GLPrimitive.cpp
index 9d39af9..856da1e 100644
--- a/suite/cts/deviceTests/opengl/jni/primitive/GLPrimitive.cpp
+++ b/suite/cts/deviceTests/opengl/jni/primitive/GLPrimitive.cpp
@@ -28,16 +28,24 @@
// Holds the current benchmark's renderer.
Renderer* gRenderer = NULL;
+ANativeWindow* gNativeWindow = NULL;
+
+enum {
+ FULL_PIPELINE_BENCHMARK = 0,
+ PIXEL_OUTPUT_BENCHMARK = 1,
+ SHADER_PERF_BENCHMARK = 2,
+ CONTEXT_SWITCH_BENCHMARK = 3
+};
extern "C" JNIEXPORT jboolean JNICALL
Java_com_android_cts_opengl_primitive_GLPrimitiveActivity_startBenchmark(
- JNIEnv* env, jclass clazz, jint numFrames, jdoubleArray frameTimes) {
+ JNIEnv* env, jclass /*clazz*/, jint workload, jint numFrames, jdoubleArray frameTimes) {
if (gRenderer == NULL) {
return false;
}
// Sets up the renderer.
- bool success = gRenderer->setUp();
+ bool success = gRenderer->setUp(workload);
// Records the start time.
double start = GLUtils::currentTimeMillis();
@@ -60,41 +68,56 @@
double times[] = {start, end};
env->SetDoubleArrayRegion(frameTimes, 0, 2, times);
- // Tears down and deletes the renderer.
success = gRenderer->tearDown() && success;
- delete gRenderer;
- gRenderer = NULL;
return success;
}
// The following functions create the renderers for the various benchmarks.
extern "C" JNIEXPORT void JNICALL
-Java_com_android_cts_opengl_primitive_GLPrimitiveActivity_setupFullPipelineBenchmark(
- JNIEnv* env, jclass clazz, jobject surface, jboolean offscreen, jint workload) {
- gRenderer = new FullPipelineRenderer(
- ANativeWindow_fromSurface(env, surface), offscreen, workload);
-}
-
-extern "C" JNIEXPORT void JNICALL
-Java_com_android_cts_opengl_primitive_GLPrimitiveActivity_setupPixelOutputBenchmark(
- JNIEnv* env, jclass clazz, jobject surface, jboolean offscreen, jint workload) {
- gRenderer = new PixelOutputRenderer(
- ANativeWindow_fromSurface(env, surface), offscreen, workload);
-}
-
-extern "C" JNIEXPORT void JNICALL
-Java_com_android_cts_opengl_primitive_GLPrimitiveActivity_setupShaderPerfBenchmark(
- JNIEnv* env, jclass clazz, jobject surface, jboolean offscreen, jint workload) {
- gRenderer = new ShaderPerfRenderer(
- ANativeWindow_fromSurface(env, surface), offscreen, workload);
-}
-
-extern "C" JNIEXPORT void JNICALL
-Java_com_android_cts_opengl_primitive_GLPrimitiveActivity_setupContextSwitchBenchmark(
- JNIEnv* env, jclass clazz, jobject surface, jboolean offscreen, jint workload) {
- if (workload <= 8) {
- // This test uses 8 iterations, so workload can't be more than 8.
- gRenderer = new ContextSwitchRenderer(
- ANativeWindow_fromSurface(env, surface), offscreen, workload);
+Java_com_android_cts_opengl_primitive_GLPrimitiveActivity_setupBenchmark(
+ JNIEnv* env, jclass /*clazz*/, jobject surface, jint benchmark,
+ jboolean offscreen) {
+ gNativeWindow = ANativeWindow_fromSurface(env, surface);
+ switch (benchmark) {
+ case FULL_PIPELINE_BENCHMARK:
+ gRenderer = new FullPipelineRenderer(gNativeWindow, offscreen);
+ break;
+ case PIXEL_OUTPUT_BENCHMARK:
+ gRenderer = new PixelOutputRenderer(gNativeWindow, offscreen);
+ break;
+ case SHADER_PERF_BENCHMARK:
+ gRenderer = new ShaderPerfRenderer(gNativeWindow, offscreen);
+ break;
+ case CONTEXT_SWITCH_BENCHMARK:
+ gRenderer = new ContextSwitchRenderer(gNativeWindow, offscreen);
+ break;
+ default:
+ ALOGE("Unknown benchmark '%d'", benchmark);
+ ANativeWindow_release(gNativeWindow);
+ gNativeWindow = NULL;
+ return;
}
+
+ // Set up call will log error conditions
+ if (!gRenderer->eglSetUp()) {
+ delete gRenderer;
+ gRenderer = NULL;
+
+ ANativeWindow_release(gNativeWindow);
+ gNativeWindow = NULL;
+ }
+}
+
+extern "C" JNIEXPORT void JNICALL
+Java_com_android_cts_opengl_primitive_GLPrimitiveActivity_tearDownBenchmark(
+ JNIEnv* /*env*/, jclass /*clazz*/) {
+ if (gRenderer == NULL) {
+ return;
+ }
+ gRenderer->eglTearDown();
+ delete gRenderer;
+ gRenderer = NULL;
+
+ ANativeWindow_release(gNativeWindow);
+ gNativeWindow = NULL;
}
diff --git a/suite/cts/deviceTests/opengl/jni/primitive/contextswitch/ContextSwitchRenderer.cpp b/suite/cts/deviceTests/opengl/jni/primitive/contextswitch/ContextSwitchRenderer.cpp
index 7fd4093..1127d88 100644
--- a/suite/cts/deviceTests/opengl/jni/primitive/contextswitch/ContextSwitchRenderer.cpp
+++ b/suite/cts/deviceTests/opengl/jni/primitive/contextswitch/ContextSwitchRenderer.cpp
@@ -74,13 +74,14 @@
" gl_FragColor = texture2D(u_Texture, v_TexCoord);"
"}";
-ContextSwitchRenderer::ContextSwitchRenderer(ANativeWindow* window, bool offscreen, int workload) :
- Renderer(window, offscreen, workload), mContexts(NULL) {
+ContextSwitchRenderer::ContextSwitchRenderer(ANativeWindow* window, bool offscreen) :
+ Renderer(window, offscreen), mContexts(NULL), mWorkload(0) {
}
-bool ContextSwitchRenderer::setUp() {
+bool ContextSwitchRenderer::setUp(int workload) {
SCOPED_TRACE();
- if (!Renderer::setUp()) {
+ mWorkload = workload;
+ if (!Renderer::setUp(workload)) {
return false;
}
@@ -137,7 +138,7 @@
bool ContextSwitchRenderer::tearDown() {
SCOPED_TRACE();
if (mContexts) {
- // Destroy the contexts, the main one will be handled by Renderer::tearDown().
+ // Destroy the contexts, the main one will be handled by Renderer::eglTearDown().
for (int i = 0; i < NUM_WORKER_CONTEXTS; i++) {
if (mOffscreen) {
if (mFboIds[i] != 0) {
@@ -146,6 +147,7 @@
mFboIds[i] = 0;
}
}
+ eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroyContext(mEglDisplay, mContexts[i]);
}
delete[] mContexts;
@@ -163,6 +165,11 @@
void ContextSwitchRenderer::drawWorkload() {
SCOPED_TRACE();
+
+ if (mWorkload > 8) {
+ return; // This test does not support higher workloads.
+ }
+
// Set the background clear color to black.
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
@@ -216,6 +223,7 @@
}
}
+ eglWaitSyncKHR(mEglDisplay, fence, 0);
eglDestroySyncKHR(mEglDisplay, fence);
// Switch back to the main context.
diff --git a/suite/cts/deviceTests/opengl/jni/primitive/contextswitch/ContextSwitchRenderer.h b/suite/cts/deviceTests/opengl/jni/primitive/contextswitch/ContextSwitchRenderer.h
index 51a4376..ae320ff 100644
--- a/suite/cts/deviceTests/opengl/jni/primitive/contextswitch/ContextSwitchRenderer.h
+++ b/suite/cts/deviceTests/opengl/jni/primitive/contextswitch/ContextSwitchRenderer.h
@@ -18,9 +18,9 @@
class ContextSwitchRenderer: public Renderer {
public:
- ContextSwitchRenderer(ANativeWindow* window, bool offscreen, int workload);
+ ContextSwitchRenderer(ANativeWindow* window, bool offscreen);
virtual ~ContextSwitchRenderer() {};
- bool setUp();
+ bool setUp(int workload);
bool tearDown();
void drawWorkload();
private:
@@ -31,6 +31,7 @@
GLuint mTranslateUniformHandle;
GLuint mPositionHandle;
GLuint mTexCoordHandle;
+ int mWorkload;
};
#endif
diff --git a/suite/cts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineRenderer.cpp b/suite/cts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineRenderer.cpp
index 97462b5..0f75f81 100644
--- a/suite/cts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineRenderer.cpp
+++ b/suite/cts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineRenderer.cpp
@@ -91,15 +91,15 @@
" gl_FragColor = (diffuse * texture2D(u_Texture, v_TexCoordinate));\n"
"}";
-FullPipelineRenderer::FullPipelineRenderer(ANativeWindow* window, bool offscreen, int workload) :
- Renderer(window, offscreen, workload), mProgram(NULL), mSceneGraph(NULL),
+FullPipelineRenderer::FullPipelineRenderer(ANativeWindow* window, bool offscreen) :
+ Renderer(window, offscreen), mProgram(NULL), mSceneGraph(NULL),
mModelMatrix(NULL), mViewMatrix(NULL), mProjectionMatrix(NULL), mMesh(NULL),
mTextureId(0) {
}
-bool FullPipelineRenderer::setUp() {
+bool FullPipelineRenderer::setUp(int workload) {
SCOPED_TRACE();
- if (!Renderer::setUp()) {
+ if (!Renderer::setUp(workload)) {
return false;
}
@@ -147,7 +147,7 @@
return false;
}
- float count = mWorkload * mWorkload;
+ float count = workload * workload;
float middle = count / 2.0f;
float scale = 2.0f / count;
diff --git a/suite/cts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineRenderer.h b/suite/cts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineRenderer.h
index 84616b4..ce44760 100644
--- a/suite/cts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineRenderer.h
+++ b/suite/cts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineRenderer.h
@@ -22,9 +22,9 @@
class FullPipelineRenderer: public Renderer {
public:
- FullPipelineRenderer(ANativeWindow* window, bool offscreen, int workload);
+ FullPipelineRenderer(ANativeWindow* window, bool offscreen);
virtual ~FullPipelineRenderer() {};
- bool setUp();
+ bool setUp(int workload);
bool tearDown();
void drawWorkload();
private:
diff --git a/suite/cts/deviceTests/opengl/jni/primitive/pixeloutput/PixelOutputRenderer.cpp b/suite/cts/deviceTests/opengl/jni/primitive/pixeloutput/PixelOutputRenderer.cpp
index 287ebfb..3a3b9d1 100644
--- a/suite/cts/deviceTests/opengl/jni/primitive/pixeloutput/PixelOutputRenderer.cpp
+++ b/suite/cts/deviceTests/opengl/jni/primitive/pixeloutput/PixelOutputRenderer.cpp
@@ -50,13 +50,14 @@
" gl_FragColor = texture2D(u_Texture, v_TexCoord);"
"}";
-PixelOutputRenderer::PixelOutputRenderer(ANativeWindow* window, bool offscreen, int workload) :
- Renderer(window, offscreen, workload) {
+PixelOutputRenderer::PixelOutputRenderer(ANativeWindow* window, bool offscreen) :
+ Renderer(window, offscreen), mWorkload(0) {
}
-bool PixelOutputRenderer::setUp() {
+bool PixelOutputRenderer::setUp(int workload) {
SCOPED_TRACE();
- if (!Renderer::setUp()) {
+ mWorkload = workload;
+ if (!Renderer::setUp(workload)) {
return false;
}
@@ -80,6 +81,11 @@
bool PixelOutputRenderer::tearDown() {
SCOPED_TRACE();
+ if (mProgramId != 0)
+ {
+ glDeleteProgram(mProgramId);
+ mProgramId = 0;
+ }
if (mTextureId != 0) {
glDeleteTextures(1, &mTextureId);
mTextureId = 0;
diff --git a/suite/cts/deviceTests/opengl/jni/primitive/pixeloutput/PixelOutputRenderer.h b/suite/cts/deviceTests/opengl/jni/primitive/pixeloutput/PixelOutputRenderer.h
index e6b5692..816da6a 100644
--- a/suite/cts/deviceTests/opengl/jni/primitive/pixeloutput/PixelOutputRenderer.h
+++ b/suite/cts/deviceTests/opengl/jni/primitive/pixeloutput/PixelOutputRenderer.h
@@ -18,9 +18,9 @@
class PixelOutputRenderer: public Renderer {
public:
- PixelOutputRenderer(ANativeWindow* window, bool offscreen, int workload);
+ PixelOutputRenderer(ANativeWindow* window, bool offscreen);
virtual ~PixelOutputRenderer() {};
- bool setUp();
+ bool setUp(int workload);
bool tearDown();
void drawWorkload();
private:
@@ -28,6 +28,7 @@
GLuint mTextureUniformHandle;
GLuint mPositionHandle;
GLuint mTexCoordHandle;
+ int mWorkload;
};
#endif
diff --git a/suite/cts/deviceTests/opengl/jni/primitive/shaderperf/ShaderPerfRenderer.cpp b/suite/cts/deviceTests/opengl/jni/primitive/shaderperf/ShaderPerfRenderer.cpp
index 1cbc839..a02f4fe 100644
--- a/suite/cts/deviceTests/opengl/jni/primitive/shaderperf/ShaderPerfRenderer.cpp
+++ b/suite/cts/deviceTests/opengl/jni/primitive/shaderperf/ShaderPerfRenderer.cpp
@@ -91,13 +91,13 @@
return destAddr - destStart;
}
-ShaderPerfRenderer::ShaderPerfRenderer(ANativeWindow* window, bool offscreen, int workload) :
- Renderer(window, offscreen, workload) {
+ShaderPerfRenderer::ShaderPerfRenderer(ANativeWindow* window, bool offscreen) :
+ Renderer(window, offscreen) {
}
-bool ShaderPerfRenderer::setUp() {
+bool ShaderPerfRenderer::setUp(int workload) {
SCOPED_TRACE();
- if (!Renderer::setUp()) {
+ if (!Renderer::setUp(workload)) {
return false;
}
@@ -106,7 +106,7 @@
// Add the first part.
int index = charCopy(SP_FRAGMENT_1, spFragment, 0);
// Add the count, overwriting the '\0' added by charCopy.
- spFragment[index - 1] = (char) (((int) '0') + mWorkload);
+ spFragment[index - 1] = (char) (((int) '0') + workload);
// Add the second part.
index += charCopy(SP_FRAGMENT_2, spFragment, index);
// Create program.
diff --git a/suite/cts/deviceTests/opengl/jni/primitive/shaderperf/ShaderPerfRenderer.h b/suite/cts/deviceTests/opengl/jni/primitive/shaderperf/ShaderPerfRenderer.h
index 52fac43..c804202 100644
--- a/suite/cts/deviceTests/opengl/jni/primitive/shaderperf/ShaderPerfRenderer.h
+++ b/suite/cts/deviceTests/opengl/jni/primitive/shaderperf/ShaderPerfRenderer.h
@@ -18,9 +18,9 @@
class ShaderPerfRenderer: public Renderer {
public:
- ShaderPerfRenderer(ANativeWindow* window, bool offscreen, int workload);
+ ShaderPerfRenderer(ANativeWindow* window, bool offscreen);
virtual ~ShaderPerfRenderer() {};
- bool setUp();
+ bool setUp(int workload);
void drawWorkload();
private:
GLuint mTextureId;
diff --git a/suite/cts/deviceTests/opengl/jni/reference/GLReference.cpp b/suite/cts/deviceTests/opengl/jni/reference/GLReference.cpp
index 1857848..dc0b4e2 100644
--- a/suite/cts/deviceTests/opengl/jni/reference/GLReference.cpp
+++ b/suite/cts/deviceTests/opengl/jni/reference/GLReference.cpp
@@ -23,7 +23,7 @@
extern "C" JNIEXPORT jboolean JNICALL
Java_com_android_cts_opengl_reference_GLGameActivity_startBenchmark(
- JNIEnv* env, jclass clazz, jobject assetManager, jobject surface, jint numFrames,
+ JNIEnv* env, jclass /*clazz*/, jobject assetManager, jobject surface, jint numFrames,
jdoubleArray setUpTimes, jdoubleArray updateTimes, jdoubleArray renderTimes) {
GLUtils::setEnvAndAssetManager(env, assetManager);
@@ -32,9 +32,10 @@
return false;
}
- ReferenceRenderer* renderer = new ReferenceRenderer(ANativeWindow_fromSurface(env, surface));
-
- bool success = renderer->setUp();
+ ANativeWindow* nativeWindow = ANativeWindow_fromSurface(env, surface);
+ ReferenceRenderer* renderer = new ReferenceRenderer(nativeWindow);
+ bool success = renderer->eglSetUp();
+ success = renderer->setUp(0) && success;
env->SetDoubleArrayRegion(
setUpTimes, 0, ReferenceRenderer::NUM_SETUP_TIMES, renderer->mSetUpTimes);
@@ -54,7 +55,11 @@
env->SetDoubleArrayRegion(renderTimes, 0, numFrames, renders);
success = renderer->tearDown() && success;
+ renderer->eglTearDown();
delete renderer;
renderer = NULL;
+
+ ANativeWindow_release(nativeWindow);
+
return success;
}
diff --git a/suite/cts/deviceTests/opengl/jni/reference/ReferenceRenderer.cpp b/suite/cts/deviceTests/opengl/jni/reference/ReferenceRenderer.cpp
index 8f7703e..3b12ee1 100644
--- a/suite/cts/deviceTests/opengl/jni/reference/ReferenceRenderer.cpp
+++ b/suite/cts/deviceTests/opengl/jni/reference/ReferenceRenderer.cpp
@@ -22,10 +22,10 @@
#include <Trace.h>
ReferenceRenderer::ReferenceRenderer(ANativeWindow* window) :
- Renderer(window, false, 0) {
+ Renderer(window, false) {
}
-bool ReferenceRenderer::setUp() {
+bool ReferenceRenderer::setUp(int workload) {
SCOPED_TRACE();
// Reset the times.
for (int i = 0; i < NUM_SETUP_TIMES; i++) {
@@ -33,7 +33,7 @@
}
// Set up OpenGLES.
double start = GLUtils::currentTimeMillis();
- if (!Renderer::setUp()) {
+ if (!Renderer::setUp(workload)) {
return false;
}
mSetUpTimes[0] = GLUtils::currentTimeMillis() - start;
diff --git a/suite/cts/deviceTests/opengl/jni/reference/ReferenceRenderer.h b/suite/cts/deviceTests/opengl/jni/reference/ReferenceRenderer.h
index d10297a..f5c4b65 100644
--- a/suite/cts/deviceTests/opengl/jni/reference/ReferenceRenderer.h
+++ b/suite/cts/deviceTests/opengl/jni/reference/ReferenceRenderer.h
@@ -23,7 +23,7 @@
public:
ReferenceRenderer(ANativeWindow* window);
virtual ~ReferenceRenderer() {};
- bool setUp();
+ bool setUp(int workload);
bool tearDown();
bool update(int frame);
void drawWorkload();
diff --git a/suite/cts/deviceTests/opengl/src/com/android/cts/opengl/primitive/GLPrimitiveActivity.java b/suite/cts/deviceTests/opengl/src/com/android/cts/opengl/primitive/GLPrimitiveActivity.java
index 5dc9b88..6defdb7 100644
--- a/suite/cts/deviceTests/opengl/src/com/android/cts/opengl/primitive/GLPrimitiveActivity.java
+++ b/suite/cts/deviceTests/opengl/src/com/android/cts/opengl/primitive/GLPrimitiveActivity.java
@@ -102,19 +102,12 @@
}
}
- private static native void setupFullPipelineBenchmark(
- Surface surface, boolean offscreen, int workload);
+ private static native boolean setupBenchmark(
+ Surface surface, int benchmark, boolean offscreen);
- private static native void setupPixelOutputBenchmark(
- Surface surface, boolean offscreen, int workload);
+ private static native boolean startBenchmark(int workload, int numFrames, double[] frameTimes);
- private static native void setupShaderPerfBenchmark(
- Surface surface, boolean offscreen, int workload);
-
- private static native void setupContextSwitchBenchmark(
- Surface surface, boolean offscreen, int workload);
-
- private static native boolean startBenchmark(int numFrames, double[] frameTimes);
+ private static native void tearDownBenchmark();
/**
* This thread runs the benchmarks, freeing the UI thread.
@@ -138,36 +131,29 @@
watchDog = new WatchDog(mTimeout, this);
// Used to record the start and end time of the iteration.
double[] times = new double[2];
- for (int i = 0; i < mNumIterations && success; i++) {
- // The workload to use for this iteration.
- int workload = i + 1;
+ try {
// Setup the benchmark.
- switch (mBenchmark) {
- case FullPipeline:
- setupFullPipelineBenchmark(mSurface, mOffscreen, workload);
- break;
- case PixelOutput:
- setupPixelOutputBenchmark(mSurface, mOffscreen, workload);
- break;
- case ShaderPerf:
- setupShaderPerfBenchmark(mSurface, mOffscreen, workload);
- break;
- case ContextSwitch:
- setupContextSwitchBenchmark(mSurface, mOffscreen, workload);
- break;
- }
- watchDog.start();
- // Start benchmark.
- success = startBenchmark(mNumFrames, times);
- watchDog.stop();
-
- if (!success) {
- setException(new Exception("Benchmark failed to run"));
- } else {
- // Calculate FPS.
- mFpsValues[i] = mNumFrames * 1000.0f / (times[1] - times[0]);
+ setupBenchmark(mSurface, mBenchmark.ordinal(), mOffscreen);
+ for (int i = 0; i < mNumIterations && success; i++) {
+ // The workload to use for this iteration.
+ int workload = i + 1;
+ watchDog.start();
+ // Start benchmark.
+ success = startBenchmark(workload, mNumFrames, times);
+ watchDog.stop();
+ if (!success) {
+ setException(new Exception("Benchmark failed to run"));
+ } else {
+ // Calculate FPS.
+ mFpsValues[i] = mNumFrames * 1000.0f / (times[1] - times[0]);
+ }
}
}
+ finally
+ {
+ tearDownBenchmark();
+ }
+
complete();
Log.i(TAG, mBenchmark + " Benchmark Completed");
}
diff --git a/tests/expectations/knownfailures.txt b/tests/expectations/knownfailures.txt
index 409e1a2..6ce548a 100644
--- a/tests/expectations/knownfailures.txt
+++ b/tests/expectations/knownfailures.txt
@@ -158,6 +158,14 @@
bug: 17508787
},
{
+ description: "This test should be outside of official CTS suite until it is verified for all Nexus devices",
+ names: [
+ "com.android.cts.devicepolicy.MixedDeviceOwnerTest#testPackageInstallUserRestrictions",
+ "com.android.cts.devicepolicy.MixedProfileOwnerTest#testPackageInstallUserRestrictions"
+ ],
+ bug: 18928535
+},
+{
description: "Test is not yet properly implemented",
names: [
"android.voicesettings.cts.ZenModeTest#testAll"
diff --git a/tests/tests/alarmclock/src/android/alarmclock/cts/AlarmClockTestBase.java b/tests/tests/alarmclock/src/android/alarmclock/cts/AlarmClockTestBase.java
index 0089e69..4e5b4ce 100644
--- a/tests/tests/alarmclock/src/android/alarmclock/cts/AlarmClockTestBase.java
+++ b/tests/tests/alarmclock/src/android/alarmclock/cts/AlarmClockTestBase.java
@@ -23,6 +23,8 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.PackageManager;
+import android.provider.AlarmClock;
import android.os.Bundle;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
@@ -68,8 +70,40 @@
new IntentFilter(Utils.BROADCAST_INTENT + testCaseType.toString()));
}
+ private boolean isIntentAupported(TestcaseType testCaseType) {
+ Intent intent;
+ switch (testCaseType) {
+ case DISMISS_ALARM:
+ intent = new Intent(AlarmClock.ACTION_DISMISS_ALARM);
+ break;
+
+ case SET_ALARM:
+ case SET_ALARM_FOR_DISMISSAL:
+ intent = new Intent(AlarmClock.ACTION_SET_ALARM);
+ break;
+
+ case SNOOZE_ALARM:
+ intent = new Intent(AlarmClock.ACTION_SNOOZE_ALARM);
+ break;
+
+ default:
+ // shouldn't happen
+ return false;
+ }
+ final PackageManager manager = mContext.getPackageManager();
+ assertNotNull(manager);
+ if (manager.resolveActivity(intent, 0) == null) {
+ Log.i(TAG, "No Voice Activity found for the intent: " + intent.getAction());
+ return false;
+ }
+ return true;
+ }
+
protected String runTest(TestcaseType testCaseType) throws Exception {
Log.i(TAG, "Begin Testing: " + testCaseType);
+ // Make sure the corresponding intent is supported by the platform, before testing.
+ if (!isIntentAupported(testCaseType)) return Utils.COMPLETION_RESULT;
+
if (!startTestActivity(testCaseType)) {
fail("test activity start failed for testcase = " + testCaseType);
return "";
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeScanTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeScanTest.java
index a79df42..cc444a6 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeScanTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeScanTest.java
@@ -249,7 +249,9 @@
@Override
public void onBatchScanResults(List<ScanResult> results) {
- mBatchScanResults = results;
+ // In case onBatchScanResults are called due to buffer full, we want to collect all
+ // scan results.
+ mBatchScanResults.addAll(results);
}
// Clear regular and batch scan results.
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorEnvironment.java b/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorEnvironment.java
index 6156d3d..47c8313 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorEnvironment.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorEnvironment.java
@@ -223,7 +223,7 @@
if (mSamplingPeriodUs == SensorManager.SENSOR_DELAY_FASTEST) {
return "fastest";
}
- return String.format("%.0fhz", getFrequencyHz());
+ return String.format("%.2fhz", getFrequencyHz());
}
/**
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/FrequencyVerification.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/FrequencyVerification.java
index cf34f28..2f4777b 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/FrequencyVerification.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/FrequencyVerification.java
@@ -128,9 +128,9 @@
stats.addValue(SensorStats.FREQUENCY_KEY, measuredFrequencyHz);
stats.addValue(PASSED_KEY, !failed);
String resultString = String.format(
- "Requested \"%s\" at %.2fHz (expecting between %.2fHz and %.2fHz, measured %.2fHz)",
+ "Requested \"%s\" at %s (expecting between %.2fHz and %.2fHz, measured %.2fHz)",
environment.getSensor().getName(),
- environment.getFrequencyHz(),
+ environment.getFrequencyString(),
mLowerThresholdHz,
mUpperThresholdHz,
measuredFrequencyHz);
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/StandardDeviationVerification.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/StandardDeviationVerification.java
index 1e1c950..1b66e6a 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/StandardDeviationVerification.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/StandardDeviationVerification.java
@@ -24,8 +24,10 @@
import android.hardware.cts.helpers.SensorStats;
import android.hardware.cts.helpers.TestSensorEnvironment;
import android.hardware.cts.helpers.TestSensorEvent;
+import android.hardware.cts.helpers.SensorCtsHelper;
import android.util.Log;
+import java.util.concurrent.TimeUnit;
import java.util.HashMap;
import java.util.Map;
@@ -66,18 +68,37 @@
*/
public static StandardDeviationVerification getDefault(TestSensorEnvironment environment) {
int sensorType = environment.getSensor().getType();
- float mGraceFactorAccelGyro = 2.0f;
- float mGraceFactorMagPressure = 4.0f;
- float mMaxBandWidth = (float) environment.getFrequencyHz();
- float mAccelNoise = (float)(mGraceFactorAccelGyro * Math.sqrt(mMaxBandWidth) * (9.81 * 0.0004));
- float mGyroNoise = (float)(mGraceFactorAccelGyro * Math.sqrt(mMaxBandWidth) * (Math.PI/180.0 * 0.014));
- float mMagNoise = (float)((mGraceFactorMagPressure) * 0.5); // Allow extra grace for mag
- float mPressureNoise = (float)(mGraceFactorMagPressure * 0.02 * (float)Math.sqrt(mMaxBandWidth)); // Allow extra grace for pressure
+ float graceFactorAccelGyro = 2.0f;
+ float graceFactorMagPressure = 4.0f;
+ float currOperatingFreq = (float) environment.getFrequencyHz();
+ float maxBandWidth = (float)SensorCtsHelper.getFrequency(
+ environment.getSensor().getMinDelay(), TimeUnit.MICROSECONDS);
+ float minBandWidth = (float) SensorCtsHelper.getFrequency(
+ environment.getSensor().getMaxDelay(), TimeUnit.MICROSECONDS);
+
+ if (Float.isInfinite(currOperatingFreq)) {
+ currOperatingFreq = maxBandWidth;
+ }
+
+ if (currOperatingFreq > maxBandWidth && !Float.isInfinite(maxBandWidth)) {
+ currOperatingFreq = maxBandWidth;
+ }
+
+ if (currOperatingFreq < minBandWidth && !Float.isInfinite(minBandWidth)) {
+ currOperatingFreq = minBandWidth;
+ }
+
+ float mAccelNoise = (float)(graceFactorAccelGyro * Math.sqrt(currOperatingFreq) *
+ (9.81 * 0.0004));
+ float mGyroNoise = (float)(graceFactorAccelGyro * Math.sqrt(currOperatingFreq) *
+ (Math.PI/180.0 * 0.014));
+ float mMagNoise = (float)((graceFactorMagPressure) * 0.5); // Allow extra grace for mag
+ float mPressureNoise = (float)(graceFactorMagPressure * 0.02 *
+ (float)Math.sqrt(currOperatingFreq)); // Allow extra grace for pressure
if (!DEFAULTS.containsKey(sensorType)) {
return null;
}
-
boolean hasHifiSensors = environment.getContext().getPackageManager().hasSystemFeature(
PackageManager.FEATURE_HIFI_SENSORS);
@@ -132,9 +153,9 @@
if (stdDevs[i] > mThreshold[i]) {
failed = true;
}
- stddevSb.append(String.format("%.3f", stdDevs[i]));
+ stddevSb.append(String.format("%.6f", stdDevs[i]));
if (i != stdDevs.length - 1) stddevSb.append(", ");
- expectedSb.append(String.format("<%.3f", mThreshold[i]));
+ expectedSb.append(String.format("<%.6f", mThreshold[i]));
if (i != stdDevs.length - 1) expectedSb.append(", ");
}
if (stdDevs.length > 1) {
diff --git a/tests/tests/os/src/android/os/cts/CpuFeaturesTest.java b/tests/tests/os/src/android/os/cts/CpuFeaturesTest.java
index 0b389a4..ecdb399 100644
--- a/tests/tests/os/src/android/os/cts/CpuFeaturesTest.java
+++ b/tests/tests/os/src/android/os/cts/CpuFeaturesTest.java
@@ -82,7 +82,7 @@
}
private static final String[] armv8RequiredFeatures = {
- "wp", "half", "thumb", "fastmult", "vfp", "edsp", "neon",
+ "half", "thumb", "fastmult", "vfp", "edsp", "neon",
"vfpv3", "tlsi", "vfpv4", "idiva", "idivt" };
private static void assertInCpuinfo(List<String> features,
diff --git a/tests/tests/permission/src/android/permission/cts/ConnectivityManagerPermissionTest.java b/tests/tests/permission/src/android/permission/cts/ConnectivityManagerPermissionTest.java
index 8714100..a95c96e 100644
--- a/tests/tests/permission/src/android/permission/cts/ConnectivityManagerPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/ConnectivityManagerPermissionTest.java
@@ -53,21 +53,4 @@
// expected
}
}
-
- /**
- * Verify that calling {@link ConnectivityManager#requestRouteToHost(int, int)}
- * requires permissions.
- * <p>Tests Permission:
- * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
- */
- @SmallTest
- public void testRequestRouteToHost() {
- try {
- mConnectivityManager.requestRouteToHost(ConnectivityManager.TYPE_MOBILE, 1);
- fail("Was able to call requestRouteToHost");
- } catch (SecurityException e) {
- // expected
- }
- }
}
-
diff --git a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
index cf6a09d..0962bbd 100644
--- a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
@@ -251,7 +251,6 @@
@MediumTest
public void testProcSelfOomAdjSane() {
File f = new File("/proc/self/oom_adj");
- assertTrue(f.canRead());
assertFalse(f.canWrite());
assertFalse(f.canExecute());
}
@@ -259,7 +258,6 @@
@MediumTest
public void testProcSelfOomScoreAdjSane() {
File f = new File("/proc/self/oom_score_adj");
- assertTrue(f.canRead());
assertFalse(f.canWrite());
assertFalse(f.canExecute());
}
diff --git a/tests/tests/telecom/src/android/telecom/cts/BaseRemoteTelecomTest.java b/tests/tests/telecom/src/android/telecom/cts/BaseRemoteTelecomTest.java
index 00a56ac..3a0dbd3 100644
--- a/tests/tests/telecom/src/android/telecom/cts/BaseRemoteTelecomTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/BaseRemoteTelecomTest.java
@@ -52,17 +52,20 @@
@Override
protected void tearDown() throws Exception {
if (mShouldTestTelecom) {
- tearDownConnectionServices(TEST_PHONE_ACCOUNT_HANDLE, TEST_REMOTE_PHONE_ACCOUNT_HANDLE);
+ tearDownRemoteConnectionService(TEST_REMOTE_PHONE_ACCOUNT_HANDLE);
}
super.tearDown();
}
protected void setupConnectionServices(MockConnectionService connectionService,
- MockConnectionService remoteConnectionService, int flags)
- throws Exception {
+ MockConnectionService remoteConnectionService, int flags) throws Exception {
// Setup the primary connection service first
setupConnectionService(connectionService, flags);
+ setupRemoteConnectionService(remoteConnectionService, flags);
+ }
+ protected void setupRemoteConnectionService(MockConnectionService remoteConnectionService,
+ int flags) throws Exception {
if (remoteConnectionService != null) {
this.remoteConnectionService = remoteConnectionService;
} else {
@@ -78,19 +81,23 @@
TEST_REMOTE_PHONE_ACCOUNT_HANDLE,
REMOTE_ACCOUNT_LABEL,
TEST_REMOTE_PHONE_ACCOUNT_ADDRESS);
+ // Wait till the adb commands have executed and account is in Telecom database.
+ assertPhoneAccountRegistered(TEST_REMOTE_PHONE_ACCOUNT_HANDLE);
}
if ((flags & FLAG_ENABLE) != 0) {
TestUtils.enablePhoneAccount(getInstrumentation(), TEST_REMOTE_PHONE_ACCOUNT_HANDLE);
+ // Wait till the adb commands have executed and account is enabled in Telecom database.
+ assertPhoneAccountEnabled(TEST_REMOTE_PHONE_ACCOUNT_HANDLE);
}
}
- protected void tearDownConnectionServices(PhoneAccountHandle accountHandle,
- PhoneAccountHandle remoteAccountHandle) throws Exception {
- // Teardown the primary connection service first
- tearDownConnectionService(accountHandle);
-
+ protected void tearDownRemoteConnectionService(PhoneAccountHandle remoteAccountHandle)
+ throws Exception {
+ assertNumConnections(this.remoteConnectionService, 0);
mTelecomManager.unregisterPhoneAccount(remoteAccountHandle);
CtsRemoteConnectionService.tearDown();
+ //Telecom doesn't unbind the remote connection service at the end of all calls today.
+ //assertCtsRemoteConnectionServiceUnbound();
this.remoteConnectionService = null;
}
@@ -210,4 +217,22 @@
"Remote Conference should be in state " + state
);
}
+
+ void assertCtsRemoteConnectionServiceUnbound() {
+ waitUntilConditionIsTrueOrTimeout(
+ new Condition() {
+ @Override
+ public Object expected(){
+ return true;
+ }
+
+ @Override
+ public Object actual() {
+ return CtsRemoteConnectionService.isServiceUnbound();
+ }
+ },
+ WAIT_FOR_STATE_CHANGE_TIMEOUT_MS,
+ "CtsRemoteConnectionService not yet unbound!"
+ );
+ }
}
diff --git a/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java b/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
index 31ca09b..d7fe239 100644
--- a/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
+++ b/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
@@ -110,13 +110,13 @@
TestUtils.setDefaultDialer(getInstrumentation(), mPreviousDefaultDialer);
}
tearDownConnectionService(TEST_PHONE_ACCOUNT_HANDLE);
+ assertMockInCallServiceUnbound();
}
super.tearDown();
}
protected PhoneAccount setupConnectionService(MockConnectionService connectionService,
- int flags)
- throws Exception {
+ int flags) throws Exception {
if (connectionService != null) {
this.connectionService = connectionService;
} else {
@@ -130,14 +130,18 @@
}
if ((flags & FLAG_ENABLE) != 0) {
TestUtils.enablePhoneAccount(getInstrumentation(), TEST_PHONE_ACCOUNT_HANDLE);
+ // Wait till the adb commands have executed and account is enabled in Telecom database.
+ assertPhoneAccountEnabled(TEST_PHONE_ACCOUNT_HANDLE);
}
return TEST_PHONE_ACCOUNT;
}
protected void tearDownConnectionService(PhoneAccountHandle accountHandle) throws Exception {
+ assertNumConnections(this.connectionService, 0);
mTelecomManager.unregisterPhoneAccount(accountHandle);
CtsConnectionService.tearDown();
+ assertCtsConnectionServiceUnbound();
this.connectionService = null;
}
@@ -513,6 +517,22 @@
}
+ void assertNumConnections(final MockConnectionService connService, final int numConnections) {
+ waitUntilConditionIsTrueOrTimeout(new Condition() {
+ @Override
+ public Object expected() {
+ return numConnections;
+ }
+ @Override
+ public Object actual() {
+ return connService.getAllConnections().size();
+ }
+ },
+ WAIT_FOR_STATE_CHANGE_TIMEOUT_MS,
+ "ConnectionService should contain " + numConnections + " connections."
+ );
+ }
+
void assertMuteState(final InCallService incallService, final boolean isMuted) {
waitUntilConditionIsTrueOrTimeout(
new Condition() {
@@ -621,7 +641,7 @@
}
},
WAIT_FOR_STATE_CHANGE_TIMEOUT_MS,
- "Call should be in state " + state
+ "Call: " + call + " should be in state " + state
);
}
@@ -731,6 +751,79 @@
);
}
+ void assertPhoneAccountRegistered(final PhoneAccountHandle handle) {
+ waitUntilConditionIsTrueOrTimeout(
+ new Condition() {
+ @Override
+ public Object expected() {
+ return true;
+ }
+
+ @Override
+ public Object actual() {
+ return mTelecomManager.getPhoneAccount(handle) != null;
+ }
+ },
+ WAIT_FOR_STATE_CHANGE_TIMEOUT_MS,
+ "Phone account registration failed for " + handle
+ );
+ }
+
+ void assertPhoneAccountEnabled(final PhoneAccountHandle handle) {
+ waitUntilConditionIsTrueOrTimeout(
+ new Condition() {
+ @Override
+ public Object expected() {
+ return true;
+ }
+
+ @Override
+ public Object actual() {
+ PhoneAccount phoneAccount = mTelecomManager.getPhoneAccount(handle);
+ return (phoneAccount != null && phoneAccount.isEnabled());
+ }
+ },
+ WAIT_FOR_STATE_CHANGE_TIMEOUT_MS,
+ "Phone account enable failed for " + handle
+ );
+ }
+
+ void assertCtsConnectionServiceUnbound() {
+ waitUntilConditionIsTrueOrTimeout(
+ new Condition() {
+ @Override
+ public Object expected() {
+ return true;
+ }
+
+ @Override
+ public Object actual() {
+ return CtsConnectionService.isServiceUnbound();
+ }
+ },
+ WAIT_FOR_STATE_CHANGE_TIMEOUT_MS,
+ "CtsConnectionService not yet unbound!"
+ );
+ }
+
+ void assertMockInCallServiceUnbound() {
+ waitUntilConditionIsTrueOrTimeout(
+ new Condition() {
+ @Override
+ public Object expected() {
+ return true;
+ }
+
+ @Override
+ public Object actual() {
+ return MockInCallService.isServiceUnbound();
+ }
+ },
+ WAIT_FOR_STATE_CHANGE_TIMEOUT_MS,
+ "MockInCallService not yet unbound!"
+ );
+ }
+
void waitUntilConditionIsTrueOrTimeout(Condition condition, long timeout,
String description) {
final long start = System.currentTimeMillis();
diff --git a/tests/tests/telecom/src/android/telecom/cts/ConferenceTest.java b/tests/tests/telecom/src/android/telecom/cts/ConferenceTest.java
index 121d559..508870c 100644
--- a/tests/tests/telecom/src/android/telecom/cts/ConferenceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/ConferenceTest.java
@@ -50,7 +50,6 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- mContext = getInstrumentation().getContext();
if (mShouldTestTelecom) {
addOutgoingCalls();
addConferenceCall(mCall1, mCall2);
diff --git a/tests/tests/telecom/src/android/telecom/cts/ConnectionServiceTest.java b/tests/tests/telecom/src/android/telecom/cts/ConnectionServiceTest.java
index afaa3eb..836ca48 100644
--- a/tests/tests/telecom/src/android/telecom/cts/ConnectionServiceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/ConnectionServiceTest.java
@@ -48,20 +48,13 @@
placeAndVerifyCall();
verifyConnectionForOutgoingCall();
+ // Add second connection (add existing connection)
final MockConnection connection = new MockConnection();
connection.setOnHold();
CtsConnectionService.addExistingConnectionToTelecom(TEST_PHONE_ACCOUNT_HANDLE, connection);
-
- try {
- if (!mInCallCallbacks.lock.tryAcquire(3, TimeUnit.SECONDS)) {
- fail("No call added to InCallService.");
- }
- } catch (InterruptedException e) {
- Log.i(TAG, "Test interrupted!");
- }
-
- final MockInCallService inCallService = mInCallCallbacks.getService();
- final Call call = inCallService.getLastCall();
+ assertNumCalls(mInCallCallbacks.getService(), 2);
+ mInCallCallbacks.lock.drainPermits();
+ final Call call = mInCallCallbacks.getService().getLastCall();
assertCallState(call, Call.STATE_HOLDING);
}
@@ -77,17 +70,22 @@
Collection<Connection> connections = CtsConnectionService.getAllConnectionsFromTelecom();
assertEquals(1, connections.size());
assertTrue(connections.contains(connection1));
+ // Need to move this to active since we reject the 3rd incoming call below if this is in
+ // dialing state (b/23428950).
+ connection1.setActive();
+ assertCallState(mInCallCallbacks.getService().getLastCall(), Call.STATE_ACTIVE);
// Add second connection (add existing connection)
final Connection connection2 = new MockConnection();
CtsConnectionService.addExistingConnectionToTelecom(TEST_PHONE_ACCOUNT_HANDLE, connection2);
-
+ assertNumCalls(mInCallCallbacks.getService(), 2);
+ mInCallCallbacks.lock.drainPermits();
connections = CtsConnectionService.getAllConnectionsFromTelecom();
assertEquals(2, connections.size());
assertTrue(connections.contains(connection2));
// Add third connection (incoming call)
- addAndVerifyNewIncomingCall(getTestNumber(), null);
+ addAndVerifyNewIncomingCall(createTestNumber(), null);
final Connection connection3 = verifyConnectionForIncomingCall();
connections = CtsConnectionService.getAllConnectionsFromTelecom();
assertEquals(3, connections.size());
diff --git a/tests/tests/telecom/src/android/telecom/cts/CtsConnectionService.java b/tests/tests/telecom/src/android/telecom/cts/CtsConnectionService.java
index 3c30e6b..d8d5773 100644
--- a/tests/tests/telecom/src/android/telecom/cts/CtsConnectionService.java
+++ b/tests/tests/telecom/src/android/telecom/cts/CtsConnectionService.java
@@ -16,6 +16,9 @@
package android.telecom.cts;
+import static org.junit.Assert.assertFalse;
+
+import android.content.Intent;
import android.telecom.Conference;
import android.telecom.Connection;
import android.telecom.ConnectionRequest;
@@ -23,6 +26,7 @@
import android.telecom.PhoneAccountHandle;
import android.telecom.RemoteConference;
import android.telecom.RemoteConnection;
+import android.util.Log;
import java.util.Collection;
@@ -43,10 +47,12 @@
*
*/
public class CtsConnectionService extends ConnectionService {
+ private static String LOG_TAG = "CtsConnectionService";
// This is the connection service implemented by the test
private static ConnectionService sConnectionService;
// This is the connection service registered with Telecom
private static ConnectionService sTelecomConnectionService;
+ private static boolean mIsServiceUnbound;
public CtsConnectionService() throws Exception {
super();
@@ -65,13 +71,14 @@
private static Object sLock = new Object();
public static void setUp(PhoneAccountHandle phoneAccountHandle,
- ConnectionService connectionService)
- throws Exception {
+ ConnectionService connectionService) throws Exception {
synchronized(sLock) {
if (sConnectionService != null) {
throw new Exception("Mock ConnectionService exists. Failed to call tearDown().");
}
sConnectionService = connectionService;
+ // Cant override the onBind method for ConnectionService, so reset it here.
+ mIsServiceUnbound = false;
}
}
@@ -178,4 +185,16 @@
}
}
}
+
+ @Override
+ public boolean onUnbind(Intent intent) {
+ Log.i(LOG_TAG, "Service unbounded");
+ assertFalse(mIsServiceUnbound);
+ mIsServiceUnbound = true;
+ return super.onUnbind(intent);
+ }
+
+ public static boolean isServiceUnbound() {
+ return mIsServiceUnbound;
+ }
}
diff --git a/tests/tests/telecom/src/android/telecom/cts/CtsRemoteConnectionService.java b/tests/tests/telecom/src/android/telecom/cts/CtsRemoteConnectionService.java
index 3738487..13b525f 100644
--- a/tests/tests/telecom/src/android/telecom/cts/CtsRemoteConnectionService.java
+++ b/tests/tests/telecom/src/android/telecom/cts/CtsRemoteConnectionService.java
@@ -16,11 +16,15 @@
package android.telecom.cts;
+import static org.junit.Assert.assertFalse;
+
+import android.content.Intent;
import android.telecom.Conference;
import android.telecom.Connection;
import android.telecom.ConnectionRequest;
import android.telecom.ConnectionService;
import android.telecom.PhoneAccountHandle;
+import android.util.Log;
/**
* This is the Remote ConnectionService for Telecom's CTS App. Since telecom requires that a
@@ -39,10 +43,12 @@
*
*/
public class CtsRemoteConnectionService extends ConnectionService {
+ private static String LOG_TAG = "CtsConnectionService";
// This is the connection service implemented by the test
private static ConnectionService sConnectionService;
// This is the connection service registered with Telecom
private static ConnectionService sTelecomConnectionService;
+ private static boolean mIsServiceUnbound;
public CtsRemoteConnectionService() throws Exception {
super();
@@ -64,13 +70,14 @@
private static Object sLock = new Object();
public static void setUp(PhoneAccountHandle phoneAccountHandle,
- ConnectionService connectionService)
- throws Exception {
+ ConnectionService connectionService) throws Exception {
synchronized(sLock) {
if (sConnectionService != null) {
throw new Exception("Mock ConnectionService exists. Failed to call tearDown().");
}
sConnectionService = connectionService;
+ // Cant override the onBind method for ConnectionService, so reset it here.
+ mIsServiceUnbound = false;
}
}
@@ -124,4 +131,16 @@
sTelecomConnectionService.addConference(conference);
}
}
+
+ @Override
+ public boolean onUnbind(Intent intent) {
+ Log.i(LOG_TAG, "Service unbounded");
+ assertFalse(mIsServiceUnbound);
+ mIsServiceUnbound = true;
+ return super.onUnbind(intent);
+ }
+
+ public static boolean isServiceUnbound() {
+ return mIsServiceUnbound;
+ }
}
diff --git a/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java b/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java
index 19d27af..02d2f15 100644
--- a/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java
@@ -188,7 +188,7 @@
return;
}
- addAndVerifyNewIncomingCall(getTestNumber(), null);
+ addAndVerifyNewIncomingCall(createTestNumber(), null);
final MockConnection connection = verifyConnectionForIncomingCall();
final MockInCallService inCallService = mInCallCallbacks.getService();
@@ -209,7 +209,7 @@
return;
}
- addAndVerifyNewIncomingCall(getTestNumber(), null);
+ addAndVerifyNewIncomingCall(createTestNumber(), null);
final MockConnection connection = verifyConnectionForIncomingCall();
final MockInCallService inCallService = mInCallCallbacks.getService();
@@ -232,7 +232,7 @@
return;
}
- addAndVerifyNewIncomingCall(getTestNumber(), null);
+ addAndVerifyNewIncomingCall(createTestNumber(), null);
final MockConnection connection = verifyConnectionForIncomingCall();
final MockInCallService inCallService = mInCallCallbacks.getService();
@@ -390,7 +390,7 @@
return;
}
- addAndVerifyNewIncomingCall(getTestNumber(), null);
+ addAndVerifyNewIncomingCall(createTestNumber(), null);
verifyConnectionForIncomingCall();
final MockInCallService inCallService = mInCallCallbacks.getService();
@@ -428,7 +428,7 @@
assertEquals("InCallService.getCalls() should return list with 1 call.", 1, calls.size());
assertEquals(call1, calls.get(0));
- addAndVerifyNewIncomingCall(getTestNumber(), null);
+ addAndVerifyNewIncomingCall(createTestNumber(), null);
verifyConnectionForIncomingCall();
final Call call2 = inCallService.getLastCall();
diff --git a/tests/tests/telecom/src/android/telecom/cts/MockConnection.java b/tests/tests/telecom/src/android/telecom/cts/MockConnection.java
index d556baa..9bb83a1 100644
--- a/tests/tests/telecom/src/android/telecom/cts/MockConnection.java
+++ b/tests/tests/telecom/src/android/telecom/cts/MockConnection.java
@@ -66,6 +66,7 @@
if (mRemoteConnection != null) {
mRemoteConnection.reject();
}
+ destroy();
}
@Override
@@ -90,18 +91,20 @@
public void onDisconnect() {
super.onDisconnect();
setDisconnected(new DisconnectCause(DisconnectCause.LOCAL));
- destroy();
if (mRemoteConnection != null) {
mRemoteConnection.disconnect();
}
+ destroy();
}
@Override
public void onAbort() {
super.onAbort();
+ setDisconnected(new DisconnectCause(DisconnectCause.UNKNOWN));
if (mRemoteConnection != null) {
mRemoteConnection.abort();
}
+ destroy();
}
@Override
diff --git a/tests/tests/telecom/src/android/telecom/cts/MockInCallService.java b/tests/tests/telecom/src/android/telecom/cts/MockInCallService.java
index 1856603..0f1f538 100644
--- a/tests/tests/telecom/src/android/telecom/cts/MockInCallService.java
+++ b/tests/tests/telecom/src/android/telecom/cts/MockInCallService.java
@@ -16,10 +16,14 @@
package android.telecom.cts;
+import static org.junit.Assert.assertFalse;
+
+import android.content.Intent;
import android.telecom.Call;
import android.telecom.CallAudioState;
import android.telecom.InCallService;
import android.util.ArrayMap;
+import android.util.Log;
import java.util.ArrayList;
import java.util.List;
@@ -27,6 +31,7 @@
import java.util.concurrent.Semaphore;
public class MockInCallService extends InCallService {
+ private static String LOG_TAG = "MockInCallService";
private ArrayList<Call> mCalls = new ArrayList<>();
private ArrayList<Call> mConferenceCalls = new ArrayList<>();
private static InCallServiceCallbacks sCallbacks;
@@ -34,6 +39,7 @@
new ArrayMap<Call, MockVideoCallCallback>();
private static final Object sLock = new Object();
+ private static boolean mIsServiceUnbound;
public static abstract class InCallServiceCallbacks {
private MockInCallService mService;
@@ -152,9 +158,11 @@
@Override
public android.os.IBinder onBind(android.content.Intent intent) {
+ Log.i(LOG_TAG, "Service bounded");
if (getCallbacks() != null) {
getCallbacks().setService(this);
}
+ mIsServiceUnbound = false;
return super.onBind(intent);
}
@@ -312,4 +320,16 @@
public MockVideoCallCallback getVideoCallCallback(Call call) {
return mVideoCallCallbacks.get(call);
}
+
+ @Override
+ public boolean onUnbind(Intent intent) {
+ Log.i(LOG_TAG, "Service unbounded");
+ assertFalse(mIsServiceUnbound);
+ mIsServiceUnbound = true;
+ return super.onUnbind(intent);
+ }
+
+ public static boolean isServiceUnbound() {
+ return mIsServiceUnbound;
+ }
}
diff --git a/tests/tests/telecom/src/android/telecom/cts/NumberDialingTest.java b/tests/tests/telecom/src/android/telecom/cts/NumberDialingTest.java
index 8ffcf48..e95a290 100644
--- a/tests/tests/telecom/src/android/telecom/cts/NumberDialingTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/NumberDialingTest.java
@@ -62,7 +62,5 @@
res.wait(CS_WAIT_MILLIS);
}
assertEquals(address, res[0]);
-
- tearDownConnectionService(account.getAccountHandle());
}
}
diff --git a/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java b/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java
index f2422c9..e02de92 100644
--- a/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java
@@ -35,15 +35,13 @@
}
}
- // TODO: Need to send some commands to the UserManager via adb to do setup
+ /* TODO: Need to send some commands to the UserManager via adb to do setup
public void testDisallowOutgoingCallsForSecondaryUser() {
+ } */
- }
-
- // TODO: Need to figure out a way to mock emergency calls without adb root
+ /* TODO: Need to figure out a way to mock emergency calls without adb root
public void testOutgoingCallBroadcast_isSentForAllCalls() {
-
- }
+ } */
/**
* Verifies that providing the EXTRA_START_CALL_WITH_SPEAKERPHONE extra starts the call with
diff --git a/tests/tests/telecom/src/android/telecom/cts/RemoteConferenceTest.java b/tests/tests/telecom/src/android/telecom/cts/RemoteConferenceTest.java
index 3fc65ea..787966a 100644
--- a/tests/tests/telecom/src/android/telecom/cts/RemoteConferenceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/RemoteConferenceTest.java
@@ -61,7 +61,6 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- mContext = getInstrumentation().getContext();
if (mShouldTestTelecom) {
addRemoteConferenceCall();
verifyRemoteConferenceObject(mRemoteConferenceObject, mRemoteConference, mConference);
diff --git a/tests/tests/telecom/src/android/telecom/cts/RemoteConnectionTest.java b/tests/tests/telecom/src/android/telecom/cts/RemoteConnectionTest.java
index 79fb592..5b552a0 100644
--- a/tests/tests/telecom/src/android/telecom/cts/RemoteConnectionTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/RemoteConnectionTest.java
@@ -1210,7 +1210,6 @@
};
mRemoteConnectionObject.registerCallback(callback, handler);
mRemoteConnection.createMockVideoProvider();
- mRemoteConnection.setVideoProvider(mRemoteConnection.getMockVideoProvider());
callbackInvoker.waitForCount(1, WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
assertEquals(mRemoteConnectionObject, callbackInvoker.getArgs(0)[0]);
mRemoteConnectionObject.unregisterCallback(callback);
diff --git a/tests/tests/telecom/src/android/telecom/cts/WiredHeadsetTest.java b/tests/tests/telecom/src/android/telecom/cts/WiredHeadsetTest.java
index 466a90b..ab4106e 100644
--- a/tests/tests/telecom/src/android/telecom/cts/WiredHeadsetTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/WiredHeadsetTest.java
@@ -35,21 +35,12 @@
}
}
- @Override
- protected void tearDown() throws Exception {
- if (mInCallCallbacks != null && mInCallCallbacks.getService() != null) {
- mInCallCallbacks.getService().disconnectLastCall();
- assertNumCalls(mInCallCallbacks.getService(), 0);
- }
- super.tearDown();
- }
-
public void testIncomingCallShortPress_acceptsCall() throws Exception {
if (!mShouldTestTelecom) {
return;
}
- addAndVerifyNewIncomingCall(getTestNumber(), null);
+ addAndVerifyNewIncomingCall(createTestNumber(), null);
final MockConnection connection = verifyConnectionForIncomingCall();
final Call call = mInCallCallbacks.getService().getLastCall();
@@ -66,7 +57,7 @@
return;
}
- addAndVerifyNewIncomingCall(getTestNumber(), null);
+ addAndVerifyNewIncomingCall(createTestNumber(), null);
final MockConnection connection = verifyConnectionForIncomingCall();
final Call call = mInCallCallbacks.getService().getLastCall();
diff --git a/tests/tests/voicesettings/src/android/voicesettings/cts/AirplaneModeTest.java b/tests/tests/voicesettings/src/android/voicesettings/cts/AirplaneModeTest.java
index 8abe396..4597651 100644
--- a/tests/tests/voicesettings/src/android/voicesettings/cts/AirplaneModeTest.java
+++ b/tests/tests/voicesettings/src/android/voicesettings/cts/AirplaneModeTest.java
@@ -33,9 +33,16 @@
}
public void testAll() throws Exception {
+ int mode;
+ try {
+ mode = getMode();
+ Log.i(TAG, "Before testing, AIRPLANE_MODE is set to: " + mode);
+ } catch (Settings.SettingNotFoundException e) {
+ // if the mode is not supported, don't run the test.
+ Log.i(TAG, "airplane mode is not found in Settings. Skipping AirplaneModeTest");
+ return;
+ }
startTestActivity("AIRPLANE_MODE");
- int mode = getMode();
- Log.i(TAG, "Before testing, AIRPLANE_MODE is set to: " + mode);
if (mode == AIRPLANE_MODE_IS_OFF) {
// mode is currently OFF.
// run a test to turn it on.
@@ -70,7 +77,7 @@
return true;
}
- private int getMode() throws Exception {
+ private int getMode() throws Settings.SettingNotFoundException {
return Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.AIRPLANE_MODE_ON);
}
diff --git a/tests/tests/voicesettings/src/android/voicesettings/cts/ZenModeTest.java b/tests/tests/voicesettings/src/android/voicesettings/cts/ZenModeTest.java
index 8c2efbe..ca86918 100644
--- a/tests/tests/voicesettings/src/android/voicesettings/cts/ZenModeTest.java
+++ b/tests/tests/voicesettings/src/android/voicesettings/cts/ZenModeTest.java
@@ -39,9 +39,16 @@
}
public void testAll() throws Exception {
+ int mode;
+ try {
+ mode = getMode();
+ Log.i(TAG, "Before testing, zen-mode is set to: " + mode);
+ } catch (Settings.SettingNotFoundException e) {
+ // if the mode is not supported, don't run the test.
+ Log.i(TAG, "zen_mode is not found in Settings. Skipping ZenModeTest");
+ return;
+ }
startTestActivity("ZEN_MODE");
- int mode = getMode();
- Log.i(TAG, "Before testing, zen-mode is set to: " + mode);
if (mode == ZEN_MODE_IS_OFF) {
// mode is currently OFF.
// run a test to turn it on.
@@ -85,7 +92,7 @@
return true;
}
- private int getMode() throws Exception {
+ private int getMode() throws Settings.SettingNotFoundException {
return Settings.Global.getInt(mContext.getContentResolver(), ZEN_MODE);
}
}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/device/DeviceInfoCollector.java b/tools/tradefed-host/src/com/android/cts/tradefed/device/DeviceInfoCollector.java
index b5f0dfc..61561a5 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/device/DeviceInfoCollector.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/device/DeviceInfoCollector.java
@@ -17,6 +17,7 @@
import com.android.cts.util.AbiUtils;
import com.android.cts.tradefed.result.CtsXmlResultReporter;
+import com.android.ddmlib.IDevice;
import com.android.ddmlib.Log;
import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.build.IFolderBuildInfo;
@@ -49,7 +50,6 @@
private static final String EXTENDED_INSTRUMENTATION_NAME =
"com.android.compatibility.common.deviceinfo.DeviceInfoInstrument";
private static final String DEVICE_INFO_FILES = "device-info-files";
- private static final String DEVICE_RESULT_DIR = "/sdcard/" + DEVICE_INFO_FILES;
public static final Set<String> IDS = new HashSet<String>();
public static final Set<String> EXTENDED_IDS = new HashSet<String>();
@@ -87,7 +87,8 @@
ITestInvocationListener listener, IBuildInfo buildInfo)
throws DeviceNotAvailableException {
// Clear files in device test result directory
- device.executeShellCommand(String.format("rm -rf %s", DEVICE_RESULT_DIR));
+ String deviceResultDir = getDeviceResultDir(device);
+ device.executeShellCommand(String.format("rm -rf %s", deviceResultDir));
runInstrumentation(device, abi, testApkDir, listener, EXTENDED_APK_NAME,
EXTENDED_APP_PACKAGE_NAME, EXTENDED_INSTRUMENTATION_NAME);
// Copy files in remote result directory to local directory
@@ -131,9 +132,12 @@
localResultDir = new File(localResultDir, DEVICE_INFO_FILES);
localResultDir.mkdirs();
+
+ String deviceResultDir = getDeviceResultDir(device);
+
// Pull files from device result directory to local result directory
String command = String.format("adb -s %s pull %s %s", device.getSerialNumber(),
- DEVICE_RESULT_DIR, localResultDir.getAbsolutePath());
+ deviceResultDir, localResultDir.getAbsolutePath());
if (!execute(command)) {
Log.e(LOG_TAG, String.format("Failed to run %s", command));
}
@@ -148,4 +152,14 @@
return false;
}
}
+
+ private static String getDeviceResultDir(ITestDevice device) {
+ String externalStorePath = device.getMountPoint(IDevice.MNT_EXTERNAL_STORAGE);
+ if (externalStorePath == null) {
+ Log.e(LOG_TAG, String.format(
+ "Failed to get external storage path on device %s", device.getSerialNumber()));
+ return null;
+ }
+ return String.format("%s/%s", externalStorePath, DEVICE_INFO_FILES);
+ }
}
diff --git a/tools/utils/buildCts.py b/tools/utils/buildCts.py
index b6f5812..9a6e2a2 100755
--- a/tools/utils/buildCts.py
+++ b/tools/utils/buildCts.py
@@ -493,6 +493,10 @@
'com.android.cts.app.os' : [
'com.android.cts.app.os.OsHostTests#testNonExportedActivities',
],
+ 'com.android.cts.devicepolicy' : [
+ 'com.android.cts.devicepolicy.MixedDeviceOwnerTest#testPackageInstallUserRestrictions',
+ 'com.android.cts.devicepolicy.MixedProfileOwnerTest#testPackageInstallUserRestrictions',
+ ],
'' : []}
def LogGenerateDescription(name):