Search in sources :

Example 31 with ServiceSpecificException

use of android.os.ServiceSpecificException in project platform_frameworks_base by android.

the class ZygoteInit method performSystemServerDexOpt.

/**
     * Performs dex-opt on the elements of {@code classPath}, if needed. We
     * choose the instruction set of the current runtime.
     */
private static void performSystemServerDexOpt(String classPath) {
    final String[] classPathElements = classPath.split(":");
    final IInstalld installd = IInstalld.Stub.asInterface(ServiceManager.getService("installd"));
    final String instructionSet = VMRuntime.getRuntime().vmInstructionSet();
    String sharedLibraries = "";
    for (String classPathElement : classPathElements) {
        // System server is fully AOTed and never profiled
        // for profile guided compilation.
        // TODO: Make this configurable between INTERPRET_ONLY, SPEED, SPACE and EVERYTHING?
        int dexoptNeeded;
        try {
            dexoptNeeded = DexFile.getDexOptNeeded(classPathElement, instructionSet, "speed", false);
        } catch (FileNotFoundException ignored) {
            // Do not add to the classpath.
            Log.w(TAG, "Missing classpath element for system server: " + classPathElement);
            continue;
        } catch (IOException e) {
            // Not fully clear what to do here as we don't know the cause of the
            // IO exception. Add to the classpath to be conservative, but don't
            // attempt to compile it.
            Log.w(TAG, "Error checking classpath element for system server: " + classPathElement, e);
            dexoptNeeded = DexFile.NO_DEXOPT_NEEDED;
        }
        if (dexoptNeeded != DexFile.NO_DEXOPT_NEEDED) {
            final String packageName = "*";
            final String outputPath = null;
            final int dexFlags = 0;
            final String compilerFilter = "speed";
            final String uuid = StorageManager.UUID_PRIVATE_INTERNAL;
            try {
                installd.dexopt(classPathElement, Process.SYSTEM_UID, packageName, instructionSet, dexoptNeeded, outputPath, dexFlags, compilerFilter, uuid, sharedLibraries);
            } catch (RemoteException | ServiceSpecificException e) {
                // Ignore (but log), we need this on the classpath for fallback mode.
                Log.w(TAG, "Failed compiling classpath element for system server: " + classPathElement, e);
            }
        }
        if (!sharedLibraries.isEmpty()) {
            sharedLibraries += ":";
        }
        sharedLibraries += classPathElement;
    }
}
Also used : ServiceSpecificException(android.os.ServiceSpecificException) IInstalld(android.os.IInstalld) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) RemoteException(android.os.RemoteException)

Example 32 with ServiceSpecificException

use of android.os.ServiceSpecificException in project platform_frameworks_base by android.

the class CameraDeviceBinderTest method testWaitUntilIdle.

@SmallTest
public void testWaitUntilIdle() throws Exception {
    CaptureRequest.Builder builder = createDefaultBuilder(/* needStream */
    true);
    SubmitInfo requestInfoStreaming = submitCameraRequest(builder.build(), /* streaming */
    true);
    // Test Bad case first: waitUntilIdle when there is active repeating request
    try {
        mCameraUser.waitUntilIdle();
    } catch (ServiceSpecificException e) {
        assertEquals("waitUntilIdle is invalid operation when there is active repeating request", ICameraService.ERROR_INVALID_OPERATION, e.errorCode);
    }
    // Test good case, waitUntilIdle when there is no active repeating request
    long lastFrameNumber = mCameraUser.cancelRequest(requestInfoStreaming.getRequestId());
    mCameraUser.waitUntilIdle();
}
Also used : ServiceSpecificException(android.os.ServiceSpecificException) SubmitInfo(android.hardware.camera2.utils.SubmitInfo) CaptureRequest(android.hardware.camera2.CaptureRequest) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 33 with ServiceSpecificException

use of android.os.ServiceSpecificException in project platform_frameworks_base by android.

the class CameraDeviceBinderTest method testCreateStreamTwo.

@SmallTest
public void testCreateStreamTwo() throws Exception {
    // Create first stream
    int streamId = mCameraUser.createStream(mOutputConfiguration);
    assertEquals(0, streamId);
    try {
        mCameraUser.createStream(mOutputConfiguration);
        fail("Created same stream twice");
    } catch (ServiceSpecificException e) {
        assertEquals("Created same stream twice", ICameraService.ERROR_ALREADY_EXISTS, e.errorCode);
    }
    // Create second stream with a different surface.
    SurfaceTexture surfaceTexture = new SurfaceTexture(/* ignored */
    0);
    surfaceTexture.setDefaultBufferSize(640, 480);
    Surface surface2 = new Surface(surfaceTexture);
    OutputConfiguration output2 = new OutputConfiguration(surface2);
    int streamId2 = mCameraUser.createStream(output2);
    assertEquals(1, streamId2);
    // Clean up streams
    mCameraUser.deleteStream(streamId);
    mCameraUser.deleteStream(streamId2);
}
Also used : ServiceSpecificException(android.os.ServiceSpecificException) SurfaceTexture(android.graphics.SurfaceTexture) OutputConfiguration(android.hardware.camera2.params.OutputConfiguration) Surface(android.view.Surface) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 34 with ServiceSpecificException

use of android.os.ServiceSpecificException in project platform_frameworks_base by android.

the class CameraDeviceBinderTest method testSubmitBadRequest.

@SmallTest
public void testSubmitBadRequest() throws Exception {
    CaptureRequest.Builder builder = createDefaultBuilder(/* needStream */
    false);
    CaptureRequest request1 = builder.build();
    try {
        SubmitInfo requestInfo = mCameraUser.submitRequest(request1, /* streaming */
        false);
        fail("Exception expected");
    } catch (ServiceSpecificException e) {
        assertEquals("Expected submitRequest to throw ServiceSpecificException with BAD_VALUE " + "since we had 0 surface targets set.", ICameraService.ERROR_ILLEGAL_ARGUMENT, e.errorCode);
    }
    builder.addTarget(mSurface);
    CaptureRequest request2 = builder.build();
    try {
        SubmitInfo requestInfo = mCameraUser.submitRequest(request2, /* streaming */
        false);
        fail("Exception expected");
    } catch (ServiceSpecificException e) {
        assertEquals("Expected submitRequest to throw ILLEGAL_ARGUMENT " + "ServiceSpecificException since the target wasn't registered with createStream.", ICameraService.ERROR_ILLEGAL_ARGUMENT, e.errorCode);
    }
}
Also used : ServiceSpecificException(android.os.ServiceSpecificException) SubmitInfo(android.hardware.camera2.utils.SubmitInfo) CaptureRequest(android.hardware.camera2.CaptureRequest) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 35 with ServiceSpecificException

use of android.os.ServiceSpecificException in project platform_frameworks_base by android.

the class CameraBinderTest method testAddRemoveListeners.

/**
     * <pre>
     * adb shell am instrument \
     *   -e class 'com.android.mediaframeworktest.integration.CameraBinderTest#testAddRemoveListeners' \
     *   -w com.android.mediaframeworktest/.MediaFrameworkIntegrationTestRunner
     * </pre>
     */
@SmallTest
public void testAddRemoveListeners() throws Exception {
    for (int cameraId = 0; cameraId < mUtils.getGuessedNumCameras(); ++cameraId) {
        ICameraServiceListener listener = new DummyCameraServiceListener();
        try {
            mUtils.getCameraService().removeListener(listener);
            fail("Listener was removed before added");
        } catch (ServiceSpecificException e) {
            assertEquals("Listener was removed before added", e.errorCode, ICameraService.ERROR_ILLEGAL_ARGUMENT);
        }
        mUtils.getCameraService().addListener(listener);
        try {
            mUtils.getCameraService().addListener(listener);
            fail("Listener was wrongly added again");
        } catch (ServiceSpecificException e) {
            assertEquals("Listener was wrongly added again", e.errorCode, ICameraService.ERROR_ALREADY_EXISTS);
        }
        mUtils.getCameraService().removeListener(listener);
        try {
            mUtils.getCameraService().removeListener(listener);
            fail("Listener was wrongly removed twice");
        } catch (ServiceSpecificException e) {
            assertEquals("Listener was wrongly removed twice", e.errorCode, ICameraService.ERROR_ILLEGAL_ARGUMENT);
        }
    }
}
Also used : ICameraServiceListener(android.hardware.ICameraServiceListener) ServiceSpecificException(android.os.ServiceSpecificException) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

ServiceSpecificException (android.os.ServiceSpecificException)66 RemoteException (android.os.RemoteException)26 SmallTest (android.test.suitebuilder.annotation.SmallTest)25 CaptureRequest (android.hardware.camera2.CaptureRequest)20 ICameraService (android.hardware.ICameraService)15 CameraMetadataNative (android.hardware.camera2.impl.CameraMetadataNative)15 SubmitInfo (android.hardware.camera2.utils.SubmitInfo)15 Surface (android.view.Surface)10 ArrayList (java.util.ArrayList)10 NonNull (android.annotation.NonNull)5 SurfaceTexture (android.graphics.SurfaceTexture)5 Camera (android.hardware.Camera)5 CameraInfo (android.hardware.Camera.CameraInfo)5 CameraInfo (android.hardware.CameraInfo)5 ICameraServiceListener (android.hardware.ICameraServiceListener)5 CameraCharacteristics (android.hardware.camera2.CameraCharacteristics)5 OutputConfiguration (android.hardware.camera2.params.OutputConfiguration)5 UidRange (android.net.UidRange)5 DeadObjectException (android.os.DeadObjectException)5 SparseIntArray (android.util.SparseIntArray)5