Last active
May 3, 2024 13:14
-
-
Save GoodbyeNJN/5f654262d1b3cb13dd03849c45e98317 to your computer and use it in GitHub Desktop.
墓碑模式 FCM 推送
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"name": "墓碑模式FCM推送v3.0-b", | |
"description": "对于支持FCM推送的 **非黑名单** 应用,当其收到推送并且处于后台时,临时解冻3秒。\n仅适配了NoActive Pro版本。全局变量示例:[ \"0#com.tencent.mm\", \"10#com.tencent.mm\" ],井号前后分别为用户id和包名。", | |
"priority": -1, | |
"condition": "fcmPushMessageArrived == true", | |
"actions": [ | |
"def debug(msg) { log.log(\"🚀 \" + msg); } def getUserIdList() { userList = context.getSystemService(context.USER_SERVICE).getUsers(); userIdList = (identifier in (userHandle in userList)); return userIdList; } def isValidPkg(pkg) { return thanos.getPkgManager().getAppInfo(pkg) != null; } def getPkgListByPkgName(pkgName) { userIdList = getUserIdList(); res = []; foreach(userId: userIdList) { pkg = Pkg.newPkg(pkgName, userId); if (isValidPkg(pkg)) { res.add(pkg.userId + \"#\" + pkg.pkgName); } } return res; } def isPkgFrozen(pkg) { return su.exe(\"pm freezer query \" + pkg + \" | awk '/isFrozen/ {print $2}'\").out[0]; } def unfreezePkg(pkg) { su.exe(\"pm freezer temporaryThaw \" + pkg); } def checkGlobalVar(pkg) { if (globalVarOf$FCM_UNFREEZE_BLACKLIST.contains(pkg)) { debug(\"应用命中黑名单,无需处理\"); return false; } else { debug(\"应用未命中黑名单,需要处理\"); return true; } } def main() { debug(\"开始处理 FCM 推送: \" + pkgName); pkgList = getPkgListByPkgName(pkgName); foreach(pkg : pkgList) { debug(\"多用户下的应用名: \" + pkg); if (!checkGlobalVar(pkg)) { return; } if (isPkgFrozen(pkg) == \"true\") { debug(\"应用已冻结\"); debug(\"开始临时解冻\"); unfreezePkg(pkg); debug(\"临时解冻完成\"); } else { debug(\"应用未冻结\"); } } debug(\"处理 FCM 推送完成: \" + pkgName); } main();" | |
] | |
} | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"name": "墓碑模式FCM推送v3.0-w", | |
"description": "对于支持FCM推送的 **白名单** 应用,当其收到推送并且处于后台时,临时解冻3秒。\n仅适配了NoActive Pro版本。全局变量示例:[ \"0#com.tencent.mm\", \"10#com.tencent.mm\" ],井号前后分别为用户id和包名。", | |
"priority": -1, | |
"condition": "fcmPushMessageArrived == true", | |
"actions": [ | |
"def debug(msg) { log.log(\"🚀 \" + msg); } def getUserIdList() { userList = context.getSystemService(context.USER_SERVICE).getUsers(); userIdList = (identifier in (userHandle in userList)); return userIdList; } def isValidPkg(pkg) { return thanos.getPkgManager().getAppInfo(pkg) != null; } def getPkgListByPkgName(pkgName) { userIdList = getUserIdList(); res = []; foreach(userId: userIdList) { pkg = Pkg.newPkg(pkgName, userId); if (isValidPkg(pkg)) { res.add(pkg.userId + \"#\" + pkg.pkgName); } } return res; } def isPkgFrozen(pkg) { return su.exe(\"pm freezer query \" + pkg + \" | awk '/isFrozen/ {print $2}'\").out[0]; } def unfreezePkg(pkg) { su.exe(\"pm freezer temporaryThaw \" + pkg); } def checkGlobalVar(pkg) { if (globalVarOf$FCM_UNFREEZE_WHITELIST.contains(pkg)) { debug(\"应用命中白名单,需要处理\"); return true; } else { debug(\"应用未命中白名单,无需处理\"); return false; } } def main() { debug(\"开始处理 FCM 推送: \" + pkgName); pkgList = getPkgListByPkgName(pkgName); foreach(pkg : pkgList) { debug(\"多用户下的应用名: \" + pkg); if (!checkGlobalVar(pkg)) { return; } if (isPkgFrozen(pkg) == \"true\") { debug(\"应用已冻结\"); debug(\"开始临时解冻\"); unfreezePkg(pkg); debug(\"临时解冻完成\"); } else { debug(\"应用未冻结\"); } } debug(\"处理 FCM 推送完成: \" + pkgName); } main();" | |
] | |
} | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def debug(msg) { | |
log.log("🚀 " + msg); | |
} | |
def getUserIdList() { | |
userList = context.getSystemService(context.USER_SERVICE).getUsers(); | |
userIdList = (identifier in (userHandle in userList)); | |
return userIdList; | |
} | |
def isValidPkg(pkg) { | |
return thanos.getPkgManager().getAppInfo(pkg) != null; | |
} | |
def getPkgListByPkgName(pkgName) { | |
userIdList = getUserIdList(); | |
res = []; | |
foreach(userId: userIdList) { | |
pkg = Pkg.newPkg(pkgName, userId); | |
if (isValidPkg(pkg)) { | |
res.add(pkg.userId + "#" + pkg.pkgName); | |
} | |
} | |
return res; | |
} | |
def isPkgFrozen(pkg) { | |
return su.exe("pm freezer query " + pkg + " | awk '/isFrozen/ {print $2}'").out[0]; | |
} | |
def unfreezePkg(pkg) { | |
su.exe("pm freezer temporaryThaw " + pkg); | |
} | |
def checkGlobalVar(pkg) { | |
// 白名单判断逻辑,按需删掉这部分 | |
if (globalVarOf$FCM_UNFREEZE_WHITELIST.contains(pkg)) { | |
debug("应用命中白名单,需要处理"); | |
return true; | |
} else { | |
debug("应用未命中白名单,无需处理"); | |
return false; | |
} | |
// 黑名单判断逻辑,按需删掉这部分 | |
if (globalVarOf$FCM_UNFREEZE_BLACKLIST.contains(pkg)) { | |
debug("应用命中黑名单,无需处理"); | |
return false; | |
} else { | |
debug("应用未命中黑名单,需要处理"); | |
return true; | |
} | |
debug("未指定黑白名单,默认需要处理"); | |
return true; | |
} | |
def main() { | |
debug("开始处理 FCM 推送: " + pkgName); | |
pkgList = getPkgListByPkgName(pkgName); | |
foreach(pkg : pkgList) { | |
debug("多用户下的应用名: " + pkg); | |
if (!checkGlobalVar(pkg)) { | |
return; | |
} | |
if (isPkgFrozen(pkg) == "true") { | |
debug("应用已冻结"); | |
debug("开始临时解冻"); | |
unfreezePkg(pkg); | |
debug("临时解冻完成"); | |
} else { | |
debug("应用未冻结"); | |
} | |
} | |
debug("处理 FCM 推送完成: " + pkgName); | |
} | |
main(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"name": "墓碑模式FCM推送v3.0", | |
"description": "对于支持FCM推送的 **任一** 应用,当其收到推送并且处于后台时,临时解冻3秒。\n仅适配了NoActive Pro版本。", | |
"priority": -1, | |
"condition": "fcmPushMessageArrived == true", | |
"actions": [ | |
"def debug(msg) { log.log(\"🚀 \" + msg); } def getUserIdList() { userList = context.getSystemService(context.USER_SERVICE).getUsers(); userIdList = (identifier in (userHandle in userList)); return userIdList; } def isValidPkg(pkg) { return thanos.getPkgManager().getAppInfo(pkg) != null; } def getPkgListByPkgName(pkgName) { userIdList = getUserIdList(); res = []; foreach(userId: userIdList) { pkg = Pkg.newPkg(pkgName, userId); if (isValidPkg(pkg)) { res.add(pkg.userId + \"#\" + pkg.pkgName); } } return res; } def isPkgFrozen(pkg) { return su.exe(\"pm freezer query \" + pkg + \" | awk '/isFrozen/ {print $2}'\").out[0]; } def unfreezePkg(pkg) { su.exe(\"pm freezer temporaryThaw \" + pkg); } def checkGlobalVar(pkg) { debug(\"未指定黑白名单,默认需要处理\"); return true; } def main() { debug(\"开始处理 FCM 推送: \" + pkgName); pkgList = getPkgListByPkgName(pkgName); foreach(pkg : pkgList) { debug(\"多用户下的应用名: \" + pkg); if (!checkGlobalVar(pkg)) { return; } if (isPkgFrozen(pkg) == \"true\") { debug(\"应用已冻结\"); debug(\"开始临时解冻\"); unfreezePkg(pkg); debug(\"临时解冻完成\"); } else { debug(\"应用未冻结\"); } } debug(\"处理 FCM 推送完成: \" + pkgName); } main();" | |
] | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment