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

Commit 7b651aaa authored by voidstarstar's avatar voidstarstar Committed by Marvin W.
Browse files

Unregister app if fully removed or data is cleared

This fixes a bug where apps were not properly unregistered on Android
8.0+ systems. Also update the log message.
parent 2a21b8ad
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -250,7 +250,8 @@

        <receiver android:name="org.microg.gms.gcm.UnregisterReceiver">
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_ADDED"/>
                <action android:name="android.intent.action.PACKAGE_DATA_CLEARED"/>
                <action android:name="android.intent.action.PACKAGE_FULLY_REMOVED"/>
                <action android:name="android.intent.action.PACKAGE_REMOVED"/>

                <data android:scheme="package"/>
+8 −2
Original line number Diff line number Diff line
@@ -8,7 +8,10 @@ import android.util.Log;
import java.util.List;

import static android.content.Intent.ACTION_PACKAGE_REMOVED;
import static android.content.Intent.ACTION_PACKAGE_DATA_CLEARED;
import static android.content.Intent.ACTION_PACKAGE_FULLY_REMOVED;
import static android.content.Intent.EXTRA_DATA_REMOVED;
import static android.content.Intent.EXTRA_REPLACING;

public class UnregisterReceiver extends BroadcastReceiver {
    private static final String TAG = "GmsGcmUnregisterRcvr";
@@ -16,10 +19,13 @@ public class UnregisterReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(final Context context, Intent intent) {
        Log.d(TAG, "Package changed: " + intent);
        if (ACTION_PACKAGE_REMOVED.contains(intent.getAction()) && intent.getBooleanExtra(EXTRA_DATA_REMOVED, false)) {
        if ((ACTION_PACKAGE_REMOVED.contains(intent.getAction()) && intent.getBooleanExtra(EXTRA_DATA_REMOVED, false) &&
                !intent.getBooleanExtra(EXTRA_REPLACING, false)) ||
                ACTION_PACKAGE_FULLY_REMOVED.contains(intent.getAction()) ||
                ACTION_PACKAGE_DATA_CLEARED.contains(intent.getAction())) {
            final GcmDatabase database = new GcmDatabase(context);
            final String packageName = intent.getData().getSchemeSpecificPart();
            Log.d(TAG, "Package removed: " + packageName);
            Log.d(TAG, "Package removed or data cleared: " + packageName);
            final GcmDatabase.App app = database.getApp(packageName);
            if (app != null) {
                new Thread(new Runnable() {