-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
301 additions
and
1 deletion.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
...id_framework/base/src/main/java/github/tornaco/android/thanos/core/wm/IWindowManager.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
package github.tornaco.android.thanos.core.wm; | ||
|
||
import github.tornaco.android.thanos.core.wm.WindowState; | ||
|
||
interface IWindowManager { | ||
int[] getScreenSize(); | ||
|
||
void setDialogForceCancelable(String packageName, boolean forceCancelable); | ||
boolean isDialogForceCancelable(String packageName); | ||
void reportDialogHasBeenForceSetCancelable(String packageName); | ||
|
||
List<WindowState> getVisibleWindows(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...droid_framework/base/src/main/java/github/tornaco/android/thanos/core/wm/WindowState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* (C) Copyright 2022 Thanox | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package github.tornaco.android.thanos.core.wm; | ||
|
||
import android.os.Parcel; | ||
import android.os.Parcelable; | ||
|
||
public class WindowState implements Parcelable { | ||
public String packageName; | ||
public int uid; | ||
public boolean visible; | ||
public int type; | ||
|
||
public WindowState(String packageName, int uid, boolean visible, int type) { | ||
this.packageName = packageName; | ||
this.uid = uid; | ||
this.visible = visible; | ||
this.type = type; | ||
} | ||
|
||
protected WindowState(Parcel in) { | ||
packageName = in.readString(); | ||
uid = in.readInt(); | ||
visible = in.readByte() != 0; | ||
type = in.readInt(); | ||
} | ||
|
||
public static final Creator<WindowState> CREATOR = new Creator<WindowState>() { | ||
@Override | ||
public WindowState createFromParcel(Parcel in) { | ||
return new WindowState(in); | ||
} | ||
|
||
@Override | ||
public WindowState[] newArray(int size) { | ||
return new WindowState[size]; | ||
} | ||
}; | ||
|
||
@Override | ||
public int describeContents() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void writeToParcel(Parcel parcel, int i) { | ||
parcel.writeString(packageName); | ||
parcel.writeInt(uid); | ||
parcel.writeByte((byte) (visible ? 1 : 0)); | ||
parcel.writeInt(type); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "WindowState{" + | ||
"packageName='" + packageName + '\'' + | ||
", uid=" + uid + | ||
", visible=" + visible + | ||
", type=" + type + " " + WindowTypeMapping.INSTANCE.getMap().get(String.valueOf(type)) + | ||
'}'; | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
...d_framework/base/src/main/java/github/tornaco/android/thanos/core/wm/WindowTypeMapping.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* (C) Copyright 2022 Thanox | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package github.tornaco.android.thanos.core.wm | ||
|
||
object WindowTypeMapping { | ||
|
||
fun <K, V> MutableMap<K, V>.add(data: Pair<K, V>) { | ||
this[data.first] = data.second | ||
} | ||
|
||
val map = mutableMapOf<String, String>().apply { | ||
add("2" to "TYPE_APPLICATION") | ||
add("3" to "TYPE_APPLICATION_STARTING") | ||
add("4" to "TYPE_DRAWN_APPLICATION") | ||
add("1000" to "TYPE_APPLICATION_PANEL") | ||
add("1001" to "TYPE_APPLICATION_MEDIA") | ||
add("1002" to "TYPE_APPLICATION_SUB_PANEL") | ||
add("1003" to "TYPE_APPLICATION_ATTACHED_DIALOG") | ||
add("1004" to "TYPE_APPLICATION_MEDIA_OVERLAY") | ||
add("1005" to "TYPE_APPLICATION_ABOVE_SUB_PANEL") | ||
add("2000" to "TYPE_STATUS_BAR") | ||
add("2001" to "TYPE_SEARCH_BAR") | ||
add("2002" to "TYPE_PHONE") | ||
add("2003" to "TYPE_SYSTEM_ALERT") | ||
add("2004" to "TYPE_KEYGUARD") | ||
add("2005" to "TYPE_TOAST") | ||
add("2006" to "TYPE_SYSTEM_OVERLAY") | ||
add("2007" to "TYPE_PRIORITY_PHONE") | ||
add("2008" to "TYPE_SYSTEM_DIALOG") | ||
add("2009" to "TYPE_KEYGUARD_DIALOG") | ||
add("2010" to "TYPE_SYSTEM_ERROR") | ||
add("2011" to "TYPE_INPUT_METHOD") | ||
add("2012" to "TYPE_INPUT_METHOD_DIALOG") | ||
add("2013" to "TYPE_WALLPAPER") | ||
add("2014" to "TYPE_STATUS_BAR_PANEL") | ||
add("2015" to "TYPE_SECURE_SYSTEM_OVERLAY") | ||
add("2016" to "TYPE_DRAG") | ||
add("2017" to "TYPE_STATUS_BAR_SUB_PANEL") | ||
add("2018" to "TYPE_POINTER") | ||
add("2019" to "TYPE_NAVIGATION_BAR") | ||
add("2020" to "TYPE_VOLUME_OVERLAY") | ||
add("2021" to "TYPE_BOOT_PROGRESS") | ||
add("2022" to "TYPE_INPUT_CONSUMER") | ||
add("2024" to "TYPE_NAVIGATION_BAR_PANEL") | ||
add("2026" to "TYPE_DISPLAY_OVERLAY") | ||
add("2027" to "TYPE_MAGNIFICATION_OVERLAY") | ||
add("2030" to "TYPE_PRIVATE_PRESENTATION") | ||
add("2031" to "TYPE_VOICE_INTERACTION") | ||
add("2032" to "TYPE_ACCESSIBILITY_OVERLAY") | ||
add("2033" to "TYPE_VOICE_INTERACTION_STARTING") | ||
add("2034" to "TYPE_DOCK_DIVIDER") | ||
add("2035" to "TYPE_QS_DIALOG") | ||
add("2036" to "TYPE_SCREENSHOT") | ||
add("2037" to "TYPE_PRESENTATION") | ||
add("2038" to "TYPE_APPLICATION_OVERLAY") | ||
add("2039" to "TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY") | ||
add("2040" to "TYPE_NOTIFICATION_SHADE") | ||
add("2041" to "TYPE_STATUS_BAR_ADDITIONAL") | ||
} | ||
} | ||
|
56 changes: 56 additions & 0 deletions
56
...main/java/github/tornaco/android/thanos/services/patch/common/wm/XWindowManagerService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package github.tornaco.android.thanos.services.patch.common.wm | ||
|
||
import com.elvishew.xlog.XLog | ||
import util.XposedHelpers | ||
import java.util.function.Consumer | ||
|
||
object XWindowManagerService { | ||
@JvmStatic | ||
fun wmsClass(classLoader: ClassLoader): Class<*> { | ||
return XposedHelpers.findClass( | ||
"com.android.server.wm.WindowManagerService", | ||
classLoader | ||
) | ||
} | ||
|
||
@JvmStatic | ||
fun getInstance(classLoader: ClassLoader): Any? { | ||
return kotlin.runCatching { | ||
XposedHelpers.callStaticMethod( | ||
wmsClass(classLoader), | ||
"getInstance" | ||
) | ||
}.getOrElse { | ||
XLog.e("XWindowManagerService#getInstance error") | ||
null | ||
} | ||
} | ||
|
||
@JvmStatic | ||
fun getRoot(wms: Any): Any? { | ||
return kotlin.runCatching { | ||
XposedHelpers.getObjectField( | ||
wms, | ||
"mRoot" | ||
) | ||
}.getOrElse { | ||
XLog.e("XWindowManagerService#getRoot error") | ||
null | ||
} | ||
} | ||
|
||
// void forAllWindows(Consumer<WindowState> var1, boolean var2) | ||
@JvmStatic | ||
fun forAllWindows(root: Any, consumer: Consumer<*>) { | ||
kotlin.runCatching { | ||
XposedHelpers.callMethod( | ||
root, | ||
"forAllWindows", | ||
consumer, | ||
false /* traverseTopToBottom */ | ||
) | ||
}.onFailure { | ||
XLog.e("XWindowManagerService#forAllWindows error") | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...mmon/src/main/java/github/tornaco/android/thanos/services/patch/common/wm/XWindowState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package github.tornaco.android.thanos.services.patch.common.wm | ||
|
||
import android.annotation.SuppressLint | ||
import com.elvishew.xlog.XLog | ||
import github.tornaco.android.thanos.core.wm.WindowState | ||
import util.XposedHelpers | ||
|
||
|
||
object XWindowState { | ||
|
||
@SuppressLint("PrivateApi") | ||
@JvmStatic | ||
fun getState(state: Any?): WindowState? { | ||
return if (state == null) null else try { | ||
val visible = XposedHelpers.callMethod(state, "isVisible") as Boolean | ||
val type = XposedHelpers.callMethod(state, "getWindowType") as Int | ||
val uid = XposedHelpers.callMethod(state, "getOwningUid") as Int | ||
val ownPackageName = | ||
XposedHelpers.callMethod(state, "getOwningPackage") as String | ||
WindowState( | ||
ownPackageName, | ||
uid, | ||
visible, | ||
type | ||
) | ||
} catch (e: Throwable) { | ||
XLog.e("XWindowState#getState error", e) | ||
null | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule Thanox-Internal
updated
from ba3a97 to 397c1a