diff --git a/api/current.xml b/api/current.xml
index 0bf588d90cfcc..79cacba93b4e4 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -16468,7 +16468,7 @@
-
+
@@ -17011,6 +17011,122 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
-
-
-
-
-
+
diff --git a/core/java/android/accounts/AccountAuthenticatorCache.java b/core/java/android/accounts/AccountAuthenticatorCache.java
index 83aae3a2d7059..c8fc12c1fd1cd 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 {
+/* package private */ class AccountAuthenticatorCache
+ extends RegisteredServicesCache {
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 4fcaa884b1c60..5182f2e94c1e8 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 getAuthenticatorTypes(Future1Callback callback,
- Handler handler) {
- return startAsFuture(callback, handler, new Callable() {
- public String[] call() throws Exception {
+ public Future1 getAuthenticatorTypes(
+ Future1Callback callback, Handler handler) {
+ return startAsFuture(callback, handler, new Callable() {
+ public AuthenticatorDescription[] call() throws Exception {
return blockingGetAuthenticatorTypes();
}
});
diff --git a/core/java/android/accounts/AccountManagerService.java b/core/java/android/accounts/AccountManagerService.java
index 545241f0f47f9..4f617c49f1c38 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> authenticatorCollection =
- mAuthenticatorCache.getAllServices();
- String[] types = new String[authenticatorCollection.size()];
+ Collection>
+ authenticatorCollection = mAuthenticatorCache.getAllServices();
+ AuthenticatorDescription[] types =
+ new AuthenticatorDescription[authenticatorCollection.size()];
int i = 0;
- for (AccountAuthenticatorCache.ServiceInfo authenticator
+ for (AccountAuthenticatorCache.ServiceInfo authenticator
: authenticatorCollection) {
types[i] = authenticator.type;
i++;
diff --git a/core/java/android/accounts/AuthenticatorBindHelper.java b/core/java/android/accounts/AuthenticatorBindHelper.java
index 9d2ccf6429a27..91e23ab8aca05 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 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 0000000000000..136361c4898ab
--- /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 0000000000000..f896bf8acf391
--- /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 CREATOR =
+ new Creator() {
+ 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 5e37a1fd46c2b..15ab4e822c505 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 56e3e757f1f90..ce47d7672fb16 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 03cfbeaff8836..cba02aa7de5c3 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 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 d8f84786a8bbd..bb94372b09a23 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 {
* @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 getServiceInfo(V type) {
if (mServices == null) {
maybeRegisterForPackageChanges();
mServices = generateServicesMap();
@@ -219,7 +219,7 @@ public abstract class RegisteredServicesCache {
"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 {
}
}
- 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 d223828c74005..d778f5c1d1fef 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -3297,6 +3297,10 @@
+
+
+
+