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

Commit 8c0397a1 authored by Daniel Lehmann's avatar Daniel Lehmann Committed by Android (Google) Code Review
Browse files

Merge "Don't declare package-listener in Manifest but instead in code."

parents 5d5aea3e 90921b3b
Loading
Loading
Loading
Loading
+0 −20
Original line number Diff line number Diff line
@@ -409,26 +409,6 @@
            </intent-filter>
        </activity>

        <!-- Flushes the QuickContact IntentCache -->
        <receiver android:name=".quickcontact.PackageIntentReceiver">
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_ADDED" />
                <data android:scheme="package" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_REPLACED" />
                <data android:scheme="package" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_REMOVED" />
                <data android:scheme="package" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_CHANGED" />
                <data android:scheme="package" />
            </intent-filter>
        </receiver>

        <activity-alias android:name="ContactShortcut"
            android:targetActivity=".activities.ContactSelectionActivity"
            android:label="@string/shortcutContact"
+0 −32
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.contacts.quickcontact;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

/**
 * Package intent receiver that flushes the {@link ResolveCache} so that Packages are rescanned next
 * time
 */
public class PackageIntentReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        ResolveCache.flush();
    }
}
+0 −1
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.contacts.quickcontact;

import com.android.contacts.Collapser;
import com.android.contacts.ContactPhotoManager;
import com.android.contacts.ContactPresenceIconUtil;
import com.android.contacts.R;
import com.android.contacts.model.AccountTypeManager;
import com.android.contacts.model.DataKind;
+22 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.contacts.quickcontact;
import com.android.contacts.util.PhoneCapabilityTester;
import com.google.android.collect.Sets;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -65,15 +66,34 @@ public class ResolveCache {
     */
    public synchronized static ResolveCache getInstance(Context context) {
        if (sInstance == null) {
            return sInstance = new ResolveCache(context.getApplicationContext());
            final Context applicationContext = context.getApplicationContext();
            sInstance = new ResolveCache(applicationContext);

            // Register for package-changes so that we can flush our cache
            final IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
            filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
            filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
            filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
            filter.addDataScheme("package");
            applicationContext.registerReceiver(sInstance.mPackageIntentReceiver, filter);
        }
        return sInstance;
    }

    public synchronized static void flush() {
    private synchronized static void flush() {
        sInstance = null;
    }

    /**
     * Called anytime a package is installed, uninstalled etc, so that we can wipe our cache
     */
    private BroadcastReceiver mPackageIntentReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            flush();
        }
    };

    /**
     * Cached entry holding the best {@link ResolveInfo} for a specific
     * MIME-type, along with a {@link SoftReference} to its icon.