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

Commit 839f9fa4 authored by Nihar Thakkar's avatar Nihar Thakkar
Browse files

Use separate custom account types for Google, eelo and webDAV accounts

parent fd97e6c0
Loading
Loading
Loading
Loading
Loading
+79 −1
Original line number Diff line number Diff line
@@ -91,8 +91,8 @@

        <activity
            android:name=".ui.setup.LoginActivity"
            android:label="@string/login_title"
            android:excludeFromRecents="true"
            android:label="@string/login_title"
            android:parentActivityName=".ui.AccountsActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
@@ -226,6 +226,45 @@
                android:name="android.accounts.AccountAuthenticator"
                android:resource="@xml/google_account_authenticator" />
        </service>
        <service
            android:name=".syncadapter.GoogleCalendarsSyncAdapterService"
            android:exported="true"
            android:process=":sync"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.content.SyncAdapter" />
            </intent-filter>

            <meta-data
                android:name="android.content.SyncAdapter"
                android:resource="@xml/google_sync_calendars" />
        </service>
        <service
            android:name=".syncadapter.GoogleTasksSyncAdapterService"
            android:exported="true"
            android:process=":sync"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.content.SyncAdapter" />
            </intent-filter>

            <meta-data
                android:name="android.content.SyncAdapter"
                android:resource="@xml/google_sync_tasks" />
        </service>
        <service
            android:name=".syncadapter.GoogleAddressBooksSyncAdapterService"
            android:exported="true"
            android:process=":sync"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.content.SyncAdapter" />
            </intent-filter>

            <meta-data
                android:name="android.content.SyncAdapter"
                android:resource="@xml/google_sync_address_books" />
        </service>

        <!-- account type "eelo" -->
        <service
@@ -239,6 +278,45 @@
                android:name="android.accounts.AccountAuthenticator"
                android:resource="@xml/eelo_account_authenticator" />
        </service>
        <service
            android:name=".syncadapter.EeloCalendarsSyncAdapterService"
            android:exported="true"
            android:process=":sync"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.content.SyncAdapter" />
            </intent-filter>

            <meta-data
                android:name="android.content.SyncAdapter"
                android:resource="@xml/eelo_sync_calendars" />
        </service>
        <service
            android:name=".syncadapter.EeloTasksSyncAdapterService"
            android:exported="true"
            android:process=":sync"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.content.SyncAdapter" />
            </intent-filter>

            <meta-data
                android:name="android.content.SyncAdapter"
                android:resource="@xml/eelo_sync_tasks" />
        </service>
        <service
            android:name=".syncadapter.EeloAddressBooksSyncAdapterService"
            android:exported="true"
            android:process=":sync"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.content.SyncAdapter" />
            </intent-filter>

            <meta-data
                android:name="android.content.SyncAdapter"
                android:resource="@xml/eelo_sync_address_books" />
        </service>

        <!-- Callback from authentication screen -->
        <activity android:name="net.openid.appauth.RedirectUriReceiverActivity">
+3 −2
Original line number Diff line number Diff line
@@ -141,9 +141,10 @@ class DavService : Service() {
            }

            val account by lazy {
                db.query(Services._TABLE, arrayOf(Services.ACCOUNT_NAME), "${Services.ID}=?", arrayOf(service.toString()), null, null, null)?.use { cursor ->
                db.query(Services._TABLE, arrayOf(Services.ACCOUNT_NAME, Services.ACCOUNT_TYPE), "${Services.ID}=?",
                        arrayOf(service.toString()), null, null, null)?.use { cursor ->
                    if (cursor.moveToNext())
                        return@lazy Account(cursor.getString(0), getString(R.string.account_type))
                        return@lazy Account(cursor.getString(0), cursor.getString(1))
                }
                throw IllegalArgumentException("Account not found")
            }
+2 −2
Original line number Diff line number Diff line
@@ -40,10 +40,10 @@ class PackageChangedReceiver: BroadcastReceiver() {
            ServiceDB.OpenHelper(context).use { dbHelper ->
                val db = dbHelper.readableDatabase

                db.query(Services._TABLE, arrayOf(Services.ACCOUNT_NAME),
                db.query(Services._TABLE, arrayOf(Services.ACCOUNT_NAME, Services.ACCOUNT_TYPE),
                        "${Services.SERVICE}=?", arrayOf(Services.SERVICE_CALDAV), null, null, null)?.use { cursor ->
                    while (cursor.moveToNext()) {
                        val account = Account(cursor.getString(0), context.getString(R.string.account_type))
                        val account = Account(cursor.getString(0), cursor.getString(1))

                        if (tasksInstalled) {
                            if (ContentResolver.getIsSyncable(account, TaskProvider.ProviderName.OpenTasks.authority) <= 0) {
+2 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ class ServiceDB {
        const val ID = "_id"
        const val ACCOUNT_NAME = "accountName"
        const val AUTH_STATE = "authState"
        const val ACCOUNT_TYPE = "accountType"
        const val SERVICE = "service"
        const val PRINCIPAL = "principal"

@@ -91,6 +92,7 @@ class ServiceDB {
                    "${Services.ID} INTEGER PRIMARY KEY AUTOINCREMENT," +
                    "${Services.ACCOUNT_NAME} TEXT NOT NULL," +
                    "${Services.AUTH_STATE} TEXT," +
                    "${Services.ACCOUNT_TYPE} TEXT," +
                    "${Services.SERVICE} TEXT NOT NULL," +
                    "${Services.PRINCIPAL} TEXT NULL)")
            db.execSQL("CREATE UNIQUE INDEX services_account ON ${Services._TABLE} (${Services.ACCOUNT_NAME},${Services.SERVICE})")
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ class EeloAccountAuthenticatorService : Service(), OnAccountsUpdateListener {
                val sqlAccountNames = LinkedList<String>()
                val accountNames = HashSet<String>()
                val accountManager = AccountManager.get(context)
                for (account in accountManager.getAccountsByType(context.getString(R.string.account_type))) {
                for (account in accountManager.getAccountsByType(context.getString(R.string.eelo_account_type))) {
                    sqlAccountNames.add(DatabaseUtils.sqlEscapeString(account.name))
                    accountNames += account.name
                }
Loading