Loading packages/CarSystemUI/AndroidManifest.xml +2 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,6 @@ package="com.android.systemui" android:sharedUserId="android.uid.systemui" coreApp="true"> <!-- This permission is required to monitor car power state. --> <uses-permission android:name="android.car.permission.CAR_POWER" /> </manifest> packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java +35 −14 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.app.ActivityTaskManager; import android.car.Car; import android.car.drivingstate.CarDrivingStateEvent; import android.car.drivingstate.CarUxRestrictionsManager; import android.car.hardware.power.CarPowerManager.CarPowerStateListener; import android.content.Context; import android.graphics.PixelFormat; import android.graphics.Rect; Loading Loading @@ -121,8 +122,11 @@ public class CarStatusBar extends StatusBar implements private boolean mDeviceIsProvisioned = true; private HvacController mHvacController; private DrivingStateHelper mDrivingStateHelper; private static FlingAnimationUtils sFlingAnimationUtils; private PowerManagerHelper mPowerManagerHelper; private FlingAnimationUtils mFlingAnimationUtils; private SwitchToGuestTimer mSwitchToGuestTimer; private NotificationDataManager mNotificationDataManager; private NotificationClickHandlerFactory mNotificationClickHandlerFactory; // The container for the notifications. private CarNotificationView mNotificationView; Loading Loading @@ -156,6 +160,20 @@ public class CarStatusBar extends StatusBar implements // If notification shade is being swiped vertically to close. private boolean mIsSwipingVerticallyToClose; private final CarPowerStateListener mCarPowerStateListener = (int state) -> { // When the car powers on, clear all notifications and mute/unread states. Log.d(TAG, "New car power state: " + state); if (state == CarPowerStateListener.ON) { if (mNotificationClickHandlerFactory != null) { mNotificationClickHandlerFactory.clearAllNotifications(); } if (mNotificationDataManager != null) { mNotificationDataManager.clearAll(); } } }; @Override public void start() { // get the provisioned state before calling the parent class since it's that flow that Loading @@ -172,7 +190,7 @@ public class CarStatusBar extends StatusBar implements R.integer.notification_settle_open_percentage); mSettleClosePercentage = mContext.getResources().getInteger( R.integer.notification_settle_close_percentage); sFlingAnimationUtils = new FlingAnimationUtils(mContext, mFlingAnimationUtils = new FlingAnimationUtils(mContext, FLING_ANIMATION_MAX_TIME, FLING_SPEED_UP_FACTOR); createBatteryController(); Loading Loading @@ -204,6 +222,9 @@ public class CarStatusBar extends StatusBar implements mDrivingStateHelper = new DrivingStateHelper(mContext, this::onDrivingStateChanged); mDrivingStateHelper.connectToCarService(); mPowerManagerHelper = new PowerManagerHelper(mContext, mCarPowerStateListener); mPowerManagerHelper.connectToCarService(); mSwitchToGuestTimer = new SwitchToGuestTimer(mContext); } Loading Loading @@ -308,7 +329,6 @@ public class CarStatusBar extends StatusBar implements } } @Override protected void makeStatusBarView(@Nullable RegisterStatusBarResult result) { super.makeStatusBarView(result); Loading Loading @@ -407,7 +427,7 @@ public class CarStatusBar extends StatusBar implements } ); NotificationClickHandlerFactory clickHandlerFactory = new NotificationClickHandlerFactory( mNotificationClickHandlerFactory = new NotificationClickHandlerFactory( mBarService, launchResult -> { if (launchResult == ActivityManager.START_TASK_TO_FRONT Loading @@ -422,26 +442,27 @@ public class CarStatusBar extends StatusBar implements CarUxRestrictionManagerWrapper carUxRestrictionManagerWrapper = new CarUxRestrictionManagerWrapper(); carUxRestrictionManagerWrapper.setCarUxRestrictionsManager(carUxRestrictionsManager); NotificationDataManager notificationDataManager = new NotificationDataManager(); notificationDataManager.setOnUnseenCountUpdateListener( mNotificationDataManager = new NotificationDataManager(); mNotificationDataManager.setOnUnseenCountUpdateListener( () -> { // TODO: Update Notification Icon based on unseen count Log.d(TAG, "unseen count: " + notificationDataManager.getUnseenNotificationCount()); mNotificationDataManager.getUnseenNotificationCount()); }); CarHeadsUpNotificationManager carHeadsUpNotificationManager = new CarSystemUIHeadsUpNotificationManager(mContext, clickHandlerFactory, notificationDataManager); new CarSystemUIHeadsUpNotificationManager(mContext, mNotificationClickHandlerFactory, mNotificationDataManager); mNotificationClickHandlerFactory.setNotificationDataManager(mNotificationDataManager); carNotificationListener.registerAsSystemService(mContext, carUxRestrictionManagerWrapper, carHeadsUpNotificationManager, notificationDataManager); carHeadsUpNotificationManager, mNotificationDataManager); mNotificationView = mStatusBarWindow.findViewById(R.id.notification_view); View glassPane = mStatusBarWindow.findViewById(R.id.glass_pane); mNotificationView.setClickHandlerFactory(clickHandlerFactory); mNotificationView.setNotificationDataManager(notificationDataManager); mNotificationView.setClickHandlerFactory(mNotificationClickHandlerFactory); mNotificationView.setNotificationDataManager(mNotificationDataManager); // The glass pane is used to view touch events before passed to the notification list. // This allows us to initialize gesture listeners and detect when to close the notifications Loading Loading @@ -528,7 +549,7 @@ public class CarStatusBar extends StatusBar implements PreprocessingManager.getInstance(mContext), carNotificationListener, carUxRestrictionManagerWrapper, notificationDataManager); mNotificationDataManager); mNotificationViewController.enable(); } Loading Loading @@ -639,7 +660,7 @@ public class CarStatusBar extends StatusBar implements } } }); sFlingAnimationUtils.apply(animator, from, to, Math.abs(velocity)); mFlingAnimationUtils.apply(animator, from, to, Math.abs(velocity)); animator.start(); } Loading packages/CarSystemUI/src/com/android/systemui/statusbar/car/PowerManagerHelper.java 0 → 100644 +93 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 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. */ package com.android.systemui.statusbar.car; import android.annotation.NonNull; import android.car.Car; import android.car.CarNotConnectedException; import android.car.hardware.power.CarPowerManager; import android.car.hardware.power.CarPowerManager.CarPowerStateListener; import android.content.ComponentName; import android.content.Context; import android.content.ServiceConnection; import android.os.IBinder; import android.util.Log; /** * Helper class for connecting to the {@link CarPowerManager} and listening for power state changes. */ public class PowerManagerHelper { public static final String TAG = "PowerManagerHelper"; private final Context mContext; private final CarPowerStateListener mCarPowerStateListener; private Car mCar; private CarPowerManager mCarPowerManager; private final ServiceConnection mCarConnectionListener = new ServiceConnection() { public void onServiceConnected(ComponentName name, IBinder service) { Log.d(TAG, "Car Service connected"); try { mCarPowerManager = (CarPowerManager) mCar.getCarManager(Car.POWER_SERVICE); if (mCarPowerManager != null) { mCarPowerManager.setListener(mCarPowerStateListener); } else { Log.e(TAG, "CarPowerManager service not available"); } } catch (CarNotConnectedException e) { Log.e(TAG, "Car not connected", e); } } @Override public void onServiceDisconnected(ComponentName name) { destroyCarPowerManager(); } }; PowerManagerHelper(Context context, @NonNull CarPowerStateListener listener) { mContext = context; mCarPowerStateListener = listener; } /** * Connect to Car service. */ void connectToCarService() { mCar = Car.createCar(mContext, mCarConnectionListener); if (mCar != null) { mCar.connect(); } } /** * Disconnects from Car service. */ void disconnectFromCarService() { if (mCar != null) { mCar.disconnect(); } } private void destroyCarPowerManager() { if (mCarPowerManager != null) { mCarPowerManager.clearListener(); } } } Loading
packages/CarSystemUI/AndroidManifest.xml +2 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,6 @@ package="com.android.systemui" android:sharedUserId="android.uid.systemui" coreApp="true"> <!-- This permission is required to monitor car power state. --> <uses-permission android:name="android.car.permission.CAR_POWER" /> </manifest>
packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java +35 −14 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.app.ActivityTaskManager; import android.car.Car; import android.car.drivingstate.CarDrivingStateEvent; import android.car.drivingstate.CarUxRestrictionsManager; import android.car.hardware.power.CarPowerManager.CarPowerStateListener; import android.content.Context; import android.graphics.PixelFormat; import android.graphics.Rect; Loading Loading @@ -121,8 +122,11 @@ public class CarStatusBar extends StatusBar implements private boolean mDeviceIsProvisioned = true; private HvacController mHvacController; private DrivingStateHelper mDrivingStateHelper; private static FlingAnimationUtils sFlingAnimationUtils; private PowerManagerHelper mPowerManagerHelper; private FlingAnimationUtils mFlingAnimationUtils; private SwitchToGuestTimer mSwitchToGuestTimer; private NotificationDataManager mNotificationDataManager; private NotificationClickHandlerFactory mNotificationClickHandlerFactory; // The container for the notifications. private CarNotificationView mNotificationView; Loading Loading @@ -156,6 +160,20 @@ public class CarStatusBar extends StatusBar implements // If notification shade is being swiped vertically to close. private boolean mIsSwipingVerticallyToClose; private final CarPowerStateListener mCarPowerStateListener = (int state) -> { // When the car powers on, clear all notifications and mute/unread states. Log.d(TAG, "New car power state: " + state); if (state == CarPowerStateListener.ON) { if (mNotificationClickHandlerFactory != null) { mNotificationClickHandlerFactory.clearAllNotifications(); } if (mNotificationDataManager != null) { mNotificationDataManager.clearAll(); } } }; @Override public void start() { // get the provisioned state before calling the parent class since it's that flow that Loading @@ -172,7 +190,7 @@ public class CarStatusBar extends StatusBar implements R.integer.notification_settle_open_percentage); mSettleClosePercentage = mContext.getResources().getInteger( R.integer.notification_settle_close_percentage); sFlingAnimationUtils = new FlingAnimationUtils(mContext, mFlingAnimationUtils = new FlingAnimationUtils(mContext, FLING_ANIMATION_MAX_TIME, FLING_SPEED_UP_FACTOR); createBatteryController(); Loading Loading @@ -204,6 +222,9 @@ public class CarStatusBar extends StatusBar implements mDrivingStateHelper = new DrivingStateHelper(mContext, this::onDrivingStateChanged); mDrivingStateHelper.connectToCarService(); mPowerManagerHelper = new PowerManagerHelper(mContext, mCarPowerStateListener); mPowerManagerHelper.connectToCarService(); mSwitchToGuestTimer = new SwitchToGuestTimer(mContext); } Loading Loading @@ -308,7 +329,6 @@ public class CarStatusBar extends StatusBar implements } } @Override protected void makeStatusBarView(@Nullable RegisterStatusBarResult result) { super.makeStatusBarView(result); Loading Loading @@ -407,7 +427,7 @@ public class CarStatusBar extends StatusBar implements } ); NotificationClickHandlerFactory clickHandlerFactory = new NotificationClickHandlerFactory( mNotificationClickHandlerFactory = new NotificationClickHandlerFactory( mBarService, launchResult -> { if (launchResult == ActivityManager.START_TASK_TO_FRONT Loading @@ -422,26 +442,27 @@ public class CarStatusBar extends StatusBar implements CarUxRestrictionManagerWrapper carUxRestrictionManagerWrapper = new CarUxRestrictionManagerWrapper(); carUxRestrictionManagerWrapper.setCarUxRestrictionsManager(carUxRestrictionsManager); NotificationDataManager notificationDataManager = new NotificationDataManager(); notificationDataManager.setOnUnseenCountUpdateListener( mNotificationDataManager = new NotificationDataManager(); mNotificationDataManager.setOnUnseenCountUpdateListener( () -> { // TODO: Update Notification Icon based on unseen count Log.d(TAG, "unseen count: " + notificationDataManager.getUnseenNotificationCount()); mNotificationDataManager.getUnseenNotificationCount()); }); CarHeadsUpNotificationManager carHeadsUpNotificationManager = new CarSystemUIHeadsUpNotificationManager(mContext, clickHandlerFactory, notificationDataManager); new CarSystemUIHeadsUpNotificationManager(mContext, mNotificationClickHandlerFactory, mNotificationDataManager); mNotificationClickHandlerFactory.setNotificationDataManager(mNotificationDataManager); carNotificationListener.registerAsSystemService(mContext, carUxRestrictionManagerWrapper, carHeadsUpNotificationManager, notificationDataManager); carHeadsUpNotificationManager, mNotificationDataManager); mNotificationView = mStatusBarWindow.findViewById(R.id.notification_view); View glassPane = mStatusBarWindow.findViewById(R.id.glass_pane); mNotificationView.setClickHandlerFactory(clickHandlerFactory); mNotificationView.setNotificationDataManager(notificationDataManager); mNotificationView.setClickHandlerFactory(mNotificationClickHandlerFactory); mNotificationView.setNotificationDataManager(mNotificationDataManager); // The glass pane is used to view touch events before passed to the notification list. // This allows us to initialize gesture listeners and detect when to close the notifications Loading Loading @@ -528,7 +549,7 @@ public class CarStatusBar extends StatusBar implements PreprocessingManager.getInstance(mContext), carNotificationListener, carUxRestrictionManagerWrapper, notificationDataManager); mNotificationDataManager); mNotificationViewController.enable(); } Loading Loading @@ -639,7 +660,7 @@ public class CarStatusBar extends StatusBar implements } } }); sFlingAnimationUtils.apply(animator, from, to, Math.abs(velocity)); mFlingAnimationUtils.apply(animator, from, to, Math.abs(velocity)); animator.start(); } Loading
packages/CarSystemUI/src/com/android/systemui/statusbar/car/PowerManagerHelper.java 0 → 100644 +93 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 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. */ package com.android.systemui.statusbar.car; import android.annotation.NonNull; import android.car.Car; import android.car.CarNotConnectedException; import android.car.hardware.power.CarPowerManager; import android.car.hardware.power.CarPowerManager.CarPowerStateListener; import android.content.ComponentName; import android.content.Context; import android.content.ServiceConnection; import android.os.IBinder; import android.util.Log; /** * Helper class for connecting to the {@link CarPowerManager} and listening for power state changes. */ public class PowerManagerHelper { public static final String TAG = "PowerManagerHelper"; private final Context mContext; private final CarPowerStateListener mCarPowerStateListener; private Car mCar; private CarPowerManager mCarPowerManager; private final ServiceConnection mCarConnectionListener = new ServiceConnection() { public void onServiceConnected(ComponentName name, IBinder service) { Log.d(TAG, "Car Service connected"); try { mCarPowerManager = (CarPowerManager) mCar.getCarManager(Car.POWER_SERVICE); if (mCarPowerManager != null) { mCarPowerManager.setListener(mCarPowerStateListener); } else { Log.e(TAG, "CarPowerManager service not available"); } } catch (CarNotConnectedException e) { Log.e(TAG, "Car not connected", e); } } @Override public void onServiceDisconnected(ComponentName name) { destroyCarPowerManager(); } }; PowerManagerHelper(Context context, @NonNull CarPowerStateListener listener) { mContext = context; mCarPowerStateListener = listener; } /** * Connect to Car service. */ void connectToCarService() { mCar = Car.createCar(mContext, mCarConnectionListener); if (mCar != null) { mCar.connect(); } } /** * Disconnects from Car service. */ void disconnectFromCarService() { if (mCar != null) { mCar.disconnect(); } } private void destroyCarPowerManager() { if (mCarPowerManager != null) { mCarPowerManager.clearListener(); } } }