MCPcopy Index your code
hub / github.com/arduino/Arduino / run

Method run

app/src/processing/app/UpdateCheck.java:66–127  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

64
65
66 public void run() {
67 //System.out.println("checking for updates...");
68
69 long id;
70 String idString = PreferencesData.get("update.id");
71 if (idString != null) {
72 id = Long.parseLong(idString);
73 } else {
74 // generate a random id in case none exists yet
75 Random r = new Random();
76 id = r.nextLong();
77 PreferencesData.set("update.id", String.valueOf(id));
78 }
79
80 try {
81 String info;
82 info = URLEncoder.encode(id + "\t" +
83 PApplet.nf(BaseNoGui.REVISION, 4) + "\t" +
84 System.getProperty("java.version") + "\t" +
85 System.getProperty("java.vendor") + "\t" +
86 System.getProperty("os.name") + "\t" +
87 System.getProperty("os.version") + "\t" +
88 System.getProperty("os.arch"), "UTF-8");
89
90 int latest = readInt(downloadURL + "?" + info);
91
92 String lastString = PreferencesData.get("update.last");
93 long now = System.currentTimeMillis();
94 if (lastString != null) {
95 long when = Long.parseLong(lastString);
96 if (now - when < ONE_DAY) {
97 // don't annoy the shit outta people
98 return;
99 }
100 }
101 PreferencesData.set("update.last", String.valueOf(now));
102
103 String prompt =
104 tr("A new version of Arduino is available,\n" +
105 "would you like to visit the Arduino download page?");
106
107 if (base.activeEditor != null) {
108 if (latest > BaseNoGui.REVISION) {
109 Object[] options = { tr("Yes"), tr("No") };
110 int result = JOptionPane.showOptionDialog(base.activeEditor,
111 prompt,
112 tr("Update"),
113 JOptionPane.YES_NO_OPTION,
114 JOptionPane.QUESTION_MESSAGE,
115 null,
116 options,
117 options[0]);
118 if (result == JOptionPane.YES_OPTION) {
119 Base.openURL("https://www.arduino.cc/en/software");
120 }
121 }
122 }
123 } catch (Exception e) {

Callers

nothing calls this directly

Calls 7

getMethod · 0.95
setMethod · 0.95
nfMethod · 0.95
readIntMethod · 0.95
openURLMethod · 0.95
trMethod · 0.80
valueOfMethod · 0.45

Tested by

no test coverage detected