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

Commit 72a88a61 authored by Nicolo' Mazzucato's avatar Nicolo' Mazzucato Committed by Nicolò Mazzucato
Browse files

Fix getResourcesForRotation to avoid overriding the entire configuration

The configuration context created was overriding the entire
configuration, which is wrong: if anything in the base context changes
(e.g. display caracteristics), we want it to be reflected in the new
context and resources.

While this didn't result in any user visible issue right now (as this resource instance was never being cached), it could have (as we've seen in several other cases.

Bug: 437082130
Test: NONE - small bugfix, hard to test reliably
Flag: com.android.systemui.shared.status_bar_connected_displays
Change-Id: Iccb0e890955353d817ef396bea90a56be26bd026
parent 569439c6
Loading
Loading
Loading
Loading
+12 −1
Original line number Original line Diff line number Diff line
@@ -25,6 +25,8 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.Resources;
import android.view.Surface;
import android.view.Surface;


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

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


@@ -138,7 +140,16 @@ public final class RotationUtils {
            default:
            default:
                throw new IllegalArgumentException("Unknown rotation: " + rot);
                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;
        c.orientation = orientation;
        Context rotated = context.createConfigurationContext(c);
        Context rotated = context.createConfigurationContext(c);
        return rotated.getResources();
        return rotated.getResources();