add an accessor for Context for use by subclasses

This commit is contained in:
Fred Quintana
2009-08-27 18:28:17 -07:00
parent 1005569fbb
commit c298a8518a
3 changed files with 11 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ import android.content.pm.RegisteredServicesCache;
import android.content.res.TypedArray;
import android.content.Context;
import android.util.AttributeSet;
import android.text.TextUtils;
/**
* A cache of services that export the {@link IAccountAuthenticator} interface. This cache
@@ -48,6 +49,9 @@ import android.util.AttributeSet;
com.android.internal.R.styleable.AccountAuthenticator_label, 0);
final int iconId = sa.getResourceId(
com.android.internal.R.styleable.AccountAuthenticator_icon, 0);
if (TextUtils.isEmpty(accountType)) {
return null;
}
return new AuthenticatorDescription(accountType, packageName, labelId, iconId);
} finally {
sa.recycle();

View File

@@ -10,6 +10,8 @@ public class AuthenticatorDescription implements Parcelable {
final public String packageName;
public AuthenticatorDescription(String type, String packageName, int labelId, int iconId) {
if (type == null) throw new IllegalArgumentException("type cannot be null");
if (packageName == null) throw new IllegalArgumentException("packageName cannot be null");
this.type = type;
this.packageName = packageName;
this.labelId = labelId;
@@ -17,6 +19,7 @@ public class AuthenticatorDescription implements Parcelable {
}
public static AuthenticatorDescription newKey(String type) {
if (type == null) throw new IllegalArgumentException("type cannot be null");
return new AuthenticatorDescription(type);
}

View File

@@ -64,6 +64,10 @@ public abstract class AbstractThreadedSyncAdapter {
mAutoInitialize = autoInitialize;
}
public Context getContext() {
return mContext;
}
class ISyncAdapterImpl extends ISyncAdapter.Stub {
public void startSync(ISyncContext syncContext, String authority, Account account,
Bundle extras) {