android: Make sure we actually have a tile when updating it

Not sure when this happens exactly, in particular because the reported
stack traces look like this

java.lang.NullPointerException:
  at org.strongswan.android.ui.VpnTileService.updateTile (VpnTileService.java:220)
  at org.strongswan.android.ui.VpnTileService.onStartListening (VpnTileService.java:97)
  at android.service.quicksettings.TileService$H.handleMessage (TileService.java:407)

which violates the API documentation for getQsTile(), which states:

  This tile is only valid for updates between onStartListening() and
  onStopListening().

But apparently that's not always the case. There have been two reports
of such a crash, both on Android 8.0 and on Xiaomi Mi 5/6 devices, so
maybe it's a bug in that particular image.
This commit is contained in:
Tobias Brunner 2018-07-06 16:01:34 +02:00
parent 4bd4750131
commit 9fb00bf89f
1 changed files with 4 additions and 0 deletions

View File

@ -204,6 +204,10 @@ public class VpnTileService extends TileService implements VpnStateService.VpnSt
}
Tile tile = getQsTile();
if (tile == null)
{
return;
}
if (error != VpnStateService.ErrorState.NO_ERROR)
{