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

Commit fdd58be7 authored by Jing Ji's avatar Jing Ji Committed by Automerger Merge Worker
Browse files

Merge "Use ArrayMap instead of SparseArray to manage the ProviderKey" into...

Merge "Use ArrayMap instead of SparseArray to manage the ProviderKey" into sc-dev am: d5ea86ea am: 9fd02e1b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15664720

Change-Id: Iecb1bc15167e2c3b51826fd5bc36d96affe1a559
parents 77b764bc 9fd02e1b
Loading
Loading
Loading
Loading
+4 −8
Original line number Original line Diff line number Diff line
@@ -466,11 +466,7 @@ public final class ActivityThread extends ClientTransactionHandler


        @Override
        @Override
        public int hashCode() {
        public int hashCode() {
            return hashCode(authority, userId);
            return ((authority != null) ? authority.hashCode() : 0) ^ userId;
        }

        public static int hashCode(final String auth, final int userIdent) {
            return ((auth != null) ? auth.hashCode() : 0) ^ userIdent;
        }
        }
    }
    }


@@ -492,7 +488,7 @@ public final class ActivityThread extends ClientTransactionHandler
    // Note we never removes items from this map but that's okay because there are only so many
    // Note we never removes items from this map but that's okay because there are only so many
    // users and so many authorities.
    // users and so many authorities.
    @GuardedBy("mGetProviderKeys")
    @GuardedBy("mGetProviderKeys")
    final SparseArray<ProviderKey> mGetProviderKeys = new SparseArray<>();
    final ArrayMap<ProviderKey, ProviderKey> mGetProviderKeys = new ArrayMap<>();


    final ArrayMap<Activity, ArrayList<OnActivityPausedListener>> mOnPauseListeners
    final ArrayMap<Activity, ArrayList<OnActivityPausedListener>> mOnPauseListeners
        = new ArrayMap<Activity, ArrayList<OnActivityPausedListener>>();
        = new ArrayMap<Activity, ArrayList<OnActivityPausedListener>>();
@@ -6992,11 +6988,11 @@ public final class ActivityThread extends ClientTransactionHandler
    }
    }


    private ProviderKey getGetProviderKey(String auth, int userId) {
    private ProviderKey getGetProviderKey(String auth, int userId) {
        final int key = ProviderKey.hashCode(auth, userId);
        final ProviderKey key = new ProviderKey(auth, userId);
        synchronized (mGetProviderKeys) {
        synchronized (mGetProviderKeys) {
            ProviderKey lock = mGetProviderKeys.get(key);
            ProviderKey lock = mGetProviderKeys.get(key);
            if (lock == null) {
            if (lock == null) {
                lock = new ProviderKey(auth, userId);
                lock = key;
                mGetProviderKeys.put(key, lock);
                mGetProviderKeys.put(key, lock);
            }
            }
            return lock;
            return lock;