為配合主幹穩定開發模型,並確保生態系統的平台穩定性,我們將於 2026 年起,在第 2 季和第 4 季將原始碼發布至 AOSP。如要建構及貢獻 AOSP,建議使用 android-latest-release,而非 aosp-main。android-latest-release 資訊清單分支版本一律會參照推送至 AOSP 的最新版本。詳情請參閱「Android 開放原始碼計畫變更」一文。
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
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
|
所有 STS 測試的基本測試類別。
請改用 RootSecurityTestCase 或 NonRootSecurityTestCase。
摘要
受保護的方法 |
boolean
|
containsDriver(ITestDevice device, String driver, boolean checkReadable)
檢查機器上是否有驅動程式。
|
boolean
|
containsDriver(ITestDevice device, String driver)
檢查是否有可讀取的驅動程式。
|
常數
TIMEOUT_DEFAULT
protected static final int TIMEOUT_DEFAULT
常數值:
60
(0x0000003c)
TIMEOUT_NONDETERMINISTIC
public static final int TIMEOUT_NONDETERMINISTIC
常數值:
315
(0x0000013b)
欄位
testName
public TestName testName
公用建構函式
SecurityTestCase
public SecurityTestCase ()
公用方法
assertMatches
public void assertMatches (String pattern,
String input)
| 參數 |
pattern |
String |
input |
String |
assertMatchesMultiLine
public void assertMatchesMultiLine (String pattern,
String input)
| 參數 |
pattern |
String |
input |
String |
assertNotKernelPointer
public void assertNotKernelPointer (Callable<String> getPtrFunction,
ITestDevice deviceToReboot)
執行提供的函式,收集字串,以便測試核心指標外洩。getPtrFunction 函式實作必須傳回以指標開頭的字串。例如「01234567」。尾隨字元可使用,但 [0-9a-fA-F] 除外。如果指標似乎有安全漏洞,系統就會擲回 JUnit 斷言。由於核心指標可以進行雜湊,因此雜湊指標可能會重疊至一般核心空間。測試會重新執行,讓偽陽性在統計上不具意義。如果核心指標在未重新啟動裝置的情況下不會變更,請提供要重新啟動的裝置。
| 參數 |
getPtrFunction |
Callable:傳回開頭為指標的字串的函式 |
deviceToReboot |
ITestDevice:當核心指標不會變更時,裝置會重新啟動 |
assertNotMatches
public void assertNotMatches (String pattern,
String input)
| 參數 |
pattern |
String |
input |
String |
assertNotMatchesMultiLine
public void assertNotMatchesMultiLine (String pattern,
String input)
| 參數 |
pattern |
String |
input |
String |
assertWifiConnected
public void assertWifiConnected (ITestDevice device)
斷言 Wi-Fi 連線狀態已連線。由於 STS 可以在執行測試前立即重新啟動裝置,因此可能在測試執行前就已連上 Wi-Fi。我們會輪詢 Wi-Fi,直到逾時或 Wi-Fi 連線為止。
| 參數 |
device |
ITestDevice:要執行的裝置 |
assumeIsSupportedNfcDevice
public void assumeIsSupportedNfcDevice (ITestDevice device)
buildMetricsReportLog
public static MetricsReportLog buildMetricsReportLog (ITestDevice device)
createWifiHelper
public WifiHelper createWifiHelper ()
| 擲回 |
DeviceNotAvailableException |
|
getAbi
public static IAbi getAbi (ITestDevice device)
getBuildInfo
public static IBuildInfo getBuildInfo (ITestDevice device)
getPocPusher
public static PocPusher getPocPusher (ITestDevice device)
getTestName
public static String getTestName (ITestDevice device)
moduleIsPlayManaged
public boolean moduleIsPlayManaged (String modulePackageName)
如果模組是 Play 管理的模組,則傳回 true。
根據主線程模組略過測試的範例:
@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...
}
| 參數 |
modulePackageName |
String |
safeReboot
public void safeReboot ()
| 擲回 |
DeviceNotAvailableException |
|
setUp
public void setUp ()
等待裝置上線,並標記裝置最近的啟動時間
tearDown
public void tearDown ()
確認手機已連上網路,並檢查裝置是否當機
updateKernelStartTime
public void updateKernelStartTime ()
如果在預定重新啟動後呼叫,則允許測試通過。
| 擲回 |
DeviceNotAvailableException |
|
受保護的方法
containsDriver
protected boolean containsDriver (ITestDevice device,
String driver,
boolean checkReadable)
檢查機器上是否有驅動程式。
| 參數 |
device |
ITestDevice |
driver |
String |
checkReadable |
boolean |
containsDriver
protected boolean containsDriver (ITestDevice device,
String driver)
檢查是否有驅動程式,且可供讀取。
| 參數 |
device |
ITestDevice |
driver |
String |
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[]]