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

Commit e2f33372 authored by Chavi Weingarten's avatar Chavi Weingarten
Browse files

Delete getInternalDisplayToken

No longer any uses of getInternalDisplayToken.

Also moved getPhysicalDisplayIds and getPhysicalDisplayToken into system
server to make it harder to use accidentally.

Test: LocalDisplayAdapterTest
Test: SizeCompatTests#testRestartProcessIfVisible
Fixes: 242714168
Change-Id: Id5eb42d5304e6a5d4c39e593bad354ccc04ce294
parent e1388556
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -2886,7 +2886,6 @@ package android.view {

  public final class SurfaceControl implements android.os.Parcelable {
    ctor public SurfaceControl(@NonNull android.view.SurfaceControl, @NonNull String);
    method @NonNull public static android.os.IBinder getInternalDisplayToken();
    method public boolean isSameSurface(@NonNull android.view.SurfaceControl);
  }

+2 −2
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ public abstract class DisplayAddress implements Parcelable {
     *
     * @param physicalDisplayId A physical display ID.
     * @return The {@link Physical} address.
     * @see SurfaceControl#getPhysicalDisplayIds
     * @see com.android.server.display.DisplayControl#getPhysicalDisplayIds
     */
    @NonNull
    public static Physical fromPhysicalDisplayId(long physicalDisplayId) {
@@ -83,7 +83,7 @@ public abstract class DisplayAddress implements Parcelable {
         * Stable display ID combining port and model.
         *
         * @return An ID in the range [0, 2^64) interpreted as signed.
         * @see SurfaceControl#getPhysicalDisplayIds
         * @see com.android.server.display.DisplayControl#getPhysicalDisplayIds
         */
        public long getPhysicalDisplayId() {
            return mPhysicalDisplayId;
+0 −31
Original line number Diff line number Diff line
@@ -173,8 +173,6 @@ public final class SurfaceControl implements Parcelable {
    private static native boolean nativeClearAnimationFrameStats();
    private static native boolean nativeGetAnimationFrameStats(WindowAnimationFrameStats outStats);

    private static native long[] nativeGetPhysicalDisplayIds();
    private static native IBinder nativeGetPhysicalDisplayToken(long physicalDisplayId);
    private static native void nativeSetDisplaySurface(long transactionObj,
            IBinder displayToken, long nativeSurfaceObject);
    private static native void nativeSetDisplayLayerStack(long transactionObj,
@@ -2034,35 +2032,6 @@ public final class SurfaceControl implements Parcelable {
                IVirtualDisplayCallback.Stub.asInterface(displayToken));
    }

    /**
     * @hide
     */
    public static long[] getPhysicalDisplayIds() {
        return nativeGetPhysicalDisplayIds();
    }

    /**
     * @hide
     */
    public static IBinder getPhysicalDisplayToken(long physicalDisplayId) {
        return nativeGetPhysicalDisplayToken(physicalDisplayId);
    }

    /**
     * TODO(b/116025192): Remove this stopgap once framework is display-agnostic.
     *
     * @hide
     */
    @TestApi
    @NonNull
    public static IBinder getInternalDisplayToken() {
        final long[] physicalDisplayIds = getPhysicalDisplayIds();
        if (physicalDisplayIds.length == 0) {
            return null;
        }
        return getPhysicalDisplayToken(physicalDisplayIds[0]);
    }

    /**
     * Returns whether protected content is supported in GPU composition.
     * @hide
+0 −32
Original line number Diff line number Diff line
@@ -886,34 +886,6 @@ static void nativeSetDestinationFrame(JNIEnv* env, jclass clazz, jlong transacti
    transaction->setDestinationFrame(ctrl, crop);
}

static jlongArray nativeGetPhysicalDisplayIds(JNIEnv* env, jclass clazz) {
    const auto displayIds = SurfaceComposerClient::getPhysicalDisplayIds();
    jlongArray array = env->NewLongArray(displayIds.size());
    if (array == nullptr) {
        jniThrowException(env, "java/lang/OutOfMemoryError", nullptr);
        return nullptr;
    }

    if (displayIds.empty()) {
        return array;
    }

    jlong* values = env->GetLongArrayElements(array, 0);
    for (size_t i = 0; i < displayIds.size(); ++i) {
        values[i] = static_cast<jlong>(displayIds[i].value);
    }

    env->ReleaseLongArrayElements(array, values, 0);
    return array;
}

static jobject nativeGetPhysicalDisplayToken(JNIEnv* env, jclass clazz, jlong physicalDisplayId) {
    const auto id = DisplayId::fromValue<PhysicalDisplayId>(physicalDisplayId);
    if (!id) return nullptr;
    sp<IBinder> token = SurfaceComposerClient::getPhysicalDisplayToken(*id);
    return javaObjectForIBinder(env, token);
}

static jobject nativeGetDisplayedContentSamplingAttributes(JNIEnv* env, jclass clazz,
        jobject tokenObj) {
    sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
@@ -1992,10 +1964,6 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeSetFrameRate },
    {"nativeSetDefaultFrameRateCompatibility", "(JJI)V",
            (void*)nativeSetDefaultFrameRateCompatibility},
    {"nativeGetPhysicalDisplayIds", "()[J",
            (void*)nativeGetPhysicalDisplayIds },
    {"nativeGetPhysicalDisplayToken", "(J)Landroid/os/IBinder;",
            (void*)nativeGetPhysicalDisplayToken },
    {"nativeSetDisplaySurface", "(JLandroid/os/IBinder;J)V",
            (void*)nativeSetDisplaySurface },
    {"nativeSetDisplayLayerStack", "(JLandroid/os/IBinder;I)V",
+16 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ public class DisplayControl {
    private static native IBinder nativeCreateDisplay(String name, boolean secure);
    private static native void nativeDestroyDisplay(IBinder displayToken);
    private static native void nativeOverrideHdrTypes(IBinder displayToken, int[] modes);
    private static native long[] nativeGetPhysicalDisplayIds();
    private static native IBinder nativeGetPhysicalDisplayToken(long physicalDisplayId);

    /**
     * Create a display in SurfaceFlinger.
@@ -63,4 +65,18 @@ public class DisplayControl {
    public static void overrideHdrTypes(@NonNull IBinder displayToken, @NonNull int[] modes) {
        nativeOverrideHdrTypes(displayToken, modes);
    }

    /**
     * Gets all the physical display ids.
     */
    public static long[] getPhysicalDisplayIds() {
        return nativeGetPhysicalDisplayIds();
    }

    /**
     * Gets the display's token from the physical display id
     */
    public static IBinder getPhysicalDisplayToken(long physicalDisplayId) {
        return nativeGetPhysicalDisplayToken(physicalDisplayId);
    }
}
Loading