22
22
package com .dadi590 .assist_c_a .GlobalUtils ;
23
23
24
24
import android .app .Activity ;
25
+ import android .app .AppOpsManager ;
25
26
import android .app .NotificationManager ;
26
27
import android .content .ComponentName ;
27
28
import android .content .Context ;
@@ -116,7 +117,7 @@ public static int checkRequestPerms(@Nullable final Activity activity, final boo
116
117
117
118
final String [][][] list_to_use = PERMS_CONSTS .list_of_perms_lists ;
118
119
final int list_to_use_len = list_to_use .length ;
119
- final boolean force_permissions = (request && activity == null );
120
+ final boolean force_permissions = false ; // todo (request && activity == null); - same reason on the auths function
120
121
int num_not_granted_perms = 0 ;
121
122
122
123
int array_length = 0 ;
@@ -209,7 +210,11 @@ public static int checkRequestAuths(int what_to_do) {
209
210
final String package_name = context .getPackageName ();
210
211
int missing_authorizations = 0 ;
211
212
212
- // todo Remove the comments when you make a way to request VISOR to stop requesting specific permissions
213
+ // todo Remove this when you make a way to request VISOR to stop requesting specific permissions
214
+ // Also I can't test stuff with this thing forcing all auths and perms to be granted...
215
+ if (ALSO_FORCE == what_to_do ) {
216
+ what_to_do = CHECK_ONLY ;
217
+ }
213
218
214
219
if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ) {
215
220
// Check if the DND management policy access has been granted for the app and if not, open the settings
@@ -218,10 +223,10 @@ public static int checkRequestAuths(int what_to_do) {
218
223
getSystemService (Context .NOTIFICATION_SERVICE );
219
224
if (!mNotificationManager .isNotificationPolicyAccessGranted ()) {
220
225
if (ALSO_FORCE == what_to_do ) {
221
- /* final String command = "cmd notification allow_dnd " + package_name;
226
+ final String command = "cmd notification allow_dnd " + package_name ;
222
227
UtilsShell .executeShellCmd (command , false , true );
223
228
224
- missing_authorizations += mNotificationManager.isNotificationPolicyAccessGranted() ? 0 : 1;*/
229
+ missing_authorizations += mNotificationManager .isNotificationPolicyAccessGranted () ? 0 : 1 ;
225
230
} else {
226
231
++missing_authorizations ;
227
232
@@ -236,11 +241,11 @@ public static int checkRequestAuths(int what_to_do) {
236
241
// Check if the app can draw system overlays and open the settings screen if not
237
242
if (!Settings .canDrawOverlays (context )) {
238
243
if (ALSO_FORCE == what_to_do ) {
239
- /* final String command = "appops set " + package_name + " " + AppOpsManager.OP_SYSTEM_ALERT_WINDOW +
244
+ final String command = "appops set " + package_name + " " + AppOpsManager .OP_SYSTEM_ALERT_WINDOW +
240
245
" allow" ;
241
246
UtilsShell .executeShellCmd (command , false , true );
242
247
243
- missing_authorizations += Settings.canDrawOverlays(context) ? 0 : 1;*/
248
+ missing_authorizations += Settings .canDrawOverlays (context ) ? 0 : 1 ;
244
249
} else {
245
250
++missing_authorizations ;
246
251
@@ -257,10 +262,10 @@ public static int checkRequestAuths(int what_to_do) {
257
262
final PowerManager powerManager = (PowerManager ) context .getSystemService (Context .POWER_SERVICE );
258
263
if (!powerManager .isIgnoringBatteryOptimizations (package_name )) {
259
264
if (ALSO_FORCE == what_to_do ) {
260
- /* final String command = "dumpsys deviceidle whitelist +" + package_name;
265
+ final String command = "dumpsys deviceidle whitelist +" + package_name ;
261
266
UtilsShell .executeShellCmd (command , false , true );
262
267
263
- missing_authorizations += powerManager.isIgnoringBatteryOptimizations(package_name) ? 0 : 1;*/
268
+ missing_authorizations += powerManager .isIgnoringBatteryOptimizations (package_name ) ? 0 : 1 ;
264
269
} else {
265
270
++missing_authorizations ;
266
271
@@ -277,11 +282,11 @@ public static int checkRequestAuths(int what_to_do) {
277
282
// Check if the app has the WRITE_SETTINGS permission and request it if not
278
283
if (!Settings .System .canWrite (context )) {
279
284
if (ALSO_FORCE == what_to_do ) {
280
- /* final String command = "appops set " + package_name + " " + AppOpsManager.OP_WRITE_SETTINGS +
285
+ final String command = "appops set " + package_name + " " + AppOpsManager .OP_WRITE_SETTINGS +
281
286
" allow" ;
282
287
UtilsShell .executeShellCmd (command , false , true );
283
288
284
- missing_authorizations += Settings.System.canWrite(context) ? 0 : 1;*/
289
+ missing_authorizations += Settings .System .canWrite (context ) ? 0 : 1 ;
285
290
} else {
286
291
++missing_authorizations ;
287
292
@@ -298,9 +303,9 @@ public static int checkRequestAuths(int what_to_do) {
298
303
299
304
if (!UtilsApp .isDeviceAdmin ()) {
300
305
if (ALSO_FORCE == what_to_do ) {
301
- /* forceDeviceAdmin();
306
+ forceDeviceAdmin ();
302
307
303
- missing_authorizations += UtilsApp.isDeviceAdmin() ? 0 : 1;*/
308
+ missing_authorizations += UtilsApp .isDeviceAdmin () ? 0 : 1 ;
304
309
} else {
305
310
++missing_authorizations ;
306
311
0 commit comments