feat: add typed data and views with scoped device power

This commit is contained in:
Codex
2026-10-25 14:35:24 +08:00
parent 5b99a7e9fc
commit ca60398dea
65 changed files with 4238 additions and 231 deletions
@@ -0,0 +1,18 @@
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||now<checkedAt-5||now-checkedAt>45||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;
}
}