Loading core/java/android/view/SurfaceControl.java +10 −3 Original line number Diff line number Diff line Loading @@ -1907,16 +1907,23 @@ public final class SurfaceControl implements Parcelable { public float appRequestRefreshRateMin; public float appRequestRefreshRateMax; /** * If true this will allow switching between modes in different display configuration * groups. This way the user may see visual interruptions when the display mode changes. */ public boolean allowGroupSwitching; public DesiredDisplayConfigSpecs() {} public DesiredDisplayConfigSpecs(DesiredDisplayConfigSpecs other) { copyFrom(other); } public DesiredDisplayConfigSpecs(int defaultConfig, float primaryRefreshRateMin, float primaryRefreshRateMax, float appRequestRefreshRateMin, float appRequestRefreshRateMax) { public DesiredDisplayConfigSpecs(int defaultConfig, boolean allowGroupSwitching, float primaryRefreshRateMin, float primaryRefreshRateMax, float appRequestRefreshRateMin, float appRequestRefreshRateMax) { this.defaultConfig = defaultConfig; this.allowGroupSwitching = allowGroupSwitching; this.primaryRefreshRateMin = primaryRefreshRateMin; this.primaryRefreshRateMax = primaryRefreshRateMax; this.appRequestRefreshRateMin = appRequestRefreshRateMin; Loading core/jni/android_view_SurfaceControl.cpp +12 −3 Original line number Diff line number Diff line Loading @@ -196,6 +196,7 @@ static struct { jclass clazz; jmethodID ctor; jfieldID defaultConfig; jfieldID allowGroupSwitching; jfieldID primaryRefreshRateMin; jfieldID primaryRefreshRateMax; jfieldID appRequestRefreshRateMin; Loading Loading @@ -1003,6 +1004,9 @@ static jboolean nativeSetDesiredDisplayConfigSpecs(JNIEnv* env, jclass clazz, jo jint defaultConfig = env->GetIntField(desiredDisplayConfigSpecs, gDesiredDisplayConfigSpecsClassInfo.defaultConfig); jboolean allowGroupSwitching = env->GetBooleanField(desiredDisplayConfigSpecs, gDesiredDisplayConfigSpecsClassInfo.allowGroupSwitching); jfloat primaryRefreshRateMin = env->GetFloatField(desiredDisplayConfigSpecs, gDesiredDisplayConfigSpecsClassInfo.primaryRefreshRateMin); Loading @@ -1017,6 +1021,7 @@ static jboolean nativeSetDesiredDisplayConfigSpecs(JNIEnv* env, jclass clazz, jo gDesiredDisplayConfigSpecsClassInfo.appRequestRefreshRateMax); size_t result = SurfaceComposerClient::setDesiredDisplayConfigSpecs(token, defaultConfig, allowGroupSwitching, primaryRefreshRateMin, primaryRefreshRateMax, appRequestRefreshRateMin, Loading @@ -1029,11 +1034,13 @@ static jobject nativeGetDesiredDisplayConfigSpecs(JNIEnv* env, jclass clazz, job if (token == nullptr) return nullptr; int32_t defaultConfig; bool allowGroupSwitching; float primaryRefreshRateMin; float primaryRefreshRateMax; float appRequestRefreshRateMin; float appRequestRefreshRateMax; if (SurfaceComposerClient::getDesiredDisplayConfigSpecs(token, &defaultConfig, &allowGroupSwitching, &primaryRefreshRateMin, &primaryRefreshRateMax, &appRequestRefreshRateMin, Loading @@ -1044,8 +1051,8 @@ static jobject nativeGetDesiredDisplayConfigSpecs(JNIEnv* env, jclass clazz, job return env->NewObject(gDesiredDisplayConfigSpecsClassInfo.clazz, gDesiredDisplayConfigSpecsClassInfo.ctor, defaultConfig, primaryRefreshRateMin, primaryRefreshRateMax, appRequestRefreshRateMin, appRequestRefreshRateMax); allowGroupSwitching, primaryRefreshRateMin, primaryRefreshRateMax, appRequestRefreshRateMin, appRequestRefreshRateMax); } static jint nativeGetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj) { Loading Loading @@ -1862,9 +1869,11 @@ int register_android_view_SurfaceControl(JNIEnv* env) gDesiredDisplayConfigSpecsClassInfo.clazz = MakeGlobalRefOrDie(env, desiredDisplayConfigSpecsClazz); gDesiredDisplayConfigSpecsClassInfo.ctor = GetMethodIDOrDie(env, gDesiredDisplayConfigSpecsClassInfo.clazz, "<init>", "(IFFFF)V"); GetMethodIDOrDie(env, gDesiredDisplayConfigSpecsClassInfo.clazz, "<init>", "(IZFFFF)V"); gDesiredDisplayConfigSpecsClassInfo.defaultConfig = GetFieldIDOrDie(env, desiredDisplayConfigSpecsClazz, "defaultConfig", "I"); gDesiredDisplayConfigSpecsClassInfo.allowGroupSwitching = GetFieldIDOrDie(env, desiredDisplayConfigSpecsClazz, "allowGroupSwitching", "Z"); gDesiredDisplayConfigSpecsClassInfo.primaryRefreshRateMin = GetFieldIDOrDie(env, desiredDisplayConfigSpecsClazz, "primaryRefreshRateMin", "F"); gDesiredDisplayConfigSpecsClassInfo.primaryRefreshRateMax = Loading services/core/java/com/android/server/display/DisplayModeDirector.java +109 −9 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.display; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.ContentResolver; Loading Loading @@ -50,11 +51,14 @@ import com.android.server.display.utils.AmbientFilter; import com.android.server.display.utils.AmbientFilterFactory; import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Objects; /** * The DisplayModeDirector is responsible for determining what modes are allowed to be automatically * picked by the system based on system-wide and display-specific configuration. Loading Loading @@ -99,6 +103,29 @@ public class DisplayModeDirector { private boolean mAlwaysRespectAppRequest; @IntDef(prefix = {"SWITCHING_TYPE_"}, value = { SWITCHING_TYPE_NONE, SWITCHING_TYPE_WITHIN_GROUPS, SWITCHING_TYPE_ACROSS_AND_WITHIN_GROUPS, }) @Retention(RetentionPolicy.SOURCE) public @interface SwitchingType {} // No mode switching will happen. public static final int SWITCHING_TYPE_NONE = 0; // Allow only refresh rate switching between modes in the same configuration group. This way // only switches without visual interruptions for the user will be allowed. public static final int SWITCHING_TYPE_WITHIN_GROUPS = 1; // Allow refresh rate switching between all refresh rates even if the switch with have visual // interruptions for the user. public static final int SWITCHING_TYPE_ACROSS_AND_WITHIN_GROUPS = 2; /** * The allowed refresh rate switching type. This is used by SurfaceFlinger. */ @SwitchingType private int mModeSwitchingType = SWITCHING_TYPE_WITHIN_GROUPS; public DisplayModeDirector(@NonNull Context context, @NonNull Handler handler) { mContext = context; mHandler = new DisplayModeDirectorHandler(handler.getLooper()); Loading Loading @@ -290,14 +317,37 @@ public class DisplayModeDirector { appRequestSummary.maxRefreshRate)); } // If the application requests a given mode with preferredModeId function, it will be // stored as baseModeId. int baseModeId = defaultMode.getModeId(); if (availableModes.length > 0) { baseModeId = availableModes[0]; } // filterModes function is going to filter the modes based on the voting system. If // the application requests a given mode with preferredModeId function, it will be // stored as baseModeId. if (mModeSwitchingType == SWITCHING_TYPE_NONE) { Display.Mode baseMode = null; for (Display.Mode mode : modes) { if (mode.getModeId() == baseModeId) { baseMode = mode; break; } } if (baseMode == null) { // This should never happen. throw new IllegalStateException( "The base mode with id " + baseModeId + " is not in the list of supported modes."); } float fps = baseMode.getRefreshRate(); return new DesiredDisplayModeSpecs(baseModeId, /*allowGroupSwitching */ false, new RefreshRateRange(fps, fps), new RefreshRateRange(fps, fps)); } boolean allowGroupSwitching = mModeSwitchingType == SWITCHING_TYPE_ACROSS_AND_WITHIN_GROUPS; return new DesiredDisplayModeSpecs(baseModeId, allowGroupSwitching, new RefreshRateRange( primarySummary.minRefreshRate, primarySummary.maxRefreshRate), new RefreshRateRange( Loading Loading @@ -384,6 +434,26 @@ public class DisplayModeDirector { } } /** * Sets the display mode switching type. * @param type */ public void setModeSwitchingType(@SwitchingType int type) { synchronized (mLock) { mModeSwitchingType = type; } } /** * Returns the display mode switching type. */ @SwitchingType public int getModeSwitchingType() { synchronized (mLock) { return mModeSwitchingType; } } /** * Print the object's state and debug information into the given stream. * Loading Loading @@ -416,6 +486,7 @@ public class DisplayModeDirector { pw.println(" " + Vote.priorityToString(p) + " -> " + vote); } } pw.println(" mModeSwitchingType: " + switchingTypeToString(mModeSwitchingType)); pw.println(" mAlwaysRespectAppRequest: " + mAlwaysRespectAppRequest); mSettingsObserver.dumpLocked(pw); mAppRequestObserver.dumpLocked(pw); Loading Loading @@ -472,7 +543,6 @@ public class DisplayModeDirector { } private SparseArray<Vote> getOrCreateVotesByDisplay(int displayId) { int index = mVotesByDisplay.indexOfKey(displayId); if (mVotesByDisplay.indexOfKey(displayId) >= 0) { return mVotesByDisplay.get(displayId); } else { Loading @@ -482,6 +552,19 @@ public class DisplayModeDirector { } } private static String switchingTypeToString(@SwitchingType int type) { switch (type) { case SWITCHING_TYPE_NONE: return "SWITCHING_TYPE_NONE"; case SWITCHING_TYPE_WITHIN_GROUPS: return "SWITCHING_TYPE_WITHIN_GROUPS"; case SWITCHING_TYPE_ACROSS_AND_WITHIN_GROUPS: return "SWITCHING_TYPE_ACROSS_AND_WITHIN_GROUPS"; default: return "Unknown SwitchingType " + type; } } @VisibleForTesting void injectSupportedModesByDisplay(SparseArray<Display.Mode[]> supportedModesByDisplay) { mSupportedModesByDisplay = supportedModesByDisplay; Loading Loading @@ -631,18 +714,26 @@ public class DisplayModeDirector { * SurfaceControl.DesiredDisplayConfigSpecs uses, and the mode ID used here. */ public static final class DesiredDisplayModeSpecs { /** * Base mode ID. This is what system defaults to for all other settings, or * if the refresh rate range is not available. */ public int baseModeId; /** * If true this will allow switching between modes in different display configuration * groups. This way the user may see visual interruptions when the display mode changes. */ public boolean allowGroupSwitching; /** * The primary refresh rate range. */ public final RefreshRateRange primaryRefreshRateRange; /** * The app request refresh rate range. Lower priority considerations won't be included in * this range, allowing surface flinger to consider additional refresh rates for apps that * this range, allowing SurfaceFlinger to consider additional refresh rates for apps that * call setFrameRate(). This range will be greater than or equal to the primary refresh rate * range, never smaller. */ Loading @@ -654,9 +745,11 @@ public class DisplayModeDirector { } public DesiredDisplayModeSpecs(int baseModeId, boolean allowGroupSwitching, @NonNull RefreshRateRange primaryRefreshRateRange, @NonNull RefreshRateRange appRequestRefreshRateRange) { this.baseModeId = baseModeId; this.allowGroupSwitching = allowGroupSwitching; this.primaryRefreshRateRange = primaryRefreshRateRange; this.appRequestRefreshRateRange = appRequestRefreshRateRange; } Loading @@ -666,10 +759,12 @@ public class DisplayModeDirector { */ @Override public String toString() { return String.format("baseModeId=%d primaryRefreshRateRange=[%.0f %.0f]" return String.format("baseModeId=%d allowGroupSwitching=%b" + " primaryRefreshRateRange=[%.0f %.0f]" + " appRequestRefreshRateRange=[%.0f %.0f]", baseModeId, primaryRefreshRateRange.min, primaryRefreshRateRange.max, appRequestRefreshRateRange.min, appRequestRefreshRateRange.max); baseModeId, allowGroupSwitching, primaryRefreshRateRange.min, primaryRefreshRateRange.max, appRequestRefreshRateRange.min, appRequestRefreshRateRange.max); } /** * Checks whether the two objects have the same values. Loading @@ -689,6 +784,9 @@ public class DisplayModeDirector { if (baseModeId != desiredDisplayModeSpecs.baseModeId) { return false; } if (allowGroupSwitching != desiredDisplayModeSpecs.allowGroupSwitching) { return false; } if (!primaryRefreshRateRange.equals(desiredDisplayModeSpecs.primaryRefreshRateRange)) { return false; } Loading @@ -701,7 +799,8 @@ public class DisplayModeDirector { @Override public int hashCode() { return Objects.hash(baseModeId, primaryRefreshRateRange, appRequestRefreshRateRange); return Objects.hash(baseModeId, allowGroupSwitching, primaryRefreshRateRange, appRequestRefreshRateRange); } /** Loading @@ -709,6 +808,7 @@ public class DisplayModeDirector { */ public void copyFrom(DesiredDisplayModeSpecs other) { baseModeId = other.baseModeId; allowGroupSwitching = other.allowGroupSwitching; primaryRefreshRateRange.min = other.primaryRefreshRateRange.min; primaryRefreshRateRange.max = other.primaryRefreshRateRange.max; appRequestRefreshRateRange.min = other.appRequestRefreshRateRange.min; Loading services/core/java/com/android/server/display/LocalDisplayAdapter.java +1 −0 Original line number Diff line number Diff line Loading @@ -817,6 +817,7 @@ final class LocalDisplayAdapter extends DisplayAdapter { LocalDisplayDevice::setDesiredDisplayModeSpecsAsync, this, getDisplayTokenLocked(), new SurfaceControl.DesiredDisplayConfigSpecs(baseConfigId, mDisplayModeSpecs.allowGroupSwitching, mDisplayModeSpecs.primaryRefreshRateRange.min, mDisplayModeSpecs.primaryRefreshRateRange.max, mDisplayModeSpecs.appRequestRefreshRateRange.min, Loading services/tests/mockingservicestests/src/com/android/server/display/LocalDisplayAdapterTest.java +6 −1 Original line number Diff line number Diff line Loading @@ -429,7 +429,12 @@ public class LocalDisplayAdapterTest { public Display.HdrCapabilities hdrCapabilities = new Display.HdrCapabilities(new int[0], 1000, 1000, 0); public SurfaceControl.DesiredDisplayConfigSpecs desiredDisplayConfigSpecs = new SurfaceControl.DesiredDisplayConfigSpecs(0, 60.f, 60.f, 60.f, 60.f); new SurfaceControl.DesiredDisplayConfigSpecs(/* defaultConfig */ 0, /* allowGroupSwitching */ false, /* primaryRefreshRateMin */ 60.f, /* primaryRefreshRateMax */ 60.f, /* appRefreshRateMin */ 60.f, /* appRefreshRateMax */60.f); private FakeDisplay(int port) { this.address = createDisplayAddress(port); Loading Loading
core/java/android/view/SurfaceControl.java +10 −3 Original line number Diff line number Diff line Loading @@ -1907,16 +1907,23 @@ public final class SurfaceControl implements Parcelable { public float appRequestRefreshRateMin; public float appRequestRefreshRateMax; /** * If true this will allow switching between modes in different display configuration * groups. This way the user may see visual interruptions when the display mode changes. */ public boolean allowGroupSwitching; public DesiredDisplayConfigSpecs() {} public DesiredDisplayConfigSpecs(DesiredDisplayConfigSpecs other) { copyFrom(other); } public DesiredDisplayConfigSpecs(int defaultConfig, float primaryRefreshRateMin, float primaryRefreshRateMax, float appRequestRefreshRateMin, float appRequestRefreshRateMax) { public DesiredDisplayConfigSpecs(int defaultConfig, boolean allowGroupSwitching, float primaryRefreshRateMin, float primaryRefreshRateMax, float appRequestRefreshRateMin, float appRequestRefreshRateMax) { this.defaultConfig = defaultConfig; this.allowGroupSwitching = allowGroupSwitching; this.primaryRefreshRateMin = primaryRefreshRateMin; this.primaryRefreshRateMax = primaryRefreshRateMax; this.appRequestRefreshRateMin = appRequestRefreshRateMin; Loading
core/jni/android_view_SurfaceControl.cpp +12 −3 Original line number Diff line number Diff line Loading @@ -196,6 +196,7 @@ static struct { jclass clazz; jmethodID ctor; jfieldID defaultConfig; jfieldID allowGroupSwitching; jfieldID primaryRefreshRateMin; jfieldID primaryRefreshRateMax; jfieldID appRequestRefreshRateMin; Loading Loading @@ -1003,6 +1004,9 @@ static jboolean nativeSetDesiredDisplayConfigSpecs(JNIEnv* env, jclass clazz, jo jint defaultConfig = env->GetIntField(desiredDisplayConfigSpecs, gDesiredDisplayConfigSpecsClassInfo.defaultConfig); jboolean allowGroupSwitching = env->GetBooleanField(desiredDisplayConfigSpecs, gDesiredDisplayConfigSpecsClassInfo.allowGroupSwitching); jfloat primaryRefreshRateMin = env->GetFloatField(desiredDisplayConfigSpecs, gDesiredDisplayConfigSpecsClassInfo.primaryRefreshRateMin); Loading @@ -1017,6 +1021,7 @@ static jboolean nativeSetDesiredDisplayConfigSpecs(JNIEnv* env, jclass clazz, jo gDesiredDisplayConfigSpecsClassInfo.appRequestRefreshRateMax); size_t result = SurfaceComposerClient::setDesiredDisplayConfigSpecs(token, defaultConfig, allowGroupSwitching, primaryRefreshRateMin, primaryRefreshRateMax, appRequestRefreshRateMin, Loading @@ -1029,11 +1034,13 @@ static jobject nativeGetDesiredDisplayConfigSpecs(JNIEnv* env, jclass clazz, job if (token == nullptr) return nullptr; int32_t defaultConfig; bool allowGroupSwitching; float primaryRefreshRateMin; float primaryRefreshRateMax; float appRequestRefreshRateMin; float appRequestRefreshRateMax; if (SurfaceComposerClient::getDesiredDisplayConfigSpecs(token, &defaultConfig, &allowGroupSwitching, &primaryRefreshRateMin, &primaryRefreshRateMax, &appRequestRefreshRateMin, Loading @@ -1044,8 +1051,8 @@ static jobject nativeGetDesiredDisplayConfigSpecs(JNIEnv* env, jclass clazz, job return env->NewObject(gDesiredDisplayConfigSpecsClassInfo.clazz, gDesiredDisplayConfigSpecsClassInfo.ctor, defaultConfig, primaryRefreshRateMin, primaryRefreshRateMax, appRequestRefreshRateMin, appRequestRefreshRateMax); allowGroupSwitching, primaryRefreshRateMin, primaryRefreshRateMax, appRequestRefreshRateMin, appRequestRefreshRateMax); } static jint nativeGetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj) { Loading Loading @@ -1862,9 +1869,11 @@ int register_android_view_SurfaceControl(JNIEnv* env) gDesiredDisplayConfigSpecsClassInfo.clazz = MakeGlobalRefOrDie(env, desiredDisplayConfigSpecsClazz); gDesiredDisplayConfigSpecsClassInfo.ctor = GetMethodIDOrDie(env, gDesiredDisplayConfigSpecsClassInfo.clazz, "<init>", "(IFFFF)V"); GetMethodIDOrDie(env, gDesiredDisplayConfigSpecsClassInfo.clazz, "<init>", "(IZFFFF)V"); gDesiredDisplayConfigSpecsClassInfo.defaultConfig = GetFieldIDOrDie(env, desiredDisplayConfigSpecsClazz, "defaultConfig", "I"); gDesiredDisplayConfigSpecsClassInfo.allowGroupSwitching = GetFieldIDOrDie(env, desiredDisplayConfigSpecsClazz, "allowGroupSwitching", "Z"); gDesiredDisplayConfigSpecsClassInfo.primaryRefreshRateMin = GetFieldIDOrDie(env, desiredDisplayConfigSpecsClazz, "primaryRefreshRateMin", "F"); gDesiredDisplayConfigSpecsClassInfo.primaryRefreshRateMax = Loading
services/core/java/com/android/server/display/DisplayModeDirector.java +109 −9 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.display; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.ContentResolver; Loading Loading @@ -50,11 +51,14 @@ import com.android.server.display.utils.AmbientFilter; import com.android.server.display.utils.AmbientFilterFactory; import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Objects; /** * The DisplayModeDirector is responsible for determining what modes are allowed to be automatically * picked by the system based on system-wide and display-specific configuration. Loading Loading @@ -99,6 +103,29 @@ public class DisplayModeDirector { private boolean mAlwaysRespectAppRequest; @IntDef(prefix = {"SWITCHING_TYPE_"}, value = { SWITCHING_TYPE_NONE, SWITCHING_TYPE_WITHIN_GROUPS, SWITCHING_TYPE_ACROSS_AND_WITHIN_GROUPS, }) @Retention(RetentionPolicy.SOURCE) public @interface SwitchingType {} // No mode switching will happen. public static final int SWITCHING_TYPE_NONE = 0; // Allow only refresh rate switching between modes in the same configuration group. This way // only switches without visual interruptions for the user will be allowed. public static final int SWITCHING_TYPE_WITHIN_GROUPS = 1; // Allow refresh rate switching between all refresh rates even if the switch with have visual // interruptions for the user. public static final int SWITCHING_TYPE_ACROSS_AND_WITHIN_GROUPS = 2; /** * The allowed refresh rate switching type. This is used by SurfaceFlinger. */ @SwitchingType private int mModeSwitchingType = SWITCHING_TYPE_WITHIN_GROUPS; public DisplayModeDirector(@NonNull Context context, @NonNull Handler handler) { mContext = context; mHandler = new DisplayModeDirectorHandler(handler.getLooper()); Loading Loading @@ -290,14 +317,37 @@ public class DisplayModeDirector { appRequestSummary.maxRefreshRate)); } // If the application requests a given mode with preferredModeId function, it will be // stored as baseModeId. int baseModeId = defaultMode.getModeId(); if (availableModes.length > 0) { baseModeId = availableModes[0]; } // filterModes function is going to filter the modes based on the voting system. If // the application requests a given mode with preferredModeId function, it will be // stored as baseModeId. if (mModeSwitchingType == SWITCHING_TYPE_NONE) { Display.Mode baseMode = null; for (Display.Mode mode : modes) { if (mode.getModeId() == baseModeId) { baseMode = mode; break; } } if (baseMode == null) { // This should never happen. throw new IllegalStateException( "The base mode with id " + baseModeId + " is not in the list of supported modes."); } float fps = baseMode.getRefreshRate(); return new DesiredDisplayModeSpecs(baseModeId, /*allowGroupSwitching */ false, new RefreshRateRange(fps, fps), new RefreshRateRange(fps, fps)); } boolean allowGroupSwitching = mModeSwitchingType == SWITCHING_TYPE_ACROSS_AND_WITHIN_GROUPS; return new DesiredDisplayModeSpecs(baseModeId, allowGroupSwitching, new RefreshRateRange( primarySummary.minRefreshRate, primarySummary.maxRefreshRate), new RefreshRateRange( Loading Loading @@ -384,6 +434,26 @@ public class DisplayModeDirector { } } /** * Sets the display mode switching type. * @param type */ public void setModeSwitchingType(@SwitchingType int type) { synchronized (mLock) { mModeSwitchingType = type; } } /** * Returns the display mode switching type. */ @SwitchingType public int getModeSwitchingType() { synchronized (mLock) { return mModeSwitchingType; } } /** * Print the object's state and debug information into the given stream. * Loading Loading @@ -416,6 +486,7 @@ public class DisplayModeDirector { pw.println(" " + Vote.priorityToString(p) + " -> " + vote); } } pw.println(" mModeSwitchingType: " + switchingTypeToString(mModeSwitchingType)); pw.println(" mAlwaysRespectAppRequest: " + mAlwaysRespectAppRequest); mSettingsObserver.dumpLocked(pw); mAppRequestObserver.dumpLocked(pw); Loading Loading @@ -472,7 +543,6 @@ public class DisplayModeDirector { } private SparseArray<Vote> getOrCreateVotesByDisplay(int displayId) { int index = mVotesByDisplay.indexOfKey(displayId); if (mVotesByDisplay.indexOfKey(displayId) >= 0) { return mVotesByDisplay.get(displayId); } else { Loading @@ -482,6 +552,19 @@ public class DisplayModeDirector { } } private static String switchingTypeToString(@SwitchingType int type) { switch (type) { case SWITCHING_TYPE_NONE: return "SWITCHING_TYPE_NONE"; case SWITCHING_TYPE_WITHIN_GROUPS: return "SWITCHING_TYPE_WITHIN_GROUPS"; case SWITCHING_TYPE_ACROSS_AND_WITHIN_GROUPS: return "SWITCHING_TYPE_ACROSS_AND_WITHIN_GROUPS"; default: return "Unknown SwitchingType " + type; } } @VisibleForTesting void injectSupportedModesByDisplay(SparseArray<Display.Mode[]> supportedModesByDisplay) { mSupportedModesByDisplay = supportedModesByDisplay; Loading Loading @@ -631,18 +714,26 @@ public class DisplayModeDirector { * SurfaceControl.DesiredDisplayConfigSpecs uses, and the mode ID used here. */ public static final class DesiredDisplayModeSpecs { /** * Base mode ID. This is what system defaults to for all other settings, or * if the refresh rate range is not available. */ public int baseModeId; /** * If true this will allow switching between modes in different display configuration * groups. This way the user may see visual interruptions when the display mode changes. */ public boolean allowGroupSwitching; /** * The primary refresh rate range. */ public final RefreshRateRange primaryRefreshRateRange; /** * The app request refresh rate range. Lower priority considerations won't be included in * this range, allowing surface flinger to consider additional refresh rates for apps that * this range, allowing SurfaceFlinger to consider additional refresh rates for apps that * call setFrameRate(). This range will be greater than or equal to the primary refresh rate * range, never smaller. */ Loading @@ -654,9 +745,11 @@ public class DisplayModeDirector { } public DesiredDisplayModeSpecs(int baseModeId, boolean allowGroupSwitching, @NonNull RefreshRateRange primaryRefreshRateRange, @NonNull RefreshRateRange appRequestRefreshRateRange) { this.baseModeId = baseModeId; this.allowGroupSwitching = allowGroupSwitching; this.primaryRefreshRateRange = primaryRefreshRateRange; this.appRequestRefreshRateRange = appRequestRefreshRateRange; } Loading @@ -666,10 +759,12 @@ public class DisplayModeDirector { */ @Override public String toString() { return String.format("baseModeId=%d primaryRefreshRateRange=[%.0f %.0f]" return String.format("baseModeId=%d allowGroupSwitching=%b" + " primaryRefreshRateRange=[%.0f %.0f]" + " appRequestRefreshRateRange=[%.0f %.0f]", baseModeId, primaryRefreshRateRange.min, primaryRefreshRateRange.max, appRequestRefreshRateRange.min, appRequestRefreshRateRange.max); baseModeId, allowGroupSwitching, primaryRefreshRateRange.min, primaryRefreshRateRange.max, appRequestRefreshRateRange.min, appRequestRefreshRateRange.max); } /** * Checks whether the two objects have the same values. Loading @@ -689,6 +784,9 @@ public class DisplayModeDirector { if (baseModeId != desiredDisplayModeSpecs.baseModeId) { return false; } if (allowGroupSwitching != desiredDisplayModeSpecs.allowGroupSwitching) { return false; } if (!primaryRefreshRateRange.equals(desiredDisplayModeSpecs.primaryRefreshRateRange)) { return false; } Loading @@ -701,7 +799,8 @@ public class DisplayModeDirector { @Override public int hashCode() { return Objects.hash(baseModeId, primaryRefreshRateRange, appRequestRefreshRateRange); return Objects.hash(baseModeId, allowGroupSwitching, primaryRefreshRateRange, appRequestRefreshRateRange); } /** Loading @@ -709,6 +808,7 @@ public class DisplayModeDirector { */ public void copyFrom(DesiredDisplayModeSpecs other) { baseModeId = other.baseModeId; allowGroupSwitching = other.allowGroupSwitching; primaryRefreshRateRange.min = other.primaryRefreshRateRange.min; primaryRefreshRateRange.max = other.primaryRefreshRateRange.max; appRequestRefreshRateRange.min = other.appRequestRefreshRateRange.min; Loading
services/core/java/com/android/server/display/LocalDisplayAdapter.java +1 −0 Original line number Diff line number Diff line Loading @@ -817,6 +817,7 @@ final class LocalDisplayAdapter extends DisplayAdapter { LocalDisplayDevice::setDesiredDisplayModeSpecsAsync, this, getDisplayTokenLocked(), new SurfaceControl.DesiredDisplayConfigSpecs(baseConfigId, mDisplayModeSpecs.allowGroupSwitching, mDisplayModeSpecs.primaryRefreshRateRange.min, mDisplayModeSpecs.primaryRefreshRateRange.max, mDisplayModeSpecs.appRequestRefreshRateRange.min, Loading
services/tests/mockingservicestests/src/com/android/server/display/LocalDisplayAdapterTest.java +6 −1 Original line number Diff line number Diff line Loading @@ -429,7 +429,12 @@ public class LocalDisplayAdapterTest { public Display.HdrCapabilities hdrCapabilities = new Display.HdrCapabilities(new int[0], 1000, 1000, 0); public SurfaceControl.DesiredDisplayConfigSpecs desiredDisplayConfigSpecs = new SurfaceControl.DesiredDisplayConfigSpecs(0, 60.f, 60.f, 60.f, 60.f); new SurfaceControl.DesiredDisplayConfigSpecs(/* defaultConfig */ 0, /* allowGroupSwitching */ false, /* primaryRefreshRateMin */ 60.f, /* primaryRefreshRateMax */ 60.f, /* appRefreshRateMin */ 60.f, /* appRefreshRateMax */60.f); private FakeDisplay(int port) { this.address = createDisplayAddress(port); Loading