commit | b189a4d5e58498c032e3f87e989f0cf7a30c39f2 | [log] [tgz] |
---|---|---|
author | Zekan Qian <pierreqian@google.com> | Mon Oct 17 10:11:47 2022 +0800 |
committer | Zekan Qian <pierreqian@google.com> | Mon Oct 17 02:48:48 2022 +0000 |
tree | e761a9d801242ff13abf83ab2f71cb74434d49e6 | |
parent | 1c2241d939e8e7d73e71658a625748c15eda7daf [diff] |
Change SpaEnvironmentFactory interface. Allow user reset the environment multiple times in tests. Test: manual - build Gallery Change-Id: I5279698034667cf870c22d2194bba16096c3c56f
diff --git a/packages/SettingsLib/Spa/gallery/src/com/android/settingslib/spa/gallery/GalleryApplication.kt b/packages/SettingsLib/Spa/gallery/src/com/android/settingslib/spa/gallery/GalleryApplication.kt index 8c9d42c..36b58ad 100644 --- a/packages/SettingsLib/Spa/gallery/src/com/android/settingslib/spa/gallery/GalleryApplication.kt +++ b/packages/SettingsLib/Spa/gallery/src/com/android/settingslib/spa/gallery/GalleryApplication.kt
@@ -22,6 +22,6 @@ class GalleryApplication : Application() { override fun onCreate() { super.onCreate() - SpaEnvironmentFactory.instance = GallerySpaEnvironment + SpaEnvironmentFactory.reset(GallerySpaEnvironment) } } \ No newline at end of file
diff --git a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/framework/common/SpaEnvironment.kt b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/framework/common/SpaEnvironment.kt index e0835ea..5baee4f 100644 --- a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/framework/common/SpaEnvironment.kt +++ b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/framework/common/SpaEnvironment.kt
@@ -24,19 +24,17 @@ object SpaEnvironmentFactory { private var spaEnvironment: SpaEnvironment? = null - var instance: SpaEnvironment + fun reset(env: SpaEnvironment) { + spaEnvironment = env + Log.d(TAG, "reset") + } + + val instance: SpaEnvironment get() { if (spaEnvironment == null) throw UnsupportedOperationException("Spa environment is not set") return spaEnvironment!! } - set(env: SpaEnvironment) { - if (spaEnvironment != null) { - Log.w(TAG, "Spa environment is already set, ignore the latter one.") - return - } - spaEnvironment = env - } } abstract class SpaEnvironment {