mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-02 08:56:55 +00:00
Opening the system default wallpaper picker on clicking the wallpaper tile
Bug: 28790378 Change-Id: If283b60a0b9563ab8e80d49b0ffa195fc3ffda8a
This commit is contained in:
@@ -16,17 +16,22 @@
|
||||
|
||||
package com.android.launcher3.util;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
|
||||
import com.android.launcher3.Utilities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Utility methods using package manager
|
||||
*/
|
||||
public class PackageManagerHelper {
|
||||
|
||||
private static final int FLAG_SUSPENDED = 1<<30;
|
||||
private static final String LIVE_WALLPAPER_PICKER_PKG = "com.android.wallpaper.livepicker";
|
||||
|
||||
/**
|
||||
* Returns true if the app can possibly be on the SDCard. This is just a workaround and doesn't
|
||||
@@ -68,4 +73,27 @@ public class PackageManagerHelper {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the package for a wallpaper picker system app giving preference to a app which
|
||||
* is not as image picker.
|
||||
*/
|
||||
public static String getWallpaperPickerPackage(PackageManager pm) {
|
||||
ArrayList<String> excludePackages = new ArrayList<>();
|
||||
// Exclude packages which contain an image picker
|
||||
for (ResolveInfo info : pm.queryIntentActivities(
|
||||
new Intent(Intent.ACTION_GET_CONTENT).setType("image/*"), 0)) {
|
||||
excludePackages.add(info.activityInfo.packageName);
|
||||
}
|
||||
excludePackages.add(LIVE_WALLPAPER_PICKER_PKG);
|
||||
|
||||
for (ResolveInfo info : pm.queryIntentActivities(
|
||||
new Intent(Intent.ACTION_SET_WALLPAPER), 0)) {
|
||||
if (!excludePackages.contains(info.activityInfo.packageName) &&
|
||||
(info.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
|
||||
return info.activityInfo.packageName;
|
||||
}
|
||||
}
|
||||
return excludePackages.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user