Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5645a41b authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix getResourcesForRotation to avoid overriding the entire configuration" into main

parents 87f9744c 72a88a61
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.view.Surface;

import com.android.systemui.statusbar.core.StatusBarConnectedDisplays;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@@ -138,7 +140,16 @@ public final class RotationUtils {
            default:
                throw new IllegalArgumentException("Unknown rotation: " + rot);
        }
        Configuration c = new Configuration(context.getResources().getConfiguration());
        Configuration c;
        if (StatusBarConnectedDisplays.isEnabled()) {
            // Create an empty config to use as an override. This ensures the new context inherits
            // other configuration values from the base context and stays up to date.
            // we only want to override the orientation, and not anything else.
            c = new Configuration();
        } else {
            // Legacy behavior: copy the full configuration, creating a static snapshot.
            c = new Configuration(context.getResources().getConfiguration());
        }
        c.orientation = orientation;
        Context rotated = context.createConfigurationContext(c);
        return rotated.getResources();