|
|
@ -13,8 +13,11 @@ public final class WindowManager {
|
|
|
|
private final IInterface manager;
|
|
|
|
private final IInterface manager;
|
|
|
|
private Method getRotationMethod;
|
|
|
|
private Method getRotationMethod;
|
|
|
|
private Method freezeRotationMethod;
|
|
|
|
private Method freezeRotationMethod;
|
|
|
|
|
|
|
|
private Method freezeDisplayRotationMethod;
|
|
|
|
private Method isRotationFrozenMethod;
|
|
|
|
private Method isRotationFrozenMethod;
|
|
|
|
|
|
|
|
private Method isDisplayRotationFrozenMethod;
|
|
|
|
private Method thawRotationMethod;
|
|
|
|
private Method thawRotationMethod;
|
|
|
|
|
|
|
|
private Method thawDisplayRotationMethod;
|
|
|
|
|
|
|
|
|
|
|
|
static WindowManager create() {
|
|
|
|
static WindowManager create() {
|
|
|
|
IInterface manager = ServiceManager.getService("window", "android.view.IWindowManager");
|
|
|
|
IInterface manager = ServiceManager.getService("window", "android.view.IWindowManager");
|
|
|
@ -47,6 +50,15 @@ public final class WindowManager {
|
|
|
|
return freezeRotationMethod;
|
|
|
|
return freezeRotationMethod;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// New method added by this commit:
|
|
|
|
|
|
|
|
// <https://android.googlesource.com/platform/frameworks/base/+/90c9005e687aa0f63f1ac391adc1e8878ab31759%5E%21/>
|
|
|
|
|
|
|
|
private Method getFreezeDisplayRotationMethod() throws NoSuchMethodException {
|
|
|
|
|
|
|
|
if (freezeDisplayRotationMethod == null) {
|
|
|
|
|
|
|
|
freezeDisplayRotationMethod = manager.getClass().getMethod("freezeDisplayRotation", int.class, int.class);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return freezeDisplayRotationMethod;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Method getIsRotationFrozenMethod() throws NoSuchMethodException {
|
|
|
|
private Method getIsRotationFrozenMethod() throws NoSuchMethodException {
|
|
|
|
if (isRotationFrozenMethod == null) {
|
|
|
|
if (isRotationFrozenMethod == null) {
|
|
|
|
isRotationFrozenMethod = manager.getClass().getMethod("isRotationFrozen");
|
|
|
|
isRotationFrozenMethod = manager.getClass().getMethod("isRotationFrozen");
|
|
|
@ -54,6 +66,15 @@ public final class WindowManager {
|
|
|
|
return isRotationFrozenMethod;
|
|
|
|
return isRotationFrozenMethod;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// New method added by this commit:
|
|
|
|
|
|
|
|
// <https://android.googlesource.com/platform/frameworks/base/+/90c9005e687aa0f63f1ac391adc1e8878ab31759%5E%21/>
|
|
|
|
|
|
|
|
private Method getIsDisplayRotationFrozenMethod() throws NoSuchMethodException {
|
|
|
|
|
|
|
|
if (isDisplayRotationFrozenMethod == null) {
|
|
|
|
|
|
|
|
isDisplayRotationFrozenMethod = manager.getClass().getMethod("isDisplayRotationFrozen", int.class);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return isDisplayRotationFrozenMethod;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Method getThawRotationMethod() throws NoSuchMethodException {
|
|
|
|
private Method getThawRotationMethod() throws NoSuchMethodException {
|
|
|
|
if (thawRotationMethod == null) {
|
|
|
|
if (thawRotationMethod == null) {
|
|
|
|
thawRotationMethod = manager.getClass().getMethod("thawRotation");
|
|
|
|
thawRotationMethod = manager.getClass().getMethod("thawRotation");
|
|
|
@ -61,6 +82,15 @@ public final class WindowManager {
|
|
|
|
return thawRotationMethod;
|
|
|
|
return thawRotationMethod;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// New method added by this commit:
|
|
|
|
|
|
|
|
// <https://android.googlesource.com/platform/frameworks/base/+/90c9005e687aa0f63f1ac391adc1e8878ab31759%5E%21/>
|
|
|
|
|
|
|
|
private Method getThawDisplayRotationMethod() throws NoSuchMethodException {
|
|
|
|
|
|
|
|
if (thawDisplayRotationMethod == null) {
|
|
|
|
|
|
|
|
thawDisplayRotationMethod = manager.getClass().getMethod("thawDisplayRotation", int.class);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return thawDisplayRotationMethod;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int getRotation() {
|
|
|
|
public int getRotation() {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Method method = getGetRotationMethod();
|
|
|
|
Method method = getGetRotationMethod();
|
|
|
@ -71,29 +101,57 @@ public final class WindowManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void freezeRotation(int rotation) {
|
|
|
|
public void freezeRotation(int displayId, int rotation) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Method method = getFreezeRotationMethod();
|
|
|
|
try {
|
|
|
|
method.invoke(manager, rotation);
|
|
|
|
Method method = getFreezeDisplayRotationMethod();
|
|
|
|
|
|
|
|
method.invoke(manager, displayId, rotation);
|
|
|
|
|
|
|
|
} catch (ReflectiveOperationException e) {
|
|
|
|
|
|
|
|
if (displayId == 0) {
|
|
|
|
|
|
|
|
Method method = getFreezeRotationMethod();
|
|
|
|
|
|
|
|
method.invoke(manager, rotation);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Ln.e("Could not invoke method", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (ReflectiveOperationException e) {
|
|
|
|
} catch (ReflectiveOperationException e) {
|
|
|
|
Ln.e("Could not invoke method", e);
|
|
|
|
Ln.e("Could not invoke method", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isRotationFrozen() {
|
|
|
|
public boolean isRotationFrozen(int displayId) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Method method = getIsRotationFrozenMethod();
|
|
|
|
try {
|
|
|
|
return (boolean) method.invoke(manager);
|
|
|
|
Method method = getIsDisplayRotationFrozenMethod();
|
|
|
|
|
|
|
|
return (boolean) method.invoke(manager, displayId);
|
|
|
|
|
|
|
|
} catch (ReflectiveOperationException e) {
|
|
|
|
|
|
|
|
if (displayId == 0) {
|
|
|
|
|
|
|
|
Method method = getIsRotationFrozenMethod();
|
|
|
|
|
|
|
|
return (boolean) method.invoke(manager);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Ln.e("Could not invoke method", e);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (ReflectiveOperationException e) {
|
|
|
|
} catch (ReflectiveOperationException e) {
|
|
|
|
Ln.e("Could not invoke method", e);
|
|
|
|
Ln.e("Could not invoke method", e);
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void thawRotation() {
|
|
|
|
public void thawRotation(int displayId) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Method method = getThawRotationMethod();
|
|
|
|
try {
|
|
|
|
method.invoke(manager);
|
|
|
|
Method method = getThawDisplayRotationMethod();
|
|
|
|
|
|
|
|
method.invoke(manager, displayId);
|
|
|
|
|
|
|
|
} catch (ReflectiveOperationException e) {
|
|
|
|
|
|
|
|
if (displayId == 0) {
|
|
|
|
|
|
|
|
Method method = getThawRotationMethod();
|
|
|
|
|
|
|
|
method.invoke(manager);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Ln.e("Could not invoke method", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (ReflectiveOperationException e) {
|
|
|
|
} catch (ReflectiveOperationException e) {
|
|
|
|
Ln.e("Could not invoke method", e);
|
|
|
|
Ln.e("Could not invoke method", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|