Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@

- 自定义关机菜单按钮(包括软重启)
- 隐藏锁屏紧急呼叫按钮
- 滑动后再进行人脸解锁
- 禁用截图声音
- 隐藏所选音乐应用的实时活动和媒体通知
- 允许所有旋转角度
Expand Down Expand Up @@ -269,6 +270,7 @@

- Customize power menu actions (including soft reboot)
- Hide the lock screen emergency call button
- Defer face unlock until swipe
- Disable screenshot sound
- Hide ongoing media activity and media notifications for selected apps
- Allow all rotation angles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,17 @@ fun DetailPaneSystemUI(
checked = uiState.other.hideLockscreenEmergencyButton,
onCheckedChange = { onEvent(SystemUIEvent.Other.HideLockscreenEmergencyButton(it)) }
)
if (ONE_UI_VERSION >= 80500) {
SwitchItem(
icon = ImageVector.vectorResource(id = R.drawable.lock_open),
title = stringResource(R.string.deferFaceUnlockUntilSwipe_title),
summary = stringResource(R.string.deferFaceUnlockUntilSwipe_summary),
checked = uiState.other.deferFaceUnlockUntilSwipe,
onCheckedChange = {
onEvent(SystemUIEvent.Other.DeferFaceUnlockUntilSwipe(it))
}
)
}
}
}

Expand Down Expand Up @@ -1205,6 +1216,9 @@ sealed interface SystemUIEvent {

@JvmInline
value class DisableScreenshotCaptureSound(val value: Boolean) : Other

@JvmInline
value class DeferFaceUnlockUntilSwipe(val value: Boolean) : Other
}
}

Expand Down Expand Up @@ -1877,6 +1891,16 @@ private fun SettingViewModel.onOtherEvent(event: SystemUIEvent.Other) {
)
)
}

is SystemUIEvent.Other.DeferFaceUnlockUntilSwipe -> {
preference.copy(
systemUI = preference.systemUI.copy(
other = preference.systemUI.other.copy(
deferFaceUnlockUntilSwipe = event.value
)
)
)
}
}
}
}
2 changes: 2 additions & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@
<string name="alignStatusBarContentToTop_summary">Mode portrait uniquement. Conserve la hauteur de la barre d’état et les marges des applications.</string>
<string name="hideLockscreenEmergencyButton_title">Masquer le bouton d’appel d’urgence sur l’écran de verrouillage</string>
<string name="hideLockscreenEmergencyButton_summary">Supprime le raccourci d’appel d’urgence de l’écran de déverrouillage et rend les appels d’urgence moins accessibles.</string>
<string name="deferFaceUnlockUntilSwipe_title">Déverrouillage facial après balayage</string>
<string name="deferFaceUnlockUntilSwipe_summary">Ne pas lancer la reconnaissance faciale avant le balayage de l\'écran de verrouillage</string>
<string name="modifyDockBottomPadding_title">Modifier la marge inférieure du dock de l’écran d’accueil</string>
<string name="modifyDockBottomPadding_summary">Téléphones en mode portrait : %1$.1f dp. Réglez sur 0 pour supprimer la marge inférieure. Peut chevaucher la zone des gestes.</string>
<string name="mediaPage_title">Page média avec application (expérimental)</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ko/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@
<string name="alignStatusBarContentToTop_summary">세로 모드에서만 적용됩니다. 상태바 높이와 앱의 상단 여백은 유지됩니다.</string>
<string name="hideLockscreenEmergencyButton_title">잠금 화면 긴급 전화 버튼 숨기기</string>
<string name="hideLockscreenEmergencyButton_summary">잠금 해제 화면의 긴급 전화 바로가기를 제거하여 긴급 전화 접근이 어려워집니다.</string>
<string name="deferFaceUnlockUntilSwipe_title">스와이프 후 얼굴 잠금 해제</string>
<string name="deferFaceUnlockUntilSwipe_summary">잠금 화면을 스와이프할 때까지 얼굴 인식을 시작하지 않음</string>
<string name="modifyDockBottomPadding_title">홈 화면 하단 독 여백 변경</string>
<string name="modifyDockBottomPadding_summary">휴대전화 세로 모드: %1$.1f dp. 0으로 설정하면 하단 여백이 제거됩니다. 제스처 영역과 겹칠 수 있습니다.</string>
<string name="mediaPage_title">앱 미디어 페이지 (실험 기능)</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@
<string name="alignStatusBarContentToTop_summary">Только в портретном режиме. Высота строки состояния и отступы приложений сохраняются.</string>
<string name="hideLockscreenEmergencyButton_title">Скрыть кнопку экстренного вызова на экране блокировки</string>
<string name="hideLockscreenEmergencyButton_summary">Удаляет ярлык экстренного вызова с экрана разблокировки, затрудняя доступ к экстренному набору.</string>
<string name="deferFaceUnlockUntilSwipe_title">Разблокировка лицом после свайпа</string>
<string name="deferFaceUnlockUntilSwipe_summary">Не запускать распознавание лица до свайпа по экрану блокировки</string>
<string name="modifyDockBottomPadding_title">Изменить нижний отступ док-панели главного экрана</string>
<string name="modifyDockBottomPadding_summary">Телефоны в портретном режиме: %1$.1f dp. Установите 0, чтобы убрать нижний отступ. Возможно перекрытие области жестов.</string>
<string name="mediaPage_title">Приложение на медиастранице (экспериментально)</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@
<string name="alignStatusBarContentToTop_summary">仅竖屏生效,保留状态栏原高度和应用顶部避让区域</string>
<string name="hideLockscreenEmergencyButton_title">隐藏锁屏紧急呼叫按钮</string>
<string name="hideLockscreenEmergencyButton_summary">移除解锁界面的紧急呼叫快捷入口,会降低紧急拨号的便捷性。</string>
<string name="deferFaceUnlockUntilSwipe_title">滑动后再进行人脸解锁</string>
<string name="deferFaceUnlockUntilSwipe_summary">在滑动锁屏之前不启动人脸识别</string>
<string name="modifyDockBottomPadding_title">修改桌面底部栏下边距</string>
<string name="modifyDockBottomPadding_summary">手机竖屏:%1$.1f dp,设为 0 移除底部留白,可能与手势区域重叠。</string>
<string name="mediaPage_title">应用负一屏(实验性)</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@
<string name="alignStatusBarContentToTop_summary">Portrait mode only. Keeps the original status bar height and app insets.</string>
<string name="hideLockscreenEmergencyButton_title">Hide lock screen emergency call button</string>
<string name="hideLockscreenEmergencyButton_summary">Removes the emergency call shortcut from the unlock screen. This makes emergency dialing less accessible.</string>
<string name="deferFaceUnlockUntilSwipe_title">Defer face unlock until swipe</string>
<string name="deferFaceUnlockUntilSwipe_summary">Do not start face recognition until the lock screen is swiped</string>
<string name="modifyDockBottomPadding_title">Modify home screen dock bottom padding</string>
<string name="modifyDockBottomPadding_summary">Phones in portrait mode: %1$.1f dp. Set to 0 to remove bottom padding. May overlap the gesture area.</string>
<string name="mediaPage_title">App media page (experimental)</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ data class Preference(
val hideLockscreenEmergencyButton: Boolean = false,
val disableScreenshotCaptureSound: Boolean = false,
val allowLowBatteryFlashlight: Boolean = false,
val deferFaceUnlockUntilSwipe: Boolean = false,
val customPowerMenu: Boolean = false,
val powerMenuActions: List<PowerMenuAction> = PowerMenuAction.defaultPreferences()
)
Expand Down
4 changes: 4 additions & 0 deletions hook/src/main/java/io/github/soclear/oneuix/hook/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ class Main : XposedModule() {
SystemUIOther.hideLockscreenEmergencyButton()
}

if (preference.systemUI.other.deferFaceUnlockUntilSwipe) {
SystemUIOther.deferFaceUnlockUntilSwipe()
}

if (preference.systemUI.statusBar.hideBatteryPercentageSign) {
StatusBar.hideBatteryPercentageSign()
}
Expand Down
88 changes: 88 additions & 0 deletions hook/src/main/java/io/github/soclear/oneuix/hook/systemui/Other.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.os.Build
import android.util.Log
import android.view.View
import io.github.libxposed.api.XposedModule
import io.github.soclear.oneuix.common.ONE_UI_VERSION
import io.github.soclear.oneuix.hook.util.afterAttachTry
import io.github.soclear.oneuix.hook.util.reflect
import io.github.soclear.oneuix.hook.util.xlog
import java.lang.reflect.Field
import java.lang.reflect.Method
import java.util.concurrent.atomic.AtomicBoolean

@SuppressLint("PrivateApi")
object Other {
Expand Down Expand Up @@ -62,4 +68,86 @@ object Other {
xposedModule.hook(it).intercept { }
}
}

context(xposedModule: XposedModule)
fun deferFaceUnlockUntilSwipe() = afterAttachTry(ONE_UI_VERSION >= 80500) {
val monitorClass = classLoader.loadClass("com.android.keyguard.KeyguardSecUpdateMonitorImpl")

// Members may be inherited from KeyguardUpdateMonitor.
fun fieldOrNull(type: Class<*>, name: String): Field? = runCatching {
type.getDeclaredField(name).apply { isAccessible = true }
}.getOrNull()

fun methodOrNull(type: Class<*>, name: String, vararg parameterTypes: Class<*>): Method? =
runCatching { type.getDeclaredMethod(name, *parameterTypes) }.getOrNull()

fun findField(name: String): Field? {
var type: Class<*>? = monitorClass
while (type != null) {
fieldOrNull(type, name)?.let { return it }
type = type.superclass
}
return null
}

fun findMethod(name: String, vararg parameterTypes: Class<*>): Method? {
var type: Class<*>? = monitorClass
while (type != null) {
methodOrNull(type, name, *parameterTypes)?.let { return it }
type = type.superclass
}
return null
}

val willShowField = findField("mPrimaryBouncerIsOrWillBeShowing")
val fullyShownField = findField("mPrimaryBouncerFullyShown")
val shouldListenForFaceMethod = findMethod("shouldListenForFace")
val bouncerChangedMethod = findMethod(
"handlePrimaryBouncerChanged",
Int::class.javaPrimitiveType!!,
Int::class.javaPrimitiveType!!
)

// Don't suppress face recognition permanently if the state is unavailable.
if ((willShowField == null && fullyShownField == null) ||
shouldListenForFaceMethod == null || bouncerChangedMethod == null
) {
xlog(
"deferFaceUnlockUntilSwipe: required members not found " +
"(fields=${willShowField != null}/${fullyShownField != null}, " +
"methods=${shouldListenForFaceMethod != null}/${bouncerChangedMethod != null})",
priority = Log.WARN
)
return@afterAttachTry
}

val bouncerVisible = AtomicBoolean(false)

fun readBouncerVisible(monitor: Any): Boolean {
fun read(field: Field?): Boolean =
field != null && runCatching { field.getBoolean(monitor) }.getOrDefault(false)
return read(willShowField) || read(fullyShownField)
}

xposedModule.hook(shouldListenForFaceMethod).intercept { chain ->
if (!bouncerVisible.get()) {
bouncerVisible.set(readBouncerVisible(chain.thisObject))
}
if (bouncerVisible.get()) {
chain.proceed()
} else {
false
}
}

xposedModule.hook(bouncerChangedMethod).intercept { chain ->
val isOrWillBeShowing = (chain.args.getOrNull(0) as? Int) == 1
val fullyShown = (chain.args.getOrNull(1) as? Int) == 1
val visible = isOrWillBeShowing || fullyShown
if (bouncerVisible.getAndSet(visible) != visible) {
xlog("bouncer visible=$visible", priority = Log.INFO)
}
chain.proceed()
}
}
}