| 245 | } |
| 246 | |
| 247 | rdcstr GetFriendlyName(const rdcstr &deviceID) |
| 248 | { |
| 249 | // run adb root now, so we hit any disconnection that we're going to before trying to connect. |
| 250 | // If we can't be root, this is cheap, if we're already root, this is cheap, if we can be root |
| 251 | // and this changes us it will block only the first time - and we expect this function to be |
| 252 | // slow-ish. |
| 253 | // |
| 254 | // We do this here so that we sneakily take advantage of the above caching - otherwise we spam adb |
| 255 | // root commands into the log |
| 256 | Android::adbExecCommand(deviceID, "root"); |
| 257 | |
| 258 | rdcstr manuf = |
| 259 | Android::adbExecCommand(deviceID, "shell getprop ro.product.manufacturer").strStdout.trimmed(); |
| 260 | rdcstr model = |
| 261 | Android::adbExecCommand(deviceID, "shell getprop ro.product.model").strStdout.trimmed(); |
| 262 | |
| 263 | rdcstr combined; |
| 264 | |
| 265 | if(manuf.empty() && model.empty()) |
| 266 | combined = ""; |
| 267 | else if(manuf.empty() && !model.empty()) |
| 268 | combined = model; |
| 269 | else if(!manuf.empty() && model.empty()) |
| 270 | combined = manuf + " device"; |
| 271 | else if(!manuf.empty() && !model.empty()) |
| 272 | combined = manuf + " " + model; |
| 273 | |
| 274 | return combined; |
| 275 | } |
| 276 | |
| 277 | bool HasRootAccess(const rdcstr &deviceID) |
| 278 | { |
no test coverage detected