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

Commit 1db5dd18 authored by Jerry Chang's avatar Jerry Chang
Browse files

Prevent fail to get device config while dumping package service

Clear binder identity when getting device config to prevent it blocks
dumping package service

Fix: 177371679
Test: atest PreRebootLogger
Change-Id: Ia3a8e2cb3eaf3aa2e1adecabe3a474b18c02bb21
parent ca5181f9
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -27759,13 +27759,23 @@ public class PackageManagerService extends IPackageManager.Stub
    }
    private static String getDefaultTimeouts() {
        return DeviceConfig.getString(DeviceConfig.NAMESPACE_PACKAGE_MANAGER_SERVICE,
        final long token = Binder.clearCallingIdentity();
        try {
            return DeviceConfig.getString(NAMESPACE_PACKAGE_MANAGER_SERVICE,
                    PROPERTY_INCFS_DEFAULT_TIMEOUTS, "");
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }
    private static String getKnownDigestersList() {
        return DeviceConfig.getString(DeviceConfig.NAMESPACE_PACKAGE_MANAGER_SERVICE,
        final long token = Binder.clearCallingIdentity();
        try {
            return DeviceConfig.getString(NAMESPACE_PACKAGE_MANAGER_SERVICE,
                    PROPERTY_KNOWN_DIGESTERS_LIST, "");
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }
    /**
+0 −4
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ 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;
@@ -147,7 +146,6 @@ final class PreRebootLogger {
            return;
        }

        final long token = Binder.clearCallingIdentity();
        try {
            final File dumpFile = new File(dumpDir, serviceName);
            final ParcelFileDescriptor fd = ParcelFileDescriptor.open(dumpFile,
@@ -156,8 +154,6 @@ 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);
        }
    }
}