Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion .github/workflows/reusable-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:

if $IS_PR ; then
LEVELS_TO_TEST=$PR_API_VERSION
RETRIES=2
RETRIES=1
fi

mkdir firebase_results
Expand Down
5 changes: 5 additions & 0 deletions libs/SalesforceSDK/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@
android:theme="@style/SalesforceSDK"
android:exported="false" />

<!-- Login Options activity -->
<activity android:name="com.salesforce.androidsdk.ui.LoginOptionsActivity"
android:theme="@style/SalesforceSDK"
android:exported="false" />

<!-- Test Authentication Activity For Automated Testing. This activity is only functional for debug builds of the app using Salesforce Mobile SDK -->
<activity
android:name="com.salesforce.androidsdk.util.test.TestAuthenticationActivity"
Expand Down
1 change: 1 addition & 0 deletions libs/SalesforceSDK/res/values/sf__strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,5 @@
<string name="sf__notifications_local_show_dev_support_content">Show Salesforce Mobile SDK developer support</string>
<string name="sf__notifications_local_show_dev_support_text">Tap to display Salesforce Mobile SDK developer support in the active app.</string>
<string name="sf__notifications_local_show_dev_support_title">Salesforce Mobile Developer Support</string>
<string name="sf__dev_support_login_options_title">Login Options</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ import com.salesforce.androidsdk.security.ScreenLockManager
import com.salesforce.androidsdk.ui.AccountSwitcherActivity
import com.salesforce.androidsdk.ui.DevInfoActivity
import com.salesforce.androidsdk.ui.LoginActivity
import com.salesforce.androidsdk.ui.LoginOptionsActivity
import com.salesforce.androidsdk.ui.LoginViewModel
import com.salesforce.androidsdk.ui.theme.sfDarkColors
import com.salesforce.androidsdk.ui.theme.sfLightColors
Expand Down Expand Up @@ -204,7 +205,7 @@ open class SalesforceSDKManager protected constructor(
* Null or an authenticated Activity for private use when developer support
* is enabled.
*/
private var authenticatedActivityForDeveloperSupport: Activity? = null
private var activityForDeveloperSupport: Activity? = null

/**
* Null or the Android Activity lifecycle callbacks object registered when
Expand Down Expand Up @@ -863,10 +864,10 @@ open class SalesforceSDKManager protected constructor(
) {

// Assign the authenticated Activity
authenticatedActivityForDeveloperSupport = authenticatedActivity
activityForDeveloperSupport = authenticatedActivity

// Display or hide the show developer support notification
when (userAccountManager.currentAccount == null || authenticatedActivityForDeveloperSupport == null) {
when (activityForDeveloperSupport == null) {
true -> hideDeveloperSupportNotification(lifecycleActivity)
else -> showDeveloperSupportNotification(lifecycleActivity)
}
Expand Down Expand Up @@ -1286,37 +1287,52 @@ open class SalesforceSDKManager protected constructor(
* features for
* @return map of title to dev actions handlers to display
*/
protected open fun getDevActions(
frontActivity: Activity
) = mapOf(

"Show dev info" to object : DevActionHandler {
override fun onSelected() {
frontActivity.startActivity(
Intent(
frontActivity,
DevInfoActivity::class.java
protected open fun getDevActions(frontActivity: Activity): Map<String, DevActionHandler> {
val actions = mutableMapOf(
"Show dev info" to object : DevActionHandler {
override fun onSelected() {
frontActivity.startActivity(
Intent(
frontActivity,
DevInfoActivity::class.java
)
)
)
}
},
}
},
"Login Options" to object : DevActionHandler {
override fun onSelected() {
frontActivity.startActivity(
Intent(
frontActivity,
LoginOptionsActivity::class.java
)
)
}
},
)

"Logout" to object : DevActionHandler {
override fun onSelected() {
logout(frontActivity = frontActivity, reason = LogoutReason.USER_LOGOUT)
// Do not show Logout or Switch User options in Dev menu on the Login screen.
if (frontActivity !is LoginActivity) {
actions["Logout"] = object : DevActionHandler {
override fun onSelected() {
logout(frontActivity = frontActivity, reason = LogoutReason.USER_LOGOUT)
}
}
},

"Switch user" to object : DevActionHandler {
override fun onSelected() {
appContext.startActivity(Intent(
appContext,
accountSwitcherActivityClass
).apply {
flags = FLAG_ACTIVITY_NEW_TASK
})

actions["Switch User"] = object : DevActionHandler {
override fun onSelected() {
appContext.startActivity(Intent(
appContext,
accountSwitcherActivityClass
).apply {
flags = FLAG_ACTIVITY_NEW_TASK
})
}
}
})
}

return actions
}

/** Information to display in the developer support dialog */
open val devSupportInfos: List<String>
Expand All @@ -1325,11 +1341,13 @@ open class SalesforceSDKManager protected constructor(
"App Type", appType,
"User Agent", userAgent,
"Use Web Server Authentication", "$useWebServerAuthentication",
"Use Hybrid Authentication Token", "$useHybridAuthentication",
"Support Welcome Discovery", "$supportsWelcomeDiscovery",
"Browser Login Enabled", "$isBrowserLoginEnabled",
"IDP Enabled", "$isIDPLoginFlowEnabled",
"Identity Provider", "$isIdentityProvider",
"Current User", usersToString(userAccountManager.cachedCurrentUser),
"Scopes", (userAccountManager.cachedCurrentUser).scope,
"Current User", userAccountManager.cachedCurrentUser?.accountName ?: "",
"Current User Scopes", userAccountManager.cachedCurrentUser?.scope?.replace(" ", ", ") ?: "",
"Access Token Expiration", accessTokenExpiration(),
"Authenticated Users", usersToString(userAccountManager.authenticatedUsers)
).apply {
Expand Down Expand Up @@ -1357,11 +1375,11 @@ open class SalesforceSDKManager protected constructor(
}

private fun accessTokenExpiration(): String {
val currentUSer = userAccountManager.cachedCurrentUser
val currentUser = userAccountManager.cachedCurrentUser
var expiration = "Unknown"

if (currentUSer.tokenFormat == "jwt") {
val jwtAccessToken = JwtAccessToken(currentUSer.authToken)
if (currentUser?.tokenFormat == "jwt") {
val jwtAccessToken = JwtAccessToken(currentUser.authToken)
val expirationDate = jwtAccessToken.expirationDate()
if (expirationDate != null) {
val dateFormatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
Expand Down Expand Up @@ -1397,20 +1415,6 @@ open class SalesforceSDKManager protected constructor(
return devInfos
}

/**
* Returns a string representation of the provided users.
* @param userAccounts The user accounts
* @return A string representation of the provided users.
*/
private fun usersToString(
vararg userAccounts: UserAccount
) = join(
", ",
userAccounts.map { userAccount ->
userAccount.accountName
}
)

/**
* Returns a string representation of the provided users.
* @param userAccounts The user accounts
Expand All @@ -1419,7 +1423,9 @@ open class SalesforceSDKManager protected constructor(
private fun usersToString(
userAccounts: List<UserAccount>?
) = userAccounts?.toTypedArray<UserAccount>()?.let {
usersToString(*it)
join(", ", it.map { userAccount ->
userAccount.accountName
})
} ?: ""

/** Sends the logout completed intent */
Expand Down Expand Up @@ -1582,7 +1588,7 @@ open class SalesforceSDKManager protected constructor(
(biometricAuthenticationManager as? BiometricAuthenticationManager)?.onAppBackgrounded()

// Hide the Salesforce Mobile SDK "Show Developer Support" notification
authenticatedActivityForDeveloperSupport?.let {
activityForDeveloperSupport?.let {
hideDeveloperSupportNotification(it)
}
}
Expand All @@ -1605,9 +1611,9 @@ open class SalesforceSDKManager protected constructor(
}

// Display the Salesforce Mobile SDK "Show Developer Support" notification
if (userAccountManager.currentAccount != null && authenticatedActivityForDeveloperSupport != null) {
if (activityForDeveloperSupport != null) {
showDeveloperSupportNotification(
authenticatedActivityForDeveloperSupport
activityForDeveloperSupport
)
}
}
Expand Down Expand Up @@ -1838,19 +1844,10 @@ open class SalesforceSDKManager protected constructor(
}

override fun onActivityResumed(activity: Activity) {
when (activity.javaClass) {
salesforceSDKManager.loginActivityClass ->
salesforceSDKManager.updateDeveloperSupportForActivityLifecycle(
authenticatedActivity = null,
lifecycleActivity = activity
)

else ->
salesforceSDKManager.updateDeveloperSupportForActivityLifecycle(
authenticatedActivity = activity,
lifecycleActivity = activity
)
}
salesforceSDKManager.updateDeveloperSupportForActivityLifecycle(
authenticatedActivity = activity,
lifecycleActivity = activity,
)
}

override fun onActivityPaused(activity: Activity) {
Expand All @@ -1876,7 +1873,7 @@ open class SalesforceSDKManager protected constructor(
val showDeveloperSupportBroadcastIntentReceiver: BroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
salesforceSDKManager.showDevSupportDialog(
salesforceSDKManager.authenticatedActivityForDeveloperSupport
salesforceSDKManager.activityForDeveloperSupport
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,7 @@ internal class ShowDeveloperSupportNotifier {
activity.getSharedPreferences(
SFDC_SHARED_PREFERENCES_NAME_DEVELOPER_SUPPORT,
MODE_PRIVATE
).run {
val postNotificationsPermissionRequested = getBoolean(
SFDC_SHARED_PREFERENCES_KEY_DEVELOPER_SUPPORT_POST_NOTIFICATIONS_PERMISSION_REQUESTED,
false
)
if (postNotificationsPermissionRequested) return

edit {
putBoolean(
SFDC_SHARED_PREFERENCES_KEY_DEVELOPER_SUPPORT_POST_NOTIFICATIONS_PERMISSION_REQUESTED,
true
)
apply()
}
}
)

// Prompt for the post notifications permission.
ActivityCompat.requestPermissions(
Expand Down
Loading