diff --git a/app/src/main/java/io/github/muntashirakon/AppManager/compat/PackageManagerCompat.java b/app/src/main/java/io/github/muntashirakon/AppManager/compat/PackageManagerCompat.java index 05de834beb9..2f61df8016f 100644 --- a/app/src/main/java/io/github/muntashirakon/AppManager/compat/PackageManagerCompat.java +++ b/app/src/main/java/io/github/muntashirakon/AppManager/compat/PackageManagerCompat.java @@ -437,7 +437,13 @@ public static int getApplicationEnabledSetting(String packageName, @UserIdInt in @RequiresPermission(allOf = {"android.permission.SUSPEND_APPS", ManifestCompat.permission.MANAGE_USERS}) public static void suspendPackages(String[] packageNames, @UserIdInt int userId, boolean suspend) throws RemoteException { String callingPackage = SelfPermissions.getCallingPackage(Users.getSelfOrRemoteUid()); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { + try { + getPackageManager().setPackagesSuspendedAsUser(packageNames, suspend, null, null, null, 0, callingPackage, 0, userId); + } catch (NoSuchMethodError e) { + getPackageManager().setPackagesSuspendedAsUser(packageNames, suspend, null, null, (SuspendDialogInfo) null, callingPackage, userId); + } + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { getPackageManager().setPackagesSuspendedAsUser(packageNames, suspend, null, null, (SuspendDialogInfo) null, callingPackage, userId); } else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.P) { getPackageManager().setPackagesSuspendedAsUser(packageNames, suspend, null, null, (String) null, callingPackage, userId); diff --git a/hiddenapi/src/main/java/android/content/pm/IPackageManager.java b/hiddenapi/src/main/java/android/content/pm/IPackageManager.java index d19e9eec308..da671bb482c 100644 --- a/hiddenapi/src/main/java/android/content/pm/IPackageManager.java +++ b/hiddenapi/src/main/java/android/content/pm/IPackageManager.java @@ -544,14 +544,14 @@ String[] setDistractingPackageRestrictionsAsUser(String[] packageNames, int rest int userId) throws RemoteException; /** - * @deprecated Removed in API 28 (Android P) + * @deprecated Replaced in API 28 (Android P) by {@link #setPackagesSuspendedAsUser(String[], boolean, PersistableBundle, PersistableBundle, String, String, int)} */ @Deprecated @RequiresApi(Build.VERSION_CODES.N) String[] setPackagesSuspendedAsUser(String[] packageNames, boolean suspended, int userId) throws RemoteException; /** - * @deprecated Removed in API 29 (Android Q) + * @deprecated Replaced in API 29 (Android Q) by {@link #setPackagesSuspendedAsUser(String[], boolean, PersistableBundle, PersistableBundle, SuspendDialogInfo, String, int)} */ @Deprecated @RequiresApi(Build.VERSION_CODES.P) @@ -559,11 +559,24 @@ String[] setPackagesSuspendedAsUser(String[] packageNames, boolean suspended, PersistableBundle appExtras, PersistableBundle launcherExtras, String dialogMessage, String callingPackage, int userId) throws RemoteException; + /** + * @deprecated Replaced in API 34 r29 (Android U) by {@link #setPackagesSuspendedAsUser(String[], boolean, PersistableBundle, PersistableBundle, SuspendDialogInfo, int, String, int, int)} + */ + @Deprecated @RequiresApi(Build.VERSION_CODES.Q) String[] setPackagesSuspendedAsUser(String[] packageNames, boolean suspended, PersistableBundle appExtras, PersistableBundle launcherExtras, SuspendDialogInfo dialogInfo, String callingPackage, int userId) throws RemoteException; + /** + * Introduced in API 34 r29 + */ + @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) + String[] setPackagesSuspendedAsUser(String[] packageNames, boolean suspended, + PersistableBundle appExtras, PersistableBundle launcherExtras, + SuspendDialogInfo dialogInfo, int flags, String suspendingPackage, + int suspendingUserId, int targetUserId) throws RemoteException; + @RequiresApi(Build.VERSION_CODES.N) boolean isPackageSuspendedForUser(String packageName, int userId) throws RemoteException;