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

Commit 03c97da8 authored by dev-12's avatar dev-12
Browse files

Merge branch '3705-a15-account-removed-migration' into 'main'

migrate to account removed callback from account manager and unify permissions across adding and removing account.

See merge request !316
parents 25bf784e 3ba03b8f
Loading
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@
        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
        android:name=".EdriveApplication"
@@ -104,19 +104,20 @@
            </intent-filter>
        </receiver>

        <receiver android:name=".account.receivers.AccountRemoveCallbackReceiver"
        <receiver
            android:name=".account.receivers.AccountRemoveCallbackReceiver"
            android:exported="true"
            android:enabled="true"
            android:exported="true">
            android:permission="foundation.e.accountmanager.permission.ACCOUNT_EVENTS">
            <intent-filter>
                <action android:name="android.accounts.action.ACCOUNT_REMOVED"/>
                <action android:name="foundation.e.accountmanager.action.ACCOUNT_REMOVED"/>
            </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, "")
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ import timber.log.Timber;

public class AccountRemoveCallbackReceiver extends BroadcastReceiver {

    private static final String ACTION_ACCOUNT_REMOVED = "android.accounts.action.ACCOUNT_REMOVED";
    private static final String ACTION_ACCOUNT_REMOVED = "foundation.e.accountmanager.action.ACCOUNT_REMOVED";

    @SuppressLint("UnsafeProtectedBroadcastReceiver")
    @Override
+2 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
    <issue id="Typos" severity="ignore" />
    <issue id="StopShip" severity="ignore" />
    <issue id="InvalidPackage" severity="ignore" />
    <issue id="UnusedQuantity" severity="ignore" />

    <!-- WARNINGS -->
    <issue id="MissingTranslation" severity="warning" />