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

Commit aee82061 authored by Daniel Zheng's avatar Daniel Zheng Committed by Android (Google) Code Review
Browse files

Merge "tim: surface screenPartStatus" into main

parents b34ec0c7 ed90493f
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -1908,6 +1908,7 @@ public final class SurfaceControl implements Parcelable {
        public boolean secure;
        public DeviceProductInfo deviceProductInfo;
        public @Surface.Rotation int installOrientation;
        public int screenPartStatus;

        @Override
        public String toString() {
@@ -1915,7 +1916,8 @@ public final class SurfaceControl implements Parcelable {
                    + ", density=" + density
                    + ", secure=" + secure
                    + ", deviceProductInfo=" + deviceProductInfo
                    + ", installOrientation=" + installOrientation + "}";
                    + ", installOrientation=" + installOrientation
                    + ", screenPartStatus=" + screenPartStatus + "}";
        }

        @Override
@@ -1927,12 +1929,14 @@ public final class SurfaceControl implements Parcelable {
                    && density == that.density
                    && secure == that.secure
                    && Objects.equals(deviceProductInfo, that.deviceProductInfo)
                    && installOrientation == that.installOrientation;
                    && installOrientation == that.installOrientation
                    && screenPartStatus == that.screenPartStatus;
        }

        @Override
        public int hashCode() {
            return Objects.hash(isInternal, density, secure, deviceProductInfo, installOrientation);
            return Objects.hash(isInternal, density, secure, deviceProductInfo,
                installOrientation, screenPartStatus);
        }
    }

+5 −0
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ static struct {
    jfieldID secure;
    jfieldID deviceProductInfo;
    jfieldID installOrientation;
    jfieldID screenPartStatus;
} gStaticDisplayInfoClassInfo;

static struct {
@@ -1480,6 +1481,8 @@ static jobject nativeGetStaticDisplayInfo(JNIEnv* env, jclass clazz, jlong id) {
                                                             isInternal));
    env->SetIntField(object, gStaticDisplayInfoClassInfo.installOrientation,
                     static_cast<uint32_t>(info.installOrientation));
    env->SetIntField(object, gStaticDisplayInfoClassInfo.screenPartStatus,
                     static_cast<uint8_t>(info.screenPartStatus));
    return object;
}

@@ -2819,6 +2822,8 @@ int register_android_view_SurfaceControl(JNIEnv* env)
    gStaticDisplayInfoClassInfo.installOrientation =
            GetFieldIDOrDie(env, infoClazz, "installOrientation", "I");

    gStaticDisplayInfoClassInfo.screenPartStatus =
            GetFieldIDOrDie(env, infoClazz, "screenPartStatus", "I");
    jclass dynamicInfoClazz = FindClassOrDie(env, "android/view/SurfaceControl$DynamicDisplayInfo");
    gDynamicDisplayInfoClassInfo.clazz = MakeGlobalRefOrDie(env, dynamicInfoClazz);
    gDynamicDisplayInfoClassInfo.ctor = GetMethodIDOrDie(env, dynamicInfoClazz, "<init>", "()V");
+11 −0
Original line number Diff line number Diff line
@@ -34,12 +34,15 @@ import android.os.Binder;
import android.os.ITradeInMode;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.RemoteException;
import android.view.SurfaceControl;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.service.persistentdata.PersistentDataBlockManager;
import android.util.Slog;

import com.android.server.health.HealthServiceWrapper;
import com.android.server.display.DisplayControl;

import java.io.FileWriter;
import java.io.IOException;
@@ -250,6 +253,14 @@ public final class TradeInModeService extends SystemService {
        @Override
        @RequiresPermission(android.Manifest.permission.ENTER_TRADE_IN_MODE)
        public int getScreenPartStatus() throws RemoteException {
            SurfaceControl b = new SurfaceControl.Builder().setName("TIM").build();
            // loop through all displayId to find id of internal display
            for (long physicalDisplayId : DisplayControl.getPhysicalDisplayIds()) {
                SurfaceControl.StaticDisplayInfo info = b.getStaticDisplayInfo(physicalDisplayId);
                if (info.isInternal) {
                    return info.screenPartStatus;
                }
            }
            return 0;
        }