Skip to content

Commit

Permalink
chore: use manifest placeholder to get rid of playstore error (WPB-86…
Browse files Browse the repository at this point in the history
…45) 🍒 (#3230)

Co-authored-by: Yamil Medina <yamilmedina@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and yamilmedina authored Jul 25, 2024
1 parent dfc69fc commit 5af0fdd
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 24 deletions.
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

0 comments on commit 5af0fdd

Please sign in to comment.