@@ -2758,12 +2758,14 @@ private void reloadCommonCriteriaModeUi() {
2758
2758
2759
2759
@ TargetApi (VERSION_CODES .S )
2760
2760
private void reloadEnableUsbDataSignalingUi () {
2761
- try {
2762
- boolean enabled = ReflectionUtil .invoke (mDevicePolicyManager ,
2761
+ if (isOrganizationOwnedDevice ()) {
2762
+ try {
2763
+ boolean enabled = ReflectionUtil .invoke (mDevicePolicyManager ,
2763
2764
"isUsbDataSignalingEnabled" );
2764
- mEnableUsbDataSignalingPreference .setChecked (enabled );
2765
- } catch (ReflectionIsTemporaryException e ) {
2766
- Log .e (TAG , "Error invoking isUsbDataSignalingEnabled" , e );
2765
+ mEnableUsbDataSignalingPreference .setChecked (enabled );
2766
+ } catch (ReflectionIsTemporaryException e ) {
2767
+ Log .e (TAG , "Error invoking isUsbDataSignalingEnabled" , e );
2768
+ }
2767
2769
}
2768
2770
}
2769
2771
@@ -2793,12 +2795,7 @@ private void reloadSetAutoTimeUi() {
2793
2795
if (Util .SDK_INT < VERSION_CODES .R ) {
2794
2796
return ;
2795
2797
}
2796
- boolean isOrgOwned =
2797
- mDevicePolicyManagerGateway .isOrganizationOwnedDeviceWithManagedProfile ();
2798
-
2799
- if (mDevicePolicyManager .isDeviceOwnerApp (mPackageName )
2800
- || (mDevicePolicyManager .isProfileOwnerApp (mPackageName )
2801
- && isOrgOwned )) {
2798
+ if (isOrganizationOwnedDevice ()) {
2802
2799
boolean isAutoTime = mDevicePolicyManager .getAutoTimeEnabled (mAdminComponentName );
2803
2800
mSetAutoTimePreference .setChecked (isAutoTime );
2804
2801
}
@@ -2809,12 +2806,7 @@ private void reloadSetAutoTimeZoneUi() {
2809
2806
if (Util .SDK_INT < VERSION_CODES .R ) {
2810
2807
return ;
2811
2808
}
2812
- boolean isOrgOwned =
2813
- mDevicePolicyManagerGateway .isOrganizationOwnedDeviceWithManagedProfile ();
2814
-
2815
- if (mDevicePolicyManager .isDeviceOwnerApp (mPackageName )
2816
- || (mDevicePolicyManager .isProfileOwnerApp (mPackageName )
2817
- && isOrgOwned )) {
2809
+ if (isOrganizationOwnedDevice ()) {
2818
2810
boolean isAutoTimeZone = mDevicePolicyManager
2819
2811
.getAutoTimeZoneEnabled (mAdminComponentName );
2820
2812
mSetAutoTimeZonePreference .setChecked (isAutoTimeZone );
@@ -4345,6 +4337,12 @@ private void factoryResetOrgOwnedDevice() {
4345
4337
(e ) -> onErrorLog ("wipeData" , e ));
4346
4338
}
4347
4339
4340
+ private boolean isOrganizationOwnedDevice () {
4341
+ return mDevicePolicyManager .isDeviceOwnerApp (mPackageName )
4342
+ || (mDevicePolicyManager .isProfileOwnerApp (mPackageName )
4343
+ && mDevicePolicyManagerGateway .isOrganizationOwnedDeviceWithManagedProfile ());
4344
+ }
4345
+
4348
4346
private int validateDeviceOwnerBeforeO () {
4349
4347
if (Util .SDK_INT < VERSION_CODES .O ) {
4350
4348
if (!mDevicePolicyManager .isDeviceOwnerApp (mPackageName )) {
0 commit comments