Merge "Support another new intent for mainline module intent" into rvc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b494d35..18cf866 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -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" />
diff --git a/res/drawable/accessibility_captions.png b/res/drawable/accessibility_captions.png
index 5467386..718f4ef 100644
--- a/res/drawable/accessibility_captions.png
+++ b/res/drawable/accessibility_captions.png
Binary files differ
diff --git a/res/layout/accessibility_captions_preview.xml b/res/layout/accessibility_captions_preview.xml
index f3c0316..1818e64 100644
--- a/res/layout/accessibility_captions_preview.xml
+++ b/res/layout/accessibility_captions_preview.xml
@@ -1,19 +1,19 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-  ~ Copyright (C) 2020 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.
-  -->
+  Copyright (C) 2020 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.
+-->
 
 <FrameLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
diff --git a/src/com/android/settings/panel/SettingsPanelActivity.java b/src/com/android/settings/panel/SettingsPanelActivity.java
index ce437bb..da46564 100644
--- a/src/com/android/settings/panel/SettingsPanelActivity.java
+++ b/src/com/android/settings/panel/SettingsPanelActivity.java
@@ -19,12 +19,14 @@
 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 @@
 
     @VisibleForTesting
     final Bundle mBundle = new Bundle();
+    @VisibleForTesting
+    boolean mForceCreation = false;
 
     /**
      * Key specifying which Panel the app is requesting.
@@ -59,8 +63,6 @@
      */
     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 @@
         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) {
diff --git a/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java b/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
index 44e5eefc..833d510 100644
--- a/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
+++ b/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
@@ -31,6 +31,7 @@
 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 @@
         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();
+    }
 }