/*
* 显示刷新率开关控制函数
* 0 = 关闭
* 1 = 开启
* 2 = 查询当前状态(返回 true/false)
* 3 = 切换(打开→关 / 关→开)
*/
function showRefreshRate(mode) {
sf = android.os.ServiceManager.getService("SurfaceFlinger");
function call(flag, needReply) {
data = android.os.Parcel.obtain();
reply = needReply ? android.os.Parcel.obtain() : null;
data.writeInterfaceToken("android.ui.ISurfaceComposer");
data.writeInt(flag);
sf.transact(1034, data, reply, 0);
return reply;
}
if (mode == 3) {
current = call(2, true).readBoolean();
call(current ? 0 : 1, false);
return !current;
}
// mode: 0=关 1=开 2=查
if (mode == 2) {
return call(2, true).readBoolean();
} else {
call(mode, false);
return mode == 1;
}
}
// 切换显示屏刷新率显示开关
showRefreshRate(3);#MVEL表达式 #Javascript