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

Commit 529304b8 authored by Jonathan Klee's avatar Jonathan Klee
Browse files

Introduce WorkAccountAuthenticatorService

parent 284f880a
Loading
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -22,5 +22,25 @@
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </service>
        <service
            android:name="org.microg.gms.auth.account.authenticator.WorkAccountAuthenticatorService"
            android:process=":persistent"
            android:enabled="false"
            android:exported="false">

           <intent-filter>
                <action android:name="android.accounts.AccountAuthenticator"/>
           </intent-filter>

           <meta-data
               android:name="android.accounts.AccountAuthenticator"
               android:resource="@xml/auth_work_authenticator"/>

           <meta-data
               android:name="android.accounts.AccountAuthenticator.customTokens"
               android:value="1"/>

        </service>

    </application>
</manifest>
+12 −0
Original line number Diff line number Diff line
package org.microg.gms.auth.account.authenticator

import android.app.Service
import android.content.Intent
import android.os.IBinder

class WorkAccountAuthenticatorService : Service() {

    override fun onBind(intent: Intent?): IBinder? {
        return null
    }
}
 No newline at end of file
+14 −0
Original line number Diff line number Diff line
@@ -2,8 +2,12 @@ package org.microg.gms.auth.workaccount

import android.accounts.Account
import android.accounts.AccountManager
import android.app.admin.DevicePolicyManager
import android.content.ComponentName
import android.content.Context
import android.content.pm.PackageManager
import android.os.Parcel
import android.os.UserManager
import android.util.Log
import com.google.android.gms.auth.account.IWorkAccountService
import com.google.android.gms.auth.account.IWorkAccountService.AddAccountResult
@@ -40,6 +44,7 @@ class WorkAccountServiceImpl(val context: Context) : IWorkAccountService.Stub()
        return object : AddAccountResult.Stub() {
            override fun getAccount(): Account? {
                // TODO

                return AccountManager.get(context).accounts.firstOrNull()?.also { Log.d(TAG, "returning account $it") }
            }

@@ -50,15 +55,24 @@ class WorkAccountServiceImpl(val context: Context) : IWorkAccountService.Stub()
    }

     override fun removeWorkAccount(googleApiClient: IObjectWrapper?, account: IObjectWrapper?): IObjectWrapper {
         Log.d(TAG, "removeWorkAccount")
        return ObjectWrapper.wrap(null)
    }

     override fun setWorkAuthenticatorEnabled(googleApiClient: IObjectWrapper?, b: Boolean) {
         // TODO
         Log.d(TAG, "setWorkAuthenticatorEnabled with $googleApiClient, $b")
         val devicePolicyManager = context.getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
         val userManger = context.getSystemService(Context.USER_SERVICE) as UserManager
         val sharedPreferences = context.getSharedPreferences("work_account_prefs", Context.MODE_PRIVATE)
         sharedPreferences.edit().putBoolean("enabled_by_admin", true).apply()

         val componentName = ComponentName("com.google.android.gms", "com.google.android.gms.auth.account.authenticator.WorkAccountAuthenticatorService")
         //context.packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP)
    }

     override fun setWorkAuthenticatorEnabledWithResult(googleApiClient: IObjectWrapper?, b: Boolean): IObjectWrapper {
        Log.d(TAG, "setWorkAuthenticatorEnabledWithResult $googleApiClient, $b")
        return ObjectWrapper.wrap(null)
    }
}
+19 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="48dp"
    android:height="48dp"
    android:viewportWidth="48"
    android:viewportHeight="48">
    <path
        android:fillColor="#4285f4"
        android:pathData="M46.98,24.55c0,-1.57 -0.15,-3.09 -0.38,-4.55H24v9.02h12.94c-0.58,2.96 -2.26,5.48 -4.78,7.18v6h7.73c4.51,-4.18 7.09,-10.36 7.09,-17.65z" />
    <path
        android:fillColor="#34a853"
        android:pathData="M24,48c6.48,0 11.93,-2.13 15.89,-5.81l-7.73,-6c-2.15,1.45 -4.92,2.3 -8.16,2.3 -6.26,0 -11.57,-4.22 -13.47,-9.91H2.56v6.19C6.51,42.62 14.62,48 24,48z" />
    <path
        android:fillColor="#fbbc05"
        android:pathData="M10.53,28.59c-0.48,-1.45 -0.76,-2.99 -0.76,-4.59s0.27,-3.14 0.76,-4.59v-6.19H2.56C0.92,16.46 0,20.12 0,24c0,3.88 0.92,7.54 2.56,10.78l7.97,-6.19z" />
    <path
        android:fillColor="#ea4335"
        android:pathData="M24,9.5c3.54,0 6.71,1.22 9.21,3.6l6.85,-6.85C35.9,2.38 30.47,0 24,0 14.62,0 6.51,5.38 2.56,13.22l7.98,6.19C12.43,13.72 17.74,9.5 24,9.5z" />
</vector>
 No newline at end of file
+6 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">

    <string name="auth_work_authenticator_label">Yo babe</string>

</resources>
Loading