Merge "Bugreport: Fix SystemUI service from being dumped twice 1/2"
This commit is contained in:
@@ -34,9 +34,18 @@ import java.util.function.Predicate;
|
||||
/**
|
||||
* Helper functions for dumping the state of system services.
|
||||
* Test:
|
||||
atest /android/pi-dev/frameworks/base/core/tests/coretests/src/com/android/internal/util/DumpUtilsTest.java
|
||||
atest FrameworksCoreTests:DumpUtilsTest
|
||||
*/
|
||||
public final class DumpUtils {
|
||||
|
||||
/**
|
||||
* List of component names that should be dumped in the bug report critical section.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final ComponentName[] CRITICAL_SECTION_COMPONENTS = {
|
||||
new ComponentName("com.android.systemui", "com.android.systemui.SystemUIService")
|
||||
};
|
||||
private static final String TAG = "DumpUtils";
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
@@ -212,6 +221,45 @@ public final class DumpUtils {
|
||||
return (wcn != null) && !isPlatformPackage(wcn.getComponentName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether a package should be dumped in the critical section.
|
||||
*/
|
||||
private static boolean isCriticalPackage(@Nullable ComponentName cname) {
|
||||
if (cname == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < CRITICAL_SECTION_COMPONENTS.length; i++) {
|
||||
if (cname.equals(CRITICAL_SECTION_COMPONENTS[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether a package name is considered to be part of the platform and in the critical
|
||||
* section.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static boolean isPlatformCriticalPackage(@Nullable ComponentName.WithComponentName wcn) {
|
||||
return (wcn != null) && isPlatformPackage(wcn.getComponentName()) &&
|
||||
isCriticalPackage(wcn.getComponentName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether a package name is considered to be part of the platform but not in the the
|
||||
* critical section.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static boolean isPlatformNonCriticalPackage(
|
||||
@Nullable ComponentName.WithComponentName wcn) {
|
||||
return (wcn != null) && isPlatformPackage(wcn.getComponentName()) &&
|
||||
!isCriticalPackage(wcn.getComponentName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for dumping providers and services. Return a predicate for a given filter string.
|
||||
* @hide
|
||||
@@ -238,6 +286,16 @@ public final class DumpUtils {
|
||||
return DumpUtils::isNonPlatformPackage;
|
||||
}
|
||||
|
||||
// Dump all platform-critical?
|
||||
if ("all-platform-critical".equals(filterString)) {
|
||||
return DumpUtils::isPlatformCriticalPackage;
|
||||
}
|
||||
|
||||
// Dump all platform-non-critical?
|
||||
if ("all-platform-non-critical".equals(filterString)) {
|
||||
return DumpUtils::isPlatformNonCriticalPackage;
|
||||
}
|
||||
|
||||
// Is the filter a component name? If so, do an exact match.
|
||||
final ComponentName filterCname = ComponentName.unflattenFromString(filterString);
|
||||
if (filterCname != null) {
|
||||
|
||||
@@ -15,8 +15,11 @@
|
||||
*/
|
||||
package com.android.internal.util;
|
||||
|
||||
import static com.android.internal.util.DumpUtils.CRITICAL_SECTION_COMPONENTS;
|
||||
import static com.android.internal.util.DumpUtils.filterRecord;
|
||||
import static com.android.internal.util.DumpUtils.isNonPlatformPackage;
|
||||
import static com.android.internal.util.DumpUtils.isPlatformCriticalPackage;
|
||||
import static com.android.internal.util.DumpUtils.isPlatformNonCriticalPackage;
|
||||
import static com.android.internal.util.DumpUtils.isPlatformPackage;
|
||||
|
||||
import android.content.ComponentName;
|
||||
@@ -25,7 +28,7 @@ import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Run with:
|
||||
atest /android/pi-dev/frameworks/base/core/tests/coretests/src/com/android/internal/util/DumpTest.java
|
||||
atest FrameworksCoreTests:DumpUtilsTest
|
||||
*/
|
||||
public class DumpUtilsTest extends TestCase {
|
||||
|
||||
@@ -89,6 +92,32 @@ public class DumpUtilsTest extends TestCase {
|
||||
assertTrue(isNonPlatformPackage(wcn("com.google.def/abc")));
|
||||
}
|
||||
|
||||
public void testIsPlatformCriticalPackage() {
|
||||
for (final ComponentName componentName : CRITICAL_SECTION_COMPONENTS) {
|
||||
assertTrue(isPlatformCriticalPackage(() -> componentName));
|
||||
assertTrue(isPlatformPackage(componentName));
|
||||
}
|
||||
assertFalse(isPlatformCriticalPackage(wcn("com.google.p/abc")));
|
||||
assertFalse(isPlatformCriticalPackage(wcn("com.android.def/abc")));
|
||||
assertFalse(isPlatformCriticalPackage(wcn("com.android.abc")));
|
||||
assertFalse(isPlatformCriticalPackage(wcn("com.android")));
|
||||
assertFalse(isPlatformCriticalPackage(wcn(null)));
|
||||
assertFalse(isPlatformCriticalPackage(null));
|
||||
}
|
||||
|
||||
public void testIsPlatformNonCriticalPackage() {
|
||||
for (final ComponentName componentName : CRITICAL_SECTION_COMPONENTS) {
|
||||
assertFalse(isPlatformNonCriticalPackage(() -> componentName));
|
||||
}
|
||||
assertTrue(isPlatformNonCriticalPackage(wcn("android/abc")));
|
||||
assertTrue(isPlatformNonCriticalPackage(wcn("android.abc/abc")));
|
||||
assertTrue(isPlatformNonCriticalPackage(wcn("com.android.def/abc")));
|
||||
|
||||
assertFalse(isPlatformNonCriticalPackage(wcn("com.google.def/abc")));
|
||||
assertFalse(isPlatformNonCriticalPackage(wcn(null)));
|
||||
assertFalse(isPlatformNonCriticalPackage(null));
|
||||
}
|
||||
|
||||
public void testFilterRecord() {
|
||||
assertFalse(filterRecord(null).test(wcn("com.google.p/abc")));
|
||||
assertFalse(filterRecord(null).test(wcn("com.android.p/abc")));
|
||||
@@ -105,6 +134,19 @@ public class DumpUtilsTest extends TestCase {
|
||||
assertFalse(filterRecord("all-non-platform").test(wcn("com.android.p/abc")));
|
||||
assertFalse(filterRecord("all-non-platform").test(wcn(null)));
|
||||
|
||||
for (final ComponentName componentName : CRITICAL_SECTION_COMPONENTS) {
|
||||
assertTrue(filterRecord("all-platform-critical").test((() -> componentName)));
|
||||
assertFalse(filterRecord("all-platform-non-critical").test((() -> componentName)));
|
||||
assertTrue(filterRecord("all-platform").test((() -> componentName)));
|
||||
}
|
||||
assertFalse(filterRecord("all-platform-critical").test(wcn("com.google.p/abc")));
|
||||
assertFalse(filterRecord("all-platform-critical").test(wcn("com.android.p/abc")));
|
||||
assertFalse(filterRecord("all-platform-critical").test(wcn(null)));
|
||||
|
||||
assertTrue(filterRecord("all-platform-non-critical").test(wcn("com.android.p/abc")));
|
||||
assertFalse(filterRecord("all-platform-non-critical").test(wcn("com.google.p/abc")));
|
||||
assertFalse(filterRecord("all-platform-non-critical").test(wcn(null)));
|
||||
|
||||
// Partial string match.
|
||||
assertTrue(filterRecord("abc").test(wcn("com.google.p/.abc")));
|
||||
assertFalse(filterRecord("abc").test(wcn("com.google.p/.def")));
|
||||
|
||||
@@ -717,8 +717,6 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
// Whether we should use SCHED_FIFO for UI and RenderThreads.
|
||||
private boolean mUseFifoUiScheduling = false;
|
||||
|
||||
private static final String SYSUI_COMPONENT_NAME = "com.android.systemui/.SystemUIService";
|
||||
|
||||
BroadcastQueue mFgBroadcastQueue;
|
||||
BroadcastQueue mBgBroadcastQueue;
|
||||
// Convenient for easy iteration over the queues. Foreground is first
|
||||
@@ -810,7 +808,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
boolean asProto) {
|
||||
if (asProto) return;
|
||||
doDump(fd, pw, new String[]{"activities"}, asProto);
|
||||
doDump(fd, pw, new String[]{"service", SYSUI_COMPONENT_NAME}, asProto);
|
||||
doDump(fd, pw, new String[]{"service", "all-platform-critical"}, asProto);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user