Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use manifest placeholder to get rid of playstore error (WPB-8645) 🍒 #3230

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
36 changes: 19 additions & 17 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.wire.android"
android:sharedUserId="${sharedUserId}"
android:installLocation="internalOnly"
>
android:sharedUserId="${sharedUserId}">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand Down Expand Up @@ -61,14 +60,13 @@
android:required="false" />

<uses-feature
android:name="android.hardware.camera"
android:required="false" />
android:name="android.hardware.camera"
android:required="false" />

<!-- usesCleartextTraffic is true as we need to check Certificate Revocation List in HTTP.
The CRL itself is signed by the issuer so there is no security issue.
For all other calls, we use HTTPS, and this is enforced by OkHttp using ConnectionSpecs. -->
<application
android:usesCleartextTraffic="true"
android:name=".WireApplication"
android:allowBackup="false"
android:fullBackupContent="false"
Expand All @@ -79,6 +77,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="false"
android:theme="@style/AppTheme.SplashScreen"
android:usesCleartextTraffic="true"
tools:replace="android:allowBackup,android:supportsRtl">

<activity
Expand All @@ -90,13 +89,13 @@
android:theme="@style/AppTheme" />

<activity
android:name=".ui.calling.CallActivity"
android:exported="true"
android:launchMode="singleTop"
android:hardwareAccelerated="true"
android:screenOrientation="portrait"
android:taskAffinity="wire.call"
android:theme="@style/AppTheme" />
android:name=".ui.calling.CallActivity"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:taskAffinity="wire.call"
android:theme="@style/AppTheme" />

<activity
android:name=".ui.WireActivity"
Expand Down Expand Up @@ -229,8 +228,8 @@
<category android:name="android.intent.category.BROWSABLE" />

<data
android:path="/oauth2redirect"
android:host="e2ei"
android:path="/oauth2redirect"
android:scheme="wire" />
</intent-filter>
<intent-filter>
Expand All @@ -240,8 +239,8 @@
<category android:name="android.intent.category.BROWSABLE" />

<data
android:path="/logout"
android:host="e2ei"
android:path="/logout"
android:scheme="wire" />
</intent-filter>
</activity>
Expand All @@ -250,6 +249,10 @@
We make a custom Firebase init, because the app selects the Firebase project at a runtime,
so we need to remove default FirebaseInitProvider and create our custom FirebaseInitializer.
-->
<meta-data
android:name="gcp.firebase.API_KEY"
android:value="${GCP_API_KEY}" />

<provider
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:authorities="${applicationId}.firebaseinitprovider"
Expand Down Expand Up @@ -329,9 +332,8 @@

<service
android:name=".services.PersistentWebSocketService"
android:foregroundServiceType="specialUse"
android:exported="false">
</service>
android:exported="false"
android:foregroundServiceType="specialUse"></service>

<service
android:name=".services.OngoingCallService"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@ fun Context.getActivity(): AppCompatActivity? = when (this) {
is ContextWrapper -> baseContext.getActivity()
else -> null
}

fun Context.getMetadataByKey(key: String): String {
val applicationInfo = packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA)
val keyValue = applicationInfo.metaData?.getString(key)
return keyValue.toString()
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.startup.Initializer
import com.google.firebase.FirebaseApp
import com.google.firebase.FirebaseOptions
import com.wire.android.BuildConfig
import com.wire.android.util.extension.getMetadataByKey
import com.wire.android.util.extension.isGoogleServicesAvailable

class FirebaseInitializer : Initializer<Unit> {
Expand All @@ -30,11 +31,12 @@ class FirebaseInitializer : Initializer<Unit> {
val firebaseOptions = FirebaseOptions.Builder()
.setApplicationId(BuildConfig.FIREBASE_APP_ID)
.setGcmSenderId(BuildConfig.FIREBASE_PUSH_SENDER_ID)
.setApiKey(BuildConfig.GOOGLE_API_KEY)
.setApiKey(context.getMetadataByKey("gcp.firebase.API_KEY"))
.setProjectId(BuildConfig.FCM_PROJECT_ID)
.build()
FirebaseApp.initializeApp(context, firebaseOptions)
}
}

override fun dependencies(): List<Class<out Initializer<*>>> = emptyList() // no dependencies on other libraries
}
17 changes: 11 additions & 6 deletions buildSrc/src/main/kotlin/scripts/variants.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,17 @@ android {
FeatureConfigs.values().forEach { configs ->
when (configs.configType) {
ConfigType.STRING -> {
buildStringConfig(
flavor,
configs.configType.type,
configs.name,
flavorMap[flavor.name]?.get(configs.value)?.toString()
)
if (FeatureConfigs.GOOGLE_API_KEY.value == configs.value) {
val apiKey:String? = flavorMap[flavor.name]?.get(configs.value)?.toString()
flavor.manifestPlaceholders["GCP_API_KEY"] = apiKey ?: ""
} else {
buildStringConfig(
flavor,
configs.configType.type,
configs.name,
flavorMap[flavor.name]?.get(configs.value)?.toString()
)
}
}

ConfigType.INT,
Expand Down
Loading