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;
}
}
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();
}
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);
}
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);
}
}
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);
}
}
}
Aggregations