Skip to content

Commit

Permalink
Fix freeze and thaw rotation for Android 14
Browse files Browse the repository at this point in the history
Changed since AOSP/framework_base commit
670fb7f5c0d23cf51ead25538bcb017e03ed73ac, included in tag
android-14.0.0_r29.

Refs <https://android.googlesource.com/platform/frameworks/base/+/670fb7f5c0d23cf51ead25538bcb017e03ed73ac%5E%21/>
PR #4740 <#4740>

Signed-off-by: Romain Vimont <[email protected]>
  • Loading branch information
Stepan Salenikovich authored and rom1v committed Apr 6, 2024
1 parent ee6620d commit 7011dd1
Showing 1 changed file with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,17 @@ private Method getFreezeDisplayRotationMethod() throws NoSuchMethodException {
freezeDisplayRotationMethod = manager.getClass().getMethod("freezeRotation", int.class);
freezeDisplayRotationMethodVersion = 0;
} catch (NoSuchMethodException e) {
// New method added by this commit:
// <https://android.googlesource.com/platform/frameworks/base/+/90c9005e687aa0f63f1ac391adc1e8878ab31759%5E%21/>
freezeDisplayRotationMethod = manager.getClass().getMethod("freezeDisplayRotation", int.class, int.class);
freezeDisplayRotationMethodVersion = 1;
try {
// New method added by this commit:
// <https://android.googlesource.com/platform/frameworks/base/+/90c9005e687aa0f63f1ac391adc1e8878ab31759%5E%21/>
freezeDisplayRotationMethod = manager.getClass().getMethod("freezeDisplayRotation", int.class, int.class);
freezeDisplayRotationMethodVersion = 1;
} catch (NoSuchMethodException e1) {
// Android 15 preview and 14 QPR3 Beta added a String caller parameter for debugging:
// <https://android.googlesource.com/platform/frameworks/base/+/670fb7f5c0d23cf51ead25538bcb017e03ed73ac%5E%21/>
freezeDisplayRotationMethod = manager.getClass().getMethod("freezeDisplayRotation", int.class, int.class, String.class);
freezeDisplayRotationMethodVersion = 2;
}
}
}
return freezeDisplayRotationMethod;
Expand All @@ -82,10 +89,17 @@ private Method getThawDisplayRotationMethod() throws NoSuchMethodException {
thawDisplayRotationMethod = manager.getClass().getMethod("thawRotation");
thawDisplayRotationMethodVersion = 0;
} catch (NoSuchMethodException e) {
// New method added by this commit:
// <https://android.googlesource.com/platform/frameworks/base/+/90c9005e687aa0f63f1ac391adc1e8878ab31759%5E%21/>
thawDisplayRotationMethod = manager.getClass().getMethod("thawDisplayRotation", int.class);
thawDisplayRotationMethodVersion = 1;
try {
// New method added by this commit:
// <https://android.googlesource.com/platform/frameworks/base/+/90c9005e687aa0f63f1ac391adc1e8878ab31759%5E%21/>
thawDisplayRotationMethod = manager.getClass().getMethod("thawDisplayRotation", int.class);
thawDisplayRotationMethodVersion = 1;
} catch (NoSuchMethodException e1) {
// Android 15 preview and 14 QPR3 Beta added a String caller parameter for debugging:
// <https://android.googlesource.com/platform/frameworks/base/+/670fb7f5c0d23cf51ead25538bcb017e03ed73ac%5E%21/>
thawDisplayRotationMethod = manager.getClass().getMethod("thawDisplayRotation", int.class, String.class);
thawDisplayRotationMethodVersion = 2;
}
}
}
return thawDisplayRotationMethod;
Expand All @@ -112,9 +126,12 @@ public void freezeRotation(int displayId, int rotation) {
}
method.invoke(manager, rotation);
break;
default:
case 1:
method.invoke(manager, displayId, rotation);
break;
default:
method.invoke(manager, displayId, rotation, "scrcpy#freezeRotation");
break;
}
} catch (ReflectiveOperationException e) {
Ln.e("Could not invoke method", e);
Expand Down Expand Up @@ -151,9 +168,12 @@ public void thawRotation(int displayId) {
}
method.invoke(manager);
break;
default:
case 1:
method.invoke(manager, displayId);
break;
default:
method.invoke(manager, displayId, "scrcpy#thawRotation");
break;
}
} catch (ReflectiveOperationException e) {
Ln.e("Could not invoke method", e);
Expand Down

0 comments on commit 7011dd1

Please sign in to comment.