summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorFred Quintana <fredq@google.com>2009-06-15 12:29:24 -0700
committerFred Quintana <fredq@google.com>2009-06-15 15:57:30 -0700
commit9788976b1465ce982b5ae7c741345edd0ecd9322 (patch)
treeb8f727509004acb6775656e1e404a67efce04f05 /core
parent21f0b1766cb502e940985777826db1a3beb625a1 (diff)
downloadframeworks_base-9788976b1465ce982b5ae7c741345edd0ecd9322.zip
frameworks_base-9788976b1465ce982b5ae7c741345edd0ecd9322.tar.gz
frameworks_base-9788976b1465ce982b5ae7c741345edd0ecd9322.tar.bz2
add icon and label to the authenticator description
Diffstat (limited to 'core')
-rw-r--r--core/java/android/accounts/AccountAuthenticatorCache.java34
-rw-r--r--core/java/android/accounts/AccountManager.java10
-rw-r--r--core/java/android/accounts/AccountManagerService.java11
-rw-r--r--core/java/android/accounts/AuthenticatorBindHelper.java5
-rw-r--r--core/java/android/accounts/AuthenticatorDescription.aidl19
-rw-r--r--core/java/android/accounts/AuthenticatorDescription.java69
-rw-r--r--core/java/android/accounts/IAccountManager.aidl3
-rw-r--r--core/java/android/content/SyncAdaptersCache.java24
-rw-r--r--core/java/android/content/SyncManager.java2
-rw-r--r--core/java/android/content/pm/RegisteredServicesCache.java6
-rw-r--r--core/res/res/values/attrs.xml4
11 files changed, 123 insertions, 64 deletions
diff --git a/core/java/android/accounts/AccountAuthenticatorCache.java b/core/java/android/accounts/AccountAuthenticatorCache.java
index 83aae3a..c8fc12c 100644
--- a/core/java/android/accounts/AccountAuthenticatorCache.java
+++ b/core/java/android/accounts/AccountAuthenticatorCache.java
@@ -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();
}
diff --git a/core/java/android/accounts/AccountManager.java b/core/java/android/accounts/AccountManager.java
index 4fcaa88..5182f2e 100644
--- a/core/java/android/accounts/AccountManager.java
+++ b/core/java/android/accounts/AccountManager.java
@@ -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();
}
});
diff --git a/core/java/android/accounts/AccountManagerService.java b/core/java/android/accounts/AccountManagerService.java
index 545241f..4f617c4 100644
--- a/core/java/android/accounts/AccountManagerService.java
+++ b/core/java/android/accounts/AccountManagerService.java
@@ -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++;
diff --git a/core/java/android/accounts/AuthenticatorBindHelper.java b/core/java/android/accounts/AuthenticatorBindHelper.java
index 9d2ccf6..91e23ab 100644
--- a/core/java/android/accounts/AuthenticatorBindHelper.java
+++ b/core/java/android/accounts/AuthenticatorBindHelper.java
@@ -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
diff --git a/core/java/android/accounts/AuthenticatorDescription.aidl b/core/java/android/accounts/AuthenticatorDescription.aidl
new file mode 100644
index 0000000..136361c
--- /dev/null
+++ b/core/java/android/accounts/AuthenticatorDescription.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.accounts;
+
+parcelable AuthenticatorDescription;
diff --git a/core/java/android/accounts/AuthenticatorDescription.java b/core/java/android/accounts/AuthenticatorDescription.java
new file mode 100644
index 0000000..f896bf8
--- /dev/null
+++ b/core/java/android/accounts/AuthenticatorDescription.java
@@ -0,0 +1,69 @@
+package android.accounts;
+
+import android.os.Parcelable;
+import android.os.Parcel;
+
+public class AuthenticatorDescription implements Parcelable {
+ final public String type;
+ final public int labelId;
+ final public int iconId;
+ final public String packageName;
+
+ public AuthenticatorDescription(String type, String packageName, int labelId, int iconId) {
+ this.type = type;
+ this.packageName = packageName;
+ this.labelId = labelId;
+ this.iconId = iconId;
+ }
+
+ public static AuthenticatorDescription newKey(String type) {
+ return new AuthenticatorDescription(type);
+ }
+
+ private AuthenticatorDescription(String type) {
+ this.type = type;
+ this.packageName = null;
+ this.labelId = 0;
+ this.iconId = 0;
+ }
+
+ private AuthenticatorDescription(Parcel source) {
+ this.type = source.readString();
+ this.packageName = source.readString();
+ this.labelId = source.readInt();
+ this.iconId = source.readInt();
+ }
+
+ public int describeContents() {
+ return 0;
+ }
+
+ public int hashCode() {
+ return type.hashCode();
+ }
+
+ public boolean equals(Object o) {
+ if (o == this) return true;
+ if (!(o instanceof AuthenticatorDescription)) return false;
+ final AuthenticatorDescription other = (AuthenticatorDescription) o;
+ return type.equals(other.type);
+ }
+
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeString(type);
+ dest.writeString(packageName);
+ dest.writeInt(labelId);
+ dest.writeInt(iconId);
+ }
+
+ public static final Creator<AuthenticatorDescription> CREATOR =
+ new Creator<AuthenticatorDescription>() {
+ public AuthenticatorDescription createFromParcel(Parcel source) {
+ return new AuthenticatorDescription(source);
+ }
+
+ public AuthenticatorDescription[] newArray(int size) {
+ return new AuthenticatorDescription[size];
+ }
+ };
+}
diff --git a/core/java/android/accounts/IAccountManager.aidl b/core/java/android/accounts/IAccountManager.aidl
index 5e37a1f..15ab4e8 100644
--- a/core/java/android/accounts/IAccountManager.aidl
+++ b/core/java/android/accounts/IAccountManager.aidl
@@ -18,6 +18,7 @@ package android.accounts;
import android.accounts.IAccountManagerResponse;
import android.accounts.Account;
+import android.accounts.AuthenticatorDescription;
import android.os.Bundle;
/**
@@ -27,7 +28,7 @@ import android.os.Bundle;
interface IAccountManager {
String getPassword(in Account account);
String getUserData(in Account account, String key);
- String[] getAuthenticatorTypes();
+ AuthenticatorDescription[] getAuthenticatorTypes();
Account[] getAccounts();
Account[] getAccountsByType(String accountType);
boolean addAccount(in Account account, String password, in Bundle extras);
diff --git a/core/java/android/content/SyncAdaptersCache.java b/core/java/android/content/SyncAdaptersCache.java
index 56e3e75..ce47d76 100644
--- a/core/java/android/content/SyncAdaptersCache.java
+++ b/core/java/android/content/SyncAdaptersCache.java
@@ -16,32 +16,10 @@
package android.content;
-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 android.content.ISyncAdapter} interface.
@@ -58,7 +36,7 @@ import org.xmlpull.v1.XmlPullParser;
super(context, SERVICE_INTERFACE, SERVICE_META_DATA, ATTRIBUTES_NAME);
}
- public SyncAdapterType parseServiceAttributes(AttributeSet attrs) {
+ public SyncAdapterType parseServiceAttributes(String packageName, AttributeSet attrs) {
TypedArray sa = mContext.getResources().obtainAttributes(attrs,
com.android.internal.R.styleable.SyncAdapter);
try {
diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java
index 03cfbea..cba02aa 100644
--- a/core/java/android/content/SyncManager.java
+++ b/core/java/android/content/SyncManager.java
@@ -1642,7 +1642,7 @@ class SyncManager implements OnAccountsUpdatedListener {
// connect to the sync adapter
SyncAdapterType syncAdapterType = new SyncAdapterType(syncOperation.authority,
syncOperation.account.mType);
- RegisteredServicesCache.ServiceInfo syncAdapterInfo =
+ RegisteredServicesCache.ServiceInfo<SyncAdapterType> syncAdapterInfo =
mSyncAdapters.getServiceInfo(syncAdapterType);
if (syncAdapterInfo == null) {
if (Config.LOGD) {
diff --git a/core/java/android/content/pm/RegisteredServicesCache.java b/core/java/android/content/pm/RegisteredServicesCache.java
index d8f8478..bb94372 100644
--- a/core/java/android/content/pm/RegisteredServicesCache.java
+++ b/core/java/android/content/pm/RegisteredServicesCache.java
@@ -130,7 +130,7 @@ public abstract class RegisteredServicesCache<V> {
* @param type the account type of the authenticator
* @return the AuthenticatorInfo that matches the account type or null if none is present
*/
- public ServiceInfo getServiceInfo(V type) {
+ public ServiceInfo<V> getServiceInfo(V type) {
if (mServices == null) {
maybeRegisterForPackageChanges();
mServices = generateServicesMap();
@@ -219,7 +219,7 @@ public abstract class RegisteredServicesCache<V> {
"Meta-data does not start with " + mAttributesName + " tag");
}
- V v = parseServiceAttributes(attrs);
+ V v = parseServiceAttributes(si.packageName, attrs);
if (v == null) {
return null;
}
@@ -229,5 +229,5 @@ public abstract class RegisteredServicesCache<V> {
}
}
- public abstract V parseServiceAttributes(AttributeSet attrs);
+ public abstract V parseServiceAttributes(String packageName, AttributeSet attrs);
}
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index d223828..d778f5c 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -3297,6 +3297,10 @@
<declare-styleable name="AccountAuthenticator">
<!-- the account type this authenticator handles. -->
<attr name="accountType" format="string"/>
+ <!-- the user-visible name of the authenticator. -->
+ <attr name="label"/>
+ <!-- the icon of the authenticator. -->
+ <attr name="icon"/>
</declare-styleable>
<!-- =============================== -->