Starting March 27, 2025, we recommend using android-latest-release instead of aosp-main to build and contribute to AOSP. For more information, see Changes to AOSP.
         
       
     
  
  
  
  
  
    
    
      
    
    
      
      Stay organized with collections
    
    
      
      Save and categorize content based on your preferences.
    
  
  
    
  
  
  
  
    
  
  
    
    
  
  
SecurityTestCase
  public
  
  
  
  class
  SecurityTestCase
  
  
  
  
  
  
  
  
  
  
  
  
  
    extends StsExtraBusinessLogicHostTestBase
  
  
  
  
  
  
  
    
    | java.lang.Object | 
  
  
    
      | ↳ | com.android.tradefed.testtype.junit4.BaseHostJUnit4Test | 
  
  
    
      |  | ↳ | com.android.compatibility.common.tradefed.testtype.BusinessLogicHostTestBase | 
  
  
    
      |  |  | ↳ | com.android.compatibility.common.tradefed.testtype.ExtraBusinessLogicHostTestBase | 
  
  
    
      |  |  |  | ↳ | com.android.sts.common.tradefed.testtype.StsExtraBusinessLogicHostTestBase | 
  
  
    
      |  |  |  |  | ↳ | com.android.sts.common.tradefed.testtype.SecurityTestCase | 
  
  
  
  
    
  Base test class for all STS tests.
 
Use RootSecurityTestCase or NonRootSecurityTestCase instead.
Summary
| Protected methods | 
|---|
  
  
  
    | 
        
        
        
        
        
        boolean | 
      containsDriver(ITestDevice device, String driver, boolean checkReadable)
      Check if a driver is present on a machine.
        
    
 | 
  
  
  
  
    | 
        
        
        
        
        
        boolean | 
      containsDriver(ITestDevice device, String driver)
      Check if a driver is present and readable.
        
    
 | 
  
Constants
    TIMEOUT_DEFAULT
    
      
  
      
  
    
protected static final int TIMEOUT_DEFAULT
    
    
    
  
    
      Constant Value:
      
          60
          (0x0000003c)
      
    
 
    TIMEOUT_NONDETERMINISTIC
    
      
  
      
  
    
public static final int TIMEOUT_NONDETERMINISTIC
    
    
    
  
    
      Constant Value:
      
          315
          (0x0000013b)
      
    
 
Fields
    testName
    
      
  
      
  
    
public TestName testName
    
    
    
  
    
 
Public constructors
    SecurityTestCase
    
public SecurityTestCase ()
    
    
    
  
 
Public methods
    assertMatches
    
public void assertMatches (String pattern, 
                String input)
    
    
    
  
    
    | Parameters | 
|---|
      
        | pattern | String | 
      
        | input | String | 
    
      
  
 
    assertMatchesMultiLine
    
public void assertMatchesMultiLine (String pattern, 
                String input)
    
    
    
  
    
    | Parameters | 
|---|
      
        | pattern | String | 
      
        | input | String | 
    
      
  
 
    assertNotKernelPointer
    
public void assertNotKernelPointer (Callable<String> getPtrFunction, 
                ITestDevice deviceToReboot)
    
    
    
  Runs a provided function that collects a String to test against kernel pointer leaks. The
 getPtrFunction function implementation must return a String that starts with the pointer.
 i.e. "01234567". Trailing characters are allowed except for [0-9a-fA-F]. In the event that
 the pointer appears to be vulnerable, a JUnit assert is thrown. Since kernel pointers can be
 hashed, there is a possibility the hashed pointer overlaps into the normal kernel space. The
 test re-runs to make false positives statistically insignificant. When kernel pointers won't
 change without a reboot, provide a device to reboot.
    
    | Parameters | 
|---|
      
        | getPtrFunction | Callable: a function that returns a string that starts with a pointer | 
      
        | deviceToReboot | ITestDevice: device to reboot when kernel pointers won't change | 
    
      
  
 
    assertNotMatches
    
public void assertNotMatches (String pattern, 
                String input)
    
    
    
  
    
    | Parameters | 
|---|
      
        | pattern | String | 
      
        | input | String | 
    
      
  
 
    assertNotMatchesMultiLine
    
public void assertNotMatchesMultiLine (String pattern, 
                String input)
    
    
    
  
    
    | Parameters | 
|---|
      
        | pattern | String | 
      
        | input | String | 
    
      
  
 
    assertWifiConnected
    
public void assertWifiConnected (ITestDevice device)
    
    
    
  Asserts the wifi connection status is connected. Because STS can reboot a device immediately
 before running a test, wifi might not be connected before the test runs. We poll wifi until
 we hit a timeout or wifi is connected.
    
    | Parameters | 
|---|
      
        | device | ITestDevice: device to be ran on | 
    
      
  
 
    assumeIsSupportedNfcDevice
    
public void assumeIsSupportedNfcDevice (ITestDevice device)
    
    
    
  
    
    | Parameters | 
|---|
      
        | device | ITestDevice | 
    
      
  
 
    buildMetricsReportLog
    
public static MetricsReportLog buildMetricsReportLog (ITestDevice device)
    
    
    
  
    
    | Parameters | 
|---|
      
        | device | ITestDevice | 
    
    
 
    createWifiHelper
    
public WifiHelper createWifiHelper ()
    
    
    
  
    
      
      | Throws | 
|---|
        
          | DeviceNotAvailableException |  | 
      
  
 
    getAbi
    
public static IAbi getAbi (ITestDevice device)
    
    
    
  
    
    | Parameters | 
|---|
      
        | device | ITestDevice | 
    
    
 
    getBuildInfo
    
public static IBuildInfo getBuildInfo (ITestDevice device)
    
    
    
  
    
    | Parameters | 
|---|
      
        | device | ITestDevice | 
    
    
 
    getPocPusher
    
public static PocPusher getPocPusher (ITestDevice device)
    
    
    
  
    
    | Parameters | 
|---|
      
        | device | ITestDevice | 
    
    
 
    getTestName
    
public static String getTestName (ITestDevice device)
    
    
    
  
    
    | Parameters | 
|---|
      
        | device | ITestDevice | 
    
    
 
    moduleIsPlayManaged
    
public boolean moduleIsPlayManaged (String modulePackageName)
    
    
    
  Return true if a module is play managed.
 
Example of skipping a test based on mainline modules:
 
  @Test
  public void testPocCVE_1234_5678() throws Exception {
      // This will skip the test if MODULE_METADATA mainline module is play managed.
      assumeFalse(moduleIsPlayManaged("com.google.android.captiveportallogin"));
      // Do testing...
  }
 
    
    | Parameters | 
|---|
      
        | modulePackageName | String | 
    
    
      
  
 
    safeReboot
    
public void safeReboot ()
    
    
    
  
      
      | Throws | 
|---|
        
          | DeviceNotAvailableException |  | 
      
  
 
    setUp
    
public void setUp ()
    
    
    
  Waits for device to be online, marks the most recent boottime of the device 
      
  
 
    tearDown
    
public void tearDown ()
    
    
    
  Makes sure the phone is online and checks if the device crashed 
      
  
 
    updateKernelStartTime
    
public void updateKernelStartTime ()
    
    
    
  Allows a test to pass if called after a planned reboot. 
      
      | Throws | 
|---|
        
          | DeviceNotAvailableException |  | 
      
  
 
Protected methods
    containsDriver
    
protected boolean containsDriver (ITestDevice device, 
                String driver, 
                boolean checkReadable)
    
    
    
  Check if a driver is present on a machine. 
    
    | Parameters | 
|---|
      
        | device | ITestDevice | 
      
        | driver | String | 
      
        | checkReadable | boolean | 
    
    
      
  
 
    containsDriver
    
protected boolean containsDriver (ITestDevice device, 
                String driver)
    
    
    
  Check if a driver is present and readable. 
    
    | Parameters | 
|---|
      
        | device | ITestDevice | 
      
        | driver | String | 
    
    
      
  
 
 
 
  
  
 
  
    
    
      
    
    
  
       
    
    
  
  
  Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
  Last updated 2022-11-18 UTC.
  
  
  
    
      [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2022-11-18 UTC."],[],[]]