1313# limitations under the License.
1414
1515import io
16- from typing import Iterable , Optional
16+ from typing import Iterable
1717
1818from mobly import utils
1919from mobly .controllers .android_device import AndroidDevice
@@ -80,8 +80,9 @@ def install(
8080 device : AndroidDevice ,
8181 apk_path : str ,
8282 timeout : int = DEFAULT_TIMEOUT_INSTALL_APK_SEC ,
83- user_id : Optional [int ] = None ,
84- params : Optional [Iterable [str ]] = None ,
83+ user_id : int | None = None ,
84+ params : Iterable [str ] | None = None ,
85+ enable_runtime_perms : bool = True ,
8586) -> None :
8687 """Install an apk on an Android device.
8788
@@ -97,6 +98,7 @@ def install(
9798 install for the current user by default. Android's multi-user support
9899 did not realistically work until SDK 24.
99100 params: string list, additional parameters included in the adb install cmd.
101+ enable_runtime_perms: bool, Set the `-g` flag, which allows all runtime permissions.
100102
101103 Raises:
102104 AdbError: Installation failed.
@@ -111,7 +113,7 @@ def install(
111113 if user_id is None :
112114 user_id = device .adb .current_user_id
113115 args = ['--user' , str (user_id )] + args
114- if android_api_version >= 23 :
116+ if android_api_version >= 23 and enable_runtime_perms :
115117 args .append ('-g' )
116118 if android_api_version >= 17 :
117119 args .append ('-d' )
0 commit comments