1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.cts.profileowner; 17 18 import android.app.admin.DevicePolicyManager; 19 20 import com.android.cts.devicepolicy.DevicePolicySafetyCheckerIntegrationTester; 21 22 // TODO(b/174859111): move to automotive-only section 23 /** 24 * Tests that DPM calls fail when determined by the 25 * {@link android.app.admin.DevicePolicySafetyChecker}. 26 */ 27 public final class DevicePolicySafetyCheckerIntegrationTest extends BaseProfileOwnerTest { 28 29 private final DevicePolicySafetyCheckerIntegrationTester mTester = 30 new DevicePolicySafetyCheckerIntegrationTester(/* forDeviceOwner= */ false); 31 32 /** 33 * Tests that all safety-aware operations are properly implemented. 34 */ testAllOperations()35 public void testAllOperations() { 36 mTester.testAllOperations(mDevicePolicyManager, getWho()); 37 } 38 39 /** 40 * Tests {@link DevicePolicyManager#isSafeOperation(int)}. 41 */ testIsSafeOperation()42 public void testIsSafeOperation() { 43 mTester.testIsSafeOperation(mDevicePolicyManager); 44 } 45 46 /** 47 * Tests {@link android.app.admin.UnsafeStateException} properties. 48 */ testUnsafeStateException()49 public void testUnsafeStateException() { 50 mTester.testUnsafeStateException(mDevicePolicyManager, getWho()); 51 } 52 53 /** 54 * Tests {@link android.app.admin.DeviceAdminReceiver#onOperationSafetyStateChanged()}. 55 */ testOnOperationSafetyStateChanged()56 public void testOnOperationSafetyStateChanged() { 57 mTester.testOnOperationSafetyStateChanged(mContext, mDevicePolicyManager); 58 } 59 } 60