Android host keeps previous fleet's self-service apps in Play Store after re-enrolling into a new fleet
Fleet versions
- Discovered: rc-minor-fleet-v4.94.0
💥 Actual behavior
After an Android host re-enrolls into a different fleet, Fleet shows the host in the new fleet, but the managed Play Store keeps offering the previous fleet's self-service apps. The new fleet has no apps configured.
- Previous fleet ("Personal mobile devices"): 5 self-service Android apps (Facebook, Google Chrome, Instagram, TikTok, WhatsApp Messenger)
- New fleet ("Test Fleet"): 0 apps in Library, nothing in Setup experience → Install software
- Device managed Play Store after re-enrollment: still shows all 5 apps from the previous fleet (plus the Fleet app)
The apps persist after a Fleet refetch and after a device restart, so this isn't caching on the device.
Reproduced on:
- Personally owned (BYOD) and company-owned devices
- Work profile removed + host record deleted in Fleet
- Work profile removed + host record kept in Fleet
🛠️ Expected behavior
The device only offers Fleet B's apps (none in this case, besides the Fleet app). Fleet A's apps are no longer available in the managed Play Store.
🧑💻 Steps to reproduce
These steps:
- [ ] Have been confirmed to consistently lead to reproduction in multiple Fleet instances.
- [x] Describe the workflow that led to the error, but have not yet been reproduced in multiple Fleet instances.
- Add one or more self-service Android apps to Fleet A.
- Enroll an Android device (BYOD or company-owned) into Fleet A. Confirm the apps show in the managed Play Store.
- Remove the work profile from the device. Then either:
- a) Delete the host record in Fleet, or
- b) Leave the host record in Fleet Both reproduce the issue.
- Re-enroll the same device into Fleet B, which has no Android apps, using Fleet B's enroll secret.
- Confirm the host shows Fleet B on its Details page.
- Open the managed Play Store on the device.
🕯️ More info (optional)
Likely cause (from reading the code at 1d8b32b098):
- The per-device AMAPI policy is named after the host UUID (
enterprises/…/policies/<host UUID>). The host UUID is theenterpriseSpecificIdfor BYOD, or a hash of brand and serial for company-owned (getAndroidHostKey,server/mdm/android/service/pubsub.go). It's stable across re-enrollments, and the policy is never deleted on unenroll or host deletion, so the old policy and itsapplicationslist survive. - On re-enroll,
ensureHostSpecificPolicyIsApplied(server/worker/software_worker.go) re-patches that policy viaPatchPolicywithExcludeApps: true, so the old fleet's apps aren't cleared. makeAndroidAppsAvailableForHostthen usesAddAppsToAndroidPolicy, which is additive and returns early when the new fleet has 0 apps. Old apps are never removed.- By contrast, the team-transfer path (
bulkSetAndroidAppsAvailableForHosts) usesSetAppsForAndroidPolicy, which replaces the app list. Using a replace on re-enrollment (or clearingapplicationswhen re-applying the host policy) would likely fix this.
Other notes:
- The host-level Software → Library tab shows "not supported on this host" for Android (planned for a future release), so the device's available-app list can't be checked from the host page.
- Screenshots: [host Details showing Test Fleet] [Personal mobile devices Library] [Test Fleet Library] [device Play Store, BYOD] [device Play Store, company-owned]
Software inventory is refresh in PlayStore on re-enrollment
Old apps linger here when a device finds new home clean slate sets it free