am 0fe27cf5: make android_id random seed depend on time as well as ro.serialno
Merge commit '0fe27cf5bd1407bc7b4eabefaa91ff535582badc' into gingerbread * commit '0fe27cf5bd1407bc7b4eabefaa91ff535582badc': make android_id random seed depend on time as well as ro.serialno
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user