Enable dumpsys car_service
The command in use to dumpsys information from CarService was "dumpsys activity service com.android.car/.CarService", which is based
on overloading dump() in the CarService class. OTOH, the class known to the ServiceManager as "car_service" is ICarImpl, which was not
providing the correct overload of dump().
Fix this by moving the dumping logic over in ICarImpl
Test: manual
Fixes: 77498074
Change-Id: I0c18a9088e9c06201de79e8ebf247dc969ff7317
diff --git a/service/src/com/android/car/ICarImpl.java b/service/src/com/android/car/ICarImpl.java
index 7adb2f1..1e11de9 100644
--- a/service/src/com/android/car/ICarImpl.java
+++ b/service/src/com/android/car/ICarImpl.java
@@ -26,6 +26,7 @@
import android.hardware.automotive.vehicle.V2_0.IVehicle;
import android.hardware.automotive.vehicle.V2_0.VehicleArea;
import android.os.Binder;
+import android.os.Build;
import android.os.IBinder;
import android.os.Process;
import android.os.Trace;
@@ -41,6 +42,8 @@
import com.android.internal.annotations.GuardedBy;
import com.android.internal.car.ICarServiceHelper;
+import java.io.FileDescriptor;
+import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
@@ -96,11 +99,14 @@
@GuardedBy("this")
private ICarServiceHelper mICarServiceHelper;
+ private final String mVehicleInterfaceName;
+
public ICarImpl(Context serviceContext, IVehicle vehicle, SystemInterface systemInterface,
- CanBusErrorNotifier errorNotifier) {
+ CanBusErrorNotifier errorNotifier, String vehicleInterfaceName) {
mContext = serviceContext;
mSystemInterface = systemInterface;
mHal = new VehicleHal(vehicle);
+ mVehicleInterfaceName = vehicleInterfaceName;
mSystemActivityMonitoringService = new SystemActivityMonitoringService(serviceContext);
mCarPowerManagementService = new CarPowerManagementService(mContext, mHal.getPowerHal(),
systemInterface);
@@ -358,22 +364,39 @@
throw new SecurityException("requires any of " + Arrays.toString(permissions));
}
- void dump(PrintWriter writer) {
- writer.println("*FutureConfig, DEFAULT:" + FeatureConfiguration.DEFAULT);
- writer.println("*Dump all services*");
- for (CarServiceBase service : mAllServices) {
- dumpService(service, writer);
+ @Override
+ protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
+ if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
+ != PackageManager.PERMISSION_GRANTED) {
+ writer.println("Permission Denial: can't dump CarService from from pid="
+ + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid()
+ + " without permission " + android.Manifest.permission.DUMP);
+ return;
}
- if (mCarTestService != null) {
- dumpService(mCarTestService, writer);
- }
- writer.println("*Dump Vehicle HAL*");
- try {
- // TODO dump all feature flags by creating a dumpable interface
- mHal.dump(writer);
- } catch (Exception e) {
- writer.println("Failed dumping: " + mHal.getClass().getName());
- e.printStackTrace(writer);
+ if (args == null || args.length == 0) {
+ writer.println("*dump car service*");
+
+ writer.println("*FutureConfig, DEFAULT:" + FeatureConfiguration.DEFAULT);
+ writer.println("*Dump all services*");
+ for (CarServiceBase service : mAllServices) {
+ dumpService(service, writer);
+ }
+ if (mCarTestService != null) {
+ dumpService(mCarTestService, writer);
+ }
+ writer.println("*Dump Vehicle HAL*");
+ writer.println("Vehicle HAL Interface: " + mVehicleInterfaceName);
+ try {
+ // TODO dump all feature flags by creating a dumpable interface
+ mHal.dump(writer);
+ } catch (Exception e) {
+ writer.println("Failed dumping: " + mHal.getClass().getName());
+ e.printStackTrace(writer);
+ }
+ } else if (Build.IS_USERDEBUG || Build.IS_ENG) {
+ execShellCmd(args, writer);
+ } else {
+ writer.println("Commands not supported in " + Build.TYPE);
}
}