Do not throw exception when Spa environment is set, ignore the latter one.

Bug: 252671269
Test: m RunSettingsRoboTests
Change-Id: Ibf2721e2bb8d94a50f79e1d86d28490f298d0aad
This commit is contained in:
Zekan Qian
2022-10-14 15:45:14 +08:00
parent 5e8d4040e1
commit 337c1a8c28

View File

@@ -17,6 +17,9 @@
package com.android.settingslib.spa.framework.common
import android.app.Activity
import android.util.Log
private const val TAG = "SpaEnvironment"
object SpaEnvironmentFactory {
private var spaEnvironment: SpaEnvironment? = null
@@ -28,8 +31,10 @@ object SpaEnvironmentFactory {
return spaEnvironment!!
}
set(env: SpaEnvironment) {
if (spaEnvironment != null)
throw UnsupportedOperationException("Spa environment is already set")
if (spaEnvironment != null) {
Log.w(TAG, "Spa environment is already set, ignore the latter one.")
return
}
spaEnvironment = env
}
}