mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-26 01:36:55 +00:00
Added screen recording detection
This commit is contained in:
parent
6bbc0d033d
commit
3209e034c5
5 changed files with 38 additions and 0 deletions
|
@ -17,6 +17,7 @@
|
|||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
|
||||
<uses-permission android:name="android.permission.DETECT_SCREEN_RECORDING" />
|
||||
<uses-permission android:name="android.permission.TURN_SCREEN_ON" />
|
||||
<uses-permission android:name="android.permission.READ_CALENDAR" />
|
||||
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
|
||||
<uses-permission android:name="android.permission.DETECT_SCREEN_RECORDING" />
|
||||
<uses-permission android:name="android.permission.READ_CALENDAR" />
|
||||
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
|
||||
<uses-permission android:name="android.permission.DETECT_SCREEN_RECORDING" />
|
||||
<uses-permission android:name="android.permission.READ_CALENDAR" />
|
||||
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import static androidx.drawerlayout.widget.DrawerLayout.LOCK_MODE_LOCKED_OPEN;
|
|||
import static androidx.drawerlayout.widget.DrawerLayout.LOCK_MODE_UNLOCKED;
|
||||
import static androidx.recyclerview.widget.RecyclerView.NO_POSITION;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
|
@ -39,6 +40,7 @@ import android.graphics.Color;
|
|||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextUtils;
|
||||
|
@ -49,6 +51,7 @@ import android.view.Menu;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
@ -1165,11 +1168,33 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
setIntent(intent);
|
||||
}
|
||||
|
||||
private final java.util.function.Consumer<Integer> recordingCallback = new java.util.function.Consumer<Integer>() {
|
||||
@Override
|
||||
public void accept(Integer state) {
|
||||
if (state == WindowManager.SCREEN_RECORDING_STATE_VISIBLE)
|
||||
getMainHandler().post(new RunnableEx("screenrecording") {
|
||||
@Override
|
||||
public void delegate() {
|
||||
ToastEx.makeText(ActivityView.this, R.string.title_screen_recording, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
if (!Helper.isPlayStoreInstall())
|
||||
infoTracker.addWindowLayoutInfoListener(this, Runnable::run, layoutStateChangeCallback);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM &&
|
||||
hasPermission(Manifest.permission.DETECT_SCREEN_RECORDING))
|
||||
try {
|
||||
WindowManager wm = Helper.getSystemService(this, WindowManager.class);
|
||||
wm.addScreenRecordingCallback(Helper.getUIExecutor(), recordingCallback);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1177,6 +1202,15 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
super.onStop();
|
||||
if (!Helper.isPlayStoreInstall())
|
||||
infoTracker.removeWindowLayoutInfoListener(layoutStateChangeCallback);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM &&
|
||||
hasPermission(Manifest.permission.DETECT_SCREEN_RECORDING))
|
||||
try {
|
||||
WindowManager wm = Helper.getSystemService(this, WindowManager.class);
|
||||
wm.removeScreenRecordingCallback(recordingCallback);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1654,6 +1654,7 @@
|
|||
<string name="title_too_large">Message too large to completely reformat</string>
|
||||
<string name="title_truncated">Message too large to display completely</string>
|
||||
<string name="title_insufficient_memory">Message too large for the available memory (%1$d)</string>
|
||||
<string name="title_screen_recording">The screen is being recorded!</string>
|
||||
<string name="title_show_full">Show full message</string>
|
||||
<string name="title_fullscreen">Show fullscreen</string>
|
||||
<string name="title_fit_width">Fit width</string>
|
||||
|
|
Loading…
Reference in a new issue