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

Commit c340cf49 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Merge tag 'android-5.0.2_r1' into LA.BR.1.2.1"

parents 848b2373 3c964dd8
Loading
Loading
Loading
Loading
+51 −0
Original line number Diff line number Diff line
@@ -22,12 +22,14 @@ import android.os.Parcelable;
import com.android.internal.util.ArrayUtils;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.lang.ref.SoftReference;
import java.security.PublicKey;
import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.Arrays;

/**
@@ -252,4 +254,53 @@ public class Signature implements Parcelable {
        return (a.length == b.length) && ArrayUtils.containsAll(a, b)
                && ArrayUtils.containsAll(b, a);
    }

    /**
     * Test if given {@link Signature} sets are effectively equal. In rare
     * cases, certificates can have slightly malformed encoding which causes
     * exact-byte checks to fail.
     * <p>
     * To identify effective equality, we bounce the certificates through an
     * decode/encode pass before doing the exact-byte check. To reduce attack
     * surface area, we only allow a byte size delta of a few bytes.
     *
     * @throws CertificateException if the before/after length differs
     *             substantially, usually a signal of something fishy going on.
     * @hide
     */
    public static boolean areEffectiveMatch(Signature[] a, Signature[] b)
            throws CertificateException {
        final CertificateFactory cf = CertificateFactory.getInstance("X.509");

        final Signature[] aPrime = new Signature[a.length];
        for (int i = 0; i < a.length; i++) {
            aPrime[i] = bounce(cf, a[i]);
        }
        final Signature[] bPrime = new Signature[b.length];
        for (int i = 0; i < b.length; i++) {
            bPrime[i] = bounce(cf, b[i]);
        }

        return areExactMatch(aPrime, bPrime);
    }

    /**
     * Bounce the given {@link Signature} through a decode/encode cycle.
     *
     * @throws CertificateException if the before/after length differs
     *             substantially, usually a signal of something fishy going on.
     * @hide
     */
    public static Signature bounce(CertificateFactory cf, Signature s) throws CertificateException {
        final InputStream is = new ByteArrayInputStream(s.mSignature);
        final X509Certificate cert = (X509Certificate) cf.generateCertificate(is);
        final Signature sPrime = new Signature(cert.getEncoded());

        if (Math.abs(sPrime.mSignature.length - s.mSignature.length) > 2) {
            throw new CertificateException("Bounced cert length looks fishy; before "
                    + s.mSignature.length + ", after " + sPrime.mSignature.length);
        }

        return sPrime;
    }
}
+63 −0
Original line number Diff line number Diff line
@@ -856,6 +856,38 @@ public interface IMountService extends IInterface {
                }
                return _result;
            }

            @Override
            public long lastMaintenance() throws RemoteException {
                Parcel _data = Parcel.obtain();
                Parcel _reply = Parcel.obtain();
                long _result;
                try {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    mRemote.transact(Stub.TRANSACTION_lastMaintenance, _data, _reply, 0);
                    _reply.readException();
                    _result = _reply.readLong();
                } finally {
                    _reply.recycle();
                    _data.recycle();
                }
                return _result;
            }

            @Override
            public void runMaintenance() throws RemoteException {
                Parcel _data = Parcel.obtain();
                Parcel _reply = Parcel.obtain();
                try {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    mRemote.transact(Stub.TRANSACTION_runMaintenance, _data, _reply, 0);
                    _reply.readException();
                } finally {
                    _reply.recycle();
                    _data.recycle();
                }
                return;
            }
        }

        private static final String DESCRIPTOR = "IMountService";
@@ -942,6 +974,10 @@ public interface IMountService extends IInterface {

        static final int TRANSACTION_resizeSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 40;

        static final int TRANSACTION_lastMaintenance = IBinder.FIRST_CALL_TRANSACTION + 41;

        static final int TRANSACTION_runMaintenance = IBinder.FIRST_CALL_TRANSACTION + 42;

        /**
         * Cast an IBinder object into an IMountService interface, generating a
         * proxy if needed.
@@ -1347,6 +1383,19 @@ public interface IMountService extends IInterface {
                    reply.writeInt(resultCode);
                    return true;
                }
                case TRANSACTION_lastMaintenance: {
                    data.enforceInterface(DESCRIPTOR);
                    long lastMaintenance = lastMaintenance();
                    reply.writeNoException();
                    reply.writeLong(lastMaintenance);
                    return true;
                }
                case TRANSACTION_runMaintenance: {
                    data.enforceInterface(DESCRIPTOR);
                    runMaintenance();
                    reply.writeNoException();
                    return true;
                }
            }
            return super.onTransact(code, data, reply, flags);
        }
@@ -1617,4 +1666,18 @@ public interface IMountService extends IInterface {
    public String getField(String field) throws RemoteException;

    public int resizeSecureContainer(String id, int sizeMb, String key) throws RemoteException;

    /**
     * Report the time of the last maintenance operation such as fstrim.
     * @return Timestamp of the last maintenance operation, in the
     *     System.currentTimeMillis() time base
     * @throws RemoteException
     */
    public long lastMaintenance() throws RemoteException;

    /**
     * Kick off an immediate maintenance operation
     * @throws RemoteException
     */
    public void runMaintenance() throws RemoteException;
}
+7 −0
Original line number Diff line number Diff line
@@ -5914,6 +5914,13 @@ public final class Settings {
        */
       public static final String PACKAGE_VERIFIER_INCLUDE_ADB = "verifier_verify_adb_installs";

       /**
        * Time since last fstrim (milliseconds) after which we force one to happen
        * during device startup.  If unset, the default is 3 days.
        * @hide
        */
       public static final String FSTRIM_MANDATORY_INTERVAL = "fstrim_mandatory_interval";

       /**
        * The interval in milliseconds at which to check packet counts on the
        * mobile data interface when screen is on, to detect possible data
+5 −0
Original line number Diff line number Diff line
@@ -31,4 +31,9 @@
        <item>"*611:+19085594899,BAE0000000000000"</item>
        <item>"*86:+1MDN,BAE0000000000000"</item>
    </string-array>

    <string-array translatable="false" name="config_sms_convert_destination_number_support">
        <item>true;BAE0000000000000</item>
        <item>false</item>
    </string-array>
</resources>
+3 −0
Original line number Diff line number Diff line
@@ -43,5 +43,8 @@
    <!-- Configuration that determines if PROTOCOL_ERRORS is to be treated as
         a permamnent error -->
    <bool name="config_protocol_errors_perm_failure">false</bool>
    <string-array translatable="false" name="config_sms_convert_destination_number_support">
        <item>true</item>
    </string-array>

</resources>
Loading