Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 63542383 authored by chaviw's avatar chaviw
Browse files

Added jni and SurfaceControl methods for native reparentChild

Added the Java methods to invoke the reparentChild method that
was added in the native code.

Test: Builds and runs

Change-Id: I25a783bbc820340a5346521a5783e50ada8c6828
parent eb280ca1
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -105,6 +105,8 @@ public class SurfaceControl {
            long surfaceObject, long frame);
    private static native void nativeReparentChildren(long nativeObject,
            IBinder handle);
    private static native void nativeReparentChild(long nativeObject,
            IBinder parentHandle, IBinder childHandle);
    private static native void nativeSeverChildren(long nativeObject);
    private static native void nativeSetOverrideScalingMode(long nativeObject,
            int scalingMode);
@@ -453,6 +455,11 @@ public class SurfaceControl {
        nativeReparentChildren(mNativeObject, newParentHandle);
    }

    /** Re-parents a specific child layer to a new parent */
    public void reparentChild(IBinder newParentHandle, IBinder childHandle) {
        nativeReparentChild(mNativeObject, newParentHandle, childHandle);
    }

    public void detachChildren() {
        nativeSeverChildren(mNativeObject);
    }
+11 −0
Original line number Diff line number Diff line
@@ -736,6 +736,15 @@ static void nativeReparentChildren(JNIEnv* env, jclass clazz, jlong nativeObject
    ctrl->reparentChildren(handle);
}

static void nativeReparentChild(JNIEnv* env, jclass clazz, jlong nativeObject,
        jobject newParentObject, jobject childObject) {
    auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
    sp<IBinder> parentHandle = ibinderForJavaObject(env, newParentObject);
    sp<IBinder> childHandle = ibinderForJavaObject(env, childObject);

    ctrl->reparentChild(parentHandle, childHandle);
}

static void nativeSeverChildren(JNIEnv* env, jclass clazz, jlong nativeObject) {
    auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
    ctrl->detachChildren();
@@ -859,6 +868,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeDeferTransactionUntilSurface },
    {"nativeReparentChildren", "(JLandroid/os/IBinder;)V",
            (void*)nativeReparentChildren } ,
    {"nativeReparentChild", "(JLandroid/os/IBinder;Landroid/os/IBinder;)V",
            (void*)nativeReparentChild },
    {"nativeSeverChildren", "(J)V",
            (void*)nativeSeverChildren } ,
    {"nativeSetOverrideScalingMode", "(JI)V",