store probed androidserial for later use by enableremote

This commit is contained in:
Joey Hess 2018-03-27 17:34:31 -04:00
parent bc90c71b54
commit ceee0ea5f1
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -98,28 +98,30 @@ adbSetup _ mu _ c gc = do
adir <- maybe (giveup "Specify androiddirectory=") (pure . AndroidPath)
(M.lookup "androiddirectory" c)
serial <- getserial =<< liftIO enumerateAdbConnected
let c' = M.insert "androidserial" (fromAndroidSerial serial) c
(c', _encsetup) <- encryptionSetup c gc
(c'', _encsetup) <- encryptionSetup c' gc
ok <- liftIO $ adbShellBool serial
[Param "mkdir", Param "-p", File (fromAndroidPath adir)]
unless ok $
giveup "Creating directory on Android device failed."
gitConfigSpecialRemote u c'
gitConfigSpecialRemote u c''
[ ("adb", "true")
, ("androiddirectory", fromAndroidPath adir)
, ("androidserial", fromAndroidSerial serial)
]
return (c', u)
return (c'', u)
where
getserial [] = giveup "adb does not list any connected android devices. Plug in an Android device, or configure adb, and try again.."
getserial (s:[]) = return s
getserial l = case M.lookup "androidserial" c of
Nothing -> giveup $ unlines $
"There are multiple connected android devices, specify which to use with androidserial="
: map fromAndroidSerial l
Nothing -> case l of
(s:[]) -> return s
_ -> giveup $ unlines $
"There are multiple connected android devices, specify which to use with androidserial="
: map fromAndroidSerial l
Just cs
| AndroidSerial cs `elem` l -> return (AndroidSerial cs)
| otherwise -> giveup $ "The device with androidserial=" ++ cs ++ " is not connected."