prevent crash

pull/183/head
M66B 5 years ago
parent 0356aac222
commit 2055d51390

@ -49,12 +49,26 @@ public class ServiceTileSynchronize extends TileService implements SharedPrefere
Log.i("Update tile synchronize=" + enabled);
Tile tile = getQsTile();
if (tile != null) {
tile.setState(enabled ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
tile.setIcon(Icon.createWithResource(this,
enabled ? R.drawable.baseline_sync_24 : R.drawable.baseline_sync_disabled_24));
tile.updateTile();
}
if (tile != null)
try {
tile.setState(enabled ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
tile.setIcon(Icon.createWithResource(this,
enabled ? R.drawable.baseline_sync_24 : R.drawable.baseline_sync_disabled_24));
tile.updateTile();
} catch (Throwable ex) {
Log.w(ex);
/*
java.lang.IllegalArgumentException: Service not registered: com.android.systemui.qs.external.TileLifecycleManager@9b4b3b0
at android.os.Parcel.createException(Parcel.java:1954)
at android.os.Parcel.readException(Parcel.java:1918)
at android.os.Parcel.readException(Parcel.java:1868)
at android.service.quicksettings.IQSService$Stub$Proxy.updateQsTile(IQSService.java:219)
at android.service.quicksettings.Tile.updateTile(Tile.java:182)
at eu.faircode.email.ServiceTileSynchronize.update(SourceFile:56)
at eu.faircode.email.ServiceTileSynchronize.onStartListening(SourceFile:37)
at android.service.quicksettings.TileService$H.handleMessage(TileService.java:407)
*/
}
}
public void onStopListening() {

@ -56,14 +56,18 @@ public class ServiceTileUnseen extends TileService {
Log.i("Update tile unseen=" + unseen);
Tile tile = getQsTile();
if (tile != null) {
tile.setState(unseen > 0 ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
tile.setIcon(Icon.createWithResource(ServiceTileUnseen.this,
unseen > 0 ? R.drawable.baseline_mail_24 : R.drawable.baseline_mail_outline_24));
tile.setLabel(getResources().getQuantityString(
R.plurals.title_tile_unseen, unseen, unseen));
tile.updateTile();
}
if (tile != null)
try {
tile.setState(unseen > 0 ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
tile.setIcon(Icon.createWithResource(ServiceTileUnseen.this,
unseen > 0 ? R.drawable.baseline_mail_24 : R.drawable.baseline_mail_outline_24));
tile.setLabel(getResources().getQuantityString(
R.plurals.title_tile_unseen, unseen, unseen));
tile.updateTile();
} catch (Throwable ex) {
Log.w(ex);
// See ServiceTileSynchronize
}
}
});
}

Loading…
Cancel
Save