1 /* 2 * Copyright (C) 2016 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 17 package com.android.server.cts; 18 19 import com.android.server.biometrics.fingerprint.FingerprintServiceDumpProto; 20 import com.android.server.biometrics.fingerprint.FingerprintUserStatsProto; 21 import com.android.server.biometrics.fingerprint.PerformanceStatsProto; 22 23 import com.android.tradefed.device.DeviceNotAvailableException; 24 import com.android.tradefed.device.ITestDevice; 25 import com.android.tradefed.log.LogUtil.CLog; 26 27 28 /** 29 * Test to check that the fingerprint service properly outputs its dump state. 30 */ 31 public class FingerprintIncidentTest extends ProtoDumpTestCase { 32 public void testFingerprintServiceDump() throws Exception { 33 // If the device doesn't support fingerprints, then pass. 34 if (!supportsFingerprint(getDevice())) { 35 return; 36 } 37 38 final FingerprintServiceDumpProto dump = 39 getDump(FingerprintServiceDumpProto.parser(), "dumpsys fingerprint --proto"); 40 41 verifyFingerprintServiceDumpProto(dump, PRIVACY_NONE); 42 } 43 44 static void verifyFingerprintServiceDumpProto(FingerprintServiceDumpProto dump, int filterLevel) { 45 for (int i = 0; i < dump.getUsersCount(); ++i) { 46 final FingerprintUserStatsProto userStats = dump.getUsers(i); 47 assertTrue(0 <= userStats.getUserId()); 48 assertTrue(0 <= userStats.getNumFingerprints()); 49 50 verifyPerformanceStatsProto(userStats.getNormal()); 51 verifyPerformanceStatsProto(userStats.getCrypto()); 52 } 53 } 54 55 private static void verifyPerformanceStatsProto(PerformanceStatsProto psp) { 56 assertTrue(0 <= psp.getAccept()); 57 assertTrue(0 <= psp.getReject()); 58 assertTrue(0 <= psp.getAcquire()); 59 assertTrue(0 <= psp.getLockout()); 60 assertTrue(0 <= psp.getPermanentLockout()); 61 } 62 63 static boolean supportsFingerprint(ITestDevice device) throws DeviceNotAvailableException { 64 if (!device.hasFeature("android.hardware.fingerprint")) { 65 CLog.d("Bypass as android.hardware.fingerprint is not supported."); 66 return false; 67 } 68 return true; 69 } 70 } 71 72