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

Commit b52ef42a authored by Walter Jang's avatar Walter Jang Committed by android-build-merger
Browse files

Enable group member edits for external accounts

am: 0fed9b62

Change-Id: I5be4e8686bddabbae1a316db857049481c08e5ae
parents b179625a 0fed9b62
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -595,7 +595,7 @@ class AccountTypeManagerImpl extends AccountTypeManager
                                    && accountWithDataSet.dataSet == null) {
                                foundWritableGoogleAccount = true;
                            }
                        }

                            if (accountType.isGroupMembershipEditable()) {
                                groupWritableAccounts.add(accountWithDataSet);
                            }
@@ -603,6 +603,7 @@ class AccountTypeManagerImpl extends AccountTypeManager
                    }
                }
            }
        }

        final DeviceLocalAccountLocator deviceAccounts =
                new DeviceLocalAccountLocator(mContext.getContentResolver(),
@@ -632,11 +633,12 @@ class AccountTypeManagerImpl extends AccountTypeManager
            }
            if (localAccountType.areContactsWritable()) {
                contactWritableAccounts.add(localAccount);
            }

                if (localAccountType.isGroupMembershipEditable()) {
                    groupWritableAccounts.add(localAccount);
                }
            }
        }

        final AccountComparator accountComparator = new AccountComparator(null);
        Collections.sort(allAccounts, accountComparator);
+10 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.pm.ServiceInfo;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.provider.ContactsContract.CommonDataKinds.GroupMembership;
import android.provider.ContactsContract.CommonDataKinds.Photo;
import android.provider.ContactsContract.CommonDataKinds.StructuredName;
import android.text.TextUtils;
@@ -101,6 +102,7 @@ public class ExternalAccountType extends BaseAccountType {
    private String mAccountTypeIconAttribute;
    private boolean mHasContactsMetadata;
    private boolean mHasEditSchema;
    private boolean mGroupMembershipEditable;

    public ExternalAccountType(Context context, String resPackageName, boolean isExtension) {
        this(context, resPackageName, isExtension, null);
@@ -172,6 +174,9 @@ public class ExternalAccountType extends BaseAccountType {
        iconRes = resolveExternalResId(context, mAccountTypeIconAttribute,
                syncAdapterPackageName, ATTR_ACCOUNT_ICON);

        final DataKind dataKind = getKindForMimetype(GroupMembership.CONTENT_ITEM_TYPE);
        mGroupMembershipEditable = dataKind != null && dataKind.editable;

        // If we reach this point, the account type has been successfully initialized.
        mIsInitialized = true;
    }
@@ -293,6 +298,11 @@ public class ExternalAccountType extends BaseAccountType {
        return mExtensionPackageNames;
    }

    @Override
    public boolean isGroupMembershipEditable() {
        return mGroupMembershipEditable;
    }

    /**
     * Inflate this {@link AccountType} from the given parser. This may only
     * load details matching the publicly-defined schema.