Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3cebcca1 authored by Pablo Gamito's avatar Pablo Gamito
Browse files

Catch `DeadObjectException` when toggling logcat on ProtoLog clients.

This prevents a `RuntimeException` from being thrown if a ProtoLog client has died, instead logging a warning and indicating failure in the dump output.

Flag: EXEMPT minor bug fix
Bug: 438667577
Change-Id: I8571abe40742a0da30d772afd71175b846cf9822
parent 51f7ddfe
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.annotation.Nullable;
import android.annotation.SystemService;
import android.content.Context;
import android.os.Binder;
import android.os.DeadObjectException;
import android.os.IBinder;
import android.os.Process;
import android.os.RemoteException;
@@ -395,8 +396,12 @@ public class ProtoLogConfigurationServiceImpl extends IProtoLogConfigurationServ
                                + String.join(", ", clientGroups) + "]");
                        clientRecord.client.toggleLogcat(enabled, clientGroups);
                        pw.println("- Done");
                    } catch (DeadObjectException e) {
                        pw.println("- Failed (client may have died)");
                        Log.w(LOG_TAG, "Failed to toggle logcat status for groups on client "
                                + clientRecord.client + ", it likely has died", e);
                    } catch (RemoteException e) {
                        pw.println("- Failed");
                        pw.println("- Failed (unexpected RemoteException)");
                        throw new RuntimeException(
                                "Failed to toggle logcat status for groups on client", e);
                    }