1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.server.cts; 17 18 import android.os.IncidentProto; 19 20 /** 21 * Tests incidentd reports filters fields correctly based on its privacy tags. 22 */ 23 public class IncidentdTest extends ProtoDumpTestCase { 24 private static final String TAG = "IncidentdTest"; 25 26 public void testIncidentReportDump(final int filterLevel, final String dest) throws Exception { 27 if (incidentdDisabled()) { 28 return; 29 } 30 final String destArg = dest == null || dest.isEmpty() ? "" : "-p " + dest; 31 final IncidentProto dump = getDump(IncidentProto.parser(), "incident " + destArg + " 2>/dev/null"); 32 33 SystemPropertiesTest.verifySystemPropertiesProto(dump.getSystemProperties(), filterLevel); 34 35 StackTraceIncidentTest.verifyBackTraceProto(dump.getNativeTraces(), filterLevel); 36 StackTraceIncidentTest.verifyBackTraceProto(dump.getHalTraces(), filterLevel); 37 StackTraceIncidentTest.verifyBackTraceProto(dump.getJavaTraces(), filterLevel); 38 39 if (FingerprintIncidentTest.supportsFingerprint(getDevice())) { 40 FingerprintIncidentTest.verifyFingerprintServiceDumpProto(dump.getFingerprint(), filterLevel); 41 } 42 43 NetstatsIncidentTest.verifyNetworkStatsServiceDumpProto(dump.getNetstats(), filterLevel); 44 45 SettingsIncidentTest.verifySettingsServiceDumpProto(dump.getSettings(), filterLevel); 46 47 NotificationIncidentTest.verifyNotificationServiceDumpProto(dump.getNotification(), filterLevel); 48 49 BatteryStatsIncidentTest.verifyBatteryStatsServiceDumpProto(dump.getBatterystats(), filterLevel); 50 51 if (BatteryIncidentTest.hasBattery(getDevice())) { 52 BatteryIncidentTest.verifyBatteryServiceDumpProto(dump.getBattery(), filterLevel); 53 } 54 55 DiskStatsProtoTest.verifyDiskStatsServiceDumpProto(dump.getDiskstats(), filterLevel, getDevice()); 56 57 PackageIncidentTest.verifyPackageServiceDumpProto(dump.getPackage(), filterLevel); 58 59 PowerIncidentTest.verifyPowerManagerServiceDumpProto(dump.getPower(), filterLevel); 60 61 if (PrintProtoTest.supportsPrinting(getDevice())) { 62 PrintProtoTest.verifyPrintServiceDumpProto(dump.getPrint(), filterLevel); 63 } 64 65 // Procstats currently has no EXPLICIT or LOCAL fields 66 67 // ActivityManagerServiceDumpActivitiesProto has no EXPLICIT or LOCAL fields. 68 69 // ActivityManagerServiceDumpBroadcastsProto has no EXPLICIT or LOCAL fields. 70 71 ActivityManagerIncidentTest.verifyActivityManagerServiceDumpServicesProto(dump.getAmservices(), filterLevel); 72 73 ActivityManagerIncidentTest.verifyActivityManagerServiceDumpProcessesProto(dump.getAmprocesses(), filterLevel); 74 75 AlarmManagerIncidentTest.verifyAlarmManagerServiceDumpProto(dump.getAlarm(), filterLevel); 76 77 MemInfoIncidentTest.verifyMemInfoDumpProto(dump.getMeminfo(), filterLevel); 78 79 // GraphicsStats is expected to be all AUTOMATIC. 80 81 WindowManagerIncidentTest.verifyWindowManagerServiceDumpProto(dump.getWindow(), filterLevel); 82 83 JobSchedulerIncidentTest.verifyJobSchedulerServiceDumpProto(dump.getJobscheduler(), filterLevel); 84 85 UsbIncidentTest.verifyUsbServiceDumpProto(dump.getUsb(), filterLevel); 86 } 87 88 // Splitting these into separate methods to make debugging easier. 89 90 public void testIncidentReportDumpAuto() throws Exception { 91 testIncidentReportDump(PRIVACY_AUTO, "AUTOMATIC"); 92 } 93 94 public void testIncidentReportDumpExplicit() throws Exception { 95 testIncidentReportDump(PRIVACY_EXPLICIT, "EXPLICIT"); 96 } 97 98 public void testIncidentReportDumpLocal() throws Exception { 99 testIncidentReportDump(PRIVACY_LOCAL, "LOCAL"); 100 } 101 } 102