mirror of
https://github.com/bitwarden/android.git
synced 2026-05-01 12:48:42 -05:00
BIT-2306: Use legacy autofill service name to enforce compatibility after migration (#1328)
This commit is contained in:
committed by
Álison Fernandes
parent
859b4c247d
commit
fd08f39fd9
@@ -0,0 +1,34 @@
|
||||
package com.x8bit.bitwarden
|
||||
|
||||
import android.app.AppComponentFactory
|
||||
import android.app.Service
|
||||
import android.content.Intent
|
||||
import com.x8bit.bitwarden.data.autofill.BitwardenAutofillService
|
||||
import com.x8bit.bitwarden.data.platform.annotation.OmitFromCoverage
|
||||
|
||||
private const val LEGACY_AUTOFILL_SERVICE_NAME = "com.x8bit.bitwarden.Autofill.AutofillService"
|
||||
|
||||
/**
|
||||
* A factory class that allows us to intercept when a manifest element is being instantiated
|
||||
* and modify various characteristics before initialization.
|
||||
*/
|
||||
@Suppress("unused")
|
||||
@OmitFromCoverage
|
||||
class BitwardenAppComponentFactory : AppComponentFactory() {
|
||||
/**
|
||||
* Used to intercept when the [BitwardenAutofillService] is being instantiated and modify which
|
||||
* service is created. This is required because the [className] used in the manifest must match
|
||||
* the legacy Xamarin app service name but the service name in this app is different.
|
||||
*/
|
||||
override fun instantiateService(
|
||||
cl: ClassLoader,
|
||||
className: String,
|
||||
intent: Intent?,
|
||||
): Service = when (className) {
|
||||
LEGACY_AUTOFILL_SERVICE_NAME -> {
|
||||
super.instantiateService(cl, BitwardenAutofillService::class.java.name, intent)
|
||||
}
|
||||
|
||||
else -> super.instantiateService(cl, className, intent)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user