Skip to content

Commit

Permalink
refactor(telephony): simplify the fix crash on Android 14
Browse files Browse the repository at this point in the history
Signed-off-by: iusmac <[email protected]>
  • Loading branch information
iusmac committed Apr 11, 2024
1 parent a52e627 commit 9ccf71e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/com/github/iusmac/sevensim/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public final class Utils {
public static final boolean IS_AT_LEAST_S = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S;
public static final boolean IS_AT_LEAST_T =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU;
public static final boolean IS_OLDER_THAN_R = Build.VERSION.SDK_INT < Build.VERSION_CODES.R;

/**
* This a backport of the {@code #BundleCompat.getParcelable} from <b>AndroidX Core v1.10.0</b>
Expand Down
18 changes: 9 additions & 9 deletions src/com/github/iusmac/sevensim/telephony/Subscriptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,22 @@ public Subscriptions(final @ApplicationContext Context context,
// We use hidden API to create listener with a custom looper before Android 11.0 (R), on
// newer versions, we can register the listener with a custom executor via
// SubscriptionsImpl#addOnSubscriptionsChangedListener()
if (Utils.IS_OLDER_THAN_R) {
mSubscriptionManagerListener =
new SubscriptionManager.OnSubscriptionsChangedListener(mContext.getMainLooper()) {
@Override
public void onSubscriptionsChanged() {
dispatchOnSubscriptionInfoRecordsChanged();
}
};
} else {
if (Utils.IS_AT_LEAST_R) {
mSubscriptionManagerListener =
new SubscriptionManager.OnSubscriptionsChangedListener() {
@Override
public void onSubscriptionsChanged() {
dispatchOnSubscriptionInfoRecordsChanged();
}
};
} else {
mSubscriptionManagerListener =
new SubscriptionManager.OnSubscriptionsChangedListener(mContext.getMainLooper()) {
@Override
public void onSubscriptionsChanged() {
dispatchOnSubscriptionInfoRecordsChanged();
}
};
}
}

Expand Down

0 comments on commit 9ccf71e

Please sign in to comment.