為配合主幹穩定開發模型,並確保生態系統的平台穩定性,我們將自 2026 年起,在第 2 季和第 4 季將原始碼發布至 AOSP。如要建構及貢獻 AOSP,請使用 android-latest-release。android-latest-release 資訊清單分支版本一律會參照推送至 Android 開放原始碼計畫的最新版本。詳情請參閱「Android 開放原始碼計畫變更」。
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
TargetFileUtils
public
class
TargetFileUtils
extends Object
| java.lang.Object
|
| ↳ |
com.android.tradefed.util.TargetFileUtils
|
摘要
公用建構函式
TargetFileUtils
public TargetFileUtils ()
公用方法
findFile
public static ArrayList<String> findFile (String path,
String namePattern,
List<String> options,
ITestDevice device)
這個輔助方法會執行 adb shell find 指令,並以 ERROR(/ArrayList) 形式傳回結果。
| 參數 |
path |
String:裝置上的搜尋路徑。 |
namePattern |
String:檔案名稱模式。 |
options |
List:要傳遞的 String List,用於尋找其他選項。 |
device |
ITestDevice:測試裝置。 |
getPermission
public static String getPermission (String filepath,
ITestDevice device)
讀取路徑的檔案權限位元。
| 參數 |
filepath |
String:檔案或目錄的路徑。 |
device |
ITestDevice:測試裝置。 |
hasPermission
public static boolean hasPermission (TargetFileUtils.FilePermission permission,
String permissionBits)
判斷權限位元是否將指定權限授予任何群組。
| 參數 |
permission |
TargetFileUtils.FilePermission:指定權限。 |
permissionBits |
String:八進位權限字串 (例如 741)。 |
| 傳回 |
boolean |
如果任何擁有者/群組/全域具有指定權限,則為 True。 |
isReadOnly
public static boolean isReadOnly (String filepath,
ITestDevice device)
檢查指定路徑的權限是否為唯讀。
| 參數 |
filepath |
String:檔案或目錄的路徑。 |
device |
ITestDevice:測試裝置。 |
| 傳回 |
boolean |
如果路徑為唯讀,則為 true,否則為 false。 |
isReadWriteOnly
public static boolean isReadWriteOnly (String filepath,
ITestDevice device)
檢查指定路徑的權限是否為讀寫。
| 參數 |
filepath |
String:檔案或目錄的路徑。 |
device |
ITestDevice:測試裝置。 |
| 傳回 |
boolean |
如果路徑為讀寫,則為 true,否則為 false。 |
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2026-06-22 (世界標準時間)。
[[["容易理解","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"]],["上次更新時間:2026-06-22 (世界標準時間)。"],[],[]]