Loading core/java/com/android/internal/policy/ScreenDecorationsUtils.java +23 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,9 @@ package com.android.internal.policy; import android.content.Context; import android.content.res.Resources; import android.util.DisplayUtils; import android.view.Display; import android.view.DisplayInfo; import android.view.RoundedCorners; import com.android.internal.R; Loading Loading @@ -57,11 +60,31 @@ public class ScreenDecorationsUtils { bottomRadius = defaultRadius; } // If the physical pixels are scaled, apply it here float scale = getPhysicalPixelDisplaySizeRatio(context); if (scale != 1f) { topRadius = topRadius * scale; bottomRadius = bottomRadius * scale; } // Always use the smallest radius to make sure the rounded corners will // completely cover the display. return Math.min(topRadius, bottomRadius); } static float getPhysicalPixelDisplaySizeRatio(Context context) { DisplayInfo displayInfo = new DisplayInfo(); context.getDisplay().getDisplayInfo(displayInfo); final Display.Mode maxDisplayMode = DisplayUtils.getMaximumResolutionDisplayMode(displayInfo.supportedModes); if (maxDisplayMode == null) { return 1f; } return DisplayUtils.getPhysicalPixelDisplaySizeRatio( maxDisplayMode.getPhysicalWidth(), maxDisplayMode.getPhysicalHeight(), displayInfo.getNaturalWidth(), displayInfo.getNaturalHeight()); } /** * If live rounded corners are supported on windows. */ Loading Loading
core/java/com/android/internal/policy/ScreenDecorationsUtils.java +23 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,9 @@ package com.android.internal.policy; import android.content.Context; import android.content.res.Resources; import android.util.DisplayUtils; import android.view.Display; import android.view.DisplayInfo; import android.view.RoundedCorners; import com.android.internal.R; Loading Loading @@ -57,11 +60,31 @@ public class ScreenDecorationsUtils { bottomRadius = defaultRadius; } // If the physical pixels are scaled, apply it here float scale = getPhysicalPixelDisplaySizeRatio(context); if (scale != 1f) { topRadius = topRadius * scale; bottomRadius = bottomRadius * scale; } // Always use the smallest radius to make sure the rounded corners will // completely cover the display. return Math.min(topRadius, bottomRadius); } static float getPhysicalPixelDisplaySizeRatio(Context context) { DisplayInfo displayInfo = new DisplayInfo(); context.getDisplay().getDisplayInfo(displayInfo); final Display.Mode maxDisplayMode = DisplayUtils.getMaximumResolutionDisplayMode(displayInfo.supportedModes); if (maxDisplayMode == null) { return 1f; } return DisplayUtils.getPhysicalPixelDisplaySizeRatio( maxDisplayMode.getPhysicalWidth(), maxDisplayMode.getPhysicalHeight(), displayInfo.getNaturalWidth(), displayInfo.getNaturalHeight()); } /** * If live rounded corners are supported on windows. */ Loading