Fixed: Catch exceptions if failed to bypass hidden API restrictions

Attempting to bypass restrictions while tests are running will fail due to call to `TermuxApplication.onCreate()` -> `TermuxShellEnvironment.init()` -> `SELinuxUtils.getContext()`
This commit is contained in:
agnostic-apollo
2022-06-14 04:08:03 +05:00
parent 162469f7ce
commit b80126fd61

View File

@@ -28,7 +28,12 @@ public class ReflectionUtils {
public static void bypassHiddenAPIReflectionRestrictions() { public static void bypassHiddenAPIReflectionRestrictions() {
if (!HIDDEN_API_REFLECTION_RESTRICTIONS_BYPASSED && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { if (!HIDDEN_API_REFLECTION_RESTRICTIONS_BYPASSED && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
Logger.logDebug(LOG_TAG, "Bypassing android hidden api reflection restrictions"); Logger.logDebug(LOG_TAG, "Bypassing android hidden api reflection restrictions");
HiddenApiBypass.addHiddenApiExemptions(""); try {
HiddenApiBypass.addHiddenApiExemptions("");
} catch (Throwable t) {
Logger.logStackTraceWithMessage(LOG_TAG, "Failed to bypass hidden API reflection restrictions", t);
}
HIDDEN_API_REFLECTION_RESTRICTIONS_BYPASSED = true; HIDDEN_API_REFLECTION_RESTRICTIONS_BYPASSED = true;
} }
} }