83
83
import com .afwsamples .testdpc .common .MediaDisplayFragment ;
84
84
import com .afwsamples .testdpc .common .Util ;
85
85
import com .afwsamples .testdpc .common .CertificateUtil ;
86
- import com .afwsamples .testdpc .common .ReflectionUtil ;
87
86
import com .afwsamples .testdpc .common .preference .DpcPreference ;
88
87
import com .afwsamples .testdpc .common .preference .DpcPreferenceBase ;
89
88
import com .afwsamples .testdpc .common .preference .DpcPreferenceHelper ;
@@ -2312,14 +2311,16 @@ protected void setPermittedComponentsList(List<String> permittedInputMethods) {
2312
2311
}
2313
2312
}
2314
2313
2314
+ @ TargetApi (Build .VERSION_CODES .O )
2315
2315
private void setNotificationWhitelistEditBox () {
2316
2316
if (getActivity () == null || getActivity ().isFinishing ()) {
2317
2317
return ;
2318
2318
}
2319
2319
View view = getActivity ().getLayoutInflater ().inflate (R .layout .simple_edittext , null );
2320
2320
final EditText input = (EditText ) view .findViewById (R .id .input );
2321
2321
input .setHint (getString (R .string .set_notification_listener_text_hint ));
2322
- List <String > enabledComponents = getPermittedNotificationListeners ();
2322
+ List <String > enabledComponents = mDevicePolicyManager .
2323
+ getPermittedCrossProfileNotificationListeners (mAdminComponentName );
2323
2324
if (enabledComponents == null ) {
2324
2325
input .setText ("null" );
2325
2326
} else {
@@ -2368,8 +2369,10 @@ protected List<ResolveInfo> getResolveInfoListFromAvailableComponents(
2368
2369
}
2369
2370
2370
2371
@ Override
2372
+ @ TargetApi (Build .VERSION_CODES .O )
2371
2373
protected List <String > getPermittedComponentsList () {
2372
- return getPermittedNotificationListeners ();
2374
+ return mDevicePolicyManager .
2375
+ getPermittedCrossProfileNotificationListeners (mAdminComponentName );
2373
2376
}
2374
2377
2375
2378
@ Override
@@ -2378,35 +2381,17 @@ protected void setPermittedComponentsList(List<String> permittedNotificationList
2378
2381
}
2379
2382
}
2380
2383
2384
+ @ TargetApi (Build .VERSION_CODES .O )
2381
2385
private void setPermittedNotificationListeners (List <String > permittedNotificationListeners ) {
2382
- // STOPSHIP: Call actual method once in the SDK
2383
- boolean result ;
2384
- try {
2385
- result = (boolean ) ReflectionUtil .invoke (mDevicePolicyManager ,
2386
- "setPermittedCrossProfileNotificationListeners" ,
2387
- new Class <?>[] {ComponentName .class , List .class },
2388
- mAdminComponentName , permittedNotificationListeners );
2389
- } catch (ReflectionUtil .ReflectionIsTemporaryException e ) {
2390
- Log .e (TAG , "Setting permitted notification listeners failed" , e );
2391
- result = false ;
2392
- }
2386
+ boolean result = mDevicePolicyManager .
2387
+ setPermittedCrossProfileNotificationListeners (
2388
+ mAdminComponentName , permittedNotificationListeners );
2393
2389
int successMsgId = (permittedNotificationListeners == null )
2394
2390
? R .string .all_notification_listeners_enabled
2395
2391
: R .string .set_notification_listeners_successful ;
2396
2392
showToast (result ? successMsgId : R .string .set_notification_listeners_fail );
2397
2393
}
2398
2394
2399
- private List <String > getPermittedNotificationListeners () {
2400
- // STOPSHIP: Call actual method once in the SDK
2401
- try {
2402
- return (List <String >) ReflectionUtil .invoke (mDevicePolicyManager ,
2403
- "getPermittedCrossProfileNotificationListeners" , mAdminComponentName );
2404
- } catch (ReflectionUtil .ReflectionIsTemporaryException e ) {
2405
- Log .e (TAG , "Setting permitted notification listeners failed" , e );
2406
- }
2407
- return null ;
2408
- }
2409
-
2410
2395
/**
2411
2396
* Gets all CA certificates and displays them in a prompt.
2412
2397
*/
0 commit comments