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

Commit 7d7c22a8 authored by Jerry Chang's avatar Jerry Chang
Browse files

Clear binder identity while dumping pre-reboot logs

Some services might check calling identity in its dump function. So
clear the binder identity when dumping services for pre-reboot
information.

Fix: 177371679
Test: atest PreRebootLoggerTest
Change-Id: I09c1954569f2d104bc6b4e4c14fb72dcf23e8015
parent 0b28f5f3
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.power;
import android.annotation.DurationMillisLong;
import android.annotation.NonNull;
import android.content.Context;
import android.os.Binder;
import android.os.Environment;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
@@ -146,6 +147,7 @@ final class PreRebootLogger {
            return;
        }

        final long token = Binder.clearCallingIdentity();
        try {
            final File dumpFile = new File(dumpDir, serviceName);
            final ParcelFileDescriptor fd = ParcelFileDescriptor.open(dumpFile,
@@ -154,6 +156,8 @@ final class PreRebootLogger {
            binder.dump(fd.getFileDescriptor(), ArrayUtils.emptyArray(String.class));
        } catch (FileNotFoundException | RemoteException e) {
            Slog.e(TAG, String.format("Failed to dump %s service before reboot", serviceName), e);
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }
}