Loading core/java/android/view/SurfaceControl.java +19 −6 Original line number Diff line number Diff line Loading @@ -74,8 +74,10 @@ public class SurfaceControl { IBinder displayToken, int orientation, int l, int t, int r, int b, int L, int T, int R, int B); private static native boolean nativeGetDisplayInfo( IBinder displayToken, SurfaceControl.PhysicalDisplayInfo outInfo); private static native SurfaceControl.PhysicalDisplayInfo[] nativeGetDisplayConfigs( IBinder displayToken); private static native int nativeGetActiveConfig(IBinder displayToken); private static native boolean nativeSetActiveConfig(IBinder displayToken, int id); private static native void nativeBlankDisplay(IBinder displayToken); private static native void nativeUnblankDisplay(IBinder displayToken); Loading Loading @@ -499,14 +501,25 @@ public class SurfaceControl { nativeBlankDisplay(displayToken); } public static boolean getDisplayInfo(IBinder displayToken, SurfaceControl.PhysicalDisplayInfo outInfo) { public static SurfaceControl.PhysicalDisplayInfo[] getDisplayConfigs(IBinder displayToken) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); } if (outInfo == null) { throw new IllegalArgumentException("outInfo must not be null"); return nativeGetDisplayConfigs(displayToken); } return nativeGetDisplayInfo(displayToken, outInfo); public static int getActiveConfig(IBinder displayToken) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); } return nativeGetActiveConfig(displayToken); } public static boolean setActiveConfig(IBinder displayToken, int id) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); } return nativeSetActiveConfig(displayToken, id); } public static void setDisplayProjection(IBinder displayToken, Loading core/jni/android_view_SurfaceControl.cpp +50 −16 Original line number Diff line number Diff line Loading @@ -50,6 +50,8 @@ static const char* const OutOfResourcesException = "android/view/Surface$OutOfResourcesException"; static struct { jclass clazz; jmethodID ctor; jfieldID width; jfieldID height; jfieldID refreshRate; Loading Loading @@ -346,16 +348,24 @@ static void nativeSetDisplayProjection(JNIEnv* env, jclass clazz, SurfaceComposerClient::setDisplayProjection(token, orientation, layerStackRect, displayRect); } static jboolean nativeGetDisplayInfo(JNIEnv* env, jclass clazz, jobject tokenObj, jobject infoObj) { static jobjectArray nativeGetDisplayConfigs(JNIEnv* env, jclass clazz, jobject tokenObj) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return JNI_FALSE; if (token == NULL) return NULL; DisplayInfo info; if (SurfaceComposerClient::getDisplayInfo(token, &info)) { return JNI_FALSE; Vector<DisplayInfo> configs; if (SurfaceComposerClient::getDisplayConfigs(token, &configs) != NO_ERROR || configs.size() == 0) { return NULL; } jobjectArray configArray = env->NewObjectArray(configs.size(), gPhysicalDisplayInfoClassInfo.clazz, NULL); for (size_t c = 0; c < configs.size(); ++c) { const DisplayInfo& info = configs[c]; jobject infoObj = env->NewObject(gPhysicalDisplayInfoClassInfo.clazz, gPhysicalDisplayInfoClassInfo.ctor); env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.width, info.w); env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.height, info.h); env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.refreshRate, info.fps); Loading @@ -363,7 +373,24 @@ static jboolean nativeGetDisplayInfo(JNIEnv* env, jclass clazz, env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.xDpi, info.xdpi); env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.yDpi, info.ydpi); env->SetBooleanField(infoObj, gPhysicalDisplayInfoClassInfo.secure, info.secure); return JNI_TRUE; env->SetObjectArrayElement(configArray, static_cast<jsize>(c), infoObj); env->DeleteLocalRef(infoObj); } return configArray; } static jint nativeGetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return -1; return static_cast<jint>(SurfaceComposerClient::getActiveConfig(token)); } static jboolean nativeSetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj, jint id) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return JNI_FALSE; status_t err = SurfaceComposerClient::setActiveConfig(token, static_cast<int>(id)); return err == NO_ERROR ? JNI_TRUE : JNI_FALSE; } static void nativeBlankDisplay(JNIEnv* env, jclass clazz, jobject tokenObj) { Loading Loading @@ -576,8 +603,12 @@ static JNINativeMethod sSurfaceControlMethods[] = { (void*)nativeSetDisplayLayerStack }, {"nativeSetDisplayProjection", "(Landroid/os/IBinder;IIIIIIIII)V", (void*)nativeSetDisplayProjection }, {"nativeGetDisplayInfo", "(Landroid/os/IBinder;Landroid/view/SurfaceControl$PhysicalDisplayInfo;)Z", (void*)nativeGetDisplayInfo }, {"nativeGetDisplayConfigs", "(Landroid/os/IBinder;)[Landroid/view/SurfaceControl$PhysicalDisplayInfo;", (void*)nativeGetDisplayConfigs }, {"nativeGetActiveConfig", "(Landroid/os/IBinder;)I", (void*)nativeGetActiveConfig }, {"nativeSetActiveConfig", "(Landroid/os/IBinder;I)Z", (void*)nativeSetActiveConfig }, {"nativeBlankDisplay", "(Landroid/os/IBinder;)V", (void*)nativeBlankDisplay }, {"nativeUnblankDisplay", "(Landroid/os/IBinder;)V", Loading @@ -598,6 +629,9 @@ int register_android_view_SurfaceControl(JNIEnv* env) sSurfaceControlMethods, NELEM(sSurfaceControlMethods)); jclass clazz = env->FindClass("android/view/SurfaceControl$PhysicalDisplayInfo"); gPhysicalDisplayInfoClassInfo.clazz = static_cast<jclass>(env->NewGlobalRef(clazz)); gPhysicalDisplayInfoClassInfo.ctor = env->GetMethodID(gPhysicalDisplayInfoClassInfo.clazz, "<init>", "()V"); gPhysicalDisplayInfoClassInfo.width = env->GetFieldID(clazz, "width", "I"); gPhysicalDisplayInfoClassInfo.height = env->GetFieldID(clazz, "height", "I"); gPhysicalDisplayInfoClassInfo.refreshRate = env->GetFieldID(clazz, "refreshRate", "F"); Loading services/core/java/com/android/server/display/LocalDisplayAdapter.java +22 −6 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.os.Handler; import android.os.IBinder; import android.os.Looper; import android.os.SystemProperties; import android.util.Slog; import android.util.SparseArray; import android.view.Display; import android.view.DisplayEventReceiver; Loading @@ -47,8 +48,6 @@ final class LocalDisplayAdapter extends DisplayAdapter { new SparseArray<LocalDisplayDevice>(); private HotplugDisplayEventReceiver mHotplugReceiver; private final SurfaceControl.PhysicalDisplayInfo mTempPhys = new SurfaceControl.PhysicalDisplayInfo(); // Called with SyncRoot lock held. public LocalDisplayAdapter(DisplayManagerService.SyncRoot syncRoot, Context context, Handler handler, Listener listener) { Loading @@ -68,14 +67,31 @@ final class LocalDisplayAdapter extends DisplayAdapter { private void tryConnectDisplayLocked(int builtInDisplayId) { IBinder displayToken = SurfaceControl.getBuiltInDisplay(builtInDisplayId); if (displayToken != null && SurfaceControl.getDisplayInfo(displayToken, mTempPhys)) { if (displayToken != null) { SurfaceControl.PhysicalDisplayInfo[] configs = SurfaceControl.getDisplayConfigs(displayToken); if (configs == null) { // There are no valid configs for this device, so we can't use it Slog.w(TAG, "No valid configs found for display device " + builtInDisplayId); return; } int activeConfig = SurfaceControl.getActiveConfig(displayToken); if (activeConfig < 0) { // There is no active config, and for now we don't have the // policy to set one. Slog.w(TAG, "No active config found for display device " + builtInDisplayId); return; } LocalDisplayDevice device = mDevices.get(builtInDisplayId); if (device == null) { // Display was added. device = new LocalDisplayDevice(displayToken, builtInDisplayId, mTempPhys); device = new LocalDisplayDevice(displayToken, builtInDisplayId, configs[activeConfig]); mDevices.put(builtInDisplayId, device); sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_ADDED); } else if (device.updatePhysicalDisplayInfoLocked(mTempPhys)) { } else if (device.updatePhysicalDisplayInfoLocked(configs[activeConfig])) { // Display properties changed. sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_CHANGED); } Loading Loading
core/java/android/view/SurfaceControl.java +19 −6 Original line number Diff line number Diff line Loading @@ -74,8 +74,10 @@ public class SurfaceControl { IBinder displayToken, int orientation, int l, int t, int r, int b, int L, int T, int R, int B); private static native boolean nativeGetDisplayInfo( IBinder displayToken, SurfaceControl.PhysicalDisplayInfo outInfo); private static native SurfaceControl.PhysicalDisplayInfo[] nativeGetDisplayConfigs( IBinder displayToken); private static native int nativeGetActiveConfig(IBinder displayToken); private static native boolean nativeSetActiveConfig(IBinder displayToken, int id); private static native void nativeBlankDisplay(IBinder displayToken); private static native void nativeUnblankDisplay(IBinder displayToken); Loading Loading @@ -499,14 +501,25 @@ public class SurfaceControl { nativeBlankDisplay(displayToken); } public static boolean getDisplayInfo(IBinder displayToken, SurfaceControl.PhysicalDisplayInfo outInfo) { public static SurfaceControl.PhysicalDisplayInfo[] getDisplayConfigs(IBinder displayToken) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); } if (outInfo == null) { throw new IllegalArgumentException("outInfo must not be null"); return nativeGetDisplayConfigs(displayToken); } return nativeGetDisplayInfo(displayToken, outInfo); public static int getActiveConfig(IBinder displayToken) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); } return nativeGetActiveConfig(displayToken); } public static boolean setActiveConfig(IBinder displayToken, int id) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); } return nativeSetActiveConfig(displayToken, id); } public static void setDisplayProjection(IBinder displayToken, Loading
core/jni/android_view_SurfaceControl.cpp +50 −16 Original line number Diff line number Diff line Loading @@ -50,6 +50,8 @@ static const char* const OutOfResourcesException = "android/view/Surface$OutOfResourcesException"; static struct { jclass clazz; jmethodID ctor; jfieldID width; jfieldID height; jfieldID refreshRate; Loading Loading @@ -346,16 +348,24 @@ static void nativeSetDisplayProjection(JNIEnv* env, jclass clazz, SurfaceComposerClient::setDisplayProjection(token, orientation, layerStackRect, displayRect); } static jboolean nativeGetDisplayInfo(JNIEnv* env, jclass clazz, jobject tokenObj, jobject infoObj) { static jobjectArray nativeGetDisplayConfigs(JNIEnv* env, jclass clazz, jobject tokenObj) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return JNI_FALSE; if (token == NULL) return NULL; DisplayInfo info; if (SurfaceComposerClient::getDisplayInfo(token, &info)) { return JNI_FALSE; Vector<DisplayInfo> configs; if (SurfaceComposerClient::getDisplayConfigs(token, &configs) != NO_ERROR || configs.size() == 0) { return NULL; } jobjectArray configArray = env->NewObjectArray(configs.size(), gPhysicalDisplayInfoClassInfo.clazz, NULL); for (size_t c = 0; c < configs.size(); ++c) { const DisplayInfo& info = configs[c]; jobject infoObj = env->NewObject(gPhysicalDisplayInfoClassInfo.clazz, gPhysicalDisplayInfoClassInfo.ctor); env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.width, info.w); env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.height, info.h); env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.refreshRate, info.fps); Loading @@ -363,7 +373,24 @@ static jboolean nativeGetDisplayInfo(JNIEnv* env, jclass clazz, env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.xDpi, info.xdpi); env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.yDpi, info.ydpi); env->SetBooleanField(infoObj, gPhysicalDisplayInfoClassInfo.secure, info.secure); return JNI_TRUE; env->SetObjectArrayElement(configArray, static_cast<jsize>(c), infoObj); env->DeleteLocalRef(infoObj); } return configArray; } static jint nativeGetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return -1; return static_cast<jint>(SurfaceComposerClient::getActiveConfig(token)); } static jboolean nativeSetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj, jint id) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return JNI_FALSE; status_t err = SurfaceComposerClient::setActiveConfig(token, static_cast<int>(id)); return err == NO_ERROR ? JNI_TRUE : JNI_FALSE; } static void nativeBlankDisplay(JNIEnv* env, jclass clazz, jobject tokenObj) { Loading Loading @@ -576,8 +603,12 @@ static JNINativeMethod sSurfaceControlMethods[] = { (void*)nativeSetDisplayLayerStack }, {"nativeSetDisplayProjection", "(Landroid/os/IBinder;IIIIIIIII)V", (void*)nativeSetDisplayProjection }, {"nativeGetDisplayInfo", "(Landroid/os/IBinder;Landroid/view/SurfaceControl$PhysicalDisplayInfo;)Z", (void*)nativeGetDisplayInfo }, {"nativeGetDisplayConfigs", "(Landroid/os/IBinder;)[Landroid/view/SurfaceControl$PhysicalDisplayInfo;", (void*)nativeGetDisplayConfigs }, {"nativeGetActiveConfig", "(Landroid/os/IBinder;)I", (void*)nativeGetActiveConfig }, {"nativeSetActiveConfig", "(Landroid/os/IBinder;I)Z", (void*)nativeSetActiveConfig }, {"nativeBlankDisplay", "(Landroid/os/IBinder;)V", (void*)nativeBlankDisplay }, {"nativeUnblankDisplay", "(Landroid/os/IBinder;)V", Loading @@ -598,6 +629,9 @@ int register_android_view_SurfaceControl(JNIEnv* env) sSurfaceControlMethods, NELEM(sSurfaceControlMethods)); jclass clazz = env->FindClass("android/view/SurfaceControl$PhysicalDisplayInfo"); gPhysicalDisplayInfoClassInfo.clazz = static_cast<jclass>(env->NewGlobalRef(clazz)); gPhysicalDisplayInfoClassInfo.ctor = env->GetMethodID(gPhysicalDisplayInfoClassInfo.clazz, "<init>", "()V"); gPhysicalDisplayInfoClassInfo.width = env->GetFieldID(clazz, "width", "I"); gPhysicalDisplayInfoClassInfo.height = env->GetFieldID(clazz, "height", "I"); gPhysicalDisplayInfoClassInfo.refreshRate = env->GetFieldID(clazz, "refreshRate", "F"); Loading
services/core/java/com/android/server/display/LocalDisplayAdapter.java +22 −6 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.os.Handler; import android.os.IBinder; import android.os.Looper; import android.os.SystemProperties; import android.util.Slog; import android.util.SparseArray; import android.view.Display; import android.view.DisplayEventReceiver; Loading @@ -47,8 +48,6 @@ final class LocalDisplayAdapter extends DisplayAdapter { new SparseArray<LocalDisplayDevice>(); private HotplugDisplayEventReceiver mHotplugReceiver; private final SurfaceControl.PhysicalDisplayInfo mTempPhys = new SurfaceControl.PhysicalDisplayInfo(); // Called with SyncRoot lock held. public LocalDisplayAdapter(DisplayManagerService.SyncRoot syncRoot, Context context, Handler handler, Listener listener) { Loading @@ -68,14 +67,31 @@ final class LocalDisplayAdapter extends DisplayAdapter { private void tryConnectDisplayLocked(int builtInDisplayId) { IBinder displayToken = SurfaceControl.getBuiltInDisplay(builtInDisplayId); if (displayToken != null && SurfaceControl.getDisplayInfo(displayToken, mTempPhys)) { if (displayToken != null) { SurfaceControl.PhysicalDisplayInfo[] configs = SurfaceControl.getDisplayConfigs(displayToken); if (configs == null) { // There are no valid configs for this device, so we can't use it Slog.w(TAG, "No valid configs found for display device " + builtInDisplayId); return; } int activeConfig = SurfaceControl.getActiveConfig(displayToken); if (activeConfig < 0) { // There is no active config, and for now we don't have the // policy to set one. Slog.w(TAG, "No active config found for display device " + builtInDisplayId); return; } LocalDisplayDevice device = mDevices.get(builtInDisplayId); if (device == null) { // Display was added. device = new LocalDisplayDevice(displayToken, builtInDisplayId, mTempPhys); device = new LocalDisplayDevice(displayToken, builtInDisplayId, configs[activeConfig]); mDevices.put(builtInDisplayId, device); sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_ADDED); } else if (device.updatePhysicalDisplayInfoLocked(mTempPhys)) { } else if (device.updatePhysicalDisplayInfoLocked(configs[activeConfig])) { // Display properties changed. sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_CHANGED); } Loading