1 /* 2 * Copyright (C) 2015 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 17 package android.assist.cts; 18 19 import android.assist.common.Utils; 20 import android.util.Log; 21 22 import com.android.compatibility.common.util.SystemUtil; 23 24 /** Test we receive proper assist data when context is disabled or enabled */ 25 26 public class DisableContextTest extends AssistTestBase { 27 static final String TAG = "DisableContextTest"; 28 29 private static final String TEST_CASE_TYPE = Utils.DISABLE_CONTEXT; 30 31 public DisableContextTest() { 32 super(); 33 } 34 35 @Override 36 public void setUp() throws Exception { 37 super.setUp(); 38 startTestActivity(TEST_CASE_TYPE); 39 } 40 41 @Override 42 public void tearDown() throws Exception { 43 SystemUtil.runShellCommand(getInstrumentation(), 44 "settings put secure assist_structure_enabled 1"); 45 SystemUtil.runShellCommand(getInstrumentation(), 46 "settings put secure assist_screenshot_enabled 1"); 47 logContextAndScreenshotSetting(); 48 super.tearDown(); 49 } 50 51 public void testContextAndScreenshotOff() throws Exception { 52 if (mActivityManager.isLowRamDevice()) { 53 Log.d(TAG, "Not running assist tests on low-RAM device."); 54 return; 55 } 56 // Both settings off 57 Log.i(TAG, "DisableContext: Screenshot OFF, Context OFF"); 58 SystemUtil.runShellCommand(getInstrumentation(), 59 "settings put secure assist_structure_enabled 0"); 60 SystemUtil.runShellCommand(getInstrumentation(), 61 "settings put secure assist_screenshot_enabled 0"); 62 waitForBroadcast(); 63 64 logContextAndScreenshotSetting(); 65 66 verifyAssistDataNullness(true, true, true, true); 67 68 // Screenshot off, context on 69 Log.i(TAG, "DisableContext: Screenshot OFF, Context ON"); 70 SystemUtil.runShellCommand(getInstrumentation(), 71 "settings put secure assist_structure_enabled 1"); 72 SystemUtil.runShellCommand(getInstrumentation(), 73 "settings put secure assist_screenshot_enabled 0"); 74 waitForBroadcast(); 75 76 logContextAndScreenshotSetting(); 77 78 verifyAssistDataNullness(false, false, false, true); 79 80 // Context off, screenshot on 81 Log.i(TAG, "DisableContext: Screenshot ON, Context OFF"); 82 SystemUtil.runShellCommand(getInstrumentation(), 83 "settings put secure assist_structure_enabled 0"); 84 SystemUtil.runShellCommand(getInstrumentation(), 85 "settings put secure assist_screenshot_enabled 1"); 86 waitForBroadcast(); 87 88 logContextAndScreenshotSetting(); 89 90 verifyAssistDataNullness(true, true, true, true); 91 } 92 } 93