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

Commit 7a129270 authored by Danesh M's avatar Danesh M
Browse files

Revert lockscreen shortcuts if app uninstalled (2/2)

CYNGNOS-1374

Change-Id: I12bfa1d0b73fa301116f0fe268d90a01401c642e
parent db5ca869
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2390,5 +2390,11 @@
            android:name=".cyanogenmod.LtoService">
        </service>

        <receiver android:name=".cyanogenmod.ShortcutCleanupReceiver">
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_REMOVED" />
                <data android:scheme="package"></data>
            </intent-filter>
        </receiver>
    </application>
</manifest>
+49 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The CyanogenMod 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.settings.cyanogenmod;

import com.android.internal.util.cm.LockscreenShortcutsHelper;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;

public class ShortcutCleanupReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        Uri uri = intent.getData();
        if (uri == null) {
            // they sent us a bad intent
            return;
        }

        final String packageName = uri.getSchemeSpecificPart();
        if (TextUtils.isEmpty(packageName)) {
            // they sent us a bad intent
            return;
        }

        cleanupLockscreenShortcuts(context, packageName);
    }

    private void cleanupLockscreenShortcuts(Context context, String packageName) {
        LockscreenShortcutsHelper helper = new LockscreenShortcutsHelper(context, null);
        helper.removeTargetsForPackage(packageName);
    }
}