or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

build-system.mdcommands.mddevice-management.mdemulator-management.mdindex.mdnetwork-configuration.mdproject-configuration.md

device-management.mddocs/

0

# Device Management

1

2

ADB integration for discovering, selecting, and managing Android devices and emulators. Provides comprehensive device detection, interactive selection, and device capability analysis.

3

4

## Capabilities

5

6

### ADB Utilities

7

8

Core ADB interaction utilities for device discovery and hardware information.

9

10

```typescript { .api }

11

/**

12

* ADB utilities object with device management functions

13

*/

14

const adb: {

15

/** Get list of connected devices from ADB */

16

getDevices: (adbPath: string) => Array<string>;

17

/** Get available CPU architectures from device */

18

getAvailableCPUs: (adbPath: string, device: string) => Array<string>;

19

/** Get primary CPU architecture of device */

20

getCPU: (adbPath: string, device: string) => string | null;

21

};

22

23

// Note: Individual ADB functions are only accessible through the adb object above.

24

// parseDevicesResult is an internal function not exported separately.

25

```

26

27

**Usage Examples:**

28

29

```typescript

30

import { adb, getAdbPath } from "@react-native-community/cli-platform-android";

31

32

const adbPath = getAdbPath();

33

34

// Get all connected devices

35

const devices = adb.getDevices(adbPath);

36

console.log("Connected devices:", devices);

37

38

// Get CPU architecture for first device

39

if (devices.length > 0) {

40

const cpu = adb.getCPU(adbPath, devices[0]);

41

console.log(`Device ${devices[0]} CPU:`, cpu);

42

43

// Get all available CPUs

44

const availableCPUs = adb.getAvailableCPUs(adbPath, devices[0]);

45

console.log("Available CPUs:", availableCPUs);

46

}

47

```

48

49

### ADB Path Resolution

50

51

Utility for locating the ADB executable in the system.

52

53

```typescript { .api }

54

/**

55

* Get path to ADB executable

56

* Uses ANDROID_HOME environment variable if available

57

* @returns Path to ADB executable

58

*/

59

function getAdbPath(): string;

60

```

61

62

**Usage Examples:**

63

64

```typescript

65

import { getAdbPath } from "@react-native-community/cli-platform-android";

66

67

// Get ADB path for system operations

68

const adbPath = getAdbPath();

69

console.log("ADB located at:", adbPath);

70

```

71

72

### Interactive Device Selection

73

74

Interactive device selection with emulator and phone detection.

75

76

```typescript { .api }

77

/**

78

* Interactive device selection with emulator/phone detection

79

* @returns Promise resolving to selected device data or undefined if cancelled

80

*/

81

async function listAndroidDevices(): Promise<DeviceData | undefined>;

82

83

/**

84

* Device information structure

85

*/

86

interface DeviceData {

87

/** Device identifier (can be undefined for offline devices) */

88

deviceId: string | undefined;

89

/** Human-readable device name */

90

readableName: string;

91

/** Whether device is currently connected */

92

connected: boolean;

93

/** Device type classification */

94

type: 'emulator' | 'phone';

95

}

96

97

/**

98

* Get readable name for Android emulator

99

* @param deviceId - Emulator device identifier

100

* @returns Human-readable emulator name

101

*/

102

function getEmulatorName(deviceId: string): string;

103

104

/**

105

* Get readable name for physical Android device

106

* @param deviceId - Physical device identifier

107

* @returns Human-readable device name

108

*/

109

function getPhoneName(deviceId: string): string;

110

111

/**

112

* Interactive prompt for device selection from available devices

113

* @param allDevices - Array of available devices

114

* @returns Promise resolving to selected device or undefined if cancelled

115

*/

116

function promptForDeviceSelection(allDevices: Array<DeviceData>): Promise<DeviceData | undefined>;

117

```

118

119

**Usage Examples:**

120

121

```typescript

122

import { listAndroidDevices } from "@react-native-community/cli-platform-android";

123

124

// Interactive device selection

125

const selectedDevice = await listAndroidDevices();

126

if (selectedDevice) {

127

console.log(`Selected device: ${selectedDevice.readableName}`);

128

console.log(`Device ID: ${selectedDevice.deviceId}`);

129

console.log(`Type: ${selectedDevice.type}`);

130

console.log(`Connected: ${selectedDevice.connected}`);

131

} else {

132

console.log("No device selected");

133

}

134

```

135

136

### Multi-User Device Support

137

138

Support for Android devices with multiple user profiles.

139

140

```typescript { .api }

141

/**

142

* User profile information for multi-user devices

143

*/

144

interface User {

145

/** User profile ID */

146

id: string;

147

/** User profile display name */

148

name: string;

149

}

150

151

/**

152

* Get available user profiles on device (Internal Function)

153

* Note: This function is internal and not directly exportable from the main package

154

* @param device - Device identifier

155

* @param adbPath - Path to ADB executable

156

* @returns Array of available user profiles

157

*/

158

function checkUsers(device: string, adbPath: string): User[];

159

160

/**

161

* Interactive prompt for user profile selection (Internal Function)

162

* Note: This function is internal and not directly exportable from the main package

163

* @param users - Array of available user profiles

164

* @returns Promise resolving to selected user profile

165

*/

166

async function promptForUser(users: User[]): Promise<User>;

167

```

168

169

**Note**: These functions are internal and used by the CLI commands for multi-user device support. They are not directly importable from the main package.

170

171

## Internal Device Operations

172

173

### Device Name Resolution

174

175

```typescript { .api }

176

/**

177

* Get readable name for Android emulator

178

* @param deviceId - Emulator device identifier

179

* @returns Human-readable emulator name

180

*/

181

function getEmulatorName(deviceId: string): string;

182

183

/**

184

* Get readable name for physical Android device

185

* @param deviceId - Physical device identifier

186

* @returns Human-readable device name

187

*/

188

function getPhoneName(deviceId: string): string;

189

```

190

191

These functions convert device IDs like "emulator-5554" or "abc123device" into user-friendly names for display in device selection prompts.