package cn.ucvl.zhaodisplay; /** Observed RUN and explicit server capabilities; OP never predicts physical state. */ final class PhonePowerModel { final int measuredRun,op;final String state;final long checkedAt;final boolean canStart,canShutdown,managed; PhonePowerModel(int run,int op,String state,long checkedAt,boolean canStart,boolean canShutdown,boolean managed){this.measuredRun=run;this.op=op;this.state=state;this.checkedAt=checkedAt;this.canStart=canStart;this.canShutdown=canShutdown;this.managed=managed;} int run(long now){ if(checkedAt<=0||now45||op<0||op>2)return -1; if(measuredRun==1&&"online".equals(state))return 1; if(measuredRun==0&&"offline".equals(state))return 0; return -1; } boolean may(int operation,long now,boolean submitting){ if(!managed||submitting||op!=0)return false; int observed=run(now); return operation==1?observed==0&&canStart:operation==2&&observed==1&&canShutdown; } }