Incorrect panel layout after rotation
-Handle onConfigurationChanged and force to update layout -Add test case Bug: 144751509 Test: make -j42 RunSettingsRoboTests Change-Id: Ic170d4f6f045299c0520e899e06b5b4e9f009643
This commit is contained in:
@@ -3180,6 +3180,7 @@
|
||||
android:theme="@style/Theme.Panel"
|
||||
android:launchMode="singleInstance"
|
||||
android:excludeFromRecents="true"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.settings.panel.action.INTERNET_CONNECTIVITY" />
|
||||
|
@@ -19,12 +19,14 @@ package com.android.settings.panel;
|
||||
import static com.android.settingslib.media.MediaOutputSliceConstants.EXTRA_PACKAGE_NAME;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
@@ -43,6 +45,8 @@ public class SettingsPanelActivity extends FragmentActivity {
|
||||
|
||||
@VisibleForTesting
|
||||
final Bundle mBundle = new Bundle();
|
||||
@VisibleForTesting
|
||||
boolean mForceCreation = false;
|
||||
|
||||
/**
|
||||
* Key specifying which Panel the app is requesting.
|
||||
@@ -59,8 +63,6 @@ public class SettingsPanelActivity extends FragmentActivity {
|
||||
*/
|
||||
public static final String KEY_MEDIA_PACKAGE_NAME = "PANEL_MEDIA_PACKAGE_NAME";
|
||||
|
||||
private boolean mForceCreation = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -87,6 +89,12 @@ public class SettingsPanelActivity extends FragmentActivity {
|
||||
mForceCreation = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
mForceCreation = true;
|
||||
}
|
||||
|
||||
private void createOrUpdatePanel(boolean shouldForceCreation) {
|
||||
final Intent callingIntent = getIntent();
|
||||
if (callingIntent == null) {
|
||||
|
@@ -31,6 +31,7 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
@@ -139,4 +140,12 @@ public class SettingsPanelActivityTest {
|
||||
assertThat(paramCaptor.getValue().privateFlags
|
||||
& SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onConfigurationChanged_shouldForceUpdate() {
|
||||
mSettingsPanelActivity.mForceCreation = false;
|
||||
mSettingsPanelActivity.onConfigurationChanged(new Configuration());
|
||||
|
||||
assertThat(mSettingsPanelActivity.mForceCreation).isTrue();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user