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

Commit fab79a07 authored by pkanwar's avatar pkanwar Committed by Steven Moreland
Browse files

Changes to align with improvements to ImsiEncryptionInfo.

BUG: 35606429
Test: NA
(cherry picked from commit 4e04c6c8)

Merged-In: I625a709ea2eedfbc989dffdbbf38b2e008de38fe
Change-Id: I625a709ea2eedfbc989dffdbbf38b2e008de38fe
parent 8c1374d3
Loading
Loading
Loading
Loading
+2 −13
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;

import android.util.Base64;

@@ -83,16 +84,6 @@ public class TestCertActivity extends Activity {
        mCertUrlView.setText(mURL);
    }

    public static PublicKey makeKeyObject(byte[] publicKeyBytes) {
        try {
            X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(publicKeyBytes);
            return KeyFactory.getInstance("RSA").generatePublic(pubKeySpec);
        } catch (InvalidKeySpecException | NoSuchAlgorithmException ex) {
            Log.e(LOG_TAG, "Error makeKeyObject: unable to convert into PublicKey", ex);
        }
        return null;
    }

    /**
     * Class to get json by making HTTP call
     */
@@ -152,8 +143,6 @@ public class TestCertActivity extends Activity {

        private void savePublicKey(String key, int type, String identifier) {
            byte[] keyBytes = Base64.decode(key.getBytes(), Base64.DEFAULT);
            PublicKey publicKey = makeKeyObject(keyBytes);
            Log.i(LOG_TAG, "generated public key: " + publicKey);
            final TelephonyManager telephonyManager =
                    (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

@@ -168,7 +157,7 @@ public class TestCertActivity extends Activity {
            }

            ImsiEncryptionInfo imsiEncryptionInfo = new ImsiEncryptionInfo(mcc,
                    mnc, type, identifier, publicKey);
                    mnc, type, identifier, keyBytes, new Date());
            telephonyManager.setCarrierInfoForImsiEncryption(imsiEncryptionInfo);
            keyList.add(imsiEncryptionInfo.getKeyType() + "," +
                    imsiEncryptionInfo.getKeyIdentifier());