Change client handling of car service crash from exception to Process.kill
- Crash led into false counting it as client side issue. Use Process.kill with
Log instead.
Bug: 149231266
Test: Kill car service and check logs with client killing.
Change-Id: Icb8e45b4da61bc6860dd0335e22155fc4001e2ee
diff --git a/car-lib/src/android/car/Car.java b/car-lib/src/android/car/Car.java
index aa2a607..086e5c8 100644
--- a/car-lib/src/android/car/Car.java
+++ b/car-lib/src/android/car/Car.java
@@ -56,6 +56,7 @@
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
+import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.TransactionTooLargeException;
@@ -1250,12 +1251,19 @@
return;
} else if (mContext instanceof Service) {
Service service = (Service) mContext;
- throw new IllegalStateException("Car service has crashed, client not handle it:"
- + service.getPackageName() + "," + service.getClass().getSimpleName(),
- mConstructionStack);
+ killClient(service.getPackageName() + "," + service.getClass().getSimpleName());
+ } else {
+ killClient(/* clientInfo= */ null);
}
- throw new IllegalStateException("Car service crashed, client not handling it.",
+ }
+
+ private void killClient(@Nullable String clientInfo) {
+ Log.w(TAG_CAR, "**Car service has crashed. Client(" + clientInfo + ") is not handling it."
+ + " Client should use Car.createCar(..., CarServiceLifecycleListener, .."
+ + ".) to handle it properly. Check pritned callstack to check where other "
+ + "version of Car.createCar() was called. Killing the client process**",
mConstructionStack);
+ Process.killProcess(Process.myPid());
}
/** @hide */