diff --git a/README.md b/README.md
index d87e2c9..dde7559 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-
+
# Hyperion Android Reborn
@@ -10,6 +10,15 @@ This application will send the content of the android screen to a hyperion insta
Info about hyperion can be found on their website:
https://hyperion-project.org/
+
+---
+
+# Important information for TCL tvs.
+For TCL televisions, the TCL watchdog will cause the app to close in the background, please run these steps to stop this from happening.
+Go to Settings > Apps > Hyperion Grabber
+Enable "Auto-start" or "Allow background activity" permission
+Some TCL TVs have this in Settings > Privacy > Special app access > Auto-start
+
---
# Download
diff --git a/app/src/main/java/com/hyperion/grabber/MainActivity.java b/app/src/main/java/com/hyperion/grabber/MainActivity.java
index ba05ee4..e97fa36 100755
--- a/app/src/main/java/com/hyperion/grabber/MainActivity.java
+++ b/app/src/main/java/com/hyperion/grabber/MainActivity.java
@@ -31,7 +31,6 @@ import android.widget.Toast;
import com.hyperion.grabber.common.BootActivity;
import com.hyperion.grabber.common.HyperionScreenService;
import com.hyperion.grabber.common.util.PermissionHelper;
-import com.hyperion.grabber.common.util.TclBypass;
public class MainActivity extends AppCompatActivity implements ImageView.OnClickListener,
ImageView.OnFocusChangeListener {
@@ -44,7 +43,6 @@ public class MainActivity extends AppCompatActivity implements ImageView.OnClick
private Intent mPendingProjectionData = null;
private int mPendingResultCode = 0;
private int mPermissionDeniedCount = 0;
- private boolean mTclWarningShown = false;
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
@@ -52,12 +50,8 @@ public class MainActivity extends AppCompatActivity implements ImageView.OnClick
boolean checked = intent.getBooleanExtra(HyperionScreenService.BROADCAST_TAG, false);
mRecorderRunning = checked;
String error = intent.getStringExtra(HyperionScreenService.BROADCAST_ERROR);
- boolean tclBlocked = intent.getBooleanExtra(HyperionScreenService.BROADCAST_TCL_BLOCKED, false);
- if (tclBlocked && !mTclWarningShown) {
- mTclWarningShown = true;
- TclBypass.showTclHelpDialog(MainActivity.this, () -> requestScreenCapture());
- } else if (error != null &&
+ if (error != null &&
(Build.VERSION.SDK_INT < Build.VERSION_CODES.N ||
!HyperionGrabberTileService.isListening())) {
Toast.makeText(getBaseContext(), error, Toast.LENGTH_LONG).show();
@@ -136,12 +130,6 @@ public class MainActivity extends AppCompatActivity implements ImageView.OnClick
}
private void requestScreenCapture() {
- // On TCL and other restricted devices, try shell bypass first
- if (TclBypass.isTclDevice() || TclBypass.isRestrictedManufacturer()) {
- Log.d(TAG, "Detected TCL/restricted device, trying shell bypass");
- TclBypass.tryShellBypass(this);
- }
-
// Also try general shell permissions
PermissionHelper.tryGrantProjectMediaViaShell(this);
@@ -158,11 +146,7 @@ public class MainActivity extends AppCompatActivity implements ImageView.OnClick
} catch (SecurityException e) {
Log.e(TAG, "Screen capture permission denied: " + e.getMessage());
mPermissionDeniedCount++;
- if (TclBypass.isTclDevice()) {
- TclBypass.showTclHelpDialog(this, this::requestScreenCapture);
- } else {
- PermissionHelper.showFullPermissionDialog(this, this::requestScreenCapture);
- }
+ PermissionHelper.showFullPermissionDialog(this, this::requestScreenCapture);
setImageViews(false, true);
} catch (Exception e) {
Log.e(TAG, "Failed to request screen capture: " + e.getMessage());
@@ -189,11 +173,7 @@ public class MainActivity extends AppCompatActivity implements ImageView.OnClick
mPermissionDeniedCount++;
mRecorderRunning = false;
if (mPermissionDeniedCount >= 2) {
- if (TclBypass.isTclDevice()) {
- TclBypass.showTclHelpDialog(this, this::requestScreenCapture);
- } else {
- PermissionHelper.showFullPermissionDialog(this, this::requestScreenCapture);
- }
+ PermissionHelper.showFullPermissionDialog(this, this::requestScreenCapture);
} else {
Toast.makeText(this, "Screen recording permission was denied. Tap again to retry.", Toast.LENGTH_LONG).show();
}
@@ -201,7 +181,6 @@ public class MainActivity extends AppCompatActivity implements ImageView.OnClick
return;
}
mPermissionDeniedCount = 0;
- mTclWarningShown = false;
Log.i(TAG, "Starting screen capture");
startScreenRecorder(resultCode, (Intent) data.clone());
mRecorderRunning = true;
diff --git a/app/src/main/java/com/hyperion/grabber/tv/activities/MainActivity.java b/app/src/main/java/com/hyperion/grabber/tv/activities/MainActivity.java
index a405ebf..fecabbb 100644
--- a/app/src/main/java/com/hyperion/grabber/tv/activities/MainActivity.java
+++ b/app/src/main/java/com/hyperion/grabber/tv/activities/MainActivity.java
@@ -29,7 +29,6 @@ import android.widget.Toast;
import com.hyperion.grabber.common.BootActivity;
import com.hyperion.grabber.common.HyperionScreenService;
-import com.hyperion.grabber.common.util.TclBypass;
import com.hyperion.grabber.common.util.Preferences;
import com.hyperion.grabber.R;
@@ -41,7 +40,6 @@ public class MainActivity extends LeanbackActivity implements ImageView.OnClickL
public static final String BROADCAST_ERROR = "SERVICE_ERROR";
public static final String BROADCAST_TAG = "SERVICE_STATUS";
public static final String BROADCAST_FILTER = "SERVICE_FILTER";
- public static final String BROADCAST_TCL_BLOCKED = "TCL_BLOCKED";
private static final String TAG = "DEBUG";
private boolean mRecorderRunning = false;
private static MediaProjectionManager mMediaProjectionManager;
@@ -53,11 +51,8 @@ public class MainActivity extends LeanbackActivity implements ImageView.OnClickL
boolean checked = intent.getBooleanExtra(BROADCAST_TAG, false);
mRecorderRunning = checked;
String error = intent.getStringExtra(BROADCAST_ERROR);
- boolean tclBlocked = intent.getBooleanExtra(BROADCAST_TCL_BLOCKED, false);
- if (tclBlocked) {
- TclBypass.showTclHelpDialog(MainActivity.this, () -> requestScreenCapture());
- } else if (error != null) {
+ if (error != null) {
Toast.makeText(getBaseContext(), error, Toast.LENGTH_SHORT).show();
}
setImageViews(checked, true);
@@ -166,15 +161,12 @@ public class MainActivity extends LeanbackActivity implements ImageView.OnClickL
}
private void requestScreenCapture() {
- TclBypass.tryShellBypass(this);
-
try {
Intent captureIntent = mMediaProjectionManager.createScreenCaptureIntent();
startActivityForResult(captureIntent, REQUEST_MEDIA_PROJECTION);
} catch (Exception e) {
Log.e(TAG, "Failed to request screen capture: " + e.getMessage());
mPermissionDeniedCount++;
- TclBypass.showTclHelpDialog(this, this::requestScreenCapture);
}
}
@@ -210,9 +202,6 @@ public class MainActivity extends LeanbackActivity implements ImageView.OnClickL
if (resultCode != Activity.RESULT_OK) {
mPermissionDeniedCount++;
Toast.makeText(this, "Permission denied. Tap again to retry.", Toast.LENGTH_SHORT).show();
- if (mPermissionDeniedCount >= 2) {
- TclBypass.showTclHelpDialog(this, this::requestScreenCapture);
- }
if (mRecorderRunning) {
stopScreenRecorder();
}
diff --git a/common/src/main/java/com/hyperion/grabber/HyperionScreenService.java b/common/src/main/java/com/hyperion/grabber/HyperionScreenService.java
index 0efd3d9..49c2d53 100644
--- a/common/src/main/java/com/hyperion/grabber/HyperionScreenService.java
+++ b/common/src/main/java/com/hyperion/grabber/HyperionScreenService.java
@@ -28,7 +28,6 @@ import android.view.WindowManager;
import com.hyperion.grabber.common.network.HyperionThread;
import com.hyperion.grabber.common.util.HyperionGrabberOptions;
import com.hyperion.grabber.common.util.Preferences;
-import com.hyperion.grabber.common.util.TclBypass;
import java.util.Objects;
@@ -36,12 +35,10 @@ public class HyperionScreenService extends Service {
public static final String BROADCAST_ERROR = "SERVICE_ERROR";
public static final String BROADCAST_TAG = "SERVICE_STATUS";
public static final String BROADCAST_FILTER = "SERVICE_FILTER";
- public static final String BROADCAST_TCL_BLOCKED = "TCL_BLOCKED";
private static final boolean DEBUG = false;
private static final String TAG = "HyperionScreenService";
private boolean mForegroundFailed = false;
- private boolean mTclBlocked = false;
private PowerManager.WakeLock mWakeLock;
private Handler mHandler;
@@ -138,12 +135,6 @@ public class HyperionScreenService extends Service {
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mHandler = new Handler(Looper.getMainLooper());
- // Try shell bypass on startup for TCL devices
- if (TclBypass.isTclDevice() || TclBypass.isRestrictedManufacturer()) {
- Log.i(TAG, "Detected restricted manufacturer, attempting shell bypass");
- TclBypass.tryShellBypass(this);
- }
-
super.onCreate();
}
@@ -208,7 +199,7 @@ public class HyperionScreenService extends Service {
if (isPrepared) {
boolean foregroundStarted = tryStartForeground();
- if (!foregroundStarted && mTclBlocked) {
+ if (!foregroundStarted) {
acquireWakeLock();
}
@@ -278,7 +269,6 @@ public class HyperionScreenService extends Service {
private boolean tryStartForeground() {
mForegroundFailed = false;
- mTclBlocked = false;
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
@@ -291,11 +281,6 @@ public class HyperionScreenService extends Service {
} catch (Exception e) {
Log.e(TAG, "Foreground start failed: " + e.getMessage());
mForegroundFailed = true;
-
- String msg = e.getMessage();
- if (msg != null && (msg.contains("TclAppBoot") || msg.contains("forbid"))) {
- mTclBlocked = true;
- }
}
if (mForegroundFailed) {
@@ -308,15 +293,13 @@ public class HyperionScreenService extends Service {
startForeground(NOTIFICATION_ID, getNotification());
}
mForegroundFailed = false;
- mTclBlocked = false;
return true;
} catch (Exception e) {
Log.e(TAG, "Foreground retry failed: " + e.getMessage());
- mTclBlocked = true;
}
}
- notifyTclBlocked();
+ notifyForegroundFailed();
return false;
}
@@ -347,10 +330,9 @@ public class HyperionScreenService extends Service {
}
}
- private void notifyTclBlocked() {
+ private void notifyForegroundFailed() {
Intent intent = new Intent(BROADCAST_FILTER);
intent.putExtra(BROADCAST_TAG, false);
- intent.putExtra(BROADCAST_TCL_BLOCKED, true);
intent.putExtra(BROADCAST_ERROR, "Foreground service blocked by device manufacturer");
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent);
}
diff --git a/common/src/main/java/com/hyperion/grabber/common/util/TclBypass.java b/common/src/main/java/com/hyperion/grabber/common/util/TclBypass.java
deleted file mode 100644
index 2ebc839..0000000
--- a/common/src/main/java/com/hyperion/grabber/common/util/TclBypass.java
+++ /dev/null
@@ -1,173 +0,0 @@
-package com.hyperion.grabber.common.util;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.net.Uri;
-import android.os.Build;
-import android.provider.Settings;
-import android.util.Log;
-import android.widget.Toast;
-
-import java.util.List;
-
-public class TclBypass {
- private static final String TAG = "TclBypass";
-
- public static boolean isTclDevice() {
- String manufacturer = Build.MANUFACTURER.toLowerCase();
- String brand = Build.BRAND.toLowerCase();
- String device = Build.DEVICE.toLowerCase();
- String model = Build.MODEL.toLowerCase();
-
- return manufacturer.contains("tcl") ||
- brand.contains("tcl") ||
- device.startsWith("g10") ||
- model.contains("tcl") ||
- model.contains("smart tv");
- }
-
- public static boolean isRestrictedManufacturer() {
- String manufacturer = Build.MANUFACTURER.toLowerCase();
- return manufacturer.contains("tcl") ||
- manufacturer.contains("xiaomi") ||
- manufacturer.contains("huawei") ||
- manufacturer.contains("oppo") ||
- manufacturer.contains("vivo") ||
- manufacturer.contains("realme") ||
- manufacturer.contains("samsung");
- }
-
- public static boolean openTclAutoStartSettings(Context context) {
- Intent[] intents = {
- // TCL specific intents
- new Intent().setComponent(new ComponentName("com.tcl.guard",
- "com.tcl.guard.activity.AutostartActivity")),
- new Intent().setComponent(new ComponentName("com.tcl.guard",
- "com.tcl.guard.activity.AppAutoStartManagerActivity")),
- new Intent().setComponent(new ComponentName("com.android.settings",
- "com.tcl.settings.TclAutoStartSettingsActivity")),
- new Intent().setComponent(new ComponentName("com.tcl.tvweishi",
- "com.tcl.tvweishi.settings.AutoBootManageActivity")),
- // TCL TV Settings
- new Intent().setComponent(new ComponentName("com.android.tv.settings",
- "com.android.tv.settings.MainSettings")),
- new Intent().setComponent(new ComponentName("com.android.tv.settings",
- "com.android.tv.settings.device.apps.AppsActivity")),
- // Generic auto-start intents
- new Intent("android.settings.APPLICATION_DEVELOPMENT_SETTINGS"),
- new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
- .setData(Uri.parse("package:" + context.getPackageName())),
- };
-
- for (Intent intent : intents) {
- try {
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- if (isIntentAvailable(context, intent)) {
- context.startActivity(intent);
- Log.d(TAG, "Opened: " + intent.getComponent());
- return true;
- }
- } catch (Exception e) {
- Log.d(TAG, "Failed to open: " + intent, e);
- }
- }
- return false;
- }
-
- public static boolean openSpecialAppAccess(Context context) {
- Intent[] intents = {
- // Special app access
- new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION)
- .setData(Uri.parse("package:" + context.getPackageName())),
- new Intent("android.settings.action.MANAGE_OVERLAY_PERMISSION")
- .setData(Uri.parse("package:" + context.getPackageName())),
- // TV Settings apps section
- new Intent().setComponent(new ComponentName("com.android.tv.settings",
- "com.android.tv.settings.device.apps.AppManagementActivity"))
- .putExtra("packageName", context.getPackageName()),
- };
-
- for (Intent intent : intents) {
- try {
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- if (isIntentAvailable(context, intent)) {
- context.startActivity(intent);
- return true;
- }
- } catch (Exception e) {
- Log.d(TAG, "Failed: " + intent, e);
- }
- }
- return false;
- }
-
- public static void tryShellBypass(Context context) {
- new Thread(() -> {
- String pkg = context.getPackageName();
- String[] commands = {
- "appops set " + pkg + " PROJECT_MEDIA allow",
- "appops set " + pkg + " android:project_media allow",
- "appops set " + pkg + " SYSTEM_ALERT_WINDOW allow",
- "settings put global auto_start_" + pkg + " 1",
- "settings put secure auto_start_" + pkg + " 1",
- "am broadcast -a com.tcl.action.ALLOW_AUTO_START -e package " + pkg,
- "am broadcast -a com.tcl.appboot.action.SET_ALLOW -e package " + pkg,
- "settings put global tcl_app_boot_" + pkg + " allow",
- "settings put secure tcl_app_boot_" + pkg + " allow",
- "cmd deviceidle whitelist +" + pkg,
- "dumpsys deviceidle whitelist +" + pkg,
- "appops set " + pkg + " RUN_IN_BACKGROUND allow",
- "appops set " + pkg + " RUN_ANY_IN_BACKGROUND allow",
- "appops set " + pkg + " START_FOREGROUND allow",
- "appops set " + pkg + " INSTANT_APP_START_FOREGROUND allow",
- };
-
- for (String cmd : commands) {
- try {
- Process process = Runtime.getRuntime().exec(new String[]{"sh", "-c", cmd});
- process.waitFor();
- int exit = process.exitValue();
- if (exit == 0) {
- Log.d(TAG, "Success: " + cmd);
- }
- } catch (Exception e) {
- }
- }
- }).start();
- }
-
- public static void showTclHelpDialog(Activity activity, Runnable onRetry) {
- String pkg = activity.getPackageName();
-
- String message = "Your TV is blocking the screen recording service.\n\n" +
- "USE ADB TO FIX (from computer):\n\n" +
- "adb shell appops set " + pkg + " PROJECT_MEDIA allow\n\n" +
- "adb shell appops set " + pkg + " START_FOREGROUND allow\n\n" +
- "Or reinstall with permissions:\n" +
- "adb install -g -r hyperion.apk";
-
- new AlertDialog.Builder(activity)
- .setTitle("TCL Blocked")
- .setMessage(message)
- .setPositiveButton("Retry", (d, w) -> {
- tryShellBypass(activity);
- if (onRetry != null) {
- activity.getWindow().getDecorView().postDelayed(() -> onRetry.run(), 1000);
- }
- })
- .setNegativeButton("Close", null)
- .setCancelable(true)
- .show();
- }
-
- private static boolean isIntentAvailable(Context context, Intent intent) {
- PackageManager pm = context.getPackageManager();
- List list = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
- return list != null && !list.isEmpty();
- }
-}