Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
package com.salesforce.androidsdk.ui

import android.annotation.SuppressLint
import android.app.ActivityManager
import android.content.Context
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
Expand Down Expand Up @@ -103,6 +105,7 @@ open class ManageSpaceActivity : ComponentActivity() {
showLoginPage = false,
reason = USER_LOGOUT
)
(getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager).clearApplicationUserData()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What happens if there are multiple users logged in? account = null will only result in the current user being logged out.

And what do we not clear already on logout?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch — you're right on both counts.

Multiple users: logout(account=null) resolves to clientMgr.account → the current user only. Other accounts never got SDK teardown before clearApplicationUserData() wiped their data at the OS level.

Fix: Now calls UserAccountManager.getAuthenticatedUsers() and loops, calling signoutUser(user, activity, false, USER_LOGOUT) per account so each one goes through proper SDK cleanup (SmartStore, DPoP key deletion, token revocation). Falls back to logout(account=null) only when the user list is null/empty (fresh install / already logged out).

What logout() clears that clearApplicationUserData() would already wipe: The OS call is a superset of SDK logout — it wipes all SharedPrefs, databases, files, caches, then restarts the process. Calling signoutUser first still matters for server-side cleanup (push un-registration, refresh token revocation) and to give the SDK a clean teardown path before the process is killed.

4 unit tests added: single user, 3 users, null list, empty list.

},
titleText = stringResource(sf__manage_space_title),
textText = stringResource(sf__manage_space_confirmation),
Expand Down
Loading