NativeDevice

public class NativeDevice
extends Object implements IManagedTestDevice , IConfigurationReceiver , ITestLoggerReceiver

java.lang.Object
com.android.tradefed.device.NativeDevice


التنفيذ الافتراضي لأجهزة android غير مكدس ITestDevice غير كاملة.

ملخص

فئات متداخلة

class NativeDevice.AdbAction

ERROR(DeviceAction/com.android.tradefed.device.NativeDevice.DeviceAction DeviceAction) لتشغيل أمر OS 'adb ....'.

class NativeDevice.AdbShellAction

class NativeDevice.RebootDeviceAction

ERROR(DeviceAction/com.android.tradefed.device.NativeDevice.DeviceAction DeviceAction) لإعادة تشغيل الجهاز.

الثوابت

int INVALID_USER_ID

القيمة التي تم إرجاعها لأي معرف مستخدم غير صالح / غير موجود: حدد UserHandle القيمة -10000

long MAX_HOST_DEVICE_TIME_OFFSET

int MAX_RETRY_ATTEMPTS

العدد الافتراضي لمحاولات الأمر إجراء

مجالات

protected static final String SD_CARD

protected static final String STORAGE_EMULATED

protected TestDeviceOptions mOptions

protected final IDeviceStateMonitor mStateMonitor

المنشأت العامة

NativeDevice (IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor)

ينشئ TestDevice .

الأساليب العامة

boolean canSwitchToHeadlessSystemUser ()

إرجاع ما إذا كان مسموحًا بالانتقال إلى مستخدم النظام بدون رأس.

boolean checkApiLevelAgainstNextRelease (int strictMinLevel)

تحقق مما إذا كانت الميزة مدعومة حاليًا أم لا نظرًا لمستوى الدعم الأدنى أم لا.

boolean checkConnectivity ()

تحقق من اتصال الجهاز بالشبكة.

boolean clearErrorDialogs ()

محاولة استبعاد أي مربعات حوار خطأ معروضة حاليًا على واجهة مستخدم الجهاز.

void clearLastConnectedWifiNetwork ()

مسح آخر شبكة wifi متصلة.

void clearLogcat ()

يحذف أي بيانات logcat المتراكمة.

boolean connectToWifiNetwork ( wifiSsidToPsk, boolean scanSsid) connectToWifiNetwork ( wifiSsidToPsk, boolean scanSsid)

يتصل بشبكة wifi.

boolean connectToWifiNetwork (String wifiSsid, String wifiPsk)

يتصل بشبكة wifi.

boolean connectToWifiNetwork ( wifiSsidToPsk) connectToWifiNetwork ( wifiSsidToPsk)

يتصل بشبكة wifi

boolean connectToWifiNetwork (String wifiSsid, String wifiPsk, boolean scanSsid)

يتصل بشبكة wifi.

boolean connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk, boolean scanSsid)

متغير من connectToWifiNetwork(String, String) يتصل فقط إذا كان الجهاز لا يحتوي حاليًا على اتصال بالشبكة.

boolean connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk)

متغير من connectToWifiNetwork(String, String) يتصل فقط إذا كان الجهاز لا يحتوي حاليًا على اتصال بالشبكة.

int createUser (String name, boolean guest, boolean ephemeral)

قم بإنشاء مستخدم باسم معين والعلامات المقدمة

int createUser (String name, boolean guest, boolean ephemeral, boolean forTesting)

قم بإنشاء مستخدم باسم معين والعلامات المقدمة

int createUser (String name)

قم بإنشاء مستخدم باسم معين وعلامات افتراضية 0.

int createUserNoThrow (String name)

قم بإنشاء مستخدم باسم معين وعلامات افتراضية 0.

void deleteFile (String deviceFilePath)

طريقة مساعدة لحذف ملف أو دليل على الجهاز.

void deregisterDeviceActionReceiver ( IDeviceActionReceiver deviceActionReceiver)

يزيل IDeviceActionReceiver المسجل.

boolean deviceSoftRestarted ( ProcessInfo prevSystemServerProcess)

طريقة مساعدة للتحقق مما إذا كان الجهاز قد تمت إعادة تشغيله بشكل بسيط عن طريق مقارنة خادم النظام الحالي مع System_server السابق ProcessInfo .

boolean deviceSoftRestartedSince (long utcEpochTime, TimeUnit timeUnit)

طريقة مساعدة للتحقق مما إذا كان الجهاز قد تمت إعادة تشغيله بشكل بسيط منذ وقت UTC منذ الحقبة من الجهاز ERROR(/TimeUnit) .

boolean disableAdbRoot ()

يوقف adb root.

void disableKeyguard ()

محاولات لتعطيل حارس المفاتيح.

boolean disableNetworkMonitor ()

تعطيل مراقبة الشبكة على الجهاز.

boolean disconnectFromWifi ()

قطع الاتصال بشبكة wifi.

boolean doesFileExist (String deviceFilePath, int userId)

طريقة مساعدة لتحديد ما إذا كان الملف الموجود على الجهاز موجودًا لمستخدم معين.

boolean doesFileExist (String deviceFilePath)

طريقة مساعدة لتحديد ما إذا كان الملف على الجهاز موجودًا.

File dumpHeap (String process, String devicePath)

محاولة تفريغ الكومة من خادم النظام.

boolean enableAdbRoot ()

يتحول على adb root.

boolean enableNetworkMonitor ()

تمكن مراقبة الشبكة على الجهاز.

String executeAdbCommand (long timeout, String... cmdArgs)

طريقة المساعد التي تنفذ أمر adb كأمر نظام مع مهلة محددة.

String executeAdbCommand (long timeout, envMap, String... cmdArgs) executeAdbCommand (long timeout, envMap, String... cmdArgs)

طريقة المساعد التي تنفذ أمر adb كأمر نظام مع مهلة محددة.

String executeAdbCommand (String... cmdArgs)

طريقة المساعد التي تنفذ أمر adb كأمر نظام.

CommandResult executeFastbootCommand (String... cmdArgs)

طريقة المساعدة التي تنفذ أمر fastboot كأمر نظام مع مهلة افتراضية تبلغ دقيقتين.

CommandResult executeFastbootCommand (long timeout, String... cmdArgs)

طريقة المساعد التي تنفذ أمر fastboot كأمر نظام.

CommandResult executeLongFastbootCommand (String... cmdArgs)

طريقة المساعد التي تقوم بتنفيذ أمر fastboot الذي يعمل لفترة طويلة كأمر نظام.

CommandResult executeLongFastbootCommand ( envVarMap, String... cmdArgs) executeLongFastbootCommand ( envVarMap, String... cmdArgs)

طريقة المساعد التي تنفذ أمر fastboot الذي يعمل لفترة طويلة كأمر نظام مع متغيرات بيئة النظام.

String executeShellCommand (String command)

أسلوب المساعد الذي ينفذ أمر adb shell ويعيد الإخراج ERROR(/String) .

void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)

ينفذ أمر adb shell ، مع المزيد من المعلمات للتحكم في سلوك الأمر.

void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeoutForCommand, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)

ينفذ أمر adb shell ، مع المزيد من المعلمات للتحكم في سلوك الأمر.

void executeShellCommand (String command, IShellOutputReceiver receiver)

ينفذ الأمر adb shell المحدد ، ويعيد المحاولة عدة مرات إذا فشل الأمر.

CommandResult executeShellV2Command (String cmd)

طريقة المساعد التي تنفذ أمر شل adb وتعيد النتائج كإنتاج CommandResult بشكل صحيح مع إخراج حالة الأمر ، stdout و stderr.

CommandResult executeShellV2Command (String cmd, OutputStream pipeToOutput)

أسلوب المساعد الذي ينفذ أمر شل adb ويعيد النتائج كإنتاج CommandResult بشكل صحيح مع إخراج حالة الأمر و stderr.

CommandResult executeShellV2Command (String cmd, File pipeAsInput)

أسلوب المساعد الذي ينفذ أمر adb shell ويعيد النتائج كإنتاج CommandResult بشكل صحيح مع إخراج حالة الأمر ، stdout و stderr.

CommandResult executeShellV2Command (String cmd, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)

ينفذ أمر adb shell ، مع المزيد من المعلمات للتحكم في سلوك الأمر.

CommandResult executeShellV2Command (String cmd, long maxTimeoutForCommand, TimeUnit timeUnit)

ينفذ أمر adb shell ، مع المزيد من المعلمات للتحكم في سلوك الأمر.

CommandResult executeShellV2Command (String cmd, File pipeAsInput, OutputStream pipeToOutput, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)

ينفذ أمر adb shell ، مع المزيد من المعلمات للتحكم في سلوك الأمر.

CommandResult executeShellV2Command (String cmd, File pipeAsInput, OutputStream pipeToOutput, OutputStream pipeToError, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)

ينفذ أمر adb shell ، مع المزيد من المعلمات للتحكم في سلوك الأمر.

CommandResult fastbootWipePartition (String partition)

الطريقة المساعدة التي تمسح قسمًا للجهاز.

getActiveApexes ()

إحضار المعلومات حول APEXes التي تم تنشيطها على الجهاز.

getAllSettings (String namespace)

إرجاع أزواج قيمة المفتاح لمساحة الاسم المطلوبة.

DeviceAllocationState getAllocationState ()

إرجاع حالة التخصيص الحالية للجهاز

String getAndroidId (int userId)

ابحث عن معرف android المرتبط بمعرّف المستخدم وأعده ، ويكون فارغًا إذا لم يتم العثور عليه.

getAndroidIds ()

قم بإنشاء خريطة لمعرفات android التي تم العثور عليها مطابقة لمعرفات المستخدم.

int getApiLevel ()

احصل على مستوى API الخاص بالجهاز.

PackageInfo getAppPackageInfo (String packageName)

إحضار معلومات حول حزمة مثبتة على الجهاز.

getAppPackageInfos ()

إحضار معلومات الحزم المثبتة على الجهاز.

String getBasebandVersion ()

طريقة ملائمة للحصول على إصدار النطاق الأساسي (الراديو) من هذا الجهاز.

Integer getBattery ()

تُرجع مستوى البطارية الحالي للجهاز أو Null إذا كان مستوى البطارية غير متاح.

boolean getBooleanProperty (String name, boolean defaultValue)

ترجع القيمة المنطقية للخاصية المحددة.

getBootHistory ()

تجمع طريقة المساعد خريطة محفوظات التمهيد مع وقت التمهيد وسبب التمهيد.

getBootHistorySince (long utcEpochTime, TimeUnit timeUnit)

يجمع أسلوب المساعد خريطة محفوظات التمهيد مع وقت التمهيد وسبب التمهيد منذ الوقت المحدد منذ الحقبة من الجهاز والوحدة الزمنية المحددة.

String getBootloaderVersion ()

طريقة ملائمة للحصول على نسخة محمل الإقلاع من هذا الجهاز.

InputStreamSource getBugreport ()

يسترجع تقرير خطأ من الجهاز.

InputStreamSource getBugreportz ()

يسترجع تقرير الأخطاء من الجهاز.

String getBuildAlias ()

استرجع الاسم المستعار للبنية التي يشغلها الجهاز حاليًا.

String getBuildFlavor ()

استرجع نكهة البناء للجهاز.

String getBuildId ()

استرجع البنية التي يشغلها الجهاز حاليًا.

String getBuildSigningKeys ()

إرجاع نوع المفتاح المستخدم لتوقيع صورة الجهاز

عادةً ما يتم توقيع أجهزة Android باستخدام مفاتيح الاختبار (مثل AOSP) أو مفاتيح التحرير (التي يتحكم فيها مصنعو الأجهزة الفردية)

DeviceDescriptor getCachedDeviceDescriptor ()

تُرجع DeviceDescriptor المخزنة مؤقتًا إذا تم تخصيص الجهاز ، وإلا فإنها تُرجع DeviceDescriptor الحالي.

DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)

تُرجع DeviceDescriptor المخزنة مؤقتًا إذا تم تخصيص الجهاز ، وإلا فإنها تُرجع DeviceDescriptor الحالي.

String[] getChildren (String path)

بديل لاستخدام IFileEntry الذي لن يعمل في بعض الأحيان بسبب الأذونات.

AbstractConnection getConnection ()

الاتصال الحالي المرتبط بالجهاز.

DeviceFoldableState getCurrentFoldableState ()

تُرجع الحالة القابلة للطي الحالية للجهاز أو تُرجع فارغة في حالة حدوث بعض المشكلات.

int getCurrentUser ()

إرجاع معرف المستخدم الحالي قيد التشغيل.

String getDeviceClass ()

احصل على فئة الجهاز.

long getDeviceDate ()

قم بإرجاع تاريخ الجهاز بالمللي ثانية منذ البداية.

DeviceDescriptor getDeviceDescriptor ()

قم بإرجاع DeviceDescriptor من معلومات الجهاز للحصول على معلومات عنه دون تمرير كائن الجهاز الفعلي.

DeviceDescriptor getDeviceDescriptor (boolean shortDescriptor)

قم بإرجاع DeviceDescriptor من معلومات الجهاز للحصول على معلومات عنه دون تمرير كائن الجهاز الفعلي.

TestDeviceState getDeviceState ()

احصل على حالة الجهاز.

long getDeviceTimeOffset (Date date)

مساعد للحصول على فارق التوقيت بين الجهاز ERROR(/Date) .

InputStreamSource getEmulatorOutput ()

احصل على دفق المحاكي stdout و stderr

Process getEmulatorProcess ()

قم بإرجاع ERROR(/Process) المقابل لهذا المحاكي.

final File getExecuteShellCommandLog ()

السجل الذي يحتوي على جميع سجلات executeShellCommand(String) .

long getExternalStoreFreeSpace ()

طريقة مساعدة لتحديد مقدار المساحة الخالية على وحدة التخزين الخارجية للجهاز.

String getFastbootPath ()

إرجاع مسار ملف fastboot الثنائي المستخدم.

String getFastbootProductType ()

طريقة ملائمة للحصول على نوع المنتج الخاص بهذا الجهاز عندما يكون في وضع التشغيل السريع.

String getFastbootProductVariant ()

طريقة ملائمة للحصول على نوع المنتج الخاص بهذا الجهاز عندما يكون في وضع التشغيل السريع.

String getFastbootSerialNumber ()

إرجاع الرقم التسلسلي لوضع Fastboot.

String getFastbootVariable (String variableName)

استرجع قيمة متغير fastboot المحددة من الجهاز.

String getFastbootVersion ()

تُرجع سلسلة إصدار ملف fastboot الثنائي المستخدم.

IFileEntry getFileEntry (String path)

استرجع مرجعًا إلى ملف بعيد على الجهاز.

IFileEntry getFileEntry (FileListingService.FileEntry entry)

مساعد غير رسمي للحصول على FileEntry من مسار غير جذر.

getFoldableStates ()

يُرجع قائمة الحالات القابلة للطي على الجهاز.

IDevice getIDevice ()

إرجاع مرجع إلى جهاز ddmlib IDevice المرتبط.

getInstalledPackageNames ()

إحضار أسماء حزم التطبيقات الموجودة على الجهاز.

long getIntProperty (String name, long defaultValue)

ترجع قيمة عدد صحيح للخاصية المحددة من الجهاز.

String getIpAddress ()

يحصل على عنوان IP الخاص بالجهاز.

KeyguardControllerState getKeyguardState ()

قم بإرجاع كائن للحصول على الحالة الحالية لحارس المفاتيح أو فارغ إذا لم يكن مدعومًا.

long getLastExpectedRebootTimeMillis ()

تُرجع آخر مرة قامت فيها واجهات برمجة التطبيقات Tradefed بإعادة التشغيل بالمللي ثانية منذ EPOCH كما تم إرجاعها بواسطة ERROR(/System#currentTimeMillis()) .

int getLaunchApiLevel ()

احصل على مستوى واجهة برمجة التطبيقات الذي تم إطلاقه لأول مرة على الجهاز.

InputStreamSource getLogcat ()

يلتقط دفق لقطة من بيانات logcat.

InputStreamSource getLogcat (int maxBytes)

لالتقاط دفق لقطة من آخر maxBytes من بيانات logcat التي تم التقاطها.

InputStreamSource getLogcatDump ()

الحصول على تفريغ logcat الحالي للجهاز.

InputStreamSource getLogcatSince (long date)

يلتقط دفقًا سريعًا لبيانات logcat التي تم التقاطها بدءًا من التاريخ المقدم.

String getMacAddress ()

يُرجع عنوان MAC الخاص بالجهاز ، فارغًا إذا فشل في الاستعلام من الجهاز.

Integer getMainUserId ()

إرجاع معرف المستخدم الرئيسي.

getMainlineModuleInfo ()

احصل على معلومات حول وحدات الخط الرئيسي المثبتة على الجهاز.

int getMaxNumberOfRunningUsersSupported ()

احصل على أكبر عدد ممكن من المستخدمين الذين يعملون في نفس الوقت.

int getMaxNumberOfUsersSupported ()

احصل على أقصى عدد من المستخدمين المدعومين.

Process getMicrodroidProcess ()
IDeviceStateMonitor getMonitor ()

قم بإرجاع IDeviceStateMonitor المرتبط بالجهاز.

String getMountPoint (String mountName)

ترجع نقطة التركيب.

ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)

تُرجع MountPointInfo المطابق لمسار نقطة التحميل المحدد ، أو null إذا كان هذا المسار لا يحتوي على أي شيء مثبت أو لا يظهر في / proc / mounts كنقطة تحميل.

getMountPointInfo ()

تُرجع نسخة مُحللة من المعلومات الموجودة في / proc / mounts على الجهاز

TestDeviceOptions getOptions ()

إحضار خيارات الاختبار للجهاز.

long getPartitionFreeSpace (String partition)

طريقة مساعدة لتحديد مقدار المساحة الخالية على قسم الجهاز.

Integer getPrimaryUserId ()

إرجاع معرف المستخدم الأساسي.

ProcessInfo getProcessByName (String processName)

تقوم طريقة المساعد بتشغيل الأمر "pidof" و "stat" وإرجاع كائن ProcessInfo مع PID ووقت بدء العملية للعملية المحددة.

String getProcessPid (String process)

تُرجع pid للخدمة أو لاغية إذا حدث خطأ ما.

String getProductType ()

طريقة ملائمة للحصول على نوع منتج هذا الجهاز.

String getProductVariant ()

طريقة ملائمة للحصول على متغير المنتج لهذا الجهاز.

String getProperty (String name)

استرجع قيمة الخاصية المحددة من الجهاز.

ITestDevice.RecoveryMode getRecoveryMode ()

احصل على وضع الاسترداد الحالي للجهاز.

InputStreamSource getScreenshot (String format)

يلتقط لقطة شاشة من الجهاز.

InputStreamSource getScreenshot (long displayId)

يأخذ لقطة شاشة من الجهاز المعطى معرّف العرض.

InputStreamSource getScreenshot (String format, boolean rescale)

يلتقط لقطة شاشة من الجهاز.

InputStreamSource getScreenshot ()

يلتقط لقطة شاشة من الجهاز.

String getSerialNumber ()

طريقة ملائمة للحصول على الرقم التسلسلي لهذا الجهاز.

String getSetting (int userId, String namespace, String key)

إرجاع قيمة الإعداد المطلوب.

String getSetting (String namespace, String key)

راجع getSetting(int, String, String) ويتم إجراؤه على مستخدم النظام.

String getSimOperator ()

أعد مشغل بطاقة SIM أو فارغًا إذا لم يكن متاحًا أو إذا كان الجهاز غير متوفر.

String getSimState ()

أعد حالة بطاقة SIM أو فارغة إذا لم تكن متوفرة أو كان الجهاز غير متاح.

getTombstones ()

جلب وإعادة قائمة شواهد القبور من الأجهزة.

long getTotalMemory ()

تُرجع إجمالي حجم الذاكرة الفعلية بالبايت أو -1 في حالة حدوث خطأ داخلي

getUninstallablePackageNames ()

قم بإحضار أسماء حزم التطبيقات التي يمكن إلغاء تثبيتها.

boolean getUseFastbootErase ()

احصل على ما إذا كنت تريد استخدام تنسيق Fastboot أو تنسيق fastboot لمسح قسم على الجهاز.

int getUserFlags (int userId)

ابحث عن أعلام مستخدم معين وقم بإعادتها.

getUserInfos ()

يحصل على خريطة معرف الاستخدام UserInfo على الجهاز.

int getUserSerialNumber (int userId)

قم بإرجاع الرقم التسلسلي المرتبط بمعرف المستخدم إذا وجد ، -10000 في أي حالات أخرى.

IManagedTestDevice.DeviceEventResponse handleAllocationEvent (DeviceEvent event)

معالجة DeviceEvent المحدد.

قم بمعالجة DeviceEvent ، والذي قد ينقل هذا الجهاز إلى حالة تخصيص جديدة أو لا.

boolean hasFeature (String feature)

تحقق مما إذا كانت الميزة متاحة على الجهاز.

String installPackage (File packageFile, boolean reinstall, String... extraArgs)

قم بتثبيت حزمة Android على الجهاز.

String installPackage (File packageFile, boolean reinstall, boolean grantPermissions, String... extraArgs)

قم بتثبيت حزمة Android على الجهاز.

String installPackageForUser (File packageFile, boolean reinstall, int userId, String... extraArgs)

قم بتثبيت حزمة Android على الجهاز لمستخدم معين.

String installPackageForUser (File packageFile, boolean reinstall, boolean grantPermissions, int userId, String... extraArgs)

قم بتثبيت حزمة Android على الجهاز لمستخدم معين.

boolean isAdbRoot ()

boolean isAdbTcp ()
boolean isAppEnumerationSupported ()

تحقق مما إذا كان النظام الأساسي على الجهاز يدعم تعداد التطبيقات

boolean isBypassLowTargetSdkBlockSupported ()

تحقق مما إذا كان النظام الأساسي على الجهاز يدعم تجاوز كتلة sdk منخفضة الهدف عند تثبيت التطبيق

boolean isDeviceEncrypted ()

يعود إذا كان الجهاز مشفرًا.

boolean isDirectory (String path)

إرجاع True إذا كان المسار الموجود على الجهاز عبارة عن دليل ، أو خطأ في حالة عدم توفره.

boolean isEnableAdbRoot ()
boolean isEncryptionSupported ()

يعود إذا كان التشفير مدعومًا على الجهاز.

boolean isExecutable (String fullPath)

إرجاع True إذا كان مسار الملف على الجهاز عبارة عن ملف قابل للتنفيذ ، والخطأ في الحالات الأخرى.

boolean isFastbootEnabled ()

العودة إذا كان fastboot متاحًا للجهاز.

boolean isHeadless ()

إرجاع صحيح إذا كان الجهاز مقطوع الرأس (بدون شاشة) ، خطأ إذا كان العكس.

boolean isHeadlessSystemUserMode ()

يُرجع ما إذا كان الجهاز يستخدم وضع مستخدم نظام مقطوعة الرأس.

boolean isMainUserPermanentAdmin ()

لعرض ما إذا كان المستخدم الرئيسي مسؤولًا دائمًا ولا يمكن حذفه أو الرجوع إلى حالة غير المسؤول.

boolean isMultiUserSupported ()

يحدد ما إذا كان يتم دعم تعدد المستخدمين.

boolean isPackageInstalled (String packageName, String userId)

استعلم عن الجهاز عن اسم حزمة معين ومعرف المستخدم المحدد للتحقق مما إذا كان مثبتًا حاليًا أم لا لهذا المستخدم.

boolean isPackageInstalled (String packageName)

استعلم عن اسم الحزمة المعطى للجهاز للتحقق مما إذا كان مثبتًا حاليًا أم لا.

boolean isRuntimePermissionSupported ()

تحقق مما إذا كان النظام الأساسي على الجهاز يدعم منح إذن وقت التشغيل

boolean isStateBootloaderOrFastbootd ()

يعود صحيحًا إذا كان الجهاز في TestDeviceState#FASTBOOT أو TestDeviceState.FASTBOOTD .

boolean isUserRunning (int userId)

تحقق مما إذا كان مستخدم معين قيد التشغيل.

boolean isUserSecondary (int userId)

قم بإرجاع ما إذا كان المستخدم المحدد مستخدمًا ثانويًا وفقًا لعلامته.

boolean isUserVisible (int userId)

للتحقق مما إذا كان المستخدم المحدد مرئيًا.

boolean isUserVisibleOnDisplay (int userId, int displayId)

للتحقق مما إذا كان المستخدم المحدد مرئيًا في الشاشة المحددة.

boolean isVisibleBackgroundUsersOnDefaultDisplaySupported ()

يُرجع ما إذا كان الجهاز يسمح للمستخدمين بالبدء في الظهور في الخلفية في ERROR(/java.android.view.Display#DEFAULT_DISPLAY) .

boolean isVisibleBackgroundUsersSupported ()

يُرجع ما إذا كان الجهاز يسمح للمستخدمين بالبدء في الظهور في الخلفية.

boolean isWifiEnabled ()

اختبر ما إذا تم تمكين wifi.

listDisplayIds ()

قم بتجميع قائمة معرّف الشاشات المتوفرة على الجهاز كما تم الإبلاغ عن ذلك بواسطة "dumpsys SurfaceFlinger".

listDisplayIdsForStartingVisibleBackgroundUsers ()

الحصول على قائمة الشاشات التي يمكن استخدامها start a user visible in the background .

listUsers ()

يحصل على قائمة المستخدمين على الجهاز.

boolean logAnrs ( ITestLogger logger)

يجمع ويسجل أخطاء ANR من الجهاز.

boolean logBugreport (String dataName, ITestLogger listener)

طريقة مساعدة لأخذ تقرير خطأ وتسجيله للمراسلين.

void logOnDevice (String tag, Log.LogLevel level, String format, Object... args)

قم بتسجيل رسالة في سجل الجهاز.

void nonBlockingReboot ()

يصدر أمرًا بإعادة تشغيل الجهاز ويعود عند اكتمال الأمر وعندما لا يكون الجهاز مرئيًا لـ adb.

void postAdbRootAction ()

تجاوز ما إذا كان الجهاز يحتاج إلى بعض الإجراءات المحددة التي يجب اتخاذها بعد adb root وقبل إعادة اتصال الجهاز بالإنترنت.

void postAdbUnrootAction ()

تجاوز ما إذا كان الجهاز يحتاج إلى بعض الإجراءات المحددة التي يتعين اتخاذها بعد adb unroot وقبل إعادة اتصال الجهاز بالإنترنت.

void postBootSetup ()

نفذ التعليمات لتهيئة الجهاز لاختبار ذلك بعد كل تمهيد.

void postInvocationTearDown (Throwable exception)

خطوات إضافية للتنظيف المطلوب المحدد للجهاز والذي سيتم تنفيذه بعد إتمام الاستدعاء.

void preInvocationSetup ( IBuildInfo info, MultiMap <String, String> attributes)

خطوات إضافية للإعداد المطلوب المحدد للجهاز والذي سيتم تنفيذه على الجهاز قبل تدفق الاستدعاء.

boolean pullDir (String deviceFilePath, File localDir)

اسحب محتويات الدليل بشكل متكرر من الجهاز.

boolean pullFile (String remoteFilePath, File localFile)

يسترجع ملف من الجهاز.

File pullFile (String remoteFilePath, int userId)

يسترجع ملفًا من الجهاز ، ويخزنه في ERROR(/File) ، ويعيد هذا File .

File pullFile (String remoteFilePath)

يسترجع ملفًا من الجهاز ، ويخزنه في ERROR(/File) ، ويعيد هذا File .

boolean pullFile (String remoteFilePath, File localFile, int userId)

يسترجع ملف من الجهاز.

String pullFileContents (String remoteFilePath)

يسترجع ملف من الجهاز ، ويعيد المحتويات.

File pullFileFromExternal (String remoteFilePath)

طريقة ملائمة لاسترداد ملف من وحدة التخزين الخارجية للجهاز ، وتخزينه في ERROR(/File) ، وإرجاع مرجع لهذا File .

boolean pushDir (File localFileDir, String deviceFilePath, excludedDirectories) pushDir (File localFileDir, String deviceFilePath, excludedDirectories)

دفع محتويات الدليل بشكل متكرر إلى الجهاز مع استبعاد بعض الأدلة التي تمت تصفيتها.

boolean pushDir (File localFileDir, String deviceFilePath)

دفع محتويات الدليل بشكل متكرر إلى الجهاز.

boolean pushFile (File localFile, String remoteFilePath, boolean evaluateContentProviderNeeded)

متغير pushFile(File, String) والذي يمكن أن يفكر اختياريًا في تقييم الحاجة إلى مزود المحتوى.

boolean pushFile (File localFile, String remoteFilePath)

دفع ملف إلى الجهاز.

boolean pushString (String contents, String remoteFilePath)

دفع ملف تم إنشاؤه من سلسلة إلى جهاز

void reboot (String reason)

يعيد تشغيل الجهاز في وضع adb مع reason معين للاستمرار في إعادة التشغيل.

void reboot ()

يعيد تشغيل الجهاز في وضع adb.

void rebootIntoBootloader ()

يعيد تشغيل الجهاز في وضع أداة تحميل التشغيل.

void rebootIntoFastbootd ()

يعيد تشغيل الجهاز في وضع fastbootd.

void rebootIntoRecovery ()

يعيد تشغيل الجهاز في وضع استرداد adb.

void rebootIntoSideload ()

يعيد تشغيل الجهاز في وضع التحميل الجانبي adb (لاحظ أن هذا وضع خاص قيد الاسترداد)

كتل حتى يدخل الجهاز في وضع التحميل الجانبي

void rebootIntoSideload (boolean autoReboot)

يعيد تشغيل الجهاز في وضع التحميل الجانبي adb (لاحظ أن هذا وضع خاص قيد الاسترداد)

كتل حتى يدخل الجهاز في وضع التحميل الجانبي

void rebootUntilOnline ()

بديل لإعادة reboot() الذي يمنع فقط حتى يصبح الجهاز متصلًا بالإنترنت ، أي مرئيًا لـ adb.

void rebootUntilOnline (String reason)

بديل لإعادة reboot() الذي يمنع فقط حتى يصبح الجهاز متصلًا بالإنترنت ، أي مرئيًا لـ adb.

void rebootUserspace ()

يعيد تشغيل جزء مساحة المستخدمين فقط من الجهاز.

void rebootUserspaceUntilOnline ()

بديل لـ rebootUserspace() ()} الذي يمنع فقط حتى يصبح الجهاز متصلًا بالإنترنت ، أي مرئيًا لـ adb.

boolean recoverDevice ()

محاولات لاستعادة اتصال الجهاز.

void registerDeviceActionReceiver ( IDeviceActionReceiver deviceActionReceiver)

يسجل IDeviceActionReceiver لهذا الجهاز.

void remountSystemWritable ()

اجعل قسم النظام على الجهاز قابلاً للكتابة.

void remountVendorWritable ()

اجعل قسم البائع على الجهاز قابلاً للكتابة.

boolean removeAdmin (String componentName, int userId)

قم بإزالة مسؤول الجهاز المحدد في مستخدم معين وإرجاع true إذا كان ناجحًا ، false في الحالات الأخرى.

void removeOwners ()

قم بإزالة جميع مالكي ملفات تعريف الجهاز الحاليين بأفضل جهد.

boolean removeUser (int userId)

إزالة مستخدم معين من الجهاز.

void resetContentProviderSetup ()

أعد تعيين علامة إعداد مزود المحتوى من أجل تشغيله مرة أخرى.

boolean runInstrumentationTests (IRemoteAndroidTestRunner runner, ITestLifeCycleReceiver... listeners)

طريقة ملائمة لإجراء ERROR(/#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection)) مع تمرير واحد أو أكثر من المستمعين كمعلمات.

boolean runInstrumentationTests (IRemoteAndroidTestRunner runner, listeners) runInstrumentationTests (IRemoteAndroidTestRunner runner, listeners)

يُجري اختبارات الأجهزة ، ويوفر إمكانية استرداد الجهاز.

boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, listeners) runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, listeners)

مماثل ERROR(ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection)/com.android.tradefed.device.ITestDevice#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection) ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection)) اختبار للمستخدم المحدد.

boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, ITestLifeCycleReceiver... listeners)

تمامًا مثل ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, ITestLifeCycleReceiver...) ولكنه يدير الاختبار لمستخدم معين.

void setConfiguration ( IConfiguration configuration)

يُحقن رمز IConfiguration قيد الاستخدام.

void setDate (Date date)

يضبط التاريخ على الجهاز

ملاحظة: يتطلب تحديد التاريخ على الجهاز الجذر

boolean setDeviceOwner (String componentName, int userId)

قم بتعيين مكون مسؤول الجهاز كمالك للجهاز في مستخدم معين.

void setDeviceState ( TestDeviceState deviceState)

قم بتحديث حالة الجهاز.

void setEmulatorOutputStream ( SizeLimitedOutputStream output)

لمجموعة المحاكي SizeLimitedOutputStream لتسجيل الإخراج

void setEmulatorProcess (Process p)

يضبط ERROR(/Process) ، عندما يكون هذا الجهاز محاكيًا.

void setFastbootEnabled (boolean fastbootEnabled)

اضبط خيار Fastboot للجهاز.

void setFastbootPath (String fastbootPath)

يضبط المسار إلى ملف fastboot الثنائي الذي يجب استخدامه.

void setIDevice (IDevice newDevice)

قم بتحديث IDevice المرتبط بجهاز ITestDevice هذا.

void setLogStartDelay (int delay)

يضبط الوقت بالمللي ثانية للانتظار قبل بدء التقاط logcat لجهاز متصل بالإنترنت.

void setOptions ( TestDeviceOptions options)

اضبط TestDeviceOptions للجهاز

boolean setProperty (String propKey, String propValue)

يضبط قيمة الخاصية المحددة على الجهاز.

void setRecovery ( IDeviceRecovery recovery)

قم بتعيين IDeviceRecovery لاستخدامه لهذا الجهاز.

void setRecoveryMode ( ITestDevice.RecoveryMode mode)

اضبط وضع الاسترداد الحالي لاستخدامه للجهاز.

void setSetting (String namespace, String key, String value)

انظر setSetting(int, String, String, String) ويتم إجراؤها على مستخدم النظام.

void setSetting (int userId, String namespace, String key, String value)

أضف قيمة الإعداد إلى مساحة الاسم لمستخدم معين.

void setTestLogger ( ITestLogger testLogger)

يقوم بإدخال مثيل ITestLogger

void setUseFastbootErase (boolean useFastbootErase)

حدد ما إذا كنت تريد استخدام تنسيق Fastboot أو تنسيق fastboot لمسح قسم على الجهاز.

void startLogcat ()

ابدأ في التقاط إخراج logcat من الجهاز في الخلفية.

boolean startUser (int userId)

يبدأ مستخدمًا معينًا في الخلفية إذا تم إيقافه حاليًا.

boolean startUser (int userId, boolean waitFlag)

يبدأ مستخدمًا معينًا في الخلفية إذا تم إيقافه حاليًا.

boolean startVisibleBackgroundUser (int userId, int displayId, boolean waitFlag)

يبدأ مستخدمًا معينًا في الخلفية ، ويكون مرئيًا في الشاشة المحددة (على سبيل المثال ، السماح للمستخدم ببدء الأنشطة في تلك الشاشة).

void stopEmulatorOutput ()

أغلق واحذف ناتج المحاكي.

void stopLogcat ()

توقف عن التقاط إخراج logcat من الجهاز ، وتجاهل بيانات logcat المحفوظة حاليًا.

boolean stopUser (int userId)

يوقف مستخدم معين.

boolean stopUser (int userId, boolean waitFlag, boolean forceFlag)

وقف مستخدم معين.

String switchToAdbTcp ()

تبديل الجهاز إلى وضع adb-over-tcp.

boolean switchToAdbUsb ()

قم بتبديل الجهاز إلى وضع ADB عبر USB.

boolean switchUser (int userId)

قم بالتبديل إلى معرف مستخدم آخر بمهلة افتراضية.

boolean switchUser (int userId, long timeout)

قم بالتبديل إلى معرف مستخدم آخر مع انتهاء المهلة المحددة كموعد نهائي.

boolean syncFiles (File localFileDir, String deviceFilePath)

يقوم بمزامنة محتويات دليل ملف محلي إلى الجهاز بشكل متزايد.

Bugreport takeBugreport ()

خذ تقرير خطأ وأعده داخل كائن Bugreport للتعامل معه.

String uninstallPackage (String packageName)

قم بإلغاء تثبيت حزمة Android من الجهاز.

String uninstallPackageForUser (String packageName, int userId)

قم بإلغاء تثبيت حزمة Android من الجهاز لمستخدم معين.

boolean unlockDevice ()

يفتح الجهاز إذا كان في حالة مشفرة.

boolean waitForBootComplete (long timeOut)

كتل حتى يتم تعيين علامة اكتمال تمهيد الجهاز.

boolean waitForDeviceAvailable ()

ينتظر أن يكون الجهاز مستجيبًا ومتاحًا للاختبار.

boolean waitForDeviceAvailable (long waitTime)

ينتظر أن يكون الجهاز مستجيبًا ومتاحًا للاختبار.

boolean waitForDeviceAvailableInRecoverPath (long waitTime)

ينتظر أن يكون الجهاز مستجيبًا ومتاحًا دون التفكير في مسار الاسترداد.

void waitForDeviceBootloader ()

كتل حتى يظهر الجهاز عبر Fastboot.

boolean waitForDeviceInRecovery (long waitTime)

كتل للجهاز ليكون في حالة "استرداد adb" (لاحظ أن هذا يختلف عن IDeviceRecovery ).

boolean waitForDeviceInSideload (long waitTime)

كتل للجهاز ليكون في حالة "adb sideload"

boolean waitForDeviceNotAvailable (long waitTime)

كتل للجهاز ليكون غير متاح أي مفقود من adb

void waitForDeviceOnline ()

يحظر حتى يظهر الجهاز عبر ADB.

void waitForDeviceOnline (long waitTime)

يحظر حتى يظهر الجهاز عبر ADB.

boolean waitForDeviceShell (long waitTime)

ينتظر أن يستجيب الجهاز لأمر adb shell الأساسي.

الطرق المحمية

String[] buildAdbShellCommand (String command, boolean forceExitStatusDetection)

يبني أمر نظام التشغيل لجلسة أمر adb shell و args

void checkApiLevelAgainst (String feature, int strictMinLevel)
NativeDevice.RebootDeviceAction createRebootDeviceAction ( NativeDevice.RebootMode rebootMode, String reason)

قم بإنشاء RebootDeviceAction لاستخدامه عند تنفيذ إجراء إعادة التشغيل.

IRunUtil createRunUtil ()
void doAdbReboot ( NativeDevice.RebootMode rebootMode, String reason)

قم بإجراء إعادة تشغيل adb.

void ensureRuntimePermissionSupported ()

طريقة مساعدة لطرح استثناء إذا لم يتم دعم إذن وقت التشغيل

int getApiLevelSafe ()
ITestLogger getLogger ()
IRunUtil getRunUtil ()

احصل على مثيل RunUtil المراد استخدامه.

void initializeConnection ( IBuildInfo info, MultiMap <String, String> attributes)
String internalGetProperty (String propName, String fastbootVar, String description)

قم بإحضار خاصية الجهاز ، من ذاكرة التخزين المؤقت ddmlib افتراضيًا ، والعودة إلى "adb shell getprop" أو "fastboot getvar" اعتمادًا على ما إذا كان الجهاز في Fastboot أم لا.

boolean isInRebootCallback ()

إرجاع ما إذا كان يتم تنفيذ عمليات الاسترجاعات الخاصة بإعادة التشغيل حاليًا أم لا.

boolean isNewer (File localFile, IFileEntry entry)

إرجاع true إذا كان الملف المحلي أحدث من الملف البعيد.

void notifyRebootEnded ()

يخطر كل IDeviceActionReceiver بحدث إنهاء إعادة التشغيل.

void notifyRebootStarted ()

يخطر كل IDeviceActionReceiver بحدث بدء إعادة التشغيل.

boolean performDeviceAction (String actionDescription, NativeDevice.DeviceAction action, int retryAttempts)

يقوم بإجراء على هذا الجهاز.

void postAdbReboot ()

الإجراءات الإضافية المحتملة التي يمكن اتخاذها بعد إعادة التشغيل.

void prePostBootSetup ()

يسمح لكل نوع جهاز (AndroidNativeDevice ، TestDevice) بتجاوز هذه الطريقة لإعداد ما بعد التمهيد المحدد.

boolean pullFileInternal (String remoteFilePath, File localFile)
void setClock (Clock clock)

اضبط مثيل الساعة المراد استخدامه.

void setMicrodroidProcess (Process process)

يميز TestDevice بأنه microdroid ويعين CID الخاص به.

void setTestDeviceOptions ( deviceOptions) setTestDeviceOptions ( deviceOptions)
CommandResult simpleFastbootCommand (long timeout, envVarMap, String[] fullCmd) simpleFastbootCommand (long timeout, envVarMap, String[] fullCmd)

ينفذ أمر fastboot بسيطًا مع متغيرات البيئة ويبلغ عن حالة الأمر.

CommandResult simpleFastbootCommand (long timeout, String[] fullCmd)

ينفذ أمر fastboot البسيط ويبلغ عن حالة الأمر.

boolean waitForDeviceNotAvailable (String operationDesc, long time)

انتظر حتى ترى الجهاز غير متاح (توقف عن إرسال التقارير إلى adb).

الثوابت

هوية مستخدم غير صالحه

public static final int INVALID_USER_ID

القيمة التي تم إرجاعها لأي معرف مستخدم غير صالح / غير موجود: حدد UserHandle القيمة -10000

قيمة ثابتة: -10000 (0xffffd8f0)

MAX_HOST_DEVICE_TIME_OFFSET

protected static final long MAX_HOST_DEVICE_TIME_OFFSET

قيمة ثابتة: 5000 (0x0000000000001388)

MAX_RETRY_ATTEMPTS

protected static final int MAX_RETRY_ATTEMPTS

العدد الافتراضي لمحاولات الأمر إجراء

قيمة ثابتة: 2 (0x00000002)

مجالات

بطاقة الذاكرة

protected static final String SD_CARD

STORAGE_EMULATED

protected static final String STORAGE_EMULATED

mOptions

protected TestDeviceOptions mOptions

mStateMonitor

protected final IDeviceStateMonitor mStateMonitor

المنشأت العامة

NativeDevice

public NativeDevice (IDevice device, 
                IDeviceStateMonitor stateMonitor, 
                IDeviceMonitor allocationMonitor)

ينشئ TestDevice .

حدود
device IDevice : معرف IDevice المرتبط

stateMonitor IDeviceStateMonitor : آلية IDeviceStateMonitor المراد استخدامها

allocationMonitor IDeviceMonitor : IDeviceMonitor للإبلاغ عن تغييرات حالة التخصيص. يمكن أن تكون خالية

الأساليب العامة

canSwitchToHeadlessSystemUser

public boolean canSwitchToHeadlessSystemUser ()

إرجاع ما إذا كان مسموحًا بالانتقال إلى مستخدم النظام بدون رأس.

عائدات
boolean

رميات
DeviceNotAvailableException

تحقق من مستوى ApiLevelAgainstNextRelease

public boolean checkApiLevelAgainstNextRelease (int strictMinLevel)

تحقق مما إذا كانت الميزة مدعومة حاليًا أم لا نظرًا لمستوى الدعم الأدنى أم لا. تأخذ هذه الطريقة في الاعتبار الميزات التي لم يتم إصدارها حتى الآن ، قبل رفع مستوى واجهة برمجة التطبيقات.

حدود
strictMinLevel int : الحد الأدنى الصارم للمستوى الممكن الذي يدعم الميزة.

عائدات
boolean صحيح إذا كان المستوى مدعومًا. خطأ خلاف ذلك.

رميات
DeviceNotAvailableException

تحقق من الاتصال

public boolean checkConnectivity ()

تحقق من اتصال هذا الجهاز بالشبكة.

عائدات
boolean true إذا كان الجهاز به اتصال شبكة يعمل ، false في الاتجاه المعاكس.

رميات
DeviceNotAvailableException

clearErrorDialogs

public boolean clearErrorDialogs ()

محاولة استبعاد أي مربعات حوار خطأ معروضة حاليًا على واجهة مستخدم الجهاز.

عائدات
boolean true في حالة عدم وجود مربعات حوار أو تم مسح الحوارات بنجاح. false ذلك كاذبة.

رميات
DeviceNotAvailableException

clearLastConnectedWifiNetwork

public void clearLastConnectedWifiNetwork ()

مسح آخر شبكة wifi متصلة. يجب استدعاء هذا عند بدء استدعاء جديد لتجنب الاتصال بشبكة wifi المستخدمة في الاختبار السابق بعد إعادة تشغيل الجهاز.

clearLogcat

public void clearLogcat ()

يحذف أي بيانات logcat المتراكمة.

يعد هذا مفيدًا للحالات التي تريد فيها التأكد من ITestDevice#getLogcat() يقوم فقط بإرجاع بيانات السجل التي تم إنتاجها بعد نقطة معينة (على سبيل المثال ، بعد وميض إصدار جهاز جديد ، وما إلى ذلك).

connectToWifiNetwork

public boolean connectToWifiNetwork ( wifiSsidToPsk, 
                boolean scanSsid)

يتصل بشبكة wifi.

يقوم بتشغيل wifi والحظر حتى يتم إجراء اتصال ناجح بإحدى شبكات wifi الواردة في خريطة wifiSsidToPsk. بمجرد إجراء الاتصال ، سيحاول المثيل استعادة الاتصال بعد كل إعادة تشغيل حتى يتم استدعاء ITestDevice#disconnectFromWifi() أو ITestDevice#clearLastConnectedWifiNetwork() .

حدود
wifiSsidToPsk : خريطة wifi SSID لكلمات المرور.

scanSsid boolean : ما إذا كان سيتم البحث عن معرّفات SSID المخفية لهذه الشبكة.

عائدات
boolean true إذا تم الاتصال بشبكة wifi بنجاح. خلاف ذلك false

رميات
DeviceNotAvailableException

connectToWifiNetwork

public boolean connectToWifiNetwork (String wifiSsid, 
                String wifiPsk)

يتصل بشبكة wifi.

يقوم بتشغيل wifi والحظر حتى يتم إجراء اتصال ناجح بشبكة wifi المحددة. بمجرد إجراء الاتصال ، سيحاول المثيل استعادة الاتصال بعد كل إعادة تشغيل حتى يتم استدعاء ITestDevice#disconnectFromWifi() أو ITestDevice#clearLastConnectedWifiNetwork() .

حدود
wifiSsid String : wifi ssid للاتصال به

wifiPsk String : عبارة مرور PSK أو خالية إذا لم يتم تشفيرها

عائدات
boolean true إذا تم الاتصال بشبكة wifi بنجاح. خلاف ذلك false

رميات
DeviceNotAvailableException

connectToWifiNetwork

public boolean connectToWifiNetwork ( wifiSsidToPsk)

يتصل بشبكة wifi.

يقوم بتشغيل wifi والحظر حتى يتم إجراء اتصال ناجح بإحدى شبكات wifi الواردة في خريطة wifiSsidToPsk. بمجرد إجراء الاتصال ، سيحاول المثيل استعادة الاتصال بعد كل إعادة تشغيل حتى يتم استدعاء ITestDevice#disconnectFromWifi() أو ITestDevice#clearLastConnectedWifiNetwork()

حدود
wifiSsidToPsk : خريطة wifi SSID لكلمات المرور.

عائدات
boolean true إذا تم الاتصال بشبكة wifi بنجاح. خلاف ذلك false

رميات
DeviceNotAvailableException

connectToWifiNetwork

public boolean connectToWifiNetwork (String wifiSsid, 
                String wifiPsk, 
                boolean scanSsid)

يتصل بشبكة wifi.

يقوم بتشغيل wifi والحظر حتى يتم إجراء اتصال ناجح بشبكة wifi المحددة. بمجرد إجراء الاتصال ، سيحاول المثيل استعادة الاتصال بعد كل إعادة تشغيل حتى يتم استدعاء ITestDevice#disconnectFromWifi() أو ITestDevice#clearLastConnectedWifiNetwork() .

حدود
wifiSsid String : wifi ssid للاتصال به

wifiPsk String : عبارة مرور PSK أو خالية إذا لم يتم تشفيرها

scanSsid boolean : ما إذا كان سيتم البحث عن SSID المخفي لهذه الشبكة.

عائدات
boolean true إذا تم الاتصال بشبكة wifi بنجاح. خلاف ذلك false

رميات
DeviceNotAvailableException

connectToWifiNetworkIfNeeded

public boolean connectToWifiNetworkIfNeeded (String wifiSsid, 
                String wifiPsk, 
                boolean scanSsid)

متغير من connectToWifiNetwork(String, String) يتصل فقط إذا كان الجهاز لا يحتوي حاليًا على اتصال بالشبكة.

حدود
scanSsid boolean : ما إذا كان سيتم البحث عن SSID المخفي لهذه الشبكة

عائدات
boolean true إذا تم الاتصال بشبكة wifi بنجاح. خلاف ذلك false

رميات
DeviceNotAvailableException

connectToWifiNetworkIfNeeded

public boolean connectToWifiNetworkIfNeeded (String wifiSsid, 
                String wifiPsk)

متغير من connectToWifiNetwork(String, String) يتصل فقط إذا كان الجهاز لا يحتوي حاليًا على اتصال بالشبكة.

عائدات
boolean true إذا تم الاتصال بشبكة wifi بنجاح. خلاف ذلك false

رميات
DeviceNotAvailableException

createUser

public int createUser (String name, 
                boolean guest, 
                boolean ephemeral)

قم بإنشاء مستخدم باسم معين والعلامات المقدمة

حدود
name String : للمستخدم الذي سيتم إنشاؤه على الجهاز

guest boolean : تمكين إشارة المستخدم أثناء الإنشاء

ephemeral boolean : تمكين علامة المستخدم - الرمز الشخصي أثناء الإنشاء

عائدات
int معرف المستخدم الذي تم إنشاؤه

رميات
DeviceNotAvailableException

createUser

public int createUser (String name, 
                boolean guest, 
                boolean ephemeral, 
                boolean forTesting)

قم بإنشاء مستخدم باسم معين والعلامات المقدمة

حدود
name String : للمستخدم الذي سيتم إنشاؤه على الجهاز

guest boolean : تمكين إشارة المستخدم أثناء الإنشاء

ephemeral boolean : تمكين علامة المستخدم - الرمز الشخصي أثناء الإنشاء

forTesting boolean : تمكين علامة الاختبار - للاختبار أثناء الإنشاء

عائدات
int معرف المستخدم الذي تم إنشاؤه

رميات
DeviceNotAvailableException

createUser

public int createUser (String name)

قم بإنشاء مستخدم باسم معين وعلامات افتراضية 0.

حدود
name String : للمستخدم الذي سيتم إنشاؤه على الجهاز

عائدات
int العدد الصحيح لمعرف المستخدم الذي تم إنشاؤه

رميات
DeviceNotAvailableException

createUserNoThrow

public int createUserNoThrow (String name)

قم بإنشاء مستخدم باسم معين وعلامات افتراضية 0.

حدود
name String : للمستخدم الذي سيتم إنشاؤه على الجهاز

عائدات
int العدد الصحيح لمعرف المستخدم الذي تم إنشاؤه أو -1 للخطأ.

رميات
DeviceNotAvailableException

حذف ملف

public void deleteFile (String deviceFilePath)

طريقة مساعدة لحذف ملف أو دليل على الجهاز.

حدود
deviceFilePath String : المسار المطلق للملف على الجهاز.

رميات
DeviceNotAvailableException

إلغاء تسجيل جهاز الاستقبال

public void deregisterDeviceActionReceiver (IDeviceActionReceiver deviceActionReceiver)

يزيل IDeviceActionReceiver المسجل.

حدود
deviceActionReceiver IDeviceActionReceiver : جهاز IDeviceActionReceiver الذي ستتم إزالته.

الجهازSoftRestarted

public boolean deviceSoftRestarted (ProcessInfo prevSystemServerProcess)

طريقة مساعدة للتحقق مما إذا كان الجهاز قد تمت إعادة تشغيله بشكل بسيط عن طريق مقارنة خادم النظام الحالي مع System_server السابق ProcessInfo . استخدم getProcessByName(String) للحصول على ProcessInfo .

حدود
prevSystemServerProcess ProcessInfo : عملية خادم النظام السابقة ProcessInfo .

عائدات
boolean true إذا تم إعادة تشغيل الجهاز

رميات
DeviceNotAvailableException

الجهاز سوفت إعادة التشغيل منذ ذلك الحين

public boolean deviceSoftRestartedSince (long utcEpochTime, 
                TimeUnit timeUnit)

طريقة مساعدة للتحقق مما إذا كان الجهاز قد تمت إعادة تشغيله بشكل بسيط منذ وقت UTC منذ الحقبة من الجهاز ERROR(/TimeUnit) . يشير Soft-Restart إلى إعادة تشغيل خادم النظام خارج إعادة تشغيل الجهاز (على سبيل المثال: طلب إعادة التشغيل). يمكن الحصول على الجهاز الحالي utcEpochTime بالمللي ثانية بواسطة الأسلوب getDeviceDate() .

حدود
utcEpochTime long : وقت الجهاز في الثانية منذ العصر.

timeUnit TimeUnit : وحدة الوقت TimeUnit لـ utcEpochTime المحدد.

عائدات
boolean true إذا تم إعادة تشغيل الجهاز

رميات
DeviceNotAvailableException

تعطيلAdbRoot

public boolean disableAdbRoot ()

يوقف adb root.

قد يؤدي تعطيل adb root إلى فصل الجهاز عن adb. سيتم حظر هذه الطريقة حتى يتوفر الجهاز.

عائدات
boolean true إذا نجح.

رميات
DeviceNotAvailableException

تعطيل Keyguard

public void disableKeyguard ()

محاولات لتعطيل حارس المفاتيح.

انتظر أولاً حتى يصبح إرسال الإدخال جاهزًا ، يحدث هذا في نفس الوقت تقريبًا عندما يقوم الجهاز بإبلاغ BOOT_COMPLETE ، على ما يبدو بشكل غير متزامن ، لأن تنفيذ إطار العمل الحالي به حالة سباق عرضية. ثم يتم إرسال الأمر لإبعاد حارس المفاتيح (يعمل على الحراس غير الآمنين فقط)

رميات
DeviceNotAvailableException

DisableNetworkMonitor

public boolean disableNetworkMonitor ()

تعطيل مراقبة الشبكة على الجهاز.

عائدات
boolean true إذا تم تعطيل المراقبة بنجاح. false إذا فشلت.

رميات
DeviceNotAvailableException

قطع الاتصال من واي فاي

public boolean disconnectFromWifi ()

قطع الاتصال بشبكة wifi.

يزيل جميع الشبكات من قائمة الشبكات المعروفة ويعطل wifi.

عائدات
boolean true إذا تم قطع الاتصال بشبكة wifi بنجاح. false إذا فشل قطع الاتصال.

رميات
DeviceNotAvailableException

doesFileExist

public boolean doesFileExist (String deviceFilePath, 
                int userId)

طريقة مساعدة لتحديد ما إذا كان الملف الموجود على الجهاز موجودًا لمستخدم معين.

حدود
deviceFilePath String : المسار المطلق للملف المراد فحصه على الجهاز

userId int : معرف المستخدم المراد التحقق من وجود الملف على أساسه

عائدات
boolean true إذا كان الملف موجودًا ، false بخلاف ذلك.

رميات
DeviceNotAvailableException

doesFileExist

public boolean doesFileExist (String deviceFilePath)

طريقة مساعدة لتحديد ما إذا كان الملف على الجهاز موجودًا.

حدود
deviceFilePath String : المسار المطلق للملف المراد فحصه على الجهاز

عائدات
boolean true إذا كان الملف موجودًا ، false بخلاف ذلك.

رميات
DeviceNotAvailableException

كومة

public File dumpHeap (String process, 
                String devicePath)

محاولة تفريغ الكومة من خادم النظام. تقع على عاتق المتصل مسؤولية تنظيف الملف الملغى.

حدود
process String : اسم عملية الجهاز المراد dumpheap تشغيلها.

devicePath String : المسار الموجود على الجهاز حيث يتم وضع التفريغ. يجب أن يكون هذا موقعًا تسمح به الأذونات.

عائدات
File ERROR(/File) الذي يحتوي على التقرير. لاغية إذا فشل شيء ما.

رميات
DeviceNotAvailableException

تمكينAdbRoot

public boolean enableAdbRoot ()

يتحول على adb root. إذا كان إعداد "تمكين الجذر" هو "خطأ" ، فسيتم تسجيل الرسالة والعودة بدون تمكين الجذر.

قد يؤدي تمكين adb root إلى فصل الجهاز عن adb. سيتم حظر هذه الطريقة حتى يتوفر الجهاز.

عائدات
boolean true إذا نجح.

رميات
DeviceNotAvailableException

تمكين NetworkMonitor

public boolean enableNetworkMonitor ()

تمكن مراقبة الشبكة على الجهاز.

عائدات
boolean true إذا تم تمكين المراقبة بنجاح. false إذا فشلت.

رميات
DeviceNotAvailableException

executeAdbCommand

public String executeAdbCommand (long timeout, 
                String... cmdArgs)

طريقة المساعد التي تنفذ أمر adb كأمر نظام مع مهلة محددة.

يجب استخدام executeShellCommand(String) بدلاً من ذلك حيثما كان ذلك ممكنًا ، لأن هذه الطريقة توفر أداءً واكتشافًا أفضل للفشل.

حدود
timeout long : الوقت بالمللي ثانية قبل اعتبار الجهاز غير مستجيب ، 0L لعدم وجود مهلة

cmdArgs String : الأمر adb والوسيطات المراد تشغيلها

عائدات
String stdout من القيادة. null إذا فشل الأمر في التنفيذ.

رميات
DeviceNotAvailableException

executeAdbCommand

public String executeAdbCommand (long timeout, 
                 envMap, 
                String... cmdArgs)

طريقة المساعد التي تنفذ أمر adb كأمر نظام مع مهلة محددة.

يجب استخدام executeShellCommand(String) بدلاً من ذلك حيثما كان ذلك ممكنًا ، لأن هذه الطريقة توفر أداءً واكتشافًا أفضل للفشل.

حدود
timeout long : الوقت بالمللي ثانية قبل اعتبار الجهاز غير مستجيب ، 0L لعدم وجود مهلة

envMap : البيئة المراد تعيينها للأمر

cmdArgs String : الأمر adb والوسيطات المراد تشغيلها

عائدات
String stdout من القيادة. null إذا فشل الأمر في التنفيذ.

رميات
DeviceNotAvailableException

executeAdbCommand

public String executeAdbCommand (String... cmdArgs)

طريقة المساعد التي تنفذ أمر adb كأمر نظام.

يجب استخدام executeShellCommand(String) بدلاً من ذلك حيثما كان ذلك ممكنًا ، لأن هذه الطريقة توفر أداءً واكتشافًا أفضل للفشل.

حدود
cmdArgs String : الأمر adb والوسيطات المراد تشغيلها

عائدات
String stdout من القيادة. null إذا فشل الأمر في التنفيذ.

رميات
DeviceNotAvailableException

executeFastbootCommand

public CommandResult executeFastbootCommand (String... cmdArgs)

طريقة المساعدة التي تنفذ أمر fastboot كأمر نظام مع مهلة افتراضية تبلغ دقيقتين.

من المتوقع استخدامه عندما يكون الجهاز في وضع Fastboot بالفعل.

حدود
cmdArgs String : الأمر fastboot والوسيطات المراد تشغيلها

عائدات
CommandResult تحتوي CommandResult على إخراج الأمر

رميات
DeviceNotAvailableException

executeFastbootCommand

public CommandResult executeFastbootCommand (long timeout, 
                String... cmdArgs)

طريقة المساعد التي تنفذ أمر fastboot كأمر نظام.

من المتوقع استخدامه عندما يكون الجهاز في وضع Fastboot بالفعل.

حدود
timeout long : الوقت بالمللي ثانية قبل انتهاء صلاحية الأمر

cmdArgs String : الأمر fastboot والوسيطات المراد تشغيلها

عائدات
CommandResult تحتوي CommandResult على إخراج الأمر

رميات
DeviceNotAvailableException

executeLongFastbootCommand

public CommandResult executeLongFastbootCommand (String... cmdArgs)

طريقة المساعد التي تقوم بتنفيذ أمر fastboot الذي يعمل لفترة طويلة كأمر نظام.

مطابق لـ executeFastbootCommand(String) باستثناء استخدام مهلة أطول.

حدود
cmdArgs String : الأمر fastboot والوسيطات المراد تشغيلها

عائدات
CommandResult تحتوي CommandResult على إخراج الأمر

رميات
DeviceNotAvailableException

executeLongFastbootCommand

public CommandResult executeLongFastbootCommand ( envVarMap, 
                String... cmdArgs)

طريقة المساعد التي تنفذ أمر fastboot الذي يعمل لفترة طويلة كأمر نظام مع متغيرات بيئة النظام.

مطابق لـ executeFastbootCommand(String) باستثناء استخدام مهلة أطول.

حدود
envVarMap : متغيرات بيئة النظام التي يعمل بها الأمر fastboot

cmdArgs String : الأمر fastboot والوسيطات المراد تشغيلها

عائدات
CommandResult تحتوي CommandResult على إخراج الأمر

رميات
DeviceNotAvailableException

executeShellCommand

public String executeShellCommand (String command)

أسلوب المساعد الذي ينفذ أمر adb shell ويعيد الإخراج ERROR(/String) .

حدود
command String : أمر adb shell المراد تشغيله

عائدات
String إخراج قذيفة

رميات
DeviceNotAvailableException

executeShellCommand

public void executeShellCommand (String command, 
                IShellOutputReceiver receiver, 
                long maxTimeToOutputShellResponse, 
                TimeUnit timeUnit, 
                int retryAttempts)

ينفذ أمر adb shell ، مع المزيد من المعلمات للتحكم في سلوك الأمر.

حدود
command String : أمر adb shell المراد تشغيله

receiver IShellOutputReceiver : the IShellOutputReceiver to direct shell output to.

maxTimeToOutputShellResponse long : the maximum amount of time during which the command is allowed to not output any response; unit as specified in timeUnit

timeUnit TimeUnit : unit for maxTimeToOutputShellResponse

retryAttempts int : the maximum number of times to retry command if it fails due to a exception. DeviceNotResponsiveException will be thrown if retryAttempts are performed without success.

رميات
DeviceNotAvailableException

executeShellCommand

public void executeShellCommand (String command, 
                IShellOutputReceiver receiver, 
                long maxTimeoutForCommand, 
                long maxTimeToOutputShellResponse, 
                TimeUnit timeUnit, 
                int retryAttempts)

Executes a adb shell command, with more parameters to control command behavior.

حدود
command String : the adb shell command to run

receiver IShellOutputReceiver : the IShellOutputReceiver to direct shell output to.

maxTimeoutForCommand long : the maximum timeout for the command to complete; unit as specified in timeUnit

maxTimeToOutputShellResponse long : the maximum amount of time during which the command is allowed to not output any response; unit as specified in timeUnit

timeUnit TimeUnit : unit for maxTimeToOutputShellResponse

retryAttempts int : the maximum number of times to retry command if it fails due to a exception. DeviceNotResponsiveException will be thrown if retryAttempts are performed without success.

رميات
DeviceNotAvailableException

executeShellCommand

public void executeShellCommand (String command, 
                IShellOutputReceiver receiver)

Executes the given adb shell command, retrying multiple times if command fails.

A simpler form of executeShellCommand(String, com.android.ddmlib.IShellOutputReceiver, long, TimeUnit, int) with default values.

حدود
command String : the adb shell command to run

receiver IShellOutputReceiver : the IShellOutputReceiver to direct shell output to.

رميات
DeviceNotAvailableException

executeShellV2Command

public CommandResult executeShellV2Command (String cmd)

Helper method which executes a adb shell command and returns the results as a CommandResult properly populated with the command status output, stdout and stderr.

حدود
cmd String : The command that should be run.

عائدات
CommandResult The result in CommandResult .

رميات
DeviceNotAvailableException

executeShellV2Command

public CommandResult executeShellV2Command (String cmd, 
                OutputStream pipeToOutput)

Helper method which executes an adb shell command and returns the results as a CommandResult properly populated with the command status output and stderr. stdout is directed to the specified stream.

حدود
cmd String : The command that should be run.

pipeToOutput OutputStream : ERROR(/OutputStream) where the std output will be redirected, or null.

عائدات
CommandResult The result in CommandResult .

رميات
DeviceNotAvailableException

executeShellV2Command

public CommandResult executeShellV2Command (String cmd, 
                File pipeAsInput)

Helper method which executes an adb shell command and returns the results as a CommandResult properly populated with the command status output, stdout and stderr.

حدود
cmd String : The command that should be run.

pipeAsInput File : A ERROR(/File) that will be piped as input to the command, or null.

عائدات
CommandResult The result in CommandResult .

رميات
DeviceNotAvailableException

executeShellV2Command

public CommandResult executeShellV2Command (String cmd, 
                long maxTimeoutForCommand, 
                TimeUnit timeUnit, 
                int retryAttempts)

Executes a adb shell command, with more parameters to control command behavior.

حدود
cmd String : the adb shell command to run

maxTimeoutForCommand long : the maximum timeout for the command to complete; unit as specified in timeUnit

timeUnit TimeUnit : unit for maxTimeToOutputShellResponse

retryAttempts int : the maximum number of times to retry command if it fails due to a exception. DeviceNotResponsiveException will be thrown if retryAttempts are performed without success.

عائدات
CommandResult

رميات
DeviceNotAvailableException

executeShellV2Command

public CommandResult executeShellV2Command (String cmd, 
                long maxTimeoutForCommand, 
                TimeUnit timeUnit)

Executes a adb shell command, with more parameters to control command behavior.

حدود
cmd String : the adb shell command to run

maxTimeoutForCommand long : the maximum timeout for the command to complete; unit as specified in timeUnit

timeUnit TimeUnit : unit for maxTimeToOutputShellResponse

عائدات
CommandResult

رميات
DeviceNotAvailableException

executeShellV2Command

public CommandResult executeShellV2Command (String cmd, 
                File pipeAsInput, 
                OutputStream pipeToOutput, 
                long maxTimeoutForCommand, 
                TimeUnit timeUnit, 
                int retryAttempts)

Executes a adb shell command, with more parameters to control command behavior.

حدود
cmd String : the adb shell command to run

pipeAsInput File : A ERROR(/File) that will be piped as input to the command, or null.

pipeToOutput OutputStream : ERROR(/OutputStream) where the std output will be redirected, or null.

maxTimeoutForCommand long : the maximum timeout for the command to complete; unit as specified in timeUnit

timeUnit TimeUnit : unit for maxTimeToOutputShellResponse

retryAttempts int : the maximum number of times to retry command if it fails due to a exception. DeviceNotResponsiveException will be thrown if retryAttempts are performed without success.

عائدات
CommandResult

رميات
DeviceNotAvailableException

executeShellV2Command

public CommandResult executeShellV2Command (String cmd, 
                File pipeAsInput, 
                OutputStream pipeToOutput, 
                OutputStream pipeToError, 
                long maxTimeoutForCommand, 
                TimeUnit timeUnit, 
                int retryAttempts)

Executes a adb shell command, with more parameters to control command behavior.

حدود
cmd String : the adb shell command to run

pipeAsInput File : A ERROR(/File) that will be piped as input to the command, or null.

pipeToOutput OutputStream : ERROR(/OutputStream) where the std output will be redirected, or null.

pipeToError OutputStream : ERROR(/OutputStream) where the std error will be redirected, or null.

maxTimeoutForCommand long : the maximum timeout for the command to complete; unit as specified in timeUnit

timeUnit TimeUnit : unit for maxTimeToOutputShellResponse

retryAttempts int : the maximum number of times to retry command if it fails due to a exception. DeviceNotResponsiveException will be thrown if retryAttempts are performed without success.

عائدات
CommandResult

رميات
DeviceNotAvailableException

fastbootWipePartition

public CommandResult fastbootWipePartition (String partition)

Helper method which wipes a partition for the device.

If getUseFastbootErase() is true , then fastboot erase will be used to wipe the partition. The device must then create a filesystem the next time the device boots. Otherwise, fastboot format is used which will create a new filesystem on the device.

Expected to be used when device is already in fastboot mode.

حدود
partition String : the partition to wipe

عائدات
CommandResult the CommandResult containing output of command

رميات
DeviceNotAvailableException

getActiveApexes

public  getActiveApexes ()

Fetch the information about APEXes activated on the device.

عائدات
ERROR(/Set) of ApexInfo currently activated on the device

رميات
DeviceNotAvailableException

getAllSettings

public  getAllSettings (String namespace)

Return key value pairs of requested namespace.

حدود
namespace String : must be one of {"system", "secure", "global"}

عائدات
the map of key value pairs. Null if namespace is not supported.

رميات
DeviceNotAvailableException

getAllocationState

public DeviceAllocationState getAllocationState ()

Return the current allocation state of device

عائدات
DeviceAllocationState

getAndroidId

public String getAndroidId (int userId)

Find and return the android-id associated to a userId, null if not found.

حدود
userId int

عائدات
String

رميات
DeviceNotAvailableException

getAndroidIds

public  getAndroidIds ()

Create a Map of android ids found matching user ids. There is no insurance that each user id will found an android id associated in this function so some user ids may match null.

عائدات
Map of android ids found matching user ids.

رميات
DeviceNotAvailableException

getApiLevel

public int getApiLevel ()

Get the device API Level. Defaults to UNKNOWN_API_LEVEL .

عائدات
int an integer indicating the API Level of device

رميات
DeviceNotAvailableException

getAppPackageInfo

public PackageInfo getAppPackageInfo (String packageName)

Fetch information about a package installed on device.

حدود
packageName String

عائدات
PackageInfo the PackageInfo or null if information could not be retrieved

رميات
DeviceNotAvailableException

getAppPackageInfos

public  getAppPackageInfos ()

Fetch information of packages installed on the device.

عائدات
ERROR(/List) of PackageInfo s installed on the device.

رميات
DeviceNotAvailableException

getBasebandVersion

public String getBasebandVersion ()

Convenience method to get baseband (radio) version of this device. Getting the radio version is device specific, so it might not return the correct information for all devices. This method relies on the gsm.version.baseband propery to return the correct version information. This is not accurate for some CDMA devices and the version returned here might not match the version reported from fastboot and might not return the version for the CDMA radio. TL;DR this method only reports accurate version if the gsm.version.baseband property is the same as the version returned by fastboot getvar version-baseband .

عائدات
String the ERROR(/String) baseband version or null if it cannot be determined (device has no radio or version string cannot be read)

رميات
DeviceNotAvailableException

getBattery

public Integer getBattery ()

Returns the current battery level of a device or Null if battery level unavailable.

عائدات
Integer

getBooleanProperty

public boolean getBooleanProperty (String name, 
                boolean defaultValue)

Returns boolean value of the given property.

حدود
name String : the property name

defaultValue boolean : default value to return if property is empty or doesn't exist.

عائدات
boolean true if the property has value "1" , "y" , "yes" , "on" , or "true" , false if the property has value of "0" , "n" , "no" , "off" , "false" , or defaultValue otherwise.

رميات
DeviceNotAvailableException

getBootHistory

public  getBootHistory ()

Helper method collects the boot history map with boot time and boot reason.

عائدات
Map of boot time (UTC time in second since Epoch) and boot reason

رميات
DeviceNotAvailableException

getBootHistorySince

public  getBootHistorySince (long utcEpochTime, 
                TimeUnit timeUnit)

Helper method collects the boot history map with boot time and boot reason since the given time since epoch from device and the time unit specified. The current device utcEpochTime in Millisecond can be obtained by method getDeviceDate() .

حدود
utcEpochTime long : the device time since Epoch.

timeUnit TimeUnit : the time unit TimeUnit .

عائدات
Map of boot time (UTC time in second since Epoch) and boot reason

رميات
DeviceNotAvailableException

getBootloaderVersion

public String getBootloaderVersion ()

Convenience method to get the bootloader version of this device.

Will attempt to retrieve bootloader version from the device's current state. (ie if device is in fastboot mode, it will attempt to retrieve version from fastboot)

عائدات
String the ERROR(/String) bootloader version or null if it cannot be found

رميات
DeviceNotAvailableException

getBugreport

public InputStreamSource getBugreport ()

Retrieves a bugreport from the device.

The implementation of this is guaranteed to continue to work on a device without an sdcard (or where the sdcard is not yet mounted).

عائدات
InputStreamSource An InputStreamSource which will produce the bugreport contents on demand. In case of failure, the InputStreamSource will produce an empty ERROR(/InputStream) .

getBugreportz

public InputStreamSource getBugreportz ()

Retrieves a bugreportz from the device. Zip format bugreport contains the main bugreport and other log files that are useful for debugging.

Only supported for 'adb version' > 1.0.36

عائدات
InputStreamSource a InputStreamSource of the zip file containing the bugreportz, return null in case of failure.

getBuildAlias

public String getBuildAlias ()

Retrieve the alias of the build that the device is currently running.

Build alias is usually a more readable string than build id (typically a number for Nexus builds). For example, final Android 4.2 release has build alias JDQ39, and build id 573038

عائدات
String the build alias or fall back to build id if it could not be retrieved

رميات
DeviceNotAvailableException

getBuildFlavor

public String getBuildFlavor ()

Retrieve the build flavor for the device.

عائدات
String the build flavor or null if it could not be retrieved

رميات
DeviceNotAvailableException

getBuildId

public String getBuildId ()

Retrieve the build the device is currently running.

عائدات
String the build id or IBuildInfo#UNKNOWN_BUILD_ID if it could not be retrieved

رميات
DeviceNotAvailableException

getBuildSigningKeys

public String getBuildSigningKeys ()

Returns the key type used to sign the device image

Typically Android devices may be signed with test-keys (like in AOSP) or release-keys (controlled by individual device manufacturers)

عائدات
String The signing key if found, null otherwise.

رميات
DeviceNotAvailableException

getCachedDeviceDescriptor

public DeviceDescriptor getCachedDeviceDescriptor ()

Returns a cached DeviceDescriptor if the device is allocated, otherwise returns the current DeviceDescriptor .

عائدات
DeviceDescriptor

getCachedDeviceDescriptor

public DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)

Returns a cached DeviceDescriptor if the device is allocated, otherwise returns the current DeviceDescriptor .

حدود
shortDescriptor boolean : Whether or not to limit descriptor to bare minimum info

عائدات
DeviceDescriptor

getChildren

public String[] getChildren (String path)

Alternative to using IFileEntry that sometimes won't work because of permissions.

حدود
path String : is the path on the device where to do the search

عائدات
String[] Array of string containing all the file in a path on the device.

رميات
DeviceNotAvailableException

getConnection

public AbstractConnection getConnection ()

The current connection associated with the device.

عائدات
AbstractConnection

getCurrentFoldableState

public DeviceFoldableState getCurrentFoldableState ()

Returns the current foldable state of the device or null if some issues occurred.

عائدات
DeviceFoldableState

رميات
DeviceNotAvailableException

getCurrentUser

public int getCurrentUser ()

Return the id of the current running user. In case of error, return -10000.

عائدات
int

رميات
DeviceNotAvailableException

getDeviceClass

public String getDeviceClass ()

Get the device class.

عائدات
String the ERROR(/String) device class.

getDeviceDate

public long getDeviceDate ()

Return the date of the device in millisecond since epoch.

عائدات
long the date of the device in epoch format.

رميات
DeviceNotAvailableException

getDeviceDescriptor

public DeviceDescriptor getDeviceDescriptor ()

Return a DeviceDescriptor from the device information to get info on it without passing the actual device object.

عائدات
DeviceDescriptor

getDeviceDescriptor

public DeviceDescriptor getDeviceDescriptor (boolean shortDescriptor)

Return a DeviceDescriptor from the device information to get info on it without passing the actual device object.

حدود
shortDescriptor boolean : Whether or not to limit descriptor to bare minimum info

عائدات
DeviceDescriptor

getDeviceState

public TestDeviceState getDeviceState ()

Get the device's state.

عائدات
TestDeviceState

getDeviceTimeOffset

public long getDeviceTimeOffset (Date date)

Helper to get the time difference between the device and a given ERROR(/Date) . Use Epoch time internally.

حدود
date Date

عائدات
long the difference in milliseconds

رميات
DeviceNotAvailableException

getEmulatorOutput

public InputStreamSource getEmulatorOutput ()

Get the stream of emulator stdout and stderr

عائدات
InputStreamSource emulator output

getEmulatorProcess

public Process getEmulatorProcess ()

Return the ERROR(/Process) corresponding to this emulator.

عائدات
Process the ERROR(/Process) or null

getExecuteShellCommandLog

public final File getExecuteShellCommandLog ()

The log that contains all the executeShellCommand(String) logs.

عائدات
File

getExternalStoreFreeSpace

public long getExternalStoreFreeSpace ()

Helper method to determine amount of free space on device external storage.

عائدات
long the amount of free space in KB

رميات
DeviceNotAvailableException

getFastbootPath

public String getFastbootPath ()

Returns the path of the fastboot binary being used. Still requires isFastbootEnabled() to be true, to have fastboot functions enabled.

عائدات
String

getFastbootProductType

public String getFastbootProductType ()

Convenience method to get the product type of this device when its in fastboot mode.

This method should only be used if device should be in fastboot. Its a bit safer variant than the generic getProductType() method in this case, because ITestDevice will know to recover device into fastboot if device is in incorrect state or is unresponsive.

عائدات
String the ERROR(/String) product type name or null if it cannot be determined

رميات
DeviceNotAvailableException

getFastbootProductVariant

public String getFastbootProductVariant ()

Convenience method to get the product type of this device when its in fastboot mode.

This method should only be used if device should be in fastboot. Its a bit safer variant than the generic getProductType() method in this case, because ITestDevice will know to recover device into fastboot if device is in incorrect state or is unresponsive.

عائدات
String the ERROR(/String) product type name or null if it cannot be determined

رميات
DeviceNotAvailableException

getFastbootSerialNumber

public String getFastbootSerialNumber ()

Returns the fastboot mode serial number.

عائدات
String

getFastbootVariable

public String getFastbootVariable (String variableName)

Retrieve the given fastboot variable value from the device.

حدود
variableName String : the variable name

عائدات
String the property value or null if it does not exist

رميات
DeviceNotAvailableException

getFastbootVersion

public String getFastbootVersion ()

Returns the version string of the fastboot binary being used. Or null if something goes wrong.

عائدات
String

getFileEntry

public IFileEntry getFileEntry (String path)

Retrieve a reference to a remote file on device.

حدود
path String : the file path to retrieve. Can be an absolute path or path relative to '/'. (ie both "/system" and "system" syntax is supported)

عائدات
IFileEntry the IFileEntry or null if file at given path cannot be found

رميات
DeviceNotAvailableException

getFileEntry

public IFileEntry getFileEntry (FileListingService.FileEntry entry)

Unofficial helper to get a FileEntry from a non-root path. FIXME: Refactor the FileEntry system to have it available from any path. (even non root).

حدود
entry FileListingService.FileEntry : a FileEntry not necessarily root as Ddmlib requires.

عائدات
IFileEntry a FileEntryWrapper representing the FileEntry.

رميات
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

getFoldableStates

public  getFoldableStates ()

Returns the list of foldable states on the device. Can be obtained with "cmd device_state print-states".

عائدات

رميات
DeviceNotAvailableException

getIDevice

public IDevice getIDevice ()

Returns a reference to the associated ddmlib IDevice .

A new IDevice may be allocated by DDMS each time the device disconnects and reconnects from adb. Thus callers should not keep a reference to the IDevice , because that reference may become stale.

عائدات
IDevice the IDevice

getInstalledPackageNames

public  getInstalledPackageNames ()

Fetch the application package names present on the device.

عائدات
ERROR(/Set) of ERROR(/String) package names currently installed on the device.

رميات
DeviceNotAvailableException

getIntProperty

public long getIntProperty (String name, 
                long defaultValue)

Returns integer value of the given property from the device.

حدود
name String : the property name

defaultValue long : default value to return if property is empty or doesn't exist.

عائدات
long the property value or defaultValue if the property is empty, doesn't exist, or doesn't have an integer value.

رميات
DeviceNotAvailableException

getIpAddress

public String getIpAddress ()

Gets the device's IP address.

عائدات
String the device's IP address, or null if device has no IP address

رميات
DeviceNotAvailableException

getKeyguardState

public KeyguardControllerState getKeyguardState ()

Return an object to get the current state of the keyguard or null if not supported.

عائدات
KeyguardControllerState a KeyguardControllerState containing a snapshot of the state of the keyguard and returns Null if the Keyguard query is not supported.

رميات
DeviceNotAvailableException

getLastExpectedRebootTimeMillis

public long getLastExpectedRebootTimeMillis ()

Returns the last time Tradefed APIs triggered a reboot in milliseconds since EPOCH as returned by ERROR(/System#currentTimeMillis()) .

عائدات
long

getLaunchApiLevel

public int getLaunchApiLevel ()

Get the device's first launched API Level. Defaults to UNKNOWN_API_LEVEL .

عائدات
int an integer indicating the first launched API Level of device

رميات
DeviceNotAvailableException

getLogcat

public InputStreamSource getLogcat ()

Grabs a snapshot stream of the logcat data.

Works in two modes:

  • If the logcat is currently being captured in the background, will return up to TestDeviceOptions.getMaxLogcatDataSize() bytes of the current contents of the background logcat capture
  • Otherwise, will return a static dump of the logcat data if device is currently responding

    عائدات
    InputStreamSource

  • getLogcat

    public InputStreamSource getLogcat (int maxBytes)

    Grabs a snapshot stream of the last maxBytes of captured logcat data.

    Useful for cases when you want to capture frequent snapshots of the captured logcat data without incurring the potentially big disk space penalty of getting the entire getLogcat() snapshot.

    حدود
    maxBytes int : the maximum amount of data to return. Should be an amount that can comfortably fit in memory

    عائدات
    InputStreamSource

    getLogcatDump

    public InputStreamSource getLogcatDump ()

    Get a dump of the current logcat for device. Unlike getLogcat() , this method will always return a static dump of the logcat.

    Has the disadvantage that nothing will be returned if device is not reachable.

    عائدات
    InputStreamSource a InputStreamSource of the logcat data. An empty stream is returned if fail to capture logcat data.

    getLogcatSince

    public InputStreamSource getLogcatSince (long date)

    Grabs a snapshot stream of captured logcat data starting the date provided. The time on the device should be used getDeviceDate() .

    حدود
    date long : in millisecond since epoch format of when to start the snapshot until present. (can be be obtained using 'date +%s')

    عائدات
    InputStreamSource

    getMacAddress

    public String getMacAddress ()

    Returns the MAC address of the device, null if it fails to query from the device.

    عائدات
    String

    getMainUserId

    public Integer getMainUserId ()

    Returns the main user id.

    عائدات
    Integer the userId of the main user if there is one, and null if there is no main user.

    رميات
    DeviceNotAvailableException

    getMainlineModuleInfo

    public  getMainlineModuleInfo ()

    Get the information about the mainline modules installed on the device.

    عائدات
    ERROR(/Set) of ERROR(/String) mainline modules currently installed on the device.

    رميات
    DeviceNotAvailableException

    getMaxNumberOfRunningUsersSupported

    public int getMaxNumberOfRunningUsersSupported ()

    Get the maximum number of supported simultaneously running users. Defaults to 0.

    عائدات
    int an integer indicating the number of simultaneously running users

    رميات
    DeviceNotAvailableException

    getMaxNumberOfUsersSupported

    public int getMaxNumberOfUsersSupported ()

    Get the maximum number of supported users. Defaults to 0.

    عائدات
    int an integer indicating the number of supported users

    رميات
    DeviceNotAvailableException

    getMicrodroidProcess

    public Process getMicrodroidProcess ()

    عائدات
    Process Returns the Process of the Microdroid VM. If TestDevice is not a Microdroid, returns null.

    getMonitor

    public IDeviceStateMonitor getMonitor ()

    Return the IDeviceStateMonitor associated with device.

    عائدات
    IDeviceStateMonitor

    getMountPoint

    public String getMountPoint (String mountName)

    Returns a mount point.

    Queries the device directly if the cached info in IDevice is not available.

    TODO: move this behavior to IDevice#getMountPoint(String)

    حدود
    mountName String : the name of the mount point

    عائدات
    String the mount point or null

    getMountPointInfo

    public ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)

    Returns a MountPointInfo corresponding to the specified mountpoint path, or null if that path has nothing mounted or otherwise does not appear in /proc/mounts as a mountpoint.

    حدود
    mountpoint String

    عائدات
    ITestDevice.MountPointInfo A ERROR(/List) of MountPointInfo containing the information in "/proc/mounts"

    رميات
    DeviceNotAvailableException

    getMountPointInfo

    public  getMountPointInfo ()

    Returns a parsed version of the information in /proc/mounts on the device

    عائدات
    A ERROR(/List) of MountPointInfo containing the information in "/proc/mounts"

    رميات
    DeviceNotAvailableException

    getOptions

    public TestDeviceOptions getOptions ()

    Fetch the test options for the device.

    عائدات
    TestDeviceOptions TestDeviceOptions related to the device under test.

    getPartitionFreeSpace

    public long getPartitionFreeSpace (String partition)

    Helper method to determine amount of free space on device partition.

    حدود
    partition String

    عائدات
    long the amount of free space in KB

    رميات
    DeviceNotAvailableException

    getPrimaryUserId

    public Integer getPrimaryUserId ()

    Returns the primary user id.

    عائدات
    Integer the userId of the primary user if there is one, and null if there is no primary user.

    رميات
    DeviceNotAvailableException

    getProcessByName

    public ProcessInfo getProcessByName (String processName)

    Helper method runs the "pidof" and "stat" command and returns ProcessInfo object with PID and process start time of the given process.

    حدود
    processName String : the proces name String.

    عائدات
    ProcessInfo ProcessInfo of given processName

    رميات
    DeviceNotAvailableException

    getProcessPid

    public String getProcessPid (String process)

    Returns the pid of the service or null if something went wrong.

    حدود
    process String : The proces name String.

    عائدات
    String

    رميات
    DeviceNotAvailableException

    getProductType

    public String getProductType ()

    Convenience method to get the product type of this device.

    This method will work if device is in either adb or fastboot mode.

    عائدات
    String the ERROR(/String) product type name. Will not be null

    رميات
    DeviceNotAvailableException

    getProductVariant

    public String getProductVariant ()

    Convenience method to get the product variant of this device.

    This method will work if device is in either adb or fastboot mode.

    عائدات
    String the ERROR(/String) product variant name or null if it cannot be determined

    رميات
    DeviceNotAvailableException

    getProperty

    public String getProperty (String name)

    Retrieve the given property value from the device.

    حدود
    name String : the property name

    عائدات
    String the property value or null if it does not exist

    رميات
    DeviceNotAvailableException

    getRecoveryMode

    public ITestDevice.RecoveryMode getRecoveryMode ()

    Get the current recovery mode used for the device.

    عائدات
    ITestDevice.RecoveryMode the current recovery mode used for the device.

    getScreenshot

    public InputStreamSource getScreenshot (String format)

    Grabs a screenshot from the device. Recommended to use getScreenshot(format) instead with JPEG encoding for smaller size

    حدود
    format String : supported PNG, JPEG

    عائدات
    InputStreamSource a InputStreamSource of the screenshot in format, or null if the screenshot was not successful.

    رميات
    DeviceNotAvailableException

    getScreenshot

    public InputStreamSource getScreenshot (long displayId)

    Grabs a screenshot from the device given display id. Format is PNG.

    TODO: extend the implementations above to support 'format' and 'rescale'

    حدود
    displayId long : the display id of the screen to get screenshot from.

    عائدات
    InputStreamSource a InputStreamSource of the screenshot in format, or null if the screenshot was not successful.

    رميات
    DeviceNotAvailableException

    getScreenshot

    public InputStreamSource getScreenshot (String format, 
                    boolean rescale)

    Grabs a screenshot from the device. Recommended to use getScreenshot(String) instead with JPEG encoding for smaller size.

    حدود
    format String : supported PNG, JPEG

    rescale boolean : if screenshot should be rescaled to reduce the size of resulting image

    عائدات
    InputStreamSource a InputStreamSource of the screenshot in format, or null if the screenshot was not successful.

    رميات
    DeviceNotAvailableException

    getScreenshot

    public InputStreamSource getScreenshot ()

    Grabs a screenshot from the device.

    عائدات
    InputStreamSource a InputStreamSource of the screenshot in png format, or null if the screenshot was not successful.

    رميات
    DeviceNotAvailableException

    getSerialNumber

    public String getSerialNumber ()

    Convenience method to get serial number of this device.

    عائدات
    String the ERROR(/String) serial number

    getSetting

    public String getSetting (int userId, 
                    String namespace, 
                    String key)

    Return the value of the requested setting. namespace must be one of: {"system", "secure", "global"}

    حدود
    userId int

    namespace String

    key String

    عائدات
    String the value associated with the namespace:key of a user. Null if not found.

    رميات
    DeviceNotAvailableException

    getSetting

    public String getSetting (String namespace, 
                    String key)

    See getSetting(int, String, String) and performed on system user.

    حدود
    namespace String

    key String

    عائدات
    String

    رميات
    DeviceNotAvailableException

    getSimOperator

    public String getSimOperator ()

    Return the SIM card operator or null if not available or if device is not available.

    عائدات
    String

    getSimState

    public String getSimState ()

    Return the SIM card state or null if not available or device is not available.

    عائدات
    String

    getTombstones

    public  getTombstones ()

    Fetch and return the list of tombstones from the devices. Requires root.

    method is best-effort so if one tombstone fails to be pulled for any reason it will be missing from the list. Only a DeviceNotAvailableException will terminate the method early.

    عائدات
    A list of tombstone files, empty if no tombstone.

    رميات
    DeviceNotAvailableException

    getTotalMemory

    public long getTotalMemory ()

    Returns total physical memory size in bytes or -1 in case of internal error

    عائدات
    long

    getUninstallablePackageNames

    public  getUninstallablePackageNames ()

    Fetch the application package names that can be uninstalled. This is presently defined as non-system packages, and updated system packages.

    عائدات
    ERROR(/Set) of uninstallable ERROR(/String) package names currently installed on the device.

    رميات
    DeviceNotAvailableException

    getUseFastbootErase

    public boolean getUseFastbootErase ()

    Get whether to use fastboot erase or fastboot format to wipe a partition on the device.

    عائدات
    boolean true if fastboot erase will be used or false if fastboot format will be used.

    getUserFlags

    public int getUserFlags (int userId)

    Find and return the flags of a given user. Flags are defined in "android.content.pm.UserInfo" class in Android Open Source Project.

    حدود
    userId int

    عائدات
    int the flags associated with the userId provided if found, -10000 in any other cases.

    رميات
    DeviceNotAvailableException

    getUserInfos

    public  getUserInfos ()

    Gets the Map of useId to UserInfo on the device. Will throw DeviceRuntimeException if output from device is not as expected.

    عائدات
    the list of UserInfo objects.

    رميات
    DeviceNotAvailableException

    getUserSerialNumber

    public int getUserSerialNumber (int userId)

    Return the serial number associated to the userId if found, -10000 in any other cases.

    حدود
    userId int

    عائدات
    int

    رميات
    DeviceNotAvailableException

    handleAllocationEvent

    public IManagedTestDevice.DeviceEventResponse handleAllocationEvent (DeviceEvent event)

    Process the given DeviceEvent . May transition device to new state. Will inform the IDeviceMonitor of any state transitions.

    Process the DeviceEvent, which may or may not transition this device to a new allocation state.

    حدود
    event DeviceEvent

    عائدات
    IManagedTestDevice.DeviceEventResponse

    hasFeature

    public boolean hasFeature (String feature)

    Check if a feature is available on a device.

    حدود
    feature String : which format should be "feature: " or " " directly.

    عائدات
    boolean True if feature is found, false otherwise.

    رميات
    DeviceNotAvailableException

    installPackage

    public String installPackage (File packageFile, 
                    boolean reinstall, 
                    String... extraArgs)

    Install an Android package on device.

    حدود
    packageFile File : the apk file to install

    reinstall boolean : true if a reinstall should be performed

    extraArgs String : optional extra arguments to pass. See 'adb shell pm -h' for available options.

    عائدات
    String a ERROR(/String) with an error code, or null if success.

    رميات
    DeviceNotAvailableException

    installPackage

    public String installPackage (File packageFile, 
                    boolean reinstall, 
                    boolean grantPermissions, 
                    String... extraArgs)

    Install an Android package on device.

    Note: Only use cases that requires explicit control of granting runtime permission at install time should call this function.

    حدود
    packageFile File : the apk file to install

    reinstall boolean : true if a reinstall should be performed

    grantPermissions boolean : if all runtime permissions should be granted at install time

    extraArgs String : optional extra arguments to pass. See 'adb shell pm -h' for available options.

    عائدات
    String a ERROR(/String) with an error code, or null if success.

    رميات
    DeviceNotAvailableException

    installPackageForUser

    public String installPackageForUser (File packageFile, 
                    boolean reinstall, 
                    int userId, 
                    String... extraArgs)

    Install an Android package on device for a given user.

    حدود
    packageFile File : the apk file to install

    reinstall boolean : true if a reinstall should be performed

    userId int : the integer user id to install for.

    extraArgs String : optional extra arguments to pass. See 'adb shell pm -h' for available options.

    عائدات
    String a ERROR(/String) with an error code, or null if success.

    رميات
    DeviceNotAvailableException

    installPackageForUser

    public String installPackageForUser (File packageFile, 
                    boolean reinstall, 
                    boolean grantPermissions, 
                    int userId, 
                    String... extraArgs)

    Install an Android package on device for a given user.

    Note: Only use cases that requires explicit control of granting runtime permission at install time should call this function.

    حدود
    packageFile File : the apk file to install

    reinstall boolean : true if a reinstall should be performed

    grantPermissions boolean : if all runtime permissions should be granted at install time

    userId int : the integer user id to install for.

    extraArgs String : optional extra arguments to pass. See 'adb shell pm -h' for available options.

    عائدات
    String a ERROR(/String) with an error code, or null if success.

    رميات
    DeviceNotAvailableException

    isAdbRoot

    public boolean isAdbRoot ()

    عائدات
    boolean

    رميات
    DeviceNotAvailableException

    isAdbTcp

    public boolean isAdbTcp ()

    عائدات
    boolean

    isAppEnumerationSupported

    public boolean isAppEnumerationSupported ()

    Check whether platform on device supports app enumeration

    عائدات
    boolean True if app enumeration is supported, false otherwise

    رميات
    DeviceNotAvailableException

    isBypassLowTargetSdkBlockSupported

    public boolean isBypassLowTargetSdkBlockSupported ()

    Check whether platform on device supports bypassing low target sdk block on app installs

    عائدات
    boolean True if bypass low target sdk block is supported, false otherwise

    رميات
    DeviceNotAvailableException

    isDeviceEncrypted

    public boolean isDeviceEncrypted ()

    Returns if the device is encrypted.

    عائدات
    boolean true if the device is encrypted.

    رميات
    DeviceNotAvailableException

    isDirectory

    public boolean isDirectory (String path)

    Return True if the path on the device is a directory, false otherwise.

    حدود
    path String

    عائدات
    boolean

    رميات
    DeviceNotAvailableException

    isEnableAdbRoot

    public boolean isEnableAdbRoot ()

    عائدات
    boolean true if adb root should be enabled on device

    isEncryptionSupported

    public boolean isEncryptionSupported ()

    Returns if encryption is supported on the device.

    عائدات
    boolean true if the device supports encryption.

    رميات
    DeviceNotAvailableException

    isExecutable

    public boolean isExecutable (String fullPath)

    Returns True if the file path on the device is an executable file, false otherwise.

    حدود
    fullPath String

    عائدات
    boolean

    رميات
    DeviceNotAvailableException

    isFastbootEnabled

    public boolean isFastbootEnabled ()

    Return if fastboot is available for the device.

    عائدات
    boolean

    isHeadless

    public boolean isHeadless ()

    Return true if the device is headless (no screen), false otherwise.

    عائدات
    boolean

    رميات
    DeviceNotAvailableException

    isHeadlessSystemUserMode

    public boolean isHeadlessSystemUserMode ()

    Returns whether the device uses headless system user mode.

    عائدات
    boolean

    رميات
    DeviceNotAvailableException

    isMainUserPermanentAdmin

    public boolean isMainUserPermanentAdmin ()

    Returns whether the main user is a permanent admin and can't be deleted or downgraded to non-admin status.

    عائدات
    boolean

    رميات
    DeviceNotAvailableException

    isMultiUserSupported

    public boolean isMultiUserSupported ()

    Determines if multi user is supported.

    عائدات
    boolean true if multi user is supported, false otherwise

    رميات
    DeviceNotAvailableException

    isPackageInstalled

    public boolean isPackageInstalled (String packageName, 
                    String userId)

    Query the device for a given package name and given user id to check if it's currently installed or not for that user.

    حدود
    packageName String : the package we are checking if it's installed.

    userId String : The user id we are checking the package is installed for. If null, primary user zero will be used.

    عائدات
    boolean True if the package is reported as installed. False otherwise.

    رميات
    DeviceNotAvailableException

    isPackageInstalled

    public boolean isPackageInstalled (String packageName)

    Query the device for a given package name to check if it's currently installed or not.

    حدود
    packageName String

    عائدات
    boolean True if the package is reported as installed. False otherwise.

    رميات
    DeviceNotAvailableException

    isRuntimePermissionSupported

    public boolean isRuntimePermissionSupported ()

    Check whether platform on device supports runtime permission granting

    عائدات
    boolean True if runtime permission are supported, false otherwise.

    رميات
    DeviceNotAvailableException

    isStateBootloaderOrFastbootd

    public boolean isStateBootloaderOrFastbootd ()

    Returns true if device is in TestDeviceState#FASTBOOT or TestDeviceState.FASTBOOTD .

    عائدات
    boolean

    isUserRunning

    public boolean isUserRunning (int userId)

    Check if a given user is running.

    حدود
    userId int

    عائدات
    boolean True if the user is running, false in every other cases.

    رميات
    DeviceNotAvailableException

    isUserSecondary

    public boolean isUserSecondary (int userId)

    Return whether the specified user is a secondary user according to it's flags.

    حدود
    userId int

    عائدات
    boolean true if the user is secondary, false otherwise.

    رميات
    DeviceNotAvailableException

    isUserVisible

    public boolean isUserVisible (int userId)

    Checks if the given user is visible.

    A "visible" user is a user that is interacting with the "human" user and hence is able to launch launch activities (typically in the default display).

    حدود
    userId int

    عائدات
    boolean

    رميات
    DeviceNotAvailableException

    isUserVisibleOnDisplay

    public boolean isUserVisibleOnDisplay (int userId, 
                    int displayId)

    Checks if the given user is visible in the given display.

    A "visible" user is a user that is interacting with the "human" user and hence is able to launch launch activities in that display.

    حدود
    userId int

    displayId int

    عائدات
    boolean

    رميات
    DeviceNotAvailableException

    isVisibleBackgroundUsersOnDefaultDisplaySupported

    public boolean isVisibleBackgroundUsersOnDefaultDisplaySupported ()

    Returns whether the device allow users to be started visible in the background in the ERROR(/java.android.view.Display#DEFAULT_DISPLAY) .

    If it does, you could call startVisibleBackgroundUser(int, int, boolean) , passing a display returned by listDisplayIdsForStartingVisibleBackgroundUsers() (which should include ERROR(/java.android.view.Display#DEFAULT_DISPLAY) ).

    عائدات
    boolean

    رميات
    DeviceNotAvailableException

    isVisibleBackgroundUsersSupported

    public boolean isVisibleBackgroundUsersSupported ()

    Returns whether the device allow users to be started visible in the background.

    If it does, you could call startVisibleBackgroundUser(int, int, boolean) , passing a display returned by listDisplayIdsForStartingVisibleBackgroundUsers() .

    عائدات
    boolean

    رميات
    DeviceNotAvailableException

    isWifiEnabled

    public boolean isWifiEnabled ()

    Test if wifi is enabled.

    Checks if wifi is enabled on device. Useful for asserting wifi status before tests that shouldn't run with wifi, eg mobile data tests.

    عائدات
    boolean true if wifi is enabled. false if disabled

    رميات
    DeviceNotAvailableException

    listDisplayIds

    public  listDisplayIds ()

    Collect the list of available displays id on the device as reported by "dumpsys SurfaceFlinger".

    عائدات
    The list of displays. Default always returns the default display 0.

    رميات
    DeviceNotAvailableException

    listDisplayIdsForStartingVisibleBackgroundUsers

    public  listDisplayIdsForStartingVisibleBackgroundUsers ()

    Gets the list of displays that can be used to start a user visible in the background .

    عائدات

    رميات
    DeviceNotAvailableException

    listUsers

    public  listUsers ()

    Gets the list of users on the device. Will throw DeviceRuntimeException if output from device is not as expected.

    عائدات
    the list of user ids.

    رميات
    DeviceNotAvailableException

    logAnrs

    public boolean logAnrs (ITestLogger logger)

    Collects and log ANRs from the device.

    حدود
    logger ITestLogger : an ITestLogger to log the ANRs.

    عائدات
    boolean True if the logging was successful, false otherwise.

    رميات
    DeviceNotAvailableException

    logBugreport

    public boolean logBugreport (String dataName, 
                    ITestLogger listener)

    Helper method to take a bugreport and log it to the reporters.

    حدود
    dataName String : name under which the bugreport will be reported.

    listener ITestLogger : an ITestLogger to log the bugreport.

    عائدات
    boolean True if the logging was successful, false otherwise.

    logOnDevice

    public void logOnDevice (String tag, 
                    Log.LogLevel level, 
                    String format, 
                    Object... args)

    Log a message in the logcat of the device. This is a safe call that will not throw even if the logging fails.

    حدود
    tag String : The tag under which we log our message in the logcat.

    level Log.LogLevel : The debug level of the message in the logcat.

    format String : The message format.

    args Object : the args to be replaced via String.format().

    nonBlockingReboot

    public void nonBlockingReboot ()

    Issues a command to reboot device and returns on command complete and when device is no longer visible to adb.

    رميات
    DeviceNotAvailableException

    postAdbRootAction

    public void postAdbRootAction ()

    Override if the device needs some specific actions to be taken after adb root and before the device is back online. Default implementation doesn't include any addition actions. adb root is not guaranteed to be enabled at this stage.

    رميات
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    postAdbUnrootAction

    public void postAdbUnrootAction ()

    Override if the device needs some specific actions to be taken after adb unroot and before the device is back online. Default implementation doesn't include any additional actions. adb root is not guaranteed to be disabled at this stage.

    رميات
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    postBootSetup

    public void postBootSetup ()

    Perform instructions to configure device for testing that after every boot.

    Should be called after device is fully booted/available

    In normal circumstances this method doesn't need to be called explicitly, as implementations should perform these steps automatically when performing a reboot.

    Where it may need to be called is when device reboots due to other events (eg when a fastboot update command has completed)

    رميات
    DeviceNotAvailableException

    postInvocationTearDown

    public void postInvocationTearDown (Throwable exception)

    Extra steps for device specific required clean up that will be executed after the invocation is done.

    حدود
    exception Throwable : if any, the final exception raised by the invocation failure.

    preInvocationSetup

    public void preInvocationSetup (IBuildInfo info, 
                    MultiMap<String, String> attributes)

    Extra steps for device specific required setup that will be executed on the device prior to the invocation flow.

    حدود
    info IBuildInfo : The IBuildInfo of the device.

    attributes MultiMap : The attributes stored in the invocation context

    رميات
    DeviceNotAvailableException
    TargetSetupError

    pullDir

    public boolean pullDir (String deviceFilePath, 
                    File localDir)

    Recursively pull directory contents from device.

    حدود
    deviceFilePath String : the absolute file path of the remote source

    localDir File : the local directory to pull files into

    عائدات
    boolean true if file was pulled successfully. false otherwise.

    رميات
    DeviceNotAvailableException

    pullFile

    public boolean pullFile (String remoteFilePath, 
                    File localFile)

    Retrieves a file off device.

    حدود
    remoteFilePath String : the absolute path to file on device.

    localFile File : the local file to store contents in. If non-empty, contents will be replaced.

    عائدات
    boolean true if file was retrieved successfully. false otherwise.

    رميات
    DeviceNotAvailableException

    pullFile

    public File pullFile (String remoteFilePath, 
                    int userId)

    Retrieves a file off device, stores it in a local temporary ERROR(/File) , and returns that File .

    حدود
    remoteFilePath String : the absolute path to file on device.

    userId int : The user id to pull from

    عائدات
    File A ERROR(/File) containing the contents of the device file, or null if the copy failed for any reason (including problems with the host filesystem)

    رميات
    DeviceNotAvailableException

    pullFile

    public File pullFile (String remoteFilePath)

    Retrieves a file off device, stores it in a local temporary ERROR(/File) , and returns that File .

    حدود
    remoteFilePath String : the absolute path to file on device.

    عائدات
    File A ERROR(/File) containing the contents of the device file, or null if the copy failed for any reason (including problems with the host filesystem)

    رميات
    DeviceNotAvailableException

    pullFile

    public boolean pullFile (String remoteFilePath, 
                    File localFile, 
                    int userId)

    Retrieves a file off device.

    حدود
    remoteFilePath String : the absolute path to file on device.

    localFile File : the local file to store contents in. If non-empty, contents will be replaced.

    userId int : The user id to pull from

    عائدات
    boolean true if file was retrieved successfully. false otherwise.

    رميات
    DeviceNotAvailableException

    pullFileContents

    public String pullFileContents (String remoteFilePath)

    Retrieves a file off device, and returns the contents.

    حدود
    remoteFilePath String : the absolute path to file on device.

    عائدات
    String A ERROR(/String) containing the contents of the device file, or null if the copy failed for any reason (including problems with the host filesystem)

    رميات
    DeviceNotAvailableException

    pullFileFromExternal

    public File pullFileFromExternal (String remoteFilePath)

    A convenience method to retrieve a file from the device's external storage, stores it in a local temporary ERROR(/File) , and return a reference to that File .

    حدود
    remoteFilePath String : the path to file on device, relative to the device's external storage mountpoint

    عائدات
    File A ERROR(/File) containing the contents of the device file, or null if the copy failed for any reason (including problems with the host filesystem)

    رميات
    DeviceNotAvailableException

    pushDir

    public boolean pushDir (File localFileDir, 
                    String deviceFilePath, 
                     excludedDirectories)

    Recursively push directory contents to device while excluding some directories that are filtered.

    حدود
    localFileDir File : the local directory to push

    deviceFilePath String : the absolute file path of the remote destination

    excludedDirectories : Set of excluded directories names that shouldn't be pushed.

    عائدات
    boolean true if file was pushed successfully. false otherwise.

    رميات
    DeviceNotAvailableException

    pushDir

    public boolean pushDir (File localFileDir, 
                    String deviceFilePath)

    Recursively push directory contents to device.

    حدود
    localFileDir File : the local directory to push

    deviceFilePath String : the absolute file path of the remote destination

    عائدات
    boolean true if file was pushed successfully. false otherwise.

    رميات
    DeviceNotAvailableException

    pushFile

    public boolean pushFile (File localFile, 
                    String remoteFilePath, 
                    boolean evaluateContentProviderNeeded)

    Variant of pushFile(File, String) which can optionally consider evaluating the need for the content provider.

    حدود
    localFile File : the local file to push

    remoteFilePath String : the remote destination absolute file path

    evaluateContentProviderNeeded boolean : whether to check if we need the content provider

    عائدات
    boolean true if file was pushed successfully. false otherwise.

    رميات
    DeviceNotAvailableException

    pushFile

    public boolean pushFile (File localFile, 
                    String remoteFilePath)

    Push a file to device. By default using a content provider.

    حدود
    localFile File : the local file to push

    remoteFilePath String : the remote destination absolute file path

    عائدات
    boolean true if file was pushed successfully. false otherwise.

    رميات
    DeviceNotAvailableException

    pushString

    public boolean pushString (String contents, 
                    String remoteFilePath)

    Push file created from a string to device

    حدود
    contents String : the contents of the file to push

    remoteFilePath String : the remote destination absolute file path

    عائدات
    boolean true if string was pushed successfully. false otherwise.

    رميات
    DeviceNotAvailableException

    reboot

    public void reboot (String reason)

    Reboots the device into adb mode with given reason to be persisted across reboot.

    Blocks until device becomes available.

    Last reboot reason can be obtained by querying sys.boot.reason propety.

    حدود
    reason String : a reason for this reboot, or null if no reason is specified.

    رميات
    DeviceNotAvailableException

    reboot

    public void reboot ()

    Reboots the device into adb mode.

    Blocks until device becomes available.

    رميات
    DeviceNotAvailableException

    rebootIntoBootloader

    public void rebootIntoBootloader ()

    Reboots the device into bootloader mode.

    Blocks until device is in bootloader mode.

    رميات
    DeviceNotAvailableException

    rebootIntoFastbootd

    public void rebootIntoFastbootd ()

    Reboots the device into fastbootd mode.

    Blocks until device is in fastbootd mode.

    رميات
    DeviceNotAvailableException

    rebootIntoRecovery

    public void rebootIntoRecovery ()

    Reboots the device into adb recovery mode.

    Blocks until device enters recovery

    رميات
    DeviceNotAvailableException

    rebootIntoSideload

    public void rebootIntoSideload ()

    Reboots the device into adb sideload mode (note that this is a special mode under recovery)

    Blocks until device enters sideload mode

    رميات
    DeviceNotAvailableException

    rebootIntoSideload

    public void rebootIntoSideload (boolean autoReboot)

    Reboots the device into adb sideload mode (note that this is a special mode under recovery)

    Blocks until device enters sideload mode

    حدود
    autoReboot boolean : whether to automatically reboot the device after sideload

    رميات
    DeviceNotAvailableException

    rebootUntilOnline

    public void rebootUntilOnline ()

    An alternate to reboot() that only blocks until device is online ie visible to adb.

    رميات
    DeviceNotAvailableException

    rebootUntilOnline

    public void rebootUntilOnline (String reason)

    An alternate to reboot() that only blocks until device is online ie visible to adb.

    حدود
    reason String : a reason for this reboot, or null if no reason is specified.

    رميات
    DeviceNotAvailableException

    rebootUserspace

    public void rebootUserspace ()

    Reboots only userspace part of device.

    Blocks until device becomes available.

    WARNING. Userspace reboot is currently under active development, use it on your own risk.

    رميات
    DeviceNotAvailableException

    rebootUserspaceUntilOnline

    public void rebootUserspaceUntilOnline ()

    An alternate to rebootUserspace() ()} that only blocks until device is online ie visible to adb.

    رميات
    DeviceNotAvailableException

    recoverDevice

    public boolean recoverDevice ()

    Attempts to recover device communication.

    عائدات
    boolean True if recovery attempted and successful, returns False if recovery was skipped

    رميات
    DeviceNotAvailableException if device is no longer available

    registerDeviceActionReceiver

    public void registerDeviceActionReceiver (IDeviceActionReceiver deviceActionReceiver)

    Registers a IDeviceActionReceiver for this device.

    All registered IDeviceActionReceiver s will be notified before a device action starts and after the device action ends.

    حدود
    deviceActionReceiver IDeviceActionReceiver : A IDeviceActionReceiver which will be registered.

    remountSystemWritable

    public void remountSystemWritable ()

    Make the system partition on the device writable. May reboot the device.

    رميات
    DeviceNotAvailableException

    remountVendorWritable

    public void remountVendorWritable ()

    Make the vendor partition on the device writable. May reboot the device.

    رميات
    DeviceNotAvailableException

    removeAdmin

    public boolean removeAdmin (String componentName, 
                    int userId)

    Remove given device admin in given user and return true if it is successful, false otherwise.

    حدود
    componentName String : of device admin to be removed.

    userId int : of user that the device admin lives in.

    عائدات
    boolean True if it is successful, false otherwise.

    رميات
    DeviceNotAvailableException

    removeOwners

    public void removeOwners ()

    Remove all existing device profile owners with the best effort.

    رميات
    DeviceNotAvailableException

    removeUser

    public boolean removeUser (int userId)

    Remove a given user from the device.

    حدود
    userId int : of the user to remove

    عائدات
    boolean true if we were successful in removing the user, false otherwise.

    رميات
    DeviceNotAvailableException

    resetContentProviderSetup

    public void resetContentProviderSetup ()

    Reset the flag for content provider setup in order to trigger it again.

    runInstrumentationTests

    public boolean runInstrumentationTests (IRemoteAndroidTestRunner runner, 
                    ITestLifeCycleReceiver... listeners)

    Convenience method for performing ERROR(/#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection)) with one or more listeners passed as parameters.

    حدود
    runner IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests

    listeners ITestLifeCycleReceiver : the test result listener(s)

    عائدات
    boolean true if test command completed. false if it failed to complete, but recovery succeeded

    رميات
    DeviceNotAvailableException

    runInstrumentationTests

    public boolean runInstrumentationTests (IRemoteAndroidTestRunner runner, 
                     listeners)

    Runs instrumentation tests, and provides device recovery.

    If connection with device is lost before test run completes, and recovery succeeds, all listeners will be informed of testRunFailed and "false" will be returned. The test command will not be rerun. It is left to callers to retry if necessary.

    If connection with device is lost before test run completes, and recovery fails, all listeners will be informed of testRunFailed and DeviceNotAvailableException will be thrown.

    حدود
    runner IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests

    listeners : the test result listeners

    عائدات
    boolean true if test command completed. false if it failed to complete due to device communication exception, but recovery succeeded

    رميات
    DeviceNotAvailableException

    runInstrumentationTestsAsUser

    public boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, 
                    int userId, 
                     listeners)

    Same as ERROR(ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection)/com.android.tradefed.device.ITestDevice#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection) ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection)) but runs the test for the given user.

    حدود
    runner IRemoteAndroidTestRunner

    userId int

    listeners

    عائدات
    boolean

    رميات
    DeviceNotAvailableException

    runInstrumentationTestsAsUser

    public boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, 
                    int userId, 
                    ITestLifeCycleReceiver... listeners)

    Same as ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, ITestLifeCycleReceiver...) but runs the test for a given user.

    حدود
    runner IRemoteAndroidTestRunner

    userId int

    listeners ITestLifeCycleReceiver

    عائدات
    boolean

    رميات
    DeviceNotAvailableException

    setConfiguration

    public void setConfiguration (IConfiguration configuration)

    Injects the IConfiguration in use.

    حدود
    configuration IConfiguration

    setDate

    public void setDate (Date date)

    Sets the date on device

    Note: setting date on device requires root

    حدود
    date Date : specify a particular date; will use host date if null

    رميات
    DeviceNotAvailableException

    setDeviceOwner

    public boolean setDeviceOwner (String componentName, 
                    int userId)

    Set a device admin component as device owner in given user.

    حدود
    componentName String : of device admin to be device owner.

    userId int : of the user that the device owner lives in.

    عائدات
    boolean True if it is successful, false otherwise.

    رميات
    DeviceNotAvailableException

    setDeviceState

    public void setDeviceState (TestDeviceState deviceState)

    Update the device's state.

    حدود
    deviceState TestDeviceState : the TestDeviceState

    setEmulatorOutputStream

    public void setEmulatorOutputStream (SizeLimitedOutputStream output)

    For emulator set SizeLimitedOutputStream to log output

    حدود
    output SizeLimitedOutputStream : to log the output

    setEmulatorProcess

    public void setEmulatorProcess (Process p)

    Sets the ERROR(/Process) , when this device is an emulator.

    حدود
    p Process

    setFastbootEnabled

    public void setFastbootEnabled (boolean fastbootEnabled)

    Set the fastboot option for the device. Should be set when device is first allocated.

    حدود
    fastbootEnabled boolean : whether fastboot is available for the device or not

    setFastbootPath

    public void setFastbootPath (String fastbootPath)

    Sets the path to the fastboot binary that should be used. Still requires isFastbootEnabled() to be true, to have fastboot functions enabled.

    حدود
    fastbootPath String

    setIDevice

    public void setIDevice (IDevice newDevice)

    Update the IDevice associated with this ITestDevice.

    The new IDevice must refer the same physical device as the current reference. This method will be called if DDMS has allocated a new IDevice

    حدود
    newDevice IDevice : the IDevice

    setLogStartDelay

    public void setLogStartDelay (int delay)

    Sets the time in ms to wait before starting logcat capture for a online device.

    حدود
    delay int : the delay in ms

    setOptions

    public void setOptions (TestDeviceOptions options)

    Set the TestDeviceOptions for the device

    حدود
    options TestDeviceOptions

    setProperty

    public boolean setProperty (String propKey, 
                    String propValue)

    Sets the given property value on the device. Requires adb root is true.

    حدود
    propKey String : The key targeted to be set.

    propValue String : The property value to be set.

    عائدات
    boolean returns True if the setprop command was successful, False otherwise.

    رميات
    DeviceNotAvailableException

    setRecovery

    public void setRecovery (IDeviceRecovery recovery)

    Set the IDeviceRecovery to use for this device. Should be set when device is first allocated.

    حدود
    recovery IDeviceRecovery : the IDeviceRecovery

    setRecoveryMode

    public void setRecoveryMode (ITestDevice.RecoveryMode mode)

    Set the current recovery mode to use for the device.

    Used to control what recovery method to use when a device communication problem is encountered. Its recommended to only use this method sparingly when needed (for example, when framework is down, etc

    حدود
    mode ITestDevice.RecoveryMode : whether 'recover till online only' mode should be on or not.

    setSetting

    public void setSetting (String namespace, 
                    String key, 
                    String value)

    See setSetting(int, String, String, String) and performed on system user.

    حدود
    namespace String

    key String

    value String

    رميات
    DeviceNotAvailableException

    setSetting

    public void setSetting (int userId, 
                    String namespace, 
                    String key, 
                    String value)

    Add a setting value to the namespace of a given user. Some settings will only be available after a reboot. namespace must be one of: {"system", "secure", "global"}

    حدود
    userId int

    namespace String

    key String

    value String

    رميات
    DeviceNotAvailableException

    setTestLogger

    public void setTestLogger (ITestLogger testLogger)

    Injects the ITestLogger instance

    حدود
    testLogger ITestLogger

    setUseFastbootErase

    public void setUseFastbootErase (boolean useFastbootErase)

    Set whether to use fastboot erase or fastboot format to wipe a partition on the device.

    حدود
    useFastbootErase boolean : true if fastboot erase should be used or false if fastboot format should be used.

    startLogcat

    public void startLogcat ()

    Start capturing logcat output from device in the background.

    Will have no effect if logcat output is already being captured. Data can be later retrieved via getLogcat.

    When the device is no longer in use, stopLogcat() must be called.

    startLogcat() and stopLogcat() do not normally need to be called when within a TF invocation context, as the TF framework will start and stop logcat.

    startUser

    public boolean startUser (int userId)

    Starts a given user in the background if it is currently stopped. If the user is already running in the background, this method is a NOOP.

    حدود
    userId int : of the user to start in the background

    عائدات
    boolean true if the user was successfully started in the background.

    رميات
    DeviceNotAvailableException

    startUser

    public boolean startUser (int userId, 
                    boolean waitFlag)

    Starts a given user in the background if it is currently stopped. If the user is already running in the background, this method is a NOOP. Possible to provide extra flag to wait for the operation to have effect.

    حدود
    userId int : of the user to start in the background

    waitFlag boolean : will make the command wait until user is started and unlocked.

    عائدات
    boolean true if the user was successfully started in the background.

    رميات
    DeviceNotAvailableException

    startVisibleBackgroundUser

    public boolean startVisibleBackgroundUser (int userId, 
                    int displayId, 
                    boolean waitFlag)

    Starts a given user in the background, visible in the given display (ie, allowing the user to launch activities in that display).

    NOTE: this command doesn't check if the user exists, display is available, device supports such feature , etc.

    حدود
    userId int : of the user to start in the background

    displayId int : display to start user visible on

    waitFlag boolean : will make the command wait until user is started and unlocked.

    عائدات
    boolean true if the user was successfully started visible in the background.

    رميات
    DeviceNotAvailableException

    stopEmulatorOutput

    public void stopEmulatorOutput ()

    Close and delete the emulator output.

    stopLogcat

    public void stopLogcat ()

    Stop capturing logcat output from device, and discard currently saved logcat data.

    Will have no effect if logcat output is not being captured.

    stopUser

    public boolean stopUser (int userId)

    Stops a given user. If the user is already stopped, this method is a NOOP. Cannot stop current and system user.

    حدود
    userId int : of the user to stop.

    عائدات
    boolean true if the user was successfully stopped.

    رميات
    DeviceNotAvailableException

    stopUser

    public boolean stopUser (int userId, 
                    boolean waitFlag, 
                    boolean forceFlag)

    Stop a given user. Possible to provide extra flags to wait for the operation to have effect, and force terminate the user. Cannot stop current and system user.

    حدود
    userId int : of the user to stop.

    waitFlag boolean : will make the command wait until user is stopped.

    forceFlag boolean : will force stop the user.

    عائدات
    boolean true if the user was successfully stopped.

    رميات
    DeviceNotAvailableException

    switchToAdbTcp

    public String switchToAdbTcp ()

    Switch device to adb-over-tcp mode.

    عائدات
    String the tcp serial number or null if device could not be switched

    رميات
    DeviceNotAvailableException

    switchToAdbUsb

    public boolean switchToAdbUsb ()

    Switch device to adb over usb mode.

    عائدات
    boolean true if switch was successful, false otherwise.

    رميات
    DeviceNotAvailableException

    switchUser

    public boolean switchUser (int userId)

    Switch to another userId with a default timeout. switchUser(int, long) .

    حدود
    userId int

    عائدات
    boolean True if the new userId matches the userId provider. False otherwise.

    رميات
    DeviceNotAvailableException

    switchUser

    public boolean switchUser (int userId, 
                    long timeout)

    Switch to another userId with the provided timeout as deadline. Attempt to disable keyguard after user change is successful.

    حدود
    userId int

    timeout long : to wait before returning false for switch-user failed.

    عائدات
    boolean True if the new userId matches the userId provider. False otherwise.

    رميات
    DeviceNotAvailableException

    syncFiles

    public boolean syncFiles (File localFileDir, 
                    String deviceFilePath)

    Incrementally syncs the contents of a local file directory to device.

    Decides which files to push by comparing timestamps of local files with their remote equivalents. Only 'newer' or non-existent files will be pushed to device. Thus overhead should be relatively small if file set on device is already up to date.

    Hidden files (with names starting with ".") will be ignored.

    Example usage: syncFiles("/tmp/files", "/sdcard") will created a /sdcard/files directory if it doesn't already exist, and recursively push the /tmp/files contents to /sdcard/files.

    حدود
    localFileDir File : the local file directory containing files to recursively push.

    deviceFilePath String : the remote destination absolute file path root. All directories in thos file path must be readable. ie pushing to /data/local/tmp when adb is not root will fail

    عائدات
    boolean true if files were synced successfully. false otherwise.

    رميات
    DeviceNotAvailableException

    takeBugreport

    public Bugreport takeBugreport ()

    Take a bugreport and returns it inside a Bugreport object to handle it. Return null in case of issue. File referenced in the Bugreport object need to be cleaned via Bugreport.close() .

    عائدات
    Bugreport

    uninstallPackage

    public String uninstallPackage (String packageName)

    Uninstall an Android package from device.

    حدود
    packageName String : the Android package to uninstall

    عائدات
    String a ERROR(/String) with an error code, or null if success.

    رميات
    DeviceNotAvailableException

    uninstallPackageForUser

    public String uninstallPackageForUser (String packageName, 
                    int userId)

    Uninstall an Android package from device for a given user.

    حدود
    packageName String : the Android package to uninstall

    userId int : the integer user id to uninstall for.

    عائدات
    String a ERROR(/String) with an error code, or null if success.

    رميات
    DeviceNotAvailableException

    unlockDevice

    public boolean unlockDevice ()

    Unlocks the device if the device is in an encrypted state.

    This method may restart the framework but will not call postBootSetup() . Therefore, the device might not be fully ready to be tested when this method returns.

    عائدات
    boolean true if successful or if the device is unencrypted.

    رميات
    DeviceNotAvailableException

    waitForBootComplete

    public boolean waitForBootComplete (long timeOut)

    Blocks until the device's boot complete flag is set.

    حدود
    timeOut long : time in msecs to wait for the flag to be set

    عائدات
    boolean true if device's boot complete flag is set within the timeout

    رميات
    DeviceNotAvailableException

    waitForDeviceAvailable

    public boolean waitForDeviceAvailable ()

    Waits for the device to be responsive and available for testing. Uses default timeout.

    عائدات
    boolean True if device is available, False if recovery is disabled and unavailable.

    رميات
    DeviceNotAvailableException

    waitForDeviceAvailable

    public boolean waitForDeviceAvailable (long waitTime)

    Waits for the device to be responsive and available for testing.

    حدود
    waitTime long : the time in ms to wait

    عائدات
    boolean True if device is available, False if recovery is disabled and unavailable.

    رميات
    DeviceNotAvailableException

    waitForDeviceAvailableInRecoverPath

    public boolean waitForDeviceAvailableInRecoverPath (long waitTime)

    Waits for the device to be responsive and available without considering recovery path.

    حدود
    waitTime long

    عائدات
    boolean True if device is available, False if unavailable.

    رميات
    DeviceNotAvailableException

    waitForDeviceBootloader

    public void waitForDeviceBootloader ()

    Blocks until device is visible via fastboot. Use default timeout.

    رميات
    DeviceNotAvailableException

    waitForDeviceInRecovery

    public boolean waitForDeviceInRecovery (long waitTime)

    Blocks for the device to be in the 'adb recovery' state (note this is distinct from IDeviceRecovery ).

    حدود
    waitTime long : the time in ms to wait

    عائدات
    boolean true if device boots into recovery before time expires. false otherwise

    waitForDeviceInSideload

    public boolean waitForDeviceInSideload (long waitTime)

    Blocks for the device to be in the 'adb sideload' state

    حدود
    waitTime long : the time in ms to wait

    عائدات
    boolean true if device boots into sideload before time expires. false otherwise

    waitForDeviceNotAvailable

    public boolean waitForDeviceNotAvailable (long waitTime)

    Blocks for the device to be not available ie missing from adb

    حدود
    waitTime long : the time in ms to wait

    عائدات
    boolean true if device becomes not available before time expires. false otherwise

    waitForDeviceOnline

    public void waitForDeviceOnline ()

    Blocks until device is visible via adb. Uses default timeout

    Note the device may not necessarily be responsive to commands on completion. Use waitForDeviceAvailable() instead.

    رميات
    DeviceNotAvailableException

    waitForDeviceOnline

    public void waitForDeviceOnline (long waitTime)

    Blocks until device is visible via adb.

    Note the device may not necessarily be responsive to commands on completion. Use waitForDeviceAvailable() instead.

    حدود
    waitTime long : the time in ms to wait

    رميات
    DeviceNotAvailableException

    waitForDeviceShell

    public boolean waitForDeviceShell (long waitTime)

    Waits for device to be responsive to a basic adb shell command.

    حدود
    waitTime long : the time in ms to wait

    عائدات
    boolean true if device becomes responsive before waitTime elapses.

    الطرق المحمية

    buildAdbShellCommand

    protected String[] buildAdbShellCommand (String command, 
                    boolean forceExitStatusDetection)

    Builds the OS command for the given adb shell command session and args

    حدود
    command String

    forceExitStatusDetection boolean

    عائدات
    String[]

    checkApiLevelAgainst

    protected void checkApiLevelAgainst (String feature, 
                    int strictMinLevel)

    حدود
    feature String

    strictMinLevel int

    createRebootDeviceAction

    protected NativeDevice.RebootDeviceAction createRebootDeviceAction (NativeDevice.RebootMode rebootMode, 
                    String reason)

    Create a RebootDeviceAction to be used when performing a reboot action.

    حدود
    rebootMode NativeDevice.RebootMode : a mode of this reboot.

    reason String : for this reboot.

    عائدات
    NativeDevice.RebootDeviceAction the created RebootDeviceAction .

    createRunUtil

    protected IRunUtil createRunUtil ()

    عائدات
    IRunUtil

    doAdbReboot

    protected void doAdbReboot (NativeDevice.RebootMode rebootMode, 
                    String reason)

    Perform a adb reboot.

    حدود
    rebootMode NativeDevice.RebootMode : a mode of this reboot.

    reason String : for this reboot.

    رميات
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    ensureRuntimePermissionSupported

    protected void ensureRuntimePermissionSupported ()

    helper method to throw exception if runtime permission isn't supported

    رميات
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    getApiLevelSafe

    protected int getApiLevelSafe ()

    عائدات
    int

    getLogger

    protected ITestLogger getLogger ()

    عائدات
    ITestLogger

    getRunUtil

    protected IRunUtil getRunUtil ()

    Get the RunUtil instance to use.

    عائدات
    IRunUtil

    initializeConnection

    protected void initializeConnection (IBuildInfo info, 
                    MultiMap<String, String> attributes)

    حدود
    info IBuildInfo

    attributes MultiMap

    رميات
    DeviceNotAvailableException
    TargetSetupError

    internalGetProperty

    protected String internalGetProperty (String propName, 
                    String fastbootVar, 
                    String description)

    Fetch a device property, from the ddmlib cache by default, and falling back to either `adb shell getprop` or `fastboot getvar` depending on whether the device is in Fastboot or not.

    حدود
    propName String : The name of the device property as returned by `adb shell getprop`

    fastbootVar String : The name of the equivalent fastboot variable to query. if null , fastboot query will not be attempted

    description String : A simple description of the variable. First letter should be capitalized.

    عائدات
    String A string, possibly null or empty, containing the value of the given property

    رميات
    DeviceNotAvailableException

    isInRebootCallback

    protected boolean isInRebootCallback ()

    Returns whether reboot callbacks is currently being executed or not. All public api's for reboot should be disabled if true.

    عائدات
    boolean

    isNewer

    protected boolean isNewer (File localFile, 
                    IFileEntry entry)

    Return true if local file is newer than remote file. IFileEntry being accurate to the minute, in case of equal times, the file will be considered newer.

    حدود
    localFile File

    entry IFileEntry

    عائدات
    boolean

    notifyRebootEnded

    protected void notifyRebootEnded ()

    Notifies all IDeviceActionReceiver about reboot end event.

    رميات
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    notifyRebootStarted

    protected void notifyRebootStarted ()

    Notifies all IDeviceActionReceiver about reboot start event.

    رميات
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    performDeviceAction

    protected boolean performDeviceAction (String actionDescription, 
                    NativeDevice.DeviceAction action, 
                    int retryAttempts)

    Performs an action on this device. Attempts to recover device and optionally retry command if action fails.

    حدود
    actionDescription String : a short description of action to be performed. Used for logging purposes only.

    action NativeDevice.DeviceAction : the action to be performed

    retryAttempts int : the retry attempts to make for action if it fails but recovery succeeds

    عائدات
    boolean true if action was performed successfully

    رميات
    DeviceNotAvailableException if recovery attempt fails or max attempts done without success

    postAdbReboot

    protected void postAdbReboot ()

    Possible extra actions that can be taken after a reboot.

    رميات
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    prePostBootSetup

    protected void prePostBootSetup ()

    Allows each device type (AndroidNativeDevice, TestDevice) to override this method for specific post boot setup.

    رميات
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    pullFileInternal

    protected boolean pullFileInternal (String remoteFilePath, 
                    File localFile)

    حدود
    remoteFilePath String

    localFile File

    عائدات
    boolean

    رميات
    DeviceNotAvailableException

    setClock

    protected void setClock (Clock clock)

    Set the Clock instance to use.

    حدود
    clock Clock

    setMicrodroidProcess

    protected void setMicrodroidProcess (Process process)

    Marks the TestDevice as microdroid and sets its CID.

    حدود
    process Process : Process of the Microdroid VM.

    setTestDeviceOptions

    protected void setTestDeviceOptions ( deviceOptions)

    حدود
    deviceOptions

    simpleFastbootCommand

    protected CommandResult simpleFastbootCommand (long timeout, 
                     envVarMap, 
                    String[] fullCmd)

    Executes a simple fastboot command with environment variables and report the status of the command.

    حدود
    timeout long

    envVarMap

    fullCmd String

    عائدات
    CommandResult

    simpleFastbootCommand

    protected CommandResult simpleFastbootCommand (long timeout, 
                    String[] fullCmd)

    Executes a simple fastboot command and report the status of the command.

    حدود
    timeout long

    fullCmd String

    عائدات
    CommandResult

    waitForDeviceNotAvailable

    protected boolean waitForDeviceNotAvailable (String operationDesc, 
                    long time)

    Wait to see the device going unavailable (stop reporting to adb).

    حدود
    operationDesc String : The name of the operation that is waiting for unavailable.

    time long : The time to wait for unavailable to occur.

    عائدات
    boolean True if device did become unavailable.