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

Commit 3ba03b8f authored by dev-12's avatar dev-12 Committed by pratyush
Browse files

fix: unify permission across account events.

don't ignore exported security warning; account added is protected by permission now, it should not be possible to call it without proper permission
parent 91f0f48c
Loading
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@
        tools:ignore="QueryAllPackagesPermission" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />

    <uses-permission android:name="foundation.e.accountmanager.permission.ADD_ACCOUNT" />
    <uses-permission android:name="foundation.e.accountmanager.permission.ACCOUNT_EVENTS"/>

    <application
@@ -115,11 +114,10 @@
            </intent-filter>
        </receiver>

        <!-- We can ignore the permission warning since ADD_ACCOUNT permission is signature -->
        <receiver
            android:name=".account.receivers.AccountAddedReceiver"
            android:exported="true"
            tools:ignore="ExportedReceiver">
            android:permission="foundation.e.accountmanager.permission.ACCOUNT_EVENTS">
            <intent-filter>
                <action android:name="foundation.e.accountmanager.action.ACCOUNT_ADDED"/>
            </intent-filter>
+9 −0
Original line number Diff line number Diff line
@@ -30,10 +30,19 @@ import timber.log.Timber
 * @author Vincent Bourgmayer
 */
class AccountAddedReceiver : BroadcastReceiver() {

    companion object {
        const val ACTION_ACCOUNT_ADDED = "foundation.e.accountmanager.action.ACCOUNT_ADDED"
    }

    override fun onReceive(context: Context?, intent: Intent?) {
        Timber.d("\"Account added\" intent received")

        if (context == null || intent == null || intent.extras == null) return
        if (intent.action != ACTION_ACCOUNT_ADDED) {
            Timber.wtf("AccountAddedReceiver.onReceive is called without proper action")
            return
        }

        val extras = intent.extras!!
        val accountName = extras.getString(AccountManager.KEY_ACCOUNT_NAME, "")