fix: survive a missing restriction bypass native library (#7484)
* fix: don't crash at startup when the restriction bypass lib is missing Unseal.unseal() loads ChickenHook's libnrb.so. Repackaged APKs and multi-open containers can fail to load it, in which case the call throws UnsatisfiedLinkError (an Error) that catch (Exception) does not handle. This runs from Application.onCreate(), so the process crash-loops forever. Catch Exception | LinkageError. A failed unseal only disables the hidden API exemption for that launch; other Errors (OOM, etc.) still propagate. * fix: don't crash reading allowEnterPip when the restriction bypass is broken getAllowEnterPip() uses RestrictionBypass below SDK 35. If the native bypass library failed to load, the bypass class is permanently broken and any further access throws LinkageError (ExceptionInInitializerError on the first touch, NoClassDefFoundError afterwards), which catch (ReflectiveOperationException) does not handle. Return false (PIP not allowed) instead of crashing the transition. --------- Co-authored-by: caizhixing <17589399+caizhixing03@user.noreply.gitee.com>
This commit is contained in:
1 parent
2b719d5134
commit
bf784dc6fb
2 files changed
+9
-1
No files matched your search
@@ -55,7 +55,10 @@ public class MainProcessInitializer implements ResourceBasedOverride {
|
||||
try {
|
||||
Unseal.unseal();
|
||||
Log.i(TAG, "Unseal success!");
|
||||
} catch (Exception e) {
|
||||
} catch (Exception | LinkageError e) {
|
||||
// A repackaged APK or a multi-open container can fail to load libnrb.so, in which
|
||||
// case Unseal.unseal() throws UnsatisfiedLinkError (an Error). Startup must survive
|
||||
// a broken bypass: only the hidden API exemption is lost for this launch.
|
||||
Log.e(TAG, "Unseal fail!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -440,6 +440,11 @@ public class TransitionUtil {
|
||||
TransitionInfo.Change.class, "getAllowEnterPip").invoke(change);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new IllegalStateException("Unable to read allowEnterPip from transition change", e);
|
||||
} catch (LinkageError e) {
|
||||
// The restriction bypass can be unavailable (libnrb.so failed to load), in which case
|
||||
// touching RestrictionBypass throws ExceptionInInitializerError/NoClassDefFoundError.
|
||||
// Assume PIP is not allowed instead of crashing the transition.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user