fleet icon indicating copy to clipboard operation
fleet copied to clipboard

Android host keeps previous fleet's self-service apps in Play Store after re-enrolling into a new fleet

Open terry-kwok-code opened this issue 1 month ago • 2 comments

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.
  1. Add one or more self-service Android apps to Fleet A.
  2. Enroll an Android device (BYOD or company-owned) into Fleet A. Confirm the apps show in the managed Play Store.
  3. 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.
  4. Re-enroll the same device into Fleet B, which has no Android apps, using Fleet B's enroll secret.
  5. Confirm the host shows Fleet B on its Details page.
  6. 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 the enterpriseSpecificId for 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 its applications list survive.
  • On re-enroll, ensureHostSpecificPolicyIsApplied (server/worker/software_worker.go) re-patches that policy via PatchPolicy with ExcludeApps: true, so the old fleet's apps aren't cleared.
  • makeAndroidAppsAvailableForHost then uses AddAppsToAndroidPolicy, 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) uses SetAppsForAndroidPolicy, which replaces the app list. Using a replace on re-enrollment (or clearing applications when 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]

terry-kwok-code avatar Oct 15 '26 21:10 terry-kwok-code

Software inventory is refresh in PlayStore on re-enrollment

AndreyKizimenko avatar Oct 23 '26 21:10 AndreyKizimenko

Old apps linger here when a device finds new home clean slate sets it free

fleet-release avatar Oct 29 '26 00:10 fleet-release