自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release 而非 aosp-main 建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
ModuleOemTargetPreparer
public
class
ModuleOemTargetPreparer
extends InstallApexModuleTargetPreparer
摘要
公用方法 |
void
|
checkModuleAfterPush(ITestDevice device, pushedModules)
檢查已推送的模組名稱和版本代碼
|
void
|
setUp(TestInformation testInfo)
執行目標設定以進行測試,並推送模組取代預先載入的模組
|
受保護的方法 |
void
|
checkPreloadModules(TestInformation testInfo, DeviceDescriptor deviceDescriptor)
檢查預先載入模組資訊
|
String[]
|
getApkDirectory(ITestDevice device, String packageName)
取得系統目錄下的 APK 檔案路徑
|
String
|
getPackageVersioncode(ITestDevice device, String packageName, boolean isAPK)
在推送的模組中檢查套件版本 (套件名稱)。
|
ModuleOemTargetPreparer.ModuleInfo
|
pushFile(File moduleFile, TestInformation testInfo)
將檔案推送至 /system/apex/ (適用於 Apex) 或 /system/** (適用於 APK)
|
String
|
renameFile(ITestDevice device, File moduleFile, String packageName)
將要更新的檔案名稱重新命名為 /system 下的相同名稱。
|
void
|
setupDevice(TestInformation testInfo)
在 /system 下推送檔案前,先使用 ADB 取得裝置的 root 權限並重新掛載裝置
|
公用建構函式
ModuleOemTargetPreparer
public ModuleOemTargetPreparer ()
公用方法
checkModuleAfterPush
public void checkModuleAfterPush (ITestDevice device,
pushedModules)
檢查已推送的模組名稱和版本代碼
| 參數 |
device |
ITestDevice |
pushedModules |
:已推送的模組清單 |
| 擲回 |
TargetSetupError |
如果沒有推送模組,則擲回例外狀況 |
DeviceNotAvailableException |
如果沒有可用的裝置,則擲回例外狀況 |
public void setUp (TestInformation testInfo)
執行目標設定以進行測試,並推送模組取代預先載入的模組
| 擲回 |
TargetSetupError |
設定環境時發生致命錯誤 |
BuildError |
如果因建構作業準備而發生錯誤 |
DeviceNotAvailableException |
如果裝置沒有回應
|
受保護的方法
protected void checkPreloadModules (TestInformation testInfo,
DeviceDescriptor deviceDescriptor)
查看預先載入模組資訊
| 參數 |
testInfo |
TestInformation:測試資訊 |
deviceDescriptor |
DeviceDescriptor |
| 擲回 |
DeviceNotAvailableException |
如果裝置不可用,則擲回例外狀況 |
TargetSetupError |
如果沒有預先載入的模組,則會擲回例外狀況 |
getApkDirectory
protected String[] getApkDirectory (ITestDevice device,
String packageName)
取得系統目錄下的 APK 檔案路徑
| 參數 |
device |
ITestDevice |
packageName |
String:模組套件名稱 |
| 傳回 |
String[] |
含有 APK 名稱和路徑的字串陣列 |
| 擲回 |
DeviceNotAvailableException |
如無法使用裝置 |
TargetSetupError |
如果找不到套件的路徑 |
getPackageVersioncode
protected String getPackageVersioncode (ITestDevice device,
String packageName,
boolean isAPK)
在推送的模組中檢查套件版本 (套件名稱)。
| 參數 |
packageName |
String:已推送的套件名稱 |
isAPK |
boolean |
| 擲回 |
DeviceNotAvailableException |
如果找不到裝置,就會擲回例外狀況。 |
protected ModuleOemTargetPreparer.ModuleInfo pushFile (File moduleFile,
TestInformation testInfo)
將檔案推送至 /system/apex/ (針對 Apex) 或 /system/** (針對 APK)
| 擲回 |
TargetSetupError |
如果無法透過 ADB 推送檔案 |
DeviceNotAvailableException |
如果裝置無法使用
|
renameFile
protected String renameFile (ITestDevice device,
File moduleFile,
String packageName)
將要更新的檔案名稱重新命名為 /system 下的相同名稱。
| 參數 |
device |
ITestDevice:測試裝置 |
moduleFile |
File:要安裝的模組檔案 |
packageName |
String:/system/* 下的名稱 |
| 擲回 |
TargetSetupError |
如果無法重新命名檔案 |
DeviceNotAvailableException |
|
protected void setupDevice (TestInformation testInfo)
在 /system 下推送檔案前,先使用 ADB 取得裝置的 root 權限並重新掛載裝置
| 擲回 |
TargetSetupError |
如果裝置無法重新掛載。 |
DeviceNotAvailableException |
|
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。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 (世界標準時間)。"],[],[]]