This commit is contained in:
zlzw 2023-08-28 18:15:38 +08:00
parent c0507cd803
commit 7dec34f076
7 changed files with 129 additions and 20 deletions

View File

@ -29,7 +29,6 @@ android {
} }
dependencies { dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.appcompat:appcompat:1.6.1'
@ -39,4 +38,6 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
compileOnly 'de.robv.android.xposed:api:82' compileOnly 'de.robv.android.xposed:api:82'
implementation 'com.github.princekin-f:EasyFloat:2.0.4'
} }

View File

@ -27,14 +27,14 @@
android:value="true" /> android:value="true" />
<meta-data <meta-data
android:name="xposeddescription" android:name="xposeddescription"
android:value="Easy example which makes the status bar clock red and adds a smiley" /> android:value="解决傻逼APP在挖孔屏下遮挡问题" />
<meta-data <meta-data
android:name="xposedminversion" android:name="xposedminversion"
android:value="53" /> android:value="53" />
<meta-data <!-- <meta-data
android:name="xposedscope" android:name="xposedscope"
android:resource="@array/scope" /> android:resource="@array/scope" />-->
</application> </application>
</manifest> </manifest>

View File

@ -1,13 +1,26 @@
package com.yutou.myxposed; package com.yutou.myxposed;
import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog;
import android.app.Application;
import android.content.Context; import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle; 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 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.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge; import de.robv.android.xposed.XposedBridge;
@ -18,24 +31,117 @@ public class Model implements IXposedHookLoadPackage {
@Override @Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
XposedBridge.log("Loaded app: " + lpparam.packageName); XposedBridge.log("Loaded_app: " + lpparam.packageName + "|" + lpparam.appInfo.className);
if(!lpparam.packageName.equals("com.yutou.myapplication"))return; if (lpparam.isFirstApplication) {
Class<?> aClass = XposedHelpers.findClass("com.yutou.myapplication.MainActivity", lpparam.classLoader); if (lpparam.appInfo.className != null) {
XposedHelpers.findAndHookMethod(aClass,"onCreate", Bundle.class,new XC_MethodHook(){ 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 @Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable { protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
super.beforeHookedMethod(param); super.beforeHookedMethod(param);
// afterHookedMethod(param);
} }
@Override @Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable { protected void afterHookedMethod(MethodHookParam param) throws Throwable {
super.afterHookedMethod(param); super.afterHookedMethod(param);
Toast.makeText((Context) param.thisObject,"Yes3",Toast.LENGTH_LONG).show(); Application context = (Application) param.thisObject;
Activity activity = (Activity) param.thisObject;
activity.getWindow().clearFlags(SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); context.registerActivityLifecycleCallbacks(new Application.ActivityLifecycleCallbacks() {
int textView = activity.getResources().getIdentifier("textView", "id", activity.getPackageName()); @Override
((TextView)activity.findViewById(textView)).setText("!!!!"); 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();
}
} }

View File

@ -1,3 +1,3 @@
<resources> <resources>
<string name="app_name">My Xposed</string> <string name="app_name">傻逼挖孔屏</string>
</resources> </resources>

View File

@ -5,6 +5,7 @@ buildscript {
google() google()
mavenCentral() mavenCentral()
maven { url 'https://maven.aliyun.com/repository/public/' } maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://jitpack.io' }
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.0.2' classpath 'com.android.tools.build:gradle:4.0.2'

View File

@ -22,5 +22,5 @@ android.nonTransitiveRClass=true
systemProp.http.proxyHost=127.0.0.1 systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyHost=127.0.0.1 systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=7890 systemProp.https.proxyPort=10809
systemProp.http.proxyPort=7890 systemProp.http.proxyPort=10809

View File

@ -4,6 +4,7 @@ pluginManagement {
mavenCentral() mavenCentral()
gradlePluginPortal() gradlePluginPortal()
maven { url 'https://maven.aliyun.com/repository/public/' } maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://jitpack.io' }
} }
} }
dependencyResolutionManagement { dependencyResolutionManagement {
@ -12,7 +13,7 @@ dependencyResolutionManagement {
google() google()
mavenCentral() mavenCentral()
maven { url 'https://maven.aliyun.com/repository/public/' } maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://jitpack.io' }
} }
} }