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

Commit 9788976b authored by Fred Quintana's avatar Fred Quintana
Browse files

add icon and label to the authenticator description

parent 21f0b176
Loading
Loading
Loading
Loading
+125 −9
Original line number Diff line number Diff line
@@ -16468,7 +16468,7 @@
</exception>
</method>
<method name="blockingGetAuthenticatorTypes"
 return="java.lang.String[]"
 return="android.accounts.AuthenticatorDescription[]"
 abstract="false"
 native="false"
 synchronized="false"
@@ -16808,7 +16808,7 @@
</parameter>
</method>
<method name="getAuthenticatorTypes"
 return="android.accounts.Future1&lt;java.lang.String[]&gt;"
 return="android.accounts.Future1&lt;android.accounts.AuthenticatorDescription[]&gt;"
 abstract="false"
 native="false"
 synchronized="false"
@@ -16817,7 +16817,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="callback" type="android.accounts.Future1Callback&lt;java.lang.String[]&gt;">
<parameter name="callback" type="android.accounts.Future1Callback&lt;android.accounts.AuthenticatorDescription[]&gt;">
</parameter>
<parameter name="handler" type="android.os.Handler">
</parameter>
@@ -17011,6 +17011,122 @@
</parameter>
</method>
</class>
<class name="AuthenticatorDescription"
 extends="java.lang.Object"
 abstract="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<implements name="android.os.Parcelable">
</implements>
<constructor name="AuthenticatorDescription"
 type="android.accounts.AuthenticatorDescription"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="type" type="java.lang.String">
</parameter>
<parameter name="packageName" type="java.lang.String">
</parameter>
<parameter name="labelId" type="int">
</parameter>
<parameter name="iconId" type="int">
</parameter>
</constructor>
<method name="describeContents"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="newKey"
 return="android.accounts.AuthenticatorDescription"
 abstract="false"
 native="false"
 synchronized="false"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="type" type="java.lang.String">
</parameter>
</method>
<method name="writeToParcel"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="dest" type="android.os.Parcel">
</parameter>
<parameter name="flags" type="int">
</parameter>
</method>
<field name="CREATOR"
 type="android.os.Parcelable.Creator"
 transient="false"
 volatile="false"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="iconId"
 type="int"
 transient="false"
 volatile="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="labelId"
 type="int"
 transient="false"
 volatile="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="packageName"
 type="java.lang.String"
 transient="false"
 volatile="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="type"
 type="java.lang.String"
 transient="false"
 volatile="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
</class>
<class name="AuthenticatorException"
 extends="java.lang.Exception"
 abstract="false"
@@ -285738,7 +285854,11 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="val" type="int">
<parameter name="buf" type="byte[]">
</parameter>
<parameter name="off" type="int">
</parameter>
<parameter name="nbytes" type="int">
</parameter>
</method>
<method name="update"
@@ -285751,11 +285871,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="buf" type="byte[]">
</parameter>
<parameter name="off" type="int">
</parameter>
<parameter name="nbytes" type="int">
<parameter name="val" type="int">
</parameter>
</method>
</interface>
+10 −24
Original line number Diff line number Diff line
@@ -17,31 +17,10 @@
package android.accounts;

import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.content.pm.RegisteredServicesCache;
import android.content.res.XmlResourceParser;
import android.content.res.TypedArray;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.util.Log;
import android.util.AttributeSet;
import android.util.Xml;

import java.io.IOException;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import com.google.android.collect.Maps;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParser;

/**
 * A cache of services that export the {@link IAccountAuthenticator} interface. This cache
@@ -50,7 +29,8 @@ import org.xmlpull.v1.XmlPullParser;
 * are made available via the {@link RegisteredServicesCache#getServiceInfo} method.
 * @hide
 */
/* package private */ class AccountAuthenticatorCache extends RegisteredServicesCache<String> {
/* package private */ class AccountAuthenticatorCache
        extends RegisteredServicesCache<AuthenticatorDescription> {
    private static final String TAG = "Account";

    private static final String SERVICE_INTERFACE = "android.accounts.AccountAuthenticator";
@@ -61,11 +41,17 @@ import org.xmlpull.v1.XmlPullParser;
        super(context, SERVICE_INTERFACE, SERVICE_META_DATA, ATTRIBUTES_NAME);
    }

    public String parseServiceAttributes(AttributeSet attrs) {
    public AuthenticatorDescription parseServiceAttributes(String packageName, AttributeSet attrs) {
        TypedArray sa = mContext.getResources().obtainAttributes(attrs,
                com.android.internal.R.styleable.AccountAuthenticator);
        try {
            return sa.getString(com.android.internal.R.styleable.AccountAuthenticator_accountType);
            final String accountType =
                    sa.getString(com.android.internal.R.styleable.AccountAuthenticator_accountType);
            final int labelId = sa.getResourceId(
                    com.android.internal.R.styleable.AccountAuthenticator_label, 0);
            final int iconId = sa.getResourceId(
                    com.android.internal.R.styleable.AccountAuthenticator_icon, 0);
            return new AuthenticatorDescription(accountType, packageName, labelId, iconId);
        } finally {
            sa.recycle();
        }
+5 −5
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ public class AccountManager {
        });
    }

    public String[] blockingGetAuthenticatorTypes() {
    public AuthenticatorDescription[] blockingGetAuthenticatorTypes() {
        ensureNotOnMainThread();
        try {
            return mService.getAuthenticatorTypes();
@@ -128,10 +128,10 @@ public class AccountManager {
        }
    }

    public Future1<String[]> getAuthenticatorTypes(Future1Callback<String[]> callback,
            Handler handler) {
        return startAsFuture(callback, handler, new Callable<String[]>() {
            public String[] call() throws Exception {
    public Future1<AuthenticatorDescription[]> getAuthenticatorTypes(
            Future1Callback<AuthenticatorDescription[]> callback, Handler handler) {
        return startAsFuture(callback, handler, new Callable<AuthenticatorDescription[]>() {
            public AuthenticatorDescription[] call() throws Exception {
                return blockingGetAuthenticatorTypes();
            }
        });
+6 −5
Original line number Diff line number Diff line
@@ -215,14 +215,15 @@ public class AccountManagerService extends IAccountManager.Stub {
        }
    }

    public String[] getAuthenticatorTypes() {
    public AuthenticatorDescription[] getAuthenticatorTypes() {
        long identityToken = clearCallingIdentity();
        try {
            Collection<AccountAuthenticatorCache.ServiceInfo<String>> authenticatorCollection =
                    mAuthenticatorCache.getAllServices();
            String[] types = new String[authenticatorCollection.size()];
            Collection<AccountAuthenticatorCache.ServiceInfo<AuthenticatorDescription>>
                    authenticatorCollection = mAuthenticatorCache.getAllServices();
            AuthenticatorDescription[] types =
                    new AuthenticatorDescription[authenticatorCollection.size()];
            int i = 0;
            for (AccountAuthenticatorCache.ServiceInfo<String> authenticator
            for (AccountAuthenticatorCache.ServiceInfo<AuthenticatorDescription> authenticator
                    : authenticatorCollection) {
                types[i] = authenticator.type;
                i++;
+3 −2
Original line number Diff line number Diff line
@@ -95,8 +95,9 @@ public class AuthenticatorBindHelper {

            // otherwise find the component name for the authenticator and initiate a bind
            // if no authenticator or the bind fails then return false, otherwise return true
            AccountAuthenticatorCache.ServiceInfo authenticatorInfo =
                    mAuthenticatorCache.getServiceInfo(authenticatorType);
            AccountAuthenticatorCache.ServiceInfo<AuthenticatorDescription> authenticatorInfo =
                    mAuthenticatorCache.getServiceInfo(
                            AuthenticatorDescription.newKey(authenticatorType));
            if (authenticatorInfo == null) {
                if (Log.isLoggable(TAG, Log.VERBOSE)) {
                    Log.v(TAG, "there is no authenticator for " + authenticatorType
Loading