fix: Remove update checker, INSTALL_PACKAGES, and SYSTEM_ALERT_WINDOW permissions to clear Play Protect flags
This commit is contained in:
1 parent
e1a91a335b
commit
314b3f99c6
5 files changed
+4
-104
No files matched your search
@@ -2,8 +2,6 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
|
||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.hardware.touchscreen"
|
android:name="android.hardware.touchscreen"
|
||||||
android:required="false" />
|
android:required="false" />
|
||||||
@@ -96,15 +94,6 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<provider
|
|
||||||
android:name="androidx.core.content.FileProvider"
|
|
||||||
android:authorities="${applicationId}.fileprovider"
|
|
||||||
android:exported="false"
|
|
||||||
android:grantUriPermissions="true">
|
|
||||||
<meta-data
|
|
||||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
|
||||||
android:resource="@xml/file_paths" />
|
|
||||||
</provider>
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -36,7 +36,6 @@ public class MainActivity extends AppCompatActivity implements ImageView.OnClick
|
|||||||
ImageView.OnFocusChangeListener {
|
ImageView.OnFocusChangeListener {
|
||||||
public static final int REQUEST_MEDIA_PROJECTION = 1;
|
public static final int REQUEST_MEDIA_PROJECTION = 1;
|
||||||
private static final int REQUEST_NOTIFICATION_PERMISSION = 2;
|
private static final int REQUEST_NOTIFICATION_PERMISSION = 2;
|
||||||
private static final int REQUEST_OVERLAY_PERMISSION = 3;
|
|
||||||
private static final String TAG = "DEBUG";
|
private static final String TAG = "DEBUG";
|
||||||
private boolean mRecorderRunning = false;
|
private boolean mRecorderRunning = false;
|
||||||
private static MediaProjectionManager mMediaProjectionManager;
|
private static MediaProjectionManager mMediaProjectionManager;
|
||||||
@@ -66,8 +65,7 @@ public class MainActivity extends AppCompatActivity implements ImageView.OnClick
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
// Check for updates
|
// Remove update check logic
|
||||||
checkForUpdates();
|
|
||||||
mMediaProjectionManager = (MediaProjectionManager)
|
mMediaProjectionManager = (MediaProjectionManager)
|
||||||
getSystemService(Context.MEDIA_PROJECTION_SERVICE);
|
getSystemService(Context.MEDIA_PROJECTION_SERVICE);
|
||||||
|
|
||||||
@@ -100,8 +98,6 @@ public class MainActivity extends AppCompatActivity implements ImageView.OnClick
|
|||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
// Check for updates when app returns to foreground
|
|
||||||
checkForUpdates();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void requestNotificationPermission() {
|
private void requestNotificationPermission() {
|
||||||
@@ -118,9 +114,6 @@ public class MainActivity extends AppCompatActivity implements ImageView.OnClick
|
|||||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
// Check for updates when user clicks play
|
|
||||||
checkForUpdates();
|
|
||||||
|
|
||||||
if (!mRecorderRunning) {
|
if (!mRecorderRunning) {
|
||||||
requestScreenCapture();
|
requestScreenCapture();
|
||||||
} else {
|
} else {
|
||||||
@@ -130,13 +123,6 @@ public class MainActivity extends AppCompatActivity implements ImageView.OnClick
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void requestScreenCapture() {
|
private void requestScreenCapture() {
|
||||||
// Check overlay permission on first attempt
|
|
||||||
if (mPermissionDeniedCount == 0 && !PermissionHelper.canDrawOverlays(this)) {
|
|
||||||
Log.d(TAG, "Requesting overlay permission first");
|
|
||||||
PermissionHelper.requestOverlayPermission(this, REQUEST_OVERLAY_PERMISSION);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Intent captureIntent = mMediaProjectionManager.createScreenCaptureIntent();
|
Intent captureIntent = mMediaProjectionManager.createScreenCaptureIntent();
|
||||||
startActivityForResult(captureIntent, REQUEST_MEDIA_PROJECTION);
|
startActivityForResult(captureIntent, REQUEST_MEDIA_PROJECTION);
|
||||||
@@ -182,10 +168,6 @@ public class MainActivity extends AppCompatActivity implements ImageView.OnClick
|
|||||||
startScreenRecorder(resultCode, (Intent) data.clone());
|
startScreenRecorder(resultCode, (Intent) data.clone());
|
||||||
mRecorderRunning = true;
|
mRecorderRunning = true;
|
||||||
}
|
}
|
||||||
if (requestCode == REQUEST_OVERLAY_PERMISSION) {
|
|
||||||
// Small delay before requesting capture - helps on some devices
|
|
||||||
getWindow().getDecorView().postDelayed(this::requestScreenCapture, 500);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -260,42 +242,6 @@ public class MainActivity extends AppCompatActivity implements ImageView.OnClick
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForUpdates() {
|
|
||||||
new Thread(() -> {
|
|
||||||
try {
|
|
||||||
Log.d(TAG, "Checking for updates...");
|
|
||||||
|
|
||||||
com.hyperion.grabber.common.util.UpdateChecker checker =
|
|
||||||
new com.hyperion.grabber.common.util.UpdateChecker(this);
|
|
||||||
com.hyperion.grabber.common.util.GithubRelease release = checker.checkForUpdates();
|
|
||||||
|
|
||||||
if (release != null) {
|
|
||||||
Log.d(TAG, "Update found: " + release.getTagName());
|
|
||||||
runOnUiThread(() -> showUpdateDialog(release));
|
|
||||||
} else {
|
|
||||||
Log.d(TAG, "No updates available");
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "Error checking for updates", e);
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showUpdateDialog(com.hyperion.grabber.common.util.GithubRelease release) {
|
|
||||||
UpdateDialog dialog = new UpdateDialog(this);
|
|
||||||
dialog.show(release,
|
|
||||||
() -> {
|
|
||||||
com.hyperion.grabber.common.util.UpdateManager manager =
|
|
||||||
new com.hyperion.grabber.common.util.UpdateManager(getApplicationContext());
|
|
||||||
manager.downloadAndInstall(release.getDownloadUrl(), release.getTagName(), success -> {
|
|
||||||
return kotlin.Unit.INSTANCE;
|
|
||||||
});
|
|
||||||
return kotlin.Unit.INSTANCE;
|
|
||||||
},
|
|
||||||
() -> kotlin.Unit.INSTANCE
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isServiceRunning() {
|
private boolean isServiceRunning() {
|
||||||
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
|
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
assert manager != null;
|
assert manager != null;
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<paths>
|
|
||||||
<external-path name="downloads" path="Download/" />
|
|
||||||
<external-files-path name="external_files" path="." />
|
|
||||||
<cache-path name="cache" path="." />
|
|
||||||
</paths>
|
|
||||||
@@ -5,11 +5,9 @@
|
|||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
|
||||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
|
||||||
|
|||||||
@@ -18,26 +18,6 @@ import java.io.InputStreamReader;
|
|||||||
public class PermissionHelper {
|
public class PermissionHelper {
|
||||||
private static final String TAG = "PermissionHelper";
|
private static final String TAG = "PermissionHelper";
|
||||||
|
|
||||||
public static boolean canDrawOverlays(Context context) {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
return Settings.canDrawOverlays(context);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void requestOverlayPermission(Activity activity, int requestCode) {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(activity)) {
|
|
||||||
try {
|
|
||||||
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
|
||||||
Uri.parse("package:" + activity.getPackageName()));
|
|
||||||
activity.startActivityForResult(intent, requestCode);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "Cannot request overlay permission", e);
|
|
||||||
openAppSettings(activity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isIgnoringBatteryOptimizations(Context context) {
|
public static boolean isIgnoringBatteryOptimizations(Context context) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||||
@@ -90,26 +70,19 @@ public class PermissionHelper {
|
|||||||
String message = "Screen recording permission could not be obtained.\n\n" +
|
String message = "Screen recording permission could not be obtained.\n\n" +
|
||||||
"Your TV may be blocking the permission dialog.\n\n" +
|
"Your TV may be blocking the permission dialog.\n\n" +
|
||||||
"SOLUTIONS:\n\n" +
|
"SOLUTIONS:\n\n" +
|
||||||
"1. OVERLAY PERMISSION:\n" +
|
"1. APP PERMISSIONS:\n" +
|
||||||
" Settings > Apps > Special access > Display over other apps\n\n" +
|
|
||||||
"2. APP PERMISSIONS:\n" +
|
|
||||||
" Settings > Apps > Hyperion Grabber > Permissions\n\n" +
|
" Settings > Apps > Hyperion Grabber > Permissions\n\n" +
|
||||||
"3. AUTO-START (TCL/Smart TVs):\n" +
|
"2. AUTO-START (TCL/Smart TVs):\n" +
|
||||||
" Settings > Privacy > Special app access > Auto-start\n" +
|
" Settings > Privacy > Special app access > Auto-start\n" +
|
||||||
" OR Settings > Apps > App management\n\n" +
|
" OR Settings > Apps > App management\n\n" +
|
||||||
"4. BATTERY OPTIMIZATION:\n" +
|
"3. BATTERY OPTIMIZATION:\n" +
|
||||||
" Settings > Apps > Special access > Battery optimization\n\n" +
|
" Settings > Apps > Special access > Battery optimization\n\n" +
|
||||||
"5. ADB COMMAND (requires computer):\n" +
|
|
||||||
" adb shell appops set " + activity.getPackageName() + " PROJECT_MEDIA allow\n\n" +
|
|
||||||
deviceInfo;
|
deviceInfo;
|
||||||
|
|
||||||
new AlertDialog.Builder(activity)
|
new AlertDialog.Builder(activity)
|
||||||
.setTitle("Permission Required")
|
.setTitle("Permission Required")
|
||||||
.setMessage(message)
|
.setMessage(message)
|
||||||
.setPositiveButton("Open App Settings", (d, w) -> openAppSettings(activity))
|
.setPositiveButton("Open App Settings", (d, w) -> openAppSettings(activity))
|
||||||
.setNeutralButton("Try Overlay", (d, w) -> {
|
|
||||||
requestOverlayPermission(activity, 999);
|
|
||||||
})
|
|
||||||
.setNegativeButton("Retry", (d, w) -> {
|
.setNegativeButton("Retry", (d, w) -> {
|
||||||
if (onRetry != null) {
|
if (onRetry != null) {
|
||||||
activity.getWindow().getDecorView().postDelayed(() -> {
|
activity.getWindow().getDecorView().postDelayed(() -> {
|
||||||
|
|||||||
Reference in new issue
Block a user