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

Commit 102f6806 authored by Doug Zongker's avatar Doug Zongker Committed by android-build SharedAccount
Browse files

make android_id random seed depend on time as well as ro.serialno

Change-Id: I0a48aacd8da30896d91fa05b7791335e6ed751e5
parent 382872e3
Loading
Loading
Loading
Loading
+4 −9
Original line number Diff line number Diff line
@@ -222,16 +222,11 @@ 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
                    }
                }
                String serial = SystemProperties.get("ro.serialno", "");
                random.setSeed(
                    (serial + System.nanoTime() + new SecureRandom().nextLong()).getBytes());
                final String newAndroidIdValue = Long.toHexString(random.nextLong());
                Log.d(TAG, "Generated and saved new ANDROID_ID");
                Log.d(TAG, "Generated and saved new ANDROID_ID [" + newAndroidIdValue + "]");
                final ContentValues values = new ContentValues();
                values.put(Settings.NameValueTable.NAME, Settings.Secure.ANDROID_ID);
                values.put(Settings.NameValueTable.VALUE, newAndroidIdValue);