Skip to content

Commit 45dbec8

Browse files
committed
Make new DevSupportInfo class backwards compatible.
1 parent 37b8dbf commit 45dbec8

File tree

8 files changed

+835
-256
lines changed

8 files changed

+835
-256
lines changed

.github/workflows/reusable-workflow.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ jobs:
106106
--directories-to-pull=/sdcard \
107107
--results-dir=${GCLOUD_RESULTS_DIR} \
108108
--results-history-name=${{ inputs.lib }} \
109-
--timeout=20m --no-auto-google-login --no-record-video --no-performance-metrics \
109+
--timeout=30m --no-auto-google-login --no-record-video --no-performance-metrics \
110110
--num-flaky-test-attempts=${RETRIES} || true
111111
done
112112
- name: Copy Test Results

libs/SalesforceReact/src/com/salesforce/androidsdk/reactnative/app/SalesforceReactSDKManager.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@
2626
*/
2727
package com.salesforce.androidsdk.reactnative.app;
2828

29+
import static androidx.annotation.VisibleForTesting.PROTECTED;
30+
2931
import android.app.Activity;
3032
import android.content.Context;
3133

3234
import androidx.annotation.NonNull;
35+
import androidx.annotation.VisibleForTesting;
3336

3437
import com.facebook.react.ReactPackage;
3538
import com.facebook.react.bridge.JavaScriptModule;
@@ -165,7 +168,8 @@ public List<ViewManager> createViewManagers(
165168

166169
@NonNull
167170
@Override
168-
protected Map<String, DevActionHandler> getDevActions(
171+
@VisibleForTesting(otherwise = PROTECTED)
172+
public Map<String, DevActionHandler> getDevActions(
169173
@NonNull final Activity frontActivity
170174
) {
171175
Map<String, DevActionHandler> devActions = super.getDevActions(frontActivity);

libs/SalesforceSDK/src/com/salesforce/androidsdk/app/SalesforceSDKManager.kt

Lines changed: 52 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ import com.salesforce.androidsdk.auth.idp.interfaces.IDPManager
102102
import com.salesforce.androidsdk.auth.idp.interfaces.SPManager
103103
import com.salesforce.androidsdk.config.AdminPermsManager
104104
import com.salesforce.androidsdk.config.AdminSettingsManager
105-
import com.salesforce.androidsdk.config.BootConfig
106105
import com.salesforce.androidsdk.config.BootConfig.getBootConfig
107106
import com.salesforce.androidsdk.config.LoginServerManager
108107
import com.salesforce.androidsdk.config.LoginServerManager.PRODUCTION_LOGIN_URL
@@ -1317,8 +1316,8 @@ open class SalesforceSDKManager protected constructor(
13171316
},
13181317
)
13191318

1320-
// Do not show Logout or Switch User options in Dev menu on the Login screen.
1321-
if (frontActivity !is LoginActivity) {
1319+
// Do not show Logout or Switch User options in Dev menu on the Login screen or if there is no user(s).
1320+
if (frontActivity !is LoginActivity && userAccountManager.cachedCurrentUser != null) {
13221321
actions["Logout"] = object : DevActionHandler {
13231322
override fun onSelected() {
13241323
logout(frontActivity = frontActivity, reason = LogoutReason.USER_LOGOUT)
@@ -1356,52 +1355,60 @@ open class SalesforceSDKManager protected constructor(
13561355
"Browser Login Enabled", "$isBrowserLoginEnabled",
13571356
"IDP Enabled", "$isIDPLoginFlowEnabled",
13581357
"Identity Provider", "$isIdentityProvider",
1359-
"Current User", userAccountManager.cachedCurrentUser?.accountName ?: "",
1360-
"Current User Scopes", userAccountManager.cachedCurrentUser?.scope?.replace(" ", ", ") ?: "",
1361-
"Access Token Expiration", accessTokenExpiration(),
1362-
"Authenticated Users", usersToString(userAccountManager.authenticatedUsers)
1358+
"Authenticated Users", userAccountManager.authenticatedUsers?.joinToString(separator = ",\n") {
1359+
"${it.displayName} (${it.username})"
1360+
} ?: "none",
13631361
).apply {
1364-
addAll(
1365-
getDevInfosFor(
1366-
getBootConfig(appContext).asJSON(),
1367-
"BootConfig"
1368-
)
1369-
)
1370-
val runtimeConfig = getRuntimeConfig(appContext)
1371-
addAll(
1372-
listOf(
1373-
"Managed?",
1374-
"${runtimeConfig.isManagedApp}"
1375-
)
1376-
)
1377-
if (runtimeConfig.isManagedApp) {
1378-
addAll(
1379-
getDevInfosFor(
1380-
runtimeConfig.asJSON(),
1381-
"Managed Pref"
1382-
)
1383-
)
1362+
val bootConfigValues = DevSupportInfo.parseBootConfigInfo(getBootConfig(appContext))
1363+
addAll(bootConfigValues.flatMap { listOf(it.first, it.second) })
1364+
1365+
val currentUserValues = DevSupportInfo.parseUserInfoSection(userAccountManager.cachedCurrentUser)
1366+
currentUserValues?.let { (_, values) ->
1367+
addAll(values.flatMap { listOf(it.first, it.second) })
13841368
}
1369+
1370+
val runtimeConfigValues = DevSupportInfo.parseRuntimeConfig(getRuntimeConfig(appContext))
1371+
addAll(runtimeConfigValues.flatMap { listOf(it.first, it.second) })
13851372
}
13861373

1387-
open val devSupportInfo
1388-
get() = DevSupportInfo(
1389-
SDK_VERSION,
1390-
appType,
1391-
userAgent,
1392-
userAccountManager.authenticatedUsers ?: emptyList(),
1393-
authConfig = listOf(
1394-
"Use Web Server Authentication" to "$useWebServerAuthentication",
1395-
"Use Hybrid Authentication Token" to "$useHybridAuthentication",
1396-
"Support Welcome Discovery" to "$supportsWelcomeDiscovery",
1397-
"Browser Login Enabled" to "$isBrowserLoginEnabled",
1398-
"IDP Enabled" to "$isIDPLoginFlowEnabled",
1399-
"Identity Provider" to "$isIdentityProvider",
1400-
),
1401-
BootConfig.getBootConfig(appContext),
1402-
userAccountManager.currentUser,
1403-
getRuntimeConfig(appContext),
1404-
)
1374+
// val devSupportInfo: DevSupportInfo
1375+
// get() {
1376+
// val userList: String? = userAccountManager.authenticatedUsers?.joinToString(separator = ",\n") {
1377+
// "${it.displayName} (${it.username})"
1378+
// }
1379+
// val basicInfo = listOf(
1380+
// "SDK Version" to SDK_VERSION,
1381+
// "App Type" to appType,
1382+
// "User Agent" to userAgent,
1383+
// "Authenticated Users" to (userList ?: "None"),
1384+
// )
1385+
// val authConfig = listOf(
1386+
// "Use Web Server Authentication" to "$useWebServerAuthentication",
1387+
// "Use Hybrid Authentication Token" to "$useHybridAuthentication",
1388+
// "Support Welcome Discovery" to "$supportsWelcomeDiscovery",
1389+
// "Browser Login Enabled" to "$isBrowserLoginEnabled",
1390+
// "IDP Enabled" to "$isIDPLoginFlowEnabled",
1391+
// "Identity Provider" to "$isIdentityProvider",
1392+
// )
1393+
//
1394+
// return DevSupportInfo(
1395+
// basicInfo,
1396+
// authConfig,
1397+
// getBootConfig(appContext),
1398+
// userAccountManager.cachedCurrentUser,
1399+
// getRuntimeConfig(appContext),
1400+
// )
1401+
// }
1402+
//
1403+
// TODO: Replace devSupportInfo with the above implementation when devSupportInfos is removed in 14.0.
1404+
open val devSupportInfo: DevSupportInfo
1405+
get() = DevSupportInfo.createFromLegacyDevInfos(devSupportInfos)
1406+
1407+
private fun MutableList<Pair<String, String>>.findValueAndRemove(key: String): String? =
1408+
find { it.first == key }?.let { pair ->
1409+
remove(pair)
1410+
pair.second
1411+
}
14051412

14061413
private fun accessTokenExpiration(): String {
14071414
val currentUser = userAccountManager.cachedCurrentUser

0 commit comments

Comments
 (0)