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

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

Merge branch '3457-a15-notify-all-components' into 'main'

Notify all components listening for account added

See merge request !161
parents 10f3d62e ab631cf2
Loading
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -28,8 +28,10 @@
    <!-- android.permission-group.CALENDAR -->
    <uses-permission android:name="android.permission.READ_CALENDAR"/>
    <uses-permission android:name="android.permission.WRITE_CALENDAR"/>
    <!-- android.permission.eDrive -->
    <uses-permission android:name="foundation.e.permission.ADD_ACCOUNT"/>

    <!-- permission to use to be notified about account being added -->
    <permission android:name="foundation.e.accountmanager.permission.ADD_ACCOUNT"
        android:protectionLevel="signature" />

    <!-- android.permission-group.LOCATION -->
    <!-- getting the WiFi name (for "sync in Wifi only") requires
+4 −9
Original line number Diff line number Diff line
@@ -204,7 +204,7 @@ class AccountDetailsFragment : Fragment() {
                            if (isSsoMigrationRunning) {
                                handlePostMurenaSsoMigrationOperations()
                            } else {
                                notifyEdriveWithAccountAdded(name)
                                notifyListeners(name)
                            }
                        }
                        handlePostAuthOperations()
@@ -264,18 +264,13 @@ class AccountDetailsFragment : Fragment() {
        requireContext().stopService(serviceIntent)
    }

    private fun notifyEdriveWithAccountAdded(name: String) {
        val intent = Intent("foundation.e.drive.action.ADD_ACCOUNT")
    private fun notifyListeners(name: String) {
        val intent = Intent("foundation.e.accountmanager.action.ACCOUNT_ADDED")
        intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES)
        intent.component =
            ComponentName(
                getString(R.string.e_drive_package_name), 
                "foundation.e.drive.account.receivers.AccountAddedReceiver"
            )

        intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, name)
        intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, getString(R.string.eelo_account_type))
        requireActivity().sendBroadcast(intent)
        requireActivity().sendBroadcast(intent, "foundation.e.accountmanager.permission.ADD_ACCOUNT")
    }