Merge "use main looper when null Handler is passed to Car" into nyc-car-dev
diff --git a/car-lib/src/android/car/Car.java b/car-lib/src/android/car/Car.java
index d6998d4..3aed437 100644
--- a/car-lib/src/android/car/Car.java
+++ b/car-lib/src/android/car/Car.java
@@ -350,7 +350,7 @@
public Car(Context context, ICar service, @Nullable Handler handler) {
mContext = context;
mEventHandler = determineEventHandler(handler);
- mMainThreadEventHandler = determineMainThreadEventHandler(handler);
+ mMainThreadEventHandler = determineMainThreadEventHandler(mEventHandler);
mService = service;
mConnectionState = STATE_CONNECTED;
@@ -364,11 +364,7 @@
private static Handler determineEventHandler(@Nullable Handler handler) {
if (handler == null) {
- Looper looper = Looper.myLooper();
-
- if(looper == null){
- looper = Looper.getMainLooper();
- }
+ Looper looper = Looper.getMainLooper();
handler = new Handler(looper);
}
return handler;
diff --git a/car-support-lib/src/android/support/car/Car.java b/car-support-lib/src/android/support/car/Car.java
index 89d949b..37f1f49 100644
--- a/car-support-lib/src/android/support/car/Car.java
+++ b/car-support-lib/src/android/support/car/Car.java
@@ -240,11 +240,7 @@
mContext = context;
mServiceConnectionCallbackClient = serviceConnectionCallback;
if (handler == null) {
- Looper looper = Looper.myLooper();
-
- if(looper == null){
- looper = Looper.getMainLooper();
- }
+ Looper looper = Looper.getMainLooper();
handler = new Handler(looper);
}
mEventHandler = handler;