mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 22:29:53 +01:00
Offline hotspot: don't crash if group is null
This commit is contained in:
@@ -312,12 +312,19 @@ class HotspotManager {
|
|||||||
}
|
}
|
||||||
GroupInfoListener groupListener = group -> {
|
GroupInfoListener groupListener = group -> {
|
||||||
boolean valid = isGroupValid(group);
|
boolean valid = isGroupValid(group);
|
||||||
// If the group is valid, set the hotspot to started. If we don't
|
if (valid) {
|
||||||
// have any attempts left, we try what we got
|
// the group is valid, set the hotspot to started.
|
||||||
if (valid || attempt >= MAX_GROUP_INFO_ATTEMPTS) {
|
onHotspotStarted(group);
|
||||||
|
} else if (attempt < MAX_GROUP_INFO_ATTEMPTS) {
|
||||||
|
// we have attempts left, try again
|
||||||
|
retryRequestingGroupInfo(attempt);
|
||||||
|
} else if (group != null) {
|
||||||
|
// no attempts left, but group is not null, try what we got
|
||||||
onHotspotStarted(group);
|
onHotspotStarted(group);
|
||||||
} else {
|
} else {
|
||||||
retryRequestingGroupInfo(attempt);
|
// no attempts left and group is null, fail
|
||||||
|
releaseHotspotWithError(ctx.getString(
|
||||||
|
R.string.hotspot_error_start_callback_no_group_info));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
@@ -366,13 +373,8 @@ class HotspotManager {
|
|||||||
private void retryRequestingGroupInfo(int attempt) {
|
private void retryRequestingGroupInfo(int attempt) {
|
||||||
LOG.info("retrying to request group info");
|
LOG.info("retrying to request group info");
|
||||||
// On some devices we need to wait for the group info to become available
|
// On some devices we need to wait for the group info to become available
|
||||||
if (attempt < MAX_GROUP_INFO_ATTEMPTS) {
|
handler.postDelayed(() -> requestGroupInfo(attempt + 1),
|
||||||
handler.postDelayed(() -> requestGroupInfo(attempt + 1),
|
RETRY_DELAY_MILLIS);
|
||||||
RETRY_DELAY_MILLIS);
|
|
||||||
} else {
|
|
||||||
releaseHotspotWithError(ctx.getString(
|
|
||||||
R.string.hotspot_error_start_callback_no_group_info));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
|
|||||||
Reference in New Issue
Block a user