@@ -61,6 +61,21 @@ public static class SecurityConfig {
61
61
private final SecurityCheckState keyloggerCheck ;
62
62
private final SecurityCheckState appSignature ;
63
63
private final SecurityCheckState ongoingCallCheck ;
64
+
65
+ // Customizable dialog options with defaults
66
+ private String criticalDialogTitle = "Security Error" ;
67
+ private String warningDialogTitle = "Security Warning" ;
68
+ private String criticalDialogPositiveButton = "Quit" ;
69
+ private String warningDialogPositiveButton = "Continue Anyway" ;
70
+ private String criticalDialogNegativeButton = null ;
71
+ private String warningDialogNegativeButton = null ;
72
+
73
+ public String getCriticalDialogTitle () { return criticalDialogTitle ; }
74
+ public String getWarningDialogTitle () { return warningDialogTitle ; }
75
+ public String getCriticalDialogPositiveButton () { return criticalDialogPositiveButton ; }
76
+ public String getWarningDialogPositiveButton () { return warningDialogPositiveButton ; }
77
+ public String getCriticalDialogNegativeButton () { return criticalDialogNegativeButton ; }
78
+ public String getWarningDialogNegativeButton () { return warningDialogNegativeButton ; }
64
79
private final String expectedPackageName ;
65
80
private final String expectedSignature ;
66
81
@@ -90,10 +105,38 @@ public SecurityConfig(
90
105
SecurityCheckState networkSecurityCheck ,
91
106
SecurityCheckState screenSharingCheck ,
92
107
SecurityCheckState keyloggerCheck ,
93
- SecurityCheckState ongoingCallCheck ,
94
108
SecurityCheckState appSignature ,
109
+ SecurityCheckState ongoingCallCheck ,
95
110
String expectedPackageName ,
96
111
String expectedSignature
112
+ ) {
113
+ this (rootCheck , developerOptionsCheck , malwareCheck , tamperingCheck , appSpoofingCheck , networkSecurityCheck ,
114
+ screenSharingCheck , keyloggerCheck , appSignature , ongoingCallCheck , expectedPackageName , expectedSignature ,
115
+ "Security Error" , "Security Warning" , "Quit" , "Continue Anyway" , null , null );
116
+ }
117
+
118
+ /**
119
+ * Extended constructor to allow dialog customization at runtime.
120
+ */
121
+ public SecurityConfig (
122
+ SecurityCheckState rootCheck ,
123
+ SecurityCheckState developerOptionsCheck ,
124
+ SecurityCheckState malwareCheck ,
125
+ SecurityCheckState tamperingCheck ,
126
+ SecurityCheckState appSpoofingCheck ,
127
+ SecurityCheckState networkSecurityCheck ,
128
+ SecurityCheckState screenSharingCheck ,
129
+ SecurityCheckState keyloggerCheck ,
130
+ SecurityCheckState appSignature ,
131
+ SecurityCheckState ongoingCallCheck ,
132
+ String expectedPackageName ,
133
+ String expectedSignature ,
134
+ String criticalDialogTitle ,
135
+ String warningDialogTitle ,
136
+ String criticalDialogPositiveButton ,
137
+ String warningDialogPositiveButton ,
138
+ String criticalDialogNegativeButton ,
139
+ String warningDialogNegativeButton
97
140
) {
98
141
this .rootCheck = rootCheck ;
99
142
this .developerOptionsCheck = developerOptionsCheck ;
@@ -107,6 +150,12 @@ public SecurityConfig(
107
150
this .ongoingCallCheck = ongoingCallCheck ;
108
151
this .expectedPackageName = expectedPackageName ;
109
152
this .expectedSignature = expectedSignature ;
153
+ this .criticalDialogTitle = criticalDialogTitle ;
154
+ this .warningDialogTitle = warningDialogTitle ;
155
+ this .criticalDialogPositiveButton = criticalDialogPositiveButton ;
156
+ this .warningDialogPositiveButton = warningDialogPositiveButton ;
157
+ this .criticalDialogNegativeButton = criticalDialogNegativeButton ;
158
+ this .warningDialogNegativeButton = warningDialogNegativeButton ;
110
159
}
111
160
112
161
// Getters
@@ -302,10 +351,15 @@ private void showNextDialog(Context context) {
302
351
isShowingDialog = true ;
303
352
SecurityDialogInfo dialogInfo = dialogQueue .remove (0 );
304
353
305
- AlertDialog dialog = new AlertDialog .Builder (context )
306
- .setTitle (dialogInfo .isCritical ? "Security Error" : "Security Warning" )
354
+ // Use dialog options directly from config
355
+ String title = dialogInfo .isCritical ? config .getCriticalDialogTitle () : config .getWarningDialogTitle ();
356
+ String positiveButton = dialogInfo .isCritical ? config .getCriticalDialogPositiveButton () : config .getWarningDialogPositiveButton ();
357
+ String negativeButton = dialogInfo .isCritical ? config .getCriticalDialogNegativeButton () : config .getWarningDialogNegativeButton ();
358
+
359
+ AlertDialog .Builder builder = new AlertDialog .Builder (context )
360
+ .setTitle (title )
307
361
.setMessage (dialogInfo .message )
308
- .setPositiveButton (dialogInfo . isCritical ? "Quit" : "Continue Anyway" , (dialogInterface , which ) -> {
362
+ .setPositiveButton (positiveButton , (dialogInterface , which ) -> {
309
363
dialogInterface .dismiss ();
310
364
if (dialogInfo .isCritical ) {
311
365
System .exit (0 );
@@ -317,8 +371,16 @@ private void showNextDialog(Context context) {
317
371
showNextDialog (context );
318
372
}
319
373
})
320
- .setCancelable (!dialogInfo .isCritical )
321
- .create ();
374
+ .setCancelable (!dialogInfo .isCritical );
375
+ if (negativeButton != null && !negativeButton .isEmpty ()) {
376
+ builder .setNegativeButton (negativeButton , (dialogInterface , which ) -> {
377
+ dialogInterface .dismiss ();
378
+ // Optionally handle negative button click here if needed
379
+ isShowingDialog = false ;
380
+ showNextDialog (context );
381
+ });
382
+ }
383
+ AlertDialog dialog = builder .create ();
322
384
323
385
dialog .setOnDismissListener (dialogInterface -> {
324
386
if (!dialogInfo .isCritical ) {
0 commit comments