Loading android/app/src/com/android/bluetooth/btservice/AdapterService.java +3 −1 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.app.AlarmManager; import android.app.AppOpsManager; import android.app.PendingIntent; import android.app.Service; import android.app.admin.DevicePolicyManager; import android.bluetooth.BluetoothActivityEnergyInfo; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAdapter.ActiveDeviceUse; Loading Loading @@ -3008,7 +3009,8 @@ public class AdapterService extends Service { } private boolean isNiapMode() { return Settings.Global.getInt(getContentResolver(), "common_criteria_mode", 0) == 1; return ((DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE)) .isCommonCriteriaModeEnabled(null); } /** Loading android/app/tests/unit/src/com/android/bluetooth/btservice/AdapterServiceTest.java +6 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; import android.app.AlarmManager; import android.app.admin.DevicePolicyManager; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.IBluetoothCallback; Loading Loading @@ -78,6 +79,7 @@ public class AdapterServiceTest { private @Mock AlarmManager mMockAlarmManager; private @Mock Resources mMockResources; private @Mock UserManager mMockUserManager; private @Mock DevicePolicyManager mMockDevicePolicyManager; private @Mock ProfileService mMockGattService; private @Mock ProfileService mMockService; private @Mock ProfileService mMockService2; Loading Loading @@ -134,6 +136,8 @@ public class AdapterServiceTest { when(mMockContext.getUserId()).thenReturn(Process.BLUETOOTH_UID); when(mMockContext.getPackageManager()).thenReturn(mMockPackageManager); when(mMockContext.getSystemService(Context.USER_SERVICE)).thenReturn(mMockUserManager); when(mMockContext.getSystemService(Context.DEVICE_POLICY_SERVICE)).thenReturn( mMockDevicePolicyManager); when(mMockContext.getSystemService(Context.POWER_SERVICE)).thenReturn(mPowerManager); when(mMockContext.getSystemService(Context.ALARM_SERVICE)).thenReturn(mMockAlarmManager); when(mMockContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager); Loading @@ -146,6 +150,8 @@ public class AdapterServiceTest { when(mMockResources.getBoolean(R.bool.profile_supported_pbap)).thenReturn(true); when(mMockResources.getBoolean(R.bool.profile_supported_pan)).thenReturn(true); when(mMockDevicePolicyManager.isCommonCriteriaModeEnabled(any())).thenReturn(false); when(mIBluetoothCallback.asBinder()).thenReturn(mBinder); doReturn(Process.BLUETOOTH_UID).when(mMockPackageManager) Loading Loading
android/app/src/com/android/bluetooth/btservice/AdapterService.java +3 −1 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.app.AlarmManager; import android.app.AppOpsManager; import android.app.PendingIntent; import android.app.Service; import android.app.admin.DevicePolicyManager; import android.bluetooth.BluetoothActivityEnergyInfo; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAdapter.ActiveDeviceUse; Loading Loading @@ -3008,7 +3009,8 @@ public class AdapterService extends Service { } private boolean isNiapMode() { return Settings.Global.getInt(getContentResolver(), "common_criteria_mode", 0) == 1; return ((DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE)) .isCommonCriteriaModeEnabled(null); } /** Loading
android/app/tests/unit/src/com/android/bluetooth/btservice/AdapterServiceTest.java +6 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; import android.app.AlarmManager; import android.app.admin.DevicePolicyManager; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.IBluetoothCallback; Loading Loading @@ -78,6 +79,7 @@ public class AdapterServiceTest { private @Mock AlarmManager mMockAlarmManager; private @Mock Resources mMockResources; private @Mock UserManager mMockUserManager; private @Mock DevicePolicyManager mMockDevicePolicyManager; private @Mock ProfileService mMockGattService; private @Mock ProfileService mMockService; private @Mock ProfileService mMockService2; Loading Loading @@ -134,6 +136,8 @@ public class AdapterServiceTest { when(mMockContext.getUserId()).thenReturn(Process.BLUETOOTH_UID); when(mMockContext.getPackageManager()).thenReturn(mMockPackageManager); when(mMockContext.getSystemService(Context.USER_SERVICE)).thenReturn(mMockUserManager); when(mMockContext.getSystemService(Context.DEVICE_POLICY_SERVICE)).thenReturn( mMockDevicePolicyManager); when(mMockContext.getSystemService(Context.POWER_SERVICE)).thenReturn(mPowerManager); when(mMockContext.getSystemService(Context.ALARM_SERVICE)).thenReturn(mMockAlarmManager); when(mMockContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager); Loading @@ -146,6 +150,8 @@ public class AdapterServiceTest { when(mMockResources.getBoolean(R.bool.profile_supported_pbap)).thenReturn(true); when(mMockResources.getBoolean(R.bool.profile_supported_pan)).thenReturn(true); when(mMockDevicePolicyManager.isCommonCriteriaModeEnabled(any())).thenReturn(false); when(mIBluetoothCallback.asBinder()).thenReturn(mBinder); doReturn(Process.BLUETOOTH_UID).when(mMockPackageManager) Loading