Skip to content

Commit

Permalink
Add QUERY_ALL_PACKAGES permission for Android 11
Browse files Browse the repository at this point in the history
  • Loading branch information
TacoTheDank committed Jul 2, 2021
1 parent f7ec4d5 commit c4c6f41
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
<uses-permission
android:name="android.permission.READ_LOGS"
tools:ignore="ProtectedPermissions" />
<!-- https://developer.android.com/about/versions/11/privacy/package-visibility -->
<uses-permission
android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />

<application
android:name=".ScoopApplication"
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/taco/scoop/data/app/AppLoader.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package taco.scoop.data.app;

import android.annotation.SuppressLint;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;

Expand All @@ -14,11 +15,12 @@ public class AppLoader {

private WeakReference<BlacklistAppsActivity> mListener;

@SuppressLint("QueryPermissionsNeeded")
public void loadData(BlacklistAppsActivity activity) {
mListener = new WeakReference<>(activity);
new Thread(() -> {
PackageManager pm = mListener.get().getPackageManager();
// TODO: Deal with https://developer.android.com/about/versions/11/privacy/package-visibility
// https://developer.android.com/about/versions/11/privacy/package-visibility
List<ApplicationInfo> apps = pm.getInstalledApplications(0);
Collections.sort(apps, new ApplicationInfo.DisplayNameComparator(pm));
final ArrayList<App> finalApps = new ArrayList<>();
Expand Down

0 comments on commit c4c6f41

Please sign in to comment.