Merge "Reconfigure all secondary displays during boot-up" into qt-dev
am: 6bc6e6aed0
Change-Id: If42d7a6757f4c9a112922e34850123d9ae096a08
diff --git a/service/src/com/android/car/ICarImpl.java b/service/src/com/android/car/ICarImpl.java
index 0335186..8c5b981 100644
--- a/service/src/com/android/car/ICarImpl.java
+++ b/service/src/com/android/car/ICarImpl.java
@@ -217,6 +217,7 @@
service.init();
}
traceEnd();
+ mSystemInterface.reconfigureSecondaryDisplays();
}
void release() {
diff --git a/service/src/com/android/car/systeminterface/DisplayInterface.java b/service/src/com/android/car/systeminterface/DisplayInterface.java
index 885657b..4d8f180 100644
--- a/service/src/com/android/car/systeminterface/DisplayInterface.java
+++ b/service/src/com/android/car/systeminterface/DisplayInterface.java
@@ -31,12 +31,16 @@
import android.os.Handler;
import android.os.Looper;
import android.os.PowerManager;
+import android.os.RemoteException;
+import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.UserHandle;
import android.provider.Settings.SettingNotFoundException;
import android.provider.Settings.System;
import android.util.Log;
import android.view.Display;
+import android.view.DisplayAddress;
+import android.view.IWindowManager;
import com.android.car.CarLog;
import com.android.car.CarPowerManagementService;
@@ -59,9 +63,15 @@
void refreshDisplayBrightness();
/**
+ * Reconfigure all secondary displays due to b/131909551
+ */
+ void reconfigureSecondaryDisplays();
+ /**
* Default implementation of display operations
*/
class DefaultImpl implements DisplayInterface, OnUsersUpdateListener {
+ static final String TAG = DisplayInterface.class.getSimpleName();
+
private final ActivityManager mActivityManager;
private final ContentResolver mContentResolver;
private final Context mContext;
@@ -211,5 +221,32 @@
mLastBrightnessLevel = -1;
refreshDisplayBrightness();
}
+
+ @Override
+ public void reconfigureSecondaryDisplays() {
+ IWindowManager wm = IWindowManager.Stub
+ .asInterface(ServiceManager.getService(Context.WINDOW_SERVICE));
+ if (wm == null) {
+ Log.e(TAG, "reconfigureSecondaryDisplays IWindowManager not available");
+ return;
+ }
+ Display[] displays = mDisplayManager.getDisplays();
+ for (Display display : displays) {
+ if (display.getDisplayId() == Display.DEFAULT_DISPLAY) { // skip main
+ continue;
+ }
+ // Only use physical secondary displays
+ if (display.getAddress() instanceof DisplayAddress.Physical) {
+ int displayId = display.getDisplayId();
+ try {
+ // Do not change the mode but this triggers reconfiguring.
+ int windowingMode = wm.getWindowingMode(displayId);
+ wm.setWindowingMode(displayId, windowingMode);
+ } catch (RemoteException e) {
+ Log.e(CarLog.TAG_SERVICE, "cannot access IWindowManager", e);
+ }
+ }
+ }
+ }
}
}
diff --git a/service/src/com/android/car/systeminterface/SystemInterface.java b/service/src/com/android/car/systeminterface/SystemInterface.java
index a617a5a..8e7f863 100644
--- a/service/src/com/android/car/systeminterface/SystemInterface.java
+++ b/service/src/com/android/car/systeminterface/SystemInterface.java
@@ -123,6 +123,11 @@
}
@Override
+ public void reconfigureSecondaryDisplays() {
+ mDisplayInterface.reconfigureSecondaryDisplays();
+ }
+
+ @Override
public void startDisplayStateMonitoring(CarPowerManagementService service) {
mDisplayInterface.startDisplayStateMonitoring(service);
}
diff --git a/tests/carservice_test/src/com/android/car/CarPowerManagementTest.java b/tests/carservice_test/src/com/android/car/CarPowerManagementTest.java
index ab5c271..58bf088 100644
--- a/tests/carservice_test/src/com/android/car/CarPowerManagementTest.java
+++ b/tests/carservice_test/src/com/android/car/CarPowerManagementTest.java
@@ -307,6 +307,9 @@
@Override
public void refreshDisplayBrightness() {}
+
+ @Override
+ public void reconfigureSecondaryDisplays() {}
}
private class PowerStatePropertyHandler implements VehicleHalPropertyHandler {
diff --git a/tests/carservice_test/src/com/android/car/MockedCarTestBase.java b/tests/carservice_test/src/com/android/car/MockedCarTestBase.java
index 44e07b2..894c402 100644
--- a/tests/carservice_test/src/com/android/car/MockedCarTestBase.java
+++ b/tests/carservice_test/src/com/android/car/MockedCarTestBase.java
@@ -311,6 +311,9 @@
@Override
public void refreshDisplayBrightness() {}
+
+ @Override
+ public void reconfigureSecondaryDisplays() {}
}
static final class MockIOInterface implements IOInterface {
diff --git a/tests/carservice_unit_test/src/com/android/car/CarPowerManagementServiceTest.java b/tests/carservice_unit_test/src/com/android/car/CarPowerManagementServiceTest.java
index 382d7ad..fa82f90 100644
--- a/tests/carservice_unit_test/src/com/android/car/CarPowerManagementServiceTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/CarPowerManagementServiceTest.java
@@ -296,6 +296,9 @@
@Override
public void refreshDisplayBrightness() {}
+
+ @Override
+ public void reconfigureSecondaryDisplays() {}
}
private static final class MockSystemStateInterface implements SystemStateInterface {