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

Commit 4f8ff39c authored by Doug Zongker's avatar Doug Zongker
Browse files

use device serial number to seed RNG for generating ANDROID_ID

Change-Id: I1bcc55f1309cb908803bc42084846a046041eda6
parent 2c355e26
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();