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

Commit bc5fd7fd authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Refresh USER_SENSITIVE flags on package changes"

parents e34def6c 542ff3d7
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -29,8 +29,10 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.app.AppOpsManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
@@ -169,6 +171,23 @@ public final class PermissionPolicyService extends SystemService {
        } catch (RemoteException doesNotHappen) {
            Slog.wtf(LOG_TAG, "Cannot set up app-ops listener");
        }

        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
        intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
        intentFilter.addDataScheme("package");

        getContext().registerReceiverAsUser(new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                UserHandle user =
                        UserHandle.getUserHandleForUid(intent.getIntExtra(Intent.EXTRA_UID, -1));
                new PermissionControllerManager(
                        getUserContext(getContext(), user), FgThread.getHandler())
                        .updateUserSensitive();
            }
        }, UserHandle.ALL, intentFilter, null, null);

    }

    /**