Skip to content

Commit

Permalink
opt: MobileTypeSingle2Hook (显示逻辑为默认时)的相关逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
lingqiqi5211 committed Jan 13, 2025
1 parent 0f5b083 commit a778cb0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,45 +28,44 @@ public class BypassUnknownSourcesRestrictions extends BaseHook {
public void init() throws NoSuchMethodException {
String packageName = lpparam.packageName;
ClassLoader classLoader = lpparam.classLoader;
//注意:com.miui.packageinstaller是com.android.packageinstaller的改包名安装器,不是MIUI原版安装器
//缘由:MIUI原版安装器上传应用信息并协同小米账号到反诈中心等,并且用其他安装器不认,故将原生的安装器直接改包名并使用核破解覆盖com.miui.packageinstaller
// 注意:com.miui.packageinstaller 是 com.android.packageinstaller 的改包名安装器,不是 MIUI 原版安装器
// 缘由:MIUI 原版安装器上传应用信息并协同小米账号到反诈中心等,并且用其他安装器不认,故将原生的安装器直接改包名并使用核破解覆盖 com.miui.packageinstaller
/*if (packageName.equals("com.miui.packageinstaller") || packageName.equals("com.android.packageinstaller")){
XposedHelpers.findAndHookMethod("com.android.packageinstaller.PackageInstallerActivity", classLoader, "onCreate", android.os.Bundle.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
super.beforeHookedMethod(param);
//很简单,只需要在onCreate方法执行前把mAllowUnknownSources字段设置为true即可
//很简单,只需要在 onCreate 方法执行前把 mAllowUnknownSources 字段设置为 true 即可
XposedHelpers.setBooleanField(param.thisObject,"mAllowUnknownSources",true);
Context context;
}
});
}*/
if (packageName.equals("android")) {
//Hook掉未知来源权限检查,一律返回有
findAndHookMethod("com.android.server.appop.AppOpsService", classLoader, "noteOperation", int.class, int.class, java.lang.String.class, java.lang.String.class, boolean.class, java.lang.String.class, boolean.class, new MethodHook() {
@Override
protected void before(MethodHookParam param) throws Throwable {
super.before(param);

// Hook 掉未知来源权限检查,一律返回有
findAndHookMethod("com.android.server.appop.AppOpsService", classLoader, "noteOperation", int.class, int.class, java.lang.String.class, java.lang.String.class, boolean.class, java.lang.String.class, boolean.class, new MethodHook() {
@Override
protected void after(MethodHookParam param) throws Throwable {
if ((Integer) param.args[0] == 66) {
// AppOpsManager.permissionToOpCode("android.permission.REQUEST_INSTALL_PACKAGES") == 66
// XposedBridge.log("com.android.server.appop.AppOpsService.noteOperation("+Arrays.toString(param.args)+") return:"+param.getResult());
setIntField(param.getResult(), "mOpMode", 0);
}
}
});

// 以免智障程序自己检查是否有这个权限,然后跑来申请
try {
findAndHookMethod("com.android.server.pm.IPackageManagerBase", classLoader, "canRequestPackageInstalls", java.lang.String.class, int.class, new MethodHook() {
@Override
protected void after(MethodHookParam param) throws Throwable {
super.after(param);
if ((Integer) param.args[0] == 66){//AppOpsManager.permissionToOpCode("android.permission.REQUEST_INSTALL_PACKAGES") == 66
//XposedBridge.log("com.android.server.appop.AppOpsService.noteOperation("+Arrays.toString(param.args)+") return:"+param.getResult());
setIntField(param.getResult(),"mOpMode",0);
}
param.setResult(true);
}
});
//以免智障程序自己检查是否有这个权限,然后跑来申请
} catch (Throwable t) {
findAndHookMethod("com.android.server.pm.PackageManagerService", classLoader, "canRequestPackageInstalls", java.lang.String.class, int.class, new MethodHook() {
@Override
protected void before(MethodHookParam param) throws Throwable {
super.before(param);
}

@Override
protected void after(MethodHookParam param) throws Throwable {
super.after(param);
param.setResult(true);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ object HideFakeStatusBar : MusicBaseHook() {
if (isShowingFocusedLyric) {
// 在显示歌词的时候固定通知栏顶部时间和日期的位置和缩放
val notificationHeaderExpandController =
it.thisObject.getObjectFieldOrNull("this\$0") ?: return@after
it.thisObject.getObjectField("this\$0")
val combinedHeaderController =
notificationHeaderExpandController.getObjectFieldOrNull("headerController")!!
notificationHeaderExpandController?.getObjectFieldOrNull("headerController")!!
.callMethod("get")
val notificationBigTime =
combinedHeaderController!!.getObjectFieldAs<TextView>("notificationBigTime")
Expand Down Expand Up @@ -188,9 +188,9 @@ object HideFakeStatusBar : MusicBaseHook() {
if (isShowingFocusedLyric) {
// 显示歌词的时候手动调用动画,防止大时钟突然出现
val notificationHeaderExpandController =
it.thisObject.getObjectFieldOrNull("this\$0") ?: return@after
it.thisObject.getObjectField("this\$0")
val combinedHeaderController =
notificationHeaderExpandController.getObjectField("headerController")!!
notificationHeaderExpandController?.getObjectField("headerController")!!
.callMethod("get")
loadClass("com.android.systemui.controlcenter.shade.NotificationHeaderExpandController")
.callStaticMethod(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,39 +65,27 @@ object MobileTypeSingle2Hook : BaseHook() {
private val simDataConnected = booleanArrayOf(false, false)

override fun init() {
if (mobileNetworkType != 0) {
hookMobileView()
}

if (!showMobileType) {
return
}
hookMobileView()
if (!showMobileType) return

try {
method = DarkIconDispatcherClass.getMethod(
"isInAreas",
MutableCollection::class.java,
View::class.java
)

try {
method2 = DarkIconDispatcherClass.getMethod(
"getTint",
MutableCollection::class.java,
View::class.java,
Integer.TYPE
)
} catch (unused: Throwable) {
logE(TAG, lpparam.packageName, "DarkIconDispatcher.isInArea not found")
if (method != null) {
return
}
return
}
} catch (unused2: Throwable) {
method2 = DarkIconDispatcherClass.getMethod(
"getTint",
MutableCollection::class.java,
View::class.java,
Integer.TYPE
)
} catch (unused: Throwable) {
logE(TAG, lpparam.packageName, "DarkIconDispatcher methods not found")
method = null
method2 = null
}
if (method == null || method2 == null) {
if (method == null && method2 == null) {
return
}

Expand Down Expand Up @@ -167,7 +155,8 @@ object MobileTypeSingle2Hook : BaseHook() {

// 添加大 5G 并设置样式
if (showMobileType) {
val mobileType = containerLeft.findViewByIdName("mobile_type") as? ImageView?
val mobileType =
containerLeft.findViewByIdName("mobile_type") as? ImageView?
val textView =
mobileGroup.findViewByIdName("mobile_type_single") as TextView
if (!getLocation) {
Expand Down

0 comments on commit a778cb0

Please sign in to comment.