Annotation Nullable (#2394)

This commit is contained in:
Howard Wu 2023-02-24 11:31:27 +08:00 committed by GitHub
parent 3d11c2f0f7
commit 9b1907adfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 9 deletions

View File

@ -47,6 +47,7 @@ import android.util.Log;
import android.util.Pair;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.lsposed.lspd.models.Application;
@ -105,6 +106,7 @@ public class PackageService {
return pm;
}
@Nullable
public static PackageInfo getPackageInfo(String packageName, int flags, int userId) throws RemoteException {
IPackageManager pm = getPackageManager();
if (pm == null) return null;
@ -126,6 +128,7 @@ public class PackageService {
return res;
}
@Nullable
public static ApplicationInfo getApplicationInfo(String packageName, int flags, int userId) throws RemoteException {
IPackageManager pm = getPackageManager();
if (pm == null) return null;
@ -206,6 +209,7 @@ public class PackageService {
}
@SuppressWarnings({"ConstantConditions", "SameParameterValue"})
@Nullable
private static PackageInfo getPackageInfoWithComponents(String packageName, int flags, int userId) throws RemoteException {
IPackageManager pm = getPackageManager();
if (pm == null) return null;
@ -291,7 +295,9 @@ public class PackageService {
}
}
public static ParcelableListSlice<ResolveInfo> queryIntentActivities(Intent intent, String resolvedType, int flags, int userId) throws RemoteException {
@Nullable
public static ParcelableListSlice<ResolveInfo> queryIntentActivities(Intent intent, String resolvedType, int flags, int userId) {
try {
IPackageManager pm = getPackageManager();
if (pm == null) return null;
ParceledListSlice<ResolveInfo> infos;
@ -301,8 +307,13 @@ public class PackageService {
infos = pm.queryIntentActivities(intent, resolvedType, flags, userId);
}
return new ParcelableListSlice<>(infos.getList());
} catch (Exception e) {
Log.e(TAG, "queryIntentActivities", e);
return new ParcelableListSlice<>(new ArrayList<>());
}
}
@Nullable
public static Intent getLaunchIntentForPackage(String packageName) throws RemoteException {
Intent intentToResolve = new Intent(Intent.ACTION_MAIN);
intentToResolve.addCategory(Intent.CATEGORY_INFO);