2018-05-08 14:06:19 -04:00
|
|
|
{-# LANGUAGE CPP #-}
|
|
|
|
|
2018-04-25 14:38:42 -04:00
|
|
|
{- Android stuff
|
|
|
|
-
|
|
|
|
- Copyright 2018 Joey Hess <id@joeyh.name>
|
|
|
|
-
|
|
|
|
- License: BSD-2-clause
|
|
|
|
-}
|
|
|
|
|
2019-11-21 15:38:06 -04:00
|
|
|
module Utility.Android (
|
|
|
|
osAndroid
|
|
|
|
) where
|
2018-04-25 14:38:42 -04:00
|
|
|
|
2018-08-07 15:06:33 -04:00
|
|
|
#ifdef linux_HOST_OS
|
2018-04-25 14:38:42 -04:00
|
|
|
import Common
|
2018-08-07 15:06:33 -04:00
|
|
|
#endif
|
2018-04-25 14:38:42 -04:00
|
|
|
|
|
|
|
-- Detect when the Linux build is running on Android, eg in termux.
|
2018-04-25 16:57:57 -04:00
|
|
|
--
|
|
|
|
-- Note that this relies on termux's uname having been built with "Android"
|
|
|
|
-- as the os name. Often on Android, uname will report "Linux".
|
2018-04-25 14:38:42 -04:00
|
|
|
osAndroid :: IO Bool
|
2018-05-08 14:06:19 -04:00
|
|
|
#ifdef linux_HOST_OS
|
|
|
|
osAndroid = catchDefaultIO False $
|
|
|
|
("Android" `isPrefixOf` ) <$> readProcess "uname" ["-o"]
|
|
|
|
#else
|
|
|
|
osAndroid = return False
|
|
|
|
#endif
|