Loading services/core/java/com/android/server/wm/LetterboxConfiguration.java +1 −30 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.server.wm; import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM; import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME; import android.annotation.DimenRes; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; Loading @@ -29,11 +28,11 @@ import android.provider.DeviceConfig; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.server.wm.utils.DimenPxIntSupplier; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.function.Function; import java.util.function.IntSupplier; /** Reads letterbox configs from resources and controls their overrides at runtime. */ final class LetterboxConfiguration { Loading Loading @@ -308,34 +307,6 @@ final class LetterboxConfiguration { // Flags dynamically updated with {@link android.provider.DeviceConfig}. @NonNull private final SynchedDeviceConfig mDeviceConfig; // Cached version of IntSupplier customised to evaluate new dimen in pixels // when density changes private static class DimenPxIntSupplier implements IntSupplier { @NonNull private final Context mContext; private final int mResourceId; private float mLastDensity = Float.MIN_VALUE; private int mValue = 0; private DimenPxIntSupplier(@NonNull Context context, @DimenRes int resourceId) { mContext = context; mResourceId = resourceId; } @Override public int getAsInt() { final float newDensity = mContext.getResources().getDisplayMetrics().density; if (newDensity != mLastDensity) { mLastDensity = newDensity; mValue = mContext.getResources().getDimensionPixelSize(mResourceId); } return mValue; } } LetterboxConfiguration(@NonNull final Context systemUiContext) { this(systemUiContext, new LetterboxConfigurationPersister( () -> readLetterboxHorizontalReachabilityPositionFromConfig( Loading services/core/java/com/android/server/wm/utils/DimenPxIntSupplier.java 0 → 100644 +54 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.wm.utils; import android.annotation.DimenRes; import android.annotation.NonNull; import android.content.Context; import java.util.function.IntSupplier; /** * Cached version of IntSupplier customised to evaluate new dimen in pixels * when density changes. * @hide */ public class DimenPxIntSupplier implements IntSupplier { @NonNull private final Context mContext; private final int mResourceId; private float mLastDensity = Float.MIN_VALUE; private int mValue = 0; public DimenPxIntSupplier(@NonNull Context context, @DimenRes int resourceId) { mContext = context; mResourceId = resourceId; } @Override public int getAsInt() { final float newDensity = mContext.getResources().getDisplayMetrics().density; if (newDensity != mLastDensity) { mLastDensity = newDensity; mValue = mContext.getResources().getDimensionPixelSize(mResourceId); } return mValue; } } Loading
services/core/java/com/android/server/wm/LetterboxConfiguration.java +1 −30 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.server.wm; import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM; import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME; import android.annotation.DimenRes; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; Loading @@ -29,11 +28,11 @@ import android.provider.DeviceConfig; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.server.wm.utils.DimenPxIntSupplier; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.function.Function; import java.util.function.IntSupplier; /** Reads letterbox configs from resources and controls their overrides at runtime. */ final class LetterboxConfiguration { Loading Loading @@ -308,34 +307,6 @@ final class LetterboxConfiguration { // Flags dynamically updated with {@link android.provider.DeviceConfig}. @NonNull private final SynchedDeviceConfig mDeviceConfig; // Cached version of IntSupplier customised to evaluate new dimen in pixels // when density changes private static class DimenPxIntSupplier implements IntSupplier { @NonNull private final Context mContext; private final int mResourceId; private float mLastDensity = Float.MIN_VALUE; private int mValue = 0; private DimenPxIntSupplier(@NonNull Context context, @DimenRes int resourceId) { mContext = context; mResourceId = resourceId; } @Override public int getAsInt() { final float newDensity = mContext.getResources().getDisplayMetrics().density; if (newDensity != mLastDensity) { mLastDensity = newDensity; mValue = mContext.getResources().getDimensionPixelSize(mResourceId); } return mValue; } } LetterboxConfiguration(@NonNull final Context systemUiContext) { this(systemUiContext, new LetterboxConfigurationPersister( () -> readLetterboxHorizontalReachabilityPositionFromConfig( Loading
services/core/java/com/android/server/wm/utils/DimenPxIntSupplier.java 0 → 100644 +54 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.wm.utils; import android.annotation.DimenRes; import android.annotation.NonNull; import android.content.Context; import java.util.function.IntSupplier; /** * Cached version of IntSupplier customised to evaluate new dimen in pixels * when density changes. * @hide */ public class DimenPxIntSupplier implements IntSupplier { @NonNull private final Context mContext; private final int mResourceId; private float mLastDensity = Float.MIN_VALUE; private int mValue = 0; public DimenPxIntSupplier(@NonNull Context context, @DimenRes int resourceId) { mContext = context; mResourceId = resourceId; } @Override public int getAsInt() { final float newDensity = mContext.getResources().getDisplayMetrics().density; if (newDensity != mLastDensity) { mLastDensity = newDensity; mValue = mContext.getResources().getDimensionPixelSize(mResourceId); } return mValue; } }