import android.car.drivingstate.CarUxRestrictionsManager;
import android.car.hardware.power.CarPowerManager.CarPowerStateListener;
import android.car.media.CarAudioManager;
+import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
}
};
+ private boolean mBootCompleted = false;
+ private final BroadcastReceiver mBootCompletedReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mBootCompleted = true;
+ String action = intent.getAction();
+ if (action != null && action.equals(Intent.ACTION_BOOT_COMPLETED)) {
+ initHvac();
+ }
+ }
+ };
+
@Override
public void start() {
// Non blocking call to connect to car service. Call this early so that we'll be connected
// asap.
((CarSystemUIFactory) SystemUIFactory.getInstance()).getCarServiceProvider(mContext);
+ // Defer some actions for CarStatusBar initialization until after boot complete event
+ registerBootCompletedReceiver();
+
// get the provisioned state before calling the parent class since it's that flow that
// builds the nav bar
mDeviceProvisionedController = Dependency.get(DeviceProvisionedController.class);
// ignore.
}
+ private void registerBootCompletedReceiver() {
+ IntentFilter bootCompletedFilter = new IntentFilter(Intent.ACTION_BOOT_COMPLETED);
+ bootCompletedFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
+ mContext.registerReceiver(mBootCompletedReceiver, bootCompletedFilter);
+ }
+
+ private void unregisterBootCompletedListener() {
+ mContext.unregisterReceiver(mBootCompletedReceiver);
+ }
+
/**
* Remove all content from navbars and rebuild them. Used to allow for different nav bars
* before and after the device is provisioned. . Also for change of density and font size.
private void restartNavBars() {
// remove and reattach all hvac components such that we don't keep a reference to unused
// ui elements
- mHvacController.removeAllComponents();
+ if (mHvacController != null) {
+ mHvacController.removeAllComponents();
+ }
mCarFacetButtonController.removeAll();
if (mNavigationBarWindow != null) {
}
buildNavBarContent();
+ if (mBootCompleted) {
+ initHvac();
+ }
// If the UI was rebuilt (day/night change) while the keyguard was up we need to
// correctly respect that state.
if (mIsKeyguard) {
}
private void addTemperatureViewToController(View v) {
+ if (v == null) return;
+
if (v instanceof TemperatureView) {
mHvacController.addHvacTextView((TemperatureView) v);
} else if (v instanceof ViewGroup) {
}
}
}
-
/**
* Allows for showing or hiding just the navigation bars. This is indented to be used when
* the full screen user selector is shown.
throw new RuntimeException("Unable to build top nav bar due to missing layout");
}
mTopNavigationBarView.setStatusBar(this);
- addTemperatureViewToController(mTopNavigationBarView);
mTopNavigationBarView.setStatusBarWindowTouchListener(mTopNavBarNotificationTouchListener);
}
throw new RuntimeException("Unable to build bottom nav bar due to missing layout");
}
mNavigationBarView.setStatusBar(this);
- addTemperatureViewToController(mNavigationBarView);
mNavigationBarView.setStatusBarWindowTouchListener(mNavBarNotificationTouchListener);
}
throw new RuntimeException("Unable to build left nav bar due to missing layout");
}
mLeftNavigationBarView.setStatusBar(this);
- addTemperatureViewToController(mLeftNavigationBarView);
mLeftNavigationBarView.setStatusBarWindowTouchListener(mNavBarNotificationTouchListener);
}
throw new RuntimeException("Unable to build right nav bar due to missing layout");
}
mRightNavigationBarView.setStatusBar(this);
- addTemperatureViewToController(mRightNavigationBarView);
mRightNavigationBarView.setStatusBarWindowTouchListener(mNavBarNotificationTouchListener);
}
+ private void initHvac() {
+ if (mHvacController == null) {
+ mHvacController = Dependency.get(HvacController.class);
+ mHvacController.connectToCarService();
+ }
+ addTemperatureViewToController(mTopNavigationBarView);
+ addTemperatureViewToController(mNavigationBarView);
+ addTemperatureViewToController(mLeftNavigationBarView);
+ addTemperatureViewToController(mRightNavigationBarView);
+ }
+
@Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
//When executing dump() function simultaneously, we need to serialize them