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

Commit 9cf1a5a0 authored by Doug Zongker's avatar Doug Zongker Committed by Android (Google) Code Review
Browse files

Merge "use device serial number to seed RNG for generating ANDROID_ID"

parents 6511fe9c 4f8ff39c
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -17,9 +17,10 @@
package com.android.providers.settings;

import java.io.FileNotFoundException;
import java.util.Random;
import java.security.SecureRandom;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Random;

import android.backup.BackupManager;
import android.content.ContentProvider;
@@ -197,6 +198,14 @@ public class SettingsProvider extends ContentProvider {
            final String value = c.moveToNext() ? c.getString(0) : null;
            if (value == null) {
                final SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
                String serial = SystemProperties.get("ro.serialno");
                if (serial != null) {
                    try {
                        random.setSeed(serial.getBytes("UTF-8"));
                    } catch (UnsupportedEncodingException ignore) {
                        // stick with default seed
                    }
                }
                final String newAndroidIdValue = Long.toHexString(random.nextLong());
                Log.d(TAG, "Generated and saved new ANDROID_ID");
                final ContentValues values = new ContentValues();