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

Commit 511504f9 authored by Marcus Hagerott's avatar Marcus Hagerott
Browse files

Check flag before adding observer in AccountTypeManager

The content observer in AccountTypeManager is only needed if OEM device
account detection is enabled.

Test
Observed logs to verify account type manager doesn't update after a
contact is added

Bug 32312206

Change-Id: Iab99d136055d0809698116d074014218a1e996d5
parent b9065ddb
Loading
Loading
Loading
Loading
+23 −18
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.util.Log;
import android.util.TimingLogger;

import com.android.contacts.R;
import com.android.contacts.common.Experiments;
import com.android.contacts.common.MoreContactUtils;
import com.android.contacts.common.list.ContactListFilterController;
import com.android.contacts.common.model.account.AccountType;
@@ -59,6 +60,7 @@ import com.android.contacts.common.model.dataitem.DataKind;
import com.android.contacts.common.util.Constants;
import com.android.contacts.common.util.DeviceLocalAccountTypeFactory;
import com.android.contactsbind.ObjectFactory;
import com.android.contactsbind.experiments.Flags;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Objects;
import com.google.common.base.Predicate;
@@ -464,6 +466,8 @@ class AccountTypeManagerImpl extends AccountTypeManager

        ContentResolver.addStatusChangeListener(ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS, this);


        if (Flags.getInstance().getBoolean(Experiments.OEM_CP2_DEVICE_ACCOUNT_DETECTION_ENABLED)) {
            // Observe changes to RAW_CONTACTS so that we will update the list of "Device" accounts
            // if a new device contact is added.
            mContext.getContentResolver().registerContentObserver(
@@ -484,6 +488,7 @@ class AccountTypeManagerImpl extends AccountTypeManager
                            mListenerHandler.sendEmptyMessage(MESSAGE_LOAD_DATA);
                        }
                    });
        }

        mListenerHandler.sendEmptyMessage(MESSAGE_LOAD_DATA);
    }