Compare commits

...

57 Commits
v4.0.0 ... main

Author SHA1 Message Date
tehcneko
b64046f57c update compile sdk to 36 2025-04-05 12:57:11 +08:00
tehcneko
bc17c4c9bb update ci to jdk 21 2025-04-05 12:57:11 +08:00
tehcneko
401f196e2e check caller method with stack walker 2025-04-05 12:57:11 +08:00
tehcneko
bf5cdb513d replace @TargetApi with @RequireApi 2025-04-05 12:57:11 +08:00
tehcneko
f11e16da7d update AGP 2025-04-05 12:57:11 +08:00
tehcneko
de591e925e
fix issue template 2025-04-05 12:49:42 +08:00
tehcneko
4b426733ca bump version 2025-03-04 19:49:27 +08:00
tehcneko
a5461af177 support scrcpy 2025-03-04 19:48:49 +08:00
tehcneko
aa56f32b6a update issue template 2025-03-04 19:35:08 +08:00
tehcneko
cf19309b6b add support info to README 2025-03-04 19:30:47 +08:00
tehcneko
cd14a26f54 remove support for Android 11- 2025-03-04 19:10:58 +08:00
tehcneko
20c7f4c30d update gradle 2025-03-04 18:55:48 +08:00
tehcneko
624a493311 update gradle 2025-01-12 11:56:00 +08:00
Wang Han
a5e8659290
Bump version 2024-12-02 11:00:19 +08:00
Wang Han
375469dd23
Hook OplusScreenCapture#setUid on Oplus A15 (#75)
Or surfaceflinger will silently reject screen capture after checking uid.
2024-11-30 21:09:03 +08:00
dependabot[bot]
2baedef66f
Bump com.android.application from 8.6.1 to 8.7.2 (#72) 2024-11-30 16:53:10 +08:00
dependabot[bot]
469d58c95f
Bump androidx.annotation:annotation from 1.8.2 to 1.9.1 (#71) 2024-11-30 16:49:55 +08:00
tehcneko
e0203a480f update gradle 2024-09-29 21:08:34 +08:00
dependabot[bot]
197f971cbb
Bump com.android.application from 8.5.2 to 8.6.0 (#62) 2024-08-30 08:57:44 +08:00
tehcneko
9fbc536136 fix SOURCE_URL 2024-08-19 18:04:32 +08:00
tehcneko
610af286b7 fix typo 2024-08-19 17:55:50 +08:00
tehcneko
8ba19d5779 mention screen record detection removal 2024-08-19 17:54:22 +08:00
tehcneko
f166d733f0 bump version 2024-08-19 17:51:43 +08:00
tehcneko
5ddd76fe39 bump min sdk 2024-08-19 17:51:29 +08:00
tehcneko
c991e3dac1 Add test activity 2024-08-18 14:17:15 +08:00
tehcneko
42ae2ab20d Disable screen record detection on Android 15 2024-08-18 14:17:15 +08:00
tehcneko
caa953cd11 Support Android 15 Beta 4 2024-08-18 14:17:15 +08:00
dependabot[bot]
4a811dd16a
Bump com.android.application from 8.5.1 to 8.5.2 (#58) 2024-08-10 09:29:32 +08:00
dependabot[bot]
bdea05344b
Bump androidx.annotation:annotation from 1.8.1 to 1.8.2 (#57) 2024-08-09 15:06:42 +08:00
tehcneko
fd0b56f651 update compile sdk 2024-07-29 11:18:42 +08:00
tehcneko
92c067bb15 fix annotations 2024-07-29 11:17:24 +08:00
dependabot[bot]
5f342219df Bump androidx.annotation:annotation from 1.8.0 to 1.8.1
Bumps androidx.annotation:annotation from 1.8.0 to 1.8.1.

---
updated-dependencies:
- dependency-name: androidx.annotation:annotation
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-29 10:54:14 +08:00
tehcneko
52e281a380 bump version 2024-07-29 10:48:43 +08:00
tehcneko
9343df3060 update gradle 2024-07-29 10:44:55 +08:00
tehcneko
b222af63b4 update libxposed 2024-07-29 10:42:15 +08:00
tehcneko
3525dd69a8 Create SOURCE 2024-07-29 10:36:24 +08:00
tehcneko
3b2efdea96 Delete useless template 2024-07-29 10:36:24 +08:00
dependabot[bot]
dab601582f Bump com.android.application from 8.5.0 to 8.5.1
Bumps com.android.application from 8.5.0 to 8.5.1.

---
updated-dependencies:
- dependency-name: com.android.application
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-21 16:12:39 +08:00
tehcneko
ac95d737da Merge source code 2024-07-21 16:11:31 +08:00
5ec1cff
3481cbbfac fix oplus in system server 2024-06-23 10:08:24 +08:00
tehcneko
201040ed64
Delete SOURCE_URL 2024-06-17 20:01:27 +08:00
tehcneko
aee7d86bb3 bump version 2024-06-17 19:21:48 +08:00
tehcneko
5fddba5a28 don't alter allowProtected 2024-06-17 17:57:57 +08:00
tehcneko
c5f1300bad replace toast with dialog 2024-06-17 17:57:57 +08:00
dependabot[bot]
8fa24bf735
Bump com.android.application from 8.4.2 to 8.5.0 (#50) 2024-06-14 08:28:29 +08:00
dependabot[bot]
7df5373528
Bump com.android.application from 8.4.1 to 8.4.2 (#49) 2024-06-11 05:49:31 +08:00
tehcneko
df2f067432 Add issue template 2024-05-30 20:09:48 +08:00
tehcneko
ad2a9422b0
Update SUMMARY 2024-05-29 09:56:19 +08:00
tehcneko
d4c648c0d6
Update README.md 2024-05-29 09:55:15 +08:00
tehcneko
e6bc968ab6
Update README.md 2024-01-17 19:28:34 +08:00
tehcneko
e4445075b3
Update SUMMARY 2024-01-17 19:28:16 +08:00
tehcneko
6c8ecc6091
Update SUMMARY 2024-01-17 19:27:59 +08:00
tehcneko
29da41af0f
Update SUMMARY 2021-02-20 12:21:16 +08:00
tehcneko
b66d2549d5
Create SOURCE_URL 2021-02-19 23:42:51 +08:00
tehcneko
8825a0fabe Update README 2021-02-19 22:37:51 +08:00
LoveSy
65d04b4c65
Create SUMMARY 2021-02-12 01:53:26 +08:00
LoveSy
8fa792e7a9
Initial commit 2021-02-03 16:45:25 +08:00
26 changed files with 332 additions and 127 deletions

View File

@ -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

View File

@ -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

View File

@ -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
View File

@ -0,0 +1 @@
https://github.com/LSPosed/DisableFlagSecure

1
SUMMARY Normal file
View File

@ -0,0 +1 @@
Enabling screenshots in apps that normally wouldn't allow it, and disabling screenshot(Android 14+) & screen record(Android 15+) detection.

View File

@ -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")
}

View File

@ -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

View 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>

View File

@ -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) {
}
}

View File

@ -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,63 +72,69 @@ public class DisableFlagSecure extends XposedModule {
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
// ScreenCapture in WindowManagerService (S~U)
try {
hookScreenCapture(classLoader);
} catch (Throwable t) {
log("hook ScreenCapture failed", t);
}
// ScreenCapture in WindowManagerService (S~Baklava)
try {
hookScreenCapture(classLoader);
} catch (Throwable t) {
log("hook ScreenCapture failed", t);
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
// Blackout permission check (S~T)
try {
hookActivityManagerService(classLoader);
} catch (Throwable t) {
log("hook ActivityManagerService failed", t);
}
}
// WifiDisplay (S~U) / OverlayDisplay (S~U) / VirtualDisplay (U)
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
// Blackout permission check (S~T)
try {
hookDisplayControl(classLoader);
hookActivityManagerService(classLoader);
} catch (Throwable t) {
log("hook DisplayControl failed", t);
}
// VirtualDisplay with MediaProjection (S~U)
try {
hookVirtualDisplayAdapter(classLoader);
} catch (Throwable t) {
log("hook VirtualDisplayAdapter failed", t);
log("hook ActivityManagerService failed", t);
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
// OneUI
try {
hookScreenshotHardwareBuffer(classLoader);
} catch (Throwable t) {
if (!(t instanceof ClassNotFoundException)) {
log("hook ScreenshotHardwareBuffer failed", t);
}
// WifiDisplay (S~Baklava) / OverlayDisplay (S~Baklava) / VirtualDisplay (U~Baklava)
try {
hookDisplayControl(classLoader);
} catch (Throwable t) {
log("hook DisplayControl failed", t);
}
// VirtualDisplay with MediaProjection (S~Baklava)
try {
hookVirtualDisplayAdapter(classLoader);
} catch (Throwable t) {
log("hook VirtualDisplayAdapter failed", t);
}
// OneUI
try {
hookScreenshotHardwareBuffer(classLoader);
} catch (Throwable t) {
if (!(t instanceof ClassNotFoundException)) {
log("hook ScreenshotHardwareBuffer failed", t);
}
try {
hookOneUI(classLoader);
} catch (Throwable t) {
if (!(t instanceof ClassNotFoundException)) {
log("hook OneUI failed", t);
}
}
try {
hookOneUI(classLoader);
} catch (Throwable t) {
if (!(t instanceof ClassNotFoundException)) {
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:
try {
hookOplus(classLoader);
} catch (Throwable t) {
log("hook OPlus failed", t);
}
try {
hookOplusNew(classLoader);
} catch (Throwable t) {
if (!(t instanceof ClassNotFoundException)) {
log("hook OPlus failed", t);
// Oplus Screenshot 15.0.0
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
try {
hookOplusScreenCapture(classLoader);
} catch (Throwable t) {
if (!(t instanceof ClassNotFoundException)) {
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,9 +333,12 @@ 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")) {
return;
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,12 +408,22 @@ 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")) {
return;
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();
}
}
}

View File

@ -0,0 +1,3 @@
<resources>
<string name="xposed_description">Enabling screenshots in apps that normally wouldn\'t allow it and disabling screenshot &amp; screen record detection.</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="xposed_description">在通常不允许截图的应用中启用屏幕截图并禁用截图与录屏检测。</string>
</resources>

View File

@ -1,6 +1,6 @@
system
com.android.systemui
com.flyme.systemuiex
com.oplus.screenshot
com.miui.screenshot
com.oplus.appplatform
com.oplus.screenshot

View File

@ -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)

Binary file not shown.

View File

@ -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
View File

@ -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
View File

@ -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
View File

@ -0,0 +1 @@
/build

View 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
}
}

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest>
</manifest>

View File

@ -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 {
}

View File

@ -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 {
}

View File

@ -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 {
}

View File

@ -19,3 +19,4 @@ dependencyResolutionManagement {
}
rootProject.name = "DisableFlagSecure"
include ':app'
include ':libxposed-compat'