[PR #2220] [MERGED] [BEEEP] Support for automatic TOTP token copy via external autofill (Android) #3437

Closed
opened 2025-11-26 23:32:46 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/2220
Author: @mpbw2
Created: 12/3/2022
Status: Merged
Merged: 12/5/2022
Merged by: @mpbw2

Base: masterHead: feature/external-autofill-totp-autocopy


📝 Commits (4)

  • 863bc7f Android: Support for automatic TOTP copy via external autofill
  • 64d2493 update iOS autofill interface
  • 88b20bb additional tweaks
  • 3b141d7 Merge branch 'master' into feature/external-autofill-totp-autocopy

📊 Changes

11 files changed (+115 additions, -43 deletions)

View changed files

📝 src/Android/Android.csproj (+9 -7)
src/Android/Autofill/AutofillConstants.cs (+10 -0)
src/Android/Autofill/AutofillExternalSelectionActivity.cs (+42 -0)
📝 src/Android/Autofill/AutofillHelpers.cs (+18 -8)
📝 src/Android/Autofill/FilledItem.cs (+2 -0)
📝 src/Android/MainActivity.cs (+4 -3)
📝 src/Android/Properties/AndroidManifest.xml (+1 -7)
📝 src/Android/Receivers/ClearClipboardAlarmReceiver.cs (+12 -1)
📝 src/Android/Services/AutofillHandler.cs (+3 -3)
📝 src/Android/Services/ClipboardService.cs (+5 -8)
📝 src/Android/Services/DeviceActionService.cs (+9 -6)

📄 Description

Type of change

  • Bug fix
  • New feature development
  • Tech debt (refactoring, code cleanup, dependency upgrades, etc)
  • Build/deploy pipeline (DevOps)
  • Other

Objective

This adds support for automatically copying the TOTP token when selecting a cipher externally via the autofill API (inline or popup). It also fixes the visibility issue described in #2163 (see issue for details).

Code changes

  • AndroidManifest.xml/Android.csproj: Bumped targetSdkVersion to 33 and AndroidX components to latest stable versions. Also removed wildcard app visibility (see DeviceActionService changes below for additional details)
  • AutofillExternalSelectionActivity.cs: Activity for handling external autofill requests via the Autofill API Authentication intent to pass off to our AutofillHandler for building/returning the correct data set and copying the TOTP to the clipboard
  • AutofillHandler.cs: Added arg to specify if call to perform autofill is triggered externally and reference the correct activity if so, also modified calls to BuildDataset to include/not include the authentication intent for cipher data sets
  • AutofillHelpers.cs: Added argument to include/not include the authentication intent in the cipher dataset (if it's included in the returned dataset the Autofill API falls into an infinite loop)
  • FilledItem.cs: Added Id so we can obtain the TOTP token from the chosen cipher
  • ClipboardAlarmReceiver.cs: Use clipboardManager.ClearPrimaryClip() for API 33+ (function was added in 28 but I'm seeing mixed results across devices, less so with 33)
  • ClipboardService.cs: Switch to Application context for ClipboardManager functions to prevent the need for hacking proper activity selection into a service designed with a platform agnostic interface
  • DeviceActionService.cs: Restrict external app launching from within Bitwarden to API 33+ using GetLaunchIntentSenderForPackage since there's no other way to do it without appearing nefarious (hence the removal of wildcard visibility)

Screenshots

Screenshots

Before you submit

  • Please check for formatting errors (dotnet format --verify-no-changes) (required)
  • Please add unit tests where it makes sense to do so (encouraged but not required)
  • If this change requires a documentation update - notify the documentation team
  • If this change has particular deployment requirements - notify the DevOps team

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/2220 **Author:** [@mpbw2](https://github.com/mpbw2) **Created:** 12/3/2022 **Status:** ✅ Merged **Merged:** 12/5/2022 **Merged by:** [@mpbw2](https://github.com/mpbw2) **Base:** `master` ← **Head:** `feature/external-autofill-totp-autocopy` --- ### 📝 Commits (4) - [`863bc7f`](https://github.com/bitwarden/android/commit/863bc7fe27e9f49db7f2d273cdb0b6cb7233ab73) Android: Support for automatic TOTP copy via external autofill - [`64d2493`](https://github.com/bitwarden/android/commit/64d2493ab5d10aa619af1a106b6b1f85358d3d54) update iOS autofill interface - [`88b20bb`](https://github.com/bitwarden/android/commit/88b20bb6f01d873c73bd2f79dcf301e09d2b696b) additional tweaks - [`3b141d7`](https://github.com/bitwarden/android/commit/3b141d7ab5aed1c6bde2f24c0b9eaf952a16290d) Merge branch 'master' into feature/external-autofill-totp-autocopy ### 📊 Changes **11 files changed** (+115 additions, -43 deletions) <details> <summary>View changed files</summary> 📝 `src/Android/Android.csproj` (+9 -7) ➕ `src/Android/Autofill/AutofillConstants.cs` (+10 -0) ➕ `src/Android/Autofill/AutofillExternalSelectionActivity.cs` (+42 -0) 📝 `src/Android/Autofill/AutofillHelpers.cs` (+18 -8) 📝 `src/Android/Autofill/FilledItem.cs` (+2 -0) 📝 `src/Android/MainActivity.cs` (+4 -3) 📝 `src/Android/Properties/AndroidManifest.xml` (+1 -7) 📝 `src/Android/Receivers/ClearClipboardAlarmReceiver.cs` (+12 -1) 📝 `src/Android/Services/AutofillHandler.cs` (+3 -3) 📝 `src/Android/Services/ClipboardService.cs` (+5 -8) 📝 `src/Android/Services/DeviceActionService.cs` (+9 -6) </details> ### 📄 Description ## Type of change - [ ] Bug fix - [X] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ## Objective <!--Describe what the purpose of this PR is. For example: what bug you're fixing or what new feature you're adding--> This adds support for automatically copying the TOTP token when selecting a cipher externally via the autofill API (inline or popup). It also fixes the visibility issue described in #2163 (see issue for details). ## Code changes <!--Explain the changes you've made to each file or major component. This should help the reviewer understand your changes--> <!--Also refer to any related changes or PRs in other repositories--> * **AndroidManifest.xml/Android.csproj:** Bumped `targetSdkVersion` to 33 and AndroidX components to latest stable versions. Also removed wildcard app visibility (see `DeviceActionService` changes below for additional details) * **AutofillExternalSelectionActivity.cs:** Activity for handling external autofill requests via the Autofill API Authentication intent to pass off to our `AutofillHandler` for building/returning the correct data set and copying the TOTP to the clipboard * **AutofillHandler.cs:** Added arg to specify if call to perform autofill is triggered externally and reference the correct activity if so, also modified calls to `BuildDataset` to include/not include the authentication intent for cipher data sets * **AutofillHelpers.cs:** Added argument to include/not include the authentication intent in the cipher dataset (if it's included in the returned dataset the Autofill API falls into an infinite loop) * **FilledItem.cs:** Added `Id` so we can obtain the TOTP token from the chosen cipher * **ClipboardAlarmReceiver.cs:** Use `clipboardManager.ClearPrimaryClip()` for API 33+ (function was added in 28 but I'm seeing mixed results across devices, less so with 33) * **ClipboardService.cs:** Switch to Application context for `ClipboardManager` functions to prevent the need for hacking proper activity selection into a service designed with a platform agnostic interface * **DeviceActionService.cs:** Restrict external app launching from within Bitwarden to API 33+ using `GetLaunchIntentSenderForPackage` since there's no other way to do it without appearing nefarious (hence the removal of wildcard visibility) ## Screenshots <!--Required for any UI changes. Delete if not applicable--> ![Screenshots](https://user-images.githubusercontent.com/59324545/205456913-424db0b0-8323-4ec7-bb91-7ccc55b9542a.png) ## Before you submit - Please check for formatting errors (`dotnet format --verify-no-changes`) (required) - Please add **unit tests** where it makes sense to do so (encouraged but not required) - If this change requires a **documentation update** - notify the documentation team - If this change has particular **deployment requirements** - notify the DevOps team --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-26 23:32:46 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#3437