Commit f4f8eec
committed
refactor(auth): Implement Device Admin for screen lock
This commit refactors the screen lock functionality to prioritize using the Device Administrator API, which is more stable than the Accessibility Service method.
Key changes include:
- A new `DeviceAdmin` receiver to handle device admin enabling/disabling.
- Updated `lockPhone` logic in `HomeFragment` to check for and use Device Admin permissions first.
- If Device Admin is not enabled, the system will prompt the user to grant permission.
- The Accessibility Service (`ActionService`) is now a fallback method for locking the screen.
- Necessary permissions and receiver declarations have been added to `AndroidManifest.xml`.
- XML configuration for the Device Admin receiver has been created.1 parent 20fbeb0 commit f4f8eec
File tree
5 files changed
+95
-33
lines changed- app/src/main
- java/com/github/droidworksstudio/mlauncher
- helper/receivers
- services
- ui
- res/xml
5 files changed
+95
-33
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
7 | 8 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 9 | + | |
| 10 | + | |
17 | 11 | | |
18 | 12 | | |
19 | 13 | | |
| |||
23 | 17 | | |
24 | 18 | | |
25 | 19 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
| 20 | + | |
| 21 | + | |
35 | 22 | | |
36 | 23 | | |
37 | 24 | | |
| |||
59 | 46 | | |
60 | 47 | | |
61 | 48 | | |
62 | | - | |
| 49 | + | |
| 50 | + | |
63 | 51 | | |
64 | 52 | | |
65 | 53 | | |
66 | 54 | | |
67 | | - | |
| 55 | + | |
| 56 | + | |
68 | 57 | | |
69 | 58 | | |
70 | 59 | | |
| |||
79 | 68 | | |
80 | 69 | | |
81 | 70 | | |
82 | | - | |
| 71 | + | |
| 72 | + | |
83 | 73 | | |
84 | 74 | | |
85 | 75 | | |
86 | 76 | | |
87 | 77 | | |
88 | | - | |
| 78 | + | |
| 79 | + | |
89 | 80 | | |
90 | 81 | | |
91 | 82 | | |
92 | 83 | | |
93 | | - | |
| 84 | + | |
| 85 | + | |
94 | 86 | | |
95 | 87 | | |
96 | 88 | | |
| |||
104 | 96 | | |
105 | 97 | | |
106 | 98 | | |
107 | | - | |
| 99 | + | |
| 100 | + | |
108 | 101 | | |
109 | 102 | | |
110 | 103 | | |
| |||
119 | 112 | | |
120 | 113 | | |
121 | 114 | | |
122 | | - | |
| 115 | + | |
| 116 | + | |
123 | 117 | | |
124 | 118 | | |
125 | 119 | | |
| |||
130 | 124 | | |
131 | 125 | | |
132 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
133 | 142 | | |
134 | 143 | | |
135 | 144 | | |
| |||
145 | 154 | | |
146 | 155 | | |
147 | 156 | | |
148 | | - | |
149 | | - | |
| 157 | + | |
150 | 158 | | |
151 | 159 | | |
152 | 160 | | |
| |||
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
Lines changed: 25 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
48 | | - | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
| |||
743 | 744 | | |
744 | 745 | | |
745 | 746 | | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
746 | 750 | | |
747 | | - | |
748 | | - | |
749 | | - | |
750 | | - | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
751 | 770 | | |
752 | 771 | | |
753 | 772 | | |
| 773 | + | |
754 | 774 | | |
755 | 775 | | |
756 | 776 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
0 commit comments