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

Commit ecdb0d31 authored by Thiébaud Weksteen's avatar Thiébaud Weksteen
Browse files

CertPinInstallReceiver: remove files at boot time

In commit 60fb1aa9, CertPinInstallReceiver was updated to be
disabled when the platform flag was enabled. This prevents fresh devices
from ever installing the pins file. However, the onReceive is not called
unless the version available on the server is different from the current
version (as recorded by ConfigUpdater). Devices upgrading would still
have a lingering version of the pins. Add a clean up stage, ran at boot
time, to remove the files previously installed.

Test: Fresh install with flag disabled; check that pins file is available.
      Enable platform flag and reboot. The pins file and its metadata are gone.
Bug: 391205997
Flag: com.android.server.flags.certpininstaller_removal
Change-Id: I502369e21b5b66a1e413cac0298b0072a904bb2e
parent 9848646d
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -9292,6 +9292,9 @@
                <action android:name="android.intent.action.UPDATE_PINS" />
                <action android:name="android.intent.action.UPDATE_PINS" />
                <data android:scheme="content" android:host="*" android:mimeType="*/*" />
                <data android:scheme="content" android:host="*" android:mimeType="*/*" />
            </intent-filter>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>
        </receiver>


        <receiver android:name="com.android.server.updates.IntentFirewallInstallReceiver"
        <receiver android:name="com.android.server.updates.IntentFirewallInstallReceiver"
+19 −1
Original line number Original line Diff line number Diff line
@@ -19,7 +19,10 @@ package com.android.server.updates;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;


import java.io.File;

public class CertPinInstallReceiver extends ConfigUpdateInstallReceiver {
public class CertPinInstallReceiver extends ConfigUpdateInstallReceiver {
    private static final String KEYCHAIN_DIR = "/data/misc/keychain/";


    public CertPinInstallReceiver() {
    public CertPinInstallReceiver() {
        super("/data/misc/keychain/", "pins", "metadata/", "version");
        super("/data/misc/keychain/", "pins", "metadata/", "version");
@@ -27,7 +30,22 @@ public class CertPinInstallReceiver extends ConfigUpdateInstallReceiver {


    @Override
    @Override
    public void onReceive(final Context context, final Intent intent) {
    public void onReceive(final Context context, final Intent intent) {
        if (!com.android.server.flags.Flags.certpininstallerRemoval()) {
        if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
            if (com.android.server.flags.Flags.certpininstallerRemoval()) {
                File pins = new File(KEYCHAIN_DIR + "pins");
                if (pins.exists()) {
                    pins.delete();
                }
                File version = new File(KEYCHAIN_DIR + "metadata/version");
                if (version.exists()) {
                    version.delete();
                }
                File metadata = new File(KEYCHAIN_DIR + "metadata");
                if (metadata.exists()) {
                    metadata.delete();
                }
            }
        } else if (!com.android.server.flags.Flags.certpininstallerRemoval()) {
            super.onReceive(context, intent);
            super.onReceive(context, intent);
        }
        }
    }
    }