Skip to content

Commit

Permalink
fix: crash in work profile due to exceptions thrown by TileService (#498
Browse files Browse the repository at this point in the history
)

I fixed a crash issue caused by: [`TileService.requestListeningState`](https://developer.android.com/reference/android/service/quicksettings/TileService#requestListeningState(android.content.Context,%20android.content.ComponentName)) throwing exceptions if the user of the context is not the current user (might be a work profile user).

This is the new behavior since API level 33, so previously this issue is not found.
  • Loading branch information
jyyi1 authored Jan 31, 2024
1 parent 51b02c8 commit c0230af
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Android/app/src/main/java/app/intra/sys/IntraVpnService.java
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,14 @@ private void stopVpnAdapter() {

private void updateQuickSettingsTile() {
if (VERSION.SDK_INT >= VERSION_CODES.N) {
TileService.requestListeningState(this,
new ComponentName(this, IntraTileService.class));
try {
TileService.requestListeningState(this,
new ComponentName(this, IntraTileService.class));
} catch (SecurityException ignored) {
} catch (IllegalArgumentException ignored) {
// Starting from API level 33, TileService will throw exceptions from apps in Work Profile
// See: https://developer.android.com/reference/android/service/quicksettings/TileService
}
}
}

Expand Down

0 comments on commit c0230af

Please sign in to comment.