26
26
import android .net .Uri ;
27
27
import android .os .AsyncTask ;
28
28
import android .os .Binder ;
29
- import android .os .Build ;
29
+ import android .os .Build . VERSION_CODES ;
30
30
import android .os .ParcelFileDescriptor ;
31
31
import android .os .PersistableBundle ;
32
32
import android .os .Process ;
33
33
import android .os .UserHandle ;
34
34
import android .os .UserManager ;
35
35
import android .support .v4 .app .NotificationCompat ;
36
- import android .support .v4 .os .BuildCompat ;
37
36
import android .util .Log ;
38
37
import android .widget .Toast ;
39
38
import com .afwsamples .testdpc .common .NotificationUtil ;
40
39
import com .afwsamples .testdpc .common .Util ;
41
- import com .afwsamples .testdpc .policy .UserRestriction ;
42
40
import com .afwsamples .testdpc .provision .PostProvisioningTask ;
43
41
import java .io .BufferedReader ;
44
42
import java .io .BufferedWriter ;
@@ -92,7 +90,7 @@ public void onReceive(Context context, Intent intent) {
92
90
}
93
91
}
94
92
95
- @ TargetApi (Build . VERSION_CODES .N )
93
+ @ TargetApi (VERSION_CODES .N )
96
94
@ Override
97
95
public void onSecurityLogsAvailable (Context context , Intent intent ) {
98
96
Log .i (TAG , "onSecurityLogsAvailable() called" );
@@ -107,7 +105,7 @@ public void onSecurityLogsAvailable(Context context, Intent intent) {
107
105
* TODO: reconsider how to store and present the logs in the future, e.g. save the file into
108
106
* internal memory and show the content in a ListView
109
107
*/
110
- @ TargetApi (Build . VERSION_CODES .O )
108
+ @ TargetApi (VERSION_CODES .O )
111
109
@ Override
112
110
public void onNetworkLogsAvailable (Context context , Intent intent , long batchToken ,
113
111
int networkLogsCount ) {
@@ -133,7 +131,7 @@ public void onProfileProvisioningComplete(Context context, Intent intent) {
133
131
}
134
132
}
135
133
136
- @ TargetApi (Build . VERSION_CODES .N )
134
+ @ TargetApi (VERSION_CODES .N )
137
135
@ Override
138
136
public void onBugreportSharingDeclined (Context context , Intent intent ) {
139
137
Log .i (TAG , "Bugreport sharing declined" );
@@ -142,7 +140,7 @@ public void onBugreportSharingDeclined(Context context, Intent intent) {
142
140
NotificationUtil .BUGREPORT_NOTIFICATION_ID );
143
141
}
144
142
145
- @ TargetApi (Build . VERSION_CODES .N )
143
+ @ TargetApi (VERSION_CODES .N )
146
144
@ Override
147
145
public void onBugreportShared (final Context context , Intent intent ,
148
146
final String bugreportFileHash ) {
@@ -190,7 +188,7 @@ protected void onPostExecute(String message) {
190
188
}.execute ();
191
189
}
192
190
193
- @ TargetApi (Build . VERSION_CODES .N )
191
+ @ TargetApi (VERSION_CODES .N )
194
192
@ Override
195
193
public void onBugreportFailed (Context context , Intent intent , int failureCode ) {
196
194
String failureReason ;
@@ -212,42 +210,42 @@ public void onBugreportFailed(Context context, Intent intent, int failureCode) {
212
210
}
213
211
214
212
215
- @ TargetApi (Build . VERSION_CODES .O )
213
+ @ TargetApi (VERSION_CODES .O )
216
214
@ Override
217
215
public void onUserAdded (Context context , Intent intent , UserHandle newUser ) {
218
216
handleUserAction (context , newUser , R .string .on_user_added_title ,
219
217
R .string .on_user_added_message , NotificationUtil .USER_ADDED_NOTIFICATION_ID );
220
218
}
221
219
222
- @ TargetApi (Build . VERSION_CODES .O )
220
+ @ TargetApi (VERSION_CODES .O )
223
221
@ Override
224
222
public void onUserRemoved (Context context , Intent intent , UserHandle removedUser ) {
225
223
handleUserAction (context , removedUser , R .string .on_user_removed_title ,
226
224
R .string .on_user_removed_message , NotificationUtil .USER_REMOVED_NOTIFICATION_ID );
227
225
}
228
226
229
- @ TargetApi (Build . VERSION_CODES .P )
227
+ @ TargetApi (VERSION_CODES .P )
230
228
@ Override
231
229
public void onUserStarted (Context context , Intent intent , UserHandle startedUser ) {
232
230
handleUserAction (context , startedUser , R .string .on_user_started_title ,
233
231
R .string .on_user_started_message , NotificationUtil .USER_STARTED_NOTIFICATION_ID );
234
232
}
235
233
236
- @ TargetApi (Build . VERSION_CODES .P )
234
+ @ TargetApi (VERSION_CODES .P )
237
235
@ Override
238
236
public void onUserStopped (Context context , Intent intent , UserHandle stoppedUser ) {
239
237
handleUserAction (context , stoppedUser , R .string .on_user_stopped_title ,
240
238
R .string .on_user_stopped_message , NotificationUtil .USER_STOPPED_NOTIFICATION_ID );
241
239
}
242
240
243
- @ TargetApi (Build . VERSION_CODES .P )
241
+ @ TargetApi (VERSION_CODES .P )
244
242
@ Override
245
243
public void onUserSwitched (Context context , Intent intent , UserHandle switchedUser ) {
246
244
handleUserAction (context , switchedUser , R .string .on_user_switched_title ,
247
245
R .string .on_user_switched_message , NotificationUtil .USER_SWITCHED_NOTIFICATION_ID );
248
246
}
249
247
250
- @ TargetApi (Build . VERSION_CODES .M )
248
+ @ TargetApi (VERSION_CODES .M )
251
249
@ Override
252
250
public void onSystemUpdatePending (Context context , Intent intent , long receivedTime ) {
253
251
if (receivedTime != -1 ) {
@@ -260,7 +258,7 @@ public void onSystemUpdatePending(Context context, Intent intent, long receivedT
260
258
}
261
259
}
262
260
263
- @ TargetApi (Build . VERSION_CODES .M )
261
+ @ TargetApi (VERSION_CODES .M )
264
262
@ Override
265
263
public String onChoosePrivateKeyAlias (Context context , Intent intent , int uid , Uri uri ,
266
264
String alias ) {
@@ -281,7 +279,7 @@ public void onPasswordExpiring(Context context, Intent intent) {
281
279
onPasswordExpiring (context , intent , Process .myUserHandle ());
282
280
}
283
281
284
- @ TargetApi (Build . VERSION_CODES .O )
282
+ @ TargetApi (VERSION_CODES .O )
285
283
// @Override
286
284
public void onPasswordExpiring (Context context , Intent intent , UserHandle user ) {
287
285
if (!Process .myUserHandle ().equals (user )) {
@@ -309,7 +307,7 @@ public void onPasswordFailed(Context context, Intent intent) {
309
307
onPasswordFailed (context , intent , Process .myUserHandle ());
310
308
}
311
309
312
- @ TargetApi (Build . VERSION_CODES .O )
310
+ @ TargetApi (VERSION_CODES .O )
313
311
// @Override
314
312
public void onPasswordFailed (Context context , Intent intent , UserHandle user ) {
315
313
if (!Process .myUserHandle ().equals (user )) {
@@ -372,7 +370,7 @@ public void onPasswordSucceeded(Context context, Intent intent) {
372
370
onPasswordSucceeded (context , intent , Process .myUserHandle ());
373
371
}
374
372
375
- @ TargetApi (Build . VERSION_CODES .O )
373
+ @ TargetApi (VERSION_CODES .O )
376
374
// @Override
377
375
public void onPasswordSucceeded (Context context , Intent intent , UserHandle user ) {
378
376
if (Process .myUserHandle ().equals (user )) {
@@ -386,7 +384,7 @@ public void onPasswordChanged(Context context, Intent intent) {
386
384
onPasswordChanged (context , intent , Process .myUserHandle ());
387
385
}
388
386
389
- @ TargetApi (Build . VERSION_CODES .O )
387
+ @ TargetApi (VERSION_CODES .O )
390
388
// @Override
391
389
public void onPasswordChanged (Context context , Intent intent , UserHandle user ) {
392
390
if (Process .myUserHandle ().equals (user )) {
@@ -478,7 +476,7 @@ private static void updatePasswordConstraintNotification(Context context) {
478
476
problems .add (context .getText (R .string .password_not_compliant_title ));
479
477
}
480
478
481
- if (um .hasUserRestriction (UserRestriction .DISALLOW_UNIFIED_PASSWORD )
479
+ if (um .hasUserRestriction (UserManager .DISALLOW_UNIFIED_PASSWORD )
482
480
&& Util .isManagedProfileOwner (context )
483
481
&& isUsingUnifiedPassword (context )) {
484
482
problems .add (context .getText (R .string .separate_challenge_required_title ));
@@ -504,9 +502,9 @@ && isUsingUnifiedPassword(context)) {
504
502
}
505
503
}
506
504
507
- @ TargetApi (28 )
505
+ @ TargetApi (VERSION_CODES . P )
508
506
private static Boolean isUsingUnifiedPassword (Context context ) {
509
- if (! BuildCompat . isAtLeastP () ) {
507
+ if (Util . SDK_INT < VERSION_CODES . P ) {
510
508
return false ;
511
509
}
512
510
final DevicePolicyManager dpm = context .getSystemService (DevicePolicyManager .class );
@@ -546,7 +544,7 @@ private void onDeviceOwnerChanged(Context context) {
546
544
NotificationUtil .DEVICE_OWNER_CHANGED_ID );
547
545
}
548
546
549
- @ TargetApi (Build . VERSION_CODES .P )
547
+ @ TargetApi (VERSION_CODES .P )
550
548
public void onTransferOwnershipComplete (Context context , PersistableBundle bundle ) {
551
549
Log .i (TAG , "onTransferOwnershipComplete" );
552
550
NotificationUtil .showNotification (context ,
@@ -556,7 +554,7 @@ public void onTransferOwnershipComplete(Context context, PersistableBundle bundl
556
554
NotificationUtil .TRANSFER_OWNERSHIP_COMPLETE_ID );
557
555
}
558
556
559
- @ TargetApi (Build . VERSION_CODES .P )
557
+ @ TargetApi (VERSION_CODES .P )
560
558
public void onTransferAffiliatedProfileOwnershipComplete (Context context , UserHandle user ) {
561
559
Log .i (TAG , "onTransferAffiliatedProfileOwnershipComplete" );
562
560
NotificationUtil .showNotification (context ,
0 commit comments