-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
118 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
58 changes: 58 additions & 0 deletions
58
app/src/main/java/com/kooritea/fcmfix/util/XposedUtils.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.kooritea.fcmfix.util; | ||
|
||
import java.lang.reflect.Constructor; | ||
import java.lang.reflect.Method; | ||
|
||
import de.robv.android.xposed.XC_MethodHook; | ||
import de.robv.android.xposed.XposedBridge; | ||
import de.robv.android.xposed.XposedHelpers; | ||
|
||
public class XposedUtils { | ||
public static XC_MethodHook.Unhook findAndHookConstructorAnyParam(String className, ClassLoader classLoader, XC_MethodHook callbacks, Class<?> ...parameterTypes){ | ||
Class<?> clazz = XposedHelpers.findClass(className,classLoader); | ||
Constructor bestMatch = null; | ||
int matchCount = 0; | ||
for(Constructor<?> constructor : clazz.getDeclaredConstructors()){ | ||
Class<?>[] constructorParamTypes = constructor.getParameterTypes(); | ||
int _matchCount = 0; | ||
for(int i = 0;i<Math.min(constructorParamTypes.length,parameterTypes.length);i++){ | ||
if(parameterTypes[i] == constructorParamTypes[i]){ | ||
_matchCount++; | ||
} | ||
} | ||
if(_matchCount >= matchCount){ | ||
matchCount = _matchCount; | ||
bestMatch = constructor; | ||
} | ||
} | ||
if(bestMatch == null){ | ||
throw new NoSuchMethodError(clazz.getName()); | ||
} | ||
return XposedBridge.hookMethod(XposedHelpers.findConstructorExact(clazz,bestMatch.getParameterTypes()), callbacks); | ||
} | ||
|
||
public static XC_MethodHook.Unhook findAndHookMethodAnyParam(String className, ClassLoader classLoader, String methodName, XC_MethodHook callbacks, Object ...parameterTypes){ | ||
Class<?> clazz = XposedHelpers.findClass(className,classLoader); | ||
Method bestMatch = null; | ||
int matchCount = 0; | ||
for(Method method : clazz.getDeclaredMethods()){ | ||
if(methodName.equals(method.getName())){ | ||
Class<?>[] methodParamTypes = method.getParameterTypes(); | ||
int _matchCount = 0; | ||
for(int i = 0;i<Math.min(methodParamTypes.length,parameterTypes.length);i++){ | ||
if(parameterTypes[i] == methodParamTypes[i]){ | ||
_matchCount++; | ||
} | ||
} | ||
if(_matchCount >= matchCount){ | ||
matchCount = _matchCount; | ||
bestMatch = method; | ||
} | ||
} | ||
} | ||
if(bestMatch == null){ | ||
throw new NoSuchMethodError(clazz.getName() + '#' + methodName); | ||
} | ||
return XposedBridge.hookMethod(XposedHelpers.findMethodExact(clazz,methodName,bestMatch.getParameterTypes()), callbacks); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
app/src/main/java/com/kooritea/fcmfix/xposed/AutoStartFix.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.kooritea.fcmfix.xposed; | ||
|
||
import android.content.Intent; | ||
|
||
import com.kooritea.fcmfix.util.XposedUtils; | ||
|
||
import de.robv.android.xposed.XC_MethodHook; | ||
import de.robv.android.xposed.XposedHelpers; | ||
import de.robv.android.xposed.callbacks.XC_LoadPackage; | ||
|
||
public class AutoStartFix extends XposedModule { | ||
|
||
public AutoStartFix(XC_LoadPackage.LoadPackageParam loadPackageParam){ | ||
super(loadPackageParam); | ||
this.startHook(); | ||
} | ||
|
||
protected void startHook(){ | ||
XposedUtils.findAndHookMethodAnyParam("com.android.server.am.BroadcastQueueInjector",loadPackageParam.classLoader,"checkApplicationAutoStart",new XC_MethodHook() { | ||
@Override | ||
protected void beforeHookedMethod(MethodHookParam methodHookParam) throws Throwable { | ||
Intent intent = (Intent) XposedHelpers.getObjectField(methodHookParam.args[2],"intent"); | ||
if("com.google.android.c2dm.intent.RECEIVE".equals(intent.getAction())){ | ||
String target; | ||
if (intent.getComponent() != null) { | ||
target = intent.getComponent().getPackageName(); | ||
} else { | ||
target = intent.getPackage(); | ||
} | ||
if(targetIsAllow(target)){ | ||
printLog("Allow Auto Start: " + target); | ||
methodHookParam.setResult(true); | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
} |
This file contains 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
ddc41fe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不需要这么麻烦,把powerkeeper那个app伪装成国际版就可以了,就是这个app有针对gms的一系列定制打压逻辑
ddc41fe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
把整个powerkeeper伪装成国际版会导致其他应用都不可控了
ddc41fe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个提交主要是不用再手动给自启动权限而已,powerkeeper会限制fcm的问题这个得另外解决
ddc41fe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我只是看到了这个做法,顺手反馈。我自己用xposed模块这么改了,只把这个伪装成国际版,问题不大,反编译看过,它只用是否国际版来控制使用哪些后台压制策略而已。
ddc41fe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个自启动的相关控制是在services.jar里面的,powerkeeper是后台策略的,所以其实关系不大