Search in sources :

Example 6 with IMediaProjection

use of android.media.projection.IMediaProjection in project android_frameworks_base by AOSPA.

the class DisplayManagerGlobal method createVirtualDisplay.

public VirtualDisplay createVirtualDisplay(Context context, MediaProjection projection, String name, int width, int height, int densityDpi, Surface surface, int flags, VirtualDisplay.Callback callback, Handler handler) {
    if (TextUtils.isEmpty(name)) {
        throw new IllegalArgumentException("name must be non-null and non-empty");
    }
    if (width <= 0 || height <= 0 || densityDpi <= 0) {
        throw new IllegalArgumentException("width, height, and densityDpi must be " + "greater than 0");
    }
    VirtualDisplayCallback callbackWrapper = new VirtualDisplayCallback(callback, handler);
    IMediaProjection projectionToken = projection != null ? projection.getProjection() : null;
    int displayId;
    try {
        displayId = mDm.createVirtualDisplay(callbackWrapper, projectionToken, context.getPackageName(), name, width, height, densityDpi, surface, flags);
    } catch (RemoteException ex) {
        throw ex.rethrowFromSystemServer();
    }
    if (displayId < 0) {
        Log.e(TAG, "Could not create virtual display: " + name);
        return null;
    }
    Display display = getRealDisplay(displayId);
    if (display == null) {
        Log.wtf(TAG, "Could not obtain display info for newly created " + "virtual display: " + name);
        try {
            mDm.releaseVirtualDisplay(callbackWrapper);
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
        return null;
    }
    return new VirtualDisplay(this, display, callbackWrapper, surface);
}
Also used : IMediaProjection(android.media.projection.IMediaProjection) RemoteException(android.os.RemoteException) Display(android.view.Display)

Example 7 with IMediaProjection

use of android.media.projection.IMediaProjection in project android_frameworks_base by ResurrectionRemix.

the class MediaProjectionPermissionActivity method getMediaProjectionIntent.

private Intent getMediaProjectionIntent(int uid, String packageName, boolean permanentGrant) throws RemoteException {
    IMediaProjection projection = mService.createProjection(uid, packageName, MediaProjectionManager.TYPE_SCREEN_CAPTURE, permanentGrant);
    Intent intent = new Intent();
    intent.putExtra(MediaProjectionManager.EXTRA_MEDIA_PROJECTION, projection.asBinder());
    return intent;
}
Also used : Intent(android.content.Intent) IMediaProjection(android.media.projection.IMediaProjection)

Example 8 with IMediaProjection

use of android.media.projection.IMediaProjection in project android_frameworks_base by DirtyUnicorns.

the class MediaProjectionPermissionActivity method getMediaProjectionIntent.

private Intent getMediaProjectionIntent(int uid, String packageName, boolean permanentGrant) throws RemoteException {
    IMediaProjection projection = mService.createProjection(uid, packageName, MediaProjectionManager.TYPE_SCREEN_CAPTURE, permanentGrant);
    Intent intent = new Intent();
    intent.putExtra(MediaProjectionManager.EXTRA_MEDIA_PROJECTION, projection.asBinder());
    return intent;
}
Also used : Intent(android.content.Intent) IMediaProjection(android.media.projection.IMediaProjection)

Example 9 with IMediaProjection

use of android.media.projection.IMediaProjection in project android_frameworks_base by crdroidandroid.

the class MediaProjectionPermissionActivity method getMediaProjectionIntent.

private Intent getMediaProjectionIntent(int uid, String packageName, boolean permanentGrant) throws RemoteException {
    IMediaProjection projection = mService.createProjection(uid, packageName, MediaProjectionManager.TYPE_SCREEN_CAPTURE, permanentGrant);
    Intent intent = new Intent();
    intent.putExtra(MediaProjectionManager.EXTRA_MEDIA_PROJECTION, projection.asBinder());
    return intent;
}
Also used : Intent(android.content.Intent) IMediaProjection(android.media.projection.IMediaProjection)

Example 10 with IMediaProjection

use of android.media.projection.IMediaProjection in project android_frameworks_base by crdroidandroid.

the class DisplayManagerGlobal method createVirtualDisplay.

public VirtualDisplay createVirtualDisplay(Context context, MediaProjection projection, String name, int width, int height, int densityDpi, Surface surface, int flags, VirtualDisplay.Callback callback, Handler handler) {
    if (TextUtils.isEmpty(name)) {
        throw new IllegalArgumentException("name must be non-null and non-empty");
    }
    if (width <= 0 || height <= 0 || densityDpi <= 0) {
        throw new IllegalArgumentException("width, height, and densityDpi must be " + "greater than 0");
    }
    VirtualDisplayCallback callbackWrapper = new VirtualDisplayCallback(callback, handler);
    IMediaProjection projectionToken = projection != null ? projection.getProjection() : null;
    int displayId;
    try {
        displayId = mDm.createVirtualDisplay(callbackWrapper, projectionToken, context.getPackageName(), name, width, height, densityDpi, surface, flags);
    } catch (RemoteException ex) {
        throw ex.rethrowFromSystemServer();
    }
    if (displayId < 0) {
        Log.e(TAG, "Could not create virtual display: " + name);
        return null;
    }
    Display display = getRealDisplay(displayId);
    if (display == null) {
        Log.wtf(TAG, "Could not obtain display info for newly created " + "virtual display: " + name);
        try {
            mDm.releaseVirtualDisplay(callbackWrapper);
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
        return null;
    }
    return new VirtualDisplay(this, display, callbackWrapper, surface);
}
Also used : IMediaProjection(android.media.projection.IMediaProjection) RemoteException(android.os.RemoteException) Display(android.view.Display)

Aggregations

IMediaProjection (android.media.projection.IMediaProjection)10 Intent (android.content.Intent)5 RemoteException (android.os.RemoteException)5 Display (android.view.Display)5