From 7dec34f07646cb91be5a56c09f680d3b09f74556 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Mon, 28 Aug 2023 18:15:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 3 +- app/src/main/AndroidManifest.xml | 6 +- .../main/java/com/yutou/myxposed/Model.java | 130 ++++++++++++++++-- app/src/main/res/values/strings.xml | 2 +- build.gradle | 1 + gradle.properties | 4 +- settings.gradle | 3 +- 7 files changed, 129 insertions(+), 20 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4f7061e..7dd3a1a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -29,7 +29,6 @@ android { } - dependencies { implementation 'androidx.appcompat:appcompat:1.6.1' @@ -39,4 +38,6 @@ dependencies { androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' compileOnly 'de.robv.android.xposed:api:82' + implementation 'com.github.princekin-f:EasyFloat:2.0.4' + } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6796e9d..be12eaa 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -27,14 +27,14 @@ android:value="true" /> + android:value="解决傻逼APP在挖孔屏下遮挡问题" /> - + android:resource="@array/scope" />--> \ No newline at end of file diff --git a/app/src/main/java/com/yutou/myxposed/Model.java b/app/src/main/java/com/yutou/myxposed/Model.java index 26c439f..35d4f4a 100644 --- a/app/src/main/java/com/yutou/myxposed/Model.java +++ b/app/src/main/java/com/yutou/myxposed/Model.java @@ -1,13 +1,26 @@ package com.yutou.myxposed; -import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; - import android.app.Activity; +import android.app.AlertDialog; +import android.app.Application; import android.content.Context; +import android.graphics.Color; +import android.os.Build; import android.os.Bundle; -import android.widget.TextView; +import android.view.DisplayCutout; +import android.view.Gravity; +import android.view.View; +import android.view.WindowInsets; +import android.view.WindowManager; +import android.widget.Button; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.lzf.easyfloat.EasyFloat; +import com.lzf.easyfloat.enums.ShowPattern; + import de.robv.android.xposed.IXposedHookLoadPackage; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedBridge; @@ -18,24 +31,117 @@ public class Model implements IXposedHookLoadPackage { @Override public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); - XposedBridge.log("Loaded app: " + lpparam.packageName); - if(!lpparam.packageName.equals("com.yutou.myapplication"))return; - Class aClass = XposedHelpers.findClass("com.yutou.myapplication.MainActivity", lpparam.classLoader); - XposedHelpers.findAndHookMethod(aClass,"onCreate", Bundle.class,new XC_MethodHook(){ + XposedBridge.log("Loaded_app: " + lpparam.packageName + "|" + lpparam.appInfo.className); + if (lpparam.isFirstApplication) { + if (lpparam.appInfo.className != null) { + hook(lpparam); + } + } + } + + private void hook(XC_LoadPackage.LoadPackageParam lpparam) { + XposedBridge.log("注入: " + lpparam.appInfo.className); + String className = "android.app.Application"; + // className="tv.danmaku.bili.MainActivityV2"; + Class aClass = XposedHelpers.findClass(className, lpparam.classLoader); + XposedHelpers.findAndHookMethod(aClass, "onCreate", new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { super.beforeHookedMethod(param); + // afterHookedMethod(param); } @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { super.afterHookedMethod(param); - Toast.makeText((Context) param.thisObject,"Yes3",Toast.LENGTH_LONG).show(); - Activity activity = (Activity) param.thisObject; - activity.getWindow().clearFlags(SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); - int textView = activity.getResources().getIdentifier("textView", "id", activity.getPackageName()); - ((TextView)activity.findViewById(textView)).setText("!!!!"); + Application context = (Application) param.thisObject; + + context.registerActivityLifecycleCallbacks(new Application.ActivityLifecycleCallbacks() { + @Override + public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) { + if (lpparam.packageName.equals("tv.danmaku.bilibilihd")) { + if (activity.getClass().getName().contains("MainActivityV2")) { + set(activity); + } + } else { + set(activity); + } + } + + @Override + public void onActivityStarted(@NonNull Activity activity) { + + } + + @Override + public void onActivityResumed(@NonNull Activity activity) { + + } + + @Override + public void onActivityPaused(@NonNull Activity activity) { + + } + + @Override + public void onActivityStopped(@NonNull Activity activity) { + + } + + @Override + public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) { + + } + + @Override + public void onActivityDestroyed(@NonNull Activity activity) { + + } + }); } }); } + + public void set(Activity activity) { + activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); + activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); + activity.getWindow().getDecorView().setBackgroundColor(Color.BLACK); + View view = activity.getWindow().getDecorView().findViewById(android.R.id.content); + view.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { + @NonNull + @Override + public WindowInsets onApplyWindowInsets(@NonNull View v, @NonNull WindowInsets insets) { + DisplayCutout cutout = null; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) { + cutout = activity.getWindowManager().getDefaultDisplay().getCutout(); + int left = cutout.getSafeInsetLeft(); + int top = 0; + int right = cutout.getSafeInsetRight(); + int bottom = 0; + v.setPadding(left, top, right, bottom); + } + return insets; + } + }); + activity.getWindow().getDecorView().setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { + @NonNull + @Override + public WindowInsets onApplyWindowInsets(@NonNull View v, @NonNull WindowInsets insets) { + return insets; + } + }); + WindowManager.LayoutParams lp = activity.getWindow().getAttributes(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER; + } + activity.getWindow().setAttributes(lp); + + } + + public void showDialog(Context context, String str) { + new AlertDialog.Builder(context) + .setTitle("出错了") + .setMessage(str) + .show(); + } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8b396f6..4ea24bd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,3 @@ - My Xposed + 傻逼挖孔屏 \ No newline at end of file diff --git a/build.gradle b/build.gradle index 4bd0a9f..7ad8123 100644 --- a/build.gradle +++ b/build.gradle @@ -5,6 +5,7 @@ buildscript { google() mavenCentral() maven { url 'https://maven.aliyun.com/repository/public/' } + maven { url 'https://jitpack.io' } } dependencies { classpath 'com.android.tools.build:gradle:4.0.2' diff --git a/gradle.properties b/gradle.properties index 9b8183d..a147350 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,5 +22,5 @@ android.nonTransitiveRClass=true systemProp.http.proxyHost=127.0.0.1 systemProp.https.proxyHost=127.0.0.1 -systemProp.https.proxyPort=7890 -systemProp.http.proxyPort=7890 \ No newline at end of file +systemProp.https.proxyPort=10809 +systemProp.http.proxyPort=10809 \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index dccbe50..88944fd 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,6 +4,7 @@ pluginManagement { mavenCentral() gradlePluginPortal() maven { url 'https://maven.aliyun.com/repository/public/' } + maven { url 'https://jitpack.io' } } } dependencyResolutionManagement { @@ -12,7 +13,7 @@ dependencyResolutionManagement { google() mavenCentral() maven { url 'https://maven.aliyun.com/repository/public/' } - + maven { url 'https://jitpack.io' } } }