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

Commit 28391cbe authored by Carlos Martinez Romero's avatar Carlos Martinez Romero
Browse files

Call bootFinished using JNI.

This way we dont need to use FIRST_CALL_TRANSACTION which forces us to
set bootFinished as the first method in the class.

Test: Manually booted the device after changes.
Bug: 221898546
Change-Id: If3337fcb46385dcc469aececf18ffa098268644c
parent 71548300
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -275,6 +275,7 @@ public final class SurfaceControl implements Parcelable {
            int l, int t, int r, int b);
    private static native void nativeSetDefaultApplyToken(IBinder token);
    private static native IBinder nativeGetDefaultApplyToken();
    private static native boolean nativeBootFinished();


    /**
@@ -2381,6 +2382,14 @@ public final class SurfaceControl implements Parcelable {
        return nativeGetGPUContextPriority();
    }

    /**
     * Lets surfaceFlinger know the boot procedure is completed.
     * @hide
     */
    public static boolean bootFinished() {
        return nativeBootFinished();
    }

    /**
     * Interface to handle request to
     * {@link SurfaceControl.Transaction#addTransactionCommittedListener(Executor, TransactionCommittedListener)}
@@ -3876,4 +3885,5 @@ public final class SurfaceControl implements Parcelable {
        SyncFence fence = new SyncFence(nativeFencePtr);
        callback.accept(fence);
    }

}
+7 −0
Original line number Diff line number Diff line
@@ -1908,6 +1908,11 @@ static jobject nativeGetDefaultApplyToken(JNIEnv* env, jclass clazz) {
    return javaObjectForIBinder(env, token);
}

static jboolean nativeBootFinished(JNIEnv* env, jclass clazz) {
    status_t error = SurfaceComposerClient::bootFinished();
    return error == OK ? JNI_TRUE : JNI_FALSE;
}

// ----------------------------------------------------------------------------

SurfaceControl* android_view_SurfaceControl_getNativeSurfaceControl(JNIEnv* env,
@@ -2140,6 +2145,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
                (void*)nativeSetDefaultApplyToken },
    {"nativeGetDefaultApplyToken", "()Landroid/os/IBinder;",
                (void*)nativeGetDefaultApplyToken },
    {"nativeBootFinished", "()Z",
            (void*)nativeBootFinished },
        // clang-format on
};

+12 −12
Original line number Diff line number Diff line
@@ -805,6 +805,12 @@
      "group": "WM_DEBUG_CONTENT_RECORDING",
      "at": "com\/android\/server\/wm\/ContentRecorder.java"
    },
    "-1323783276": {
      "message": "performEnableScreen: bootFinished() failed.",
      "level": "WARN",
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-1318478129": {
      "message": "applyAnimation: win=%s anim=%d attr=0x%x a=%s transit=%d type=%d isEntrance=%b Callers %s",
      "level": "VERBOSE",
@@ -1603,6 +1609,12 @@
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-576580969": {
      "message": "viewServerWindowCommand: bootFinished() failed.",
      "level": "WARN",
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-576070986": {
      "message": "Performing post-rotate rotation after seamless rotation",
      "level": "INFO",
@@ -2113,12 +2125,6 @@
      "group": "WM_DEBUG_FOCUS_LIGHT",
      "at": "com\/android\/server\/wm\/DisplayContent.java"
    },
    "-87703044": {
      "message": "Boot completed: SurfaceFlinger is dead!",
      "level": "ERROR",
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-86763148": {
      "message": "  KILL SURFACE SESSION %s",
      "level": "INFO",
@@ -2911,12 +2917,6 @@
      "group": "WM_DEBUG_CONTENT_RECORDING",
      "at": "com\/android\/server\/wm\/ContentRecorder.java"
    },
    "620368427": {
      "message": "******* TELLING SURFACE FLINGER WE ARE BOOTED!",
      "level": "INFO",
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "620519522": {
      "message": "findFocusedWindow: No focusable windows, display=%d",
      "level": "VERBOSE",
+3 −15
Original line number Diff line number Diff line
@@ -168,7 +168,6 @@ import android.app.IActivityManager;
import android.app.IAssistDataReceiver;
import android.app.WindowConfiguration;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
@@ -178,7 +177,6 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManagerInternal;
import android.content.pm.TestUtilityService;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.database.ContentObserver;
import android.graphics.Bitmap;
@@ -3718,19 +3716,9 @@ public class WindowManagerService extends IWindowManager.Stub
                return;
            }

            try {
                // TODO(b/221898546): remove the following and convert to jni
                IBinder surfaceFlinger = ServiceManager.getService("SurfaceFlingerAIDL");
                if (surfaceFlinger != null) {
                    ProtoLog.i(WM_ERROR, "******* TELLING SURFACE FLINGER WE ARE BOOTED!");
                    Parcel data = Parcel.obtain();
                    data.writeInterfaceToken("android.gui.ISurfaceComposer");
                    surfaceFlinger.transact(IBinder.FIRST_CALL_TRANSACTION, // BOOT_FINISHED
                            data, null, 0);
                    data.recycle();
                }
            } catch (RemoteException ex) {
                ProtoLog.e(WM_ERROR, "Boot completed: SurfaceFlinger is dead!");
            if (!SurfaceControl.bootFinished()) {
                ProtoLog.w(WM_ERROR, "performEnableScreen: bootFinished() failed.");
                return;
            }

            EventLogTags.writeWmBootAnimationDone(SystemClock.uptimeMillis());