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

Commit 6752cba4 authored by Nick Kralevich's avatar Nick Kralevich Committed by Android (Google) Code Review
Browse files

Merge "ConfigUpdateInstallReceiver: pass content via content provider"

parents e7ef59a7 103173e1
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2896,36 +2896,42 @@
        <receiver android:name="com.android.server.updates.CertPinInstallReceiver" >
            <intent-filter>
                <action android:name="android.intent.action.UPDATE_PINS" />
                <data android:scheme="content" android:host="*" android:mimeType="*/*" />
            </intent-filter>
        </receiver>

        <receiver android:name="com.android.server.updates.IntentFirewallInstallReceiver" >
            <intent-filter>
                <action android:name="android.intent.action.UPDATE_INTENT_FIREWALL" />
                <data android:scheme="content" android:host="*" android:mimeType="*/*" />
            </intent-filter>
        </receiver>

        <receiver android:name="com.android.server.updates.SmsShortCodesInstallReceiver" >
            <intent-filter>
                <action android:name="android.intent.action.UPDATE_SMS_SHORT_CODES" />
                <data android:scheme="content" android:host="*" android:mimeType="*/*" />
            </intent-filter>
        </receiver>

        <receiver android:name="com.android.server.updates.CarrierProvisioningUrlsInstallReceiver" >
            <intent-filter>
                <action android:name="android.intent.action.UPDATE_CARRIER_PROVISIONING_URLS" />
                <data android:scheme="content" android:host="*" android:mimeType="*/*" />
            </intent-filter>
        </receiver>

        <receiver android:name="com.android.server.updates.TZInfoInstallReceiver" >
            <intent-filter>
                <action android:name="android.intent.action.UPDATE_TZINFO" />
                <data android:scheme="content" android:host="*" android:mimeType="*/*" />
            </intent-filter>
        </receiver>

        <receiver android:name="com.android.server.updates.SELinuxPolicyInstallReceiver" >
            <intent-filter>
                <action android:name="android.intent.action.UPDATE_SEPOLICY" />
                <data android:scheme="content" android:host="*" android:mimeType="*/*" />
            </intent-filter>
        </receiver>

+15 −7
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.provider.Settings;
import android.util.Base64;
import android.util.EventLog;
@@ -40,6 +41,7 @@ import java.security.NoSuchAlgorithmException;
import java.security.Signature;

import libcore.io.IoUtils;
import libcore.io.Streams;

public class ConfigUpdateInstallReceiver extends BroadcastReceiver {

@@ -73,7 +75,7 @@ public class ConfigUpdateInstallReceiver extends BroadcastReceiver {
                    // get the certificate from Settings.Secure
                    X509Certificate cert = getCert(context.getContentResolver());
                    // get the content path from the extras
                    byte[] altContent = getAltContent(intent);
                    byte[] altContent = getAltContent(context, intent);
                    // get the version from the extras
                    int altVersion = getVersionFromIntent(intent);
                    // get the previous value from the extras
@@ -127,12 +129,12 @@ public class ConfigUpdateInstallReceiver extends BroadcastReceiver {
        }
    }

    private String getContentFromIntent(Intent i) {
        String extraValue = i.getStringExtra(EXTRA_CONTENT_PATH);
        if (extraValue == null) {
    private Uri getContentFromIntent(Intent i) {
        Uri data = i.getData();
        if (data == null) {
            throw new IllegalStateException("Missing required content path, ignoring.");
        }
        return extraValue;
        return data;
    }

    private int getVersionFromIntent(Intent i) throws NumberFormatException {
@@ -169,8 +171,14 @@ public class ConfigUpdateInstallReceiver extends BroadcastReceiver {
        }
    }

    private byte[] getAltContent(Intent i) throws IOException {
        return IoUtils.readFileAsByteArray(getContentFromIntent(i));
    private byte[] getAltContent(Context c, Intent i) throws IOException {
        Uri content = getContentFromIntent(i);
        InputStream is = c.getContentResolver().openInputStream(content);
        try {
            return Streams.readFullyNoClose(is);
        } finally {
            is.close();
        }
    }

    private byte[] getCurrentContent() {