Add codesign support for host only bots

This CL mainly copies mobile provisioning profile to the default location for Host only bots.

Led run with `--codesign` on a host only bot:
https://ci.chromium.org/raw/build/logs.chromium.org/flutter/led/keyonghan_google.com/742210519cd0da697bc736a9369d0a4013a267cb58f59bda53192a5e7b7a22d0/+/build.proto?server=chromium-swarm.appspot.com

Change-Id: Ia97f97fe482d02e145527c7aeeb663c4dd2543b2
Bug: https://github.com/flutter/flutter/issues/115043
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/35962
Commit-Queue: Keyong Han <keyonghan@google.com>
Reviewed-by: Ricardo Amador <ricardoamador@google.com>
Reviewed-by: Godofredo Contreras <godofredoc@google.com>
diff --git a/recipe_modules/flutter_deps/__init__.py b/recipe_modules/flutter_deps/__init__.py
index a8bb4a7..f1dfa6e 100644
--- a/recipe_modules/flutter_deps/__init__.py
+++ b/recipe_modules/flutter_deps/__init__.py
@@ -1,6 +1,7 @@
 DEPS = [
     'flutter/android_virtual_device',
     'flutter/repo_util',
+    'flutter/test_utils',
     'recipe_engine/cas',
     'recipe_engine/cipd',
     'recipe_engine/context',
@@ -9,4 +10,5 @@
     'recipe_engine/platform',
     'recipe_engine/properties',
     'recipe_engine/step',
+    'recipe_engine/swarming',
 ]
diff --git a/recipe_modules/flutter_deps/api.py b/recipe_modules/flutter_deps/api.py
index 3ff78ac..b1367e9 100644
--- a/recipe_modules/flutter_deps/api.py
+++ b/recipe_modules/flutter_deps/api.py
@@ -542,11 +542,30 @@
       env_prefixes(dict):  Current environment prefixes variables.
     """
     with self.m.step.nest('Prepare code signing'):
-      self.m.step(
-          'unlock login keychain',
-          ['unlock_login_keychain.sh'],
-          infra_step=True,
-      )
+      # Unlock keychain for devicelab tasks.
+      if self.m.test_utils.is_devicelab_bot():
+        self.m.step(
+            'unlock login keychain',
+            ['unlock_login_keychain.sh'],
+            infra_step=True,
+        )
+      # Download and copy provisiong profile to default location for Chromium Host only bots.
+      else:
+        version = version or 'latest'
+        mobileprovision_path = self.m.path.mkdtemp().join('mobileprovision')
+        mobileprovision = self.m.cipd.EnsureFile()
+        mobileprovision.add_package('flutter_internal/mac/mobileprovision/${platform}', version)
+        with self.m.step.nest('Installing Mac mobileprovision'):
+          self.m.cipd.ensure(mobileprovision_path, mobileprovision)
+
+        mobileprovision_profile = mobileprovision_path.join('development.mobileprovision')
+        copy_script = self.resource('copy_mobileprovisioning_profile.sh')
+        self.m.step('Set execute permission', ['chmod', '755', copy_script])
+        self.m.step(
+            'copy mobileprovisioning profile',
+            [copy_script, mobileprovision_profile]
+        )
+
       # See go/googler-flutter-signing about how to renew the Apple development
       # certificate and provisioning profile.
       env['FLUTTER_XCODE_CODE_SIGN_STYLE'] = 'Manual'
diff --git a/recipe_modules/flutter_deps/examples/full.expected/basic.json b/recipe_modules/flutter_deps/examples/full.expected/basic.json
index 239f109..f71374f 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/basic.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/basic.json
@@ -542,11 +542,8 @@
     "name": "Prepare code signing"
   },
   {
-    "cmd": [
-      "unlock_login_keychain.sh"
-    ],
-    "infra_step": true,
-    "name": "Prepare code signing.unlock login keychain",
+    "cmd": [],
+    "name": "Prepare code signing.Installing Mac mobileprovision",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -556,7 +553,57 @@
       "cipd",
       "ensure",
       "-root",
-      "[CLEANUP]/tmp_tmp_2/curl",
+      "[CLEANUP]/tmp_tmp_2/mobileprovision",
+      "-ensure-file",
+      "flutter_internal/mac/mobileprovision/${platform} latest",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Prepare code signing.Installing Mac mobileprovision.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-latest----------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter_internal/mac/mobileprovision/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "chmod",
+      "755",
+      "RECIPE_MODULE[flutter::flutter_deps]/resources/copy_mobileprovisioning_profile.sh"
+    ],
+    "name": "Prepare code signing.Set execute permission",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[flutter::flutter_deps]/resources/copy_mobileprovisioning_profile.sh",
+      "[CLEANUP]/tmp_tmp_2/mobileprovision/development.mobileprovision"
+    ],
+    "name": "Prepare code signing.copy mobileprovisioning profile",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CLEANUP]/tmp_tmp_3/curl",
       "-ensure-file",
       "flutter_internal/tools/curl/${platform} latest",
       "-max-threads",
@@ -717,7 +764,7 @@
         "[CACHE]/cosign/bin",
         "[CACHE]/ninja",
         "[CACHE]/clang/bin",
-        "[CLEANUP]/tmp_tmp_2/curl",
+        "[CLEANUP]/tmp_tmp_3/curl",
         "[START_DIR]/gems/bin"
       ]
     },
diff --git a/recipe_modules/flutter_deps/examples/full.expected/flutter_engine.json b/recipe_modules/flutter_deps/examples/full.expected/flutter_engine.json
index f6e4c01..dbd0659 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/flutter_engine.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/flutter_engine.json
@@ -626,11 +626,8 @@
     "name": "Prepare code signing"
   },
   {
-    "cmd": [
-      "unlock_login_keychain.sh"
-    ],
-    "infra_step": true,
-    "name": "Prepare code signing.unlock login keychain",
+    "cmd": [],
+    "name": "Prepare code signing.Installing Mac mobileprovision",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -640,7 +637,57 @@
       "cipd",
       "ensure",
       "-root",
-      "[CLEANUP]/tmp_tmp_2/curl",
+      "[CLEANUP]/tmp_tmp_2/mobileprovision",
+      "-ensure-file",
+      "flutter_internal/mac/mobileprovision/${platform} latest",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Prepare code signing.Installing Mac mobileprovision.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-latest----------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter_internal/mac/mobileprovision/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "chmod",
+      "755",
+      "RECIPE_MODULE[flutter::flutter_deps]/resources/copy_mobileprovisioning_profile.sh"
+    ],
+    "name": "Prepare code signing.Set execute permission",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[flutter::flutter_deps]/resources/copy_mobileprovisioning_profile.sh",
+      "[CLEANUP]/tmp_tmp_2/mobileprovision/development.mobileprovision"
+    ],
+    "name": "Prepare code signing.copy mobileprovisioning profile",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CLEANUP]/tmp_tmp_3/curl",
       "-ensure-file",
       "flutter_internal/tools/curl/${platform} latest",
       "-max-threads",
@@ -803,7 +850,7 @@
         "[CACHE]/cosign/bin",
         "[CACHE]/ninja",
         "[CACHE]/clang/bin",
-        "[CLEANUP]/tmp_tmp_2/curl",
+        "[CLEANUP]/tmp_tmp_3/curl",
         "[START_DIR]/gems/bin"
       ]
     },
diff --git a/recipe_modules/flutter_deps/examples/full.expected/goldTryjob.json b/recipe_modules/flutter_deps/examples/full.expected/goldTryjob.json
index 239f109..f71374f 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/goldTryjob.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/goldTryjob.json
@@ -542,11 +542,8 @@
     "name": "Prepare code signing"
   },
   {
-    "cmd": [
-      "unlock_login_keychain.sh"
-    ],
-    "infra_step": true,
-    "name": "Prepare code signing.unlock login keychain",
+    "cmd": [],
+    "name": "Prepare code signing.Installing Mac mobileprovision",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -556,7 +553,57 @@
       "cipd",
       "ensure",
       "-root",
-      "[CLEANUP]/tmp_tmp_2/curl",
+      "[CLEANUP]/tmp_tmp_2/mobileprovision",
+      "-ensure-file",
+      "flutter_internal/mac/mobileprovision/${platform} latest",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Prepare code signing.Installing Mac mobileprovision.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-latest----------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter_internal/mac/mobileprovision/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "chmod",
+      "755",
+      "RECIPE_MODULE[flutter::flutter_deps]/resources/copy_mobileprovisioning_profile.sh"
+    ],
+    "name": "Prepare code signing.Set execute permission",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[flutter::flutter_deps]/resources/copy_mobileprovisioning_profile.sh",
+      "[CLEANUP]/tmp_tmp_2/mobileprovision/development.mobileprovision"
+    ],
+    "name": "Prepare code signing.copy mobileprovisioning profile",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CLEANUP]/tmp_tmp_3/curl",
       "-ensure-file",
       "flutter_internal/tools/curl/${platform} latest",
       "-max-threads",
@@ -717,7 +764,7 @@
         "[CACHE]/cosign/bin",
         "[CACHE]/ninja",
         "[CACHE]/clang/bin",
-        "[CLEANUP]/tmp_tmp_2/curl",
+        "[CLEANUP]/tmp_tmp_3/curl",
         "[START_DIR]/gems/bin"
       ]
     },
diff --git a/recipe_modules/flutter_deps/examples/full.expected/linux.json b/recipe_modules/flutter_deps/examples/full.expected/linux.json
index 239f109..f71374f 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/linux.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/linux.json
@@ -542,11 +542,8 @@
     "name": "Prepare code signing"
   },
   {
-    "cmd": [
-      "unlock_login_keychain.sh"
-    ],
-    "infra_step": true,
-    "name": "Prepare code signing.unlock login keychain",
+    "cmd": [],
+    "name": "Prepare code signing.Installing Mac mobileprovision",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -556,7 +553,57 @@
       "cipd",
       "ensure",
       "-root",
-      "[CLEANUP]/tmp_tmp_2/curl",
+      "[CLEANUP]/tmp_tmp_2/mobileprovision",
+      "-ensure-file",
+      "flutter_internal/mac/mobileprovision/${platform} latest",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Prepare code signing.Installing Mac mobileprovision.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-latest----------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter_internal/mac/mobileprovision/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "chmod",
+      "755",
+      "RECIPE_MODULE[flutter::flutter_deps]/resources/copy_mobileprovisioning_profile.sh"
+    ],
+    "name": "Prepare code signing.Set execute permission",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[flutter::flutter_deps]/resources/copy_mobileprovisioning_profile.sh",
+      "[CLEANUP]/tmp_tmp_2/mobileprovision/development.mobileprovision"
+    ],
+    "name": "Prepare code signing.copy mobileprovisioning profile",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CLEANUP]/tmp_tmp_3/curl",
       "-ensure-file",
       "flutter_internal/tools/curl/${platform} latest",
       "-max-threads",
@@ -717,7 +764,7 @@
         "[CACHE]/cosign/bin",
         "[CACHE]/ninja",
         "[CACHE]/clang/bin",
-        "[CLEANUP]/tmp_tmp_2/curl",
+        "[CLEANUP]/tmp_tmp_3/curl",
         "[START_DIR]/gems/bin"
       ]
     },
diff --git a/recipe_modules/flutter_deps/examples/full.expected/local_engine_cas.json b/recipe_modules/flutter_deps/examples/full.expected/local_engine_cas.json
index 0962d23..3ca893f 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/local_engine_cas.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/local_engine_cas.json
@@ -626,11 +626,8 @@
     "name": "Prepare code signing"
   },
   {
-    "cmd": [
-      "unlock_login_keychain.sh"
-    ],
-    "infra_step": true,
-    "name": "Prepare code signing.unlock login keychain",
+    "cmd": [],
+    "name": "Prepare code signing.Installing Mac mobileprovision",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -640,7 +637,57 @@
       "cipd",
       "ensure",
       "-root",
-      "[CLEANUP]/tmp_tmp_2/curl",
+      "[CLEANUP]/tmp_tmp_2/mobileprovision",
+      "-ensure-file",
+      "flutter_internal/mac/mobileprovision/${platform} latest",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Prepare code signing.Installing Mac mobileprovision.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-latest----------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter_internal/mac/mobileprovision/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "chmod",
+      "755",
+      "RECIPE_MODULE[flutter::flutter_deps]/resources/copy_mobileprovisioning_profile.sh"
+    ],
+    "name": "Prepare code signing.Set execute permission",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[flutter::flutter_deps]/resources/copy_mobileprovisioning_profile.sh",
+      "[CLEANUP]/tmp_tmp_2/mobileprovision/development.mobileprovision"
+    ],
+    "name": "Prepare code signing.copy mobileprovisioning profile",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CLEANUP]/tmp_tmp_3/curl",
       "-ensure-file",
       "flutter_internal/tools/curl/${platform} latest",
       "-max-threads",
@@ -803,7 +850,7 @@
         "[CACHE]/cosign/bin",
         "[CACHE]/ninja",
         "[CACHE]/clang/bin",
-        "[CLEANUP]/tmp_tmp_2/curl",
+        "[CLEANUP]/tmp_tmp_3/curl",
         "[START_DIR]/gems/bin"
       ]
     },
diff --git a/recipe_modules/flutter_deps/examples/full.expected/windows.json b/recipe_modules/flutter_deps/examples/full.expected/windows.json
index 2f224fc..b0dad1d 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/windows.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/windows.json
@@ -542,11 +542,8 @@
     "name": "Prepare code signing"
   },
   {
-    "cmd": [
-      "unlock_login_keychain.sh"
-    ],
-    "infra_step": true,
-    "name": "Prepare code signing.unlock login keychain",
+    "cmd": [],
+    "name": "Prepare code signing.Installing Mac mobileprovision",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -556,7 +553,57 @@
       "cipd.bat",
       "ensure",
       "-root",
-      "[CLEANUP]\\tmp_tmp_2\\curl",
+      "[CLEANUP]\\tmp_tmp_2\\mobileprovision",
+      "-ensure-file",
+      "flutter_internal/mac/mobileprovision/${platform} latest",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Prepare code signing.Installing Mac mobileprovision.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-latest----------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter_internal/mac/mobileprovision/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "chmod",
+      "755",
+      "RECIPE_MODULE[flutter::flutter_deps]\\resources\\copy_mobileprovisioning_profile.sh"
+    ],
+    "name": "Prepare code signing.Set execute permission",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[flutter::flutter_deps]\\resources\\copy_mobileprovisioning_profile.sh",
+      "[CLEANUP]\\tmp_tmp_2\\mobileprovision\\development.mobileprovision"
+    ],
+    "name": "Prepare code signing.copy mobileprovisioning profile",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "cipd.bat",
+      "ensure",
+      "-root",
+      "[CLEANUP]\\tmp_tmp_3\\curl",
       "-ensure-file",
       "flutter_internal/tools/curl/${platform} latest",
       "-max-threads",
@@ -682,7 +729,7 @@
         "[CACHE]\\cosign\\bin",
         "[CACHE]\\ninja",
         "[CACHE]\\clang\\bin",
-        "[CLEANUP]\\tmp_tmp_2\\curl"
+        "[CLEANUP]\\tmp_tmp_3\\curl"
       ]
     },
     "name": "Install Certs"
@@ -758,7 +805,7 @@
         "[CACHE]\\cosign\\bin",
         "[CACHE]\\ninja",
         "[CACHE]\\clang\\bin",
-        "[CLEANUP]\\tmp_tmp_2\\curl"
+        "[CLEANUP]\\tmp_tmp_3\\curl"
       ]
     },
     "name": "Install VS build"
diff --git a/recipe_modules/flutter_deps/examples/full.expected/with-arm64ruby.json b/recipe_modules/flutter_deps/examples/full.expected/with-arm64ruby.json
index 838b451..ea3ea89 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/with-arm64ruby.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/with-arm64ruby.json
@@ -542,11 +542,8 @@
     "name": "Prepare code signing"
   },
   {
-    "cmd": [
-      "unlock_login_keychain.sh"
-    ],
-    "infra_step": true,
-    "name": "Prepare code signing.unlock login keychain",
+    "cmd": [],
+    "name": "Prepare code signing.Installing Mac mobileprovision",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -556,7 +553,57 @@
       "cipd",
       "ensure",
       "-root",
-      "[CLEANUP]/tmp_tmp_2/curl",
+      "[CLEANUP]/tmp_tmp_2/mobileprovision",
+      "-ensure-file",
+      "flutter_internal/mac/mobileprovision/${platform} latest",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Prepare code signing.Installing Mac mobileprovision.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-latest----------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter_internal/mac/mobileprovision/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "chmod",
+      "755",
+      "RECIPE_MODULE[flutter::flutter_deps]/resources/copy_mobileprovisioning_profile.sh"
+    ],
+    "name": "Prepare code signing.Set execute permission",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[flutter::flutter_deps]/resources/copy_mobileprovisioning_profile.sh",
+      "[CLEANUP]/tmp_tmp_2/mobileprovision/development.mobileprovision"
+    ],
+    "name": "Prepare code signing.copy mobileprovisioning profile",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CLEANUP]/tmp_tmp_3/curl",
       "-ensure-file",
       "flutter_internal/tools/curl/${platform} latest",
       "-max-threads",
@@ -717,7 +764,7 @@
         "[CACHE]/cosign/bin",
         "[CACHE]/ninja",
         "[CACHE]/clang/bin",
-        "[CLEANUP]/tmp_tmp_2/curl",
+        "[CLEANUP]/tmp_tmp_3/curl",
         "[START_DIR]/gems/bin"
       ]
     },
diff --git a/recipe_modules/flutter_deps/examples/full.expected/with-gems.json b/recipe_modules/flutter_deps/examples/full.expected/with-gems.json
index 010ffeb..57ef6b5 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/with-gems.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/with-gems.json
@@ -542,11 +542,8 @@
     "name": "Prepare code signing"
   },
   {
-    "cmd": [
-      "unlock_login_keychain.sh"
-    ],
-    "infra_step": true,
-    "name": "Prepare code signing.unlock login keychain",
+    "cmd": [],
+    "name": "Prepare code signing.Installing Mac mobileprovision",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -556,7 +553,57 @@
       "cipd",
       "ensure",
       "-root",
-      "[CLEANUP]/tmp_tmp_2/curl",
+      "[CLEANUP]/tmp_tmp_2/mobileprovision",
+      "-ensure-file",
+      "flutter_internal/mac/mobileprovision/${platform} latest",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Prepare code signing.Installing Mac mobileprovision.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-latest----------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter_internal/mac/mobileprovision/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "chmod",
+      "755",
+      "RECIPE_MODULE[flutter::flutter_deps]/resources/copy_mobileprovisioning_profile.sh"
+    ],
+    "name": "Prepare code signing.Set execute permission",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[flutter::flutter_deps]/resources/copy_mobileprovisioning_profile.sh",
+      "[CLEANUP]/tmp_tmp_2/mobileprovision/development.mobileprovision"
+    ],
+    "name": "Prepare code signing.copy mobileprovisioning profile",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CLEANUP]/tmp_tmp_3/curl",
       "-ensure-file",
       "flutter_internal/tools/curl/${platform} latest",
       "-max-threads",
@@ -717,7 +764,7 @@
         "[CACHE]/cosign/bin",
         "[CACHE]/ninja",
         "[CACHE]/clang/bin",
-        "[CLEANUP]/tmp_tmp_2/curl",
+        "[CLEANUP]/tmp_tmp_3/curl",
         "[START_DIR]/gems/bin"
       ]
     },
diff --git a/recipe_modules/flutter_deps/examples/full.py b/recipe_modules/flutter_deps/examples/full.py
index bfbe5dc..a6d85b3 100644
--- a/recipe_modules/flutter_deps/examples/full.py
+++ b/recipe_modules/flutter_deps/examples/full.py
@@ -12,6 +12,7 @@
     'recipe_engine/path',
     'recipe_engine/platform',
     'recipe_engine/properties',
+    'recipe_engine/swarming',
 ]
 
 
@@ -108,6 +109,7 @@
           dependencies=[{"dependency": "xcode"},
                         {'dependency': 'chrome_and_driver'}]
       ),
+      api.swarming.properties(bot_id='flutter-devicelab-mac-1'),
       api.path.exists(
           api.path['cache'].join(
               'osx_sdk/XCode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift'
diff --git a/recipe_modules/flutter_deps/resources/copy_mobileprovisioning_profile.sh b/recipe_modules/flutter_deps/resources/copy_mobileprovisioning_profile.sh
new file mode 100644
index 0000000..dcefed0
--- /dev/null
+++ b/recipe_modules/flutter_deps/resources/copy_mobileprovisioning_profile.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# Helper script to copy mobileprovisioning profile to
+# bot's default location.
+set -e
+
+mobileprovision_profile=$1
+destination="$HOME/Library/MobileDevice/Provisioning Profiles"
+uuid=$(/usr/libexec/PlistBuddy -c 'Print UUID' /dev/stdin <<< $(security cms -D -i "$mobileprovision_profile"))
+mkdir -p "$destination"
+if [ ! -f "$destination"/"$uuid".mobileprovision ]; then
+  cp "$mobileprovision_profile" "$destination"/"$uuid".mobileprovision
+fi
\ No newline at end of file