mirror of
https://github.com/LSPosed/DisableFlagSecure.git
synced 2025-05-05 01:59:43 +08:00
Compare commits
57 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
b64046f57c | ||
|
bc17c4c9bb | ||
|
401f196e2e | ||
|
bf5cdb513d | ||
|
f11e16da7d | ||
|
de591e925e | ||
|
4b426733ca | ||
|
a5461af177 | ||
|
aa56f32b6a | ||
|
cf19309b6b | ||
|
cd14a26f54 | ||
|
20c7f4c30d | ||
|
624a493311 | ||
|
a5e8659290 | ||
|
375469dd23 | ||
|
2baedef66f | ||
|
469d58c95f | ||
|
e0203a480f | ||
|
197f971cbb | ||
|
9fbc536136 | ||
|
610af286b7 | ||
|
8ba19d5779 | ||
|
f166d733f0 | ||
|
5ddd76fe39 | ||
|
c991e3dac1 | ||
|
42ae2ab20d | ||
|
caa953cd11 | ||
|
4a811dd16a | ||
|
bdea05344b | ||
|
fd0b56f651 | ||
|
92c067bb15 | ||
|
5f342219df | ||
|
52e281a380 | ||
|
9343df3060 | ||
|
b222af63b4 | ||
|
3525dd69a8 | ||
|
3b2efdea96 | ||
|
dab601582f | ||
|
ac95d737da | ||
|
3481cbbfac | ||
|
201040ed64 | ||
|
aee7d86bb3 | ||
|
5fddba5a28 | ||
|
c5f1300bad | ||
|
8fa24bf735 | ||
|
7df5373528 | ||
|
df2f067432 | ||
|
ad2a9422b0 | ||
|
d4c648c0d6 | ||
|
e6bc968ab6 | ||
|
e4445075b3 | ||
|
6c8ecc6091 | ||
|
29da41af0f | ||
|
b66d2549d5 | ||
|
8825a0fabe | ||
|
65d04b4c65 | ||
|
8fa792e7a9 |
7
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
7
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -29,6 +29,13 @@ body:
|
||||
options:
|
||||
- label: I am using latest debug CI version
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: official
|
||||
attributes:
|
||||
label: LSPosed requirement
|
||||
options:
|
||||
- label: I am using official LSPosed version
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Behavior
|
||||
|
6
.github/workflows/android.yml
vendored
6
.github/workflows/android.yml
vendored
@ -19,14 +19,14 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: libxposed/api
|
||||
ref: a42f85d06eac3373d266a534ab3b31a584b30774
|
||||
ref: 64e29bd657ef4d2540b34402f5a988778f29e676
|
||||
path: libxposed/api
|
||||
fetch-depth: 0
|
||||
|
||||
- name: set up JDK 17
|
||||
- name: set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '17'
|
||||
java-version: '21'
|
||||
distribution: 'temurin'
|
||||
cache: gradle
|
||||
|
||||
|
10
README.md
10
README.md
@ -1,5 +1,13 @@
|
||||
# Enable Screenshot (formerly known as Disable FLAG_SECURE)
|
||||
Enabling screenshots in apps that normally wouldn\'t allow it, and disabling screenshot detection on Android 14+.
|
||||
Enabling screenshots in apps that normally wouldn\'t allow it, and disabling screenshot(Android 14+) & screen record(Android 15+) detection.
|
||||
|
||||
**Unofficial LSPosed versions are not supported.**
|
||||
|
||||
## Supported OSes
|
||||
- Android 12-16 Beta 3 (Custom ROMs are **not** supported)
|
||||
- Xiaomi Hyper OS
|
||||
- OPlus OS (Color OS/Realme UI/Oxygen OS)
|
||||
- Samsung One UI
|
||||
|
||||
## Usage
|
||||
1. Enable the module
|
||||
|
1
SOURCE_URL
Normal file
1
SOURCE_URL
Normal file
@ -0,0 +1 @@
|
||||
https://github.com/LSPosed/DisableFlagSecure
|
1
SUMMARY
Normal file
1
SUMMARY
Normal file
@ -0,0 +1 @@
|
||||
Enabling screenshots in apps that normally wouldn't allow it, and disabling screenshot(Android 14+) & screen record(Android 15+) detection.
|
@ -3,15 +3,15 @@ plugins {
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk 34
|
||||
buildToolsVersion "34.0.0"
|
||||
compileSdk 36
|
||||
buildToolsVersion "36.0.0"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "io.github.lsposed.disableflagsecure"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 34
|
||||
minSdkVersion 31
|
||||
targetSdkVersion 36
|
||||
versionCode rootProject.ext.commitCount
|
||||
versionName "4.0.0"
|
||||
versionName "4.2.0"
|
||||
}
|
||||
|
||||
Properties localProperties = new Properties()
|
||||
@ -42,14 +42,15 @@ android {
|
||||
} else {
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
vcsInfo.include false
|
||||
minifyEnabled true
|
||||
proguardFiles 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
sourceCompatibility JavaVersion.VERSION_21
|
||||
targetCompatibility JavaVersion.VERSION_21
|
||||
}
|
||||
|
||||
lint {
|
||||
@ -61,6 +62,7 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly 'androidx.annotation:annotation:1.8.0'
|
||||
compileOnly 'androidx.annotation:annotation:1.9.1'
|
||||
compileOnly 'io.github.libxposed:api:100'
|
||||
compileOnly project(":libxposed-compat")
|
||||
}
|
||||
|
12
app/proguard-rules.pro
vendored
12
app/proguard-rules.pro
vendored
@ -6,9 +6,15 @@
|
||||
public void onPackageLoaded(...);
|
||||
public void onSystemServerLoaded(...);
|
||||
}
|
||||
-keep,allowoptimization,allowobfuscation @io.github.libxposed.api.annotations.* class * {
|
||||
@io.github.libxposed.api.annotations.BeforeInvocation <methods>;
|
||||
@io.github.libxposed.api.annotations.AfterInvocation <methods>;
|
||||
-keep,allowshrinking,allowoptimization,allowobfuscation class ** implements io.github.libxposed.api.XposedInterface$Hooker
|
||||
-keepclassmembers,allowoptimization class ** implements io.github.libxposed.api.XposedInterface$Hooker {
|
||||
public *** before(***);
|
||||
public *** after(***);
|
||||
public static *** before();
|
||||
public static *** before(io.github.libxposed.api.XposedInterface$BeforeHookCallback);
|
||||
public static void after();
|
||||
public static void after(io.github.libxposed.api.XposedInterface$AfterHookCallback);
|
||||
public static void after(io.github.libxposed.api.XposedInterface$AfterHookCallback, ***);
|
||||
}
|
||||
|
||||
-repackageclasses
|
||||
|
16
app/src/debug/AndroidManifest.xml
Normal file
16
app/src/debug/AndroidManifest.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application tools:ignore="MissingApplicationIcon">
|
||||
<activity
|
||||
android:name=".TestActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="de.robv.android.xposed.category.MODULE_SETTINGS" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -0,0 +1,63 @@
|
||||
package io.github.lsposed.disableflagsecure;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Paint;
|
||||
import android.os.Bundle;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class TestActivity extends Activity implements SurfaceHolder.Callback {
|
||||
private TextView textView;
|
||||
private SurfaceView surfaceView;
|
||||
private final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG) {{
|
||||
setColor(0xFF00FFFF);
|
||||
}};
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
||||
|
||||
var linearLayout = new LinearLayout(this);
|
||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
linearLayout.setBackgroundColor(0xFFFFFF00);
|
||||
setContentView(linearLayout, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
|
||||
|
||||
textView = new TextView(this);
|
||||
linearLayout.addView(textView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f));
|
||||
|
||||
surfaceView = new SurfaceView(this);
|
||||
surfaceView.setZOrderOnTop(true);
|
||||
surfaceView.setSecure(true);
|
||||
surfaceView.getHolder().addCallback(this);
|
||||
linearLayout.addView(surfaceView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void surfaceCreated(@NonNull SurfaceHolder holder) {
|
||||
var canvas = holder.lockCanvas();
|
||||
canvas.drawRect(0, 0, surfaceView.getMeasuredWidth(), surfaceView.getMeasuredHeight(), paint);
|
||||
textView.setText("SurfaceView");
|
||||
textView.draw(canvas);
|
||||
textView.setText("TextView");
|
||||
holder.unlockCanvasAndPost(canvas);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceChanged(@NonNull SurfaceHolder holder, int format, int width, int height) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceDestroyed(@NonNull SurfaceHolder holder) {
|
||||
|
||||
}
|
||||
}
|
@ -1,18 +1,16 @@
|
||||
package io.github.lsposed.disableflagsecure;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.view.SurfaceControl;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiPredicate;
|
||||
@ -25,8 +23,8 @@ import io.github.libxposed.api.annotations.XposedHooker;
|
||||
@SuppressLint({"PrivateApi", "BlockedPrivateApi"})
|
||||
public class DisableFlagSecure extends XposedModule {
|
||||
private static final String SYSTEMUI = "com.android.systemui";
|
||||
private static final String OPLUS_SCREENSHOT = "com.oplus.screenshot";
|
||||
private static final String OPLUS_APPPLATFORM = "com.oplus.appplatform";
|
||||
private static final String OPLUS_SCREENSHOT = "com.oplus.screenshot";
|
||||
private static final String FLYME_SYSTEMUIEX = "com.flyme.systemuiex";
|
||||
private static final String MIUI_SCREENSHOT = "com.miui.screenshot";
|
||||
|
||||
@ -47,15 +45,25 @@ public class DisableFlagSecure extends XposedModule {
|
||||
log("deoptimize system server failed", t);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
||||
// Screen record detection (V~Baklava)
|
||||
try {
|
||||
hookWindowManagerService(classLoader);
|
||||
} catch (Throwable t) {
|
||||
log("hook WindowManagerService failed", t);
|
||||
}
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||
// Screenshot detection (U)
|
||||
// Screenshot detection (U~Baklava)
|
||||
try {
|
||||
hookActivityTaskManagerService(classLoader);
|
||||
} catch (Throwable t) {
|
||||
log("hook ActivityTaskManagerService failed", t);
|
||||
}
|
||||
|
||||
// Xiaomi HyperOS (U)
|
||||
// Xiaomi HyperOS (U~Baklava)
|
||||
// OS2.0.250220.1.WOCCNXM.PRE
|
||||
try {
|
||||
hookHyperOS(classLoader);
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
@ -64,8 +72,7 @@ public class DisableFlagSecure extends XposedModule {
|
||||
}
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
// ScreenCapture in WindowManagerService (S~U)
|
||||
// ScreenCapture in WindowManagerService (S~Baklava)
|
||||
try {
|
||||
hookScreenCapture(classLoader);
|
||||
} catch (Throwable t) {
|
||||
@ -81,22 +88,20 @@ public class DisableFlagSecure extends XposedModule {
|
||||
}
|
||||
}
|
||||
|
||||
// WifiDisplay (S~U) / OverlayDisplay (S~U) / VirtualDisplay (U)
|
||||
// WifiDisplay (S~Baklava) / OverlayDisplay (S~Baklava) / VirtualDisplay (U~Baklava)
|
||||
try {
|
||||
hookDisplayControl(classLoader);
|
||||
} catch (Throwable t) {
|
||||
log("hook DisplayControl failed", t);
|
||||
}
|
||||
|
||||
// VirtualDisplay with MediaProjection (S~U)
|
||||
// VirtualDisplay with MediaProjection (S~Baklava)
|
||||
try {
|
||||
hookVirtualDisplayAdapter(classLoader);
|
||||
} catch (Throwable t) {
|
||||
log("hook VirtualDisplayAdapter failed", t);
|
||||
}
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
// OneUI
|
||||
try {
|
||||
hookScreenshotHardwareBuffer(classLoader);
|
||||
@ -112,15 +117,24 @@ public class DisableFlagSecure extends XposedModule {
|
||||
log("hook OneUI failed", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// secureLocked flag (S-)
|
||||
// secureLocked flag
|
||||
try {
|
||||
// Screenshot
|
||||
hookWindowState(classLoader);
|
||||
} catch (Throwable t) {
|
||||
log("hook WindowState failed", t);
|
||||
}
|
||||
|
||||
// oplus dumpsys
|
||||
// dumpsys window screenshot systemQuickTileScreenshotOut display_id=0
|
||||
try {
|
||||
hookOplus(classLoader);
|
||||
} catch (Throwable t) {
|
||||
if (!(t instanceof ClassNotFoundException)) {
|
||||
log("hook Oplus failed", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("PrivateApi")
|
||||
@ -132,19 +146,16 @@ public class DisableFlagSecure extends XposedModule {
|
||||
var pn = param.getPackageName();
|
||||
switch (pn) {
|
||||
case OPLUS_SCREENSHOT:
|
||||
// Oplus Screenshot 15.0.0
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
||||
try {
|
||||
hookOplus(classLoader);
|
||||
} catch (Throwable t) {
|
||||
log("hook OPlus failed", t);
|
||||
}
|
||||
try {
|
||||
hookOplusNew(classLoader);
|
||||
hookOplusScreenCapture(classLoader);
|
||||
} catch (Throwable t) {
|
||||
if (!(t instanceof ClassNotFoundException)) {
|
||||
log("hook OPlus failed", t);
|
||||
log("hook OplusScreenCapture failed", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FLYME_SYSTEMUIEX:
|
||||
case OPLUS_APPPLATFORM:
|
||||
// Flyme SystemUI Ext 10.3.0
|
||||
@ -158,10 +169,10 @@ public class DisableFlagSecure extends XposedModule {
|
||||
}
|
||||
case SYSTEMUI:
|
||||
case MIUI_SCREENSHOT:
|
||||
if (OPLUS_APPPLATFORM.equals(pn) ||
|
||||
(Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
|
||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE)) {
|
||||
// ScreenCapture in App (S~T) (OPlus S-U)
|
||||
if (OPLUS_APPPLATFORM.equals(pn) || OPLUS_SCREENSHOT.equals(pn) ||
|
||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||
// ScreenCapture in App (S~T) (OPlus S~V)
|
||||
// TODO: test Oplus Baklava
|
||||
try {
|
||||
hookScreenCapture(classLoader);
|
||||
} catch (Throwable t) {
|
||||
@ -213,20 +224,12 @@ public class DisableFlagSecure extends XposedModule {
|
||||
|
||||
private void hookWindowState(ClassLoader classLoader) throws ClassNotFoundException, NoSuchMethodException {
|
||||
var windowStateClazz = classLoader.loadClass("com.android.server.wm.WindowState");
|
||||
Method isSecureLockedMethod;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
isSecureLockedMethod = windowStateClazz.getDeclaredMethod("isSecureLocked");
|
||||
} else {
|
||||
var windowManagerServiceClazz = classLoader.loadClass("com.android.server.wm.WindowManagerService");
|
||||
isSecureLockedMethod = windowManagerServiceClazz.getDeclaredMethod("isSecureLocked", windowStateClazz);
|
||||
}
|
||||
var isSecureLockedMethod = windowStateClazz.getDeclaredMethod("isSecureLocked");
|
||||
hook(isSecureLockedMethod, SecureLockedHooker.class);
|
||||
}
|
||||
|
||||
private static Field captureSecureLayersField;
|
||||
private static Field allowProtectedField;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.S)
|
||||
private void hookScreenCapture(ClassLoader classLoader) throws ClassNotFoundException, NoSuchFieldException {
|
||||
var screenCaptureClazz = Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE ?
|
||||
classLoader.loadClass("android.window.ScreenCapture") :
|
||||
@ -236,28 +239,27 @@ public class DisableFlagSecure extends XposedModule {
|
||||
"android.view.SurfaceControl$CaptureArgs");
|
||||
captureSecureLayersField = captureArgsClazz.getDeclaredField("mCaptureSecureLayers");
|
||||
captureSecureLayersField.setAccessible(true);
|
||||
allowProtectedField = captureArgsClazz.getDeclaredField("mAllowProtected");
|
||||
allowProtectedField.setAccessible(true);
|
||||
hookMethods(screenCaptureClazz, ScreenCaptureHooker.class, "nativeCaptureDisplay");
|
||||
hookMethods(screenCaptureClazz, ScreenCaptureHooker.class, "nativeCaptureLayers");
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.S)
|
||||
private void hookDisplayControl(ClassLoader classLoader) throws ClassNotFoundException, NoSuchMethodException {
|
||||
var displayControlClazz = Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE ?
|
||||
classLoader.loadClass("com.android.server.display.DisplayControl") :
|
||||
SurfaceControl.class;
|
||||
var method = displayControlClazz.getDeclaredMethod("createDisplay", String.class, boolean.class);
|
||||
var method = displayControlClazz.getDeclaredMethod(
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM ?
|
||||
"createVirtualDisplay" :
|
||||
"createDisplay", String.class, boolean.class);
|
||||
hook(method, CreateDisplayHooker.class);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.S)
|
||||
private void hookVirtualDisplayAdapter(ClassLoader classLoader) throws ClassNotFoundException {
|
||||
var displayControlClazz = classLoader.loadClass("com.android.server.display.VirtualDisplayAdapter");
|
||||
hookMethods(displayControlClazz, CreateVirtualDisplayLockedHooker.class, "createVirtualDisplayLocked");
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
|
||||
@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
|
||||
private void hookActivityTaskManagerService(ClassLoader classLoader) throws ClassNotFoundException, NoSuchMethodException {
|
||||
var activityTaskManagerServiceClazz = classLoader.loadClass("com.android.server.wm.ActivityTaskManagerService");
|
||||
var iBinderClazz = classLoader.loadClass("android.os.IBinder");
|
||||
@ -266,20 +268,26 @@ public class DisableFlagSecure extends XposedModule {
|
||||
hook(method, ReturnNullHooker.class);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.S)
|
||||
@RequiresApi(Build.VERSION_CODES.VANILLA_ICE_CREAM)
|
||||
private void hookWindowManagerService(ClassLoader classLoader) throws ClassNotFoundException, NoSuchMethodException {
|
||||
var windowManagerServiceClazz = classLoader.loadClass("com.android.server.wm.WindowManagerService");
|
||||
var iScreenRecordingCallbackClazz = classLoader.loadClass("android.window.IScreenRecordingCallback");
|
||||
var method = windowManagerServiceClazz.getDeclaredMethod("registerScreenRecordingCallback", iScreenRecordingCallbackClazz);
|
||||
hook(method, ReturnFalseHooker.class);
|
||||
}
|
||||
|
||||
private void hookActivityManagerService(ClassLoader classLoader) throws ClassNotFoundException, NoSuchMethodException {
|
||||
var activityTaskManagerServiceClazz = classLoader.loadClass("com.android.server.am.ActivityManagerService");
|
||||
var method = activityTaskManagerServiceClazz.getDeclaredMethod("checkPermission", String.class, int.class, int.class);
|
||||
hook(method, CheckPermissionHooker.class);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
|
||||
@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
|
||||
private void hookHyperOS(ClassLoader classLoader) throws ClassNotFoundException {
|
||||
var windowManagerServiceImplClazz = classLoader.loadClass("com.android.server.wm.WindowManagerServiceImpl");
|
||||
hookMethods(windowManagerServiceImplClazz, ReturnFalseHooker.class, "notAllowCaptureDisplay");
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.S)
|
||||
private void hookScreenshotHardwareBuffer(ClassLoader classLoader) throws ClassNotFoundException, NoSuchMethodException {
|
||||
var screenshotHardwareBufferClazz = classLoader.loadClass(
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE ?
|
||||
@ -289,17 +297,19 @@ public class DisableFlagSecure extends XposedModule {
|
||||
hook(method, ReturnFalseHooker.class);
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.VANILLA_ICE_CREAM)
|
||||
private void hookOplusScreenCapture(ClassLoader classLoader) throws ClassNotFoundException, NoSuchMethodException {
|
||||
var oplusScreenCaptureClazz = classLoader.loadClass("com.oplus.screenshot.OplusScreenCapture$CaptureArgs$Builder");
|
||||
var method = oplusScreenCaptureClazz.getDeclaredMethod("setUid", long.class);
|
||||
hook(method, OplusScreenCaptureHooker.class);
|
||||
}
|
||||
|
||||
private void hookOplus(ClassLoader classLoader) throws ClassNotFoundException {
|
||||
var screenshotContextClazz = classLoader.loadClass("com.oplus.screenshot.screenshot.core.ScreenshotContext");
|
||||
hookMethods(screenshotContextClazz, ReturnNullHooker.class, "setScreenshotReject", "setLongshotReject");
|
||||
// caller: com.android.server.wm.OplusLongshotWindowDump#dumpWindows
|
||||
var longshotMainClazz = classLoader.loadClass("com.android.server.wm.OplusLongshotMainWindow");
|
||||
hookMethods(longshotMainClazz, ReturnFalseHooker.class, "hasSecure");
|
||||
}
|
||||
|
||||
private void hookOplusNew(ClassLoader classLoader) throws ClassNotFoundException {
|
||||
var screenshotContextClazz = classLoader.loadClass("com.oplus.screenshot.screenshot.core.ScreenshotContentContext");
|
||||
hookMethods(screenshotContextClazz, ReturnNullHooker.class, "setScreenshotReject", "setLongshotReject");
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.S)
|
||||
private void hookOneUI(ClassLoader classLoader) throws ClassNotFoundException {
|
||||
var wmScreenshotControllerClazz = classLoader.loadClass("com.android.server.wm.WmScreenshotController");
|
||||
hookMethods(wmScreenshotControllerClazz, ReturnTrueHooker.class, "canBeScreenshotTarget");
|
||||
@ -323,11 +333,14 @@ public class DisableFlagSecure extends XposedModule {
|
||||
@BeforeInvocation
|
||||
public static void before(@NonNull BeforeHookCallback callback) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||
String stack = Log.getStackTraceString(new Throwable());
|
||||
if (stack.contains("createVirtualDisplayLocked")) {
|
||||
var stackTrace = new Throwable().getStackTrace();
|
||||
for (int i = 4; i < stackTrace.length && i < 8; i++) {
|
||||
var name = stackTrace[i].getMethodName();
|
||||
if (name.equals("createVirtualDisplayLocked")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
callback.getArgs()[1] = true;
|
||||
}
|
||||
}
|
||||
@ -344,6 +357,15 @@ public class DisableFlagSecure extends XposedModule {
|
||||
}
|
||||
}
|
||||
|
||||
@XposedHooker
|
||||
private static class OplusScreenCaptureHooker implements Hooker {
|
||||
|
||||
@BeforeInvocation
|
||||
public static void before(@NonNull BeforeHookCallback callback) {
|
||||
callback.getArgs()[0] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@XposedHooker
|
||||
private static class ScreenCaptureHooker implements Hooker {
|
||||
|
||||
@ -352,7 +374,6 @@ public class DisableFlagSecure extends XposedModule {
|
||||
var captureArgs = callback.getArgs()[0];
|
||||
try {
|
||||
captureSecureLayersField.set(captureArgs, true);
|
||||
allowProtectedField.set(captureArgs, true);
|
||||
} catch (IllegalAccessException t) {
|
||||
module.log("ScreenCaptureHooker failed", t);
|
||||
}
|
||||
@ -365,7 +386,7 @@ public class DisableFlagSecure extends XposedModule {
|
||||
@BeforeInvocation
|
||||
public static void before(@NonNull BeforeHookCallback callback) {
|
||||
var caller = (int) callback.getArgs()[2];
|
||||
if (caller != 1000 && callback.getArgs()[1] == null) {
|
||||
if (caller >= 10000 && callback.getArgs()[1] == null) {
|
||||
// not os and not media projection
|
||||
return;
|
||||
}
|
||||
@ -387,14 +408,24 @@ public class DisableFlagSecure extends XposedModule {
|
||||
|
||||
@BeforeInvocation
|
||||
public static void before(@NonNull BeforeHookCallback callback) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
String stack = Log.getStackTraceString(new Throwable());
|
||||
// don't change surface flags, but passing other checks
|
||||
if (stack.contains("setInitialSurfaceControlProperties")
|
||||
|| stack.contains("createSurfaceLocked")) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||
var walker = StackWalker.getInstance();
|
||||
var match = walker.walk(frames -> frames
|
||||
.map(StackWalker.StackFrame::getMethodName)
|
||||
.limit(6)
|
||||
.skip(2)
|
||||
.anyMatch(s -> s.equals("setInitialSurfaceControlProperties") || s.equals("createSurfaceLocked")));
|
||||
if (match) return;
|
||||
} else {
|
||||
var stackTrace = new Throwable().getStackTrace();
|
||||
for (int i = 4; i < stackTrace.length && i < 8; i++) {
|
||||
var name = stackTrace[i].getMethodName();
|
||||
if (name.equals("setInitialSurfaceControlProperties") ||
|
||||
name.equals("createSurfaceLocked")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
callback.returnAndSkip(false);
|
||||
}
|
||||
}
|
||||
@ -428,9 +459,12 @@ public class DisableFlagSecure extends XposedModule {
|
||||
@BeforeInvocation
|
||||
public static void before(@NonNull BeforeHookCallback callback) {
|
||||
var activity = (Activity) callback.getThisObject();
|
||||
assert activity != null;
|
||||
Toast.makeText(activity, "DFS: Incorrect module usage, remove this app from scope.", Toast.LENGTH_LONG).show();
|
||||
activity.finish();
|
||||
new AlertDialog.Builder(activity)
|
||||
.setTitle("Enable Screenshot")
|
||||
.setMessage("Incorrect module usage, remove this app from scope.")
|
||||
.setCancelable(false)
|
||||
.setPositiveButton("OK", (dialog, which) -> System.exit(0))
|
||||
.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
3
app/src/main/res/values-v35/strings.xml
Normal file
3
app/src/main/res/values-v35/strings.xml
Normal file
@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="xposed_description">Enabling screenshots in apps that normally wouldn\'t allow it and disabling screenshot & screen record detection.</string>
|
||||
</resources>
|
4
app/src/main/res/values-zh-rCN-v35/strings.xml
Normal file
4
app/src/main/res/values-zh-rCN-v35/strings.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="xposed_description">在通常不允许截图的应用中启用屏幕截图并禁用截图与录屏检测。</string>
|
||||
</resources>
|
@ -1,6 +1,6 @@
|
||||
system
|
||||
com.android.systemui
|
||||
com.flyme.systemuiex
|
||||
com.oplus.screenshot
|
||||
com.miui.screenshot
|
||||
com.oplus.appplatform
|
||||
com.oplus.screenshot
|
||||
|
@ -1,10 +1,10 @@
|
||||
plugins {
|
||||
id 'com.android.application' version '8.4.1' apply false
|
||||
id 'com.android.application' version '8.9.1' apply false
|
||||
id 'org.lsposed.lsplugin.jgit' version "1.1"
|
||||
}
|
||||
|
||||
tasks.register('clean', Delete) {
|
||||
delete rootProject.buildDir
|
||||
delete rootProject.layout.buildDirectory
|
||||
}
|
||||
|
||||
var repo = jgit.repo(true)
|
||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
8
gradlew
vendored
8
gradlew
vendored
@ -15,6 +15,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@ -55,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@ -84,7 +86,7 @@ done
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@ -203,7 +205,7 @@ fi
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
2
gradlew.bat
vendored
2
gradlew.bat
vendored
@ -13,6 +13,8 @@
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
|
1
libxposed-compat/.gitignore
vendored
Normal file
1
libxposed-compat/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/build
|
18
libxposed-compat/build.gradle
Normal file
18
libxposed-compat/build.gradle
Normal file
@ -0,0 +1,18 @@
|
||||
plugins {
|
||||
id 'com.android.library'
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'io.github.libxposed'
|
||||
compileSdk 35
|
||||
|
||||
defaultConfig {
|
||||
minSdk 24
|
||||
targetSdk 35
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_21
|
||||
targetCompatibility JavaVersion.VERSION_21
|
||||
}
|
||||
}
|
3
libxposed-compat/src/main/AndroidManifest.xml
Normal file
3
libxposed-compat/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest>
|
||||
</manifest>
|
@ -0,0 +1,11 @@
|
||||
package io.github.libxposed.api.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface AfterInvocation {
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package io.github.libxposed.api.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface BeforeInvocation {
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package io.github.libxposed.api.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE, ElementType.TYPE_USE})
|
||||
public @interface XposedHooker {
|
||||
}
|
@ -19,3 +19,4 @@ dependencyResolutionManagement {
|
||||
}
|
||||
rootProject.name = "DisableFlagSecure"
|
||||
include ':app'
|
||||
include ':libxposed-compat'
|
||||
|
Loading…
x
Reference in New Issue
Block a user