diff options
author | Xin Li <delphij@google.com> | 2023-03-13 23:11:24 -0700 |
---|---|---|
committer | Xin Li <delphij@google.com> | 2023-03-13 23:11:24 -0700 |
commit | 238660bf6bc9ddb3d74ec9e35a5677db7e65b3c5 (patch) | |
tree | 0ea6486ced7ceaed49a8abe587d9aa70db710217 | |
parent | c6a344ad854bd6f74f9da6a43cb6bf724f589a92 (diff) | |
parent | 3e437be8b22f8a208ea10579752147ee1bbd3b4c (diff) | |
download | Cluster-238660bf6bc9ddb3d74ec9e35a5677db7e65b3c5.tar.gz |
Merge Android 13 QPR2android-u-beta-1-gpl
Bug: 273316506
Merged-In: Ib6081cf45ecf2a6d4b68434666a2e4da9c1d90d4
Change-Id: I41e7cadc52bb15bc13a83297492649e2defdab5d
5 files changed, 30 insertions, 39 deletions
diff --git a/ClusterHomeSample/src/com/android/car/cluster/home/ClusterHomeApplication.java b/ClusterHomeSample/src/com/android/car/cluster/home/ClusterHomeApplication.java index c0001da..2171e8a 100644 --- a/ClusterHomeSample/src/com/android/car/cluster/home/ClusterHomeApplication.java +++ b/ClusterHomeSample/src/com/android/car/cluster/home/ClusterHomeApplication.java @@ -348,7 +348,9 @@ public final class ClusterHomeApplication extends Application { if (keyEvent.getAction() != KeyEvent.ACTION_DOWN) return; int nextUiType; do { - nextUiType = (mLastLaunchedUiType + 1) % mUiAvailability.length; + // Select the Cluster Activity within the preinstalled ones. + nextUiType = mLastLaunchedUiType + 1; + if (nextUiType >= mDefaultClusterActivitySize) nextUiType = 0; } while (mUiAvailability[nextUiType] == UI_UNAVAILABLE); startClusterActivity(nextUiType); return; diff --git a/ClusterOsDouble/AndroidManifest.xml b/ClusterOsDouble/AndroidManifest.xml index 5e8d334..e57b260 100644 --- a/ClusterOsDouble/AndroidManifest.xml +++ b/ClusterOsDouble/AndroidManifest.xml @@ -13,9 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. --> - <manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.android.car.cluster.osdouble"> + package="com.android.car.cluster.osdouble" + android:sharedUserId="android.uid.system"> + <!-- system uid is required to access the local private display --> <!-- Required to show car sensor data --> <uses-permission android:name="android.car.permission.CAR_SPEED"/> diff --git a/ClusterOsDouble/src/com/android/car/cluster/osdouble/ClusterOsDoubleActivity.java b/ClusterOsDouble/src/com/android/car/cluster/osdouble/ClusterOsDoubleActivity.java index 3671b5d..785f9d8 100644 --- a/ClusterOsDouble/src/com/android/car/cluster/osdouble/ClusterOsDoubleActivity.java +++ b/ClusterOsDouble/src/com/android/car/cluster/osdouble/ClusterOsDoubleActivity.java @@ -326,7 +326,8 @@ public class ClusterOsDoubleActivity extends ComponentActivity { if (keyCode == KeyEvent.KEYCODE_MENU) { int nextUi = mCurrentUi; do { - nextUi = (nextUi + 1) % mUiAvailability.size(); + nextUi = nextUi + 1; + if (nextUi >= mUiToButton.size()) nextUi = 0; } while (mUiAvailability.get(nextUi) == 0); switchUi(nextUi); return true; diff --git a/DirectRenderingCluster/AndroidManifest.xml b/DirectRenderingCluster/AndroidManifest.xml index 809fa3f..f972e97 100644 --- a/DirectRenderingCluster/AndroidManifest.xml +++ b/DirectRenderingCluster/AndroidManifest.xml @@ -42,8 +42,11 @@ <uses-permission android:name="android.permission.MANAGE_USERS" /> <!-- Required to launch navigation apps --> <uses-permission android:name="android.car.permission.CAR_INSTRUMENT_CLUSTER_CONTROL"/> + <!-- Required to use CarOccupantZoneManager.getDisplayIdForDriver() --> + <uses-permission android:name="android.car.permission.ACCESS_PRIVATE_DISPLAY_ID"/> <!-- Required to watch activities running on the cluster --> <uses-permission android:name="android.permission.SET_ACTIVITY_WATCHER"/> + <!-- Required to show car sensor data --> <uses-permission android:name="android.car.permission.CAR_ENERGY"/> <uses-permission android:name="android.car.permission.CAR_POWERTRAIN"/> diff --git a/DirectRenderingCluster/src/android/car/cluster/ClusterDisplayProvider.java b/DirectRenderingCluster/src/android/car/cluster/ClusterDisplayProvider.java index 4050099..5949a50 100644 --- a/DirectRenderingCluster/src/android/car/cluster/ClusterDisplayProvider.java +++ b/DirectRenderingCluster/src/android/car/cluster/ClusterDisplayProvider.java @@ -18,7 +18,6 @@ package android.car.cluster; import android.car.Car; import android.car.CarOccupantZoneManager; -import android.car.CarOccupantZoneManager.OccupantZoneInfo; import android.content.Context; import android.hardware.display.DisplayManager.DisplayListener; import android.util.Log; @@ -26,8 +25,6 @@ import android.view.Display; import com.android.internal.util.Preconditions; -import java.util.List; - /** * This class provides a display for instrument cluster renderer. * <p> @@ -37,7 +34,7 @@ import java.util.List; */ public class ClusterDisplayProvider { private static final String TAG = "Cluster.DisplayProvider"; - private static final boolean DEBUG = false; + private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private final DisplayListener mListener; private final Car mCar; @@ -66,35 +63,30 @@ public class ClusterDisplayProvider { Preconditions.checkArgument( occupantZoneManager != null,"Can't get CarOccupantZoneManager"); mOccupantZoneManager = occupantZoneManager; - checkClusterDisplayAdded(); + checkClusterDisplayChanged(); mOccupantZoneManager.registerOccupantZoneConfigChangeListener( new ClusterDisplayChangeListener()); } - private void checkClusterDisplayAdded() { - Display clusterDisplay = getClusterDisplay(); - if (clusterDisplay != null) { - Log.i(TAG, String.format("Found display: %s (id: %d, owner: %s)", - clusterDisplay.getName(), clusterDisplay.getDisplayId(), - clusterDisplay.getOwnerPackageName())); - mClusterDisplayId = clusterDisplay.getDisplayId(); - mListener.onDisplayAdded(clusterDisplay.getDisplayId()); + private void checkClusterDisplayChanged() { + int clusterDisplayId = getClusterDisplayId(); + if (clusterDisplayId == mClusterDisplayId) { + return; + } + if (mClusterDisplayId != Display.INVALID_DISPLAY) { + Log.i(TAG, "Cluster display is removed"); + mListener.onDisplayRemoved(mClusterDisplayId); + } + mClusterDisplayId = clusterDisplayId; + if (clusterDisplayId != Display.INVALID_DISPLAY) { + Log.i(TAG, "Found cluster displayId=" + clusterDisplayId); + mListener.onDisplayAdded(clusterDisplayId); } } - private Display getClusterDisplay() { - List<OccupantZoneInfo> zones = mOccupantZoneManager.getAllOccupantZones(); - int zones_size = zones.size(); - for (int i = 0; i < zones_size; ++i) { - OccupantZoneInfo zone = zones.get(i); - // Assumes that a Car has only one driver. - if (zone.occupantType == CarOccupantZoneManager.OCCUPANT_TYPE_DRIVER) { - return mOccupantZoneManager.getDisplayForOccupant( - zone, CarOccupantZoneManager.DISPLAY_TYPE_INSTRUMENT_CLUSTER); - } - } - Log.e(TAG, "Can't find the OccupantZoneInfo for driver"); - return null; + private int getClusterDisplayId() { + return mOccupantZoneManager.getDisplayIdForDriver( + CarOccupantZoneManager.DISPLAY_TYPE_INSTRUMENT_CLUSTER); } private final class ClusterDisplayChangeListener implements @@ -105,15 +97,7 @@ public class ClusterDisplayProvider { if ((changeFlags & CarOccupantZoneManager.ZONE_CONFIG_CHANGE_FLAG_DISPLAY) == 0) { return; } - if (mClusterDisplayId == Display.INVALID_DISPLAY) { - checkClusterDisplayAdded(); - } else { - Display clusterDisplay = getClusterDisplay(); - if (clusterDisplay == null) { - mListener.onDisplayRemoved(mClusterDisplayId); - mClusterDisplayId = Display.INVALID_DISPLAY; - } - } + checkClusterDisplayChanged(); } } |