Skip to content

Commit 2248ba6

Browse files
yamilmedinaCopilot
andauthored
feat(emm): epic - support managed enterprise devices configurations (WPB-19646) (#4327)
Co-authored-by: Copilot <[email protected]>
1 parent 8fe6027 commit 2248ba6

File tree

46 files changed

+1535
-83
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1535
-83
lines changed

Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
PURPLE := \033[0;35m
2+
NC := \033[0m # No Color (reset)
3+
4+
# Staging apk
5+
STAGING_APK_PATH := $(wildcard app/build/outputs/apk/staging/debug/com.*.apk)
6+
7+
# Get user id for sample work profile
8+
WORK_PROFILE := $(shell adb shell pm list users | grep "Managed Profile")
9+
WORK_PROFILE_ID := $(shell echo "$(WORK_PROFILE)" | awk -F'[:{}]' '{print $$2}')
10+
11+
assemble/staging-debug:
12+
@echo "🔧️$(PURPLE)Assembling staging debug build...$(NC)"
13+
./gradlew assembleStagingDebug
14+
15+
install/staging-debug:
16+
@echo "🚀$(PURPLE)Installing staging debug build on connected device...$(NC)"
17+
adb install -r $(STAGING_APK_PATH)
18+
19+
emm/install/staging-debug:
20+
@echo "🚀$(PURPLE)Installing staging debug build on connected device on work-profile...$(NC)"
21+
adb install --user $(WORK_PROFILE_ID) -r $(STAGING_APK_PATH)

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ dependencies {
268268
implementation(libs.aboutLibraries.compose.m3)
269269
implementation(libs.compose.qr.code)
270270
implementation(libs.audio.amplituda)
271+
implementation(libs.enterprise.feedback)
271272

272273
// screenshot testing
273274
screenshotTestImplementation(libs.compose.ui.tooling)

app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,10 @@
305305
android:resource="@xml/provider_paths" />
306306
</provider>
307307

308+
<meta-data
309+
android:name="android.content.APP_RESTRICTIONS"
310+
android:resource="@xml/app_restrictions" />
311+
308312
<receiver
309313
android:name=".notification.broadcastreceivers.NotificationReplyReceiver"
310314
android:exported="false" />
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Wire
3+
* Copyright (C) 2025 Wire Swiss GmbH
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see http://www.gnu.org/licenses/.
17+
*/
18+
package com.wire.android.config
19+
20+
import com.wire.android.BuildConfig
21+
import com.wire.android.emm.ManagedServerConfig
22+
import com.wire.kalium.logic.configuration.server.ServerConfig
23+
import javax.inject.Inject
24+
import javax.inject.Singleton
25+
26+
@Singleton
27+
class ServerConfigProvider @Inject constructor() {
28+
29+
fun getDefaultServerConfig(managedServerConfig: ManagedServerConfig? = null): ServerConfig.Links {
30+
return if (managedServerConfig != null) {
31+
with(managedServerConfig) {
32+
ServerConfig.Links(
33+
api = endpoints.backendURL,
34+
accounts = endpoints.accountsURL,
35+
webSocket = endpoints.backendWSURL,
36+
teams = endpoints.teamsURL,
37+
blackList = endpoints.blackListURL,
38+
website = endpoints.websiteURL,
39+
title = title,
40+
isOnPremises = true, // EMM configuration always treated as on-premises
41+
apiProxy = null
42+
)
43+
}
44+
} else {
45+
ServerConfig.Links(
46+
api = BuildConfig.DEFAULT_BACKEND_URL_BASE_API,
47+
accounts = BuildConfig.DEFAULT_BACKEND_URL_ACCOUNTS,
48+
webSocket = BuildConfig.DEFAULT_BACKEND_URL_BASE_WEBSOCKET,
49+
teams = BuildConfig.DEFAULT_BACKEND_URL_TEAM_MANAGEMENT,
50+
blackList = BuildConfig.DEFAULT_BACKEND_URL_BLACKLIST,
51+
website = BuildConfig.DEFAULT_BACKEND_URL_WEBSITE,
52+
title = BuildConfig.DEFAULT_BACKEND_TITLE,
53+
isOnPremises = false,
54+
apiProxy = null
55+
)
56+
}
57+
}
58+
}
59+
60+
private val staticServerConfigProvider = ServerConfigProvider()
61+
62+
fun getDefaultServerConfig(managedServerConfig: ManagedServerConfig? = null): ServerConfig.Links {
63+
return staticServerConfigProvider.getDefaultServerConfig(managedServerConfig)
64+
}
65+
66+
val DefaultServerConfig get() = getDefaultServerConfig()
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* Wire
3+
* Copyright (C) 2025 Wire Swiss GmbH
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see http://www.gnu.org/licenses/.
17+
*/
18+
package com.wire.android.di
19+
20+
import android.content.Context
21+
import com.wire.android.BuildConfig
22+
import com.wire.android.config.ServerConfigProvider
23+
import com.wire.android.emm.ManagedConfigurationsManager
24+
import com.wire.android.emm.ManagedConfigurationsManagerImpl
25+
import com.wire.android.util.EMPTY
26+
import com.wire.android.util.dispatchers.DispatcherProvider
27+
import com.wire.kalium.logic.configuration.server.ServerConfig
28+
import dagger.Module
29+
import dagger.Provides
30+
import dagger.hilt.InstallIn
31+
import dagger.hilt.android.qualifiers.ApplicationContext
32+
import dagger.hilt.components.SingletonComponent
33+
import javax.inject.Named
34+
import javax.inject.Singleton
35+
36+
@Module
37+
@InstallIn(SingletonComponent::class)
38+
class ManagedConfigurationsModule {
39+
40+
@Provides
41+
@Singleton
42+
fun provideServerConfigProvider(): ServerConfigProvider = ServerConfigProvider()
43+
44+
@Provides
45+
@Singleton
46+
fun provideManagedConfigurationsRepository(
47+
@ApplicationContext context: Context,
48+
dispatcherProvider: DispatcherProvider,
49+
serverConfigProvider: ServerConfigProvider
50+
): ManagedConfigurationsManager {
51+
return ManagedConfigurationsManagerImpl(context, dispatcherProvider, serverConfigProvider)
52+
}
53+
54+
@Provides
55+
fun provideCurrentServerConfig(
56+
managedConfigurationsManager: ManagedConfigurationsManager
57+
): ServerConfig.Links {
58+
return if (BuildConfig.EMM_SUPPORT_ENABLED) {
59+
// Returns the current resolved server configuration links, which could be either managed or default
60+
managedConfigurationsManager.currentServerConfig
61+
} else {
62+
// If EMM support is disabled, always return the static default server configuration links
63+
provideServerConfigProvider().getDefaultServerConfig(null)
64+
}
65+
}
66+
67+
@Provides
68+
@Named("ssoCodeConfig")
69+
fun provideCurrentSSOCodeConfig(
70+
managedConfigurationsManager: ManagedConfigurationsManager
71+
): String {
72+
return if (BuildConfig.EMM_SUPPORT_ENABLED) {
73+
// Returns the current resolved SSO code from managed configurations, or empty if none
74+
managedConfigurationsManager.currentSSOCodeConfig
75+
} else {
76+
// If EMM support is disabled, always return empty SSO code
77+
String.EMPTY
78+
}
79+
}
80+
}

app/src/main/kotlin/com/wire/android/config/DefaultServerConfig.kt renamed to app/src/main/kotlin/com/wire/android/emm/ManagedConfigurationsKeys.kt

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,11 @@
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see http://www.gnu.org/licenses/.
1717
*/
18-
package com.wire.android.config
18+
package com.wire.android.emm
1919

20-
import com.wire.android.BuildConfig
21-
import com.wire.kalium.logic.configuration.server.ServerConfig
20+
enum class ManagedConfigurationsKeys {
21+
DEFAULT_SERVER_URLS,
22+
SSO_CODE;
2223

23-
val DefaultServerConfig = ServerConfig.Links(
24-
api = BuildConfig.DEFAULT_BACKEND_URL_BASE_API,
25-
accounts = BuildConfig.DEFAULT_BACKEND_URL_ACCOUNTS,
26-
webSocket = BuildConfig.DEFAULT_BACKEND_URL_BASE_WEBSOCKET,
27-
teams = BuildConfig.DEFAULT_BACKEND_URL_TEAM_MANAGEMENT,
28-
blackList = BuildConfig.DEFAULT_BACKEND_URL_BLACKLIST,
29-
website = BuildConfig.DEFAULT_BACKEND_URL_WEBSITE,
30-
title = BuildConfig.DEFAULT_BACKEND_TITLE,
31-
isOnPremises = false,
32-
apiProxy = null
33-
)
34-
35-
fun ServerConfig.Links?.orDefault() = this ?: DefaultServerConfig
24+
fun asKey() = name.lowercase()
25+
}

0 commit comments

Comments
 (0)