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
This commit is contained in:
Jerry Chang
2021-03-04 15:43:36 +08:00
parent ca5181f90a
commit 1db5dd180b
2 changed files with 14 additions and 8 deletions

View File

@@ -27759,13 +27759,23 @@ public class PackageManagerService extends IPackageManager.Stub
}
private static String getDefaultTimeouts() {
return DeviceConfig.getString(DeviceConfig.NAMESPACE_PACKAGE_MANAGER_SERVICE,
PROPERTY_INCFS_DEFAULT_TIMEOUTS, "");
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,
PROPERTY_KNOWN_DIGESTERS_LIST, "");
final long token = Binder.clearCallingIdentity();
try {
return DeviceConfig.getString(NAMESPACE_PACKAGE_MANAGER_SERVICE,
PROPERTY_KNOWN_DIGESTERS_LIST, "");
} finally {
Binder.restoreCallingIdentity(token);
}
}
/**

View File

@@ -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);
}
}
}