Loading core/java/android/view/SurfaceControl.java +7 −3 Original line number Diff line number Diff line Loading @@ -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() { Loading @@ -1915,7 +1916,8 @@ public final class SurfaceControl implements Parcelable { + ", density=" + density + ", secure=" + secure + ", deviceProductInfo=" + deviceProductInfo + ", installOrientation=" + installOrientation + "}"; + ", installOrientation=" + installOrientation + ", screenPartStatus=" + screenPartStatus + "}"; } @Override Loading @@ -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); } } Loading core/jni/android_view_SurfaceControl.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,7 @@ static struct { jfieldID secure; jfieldID deviceProductInfo; jfieldID installOrientation; jfieldID screenPartStatus; } gStaticDisplayInfoClassInfo; static struct { Loading Loading @@ -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; } Loading Loading @@ -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"); Loading services/core/java/com/android/server/TradeInModeService.java +11 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading Loading
core/java/android/view/SurfaceControl.java +7 −3 Original line number Diff line number Diff line Loading @@ -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() { Loading @@ -1915,7 +1916,8 @@ public final class SurfaceControl implements Parcelable { + ", density=" + density + ", secure=" + secure + ", deviceProductInfo=" + deviceProductInfo + ", installOrientation=" + installOrientation + "}"; + ", installOrientation=" + installOrientation + ", screenPartStatus=" + screenPartStatus + "}"; } @Override Loading @@ -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); } } Loading
core/jni/android_view_SurfaceControl.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,7 @@ static struct { jfieldID secure; jfieldID deviceProductInfo; jfieldID installOrientation; jfieldID screenPartStatus; } gStaticDisplayInfoClassInfo; static struct { Loading Loading @@ -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; } Loading Loading @@ -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"); Loading
services/core/java/com/android/server/TradeInModeService.java +11 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading