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

Commit 735f4553 authored by Fred Quintana's avatar Fred Quintana
Browse files

resolved conflicts for merge of ae0cf6dc to eclair-mr2

parents cf250733 ae0cf6dc
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -18,10 +18,16 @@ package android.accounts;

import android.content.pm.PackageManager;
import android.content.pm.RegisteredServicesCache;
import android.content.pm.XmlSerializerAndParser;
import android.content.res.TypedArray;
import android.content.Context;
import android.util.AttributeSet;
import android.text.TextUtils;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlSerializer;
import org.xmlpull.v1.XmlPullParserException;

import java.io.IOException;

/**
 * A cache of services that export the {@link IAccountAuthenticator} interface. This cache
@@ -33,10 +39,12 @@ import android.text.TextUtils;
/* package private */ class AccountAuthenticatorCache
        extends RegisteredServicesCache<AuthenticatorDescription> {
    private static final String TAG = "Account";
    private static final MySerializer sSerializer = new MySerializer();

    public AccountAuthenticatorCache(Context context) {
        super(context, AccountManager.ACTION_AUTHENTICATOR_INTENT,
                AccountManager.AUTHENTICATOR_META_DATA_NAME, AccountManager.AUTHENTICATOR_ATTRIBUTES_NAME);
                AccountManager.AUTHENTICATOR_META_DATA_NAME,
                AccountManager.AUTHENTICATOR_ATTRIBUTES_NAME, sSerializer);
    }

    public AuthenticatorDescription parseServiceAttributes(String packageName, AttributeSet attrs) {
@@ -62,4 +70,16 @@ import android.text.TextUtils;
            sa.recycle();
        }
    }

    private static class MySerializer implements XmlSerializerAndParser<AuthenticatorDescription> {
        public void writeAsXml(AuthenticatorDescription item, XmlSerializer out)
                throws IOException {
            out.attribute(null, "type", item.type);
        }

        public AuthenticatorDescription createFromXml(XmlPullParser parser)
                throws IOException, XmlPullParserException {
            return AuthenticatorDescription.newKey(parser.getAttributeValue(null, "type"));
        }
    }
}
+8 −13
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ import com.android.internal.telephony.TelephonyIntents;
 */
public class AccountManagerService
        extends IAccountManager.Stub
        implements RegisteredServicesCacheListener {
        implements RegisteredServicesCacheListener<AuthenticatorDescription> {
    private static final String GOOGLE_ACCOUNT_TYPE = "com.google";

    private static final String NO_BROADCAST_FLAG = "nobroadcast";
@@ -221,33 +221,28 @@ public class AccountManagerService
        mMessageHandler = new MessageHandler(mMessageThread.getLooper());

        mAuthenticatorCache = new AccountAuthenticatorCache(mContext);
        mAuthenticatorCache.setListener(this);
        mAuthenticatorCache.setListener(this, null /* Handler */);

        mSimWatcher = new SimWatcher(mContext);
        sThis.set(this);

        onRegisteredServicesCacheChanged();
    }

    public void onRegisteredServicesCacheChanged() {
    public void onServiceChanged(AuthenticatorDescription desc, boolean removed) {
        boolean accountDeleted = false;
        SQLiteDatabase db = mOpenHelper.getWritableDatabase();
        Cursor cursor = db.query(TABLE_ACCOUNTS,
                new String[]{ACCOUNTS_ID, ACCOUNTS_TYPE, ACCOUNTS_NAME},
                null, null, null, null, null);
                ACCOUNTS_TYPE + "=?", new String[]{desc.type}, null, null, null);
        try {
            while (cursor.moveToNext()) {
                final long accountId = cursor.getLong(0);
                final String accountType = cursor.getString(1);
                final String accountName = cursor.getString(2);
                if (mAuthenticatorCache.getServiceInfo(AuthenticatorDescription.newKey(accountType))
                        == null) {
                Log.d(TAG, "deleting account " + accountName + " because type "
                        + accountType + " no longer has a registered authenticator");
                db.delete(TABLE_ACCOUNTS, ACCOUNTS_ID + "=" + accountId, null);
                accountDeleted = true;
            }
            }
        } finally {
            cursor.close();
            if (accountDeleted) {
+4 −0
Original line number Diff line number Diff line
@@ -87,6 +87,10 @@ public class AuthenticatorDescription implements Parcelable {
        return type.equals(other.type);
    }

    public String toString() {
        return "AuthenticatorDescription {type=" + type + "}";
    }

    /** @inhericDoc */
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(type);
+2 −0
Original line number Diff line number Diff line
@@ -135,6 +135,8 @@ public abstract class AbstractSyncableContentProvider extends SyncableContentPro
        public void onCreate(SQLiteDatabase db) {
            bootstrapDatabase(db);
            mSyncState.createDatabase(db);
            ContentResolver.requestSync(null /* all accounts */,
                    mContentUri.getAuthority(), new Bundle());
        }

        @Override
+22 −2
Original line number Diff line number Diff line
@@ -17,9 +17,14 @@
package android.content;

import android.content.pm.RegisteredServicesCache;
import android.content.pm.XmlSerializerAndParser;
import android.content.res.TypedArray;
import android.content.Context;
import android.util.AttributeSet;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlSerializer;
import org.xmlpull.v1.XmlPullParserException;

import java.io.IOException;

/**
 * A cache of services that export the {@link android.content.ISyncAdapter} interface.
@@ -31,9 +36,10 @@ import android.util.AttributeSet;
    private static final String SERVICE_INTERFACE = "android.content.SyncAdapter";
    private static final String SERVICE_META_DATA = "android.content.SyncAdapter";
    private static final String ATTRIBUTES_NAME = "sync-adapter";
    private static final MySerializer sSerializer = new MySerializer();

    SyncAdaptersCache(Context context) {
        super(context, SERVICE_INTERFACE, SERVICE_META_DATA, ATTRIBUTES_NAME);
        super(context, SERVICE_INTERFACE, SERVICE_META_DATA, ATTRIBUTES_NAME, sSerializer);
    }

    public SyncAdapterType parseServiceAttributes(String packageName, AttributeSet attrs) {
@@ -57,4 +63,18 @@ import android.util.AttributeSet;
            sa.recycle();
        }
    }

    static class MySerializer implements XmlSerializerAndParser<SyncAdapterType> {
        public void writeAsXml(SyncAdapterType item, XmlSerializer out) throws IOException {
            out.attribute(null, "authority", item.authority);
            out.attribute(null, "accountType", item.accountType);
        }
    
        public SyncAdapterType createFromXml(XmlPullParser parser)
                throws IOException, XmlPullParserException {
            final String authority = parser.getAttributeValue(null, "authority");
            final String accountType = parser.getAttributeValue(null, "accountType");
            return SyncAdapterType.newKey(authority, accountType);
        }
    }
}
 No newline at end of file
Loading