#shell #adb #monkey
关键代码(从设备 /system/framework/monkey.jar 反编译)

1. 每次 monkey 运行结束必发旋转事件(Monkey.java 的 run 流程,正常结束和异常退出两个分支都有):
int crashedAtCycle = runMonkeyCycles();
new MonkeyRotationEvent(0, false).injectEvent(this.mWm, this.mAm, this.mVerbose);  // 正常结束
...
} catch (Throwable th) {
    new MonkeyRotationEvent(0, false).injectEvent(this.mWm, this.mAm, this.mVerbose);  // 异常退出
    throw th;
}

2. 这个事件就是"冻结→解冻"(MonkeyRotationEvent.java):
iwm.freezeRotation(0, "MonkeyRotationEven#injectEvent");   // 强制冻结到0度
if (!this.mPersist) { iwm.thawRotation("MonkeyRotationEven#injectEvent");    // 解冻 = 释放方向锁
}

3. --pct-rotation 隐藏选项确实存在
(processOptions 里 mFactors[4])——但即使比例为 0,上面这段也会无条件执行

*总结*
freezeRotation(0)+thawRotation 由 system_server 的 DisplayRotation 落地 → 对 accelerometer_rotation 连写 2 次→ 解冻=恢复自,方向锁定被清成 ar。与启动哪个 App(UNSPECIFIED、PORTRAIT等)、什么启动方式都是 monkey 自己的收尾动作
 
 
Back to Top