1 /* 2 * Copyright (C) 2024 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.uwb.rftest; 18 19 import android.os.PersistableBundle; 20 21 import com.android.server.uwb.util.UwbUtil; 22 import com.google.uwb.support.rftest.RfTestParams; 23 import com.google.uwb.support.rftest.RfTestPerRxResult; 24 25 public class UwbTestPerRxResult implements RfNotificationEvent { 26 private int mStatus; 27 private long mAttempts; 28 private long mAcqDetect; 29 private long mAcqReject; 30 private long mRxFail; 31 private long mSyncCirReady; 32 private long mSfdFail; 33 private long mSfdFound; 34 private long mPhrDecError; 35 private long mPhrBitError; 36 private long mPsduDecError; 37 private long mPsduBitError; 38 private long mStsFound; 39 private long mEof; 40 private byte[] mRawNotificationData; 41 UwbTestPerRxResult(int status, byte[] rawNotificationData)42 public UwbTestPerRxResult(int status, byte[] rawNotificationData) { 43 this.mStatus = status; 44 this.mRawNotificationData = rawNotificationData; 45 } 46 UwbTestPerRxResult(int status, long attempts, long acqDetect, long acqReject, long rxFail, long syncCirReady, long sfdFail, long sfdFound, long phrDecError, long phrBitError, long psduDecError, long psduBitError, long stsFound, long eof, byte[] rawNotificationData)47 public UwbTestPerRxResult(int status, long attempts, long acqDetect, long acqReject, 48 long rxFail, long syncCirReady, long sfdFail, long sfdFound, 49 long phrDecError, long phrBitError, 50 long psduDecError, long psduBitError, long stsFound, long eof, 51 byte[] rawNotificationData) { 52 this.mStatus = status; 53 this.mAttempts = attempts; 54 this.mAcqDetect = acqDetect; 55 this.mAcqReject = acqReject; 56 this.mRxFail = rxFail; 57 this.mSyncCirReady = syncCirReady; 58 this.mSfdFail = sfdFail; 59 this.mSfdFound = sfdFound; 60 this.mPhrDecError = phrDecError; 61 this.mPhrBitError = phrBitError; 62 this.mPsduDecError = psduDecError; 63 this.mPsduBitError = psduBitError; 64 this.mStsFound = stsFound; 65 this.mEof = eof; 66 this.mRawNotificationData = rawNotificationData; 67 } 68 69 @Override getStatus()70 public int getStatus() { 71 return mStatus; 72 } 73 getAttempts()74 public long getAttempts() { 75 return mAttempts; 76 } 77 getAcqDetect()78 public long getAcqDetect() { 79 return mAcqDetect; 80 } 81 getAcqReject()82 public long getAcqReject() { 83 return mAcqReject; 84 } 85 getRxFail()86 public long getRxFail() { 87 return mRxFail; 88 } 89 getSyncCirReady()90 public long getSyncCirReady() { 91 return mSyncCirReady; 92 } 93 getSfdFail()94 public long getSfdFail() { 95 return mSfdFail; 96 } 97 getSfdFound()98 public long getSfdFound() { 99 return mSfdFound; 100 } 101 getPhrDecError()102 public long getPhrDecError() { 103 return mPhrDecError; 104 } 105 getPhrBitError()106 public long getPhrBitError() { 107 return mPhrBitError; 108 } 109 getPsduDecError()110 public long getPsduDecError() { 111 return mPsduDecError; 112 } 113 getPsduBitError()114 public long getPsduBitError() { 115 return mPsduBitError; 116 } 117 getStsFound()118 public long getStsFound() { 119 return mStsFound; 120 } 121 getEof()122 public long getEof() { 123 return mEof; 124 } 125 126 @Override getRawNotificationData()127 public byte[] getRawNotificationData() { 128 return mRawNotificationData; 129 } 130 131 @Override getOperationType()132 public int getOperationType() { 133 return RfTestParams.TEST_PER_RX; 134 } 135 136 @Override toBundle()137 public PersistableBundle toBundle() { 138 RfTestPerRxResult.Builder periodicRxResult = new RfTestPerRxResult.Builder() 139 .setOperationType(getOperationType()) 140 .setStatus(mStatus) 141 .setAttempts(mAttempts) 142 .setAcqDetect(mAcqDetect) 143 .setAcqReject(mAcqReject) 144 .setRxFail(mRxFail) 145 .setSyncCirReady(mSyncCirReady) 146 .setSfdFail(mSfdFail) 147 .setSfdFound(mSfdFound) 148 .setPhrDecError(mPhrDecError) 149 .setPhrBitError(mPhrBitError) 150 .setPsduDecError(mPsduDecError) 151 .setPsduBitError(mPsduBitError) 152 .setStsFound(mStsFound) 153 .setRawNtfData(mRawNotificationData) 154 .setEof(mEof); 155 return periodicRxResult.build().toBundle(); 156 } 157 158 @Override toString()159 public String toString() { 160 return "UwbTestPerRxResult { " 161 + " Status = " + mStatus 162 + ", Attempts = " + mAttempts 163 + ", AcqDetect = " + mAcqDetect 164 + ", AcqReject = " + mAcqReject 165 + ", RxFail = " + mRxFail 166 + ", SyncCirReady = " + mSyncCirReady 167 + ", SfdFail = " + mSfdFail 168 + ", SfdFound = " + mSfdFound 169 + ", PhrDecError = " + mPhrDecError 170 + ", PhrBitError = " + mPhrBitError 171 + ", PsduDecError = " + mPsduDecError 172 + ", PsduBitError = " + mPsduBitError 173 + ", StsFound = " + mStsFound 174 + ", Eof = " + mEof 175 + ", RfOperationType = " + getOperationType() 176 + ", RawNotificationData = " + UwbUtil.toHexString(mRawNotificationData) 177 + '}'; 178 } 179 } 180