make android_id random seed depend on time as well as ro.serialno
Change-Id: I0a48aacd8da30896d91fa05b7791335e6ed751e5
This commit is contained in:
@@ -222,16 +222,11 @@ public class SettingsProvider extends ContentProvider {
|
|||||||
final String value = c.moveToNext() ? c.getString(0) : null;
|
final String value = c.moveToNext() ? c.getString(0) : null;
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
final SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
|
final SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
|
||||||
String serial = SystemProperties.get("ro.serialno");
|
String serial = SystemProperties.get("ro.serialno", "");
|
||||||
if (serial != null) {
|
random.setSeed(
|
||||||
try {
|
(serial + System.nanoTime() + new SecureRandom().nextLong()).getBytes());
|
||||||
random.setSeed(serial.getBytes("UTF-8"));
|
|
||||||
} catch (UnsupportedEncodingException ignore) {
|
|
||||||
// stick with default seed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final String newAndroidIdValue = Long.toHexString(random.nextLong());
|
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();
|
final ContentValues values = new ContentValues();
|
||||||
values.put(Settings.NameValueTable.NAME, Settings.Secure.ANDROID_ID);
|
values.put(Settings.NameValueTable.NAME, Settings.Secure.ANDROID_ID);
|
||||||
values.put(Settings.NameValueTable.VALUE, newAndroidIdValue);
|
values.put(Settings.NameValueTable.VALUE, newAndroidIdValue);
|
||||||
|
|||||||
Reference in New Issue
Block a user