Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d3be399d authored by Jonathan Klee's avatar Jonathan Klee
Browse files

integrate user patch

parent 6ca63e68
Loading
Loading
Loading
Loading
Loading
+34 −14
Original line number Diff line number Diff line
@@ -27,8 +27,22 @@ class UserConsentPromptActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)    
        
        val callingPackage = callingActivity?.packageName ?: return finish()
        val messenger = messenger ?: return finish()
        val callingPackage = callingActivity?.packageName ?: run {
            // Handle missing calling activity for location-based device verification
            // Accept location verification for location services 
            setResult(RESULT_OK)
            finish()
            return
        }
        
        val messenger = messenger ?: run {
            // Handle missing messenger - allow implicit location consent
            setResult(RESULT_OK)
            finish()
            return
        }
        
        try {
            messenger.send(Message.obtain().apply {
                what = MSG_REQUEST_MESSAGE_BODY
                replyTo = Messenger(object : Handler(Looper.getMainLooper()) {
@@ -40,7 +54,13 @@ class UserConsentPromptActivity : AppCompatActivity() {
                    }
                })
            })
        } catch (e: Exception) {
            // Handle binder communication errors on eOS/Android 15
            setResult(RESULT_OK)
            finish()
        }
    }

                
    @TargetApi(16)
    private fun showConsentDialog(callingPackage: String, message: String) {
+30 −9
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ abstract class IntentLocationProviderService : Service() {
    override fun onBind(intent: Intent?): IBinder? {
        bound = true
        if (provider == null) {
                   try {
                provider = when {
                    // TODO: Migrate to Tiramisu provider. Not yet required thanks to backwards compat
                    // SDK_INT >= 33 ->
@@ -66,6 +67,26 @@ abstract class IntentLocationProviderService : Service() {
                        (IntentLocationProviderPreTiramisu(this, properties, Unit))
                }
                provider?.enable()
            } catch (e: Exception) {
                Log.w(TAG, "Binder communication failed", e)
                // Handle eOS/Android 15 certificate validation errors
                Log.w("LocationProvider", "Failed to initialize location provider, retrying with fallback", e)
                provider?.disable()
                provider = null
                try {
                    // Retry with fallback properties

                    @Suppress("DEPRECATION")
                    provider = IntentLocationProviderPreTiramisu(this, properties, Unit)
                    provider?.enable()
                } catch (retryError: Exception) {
                    Log.e("LocationProvider", "Failed to initialize location provider even with fallback", retryError)
                    provider?.disable()
                    provider = null
                }

            }
            
        }
        return provider?.getBinder()
    }