import android.text.TextUtils; import com.cpt.zhct.weighting.utils.Constants; import com.cpt.zhct.weighting.utils.MmkvUtils; import com.cpt.zhct.weighting.antiescape.*; public class ExtractedActualFlow { String mCurrentCode="123456",mPerformanceFlowId="audit";int scanEmptyFrameCount=0,mTrayRemovalConfirmationCount=3,ended=0,recognized=0; long mFirstEmptyScanElapsedMs; final Anti mAntiEscapeController=new Anti();final UnlockCodePolicy mUnlockCodePolicy=new UnlockCodePolicy(); static class Anti {boolean hasActiveAlarm(){return false;}} static class LogUtils {static void e(String s){}} static class PerformanceTrace {static boolean isEnabled(){return false;} static long elapsedRealtime(){return 1L;} static void log(String a,String b,long c,String d){}} static class LocalFileRecorder {static void writeLog(String a,String b){}} static class R {static class string {static final int local_log_file_name=1;}} String getString(int x){return "audit";} void handleScanCodeDuringAlarm(String s){throw new AssertionError("Out-of-scope alarm branch");} void stopLegacyTrayNotBoundBlink(){} void updateTrayRequiredAlarmAfterTrayRemoval(){} void scanCodeResult(int code,String result){if(code==2){ended++;mCurrentCode="";}else if(code==0){recognized++;mCurrentCode=result;}} @@HANDLE_YOUKATE_SCAN_CODE@@ @@HANDLE_EMPTY_SCAN_CODE@@ @@CLEAN_SCAN_CODE@@ void feed(String raw){handleYoukateScanCode(cleanScanCode(raw));} static void eq(Object a,Object b,String why){if(!a.equals(b))throw new AssertionError(why+": "+a+" != "+b);} static void ok(String msg){System.out.println("PASS "+msg);} public static void main(String[] args){ android.content.Context c=new android.content.Context();c.pm.info.firstInstallTime=10;c.pm.info.lastUpdateTime=20; MmkvUtils.getInstance().data.clear();eq(TrayRemovalConfirmationCountConfig.get(c),3,"upgraded absent config");ok("Actual config: upgraded installation without stored key becomes 3"); MmkvUtils.getInstance().data.clear();c.pm.info.lastUpdateTime=10;eq(TrayRemovalConfirmationCountConfig.get(c),Constants.TRAY_REMOVAL_CONFIRMATION_COUNT_DEFAULT_VALUE,"fresh absent config");ok("Actual config: fresh installation uses current declared default"); TrayRemovalConfirmationCountConfig.save(3);eq(TrayRemovalConfirmationCountConfig.get(c),3,"persist 3");ok("Actual config: saved 3 preserved"); MmkvUtils.getInstance().put(Constants.TRAY_REMOVAL_CONFIRMATION_COUNT,Constants.TRAY_REMOVAL_CONFIRMATION_COUNT_MAX_VALUE+1);eq(TrayRemovalConfirmationCountConfig.get(c),Constants.TRAY_REMOVAL_CONFIRMATION_COUNT_DEFAULT_VALUE,"repair invalid");ok("Actual config: above-current-maximum value repaired to current default"); ExtractedActualFlow f=new ExtractedActualFlow();f.mTrayRemovalConfirmationCount=7;for(int i=0;i<6;i++)f.feed("");eq(f.ended,0,"six empty frames");f.feed("");eq(f.ended,1,"seven empty frames");ok("Actual extracted flow: 7 consecutive empty callbacks end exactly once"); f=new ExtractedActualFlow();f.feed("");f.feed("");f.feed("123456");eq(f.scanEmptyFrameCount,0,"valid resets count");f.feed("");f.feed("");eq(f.ended,0,"nonconsecutive empty frames");ok("Actual extracted flow: same ordinary valid code clears empty counter"); f=new ExtractedActualFlow();f.feed("12345");f.feed("12345");f.feed("12345");eq(f.ended,1,"short codes count as empty");ok("Actual extracted methods: three nonempty short codes become empty and trigger removal"); f=new ExtractedActualFlow();eq(f.cleanScanCode("123456\r\n"),"","length before normalize");ok("Actual extracted cleaner: CRLF appended to six digits is rejected before cleaning (PC681 parser normally trims ends first)"); f=new ExtractedActualFlow();f.feed("");f.feed("");f.feed("888880");f.feed("");eq(f.ended,1,"ignored admin code does not reset");ok("Actual extracted normal-flow branch: ignored admin code does not reset empty count"); f=new ExtractedActualFlow();long begin=System.nanoTime();for(int i=0;i<3;i++)f.feed("");eq(f.ended,1,"no time predicate");ok("Actual extracted flow: 3 callbacks without delays end (duration_us="+((System.nanoTime()-begin)/1000)+")"); f=new ExtractedActualFlow();f.feed("654321");eq(f.ended,0,"different code no removal");eq(f.recognized,1,"different code recognized");ok("Actual extracted routing: a different valid code directly starts recognition without removal callback"); for(int threshold:new int[]{3,7,12,15,30}){ f=new ExtractedActualFlow();f.mTrayRemovalConfirmationCount=threshold; long tick=System.nanoTime(); for(int i=0;i