2017-11-05 14:17:09 +00:00
|
|
|
package eu.faircode.netguard;
|
|
|
|
|
|
|
|
/*
|
|
|
|
This file is part of NetGuard.
|
|
|
|
|
|
|
|
NetGuard is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
NetGuard is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with NetGuard. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2018-12-31 16:12:49 +00:00
|
|
|
Copyright 2015-2019 by Marcel Bokhorst (M66B)
|
2017-11-05 14:17:09 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.util.Log;
|
|
|
|
|
2018-11-17 16:32:36 +00:00
|
|
|
import androidx.core.app.NotificationManagerCompat;
|
2017-11-05 14:17:09 +00:00
|
|
|
|
|
|
|
public class ReceiverPackageRemoved extends BroadcastReceiver {
|
|
|
|
private static final String TAG = "NetGuard.Receiver";
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onReceive(final Context context, Intent intent) {
|
|
|
|
Log.i(TAG, "Received " + intent);
|
|
|
|
Util.logExtras(intent);
|
|
|
|
|
2019-02-20 16:42:37 +00:00
|
|
|
String action = (intent == null ? null : intent.getAction());
|
|
|
|
if (Intent.ACTION_PACKAGE_FULLY_REMOVED.equals(action)) {
|
|
|
|
int uid = intent.getIntExtra(Intent.EXTRA_UID, 0);
|
|
|
|
if (uid > 0) {
|
|
|
|
DatabaseHelper dh = DatabaseHelper.getInstance(context);
|
|
|
|
dh.clearLog(uid);
|
|
|
|
dh.clearAccess(uid, false);
|
|
|
|
|
|
|
|
NotificationManagerCompat.from(context).cancel(uid); // installed notification
|
|
|
|
NotificationManagerCompat.from(context).cancel(uid + 10000); // access notification
|
|
|
|
}
|
2017-11-05 14:17:09 +00:00
|
|
|
}
|
|
|
|
}
|
2017-12-24 09:12:10 +00:00
|
|
|
}
|