Skip to content

Commit

Permalink
Register rotation watcher only when possible
Browse files Browse the repository at this point in the history
Old Android versions may not be able to register a rotation watcher for
a secondary display. In that case, report the error instead of
registering a rotation watcher for the default display.

Refs <Genymobile#4740 (comment)>

Suggested by: Kaiming Hu <[email protected]>
  • Loading branch information
rom1v authored and FreedomBen committed Aug 2, 2024
1 parent 2f717e6 commit ec942e5
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ public void registerRotationWatcher(IRotationWatcher rotationWatcher, int displa
cls.getMethod("watchRotation", IRotationWatcher.class, int.class).invoke(manager, rotationWatcher, displayId);
} catch (NoSuchMethodException e) {
// old version
if (displayId != 0) {
Ln.e("Secondary display rotation not supported on this device");
return;
}
cls.getMethod("watchRotation", IRotationWatcher.class).invoke(manager, rotationWatcher);
}
} catch (Exception e) {
Expand Down

0 comments on commit ec942e5

Please sign in to comment.