Snap for 5648992 from 0561e724bbdd70658ab761053ea1f8cab312d9a4 to rvc-release
Change-Id: I7d2158f46abe5c8d7bd9e35ef661c8de8972a6c2
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/EmbeddedKitchenSinkApp/res/layout/connectivity_fragment.xml b/tests/EmbeddedKitchenSinkApp/res/layout/connectivity_fragment.xml
index 245ba03..3d8f94a 100644
--- a/tests/EmbeddedKitchenSinkApp/res/layout/connectivity_fragment.xml
+++ b/tests/EmbeddedKitchenSinkApp/res/layout/connectivity_fragment.xml
@@ -126,6 +126,40 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
+
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="4dp">
+ <Button android:id="@+id/networkEnableWifiIntent"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Enable Wifi Intent"/>
+ <Button android:id="@+id/networkDisableWifiIntent"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Disable Wifi Intent"/>
+ </LinearLayout>
+
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="4dp">
+ <Button android:id="@+id/networkEnableBluetoothIntent"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Enable Bluetooth Intent"/>
+ <Button android:id="@+id/networkDisableBluetoothIntent"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Disable Bluetooth Intent"/>
+ <Button android:id="@+id/networkDiscoverableBluetoothIntent"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Discoverable Bluetooth Intent"/>
+ </LinearLayout>
</LinearLayout>
<LinearLayout
diff --git a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/connectivity/ConnectivityFragment.java b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/connectivity/ConnectivityFragment.java
index 0306698..7ec9f78 100644
--- a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/connectivity/ConnectivityFragment.java
+++ b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/connectivity/ConnectivityFragment.java
@@ -18,7 +18,9 @@
import android.annotation.Nullable;
import android.annotation.SuppressLint;
+import android.bluetooth.BluetoothAdapter;
import android.content.Context;
+import android.content.Intent;
import android.graphics.Color;
import android.location.LocationManager;
import android.net.ConnectivityManager;
@@ -496,9 +498,49 @@
mTetheringStatusPolled = (TextView) view.findViewById(R.id.tetheringStatusPolled);
mLocalOnlyStatus = (TextView) view.findViewById(R.id.localOnlyStatus);
+ view.findViewById(R.id.networkEnableWifiIntent).setOnClickListener(v -> enableWifiIntent());
+ view.findViewById(R.id.networkDisableWifiIntent)
+ .setOnClickListener(v -> disableWifiIntent());
+ view.findViewById(R.id.networkEnableBluetoothIntent)
+ .setOnClickListener(v -> enableBluetoothIntent());
+ view.findViewById(R.id.networkDisableBluetoothIntent)
+ .setOnClickListener(v -> disableBluetoothIntent());
+ view.findViewById(R.id.networkDiscoverableBluetoothIntent)
+ .setOnClickListener(v -> discoverableBluetoothIntent());
+
return view;
}
+ private void enableWifiIntent() {
+ Intent enableWifi = new Intent(WifiManager.ACTION_REQUEST_ENABLE);
+ enableWifi.putExtra(Intent.EXTRA_PACKAGE_NAME, getContext().getPackageName());
+ startActivity(enableWifi);
+ }
+
+ private void disableWifiIntent() {
+ Intent disableWifi = new Intent(WifiManager.ACTION_REQUEST_DISABLE);
+ disableWifi.putExtra(Intent.EXTRA_PACKAGE_NAME, getContext().getPackageName());
+ startActivity(disableWifi);
+ }
+
+ private void enableBluetoothIntent() {
+ Intent enableBluetooth = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
+ enableBluetooth.putExtra(Intent.EXTRA_PACKAGE_NAME, getContext().getPackageName());
+ startActivity(enableBluetooth);
+ }
+
+ private void disableBluetoothIntent() {
+ Intent disableBluetooth = new Intent(BluetoothAdapter.ACTION_REQUEST_DISABLE);
+ disableBluetooth.putExtra(Intent.EXTRA_PACKAGE_NAME, getContext().getPackageName());
+ startActivity(disableBluetooth);
+ }
+
+ private void discoverableBluetoothIntent() {
+ Intent discoverableBluetooth = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
+ discoverableBluetooth.putExtra(Intent.EXTRA_PACKAGE_NAME, getContext().getPackageName());
+ startActivity(discoverableBluetooth);
+ }
+
@Override
public void onResume() {
super.onResume();
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 {