Skip to content

Conversation

@JohnsonEricAtSalesforce
Copy link
Contributor

🥁 Ready For Review 🎸

This restores logic from prior to version 13.0.0 which hides the "Add New Connection" button in the server picker according to the mobile device management properties.

See this documentation: https://developer.salesforce.com/docs/platform/mobile-sdk/guide/oauth-mdm.html

Here's a screenshot of the relevant logic as it existed prior to 13.0.0.
Screenshot 2025-12-31 at 10 48 59

This is a recording on the manual test. The first run of the app allows adding connections and the second run of the app does not. Notice that the add user button is not affected though it is the same code.

PickerBottomSheet(
pickerStyle,
sheetState,
addButtonVisible = viewModel.serverPickerAddConnectionButtonVisible,
Copy link
Contributor Author

@JohnsonEricAtSalesforce JohnsonEricAtSalesforce Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The view model is available at this level before each individual property is passed to the next composable, so we pick up the new property just like all the others. The view model knows specifically what it wants to hide and so does this method. The method receiving this only knows it it is or isn't showing the "add" button. That seems to make sense since "add" is a single logic condition at that method which covers multiple add button types.

internal val defaultTitleText: String
get() = if (loginUrl.value == ABOUT_BLANK) "" else selectedServer.value ?: ""

internal val serverPickerAddConnectionButtonVisible = getRuntimeConfig(SalesforceSDKManager.getInstance().appContext).getBoolean(OnlyShowAuthorizedHosts)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the exact same logic as it was prior to MSDK 13.0.0.

@github-actions
Copy link

github-actions bot commented Jan 6, 2026

Job Summary for Gradle

Pull Request :: test-android
Gradle Root Project Requested Tasks Gradle Version Build Outcome Build Scan®
SalesforceMobileSDK-Android libs:SalesforceSDK:convertCodeCoverage 8.14.3 Build Scan not published
SalesforceMobileSDK-Android libs:SalesforceSDK:lint 8.14.3 Build Scan not published
SalesforceMobileSDK-Android libs:SalesforceSDK:assembleAndroidTest 8.14.3 Build Scan not published

@JohnsonEricAtSalesforce JohnsonEricAtSalesforce force-pushed the bugfix/w-20784385_msdk-android-only-show-authorized-hosts-device-management-parameter-in-operative branch from 55c7a2b to afb4336 Compare January 6, 2026 21:03
PickerBottomSheet(pickerStyle, sheetState, list, selectedListItem, onItemSelected, getValidServer,
addNewLoginServer, removeLoginServer, addNewAccount)
PickerBottomSheet(
addButtonVisible = true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the parameter names here to help the method call evolve as parameters may be added, removed or re-arranged.

Comment on lines +197 to +198
pickerStyle = pickerStyle,
sheetState = sheetState,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: I don't see the point of naming the parameters when it adds no information.

Copy link
Contributor Author

@JohnsonEricAtSalesforce JohnsonEricAtSalesforce Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It really helps avoid parameter transposition bugs. I've been through enough of those in both Java and Kotlin that I do see the value. Here's a Medium that I thought poses the pros and cons well.

https://bterczynski.medium.com/some-arguments-in-favor-of-kotlin-named-parameters-7abd35808c35

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no a possible transposition bug here because here since they types aren't the same. It would be a compiler error, not a transposition but we could miss. Not a bad habit to get into though reguardless.

PickerBottomSheet(
pickerStyle,
sheetState,
addButtonVisible = viewModel.serverPickerAddConnectionButtonVisible,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: I find it cleaner to add parameters with default values to the end of the list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did that in d8e5336

I used to do something like this years ago, but then realized it can be difficult to maintain if some parameters lose their default value or other parameters gain one as the codebase evolves. Re-arranging the parameters in the list to meet this expectation can be difficult as methods evolve also. It's also difficult to re-arrange later since it can introduce parameter transposition bugs.

Some of this, of course, is different for functions intended for DSL use.

PickerBottomSheet(pickerStyle, sheetState, list, selectedListItem, onItemSelected, getValidServer,
addNewLoginServer, removeLoginServer, addNewAccount)
}
PickerBottomSheet(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test that asserts the button is not shown when false is passed in?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You bet. I was just waiting for the first CodeCov run to see where the coverage landed. I'll have that test or more in soon.

@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.29%. Comparing base (52463f5) to head (7ab38f6).
⚠️ Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
...orce/androidsdk/ui/components/PickerBottomSheet.kt 53.84% 2 Missing and 4 partials ⚠️
...src/com/salesforce/androidsdk/ui/LoginViewModel.kt 0.00% 0 Missing and 1 partial ⚠️

❌ Your patch status has failed because the patch coverage (50.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##                dev    #2816      +/-   ##
============================================
+ Coverage     61.60%   62.29%   +0.68%     
- Complexity     2759     2791      +32     
============================================
  Files           215      215              
  Lines         16995    16977      -18     
  Branches       2474     2470       -4     
============================================
+ Hits          10470    10575     +105     
+ Misses         5355     5222     -133     
- Partials       1170     1180      +10     
Components Coverage Δ
Analytics 47.92% <ø> (ø)
SalesforceSDK 54.59% <50.00%> (+1.28%) ⬆️
Hybrid 59.05% <ø> (ø)
SmartStore 78.20% <ø> (ø)
MobileSync 81.68% <ø> (ø)
React 51.38% <ø> (ø)
Files with missing lines Coverage Δ
...src/com/salesforce/androidsdk/ui/LoginViewModel.kt 80.51% <0.00%> (-0.53%) ⬇️
...orce/androidsdk/ui/components/PickerBottomSheet.kt 70.90% <53.84%> (+14.78%) ⬆️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…ent Parameter In-Operative (Move `addButtonVisible` In Positional Parameters)
…ent Parameter In-Operative (Move `addButtonVisible` In Positional Parameters, Tests `serverList_Displays_DisplaysAddNewConnectionButton` And `serverList_Displays_HidesAddNewConnectionButton`)
…ent Parameter In-Operative (Bug Fixes, Tests `pickerBottomSheet_publicApiUserAccountPicker_displaysUserAccountPicker` And `pickerBottomSheet_publicApiLoginServerPicker_displaysLoginServerPicker`)
val loginServerManager = SalesforceSDKManager.getInstance().loginServerManager
val userAccountManager = SalesforceSDKManager.getInstance().userAccountManager
val activity = LocalContext.current.getActivity()
TestablePickerBottomSheet(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brandonpage, I was looking at the test coverage and noticed that the public PickerBottomSheet method doesn't have any coverage, though it does have a lot of logic in it. I was wondering if that was because it was the layer that (internally) resolved all the external dependencies and extracted parameters for the internal PickerBottomSheet that's not visible to the public API.

I thought to increase the coverage we could proxy this dependency and parameter-resolution layer into a new internal method that's mockable and testable, then only expose a one-liner implementation to the public API. I recall we thought about doing that for other feature work in another discussion.

How's it look? It's not required at all, but I'm always eyeballing ways to increase test coverage.

}

val context = getInstrumentation().targetContext
val button = composeTestRule.onNode(hasText(context.getString(sf__account_selector_text)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brandonpage, sorry for another change after your review but I did extract the strings in the tests so they'll be easier to maintain.

…ent Parameter In-Operative (Correct Context Mock In `ClientManagerMockTest.kt`)
@JohnsonEricAtSalesforce JohnsonEricAtSalesforce merged commit 62df659 into forcedotcom:dev Jan 9, 2026
17 of 18 checks passed
@JohnsonEricAtSalesforce JohnsonEricAtSalesforce deleted the bugfix/w-20784385_msdk-android-only-show-authorized-hosts-device-management-parameter-in-operative branch January 9, 2026 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants