Skip to content

Commit

Permalink
Prevent AppInfo tab from crashing in Google Pixel/Android 14
Browse files Browse the repository at this point in the history
  • Loading branch information
MuntashirAkon committed Mar 18, 2024
1 parent 5597e88 commit 903f1dc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.github.muntashirakon.AppManager.ipc.ProxyBinder;
import io.github.muntashirakon.AppManager.self.SelfPermissions;
import io.github.muntashirakon.AppManager.users.Users;
import io.github.muntashirakon.AppManager.utils.ExUtils;

public class SubscriptionManagerCompat {
@SuppressWarnings("deprecation")
Expand All @@ -27,16 +28,22 @@ public static List<SubscriptionInfo> getActiveSubscriptionInfoList() {
ISub sub = getSub();
int uid = Users.getSelfOrRemoteUid();
String callingPackage = SelfPermissions.getCallingPackage(uid);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
try {
return sub.getActiveSubscriptionInfoList(callingPackage, null);
} catch (NoSuchMethodError e) {
// Google Pixel
return sub.getActiveSubscriptionInfoList(callingPackage, null, true);
}
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
return sub.getActiveSubscriptionInfoList(callingPackage, null);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return sub.getActiveSubscriptionInfoList(callingPackage);
}
return sub.getActiveSubscriptionInfoList();
} catch (RemoteException e) {
e.printStackTrace();
return ExUtils.rethrowFromSystemServer(e);
}
return null;
}

@SuppressWarnings("deprecation")
Expand All @@ -55,7 +62,7 @@ public static String getSubscriberIdForSubscriber(long subId) {
}
return sub.getSubscriberIdForSubscriber(subId);
} catch (RemoteException e) {
e.printStackTrace();
return ExUtils.rethrowFromSystemServer(e);
} catch (NullPointerException ignore) {
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public interface ISub extends IInterface {
@RequiresApi(Build.VERSION_CODES.R)
List<SubscriptionInfo> getActiveSubscriptionInfoList(String callingPackage, @Nullable String callingFeatureId) throws RemoteException;

/**
* Added in Google Pixel stock ROM
*/
@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
List<SubscriptionInfo> getActiveSubscriptionInfoList(String callingPackage, @Nullable String callingFeatureId, boolean allUsers) throws RemoteException;

abstract class Stub {
public static ISub asInterface(android.os.IBinder obj) {
return HiddenUtil.throwUOE(obj);
Expand Down

0 comments on commit 903f1dc

Please sign in to comment.