Skip to content

Commit

Permalink
[AppInfo] Prevent crashes in tablets running GSI FW
Browse files Browse the repository at this point in the history
Signed-off-by: Muntashir Al-Islam <[email protected]>
  • Loading branch information
MuntashirAkon committed Mar 28, 2024
1 parent 91714a2 commit f788888
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,23 @@
import java.util.List;

import io.github.muntashirakon.AppManager.ipc.ProxyBinder;
import io.github.muntashirakon.AppManager.logs.Log;
import io.github.muntashirakon.AppManager.self.SelfPermissions;
import io.github.muntashirakon.AppManager.users.Users;
import io.github.muntashirakon.AppManager.utils.ExUtils;

public class SubscriptionManagerCompat {
public static final String TAG = SubscriptionManagerCompat.class.getSimpleName();

@SuppressWarnings("deprecation")
@RequiresApi(Build.VERSION_CODES.LOLLIPOP_MR1)
@Nullable
public static List<SubscriptionInfo> getActiveSubscriptionInfoList() {
try {
ISub sub = getSub();
if (sub == null) {
return null;
}
int uid = Users.getSelfOrRemoteUid();
String callingPackage = SelfPermissions.getCallingPackage(uid);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
Expand All @@ -51,6 +57,9 @@ public static List<SubscriptionInfo> getActiveSubscriptionInfoList() {
public static String getSubscriberIdForSubscriber(long subId) {
try {
IPhoneSubInfo sub = getPhoneSubInfo();
if (sub == null) {
return null;
}
int uid = Users.getSelfOrRemoteUid();
String callingPackage = SelfPermissions.getCallingPackage(uid);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
Expand All @@ -68,11 +77,23 @@ public static String getSubscriberIdForSubscriber(long subId) {
return null;
}

@Nullable
private static ISub getSub() {
return ISub.Stub.asInterface(ProxyBinder.getService("isub"));
try {
return ISub.Stub.asInterface(ProxyBinder.getService("isub"));
} catch (NullPointerException e) {
Log.i(TAG, "No isub, Huawei GSI?", e);
return null;
}
}

@Nullable
private static IPhoneSubInfo getPhoneSubInfo() {
return IPhoneSubInfo.Stub.asInterface(ProxyBinder.getService("iphonesubinfo"));
try {
return IPhoneSubInfo.Stub.asInterface(ProxyBinder.getService("iphonesubinfo"));
} catch (NullPointerException e) {
Log.i(TAG, "No iphonesubinfo, Huawei GSI?", e);
return null;
}
}
}

0 comments on commit f788888

Please sign in to comment.