summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/Launcher.java12
-rw-r--r--src/com/android/launcher3/util/PackageManagerHelper.java28
2 files changed, 38 insertions, 2 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 6d5b203c1..3ce07e3ea 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -115,6 +115,7 @@ import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.logging.FileLog;
+import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.TestingUtils;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.ViewOnDrawExecutor;
@@ -2715,10 +2716,17 @@ public class Launcher extends Activity
return;
}
- if (LOGD) Log.d(TAG, "onClickWallpaperPicker");
+ String pickerPackage = getString(R.string.wallpaper_picker_package);
+ if (TextUtils.isEmpty(pickerPackage)) {
+ pickerPackage = PackageManagerHelper.getWallpaperPickerPackage(getPackageManager());
+ }
+
int pageScroll = mWorkspace.getScrollForPage(mWorkspace.getPageNearestToCenterOfScreen());
float offset = mWorkspace.mWallpaperOffset.wallpaperOffsetForScroll(pageScroll);
- // TODO: Start the system wallpaper picker
+ startActivityForResult(new Intent(Intent.ACTION_SET_WALLPAPER)
+ .setPackage(pickerPackage)
+ .putExtra(Utilities.EXTRA_WALLPAPER_OFFSET, offset),
+ REQUEST_PICK_WALLPAPER);
}
/**
diff --git a/src/com/android/launcher3/util/PackageManagerHelper.java b/src/com/android/launcher3/util/PackageManagerHelper.java
index 08e8e869d..3c4c79aec 100644
--- a/src/com/android/launcher3/util/PackageManagerHelper.java
+++ b/src/com/android/launcher3/util/PackageManagerHelper.java
@@ -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);
+ }
}