package com.basic.security.manager;
|
|
import com.basic.security.base.BaseApplication;
|
import com.basic.security.manager.impl.sqlite.SlDeviceManager;
|
import com.basic.security.utils.IpUtils;
|
|
import org.apache.commons.io.IOUtils;
|
|
import java.io.File;
|
import java.io.FileWriter;
|
import java.io.IOException;
|
|
public class DeviceManager extends BaseManager {
|
// bufferReader和bufferWriter比fileWriter和fileReader 效率高,
|
public static String company_id = "";
|
// public static String couchbase_server_ip = "";
|
// public static String port = "";
|
public static String device_id = "security";
|
|
public static String getDeviceId() {
|
return SlDeviceManager.getDeviceId();
|
// if (device_id != null && device_id.length() > 0) {
|
// return device_id;
|
// }
|
// File deviceIdFile = new File("/sdcard/device_id.txt");
|
// FileReader fileReader = null;
|
// if (deviceIdFile.exists()) {
|
// try {
|
// fileReader = new FileReader(deviceIdFile);
|
// List<String> lines = IOUtils.readLines(fileReader);
|
// if (lines.size() > 0) {
|
// device_id = lines.get(0);
|
// }
|
// } catch (IOException e) {
|
// e.printStackTrace();
|
// } finally {
|
// try {
|
// if (fileReader != null) {
|
// fileReader.close();
|
// }
|
// } catch (Exception e) {
|
//
|
// }
|
// }
|
// }
|
// return device_id;
|
}
|
|
public static String getCompareId() {
|
return company_id;
|
}
|
|
public static void writeDeviceId(String newDeviceId) {
|
File deviceIdFile = new File("/sdcard/device_id.txt");
|
if (!deviceIdFile.exists()) {
|
try {
|
deviceIdFile.createNewFile();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
try {
|
FileWriter fileWriter = new FileWriter(deviceIdFile);
|
IOUtils.write(newDeviceId.getBytes(), fileWriter);
|
fileWriter.flush();
|
fileWriter.close();
|
} catch (IOException e) {
|
e.printStackTrace();
|
} finally {
|
|
}
|
}
|
|
public static String getDeviceIp() {
|
return IpUtils.getIpAddress(BaseApplication.getApplication());
|
}
|
}
|