Harden Device.getDeviceId()
* If we read a null deviceName, delete the file and create a new one. Bug: 3506362 Change-Id: Ida670db2f4b75cb9c94636a0af541ae5df50addf
This commit is contained in:
parent
4ef0960790
commit
a6de89e79c
|
@ -59,9 +59,16 @@ public class Device {
|
||||||
rdr = new BufferedReader(new FileReader(f), 128);
|
rdr = new BufferedReader(new FileReader(f), 128);
|
||||||
id = rdr.readLine();
|
id = rdr.readLine();
|
||||||
rdr.close();
|
rdr.close();
|
||||||
// STOPSHIP Remove logging
|
if (id == null) {
|
||||||
Log.w(Logging.LOG_TAG, "deviceId read as: " + id);
|
// It's very bad if we read a null device id; let's delete that file
|
||||||
return id;
|
if (!f.delete()) {
|
||||||
|
Log.e(Logging.LOG_TAG, "Can't delete null deviceName file; try overwrite.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// STOPSHIP Remove logging
|
||||||
|
Log.w(Logging.LOG_TAG, "deviceId read as: " + id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.w(Logging.LOG_TAG, f.getAbsolutePath() + ": File exists, but can't read?" +
|
Log.w(Logging.LOG_TAG, f.getAbsolutePath() + ": File exists, but can't read?" +
|
||||||
" Trying to remove.");
|
" Trying to remove.");
|
||||||
|
|
Loading…
Reference in New Issue