-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#52516] android-client: Handle unreachable network during app startup
Previously, we required MAC address discovery to succeed during MainActivity creation. This caused the app to crash when the network wasn't yet accessible during startup. This removes that requirement, and MAC address discovery now happens lazily and is cached for the entire duration of the app's runtime.
- Loading branch information
Showing
6 changed files
with
96 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...oid-client/app/src/main/java/com/antmicro/update/rdfm/exceptions/DeviceInfoException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.antmicro.update.rdfm.exceptions; | ||
|
||
public class DeviceInfoException extends Exception { | ||
public DeviceInfoException(String message) { | ||
super(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...es/android-client/app/src/main/java/com/antmicro/update/rdfm/mgmt/DeviceInfoProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.antmicro.update.rdfm.mgmt; | ||
|
||
import com.antmicro.update.rdfm.exceptions.DeviceInfoException; | ||
import com.antmicro.update.rdfm.utilities.SysUtils; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import kotlin.contracts.Returns; | ||
|
||
public class DeviceInfoProvider { | ||
private String mDeviceMAC; | ||
|
||
public DeviceInfoProvider() { | ||
} | ||
|
||
/** | ||
* Get the device MAC to be used as a unique device identifier. | ||
* | ||
* @return device MAC | ||
*/ | ||
public String getDeviceMAC() throws DeviceInfoException { | ||
if (mDeviceMAC == null) { | ||
try { | ||
mDeviceMAC = SysUtils.findDeviceMAC(); | ||
} catch (RuntimeException e) { | ||
throw new DeviceInfoException(e.getMessage()); | ||
} | ||
} | ||
return mDeviceMAC; | ||
} | ||
|
||
/** | ||
* Get the device type identifier | ||
* | ||
* @return device type string | ||
*/ | ||
public String getDeviceType() { | ||
return SysUtils.getDeviceType(); | ||
} | ||
|
||
/** | ||
* Get the unique software version identifier | ||
* | ||
* @return software version identifier | ||
*/ | ||
public String getSoftwareVersion() { | ||
return SysUtils.getBuildVersion(); | ||
} | ||
|
||
/** | ||
* Save the metadata of the device as a map of Strings to String values. | ||
* | ||
* @return device metadata in map form | ||
*/ | ||
public Map<String, String> toMap() throws DeviceInfoException { | ||
Map<String, String> devParams = new HashMap<>(); | ||
devParams.put("rdfm.software.version", getSoftwareVersion()); | ||
devParams.put("rdfm.hardware.macaddr", getDeviceMAC()); | ||
devParams.put("rdfm.hardware.devtype", getDeviceType()); | ||
return devParams; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters