Skip to content

Commit bd046af

Browse files
committed
fix: add view to q11y window
1 parent c29263f commit bd046af

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

app/src/main/kotlin/li/songe/gkd/a11y/A11yFeat.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,15 @@ private fun A11yService.useAliveOverlayView() {
211211
height = 1
212212
packageName = context.packageName
213213
}
214-
wm.addView(tempView, lp)
214+
try {
215+
// 某些设备 android.view.WindowManager$BadTokenException
216+
wm.addView(tempView, lp)
217+
aliveView = tempView
218+
} catch (e: Throwable) {
219+
aliveView = null
220+
LogUtils.d(e)
221+
toast("添加无障碍保活失败\n请尝试重启无障碍")
222+
}
215223
}
216224
onA11yConnected { addA11View() }
217225
onDestroyed { removeA11View() }

0 commit comments

Comments
 (0)