Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] 为 OwnDroid 添加启动时 PIN 锁 #20

Closed
Minoricew opened this issue May 12, 2024 · 75 comments
Closed

[Feature Request] 为 OwnDroid 添加启动时 PIN 锁 #20

Minoricew opened this issue May 12, 2024 · 75 comments

Comments

@Minoricew
Copy link
Collaborator

Minoricew commented May 12, 2024

Describe the issue / 描述问题

OwnDroid 功能涉及 Device owner 等高权限的操作, 部分情况下未经授权的操作可能导致危险。

Expected implementation / 预期实现

允许用户在 OwnDroid 内设置 PIN 码 / 解锁手势, 置于后台超过指定时间 / 应用重启后自动锁定。

FAQ / 疑问解答

Q: 现在国内系统不是都自带应用锁功能嘛?

A: 类原生用户应该还是不少的吧... (Lineage 除外, 启动器自带应用锁) 以及海外 UI 也基本上没有应用锁功能。

@BinTianqi
Copy link
Owner

好主意

可以直接用安卓sdk的KeyguardManager和BiometricManager,用锁屏密码和指纹验证

@Minoricew
Copy link
Collaborator Author

好主意

可以直接用安卓sdk的KeyguardManager和BiometricManager,用锁屏密码和指纹验证

对哦, 这样代码写起来也比较方便, 用户体验也无缝不少。

@BinTianqi

This comment was marked as off-topic.

@Minoricew

This comment was marked as off-topic.

@BinTianqi

This comment was marked as off-topic.

@Minoricew

This comment was marked as off-topic.

@BinTianqi

This comment was marked as off-topic.

@Minoricew

This comment was marked as off-topic.

@Minoricew
Copy link
Collaborator Author

Describe the issue / 描述问题

OwnDroid 功能涉及 Device owner 等高权限的操作, 部分情况下未经授权的操作可能导致危险。

Expected implementation / 预期实现

允许用户在 OwnDroid 内设置 PIN 码 / 解锁手势, 置于后台超过指定时间 / 应用重启后自动锁定。

FAQ / 疑问解答

Q: 现在国内系统不是都自带应用锁功能嘛?

A: 类原生用户应该还是不少的吧... (Lineage 除外, 启动器自带应用锁) 以及海外 UI 也基本上没有应用锁功能。

我现在想到了这个功能的一个使用场景。

1000016512.png

@BinTianqi

This comment was marked as off-topic.

@Minoricew

This comment was marked as off-topic.

@BinTianqi

This comment was marked as off-topic.

@Minoricew

This comment was marked as off-topic.

@BinTianqi
Copy link
Owner

BinTianqi commented May 14, 2024

开始做了😀 11bd8a2

本来想用compose的Navigation做验证页和主页的切换,但是compose的导航不好用,所以多加了一个activity,但是多一个activity后启动速度慢了好多😭

现在想想,还是试试fragment吧

@Minoricew

This comment was marked as off-topic.

@BinTianqi
Copy link
Owner

BinTianqi commented May 14, 2024

不是多activity导致卡,而是启动owndroid之后,MainActivity判断有没有解锁,没解锁就跳转到AuthActivity,AuthActivity解锁完了再跳转回MainActivity,如果解锁了就直接显示内容

就是跳转的时候有点卡

(在我这个骁龙855的一加7上没什么感觉,但是在骁龙675的红米note7pro会卡)

ci啊,等6.0之后或者commit了200个之后吧

刚开始做的时候一天一个小版本,现在没啥功能可以做了,一周一个了😂

@Minoricew

This comment was marked as off-topic.

@BinTianqi
Copy link
Owner

话说现在是每次重启 OwnDroid 后需要认证还是锁屏后才需要认证

杀后台之后需要验证

其实好像可以直接把 AuthActivity 作为入口活动吧。

感觉还是MainActivity做入口好,如果AuthActivity做入口了,那每次通过桌面图标进Owndroid又得跳转一次

@Minoricew

This comment was marked as off-topic.

@BinTianqi

This comment was marked as off-topic.

@Minoricew

This comment was marked as off-topic.

@Minoricew

This comment was marked as off-topic.

@BinTianqi
Copy link
Owner

BinTianqi commented May 15, 2024

换成Fragment了 b7f6eea

支持生物识别了 405b897

GenDino 好像是一个发布会的小游戏, 可惜我谷歌账号被锁区了, 所有 Genmini 相关的功能都用不了。

我能登录谷歌账号但是玩不了。原来是锁区啊,我在Android studio里面也用不了gemini

@Minoricew

This comment was marked as off-topic.

@Minoricew

This comment was marked as off-topic.

@Minoricew Minoricew reopened this May 15, 2024
@BinTianqi

This comment was marked as off-topic.

@Minoricew

This comment was marked as off-topic.

@BinTianqi
Copy link
Owner

差不多做好了

来看看

owndroid-auth.zip

@BinTianqi

This comment was marked as off-topic.

@Minoricew
Copy link
Collaborator Author

这种情况下如果在 Home 里面加个判断, 如果未 Auth 就不响应任何页面请求, 可能吗?

能防止点击但是应该拦不住返回键

不过好像能防止点击就行了吧... 返回键毕竟做不了什么。

但这样用户难道就不能点击下面的内容了嘛 (?)

应该可以改

哦哦, 这样。

@BinTianqi
Copy link
Owner

应该用一个ViewModel类存住所有变量

验证时不显示Home,验证完了用这些变量恢复界面

@Minoricew
Copy link
Collaborator Author

应该用一个ViewModel类存住所有变量

验证时不显示Home,验证完了用这些变量恢复界面

有道理。

@BinTianqi
Copy link
Owner

BinTianqi commented May 19, 2024

试着用viewModel存住状态,但是嵌套的NavHost不能用viewModel

比如,进入应用管理、回到主页、再进入应用管理,就会崩溃: java.lang.IllegalStateException: ViewModelStore should be set before setGraph call

所以现在的方法应该只有一个了,就是用Fragment

@Minoricew
Copy link
Collaborator Author

试着用viewModel存住状态,但是嵌套的NavHost不能用viewModel

比如,进入应用管理、回到主页、再进入应用管理,就会崩溃: java.lang.IllegalStateException: ViewModelStore should be set before setGraph call

翻到一篇这个, 但看不懂。

所以现在的方法应该只有一个了,就是用Fragment

回归初心了。

@BinTianqi
Copy link
Owner

BinTianqi commented May 19, 2024

翻到一篇这个, 但看不懂。

我在百度上搜这个Exception,搜到了StackOverflow里面这个问题的机翻

回归初心了。

😭😭😭白搞了

@BinTianqi
Copy link
Owner

BinTianqi commented May 19, 2024

已经回滚代码了,给AuthFragment加了个背景并设置clickable = true,但返回键还是由NavHost监听

还是得改NavHost

我在百度上搜索 怎么防止compose navhost监听返回键,那个百度AI回答了这个

import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalFocusManager
import androidx.activity.OnBackPressedDispatcher
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.remember
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.rememberNavController
 
@Composable
fun PreventBackPressNavHost(
    onBackPressDispatcher: OnBackPressedDispatcher,
    navController: NavHostController = rememberNavController(),
    content: @Composable () -> Unit
) {
    var isEnabled by remember { mutableStateOf(false) }
 
    val focusManager = LocalFocusManager.current
 
    DisposableEffect(onBackPressDispatcher) {
        val callback = onBackPressDispatcher.addCallback(object : OnBackPressedCallback(true) {
            override fun handleOnBackPressed() {
                if (isEnabled) isEnabled = false
            }
        })
        callback.isEnabled = isEnabled
 
        onDispose {
            callback.remove()
        }
    }
 
    NavHost(navController = navController, startDestination = "home") {
        composable("home") {
            content()
            DisposableEffect(Unit) {
                val backCallback = navController.addBackPressCallback {
                    isEnabled = true
                    focusManager.clearFocus()
                }
                onDispose {
                    backCallback.remove()
                }
            }
        }
    }
}

BinTianqi added a commit that referenced this issue May 19, 2024
use composable function instead of fragment to display authenticate screen
fix authenticate screen is transparent in light theme
@Minoricew

This comment was marked as off-topic.

@BinTianqi
Copy link
Owner

BinTianqi commented May 19, 2024

v5.3.1已经发了

现在又改回纯compose。在 处于后台时锁定 的开关底下加了个“功能开发中”

APK仍然是2.2MB,biometric库的锅,不知道这个库塞了什么💩

Screenshot from 2024-05-19 20-41-45

超长 Issue, 甚至 56 个回复

一开始聊off-topic聊多了😂

@Minoricew
Copy link
Collaborator Author

v5.3.1已经发了

任务完成 🎉

现在又改回纯compose。在 处于后台时锁定 的开关底下加了个“功能开发中”

功能画饼中 (不是

APK仍然是2.2MB,biometric库的锅,不知道这个库塞了什么💩

Screenshot from 2024-05-19 20-41-45

好像是塞了好多 Material Icons, 但有些感觉完全用不到, 还是塞进去了。

超长 Issue, 甚至 56 个回复

一开始聊off-topic聊多了😂

是这样的, 就像 QAuxv 群里根本没人聊 QAuxiliary (确信

话说日用 Ubuntu 不会很痛苦嘛, 之前试过, 软件生态其实还没完全起来... 外加 NVIDIA 的 GPU 驱动其实对 Linux 的兼容也不算很好, 后面还是回万恶的 Win 了。
或者说这是双系统?

@BinTianqi

This comment was marked as off-topic.

@BinTianqi
Copy link
Owner

大概两周之前,我发现这个app被上架IzzySoft了,不知道谁好心去弄的

https://apt.izzysoft.de/fdroid/index/apk/com.bintianqi.owndroid

今天一看,发现没有v5.3,有v5.2和v5.3.1

怎么,这都能撤包?

@Minoricew

This comment was marked as off-topic.

@Minoricew
Copy link
Collaborator Author

大概两周之前,我发现这个app被上架IzzySoft了,不知道谁好心去弄的

https://apt.izzysoft.de/fdroid/index/apk/com.bintianqi.owndroid

甚至官方 F-droid 也有好心人帮忙提交了请求

今天一看,发现没有v5.3,有v5.2和v5.3.1

怎么,这都能撤包?

比较高级的一集

@BinTianqi
Copy link
Owner

Terminal Systemizer 设系统应用直接进 Boot loop 了, 还好装了救砖模块 ()

可能是被设为系统应用的那个app乱搞

甚至官方 F-droid 也有好心人帮忙提交了请求

听说在f-droid上架需要用他的服务器构建,而且用fdroid的签名,感觉怪怪的。Rikka以前不同意shizuku上架fdroid就是因为这个RikkaApps/Shizuku#69

画饼:人家fdroid能构建,咱自己的action也得跑起来

@Minoricew

This comment was marked as off-topic.

@BinTianqi

This comment was marked as off-topic.

@BinTianqi

This comment was marked as off-topic.

@Minoricew

This comment was marked as off-topic.

@BinTianqi
Copy link
Owner

BinTianqi commented May 27, 2024

基于API23没有系统自带的指纹识别弹框,当我们调用指纹传感器时需要提供指纹UI去提示用户,从而让用户知道指纹传感器已经开始工作从而将手指放入传感器之上,Biomteric依赖库将会库提供自带的UI或者系统UI

难怪biometric库乱拉屎

想知道biometric库自带的弹窗是怎么样的

@Minoricew

This comment was marked as off-topic.

@BinTianqi

This comment was marked as off-topic.

@Minoricew

This comment was marked as off-topic.

@BinTianqi

This comment was marked as off-topic.

@Minoricew

This comment was marked as off-topic.

@BinTianqi

This comment was marked as off-topic.

@Minoricew

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants