UserSwitcher

public final class UserSwitcher
extends Object

java.lang.Object
   ↳ com.android.tradefed.device.UserSwitcher


ออบเจ็กต์ช่วยที่ใช้เพื่อเปลี่ยนเป็นผู้ใช้ของ type ที่ระบุ แล้วเปลี่ยนกลับไปเป็น ผู้ใช้ก่อนหน้าในภายหลัง

หมายเหตุ: โดยทั่วไปแล้วจะใช้เพียงครั้งเดียว ซึ่งมักจะใช้โดยการติดตั้งใช้งาน ERROR(/com.android.tradefed.targetprep.ISwitchUserTargetPreparer) (ซึ่งจะเรียก ERROR(switchUser(ITestDevice,UserType)/#switchUser(com.android.tradefed.device.ITestDevice,com.android.tradefed.device.UserInfo.UserType) switchUser(ITestDevice,UserType)) ใน setUp() และ switchBack() ใน tearDown() โดยอาจใช้ได้หลายครั้ง ในกรณีนี้ switchBack() จะเปลี่ยนไปเป็น ERROR(user switched to/#switchUser(com.android.tradefed.device.ITestDevice,com.android.tradefed.device.UserInfo.UserType) user switched to) ล่าสุดเสมอ

สรุป

เครื่องมือสร้างสาธารณะ

UserSwitcher(ITestDevice device, UserInfo.UserType userType)

ตัวสร้างเริ่มต้น

UserSwitcher(ITestDevice device, UserInfo.UserType userType, UserSwitcher.UserTypeMode userTypeMode)

เครื่องมือสร้างแบบเต็ม

เมธอดสาธารณะ

boolean switchBack()

เปลี่ยนกลับไปเป็นผู้ใช้ปัจจุบันก่อนการโทร ERROR(switchUser(ITestDevice,UserType)/#switchUser(com.android.tradefed.device.ITestDevice,com.android.tradefed.device.UserInfo.UserType) switchUser(ITestDevice,UserType))

int switchUser()

เปลี่ยนไปใช้ผู้ใช้ของ type ที่ตั้งค่าไว้ในตัวสร้าง หากจำเป็น

เครื่องมือสร้างสาธารณะ

UserSwitcher

public UserSwitcher (ITestDevice device, 
                UserInfo.UserType userType)

ตัวสร้างเริ่มต้น

โดยจะตั้งค่าโหมดประเภทผู้ใช้เป็น UserTypeMode.LEGACY

พารามิเตอร์
device ITestDevice

userType UserInfo.UserType: ประเภทผู้ใช้ที่จะเปลี่ยนไปใช้

UserSwitcher

public UserSwitcher (ITestDevice device, 
                UserInfo.UserType userType, 
                UserSwitcher.UserTypeMode userTypeMode)

เครื่องมือสร้างแบบเต็ม

พารามิเตอร์
device ITestDevice

userType UserInfo.UserType: ประเภทผู้ใช้ที่จะเปลี่ยนไปใช้

userTypeMode UserSwitcher.UserTypeMode: กำหนดลักษณะการทำงานของผู้เตรียมข้อมูลตามพร็อพเพอร์ตี้บางอย่างของประเภทผู้ใช้

เมธอดสาธารณะ

switchBack

public boolean switchBack ()

เปลี่ยนกลับไปเป็นผู้ใช้ปัจจุบันก่อนการโทร ERROR(switchUser(ITestDevice,UserType)/#switchUser(com.android.tradefed.device.ITestDevice,com.android.tradefed.device.UserInfo.UserType) switchUser(ITestDevice,UserType))

การคืนสินค้า
boolean การเปลี่ยนสำเร็จหรือไม่

ส่ง
IllegalStateException หากเรียกใช้เมธอดนี้ก่อน ERROR(switchUser(ITestDevice,UserType)/#switchUser(com.android.tradefed.device.ITestDevice,com.android.tradefed.device.UserInfo.UserType) switchUser(ITestDevice,UserType))
DeviceNotAvailableException

switchUser

public int switchUser ()

เปลี่ยนไปใช้ผู้ใช้ของ type ที่ตั้งค่าไว้ในตัวสร้าง หากจำเป็น

การคืนสินค้า
int รหัสของผู้ใช้ปัจจุบันหลังจากเปลี่ยน

ส่ง
TargetSetupError หากไม่พบผู้ใช้ประเภทที่ระบุ หรือหากการสลับผู้ใช้ ไม่สำเร็จ หรือหากมีการเรียกใช้เมธอดนี้แล้ว
DeviceNotAvailableException